@leafer-ui/worker 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/dist/worker.esm.js +76 -27
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +206 -120
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +206 -121
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.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, canvasPatch, LeaferImage, InteractionBase, FileHelper, MatrixHelper, ImageEvent, PointHelper,
|
|
1
|
+
import { LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, Platform, AnimateEvent, ResizeEvent, BoundsHelper, Creator, LeaferCanvasBase, canvasPatch, LeaferImage, InteractionBase, 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';
|
|
@@ -916,6 +916,7 @@ else if (userAgent.indexOf('Linux') > -1) {
|
|
|
916
916
|
Platform.os = 'Linux';
|
|
917
917
|
}
|
|
918
918
|
|
|
919
|
+
let origin = {};
|
|
919
920
|
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
|
|
920
921
|
function fillOrFitMode(data, mode, box, width, height, rotation) {
|
|
921
922
|
const transform = get$4();
|
|
@@ -932,13 +933,13 @@ function fillOrFitMode(data, mode, box, width, height, rotation) {
|
|
|
932
933
|
data.scaleX = data.scaleY = scale;
|
|
933
934
|
data.transform = transform;
|
|
934
935
|
}
|
|
935
|
-
function clipMode(data, box,
|
|
936
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
936
937
|
const transform = get$4();
|
|
937
938
|
translate$1(transform, box.x, box.y);
|
|
938
|
-
if (
|
|
939
|
-
translate$1(transform,
|
|
940
|
-
if (
|
|
941
|
-
|
|
939
|
+
if (x || y)
|
|
940
|
+
translate$1(transform, x, y);
|
|
941
|
+
if (scaleX) {
|
|
942
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
942
943
|
data.scaleX = transform.a;
|
|
943
944
|
data.scaleY = transform.d;
|
|
944
945
|
}
|
|
@@ -946,7 +947,7 @@ function clipMode(data, box, offset, scale, rotation) {
|
|
|
946
947
|
rotate(transform, rotation);
|
|
947
948
|
data.transform = transform;
|
|
948
949
|
}
|
|
949
|
-
function repeatMode(data, box, width, height,
|
|
950
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
|
|
950
951
|
const transform = get$4();
|
|
951
952
|
if (rotation) {
|
|
952
953
|
rotate(transform, rotation);
|
|
@@ -962,10 +963,15 @@ function repeatMode(data, box, width, height, scale, rotation) {
|
|
|
962
963
|
break;
|
|
963
964
|
}
|
|
964
965
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
966
|
+
origin.x = box.x;
|
|
967
|
+
origin.y = box.y;
|
|
968
|
+
if (x || y)
|
|
969
|
+
origin.x += x, origin.y += y;
|
|
970
|
+
translate$1(transform, origin.x, origin.y);
|
|
971
|
+
if (scaleX) {
|
|
972
|
+
scaleOfOuter$2(transform, origin, scaleX, scaleY);
|
|
973
|
+
data.scaleX = scaleX;
|
|
974
|
+
data.scaleY = scaleY;
|
|
969
975
|
}
|
|
970
976
|
data.transform = transform;
|
|
971
977
|
}
|
|
@@ -973,11 +979,22 @@ function repeatMode(data, box, width, height, scale, rotation) {
|
|
|
973
979
|
const { get: get$3, translate } = MatrixHelper;
|
|
974
980
|
function createData(leafPaint, image, paint, box) {
|
|
975
981
|
let { width, height } = image;
|
|
976
|
-
const { opacity, mode, offset, scale, rotation, blendMode } = paint;
|
|
982
|
+
const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
|
|
977
983
|
const sameBox = box.width === width && box.height === height;
|
|
978
984
|
if (blendMode)
|
|
979
985
|
leafPaint.blendMode = blendMode;
|
|
980
986
|
const data = leafPaint.data = { mode };
|
|
987
|
+
let x, y, scaleX, scaleY;
|
|
988
|
+
if (offset)
|
|
989
|
+
x = offset.x, y = offset.y;
|
|
990
|
+
if (size) {
|
|
991
|
+
scaleX = (typeof size === 'number' ? size : size.width) / width;
|
|
992
|
+
scaleY = (typeof size === 'number' ? size : size.height) / height;
|
|
993
|
+
}
|
|
994
|
+
else if (scale) {
|
|
995
|
+
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
996
|
+
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
997
|
+
}
|
|
981
998
|
switch (mode) {
|
|
982
999
|
case 'strench':
|
|
983
1000
|
if (!sameBox)
|
|
@@ -988,12 +1005,14 @@ function createData(leafPaint, image, paint, box) {
|
|
|
988
1005
|
}
|
|
989
1006
|
break;
|
|
990
1007
|
case 'clip':
|
|
991
|
-
if (offset ||
|
|
992
|
-
clipMode(data, box,
|
|
1008
|
+
if (offset || scaleX || rotation)
|
|
1009
|
+
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
993
1010
|
break;
|
|
994
1011
|
case 'repeat':
|
|
995
|
-
if (!sameBox ||
|
|
996
|
-
repeatMode(data, box, width, height,
|
|
1012
|
+
if (!sameBox || scaleX || rotation)
|
|
1013
|
+
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
|
|
1014
|
+
if (!repeat)
|
|
1015
|
+
data.repeat = 'repeat';
|
|
997
1016
|
break;
|
|
998
1017
|
case 'fit':
|
|
999
1018
|
case 'cover':
|
|
@@ -1005,6 +1024,8 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1005
1024
|
data.height = height;
|
|
1006
1025
|
if (opacity)
|
|
1007
1026
|
data.opacity = opacity;
|
|
1027
|
+
if (repeat)
|
|
1028
|
+
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
1008
1029
|
}
|
|
1009
1030
|
|
|
1010
1031
|
function image(ui, attrName, attrValue, box, firstUse) {
|
|
@@ -1051,11 +1072,11 @@ function hasNaturalSize(ui, attrName, image) {
|
|
|
1051
1072
|
d.__naturalWidth = image.width;
|
|
1052
1073
|
d.__naturalHeight = image.height;
|
|
1053
1074
|
if (!d.__getInput('width') || !d.__getInput('height')) {
|
|
1075
|
+
ui.forceUpdate('width');
|
|
1054
1076
|
if (ui.__proxyData) {
|
|
1055
1077
|
ui.setProxyAttr('width', ui.__.width);
|
|
1056
1078
|
ui.setProxyAttr('height', ui.__.height);
|
|
1057
1079
|
}
|
|
1058
|
-
ui.forceUpdate('width');
|
|
1059
1080
|
return false;
|
|
1060
1081
|
}
|
|
1061
1082
|
}
|
|
@@ -1108,7 +1129,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1108
1129
|
scaleX = Math.abs(scaleX);
|
|
1109
1130
|
scaleY = Math.abs(scaleY);
|
|
1110
1131
|
const { image, data } = paint;
|
|
1111
|
-
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform,
|
|
1132
|
+
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
|
|
1112
1133
|
if (sx) {
|
|
1113
1134
|
imageMatrix = get$2();
|
|
1114
1135
|
copy$1(imageMatrix, transform);
|
|
@@ -1121,7 +1142,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1121
1142
|
width *= scaleX;
|
|
1122
1143
|
height *= scaleY;
|
|
1123
1144
|
const size = width * height;
|
|
1124
|
-
if (
|
|
1145
|
+
if (!repeat) {
|
|
1125
1146
|
if (size > Platform.image.maxCacheSize)
|
|
1126
1147
|
return false;
|
|
1127
1148
|
}
|
|
@@ -1151,7 +1172,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1151
1172
|
}
|
|
1152
1173
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
1153
1174
|
}
|
|
1154
|
-
const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity),
|
|
1175
|
+
const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), repeat || (Platform.origin.noRepeat || 'no-repeat'));
|
|
1155
1176
|
try {
|
|
1156
1177
|
if (paint.transform)
|
|
1157
1178
|
paint.transform = null;
|
|
@@ -1179,7 +1200,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1179
1200
|
else {
|
|
1180
1201
|
const { data } = paint;
|
|
1181
1202
|
if (allowPaint) {
|
|
1182
|
-
if (data.
|
|
1203
|
+
if (!data.repeat) {
|
|
1183
1204
|
let { width, height } = data;
|
|
1184
1205
|
width *= abs(scaleX) * canvas.pixelRatio;
|
|
1185
1206
|
height *= abs(scaleY) * canvas.pixelRatio;
|
|
@@ -2179,6 +2200,7 @@ function decorationText(drawData, style) {
|
|
|
2179
2200
|
}
|
|
2180
2201
|
}
|
|
2181
2202
|
|
|
2203
|
+
const { top, right, bottom, left } = Direction4;
|
|
2182
2204
|
const TextConvert = {
|
|
2183
2205
|
getDrawData(content, style) {
|
|
2184
2206
|
if (typeof content !== 'string')
|
|
@@ -2186,16 +2208,15 @@ const TextConvert = {
|
|
|
2186
2208
|
let x = 0, y = 0;
|
|
2187
2209
|
let width = style.__getInput('width') || 0;
|
|
2188
2210
|
let height = style.__getInput('height') || 0;
|
|
2189
|
-
const { textDecoration, __font, padding } = style;
|
|
2211
|
+
const { textDecoration, __font, __padding: padding } = style;
|
|
2190
2212
|
if (padding) {
|
|
2191
|
-
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
2192
2213
|
if (width) {
|
|
2193
|
-
x = left;
|
|
2194
|
-
width -= (right + left);
|
|
2214
|
+
x = padding[left];
|
|
2215
|
+
width -= (padding[right] + padding[left]);
|
|
2195
2216
|
}
|
|
2196
2217
|
if (height) {
|
|
2197
|
-
y = top;
|
|
2198
|
-
height -= (top + bottom);
|
|
2218
|
+
y = padding[top];
|
|
2219
|
+
height -= (padding[top] + padding[bottom]);
|
|
2199
2220
|
}
|
|
2200
2221
|
}
|
|
2201
2222
|
const drawData = {
|
|
@@ -2205,6 +2226,8 @@ const TextConvert = {
|
|
|
2205
2226
|
font: Platform.canvas.font = __font
|
|
2206
2227
|
};
|
|
2207
2228
|
createRows(drawData, content, style);
|
|
2229
|
+
if (padding)
|
|
2230
|
+
padAutoText(padding, drawData, style, width, height);
|
|
2208
2231
|
layoutText(drawData, style);
|
|
2209
2232
|
layoutChar(drawData, style, width);
|
|
2210
2233
|
if (drawData.overflow)
|
|
@@ -2214,6 +2237,32 @@ const TextConvert = {
|
|
|
2214
2237
|
return drawData;
|
|
2215
2238
|
}
|
|
2216
2239
|
};
|
|
2240
|
+
function padAutoText(padding, drawData, style, width, height) {
|
|
2241
|
+
if (!width) {
|
|
2242
|
+
switch (style.textAlign) {
|
|
2243
|
+
case 'left':
|
|
2244
|
+
offsetText(drawData, 'x', padding[left]);
|
|
2245
|
+
break;
|
|
2246
|
+
case 'right':
|
|
2247
|
+
offsetText(drawData, 'x', -padding[right]);
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
if (!height) {
|
|
2251
|
+
switch (style.verticalAlign) {
|
|
2252
|
+
case 'top':
|
|
2253
|
+
offsetText(drawData, 'y', padding[top]);
|
|
2254
|
+
break;
|
|
2255
|
+
case 'bottom':
|
|
2256
|
+
offsetText(drawData, 'y', -padding[bottom]);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
function offsetText(drawData, attrName, value) {
|
|
2261
|
+
const { bounds, rows } = drawData;
|
|
2262
|
+
bounds[attrName] += value;
|
|
2263
|
+
for (let i = 0; i < rows.length; i++)
|
|
2264
|
+
rows[i][attrName] += value;
|
|
2265
|
+
}
|
|
2217
2266
|
|
|
2218
2267
|
const ColorConvert = {
|
|
2219
2268
|
string(color, opacity) {
|
package/dist/worker.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 a,LeafHelper as r,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,Debug as l,LeafLevelList as c,LayoutEvent as u,Run as f,ImageManager as _,Platform as g,AnimateEvent as p,ResizeEvent as w,BoundsHelper as y,Creator as m,LeaferCanvasBase as v,canvasPatch as x,LeaferImage as B,InteractionBase as b,FileHelper as R,MatrixHelper as E,ImageEvent as k,PointHelper as L,MathHelper as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as M,ImageManager as C,Paint as O,Effect as T,TextConvert as I,Export as W}from"@leafer-ui/core";export*from"@leafer-ui/core";class D{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_(a.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:P,updateBounds:F,updateAllWorldOpacity:N}=r,{pushAllChildBranch:Y,pushAllParent:U}=o;const{worldBounds:H}=h,V={x:0,y:0,width:1e5,height:1e5};class X{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,H)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(V):this.afterBounds.setListWithFn(t,H),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:j}=r,G=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){G.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?G.warn("layouting"):this.times>3?G.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=f.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=u,o=this.getBlocks(s);o.forEach((t=>t.setBefore())),i.emitEvent(new u(n,o,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?(P(t,!0),e.add(t),t.isBranch&&Y(t,e),U(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),U(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||F(s[t])}F(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&N(t),t.__updateChange()}))}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new u(a,o,this.times)),i.emitEvent(new u(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:a}=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(a,r,this.times)),this.addBlocks(r),f.end(e)}static fullLayout(t){q(t,!0),t.isBranch?o.updateBounds(t):r.updateBounds(t),j(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new X([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new X(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 Q=l.get("Renderer");class Z{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 d,Q.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),_.clearRecycled()}catch(t){this.rendering=!1,Q.error(t)}Q.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Q.warn("rendering"):this.times>3?Q.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,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 Q.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new d(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,a),i.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),f.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 d;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();g.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(p.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new d(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||Q.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 K;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(K||(K={}));const{hitRadiusPoint:$}=y;class J{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 a=this.findList,r=this.getBestMatchLeaf(),o=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:o,leaf:r,throughPath:a.length?this.getThroughPath(a):o}:{path:o,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,a,r;for(let t=0,e=s.length;t<e;t++){n=s[t],a=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!a||!a.has(r));t++)i.add(r)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||$(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:tt,NoAndSkip:et,YesAndSkip:it}=K;class st{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 J(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"===g.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,a;for(let r=0,o=t.length;r<o;r++){if(n=t[r],a=e(n,s),a===tt||a===it){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<et&&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_(a.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(m,{watcher:(t,e)=>new D(t,e),layouter:(t,e)=>new z(t,e),renderer:(t,e,i)=>new Z(t,e,i),selector:(t,e)=>new st(t,e)}),g.layout=z.fullLayout;class nt extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=g.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i,this.clientBounds=this.bounds}}x(OffscreenCanvasRenderingContext2D.prototype),x(Path2D.prototype);const{mineType:at}=R;function rt(t,e){g.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:at(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:at(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,i)=>{!t.startsWith("data:")&&g.image.suffix&&(t+=(t.includes("?")?"&":"?")+g.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{e(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},g.canvas=m.canvas(),g.conicGradientSupport=!!g.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new nt(t,e),image:t=>new B(t),hitCanvas:(t,e)=>new nt(t,e),interaction:(t,e,i,s)=>new b(t,e,i,s)}),g.name="web",g.isWorker=!0,g.requestRender=function(t){requestAnimationFrame(t)},g.devicePixelRatio=1;const{userAgent:ot}=navigator;ot.indexOf("Firefox")>-1?(g.conicGradientRotate90=!0,g.intWheelDeltaY=!0):ot.indexOf("Safari")>-1&&-1===ot.indexOf("Chrome")&&(g.fullImageShadow=!0),ot.indexOf("Windows")>-1?(g.os="Windows",g.intWheelDeltaY=!0):ot.indexOf("Mac")>-1?g.os="Mac":ot.indexOf("Linux")>-1&&(g.os="Linux");const{get:dt,rotateOfOuter:ht,translate:lt,scaleOfOuter:ct,scale:ut,rotate:ft}=E;const{get:_t,translate:gt}=E;function pt(t,e,i,s){let{width:n,height:a}=e;const{opacity:r,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===a;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=s.width,a=s.height),(s.x||s.y)&&(f.transform=_t(),gt(f.transform,s.x,s.y));break;case"clip":(d||h||l)&&function(t,e,i,s,n){const a=dt();lt(a,e.x,e.y),i&<(a,i.x,i.y),s&&("number"==typeof s?ut(a,s):ut(a,s.x,s.y),t.scaleX=a.a,t.scaleY=a.d),n&&ft(a,n),t.transform=a}(f,s,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,i,s,n,a){const r=dt();if(a)switch(ft(r,a),a){case 90:lt(r,s,0);break;case 180:lt(r,i,s);break;case 270:lt(r,0,i)}lt(r,e.x,e.y),n&&(ct(r,e,n),t.scaleX=t.scaleY=n),t.transform=r}(f,s,n,a,h,l);break;default:u&&!l||function(t,e,i,s,n,a){const r=dt(),o=a&&180!==a,d=i.width/(o?n:s),h=i.height/(o?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;lt(r,c,u),ut(r,l),a&&ht(r,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=r}(f,o,s,n,a,l)}f.width=n,f.height=a,r&&(f.opacity=r)}function wt(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 yt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new k(t,e))}function mt(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{d(s.next(t))}catch(t){a(t)}}function o(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const vt={},{get:xt,scale:Bt,copy:bt}=E;function Rt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const a=s+"-"+n;if(e.patternId===a||t.destroyed)return!1;{s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e;let o,d,{width:h,height:l,scaleX:c,scaleY:u,opacity:f,transform:_,mode:p}=r;c&&(d=xt(),bt(d,_),Bt(d,1/c,1/u),s*=c,n*=u),s*=i,n*=i,h*=s,l*=n;const w=h*l;if("repeat"!==e.data.mode&&w>g.image.maxCacheSize)return!1;let y=g.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(o=Math.sqrt(w/y)),o&&(s/=o,n/=o,h/=o,l/=o),c&&(s/=c,n/=u),(_||1!==s||1!==n)&&(d||(d=xt(),_&&bt(d,_)),Bt(d,1/s,1/n));const m=g.canvas.createPattern(t.getCanvas(h<1?1:h,l<1?1:l,f),"repeat"===p?"repeat":g.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),d&&(m.setTransform?m.setTransform(d):e.transform=d)}catch(t){e.transform=d}return e.style=m,e.patternId=a,!0}}const{abs:Et}=Math;function kt(t,e,i,s){const{scaleX:n,scaleY:a}=t.__world;if(i.data&&i.patternId!==n+"-"+a){const{data:r}=i;if(s)if("repeat"!==r.mode){let{width:t,height:i}=r;t*=Et(n)*e.pixelRatio,i*=Et(a)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>g.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||vt.running?Rt(t,i,e.pixelRatio):i.patternTask||(i.patternTask=_.patternTasker.add((()=>mt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&Rt(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1}function Lt(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,r;for(let o=0,d=i.length;o<d;o++)s=i[o].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,_.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[o].loadId,!a.some((t=>t.url===r)))));return n}return null}function St(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=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,a)}function At(t,e,i,s){const{strokeAlign:n}=e.__,a="string"!=typeof t;switch(n){case"center":i.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?Ot(t,!0,e,i):Ct(e,i);break;case"inside":Mt("inside",t,a,e,i,s);break;case"outside":Mt("outside",t,a,e,i,s)}}function Mt(t,e,i,s,n,a){const{strokeWidth:r,__font:o}=s.__,d=n.getSameCanvas(!0);d.setStroke(i?void 0:e,2*r,s.__),d.font=o,i?Ot(e,!0,s,d):Ct(s,d),d.blendMode="outside"===t?"destination-out":"destination-in",St(s,d),d.blendMode="normal",s.__worldFlipped||a.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,s.__world,s.__layout.renderBounds),d.recycle()}function Ct(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=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,a)}function Ot(t,e,i,s){let n;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&kt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Ct(i,s):s.stroke(),s.restoreBlendMode()):e?Ct(i,s):s.stroke())}const{getSpread:Tt,getOuterOf:It,getByMove:Wt,getIntersectData:Dt}=y;const Pt={x:.5,y:0},Ft={x:.5,y:1};function Nt(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,M.string(s.color,i))}const{set:Yt,getAngle:Ut,getDistance:Ht}=L,{get:Vt,rotateOfOuter:Xt,scaleOfOuter:qt}=E,jt={x:.5,y:.5},Gt={x:.5,y:1},zt={},Qt={};const{set:Zt,getAngle:Kt,getDistance:$t}=L,{get:Jt,rotateOfOuter:te,scaleOfOuter:ee}=E,ie={x:.5,y:.5},se={x:.5,y:1},ne={},ae={};let re;function oe(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:a,color:r,opacity:o}=e;return{type:n,blendMode:a,style:M.string(r,o)};case"image":return function(t,e,i,s,n){const a={type:i.type},r=a.image=_.get(i),o=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(wt(t,e,r)&&pt(a,r,i,s),n&&(yt(k.LOAD,o),yt(k.LOADED,o))):r.error?n&&(t.forceUpdate("surface"),o.error=r.error,yt(k.ERROR,o)):(n&&yt(k.LOAD,o),a.loadId=r.load((()=>{t.destroyed||(wt(t,e,r)&&(pt(a,r,i,s),t.forceUpdate("surface")),yt(k.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,yt(k.ERROR,o)}))),a}(i,t,e,s,!re||!re[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:a,opacity:r}=t;i||(i=Pt),s||(s=Ft);const o=g.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);Nt(o,t.stops,r);const d={type:n,style:o};return a&&(d.blendMode=a),d}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:a,blendMode:r,stretch:o}=t;i||(i=jt),s||(s=Gt);const{x:d,y:h,width:l,height:c}=e;let u;Yt(zt,d+i.x*l,h+i.y*c),Yt(Qt,d+s.x*l,h+s.y*c),(l!==c||o)&&(u=Vt(),qt(u,zt,l/c*(o||1),1),Xt(u,zt,Ut(zt,Qt)+90));const f=g.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Ht(zt,Qt));Nt(f,t.stops,a);const _={type:n,style:f,transform:u};return r&&(_.blendMode=r),_}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:a,blendMode:r,stretch:o}=t;i||(i=ie),s||(s=se);const{x:d,y:h,width:l,height:c}=e;Zt(ne,d+i.x*l,h+i.y*c),Zt(ae,d+s.x*l,h+s.y*c);const u=Jt(),f=Kt(ne,ae);g.conicGradientRotate90?(ee(u,ne,l/c*(o||1),1),te(u,ne,f+90)):(ee(u,ne,1,l/c*(o||1)),te(u,ne,f));const _=g.conicGradientSupport?g.canvas.createConicGradient(0,ne.x,ne.y):g.canvas.createRadialGradient(ne.x,ne.y,0,ne.x,ne.y,$t(ne,ae));Nt(_,t.stops,a);const p={type:n,style:_,transform:u};return r&&(p.blendMode=r),p}(e,s);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}var de=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,a,r=s.__input[t];r instanceof Array||(r=[r]),re=Lt(t,s);for(let s=0,a=r.length;s<a;s++)n=oe(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&&(a=C.isPixel(t))}"fill"===t?s.__pixelFill=a:s.__pixelStroke=a},drawTextStroke:Ct,fill:function(t,e,i){i.fillStyle=t,e.__.__font?St(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:St,fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let r=0,o=t.length;r<o;r++)s=t[r],s.image&&kt(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?St(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?St(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?St(e,i):n?i.fill(n):i.fill())},recycleImage:Lt,shape:function(t,e,i){const s=e.getSameCanvas();let n,a,r,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,i.matrix))i.matrix?(h*=i.matrix.a,l*=i.matrix.d,n=r=It(d,i.matrix)):n=r=d,o=s;else{const{renderShapeSpread:s}=t.__layout,c=Dt(s?Tt(e.bounds,s*h,s*l):e.bounds,d,i.matrix);a=e.bounds.getFitMatrix(c),a.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,i),h*=a.a,l*=a.d),r=It(d,a),n=Wt(r,-a.e,-a.f),i.matrix&&a.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:a})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:n,worldCanvas:o,shapeBounds:r,scaleX:h,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:a,strokeAlign:r,__font:o}=n;if(a)if(o)At(t,e,i,s);else switch(r){case"center":i.setStroke(t,a,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*a,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*a,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:At,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:a,strokeAlign:r,__font:o}=n;if(a)if(o)At(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,a,n),Ot(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*a,n),n.windingRule?i.clip(n.windingRule):i.clip(),Ot(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,e.__),Ot(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(r),e.__worldFlipped||s.matrix?i.copyWorldByReset(o):i.copyWorldToInner(o,e.__world,r),o.recycle()}}});const{copy:he,toOffsetOutBounds:le}=y,ce={},ue={};function fe(t,e,i,s){const{bounds:n,shapeBounds:a}=s;if(g.fullImageShadow){if(he(ce,t.bounds),ce.x+=e.x-a.x,ce.y+=e.y-a.y,i){const{matrix:t}=s;ce.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ce.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ce.width*=i,ce.height*=i}t.copyWorld(s.canvas,t.bounds,ce)}else i&&(he(ce,e),ce.x-=e.width/2*(i-1),ce.y-=e.height/2*(i-1),ce.width*=i,ce.height*=i),t.copyWorld(s.canvas,a,i?ce:e)}const{toOffsetOutBounds:_e}=y,ge={};var pe=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,a;const{__world:r,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;_e(l,ge),d.forEach(((d,p)=>{_.save(),_.setWorldShadow(ge.offsetX+d.x*u,ge.offsetY+d.y*f,d.blur*u),a=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,fe(_,ge,a,i),_.restore(),h?(_.copyWorld(_,l,r,"copy"),_.copyWorld(h,r,r,"source-out"),n=r):(_.copyWorld(i.canvas,c,l,"source-out"),n=l),_.fillWorld(n,d.color,"source-in"),t.__worldFlipped||s.matrix?e.copyWorldByReset(_,n,r,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()},shadow:function(t,e,i,s){let n,a;const{__world:r,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;le(l,ue),d.forEach(((d,p)=>{_.setWorldShadow(ue.offsetX+d.x*u,ue.offsetY+d.y*f,d.blur*u,d.color),a=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,fe(_,ue,a,i),n=l,d.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,r,"copy"),n=r),h?_.copyWorld(h,r,r,"destination-out"):_.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped||s.matrix?e.copyWorldByReset(_,n,r,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()}});const we=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ye=we+"_#~&*+\\=|≮≯≈≠=…",me=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 ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const xe=ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Be=ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),be=ve(we),Re=ve(ye),Ee=ve("- —/~|┆·");var ke;!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"}(ke||(ke={}));const{Letter:Le,Single:Se,Before:Ae,After:Me,Symbol:Ce,Break:Oe}=ke;function Te(t){return xe[t]?Le:Ee[t]?Oe:Be[t]?Ae:be[t]?Me:Re[t]?Ce:me.test(t)?Se:Le}const Ie={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function We(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:De}=Ie,{Letter:Pe,Single:Fe,Before:Ne,After:Ye,Symbol:Ue,Break:He}=ke;let Ve,Xe,qe,je,Ge,ze,Qe,Ze,Ke,$e,Je,ti,ei,ii,si,ni,ai=[];function ri(t,e){Ke&&!Ze&&(Ze=Ke),Ve.data.push({char:t,width:e}),qe+=e}function oi(){je+=qe,Ve.width=qe,Xe.words.push(Ve),Ve={data:[]},qe=0}function di(){ii&&(si.paraNumber++,Xe.paraStart=!0,ii=!1),Ke&&(Xe.startCharSize=Ze,Xe.endCharSize=Ke,Ze=0),Xe.width=je,ni.width&&De(Xe),ai.push(Xe),Xe={words:[]},je=0}const hi={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:o,padding:d}=e;if(d){const[t,e,r,o]=S.fourNumber(d);n&&(i=o,n-=e+o),a&&(s=t,a-=t+r)}const h={bounds:{x:i,y:s,width:n,height:a},rows:[],paraNumber:0,font:g.canvas.font=o};return function(t,e,i){si=t,ai=t.rows,ni=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:a}=i,{canvas:r}=g,{width:o,height:d}=ni;if(o||d||s||"none"!==a){const t="none"!==i.textWrap,d="break"===i.textWrap;ii=!0,Je=null,Ze=Qe=Ke=qe=je=0,Ve={data:[]},Xe={words:[]};for(let i=0,h=e.length;i<h;i++)ze=e[i],"\n"===ze?(qe&&oi(),Xe.paraEnd=!0,di(),ii=!0):($e=Te(ze),$e===Pe&&"none"!==a&&(ze=We(ze,a,!qe)),Qe=r.measureText(ze).width,s&&(s<0&&(Ke=Qe),Qe+=s),ti=$e===Fe&&(Je===Fe||Je===Pe)||Je===Fe&&$e!==Ye,ei=!($e!==Ne&&$e!==Fe||Je!==Ue&&Je!==Ye),Ge=ii&&n?o-n:o,t&&o&&je+qe+Qe>Ge&&(d?(qe&&oi(),di()):(ei||(ei=$e===Pe&&Je==Ye),ti||ei||$e===He||$e===Ne||$e===Fe||qe+Qe>Ge?(qe&&oi(),di()):di()))," "===ze&&!0!==ii&&je+qe===0||($e===He?(" "===ze&&qe&&oi(),ri(ze,Qe),oi()):ti||ei?(qe&&oi(),ri(ze,Qe)):ri(ze,Qe)),Je=$e);qe&&oi(),je&&di(),ai.length>0&&(ai[ai.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{si.paraNumber++,ai.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(o&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=n,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<s.x&&(s.x=u),f>s.width&&(s.width=f),o&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(h,e),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!o&&(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,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(h,e,n),h.overflow&&function(t,e){const{rows:i,overflow:s}=t;let{textOverflow:n}=e;if(i.splice(s),"hide"!==n){let t,a;"ellipsis"===n&&(n="...");const r=g.canvas.measureText(n).width,o=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],a=t.x+t.width,!(s===i&&a<o));s--){if(a<o&&" "!==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:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,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}}(h,e),h}},li={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){ui||(ui=new A);return new Promise((e=>{ui.add((()=>mt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:a}=t;a?a.waitViewCompleted((()=>mt(this,void 0,void 0,(function*(){let t,r,o,{canvas:d}=a,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=a.config.fill,a.__render(d,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}o=e.includes(".")?yield d.saveAs(e,t):r?yield d.toBlob(e,t):yield d.toDataURL(e,t),s({data:o}),n(),ci.running=!1,h&&d.recycle()})))):(s({data:!1}),n(),ci.running=!1)}))))}};let ui;Object.assign(O,de),Object.assign(T,pe),Object.assign(I,hi),Object.assign(M,li),Object.assign(W,ci),rt();export{z as Layouter,nt as LeaferCanvas,Z as Renderer,st as Selector,D as Watcher,rt as useCanvas};
|
|
1
|
+
import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as a,LeafHelper as r,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,Debug as l,LeafLevelList as c,LayoutEvent as u,Run as f,ImageManager as _,Platform as g,AnimateEvent as p,ResizeEvent as y,BoundsHelper as w,Creator as m,LeaferCanvasBase as x,canvasPatch as v,LeaferImage as b,InteractionBase as B,FileHelper as R,MatrixHelper as E,ImageEvent as k,PointHelper as L,Direction4 as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as M,ImageManager as C,Paint as O,Effect as T,TextConvert as I,Export as W}from"@leafer-ui/core";export*from"@leafer-ui/core";class D{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_(a.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:P,updateBounds:F,updateAllWorldOpacity:Y}=r,{pushAllChildBranch:N,pushAllParent:U}=o;const{worldBounds:H}=h,V={x:0,y:0,width:1e5,height:1e5};class X{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,H)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(V):this.afterBounds.setListWithFn(t,H),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:j}=r,z=l.get("Layouter");class G{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){z.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?z.warn("layouting"):this.times>3?z.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=f.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=u,o=this.getBlocks(s);o.forEach((t=>t.setBefore())),i.emitEvent(new u(n,o,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?(P(t,!0),e.add(t),t.isBranch&&N(t,e),U(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),U(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||F(s[t])}F(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Y(t),t.__updateChange()}))}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new u(a,o,this.times)),i.emitEvent(new u(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:a}=u,r=this.getBlocks(new t(i));i.emitEvent(new u(s,r,this.times)),G.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new u(n,r,this.times)),i.emitEvent(new u(a,r,this.times)),this.addBlocks(r),f.end(e)}static fullLayout(t){q(t,!0),t.isBranch?o.updateBounds(t):r.updateBounds(t),j(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new X([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new X(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 Q=l.get("Renderer");class Z{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 d,Q.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),_.clearRecycled()}catch(t){this.rendering=!1,Q.error(t)}Q.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Q.warn("rendering"):this.times>3?Q.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,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 Q.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new d(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,a),i.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),f.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 d;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();g.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(p.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new d(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||Q.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_(y.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 K;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(K||(K={}));const{hitRadiusPoint:$}=w;class J{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 a=this.findList,r=this.getBestMatchLeaf(),o=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:o,leaf:r,throughPath:a.length?this.getThroughPath(a):o}:{path:o,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,a,r;for(let t=0,e=s.length;t<e;t++){n=s[t],a=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!a||!a.has(r));t++)i.add(r)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||$(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:tt,NoAndSkip:et,YesAndSkip:it}=K;class st{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 J(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"===g.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,a;for(let r=0,o=t.length;r<o;r++){if(n=t[r],a=e(n,s),a===tt||a===it){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<et&&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_(a.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(m,{watcher:(t,e)=>new D(t,e),layouter:(t,e)=>new G(t,e),renderer:(t,e,i)=>new Z(t,e,i),selector:(t,e)=>new st(t,e)}),g.layout=G.fullLayout;class nt extends x{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=g.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i,this.clientBounds=this.bounds}}v(OffscreenCanvasRenderingContext2D.prototype),v(Path2D.prototype);const{mineType:at}=R;function rt(t,e){g.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:at(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:at(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,i)=>{!t.startsWith("data:")&&g.image.suffix&&(t+=(t.includes("?")?"&":"?")+g.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{e(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},g.canvas=m.canvas(),g.conicGradientSupport=!!g.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new nt(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new nt(t,e),interaction:(t,e,i,s)=>new B(t,e,i,s)}),g.name="web",g.isWorker=!0,g.requestRender=function(t){requestAnimationFrame(t)},g.devicePixelRatio=1;const{userAgent:ot}=navigator;ot.indexOf("Firefox")>-1?(g.conicGradientRotate90=!0,g.intWheelDeltaY=!0):ot.indexOf("Safari")>-1&&-1===ot.indexOf("Chrome")&&(g.fullImageShadow=!0),ot.indexOf("Windows")>-1?(g.os="Windows",g.intWheelDeltaY=!0):ot.indexOf("Mac")>-1?g.os="Mac":ot.indexOf("Linux")>-1&&(g.os="Linux");let dt={};const{get:ht,rotateOfOuter:lt,translate:ct,scaleOfOuter:ut,scale:ft,rotate:_t}=E;const{get:gt,translate:pt}=E;function yt(t,e,i,s){let{width:n,height:a}=e;const{opacity:r,mode:o,offset:d,scale:h,size:l,rotation:c,blendMode:u,repeat:f}=i,_=s.width===n&&s.height===a;u&&(t.blendMode=u);const g=t.data={mode:o};let p,y,w,m;switch(d&&(p=d.x,y=d.y),l?(w=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/a):h&&(w="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y),o){case"strench":_||(n=s.width,a=s.height),(s.x||s.y)&&(g.transform=gt(),pt(g.transform,s.x,s.y));break;case"clip":(d||w||c)&&function(t,e,i,s,n,a,r){const o=ht();ct(o,e.x,e.y),(i||s)&&ct(o,i,s),n&&(ft(o,n,a),t.scaleX=o.a,t.scaleY=o.d),r&&_t(o,r),t.transform=o}(g,s,p,y,w,m,c);break;case"repeat":(!_||w||c)&&function(t,e,i,s,n,a,r,o,d){const h=ht();if(d)switch(_t(h,d),d){case 90:ct(h,s,0);break;case 180:ct(h,i,s);break;case 270:ct(h,0,i)}dt.x=e.x,dt.y=e.y,(n||a)&&(dt.x+=n,dt.y+=a),ct(h,dt.x,dt.y),r&&(ut(h,dt,r,o),t.scaleX=r,t.scaleY=o),t.transform=h}(g,s,n,a,p,y,w,m,c),f||(g.repeat="repeat");break;default:_&&!c||function(t,e,i,s,n,a){const r=ht(),o=a&&180!==a,d=i.width/(o?n:s),h=i.height/(o?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ct(r,c,u),ft(r,l),a&<(r,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=r}(g,o,s,n,a,c)}g.width=n,g.height=a,r&&(g.opacity=r),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}function wt(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 mt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new k(t,e))}function xt(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{d(s.next(t))}catch(t){a(t)}}function o(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const vt={},{get:bt,scale:Bt,copy:Rt}=E;function Et(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const a=s+"-"+n;if(e.patternId===a||t.destroyed)return!1;{s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e;let o,d,{width:h,height:l,scaleX:c,scaleY:u,opacity:f,transform:_,repeat:p}=r;c&&(d=bt(),Rt(d,_),Bt(d,1/c,1/u),s*=c,n*=u),s*=i,n*=i,h*=s,l*=n;const y=h*l;if(!p&&y>g.image.maxCacheSize)return!1;let w=g.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}y>w&&(o=Math.sqrt(y/w)),o&&(s/=o,n/=o,h/=o,l/=o),c&&(s/=c,n/=u),(_||1!==s||1!==n)&&(d||(d=bt(),_&&Rt(d,_)),Bt(d,1/s,1/n));const m=g.canvas.createPattern(t.getCanvas(h<1?1:h,l<1?1:l,f),p||g.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),d&&(m.setTransform?m.setTransform(d):e.transform=d)}catch(t){e.transform=d}return e.style=m,e.patternId=a,!0}}const{abs:kt}=Math;function Lt(t,e,i,s){const{scaleX:n,scaleY:a}=t.__world;if(i.data&&i.patternId!==n+"-"+a){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=kt(n)*e.pixelRatio,i*=kt(a)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>g.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||vt.running?Et(t,i,e.pixelRatio):i.patternTask||(i.patternTask=_.patternTasker.add((()=>xt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&Et(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1}function St(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,r;for(let o=0,d=i.length;o<d;o++)s=i[o].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,_.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[o].loadId,!a.some((t=>t.url===r)))));return n}return null}function At(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=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,a)}function Mt(t,e,i,s){const{strokeAlign:n}=e.__,a="string"!=typeof t;switch(n){case"center":i.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?Tt(t,!0,e,i):Ot(e,i);break;case"inside":Ct("inside",t,a,e,i,s);break;case"outside":Ct("outside",t,a,e,i,s)}}function Ct(t,e,i,s,n,a){const{strokeWidth:r,__font:o}=s.__,d=n.getSameCanvas(!0);d.setStroke(i?void 0:e,2*r,s.__),d.font=o,i?Tt(e,!0,s,d):Ot(s,d),d.blendMode="outside"===t?"destination-out":"destination-in",At(s,d),d.blendMode="normal",s.__worldFlipped||a.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,s.__world,s.__layout.renderBounds),d.recycle()}function Ot(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=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,a)}function Tt(t,e,i,s){let n;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&Lt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Ot(i,s):s.stroke(),s.restoreBlendMode()):e?Ot(i,s):s.stroke())}const{getSpread:It,getOuterOf:Wt,getByMove:Dt,getIntersectData:Pt}=w;const Ft={x:.5,y:0},Yt={x:.5,y:1};function Nt(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,M.string(s.color,i))}const{set:Ut,getAngle:Ht,getDistance:Vt}=L,{get:Xt,rotateOfOuter:qt,scaleOfOuter:jt}=E,zt={x:.5,y:.5},Gt={x:.5,y:1},Qt={},Zt={};const{set:Kt,getAngle:$t,getDistance:Jt}=L,{get:te,rotateOfOuter:ee,scaleOfOuter:ie}=E,se={x:.5,y:.5},ne={x:.5,y:1},ae={},re={};let oe;function de(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:a,color:r,opacity:o}=e;return{type:n,blendMode:a,style:M.string(r,o)};case"image":return function(t,e,i,s,n){const a={type:i.type},r=a.image=_.get(i),o=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(wt(t,e,r)&&yt(a,r,i,s),n&&(mt(k.LOAD,o),mt(k.LOADED,o))):r.error?n&&(t.forceUpdate("surface"),o.error=r.error,mt(k.ERROR,o)):(n&&mt(k.LOAD,o),a.loadId=r.load((()=>{t.destroyed||(wt(t,e,r)&&(yt(a,r,i,s),t.forceUpdate("surface")),mt(k.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,mt(k.ERROR,o)}))),a}(i,t,e,s,!oe||!oe[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:a,opacity:r}=t;i||(i=Ft),s||(s=Yt);const o=g.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);Nt(o,t.stops,r);const d={type:n,style:o};return a&&(d.blendMode=a),d}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:a,blendMode:r,stretch:o}=t;i||(i=zt),s||(s=Gt);const{x:d,y:h,width:l,height:c}=e;let u;Ut(Qt,d+i.x*l,h+i.y*c),Ut(Zt,d+s.x*l,h+s.y*c),(l!==c||o)&&(u=Xt(),jt(u,Qt,l/c*(o||1),1),qt(u,Qt,Ht(Qt,Zt)+90));const f=g.canvas.createRadialGradient(Qt.x,Qt.y,0,Qt.x,Qt.y,Vt(Qt,Zt));Nt(f,t.stops,a);const _={type:n,style:f,transform:u};return r&&(_.blendMode=r),_}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:a,blendMode:r,stretch:o}=t;i||(i=se),s||(s=ne);const{x:d,y:h,width:l,height:c}=e;Kt(ae,d+i.x*l,h+i.y*c),Kt(re,d+s.x*l,h+s.y*c);const u=te(),f=$t(ae,re);g.conicGradientRotate90?(ie(u,ae,l/c*(o||1),1),ee(u,ae,f+90)):(ie(u,ae,1,l/c*(o||1)),ee(u,ae,f));const _=g.conicGradientSupport?g.canvas.createConicGradient(0,ae.x,ae.y):g.canvas.createRadialGradient(ae.x,ae.y,0,ae.x,ae.y,Jt(ae,re));Nt(_,t.stops,a);const p={type:n,style:_,transform:u};return r&&(p.blendMode=r),p}(e,s);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}var he=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,a,r=s.__input[t];r instanceof Array||(r=[r]),oe=St(t,s);for(let s=0,a=r.length;s<a;s++)n=de(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&&(a=C.isPixel(t))}"fill"===t?s.__pixelFill=a:s.__pixelStroke=a},drawTextStroke:Ot,fill:function(t,e,i){i.fillStyle=t,e.__.__font?At(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:At,fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let r=0,o=t.length;r<o;r++)s=t[r],s.image&&Lt(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?At(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?At(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?At(e,i):n?i.fill(n):i.fill())},recycleImage:St,shape:function(t,e,i){const s=e.getSameCanvas();let n,a,r,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,i.matrix))i.matrix?(h*=i.matrix.a,l*=i.matrix.d,n=r=Wt(d,i.matrix)):n=r=d,o=s;else{const{renderShapeSpread:s}=t.__layout,c=Pt(s?It(e.bounds,s*h,s*l):e.bounds,d,i.matrix);a=e.bounds.getFitMatrix(c),a.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,i),h*=a.a,l*=a.d),r=Wt(d,a),n=Dt(r,-a.e,-a.f),i.matrix&&a.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:a})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:n,worldCanvas:o,shapeBounds:r,scaleX:h,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:a,strokeAlign:r,__font:o}=n;if(a)if(o)Mt(t,e,i,s);else switch(r){case"center":i.setStroke(t,a,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*a,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*a,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:Mt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:a,strokeAlign:r,__font:o}=n;if(a)if(o)Mt(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,a,n),Tt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*a,n),n.windingRule?i.clip(n.windingRule):i.clip(),Tt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,e.__),Tt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(r),e.__worldFlipped||s.matrix?i.copyWorldByReset(o):i.copyWorldToInner(o,e.__world,r),o.recycle()}}});const{copy:le,toOffsetOutBounds:ce}=w,ue={},fe={};function _e(t,e,i,s){const{bounds:n,shapeBounds:a}=s;if(g.fullImageShadow){if(le(ue,t.bounds),ue.x+=e.x-a.x,ue.y+=e.y-a.y,i){const{matrix:t}=s;ue.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ue.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ue.width*=i,ue.height*=i}t.copyWorld(s.canvas,t.bounds,ue)}else i&&(le(ue,e),ue.x-=e.width/2*(i-1),ue.y-=e.height/2*(i-1),ue.width*=i,ue.height*=i),t.copyWorld(s.canvas,a,i?ue:e)}const{toOffsetOutBounds:ge}=w,pe={};var ye=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,a;const{__world:r,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;ge(l,pe),d.forEach(((d,p)=>{_.save(),_.setWorldShadow(pe.offsetX+d.x*u,pe.offsetY+d.y*f,d.blur*u),a=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,_e(_,pe,a,i),_.restore(),h?(_.copyWorld(_,l,r,"copy"),_.copyWorld(h,r,r,"source-out"),n=r):(_.copyWorld(i.canvas,c,l,"source-out"),n=l),_.fillWorld(n,d.color,"source-in"),t.__worldFlipped||s.matrix?e.copyWorldByReset(_,n,r,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()},shadow:function(t,e,i,s){let n,a;const{__world:r,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;ce(l,fe),d.forEach(((d,p)=>{_.setWorldShadow(fe.offsetX+d.x*u,fe.offsetY+d.y*f,d.blur*u,d.color),a=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,_e(_,fe,a,i),n=l,d.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,r,"copy"),n=r),h?_.copyWorld(h,r,r,"destination-out"):_.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped||s.matrix?e.copyWorldByReset(_,n,r,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()}});const we=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",me=we+"_#~&*+\\=|≮≯≈≠=…",xe=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 ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const be=ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Be=ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Re=ve(we),Ee=ve(me),ke=ve("- —/~|┆·");var Le;!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"}(Le||(Le={}));const{Letter:Se,Single:Ae,Before:Me,After:Ce,Symbol:Oe,Break:Te}=Le;function Ie(t){return be[t]?Se:ke[t]?Te:Be[t]?Me:Re[t]?Ce:Ee[t]?Oe:xe.test(t)?Ae:Se}const We={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function De(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:Pe}=We,{Letter:Fe,Single:Ye,Before:Ne,After:Ue,Symbol:He,Break:Ve}=Le;let Xe,qe,je,ze,Ge,Qe,Ze,Ke,$e,Je,ti,ei,ii,si,ni,ai,ri=[];function oi(t,e){$e&&!Ke&&(Ke=$e),Xe.data.push({char:t,width:e}),je+=e}function di(){ze+=je,Xe.width=je,qe.words.push(Xe),Xe={data:[]},je=0}function hi(){si&&(ni.paraNumber++,qe.paraStart=!0,si=!1),$e&&(qe.startCharSize=Ke,qe.endCharSize=$e,Ke=0),qe.width=ze,ai.width&&Pe(qe),ri.push(qe),qe={words:[]},ze=0}const{top:li,right:ci,bottom:ui,left:fi}=S,_i={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:o,__padding:d}=e;d&&(n&&(i=d[fi],n-=d[ci]+d[fi]),a&&(s=d[li],a-=d[li]+d[ui]));const h={bounds:{x:i,y:s,width:n,height:a},rows:[],paraNumber:0,font:g.canvas.font=o};return function(t,e,i){ni=t,ri=t.rows,ai=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:a}=i,{canvas:r}=g,{width:o,height:d}=ai;if(o||d||s||"none"!==a){const t="none"!==i.textWrap,d="break"===i.textWrap;si=!0,ti=null,Ke=Ze=$e=je=ze=0,Xe={data:[]},qe={words:[]};for(let i=0,h=e.length;i<h;i++)Qe=e[i],"\n"===Qe?(je&&di(),qe.paraEnd=!0,hi(),si=!0):(Je=Ie(Qe),Je===Fe&&"none"!==a&&(Qe=De(Qe,a,!je)),Ze=r.measureText(Qe).width,s&&(s<0&&($e=Ze),Ze+=s),ei=Je===Ye&&(ti===Ye||ti===Fe)||ti===Ye&&Je!==Ue,ii=!(Je!==Ne&&Je!==Ye||ti!==He&&ti!==Ue),Ge=si&&n?o-n:o,t&&o&&ze+je+Ze>Ge&&(d?(je&&di(),hi()):(ii||(ii=Je===Fe&&ti==Ue),ei||ii||Je===Ve||Je===Ne||Je===Ye||je+Ze>Ge?(je&&di(),hi()):hi()))," "===Qe&&!0!==si&&ze+je===0||(Je===Ve?(" "===Qe&&je&&di(),oi(Qe,Ze),di()):ei||ii?(je&&di(),oi(Qe,Ze)):oi(Qe,Ze)),ti=Je);je&&di(),ze&&hi(),ri.length>0&&(ri[ri.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{ni.paraNumber++,ri.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,t,e),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":gi(e,"x",t[fi]);break;case"right":gi(e,"x",-t[ci])}if(!n)switch(i.verticalAlign){case"top":gi(e,"y",t[li]);break;case"bottom":gi(e,"y",-t[ui])}}(d,h,e,n,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:y}=s,w=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(o&&w>y)w=Math.max(y,n),t.overflow=i.length;else switch(h){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=n,t.overflow>a&&m>w&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<s.x&&(s.x=u),f>s.width&&(s.width=f),o&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,e),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!o&&(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,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(h,e,n),h.overflow&&function(t,e){const{rows:i,overflow:s}=t;let{textOverflow:n}=e;if(i.splice(s),"hide"!==n){let t,a;"ellipsis"===n&&(n="...");const r=g.canvas.measureText(n).width,o=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],a=t.x+t.width,!(s===i&&a<o));s--){if(a<o&&" "!==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:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,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}}(h,e),h}};function gi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const pi={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+")"}},yi={export(t,e,i){return yi.running=!0,function(t){wi||(wi=new A);return new Promise((e=>{wi.add((()=>xt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:a}=t;a?a.waitViewCompleted((()=>xt(this,void 0,void 0,(function*(){let t,r,o,{canvas:d}=a,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=a.config.fill,a.__render(d,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}o=e.includes(".")?yield d.saveAs(e,t):r?yield d.toBlob(e,t):yield d.toDataURL(e,t),s({data:o}),n(),yi.running=!1,h&&d.recycle()})))):(s({data:!1}),n(),yi.running=!1)}))))}};let wi;Object.assign(O,he),Object.assign(T,ye),Object.assign(I,_i),Object.assign(M,pi),Object.assign(W,yi),rt();export{G as Layouter,nt as LeaferCanvas,Z as Renderer,st as Selector,D as Watcher,rt as useCanvas};
|