leafer-ui 1.9.9 → 1.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.cjs CHANGED
@@ -876,7 +876,7 @@ class Picker {
876
876
  children: [ target ]
877
877
  } : target);
878
878
  const {list: list} = this.findList;
879
- const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
879
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable, !!options.findList);
880
880
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
881
881
  this.clear();
882
882
  return through ? {
@@ -891,7 +891,7 @@ class Picker {
891
891
  hitPoint(hitPoint, hitRadius, options) {
892
892
  return !!this.getByPoint(hitPoint, hitRadius, options).target;
893
893
  }
894
- getBestMatchLeaf(list, bottomList, ignoreHittable) {
894
+ getBestMatchLeaf(list, bottomList, ignoreHittable, allowNull) {
895
895
  const findList = this.findList = new core.LeafList;
896
896
  if (list.length) {
897
897
  let find;
@@ -922,15 +922,27 @@ class Picker {
922
922
  if (findList.length) return findList.list[0];
923
923
  }
924
924
  }
925
+ if (allowNull) return null;
925
926
  return ignoreHittable ? list[0] : list.find(item => core.LeafHelper.worldHittable(item));
926
927
  }
927
928
  getPath(leaf) {
928
- const path = new core.LeafList;
929
+ const path = new core.LeafList, syncList = [], {target: target} = this;
929
930
  while (leaf) {
931
+ if (leaf.syncEventer) syncList.push(leaf.syncEventer);
930
932
  path.add(leaf);
931
933
  leaf = leaf.parent;
934
+ if (leaf === target) break;
935
+ }
936
+ if (syncList.length) {
937
+ syncList.forEach(item => {
938
+ while (item) {
939
+ if (item.__.hittable) path.add(item);
940
+ item = item.parent;
941
+ if (item === target) break;
942
+ }
943
+ });
932
944
  }
933
- if (this.target) path.add(this.target);
945
+ if (target) path.add(target);
934
946
  return path;
935
947
  }
936
948
  getHitablePath(leaf) {
@@ -1734,7 +1746,14 @@ const PaintModule = {
1734
1746
 
1735
1747
  let origin = {}, tempMatrix$1 = core.getMatrixData();
1736
1748
 
1737
- const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = core.MatrixHelper;
1749
+ const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = core.MatrixHelper;
1750
+
1751
+ function stretchMode(data, box, scaleX, scaleY) {
1752
+ const transform = get$3();
1753
+ translate$1(transform, box.x, box.y);
1754
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
1755
+ data.transform = transform;
1756
+ }
1738
1757
 
1739
1758
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1740
1759
  const transform = get$3();
@@ -1751,8 +1770,11 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, c
1751
1770
  const transform = get$3();
1752
1771
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1753
1772
  if (clipScaleX) {
1754
- tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
1755
- multiplyParent(transform, tempMatrix$1);
1773
+ if (rotation || skew) {
1774
+ set(tempMatrix$1);
1775
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
1776
+ multiplyParent(transform, tempMatrix$1);
1777
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
1756
1778
  }
1757
1779
  data.transform = transform;
1758
1780
  }
@@ -1848,7 +1870,10 @@ function getPatternData(paint, box, image) {
1848
1870
  if (offset) core.PointHelper.move(tempImage, offset);
1849
1871
  switch (mode) {
1850
1872
  case "stretch":
1851
- if (!sameBox) width = box.width, height = box.height;
1873
+ if (!sameBox) {
1874
+ scaleX = box.width / width, scaleY = box.height / height;
1875
+ stretchMode(data, box, scaleX, scaleY);
1876
+ }
1852
1877
  break;
1853
1878
 
1854
1879
  case "normal":
@@ -1857,7 +1882,7 @@ function getPatternData(paint, box, image) {
1857
1882
  let clipScaleX, clipScaleY;
1858
1883
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
1859
1884
  clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
1860
- if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1885
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1861
1886
  }
1862
1887
  break;
1863
1888
 
@@ -1874,17 +1899,14 @@ function getPatternData(paint, box, image) {
1874
1899
  if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1875
1900
  }
1876
1901
  if (!data.transform) {
1877
- if (box.x || box.y) {
1878
- data.transform = get$2();
1879
- translate(data.transform, box.x, box.y);
1880
- }
1902
+ if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
1881
1903
  }
1882
- if (scaleX && mode !== "stretch") {
1904
+ data.width = width;
1905
+ data.height = height;
1906
+ if (scaleX) {
1883
1907
  data.scaleX = scaleX;
1884
1908
  data.scaleY = scaleY;
1885
1909
  }
1886
- data.width = width;
1887
- data.height = height;
1888
1910
  if (opacity) data.opacity = opacity;
1889
1911
  if (filters) data.filters = filters;
1890
1912
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
@@ -2016,7 +2038,7 @@ function ignoreRender(ui, value) {
2016
2038
 
2017
2039
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
2018
2040
 
2019
- const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
2041
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
2020
2042
 
2021
2043
  function createPattern(ui, paint, pixelRatio) {
2022
2044
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -2027,8 +2049,8 @@ function createPattern(ui, paint, pixelRatio) {
2027
2049
  scaleX *= pixelRatio;
2028
2050
  scaleY *= pixelRatio;
2029
2051
  if (sx) {
2030
- sx = abs(sx);
2031
- sy = abs(sy);
2052
+ sx = abs$1(sx);
2053
+ sy = abs$1(sy);
2032
2054
  imageMatrix = get$1();
2033
2055
  copy$1(imageMatrix, transform);
2034
2056
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -2203,6 +2225,7 @@ const PaintImageModule = {
2203
2225
  recycleImage: recycleImage,
2204
2226
  createData: createData,
2205
2227
  getPatternData: getPatternData,
2228
+ stretchMode: stretchMode,
2206
2229
  fillOrFitMode: fillOrFitMode,
2207
2230
  clipMode: clipMode,
2208
2231
  repeatMode: repeatMode
@@ -2313,7 +2336,7 @@ const PaintGradientModule = {
2313
2336
  getTransform: getTransform
2314
2337
  };
2315
2338
 
2316
- const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = core.BoundsHelper, {max: max} = Math;
2339
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = core.BoundsHelper, {max: max, abs: abs} = Math;
2317
2340
 
2318
2341
  const tempBounds = {}, tempMatrix = new core.Matrix;
2319
2342
 
@@ -2357,7 +2380,7 @@ function shadow(ui, current, shape) {
2357
2380
  function getShadowRenderSpread(_ui, shadow) {
2358
2381
  let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
2359
2382
  shadow.forEach(item => {
2360
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
2383
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs(item.spread || 0);
2361
2384
  top = max(top, spread + blur - y);
2362
2385
  right = max(right, spread + blur + x);
2363
2386
  bottom = max(bottom, spread + blur + y);
@@ -2368,11 +2391,11 @@ function getShadowRenderSpread(_ui, shadow) {
2368
2391
 
2369
2392
  function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
2370
2393
  if (shadow.spread) {
2371
- const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
2394
+ const spread = shadow.spread * 2 * otherScale * (isInnerShaodw ? -1 : 1), {width: width, height: height} = ui.__layout.strokeBounds;
2372
2395
  tempMatrix.set().scaleOfOuter({
2373
2396
  x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
2374
2397
  y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
2375
- }, spreadScale);
2398
+ }, 1 + spread / width, 1 + spread / height);
2376
2399
  return tempMatrix;
2377
2400
  }
2378
2401
  return undefined;
package/dist/web.esm.js CHANGED
@@ -880,7 +880,7 @@ class Picker {
880
880
  children: [ target ]
881
881
  } : target);
882
882
  const {list: list} = this.findList;
883
- const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
883
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable, !!options.findList);
884
884
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
885
885
  this.clear();
886
886
  return through ? {
@@ -895,7 +895,7 @@ class Picker {
895
895
  hitPoint(hitPoint, hitRadius, options) {
896
896
  return !!this.getByPoint(hitPoint, hitRadius, options).target;
897
897
  }
898
- getBestMatchLeaf(list, bottomList, ignoreHittable) {
898
+ getBestMatchLeaf(list, bottomList, ignoreHittable, allowNull) {
899
899
  const findList = this.findList = new LeafList;
900
900
  if (list.length) {
901
901
  let find;
@@ -926,15 +926,27 @@ class Picker {
926
926
  if (findList.length) return findList.list[0];
927
927
  }
928
928
  }
929
+ if (allowNull) return null;
929
930
  return ignoreHittable ? list[0] : list.find(item => LeafHelper.worldHittable(item));
930
931
  }
931
932
  getPath(leaf) {
932
- const path = new LeafList;
933
+ const path = new LeafList, syncList = [], {target: target} = this;
933
934
  while (leaf) {
935
+ if (leaf.syncEventer) syncList.push(leaf.syncEventer);
934
936
  path.add(leaf);
935
937
  leaf = leaf.parent;
938
+ if (leaf === target) break;
939
+ }
940
+ if (syncList.length) {
941
+ syncList.forEach(item => {
942
+ while (item) {
943
+ if (item.__.hittable) path.add(item);
944
+ item = item.parent;
945
+ if (item === target) break;
946
+ }
947
+ });
936
948
  }
937
- if (this.target) path.add(this.target);
949
+ if (target) path.add(target);
938
950
  return path;
939
951
  }
940
952
  getHitablePath(leaf) {
@@ -1738,7 +1750,14 @@ const PaintModule = {
1738
1750
 
1739
1751
  let origin = {}, tempMatrix$1 = getMatrixData();
1740
1752
 
1741
- const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
1753
+ const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
1754
+
1755
+ function stretchMode(data, box, scaleX, scaleY) {
1756
+ const transform = get$3();
1757
+ translate$1(transform, box.x, box.y);
1758
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
1759
+ data.transform = transform;
1760
+ }
1742
1761
 
1743
1762
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1744
1763
  const transform = get$3();
@@ -1755,8 +1774,11 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, c
1755
1774
  const transform = get$3();
1756
1775
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1757
1776
  if (clipScaleX) {
1758
- tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
1759
- multiplyParent(transform, tempMatrix$1);
1777
+ if (rotation || skew) {
1778
+ set(tempMatrix$1);
1779
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
1780
+ multiplyParent(transform, tempMatrix$1);
1781
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
1760
1782
  }
1761
1783
  data.transform = transform;
1762
1784
  }
@@ -1852,7 +1874,10 @@ function getPatternData(paint, box, image) {
1852
1874
  if (offset) PointHelper.move(tempImage, offset);
1853
1875
  switch (mode) {
1854
1876
  case "stretch":
1855
- if (!sameBox) width = box.width, height = box.height;
1877
+ if (!sameBox) {
1878
+ scaleX = box.width / width, scaleY = box.height / height;
1879
+ stretchMode(data, box, scaleX, scaleY);
1880
+ }
1856
1881
  break;
1857
1882
 
1858
1883
  case "normal":
@@ -1861,7 +1886,7 @@ function getPatternData(paint, box, image) {
1861
1886
  let clipScaleX, clipScaleY;
1862
1887
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
1863
1888
  clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
1864
- if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1889
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1865
1890
  }
1866
1891
  break;
1867
1892
 
@@ -1878,17 +1903,14 @@ function getPatternData(paint, box, image) {
1878
1903
  if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1879
1904
  }
1880
1905
  if (!data.transform) {
1881
- if (box.x || box.y) {
1882
- data.transform = get$2();
1883
- translate(data.transform, box.x, box.y);
1884
- }
1906
+ if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
1885
1907
  }
1886
- if (scaleX && mode !== "stretch") {
1908
+ data.width = width;
1909
+ data.height = height;
1910
+ if (scaleX) {
1887
1911
  data.scaleX = scaleX;
1888
1912
  data.scaleY = scaleY;
1889
1913
  }
1890
- data.width = width;
1891
- data.height = height;
1892
1914
  if (opacity) data.opacity = opacity;
1893
1915
  if (filters) data.filters = filters;
1894
1916
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
@@ -2020,7 +2042,7 @@ function ignoreRender(ui, value) {
2020
2042
 
2021
2043
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
2022
2044
 
2023
- const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
2045
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
2024
2046
 
2025
2047
  function createPattern(ui, paint, pixelRatio) {
2026
2048
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -2031,8 +2053,8 @@ function createPattern(ui, paint, pixelRatio) {
2031
2053
  scaleX *= pixelRatio;
2032
2054
  scaleY *= pixelRatio;
2033
2055
  if (sx) {
2034
- sx = abs(sx);
2035
- sy = abs(sy);
2056
+ sx = abs$1(sx);
2057
+ sy = abs$1(sy);
2036
2058
  imageMatrix = get$1();
2037
2059
  copy$1(imageMatrix, transform);
2038
2060
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -2207,6 +2229,7 @@ const PaintImageModule = {
2207
2229
  recycleImage: recycleImage,
2208
2230
  createData: createData,
2209
2231
  getPatternData: getPatternData,
2232
+ stretchMode: stretchMode,
2210
2233
  fillOrFitMode: fillOrFitMode,
2211
2234
  clipMode: clipMode,
2212
2235
  repeatMode: repeatMode
@@ -2317,7 +2340,7 @@ const PaintGradientModule = {
2317
2340
  getTransform: getTransform
2318
2341
  };
2319
2342
 
2320
- const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
2343
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max, abs: abs} = Math;
2321
2344
 
2322
2345
  const tempBounds = {}, tempMatrix = new Matrix;
2323
2346
 
@@ -2361,7 +2384,7 @@ function shadow(ui, current, shape) {
2361
2384
  function getShadowRenderSpread(_ui, shadow) {
2362
2385
  let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
2363
2386
  shadow.forEach(item => {
2364
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
2387
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs(item.spread || 0);
2365
2388
  top = max(top, spread + blur - y);
2366
2389
  right = max(right, spread + blur + x);
2367
2390
  bottom = max(bottom, spread + blur + y);
@@ -2372,11 +2395,11 @@ function getShadowRenderSpread(_ui, shadow) {
2372
2395
 
2373
2396
  function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
2374
2397
  if (shadow.spread) {
2375
- const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
2398
+ const spread = shadow.spread * 2 * otherScale * (isInnerShaodw ? -1 : 1), {width: width, height: height} = ui.__layout.strokeBounds;
2376
2399
  tempMatrix.set().scaleOfOuter({
2377
2400
  x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
2378
2401
  y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
2379
- }, spreadScale);
2402
+ }, 1 + spread / width, 1 + spread / height);
2380
2403
  return tempMatrix;
2381
2404
  }
2382
2405
  return undefined;
@@ -1,2 +1,2 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,isUndefined as n,DataHelper as o,canvasSizeAttrs as r,ResizeEvent as a,canvasPatch as h,FileHelper as l,Creator as c,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as w,PropertyEvent as _,LeafHelper as m,BranchHelper as v,LeafBoundsHelper as y,Bounds as x,isArray as b,LeafLevelList as B,LayoutEvent as S,Run as k,ImageManager as L,BoundsHelper as E,Plugin as T,MathHelper as R,isObject as P,FourNumberHelper as C,Matrix as M,getMatrixData as A,MatrixHelper as O,AlignHelper as D,PointHelper as W,ImageEvent as I,AroundHelper as F,Direction4 as z,isNumber as j}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as G,Cursor as Y,HitCanvasManager as V}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as X,Paint as H,ColorConvert as N,PaintGradient as q,Export as K,Effect as Q,Group as $,TextConvert as Z}from"@leafer-ui/draw";const J=t.get("LeaferCanvas");class tt extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else J.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;if(this.unreal){const{config:t,autoWidthStr:e,autoHeightStr:i}=this;t.width?(n(e)&&(this.autoWidthStr=s.width||""),s.width=t.width+"px"):n(e)||(s.width=e),t.height?(n(i)&&(this.autoHeightStr=s.height||""),s.height=t.height+"px"):n(i)||(s.height=i)}else s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),J.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};o.copyAttrs(e,this,r),this.resize(t),this.resizeListener&&!n(this.width)&&this.resizeListener(new a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype);const{mineType:et,fileType:it}=l;function st(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=et(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,et(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(et(it(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new tt(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),nt.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):nt.indexOf("Mac")>-1?i.os="Mac":nt.indexOf("Linux")>-1&&(i.os="Linux");class ot{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;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 f,this.target=t,e&&(this.config=o.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(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.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 w(w.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[_.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[w.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:rt,updateBounds:at,updateChange:ht}=m,{pushAllChildBranch:lt,pushAllParent:ct}=v;const{worldBounds:dt}=y;class ut{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,dt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,dt),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:ft,updateAllChange:pt}=m,gt=t.get("Layouter");class wt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new B,this.target=t,e&&(this.config=o.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(S.START),this.layoutOnce(),t.emitEvent(new S(S.END,this.layoutedBlocks,this.times))}catch(t){gt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gt.warn("layouting"):this.times>3?gt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(w.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=k.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=S,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new S(n,a,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?(rt(t,!0),e.add(t),t.isBranch&&lt(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(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||at(s[t])}at(i)}})}(this.__levelList),function(t){t.list.forEach(ht)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new S(o,a,this.times)),i.emitEvent(new S(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,k.end(e)}fullLayout(){const t=k.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=S,o=this.getBlocks(new f(e));e.emitEvent(new S(i,o,this.times)),wt.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new S(s,o,this.times)),e.emitEvent(new S(n,o,this.times)),this.addBlocks(o),k.end(t)}static fullLayout(t){ft(t,!0),t.isBranch?v.updateBounds(t):m.updateBounds(t),pt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ut([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ut(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[S.REQUEST,this.layout,this],[S.AGAIN,this.layoutAgain,this],[w.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const _t=t.get("Renderer");class mt{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:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=o.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(S.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,_t.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),L.clearRecycled()}catch(t){this.rendering=!1,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=k.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(mt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),k.end(e)}fullRender(){const t=k.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),k.end(t)}__render(e,s){const{canvas:n}=this,o=e.includes(this.target.__world),r=o?{includes:o}:{bounds:e,includes:o};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),i.render(this.target,n,r),this.renderBounds=s=s||e,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),n.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(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 x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||_t.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 p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[S.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}mt.clipSpread=10;const{hitRadiusPoint:vt}=E;class yt{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 f(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new f;if(t.length){let e;const{x:n,y:o}=this.point,r={x:n,y:o,radiusX:0,radiusY:0};for(let n=0,o=t.length;n<o;n++)if(e=t[n],(i||m.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&m.hasParent(t,e))){s.reset();break}return s.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),s.length)return s.list[0];return i?t[0]:t.find(t=>m.worldHittable(t))}getPath(t){const e=new f;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new f;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;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||vt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class xt{constructor(t,e){this.config={},e&&(this.config=o.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=c.finder&&c.finder()}getByPoint(t,e,s){const{target:n,picker:o}=this;return i.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,e,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):T.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(c,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new wt(t,e),renderer:(t,e,i)=>new mt(t,e,i),selector:(t,e)=>new xt(t,e)}),i.layout=wt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const bt={convert(t,e){const i=U.getBase(t),{x:s,y:n}=e,o=Object.assign(Object.assign({},i),{x:s,y:n,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===o.pointerType&&(o.tangentialPressure=t.tangentialPressure,o.tiltX=t.tiltX,o.tiltY=t.tiltY,o.twist=t.twist),o},convertMouse(t,e){const i=U.getBase(t),{x:s,y:n}=e;return Object.assign(Object.assign({},i),{x:s,y:n,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=bt.getTouch(t),s=U.getBase(t),{x:n,y:o}=e;return Object.assign(Object.assign({},s),{x:n,y:o,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},Bt={convert(t){const e=U.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:St}=U;class kt extends G{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(Bt.convert(t))}onKeyUp(t){this.keyUp(Bt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(bt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(bt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=bt.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(bt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(bt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(bt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(bt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=bt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&St(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(bt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=bt.getTouch(t);this.pointerUp(bt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,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(U.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))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},U.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=U.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),P(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>P(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,b(t))t.forEach(t=>this.eachCursor(t,e,i));else{const n=s(t)&&Y.get(t);n&&i<2?this.eachCursor(n,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Lt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,o)))}}function Et(t,e){t.__.__font?Lt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,i){switch(e.__.strokeAlign){case"center":Rt(t,1,e,i);break;case"inside":Pt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Rt(t,2,e,i):Pt(t,"outside",e,i)}}function Rt(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Ct(i,s))}function Pt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Rt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Lt(i,n),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Ct(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(o){const{decorationHeight:t}=s;n.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Mt(t,e,i,s,n){let o;const r=s.__,{__hasMultiStrokeStyle:a}=r;a||n.setStroke(void 0,r.__strokeWidth*e,r);for(let h=0,l=t.length;h<l;h++)if(o=t[h],(!o.image||!X.checkImage(s,n,o,!1))&&o.style){if(a){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.blendMode?(n.saveBlendMode(o.blendMode),i?Ct(s,n):n.stroke(),n.restoreBlendMode()):i?Ct(s,n):n.stroke()}}function At(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Tt(t,e,i);else switch(s.strokeAlign){case"center":Ot(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Ot(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Ot(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),Ot(t,2,e,o),o.clipUI(s),o.clearWorld(n),m.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i)}}function Ot(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&H.strokeArrow(t,i,s)}const{getSpread:Dt,copyAndSpread:Wt,toOuterOf:It,getOuterOf:Ft,getByMove:zt,move:jt,getIntersectData:Ut}=E,Gt={};let Yt;const{stintSet:Vt}=o,{hasTransparent:Xt}=N;function Ht(t,e,i){if(!P(e)||!1===e.visible||0===e.opacity)return;let o;const{boxBounds:r}=i.__layout;switch(e.type){case"image":o=X.image(i,t,e,r,!Yt||!Yt[e.url]);break;case"linear":o=q.linearGradient(e,r);break;case"radial":o=q.radialGradient(e,r);break;case"angular":o=q.conicGradient(e,r);break;case"solid":const{type:s,color:a,opacity:h}=e;o={type:s,style:N.string(a,h)};break;default:n(e.r)||(o={type:"solid",style:N.string(e)})}if(o){if(s(o.style)&&Xt(o.style)&&(o.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;o.strokeStyle=e.style}e.editing&&(o.editing=e.editing),e.blendMode&&(o.blendMode=e.blendMode)}return o}const Nt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),Yt=X.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Ht(t,a[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),o=!0),"fill"===t?(Vt(i,"__isAlphaPixelFill",n),Vt(i,"__isTransparentFill",o)):(Vt(i,"__isAlphaPixelStroke",n),Vt(i,"__isTransparentStroke",o),Vt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,Et(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(X.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),Et(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Et(e,i),i.restoreBlendMode()):Et(e,i)}},fillPathOrText:Et,fillText:Lt,stroke:At,strokes:function(t,e,i){At(t,e,i)},strokeText:Tt,drawTextStroke:Ct,shape:function(t,e,s){const n=e.getSameCanvas(),o=e.bounds,r=t.__nowWorld,a=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let l,c,d,u,f,p;It(a.strokeSpread?(Wt(Gt,a.boxBounds,a.strokeSpread),Gt):a.boxBounds,r,h);let{scaleX:g,scaleY:w}=t.getRenderScaleData(!0);if(o.includes(h))p=n,l=f=h,c=r;else{let n;if(i.fullImageShadow)n=h;else{const t=a.renderShapeSpread?Dt(o,C.swapAndScale(a.renderShapeSpread,g,w)):o;n=Ut(t,h)}u=o.getFitMatrix(n);let{a:_,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=_,w*=m),f=Ft(h,u),l=zt(f,-u.e,-u.f),c=Ft(r,u),jt(c,-u.e,-u.f);const v=s.matrix;v?(d=new M(u),d.multiply(v),_*=v.scaleX,m*=v.scaleY):d=u,d.withScale(_,m),s=Object.assign(Object.assign({},s),{matrix:d})}return t.__renderShape(n,s),{canvas:n,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:w}}};let qt={},Kt=A();const{get:Qt,rotateOfOuter:$t,translate:Zt,scaleOfOuter:Jt,multiplyParent:te,scale:ee,rotate:ie,skew:se}=O;function ne(t,e,i,s,n,o,r){const a=Qt();Zt(a,e.x+i,e.y+s),ee(a,n,o),r&&$t(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function oe(t,e,i,s,n,o,r,a,h,l){const c=Qt();ae(c,e,i,s,n,o,r,a),h&&(Kt.a=h,Kt.d=l,te(c,Kt)),t.transform=c}function re(t,e,i,s,n,o,r,a,h,l,c,d){const u=Qt();if(d)ae(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)$t(u,{x:i/2,y:s/2},h);else switch(ie(u,h),h){case 90:Zt(u,s,0);break;case 180:Zt(u,i,s);break;case 270:Zt(u,0,i)}qt.x=e.x+n,qt.y=e.y+o,Zt(u,qt.x,qt.y),r&&Jt(u,qt,r,a)}t.transform=u}function ae(t,e,i,s,n,o,r,a){r&&ie(t,r),a&&se(t,a.x,a.y),n&&ee(t,n,o),Zt(t,e.x+i,e.y+s)}const{get:he,translate:le}=O,ce=new x,de={},ue={};function fe(t,e,i,s){const{changeful:n,sync:o,scaleFixed:r}=i;n&&(t.changeful=n),o&&(t.sync=o),r&&(t.scaleFixed=r),t.data=pe(i,s,e)}function pe(t,e,i){t.padding&&(e=ce.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:o}=i;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:w,filters:_}=t,m=e.width===n&&e.height===o,v={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(E.set(ue,0,0,y?o:n,y?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(R.getScaleData(c,d,i,de),x=de.scaleX,b=de.scaleY),(h||w||g)&&(x&&E.scale(ue,x,b,!0),h&&D.toPoint(h,ue,e,ue,!0,!0))):m&&!u||(x=b=E.getFitScale(e,ue,"fit"!==a),E.put(e,i,h,x,!1,ue),E.scale(ue,x,b,!0)),l&&W.move(ue,l),a){case"stretch":m||(n=e.width,o=e.height);break;case"normal":case"clip":if(ue.x||ue.y||x||p||u||f){let t,i;p&&(t=e.width/p.width,i=e.height/p.height),oe(v,e,ue.x,ue.y,x,b,u,f,t,i),t&&(x=x?x*t:x,b=b?b*i:i)}break;case"repeat":(!m||x||u||f)&&re(v,e,n,o,ue.x,ue.y,x,b,u,f,h,t.freeTransform),g||(v.repeat="repeat");const i=P(g);(w||i)&&(v.gap=function(t,e,i,s,n){let o,r;P(t)?(o=t.x,r=t.y):o=r=t;return{x:ge(o,i,n.width,e&&e.x),y:ge(r,s,n.height,e&&e.y)}}(w,i&&g,ue.width,ue.height,e));break;default:x&&ne(v,e,ue.x,ue.y,x,b,u)}return v.transform||(e.x||e.y)&&(v.transform=he(),le(v.transform,e.x,e.y)),x&&"stretch"!==a&&(v.scaleX=x,v.scaleY=b),v.width=n,v.height=o,r&&(v.opacity=r),_&&(v.filters=_),g&&(v.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),v}function ge(t,e,i,n){const o=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&o<0?0:o}let we,_e=new x;const{isSame:me}=E;function ve(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||fe(n,s,i,o),!0}function ye(t,e){Be(t,I.LOAD,e)}function xe(t,e){Be(t,I.LOADED,e)}function be(t,e,i){e.error=i,t.forceUpdate("surface"),Be(t,I.ERROR,e)}function Be(t,e,i){t.hasEvent(e)&&t.emitEvent(new I(e,i))}function Se(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ke,scale:Le,copy:Ee}=O,{floor:Te,ceil:Re,max:Pe,abs:Ce}=Math;function Me(t,e,s){let{scaleX:n,scaleY:o}=t.getRenderScaleData(!0,e.scaleFixed);const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{const{image:a,data:h}=e;let l,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:w,gap:_}=h;n*=s,o*=s,f&&(f=Ce(f),p=Ce(p),c=ke(),Ee(c,g),Le(c,1/f,1/p),n*=f,o*=p),d*=n,u*=o;const m=d*u;if(!w&&m>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(a.isSVG){const t=d/a.width;t>1&&(l=t/Re(t))}else{const t=a.width*a.height;v>t&&(v=t)}m>v&&(l=Math.sqrt(m/v)),l&&(n/=l,o/=l,d/=l,u/=l),f&&(n/=f,o/=p);const y=_&&_.x*n,x=_&&_.y*o;if(g||1!==n||1!==o){const t=d+(y||0),e=u+(x||0);n/=t/Pe(Te(t),1),o/=e/Pe(Te(e),1),c||(c=ke(),g&&Ee(c,g)),Le(c,1/n,1/o)}const b=a.getCanvas(d,u,h.opacity,h.filters,y,x,t.leafer&&t.leafer.config.smooth),B=a.getPattern(b,w||i.origin.noRepeat||"no-repeat",c,e);return e.style=B,e.patternId=r,!0}}function Ae(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Oe={image:function(t,e,i,s,n){let o,r;const a=L.get(i);return we&&i===we.paint&&me(s,we.boxBounds)?o=we.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),we=a.use>1?{leafPaint:o,paint:i,boxBounds:_e.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(ve(t,e,i,a,o,s),n&&(ye(t,r),xe(t,r))):a.error?n&&be(t,r,a.error):(n&&(Se(t,!0),ye(t,r)),o.loadId=a.load(()=>{Se(t,!1),t.destroyed||(ve(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),xe(t,r)),o.loadId=void 0},e=>{Se(t,!1),be(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:h}=e,{data:l}=s;if(!l||s.patternId===o+"-"+r+"-"+h&&!K.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&a.isResizing(t)||K.running)){let{width:t,height:e}=l;t*=o*h,e*=r*h,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,l),!0):(!s.style||s.sync||K.running?Me(t,s,h):s.patternTask||(s.patternTask=L.patternTasker.add(()=>Ae(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&Me(t,s,h),t.forceUpdate("surface")}),300)),!1)},createPattern:Me,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,L.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],b(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createData:fe,getPatternData:pe,fillOrFitMode:ne,clipMode:oe,repeatMode:re},{toPoint:De}=F,{hasTransparent:We}=N,Ie={},Fe={};function ze(t,e,i,n){if(i){let o,r,a,h;for(let t=0,l=i.length;t<l;t++)o=i[t],s(o)?(a=t/(l-1),r=N.string(o,n)):(a=o.offset,r=N.string(o.color,n)),e.addColorStop(a,r),!h&&We(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:je,getDistance:Ue}=W,{get:Ge,rotateOfOuter:Ye,scaleOfOuter:Ve}=O,{toPoint:Xe}=F,He={},Ne={};function qe(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=je(e,i);o=Ge(),n?(Ve(o,e,r/a*(s||1),1),Ye(o,e,t+90)):(Ve(o,e,1,r/a*(s||1)),Ye(o,e,t))}return o}const{getDistance:Ke}=W,{toPoint:Qe}=F,$e={},Ze={};const Je={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;De(s||"top",e,Ie),De(n||"bottom",e,Fe);const a=i.canvas.createLinearGradient(Ie.x,Ie.y,Fe.x,Fe.y),h={type:o,style:a};return ze(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Xe(s||"center",e,He),Xe(n||"bottom",e,Ne);const h=i.canvas.createRadialGradient(He.x,He.y,0,He.x,He.y,Ue(He,Ne)),l={type:o,style:h};ze(l,h,t.stops,r);const c=qe(e,He,Ne,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Qe(s||"center",e,$e),Qe(n||"bottom",e,Ze);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,$e.x,$e.y):i.canvas.createRadialGradient($e.x,$e.y,0,$e.x,$e.y,Ke($e,Ze)),l={type:o,style:h};ze(l,h,t.stops,r);const c=qe(e,$e,Ze,a||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:qe},{copy:ti,move:ei,toOffsetOutBounds:ii}=E,{max:si}=Math,ni={},oi=new M,ri={};function ai(t,e){let i,s,n,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=t.spread||0,o=1.5*(t.blur||0),r=si(r,n+o-s),a=si(a,n+o+i),h=si(h,n+o+s),l=si(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function hi(t,e,s){const{shapeBounds:n}=s;let o,r;i.fullImageShadow?(ti(ni,t.bounds),ei(ni,e.x-n.x,e.y-n.y),o=t.bounds,r=ni):(o=n,r=e),t.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:li}=E,ci={};const di=ai;const ui={shadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ii(h,ri,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.setWorldShadow(ri.offsetX+(r.x||0)*d*w,ri.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w,N.string(r.color)),n=Q.getShadowTransform(t,f,i,r,ri,w),n&&f.setTransform(n),hi(f,ri,i),n&&f.resetTransform(),s=l,r.box&&(f.restore(),f.save(),a&&(f.copyWorld(f,l,o,"copy"),s=o),a?f.copyWorld(a,o,o,"destination-out"):f.copyWorld(i.canvas,c,h,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;li(h,ci,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.save(),f.setWorldShadow(ci.offsetX+(r.x||0)*d*w,ci.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w),n=Q.getShadowTransform(t,f,i,r,ci,w,!0),n&&f.setTransform(n),hi(f,ci,i),f.restore(),a?(f.copyWorld(f,l,o,"copy"),f.copyWorld(a,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,h,"source-out"),s=l),f.fillWorld(s,N.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),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){},getShadowRenderSpread:ai,getShadowTransform:function(t,e,i,s,n,o,r){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*o*(r?-1:1);return oi.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),oi}},isTransformShadow(t){},getInnerShadowSpread:di},{excludeRenderBounds:fi}=y;let pi;function gi(t,e,i,s,n,o,r,a){switch(e){case"grayscale":pi||(pi=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);_i(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":_i(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function wi(t){return t.getSameCanvas(!1,!0)}function _i(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r)}$.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(gi(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||fi(i,e)||i.__render(t,e),o=i.__.opacity,pi=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=wi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=wi(t)),n||(n=wi(t)),i.__render(s,e));continue}const c=1===o&&i.__.__blendMode;c&&gi(this,r,t,n,s,o,void 0,!1),fi(i,e)||i.__render(n||t,e),c&&gi(this,r,t,n,s,o,c,!1)}gi(this,r,t,n,s,o,void 0,!0)};const mi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",vi=mi+"_#~&*+\\=|≮≯≈≠=…",yi=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 xi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const bi=xi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Bi=xi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Si=xi(mi),ki=xi(vi),Li=xi("- —/~|┆·");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:Ti,Single:Ri,Before:Pi,After:Ci,Symbol:Mi,Break:Ai}=Ei;function Oi(t){return bi[t]?Ti:Li[t]?Ai:Bi[t]?Pi:Si[t]?Ci:ki[t]?Mi:yi.test(t)?Ri:Ti}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 Wi(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:Ii}=Di,{Letter:Fi,Single:zi,Before:ji,After:Ui,Symbol:Gi,Break:Yi}=Ei;let Vi,Xi,Hi,Ni,qi,Ki,Qi,$i,Zi,Ji,ts,es,is,ss,ns,os,rs,as=[];function hs(t,e){Zi&&!$i&&($i=Zi),Vi.data.push({char:t,width:e}),Hi+=e}function ls(){Ni+=Hi,Vi.width=Hi,Xi.words.push(Vi),Vi={data:[]},Hi=0}function cs(){ss&&(ns.paraNumber++,Xi.paraStart=!0,ss=!1),Zi&&(Xi.startCharSize=$i,Xi.endCharSize=Zi,$i=0),Xi.width=Ni,os.width?Ii(Xi):rs&&ds(),as.push(Xi),Xi={words:[]},Ni=0}function ds(){Ni>(ns.maxWidth||0)&&(ns.maxWidth=Ni)}const{top:us,right:fs,bottom:ps,left:gs}=z;function ws(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 _s={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,o=0,r=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=e;c&&(r?(n=c[gs],r-=c[fs]+c[gs]):e.autoSizeAlign||(n=c[gs]),a?(o=c[us],a-=c[us]+c[ps]):e.autoSizeAlign||(o=c[us]));const d={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:i.canvas.font=l};return function(t,e,s){ns=t,as=t.rows,os=t.bounds,rs=!os.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=os;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;ss=!0,ts=null,$i=Qi=Zi=Hi=Ni=0,Vi={data:[]},Xi={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)Ki=e[s],"\n"===Ki?(Hi&&ls(),Xi.paraEnd=!0,cs(),ss=!0):(Ji=Oi(Ki),Ji===Fi&&"none"!==r&&(Ki=Wi(Ki,r,!Hi)),Qi=a.measureText(Ki).width,n&&(n<0&&(Zi=Qi),Qi+=n),es=Ji===zi&&(ts===zi||ts===Fi)||ts===zi&&Ji!==Ui,is=!(Ji!==ji&&Ji!==zi||ts!==Gi&&ts!==Ui),qi=ss&&o?h-o:h,t&&h&&Ni+Hi+Qi>qi&&(i?(Hi&&ls(),Ni&&cs()):(is||(is=Ji===Fi&&ts==Ui),es||is||Ji===Yi||Ji===ji||Ji===zi||Hi+Qi>qi?(Hi&&ls(),Ni&&cs()):Ni&&cs()))," "===Ki&&!0!==ss&&Ni+Hi===0||(Ji===Yi?(" "===Ki&&Hi&&ls(),hs(Ki,Qi),ls()):es||is?(Hi&&ls(),hs(Ki,Qi)):hs(Ki,Qi)),ts=Ji);Hi&&ls(),Ni&&cs(),as.length>0&&(as[as.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{ns.paraNumber++,Ni=a.measureText(t).width,as.push({x:o||0,text:t,width:Ni,paraStart:!0}),rs&&ds()})}(d,t,e),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ws(e,"x",t[gs]);break;case"right":ws(e,"x",-t[fs])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ws(e,"y",t[us]);break;case"bottom":ws(e,"y",-t[ps])}}(c,d,e,r,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:w}=s,_=o*n+(d?d*(t.paraNumber-1):0),m=r;if(h&&_>w)_=Math.max(w,o),n>1&&(t.overflow=n);else if(w||u)switch(c){case"middle":p+=(w-_)/2;break;case"bottom":p+=w-_}m+=p;let v,y,x,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(v=i[r],v.x=f,v.width<g||v.width>g&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&d&&r>0&&(m+=d),v.y=m,m+=o,t.overflow>r&&m>_&&(v.isOverflow=!0,t.overflow=r+1),y=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<s.x&&(s.x=y),x>s.width&&(s.width=x),h&&g&&g<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(d,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;s.forEach(t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(d,e,r),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,e,n,r),"none"!==h&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,P(o)?(i=o.type,o.color&&(t.decorationColor=N.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(d,e),d}};const ms={string:function(t,e){if(!t)return"#000";const i=j(e)&&e<1;if(s(t)){if(!i||!N.object)return t;t=N.object(t)}let o=n(t.a)?1:t.a;i&&(o*=e);const r=t.r+","+t.g+","+t.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign(Z,_s),Object.assign(N,ms),Object.assign(H,Nt),Object.assign(X,Oe),Object.assign(q,Je),Object.assign(Q,ui),Object.assign(c,{interaction:(t,e,i,s)=>new kt(t,e,i,s),hitCanvas:(t,e)=>new tt(t,e),hitCanvasManager:()=>new V}),st();export{kt as Interaction,wt as Layouter,tt as LeaferCanvas,yt as Picker,mt as Renderer,xt as Selector,ot as Watcher,st as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,isUndefined as n,DataHelper as o,canvasSizeAttrs as r,ResizeEvent as a,canvasPatch as h,FileHelper as l,Creator as c,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as w,PropertyEvent as _,LeafHelper as m,BranchHelper as v,LeafBoundsHelper as y,Bounds as x,isArray as b,LeafLevelList as B,LayoutEvent as S,Run as k,ImageManager as E,BoundsHelper as L,Plugin as T,MathHelper as R,isObject as P,FourNumberHelper as M,Matrix as C,getMatrixData as A,MatrixHelper as O,AlignHelper as D,PointHelper as W,ImageEvent as I,AroundHelper as F,Direction4 as z,isNumber as j}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as G,Cursor as Y,HitCanvasManager as V}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as X,Paint as H,ColorConvert as N,PaintGradient as q,Export as K,Effect as Q,Group as $,TextConvert as Z}from"@leafer-ui/draw";const J=t.get("LeaferCanvas");class tt extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else J.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;if(this.unreal){const{config:t,autoWidthStr:e,autoHeightStr:i}=this;t.width?(n(e)&&(this.autoWidthStr=s.width||""),s.width=t.width+"px"):n(e)||(s.width=e),t.height?(n(i)&&(this.autoHeightStr=s.height||""),s.height=t.height+"px"):n(i)||(s.height=i)}else s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),J.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};o.copyAttrs(e,this,r),this.resize(t),this.resizeListener&&!n(this.width)&&this.resizeListener(new a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype);const{mineType:et,fileType:it}=l;function st(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=et(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,et(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(et(it(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new tt(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),nt.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):nt.indexOf("Mac")>-1?i.os="Mac":nt.indexOf("Linux")>-1&&(i.os="Linux");class ot{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;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 f,this.target=t,e&&(this.config=o.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(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.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 w(w.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[_.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[w.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:rt,updateBounds:at,updateChange:ht}=m,{pushAllChildBranch:lt,pushAllParent:ct}=v;const{worldBounds:dt}=y;class ut{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,dt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,dt),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:ft,updateAllChange:pt}=m,gt=t.get("Layouter");class wt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new B,this.target=t,e&&(this.config=o.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(S.START),this.layoutOnce(),t.emitEvent(new S(S.END,this.layoutedBlocks,this.times))}catch(t){gt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gt.warn("layouting"):this.times>3?gt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(w.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=k.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=S,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new S(n,a,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?(rt(t,!0),e.add(t),t.isBranch&&lt(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(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||at(s[t])}at(i)}})}(this.__levelList),function(t){t.list.forEach(ht)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new S(o,a,this.times)),i.emitEvent(new S(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,k.end(e)}fullLayout(){const t=k.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=S,o=this.getBlocks(new f(e));e.emitEvent(new S(i,o,this.times)),wt.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new S(s,o,this.times)),e.emitEvent(new S(n,o,this.times)),this.addBlocks(o),k.end(t)}static fullLayout(t){ft(t,!0),t.isBranch?v.updateBounds(t):m.updateBounds(t),pt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ut([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ut(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[S.REQUEST,this.layout,this],[S.AGAIN,this.layoutAgain,this],[w.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const _t=t.get("Renderer");class mt{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:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=o.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(S.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,_t.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=k.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(mt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),k.end(e)}fullRender(){const t=k.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),k.end(t)}__render(e,s){const{canvas:n}=this,o=e.includes(this.target.__world),r=o?{includes:o}:{bounds:e,includes:o};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),i.render(this.target,n,r),this.renderBounds=s=s||e,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),n.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(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 x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||_t.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 p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[S.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}mt.clipSpread=10;const{hitRadiusPoint:vt}=L;class yt{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 f(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new f;if(t.length){let e;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=t.length;s<o;s++)if(e=t[s],(i||m.worldHittable(e))&&(this.hitChild(e,r),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&m.hasParent(t,e))){n.reset();break}return n.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),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>m.worldHittable(t))}getPath(t){const e=new f,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new f;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;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||vt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class xt{constructor(t,e){this.config={},e&&(this.config=o.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=c.finder&&c.finder()}getByPoint(t,e,s){const{target:n,picker:o}=this;return i.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,e,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):T.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(c,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new wt(t,e),renderer:(t,e,i)=>new mt(t,e,i),selector:(t,e)=>new xt(t,e)}),i.layout=wt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const bt={convert(t,e){const i=U.getBase(t),{x:s,y:n}=e,o=Object.assign(Object.assign({},i),{x:s,y:n,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===o.pointerType&&(o.tangentialPressure=t.tangentialPressure,o.tiltX=t.tiltX,o.tiltY=t.tiltY,o.twist=t.twist),o},convertMouse(t,e){const i=U.getBase(t),{x:s,y:n}=e;return Object.assign(Object.assign({},i),{x:s,y:n,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=bt.getTouch(t),s=U.getBase(t),{x:n,y:o}=e;return Object.assign(Object.assign({},s),{x:n,y:o,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},Bt={convert(t){const e=U.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:St}=U;class kt extends G{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(Bt.convert(t))}onKeyUp(t){this.keyUp(Bt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(bt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(bt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=bt.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(bt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(bt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(bt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(bt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=bt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&St(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(bt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=bt.getTouch(t);this.pointerUp(bt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,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(U.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))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},U.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=U.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),P(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>P(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,b(t))t.forEach(t=>this.eachCursor(t,e,i));else{const n=s(t)&&Y.get(t);n&&i<2?this.eachCursor(n,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Et(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,o)))}}function Lt(t,e){t.__.__font?Et(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,i){switch(e.__.strokeAlign){case"center":Rt(t,1,e,i);break;case"inside":Pt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Rt(t,2,e,i):Pt(t,"outside",e,i)}}function Rt(t,e,i,s){const n=i.__;P(t)?Ct(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Mt(i,s))}function Pt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Rt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Et(i,n),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Mt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(o){const{decorationHeight:t}=s;n.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Ct(t,e,i,s,n){let o;const r=s.__,{__hasMultiStrokeStyle:a}=r;a||n.setStroke(void 0,r.__strokeWidth*e,r);for(let h=0,l=t.length;h<l;h++)if(o=t[h],(!o.image||!X.checkImage(s,n,o,!1))&&o.style){if(a){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.blendMode?(n.saveBlendMode(o.blendMode),i?Mt(s,n):n.stroke(),n.restoreBlendMode()):i?Mt(s,n):n.stroke()}}function At(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Tt(t,e,i);else switch(s.strokeAlign){case"center":Ot(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Ot(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Ot(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),Ot(t,2,e,o),o.clipUI(s),o.clearWorld(n),m.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i)}}function Ot(t,e,i,s){const n=i.__;P(t)?Ct(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&H.strokeArrow(t,i,s)}const{getSpread:Dt,copyAndSpread:Wt,toOuterOf:It,getOuterOf:Ft,getByMove:zt,move:jt,getIntersectData:Ut}=L,Gt={};let Yt;const{stintSet:Vt}=o,{hasTransparent:Xt}=N;function Ht(t,e,i){if(!P(e)||!1===e.visible||0===e.opacity)return;let o;const{boxBounds:r}=i.__layout;switch(e.type){case"image":o=X.image(i,t,e,r,!Yt||!Yt[e.url]);break;case"linear":o=q.linearGradient(e,r);break;case"radial":o=q.radialGradient(e,r);break;case"angular":o=q.conicGradient(e,r);break;case"solid":const{type:s,color:a,opacity:h}=e;o={type:s,style:N.string(a,h)};break;default:n(e.r)||(o={type:"solid",style:N.string(e)})}if(o){if(s(o.style)&&Xt(o.style)&&(o.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;o.strokeStyle=e.style}e.editing&&(o.editing=e.editing),e.blendMode&&(o.blendMode=e.blendMode)}return o}const Nt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),Yt=X.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Ht(t,a[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),o=!0),"fill"===t?(Vt(i,"__isAlphaPixelFill",n),Vt(i,"__isTransparentFill",o)):(Vt(i,"__isAlphaPixelStroke",n),Vt(i,"__isTransparentStroke",o),Vt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,Lt(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(X.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),Lt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Lt(e,i),i.restoreBlendMode()):Lt(e,i)}},fillPathOrText:Lt,fillText:Et,stroke:At,strokes:function(t,e,i){At(t,e,i)},strokeText:Tt,drawTextStroke:Mt,shape:function(t,e,s){const n=e.getSameCanvas(),o=e.bounds,r=t.__nowWorld,a=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let l,c,d,u,f,p;It(a.strokeSpread?(Wt(Gt,a.boxBounds,a.strokeSpread),Gt):a.boxBounds,r,h);let{scaleX:g,scaleY:w}=t.getRenderScaleData(!0);if(o.includes(h))p=n,l=f=h,c=r;else{let n;if(i.fullImageShadow)n=h;else{const t=a.renderShapeSpread?Dt(o,M.swapAndScale(a.renderShapeSpread,g,w)):o;n=Ut(t,h)}u=o.getFitMatrix(n);let{a:_,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=_,w*=m),f=Ft(h,u),l=zt(f,-u.e,-u.f),c=Ft(r,u),jt(c,-u.e,-u.f);const v=s.matrix;v?(d=new C(u),d.multiply(v),_*=v.scaleX,m*=v.scaleY):d=u,d.withScale(_,m),s=Object.assign(Object.assign({},s),{matrix:d})}return t.__renderShape(n,s),{canvas:n,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:w}}};let qt={},Kt=A();const{get:Qt,set:$t,rotateOfOuter:Zt,translate:Jt,scaleOfOuter:te,multiplyParent:ee,scale:ie,rotate:se,skew:ne}=O;function oe(t,e,i,s){const n=Qt();Jt(n,e.x,e.y),i&&ie(n,i,s),t.transform=n}function re(t,e,i,s,n,o,r){const a=Qt();Jt(a,e.x+i,e.y+s),ie(a,n,o),r&&Zt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function ae(t,e,i,s,n,o,r,a,h,l){const c=Qt();le(c,e,i,s,n,o,r,a),h&&(r||a?($t(Kt),te(Kt,e,h,l),ee(c,Kt)):te(c,e,h,l)),t.transform=c}function he(t,e,i,s,n,o,r,a,h,l,c,d){const u=Qt();if(d)le(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)Zt(u,{x:i/2,y:s/2},h);else switch(se(u,h),h){case 90:Jt(u,s,0);break;case 180:Jt(u,i,s);break;case 270:Jt(u,0,i)}qt.x=e.x+n,qt.y=e.y+o,Jt(u,qt.x,qt.y),r&&te(u,qt,r,a)}t.transform=u}function le(t,e,i,s,n,o,r,a){r&&se(t,r),a&&ne(t,a.x,a.y),n&&ie(t,n,o),Jt(t,e.x+i,e.y+s)}const{get:ce,translate:de}=O,ue=new x,fe={},pe={};function ge(t,e,i,s){const{changeful:n,sync:o,scaleFixed:r}=i;n&&(t.changeful=n),o&&(t.sync=o),r&&(t.scaleFixed=r),t.data=we(i,s,e)}function we(t,e,i){t.padding&&(e=ue.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:o}=i;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:w,filters:_}=t,m=e.width===n&&e.height===o,v={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(L.set(pe,0,0,y?o:n,y?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(R.getScaleData(c,d,i,fe),x=fe.scaleX,b=fe.scaleY),(h||w||g)&&(x&&L.scale(pe,x,b,!0),h&&D.toPoint(h,pe,e,pe,!0,!0))):m&&!u||(x=b=L.getFitScale(e,pe,"fit"!==a),L.put(e,i,h,x,!1,pe),L.scale(pe,x,b,!0)),l&&W.move(pe,l),a){case"stretch":m||(x=e.width/n,b=e.height/o,oe(v,e,x,b));break;case"normal":case"clip":if(pe.x||pe.y||x||p||u||f){let t,i;p&&(t=e.width/p.width,i=e.height/p.height),ae(v,e,pe.x,pe.y,x,b,u,f,t,i),t&&(x=x?x*t:t,b=b?b*i:i)}break;case"repeat":(!m||x||u||f)&&he(v,e,n,o,pe.x,pe.y,x,b,u,f,h,t.freeTransform),g||(v.repeat="repeat");const i=P(g);(w||i)&&(v.gap=function(t,e,i,s,n){let o,r;P(t)?(o=t.x,r=t.y):o=r=t;return{x:_e(o,i,n.width,e&&e.x),y:_e(r,s,n.height,e&&e.y)}}(w,i&&g,pe.width,pe.height,e));break;default:x&&re(v,e,pe.x,pe.y,x,b,u)}return v.transform||(e.x||e.y)&&de(v.transform=ce(),e.x,e.y),v.width=n,v.height=o,x&&(v.scaleX=x,v.scaleY=b),r&&(v.opacity=r),_&&(v.filters=_),g&&(v.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),v}function _e(t,e,i,n){const o=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&o<0?0:o}let me,ve=new x;const{isSame:ye}=L;function xe(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||ge(n,s,i,o),!0}function be(t,e){ke(t,I.LOAD,e)}function Be(t,e){ke(t,I.LOADED,e)}function Se(t,e,i){e.error=i,t.forceUpdate("surface"),ke(t,I.ERROR,e)}function ke(t,e,i){t.hasEvent(e)&&t.emitEvent(new I(e,i))}function Ee(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Le,scale:Te,copy:Re}=O,{floor:Pe,ceil:Me,max:Ce,abs:Ae}=Math;function Oe(t,e,s){let{scaleX:n,scaleY:o}=t.getRenderScaleData(!0,e.scaleFixed);const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{const{image:a,data:h}=e;let l,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:w,gap:_}=h;n*=s,o*=s,f&&(f=Ae(f),p=Ae(p),c=Le(),Re(c,g),Te(c,1/f,1/p),n*=f,o*=p),d*=n,u*=o;const m=d*u;if(!w&&m>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(a.isSVG){const t=d/a.width;t>1&&(l=t/Me(t))}else{const t=a.width*a.height;v>t&&(v=t)}m>v&&(l=Math.sqrt(m/v)),l&&(n/=l,o/=l,d/=l,u/=l),f&&(n/=f,o/=p);const y=_&&_.x*n,x=_&&_.y*o;if(g||1!==n||1!==o){const t=d+(y||0),e=u+(x||0);n/=t/Ce(Pe(t),1),o/=e/Ce(Pe(e),1),c||(c=Le(),g&&Re(c,g)),Te(c,1/n,1/o)}const b=a.getCanvas(d,u,h.opacity,h.filters,y,x,t.leafer&&t.leafer.config.smooth),B=a.getPattern(b,w||i.origin.noRepeat||"no-repeat",c,e);return e.style=B,e.patternId=r,!0}}function De(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const We={image:function(t,e,i,s,n){let o,r;const a=E.get(i);return me&&i===me.paint&&ye(s,me.boxBounds)?o=me.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),me=a.use>1?{leafPaint:o,paint:i,boxBounds:ve.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(xe(t,e,i,a,o,s),n&&(be(t,r),Be(t,r))):a.error?n&&Se(t,r,a.error):(n&&(Ee(t,!0),be(t,r)),o.loadId=a.load(()=>{Ee(t,!1),t.destroyed||(xe(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Be(t,r)),o.loadId=void 0},e=>{Ee(t,!1),Se(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:h}=e,{data:l}=s;if(!l||s.patternId===o+"-"+r+"-"+h&&!K.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&a.isResizing(t)||K.running)){let{width:t,height:e}=l;t*=o*h,e*=r*h,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,l),!0):(!s.style||s.sync||K.running?Oe(t,s,h):s.patternTask||(s.patternTask=E.patternTasker.add(()=>De(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&Oe(t,s,h),t.forceUpdate("surface")}),300)),!1)},createPattern:Oe,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,E.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],b(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createData:ge,getPatternData:we,stretchMode:oe,fillOrFitMode:re,clipMode:ae,repeatMode:he},{toPoint:Ie}=F,{hasTransparent:Fe}=N,ze={},je={};function Ue(t,e,i,n){if(i){let o,r,a,h;for(let t=0,l=i.length;t<l;t++)o=i[t],s(o)?(a=t/(l-1),r=N.string(o,n)):(a=o.offset,r=N.string(o.color,n)),e.addColorStop(a,r),!h&&Fe(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Ge,getDistance:Ye}=W,{get:Ve,rotateOfOuter:Xe,scaleOfOuter:He}=O,{toPoint:Ne}=F,qe={},Ke={};function Qe(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Ge(e,i);o=Ve(),n?(He(o,e,r/a*(s||1),1),Xe(o,e,t+90)):(He(o,e,1,r/a*(s||1)),Xe(o,e,t))}return o}const{getDistance:$e}=W,{toPoint:Ze}=F,Je={},ti={};const ei={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;Ie(s||"top",e,ze),Ie(n||"bottom",e,je);const a=i.canvas.createLinearGradient(ze.x,ze.y,je.x,je.y),h={type:o,style:a};return Ue(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Ne(s||"center",e,qe),Ne(n||"bottom",e,Ke);const h=i.canvas.createRadialGradient(qe.x,qe.y,0,qe.x,qe.y,Ye(qe,Ke)),l={type:o,style:h};Ue(l,h,t.stops,r);const c=Qe(e,qe,Ke,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Ze(s||"center",e,Je),Ze(n||"bottom",e,ti);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,Je.x,Je.y):i.canvas.createRadialGradient(Je.x,Je.y,0,Je.x,Je.y,$e(Je,ti)),l={type:o,style:h};Ue(l,h,t.stops,r);const c=Qe(e,Je,ti,a||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Qe},{copy:ii,move:si,toOffsetOutBounds:ni}=L,{max:oi,abs:ri}=Math,ai={},hi=new C,li={};function ci(t,e){let i,s,n,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,o=1.5*(t.blur||0),n=ri(t.spread||0),r=oi(r,n+o-s),a=oi(a,n+o+i),h=oi(h,n+o+s),l=oi(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function di(t,e,s){const{shapeBounds:n}=s;let o,r;i.fullImageShadow?(ii(ai,t.bounds),si(ai,e.x-n.x,e.y-n.y),o=t.bounds,r=ai):(o=n,r=e),t.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:ui}=L,fi={};const pi=ci;const gi={shadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ni(h,li,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.setWorldShadow(li.offsetX+(r.x||0)*d*w,li.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w,N.string(r.color)),n=Q.getShadowTransform(t,f,i,r,li,w),n&&f.setTransform(n),di(f,li,i),n&&f.resetTransform(),s=l,r.box&&(f.restore(),f.save(),a&&(f.copyWorld(f,l,o,"copy"),s=o),a?f.copyWorld(a,o,o,"destination-out"):f.copyWorld(i.canvas,c,h,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ui(h,fi,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.save(),f.setWorldShadow(fi.offsetX+(r.x||0)*d*w,fi.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w),n=Q.getShadowTransform(t,f,i,r,fi,w,!0),n&&f.setTransform(n),di(f,fi,i),f.restore(),a?(f.copyWorld(f,l,o,"copy"),f.copyWorld(a,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,h,"source-out"),s=l),f.fillWorld(s,N.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),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){},getShadowRenderSpread:ci,getShadowTransform:function(t,e,i,s,n,o,r){if(s.spread){const i=2*s.spread*o*(r?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return hi.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),hi}},isTransformShadow(t){},getInnerShadowSpread:pi},{excludeRenderBounds:wi}=y;let _i;function mi(t,e,i,s,n,o,r,a){switch(e){case"grayscale":_i||(_i=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);yi(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":yi(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function vi(t){return t.getSameCanvas(!1,!0)}function yi(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r)}$.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(mi(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||wi(i,e)||i.__render(t,e),o=i.__.opacity,_i=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=vi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=vi(t)),n||(n=vi(t)),i.__render(s,e));continue}const c=1===o&&i.__.__blendMode;c&&mi(this,r,t,n,s,o,void 0,!1),wi(i,e)||i.__render(n||t,e),c&&mi(this,r,t,n,s,o,c,!1)}mi(this,r,t,n,s,o,void 0,!0)};const xi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",bi=xi+"_#~&*+\\=|≮≯≈≠=…",Bi=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 Si(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ki=Si("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ei=Si("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Li=Si(xi),Ti=Si(bi),Ri=Si("- —/~|┆·");var Pi;!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"}(Pi||(Pi={}));const{Letter:Mi,Single:Ci,Before:Ai,After:Oi,Symbol:Di,Break:Wi}=Pi;function Ii(t){return ki[t]?Mi:Ri[t]?Wi:Ei[t]?Ai:Li[t]?Oi:Ti[t]?Di:Bi.test(t)?Ci:Mi}const Fi={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 zi(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:ji}=Fi,{Letter:Ui,Single:Gi,Before:Yi,After:Vi,Symbol:Xi,Break:Hi}=Pi;let Ni,qi,Ki,Qi,$i,Zi,Ji,ts,es,is,ss,ns,os,rs,as,hs,ls,cs=[];function ds(t,e){es&&!ts&&(ts=es),Ni.data.push({char:t,width:e}),Ki+=e}function us(){Qi+=Ki,Ni.width=Ki,qi.words.push(Ni),Ni={data:[]},Ki=0}function fs(){rs&&(as.paraNumber++,qi.paraStart=!0,rs=!1),es&&(qi.startCharSize=ts,qi.endCharSize=es,ts=0),qi.width=Qi,hs.width?ji(qi):ls&&ps(),cs.push(qi),qi={words:[]},Qi=0}function ps(){Qi>(as.maxWidth||0)&&(as.maxWidth=Qi)}const{top:gs,right:ws,bottom:_s,left:ms}=z;function vs(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 ys={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,o=0,r=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=e;c&&(r?(n=c[ms],r-=c[ws]+c[ms]):e.autoSizeAlign||(n=c[ms]),a?(o=c[gs],a-=c[gs]+c[_s]):e.autoSizeAlign||(o=c[gs]));const d={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:i.canvas.font=l};return function(t,e,s){as=t,cs=t.rows,hs=t.bounds,ls=!hs.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=hs;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;rs=!0,ss=null,ts=Ji=es=Ki=Qi=0,Ni={data:[]},qi={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)Zi=e[s],"\n"===Zi?(Ki&&us(),qi.paraEnd=!0,fs(),rs=!0):(is=Ii(Zi),is===Ui&&"none"!==r&&(Zi=zi(Zi,r,!Ki)),Ji=a.measureText(Zi).width,n&&(n<0&&(es=Ji),Ji+=n),ns=is===Gi&&(ss===Gi||ss===Ui)||ss===Gi&&is!==Vi,os=!(is!==Yi&&is!==Gi||ss!==Xi&&ss!==Vi),$i=rs&&o?h-o:h,t&&h&&Qi+Ki+Ji>$i&&(i?(Ki&&us(),Qi&&fs()):(os||(os=is===Ui&&ss==Vi),ns||os||is===Hi||is===Yi||is===Gi||Ki+Ji>$i?(Ki&&us(),Qi&&fs()):Qi&&fs()))," "===Zi&&!0!==rs&&Qi+Ki===0||(is===Hi?(" "===Zi&&Ki&&us(),ds(Zi,Ji),us()):ns||os?(Ki&&us(),ds(Zi,Ji)):ds(Zi,Ji)),ss=is);Ki&&us(),Qi&&fs(),cs.length>0&&(cs[cs.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{as.paraNumber++,Qi=a.measureText(t).width,cs.push({x:o||0,text:t,width:Qi,paraStart:!0}),ls&&ps()})}(d,t,e),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":vs(e,"x",t[ms]);break;case"right":vs(e,"x",-t[ws])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":vs(e,"y",t[gs]);break;case"bottom":vs(e,"y",-t[_s])}}(c,d,e,r,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:w}=s,_=o*n+(d?d*(t.paraNumber-1):0),m=r;if(h&&_>w)_=Math.max(w,o),n>1&&(t.overflow=n);else if(w||u)switch(c){case"middle":p+=(w-_)/2;break;case"bottom":p+=w-_}m+=p;let v,y,x,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(v=i[r],v.x=f,v.width<g||v.width>g&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&d&&r>0&&(m+=d),v.y=m,m+=o,t.overflow>r&&m>_&&(v.isOverflow=!0,t.overflow=r+1),y=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<s.x&&(s.x=y),x>s.width&&(s.width=x),h&&g&&g<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(d,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;s.forEach(t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(d,e,r),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,e,n,r),"none"!==h&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,P(o)?(i=o.type,o.color&&(t.decorationColor=N.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(d,e),d}};const xs={string:function(t,e){if(!t)return"#000";const i=j(e)&&e<1;if(s(t)){if(!i||!N.object)return t;t=N.object(t)}let o=n(t.a)?1:t.a;i&&(o*=e);const r=t.r+","+t.g+","+t.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign(Z,ys),Object.assign(N,xs),Object.assign(H,Nt),Object.assign(X,We),Object.assign(q,ei),Object.assign(Q,gi),Object.assign(c,{interaction:(t,e,i,s)=>new kt(t,e,i,s),hitCanvas:(t,e)=>new tt(t,e),hitCanvasManager:()=>new V}),st();export{kt as Interaction,wt as Layouter,tt as LeaferCanvas,yt as Picker,mt as Renderer,xt as Selector,ot as Watcher,st as useCanvas};
2
2
  //# sourceMappingURL=web.esm.min.js.map