leafer-draw 1.10.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.js CHANGED
@@ -6428,7 +6428,7 @@ var LeaferUI = function(exports) {
6428
6428
  this.levelMap = null;
6429
6429
  }
6430
6430
  }
6431
- const version = "1.10.0";
6431
+ const version = "1.10.1";
6432
6432
  const debug$4 = Debug.get("LeaferCanvas");
6433
6433
  class LeaferCanvas extends LeaferCanvasBase {
6434
6434
  set zIndex(zIndex) {
@@ -7870,7 +7870,7 @@ var LeaferUI = function(exports) {
7870
7870
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
7871
7871
  } else drawer.rect(x, y, width, height);
7872
7872
  }
7873
- drawImagePlaceholder(_image, canvas, renderOptions) {
7873
+ drawImagePlaceholder(_paint, canvas, renderOptions) {
7874
7874
  Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
7875
7875
  }
7876
7876
  animate(keyframe, _options, _type, _isTemp) {
@@ -8929,30 +8929,31 @@ var LeaferUI = function(exports) {
8929
8929
  fillPathOrText(ui, canvas, renderOptions);
8930
8930
  }
8931
8931
  function fills(fills, ui, canvas, renderOptions) {
8932
- let item;
8932
+ let item, originPaint, countImage;
8933
8933
  for (let i = 0, len = fills.length; i < len; i++) {
8934
- item = fills[i];
8934
+ item = fills[i], originPaint = item.originPaint;
8935
8935
  if (item.image) {
8936
+ countImage ? countImage++ : countImage = 1;
8936
8937
  if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
8937
8938
  if (!item.style) {
8938
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
8939
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
8939
8940
  continue;
8940
8941
  }
8941
8942
  }
8942
8943
  canvas.fillStyle = item.style;
8943
- if (item.transform || item.scaleFixed) {
8944
+ if (item.transform || originPaint.scaleFixed) {
8944
8945
  canvas.save();
8945
8946
  if (item.transform) canvas.transform(item.transform);
8946
- if (item.scaleFixed) {
8947
+ if (originPaint.scaleFixed) {
8947
8948
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
8948
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
8949
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
8949
8950
  }
8950
- if (item.blendMode) canvas.blendMode = item.blendMode;
8951
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
8951
8952
  fillPathOrText(ui, canvas, renderOptions);
8952
8953
  canvas.restore();
8953
8954
  } else {
8954
- if (item.blendMode) {
8955
- canvas.saveBlendMode(item.blendMode);
8955
+ if (originPaint.blendMode) {
8956
+ canvas.saveBlendMode(originPaint.blendMode);
8956
8957
  fillPathOrText(ui, canvas, renderOptions);
8957
8958
  canvas.restoreBlendMode();
8958
8959
  } else fillPathOrText(ui, canvas, renderOptions);
@@ -9093,8 +9094,8 @@ var LeaferUI = function(exports) {
9093
9094
  const {strokeStyle: strokeStyle} = item;
9094
9095
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
9095
9096
  } else canvas.strokeStyle = item.style;
9096
- if (item.blendMode) {
9097
- canvas.saveBlendMode(item.blendMode);
9097
+ if (item.originPaint.blendMode) {
9098
+ canvas.saveBlendMode(item.originPaint.blendMode);
9098
9099
  isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
9099
9100
  canvas.restoreBlendMode();
9100
9101
  } else {
@@ -9185,61 +9186,62 @@ var LeaferUI = function(exports) {
9185
9186
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
9186
9187
  isTransparent = true;
9187
9188
  }
9188
- }
9189
- if (attrName === "fill") {
9190
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
9191
- stintSet(data, "__isTransparentFill", isTransparent);
9189
+ if (attrName === "fill") {
9190
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
9191
+ stintSet(data, "__isTransparentFill", isTransparent);
9192
+ } else {
9193
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
9194
+ stintSet(data, "__isTransparentStroke", isTransparent);
9195
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
9196
+ }
9192
9197
  } else {
9193
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
9194
- stintSet(data, "__isTransparentStroke", isTransparent);
9195
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
9198
+ data.__removePaint(attrName, false);
9196
9199
  }
9197
9200
  }
9198
9201
  function getLeafPaint(attrName, paint, ui) {
9199
9202
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
9200
- let data;
9203
+ let leafPaint;
9201
9204
  const {boxBounds: boxBounds} = ui.__layout;
9202
9205
  switch (paint.type) {
9203
9206
  case "image":
9204
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9207
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9205
9208
  break;
9206
9209
 
9207
9210
  case "linear":
9208
- data = PaintGradient.linearGradient(paint, boxBounds);
9211
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
9209
9212
  break;
9210
9213
 
9211
9214
  case "radial":
9212
- data = PaintGradient.radialGradient(paint, boxBounds);
9215
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
9213
9216
  break;
9214
9217
 
9215
9218
  case "angular":
9216
- data = PaintGradient.conicGradient(paint, boxBounds);
9219
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
9217
9220
  break;
9218
9221
 
9219
9222
  case "solid":
9220
9223
  const {type: type, color: color, opacity: opacity} = paint;
9221
- data = {
9224
+ leafPaint = {
9222
9225
  type: type,
9223
9226
  style: ColorConvert.string(color, opacity)
9224
9227
  };
9225
9228
  break;
9226
9229
 
9227
9230
  default:
9228
- if (!isUndefined(paint.r)) data = {
9231
+ if (!isUndefined(paint.r)) leafPaint = {
9229
9232
  type: "solid",
9230
9233
  style: ColorConvert.string(paint)
9231
9234
  };
9232
9235
  }
9233
- if (data) {
9234
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
9236
+ if (leafPaint) {
9237
+ leafPaint.originPaint = paint;
9238
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
9235
9239
  if (paint.style) {
9236
9240
  if (paint.style.strokeWidth === 0) return undefined;
9237
- data.strokeStyle = paint.style;
9241
+ leafPaint.strokeStyle = paint.style;
9238
9242
  }
9239
- if (paint.editing) data.editing = paint.editing;
9240
- if (paint.blendMode) data.blendMode = paint.blendMode;
9241
9243
  }
9242
- return data;
9244
+ return leafPaint;
9243
9245
  }
9244
9246
  const PaintModule = {
9245
9247
  compute: compute,
@@ -9357,10 +9359,6 @@ var LeaferUI = function(exports) {
9357
9359
  const tempScaleData = {};
9358
9360
  const tempImage = {};
9359
9361
  function createData(leafPaint, image, paint, box) {
9360
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
9361
- if (changeful) leafPaint.changeful = changeful;
9362
- if (sync) leafPaint.sync = sync;
9363
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
9364
9362
  leafPaint.data = PaintImage.getPatternData(paint, box, image);
9365
9363
  }
9366
9364
  function getPatternData(paint, box, image) {
@@ -9571,14 +9569,14 @@ var LeaferUI = function(exports) {
9571
9569
  }
9572
9570
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
9573
9571
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
9574
- const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
9572
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
9575
9573
  if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
9576
9574
  return false;
9577
9575
  } else {
9578
9576
  if (drawImage) {
9579
9577
  if (data.repeat) {
9580
9578
  drawImage = false;
9581
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
9579
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
9582
9580
  drawImage = Platform.image.isLarge(image, scaleX, scaleY);
9583
9581
  }
9584
9582
  }
@@ -9590,15 +9588,15 @@ var LeaferUI = function(exports) {
9590
9588
  PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
9591
9589
  return true;
9592
9590
  } else {
9593
- if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
9591
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
9594
9592
  return false;
9595
9593
  }
9596
9594
  }
9597
9595
  }
9598
9596
  function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
9599
- const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
9597
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
9600
9598
  let {width: width, height: height} = image, clipUI;
9601
- if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
9599
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
9602
9600
  canvas.save();
9603
9601
  clipUI && canvas.clipUI(ui);
9604
9602
  blendMode && (canvas.blendMode = blendMode);
@@ -9612,7 +9610,7 @@ var LeaferUI = function(exports) {
9612
9610
  }
9613
9611
  }
9614
9612
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
9615
- const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
9613
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
9616
9614
  if (canvas) {
9617
9615
  const {pixelRatio: pixelRatio} = canvas;
9618
9616
  scaleData.scaleX *= pixelRatio;
package/dist/web.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const i=t.Debug.get("LeaferCanvas");class n extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(e){let n=t.isString(e)?document.getElementById(e):e;if(n)if(n instanceof HTMLCanvasElement)this.view=n;else{let t=n;if(n===window||n===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else i.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:e,height:i,pixelRatio:n}=this,{style:s}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:n}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=s.width||""),s.width=e.width+"px"):t.isUndefined(i)||(s.width=i),e.height?(t.isUndefined(n)&&(this.autoHeightStr=s.height||""),s.height=e.height+"px"):t.isUndefined(n)||(s.height=n)}else s.width=e+"px",s.height=i+"px",this.view.width=Math.ceil(e*n),this.view.height=Math.ceil(i*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),i.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:a,height:r}=this.autoBounds.getBoundsFrom(e),o={width:a,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(o)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(o)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:a}=t.FileHelper;function r(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const n=s(e),a=t.toDataURL(n,i);return"image/bmp"===n?a.replace("image/png;","image/bmp;"):a},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,s(e),i)),canvasSaveAs:(e,i,n)=>{const r=e.toDataURL(s(a(i)),n);return t.Platform.origin.download(r,i)},download:(t,e)=>new Promise(i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()}),loadImage:e=>new Promise((i,n)=>{const s=new t.Platform.origin.Image,{crossOrigin:a}=t.Platform.image;a&&(s.setAttribute("crossOrigin",a),s.crossOrigin=a),s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},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="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{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,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,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,i=e.length;t<i;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=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateChange:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),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:m,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target: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 i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(s);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(s,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||c(n[t])}c(i)}})}(this.__levelList),function(t){t.list.forEach(h)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){m(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[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 x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{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;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(x.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),t.Platform.render(this.target,n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&e>n)return t.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(e),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).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.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function b(t,i,n){t.__.__font?e.Paint.fillText(t,i,n):t.__.windingRule?i.fill(t.__.windingRule):i.fill()}function E(i,n,s,a,r){const o=s.__;t.isObject(i)?e.Paint.drawStrokesStyle(i,n,!1,s,a,r):(a.setStroke(i,o.__strokeWidth*n,o),a.stroke()),o.__useArrow&&e.Paint.strokeArrow(i,s,a,r)}function S(i,n,s,a,r){const o=s.__;t.isObject(i)?e.Paint.drawStrokesStyle(i,n,!0,s,a,r):(a.setStroke(i,o.__strokeWidth*n,o),e.Paint.drawTextStroke(s,a,r))}function B(i,n,s,a,r){const o=a.getSameCanvas(!0,!0);o.font=s.__.__font,S(i,2,s,o,r),o.blendMode="outside"===n?"destination-out":"destination-in",e.Paint.fillText(s,o,r),o.blendMode="normal",t.LeafHelper.copyCanvasByWorld(s,a,o),o.recycle(s.__nowWorld)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),t.Platform.layout=y.fullLayout,t.Platform.render=function(e,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new t.LeafList,e.__render(i,n),n.topList.length&&n.topList.forEach(t=>t.__render(i,s))};const{getSpread:R,copyAndSpread:P,toOuterOf:L,getOuterOf:k,getByMove:C,move:A,getIntersectData:O}=t.BoundsHelper,T={};let I;const{stintSet:M}=t.DataHelper,{hasTransparent:D}=e.ColorConvert;function W(i,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=e.PaintImage.image(s,i,n,r,!I||!I[n.url]);break;case"linear":a=e.PaintGradient.linearGradient(n,r);break;case"radial":a=e.PaintGradient.radialGradient(n,r);break;case"angular":a=e.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;a={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:e.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&D(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const H={compute:function(i,n){const s=n.__,a=[];let r,o,l,d=s.__input[i];t.isArray(d)||(d=[d]),I=e.PaintImage.recycleImage(i,s);for(let t,e=0,s=d.length;e<s;e++)(t=W(i,d[e],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+i]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(M(s,"__isAlphaPixelFill",r),M(s,"__isTransparentFill",o)):(M(s,"__isAlphaPixelStroke",r),M(s,"__isTransparentStroke",o),M(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i,n){i.fillStyle=t,b(e,i,n)},fills:function(t,i,n,s){let a;for(let r=0,o=t.length;r<o;r++){if(a=t[r],a.image){if(e.PaintImage.checkImage(a,!i.__.__font,i,n,s))continue;if(!a.style){!r&&a.image.isPlacehold&&i.drawImagePlaceholder(a.image,n,s);continue}}if(n.fillStyle=a.style,a.transform||a.scaleFixed){if(n.save(),a.transform&&n.transform(a.transform),a.scaleFixed){const{scaleX:t,scaleY:e}=i.getRenderScaleData(!0);(!0===a.scaleFixed||"zoom-in"===a.scaleFixed&&t>1&&e>1)&&n.scale(1/t,1/e)}a.blendMode&&(n.blendMode=a.blendMode),b(i,n,s),n.restore()}else a.blendMode?(n.saveBlendMode(a.blendMode),b(i,n,s),n.restoreBlendMode()):b(i,n,s)}},fillPathOrText:b,fillText:function(t,e,i){const n=t.__,{rows:s,decorationY:a}=n.__textDrawData;let r;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,i=s.length;t<i;t++)r=s[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:i}=n.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>a.forEach(n=>e.fillRect(t.x,t.y+n,t.width,i)))}},stroke:function(i,n,s,a){const r=n.__;if(r.__strokeWidth)if(r.__font)e.Paint.strokeText(i,n,s,a);else switch(r.strokeAlign){case"center":E(i,1,n,s,a);break;case"inside":!function(t,e,i,n){i.save(),i.clipUI(e),E(t,2,e,i,n),i.restore()}(i,n,s,a);break;case"outside":!function(e,i,n,s){const a=i.__;if(a.__fillAfterStroke)E(e,2,i,n,s);else{const{renderBounds:r}=i.__layout,o=n.getSameCanvas(!0,!0);i.__drawRenderPath(o),E(e,2,i,o,s),o.clipUI(a),o.clearWorld(r),t.LeafHelper.copyCanvasByWorld(i,n,o),o.recycle(i.__nowWorld)}}(i,n,s,a)}},strokes:function(t,i,n,s){e.Paint.stroke(t,i,n,s)},strokeText:function(t,e,i,n){switch(e.__.strokeAlign){case"center":S(t,1,e,i,n);break;case"inside":B(t,"inside",e,i,n);break;case"outside":e.__.__fillAfterStroke?S(t,2,e,i,n):B(t,"outside",e,i,n)}},drawTextStroke:function(t,e,i){let n,s=t.__.__textDrawData;const{rows:a,decorationY:r}=s;for(let t=0,i=a.length;t<i;t++)n=a[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)});if(r){const{decorationHeight:t}=s;a.forEach(i=>r.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}},drawStrokesStyle:function(t,i,n,s,a,r){let o;const l=s.__,{__hasMultiStrokeStyle:d}=l;d||a.setStroke(void 0,l.__strokeWidth*i,l);for(let c=0,h=t.length;c<h;c++)if(o=t[c],(!o.image||!e.PaintImage.checkImage(o,!1,s,a,r))&&o.style){if(d){const{strokeStyle:t}=o;t?a.setStroke(o.style,l.__getRealStrokeWidth(t)*i,l,t):a.setStroke(o.style,l.__strokeWidth*i,l)}else a.strokeStyle=o.style;o.blendMode?(a.saveBlendMode(o.blendMode),n?e.Paint.drawTextStroke(s,a,r):a.stroke(),a.restoreBlendMode()):n?e.Paint.drawTextStroke(s,a,r):a.stroke()}},shape:function(e,i,n){const s=i.getSameCanvas(),a=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,c,h,u,f,p;L(o.strokeSpread?(P(T,o.boxBounds,o.strokeSpread),T):o.boxBounds,r,l);let{scaleX:g,scaleY:m}=e.getRenderScaleData(!0);if(a.includes(l))p=s,d=f=l,c=r;else{let s;if(t.Platform.fullImageShadow)s=l;else{const e=o.renderShapeSpread?R(a,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,m)):a;s=O(e,l)}u=a.getFitMatrix(s);let{a:_,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,n),g*=_,m*=w),f=k(l,u),d=C(f,-u.e,-u.f),c=k(r,u),A(c,-u.e,-u.f);const y=n.matrix;y?(h=new t.Matrix(u),h.multiply(y),_*=y.scaleX,w*=y.scaleY):h=u,h.withScale(_,w),n=Object.assign(Object.assign({},n),{matrix:h})}return e.__renderShape(s,n),{canvas:s,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:m}}};let F,z=new t.Bounds;const{isSame:U}=t.BoundsHelper;function j(t,i,n,s,a,r){if("fill"===i&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||e.PaintImage.createData(a,s,n,r),!0}function Y(e,i){N(e,t.ImageEvent.LOAD,i)}function G(e,i){N(e,t.ImageEvent.LOADED,i)}function V(e,i,n){i.error=n,e.forceUpdate("surface"),N(e,t.ImageEvent.ERROR,i)}function N(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function X(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:q,translate:Q}=t.MatrixHelper,Z=new t.Bounds,$={},K={};function J(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let tt={},et=t.getMatrixData();const{get:it,set:nt,rotateOfOuter:st,translate:at,scaleOfOuter:rt,multiplyParent:ot,scale:lt,rotate:dt,skew:ct}=t.MatrixHelper;function ht(t,e,i,n,s,a,r,o){r&&dt(t,r),o&&ct(t,o.x,o.y),s&&lt(t,s,a),at(t,e.x+i,e.y+n)}function ut(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ft,scale:pt,copy:gt}=t.MatrixHelper,{getFloorScale:mt}=t.MathHelper,{abs:_t}=Math;const wt={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return F&&n===F.paint&&U(s,F.boxBounds)?r=F.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),F=l.use>1?{leafPaint:r,paint:n,boxBounds:z.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(j(e,i,n,l,r,s),a&&(Y(e,o),G(e,o))):l.error?a&&V(e,o,l.error):(a&&(X(e,!0),Y(e,o)),r.loadId=l.load(()=>{X(e,!1),e.destroyed||(j(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),G(e,o)),r.loadId=void 0},t=>{X(e,!1),V(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(i,n,s,a,r){const{scaleX:o,scaleY:l}=e.PaintImage.getImageRenderScaleData(i,s,a,r),{image:d,data:c}=i,{exporting:h}=r;return!(!c||i.patternId===o+"-"+l&&!h)&&(n&&(c.repeat?n=!1:i.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(s)||h||(n=t.Platform.image.isLarge(d,o,l))),n?(s.__.__isFastShadow&&(a.fillStyle=i.style||"#000",a.fill()),e.PaintImage.drawImage(i,o,l,s,a,r),!0):(!i.style||i.sync||h?e.PaintImage.createPattern(i,s,a,r):e.PaintImage.createPatternTask(i,s,a,r),!1))},drawImage:function(t,e,i,n,s,a){const{data:r,image:o,blendMode:l}=t,{opacity:d,transform:c}=r,h=o.getFull(r.filters),u=n.__;let f,{width:p,height:g}=o;c&&!c.onlyScale||(f=u.path||u.cornerRadius)||d||l?(s.save(),f&&s.clipUI(n),l&&(s.blendMode=l),d&&(s.opacity*=d),c&&s.transform(c),s.drawImage(h,0,0,p,g),s.restore()):(r.scaleX&&(p*=r.scaleX,g*=r.scaleY),s.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,i,n){const s=e.getRenderScaleData(!0,t.scaleFixed),{data:a}=t;if(i){const{pixelRatio:t}=i;s.scaleX*=t,s.scaleY*=t}return a&&a.scaleX&&(s.scaleX*=Math.abs(a.scaleX),s.scaleY*=Math.abs(a.scaleY)),s},recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let d=0,c=n.length;d<c;d++)s=n[d],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createPatternTask:function(i,n,s,a){i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add(()=>ut(this,void 0,void 0,function*(){i.patternTask=null,s.bounds.hit(n.__nowWorld)&&e.PaintImage.createPattern(i,n,s,a),n.forceUpdate("surface")}),300))},createPattern:function(i,n,s,a){let{scaleX:r,scaleY:o}=e.PaintImage.getImageRenderScaleData(i,n,s,a),l=r+"-"+o;if(i.patternId!==l&&!n.destroyed&&(!t.Platform.image.isLarge(i.image,r,o)||i.data.repeat)){const{image:s,data:a}=i,{transform:d,gap:c}=a,h=e.PaintImage.getPatternFixScale(i,r,o);let u,f,p,{width:g,height:m}=s;h&&(r*=h,o*=h),g*=r,m*=o,c&&(f=c.x*r/_t(a.scaleX||1),p=c.y*o/_t(a.scaleY||1)),(d||1!==r||1!==o)&&(r*=mt(g+(f||0)),o*=mt(m+(p||0)),u=ft(),d&&gt(u,d),pt(u,1/r,1/o));const _=s.getCanvas(g,m,a.opacity,a.filters,f,p,n.leafer&&n.leafer.config.smooth),w=s.getPattern(_,a.repeat||t.Platform.origin.noRepeat||"no-repeat",u,i);i.style=w,i.patternId=l}},getPatternFixScale:function(e,i,n){const{image:s}=e;let a,r=t.Platform.image.maxPatternSize,o=s.width*s.height;return s.isSVG?i>1&&(a=Math.ceil(i)/i):r>o&&(r=o),(o*=i*n)>r&&(a=Math.sqrt(r/o)),a},createData:function(t,i,n,s){const{changeful:a,sync:r,scaleFixed:o}=n;a&&(t.changeful=a),r&&(t.sync=r),o&&(t.scaleFixed=o),t.data=e.PaintImage.getPatternData(n,s,i)},getPatternData:function(i,n,s){i.padding&&(n=Z.set(n).shrink(i.padding)),"strench"===i.mode&&(i.mode="stretch");const{width:a,height:r}=s,{opacity:o,mode:l,align:d,offset:c,scale:h,size:u,rotation:f,skew:p,clipSize:g,repeat:m,gap:_,filters:w}=i,y=n.width===a&&n.height===r,v={mode:l},x="center"!==d&&(f||0)%180==90;let b,E;switch(t.BoundsHelper.set(K,0,0,x?r:a,x?a:r),l&&"cover"!==l&&"fit"!==l?((h||u)&&(t.MathHelper.getScaleData(h,u,s,$),b=$.scaleX,E=$.scaleY),(d||_||m)&&(b&&t.BoundsHelper.scale(K,b,E,!0),d&&t.AlignHelper.toPoint(d,K,n,K,!0,!0))):y&&!f||(b=E=t.BoundsHelper.getFitScale(n,K,"fit"!==l),t.BoundsHelper.put(n,s,d,b,!1,K),t.BoundsHelper.scale(K,b,E,!0)),c&&t.PointHelper.move(K,c),l){case"stretch":y?b&&(b=E=void 0):(b=n.width/a,E=n.height/r,e.PaintImage.stretchMode(v,n,b,E));break;case"normal":case"clip":if(K.x||K.y||b||g||f||p){let t,i;g&&(t=n.width/g.width,i=n.height/g.height),e.PaintImage.clipMode(v,n,K.x,K.y,b,E,f,p,t,i),t&&(b=b?b*t:t,E=E?E*i:i)}break;case"repeat":(!y||b||f||p)&&e.PaintImage.repeatMode(v,n,a,r,K.x,K.y,b,E,f,p,d,i.freeTransform),m||(v.repeat="repeat");const s=t.isObject(m);(_||s)&&(v.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:J(r,n,a.width,i&&i.x),y:J(o,s,a.height,i&&i.y)}}(_,s&&m,K.width,K.height,n));break;default:b&&e.PaintImage.fillOrFitMode(v,n,K.x,K.y,b,E,f)}return v.transform||(n.x||n.y)&&Q(v.transform=q(),n.x,n.y),b&&(v.scaleX=b,v.scaleY=E),o&&o<1&&(v.opacity=o),w&&(v.filters=w),m&&(v.repeat=t.isString(m)?"x"===m?"repeat-x":"repeat-y":"repeat"),v},stretchMode:function(t,e,i,n){const s=it(),{x:a,y:r}=e;a||r?at(s,a,r):s.onlyScale=!0,lt(s,i,n),t.transform=s},fillOrFitMode:function(t,e,i,n,s,a,r){const o=it();at(o,e.x+i,e.y+n),lt(o,s,a),r&&st(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,n,s,a,r,o,l,d){const c=it();ht(c,e,i,n,s,a,r,o),l&&(r||o?(nt(et),rt(et,e,l,d),ot(c,et)):rt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,n,s,a,r,o,l,d,c,h){const u=it();if(h)ht(u,e,s,a,r,o,l,d);else{if(l)if("center"===c)st(u,{x:i/2,y:n/2},l);else switch(dt(u,l),l){case 90:at(u,n,0);break;case 180:at(u,i,n);break;case 270:at(u,0,i)}tt.x=e.x+s,tt.y=e.y+a,at(u,tt.x,tt.y),r&&rt(u,tt,r,o)}t.transform=u}},{toPoint:yt}=t.AroundHelper,{hasTransparent:vt}=e.ColorConvert,xt={},bt={};function Et(i,n,s,a){if(s){let r,o,l,d;for(let i=0,c=s.length;i<c;i++)r=s[i],t.isString(r)?(l=i/(c-1),o=e.ColorConvert.string(r,a)):(l=r.offset,o=e.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!d&&vt(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:St,getDistance:Bt}=t.PointHelper,{get:Rt,rotateOfOuter:Pt,scaleOfOuter:Lt}=t.MatrixHelper,{toPoint:kt}=t.AroundHelper,Ct={},At={};function Ot(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=St(e,i);a=Rt(),s?(Lt(a,e,r/o*(n||1),1),Pt(a,e,t+90)):(Lt(a,e,1,r/o*(n||1)),Pt(a,e,t))}return a}const{getDistance:Tt}=t.PointHelper,{toPoint:It}=t.AroundHelper,Mt={},Dt={};const Wt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;yt(n||"top",i,xt),yt(s||"bottom",i,bt);const o=t.Platform.canvas.createLinearGradient(xt.x,xt.y,bt.x,bt.y),l={type:a,style:o};return Et(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;kt(n||"center",i,Ct),kt(s||"bottom",i,At);const l=t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,Bt(Ct,At)),d={type:a,style:l};Et(d,l,e.stops,r);const c=Ot(i,Ct,At,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;It(n||"center",i,Mt),It(s||"bottom",i,Dt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Mt.x,Mt.y):t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,Tt(Mt,Dt)),d={type:a,style:l};Et(d,l,e.stops,r);const c=Ot(i,Mt,Dt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ot},{copy:Ht,move:Ft,toOffsetOutBounds:zt}=t.BoundsHelper,{max:Ut,abs:jt}=Math,Yt={},Gt=new t.Matrix,Vt={};function Nt(t,e){let i,n,s,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,a=1.5*(t.blur||0),s=jt(t.spread||0),r=Ut(r,s+a-n),o=Ut(o,s+a+i),l=Ut(l,s+a+n),d=Ut(d,s+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Xt(e,i,n){const{shapeBounds:s}=n;let a,r;t.Platform.fullImageShadow?(Ht(Yt,e.bounds),Ft(Yt,i.x-s.x,i.y-s.y),a=e.bounds,r=Yt):(a=s,r=i),e.copyWorld(n.canvas,a,r)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Qt={};const Zt=Nt;const $t={shadow:function(i,n,s){let a,r;const{__nowWorld:o}=i,{shadow:l}=i.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),m=l.length-1;zt(c,Vt,h),l.forEach((l,_)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Vt.offsetX+(l.x||0)*f*w,Vt.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w,e.ColorConvert.string(l.color)),r=e.Effect.getShadowTransform(i,g,s,l,Vt,w),r&&g.setTransform(r),Xt(g,Vt,s),r&&g.resetTransform(),a=h,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,h,o,"copy"),a=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,n,g,a,l.blendMode),m&&_<m&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(i,n,s){let a,r;const{__nowWorld:o}=i,{innerShadow:l}=i.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),m=l.length-1;qt(c,Qt,h),l.forEach((l,_)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(Qt.offsetX+(l.x||0)*f*w,Qt.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w),r=e.Effect.getShadowTransform(i,g,s,l,Qt,w,!0),r&&g.setTransform(r),Xt(g,Qt,s),g.restore(),d?(g.copyWorld(g,h,o,"copy"),g.copyWorld(d,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,c,"source-out"),a=h),g.fillWorld(a,e.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,a,l.blendMode),m&&_<m&&g.clearWorld(a)}),g.recycle(a)},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){},getShadowRenderSpread:Nt,getShadowTransform:function(t,e,i,n,s,a,r){if(n.spread){const i=2*n.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Gt.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/o,1+i/l),Gt}},isTransformShadow(t){},getInnerShadowSpread:Zt},{excludeRenderBounds:Kt}=t.LeafBoundsHelper;let Jt;function te(t,e,i,n,s,a,r,o){switch(e){case"grayscale":Jt||(Jt=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);ie(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":ie(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function ee(t){return t.getSameCanvas(!1,!0)}function ie(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(te(this,r,t,s,n,a,void 0,!0),n=s=null),"clipping"!==o&&"clipping-path"!==o||Kt(i,e)||i.__render(t,e),a=i.__.opacity,Jt=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=ee(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ee(t)),s||(s=ee(t)),i.__render(n,e));continue}const c=1===a&&i.__.__blendMode;c&&te(this,r,t,s,n,a,void 0,!1),Kt(i,e)||i.__render(s||t,e),c&&te(this,r,t,s,n,a,c,!1)}te(this,r,t,s,n,a,void 0,!0)};const ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",se=ne+"_#~&*+\\=|≮≯≈≠=…",ae=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 re(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const oe=re("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),le=re("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),de=re(ne),ce=re(se),he=re("- —/~|┆·");var ue;!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"}(ue||(ue={}));const{Letter:fe,Single:pe,Before:ge,After:me,Symbol:_e,Break:we}=ue;function ye(t){return oe[t]?fe:he[t]?we:le[t]?ge:de[t]?me:ce[t]?_e:ae.test(t)?pe:fe}const ve={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function xe(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:be}=ve,{Letter:Ee,Single:Se,Before:Be,After:Re,Symbol:Pe,Break:Le}=ue;let ke,Ce,Ae,Oe,Te,Ie,Me,De,We,He,Fe,ze,Ue,je,Ye,Ge,Ve,Ne=[];function Xe(t,e){We&&!De&&(De=We),ke.data.push({char:t,width:e}),Ae+=e}function qe(){Oe+=Ae,ke.width=Ae,Ce.words.push(ke),ke={data:[]},Ae=0}function Qe(){je&&(Ye.paraNumber++,Ce.paraStart=!0,je=!1),We&&(Ce.startCharSize=De,Ce.endCharSize=We,De=0),Ce.width=Oe,Ge.width?be(Ce):Ve&&Ze(),Ne.push(Ce),Ce={words:[]},Oe=0}function Ze(){Oe>(Ye.maxWidth||0)&&(Ye.maxWidth=Oe)}const{top:$e,right:Ke,bottom:Je,left:ti}=t.Direction4;function ei(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 ii={getDrawData:function(i,n){t.isString(i)||(i=String(i));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{__padding:l}=n;l&&(r?(s=l[ti],r-=l[Ke]+l[ti],!r&&(r=.01)):n.autoSizeAlign||(s=l[ti]),o?(a=l[$e],o-=l[$e]+l[Je],!o&&(o=.01)):n.autoSizeAlign||(a=l[$e]));const d={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=n.__font};return function(e,i,n){Ye=e,Ne=e.rows,Ge=e.bounds,Ve=!Ge.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l}=Ge;if(n.__isCharMode){const t="none"!==n.textWrap,e="break"===n.textWrap;je=!0,Fe=null,De=Me=We=Ae=Oe=0,ke={data:[]},Ce={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Ie=i[n],"\n"===Ie?(Ae&&qe(),Ce.paraEnd=!0,Qe(),je=!0):(He=ye(Ie),He===Ee&&"none"!==r&&(Ie=xe(Ie,r,!Ae)),Me=o.measureText(Ie).width,s&&(s<0&&(We=Me),Me+=s),ze=He===Se&&(Fe===Se||Fe===Ee)||Fe===Se&&He!==Re,Ue=!(He!==Be&&He!==Se||Fe!==Pe&&Fe!==Re),Te=je&&a?l-a:l,t&&l&&Oe+Ae+Me>Te&&(e?(Ae&&qe(),Oe&&Qe()):(Ue||(Ue=He===Ee&&Fe==Re),ze||Ue||He===Le||He===Be||He===Se||Ae+Me>Te?(Ae&&qe(),Oe&&Qe()):Oe&&Qe()))," "===Ie&&!0!==je&&Oe+Ae===0||(He===Le?(" "===Ie&&Ae&&qe(),Xe(Ie,Me),qe()):ze||Ue?(Ae&&qe(),Xe(Ie,Me)):Xe(Ie,Me)),Fe=He);Ae&&qe(),Oe&&Qe(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ye.paraNumber++,Oe=o.measureText(t).width,Ne.push({x:a||0,text:t,width:Oe,paraStart:!0}),Ve&&Ze()})}(d,i,n),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ei(e,"x",t[ti]);break;case"right":ei(e,"x",-t[Ke])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ei(e,"y",t[$e]);break;case"bottom":ei(e,"y",-t[Je])}}(l,d,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:m}=n,_=a*s+(h?h*(t.paraNumber-1):0),w=r;if(l&&_>m)_=Math.max(m,a),s>1&&(t.overflow=s);else if(m||u)switch(c){case"middle":p+=(m-_)/2;break;case"bottom":p+=m-_}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=a,t.overflow>r&&w>_&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=_}(d,n),n.__isCharMode&&function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e,o=i&&s.includes("both"),l=o||i&&s.includes("justify"),d=l&&s.includes("letter");let c,h,u,f,p,g,m,_,w,y;n.forEach(t=>{t.words&&(p=a&&t.paraStart?a:0,_=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=_>1?h/(_-1):0),g=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(m={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,m),(t.isOverflow||" "!==m.char)&&t.data.push(m)):c=function(t,e,i,n,s){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(w=i===_-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(d,n,r),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<c));n--){if(l<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(d,n,s,r),"none"!==n.textDecoration&&function(i,n){let s,a=0;const{fontSize:r,textDecoration:o}=n;switch(i.decorationHeight=r/11,t.isObject(o)?(s=o.type,o.color&&(i.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(a=Math.min(.3*r,Math.max(o.offset,.15*-r)))):s=o,s){case"under":i.decorationY=[.15*r+a];break;case"delete":i.decorationY=[.35*-r];break;case"under-delete":i.decorationY=[.15*r+a,.35*-r]}}(d,n),d}};const ni={string:function(i,n){if(!i)return"#000";const s=t.isNumber(n)&&n<1;if(t.isString(i)){if(!s||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let a=t.isUndefined(i.a)?1:i.a;s&&(a*=n);const r=i.r+","+i.g+","+i.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(e.TextConvert,ii),Object.assign(e.ColorConvert,ni),Object.assign(e.Paint,H),Object.assign(e.PaintImage,wt),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,$t),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,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");const i=t.Debug.get("LeaferCanvas");class n extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(e){let n=t.isString(e)?document.getElementById(e):e;if(n)if(n instanceof HTMLCanvasElement)this.view=n;else{let t=n;if(n===window||n===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else i.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:e,height:i,pixelRatio:n}=this,{style:a}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:n}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=a.width||""),a.width=e.width+"px"):t.isUndefined(i)||(a.width=i),e.height?(t.isUndefined(n)&&(this.autoHeightStr=a.height||""),a.height=e.height+"px"):t.isUndefined(n)||(a.height=n)}else a.width=e+"px",a.height=i+"px",this.view.width=Math.ceil(e*n),this.view.height=Math.ceil(i*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),i.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(e){const i=this.view,{x:n,y:a,width:s,height:r}=this.autoBounds.getBoundsFrom(e),o={width:s,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(o)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=a+"px",this.emitResize(o)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:a,fileType:s}=t.FileHelper;function r(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const n=a(e),s=t.toDataURL(n,i);return"image/bmp"===n?s.replace("image/png;","image/bmp;"):s},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,a(e),i)),canvasSaveAs:(e,i,n)=>{const r=e.toDataURL(a(s(i)),n);return t.Platform.origin.download(r,i)},download:(t,e)=>new Promise(i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()}),loadImage:e=>new Promise((i,n)=>{const a=new t.Platform.origin.Image,{crossOrigin:s}=t.Platform.image;s&&(a.setAttribute("crossOrigin",s),a.crossOrigin=s),a.onload=()=>{i(a)},a.onerror=t=>{n(t)},a.src=t.Platform.image.getRealURL(e)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},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="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{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,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,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,i=e.length;t<i;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=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateChange:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),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:m,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target: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 i=t.Run.start("PartLayout"),{target:n,__updatedList:a}=this,{BEFORE:s,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(a);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(a,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;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||c(n[t])}c(i)}})}(this.__levelList),function(t){t.list.forEach(h)}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:a,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(a,r,this.times)),i.emitEvent(new t.LayoutEvent(s,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){m(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[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 x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{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;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,a=e.getIntersect(n.bounds),s=new t.Bounds(a);n.save(),a.spread(x.clipSpread).ceil(),n.clearWorld(a),n.clipWorld(a),this.__render(a,s),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,a=e.includes(this.target.__world),s=a?{includes:a}:{bounds:e,includes:a};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),t.Platform.render(this.target,n,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&e>n)return t.Platform.requestRender(i);const{frames:a}=this;a.length>30&&a.shift(),a.push(e),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).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.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function b(t,i,n){t.__.__font?e.Paint.fillText(t,i,n):t.__.windingRule?i.fill(t.__.windingRule):i.fill()}function E(i,n,a,s,r){const o=a.__;t.isObject(i)?e.Paint.drawStrokesStyle(i,n,!1,a,s,r):(s.setStroke(i,o.__strokeWidth*n,o),s.stroke()),o.__useArrow&&e.Paint.strokeArrow(i,a,s,r)}function S(i,n,a,s,r){const o=a.__;t.isObject(i)?e.Paint.drawStrokesStyle(i,n,!0,a,s,r):(s.setStroke(i,o.__strokeWidth*n,o),e.Paint.drawTextStroke(a,s,r))}function P(i,n,a,s,r){const o=s.getSameCanvas(!0,!0);o.font=a.__.__font,S(i,2,a,o,r),o.blendMode="outside"===n?"destination-out":"destination-in",e.Paint.fillText(a,o,r),o.blendMode="normal",t.LeafHelper.copyCanvasByWorld(a,s,o),o.recycle(a.__nowWorld)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),t.Platform.layout=y.fullLayout,t.Platform.render=function(e,i,n){const a=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new t.LeafList,e.__render(i,n),n.topList.length&&n.topList.forEach(t=>t.__render(i,a))};const{getSpread:B,copyAndSpread:R,toOuterOf:L,getOuterOf:k,getByMove:C,move:A,getIntersectData:O}=t.BoundsHelper,T={};let I;const{stintSet:M}=t.DataHelper,{hasTransparent:D}=e.ColorConvert;function W(i,n,a){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let s;const{boxBounds:r}=a.__layout;switch(n.type){case"image":s=e.PaintImage.image(a,i,n,r,!I||!I[n.url]);break;case"linear":s=e.PaintGradient.linearGradient(n,r);break;case"radial":s=e.PaintGradient.radialGradient(n,r);break;case"angular":s=e.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;s={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(s={type:"solid",style:e.ColorConvert.string(n)})}if(s&&(s.originPaint=n,t.isString(s.style)&&D(s.style)&&(s.isTransparent=!0),n.style)){if(0===n.style.strokeWidth)return;s.strokeStyle=n.style}return s}const H={compute:function(i,n){const a=n.__,s=[];let r,o,l,d=a.__input[i];t.isArray(d)||(d=[d]),I=e.PaintImage.recycleImage(i,a);for(let t,e=0,a=d.length;e<a;e++)(t=W(i,d[e],n))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));a["_"+i]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(M(a,"__isAlphaPixelFill",r),M(a,"__isTransparentFill",o)):(M(a,"__isAlphaPixelStroke",r),M(a,"__isTransparentStroke",o),M(a,"__hasMultiStrokeStyle",l))):a.__removePaint(i,!1)},fill:function(t,e,i,n){i.fillStyle=t,b(e,i,n)},fills:function(t,i,n,a){let s,r,o;for(let l=0,d=t.length;l<d;l++){if(s=t[l],r=s.originPaint,s.image){if(o?o++:o=1,e.PaintImage.checkImage(s,!i.__.__font,i,n,a))continue;if(!s.style){1===o&&s.image.isPlacehold&&i.drawImagePlaceholder(s,n,a);continue}}if(n.fillStyle=s.style,s.transform||r.scaleFixed){if(n.save(),s.transform&&n.transform(s.transform),r.scaleFixed){const{scaleX:t,scaleY:e}=i.getRenderScaleData(!0);(!0===r.scaleFixed||"zoom-in"===r.scaleFixed&&t>1&&e>1)&&n.scale(1/t,1/e)}r.blendMode&&(n.blendMode=r.blendMode),b(i,n,a),n.restore()}else r.blendMode?(n.saveBlendMode(r.blendMode),b(i,n,a),n.restoreBlendMode()):b(i,n,a)}},fillPathOrText:b,fillText:function(t,e,i){const n=t.__,{rows:a,decorationY:s}=n.__textDrawData;let r;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,i=a.length;t<i;t++)r=a[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(s){const{decorationColor:t,decorationHeight:i}=n.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>s.forEach(n=>e.fillRect(t.x,t.y+n,t.width,i)))}},stroke:function(i,n,a,s){const r=n.__;if(r.__strokeWidth)if(r.__font)e.Paint.strokeText(i,n,a,s);else switch(r.strokeAlign){case"center":E(i,1,n,a,s);break;case"inside":!function(t,e,i,n){i.save(),i.clipUI(e),E(t,2,e,i,n),i.restore()}(i,n,a,s);break;case"outside":!function(e,i,n,a){const s=i.__;if(s.__fillAfterStroke)E(e,2,i,n,a);else{const{renderBounds:r}=i.__layout,o=n.getSameCanvas(!0,!0);i.__drawRenderPath(o),E(e,2,i,o,a),o.clipUI(s),o.clearWorld(r),t.LeafHelper.copyCanvasByWorld(i,n,o),o.recycle(i.__nowWorld)}}(i,n,a,s)}},strokes:function(t,i,n,a){e.Paint.stroke(t,i,n,a)},strokeText:function(t,e,i,n){switch(e.__.strokeAlign){case"center":S(t,1,e,i,n);break;case"inside":P(t,"inside",e,i,n);break;case"outside":e.__.__fillAfterStroke?S(t,2,e,i,n):P(t,"outside",e,i,n)}},drawTextStroke:function(t,e,i){let n,a=t.__.__textDrawData;const{rows:s,decorationY:r}=a;for(let t=0,i=s.length;t<i;t++)n=s[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)});if(r){const{decorationHeight:t}=a;s.forEach(i=>r.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}},drawStrokesStyle:function(t,i,n,a,s,r){let o;const l=a.__,{__hasMultiStrokeStyle:d}=l;d||s.setStroke(void 0,l.__strokeWidth*i,l);for(let c=0,h=t.length;c<h;c++)if(o=t[c],(!o.image||!e.PaintImage.checkImage(o,!1,a,s,r))&&o.style){if(d){const{strokeStyle:t}=o;t?s.setStroke(o.style,l.__getRealStrokeWidth(t)*i,l,t):s.setStroke(o.style,l.__strokeWidth*i,l)}else s.strokeStyle=o.style;o.originPaint.blendMode?(s.saveBlendMode(o.originPaint.blendMode),n?e.Paint.drawTextStroke(a,s,r):s.stroke(),s.restoreBlendMode()):n?e.Paint.drawTextStroke(a,s,r):s.stroke()}},shape:function(e,i,n){const a=i.getSameCanvas(),s=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,c,h,u,f,p;L(o.strokeSpread?(R(T,o.boxBounds,o.strokeSpread),T):o.boxBounds,r,l);let{scaleX:g,scaleY:m}=e.getRenderScaleData(!0);if(s.includes(l))p=a,d=f=l,c=r;else{let a;if(t.Platform.fullImageShadow)a=l;else{const e=o.renderShapeSpread?B(s,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,m)):s;a=O(e,l)}u=s.getFitMatrix(a);let{a:_,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,n),g*=_,m*=w),f=k(l,u),d=C(f,-u.e,-u.f),c=k(r,u),A(c,-u.e,-u.f);const y=n.matrix;y?(h=new t.Matrix(u),h.multiply(y),_*=y.scaleX,w*=y.scaleY):h=u,h.withScale(_,w),n=Object.assign(Object.assign({},n),{matrix:h})}return e.__renderShape(a,n),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:m}}};let z,F=new t.Bounds;const{isSame:U}=t.BoundsHelper;function j(t,i,n,a,s,r){if("fill"===i&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=a.width/e.pixelRatio,e.__naturalHeight=a.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||e.PaintImage.createData(s,a,n,r),!0}function Y(e,i){N(e,t.ImageEvent.LOAD,i)}function G(e,i){N(e,t.ImageEvent.LOADED,i)}function V(e,i,n){i.error=n,e.forceUpdate("surface"),N(e,t.ImageEvent.ERROR,i)}function N(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function X(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:q,translate:Q}=t.MatrixHelper,Z=new t.Bounds,$={},K={};function J(e,i,n,a){const s=t.isString(e)||a?(a?n-a*i:n%i)/((a||Math.floor(n/i))-1):e;return"auto"===e&&s<0?0:s}let tt={},et=t.getMatrixData();const{get:it,set:nt,rotateOfOuter:at,translate:st,scaleOfOuter:rt,multiplyParent:ot,scale:lt,rotate:dt,skew:ct}=t.MatrixHelper;function ht(t,e,i,n,a,s,r,o){r&&dt(t,r),o&&ct(t,o.x,o.y),a&&lt(t,a,s),st(t,e.x+i,e.y+n)}function ut(t,e,i,n){return new(i||(i=Promise))(function(a,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function o(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ft,scale:pt,copy:gt}=t.MatrixHelper,{getFloorScale:mt}=t.MathHelper,{abs:_t}=Math;const wt={image:function(e,i,n,a,s){let r,o;const l=t.ImageManager.get(n);return z&&n===z.paint&&U(a,z.boxBounds)?r=z.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),z=l.use>1?{leafPaint:r,paint:n,boxBounds:F.set(a)}:null),(s||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(j(e,i,n,l,r,a),s&&(Y(e,o),G(e,o))):l.error?s&&V(e,o,l.error):(s&&(X(e,!0),Y(e,o)),r.loadId=l.load(()=>{X(e,!1),e.destroyed||(j(e,i,n,l,r,a)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),G(e,o)),r.loadId=void 0},t=>{X(e,!1),V(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(i,n,a,s,r){const{scaleX:o,scaleY:l}=e.PaintImage.getImageRenderScaleData(i,a,s,r),{image:d,data:c,originPaint:h}=i,{exporting:u}=r;return!(!c||i.patternId===o+"-"+l&&!u)&&(n&&(c.repeat?n=!1:h.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(a)||u||(n=t.Platform.image.isLarge(d,o,l))),n?(a.__.__isFastShadow&&(s.fillStyle=i.style||"#000",s.fill()),e.PaintImage.drawImage(i,o,l,a,s,r),!0):(!i.style||h.sync||u?e.PaintImage.createPattern(i,a,s,r):e.PaintImage.createPatternTask(i,a,s,r),!1))},drawImage:function(t,e,i,n,a,s){const{data:r,image:o}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=r,h=o.getFull(r.filters),u=n.__;let f,{width:p,height:g}=o;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(a.save(),f&&a.clipUI(n),l&&(a.blendMode=l),d&&(a.opacity*=d),c&&a.transform(c),a.drawImage(h,0,0,p,g),a.restore()):(r.scaleX&&(p*=r.scaleX,g*=r.scaleY),a.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,i,n){const a=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:s}=t;if(i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return s&&s.scaleX&&(a.scaleX*=Math.abs(s.scaleX),a.scaleY*=Math.abs(s.scaleY)),a},recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let a,s,r,o,l;for(let d=0,c=n.length;d<c;d++)a=n[d],s=a.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),s.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createPatternTask:function(i,n,a,s){i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add(()=>ut(this,void 0,void 0,function*(){i.patternTask=null,a.bounds.hit(n.__nowWorld)&&e.PaintImage.createPattern(i,n,a,s),n.forceUpdate("surface")}),300))},createPattern:function(i,n,a,s){let{scaleX:r,scaleY:o}=e.PaintImage.getImageRenderScaleData(i,n,a,s),l=r+"-"+o;if(i.patternId!==l&&!n.destroyed&&(!t.Platform.image.isLarge(i.image,r,o)||i.data.repeat)){const{image:a,data:s}=i,{transform:d,gap:c}=s,h=e.PaintImage.getPatternFixScale(i,r,o);let u,f,p,{width:g,height:m}=a;h&&(r*=h,o*=h),g*=r,m*=o,c&&(f=c.x*r/_t(s.scaleX||1),p=c.y*o/_t(s.scaleY||1)),(d||1!==r||1!==o)&&(r*=mt(g+(f||0)),o*=mt(m+(p||0)),u=ft(),d&&gt(u,d),pt(u,1/r,1/o));const _=a.getCanvas(g,m,s.opacity,s.filters,f,p,n.leafer&&n.leafer.config.smooth),w=a.getPattern(_,s.repeat||t.Platform.origin.noRepeat||"no-repeat",u,i);i.style=w,i.patternId=l}},getPatternFixScale:function(e,i,n){const{image:a}=e;let s,r=t.Platform.image.maxPatternSize,o=a.width*a.height;return a.isSVG?i>1&&(s=Math.ceil(i)/i):r>o&&(r=o),(o*=i*n)>r&&(s=Math.sqrt(r/o)),s},createData:function(t,i,n,a){t.data=e.PaintImage.getPatternData(n,a,i)},getPatternData:function(i,n,a){i.padding&&(n=Z.set(n).shrink(i.padding)),"strench"===i.mode&&(i.mode="stretch");const{width:s,height:r}=a,{opacity:o,mode:l,align:d,offset:c,scale:h,size:u,rotation:f,skew:p,clipSize:g,repeat:m,gap:_,filters:w}=i,y=n.width===s&&n.height===r,v={mode:l},x="center"!==d&&(f||0)%180==90;let b,E;switch(t.BoundsHelper.set(K,0,0,x?r:s,x?s:r),l&&"cover"!==l&&"fit"!==l?((h||u)&&(t.MathHelper.getScaleData(h,u,a,$),b=$.scaleX,E=$.scaleY),(d||_||m)&&(b&&t.BoundsHelper.scale(K,b,E,!0),d&&t.AlignHelper.toPoint(d,K,n,K,!0,!0))):y&&!f||(b=E=t.BoundsHelper.getFitScale(n,K,"fit"!==l),t.BoundsHelper.put(n,a,d,b,!1,K),t.BoundsHelper.scale(K,b,E,!0)),c&&t.PointHelper.move(K,c),l){case"stretch":y?b&&(b=E=void 0):(b=n.width/s,E=n.height/r,e.PaintImage.stretchMode(v,n,b,E));break;case"normal":case"clip":if(K.x||K.y||b||g||f||p){let t,i;g&&(t=n.width/g.width,i=n.height/g.height),e.PaintImage.clipMode(v,n,K.x,K.y,b,E,f,p,t,i),t&&(b=b?b*t:t,E=E?E*i:i)}break;case"repeat":(!y||b||f||p)&&e.PaintImage.repeatMode(v,n,s,r,K.x,K.y,b,E,f,p,d,i.freeTransform),m||(v.repeat="repeat");const a=t.isObject(m);(_||a)&&(v.gap=function(e,i,n,a,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:J(r,n,s.width,i&&i.x),y:J(o,a,s.height,i&&i.y)}}(_,a&&m,K.width,K.height,n));break;default:b&&e.PaintImage.fillOrFitMode(v,n,K.x,K.y,b,E,f)}return v.transform||(n.x||n.y)&&Q(v.transform=q(),n.x,n.y),b&&(v.scaleX=b,v.scaleY=E),o&&o<1&&(v.opacity=o),w&&(v.filters=w),m&&(v.repeat=t.isString(m)?"x"===m?"repeat-x":"repeat-y":"repeat"),v},stretchMode:function(t,e,i,n){const a=it(),{x:s,y:r}=e;s||r?st(a,s,r):a.onlyScale=!0,lt(a,i,n),t.transform=a},fillOrFitMode:function(t,e,i,n,a,s,r){const o=it();st(o,e.x+i,e.y+n),lt(o,a,s),r&&at(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,n,a,s,r,o,l,d){const c=it();ht(c,e,i,n,a,s,r,o),l&&(r||o?(nt(et),rt(et,e,l,d),ot(c,et)):rt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,n,a,s,r,o,l,d,c,h){const u=it();if(h)ht(u,e,a,s,r,o,l,d);else{if(l)if("center"===c)at(u,{x:i/2,y:n/2},l);else switch(dt(u,l),l){case 90:st(u,n,0);break;case 180:st(u,i,n);break;case 270:st(u,0,i)}tt.x=e.x+a,tt.y=e.y+s,st(u,tt.x,tt.y),r&&rt(u,tt,r,o)}t.transform=u}},{toPoint:yt}=t.AroundHelper,{hasTransparent:vt}=e.ColorConvert,xt={},bt={};function Et(i,n,a,s){if(a){let r,o,l,d;for(let i=0,c=a.length;i<c;i++)r=a[i],t.isString(r)?(l=i/(c-1),o=e.ColorConvert.string(r,s)):(l=r.offset,o=e.ColorConvert.string(r.color,s)),n.addColorStop(l,o),!d&&vt(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:St,getDistance:Pt}=t.PointHelper,{get:Bt,rotateOfOuter:Rt,scaleOfOuter:Lt}=t.MatrixHelper,{toPoint:kt}=t.AroundHelper,Ct={},At={};function Ot(t,e,i,n,a){let s;const{width:r,height:o}=t;if(r!==o||n){const t=St(e,i);s=Bt(),a?(Lt(s,e,r/o*(n||1),1),Rt(s,e,t+90)):(Lt(s,e,1,r/o*(n||1)),Rt(s,e,t))}return s}const{getDistance:Tt}=t.PointHelper,{toPoint:It}=t.AroundHelper,Mt={},Dt={};const Wt={linearGradient:function(e,i){let{from:n,to:a,type:s,opacity:r}=e;yt(n||"top",i,xt),yt(a||"bottom",i,bt);const o=t.Platform.canvas.createLinearGradient(xt.x,xt.y,bt.x,bt.y),l={type:s,style:o};return Et(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:a,type:s,opacity:r,stretch:o}=e;kt(n||"center",i,Ct),kt(a||"bottom",i,At);const l=t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,Pt(Ct,At)),d={type:s,style:l};Et(d,l,e.stops,r);const c=Ot(i,Ct,At,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,i){let{from:n,to:a,type:s,opacity:r,stretch:o}=e;It(n||"center",i,Mt),It(a||"bottom",i,Dt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Mt.x,Mt.y):t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,Tt(Mt,Dt)),d={type:s,style:l};Et(d,l,e.stops,r);const c=Ot(i,Mt,Dt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ot},{copy:Ht,move:zt,toOffsetOutBounds:Ft}=t.BoundsHelper,{max:Ut,abs:jt}=Math,Yt={},Gt=new t.Matrix,Vt={};function Nt(t,e){let i,n,a,s,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,s=1.5*(t.blur||0),a=jt(t.spread||0),r=Ut(r,a+s-n),o=Ut(o,a+s+i),l=Ut(l,a+s+n),d=Ut(d,a+s-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Xt(e,i,n){const{shapeBounds:a}=n;let s,r;t.Platform.fullImageShadow?(Ht(Yt,e.bounds),zt(Yt,i.x-a.x,i.y-a.y),s=e.bounds,r=Yt):(s=a,r=i),e.copyWorld(n.canvas,s,r)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Qt={};const Zt=Nt;const $t={shadow:function(i,n,a){let s,r;const{__nowWorld:o}=i,{shadow:l}=i.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=n.getSameCanvas(),m=l.length-1;Ft(c,Vt,h),l.forEach((l,_)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Vt.offsetX+(l.x||0)*f*w,Vt.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w,e.ColorConvert.string(l.color)),r=e.Effect.getShadowTransform(i,g,a,l,Vt,w),r&&g.setTransform(r),Xt(g,Vt,a),r&&g.resetTransform(),s=h,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,h,o,"copy"),s=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(a.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,n,g,s,l.blendMode),m&&_<m&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(i,n,a){let s,r;const{__nowWorld:o}=i,{innerShadow:l}=i.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=n.getSameCanvas(),m=l.length-1;qt(c,Qt,h),l.forEach((l,_)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(Qt.offsetX+(l.x||0)*f*w,Qt.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w),r=e.Effect.getShadowTransform(i,g,a,l,Qt,w,!0),r&&g.setTransform(r),Xt(g,Qt,a),g.restore(),d?(g.copyWorld(g,h,o,"copy"),g.copyWorld(d,o,o,"source-out"),s=o):(g.copyWorld(a.canvas,u,c,"source-out"),s=h),g.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,s,l.blendMode),m&&_<m&&g.clearWorld(s)}),g.recycle(s)},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){},getShadowRenderSpread:Nt,getShadowTransform:function(t,e,i,n,a,s,r){if(n.spread){const i=2*n.spread*s*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Gt.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/o,1+i/l),Gt}},isTransformShadow(t){},getInnerShadowSpread:Zt},{excludeRenderBounds:Kt}=t.LeafBoundsHelper;let Jt;function te(t,e,i,n,a,s,r,o){switch(e){case"grayscale":Jt||(Jt=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,a,s){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),s&&n.recycle(r);ie(t,e,i,1,a,s)}(t,i,n,a,r,o);break;case"opacity-path":ie(t,i,n,s,r,o);break;case"path":o&&i.restore()}}function ee(t){return t.getSameCanvas(!1,!0)}function ie(t,e,i,n,a,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,a),s?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,n,a,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(te(this,r,t,a,n,s,void 0,!0),n=a=null),"clipping"!==o&&"clipping-path"!==o||Kt(i,e)||i.__render(t,e),s=i.__.opacity,Jt=!1,"path"===o||"clipping-path"===o?(s<1?(r="opacity-path",a||(a=ee(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ee(t)),a||(a=ee(t)),i.__render(n,e));continue}const c=1===s&&i.__.__blendMode;c&&te(this,r,t,a,n,s,void 0,!1),Kt(i,e)||i.__render(a||t,e),c&&te(this,r,t,a,n,s,c,!1)}te(this,r,t,a,n,s,void 0,!0)};const ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ae=ne+"_#~&*+\\=|≮≯≈≠=…",se=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 re(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const oe=re("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),le=re("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),de=re(ne),ce=re(ae),he=re("- —/~|┆·");var ue;!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"}(ue||(ue={}));const{Letter:fe,Single:pe,Before:ge,After:me,Symbol:_e,Break:we}=ue;function ye(t){return oe[t]?fe:he[t]?we:le[t]?ge:de[t]?me:ce[t]?_e:se.test(t)?pe:fe}const ve={trimRight(t){const{words:e}=t;let i,n=0,a=e.length;for(let s=a-1;s>-1&&(i=e[s].data[0]," "===i.char);s--)n++,t.width-=i.width;n&&e.splice(a-n,n)}};function xe(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:be}=ve,{Letter:Ee,Single:Se,Before:Pe,After:Be,Symbol:Re,Break:Le}=ue;let ke,Ce,Ae,Oe,Te,Ie,Me,De,We,He,ze,Fe,Ue,je,Ye,Ge,Ve,Ne=[];function Xe(t,e){We&&!De&&(De=We),ke.data.push({char:t,width:e}),Ae+=e}function qe(){Oe+=Ae,ke.width=Ae,Ce.words.push(ke),ke={data:[]},Ae=0}function Qe(){je&&(Ye.paraNumber++,Ce.paraStart=!0,je=!1),We&&(Ce.startCharSize=De,Ce.endCharSize=We,De=0),Ce.width=Oe,Ge.width?be(Ce):Ve&&Ze(),Ne.push(Ce),Ce={words:[]},Oe=0}function Ze(){Oe>(Ye.maxWidth||0)&&(Ye.maxWidth=Oe)}const{top:$e,right:Ke,bottom:Je,left:ti}=t.Direction4;function ei(t,e,i){const{bounds:n,rows:a}=t;n[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const ii={getDrawData:function(i,n){t.isString(i)||(i=String(i));let a=0,s=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{__padding:l}=n;l&&(r?(a=l[ti],r-=l[Ke]+l[ti],!r&&(r=.01)):n.autoSizeAlign||(a=l[ti]),o?(s=l[$e],o-=l[$e]+l[Je],!o&&(o=.01)):n.autoSizeAlign||(s=l[$e]));const d={bounds:{x:a,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=n.__font};return function(e,i,n){Ye=e,Ne=e.rows,Ge=e.bounds,Ve=!Ge.width&&!n.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:r}=n,{canvas:o}=t.Platform,{width:l}=Ge;if(n.__isCharMode){const t="none"!==n.textWrap,e="break"===n.textWrap;je=!0,ze=null,De=Me=We=Ae=Oe=0,ke={data:[]},Ce={words:[]},a&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Ie=i[n],"\n"===Ie?(Ae&&qe(),Ce.paraEnd=!0,Qe(),je=!0):(He=ye(Ie),He===Ee&&"none"!==r&&(Ie=xe(Ie,r,!Ae)),Me=o.measureText(Ie).width,a&&(a<0&&(We=Me),Me+=a),Fe=He===Se&&(ze===Se||ze===Ee)||ze===Se&&He!==Be,Ue=!(He!==Pe&&He!==Se||ze!==Re&&ze!==Be),Te=je&&s?l-s:l,t&&l&&Oe+Ae+Me>Te&&(e?(Ae&&qe(),Oe&&Qe()):(Ue||(Ue=He===Ee&&ze==Be),Fe||Ue||He===Le||He===Pe||He===Se||Ae+Me>Te?(Ae&&qe(),Oe&&Qe()):Oe&&Qe()))," "===Ie&&!0!==je&&Oe+Ae===0||(He===Le?(" "===Ie&&Ae&&qe(),Xe(Ie,Me),qe()):Fe||Ue?(Ae&&qe(),Xe(Ie,Me)):Xe(Ie,Me)),ze=He);Ae&&qe(),Oe&&Qe(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ye.paraNumber++,Oe=o.measureText(t).width,Ne.push({x:s||0,text:t,width:Oe,paraStart:!0}),Ve&&Ze()})}(d,i,n),l&&function(t,e,i,n,a){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ei(e,"x",t[ti]);break;case"right":ei(e,"x",-t[Ke])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ei(e,"y",t[$e]);break;case"bottom":ei(e,"y",-t[Je])}}(l,d,n,r,o),function(t,e){const{rows:i,bounds:n}=t,a=i.length,{__lineHeight:s,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:m}=n,_=s*a+(h?h*(t.paraNumber-1):0),w=r;if(l&&_>m)_=Math.max(m,s),a>1&&(t.overflow=a);else if(m||u)switch(c){case"middle":p+=(m-_)/2;break;case"bottom":p+=m-_}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=a;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=s,t.overflow>r&&w>_&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=_}(d,n),n.__isCharMode&&function(t,e,i){const{rows:n}=t,{textAlign:a,paraIndent:s,letterSpacing:r}=e,o=i&&a.includes("both"),l=o||i&&a.includes("justify"),d=l&&a.includes("letter");let c,h,u,f,p,g,m,_,w,y;n.forEach(t=>{t.words&&(p=s&&t.paraStart?s:0,_=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=_>1?h/(_-1):0),g=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(m={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,m),(t.isOverflow||" "!==m.char)&&t.data.push(m)):c=function(t,e,i,n,a){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(w=i===_-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(d,n,r),d.overflow&&function(e,i,n,a){if(!a)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=i;if(s.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=n+a-d;("none"===i.textWrap?s:[s[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<c));n--){if(l<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(d,n,a,r),"none"!==n.textDecoration&&function(i,n){let a,s=0;const{fontSize:r,textDecoration:o}=n;switch(i.decorationHeight=r/11,t.isObject(o)?(a=o.type,o.color&&(i.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):a=o,a){case"under":i.decorationY=[.15*r+s];break;case"delete":i.decorationY=[.35*-r];break;case"under-delete":i.decorationY=[.15*r+s,.35*-r]}}(d,n),d}};const ni={string:function(i,n){if(!i)return"#000";const a=t.isNumber(n)&&n<1;if(t.isString(i)){if(!a||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let s=t.isUndefined(i.a)?1:i.a;a&&(s*=n);const r=i.r+","+i.g+","+i.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(e.TextConvert,ii),Object.assign(e.ColorConvert,ni),Object.assign(e.Paint,H),Object.assign(e.PaintImage,wt),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,$t),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,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]}})});
2
2
  //# sourceMappingURL=web.min.cjs.map