@leafer-draw/worker 2.0.1 → 2.0.3

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.
@@ -1,8 +1,8 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, isObject, BoundsHelper, FourNumberHelper, Matrix, isUndefined, isString, ImageEvent, MatrixHelper, MathHelper, AlignHelper, PointHelper, isNumber, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
1
+ import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, isObject, BoundsHelper, FourNumberHelper, Matrix, isUndefined, isString, ImageEvent, MatrixHelper, MathHelper, AlignHelper, PointHelper, isNumber, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
2
2
 
3
3
  export * from "@leafer/core";
4
4
 
5
- export { LeaferImage } from "@leafer/core";
5
+ export { LeaferFilm, LeaferImage, LeaferVideo } from "@leafer/core";
6
6
 
7
7
  import { Paint, PaintImage, ColorConvert, PaintGradient, Effect, Group, TextConvert } from "@leafer-ui/draw";
8
8
 
@@ -17,6 +17,39 @@ var PathNodeHandleType;
17
17
  PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
18
18
  })(PathNodeHandleType || (PathNodeHandleType = {}));
19
19
 
20
+ function __awaiter(thisArg, _arguments, P, generator) {
21
+ function adopt(value) {
22
+ return value instanceof P ? value : new P(function(resolve) {
23
+ resolve(value);
24
+ });
25
+ }
26
+ return new (P || (P = Promise))(function(resolve, reject) {
27
+ function fulfilled(value) {
28
+ try {
29
+ step(generator.next(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ }
34
+ function rejected(value) {
35
+ try {
36
+ step(generator["throw"](value));
37
+ } catch (e) {
38
+ reject(e);
39
+ }
40
+ }
41
+ function step(result) {
42
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
43
+ }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ }
47
+
48
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
49
+ var e = new Error(message);
50
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
51
+ };
52
+
20
53
  class LeaferCanvas extends LeaferCanvasBase {
21
54
  get allowBackgroundColor() {
22
55
  return true;
@@ -41,8 +74,6 @@ canvasPatch(OffscreenCanvasRenderingContext2D.prototype);
41
74
 
42
75
  canvasPatch(Path2D.prototype);
43
76
 
44
- const {mineType: mineType} = FileHelper;
45
-
46
77
  Object.assign(Creator, {
47
78
  canvas: (options, manager) => new LeaferCanvas(options, manager),
48
79
  image: options => new LeaferImage(options)
@@ -53,7 +84,7 @@ function useCanvas(_canvasType, _power) {
53
84
  createCanvas: (width, height) => new OffscreenCanvas(width, height),
54
85
  canvasToDataURL: (canvas, type, quality) => new Promise((resolve, reject) => {
55
86
  canvas.convertToBlob({
56
- type: mineType(type),
87
+ type: FileHelper.mimeType(type),
57
88
  quality: quality
58
89
  }).then(blob => {
59
90
  var reader = new FileReader;
@@ -65,14 +96,14 @@ function useCanvas(_canvasType, _power) {
65
96
  });
66
97
  }),
67
98
  canvasToBolb: (canvas, type, quality) => canvas.convertToBlob({
68
- type: mineType(type),
99
+ type: FileHelper.mimeType(type),
69
100
  quality: quality
70
101
  }),
71
102
  canvasSaveAs: (_canvas, _filename, _quality) => new Promise(resolve => resolve()),
72
103
  download(_url, _filename) {
73
104
  return undefined;
74
105
  },
75
- loadImage(src) {
106
+ loadImage(src, _crossOrigin, _leaferImage) {
76
107
  return new Promise((resolve, reject) => {
77
108
  let req = new XMLHttpRequest;
78
109
  req.open("GET", Platform.image.getRealURL(src), true);
@@ -87,6 +118,13 @@ function useCanvas(_canvasType, _power) {
87
118
  req.onerror = e => reject(e);
88
119
  req.send();
89
120
  });
121
+ },
122
+ loadContent(url_1) {
123
+ return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
124
+ const response = yield fetch(url);
125
+ if (!response.ok) throw new Error(`${response.status}`);
126
+ return yield response[responseType]();
127
+ });
90
128
  }
91
129
  };
92
130
  Platform.canvas = Creator.canvas();
@@ -586,7 +624,7 @@ class Renderer {
586
624
  getCellList() {
587
625
  return undefined;
588
626
  }
589
- addBlock(block) {
627
+ addBlock(block, _leafList) {
590
628
  if (!this.updateBlocks) this.updateBlocks = [];
591
629
  this.updateBlocks.push(block);
592
630
  }
@@ -634,7 +672,8 @@ class Renderer {
634
672
  __onLayoutEnd(event) {
635
673
  if (event.data) event.data.map(item => {
636
674
  let empty;
637
- if (item.updatedList) item.updatedList.list.some(leaf => {
675
+ const {updatedList: updatedList} = item;
676
+ if (updatedList) updatedList.list.some(leaf => {
638
677
  empty = !leaf.__world.width || !leaf.__world.height;
639
678
  if (empty) {
640
679
  if (!leaf.isLeafer) debug.tip(leaf.innerName, ": empty");
@@ -642,7 +681,7 @@ class Renderer {
642
681
  }
643
682
  return empty;
644
683
  });
645
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
684
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
646
685
  });
647
686
  }
648
687
  emitRender(type, bounds, options) {
@@ -707,8 +746,8 @@ function fills(fills, ui, canvas, renderOptions) {
707
746
  canvas.save();
708
747
  if (item.transform) canvas.transform(item.transform);
709
748
  if (originPaint.scaleFixed) {
710
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
711
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
749
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
750
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
712
751
  }
713
752
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
714
753
  fillPathOrText(ui, canvas, renderOptions);
@@ -982,11 +1021,14 @@ function compute(attrName, ui) {
982
1021
  function getLeafPaint(attrName, paint, ui) {
983
1022
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
984
1023
  let leafPaint;
985
- const {boxBounds: boxBounds} = ui.__layout;
986
- switch (paint.type) {
1024
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1025
+ switch (type) {
987
1026
  case "image":
1027
+ case "film":
1028
+ case "video":
988
1029
  if (!paint.url) return undefined;
989
1030
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1031
+ if (type !== "image") PaintImage[type](leafPaint);
990
1032
  break;
991
1033
 
992
1034
  case "linear":
@@ -1002,7 +1044,7 @@ function getLeafPaint(attrName, paint, ui) {
1002
1044
  break;
1003
1045
 
1004
1046
  case "solid":
1005
- const {type: type, color: color, opacity: opacity} = paint;
1047
+ const {color: color, opacity: opacity} = paint;
1006
1048
  leafPaint = {
1007
1049
  type: type,
1008
1050
  style: ColorConvert.string(color, opacity)
@@ -1046,7 +1088,7 @@ const {isSame: isSame} = BoundsHelper;
1046
1088
 
1047
1089
  function image(ui, attrName, paint, boxBounds, firstUse) {
1048
1090
  let leafPaint, event;
1049
- const image = ImageManager.get(paint);
1091
+ const image = ImageManager.get(paint, paint.type);
1050
1092
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1051
1093
  leafPaint = cache.leafPaint;
1052
1094
  } else {
@@ -1107,8 +1149,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1107
1149
  }
1108
1150
 
1109
1151
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1110
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1111
- const data = ui.__;
1152
+ const data = ui.__;
1153
+ if (attrName === "fill" && !data.__naturalWidth) {
1112
1154
  data.__naturalWidth = image.width / data.pixelRatio;
1113
1155
  data.__naturalHeight = image.height / data.pixelRatio;
1114
1156
  if (data.__autoSide) {
@@ -1120,7 +1162,13 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1120
1162
  return false;
1121
1163
  }
1122
1164
  }
1123
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
1165
+ if (!leafPaint.data) {
1166
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
1167
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1168
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1169
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1170
+ }
1171
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
1124
1172
  return true;
1125
1173
  }
1126
1174
 
@@ -1163,7 +1211,7 @@ function getPatternData(paint, box, image) {
1163
1211
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1164
1212
  if (paint.mode === "strench") paint.mode = "stretch";
1165
1213
  const {width: width, height: height} = image;
1166
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
1214
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
1167
1215
  const sameBox = box.width === width && box.height === height;
1168
1216
  const data = {
1169
1217
  mode: mode
@@ -1226,8 +1274,6 @@ function getPatternData(paint, box, image) {
1226
1274
  data.scaleX = scaleX;
1227
1275
  data.scaleY = scaleY;
1228
1276
  }
1229
- if (opacity && opacity < 1) data.opacity = opacity;
1230
- if (filters) data.filters = filters;
1231
1277
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1232
1278
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
1233
1279
  type: "x",
@@ -1258,7 +1304,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1258
1304
 
1259
1305
  function stretchMode(data, box, scaleX, scaleY) {
1260
1306
  const transform = get$2(), {x: x, y: y} = box;
1261
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1307
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1262
1308
  scaleHelper(transform, scaleX, scaleY);
1263
1309
  data.transform = transform;
1264
1310
  }
@@ -1330,39 +1376,6 @@ function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
1330
1376
  translate(transform, box.x + x, box.y + y);
1331
1377
  }
1332
1378
 
1333
- function __awaiter(thisArg, _arguments, P, generator) {
1334
- function adopt(value) {
1335
- return value instanceof P ? value : new P(function(resolve) {
1336
- resolve(value);
1337
- });
1338
- }
1339
- return new (P || (P = Promise))(function(resolve, reject) {
1340
- function fulfilled(value) {
1341
- try {
1342
- step(generator.next(value));
1343
- } catch (e) {
1344
- reject(e);
1345
- }
1346
- }
1347
- function rejected(value) {
1348
- try {
1349
- step(generator["throw"](value));
1350
- } catch (e) {
1351
- reject(e);
1352
- }
1353
- }
1354
- function step(result) {
1355
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1356
- }
1357
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1358
- });
1359
- }
1360
-
1361
- typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
1362
- var e = new Error(message);
1363
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1364
- };
1365
-
1366
1379
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1367
1380
 
1368
1381
  const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
@@ -1380,10 +1393,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1380
1393
  }
1381
1394
 
1382
1395
  function createPattern(paint, ui, canvas, renderOptions) {
1383
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1396
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1384
1397
  if (paint.patternId !== id && !ui.destroyed) {
1385
1398
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1386
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1399
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1387
1400
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1388
1401
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1389
1402
  width *= scaleX;
@@ -1399,7 +1412,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1399
1412
  if (transform) copy$1(imageMatrix, transform);
1400
1413
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1401
1414
  }
1402
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1415
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1403
1416
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1404
1417
  paint.style = pattern;
1405
1418
  paint.patternId = id;
@@ -1420,15 +1433,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1420
1433
  }
1421
1434
 
1422
1435
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1423
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1436
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1424
1437
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1425
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1438
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1426
1439
  return false;
1427
1440
  } else {
1428
1441
  if (drawImage) {
1429
1442
  if (data.repeat) {
1430
1443
  drawImage = false;
1431
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1444
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1432
1445
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1433
1446
  }
1434
1447
  }
@@ -1446,20 +1459,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1446
1459
  }
1447
1460
  }
1448
1461
 
1449
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1450
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1451
- let {width: width, height: height} = image, clipUI;
1452
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1462
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1463
+ const {data: data, image: image, complex: complex} = paint;
1464
+ let {width: width, height: height} = image;
1465
+ if (complex) {
1466
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1453
1467
  canvas.save();
1454
- clipUI && canvas.clipUI(ui);
1468
+ complex === 2 && canvas.clipUI(ui);
1455
1469
  blendMode && (canvas.blendMode = blendMode);
1456
1470
  opacity && (canvas.opacity *= opacity);
1457
1471
  transform && canvas.transform(transform);
1458
- canvas.drawImage(view, 0, 0, width, height);
1472
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1459
1473
  canvas.restore();
1460
1474
  } else {
1461
1475
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1462
- canvas.drawImage(view, 0, 0, width, height);
1476
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1463
1477
  }
1464
1478
  }
1465
1479
 
@@ -1489,6 +1503,7 @@ function recycleImage(attrName, data) {
1489
1503
  if (!recycleMap) recycleMap = {};
1490
1504
  recycleMap[url] = true;
1491
1505
  ImageManager.recyclePaint(paint);
1506
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf);
1492
1507
  if (image.loading) {
1493
1508
  if (!input) {
1494
1509
  input = data.__input && data.__input[attrName] || [];
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as a,LeaferImage as n,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as m,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as R,Matrix as E,isUndefined as L,isString as T,ImageEvent as A,MatrixHelper as P,MathHelper as O,AlignHelper as W,PointHelper as C,isNumber as M,getMatrixData as D,AroundHelper as I,Direction4 as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{Paint as Y,PaintImage as X,ColorConvert as U,PaintGradient as z,Effect as G,Group as q,TextConvert as N}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var j;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(j||(j={}));class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:V}=s;function Q(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,a)=>{t.convertToBlob({type:V(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>a(t),e.readAsDataURL(t)}).catch(t=>{a(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:V(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let a=new XMLHttpRequest;a.open("GET",e.image.getRealURL(t),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then(t=>{i(t)}).catch(t=>{s(t)})},a.onerror=t=>s(t),a.send()})},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new H(t,e),image:t=>new n(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:Z}=navigator;Z.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),Z.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):Z.indexOf("Mac")>-1?e.os="Mac":Z.indexOf("Linux")>-1&&(e.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=f,{pushAllChildBranch:et,pushAllParent:it}=g;const{worldBounds:st}=p;class at{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),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:nt,updateAllChange:rt}=f,ot=m.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(a,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;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||K(s[t])}K(i)}})}(this.__levelList),function(t){t.list.forEach(tt)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(n,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=x,n=this.getBlocks(new o(e));e.emitEvent(new x(i,n,this.times)),lt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,n,this.times)),e.emitEvent(new x(a,n,this.times)),this.addBlocks(n),v.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(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],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=m.get("Renderer");class ct{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,dt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),a=new _(s);i.save(),s.spread(ct.clipSpread).ceil();const{ceilPartPixel:n}=this.config;i.clipWorld(s,n),i.clearWorld(s,n),this.__render(s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:s,target:a}=this,n=t.includes(a.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(a,s,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}getCellList(){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);const{frames:a}=this;a.length>30&&a.shift(),a.push(t),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ht(t,e,i){t.__.__font?Y.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ut(t,e,i,s,a){const n=i.__;k(t)?Y.drawStrokesStyle(t,e,!1,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&Y.strokeArrow(t,i,s,a)}function ft(t,e,i,s,a){const n=i.__;k(t)?Y.drawStrokesStyle(t,e,!0,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),Y.drawTextStroke(i,s,a))}function gt(t,e,i,s,a){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ft(t,2,i,n,a),n.blendMode="outside"===e?"destination-out":"destination-in",Y.fillText(i,n,a),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}ct.clipSpread=10,Object.assign(a,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ct(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=lt.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:pt,copyAndSpread:_t,toOuterOf:wt,getOuterOf:mt,getByMove:yt,move:xt,getIntersectData:vt}=B,St={};let bt;const{stintSet:kt}=l,{hasTransparent:Bt}=U;function Rt(t,e,i){if(!k(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:a}=i.__layout;switch(e.type){case"image":if(!e.url)return;s=X.image(i,t,e,a,!bt||!bt[e.url]);break;case"linear":s=z.linearGradient(e,a);break;case"radial":s=z.radialGradient(e,a);break;case"angular":s=z.conicGradient(e,a);break;case"solid":const{type:n,color:r,opacity:o}=e;s={type:n,style:U.string(r,o)};break;default:L(e.r)||(s={type:"solid",style:U.string(e)})}if(s&&(s.originPaint=e,T(s.style)&&Bt(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const Et={compute:function(t,e){const i=e.__,s=[];let a,n,r,o=i.__input[t];w(o)||(o=[o]),bt=X.recycleImage(t,i);for(let i,a=0,n=o.length;a<n;a++)(i=Rt(t,o[a],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(a=!0),n=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",a),kt(i,"__isTransparentFill",n)):(kt(i,"__isAlphaPixelStroke",a),kt(i,"__isTransparentStroke",n),kt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,ht(e,i,s)},fills:function(t,e,i,s){let a,n,r;for(let o=0,l=t.length;o<l;o++){if(a=t[o],n=a.originPaint,a.image){if(r?r++:r=1,X.checkImage(a,!e.__.__font,e,i,s))continue;if(!a.style){1===r&&a.image.isPlacehold&&e.drawImagePlaceholder(a,i,s);continue}}if(i.fillStyle=a.style,a.transform||n.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===n.scaleFixed||"zoom-in"===n.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}n.blendMode&&(i.blendMode=n.blendMode),ht(e,i,s),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),ht(e,i,s),i.restoreBlendMode()):ht(e,i,s)}},fillPathOrText:ht,fillText:function(t,e,i){const s=t.__,{rows:a,decorationY:n}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=a.length;t<i;t++)r=a[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(n){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const a=e.__;if(a.__strokeWidth)if(a.__font)Y.strokeText(t,e,i,s);else switch(a.strokeAlign){case"center":ut(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),ut(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const a=e.__;if(a.__fillAfterStroke)ut(t,2,e,i,s);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),ut(t,2,e,r,s),r.clipUI(a),r.clearWorld(n),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Y.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":ft(t,1,e,i,s);break;case"inside":gt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?ft(t,2,e,i,s):gt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,a=t.__.__textDrawData;const{rows:n,decorationY:r}=a;for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=a;n.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,a,n){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!X.checkImage(r,!1,s,a,n))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.originPaint.blendMode?(a.saveBlendMode(r.originPaint.blendMode),i?Y.drawTextStroke(s,a,n):a.stroke(),a.restoreBlendMode()):i?Y.drawTextStroke(s,a,n):a.stroke()}},shape:function(t,i,s){const a=i.getSameCanvas(),n=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;wt(o.strokeSpread?(_t(St,o.boxBounds,o.strokeSpread),St):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=a,d=f=l,c=r;else{let a;if(e.fullImageShadow)a=l;else{const t=o.renderShapeSpread?pt(n,R.swapAndScale(o.renderShapeSpread,p,_)):n;a=vt(t,l)}u=n.getFitMatrix(a);let{a:w,d:m}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=m),f=mt(l,u),d=yt(f,-u.e,-u.f),c=mt(r,u),xt(c,-u.e,-u.f);const y=s.matrix;y?(h=new E(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(a,s),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Lt,Tt=new _;const{isSame:At}=B;function Pt(t,e,i,s,a,n){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 a.data||X.createData(a,s,i,n),!0}function Ot(t,e){Mt(t,A.LOAD,e)}function Wt(t,e){Mt(t,A.LOADED,e)}function Ct(t,e,i){e.error=i,t.forceUpdate("surface"),Mt(t,A.ERROR,e)}function Mt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Dt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:It,translate:Ft}=P,Yt=new _,Xt={},Ut={};function zt(t,e,i,s){const a=T(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let Gt={},qt=D();const{get:Nt,set:jt,rotateOfOuter:Ht,translate:Vt,scaleOfOuter:Qt,multiplyParent:Zt,scale:$t,rotate:Jt,skew:Kt}=P;function te(t,e,i,s,a,n,r,o){r&&Jt(t,r),o&&Kt(t,o.x,o.y),a&&$t(t,a,n),Vt(t,e.x+i,e.y+s)}function ee(t,e,i,s){return new(i||(i=Promise))(function(a,n){function r(t){try{l(s.next(t))}catch(t){n(t)}}function o(t){try{l(s.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ie,scale:se,copy:ae}=P,{getFloorScale:ne}=O,{abs:re}=Math;const oe={image:function(t,e,i,s,a){let n,r;const o=S.get(i);return Lt&&i===Lt.paint&&At(s,Lt.boxBounds)?n=Lt.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Lt=o.use>1?{leafPaint:n,paint:i,boxBounds:Tt.set(s)}:null),(a||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Pt(t,e,i,o,n,s),a&&(Ot(t,r),Wt(t,r))):o.error?a&&Ct(t,r,o.error):(a&&(Dt(t,!0),Ot(t,r)),n.loadId=o.load(()=>{Dt(t,!1),t.destroyed||(Pt(t,e,i,o,n,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Wt(t,r)),n.loadId=void 0},e=>{Dt(t,!1),Ct(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,i,s,a,n){const{scaleX:r,scaleY:o}=X.getImageRenderScaleData(t,s,a,n),{image:l,data:d,originPaint:c}=t,{exporting:h,snapshot:u}=n;return!(!d||t.patternId===r+"-"+o&&!h||u)&&(i&&(d.repeat?i=!1:c.changeful||"miniapp"===e.name&&b.isResizing(s)||h||(i=e.image.isLarge(l,r,o)||l.width*r>8096||l.height*o>8096)),i?(s.__.__isFastShadow&&(a.fillStyle=t.style||"#000",a.fill()),X.drawImage(t,r,o,s,a,n),!0):(!t.style||c.sync||h?X.createPattern(t,s,a,n):X.createPatternTask(t,s,a,n),!1))},drawImage:function(t,e,i,s,a,n){const{data:r,image:o}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=r,h=o.getFull(r.filters),u=s.__;let f,{width:g,height:p}=o;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(a.save(),f&&a.clipUI(s),l&&(a.blendMode=l),d&&(a.opacity*=d),c&&a.transform(c),a.drawImage(h,0,0,g,p),a.restore()):(r.scaleX&&(g*=r.scaleX,p*=r.scaleY),a.drawImage(h,0,0,g,p))},getImageRenderScaleData:function(t,e,i,s){const a=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return n&&n.scaleX&&(a.scaleX*=Math.abs(n.scaleX),a.scaleY*=Math.abs(n.scaleY)),a},recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,a,n,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],a=s.image,o=a&&a.url,o&&(n||(n={}),n[o]=!0,S.recyclePaint(s),a.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),a.unload(i[l].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=S.patternTasker.add(()=>ee(this,void 0,void 0,function*(){X.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,s,a){let{scaleX:n,scaleY:r}=X.getImageRenderScaleData(t,i,s,a),o=n+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:s,data:a}=t,{transform:l,gap:d}=a,c=X.getPatternFixScale(t,n,r);let h,u,f,{width:g,height:p}=s;c&&(n*=c,r*=c),g*=n,p*=r,d&&(u=d.x*n/re(a.scaleX||1),f=d.y*r/re(a.scaleY||1)),(l||1!==n||1!==r)&&(n*=ne(g+(u||0)),r*=ne(p+(f||0)),h=ie(),l&&ae(h,l),se(h,1/n,1/r));const _=s.getCanvas(g,p,a.opacity,a.filters,u,f,i.leafer&&i.leafer.config.smooth,a.interlace),w=s.getPattern(_,a.repeat||e.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,s){const{image:a}=t;let n,r=e.image.maxPatternSize,o=a.width*a.height;return a.isSVG?i>1&&(n=Math.ceil(i)/i):r>o&&(r=o),(o*=i*s)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=X.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=Yt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:a}=i,{opacity:n,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:g,gap:p,filters:_,interlace:w}=t,m=e.width===s&&e.height===a,y={mode:r},x="center"!==o&&(h||0)%180==90;let v,S;switch(B.set(Ut,0,0,x?a:s,x?s:a),r&&"cover"!==r&&"fit"!==r?((d||c)&&(O.getScaleData(d,c,i,Xt),v=Xt.scaleX,S=Xt.scaleY),(o||p||g)&&(v&&B.scale(Ut,v,S,!0),o&&W.toPoint(o,Ut,e,Ut,!0,!0))):m&&!h||(v=S=B.getFitScale(e,Ut,"fit"!==r),B.put(e,i,o,v,!1,Ut),B.scale(Ut,v,S,!0)),l&&C.move(Ut,l),r){case"stretch":m?v&&(v=S=void 0):(v=e.width/s,S=e.height/a,X.stretchMode(y,e,v,S));break;case"normal":case"clip":if(Ut.x||Ut.y||v||f||h||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),X.clipMode(y,e,Ut.x,Ut.y,v,S,h,u,t,i),t&&(v=v?v*t:t,S=S?S*i:i)}break;case"repeat":(!m||v||h||u)&&X.repeatMode(y,e,s,a,Ut.x,Ut.y,v,S,h,u,o,t.freeTransform),g||(y.repeat="repeat");const i=k(g);(p||i)&&(y.gap=function(t,e,i,s,a){let n,r;k(t)?(n=t.x,r=t.y):n=r=t;return{x:zt(n,i,a.width,e&&e.x),y:zt(r,s,a.height,e&&e.y)}}(p,i&&g,Ut.width,Ut.height,e));break;default:v&&X.fillOrFitMode(y,e,Ut.x,Ut.y,v,S,h)}return y.transform||(e.x||e.y)&&Ft(y.transform=It(),e.x,e.y),v&&(y.scaleX=v,y.scaleY=S),n&&n<1&&(y.opacity=n),_&&(y.filters=_),g&&(y.repeat=T(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w&&(y.interlace=M(w)||"percent"===w.type?{type:"x",offset:w}:w),y},stretchMode:function(t,e,i,s){const a=Nt(),{x:n,y:r}=e;n||r?Vt(a,n,r):a.onlyScale=!0,$t(a,i,s),t.transform=a},fillOrFitMode:function(t,e,i,s,a,n,r){const o=Nt();Vt(o,e.x+i,e.y+s),$t(o,a,n),r&&Ht(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,a,n,r,o,l,d){const c=Nt();te(c,e,i,s,a,n,r,o),l&&(r||o?(jt(qt),Qt(qt,e,l,d),Zt(c,qt)):Qt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,s,a,n,r,o,l,d,c,h){const u=Nt();if(h)te(u,e,a,n,r,o,l,d);else{if(l)if("center"===c)Ht(u,{x:i/2,y:s/2},l);else switch(Jt(u,l),l){case 90:Vt(u,s,0);break;case 180:Vt(u,i,s);break;case 270:Vt(u,0,i)}Gt.x=e.x+a,Gt.y=e.y+n,Vt(u,Gt.x,Gt.y),r&&Qt(u,Gt,r,o)}t.transform=u}},{toPoint:le}=I,{hasTransparent:de}=U,ce={},he={};function ue(t,e,i,s){if(i){let a,n,r,o;for(let t=0,l=i.length;t<l;t++)a=i[t],T(a)?(r=t/(l-1),n=U.string(a,s)):(r=a.offset,n=U.string(a.color,s)),e.addColorStop(r,n),!o&&de(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:fe,getDistance:ge}=C,{get:pe,rotateOfOuter:_e,scaleOfOuter:we}=P,{toPoint:me}=I,ye={},xe={};function ve(t,e,i,s,a){let n;const{width:r,height:o}=t;if(r!==o||s){const t=fe(e,i);n=pe(),a?(we(n,e,r/o*(s||1),1),_e(n,e,t+90)):(we(n,e,1,r/o*(s||1)),_e(n,e,t))}return n}const{getDistance:Se}=C,{toPoint:be}=I,ke={},Be={};const Re={linearGradient:function(t,i){let{from:s,to:a,type:n,opacity:r}=t;le(s||"top",i,ce),le(a||"bottom",i,he);const o=e.canvas.createLinearGradient(ce.x,ce.y,he.x,he.y),l={type:n,style:o};return ue(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;me(s||"center",i,ye),me(a||"bottom",i,xe);const l=e.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,ge(ye,xe)),d={type:n,style:l};ue(d,l,t.stops,r);const c=ve(i,ye,xe,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;be(s||"center",i,ke),be(a||"bottom",i,Be);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,ke.x,ke.y):e.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Se(ke,Be)),d={type:n,style:l};ue(d,l,t.stops,r);const c=ve(i,ke,Be,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:ve},{copy:Ee,move:Le,toOffsetOutBounds:Te}=B,{max:Ae,abs:Pe}=Math,Oe={},We=new E,Ce={};function Me(t,e){let i,s,a,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=1.5*(t.blur||0),a=Pe(t.spread||0),r=Ae(r,a+n-s),o=Ae(o,a+n+i),l=Ae(l,a+n+s),d=Ae(d,a+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function De(t,i,s){const{shapeBounds:a}=s;let n,r;e.fullImageShadow?(Ee(Oe,t.bounds),Le(Oe,i.x-a.x,i.y-a.y),n=t.bounds,r=Oe):(n=a,r=i),t.copyWorld(s.canvas,n,r)}const{toOffsetOutBounds:Ie}=B,Fe={};const Ye=Me;const Xe={shadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Te(l,Ce,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Ce.offsetX+(r.x||0)*h*w,Ce.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w,U.string(r.color)),a=G.getShadowTransform(t,g,i,r,Ce,w),a&&g.setTransform(a),De(g,Ce,i),a&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),s=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ie(l,Fe,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(Fe.offsetX+(r.x||0)*h*w,Fe.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w),a=G.getShadowTransform(t,g,i,r,Fe,w,!0),a&&g.setTransform(a),De(g,Fe,i),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),s=n):(g.copyWorld(i.canvas,c,l,"source-out"),s=d),g.fillWorld(s,U.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.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){},getShadowRenderSpread:Me,getShadowTransform:function(t,e,i,s,a,n,r){if(s.spread){const i=2*s.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return We.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/o,1+i/l),We}},isTransformShadow(t){},getInnerShadowSpread:Ye},{excludeRenderBounds:Ue}=p;let ze;function Ge(t,e,i,s,a,n,r,o){switch(e){case"grayscale":ze||(ze=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),n&&s.recycle(r);Ne(t,e,i,1,a,n)}(t,i,s,a,r,o);break;case"opacity-path":Ne(t,i,s,n,r,o);break;case"path":o&&i.restore()}}function qe(t){return t.getSameCanvas(!1,!0)}function Ne(t,e,i,s,a,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,a),n?i.recycle(r):i.clearWorld(r)}q.prototype.__renderMask=function(t,e){let i,s,a,n,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(Ge(this,r,t,a,s,n,void 0,!0),s=a=null),"clipping"!==o&&"clipping-path"!==o||Ue(i,e)||i.__render(t,e),n=i.__.opacity,ze=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",a||(a=qe(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=qe(t)),a||(a=qe(t)),i.__render(s,e));continue}const c=1===n&&i.__.__blendMode;c&&Ge(this,r,t,a,s,n,void 0,!1),Ue(i,e)||i.__render(a||t,e),c&&Ge(this,r,t,a,s,n,c,!1)}Ge(this,r,t,a,s,n,void 0,!0)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",He=je+"_#~&*+\\=|≮≯≈≠=…",Ve=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 Qe(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Ze=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Je=Qe(je),Ke=Qe(He),ti=Qe("- —/~|┆·");var ei;!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"}(ei||(ei={}));const{Letter:ii,Single:si,Before:ai,After:ni,Symbol:ri,Break:oi}=ei;function li(t){return Ze[t]?ii:ti[t]?oi:$e[t]?ai:Je[t]?ni:Ke[t]?ri:Ve.test(t)?si:ii}const di={trimRight(t){const{words:e}=t;let i,s=0,a=e.length;for(let n=a-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)s++,t.width-=i.width;s&&e.splice(a-s,s)}};function ci(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:hi}=di,{Letter:ui,Single:fi,Before:gi,After:pi,Symbol:_i,Break:wi}=ei;let mi,yi,xi,vi,Si,bi,ki,Bi,Ri,Ei,Li,Ti,Ai,Pi,Oi,Wi,Ci,Mi=[];function Di(t,e){Ri&&!Bi&&(Bi=Ri),mi.data.push({char:t,width:e}),xi+=e}function Ii(){vi+=xi,mi.width=xi,yi.words.push(mi),mi={data:[]},xi=0}function Fi(){Pi&&(Oi.paraNumber++,yi.paraStart=!0,Pi=!1),Ri&&(yi.startCharSize=Bi,yi.endCharSize=Ri,Bi=0),yi.width=vi,Wi.width?hi(yi):Ci&&Yi(),Mi.push(yi),yi={words:[]},vi=0}function Yi(){vi>(Oi.maxWidth||0)&&(Oi.maxWidth=vi)}const{top:Xi,right:Ui,bottom:zi,left:Gi}=F;function qi(t,e,i){const{bounds:s,rows:a}=t;s[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const Ni={getDrawData:function(t,i){T(t)||(t=String(t));let s=0,a=0,n=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(n?(s=o[Gi],n-=o[Ui]+o[Gi],!n&&(n=.01)):i.autoSizeAlign||(s=o[Gi]),r?(a=o[Xi],r-=o[Xi]+o[zi],!r&&(r=.01)):i.autoSizeAlign||(a=o[Xi]));const l={bounds:{x:s,y:a,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,s){Oi=t,Mi=t.rows,Wi=t.bounds,Ci=!Wi.width&&!s.autoSizeAlign;const{__letterSpacing:a,paraIndent:n,textCase:r}=s,{canvas:o}=e,{width:l}=Wi;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap;Pi=!0,Li=null,Bi=ki=Ri=xi=vi=0,mi={data:[]},yi={words:[]},a&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)bi=i[s],"\n"===bi?(xi&&Ii(),yi.paraEnd=!0,Fi(),Pi=!0):(Ei=li(bi),Ei===ui&&"none"!==r&&(bi=ci(bi,r,!xi)),ki=o.measureText(bi).width,a&&(a<0&&(Ri=ki),ki+=a),Ti=Ei===fi&&(Li===fi||Li===ui)||Li===fi&&Ei!==pi,Ai=!(Ei!==gi&&Ei!==fi||Li!==_i&&Li!==pi),Si=Pi&&n?l-n:l,t&&l&&vi+xi+ki>Si&&(e?(xi&&Ii(),vi&&Fi()):(Ai||(Ai=Ei===ui&&Li==pi),Ti||Ai||Ei===wi||Ei===gi||Ei===fi||xi+ki>Si?(xi&&Ii(),vi&&Fi()):vi&&Fi()))," "===bi&&!0!==Pi&&vi+xi===0||(Ei===wi?(" "===bi&&xi&&Ii(),Di(bi,ki),Ii()):Ti||Ai?(xi&&Ii(),Di(bi,ki)):Di(bi,ki)),Li=Ei);xi&&Ii(),vi&&Fi(),Mi.length>0&&(Mi[Mi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Oi.paraNumber++,vi=o.measureText(t).width,Mi.push({x:n||0,text:t,width:vi,paraStart:!0}),Ci&&Yi()})}(l,t,i),o&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":qi(e,"x",t[Gi]);break;case"right":qi(e,"x",-t[Ui])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":qi(e,"y",t[Xi]);break;case"bottom":qi(e,"y",-t[zi])}}(o,l,i,n,r),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=n*a+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(e.__autoHeight?w:_,n),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}m+=g;let y,x,v,S=p||u?p:t.maxWidth;for(let r=0,c=a;r<c;r++){if(y=i[r],y.x=f,y.width<p||y.width>p&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=n,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(l,i),i.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n,__letterSpacing:r}=e,o=i&&a.includes("both"),l=o||i&&a.includes("justify"),d=l&&a.includes("letter");let c,h,u,f,g,p,_,w,m,y;s.forEach(t=>{t.words&&(g=n&&t.paraStart?n:0,w=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,s,a){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(l,i,n),l.overflow&&function(t,i,s,a){const{rows:n,overflow:r}=t;let{textOverflow:o}=i;if(r&&n.splice(r),a&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=s+a-d;("none"===i.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<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:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,n),"none"!==i.textDecoration&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,k(n)?(i=n.type,n.color&&(t.decorationColor=U.string(n.color)),n.offset&&(s=Math.min(.3*a,Math.max(n.offset,.15*-a)))):i=n,i){case"under":t.decorationY=[.15*a+s];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a+s,.35*-a]}}(l,i),l}};const ji={string:function(t,e){if(!t)return"#000";const i=M(e)&&e<1;if(T(t)){if(!i||!U.object)return t;t=U.object(t)}let s=L(t.a)?1:t.a;i&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}};Object.assign(N,Ni),Object.assign(U,ji),Object.assign(Y,Et),Object.assign(X,oe),Object.assign(z,Re),Object.assign(G,Xe),Q();export{lt as Layouter,H as LeaferCanvas,j as PathNodeHandleType,ct as Renderer,$ as Watcher,Q as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as a,LeaferImage as s,defineKey as n,FileHelper as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as m,Debug as w,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as R,Matrix as E,isUndefined as L,isString as T,ImageEvent as A,MatrixHelper as P,MathHelper as O,AlignHelper as C,PointHelper as W,isNumber as M,getMatrixData as D,AroundHelper as I,Direction4 as F}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as Y,PaintImage as X,ColorConvert as U,PaintGradient as G,Effect as q,Group as z,TextConvert as N}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var j;function H(t,e,i,a){return new(i||(i=Promise))(function(s,n){function r(t){try{l(a.next(t))}catch(t){n(t)}}function o(t){try{l(a.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(j||(j={})),"function"==typeof SuppressedError&&SuppressedError;class V extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function Q(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((a,s)=>{t.convertToBlob({type:r.mimeType(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)}).catch(t=>{s(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:r.mimeType(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:(t,i,a)=>new Promise((i,a)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then(t=>{i(t)}).catch(t=>{a(t)})},s.onerror=t=>a(t),s.send()}),loadContent(t){return H(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype),Object.assign(a,{canvas:(t,e)=>new V(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},n(e,"devicePixelRatio",{get:()=>1});const{userAgent:Z}=navigator;Z.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),Z.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):Z.indexOf("Mac")>-1?e.os="Mac":Z.indexOf("Linux")>-1&&(e.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=f,{pushAllChildBranch:et,pushAllParent:it}=g;const{worldBounds:at}=p;class st{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,m(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),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:nt,updateAllChange:rt}=f,ot=w.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:s,LAYOUT:n,AFTER:r}=x,o=this.getBlocks(a);o.forEach(t=>t.setBefore()),i.emitEvent(new x(s,o,this.times)),this.extraBlock=null,a.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))})}(a,this.__levelList),function(t){let e,i,a;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){a=i.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||K(a[t])}K(i)}})}(this.__levelList),function(t){t.list.forEach(tt)}(a),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(n,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=x,n=this.getBlocks(new o(e));e.emitEvent(new x(i,n,this.times)),lt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new x(a,n,this.times)),e.emitEvent(new x(s,n,this.times)),this.addBlocks(n),v.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(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],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=w.get("Renderer");class ct{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,dt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,a=t.getIntersect(i.bounds),s=new _(a);i.save(),a.spread(ct.clipSpread).ceil();const{ceilPartPixel:n}=this.config;i.clipWorld(a,n),i.clearWorld(a,n),this.__render(a,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:a,target:s}=this,n=t.includes(s.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&a.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(a,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(s,a,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),a.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:a}=this.config;if(a&&t>a)return e.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ht(t,e,i){t.__.__font?Y.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ut(t,e,i,a,s){const n=i.__;k(t)?Y.drawStrokesStyle(t,e,!1,i,a,s):(a.setStroke(t,n.__strokeWidth*e,n),a.stroke()),n.__useArrow&&Y.strokeArrow(t,i,a,s)}function ft(t,e,i,a,s){const n=i.__;k(t)?Y.drawStrokesStyle(t,e,!0,i,a,s):(a.setStroke(t,n.__strokeWidth*e,n),Y.drawTextStroke(i,a,s))}function gt(t,e,i,a,s){const n=a.getSameCanvas(!0,!0);n.font=i.__.__font,ft(t,2,i,n,s),n.blendMode="outside"===e?"destination-out":"destination-in",Y.fillText(i,n,s),n.blendMode="normal",f.copyCanvasByWorld(i,a,n),n.recycle(i.__nowWorld)}ct.clipSpread=10,Object.assign(a,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ct(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,a)=>{}}),e.layout=lt.fullLayout,e.render=function(t,e,i){const a=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,a))};const{getSpread:pt,copyAndSpread:_t,toOuterOf:mt,getOuterOf:wt,getByMove:yt,move:xt,getIntersectData:vt}=B,St={};let bt;const{stintSet:kt}=l,{hasTransparent:Bt}=U;function Rt(t,e,i){if(!k(e)||!1===e.visible||0===e.opacity)return;let a;const{boxBounds:s}=i.__layout,{type:n}=e;switch(n){case"image":case"film":case"video":if(!e.url)return;a=X.image(i,t,e,s,!bt||!bt[e.url]),"image"!==n&&X[n](a);break;case"linear":a=G.linearGradient(e,s);break;case"radial":a=G.radialGradient(e,s);break;case"angular":a=G.conicGradient(e,s);break;case"solid":const{color:r,opacity:o}=e;a={type:n,style:U.string(r,o)};break;default:L(e.r)||(a={type:"solid",style:U.string(e)})}if(a&&(a.originPaint=e,T(a.style)&&Bt(a.style)&&(a.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;a.strokeStyle=e.style}return a}const Et={compute:function(t,e){const i=e.__,a=[];let s,n,r,o=i.__input[t];m(o)||(o=[o]),bt=X.recycleImage(t,i);for(let i,s=0,n=o.length;s<n;s++)(i=Rt(t,o[s],e))&&(a.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=a.length?a:void 0,a.length?(a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(s=!0),n=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",s),kt(i,"__isTransparentFill",n)):(kt(i,"__isAlphaPixelStroke",s),kt(i,"__isTransparentStroke",n),kt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,a){i.fillStyle=t,ht(e,i,a)},fills:function(t,e,i,a){let s,n,r;for(let o=0,l=t.length;o<l;o++){if(s=t[o],n=s.originPaint,s.image){if(r?r++:r=1,X.checkImage(s,!e.__.__font,e,i,a))continue;if(!s.style){1===r&&s.image.isPlacehold&&e.drawImagePlaceholder(s,i,a);continue}}if(i.fillStyle=s.style,s.transform||n.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),n.scaleFixed){const{scaleX:t,scaleY:a}=e.getRenderScaleData(!0,n.scaleFixed,!1);1!==t&&i.scale(t,a)}n.blendMode&&(i.blendMode=n.blendMode),ht(e,i,a),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),ht(e,i,a),i.restoreBlendMode()):ht(e,i,a)}},fillPathOrText:ht,fillText:function(t,e,i){const a=t.__,{rows:s,decorationY:n}=a.__textDrawData;let r;a.__isPlacehold&&a.placeholderColor&&(e.fillStyle=a.placeholderColor);for(let t=0,i=s.length;t<i;t++)r=s[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(n){const{decorationColor:t,decorationHeight:i}=a.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(a=>e.fillRect(t.x,t.y+a,t.width,i)))}},stroke:function(t,e,i,a){const s=e.__;if(s.__strokeWidth)if(s.__font)Y.strokeText(t,e,i,a);else switch(s.strokeAlign){case"center":ut(t,1,e,i,a);break;case"inside":!function(t,e,i,a){i.save(),i.clipUI(e),ut(t,2,e,i,a),i.restore()}(t,e,i,a);break;case"outside":!function(t,e,i,a){const s=e.__;if(s.__fillAfterStroke)ut(t,2,e,i,a);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),ut(t,2,e,r,a),r.clipUI(s),r.clearWorld(n),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,a)}},strokes:function(t,e,i,a){Y.stroke(t,e,i,a)},strokeText:function(t,e,i,a){switch(e.__.strokeAlign){case"center":ft(t,1,e,i,a);break;case"inside":gt(t,"inside",e,i,a);break;case"outside":e.__.__fillAfterStroke?ft(t,2,e,i,a):gt(t,"outside",e,i,a)}},drawTextStroke:function(t,e,i){let a,s=t.__.__textDrawData;const{rows:n,decorationY:r}=s;for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.strokeText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.strokeText(t.char,t.x,a.y)});if(r){const{decorationHeight:t}=s;n.forEach(i=>r.forEach(a=>e.strokeRect(i.x,i.y+a,i.width,t)))}},drawStrokesStyle:function(t,e,i,a,s,n){let r;const o=a.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!X.checkImage(r,!1,a,s,n))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):s.setStroke(r.style,o.__strokeWidth*e,o)}else s.strokeStyle=r.style;r.originPaint.blendMode?(s.saveBlendMode(r.originPaint.blendMode),i?Y.drawTextStroke(a,s,n):s.stroke(),s.restoreBlendMode()):i?Y.drawTextStroke(a,s,n):s.stroke()}},shape:function(t,i,a){const s=i.getSameCanvas(),n=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;mt(o.strokeSpread?(_t(St,o.boxBounds,o.strokeSpread),St):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=s,d=f=l,c=r;else{let s;if(e.fullImageShadow)s=l;else{const t=o.renderShapeSpread?pt(n,R.swapAndScale(o.renderShapeSpread,p,_)):n;s=vt(t,l)}u=n.getFitMatrix(s);let{a:m,d:w}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,a),p*=m,_*=w),f=wt(l,u),d=yt(f,-u.e,-u.f),c=wt(r,u),xt(c,-u.e,-u.f);const y=a.matrix;y?(h=new E(u),h.multiply(y),m*=y.scaleX,w*=y.scaleY):h=u,h.withScale(m,w),a=Object.assign(Object.assign({},a),{matrix:h})}return t.__renderShape(s,a),{canvas:s,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Lt,Tt=new _;const{isSame:At}=B;function Pt(t,e,i,a,s,n){const r=t.__;if("fill"===e&&!r.__naturalWidth&&(r.__naturalWidth=a.width/r.pixelRatio,r.__naturalHeight=a.height/r.pixelRatio,r.__autoSide))return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",r.width),t.setProxyAttr("height",r.height)),!1;if(!s.data){X.createData(s,a,i,n);const{transform:t}=s.data,{opacity:e,blendMode:o}=i,l=t&&!t.onlyScale||r.path||r.cornerRadius;(l||e&&e<1||o)&&(s.complex=!l||2)}return i.filter&&X.applyFilter(s,a,i.filter,t),!0}function Ot(t,e){Mt(t,A.LOAD,e)}function Ct(t,e){Mt(t,A.LOADED,e)}function Wt(t,e,i){e.error=i,t.forceUpdate("surface"),Mt(t,A.ERROR,e)}function Mt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Dt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:It,translate:Ft}=P,Yt=new _,Xt={},Ut={};function Gt(t,e,i,a){const s=T(t)||a?(a?i-a*e:i%e)/((a||Math.floor(i/e))-1):t;return"auto"===t&&s<0?0:s}let qt={},zt=D();const{get:Nt,set:jt,rotateOfOuter:Ht,translate:Vt,scaleOfOuter:Qt,multiplyParent:Zt,scale:$t,rotate:Jt,skew:Kt}=P;function te(t,e,i,a,s,n,r,o){r&&Jt(t,r),o&&Kt(t,o.x,o.y),s&&$t(t,s,n),Vt(t,e.x+i,e.y+a)}const{get:ee,scale:ie,copy:ae}=P,{getFloorScale:se}=O,{abs:ne}=Math;const re={image:function(t,e,i,a,s){let n,r;const o=S.get(i,i.type);return Lt&&i===Lt.paint&&At(a,Lt.boxBounds)?n=Lt.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Lt=o.use>1?{leafPaint:n,paint:i,boxBounds:Tt.set(a)}:null),(s||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Pt(t,e,i,o,n,a),s&&(Ot(t,r),Ct(t,r))):o.error?s&&Wt(t,r,o.error):(s&&(Dt(t,!0),Ot(t,r)),n.loadId=o.load(()=>{Dt(t,!1),t.destroyed||(Pt(t,e,i,o,n,a)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ct(t,r)),n.loadId=void 0},e=>{Dt(t,!1),Wt(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,i,a,s,n){const{scaleX:r,scaleY:o}=X.getImageRenderScaleData(t,a,s,n),l=t.film?t.nowIndex:r+"-"+o,{image:d,data:c,originPaint:h}=t,{exporting:u,snapshot:f}=n;return!(!c||t.patternId===l&&!u||f)&&(i&&(c.repeat?i=!1:h.changeful||t.film||"miniapp"===e.name&&b.isResizing(a)||u||(i=e.image.isLarge(d,r,o)||d.width*r>8096||d.height*o>8096)),i?(a.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),X.drawImage(t,r,o,a,s,n),!0):(!t.style||h.sync||u?X.createPattern(t,a,s,n):X.createPatternTask(t,a,s,n),!1))},drawImage:function(t,e,i,a,s,n){const{data:r,image:o,complex:l}=t;let{width:d,height:c}=o;if(l){const{blendMode:n,opacity:h}=t.originPaint,{transform:u}=r;s.save(),2===l&&s.clipUI(a),n&&(s.blendMode=n),h&&(s.opacity*=h),u&&s.transform(u),o.render(s,0,0,d,c,a,t,e,i),s.restore()}else r.scaleX&&(d*=r.scaleX,c*=r.scaleY),o.render(s,0,0,d,c,a,t,e,i)},getImageRenderScaleData:function(t,e,i,a){const s=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(i){const{pixelRatio:t}=i;s.scaleX*=t,s.scaleY*=t}return n&&n.scaleX&&(s.scaleX*=Math.abs(n.scaleX),s.scaleY*=Math.abs(n.scaleY)),s},recycleImage:function(t,e){const i=e["_"+t];if(m(i)){let a,s,n,r,o;for(let l=0,d=i.length;l<d;l++)a=i[l],s=a.image,o=s&&s.url,o&&(n||(n={}),n[o]=!0,S.recyclePaint(a),e.__willDestroy&&s.parent&&X.recycleFilter(s,e.__leaf),s.loading&&(r||(r=e.__input&&e.__input[t]||[],m(r)||(r=[r])),s.unload(i[l].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,a){t.patternTask||(t.patternTask=S.patternTasker.add(()=>H(this,void 0,void 0,function*(){X.createPattern(t,e,i,a),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,a,s){let{scaleX:n,scaleY:r}=X.getImageRenderScaleData(t,i,a,s),o=t.film?t.nowIndex:n+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:a,data:s}=t,{opacity:l}=t.originPaint,{transform:d,gap:c}=s,h=X.getPatternFixScale(t,n,r);let u,f,g,{width:p,height:_}=a;h&&(n*=h,r*=h),p*=n,_*=r,c&&(f=c.x*n/ne(s.scaleX||1),g=c.y*r/ne(s.scaleY||1)),(d||1!==n||1!==r)&&(n*=se(p+(f||0)),r*=se(_+(g||0)),u=ee(),d&&ae(u,d),ie(u,1/n,1/r));const m=a.getCanvas(p,_,l,void 0,f,g,i.leafer&&i.leafer.config.smooth,s.interlace),w=a.getPattern(m,s.repeat||e.origin.noRepeat||"no-repeat",u,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,a){const{image:s}=t;let n,r=e.image.maxPatternSize,o=s.width*s.height;return s.isSVG?i>1&&(n=Math.ceil(i)/i):r>o&&(r=o),(o*=i*a)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,a){t.data=X.getPatternData(i,a,e)},getPatternData:function(t,e,i){t.padding&&(e=Yt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:s}=i,{mode:n,align:r,offset:o,scale:l,size:d,rotation:c,skew:h,clipSize:u,repeat:f,gap:g,interlace:p}=t,_=e.width===a&&e.height===s,m={mode:n},w="center"!==r&&(c||0)%180==90;let y,x;switch(B.set(Ut,0,0,w?s:a,w?a:s),n&&"cover"!==n&&"fit"!==n?((l||d)&&(O.getScaleData(l,d,i,Xt),y=Xt.scaleX,x=Xt.scaleY),(r||g||f)&&(y&&B.scale(Ut,y,x,!0),r&&C.toPoint(r,Ut,e,Ut,!0,!0))):_&&!c||(y=x=B.getFitScale(e,Ut,"fit"!==n),B.put(e,i,r,y,!1,Ut),B.scale(Ut,y,x,!0)),o&&W.move(Ut,o),n){case"stretch":_?y&&(y=x=void 0):(y=e.width/a,x=e.height/s,X.stretchMode(m,e,y,x));break;case"normal":case"clip":if(Ut.x||Ut.y||y||u||c||h){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),X.clipMode(m,e,Ut.x,Ut.y,y,x,c,h,t,i),t&&(y=y?y*t:t,x=x?x*i:i)}break;case"repeat":(!_||y||c||h)&&X.repeatMode(m,e,a,s,Ut.x,Ut.y,y,x,c,h,r,t.freeTransform),f||(m.repeat="repeat");const i=k(f);(g||i)&&(m.gap=function(t,e,i,a,s){let n,r;k(t)?(n=t.x,r=t.y):n=r=t;return{x:Gt(n,i,s.width,e&&e.x),y:Gt(r,a,s.height,e&&e.y)}}(g,i&&f,Ut.width,Ut.height,e));break;default:y&&X.fillOrFitMode(m,e,Ut.x,Ut.y,y,x,c)}return m.transform||(e.x||e.y)&&Ft(m.transform=It(),e.x,e.y),y&&(m.scaleX=y,m.scaleY=x),f&&(m.repeat=T(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),p&&(m.interlace=M(p)||"percent"===p.type?{type:"x",offset:p}:p),m},stretchMode:function(t,e,i,a){const s=Nt(),{x:n,y:r}=e;n||r?Vt(s,n,r):i>0&&a>0&&(s.onlyScale=!0),$t(s,i,a),t.transform=s},fillOrFitMode:function(t,e,i,a,s,n,r){const o=Nt();Vt(o,e.x+i,e.y+a),$t(o,s,n),r&&Ht(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,a,s,n,r,o,l,d){const c=Nt();te(c,e,i,a,s,n,r,o),l&&(r||o?(jt(zt),Qt(zt,e,l,d),Zt(c,zt)):Qt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,a,s,n,r,o,l,d,c,h){const u=Nt();if(h)te(u,e,s,n,r,o,l,d);else{if(l)if("center"===c)Ht(u,{x:i/2,y:a/2},l);else switch(Jt(u,l),l){case 90:Vt(u,a,0);break;case 180:Vt(u,i,a);break;case 270:Vt(u,0,i)}qt.x=e.x+s,qt.y=e.y+n,Vt(u,qt.x,qt.y),r&&Qt(u,qt,r,o)}t.transform=u}},{toPoint:oe}=I,{hasTransparent:le}=U,de={},ce={};function he(t,e,i,a){if(i){let s,n,r,o;for(let t=0,l=i.length;t<l;t++)s=i[t],T(s)?(r=t/(l-1),n=U.string(s,a)):(r=s.offset,n=U.string(s.color,a)),e.addColorStop(r,n),!o&&le(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:ue,getDistance:fe}=W,{get:ge,rotateOfOuter:pe,scaleOfOuter:_e}=P,{toPoint:me}=I,we={},ye={};function xe(t,e,i,a,s){let n;const{width:r,height:o}=t;if(r!==o||a){const t=ue(e,i);n=ge(),s?(_e(n,e,r/o*(a||1),1),pe(n,e,t+90)):(_e(n,e,1,r/o*(a||1)),pe(n,e,t))}return n}const{getDistance:ve}=W,{toPoint:Se}=I,be={},ke={};const Be={linearGradient:function(t,i){let{from:a,to:s,type:n,opacity:r}=t;oe(a||"top",i,de),oe(s||"bottom",i,ce);const o=e.canvas.createLinearGradient(de.x,de.y,ce.x,ce.y),l={type:n,style:o};return he(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:a,to:s,type:n,opacity:r,stretch:o}=t;me(a||"center",i,we),me(s||"bottom",i,ye);const l=e.canvas.createRadialGradient(we.x,we.y,0,we.x,we.y,fe(we,ye)),d={type:n,style:l};he(d,l,t.stops,r);const c=xe(i,we,ye,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:a,to:s,type:n,opacity:r,stretch:o}=t;Se(a||"center",i,be),Se(s||"bottom",i,ke);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,be.x,be.y):e.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,ve(be,ke)),d={type:n,style:l};he(d,l,t.stops,r);const c=xe(i,be,ke,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:xe},{copy:Re,move:Ee,toOffsetOutBounds:Le}=B,{max:Te,abs:Ae}=Math,Pe={},Oe=new E,Ce={};function We(t,e){let i,a,s,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,a=t.y||0,n=1.5*(t.blur||0),s=Ae(t.spread||0),r=Te(r,s+n-a),o=Te(o,s+n+i),l=Te(l,s+n+a),d=Te(d,s+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Me(t,i,a){const{shapeBounds:s}=a;let n,r;e.fullImageShadow?(Re(Pe,t.bounds),Ee(Pe,i.x-s.x,i.y-s.y),n=t.bounds,r=Pe):(n=s,r=i),t.copyWorld(a.canvas,n,r)}const{toOffsetOutBounds:De}=B,Ie={};const Fe=We;const Ye={shadow:function(t,e,i){let a,s;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Le(l,Ce,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.setWorldShadow(Ce.offsetX+(r.x||0)*h*m,Ce.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m,U.string(r.color)),s=q.getShadowTransform(t,g,i,r,Ce,m),s&&g.setTransform(s),Me(g,Ce,i),s&&g.resetTransform(),a=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),a=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,a,r.blendMode),p&&_<p&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(t,e,i){let a,s;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;De(l,Ie,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.save(),g.setWorldShadow(Ie.offsetX+(r.x||0)*h*m,Ie.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m),s=q.getShadowTransform(t,g,i,r,Ie,m,!0),s&&g.setTransform(s),Me(g,Ie,i),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),a=n):(g.copyWorld(i.canvas,c,l,"source-out"),a=d),g.fillWorld(a,U.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,a,r.blendMode),p&&_<p&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:a}=t.__;i.setWorldBlur(a*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:We,getShadowTransform:function(t,e,i,a,s,n,r){if(a.spread){const i=2*a.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Oe.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/o,1+i/l),Oe}},isTransformShadow(t){},getInnerShadowSpread:Fe},{excludeRenderBounds:Xe}=p;let Ue;function Ge(t,e,i,a,s,n,r,o){switch(e){case"grayscale":Ue||(Ue=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,a,s,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(a,r),n&&a.recycle(r);ze(t,e,i,1,s,n)}(t,i,a,s,r,o);break;case"opacity-path":ze(t,i,a,n,r,o);break;case"path":o&&i.restore()}}function qe(t){return t.getSameCanvas(!1,!0)}function ze(t,e,i,a,s,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(i,r,void 0,s),n?i.recycle(r):i.clearWorld(r)}z.prototype.__renderMask=function(t,e){let i,a,s,n,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(Ge(this,r,t,s,a,n,void 0,!0),a=s=null),"clipping"!==o&&"clipping-path"!==o||Xe(i,e)||i.__render(t,e),n=i.__.opacity,Ue=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",s||(s=qe(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=qe(t)),s||(s=qe(t)),i.__render(a,e));continue}const c=1===n&&i.__.__blendMode;c&&Ge(this,r,t,s,a,n,void 0,!1),Xe(i,e)||i.__render(s||t,e),c&&Ge(this,r,t,s,a,n,c,!1)}Ge(this,r,t,s,a,n,void 0,!0)};const Ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",je=Ne+"_#~&*+\\=|≮≯≈≠=…",He=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 Ve(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Qe=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ze=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$e=Ve(Ne),Je=Ve(je),Ke=Ve("- —/~|┆·");var ti;!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"}(ti||(ti={}));const{Letter:ei,Single:ii,Before:ai,After:si,Symbol:ni,Break:ri}=ti;function oi(t){return Qe[t]?ei:Ke[t]?ri:Ze[t]?ai:$e[t]?si:Je[t]?ni:He.test(t)?ii:ei}const li={trimRight(t){const{words:e}=t;let i,a=0,s=e.length;for(let n=s-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)a++,t.width-=i.width;a&&e.splice(s-a,a)}};function di(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:ci}=li,{Letter:hi,Single:ui,Before:fi,After:gi,Symbol:pi,Break:_i}=ti;let mi,wi,yi,xi,vi,Si,bi,ki,Bi,Ri,Ei,Li,Ti,Ai,Pi,Oi,Ci,Wi=[];function Mi(t,e){Bi&&!ki&&(ki=Bi),mi.data.push({char:t,width:e}),yi+=e}function Di(){xi+=yi,mi.width=yi,wi.words.push(mi),mi={data:[]},yi=0}function Ii(){Ai&&(Pi.paraNumber++,wi.paraStart=!0,Ai=!1),Bi&&(wi.startCharSize=ki,wi.endCharSize=Bi,ki=0),wi.width=xi,Oi.width?ci(wi):Ci&&Fi(),Wi.push(wi),wi={words:[]},xi=0}function Fi(){xi>(Pi.maxWidth||0)&&(Pi.maxWidth=xi)}const{top:Yi,right:Xi,bottom:Ui,left:Gi}=F;function qi(t,e,i){const{bounds:a,rows:s}=t;a[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const zi={getDrawData:function(t,i){T(t)||(t=String(t));let a=0,s=0,n=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(n?(a=o[Gi],n-=o[Xi]+o[Gi],!n&&(n=.01)):i.autoSizeAlign||(a=o[Gi]),r?(s=o[Yi],r-=o[Yi]+o[Ui],!r&&(r=.01)):i.autoSizeAlign||(s=o[Yi]));const l={bounds:{x:a,y:s,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,a){Pi=t,Wi=t.rows,Oi=t.bounds,Ci=!Oi.width&&!a.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:r}=a,{canvas:o}=e,{width:l}=Oi;if(a.__isCharMode){const t="none"!==a.textWrap,e="break"===a.textWrap;Ai=!0,Ei=null,ki=bi=Bi=yi=xi=0,mi={data:[]},wi={words:[]},s&&(i=[...i]);for(let a=0,d=i.length;a<d;a++)Si=i[a],"\n"===Si?(yi&&Di(),wi.paraEnd=!0,Ii(),Ai=!0):(Ri=oi(Si),Ri===hi&&"none"!==r&&(Si=di(Si,r,!yi)),bi=o.measureText(Si).width,s&&(s<0&&(Bi=bi),bi+=s),Li=Ri===ui&&(Ei===ui||Ei===hi)||Ei===ui&&Ri!==gi,Ti=!(Ri!==fi&&Ri!==ui||Ei!==pi&&Ei!==gi),vi=Ai&&n?l-n:l,t&&l&&xi+yi+bi>vi&&(e?(yi&&Di(),xi&&Ii()):(Ti||(Ti=Ri===hi&&Ei==gi),Li||Ti||Ri===_i||Ri===fi||Ri===ui||yi+bi>vi?(yi&&Di(),xi&&Ii()):xi&&Ii()))," "===Si&&!0!==Ai&&xi+yi===0||(Ri===_i?(" "===Si&&yi&&Di(),Mi(Si,bi),Di()):Li||Ti?(yi&&Di(),Mi(Si,bi)):Mi(Si,bi)),Ei=Ri);yi&&Di(),xi&&Ii(),Wi.length>0&&(Wi[Wi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Pi.paraNumber++,xi=o.measureText(t).width,Wi.push({x:n||0,text:t,width:xi,paraStart:!0}),Ci&&Fi()})}(l,t,i),o&&function(t,e,i,a,s){if(!a&&i.autoSizeAlign)switch(i.textAlign){case"left":qi(e,"x",t[Gi]);break;case"right":qi(e,"x",-t[Xi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":qi(e,"y",t[Yi]);break;case"bottom":qi(e,"y",-t[Ui])}}(o,l,i,n,r),function(t,e){const{rows:i,bounds:a}=t,s=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=a,m=n*s+(h?h*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(e.__autoHeight?m:_,n),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":g+=(_-m)/2;break;case"bottom":g+=_-m}w+=g;let y,x,v,S=p||u?p:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=i[r],y.x=f,y.width<p||y.width>p&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=n,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<a.x&&(a.x=x),v>a.width&&(a.width=v),l&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}a.y=g,a.height=m}(l,i),i.__isCharMode&&function(t,e,i){const{rows:a}=t,{textAlign:s,paraIndent:n,__letterSpacing:r}=e,o=i&&s.includes("both"),l=o||i&&s.includes("justify"),d=l&&s.includes("letter");let c,h,u,f,g,p,_,m,w,y;a.forEach(t=>{t.words&&(g=n&&t.paraStart?n:0,m=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?h/(m-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,a,s){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(w=i===m-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(l,i,n),l.overflow&&function(t,i,a,s){const{rows:n,overflow:r}=t;let{textOverflow:o}=i;if(r&&n.splice(r),s&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=a+s-d;("none"===i.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let a=i;a>-1&&(t=e.data[a],l=t.x+t.width,!(a===i&&l<c));a--){if(l<c&&" "!==t.char||!a){e.data.splice(a+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,a,n),"none"!==i.textDecoration&&function(t,e){let i,a=0;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,k(n)?(i=n.type,n.color&&(t.decorationColor=U.string(n.color)),n.offset&&(a=Math.min(.3*s,Math.max(n.offset,.15*-s)))):i=n,i){case"under":t.decorationY=[.15*s+a];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s+a,.35*-s]}}(l,i),l}};const Ni={string:function(t,e){if(!t)return"#000";const i=M(e)&&e<1;if(T(t)){if(!i||!U.object)return t;t=U.object(t)}let a=L(t.a)?1:t.a;i&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(N,zi),Object.assign(U,Ni),Object.assign(Y,Et),Object.assign(X,re),Object.assign(G,Be),Object.assign(q,Ye),Q();export{lt as Layouter,V as LeaferCanvas,j as PathNodeHandleType,ct as Renderer,$ as Watcher,Q as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map