@leafer-draw/miniapp 1.0.6 → 1.0.8

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/miniapp.cjs CHANGED
@@ -112,7 +112,10 @@ Object.assign(core.Creator, {
112
112
  });
113
113
  function useCanvas(_canvasType, app) {
114
114
  core.Platform.origin = {
115
- createCanvas: (width, height, _format) => app.createOffscreenCanvas({ type: '2d', width, height }),
115
+ createCanvas: (width, height, _format) => {
116
+ const data = { type: '2d', width, height };
117
+ app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
118
+ },
116
119
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
117
120
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
118
121
  canvasSaveAs: (canvas, filePath, quality) => {
@@ -816,14 +819,10 @@ function fillText(ui, canvas) {
816
819
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
817
820
  for (let i = 0, len = rows.length; i < len; i++) {
818
821
  row = rows[i];
819
- if (row.text) {
822
+ if (row.text)
820
823
  canvas.fillText(row.text, row.x, row.y);
821
- }
822
- else if (row.data) {
823
- row.data.forEach(charData => {
824
- canvas.fillText(charData.char, charData.x, row.y);
825
- });
826
- }
824
+ else if (row.data)
825
+ row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
827
826
  if (decorationY)
828
827
  canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
829
828
  }
@@ -889,12 +888,10 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
889
888
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
890
889
  fillText(ui, out);
891
890
  out.blendMode = 'normal';
892
- if (ui.__worldFlipped) {
891
+ if (ui.__worldFlipped)
893
892
  canvas.copyWorldByReset(out, ui.__nowWorld);
894
- }
895
- else {
893
+ else
896
894
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
897
- }
898
895
  out.recycle(ui.__nowWorld);
899
896
  }
900
897
  function drawTextStroke(ui, canvas) {
@@ -902,14 +899,10 @@ function drawTextStroke(ui, canvas) {
902
899
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
903
900
  for (let i = 0, len = rows.length; i < len; i++) {
904
901
  row = rows[i];
905
- if (row.text) {
902
+ if (row.text)
906
903
  canvas.strokeText(row.text, row.x, row.y);
907
- }
908
- else if (row.data) {
909
- row.data.forEach(charData => {
910
- canvas.strokeText(charData.char, charData.x, row.y);
911
- });
912
- }
904
+ else if (row.data)
905
+ row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
913
906
  if (decorationY)
914
907
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
915
908
  }
@@ -962,12 +955,10 @@ function stroke(stroke, ui, canvas) {
962
955
  out.stroke();
963
956
  options.windingRule ? out.clip(options.windingRule) : out.clip();
964
957
  out.clearWorld(ui.__layout.renderBounds);
965
- if (ui.__worldFlipped) {
958
+ if (ui.__worldFlipped)
966
959
  canvas.copyWorldByReset(out, ui.__nowWorld);
967
- }
968
- else {
960
+ else
969
961
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
970
- }
971
962
  out.recycle(ui.__nowWorld);
972
963
  break;
973
964
  }
@@ -1002,12 +993,10 @@ function strokes(strokes, ui, canvas) {
1002
993
  drawStrokesStyle(strokes, false, ui, out);
1003
994
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1004
995
  out.clearWorld(renderBounds);
1005
- if (ui.__worldFlipped) {
996
+ if (ui.__worldFlipped)
1006
997
  canvas.copyWorldByReset(out, ui.__nowWorld);
1007
- }
1008
- else {
998
+ else
1009
999
  canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
1010
- }
1011
1000
  out.recycle(ui.__nowWorld);
1012
1001
  break;
1013
1002
  }
@@ -1071,12 +1060,7 @@ function compute(attrName, ui) {
1071
1060
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
1072
1061
  if (leafPaints.length && leafPaints[0].image)
1073
1062
  hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
1074
- if (attrName === 'fill') {
1075
- data.__pixelFill = hasOpacityPixel;
1076
- }
1077
- else {
1078
- data.__pixelStroke = hasOpacityPixel;
1079
- }
1063
+ attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
1080
1064
  }
1081
1065
  function getLeafPaint(attrName, paint, ui) {
1082
1066
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
@@ -113,7 +113,10 @@ Object.assign(Creator, {
113
113
  });
114
114
  function useCanvas(_canvasType, app) {
115
115
  Platform.origin = {
116
- createCanvas: (width, height, _format) => app.createOffscreenCanvas({ type: '2d', width, height }),
116
+ createCanvas: (width, height, _format) => {
117
+ const data = { type: '2d', width, height };
118
+ app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
119
+ },
117
120
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
118
121
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
119
122
  canvasSaveAs: (canvas, filePath, quality) => {
@@ -817,14 +820,10 @@ function fillText(ui, canvas) {
817
820
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
818
821
  for (let i = 0, len = rows.length; i < len; i++) {
819
822
  row = rows[i];
820
- if (row.text) {
823
+ if (row.text)
821
824
  canvas.fillText(row.text, row.x, row.y);
822
- }
823
- else if (row.data) {
824
- row.data.forEach(charData => {
825
- canvas.fillText(charData.char, charData.x, row.y);
826
- });
827
- }
825
+ else if (row.data)
826
+ row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
828
827
  if (decorationY)
829
828
  canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
830
829
  }
@@ -890,12 +889,10 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
890
889
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
891
890
  fillText(ui, out);
892
891
  out.blendMode = 'normal';
893
- if (ui.__worldFlipped) {
892
+ if (ui.__worldFlipped)
894
893
  canvas.copyWorldByReset(out, ui.__nowWorld);
895
- }
896
- else {
894
+ else
897
895
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
898
- }
899
896
  out.recycle(ui.__nowWorld);
900
897
  }
901
898
  function drawTextStroke(ui, canvas) {
@@ -903,14 +900,10 @@ function drawTextStroke(ui, canvas) {
903
900
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
904
901
  for (let i = 0, len = rows.length; i < len; i++) {
905
902
  row = rows[i];
906
- if (row.text) {
903
+ if (row.text)
907
904
  canvas.strokeText(row.text, row.x, row.y);
908
- }
909
- else if (row.data) {
910
- row.data.forEach(charData => {
911
- canvas.strokeText(charData.char, charData.x, row.y);
912
- });
913
- }
905
+ else if (row.data)
906
+ row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
914
907
  if (decorationY)
915
908
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
916
909
  }
@@ -963,12 +956,10 @@ function stroke(stroke, ui, canvas) {
963
956
  out.stroke();
964
957
  options.windingRule ? out.clip(options.windingRule) : out.clip();
965
958
  out.clearWorld(ui.__layout.renderBounds);
966
- if (ui.__worldFlipped) {
959
+ if (ui.__worldFlipped)
967
960
  canvas.copyWorldByReset(out, ui.__nowWorld);
968
- }
969
- else {
961
+ else
970
962
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
971
- }
972
963
  out.recycle(ui.__nowWorld);
973
964
  break;
974
965
  }
@@ -1003,12 +994,10 @@ function strokes(strokes, ui, canvas) {
1003
994
  drawStrokesStyle(strokes, false, ui, out);
1004
995
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1005
996
  out.clearWorld(renderBounds);
1006
- if (ui.__worldFlipped) {
997
+ if (ui.__worldFlipped)
1007
998
  canvas.copyWorldByReset(out, ui.__nowWorld);
1008
- }
1009
- else {
999
+ else
1010
1000
  canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
1011
- }
1012
1001
  out.recycle(ui.__nowWorld);
1013
1002
  break;
1014
1003
  }
@@ -1072,12 +1061,7 @@ function compute(attrName, ui) {
1072
1061
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
1073
1062
  if (leafPaints.length && leafPaints[0].image)
1074
1063
  hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
1075
- if (attrName === 'fill') {
1076
- data.__pixelFill = hasOpacityPixel;
1077
- }
1078
- else {
1079
- data.__pixelStroke = hasOpacityPixel;
1080
- }
1064
+ attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
1081
1065
  }
1082
1066
  function getLeafPaint(attrName, paint, ui) {
1083
1067
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as d,FileHelper as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as S,MathHelper as k,AlignHelper as E,ImageEvent as A,AroundHelper as L,PointHelper as W,Direction4 as T,TwoPointBoundsHelper as O,TaskProcessor as C,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as z,Group as F,TextConvert as Y,Paint as U,Effect as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:s,pixelRatio:o}=this.config,a={width:n||t.width,height:s||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:N,fileType:G}=l;function j(t,i){e.origin={createCanvas:(t,e,n)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(N(G(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new X(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},d(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});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(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.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:H,updateBounds:Q,updateAllWorldOpacity:J}=g,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:K}=m,tt={x:0,y:0,width:1e5,height:1e5};class et{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(tt):this.afterBounds.setListWithFn(t,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:it,updateAllChange:nt}=g,st=y.get("Layouter");class ot{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){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:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new x(s,r,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?(H(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||Q(n[t])}Q(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&J(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),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:n,AFTER:s}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),ot.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){it(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new et([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new et(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 at=y.get("Renderer");class rt{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(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,at.log(e.innerName,"---\x3e");try{e.app.emit(h.CHILD_START,e),this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");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=t.includes(this.target.__world),o=new w(n);i.save(),s&&!y.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(n),y.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(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 w(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||at.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 h(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(h.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 dt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[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)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function lt(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?ut(t,!0,e,i):ht(e,i);break;case"inside":ct("inside",t,s,e,i);break;case"outside":ct("outside",t,s,e,i)}}function ct(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ut(e,!0,n,r):ht(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",dt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ht(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ut(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ht(i,n):n.stroke(),n.restoreBlendMode()):e?ht(i,n):n.stroke())}Object.assign(a,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=ot.fullLayout;const{getSpread:ft,getOuterOf:pt,getByMove:gt,getIntersectData:_t}=R;let wt;function mt(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:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return P.image(i,t,e,n,!wt||!wt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.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]),wt=P.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=mt(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?dt(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 a=0,r=t.length;a<r;a++)n=t[a],n.image&&P.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?dt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?dt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?dt(e,i):s?i.fill(s):i.fill())},fillText:dt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)lt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke();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:a}=n;if(s)if(a)lt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ut(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ut(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ut(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:lt,drawTextStroke:ht,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=_t(n?ft(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=pt(s,a),o=gt(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(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:St,rotate:kt}=S;function Et(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),St(r,s,o),a&&bt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function At(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),s&&St(r,s,o),a&&kt(r,a),t.transform=r}function Lt(t,e,i,n,s,o,a,r,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),a&&Rt(c,vt,a,r),t.transform=c}const{get:Wt,translate:Tt}=S,Ot=new w,Ct={},Mt={};function Pt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Dt(i,n,e)}function Dt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ot.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,i,Mt),m=Mt.scaleX,y=Mt.scaleY);else if(!f||h){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,x+=(e.height-s*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),E.toPoint(r,t,e,Ct,!0),v+=Ct.x,x+=Ct.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||m||h)&&At(p,e,v,x,m,y,h);break;case"repeat":(!f||m||h)&&Lt(p,e,n,s,v,x,m,y,h,r),u||(p.repeat="repeat");break;default:m&&Et(p,e,v,x,m,y,h)}return p.transform||(e.x||e.y)&&(p.transform=Wt(),Tt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=y),p.width=n,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let It,zt=new w;const{isSame:Ft}=R;function Yt(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||Pt(s,n,i,o),!0}function Ut(t,e){Nt(t,A.LOAD,e)}function Vt(t,e){Nt(t,A.LOADED,e)}function Xt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,A.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Gt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Ht}=S,{ceil:Qt,abs:Jt}=Math;function Zt(t,i,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=Jt(s),o=Jt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=jt(),Ht(l,g),qt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=jt(),g&&Ht(l,g)),qt(l,1/s,1/o));const y=t.getCanvas(Qt(c)||1,Qt(h)||1,p),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function $t(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(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(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Kt}=Math;const te={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return It&&i===It.paint&&Ft(n,It.boxBounds)?o=It.leafPaint:(o={type:i.type,image:r},It=r.use>1?{leafPaint:o,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Yt(t,e,i,r,o,n),s&&(Ut(t,a),Vt(t,a))):r.error?s&&Xt(t,a,r.error):(s&&(Gt(t,!0),Ut(t,a)),o.loadId=r.load((()=>{Gt(t,!1),t.destroyed||(Yt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Vt(t,a)),o.loadId=null}),(e=>{Gt(t,!1),Xt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!z.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=Kt(o)*r,i*=Kt(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||z.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||z.running?Zt(t,n,r):n.patternTask||(n.patternTask=B.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Zt(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Zt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,B.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Pt,getPatternData:Dt,fillOrFitMode:Et,clipMode:At,repeatMode:Lt},{toPoint:ee}=L,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),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:oe,getDistance:ae}=W,{get:re,rotateOfOuter:de,scaleOfOuter:le}=S,{toPoint:ce}=L,he={},ue={};function fe(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=oe(e,i);o=re(),s?(le(o,e,a/r*(n||1),1),de(o,e,t+90)):(le(o,e,1,a/r*(n||1)),de(o,e,t))}return o}const{getDistance:pe}=W,{toPoint:ge}=L,_e={},we={};const me={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ee(n||"top",i,ie),ee(s||"bottom",i,ne);const d=e.canvas.createLinearGradient(ie.x,ie.y,ne.x,ne.y);se(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ce(n||"center",i,he),ce(s||"bottom",i,ue);const l=e.canvas.createRadialGradient(he.x,he.y,0,he.x,he.y,ae(he,ue));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,he,ue,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ge(n||"center",i,_e),ge(s||"bottom",i,we);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,_e.x,_e.y):e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,pe(_e,we));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,_e,we,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:fe},{copy:ye,toOffsetOutBounds:ve}=R,xe={},be={};function Be(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ye(xe,t.bounds),xe.x+=i.x-a.x,xe.y+=i.y-a.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&&(ye(xe,i),xe.x-=i.width/2*(n-1),xe.y-=i.height/2*(n-1),xe.width*=n,xe.height*=n),t.copyWorld(s.canvas,a,n?xe:i)}const{toOffsetOutBounds:Re}=R,Se={};const ke={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ve(l,be),r.forEach(((r,g)=>{f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,be,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Re(l,Se),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Se.offsetX+r.x*h,Se.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,Se,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.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:Ee}=m;function Ae(t,e,i,n,s,o){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),We(t,e,i,1)}(t,i,n,s);break;case"opacity-path":We(t,i,n,o);break;case"path":i.restore()}}function Le(t){return t.getSameCanvas(!1,!0)}function We(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Ae(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Le(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Le(t)),s||(s=Le(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Ee(i,e)||i.__render(s||t,e);Ae(this,a,t,s,n,o)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Oe=Te+"_#~&*+\\=|≮≯≈≠=…",Ce=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 Pe=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Me(Te),ze=Me(Oe),Fe=Me("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:Ue,Single:Ve,Before:Xe,After:Ne,Symbol:Ge,Break:je}=Ye;function qe(t){return Pe[t]?Ue:Fe[t]?je:De[t]?Xe:Ie[t]?Ne:ze[t]?Ge:Ce.test(t)?Ve:Ue}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:Je}=He,{Letter:Ze,Single:$e,Before:Ke,After:ti,Symbol:ei,Break:ii}=Ye;let ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi,mi,yi,vi=[];function xi(t,e){hi&&!ci&&(ci=hi),ni.data.push({char:t,width:e}),oi+=e}function bi(){ai+=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=ai,mi.width?Je(si):yi&&Ri(),vi.push(si),si={words:[]},ai=0}function Ri(){ai>(wi.maxWidth||0)&&(wi.maxWidth=ai)}const Si=0,ki=1,Ei=2;const{top:Ai,right:Li,bottom:Wi,left:Ti}=T;function Oi(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 Ci={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o?(n=l[Ti],o-=l[Li]+l[Ti]):i.autoSizeAlign||(n=l[Ti]),a?(s=l[Ai],a-=l[Ai]+l[Wi]):i.autoSizeAlign||(s=l[Ai]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){wi=t,vi=t.rows,mi=t.bounds,yi=!mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=mi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;_i=!0,fi=null,ci=li=hi=oi=ai=0,ni={data:[]},si={words:[]};for(let n=0,l=i.length;n<l;n++)di=i[n],"\n"===di?(oi&&bi(),si.paraEnd=!0,Bi(),_i=!0):(ui=qe(di),ui===Ze&&"none"!==a&&(di=Qe(di,a,!oi)),li=r.measureText(di).width,s&&(s<0&&(hi=li),li+=s),pi=ui===$e&&(fi===$e||fi===Ze)||fi===$e&&ui!==ti,gi=!(ui!==Ke&&ui!==$e||fi!==ei&&fi!==ti),ri=_i&&o?d-o:d,t&&d&&ai+oi+li>ri&&(e?(oi&&bi(),ai&&Bi()):(gi||(gi=ui===Ze&&fi==ti),pi||gi||ui===ii||ui===Ke||ui===$e||oi+li>ri?(oi&&bi(),ai&&Bi()):ai&&Bi()))," "===di&&!0!==_i&&ai+oi===0||(ui===ii?(" "===di&&oi&&bi(),xi(di,li),bi()):pi||gi?(oi&&bi(),xi(di,li)):xi(di,li)),fi=ui);oi&&bi(),ai&&Bi(),vi.length>0&&(vi[vi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{wi.paraNumber++,ai=r.measureText(t).width,vi.push({x:o||0,text:t,width:ai,paraStart:!0}),yi&&Ri()}))}(c,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Oi(e,"x",t[Ti]);break;case"right":Oi(e,"x",-t[Li])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Oi(e,"y",t[Ai]);break;case"bottom":Oi(e,"y",-t[Wi])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=n,_=s*i.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=i.length;else if(g||h)switch(l){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(m=i[o],m.x=u,m.width<p||m.width>p&&!r)switch(d){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<n.x&&(n.x=y),v>n.width&&(n.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=_}(c,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Si:l>.01?ki:Ei,t.isOverflow&&!r&&(t.textMode=!0),h===Ei?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===ki?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.textWrap?o:[o[a-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){e.data.splice(n+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,i,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,i),c}};const Mi={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 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+")"}},{setPoint:Pi,addPoint:Di,toBounds:Ii}=O;const zi={export(t,i,n){this.running=!0;const s=l.fileType(i),o=i.includes(".");return n=l.getExportOptions(n),function(t){Fi||(Fi=new C);return new Promise((e=>{Fi.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const c=t=>{r(t),d(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),i),c({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),i),c({data:!!o||t.toSVG()});const{leafer:f}=t;f?(Yi(t),f.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){let e,s,o=1,r=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:_}=n,m=void 0===n.smooth?f.config.smooth:n.smooth,y=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=l.isOpaqueImage(i)||x,B=new M;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(h?"inner":"local");switch(o=d.scaleX,r=d.scaleY,i){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(d).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};k.getScaleData(n.scale,n.size,e,R);let S=n.pixelRatio||1;t.isApp&&(R.scaleX*=S,R.scaleY*=S,S=t.app.pixelRatio);const{x:E,y:A,width:L,height:W}=new w(e).scale(R.scaleX,R.scaleY),T={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-A).withScale(1/o*R.scaleX,1/r*R.scaleY)};let O,C=a.canvas({width:Math.round(L),height:Math.round(W),pixelRatio:S,smooth:m,contextSettings:y});if(p&&(O=t,O.__worldOpacity=0,t=f,T.bounds=C.bounds),C.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(C,T),t.fill=e}else t.__render(C,T);if(C.restore(),O&&O.__updateWorldOpacity(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Di(a,s,o):Pi(a={},s,o)),r++;const d=new w;return Ii(a,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:S};C=a.canvas(n),C.copyWorld(t,s,n)}b&&C.fillWorld(C.bounds,x||"#FFFFFF","destination-over"),_&&_(C);const P="canvas"===i?C:yield C.export(i,n);c({data:P,width:C.pixelWidth,height:C.pixelHeight,renderBounds:e,trimBounds:s})}))))):c({data:!1})}))))}};let Fi;function Yi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Yi(t)))}const Ui=t.prototype,Vi=y.get("@leafer-ui/export");Ui.export=function(t,e){const{quality:i,blob:n}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ui.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Vi.error(t),n(null)}))}))},Ui.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Ui.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Vi.error(t),n(!1)}))}))},Object.assign(Y,Ci),Object.assign(D,Mi),Object.assign(U,yt),Object.assign(P,te),Object.assign(I,me),Object.assign(V,ke),Object.assign(z,zi);try{wx&&j(0,wx)}catch(t){}export{ot as Layouter,X as LeaferCanvas,rt as Renderer,q as Watcher,j as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as d,FileHelper as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as S,MathHelper as k,AlignHelper as E,ImageEvent as A,AroundHelper as L,PointHelper as W,Direction4 as T,TwoPointBoundsHelper as O,TaskProcessor as C,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as z,Group as F,TextConvert as Y,Paint as U,Effect as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:s,pixelRatio:o}=this.config,a={width:n||t.width,height:s||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:N,fileType:G}=l;function j(t,i){e.origin={createCanvas:(t,e,n)=>{const s={type:"2d",width:t,height:e};i.createOffscreenCanvas?i.createOffscreenCanvas(s):i.createOffScreenCanvas(s)},canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(N(G(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new X(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},d(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});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(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.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:H,updateBounds:Q,updateAllWorldOpacity:J}=g,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:K}=m,tt={x:0,y:0,width:1e5,height:1e5};class et{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(tt):this.afterBounds.setListWithFn(t,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:it,updateAllChange:nt}=g,st=y.get("Layouter");class ot{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){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:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new x(s,r,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?(H(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||Q(n[t])}Q(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&J(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),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:n,AFTER:s}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),ot.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){it(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new et([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new et(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 at=y.get("Renderer");class rt{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(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,at.log(e.innerName,"---\x3e");try{e.app.emit(h.CHILD_START,e),this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");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=t.includes(this.target.__world),o=new w(n);i.save(),s&&!y.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(n),y.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(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 w(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||at.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 h(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(h.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 dt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[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)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function lt(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?ut(t,!0,e,i):ht(e,i);break;case"inside":ct("inside",t,s,e,i);break;case"outside":ct("outside",t,s,e,i)}}function ct(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ut(e,!0,n,r):ht(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",dt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ht(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ut(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ht(i,n):n.stroke(),n.restoreBlendMode()):e?ht(i,n):n.stroke())}Object.assign(a,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=ot.fullLayout;const{getSpread:ft,getOuterOf:pt,getByMove:gt,getIntersectData:_t}=R;let wt;function mt(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:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return P.image(i,t,e,n,!wt||!wt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.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]),wt=P.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=mt(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?dt(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 a=0,r=t.length;a<r;a++)n=t[a],n.image&&P.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?dt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?dt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?dt(e,i):s?i.fill(s):i.fill())},fillText:dt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)lt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke();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:a}=n;if(s)if(a)lt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ut(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ut(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ut(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:lt,drawTextStroke:ht,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=_t(n?ft(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=pt(s,a),o=gt(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(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:St,rotate:kt}=S;function Et(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),St(r,s,o),a&&bt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function At(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),s&&St(r,s,o),a&&kt(r,a),t.transform=r}function Lt(t,e,i,n,s,o,a,r,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),a&&Rt(c,vt,a,r),t.transform=c}const{get:Wt,translate:Tt}=S,Ot=new w,Ct={},Mt={};function Pt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Dt(i,n,e)}function Dt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ot.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,i,Mt),m=Mt.scaleX,y=Mt.scaleY);else if(!f||h){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,x+=(e.height-s*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),E.toPoint(r,t,e,Ct,!0),v+=Ct.x,x+=Ct.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||m||h)&&At(p,e,v,x,m,y,h);break;case"repeat":(!f||m||h)&&Lt(p,e,n,s,v,x,m,y,h,r),u||(p.repeat="repeat");break;default:m&&Et(p,e,v,x,m,y,h)}return p.transform||(e.x||e.y)&&(p.transform=Wt(),Tt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=y),p.width=n,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let It,zt=new w;const{isSame:Ft}=R;function Yt(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||Pt(s,n,i,o),!0}function Ut(t,e){Nt(t,A.LOAD,e)}function Vt(t,e){Nt(t,A.LOADED,e)}function Xt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,A.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Gt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Ht}=S,{ceil:Qt,abs:Jt}=Math;function Zt(t,i,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=Jt(s),o=Jt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=jt(),Ht(l,g),qt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=jt(),g&&Ht(l,g)),qt(l,1/s,1/o));const y=t.getCanvas(Qt(c)||1,Qt(h)||1,p),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function $t(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(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(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Kt}=Math;const te={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return It&&i===It.paint&&Ft(n,It.boxBounds)?o=It.leafPaint:(o={type:i.type,image:r},It=r.use>1?{leafPaint:o,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Yt(t,e,i,r,o,n),s&&(Ut(t,a),Vt(t,a))):r.error?s&&Xt(t,a,r.error):(s&&(Gt(t,!0),Ut(t,a)),o.loadId=r.load((()=>{Gt(t,!1),t.destroyed||(Yt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Vt(t,a)),o.loadId=null}),(e=>{Gt(t,!1),Xt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!z.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=Kt(o)*r,i*=Kt(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||z.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||z.running?Zt(t,n,r):n.patternTask||(n.patternTask=B.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Zt(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Zt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,B.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Pt,getPatternData:Dt,fillOrFitMode:Et,clipMode:At,repeatMode:Lt},{toPoint:ee}=L,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),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:oe,getDistance:ae}=W,{get:re,rotateOfOuter:de,scaleOfOuter:le}=S,{toPoint:ce}=L,he={},ue={};function fe(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=oe(e,i);o=re(),s?(le(o,e,a/r*(n||1),1),de(o,e,t+90)):(le(o,e,1,a/r*(n||1)),de(o,e,t))}return o}const{getDistance:pe}=W,{toPoint:ge}=L,_e={},we={};const me={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ee(n||"top",i,ie),ee(s||"bottom",i,ne);const d=e.canvas.createLinearGradient(ie.x,ie.y,ne.x,ne.y);se(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ce(n||"center",i,he),ce(s||"bottom",i,ue);const l=e.canvas.createRadialGradient(he.x,he.y,0,he.x,he.y,ae(he,ue));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,he,ue,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ge(n||"center",i,_e),ge(s||"bottom",i,we);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,_e.x,_e.y):e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,pe(_e,we));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,_e,we,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:fe},{copy:ye,toOffsetOutBounds:ve}=R,xe={},be={};function Be(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ye(xe,t.bounds),xe.x+=i.x-a.x,xe.y+=i.y-a.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&&(ye(xe,i),xe.x-=i.width/2*(n-1),xe.y-=i.height/2*(n-1),xe.width*=n,xe.height*=n),t.copyWorld(s.canvas,a,n?xe:i)}const{toOffsetOutBounds:Re}=R,Se={};const ke={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ve(l,be),r.forEach(((r,g)=>{f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,be,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Re(l,Se),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Se.offsetX+r.x*h,Se.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,Se,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.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:Ee}=m;function Ae(t,e,i,n,s,o){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),We(t,e,i,1)}(t,i,n,s);break;case"opacity-path":We(t,i,n,o);break;case"path":i.restore()}}function Le(t){return t.getSameCanvas(!1,!0)}function We(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Ae(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Le(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Le(t)),s||(s=Le(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Ee(i,e)||i.__render(s||t,e);Ae(this,a,t,s,n,o)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Oe=Te+"_#~&*+\\=|≮≯≈≠=…",Ce=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 Pe=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Me(Te),ze=Me(Oe),Fe=Me("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:Ue,Single:Ve,Before:Xe,After:Ne,Symbol:Ge,Break:je}=Ye;function qe(t){return Pe[t]?Ue:Fe[t]?je:De[t]?Xe:Ie[t]?Ne:ze[t]?Ge:Ce.test(t)?Ve:Ue}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:Je}=He,{Letter:Ze,Single:$e,Before:Ke,After:ti,Symbol:ei,Break:ii}=Ye;let ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi,mi,yi,vi=[];function xi(t,e){hi&&!ci&&(ci=hi),ni.data.push({char:t,width:e}),oi+=e}function bi(){ai+=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=ai,mi.width?Je(si):yi&&Ri(),vi.push(si),si={words:[]},ai=0}function Ri(){ai>(wi.maxWidth||0)&&(wi.maxWidth=ai)}const Si=0,ki=1,Ei=2;const{top:Ai,right:Li,bottom:Wi,left:Ti}=T;function Oi(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 Ci={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o?(n=l[Ti],o-=l[Li]+l[Ti]):i.autoSizeAlign||(n=l[Ti]),a?(s=l[Ai],a-=l[Ai]+l[Wi]):i.autoSizeAlign||(s=l[Ai]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){wi=t,vi=t.rows,mi=t.bounds,yi=!mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=mi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;_i=!0,fi=null,ci=li=hi=oi=ai=0,ni={data:[]},si={words:[]};for(let n=0,l=i.length;n<l;n++)di=i[n],"\n"===di?(oi&&bi(),si.paraEnd=!0,Bi(),_i=!0):(ui=qe(di),ui===Ze&&"none"!==a&&(di=Qe(di,a,!oi)),li=r.measureText(di).width,s&&(s<0&&(hi=li),li+=s),pi=ui===$e&&(fi===$e||fi===Ze)||fi===$e&&ui!==ti,gi=!(ui!==Ke&&ui!==$e||fi!==ei&&fi!==ti),ri=_i&&o?d-o:d,t&&d&&ai+oi+li>ri&&(e?(oi&&bi(),ai&&Bi()):(gi||(gi=ui===Ze&&fi==ti),pi||gi||ui===ii||ui===Ke||ui===$e||oi+li>ri?(oi&&bi(),ai&&Bi()):ai&&Bi()))," "===di&&!0!==_i&&ai+oi===0||(ui===ii?(" "===di&&oi&&bi(),xi(di,li),bi()):pi||gi?(oi&&bi(),xi(di,li)):xi(di,li)),fi=ui);oi&&bi(),ai&&Bi(),vi.length>0&&(vi[vi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{wi.paraNumber++,ai=r.measureText(t).width,vi.push({x:o||0,text:t,width:ai,paraStart:!0}),yi&&Ri()}))}(c,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Oi(e,"x",t[Ti]);break;case"right":Oi(e,"x",-t[Li])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Oi(e,"y",t[Ai]);break;case"bottom":Oi(e,"y",-t[Wi])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=n,_=s*i.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=i.length;else if(g||h)switch(l){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(m=i[o],m.x=u,m.width<p||m.width>p&&!r)switch(d){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<n.x&&(n.x=y),v>n.width&&(n.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=_}(c,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Si:l>.01?ki:Ei,t.isOverflow&&!r&&(t.textMode=!0),h===Ei?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===ki?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.textWrap?o:[o[a-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){e.data.splice(n+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,i,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,i),c}};const Mi={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 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+")"}},{setPoint:Pi,addPoint:Di,toBounds:Ii}=O;const zi={export(t,i,n){this.running=!0;const s=l.fileType(i),o=i.includes(".");return n=l.getExportOptions(n),function(t){Fi||(Fi=new C);return new Promise((e=>{Fi.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const c=t=>{r(t),d(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),i),c({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),i),c({data:!!o||t.toSVG()});const{leafer:f}=t;f?(Yi(t),f.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){let e,s,o=1,r=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:_}=n,m=void 0===n.smooth?f.config.smooth:n.smooth,y=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=l.isOpaqueImage(i)||x,B=new M;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(h?"inner":"local");switch(o=d.scaleX,r=d.scaleY,i){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(d).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};k.getScaleData(n.scale,n.size,e,R);let S=n.pixelRatio||1;t.isApp&&(R.scaleX*=S,R.scaleY*=S,S=t.app.pixelRatio);const{x:E,y:A,width:L,height:W}=new w(e).scale(R.scaleX,R.scaleY),T={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-A).withScale(1/o*R.scaleX,1/r*R.scaleY)};let O,C=a.canvas({width:Math.round(L),height:Math.round(W),pixelRatio:S,smooth:m,contextSettings:y});if(p&&(O=t,O.__worldOpacity=0,t=f,T.bounds=C.bounds),C.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(C,T),t.fill=e}else t.__render(C,T);if(C.restore(),O&&O.__updateWorldOpacity(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Di(a,s,o):Pi(a={},s,o)),r++;const d=new w;return Ii(a,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:S};C=a.canvas(n),C.copyWorld(t,s,n)}b&&C.fillWorld(C.bounds,x||"#FFFFFF","destination-over"),_&&_(C);const P="canvas"===i?C:yield C.export(i,n);c({data:P,width:C.pixelWidth,height:C.pixelHeight,renderBounds:e,trimBounds:s})}))))):c({data:!1})}))))}};let Fi;function Yi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Yi(t)))}const Ui=t.prototype,Vi=y.get("@leafer-ui/export");Ui.export=function(t,e){const{quality:i,blob:n}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ui.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Vi.error(t),n(null)}))}))},Ui.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Ui.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Vi.error(t),n(!1)}))}))},Object.assign(Y,Ci),Object.assign(D,Mi),Object.assign(U,yt),Object.assign(P,te),Object.assign(I,me),Object.assign(V,ke),Object.assign(z,zi);try{wx&&j(0,wx)}catch(t){}export{ot as Layouter,X as LeaferCanvas,rt as Renderer,q as Watcher,j as useCanvas};
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let n=e.view||e.canvas;n?("string"==typeof n?("#"!==n[0]&&(n="#"+n),this.viewSelect=t.Platform.miniapp.select(n)):n.fields?this.viewSelect=n:this.initView(n),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:i,pixelRatio:s}=this.config,o={width:n||e.width,height:i||e.height,pixelRatio:s};this.resize(o),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,n,i,s){this.context.roundRect(t,e,n,i,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then((t=>{this.clientBounds=t,e&&e()}))}startAutoLayout(e,n){this.resizeListener=n,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:n}=this,i={width:t,height:e,pixelRatio:n};this.isSameSize(i)||this.emitResize(i)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}}const{mineType:i,fileType:s}=t.FileHelper;function o(e,n){t.Platform.origin={createCanvas:(t,e,i)=>n.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,n)=>t.toDataURL(i(e),n),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(e,n,o)=>{let a=e.toDataURL(i(s(n)),o);return a=a.substring(a.indexOf("64,")+3),t.Platform.origin.download(a,n)},download:(e,i)=>new Promise(((s,o)=>{let a;i.includes("/")||(i=`${n.env.USER_DATA_PATH}/`+i,a=!0);const r=n.getFileSystemManager();r.writeFile({filePath:i,data:e,encoding:"base64",success(){a?t.Platform.miniapp.saveToAlbum(i).then((()=>{r.unlink({filePath:i}),s()})):s()},fail(t){o(t)}})})),loadImage:e=>new Promise(((n,i)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>n.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const n=t[1];e({x:n.top,y:n.left,width:n.width,height:n.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const n=t[0];e({view:n.node,width:n.width,height:n.height})}))})),saveToAlbum:t=>new Promise((e=>{n.getSetting({success:i=>{i.authSetting["scope.writePhotosAlbum"]?n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):n.authorize({scope:"scope.writePhotosAlbum",success:()=>{n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){n.onWindowResize(t)},offWindowResize(t){n.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:n}=t.Platform.renderCanvas||t.Platform.canvas;n.requestAnimationFrame?n.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class a{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),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:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:u}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),m.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(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:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.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 x(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function b(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?E(t,!0,e,n):R(e,n);break;case"inside":B("inside",t,s,e,n);break;case"outside":B("outside",t,s,e,n)}}function B(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?E(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function R(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function E(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?R(i,s):s.stroke(),s.restoreBlendMode()):n?R(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new a(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new y(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:S,getOuterOf:L,getByMove:k,getIntersectData:P}=t.BoundsHelper;let A;function C(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!A||!A[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const W={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),A=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=C(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?x(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?x(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?x(n,i):o?i.fill(o):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)b(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),E(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),E(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),E(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=P(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=L(s,a),o=k(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let O={};const{get:T,rotateOfOuter:M,translate:I,scaleOfOuter:D,scale:z,rotate:H}=t.MatrixHelper;function F(t,e,n,i,s,o,a){const r=T();I(r,e.x+n,e.y+i),z(r,s,o),a&&M(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Y(t,e,n,i,s,o,a){const r=T();I(r,e.x+n,e.y+i),s&&z(r,s,o),a&&H(r,a),t.transform=r}function j(t,e,n,i,s,o,a,r,l,d){const c=T();if(l)if("center"===d)M(c,{x:n/2,y:i/2},l);else switch(H(c,l),l){case 90:I(c,i,0);break;case 180:I(c,n,i);break;case 270:I(c,0,n)}O.x=e.x+s,O.y=e.y+o,I(c,O.x,O.y),a&&D(c,O,a,r),t.transform=c}const{get:G,translate:U}=t.MatrixHelper,V=new t.Bounds,X={},N={};function q(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Q(n,i,e)}function Q(e,n,i){let{width:s,height:o}=i;e.padding&&(n=V.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,N),v=N.scaleX,y=N.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(l,e,n,X,!0),x+=X.x,b+=X.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&Y(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&j(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&F(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=G(),U(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let J,Z=new t.Bounds;const{isSame:$}=t.BoundsHelper;function K(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.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||q(s,i,n,o),!0}function tt(e,n){it(e,t.ImageEvent.LOAD,n)}function et(e,n){it(e,t.ImageEvent.LOADED,n)}function nt(e,n,i){n.error=i,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function st(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ot,scale:at,copy:rt}=t.MatrixHelper,{ceil:lt,abs:dt}=Math;function ct(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=dt(s),o=dt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ot(),rt(d,g),at(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=ot(),g&&rt(d,g)),at(d,1/s,1/o));const v=e.getCanvas(lt(c)||1,lt(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function ht(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ut}=Math;const ft={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return J&&i===J.paint&&$(s,J.boxBounds)?a=J.leafPaint:(a={type:i.type,image:l},J=l.use>1?{leafPaint:a,paint:i,boxBounds:Z.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(K(e,n,i,l,a,s),o&&(tt(e,r),et(e,r))):l.error?o&&nt(e,r,l.error):(o&&(st(e,!0),tt(e,r)),a.loadId=l.load((()=>{st(e,!1),e.destroyed||(K(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),et(e,r)),a.loadId=null}),(t=>{st(e,!1),nt(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=ut(a)*l,i*=ut(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ct(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ht(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ct(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ct,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:q,getPatternData:Q,fillOrFitMode:F,clipMode:Y,repeatMode:j},{toPoint:pt}=t.AroundHelper,gt={},_t={};function wt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:mt,getDistance:vt}=t.PointHelper,{get:yt,rotateOfOuter:xt,scaleOfOuter:bt}=t.MatrixHelper,{toPoint:Bt}=t.AroundHelper,Rt={},Et={};function St(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=mt(e,n);o=yt(),s?(bt(o,e,a/r*(i||1),1),xt(o,e,t+90)):(bt(o,e,1,a/r*(i||1)),xt(o,e,t))}return o}const{getDistance:Lt}=t.PointHelper,{toPoint:kt}=t.AroundHelper,Pt={},At={};const Ct={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;pt(i||"top",n,gt),pt(s||"bottom",n,_t);const l=t.Platform.canvas.createLinearGradient(gt.x,gt.y,_t.x,_t.y);wt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Bt(i||"center",n,Rt),Bt(s||"bottom",n,Et);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Et));wt(d,e.stops,a);const c={type:o,style:d},h=St(n,Rt,Et,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;kt(i||"center",n,Pt),kt(s||"bottom",n,At);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Pt.x,Pt.y):t.Platform.canvas.createRadialGradient(Pt.x,Pt.y,0,Pt.x,Pt.y,Lt(Pt,At));wt(d,e.stops,a);const c={type:o,style:d},h=St(n,Pt,At,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:St},{copy:Wt,toOffsetOutBounds:Ot}=t.BoundsHelper,Tt={},Mt={};function It(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Wt(Tt,e.bounds),Tt.x+=n.x-a.x,Tt.y+=n.y-a.y,i){const{matrix:t}=s;Tt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Tt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(s.canvas,e.bounds,Tt)}else i&&(Wt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(s.canvas,a,i?Tt:n)}const{toOffsetOutBounds:Dt}=t.BoundsHelper,zt={};const Ht={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ot(d,Mt),r.forEach(((r,g)=>{f.setWorldShadow(Mt.offsetX+r.x*h,Mt.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,It(f,Mt,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Dt(d,zt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(zt.offsetX+r.x*h,zt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,It(f,zt,s,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Ft}=t.LeafBoundsHelper;function Yt(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Gt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Gt(t,n,i,o);break;case"path":n.restore()}}function jt(t){return t.getSameCanvas(!1,!0)}function Gt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(a&&(Yt(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=jt(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=jt(t)),s||(s=jt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Ft(n,e)||n.__render(s||t,e);Yt(this,a,t,s,i,o)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Vt=Ut+"_#~&*+\\=|≮≯≈≠=…",Xt=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 Nt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qt=Nt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Qt=Nt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Nt(Ut),Zt=Nt(Vt),$t=Nt("- —/~|┆·");var Kt;!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"}(Kt||(Kt={}));const{Letter:te,Single:ee,Before:ne,After:ie,Symbol:se,Break:oe}=Kt;function ae(t){return qt[t]?te:$t[t]?oe:Qt[t]?ne:Jt[t]?ie:Zt[t]?se:Xt.test(t)?ee:te}const re={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:de}=re,{Letter:ce,Single:he,Before:ue,After:fe,Symbol:pe,Break:ge}=Kt;let _e,we,me,ve,ye,xe,be,Be,Re,Ee,Se,Le,ke,Pe,Ae,Ce,We,Oe=[];function Te(t,e){Re&&!Be&&(Be=Re),_e.data.push({char:t,width:e}),me+=e}function Me(){ve+=me,_e.width=me,we.words.push(_e),_e={data:[]},me=0}function Ie(){Pe&&(Ae.paraNumber++,we.paraStart=!0,Pe=!1),Re&&(we.startCharSize=Be,we.endCharSize=Re,Be=0),we.width=ve,Ce.width?de(we):We&&De(),Oe.push(we),we={words:[]},ve=0}function De(){ve>(Ae.maxWidth||0)&&(Ae.maxWidth=ve)}const ze=0,He=1,Fe=2;const{top:Ye,right:je,bottom:Ge,left:Ue}=t.Direction4;function Ve(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Xe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Ue],o-=d[je]+d[Ue]):n.autoSizeAlign||(i=d[Ue]),a?(s=d[Ye],a-=d[Ye]+d[Ge]):n.autoSizeAlign||(s=d[Ye]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ae=e,Oe=e.rows,Ce=e.bounds,We=!Ce.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ce;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Pe=!0,Se=null,Be=be=Re=me=ve=0,_e={data:[]},we={words:[]};for(let i=0,d=n.length;i<d;i++)xe=n[i],"\n"===xe?(me&&Me(),we.paraEnd=!0,Ie(),Pe=!0):(Ee=ae(xe),Ee===ce&&"none"!==a&&(xe=le(xe,a,!me)),be=r.measureText(xe).width,s&&(s<0&&(Re=be),be+=s),Le=Ee===he&&(Se===he||Se===ce)||Se===he&&Ee!==fe,ke=!(Ee!==ue&&Ee!==he||Se!==pe&&Se!==fe),ye=Pe&&o?l-o:l,t&&l&&ve+me+be>ye&&(e?(me&&Me(),ve&&Ie()):(ke||(ke=Ee===ce&&Se==fe),Le||ke||Ee===ge||Ee===ue||Ee===he||me+be>ye?(me&&Me(),ve&&Ie()):ve&&Ie()))," "===xe&&!0!==Pe&&ve+me===0||(Ee===ge?(" "===xe&&me&&Me(),Te(xe,be),Me()):Le||ke?(me&&Me(),Te(xe,be)):Te(xe,be)),Se=Ee);me&&Me(),ve&&Ie(),Oe.length>0&&(Oe[Oe.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ae.paraNumber++,ve=r.measureText(t).width,Oe.push({x:o||0,text:t,width:ve,paraStart:!0}),We&&De()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ve(e,"x",t[Ue]);break;case"right":Ve(e,"x",-t[je])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ve(e,"y",t[Ye]);break;case"bottom":Ve(e,"y",-t[Ge])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,y=m.width,a<0&&(m.width<0?(y=-m.width+e.fontSize+a,v-=y,y+=e.fontSize):y-=a),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?ze:d>.01?He:Fe,t.isOverflow&&!r&&(t.textMode=!0),h===Fe?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===He?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ne={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:qe,addPoint:Qe,toBounds:Je}=t.TwoPointBoundsHelper;const Ze={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){$e||($e=new t.TaskProcessor);return new Promise((t=>{$e.add((()=>ht(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(Ke(e),h.waitViewCompleted((()=>ht(this,void 0,void 0,(function*(){let s,o,a=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:R,y:E,width:S,height:L}=new t.Bounds(s).scale(b.scaleX,b.scaleY),k={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-E).withScale(1/a*b.scaleX,1/r*b.scaleY)};let P,A=t.Creator.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=e,P.__worldOpacity=0,e=h,k.bounds=A.bounds),A.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(A,k),e.fill=t}else e.__render(A,k);if(A.restore(),P&&P.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?Qe(r,o,a):qe(r={},o,a)),l++;const d=new t.Bounds;return Je(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(s),A.copyWorld(e,o,s)}y&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let $e;function Ke(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ke(t)))}const tn=t.LeaferCanvasBase.prototype,en=t.Debug.get("@leafer-ui/export");tn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},tn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},tn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Xe),Object.assign(e.ColorConvert,Ne),Object.assign(e.Paint,W),Object.assign(e.PaintImage,ft),Object.assign(e.PaintGradient,Ct),Object.assign(e.Effect,Ht),Object.assign(e.Export,Ze);try{wx&&o(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=y,exports.Watcher=a,exports.useCanvas=o,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let n=e.view||e.canvas;n?("string"==typeof n?("#"!==n[0]&&(n="#"+n),this.viewSelect=t.Platform.miniapp.select(n)):n.fields?this.viewSelect=n:this.initView(n),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:i,pixelRatio:s}=this.config,o={width:n||e.width,height:i||e.height,pixelRatio:s};this.resize(o),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,n,i,s){this.context.roundRect(t,e,n,i,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then((t=>{this.clientBounds=t,e&&e()}))}startAutoLayout(e,n){this.resizeListener=n,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:n}=this,i={width:t,height:e,pixelRatio:n};this.isSameSize(i)||this.emitResize(i)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}}const{mineType:i,fileType:s}=t.FileHelper;function o(e,n){t.Platform.origin={createCanvas:(t,e,i)=>{const s={type:"2d",width:t,height:e};n.createOffscreenCanvas?n.createOffscreenCanvas(s):n.createOffScreenCanvas(s)},canvasToDataURL:(t,e,n)=>t.toDataURL(i(e),n),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(e,n,o)=>{let a=e.toDataURL(i(s(n)),o);return a=a.substring(a.indexOf("64,")+3),t.Platform.origin.download(a,n)},download:(e,i)=>new Promise(((s,o)=>{let a;i.includes("/")||(i=`${n.env.USER_DATA_PATH}/`+i,a=!0);const r=n.getFileSystemManager();r.writeFile({filePath:i,data:e,encoding:"base64",success(){a?t.Platform.miniapp.saveToAlbum(i).then((()=>{r.unlink({filePath:i}),s()})):s()},fail(t){o(t)}})})),loadImage:e=>new Promise(((n,i)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>n.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const n=t[1];e({x:n.top,y:n.left,width:n.width,height:n.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const n=t[0];e({view:n.node,width:n.width,height:n.height})}))})),saveToAlbum:t=>new Promise((e=>{n.getSetting({success:i=>{i.authSetting["scope.writePhotosAlbum"]?n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):n.authorize({scope:"scope.writePhotosAlbum",success:()=>{n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){n.onWindowResize(t)},offWindowResize(t){n.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:n}=t.Platform.renderCanvas||t.Platform.canvas;n.requestAnimationFrame?n.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class a{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),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:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:u}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),m.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(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:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.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 x(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function b(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?E(t,!0,e,n):R(e,n);break;case"inside":B("inside",t,s,e,n);break;case"outside":B("outside",t,s,e,n)}}function B(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?E(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function R(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function E(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?R(i,s):s.stroke(),s.restoreBlendMode()):n?R(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new a(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new y(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:S,getOuterOf:L,getByMove:k,getIntersectData:P}=t.BoundsHelper;let A;function C(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!A||!A[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const W={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),A=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=C(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?x(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?x(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?x(n,i):o?i.fill(o):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)b(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),E(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),E(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),E(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=P(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=L(s,a),o=k(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let O={};const{get:T,rotateOfOuter:M,translate:I,scaleOfOuter:D,scale:z,rotate:H}=t.MatrixHelper;function F(t,e,n,i,s,o,a){const r=T();I(r,e.x+n,e.y+i),z(r,s,o),a&&M(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Y(t,e,n,i,s,o,a){const r=T();I(r,e.x+n,e.y+i),s&&z(r,s,o),a&&H(r,a),t.transform=r}function j(t,e,n,i,s,o,a,r,l,d){const c=T();if(l)if("center"===d)M(c,{x:n/2,y:i/2},l);else switch(H(c,l),l){case 90:I(c,i,0);break;case 180:I(c,n,i);break;case 270:I(c,0,n)}O.x=e.x+s,O.y=e.y+o,I(c,O.x,O.y),a&&D(c,O,a,r),t.transform=c}const{get:G,translate:U}=t.MatrixHelper,V=new t.Bounds,X={},N={};function q(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Q(n,i,e)}function Q(e,n,i){let{width:s,height:o}=i;e.padding&&(n=V.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,N),v=N.scaleX,y=N.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(l,e,n,X,!0),x+=X.x,b+=X.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&Y(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&j(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&F(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=G(),U(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let J,Z=new t.Bounds;const{isSame:$}=t.BoundsHelper;function K(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.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||q(s,i,n,o),!0}function tt(e,n){it(e,t.ImageEvent.LOAD,n)}function et(e,n){it(e,t.ImageEvent.LOADED,n)}function nt(e,n,i){n.error=i,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function st(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ot,scale:at,copy:rt}=t.MatrixHelper,{ceil:lt,abs:dt}=Math;function ct(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=dt(s),o=dt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ot(),rt(d,g),at(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=ot(),g&&rt(d,g)),at(d,1/s,1/o));const v=e.getCanvas(lt(c)||1,lt(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function ht(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ut}=Math;const ft={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return J&&i===J.paint&&$(s,J.boxBounds)?a=J.leafPaint:(a={type:i.type,image:l},J=l.use>1?{leafPaint:a,paint:i,boxBounds:Z.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(K(e,n,i,l,a,s),o&&(tt(e,r),et(e,r))):l.error?o&&nt(e,r,l.error):(o&&(st(e,!0),tt(e,r)),a.loadId=l.load((()=>{st(e,!1),e.destroyed||(K(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),et(e,r)),a.loadId=null}),(t=>{st(e,!1),nt(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=ut(a)*l,i*=ut(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ct(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ht(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ct(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ct,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:q,getPatternData:Q,fillOrFitMode:F,clipMode:Y,repeatMode:j},{toPoint:pt}=t.AroundHelper,gt={},_t={};function wt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:mt,getDistance:vt}=t.PointHelper,{get:yt,rotateOfOuter:xt,scaleOfOuter:bt}=t.MatrixHelper,{toPoint:Bt}=t.AroundHelper,Rt={},Et={};function St(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=mt(e,n);o=yt(),s?(bt(o,e,a/r*(i||1),1),xt(o,e,t+90)):(bt(o,e,1,a/r*(i||1)),xt(o,e,t))}return o}const{getDistance:Lt}=t.PointHelper,{toPoint:kt}=t.AroundHelper,Pt={},At={};const Ct={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;pt(i||"top",n,gt),pt(s||"bottom",n,_t);const l=t.Platform.canvas.createLinearGradient(gt.x,gt.y,_t.x,_t.y);wt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Bt(i||"center",n,Rt),Bt(s||"bottom",n,Et);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Et));wt(d,e.stops,a);const c={type:o,style:d},h=St(n,Rt,Et,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;kt(i||"center",n,Pt),kt(s||"bottom",n,At);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Pt.x,Pt.y):t.Platform.canvas.createRadialGradient(Pt.x,Pt.y,0,Pt.x,Pt.y,Lt(Pt,At));wt(d,e.stops,a);const c={type:o,style:d},h=St(n,Pt,At,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:St},{copy:Wt,toOffsetOutBounds:Ot}=t.BoundsHelper,Tt={},Mt={};function It(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Wt(Tt,e.bounds),Tt.x+=n.x-a.x,Tt.y+=n.y-a.y,i){const{matrix:t}=s;Tt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Tt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(s.canvas,e.bounds,Tt)}else i&&(Wt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(s.canvas,a,i?Tt:n)}const{toOffsetOutBounds:Dt}=t.BoundsHelper,zt={};const Ht={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ot(d,Mt),r.forEach(((r,g)=>{f.setWorldShadow(Mt.offsetX+r.x*h,Mt.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,It(f,Mt,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Dt(d,zt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(zt.offsetX+r.x*h,zt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,It(f,zt,s,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Ft}=t.LeafBoundsHelper;function Yt(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Gt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Gt(t,n,i,o);break;case"path":n.restore()}}function jt(t){return t.getSameCanvas(!1,!0)}function Gt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(a&&(Yt(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=jt(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=jt(t)),s||(s=jt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Ft(n,e)||n.__render(s||t,e);Yt(this,a,t,s,i,o)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Vt=Ut+"_#~&*+\\=|≮≯≈≠=…",Xt=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 Nt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qt=Nt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Qt=Nt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Nt(Ut),Zt=Nt(Vt),$t=Nt("- —/~|┆·");var Kt;!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"}(Kt||(Kt={}));const{Letter:te,Single:ee,Before:ne,After:ie,Symbol:se,Break:oe}=Kt;function ae(t){return qt[t]?te:$t[t]?oe:Qt[t]?ne:Jt[t]?ie:Zt[t]?se:Xt.test(t)?ee:te}const re={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:de}=re,{Letter:ce,Single:he,Before:ue,After:fe,Symbol:pe,Break:ge}=Kt;let _e,we,me,ve,ye,xe,be,Be,Re,Ee,Se,Le,ke,Pe,Ae,Ce,We,Oe=[];function Te(t,e){Re&&!Be&&(Be=Re),_e.data.push({char:t,width:e}),me+=e}function Me(){ve+=me,_e.width=me,we.words.push(_e),_e={data:[]},me=0}function Ie(){Pe&&(Ae.paraNumber++,we.paraStart=!0,Pe=!1),Re&&(we.startCharSize=Be,we.endCharSize=Re,Be=0),we.width=ve,Ce.width?de(we):We&&De(),Oe.push(we),we={words:[]},ve=0}function De(){ve>(Ae.maxWidth||0)&&(Ae.maxWidth=ve)}const ze=0,He=1,Fe=2;const{top:Ye,right:je,bottom:Ge,left:Ue}=t.Direction4;function Ve(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Xe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Ue],o-=d[je]+d[Ue]):n.autoSizeAlign||(i=d[Ue]),a?(s=d[Ye],a-=d[Ye]+d[Ge]):n.autoSizeAlign||(s=d[Ye]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ae=e,Oe=e.rows,Ce=e.bounds,We=!Ce.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ce;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Pe=!0,Se=null,Be=be=Re=me=ve=0,_e={data:[]},we={words:[]};for(let i=0,d=n.length;i<d;i++)xe=n[i],"\n"===xe?(me&&Me(),we.paraEnd=!0,Ie(),Pe=!0):(Ee=ae(xe),Ee===ce&&"none"!==a&&(xe=le(xe,a,!me)),be=r.measureText(xe).width,s&&(s<0&&(Re=be),be+=s),Le=Ee===he&&(Se===he||Se===ce)||Se===he&&Ee!==fe,ke=!(Ee!==ue&&Ee!==he||Se!==pe&&Se!==fe),ye=Pe&&o?l-o:l,t&&l&&ve+me+be>ye&&(e?(me&&Me(),ve&&Ie()):(ke||(ke=Ee===ce&&Se==fe),Le||ke||Ee===ge||Ee===ue||Ee===he||me+be>ye?(me&&Me(),ve&&Ie()):ve&&Ie()))," "===xe&&!0!==Pe&&ve+me===0||(Ee===ge?(" "===xe&&me&&Me(),Te(xe,be),Me()):Le||ke?(me&&Me(),Te(xe,be)):Te(xe,be)),Se=Ee);me&&Me(),ve&&Ie(),Oe.length>0&&(Oe[Oe.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ae.paraNumber++,ve=r.measureText(t).width,Oe.push({x:o||0,text:t,width:ve,paraStart:!0}),We&&De()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ve(e,"x",t[Ue]);break;case"right":Ve(e,"x",-t[je])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ve(e,"y",t[Ye]);break;case"bottom":Ve(e,"y",-t[Ge])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,y=m.width,a<0&&(m.width<0?(y=-m.width+e.fontSize+a,v-=y,y+=e.fontSize):y-=a),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?ze:d>.01?He:Fe,t.isOverflow&&!r&&(t.textMode=!0),h===Fe?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===He?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ne={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:qe,addPoint:Qe,toBounds:Je}=t.TwoPointBoundsHelper;const Ze={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){$e||($e=new t.TaskProcessor);return new Promise((t=>{$e.add((()=>ht(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(Ke(e),h.waitViewCompleted((()=>ht(this,void 0,void 0,(function*(){let s,o,a=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:R,y:E,width:S,height:L}=new t.Bounds(s).scale(b.scaleX,b.scaleY),k={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-E).withScale(1/a*b.scaleX,1/r*b.scaleY)};let P,A=t.Creator.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=e,P.__worldOpacity=0,e=h,k.bounds=A.bounds),A.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(A,k),e.fill=t}else e.__render(A,k);if(A.restore(),P&&P.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?Qe(r,o,a):qe(r={},o,a)),l++;const d=new t.Bounds;return Je(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(s),A.copyWorld(e,o,s)}y&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let $e;function Ke(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ke(t)))}const tn=t.LeaferCanvasBase.prototype,en=t.Debug.get("@leafer-ui/export");tn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},tn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},tn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Xe),Object.assign(e.ColorConvert,Ne),Object.assign(e.Paint,W),Object.assign(e.PaintImage,ft),Object.assign(e.PaintGradient,Ct),Object.assign(e.Effect,Ht),Object.assign(e.Export,Ze);try{wx&&o(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=y,exports.Watcher=a,exports.useCanvas=o,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));