leafer-draw 1.6.1 → 1.6.2

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
@@ -367,7 +367,7 @@ class Watcher {
367
367
  }
368
368
  }
369
369
 
370
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = core.LeafHelper;
370
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = core.LeafHelper;
371
371
  const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
372
372
  function updateMatrix(updateList, levelList) {
373
373
  let layout;
@@ -410,15 +410,7 @@ function updateBounds(boundsList) {
410
410
  });
411
411
  }
412
412
  function updateChange(updateList) {
413
- let layout;
414
- updateList.list.forEach(leaf => {
415
- layout = leaf.__layout;
416
- if (layout.opacityChanged)
417
- updateAllWorldOpacity(leaf);
418
- if (layout.stateStyleChanged)
419
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
420
- leaf.__updateChange();
421
- });
413
+ updateList.list.forEach(updateOneChange);
422
414
  }
423
415
 
424
416
  const { worldBounds } = core.LeafBoundsHelper;
@@ -852,8 +844,10 @@ Object.assign(core.Creator, {
852
844
  core.Platform.layout = Layouter.fullLayout;
853
845
 
854
846
  function fillText(ui, canvas) {
855
- let row, data = ui.__.__textDrawData;
856
- const { rows, decorationY } = data;
847
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
848
+ if (data.__isPlacehold && data.placeholderColor)
849
+ canvas.fillStyle = data.placeholderColor;
850
+ let row;
857
851
  for (let i = 0, len = rows.length; i < len; i++) {
858
852
  row = rows[i];
859
853
  if (row.text)
@@ -862,7 +856,7 @@ function fillText(ui, canvas) {
862
856
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
863
857
  }
864
858
  if (decorationY) {
865
- const { decorationColor, decorationHeight } = data;
859
+ const { decorationColor, decorationHeight } = data.__textDrawData;
866
860
  if (decorationColor)
867
861
  canvas.fillStyle = decorationColor;
868
862
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -871,38 +865,44 @@ function fillText(ui, canvas) {
871
865
 
872
866
  function fill(fill, ui, canvas) {
873
867
  canvas.fillStyle = fill;
874
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
868
+ fillPathOrText(ui, canvas);
875
869
  }
876
870
  function fills(fills, ui, canvas) {
877
871
  let item;
878
- const { windingRule, __font } = ui.__;
879
872
  for (let i = 0, len = fills.length; i < len; i++) {
880
873
  item = fills[i];
881
- if (item.image && draw.PaintImage.checkImage(ui, canvas, item, !__font))
882
- continue;
883
- if (item.style) {
884
- canvas.fillStyle = item.style;
885
- if (item.transform) {
886
- canvas.save();
887
- canvas.transform(item.transform);
888
- if (item.blendMode)
889
- canvas.blendMode = item.blendMode;
890
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
891
- canvas.restore();
874
+ if (item.image) {
875
+ if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
876
+ continue;
877
+ if (!item.style) {
878
+ if (!i && item.image.isPlacehold)
879
+ ui.drawImagePlaceholder(canvas, item.image);
880
+ continue;
892
881
  }
893
- else {
894
- if (item.blendMode) {
895
- canvas.saveBlendMode(item.blendMode);
896
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
897
- canvas.restoreBlendMode();
898
- }
899
- else {
900
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
901
- }
882
+ }
883
+ canvas.fillStyle = item.style;
884
+ if (item.transform) {
885
+ canvas.save();
886
+ canvas.transform(item.transform);
887
+ if (item.blendMode)
888
+ canvas.blendMode = item.blendMode;
889
+ fillPathOrText(ui, canvas);
890
+ canvas.restore();
891
+ }
892
+ else {
893
+ if (item.blendMode) {
894
+ canvas.saveBlendMode(item.blendMode);
895
+ fillPathOrText(ui, canvas);
896
+ canvas.restoreBlendMode();
902
897
  }
898
+ else
899
+ fillPathOrText(ui, canvas);
903
900
  }
904
901
  }
905
902
  }
903
+ function fillPathOrText(ui, canvas) {
904
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
905
+ }
906
906
 
907
907
  function strokeText(stroke, ui, canvas) {
908
908
  const { strokeAlign } = ui.__;
@@ -1142,6 +1142,7 @@ const PaintModule = {
1142
1142
  compute,
1143
1143
  fill,
1144
1144
  fills,
1145
+ fillPathOrText,
1145
1146
  fillText,
1146
1147
  stroke,
1147
1148
  strokes,
@@ -1334,6 +1335,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1334
1335
  onLoadError(ui, event, error);
1335
1336
  leafPaint.loadId = null;
1336
1337
  });
1338
+ if (ui.placeholderColor)
1339
+ setTimeout(() => {
1340
+ if (!(image.ready || image.isPlacehold)) {
1341
+ image.isPlacehold = true;
1342
+ ui.forceUpdate('surface');
1343
+ }
1344
+ }, 100);
1337
1345
  }
1338
1346
  return leafPaint;
1339
1347
  }
@@ -2419,4 +2427,3 @@ Object.keys(draw).forEach(function (k) {
2419
2427
  get: function () { return draw[k]; }
2420
2428
  });
2421
2429
  });
2422
- //# sourceMappingURL=web.cjs.map
package/dist/web.esm.js CHANGED
@@ -368,7 +368,7 @@ class Watcher {
368
368
  }
369
369
  }
370
370
 
371
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
371
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
372
372
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
373
373
  function updateMatrix(updateList, levelList) {
374
374
  let layout;
@@ -411,15 +411,7 @@ function updateBounds(boundsList) {
411
411
  });
412
412
  }
413
413
  function updateChange(updateList) {
414
- let layout;
415
- updateList.list.forEach(leaf => {
416
- layout = leaf.__layout;
417
- if (layout.opacityChanged)
418
- updateAllWorldOpacity(leaf);
419
- if (layout.stateStyleChanged)
420
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
421
- leaf.__updateChange();
422
- });
414
+ updateList.list.forEach(updateOneChange);
423
415
  }
424
416
 
425
417
  const { worldBounds } = LeafBoundsHelper;
@@ -853,8 +845,10 @@ Object.assign(Creator, {
853
845
  Platform.layout = Layouter.fullLayout;
854
846
 
855
847
  function fillText(ui, canvas) {
856
- let row, data = ui.__.__textDrawData;
857
- const { rows, decorationY } = data;
848
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
849
+ if (data.__isPlacehold && data.placeholderColor)
850
+ canvas.fillStyle = data.placeholderColor;
851
+ let row;
858
852
  for (let i = 0, len = rows.length; i < len; i++) {
859
853
  row = rows[i];
860
854
  if (row.text)
@@ -863,7 +857,7 @@ function fillText(ui, canvas) {
863
857
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
864
858
  }
865
859
  if (decorationY) {
866
- const { decorationColor, decorationHeight } = data;
860
+ const { decorationColor, decorationHeight } = data.__textDrawData;
867
861
  if (decorationColor)
868
862
  canvas.fillStyle = decorationColor;
869
863
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -872,38 +866,44 @@ function fillText(ui, canvas) {
872
866
 
873
867
  function fill(fill, ui, canvas) {
874
868
  canvas.fillStyle = fill;
875
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
869
+ fillPathOrText(ui, canvas);
876
870
  }
877
871
  function fills(fills, ui, canvas) {
878
872
  let item;
879
- const { windingRule, __font } = ui.__;
880
873
  for (let i = 0, len = fills.length; i < len; i++) {
881
874
  item = fills[i];
882
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
883
- continue;
884
- if (item.style) {
885
- canvas.fillStyle = item.style;
886
- if (item.transform) {
887
- canvas.save();
888
- canvas.transform(item.transform);
889
- if (item.blendMode)
890
- canvas.blendMode = item.blendMode;
891
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
892
- canvas.restore();
875
+ if (item.image) {
876
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
877
+ continue;
878
+ if (!item.style) {
879
+ if (!i && item.image.isPlacehold)
880
+ ui.drawImagePlaceholder(canvas, item.image);
881
+ continue;
893
882
  }
894
- else {
895
- if (item.blendMode) {
896
- canvas.saveBlendMode(item.blendMode);
897
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
898
- canvas.restoreBlendMode();
899
- }
900
- else {
901
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
902
- }
883
+ }
884
+ canvas.fillStyle = item.style;
885
+ if (item.transform) {
886
+ canvas.save();
887
+ canvas.transform(item.transform);
888
+ if (item.blendMode)
889
+ canvas.blendMode = item.blendMode;
890
+ fillPathOrText(ui, canvas);
891
+ canvas.restore();
892
+ }
893
+ else {
894
+ if (item.blendMode) {
895
+ canvas.saveBlendMode(item.blendMode);
896
+ fillPathOrText(ui, canvas);
897
+ canvas.restoreBlendMode();
903
898
  }
899
+ else
900
+ fillPathOrText(ui, canvas);
904
901
  }
905
902
  }
906
903
  }
904
+ function fillPathOrText(ui, canvas) {
905
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
906
+ }
907
907
 
908
908
  function strokeText(stroke, ui, canvas) {
909
909
  const { strokeAlign } = ui.__;
@@ -1143,6 +1143,7 @@ const PaintModule = {
1143
1143
  compute,
1144
1144
  fill,
1145
1145
  fills,
1146
+ fillPathOrText,
1146
1147
  fillText,
1147
1148
  stroke,
1148
1149
  strokes,
@@ -1335,6 +1336,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1335
1336
  onLoadError(ui, event, error);
1336
1337
  leafPaint.loadId = null;
1337
1338
  });
1339
+ if (ui.placeholderColor)
1340
+ setTimeout(() => {
1341
+ if (!(image.ready || image.isPlacehold)) {
1342
+ image.isPlacehold = true;
1343
+ ui.forceUpdate('surface');
1344
+ }
1345
+ }, 100);
1338
1346
  }
1339
1347
  return leafPaint;
1340
1348
  }
@@ -2400,4 +2408,3 @@ Object.assign(Effect, EffectModule);
2400
2408
  useCanvas();
2401
2409
 
2402
2410
  export { Layouter, LeaferCanvas, Renderer, Watcher, useCanvas };
2403
- //# sourceMappingURL=web.esm.js.map
@@ -1,2 +1,2 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,canvasPatch as r,FileHelper as a,Creator as d,LeaferImage as l,defineKey as h,LeafList as c,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,ImageEvent as L,AroundHelper as A,PointHelper as O,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as W,ColorConvert as T,PaintGradient as M,Export as D,Group as I,TextConvert as P,Paint as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const V=t.get("LeaferCanvas");class Y 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 n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(n.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 V.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:n}=this.view;n.width=t+"px",n.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),V.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:n,y:s,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=n+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};n.copyAttrs(e,this,s),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()}}}r(CanvasRenderingContext2D.prototype),r(Path2D.prototype);const{mineType:G,fileType:N}=a;function U(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 n=G(e),s=t.toDataURL(n,i);return"image/bmp"===n?s.replace("image/png;","image/bmp;"):s},canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,G(e),i))),canvasSaveAs:(t,e,n)=>{const s=t.toDataURL(G(N(e)),n);return i.origin.download(s,e)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:t=>new Promise(((e,n)=>{const s=new i.origin.Image,{crossOrigin:o}=i.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{e(s)},s.onerror=t=>{n(t)},s.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 Y(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=n.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 c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:X,updateBounds:H,updateAllWorldOpacity: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 nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(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(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:n}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=x,a=this.getBlocks(n);a.forEach((t=>t.setBefore())),i.emitEvent(new x(s,a,this.times)),this.extraBlock=null,n.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)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||H(n[t])}H(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&Q(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new x(o,a,this.times)),i.emitEvent(new x(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),nt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(n,o,this.times)),e.emitEvent(new x(s,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(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const st=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=n.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,st.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,st.error(t)}st.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return st.warn("rendering");if(this.times>3)return st.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,n=t.getIntersect(i.bounds),s=new m(n);i.save(),n.spread(ot.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),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:n}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),this.target.__render(n,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.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||st.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(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function rt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=n;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}function at(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ht(t,!0,e,i):lt(e,i);break;case"inside":dt("inside",t,s,e,i);break;case"outside":dt("outside",t,s,e,i)}}function dt(t,e,i,n,s){const{__strokeWidth:o,__font:r}=n.__,a=s.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,n.__),a.font=r,i?ht(e,!0,n,a):lt(n,a),a.blendMode="outside"===t?"destination-out":"destination-in",rt(n,a),a.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(a,n.__nowWorld):s.copyWorldToInner(a,n.__nowWorld,n.__layout.renderBounds),a.recycle(n.__nowWorld)}function lt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function ht(t,e,i,n){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&W.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?lt(i,n):n.stroke(),n.restoreBlendMode()):e?lt(i,n):n.stroke())}function ct(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}ot.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),i.layout=nt.fullLayout;const{getSpread:ut,getOuterOf:pt,getByMove:ft,getIntersectData:gt}=R;let _t;function wt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:a}=e;return{type:s,blendMode:o,style:T.string(r,a)};case"image":return W.image(i,t,e,n,!_t||!_t[e.url]);case"linear":return M.linearGradient(e,n);case"radial":return M.radialGradient(e,n);case"angular":return M.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:T.string(e)}:void 0}}const yt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),_t=W.recycleImage(t,i);for(let i,s=0,r=o.length;s<r;s++)i=wt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?rt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)n=t[r],n.image&&W.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?rt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?rt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?rt(e,i):s?i.fill(s):i.fill())},fillText:rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)at(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&ct(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)at(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ht(t,!1,e,i),n.__useArrow&&ct(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ht(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,n),ht(t,!1,e,r),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:at,drawTextStroke:lt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,o=a=s;else{const{renderShapeSpread:n}=t.__layout,c=gt(n?ut(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:p}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=p),a=pt(s,r),o=ft(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:o,worldCanvas:d,shapeBounds:a,scaleX:l,scaleY:h}}};let mt={};const{get:vt,rotateOfOuter:xt,translate:bt,scaleOfOuter:Bt,scale:Rt,rotate:Et}=E;function kt(t,e,i,n,s,o,r){const a=vt();bt(a,e.x+i,e.y+n),Rt(a,s,o),r&&xt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function St(t,e,i,n,s,o,r){const a=vt();bt(a,e.x+i,e.y+n),s&&Rt(a,s,o),r&&Et(a,r),t.transform=a}function Lt(t,e,i,n,s,o,r,a,d,l){const h=vt();if(d)if("center"===l)xt(h,{x:i/2,y:n/2},d);else switch(Et(h,d),d){case 90:bt(h,n,0);break;case 180:bt(h,i,n);break;case 270:bt(h,0,i)}mt.x=e.x+s,mt.y=e.y+o,bt(h,mt.x,mt.y),r&&Bt(h,mt,r,a),t.transform=h}const{get:At,translate:Ot}=E,Ct=new m,Wt={},Tt={};function Mt(t,e,i,n){const{blendMode:s,changeful:o,sync:r}=i;s&&(t.blendMode=s),o&&(t.changeful=o),r&&(t.sync=r),t.data=Dt(i,n,e)}function Dt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ct.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:d,scale:l,size:h,rotation:c,repeat:u,filters:p}=t,f=e.width===n&&e.height===s,g={mode:r},_="center"!==a&&(c||0)%180==90,w=_?s:n,y=_?n:s;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(l||h)&&(k.getScaleData(l,h,i,Tt),m=Tt.scaleX,v=Tt.scaleY);else if(!f||c){const t=e.width/w,i=e.height/y;m=v="fit"===r?Math.min(t,i):Math.max(t,i),x+=(e.width-n*m)/2,b+=(e.height-s*v)/2}if(a){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),S.toPoint(a,t,e,Wt,!0),x+=Wt.x,b+=Wt.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||c)&&St(g,e,x,b,m,v,c);break;case"repeat":(!f||m||c)&&Lt(g,e,n,s,x,b,m,v,c,a),u||(g.repeat="repeat");break;default:m&&kt(g,e,x,b,m,v,c)}return g.transform||(e.x||e.y)&&(g.transform=At(),Ot(g.transform,e.x,e.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=n,g.height=s,o&&(g.opacity=o),p&&(g.filters=p),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let It,Pt=new m;const{isSame:zt}=R;function Ft(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Mt(s,n,i,o),!0}function Vt(t,e){Nt(t,L.LOAD,e)}function Yt(t,e){Nt(t,L.LOADED,e)}function Gt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,L.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Ut(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Xt}=E,{ceil:Ht,abs:Qt}=Math;function Zt(t,e,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const r=s+"-"+o+"-"+n;if(e.patternId===r||t.destroyed)return!1;{s=Qt(s),o=Qt(o);const{image:t,data:a}=e;let d,l,{width:h,height:c,scaleX:u,scaleY:p,transform:f,repeat:g}=a;u&&(l=jt(),Xt(l,f),qt(l,1/u,1/p),s*=u,o*=p),s*=n,o*=n,h*=s,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&&(s/=d,o/=d,h/=d,c/=d),u&&(s/=u,o/=p),(f||1!==s||1!==o)&&(l||(l=jt(),f&&Xt(l,f)),qt(l,1/s,1/o));const y=t.getCanvas(Ht(h)||1,Ht(c)||1,a.opacity,a.filters),m=t.getPattern(y,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=r,!0}}function $t(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{d(n.next(t))}catch(t){o(t)}}function a(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Kt}=Math;const Jt={image:function(t,e,i,n,s){let o,r;const a=B.get(i);return It&&i===It.paint&&zt(n,It.boxBounds)?o=It.leafPaint:(o={type:i.type,image:a},It=a.use>1?{leafPaint:o,paint:i,boxBounds:Pt.set(n)}:null),(s||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Ft(t,e,i,a,o,n),s&&(Vt(t,r),Yt(t,r))):a.error?s&&Gt(t,r,a.error):(s&&(Ut(t,!0),Vt(t,r)),o.loadId=a.load((()=>{Ut(t,!1),t.destroyed||(Ft(t,e,i,a,o,n)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Yt(t,r)),o.loadId=null}),(e=>{Ut(t,!1),Gt(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,n,s){const{scaleX:r,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=e,{data:l}=n;if(!l||n.patternId===r+"-"+a+"-"+d&&!D.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||o.isResizing(t)||D.running)){let{width:t,height:e}=l;t*=Kt(r)*d,e*=Kt(a)*d,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),s=t*e>i.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,e,n,l),!0):(!n.style||n.sync||D.running?Zt(t,n,d):n.patternTask||(n.patternTask=B.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){n.patternTask=null,e.bounds.hit(t.__nowWorld)&&Zt(t,n,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:Zt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,r,a;for(let d=0,l=i.length;d<l;d++)n=i[d],s=n.image,a=s&&s.url,a&&(o||(o={}),o[a]=!0,B.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===a)))));return o}return null},createData:Mt,getPatternData:Dt,fillOrFitMode:kt,clipMode:St,repeatMode:Lt},{toPoint:te}=A,ee={},ie={};function ne(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),T.string(n,i)):t.addColorStop(n.offset,T.string(n.color,i))}}const{getAngle:se,getDistance:oe}=O,{get:re,rotateOfOuter:ae,scaleOfOuter:de}=E,{toPoint:le}=A,he={},ce={};function ue(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=se(e,i);o=re(),s?(de(o,e,r/a*(n||1),1),ae(o,e,t+90)):(de(o,e,1,r/a*(n||1)),ae(o,e,t))}return o}const{getDistance:pe}=O,{toPoint:fe}=A,ge={},_e={};const we={linearGradient:function(t,e){let{from:n,to:s,type:o,blendMode:r,opacity:a}=t;te(n||"top",e,ee),te(s||"bottom",e,ie);const d=i.canvas.createLinearGradient(ee.x,ee.y,ie.x,ie.y);ne(d,t.stops,a);const l={type:o,style:d};return r&&(l.blendMode=r),l},radialGradient:function(t,e){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:d}=t;le(n||"center",e,he),le(s||"bottom",e,ce);const l=i.canvas.createRadialGradient(he.x,he.y,0,he.x,he.y,oe(he,ce));ne(l,t.stops,r);const h={type:o,style:l},c=ue(e,he,ce,d,!0);return c&&(h.transform=c),a&&(h.blendMode=a),h},conicGradient:function(t,e){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:d}=t;fe(n||"center",e,ge),fe(s||"bottom",e,_e);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,ge.x,ge.y):i.canvas.createRadialGradient(ge.x,ge.y,0,ge.x,ge.y,pe(ge,_e));ne(l,t.stops,r);const h={type:o,style:l},c=ue(e,ge,_e,d||1,i.conicGradientRotate90);return c&&(h.transform=c),a&&(h.blendMode=a),h},getTransform:ue},{copy:ye,toOffsetOutBounds:me}=R,ve={},xe={};function be(t,e,n,s){const{bounds:o,shapeBounds:r}=s;if(i.fullImageShadow){if(ye(ve,t.bounds),ve.x+=e.x-r.x,ve.y+=e.y-r.y,n){const{matrix:t}=s;ve.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),ve.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),ve.width*=n,ve.height*=n}t.copyWorld(s.canvas,t.bounds,ve)}else n&&(ye(ve,e),ve.x-=e.width/2*(n-1),ve.y-=e.height/2*(n-1),ve.width*=n,ve.height*=n),t.copyWorld(s.canvas,r,n?ve:e)}const{toOffsetOutBounds:Be}=R,Re={};const Ee={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;me(l,xe),a.forEach(((a,g)=>{p.setWorldShadow(xe.offsetX+a.x*c,xe.offsetY+a.y*u,a.blur*c,T.string(a.color)),s=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,be(p,xe,s,i),n=l,a.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,l,o,"copy"),n=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,n,o,a.blendMode):e.copyWorldToInner(p,n,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Be(l,Re),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(Re.offsetX+a.x*c,Re.offsetY+a.y*u,a.blur*c),s=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,be(p,Re,s,i),p.restore(),d?(p.copyWorld(p,l,o,"copy"),p.copyWorld(d,o,o,"source-out"),n=o):(p.copyWorld(i.canvas,h,l,"source-out"),n=l),p.fillWorld(n,T.string(a.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,n,o,a.blendMode):e.copyWorldToInner(p,n,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ke}=y;function Se(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ae(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ae(t,i,n,o);break;case"path":i.restore()}}function Le(t){return t.getSameCanvas(!1,!0)}function Ae(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}I.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],a=i.__.mask,a&&(r&&(Se(this,r,t,s,n,o),n=s=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,s||(s=Le(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=Le(t)),s||(s=Le(t)),i.__render(n,e)),"clipping"!==a&&"clipping-path"!==a)||ke(i,e)||i.__render(s||t,e);Se(this,r,t,s,n,o)};const Oe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ce=Oe+"_#~&*+\\=|≮≯≈≠=…",We=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 Te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Te(Oe),Pe=Te(Ce),ze=Te("- —/~|┆·");var Fe;!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"}(Fe||(Fe={}));const{Letter:Ve,Single:Ye,Before:Ge,After:Ne,Symbol:Ue,Break:je}=Fe;function qe(t){return Me[t]?Ve:ze[t]?je:De[t]?Ge:Ie[t]?Ne:Pe[t]?Ue:We.test(t)?Ye:Ve}const Xe={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function He(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:Qe}=Xe,{Letter:Ze,Single:$e,Before:Ke,After:Je,Symbol:ti,Break:ei}=Fe;let ii,ni,si,oi,ri,ai,di,li,hi,ci,ui,pi,fi,gi,_i,wi,yi,mi=[];function vi(t,e){hi&&!li&&(li=hi),ii.data.push({char:t,width:e}),si+=e}function xi(){oi+=si,ii.width=si,ni.words.push(ii),ii={data:[]},si=0}function bi(){gi&&(_i.paraNumber++,ni.paraStart=!0,gi=!1),hi&&(ni.startCharSize=li,ni.endCharSize=hi,li=0),ni.width=oi,wi.width?Qe(ni):yi&&Bi(),mi.push(ni),ni={words:[]},oi=0}function Bi(){oi>(_i.maxWidth||0)&&(_i.maxWidth=oi)}const{top:Ri,right:Ei,bottom:ki,left:Si}=C;function Li(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ai={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,__font:d,__padding:l}=e;l&&(o?(n=l[Si],o-=l[Ei]+l[Si]):e.autoSizeAlign||(n=l[Si]),r?(s=l[Ri],r-=l[Ri]+l[ki]):e.autoSizeAlign||(s=l[Ri]));const h={bounds:{x:n,y:s,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,n){_i=t,mi=t.rows,wi=t.bounds,yi=!wi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=i,{width:d,height:l}=wi;if(d||l||s||"none"!==r){const t="none"!==n.textWrap,i="break"===n.textWrap;gi=!0,ui=null,li=di=hi=si=oi=0,ii={data:[]},ni={words:[]};for(let n=0,l=e.length;n<l;n++)ai=e[n],"\n"===ai?(si&&xi(),ni.paraEnd=!0,bi(),gi=!0):(ci=qe(ai),ci===Ze&&"none"!==r&&(ai=He(ai,r,!si)),di=a.measureText(ai).width,s&&(s<0&&(hi=di),di+=s),pi=ci===$e&&(ui===$e||ui===Ze)||ui===$e&&ci!==Je,fi=!(ci!==Ke&&ci!==$e||ui!==ti&&ui!==Je),ri=gi&&o?d-o:d,t&&d&&oi+si+di>ri&&(i?(si&&xi(),oi&&bi()):(fi||(fi=ci===Ze&&ui==Je),pi||fi||ci===ei||ci===Ke||ci===$e||si+di>ri?(si&&xi(),oi&&bi()):oi&&bi()))," "===ai&&!0!==gi&&oi+si===0||(ci===ei?(" "===ai&&si&&xi(),vi(ai,di),xi()):pi||fi?(si&&xi(),vi(ai,di)):vi(ai,di)),ui=ci);si&&xi(),oi&&bi(),mi.length>0&&(mi[mi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{_i.paraNumber++,oi=a.measureText(t).width,mi.push({x:o||0,text:t,width:oi,paraStart:!0}),yi&&Bi()}))}(h,t,e),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Li(e,"x",t[Si]);break;case"right":Li(e,"x",-t[Ei])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Li(e,"y",t[Ri]);break;case"bottom":Li(e,"y",-t[ki])}}(l,h,e,o,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:p,y:f,width:g,height:_}=n,w=o*s+(c?c*(t.paraNumber-1):0),y=r;if(d&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":f+=(_-w)/2;break;case"bottom":f+=_-w}y+=f;let m,v,x,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(m=i[r],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&&c&&r>0&&(y+=c),m.y=y,y+=o,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),v=m.x,x=m.width,a<0&&(m.width<0?(x=-m.width+e.fontSize+a,v-=x,x+=e.fontSize):x-=a),v<n.x&&(n.x=v),x>n.width&&(n.width=x),d&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=w}(h,e),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let a,d,l,h,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,h=r||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!r&&(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,a=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):a=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(a+=d,t.width+=d)}))),t.words=null)}))}(h,e,o),h.overflow&&function(t,e,n,s){if(!s)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,d;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,h=n+s-l;("none"===e.textWrap?o:[o[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e,n,o),"none"!==a&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=T.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(h,e),h}};const Oi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!T.object)return t;t=T.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(P,Ai),Object.assign(T,Oi),Object.assign(z,yt),Object.assign(W,Jt),Object.assign(M,we),Object.assign(F,Ee),U();export{nt as Layouter,Y as LeaferCanvas,ot as Renderer,q as Watcher,U as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,canvasPatch as r,FileHelper as a,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,ImageEvent as L,AroundHelper as A,PointHelper as O,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as W,ColorConvert as T,PaintGradient as M,Export as D,Group as P,TextConvert as I,Paint as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const V=t.get("LeaferCanvas");class Y 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 n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(n.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 V.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:n}=this.view;n.width=t+"px",n.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),V.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:n,y:s,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=n+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};n.copyAttrs(e,this,s),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()}}}r(CanvasRenderingContext2D.prototype),r(Path2D.prototype);const{mineType:U,fileType:G}=a;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 n=U(e),s=t.toDataURL(n,i);return"image/bmp"===n?s.replace("image/png;","image/bmp;"):s},canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,U(e),i))),canvasSaveAs:(t,e,n)=>{const s=t.toDataURL(U(G(e)),n);return i.origin.download(s,e)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:t=>new Promise(((e,n)=>{const s=new i.origin.Image,{crossOrigin:o}=i.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{e(s)},s.onerror=t=>{n(t)},s.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 Y(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: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 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=n.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=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix: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 h(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 nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(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(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:n}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=x,a=this.getBlocks(n);a.forEach((t=>t.setBefore())),i.emitEvent(new x(s,a,this.times)),this.extraBlock=null,n.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)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||H(n[t])}H(i)}}))}(this.__levelList),function(t){t.list.forEach(Q)}(n),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new x(o,a,this.times)),i.emitEvent(new x(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=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(n,o,this.times)),e.emitEvent(new x(s,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(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const st=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=n.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,st.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,st.error(t)}st.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return st.warn("rendering");if(this.times>3)return st.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,n=t.getIntersect(i.bounds),s=new m(n);i.save(),n.spread(ot.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),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:n}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),this.target.__render(n,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.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||st.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(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function rt(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[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(s){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function at(t,e){t.__.__font?rt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function dt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ht(t,!0,e,i):ct(e,i);break;case"inside":lt("inside",t,s,e,i);break;case"outside":lt("outside",t,s,e,i)}}function lt(t,e,i,n,s){const{__strokeWidth:o,__font:r}=n.__,a=s.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,n.__),a.font=r,i?ht(e,!0,n,a):ct(n,a),a.blendMode="outside"===t?"destination-out":"destination-in",rt(n,a),a.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(a,n.__nowWorld):s.copyWorldToInner(a,n.__nowWorld,n.__layout.renderBounds),a.recycle(n.__nowWorld)}function ct(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function ht(t,e,i,n){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&W.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ct(i,n):n.stroke(),n.restoreBlendMode()):e?ct(i,n):n.stroke())}function ut(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}ot.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),i.layout=nt.fullLayout;const{getSpread:pt,getOuterOf:ft,getByMove:gt,getIntersectData:_t}=R;let wt;function yt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:a}=e;return{type:s,blendMode:o,style:T.string(r,a)};case"image":return W.image(i,t,e,n,!wt||!wt[e.url]);case"linear":return M.linearGradient(e,n);case"radial":return M.radialGradient(e,n);case"angular":return M.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:T.string(e)}:void 0}}const mt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),wt=W.recycleImage(t,i);for(let i,s=0,r=o.length;s<r;s++)i=yt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,at(e,i)},fills:function(t,e,i){let n;for(let s=0,o=t.length;s<o;s++){if(n=t[s],n.image){if(W.checkImage(e,i,n,!e.__.__font))continue;if(!n.style){!s&&n.image.isPlacehold&&e.drawImagePlaceholder(i,n.image);continue}}i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),at(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),at(e,i),i.restoreBlendMode()):at(e,i)}},fillPathOrText:at,fillText:rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)dt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&ut(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)dt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ht(t,!1,e,i),n.__useArrow&&ut(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ht(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,n),ht(t,!1,e,r),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:dt,drawTextStroke:ct,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=a=s;else{const{renderShapeSpread:n}=t.__layout,h=_t(n?pt(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(h);let{a:u,d:p}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=p),a=ft(s,r),o=gt(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:o,worldCanvas:d,shapeBounds:a,scaleX:l,scaleY:c}}};let vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:Et,rotate:kt}=E;function St(t,e,i,n,s,o,r){const a=xt();Bt(a,e.x+i,e.y+n),Et(a,s,o),r&&bt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Lt(t,e,i,n,s,o,r){const a=xt();Bt(a,e.x+i,e.y+n),s&&Et(a,s,o),r&&kt(a,r),t.transform=a}function At(t,e,i,n,s,o,r,a,d,l){const c=xt();if(d)if("center"===l)bt(c,{x:i/2,y:n/2},d);else switch(kt(c,d),d){case 90:Bt(c,n,0);break;case 180:Bt(c,i,n);break;case 270:Bt(c,0,i)}vt.x=e.x+s,vt.y=e.y+o,Bt(c,vt.x,vt.y),r&&Rt(c,vt,r,a),t.transform=c}const{get:Ot,translate:Ct}=E,Wt=new m,Tt={},Mt={};function Dt(t,e,i,n){const{blendMode:s,changeful:o,sync:r}=i;s&&(t.blendMode=s),o&&(t.changeful=o),r&&(t.sync=r),t.data=Pt(i,n,e)}function Pt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Wt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:d,scale:l,size:c,rotation:h,repeat:u,filters:p}=t,f=e.width===n&&e.height===s,g={mode:r},_="center"!==a&&(h||0)%180==90,w=_?s:n,y=_?n:s;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(l||c)&&(k.getScaleData(l,c,i,Mt),m=Mt.scaleX,v=Mt.scaleY);else if(!f||h){const t=e.width/w,i=e.height/y;m=v="fit"===r?Math.min(t,i):Math.max(t,i),x+=(e.width-n*m)/2,b+=(e.height-s*v)/2}if(a){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),S.toPoint(a,t,e,Tt,!0),x+=Tt.x,b+=Tt.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||h)&&Lt(g,e,x,b,m,v,h);break;case"repeat":(!f||m||h)&&At(g,e,n,s,x,b,m,v,h,a),u||(g.repeat="repeat");break;default:m&&St(g,e,x,b,m,v,h)}return g.transform||(e.x||e.y)&&(g.transform=Ot(),Ct(g.transform,e.x,e.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=n,g.height=s,o&&(g.opacity=o),p&&(g.filters=p),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let It,zt=new m;const{isSame:Ft}=R;function Vt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Dt(s,n,i,o),!0}function Yt(t,e){Nt(t,L.LOAD,e)}function Ut(t,e){Nt(t,L.LOADED,e)}function Gt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,L.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:qt,scale:Xt,copy:Ht}=E,{ceil:Qt,abs:Zt}=Math;function $t(t,e,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const r=s+"-"+o+"-"+n;if(e.patternId===r||t.destroyed)return!1;{s=Zt(s),o=Zt(o);const{image:t,data:a}=e;let d,l,{width:c,height:h,scaleX:u,scaleY:p,transform:f,repeat:g}=a;u&&(l=qt(),Ht(l,f),Xt(l,1/u,1/p),s*=u,o*=p),s*=n,o*=n,c*=s,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&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=p),(f||1!==s||1!==o)&&(l||(l=qt(),f&&Ht(l,f)),Xt(l,1/s,1/o));const y=t.getCanvas(Qt(c)||1,Qt(h)||1,a.opacity,a.filters),m=t.getPattern(y,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=r,!0}}function Kt(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{d(n.next(t))}catch(t){o(t)}}function a(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Jt}=Math;const te={image:function(t,e,i,n,s){let o,r;const a=B.get(i);return It&&i===It.paint&&Ft(n,It.boxBounds)?o=It.leafPaint:(o={type:i.type,image:a},It=a.use>1?{leafPaint:o,paint:i,boxBounds:zt.set(n)}:null),(s||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Vt(t,e,i,a,o,n),s&&(Yt(t,r),Ut(t,r))):a.error?s&&Gt(t,r,a.error):(s&&(jt(t,!0),Yt(t,r)),o.loadId=a.load((()=>{jt(t,!1),t.destroyed||(Vt(t,e,i,a,o,n)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ut(t,r)),o.loadId=null}),(e=>{jt(t,!1),Gt(t,r,e),o.loadId=null})),t.placeholderColor&&setTimeout((()=>{a.ready||a.isPlacehold||(a.isPlacehold=!0,t.forceUpdate("surface"))}),100)),o},checkImage:function(t,e,n,s){const{scaleX:r,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=e,{data:l}=n;if(!l||n.patternId===r+"-"+a+"-"+d&&!D.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||o.isResizing(t)||D.running)){let{width:t,height:e}=l;t*=Jt(r)*d,e*=Jt(a)*d,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),s=t*e>i.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,e,n,l),!0):(!n.style||n.sync||D.running?$t(t,n,d):n.patternTask||(n.patternTask=B.patternTasker.add((()=>Kt(this,void 0,void 0,(function*(){n.patternTask=null,e.bounds.hit(t.__nowWorld)&&$t(t,n,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:$t,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,r,a;for(let d=0,l=i.length;d<l;d++)n=i[d],s=n.image,a=s&&s.url,a&&(o||(o={}),o[a]=!0,B.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===a)))));return o}return null},createData:Dt,getPatternData:Pt,fillOrFitMode:St,clipMode:Lt,repeatMode:At},{toPoint:ee}=A,ie={},ne={};function se(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),T.string(n,i)):t.addColorStop(n.offset,T.string(n.color,i))}}const{getAngle:oe,getDistance:re}=O,{get:ae,rotateOfOuter:de,scaleOfOuter:le}=E,{toPoint:ce}=A,he={},ue={};function pe(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=oe(e,i);o=ae(),s?(le(o,e,r/a*(n||1),1),de(o,e,t+90)):(le(o,e,1,r/a*(n||1)),de(o,e,t))}return o}const{getDistance:fe}=O,{toPoint:ge}=A,_e={},we={};const ye={linearGradient:function(t,e){let{from:n,to:s,type:o,blendMode:r,opacity:a}=t;ee(n||"top",e,ie),ee(s||"bottom",e,ne);const d=i.canvas.createLinearGradient(ie.x,ie.y,ne.x,ne.y);se(d,t.stops,a);const l={type:o,style:d};return r&&(l.blendMode=r),l},radialGradient:function(t,e){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:d}=t;ce(n||"center",e,he),ce(s||"bottom",e,ue);const l=i.canvas.createRadialGradient(he.x,he.y,0,he.x,he.y,re(he,ue));se(l,t.stops,r);const c={type:o,style:l},h=pe(e,he,ue,d,!0);return h&&(c.transform=h),a&&(c.blendMode=a),c},conicGradient:function(t,e){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:d}=t;ge(n||"center",e,_e),ge(s||"bottom",e,we);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,_e.x,_e.y):i.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,fe(_e,we));se(l,t.stops,r);const c={type:o,style:l},h=pe(e,_e,we,d||1,i.conicGradientRotate90);return h&&(c.transform=h),a&&(c.blendMode=a),c},getTransform:pe},{copy:me,toOffsetOutBounds:ve}=R,xe={},be={};function Be(t,e,n,s){const{bounds:o,shapeBounds:r}=s;if(i.fullImageShadow){if(me(xe,t.bounds),xe.x+=e.x-r.x,xe.y+=e.y-r.y,n){const{matrix:t}=s;xe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),xe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),xe.width*=n,xe.height*=n}t.copyWorld(s.canvas,t.bounds,xe)}else n&&(me(xe,e),xe.x-=e.width/2*(n-1),xe.y-=e.height/2*(n-1),xe.width*=n,xe.height*=n),t.copyWorld(s.canvas,r,n?xe:e)}const{toOffsetOutBounds:Re}=R,Ee={};const ke={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;ve(l,be),a.forEach(((a,g)=>{p.setWorldShadow(be.offsetX+a.x*h,be.offsetY+a.y*u,a.blur*h,T.string(a.color)),s=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Be(p,be,s,i),n=l,a.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,l,o,"copy"),n=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,n,o,a.blendMode):e.copyWorldToInner(p,n,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Re(l,Ee),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(Ee.offsetX+a.x*h,Ee.offsetY+a.y*u,a.blur*h),s=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Be(p,Ee,s,i),p.restore(),d?(p.copyWorld(p,l,o,"copy"),p.copyWorld(d,o,o,"source-out"),n=o):(p.copyWorld(i.canvas,c,l,"source-out"),n=l),p.fillWorld(n,T.string(a.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,n,o,a.blendMode):e.copyWorldToInner(p,n,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Se}=y;function Le(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Oe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Oe(t,i,n,o);break;case"path":i.restore()}}function Ae(t){return t.getSameCanvas(!1,!0)}function Oe(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}P.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],a=i.__.mask,a&&(r&&(Le(this,r,t,s,n,o),n=s=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,s||(s=Ae(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=Ae(t)),s||(s=Ae(t)),i.__render(n,e)),"clipping"!==a&&"clipping-path"!==a)||Se(i,e)||i.__render(s||t,e);Le(this,r,t,s,n,o)};const Ce=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",We=Ce+"_#~&*+\\=|≮≯≈≠=…",Te=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const De=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Pe=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Me(Ce),ze=Me(We),Fe=Me("- —/~|┆·");var Ve;!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"}(Ve||(Ve={}));const{Letter:Ye,Single:Ue,Before:Ge,After:Ne,Symbol:je,Break:qe}=Ve;function Xe(t){return De[t]?Ye:Fe[t]?qe:Pe[t]?Ge:Ie[t]?Ne:ze[t]?je:Te.test(t)?Ue:Ye}const He={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Qe(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:Ze}=He,{Letter:$e,Single:Ke,Before:Je,After:ti,Symbol:ei,Break:ii}=Ve;let ni,si,oi,ri,ai,di,li,ci,hi,ui,pi,fi,gi,_i,wi,yi,mi,vi=[];function xi(t,e){hi&&!ci&&(ci=hi),ni.data.push({char:t,width:e}),oi+=e}function bi(){ri+=oi,ni.width=oi,si.words.push(ni),ni={data:[]},oi=0}function Bi(){_i&&(wi.paraNumber++,si.paraStart=!0,_i=!1),hi&&(si.startCharSize=ci,si.endCharSize=hi,ci=0),si.width=ri,yi.width?Ze(si):mi&&Ri(),vi.push(si),si={words:[]},ri=0}function Ri(){ri>(wi.maxWidth||0)&&(wi.maxWidth=ri)}const{top:Ei,right:ki,bottom:Si,left:Li}=C;function Ai(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Oi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,__font:d,__padding:l}=e;l&&(o?(n=l[Li],o-=l[ki]+l[Li]):e.autoSizeAlign||(n=l[Li]),r?(s=l[Ei],r-=l[Ei]+l[Si]):e.autoSizeAlign||(s=l[Ei]));const c={bounds:{x:n,y:s,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,n){wi=t,vi=t.rows,yi=t.bounds,mi=!yi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=i,{width:d,height:l}=yi;if(d||l||s||"none"!==r){const t="none"!==n.textWrap,i="break"===n.textWrap;_i=!0,pi=null,ci=li=hi=oi=ri=0,ni={data:[]},si={words:[]};for(let n=0,l=e.length;n<l;n++)di=e[n],"\n"===di?(oi&&bi(),si.paraEnd=!0,Bi(),_i=!0):(ui=Xe(di),ui===$e&&"none"!==r&&(di=Qe(di,r,!oi)),li=a.measureText(di).width,s&&(s<0&&(hi=li),li+=s),fi=ui===Ke&&(pi===Ke||pi===$e)||pi===Ke&&ui!==ti,gi=!(ui!==Je&&ui!==Ke||pi!==ei&&pi!==ti),ai=_i&&o?d-o:d,t&&d&&ri+oi+li>ai&&(i?(oi&&bi(),ri&&Bi()):(gi||(gi=ui===$e&&pi==ti),fi||gi||ui===ii||ui===Je||ui===Ke||oi+li>ai?(oi&&bi(),ri&&Bi()):ri&&Bi()))," "===di&&!0!==_i&&ri+oi===0||(ui===ii?(" "===di&&oi&&bi(),xi(di,li),bi()):fi||gi?(oi&&bi(),xi(di,li)):xi(di,li)),pi=ui);oi&&bi(),ri&&Bi(),vi.length>0&&(vi[vi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{wi.paraNumber++,ri=a.measureText(t).width,vi.push({x:o||0,text:t,width:ri,paraStart:!0}),mi&&Ri()}))}(c,t,e),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ai(e,"x",t[Li]);break;case"right":Ai(e,"x",-t[ki])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ai(e,"y",t[Ei]);break;case"bottom":Ai(e,"y",-t[Si])}}(l,c,e,o,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:p,y:f,width:g,height:_}=n,w=o*s+(h?h*(t.paraNumber-1):0),y=r;if(d&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);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 r=0,c=s;r<c;r++){if(m=i[r],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&&r>0&&(y+=h),m.y=y,y+=o,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),v=m.x,x=m.width,a<0&&(m.width<0?(x=-m.width+e.fontSize+a,v-=x,x+=e.fontSize):x-=a),v<n.x&&(n.x=v),x>n.width&&(n.width=x),d&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=w}(c,e),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let a,d,l,c,h,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:d>.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?(h={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):a=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(a+=d,t.width+=d)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,n,s){if(!s)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,d;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=n+s-l;("none"===e.textWrap?o:[o[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,e,n,o),"none"!==a&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=T.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(c,e),c}};const Ci={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!T.object)return t;t=T.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(I,Oi),Object.assign(T,Ci),Object.assign(z,mt),Object.assign(W,te),Object.assign(M,ye),Object.assign(F,ke),N();export{nt as Layouter,Y as LeaferCanvas,ot as Renderer,q as Watcher,N as useCanvas};
2
2
  //# sourceMappingURL=web.esm.min.js.map