@leafer-draw/node 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/node.cjs +17 -27
- package/dist/node.esm.js +24 -34
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +10 -10
package/dist/node.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var core = require('@leafer/core');
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var draw = require('@leafer-ui/draw');
|
|
6
|
-
var core$1 = require('@leafer-ui/core');
|
|
7
6
|
|
|
8
7
|
/******************************************************************************
|
|
9
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -734,8 +733,6 @@ function fillPathOrText(ui, canvas) {
|
|
|
734
733
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
735
734
|
}
|
|
736
735
|
|
|
737
|
-
const Paint = {};
|
|
738
|
-
|
|
739
736
|
function strokeText(stroke, ui, canvas) {
|
|
740
737
|
switch (ui.__.strokeAlign) {
|
|
741
738
|
case 'center':
|
|
@@ -761,11 +758,14 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
761
758
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
762
759
|
fillText(ui, out);
|
|
763
760
|
out.blendMode = 'normal';
|
|
764
|
-
|
|
761
|
+
copyWorld(canvas, out, ui);
|
|
762
|
+
out.recycle(ui.__nowWorld);
|
|
763
|
+
}
|
|
764
|
+
function copyWorld(canvas, out, ui) {
|
|
765
|
+
if (ui.__worldFlipped || core.Platform.fullImageShadow)
|
|
765
766
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
766
767
|
else
|
|
767
768
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
768
|
-
out.recycle(ui.__nowWorld);
|
|
769
769
|
}
|
|
770
770
|
function drawTextStroke(ui, canvas) {
|
|
771
771
|
let row, data = ui.__.__textDrawData;
|
|
@@ -831,12 +831,11 @@ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
|
831
831
|
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
832
832
|
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
833
833
|
if (data.__useArrow)
|
|
834
|
-
Paint.strokeArrow(stroke, ui, canvas);
|
|
834
|
+
draw.Paint.strokeArrow(stroke, ui, canvas);
|
|
835
835
|
}
|
|
836
836
|
function drawInside(stroke, ui, canvas) {
|
|
837
|
-
const data = ui.__;
|
|
838
837
|
canvas.save();
|
|
839
|
-
|
|
838
|
+
canvas.clipUI(ui);
|
|
840
839
|
drawCenter(stroke, 2, ui, canvas);
|
|
841
840
|
canvas.restore();
|
|
842
841
|
}
|
|
@@ -850,12 +849,9 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
850
849
|
const out = canvas.getSameCanvas(true, true);
|
|
851
850
|
ui.__drawRenderPath(out);
|
|
852
851
|
drawCenter(stroke, 2, ui, out);
|
|
853
|
-
|
|
852
|
+
out.clipUI(data);
|
|
854
853
|
out.clearWorld(renderBounds);
|
|
855
|
-
|
|
856
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
857
|
-
else
|
|
858
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
854
|
+
copyWorld(canvas, out, ui);
|
|
859
855
|
out.recycle(ui.__nowWorld);
|
|
860
856
|
}
|
|
861
857
|
}
|
|
@@ -911,9 +907,7 @@ function compute(attrName, ui) {
|
|
|
911
907
|
paints = [paints];
|
|
912
908
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
913
909
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
914
|
-
item = getLeafPaint(attrName, paints[i], ui);
|
|
915
|
-
if (item)
|
|
916
|
-
leafPaints.push(item);
|
|
910
|
+
(item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
|
|
917
911
|
}
|
|
918
912
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
919
913
|
if (leafPaints.length) {
|
|
@@ -951,8 +945,8 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
951
945
|
data = draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
952
946
|
break;
|
|
953
947
|
case 'solid':
|
|
954
|
-
const { type,
|
|
955
|
-
data = { type,
|
|
948
|
+
const { type, color, opacity } = paint;
|
|
949
|
+
data = { type, style: draw.ColorConvert.string(color, opacity) };
|
|
956
950
|
break;
|
|
957
951
|
default:
|
|
958
952
|
if (paint.r !== undefined)
|
|
@@ -1329,7 +1323,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1329
1323
|
}
|
|
1330
1324
|
function drawImage(ui, canvas, paint, data) {
|
|
1331
1325
|
canvas.save();
|
|
1332
|
-
|
|
1326
|
+
canvas.clipUI(ui);
|
|
1333
1327
|
if (paint.blendMode)
|
|
1334
1328
|
canvas.blendMode = paint.blendMode;
|
|
1335
1329
|
if (data.opacity)
|
|
@@ -1494,12 +1488,10 @@ function shadow(ui, current, shape) {
|
|
|
1494
1488
|
}
|
|
1495
1489
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1496
1490
|
}
|
|
1497
|
-
if (ui.__worldFlipped)
|
|
1491
|
+
if (ui.__worldFlipped)
|
|
1498
1492
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1499
|
-
|
|
1500
|
-
else {
|
|
1493
|
+
else
|
|
1501
1494
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1502
|
-
}
|
|
1503
1495
|
if (end && index < end)
|
|
1504
1496
|
other.clearWorld(copyBounds, true);
|
|
1505
1497
|
});
|
|
@@ -1558,12 +1550,10 @@ function innerShadow(ui, current, shape) {
|
|
|
1558
1550
|
copyBounds = bounds;
|
|
1559
1551
|
}
|
|
1560
1552
|
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1561
|
-
if (ui.__worldFlipped)
|
|
1553
|
+
if (ui.__worldFlipped)
|
|
1562
1554
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1563
|
-
|
|
1564
|
-
else {
|
|
1555
|
+
else
|
|
1565
1556
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1566
|
-
}
|
|
1567
1557
|
if (end && index < end)
|
|
1568
1558
|
other.clearWorld(copyBounds, true);
|
|
1569
1559
|
});
|
package/dist/node.esm.js
CHANGED
|
@@ -2,9 +2,8 @@ import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferIma
|
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
4
|
import { writeFileSync } from 'fs';
|
|
5
|
-
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert,
|
|
5
|
+
import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect, TwoPointBoundsHelper, Bounds as Bounds$1, FileHelper as FileHelper$1, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, TaskProcessor, Resource, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin, UI } from '@leafer-ui/draw';
|
|
6
6
|
export * from '@leafer-ui/draw';
|
|
7
|
-
import { Platform as Platform$1 } from '@leafer-ui/core';
|
|
8
7
|
|
|
9
8
|
/******************************************************************************
|
|
10
9
|
Copyright (c) Microsoft Corporation.
|
|
@@ -735,8 +734,6 @@ function fillPathOrText(ui, canvas) {
|
|
|
735
734
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
736
735
|
}
|
|
737
736
|
|
|
738
|
-
const Paint = {};
|
|
739
|
-
|
|
740
737
|
function strokeText(stroke, ui, canvas) {
|
|
741
738
|
switch (ui.__.strokeAlign) {
|
|
742
739
|
case 'center':
|
|
@@ -762,11 +759,14 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
762
759
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
763
760
|
fillText(ui, out);
|
|
764
761
|
out.blendMode = 'normal';
|
|
765
|
-
|
|
762
|
+
copyWorld(canvas, out, ui);
|
|
763
|
+
out.recycle(ui.__nowWorld);
|
|
764
|
+
}
|
|
765
|
+
function copyWorld(canvas, out, ui) {
|
|
766
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
766
767
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
767
768
|
else
|
|
768
769
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
769
|
-
out.recycle(ui.__nowWorld);
|
|
770
770
|
}
|
|
771
771
|
function drawTextStroke(ui, canvas) {
|
|
772
772
|
let row, data = ui.__.__textDrawData;
|
|
@@ -835,9 +835,8 @@ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
|
835
835
|
Paint.strokeArrow(stroke, ui, canvas);
|
|
836
836
|
}
|
|
837
837
|
function drawInside(stroke, ui, canvas) {
|
|
838
|
-
const data = ui.__;
|
|
839
838
|
canvas.save();
|
|
840
|
-
|
|
839
|
+
canvas.clipUI(ui);
|
|
841
840
|
drawCenter(stroke, 2, ui, canvas);
|
|
842
841
|
canvas.restore();
|
|
843
842
|
}
|
|
@@ -851,12 +850,9 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
851
850
|
const out = canvas.getSameCanvas(true, true);
|
|
852
851
|
ui.__drawRenderPath(out);
|
|
853
852
|
drawCenter(stroke, 2, ui, out);
|
|
854
|
-
|
|
853
|
+
out.clipUI(data);
|
|
855
854
|
out.clearWorld(renderBounds);
|
|
856
|
-
|
|
857
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
858
|
-
else
|
|
859
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
855
|
+
copyWorld(canvas, out, ui);
|
|
860
856
|
out.recycle(ui.__nowWorld);
|
|
861
857
|
}
|
|
862
858
|
}
|
|
@@ -912,9 +908,7 @@ function compute(attrName, ui) {
|
|
|
912
908
|
paints = [paints];
|
|
913
909
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
914
910
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
915
|
-
item = getLeafPaint(attrName, paints[i], ui);
|
|
916
|
-
if (item)
|
|
917
|
-
leafPaints.push(item);
|
|
911
|
+
(item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
|
|
918
912
|
}
|
|
919
913
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
920
914
|
if (leafPaints.length) {
|
|
@@ -952,8 +946,8 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
952
946
|
data = PaintGradient.conicGradient(paint, boxBounds);
|
|
953
947
|
break;
|
|
954
948
|
case 'solid':
|
|
955
|
-
const { type,
|
|
956
|
-
data = { type,
|
|
949
|
+
const { type, color, opacity } = paint;
|
|
950
|
+
data = { type, style: ColorConvert.string(color, opacity) };
|
|
957
951
|
break;
|
|
958
952
|
default:
|
|
959
953
|
if (paint.r !== undefined)
|
|
@@ -1330,7 +1324,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1330
1324
|
}
|
|
1331
1325
|
function drawImage(ui, canvas, paint, data) {
|
|
1332
1326
|
canvas.save();
|
|
1333
|
-
|
|
1327
|
+
canvas.clipUI(ui);
|
|
1334
1328
|
if (paint.blendMode)
|
|
1335
1329
|
canvas.blendMode = paint.blendMode;
|
|
1336
1330
|
if (data.opacity)
|
|
@@ -1495,12 +1489,10 @@ function shadow(ui, current, shape) {
|
|
|
1495
1489
|
}
|
|
1496
1490
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1497
1491
|
}
|
|
1498
|
-
if (ui.__worldFlipped)
|
|
1492
|
+
if (ui.__worldFlipped)
|
|
1499
1493
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1500
|
-
|
|
1501
|
-
else {
|
|
1494
|
+
else
|
|
1502
1495
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1503
|
-
}
|
|
1504
1496
|
if (end && index < end)
|
|
1505
1497
|
other.clearWorld(copyBounds, true);
|
|
1506
1498
|
});
|
|
@@ -1559,12 +1551,10 @@ function innerShadow(ui, current, shape) {
|
|
|
1559
1551
|
copyBounds = bounds;
|
|
1560
1552
|
}
|
|
1561
1553
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
1562
|
-
if (ui.__worldFlipped)
|
|
1554
|
+
if (ui.__worldFlipped)
|
|
1563
1555
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1564
|
-
|
|
1565
|
-
else {
|
|
1556
|
+
else
|
|
1566
1557
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1567
|
-
}
|
|
1568
1558
|
if (end && index < end)
|
|
1569
1559
|
other.clearWorld(copyBounds, true);
|
|
1570
1560
|
});
|
|
@@ -2200,7 +2190,7 @@ const ColorConvertModule = {
|
|
|
2200
2190
|
|
|
2201
2191
|
Object.assign(TextConvert, TextConvertModule);
|
|
2202
2192
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
2203
|
-
Object.assign(Paint
|
|
2193
|
+
Object.assign(Paint, PaintModule);
|
|
2204
2194
|
Object.assign(PaintImage, PaintImageModule);
|
|
2205
2195
|
Object.assign(PaintGradient, PaintGradientModule);
|
|
2206
2196
|
Object.assign(Effect, EffectModule);
|
|
@@ -2230,8 +2220,8 @@ const ExportModule = {
|
|
|
2230
2220
|
const fileType = FileHelper$1.fileType(filename);
|
|
2231
2221
|
const isDownload = filename.includes('.');
|
|
2232
2222
|
options = FileHelper$1.getExportOptions(options);
|
|
2233
|
-
const { toURL } = Platform$
|
|
2234
|
-
const { download } = Platform$
|
|
2223
|
+
const { toURL } = Platform$1;
|
|
2224
|
+
const { download } = Platform$1.origin;
|
|
2235
2225
|
if (fileType === 'json') {
|
|
2236
2226
|
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
2237
2227
|
result = { data: isDownload ? true : leaf.toJSON(options.json) };
|
|
@@ -2334,7 +2324,7 @@ const ExportModule = {
|
|
|
2334
2324
|
return addTask((success) => new Promise((resolve) => {
|
|
2335
2325
|
const getResult = () => __awaiter(this, void 0, void 0, function* () {
|
|
2336
2326
|
if (!Resource.isComplete)
|
|
2337
|
-
return Platform$
|
|
2327
|
+
return Platform$1.requestRender(getResult);
|
|
2338
2328
|
const result = ExportModule.syncExport(leaf, filename, options);
|
|
2339
2329
|
if (result.data instanceof Promise)
|
|
2340
2330
|
result.data = yield result.data;
|
|
@@ -2379,7 +2369,7 @@ canvas.export = function (filename, options) {
|
|
|
2379
2369
|
};
|
|
2380
2370
|
canvas.toBlob = function (type, quality) {
|
|
2381
2371
|
return new Promise((resolve) => {
|
|
2382
|
-
Platform$
|
|
2372
|
+
Platform$1.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
2383
2373
|
resolve(blob);
|
|
2384
2374
|
}).catch((e) => {
|
|
2385
2375
|
debug.error(e);
|
|
@@ -2388,11 +2378,11 @@ canvas.toBlob = function (type, quality) {
|
|
|
2388
2378
|
});
|
|
2389
2379
|
};
|
|
2390
2380
|
canvas.toDataURL = function (type, quality) {
|
|
2391
|
-
return Platform$
|
|
2381
|
+
return Platform$1.origin.canvasToDataURL(this.view, type, quality);
|
|
2392
2382
|
};
|
|
2393
2383
|
canvas.saveAs = function (filename, quality) {
|
|
2394
2384
|
return new Promise((resolve) => {
|
|
2395
|
-
Platform$
|
|
2385
|
+
Platform$1.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
2396
2386
|
resolve(true);
|
|
2397
2387
|
}).catch((e) => {
|
|
2398
2388
|
debug.error(e);
|
package/dist/node.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 o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,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 v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as S,AlignHelper as k,PointHelper as E,ImageEvent as L,AroundHelper as A,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{PaintImage as W,ColorConvert as C,PaintGradient as D,Export as P,Group as M,TextConvert as I,Paint as F,Effect as Y,TwoPointBoundsHelper as U,Bounds as N,FileHelper as X,Platform as z,Matrix as j,MathHelper as G,Creator as q,TaskProcessor as H,Resource as V,LeaferCanvasBase as Q,Debug as J,Plugin as Z,UI as $}from"@leafer-ui/draw";export*from"@leafer-ui/draw";import{Platform as K}from"@leafer-ui/core";function tt(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function r(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(o,r)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class et extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__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}}const{mineType:it,fileType:nt}=n;function st(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(it(e),i),canvasToBolb:(t,e,i)=>tt(this,void 0,void 0,(function*(){return t.toBuffer(it(e),i)})),canvasSaveAs:(t,e,i)=>tt(this,void 0,void 0,(function*(){return O(e,t.toBuffer(it(nt(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new et(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class at{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,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===c.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 h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:ot,updateBounds:rt,updateChange:lt}=f,{pushAllChildBranch:dt,pushAllParent:ct}=p;const{worldBounds:ht}=g;class ut{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ht)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ht),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:ft,updateAllChange:pt}=f,gt=w.get("Layouter");class _t{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){gt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gt.warn("layouting"):this.times>3?gt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.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=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,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?(ot(t,!0),e.add(t),t.isBranch&&dt(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(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||rt(n[t])}rt(i)}}))}(this.__levelList),function(t){t.list.forEach(lt)}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),_t.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),v.end(t)}static fullLayout(t){ft(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),pt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ut([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ut(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],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const wt=w.get("Renderer");class yt{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 _,wt.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,wt.error(t)}wt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return wt.warn("rendering");if(this.times>3)return wt.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=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(yt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.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||wt.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)}}function mt(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 vt(t,e){t.__.__font?mt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}yt.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new at(t,e),layouter:(t,e)=>new _t(t,e),renderer:(t,e,i)=>new yt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=_t.fullLayout;const xt={};function bt(t,e,i){switch(e.__.strokeAlign){case"center":Bt(t,1,e,i);break;case"inside":Rt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Bt(t,2,e,i):Rt(t,"outside",e,i)}}function Bt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?kt(t,!0,i,n):St(i,n)}function Rt(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,Bt(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",mt(i,s),s.blendMode="normal",i.__worldFlipped||K.fullImageShadow?n.copyWorldByReset(s,i.__nowWorld):n.copyWorldToInner(s,i.__nowWorld,i.__layout.renderBounds),s.recycle(i.__nowWorld)}function St(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 kt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&W.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?St(i,n):n.stroke(),n.restoreBlendMode()):e?St(i,n):n.stroke())}function Et(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)bt(t,e,i);else switch(n.strokeAlign){case"center":Lt(t,1,e,i);break;case"inside":!function(t,e,i){const n=e.__;i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),Lt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)Lt(t,2,e,i);else{const{renderBounds:s}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Lt(t,2,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(s),e.__worldFlipped||K.fullImageShadow?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,s),a.recycle(e.__nowWorld)}}(t,e,i)}}function Lt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?kt(t,!1,i,n):n.stroke(),s.__useArrow&&xt.strokeArrow(t,i,n)}const{getSpread:At,getOuterOf:Tt,getByMove:Ot,getIntersectData:Wt}=B;let Ct;const{stintSet:Dt}=l,{hasTransparent:Pt}=C;function Mt(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=W.image(i,t,e,s,!Ct||!Ct[e.url]);break;case"linear":n=D.linearGradient(e,s);break;case"radial":n=D.radialGradient(e,s);break;case"angular":n=D.conicGradient(e,s);break;case"solid":const{type:a,blendMode:o,color:r,opacity:l}=e;n={type:a,blendMode:o,style:C.string(r,l)};break;default:void 0!==e.r&&(n={type:"solid",style:C.string(e)})}return n&&("string"==typeof n.style&&Pt(n.style)&&(n.isTransparent=!0),e.blendMode&&(n.blendMode=e.blendMode)),n}const It={compute:function(t,e){const i=e.__,n=[];let s,a,o=i.__input[t];o instanceof Array||(o=[o]),Ct=W.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=Mt(t,o[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?(Dt(i,"__isAlphaPixelFill",s),Dt(i,"__isTransparentFill",a)):(Dt(i,"__isAlphaPixelStroke",s),Dt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,vt(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(W.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),vt(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),vt(e,i),i.restoreBlendMode()):vt(e,i)}},fillPathOrText:vt,fillText:mt,stroke:Et,strokes:function(t,e,i){Et(t,e,i)},strokeText:bt,drawTextStroke:St,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,h=Wt(n?At(e.bounds,d===c?n*d:[n*c,n*d]):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,c*=f),r=Tt(s,o),a=Ot(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let Ft={};const{get:Yt,rotateOfOuter:Ut,translate:Nt,scaleOfOuter:Xt,scale:zt,rotate:jt}=R;function Gt(t,e,i,n,s,a,o){const r=Yt();Nt(r,e.x+i,e.y+n),zt(r,s,a),o&&Ut(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function qt(t,e,i,n,s,a,o){const r=Yt();Nt(r,e.x+i,e.y+n),s&&zt(r,s,a),o&&jt(r,o),t.transform=r}function Ht(t,e,i,n,s,a,o,r,l,d){const c=Yt();if(l)if("center"===d)Ut(c,{x:i/2,y:n/2},l);else switch(jt(c,l),l){case 90:Nt(c,n,0);break;case 180:Nt(c,i,n);break;case 270:Nt(c,0,i)}Ft.x=e.x+s,Ft.y=e.y+a,Nt(c,Ft.x,Ft.y),o&&Xt(c,Ft,o,r),t.transform=c}const{get:Vt,translate:Qt}=R,Jt=new _,Zt={},$t={};function Kt(t,e,i,n){const{changeful:s,sync:a}=i;s&&(t.changeful=s),a&&(t.sync=a),t.data=te(i,n,e)}function te(t,e,i){t.padding&&(e=Jt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:s}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(h||0)%180==90;let w,y;switch(B.set($t,0,0,_?s:n,_?n:s),o&&"cover"!==o&&"fit"!==o?((d||c)&&(S.getScaleData(d,c,i,Zt),w=Zt.scaleX,y=Zt.scaleY),r&&(w&&B.scale($t,w,y,!0),k.toPoint(r,$t,e,$t,!0,!0))):p&&!h||(w=y=B.getFitScale(e,$t,"fit"!==o),B.put(e,i,r,w,!1,$t),B.scale($t,w,y,!0)),l&&E.move($t,l),o){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":($t.x||$t.y||w||h)&&qt(g,e,$t.x,$t.y,w,y,h);break;case"repeat":(!p||w||h)&&Ht(g,e,n,s,$t.x,$t.y,w,y,h,r),u||(g.repeat="repeat");break;default:w&&Gt(g,e,$t.x,$t.y,w,y,h)}return g.transform||(e.x||e.y)&&(g.transform=Vt(),Qt(g.transform,e.x,e.y)),w&&"stretch"!==o&&(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 ee,ie=new _;const{isSame:ne}=B;function se(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||Kt(s,n,i,a),!0}function ae(t,e){le(t,L.LOAD,e)}function oe(t,e){le(t,L.LOADED,e)}function re(t,e,i){e.error=i,t.forceUpdate("surface"),le(t,L.ERROR,e)}function le(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ce,scale:he,copy:ue}=R,{ceil:fe,abs:pe}=Math;function ge(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=pe(s),a=pe(a);const{image:t,data:r}=i;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=ce(),ue(d,p),he(d,1/u,1/f),s*=u,a*=f),s*=n,a*=n,c*=s,h*=a;const _=c*h;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,c/=l,h/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=ce(),p&&ue(d,p)),he(d,1/s,1/a));const y=t.getCanvas(fe(c)||1,fe(h)||1,r.opacity,r.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=o,!0}}const{abs:_e}=Math;const we={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return ee&&i===ee.paint&&ne(n,ee.boxBounds)?a=ee.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),ee=r.use>1?{leafPaint:a,paint:i,boxBounds:ie.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(se(t,e,i,r,a,n),s&&(ae(t,o),oe(t,o))):r.error?s&&re(t,o,r.error):(s&&(de(t,!0),ae(t,o)),a.loadId=r.load((()=>{de(t,!1),t.destroyed||(se(t,e,i,r,a,n)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),oe(t,o)),a.loadId=null}),(e=>{de(t,!1),re(t,o,e),a.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:l}=n;if(!l||n.patternId===a+"-"+o+"-"+r&&!P.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||P.running)){let{width:t,height:i}=l;t*=_e(a)*r,i*=_e(o)*r,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||P.running?ge(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>tt(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ge(t,n,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:ge,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o,r;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,x.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:Kt,getPatternData:te,fillOrFitMode:Gt,clipMode:qt,repeatMode:Ht},{toPoint:ye}=A,{hasTransparent:me}=C,ve={},xe={};function be(t,e,i,n){if(i){let s,a,o,r;for(let t=0,l=i.length;t<l;t++)s=i[t],"string"==typeof s?(o=t/(l-1),a=C.string(s,n)):(o=s.offset,a=C.string(s.color,n)),e.addColorStop(o,a),!r&&me(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Be,getDistance:Re}=E,{get:Se,rotateOfOuter:ke,scaleOfOuter:Ee}=R,{toPoint:Le}=A,Ae={},Te={};function Oe(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=Be(e,i);a=Se(),s?(Ee(a,e,o/r*(n||1),1),ke(a,e,t+90)):(Ee(a,e,1,o/r*(n||1)),ke(a,e,t))}return a}const{getDistance:We}=E,{toPoint:Ce}=A,De={},Pe={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:o}=t;ye(n||"top",i,ve),ye(s||"bottom",i,xe);const r=e.canvas.createLinearGradient(ve.x,ve.y,xe.x,xe.y),l={type:a,style:r};return be(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;Le(n||"center",i,Ae),Le(s||"bottom",i,Te);const l=e.canvas.createRadialGradient(Ae.x,Ae.y,0,Ae.x,Ae.y,Re(Ae,Te)),d={type:a,style:l};be(d,l,t.stops,o);const c=Oe(i,Ae,Te,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;Ce(n||"center",i,De),Ce(s||"bottom",i,Pe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,De.x,De.y):e.canvas.createRadialGradient(De.x,De.y,0,De.x,De.y,We(De,Pe)),d={type:a,style:l};be(d,l,t.stops,o);const c=Oe(i,De,Pe,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Oe},{copy:Ie,toOffsetOutBounds:Fe}=B,Ye={},Ue={};function Ne(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Ie(Ye,t.bounds),Ye.x+=i.x-o.x,Ye.y+=i.y-o.y,n){const{matrix:t}=s;Ye.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ye.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ye.width*=n,Ye.height*=n}t.copyWorld(s.canvas,t.bounds,Ye)}else n&&(Ie(Ye,i),Ye.x-=i.width/2*(n-1),Ye.y-=i.height/2*(n-1),Ye.width*=n,Ye.height*=n),t.copyWorld(s.canvas,o,n?Ye:i)}const{toOffsetOutBounds:Xe}=B,ze={};const je={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Fe(d,Ue),r.forEach(((r,g)=>{f.setWorldShadow(Ue.offsetX+r.x*h,Ue.offsetY+r.y*u,r.blur*h,C.string(r.color)),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ne(f,Ue,s,i),n=d,r.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,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Xe(d,ze),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(ze.offsetX+r.x*h,ze.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ne(f,ze,s,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,c,d,"source-out"),n=d),f.fillWorld(n,C.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.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:Ge}=g;function qe(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),Ve(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ve(t,i,n,a);break;case"path":i.restore()}}function He(t){return t.getSameCanvas(!1,!0)}function Ve(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}M.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)i=l[d],r=i.__.mask,r&&(o&&(qe(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=He(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=He(t)),s||(s=He(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Ge(i,e)||i.__render(s||t,e);qe(this,o,t,s,n,a)};const Qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Je=Qe+"_#~&*+\\=|≮≯≈≠=…",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 $e(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ke=$e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ti=$e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ei=$e(Qe),ii=$e(Je),ni=$e("- —/~|┆·");var si;!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"}(si||(si={}));const{Letter:ai,Single:oi,Before:ri,After:li,Symbol:di,Break:ci}=si;function hi(t){return Ke[t]?ai:ni[t]?ci:ti[t]?ri:ei[t]?li:ii[t]?di:Ze.test(t)?oi:ai}const ui={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 fi(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:pi}=ui,{Letter:gi,Single:_i,Before:wi,After:yi,Symbol:mi,Break:vi}=si;let xi,bi,Bi,Ri,Si,ki,Ei,Li,Ai,Ti,Oi,Wi,Ci,Di,Pi,Mi,Ii,Fi=[];function Yi(t,e){Ai&&!Li&&(Li=Ai),xi.data.push({char:t,width:e}),Bi+=e}function Ui(){Ri+=Bi,xi.width=Bi,bi.words.push(xi),xi={data:[]},Bi=0}function Ni(){Di&&(Pi.paraNumber++,bi.paraStart=!0,Di=!1),Ai&&(bi.startCharSize=Li,bi.endCharSize=Ai,Li=0),bi.width=Ri,Mi.width?pi(bi):Ii&&Xi(),Fi.push(bi),bi={words:[]},Ri=0}function Xi(){Ri>(Pi.maxWidth||0)&&(Pi.maxWidth=Ri)}const{top:zi,right:ji,bottom:Gi,left:qi}=T;function Hi(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 Vi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(a?(n=d[qi],a-=d[ji]+d[qi]):i.autoSizeAlign||(n=d[qi]),o?(s=d[zi],o-=d[zi]+d[Gi]):i.autoSizeAlign||(s=d[zi]));const c={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,n){Pi=t,Fi=t.rows,Mi=t.bounds,Ii=!Mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:l,height:d}=Mi;if(l||d||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Di=!0,Oi=null,Li=Ei=Ai=Bi=Ri=0,xi={data:[]},bi={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)ki=i[n],"\n"===ki?(Bi&&Ui(),bi.paraEnd=!0,Ni(),Di=!0):(Ti=hi(ki),Ti===gi&&"none"!==o&&(ki=fi(ki,o,!Bi)),Ei=r.measureText(ki).width,s&&(s<0&&(Ai=Ei),Ei+=s),Wi=Ti===_i&&(Oi===_i||Oi===gi)||Oi===_i&&Ti!==yi,Ci=!(Ti!==wi&&Ti!==_i||Oi!==mi&&Oi!==yi),Si=Di&&a?l-a:l,t&&l&&Ri+Bi+Ei>Si&&(e?(Bi&&Ui(),Ri&&Ni()):(Ci||(Ci=Ti===gi&&Oi==yi),Wi||Ci||Ti===vi||Ti===wi||Ti===_i||Bi+Ei>Si?(Bi&&Ui(),Ri&&Ni()):Ri&&Ni()))," "===ki&&!0!==Di&&Ri+Bi===0||(Ti===vi?(" "===ki&&Bi&&Ui(),Yi(ki,Ei),Ui()):Wi||Ci?(Bi&&Ui(),Yi(ki,Ei)):Yi(ki,Ei)),Oi=Ti);Bi&&Ui(),Ri&&Ni(),Fi.length>0&&(Fi[Fi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Pi.paraNumber++,Ri=r.measureText(t).width,Fi.push({x:a||0,text:t,width:Ri,paraStart:!0}),Ii&&Xi()}))}(c,t,i),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Hi(e,"x",t[qi]);break;case"right":Hi(e,"x",-t[ji])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Hi(e,"y",t[zi]);break;case"bottom":Hi(e,"y",-t[Gi])}}(d,c,i,a,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,w=a*s+(h?h*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=s;o<c;o++){if(m=i[o],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&&h&&o>0&&(y+=h),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(c,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,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,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(c,i,a),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=n+s-d;("none"===i.textWrap?a:[a[o-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<c));n--){if(l<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,n,a),"none"!==r&&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=C.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]}}(c,i),c}};const Qi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!C.object)return t;t=C.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(I,Vi),Object.assign(C,Qi),Object.assign(F,It),Object.assign(W,we),Object.assign(D,Me),Object.assign(Y,je);const{setPoint:Ji,addPoint:Zi,toBounds:$i}=U;const Ki={syncExport(t,e,i){let n;this.running=!0;const s=X.fileType(e),a=e.includes(".");i=X.getExportOptions(i);const{toURL:o}=z,{download:r}=z.origin;if("json"===s)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!a||t.toJSON(i.json)};else if("svg"===s)a&&r(o(t.toSVG(),"svg"),e),n={data:!!a||t.toSVG()};else{let s,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=i,y=void 0===i.smooth?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&void 0===i.fill?t.fill:i.fill,x=X.isOpaqueImage(e)||v,b=new j;if(g)s=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};G.getScaleData(i.scale,i.size,s,B);let R=i.pixelRatio||1,{x:S,y:k,width:E,height:L}=new N(s).scale(B.scaleX,B.scaleY);f&&(S+=f.x,k+=f.y,E=f.width,L=f.height);const A={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-S,-k).withScale(1/o*B.scaleX,1/r*B.scaleY)};let T,O=q.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:R,smooth:y,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=c||t,A.bounds=O.bounds),O.save(),h&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(O,A),t.fill=e}else t.__render(O,A);if(O.restore(),T&&T.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Zi(o,s,a):Ji(o={},s,a)),r++;const l=new N;return $i(o,l),l.scale(1/t.pixelRatio).ceil()}(O);const t=O,{width:e,height:i}=a,n={x:0,y:0,width:e,height:i,pixelRatio:R};O=q.canvas(n),O.copyWorld(t,a,n)}if(_){const[t,e,i,n]=G.fourNumber(_),s=O,{width:a,height:o}=s;O=q.canvas({width:a+n+e,height:o+t+i,pixelRatio:R}),O.copyWorld(s,s.bounds,{x:n,y:t,width:a,height:o})}x&&O.fillWorld(O.bounds,v||"#FFFFFF","destination-over"),w&&w(O);n={data:"canvas"===e?O:O.export(e,i),width:O.pixelWidth,height:O.pixelHeight,renderBounds:s,trimBounds:a}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){tn||(tn=new H);return new Promise((e=>{tn.add((()=>tt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const a=()=>tt(this,void 0,void 0,(function*(){if(!V.isComplete)return z.requestRender(a);const o=Ki.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),n(o),s()}));t.updateLayout(),en(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))))}};let tn;function en(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>en(t)))}const nn=Q.prototype,sn=J.get("@leafer-in/export");nn.export=function(t,e){const{quality:i,blob:n}=X.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},nn.toBlob=function(t,e){return new Promise((i=>{z.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{sn.error(t),i(null)}))}))},nn.toDataURL=function(t,e){return z.origin.canvasToDataURL(this.view,t,e)},nn.saveAs=function(t,e){return new Promise((i=>{z.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{sn.error(t),i(!1)}))}))},Z.add("export"),Object.assign(P,Ki),$.prototype.export=function(t,e){return P.export(this,t,e)},$.prototype.syncExport=function(t,e){return P.syncExport(this,t,e)};export{_t as Layouter,et as LeaferCanvas,yt as Renderer,at as Watcher,st as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,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 v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as S,MathHelper as k,AlignHelper as R,PointHelper as E,ImageEvent as L,AroundHelper as A,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{PaintImage as C,Paint as W,ColorConvert as D,PaintGradient as P,Export as I,Group as M,TextConvert as F,Effect as U,TwoPointBoundsHelper as Y,Bounds as N,FileHelper as X,Platform as z,Matrix as j,MathHelper as G,Creator as q,TaskProcessor as H,Resource as V,LeaferCanvasBase as Q,Debug as J,Plugin as Z,UI as $}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function K(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function r(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(o,r)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class tt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__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}}const{mineType:et,fileType:it}=n;function nt(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(et(e),i),canvasToBolb:(t,e,i)=>K(this,void 0,void 0,(function*(){return t.toBuffer(et(e),i)})),canvasSaveAs:(t,e,i)=>K(this,void 0,void 0,(function*(){return O(e,t.toBuffer(et(it(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new tt(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class st{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,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===c.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 h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:at,updateBounds:ot,updateChange:rt}=f,{pushAllChildBranch:lt,pushAllParent:dt}=p;const{worldBounds:ct}=g;class ht{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ct)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ct),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:ut,updateAllChange:ft}=f,pt=w.get("Layouter");class gt{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){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.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=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,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?(at(t,!0),e.add(t),t.isBranch&<(t,e),dt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),dt(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||ot(n[t])}ot(i)}}))}(this.__levelList),function(t){t.list.forEach(rt)}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),gt.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),v.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ht([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ht(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],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const _t=w.get("Renderer");class wt{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 _,_t.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,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.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=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(wt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.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||_t.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)}}function yt(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 mt(t,e){t.__.__font?yt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function vt(t,e,i){switch(e.__.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":bt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?xt(t,2,e,i):bt(t,"outside",e,i)}}function xt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?kt(t,!0,i,n):St(i,n)}function bt(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,xt(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",yt(i,s),s.blendMode="normal",Bt(n,s,i),s.recycle(i.__nowWorld)}function Bt(t,i,n){n.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(i,n.__nowWorld):t.copyWorldToInner(i,n.__nowWorld,n.__layout.renderBounds)}function St(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 kt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&C.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?St(i,n):n.stroke(),n.restoreBlendMode()):e?St(i,n):n.stroke())}function Rt(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)vt(t,e,i);else switch(n.strokeAlign){case"center":Et(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Et(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)Et(t,2,e,i);else{const{renderBounds:s}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Et(t,2,e,a),a.clipUI(n),a.clearWorld(s),Bt(i,a,e),a.recycle(e.__nowWorld)}}(t,e,i)}}function Et(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?kt(t,!1,i,n):n.stroke(),s.__useArrow&&W.strokeArrow(t,i,n)}wt.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new st(t,e),layouter:(t,e)=>new gt(t,e),renderer:(t,e,i)=>new wt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=gt.fullLayout;const{getSpread:Lt,getOuterOf:At,getByMove:Tt,getIntersectData:Ot}=B;let Ct;const{stintSet:Wt}=l,{hasTransparent:Dt}=D;function Pt(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=C.image(i,t,e,s,!Ct||!Ct[e.url]);break;case"linear":n=P.linearGradient(e,s);break;case"radial":n=P.radialGradient(e,s);break;case"angular":n=P.conicGradient(e,s);break;case"solid":const{type:a,color:o,opacity:r}=e;n={type:a,style:D.string(o,r)};break;default:void 0!==e.r&&(n={type:"solid",style:D.string(e)})}return n&&("string"==typeof n.style&&Dt(n.style)&&(n.isTransparent=!0),e.blendMode&&(n.blendMode=e.blendMode)),n}const It={compute:function(t,e){const i=e.__,n=[];let s,a,o=i.__input[t];o instanceof Array||(o=[o]),Ct=C.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)(i=Pt(t,o[s],e))&&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?(Wt(i,"__isAlphaPixelFill",s),Wt(i,"__isTransparentFill",a)):(Wt(i,"__isAlphaPixelStroke",s),Wt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,mt(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(C.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),mt(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),mt(e,i),i.restoreBlendMode()):mt(e,i)}},fillPathOrText:mt,fillText:yt,stroke:Rt,strokes:function(t,e,i){Rt(t,e,i)},strokeText:vt,drawTextStroke:St,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,h=Ot(n?Lt(e.bounds,d===c?n*d:[n*c,n*d]):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,c*=f),r=At(s,o),a=Tt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let Mt={};const{get:Ft,rotateOfOuter:Ut,translate:Yt,scaleOfOuter:Nt,scale:Xt,rotate:zt}=S;function jt(t,e,i,n,s,a,o){const r=Ft();Yt(r,e.x+i,e.y+n),Xt(r,s,a),o&&Ut(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Gt(t,e,i,n,s,a,o){const r=Ft();Yt(r,e.x+i,e.y+n),s&&Xt(r,s,a),o&&zt(r,o),t.transform=r}function qt(t,e,i,n,s,a,o,r,l,d){const c=Ft();if(l)if("center"===d)Ut(c,{x:i/2,y:n/2},l);else switch(zt(c,l),l){case 90:Yt(c,n,0);break;case 180:Yt(c,i,n);break;case 270:Yt(c,0,i)}Mt.x=e.x+s,Mt.y=e.y+a,Yt(c,Mt.x,Mt.y),o&&Nt(c,Mt,o,r),t.transform=c}const{get:Ht,translate:Vt}=S,Qt=new _,Jt={},Zt={};function $t(t,e,i,n){const{changeful:s,sync:a}=i;s&&(t.changeful=s),a&&(t.sync=a),t.data=Kt(i,n,e)}function Kt(t,e,i){t.padding&&(e=Qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:s}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(h||0)%180==90;let w,y;switch(B.set(Zt,0,0,_?s:n,_?n:s),o&&"cover"!==o&&"fit"!==o?((d||c)&&(k.getScaleData(d,c,i,Jt),w=Jt.scaleX,y=Jt.scaleY),r&&(w&&B.scale(Zt,w,y,!0),R.toPoint(r,Zt,e,Zt,!0,!0))):p&&!h||(w=y=B.getFitScale(e,Zt,"fit"!==o),B.put(e,i,r,w,!1,Zt),B.scale(Zt,w,y,!0)),l&&E.move(Zt,l),o){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(Zt.x||Zt.y||w||h)&&Gt(g,e,Zt.x,Zt.y,w,y,h);break;case"repeat":(!p||w||h)&&qt(g,e,n,s,Zt.x,Zt.y,w,y,h,r),u||(g.repeat="repeat");break;default:w&&jt(g,e,Zt.x,Zt.y,w,y,h)}return g.transform||(e.x||e.y)&&(g.transform=Ht(),Vt(g.transform,e.x,e.y)),w&&"stretch"!==o&&(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 te,ee=new _;const{isSame:ie}=B;function ne(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||$t(s,n,i,a),!0}function se(t,e){re(t,L.LOAD,e)}function ae(t,e){re(t,L.LOADED,e)}function oe(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,L.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function le(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:de,scale:ce,copy:he}=S,{ceil:ue,abs:fe}=Math;function pe(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=fe(s),a=fe(a);const{image:t,data:r}=i;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=de(),he(d,p),ce(d,1/u,1/f),s*=u,a*=f),s*=n,a*=n,c*=s,h*=a;const _=c*h;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,c/=l,h/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=de(),p&&he(d,p)),ce(d,1/s,1/a));const y=t.getCanvas(ue(c)||1,ue(h)||1,r.opacity,r.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=o,!0}}const{abs:ge}=Math;const _e={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return te&&i===te.paint&&ie(n,te.boxBounds)?a=te.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),te=r.use>1?{leafPaint:a,paint:i,boxBounds:ee.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ne(t,e,i,r,a,n),s&&(se(t,o),ae(t,o))):r.error?s&&oe(t,o,r.error):(s&&(le(t,!0),se(t,o)),a.loadId=r.load((()=>{le(t,!1),t.destroyed||(ne(t,e,i,r,a,n)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,o)),a.loadId=null}),(e=>{le(t,!1),oe(t,o,e),a.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:l}=n;if(!l||n.patternId===a+"-"+o+"-"+r&&!I.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||I.running)){let{width:t,height:i}=l;t*=ge(a)*r,i*=ge(o)*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),e.clipUI(t),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||I.running?pe(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>K(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&pe(t,n,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:pe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o,r;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,x.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:$t,getPatternData:Kt,fillOrFitMode:jt,clipMode:Gt,repeatMode:qt},{toPoint:we}=A,{hasTransparent:ye}=D,me={},ve={};function xe(t,e,i,n){if(i){let s,a,o,r;for(let t=0,l=i.length;t<l;t++)s=i[t],"string"==typeof s?(o=t/(l-1),a=D.string(s,n)):(o=s.offset,a=D.string(s.color,n)),e.addColorStop(o,a),!r&&ye(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:be,getDistance:Be}=E,{get:Se,rotateOfOuter:ke,scaleOfOuter:Re}=S,{toPoint:Ee}=A,Le={},Ae={};function Te(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=be(e,i);a=Se(),s?(Re(a,e,o/r*(n||1),1),ke(a,e,t+90)):(Re(a,e,1,o/r*(n||1)),ke(a,e,t))}return a}const{getDistance:Oe}=E,{toPoint:Ce}=A,We={},De={};const Pe={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:o}=t;we(n||"top",i,me),we(s||"bottom",i,ve);const r=e.canvas.createLinearGradient(me.x,me.y,ve.x,ve.y),l={type:a,style:r};return xe(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;Ee(n||"center",i,Le),Ee(s||"bottom",i,Ae);const l=e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,Be(Le,Ae)),d={type:a,style:l};xe(d,l,t.stops,o);const c=Te(i,Le,Ae,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;Ce(n||"center",i,We),Ce(s||"bottom",i,De);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,We.x,We.y):e.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Oe(We,De)),d={type:a,style:l};xe(d,l,t.stops,o);const c=Te(i,We,De,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Te},{copy:Ie,toOffsetOutBounds:Me}=B,Fe={},Ue={};function Ye(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Ie(Fe,t.bounds),Fe.x+=i.x-o.x,Fe.y+=i.y-o.y,n){const{matrix:t}=s;Fe.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Fe.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Fe.width*=n,Fe.height*=n}t.copyWorld(s.canvas,t.bounds,Fe)}else n&&(Ie(Fe,i),Fe.x-=i.width/2*(n-1),Fe.y-=i.height/2*(n-1),Fe.width*=n,Fe.height*=n),t.copyWorld(s.canvas,o,n?Fe:i)}const{toOffsetOutBounds:Ne}=B,Xe={};const ze={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Me(d,Ue),r.forEach(((r,g)=>{f.setWorldShadow(Ue.offsetX+r.x*h,Ue.offsetY+r.y*u,r.blur*h,D.string(r.color)),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Ue,s,i),n=d,r.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,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ne(d,Xe),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Xe.offsetX+r.x*h,Xe.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Xe,s,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,c,d,"source-out"),n=d),f.fillWorld(n,D.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.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:je}=g;function Ge(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),He(t,e,i,1)}(t,i,n,s);break;case"opacity-path":He(t,i,n,a);break;case"path":i.restore()}}function qe(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}M.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)i=l[d],r=i.__.mask,r&&(o&&(Ge(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=qe(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=qe(t)),s||(s=qe(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||je(i,e)||i.__render(s||t,e);Ge(this,o,t,s,n,a)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=Ve+"_#~&*+\\=|≮≯≈≠=…",Je=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 Ze(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $e=Ze("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=Ze("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=Ze(Ve),ei=Ze(Qe),ii=Ze("- —/~|┆·");var ni;!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"}(ni||(ni={}));const{Letter:si,Single:ai,Before:oi,After:ri,Symbol:li,Break:di}=ni;function ci(t){return $e[t]?si:ii[t]?di:Ke[t]?oi:ti[t]?ri:ei[t]?li:Je.test(t)?ai:si}const hi={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 ui(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:fi}=hi,{Letter:pi,Single:gi,Before:_i,After:wi,Symbol:yi,Break:mi}=ni;let vi,xi,bi,Bi,Si,ki,Ri,Ei,Li,Ai,Ti,Oi,Ci,Wi,Di,Pi,Ii,Mi=[];function Fi(t,e){Li&&!Ei&&(Ei=Li),vi.data.push({char:t,width:e}),bi+=e}function Ui(){Bi+=bi,vi.width=bi,xi.words.push(vi),vi={data:[]},bi=0}function Yi(){Wi&&(Di.paraNumber++,xi.paraStart=!0,Wi=!1),Li&&(xi.startCharSize=Ei,xi.endCharSize=Li,Ei=0),xi.width=Bi,Pi.width?fi(xi):Ii&&Ni(),Mi.push(xi),xi={words:[]},Bi=0}function Ni(){Bi>(Di.maxWidth||0)&&(Di.maxWidth=Bi)}const{top:Xi,right:zi,bottom:ji,left:Gi}=T;function qi(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 Hi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(a?(n=d[Gi],a-=d[zi]+d[Gi]):i.autoSizeAlign||(n=d[Gi]),o?(s=d[Xi],o-=d[Xi]+d[ji]):i.autoSizeAlign||(s=d[Xi]));const c={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,n){Di=t,Mi=t.rows,Pi=t.bounds,Ii=!Pi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:l,height:d}=Pi;if(l||d||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Wi=!0,Ti=null,Ei=Ri=Li=bi=Bi=0,vi={data:[]},xi={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)ki=i[n],"\n"===ki?(bi&&Ui(),xi.paraEnd=!0,Yi(),Wi=!0):(Ai=ci(ki),Ai===pi&&"none"!==o&&(ki=ui(ki,o,!bi)),Ri=r.measureText(ki).width,s&&(s<0&&(Li=Ri),Ri+=s),Oi=Ai===gi&&(Ti===gi||Ti===pi)||Ti===gi&&Ai!==wi,Ci=!(Ai!==_i&&Ai!==gi||Ti!==yi&&Ti!==wi),Si=Wi&&a?l-a:l,t&&l&&Bi+bi+Ri>Si&&(e?(bi&&Ui(),Bi&&Yi()):(Ci||(Ci=Ai===pi&&Ti==wi),Oi||Ci||Ai===mi||Ai===_i||Ai===gi||bi+Ri>Si?(bi&&Ui(),Bi&&Yi()):Bi&&Yi()))," "===ki&&!0!==Wi&&Bi+bi===0||(Ai===mi?(" "===ki&&bi&&Ui(),Fi(ki,Ri),Ui()):Oi||Ci?(bi&&Ui(),Fi(ki,Ri)):Fi(ki,Ri)),Ti=Ai);bi&&Ui(),Bi&&Yi(),Mi.length>0&&(Mi[Mi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Di.paraNumber++,Bi=r.measureText(t).width,Mi.push({x:a||0,text:t,width:Bi,paraStart:!0}),Ii&&Ni()}))}(c,t,i),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":qi(e,"x",t[Gi]);break;case"right":qi(e,"x",-t[zi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":qi(e,"y",t[Xi]);break;case"bottom":qi(e,"y",-t[ji])}}(d,c,i,a,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,w=a*s+(h?h*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=s;o<c;o++){if(m=i[o],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&&h&&o>0&&(y+=h),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(c,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,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,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(c,i,a),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=n+s-d;("none"===i.textWrap?a:[a[o-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<c));n--){if(l<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,n,a),"none"!==r&&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]}}(c,i),c}};const Vi={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(F,Hi),Object.assign(D,Vi),Object.assign(W,It),Object.assign(C,_e),Object.assign(P,Pe),Object.assign(U,ze);const{setPoint:Qi,addPoint:Ji,toBounds:Zi}=Y;const $i={syncExport(t,e,i){let n;this.running=!0;const s=X.fileType(e),a=e.includes(".");i=X.getExportOptions(i);const{toURL:o}=z,{download:r}=z.origin;if("json"===s)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!a||t.toJSON(i.json)};else if("svg"===s)a&&r(o(t.toSVG(),"svg"),e),n={data:!!a||t.toSVG()};else{let s,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=i,y=void 0===i.smooth?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&void 0===i.fill?t.fill:i.fill,x=X.isOpaqueImage(e)||v,b=new j;if(g)s=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};G.getScaleData(i.scale,i.size,s,B);let S=i.pixelRatio||1,{x:k,y:R,width:E,height:L}=new N(s).scale(B.scaleX,B.scaleY);f&&(k+=f.x,R+=f.y,E=f.width,L=f.height);const A={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-k,-R).withScale(1/o*B.scaleX,1/r*B.scaleY)};let T,O=q.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:S,smooth:y,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=c||t,A.bounds=O.bounds),O.save(),h&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(O,A),t.fill=e}else t.__render(O,A);if(O.restore(),T&&T.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Ji(o,s,a):Qi(o={},s,a)),r++;const l=new N;return Zi(o,l),l.scale(1/t.pixelRatio).ceil()}(O);const t=O,{width:e,height:i}=a,n={x:0,y:0,width:e,height:i,pixelRatio:S};O=q.canvas(n),O.copyWorld(t,a,n)}if(_){const[t,e,i,n]=G.fourNumber(_),s=O,{width:a,height:o}=s;O=q.canvas({width:a+n+e,height:o+t+i,pixelRatio:S}),O.copyWorld(s,s.bounds,{x:n,y:t,width:a,height:o})}x&&O.fillWorld(O.bounds,v||"#FFFFFF","destination-over"),w&&w(O);n={data:"canvas"===e?O:O.export(e,i),width:O.pixelWidth,height:O.pixelHeight,renderBounds:s,trimBounds:a}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){Ki||(Ki=new H);return new Promise((e=>{Ki.add((()=>K(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const a=()=>K(this,void 0,void 0,(function*(){if(!V.isComplete)return z.requestRender(a);const o=$i.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),n(o),s()}));t.updateLayout(),tn(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))))}};let Ki;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=Q.prototype,nn=J.get("@leafer-in/export");en.export=function(t,e){const{quality:i,blob:n}=X.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},en.toBlob=function(t,e){return new Promise((i=>{z.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(t,e){return z.origin.canvasToDataURL(this.view,t,e)},en.saveAs=function(t,e){return new Promise((i=>{z.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},Z.add("export"),Object.assign(I,$i),$.prototype.export=function(t,e){return I.export(this,t,e)},$.prototype.syncExport=function(t,e){return I.syncExport(this,t,e)};export{gt as Layouter,tt as LeaferCanvas,wt as Renderer,st as Watcher,nt as useCanvas};
|
|
2
2
|
//# sourceMappingURL=node.esm.min.js.map
|