@leafer-ui/miniapp 1.0.0-rc.22 → 1.0.0-rc.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, BoundsHelper, Answer, MatrixHelper, AroundHelper, ImageEvent, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
1
+ import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, BoundsHelper, Answer, MatrixHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { InteractionHelper, InteractionBase, HitCanvasManager, Platform as Platform$1 } from '@leafer-ui/core';
@@ -665,7 +665,7 @@ class Renderer {
665
665
  canvas.clear();
666
666
  }
667
667
  else {
668
- bounds.spread(1 + 1 / this.canvas.pixelRatio).ceil();
668
+ bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
669
669
  canvas.clearWorld(bounds, true);
670
670
  canvas.clipWorld(bounds, true);
671
671
  }
@@ -737,8 +737,11 @@ class Renderer {
737
737
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
738
738
  this.addBlock(this.canvas.bounds);
739
739
  this.target.forceUpdate('surface');
740
+ return;
740
741
  }
741
742
  }
743
+ this.addBlock(new Bounds(0, 0, 1, 1));
744
+ this.changed = true;
742
745
  }
743
746
  __onLayoutEnd(event) {
744
747
  if (event.data)
@@ -911,6 +914,7 @@ class Picker {
911
914
  }
912
915
 
913
916
  const { Yes, NoAndSkip, YesAndSkip } = Answer;
917
+ const idCondition = {}, classNameCondition = {}, tagCondition = {};
914
918
  class Selector {
915
919
  constructor(target, userConfig) {
916
920
  this.config = {};
@@ -920,7 +924,8 @@ class Selector {
920
924
  id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
921
925
  innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
922
926
  className: (leaf, name) => leaf.className === name ? 1 : 0,
923
- tag: (leaf, name) => leaf.__tag === name ? 1 : 0
927
+ tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
928
+ tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
924
929
  };
925
930
  this.target = target;
926
931
  if (userConfig)
@@ -936,12 +941,25 @@ class Selector {
936
941
  case 'string':
937
942
  switch (condition[0]) {
938
943
  case '#':
939
- const leaf = this.getById(condition.substring(1), branch);
940
- return one ? leaf : (leaf ? [leaf] : []);
944
+ idCondition.id = condition.substring(1), condition = idCondition;
945
+ break;
941
946
  case '.':
942
- return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
947
+ classNameCondition.className = condition.substring(1), condition = classNameCondition;
948
+ break;
943
949
  default:
944
- return this.getByMethod(this.methods.tag, branch, one, condition);
950
+ tagCondition.tag = condition, condition = tagCondition;
951
+ }
952
+ case 'object':
953
+ if (condition.id !== undefined) {
954
+ const leaf = this.getById(condition.id, branch);
955
+ return one ? leaf : (leaf ? [leaf] : []);
956
+ }
957
+ else if (condition.tag) {
958
+ const { tag } = condition, isArray = tag instanceof Array;
959
+ return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
960
+ }
961
+ else {
962
+ return this.getByMethod(this.methods.className, branch, one, condition.className);
945
963
  }
946
964
  case 'function':
947
965
  return this.getByMethod(condition, branch, one, options);
@@ -1074,15 +1092,12 @@ class Interaction extends InteractionBase {
1074
1092
  this.onTouchCancel();
1075
1093
  }
1076
1094
  }
1077
- getLocal(p, updateClient) {
1078
- if (updateClient)
1079
- this.canvas.updateClientBounds();
1080
- if (p.x !== undefined) {
1081
- return { x: p.x, y: p.y };
1095
+ getLocal(clientPoint, updateClient) {
1096
+ if (clientPoint.x !== undefined) {
1097
+ return { x: clientPoint.x, y: clientPoint.y };
1082
1098
  }
1083
1099
  else {
1084
- const { clientBounds } = this.canvas;
1085
- return { x: p.clientX - clientBounds.x, y: p.clientY - clientBounds.y };
1100
+ return super.getLocal(clientPoint, updateClient);
1086
1101
  }
1087
1102
  }
1088
1103
  getTouches(touches) {
@@ -1369,7 +1384,7 @@ function shape(ui, current, options) {
1369
1384
  }
1370
1385
  else {
1371
1386
  const { renderShapeSpread: spread } = ui.__layout;
1372
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, spread * scaleX, spread * scaleY) : current.bounds, nowWorld);
1387
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
1373
1388
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
1374
1389
  let { a: fitScaleX, d: fitScaleY } = fitMatrix;
1375
1390
  if (fitMatrix.a < 1) {
@@ -1469,10 +1484,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
1469
1484
  rotate(transform, rotation);
1470
1485
  data.transform = transform;
1471
1486
  }
1472
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
1487
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
1473
1488
  const transform = get$4();
1474
1489
  if (rotation) {
1475
- if (around === 'center') {
1490
+ if (align === 'center') {
1476
1491
  rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
1477
1492
  }
1478
1493
  else {
@@ -1505,12 +1520,12 @@ function createData(leafPaint, image, paint, box) {
1505
1520
  let { width, height } = image;
1506
1521
  if (paint.padding)
1507
1522
  box = tempBox.set(box).shrink(paint.padding);
1508
- const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
1523
+ const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
1509
1524
  const sameBox = box.width === width && box.height === height;
1510
1525
  if (blendMode)
1511
1526
  leafPaint.blendMode = blendMode;
1512
1527
  const data = leafPaint.data = { mode };
1513
- const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
1528
+ const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
1514
1529
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
1515
1530
  let x = 0, y = 0, scaleX, scaleY;
1516
1531
  if (!mode || mode === 'cover' || mode === 'fit') {
@@ -1528,11 +1543,11 @@ function createData(leafPaint, image, paint, box) {
1528
1543
  scaleX = typeof scale === 'number' ? scale : scale.x;
1529
1544
  scaleY = typeof scale === 'number' ? scale : scale.y;
1530
1545
  }
1531
- if (around) {
1546
+ if (align) {
1532
1547
  const imageBounds = { x, y, width: swapWidth, height: swapHeight };
1533
1548
  if (scaleX)
1534
1549
  imageBounds.width *= scaleX, imageBounds.height *= scaleY;
1535
- AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
1550
+ AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
1536
1551
  x += tempPoint.x, y += tempPoint.y;
1537
1552
  }
1538
1553
  if (offset)
@@ -1549,7 +1564,7 @@ function createData(leafPaint, image, paint, box) {
1549
1564
  break;
1550
1565
  case 'repeat':
1551
1566
  if (!sameBox || scaleX || rotation)
1552
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
1567
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
1553
1568
  if (!repeat)
1554
1569
  data.repeat = 'repeat';
1555
1570
  break;
@@ -1852,13 +1867,14 @@ const PaintImageModule = {
1852
1867
  recycleImage
1853
1868
  };
1854
1869
 
1855
- const defaultFrom$2 = { x: 0.5, y: 0 };
1856
- const defaultTo$2 = { x: 0.5, y: 1 };
1870
+ const { toPoint: toPoint$2 } = AroundHelper;
1871
+ const realFrom$2 = {};
1872
+ const realTo$2 = {};
1857
1873
  function linearGradient(paint, box) {
1858
1874
  let { from, to, type, blendMode, opacity } = paint;
1859
- from || (from = defaultFrom$2);
1860
- to || (to = defaultTo$2);
1861
- const style = Platform.canvas.createLinearGradient(box.x + from.x * box.width, box.y + from.y * box.height, box.x + to.x * box.width, box.y + to.y * box.height);
1875
+ toPoint$2(from || 'top', box, realFrom$2);
1876
+ toPoint$2(to || 'bottom', box, realTo$2);
1877
+ const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
1862
1878
  applyStops(style, paint.stops, opacity);
1863
1879
  const data = { type, style };
1864
1880
  if (blendMode)
@@ -1869,23 +1885,25 @@ function applyStops(gradient, stops, opacity) {
1869
1885
  let stop;
1870
1886
  for (let i = 0, len = stops.length; i < len; i++) {
1871
1887
  stop = stops[i];
1872
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
1888
+ if (typeof stop === 'string') {
1889
+ gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
1890
+ }
1891
+ else {
1892
+ gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
1893
+ }
1873
1894
  }
1874
1895
  }
1875
1896
 
1876
- const { set: set$1, getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
1897
+ const { getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
1877
1898
  const { get: get$1, rotateOfOuter: rotateOfOuter$1, scaleOfOuter: scaleOfOuter$1 } = MatrixHelper;
1878
- const defaultFrom$1 = { x: 0.5, y: 0.5 };
1879
- const defaultTo$1 = { x: 0.5, y: 1 };
1899
+ const { toPoint: toPoint$1 } = AroundHelper;
1880
1900
  const realFrom$1 = {};
1881
1901
  const realTo$1 = {};
1882
1902
  function radialGradient(paint, box) {
1883
1903
  let { from, to, type, opacity, blendMode, stretch } = paint;
1884
- from || (from = defaultFrom$1);
1885
- to || (to = defaultTo$1);
1886
- const { x, y, width, height } = box;
1887
- set$1(realFrom$1, x + from.x * width, y + from.y * height);
1888
- set$1(realTo$1, x + to.x * width, y + to.y * height);
1904
+ toPoint$1(from || 'center', box, realFrom$1);
1905
+ toPoint$1(to || 'bottom', box, realTo$1);
1906
+ const { width, height } = box;
1889
1907
  let transform;
1890
1908
  if (width !== height || stretch) {
1891
1909
  transform = get$1();
@@ -1900,19 +1918,16 @@ function radialGradient(paint, box) {
1900
1918
  return data;
1901
1919
  }
1902
1920
 
1903
- const { set, getAngle, getDistance } = PointHelper;
1921
+ const { getAngle, getDistance } = PointHelper;
1904
1922
  const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
1905
- const defaultFrom = { x: 0.5, y: 0.5 };
1906
- const defaultTo = { x: 0.5, y: 1 };
1923
+ const { toPoint } = AroundHelper;
1907
1924
  const realFrom = {};
1908
1925
  const realTo = {};
1909
1926
  function conicGradient(paint, box) {
1910
1927
  let { from, to, type, opacity, blendMode, stretch } = paint;
1911
- from || (from = defaultFrom);
1912
- to || (to = defaultTo);
1913
- const { x, y, width, height } = box;
1914
- set(realFrom, x + from.x * width, y + from.y * height);
1915
- set(realTo, x + to.x * width, y + to.y * height);
1928
+ toPoint(from || 'center', box, realFrom);
1929
+ toPoint(to || 'bottom', box, realTo);
1930
+ const { width, height } = box;
1916
1931
  const transform = get();
1917
1932
  const angle = getAngle(realFrom, realTo);
1918
1933
  if (Platform.conicGradientRotate90) {
@@ -2066,7 +2081,7 @@ Group.prototype.__renderMask = function (canvas, options) {
2066
2081
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
2067
2082
  maskCanvas = contentCanvas = null;
2068
2083
  }
2069
- if (child.__.maskType === 'path') {
2084
+ if (child.__.mask === 'path') {
2070
2085
  if (child.opacity < 1) {
2071
2086
  currentMask = 'opacity-path';
2072
2087
  maskOpacity = child.opacity;
@@ -2087,7 +2102,7 @@ Group.prototype.__renderMask = function (canvas, options) {
2087
2102
  contentCanvas = getCanvas(canvas);
2088
2103
  child.__render(maskCanvas, options);
2089
2104
  }
2090
- if (child.__.maskType !== 'clipping')
2105
+ if (child.__.mask !== 'clipping')
2091
2106
  continue;
2092
2107
  }
2093
2108
  if (excludeRenderBounds(child, options))
@@ -2388,11 +2403,11 @@ function layoutChar(drawData, style, width, _height) {
2388
2403
  if (mode === WordMode) {
2389
2404
  wordChar = { char: '', x: charX };
2390
2405
  charX = toWordChar(word.data, charX, wordChar);
2391
- if (wordChar.char !== ' ')
2406
+ if (row.isOverflow || wordChar.char !== ' ')
2392
2407
  row.data.push(wordChar);
2393
2408
  }
2394
2409
  else {
2395
- charX = toChar(word.data, charX, row.data);
2410
+ charX = toChar(word.data, charX, row.data, row.isOverflow);
2396
2411
  }
2397
2412
  if (!row.paraEnd && addWordWidth) {
2398
2413
  charX += addWordWidth;
@@ -2419,9 +2434,9 @@ function toWordChar(data, charX, wordChar) {
2419
2434
  });
2420
2435
  return charX;
2421
2436
  }
2422
- function toChar(data, charX, rowData) {
2437
+ function toChar(data, charX, rowData, isOverflow) {
2423
2438
  data.forEach(char => {
2424
- if (char.char !== ' ') {
2439
+ if (isOverflow || char.char !== ' ') {
2425
2440
  char.x = charX;
2426
2441
  rowData.push(char);
2427
2442
  }
@@ -2453,12 +2468,14 @@ function layoutText(drawData, style) {
2453
2468
  for (let i = 0, len = rows.length; i < len; i++) {
2454
2469
  row = rows[i];
2455
2470
  row.x = x;
2456
- switch (textAlign) {
2457
- case 'center':
2458
- row.x += (width - row.width) / 2;
2459
- break;
2460
- case 'right':
2461
- row.x += width - row.width;
2471
+ if (row.width < width || (row.width > width && !__clipText)) {
2472
+ switch (textAlign) {
2473
+ case 'center':
2474
+ row.x += (width - row.width) / 2;
2475
+ break;
2476
+ case 'right':
2477
+ row.x += width - row.width;
2478
+ }
2462
2479
  }
2463
2480
  if (row.paraStart && paraSpacing && i > 0)
2464
2481
  starY += paraSpacing;
@@ -2498,11 +2515,13 @@ function clipText(drawData, style) {
2498
2515
  const { rows, overflow } = drawData;
2499
2516
  let { textOverflow } = style;
2500
2517
  rows.splice(overflow);
2501
- if (textOverflow !== 'hide') {
2502
- if (textOverflow === 'ellipsis')
2518
+ if (textOverflow && textOverflow !== 'show') {
2519
+ if (textOverflow === 'hide')
2520
+ textOverflow = '';
2521
+ else if (textOverflow === 'ellipsis')
2503
2522
  textOverflow = '...';
2504
2523
  let char, charRight;
2505
- const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
2524
+ const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
2506
2525
  const right = style.x + style.width - ellipsisWidth;
2507
2526
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
2508
2527
  list.forEach(row => {
@@ -2670,8 +2689,12 @@ const ExportModule = {
2670
2689
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
2671
2690
  const { worldTransform, isLeafer, isFrame } = leaf;
2672
2691
  const { slice, trim, onCanvas } = options;
2673
- const scale = options.scale || 1;
2674
- const pixelRatio = options.pixelRatio || 1;
2692
+ let scale = options.scale || 1;
2693
+ let pixelRatio = options.pixelRatio || 1;
2694
+ if (leaf.isApp) {
2695
+ scale *= pixelRatio;
2696
+ pixelRatio = leaf.app.pixelRatio;
2697
+ }
2675
2698
  const screenshot = options.screenshot || leaf.isApp;
2676
2699
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
2677
2700
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,FileHelper as h,LeafList as d,RenderEvent as l,ChildEvent as c,WatchEvent as u,PropertyEvent as f,LeafHelper as g,BranchHelper as p,Bounds as _,LeafBoundsHelper as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as R,Answer as k,MatrixHelper as S,AroundHelper as L,ImageEvent as E,PointHelper as T,Direction4 as M,TwoPointBoundsHelper as C,TaskProcessor as A,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as O,InteractionBase as I,HitCanvasManager as P,Platform as F}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as z,PaintGradient as N,Export as V,Group as Y,TextConvert as U,Paint as H,Effect as X}from"@leafer-ui/draw";class j extends t{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=e.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.__createContext();const{width:e,height:s,pixelRatio:n}=this.config,o={width:e||t.width,height:s||t.height,pixelRatio:n};this.resize(o),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,a={width:t,height:e,pixelRatio:i};if(!this.isSameSize(a)){const t={};s.copyAttrs(t,this,n),this.resize(a),void 0!==this.width&&this.resizeListener(new o(a,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}}const{mineType:G,fileType:q}=h;function Q(t,i){e.origin||(e.origin={createCanvas:(t,e,s)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(G(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(G(q(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a&&e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s})})),n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=t})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient)}Object.assign(a,{canvas:(t,e)=>new j(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){e.canvas.view.requestAnimationFrame(t)},e.devicePixelRatio=wx.getSystemInfoSync().pixelRatio;class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new d;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new d,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new u(u.DATA,{updatedList:this.updatedList})),this.__updatedList=new d,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(u.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:Z,updateAllWorldOpacity:$}=g,{pushAllChildBranch:tt,pushAllParent:et}=p;const{worldBounds:it}=w,st={x:0,y:0,width:1e5,height:1e5};class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(st):this.afterBounds.setListWithFn(t,it),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:at}=g,rt=y.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(u.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=v,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new v(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&tt(t,e),et(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),et(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&$(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new v(o,r,this.times)),i.emitEvent(new v(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=v,o=this.getBlocks(new d(e));e.emitEvent(new v(i,o,this.times)),ht.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new v(s,o,this.times)),e.emitEvent(new v(n,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?p.updateBounds(t):g.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(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_(v.REQUEST,this.layout,this),t.on_(v.AGAIN,this.layoutAgain,this),t.on_(u.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=y.get("Renderer");class lt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(v.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,dt.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return dt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new _(s);i.save(),n&&!y.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),y.showHitView&&this.renderHitView(s),y.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 _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(B.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(v.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ct}=R;class ut{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new d(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new d;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||g.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new d;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new d;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new d,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}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.__.mask||(s=!!i.__.hitRadius||ct(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,i){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.add(i||t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ft,NoAndSkip:gt,YesAndSkip:pt}=k;class _t{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new ut(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(v.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&g.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let a=0,r=t.length;a<r;a++){if(n=t[a],o=e(n,s),o===ft||o===pt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<gt&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(c.REMOVE,this.__onRemoveChild,this),this.target.on_(f.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ht.fullLayout;const wt={convertTouch(t,e){const i=wt.getTouch(t),s=O.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 yt extends I{__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=wt.getTouch(t);this.pointerDown(wt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=wt.getTouch(t);this.pointerMove(wt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=wt.getTouch(t);this.pointerUp(wt.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(O.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}}function mt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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 vt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Bt(t,!0,e,i):bt(e,i);break;case"inside":xt("inside",t,n,e,i);break;case"outside":xt("outside",t,n,e,i)}}function xt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?Bt(e,!0,s,r):bt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",mt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function bt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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 Bt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&D.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?bt(i,s):s.stroke(),s.restoreBlendMode()):e?bt(i,s):s.stroke())}const{getSpread:Rt,getOuterOf:kt,getByMove:St,getIntersectData:Lt}=R;let Et;function Tt(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:a,opacity:r}=e;return{type:n,blendMode:o,style:z.string(a,r)};case"image":return D.image(i,t,e,s,!Et||!Et[e.url]);case"linear":return N.linearGradient(e,s);case"radial":return N.radialGradient(e,s);case"angular":return N.conicGradient(e,s);default:return e.r?{type:"solid",style:z.string(e)}:void 0}}const Mt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Et=D.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=Tt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?mt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&D.checkImage(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?mt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?mt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?mt(e,i):n?i.fill(n):i.fill())},fillText:mt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)vt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)vt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Bt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),Bt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:vt,drawTextStroke:bt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:l}=n;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Lt(s?Rt(e.bounds,s*d,s*l):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,l*=f),r=kt(n,a),o=St(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:l}}};let Ct={};const{get:At,rotateOfOuter:Wt,translate:Ot,scaleOfOuter:It,scale:Pt,rotate:Ft}=S;function Dt(t,e,i,s,n,o,a){const r=At();Ot(r,e.x+i,e.y+s),Pt(r,n,o),a&&Wt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function zt(t,e,i,s,n,o,a){const r=At();Ot(r,e.x+i,e.y+s),n&&Pt(r,n,o),a&&Ft(r,a),t.transform=r}function Nt(t,e,i,s,n,o,a,r,h,d){const l=At();if(h)if("center"===d)Wt(l,{x:i/2,y:s/2},h);else switch(Ft(l,h),h){case 90:Ot(l,s,0);break;case 180:Ot(l,i,s);break;case 270:Ot(l,0,i)}Ct.x=e.x+n,Ct.y=e.y+o,Ot(l,Ct.x,Ct.y),a&&It(l,Ct,a,r),t.transform=l}const{get:Vt,translate:Yt}=S,Ut=new _,Ht={};function Xt(t,e,i,s){let{width:n,height:o}=e;i.padding&&(s=Ut.set(s).shrink(i.padding));const{opacity:a,mode:r,around:h,offset:d,scale:l,size:c,rotation:u,blendMode:f,repeat:g}=i,p=s.width===n&&s.height===o;f&&(t.blendMode=f);const _=t.data={mode:r},w="center"!==h&&(u||0)%180==90,y=w?o:n,m=w?n:o;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)c?(v=("number"==typeof c?c:c.width)/n,x=("number"==typeof c?c:c.height)/o):l&&(v="number"==typeof l?l:l.x,x="number"==typeof l?l:l.y);else if(!p||u){const t=s.width/y,e=s.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(s.width-n*v)/2,B+=(s.height-o*x)/2}if(h){const t={x:b,y:B,width:y,height:m};v&&(t.width*=v,t.height*=x),L.toPoint(h,s,Ht,!0,t),b+=Ht.x,B+=Ht.y}switch(d&&(b+=d.x,B+=d.y),r){case"strench":p||(n=s.width,o=s.height);break;case"normal":case"clip":(b||B||v||u)&&zt(_,s,b,B,v,x,u);break;case"repeat":(!p||v||u)&&Nt(_,s,n,o,b,B,v,x,u,h),g||(_.repeat="repeat");break;default:v&&Dt(_,s,b,B,v,x,u)}_.transform||(s.x||s.y)&&(_.transform=Vt(),Yt(_.transform,s.x,s.y)),v&&"strench"!==r&&(_.scaleX=v,_.scaleY=x),_.width=n,_.height=o,a&&(_.opacity=a),g&&(_.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat")}let jt,Gt=new _;const{isSame:qt}=R;function Qt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Xt(n,s,i,o),!0}function Jt(t,e){$t(t,E.LOAD,e)}function Kt(t,e){$t(t,E.LOADED,e)}function Zt(t,e,i){e.error=i,t.forceUpdate("surface"),$t(t,E.ERROR,e)}function $t(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function te(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ee,scale:ie,copy:se}=S,{ceil:ne,abs:oe}=Math;function ae(t,i,s){let{scaleX:n,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o;if(i.patternId===a||t.destroyed)return!1;{n=oe(n),o=oe(o);const{image:t,data:r}=i;let h,d,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=ee(),se(d,p),ie(d,1/u,1/f),n*=u,o*=f),n*=s,o*=s,l*=n,c*=o;const w=l*c;if(!_&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(h=Math.sqrt(w/y)),h&&(n/=h,o/=h,l/=h,c/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(d||(d=ee(),p&&se(d,p)),ie(d,1/n,1/o));const m=t.getCanvas(ne(l)||1,ne(c)||1,g),v=t.getPattern(m,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function re(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(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(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:he}=Math;const de={image:function(t,e,i,s,n){let o,a;const r=b.get(i);return jt&&i===jt.paint&&qt(s,jt.boxBounds)?o=jt.leafPaint:(o={type:i.type,image:r},jt=r.use>1?{leafPaint:o,paint:i,boxBounds:Gt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Qt(t,e,i,r,o,s),n&&(Jt(t,a),Kt(t,a))):r.error?n&&Zt(t,a,r.error):(te(t,!0),n&&Jt(t,a),o.loadId=r.load((()=>{te(t,!1),t.destroyed||(Qt(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,a)),o.loadId=null}),(e=>{te(t,!1),Zt(t,a,e),o.loadId=null}))),o},createData:Xt,fillOrFitMode:Dt,clipMode:zt,repeatMode:Nt,createPattern:ae,checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=b.patternLocked?t.__world:t.__nowWorld;if(s.data&&s.patternId!==o+"-"+a){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=he(o)*i.pixelRatio,s*=he(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||V.running?ae(t,s,i.pixelRatio):s.patternTask||(s.patternTask=b.patternTasker.add((()=>re(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ae(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,b.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null}},le={x:.5,y:0},ce={x:.5,y:1};function ue(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,z.string(s.color,i))}const{set:fe,getAngle:ge,getDistance:pe}=T,{get:_e,rotateOfOuter:we,scaleOfOuter:ye}=S,me={x:.5,y:.5},ve={x:.5,y:1},xe={},be={};const{set:Be,getAngle:Re,getDistance:ke}=T,{get:Se,rotateOfOuter:Le,scaleOfOuter:Ee}=S,Te={x:.5,y:.5},Me={x:.5,y:1},Ce={},Ae={};const We={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;s||(s=le),n||(n=ce);const h=e.canvas.createLinearGradient(i.x+s.x*i.width,i.y+s.y*i.height,i.x+n.x*i.width,i.y+n.y*i.height);ue(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;s||(s=me),n||(n=ve);const{x:d,y:l,width:c,height:u}=i;let f;fe(xe,d+s.x*c,l+s.y*u),fe(be,d+n.x*c,l+n.y*u),(c!==u||h)&&(f=_e(),ye(f,xe,c/u*(h||1),1),we(f,xe,ge(xe,be)+90));const g=e.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,pe(xe,be));ue(g,t.stops,a);const p={type:o,style:g,transform:f};return r&&(p.blendMode=r),p},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;s||(s=Te),n||(n=Me);const{x:d,y:l,width:c,height:u}=i;Be(Ce,d+s.x*c,l+s.y*u),Be(Ae,d+n.x*c,l+n.y*u);const f=Se(),g=Re(Ce,Ae);e.conicGradientRotate90?(Ee(f,Ce,c/u*(h||1),1),Le(f,Ce,g+90)):(Ee(f,Ce,1,c/u*(h||1)),Le(f,Ce,g));const p=e.conicGradientSupport?e.canvas.createConicGradient(0,Ce.x,Ce.y):e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,ke(Ce,Ae));ue(p,t.stops,a);const _={type:o,style:p,transform:f};return r&&(_.blendMode=r),_}},{copy:Oe,toOffsetOutBounds:Ie}=R,Pe={},Fe={};function De(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Oe(Pe,t.bounds),Pe.x+=i.x-a.x,Pe.y+=i.y-a.y,s){const{matrix:t}=n;Pe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Pe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Pe.width*=s,Pe.height*=s}t.copyWorld(n.canvas,t.bounds,Pe)}else s&&(Oe(Pe,i),Pe.x-=i.width/2*(s-1),Pe.y-=i.height/2*(s-1),Pe.width*=s,Pe.height*=s),t.copyWorld(n.canvas,a,s?Pe:i)}const{toOffsetOutBounds:ze}=R,Ne={};const Ve={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ie(d,Fe),r.forEach(((r,p)=>{f.setWorldShadow(Fe.offsetX+r.x*c,Fe.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,De(f,Fe,n,i),s=d,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,d,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,l,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;ze(d,Ne),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Ne.offsetX+r.x*c,Ne.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,De(f,Ne,n,i),f.restore(),h?(f.copyWorld(f,d,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,l,d,"source-out"),s=d),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ye}=w;function Ue(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Xe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Xe(t,i,s,o);break;case"path":i.restore()}}function He(t){return t.getSameCanvas(!1,!0)}function Xe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Y.prototype.__renderMask=function(t,e){let i,s,n,o,a;const{children:r}=this;for(let h=0,d=r.length;h<d;h++)i=r[h],i.__.mask&&(a&&(Ue(this,a,t,n,s,o),s=n=null),"path"===i.__.maskType?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=He(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="alpha",s||(s=He(t)),n||(n=He(t)),i.__render(s,e)),"clipping"!==i.__.maskType)||Ye(i,e)||i.__render(n||t,e);Ue(this,a,t,n,s,o)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ge=je+"_#~&*+\\=|≮≯≈≠=…",qe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Qe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Je=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ze=Qe(je),$e=Qe(Ge),ti=Qe("- —/~|┆·");var ei;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ei||(ei={}));const{Letter:ii,Single:si,Before:ni,After:oi,Symbol:ai,Break:ri}=ei;function hi(t){return Je[t]?ii:ti[t]?ri:Ke[t]?ni:Ze[t]?oi:$e[t]?ai:qe.test(t)?si:ii}const di={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 li(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ci}=di,{Letter:ui,Single:fi,Before:gi,After:pi,Symbol:_i,Break:wi}=ei;let yi,mi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ti,Mi,Ci,Ai,Wi,Oi=[];function Ii(t,e){Si&&!ki&&(ki=Si),yi.data.push({char:t,width:e}),vi+=e}function Pi(){xi+=vi,yi.width=vi,mi.words.push(yi),yi={data:[]},vi=0}function Fi(){Ci&&(Ai.paraNumber++,mi.paraStart=!0,Ci=!1),Si&&(mi.startCharSize=ki,mi.endCharSize=Si,ki=0),mi.width=xi,Wi.width&&ci(mi),Oi.push(mi),mi={words:[]},xi=0}const Di=0,zi=1,Ni=2;const{top:Vi,right:Yi,bottom:Ui,left:Hi}=M;function Xi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ji={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o&&(s=d[Hi],o-=d[Yi]+d[Hi]),a&&(n=d[Vi],a-=d[Vi]+d[Ui]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Ai=t,Oi=t.rows,Wi=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=Wi;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Ci=!0,Ei=null,ki=Ri=Si=vi=xi=0,yi={data:[]},mi={words:[]};for(let s=0,d=i.length;s<d;s++)Bi=i[s],"\n"===Bi?(vi&&Pi(),mi.paraEnd=!0,Fi(),Ci=!0):(Li=hi(Bi),Li===ui&&"none"!==a&&(Bi=li(Bi,a,!vi)),Ri=r.measureText(Bi).width,n&&(n<0&&(Si=Ri),Ri+=n),Ti=Li===fi&&(Ei===fi||Ei===ui)||Ei===fi&&Li!==pi,Mi=!(Li!==gi&&Li!==fi||Ei!==_i&&Ei!==pi),bi=Ci&&o?h-o:h,t&&h&&xi+vi+Ri>bi&&(e?(vi&&Pi(),Fi()):(Mi||(Mi=Li===ui&&Ei==pi),Ti||Mi||Li===wi||Li===gi||Li===fi||vi+Ri>bi?(vi&&Pi(),Fi()):Fi()))," "===Bi&&!0!==Ci&&xi+vi===0||(Li===wi?(" "===Bi&&vi&&Pi(),Ii(Bi,Ri),Pi()):Ti||Mi?(vi&&Pi(),Ii(Bi,Ri)):Ii(Bi,Ri)),Ei=Li);vi&&Pi(),xi&&Fi(),Oi.length>0&&(Oi[Oi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ai.paraNumber++,Oi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Xi(e,"x",t[Hi]);break;case"right":Xi(e,"x",-t[Yi])}if(!n)switch(i.verticalAlign){case"top":Xi(e,"y",t[Vi]);break;case"bottom":Xi(e,"y",-t[Ui])}}(d,l,i,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:l}=e;let c,u,f,{x:g,y:p,width:_,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(d){case"middle":p+=(w-y)/2;break;case"bottom":p+=w-y}m+=p;for(let o=0,d=i.length;o<d;o++){switch(c=i[o],c.x=g,h){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&l&&o>0&&(m+=l),c.y=m,m+=n,t.overflow>o&&m>y&&(c.isOverflow=!0,t.overflow=o+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<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=y}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Di:d>.01?zi:Ni,t.isOverflow&&!r&&(t.textMode=!0),c===Ni?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,h=t.x,t.data=[],t.words.forEach((e=>{c===zi?(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,i,o),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:o}=i;if(s.splice(n),"hide"!==o){let t,a;"ellipsis"===o&&(o="...");const r=e.canvas.measureText(o).width,h=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<h));s--){if(a<h&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"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,i),l}};const Gi={string:function(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+")"}},{setPoint:qi,addPoint:Qi,toBounds:Ji}=C;const Ki={export(t,i,s){return this.running=!0,function(t){Zi||(Zi=new A);return new Promise((e=>{Zi.add((()=>re(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=t=>{n(t),o(),this.running=!1};if("json"===i)return r({data:t.toJSON()});if("json"===h.fileType(i))return e.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(t.toJSON())),i),r({data:!0});const{leafer:d}=t;d?d.waitViewCompleted((()=>re(this,void 0,void 0,(function*(){s=h.getExportOptions(s);let e,n,o=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:g,trim:p,onCanvas:w}=s,y=s.scale||1,m=s.pixelRatio||1,v=s.screenshot||t.isApp,x=u&&v&&void 0===s.fill?t.fill:s.fill,b=h.isOpaqueImage(i)||x,B=new W;if(v)e=!0===v?u?d.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(u?"inner":"local");switch(o=c.scaleX,l=c.scaleY,i){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),o/=t.scaleX,l/=t.scaleY;break;case"world":o=1,l=1;break;case"page":i=t.leafer;default:B.set(c).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:k,width:S,height:L}=new _(e).scale(y);let E=a.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:m});const T={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/o*y,1/l*y)};if(g&&(t=d,T.bounds=E.bounds),E.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(E,T),t.fill=e}else t.__render(E,T);if(E.restore(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?Qi(a,n,o):qi(a={},n,o)),r++;const h=new _;return Ji(a,h),h.scale(1/t.pixelRatio).ceil()}(E);const t=E,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:m};E=a.canvas(s),E.copyWorld(t,n,s)}b&&E.fillWorld(E.bounds,x||"#FFFFFF","destination-over"),w&&w(E);const M="canvas"===i?E:yield E.export(i,s);r({data:M,width:E.pixelWidth,height:E.pixelHeight,renderBounds:e,trimBounds:n})})))):r({data:!1})}))))}};let Zi;const $i=t.prototype,ts=y.get("@leafer-ui/export");$i.export=function(t,e){const{quality:i,blob:s}=h.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},$i.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{ts.error(t),s(null)}))}))},$i.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},$i.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{ts.error(t),s(!1)}))}))},Object.assign(U,ji),Object.assign(z,Gi),Object.assign(H,Mt),Object.assign(D,de),Object.assign(N,We),Object.assign(X,Ve),Object.assign(V,Ki),Object.assign(a,{interaction:(t,e,i,s)=>new yt(t,e,i,s),hitCanvas:(t,e)=>new j(t,e),hitCanvasManager:()=>new P});try{Q(0,wx)}catch(t){}j.prototype.__createContext=function(){if(this.viewSelect){const t=F.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()},j.prototype.updateRender=function(){if(this.testView){let t=this.context.createPattern(this.view,F.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}},j.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{yt as Interaction,ht as Layouter,j as LeaferCanvas,lt as Renderer,_t as Selector,J as Watcher,Q as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,FileHelper as h,LeafList as d,RenderEvent as l,ChildEvent as c,WatchEvent as u,PropertyEvent as f,LeafHelper as g,BranchHelper as p,Bounds as _,LeafBoundsHelper as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as R,Answer as k,MatrixHelper as S,AlignHelper as L,ImageEvent as E,AroundHelper as T,PointHelper as M,Direction4 as A,TwoPointBoundsHelper as C,TaskProcessor as W,Matrix as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as I,InteractionBase as P,HitCanvasManager as F,Platform as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as z,ColorConvert as N,PaintGradient as V,Export as U,Group as Y,TextConvert as j,Paint as H,Effect as G}from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=e.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.__createContext();const{width:e,height:s,pixelRatio:n}=this.config,o={width:e||t.width,height:s||t.height,pixelRatio:n};this.resize(o),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,a={width:t,height:e,pixelRatio:i};if(!this.isSameSize(a)){const t={};s.copyAttrs(t,this,n),this.resize(a),void 0!==this.width&&this.resizeListener(new o(a,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}}const{mineType:q,fileType:Q}=h;function J(t,i){e.origin||(e.origin={createCanvas:(t,e,s)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(q(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(q(Q(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a&&e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s})})),n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=t})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient)}Object.assign(a,{canvas:(t,e)=>new X(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){e.canvas.view.requestAnimationFrame(t)},e.devicePixelRatio=wx.getSystemInfoSync().pixelRatio;class K{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new d;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new d,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new u(u.DATA,{updatedList:this.updatedList})),this.__updatedList=new d,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(u.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:$,updateAllWorldOpacity:tt}=g,{pushAllChildBranch:et,pushAllParent:it}=p;const{worldBounds:st}=w,nt={x:0,y:0,width:1e5,height:1e5};class ot{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:at,updateAllChange:rt}=g,ht=y.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(u.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=v,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new v(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Z(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||$(s[t])}$(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&tt(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new v(o,r,this.times)),i.emitEvent(new v(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=v,o=this.getBlocks(new d(e));e.emitEvent(new v(i,o,this.times)),dt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new v(s,o,this.times)),e.emitEvent(new v(n,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){at(t,!0),t.isBranch?p.updateBounds(t):g.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(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_(v.REQUEST,this.layout,this),t.on_(v.AGAIN,this.layoutAgain,this),t.on_(u.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const lt=y.get("Renderer");class ct{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(v.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,lt.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,lt.error(t)}lt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return lt.warn("rendering");if(this.times>3)return lt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return lt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new _(s);i.save(),n&&!y.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),y.showHitView&&this.renderHitView(s),y.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 _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(B.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||lt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(v.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ut}=R;class ft{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new d(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new d;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||g.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new d;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new d;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new d,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}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.__.mask||(s=!!i.__.hitRadius||ut(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,i){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.add(i||t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:gt,NoAndSkip:pt,YesAndSkip:_t}=k,wt={},yt={},mt={};class vt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new ft(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const o=this.getByInnerId(t,e);return i?o:o?[o]:[];case"string":switch(t[0]){case"#":wt.id=t.substring(1),t=wt;break;case".":yt.className=t.substring(1),t=yt;break;default:mt.tag=t,t=mt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:n}=t,o=n instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,e,i,o?s.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(v.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&g.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let a=0,r=t.length;a<r;a++){if(n=t[a],o=e(n,s),o===gt||o===_t){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<pt&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(c.REMOVE,this.__onRemoveChild,this),this.target.on_(f.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new ct(t,e,i),selector:(t,e)=>new vt(t,e)}),e.layout=dt.fullLayout;const xt={convertTouch(t,e){const i=xt.getTouch(t),s=I.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 bt extends P{__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){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=xt.getTouch(t);this.pointerDown(xt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=xt.getTouch(t);this.pointerMove(xt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=xt.getTouch(t);this.pointerUp(xt.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(I.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}}function Bt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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 Rt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Lt(t,!0,e,i):St(e,i);break;case"inside":kt("inside",t,n,e,i);break;case"outside":kt("outside",t,n,e,i)}}function kt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?Lt(e,!0,s,r):St(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",Bt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function St(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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 Lt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&z.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?St(i,s):s.stroke(),s.restoreBlendMode()):e?St(i,s):s.stroke())}const{getSpread:Et,getOuterOf:Tt,getByMove:Mt,getIntersectData:At}=R;let Ct;function Wt(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:a,opacity:r}=e;return{type:n,blendMode:o,style:N.string(a,r)};case"image":return z.image(i,t,e,s,!Ct||!Ct[e.url]);case"linear":return V.linearGradient(e,s);case"radial":return V.radialGradient(e,s);case"angular":return V.conicGradient(e,s);default:return e.r?{type:"solid",style:N.string(e)}:void 0}}const Ot={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Ct=z.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=Wt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?Bt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&z.checkImage(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?Bt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Bt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Bt(e,i):n?i.fill(n):i.fill())},fillText:Bt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)Rt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)Rt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Lt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Lt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),Lt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:Rt,drawTextStroke:St,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:l}=n;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=At(s?Et(e.bounds,d===l?s*d:[s*l,s*d]):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,l*=f),r=Tt(n,a),o=Mt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:l}}};let It={};const{get:Pt,rotateOfOuter:Ft,translate:Dt,scaleOfOuter:zt,scale:Nt,rotate:Vt}=S;function Ut(t,e,i,s,n,o,a){const r=Pt();Dt(r,e.x+i,e.y+s),Nt(r,n,o),a&&Ft(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Yt(t,e,i,s,n,o,a){const r=Pt();Dt(r,e.x+i,e.y+s),n&&Nt(r,n,o),a&&Vt(r,a),t.transform=r}function jt(t,e,i,s,n,o,a,r,h,d){const l=Pt();if(h)if("center"===d)Ft(l,{x:i/2,y:s/2},h);else switch(Vt(l,h),h){case 90:Dt(l,s,0);break;case 180:Dt(l,i,s);break;case 270:Dt(l,0,i)}It.x=e.x+n,It.y=e.y+o,Dt(l,It.x,It.y),a&&zt(l,It,a,r),t.transform=l}const{get:Ht,translate:Gt}=S,Xt=new _,qt={};function Qt(t,e,i,s){let{width:n,height:o}=e;i.padding&&(s=Xt.set(s).shrink(i.padding));const{opacity:a,mode:r,align:h,offset:d,scale:l,size:c,rotation:u,blendMode:f,repeat:g}=i,p=s.width===n&&s.height===o;f&&(t.blendMode=f);const _=t.data={mode:r},w="center"!==h&&(u||0)%180==90,y=w?o:n,m=w?n:o;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)c?(v=("number"==typeof c?c:c.width)/n,x=("number"==typeof c?c:c.height)/o):l&&(v="number"==typeof l?l:l.x,x="number"==typeof l?l:l.y);else if(!p||u){const t=s.width/y,e=s.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(s.width-n*v)/2,B+=(s.height-o*x)/2}if(h){const t={x:b,y:B,width:y,height:m};v&&(t.width*=v,t.height*=x),L.toPoint(h,t,s,qt,!0),b+=qt.x,B+=qt.y}switch(d&&(b+=d.x,B+=d.y),r){case"strench":p||(n=s.width,o=s.height);break;case"normal":case"clip":(b||B||v||u)&&Yt(_,s,b,B,v,x,u);break;case"repeat":(!p||v||u)&&jt(_,s,n,o,b,B,v,x,u,h),g||(_.repeat="repeat");break;default:v&&Ut(_,s,b,B,v,x,u)}_.transform||(s.x||s.y)&&(_.transform=Ht(),Gt(_.transform,s.x,s.y)),v&&"strench"!==r&&(_.scaleX=v,_.scaleY=x),_.width=n,_.height=o,a&&(_.opacity=a),g&&(_.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat")}let Jt,Kt=new _;const{isSame:Zt}=R;function $t(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Qt(n,s,i,o),!0}function te(t,e){se(t,E.LOAD,e)}function ee(t,e){se(t,E.LOADED,e)}function ie(t,e,i){e.error=i,t.forceUpdate("surface"),se(t,E.ERROR,e)}function se(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function ne(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:oe,scale:ae,copy:re}=S,{ceil:he,abs:de}=Math;function le(t,i,s){let{scaleX:n,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o;if(i.patternId===a||t.destroyed)return!1;{n=de(n),o=de(o);const{image:t,data:r}=i;let h,d,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=oe(),re(d,p),ae(d,1/u,1/f),n*=u,o*=f),n*=s,o*=s,l*=n,c*=o;const w=l*c;if(!_&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(h=Math.sqrt(w/y)),h&&(n/=h,o/=h,l/=h,c/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(d||(d=oe(),p&&re(d,p)),ae(d,1/n,1/o));const m=t.getCanvas(he(l)||1,he(c)||1,g),v=t.getPattern(m,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function ce(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(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(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ue}=Math;const fe={image:function(t,e,i,s,n){let o,a;const r=b.get(i);return Jt&&i===Jt.paint&&Zt(s,Jt.boxBounds)?o=Jt.leafPaint:(o={type:i.type,image:r},Jt=r.use>1?{leafPaint:o,paint:i,boxBounds:Kt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?($t(t,e,i,r,o,s),n&&(te(t,a),ee(t,a))):r.error?n&&ie(t,a,r.error):(ne(t,!0),n&&te(t,a),o.loadId=r.load((()=>{ne(t,!1),t.destroyed||($t(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ee(t,a)),o.loadId=null}),(e=>{ne(t,!1),ie(t,a,e),o.loadId=null}))),o},createData:Qt,fillOrFitMode:Ut,clipMode:Yt,repeatMode:jt,createPattern:le,checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=b.patternLocked?t.__world:t.__nowWorld;if(s.data&&s.patternId!==o+"-"+a){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=ue(o)*i.pixelRatio,s*=ue(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||U.running?le(t,s,i.pixelRatio):s.patternTask||(s.patternTask=b.patternTasker.add((()=>ce(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&le(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,b.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null}},{toPoint:ge}=T,pe={},_e={};function we(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),N.string(s,i)):t.addColorStop(s.offset,N.string(s.color,i))}const{getAngle:ye,getDistance:me}=M,{get:ve,rotateOfOuter:xe,scaleOfOuter:be}=S,{toPoint:Be}=T,Re={},ke={};const{getAngle:Se,getDistance:Le}=M,{get:Ee,rotateOfOuter:Te,scaleOfOuter:Me}=S,{toPoint:Ae}=T,Ce={},We={};const Oe={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;ge(s||"top",i,pe),ge(n||"bottom",i,_e);const h=e.canvas.createLinearGradient(pe.x,pe.y,_e.x,_e.y);we(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Be(s||"center",i,Re),Be(n||"bottom",i,ke);const{width:d,height:l}=i;let c;(d!==l||h)&&(c=ve(),be(c,Re,d/l*(h||1),1),xe(c,Re,ye(Re,ke)+90));const u=e.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,me(Re,ke));we(u,t.stops,a);const f={type:o,style:u,transform:c};return r&&(f.blendMode=r),f},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Ae(s||"center",i,Ce),Ae(n||"bottom",i,We);const{width:d,height:l}=i,c=Ee(),u=Se(Ce,We);e.conicGradientRotate90?(Me(c,Ce,d/l*(h||1),1),Te(c,Ce,u+90)):(Me(c,Ce,1,d/l*(h||1)),Te(c,Ce,u));const f=e.conicGradientSupport?e.canvas.createConicGradient(0,Ce.x,Ce.y):e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,Le(Ce,We));we(f,t.stops,a);const g={type:o,style:f,transform:c};return r&&(g.blendMode=r),g}},{copy:Ie,toOffsetOutBounds:Pe}=R,Fe={},De={};function ze(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Ie(Fe,t.bounds),Fe.x+=i.x-a.x,Fe.y+=i.y-a.y,s){const{matrix:t}=n;Fe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Fe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Fe.width*=s,Fe.height*=s}t.copyWorld(n.canvas,t.bounds,Fe)}else s&&(Ie(Fe,i),Fe.x-=i.width/2*(s-1),Fe.y-=i.height/2*(s-1),Fe.width*=s,Fe.height*=s),t.copyWorld(n.canvas,a,s?Fe:i)}const{toOffsetOutBounds:Ne}=R,Ve={};const Ue={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Pe(d,De),r.forEach(((r,p)=>{f.setWorldShadow(De.offsetX+r.x*c,De.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ze(f,De,n,i),s=d,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,d,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,l,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ne(d,Ve),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Ve.offsetX+r.x*c,Ve.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ze(f,Ve,n,i),f.restore(),h?(f.copyWorld(f,d,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,l,d,"source-out"),s=d),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ye}=w;function je(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ge(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ge(t,i,s,o);break;case"path":i.restore()}}function He(t){return t.getSameCanvas(!1,!0)}function Ge(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Y.prototype.__renderMask=function(t,e){let i,s,n,o,a;const{children:r}=this;for(let h=0,d=r.length;h<d;h++)i=r[h],i.__.mask&&(a&&(je(this,a,t,n,s,o),s=n=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=He(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="alpha",s||(s=He(t)),n||(n=He(t)),i.__render(s,e)),"clipping"!==i.__.mask)||Ye(i,e)||i.__render(n||t,e);je(this,a,t,n,s,o)};const Xe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qe=Xe+"_#~&*+\\=|≮≯≈≠=…",Qe=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 Je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ke=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ze=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$e=Je(Xe),ti=Je(qe),ei=Je("- —/~|┆·");var ii;!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"}(ii||(ii={}));const{Letter:si,Single:ni,Before:oi,After:ai,Symbol:ri,Break:hi}=ii;function di(t){return Ke[t]?si:ei[t]?hi:Ze[t]?oi:$e[t]?ai:ti[t]?ri:Qe.test(t)?ni:si}const li={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 ci(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ui}=li,{Letter:fi,Single:gi,Before:pi,After:_i,Symbol:wi,Break:yi}=ii;let mi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ti,Mi,Ai,Ci,Wi,Oi,Ii=[];function Pi(t,e){Li&&!Si&&(Si=Li),mi.data.push({char:t,width:e}),xi+=e}function Fi(){bi+=xi,mi.width=xi,vi.words.push(mi),mi={data:[]},xi=0}function Di(){Ci&&(Wi.paraNumber++,vi.paraStart=!0,Ci=!1),Li&&(vi.startCharSize=Si,vi.endCharSize=Li,Si=0),vi.width=bi,Oi.width&&ui(vi),Ii.push(vi),vi={words:[]},bi=0}const zi=0,Ni=1,Vi=2;const{top:Ui,right:Yi,bottom:ji,left:Hi}=A;function Gi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Xi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o&&(s=d[Hi],o-=d[Yi]+d[Hi]),a&&(n=d[Ui],a-=d[Ui]+d[ji]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Wi=t,Ii=t.rows,Oi=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=Oi;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Ci=!0,Ti=null,Si=ki=Li=xi=bi=0,mi={data:[]},vi={words:[]};for(let s=0,d=i.length;s<d;s++)Ri=i[s],"\n"===Ri?(xi&&Fi(),vi.paraEnd=!0,Di(),Ci=!0):(Ei=di(Ri),Ei===fi&&"none"!==a&&(Ri=ci(Ri,a,!xi)),ki=r.measureText(Ri).width,n&&(n<0&&(Li=ki),ki+=n),Mi=Ei===gi&&(Ti===gi||Ti===fi)||Ti===gi&&Ei!==_i,Ai=!(Ei!==pi&&Ei!==gi||Ti!==wi&&Ti!==_i),Bi=Ci&&o?h-o:h,t&&h&&bi+xi+ki>Bi&&(e?(xi&&Fi(),Di()):(Ai||(Ai=Ei===fi&&Ti==_i),Mi||Ai||Ei===yi||Ei===pi||Ei===gi||xi+ki>Bi?(xi&&Fi(),Di()):Di()))," "===Ri&&!0!==Ci&&bi+xi===0||(Ei===yi?(" "===Ri&&xi&&Fi(),Pi(Ri,ki),Fi()):Mi||Ai?(xi&&Fi(),Pi(Ri,ki)):Pi(Ri,ki)),Ti=Ei);xi&&Fi(),bi&&Di(),Ii.length>0&&(Ii[Ii.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Wi.paraNumber++,Ii.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Gi(e,"x",t[Hi]);break;case"right":Gi(e,"x",-t[Yi])}if(!n)switch(i.verticalAlign){case"top":Gi(e,"y",t[Ui]);break;case"bottom":Gi(e,"y",-t[ji])}}(d,l,i,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:l}=e;let c,u,f,{x:g,y:p,width:_,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(d){case"middle":p+=(w-y)/2;break;case"bottom":p+=w-y}m+=p;for(let o=0,d=i.length;o<d;o++){if(c=i[o],c.x=g,c.width<_||c.width>_&&!r)switch(h){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&l&&o>0&&(m+=l),c.y=m,m+=n,t.overflow>o&&m>y&&(c.isOverflow=!0,t.overflow=o+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<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=y}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?zi:d>.01?Ni:Vi,t.isOverflow&&!r&&(t.textMode=!0),c===Vi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,h=t.x,t.data=[],t.words.forEach((e=>{c===Ni?(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),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(l,i,o),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:o}=i;if(s.splice(n),o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?e.canvas.measureText(o).width:0,h=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<h));s--){if(a<h&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"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,i),l}};const qi={string:function(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+")"}},{setPoint:Qi,addPoint:Ji,toBounds:Ki}=C;const Zi={export(t,i,s){return this.running=!0,function(t){$i||($i=new W);return new Promise((e=>{$i.add((()=>ce(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=t=>{n(t),o(),this.running=!1};if("json"===i)return r({data:t.toJSON()});if("json"===h.fileType(i))return e.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(t.toJSON())),i),r({data:!0});const{leafer:d}=t;d?d.waitViewCompleted((()=>ce(this,void 0,void 0,(function*(){s=h.getExportOptions(s);let e,n,o=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:g,trim:p,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;t.isApp&&(y*=m,m=t.app.pixelRatio);const v=s.screenshot||t.isApp,x=u&&v&&void 0===s.fill?t.fill:s.fill,b=h.isOpaqueImage(i)||x,B=new O;if(v)e=!0===v?u?d.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(u?"inner":"local");switch(o=c.scaleX,l=c.scaleY,i){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),o/=t.scaleX,l/=t.scaleY;break;case"world":o=1,l=1;break;case"page":i=t.leafer;default:B.set(c).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:k,width:S,height:L}=new _(e).scale(y);let E=a.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:m});const T={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/o*y,1/l*y)};if(g&&(t=d,T.bounds=E.bounds),E.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(E,T),t.fill=e}else t.__render(E,T);if(E.restore(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?Ji(a,n,o):Qi(a={},n,o)),r++;const h=new _;return Ki(a,h),h.scale(1/t.pixelRatio).ceil()}(E);const t=E,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:m};E=a.canvas(s),E.copyWorld(t,n,s)}b&&E.fillWorld(E.bounds,x||"#FFFFFF","destination-over"),w&&w(E);const M="canvas"===i?E:yield E.export(i,s);r({data:M,width:E.pixelWidth,height:E.pixelHeight,renderBounds:e,trimBounds:n})})))):r({data:!1})}))))}};let $i;const ts=t.prototype,es=y.get("@leafer-ui/export");ts.export=function(t,e){const{quality:i,blob:s}=h.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},ts.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{es.error(t),s(null)}))}))},ts.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},ts.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{es.error(t),s(!1)}))}))},Object.assign(j,Xi),Object.assign(N,qi),Object.assign(H,Ot),Object.assign(z,fe),Object.assign(V,Oe),Object.assign(G,Ue),Object.assign(U,Zi),Object.assign(a,{interaction:(t,e,i,s)=>new bt(t,e,i,s),hitCanvas:(t,e)=>new X(t,e),hitCanvasManager:()=>new F});try{J(0,wx)}catch(t){}X.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()},X.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}},X.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{bt as Interaction,dt as Layouter,X as LeaferCanvas,ct as Renderer,vt as Selector,K as Watcher,J as useCanvas};