@leafer-ui/node 1.0.0-rc.3 → 1.0.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.cjs CHANGED
@@ -104,7 +104,7 @@ function updateMatrix(updateList, levelList) {
104
104
  let layout;
105
105
  updateList.list.forEach(leaf => {
106
106
  layout = leaf.__layout;
107
- if (levelList.without(leaf) && !layout.useZoomProxy) {
107
+ if (levelList.without(leaf) && !layout.proxyZoom) {
108
108
  if (layout.matrixChanged) {
109
109
  updateAllWorldMatrix$1(leaf);
110
110
  levelList.push(leaf);
@@ -423,8 +423,7 @@ class Renderer {
423
423
  const { canvas, updateBlocks: list } = this;
424
424
  if (!list)
425
425
  return debug.warn('PartRender: need update attr');
426
- if (list.some(block => block.includes(this.target.__world)))
427
- this.mergeBlocks();
426
+ this.mergeBlocks();
428
427
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
429
428
  this.clipRender(block); });
430
429
  }
@@ -443,7 +442,7 @@ class Renderer {
443
442
  canvas.clearWorld(bounds, true);
444
443
  canvas.clipWorld(bounds, true);
445
444
  }
446
- this.__render(bounds, realBounds);
445
+ this.__render(bounds, includes, realBounds);
447
446
  canvas.restore();
448
447
  core.Run.end(t);
449
448
  }
@@ -452,12 +451,12 @@ class Renderer {
452
451
  const { canvas } = this;
453
452
  canvas.save();
454
453
  canvas.clear();
455
- this.__render(canvas.bounds);
454
+ this.__render(canvas.bounds, true);
456
455
  canvas.restore();
457
456
  core.Run.end(t);
458
457
  }
459
- __render(bounds, realBounds) {
460
- const options = (bounds === null || bounds === void 0 ? void 0 : bounds.includes(this.target.__world)) ? {} : { bounds };
458
+ __render(bounds, includes, realBounds) {
459
+ const options = bounds.includes(this.target.__world) ? { includes } : { bounds, includes };
461
460
  if (this.needFill)
462
461
  this.canvas.fillWorld(bounds, this.config.fill);
463
462
  if (core.Debug.showRepaint)
@@ -821,6 +820,8 @@ class LeaferCanvas extends core.LeaferCanvasBase {
821
820
  this.__createView();
822
821
  this.__createContext();
823
822
  this.resize(this.config);
823
+ this.context.__proto__.roundRect = null;
824
+ core.canvasPatch(this.context.__proto__);
824
825
  }
825
826
  __createView() {
826
827
  this.view = core.Platform.origin.createCanvas(1, 1);
@@ -851,6 +852,11 @@ function useCanvas(canvasType, power) {
851
852
  loadImage
852
853
  };
853
854
  }
855
+ core.Platform.event = {
856
+ stopDefault(_origin) { },
857
+ stopNow(_origin) { },
858
+ stop(_origin) { }
859
+ };
854
860
  core.Platform.canvas = core.Creator.canvas();
855
861
  }
856
862
  }
@@ -1136,17 +1142,20 @@ function checkImage(ui, canvas, paint, allowPaint) {
1136
1142
  createPattern(ui, paint, canvas.pixelRatio);
1137
1143
  }
1138
1144
  else {
1139
- core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1140
- if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
1141
- ui.forceUpdate('surface');
1142
- }), 300);
1145
+ if (!paint.patternTask) {
1146
+ paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1147
+ paint.patternTask = null;
1148
+ if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
1149
+ ui.forceUpdate('surface');
1150
+ }), 300);
1151
+ }
1143
1152
  }
1144
1153
  return false;
1145
1154
  }
1146
1155
  }
1147
1156
  }
1148
1157
 
1149
- function recycleImage(data, attrName) {
1158
+ function recycleImage(attrName, data) {
1150
1159
  const paints = (attrName === 'fill' ? data._fill : data._stroke);
1151
1160
  if (paints instanceof Array) {
1152
1161
  let image, recycleMap, input, url;
@@ -1191,11 +1200,11 @@ function fillText(ui, canvas) {
1191
1200
  }
1192
1201
  }
1193
1202
 
1194
- function fill(ui, canvas, fill) {
1203
+ function fill(fill, ui, canvas) {
1195
1204
  canvas.fillStyle = fill;
1196
1205
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
1197
1206
  }
1198
- function fills(ui, canvas, fills) {
1207
+ function fills(fills, ui, canvas) {
1199
1208
  let item;
1200
1209
  const { windingRule, __font } = ui.__;
1201
1210
  for (let i = 0, len = fills.length; i < len; i++) {
@@ -1226,32 +1235,37 @@ function fills(ui, canvas, fills) {
1226
1235
  }
1227
1236
  }
1228
1237
 
1229
- function strokeText(ui, canvas, stroke) {
1238
+ function strokeText(stroke, ui, canvas, renderOptions) {
1230
1239
  const { strokeAlign } = ui.__;
1231
1240
  const isStrokes = typeof stroke !== 'string';
1232
1241
  switch (strokeAlign) {
1233
1242
  case 'center':
1234
1243
  canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
1235
- isStrokes ? drawStrokesStyle(ui, stroke, canvas, true) : drawTextStroke(ui, canvas);
1244
+ isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
1236
1245
  break;
1237
1246
  case 'inside':
1238
- drawAlignStroke(ui, canvas, stroke, 'inside', isStrokes);
1247
+ drawAlignStroke('inside', stroke, isStrokes, ui, canvas, renderOptions);
1239
1248
  break;
1240
1249
  case 'outside':
1241
- drawAlignStroke(ui, canvas, stroke, 'outside', isStrokes);
1250
+ drawAlignStroke('outside', stroke, isStrokes, ui, canvas, renderOptions);
1242
1251
  break;
1243
1252
  }
1244
1253
  }
1245
- function drawAlignStroke(ui, canvas, stroke, align, isStrokes) {
1254
+ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
1246
1255
  const { strokeWidth, __font } = ui.__;
1247
1256
  const out = canvas.getSameCanvas(true);
1248
1257
  out.setStroke(isStrokes ? undefined : stroke, strokeWidth * 2, ui.__);
1249
1258
  out.font = __font;
1250
- isStrokes ? drawStrokesStyle(ui, stroke, out, true) : drawTextStroke(ui, out);
1259
+ isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
1251
1260
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
1252
1261
  fillText(ui, out);
1253
1262
  out.blendMode = 'normal';
1254
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1263
+ if (ui.__hasMirror || renderOptions.matrix) {
1264
+ canvas.copyWorldByReset(out);
1265
+ }
1266
+ else {
1267
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1268
+ }
1255
1269
  out.recycle();
1256
1270
  }
1257
1271
  function drawTextStroke(ui, canvas) {
@@ -1271,7 +1285,7 @@ function drawTextStroke(ui, canvas) {
1271
1285
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
1272
1286
  }
1273
1287
  }
1274
- function drawStrokesStyle(ui, strokes, canvas, isText) {
1288
+ function drawStrokesStyle(strokes, isText, ui, canvas) {
1275
1289
  let item;
1276
1290
  for (let i = 0, len = strokes.length; i < len; i++) {
1277
1291
  item = strokes[i];
@@ -1291,13 +1305,13 @@ function drawStrokesStyle(ui, strokes, canvas, isText) {
1291
1305
  }
1292
1306
  }
1293
1307
 
1294
- function stroke(ui, canvas, stroke) {
1308
+ function stroke(stroke, ui, canvas, renderOptions) {
1295
1309
  const options = ui.__;
1296
1310
  const { strokeWidth, strokeAlign, __font } = options;
1297
1311
  if (!strokeWidth)
1298
1312
  return;
1299
1313
  if (__font) {
1300
- strokeText(ui, canvas, stroke);
1314
+ strokeText(stroke, ui, canvas, renderOptions);
1301
1315
  }
1302
1316
  else {
1303
1317
  switch (strokeAlign) {
@@ -1319,31 +1333,36 @@ function stroke(ui, canvas, stroke) {
1319
1333
  out.stroke();
1320
1334
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1321
1335
  out.clearWorld(ui.__layout.renderBounds);
1322
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1336
+ if (ui.__hasMirror || renderOptions.matrix) {
1337
+ canvas.copyWorldByReset(out);
1338
+ }
1339
+ else {
1340
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1341
+ }
1323
1342
  out.recycle();
1324
1343
  break;
1325
1344
  }
1326
1345
  }
1327
1346
  }
1328
- function strokes(ui, canvas, strokes) {
1347
+ function strokes(strokes, ui, canvas, renderOptions) {
1329
1348
  const options = ui.__;
1330
1349
  const { strokeWidth, strokeAlign, __font } = options;
1331
1350
  if (!strokeWidth)
1332
1351
  return;
1333
1352
  if (__font) {
1334
- strokeText(ui, canvas, strokes);
1353
+ strokeText(strokes, ui, canvas, renderOptions);
1335
1354
  }
1336
1355
  else {
1337
1356
  switch (strokeAlign) {
1338
1357
  case 'center':
1339
1358
  canvas.setStroke(undefined, strokeWidth, options);
1340
- drawStrokesStyle(ui, strokes, canvas);
1359
+ drawStrokesStyle(strokes, false, ui, canvas);
1341
1360
  break;
1342
1361
  case 'inside':
1343
1362
  canvas.save();
1344
1363
  canvas.setStroke(undefined, strokeWidth * 2, options);
1345
1364
  options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
1346
- drawStrokesStyle(ui, strokes, canvas);
1365
+ drawStrokesStyle(strokes, false, ui, canvas);
1347
1366
  canvas.restore();
1348
1367
  break;
1349
1368
  case 'outside':
@@ -1351,10 +1370,15 @@ function strokes(ui, canvas, strokes) {
1351
1370
  const out = canvas.getSameCanvas(true);
1352
1371
  ui.__drawRenderPath(out);
1353
1372
  out.setStroke(undefined, strokeWidth * 2, ui.__);
1354
- drawStrokesStyle(ui, strokes, out);
1373
+ drawStrokesStyle(strokes, false, ui, out);
1355
1374
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1356
1375
  out.clearWorld(renderBounds);
1357
- canvas.copyWorldToInner(out, ui.__world, renderBounds);
1376
+ if (ui.__hasMirror || renderOptions.matrix) {
1377
+ canvas.copyWorldByReset(out);
1378
+ }
1379
+ else {
1380
+ canvas.copyWorldToInner(out, ui.__world, renderBounds);
1381
+ }
1358
1382
  out.recycle();
1359
1383
  break;
1360
1384
  }
@@ -1486,21 +1510,34 @@ function conicGradient(paint, box) {
1486
1510
  }
1487
1511
 
1488
1512
  let recycleMap;
1489
- function compute(ui, attrName) {
1513
+ function compute(attrName, ui) {
1490
1514
  const value = [];
1515
+ const data = ui.__;
1491
1516
  let item;
1492
- let paints = ui.__.__input[attrName];
1517
+ let paints = data.__input[attrName];
1493
1518
  if (!(paints instanceof Array))
1494
1519
  paints = [paints];
1495
- recycleMap = recycleImage(ui.__, attrName);
1520
+ recycleMap = recycleImage(attrName, data);
1496
1521
  for (let i = 0, len = paints.length; i < len; i++) {
1497
- item = getLeafPaint(ui, paints[i], attrName);
1522
+ item = getLeafPaint(attrName, paints[i], ui);
1498
1523
  if (item)
1499
1524
  value.push(item);
1500
1525
  }
1501
- ui.__['_' + attrName] = value.length ? value : undefined;
1526
+ data['_' + attrName] = value.length ? value : undefined;
1527
+ let isPixel;
1528
+ if (paints.length === 1) {
1529
+ const paint = paints[0];
1530
+ if (paint.type === 'image')
1531
+ isPixel = core$1.ImageManager.isPixel(paint);
1532
+ }
1533
+ if (attrName === 'fill') {
1534
+ data.__pixelFill = isPixel;
1535
+ }
1536
+ else {
1537
+ data.__pixelStroke = isPixel;
1538
+ }
1502
1539
  }
1503
- function getLeafPaint(ui, paint, attrName) {
1540
+ function getLeafPaint(attrName, paint, ui) {
1504
1541
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
1505
1542
  return undefined;
1506
1543
  const { boxBounds } = ui.__layout;
@@ -1538,7 +1575,7 @@ var UIPaint = /*#__PURE__*/Object.freeze({
1538
1575
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = core.BoundsHelper;
1539
1576
  const tempBounds = {};
1540
1577
  const offsetOutBounds$1 = {};
1541
- function shadow(ui, current, shape, _options) {
1578
+ function shadow(ui, current, shape, renderOptions) {
1542
1579
  let copyBounds, spreadScale;
1543
1580
  const { __world, __layout } = ui;
1544
1581
  const { shadow } = ui.__;
@@ -1560,7 +1597,7 @@ function shadow(ui, current, shape, _options) {
1560
1597
  }
1561
1598
  worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1562
1599
  }
1563
- if (ui.__hasMirror) {
1600
+ if (ui.__hasMirror || renderOptions.matrix) {
1564
1601
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
1565
1602
  }
1566
1603
  else {
@@ -1600,7 +1637,7 @@ function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1600
1637
 
1601
1638
  const { toOffsetOutBounds } = core.BoundsHelper;
1602
1639
  const offsetOutBounds = {};
1603
- function innerShadow(ui, current, shape, _options) {
1640
+ function innerShadow(ui, current, shape, renderOptions) {
1604
1641
  let copyBounds, spreadScale;
1605
1642
  const { __world, __layout: __layout } = ui;
1606
1643
  const { innerShadow } = ui.__;
@@ -1624,7 +1661,7 @@ function innerShadow(ui, current, shape, _options) {
1624
1661
  copyBounds = bounds;
1625
1662
  }
1626
1663
  other.fillWorld(copyBounds, item.color, 'source-in');
1627
- if (ui.__hasMirror) {
1664
+ if (ui.__hasMirror || renderOptions.matrix) {
1628
1665
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
1629
1666
  }
1630
1667
  else {
package/dist/node.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- import { LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, BoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, Platform, AnimateEvent, ResizeEvent, Creator, LeaferCanvasBase, LeaferImage, InteractionBase, MatrixHelper, ImageEvent, PointHelper, MathHelper, TaskProcessor } from '@leafer/core';
1
+ import { LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, BoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, Platform, AnimateEvent, ResizeEvent, Creator, LeaferCanvasBase, canvasPatch, LeaferImage, InteractionBase, MatrixHelper, ImageEvent, PointHelper, MathHelper, TaskProcessor } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
- import { ColorConvert as ColorConvert$1, Paint, Effect, TextConvert as TextConvert$1, Export as Export$1 } from '@leafer-ui/core';
4
+ import { ColorConvert as ColorConvert$1, ImageManager as ImageManager$1, Paint, Effect, TextConvert as TextConvert$1, Export as Export$1 } from '@leafer-ui/core';
5
5
  export * from '@leafer-ui/core';
6
6
 
7
7
  class Watcher {
@@ -105,7 +105,7 @@ function updateMatrix(updateList, levelList) {
105
105
  let layout;
106
106
  updateList.list.forEach(leaf => {
107
107
  layout = leaf.__layout;
108
- if (levelList.without(leaf) && !layout.useZoomProxy) {
108
+ if (levelList.without(leaf) && !layout.proxyZoom) {
109
109
  if (layout.matrixChanged) {
110
110
  updateAllWorldMatrix$1(leaf);
111
111
  levelList.push(leaf);
@@ -424,8 +424,7 @@ class Renderer {
424
424
  const { canvas, updateBlocks: list } = this;
425
425
  if (!list)
426
426
  return debug.warn('PartRender: need update attr');
427
- if (list.some(block => block.includes(this.target.__world)))
428
- this.mergeBlocks();
427
+ this.mergeBlocks();
429
428
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
430
429
  this.clipRender(block); });
431
430
  }
@@ -444,7 +443,7 @@ class Renderer {
444
443
  canvas.clearWorld(bounds, true);
445
444
  canvas.clipWorld(bounds, true);
446
445
  }
447
- this.__render(bounds, realBounds);
446
+ this.__render(bounds, includes, realBounds);
448
447
  canvas.restore();
449
448
  Run.end(t);
450
449
  }
@@ -453,12 +452,12 @@ class Renderer {
453
452
  const { canvas } = this;
454
453
  canvas.save();
455
454
  canvas.clear();
456
- this.__render(canvas.bounds);
455
+ this.__render(canvas.bounds, true);
457
456
  canvas.restore();
458
457
  Run.end(t);
459
458
  }
460
- __render(bounds, realBounds) {
461
- const options = (bounds === null || bounds === void 0 ? void 0 : bounds.includes(this.target.__world)) ? {} : { bounds };
459
+ __render(bounds, includes, realBounds) {
460
+ const options = bounds.includes(this.target.__world) ? { includes } : { bounds, includes };
462
461
  if (this.needFill)
463
462
  this.canvas.fillWorld(bounds, this.config.fill);
464
463
  if (Debug.showRepaint)
@@ -822,6 +821,8 @@ class LeaferCanvas extends LeaferCanvasBase {
822
821
  this.__createView();
823
822
  this.__createContext();
824
823
  this.resize(this.config);
824
+ this.context.__proto__.roundRect = null;
825
+ canvasPatch(this.context.__proto__);
825
826
  }
826
827
  __createView() {
827
828
  this.view = Platform.origin.createCanvas(1, 1);
@@ -852,6 +853,11 @@ function useCanvas(canvasType, power) {
852
853
  loadImage
853
854
  };
854
855
  }
856
+ Platform.event = {
857
+ stopDefault(_origin) { },
858
+ stopNow(_origin) { },
859
+ stop(_origin) { }
860
+ };
855
861
  Platform.canvas = Creator.canvas();
856
862
  }
857
863
  }
@@ -1137,17 +1143,20 @@ function checkImage(ui, canvas, paint, allowPaint) {
1137
1143
  createPattern(ui, paint, canvas.pixelRatio);
1138
1144
  }
1139
1145
  else {
1140
- ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1141
- if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
1142
- ui.forceUpdate('surface');
1143
- }), 300);
1146
+ if (!paint.patternTask) {
1147
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1148
+ paint.patternTask = null;
1149
+ if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
1150
+ ui.forceUpdate('surface');
1151
+ }), 300);
1152
+ }
1144
1153
  }
1145
1154
  return false;
1146
1155
  }
1147
1156
  }
1148
1157
  }
1149
1158
 
1150
- function recycleImage(data, attrName) {
1159
+ function recycleImage(attrName, data) {
1151
1160
  const paints = (attrName === 'fill' ? data._fill : data._stroke);
1152
1161
  if (paints instanceof Array) {
1153
1162
  let image, recycleMap, input, url;
@@ -1192,11 +1201,11 @@ function fillText(ui, canvas) {
1192
1201
  }
1193
1202
  }
1194
1203
 
1195
- function fill(ui, canvas, fill) {
1204
+ function fill(fill, ui, canvas) {
1196
1205
  canvas.fillStyle = fill;
1197
1206
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
1198
1207
  }
1199
- function fills(ui, canvas, fills) {
1208
+ function fills(fills, ui, canvas) {
1200
1209
  let item;
1201
1210
  const { windingRule, __font } = ui.__;
1202
1211
  for (let i = 0, len = fills.length; i < len; i++) {
@@ -1227,32 +1236,37 @@ function fills(ui, canvas, fills) {
1227
1236
  }
1228
1237
  }
1229
1238
 
1230
- function strokeText(ui, canvas, stroke) {
1239
+ function strokeText(stroke, ui, canvas, renderOptions) {
1231
1240
  const { strokeAlign } = ui.__;
1232
1241
  const isStrokes = typeof stroke !== 'string';
1233
1242
  switch (strokeAlign) {
1234
1243
  case 'center':
1235
1244
  canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
1236
- isStrokes ? drawStrokesStyle(ui, stroke, canvas, true) : drawTextStroke(ui, canvas);
1245
+ isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
1237
1246
  break;
1238
1247
  case 'inside':
1239
- drawAlignStroke(ui, canvas, stroke, 'inside', isStrokes);
1248
+ drawAlignStroke('inside', stroke, isStrokes, ui, canvas, renderOptions);
1240
1249
  break;
1241
1250
  case 'outside':
1242
- drawAlignStroke(ui, canvas, stroke, 'outside', isStrokes);
1251
+ drawAlignStroke('outside', stroke, isStrokes, ui, canvas, renderOptions);
1243
1252
  break;
1244
1253
  }
1245
1254
  }
1246
- function drawAlignStroke(ui, canvas, stroke, align, isStrokes) {
1255
+ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
1247
1256
  const { strokeWidth, __font } = ui.__;
1248
1257
  const out = canvas.getSameCanvas(true);
1249
1258
  out.setStroke(isStrokes ? undefined : stroke, strokeWidth * 2, ui.__);
1250
1259
  out.font = __font;
1251
- isStrokes ? drawStrokesStyle(ui, stroke, out, true) : drawTextStroke(ui, out);
1260
+ isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
1252
1261
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
1253
1262
  fillText(ui, out);
1254
1263
  out.blendMode = 'normal';
1255
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1264
+ if (ui.__hasMirror || renderOptions.matrix) {
1265
+ canvas.copyWorldByReset(out);
1266
+ }
1267
+ else {
1268
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1269
+ }
1256
1270
  out.recycle();
1257
1271
  }
1258
1272
  function drawTextStroke(ui, canvas) {
@@ -1272,7 +1286,7 @@ function drawTextStroke(ui, canvas) {
1272
1286
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
1273
1287
  }
1274
1288
  }
1275
- function drawStrokesStyle(ui, strokes, canvas, isText) {
1289
+ function drawStrokesStyle(strokes, isText, ui, canvas) {
1276
1290
  let item;
1277
1291
  for (let i = 0, len = strokes.length; i < len; i++) {
1278
1292
  item = strokes[i];
@@ -1292,13 +1306,13 @@ function drawStrokesStyle(ui, strokes, canvas, isText) {
1292
1306
  }
1293
1307
  }
1294
1308
 
1295
- function stroke(ui, canvas, stroke) {
1309
+ function stroke(stroke, ui, canvas, renderOptions) {
1296
1310
  const options = ui.__;
1297
1311
  const { strokeWidth, strokeAlign, __font } = options;
1298
1312
  if (!strokeWidth)
1299
1313
  return;
1300
1314
  if (__font) {
1301
- strokeText(ui, canvas, stroke);
1315
+ strokeText(stroke, ui, canvas, renderOptions);
1302
1316
  }
1303
1317
  else {
1304
1318
  switch (strokeAlign) {
@@ -1320,31 +1334,36 @@ function stroke(ui, canvas, stroke) {
1320
1334
  out.stroke();
1321
1335
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1322
1336
  out.clearWorld(ui.__layout.renderBounds);
1323
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1337
+ if (ui.__hasMirror || renderOptions.matrix) {
1338
+ canvas.copyWorldByReset(out);
1339
+ }
1340
+ else {
1341
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1342
+ }
1324
1343
  out.recycle();
1325
1344
  break;
1326
1345
  }
1327
1346
  }
1328
1347
  }
1329
- function strokes(ui, canvas, strokes) {
1348
+ function strokes(strokes, ui, canvas, renderOptions) {
1330
1349
  const options = ui.__;
1331
1350
  const { strokeWidth, strokeAlign, __font } = options;
1332
1351
  if (!strokeWidth)
1333
1352
  return;
1334
1353
  if (__font) {
1335
- strokeText(ui, canvas, strokes);
1354
+ strokeText(strokes, ui, canvas, renderOptions);
1336
1355
  }
1337
1356
  else {
1338
1357
  switch (strokeAlign) {
1339
1358
  case 'center':
1340
1359
  canvas.setStroke(undefined, strokeWidth, options);
1341
- drawStrokesStyle(ui, strokes, canvas);
1360
+ drawStrokesStyle(strokes, false, ui, canvas);
1342
1361
  break;
1343
1362
  case 'inside':
1344
1363
  canvas.save();
1345
1364
  canvas.setStroke(undefined, strokeWidth * 2, options);
1346
1365
  options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
1347
- drawStrokesStyle(ui, strokes, canvas);
1366
+ drawStrokesStyle(strokes, false, ui, canvas);
1348
1367
  canvas.restore();
1349
1368
  break;
1350
1369
  case 'outside':
@@ -1352,10 +1371,15 @@ function strokes(ui, canvas, strokes) {
1352
1371
  const out = canvas.getSameCanvas(true);
1353
1372
  ui.__drawRenderPath(out);
1354
1373
  out.setStroke(undefined, strokeWidth * 2, ui.__);
1355
- drawStrokesStyle(ui, strokes, out);
1374
+ drawStrokesStyle(strokes, false, ui, out);
1356
1375
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1357
1376
  out.clearWorld(renderBounds);
1358
- canvas.copyWorldToInner(out, ui.__world, renderBounds);
1377
+ if (ui.__hasMirror || renderOptions.matrix) {
1378
+ canvas.copyWorldByReset(out);
1379
+ }
1380
+ else {
1381
+ canvas.copyWorldToInner(out, ui.__world, renderBounds);
1382
+ }
1359
1383
  out.recycle();
1360
1384
  break;
1361
1385
  }
@@ -1487,21 +1511,34 @@ function conicGradient(paint, box) {
1487
1511
  }
1488
1512
 
1489
1513
  let recycleMap;
1490
- function compute(ui, attrName) {
1514
+ function compute(attrName, ui) {
1491
1515
  const value = [];
1516
+ const data = ui.__;
1492
1517
  let item;
1493
- let paints = ui.__.__input[attrName];
1518
+ let paints = data.__input[attrName];
1494
1519
  if (!(paints instanceof Array))
1495
1520
  paints = [paints];
1496
- recycleMap = recycleImage(ui.__, attrName);
1521
+ recycleMap = recycleImage(attrName, data);
1497
1522
  for (let i = 0, len = paints.length; i < len; i++) {
1498
- item = getLeafPaint(ui, paints[i], attrName);
1523
+ item = getLeafPaint(attrName, paints[i], ui);
1499
1524
  if (item)
1500
1525
  value.push(item);
1501
1526
  }
1502
- ui.__['_' + attrName] = value.length ? value : undefined;
1527
+ data['_' + attrName] = value.length ? value : undefined;
1528
+ let isPixel;
1529
+ if (paints.length === 1) {
1530
+ const paint = paints[0];
1531
+ if (paint.type === 'image')
1532
+ isPixel = ImageManager$1.isPixel(paint);
1533
+ }
1534
+ if (attrName === 'fill') {
1535
+ data.__pixelFill = isPixel;
1536
+ }
1537
+ else {
1538
+ data.__pixelStroke = isPixel;
1539
+ }
1503
1540
  }
1504
- function getLeafPaint(ui, paint, attrName) {
1541
+ function getLeafPaint(attrName, paint, ui) {
1505
1542
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
1506
1543
  return undefined;
1507
1544
  const { boxBounds } = ui.__layout;
@@ -1539,7 +1576,7 @@ var UIPaint = /*#__PURE__*/Object.freeze({
1539
1576
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
1540
1577
  const tempBounds = {};
1541
1578
  const offsetOutBounds$1 = {};
1542
- function shadow(ui, current, shape, _options) {
1579
+ function shadow(ui, current, shape, renderOptions) {
1543
1580
  let copyBounds, spreadScale;
1544
1581
  const { __world, __layout } = ui;
1545
1582
  const { shadow } = ui.__;
@@ -1561,7 +1598,7 @@ function shadow(ui, current, shape, _options) {
1561
1598
  }
1562
1599
  worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1563
1600
  }
1564
- if (ui.__hasMirror) {
1601
+ if (ui.__hasMirror || renderOptions.matrix) {
1565
1602
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
1566
1603
  }
1567
1604
  else {
@@ -1601,7 +1638,7 @@ function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1601
1638
 
1602
1639
  const { toOffsetOutBounds } = BoundsHelper;
1603
1640
  const offsetOutBounds = {};
1604
- function innerShadow(ui, current, shape, _options) {
1641
+ function innerShadow(ui, current, shape, renderOptions) {
1605
1642
  let copyBounds, spreadScale;
1606
1643
  const { __world, __layout: __layout } = ui;
1607
1644
  const { innerShadow } = ui.__;
@@ -1625,7 +1662,7 @@ function innerShadow(ui, current, shape, _options) {
1625
1662
  copyBounds = bounds;
1626
1663
  }
1627
1664
  other.fillWorld(copyBounds, item.color, 'source-in');
1628
- if (ui.__hasMirror) {
1665
+ if (ui.__hasMirror || renderOptions.matrix) {
1629
1666
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
1630
1667
  }
1631
1668
  else {
@@ -1 +1 @@
1
- import{LeafList as t,DataHelper as e,RenderEvent as s,ChildEvent as i,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as _,Run as f,ImageManager as g,Platform as p,AnimateEvent as y,ResizeEvent as w,Creator as m,LeaferCanvasBase as v,LeaferImage as x,InteractionBase as b,MatrixHelper as B,ImageEvent as R,PointHelper as E,MathHelper as L,TaskProcessor as k}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as S,Paint as A,Effect as C,TextConvert as O,Export as M}from"@leafer-ui/core";export*from"@leafer-ui/core";class T{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(s,i){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=s,i&&(this.config=e.default(i,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(s.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===i.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([i.ADD,i.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:I,updateAllWorldOpacity:W}=a,{pushAllChildBranch:D,pushAllParent:P}=o;const{worldBounds:F}=h,{setByListWithHandle:N}=l;class U{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){N(this.beforeBounds,this.updatedList.list,F)}setAfter(){N(this.afterBounds,this.updatedList.list,F),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:Y,updateAllChange:H}=a,{pushAllBranchStack:V,updateWorldBoundsByBranchStack:j}=o,q=c.get("Layouter");class X{constructor(t,s){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,s&&(this.config=e.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(_.START),this.layoutOnce(),t.emitEvent(new _(_.END,this.layoutedBlocks,this.times))}catch(t){q.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?q.warn("layouting"):this.times>3?q.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=f.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=_,o=this.getBlocks(i);o.forEach((t=>{t.setBefore()})),s.emitEvent(new _(n,o,this.times)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(I(t),e.push(t),t.isBranch&&D(t,e),P(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),P(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&W(t),t.__updateChange()}))}(i),o.forEach((t=>t.setAfter())),s.emitEvent(new _(r,o,this.times)),s.emitEvent(new _(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=_,a=this.getBlocks(new t(s));s.emitEvent(new _(i,a,this.times)),X.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new _(n,a,this.times)),s.emitEvent(new _(r,a,this.times)),this.addBlocks(a),f.end(e)}static fullLayout(t){if(Y(t),t.isBranch){const e=[t];V(t,e),j(e)}else t.__updateWorldBounds();H(t)}createBlock(t){return new U(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(_.REQUEST,this.layout,this),t.on_(_.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const G=c.get("Renderer");class z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=s,i&&(this.config=e.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(_.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,G.log(e.innerName,"---\x3e");try{this.emitRender(s.START),this.renderOnce(t),this.emitRender(s.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,G.error(t)}G.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?G.warn("rendering"):this.times>3?G.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(s.BEFORE),t()):(this.requestLayout(),this.emitRender(s.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(s.RENDER,this.renderBounds,this.renderOptions),this.emitRender(s.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return G.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world),r=(new d).copy(i);s.save(),n&&!c.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,r),s.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),f.end(t)}__render(t,e){const s=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(y.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:s}=t.old;new d(0,0,e,s).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||G.warn(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 s(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(s.REQUEST,this.update,this),t.on_(_.END,this.__onLayoutEnd,this),t.on_(s.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:Q}=l;class Z{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:s,y:i}=this.point,n={x:s,y:i,radiusX:0,radiusY:0};for(let s=0,i=t.length;s<i;s++)if(e=t[s],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const s=new t;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||Q(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class K{constructor(t,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,s&&(this.config=e.default(s,this.config)),this.findPath=new Z(t,this),this.__listenEvents()}getByPoint(t,e,s){return"node"===p.name&&this.target.emit(_.CHECK_UPDATE),this.findPath.getByPoint(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(i.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new T(t,e),layouter:(t,e)=>new X(t,e),renderer:(t,e,s)=>new z(t,e,s),selector:(t,e)=>new K(t,e)}),p.layout=X.fullLayout;class $ extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}function J(t,e){if(!p.origin){if("skia"===t){const{Canvas:t,loadImage:s}=e;p.origin={createCanvas:(e,s,i)=>new t(e,s,i),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),loadImage:s}}p.canvas=m.canvas()}}Object.assign(m,{canvas:(t,e)=>new $(t,e),image:t=>new x(t),hitCanvas:(t,e)=>new $(t,e),interaction:(t,e,s,i)=>new b(t,e,s,i)}),p.name="node",p.requestRender=function(t){setTimeout(t)},p.devicePixelRatio=1,p.conicGradientSupport=!0,p.realtimeLayout=!0;const{get:tt,rotateOfOuter:et,translate:st,scaleOfOuter:it,scale:nt,rotate:rt}=B;const{get:at,translate:ot}=B;function dt(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const _=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(_.transform=at(),ot(_.transform,i.x,i.y));break;case"clip":(d||h||l)&&function(t,e,s,i,n){const r=tt();st(r,e.x,e.y),s&&st(r,s.x,s.y),i&&("number"==typeof i?nt(r,i):nt(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&rt(r,n),t.transform=r}(_,i,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,s,i,n,r){const a=tt();if(r)switch(rt(a,r),r){case 90:st(a,i,0);break;case 180:st(a,s,i);break;case 270:st(a,0,s)}st(a,e.x,e.y),n&&(it(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(_,i,n,r,h,l);break;default:u&&!l||function(t,e,s,i,n,r){const a=tt(),o=r&&180!==r,d=s.width/(o?n:i),h=s.height/(o?i:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=s.x+(s.width-i*l)/2,u=s.y+(s.height-n*l)/2;st(a,c,u),nt(a,l),r&&et(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(_,o,i,n,r,l)}_.width=n,_.height=r,a&&(_.opacity=a)}function ht(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function lt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new R(t,e))}function ct(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:ut,scale:_t,copy:ft}=B;function gt(t,e,s){let{scaleX:i,scaleY:n}=t.__world;const r=i+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,i=Math.abs(i),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:_,scaleY:f,opacity:g,transform:y,mode:w}=a;_&&(l=ut(),ft(l,y),_t(l,1/_,1/f),i*=_,n*=f),i*=s,n*=s,c*=i,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(i/=h,n/=h,c/=h,u/=h),_&&(i/=_,n/=f),(y||1!==i||1!==n)&&(l||(l=ut(),y&&ft(l,y)),_t(l,1/i,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===w?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function pt(t,e,s,i){const{scaleX:n,scaleY:r}=t.__world;if(s.data&&s.patternId!==n+"-"+r){if(i)if(s.image.isSVG&&"repeat"!==s.data.mode){let{width:t,height:a}=s.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,i=t>4096||a>4096}else i=!1;if(i){e.save(),e.clip();const{data:t}=s;return s.blendMode&&(e.blendMode=s.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(s.image.view,0,0,t.width,t.height),e.restore(),!0}return s.style?g.patternTasker.add((()=>ct(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&&gt(t,s,e.pixelRatio)&&t.forceUpdate("surface")}))),300):gt(t,s,e.pixelRatio),!1}return!1}function yt(t,e){const s="fill"===e?t._fill:t._stroke;if(s instanceof Array){let i,n,r,a;for(let o=0,d=s.length;o<d;o++)i=s[o].image,a=i&&i.url,a&&(n||(n={}),n[a]=!0,g.recycle(i),i.loading&&(r||(r=t.__input&&t.__input[e]||[],r instanceof Array||(r=[r])),i.unload(s[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function wt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function mt(t,e,s){const{strokeAlign:i}=t.__,n="string"!=typeof s;switch(i){case"center":e.setStroke(n?void 0:s,t.__.strokeWidth,t.__),n?bt(t,s,e,!0):xt(t,e);break;case"inside":vt(t,e,s,"inside",n);break;case"outside":vt(t,e,s,"outside",n)}}function vt(t,e,s,i,n){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(n?void 0:s,2*r,t.__),o.font=a,n?bt(t,s,o,!0):xt(t,o),o.blendMode="outside"===i?"destination-out":"destination-in",wt(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function xt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[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)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function bt(t,e,s,i){let n;for(let r=0,a=e.length;r<a;r++)n=e[r],n.image&&pt(t,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),i?xt(t,s):s.stroke(),s.restoreBlendMode()):i?xt(t,s):s.stroke())}const{getSpread:Bt,getOuterOf:Rt,getByMove:Et,getIntersectData:Lt}=l;const kt={x:.5,y:0},St={x:.5,y:1};function At(t,e,s){let i;for(let n=0,r=e.length;n<r;n++)i=e[n],t.addColorStop(i.offset,S.string(i.color,s))}const{set:Ct,getAngle:Ot,getDistance:Mt}=E,{get:Tt,rotateOfOuter:It,scaleOfOuter:Wt}=B,Dt={x:.5,y:.5},Pt={x:.5,y:1},Ft={},Nt={};const{set:Ut,getAngle:Yt,getDistance:Ht}=E,{get:Vt,rotateOfOuter:jt,scaleOfOuter:qt}=B,Xt={x:.5,y:.5},Gt={x:.5,y:1},zt={},Qt={};let Zt;function Kt(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:S.string(a,o)};case"image":return function(t,e,s,i,n){const r={type:s.type},a=r.image=g.get(s),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:s};return a.ready?(ht(t,e,a)&&dt(r,a,s,i),n&&(lt(R.LOAD,o),lt(R.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,lt(R.ERROR,o)):(n&&lt(R.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(ht(t,e,a)&&(dt(r,a,s,i),t.forceUpdate("surface")),lt(R.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,lt(R.ERROR,o)}))),r}(t,s,e,i,!Zt||!Zt[e.url]);case"linear":return function(t,e){let{from:s,to:i,type:n,blendMode:r,opacity:a}=t;s||(s=kt),i||(i=St);const o=p.canvas.createLinearGradient(e.x+s.x*e.width,e.y+s.y*e.height,e.x+i.x*e.width,e.y+i.y*e.height);At(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,i);case"radial":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Dt),i||(i=Pt);const{x:d,y:h,width:l,height:c}=e;let u;Ct(Ft,d+s.x*l,h+s.y*c),Ct(Nt,d+i.x*l,h+i.y*c),(l!==c||o)&&(u=Tt(),Wt(u,Ft,l/c*(o||1),1),It(u,Ft,Ot(Ft,Nt)+90));const _=p.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Mt(Ft,Nt));At(_,t.stops,r);const f={type:n,style:_,transform:u};return a&&(f.blendMode=a),f}(e,i);case"angular":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Xt),i||(i=Gt);const{x:d,y:h,width:l,height:c}=e;Ut(zt,d+s.x*l,h+s.y*c),Ut(Qt,d+i.x*l,h+i.y*c);const u=Vt(),_=Yt(zt,Qt);p.conicGradientRotate90?(qt(u,zt,l/c*(o||1),1),jt(u,zt,_+90)):(qt(u,zt,1,l/c*(o||1)),jt(u,zt,_));const f=p.conicGradientSupport?p.canvas.createConicGradient(0,zt.x,zt.y):p.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Ht(zt,Qt));At(f,t.stops,r);const g={type:n,style:f,transform:u};return a&&(g.blendMode=a),g}(e,i);default:return e.r?{type:"solid",style:S.string(e)}:void 0}}var $t=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let i,n=t.__.__input[e];n instanceof Array||(n=[n]),Zt=yt(t.__,e);for(let r=0,a=n.length;r<a;r++)i=Kt(t,n[r],e),i&&s.push(i);t.__["_"+e]=s.length?s:void 0},drawTextStroke:xt,fill:function(t,e,s){e.fillStyle=s,t.__.__font?wt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:wt,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)i=s[a],i.image&&pt(t,e,i,!r)||i.style&&(e.fillStyle=i.style,i.transform?(e.save(),e.transform(i.transform),i.blendMode&&(e.blendMode=i.blendMode),r?wt(t,e):n?e.fill(n):e.fill(),e.restore()):i.blendMode?(e.saveBlendMode(i.blendMode),r?wt(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):r?wt(t,e):n?e.fill(n):e.fill())},recycleImage:yt,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,s.matrix))s.matrix?(h*=s.matrix.a,l*=s.matrix.d,n=a=Rt(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=Lt(i?Bt(e.bounds,i*h,i*l):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),h*=r.a,l*=r.d),a=Rt(d,r),n=Et(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)mt(t,e,s);else switch(r){case"center":e.setStroke(s,n,i),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*n,t.__),t.__drawRenderPath(r),r.stroke(),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:mt,strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)mt(t,e,s);else switch(r){case"center":e.setStroke(void 0,n,i),bt(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),bt(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*n,t.__),bt(t,s,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:Jt,toOffsetOutBounds:te}=l,ee={},se={};function ie(t,e,s,i){const{bounds:n,shapeBounds:r}=i;if(p.fullImageShadow){if(Jt(ee,t.bounds),ee.x+=e.x-r.x,ee.y+=e.y-r.y,s){const{matrix:t}=i;ee.x-=(n.x+(t?t.e:0)+n.width/2)*(s-1),ee.y-=(n.y+(t?t.f:0)+n.height/2)*(s-1),ee.width*=s,ee.height*=s}t.copyWorld(i.canvas,t.bounds,ee)}else s&&(Jt(ee,e),ee.x-=e.width/2*(s-1),ee.y-=e.height/2*(s-1),ee.width*=s,ee.height*=s),t.copyWorld(i.canvas,r,s?ee:e)}const{toOffsetOutBounds:ne}=l,re={};var ae=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:_}=s,f=e.getSameCanvas(),g=d.length-1;ne(l,re),d.forEach(((i,d)=>{f.save(),f.setWorldShadow(re.offsetX+i.x*u,re.offsetY+i.y*_,i.blur*u),r=i.spread?1-2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,ie(f,re,r,s),f.restore(),h?(f.copyWorld(f,l,a,"copy"),f.copyWorld(h,a,a,"source-out"),n=a):(f.copyWorld(s.canvas,c,l,"source-out"),n=l),f.fillWorld(n,i.color,"source-in"),t.__hasMirror?e.copyWorldByReset(f,n,a,i.blendMode):e.copyWorldToInner(f,n,o.renderBounds,i.blendMode),g&&d<g&&f.clear()})),f.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:_}=s,f=e.getSameCanvas(),g=d.length-1;te(l,se),d.forEach(((i,d)=>{f.setWorldShadow(se.offsetX+i.x*u,se.offsetY+i.y*_,i.blur*u,i.color),r=i.spread?1+2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,ie(f,se,r,s),n=l,i.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,a,"copy"),n=a),h?f.copyWorld(h,a,a,"destination-out"):f.copyWorld(s.canvas,c,l,"destination-out")),t.__hasMirror?e.copyWorldByReset(f,n,a,i.blendMode):e.copyWorldToInner(f,n,o.renderBounds,i.blendMode),g&&d<g&&f.clear()})),f.recycle()}});const oe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",de=oe+"_#~&*+\\=|≮≯≈≠=…",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 le(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ce=le("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ue=le("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),_e=le(oe),fe=le(de),ge=le("- —/~|┆·");var pe;!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"}(pe||(pe={}));const{Letter:ye,Single:we,Before:me,After:ve,Symbol:xe,Break:be}=pe;function Be(t){return ce[t]?ye:ge[t]?be:ue[t]?me:_e[t]?ve:fe[t]?xe:he.test(t)?we:ye}const Re={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Ee(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Le}=Re,{Letter:ke,Single:Se,Before:Ae,After:Ce,Symbol:Oe,Break:Me}=pe;let Te,Ie,We,De,Pe,Fe,Ne,Ue,Ye,He,Ve,je,qe,Xe,Ge,ze,Qe=[];function Ze(t,e){Ye&&!Ue&&(Ue=Ye),Te.data.push({char:t,width:e}),We+=e}function Ke(){De+=We,Te.width=We,Ie.words.push(Te),Te={data:[]},We=0}function $e(){Xe&&(Ge.paraNumber++,Ie.paraStart=!0,Xe=!1),Ye&&(Ie.startCharSize=Ue,Ie.endCharSize=Ye,Ue=0),Ie.width=De,ze.width&&Le(Ie),Qe.push(Ie),Ie={words:[]},De=0}const Je={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let s=0,i=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,textOverflow:o,__font:d,padding:h}=e;if(h){const[t,e,a,o]=L.fourNumber(h);n&&(s=o,n-=e+o),r&&(i=t,r-=t+a)}const l={bounds:{x:s,y:i,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=d};return function(t,e,s){Ge=t,Qe=t.rows,ze=t.bounds;const{__letterSpacing:i,paraIndent:n,textCase:r}=s,{canvas:a}=p,{width:o,height:d}=ze;if(o||d||i||"none"!==r){Xe=!0,Ve=null,Ue=Ne=Ye=We=De=0,Te={data:[]},Ie={words:[]};for(let t=0,s=e.length;t<s;t++)Fe=e[t],"\n"===Fe?(We&&Ke(),Ie.paraEnd=!0,$e(),Xe=!0):(He=Be(Fe),He===ke&&"none"!==r&&(Fe=Ee(Fe,r,!We)),Ne=a.measureText(Fe).width,i&&(i<0&&(Ye=Ne),Ne+=i),je=He===Se&&(Ve===Se||Ve===ke)||Ve===Se&&He!==Ce,qe=!(He!==Ae&&He!==Se||Ve!==Oe&&Ve!==Ce),Pe=Xe&&n?o-n:o,o&&De+We+Ne>Pe&&(qe||(qe=He===ke&&Ve==Ce),je||qe||He===Me||He===Ae||He===Se||We+Ne>Pe?(We&&Ke(),$e()):$e())," "===Fe&&!0!==Xe&&De+We===0||(He===Me?(" "===Fe&&We&&Ke(),Ze(Fe,Ne),Ke()):je||qe?(We&&Ke(),Ze(Fe,Ne)):Ze(Fe,Ne)),Ve=He);We&&Ke(),De&&$e(),Qe.length>0&&(Qe[Qe.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ge.paraNumber++,Qe.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:h,textOverflow:l}=e;let c,u,_,{x:f,y:g,width:p,height:y}=i,w=n*s.length+(h?h*(t.paraNumber-1):0),m=r;if("show"!==l&&w>y)w=Math.max(y,n),t.overflow=s.length;else switch(d){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let r=0,d=s.length;r<d;r++){switch(c=s[r],c.x=f,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&h&&r>0&&(m+=h),c.y=m,m+=n,t.overflow>r&&m>w&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,_=c.width,a<0&&(c.width<0?(_=-c.width+e.fontSize+a,u-=_,_+=e.fontSize):_-=a),u<i.x&&(i.x=u),_>i.width&&(i.width=_)}i.y=g,i.height=w}(l,e),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=s&&"justify"===r&&t.words.length>1?(s-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:s,overflow:i}=t;if(s.splice(i),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=s[i-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,o),"none"!==a&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(l,e),l}},ts={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},es={export(t,e,s){return function(t){ss||(ss=new k);return new Promise((e=>{ss.add((()=>ct(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((i=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>ct(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof s){case"object":s.quality&&(t=s.quality),s.blob&&(a=!0);break;case"number":t=s;break;case"boolean":a=s}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),i({data:o}),n(),h&&d.recycle()})))):(i({data:!1}),n())}))))}};let ss;Object.assign(A,$t),Object.assign(C,ae),Object.assign(O,Je),Object.assign(S,ts),Object.assign(M,es);export{X as Layouter,$ as LeaferCanvas,z as Renderer,K as Selector,T as Watcher,J as useCanvas};
1
+ import{LeafList as t,DataHelper as e,RenderEvent as s,ChildEvent as i,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as _,Run as f,ImageManager as g,Platform as p,AnimateEvent as y,ResizeEvent as w,Creator as m,LeaferCanvasBase as v,canvasPatch as x,LeaferImage as b,InteractionBase as B,MatrixHelper as R,ImageEvent as E,PointHelper as L,MathHelper as k,TaskProcessor as S}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as A,ImageManager as C,Paint as M,Effect as O,TextConvert as T,Export as I}from"@leafer-ui/core";export*from"@leafer-ui/core";class W{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(s,i){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=s,i&&(this.config=e.default(i,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(s.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===i.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([i.ADD,i.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:D,updateAllWorldOpacity:P}=a,{pushAllChildBranch:F,pushAllParent:N}=o;const{worldBounds:U}=h,{setByListWithHandle:Y}=l;class H{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){Y(this.beforeBounds,this.updatedList.list,U)}setAfter(){Y(this.afterBounds,this.updatedList.list,U),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:V,updateAllChange:j}=a,{pushAllBranchStack:q,updateWorldBoundsByBranchStack:X}=o,G=c.get("Layouter");class z{constructor(t,s){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,s&&(this.config=e.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(_.START),this.layoutOnce(),t.emitEvent(new _(_.END,this.layoutedBlocks,this.times))}catch(t){G.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?G.warn("layouting"):this.times>3?G.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=f.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=_,o=this.getBlocks(i);o.forEach((t=>{t.setBefore()})),s.emitEvent(new _(n,o,this.times)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.proxyZoom&&(s.matrixChanged?(D(t),e.push(t),t.isBranch&&F(t,e),N(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),N(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&P(t),t.__updateChange()}))}(i),o.forEach((t=>t.setAfter())),s.emitEvent(new _(r,o,this.times)),s.emitEvent(new _(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=_,a=this.getBlocks(new t(s));s.emitEvent(new _(i,a,this.times)),z.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new _(n,a,this.times)),s.emitEvent(new _(r,a,this.times)),this.addBlocks(a),f.end(e)}static fullLayout(t){if(V(t),t.isBranch){const e=[t];q(t,e),X(e)}else t.__updateWorldBounds();j(t)}createBlock(t){return new H(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(_.REQUEST,this.layout,this),t.on_(_.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const Q=c.get("Renderer");class Z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=s,i&&(this.config=e.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(_.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Q.log(e.innerName,"---\x3e");try{this.emitRender(s.START),this.renderOnce(t),this.emitRender(s.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,Q.error(t)}Q.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Q.warn("rendering"):this.times>3?Q.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(s.BEFORE),t()):(this.requestLayout(),this.emitRender(s.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(s.RENDER,this.renderBounds,this.renderOptions),this.emitRender(s.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Q.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world),r=(new d).copy(i);s.save(),n&&!c.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,n,r),s.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),f.end(t)}__render(t,e,s){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=s||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(i),c.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(y.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:s}=t.old;new d(0,0,e,s).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Q.warn(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 s(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(s.REQUEST,this.update,this),t.on_(_.END,this.__onLayoutEnd,this),t.on_(s.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:K}=l;class ${constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:s,y:i}=this.point,n={x:s,y:i,radiusX:0,radiusY:0};for(let s=0,i=t.length;s<i;s++)if(e=t[s],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const s=new t;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||K(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class J{constructor(t,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,s&&(this.config=e.default(s,this.config)),this.findPath=new $(t,this),this.__listenEvents()}getByPoint(t,e,s){return"node"===p.name&&this.target.emit(_.CHECK_UPDATE),this.findPath.getByPoint(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(i.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new W(t,e),layouter:(t,e)=>new z(t,e),renderer:(t,e,s)=>new Z(t,e,s),selector:(t,e)=>new J(t,e)}),p.layout=z.fullLayout;class tt extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),this.context.__proto__.roundRect=null,x(this.context.__proto__)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}function et(t,e){if(!p.origin){if("skia"===t){const{Canvas:t,loadImage:s}=e;p.origin={createCanvas:(e,s,i)=>new t(e,s,i),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),loadImage:s}}p.event={stopDefault(t){},stopNow(t){},stop(t){}},p.canvas=m.canvas()}}Object.assign(m,{canvas:(t,e)=>new tt(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new tt(t,e),interaction:(t,e,s,i)=>new B(t,e,s,i)}),p.name="node",p.requestRender=function(t){setTimeout(t)},p.devicePixelRatio=1,p.conicGradientSupport=!0,p.realtimeLayout=!0;const{get:st,rotateOfOuter:it,translate:nt,scaleOfOuter:rt,scale:at,rotate:ot}=R;const{get:dt,translate:ht}=R;function lt(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const _=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(_.transform=dt(),ht(_.transform,i.x,i.y));break;case"clip":(d||h||l)&&function(t,e,s,i,n){const r=st();nt(r,e.x,e.y),s&&nt(r,s.x,s.y),i&&("number"==typeof i?at(r,i):at(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&ot(r,n),t.transform=r}(_,i,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,s,i,n,r){const a=st();if(r)switch(ot(a,r),r){case 90:nt(a,i,0);break;case 180:nt(a,s,i);break;case 270:nt(a,0,s)}nt(a,e.x,e.y),n&&(rt(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(_,i,n,r,h,l);break;default:u&&!l||function(t,e,s,i,n,r){const a=st(),o=r&&180!==r,d=s.width/(o?n:i),h=s.height/(o?i:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=s.x+(s.width-i*l)/2,u=s.y+(s.height-n*l)/2;nt(a,c,u),at(a,l),r&&it(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(_,o,i,n,r,l)}_.width=n,_.height=r,a&&(_.opacity=a)}function ct(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function ut(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new E(t,e))}function _t(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:ft,scale:gt,copy:pt}=R;function yt(t,e,s){let{scaleX:i,scaleY:n}=t.__world;const r=i+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,i=Math.abs(i),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:_,scaleY:f,opacity:g,transform:y,mode:w}=a;_&&(l=ft(),pt(l,y),gt(l,1/_,1/f),i*=_,n*=f),i*=s,n*=s,c*=i,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(i/=h,n/=h,c/=h,u/=h),_&&(i/=_,n/=f),(y||1!==i||1!==n)&&(l||(l=ft(),y&&pt(l,y)),gt(l,1/i,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===w?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function wt(t,e,s,i){const{scaleX:n,scaleY:r}=t.__world;if(s.data&&s.patternId!==n+"-"+r){if(i)if(s.image.isSVG&&"repeat"!==s.data.mode){let{width:t,height:a}=s.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,i=t>4096||a>4096}else i=!1;if(i){e.save(),e.clip();const{data:t}=s;return s.blendMode&&(e.blendMode=s.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(s.image.view,0,0,t.width,t.height),e.restore(),!0}return s.style?s.patternTask||(s.patternTask=g.patternTasker.add((()=>_t(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__world)&&yt(t,s,e.pixelRatio)&&t.forceUpdate("surface")}))),300)):yt(t,s,e.pixelRatio),!1}return!1}function mt(t,e){const s="fill"===t?e._fill:e._stroke;if(s instanceof Array){let i,n,r,a;for(let o=0,d=s.length;o<d;o++)i=s[o].image,a=i&&i.url,a&&(n||(n={}),n[a]=!0,g.recycle(i),i.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),i.unload(s[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function vt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function xt(t,e,s,i){const{strokeAlign:n}=e.__,r="string"!=typeof t;switch(n){case"center":s.setStroke(r?void 0:t,e.__.strokeWidth,e.__),r?Rt(t,!0,e,s):Bt(e,s);break;case"inside":bt("inside",t,r,e,s,i);break;case"outside":bt("outside",t,r,e,s,i)}}function bt(t,e,s,i,n,r){const{strokeWidth:a,__font:o}=i.__,d=n.getSameCanvas(!0);d.setStroke(s?void 0:e,2*a,i.__),d.font=o,s?Rt(e,!0,i,d):Bt(i,d),d.blendMode="outside"===t?"destination-out":"destination-in",vt(i,d),d.blendMode="normal",i.__hasMirror||r.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,i.__world,i.__layout.renderBounds),d.recycle()}function Bt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[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)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function Rt(t,e,s,i){let n;for(let r=0,a=t.length;r<a;r++)n=t[r],n.image&&wt(s,i,n,!1)||n.style&&(i.strokeStyle=n.style,n.blendMode?(i.saveBlendMode(n.blendMode),e?Bt(s,i):i.stroke(),i.restoreBlendMode()):e?Bt(s,i):i.stroke())}const{getSpread:Et,getOuterOf:Lt,getByMove:kt,getIntersectData:St}=l;const At={x:.5,y:0},Ct={x:.5,y:1};function Mt(t,e,s){let i;for(let n=0,r=e.length;n<r;n++)i=e[n],t.addColorStop(i.offset,A.string(i.color,s))}const{set:Ot,getAngle:Tt,getDistance:It}=L,{get:Wt,rotateOfOuter:Dt,scaleOfOuter:Pt}=R,Ft={x:.5,y:.5},Nt={x:.5,y:1},Ut={},Yt={};const{set:Ht,getAngle:Vt,getDistance:jt}=L,{get:qt,rotateOfOuter:Xt,scaleOfOuter:Gt}=R,zt={x:.5,y:.5},Qt={x:.5,y:1},Zt={},Kt={};let $t;function Jt(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=s.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:A.string(a,o)};case"image":return function(t,e,s,i,n){const r={type:s.type},a=r.image=g.get(s),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:s};return a.ready?(ct(t,e,a)&&lt(r,a,s,i),n&&(ut(E.LOAD,o),ut(E.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,ut(E.ERROR,o)):(n&&ut(E.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(ct(t,e,a)&&(lt(r,a,s,i),t.forceUpdate("surface")),ut(E.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,ut(E.ERROR,o)}))),r}(s,t,e,i,!$t||!$t[e.url]);case"linear":return function(t,e){let{from:s,to:i,type:n,blendMode:r,opacity:a}=t;s||(s=At),i||(i=Ct);const o=p.canvas.createLinearGradient(e.x+s.x*e.width,e.y+s.y*e.height,e.x+i.x*e.width,e.y+i.y*e.height);Mt(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,i);case"radial":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Ft),i||(i=Nt);const{x:d,y:h,width:l,height:c}=e;let u;Ot(Ut,d+s.x*l,h+s.y*c),Ot(Yt,d+i.x*l,h+i.y*c),(l!==c||o)&&(u=Wt(),Pt(u,Ut,l/c*(o||1),1),Dt(u,Ut,Tt(Ut,Yt)+90));const _=p.canvas.createRadialGradient(Ut.x,Ut.y,0,Ut.x,Ut.y,It(Ut,Yt));Mt(_,t.stops,r);const f={type:n,style:_,transform:u};return a&&(f.blendMode=a),f}(e,i);case"angular":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=zt),i||(i=Qt);const{x:d,y:h,width:l,height:c}=e;Ht(Zt,d+s.x*l,h+s.y*c),Ht(Kt,d+i.x*l,h+i.y*c);const u=qt(),_=Vt(Zt,Kt);p.conicGradientRotate90?(Gt(u,Zt,l/c*(o||1),1),Xt(u,Zt,_+90)):(Gt(u,Zt,1,l/c*(o||1)),Xt(u,Zt,_));const f=p.conicGradientSupport?p.canvas.createConicGradient(0,Zt.x,Zt.y):p.canvas.createRadialGradient(Zt.x,Zt.y,0,Zt.x,Zt.y,jt(Zt,Kt));Mt(f,t.stops,r);const g={type:n,style:f,transform:u};return a&&(g.blendMode=a),g}(e,i);default:return e.r?{type:"solid",style:A.string(e)}:void 0}}var te=Object.freeze({__proto__:null,compute:function(t,e){const s=[],i=e.__;let n,r,a=i.__input[t];a instanceof Array||(a=[a]),$t=mt(t,i);for(let i=0,r=a.length;i<r;i++)n=Jt(t,a[i],e),n&&s.push(n);if(i["_"+t]=s.length?s:void 0,1===a.length){const t=a[0];"image"===t.type&&(r=C.isPixel(t))}"fill"===t?i.__pixelFill=r:i.__pixelStroke=r},drawTextStroke:Bt,fill:function(t,e,s){s.fillStyle=t,e.__.__font?vt(e,s):e.__.windingRule?s.fill(e.__.windingRule):s.fill()},fillText:vt,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=e.__;for(let a=0,o=t.length;a<o;a++)i=t[a],i.image&&wt(e,s,i,!r)||i.style&&(s.fillStyle=i.style,i.transform?(s.save(),s.transform(i.transform),i.blendMode&&(s.blendMode=i.blendMode),r?vt(e,s):n?s.fill(n):s.fill(),s.restore()):i.blendMode?(s.saveBlendMode(i.blendMode),r?vt(e,s):n?s.fill(n):s.fill(),s.restoreBlendMode()):r?vt(e,s):n?s.fill(n):s.fill())},recycleImage:mt,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,s.matrix))s.matrix?(h*=s.matrix.a,l*=s.matrix.d,n=a=Lt(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=St(i?Et(e.bounds,i*h,i*l):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),h*=r.a,l*=r.d),a=Lt(d,r),n=kt(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,s,i){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)xt(t,e,s,i);else switch(a){case"center":s.setStroke(t,r,n),s.stroke();break;case"inside":s.save(),s.setStroke(t,2*r,n),n.windingRule?s.clip(n.windingRule):s.clip(),s.stroke(),s.restore();break;case"outside":const a=s.getSameCanvas(!0);a.setStroke(t,2*r,e.__),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__hasMirror||i.matrix?s.copyWorldByReset(a):s.copyWorldToInner(a,e.__world,e.__layout.renderBounds),a.recycle()}},strokeText:xt,strokes:function(t,e,s,i){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)xt(t,e,s,i);else switch(a){case"center":s.setStroke(void 0,r,n),Rt(t,!1,e,s);break;case"inside":s.save(),s.setStroke(void 0,2*r,n),n.windingRule?s.clip(n.windingRule):s.clip(),Rt(t,!1,e,s),s.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=s.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*r,e.__),Rt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__hasMirror||i.matrix?s.copyWorldByReset(o):s.copyWorldToInner(o,e.__world,a),o.recycle()}}});const{copy:ee,toOffsetOutBounds:se}=l,ie={},ne={};function re(t,e,s,i){const{bounds:n,shapeBounds:r}=i;if(p.fullImageShadow){if(ee(ie,t.bounds),ie.x+=e.x-r.x,ie.y+=e.y-r.y,s){const{matrix:t}=i;ie.x-=(n.x+(t?t.e:0)+n.width/2)*(s-1),ie.y-=(n.y+(t?t.f:0)+n.height/2)*(s-1),ie.width*=s,ie.height*=s}t.copyWorld(i.canvas,t.bounds,ie)}else s&&(ee(ie,e),ie.x-=e.width/2*(s-1),ie.y-=e.height/2*(s-1),ie.width*=s,ie.height*=s),t.copyWorld(i.canvas,r,s?ie:e)}const{toOffsetOutBounds:ae}=l,oe={};var de=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:_}=s,f=e.getSameCanvas(),g=d.length-1;ae(l,oe),d.forEach(((d,p)=>{f.save(),f.setWorldShadow(oe.offsetX+d.x*u,oe.offsetY+d.y*_,d.blur*u),r=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,re(f,oe,r,s),f.restore(),h?(f.copyWorld(f,l,a,"copy"),f.copyWorld(h,a,a,"source-out"),n=a):(f.copyWorld(s.canvas,c,l,"source-out"),n=l),f.fillWorld(n,d.color,"source-in"),t.__hasMirror||i.matrix?e.copyWorldByReset(f,n,a,d.blendMode):e.copyWorldToInner(f,n,o.renderBounds,d.blendMode),g&&p<g&&f.clear()})),f.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:_}=s,f=e.getSameCanvas(),g=d.length-1;se(l,ne),d.forEach(((d,p)=>{f.setWorldShadow(ne.offsetX+d.x*u,ne.offsetY+d.y*_,d.blur*u,d.color),r=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,re(f,ne,r,s),n=l,d.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,a,"copy"),n=a),h?f.copyWorld(h,a,a,"destination-out"):f.copyWorld(s.canvas,c,l,"destination-out")),t.__hasMirror||i.matrix?e.copyWorldByReset(f,n,a,d.blendMode):e.copyWorldToInner(f,n,o.renderBounds,d.blendMode),g&&p<g&&f.clear()})),f.recycle()}});const he=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",le=he+"_#~&*+\\=|≮≯≈≠=…",ce=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ue(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const _e=ue("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),fe=ue("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ge=ue(he),pe=ue(le),ye=ue("- —/~|┆·");var we;!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"}(we||(we={}));const{Letter:me,Single:ve,Before:xe,After:be,Symbol:Be,Break:Re}=we;function Ee(t){return _e[t]?me:ye[t]?Re:fe[t]?xe:ge[t]?be:pe[t]?Be:ce.test(t)?ve:me}const Le={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function ke(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Se}=Le,{Letter:Ae,Single:Ce,Before:Me,After:Oe,Symbol:Te,Break:Ie}=we;let We,De,Pe,Fe,Ne,Ue,Ye,He,Ve,je,qe,Xe,Ge,ze,Qe,Ze,Ke=[];function $e(t,e){Ve&&!He&&(He=Ve),We.data.push({char:t,width:e}),Pe+=e}function Je(){Fe+=Pe,We.width=Pe,De.words.push(We),We={data:[]},Pe=0}function ts(){ze&&(Qe.paraNumber++,De.paraStart=!0,ze=!1),Ve&&(De.startCharSize=He,De.endCharSize=Ve,He=0),De.width=Fe,Ze.width&&Se(De),Ke.push(De),De={words:[]},Fe=0}const es={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let s=0,i=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,textOverflow:o,__font:d,padding:h}=e;if(h){const[t,e,a,o]=k.fourNumber(h);n&&(s=o,n-=e+o),r&&(i=t,r-=t+a)}const l={bounds:{x:s,y:i,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=d};return function(t,e,s){Qe=t,Ke=t.rows,Ze=t.bounds;const{__letterSpacing:i,paraIndent:n,textCase:r}=s,{canvas:a}=p,{width:o,height:d}=Ze;if(o||d||i||"none"!==r){ze=!0,qe=null,He=Ye=Ve=Pe=Fe=0,We={data:[]},De={words:[]};for(let t=0,s=e.length;t<s;t++)Ue=e[t],"\n"===Ue?(Pe&&Je(),De.paraEnd=!0,ts(),ze=!0):(je=Ee(Ue),je===Ae&&"none"!==r&&(Ue=ke(Ue,r,!Pe)),Ye=a.measureText(Ue).width,i&&(i<0&&(Ve=Ye),Ye+=i),Xe=je===Ce&&(qe===Ce||qe===Ae)||qe===Ce&&je!==Oe,Ge=!(je!==Me&&je!==Ce||qe!==Te&&qe!==Oe),Ne=ze&&n?o-n:o,o&&Fe+Pe+Ye>Ne&&(Ge||(Ge=je===Ae&&qe==Oe),Xe||Ge||je===Ie||je===Me||je===Ce||Pe+Ye>Ne?(Pe&&Je(),ts()):ts())," "===Ue&&!0!==ze&&Fe+Pe===0||(je===Ie?(" "===Ue&&Pe&&Je(),$e(Ue,Ye),Je()):Xe||Ge?(Pe&&Je(),$e(Ue,Ye)):$e(Ue,Ye)),qe=je);Pe&&Je(),Fe&&ts(),Ke.length>0&&(Ke[Ke.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Qe.paraNumber++,Ke.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:h,textOverflow:l}=e;let c,u,_,{x:f,y:g,width:p,height:y}=i,w=n*s.length+(h?h*(t.paraNumber-1):0),m=r;if("show"!==l&&w>y)w=Math.max(y,n),t.overflow=s.length;else switch(d){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let r=0,d=s.length;r<d;r++){switch(c=s[r],c.x=f,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&h&&r>0&&(m+=h),c.y=m,m+=n,t.overflow>r&&m>w&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,_=c.width,a<0&&(c.width<0?(_=-c.width+e.fontSize+a,u-=_,_+=e.fontSize):_-=a),u<i.x&&(i.x=u),_>i.width&&(i.width=_)}i.y=g,i.height=w}(l,e),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=s&&"justify"===r&&t.words.length>1?(s-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:s,overflow:i}=t;if(s.splice(i),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=s[i-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,o),"none"!==a&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(l,e),l}},ss={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},is={export(t,e,s){return function(t){ns||(ns=new S);return new Promise((e=>{ns.add((()=>_t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((i=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>_t(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof s){case"object":s.quality&&(t=s.quality),s.blob&&(a=!0);break;case"number":t=s;break;case"boolean":a=s}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),i({data:o}),n(),h&&d.recycle()})))):(i({data:!1}),n())}))))}};let ns;Object.assign(M,te),Object.assign(O,de),Object.assign(T,es),Object.assign(A,ss),Object.assign(I,is);export{z as Layouter,tt as LeaferCanvas,Z as Renderer,J as Selector,W as Watcher,et as useCanvas};
package/dist/node.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core");class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(e,s){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,s&&(this.config=t.DataHelper.default(s,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.push(e.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:n,updateAllWorldOpacity:i}=t.LeafHelper,{pushAllChildBranch:r,pushAllParent:a}=t.BranchHelper;const{worldBounds:o}=t.LeafBoundsHelper,{setByListWithHandle:d}=t.BoundsHelper;class l{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){d(this.beforeBounds,this.updatedList.list,o)}setAfter(){d(this.afterBounds,this.updatedList.list,o),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:h,updateAllChange:c}=t.LeafHelper,{pushAllBranchStack:u,updateWorldBoundsByBranchStack:f}=t.BranchHelper,g=t.Debug.get("Layouter");class _{constructor(e,s){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,s&&(this.config=t.DataHelper.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){g.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?g.warn("layouting"):this.times>3?g.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const s=t.Run.start("PartLayout"),{target:o,__updatedList:d}=this,{BEFORE:l,LAYOUT:h,AFTER:c}=t.LayoutEvent,u=this.getBlocks(d);u.forEach((t=>{t.setBefore()})),o.emitEvent(new t.LayoutEvent(l,u,this.times)),d.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(n(t),e.push(t),t.isBranch&&r(t,e),a(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),a(t,e)))}))}(d,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&i(t),t.__updateChange()}))}(d),u.forEach((t=>t.setAfter())),o.emitEvent(new t.LayoutEvent(h,u,this.times)),o.emitEvent(new t.LayoutEvent(c,u,this.times)),this.addBlocks(u),this.__levelList.reset(),this.__updatedList=null,t.Run.end(s)}fullLayout(){const e=t.Run.start("FullLayout"),{target:s}=this,{BEFORE:n,LAYOUT:i,AFTER:r}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(s));s.emitEvent(new t.LayoutEvent(n,a,this.times)),_.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new t.LayoutEvent(i,a,this.times)),s.emitEvent(new t.LayoutEvent(r,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(t){if(h(t),t.isBranch){const e=[t];u(t,e),f(e)}else t.__updateWorldBounds();c(t)}createBlock(t){return new l(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const p=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,s,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=s,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:s}=this;this.times=0,this.totalBounds=new t.Bounds,p.log(s.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,p.error(t)}p.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){return this.rendering?p.warn("rendering"):this.times>3?p.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e?(this.emitRender(t.RenderEvent.BEFORE),e()):(this.requestLayout(),this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return p.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const s=t.Run.start("PartRender"),{canvas:n}=this,i=e.getIntersect(n.bounds),r=e.includes(this.target.__world),a=(new t.Bounds).copy(i);n.save(),r&&!t.Debug.showRepaint?n.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,a),n.restore(),t.Run.end(s)}fullRender(){const e=t.Run.start("FullRender"),{canvas:s}=this;s.save(),s.clear(),this.__render(s.bounds),s.restore(),t.Run.end(e)}__render(e,s){const n=(null==e?void 0:e.includes(this.target.__world))?{}:{bounds:e};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,n),this.renderBounds=s||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(n),t.Debug.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const s=new t.Bounds;s.setByList(e),e.length=0,e.push(s)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(t.AnimateEvent.FRAME),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:s,height:n}=e.old;new t.Bounds(0,0,s,n).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||p.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,s,n){this.target.emitEvent(new t.RenderEvent(e,this.times,s,n))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:m}=t.BoundsHelper;class w{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const n=s.through||!1,i=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=i?this.getPath(a):this.getHitablePath(a);return this.clear(),n?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:e}=this;if(e.length>1){let s;this.findList=[];const{x:n,y:i}=this.point,r={x:n,y:i,radiusX:0,radiusY:0};for(let n=0,i=e.length;n<i;n++)if(s=e[n],t.LeafHelper.worldHittable(s)&&(this.hitChild(s,r),this.findList.length))return this.findList[0]}return e[0]}getPath(e){const s=new t.LeafList;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let n,i=new t.LeafList;for(let t=s.list.length-1;t>-1&&(n=s.list[t],n.__.hittable)&&(i.unshift(n),n.__.hitChildren);t--);return i}getThroughPath(e){const s=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let i,r,a;for(let t=0,e=n.length;t<e;t++){i=n[t],r=n[t+1];for(let t=0,e=i.length;t<e&&(a=i.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,n;const{point:i}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(n=!!s.__.hitRadius||m(s.__world,i),s.isBranch?(n||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,i)):n&&this.hitChild(s,i))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class v{constructor(e,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=e,s&&(this.config=t.DataHelper.default(s,this.config)),this.findPath=new w(e,this),this.__listenEvents()}getByPoint(e,s,n){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.findPath.getByPoint(e,s,n)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,n=this.innerIdList[t];return n||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,n=this.idList[t];return n||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let n=0,i=s.length;n<i;n++){if(e(t=s[n]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new _(t,e),renderer:(t,e,s)=>new y(t,e,s),selector:(t,e)=>new v(t,e)}),t.Platform.layout=_.fullLayout;class x extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}Object.assign(t.Creator,{canvas:(t,e)=>new x(t,e),image:e=>new t.LeaferImage(e),hitCanvas:(t,e)=>new x(t,e),interaction:(e,s,n,i)=>new t.InteractionBase(e,s,n,i)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0,t.Platform.realtimeLayout=!0;const{get:b,rotateOfOuter:B,translate:E,scaleOfOuter:L,scale:R,rotate:k}=t.MatrixHelper;const{get:S,translate:C}=t.MatrixHelper;function P(t,e,s,n){let{width:i,height:r}=e;const{opacity:a,mode:o,offset:d,scale:l,rotation:h,blendMode:c}=s,u=n.width===i&&n.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(i=n.width,r=n.height),(n.x||n.y)&&(f.transform=S(),C(f.transform,n.x,n.y));break;case"clip":(d||l||h)&&function(t,e,s,n,i){const r=b();E(r,e.x,e.y),s&&E(r,s.x,s.y),n&&("number"==typeof n?R(r,n):R(r,n.x,n.y),t.scaleX=r.a,t.scaleY=r.d),i&&k(r,i),t.transform=r}(f,n,d,l,h);break;case"repeat":(!u||l||h)&&function(t,e,s,n,i,r){const a=b();if(r)switch(k(a,r),r){case 90:E(a,n,0);break;case 180:E(a,s,n);break;case 270:E(a,0,s)}E(a,e.x,e.y),i&&(L(a,e,i),t.scaleX=t.scaleY=i),t.transform=a}(f,n,i,r,l,h);break;default:u&&!h||function(t,e,s,n,i,r){const a=b(),o=r&&180!==r,d=s.width/(o?i:n),l=s.height/(o?n:i),h="fit"===e?Math.min(d,l):Math.max(d,l),c=s.x+(s.width-n*h)/2,u=s.y+(s.height-i*h)/2;E(a,c,u),R(a,h),r&&B(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=h,t.transform=a}(f,o,n,i,r,h)}f.width=i,f.height=r,a&&(f.opacity=a)}function A(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function O(e,s){s.target.hasEvent(e)&&s.target.emitEvent(new t.ImageEvent(e,s))}function I(t,e,s,n){return new(s||(s=Promise))((function(i,r){function a(t){try{d(n.next(t))}catch(t){r(t)}}function o(t){try{d(n.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:M,scale:T,copy:W}=t.MatrixHelper;function D(e,s,n){let{scaleX:i,scaleY:r}=e.__world;const a=i+"-"+r;if(s.patternId===a||e.destroyed)return!1;{s.patternId=a,i=Math.abs(i),r=Math.abs(r);const{image:e,data:o}=s,d=e.isSVG?4096:Math.min(e.width,4096),l=e.isSVG?4096:Math.min(e.height,4096);let h,c,{width:u,height:f,scaleX:g,scaleY:_,opacity:p,transform:y,mode:m}=o;g&&(c=M(),W(c,y),T(c,1/g,1/_),i*=g,r*=_),i*=n,r*=n,u*=i,f*=r,(u>d||f>l)&&(h=Math.max(u/d,f/l)),h&&(i/=h,r/=h,u/=h,f/=h),g&&(i/=g,r/=_),(y||1!==i||1!==r)&&(c||(c=M(),y&&W(c,y)),T(c,1/i,1/r));const w=t.Platform.canvas.createPattern(e.getCanvas(u<1?1:u,f<1?1:f,p),"repeat"===m?"repeat":t.Platform.origin.noRepeat||"no-repeat");try{s.transform&&(s.transform=null),c&&(w.setTransform?w.setTransform(c):s.transform=c)}catch(t){s.transform=c}return s.style=w,!0}}function H(e,s,n,i){const{scaleX:r,scaleY:a}=e.__world;if(n.data&&n.patternId!==r+"-"+a){if(i)if(n.image.isSVG&&"repeat"!==n.data.mode){let{width:t,height:e}=n.data;t*=r*s.pixelRatio,e*=a*s.pixelRatio,i=t>4096||e>4096}else i=!1;if(i){s.save(),s.clip();const{data:t}=n;return n.blendMode&&(s.blendMode=n.blendMode),t.opacity&&(s.opacity*=t.opacity),t.transform&&s.transform(t.transform),s.drawImage(n.image.view,0,0,t.width,t.height),s.restore(),!0}return n.style?t.ImageManager.patternTasker.add((()=>I(this,void 0,void 0,(function*(){s.bounds.hit(e.__world)&&D(e,n,s.pixelRatio)&&e.forceUpdate("surface")}))),300):D(e,n,s.pixelRatio),!1}return!1}function F(e,s){const n="fill"===s?e._fill:e._stroke;if(n instanceof Array){let i,r,a,o;for(let d=0,l=n.length;d<l;d++)i=n[d].image,o=i&&i.url,o&&(r||(r={}),r[o]=!0,t.ImageManager.recycle(i),i.loading&&(a||(a=e.__input&&e.__input[s]||[],a instanceof Array||(a=[a])),i.unload(n[d].loadId,!a.some((t=>t.url===o)))));return r}return null}function N(t,e){let s;const{rows:n,decorationY:i,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)s=n[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),i&&e.fillRect(s.x,s.y+i,s.width,r)}function j(t,e,s){const{strokeAlign:n}=t.__,i="string"!=typeof s;switch(n){case"center":e.setStroke(i?void 0:s,t.__.strokeWidth,t.__),i?V(t,s,e,!0):Y(t,e);break;case"inside":U(t,e,s,"inside",i);break;case"outside":U(t,e,s,"outside",i)}}function U(t,e,s,n,i){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(i?void 0:s,2*r,t.__),o.font=a,i?V(t,s,o,!0):Y(t,o),o.blendMode="outside"===n?"destination-out":"destination-in",N(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function Y(t,e){let s;const{rows:n,decorationY:i,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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)})),i&&e.strokeRect(s.x,s.y+i,s.width,r)}function V(t,e,s,n){let i;for(let r=0,a=e.length;r<a;r++)i=e[r],i.image&&H(t,s,i,!1)||i.style&&(s.strokeStyle=i.style,i.blendMode?(s.saveBlendMode(i.blendMode),n?Y(t,s):s.stroke(),s.restoreBlendMode()):n?Y(t,s):s.stroke())}const{getSpread:q,getOuterOf:X,getByMove:G,getIntersectData:z}=t.BoundsHelper;const Q={x:.5,y:0},Z={x:.5,y:1};function K(t,s,n){let i;for(let r=0,a=s.length;r<a;r++)i=s[r],t.addColorStop(i.offset,e.ColorConvert.string(i.color,n))}const{set:$,getAngle:J,getDistance:tt}=t.PointHelper,{get:et,rotateOfOuter:st,scaleOfOuter:nt}=t.MatrixHelper,it={x:.5,y:.5},rt={x:.5,y:1},at={},ot={};const{set:dt,getAngle:lt,getDistance:ht}=t.PointHelper,{get:ct,rotateOfOuter:ut,scaleOfOuter:ft}=t.MatrixHelper,gt={x:.5,y:.5},_t={x:.5,y:1},pt={},yt={};let mt;function wt(s,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:r}=s.__layout;switch(n.type){case"solid":let{type:a,blendMode:o,color:d,opacity:l}=n;return{type:a,blendMode:o,style:e.ColorConvert.string(d,l)};case"image":return function(e,s,n,i,r){const a={type:n.type},o=a.image=t.ImageManager.get(n),d=(r||o.loading)&&{target:e,image:o,attrName:s,attrValue:n};return o.ready?(A(e,s,o)&&P(a,o,n,i),r&&(O(t.ImageEvent.LOAD,d),O(t.ImageEvent.LOADED,d))):o.error?r&&(e.forceUpdate("surface"),d.error=o.error,O(t.ImageEvent.ERROR,d)):(r&&O(t.ImageEvent.LOAD,d),a.loadId=o.load((()=>{e.destroyed||(A(e,s,o)&&(P(a,o,n,i),e.forceUpdate("surface")),O(t.ImageEvent.LOADED,d))}),(s=>{e.forceUpdate("surface"),d.error=s,O(t.ImageEvent.ERROR,d)}))),a}(s,i,n,r,!mt||!mt[n.url]);case"linear":return function(e,s){let{from:n,to:i,type:r,blendMode:a,opacity:o}=e;n||(n=Q),i||(i=Z);const d=t.Platform.canvas.createLinearGradient(s.x+n.x*s.width,s.y+n.y*s.height,s.x+i.x*s.width,s.y+i.y*s.height);K(d,e.stops,o);const l={type:r,style:d};return a&&(l.blendMode=a),l}(n,r);case"radial":return function(e,s){let{from:n,to:i,type:r,opacity:a,blendMode:o,stretch:d}=e;n||(n=it),i||(i=rt);const{x:l,y:h,width:c,height:u}=s;let f;$(at,l+n.x*c,h+n.y*u),$(ot,l+i.x*c,h+i.y*u),(c!==u||d)&&(f=et(),nt(f,at,c/u*(d||1),1),st(f,at,J(at,ot)+90));const g=t.Platform.canvas.createRadialGradient(at.x,at.y,0,at.x,at.y,tt(at,ot));K(g,e.stops,a);const _={type:r,style:g,transform:f};return o&&(_.blendMode=o),_}(n,r);case"angular":return function(e,s){let{from:n,to:i,type:r,opacity:a,blendMode:o,stretch:d}=e;n||(n=gt),i||(i=_t);const{x:l,y:h,width:c,height:u}=s;dt(pt,l+n.x*c,h+n.y*u),dt(yt,l+i.x*c,h+i.y*u);const f=ct(),g=lt(pt,yt);t.Platform.conicGradientRotate90?(ft(f,pt,c/u*(d||1),1),ut(f,pt,g+90)):(ft(f,pt,1,c/u*(d||1)),ut(f,pt,g));const _=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,pt.x,pt.y):t.Platform.canvas.createRadialGradient(pt.x,pt.y,0,pt.x,pt.y,ht(pt,yt));K(_,e.stops,a);const p={type:r,style:_,transform:f};return o&&(p.blendMode=o),p}(n,r);default:return n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}var vt=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let n,i=t.__.__input[e];i instanceof Array||(i=[i]),mt=F(t.__,e);for(let r=0,a=i.length;r<a;r++)n=wt(t,i[r],e),n&&s.push(n);t.__["_"+e]=s.length?s:void 0},drawTextStroke:Y,fill:function(t,e,s){e.fillStyle=s,t.__.__font?N(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:N,fills:function(t,e,s){let n;const{windingRule:i,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)n=s[a],n.image&&H(t,e,n,!r)||n.style&&(e.fillStyle=n.style,n.transform?(e.save(),e.transform(n.transform),n.blendMode&&(e.blendMode=n.blendMode),r?N(t,e):i?e.fill(i):e.fill(),e.restore()):n.blendMode?(e.saveBlendMode(n.blendMode),r?N(t,e):i?e.fill(i):e.fill(),e.restoreBlendMode()):r?N(t,e):i?e.fill(i):e.fill())},recycleImage:F,shape:function(t,e,s){const n=e.getSameCanvas();let i,r,a,o;const{__world:d}=t;let{scaleX:l,scaleY:h}=d;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(d,s.matrix))s.matrix?(l*=s.matrix.a,h*=s.matrix.d,i=a=X(d,s.matrix)):i=a=d,o=n;else{const{renderShapeSpread:n}=t.__layout,c=z(n?q(e.bounds,n*l,n*h):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),l*=r.a,h*=r.d),a=X(d,r),i=G(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(n,s),{canvas:n,matrix:r,bounds:i,worldCanvas:o,shapeBounds:a,scaleX:l,scaleY:h}},stroke:function(t,e,s){const n=t.__,{strokeWidth:i,strokeAlign:r,__font:a}=n;if(i)if(a)j(t,e,s);else switch(r){case"center":e.setStroke(s,i,n),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*i,n),n.windingRule?e.clip(n.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*i,t.__),t.__drawRenderPath(r),r.stroke(),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:j,strokes:function(t,e,s){const n=t.__,{strokeWidth:i,strokeAlign:r,__font:a}=n;if(i)if(a)j(t,e,s);else switch(r){case"center":e.setStroke(void 0,i,n),V(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*i,n),n.windingRule?e.clip(n.windingRule):e.clip(),V(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*i,t.__),V(t,s,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:xt,toOffsetOutBounds:bt}=t.BoundsHelper,Bt={},Et={};function Lt(e,s,n,i){const{bounds:r,shapeBounds:a}=i;if(t.Platform.fullImageShadow){if(xt(Bt,e.bounds),Bt.x+=s.x-a.x,Bt.y+=s.y-a.y,n){const{matrix:t}=i;Bt.x-=(r.x+(t?t.e:0)+r.width/2)*(n-1),Bt.y-=(r.y+(t?t.f:0)+r.height/2)*(n-1),Bt.width*=n,Bt.height*=n}e.copyWorld(i.canvas,e.bounds,Bt)}else n&&(xt(Bt,s),Bt.x-=s.width/2*(n-1),Bt.y-=s.height/2*(n-1),Bt.width*=n,Bt.height*=n),e.copyWorld(i.canvas,a,n?Bt:s)}const{toOffsetOutBounds:Rt}=t.BoundsHelper,kt={};var St=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:n}=t.__;s.setWorldBlur(n*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,n){let i,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:l,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=s,g=e.getSameCanvas(),_=d.length-1;Rt(h,kt),d.forEach(((n,d)=>{g.save(),g.setWorldShadow(kt.offsetX+n.x*u,kt.offsetY+n.y*f,n.blur*u),r=n.spread?1-2*n.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Lt(g,kt,r,s),g.restore(),l?(g.copyWorld(g,h,a,"copy"),g.copyWorld(l,a,a,"source-out"),i=a):(g.copyWorld(s.canvas,c,h,"source-out"),i=h),g.fillWorld(i,n.color,"source-in"),t.__hasMirror?e.copyWorldByReset(g,i,a,n.blendMode):e.copyWorldToInner(g,i,o.renderBounds,n.blendMode),_&&d<_&&g.clear()})),g.recycle()},shadow:function(t,e,s,n){let i,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:l,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=s,g=e.getSameCanvas(),_=d.length-1;bt(h,Et),d.forEach(((n,d)=>{g.setWorldShadow(Et.offsetX+n.x*u,Et.offsetY+n.y*f,n.blur*u,n.color),r=n.spread?1+2*n.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Lt(g,Et,r,s),i=h,n.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,h,a,"copy"),i=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(s.canvas,c,h,"destination-out")),t.__hasMirror?e.copyWorldByReset(g,i,a,n.blendMode):e.copyWorldToInner(g,i,o.renderBounds,n.blendMode),_&&d<_&&g.clear()})),g.recycle()}});const Ct=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Pt=Ct+"_#~&*+\\=|≮≯≈≠=…",At=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 Ot(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const It=Ot("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Mt=Ot("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Tt=Ot(Ct),Wt=Ot(Pt),Dt=Ot("- —/~|┆·");var Ht;!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"}(Ht||(Ht={}));const{Letter:Ft,Single:Nt,Before:jt,After:Ut,Symbol:Yt,Break:Vt}=Ht;function qt(t){return It[t]?Ft:Dt[t]?Vt:Mt[t]?jt:Tt[t]?Ut:Wt[t]?Yt:At.test(t)?Nt:Ft}const Xt={trimRight(t){const{words:e}=t;let s,n=0,i=e.length;for(let r=i-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)n++,t.width-=s.width;n&&e.splice(i-n,n)}};function Gt(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:zt}=Xt,{Letter:Qt,Single:Zt,Before:Kt,After:$t,Symbol:Jt,Break:te}=Ht;let ee,se,ne,ie,re,ae,oe,de,le,he,ce,ue,fe,ge,_e,pe,ye=[];function me(t,e){le&&!de&&(de=le),ee.data.push({char:t,width:e}),ne+=e}function we(){ie+=ne,ee.width=ne,se.words.push(ee),ee={data:[]},ne=0}function ve(){ge&&(_e.paraNumber++,se.paraStart=!0,ge=!1),le&&(se.startCharSize=de,se.endCharSize=le,de=0),se.width=ie,pe.width&&zt(se),ye.push(se),se={words:[]},ie=0}const xe={getDrawData(e,s){"string"!=typeof e&&(e=String(e));let n=0,i=0,r=s.__getInput("width")||0,a=s.__getInput("height")||0;const{textDecoration:o,textOverflow:d,__font:l,padding:h}=s;if(h){const[e,s,o,d]=t.MathHelper.fourNumber(h);r&&(n=d,r-=s+d),a&&(i=e,a-=e+o)}const c={bounds:{x:n,y:i,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,s,n){_e=e,ye=e.rows,pe=e.bounds;const{__letterSpacing:i,paraIndent:r,textCase:a}=n,{canvas:o}=t.Platform,{width:d,height:l}=pe;if(d||l||i||"none"!==a){ge=!0,ce=null,de=oe=le=ne=ie=0,ee={data:[]},se={words:[]};for(let t=0,e=s.length;t<e;t++)ae=s[t],"\n"===ae?(ne&&we(),se.paraEnd=!0,ve(),ge=!0):(he=qt(ae),he===Qt&&"none"!==a&&(ae=Gt(ae,a,!ne)),oe=o.measureText(ae).width,i&&(i<0&&(le=oe),oe+=i),ue=he===Zt&&(ce===Zt||ce===Qt)||ce===Zt&&he!==$t,fe=!(he!==Kt&&he!==Zt||ce!==Jt&&ce!==$t),re=ge&&r?d-r:d,d&&ie+ne+oe>re&&(fe||(fe=he===Qt&&ce==$t),ue||fe||he===te||he===Kt||he===Zt||ne+oe>re?(ne&&we(),ve()):ve())," "===ae&&!0!==ge&&ie+ne===0||(he===te?(" "===ae&&ne&&we(),me(ae,oe),we()):ue||fe?(ne&&we(),me(ae,oe)):me(ae,oe)),ce=he);ne&&we(),ie&&ve(),ye.length>0&&(ye[ye.length-1].paraEnd=!0)}else s.split("\n").forEach((t=>{_e.paraNumber++,ye.push({x:r||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(c,e,s),function(t,e){const{rows:s,bounds:n}=t,{__lineHeight:i,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:l,textOverflow:h}=e;let c,u,f,{x:g,y:_,width:p,height:y}=n,m=i*s.length+(l?l*(t.paraNumber-1):0),w=r;if("show"!==h&&m>y)m=Math.max(y,i),t.overflow=s.length;else switch(d){case"middle":_+=(y-m)/2;break;case"bottom":_+=y-m}w+=_;for(let r=0,d=s.length;r<d;r++){switch(c=s[r],c.x=g,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&r>0&&(w+=l),c.y=w,w+=i,t.overflow>r&&w>m&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<n.x&&(n.x=u),f>n.width&&(n.width=f)}n.y=_,n.height=m}(c,s),function(t,e,s,n){const{rows:i}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,l,h,c,u;i.forEach((t=>{t.words&&(h=a&&t.paraStart?a:0,l=s&&"justify"===r&&t.words.length>1?(s-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?0:l>.01?1:2,2===c?(t.text="",t.x+=h,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,s,r),c.overflow&&function(e,s){const{rows:n,overflow:i}=e;if(n.splice(i),"hide"!==s){"ellipsis"===s&&(s="...");const r=t.Platform.canvas.measureText(s).width,a=n[i-1];let o,d,l=a.data.length-1;const{x:h,width:c}=e.bounds,u=h+c-r;for(let t=l;t>-1&&(o=a.data[t],d=o.x+o.width,!(t===l&&d<u));t--){if(d<u&&" "!==o.char){a.data.splice(t+1),a.width-=o.width;break}a.width-=o.width}a.width+=r,a.data.push({char:s,x:d})}}(c,d),"none"!==o&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(c,s),c}},be={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},Be={export(e,s,n){return function(e){Ee||(Ee=new t.TaskProcessor);return new Promise((t=>{Ee.add((()=>I(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((t=>new Promise((i=>{const{leafer:r}=e;r?r.waitViewCompleted((()=>I(this,void 0,void 0,(function*(){let e,a,o,{canvas:d}=r,{unreal:l}=d;switch(l&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof n){case"object":n.quality&&(e=n.quality),n.blob&&(a=!0);break;case"number":e=n;break;case"boolean":a=n}o=s.includes(".")?yield d.saveAs(s,e):a?yield d.toBlob(s,e):yield d.toDataURL(s,e),t({data:o}),i(),l&&d.recycle()})))):(t({data:!1}),i())}))))}};let Ee;Object.assign(e.Paint,vt),Object.assign(e.Effect,St),Object.assign(e.TextConvert,xe),Object.assign(e.ColorConvert,be),Object.assign(e.Export,Be),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=_,exports.LeaferCanvas=x,exports.Renderer=y,exports.Selector=v,exports.Watcher=s,exports.useCanvas=function(e,s){if(!t.Platform.origin){if("skia"===e){const{Canvas:e,loadImage:n}=s;t.Platform.origin={createCanvas:(t,s,n)=>new e(t,s,n),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),loadImage:n}}t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core");class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(e,s){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,s&&(this.config=t.DataHelper.default(s,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.push(e.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:i,updateAllWorldOpacity:n}=t.LeafHelper,{pushAllChildBranch:r,pushAllParent:a}=t.BranchHelper;const{worldBounds:o}=t.LeafBoundsHelper,{setByListWithHandle:d}=t.BoundsHelper;class l{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){d(this.beforeBounds,this.updatedList.list,o)}setAfter(){d(this.afterBounds,this.updatedList.list,o),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:h,updateAllChange:c}=t.LeafHelper,{pushAllBranchStack:u,updateWorldBoundsByBranchStack:f}=t.BranchHelper,_=t.Debug.get("Layouter");class g{constructor(e,s){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,s&&(this.config=t.DataHelper.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){_.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?_.warn("layouting"):this.times>3?_.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const s=t.Run.start("PartLayout"),{target:o,__updatedList:d}=this,{BEFORE:l,LAYOUT:h,AFTER:c}=t.LayoutEvent,u=this.getBlocks(d);u.forEach((t=>{t.setBefore()})),o.emitEvent(new t.LayoutEvent(l,u,this.times)),d.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.proxyZoom&&(s.matrixChanged?(i(t),e.push(t),t.isBranch&&r(t,e),a(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),a(t,e)))}))}(d,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&n(t),t.__updateChange()}))}(d),u.forEach((t=>t.setAfter())),o.emitEvent(new t.LayoutEvent(h,u,this.times)),o.emitEvent(new t.LayoutEvent(c,u,this.times)),this.addBlocks(u),this.__levelList.reset(),this.__updatedList=null,t.Run.end(s)}fullLayout(){const e=t.Run.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(s));s.emitEvent(new t.LayoutEvent(i,a,this.times)),g.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new t.LayoutEvent(n,a,this.times)),s.emitEvent(new t.LayoutEvent(r,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(t){if(h(t),t.isBranch){const e=[t];u(t,e),f(e)}else t.__updateWorldBounds();c(t)}createBlock(t){return new l(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const p=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=s,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:s}=this;this.times=0,this.totalBounds=new t.Bounds,p.log(s.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,p.error(t)}p.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){return this.rendering?p.warn("rendering"):this.times>3?p.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e?(this.emitRender(t.RenderEvent.BEFORE),e()):(this.requestLayout(),this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return p.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const s=t.Run.start("PartRender"),{canvas:i}=this,n=e.getIntersect(i.bounds),r=e.includes(this.target.__world),a=(new t.Bounds).copy(n);i.save(),r&&!t.Debug.showRepaint?i.clear():(n.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,r,a),i.restore(),t.Run.end(s)}fullRender(){const e=t.Run.start("FullRender"),{canvas:s}=this;s.save(),s.clear(),this.__render(s.bounds,!0),s.restore(),t.Run.end(e)}__render(e,s,i){const n=e.includes(this.target.__world)?{includes:s}:{bounds:e,includes:s};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(n),t.Debug.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const s=new t.Bounds;s.setByList(e),e.length=0,e.push(s)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(t.AnimateEvent.FRAME),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:s,height:i}=e.old;new t.Bounds(0,0,s,i).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||p.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,s,i){this.target.emitEvent(new t.RenderEvent(e,this.times,s,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:m}=t.BoundsHelper;class w{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:e}=this;if(e.length>1){let s;this.findList=[];const{x:i,y:n}=this.point,r={x:i,y:n,radiusX:0,radiusY:0};for(let i=0,n=e.length;i<n;i++)if(s=e[i],t.LeafHelper.worldHittable(s)&&(this.hitChild(s,r),this.findList.length))return this.findList[0]}return e[0]}getPath(e){const s=new t.LeafList;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t.LeafList;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||m(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class v{constructor(e,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=e,s&&(this.config=t.DataHelper.default(s,this.config)),this.findPath=new w(e,this),this.__listenEvents()}getByPoint(e,s,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.findPath.getByPoint(e,s,i)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new g(t,e),renderer:(t,e,s)=>new y(t,e,s),selector:(t,e)=>new v(t,e)}),t.Platform.layout=g.fullLayout;class x extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}Object.assign(t.Creator,{canvas:(t,e)=>new x(t,e),image:e=>new t.LeaferImage(e),hitCanvas:(t,e)=>new x(t,e),interaction:(e,s,i,n)=>new t.InteractionBase(e,s,i,n)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0,t.Platform.realtimeLayout=!0;const{get:B,rotateOfOuter:b,translate:E,scaleOfOuter:L,scale:R,rotate:k}=t.MatrixHelper;const{get:S,translate:C}=t.MatrixHelper;function P(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:l,rotation:h,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(f.transform=S(),C(f.transform,i.x,i.y));break;case"clip":(d||l||h)&&function(t,e,s,i,n){const r=B();E(r,e.x,e.y),s&&E(r,s.x,s.y),i&&("number"==typeof i?R(r,i):R(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&k(r,n),t.transform=r}(f,i,d,l,h);break;case"repeat":(!u||l||h)&&function(t,e,s,i,n,r){const a=B();if(r)switch(k(a,r),r){case 90:E(a,i,0);break;case 180:E(a,s,i);break;case 270:E(a,0,s)}E(a,e.x,e.y),n&&(L(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,i,n,r,l,h);break;default:u&&!h||function(t,e,s,i,n,r){const a=B(),o=r&&180!==r,d=s.width/(o?n:i),l=s.height/(o?i:n),h="fit"===e?Math.min(d,l):Math.max(d,l),c=s.x+(s.width-i*h)/2,u=s.y+(s.height-n*h)/2;E(a,c,u),R(a,h),r&&b(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=h,t.transform=a}(f,o,i,n,r,h)}f.width=n,f.height=r,a&&(f.opacity=a)}function M(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function A(e,s){s.target.hasEvent(e)&&s.target.emitEvent(new t.ImageEvent(e,s))}function O(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:I,scale:T,copy:W}=t.MatrixHelper;function D(e,s,i){let{scaleX:n,scaleY:r}=e.__world;const a=n+"-"+r;if(s.patternId===a||e.destroyed)return!1;{s.patternId=a,n=Math.abs(n),r=Math.abs(r);const{image:e,data:o}=s,d=e.isSVG?4096:Math.min(e.width,4096),l=e.isSVG?4096:Math.min(e.height,4096);let h,c,{width:u,height:f,scaleX:_,scaleY:g,opacity:p,transform:y,mode:m}=o;_&&(c=I(),W(c,y),T(c,1/_,1/g),n*=_,r*=g),n*=i,r*=i,u*=n,f*=r,(u>d||f>l)&&(h=Math.max(u/d,f/l)),h&&(n/=h,r/=h,u/=h,f/=h),_&&(n/=_,r/=g),(y||1!==n||1!==r)&&(c||(c=I(),y&&W(c,y)),T(c,1/n,1/r));const w=t.Platform.canvas.createPattern(e.getCanvas(u<1?1:u,f<1?1:f,p),"repeat"===m?"repeat":t.Platform.origin.noRepeat||"no-repeat");try{s.transform&&(s.transform=null),c&&(w.setTransform?w.setTransform(c):s.transform=c)}catch(t){s.transform=c}return s.style=w,!0}}function H(e,s,i,n){const{scaleX:r,scaleY:a}=e.__world;if(i.data&&i.patternId!==r+"-"+a){if(n)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:e}=i.data;t*=r*s.pixelRatio,e*=a*s.pixelRatio,n=t>4096||e>4096}else n=!1;if(n){s.save(),s.clip();const{data:t}=i;return i.blendMode&&(s.blendMode=i.blendMode),t.opacity&&(s.opacity*=t.opacity),t.transform&&s.transform(t.transform),s.drawImage(i.image.view,0,0,t.width,t.height),s.restore(),!0}return i.style?i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add((()=>O(this,void 0,void 0,(function*(){i.patternTask=null,s.bounds.hit(e.__world)&&D(e,i,s.pixelRatio)&&e.forceUpdate("surface")}))),300)):D(e,i,s.pixelRatio),!1}return!1}function F(e,s){const i="fill"===e?s._fill:s._stroke;if(i instanceof Array){let n,r,a,o;for(let d=0,l=i.length;d<l;d++)n=i[d].image,o=n&&n.url,o&&(r||(r={}),r[o]=!0,t.ImageManager.recycle(n),n.loading&&(a||(a=s.__input&&s.__input[e]||[],a instanceof Array||(a=[a])),n.unload(i[d].loadId,!a.some((t=>t.url===o)))));return r}return null}function N(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function j(t,e,s,i){const{strokeAlign:n}=e.__,r="string"!=typeof t;switch(n){case"center":s.setStroke(r?void 0:t,e.__.strokeWidth,e.__),r?V(t,!0,e,s):Y(e,s);break;case"inside":U("inside",t,r,e,s,i);break;case"outside":U("outside",t,r,e,s,i)}}function U(t,e,s,i,n,r){const{strokeWidth:a,__font:o}=i.__,d=n.getSameCanvas(!0);d.setStroke(s?void 0:e,2*a,i.__),d.font=o,s?V(e,!0,i,d):Y(i,d),d.blendMode="outside"===t?"destination-out":"destination-in",N(i,d),d.blendMode="normal",i.__hasMirror||r.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,i.__world,i.__layout.renderBounds),d.recycle()}function Y(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[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)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function V(t,e,s,i){let n;for(let r=0,a=t.length;r<a;r++)n=t[r],n.image&&H(s,i,n,!1)||n.style&&(i.strokeStyle=n.style,n.blendMode?(i.saveBlendMode(n.blendMode),e?Y(s,i):i.stroke(),i.restoreBlendMode()):e?Y(s,i):i.stroke())}const{getSpread:q,getOuterOf:X,getByMove:G,getIntersectData:z}=t.BoundsHelper;const Q={x:.5,y:0},Z={x:.5,y:1};function K(t,s,i){let n;for(let r=0,a=s.length;r<a;r++)n=s[r],t.addColorStop(n.offset,e.ColorConvert.string(n.color,i))}const{set:$,getAngle:J,getDistance:tt}=t.PointHelper,{get:et,rotateOfOuter:st,scaleOfOuter:it}=t.MatrixHelper,nt={x:.5,y:.5},rt={x:.5,y:1},at={},ot={};const{set:dt,getAngle:lt,getDistance:ht}=t.PointHelper,{get:ct,rotateOfOuter:ut,scaleOfOuter:ft}=t.MatrixHelper,_t={x:.5,y:.5},gt={x:.5,y:1},pt={},yt={};let mt;function wt(s,i,n){if("object"!=typeof i||!1===i.visible||0===i.opacity)return;const{boxBounds:r}=n.__layout;switch(i.type){case"solid":let{type:a,blendMode:o,color:d,opacity:l}=i;return{type:a,blendMode:o,style:e.ColorConvert.string(d,l)};case"image":return function(e,s,i,n,r){const a={type:i.type},o=a.image=t.ImageManager.get(i),d=(r||o.loading)&&{target:e,image:o,attrName:s,attrValue:i};return o.ready?(M(e,s,o)&&P(a,o,i,n),r&&(A(t.ImageEvent.LOAD,d),A(t.ImageEvent.LOADED,d))):o.error?r&&(e.forceUpdate("surface"),d.error=o.error,A(t.ImageEvent.ERROR,d)):(r&&A(t.ImageEvent.LOAD,d),a.loadId=o.load((()=>{e.destroyed||(M(e,s,o)&&(P(a,o,i,n),e.forceUpdate("surface")),A(t.ImageEvent.LOADED,d))}),(s=>{e.forceUpdate("surface"),d.error=s,A(t.ImageEvent.ERROR,d)}))),a}(n,s,i,r,!mt||!mt[i.url]);case"linear":return function(e,s){let{from:i,to:n,type:r,blendMode:a,opacity:o}=e;i||(i=Q),n||(n=Z);const d=t.Platform.canvas.createLinearGradient(s.x+i.x*s.width,s.y+i.y*s.height,s.x+n.x*s.width,s.y+n.y*s.height);K(d,e.stops,o);const l={type:r,style:d};return a&&(l.blendMode=a),l}(i,r);case"radial":return function(e,s){let{from:i,to:n,type:r,opacity:a,blendMode:o,stretch:d}=e;i||(i=nt),n||(n=rt);const{x:l,y:h,width:c,height:u}=s;let f;$(at,l+i.x*c,h+i.y*u),$(ot,l+n.x*c,h+n.y*u),(c!==u||d)&&(f=et(),it(f,at,c/u*(d||1),1),st(f,at,J(at,ot)+90));const _=t.Platform.canvas.createRadialGradient(at.x,at.y,0,at.x,at.y,tt(at,ot));K(_,e.stops,a);const g={type:r,style:_,transform:f};return o&&(g.blendMode=o),g}(i,r);case"angular":return function(e,s){let{from:i,to:n,type:r,opacity:a,blendMode:o,stretch:d}=e;i||(i=_t),n||(n=gt);const{x:l,y:h,width:c,height:u}=s;dt(pt,l+i.x*c,h+i.y*u),dt(yt,l+n.x*c,h+n.y*u);const f=ct(),_=lt(pt,yt);t.Platform.conicGradientRotate90?(ft(f,pt,c/u*(d||1),1),ut(f,pt,_+90)):(ft(f,pt,1,c/u*(d||1)),ut(f,pt,_));const g=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,pt.x,pt.y):t.Platform.canvas.createRadialGradient(pt.x,pt.y,0,pt.x,pt.y,ht(pt,yt));K(g,e.stops,a);const p={type:r,style:g,transform:f};return o&&(p.blendMode=o),p}(i,r);default:return i.r?{type:"solid",style:e.ColorConvert.string(i)}:void 0}}var vt=Object.freeze({__proto__:null,compute:function(t,s){const i=[],n=s.__;let r,a,o=n.__input[t];o instanceof Array||(o=[o]),mt=F(t,n);for(let e=0,n=o.length;e<n;e++)r=wt(t,o[e],s),r&&i.push(r);if(n["_"+t]=i.length?i:void 0,1===o.length){const t=o[0];"image"===t.type&&(a=e.ImageManager.isPixel(t))}"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},drawTextStroke:Y,fill:function(t,e,s){s.fillStyle=t,e.__.__font?N(e,s):e.__.windingRule?s.fill(e.__.windingRule):s.fill()},fillText:N,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=e.__;for(let a=0,o=t.length;a<o;a++)i=t[a],i.image&&H(e,s,i,!r)||i.style&&(s.fillStyle=i.style,i.transform?(s.save(),s.transform(i.transform),i.blendMode&&(s.blendMode=i.blendMode),r?N(e,s):n?s.fill(n):s.fill(),s.restore()):i.blendMode?(s.saveBlendMode(i.blendMode),r?N(e,s):n?s.fill(n):s.fill(),s.restoreBlendMode()):r?N(e,s):n?s.fill(n):s.fill())},recycleImage:F,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:l,scaleY:h}=d;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(d,s.matrix))s.matrix?(l*=s.matrix.a,h*=s.matrix.d,n=a=X(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=z(i?q(e.bounds,i*l,i*h):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),l*=r.a,h*=r.d),a=X(d,r),n=G(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:l,scaleY:h}},stroke:function(t,e,s,i){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)j(t,e,s,i);else switch(a){case"center":s.setStroke(t,r,n),s.stroke();break;case"inside":s.save(),s.setStroke(t,2*r,n),n.windingRule?s.clip(n.windingRule):s.clip(),s.stroke(),s.restore();break;case"outside":const a=s.getSameCanvas(!0);a.setStroke(t,2*r,e.__),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__hasMirror||i.matrix?s.copyWorldByReset(a):s.copyWorldToInner(a,e.__world,e.__layout.renderBounds),a.recycle()}},strokeText:j,strokes:function(t,e,s,i){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)j(t,e,s,i);else switch(a){case"center":s.setStroke(void 0,r,n),V(t,!1,e,s);break;case"inside":s.save(),s.setStroke(void 0,2*r,n),n.windingRule?s.clip(n.windingRule):s.clip(),V(t,!1,e,s),s.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=s.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*r,e.__),V(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__hasMirror||i.matrix?s.copyWorldByReset(o):s.copyWorldToInner(o,e.__world,a),o.recycle()}}});const{copy:xt,toOffsetOutBounds:Bt}=t.BoundsHelper,bt={},Et={};function Lt(e,s,i,n){const{bounds:r,shapeBounds:a}=n;if(t.Platform.fullImageShadow){if(xt(bt,e.bounds),bt.x+=s.x-a.x,bt.y+=s.y-a.y,i){const{matrix:t}=n;bt.x-=(r.x+(t?t.e:0)+r.width/2)*(i-1),bt.y-=(r.y+(t?t.f:0)+r.height/2)*(i-1),bt.width*=i,bt.height*=i}e.copyWorld(n.canvas,e.bounds,bt)}else i&&(xt(bt,s),bt.x-=s.width/2*(i-1),bt.y-=s.height/2*(i-1),bt.width*=i,bt.height*=i),e.copyWorld(n.canvas,a,i?bt:s)}const{toOffsetOutBounds:Rt}=t.BoundsHelper,kt={};var St=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:l,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;Rt(h,kt),d.forEach(((d,p)=>{_.save(),_.setWorldShadow(kt.offsetX+d.x*u,kt.offsetY+d.y*f,d.blur*u),r=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Lt(_,kt,r,s),_.restore(),l?(_.copyWorld(_,h,a,"copy"),_.copyWorld(l,a,a,"source-out"),n=a):(_.copyWorld(s.canvas,c,h,"source-out"),n=h),_.fillWorld(n,d.color,"source-in"),t.__hasMirror||i.matrix?e.copyWorldByReset(_,n,a,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:l,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;Bt(h,Et),d.forEach(((d,p)=>{_.setWorldShadow(Et.offsetX+d.x*u,Et.offsetY+d.y*f,d.blur*u,d.color),r=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Lt(_,Et,r,s),n=h,d.box&&(_.restore(),_.save(),l&&(_.copyWorld(_,h,a,"copy"),n=a),l?_.copyWorld(l,a,a,"destination-out"):_.copyWorld(s.canvas,c,h,"destination-out")),t.__hasMirror||i.matrix?e.copyWorldByReset(_,n,a,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()}});const Ct=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Pt=Ct+"_#~&*+\\=|≮≯≈≠=…",Mt=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 At(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ot=At("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),It=At("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Tt=At(Ct),Wt=At(Pt),Dt=At("- —/~|┆·");var Ht;!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"}(Ht||(Ht={}));const{Letter:Ft,Single:Nt,Before:jt,After:Ut,Symbol:Yt,Break:Vt}=Ht;function qt(t){return Ot[t]?Ft:Dt[t]?Vt:It[t]?jt:Tt[t]?Ut:Wt[t]?Yt:Mt.test(t)?Nt:Ft}const Xt={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Gt(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:zt}=Xt,{Letter:Qt,Single:Zt,Before:Kt,After:$t,Symbol:Jt,Break:te}=Ht;let ee,se,ie,ne,re,ae,oe,de,le,he,ce,ue,fe,_e,ge,pe,ye=[];function me(t,e){le&&!de&&(de=le),ee.data.push({char:t,width:e}),ie+=e}function we(){ne+=ie,ee.width=ie,se.words.push(ee),ee={data:[]},ie=0}function ve(){_e&&(ge.paraNumber++,se.paraStart=!0,_e=!1),le&&(se.startCharSize=de,se.endCharSize=le,de=0),se.width=ne,pe.width&&zt(se),ye.push(se),se={words:[]},ne=0}const xe={getDrawData(e,s){"string"!=typeof e&&(e=String(e));let i=0,n=0,r=s.__getInput("width")||0,a=s.__getInput("height")||0;const{textDecoration:o,textOverflow:d,__font:l,padding:h}=s;if(h){const[e,s,o,d]=t.MathHelper.fourNumber(h);r&&(i=d,r-=s+d),a&&(n=e,a-=e+o)}const c={bounds:{x:i,y:n,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,s,i){ge=e,ye=e.rows,pe=e.bounds;const{__letterSpacing:n,paraIndent:r,textCase:a}=i,{canvas:o}=t.Platform,{width:d,height:l}=pe;if(d||l||n||"none"!==a){_e=!0,ce=null,de=oe=le=ie=ne=0,ee={data:[]},se={words:[]};for(let t=0,e=s.length;t<e;t++)ae=s[t],"\n"===ae?(ie&&we(),se.paraEnd=!0,ve(),_e=!0):(he=qt(ae),he===Qt&&"none"!==a&&(ae=Gt(ae,a,!ie)),oe=o.measureText(ae).width,n&&(n<0&&(le=oe),oe+=n),ue=he===Zt&&(ce===Zt||ce===Qt)||ce===Zt&&he!==$t,fe=!(he!==Kt&&he!==Zt||ce!==Jt&&ce!==$t),re=_e&&r?d-r:d,d&&ne+ie+oe>re&&(fe||(fe=he===Qt&&ce==$t),ue||fe||he===te||he===Kt||he===Zt||ie+oe>re?(ie&&we(),ve()):ve())," "===ae&&!0!==_e&&ne+ie===0||(he===te?(" "===ae&&ie&&we(),me(ae,oe),we()):ue||fe?(ie&&we(),me(ae,oe)):me(ae,oe)),ce=he);ie&&we(),ne&&ve(),ye.length>0&&(ye[ye.length-1].paraEnd=!0)}else s.split("\n").forEach((t=>{ge.paraNumber++,ye.push({x:r||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(c,e,s),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:l,textOverflow:h}=e;let c,u,f,{x:_,y:g,width:p,height:y}=i,m=n*s.length+(l?l*(t.paraNumber-1):0),w=r;if("show"!==h&&m>y)m=Math.max(y,n),t.overflow=s.length;else switch(d){case"middle":g+=(y-m)/2;break;case"bottom":g+=y-m}w+=g;for(let r=0,d=s.length;r<d;r++){switch(c=s[r],c.x=_,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&r>0&&(w+=l),c.y=w,w+=n,t.overflow>r&&w>m&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<i.x&&(i.x=u),f>i.width&&(i.width=f)}i.y=g,i.height=m}(c,s),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,l,h,c,u;n.forEach((t=>{t.words&&(h=a&&t.paraStart?a:0,l=s&&"justify"===r&&t.words.length>1?(s-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?0:l>.01?1:2,2===c?(t.text="",t.x+=h,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,s,r),c.overflow&&function(e,s){const{rows:i,overflow:n}=e;if(i.splice(n),"hide"!==s){"ellipsis"===s&&(s="...");const r=t.Platform.canvas.measureText(s).width,a=i[n-1];let o,d,l=a.data.length-1;const{x:h,width:c}=e.bounds,u=h+c-r;for(let t=l;t>-1&&(o=a.data[t],d=o.x+o.width,!(t===l&&d<u));t--){if(d<u&&" "!==o.char){a.data.splice(t+1),a.width-=o.width;break}a.width-=o.width}a.width+=r,a.data.push({char:s,x:d})}}(c,d),"none"!==o&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(c,s),c}},Be={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},be={export(e,s,i){return function(e){Ee||(Ee=new t.TaskProcessor);return new Promise((t=>{Ee.add((()=>O(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((t=>new Promise((n=>{const{leafer:r}=e;r?r.waitViewCompleted((()=>O(this,void 0,void 0,(function*(){let e,a,o,{canvas:d}=r,{unreal:l}=d;switch(l&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof i){case"object":i.quality&&(e=i.quality),i.blob&&(a=!0);break;case"number":e=i;break;case"boolean":a=i}o=s.includes(".")?yield d.saveAs(s,e):a?yield d.toBlob(s,e):yield d.toDataURL(s,e),t({data:o}),n(),l&&d.recycle()})))):(t({data:!1}),n())}))))}};let Ee;Object.assign(e.Paint,vt),Object.assign(e.Effect,St),Object.assign(e.TextConvert,xe),Object.assign(e.ColorConvert,Be),Object.assign(e.Export,be),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=g,exports.LeaferCanvas=x,exports.Renderer=y,exports.Selector=v,exports.Watcher=s,exports.useCanvas=function(e,s){if(!t.Platform.origin){if("skia"===e){const{Canvas:e,loadImage:i}=s;t.Platform.origin={createCanvas:(t,s,i)=>new e(t,s,i),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),loadImage:i}}t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/node",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.5",
4
4
  "description": "@leafer-ui/node",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -29,10 +29,10 @@
29
29
  "leaferjs"
30
30
  ],
31
31
  "dependencies": {
32
- "@leafer/node": "1.0.0-rc.3",
33
- "@leafer-ui/core": "1.0.0-rc.3",
34
- "@leafer-ui/partner": "1.0.0-rc.3",
35
- "@leafer-ui/interface": "1.0.0-rc.3",
36
- "leafer-in": "1.0.0-rc.3"
32
+ "@leafer/node": "1.0.0-rc.5",
33
+ "@leafer-ui/core": "1.0.0-rc.5",
34
+ "@leafer-ui/partner": "1.0.0-rc.5",
35
+ "@leafer-ui/interface": "1.0.0-rc.5",
36
+ "leafer-in": "1.0.0-rc.5"
37
37
  }
38
38
  }