@leafer-ui/miniapp 1.0.0-rc.2 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1413,7 +1413,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1413
1413
  }
1414
1414
  }
1415
1415
 
1416
- function recycleImage(data, attrName) {
1416
+ function recycleImage(attrName, data) {
1417
1417
  const paints = (attrName === 'fill' ? data._fill : data._stroke);
1418
1418
  if (paints instanceof Array) {
1419
1419
  let image, recycleMap, input, url;
@@ -1458,11 +1458,11 @@ function fillText(ui, canvas) {
1458
1458
  }
1459
1459
  }
1460
1460
 
1461
- function fill(ui, canvas, fill) {
1461
+ function fill(fill, ui, canvas) {
1462
1462
  canvas.fillStyle = fill;
1463
1463
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
1464
1464
  }
1465
- function fills(ui, canvas, fills) {
1465
+ function fills(fills, ui, canvas) {
1466
1466
  let item;
1467
1467
  const { windingRule, __font } = ui.__;
1468
1468
  for (let i = 0, len = fills.length; i < len; i++) {
@@ -1493,32 +1493,37 @@ function fills(ui, canvas, fills) {
1493
1493
  }
1494
1494
  }
1495
1495
 
1496
- function strokeText(ui, canvas, stroke) {
1496
+ function strokeText(stroke, ui, canvas, renderOptions) {
1497
1497
  const { strokeAlign } = ui.__;
1498
1498
  const isStrokes = typeof stroke !== 'string';
1499
1499
  switch (strokeAlign) {
1500
1500
  case 'center':
1501
1501
  canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
1502
- isStrokes ? drawStrokesStyle(ui, stroke, canvas, true) : drawTextStroke(ui, canvas);
1502
+ isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
1503
1503
  break;
1504
1504
  case 'inside':
1505
- drawAlignStroke(ui, canvas, stroke, 'inside', isStrokes);
1505
+ drawAlignStroke('inside', stroke, isStrokes, ui, canvas, renderOptions);
1506
1506
  break;
1507
1507
  case 'outside':
1508
- drawAlignStroke(ui, canvas, stroke, 'outside', isStrokes);
1508
+ drawAlignStroke('outside', stroke, isStrokes, ui, canvas, renderOptions);
1509
1509
  break;
1510
1510
  }
1511
1511
  }
1512
- function drawAlignStroke(ui, canvas, stroke, align, isStrokes) {
1512
+ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
1513
1513
  const { strokeWidth, __font } = ui.__;
1514
1514
  const out = canvas.getSameCanvas(true);
1515
1515
  out.setStroke(isStrokes ? undefined : stroke, strokeWidth * 2, ui.__);
1516
1516
  out.font = __font;
1517
- isStrokes ? drawStrokesStyle(ui, stroke, out, true) : drawTextStroke(ui, out);
1517
+ isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
1518
1518
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
1519
1519
  fillText(ui, out);
1520
1520
  out.blendMode = 'normal';
1521
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1521
+ if (ui.__hasMirror || renderOptions.matrix) {
1522
+ canvas.copyWorldByReset(out);
1523
+ }
1524
+ else {
1525
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1526
+ }
1522
1527
  out.recycle();
1523
1528
  }
1524
1529
  function drawTextStroke(ui, canvas) {
@@ -1538,7 +1543,7 @@ function drawTextStroke(ui, canvas) {
1538
1543
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
1539
1544
  }
1540
1545
  }
1541
- function drawStrokesStyle(ui, strokes, canvas, isText) {
1546
+ function drawStrokesStyle(strokes, isText, ui, canvas) {
1542
1547
  let item;
1543
1548
  for (let i = 0, len = strokes.length; i < len; i++) {
1544
1549
  item = strokes[i];
@@ -1558,13 +1563,13 @@ function drawStrokesStyle(ui, strokes, canvas, isText) {
1558
1563
  }
1559
1564
  }
1560
1565
 
1561
- function stroke(ui, canvas, stroke) {
1566
+ function stroke(stroke, ui, canvas, renderOptions) {
1562
1567
  const options = ui.__;
1563
1568
  const { strokeWidth, strokeAlign, __font } = options;
1564
1569
  if (!strokeWidth)
1565
1570
  return;
1566
1571
  if (__font) {
1567
- strokeText(ui, canvas, stroke);
1572
+ strokeText(stroke, ui, canvas, renderOptions);
1568
1573
  }
1569
1574
  else {
1570
1575
  switch (strokeAlign) {
@@ -1586,31 +1591,36 @@ function stroke(ui, canvas, stroke) {
1586
1591
  out.stroke();
1587
1592
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1588
1593
  out.clearWorld(ui.__layout.renderBounds);
1589
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1594
+ if (ui.__hasMirror || renderOptions.matrix) {
1595
+ canvas.copyWorldByReset(out);
1596
+ }
1597
+ else {
1598
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1599
+ }
1590
1600
  out.recycle();
1591
1601
  break;
1592
1602
  }
1593
1603
  }
1594
1604
  }
1595
- function strokes(ui, canvas, strokes) {
1605
+ function strokes(strokes, ui, canvas, renderOptions) {
1596
1606
  const options = ui.__;
1597
1607
  const { strokeWidth, strokeAlign, __font } = options;
1598
1608
  if (!strokeWidth)
1599
1609
  return;
1600
1610
  if (__font) {
1601
- strokeText(ui, canvas, strokes);
1611
+ strokeText(strokes, ui, canvas, renderOptions);
1602
1612
  }
1603
1613
  else {
1604
1614
  switch (strokeAlign) {
1605
1615
  case 'center':
1606
1616
  canvas.setStroke(undefined, strokeWidth, options);
1607
- drawStrokesStyle(ui, strokes, canvas);
1617
+ drawStrokesStyle(strokes, false, ui, canvas);
1608
1618
  break;
1609
1619
  case 'inside':
1610
1620
  canvas.save();
1611
1621
  canvas.setStroke(undefined, strokeWidth * 2, options);
1612
1622
  options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
1613
- drawStrokesStyle(ui, strokes, canvas);
1623
+ drawStrokesStyle(strokes, false, ui, canvas);
1614
1624
  canvas.restore();
1615
1625
  break;
1616
1626
  case 'outside':
@@ -1618,10 +1628,15 @@ function strokes(ui, canvas, strokes) {
1618
1628
  const out = canvas.getSameCanvas(true);
1619
1629
  ui.__drawRenderPath(out);
1620
1630
  out.setStroke(undefined, strokeWidth * 2, ui.__);
1621
- drawStrokesStyle(ui, strokes, out);
1631
+ drawStrokesStyle(strokes, false, ui, out);
1622
1632
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1623
1633
  out.clearWorld(renderBounds);
1624
- canvas.copyWorldToInner(out, ui.__world, renderBounds);
1634
+ if (ui.__hasMirror || renderOptions.matrix) {
1635
+ canvas.copyWorldByReset(out);
1636
+ }
1637
+ else {
1638
+ canvas.copyWorldToInner(out, ui.__world, renderBounds);
1639
+ }
1625
1640
  out.recycle();
1626
1641
  break;
1627
1642
  }
@@ -1753,21 +1768,21 @@ function conicGradient(paint, box) {
1753
1768
  }
1754
1769
 
1755
1770
  let recycleMap;
1756
- function compute(ui, attrName) {
1771
+ function compute(attrName, ui) {
1757
1772
  const value = [];
1758
1773
  let item;
1759
1774
  let paints = ui.__.__input[attrName];
1760
1775
  if (!(paints instanceof Array))
1761
1776
  paints = [paints];
1762
- recycleMap = recycleImage(ui.__, attrName);
1777
+ recycleMap = recycleImage(attrName, ui.__);
1763
1778
  for (let i = 0, len = paints.length; i < len; i++) {
1764
- item = getLeafPaint(ui, paints[i], attrName);
1779
+ item = getLeafPaint(attrName, paints[i], ui);
1765
1780
  if (item)
1766
1781
  value.push(item);
1767
1782
  }
1768
1783
  ui.__['_' + attrName] = value.length ? value : undefined;
1769
1784
  }
1770
- function getLeafPaint(ui, paint, attrName) {
1785
+ function getLeafPaint(attrName, paint, ui) {
1771
1786
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
1772
1787
  return undefined;
1773
1788
  const { boxBounds } = ui.__layout;
@@ -1805,7 +1820,7 @@ var UIPaint = /*#__PURE__*/Object.freeze({
1805
1820
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
1806
1821
  const tempBounds = {};
1807
1822
  const offsetOutBounds$1 = {};
1808
- function shadow(ui, current, shape, _options) {
1823
+ function shadow(ui, current, shape, renderOptions) {
1809
1824
  let copyBounds, spreadScale;
1810
1825
  const { __world, __layout } = ui;
1811
1826
  const { shadow } = ui.__;
@@ -1827,7 +1842,7 @@ function shadow(ui, current, shape, _options) {
1827
1842
  }
1828
1843
  worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1829
1844
  }
1830
- if (ui.__hasMirror) {
1845
+ if (ui.__hasMirror || renderOptions.matrix) {
1831
1846
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
1832
1847
  }
1833
1848
  else {
@@ -1867,7 +1882,7 @@ function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1867
1882
 
1868
1883
  const { toOffsetOutBounds } = BoundsHelper;
1869
1884
  const offsetOutBounds = {};
1870
- function innerShadow(ui, current, shape, _options) {
1885
+ function innerShadow(ui, current, shape, renderOptions) {
1871
1886
  let copyBounds, spreadScale;
1872
1887
  const { __world, __layout: __layout } = ui;
1873
1888
  const { innerShadow } = ui.__;
@@ -1891,7 +1906,7 @@ function innerShadow(ui, current, shape, _options) {
1891
1906
  copyBounds = bounds;
1892
1907
  }
1893
1908
  other.fillWorld(copyBounds, item.color, 'source-in');
1894
- if (ui.__hasMirror) {
1909
+ if (ui.__hasMirror || renderOptions.matrix) {
1895
1910
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
1896
1911
  }
1897
1912
  else {
@@ -2029,7 +2044,7 @@ function getTextCase(char, textCase, firstChar) {
2029
2044
  const { trimRight } = TextRowHelper;
2030
2045
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
2031
2046
  let word, row, wordWidth, rowWidth, realWidth;
2032
- let char, charWidth, charType, lastCharType, langBreak, afterBreak, paraStart;
2047
+ let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
2033
2048
  let textDrawData, rows = [], bounds;
2034
2049
  function createRows(drawData, content, style) {
2035
2050
  textDrawData = drawData;
@@ -2042,7 +2057,7 @@ function createRows(drawData, content, style) {
2042
2057
  if (charMode) {
2043
2058
  paraStart = true;
2044
2059
  lastCharType = null;
2045
- wordWidth = rowWidth = 0;
2060
+ startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
2046
2061
  word = { data: [] }, row = { words: [] };
2047
2062
  for (let i = 0, len = content.length; i < len; i++) {
2048
2063
  char = content[i];
@@ -2058,8 +2073,11 @@ function createRows(drawData, content, style) {
2058
2073
  if (charType === Letter && textCase !== 'none')
2059
2074
  char = getTextCase(char, textCase, !wordWidth);
2060
2075
  charWidth = canvas.measureText(char).width;
2061
- if (__letterSpacing)
2076
+ if (__letterSpacing) {
2077
+ if (__letterSpacing < 0)
2078
+ charSize = charWidth;
2062
2079
  charWidth += __letterSpacing;
2080
+ }
2063
2081
  langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
2064
2082
  afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
2065
2083
  realWidth = paraStart && paraIndent ? width - paraIndent : width;
@@ -2109,6 +2127,8 @@ function createRows(drawData, content, style) {
2109
2127
  }
2110
2128
  }
2111
2129
  function addChar(char, width) {
2130
+ if (charSize && !startCharSize)
2131
+ startCharSize = charSize;
2112
2132
  word.data.push({ char, width });
2113
2133
  wordWidth += width;
2114
2134
  }
@@ -2125,6 +2145,11 @@ function addRow() {
2125
2145
  row.paraStart = true;
2126
2146
  paraStart = false;
2127
2147
  }
2148
+ if (charSize) {
2149
+ row.startCharSize = startCharSize;
2150
+ row.endCharSize = charSize;
2151
+ startCharSize = 0;
2152
+ }
2128
2153
  row.width = rowWidth;
2129
2154
  if (bounds.width)
2130
2155
  trimRight(row);
@@ -2198,7 +2223,7 @@ function toChar(data, charX, rowData) {
2198
2223
 
2199
2224
  function layoutText(drawData, style) {
2200
2225
  const { rows, bounds } = drawData;
2201
- const { __lineHeight, __baseLine, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
2226
+ const { __lineHeight, __baseLine, __letterSpacing, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
2202
2227
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2203
2228
  let starY = __baseLine;
2204
2229
  if (textOverflow !== 'show' && realHeight > height) {
@@ -2215,7 +2240,7 @@ function layoutText(drawData, style) {
2215
2240
  }
2216
2241
  }
2217
2242
  starY += y;
2218
- let row;
2243
+ let row, rowX, rowWidth;
2219
2244
  for (let i = 0, len = rows.length; i < len; i++) {
2220
2245
  row = rows[i];
2221
2246
  row.x = x;
@@ -2234,20 +2259,22 @@ function layoutText(drawData, style) {
2234
2259
  row.isOverflow = true;
2235
2260
  drawData.overflow = i + 1;
2236
2261
  }
2237
- if (row.width < 0) {
2238
- const charWidth = row.words[0].data[0].width;
2239
- const rowX = row.x + row.width;
2240
- if (rowX < bounds.x)
2241
- bounds.x = rowX - charWidth;
2242
- if (-row.width > bounds.width)
2243
- bounds.width = -row.width + style.fontSize + charWidth;
2244
- }
2245
- else {
2246
- if (row.x < bounds.x)
2247
- bounds.x = row.x;
2248
- if (row.width > bounds.width)
2249
- bounds.width = row.width;
2262
+ rowX = row.x;
2263
+ rowWidth = row.width;
2264
+ if (__letterSpacing < 0) {
2265
+ if (row.width < 0) {
2266
+ rowWidth = -row.width + style.fontSize + __letterSpacing;
2267
+ rowX -= rowWidth;
2268
+ rowWidth += style.fontSize;
2269
+ }
2270
+ else {
2271
+ rowWidth -= __letterSpacing;
2272
+ }
2250
2273
  }
2274
+ if (rowX < bounds.x)
2275
+ bounds.x = rowX;
2276
+ if (rowWidth > bounds.width)
2277
+ bounds.width = rowWidth;
2251
2278
  }
2252
2279
  bounds.y = y;
2253
2280
  bounds.height = realHeight;
@@ -2299,10 +2326,9 @@ const TextConvert = {
2299
2326
  if (typeof content !== 'string')
2300
2327
  content = String(content);
2301
2328
  let x = 0, y = 0;
2302
- let { width, height, padding } = style;
2303
- const { textDecoration, textOverflow, __font } = style;
2304
- if (!width)
2305
- width = 0;
2329
+ let width = style.__getInput('width') || 0;
2330
+ let height = style.__getInput('height') || 0;
2331
+ const { textDecoration, textOverflow, __font, padding } = style;
2306
2332
  if (padding) {
2307
2333
  const [top, right, bottom, left] = MathHelper.fourNumber(padding);
2308
2334
  if (width) {
@@ -2417,14 +2443,9 @@ LeaferCanvas.prototype.__createContext = function () {
2417
2443
  if (this.viewSelect) {
2418
2444
  const offscreenView = Platform$1.origin.createCanvas(1, 1);
2419
2445
  const context = this.view.getContext('2d');
2420
- try {
2421
- context.drawImage(offscreenView, 0, 0);
2422
- }
2423
- catch (e) {
2424
- this.testView = this.view;
2425
- this.testContext = context;
2426
- this.view = offscreenView;
2427
- }
2446
+ this.testView = this.view;
2447
+ this.testContext = context;
2448
+ this.view = offscreenView;
2428
2449
  }
2429
2450
  this.context = this.view.getContext('2d');
2430
2451
  this.__bindContext();
@@ -1 +1 @@
1
- import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as o,LeafHelper as r,BranchHelper as a,Bounds as h,LeafBoundsHelper as d,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as g,Run as f,ImageManager as _,Platform as p,AnimateEvent as w,ResizeEvent as y,Creator as m,LeaferCanvasBase as v,canvasPatch as x,canvasSizeAttrs as b,InteractionHelper as B,InteractionBase as R,LeaferImage as L,FileHelper as E,MatrixHelper as S,ImageEvent as T,PointHelper as k,MathHelper as A,TaskProcessor as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as M,Paint as O,Effect as I,TextConvert as P,Export as W,Platform as D}from"@leafer-ui/core";export*from"@leafer-ui/core";class z{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(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,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}update(){this.changed=!0,this.running&&this.target.emit(i.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===s.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,i=e.length;t<i;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_(o.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.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:F,updateAllWorldOpacity:V}=r,{pushAllChildBranch:N,pushAllParent:U}=a;const{worldBounds:Y}=d,{setByListWithHandle:H}=l;class j{constructor(e){this.updatedBounds=new h,this.beforeBounds=new h,this.afterBounds=new h,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){H(this.beforeBounds,this.updatedList.list,Y)}setAfter(){H(this.afterBounds,this.updatedList.list,Y),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:X,updateAllChange:G}=r,{pushAllBranchStack:q,updateWorldBoundsByBranchStack:Q}=a,K=c.get("Layouter");class Z{constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,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}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(g.START),this.layoutOnce(),t.emitEvent(new g(g.END,this.layoutedBlocks,this.times))}catch(t){K.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?K.warn("layouting"):this.times>3?K.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:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=g,a=this.getBlocks(s);a.forEach((t=>{t.setBefore()})),i.emitEvent(new g(n,a,this.times)),s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.useZoomProxy&&(i.matrixChanged?(F(t),e.push(t),t.isBranch&&N(t,e),U(t,e)):i.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),U(t,e)))}))}(s,this.__levelList),function(t){let e,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber)for(let t=0,e=i.children.length;t<e;t++)i.children[t].isBranch||i.children[t].__updateWorldBounds();i.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&V(t),t.__updateChange()}))}(s),a.forEach((t=>t.setAfter())),i.emitEvent(new g(o,a,this.times)),i.emitEvent(new g(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=g,r=this.getBlocks(new t(i));i.emitEvent(new g(s,r,this.times)),Z.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new g(n,r,this.times)),i.emitEvent(new g(o,r,this.times)),this.addBlocks(r),f.end(e)}static fullLayout(t){if(X(t),t.isBranch){const e=[t];q(t,e),Q(e)}else t.__updateWorldBounds();G(t)}createBlock(t){return new j(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_(g.REQUEST,this.layout,this),t.on_(g.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 $=c.get("Renderer");class J{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(g.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new h,$.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),_.clearRecycled()}catch(t){this.rendering=!1,$.error(t)}$.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?$.warn("rendering"):this.times>3?$.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new h,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.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 $.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:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=(new h).copy(s);i.save(),n&&!c.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o),i.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 i=(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,i),this.renderBounds=e||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 h;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(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new h(0,0,e,i).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||$.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(g.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(y.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:tt}=l;class et{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.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 o=this.findList,r=this.getBestMatchLeaf(),a=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:a,leaf:r,throughPath:o.length?this.getThroughPath(o):a}:{path:a,leaf:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],r.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.push(e),e=e.parent;return i.push(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.unshift(s),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,o,r;for(let t=0,e=s.length;t<e;t++){n=s[t],o=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!o||!o.has(r));t++)i.push(r)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||tt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,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 it{constructor(t,i){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,i&&(this.config=e.default(i,this.config)),this.findPath=new et(t,this),this.__listenEvents()}getByPoint(t,e,i){return"node"===p.name&&this.target.emit(g.CHECK_UPDATE),this.findPath.getByPoint(t,e,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 i,s=this.innerIdList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(i=e,this.innerIdList[t]=i,!0))),i)}getById(t,e){let i,s=this.idList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(i=e,this.idList[t]=i,!0))),i)}getByClassName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.className===t&&i.push(e),!1))),i}getByTagName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.__tag===t&&i.push(e),!1))),i}loopFind(t,e){if(e(t))return;const{children:i}=t;for(let s=0,n=i.length;s<n;s++){if(e(t=i[s]))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_(s.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 z(t,e),layouter:(t,e)=>new Z(t,e),renderer:(t,e,i)=>new J(t,e,i),selector:(t,e)=>new it(t,e)}),p.layout=Z.fullLayout;class st extends v{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=p.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&p.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.__createContext();const{width:e,height:i,pixelRatio:s}=this.config,n={width:e||t.width,height:i||t.height,pixelRatio:s};this.resize(n),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),x(this.context.__proto__)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i}updateClientBounds(t){this.viewSelect&&p.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,e){this.resizeListener=e,this.checkSize=this.checkSize.bind(this),p.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:i}=this.clientBounds,{pixelRatio:s}=this,n={width:t,height:i,pixelRatio:s};if(!this.isSameSize(n)){const t={};e.copyAttrs(t,this,b),this.resize(n),void 0!==this.width&&this.resizeListener(new y(n,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,p.miniapp.offWindowResize(this.checkSize)}}const nt={convertTouch(t,e){const i=nt.getTouch(t),s=B.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class ot extends R{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){if(e&&this.canvas.updateClientBounds(),void 0!==t.x)return{x:t.x,y:t.y};{const{clientBounds:e}=this.canvas;return{x:t.clientX-e.x,y:t.clientY-e.y}}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=nt.getTouch(t);this.pointerDown(nt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=nt.getTouch(t);this.pointerMove(nt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=nt.getTouch(t);this.pointerUp(nt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>=2,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(B.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}const{mineType:rt,fileType:at}=E;function ht(t,e){p.origin||(p.origin={createCanvas:(t,i,s)=>e.createOffscreenCanvas({type:"2d",width:t,height:i}),canvasToDataURL:(t,e,i)=>t.toDataURL(rt(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>new Promise(((n,o)=>{let r,a=t.toDataURL(rt(at(i)),s);a=a.substring(a.indexOf("64,")+3),i.includes("/")||(i=`${e.env.USER_DATA_PATH}/`+i,r=!0);const h=e.getFileSystemManager();h.writeFile({filePath:i,data:a,encoding:"base64",success(){r&&p.miniapp.saveToAlbum(i).then((()=>{h.unlink({filePath:i})})),n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((e,i)=>{const s=p.canvas.view.createImage();s.onload=()=>{e(s)},s.onerror=t=>{i(t)},s.src=t})),noRepeat:"repeat-x"},p.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})})),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient)}Object.assign(m,{canvas:(t,e)=>new st(t,e),image:t=>new L(t),hitCanvas:(t,e)=>new st(t,e),interaction:(t,e,i,s)=>new ot(t,e,i,s)}),p.name="miniapp",p.requestRender=function(t){p.canvas.view.requestAnimationFrame(t)},p.devicePixelRatio=wx.getSystemInfoSync().pixelRatio,p.realtimeLayout=!0;const{get:dt,rotateOfOuter:lt,translate:ct,scaleOfOuter:ut,scale:gt,rotate:ft}=S;const{get:_t,translate:pt}=S;function wt(t,e,i,s){let{width:n,height:o}=e;const{opacity:r,mode:a,offset:h,scale:d,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===o;c&&(t.blendMode=c);const g=t.data={mode:a};switch(a){case"strench":u||(n=s.width,o=s.height),(s.x||s.y)&&(g.transform=_t(),pt(g.transform,s.x,s.y));break;case"clip":(h||d||l)&&function(t,e,i,s,n){const o=dt();ct(o,e.x,e.y),i&&ct(o,i.x,i.y),s&&("number"==typeof s?gt(o,s):gt(o,s.x,s.y),t.scaleX=o.a,t.scaleY=o.d),n&&ft(o,n),t.transform=o}(g,s,h,d,l);break;case"repeat":(!u||d||l)&&function(t,e,i,s,n,o){const r=dt();if(o)switch(ft(r,o),o){case 90:ct(r,s,0);break;case 180:ct(r,i,s);break;case 270:ct(r,0,i)}ct(r,e.x,e.y),n&&(ut(r,e,n),t.scaleX=t.scaleY=n),t.transform=r}(g,s,n,o,d,l);break;default:u&&!l||function(t,e,i,s,n,o){const r=dt(),a=o&&180!==o,h=i.width/(a?n:s),d=i.height/(a?s:n),l="fit"===e?Math.min(h,d):Math.max(h,d),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ct(r,c,u),gt(r,l),o&&lt(r,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=l,t.transform=r}(g,a,s,n,o,l)}g.width=n,g.height=o,r&&(g.opacity=r)}function yt(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function mt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new T(t,e))}function vt(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:xt,scale:bt,copy:Bt}=S;function Rt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const o=s+"-"+n;if(e.patternId===o||t.destroyed)return!1;{e.patternId=o,s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e,a=t.isSVG?4096:Math.min(t.width,4096),h=t.isSVG?4096:Math.min(t.height,4096);let d,l,{width:c,height:u,scaleX:g,scaleY:f,opacity:_,transform:w,mode:y}=r;g&&(l=xt(),Bt(l,w),bt(l,1/g,1/f),s*=g,n*=f),s*=i,n*=i,c*=s,u*=n,(c>a||u>h)&&(d=Math.max(c/a,u/h)),d&&(s/=d,n/=d,c/=d,u/=d),g&&(s/=g,n/=f),(w||1!==s||1!==n)&&(l||(l=xt(),w&&Bt(l,w)),bt(l,1/s,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,_),"repeat"===y?"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 Lt(t,e,i,s){const{scaleX:n,scaleY:o}=t.__world;if(i.data&&i.patternId!==n+"-"+o){if(s)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:r}=i.data;t*=n*e.pixelRatio,r*=o*e.pixelRatio,s=t>4096||r>4096}else s=!1;if(s){e.save(),e.clip();const{data:t}=i;return i.blendMode&&(e.blendMode=i.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(i.image.view,0,0,t.width,t.height),e.restore(),!0}return i.style?_.patternTasker.add((()=>vt(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&&Rt(t,i,e.pixelRatio)&&t.forceUpdate("surface")}))),300):Rt(t,i,e.pixelRatio),!1}return!1}function Et(t,e){const i="fill"===e?t._fill:t._stroke;if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,_.recycle(s),s.loading&&(o||(o=t.__input&&t.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null}function St(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function Tt(t,e,i){const{strokeAlign:s}=t.__,n="string"!=typeof i;switch(s){case"center":e.setStroke(n?void 0:i,t.__.strokeWidth,t.__),n?Ct(t,i,e,!0):At(t,e);break;case"inside":kt(t,e,i,"inside",n);break;case"outside":kt(t,e,i,"outside",n)}}function kt(t,e,i,s,n){const{strokeWidth:o,__font:r}=t.__,a=e.getSameCanvas(!0);a.setStroke(n?void 0:i,2*o,t.__),a.font=r,n?Ct(t,i,a,!0):At(t,a),a.blendMode="outside"===s?"destination-out":"destination-in",St(t,a),a.blendMode="normal",e.copyWorldToInner(a,t.__world,t.__layout.renderBounds),a.recycle()}function At(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Ct(t,e,i,s){let n;for(let o=0,r=e.length;o<r;o++)n=e[o],n.image&&Lt(t,i,n,!1)||n.style&&(i.strokeStyle=n.style,n.blendMode?(i.saveBlendMode(n.blendMode),s?At(t,i):i.stroke(),i.restoreBlendMode()):s?At(t,i):i.stroke())}const{getSpread:Mt,getOuterOf:Ot,getByMove:It,getIntersectData:Pt}=l;const Wt={x:.5,y:0},Dt={x:.5,y:1};function zt(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,M.string(s.color,i))}const{set:Ft,getAngle:Vt,getDistance:Nt}=k,{get:Ut,rotateOfOuter:Yt,scaleOfOuter:Ht}=S,jt={x:.5,y:.5},Xt={x:.5,y:1},Gt={},qt={};const{set:Qt,getAngle:Kt,getDistance:Zt}=k,{get:$t,rotateOfOuter:Jt,scaleOfOuter:te}=S,ee={x:.5,y:.5},ie={x:.5,y:1},se={},ne={};let oe;function re(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:M.string(r,a)};case"image":return function(t,e,i,s,n){const o={type:i.type},r=o.image=_.get(i),a=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(yt(t,e,r)&&wt(o,r,i,s),n&&(mt(T.LOAD,a),mt(T.LOADED,a))):r.error?n&&(t.forceUpdate("surface"),a.error=r.error,mt(T.ERROR,a)):(n&&mt(T.LOAD,a),o.loadId=r.load((()=>{t.destroyed||(yt(t,e,r)&&(wt(o,r,i,s),t.forceUpdate("surface")),mt(T.LOADED,a))}),(e=>{t.forceUpdate("surface"),a.error=e,mt(T.ERROR,a)}))),o}(t,i,e,s,!oe||!oe[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:o,opacity:r}=t;i||(i=Wt),s||(s=Dt);const a=p.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);zt(a,t.stops,r);const h={type:n,style:a};return o&&(h.blendMode=o),h}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=jt),s||(s=Xt);const{x:h,y:d,width:l,height:c}=e;let u;Ft(Gt,h+i.x*l,d+i.y*c),Ft(qt,h+s.x*l,d+s.y*c),(l!==c||a)&&(u=Ut(),Ht(u,Gt,l/c*(a||1),1),Yt(u,Gt,Vt(Gt,qt)+90));const g=p.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,Nt(Gt,qt));zt(g,t.stops,o);const f={type:n,style:g,transform:u};return r&&(f.blendMode=r),f}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=ee),s||(s=ie);const{x:h,y:d,width:l,height:c}=e;Qt(se,h+i.x*l,d+i.y*c),Qt(ne,h+s.x*l,d+s.y*c);const u=$t(),g=Kt(se,ne);p.conicGradientRotate90?(te(u,se,l/c*(a||1),1),Jt(u,se,g+90)):(te(u,se,1,l/c*(a||1)),Jt(u,se,g));const f=p.conicGradientSupport?p.canvas.createConicGradient(0,se.x,se.y):p.canvas.createRadialGradient(se.x,se.y,0,se.x,se.y,Zt(se,ne));zt(f,t.stops,o);const _={type:n,style:f,transform:u};return r&&(_.blendMode=r),_}(e,s);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}var ae=Object.freeze({__proto__:null,compute:function(t,e){const i=[];let s,n=t.__.__input[e];n instanceof Array||(n=[n]),oe=Et(t.__,e);for(let o=0,r=n.length;o<r;o++)s=re(t,n[o],e),s&&i.push(s);t.__["_"+e]=i.length?i:void 0},drawTextStroke:At,fill:function(t,e,i){e.fillStyle=i,t.__.__font?St(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:St,fills:function(t,e,i){let s;const{windingRule:n,__font:o}=t.__;for(let r=0,a=i.length;r<a;r++)s=i[r],s.image&&Lt(t,e,s,!o)||s.style&&(e.fillStyle=s.style,s.transform?(e.save(),e.transform(s.transform),s.blendMode&&(e.blendMode=s.blendMode),o?St(t,e):n?e.fill(n):e.fill(),e.restore()):s.blendMode?(e.saveBlendMode(s.blendMode),o?St(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):o?St(t,e):n?e.fill(n):e.fill())},recycleImage:Et,shape:function(t,e,i){const s=e.getSameCanvas();let n,o,r,a;const{__world:h}=t;let{scaleX:d,scaleY:l}=h;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(h,i.matrix))i.matrix?(d*=i.matrix.a,l*=i.matrix.d,n=r=Ot(h,i.matrix)):n=r=h,a=s;else{const{renderShapeSpread:s}=t.__layout,c=Pt(s?Mt(e.bounds,s*d,s*l):e.bounds,h,i.matrix);o=e.bounds.getFitMatrix(c),o.a<1&&(a=e.getSameCanvas(),t.__renderShape(a,i),d*=o.a,l*=o.d),r=Ot(h,o),n=It(r,-o.e,-o.f),i.matrix&&o.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:o})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:n,worldCanvas:a,shapeBounds:r,scaleX:d,scaleY:l}},stroke:function(t,e,i){const s=t.__,{strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)Tt(t,e,i);else switch(o){case"center":e.setStroke(i,n,s),e.stroke();break;case"inside":e.save(),e.setStroke(i,2*n,s),s.windingRule?e.clip(s.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const o=e.getSameCanvas(!0);o.setStroke(i,2*n,t.__),t.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}},strokeText:Tt,strokes:function(t,e,i){const s=t.__,{strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)Tt(t,e,i);else switch(o){case"center":e.setStroke(void 0,n,s),Ct(t,i,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,s),s.windingRule?e.clip(s.windingRule):e.clip(),Ct(t,i,e),e.restore();break;case"outside":const{renderBounds:o}=t.__layout,r=e.getSameCanvas(!0);t.__drawRenderPath(r),r.setStroke(void 0,2*n,t.__),Ct(t,i,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.copyWorldToInner(r,t.__world,o),r.recycle()}}});const{copy:he,toOffsetOutBounds:de}=l,le={},ce={};function ue(t,e,i,s){const{bounds:n,shapeBounds:o}=s;if(p.fullImageShadow){if(he(le,t.bounds),le.x+=e.x-o.x,le.y+=e.y-o.y,i){const{matrix:t}=s;le.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),le.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),le.width*=i,le.height*=i}t.copyWorld(s.canvas,t.bounds,le)}else i&&(he(le,e),le.x-=e.width/2*(i-1),le.y-=e.height/2*(i-1),le.width*=i,le.height*=i),t.copyWorld(s.canvas,o,i?le:e)}const{toOffsetOutBounds:ge}=l,fe={};var _e=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{innerShadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:g}=i,f=e.getSameCanvas(),_=h.length-1;ge(l,fe),h.forEach(((s,h)=>{f.save(),f.setWorldShadow(fe.offsetX+s.x*u,fe.offsetY+s.y*g,s.blur*u),o=s.spread?1-2*s.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ue(f,fe,o,i),f.restore(),d?(f.copyWorld(f,l,r,"copy"),f.copyWorld(d,r,r,"source-out"),n=r):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,s.color,"source-in"),t.__hasMirror?e.copyWorldByReset(f,n,r,s.blendMode):e.copyWorldToInner(f,n,a.renderBounds,s.blendMode),_&&h<_&&f.clear()})),f.recycle()},shadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{shadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:g}=i,f=e.getSameCanvas(),_=h.length-1;de(l,ce),h.forEach(((s,h)=>{f.setWorldShadow(ce.offsetX+s.x*u,ce.offsetY+s.y*g,s.blur*u,s.color),o=s.spread?1+2*s.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ue(f,ce,o,i),n=l,s.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,r,"copy"),n=r),d?f.copyWorld(d,r,r,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__hasMirror?e.copyWorldByReset(f,n,r,s.blendMode):e.copyWorldToInner(f,n,a.renderBounds,s.blendMode),_&&h<_&&f.clear()})),f.recycle()}});const pe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",we=pe+"_#~&*+\\=|≮≯≈≠=…",ye=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ve=me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),xe=me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),be=me(pe),Be=me(we),Re=me("- —/~|┆·");var Le;!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"}(Le||(Le={}));const{Letter:Ee,Single:Se,Before:Te,After:ke,Symbol:Ae,Break:Ce}=Le;function Me(t){return ve[t]?Ee:Re[t]?Ce:xe[t]?Te:be[t]?ke:Be[t]?Ae:ye.test(t)?Se:Ee}const Oe={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ie(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Pe}=Oe,{Letter:We,Single:De,Before:ze,After:Fe,Symbol:Ve,Break:Ne}=Le;let Ue,Ye,He,je,Xe,Ge,qe,Qe,Ke,Ze,$e,Je,ti,ei,ii=[];function si(t,e){Ue.data.push({char:t,width:e}),He+=e}function ni(){je+=He,Ue.width=He,Ye.words.push(Ue),Ue={data:[]},He=0}function oi(){Je&&(ti.paraNumber++,Ye.paraStart=!0,Je=!1),Ye.width=je,ei.width&&Pe(Ye),ii.push(Ye),Ye={words:[]},je=0}const ri={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,{width:n,height:o,padding:r}=e;const{textDecoration:a,textOverflow:h,__font:d}=e;if(n||(n=0),r){const[t,e,a,h]=A.fourNumber(r);n&&(i=h,n-=e+h),o&&(s=t,o-=t+a)}const l={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:p.canvas.font=d};return function(t,e,i){ti=t,ii=t.rows,ei=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=p,{width:a,height:h}=ei;if(a||h||s||"none"!==o){Je=!0,Ke=null,He=je=0,Ue={data:[]},Ye={words:[]};for(let t=0,i=e.length;t<i;t++)Ge=e[t],"\n"===Ge?(He&&ni(),Ye.paraEnd=!0,oi(),Je=!0):(Qe=Me(Ge),Qe===We&&"none"!==o&&(Ge=Ie(Ge,o,!He)),qe=r.measureText(Ge).width,s&&(qe+=s),Ze=Qe===De&&(Ke===De||Ke===We)||Ke===De&&Qe!==Fe,$e=!(Qe!==ze&&Qe!==De||Ke!==Ve&&Ke!==Fe),Xe=Je&&n?a-n:a,a&&je+He+qe>Xe&&($e||($e=Qe===We&&Ke==Fe),Ze||$e||Qe===Ne||Qe===ze||Qe===De||He+qe>Xe?(He&&ni(),oi()):oi())," "===Ge&&!0!==Je&&je+He===0||(Qe===Ne?(" "===Ge&&He&&ni(),si(Ge,qe),ni()):Ze||$e?(He&&ni(),si(Ge,qe)):si(Ge,qe)),Ke=Qe);He&&ni(),je&&oi(),ii.length>0&&(ii[ii.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{ti.paraNumber++,ii.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,textAlign:r,verticalAlign:a,paraSpacing:h,textOverflow:d}=e;let l,{x:c,y:u,width:g,height:f}=s,_=n*i.length+(h?h*(t.paraNumber-1):0),p=o;if("show"!==d&&_>f)_=Math.max(f,n),t.overflow=i.length;else switch(a){case"middle":u+=(f-_)/2;break;case"bottom":u+=f-_}p+=u;for(let o=0,a=i.length;o<a;o++){switch(l=i[o],l.x=c,r){case"center":l.x+=(g-l.width)/2;break;case"right":l.x+=g-l.width}if(l.paraStart&&h&&o>0&&(p+=h),l.y=p,p+=n,t.overflow>o&&p>_&&(l.isOverflow=!0,t.overflow=o+1),l.width<0){const t=l.words[0].data[0].width,i=l.x+l.width;i<s.x&&(s.x=i-t),-l.width>s.width&&(s.width=-l.width+e.fontSize+t)}else l.x<s.x&&(s.x=l.x),l.width>s.width&&(s.width=l.width)}s.y=u,s.height=_}(l,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=a||t.isOverflow?0:d>.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,h=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u)," "!==u.char&&t.data.push(u)):h=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:i,overflow:s}=t;if(i.splice(s),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,o=i[s-1];let r,a,h=o.data.length-1;const{x:d,width:l}=t.bounds,c=d+l-n;for(let t=h;t>-1&&(r=o.data[t],a=r.x+r.width,!(t===h&&a<c));t--){if(a<c&&" "!==r.char){o.data.splice(t+1),o.width-=r.width;break}o.width-=r.width}o.width+=n,o.data.push({char:e,x:a})}}(l,h),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,e),l}},ai={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},hi={export(t,e,i){return function(t){di||(di=new C);return new Promise((e=>{di.add((()=>vt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:o}=t;o?o.waitViewCompleted((()=>vt(this,void 0,void 0,(function*(){let t,r,a,{canvas:h}=o,{unreal:d}=h;switch(d&&(h=h.getSameCanvas(),h.backgroundColor=o.config.fill,o.__render(h,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}a=e.includes(".")?yield h.saveAs(e,t):r?yield h.toBlob(e,t):yield h.toDataURL(e,t),s({data:a}),n(),d&&h.recycle()})))):(s({data:!1}),n())}))))}};let di;Object.assign(O,ae),Object.assign(I,_e),Object.assign(P,ri),Object.assign(M,ai),Object.assign(W,hi);try{ht(0,wx)}catch(t){}st.prototype.__createContext=function(){if(this.viewSelect){const t=D.origin.createCanvas(1,1),e=this.view.getContext("2d");try{e.drawImage(t,0,0)}catch(i){this.testView=this.view,this.testContext=e,this.view=t}}this.context=this.view.getContext("2d"),this.__bindContext()},st.prototype.updateRender=function(){if(this.testView){let t=this.context.createPattern(this.view,D.origin.noRepeat);this.testContext.clearRect(0,0,this.view.width,this.view.height),this.testContext.fillStyle=t,this.testContext.fillRect(0,0,this.view.width,this.view.height),this.testContext.fillStyle=t=null}},st.prototype.updateViewSize=function(){const{width:t,height:e,pixelRatio:i,view:s,testView:n}=this;s.width=t*i,s.height=e*i,n&&(n.width=s.width,n.height=s.height)};export{ot as Interaction,Z as Layouter,st as LeaferCanvas,J as Renderer,it as Selector,z as Watcher,ht as useCanvas};
1
+ import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as o,LeafHelper as r,BranchHelper as a,Bounds as h,LeafBoundsHelper as d,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as g,Run as f,ImageManager as _,Platform as p,AnimateEvent as w,ResizeEvent as y,Creator as m,LeaferCanvasBase as v,canvasPatch as x,canvasSizeAttrs as b,InteractionHelper as B,InteractionBase as R,LeaferImage as L,FileHelper as E,MatrixHelper as S,ImageEvent as T,PointHelper as k,MathHelper as A,TaskProcessor as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as M,Paint as O,Effect as I,TextConvert as W,Export as P,Platform as D}from"@leafer-ui/core";export*from"@leafer-ui/core";class z{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(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,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}update(){this.changed=!0,this.running&&this.target.emit(i.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===s.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,i=e.length;t<i;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_(o.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.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:F,updateAllWorldOpacity:V}=r,{pushAllChildBranch:N,pushAllParent:U}=a;const{worldBounds:Y}=d,{setByListWithHandle:H}=l;class j{constructor(e){this.updatedBounds=new h,this.beforeBounds=new h,this.afterBounds=new h,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){H(this.beforeBounds,this.updatedList.list,Y)}setAfter(){H(this.afterBounds,this.updatedList.list,Y),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:X,updateAllChange:G}=r,{pushAllBranchStack:q,updateWorldBoundsByBranchStack:Q}=a,K=c.get("Layouter");class Z{constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,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}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(g.START),this.layoutOnce(),t.emitEvent(new g(g.END,this.layoutedBlocks,this.times))}catch(t){K.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?K.warn("layouting"):this.times>3?K.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:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=g,a=this.getBlocks(s);a.forEach((t=>{t.setBefore()})),i.emitEvent(new g(n,a,this.times)),s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.useZoomProxy&&(i.matrixChanged?(F(t),e.push(t),t.isBranch&&N(t,e),U(t,e)):i.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),U(t,e)))}))}(s,this.__levelList),function(t){let e,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber)for(let t=0,e=i.children.length;t<e;t++)i.children[t].isBranch||i.children[t].__updateWorldBounds();i.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&V(t),t.__updateChange()}))}(s),a.forEach((t=>t.setAfter())),i.emitEvent(new g(o,a,this.times)),i.emitEvent(new g(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=g,r=this.getBlocks(new t(i));i.emitEvent(new g(s,r,this.times)),Z.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new g(n,r,this.times)),i.emitEvent(new g(o,r,this.times)),this.addBlocks(r),f.end(e)}static fullLayout(t){if(X(t),t.isBranch){const e=[t];q(t,e),Q(e)}else t.__updateWorldBounds();G(t)}createBlock(t){return new j(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_(g.REQUEST,this.layout,this),t.on_(g.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 $=c.get("Renderer");class J{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(g.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new h,$.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),_.clearRecycled()}catch(t){this.rendering=!1,$.error(t)}$.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?$.warn("rendering"):this.times>3?$.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new h,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.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 $.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:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=(new h).copy(s);i.save(),n&&!c.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o),i.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 i=(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,i),this.renderBounds=e||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 h;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(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new h(0,0,e,i).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||$.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(g.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(y.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:tt}=l;class et{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.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 o=this.findList,r=this.getBestMatchLeaf(),a=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:a,leaf:r,throughPath:o.length?this.getThroughPath(o):a}:{path:a,leaf:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],r.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.push(e),e=e.parent;return i.push(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.unshift(s),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,o,r;for(let t=0,e=s.length;t<e;t++){n=s[t],o=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!o||!o.has(r));t++)i.push(r)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||tt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,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 it{constructor(t,i){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,i&&(this.config=e.default(i,this.config)),this.findPath=new et(t,this),this.__listenEvents()}getByPoint(t,e,i){return"node"===p.name&&this.target.emit(g.CHECK_UPDATE),this.findPath.getByPoint(t,e,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 i,s=this.innerIdList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(i=e,this.innerIdList[t]=i,!0))),i)}getById(t,e){let i,s=this.idList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(i=e,this.idList[t]=i,!0))),i)}getByClassName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.className===t&&i.push(e),!1))),i}getByTagName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.__tag===t&&i.push(e),!1))),i}loopFind(t,e){if(e(t))return;const{children:i}=t;for(let s=0,n=i.length;s<n;s++){if(e(t=i[s]))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_(s.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 z(t,e),layouter:(t,e)=>new Z(t,e),renderer:(t,e,i)=>new J(t,e,i),selector:(t,e)=>new it(t,e)}),p.layout=Z.fullLayout;class st extends v{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=p.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&p.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.__createContext();const{width:e,height:i,pixelRatio:s}=this.config,n={width:e||t.width,height:i||t.height,pixelRatio:s};this.resize(n),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),x(this.context.__proto__)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i}updateClientBounds(t){this.viewSelect&&p.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,e){this.resizeListener=e,this.checkSize=this.checkSize.bind(this),p.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:i}=this.clientBounds,{pixelRatio:s}=this,n={width:t,height:i,pixelRatio:s};if(!this.isSameSize(n)){const t={};e.copyAttrs(t,this,b),this.resize(n),void 0!==this.width&&this.resizeListener(new y(n,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,p.miniapp.offWindowResize(this.checkSize)}}const nt={convertTouch(t,e){const i=nt.getTouch(t),s=B.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class ot extends R{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){if(e&&this.canvas.updateClientBounds(),void 0!==t.x)return{x:t.x,y:t.y};{const{clientBounds:e}=this.canvas;return{x:t.clientX-e.x,y:t.clientY-e.y}}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=nt.getTouch(t);this.pointerDown(nt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=nt.getTouch(t);this.pointerMove(nt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=nt.getTouch(t);this.pointerUp(nt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>=2,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(B.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}const{mineType:rt,fileType:at}=E;function ht(t,e){p.origin||(p.origin={createCanvas:(t,i,s)=>e.createOffscreenCanvas({type:"2d",width:t,height:i}),canvasToDataURL:(t,e,i)=>t.toDataURL(rt(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>new Promise(((n,o)=>{let r,a=t.toDataURL(rt(at(i)),s);a=a.substring(a.indexOf("64,")+3),i.includes("/")||(i=`${e.env.USER_DATA_PATH}/`+i,r=!0);const h=e.getFileSystemManager();h.writeFile({filePath:i,data:a,encoding:"base64",success(){r&&p.miniapp.saveToAlbum(i).then((()=>{h.unlink({filePath:i})})),n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((e,i)=>{const s=p.canvas.view.createImage();s.onload=()=>{e(s)},s.onerror=t=>{i(t)},s.src=t})),noRepeat:"repeat-x"},p.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})})),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient)}Object.assign(m,{canvas:(t,e)=>new st(t,e),image:t=>new L(t),hitCanvas:(t,e)=>new st(t,e),interaction:(t,e,i,s)=>new ot(t,e,i,s)}),p.name="miniapp",p.requestRender=function(t){p.canvas.view.requestAnimationFrame(t)},p.devicePixelRatio=wx.getSystemInfoSync().pixelRatio,p.realtimeLayout=!0;const{get:dt,rotateOfOuter:lt,translate:ct,scaleOfOuter:ut,scale:gt,rotate:ft}=S;const{get:_t,translate:pt}=S;function wt(t,e,i,s){let{width:n,height:o}=e;const{opacity:r,mode:a,offset:h,scale:d,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===o;c&&(t.blendMode=c);const g=t.data={mode:a};switch(a){case"strench":u||(n=s.width,o=s.height),(s.x||s.y)&&(g.transform=_t(),pt(g.transform,s.x,s.y));break;case"clip":(h||d||l)&&function(t,e,i,s,n){const o=dt();ct(o,e.x,e.y),i&&ct(o,i.x,i.y),s&&("number"==typeof s?gt(o,s):gt(o,s.x,s.y),t.scaleX=o.a,t.scaleY=o.d),n&&ft(o,n),t.transform=o}(g,s,h,d,l);break;case"repeat":(!u||d||l)&&function(t,e,i,s,n,o){const r=dt();if(o)switch(ft(r,o),o){case 90:ct(r,s,0);break;case 180:ct(r,i,s);break;case 270:ct(r,0,i)}ct(r,e.x,e.y),n&&(ut(r,e,n),t.scaleX=t.scaleY=n),t.transform=r}(g,s,n,o,d,l);break;default:u&&!l||function(t,e,i,s,n,o){const r=dt(),a=o&&180!==o,h=i.width/(a?n:s),d=i.height/(a?s:n),l="fit"===e?Math.min(h,d):Math.max(h,d),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ct(r,c,u),gt(r,l),o&&lt(r,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=l,t.transform=r}(g,a,s,n,o,l)}g.width=n,g.height=o,r&&(g.opacity=r)}function yt(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function mt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new T(t,e))}function vt(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:xt,scale:bt,copy:Bt}=S;function Rt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const o=s+"-"+n;if(e.patternId===o||t.destroyed)return!1;{e.patternId=o,s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e,a=t.isSVG?4096:Math.min(t.width,4096),h=t.isSVG?4096:Math.min(t.height,4096);let d,l,{width:c,height:u,scaleX:g,scaleY:f,opacity:_,transform:w,mode:y}=r;g&&(l=xt(),Bt(l,w),bt(l,1/g,1/f),s*=g,n*=f),s*=i,n*=i,c*=s,u*=n,(c>a||u>h)&&(d=Math.max(c/a,u/h)),d&&(s/=d,n/=d,c/=d,u/=d),g&&(s/=g,n/=f),(w||1!==s||1!==n)&&(l||(l=xt(),w&&Bt(l,w)),bt(l,1/s,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,_),"repeat"===y?"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 Lt(t,e,i,s){const{scaleX:n,scaleY:o}=t.__world;if(i.data&&i.patternId!==n+"-"+o){if(s)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:r}=i.data;t*=n*e.pixelRatio,r*=o*e.pixelRatio,s=t>4096||r>4096}else s=!1;if(s){e.save(),e.clip();const{data:t}=i;return i.blendMode&&(e.blendMode=i.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(i.image.view,0,0,t.width,t.height),e.restore(),!0}return i.style?_.patternTasker.add((()=>vt(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&&Rt(t,i,e.pixelRatio)&&t.forceUpdate("surface")}))),300):Rt(t,i,e.pixelRatio),!1}return!1}function Et(t,e){const i="fill"===t?e._fill:e._stroke;if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,_.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null}function St(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function Tt(t,e,i,s){const{strokeAlign:n}=e.__,o="string"!=typeof t;switch(n){case"center":i.setStroke(o?void 0:t,e.__.strokeWidth,e.__),o?Ct(t,!0,e,i):At(e,i);break;case"inside":kt("inside",t,o,e,i,s);break;case"outside":kt("outside",t,o,e,i,s)}}function kt(t,e,i,s,n,o){const{strokeWidth:r,__font:a}=s.__,h=n.getSameCanvas(!0);h.setStroke(i?void 0:e,2*r,s.__),h.font=a,i?Ct(e,!0,s,h):At(s,h),h.blendMode="outside"===t?"destination-out":"destination-in",St(s,h),h.blendMode="normal",s.__hasMirror||o.matrix?n.copyWorldByReset(h):n.copyWorldToInner(h,s.__world,s.__layout.renderBounds),h.recycle()}function At(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Ct(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&Lt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?At(i,s):s.stroke(),s.restoreBlendMode()):e?At(i,s):s.stroke())}const{getSpread:Mt,getOuterOf:Ot,getByMove:It,getIntersectData:Wt}=l;const Pt={x:.5,y:0},Dt={x:.5,y:1};function zt(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,M.string(s.color,i))}const{set:Ft,getAngle:Vt,getDistance:Nt}=k,{get:Ut,rotateOfOuter:Yt,scaleOfOuter:Ht}=S,jt={x:.5,y:.5},Xt={x:.5,y:1},Gt={},qt={};const{set:Qt,getAngle:Kt,getDistance:Zt}=k,{get:$t,rotateOfOuter:Jt,scaleOfOuter:te}=S,ee={x:.5,y:.5},ie={x:.5,y:1},se={},ne={};let oe;function re(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:M.string(r,a)};case"image":return function(t,e,i,s,n){const o={type:i.type},r=o.image=_.get(i),a=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(yt(t,e,r)&&wt(o,r,i,s),n&&(mt(T.LOAD,a),mt(T.LOADED,a))):r.error?n&&(t.forceUpdate("surface"),a.error=r.error,mt(T.ERROR,a)):(n&&mt(T.LOAD,a),o.loadId=r.load((()=>{t.destroyed||(yt(t,e,r)&&(wt(o,r,i,s),t.forceUpdate("surface")),mt(T.LOADED,a))}),(e=>{t.forceUpdate("surface"),a.error=e,mt(T.ERROR,a)}))),o}(i,t,e,s,!oe||!oe[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:o,opacity:r}=t;i||(i=Pt),s||(s=Dt);const a=p.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);zt(a,t.stops,r);const h={type:n,style:a};return o&&(h.blendMode=o),h}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=jt),s||(s=Xt);const{x:h,y:d,width:l,height:c}=e;let u;Ft(Gt,h+i.x*l,d+i.y*c),Ft(qt,h+s.x*l,d+s.y*c),(l!==c||a)&&(u=Ut(),Ht(u,Gt,l/c*(a||1),1),Yt(u,Gt,Vt(Gt,qt)+90));const g=p.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,Nt(Gt,qt));zt(g,t.stops,o);const f={type:n,style:g,transform:u};return r&&(f.blendMode=r),f}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=ee),s||(s=ie);const{x:h,y:d,width:l,height:c}=e;Qt(se,h+i.x*l,d+i.y*c),Qt(ne,h+s.x*l,d+s.y*c);const u=$t(),g=Kt(se,ne);p.conicGradientRotate90?(te(u,se,l/c*(a||1),1),Jt(u,se,g+90)):(te(u,se,1,l/c*(a||1)),Jt(u,se,g));const f=p.conicGradientSupport?p.canvas.createConicGradient(0,se.x,se.y):p.canvas.createRadialGradient(se.x,se.y,0,se.x,se.y,Zt(se,ne));zt(f,t.stops,o);const _={type:n,style:f,transform:u};return r&&(_.blendMode=r),_}(e,s);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}var ae=Object.freeze({__proto__:null,compute:function(t,e){const i=[];let s,n=e.__.__input[t];n instanceof Array||(n=[n]),oe=Et(t,e.__);for(let o=0,r=n.length;o<r;o++)s=re(t,n[o],e),s&&i.push(s);e.__["_"+t]=i.length?i:void 0},drawTextStroke:At,fill:function(t,e,i){i.fillStyle=t,e.__.__font?St(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:St,fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&Lt(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?St(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?St(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?St(e,i):n?i.fill(n):i.fill())},recycleImage:Et,shape:function(t,e,i){const s=e.getSameCanvas();let n,o,r,a;const{__world:h}=t;let{scaleX:d,scaleY:l}=h;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(h,i.matrix))i.matrix?(d*=i.matrix.a,l*=i.matrix.d,n=r=Ot(h,i.matrix)):n=r=h,a=s;else{const{renderShapeSpread:s}=t.__layout,c=Wt(s?Mt(e.bounds,s*d,s*l):e.bounds,h,i.matrix);o=e.bounds.getFitMatrix(c),o.a<1&&(a=e.getSameCanvas(),t.__renderShape(a,i),d*=o.a,l*=o.d),r=Ot(h,o),n=It(r,-o.e,-o.f),i.matrix&&o.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:o})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:n,worldCanvas:a,shapeBounds:r,scaleX:d,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)Tt(t,e,i,s);else switch(r){case"center":i.setStroke(t,o,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const r=i.getSameCanvas(!0);r.setStroke(t,2*o,e.__),e.__drawRenderPath(r),r.stroke(),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(e.__layout.renderBounds),e.__hasMirror||s.matrix?i.copyWorldByReset(r):i.copyWorldToInner(r,e.__world,e.__layout.renderBounds),r.recycle()}},strokeText:Tt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)Tt(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,o,n),Ct(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),Ct(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:r}=e.__layout,a=i.getSameCanvas(!0);e.__drawRenderPath(a),a.setStroke(void 0,2*o,e.__),Ct(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(r),e.__hasMirror||s.matrix?i.copyWorldByReset(a):i.copyWorldToInner(a,e.__world,r),a.recycle()}}});const{copy:he,toOffsetOutBounds:de}=l,le={},ce={};function ue(t,e,i,s){const{bounds:n,shapeBounds:o}=s;if(p.fullImageShadow){if(he(le,t.bounds),le.x+=e.x-o.x,le.y+=e.y-o.y,i){const{matrix:t}=s;le.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),le.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),le.width*=i,le.height*=i}t.copyWorld(s.canvas,t.bounds,le)}else i&&(he(le,e),le.x-=e.width/2*(i-1),le.y-=e.height/2*(i-1),le.width*=i,le.height*=i),t.copyWorld(s.canvas,o,i?le:e)}const{toOffsetOutBounds:ge}=l,fe={};var _e=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{innerShadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:g}=i,f=e.getSameCanvas(),_=h.length-1;ge(l,fe),h.forEach(((h,p)=>{f.save(),f.setWorldShadow(fe.offsetX+h.x*u,fe.offsetY+h.y*g,h.blur*u),o=h.spread?1-2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ue(f,fe,o,i),f.restore(),d?(f.copyWorld(f,l,r,"copy"),f.copyWorld(d,r,r,"source-out"),n=r):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,h.color,"source-in"),t.__hasMirror||s.matrix?e.copyWorldByReset(f,n,r,h.blendMode):e.copyWorldToInner(f,n,a.renderBounds,h.blendMode),_&&p<_&&f.clear()})),f.recycle()},shadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{shadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:g}=i,f=e.getSameCanvas(),_=h.length-1;de(l,ce),h.forEach(((h,p)=>{f.setWorldShadow(ce.offsetX+h.x*u,ce.offsetY+h.y*g,h.blur*u,h.color),o=h.spread?1+2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ue(f,ce,o,i),n=l,h.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,r,"copy"),n=r),d?f.copyWorld(d,r,r,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__hasMirror||s.matrix?e.copyWorldByReset(f,n,r,h.blendMode):e.copyWorldToInner(f,n,a.renderBounds,h.blendMode),_&&p<_&&f.clear()})),f.recycle()}});const pe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",we=pe+"_#~&*+\\=|≮≯≈≠=…",ye=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ve=me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),xe=me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),be=me(pe),Be=me(we),Re=me("- —/~|┆·");var Le;!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"}(Le||(Le={}));const{Letter:Ee,Single:Se,Before:Te,After:ke,Symbol:Ae,Break:Ce}=Le;function Me(t){return ve[t]?Ee:Re[t]?Ce:xe[t]?Te:be[t]?ke:Be[t]?Ae:ye.test(t)?Se:Ee}const Oe={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ie(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:We}=Oe,{Letter:Pe,Single:De,Before:ze,After:Fe,Symbol:Ve,Break:Ne}=Le;let Ue,Ye,He,je,Xe,Ge,qe,Qe,Ke,Ze,$e,Je,ti,ei,ii,si,ni=[];function oi(t,e){Ke&&!Qe&&(Qe=Ke),Ue.data.push({char:t,width:e}),He+=e}function ri(){je+=He,Ue.width=He,Ye.words.push(Ue),Ue={data:[]},He=0}function ai(){ei&&(ii.paraNumber++,Ye.paraStart=!0,ei=!1),Ke&&(Ye.startCharSize=Qe,Ye.endCharSize=Ke,Qe=0),Ye.width=je,si.width&&We(Ye),ni.push(Ye),Ye={words:[]},je=0}const hi={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,o=e.__getInput("height")||0;const{textDecoration:r,textOverflow:a,__font:h,padding:d}=e;if(d){const[t,e,r,a]=A.fourNumber(d);n&&(i=a,n-=e+a),o&&(s=t,o-=t+r)}const l={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:p.canvas.font=h};return function(t,e,i){ii=t,ni=t.rows,si=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=p,{width:a,height:h}=si;if(a||h||s||"none"!==o){ei=!0,$e=null,Qe=qe=Ke=He=je=0,Ue={data:[]},Ye={words:[]};for(let t=0,i=e.length;t<i;t++)Ge=e[t],"\n"===Ge?(He&&ri(),Ye.paraEnd=!0,ai(),ei=!0):(Ze=Me(Ge),Ze===Pe&&"none"!==o&&(Ge=Ie(Ge,o,!He)),qe=r.measureText(Ge).width,s&&(s<0&&(Ke=qe),qe+=s),Je=Ze===De&&($e===De||$e===Pe)||$e===De&&Ze!==Fe,ti=!(Ze!==ze&&Ze!==De||$e!==Ve&&$e!==Fe),Xe=ei&&n?a-n:a,a&&je+He+qe>Xe&&(ti||(ti=Ze===Pe&&$e==Fe),Je||ti||Ze===Ne||Ze===ze||Ze===De||He+qe>Xe?(He&&ri(),ai()):ai())," "===Ge&&!0!==ei&&je+He===0||(Ze===Ne?(" "===Ge&&He&&ri(),oi(Ge,qe),ri()):Je||ti?(He&&ri(),oi(Ge,qe)):oi(Ge,qe)),$e=Ze);He&&ri(),je&&ai(),ni.length>0&&(ni[ni.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{ii.paraNumber++,ni.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,textAlign:a,verticalAlign:h,paraSpacing:d,textOverflow:l}=e;let c,u,g,{x:f,y:_,width:p,height:w}=s,y=n*i.length+(d?d*(t.paraNumber-1):0),m=o;if("show"!==l&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let o=0,h=i.length;o<h;o++){switch(c=i[o],c.x=f,a){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&d&&o>0&&(m+=d),c.y=m,m+=n,t.overflow>o&&m>y&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,g=c.width,r<0&&(c.width<0?(g=-c.width+e.fontSize+r,u-=g,g+=e.fontSize):g-=r),u<s.x&&(s.x=u),g>s.width&&(s.width=g)}s.y=_,s.height=y}(l,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=a||t.isOverflow?0:d>.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,h=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u)," "!==u.char&&t.data.push(u)):h=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:i,overflow:s}=t;if(i.splice(s),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,o=i[s-1];let r,a,h=o.data.length-1;const{x:d,width:l}=t.bounds,c=d+l-n;for(let t=h;t>-1&&(r=o.data[t],a=r.x+r.width,!(t===h&&a<c));t--){if(a<c&&" "!==r.char){o.data.splice(t+1),o.width-=r.width;break}o.width-=r.width}o.width+=n,o.data.push({char:e,x:a})}}(l,a),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,e),l}},di={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},li={export(t,e,i){return function(t){ci||(ci=new C);return new Promise((e=>{ci.add((()=>vt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:o}=t;o?o.waitViewCompleted((()=>vt(this,void 0,void 0,(function*(){let t,r,a,{canvas:h}=o,{unreal:d}=h;switch(d&&(h=h.getSameCanvas(),h.backgroundColor=o.config.fill,o.__render(h,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}a=e.includes(".")?yield h.saveAs(e,t):r?yield h.toBlob(e,t):yield h.toDataURL(e,t),s({data:a}),n(),d&&h.recycle()})))):(s({data:!1}),n())}))))}};let ci;Object.assign(O,ae),Object.assign(I,_e),Object.assign(W,hi),Object.assign(M,di),Object.assign(P,li);try{ht(0,wx)}catch(t){}st.prototype.__createContext=function(){if(this.viewSelect){const t=D.origin.createCanvas(1,1),e=this.view.getContext("2d");this.testView=this.view,this.testContext=e,this.view=t}this.context=this.view.getContext("2d"),this.__bindContext()},st.prototype.updateRender=function(){if(this.testView){let t=this.context.createPattern(this.view,D.origin.noRepeat);this.testContext.clearRect(0,0,this.view.width,this.view.height),this.testContext.fillStyle=t,this.testContext.fillRect(0,0,this.view.width,this.view.height),this.testContext.fillStyle=t=null}},st.prototype.updateViewSize=function(){const{width:t,height:e,pixelRatio:i,view:s,testView:n}=this;s.width=t*i,s.height=e*i,n&&(n.width=s.width,n.height=s.height)};export{ot as Interaction,Z as Layouter,st as LeaferCanvas,J as Renderer,it as Selector,z as Watcher,ht as useCanvas};