@leafer-draw/worker 1.0.0-rc.17 → 1.0.0-rc.19
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 +37 -19
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +723 -536
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +720 -537
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.esm.js
CHANGED
|
@@ -504,6 +504,10 @@ class Renderer {
|
|
|
504
504
|
}
|
|
505
505
|
else {
|
|
506
506
|
this.requestLayout();
|
|
507
|
+
if (this.ignore) {
|
|
508
|
+
this.ignore = this.rendering = false;
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
507
511
|
this.emitRender(RenderEvent.BEFORE);
|
|
508
512
|
if (this.config.usePartRender && this.totalTimes > 1) {
|
|
509
513
|
this.partRender();
|
|
@@ -651,9 +655,7 @@ class Renderer {
|
|
|
651
655
|
if (this.target) {
|
|
652
656
|
this.stop();
|
|
653
657
|
this.__removeListenEvents();
|
|
654
|
-
this.target = null;
|
|
655
|
-
this.canvas = null;
|
|
656
|
-
this.config = null;
|
|
658
|
+
this.target = this.canvas = this.config = null;
|
|
657
659
|
}
|
|
658
660
|
}
|
|
659
661
|
}
|
|
@@ -1050,10 +1052,6 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1050
1052
|
case 'strench':
|
|
1051
1053
|
if (!sameBox)
|
|
1052
1054
|
width = box.width, height = box.height;
|
|
1053
|
-
if (box.x || box.y) {
|
|
1054
|
-
data.transform = get$3();
|
|
1055
|
-
translate(data.transform, box.x, box.y);
|
|
1056
|
-
}
|
|
1057
1055
|
break;
|
|
1058
1056
|
case 'clip':
|
|
1059
1057
|
if (offset || scaleX || rotation)
|
|
@@ -1071,6 +1069,12 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1071
1069
|
if (!sameBox || rotation)
|
|
1072
1070
|
fillOrFitMode(data, mode, box, width, height, rotation);
|
|
1073
1071
|
}
|
|
1072
|
+
if (!data.transform) {
|
|
1073
|
+
if (box.x || box.y) {
|
|
1074
|
+
data.transform = get$3();
|
|
1075
|
+
translate(data.transform, box.x, box.y);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1074
1078
|
data.width = width;
|
|
1075
1079
|
data.height = height;
|
|
1076
1080
|
if (opacity)
|
|
@@ -1088,8 +1092,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1088
1092
|
leafPaint = cache.leafPaint;
|
|
1089
1093
|
}
|
|
1090
1094
|
else {
|
|
1091
|
-
leafPaint = { type: paint.type };
|
|
1092
|
-
leafPaint.image = image;
|
|
1095
|
+
leafPaint = { type: paint.type, image };
|
|
1093
1096
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
1094
1097
|
}
|
|
1095
1098
|
if (firstUse || image.loading)
|
|
@@ -1106,9 +1109,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1106
1109
|
onLoadError(ui, event, image.error);
|
|
1107
1110
|
}
|
|
1108
1111
|
else {
|
|
1112
|
+
ignoreRender(ui, true);
|
|
1109
1113
|
if (firstUse)
|
|
1110
1114
|
onLoad(ui, event);
|
|
1111
1115
|
leafPaint.loadId = image.load(() => {
|
|
1116
|
+
ignoreRender(ui, false);
|
|
1112
1117
|
if (!ui.destroyed) {
|
|
1113
1118
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds))
|
|
1114
1119
|
ui.forceUpdate('surface');
|
|
@@ -1116,6 +1121,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1116
1121
|
}
|
|
1117
1122
|
leafPaint.loadId = null;
|
|
1118
1123
|
}, (error) => {
|
|
1124
|
+
ignoreRender(ui, false);
|
|
1119
1125
|
onLoadError(ui, event, error);
|
|
1120
1126
|
leafPaint.loadId = null;
|
|
1121
1127
|
});
|
|
@@ -1155,11 +1161,16 @@ function emit(ui, type, data) {
|
|
|
1155
1161
|
if (ui.hasEvent(type))
|
|
1156
1162
|
ui.emitEvent(new ImageEvent(type, data));
|
|
1157
1163
|
}
|
|
1164
|
+
function ignoreRender(ui, value) {
|
|
1165
|
+
const { leafer } = ui;
|
|
1166
|
+
if (leafer && leafer.viewReady)
|
|
1167
|
+
leafer.renderer.ignore = value;
|
|
1168
|
+
}
|
|
1158
1169
|
|
|
1159
1170
|
const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
|
|
1160
1171
|
const { ceil, abs: abs$1 } = Math;
|
|
1161
1172
|
function createPattern(ui, paint, pixelRatio) {
|
|
1162
|
-
let { scaleX, scaleY } = ui.
|
|
1173
|
+
let { scaleX, scaleY } = ui.__nowWorld;
|
|
1163
1174
|
const id = scaleX + '-' + scaleY;
|
|
1164
1175
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1165
1176
|
scaleX = abs$1(scaleX);
|
|
@@ -1253,7 +1264,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1253
1264
|
|
|
1254
1265
|
const { abs } = Math;
|
|
1255
1266
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
1256
|
-
const { scaleX, scaleY } = ui.
|
|
1267
|
+
const { scaleX, scaleY } = ui.__nowWorld;
|
|
1257
1268
|
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
1258
1269
|
return false;
|
|
1259
1270
|
}
|
|
@@ -1295,7 +1306,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1295
1306
|
if (!paint.patternTask) {
|
|
1296
1307
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1297
1308
|
paint.patternTask = null;
|
|
1298
|
-
if (canvas.bounds.hit(ui.
|
|
1309
|
+
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1299
1310
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
1300
1311
|
ui.forceUpdate('surface');
|
|
1301
1312
|
}), 300);
|
|
@@ -1532,8 +1543,8 @@ function innerShadow(ui, current, shape) {
|
|
|
1532
1543
|
|
|
1533
1544
|
function blur(ui, current, origin) {
|
|
1534
1545
|
const { blur } = ui.__;
|
|
1535
|
-
origin.setWorldBlur(blur * ui.
|
|
1536
|
-
origin.copyWorldToInner(current, ui.
|
|
1546
|
+
origin.setWorldBlur(blur * ui.__nowWorld.a);
|
|
1547
|
+
origin.copyWorldToInner(current, ui.__nowWorld, ui.__layout.renderBounds);
|
|
1537
1548
|
origin.filter = 'none';
|
|
1538
1549
|
}
|
|
1539
1550
|
|
|
@@ -2164,10 +2175,10 @@ const ExportModule = {
|
|
|
2164
2175
|
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
2165
2176
|
}
|
|
2166
2177
|
else {
|
|
2167
|
-
|
|
2178
|
+
let relative = options.relative || (isLeafer ? 'inner' : 'local');
|
|
2168
2179
|
scaleX = worldTransform.scaleX;
|
|
2169
2180
|
scaleY = worldTransform.scaleY;
|
|
2170
|
-
switch (
|
|
2181
|
+
switch (relative) {
|
|
2171
2182
|
case 'inner':
|
|
2172
2183
|
matrix.set(worldTransform).invert();
|
|
2173
2184
|
break;
|
|
@@ -2180,11 +2191,18 @@ const ExportModule = {
|
|
|
2180
2191
|
scaleX = 1;
|
|
2181
2192
|
scaleY = 1;
|
|
2182
2193
|
break;
|
|
2194
|
+
case 'page':
|
|
2195
|
+
relative = leaf.leafer;
|
|
2196
|
+
default:
|
|
2197
|
+
matrix.set(worldTransform).divide(leaf.getTransform(relative)).invert();
|
|
2198
|
+
const l = relative.worldTransform;
|
|
2199
|
+
scaleX /= scaleX / l.scaleX;
|
|
2200
|
+
scaleY /= scaleY / l.scaleY;
|
|
2183
2201
|
}
|
|
2184
|
-
renderBounds = leaf.getBounds('render',
|
|
2202
|
+
renderBounds = leaf.getBounds('render', relative);
|
|
2185
2203
|
}
|
|
2186
|
-
const { x, y, width, height } = new Bounds(renderBounds).scale(scale)
|
|
2187
|
-
let canvas = Creator.canvas({ width, height, pixelRatio });
|
|
2204
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
|
|
2205
|
+
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
|
|
2188
2206
|
const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
2189
2207
|
if (slice) {
|
|
2190
2208
|
leaf = leafer;
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as l,WatchEvent as c,PropertyEvent as h,LeafHelper as u,BranchHelper as f,Bounds as p,LeafBoundsHelper as _,Debug as g,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as x,AnimateEvent as v,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,ImageEvent as k,PointHelper as E,Direction4 as S,TwoPointBoundsHelper as L,TaskProcessor as A,Matrix as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as W,ColorConvert as T,PaintGradient as M,Export as C,Group as I,TextConvert as D,Paint as F,Effect as P}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class Y extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:G}=a;function X(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:G(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:G(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),loadImage:t=>new Promise(((n,i)=>{!t.startsWith("data:")&&e.image.suffix&&(t+=(t.includes("?")?"&":"?")+e.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new Y(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},e.devicePixelRatio=1;const{userAgent:N}=navigator;N.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):N.indexOf("Safari")>-1&&-1===N.indexOf("Chrome")&&(e.fullImageShadow=!0),N.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):N.indexOf("Mac")>-1?e.os="Mac":N.indexOf("Linux")>-1&&(e.os="Linux");class U{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===l.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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.CHANGE,this.__onAttrChange,this),t.on_([l.ADD,l.REMOVE],this.__onChildEvent,this),t.on_(c.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:q,updateBounds:V,updateAllWorldOpacity:j}=u,{pushAllChildBranch:z,pushAllParent:H}=f;const{worldBounds:Q}=_,Z={x:0,y:0,width:1e5,height:1e5};class ${constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Z):this.afterBounds.setListWithFn(t,Q),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:J,updateAllChange:K}=u,tt=g.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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=m.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new y(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&z(t,e),H(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),H(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||V(i[t])}V(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&j(t),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new y(a,r,this.times)),n.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(n,a,this.times)),et.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(i,a,this.times)),e.emitEvent(new y(s,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){J(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new $([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new $(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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=g.get("Renderer");class it{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=r.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new p,nt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?nt.warn("rendering"):this.times>3?nt.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t?(this.emitRender(d.BEFORE),t()):(this.requestLayout(),this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.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 nt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),a=new p(i);n.save(),s&&!g.showRepaint?n.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,a),n.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),g.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),g.showHitView&&this.renderHitView(i),g.showBoundsView&&this.renderBoundsView(i),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 p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(v.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:n}=t.old;new p(0,0,e,n).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||nt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new d(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.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)}}function st(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function at(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?dt(t,!0,e,n):rt(e,n);break;case"inside":ot("inside",t,s,e,n);break;case"outside":ot("outside",t,s,e,n)}}function ot(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?dt(e,!0,i,r):rt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",st(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function rt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function dt(t,e,n,i){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&W.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?rt(n,i):i.stroke(),i.restoreBlendMode()):e?rt(n,i):i.stroke())}Object.assign(i,{watcher:(t,e)=>new U(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,n)=>new it(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=et.fullLayout;const{getSpread:lt,getOuterOf:ct,getByMove:ht,getIntersectData:ut}=B;let ft;function pt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:T.string(o,r)};case"image":return W.image(n,t,e,i,!ft||!ft[e.url]);case"linear":return M.linearGradient(e,i);case"radial":return M.radialGradient(e,i);case"angular":return M.conicGradient(e,i);default:return e.r?{type:"solid",style:T.string(e)}:void 0}}const _t={compute:function(t,e){const n=e.__,i=[];let s,a=n.__input[t];a instanceof Array||(a=[a]),ft=W.recycleImage(t,n);for(let n,s=0,o=a.length;s<o;s++)n=pt(t,a[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?st(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)i=t[o],i.image&&W.checkImage(e,n,i,!a)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),a?st(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),a?st(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):a?st(e,n):s?n.fill(s):n.fill())},fillText:st,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)at(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)at(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),dt(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),dt(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),dt(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:at,drawTextStroke:rt,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,h=ut(i?lt(e.bounds,i*l,i*c):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ct(s,o),a=ht(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let gt={};const{get:wt,rotateOfOuter:yt,translate:mt,scaleOfOuter:xt,scale:vt,rotate:bt}=R;function Bt(t,e,n,i,s,a){const o=wt(),r=a&&180!==a,d=n.width/(r?s:i),l=n.height/(r?i:s),c="fit"===e?Math.min(d,l):Math.max(d,l),h=n.x+(n.width-i*c)/2,u=n.y+(n.height-s*c)/2;mt(o,h,u),vt(o,c),a&&yt(o,{x:n.x+n.width/2,y:n.y+n.height/2},a),t.scaleX=t.scaleY=c,t.transform=o}function Rt(t,e,n,i,s,a,o){const r=wt();mt(r,e.x,e.y),(n||i)&&mt(r,n,i),s&&(vt(r,s,a),t.scaleX=r.a,t.scaleY=r.d),o&&bt(r,o),t.transform=r}function kt(t,e,n,i,s,a,o,r,d){const l=wt();if(d)switch(bt(l,d),d){case 90:mt(l,i,0);break;case 180:mt(l,n,i);break;case 270:mt(l,0,n)}gt.x=e.x,gt.y=e.y,(s||a)&&(gt.x+=s,gt.y+=a),mt(l,gt.x,gt.y),o&&(xt(l,gt,o,r),t.scaleX=o,t.scaleY=r),t.transform=l}const{get:Et,translate:St}=R;function Lt(t,e,n,i){let{width:s,height:a}=e;const{opacity:o,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=n,p=i.width===s&&i.height===a;u&&(t.blendMode=u);const _=t.data={mode:r};let g,w,y,m;switch(d&&(g=d.x,w=d.y),c?(y=("number"==typeof c?c:c.width)/s,m=("number"==typeof c?c:c.height)/a):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":p||(s=i.width,a=i.height),(i.x||i.y)&&(_.transform=Et(),St(_.transform,i.x,i.y));break;case"clip":(d||y||h)&&Rt(_,i,g,w,y,m,h);break;case"repeat":(!p||y||h)&&kt(_,i,s,a,g,w,y,m,h),f||(_.repeat="repeat");break;default:p&&!h||Bt(_,r,i,s,a,h)}_.width=s,_.height=a,o&&(_.opacity=o),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let At,Ot=new p;const{isSame:Wt}=B;function Tt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Lt(s,i,n,a),!0}function Mt(t,e){Dt(t,k.LOAD,e)}function Ct(t,e){Dt(t,k.LOADED,e)}function It(t,e,n){e.error=n,t.forceUpdate("surface"),Dt(t,k.ERROR,e)}function Dt(t,e,n){t.hasEvent(e)&&t.emitEvent(new k(e,n))}const{get:Ft,scale:Pt,copy:Yt}=R,{ceil:Gt,abs:Xt}=Math;function Nt(t,n,i){let{scaleX:s,scaleY:a}=t.__world;const o=s+"-"+a;if(n.patternId===o||t.destroyed)return!1;{s=Xt(s),a=Xt(a);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=Ft(),Yt(l,_),Pt(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,c*=s,h*=a;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,c/=d,h/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=Ft(),_&&Yt(l,_)),Pt(l,1/s,1/a));const m=t.getCanvas(Gt(c)||1,Gt(h)||1,p),x=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=x,n.patternId=o,!0}}function Ut(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{d(i.next(t))}catch(t){a(t)}}function r(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:qt}=Math;const Vt={image:function(t,e,n,i,s){let a,o;const r=x.get(n);return At&&n===At.paint&&Wt(i,At.boxBounds)?a=At.leafPaint:(a={type:n.type},a.image=r,At=r.use>1?{leafPaint:a,paint:n,boxBounds:Ot.set(i)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:n}),r.ready?(Tt(t,e,n,r,a,i),s&&(Mt(t,o),Ct(t,o))):r.error?s&&It(t,o,r.error):(s&&Mt(t,o),a.loadId=r.load((()=>{t.destroyed||(Tt(t,e,n,r,a,i)&&t.forceUpdate("surface"),Ct(t,o)),a.loadId=null}),(e=>{It(t,o,e),a.loadId=null}))),a},createData:Lt,fillOrFitMode:Bt,clipMode:Rt,repeatMode:kt,createPattern:Nt,checkImage:function(t,n,i,s){const{scaleX:a,scaleY:o}=t.__world;if(i.data&&i.patternId!==a+"-"+o){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=qt(a)*n.pixelRatio,i*=qt(o)*n.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>e.image.maxCacheSize}return s?(n.save(),n.clip(),i.blendMode&&(n.blendMode=i.blendMode),r.opacity&&(n.opacity*=r.opacity),r.transform&&n.transform(r.transform),n.drawImage(i.image.view,0,0,r.width,r.height),n.restore(),!0):(!i.style||C.running?Nt(t,i,n.pixelRatio):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Ut(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__world)&&Nt(t,i,n.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,a,o;for(let r=0,d=n.length;r<d;r++)i=n[r].image,o=i&&i.url,o&&(s||(s={}),s[o]=!0,x.recycle(i),i.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),i.unload(n[r].loadId,!a.some((t=>t.url===o)))));return s}return null}},jt={x:.5,y:0},zt={x:.5,y:1};function Ht(t,e,n){let i;for(let s=0,a=e.length;s<a;s++)i=e[s],t.addColorStop(i.offset,T.string(i.color,n))}const{set:Qt,getAngle:Zt,getDistance:$t}=E,{get:Jt,rotateOfOuter:Kt,scaleOfOuter:te}=R,ee={x:.5,y:.5},ne={x:.5,y:1},ie={},se={};const{set:ae,getAngle:oe,getDistance:re}=E,{get:de,rotateOfOuter:le,scaleOfOuter:ce}=R,he={x:.5,y:.5},ue={x:.5,y:1},fe={},pe={};const _e={linearGradient:function(t,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=t;i||(i=jt),s||(s=zt);const d=e.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+s.x*n.width,n.y+s.y*n.height);Ht(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;i||(i=ee),s||(s=ne);const{x:l,y:c,width:h,height:u}=n;let f;Qt(ie,l+i.x*h,c+i.y*u),Qt(se,l+s.x*h,c+s.y*u),(h!==u||d)&&(f=Jt(),te(f,ie,h/u*(d||1),1),Kt(f,ie,Zt(ie,se)+90));const p=e.canvas.createRadialGradient(ie.x,ie.y,0,ie.x,ie.y,$t(ie,se));Ht(p,t.stops,o);const _={type:a,style:p,transform:f};return r&&(_.blendMode=r),_},conicGradient:function(t,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;i||(i=he),s||(s=ue);const{x:l,y:c,width:h,height:u}=n;ae(fe,l+i.x*h,c+i.y*u),ae(pe,l+s.x*h,c+s.y*u);const f=de(),p=oe(fe,pe);e.conicGradientRotate90?(ce(f,fe,h/u*(d||1),1),le(f,fe,p+90)):(ce(f,fe,1,h/u*(d||1)),le(f,fe,p));const _=e.conicGradientSupport?e.canvas.createConicGradient(0,fe.x,fe.y):e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,re(fe,pe));Ht(_,t.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g}},{copy:ge,toOffsetOutBounds:we}=B,ye={},me={};function xe(t,n,i,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(ge(ye,t.bounds),ye.x+=n.x-o.x,ye.y+=n.y-o.y,i){const{matrix:t}=s;ye.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),ye.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),ye.width*=i,ye.height*=i}t.copyWorld(s.canvas,t.bounds,ye)}else i&&(ge(ye,n),ye.x-=n.width/2*(i-1),ye.y-=n.height/2*(i-1),ye.width*=i,ye.height*=i),t.copyWorld(s.canvas,o,i?ye:n)}const{toOffsetOutBounds:ve}=B,be={};const Be={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;we(l,me),r.forEach(((r,_)=>{f.setWorldShadow(me.offsetX+r.x*h,me.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,xe(f,me,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;ve(l,be),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,xe(f,be,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__world.a),n.copyWorldToInner(e,t.__world,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Re}=_;function ke(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Se(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Se(t,n,i,a);break;case"path":n.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Se(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}I.prototype.__renderMask=function(t,e){let n,i,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(ke(this,o,t,s,i,a),i=s=null),"path"===n.__.maskType?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Ee(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="alpha",i||(i=Ee(t)),s||(s=Ee(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||Re(n,e)||n.__render(s||t,e);ke(this,o,t,s,i,a)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Le+"_#~&*+\\=|≮≯≈≠=…",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 We(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Te=We("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Me=We("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ce=We(Le),Ie=We(Ae),De=We("- —/~|┆·");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:Pe,Single:Ye,Before:Ge,After:Xe,Symbol:Ne,Break:Ue}=Fe;function qe(t){return Te[t]?Pe:De[t]?Ue:Me[t]?Ge:Ce[t]?Xe:Ie[t]?Ne:Oe.test(t)?Ye:Pe}const Ve={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function je(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ze}=Ve,{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Je,Break:Ke}=Fe;let tn,en,nn,sn,an,on,rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn=[];function yn(t,e){ln&&!dn&&(dn=ln),tn.data.push({char:t,width:e}),nn+=e}function mn(){sn+=nn,tn.width=nn,en.words.push(tn),tn={data:[]},nn=0}function xn(){pn&&(_n.paraNumber++,en.paraStart=!0,pn=!1),ln&&(en.startCharSize=dn,en.endCharSize=ln,dn=0),en.width=sn,gn.width&&ze(en),wn.push(en),en={words:[]},sn=0}const vn=0,bn=1,Bn=2;const{top:Rn,right:kn,bottom:En,left:Sn}=S;function Ln(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const An={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(a&&(i=l[Sn],a-=l[kn]+l[Sn]),o&&(s=l[Rn],o-=l[Rn]+l[En]));const c={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){_n=t,wn=t.rows,gn=t.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=e,{width:d,height:l}=gn;if(d||l||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;pn=!0,hn=null,dn=rn=ln=nn=sn=0,tn={data:[]},en={words:[]};for(let i=0,l=n.length;i<l;i++)on=n[i],"\n"===on?(nn&&mn(),en.paraEnd=!0,xn(),pn=!0):(cn=qe(on),cn===He&&"none"!==o&&(on=je(on,o,!nn)),rn=r.measureText(on).width,s&&(s<0&&(ln=rn),rn+=s),un=cn===Qe&&(hn===Qe||hn===He)||hn===Qe&&cn!==$e,fn=!(cn!==Ze&&cn!==Qe||hn!==Je&&hn!==$e),an=pn&&a?d-a:d,t&&d&&sn+nn+rn>an&&(e?(nn&&mn(),xn()):(fn||(fn=cn===He&&hn==$e),un||fn||cn===Ke||cn===Ze||cn===Qe||nn+rn>an?(nn&&mn(),xn()):xn()))," "===on&&!0!==pn&&sn+nn===0||(cn===Ke?(" "===on&&nn&&mn(),yn(on,rn),mn()):un||fn?(nn&&mn(),yn(on,rn)):yn(on,rn)),hn=cn);nn&&mn(),sn&&xn(),wn.length>0&&(wn[wn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{_n.paraNumber++,wn.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Ln(e,"x",t[Sn]);break;case"right":Ln(e,"x",-t[kn])}if(!s)switch(n.verticalAlign){case"top":Ln(e,"y",t[Rn]);break;case"bottom":Ln(e,"y",-t[En])}}(l,c,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:_,width:g,height:w}=i,y=s*n.length+(c?c*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let a=0,l=n.length;a<l;a++){switch(h=n[a],h.x=p,d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&a>0&&(m+=c),h.y=m,m+=s,t.overflow>a&&m>y&&(h.isOverflow=!0,t.overflow=a+1),u=h.x,f=h.width,o<0&&(h.width<0?(f=-h.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=_,i.height=y}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?vn:l>.01?bn:Bn,t.isOverflow&&!r&&(t.textMode=!0),h===Bn?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===bn?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,a),c.overflow&&function(t,n){const{rows:i,overflow:s}=t;let{textOverflow:a}=n;if(i.splice(s),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=n.x+n.width-r;("none"===n.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],o=t.x+t.width,!(i===n&&o<d));i--){if(o<d&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const On={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:Wn,addPoint:Tn,toBounds:Mn}=L;const Cn={export(t,e,n){return this.running=!0,function(t){In||(In=new A);return new Promise((e=>{In.add((()=>Ut(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((o=>{const r=t=>{s(t),o(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>Ut(this,void 0,void 0,(function*(){n=a.getExportOptions(n);let s,o,l=1,c=1;const{worldTransform:h,isLeafer:u,isFrame:f}=t,{slice:_,trim:g,onCanvas:w}=n,y=n.scale||1,m=n.pixelRatio||1,x=n.screenshot||t.isApp,v=u&&x?void 0===n.fill?t.fill:void 0:n.fill,b=a.isOpaqueImage(e)||v,B=new O;if(x)s=!0===x?u?d.canvas.bounds:t.worldRenderBounds:x;else{const e=n.location||(u||f?"inner":"local");switch(l=h.scaleX,c=h.scaleY,e){case"inner":B.set(h).invert();break;case"local":B.set(h).divide(t.localTransform).invert(),l/=t.scaleX,c/=t.scaleY;break;case"world":l=1,c=1}s=t.getBounds("render",e)}const{x:R,y:k,width:E,height:S}=new p(s).scale(y).ceil();let L=i.canvas({width:E,height:S,pixelRatio:m});const A={matrix:B.scale(y).translate(-R,-k).withScale(1/l*y,1/c*y)};if(_&&(t=d,A.bounds=L.bounds),L.save(),f&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(L,A),t.fill=e}else t.__render(L,A);if(L.restore(),g){o=function(t){const{width:e,height:n}=t.view,{data:i}=t.context.getImageData(0,0,e,n);let s,a,o,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(s=r%e,a=(r-s)/e,o?Tn(o,s,a):Wn(o={},s,a)),r++;const d=new p;return Mn(o,d),d.scale(1/t.pixelRatio).ceil()}(L);const t=L,{width:e,height:n}=o,s={x:0,y:0,width:e,height:n,pixelRatio:m};L=i.canvas(s),L.copyWorld(t,o,s)}b&&L.fillWorld(L.bounds,v||"#FFFFFF","destination-over"),w&&w(L);const W="canvas"===e?L:yield L.export(e,n);r({data:W,width:L.pixelWidth,height:L.pixelHeight,renderBounds:s,trimBounds:o})})))):r({data:!1})}))))}};let In;Object.assign(D,An),Object.assign(T,On),Object.assign(F,_t),Object.assign(W,Vt),Object.assign(M,_e),Object.assign(P,Be),Object.assign(C,Cn),X();export{et as Layouter,Y as LeaferCanvas,it as Renderer,U as Watcher,X as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as l,WatchEvent as c,PropertyEvent as h,LeafHelper as u,BranchHelper as f,Bounds as p,LeafBoundsHelper as _,Debug as g,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as x,AnimateEvent as v,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,ImageEvent as k,PointHelper as E,Direction4 as S,TwoPointBoundsHelper as L,TaskProcessor as W,Matrix as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,ColorConvert as T,PaintGradient as M,Export as C,Group as I,TextConvert as D,Paint as F,Effect as P}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class Y extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:G}=a;function X(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:G(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:G(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),loadImage:t=>new Promise(((n,i)=>{!t.startsWith("data:")&&e.image.suffix&&(t+=(t.includes("?")?"&":"?")+e.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new Y(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},e.devicePixelRatio=1;const{userAgent:N}=navigator;N.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):N.indexOf("Safari")>-1&&-1===N.indexOf("Chrome")&&(e.fullImageShadow=!0),N.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):N.indexOf("Mac")>-1?e.os="Mac":N.indexOf("Linux")>-1&&(e.os="Linux");class U{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===l.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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.CHANGE,this.__onAttrChange,this),t.on_([l.ADD,l.REMOVE],this.__onChildEvent,this),t.on_(c.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:q,updateBounds:V,updateAllWorldOpacity:j}=u,{pushAllChildBranch:z,pushAllParent:H}=f;const{worldBounds:Q}=_,Z={x:0,y:0,width:1e5,height:1e5};class ${constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Z):this.afterBounds.setListWithFn(t,Q),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:J,updateAllChange:K}=u,tt=g.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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=m.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new y(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&z(t,e),H(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),H(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||V(i[t])}V(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&j(t),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new y(a,r,this.times)),n.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(n,a,this.times)),et.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(i,a,this.times)),e.emitEvent(new y(s,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){J(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new $([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new $(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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=g.get("Renderer");class it{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=r.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new p,nt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return nt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),a=new p(i);n.save(),s&&!g.showRepaint?n.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,a),n.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),g.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),g.showHitView&&this.renderHitView(i),g.showBoundsView&&this.renderBoundsView(i),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 p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(v.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:n}=t.old;new p(0,0,e,n).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||nt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new d(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function st(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function at(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?dt(t,!0,e,n):rt(e,n);break;case"inside":ot("inside",t,s,e,n);break;case"outside":ot("outside",t,s,e,n)}}function ot(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?dt(e,!0,i,r):rt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",st(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function rt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function dt(t,e,n,i){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?rt(n,i):i.stroke(),i.restoreBlendMode()):e?rt(n,i):i.stroke())}Object.assign(i,{watcher:(t,e)=>new U(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,n)=>new it(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=et.fullLayout;const{getSpread:lt,getOuterOf:ct,getByMove:ht,getIntersectData:ut}=B;let ft;function pt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:T.string(o,r)};case"image":return O.image(n,t,e,i,!ft||!ft[e.url]);case"linear":return M.linearGradient(e,i);case"radial":return M.radialGradient(e,i);case"angular":return M.conicGradient(e,i);default:return e.r?{type:"solid",style:T.string(e)}:void 0}}const _t={compute:function(t,e){const n=e.__,i=[];let s,a=n.__input[t];a instanceof Array||(a=[a]),ft=O.recycleImage(t,n);for(let n,s=0,o=a.length;s<o;s++)n=pt(t,a[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?st(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)i=t[o],i.image&&O.checkImage(e,n,i,!a)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),a?st(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),a?st(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):a?st(e,n):s?n.fill(s):n.fill())},fillText:st,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)at(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)at(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),dt(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),dt(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),dt(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:at,drawTextStroke:rt,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,h=ut(i?lt(e.bounds,i*l,i*c):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ct(s,o),a=ht(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let gt={};const{get:wt,rotateOfOuter:yt,translate:mt,scaleOfOuter:xt,scale:vt,rotate:bt}=R;function Bt(t,e,n,i,s,a){const o=wt(),r=a&&180!==a,d=n.width/(r?s:i),l=n.height/(r?i:s),c="fit"===e?Math.min(d,l):Math.max(d,l),h=n.x+(n.width-i*c)/2,u=n.y+(n.height-s*c)/2;mt(o,h,u),vt(o,c),a&&yt(o,{x:n.x+n.width/2,y:n.y+n.height/2},a),t.scaleX=t.scaleY=c,t.transform=o}function Rt(t,e,n,i,s,a,o){const r=wt();mt(r,e.x,e.y),(n||i)&&mt(r,n,i),s&&(vt(r,s,a),t.scaleX=r.a,t.scaleY=r.d),o&&bt(r,o),t.transform=r}function kt(t,e,n,i,s,a,o,r,d){const l=wt();if(d)switch(bt(l,d),d){case 90:mt(l,i,0);break;case 180:mt(l,n,i);break;case 270:mt(l,0,n)}gt.x=e.x,gt.y=e.y,(s||a)&&(gt.x+=s,gt.y+=a),mt(l,gt.x,gt.y),o&&(xt(l,gt,o,r),t.scaleX=o,t.scaleY=r),t.transform=l}const{get:Et,translate:St}=R;function Lt(t,e,n,i){let{width:s,height:a}=e;const{opacity:o,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=n,p=i.width===s&&i.height===a;u&&(t.blendMode=u);const _=t.data={mode:r};let g,w,y,m;switch(d&&(g=d.x,w=d.y),c?(y=("number"==typeof c?c:c.width)/s,m=("number"==typeof c?c:c.height)/a):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":p||(s=i.width,a=i.height);break;case"clip":(d||y||h)&&Rt(_,i,g,w,y,m,h);break;case"repeat":(!p||y||h)&&kt(_,i,s,a,g,w,y,m,h),f||(_.repeat="repeat");break;default:p&&!h||Bt(_,r,i,s,a,h)}_.transform||(i.x||i.y)&&(_.transform=Et(),St(_.transform,i.x,i.y)),_.width=s,_.height=a,o&&(_.opacity=o),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Wt,At=new p;const{isSame:Ot}=B;function Tt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Lt(s,i,n,a),!0}function Mt(t,e){Dt(t,k.LOAD,e)}function Ct(t,e){Dt(t,k.LOADED,e)}function It(t,e,n){e.error=n,t.forceUpdate("surface"),Dt(t,k.ERROR,e)}function Dt(t,e,n){t.hasEvent(e)&&t.emitEvent(new k(e,n))}function Ft(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Pt,scale:Yt,copy:Gt}=R,{ceil:Xt,abs:Nt}=Math;function Ut(t,n,i){let{scaleX:s,scaleY:a}=t.__nowWorld;const o=s+"-"+a;if(n.patternId===o||t.destroyed)return!1;{s=Nt(s),a=Nt(a);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=Pt(),Gt(l,_),Yt(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,c*=s,h*=a;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,c/=d,h/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=Pt(),_&&Gt(l,_)),Yt(l,1/s,1/a));const m=t.getCanvas(Xt(c)||1,Xt(h)||1,p),x=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=x,n.patternId=o,!0}}function qt(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{d(i.next(t))}catch(t){a(t)}}function r(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Vt}=Math;const jt={image:function(t,e,n,i,s){let a,o;const r=x.get(n);return Wt&&n===Wt.paint&&Ot(i,Wt.boxBounds)?a=Wt.leafPaint:(a={type:n.type,image:r},Wt=r.use>1?{leafPaint:a,paint:n,boxBounds:At.set(i)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:n}),r.ready?(Tt(t,e,n,r,a,i),s&&(Mt(t,o),Ct(t,o))):r.error?s&&It(t,o,r.error):(Ft(t,!0),s&&Mt(t,o),a.loadId=r.load((()=>{Ft(t,!1),t.destroyed||(Tt(t,e,n,r,a,i)&&t.forceUpdate("surface"),Ct(t,o)),a.loadId=null}),(e=>{Ft(t,!1),It(t,o,e),a.loadId=null}))),a},createData:Lt,fillOrFitMode:Bt,clipMode:Rt,repeatMode:kt,createPattern:Ut,checkImage:function(t,n,i,s){const{scaleX:a,scaleY:o}=t.__nowWorld;if(i.data&&i.patternId!==a+"-"+o){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=Vt(a)*n.pixelRatio,i*=Vt(o)*n.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>e.image.maxCacheSize}return s?(n.save(),n.clip(),i.blendMode&&(n.blendMode=i.blendMode),r.opacity&&(n.opacity*=r.opacity),r.transform&&n.transform(r.transform),n.drawImage(i.image.view,0,0,r.width,r.height),n.restore(),!0):(!i.style||C.running?Ut(t,i,n.pixelRatio):i.patternTask||(i.patternTask=x.patternTasker.add((()=>qt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Ut(t,i,n.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,a,o;for(let r=0,d=n.length;r<d;r++)i=n[r].image,o=i&&i.url,o&&(s||(s={}),s[o]=!0,x.recycle(i),i.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),i.unload(n[r].loadId,!a.some((t=>t.url===o)))));return s}return null}},zt={x:.5,y:0},Ht={x:.5,y:1};function Qt(t,e,n){let i;for(let s=0,a=e.length;s<a;s++)i=e[s],t.addColorStop(i.offset,T.string(i.color,n))}const{set:Zt,getAngle:$t,getDistance:Jt}=E,{get:Kt,rotateOfOuter:te,scaleOfOuter:ee}=R,ne={x:.5,y:.5},ie={x:.5,y:1},se={},ae={};const{set:oe,getAngle:re,getDistance:de}=E,{get:le,rotateOfOuter:ce,scaleOfOuter:he}=R,ue={x:.5,y:.5},fe={x:.5,y:1},pe={},_e={};const ge={linearGradient:function(t,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=t;i||(i=zt),s||(s=Ht);const d=e.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+s.x*n.width,n.y+s.y*n.height);Qt(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;i||(i=ne),s||(s=ie);const{x:l,y:c,width:h,height:u}=n;let f;Zt(se,l+i.x*h,c+i.y*u),Zt(ae,l+s.x*h,c+s.y*u),(h!==u||d)&&(f=Kt(),ee(f,se,h/u*(d||1),1),te(f,se,$t(se,ae)+90));const p=e.canvas.createRadialGradient(se.x,se.y,0,se.x,se.y,Jt(se,ae));Qt(p,t.stops,o);const _={type:a,style:p,transform:f};return r&&(_.blendMode=r),_},conicGradient:function(t,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;i||(i=ue),s||(s=fe);const{x:l,y:c,width:h,height:u}=n;oe(pe,l+i.x*h,c+i.y*u),oe(_e,l+s.x*h,c+s.y*u);const f=le(),p=re(pe,_e);e.conicGradientRotate90?(he(f,pe,h/u*(d||1),1),ce(f,pe,p+90)):(he(f,pe,1,h/u*(d||1)),ce(f,pe,p));const _=e.conicGradientSupport?e.canvas.createConicGradient(0,pe.x,pe.y):e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,de(pe,_e));Qt(_,t.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g}},{copy:we,toOffsetOutBounds:ye}=B,me={},xe={};function ve(t,n,i,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(we(me,t.bounds),me.x+=n.x-o.x,me.y+=n.y-o.y,i){const{matrix:t}=s;me.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),me.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),me.width*=i,me.height*=i}t.copyWorld(s.canvas,t.bounds,me)}else i&&(we(me,n),me.x-=n.width/2*(i-1),me.y-=n.height/2*(i-1),me.width*=i,me.height*=i),t.copyWorld(s.canvas,o,i?me:n)}const{toOffsetOutBounds:be}=B,Be={};const Re={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;ye(l,xe),r.forEach(((r,_)=>{f.setWorldShadow(xe.offsetX+r.x*h,xe.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,ve(f,xe,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;be(l,Be),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Be.offsetX+r.x*h,Be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,ve(f,Be,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:ke}=_;function Ee(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Le(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Le(t,n,i,a);break;case"path":n.restore()}}function Se(t){return t.getSameCanvas(!1,!0)}function Le(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}I.prototype.__renderMask=function(t,e){let n,i,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(Ee(this,o,t,s,i,a),i=s=null),"path"===n.__.maskType?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Se(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="alpha",i||(i=Se(t)),s||(s=Se(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||ke(n,e)||n.__render(s||t,e);Ee(this,o,t,s,i,a)};const We=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=We+"_#~&*+\\=|≮≯≈≠=…",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 Te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ce=Te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Te(We),De=Te(Ae),Fe=Te("- —/~|┆·");var Pe;!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"}(Pe||(Pe={}));const{Letter:Ye,Single:Ge,Before:Xe,After:Ne,Symbol:Ue,Break:qe}=Pe;function Ve(t){return Me[t]?Ye:Fe[t]?qe:Ce[t]?Xe:Ie[t]?Ne:De[t]?Ue:Oe.test(t)?Ge:Ye}const je={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function ze(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:He}=je,{Letter:Qe,Single:Ze,Before:$e,After:Je,Symbol:Ke,Break:tn}=Pe;let en,nn,sn,an,on,rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn,yn=[];function mn(t,e){cn&&!ln&&(ln=cn),en.data.push({char:t,width:e}),sn+=e}function xn(){an+=sn,en.width=sn,nn.words.push(en),en={data:[]},sn=0}function vn(){_n&&(gn.paraNumber++,nn.paraStart=!0,_n=!1),cn&&(nn.startCharSize=ln,nn.endCharSize=cn,ln=0),nn.width=an,wn.width&&He(nn),yn.push(nn),nn={words:[]},an=0}const bn=0,Bn=1,Rn=2;const{top:kn,right:En,bottom:Sn,left:Ln}=S;function Wn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const An={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(a&&(i=l[Ln],a-=l[En]+l[Ln]),o&&(s=l[kn],o-=l[kn]+l[Sn]));const c={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){gn=t,yn=t.rows,wn=t.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=e,{width:d,height:l}=wn;if(d||l||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;_n=!0,un=null,ln=dn=cn=sn=an=0,en={data:[]},nn={words:[]};for(let i=0,l=n.length;i<l;i++)rn=n[i],"\n"===rn?(sn&&xn(),nn.paraEnd=!0,vn(),_n=!0):(hn=Ve(rn),hn===Qe&&"none"!==o&&(rn=ze(rn,o,!sn)),dn=r.measureText(rn).width,s&&(s<0&&(cn=dn),dn+=s),fn=hn===Ze&&(un===Ze||un===Qe)||un===Ze&&hn!==Je,pn=!(hn!==$e&&hn!==Ze||un!==Ke&&un!==Je),on=_n&&a?d-a:d,t&&d&&an+sn+dn>on&&(e?(sn&&xn(),vn()):(pn||(pn=hn===Qe&&un==Je),fn||pn||hn===tn||hn===$e||hn===Ze||sn+dn>on?(sn&&xn(),vn()):vn()))," "===rn&&!0!==_n&&an+sn===0||(hn===tn?(" "===rn&&sn&&xn(),mn(rn,dn),xn()):fn||pn?(sn&&xn(),mn(rn,dn)):mn(rn,dn)),un=hn);sn&&xn(),an&&vn(),yn.length>0&&(yn[yn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{gn.paraNumber++,yn.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Wn(e,"x",t[Ln]);break;case"right":Wn(e,"x",-t[En])}if(!s)switch(n.verticalAlign){case"top":Wn(e,"y",t[kn]);break;case"bottom":Wn(e,"y",-t[Sn])}}(l,c,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:_,width:g,height:w}=i,y=s*n.length+(c?c*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let a=0,l=n.length;a<l;a++){switch(h=n[a],h.x=p,d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&a>0&&(m+=c),h.y=m,m+=s,t.overflow>a&&m>y&&(h.isOverflow=!0,t.overflow=a+1),u=h.x,f=h.width,o<0&&(h.width<0?(f=-h.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=_,i.height=y}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?bn:l>.01?Bn:Rn,t.isOverflow&&!r&&(t.textMode=!0),h===Rn?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Bn?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,a),c.overflow&&function(t,n){const{rows:i,overflow:s}=t;let{textOverflow:a}=n;if(i.splice(s),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=n.x+n.width-r;("none"===n.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],o=t.x+t.width,!(i===n&&o<d));i--){if(o<d&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const On={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:Tn,addPoint:Mn,toBounds:Cn}=L;const In={export(t,e,n){return this.running=!0,function(t){Dn||(Dn=new W);return new Promise((e=>{Dn.add((()=>qt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((o=>{const r=t=>{s(t),o(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>qt(this,void 0,void 0,(function*(){n=a.getExportOptions(n);let s,o,l=1,c=1;const{worldTransform:h,isLeafer:u,isFrame:f}=t,{slice:_,trim:g,onCanvas:w}=n,y=n.scale||1,m=n.pixelRatio||1,x=n.screenshot||t.isApp,v=u&&x?void 0===n.fill?t.fill:void 0:n.fill,b=a.isOpaqueImage(e)||v,B=new A;if(x)s=!0===x?u?d.canvas.bounds:t.worldRenderBounds:x;else{let e=n.relative||(u?"inner":"local");switch(l=h.scaleX,c=h.scaleY,e){case"inner":B.set(h).invert();break;case"local":B.set(h).divide(t.localTransform).invert(),l/=t.scaleX,c/=t.scaleY;break;case"world":l=1,c=1;break;case"page":e=t.leafer;default:B.set(h).divide(t.getTransform(e)).invert();const n=e.worldTransform;l/=l/n.scaleX,c/=c/n.scaleY}s=t.getBounds("render",e)}const{x:R,y:k,width:E,height:S}=new p(s).scale(y);let L=i.canvas({width:Math.round(E),height:Math.round(S),pixelRatio:m});const W={matrix:B.scale(y).translate(-R,-k).withScale(1/l*y,1/c*y)};if(_&&(t=d,W.bounds=L.bounds),L.save(),f&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(L,W),t.fill=e}else t.__render(L,W);if(L.restore(),g){o=function(t){const{width:e,height:n}=t.view,{data:i}=t.context.getImageData(0,0,e,n);let s,a,o,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(s=r%e,a=(r-s)/e,o?Mn(o,s,a):Tn(o={},s,a)),r++;const d=new p;return Cn(o,d),d.scale(1/t.pixelRatio).ceil()}(L);const t=L,{width:e,height:n}=o,s={x:0,y:0,width:e,height:n,pixelRatio:m};L=i.canvas(s),L.copyWorld(t,o,s)}b&&L.fillWorld(L.bounds,v||"#FFFFFF","destination-over"),w&&w(L);const O="canvas"===e?L:yield L.export(e,n);r({data:O,width:L.pixelWidth,height:L.pixelHeight,renderBounds:s,trimBounds:o})})))):r({data:!1})}))))}};let Dn;Object.assign(D,An),Object.assign(T,On),Object.assign(F,_t),Object.assign(O,jt),Object.assign(M,ge),Object.assign(P,Re),Object.assign(C,In),X();export{et as Layouter,Y as LeaferCanvas,it as Renderer,U as Watcher,X as useCanvas};
|