@leafer-draw/miniapp 1.0.3 → 1.0.5
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/miniapp.cjs +32 -24
- package/dist/miniapp.esm.js +32 -24
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +77 -62
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +10 -10
- package/src/index.ts +2 -0
- package/types/index.d.ts +1 -0
package/dist/miniapp.cjs
CHANGED
|
@@ -607,6 +607,7 @@ class Renderer {
|
|
|
607
607
|
this.totalBounds = new core.Bounds();
|
|
608
608
|
debug$1.log(target.innerName, '--->');
|
|
609
609
|
try {
|
|
610
|
+
target.app.emit(core.RenderEvent.CHILD_START, target);
|
|
610
611
|
this.emitRender(core.RenderEvent.START);
|
|
611
612
|
this.renderOnce(callback);
|
|
612
613
|
this.emitRender(core.RenderEvent.END, this.totalBounds);
|
|
@@ -1270,9 +1271,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1270
1271
|
onLoadError(ui, event, image.error);
|
|
1271
1272
|
}
|
|
1272
1273
|
else {
|
|
1273
|
-
|
|
1274
|
-
|
|
1274
|
+
if (firstUse) {
|
|
1275
|
+
ignoreRender(ui, true);
|
|
1275
1276
|
onLoad(ui, event);
|
|
1277
|
+
}
|
|
1276
1278
|
leafPaint.loadId = image.load(() => {
|
|
1277
1279
|
ignoreRender(ui, false);
|
|
1278
1280
|
if (!ui.destroyed) {
|
|
@@ -1916,11 +1918,12 @@ const { trimRight } = TextRowHelper;
|
|
|
1916
1918
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
1917
1919
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
1918
1920
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
1919
|
-
let textDrawData, rows = [], bounds;
|
|
1921
|
+
let textDrawData, rows = [], bounds, findMaxWidth;
|
|
1920
1922
|
function createRows(drawData, content, style) {
|
|
1921
1923
|
textDrawData = drawData;
|
|
1922
1924
|
rows = drawData.rows;
|
|
1923
1925
|
bounds = drawData.bounds;
|
|
1926
|
+
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
1924
1927
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
1925
1928
|
const { canvas } = core.Platform;
|
|
1926
1929
|
const { width, height } = bounds;
|
|
@@ -2005,7 +2008,10 @@ function createRows(drawData, content, style) {
|
|
|
2005
2008
|
else {
|
|
2006
2009
|
content.split('\n').forEach(content => {
|
|
2007
2010
|
textDrawData.paraNumber++;
|
|
2008
|
-
|
|
2011
|
+
rowWidth = canvas.measureText(content).width;
|
|
2012
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
2013
|
+
if (findMaxWidth)
|
|
2014
|
+
setMaxWidth();
|
|
2009
2015
|
});
|
|
2010
2016
|
}
|
|
2011
2017
|
}
|
|
@@ -2036,10 +2042,16 @@ function addRow() {
|
|
|
2036
2042
|
row.width = rowWidth;
|
|
2037
2043
|
if (bounds.width)
|
|
2038
2044
|
trimRight(row);
|
|
2045
|
+
else if (findMaxWidth)
|
|
2046
|
+
setMaxWidth();
|
|
2039
2047
|
rows.push(row);
|
|
2040
2048
|
row = { words: [] };
|
|
2041
2049
|
rowWidth = 0;
|
|
2042
2050
|
}
|
|
2051
|
+
function setMaxWidth() {
|
|
2052
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
2053
|
+
textDrawData.maxWidth = rowWidth;
|
|
2054
|
+
}
|
|
2043
2055
|
|
|
2044
2056
|
const CharMode = 0;
|
|
2045
2057
|
const WordMode = 1;
|
|
@@ -2111,34 +2123,32 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
2111
2123
|
|
|
2112
2124
|
function layoutText(drawData, style) {
|
|
2113
2125
|
const { rows, bounds } = drawData;
|
|
2114
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
2126
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
2115
2127
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
2116
2128
|
let starY = __baseLine;
|
|
2117
2129
|
if (__clipText && realHeight > height) {
|
|
2118
2130
|
realHeight = Math.max(height, __lineHeight);
|
|
2119
2131
|
drawData.overflow = rows.length;
|
|
2120
2132
|
}
|
|
2121
|
-
else {
|
|
2133
|
+
else if (height || autoSizeAlign) {
|
|
2122
2134
|
switch (verticalAlign) {
|
|
2123
2135
|
case 'middle':
|
|
2124
2136
|
y += (height - realHeight) / 2;
|
|
2125
2137
|
break;
|
|
2126
|
-
case 'bottom':
|
|
2127
|
-
y += (height - realHeight);
|
|
2138
|
+
case 'bottom': y += (height - realHeight);
|
|
2128
2139
|
}
|
|
2129
2140
|
}
|
|
2130
2141
|
starY += y;
|
|
2131
|
-
let row, rowX, rowWidth;
|
|
2142
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
2132
2143
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
2133
2144
|
row = rows[i];
|
|
2134
2145
|
row.x = x;
|
|
2135
2146
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
2136
2147
|
switch (textAlign) {
|
|
2137
2148
|
case 'center':
|
|
2138
|
-
row.x += (
|
|
2149
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
2139
2150
|
break;
|
|
2140
|
-
case 'right':
|
|
2141
|
-
row.x += width - row.width;
|
|
2151
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
2142
2152
|
}
|
|
2143
2153
|
}
|
|
2144
2154
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -2243,14 +2253,14 @@ function getDrawData(content, style) {
|
|
|
2243
2253
|
let height = style.__getInput('height') || 0;
|
|
2244
2254
|
const { textDecoration, __font, __padding: padding } = style;
|
|
2245
2255
|
if (padding) {
|
|
2246
|
-
if (width)
|
|
2256
|
+
if (width)
|
|
2257
|
+
x = padding[left], width -= (padding[right] + padding[left]);
|
|
2258
|
+
else if (!style.autoSizeAlign)
|
|
2247
2259
|
x = padding[left];
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
if (
|
|
2260
|
+
if (height)
|
|
2261
|
+
y = padding[top], height -= (padding[top] + padding[bottom]);
|
|
2262
|
+
else if (!style.autoSizeAlign)
|
|
2251
2263
|
y = padding[top];
|
|
2252
|
-
height -= (padding[top] + padding[bottom]);
|
|
2253
|
-
}
|
|
2254
2264
|
}
|
|
2255
2265
|
const drawData = {
|
|
2256
2266
|
bounds: { x, y, width, height },
|
|
@@ -2270,22 +2280,20 @@ function getDrawData(content, style) {
|
|
|
2270
2280
|
return drawData;
|
|
2271
2281
|
}
|
|
2272
2282
|
function padAutoText(padding, drawData, style, width, height) {
|
|
2273
|
-
if (!width) {
|
|
2283
|
+
if (!width && style.autoSizeAlign) {
|
|
2274
2284
|
switch (style.textAlign) {
|
|
2275
2285
|
case 'left':
|
|
2276
2286
|
offsetText(drawData, 'x', padding[left]);
|
|
2277
2287
|
break;
|
|
2278
|
-
case 'right':
|
|
2279
|
-
offsetText(drawData, 'x', -padding[right]);
|
|
2288
|
+
case 'right': offsetText(drawData, 'x', -padding[right]);
|
|
2280
2289
|
}
|
|
2281
2290
|
}
|
|
2282
|
-
if (!height) {
|
|
2291
|
+
if (!height && style.autoSizeAlign) {
|
|
2283
2292
|
switch (style.verticalAlign) {
|
|
2284
2293
|
case 'top':
|
|
2285
2294
|
offsetText(drawData, 'y', padding[top]);
|
|
2286
2295
|
break;
|
|
2287
|
-
case 'bottom':
|
|
2288
|
-
offsetText(drawData, 'y', -padding[bottom]);
|
|
2296
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
|
|
2289
2297
|
}
|
|
2290
2298
|
}
|
|
2291
2299
|
}
|
package/dist/miniapp.esm.js
CHANGED
|
@@ -608,6 +608,7 @@ class Renderer {
|
|
|
608
608
|
this.totalBounds = new Bounds();
|
|
609
609
|
debug$1.log(target.innerName, '--->');
|
|
610
610
|
try {
|
|
611
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
611
612
|
this.emitRender(RenderEvent.START);
|
|
612
613
|
this.renderOnce(callback);
|
|
613
614
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -1271,9 +1272,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1271
1272
|
onLoadError(ui, event, image.error);
|
|
1272
1273
|
}
|
|
1273
1274
|
else {
|
|
1274
|
-
|
|
1275
|
-
|
|
1275
|
+
if (firstUse) {
|
|
1276
|
+
ignoreRender(ui, true);
|
|
1276
1277
|
onLoad(ui, event);
|
|
1278
|
+
}
|
|
1277
1279
|
leafPaint.loadId = image.load(() => {
|
|
1278
1280
|
ignoreRender(ui, false);
|
|
1279
1281
|
if (!ui.destroyed) {
|
|
@@ -1917,11 +1919,12 @@ const { trimRight } = TextRowHelper;
|
|
|
1917
1919
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
1918
1920
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
1919
1921
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
1920
|
-
let textDrawData, rows = [], bounds;
|
|
1922
|
+
let textDrawData, rows = [], bounds, findMaxWidth;
|
|
1921
1923
|
function createRows(drawData, content, style) {
|
|
1922
1924
|
textDrawData = drawData;
|
|
1923
1925
|
rows = drawData.rows;
|
|
1924
1926
|
bounds = drawData.bounds;
|
|
1927
|
+
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
1925
1928
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
1926
1929
|
const { canvas } = Platform;
|
|
1927
1930
|
const { width, height } = bounds;
|
|
@@ -2006,7 +2009,10 @@ function createRows(drawData, content, style) {
|
|
|
2006
2009
|
else {
|
|
2007
2010
|
content.split('\n').forEach(content => {
|
|
2008
2011
|
textDrawData.paraNumber++;
|
|
2009
|
-
|
|
2012
|
+
rowWidth = canvas.measureText(content).width;
|
|
2013
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
2014
|
+
if (findMaxWidth)
|
|
2015
|
+
setMaxWidth();
|
|
2010
2016
|
});
|
|
2011
2017
|
}
|
|
2012
2018
|
}
|
|
@@ -2037,10 +2043,16 @@ function addRow() {
|
|
|
2037
2043
|
row.width = rowWidth;
|
|
2038
2044
|
if (bounds.width)
|
|
2039
2045
|
trimRight(row);
|
|
2046
|
+
else if (findMaxWidth)
|
|
2047
|
+
setMaxWidth();
|
|
2040
2048
|
rows.push(row);
|
|
2041
2049
|
row = { words: [] };
|
|
2042
2050
|
rowWidth = 0;
|
|
2043
2051
|
}
|
|
2052
|
+
function setMaxWidth() {
|
|
2053
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
2054
|
+
textDrawData.maxWidth = rowWidth;
|
|
2055
|
+
}
|
|
2044
2056
|
|
|
2045
2057
|
const CharMode = 0;
|
|
2046
2058
|
const WordMode = 1;
|
|
@@ -2112,34 +2124,32 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
2112
2124
|
|
|
2113
2125
|
function layoutText(drawData, style) {
|
|
2114
2126
|
const { rows, bounds } = drawData;
|
|
2115
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
2127
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
2116
2128
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
2117
2129
|
let starY = __baseLine;
|
|
2118
2130
|
if (__clipText && realHeight > height) {
|
|
2119
2131
|
realHeight = Math.max(height, __lineHeight);
|
|
2120
2132
|
drawData.overflow = rows.length;
|
|
2121
2133
|
}
|
|
2122
|
-
else {
|
|
2134
|
+
else if (height || autoSizeAlign) {
|
|
2123
2135
|
switch (verticalAlign) {
|
|
2124
2136
|
case 'middle':
|
|
2125
2137
|
y += (height - realHeight) / 2;
|
|
2126
2138
|
break;
|
|
2127
|
-
case 'bottom':
|
|
2128
|
-
y += (height - realHeight);
|
|
2139
|
+
case 'bottom': y += (height - realHeight);
|
|
2129
2140
|
}
|
|
2130
2141
|
}
|
|
2131
2142
|
starY += y;
|
|
2132
|
-
let row, rowX, rowWidth;
|
|
2143
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
2133
2144
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
2134
2145
|
row = rows[i];
|
|
2135
2146
|
row.x = x;
|
|
2136
2147
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
2137
2148
|
switch (textAlign) {
|
|
2138
2149
|
case 'center':
|
|
2139
|
-
row.x += (
|
|
2150
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
2140
2151
|
break;
|
|
2141
|
-
case 'right':
|
|
2142
|
-
row.x += width - row.width;
|
|
2152
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
2143
2153
|
}
|
|
2144
2154
|
}
|
|
2145
2155
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -2244,14 +2254,14 @@ function getDrawData(content, style) {
|
|
|
2244
2254
|
let height = style.__getInput('height') || 0;
|
|
2245
2255
|
const { textDecoration, __font, __padding: padding } = style;
|
|
2246
2256
|
if (padding) {
|
|
2247
|
-
if (width)
|
|
2257
|
+
if (width)
|
|
2258
|
+
x = padding[left], width -= (padding[right] + padding[left]);
|
|
2259
|
+
else if (!style.autoSizeAlign)
|
|
2248
2260
|
x = padding[left];
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
if (
|
|
2261
|
+
if (height)
|
|
2262
|
+
y = padding[top], height -= (padding[top] + padding[bottom]);
|
|
2263
|
+
else if (!style.autoSizeAlign)
|
|
2252
2264
|
y = padding[top];
|
|
2253
|
-
height -= (padding[top] + padding[bottom]);
|
|
2254
|
-
}
|
|
2255
2265
|
}
|
|
2256
2266
|
const drawData = {
|
|
2257
2267
|
bounds: { x, y, width, height },
|
|
@@ -2271,22 +2281,20 @@ function getDrawData(content, style) {
|
|
|
2271
2281
|
return drawData;
|
|
2272
2282
|
}
|
|
2273
2283
|
function padAutoText(padding, drawData, style, width, height) {
|
|
2274
|
-
if (!width) {
|
|
2284
|
+
if (!width && style.autoSizeAlign) {
|
|
2275
2285
|
switch (style.textAlign) {
|
|
2276
2286
|
case 'left':
|
|
2277
2287
|
offsetText(drawData, 'x', padding[left]);
|
|
2278
2288
|
break;
|
|
2279
|
-
case 'right':
|
|
2280
|
-
offsetText(drawData, 'x', -padding[right]);
|
|
2289
|
+
case 'right': offsetText(drawData, 'x', -padding[right]);
|
|
2281
2290
|
}
|
|
2282
2291
|
}
|
|
2283
|
-
if (!height) {
|
|
2292
|
+
if (!height && style.autoSizeAlign) {
|
|
2284
2293
|
switch (style.verticalAlign) {
|
|
2285
2294
|
case 'top':
|
|
2286
2295
|
offsetText(drawData, 'y', padding[top]);
|
|
2287
2296
|
break;
|
|
2288
|
-
case 'bottom':
|
|
2289
|
-
offsetText(drawData, 'y', -padding[bottom]);
|
|
2297
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
|
|
2290
2298
|
}
|
|
2291
2299
|
}
|
|
2292
2300
|
}
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as d,FileHelper as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as S,MathHelper as k,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as T,TwoPointBoundsHelper as O,TaskProcessor as C,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as z,Group as F,TextConvert as Y,Paint as U,Effect as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:s,pixelRatio:o}=this.config,a={width:n||t.width,height:s||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),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)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:N,fileType:G}=l;function j(t,i){e.origin={createCanvas:(t,e,n)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(N(G(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new X(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},d(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,this.target=t,e&&(this.config=n.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(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:H,updateBounds:Q,updateAllWorldOpacity:J}=g,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:K}=m,tt={x:0,y:0,width:1e5,height:1e5};class et{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(tt):this.afterBounds.setListWithFn(t,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:it,updateAllChange:nt}=g,st=y.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new x(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?(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)))}))}(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){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&J(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),ot.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(n,o,this.times)),e.emitEvent(new x(s,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){it(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new et([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new et(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=y.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=n.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,at.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),B.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 w,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new w(n);i.save(),s&&!y.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(n),y.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(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 w(0,0,1,1)),this.changed=!0}}__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 h(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(h.AGAIN,this.renderAgain,this),t.on_(o.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 dt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function lt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ut(t,!0,e,i):ht(e,i);break;case"inside":ct("inside",t,s,e,i);break;case"outside":ct("outside",t,s,e,i)}}function ct(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ut(e,!0,n,r):ht(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",dt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ht(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ut(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ht(i,n):n.stroke(),n.restoreBlendMode()):e?ht(i,n):n.stroke())}Object.assign(a,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=ot.fullLayout;const{getSpread:ft,getOuterOf:pt,getByMove:gt,getIntersectData:_t}=R;let wt;function mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return P.image(i,t,e,n,!wt||!wt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const yt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),wt=P.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[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?dt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&P.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?dt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?dt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?dt(e,i):s?i.fill(s):i.fill())},fillText:dt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)lt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)lt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ut(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ut(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ut(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:lt,drawTextStroke:ht,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=_t(n?ft(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=pt(s,a),o=gt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:St,rotate:kt}=S;function Et(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),St(r,s,o),a&&bt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Lt(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),s&&St(r,s,o),a&&kt(r,a),t.transform=r}function At(t,e,i,n,s,o,a,r,d,l){const c=xt();if(d)if("center"===l)bt(c,{x:i/2,y:n/2},d);else switch(kt(c,d),d){case 90:Bt(c,n,0);break;case 180:Bt(c,i,n);break;case 270:Bt(c,0,i)}vt.x=e.x+s,vt.y=e.y+o,Bt(c,vt.x,vt.y),a&&Rt(c,vt,a,r),t.transform=c}const{get:Wt,translate:Tt}=S,Ot=new w,Ct={},Mt={};function Pt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Dt(i,n,e)}function Dt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ot.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,i,Mt),m=Mt.scaleX,y=Mt.scaleY);else if(!f||h){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,x+=(e.height-s*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),E.toPoint(r,t,e,Ct,!0),v+=Ct.x,x+=Ct.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||m||h)&&Lt(p,e,v,x,m,y,h);break;case"repeat":(!f||m||h)&&At(p,e,n,s,v,x,m,y,h,r),u||(p.repeat="repeat");break;default:m&&Et(p,e,v,x,m,y,h)}return p.transform||(e.x||e.y)&&(p.transform=Wt(),Tt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=y),p.width=n,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let It,zt=new w;const{isSame:Ft}=R;function Yt(t,e,i,n,s,o){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||Pt(s,n,i,o),!0}function Ut(t,e){Nt(t,L.LOAD,e)}function Vt(t,e){Nt(t,L.LOADED,e)}function Xt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,L.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Gt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Ht}=S,{ceil:Qt,abs:Jt}=Math;function Zt(t,i,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=Jt(s),o=Jt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=jt(),Ht(l,g),qt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=jt(),g&&Ht(l,g)),qt(l,1/s,1/o));const y=t.getCanvas(Qt(c)||1,Qt(h)||1,p),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function $t(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Kt}=Math;const te={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return It&&i===It.paint&&Ft(n,It.boxBounds)?o=It.leafPaint:(o={type:i.type,image:r},It=r.use>1?{leafPaint:o,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Yt(t,e,i,r,o,n),s&&(Ut(t,a),Vt(t,a))):r.error?s&&Xt(t,a,r.error):(Gt(t,!0),s&&Ut(t,a),o.loadId=r.load((()=>{Gt(t,!1),t.destroyed||(Yt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Vt(t,a)),o.loadId=null}),(e=>{Gt(t,!1),Xt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!z.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=Kt(o)*r,i*=Kt(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||z.running}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||z.running?Zt(t,n,r):n.patternTask||(n.patternTask=B.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Zt(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Zt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,B.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Pt,getPatternData:Dt,fillOrFitMode:Et,clipMode:Lt,repeatMode:At},{toPoint:ee}=A,ie={},ne={};function se(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:oe,getDistance:ae}=W,{get:re,rotateOfOuter:de,scaleOfOuter:le}=S,{toPoint:ce}=A,he={},ue={};function fe(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=oe(e,i);o=re(),s?(le(o,e,a/r*(n||1),1),de(o,e,t+90)):(le(o,e,1,a/r*(n||1)),de(o,e,t))}return o}const{getDistance:pe}=W,{toPoint:ge}=A,_e={},we={};const me={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ee(n||"top",i,ie),ee(s||"bottom",i,ne);const d=e.canvas.createLinearGradient(ie.x,ie.y,ne.x,ne.y);se(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ce(n||"center",i,he),ce(s||"bottom",i,ue);const l=e.canvas.createRadialGradient(he.x,he.y,0,he.x,he.y,ae(he,ue));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,he,ue,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ge(n||"center",i,_e),ge(s||"bottom",i,we);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,_e.x,_e.y):e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,pe(_e,we));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,_e,we,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:fe},{copy:ye,toOffsetOutBounds:ve}=R,xe={},be={};function Be(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ye(xe,t.bounds),xe.x+=i.x-a.x,xe.y+=i.y-a.y,n){const{matrix:t}=s;xe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),xe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),xe.width*=n,xe.height*=n}t.copyWorld(s.canvas,t.bounds,xe)}else n&&(ye(xe,i),xe.x-=i.width/2*(n-1),xe.y-=i.height/2*(n-1),xe.width*=n,xe.height*=n),t.copyWorld(s.canvas,a,n?xe:i)}const{toOffsetOutBounds:Re}=R,Se={};const ke={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ve(l,be),r.forEach(((r,g)=>{f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,be,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Re(l,Se),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Se.offsetX+r.x*h,Se.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,Se,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.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:Ee}=m;function Le(t,e,i,n,s,o){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),We(t,e,i,1)}(t,i,n,s);break;case"opacity-path":We(t,i,n,o);break;case"path":i.restore()}}function Ae(t){return t.getSameCanvas(!1,!0)}function We(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Le(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ae(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Ae(t)),s||(s=Ae(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Ee(i,e)||i.__render(s||t,e);Le(this,a,t,s,n,o)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Oe=Te+"_#~&*+\\=|≮≯≈≠=…",Ce=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 Me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Pe=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Me(Te),ze=Me(Oe),Fe=Me("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:Ue,Single:Ve,Before:Xe,After:Ne,Symbol:Ge,Break:je}=Ye;function qe(t){return Pe[t]?Ue:Fe[t]?je:De[t]?Xe:Ie[t]?Ne:ze[t]?Ge:Ce.test(t)?Ve:Ue}const He={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Qe(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:Je}=He,{Letter:Ze,Single:$e,Before:Ke,After:ti,Symbol:ei,Break:ii}=Ye;let ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi,mi,yi=[];function vi(t,e){hi&&!ci&&(ci=hi),ni.data.push({char:t,width:e}),oi+=e}function xi(){ai+=oi,ni.width=oi,si.words.push(ni),ni={data:[]},oi=0}function bi(){_i&&(wi.paraNumber++,si.paraStart=!0,_i=!1),hi&&(si.startCharSize=ci,si.endCharSize=hi,ci=0),si.width=ai,mi.width&&Je(si),yi.push(si),si={words:[]},ai=0}const Bi=0,Ri=1,Si=2;const{top:ki,right:Ei,bottom:Li,left:Ai}=T;function Wi(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 Ti={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o&&(n=l[Ai],o-=l[Ei]+l[Ai]),a&&(s=l[ki],a-=l[ki]+l[Li]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){wi=t,yi=t.rows,mi=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=mi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;_i=!0,fi=null,ci=li=hi=oi=ai=0,ni={data:[]},si={words:[]};for(let n=0,l=i.length;n<l;n++)di=i[n],"\n"===di?(oi&&xi(),si.paraEnd=!0,bi(),_i=!0):(ui=qe(di),ui===Ze&&"none"!==a&&(di=Qe(di,a,!oi)),li=r.measureText(di).width,s&&(s<0&&(hi=li),li+=s),pi=ui===$e&&(fi===$e||fi===Ze)||fi===$e&&ui!==ti,gi=!(ui!==Ke&&ui!==$e||fi!==ei&&fi!==ti),ri=_i&&o?d-o:d,t&&d&&ai+oi+li>ri&&(e?(oi&&xi(),ai&&bi()):(gi||(gi=ui===Ze&&fi==ti),pi||gi||ui===ii||ui===Ke||ui===$e||oi+li>ri?(oi&&xi(),ai&&bi()):ai&&bi()))," "===di&&!0!==_i&&ai+oi===0||(ui===ii?(" "===di&&oi&&xi(),vi(di,li),xi()):pi||gi?(oi&&xi(),vi(di,li)):vi(di,li)),fi=ui);oi&&xi(),ai&&bi(),yi.length>0&&(yi[yi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{wi.paraNumber++,yi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,i),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Wi(e,"x",t[Ai]);break;case"right":Wi(e,"x",-t[Ei])}if(!s)switch(i.verticalAlign){case"top":Wi(e,"y",t[ki]);break;case"bottom":Wi(e,"y",-t[Li])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=n,m=s*i.length+(c?c*(t.paraNumber-1):0),y=o;if(r&&m>w)m=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":g+=(w-m)/2;break;case"bottom":g+=w-m}y+=g;for(let o=0,l=i.length;o<l;o++){if(h=i[o],h.x=p,h.width<_||h.width>_&&!r)switch(d){case"center":h.x+=(_-h.width)/2;break;case"right":h.x+=_-h.width}h.paraStart&&c&&o>0&&(y+=c),h.y=y,y+=s,t.overflow>o&&y>m&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&_&&_<f&&(h.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=m}(c,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Bi:l>.01?Ri:Si,t.isOverflow&&!r&&(t.textMode=!0),h===Si?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Ri?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,i),c}};const Oi={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+")"}},{setPoint:Ci,addPoint:Mi,toBounds:Pi}=O;const Di={export(t,i,n){this.running=!0;const s=l.fileType(i),o=i.includes(".");return n=l.getExportOptions(n),function(t){Ii||(Ii=new C);return new Promise((e=>{Ii.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const c=t=>{r(t),d(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),i),c({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),i),c({data:!!o||t.toSVG()});const{leafer:f}=t;f?(zi(t),f.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){let e,s,o=1,r=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:_}=n,m=void 0===n.smooth?f.config.smooth:n.smooth,y=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=l.isOpaqueImage(i)||x,B=new M;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(h?"inner":"local");switch(o=d.scaleX,r=d.scaleY,i){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(d).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};k.getScaleData(n.scale,n.size,e,R);let S=n.pixelRatio||1;t.isApp&&(R.scaleX*=S,R.scaleY*=S,S=t.app.pixelRatio);const{x:E,y:L,width:A,height:W}=new w(e).scale(R.scaleX,R.scaleY),T={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/o*R.scaleX,1/r*R.scaleY)};let O,C=a.canvas({width:Math.round(A),height:Math.round(W),pixelRatio:S,smooth:m,contextSettings:y});if(p&&(O=t,O.__worldOpacity=0,t=f,T.bounds=C.bounds),C.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(C,T),t.fill=e}else t.__render(C,T);if(C.restore(),O&&O.__updateWorldOpacity(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Mi(a,s,o):Ci(a={},s,o)),r++;const d=new w;return Pi(a,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:S};C=a.canvas(n),C.copyWorld(t,s,n)}b&&C.fillWorld(C.bounds,x||"#FFFFFF","destination-over"),_&&_(C);const P="canvas"===i?C:yield C.export(i,n);c({data:P,width:C.pixelWidth,height:C.pixelHeight,renderBounds:e,trimBounds:s})}))))):c({data:!1})}))))}};let Ii;function zi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>zi(t)))}const Fi=t.prototype,Yi=y.get("@leafer-ui/export");Fi.export=function(t,e){const{quality:i,blob:n}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Fi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Yi.error(t),n(null)}))}))},Fi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Fi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Yi.error(t),n(!1)}))}))},Object.assign(Y,Ti),Object.assign(D,Oi),Object.assign(U,yt),Object.assign(P,te),Object.assign(I,me),Object.assign(V,ke),Object.assign(z,Di);try{wx&&j(0,wx)}catch(t){}export{ot as Layouter,X as LeaferCanvas,rt as Renderer,q as Watcher,j as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as d,FileHelper as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as S,MathHelper as k,AlignHelper as E,ImageEvent as A,AroundHelper as L,PointHelper as W,Direction4 as T,TwoPointBoundsHelper as O,TaskProcessor as C,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as z,Group as F,TextConvert as Y,Paint as U,Effect as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:s,pixelRatio:o}=this.config,a={width:n||t.width,height:s||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),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)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:N,fileType:G}=l;function j(t,i){e.origin={createCanvas:(t,e,n)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(N(G(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new X(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},d(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,this.target=t,e&&(this.config=n.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(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:H,updateBounds:Q,updateAllWorldOpacity:J}=g,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:K}=m,tt={x:0,y:0,width:1e5,height:1e5};class et{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(tt):this.afterBounds.setListWithFn(t,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:it,updateAllChange:nt}=g,st=y.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new x(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?(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)))}))}(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){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&J(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),ot.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(n,o,this.times)),e.emitEvent(new x(s,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){it(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new et([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new et(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=y.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=n.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,at.log(e.innerName,"---\x3e");try{e.app.emit(h.CHILD_START,e),this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),B.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 w,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new w(n);i.save(),s&&!y.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(n),y.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(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 w(0,0,1,1)),this.changed=!0}}__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 h(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(h.AGAIN,this.renderAgain,this),t.on_(o.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 dt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function lt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ut(t,!0,e,i):ht(e,i);break;case"inside":ct("inside",t,s,e,i);break;case"outside":ct("outside",t,s,e,i)}}function ct(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ut(e,!0,n,r):ht(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",dt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ht(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ut(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ht(i,n):n.stroke(),n.restoreBlendMode()):e?ht(i,n):n.stroke())}Object.assign(a,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=ot.fullLayout;const{getSpread:ft,getOuterOf:pt,getByMove:gt,getIntersectData:_t}=R;let wt;function mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return P.image(i,t,e,n,!wt||!wt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const yt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),wt=P.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[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?dt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&P.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?dt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?dt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?dt(e,i):s?i.fill(s):i.fill())},fillText:dt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)lt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)lt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ut(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ut(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ut(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:lt,drawTextStroke:ht,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=_t(n?ft(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=pt(s,a),o=gt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:St,rotate:kt}=S;function Et(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),St(r,s,o),a&&bt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function At(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),s&&St(r,s,o),a&&kt(r,a),t.transform=r}function Lt(t,e,i,n,s,o,a,r,d,l){const c=xt();if(d)if("center"===l)bt(c,{x:i/2,y:n/2},d);else switch(kt(c,d),d){case 90:Bt(c,n,0);break;case 180:Bt(c,i,n);break;case 270:Bt(c,0,i)}vt.x=e.x+s,vt.y=e.y+o,Bt(c,vt.x,vt.y),a&&Rt(c,vt,a,r),t.transform=c}const{get:Wt,translate:Tt}=S,Ot=new w,Ct={},Mt={};function Pt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Dt(i,n,e)}function Dt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ot.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,i,Mt),m=Mt.scaleX,y=Mt.scaleY);else if(!f||h){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,x+=(e.height-s*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),E.toPoint(r,t,e,Ct,!0),v+=Ct.x,x+=Ct.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||m||h)&&At(p,e,v,x,m,y,h);break;case"repeat":(!f||m||h)&&Lt(p,e,n,s,v,x,m,y,h,r),u||(p.repeat="repeat");break;default:m&&Et(p,e,v,x,m,y,h)}return p.transform||(e.x||e.y)&&(p.transform=Wt(),Tt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=y),p.width=n,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let It,zt=new w;const{isSame:Ft}=R;function Yt(t,e,i,n,s,o){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||Pt(s,n,i,o),!0}function Ut(t,e){Nt(t,A.LOAD,e)}function Vt(t,e){Nt(t,A.LOADED,e)}function Xt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,A.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Gt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Ht}=S,{ceil:Qt,abs:Jt}=Math;function Zt(t,i,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=Jt(s),o=Jt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=jt(),Ht(l,g),qt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=jt(),g&&Ht(l,g)),qt(l,1/s,1/o));const y=t.getCanvas(Qt(c)||1,Qt(h)||1,p),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function $t(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Kt}=Math;const te={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return It&&i===It.paint&&Ft(n,It.boxBounds)?o=It.leafPaint:(o={type:i.type,image:r},It=r.use>1?{leafPaint:o,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Yt(t,e,i,r,o,n),s&&(Ut(t,a),Vt(t,a))):r.error?s&&Xt(t,a,r.error):(s&&(Gt(t,!0),Ut(t,a)),o.loadId=r.load((()=>{Gt(t,!1),t.destroyed||(Yt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Vt(t,a)),o.loadId=null}),(e=>{Gt(t,!1),Xt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!z.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=Kt(o)*r,i*=Kt(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||z.running}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||z.running?Zt(t,n,r):n.patternTask||(n.patternTask=B.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Zt(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Zt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,B.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Pt,getPatternData:Dt,fillOrFitMode:Et,clipMode:At,repeatMode:Lt},{toPoint:ee}=L,ie={},ne={};function se(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:oe,getDistance:ae}=W,{get:re,rotateOfOuter:de,scaleOfOuter:le}=S,{toPoint:ce}=L,he={},ue={};function fe(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=oe(e,i);o=re(),s?(le(o,e,a/r*(n||1),1),de(o,e,t+90)):(le(o,e,1,a/r*(n||1)),de(o,e,t))}return o}const{getDistance:pe}=W,{toPoint:ge}=L,_e={},we={};const me={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ee(n||"top",i,ie),ee(s||"bottom",i,ne);const d=e.canvas.createLinearGradient(ie.x,ie.y,ne.x,ne.y);se(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ce(n||"center",i,he),ce(s||"bottom",i,ue);const l=e.canvas.createRadialGradient(he.x,he.y,0,he.x,he.y,ae(he,ue));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,he,ue,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ge(n||"center",i,_e),ge(s||"bottom",i,we);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,_e.x,_e.y):e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,pe(_e,we));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,_e,we,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:fe},{copy:ye,toOffsetOutBounds:ve}=R,xe={},be={};function Be(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ye(xe,t.bounds),xe.x+=i.x-a.x,xe.y+=i.y-a.y,n){const{matrix:t}=s;xe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),xe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),xe.width*=n,xe.height*=n}t.copyWorld(s.canvas,t.bounds,xe)}else n&&(ye(xe,i),xe.x-=i.width/2*(n-1),xe.y-=i.height/2*(n-1),xe.width*=n,xe.height*=n),t.copyWorld(s.canvas,a,n?xe:i)}const{toOffsetOutBounds:Re}=R,Se={};const ke={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ve(l,be),r.forEach(((r,g)=>{f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,be,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Re(l,Se),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Se.offsetX+r.x*h,Se.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,Se,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.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:Ee}=m;function Ae(t,e,i,n,s,o){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),We(t,e,i,1)}(t,i,n,s);break;case"opacity-path":We(t,i,n,o);break;case"path":i.restore()}}function Le(t){return t.getSameCanvas(!1,!0)}function We(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Ae(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Le(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Le(t)),s||(s=Le(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Ee(i,e)||i.__render(s||t,e);Ae(this,a,t,s,n,o)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Oe=Te+"_#~&*+\\=|≮≯≈≠=…",Ce=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 Me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Pe=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Me(Te),ze=Me(Oe),Fe=Me("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:Ue,Single:Ve,Before:Xe,After:Ne,Symbol:Ge,Break:je}=Ye;function qe(t){return Pe[t]?Ue:Fe[t]?je:De[t]?Xe:Ie[t]?Ne:ze[t]?Ge:Ce.test(t)?Ve:Ue}const He={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Qe(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:Je}=He,{Letter:Ze,Single:$e,Before:Ke,After:ti,Symbol:ei,Break:ii}=Ye;let ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi,mi,yi,vi=[];function xi(t,e){hi&&!ci&&(ci=hi),ni.data.push({char:t,width:e}),oi+=e}function bi(){ai+=oi,ni.width=oi,si.words.push(ni),ni={data:[]},oi=0}function Bi(){_i&&(wi.paraNumber++,si.paraStart=!0,_i=!1),hi&&(si.startCharSize=ci,si.endCharSize=hi,ci=0),si.width=ai,mi.width?Je(si):yi&&Ri(),vi.push(si),si={words:[]},ai=0}function Ri(){ai>(wi.maxWidth||0)&&(wi.maxWidth=ai)}const Si=0,ki=1,Ei=2;const{top:Ai,right:Li,bottom:Wi,left:Ti}=T;function Oi(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 Ci={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o?(n=l[Ti],o-=l[Li]+l[Ti]):i.autoSizeAlign||(n=l[Ti]),a?(s=l[Ai],a-=l[Ai]+l[Wi]):i.autoSizeAlign||(s=l[Ai]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){wi=t,vi=t.rows,mi=t.bounds,yi=!mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=mi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;_i=!0,fi=null,ci=li=hi=oi=ai=0,ni={data:[]},si={words:[]};for(let n=0,l=i.length;n<l;n++)di=i[n],"\n"===di?(oi&&bi(),si.paraEnd=!0,Bi(),_i=!0):(ui=qe(di),ui===Ze&&"none"!==a&&(di=Qe(di,a,!oi)),li=r.measureText(di).width,s&&(s<0&&(hi=li),li+=s),pi=ui===$e&&(fi===$e||fi===Ze)||fi===$e&&ui!==ti,gi=!(ui!==Ke&&ui!==$e||fi!==ei&&fi!==ti),ri=_i&&o?d-o:d,t&&d&&ai+oi+li>ri&&(e?(oi&&bi(),ai&&Bi()):(gi||(gi=ui===Ze&&fi==ti),pi||gi||ui===ii||ui===Ke||ui===$e||oi+li>ri?(oi&&bi(),ai&&Bi()):ai&&Bi()))," "===di&&!0!==_i&&ai+oi===0||(ui===ii?(" "===di&&oi&&bi(),xi(di,li),bi()):pi||gi?(oi&&bi(),xi(di,li)):xi(di,li)),fi=ui);oi&&bi(),ai&&Bi(),vi.length>0&&(vi[vi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{wi.paraNumber++,ai=r.measureText(t).width,vi.push({x:o||0,text:t,width:ai,paraStart:!0}),yi&&Ri()}))}(c,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Oi(e,"x",t[Ti]);break;case"right":Oi(e,"x",-t[Li])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Oi(e,"y",t[Ai]);break;case"bottom":Oi(e,"y",-t[Wi])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=n,_=s*i.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=i.length;else if(g||h)switch(l){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(m=i[o],m.x=u,m.width<p||m.width>p&&!r)switch(d){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<n.x&&(n.x=y),v>n.width&&(n.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=_}(c,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Si:l>.01?ki:Ei,t.isOverflow&&!r&&(t.textMode=!0),h===Ei?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===ki?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,i),c}};const Mi={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+")"}},{setPoint:Pi,addPoint:Di,toBounds:Ii}=O;const zi={export(t,i,n){this.running=!0;const s=l.fileType(i),o=i.includes(".");return n=l.getExportOptions(n),function(t){Fi||(Fi=new C);return new Promise((e=>{Fi.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const c=t=>{r(t),d(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),i),c({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),i),c({data:!!o||t.toSVG()});const{leafer:f}=t;f?(Yi(t),f.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){let e,s,o=1,r=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:_}=n,m=void 0===n.smooth?f.config.smooth:n.smooth,y=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=l.isOpaqueImage(i)||x,B=new M;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(h?"inner":"local");switch(o=d.scaleX,r=d.scaleY,i){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(d).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};k.getScaleData(n.scale,n.size,e,R);let S=n.pixelRatio||1;t.isApp&&(R.scaleX*=S,R.scaleY*=S,S=t.app.pixelRatio);const{x:E,y:A,width:L,height:W}=new w(e).scale(R.scaleX,R.scaleY),T={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-A).withScale(1/o*R.scaleX,1/r*R.scaleY)};let O,C=a.canvas({width:Math.round(L),height:Math.round(W),pixelRatio:S,smooth:m,contextSettings:y});if(p&&(O=t,O.__worldOpacity=0,t=f,T.bounds=C.bounds),C.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(C,T),t.fill=e}else t.__render(C,T);if(C.restore(),O&&O.__updateWorldOpacity(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Di(a,s,o):Pi(a={},s,o)),r++;const d=new w;return Ii(a,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:S};C=a.canvas(n),C.copyWorld(t,s,n)}b&&C.fillWorld(C.bounds,x||"#FFFFFF","destination-over"),_&&_(C);const P="canvas"===i?C:yield C.export(i,n);c({data:P,width:C.pixelWidth,height:C.pixelHeight,renderBounds:e,trimBounds:s})}))))):c({data:!1})}))))}};let Fi;function Yi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Yi(t)))}const Ui=t.prototype,Vi=y.get("@leafer-ui/export");Ui.export=function(t,e){const{quality:i,blob:n}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ui.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Vi.error(t),n(null)}))}))},Ui.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Ui.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Vi.error(t),n(!1)}))}))},Object.assign(Y,Ci),Object.assign(D,Mi),Object.assign(U,yt),Object.assign(P,te),Object.assign(I,me),Object.assign(V,ke),Object.assign(z,zi);try{wx&&j(0,wx)}catch(t){}export{ot as Layouter,X as LeaferCanvas,rt as Renderer,q as Watcher,j as useCanvas};
|