@leafer-ui/worker 1.6.3 → 1.6.4
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.cjs +17 -26
- package/dist/worker.esm.js +19 -28
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +28 -29
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +28 -29
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/worker.cjs
CHANGED
|
@@ -878,8 +878,6 @@ function fillPathOrText(ui, canvas) {
|
|
|
878
878
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
879
879
|
}
|
|
880
880
|
|
|
881
|
-
const Paint = {};
|
|
882
|
-
|
|
883
881
|
function strokeText(stroke, ui, canvas) {
|
|
884
882
|
switch (ui.__.strokeAlign) {
|
|
885
883
|
case 'center':
|
|
@@ -905,11 +903,14 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
905
903
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
906
904
|
fillText(ui, out);
|
|
907
905
|
out.blendMode = 'normal';
|
|
908
|
-
|
|
906
|
+
copyWorld(canvas, out, ui);
|
|
907
|
+
out.recycle(ui.__nowWorld);
|
|
908
|
+
}
|
|
909
|
+
function copyWorld(canvas, out, ui) {
|
|
910
|
+
if (ui.__worldFlipped || core.Platform.fullImageShadow)
|
|
909
911
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
910
912
|
else
|
|
911
913
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
912
|
-
out.recycle(ui.__nowWorld);
|
|
913
914
|
}
|
|
914
915
|
function drawTextStroke(ui, canvas) {
|
|
915
916
|
let row, data = ui.__.__textDrawData;
|
|
@@ -975,12 +976,11 @@ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
|
975
976
|
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
976
977
|
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
977
978
|
if (data.__useArrow)
|
|
978
|
-
Paint.strokeArrow(stroke, ui, canvas);
|
|
979
|
+
draw.Paint.strokeArrow(stroke, ui, canvas);
|
|
979
980
|
}
|
|
980
981
|
function drawInside(stroke, ui, canvas) {
|
|
981
|
-
const data = ui.__;
|
|
982
982
|
canvas.save();
|
|
983
|
-
|
|
983
|
+
canvas.clipUI(ui);
|
|
984
984
|
drawCenter(stroke, 2, ui, canvas);
|
|
985
985
|
canvas.restore();
|
|
986
986
|
}
|
|
@@ -994,12 +994,9 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
994
994
|
const out = canvas.getSameCanvas(true, true);
|
|
995
995
|
ui.__drawRenderPath(out);
|
|
996
996
|
drawCenter(stroke, 2, ui, out);
|
|
997
|
-
|
|
997
|
+
out.clipUI(data);
|
|
998
998
|
out.clearWorld(renderBounds);
|
|
999
|
-
|
|
1000
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1001
|
-
else
|
|
1002
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
999
|
+
copyWorld(canvas, out, ui);
|
|
1003
1000
|
out.recycle(ui.__nowWorld);
|
|
1004
1001
|
}
|
|
1005
1002
|
}
|
|
@@ -1055,9 +1052,7 @@ function compute(attrName, ui) {
|
|
|
1055
1052
|
paints = [paints];
|
|
1056
1053
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
1057
1054
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1058
|
-
item = getLeafPaint(attrName, paints[i], ui);
|
|
1059
|
-
if (item)
|
|
1060
|
-
leafPaints.push(item);
|
|
1055
|
+
(item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
|
|
1061
1056
|
}
|
|
1062
1057
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1063
1058
|
if (leafPaints.length) {
|
|
@@ -1095,8 +1090,8 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1095
1090
|
data = draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
1096
1091
|
break;
|
|
1097
1092
|
case 'solid':
|
|
1098
|
-
const { type,
|
|
1099
|
-
data = { type,
|
|
1093
|
+
const { type, color, opacity } = paint;
|
|
1094
|
+
data = { type, style: draw.ColorConvert.string(color, opacity) };
|
|
1100
1095
|
break;
|
|
1101
1096
|
default:
|
|
1102
1097
|
if (paint.r !== undefined)
|
|
@@ -1505,7 +1500,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1505
1500
|
}
|
|
1506
1501
|
function drawImage(ui, canvas, paint, data) {
|
|
1507
1502
|
canvas.save();
|
|
1508
|
-
|
|
1503
|
+
canvas.clipUI(ui);
|
|
1509
1504
|
if (paint.blendMode)
|
|
1510
1505
|
canvas.blendMode = paint.blendMode;
|
|
1511
1506
|
if (data.opacity)
|
|
@@ -1670,12 +1665,10 @@ function shadow(ui, current, shape) {
|
|
|
1670
1665
|
}
|
|
1671
1666
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1672
1667
|
}
|
|
1673
|
-
if (ui.__worldFlipped)
|
|
1668
|
+
if (ui.__worldFlipped)
|
|
1674
1669
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1675
|
-
|
|
1676
|
-
else {
|
|
1670
|
+
else
|
|
1677
1671
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1678
|
-
}
|
|
1679
1672
|
if (end && index < end)
|
|
1680
1673
|
other.clearWorld(copyBounds, true);
|
|
1681
1674
|
});
|
|
@@ -1734,12 +1727,10 @@ function innerShadow(ui, current, shape) {
|
|
|
1734
1727
|
copyBounds = bounds;
|
|
1735
1728
|
}
|
|
1736
1729
|
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1737
|
-
if (ui.__worldFlipped)
|
|
1730
|
+
if (ui.__worldFlipped)
|
|
1738
1731
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1739
|
-
|
|
1740
|
-
else {
|
|
1732
|
+
else
|
|
1741
1733
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1742
|
-
}
|
|
1743
1734
|
if (end && index < end)
|
|
1744
1735
|
other.clearWorld(copyBounds, true);
|
|
1745
1736
|
});
|
package/dist/worker.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, Plugin, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
|
-
import {
|
|
4
|
+
import { HitCanvasManager, InteractionBase } from '@leafer-ui/core';
|
|
5
5
|
export * from '@leafer-ui/core';
|
|
6
|
-
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert,
|
|
6
|
+
import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect } from '@leafer-ui/draw';
|
|
7
7
|
|
|
8
8
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
9
9
|
get allowBackgroundColor() { return true; }
|
|
@@ -879,8 +879,6 @@ function fillPathOrText(ui, canvas) {
|
|
|
879
879
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
880
880
|
}
|
|
881
881
|
|
|
882
|
-
const Paint = {};
|
|
883
|
-
|
|
884
882
|
function strokeText(stroke, ui, canvas) {
|
|
885
883
|
switch (ui.__.strokeAlign) {
|
|
886
884
|
case 'center':
|
|
@@ -906,11 +904,14 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
906
904
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
907
905
|
fillText(ui, out);
|
|
908
906
|
out.blendMode = 'normal';
|
|
909
|
-
|
|
907
|
+
copyWorld(canvas, out, ui);
|
|
908
|
+
out.recycle(ui.__nowWorld);
|
|
909
|
+
}
|
|
910
|
+
function copyWorld(canvas, out, ui) {
|
|
911
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
910
912
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
911
913
|
else
|
|
912
914
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
913
|
-
out.recycle(ui.__nowWorld);
|
|
914
915
|
}
|
|
915
916
|
function drawTextStroke(ui, canvas) {
|
|
916
917
|
let row, data = ui.__.__textDrawData;
|
|
@@ -979,9 +980,8 @@ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
|
979
980
|
Paint.strokeArrow(stroke, ui, canvas);
|
|
980
981
|
}
|
|
981
982
|
function drawInside(stroke, ui, canvas) {
|
|
982
|
-
const data = ui.__;
|
|
983
983
|
canvas.save();
|
|
984
|
-
|
|
984
|
+
canvas.clipUI(ui);
|
|
985
985
|
drawCenter(stroke, 2, ui, canvas);
|
|
986
986
|
canvas.restore();
|
|
987
987
|
}
|
|
@@ -995,12 +995,9 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
995
995
|
const out = canvas.getSameCanvas(true, true);
|
|
996
996
|
ui.__drawRenderPath(out);
|
|
997
997
|
drawCenter(stroke, 2, ui, out);
|
|
998
|
-
|
|
998
|
+
out.clipUI(data);
|
|
999
999
|
out.clearWorld(renderBounds);
|
|
1000
|
-
|
|
1001
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1002
|
-
else
|
|
1003
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
1000
|
+
copyWorld(canvas, out, ui);
|
|
1004
1001
|
out.recycle(ui.__nowWorld);
|
|
1005
1002
|
}
|
|
1006
1003
|
}
|
|
@@ -1056,9 +1053,7 @@ function compute(attrName, ui) {
|
|
|
1056
1053
|
paints = [paints];
|
|
1057
1054
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
1058
1055
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1059
|
-
item = getLeafPaint(attrName, paints[i], ui);
|
|
1060
|
-
if (item)
|
|
1061
|
-
leafPaints.push(item);
|
|
1056
|
+
(item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
|
|
1062
1057
|
}
|
|
1063
1058
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1064
1059
|
if (leafPaints.length) {
|
|
@@ -1096,8 +1091,8 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1096
1091
|
data = PaintGradient.conicGradient(paint, boxBounds);
|
|
1097
1092
|
break;
|
|
1098
1093
|
case 'solid':
|
|
1099
|
-
const { type,
|
|
1100
|
-
data = { type,
|
|
1094
|
+
const { type, color, opacity } = paint;
|
|
1095
|
+
data = { type, style: ColorConvert.string(color, opacity) };
|
|
1101
1096
|
break;
|
|
1102
1097
|
default:
|
|
1103
1098
|
if (paint.r !== undefined)
|
|
@@ -1506,7 +1501,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1506
1501
|
}
|
|
1507
1502
|
function drawImage(ui, canvas, paint, data) {
|
|
1508
1503
|
canvas.save();
|
|
1509
|
-
|
|
1504
|
+
canvas.clipUI(ui);
|
|
1510
1505
|
if (paint.blendMode)
|
|
1511
1506
|
canvas.blendMode = paint.blendMode;
|
|
1512
1507
|
if (data.opacity)
|
|
@@ -1671,12 +1666,10 @@ function shadow(ui, current, shape) {
|
|
|
1671
1666
|
}
|
|
1672
1667
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1673
1668
|
}
|
|
1674
|
-
if (ui.__worldFlipped)
|
|
1669
|
+
if (ui.__worldFlipped)
|
|
1675
1670
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1676
|
-
|
|
1677
|
-
else {
|
|
1671
|
+
else
|
|
1678
1672
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1679
|
-
}
|
|
1680
1673
|
if (end && index < end)
|
|
1681
1674
|
other.clearWorld(copyBounds, true);
|
|
1682
1675
|
});
|
|
@@ -1735,12 +1728,10 @@ function innerShadow(ui, current, shape) {
|
|
|
1735
1728
|
copyBounds = bounds;
|
|
1736
1729
|
}
|
|
1737
1730
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
1738
|
-
if (ui.__worldFlipped)
|
|
1731
|
+
if (ui.__worldFlipped)
|
|
1739
1732
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1740
|
-
|
|
1741
|
-
else {
|
|
1733
|
+
else
|
|
1742
1734
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1743
|
-
}
|
|
1744
1735
|
if (end && index < end)
|
|
1745
1736
|
other.clearWorld(copyBounds, true);
|
|
1746
1737
|
});
|
|
@@ -2376,7 +2367,7 @@ const ColorConvertModule = {
|
|
|
2376
2367
|
|
|
2377
2368
|
Object.assign(TextConvert, TextConvertModule);
|
|
2378
2369
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
2379
|
-
Object.assign(Paint
|
|
2370
|
+
Object.assign(Paint, PaintModule);
|
|
2380
2371
|
Object.assign(PaintImage, PaintImageModule);
|
|
2381
2372
|
Object.assign(PaintGradient, PaintGradientModule);
|
|
2382
2373
|
Object.assign(Effect, EffectModule);
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as x,ImageManager as v,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as R,MathHelper as E,AlignHelper as S,PointHelper as L,ImageEvent as A,AroundHelper as T,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{Platform as O,HitCanvasManager as C,InteractionBase as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as G,Paint as z,Effect as U}from"@leafer-ui/draw";class N 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:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:X}=n;function j(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:X(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:X(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new N(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):q.indexOf("Safari")>-1&&-1===q.indexOf("Chrome")&&(e.fullImageShadow=!0),q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):q.indexOf("Mac")>-1?e.os="Mac":q.indexOf("Linux")>-1&&(e.os="Linux");class H{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=l.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===h.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:V,updateBounds:Q,updateChange:Z}=f,{pushAllChildBranch:$,pushAllParent:J}=p;const{worldBounds:K}=g;class tt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,K),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:et,updateAllChange:it}=f,nt=w.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.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=x.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:r}=m,o=this.getBlocks(n);o.forEach((t=>t.setBefore())),i.emitEvent(new m(s,o,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(V(t,!0),e.add(t),t.isBranch&&$(t,e),J(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),J(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||Q(n[t])}Q(i)}}))}(this.__levelList),function(t){t.list.forEach(Z)}(n),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new m(a,o,this.times)),i.emitEvent(new m(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new o(e));e.emitEvent(new m(i,a,this.times)),st.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){et(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(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(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=w.get("Renderer");class rt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,at.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,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;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(rt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,e){const{canvas:i}=this,n=t.includes(this.target.__world),s=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__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||at.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[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)}}rt.clipSpread=10;const{hitRadiusPoint:ot}=B;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),n?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,r=i.length;t<r;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||ot(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class dt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new lt(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:a}=this;return e.backgrounder&&s&&s.updateLayout(),a.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function ht(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function ct(t,e){t.__.__font?ht(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}Object.assign(s,{watcher:(t,e)=>new H(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>new dt(t,e)}),e.layout=st.fullLayout;const ut={};function ft(t,e,i){switch(e.__.strokeAlign){case"center":pt(t,1,e,i);break;case"inside":gt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?pt(t,2,e,i):gt(t,"outside",e,i)}}function pt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?wt(t,!0,i,n):_t(i,n)}function gt(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,pt(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",ht(i,s),s.blendMode="normal",i.__worldFlipped||O.fullImageShadow?n.copyWorldByReset(s,i.__nowWorld):n.copyWorldToInner(s,i.__nowWorld,i.__layout.renderBounds),s.recycle(i.__nowWorld)}function _t(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;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)}));if(a){const{decorationHeight:t}=n;s.forEach((i=>a.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function wt(t,e,i,n){let s;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&M.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?_t(i,n):n.stroke(),n.restoreBlendMode()):e?_t(i,n):n.stroke())}function yt(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)ft(t,e,i);else switch(n.strokeAlign){case"center":mt(t,1,e,i);break;case"inside":!function(t,e,i){const n=e.__;i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),mt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)mt(t,2,e,i);else{const{renderBounds:s}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),mt(t,2,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(s),e.__worldFlipped||O.fullImageShadow?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,s),a.recycle(e.__nowWorld)}}(t,e,i)}}function mt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?wt(t,!1,i,n):n.stroke(),s.__useArrow&&ut.strokeArrow(t,i,n)}const{getSpread:xt,getOuterOf:vt,getByMove:bt,getIntersectData:Bt}=B;let kt;const{stintSet:Rt}=l,{hasTransparent:Et}=D;function St(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:s}=i.__layout;switch(e.type){case"image":n=M.image(i,t,e,s,!kt||!kt[e.url]);break;case"linear":n=I.linearGradient(e,s);break;case"radial":n=I.radialGradient(e,s);break;case"angular":n=I.conicGradient(e,s);break;case"solid":const{type:a,blendMode:r,color:o,opacity:l}=e;n={type:a,blendMode:r,style:D.string(o,l)};break;default:void 0!==e.r&&(n={type:"solid",style:D.string(e)})}return n&&("string"==typeof n.style&&Et(n.style)&&(n.isTransparent=!0),e.blendMode&&(n.blendMode=e.blendMode)),n}const Lt={compute:function(t,e){const i=e.__,n=[];let s,a,r=i.__input[t];r instanceof Array||(r=[r]),kt=M.recycleImage(t,i);for(let i,s=0,a=r.length;s<a;s++)i=St(t,r[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n.every((t=>t.isTransparent))&&(n.some((t=>t.image))&&(s=!0),a=!0),"fill"===t?(Rt(i,"__isAlphaPixelFill",s),Rt(i,"__isTransparentFill",a)):(Rt(i,"__isAlphaPixelStroke",s),Rt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,ct(e,i)},fills:function(t,e,i){let n;for(let s=0,a=t.length;s<a;s++){if(n=t[s],n.image){if(M.checkImage(e,i,n,!e.__.__font))continue;if(!n.style){!s&&n.image.isPlacehold&&e.drawImagePlaceholder(i,n.image);continue}}i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),ct(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),ct(e,i),i.restoreBlendMode()):ct(e,i)}},fillPathOrText:ct,fillText:ht,stroke:yt,strokes:function(t,e,i){yt(t,e,i)},strokeText:ft,drawTextStroke:_t,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,l,{scaleX:d,scaleY:h}=s;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(s))l=n,a=o=s;else{const{renderShapeSpread:n}=t.__layout,c=Bt(n?xt(e.bounds,d===h?n*d:[n*h,n*d]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),o=vt(s,r),a=bt(o,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:a,worldCanvas:l,shapeBounds:o,scaleX:d,scaleY:h}}};let At={};const{get:Tt,rotateOfOuter:Wt,translate:Ot,scaleOfOuter:Ct,scale:Pt,rotate:Mt}=R;function Dt(t,e,i,n,s,a,r){const o=Tt();Ot(o,e.x+i,e.y+n),Pt(o,s,a),r&&Wt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function It(t,e,i,n,s,a,r){const o=Tt();Ot(o,e.x+i,e.y+n),s&&Pt(o,s,a),r&&Mt(o,r),t.transform=o}function Ft(t,e,i,n,s,a,r,o,l,d){const h=Tt();if(l)if("center"===d)Wt(h,{x:i/2,y:n/2},l);else switch(Mt(h,l),l){case 90:Ot(h,n,0);break;case 180:Ot(h,i,n);break;case 270:Ot(h,0,i)}At.x=e.x+s,At.y=e.y+a,Ot(h,At.x,At.y),r&&Ct(h,At,r,o),t.transform=h}const{get:Yt,translate:Gt}=R,zt=new _,Ut={},Nt={};function Xt(t,e,i,n){const{changeful:s,sync:a}=i;s&&(t.changeful=s),a&&(t.sync=a),t.data=jt(i,n,e)}function jt(t,e,i){t.padding&&(e=zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:s}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,repeat:u,filters:f}=t,p=e.width===n&&e.height===s,g={mode:r},_="center"!==o&&(c||0)%180==90;let w,y;switch(B.set(Nt,0,0,_?s:n,_?n:s),r&&"cover"!==r&&"fit"!==r?((d||h)&&(E.getScaleData(d,h,i,Ut),w=Ut.scaleX,y=Ut.scaleY),o&&(w&&B.scale(Nt,w,y,!0),S.toPoint(o,Nt,e,Nt,!0,!0))):p&&!c||(w=y=B.getFitScale(e,Nt,"fit"!==r),B.put(e,i,o,w,!1,Nt),B.scale(Nt,w,y,!0)),l&&L.move(Nt,l),r){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(Nt.x||Nt.y||w||c)&&It(g,e,Nt.x,Nt.y,w,y,c);break;case"repeat":(!p||w||c)&&Ft(g,e,n,s,Nt.x,Nt.y,w,y,c,o),u||(g.repeat="repeat");break;default:w&&Dt(g,e,Nt.x,Nt.y,w,y,c)}return g.transform||(e.x||e.y)&&(g.transform=Yt(),Gt(g.transform,e.x,e.y)),w&&"stretch"!==r&&(g.scaleX=w,g.scaleY=y),g.width=n,g.height=s,a&&(g.opacity=a),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let qt,Ht=new _;const{isSame:Vt}=B;function Qt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.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||Xt(s,n,i,a),!0}function Zt(t,e){Kt(t,A.LOAD,e)}function $t(t,e){Kt(t,A.LOADED,e)}function Jt(t,e,i){e.error=i,t.forceUpdate("surface"),Kt(t,A.ERROR,e)}function Kt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function te(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ee,scale:ie,copy:ne}=R,{ceil:se,abs:ae}=Math;function re(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const r=s+"-"+a+"-"+n;if(i.patternId===r||t.destroyed)return!1;{s=ae(s),a=ae(a);const{image:t,data:o}=i;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g}=o;u&&(d=ee(),ne(d,p),ie(d,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const _=h*c;if(!g&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,a/=l,h/=l,c/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=ee(),p&&ne(d,p)),ie(d,1/s,1/a));const y=t.getCanvas(se(h)||1,se(c)||1,o.opacity,o.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=r,!0}}function oe(t,e,i,n){return new(i||(i=Promise))((function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:le}=Math;const de={image:function(t,e,i,n,s){let a,r;const o=v.get(i);return qt&&i===qt.paint&&Vt(n,qt.boxBounds)?a=qt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),qt=o.use>1?{leafPaint:a,paint:i,boxBounds:Ht.set(n)}:null),(s||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Qt(t,e,i,o,a,n),s&&(Zt(t,r),$t(t,r))):o.error?s&&Jt(t,r,o.error):(s&&(te(t,!0),Zt(t,r)),a.loadId=o.load((()=>{te(t,!1),t.destroyed||(Qt(t,e,i,o,a,n)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),$t(t,r)),a.loadId=null}),(e=>{te(t,!1),Jt(t,r,e),a.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:r}=v.patternLocked?t.__world:t.__nowWorld,{pixelRatio:o}=i,{data:l}=n;if(!l||n.patternId===a+"-"+r+"-"+o&&!F.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||F.running)){let{width:t,height:i}=l;t*=le(a)*o,i*=le(r)*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,l),!0):(!n.style||n.sync||F.running?re(t,n,o):n.patternTask||(n.patternTask=v.patternTasker.add((()=>oe(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&re(t,n,o),t.forceUpdate("surface")}))),300)),!1)},createPattern:re,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,r,o;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,v.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[l].loadId,!r.some((t=>t.url===o)))));return a}return null},createData:Xt,getPatternData:jt,fillOrFitMode:Dt,clipMode:It,repeatMode:Ft},{toPoint:he}=T,{hasTransparent:ce}=D,ue={},fe={};function pe(t,e,i,n){if(i){let s,a,r,o;for(let t=0,l=i.length;t<l;t++)s=i[t],"string"==typeof s?(r=t/(l-1),a=D.string(s,n)):(r=s.offset,a=D.string(s.color,n)),e.addColorStop(r,a),!o&&ce(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:ge,getDistance:_e}=L,{get:we,rotateOfOuter:ye,scaleOfOuter:me}=R,{toPoint:xe}=T,ve={},be={};function Be(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=ge(e,i);a=we(),s?(me(a,e,r/o*(n||1),1),ye(a,e,t+90)):(me(a,e,1,r/o*(n||1)),ye(a,e,t))}return a}const{getDistance:ke}=L,{toPoint:Re}=T,Ee={},Se={};const Le={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:r}=t;he(n||"top",i,ue),he(s||"bottom",i,fe);const o=e.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y),l={type:a,style:o};return pe(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=t;xe(n||"center",i,ve),xe(s||"bottom",i,be);const l=e.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,_e(ve,be)),d={type:a,style:l};pe(d,l,t.stops,r);const h=Be(i,ve,be,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=t;Re(n||"center",i,Ee),Re(s||"bottom",i,Se);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ee.x,Ee.y):e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,ke(Ee,Se)),d={type:a,style:l};pe(d,l,t.stops,r);const h=Be(i,Ee,Se,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Be},{copy:Ae,toOffsetOutBounds:Te}=B,We={},Oe={};function Ce(t,i,n,s){const{bounds:a,shapeBounds:r}=s;if(e.fullImageShadow){if(Ae(We,t.bounds),We.x+=i.x-r.x,We.y+=i.y-r.y,n){const{matrix:t}=s;We.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),We.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),We.width*=n,We.height*=n}t.copyWorld(s.canvas,t.bounds,We)}else n&&(Ae(We,i),We.x-=i.width/2*(n-1),We.y-=i.height/2*(n-1),We.width*=n,We.height*=n),t.copyWorld(s.canvas,r,n?We:i)}const{toOffsetOutBounds:Pe}=B,Me={};const De={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=o.length-1;Te(d,Oe),o.forEach(((o,g)=>{f.setWorldShadow(Oe.offsetX+o.x*c,Oe.offsetY+o.y*u,o.blur*c,D.string(o.color)),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ce(f,Oe,s,i),n=d,o.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),n=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,o.blendMode):e.copyWorldToInner(f,n,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=o.length-1;Pe(d,Me),o.forEach(((o,g)=>{f.save(),f.setWorldShadow(Me.offsetX+o.x*c,Me.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ce(f,Me,s,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,d,"source-out"),n=d),f.fillWorld(n,D.string(o.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,o.blendMode):e.copyWorldToInner(f,n,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ie}=g;function Fe(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ge(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ge(t,i,n,a);break;case"path":i.restore()}}function Ye(t){return t.getSameCanvas(!1,!0)}function Ge(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],o=i.__.mask,o&&(r&&(Fe(this,r,t,s,n,a),n=s=null),"path"===o||"clipping-path"===o?(i.opacity<1?(r="opacity-path",a=i.opacity,s||(s=Ye(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=Ye(t)),s||(s=Ye(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o)||Ie(i,e)||i.__render(s||t,e);Fe(this,r,t,s,n,a)};const ze=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=ze+"_#~&*+\\=|≮≯≈≠=…",Ne=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 Xe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const je=Xe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=Xe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),He=Xe(ze),Ve=Xe(Ue),Qe=Xe("- —/~|┆·");var Ze;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Ze||(Ze={}));const{Letter:$e,Single:Je,Before:Ke,After:ti,Symbol:ei,Break:ii}=Ze;function ni(t){return je[t]?$e:Qe[t]?ii:qe[t]?Ke:He[t]?ti:Ve[t]?ei:Ne.test(t)?Je:$e}const si={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ai(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:ri}=si,{Letter:oi,Single:li,Before:di,After:hi,Symbol:ci,Break:ui}=Ze;let fi,pi,gi,_i,wi,yi,mi,xi,vi,bi,Bi,ki,Ri,Ei,Si,Li,Ai,Ti=[];function Wi(t,e){vi&&!xi&&(xi=vi),fi.data.push({char:t,width:e}),gi+=e}function Oi(){_i+=gi,fi.width=gi,pi.words.push(fi),fi={data:[]},gi=0}function Ci(){Ei&&(Si.paraNumber++,pi.paraStart=!0,Ei=!1),vi&&(pi.startCharSize=xi,pi.endCharSize=vi,xi=0),pi.width=_i,Li.width?ri(pi):Ai&&Pi(),Ti.push(pi),pi={words:[]},_i=0}function Pi(){_i>(Si.maxWidth||0)&&(Si.maxWidth=_i)}const{top:Mi,right:Di,bottom:Ii,left:Fi}=W;function Yi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Gi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(n=d[Fi],a-=d[Di]+d[Fi]):i.autoSizeAlign||(n=d[Fi]),r?(s=d[Mi],r-=d[Mi]+d[Ii]):i.autoSizeAlign||(s=d[Mi]));const h={bounds:{x:n,y:s,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,n){Si=t,Ti=t.rows,Li=t.bounds,Ai=!Li.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=e,{width:l,height:d}=Li;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ei=!0,Bi=null,xi=mi=vi=gi=_i=0,fi={data:[]},pi={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)yi=i[n],"\n"===yi?(gi&&Oi(),pi.paraEnd=!0,Ci(),Ei=!0):(bi=ni(yi),bi===oi&&"none"!==r&&(yi=ai(yi,r,!gi)),mi=o.measureText(yi).width,s&&(s<0&&(vi=mi),mi+=s),ki=bi===li&&(Bi===li||Bi===oi)||Bi===li&&bi!==hi,Ri=!(bi!==di&&bi!==li||Bi!==ci&&Bi!==hi),wi=Ei&&a?l-a:l,t&&l&&_i+gi+mi>wi&&(e?(gi&&Oi(),_i&&Ci()):(Ri||(Ri=bi===oi&&Bi==hi),ki||Ri||bi===ui||bi===di||bi===li||gi+mi>wi?(gi&&Oi(),_i&&Ci()):_i&&Ci()))," "===yi&&!0!==Ei&&_i+gi===0||(bi===ui?(" "===yi&&gi&&Oi(),Wi(yi,mi),Oi()):ki||Ri?(gi&&Oi(),Wi(yi,mi)):Wi(yi,mi)),Bi=bi);gi&&Oi(),_i&&Ci(),Ti.length>0&&(Ti[Ti.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Si.paraNumber++,_i=o.measureText(t).width,Ti.push({x:a||0,text:t,width:_i,paraStart:!0}),Ai&&Pi()}))}(h,t,i),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Yi(e,"x",t[Fi]);break;case"right":Yi(e,"x",-t[Di])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Yi(e,"y",t[Mi]);break;case"bottom":Yi(e,"y",-t[Ii])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,w=a*s+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,x,v,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(m=i[r],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<n.x&&(n.x=x),v>n.width&&(n.width=v),l&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;n.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,h=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],l=t.x+t.width,!(n===i&&l<h));n--){if(l<h&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,a),"none"!==o&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=D.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(h,i),h}};const zi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(G,Gi),Object.assign(D,zi),Object.assign(z,Lt),Object.assign(M,de),Object.assign(I,Le),Object.assign(U,De),Object.assign(s,{interaction:(t,e,i,n)=>new P(t,e,i,n),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new C}),j();export{st as Layouter,N as LeaferCanvas,lt as Picker,rt as Renderer,dt as Selector,H as Watcher,j as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as x,ImageManager as v,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as E,MathHelper as S,AlignHelper as R,PointHelper as L,ImageEvent as A,AroundHelper as T,Direction4 as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as C,InteractionBase as W}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,Paint as M,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as U,Effect as G}from"@leafer-ui/draw";class z 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:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:N}=s;function X(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:N(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:N(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then((t=>{i(t)})).catch((t=>{s(t)}))},n.onerror=t=>s(t),n.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new z(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):j.indexOf("Safari")>-1&&-1===j.indexOf("Chrome")&&(e.fullImageShadow=!0),j.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):j.indexOf("Mac")>-1?e.os="Mac":j.indexOf("Linux")>-1&&(e.os="Linux");class q{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=l.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===h.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:H,updateBounds:V,updateChange:Q}=f,{pushAllChildBranch:Z,pushAllParent:$}=p;const{worldBounds:J}=g;class K{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,J)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,J),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:tt,updateAllChange:et}=f,it=w.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=m,o=this.getBlocks(s);o.forEach((t=>t.setBefore())),i.emitEvent(new m(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?(H(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(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||V(s[t])}V(i)}}))}(this.__levelList),function(t){t.list.forEach(Q)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new m(a,o,this.times)),i.emitEvent(new m(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=m,a=this.getBlocks(new o(e));e.emitEvent(new m(i,a,this.times)),st.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(s,a,this.times)),e.emitEvent(new m(n,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new K([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new K(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(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[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=w.get("Renderer");class at{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,nt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.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 _,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;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(at.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__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,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[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)}}at.clipSpread=10;const{hitRadiusPoint:rt}=B;class ot{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,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:s,y:n}=this.point,a={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}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.__.mask||(s=!!i.__.hitRadius||rt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class lt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new ot(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function dt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function ht(t,e){t.__.__font?dt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ct(t,e,i){switch(e.__.strokeAlign){case"center":ut(t,1,e,i);break;case"inside":ft(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ut(t,2,e,i):ft(t,"outside",e,i)}}function ut(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?_t(t,!0,i,s):gt(i,s)}function ft(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ut(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",dt(i,n),n.blendMode="normal",pt(s,n,i),n.recycle(i.__nowWorld)}function pt(t,i,s){s.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(i,s.__nowWorld):t.copyWorldToInner(i,s.__nowWorld,s.__layout.renderBounds)}function gt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[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)}));if(a){const{decorationHeight:t}=s;n.forEach((i=>a.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function _t(t,e,i,s){let n;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&P.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?gt(i,s):s.stroke(),s.restoreBlendMode()):e?gt(i,s):s.stroke())}function wt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ct(t,e,i);else switch(s.strokeAlign){case"center":yt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),yt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)yt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),yt(t,2,e,a),a.clipUI(s),a.clearWorld(n),pt(i,a,e),a.recycle(e.__nowWorld)}}(t,e,i)}}function yt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?_t(t,!1,i,s):s.stroke(),n.__useArrow&&M.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new at(t,e,i),selector:(t,e)=>new lt(t,e)}),e.layout=st.fullLayout;const{getSpread:mt,getOuterOf:xt,getByMove:vt,getIntersectData:bt}=B;let Bt;const{stintSet:kt}=l,{hasTransparent:Et}=D;function St(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=P.image(i,t,e,n,!Bt||!Bt[e.url]);break;case"linear":s=I.linearGradient(e,n);break;case"radial":s=I.radialGradient(e,n);break;case"angular":s=I.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:D.string(r,o)};break;default:void 0!==e.r&&(s={type:"solid",style:D.string(e)})}return s&&("string"==typeof s.style&&Et(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const Rt={compute:function(t,e){const i=e.__,s=[];let n,a,r=i.__input[t];r instanceof Array||(r=[r]),Bt=P.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=St(t,r[n],e))&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),a=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",n),kt(i,"__isTransparentFill",a)):(kt(i,"__isAlphaPixelStroke",n),kt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,ht(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(P.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),ht(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),ht(e,i),i.restoreBlendMode()):ht(e,i)}},fillPathOrText:ht,fillText:dt,stroke:wt,strokes:function(t,e,i){wt(t,e,i)},strokeText:ct,drawTextStroke:gt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,r,o,l,{scaleX:d,scaleY:h}=n;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(n))l=s,a=o=n;else{const{renderShapeSpread:s}=t.__layout,c=bt(s?mt(e.bounds,d===h?s*d:[s*h,s*d]):e.bounds,n);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),o=xt(n,r),a=vt(o,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:a,worldCanvas:l,shapeBounds:o,scaleX:d,scaleY:h}}};let Lt={};const{get:At,rotateOfOuter:Tt,translate:Ot,scaleOfOuter:Ct,scale:Wt,rotate:Pt}=E;function Mt(t,e,i,s,n,a,r){const o=At();Ot(o,e.x+i,e.y+s),Wt(o,n,a),r&&Tt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Dt(t,e,i,s,n,a,r){const o=At();Ot(o,e.x+i,e.y+s),n&&Wt(o,n,a),r&&Pt(o,r),t.transform=o}function It(t,e,i,s,n,a,r,o,l,d){const h=At();if(l)if("center"===d)Tt(h,{x:i/2,y:s/2},l);else switch(Pt(h,l),l){case 90:Ot(h,s,0);break;case 180:Ot(h,i,s);break;case 270:Ot(h,0,i)}Lt.x=e.x+n,Lt.y=e.y+a,Ot(h,Lt.x,Lt.y),r&&Ct(h,Lt,r,o),t.transform=h}const{get:Ft,translate:Yt}=E,Ut=new _,Gt={},zt={};function Nt(t,e,i,s){const{changeful:n,sync:a}=i;n&&(t.changeful=n),a&&(t.sync=a),t.data=Xt(i,s,e)}function Xt(t,e,i){t.padding&&(e=Ut.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,repeat:u,filters:f}=t,p=e.width===s&&e.height===n,g={mode:r},_="center"!==o&&(c||0)%180==90;let w,y;switch(B.set(zt,0,0,_?n:s,_?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(S.getScaleData(d,h,i,Gt),w=Gt.scaleX,y=Gt.scaleY),o&&(w&&B.scale(zt,w,y,!0),R.toPoint(o,zt,e,zt,!0,!0))):p&&!c||(w=y=B.getFitScale(e,zt,"fit"!==r),B.put(e,i,o,w,!1,zt),B.scale(zt,w,y,!0)),l&&L.move(zt,l),r){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(zt.x||zt.y||w||c)&&Dt(g,e,zt.x,zt.y,w,y,c);break;case"repeat":(!p||w||c)&&It(g,e,s,n,zt.x,zt.y,w,y,c,o),u||(g.repeat="repeat");break;default:w&&Mt(g,e,zt.x,zt.y,w,y,c)}return g.transform||(e.x||e.y)&&(g.transform=Ft(),Yt(g.transform,e.x,e.y)),w&&"stretch"!==r&&(g.scaleX=w,g.scaleY=y),g.width=s,g.height=n,a&&(g.opacity=a),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let jt,qt=new _;const{isSame:Ht}=B;function Vt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Nt(n,s,i,a),!0}function Qt(t,e){Jt(t,A.LOAD,e)}function Zt(t,e){Jt(t,A.LOADED,e)}function $t(t,e,i){e.error=i,t.forceUpdate("surface"),Jt(t,A.ERROR,e)}function Jt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Kt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:te,scale:ee,copy:ie}=E,{ceil:se,abs:ne}=Math;function ae(t,i,s){let{scaleX:n,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{n=ne(n),a=ne(a);const{image:t,data:o}=i;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g}=o;u&&(d=te(),ie(d,p),ee(d,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const _=h*c;if(!g&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(l=Math.sqrt(_/w)),l&&(n/=l,a/=l,h/=l,c/=l),u&&(n/=u,a/=f),(p||1!==n||1!==a)&&(d||(d=te(),p&&ie(d,p)),ee(d,1/n,1/a));const y=t.getCanvas(se(h)||1,se(c)||1,o.opacity,o.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=r,!0}}function re(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:oe}=Math;const le={image:function(t,e,i,s,n){let a,r;const o=v.get(i);return jt&&i===jt.paint&&Ht(s,jt.boxBounds)?a=jt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),jt=o.use>1?{leafPaint:a,paint:i,boxBounds:qt.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Vt(t,e,i,o,a,s),n&&(Qt(t,r),Zt(t,r))):o.error?n&&$t(t,r,o.error):(n&&(Kt(t,!0),Qt(t,r)),a.loadId=o.load((()=>{Kt(t,!1),t.destroyed||(Vt(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Zt(t,r)),a.loadId=null}),(e=>{Kt(t,!1),$t(t,r,e),a.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=v.patternLocked?t.__world:t.__nowWorld,{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!F.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||b.isResizing(t)||F.running)){let{width:t,height:i}=l;t*=oe(a)*o,i*=oe(r)*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||F.running?ae(t,s,o):s.patternTask||(s.patternTask=v.patternTasker.add((()=>re(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ae(t,s,o),t.forceUpdate("surface")}))),300)),!1)},createPattern:ae,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,v.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),n.unload(i[l].loadId,!r.some((t=>t.url===o)))));return a}return null},createData:Nt,getPatternData:Xt,fillOrFitMode:Mt,clipMode:Dt,repeatMode:It},{toPoint:de}=T,{hasTransparent:he}=D,ce={},ue={};function fe(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],"string"==typeof n?(r=t/(l-1),a=D.string(n,s)):(r=n.offset,a=D.string(n.color,s)),e.addColorStop(r,a),!o&&he(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:pe,getDistance:ge}=L,{get:_e,rotateOfOuter:we,scaleOfOuter:ye}=E,{toPoint:me}=T,xe={},ve={};function be(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=pe(e,i);a=_e(),n?(ye(a,e,r/o*(s||1),1),we(a,e,t+90)):(ye(a,e,1,r/o*(s||1)),we(a,e,t))}return a}const{getDistance:Be}=L,{toPoint:ke}=T,Ee={},Se={};const Re={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;de(s||"top",i,ce),de(n||"bottom",i,ue);const o=e.canvas.createLinearGradient(ce.x,ce.y,ue.x,ue.y),l={type:a,style:o};return fe(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;me(s||"center",i,xe),me(n||"bottom",i,ve);const l=e.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,ge(xe,ve)),d={type:a,style:l};fe(d,l,t.stops,r);const h=be(i,xe,ve,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;ke(s||"center",i,Ee),ke(n||"bottom",i,Se);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ee.x,Ee.y):e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,Be(Ee,Se)),d={type:a,style:l};fe(d,l,t.stops,r);const h=be(i,Ee,Se,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:be},{copy:Le,toOffsetOutBounds:Ae}=B,Te={},Oe={};function Ce(t,i,s,n){const{bounds:a,shapeBounds:r}=n;if(e.fullImageShadow){if(Le(Te,t.bounds),Te.x+=i.x-r.x,Te.y+=i.y-r.y,s){const{matrix:t}=n;Te.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Te.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Te.width*=s,Te.height*=s}t.copyWorld(n.canvas,t.bounds,Te)}else s&&(Le(Te,i),Te.x-=i.width/2*(s-1),Te.y-=i.height/2*(s-1),Te.width*=s,Te.height*=s),t.copyWorld(n.canvas,r,s?Te:i)}const{toOffsetOutBounds:We}=B,Pe={};const Me={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=o.length-1;Ae(d,Oe),o.forEach(((o,g)=>{f.setWorldShadow(Oe.offsetX+o.x*c,Oe.offsetY+o.y*u,o.blur*c,D.string(o.color)),n=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ce(f,Oe,n,i),s=d,o.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),s=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,o.blendMode):e.copyWorldToInner(f,s,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=o.length-1;We(d,Pe),o.forEach(((o,g)=>{f.save(),f.setWorldShadow(Pe.offsetX+o.x*c,Pe.offsetY+o.y*u,o.blur*c),n=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ce(f,Pe,n,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,d,"source-out"),s=d),f.fillWorld(s,D.string(o.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,o.blendMode):e.copyWorldToInner(f,s,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:De}=g;function Ie(t,e,i,s,n,a){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ye(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ye(t,i,s,a);break;case"path":i.restore()}}function Fe(t){return t.getSameCanvas(!1,!0)}function Ye(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Y.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],o=i.__.mask,o&&(r&&(Ie(this,r,t,n,s,a),s=n=null),"path"===o||"clipping-path"===o?(i.opacity<1?(r="opacity-path",a=i.opacity,n||(n=Fe(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Fe(t)),n||(n=Fe(t)),i.__render(s,e)),"clipping"!==o&&"clipping-path"!==o)||De(i,e)||i.__render(n||t,e);Ie(this,r,t,n,s,a)};const Ue=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ge=Ue+"_#~&*+\\=|≮≯≈≠=…",ze=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 Ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Xe=Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),je=Ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),qe=Ne(Ue),He=Ne(Ge),Ve=Ne("- —/~|┆·");var Qe;!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"}(Qe||(Qe={}));const{Letter:Ze,Single:$e,Before:Je,After:Ke,Symbol:ti,Break:ei}=Qe;function ii(t){return Xe[t]?Ze:Ve[t]?ei:je[t]?Je:qe[t]?Ke:He[t]?ti:ze.test(t)?$e:Ze}const si={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 ni(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:ai}=si,{Letter:ri,Single:oi,Before:li,After:di,Symbol:hi,Break:ci}=Qe;let ui,fi,pi,gi,_i,wi,yi,mi,xi,vi,bi,Bi,ki,Ei,Si,Ri,Li,Ai=[];function Ti(t,e){xi&&!mi&&(mi=xi),ui.data.push({char:t,width:e}),pi+=e}function Oi(){gi+=pi,ui.width=pi,fi.words.push(ui),ui={data:[]},pi=0}function Ci(){Ei&&(Si.paraNumber++,fi.paraStart=!0,Ei=!1),xi&&(fi.startCharSize=mi,fi.endCharSize=xi,mi=0),fi.width=gi,Ri.width?ai(fi):Li&&Wi(),Ai.push(fi),fi={words:[]},gi=0}function Wi(){gi>(Si.maxWidth||0)&&(Si.maxWidth=gi)}const{top:Pi,right:Mi,bottom:Di,left:Ii}=O;function Fi(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 Yi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[Ii],a-=d[Mi]+d[Ii]):i.autoSizeAlign||(s=d[Ii]),r?(n=d[Pi],r-=d[Pi]+d[Di]):i.autoSizeAlign||(n=d[Pi]));const h={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Si=t,Ai=t.rows,Ri=t.bounds,Li=!Ri.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=Ri;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Ei=!0,bi=null,mi=yi=xi=pi=gi=0,ui={data:[]},fi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)wi=i[s],"\n"===wi?(pi&&Oi(),fi.paraEnd=!0,Ci(),Ei=!0):(vi=ii(wi),vi===ri&&"none"!==r&&(wi=ni(wi,r,!pi)),yi=o.measureText(wi).width,n&&(n<0&&(xi=yi),yi+=n),Bi=vi===oi&&(bi===oi||bi===ri)||bi===oi&&vi!==di,ki=!(vi!==li&&vi!==oi||bi!==hi&&bi!==di),_i=Ei&&a?l-a:l,t&&l&&gi+pi+yi>_i&&(e?(pi&&Oi(),gi&&Ci()):(ki||(ki=vi===ri&&bi==di),Bi||ki||vi===ci||vi===li||vi===oi||pi+yi>_i?(pi&&Oi(),gi&&Ci()):gi&&Ci()))," "===wi&&!0!==Ei&&gi+pi===0||(vi===ci?(" "===wi&&pi&&Oi(),Ti(wi,yi),Oi()):Bi||ki?(pi&&Oi(),Ti(wi,yi)):Ti(wi,yi)),bi=vi);pi&&Oi(),gi&&Ci(),Ai.length>0&&(Ai[Ai.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Si.paraNumber++,gi=o.measureText(t).width,Ai.push({x:a||0,text:t,width:gi,paraStart:!0}),Li&&Wi()}))}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Fi(e,"x",t[Ii]);break;case"right":Fi(e,"x",-t[Mi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Fi(e,"y",t[Pi]);break;case"bottom":Fi(e,"y",-t[Di])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,x,v,b=g||u?g:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;s.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,h=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,s,a),"none"!==o&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=D.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const Ui={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(U,Yi),Object.assign(D,Ui),Object.assign(M,Rt),Object.assign(P,le),Object.assign(I,Re),Object.assign(G,Me),Object.assign(n,{interaction:(t,e,i,s)=>new W(t,e,i,s),hitCanvas:(t,e)=>new z(t,e),hitCanvasManager:()=>new C}),X();export{st as Layouter,z as LeaferCanvas,ot as Picker,at as Renderer,lt as Selector,q as Watcher,X as useCanvas};
|
|
2
2
|
//# sourceMappingURL=worker.esm.min.js.map
|