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