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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.8 已发布 🎉🎉🎉,查看 [更新日志](https://leaferjs.com/ui/update/)。
7
+ 1.0.0-rc.9 已发布 🎉🎉🎉,查看 [更新日志](https://leaferjs.com/ui/update/)。
8
8
 
9
9
  目前产品已经逐步稳定,正式版即将到来,感谢所有参与的朋友们~
10
10
 
package/dist/web.esm.js CHANGED
@@ -833,8 +833,9 @@ 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';
837
836
  this.parentView = this.view.parentElement;
837
+ if (this.parentView)
838
+ this.parentView.style.userSelect = 'none';
838
839
  if (Platform.syncDomFont && !this.parentView) {
839
840
  this.view.style.display = 'none';
840
841
  document.body.appendChild(this.view);
@@ -1385,6 +1386,7 @@ else if (userAgent.indexOf('Linux') > -1) {
1385
1386
  Platform.os = 'Linux';
1386
1387
  }
1387
1388
 
1389
+ let origin = {};
1388
1390
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
1389
1391
  function fillOrFitMode(data, mode, box, width, height, rotation) {
1390
1392
  const transform = get$4();
@@ -1401,13 +1403,13 @@ function fillOrFitMode(data, mode, box, width, height, rotation) {
1401
1403
  data.scaleX = data.scaleY = scale;
1402
1404
  data.transform = transform;
1403
1405
  }
1404
- function clipMode(data, box, offset, scale, rotation) {
1406
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
1405
1407
  const transform = get$4();
1406
1408
  translate$1(transform, box.x, box.y);
1407
- if (offset)
1408
- translate$1(transform, offset.x, offset.y);
1409
- if (scale) {
1410
- typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
1409
+ if (x || y)
1410
+ translate$1(transform, x, y);
1411
+ if (scaleX) {
1412
+ scaleHelper(transform, scaleX, scaleY);
1411
1413
  data.scaleX = transform.a;
1412
1414
  data.scaleY = transform.d;
1413
1415
  }
@@ -1415,7 +1417,7 @@ function clipMode(data, box, offset, scale, rotation) {
1415
1417
  rotate(transform, rotation);
1416
1418
  data.transform = transform;
1417
1419
  }
1418
- function repeatMode(data, box, width, height, scale, rotation) {
1420
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
1419
1421
  const transform = get$4();
1420
1422
  if (rotation) {
1421
1423
  rotate(transform, rotation);
@@ -1431,10 +1433,15 @@ function repeatMode(data, box, width, height, scale, rotation) {
1431
1433
  break;
1432
1434
  }
1433
1435
  }
1434
- translate$1(transform, box.x, box.y);
1435
- if (scale) {
1436
- scaleOfOuter$2(transform, box, scale);
1437
- data.scaleX = data.scaleY = scale;
1436
+ origin.x = box.x;
1437
+ origin.y = box.y;
1438
+ if (x || y)
1439
+ origin.x += x, origin.y += y;
1440
+ translate$1(transform, origin.x, origin.y);
1441
+ if (scaleX) {
1442
+ scaleOfOuter$2(transform, origin, scaleX, scaleY);
1443
+ data.scaleX = scaleX;
1444
+ data.scaleY = scaleY;
1438
1445
  }
1439
1446
  data.transform = transform;
1440
1447
  }
@@ -1442,11 +1449,22 @@ function repeatMode(data, box, width, height, scale, rotation) {
1442
1449
  const { get: get$3, translate } = MatrixHelper;
1443
1450
  function createData(leafPaint, image, paint, box) {
1444
1451
  let { width, height } = image;
1445
- const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint;
1452
+ const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
1446
1453
  const sameBox = box.width === width && box.height === height;
1447
1454
  if (blendMode)
1448
1455
  leafPaint.blendMode = blendMode;
1449
1456
  const data = leafPaint.data = { mode };
1457
+ let x, y, scaleX, scaleY;
1458
+ if (offset)
1459
+ x = offset.x, y = offset.y;
1460
+ if (size) {
1461
+ scaleX = (typeof size === 'number' ? size : size.width) / width;
1462
+ scaleY = (typeof size === 'number' ? size : size.height) / height;
1463
+ }
1464
+ else if (scale) {
1465
+ scaleX = typeof scale === 'number' ? scale : scale.x;
1466
+ scaleY = typeof scale === 'number' ? scale : scale.y;
1467
+ }
1450
1468
  switch (mode) {
1451
1469
  case 'strench':
1452
1470
  if (!sameBox)
@@ -1457,12 +1475,12 @@ function createData(leafPaint, image, paint, box) {
1457
1475
  }
1458
1476
  break;
1459
1477
  case 'clip':
1460
- if (offset || scale || rotation)
1461
- clipMode(data, box, offset, scale, rotation);
1478
+ if (offset || scaleX || rotation)
1479
+ clipMode(data, box, x, y, scaleX, scaleY, rotation);
1462
1480
  break;
1463
1481
  case 'repeat':
1464
- if (!sameBox || scale || rotation)
1465
- repeatMode(data, box, width, height, scale, rotation);
1482
+ if (!sameBox || scaleX || rotation)
1483
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
1466
1484
  if (!repeat)
1467
1485
  data.repeat = 'repeat';
1468
1486
  break;
@@ -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 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};
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 y,Creator as v,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}=y;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(v,{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"),this.parentView=this.view.parentElement,this.parentView&&(this.parentView.style.userSelect="none"),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:yt}=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(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(yt(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=v.canvas(),f.conicGradientSupport=!!f.canvas.context.createConicGradient}Object.assign(v,{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");let xt={};const{get:bt,rotateOfOuter:Bt,translate:Et,scaleOfOuter:Lt,scale:Rt,rotate:Mt}=k;const{get:Tt,translate:kt}=k;function Ct(t,e,i,s){let{width:n,height:o}=e;const{opacity:r,mode:a,offset:h,scale:d,size:l,rotation:c,blendMode:u,repeat:p}=i,g=s.width===n&&s.height===o;u&&(t.blendMode=u);const f=t.data={mode:a};let _,w,y,v;switch(h&&(_=h.x,w=h.y),l?(y=("number"==typeof l?l:l.width)/n,v=("number"==typeof l?l:l.height)/o):d&&(y="number"==typeof d?d:d.x,v="number"==typeof d?d:d.y),a){case"strench":g||(n=s.width,o=s.height),(s.x||s.y)&&(f.transform=Tt(),kt(f.transform,s.x,s.y));break;case"clip":(h||y||c)&&function(t,e,i,s,n,o,r){const a=bt();Et(a,e.x,e.y),(i||s)&&Et(a,i,s),n&&(Rt(a,n,o),t.scaleX=a.a,t.scaleY=a.d),r&&Mt(a,r),t.transform=a}(f,s,_,w,y,v,c);break;case"repeat":(!g||y||c)&&function(t,e,i,s,n,o,r,a,h){const d=bt();if(h)switch(Mt(d,h),h){case 90:Et(d,s,0);break;case 180:Et(d,i,s);break;case 270:Et(d,0,i)}xt.x=e.x,xt.y=e.y,(n||o)&&(xt.x+=n,xt.y+=o),Et(d,xt.x,xt.y),r&&(Lt(d,xt,r,a),t.scaleX=r,t.scaleY=a),t.transform=d}(f,s,n,o,_,w,y,v,c),p||(f.repeat="repeat");break;default:g&&!c||function(t,e,i,s,n,o){const r=bt(),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;Et(r,c,u),Rt(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}(f,a,s,n,o,c)}f.width=n,f.height=o,r&&(f.opacity=r),p&&(f.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat")}function St(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 At(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new C(t,e))}function Ot(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 Dt={},{get:Pt,scale:Wt,copy:It}=k;function Ft(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=Pt(),It(h,g),Wt(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 y=f.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(a=Math.sqrt(w/y)),a&&(s/=a,n/=a,d/=a,l/=a),c&&(s/=c,n/=u),(g||1!==s||1!==n)&&(h||(h=Pt(),g&&It(h,g)),Wt(h,1/s,1/n));const v=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&&(v.setTransform?v.setTransform(h):e.transform=h)}catch(t){e.transform=h}return e.style=v,e.patternId=o,!0}}const{abs:Yt}=Math;function zt(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*=Yt(n)*e.pixelRatio,i*=Yt(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||Dt.running?Ft(t,i,e.pixelRatio):i.patternTask||(i.patternTask=g.patternTasker.add((()=>Ot(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&Ft(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1}function Ut(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 Nt(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 Vt(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?Xt(t,!0,e,i):Gt(e,i);break;case"inside":jt("inside",t,o,e,i,s);break;case"outside":jt("outside",t,o,e,i,s)}}function jt(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?Xt(e,!0,s,h):Gt(s,h),h.blendMode="outside"===t?"destination-out":"destination-in",Nt(s,h),h.blendMode="normal",s.__worldFlipped||o.matrix?n.copyWorldByReset(h):n.copyWorldToInner(h,s.__world,s.__layout.renderBounds),h.recycle()}function Gt(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 Xt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&zt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Gt(i,s):s.stroke(),s.restoreBlendMode()):e?Gt(i,s):s.stroke())}const{getSpread:Ht,getOuterOf:qt,getByMove:Kt,getIntersectData:Qt}=y;const $t={x:.5,y:0},Zt={x:.5,y:1};function Jt(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:te,getAngle:ee,getDistance:ie}=S,{get:se,rotateOfOuter:ne,scaleOfOuter:oe}=k,re={x:.5,y:.5},ae={x:.5,y:1},he={},de={};const{set:le,getAngle:ce,getDistance:ue}=S,{get:pe,rotateOfOuter:ge,scaleOfOuter:fe}=k,_e={x:.5,y:.5},we={x:.5,y:1},ye={},ve={};let me;function xe(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?(St(t,e,r)&&Ct(o,r,i,s),n&&(At(C.LOAD,a),At(C.LOADED,a))):r.error?n&&(t.forceUpdate("surface"),a.error=r.error,At(C.ERROR,a)):(n&&At(C.LOAD,a),o.loadId=r.load((()=>{t.destroyed||(St(t,e,r)&&(Ct(o,r,i,s),t.forceUpdate("surface")),At(C.LOADED,a))}),(e=>{t.forceUpdate("surface"),a.error=e,At(C.ERROR,a)}))),o}(i,t,e,s,!me||!me[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:o,opacity:r}=t;i||(i=$t),s||(s=Zt);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);Jt(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=re),s||(s=ae);const{x:h,y:d,width:l,height:c}=e;let u;te(he,h+i.x*l,d+i.y*c),te(de,h+s.x*l,d+s.y*c),(l!==c||a)&&(u=se(),oe(u,he,l/c*(a||1),1),ne(u,he,ee(he,de)+90));const p=f.canvas.createRadialGradient(he.x,he.y,0,he.x,he.y,ie(he,de));Jt(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=_e),s||(s=we);const{x:h,y:d,width:l,height:c}=e;le(ye,h+i.x*l,d+i.y*c),le(ve,h+s.x*l,d+s.y*c);const u=pe(),p=ce(ye,ve);f.conicGradientRotate90?(fe(u,ye,l/c*(a||1),1),ge(u,ye,p+90)):(fe(u,ye,1,l/c*(a||1)),ge(u,ye,p));const g=f.conicGradientSupport?f.canvas.createConicGradient(0,ye.x,ye.y):f.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,ue(ye,ve));Jt(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 be=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,o,r=s.__input[t];r instanceof Array||(r=[r]),me=Ut(t,s);for(let s=0,o=r.length;s<o;s++)n=xe(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:Gt,fill:function(t,e,i){i.fillStyle=t,e.__.__font?Nt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:Nt,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&&zt(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?Nt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Nt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Nt(e,i):n?i.fill(n):i.fill())},recycleImage:Ut,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=qt(h,i.matrix)):n=r=h,a=s;else{const{renderShapeSpread:s}=t.__layout,c=Qt(s?Ht(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=qt(h,o),n=Kt(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)Vt(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:Vt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)Vt(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,o,n),Xt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),Xt(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.__),Xt(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:Ee}=y,Le={},Re={};function Me(t,e,i,s){const{bounds:n,shapeBounds:o}=s;if(f.fullImageShadow){if(Be(Le,t.bounds),Le.x+=e.x-o.x,Le.y+=e.y-o.y,i){const{matrix:t}=s;Le.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),Le.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),Le.width*=i,Le.height*=i}t.copyWorld(s.canvas,t.bounds,Le)}else i&&(Be(Le,e),Le.x-=e.width/2*(i-1),Le.y-=e.height/2*(i-1),Le.width*=i,Le.height*=i),t.copyWorld(s.canvas,o,i?Le:e)}const{toOffsetOutBounds:Te}=y,ke={};var Ce=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;Te(l,ke),h.forEach(((h,_)=>{g.save(),g.setWorldShadow(ke.offsetX+h.x*u,ke.offsetY+h.y*p,h.blur*u),o=h.spread?1-2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Me(g,ke,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;Ee(l,Re),h.forEach(((h,_)=>{g.setWorldShadow(Re.offsetX+h.x*u,Re.offsetY+h.y*p,h.blur*u,h.color),o=h.spread?1+2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Me(g,Re,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 Se=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Se+"_#~&*+\\=|≮≯≈≠=…",Oe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function De(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Pe=De("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),We=De("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=De(Se),Fe=De(Ae),Ye=De("- —/~|┆·");var ze;!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"}(ze||(ze={}));const{Letter:Ue,Single:Ne,Before:Ve,After:je,Symbol:Ge,Break:Xe}=ze;function He(t){return Pe[t]?Ue:Ye[t]?Xe:We[t]?Ve:Ie[t]?je:Fe[t]?Ge:Oe.test(t)?Ne:Ue}const qe={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 Ke(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}=qe,{Letter:$e,Single:Ze,Before:Je,After:ti,Symbol:ei,Break:ii}=ze;let si,ni,oi,ri,ai,hi,di,li,ci,ui,pi,gi,fi,_i,wi,yi,vi=[];function mi(t,e){ci&&!li&&(li=ci),si.data.push({char:t,width:e}),oi+=e}function xi(){ri+=oi,si.width=oi,ni.words.push(si),si={data:[]},oi=0}function bi(){_i&&(wi.paraNumber++,ni.paraStart=!0,_i=!1),ci&&(ni.startCharSize=li,ni.endCharSize=ci,li=0),ni.width=ri,yi.width&&Qe(ni),vi.push(ni),ni={words:[]},ri=0}const{top:Bi,right:Ei,bottom:Li,left:Ri}=A,Mi={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[Ri],n-=h[Ei]+h[Ri]),o&&(s=h[Bi],o-=h[Bi]+h[Li]));const d={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:f.canvas.font=a};return function(t,e,i){wi=t,vi=t.rows,yi=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=f,{width:a,height:h}=yi;if(a||h||s||"none"!==o){const t="none"!==i.textWrap,h="break"===i.textWrap;_i=!0,pi=null,li=di=ci=oi=ri=0,si={data:[]},ni={words:[]};for(let i=0,d=e.length;i<d;i++)hi=e[i],"\n"===hi?(oi&&xi(),ni.paraEnd=!0,bi(),_i=!0):(ui=He(hi),ui===$e&&"none"!==o&&(hi=Ke(hi,o,!oi)),di=r.measureText(hi).width,s&&(s<0&&(ci=di),di+=s),gi=ui===Ze&&(pi===Ze||pi===$e)||pi===Ze&&ui!==ti,fi=!(ui!==Je&&ui!==Ze||pi!==ei&&pi!==ti),ai=_i&&n?a-n:a,t&&a&&ri+oi+di>ai&&(h?(oi&&xi(),bi()):(fi||(fi=ui===$e&&pi==ti),gi||fi||ui===ii||ui===Je||ui===Ze||oi+di>ai?(oi&&xi(),bi()):bi()))," "===hi&&!0!==_i&&ri+oi===0||(ui===ii?(" "===hi&&oi&&xi(),mi(hi,di),xi()):gi||fi?(oi&&xi(),mi(hi,di)):mi(hi,di)),pi=ui);oi&&xi(),ri&&bi(),vi.length>0&&(vi[vi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{wi.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":Ti(e,"x",t[Ri]);break;case"right":Ti(e,"x",-t[Ei])}if(!n)switch(i.verticalAlign){case"top":Ti(e,"y",t[Bi]);break;case"bottom":Ti(e,"y",-t[Li])}}(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,y=n*i.length+(l?l*(t.paraNumber-1):0),v=o;if(a&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(d){case"middle":f+=(w-y)/2;break;case"bottom":f+=w-y}v+=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&&(v+=l),c.y=v,v+=n,t.overflow>o&&v>y&&(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=y}(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 Ti(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 ki={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+")"}},Ci={export(t,e,i){return Ci.running=!0,function(t){Si||(Si=new O);return new Promise((e=>{Si.add((()=>Ot(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:o}=t;o?o.waitViewCompleted((()=>Ot(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(),Ci.running=!1,d&&h.recycle()})))):(s({data:!1}),n(),Ci.running=!1)}))))}};let Si;Object.assign(W,be),Object.assign(I,Ce),Object.assign(F,Mi),Object.assign(D,ki),Object.assign(Y,Ci),vt();export{_t as Interaction,Z as Layouter,dt as LeaferCanvas,tt as Renderer,at as Selector,z as Watcher,vt as useCanvas};
package/dist/web.js CHANGED
@@ -5938,7 +5938,7 @@ var LeaferUI = (function (exports) {
5938
5938
  canvas.setWorld(this.__world, options.matrix);
5939
5939
  canvas.opacity = this.__worldOpacity;
5940
5940
  if (this.__.__single) {
5941
- const tempCanvas = canvas.getSameCanvas(true);
5941
+ const tempCanvas = canvas.getSameCanvas(true, true);
5942
5942
  this.__draw(tempCanvas, options);
5943
5943
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5944
5944
  if (this.__worldFlipped || options.matrix) {
@@ -6015,7 +6015,7 @@ var LeaferUI = (function (exports) {
6015
6015
  if (this.__worldOpacity) {
6016
6016
  if (this.__.__single) {
6017
6017
  canvas.resetTransform();
6018
- const tempCanvas = canvas.getSameCanvas();
6018
+ const tempCanvas = canvas.getSameCanvas(false, true);
6019
6019
  this.__renderBranch(tempCanvas, options);
6020
6020
  canvas.opacity = this.__worldOpacity;
6021
6021
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
@@ -7360,8 +7360,9 @@ var LeaferUI = (function (exports) {
7360
7360
  view ? this.__createViewFrom(view) : this.__createView();
7361
7361
  const { style } = this.view;
7362
7362
  style.display || (style.display = 'block');
7363
- style.userSelect = 'none';
7364
7363
  this.parentView = this.view.parentElement;
7364
+ if (this.parentView)
7365
+ this.parentView.style.userSelect = 'none';
7365
7366
  if (Platform.syncDomFont && !this.parentView) {
7366
7367
  this.view.style.display = 'none';
7367
7368
  document.body.appendChild(this.view);
@@ -8087,6 +8088,9 @@ var LeaferUI = (function (exports) {
8087
8088
  class LineData extends UIData {
8088
8089
  }
8089
8090
 
8091
+ class ArrowData extends LineData {
8092
+ }
8093
+
8090
8094
  class RectData extends UIData {
8091
8095
  get __boxStroke() { return true; }
8092
8096
  }
@@ -8145,6 +8149,25 @@ var LeaferUI = (function (exports) {
8145
8149
  }
8146
8150
 
8147
8151
  class ImageData extends RectData {
8152
+ setUrl(value) {
8153
+ this.__setImageFill(value);
8154
+ this._url = value;
8155
+ }
8156
+ __setImageFill(value) {
8157
+ if (this.__leaf.image)
8158
+ this.__leaf.image = null;
8159
+ this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
8160
+ }
8161
+ __getData() {
8162
+ const data = super.__getData();
8163
+ delete data.fill;
8164
+ return data;
8165
+ }
8166
+ __getInputData() {
8167
+ const data = super.__getInputData();
8168
+ delete data.fill;
8169
+ return data;
8170
+ }
8148
8171
  }
8149
8172
 
8150
8173
  class CanvasData extends RectData {
@@ -8391,14 +8414,15 @@ var LeaferUI = (function (exports) {
8391
8414
  findOne(condition, options) {
8392
8415
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
8393
8416
  }
8394
- getPath(curve) {
8395
- const { path } = this.__;
8417
+ getPath(curve, pathForRender) {
8418
+ this.__layout.update();
8419
+ let path = pathForRender ? this.__.__pathForRender : this.__.path;
8396
8420
  if (!path)
8397
- return [];
8421
+ this.__drawPathByBox(new PathCreator(path = []));
8398
8422
  return curve ? PathConvert.toCanvasData(path, true) : path;
8399
8423
  }
8400
- getPathString(curve) {
8401
- return PathConvert.stringify(this.getPath(curve));
8424
+ getPathString(curve, pathForRender) {
8425
+ return PathConvert.stringify(this.getPath(curve, pathForRender));
8402
8426
  }
8403
8427
  __onUpdateSize() {
8404
8428
  if (this.__.__input) {
@@ -8570,6 +8594,12 @@ var LeaferUI = (function (exports) {
8570
8594
  __decorate([
8571
8595
  strokeType(10)
8572
8596
  ], exports.UI.prototype, "miterLimit", void 0);
8597
+ __decorate([
8598
+ strokeType('none')
8599
+ ], exports.UI.prototype, "startArrow", void 0);
8600
+ __decorate([
8601
+ strokeType('none')
8602
+ ], exports.UI.prototype, "endArrow", void 0);
8573
8603
  __decorate([
8574
8604
  pathType(0)
8575
8605
  ], exports.UI.prototype, "cornerRadius", void 0);
@@ -9066,26 +9096,10 @@ var LeaferUI = (function (exports) {
9066
9096
  get ready() { return this.image ? this.image.ready : false; }
9067
9097
  constructor(data) {
9068
9098
  super(data);
9069
- }
9070
- __updateBoxBounds() {
9071
- let update;
9072
- const { url } = this;
9073
- const fill = this.fill;
9074
- if (fill) {
9075
- if (fill.url !== url)
9076
- update = true;
9077
- }
9078
- else {
9079
- if (url)
9080
- update = true;
9081
- }
9082
- if (update) {
9083
- if (this.image)
9084
- this.image = null;
9085
- this.fill = url ? { type: 'image', mode: 'strench', url } : undefined;
9086
- this.once(ImageEvent.LOADED, (e) => this.image = e.image);
9087
- }
9088
- super.__updateBoxBounds();
9099
+ this.on(ImageEvent.LOADED, (e) => {
9100
+ if (e.attrName === 'fill' && e.attrValue.url === this.url)
9101
+ this.image = e.image;
9102
+ });
9089
9103
  }
9090
9104
  destroy() {
9091
9105
  this.image = null;
@@ -9845,6 +9859,7 @@ var LeaferUI = (function (exports) {
9845
9859
  registerUI()
9846
9860
  ], exports.App);
9847
9861
 
9862
+ let origin = {};
9848
9863
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
9849
9864
  function fillOrFitMode(data, mode, box, width, height, rotation) {
9850
9865
  const transform = get$4();
@@ -9861,13 +9876,13 @@ var LeaferUI = (function (exports) {
9861
9876
  data.scaleX = data.scaleY = scale;
9862
9877
  data.transform = transform;
9863
9878
  }
9864
- function clipMode(data, box, offset, scale, rotation) {
9879
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
9865
9880
  const transform = get$4();
9866
9881
  translate$1(transform, box.x, box.y);
9867
- if (offset)
9868
- translate$1(transform, offset.x, offset.y);
9869
- if (scale) {
9870
- typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
9882
+ if (x || y)
9883
+ translate$1(transform, x, y);
9884
+ if (scaleX) {
9885
+ scaleHelper(transform, scaleX, scaleY);
9871
9886
  data.scaleX = transform.a;
9872
9887
  data.scaleY = transform.d;
9873
9888
  }
@@ -9875,7 +9890,7 @@ var LeaferUI = (function (exports) {
9875
9890
  rotate(transform, rotation);
9876
9891
  data.transform = transform;
9877
9892
  }
9878
- function repeatMode(data, box, width, height, scale, rotation) {
9893
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
9879
9894
  const transform = get$4();
9880
9895
  if (rotation) {
9881
9896
  rotate(transform, rotation);
@@ -9891,10 +9906,15 @@ var LeaferUI = (function (exports) {
9891
9906
  break;
9892
9907
  }
9893
9908
  }
9894
- translate$1(transform, box.x, box.y);
9895
- if (scale) {
9896
- scaleOfOuter$2(transform, box, scale);
9897
- data.scaleX = data.scaleY = scale;
9909
+ origin.x = box.x;
9910
+ origin.y = box.y;
9911
+ if (x || y)
9912
+ origin.x += x, origin.y += y;
9913
+ translate$1(transform, origin.x, origin.y);
9914
+ if (scaleX) {
9915
+ scaleOfOuter$2(transform, origin, scaleX, scaleY);
9916
+ data.scaleX = scaleX;
9917
+ data.scaleY = scaleY;
9898
9918
  }
9899
9919
  data.transform = transform;
9900
9920
  }
@@ -9902,11 +9922,22 @@ var LeaferUI = (function (exports) {
9902
9922
  const { get: get$3, translate } = MatrixHelper;
9903
9923
  function createData(leafPaint, image, paint, box) {
9904
9924
  let { width, height } = image;
9905
- const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint;
9925
+ const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
9906
9926
  const sameBox = box.width === width && box.height === height;
9907
9927
  if (blendMode)
9908
9928
  leafPaint.blendMode = blendMode;
9909
9929
  const data = leafPaint.data = { mode };
9930
+ let x, y, scaleX, scaleY;
9931
+ if (offset)
9932
+ x = offset.x, y = offset.y;
9933
+ if (size) {
9934
+ scaleX = (typeof size === 'number' ? size : size.width) / width;
9935
+ scaleY = (typeof size === 'number' ? size : size.height) / height;
9936
+ }
9937
+ else if (scale) {
9938
+ scaleX = typeof scale === 'number' ? scale : scale.x;
9939
+ scaleY = typeof scale === 'number' ? scale : scale.y;
9940
+ }
9910
9941
  switch (mode) {
9911
9942
  case 'strench':
9912
9943
  if (!sameBox)
@@ -9917,12 +9948,12 @@ var LeaferUI = (function (exports) {
9917
9948
  }
9918
9949
  break;
9919
9950
  case 'clip':
9920
- if (offset || scale || rotation)
9921
- clipMode(data, box, offset, scale, rotation);
9951
+ if (offset || scaleX || rotation)
9952
+ clipMode(data, box, x, y, scaleX, scaleY, rotation);
9922
9953
  break;
9923
9954
  case 'repeat':
9924
- if (!sameBox || scale || rotation)
9925
- repeatMode(data, box, width, height, scale, rotation);
9955
+ if (!sameBox || scaleX || rotation)
9956
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
9926
9957
  if (!repeat)
9927
9958
  data.repeat = 'repeat';
9928
9959
  break;
@@ -11227,6 +11258,7 @@ var LeaferUI = (function (exports) {
11227
11258
  exports.Animate = Animate;
11228
11259
  exports.AnimateEvent = AnimateEvent;
11229
11260
  exports.AroundHelper = AroundHelper;
11261
+ exports.ArrowData = ArrowData;
11230
11262
  exports.AutoBounds = AutoBounds;
11231
11263
  exports.BezierHelper = BezierHelper;
11232
11264
  exports.Bounds = Bounds;