leafer-ui 1.0.0-rc.7 → 1.0.0-rc.8

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/README.md CHANGED
@@ -4,7 +4,7 @@ Leafer UI 是基于 Leafer 开发的一套绚丽多彩的 UI 绘图框架,可
4
4
 
5
5
  提供了常用的 UI 绘图组件,和开箱即用的功能,方便与 Figma、Sketch 等产品进行数据交换,并为跨平台开发提供了统一、丰富的交互事件,如拖拽、旋转、缩放手势等。
6
6
 
7
- 1.0.0-rc.7 已发布 🎉🎉🎉,查看 [更新日志](https://leaferjs.com/ui/update/)。
7
+ 1.0.0-rc.8 已发布 🎉🎉🎉,查看 [更新日志](https://leaferjs.com/ui/update/)。
8
8
 
9
9
  目前产品已经逐步稳定,正式版即将到来,感谢所有参与的朋友们~
10
10
 
package/dist/web.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, Platform, AnimateEvent, ResizeEvent, BoundsHelper, Creator, LeaferCanvasBase, Cursor, canvasSizeAttrs, canvasPatch, InteractionHelper, MathHelper, InteractionBase, LeaferImage, FileHelper, MatrixHelper, ImageEvent, PointHelper, TaskProcessor } from '@leafer/core';
1
+ import { LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, Platform, AnimateEvent, ResizeEvent, BoundsHelper, Creator, LeaferCanvasBase, Cursor, canvasSizeAttrs, canvasPatch, InteractionHelper, MathHelper, InteractionBase, LeaferImage, FileHelper, MatrixHelper, ImageEvent, PointHelper, Direction4, TaskProcessor } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { ColorConvert as ColorConvert$1, ImageManager as ImageManager$1, Paint, Effect, TextConvert as TextConvert$1, Export as Export$2 } from '@leafer-ui/core';
@@ -833,6 +833,7 @@ class LeaferCanvas extends LeaferCanvasBase {
833
833
  view ? this.__createViewFrom(view) : this.__createView();
834
834
  const { style } = this.view;
835
835
  style.display || (style.display = 'block');
836
+ style.userSelect = 'none';
836
837
  this.parentView = this.view.parentElement;
837
838
  if (Platform.syncDomFont && !this.parentView) {
838
839
  this.view.style.display = 'none';
@@ -1441,7 +1442,7 @@ function repeatMode(data, box, width, height, scale, rotation) {
1441
1442
  const { get: get$3, translate } = MatrixHelper;
1442
1443
  function createData(leafPaint, image, paint, box) {
1443
1444
  let { width, height } = image;
1444
- const { opacity, mode, offset, scale, rotation, blendMode } = paint;
1445
+ const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint;
1445
1446
  const sameBox = box.width === width && box.height === height;
1446
1447
  if (blendMode)
1447
1448
  leafPaint.blendMode = blendMode;
@@ -1462,6 +1463,8 @@ function createData(leafPaint, image, paint, box) {
1462
1463
  case 'repeat':
1463
1464
  if (!sameBox || scale || rotation)
1464
1465
  repeatMode(data, box, width, height, scale, rotation);
1466
+ if (!repeat)
1467
+ data.repeat = 'repeat';
1465
1468
  break;
1466
1469
  case 'fit':
1467
1470
  case 'cover':
@@ -1473,6 +1476,8 @@ function createData(leafPaint, image, paint, box) {
1473
1476
  data.height = height;
1474
1477
  if (opacity)
1475
1478
  data.opacity = opacity;
1479
+ if (repeat)
1480
+ data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
1476
1481
  }
1477
1482
 
1478
1483
  function image(ui, attrName, attrValue, box, firstUse) {
@@ -1519,11 +1524,11 @@ function hasNaturalSize(ui, attrName, image) {
1519
1524
  d.__naturalWidth = image.width;
1520
1525
  d.__naturalHeight = image.height;
1521
1526
  if (!d.__getInput('width') || !d.__getInput('height')) {
1527
+ ui.forceUpdate('width');
1522
1528
  if (ui.__proxyData) {
1523
1529
  ui.setProxyAttr('width', ui.__.width);
1524
1530
  ui.setProxyAttr('height', ui.__.height);
1525
1531
  }
1526
- ui.forceUpdate('width');
1527
1532
  return false;
1528
1533
  }
1529
1534
  }
@@ -1576,7 +1581,7 @@ function createPattern(ui, paint, pixelRatio) {
1576
1581
  scaleX = Math.abs(scaleX);
1577
1582
  scaleY = Math.abs(scaleY);
1578
1583
  const { image, data } = paint;
1579
- let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
1584
+ let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
1580
1585
  if (sx) {
1581
1586
  imageMatrix = get$2();
1582
1587
  copy$1(imageMatrix, transform);
@@ -1589,7 +1594,7 @@ function createPattern(ui, paint, pixelRatio) {
1589
1594
  width *= scaleX;
1590
1595
  height *= scaleY;
1591
1596
  const size = width * height;
1592
- if (paint.data.mode !== 'repeat') {
1597
+ if (!repeat) {
1593
1598
  if (size > Platform.image.maxCacheSize)
1594
1599
  return false;
1595
1600
  }
@@ -1619,7 +1624,7 @@ function createPattern(ui, paint, pixelRatio) {
1619
1624
  }
1620
1625
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1621
1626
  }
1622
- const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), mode === 'repeat' ? 'repeat' : (Platform.origin.noRepeat || 'no-repeat'));
1627
+ const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), repeat || (Platform.origin.noRepeat || 'no-repeat'));
1623
1628
  try {
1624
1629
  if (paint.transform)
1625
1630
  paint.transform = null;
@@ -1647,7 +1652,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1647
1652
  else {
1648
1653
  const { data } = paint;
1649
1654
  if (allowPaint) {
1650
- if (data.mode !== 'repeat') {
1655
+ if (!data.repeat) {
1651
1656
  let { width, height } = data;
1652
1657
  width *= abs(scaleX) * canvas.pixelRatio;
1653
1658
  height *= abs(scaleY) * canvas.pixelRatio;
@@ -2647,6 +2652,7 @@ function decorationText(drawData, style) {
2647
2652
  }
2648
2653
  }
2649
2654
 
2655
+ const { top, right, bottom, left } = Direction4;
2650
2656
  const TextConvert = {
2651
2657
  getDrawData(content, style) {
2652
2658
  if (typeof content !== 'string')
@@ -2654,16 +2660,15 @@ const TextConvert = {
2654
2660
  let x = 0, y = 0;
2655
2661
  let width = style.__getInput('width') || 0;
2656
2662
  let height = style.__getInput('height') || 0;
2657
- const { textDecoration, __font, padding } = style;
2663
+ const { textDecoration, __font, __padding: padding } = style;
2658
2664
  if (padding) {
2659
- const [top, right, bottom, left] = MathHelper.fourNumber(padding);
2660
2665
  if (width) {
2661
- x = left;
2662
- width -= (right + left);
2666
+ x = padding[left];
2667
+ width -= (padding[right] + padding[left]);
2663
2668
  }
2664
2669
  if (height) {
2665
- y = top;
2666
- height -= (top + bottom);
2670
+ y = padding[top];
2671
+ height -= (padding[top] + padding[bottom]);
2667
2672
  }
2668
2673
  }
2669
2674
  const drawData = {
@@ -2673,6 +2678,8 @@ const TextConvert = {
2673
2678
  font: Platform.canvas.font = __font
2674
2679
  };
2675
2680
  createRows(drawData, content, style);
2681
+ if (padding)
2682
+ padAutoText(padding, drawData, style, width, height);
2676
2683
  layoutText(drawData, style);
2677
2684
  layoutChar(drawData, style, width);
2678
2685
  if (drawData.overflow)
@@ -2682,6 +2689,32 @@ const TextConvert = {
2682
2689
  return drawData;
2683
2690
  }
2684
2691
  };
2692
+ function padAutoText(padding, drawData, style, width, height) {
2693
+ if (!width) {
2694
+ switch (style.textAlign) {
2695
+ case 'left':
2696
+ offsetText(drawData, 'x', padding[left]);
2697
+ break;
2698
+ case 'right':
2699
+ offsetText(drawData, 'x', -padding[right]);
2700
+ }
2701
+ }
2702
+ if (!height) {
2703
+ switch (style.verticalAlign) {
2704
+ case 'top':
2705
+ offsetText(drawData, 'y', padding[top]);
2706
+ break;
2707
+ case 'bottom':
2708
+ offsetText(drawData, 'y', -padding[bottom]);
2709
+ }
2710
+ }
2711
+ }
2712
+ function offsetText(drawData, attrName, value) {
2713
+ const { bounds, rows } = drawData;
2714
+ bounds[attrName] += value;
2715
+ for (let i = 0; i < rows.length; i++)
2716
+ rows[i][attrName] += value;
2717
+ }
2685
2718
 
2686
2719
  const ColorConvert = {
2687
2720
  string(color, opacity) {
@@ -1 +1 @@
1
- import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as o,LeafHelper as r,BranchHelper as a,Bounds as h,LeafBoundsHelper as d,Debug as l,LeafLevelList as c,LayoutEvent as u,Run as g,ImageManager as p,Platform as f,AnimateEvent as _,ResizeEvent as w,BoundsHelper as v,Creator as y,LeaferCanvasBase as m,Cursor as x,canvasSizeAttrs as b,canvasPatch as B,InteractionHelper as E,MathHelper as L,InteractionBase as R,LeaferImage as M,FileHelper as T,MatrixHelper as k,ImageEvent as C,PointHelper as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as O,ImageManager as D,Paint as P,Effect as W,TextConvert as I,Export as F}from"@leafer-ui/core";export*from"@leafer-ui/core";class Y{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,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(i.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===s.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 n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(o.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.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:z,updateBounds:N,updateAllWorldOpacity:U}=r,{pushAllChildBranch:V,pushAllParent:j}=a;const{worldBounds:G}=d,X={x:0,y:0,width:1e5,height:1e5};class H{constructor(e){this.updatedBounds=new h,this.beforeBounds=new h,this.afterBounds=new h,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,G)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(X):this.afterBounds.setListWithFn(t,G),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:q,updateAllChange:K}=r,Q=l.get("Layouter");class ${constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new c,this.target=t,i&&(this.config=e.default(i,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(u.START),this.layoutOnce(),t.emitEvent(new u(u.END,this.layoutedBlocks,this.times))}catch(t){Q.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Q.warn("layouting"):this.times>3?Q.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.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=g.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=u,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new u(n,a,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?(z(t,!0),e.add(t),t.isBranch&&V(t,e),j(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),j(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||N(s[t])}N(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&U(t),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new u(o,a,this.times)),i.emitEvent(new u(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,g.end(e)}fullLayout(){const e=g.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=u,r=this.getBlocks(new t(i));i.emitEvent(new u(s,r,this.times)),$.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new u(n,r,this.times)),i.emitEvent(new u(o,r,this.times)),this.addBlocks(r),g.end(e)}static fullLayout(t){q(t,!0),t.isBranch?a.updateBounds(t):r.updateBounds(t),K(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new H([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new H(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_(u.REQUEST,this.layout,this),t.on_(u.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Z=l.get("Renderer");class J{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(u.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new h,Z.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),p.clearRecycled()}catch(t){this.rendering=!1,Z.error(t)}Z.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Z.warn("rendering"):this.times>3?Z.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new h,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Z.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=g.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new h(s);i.save(),n&&!l.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),g.end(e)}fullRender(){const t=g.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),g.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),l.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),l.showHitView&&this.renderHitView(s),l.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new h;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();f.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(_.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new h(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Z.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(u.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}var tt;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(tt||(tt={}));const{hitRadiusPoint:et}=v;class it{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;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),a=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:a,leaf:r,throughPath:o.length?this.getThroughPath(o):a}:{path:a,leaf:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],r.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.add(e),e=e.parent;return i.add(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.addAt(s,0),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,o,r;for(let t=0,e=s.length;t<e;t++){n=s[t],o=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!o||!o.has(r));t++)i.add(r)}return i}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.__.isMask||(s=!!i.__.hitRadius||et(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){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:st,NoAndSkip:nt,YesAndSkip:ot}=tt;class rt{constructor(t,i){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},this.target=t,i&&(this.config=e.default(i,this.config)),this.pather=new it(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,e,i){return"node"===f.name&&this.target.emit(u.CHECK_UPDATE),this.pather.getByPoint(t,e,i)}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&&r.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 r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),o===st||o===ot){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<nt&&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_(s.REMOVE,this.__onRemoveChild,this),this.target.on_(o.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.pather.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(y,{watcher:(t,e)=>new Y(t,e),layouter:(t,e)=>new $(t,e),renderer:(t,e,i)=>new J(t,e,i),selector:(t,e)=>new rt(t,e)}),f.layout=$.fullLayout;const at=l.get("LeaferCanvas");class ht extends m{init(){const{view:t}=this.config;t?this.__createViewFrom(t):this.__createView();const{style:e}=this.view;e.display||(e.display="block"),this.parentView=this.view.parentElement,f.syncDomFont&&!this.parentView&&(this.view.style.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(this.config)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}setCursor(t){const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&x.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;if(t.hasChildNodes()){const{style:e}=i;e.position="absolute",e.top=e.left="0px",t.style.position||(t.style.position="relative")}t.appendChild(i)}else at.error(`no id: ${t}`),this.__createView()}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=t*i,this.view.height=e*i}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(t,e){this.autoBounds=t,this.resizeListener=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t&&(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect()))}catch(t){this.imitateResizeObserver()}}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),f.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const i=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t);if(o!==this.width||r!==this.height){const{style:t}=i,{pixelRatio:a}=this;t.marginLeft=s+"px",t.marginTop=n+"px";const h={width:o,height:r,pixelRatio:a},d={};e.copyAttrs(d,this,b),this.resize(h),void 0!==this.width&&this.resizeListener(new w(h,d))}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}B(CanvasRenderingContext2D.prototype),B(Path2D.prototype);const dt={convert(t,e){const i=E.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=E.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=dt.getTouch(t),s=E.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},lt={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;return t.shiftKey&&!s&&(s=n,n=0),s>50&&(s=Math.max(50,s/3)),n>50&&(n=Math.max(50,n/3)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let i,s=1,{zoomMode:n,zoomSpeed:o}=e;const r=t.deltaY||t.deltaX;if(n?(i="mouse"===n||!t.deltaX&&(f.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){o=L.within(o,0,1);s=1-r/(25*(t.deltaY?e.delta.y:e.delta.x)*(1-o)+10),s<.5&&(s=.5),s>=1.5&&(s=1.5)}return s}},ct={convert(t){const e=E.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{getMoveEventData:ut,getZoomEventData:gt,getRotateEventData:pt}=E;class ft extends R{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getLocal(t,e){e&&this.canvas.updateClientBounds();const{clientBounds:i}=this.canvas;return{x:t.clientX-i.x,y:t.clientY-i.y}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(ct.convert(t))}onKeyUp(t){this.keyUp(ct.convert(t))}onContextMenu(t){this.menu(dt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.usePointer||(this.usePointer=!0),this.useMultiTouch||this.pointerDown(dt.convert(t,this.getLocal(t)))}onPointerMove(t){this.usePointer||(this.usePointer=!0),this.useMultiTouch||this.preventWindowPointer(t)||this.pointerMove(dt.convert(t,this.getLocal(t,!0)))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(dt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(dt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(dt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(dt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){if(t.preventDefault(),this.multiTouchStart(t),this.usePointer)return;this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0;const e=dt.getTouch(t);this.pointerDown(dt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=dt.getTouch(t);this.pointerMove(dt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=dt.getTouch(t);this.pointerUp(dt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>=2,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(E.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)))}onWheel(t){this.preventDefaultWheel(t);const{wheel:e}=this.config,i=e.getScale?e.getScale(t,e):lt.getScale(t,e),s=this.getLocal(t),n=E.getBase(t);1!==i?this.zoom(gt(s,i,n)):this.move(ut(s,e.getMove?e.getMove(t,e):lt.getMove(t,e),n))}onGesturestart(t){this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0}onGesturechange(t){this.preventDefaultWheel(t);const e=this.getLocal(t),i=E.getBase(t),s=t.scale/this.lastGestureScale,n=t.rotation-this.lastGestureRotation;let{rotateSpeed:o}=this.config.wheel;o=L.within(o,0,1),this.zoom(gt(e,s*s,i)),this.rotate(pt(e,n/Math.PI*180*(o/4+.1),i)),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.preventDefaultWheel(t),this.transformEnd()}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}const{mineType:_t,fileType:wt}=T;function vt(t,e){f.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(_t(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,_t(e),i))),canvasSaveAs:(t,e,i)=>new Promise((s=>{let n=document.createElement("a");n.href=t.toDataURL(_t(wt(e)),i),n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),s()})),loadImage:t=>new Promise(((e,i)=>{const s=new Image;s.setAttribute("crossOrigin","anonymous"),s.crossOrigin="anonymous",s.onload=()=>{e(s)},s.onerror=t=>{i(t)},!t.startsWith("data:")&&f.image.suffix&&(t+=(t.includes("?")?"&":"?")+f.image.suffix),s.src=t}))},f.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},f.canvas=y.canvas(),f.conicGradientSupport=!!f.canvas.context.createConicGradient}Object.assign(y,{canvas:(t,e)=>new ht(t,e),image:t=>new M(t),hitCanvas:(t,e)=>new ht(t,e),interaction:(t,e,i,s)=>new ft(t,e,i,s)}),f.name="web",f.isMobile="ontouchstart"in window,f.requestRender=function(t){window.requestAnimationFrame(t)},f.devicePixelRatio=Math.max(1,devicePixelRatio);const{userAgent:yt}=navigator;yt.indexOf("Firefox")>-1?(f.conicGradientRotate90=!0,f.intWheelDeltaY=!0,f.syncDomFont=!0):yt.indexOf("Safari")>-1&&-1===yt.indexOf("Chrome")&&(f.fullImageShadow=!0),yt.indexOf("Windows")>-1?(f.os="Windows",f.intWheelDeltaY=!0):yt.indexOf("Mac")>-1?f.os="Mac":yt.indexOf("Linux")>-1&&(f.os="Linux");const{get:mt,rotateOfOuter:xt,translate:bt,scaleOfOuter:Bt,scale:Et,rotate:Lt}=k;const{get:Rt,translate:Mt}=k;function Tt(t,e,i,s){let{width:n,height:o}=e;const{opacity:r,mode:a,offset:h,scale:d,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===o;c&&(t.blendMode=c);const g=t.data={mode:a};switch(a){case"strench":u||(n=s.width,o=s.height),(s.x||s.y)&&(g.transform=Rt(),Mt(g.transform,s.x,s.y));break;case"clip":(h||d||l)&&function(t,e,i,s,n){const o=mt();bt(o,e.x,e.y),i&&bt(o,i.x,i.y),s&&("number"==typeof s?Et(o,s):Et(o,s.x,s.y),t.scaleX=o.a,t.scaleY=o.d),n&&Lt(o,n),t.transform=o}(g,s,h,d,l);break;case"repeat":(!u||d||l)&&function(t,e,i,s,n,o){const r=mt();if(o)switch(Lt(r,o),o){case 90:bt(r,s,0);break;case 180:bt(r,i,s);break;case 270:bt(r,0,i)}bt(r,e.x,e.y),n&&(Bt(r,e,n),t.scaleX=t.scaleY=n),t.transform=r}(g,s,n,o,d,l);break;default:u&&!l||function(t,e,i,s,n,o){const r=mt(),a=o&&180!==o,h=i.width/(a?n:s),d=i.height/(a?s:n),l="fit"===e?Math.min(h,d):Math.max(h,d),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;bt(r,c,u),Et(r,l),o&&xt(r,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=l,t.transform=r}(g,a,s,n,o,l)}g.width=n,g.height=o,r&&(g.opacity=r)}function kt(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.__proxyData&&(t.setProxyAttr("width",t.__.width),t.setProxyAttr("height",t.__.height)),t.forceUpdate("width"),!1}return!0}function Ct(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new C(t,e))}function St(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(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(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const At={},{get:Ot,scale:Dt,copy:Pt}=k;function Wt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const o=s+"-"+n;if(e.patternId===o||t.destroyed)return!1;{s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e;let a,h,{width:d,height:l,scaleX:c,scaleY:u,opacity:g,transform:p,mode:_}=r;c&&(h=Ot(),Pt(h,p),Dt(h,1/c,1/u),s*=c,n*=u),s*=i,n*=i,d*=s,l*=n;const w=d*l;if("repeat"!==e.data.mode&&w>f.image.maxCacheSize)return!1;let v=f.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}w>v&&(a=Math.sqrt(w/v)),a&&(s/=a,n/=a,d/=a,l/=a),c&&(s/=c,n/=u),(p||1!==s||1!==n)&&(h||(h=Ot(),p&&Pt(h,p)),Dt(h,1/s,1/n));const y=f.canvas.createPattern(t.getCanvas(d<1?1:d,l<1?1:l,g),"repeat"===_?"repeat":f.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),h&&(y.setTransform?y.setTransform(h):e.transform=h)}catch(t){e.transform=h}return e.style=y,e.patternId=o,!0}}const{abs:It}=Math;function Ft(t,e,i,s){const{scaleX:n,scaleY:o}=t.__world;if(i.data&&i.patternId!==n+"-"+o){const{data:r}=i;if(s)if("repeat"!==r.mode){let{width:t,height:i}=r;t*=It(n)*e.pixelRatio,i*=It(o)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>f.image.maxCacheSize}else s=!1;return s?(e.save(),e.clip(),i.blendMode&&(e.blendMode=i.blendMode),r.opacity&&(e.opacity*=r.opacity),r.transform&&e.transform(r.transform),e.drawImage(i.image.view,0,0,r.width,r.height),e.restore(),!0):(!i.style||At.running?Wt(t,i,e.pixelRatio):i.patternTask||(i.patternTask=p.patternTasker.add((()=>St(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&Wt(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1}function Yt(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,p.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null}function zt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;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 Nt(t,e,i,s){const{strokeAlign:n}=e.__,o="string"!=typeof t;switch(n){case"center":i.setStroke(o?void 0:t,e.__.strokeWidth,e.__),o?jt(t,!0,e,i):Vt(e,i);break;case"inside":Ut("inside",t,o,e,i,s);break;case"outside":Ut("outside",t,o,e,i,s)}}function Ut(t,e,i,s,n,o){const{strokeWidth:r,__font:a}=s.__,h=n.getSameCanvas(!0);h.setStroke(i?void 0:e,2*r,s.__),h.font=a,i?jt(e,!0,s,h):Vt(s,h),h.blendMode="outside"===t?"destination-out":"destination-in",zt(s,h),h.blendMode="normal",s.__worldFlipped||o.matrix?n.copyWorldByReset(h):n.copyWorldToInner(h,s.__world,s.__layout.renderBounds),h.recycle()}function Vt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;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 jt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&Ft(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Vt(i,s):s.stroke(),s.restoreBlendMode()):e?Vt(i,s):s.stroke())}const{getSpread:Gt,getOuterOf:Xt,getByMove:Ht,getIntersectData:qt}=v;const Kt={x:.5,y:0},Qt={x:.5,y:1};function $t(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,O.string(s.color,i))}const{set:Zt,getAngle:Jt,getDistance:te}=S,{get:ee,rotateOfOuter:ie,scaleOfOuter:se}=k,ne={x:.5,y:.5},oe={x:.5,y:1},re={},ae={};const{set:he,getAngle:de,getDistance:le}=S,{get:ce,rotateOfOuter:ue,scaleOfOuter:ge}=k,pe={x:.5,y:.5},fe={x:.5,y:1},_e={},we={};let ve;function ye(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:r,opacity:a}=e;return{type:n,blendMode:o,style:O.string(r,a)};case"image":return function(t,e,i,s,n){const o={type:i.type},r=o.image=p.get(i),a=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(kt(t,e,r)&&Tt(o,r,i,s),n&&(Ct(C.LOAD,a),Ct(C.LOADED,a))):r.error?n&&(t.forceUpdate("surface"),a.error=r.error,Ct(C.ERROR,a)):(n&&Ct(C.LOAD,a),o.loadId=r.load((()=>{t.destroyed||(kt(t,e,r)&&(Tt(o,r,i,s),t.forceUpdate("surface")),Ct(C.LOADED,a))}),(e=>{t.forceUpdate("surface"),a.error=e,Ct(C.ERROR,a)}))),o}(i,t,e,s,!ve||!ve[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:o,opacity:r}=t;i||(i=Kt),s||(s=Qt);const a=f.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);$t(a,t.stops,r);const h={type:n,style:a};return o&&(h.blendMode=o),h}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=ne),s||(s=oe);const{x:h,y:d,width:l,height:c}=e;let u;Zt(re,h+i.x*l,d+i.y*c),Zt(ae,h+s.x*l,d+s.y*c),(l!==c||a)&&(u=ee(),se(u,re,l/c*(a||1),1),ie(u,re,Jt(re,ae)+90));const g=f.canvas.createRadialGradient(re.x,re.y,0,re.x,re.y,te(re,ae));$t(g,t.stops,o);const p={type:n,style:g,transform:u};return r&&(p.blendMode=r),p}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=pe),s||(s=fe);const{x:h,y:d,width:l,height:c}=e;he(_e,h+i.x*l,d+i.y*c),he(we,h+s.x*l,d+s.y*c);const u=ce(),g=de(_e,we);f.conicGradientRotate90?(ge(u,_e,l/c*(a||1),1),ue(u,_e,g+90)):(ge(u,_e,1,l/c*(a||1)),ue(u,_e,g));const p=f.conicGradientSupport?f.canvas.createConicGradient(0,_e.x,_e.y):f.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,le(_e,we));$t(p,t.stops,o);const _={type:n,style:p,transform:u};return r&&(_.blendMode=r),_}(e,s);default:return e.r?{type:"solid",style:O.string(e)}:void 0}}var me=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,o,r=s.__input[t];r instanceof Array||(r=[r]),ve=Yt(t,s);for(let s=0,o=r.length;s<o;s++)n=ye(t,r[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===r.length){const t=r[0];"image"===t.type&&(o=D.isPixel(t))}"fill"===t?s.__pixelFill=o:s.__pixelStroke=o},drawTextStroke:Vt,fill:function(t,e,i){i.fillStyle=t,e.__.__font?zt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:zt,fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&Ft(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?zt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?zt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?zt(e,i):n?i.fill(n):i.fill())},recycleImage:Yt,shape:function(t,e,i){const s=e.getSameCanvas();let n,o,r,a;const{__world:h}=t;let{scaleX:d,scaleY:l}=h;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(h,i.matrix))i.matrix?(d*=i.matrix.a,l*=i.matrix.d,n=r=Xt(h,i.matrix)):n=r=h,a=s;else{const{renderShapeSpread:s}=t.__layout,c=qt(s?Gt(e.bounds,s*d,s*l):e.bounds,h,i.matrix);o=e.bounds.getFitMatrix(c),o.a<1&&(a=e.getSameCanvas(),t.__renderShape(a,i),d*=o.a,l*=o.d),r=Xt(h,o),n=Ht(r,-o.e,-o.f),i.matrix&&o.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:o})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:n,worldCanvas:a,shapeBounds:r,scaleX:d,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)Nt(t,e,i,s);else switch(r){case"center":i.setStroke(t,o,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const r=i.getSameCanvas(!0);r.setStroke(t,2*o,e.__),e.__drawRenderPath(r),r.stroke(),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(e.__layout.renderBounds),e.__worldFlipped||s.matrix?i.copyWorldByReset(r):i.copyWorldToInner(r,e.__world,e.__layout.renderBounds),r.recycle()}},strokeText:Nt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)Nt(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,o,n),jt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),jt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:r}=e.__layout,a=i.getSameCanvas(!0);e.__drawRenderPath(a),a.setStroke(void 0,2*o,e.__),jt(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(r),e.__worldFlipped||s.matrix?i.copyWorldByReset(a):i.copyWorldToInner(a,e.__world,r),a.recycle()}}});const{copy:xe,toOffsetOutBounds:be}=v,Be={},Ee={};function Le(t,e,i,s){const{bounds:n,shapeBounds:o}=s;if(f.fullImageShadow){if(xe(Be,t.bounds),Be.x+=e.x-o.x,Be.y+=e.y-o.y,i){const{matrix:t}=s;Be.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),Be.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),Be.width*=i,Be.height*=i}t.copyWorld(s.canvas,t.bounds,Be)}else i&&(xe(Be,e),Be.x-=e.width/2*(i-1),Be.y-=e.height/2*(i-1),Be.width*=i,Be.height*=i),t.copyWorld(s.canvas,o,i?Be:e)}const{toOffsetOutBounds:Re}=v,Me={};var Te=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{innerShadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:g}=i,p=e.getSameCanvas(),f=h.length-1;Re(l,Me),h.forEach(((h,_)=>{p.save(),p.setWorldShadow(Me.offsetX+h.x*u,Me.offsetY+h.y*g,h.blur*u),o=h.spread?1-2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Le(p,Me,o,i),p.restore(),d?(p.copyWorld(p,l,r,"copy"),p.copyWorld(d,r,r,"source-out"),n=r):(p.copyWorld(i.canvas,c,l,"source-out"),n=l),p.fillWorld(n,h.color,"source-in"),t.__worldFlipped||s.matrix?e.copyWorldByReset(p,n,r,h.blendMode):e.copyWorldToInner(p,n,a.renderBounds,h.blendMode),f&&_<f&&p.clear()})),p.recycle()},shadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{shadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:g}=i,p=e.getSameCanvas(),f=h.length-1;be(l,Ee),h.forEach(((h,_)=>{p.setWorldShadow(Ee.offsetX+h.x*u,Ee.offsetY+h.y*g,h.blur*u,h.color),o=h.spread?1+2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Le(p,Ee,o,i),n=l,h.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,l,r,"copy"),n=r),d?p.copyWorld(d,r,r,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped||s.matrix?e.copyWorldByReset(p,n,r,h.blendMode):e.copyWorldToInner(p,n,a.renderBounds,h.blendMode),f&&_<f&&p.clear()})),p.recycle()}});const ke=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ce=ke+"_#~&*+\\=|≮≯≈≠=…",Se=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ae(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Oe=Ae("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Ae("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Pe=Ae(ke),We=Ae(Ce),Ie=Ae("- —/~|┆·");var Fe;!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"}(Fe||(Fe={}));const{Letter:Ye,Single:ze,Before:Ne,After:Ue,Symbol:Ve,Break:je}=Fe;function Ge(t){return Oe[t]?Ye:Ie[t]?je:De[t]?Ne:Pe[t]?Ue:We[t]?Ve:Se.test(t)?ze:Ye}const Xe={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 He(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:qe}=Xe,{Letter:Ke,Single:Qe,Before:$e,After:Ze,Symbol:Je,Break:ti}=Fe;let ei,ii,si,ni,oi,ri,ai,hi,di,li,ci,ui,gi,pi,fi,_i,wi=[];function vi(t,e){di&&!hi&&(hi=di),ei.data.push({char:t,width:e}),si+=e}function yi(){ni+=si,ei.width=si,ii.words.push(ei),ei={data:[]},si=0}function mi(){pi&&(fi.paraNumber++,ii.paraStart=!0,pi=!1),di&&(ii.startCharSize=hi,ii.endCharSize=di,hi=0),ii.width=ni,_i.width&&qe(ii),wi.push(ii),ii={words:[]},ni=0}const xi={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,o=e.__getInput("height")||0;const{textDecoration:r,__font:a,padding:h}=e;if(h){const[t,e,r,a]=L.fourNumber(h);n&&(i=a,n-=e+a),o&&(s=t,o-=t+r)}const d={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:f.canvas.font=a};return function(t,e,i){fi=t,wi=t.rows,_i=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=f,{width:a,height:h}=_i;if(a||h||s||"none"!==o){const t="none"!==i.textWrap,h="break"===i.textWrap;pi=!0,ci=null,hi=ai=di=si=ni=0,ei={data:[]},ii={words:[]};for(let i=0,d=e.length;i<d;i++)ri=e[i],"\n"===ri?(si&&yi(),ii.paraEnd=!0,mi(),pi=!0):(li=Ge(ri),li===Ke&&"none"!==o&&(ri=He(ri,o,!si)),ai=r.measureText(ri).width,s&&(s<0&&(di=ai),ai+=s),ui=li===Qe&&(ci===Qe||ci===Ke)||ci===Qe&&li!==Ze,gi=!(li!==$e&&li!==Qe||ci!==Je&&ci!==Ze),oi=pi&&n?a-n:a,t&&a&&ni+si+ai>oi&&(h?(si&&yi(),mi()):(gi||(gi=li===Ke&&ci==Ze),ui||gi||li===ti||li===$e||li===Qe||si+ai>oi?(si&&yi(),mi()):mi()))," "===ri&&!0!==pi&&ni+si===0||(li===ti?(" "===ri&&si&&yi(),vi(ri,ai),yi()):ui||gi?(si&&yi(),vi(ri,ai)):vi(ri,ai)),ci=li);si&&yi(),ni&&mi(),wi.length>0&&(wi[wi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{fi.paraNumber++,wi.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(d,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:d,paraSpacing:l}=e;let c,u,g,{x:p,y:f,width:_,height:w}=s,v=n*i.length+(l?l*(t.paraNumber-1):0),y=o;if(a&&v>w)v=Math.max(w,n),t.overflow=i.length;else switch(d){case"middle":f+=(w-v)/2;break;case"bottom":f+=w-v}y+=f;for(let o=0,d=i.length;o<d;o++){switch(c=i[o],c.x=p,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>v&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,g=c.width,r<0&&(c.width<0?(g=-c.width+e.fontSize+r,u-=g,g+=e.fontSize):g-=r),u<s.x&&(s.x=u),g>s.width&&(s.width=g),a&&_&&_<g&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=f,s.height=v}(d,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(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=>{1===c?(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)," "!==u.char&&t.data.push(u)):h=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(d,e,n),d.overflow&&function(t,e){const{rows:i,overflow:s}=t;let{textOverflow:n}=e;if(i.splice(s),"hide"!==n){let t,o;"ellipsis"===n&&(n="...");const r=f.canvas.measureText(n).width,a=e.x+e.width-r;("none"===e.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],o=t.x+t.width,!(s===i&&o<a));s--){if(o<a&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:n,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(d,e),"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}}(d,e),d}},bi={string(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+")"}},Bi={export(t,e,i){return Bi.running=!0,function(t){Ei||(Ei=new A);return new Promise((e=>{Ei.add((()=>St(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:o}=t;o?o.waitViewCompleted((()=>St(this,void 0,void 0,(function*(){let t,r,a,{canvas:h}=o,{unreal:d}=h;switch(d&&(h=h.getSameCanvas(),h.backgroundColor=o.config.fill,o.__render(h,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}a=e.includes(".")?yield h.saveAs(e,t):r?yield h.toBlob(e,t):yield h.toDataURL(e,t),s({data:a}),n(),Bi.running=!1,d&&h.recycle()})))):(s({data:!1}),n(),Bi.running=!1)}))))}};let Ei;Object.assign(P,me),Object.assign(W,Te),Object.assign(I,xi),Object.assign(O,bi),Object.assign(F,Bi),vt();export{ft as Interaction,$ as Layouter,ht as LeaferCanvas,J as Renderer,rt as Selector,Y as Watcher,vt as useCanvas};
1
+ import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as o,LeafHelper as r,BranchHelper as a,Bounds as h,LeafBoundsHelper as d,Debug as l,LeafLevelList as c,LayoutEvent as u,Run as p,ImageManager as g,Platform as f,AnimateEvent as _,ResizeEvent as w,BoundsHelper as v,Creator as y,LeaferCanvasBase as m,Cursor as x,canvasSizeAttrs as b,canvasPatch as B,InteractionHelper as E,MathHelper as L,InteractionBase as R,LeaferImage as M,FileHelper as T,MatrixHelper as k,ImageEvent as C,PointHelper as S,Direction4 as A,TaskProcessor as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as D,ImageManager as P,Paint as W,Effect as I,TextConvert as F,Export as Y}from"@leafer-ui/core";export*from"@leafer-ui/core";class z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,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(i.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===s.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 n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(o.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.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:U,updateBounds:N,updateAllWorldOpacity:V}=r,{pushAllChildBranch:j,pushAllParent:G}=a;const{worldBounds:X}=d,H={x:0,y:0,width:1e5,height:1e5};class q{constructor(e){this.updatedBounds=new h,this.beforeBounds=new h,this.afterBounds=new h,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,X)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(H):this.afterBounds.setListWithFn(t,X),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:K,updateAllChange:Q}=r,$=l.get("Layouter");class Z{constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new c,this.target=t,i&&(this.config=e.default(i,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(u.START),this.layoutOnce(),t.emitEvent(new u(u.END,this.layoutedBlocks,this.times))}catch(t){$.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?$.warn("layouting"):this.times>3?$.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.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=p.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=u,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new u(n,a,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?(U(t,!0),e.add(t),t.isBranch&&j(t,e),G(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),G(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||N(s[t])}N(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&V(t),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new u(o,a,this.times)),i.emitEvent(new u(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,p.end(e)}fullLayout(){const e=p.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=u,r=this.getBlocks(new t(i));i.emitEvent(new u(s,r,this.times)),Z.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new u(n,r,this.times)),i.emitEvent(new u(o,r,this.times)),this.addBlocks(r),p.end(e)}static fullLayout(t){K(t,!0),t.isBranch?a.updateBounds(t):r.updateBounds(t),Q(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new q([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new q(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_(u.REQUEST,this.layout,this),t.on_(u.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const J=l.get("Renderer");class tt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(u.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new h,J.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,J.error(t)}J.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?J.warn("rendering"):this.times>3?J.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new h,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return J.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=p.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new h(s);i.save(),n&&!l.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),p.end(e)}fullRender(){const t=p.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),p.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),l.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),l.showHitView&&this.renderHitView(s),l.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new h;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();f.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(_.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new h(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||J.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(u.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}var et;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(et||(et={}));const{hitRadiusPoint:it}=v;class st{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;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),a=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:a,leaf:r,throughPath:o.length?this.getThroughPath(o):a}:{path:a,leaf:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],r.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.add(e),e=e.parent;return i.add(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.addAt(s,0),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,o,r;for(let t=0,e=s.length;t<e;t++){n=s[t],o=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!o||!o.has(r));t++)i.add(r)}return i}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.__.isMask||(s=!!i.__.hitRadius||it(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){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:nt,NoAndSkip:ot,YesAndSkip:rt}=et;class at{constructor(t,i){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},this.target=t,i&&(this.config=e.default(i,this.config)),this.pather=new st(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,e,i){return"node"===f.name&&this.target.emit(u.CHECK_UPDATE),this.pather.getByPoint(t,e,i)}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&&r.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 r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),o===nt||o===rt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<ot&&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_(s.REMOVE,this.__onRemoveChild,this),this.target.on_(o.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.pather.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(y,{watcher:(t,e)=>new z(t,e),layouter:(t,e)=>new Z(t,e),renderer:(t,e,i)=>new tt(t,e,i),selector:(t,e)=>new at(t,e)}),f.layout=Z.fullLayout;const ht=l.get("LeaferCanvas");class dt extends m{init(){const{view:t}=this.config;t?this.__createViewFrom(t):this.__createView();const{style:e}=this.view;e.display||(e.display="block"),e.userSelect="none",this.parentView=this.view.parentElement,f.syncDomFont&&!this.parentView&&(this.view.style.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(this.config)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}setCursor(t){const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&x.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;if(t.hasChildNodes()){const{style:e}=i;e.position="absolute",e.top=e.left="0px",t.style.position||(t.style.position="relative")}t.appendChild(i)}else ht.error(`no id: ${t}`),this.__createView()}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=t*i,this.view.height=e*i}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(t,e){this.autoBounds=t,this.resizeListener=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t&&(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect()))}catch(t){this.imitateResizeObserver()}}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),f.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const i=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t);if(o!==this.width||r!==this.height){const{style:t}=i,{pixelRatio:a}=this;t.marginLeft=s+"px",t.marginTop=n+"px";const h={width:o,height:r,pixelRatio:a},d={};e.copyAttrs(d,this,b),this.resize(h),void 0!==this.width&&this.resizeListener(new w(h,d))}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}B(CanvasRenderingContext2D.prototype),B(Path2D.prototype);const lt={convert(t,e){const i=E.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=E.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=lt.getTouch(t),s=E.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},ct={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;return t.shiftKey&&!s&&(s=n,n=0),s>50&&(s=Math.max(50,s/3)),n>50&&(n=Math.max(50,n/3)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let i,s=1,{zoomMode:n,zoomSpeed:o}=e;const r=t.deltaY||t.deltaX;if(n?(i="mouse"===n||!t.deltaX&&(f.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){o=L.within(o,0,1);s=1-r/(25*(t.deltaY?e.delta.y:e.delta.x)*(1-o)+10),s<.5&&(s=.5),s>=1.5&&(s=1.5)}return s}},ut={convert(t){const e=E.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{getMoveEventData:pt,getZoomEventData:gt,getRotateEventData:ft}=E;class _t extends R{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getLocal(t,e){e&&this.canvas.updateClientBounds();const{clientBounds:i}=this.canvas;return{x:t.clientX-i.x,y:t.clientY-i.y}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(ut.convert(t))}onKeyUp(t){this.keyUp(ut.convert(t))}onContextMenu(t){this.menu(lt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.usePointer||(this.usePointer=!0),this.useMultiTouch||this.pointerDown(lt.convert(t,this.getLocal(t)))}onPointerMove(t){this.usePointer||(this.usePointer=!0),this.useMultiTouch||this.preventWindowPointer(t)||this.pointerMove(lt.convert(t,this.getLocal(t,!0)))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(lt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(lt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(lt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(lt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){if(t.preventDefault(),this.multiTouchStart(t),this.usePointer)return;this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0;const e=lt.getTouch(t);this.pointerDown(lt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=lt.getTouch(t);this.pointerMove(lt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=lt.getTouch(t);this.pointerUp(lt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>=2,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(E.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)))}onWheel(t){this.preventDefaultWheel(t);const{wheel:e}=this.config,i=e.getScale?e.getScale(t,e):ct.getScale(t,e),s=this.getLocal(t),n=E.getBase(t);1!==i?this.zoom(gt(s,i,n)):this.move(pt(s,e.getMove?e.getMove(t,e):ct.getMove(t,e),n))}onGesturestart(t){this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0}onGesturechange(t){this.preventDefaultWheel(t);const e=this.getLocal(t),i=E.getBase(t),s=t.scale/this.lastGestureScale,n=t.rotation-this.lastGestureRotation;let{rotateSpeed:o}=this.config.wheel;o=L.within(o,0,1),this.zoom(gt(e,s*s,i)),this.rotate(ft(e,n/Math.PI*180*(o/4+.1),i)),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.preventDefaultWheel(t),this.transformEnd()}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}const{mineType:wt,fileType:vt}=T;function yt(t,e){f.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(wt(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,wt(e),i))),canvasSaveAs:(t,e,i)=>new Promise((s=>{let n=document.createElement("a");n.href=t.toDataURL(wt(vt(e)),i),n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),s()})),loadImage:t=>new Promise(((e,i)=>{const s=new Image;s.setAttribute("crossOrigin","anonymous"),s.crossOrigin="anonymous",s.onload=()=>{e(s)},s.onerror=t=>{i(t)},!t.startsWith("data:")&&f.image.suffix&&(t+=(t.includes("?")?"&":"?")+f.image.suffix),s.src=t}))},f.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},f.canvas=y.canvas(),f.conicGradientSupport=!!f.canvas.context.createConicGradient}Object.assign(y,{canvas:(t,e)=>new dt(t,e),image:t=>new M(t),hitCanvas:(t,e)=>new dt(t,e),interaction:(t,e,i,s)=>new _t(t,e,i,s)}),f.name="web",f.isMobile="ontouchstart"in window,f.requestRender=function(t){window.requestAnimationFrame(t)},f.devicePixelRatio=Math.max(1,devicePixelRatio);const{userAgent:mt}=navigator;mt.indexOf("Firefox")>-1?(f.conicGradientRotate90=!0,f.intWheelDeltaY=!0,f.syncDomFont=!0):mt.indexOf("Safari")>-1&&-1===mt.indexOf("Chrome")&&(f.fullImageShadow=!0),mt.indexOf("Windows")>-1?(f.os="Windows",f.intWheelDeltaY=!0):mt.indexOf("Mac")>-1?f.os="Mac":mt.indexOf("Linux")>-1&&(f.os="Linux");const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Et,scale:Lt,rotate:Rt}=k;const{get:Mt,translate:Tt}=k;function kt(t,e,i,s){let{width:n,height:o}=e;const{opacity:r,mode:a,offset:h,scale:d,rotation:l,blendMode:c,repeat:u}=i,p=s.width===n&&s.height===o;c&&(t.blendMode=c);const g=t.data={mode:a};switch(a){case"strench":p||(n=s.width,o=s.height),(s.x||s.y)&&(g.transform=Mt(),Tt(g.transform,s.x,s.y));break;case"clip":(h||d||l)&&function(t,e,i,s,n){const o=xt();Bt(o,e.x,e.y),i&&Bt(o,i.x,i.y),s&&("number"==typeof s?Lt(o,s):Lt(o,s.x,s.y),t.scaleX=o.a,t.scaleY=o.d),n&&Rt(o,n),t.transform=o}(g,s,h,d,l);break;case"repeat":(!p||d||l)&&function(t,e,i,s,n,o){const r=xt();if(o)switch(Rt(r,o),o){case 90:Bt(r,s,0);break;case 180:Bt(r,i,s);break;case 270:Bt(r,0,i)}Bt(r,e.x,e.y),n&&(Et(r,e,n),t.scaleX=t.scaleY=n),t.transform=r}(g,s,n,o,d,l),u||(g.repeat="repeat");break;default:p&&!l||function(t,e,i,s,n,o){const r=xt(),a=o&&180!==o,h=i.width/(a?n:s),d=i.height/(a?s:n),l="fit"===e?Math.min(h,d):Math.max(h,d),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;Bt(r,c,u),Lt(r,l),o&&bt(r,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=l,t.transform=r}(g,a,s,n,o,l)}g.width=n,g.height=o,r&&(g.opacity=r),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat")}function Ct(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",t.__.width),t.setProxyAttr("height",t.__.height)),!1}return!0}function St(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new C(t,e))}function At(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(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(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const Ot={},{get:Dt,scale:Pt,copy:Wt}=k;function It(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const o=s+"-"+n;if(e.patternId===o||t.destroyed)return!1;{s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e;let a,h,{width:d,height:l,scaleX:c,scaleY:u,opacity:p,transform:g,repeat:_}=r;c&&(h=Dt(),Wt(h,g),Pt(h,1/c,1/u),s*=c,n*=u),s*=i,n*=i,d*=s,l*=n;const w=d*l;if(!_&&w>f.image.maxCacheSize)return!1;let v=f.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}w>v&&(a=Math.sqrt(w/v)),a&&(s/=a,n/=a,d/=a,l/=a),c&&(s/=c,n/=u),(g||1!==s||1!==n)&&(h||(h=Dt(),g&&Wt(h,g)),Pt(h,1/s,1/n));const y=f.canvas.createPattern(t.getCanvas(d<1?1:d,l<1?1:l,p),_||f.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),h&&(y.setTransform?y.setTransform(h):e.transform=h)}catch(t){e.transform=h}return e.style=y,e.patternId=o,!0}}const{abs:Ft}=Math;function Yt(t,e,i,s){const{scaleX:n,scaleY:o}=t.__world;if(i.data&&i.patternId!==n+"-"+o){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=Ft(n)*e.pixelRatio,i*=Ft(o)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>f.image.maxCacheSize}return s?(e.save(),e.clip(),i.blendMode&&(e.blendMode=i.blendMode),r.opacity&&(e.opacity*=r.opacity),r.transform&&e.transform(r.transform),e.drawImage(i.image.view,0,0,r.width,r.height),e.restore(),!0):(!i.style||Ot.running?It(t,i,e.pixelRatio):i.patternTask||(i.patternTask=g.patternTasker.add((()=>At(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&It(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1}function zt(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,g.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null}function Ut(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;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 Nt(t,e,i,s){const{strokeAlign:n}=e.__,o="string"!=typeof t;switch(n){case"center":i.setStroke(o?void 0:t,e.__.strokeWidth,e.__),o?Gt(t,!0,e,i):jt(e,i);break;case"inside":Vt("inside",t,o,e,i,s);break;case"outside":Vt("outside",t,o,e,i,s)}}function Vt(t,e,i,s,n,o){const{strokeWidth:r,__font:a}=s.__,h=n.getSameCanvas(!0);h.setStroke(i?void 0:e,2*r,s.__),h.font=a,i?Gt(e,!0,s,h):jt(s,h),h.blendMode="outside"===t?"destination-out":"destination-in",Ut(s,h),h.blendMode="normal",s.__worldFlipped||o.matrix?n.copyWorldByReset(h):n.copyWorldToInner(h,s.__world,s.__layout.renderBounds),h.recycle()}function jt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;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 Gt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&Yt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?jt(i,s):s.stroke(),s.restoreBlendMode()):e?jt(i,s):s.stroke())}const{getSpread:Xt,getOuterOf:Ht,getByMove:qt,getIntersectData:Kt}=v;const Qt={x:.5,y:0},$t={x:.5,y:1};function Zt(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,D.string(s.color,i))}const{set:Jt,getAngle:te,getDistance:ee}=S,{get:ie,rotateOfOuter:se,scaleOfOuter:ne}=k,oe={x:.5,y:.5},re={x:.5,y:1},ae={},he={};const{set:de,getAngle:le,getDistance:ce}=S,{get:ue,rotateOfOuter:pe,scaleOfOuter:ge}=k,fe={x:.5,y:.5},_e={x:.5,y:1},we={},ve={};let ye;function me(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:r,opacity:a}=e;return{type:n,blendMode:o,style:D.string(r,a)};case"image":return function(t,e,i,s,n){const o={type:i.type},r=o.image=g.get(i),a=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(Ct(t,e,r)&&kt(o,r,i,s),n&&(St(C.LOAD,a),St(C.LOADED,a))):r.error?n&&(t.forceUpdate("surface"),a.error=r.error,St(C.ERROR,a)):(n&&St(C.LOAD,a),o.loadId=r.load((()=>{t.destroyed||(Ct(t,e,r)&&(kt(o,r,i,s),t.forceUpdate("surface")),St(C.LOADED,a))}),(e=>{t.forceUpdate("surface"),a.error=e,St(C.ERROR,a)}))),o}(i,t,e,s,!ye||!ye[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:o,opacity:r}=t;i||(i=Qt),s||(s=$t);const a=f.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);Zt(a,t.stops,r);const h={type:n,style:a};return o&&(h.blendMode=o),h}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=oe),s||(s=re);const{x:h,y:d,width:l,height:c}=e;let u;Jt(ae,h+i.x*l,d+i.y*c),Jt(he,h+s.x*l,d+s.y*c),(l!==c||a)&&(u=ie(),ne(u,ae,l/c*(a||1),1),se(u,ae,te(ae,he)+90));const p=f.canvas.createRadialGradient(ae.x,ae.y,0,ae.x,ae.y,ee(ae,he));Zt(p,t.stops,o);const g={type:n,style:p,transform:u};return r&&(g.blendMode=r),g}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=fe),s||(s=_e);const{x:h,y:d,width:l,height:c}=e;de(we,h+i.x*l,d+i.y*c),de(ve,h+s.x*l,d+s.y*c);const u=ue(),p=le(we,ve);f.conicGradientRotate90?(ge(u,we,l/c*(a||1),1),pe(u,we,p+90)):(ge(u,we,1,l/c*(a||1)),pe(u,we,p));const g=f.conicGradientSupport?f.canvas.createConicGradient(0,we.x,we.y):f.canvas.createRadialGradient(we.x,we.y,0,we.x,we.y,ce(we,ve));Zt(g,t.stops,o);const _={type:n,style:g,transform:u};return r&&(_.blendMode=r),_}(e,s);default:return e.r?{type:"solid",style:D.string(e)}:void 0}}var xe=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,o,r=s.__input[t];r instanceof Array||(r=[r]),ye=zt(t,s);for(let s=0,o=r.length;s<o;s++)n=me(t,r[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===r.length){const t=r[0];"image"===t.type&&(o=P.isPixel(t))}"fill"===t?s.__pixelFill=o:s.__pixelStroke=o},drawTextStroke:jt,fill:function(t,e,i){i.fillStyle=t,e.__.__font?Ut(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:Ut,fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&Yt(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?Ut(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Ut(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Ut(e,i):n?i.fill(n):i.fill())},recycleImage:zt,shape:function(t,e,i){const s=e.getSameCanvas();let n,o,r,a;const{__world:h}=t;let{scaleX:d,scaleY:l}=h;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(h,i.matrix))i.matrix?(d*=i.matrix.a,l*=i.matrix.d,n=r=Ht(h,i.matrix)):n=r=h,a=s;else{const{renderShapeSpread:s}=t.__layout,c=Kt(s?Xt(e.bounds,s*d,s*l):e.bounds,h,i.matrix);o=e.bounds.getFitMatrix(c),o.a<1&&(a=e.getSameCanvas(),t.__renderShape(a,i),d*=o.a,l*=o.d),r=Ht(h,o),n=qt(r,-o.e,-o.f),i.matrix&&o.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:o})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:n,worldCanvas:a,shapeBounds:r,scaleX:d,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)Nt(t,e,i,s);else switch(r){case"center":i.setStroke(t,o,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const r=i.getSameCanvas(!0);r.setStroke(t,2*o,e.__),e.__drawRenderPath(r),r.stroke(),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(e.__layout.renderBounds),e.__worldFlipped||s.matrix?i.copyWorldByReset(r):i.copyWorldToInner(r,e.__world,e.__layout.renderBounds),r.recycle()}},strokeText:Nt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)Nt(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,o,n),Gt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),Gt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:r}=e.__layout,a=i.getSameCanvas(!0);e.__drawRenderPath(a),a.setStroke(void 0,2*o,e.__),Gt(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(r),e.__worldFlipped||s.matrix?i.copyWorldByReset(a):i.copyWorldToInner(a,e.__world,r),a.recycle()}}});const{copy:be,toOffsetOutBounds:Be}=v,Ee={},Le={};function Re(t,e,i,s){const{bounds:n,shapeBounds:o}=s;if(f.fullImageShadow){if(be(Ee,t.bounds),Ee.x+=e.x-o.x,Ee.y+=e.y-o.y,i){const{matrix:t}=s;Ee.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),Ee.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),Ee.width*=i,Ee.height*=i}t.copyWorld(s.canvas,t.bounds,Ee)}else i&&(be(Ee,e),Ee.x-=e.width/2*(i-1),Ee.y-=e.height/2*(i-1),Ee.width*=i,Ee.height*=i),t.copyWorld(s.canvas,o,i?Ee:e)}const{toOffsetOutBounds:Me}=v,Te={};var ke=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{innerShadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:p}=i,g=e.getSameCanvas(),f=h.length-1;Me(l,Te),h.forEach(((h,_)=>{g.save(),g.setWorldShadow(Te.offsetX+h.x*u,Te.offsetY+h.y*p,h.blur*u),o=h.spread?1-2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Re(g,Te,o,i),g.restore(),d?(g.copyWorld(g,l,r,"copy"),g.copyWorld(d,r,r,"source-out"),n=r):(g.copyWorld(i.canvas,c,l,"source-out"),n=l),g.fillWorld(n,h.color,"source-in"),t.__worldFlipped||s.matrix?e.copyWorldByReset(g,n,r,h.blendMode):e.copyWorldToInner(g,n,a.renderBounds,h.blendMode),f&&_<f&&g.clear()})),g.recycle()},shadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{shadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:p}=i,g=e.getSameCanvas(),f=h.length-1;Be(l,Le),h.forEach(((h,_)=>{g.setWorldShadow(Le.offsetX+h.x*u,Le.offsetY+h.y*p,h.blur*u,h.color),o=h.spread?1+2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Re(g,Le,o,i),n=l,h.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,l,r,"copy"),n=r),d?g.copyWorld(d,r,r,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped||s.matrix?e.copyWorldByReset(g,n,r,h.blendMode):e.copyWorldToInner(g,n,a.renderBounds,h.blendMode),f&&_<f&&g.clear()})),g.recycle()}});const Ce=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Se=Ce+"_#~&*+\\=|≮≯≈≠=…",Ae=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 Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const De=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Pe=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),We=Oe(Ce),Ie=Oe(Se),Fe=Oe("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:ze,Single:Ue,Before:Ne,After:Ve,Symbol:je,Break:Ge}=Ye;function Xe(t){return De[t]?ze:Fe[t]?Ge:Pe[t]?Ne:We[t]?Ve:Ie[t]?je:Ae.test(t)?Ue:ze}const He={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 qe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ke}=He,{Letter:Qe,Single:$e,Before:Ze,After:Je,Symbol:ti,Break:ei}=Ye;let ii,si,ni,oi,ri,ai,hi,di,li,ci,ui,pi,gi,fi,_i,wi,vi=[];function yi(t,e){li&&!di&&(di=li),ii.data.push({char:t,width:e}),ni+=e}function mi(){oi+=ni,ii.width=ni,si.words.push(ii),ii={data:[]},ni=0}function xi(){fi&&(_i.paraNumber++,si.paraStart=!0,fi=!1),li&&(si.startCharSize=di,si.endCharSize=li,di=0),si.width=oi,wi.width&&Ke(si),vi.push(si),si={words:[]},oi=0}const{top:bi,right:Bi,bottom:Ei,left:Li}=A,Ri={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,o=e.__getInput("height")||0;const{textDecoration:r,__font:a,__padding:h}=e;h&&(n&&(i=h[Li],n-=h[Bi]+h[Li]),o&&(s=h[bi],o-=h[bi]+h[Ei]));const d={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:f.canvas.font=a};return function(t,e,i){_i=t,vi=t.rows,wi=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=f,{width:a,height:h}=wi;if(a||h||s||"none"!==o){const t="none"!==i.textWrap,h="break"===i.textWrap;fi=!0,ui=null,di=hi=li=ni=oi=0,ii={data:[]},si={words:[]};for(let i=0,d=e.length;i<d;i++)ai=e[i],"\n"===ai?(ni&&mi(),si.paraEnd=!0,xi(),fi=!0):(ci=Xe(ai),ci===Qe&&"none"!==o&&(ai=qe(ai,o,!ni)),hi=r.measureText(ai).width,s&&(s<0&&(li=hi),hi+=s),pi=ci===$e&&(ui===$e||ui===Qe)||ui===$e&&ci!==Je,gi=!(ci!==Ze&&ci!==$e||ui!==ti&&ui!==Je),ri=fi&&n?a-n:a,t&&a&&oi+ni+hi>ri&&(h?(ni&&mi(),xi()):(gi||(gi=ci===Qe&&ui==Je),pi||gi||ci===ei||ci===Ze||ci===$e||ni+hi>ri?(ni&&mi(),xi()):xi()))," "===ai&&!0!==fi&&oi+ni===0||(ci===ei?(" "===ai&&ni&&mi(),yi(ai,hi),mi()):pi||gi?(ni&&mi(),yi(ai,hi)):yi(ai,hi)),ui=ci);ni&&mi(),oi&&xi(),vi.length>0&&(vi[vi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{_i.paraNumber++,vi.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(d,t,e),h&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Mi(e,"x",t[Li]);break;case"right":Mi(e,"x",-t[Bi])}if(!n)switch(i.verticalAlign){case"top":Mi(e,"y",t[bi]);break;case"bottom":Mi(e,"y",-t[Ei])}}(h,d,e,n,o),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:d,paraSpacing:l}=e;let c,u,p,{x:g,y:f,width:_,height:w}=s,v=n*i.length+(l?l*(t.paraNumber-1):0),y=o;if(a&&v>w)v=Math.max(w,n),t.overflow=i.length;else switch(d){case"middle":f+=(w-v)/2;break;case"bottom":f+=w-v}y+=f;for(let o=0,d=i.length;o<d;o++){switch(c=i[o],c.x=g,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>v&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,p=c.width,r<0&&(c.width<0?(p=-c.width+e.fontSize+r,u-=p,p+=e.fontSize):p-=r),u<s.x&&(s.x=u),p>s.width&&(s.width=p),a&&_&&_<p&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=f,s.height=v}(d,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(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=>{1===c?(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)," "!==u.char&&t.data.push(u)):h=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(d,e,n),d.overflow&&function(t,e){const{rows:i,overflow:s}=t;let{textOverflow:n}=e;if(i.splice(s),"hide"!==n){let t,o;"ellipsis"===n&&(n="...");const r=f.canvas.measureText(n).width,a=e.x+e.width-r;("none"===e.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],o=t.x+t.width,!(s===i&&o<a));s--){if(o<a&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:n,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(d,e),"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}}(d,e),d}};function Mi(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 Ti={string(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+")"}},ki={export(t,e,i){return ki.running=!0,function(t){Ci||(Ci=new O);return new Promise((e=>{Ci.add((()=>At(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:o}=t;o?o.waitViewCompleted((()=>At(this,void 0,void 0,(function*(){let t,r,a,{canvas:h}=o,{unreal:d}=h;switch(d&&(h=h.getSameCanvas(),h.backgroundColor=o.config.fill,o.__render(h,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}a=e.includes(".")?yield h.saveAs(e,t):r?yield h.toBlob(e,t):yield h.toDataURL(e,t),s({data:a}),n(),ki.running=!1,d&&h.recycle()})))):(s({data:!1}),n(),ki.running=!1)}))))}};let Ci;Object.assign(W,xe),Object.assign(I,ke),Object.assign(F,Ri),Object.assign(D,Ti),Object.assign(Y,ki),yt();export{_t as Interaction,Z as Layouter,dt as LeaferCanvas,tt as Renderer,at as Selector,z as Watcher,yt as useCanvas};