@leafer-ui/node 1.12.4 → 2.0.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/node.cjs CHANGED
@@ -465,6 +465,7 @@ class Renderer {
465
465
  this.times = 0;
466
466
  this.config = {
467
467
  usePartRender: true,
468
+ ceilPartPixel: true,
468
469
  maxFPS: 120
469
470
  };
470
471
  this.frames = [];
@@ -573,8 +574,9 @@ class Renderer {
573
574
  const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
574
575
  canvas.save();
575
576
  bounds.spread(Renderer.clipSpread).ceil();
576
- canvas.clearWorld(bounds);
577
- canvas.clipWorld(bounds);
577
+ const {ceilPartPixel: ceilPartPixel} = this.config;
578
+ canvas.clipWorld(bounds, ceilPartPixel);
579
+ canvas.clearWorld(bounds, ceilPartPixel);
578
580
  this.__render(bounds, realBounds);
579
581
  canvas.restore();
580
582
  core.Run.end(t);
@@ -1384,7 +1386,7 @@ function getPatternData(paint, box, image) {
1384
1386
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1385
1387
  if (paint.mode === "strench") paint.mode = "stretch";
1386
1388
  const {width: width, height: height} = image;
1387
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters} = paint;
1389
+ const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
1388
1390
  const sameBox = box.width === width && box.height === height;
1389
1391
  const data = {
1390
1392
  mode: mode
@@ -1450,6 +1452,10 @@ function getPatternData(paint, box, image) {
1450
1452
  if (opacity && opacity < 1) data.opacity = opacity;
1451
1453
  if (filters) data.filters = filters;
1452
1454
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1455
+ if (interlace) data.interlace = core.isNumber(interlace) || interlace.type === "percent" ? {
1456
+ type: "x",
1457
+ offset: interlace
1458
+ } : interlace;
1453
1459
  return data;
1454
1460
  }
1455
1461
 
@@ -1583,7 +1589,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1583
1589
  if (transform) copy$1(imageMatrix, transform);
1584
1590
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1585
1591
  }
1586
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1592
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1587
1593
  const pattern = image.getPattern(imageCanvas, data.repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1588
1594
  paint.style = pattern;
1589
1595
  paint.patternId = id;
@@ -1605,8 +1611,8 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1605
1611
 
1606
1612
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1607
1613
  const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1608
- const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
1609
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
1614
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1615
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1610
1616
  return false;
1611
1617
  } else {
1612
1618
  if (drawImage) {
@@ -2280,7 +2286,7 @@ const TextMode = 2;
2280
2286
 
2281
2287
  function layoutChar(drawData, style, width, _height) {
2282
2288
  const {rows: rows} = drawData;
2283
- const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
2289
+ const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
2284
2290
  const justifyLast = width && textAlign.includes("both");
2285
2291
  const justify = justifyLast || width && textAlign.includes("justify");
2286
2292
  const justifyLetter = justify && textAlign.includes("letter");
@@ -2293,8 +2299,8 @@ function layoutChar(drawData, style, width, _height) {
2293
2299
  remainingWidth = width - row.width - indentWidth;
2294
2300
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
2295
2301
  }
2296
- mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2297
- if (row.isOverflow && !letterSpacing) row.textMode = true;
2302
+ mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2303
+ if (row.isOverflow && !__letterSpacing) row.textMode = true;
2298
2304
  if (mode === TextMode) {
2299
2305
  row.x += indentWidth;
2300
2306
  toTextChar$1(row);
@@ -2363,7 +2369,7 @@ function layoutText(drawData, style) {
2363
2369
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2364
2370
  let starY = __baseLine;
2365
2371
  if (__clipText && realHeight > height) {
2366
- realHeight = Math.max(height, __lineHeight);
2372
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
2367
2373
  if (countRows > 1) drawData.overflow = countRows;
2368
2374
  } else if (height || autoSizeAlign) {
2369
2375
  switch (verticalAlign) {
@@ -2420,10 +2426,10 @@ function layoutText(drawData, style) {
2420
2426
  }
2421
2427
 
2422
2428
  function clipText(drawData, style, x, width) {
2423
- if (!width) return;
2424
2429
  const {rows: rows, overflow: overflow} = drawData;
2425
2430
  let {textOverflow: textOverflow} = style;
2426
- rows.splice(overflow);
2431
+ if (overflow) rows.splice(overflow);
2432
+ if (!width) return;
2427
2433
  if (textOverflow && textOverflow !== "show") {
2428
2434
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
2429
2435
  let char, charRight;
@@ -2670,7 +2676,13 @@ const ExportModule = {
2670
2676
  draw.MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
2671
2677
  let pixelRatio = options.pixelRatio || 1;
2672
2678
  let {x: x, y: y, width: width, height: height} = new draw.Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
2673
- if (clip) x += clip.x, y += clip.y, width = clip.width, height = clip.height;
2679
+ if (clip) {
2680
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
2681
+ if (clip.rotation) matrix.rotateOfInner({
2682
+ x: x,
2683
+ y: y
2684
+ }, -clip.rotation);
2685
+ }
2674
2686
  const renderOptions = {
2675
2687
  exporting: true,
2676
2688
  matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY)
package/dist/node.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, PointHelper, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, isUndefined, isString, ImageEvent, MatrixHelper, MathHelper, AlignHelper, getMatrixData, AroundHelper, Direction4, isNumber } from "@leafer/core";
1
+ import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, PointHelper, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, isUndefined, isString, ImageEvent, MatrixHelper, MathHelper, AlignHelper, isNumber, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
2
2
 
3
3
  export * from "@leafer/core";
4
4
 
@@ -469,6 +469,7 @@ class Renderer {
469
469
  this.times = 0;
470
470
  this.config = {
471
471
  usePartRender: true,
472
+ ceilPartPixel: true,
472
473
  maxFPS: 120
473
474
  };
474
475
  this.frames = [];
@@ -577,8 +578,9 @@ class Renderer {
577
578
  const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
578
579
  canvas.save();
579
580
  bounds.spread(Renderer.clipSpread).ceil();
580
- canvas.clearWorld(bounds);
581
- canvas.clipWorld(bounds);
581
+ const {ceilPartPixel: ceilPartPixel} = this.config;
582
+ canvas.clipWorld(bounds, ceilPartPixel);
583
+ canvas.clearWorld(bounds, ceilPartPixel);
582
584
  this.__render(bounds, realBounds);
583
585
  canvas.restore();
584
586
  Run.end(t);
@@ -1388,7 +1390,7 @@ function getPatternData(paint, box, image) {
1388
1390
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1389
1391
  if (paint.mode === "strench") paint.mode = "stretch";
1390
1392
  const {width: width, height: height} = image;
1391
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters} = paint;
1393
+ const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
1392
1394
  const sameBox = box.width === width && box.height === height;
1393
1395
  const data = {
1394
1396
  mode: mode
@@ -1454,6 +1456,10 @@ function getPatternData(paint, box, image) {
1454
1456
  if (opacity && opacity < 1) data.opacity = opacity;
1455
1457
  if (filters) data.filters = filters;
1456
1458
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1459
+ if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
1460
+ type: "x",
1461
+ offset: interlace
1462
+ } : interlace;
1457
1463
  return data;
1458
1464
  }
1459
1465
 
@@ -1587,7 +1593,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1587
1593
  if (transform) copy$1(imageMatrix, transform);
1588
1594
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1589
1595
  }
1590
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1596
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1591
1597
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1592
1598
  paint.style = pattern;
1593
1599
  paint.patternId = id;
@@ -1609,8 +1615,8 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1609
1615
 
1610
1616
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1611
1617
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1612
- const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
1613
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
1618
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1619
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1614
1620
  return false;
1615
1621
  } else {
1616
1622
  if (drawImage) {
@@ -2284,7 +2290,7 @@ const TextMode = 2;
2284
2290
 
2285
2291
  function layoutChar(drawData, style, width, _height) {
2286
2292
  const {rows: rows} = drawData;
2287
- const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
2293
+ const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
2288
2294
  const justifyLast = width && textAlign.includes("both");
2289
2295
  const justify = justifyLast || width && textAlign.includes("justify");
2290
2296
  const justifyLetter = justify && textAlign.includes("letter");
@@ -2297,8 +2303,8 @@ function layoutChar(drawData, style, width, _height) {
2297
2303
  remainingWidth = width - row.width - indentWidth;
2298
2304
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
2299
2305
  }
2300
- mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2301
- if (row.isOverflow && !letterSpacing) row.textMode = true;
2306
+ mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2307
+ if (row.isOverflow && !__letterSpacing) row.textMode = true;
2302
2308
  if (mode === TextMode) {
2303
2309
  row.x += indentWidth;
2304
2310
  toTextChar$1(row);
@@ -2367,7 +2373,7 @@ function layoutText(drawData, style) {
2367
2373
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2368
2374
  let starY = __baseLine;
2369
2375
  if (__clipText && realHeight > height) {
2370
- realHeight = Math.max(height, __lineHeight);
2376
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
2371
2377
  if (countRows > 1) drawData.overflow = countRows;
2372
2378
  } else if (height || autoSizeAlign) {
2373
2379
  switch (verticalAlign) {
@@ -2424,10 +2430,10 @@ function layoutText(drawData, style) {
2424
2430
  }
2425
2431
 
2426
2432
  function clipText(drawData, style, x, width) {
2427
- if (!width) return;
2428
2433
  const {rows: rows, overflow: overflow} = drawData;
2429
2434
  let {textOverflow: textOverflow} = style;
2430
- rows.splice(overflow);
2435
+ if (overflow) rows.splice(overflow);
2436
+ if (!width) return;
2431
2437
  if (textOverflow && textOverflow !== "show") {
2432
2438
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
2433
2439
  let char, charRight;
@@ -2674,7 +2680,13 @@ const ExportModule = {
2674
2680
  MathHelper$1.getScaleData(options.scale, options.size, renderBounds, scaleData);
2675
2681
  let pixelRatio = options.pixelRatio || 1;
2676
2682
  let {x: x, y: y, width: width, height: height} = new Bounds$1(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
2677
- if (clip) x += clip.x, y += clip.y, width = clip.width, height = clip.height;
2683
+ if (clip) {
2684
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
2685
+ if (clip.rotation) matrix.rotateOfInner({
2686
+ x: x,
2687
+ y: y
2688
+ }, -clip.rotation);
2689
+ }
2678
2690
  const renderOptions = {
2679
2691
  exporting: true,
2680
2692
  matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY)
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as a,LeaferImage as n,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,ResizeEvent as S,PointHelper as k,BoundsHelper as B,Plugin as R,isObject as L,FourNumberHelper as E,Matrix as T,isUndefined as P,isString as A,ImageEvent as C,MatrixHelper as O,MathHelper as M,AlignHelper as W,getMatrixData as D,AroundHelper as F,Direction4 as I,isNumber as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as X}from"fs";import{HitCanvasManager as U,InteractionBase as N}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as q,PaintImage as z,ColorConvert as j,PaintGradient as G,Effect as H,Group as V,TextConvert as Q,TwoPointBoundsHelper as J,Bounds as Z,Export as $,FileHelper as K,Platform as tt,isUndefined as et,Matrix as it,MathHelper as st,Creator as at,TaskProcessor as nt,Resource as rt,LeaferCanvasBase as ot,Debug as lt,Plugin as dt,UI as ct}from"@leafer-ui/draw";var ht;function ut(t,e,i,s){return new(i||(i=Promise))(function(a,n){function r(t){try{l(s.next(t))}catch(t){n(t)}}function o(t){try{l(s.throw(t))}catch(t){n(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((s=s.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(ht||(ht={})),"function"==typeof SuppressedError&&SuppressedError;class ft extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:gt,fileType:pt}=s;function _t(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURL(gt(e),i),canvasToBolb:(t,e,i)=>ut(this,void 0,void 0,function*(){return t.toBuffer(gt(e),i)}),canvasSaveAs:(t,e,i)=>ut(this,void 0,void 0,function*(){return X(e,t.toBuffer(gt(pt(e)),i))}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas()}}Object.assign(a,{canvas:(t,e)=>new ft(t,e),image:t=>new n(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},r(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class wt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:yt,updateBounds:mt,updateChange:vt}=f,{pushAllChildBranch:xt,pushAllParent:bt}=g;const{worldBounds:St}=p;class kt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,St)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,St),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:Bt,updateAllChange:Rt}=f,Lt=y.get("Layouter");class Et{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){Lt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Lt.warn("layouting"):this.times>3?Lt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:r}=v,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new v(a,o,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?(yt(t,!0),e.add(t),t.isBranch&&xt(t,e),bt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),bt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;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){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||mt(s[t])}mt(i)}})}(this.__levelList),function(t){t.list.forEach(vt)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new v(n,o,this.times)),i.emitEvent(new v(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=v,n=this.getBlocks(new o(e));e.emitEvent(new v(i,n,this.times)),Et.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new v(s,n,this.times)),e.emitEvent(new v(a,n,this.times)),this.addBlocks(n),x.end(t)}static fullLayout(t){Bt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),Rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new kt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new kt(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_([[v.REQUEST,this.layout,this],[v.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Tt=y.get("Renderer");class Pt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(v.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Tt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,Tt.error(t)}Tt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Tt.warn("rendering");if(this.times>3)return Tt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),a=new _(s);i.save(),s.spread(Pt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,a),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,i){const{canvas:s,target:a}=this,n=t.includes(a.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(a,s,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}getCellList(){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);const{frames:a}=this;a.length>30&&a.shift(),a.push(t),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(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||Tt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[v.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Pt.clipSpread=10;const At={},{copyRadiusPoint:Ct}=k,{hitRadiusPoint:Ot}=B;class Mt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,n=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(n.isBranchLeaf?{children:[n]}:n);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,a,!!i.findList),d=a?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const a=this.findList=new o;if(t.length){let e;const{x:s,y:n}=this.point,r={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,r),a.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){a.reset();break}return a.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),a.length)return a.list[0];return s?null:i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,a,n;for(let t=0,r=i.length;t<r;t++){s=i[t],a=i[t+1];for(let t=0,i=s.length;t<i&&(n=s.list[t],!a||!a.has(n));t++)e.add(n)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s,a;const{point:n}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],a=i.__,a.visible&&(!e||a.mask))if(s=Ot(i.__world,a.hitRadius?Ct(At,n,a.hitRadius):n),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&a.__clipAfterFill&&!i.__hitWorld(n,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)}}else s&&this.hitChild(i,n)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,a=[];const{children:n}=s;for(let s=0,r=n.length;s<r;s++)if(i=n[s],i.__.mask&&a.push(i),i===t){if(a&&!a.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Wt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Mt(this.target=t,this),this.finder=a.finder&&a.finder()}getByPoint(t,i,s){const{target:a,picker:n}=this;return e.backgrounder&&a&&a.updateLayout(),n.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Dt(t,e,i){t.__.__font?q.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Ft(t,e,i,s,a){const n=i.__;L(t)?q.drawStrokesStyle(t,e,!1,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&q.strokeArrow(t,i,s,a)}function It(t,e,i,s,a){const n=i.__;L(t)?q.drawStrokesStyle(t,e,!0,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),q.drawTextStroke(i,s,a))}function Yt(t,e,i,s,a){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,It(t,2,i,n,a),n.blendMode="outside"===e?"destination-out":"destination-in",q.fillText(i,n,a),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}Object.assign(a,{watcher:(t,e)=>new wt(t,e),layouter:(t,e)=>new Et(t,e),renderer:(t,e,i)=>new Pt(t,e,i),selector:(t,e)=>new Wt(t,e)}),e.layout=Et.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:Xt,copyAndSpread:Ut,toOuterOf:Nt,getOuterOf:qt,getByMove:zt,move:jt,getIntersectData:Gt}=B,Ht={};let Vt;const{stintSet:Qt}=l,{hasTransparent:Jt}=j;function Zt(t,e,i){if(!L(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:a}=i.__layout;switch(e.type){case"image":if(!e.url)return;s=z.image(i,t,e,a,!Vt||!Vt[e.url]);break;case"linear":s=G.linearGradient(e,a);break;case"radial":s=G.radialGradient(e,a);break;case"angular":s=G.conicGradient(e,a);break;case"solid":const{type:n,color:r,opacity:o}=e;s={type:n,style:j.string(r,o)};break;default:P(e.r)||(s={type:"solid",style:j.string(e)})}if(s&&(s.originPaint=e,A(s.style)&&Jt(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const $t={compute:function(t,e){const i=e.__,s=[];let a,n,r,o=i.__input[t];w(o)||(o=[o]),Vt=z.recycleImage(t,i);for(let i,a=0,n=o.length;a<n;a++)(i=Zt(t,o[a],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(a=!0),n=!0),"fill"===t?(Qt(i,"__isAlphaPixelFill",a),Qt(i,"__isTransparentFill",n)):(Qt(i,"__isAlphaPixelStroke",a),Qt(i,"__isTransparentStroke",n),Qt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Dt(e,i,s)},fills:function(t,e,i,s){let a,n,r;for(let o=0,l=t.length;o<l;o++){if(a=t[o],n=a.originPaint,a.image){if(r?r++:r=1,z.checkImage(a,!e.__.__font,e,i,s))continue;if(!a.style){1===r&&a.image.isPlacehold&&e.drawImagePlaceholder(a,i,s);continue}}if(i.fillStyle=a.style,a.transform||n.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===n.scaleFixed||"zoom-in"===n.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}n.blendMode&&(i.blendMode=n.blendMode),Dt(e,i,s),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),Dt(e,i,s),i.restoreBlendMode()):Dt(e,i,s)}},fillPathOrText:Dt,fillText:function(t,e,i){const s=t.__,{rows:a,decorationY:n}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.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(n){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const a=e.__;if(a.__strokeWidth)if(a.__font)q.strokeText(t,e,i,s);else switch(a.strokeAlign){case"center":Ft(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Ft(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const a=e.__;if(a.__fillAfterStroke)Ft(t,2,e,i,s);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),Ft(t,2,e,r,s),r.clipUI(a),r.clearWorld(n),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){q.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":It(t,1,e,i,s);break;case"inside":Yt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?It(t,2,e,i,s):Yt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,a=t.__.__textDrawData;const{rows:n,decorationY:r}=a;for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=a;n.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,a,n){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!z.checkImage(r,!1,s,a,n))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.originPaint.blendMode?(a.saveBlendMode(r.originPaint.blendMode),i?q.drawTextStroke(s,a,n):a.stroke(),a.restoreBlendMode()):i?q.drawTextStroke(s,a,n):a.stroke()}},shape:function(t,i,s){const a=i.getSameCanvas(),n=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;Nt(o.strokeSpread?(Ut(Ht,o.boxBounds,o.strokeSpread),Ht):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=a,d=f=l,c=r;else{let a;if(e.fullImageShadow)a=l;else{const t=o.renderShapeSpread?Xt(n,E.swapAndScale(o.renderShapeSpread,p,_)):n;a=Gt(t,l)}u=n.getFitMatrix(a);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=qt(l,u),d=zt(f,-u.e,-u.f),c=qt(r,u),jt(c,-u.e,-u.f);const m=s.matrix;m?(h=new T(u),h.multiply(m),w*=m.scaleX,y*=m.scaleY):h=u,h.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(a,s),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Kt,te=new _;const{isSame:ee}=B;function ie(t,e,i,s,a,n){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||z.createData(a,s,i,n),!0}function se(t,e){re(t,C.LOAD,e)}function ae(t,e){re(t,C.LOADED,e)}function ne(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,C.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function oe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,translate:de}=O,ce=new _,he={},ue={};function fe(t,e,i,s){const a=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let ge={},pe=D();const{get:_e,set:we,rotateOfOuter:ye,translate:me,scaleOfOuter:ve,multiplyParent:xe,scale:be,rotate:Se,skew:ke}=O;function Be(t,e,i,s,a,n,r,o){r&&Se(t,r),o&&ke(t,o.x,o.y),a&&be(t,a,n),me(t,e.x+i,e.y+s)}const{get:Re,scale:Le,copy:Ee}=O,{getFloorScale:Te}=M,{abs:Pe}=Math;const Ae={image:function(t,e,i,s,a){let n,r;const o=b.get(i);return Kt&&i===Kt.paint&&ee(s,Kt.boxBounds)?n=Kt.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Kt=o.use>1?{leafPaint:n,paint:i,boxBounds:te.set(s)}:null),(a||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(ie(t,e,i,o,n,s),a&&(se(t,r),ae(t,r))):o.error?a&&ne(t,r,o.error):(a&&(oe(t,!0),se(t,r)),n.loadId=o.load(()=>{oe(t,!1),t.destroyed||(ie(t,e,i,o,n,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,r)),n.loadId=void 0},e=>{oe(t,!1),ne(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,i,s,a,n){const{scaleX:r,scaleY:o}=z.getImageRenderScaleData(t,s,a,n),{image:l,data:d,originPaint:c}=t,{exporting:h}=n;return!(!d||t.patternId===r+"-"+o&&!h)&&(i&&(d.repeat?i=!1:c.changeful||"miniapp"===e.name&&S.isResizing(s)||h||(i=e.image.isLarge(l,r,o)||l.width*r>8096||l.height*o>8096)),i?(s.__.__isFastShadow&&(a.fillStyle=t.style||"#000",a.fill()),z.drawImage(t,r,o,s,a,n),!0):(!t.style||c.sync||h?z.createPattern(t,s,a,n):z.createPatternTask(t,s,a,n),!1))},drawImage:function(t,e,i,s,a,n){const{data:r,image:o}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=r,h=o.getFull(r.filters),u=s.__;let f,{width:g,height:p}=o;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(a.save(),f&&a.clipUI(s),l&&(a.blendMode=l),d&&(a.opacity*=d),c&&a.transform(c),a.drawImage(h,0,0,g,p),a.restore()):(r.scaleX&&(g*=r.scaleX,p*=r.scaleY),a.drawImage(h,0,0,g,p))},getImageRenderScaleData:function(t,e,i,s){const a=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return n&&n.scaleX&&(a.scaleX*=Math.abs(n.scaleX),a.scaleY*=Math.abs(n.scaleY)),a},recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,a,n,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],a=s.image,o=a&&a.url,o&&(n||(n={}),n[o]=!0,b.recyclePaint(s),a.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),a.unload(i[l].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=b.patternTasker.add(()=>ut(this,void 0,void 0,function*(){z.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,s,a){let{scaleX:n,scaleY:r}=z.getImageRenderScaleData(t,i,s,a),o=n+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:s,data:a}=t,{transform:l,gap:d}=a,c=z.getPatternFixScale(t,n,r);let h,u,f,{width:g,height:p}=s;c&&(n*=c,r*=c),g*=n,p*=r,d&&(u=d.x*n/Pe(a.scaleX||1),f=d.y*r/Pe(a.scaleY||1)),(l||1!==n||1!==r)&&(n*=Te(g+(u||0)),r*=Te(p+(f||0)),h=Re(),l&&Ee(h,l),Le(h,1/n,1/r));const _=s.getCanvas(g,p,a.opacity,a.filters,u,f,i.leafer&&i.leafer.config.smooth),w=s.getPattern(_,a.repeat||e.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,s){const{image:a}=t;let n,r=e.image.maxPatternSize,o=a.width*a.height;return a.isSVG?i>1&&(n=Math.ceil(i)/i):r>o&&(r=o),(o*=i*s)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=z.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=ce.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:a}=i,{opacity:n,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===a,y={mode:r},m="center"!==o&&(h||0)%180==90;let v,x;switch(B.set(ue,0,0,m?a:s,m?s:a),r&&"cover"!==r&&"fit"!==r?((d||c)&&(M.getScaleData(d,c,i,he),v=he.scaleX,x=he.scaleY),(o||p||g)&&(v&&B.scale(ue,v,x,!0),o&&W.toPoint(o,ue,e,ue,!0,!0))):w&&!h||(v=x=B.getFitScale(e,ue,"fit"!==r),B.put(e,i,o,v,!1,ue),B.scale(ue,v,x,!0)),l&&k.move(ue,l),r){case"stretch":w?v&&(v=x=void 0):(v=e.width/s,x=e.height/a,z.stretchMode(y,e,v,x));break;case"normal":case"clip":if(ue.x||ue.y||v||f||h||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),z.clipMode(y,e,ue.x,ue.y,v,x,h,u,t,i),t&&(v=v?v*t:t,x=x?x*i:i)}break;case"repeat":(!w||v||h||u)&&z.repeatMode(y,e,s,a,ue.x,ue.y,v,x,h,u,o,t.freeTransform),g||(y.repeat="repeat");const i=L(g);(p||i)&&(y.gap=function(t,e,i,s,a){let n,r;L(t)?(n=t.x,r=t.y):n=r=t;return{x:fe(n,i,a.width,e&&e.x),y:fe(r,s,a.height,e&&e.y)}}(p,i&&g,ue.width,ue.height,e));break;default:v&&z.fillOrFitMode(y,e,ue.x,ue.y,v,x,h)}return y.transform||(e.x||e.y)&&de(y.transform=le(),e.x,e.y),v&&(y.scaleX=v,y.scaleY=x),n&&n<1&&(y.opacity=n),_&&(y.filters=_),g&&(y.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y},stretchMode:function(t,e,i,s){const a=_e(),{x:n,y:r}=e;n||r?me(a,n,r):a.onlyScale=!0,be(a,i,s),t.transform=a},fillOrFitMode:function(t,e,i,s,a,n,r){const o=_e();me(o,e.x+i,e.y+s),be(o,a,n),r&&ye(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,a,n,r,o,l,d){const c=_e();Be(c,e,i,s,a,n,r,o),l&&(r||o?(we(pe),ve(pe,e,l,d),xe(c,pe)):ve(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,s,a,n,r,o,l,d,c,h){const u=_e();if(h)Be(u,e,a,n,r,o,l,d);else{if(l)if("center"===c)ye(u,{x:i/2,y:s/2},l);else switch(Se(u,l),l){case 90:me(u,s,0);break;case 180:me(u,i,s);break;case 270:me(u,0,i)}ge.x=e.x+a,ge.y=e.y+n,me(u,ge.x,ge.y),r&&ve(u,ge,r,o)}t.transform=u}},{toPoint:Ce}=F,{hasTransparent:Oe}=j,Me={},We={};function De(t,e,i,s){if(i){let a,n,r,o;for(let t=0,l=i.length;t<l;t++)a=i[t],A(a)?(r=t/(l-1),n=j.string(a,s)):(r=a.offset,n=j.string(a.color,s)),e.addColorStop(r,n),!o&&Oe(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Fe,getDistance:Ie}=k,{get:Ye,rotateOfOuter:Xe,scaleOfOuter:Ue}=O,{toPoint:Ne}=F,qe={},ze={};function je(t,e,i,s,a){let n;const{width:r,height:o}=t;if(r!==o||s){const t=Fe(e,i);n=Ye(),a?(Ue(n,e,r/o*(s||1),1),Xe(n,e,t+90)):(Ue(n,e,1,r/o*(s||1)),Xe(n,e,t))}return n}const{getDistance:Ge}=k,{toPoint:He}=F,Ve={},Qe={};const Je={linearGradient:function(t,i){let{from:s,to:a,type:n,opacity:r}=t;Ce(s||"top",i,Me),Ce(a||"bottom",i,We);const o=e.canvas.createLinearGradient(Me.x,Me.y,We.x,We.y),l={type:n,style:o};return De(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;Ne(s||"center",i,qe),Ne(a||"bottom",i,ze);const l=e.canvas.createRadialGradient(qe.x,qe.y,0,qe.x,qe.y,Ie(qe,ze)),d={type:n,style:l};De(d,l,t.stops,r);const c=je(i,qe,ze,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;He(s||"center",i,Ve),He(a||"bottom",i,Qe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ve.x,Ve.y):e.canvas.createRadialGradient(Ve.x,Ve.y,0,Ve.x,Ve.y,Ge(Ve,Qe)),d={type:n,style:l};De(d,l,t.stops,r);const c=je(i,Ve,Qe,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:je},{copy:Ze,move:$e,toOffsetOutBounds:Ke}=B,{max:ti,abs:ei}=Math,ii={},si=new T,ai={};function ni(t,e){let i,s,a,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=1.5*(t.blur||0),a=ei(t.spread||0),r=ti(r,a+n-s),o=ti(o,a+n+i),l=ti(l,a+n+s),d=ti(d,a+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function ri(t,i,s){const{shapeBounds:a}=s;let n,r;e.fullImageShadow?(Ze(ii,t.bounds),$e(ii,i.x-a.x,i.y-a.y),n=t.bounds,r=ii):(n=a,r=i),t.copyWorld(s.canvas,n,r)}const{toOffsetOutBounds:oi}=B,li={};const di=ni;const ci={shadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ke(l,ai,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ai.offsetX+(r.x||0)*h*w,ai.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w,j.string(r.color)),a=H.getShadowTransform(t,g,i,r,ai,w),a&&g.setTransform(a),ri(g,ai,i),a&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),s=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;oi(l,li,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(li.offsetX+(r.x||0)*h*w,li.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w),a=H.getShadowTransform(t,g,i,r,li,w,!0),a&&g.setTransform(a),ri(g,li,i),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),s=n):(g.copyWorld(i.canvas,c,l,"source-out"),s=d),g.fillWorld(s,j.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:ni,getShadowTransform:function(t,e,i,s,a,n,r){if(s.spread){const i=2*s.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return si.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/o,1+i/l),si}},isTransformShadow(t){},getInnerShadowSpread:di},{excludeRenderBounds:hi}=p;let ui;function fi(t,e,i,s,a,n,r,o){switch(e){case"grayscale":ui||(ui=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),n&&s.recycle(r);pi(t,e,i,1,a,n)}(t,i,s,a,r,o);break;case"opacity-path":pi(t,i,s,n,r,o);break;case"path":o&&i.restore()}}function gi(t){return t.getSameCanvas(!1,!0)}function pi(t,e,i,s,a,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,a),n?i.recycle(r):i.clearWorld(r)}V.prototype.__renderMask=function(t,e){let i,s,a,n,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&&(fi(this,r,t,a,s,n,void 0,!0),s=a=null),"clipping"!==o&&"clipping-path"!==o||hi(i,e)||i.__render(t,e),n=i.__.opacity,ui=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",a||(a=gi(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=gi(t)),a||(a=gi(t)),i.__render(s,e));continue}const c=1===n&&i.__.__blendMode;c&&fi(this,r,t,a,s,n,void 0,!1),hi(i,e)||i.__render(a||t,e),c&&fi(this,r,t,a,s,n,c,!1)}fi(this,r,t,a,s,n,void 0,!0)};const _i=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",wi=_i+"_#~&*+\\=|≮≯≈≠=…",yi=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function mi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const vi=mi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),xi=mi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),bi=mi(_i),Si=mi(wi),ki=mi("- —/~|┆·");var Bi;!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"}(Bi||(Bi={}));const{Letter:Ri,Single:Li,Before:Ei,After:Ti,Symbol:Pi,Break:Ai}=Bi;function Ci(t){return vi[t]?Ri:ki[t]?Ai:xi[t]?Ei:bi[t]?Ti:Si[t]?Pi:yi.test(t)?Li:Ri}const Oi={trimRight(t){const{words:e}=t;let i,s=0,a=e.length;for(let n=a-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)s++,t.width-=i.width;s&&e.splice(a-s,s)}};function Mi(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:Wi}=Oi,{Letter:Di,Single:Fi,Before:Ii,After:Yi,Symbol:Xi,Break:Ui}=Bi;let Ni,qi,zi,ji,Gi,Hi,Vi,Qi,Ji,Zi,$i,Ki,ts,es,is,ss,as,ns=[];function rs(t,e){Ji&&!Qi&&(Qi=Ji),Ni.data.push({char:t,width:e}),zi+=e}function os(){ji+=zi,Ni.width=zi,qi.words.push(Ni),Ni={data:[]},zi=0}function ls(){es&&(is.paraNumber++,qi.paraStart=!0,es=!1),Ji&&(qi.startCharSize=Qi,qi.endCharSize=Ji,Qi=0),qi.width=ji,ss.width?Wi(qi):as&&ds(),ns.push(qi),qi={words:[]},ji=0}function ds(){ji>(is.maxWidth||0)&&(is.maxWidth=ji)}const{top:cs,right:hs,bottom:us,left:fs}=I;function gs(t,e,i){const{bounds:s,rows:a}=t;s[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const ps={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,a=0,n=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(n?(s=o[fs],n-=o[hs]+o[fs],!n&&(n=.01)):i.autoSizeAlign||(s=o[fs]),r?(a=o[cs],r-=o[cs]+o[us],!r&&(r=.01)):i.autoSizeAlign||(a=o[cs]));const l={bounds:{x:s,y:a,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,s){is=t,ns=t.rows,ss=t.bounds,as=!ss.width&&!s.autoSizeAlign;const{__letterSpacing:a,paraIndent:n,textCase:r}=s,{canvas:o}=e,{width:l}=ss;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap;es=!0,$i=null,Qi=Vi=Ji=zi=ji=0,Ni={data:[]},qi={words:[]},a&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Hi=i[s],"\n"===Hi?(zi&&os(),qi.paraEnd=!0,ls(),es=!0):(Zi=Ci(Hi),Zi===Di&&"none"!==r&&(Hi=Mi(Hi,r,!zi)),Vi=o.measureText(Hi).width,a&&(a<0&&(Ji=Vi),Vi+=a),Ki=Zi===Fi&&($i===Fi||$i===Di)||$i===Fi&&Zi!==Yi,ts=!(Zi!==Ii&&Zi!==Fi||$i!==Xi&&$i!==Yi),Gi=es&&n?l-n:l,t&&l&&ji+zi+Vi>Gi&&(e?(zi&&os(),ji&&ls()):(ts||(ts=Zi===Di&&$i==Yi),Ki||ts||Zi===Ui||Zi===Ii||Zi===Fi||zi+Vi>Gi?(zi&&os(),ji&&ls()):ji&&ls()))," "===Hi&&!0!==es&&ji+zi===0||(Zi===Ui?(" "===Hi&&zi&&os(),rs(Hi,Vi),os()):Ki||ts?(zi&&os(),rs(Hi,Vi)):rs(Hi,Vi)),$i=Zi);zi&&os(),ji&&ls(),ns.length>0&&(ns[ns.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{is.paraNumber++,ji=o.measureText(t).width,ns.push({x:n||0,text:t,width:ji,paraStart:!0}),as&&ds()})}(l,t,i),o&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":gs(e,"x",t[fs]);break;case"right":gs(e,"x",-t[hs])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":gs(e,"y",t[cs]);break;case"bottom":gs(e,"y",-t[us])}}(o,l,i,n,r),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=n*a+(h?h*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,n),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let r=0,c=a;r<c;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&r>0&&(y+=h),m.y=y,y+=n,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),v=m.x,x=m.width,o<0&&(m.width<0?(x=-m.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(l,i),i.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n,letterSpacing:r}=e,o=i&&a.includes("both"),l=o||i&&a.includes("justify"),d=l&&a.includes("letter");let c,h,u,f,g,p,_,w,y,m;s.forEach(t=>{t.words&&(g=n&&t.paraStart?n:0,w=t.words.length,l&&(m=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,s,a){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,c,t.data,t.isOverflow,m&&f),m&&(y=i===w-1,u?y||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(y?1:0))))})),t.words=null)})}(l,i,n),l.overflow&&function(t,i,s,a){if(!a)return;const{rows:n,overflow:r}=t;let{textOverflow:o}=i;if(n.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=s+a-d;("none"===i.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,n),"none"!==i.textDecoration&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,L(n)?(i=n.type,n.color&&(t.decorationColor=j.string(n.color)),n.offset&&(s=Math.min(.3*a,Math.max(n.offset,.15*-a)))):i=n,i){case"under":t.decorationY=[.15*a+s];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a+s,.35*-a]}}(l,i),l}};const _s={string:function(t,e){if(!t)return"#000";const i=Y(e)&&e<1;if(A(t)){if(!i||!j.object)return t;t=j.object(t)}let s=P(t.a)?1:t.a;i&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}};Object.assign(Q,ps),Object.assign(j,_s),Object.assign(q,$t),Object.assign(z,Ae),Object.assign(G,Je),Object.assign(H,ci);const{setPoint:ws,addPoint:ys,toBounds:ms}=J;const vs={syncExport(t,e,i){let s;$.running=!0;try{const a=K.fileType(e),n=e.includes(".");i=K.getExportOptions(i);const{toURL:r}=tt,{download:o}=tt.origin;if("json"===a)n&&o(r(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!n||t.toJSON(i.json)};else if("svg"===a)n&&o(r(t.toSVG(),"svg"),e),s={data:!!n||t.toSVG()};else{let a,n,r=1,o=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:g,screenshot:p,padding:_,onCanvas:w}=i,y=et(i.smooth)?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),v=d&&p&&et(i.fill)?t.fill:i.fill,x=K.isOpaqueImage(e)||v,b=new it;if(p)a=!0===p?d?c.canvas.bounds:t.worldRenderBounds:p;else{let e=i.relative||(d?"inner":"local");switch(r=l.scaleX,o=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),r/=t.scaleX,o/=t.scaleY;break;case"world":r=1,o=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;r/=r/i.scaleX,o/=o/i.scaleY}a=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};st.getScaleData(i.scale,i.size,a,S);let k=i.pixelRatio||1,{x:B,y:R,width:L,height:E}=new Z(a).scale(S.scaleX,S.scaleY);f&&(B+=f.x,R+=f.y,L=f.width,E=f.height);const T={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-B,-R).withScale(1/r*S.scaleX,1/o*S.scaleY)};let P,A=at.canvas({width:Math.floor(L),height:Math.floor(E),pixelRatio:k,smooth:y,contextSettings:m});u&&(P=t,P.__worldOpacity=0,t=c||t,T.bounds=A.bounds),A.save();const C=h&&!et(v),O=t.get("fill");if(C&&(t.fill=""),tt.render(t,A,T),C&&(t.fill=O),A.restore(),P&&P.__updateWorldOpacity(),g){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let a,n,r,o=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=o%e,n=(o-a)/e,r?ys(r,a,n):ws(r={},a,n)),o++;const l=new Z;return r&&(ms(r,l),l.scale(1/t.pixelRatio).ceil()),l}(A);const t=A,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:k};A=at.canvas(s),A.copyWorld(t,n,s),t.destroy()}if(_){const[t,e,i,s]=st.fourNumber(_),a=A,{width:n,height:r}=a;A=at.canvas({width:n+s+e,height:r+t+i,pixelRatio:k}),A.copyWorld(a,a.bounds,{x:s,y:t,width:n,height:r}),a.destroy()}x&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),w&&w(A);s={data:"canvas"===e?A:A.export(e,i),width:A.pixelWidth,height:A.pixelHeight,renderBounds:a,trimBounds:n};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return $.running=!1,s},export(t,e,i){return $.running=!0,function(t){xs||(xs=new nt);return new Promise(e=>{xs.add(()=>ut(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(a=>{const n=()=>ut(this,void 0,void 0,function*(){if(!rt.isComplete)return tt.requestRender(n);const r=$.syncExport(t,e,i);r.data instanceof Promise&&(r.data=yield r.data),s(r),a()});t.updateLayout(),bs(t);const{leafer:r}=t;r?r.waitViewCompleted(n):n()}))}};let xs;function bs(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>bs(t))}const Ss=ot.prototype,ks=lt.get("@leafer-in/export");Ss.export=function(t,e){const{quality:i,blob:s}=K.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Ss.toBlob=function(t,e){return new Promise(i=>{tt.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{ks.error(t),i(null)})})},Ss.toDataURL=function(t,e){return tt.origin.canvasToDataURL(this.view,t,e)},Ss.saveAs=function(t,e){return new Promise(i=>{tt.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{ks.error(t),i(!1)})})},dt.add("export"),Object.assign($,vs),ct.prototype.export=function(t,e){return $.export(this,t,e)},ct.prototype.syncExport=function(t,e){return $.syncExport(this,t,e)},Object.assign(a,{interaction:(t,e,i,s)=>new N(t,e,i,s),hitCanvas:(t,e)=>new ft(t,e),hitCanvasManager:()=>new U});export{Et as Layouter,ft as LeaferCanvas,ht as PathNodeHandleType,Mt as Picker,Pt as Renderer,Wt as Selector,wt as Watcher,_t as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as a,LeaferImage as n,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,PointHelper as k,BoundsHelper as B,Plugin as R,isObject as L,FourNumberHelper as E,Matrix as T,isUndefined as P,isString as A,ImageEvent as C,MatrixHelper as O,MathHelper as M,AlignHelper as W,isNumber as D,getMatrixData as I,AroundHelper as F,Direction4 as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as X}from"fs";import{HitCanvasManager as U,InteractionBase as N}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as q,PaintImage as z,ColorConvert as j,PaintGradient as G,Effect as H,Group as V,TextConvert as Q,TwoPointBoundsHelper as J,Bounds as Z,Export as $,FileHelper as K,Platform as tt,isUndefined as et,Matrix as it,MathHelper as st,Creator as at,TaskProcessor as nt,Resource as rt,LeaferCanvasBase as ot,Debug as lt,Plugin as dt,UI as ct}from"@leafer-ui/draw";var ht;function ut(t,e,i,s){return new(i||(i=Promise))(function(a,n){function r(t){try{l(s.next(t))}catch(t){n(t)}}function o(t){try{l(s.throw(t))}catch(t){n(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((s=s.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(ht||(ht={})),"function"==typeof SuppressedError&&SuppressedError;class ft extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:gt,fileType:pt}=s;function _t(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURL(gt(e),i),canvasToBolb:(t,e,i)=>ut(this,void 0,void 0,function*(){return t.toBuffer(gt(e),i)}),canvasSaveAs:(t,e,i)=>ut(this,void 0,void 0,function*(){return X(e,t.toBuffer(gt(pt(e)),i))}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas()}}Object.assign(a,{canvas:(t,e)=>new ft(t,e),image:t=>new n(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},r(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class wt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:yt,updateBounds:mt,updateChange:xt}=f,{pushAllChildBranch:vt,pushAllParent:bt}=g;const{worldBounds:St}=p;class kt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,St)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,St),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:Bt,updateAllChange:Rt}=f,Lt=y.get("Layouter");class Et{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){Lt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Lt.warn("layouting"):this.times>3?Lt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(a,o,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?(yt(t,!0),e.add(t),t.isBranch&&vt(t,e),bt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),bt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;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){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||mt(s[t])}mt(i)}})}(this.__levelList),function(t){t.list.forEach(xt)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(n,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=x,n=this.getBlocks(new o(e));e.emitEvent(new x(i,n,this.times)),Et.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,n,this.times)),e.emitEvent(new x(a,n,this.times)),this.addBlocks(n),v.end(t)}static fullLayout(t){Bt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),Rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new kt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new kt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Tt=y.get("Renderer");class Pt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Tt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,Tt.error(t)}Tt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Tt.warn("rendering");if(this.times>3)return Tt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),a=new _(s);i.save(),s.spread(Pt.clipSpread).ceil();const{ceilPartPixel:n}=this.config;i.clipWorld(s,n),i.clearWorld(s,n),this.__render(s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:s,target:a}=this,n=t.includes(a.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(a,s,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}getCellList(){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);const{frames:a}=this;a.length>30&&a.shift(),a.push(t),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(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||Tt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Pt.clipSpread=10;const At={},{copyRadiusPoint:Ct}=k,{hitRadiusPoint:Ot}=B;class Mt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,n=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(n.isBranchLeaf?{children:[n]}:n);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,a,!!i.findList),d=a?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const a=this.findList=new o;if(t.length){let e;const{x:s,y:n}=this.point,r={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,r),a.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){a.reset();break}return a.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),a.length)return a.list[0];return s?null:i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,a,n;for(let t=0,r=i.length;t<r;t++){s=i[t],a=i[t+1];for(let t=0,i=s.length;t<i&&(n=s.list[t],!a||!a.has(n));t++)e.add(n)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s,a;const{point:n}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],a=i.__,a.visible&&(!e||a.mask))if(s=Ot(i.__world,a.hitRadius?Ct(At,n,a.hitRadius):n),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&a.__clipAfterFill&&!i.__hitWorld(n,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)}}else s&&this.hitChild(i,n)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,a=[];const{children:n}=s;for(let s=0,r=n.length;s<r;s++)if(i=n[s],i.__.mask&&a.push(i),i===t){if(a&&!a.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Wt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Mt(this.target=t,this),this.finder=a.finder&&a.finder()}getByPoint(t,i,s){const{target:a,picker:n}=this;return e.backgrounder&&a&&a.updateLayout(),n.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Dt(t,e,i){t.__.__font?q.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function It(t,e,i,s,a){const n=i.__;L(t)?q.drawStrokesStyle(t,e,!1,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&q.strokeArrow(t,i,s,a)}function Ft(t,e,i,s,a){const n=i.__;L(t)?q.drawStrokesStyle(t,e,!0,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),q.drawTextStroke(i,s,a))}function Yt(t,e,i,s,a){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Ft(t,2,i,n,a),n.blendMode="outside"===e?"destination-out":"destination-in",q.fillText(i,n,a),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}Object.assign(a,{watcher:(t,e)=>new wt(t,e),layouter:(t,e)=>new Et(t,e),renderer:(t,e,i)=>new Pt(t,e,i),selector:(t,e)=>new Wt(t,e)}),e.layout=Et.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:Xt,copyAndSpread:Ut,toOuterOf:Nt,getOuterOf:qt,getByMove:zt,move:jt,getIntersectData:Gt}=B,Ht={};let Vt;const{stintSet:Qt}=l,{hasTransparent:Jt}=j;function Zt(t,e,i){if(!L(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:a}=i.__layout;switch(e.type){case"image":if(!e.url)return;s=z.image(i,t,e,a,!Vt||!Vt[e.url]);break;case"linear":s=G.linearGradient(e,a);break;case"radial":s=G.radialGradient(e,a);break;case"angular":s=G.conicGradient(e,a);break;case"solid":const{type:n,color:r,opacity:o}=e;s={type:n,style:j.string(r,o)};break;default:P(e.r)||(s={type:"solid",style:j.string(e)})}if(s&&(s.originPaint=e,A(s.style)&&Jt(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const $t={compute:function(t,e){const i=e.__,s=[];let a,n,r,o=i.__input[t];w(o)||(o=[o]),Vt=z.recycleImage(t,i);for(let i,a=0,n=o.length;a<n;a++)(i=Zt(t,o[a],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(a=!0),n=!0),"fill"===t?(Qt(i,"__isAlphaPixelFill",a),Qt(i,"__isTransparentFill",n)):(Qt(i,"__isAlphaPixelStroke",a),Qt(i,"__isTransparentStroke",n),Qt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Dt(e,i,s)},fills:function(t,e,i,s){let a,n,r;for(let o=0,l=t.length;o<l;o++){if(a=t[o],n=a.originPaint,a.image){if(r?r++:r=1,z.checkImage(a,!e.__.__font,e,i,s))continue;if(!a.style){1===r&&a.image.isPlacehold&&e.drawImagePlaceholder(a,i,s);continue}}if(i.fillStyle=a.style,a.transform||n.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===n.scaleFixed||"zoom-in"===n.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}n.blendMode&&(i.blendMode=n.blendMode),Dt(e,i,s),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),Dt(e,i,s),i.restoreBlendMode()):Dt(e,i,s)}},fillPathOrText:Dt,fillText:function(t,e,i){const s=t.__,{rows:a,decorationY:n}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.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(n){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const a=e.__;if(a.__strokeWidth)if(a.__font)q.strokeText(t,e,i,s);else switch(a.strokeAlign){case"center":It(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),It(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const a=e.__;if(a.__fillAfterStroke)It(t,2,e,i,s);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),It(t,2,e,r,s),r.clipUI(a),r.clearWorld(n),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){q.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Ft(t,1,e,i,s);break;case"inside":Yt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Ft(t,2,e,i,s):Yt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,a=t.__.__textDrawData;const{rows:n,decorationY:r}=a;for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=a;n.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,a,n){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!z.checkImage(r,!1,s,a,n))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.originPaint.blendMode?(a.saveBlendMode(r.originPaint.blendMode),i?q.drawTextStroke(s,a,n):a.stroke(),a.restoreBlendMode()):i?q.drawTextStroke(s,a,n):a.stroke()}},shape:function(t,i,s){const a=i.getSameCanvas(),n=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;Nt(o.strokeSpread?(Ut(Ht,o.boxBounds,o.strokeSpread),Ht):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=a,d=f=l,c=r;else{let a;if(e.fullImageShadow)a=l;else{const t=o.renderShapeSpread?Xt(n,E.swapAndScale(o.renderShapeSpread,p,_)):n;a=Gt(t,l)}u=n.getFitMatrix(a);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=qt(l,u),d=zt(f,-u.e,-u.f),c=qt(r,u),jt(c,-u.e,-u.f);const m=s.matrix;m?(h=new T(u),h.multiply(m),w*=m.scaleX,y*=m.scaleY):h=u,h.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(a,s),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Kt,te=new _;const{isSame:ee}=B;function ie(t,e,i,s,a,n){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||z.createData(a,s,i,n),!0}function se(t,e){re(t,C.LOAD,e)}function ae(t,e){re(t,C.LOADED,e)}function ne(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,C.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function oe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,translate:de}=O,ce=new _,he={},ue={};function fe(t,e,i,s){const a=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let ge={},pe=I();const{get:_e,set:we,rotateOfOuter:ye,translate:me,scaleOfOuter:xe,multiplyParent:ve,scale:be,rotate:Se,skew:ke}=O;function Be(t,e,i,s,a,n,r,o){r&&Se(t,r),o&&ke(t,o.x,o.y),a&&be(t,a,n),me(t,e.x+i,e.y+s)}const{get:Re,scale:Le,copy:Ee}=O,{getFloorScale:Te}=M,{abs:Pe}=Math;const Ae={image:function(t,e,i,s,a){let n,r;const o=b.get(i);return Kt&&i===Kt.paint&&ee(s,Kt.boxBounds)?n=Kt.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Kt=o.use>1?{leafPaint:n,paint:i,boxBounds:te.set(s)}:null),(a||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(ie(t,e,i,o,n,s),a&&(se(t,r),ae(t,r))):o.error?a&&ne(t,r,o.error):(a&&(oe(t,!0),se(t,r)),n.loadId=o.load(()=>{oe(t,!1),t.destroyed||(ie(t,e,i,o,n,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,r)),n.loadId=void 0},e=>{oe(t,!1),ne(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,i,s,a,n){const{scaleX:r,scaleY:o}=z.getImageRenderScaleData(t,s,a,n),{image:l,data:d,originPaint:c}=t,{exporting:h,snapshot:u}=n;return!(!d||t.patternId===r+"-"+o&&!h||u)&&(i&&(d.repeat?i=!1:c.changeful||"miniapp"===e.name&&S.isResizing(s)||h||(i=e.image.isLarge(l,r,o)||l.width*r>8096||l.height*o>8096)),i?(s.__.__isFastShadow&&(a.fillStyle=t.style||"#000",a.fill()),z.drawImage(t,r,o,s,a,n),!0):(!t.style||c.sync||h?z.createPattern(t,s,a,n):z.createPatternTask(t,s,a,n),!1))},drawImage:function(t,e,i,s,a,n){const{data:r,image:o}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=r,h=o.getFull(r.filters),u=s.__;let f,{width:g,height:p}=o;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(a.save(),f&&a.clipUI(s),l&&(a.blendMode=l),d&&(a.opacity*=d),c&&a.transform(c),a.drawImage(h,0,0,g,p),a.restore()):(r.scaleX&&(g*=r.scaleX,p*=r.scaleY),a.drawImage(h,0,0,g,p))},getImageRenderScaleData:function(t,e,i,s){const a=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return n&&n.scaleX&&(a.scaleX*=Math.abs(n.scaleX),a.scaleY*=Math.abs(n.scaleY)),a},recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,a,n,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],a=s.image,o=a&&a.url,o&&(n||(n={}),n[o]=!0,b.recyclePaint(s),a.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),a.unload(i[l].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=b.patternTasker.add(()=>ut(this,void 0,void 0,function*(){z.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,s,a){let{scaleX:n,scaleY:r}=z.getImageRenderScaleData(t,i,s,a),o=n+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:s,data:a}=t,{transform:l,gap:d}=a,c=z.getPatternFixScale(t,n,r);let h,u,f,{width:g,height:p}=s;c&&(n*=c,r*=c),g*=n,p*=r,d&&(u=d.x*n/Pe(a.scaleX||1),f=d.y*r/Pe(a.scaleY||1)),(l||1!==n||1!==r)&&(n*=Te(g+(u||0)),r*=Te(p+(f||0)),h=Re(),l&&Ee(h,l),Le(h,1/n,1/r));const _=s.getCanvas(g,p,a.opacity,a.filters,u,f,i.leafer&&i.leafer.config.smooth,a.interlace),w=s.getPattern(_,a.repeat||e.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,s){const{image:a}=t;let n,r=e.image.maxPatternSize,o=a.width*a.height;return a.isSVG?i>1&&(n=Math.ceil(i)/i):r>o&&(r=o),(o*=i*s)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=z.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=ce.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:a}=i,{opacity:n,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:g,gap:p,filters:_,interlace:w}=t,y=e.width===s&&e.height===a,m={mode:r},x="center"!==o&&(h||0)%180==90;let v,b;switch(B.set(ue,0,0,x?a:s,x?s:a),r&&"cover"!==r&&"fit"!==r?((d||c)&&(M.getScaleData(d,c,i,he),v=he.scaleX,b=he.scaleY),(o||p||g)&&(v&&B.scale(ue,v,b,!0),o&&W.toPoint(o,ue,e,ue,!0,!0))):y&&!h||(v=b=B.getFitScale(e,ue,"fit"!==r),B.put(e,i,o,v,!1,ue),B.scale(ue,v,b,!0)),l&&k.move(ue,l),r){case"stretch":y?v&&(v=b=void 0):(v=e.width/s,b=e.height/a,z.stretchMode(m,e,v,b));break;case"normal":case"clip":if(ue.x||ue.y||v||f||h||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),z.clipMode(m,e,ue.x,ue.y,v,b,h,u,t,i),t&&(v=v?v*t:t,b=b?b*i:i)}break;case"repeat":(!y||v||h||u)&&z.repeatMode(m,e,s,a,ue.x,ue.y,v,b,h,u,o,t.freeTransform),g||(m.repeat="repeat");const i=L(g);(p||i)&&(m.gap=function(t,e,i,s,a){let n,r;L(t)?(n=t.x,r=t.y):n=r=t;return{x:fe(n,i,a.width,e&&e.x),y:fe(r,s,a.height,e&&e.y)}}(p,i&&g,ue.width,ue.height,e));break;default:v&&z.fillOrFitMode(m,e,ue.x,ue.y,v,b,h)}return m.transform||(e.x||e.y)&&de(m.transform=le(),e.x,e.y),v&&(m.scaleX=v,m.scaleY=b),n&&n<1&&(m.opacity=n),_&&(m.filters=_),g&&(m.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w&&(m.interlace=D(w)||"percent"===w.type?{type:"x",offset:w}:w),m},stretchMode:function(t,e,i,s){const a=_e(),{x:n,y:r}=e;n||r?me(a,n,r):a.onlyScale=!0,be(a,i,s),t.transform=a},fillOrFitMode:function(t,e,i,s,a,n,r){const o=_e();me(o,e.x+i,e.y+s),be(o,a,n),r&&ye(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,a,n,r,o,l,d){const c=_e();Be(c,e,i,s,a,n,r,o),l&&(r||o?(we(pe),xe(pe,e,l,d),ve(c,pe)):xe(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,s,a,n,r,o,l,d,c,h){const u=_e();if(h)Be(u,e,a,n,r,o,l,d);else{if(l)if("center"===c)ye(u,{x:i/2,y:s/2},l);else switch(Se(u,l),l){case 90:me(u,s,0);break;case 180:me(u,i,s);break;case 270:me(u,0,i)}ge.x=e.x+a,ge.y=e.y+n,me(u,ge.x,ge.y),r&&xe(u,ge,r,o)}t.transform=u}},{toPoint:Ce}=F,{hasTransparent:Oe}=j,Me={},We={};function De(t,e,i,s){if(i){let a,n,r,o;for(let t=0,l=i.length;t<l;t++)a=i[t],A(a)?(r=t/(l-1),n=j.string(a,s)):(r=a.offset,n=j.string(a.color,s)),e.addColorStop(r,n),!o&&Oe(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Ie,getDistance:Fe}=k,{get:Ye,rotateOfOuter:Xe,scaleOfOuter:Ue}=O,{toPoint:Ne}=F,qe={},ze={};function je(t,e,i,s,a){let n;const{width:r,height:o}=t;if(r!==o||s){const t=Ie(e,i);n=Ye(),a?(Ue(n,e,r/o*(s||1),1),Xe(n,e,t+90)):(Ue(n,e,1,r/o*(s||1)),Xe(n,e,t))}return n}const{getDistance:Ge}=k,{toPoint:He}=F,Ve={},Qe={};const Je={linearGradient:function(t,i){let{from:s,to:a,type:n,opacity:r}=t;Ce(s||"top",i,Me),Ce(a||"bottom",i,We);const o=e.canvas.createLinearGradient(Me.x,Me.y,We.x,We.y),l={type:n,style:o};return De(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;Ne(s||"center",i,qe),Ne(a||"bottom",i,ze);const l=e.canvas.createRadialGradient(qe.x,qe.y,0,qe.x,qe.y,Fe(qe,ze)),d={type:n,style:l};De(d,l,t.stops,r);const c=je(i,qe,ze,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;He(s||"center",i,Ve),He(a||"bottom",i,Qe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ve.x,Ve.y):e.canvas.createRadialGradient(Ve.x,Ve.y,0,Ve.x,Ve.y,Ge(Ve,Qe)),d={type:n,style:l};De(d,l,t.stops,r);const c=je(i,Ve,Qe,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:je},{copy:Ze,move:$e,toOffsetOutBounds:Ke}=B,{max:ti,abs:ei}=Math,ii={},si=new T,ai={};function ni(t,e){let i,s,a,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=1.5*(t.blur||0),a=ei(t.spread||0),r=ti(r,a+n-s),o=ti(o,a+n+i),l=ti(l,a+n+s),d=ti(d,a+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function ri(t,i,s){const{shapeBounds:a}=s;let n,r;e.fullImageShadow?(Ze(ii,t.bounds),$e(ii,i.x-a.x,i.y-a.y),n=t.bounds,r=ii):(n=a,r=i),t.copyWorld(s.canvas,n,r)}const{toOffsetOutBounds:oi}=B,li={};const di=ni;const ci={shadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ke(l,ai,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ai.offsetX+(r.x||0)*h*w,ai.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w,j.string(r.color)),a=H.getShadowTransform(t,g,i,r,ai,w),a&&g.setTransform(a),ri(g,ai,i),a&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),s=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;oi(l,li,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(li.offsetX+(r.x||0)*h*w,li.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w),a=H.getShadowTransform(t,g,i,r,li,w,!0),a&&g.setTransform(a),ri(g,li,i),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),s=n):(g.copyWorld(i.canvas,c,l,"source-out"),s=d),g.fillWorld(s,j.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:ni,getShadowTransform:function(t,e,i,s,a,n,r){if(s.spread){const i=2*s.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return si.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/o,1+i/l),si}},isTransformShadow(t){},getInnerShadowSpread:di},{excludeRenderBounds:hi}=p;let ui;function fi(t,e,i,s,a,n,r,o){switch(e){case"grayscale":ui||(ui=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),n&&s.recycle(r);pi(t,e,i,1,a,n)}(t,i,s,a,r,o);break;case"opacity-path":pi(t,i,s,n,r,o);break;case"path":o&&i.restore()}}function gi(t){return t.getSameCanvas(!1,!0)}function pi(t,e,i,s,a,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,a),n?i.recycle(r):i.clearWorld(r)}V.prototype.__renderMask=function(t,e){let i,s,a,n,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&&(fi(this,r,t,a,s,n,void 0,!0),s=a=null),"clipping"!==o&&"clipping-path"!==o||hi(i,e)||i.__render(t,e),n=i.__.opacity,ui=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",a||(a=gi(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=gi(t)),a||(a=gi(t)),i.__render(s,e));continue}const c=1===n&&i.__.__blendMode;c&&fi(this,r,t,a,s,n,void 0,!1),hi(i,e)||i.__render(a||t,e),c&&fi(this,r,t,a,s,n,c,!1)}fi(this,r,t,a,s,n,void 0,!0)};const _i=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",wi=_i+"_#~&*+\\=|≮≯≈≠=…",yi=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function mi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const xi=mi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),vi=mi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),bi=mi(_i),Si=mi(wi),ki=mi("- —/~|┆·");var Bi;!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"}(Bi||(Bi={}));const{Letter:Ri,Single:Li,Before:Ei,After:Ti,Symbol:Pi,Break:Ai}=Bi;function Ci(t){return xi[t]?Ri:ki[t]?Ai:vi[t]?Ei:bi[t]?Ti:Si[t]?Pi:yi.test(t)?Li:Ri}const Oi={trimRight(t){const{words:e}=t;let i,s=0,a=e.length;for(let n=a-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)s++,t.width-=i.width;s&&e.splice(a-s,s)}};function Mi(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:Wi}=Oi,{Letter:Di,Single:Ii,Before:Fi,After:Yi,Symbol:Xi,Break:Ui}=Bi;let Ni,qi,zi,ji,Gi,Hi,Vi,Qi,Ji,Zi,$i,Ki,ts,es,is,ss,as,ns=[];function rs(t,e){Ji&&!Qi&&(Qi=Ji),Ni.data.push({char:t,width:e}),zi+=e}function os(){ji+=zi,Ni.width=zi,qi.words.push(Ni),Ni={data:[]},zi=0}function ls(){es&&(is.paraNumber++,qi.paraStart=!0,es=!1),Ji&&(qi.startCharSize=Qi,qi.endCharSize=Ji,Qi=0),qi.width=ji,ss.width?Wi(qi):as&&ds(),ns.push(qi),qi={words:[]},ji=0}function ds(){ji>(is.maxWidth||0)&&(is.maxWidth=ji)}const{top:cs,right:hs,bottom:us,left:fs}=Y;function gs(t,e,i){const{bounds:s,rows:a}=t;s[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const ps={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,a=0,n=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(n?(s=o[fs],n-=o[hs]+o[fs],!n&&(n=.01)):i.autoSizeAlign||(s=o[fs]),r?(a=o[cs],r-=o[cs]+o[us],!r&&(r=.01)):i.autoSizeAlign||(a=o[cs]));const l={bounds:{x:s,y:a,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,s){is=t,ns=t.rows,ss=t.bounds,as=!ss.width&&!s.autoSizeAlign;const{__letterSpacing:a,paraIndent:n,textCase:r}=s,{canvas:o}=e,{width:l}=ss;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap;es=!0,$i=null,Qi=Vi=Ji=zi=ji=0,Ni={data:[]},qi={words:[]},a&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Hi=i[s],"\n"===Hi?(zi&&os(),qi.paraEnd=!0,ls(),es=!0):(Zi=Ci(Hi),Zi===Di&&"none"!==r&&(Hi=Mi(Hi,r,!zi)),Vi=o.measureText(Hi).width,a&&(a<0&&(Ji=Vi),Vi+=a),Ki=Zi===Ii&&($i===Ii||$i===Di)||$i===Ii&&Zi!==Yi,ts=!(Zi!==Fi&&Zi!==Ii||$i!==Xi&&$i!==Yi),Gi=es&&n?l-n:l,t&&l&&ji+zi+Vi>Gi&&(e?(zi&&os(),ji&&ls()):(ts||(ts=Zi===Di&&$i==Yi),Ki||ts||Zi===Ui||Zi===Fi||Zi===Ii||zi+Vi>Gi?(zi&&os(),ji&&ls()):ji&&ls()))," "===Hi&&!0!==es&&ji+zi===0||(Zi===Ui?(" "===Hi&&zi&&os(),rs(Hi,Vi),os()):Ki||ts?(zi&&os(),rs(Hi,Vi)):rs(Hi,Vi)),$i=Zi);zi&&os(),ji&&ls(),ns.length>0&&(ns[ns.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{is.paraNumber++,ji=o.measureText(t).width,ns.push({x:n||0,text:t,width:ji,paraStart:!0}),as&&ds()})}(l,t,i),o&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":gs(e,"x",t[fs]);break;case"right":gs(e,"x",-t[hs])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":gs(e,"y",t[cs]);break;case"bottom":gs(e,"y",-t[us])}}(o,l,i,n,r),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=n*a+(h?h*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(e.__autoHeight?w:_,n),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,c=a;r<c;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&r>0&&(y+=h),m.y=y,y+=n,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(l,i),i.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n,__letterSpacing:r}=e,o=i&&a.includes("both"),l=o||i&&a.includes("justify"),d=l&&a.includes("letter");let c,h,u,f,g,p,_,w,y,m;s.forEach(t=>{t.words&&(g=n&&t.paraStart?n:0,w=t.words.length,l&&(m=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,s,a){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,c,t.data,t.isOverflow,m&&f),m&&(y=i===w-1,u?y||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(y?1:0))))})),t.words=null)})}(l,i,n),l.overflow&&function(t,i,s,a){const{rows:n,overflow:r}=t;let{textOverflow:o}=i;if(r&&n.splice(r),a&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=s+a-d;("none"===i.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,n),"none"!==i.textDecoration&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,L(n)?(i=n.type,n.color&&(t.decorationColor=j.string(n.color)),n.offset&&(s=Math.min(.3*a,Math.max(n.offset,.15*-a)))):i=n,i){case"under":t.decorationY=[.15*a+s];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a+s,.35*-a]}}(l,i),l}};const _s={string:function(t,e){if(!t)return"#000";const i=D(e)&&e<1;if(A(t)){if(!i||!j.object)return t;t=j.object(t)}let s=P(t.a)?1:t.a;i&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}};Object.assign(Q,ps),Object.assign(j,_s),Object.assign(q,$t),Object.assign(z,Ae),Object.assign(G,Je),Object.assign(H,ci);const{setPoint:ws,addPoint:ys,toBounds:ms}=J;const xs={syncExport(t,e,i){let s;$.running=!0;try{const a=K.fileType(e),n=e.includes(".");i=K.getExportOptions(i);const{toURL:r}=tt,{download:o}=tt.origin;if("json"===a)n&&o(r(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!n||t.toJSON(i.json)};else if("svg"===a)n&&o(r(t.toSVG(),"svg"),e),s={data:!!n||t.toSVG()};else{let a,n,r=1,o=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:g,screenshot:p,padding:_,onCanvas:w}=i,y=et(i.smooth)?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),x=d&&p&&et(i.fill)?t.fill:i.fill,v=K.isOpaqueImage(e)||x,b=new it;if(p)a=!0===p?d?c.canvas.bounds:t.worldRenderBounds:p;else{let e=i.relative||(d?"inner":"local");switch(r=l.scaleX,o=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),r/=t.scaleX,o/=t.scaleY;break;case"world":r=1,o=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;r/=r/i.scaleX,o/=o/i.scaleY}a=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};st.getScaleData(i.scale,i.size,a,S);let k=i.pixelRatio||1,{x:B,y:R,width:L,height:E}=new Z(a).scale(S.scaleX,S.scaleY);f&&(B+=f.x,R+=f.y,L=f.width,E=f.height,f.rotation&&b.rotateOfInner({x:B,y:R},-f.rotation));const T={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-B,-R).withScale(1/r*S.scaleX,1/o*S.scaleY)};let P,A=at.canvas({width:Math.floor(L),height:Math.floor(E),pixelRatio:k,smooth:y,contextSettings:m});u&&(P=t,P.__worldOpacity=0,t=c||t,T.bounds=A.bounds),A.save();const C=h&&!et(x),O=t.get("fill");if(C&&(t.fill=""),tt.render(t,A,T),C&&(t.fill=O),A.restore(),P&&P.__updateWorldOpacity(),g){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let a,n,r,o=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=o%e,n=(o-a)/e,r?ys(r,a,n):ws(r={},a,n)),o++;const l=new Z;return r&&(ms(r,l),l.scale(1/t.pixelRatio).ceil()),l}(A);const t=A,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:k};A=at.canvas(s),A.copyWorld(t,n,s),t.destroy()}if(_){const[t,e,i,s]=st.fourNumber(_),a=A,{width:n,height:r}=a;A=at.canvas({width:n+s+e,height:r+t+i,pixelRatio:k}),A.copyWorld(a,a.bounds,{x:s,y:t,width:n,height:r}),a.destroy()}v&&A.fillWorld(A.bounds,x||"#FFFFFF","destination-over"),w&&w(A);s={data:"canvas"===e?A:A.export(e,i),width:A.pixelWidth,height:A.pixelHeight,renderBounds:a,trimBounds:n};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return $.running=!1,s},export(t,e,i){return $.running=!0,function(t){vs||(vs=new nt);return new Promise(e=>{vs.add(()=>ut(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(a=>{const n=()=>ut(this,void 0,void 0,function*(){if(!rt.isComplete)return tt.requestRender(n);const r=$.syncExport(t,e,i);r.data instanceof Promise&&(r.data=yield r.data),s(r),a()});t.updateLayout(),bs(t);const{leafer:r}=t;r?r.waitViewCompleted(n):n()}))}};let vs;function bs(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>bs(t))}const Ss=ot.prototype,ks=lt.get("@leafer-in/export");Ss.export=function(t,e){const{quality:i,blob:s}=K.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Ss.toBlob=function(t,e){return new Promise(i=>{tt.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{ks.error(t),i(null)})})},Ss.toDataURL=function(t,e){return tt.origin.canvasToDataURL(this.view,t,e)},Ss.saveAs=function(t,e){return new Promise(i=>{tt.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{ks.error(t),i(!1)})})},dt.add("export"),Object.assign($,xs),ct.prototype.export=function(t,e){return $.export(this,t,e)},ct.prototype.syncExport=function(t,e){return $.syncExport(this,t,e)},Object.assign(a,{interaction:(t,e,i,s)=>new N(t,e,i,s),hitCanvas:(t,e)=>new ft(t,e),hitCanvasManager:()=>new U});export{Et as Layouter,ft as LeaferCanvas,ht as PathNodeHandleType,Mt as Picker,Pt as Renderer,Wt as Selector,wt as Watcher,_t as useCanvas};
2
2
  //# sourceMappingURL=node.esm.min.js.map