@leafer-draw/miniapp 1.6.7 → 1.7.0
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 +17 -11
- package/dist/miniapp.esm.js +17 -11
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +85 -61
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/miniapp.cjs
CHANGED
|
@@ -1101,7 +1101,7 @@ const PaintModule = {
|
|
|
1101
1101
|
};
|
|
1102
1102
|
|
|
1103
1103
|
let origin = {};
|
|
1104
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = core.MatrixHelper;
|
|
1104
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
|
|
1105
1105
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1106
1106
|
const transform = get$3();
|
|
1107
1107
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1110,13 +1110,15 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1110
1110
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1111
1111
|
data.transform = transform;
|
|
1112
1112
|
}
|
|
1113
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1113
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
1114
1114
|
const transform = get$3();
|
|
1115
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
1116
|
-
if (scaleX)
|
|
1117
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
1118
1115
|
if (rotation)
|
|
1119
1116
|
rotate(transform, rotation);
|
|
1117
|
+
if (skew)
|
|
1118
|
+
skewHelper(transform, skew.x, skew.y);
|
|
1119
|
+
if (scaleX)
|
|
1120
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
1121
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
1120
1122
|
data.transform = transform;
|
|
1121
1123
|
}
|
|
1122
1124
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1153,11 +1155,13 @@ const tempBox = new core.Bounds();
|
|
|
1153
1155
|
const tempScaleData = {};
|
|
1154
1156
|
const tempImage = {};
|
|
1155
1157
|
function createData(leafPaint, image, paint, box) {
|
|
1156
|
-
const { changeful, sync } = paint;
|
|
1158
|
+
const { changeful, sync, editing } = paint;
|
|
1157
1159
|
if (changeful)
|
|
1158
1160
|
leafPaint.changeful = changeful;
|
|
1159
1161
|
if (sync)
|
|
1160
1162
|
leafPaint.sync = sync;
|
|
1163
|
+
if (editing)
|
|
1164
|
+
leafPaint.editing = editing;
|
|
1161
1165
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1162
1166
|
}
|
|
1163
1167
|
function getPatternData(paint, box, image) {
|
|
@@ -1166,7 +1170,7 @@ function getPatternData(paint, box, image) {
|
|
|
1166
1170
|
if (paint.mode === 'strench')
|
|
1167
1171
|
paint.mode = 'stretch';
|
|
1168
1172
|
let { width, height } = image;
|
|
1169
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1173
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
1170
1174
|
const sameBox = box.width === width && box.height === height;
|
|
1171
1175
|
const data = { mode };
|
|
1172
1176
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1200,8 +1204,8 @@ function getPatternData(paint, box, image) {
|
|
|
1200
1204
|
break;
|
|
1201
1205
|
case 'normal':
|
|
1202
1206
|
case 'clip':
|
|
1203
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1204
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1207
|
+
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
1208
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
1205
1209
|
break;
|
|
1206
1210
|
case 'repeat':
|
|
1207
1211
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1278,11 +1282,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1278
1282
|
}
|
|
1279
1283
|
onLoadSuccess(ui, event);
|
|
1280
1284
|
}
|
|
1281
|
-
leafPaint.loadId =
|
|
1285
|
+
leafPaint.loadId = undefined;
|
|
1282
1286
|
}, (error) => {
|
|
1283
1287
|
ignoreRender(ui, false);
|
|
1284
1288
|
onLoadError(ui, event, error);
|
|
1285
|
-
leafPaint.loadId =
|
|
1289
|
+
leafPaint.loadId = undefined;
|
|
1286
1290
|
});
|
|
1287
1291
|
if (ui.placeholderColor) {
|
|
1288
1292
|
if (!ui.placeholderDelay)
|
|
@@ -1348,6 +1352,8 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1348
1352
|
const { image, data } = paint;
|
|
1349
1353
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1350
1354
|
if (sx) {
|
|
1355
|
+
sx = abs$1(sx);
|
|
1356
|
+
sy = abs$1(sy);
|
|
1351
1357
|
imageMatrix = get$1();
|
|
1352
1358
|
copy$1(imageMatrix, transform);
|
|
1353
1359
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
package/dist/miniapp.esm.js
CHANGED
|
@@ -1102,7 +1102,7 @@ const PaintModule = {
|
|
|
1102
1102
|
};
|
|
1103
1103
|
|
|
1104
1104
|
let origin = {};
|
|
1105
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
|
|
1105
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
|
|
1106
1106
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1107
1107
|
const transform = get$3();
|
|
1108
1108
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1111,13 +1111,15 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1111
1111
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1112
1112
|
data.transform = transform;
|
|
1113
1113
|
}
|
|
1114
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1114
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
1115
1115
|
const transform = get$3();
|
|
1116
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
1117
|
-
if (scaleX)
|
|
1118
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
1119
1116
|
if (rotation)
|
|
1120
1117
|
rotate(transform, rotation);
|
|
1118
|
+
if (skew)
|
|
1119
|
+
skewHelper(transform, skew.x, skew.y);
|
|
1120
|
+
if (scaleX)
|
|
1121
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
1122
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
1121
1123
|
data.transform = transform;
|
|
1122
1124
|
}
|
|
1123
1125
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1154,11 +1156,13 @@ const tempBox = new Bounds();
|
|
|
1154
1156
|
const tempScaleData = {};
|
|
1155
1157
|
const tempImage = {};
|
|
1156
1158
|
function createData(leafPaint, image, paint, box) {
|
|
1157
|
-
const { changeful, sync } = paint;
|
|
1159
|
+
const { changeful, sync, editing } = paint;
|
|
1158
1160
|
if (changeful)
|
|
1159
1161
|
leafPaint.changeful = changeful;
|
|
1160
1162
|
if (sync)
|
|
1161
1163
|
leafPaint.sync = sync;
|
|
1164
|
+
if (editing)
|
|
1165
|
+
leafPaint.editing = editing;
|
|
1162
1166
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1163
1167
|
}
|
|
1164
1168
|
function getPatternData(paint, box, image) {
|
|
@@ -1167,7 +1171,7 @@ function getPatternData(paint, box, image) {
|
|
|
1167
1171
|
if (paint.mode === 'strench')
|
|
1168
1172
|
paint.mode = 'stretch';
|
|
1169
1173
|
let { width, height } = image;
|
|
1170
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1174
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
1171
1175
|
const sameBox = box.width === width && box.height === height;
|
|
1172
1176
|
const data = { mode };
|
|
1173
1177
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1201,8 +1205,8 @@ function getPatternData(paint, box, image) {
|
|
|
1201
1205
|
break;
|
|
1202
1206
|
case 'normal':
|
|
1203
1207
|
case 'clip':
|
|
1204
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1205
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1208
|
+
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
1209
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
1206
1210
|
break;
|
|
1207
1211
|
case 'repeat':
|
|
1208
1212
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1279,11 +1283,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1279
1283
|
}
|
|
1280
1284
|
onLoadSuccess(ui, event);
|
|
1281
1285
|
}
|
|
1282
|
-
leafPaint.loadId =
|
|
1286
|
+
leafPaint.loadId = undefined;
|
|
1283
1287
|
}, (error) => {
|
|
1284
1288
|
ignoreRender(ui, false);
|
|
1285
1289
|
onLoadError(ui, event, error);
|
|
1286
|
-
leafPaint.loadId =
|
|
1290
|
+
leafPaint.loadId = undefined;
|
|
1287
1291
|
});
|
|
1288
1292
|
if (ui.placeholderColor) {
|
|
1289
1293
|
if (!ui.placeholderDelay)
|
|
@@ -1349,6 +1353,8 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1349
1353
|
const { image, data } = paint;
|
|
1350
1354
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1351
1355
|
if (sx) {
|
|
1356
|
+
sx = abs$1(sx);
|
|
1357
|
+
sy = abs$1(sy);
|
|
1352
1358
|
imageMatrix = get$1();
|
|
1353
1359
|
copy$1(imageMatrix, transform);
|
|
1354
1360
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as a,FileHelper as o,Creator as r,LeaferImage as l,defineKey as d,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,LeafBoundsHelper as w,Bounds as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as S,BoundsHelper as B,MatrixHelper as k,MathHelper as R,AlignHelper as E,PointHelper as A,ImageEvent as L,AroundHelper as T,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as W,Paint as O,ColorConvert as P,PaintGradient as D,Export as I,Group as M,TextConvert as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class U 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:s,height:n,pixelRatio:a}=this.config,o={width:s||t.width,height:n||t.height,pixelRatio:a};this.resize(o),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),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,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new a(t,e))}}const{mineType:Y,fileType:G}=o;function N(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(Y(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(Y(G(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,a)=>{let o;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,o=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){o?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){a(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.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:s=>{s.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=r.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new U(t,e),image:t=>new l(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 j{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=s.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=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[p.CHANGE,this.__onAttrChange,this],[[u.ADD,u.REMOVE],this.__onChildEvent,this],[f.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:X,updateChange:V}=g,{pushAllChildBranch:H,pushAllParent:Q}=_;const{worldBounds:Z}=w;class ${constructor(t){this.updatedBounds=new m,this.beforeBounds=new m,this.afterBounds=new m,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Z)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Z),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:J,updateAllChange:K}=g,tt=y.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.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(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(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:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&H(t,e),Q(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Q(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||X(s[t])}X(i)}}))}(this.__levelList),function(t){t.list.forEach(V)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(a,r,this.times)),i.emitEvent(new x(o,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:s,AFTER:n}=x,a=this.getBlocks(new c(e));e.emitEvent(new x(i,a,this.times)),et.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),b.end(t)}static fullLayout(t){J(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new $([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new $(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[f.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const it=y.get("Renderer");class st{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=s.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(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(h.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(h.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new m,it.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,it.error(t)}it.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return it.warn("rendering");if(this.times>3)return it.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new m,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;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new m(s);i.save(),s.spread(st.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new m;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 m(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 m(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||it.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(){this.__eventIds=[this.target.on_([[h.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[h.AGAIN,this.renderAgain,this],[a.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 nt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function at(t,e){t.__.__font?nt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ot(t,e,i){switch(e.__.strokeAlign){case"center":rt(t,1,e,i);break;case"inside":lt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?rt(t,2,e,i):lt(t,"outside",e,i)}}function rt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?ht(t,!0,i,s):ct(i,s)}function lt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,rt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",nt(i,n),n.blendMode="normal",dt(s,n,i),n.recycle(i.__nowWorld)}function dt(t,i,s){s.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(i,s.__nowWorld):t.copyWorldToInner(i,s.__nowWorld,s.__layout.renderBounds)}function ct(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=s;n.forEach((i=>a.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function ht(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&W.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?ct(i,s):s.stroke(),s.restoreBlendMode()):e?ct(i,s):s.stroke())}function ut(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ot(t,e,i);else switch(s.strokeAlign){case"center":ft(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),ft(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)ft(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),ft(t,2,e,a),a.clipUI(s),a.clearWorld(n),dt(i,a,e),a.recycle(e.__nowWorld)}}(t,e,i)}}function ft(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?ht(t,!1,i,s):s.stroke(),n.__useArrow&&O.strokeArrow(t,i,s)}st.clipSpread=10,Object.assign(r,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,i)=>new st(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=et.fullLayout;const{getSpread:pt,getOuterOf:gt,getByMove:_t,getIntersectData:wt}=B;let mt;const{stintSet:yt}=s,{hasTransparent:vt}=P;function xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=W.image(i,t,e,n,!mt||!mt[e.url]);break;case"linear":s=D.linearGradient(e,n);break;case"radial":s=D.radialGradient(e,n);break;case"angular":s=D.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:P.string(o,r)};break;default:void 0!==e.r&&(s={type:"solid",style:P.string(e)})}return s&&("string"==typeof s.style&&vt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const bt={compute:function(t,e){const i=e.__,s=[];let n,a,o=i.__input[t];o instanceof Array||(o=[o]),mt=W.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=xt(t,o[n],e))&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),a=!0),"fill"===t?(yt(i,"__isAlphaPixelFill",n),yt(i,"__isTransparentFill",a)):(yt(i,"__isAlphaPixelStroke",n),yt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,at(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(W.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),at(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),at(e,i),i.restoreBlendMode()):at(e,i)}},fillPathOrText:at,fillText:nt,stroke:ut,strokes:function(t,e,i){ut(t,e,i)},strokeText:ot,drawTextStroke:ct,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:c}=n;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(n))l=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,h=wt(s?pt(e.bounds,d===c?s*d:[s*c,s*d]):e.bounds,n);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=gt(n,o),a=_t(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(s,i),{canvas:s,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let St={};const{get:Bt,rotateOfOuter:kt,translate:Rt,scaleOfOuter:Et,scale:At,rotate:Lt}=k;function Tt(t,e,i,s,n,a,o){const r=Bt();Rt(r,e.x+i,e.y+s),At(r,n,a),o&&kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Ct(t,e,i,s,n,a,o){const r=Bt();Rt(r,e.x+i,e.y+s),n&&At(r,n,a),o&&Lt(r,o),t.transform=r}function Wt(t,e,i,s,n,a,o,r,l,d){const c=Bt();if(l)if("center"===d)kt(c,{x:i/2,y:s/2},l);else switch(Lt(c,l),l){case 90:Rt(c,s,0);break;case 180:Rt(c,i,s);break;case 270:Rt(c,0,i)}St.x=e.x+n,St.y=e.y+a,Rt(c,St.x,St.y),o&&Et(c,St,o,r),t.transform=c}const{get:Ot,translate:Pt}=k,Dt=new m,It={},Mt={};function zt(t,e,i,s){const{changeful:n,sync:a}=i;n&&(t.changeful=n),a&&(t.sync=a),t.data=Ft(i,s,e)}function Ft(t,e,i){t.padding&&(e=Dt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===s&&e.height===n,g={mode:o},_="center"!==r&&(h||0)%180==90;let w,m;switch(B.set(Mt,0,0,_?n:s,_?s:n),o&&"cover"!==o&&"fit"!==o?((d||c)&&(R.getScaleData(d,c,i,It),w=It.scaleX,m=It.scaleY),r&&(w&&B.scale(Mt,w,m,!0),E.toPoint(r,Mt,e,Mt,!0,!0))):p&&!h||(w=m=B.getFitScale(e,Mt,"fit"!==o),B.put(e,i,r,w,!1,Mt),B.scale(Mt,w,m,!0)),l&&A.move(Mt,l),o){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(Mt.x||Mt.y||w||h)&&Ct(g,e,Mt.x,Mt.y,w,m,h);break;case"repeat":(!p||w||h)&&Wt(g,e,s,n,Mt.x,Mt.y,w,m,h,r),u||(g.repeat="repeat");break;default:w&&Tt(g,e,Mt.x,Mt.y,w,m,h)}return g.transform||(e.x||e.y)&&(g.transform=Ot(),Pt(g.transform,e.x,e.y)),w&&"stretch"!==o&&(g.scaleX=w,g.scaleY=m),g.width=s,g.height=n,a&&(g.opacity=a),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Ut,Yt=new m;const{isSame:Gt}=B;function Nt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||zt(n,s,i,a),!0}function jt(t,e){Vt(t,L.LOAD,e)}function qt(t,e){Vt(t,L.LOADED,e)}function Xt(t,e,i){e.error=i,t.forceUpdate("surface"),Vt(t,L.ERROR,e)}function Vt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Ht(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Qt,scale:Zt,copy:$t}=k,{ceil:Jt,abs:Kt}=Math;function te(t,i,s){let{scaleX:n,scaleY:a}=S.patternLocked?t.__world:t.__nowWorld;const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{n=Kt(n),a=Kt(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=Qt(),$t(d,p),Zt(d,1/u,1/f),n*=u,a*=f),n*=s,a*=s,c*=n,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&&(n/=l,a/=l,c/=l,h/=l),u&&(n/=u,a/=f),(p||1!==n||1!==a)&&(d||(d=Qt(),p&&$t(d,p)),Zt(d,1/n,1/a));const m=t.getCanvas(Jt(c)||1,Jt(h)||1,r.opacity,r.filters),y=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=y,i.patternId=o,!0}}function ee(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ie}=Math;const se={image:function(t,e,i,s,n){let a,o;const r=S.get(i);return Ut&&i===Ut.paint&&Gt(s,Ut.boxBounds)?a=Ut.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Ut=r.use>1?{leafPaint:a,paint:i,boxBounds:Yt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Nt(t,e,i,r,a,s),n&&(jt(t,o),qt(t,o))):r.error?n&&Xt(t,o,r.error):(n&&(Ht(t,!0),jt(t,o)),a.loadId=r.load((()=>{Ht(t,!1),t.destroyed||(Nt(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),qt(t,o)),a.loadId=null}),(e=>{Ht(t,!1),Xt(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,s,n){const{scaleX:o,scaleY:r}=S.patternLocked?t.__world:t.__nowWorld,{pixelRatio:l}=i,{data:d}=s;if(!d||s.patternId===o+"-"+r+"-"+l&&!I.running)return!1;if(n)if(d.repeat)n=!1;else if(!(s.changeful||a.isResizing(t)||I.running)){let{width:t,height:i}=d;t*=ie(o)*l,i*=ie(r)*l,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),n=t*i>e.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,d),!0):(!s.style||s.sync||I.running?te(t,s,l):s.patternTask||(s.patternTask=S.patternTasker.add((()=>ee(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&te(t,s,l),t.forceUpdate("surface")}))),300)),!1)},createPattern:te,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,S.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:zt,getPatternData:Ft,fillOrFitMode:Tt,clipMode:Ct,repeatMode:Wt},{toPoint:ne}=T,{hasTransparent:ae}=P,oe={},re={};function le(t,e,i,s){if(i){let n,a,o,r;for(let t=0,l=i.length;t<l;t++)n=i[t],"string"==typeof n?(o=t/(l-1),a=P.string(n,s)):(o=n.offset,a=P.string(n.color,s)),e.addColorStop(o,a),!r&&ae(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:de,getDistance:ce}=A,{get:he,rotateOfOuter:ue,scaleOfOuter:fe}=k,{toPoint:pe}=T,ge={},_e={};function we(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=de(e,i);a=he(),n?(fe(a,e,o/r*(s||1),1),ue(a,e,t+90)):(fe(a,e,1,o/r*(s||1)),ue(a,e,t))}return a}const{getDistance:me}=A,{toPoint:ye}=T,ve={},xe={};const be={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;ne(s||"top",i,oe),ne(n||"bottom",i,re);const r=e.canvas.createLinearGradient(oe.x,oe.y,re.x,re.y),l={type:a,style:r};return le(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;pe(s||"center",i,ge),pe(n||"bottom",i,_e);const l=e.canvas.createRadialGradient(ge.x,ge.y,0,ge.x,ge.y,ce(ge,_e)),d={type:a,style:l};le(d,l,t.stops,o);const c=we(i,ge,_e,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;ye(s||"center",i,ve),ye(n||"bottom",i,xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,ve.x,ve.y):e.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,me(ve,xe)),d={type:a,style:l};le(d,l,t.stops,o);const c=we(i,ve,xe,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:we},{copy:Se,toOffsetOutBounds:Be}=B,ke={},Re={};function Ee(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Se(ke,t.bounds),ke.x+=i.x-o.x,ke.y+=i.y-o.y,s){const{matrix:t}=n;ke.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),ke.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),ke.width*=s,ke.height*=s}t.copyWorld(n.canvas,t.bounds,ke)}else s&&(Se(ke,i),ke.x-=i.width/2*(s-1),ke.y-=i.height/2*(s-1),ke.width*=s,ke.height*=s),t.copyWorld(n.canvas,o,s?ke:i)}const{toOffsetOutBounds:Ae}=B,Le={};const Te={shadow:function(t,e,i){let s,n;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;Be(d,Re),r.forEach(((r,g)=>{f.setWorldShadow(Re.offsetX+r.x*h,Re.offsetY+r.y*u,r.blur*h,P.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ee(f,Re,n,i),s=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),s=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;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;Ae(d,Le),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Le.offsetX+r.x*h,Le.offsetY+r.y*u,r.blur*h),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ee(f,Le,n,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,c,d,"source-out"),s=d),f.fillWorld(s,P.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ce}=w;function We(t,e,i,s,n,a){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Pe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Pe(t,i,s,a);break;case"path":i.restore()}}function Oe(t){return t.getSameCanvas(!1,!0)}function Pe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}M.prototype.__renderMask=function(t,e){let i,s,n,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&&(We(this,o,t,n,s,a),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=Oe(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=Oe(t)),n||(n=Oe(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Ce(i,e)||i.__render(n||t,e);We(this,o,t,n,s,a)};const De=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ie=De+"_#~&*+\\=|≮≯≈≠=…",Me=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ze(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Fe=ze("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ue=ze("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ye=ze(De),Ge=ze(Ie),Ne=ze("- —/~|┆·");var je;!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"}(je||(je={}));const{Letter:qe,Single:Xe,Before:Ve,After:He,Symbol:Qe,Break:Ze}=je;function $e(t){return Fe[t]?qe:Ne[t]?Ze:Ue[t]?Ve:Ye[t]?He:Ge[t]?Qe:Me.test(t)?Xe:qe}const Je={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ke(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:ti}=Je,{Letter:ei,Single:ii,Before:si,After:ni,Symbol:ai,Break:oi}=je;let ri,li,di,ci,hi,ui,fi,pi,gi,_i,wi,mi,yi,vi,xi,bi,Si,Bi=[];function ki(t,e){gi&&!pi&&(pi=gi),ri.data.push({char:t,width:e}),di+=e}function Ri(){ci+=di,ri.width=di,li.words.push(ri),ri={data:[]},di=0}function Ei(){vi&&(xi.paraNumber++,li.paraStart=!0,vi=!1),gi&&(li.startCharSize=pi,li.endCharSize=gi,pi=0),li.width=ci,bi.width?ti(li):Si&&Ai(),Bi.push(li),li={words:[]},ci=0}function Ai(){ci>(xi.maxWidth||0)&&(xi.maxWidth=ci)}const{top:Li,right:Ti,bottom:Ci,left:Wi}=C;function Oi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Pi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(a?(s=d[Wi],a-=d[Ti]+d[Wi]):i.autoSizeAlign||(s=d[Wi]),o?(n=d[Li],o-=d[Li]+d[Ci]):i.autoSizeAlign||(n=d[Li]));const c={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){xi=t,Bi=t.rows,bi=t.bounds,Si=!bi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:l,height:d}=bi;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;vi=!0,wi=null,pi=fi=gi=di=ci=0,ri={data:[]},li={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)ui=i[s],"\n"===ui?(di&&Ri(),li.paraEnd=!0,Ei(),vi=!0):(_i=$e(ui),_i===ei&&"none"!==o&&(ui=Ke(ui,o,!di)),fi=r.measureText(ui).width,n&&(n<0&&(gi=fi),fi+=n),mi=_i===ii&&(wi===ii||wi===ei)||wi===ii&&_i!==ni,yi=!(_i!==si&&_i!==ii||wi!==ai&&wi!==ni),hi=vi&&a?l-a:l,t&&l&&ci+di+fi>hi&&(e?(di&&Ri(),ci&&Ei()):(yi||(yi=_i===ei&&wi==ni),mi||yi||_i===oi||_i===si||_i===ii||di+fi>hi?(di&&Ri(),ci&&Ei()):ci&&Ei()))," "===ui&&!0!==vi&&ci+di===0||(_i===oi?(" "===ui&&di&&Ri(),ki(ui,fi),Ri()):mi||yi?(di&&Ri(),ki(ui,fi)):ki(ui,fi)),wi=_i);di&&Ri(),ci&&Ei(),Bi.length>0&&(Bi[Bi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{xi.paraNumber++,ci=r.measureText(t).width,Bi.push({x:a||0,text:t,width:ci,paraStart:!0}),Si&&Ai()}))}(c,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Oi(e,"x",t[Wi]);break;case"right":Oi(e,"x",-t[Ti])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Oi(e,"y",t[Li]);break;case"bottom":Oi(e,"y",-t[Ci])}}(d,c,i,a,o),function(t,e){const{rows:i,bounds:s}=t,n=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:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=n;o<c;o++){if(y=i[o],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&o>0&&(m+=h),y.y=m,m+=a,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,u;s.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,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,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(c,i,a),c.overflow&&function(t,i,s,n){if(!n)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=s+n-d;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+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,s,a),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=P.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(c,i),c}};const Di={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(z,Pi),Object.assign(P,Di),Object.assign(O,bt),Object.assign(W,se),Object.assign(D,be),Object.assign(F,Te);try{wx&&N(0,wx)}catch(t){}export{et as Layouter,U as LeaferCanvas,st as Renderer,j as Watcher,N as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as a,FileHelper as o,Creator as r,LeaferImage as d,defineKey as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,LeafBoundsHelper as w,Bounds as y,Debug as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as S,BoundsHelper as B,MatrixHelper as k,MathHelper as R,AlignHelper as E,PointHelper as A,ImageEvent as L,AroundHelper as T,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as W,Paint as O,ColorConvert as P,PaintGradient as D,Export as I,Group as M,TextConvert as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class U 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:s,height:n,pixelRatio:a}=this.config,o={width:s||t.width,height:n||t.height,pixelRatio:a};this.resize(o),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),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,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new a(t,e))}}const{mineType:Y,fileType:G}=o;function N(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(Y(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(Y(G(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,a)=>{let o;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,o=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){o?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){a(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.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:s=>{s.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=r.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new U(t,e),image:t=>new d(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},l(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class j{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=s.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=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[p.CHANGE,this.__onAttrChange,this],[[u.ADD,u.REMOVE],this.__onChildEvent,this],[f.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:X,updateChange:V}=g,{pushAllChildBranch:H,pushAllParent:Q}=_;const{worldBounds:Z}=w;class ${constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Z)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Z),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:J,updateAllChange:K}=g,tt=m.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.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(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(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:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&H(t,e),Q(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Q(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||X(s[t])}X(i)}}))}(this.__levelList),function(t){t.list.forEach(V)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(a,r,this.times)),i.emitEvent(new x(o,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:s,AFTER:n}=x,a=this.getBlocks(new c(e));e.emitEvent(new x(i,a,this.times)),et.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),b.end(t)}static fullLayout(t){J(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new $([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new $(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[f.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const it=m.get("Renderer");class st{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=s.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(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(h.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(h.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new y,it.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,it.error(t)}it.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return it.warn("rendering");if(this.times>3)return it.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,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;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new y(s);i.save(),s.spread(st.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;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 y(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 y(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||it.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(){this.__eventIds=[this.target.on_([[h.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[h.AGAIN,this.renderAgain,this],[a.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 nt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function at(t,e){t.__.__font?nt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ot(t,e,i){switch(e.__.strokeAlign){case"center":rt(t,1,e,i);break;case"inside":dt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?rt(t,2,e,i):dt(t,"outside",e,i)}}function rt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?ht(t,!0,i,s):ct(i,s)}function dt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,rt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",nt(i,n),n.blendMode="normal",lt(s,n,i),n.recycle(i.__nowWorld)}function lt(t,i,s){s.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(i,s.__nowWorld):t.copyWorldToInner(i,s.__nowWorld,s.__layout.renderBounds)}function ct(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=s;n.forEach((i=>a.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function ht(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&W.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?ct(i,s):s.stroke(),s.restoreBlendMode()):e?ct(i,s):s.stroke())}function ut(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ot(t,e,i);else switch(s.strokeAlign){case"center":ft(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),ft(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)ft(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),ft(t,2,e,a),a.clipUI(s),a.clearWorld(n),lt(i,a,e),a.recycle(e.__nowWorld)}}(t,e,i)}}function ft(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?ht(t,!1,i,s):s.stroke(),n.__useArrow&&O.strokeArrow(t,i,s)}st.clipSpread=10,Object.assign(r,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,i)=>new st(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=et.fullLayout;const{getSpread:pt,getOuterOf:gt,getByMove:_t,getIntersectData:wt}=B;let yt;const{stintSet:mt}=s,{hasTransparent:vt}=P;function xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=W.image(i,t,e,n,!yt||!yt[e.url]);break;case"linear":s=D.linearGradient(e,n);break;case"radial":s=D.radialGradient(e,n);break;case"angular":s=D.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:P.string(o,r)};break;default:void 0!==e.r&&(s={type:"solid",style:P.string(e)})}return s&&("string"==typeof s.style&&vt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const bt={compute:function(t,e){const i=e.__,s=[];let n,a,o=i.__input[t];o instanceof Array||(o=[o]),yt=W.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=xt(t,o[n],e))&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),a=!0),"fill"===t?(mt(i,"__isAlphaPixelFill",n),mt(i,"__isTransparentFill",a)):(mt(i,"__isAlphaPixelStroke",n),mt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,at(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(W.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),at(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),at(e,i),i.restoreBlendMode()):at(e,i)}},fillPathOrText:at,fillText:nt,stroke:ut,strokes:function(t,e,i){ut(t,e,i)},strokeText:ot,drawTextStroke:ct,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))d=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,h=wt(s?pt(e.bounds,l===c?s*l:[s*c,s*l]):e.bounds,n);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=gt(n,o),a=_t(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(s,i),{canvas:s,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let St={};const{get:Bt,rotateOfOuter:kt,translate:Rt,scaleOfOuter:Et,scale:At,rotate:Lt,skew:Tt}=k;function Ct(t,e,i,s,n,a,o){const r=Bt();Rt(r,e.x+i,e.y+s),At(r,n,a),o&&kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Wt(t,e,i,s,n,a,o,r){const d=Bt();o&&Lt(d,o),r&&Tt(d,r.x,r.y),n&&At(d,n,a),Rt(d,e.x+i,e.y+s),t.transform=d}function Ot(t,e,i,s,n,a,o,r,d,l){const c=Bt();if(d)if("center"===l)kt(c,{x:i/2,y:s/2},d);else switch(Lt(c,d),d){case 90:Rt(c,s,0);break;case 180:Rt(c,i,s);break;case 270:Rt(c,0,i)}St.x=e.x+n,St.y=e.y+a,Rt(c,St.x,St.y),o&&Et(c,St,o,r),t.transform=c}const{get:Pt,translate:Dt}=k,It=new y,Mt={},zt={};function Ft(t,e,i,s){const{changeful:n,sync:a,editing:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.editing=o),t.data=Ut(i,s,e)}function Ut(t,e,i){t.padding&&(e=It.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:o,align:r,offset:d,scale:l,size:c,rotation:h,skew:u,repeat:f,filters:p}=t,g=e.width===s&&e.height===n,_={mode:o},w="center"!==r&&(h||0)%180==90;let y,m;switch(B.set(zt,0,0,w?n:s,w?s:n),o&&"cover"!==o&&"fit"!==o?((l||c)&&(R.getScaleData(l,c,i,Mt),y=Mt.scaleX,m=Mt.scaleY),r&&(y&&B.scale(zt,y,m,!0),E.toPoint(r,zt,e,zt,!0,!0))):g&&!h||(y=m=B.getFitScale(e,zt,"fit"!==o),B.put(e,i,r,y,!1,zt),B.scale(zt,y,m,!0)),d&&A.move(zt,d),o){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(zt.x||zt.y||y||h||u)&&Wt(_,e,zt.x,zt.y,y,m,h,u);break;case"repeat":(!g||y||h)&&Ot(_,e,s,n,zt.x,zt.y,y,m,h,r),f||(_.repeat="repeat");break;default:y&&Ct(_,e,zt.x,zt.y,y,m,h)}return _.transform||(e.x||e.y)&&(_.transform=Pt(),Dt(_.transform,e.x,e.y)),y&&"stretch"!==o&&(_.scaleX=y,_.scaleY=m),_.width=s,_.height=n,a&&(_.opacity=a),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let Yt,Gt=new y;const{isSame:Nt}=B;function jt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ft(n,s,i,a),!0}function qt(t,e){Ht(t,L.LOAD,e)}function Xt(t,e){Ht(t,L.LOADED,e)}function Vt(t,e,i){e.error=i,t.forceUpdate("surface"),Ht(t,L.ERROR,e)}function Ht(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Qt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Zt,scale:$t,copy:Jt}=k,{ceil:Kt,abs:te}=Math;function ee(t,i,s){let{scaleX:n,scaleY:a}=S.patternLocked?t.__world:t.__nowWorld;const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{n=te(n),a=te(a);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(u=te(u),f=te(f),l=Zt(),Jt(l,p),$t(l,1/u,1/f),n*=u,a*=f),n*=s,a*=s,c*=n,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&&(d=Math.sqrt(_/w)),d&&(n/=d,a/=d,c/=d,h/=d),u&&(n/=u,a/=f),(p||1!==n||1!==a)&&(l||(l=Zt(),p&&Jt(l,p)),$t(l,1/n,1/a));const y=t.getCanvas(Kt(c)||1,Kt(h)||1,r.opacity,r.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=o,!0}}function ie(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{d(s.next(t))}catch(t){a(t)}}function r(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:se}=Math;const ne={image:function(t,e,i,s,n){let a,o;const r=S.get(i);return Yt&&i===Yt.paint&&Nt(s,Yt.boxBounds)?a=Yt.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Yt=r.use>1?{leafPaint:a,paint:i,boxBounds:Gt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(jt(t,e,i,r,a,s),n&&(qt(t,o),Xt(t,o))):r.error?n&&Vt(t,o,r.error):(n&&(Qt(t,!0),qt(t,o)),a.loadId=r.load((()=>{Qt(t,!1),t.destroyed||(jt(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Xt(t,o)),a.loadId=void 0}),(e=>{Qt(t,!1),Vt(t,o,e),a.loadId=void 0})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:o,scaleY:r}=S.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=i,{data:l}=s;if(!l||s.patternId===o+"-"+r+"-"+d&&!I.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||a.isResizing(t)||I.running)){let{width:t,height:i}=l;t*=se(o)*d,i*=se(r)*d,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||I.running?ee(t,s,d):s.patternTask||(s.patternTask=S.patternTasker.add((()=>ie(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ee(t,s,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:ee,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o,r;for(let d=0,l=i.length;d<l;d++)s=i[d],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,S.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[d].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:Ft,getPatternData:Ut,fillOrFitMode:Ct,clipMode:Wt,repeatMode:Ot},{toPoint:ae}=T,{hasTransparent:oe}=P,re={},de={};function le(t,e,i,s){if(i){let n,a,o,r;for(let t=0,d=i.length;t<d;t++)n=i[t],"string"==typeof n?(o=t/(d-1),a=P.string(n,s)):(o=n.offset,a=P.string(n.color,s)),e.addColorStop(o,a),!r&&oe(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:ce,getDistance:he}=A,{get:ue,rotateOfOuter:fe,scaleOfOuter:pe}=k,{toPoint:ge}=T,_e={},we={};function ye(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=ce(e,i);a=ue(),n?(pe(a,e,o/r*(s||1),1),fe(a,e,t+90)):(pe(a,e,1,o/r*(s||1)),fe(a,e,t))}return a}const{getDistance:me}=A,{toPoint:ve}=T,xe={},be={};const Se={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;ae(s||"top",i,re),ae(n||"bottom",i,de);const r=e.canvas.createLinearGradient(re.x,re.y,de.x,de.y),d={type:a,style:r};return le(d,r,t.stops,o),d},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;ge(s||"center",i,_e),ge(n||"bottom",i,we);const d=e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,he(_e,we)),l={type:a,style:d};le(l,d,t.stops,o);const c=ye(i,_e,we,r,!0);return c&&(l.transform=c),l},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;ve(s||"center",i,xe),ve(n||"bottom",i,be);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,xe.x,xe.y):e.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,me(xe,be)),l={type:a,style:d};le(l,d,t.stops,o);const c=ye(i,xe,be,r||1,e.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:ye},{copy:Be,toOffsetOutBounds:ke}=B,Re={},Ee={};function Ae(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Be(Re,t.bounds),Re.x+=i.x-o.x,Re.y+=i.y-o.y,s){const{matrix:t}=n;Re.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Re.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Re.width*=s,Re.height*=s}t.copyWorld(n.canvas,t.bounds,Re)}else s&&(Be(Re,i),Re.x-=i.width/2*(s-1),Re.y-=i.height/2*(s-1),Re.width*=s,Re.height*=s),t.copyWorld(n.canvas,o,s?Re:i)}const{toOffsetOutBounds:Le}=B,Te={};const Ce={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ke(l,Ee),r.forEach(((r,g)=>{f.setWorldShadow(Ee.offsetX+r.x*h,Ee.offsetY+r.y*u,r.blur*h,P.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ae(f,Ee,n,i),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Le(l,Te),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Te.offsetX+r.x*h,Te.offsetY+r.y*u,r.blur*h),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ae(f,Te,n,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,c,l,"source-out"),s=l),f.fillWorld(s,P.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:We}=w;function Oe(t,e,i,s,n,a){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),De(t,e,i,1)}(t,i,s,n);break;case"opacity-path":De(t,i,s,a);break;case"path":i.restore()}}function Pe(t){return t.getSameCanvas(!1,!0)}function De(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}M.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(o&&(Oe(this,o,t,n,s,a),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=Pe(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=Pe(t)),n||(n=Pe(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||We(i,e)||i.__render(n||t,e);Oe(this,o,t,n,s,a)};const Ie=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Me=Ie+"_#~&*+\\=|≮≯≈≠=…",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 Fe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ue=Fe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ye=Fe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ge=Fe(Ie),Ne=Fe(Me),je=Fe("- —/~|┆·");var qe;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(qe||(qe={}));const{Letter:Xe,Single:Ve,Before:He,After:Qe,Symbol:Ze,Break:$e}=qe;function Je(t){return Ue[t]?Xe:je[t]?$e:Ye[t]?He:Ge[t]?Qe:Ne[t]?Ze:ze.test(t)?Ve:Xe}const Ke={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ti(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:ei}=Ke,{Letter:ii,Single:si,Before:ni,After:ai,Symbol:oi,Break:ri}=qe;let di,li,ci,hi,ui,fi,pi,gi,_i,wi,yi,mi,vi,xi,bi,Si,Bi,ki=[];function Ri(t,e){_i&&!gi&&(gi=_i),di.data.push({char:t,width:e}),ci+=e}function Ei(){hi+=ci,di.width=ci,li.words.push(di),di={data:[]},ci=0}function Ai(){xi&&(bi.paraNumber++,li.paraStart=!0,xi=!1),_i&&(li.startCharSize=gi,li.endCharSize=_i,gi=0),li.width=hi,Si.width?ei(li):Bi&&Li(),ki.push(li),li={words:[]},hi=0}function Li(){hi>(bi.maxWidth||0)&&(bi.maxWidth=hi)}const{top:Ti,right:Ci,bottom:Wi,left:Oi}=C;function Pi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Di={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(s=l[Oi],a-=l[Ci]+l[Oi]):i.autoSizeAlign||(s=l[Oi]),o?(n=l[Ti],o-=l[Ti]+l[Wi]):i.autoSizeAlign||(n=l[Ti]));const c={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){bi=t,ki=t.rows,Si=t.bounds,Bi=!Si.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:d,height:l}=Si;if(d||l||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;xi=!0,yi=null,gi=pi=_i=ci=hi=0,di={data:[]},li={words:[]},n&&(i=[...i]);for(let s=0,l=i.length;s<l;s++)fi=i[s],"\n"===fi?(ci&&Ei(),li.paraEnd=!0,Ai(),xi=!0):(wi=Je(fi),wi===ii&&"none"!==o&&(fi=ti(fi,o,!ci)),pi=r.measureText(fi).width,n&&(n<0&&(_i=pi),pi+=n),mi=wi===si&&(yi===si||yi===ii)||yi===si&&wi!==ai,vi=!(wi!==ni&&wi!==si||yi!==oi&&yi!==ai),ui=xi&&a?d-a:d,t&&d&&hi+ci+pi>ui&&(e?(ci&&Ei(),hi&&Ai()):(vi||(vi=wi===ii&&yi==ai),mi||vi||wi===ri||wi===ni||wi===si||ci+pi>ui?(ci&&Ei(),hi&&Ai()):hi&&Ai()))," "===fi&&!0!==xi&&hi+ci===0||(wi===ri?(" "===fi&&ci&&Ei(),Ri(fi,pi),Ei()):mi||vi?(ci&&Ei(),Ri(fi,pi)):Ri(fi,pi)),yi=wi);ci&&Ei(),hi&&Ai(),ki.length>0&&(ki[ki.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{bi.paraNumber++,hi=r.measureText(t).width,ki.push({x:a||0,text:t,width:hi,paraStart:!0}),Bi&&Li()}))}(c,t,i),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Pi(e,"x",t[Oi]);break;case"right":Pi(e,"x",-t[Ci])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Pi(e,"y",t[Ti]);break;case"bottom":Pi(e,"y",-t[Wi])}}(l,c,i,a,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),y=o;if(d&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);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=n;o<c;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!d)switch(l){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<s.x&&(s.x=v),x>s.width&&(s.width=x),d&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,d,l,c,h,u;s.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,u=t.words.length,d=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=o||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,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,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==n||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,i,a),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=s+n-l;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<c));s--){if(d<c&&" "!==t.char||!s){e.data.splice(s+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,s,a),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=P.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(c,i),c}};const Ii={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(z,Di),Object.assign(P,Ii),Object.assign(O,bt),Object.assign(W,ne),Object.assign(D,Se),Object.assign(F,Ce);try{wx&&N(0,wx)}catch(t){}export{et as Layouter,U as LeaferCanvas,st as Renderer,j as Watcher,N as useCanvas};
|
|
2
2
|
//# sourceMappingURL=miniapp.esm.min.js.map
|