leafer-draw 1.6.3 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.cjs CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  var core = require('@leafer/core');
4
4
  var draw = require('@leafer-ui/draw');
5
- var core$1 = require('@leafer-ui/core');
6
5
 
7
6
  const debug$2 = core.Debug.get('LeaferCanvas');
8
7
  class LeaferCanvas extends core.LeaferCanvasBase {
@@ -902,8 +901,6 @@ function fillPathOrText(ui, canvas) {
902
901
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
903
902
  }
904
903
 
905
- const Paint = {};
906
-
907
904
  function strokeText(stroke, ui, canvas) {
908
905
  switch (ui.__.strokeAlign) {
909
906
  case 'center':
@@ -929,11 +926,14 @@ function drawAlign(stroke, align, ui, canvas) {
929
926
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
930
927
  fillText(ui, out);
931
928
  out.blendMode = 'normal';
932
- if (ui.__worldFlipped || core$1.Platform.fullImageShadow)
929
+ copyWorld(canvas, out, ui);
930
+ out.recycle(ui.__nowWorld);
931
+ }
932
+ function copyWorld(canvas, out, ui) {
933
+ if (ui.__worldFlipped || core.Platform.fullImageShadow)
933
934
  canvas.copyWorldByReset(out, ui.__nowWorld);
934
935
  else
935
936
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
936
- out.recycle(ui.__nowWorld);
937
937
  }
938
938
  function drawTextStroke(ui, canvas) {
939
939
  let row, data = ui.__.__textDrawData;
@@ -999,12 +999,11 @@ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
999
999
  canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
1000
1000
  data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
1001
1001
  if (data.__useArrow)
1002
- Paint.strokeArrow(stroke, ui, canvas);
1002
+ draw.Paint.strokeArrow(stroke, ui, canvas);
1003
1003
  }
1004
1004
  function drawInside(stroke, ui, canvas) {
1005
- const data = ui.__;
1006
1005
  canvas.save();
1007
- data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
1006
+ canvas.clipUI(ui);
1008
1007
  drawCenter(stroke, 2, ui, canvas);
1009
1008
  canvas.restore();
1010
1009
  }
@@ -1018,12 +1017,9 @@ function drawOutside(stroke, ui, canvas) {
1018
1017
  const out = canvas.getSameCanvas(true, true);
1019
1018
  ui.__drawRenderPath(out);
1020
1019
  drawCenter(stroke, 2, ui, out);
1021
- data.windingRule ? out.clip(data.windingRule) : out.clip();
1020
+ out.clipUI(data);
1022
1021
  out.clearWorld(renderBounds);
1023
- if (ui.__worldFlipped || core$1.Platform.fullImageShadow)
1024
- canvas.copyWorldByReset(out, ui.__nowWorld);
1025
- else
1026
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
1022
+ copyWorld(canvas, out, ui);
1027
1023
  out.recycle(ui.__nowWorld);
1028
1024
  }
1029
1025
  }
@@ -1079,9 +1075,7 @@ function compute(attrName, ui) {
1079
1075
  paints = [paints];
1080
1076
  recycleMap = draw.PaintImage.recycleImage(attrName, data);
1081
1077
  for (let i = 0, len = paints.length, item; i < len; i++) {
1082
- item = getLeafPaint(attrName, paints[i], ui);
1083
- if (item)
1084
- leafPaints.push(item);
1078
+ (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
1085
1079
  }
1086
1080
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
1087
1081
  if (leafPaints.length) {
@@ -1119,8 +1113,8 @@ function getLeafPaint(attrName, paint, ui) {
1119
1113
  data = draw.PaintGradient.conicGradient(paint, boxBounds);
1120
1114
  break;
1121
1115
  case 'solid':
1122
- const { type, blendMode, color, opacity } = paint;
1123
- data = { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
1116
+ const { type, color, opacity } = paint;
1117
+ data = { type, style: draw.ColorConvert.string(color, opacity) };
1124
1118
  break;
1125
1119
  default:
1126
1120
  if (paint.r !== undefined)
@@ -1529,7 +1523,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
1529
1523
  }
1530
1524
  function drawImage(ui, canvas, paint, data) {
1531
1525
  canvas.save();
1532
- ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
1526
+ canvas.clipUI(ui);
1533
1527
  if (paint.blendMode)
1534
1528
  canvas.blendMode = paint.blendMode;
1535
1529
  if (data.opacity)
@@ -1694,12 +1688,10 @@ function shadow(ui, current, shape) {
1694
1688
  }
1695
1689
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1696
1690
  }
1697
- if (ui.__worldFlipped) {
1691
+ if (ui.__worldFlipped)
1698
1692
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1699
- }
1700
- else {
1693
+ else
1701
1694
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
1702
- }
1703
1695
  if (end && index < end)
1704
1696
  other.clearWorld(copyBounds, true);
1705
1697
  });
@@ -1758,12 +1750,10 @@ function innerShadow(ui, current, shape) {
1758
1750
  copyBounds = bounds;
1759
1751
  }
1760
1752
  other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
1761
- if (ui.__worldFlipped) {
1753
+ if (ui.__worldFlipped)
1762
1754
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1763
- }
1764
- else {
1755
+ else
1765
1756
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
1766
- }
1767
1757
  if (end && index < end)
1768
1758
  other.clearWorld(copyBounds, true);
1769
1759
  });
package/dist/web.esm.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { Debug, LeaferCanvasBase, Platform, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
- import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint as Paint$1, Effect } from '@leafer-ui/draw';
4
+ import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect } from '@leafer-ui/draw';
5
5
  export * from '@leafer-ui/draw';
6
- import { Platform as Platform$1 } from '@leafer-ui/core';
7
6
 
8
7
  const debug$2 = Debug.get('LeaferCanvas');
9
8
  class LeaferCanvas extends LeaferCanvasBase {
@@ -903,8 +902,6 @@ function fillPathOrText(ui, canvas) {
903
902
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
904
903
  }
905
904
 
906
- const Paint = {};
907
-
908
905
  function strokeText(stroke, ui, canvas) {
909
906
  switch (ui.__.strokeAlign) {
910
907
  case 'center':
@@ -930,11 +927,14 @@ function drawAlign(stroke, align, ui, canvas) {
930
927
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
931
928
  fillText(ui, out);
932
929
  out.blendMode = 'normal';
933
- if (ui.__worldFlipped || Platform$1.fullImageShadow)
930
+ copyWorld(canvas, out, ui);
931
+ out.recycle(ui.__nowWorld);
932
+ }
933
+ function copyWorld(canvas, out, ui) {
934
+ if (ui.__worldFlipped || Platform.fullImageShadow)
934
935
  canvas.copyWorldByReset(out, ui.__nowWorld);
935
936
  else
936
937
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
937
- out.recycle(ui.__nowWorld);
938
938
  }
939
939
  function drawTextStroke(ui, canvas) {
940
940
  let row, data = ui.__.__textDrawData;
@@ -1003,9 +1003,8 @@ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
1003
1003
  Paint.strokeArrow(stroke, ui, canvas);
1004
1004
  }
1005
1005
  function drawInside(stroke, ui, canvas) {
1006
- const data = ui.__;
1007
1006
  canvas.save();
1008
- data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
1007
+ canvas.clipUI(ui);
1009
1008
  drawCenter(stroke, 2, ui, canvas);
1010
1009
  canvas.restore();
1011
1010
  }
@@ -1019,12 +1018,9 @@ function drawOutside(stroke, ui, canvas) {
1019
1018
  const out = canvas.getSameCanvas(true, true);
1020
1019
  ui.__drawRenderPath(out);
1021
1020
  drawCenter(stroke, 2, ui, out);
1022
- data.windingRule ? out.clip(data.windingRule) : out.clip();
1021
+ out.clipUI(data);
1023
1022
  out.clearWorld(renderBounds);
1024
- if (ui.__worldFlipped || Platform$1.fullImageShadow)
1025
- canvas.copyWorldByReset(out, ui.__nowWorld);
1026
- else
1027
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
1023
+ copyWorld(canvas, out, ui);
1028
1024
  out.recycle(ui.__nowWorld);
1029
1025
  }
1030
1026
  }
@@ -1080,9 +1076,7 @@ function compute(attrName, ui) {
1080
1076
  paints = [paints];
1081
1077
  recycleMap = PaintImage.recycleImage(attrName, data);
1082
1078
  for (let i = 0, len = paints.length, item; i < len; i++) {
1083
- item = getLeafPaint(attrName, paints[i], ui);
1084
- if (item)
1085
- leafPaints.push(item);
1079
+ (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
1086
1080
  }
1087
1081
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
1088
1082
  if (leafPaints.length) {
@@ -1120,8 +1114,8 @@ function getLeafPaint(attrName, paint, ui) {
1120
1114
  data = PaintGradient.conicGradient(paint, boxBounds);
1121
1115
  break;
1122
1116
  case 'solid':
1123
- const { type, blendMode, color, opacity } = paint;
1124
- data = { type, blendMode, style: ColorConvert.string(color, opacity) };
1117
+ const { type, color, opacity } = paint;
1118
+ data = { type, style: ColorConvert.string(color, opacity) };
1125
1119
  break;
1126
1120
  default:
1127
1121
  if (paint.r !== undefined)
@@ -1530,7 +1524,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
1530
1524
  }
1531
1525
  function drawImage(ui, canvas, paint, data) {
1532
1526
  canvas.save();
1533
- ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
1527
+ canvas.clipUI(ui);
1534
1528
  if (paint.blendMode)
1535
1529
  canvas.blendMode = paint.blendMode;
1536
1530
  if (data.opacity)
@@ -1695,12 +1689,10 @@ function shadow(ui, current, shape) {
1695
1689
  }
1696
1690
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1697
1691
  }
1698
- if (ui.__worldFlipped) {
1692
+ if (ui.__worldFlipped)
1699
1693
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1700
- }
1701
- else {
1694
+ else
1702
1695
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
1703
- }
1704
1696
  if (end && index < end)
1705
1697
  other.clearWorld(copyBounds, true);
1706
1698
  });
@@ -1759,12 +1751,10 @@ function innerShadow(ui, current, shape) {
1759
1751
  copyBounds = bounds;
1760
1752
  }
1761
1753
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
1762
- if (ui.__worldFlipped) {
1754
+ if (ui.__worldFlipped)
1763
1755
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1764
- }
1765
- else {
1756
+ else
1766
1757
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
1767
- }
1768
1758
  if (end && index < end)
1769
1759
  other.clearWorld(copyBounds, true);
1770
1760
  });
@@ -2400,7 +2390,7 @@ const ColorConvertModule = {
2400
2390
 
2401
2391
  Object.assign(TextConvert, TextConvertModule);
2402
2392
  Object.assign(ColorConvert, ColorConvertModule);
2403
- Object.assign(Paint$1, PaintModule);
2393
+ Object.assign(Paint, PaintModule);
2404
2394
  Object.assign(PaintImage, PaintImageModule);
2405
2395
  Object.assign(PaintGradient, PaintGradientModule);
2406
2396
  Object.assign(Effect, EffectModule);
@@ -1,2 +1,2 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as a,FileHelper as r,Creator as d,LeaferImage as l,defineKey as c,LeafList as h,RenderEvent as u,ChildEvent as p,WatchEvent as f,PropertyEvent as g,LeafHelper as _,BranchHelper as w,LeafBoundsHelper as y,Bounds as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as E,MathHelper as k,AlignHelper as S,PointHelper as L,ImageEvent as A,AroundHelper as O,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as T,ColorConvert as W,PaintGradient as D,Export as I,Group as M,TextConvert as P,Paint as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";import{Platform as V}from"@leafer-ui/core";const Y=t.get("LeaferCanvas");class U 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.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="string"==typeof 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 Y.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;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){this.autoBounds=t;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),Y.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else 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})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(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.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:G,fileType:N}=r;function j(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=G(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,G(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(G(N(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=d.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(d,{canvas:(t,e)=>new U(t,e),image:t=>new l(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},c(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):q.indexOf("AppleWebKit")>-1&&(i.fullImageShadow=!0),q.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):q.indexOf("Mac")>-1?i.os="Mac":q.indexOf("Linux")>-1&&(i.os="Linux");class X{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new h;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 h,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new h,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[g.CHANGE,this.__onAttrChange,this],[[p.ADD,p.REMOVE],this.__onChildEvent,this],[f.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:H,updateBounds:Q,updateChange:Z}=_,{pushAllChildBranch:$,pushAllParent:K}=w;const{worldBounds:J}=y;class tt{constructor(t){this.updatedBounds=new m,this.beforeBounds=new m,this.afterBounds=new m,t instanceof Array&&(t=new h(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,J)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,J),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:et,updateAllChange:it}=_,st=t.get("Layouter");class nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(H(t,!0),e.add(t),t.isBranch&&$(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(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||Q(s[t])}Q(i)}}))}(this.__levelList),function(t){t.list.forEach(Z)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new h(e));e.emitEvent(new x(i,o,this.times)),nt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){et(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[f.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ot=t.get("Renderer");class at{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents()}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(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(u.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(u.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new m,ot.log(e.innerName,"---\x3e");try{this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,ot.error(t)}ot.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ot.warn("rendering");if(this.times>3)return ot.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new m,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new m(s);i.save(),s.spread(at.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new m;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);const e=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new m(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 m(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||ot.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 u(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[u.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[u.AGAIN,this.renderAgain,this],[o.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function rt(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 dt(t,e){t.__.__font?rt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}at.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new X(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new at(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=nt.fullLayout;const lt={};function ct(t,e,i){switch(e.__.strokeAlign){case"center":ht(t,1,e,i);break;case"inside":ut(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ht(t,2,e,i):ut(t,"outside",e,i)}}function ht(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?ft(t,!0,i,s):pt(i,s)}function ut(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ht(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",rt(i,n),n.blendMode="normal",i.__worldFlipped||V.fullImageShadow?s.copyWorldByReset(n,i.__nowWorld):s.copyWorldToInner(n,i.__nowWorld,i.__layout.renderBounds),n.recycle(i.__nowWorld)}function pt(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 ft(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&T.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?pt(i,s):s.stroke(),s.restoreBlendMode()):e?pt(i,s):s.stroke())}function gt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ct(t,e,i);else switch(s.strokeAlign){case"center":_t(t,1,e,i);break;case"inside":!function(t,e,i){const s=e.__;i.save(),s.windingRule?i.clip(s.windingRule):i.clip(),_t(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)_t(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),_t(t,2,e,o),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(n),e.__worldFlipped||V.fullImageShadow?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,n),o.recycle(e.__nowWorld)}}(t,e,i)}}function _t(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?ft(t,!1,i,s):s.stroke(),n.__useArrow&&lt.strokeArrow(t,i,s)}const{getSpread:wt,getOuterOf:yt,getByMove:mt,getIntersectData:vt}=R;let xt;const{stintSet:bt}=s,{hasTransparent:Bt}=W;function Rt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=T.image(i,t,e,n,!xt||!xt[e.url]);break;case"linear":s=D.linearGradient(e,n);break;case"radial":s=D.radialGradient(e,n);break;case"angular":s=D.conicGradient(e,n);break;case"solid":const{type:o,blendMode:a,color:r,opacity:d}=e;s={type:o,blendMode:a,style:W.string(r,d)};break;default:void 0!==e.r&&(s={type:"solid",style:W.string(e)})}return s&&("string"==typeof s.style&&Bt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const Et={compute:function(t,e){const i=e.__,s=[];let n,o,a=i.__input[t];a instanceof Array||(a=[a]),xt=T.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)i=Rt(t,a[n],e),i&&s.push(i);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?(bt(i,"__isAlphaPixelFill",n),bt(i,"__isTransparentFill",o)):(bt(i,"__isAlphaPixelStroke",n),bt(i,"__isTransparentStroke",o))},fill:function(t,e,i){i.fillStyle=t,dt(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(T.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),dt(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),dt(e,i),i.restoreBlendMode()):dt(e,i)}},fillPathOrText:dt,fillText:rt,stroke:gt,strokes:function(t,e,i){gt(t,e,i)},strokeText:ct,drawTextStroke:pt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))d=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,h=vt(s?wt(e.bounds,l===c?s*l:[s*c,s*l]):e.bounds,n);a=e.bounds.getFitMatrix(h);let{a:u,d:p}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=p),r=yt(n,a),o=mt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,p)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let kt={};const{get:St,rotateOfOuter:Lt,translate:At,scaleOfOuter:Ot,scale:Ct,rotate:Tt}=E;function Wt(t,e,i,s,n,o,a){const r=St();At(r,e.x+i,e.y+s),Ct(r,n,o),a&&Lt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Dt(t,e,i,s,n,o,a){const r=St();At(r,e.x+i,e.y+s),n&&Ct(r,n,o),a&&Tt(r,a),t.transform=r}function It(t,e,i,s,n,o,a,r,d,l){const c=St();if(d)if("center"===l)Lt(c,{x:i/2,y:s/2},d);else switch(Tt(c,d),d){case 90:At(c,s,0);break;case 180:At(c,i,s);break;case 270:At(c,0,i)}kt.x=e.x+n,kt.y=e.y+o,At(c,kt.x,kt.y),a&&Ot(c,kt,a,r),t.transform=c}const{get:Mt,translate:Pt}=E,zt=new m,Ft={},Vt={};function Yt(t,e,i,s){const{changeful:n,sync:o}=i;n&&(t.changeful=n),o&&(t.sync=o),t.data=Ut(i,s,e)}function Ut(t,e,i){t.padding&&(e=zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u,filters:p}=t,f=e.width===s&&e.height===n,g={mode:a},_="center"!==r&&(h||0)%180==90;let w,y;switch(R.set(Vt,0,0,_?n:s,_?s:n),a&&"cover"!==a&&"fit"!==a?((l||c)&&(k.getScaleData(l,c,i,Ft),w=Ft.scaleX,y=Ft.scaleY),r&&(w&&R.scale(Vt,w,y,!0),S.toPoint(r,Vt,e,Vt,!0,!0))):f&&!h||(w=y=R.getFitScale(e,Vt,"fit"!==a),R.put(e,i,r,w,!1,Vt),R.scale(Vt,w,y,!0)),d&&L.move(Vt,d),a){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(Vt.x||Vt.y||w||h)&&Dt(g,e,Vt.x,Vt.y,w,y,h);break;case"repeat":(!f||w||h)&&It(g,e,s,n,Vt.x,Vt.y,w,y,h,r),u||(g.repeat="repeat");break;default:w&&Wt(g,e,Vt.x,Vt.y,w,y,h)}return g.transform||(e.x||e.y)&&(g.transform=Mt(),Pt(g.transform,e.x,e.y)),w&&"stretch"!==a&&(g.scaleX=w,g.scaleY=y),g.width=s,g.height=n,o&&(g.opacity=o),p&&(g.filters=p),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Gt,Nt=new m;const{isSame:jt}=R;function qt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Yt(n,s,i,o),!0}function Xt(t,e){Zt(t,A.LOAD,e)}function Ht(t,e){Zt(t,A.LOADED,e)}function Qt(t,e,i){e.error=i,t.forceUpdate("surface"),Zt(t,A.ERROR,e)}function Zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function $t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Kt,scale:Jt,copy:te}=E,{ceil:ee,abs:ie}=Math;function se(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(e.patternId===a||t.destroyed)return!1;{n=ie(n),o=ie(o);const{image:t,data:r}=e;let d,l,{width:c,height:h,scaleX:u,scaleY:p,transform:f,repeat:g}=r;u&&(l=Kt(),te(l,f),Jt(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,c*=n,h*=o;const _=c*h;if(!g&&_>i.image.maxCacheSize)return!1;let w=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(d=Math.sqrt(_/w)),d&&(n/=d,o/=d,c/=d,h/=d),u&&(n/=u,o/=p),(f||1!==n||1!==o)&&(l||(l=Kt(),f&&te(l,f)),Jt(l,1/n,1/o));const y=t.getCanvas(ee(c)||1,ee(h)||1,r.opacity,r.filters),m=t.getPattern(y,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=a,!0}}function ne(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{d(s.next(t))}catch(t){o(t)}}function r(t){try{d(s.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:oe}=Math;const ae={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Gt&&i===Gt.paint&&jt(s,Gt.boxBounds)?o=Gt.leafPaint:(o={type:i.type,image:r},r.hasAlphaPixel&&(o.isTransparent=!0),Gt=r.use>1?{leafPaint:o,paint:i,boxBounds:Nt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(qt(t,e,i,r,o,s),n&&(Xt(t,a),Ht(t,a))):r.error?n&&Qt(t,a,r.error):(n&&($t(t,!0),Xt(t,a)),o.loadId=r.load((()=>{$t(t,!1),t.destroyed||(qt(t,e,i,r,o,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ht(t,a)),o.loadId=null}),(e=>{$t(t,!1),Qt(t,a,e),o.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=e,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+d&&!I.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||I.running)){let{width:t,height:e}=l;t*=oe(a)*d,e*=oe(r)*d,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),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||I.running?se(t,s,d):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ne(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&se(t,s,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:se,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a,r;for(let d=0,l=i.length;d<l;d++)s=i[d],n=s.image,r=n&&n.url,r&&(o||(o={}),o[r]=!0,B.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Yt,getPatternData:Ut,fillOrFitMode:Wt,clipMode:Dt,repeatMode:It},{toPoint:re}=O,{hasTransparent:de}=W,le={},ce={};function he(t,e,i,s){if(i){let n,o,a,r;for(let t=0,d=i.length;t<d;t++)n=i[t],"string"==typeof n?(a=t/(d-1),o=W.string(n,s)):(a=n.offset,o=W.string(n.color,s)),e.addColorStop(a,o),!r&&de(o)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:ue,getDistance:pe}=L,{get:fe,rotateOfOuter:ge,scaleOfOuter:_e}=E,{toPoint:we}=O,ye={},me={};function ve(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=ue(e,i);o=fe(),n?(_e(o,e,a/r*(s||1),1),ge(o,e,t+90)):(_e(o,e,1,a/r*(s||1)),ge(o,e,t))}return o}const{getDistance:xe}=L,{toPoint:be}=O,Be={},Re={};const Ee={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:a}=t;re(s||"top",e,le),re(n||"bottom",e,ce);const r=i.canvas.createLinearGradient(le.x,le.y,ce.x,ce.y),d={type:o,style:r};return he(d,r,t.stops,a),d},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;we(s||"center",e,ye),we(n||"bottom",e,me);const d=i.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,pe(ye,me)),l={type:o,style:d};he(l,d,t.stops,a);const c=ve(e,ye,me,r,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;be(s||"center",e,Be),be(n||"bottom",e,Re);const d=i.conicGradientSupport?i.canvas.createConicGradient(0,Be.x,Be.y):i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,xe(Be,Re)),l={type:o,style:d};he(l,d,t.stops,a);const c=ve(e,Be,Re,r||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:ve},{copy:ke,toOffsetOutBounds:Se}=R,Le={},Ae={};function Oe(t,e,s,n){const{bounds:o,shapeBounds:a}=n;if(i.fullImageShadow){if(ke(Le,t.bounds),Le.x+=e.x-a.x,Le.y+=e.y-a.y,s){const{matrix:t}=n;Le.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Le.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Le.width*=s,Le.height*=s}t.copyWorld(n.canvas,t.bounds,Le)}else s&&(ke(Le,e),Le.x-=e.width/2*(s-1),Le.y-=e.height/2*(s-1),Le.width*=s,Le.height*=s),t.copyWorld(n.canvas,a,s?Le:e)}const{toOffsetOutBounds:Ce}=R,Te={};const We={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),f=r.length-1;Se(l,Ae),r.forEach(((r,g)=>{p.setWorldShadow(Ae.offsetX+r.x*h,Ae.offsetY+r.y*u,r.blur*h,W.string(r.color)),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Oe(p,Ae,n,i),s=l,r.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,l,o,"copy"),s=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,o,r.blendMode):e.copyWorldToInner(p,s,a.renderBounds,r.blendMode),f&&g<f&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),f=r.length-1;Ce(l,Te),r.forEach(((r,g)=>{p.save(),p.setWorldShadow(Te.offsetX+r.x*h,Te.offsetY+r.y*u,r.blur*h),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Oe(p,Te,n,i),p.restore(),d?(p.copyWorld(p,l,o,"copy"),p.copyWorld(d,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,c,l,"source-out"),s=l),p.fillWorld(s,W.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,s,o,r.blendMode):e.copyWorldToInner(p,s,a.renderBounds,r.blendMode),f&&g<f&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:De}=y;function Ie(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Pe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Pe(t,i,s,o);break;case"path":i.restore()}}function Me(t){return t.getSameCanvas(!1,!0)}function Pe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}M.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(a&&(Ie(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Me(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Me(t)),n||(n=Me(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||De(i,e)||i.__render(n||t,e);Ie(this,a,t,n,s,o)};const ze=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Fe=ze+"_#~&*+\\=|≮≯≈≠=…",Ve=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ye(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ue=Ye("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ge=Ye("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ne=Ye(ze),je=Ye(Fe),qe=Ye("- —/~|┆·");var Xe;!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"}(Xe||(Xe={}));const{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Ke,Break:Je}=Xe;function ti(t){return Ue[t]?He:qe[t]?Je:Ge[t]?Ze:Ne[t]?$e:je[t]?Ke:Ve.test(t)?Qe:He}const ei={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 ii(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:si}=ei,{Letter:ni,Single:oi,Before:ai,After:ri,Symbol:di,Break:li}=Xe;let ci,hi,ui,pi,fi,gi,_i,wi,yi,mi,vi,xi,bi,Bi,Ri,Ei,ki,Si=[];function Li(t,e){yi&&!wi&&(wi=yi),ci.data.push({char:t,width:e}),ui+=e}function Ai(){pi+=ui,ci.width=ui,hi.words.push(ci),ci={data:[]},ui=0}function Oi(){Bi&&(Ri.paraNumber++,hi.paraStart=!0,Bi=!1),yi&&(hi.startCharSize=wi,hi.endCharSize=yi,wi=0),hi.width=pi,Ei.width?si(hi):ki&&Ci(),Si.push(hi),hi={words:[]},pi=0}function Ci(){pi>(Ri.maxWidth||0)&&(Ri.maxWidth=pi)}const{top:Ti,right:Wi,bottom:Di,left:Ii}=C;function Mi(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 Pi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o?(s=l[Ii],o-=l[Wi]+l[Ii]):e.autoSizeAlign||(s=l[Ii]),a?(n=l[Ti],a-=l[Ti]+l[Di]):e.autoSizeAlign||(n=l[Ti]));const c={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){Ri=t,Si=t.rows,Ei=t.bounds,ki=!Ei.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=i,{width:d,height:l}=Ei;if(d||l||n||"none"!==a){const t="none"!==s.textWrap,i="break"===s.textWrap;Bi=!0,vi=null,wi=_i=yi=ui=pi=0,ci={data:[]},hi={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)gi=e[s],"\n"===gi?(ui&&Ai(),hi.paraEnd=!0,Oi(),Bi=!0):(mi=ti(gi),mi===ni&&"none"!==a&&(gi=ii(gi,a,!ui)),_i=r.measureText(gi).width,n&&(n<0&&(yi=_i),_i+=n),xi=mi===oi&&(vi===oi||vi===ni)||vi===oi&&mi!==ri,bi=!(mi!==ai&&mi!==oi||vi!==di&&vi!==ri),fi=Bi&&o?d-o:d,t&&d&&pi+ui+_i>fi&&(i?(ui&&Ai(),pi&&Oi()):(bi||(bi=mi===ni&&vi==ri),xi||bi||mi===li||mi===ai||mi===oi||ui+_i>fi?(ui&&Ai(),pi&&Oi()):pi&&Oi()))," "===gi&&!0!==Bi&&pi+ui===0||(mi===li?(" "===gi&&ui&&Ai(),Li(gi,_i),Ai()):xi||bi?(ui&&Ai(),Li(gi,_i)):Li(gi,_i)),vi=mi);ui&&Ai(),pi&&Oi(),Si.length>0&&(Si[Si.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ri.paraNumber++,pi=r.measureText(t).width,Si.push({x:o||0,text:t,width:pi,paraStart:!0}),ki&&Ci()}))}(c,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Mi(e,"x",t[Ii]);break;case"right":Mi(e,"x",-t[Wi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Mi(e,"y",t[Ti]);break;case"bottom":Mi(e,"y",-t[Di])}}(l,c,e,o,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:p,y:f,width:g,height:_}=s,w=o*n+(h?h*(t.paraNumber-1):0),y=a;if(d&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":f+=(_-w)/2;break;case"bottom":f+=_-w}y+=f;let m,v,x,b=g||u?g:t.maxWidth;for(let a=0,c=n;a<c;a++){if(m=i[a],m.x=p,m.width<g||m.width>g&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&a>0&&(y+=h),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),d&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=f,s.height=w}(c,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(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,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==n||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,c=s+n-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<c));s--){if(d<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:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,e,s,o),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=W.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(c,e),c}};const zi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!W.object)return t;t=W.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(P,Pi),Object.assign(W,zi),Object.assign(z,Et),Object.assign(T,ae),Object.assign(D,Ee),Object.assign(F,We),j();export{nt as Layouter,U as LeaferCanvas,at as Renderer,X as Watcher,j as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as a,FileHelper as r,Creator as d,LeaferImage as l,defineKey as h,LeafList as c,RenderEvent as u,ChildEvent as f,WatchEvent as p,PropertyEvent as g,LeafHelper as _,BranchHelper as w,LeafBoundsHelper as y,Bounds as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as E,MatrixHelper as k,MathHelper as R,AlignHelper as S,PointHelper as L,ImageEvent as A,AroundHelper as O,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as T,Paint as W,ColorConvert as D,PaintGradient as I,Export as M,Group as P,TextConvert as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const U=t.get("LeaferCanvas");class V 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.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="string"==typeof 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 U.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;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){this.autoBounds=t;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),U.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else 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})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(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.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:Y,fileType:G}=r;function N(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=Y(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,Y(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(Y(G(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=d.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(d,{canvas:(t,e)=>new V(t,e),image:t=>new l(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},h(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):j.indexOf("AppleWebKit")>-1&&(i.fullImageShadow=!0),j.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):j.indexOf("Mac")>-1?i.os="Mac":j.indexOf("Linux")>-1&&(i.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===f.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 p(p.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[g.CHANGE,this.__onAttrChange,this],[[f.ADD,f.REMOVE],this.__onChildEvent,this],[p.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:X,updateBounds:H,updateChange:Q}=_,{pushAllChildBranch:Z,pushAllParent:$}=w;const{worldBounds:K}=y;class J{constructor(t){this.updatedBounds=new m,this.beforeBounds=new m,this.afterBounds=new m,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,K),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:tt,updateAllChange:et}=_,it=t.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(p.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(X(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(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||H(s[t])}H(i)}}))}(this.__levelList),function(t){t.list.forEach(Q)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),st.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new J([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new J(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[p.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=t.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents()}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(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(u.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(u.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new m,nt.log(e.innerName,"---\x3e");try{this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new m,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new m(s);i.save(),s.spread(ot.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new m;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);const e=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new m(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 m(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||nt.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 u(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[u.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[u.AGAIN,this.renderAgain,this],[o.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function at(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 rt(t,e){t.__.__font?at(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function dt(t,e,i){switch(e.__.strokeAlign){case"center":lt(t,1,e,i);break;case"inside":ht(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?lt(t,2,e,i):ht(t,"outside",e,i)}}function lt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?ft(t,!0,i,s):ut(i,s)}function ht(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,lt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",at(i,n),n.blendMode="normal",ct(s,n,i),n.recycle(i.__nowWorld)}function ct(t,e,s){s.__worldFlipped||i.fullImageShadow?t.copyWorldByReset(e,s.__nowWorld):t.copyWorldToInner(e,s.__nowWorld,s.__layout.renderBounds)}function ut(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 ft(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&T.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?ut(i,s):s.stroke(),s.restoreBlendMode()):e?ut(i,s):s.stroke())}function pt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)dt(t,e,i);else switch(s.strokeAlign){case"center":gt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),gt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)gt(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),gt(t,2,e,o),o.clipUI(s),o.clearWorld(n),ct(i,o,e),o.recycle(e.__nowWorld)}}(t,e,i)}}function gt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?ft(t,!1,i,s):s.stroke(),n.__useArrow&&W.strokeArrow(t,i,s)}ot.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=st.fullLayout;const{getSpread:_t,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=E;let vt;const{stintSet:xt}=s,{hasTransparent:bt}=D;function Bt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=T.image(i,t,e,n,!vt||!vt[e.url]);break;case"linear":s=I.linearGradient(e,n);break;case"radial":s=I.radialGradient(e,n);break;case"angular":s=I.conicGradient(e,n);break;case"solid":const{type:o,color:a,opacity:r}=e;s={type:o,style:D.string(a,r)};break;default:void 0!==e.r&&(s={type:"solid",style:D.string(e)})}return s&&("string"==typeof s.style&&bt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const Et={compute:function(t,e){const i=e.__,s=[];let n,o,a=i.__input[t];a instanceof Array||(a=[a]),vt=T.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Bt(t,a[n],e))&&s.push(i);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?(xt(i,"__isAlphaPixelFill",n),xt(i,"__isTransparentFill",o)):(xt(i,"__isAlphaPixelStroke",n),xt(i,"__isTransparentStroke",o))},fill:function(t,e,i){i.fillStyle=t,rt(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(T.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),rt(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),rt(e,i),i.restoreBlendMode()):rt(e,i)}},fillPathOrText:rt,fillText:at,stroke:pt,strokes:function(t,e,i){pt(t,e,i)},strokeText:dt,drawTextStroke:ut,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:h}=n;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(n))d=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=mt(s?_t(e.bounds,l===h?s*l:[s*h,s*l]):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=wt(n,a),o=yt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let kt={};const{get:Rt,rotateOfOuter:St,translate:Lt,scaleOfOuter:At,scale:Ot,rotate:Ct}=k;function Tt(t,e,i,s,n,o,a){const r=Rt();Lt(r,e.x+i,e.y+s),Ot(r,n,o),a&&St(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Wt(t,e,i,s,n,o,a){const r=Rt();Lt(r,e.x+i,e.y+s),n&&Ot(r,n,o),a&&Ct(r,a),t.transform=r}function Dt(t,e,i,s,n,o,a,r,d,l){const h=Rt();if(d)if("center"===l)St(h,{x:i/2,y:s/2},d);else switch(Ct(h,d),d){case 90:Lt(h,s,0);break;case 180:Lt(h,i,s);break;case 270:Lt(h,0,i)}kt.x=e.x+n,kt.y=e.y+o,Lt(h,kt.x,kt.y),a&&At(h,kt,a,r),t.transform=h}const{get:It,translate:Mt}=k,Pt=new m,zt={},Ft={};function Ut(t,e,i,s){const{changeful:n,sync:o}=i;n&&(t.changeful=n),o&&(t.sync=o),t.data=Vt(i,s,e)}function Vt(t,e,i){t.padding&&(e=Pt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:o,mode:a,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u,filters:f}=t,p=e.width===s&&e.height===n,g={mode:a},_="center"!==r&&(c||0)%180==90;let w,y;switch(E.set(Ft,0,0,_?n:s,_?s:n),a&&"cover"!==a&&"fit"!==a?((l||h)&&(R.getScaleData(l,h,i,zt),w=zt.scaleX,y=zt.scaleY),r&&(w&&E.scale(Ft,w,y,!0),S.toPoint(r,Ft,e,Ft,!0,!0))):p&&!c||(w=y=E.getFitScale(e,Ft,"fit"!==a),E.put(e,i,r,w,!1,Ft),E.scale(Ft,w,y,!0)),d&&L.move(Ft,d),a){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(Ft.x||Ft.y||w||c)&&Wt(g,e,Ft.x,Ft.y,w,y,c);break;case"repeat":(!p||w||c)&&Dt(g,e,s,n,Ft.x,Ft.y,w,y,c,r),u||(g.repeat="repeat");break;default:w&&Tt(g,e,Ft.x,Ft.y,w,y,c)}return g.transform||(e.x||e.y)&&(g.transform=It(),Mt(g.transform,e.x,e.y)),w&&"stretch"!==a&&(g.scaleX=w,g.scaleY=y),g.width=s,g.height=n,o&&(g.opacity=o),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Yt,Gt=new m;const{isSame:Nt}=E;function jt(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||Ut(n,s,i,o),!0}function qt(t,e){Qt(t,A.LOAD,e)}function Xt(t,e){Qt(t,A.LOADED,e)}function Ht(t,e,i){e.error=i,t.forceUpdate("surface"),Qt(t,A.ERROR,e)}function Qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Zt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:$t,scale:Kt,copy:Jt}=k,{ceil:te,abs:ee}=Math;function ie(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(e.patternId===a||t.destroyed)return!1;{n=ee(n),o=ee(o);const{image:t,data:r}=e;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(l=$t(),Jt(l,p),Kt(l,1/u,1/f),n*=u,o*=f),n*=s,o*=s,h*=n,c*=o;const _=h*c;if(!g&&_>i.image.maxCacheSize)return!1;let w=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(d=Math.sqrt(_/w)),d&&(n/=d,o/=d,h/=d,c/=d),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(l||(l=$t(),p&&Jt(l,p)),Kt(l,1/n,1/o));const y=t.getCanvas(te(h)||1,te(c)||1,r.opacity,r.filters),m=t.getPattern(y,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=a,!0}}function se(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{d(s.next(t))}catch(t){o(t)}}function r(t){try{d(s.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ne}=Math;const oe={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Yt&&i===Yt.paint&&Nt(s,Yt.boxBounds)?o=Yt.leafPaint:(o={type:i.type,image:r},r.hasAlphaPixel&&(o.isTransparent=!0),Yt=r.use>1?{leafPaint:o,paint:i,boxBounds:Gt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(jt(t,e,i,r,o,s),n&&(qt(t,a),Xt(t,a))):r.error?n&&Ht(t,a,r.error):(n&&(Zt(t,!0),qt(t,a)),o.loadId=r.load((()=>{Zt(t,!1),t.destroyed||(jt(t,e,i,r,o,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Xt(t,a)),o.loadId=null}),(e=>{Zt(t,!1),Ht(t,a,e),o.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=e,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+d&&!M.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||M.running)){let{width:t,height:e}=l;t*=ne(a)*d,e*=ne(r)*d,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(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||M.running?ie(t,s,d):s.patternTask||(s.patternTask=B.patternTasker.add((()=>se(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&ie(t,s,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:ie,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a,r;for(let d=0,l=i.length;d<l;d++)s=i[d],n=s.image,r=n&&n.url,r&&(o||(o={}),o[r]=!0,B.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Ut,getPatternData:Vt,fillOrFitMode:Tt,clipMode:Wt,repeatMode:Dt},{toPoint:ae}=O,{hasTransparent:re}=D,de={},le={};function he(t,e,i,s){if(i){let n,o,a,r;for(let t=0,d=i.length;t<d;t++)n=i[t],"string"==typeof n?(a=t/(d-1),o=D.string(n,s)):(a=n.offset,o=D.string(n.color,s)),e.addColorStop(a,o),!r&&re(o)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:ce,getDistance:ue}=L,{get:fe,rotateOfOuter:pe,scaleOfOuter:ge}=k,{toPoint:_e}=O,we={},ye={};function me(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=ce(e,i);o=fe(),n?(ge(o,e,a/r*(s||1),1),pe(o,e,t+90)):(ge(o,e,1,a/r*(s||1)),pe(o,e,t))}return o}const{getDistance:ve}=L,{toPoint:xe}=O,be={},Be={};const Ee={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:a}=t;ae(s||"top",e,de),ae(n||"bottom",e,le);const r=i.canvas.createLinearGradient(de.x,de.y,le.x,le.y),d={type:o,style:r};return he(d,r,t.stops,a),d},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;_e(s||"center",e,we),_e(n||"bottom",e,ye);const d=i.canvas.createRadialGradient(we.x,we.y,0,we.x,we.y,ue(we,ye)),l={type:o,style:d};he(l,d,t.stops,a);const h=me(e,we,ye,r,!0);return h&&(l.transform=h),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;xe(s||"center",e,be),xe(n||"bottom",e,Be);const d=i.conicGradientSupport?i.canvas.createConicGradient(0,be.x,be.y):i.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,ve(be,Be)),l={type:o,style:d};he(l,d,t.stops,a);const h=me(e,be,Be,r||1,i.conicGradientRotate90);return h&&(l.transform=h),l},getTransform:me},{copy:ke,toOffsetOutBounds:Re}=E,Se={},Le={};function Ae(t,e,s,n){const{bounds:o,shapeBounds:a}=n;if(i.fullImageShadow){if(ke(Se,t.bounds),Se.x+=e.x-a.x,Se.y+=e.y-a.y,s){const{matrix:t}=n;Se.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Se.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Se.width*=s,Se.height*=s}t.copyWorld(n.canvas,t.bounds,Se)}else s&&(ke(Se,e),Se.x-=e.width/2*(s-1),Se.y-=e.height/2*(s-1),Se.width*=s,Se.height*=s),t.copyWorld(n.canvas,a,s?Se:e)}const{toOffsetOutBounds:Oe}=E,Ce={};const Te={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Re(l,Le),r.forEach(((r,g)=>{f.setWorldShadow(Le.offsetX+r.x*c,Le.offsetY+r.y*u,r.blur*c,D.string(r.color)),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ae(f,Le,n,i),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),s=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Oe(l,Ce),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ce.offsetX+r.x*c,Ce.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ae(f,Ce,n,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,h,l,"source-out"),s=l),f.fillWorld(s,D.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:We}=y;function De(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Me(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Me(t,i,s,o);break;case"path":i.restore()}}function Ie(t){return t.getSameCanvas(!1,!0)}function Me(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}P.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(a&&(De(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Ie(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Ie(t)),n||(n=Ie(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||We(i,e)||i.__render(n||t,e);De(this,a,t,n,s,o)};const Pe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ze=Pe+"_#~&*+\\=|≮≯≈≠=…",Fe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ue(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ve=Ue("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ye=Ue("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ge=Ue(Pe),Ne=Ue(ze),je=Ue("- —/~|┆·");var qe;!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"}(qe||(qe={}));const{Letter:Xe,Single:He,Before:Qe,After:Ze,Symbol:$e,Break:Ke}=qe;function Je(t){return Ve[t]?Xe:je[t]?Ke:Ye[t]?Qe:Ge[t]?Ze:Ne[t]?$e:Fe.test(t)?He:Xe}const ti={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 ei(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}=ti,{Letter:si,Single:ni,Before:oi,After:ai,Symbol:ri,Break:di}=qe;let li,hi,ci,ui,fi,pi,gi,_i,wi,yi,mi,vi,xi,bi,Bi,Ei,ki,Ri=[];function Si(t,e){wi&&!_i&&(_i=wi),li.data.push({char:t,width:e}),ci+=e}function Li(){ui+=ci,li.width=ci,hi.words.push(li),li={data:[]},ci=0}function Ai(){bi&&(Bi.paraNumber++,hi.paraStart=!0,bi=!1),wi&&(hi.startCharSize=_i,hi.endCharSize=wi,_i=0),hi.width=ui,Ei.width?ii(hi):ki&&Oi(),Ri.push(hi),hi={words:[]},ui=0}function Oi(){ui>(Bi.maxWidth||0)&&(Bi.maxWidth=ui)}const{top:Ci,right:Ti,bottom:Wi,left:Di}=C;function Ii(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 Mi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o?(s=l[Di],o-=l[Ti]+l[Di]):e.autoSizeAlign||(s=l[Di]),a?(n=l[Ci],a-=l[Ci]+l[Wi]):e.autoSizeAlign||(n=l[Ci]));const h={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){Bi=t,Ri=t.rows,Ei=t.bounds,ki=!Ei.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=i,{width:d,height:l}=Ei;if(d||l||n||"none"!==a){const t="none"!==s.textWrap,i="break"===s.textWrap;bi=!0,mi=null,_i=gi=wi=ci=ui=0,li={data:[]},hi={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)pi=e[s],"\n"===pi?(ci&&Li(),hi.paraEnd=!0,Ai(),bi=!0):(yi=Je(pi),yi===si&&"none"!==a&&(pi=ei(pi,a,!ci)),gi=r.measureText(pi).width,n&&(n<0&&(wi=gi),gi+=n),vi=yi===ni&&(mi===ni||mi===si)||mi===ni&&yi!==ai,xi=!(yi!==oi&&yi!==ni||mi!==ri&&mi!==ai),fi=bi&&o?d-o:d,t&&d&&ui+ci+gi>fi&&(i?(ci&&Li(),ui&&Ai()):(xi||(xi=yi===si&&mi==ai),vi||xi||yi===di||yi===oi||yi===ni||ci+gi>fi?(ci&&Li(),ui&&Ai()):ui&&Ai()))," "===pi&&!0!==bi&&ui+ci===0||(yi===di?(" "===pi&&ci&&Li(),Si(pi,gi),Li()):vi||xi?(ci&&Li(),Si(pi,gi)):Si(pi,gi)),mi=yi);ci&&Li(),ui&&Ai(),Ri.length>0&&(Ri[Ri.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Bi.paraNumber++,ui=r.measureText(t).width,Ri.push({x:o||0,text:t,width:ui,paraStart:!0}),ki&&Oi()}))}(h,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ii(e,"x",t[Di]);break;case"right":Ii(e,"x",-t[Ti])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ii(e,"y",t[Ci]);break;case"bottom":Ii(e,"y",-t[Wi])}}(l,h,e,o,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=o*n+(c?c*(t.paraNumber-1):0),y=a;if(d&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let a=0,h=n;a<h;a++){if(m=i[a],m.x=f,m.width<g||m.width>g&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&a>0&&(y+=c),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),d&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(h,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:a}=e;let r,d,l,h,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,h=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==n||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(h,e,o),h.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,h=s+n-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<h));s--){if(d<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e,s,o),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=D.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,e),h}};const Pi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(z,Mi),Object.assign(D,Pi),Object.assign(W,Et),Object.assign(T,oe),Object.assign(I,Ee),Object.assign(F,Te),N();export{st as Layouter,V as LeaferCanvas,ot as Renderer,q as Watcher,N as useCanvas};
2
2
  //# sourceMappingURL=web.esm.min.js.map