@leafer-draw/node 1.9.4 → 1.9.6

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
@@ -450,7 +450,7 @@ class Renderer {
450
450
  this.times = 0;
451
451
  this.config = {
452
452
  usePartRender: true,
453
- maxFPS: 60
453
+ maxFPS: 120
454
454
  };
455
455
  this.target = target;
456
456
  this.canvas = canvas;
@@ -605,11 +605,15 @@ class Renderer {
605
605
  if (this.requestTime || !target) return;
606
606
  if (target.parentApp) return target.parentApp.requestRender(false);
607
607
  const requestTime = this.requestTime = Date.now();
608
- core.Platform.requestRender(() => {
609
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
608
+ const render = () => {
609
+ const nowFPS = 1e3 / (Date.now() - requestTime);
610
+ const {maxFPS: maxFPS} = this.config;
611
+ if (maxFPS && nowFPS > maxFPS - .5) return core.Platform.requestRender(render);
612
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
610
613
  this.requestTime = 0;
611
614
  this.checkRender();
612
- });
615
+ };
616
+ core.Platform.requestRender(render);
613
617
  }
614
618
  __onResize(e) {
615
619
  if (this.canvas.unreal) return;
@@ -652,7 +656,8 @@ class Renderer {
652
656
  if (this.target) {
653
657
  this.stop();
654
658
  this.__removeListenEvents();
655
- this.target = this.canvas = this.config = null;
659
+ this.config = {};
660
+ this.target = this.canvas = null;
656
661
  }
657
662
  }
658
663
  }
@@ -1291,7 +1296,7 @@ function ignoreRender(ui, value) {
1291
1296
 
1292
1297
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1293
1298
 
1294
- const {floor: floor, max: max, abs: abs} = Math;
1299
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1295
1300
 
1296
1301
  function createPattern(ui, paint, pixelRatio) {
1297
1302
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1301,8 +1306,6 @@ function createPattern(ui, paint, pixelRatio) {
1301
1306
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1302
1307
  scaleX *= pixelRatio;
1303
1308
  scaleY *= pixelRatio;
1304
- const xGap = gap && gap.x * scaleX;
1305
- const yGap = gap && gap.y * scaleY;
1306
1309
  if (sx) {
1307
1310
  sx = abs(sx);
1308
1311
  sy = abs(sy);
@@ -1319,7 +1322,10 @@ function createPattern(ui, paint, pixelRatio) {
1319
1322
  if (size > core.Platform.image.maxCacheSize) return false;
1320
1323
  }
1321
1324
  let maxSize = core.Platform.image.maxPatternSize;
1322
- if (!image.isSVG) {
1325
+ if (image.isSVG) {
1326
+ const ws = width / image.width;
1327
+ if (ws > 1) imageScale = ws / ceil(ws);
1328
+ } else {
1323
1329
  const imageSize = image.width * image.height;
1324
1330
  if (maxSize > imageSize) maxSize = imageSize;
1325
1331
  }
@@ -1334,18 +1340,20 @@ function createPattern(ui, paint, pixelRatio) {
1334
1340
  scaleX /= sx;
1335
1341
  scaleY /= sy;
1336
1342
  }
1343
+ const xGap = gap && gap.x * scaleX;
1344
+ const yGap = gap && gap.y * scaleY;
1337
1345
  if (transform || scaleX !== 1 || scaleY !== 1) {
1346
+ const canvasWidth = width + (xGap || 0);
1347
+ const canvasHeight = height + (yGap || 0);
1348
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1349
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1338
1350
  if (!imageMatrix) {
1339
1351
  imageMatrix = get$1();
1340
1352
  if (transform) copy$1(imageMatrix, transform);
1341
1353
  }
1342
1354
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1343
1355
  }
1344
- if (imageMatrix) {
1345
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1346
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1347
- }
1348
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1356
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1349
1357
  const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1350
1358
  paint.style = pattern;
1351
1359
  paint.patternId = id;
@@ -1587,12 +1595,18 @@ function shadow(ui, current, shape) {
1587
1595
  }
1588
1596
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
1589
1597
  }
1590
- core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1598
+ if (draw.Effect.isTransformShadow(item)) draw.Effect.renderTransformShadow(ui, current, other, copyBounds, item); else core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1591
1599
  if (end && index < end) other.clearWorld(copyBounds);
1592
1600
  });
1593
1601
  other.recycle(copyBounds);
1594
1602
  }
1595
1603
 
1604
+ function getShadowSpread(_ui, shadow) {
1605
+ let width = 0;
1606
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
1607
+ return width;
1608
+ }
1609
+
1596
1610
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1597
1611
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
1598
1612
  if (core.Platform.fullImageShadow) {
@@ -1670,7 +1684,11 @@ const EffectModule = {
1670
1684
  shadow: shadow,
1671
1685
  innerShadow: innerShadow,
1672
1686
  blur: blur,
1673
- backgroundBlur: backgroundBlur
1687
+ backgroundBlur: backgroundBlur,
1688
+ getShadowSpread: getShadowSpread,
1689
+ isTransformShadow(_shadow) {
1690
+ return undefined;
1691
+ }
1674
1692
  };
1675
1693
 
1676
1694
  const {excludeRenderBounds: excludeRenderBounds} = core.LeafBoundsHelper;
@@ -2178,16 +2196,17 @@ function toTextChar(row) {
2178
2196
  }
2179
2197
 
2180
2198
  function decorationText(drawData, style) {
2181
- let type;
2199
+ let type, offset = 0;
2182
2200
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
2183
2201
  drawData.decorationHeight = fontSize / 11;
2184
2202
  if (core.isObject(textDecoration)) {
2185
2203
  type = textDecoration.type;
2186
2204
  if (textDecoration.color) drawData.decorationColor = draw.ColorConvert.string(textDecoration.color);
2205
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
2187
2206
  } else type = textDecoration;
2188
2207
  switch (type) {
2189
2208
  case "under":
2190
- drawData.decorationY = [ fontSize * .15 ];
2209
+ drawData.decorationY = [ fontSize * .15 + offset ];
2191
2210
  break;
2192
2211
 
2193
2212
  case "delete":
@@ -2195,7 +2214,7 @@ function decorationText(drawData, style) {
2195
2214
  break;
2196
2215
 
2197
2216
  case "under-delete":
2198
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
2217
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
2199
2218
  }
2200
2219
  }
2201
2220
 
@@ -2451,6 +2470,8 @@ const ExportModule = {
2451
2470
  renderBounds: renderBounds,
2452
2471
  trimBounds: trimBounds
2453
2472
  };
2473
+ const app = leafer && leafer.app;
2474
+ if (app && app.canvasManager) app.canvasManager.clearRecycled();
2454
2475
  }
2455
2476
  } catch (error) {
2456
2477
  result = {
package/dist/node.esm.js CHANGED
@@ -6,7 +6,7 @@ export { LeaferImage } from "@leafer/core";
6
6
 
7
7
  import { writeFileSync } from "fs";
8
8
 
9
- import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect, TwoPointBoundsHelper, Bounds as Bounds$1, FileHelper as FileHelper$1, Platform as Platform$1, isUndefined as isUndefined$1, Matrix as Matrix$1, MathHelper as MathHelper$1, Creator as Creator$1, TaskProcessor, Resource, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin, UI } from "@leafer-ui/draw";
9
+ import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Effect, Group, TextConvert, TwoPointBoundsHelper, Bounds as Bounds$1, FileHelper as FileHelper$1, Platform as Platform$1, isUndefined as isUndefined$1, Matrix as Matrix$1, MathHelper as MathHelper$1, Creator as Creator$1, TaskProcessor, Resource, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin, UI } from "@leafer-ui/draw";
10
10
 
11
11
  export * from "@leafer-ui/draw";
12
12
 
@@ -454,7 +454,7 @@ class Renderer {
454
454
  this.times = 0;
455
455
  this.config = {
456
456
  usePartRender: true,
457
- maxFPS: 60
457
+ maxFPS: 120
458
458
  };
459
459
  this.target = target;
460
460
  this.canvas = canvas;
@@ -609,11 +609,15 @@ class Renderer {
609
609
  if (this.requestTime || !target) return;
610
610
  if (target.parentApp) return target.parentApp.requestRender(false);
611
611
  const requestTime = this.requestTime = Date.now();
612
- Platform.requestRender(() => {
613
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
612
+ const render = () => {
613
+ const nowFPS = 1e3 / (Date.now() - requestTime);
614
+ const {maxFPS: maxFPS} = this.config;
615
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
616
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
614
617
  this.requestTime = 0;
615
618
  this.checkRender();
616
- });
619
+ };
620
+ Platform.requestRender(render);
617
621
  }
618
622
  __onResize(e) {
619
623
  if (this.canvas.unreal) return;
@@ -656,7 +660,8 @@ class Renderer {
656
660
  if (this.target) {
657
661
  this.stop();
658
662
  this.__removeListenEvents();
659
- this.target = this.canvas = this.config = null;
663
+ this.config = {};
664
+ this.target = this.canvas = null;
660
665
  }
661
666
  }
662
667
  }
@@ -1295,7 +1300,7 @@ function ignoreRender(ui, value) {
1295
1300
 
1296
1301
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1297
1302
 
1298
- const {floor: floor, max: max, abs: abs} = Math;
1303
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1299
1304
 
1300
1305
  function createPattern(ui, paint, pixelRatio) {
1301
1306
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1305,8 +1310,6 @@ function createPattern(ui, paint, pixelRatio) {
1305
1310
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1306
1311
  scaleX *= pixelRatio;
1307
1312
  scaleY *= pixelRatio;
1308
- const xGap = gap && gap.x * scaleX;
1309
- const yGap = gap && gap.y * scaleY;
1310
1313
  if (sx) {
1311
1314
  sx = abs(sx);
1312
1315
  sy = abs(sy);
@@ -1323,7 +1326,10 @@ function createPattern(ui, paint, pixelRatio) {
1323
1326
  if (size > Platform.image.maxCacheSize) return false;
1324
1327
  }
1325
1328
  let maxSize = Platform.image.maxPatternSize;
1326
- if (!image.isSVG) {
1329
+ if (image.isSVG) {
1330
+ const ws = width / image.width;
1331
+ if (ws > 1) imageScale = ws / ceil(ws);
1332
+ } else {
1327
1333
  const imageSize = image.width * image.height;
1328
1334
  if (maxSize > imageSize) maxSize = imageSize;
1329
1335
  }
@@ -1338,18 +1344,20 @@ function createPattern(ui, paint, pixelRatio) {
1338
1344
  scaleX /= sx;
1339
1345
  scaleY /= sy;
1340
1346
  }
1347
+ const xGap = gap && gap.x * scaleX;
1348
+ const yGap = gap && gap.y * scaleY;
1341
1349
  if (transform || scaleX !== 1 || scaleY !== 1) {
1350
+ const canvasWidth = width + (xGap || 0);
1351
+ const canvasHeight = height + (yGap || 0);
1352
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1353
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1342
1354
  if (!imageMatrix) {
1343
1355
  imageMatrix = get$1();
1344
1356
  if (transform) copy$1(imageMatrix, transform);
1345
1357
  }
1346
1358
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1347
1359
  }
1348
- if (imageMatrix) {
1349
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1350
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1351
- }
1352
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1360
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1353
1361
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1354
1362
  paint.style = pattern;
1355
1363
  paint.patternId = id;
@@ -1591,12 +1599,18 @@ function shadow(ui, current, shape) {
1591
1599
  }
1592
1600
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
1593
1601
  }
1594
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1602
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1595
1603
  if (end && index < end) other.clearWorld(copyBounds);
1596
1604
  });
1597
1605
  other.recycle(copyBounds);
1598
1606
  }
1599
1607
 
1608
+ function getShadowSpread(_ui, shadow) {
1609
+ let width = 0;
1610
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
1611
+ return width;
1612
+ }
1613
+
1600
1614
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1601
1615
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
1602
1616
  if (Platform.fullImageShadow) {
@@ -1674,7 +1688,11 @@ const EffectModule = {
1674
1688
  shadow: shadow,
1675
1689
  innerShadow: innerShadow,
1676
1690
  blur: blur,
1677
- backgroundBlur: backgroundBlur
1691
+ backgroundBlur: backgroundBlur,
1692
+ getShadowSpread: getShadowSpread,
1693
+ isTransformShadow(_shadow) {
1694
+ return undefined;
1695
+ }
1678
1696
  };
1679
1697
 
1680
1698
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -2182,16 +2200,17 @@ function toTextChar(row) {
2182
2200
  }
2183
2201
 
2184
2202
  function decorationText(drawData, style) {
2185
- let type;
2203
+ let type, offset = 0;
2186
2204
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
2187
2205
  drawData.decorationHeight = fontSize / 11;
2188
2206
  if (isObject(textDecoration)) {
2189
2207
  type = textDecoration.type;
2190
2208
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
2209
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
2191
2210
  } else type = textDecoration;
2192
2211
  switch (type) {
2193
2212
  case "under":
2194
- drawData.decorationY = [ fontSize * .15 ];
2213
+ drawData.decorationY = [ fontSize * .15 + offset ];
2195
2214
  break;
2196
2215
 
2197
2216
  case "delete":
@@ -2199,7 +2218,7 @@ function decorationText(drawData, style) {
2199
2218
  break;
2200
2219
 
2201
2220
  case "under-delete":
2202
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
2221
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
2203
2222
  }
2204
2223
  }
2205
2224
 
@@ -2455,6 +2474,8 @@ const ExportModule = {
2455
2474
  renderBounds: renderBounds,
2456
2475
  trimBounds: trimBounds
2457
2476
  };
2477
+ const app = leafer && leafer.app;
2478
+ if (app && app.canvasManager) app.canvasManager.clearRecycled();
2458
2479
  }
2459
2480
  } catch (error) {
2460
2481
  result = {
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,ResizeEvent as S,isObject as B,BoundsHelper as k,Matrix as R,isUndefined as E,isString as L,getMatrixData as A,MatrixHelper as T,MathHelper as C,AlignHelper as O,PointHelper as W,ImageEvent as D,AroundHelper as M,Direction4 as P,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as I}from"fs";import{PaintImage as U,Paint as Y,ColorConvert as X,PaintGradient as z,Export as N,Group as G,TextConvert as q,Effect as j,TwoPointBoundsHelper as H,Bounds as V,FileHelper as Q,Platform as J,isUndefined as Z,Matrix as $,MathHelper as K,Creator as tt,TaskProcessor as et,Resource as it,LeaferCanvasBase as st,Debug as nt,Plugin as at,UI as ot}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function rt(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class lt 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:dt,fileType:ct}=s;function ht(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(dt(e),i),canvasToBolb:(t,e,i)=>rt(this,void 0,void 0,function*(){return t.toBuffer(dt(e),i)}),canvasSaveAs:(t,e,i)=>rt(this,void 0,void 0,function*(){return I(e,t.toBuffer(dt(ct(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=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new lt(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ut{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,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.__updatedList.add(t.target),this.update()}__onChildEvent(t){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 r,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:ft,updateBounds:pt,updateChange:gt}=f,{pushAllChildBranch:_t,pushAllParent:wt}=p;const{worldBounds:yt}=g;class mt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,yt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,yt),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:vt,updateAllChange:xt}=f,bt=y.get("Layouter");class St{constructor(t,e){this.totalTimes=0,this.config={},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){bt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?bt.warn("layouting"):this.times>3?bt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=v,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new v(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(ft(t,!0),e.add(t),t.isBranch&&_t(t,e),wt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),wt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||pt(s[t])}pt(i)}})}(this.__levelList),function(t){t.list.forEach(gt)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new v(a,r,this.times)),i.emitEvent(new v(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=v,a=this.getBlocks(new r(e));e.emitEvent(new v(i,a,this.times)),St.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new v(s,a,this.times)),e.emitEvent(new v(n,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){vt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),xt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new mt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new mt(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 Bt=y.get("Renderer");class kt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=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.__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 _,Bt.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,Bt.error(t)}Bt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Bt.warn("rendering");if(this.times>3)return Bt.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),n=new _(s);i.save(),s.spread(kt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),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,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}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);const i=this.requestTime=Date.now();e.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()})}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(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||Bt.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.target=this.canvas=this.config=null)}}function Rt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function Et(t,e){t.__.__font?Rt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Lt(t,e,i){switch(e.__.strokeAlign){case"center":At(t,1,e,i);break;case"inside":Tt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?At(t,2,e,i):Tt(t,"outside",e,i)}}function At(t,e,i,s){const n=i.__;B(t)?Ot(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Ct(i,s))}function Tt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,At(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Rt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Ct(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Ot(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!U.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?Ct(s,n):n.stroke(),n.restoreBlendMode()):i?Ct(s,n):n.stroke()}}function Wt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Lt(t,e,i);else switch(s.strokeAlign){case"center":Dt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Dt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Dt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Dt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function Dt(t,e,i,s){const n=i.__;B(t)?Ot(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&Y.strokeArrow(t,i,s)}kt.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new ut(t,e),layouter:(t,e)=>new St(t,e),renderer:(t,e,i)=>new kt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=St.fullLayout;const{getSpread:Mt,getOuterOf:Pt,getByMove:Ft,getIntersectData:It}=k;let Ut;const{stintSet:Yt}=l,{hasTransparent:Xt}=X;function zt(t,e,i){if(!B(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=U.image(i,t,e,n,!Ut||!Ut[e.url]);break;case"linear":s=z.linearGradient(e,n);break;case"radial":s=z.radialGradient(e,n);break;case"angular":s=z.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:X.string(o,r)};break;default:E(e.r)||(s={type:"solid",style:X.string(e)})}if(s){if(L(s.style)&&Xt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Nt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];w(r)||(r=[r]),Ut=U.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=zt(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Yt(i,"__isAlphaPixelFill",n),Yt(i,"__isTransparentFill",a)):(Yt(i,"__isAlphaPixelStroke",n),Yt(i,"__isTransparentStroke",a),Yt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,Et(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(U.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),Et(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Et(e,i),i.restoreBlendMode()):Et(e,i)}},fillPathOrText:Et,fillText:Rt,stroke:Wt,strokes:function(t,e,i){Wt(t,e,i)},strokeText:Lt,drawTextStroke:Ct,shape:function(t,i,s){const n=i.getSameCanvas(),a=t.__nowWorld,o=i.bounds;let r,l,d,c,h,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))h=n,r=c=a;else{const{renderShapeSpread:n}=t.__layout;let p;if(e.fullImageShadow)p=a;else{const t=n?Mt(o,u===f?n*u:[n*f,n*u]):o;p=It(t,a)}d=o.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=i.getSameCanvas(),t.__renderShape(h,s),u*=g,f*=_),c=Pt(a,d),r=Ft(c,-d.e,-d.f);const w=s.matrix;w?(l=new R(d),l.multiply(w),g*=w.scaleX,_*=w.scaleY):l=d,l.withScale(g,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:d,bounds:r,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let Gt={},qt=A();const{get:jt,rotateOfOuter:Ht,translate:Vt,scaleOfOuter:Qt,multiplyParent:Jt,scale:Zt,rotate:$t,skew:Kt}=T;function te(t,e,i,s,n,a,o){const r=jt();Vt(r,e.x+i,e.y+s),Zt(r,n,a),o&&Ht(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function ee(t,e,i,s,n,a,o,r,l){const d=jt();se(d,e,i,s,n,a,o,r),l&&(qt.a=e.width/l.width,qt.d=e.height/l.height,Jt(d,qt)),t.transform=d}function ie(t,e,i,s,n,a,o,r,l,d,c,h){const u=jt();if(h)se(u,e,n,a,o,r,l,d);else{if(l)if("center"===c)Ht(u,{x:i/2,y:s/2},l);else switch($t(u,l),l){case 90:Vt(u,s,0);break;case 180:Vt(u,i,s);break;case 270:Vt(u,0,i)}Gt.x=e.x+n,Gt.y=e.y+a,Vt(u,Gt.x,Gt.y),o&&Qt(u,Gt,o,r)}t.transform=u}function se(t,e,i,s,n,a,o,r){o&&$t(t,o),r&&Kt(t,r.x,r.y),n&&Zt(t,n,a),Vt(t,e.x+i,e.y+s)}const{get:ne,translate:ae}=T,oe=new _,re={},le={};function de(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=ce(i,s,e)}function ce(t,e,i){t.padding&&(e=oe.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===s&&e.height===n,y={mode:o},m="center"!==r&&(h||0)%180==90;let v,x;switch(k.set(le,0,0,m?n:s,m?s:n),o&&"cover"!==o&&"fit"!==o?((d||c)&&(C.getScaleData(d,c,i,re),v=re.scaleX,x=re.scaleY),(r||g||p)&&(v&&k.scale(le,v,x,!0),r&&O.toPoint(r,le,e,le,!0,!0))):w&&!h||(v=x=k.getFitScale(e,le,"fit"!==o),k.put(e,i,r,v,!1,le),k.scale(le,v,x,!0)),l&&W.move(le,l),o){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":(le.x||le.y||v||f||h||u)&&ee(y,e,le.x,le.y,v,x,h,u,t.clipSize);break;case"repeat":(!w||v||h||u)&&ie(y,e,s,n,le.x,le.y,v,x,h,u,r,t.freeTransform),p||(y.repeat="repeat");const i=B(p);(g||i)&&(y.gap=function(t,e,i,s,n){let a,o;B(t)?(a=t.x,o=t.y):a=o=t;return{x:he(a,i,n.width,e&&e.x),y:he(o,s,n.height,e&&e.y)}}(g,i&&p,le.width,le.height,e));break;default:v&&te(y,e,le.x,le.y,v,x,h)}return y.transform||(e.x||e.y)&&(y.transform=ne(),ae(y.transform,e.x,e.y)),v&&"stretch"!==o&&(y.scaleX=v,y.scaleY=x),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),p&&(y.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),y}function he(t,e,i,s){const n=L(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let ue,fe=new _;const{isSame:pe}=k;function ge(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||de(n,s,i,a),!0}function _e(t,e){me(t,D.LOAD,e)}function we(t,e){me(t,D.LOADED,e)}function ye(t,e,i){e.error=i,t.forceUpdate("surface"),me(t,D.ERROR,e)}function me(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function ve(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:xe,scale:be,copy:Se}=T,{floor:Be,max:ke,abs:Re}=Math;function Ee(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{const{image:t,data:r}=i;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g,gap:_}=r;n*=s,a*=s;const w=_&&_.x*n,y=_&&_.y*a;u&&(u=Re(u),f=Re(f),d=xe(),Se(d,p),be(d,1/u,1/f),n*=u,a*=f),c*=n,h*=a;const m=c*h;if(!g&&m>e.image.maxCacheSize)return!1;let v=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}if(m>v&&(l=Math.sqrt(m/v)),l&&(n/=l,a/=l,c/=l,h/=l),u&&(n/=u,a/=f),(p||1!==n||1!==a)&&(d||(d=xe(),p&&Se(d,p)),be(d,1/n,1/a)),d){const t=c+(w||0),e=h+(y||0);be(d,t/ke(Be(t),1),e/ke(Be(e),1))}const x=t.getCanvas(c,h,r.opacity,r.filters,w,y),b=t.getPattern(x,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=b,i.patternId=o,!0}}const Le={image:function(t,e,i,s,n){let a,o;const r=b.get(i);return ue&&i===ue.paint&&pe(s,ue.boxBounds)?a=ue.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),ue=r.use>1?{leafPaint:a,paint:i,boxBounds:fe.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ge(t,e,i,r,a,s),n&&(_e(t,o),we(t,o))):r.error?n&&ye(t,o,r.error):(n&&(ve(t,!0),_e(t,o)),a.loadId=r.load(()=>{ve(t,!1),t.destroyed||(ge(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),we(t,o)),a.loadId=void 0},e=>{ve(t,!1),ye(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=i,{data:l}=s;if(!l||s.patternId===a+"-"+o+"-"+r&&!N.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&S.isResizing(t)||N.running)){let{width:t,height:i}=l;t*=a*r,i*=o*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||N.running?Ee(t,s,r):s.patternTask||(s.patternTask=b.patternTasker.add(()=>rt(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&Ee(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:Ee,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,b.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],w(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:de,getPatternData:ce,fillOrFitMode:te,clipMode:ee,repeatMode:ie},{toPoint:Ae}=M,{hasTransparent:Te}=X,Ce={},Oe={};function We(t,e,i,s){if(i){let n,a,o,r;for(let t=0,l=i.length;t<l;t++)n=i[t],L(n)?(o=t/(l-1),a=X.string(n,s)):(o=n.offset,a=X.string(n.color,s)),e.addColorStop(o,a),!r&&Te(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:De,getDistance:Me}=W,{get:Pe,rotateOfOuter:Fe,scaleOfOuter:Ie}=T,{toPoint:Ue}=M,Ye={},Xe={};function ze(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=De(e,i);a=Pe(),n?(Ie(a,e,o/r*(s||1),1),Fe(a,e,t+90)):(Ie(a,e,1,o/r*(s||1)),Fe(a,e,t))}return a}const{getDistance:Ne}=W,{toPoint:Ge}=M,qe={},je={};const He={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;Ae(s||"top",i,Ce),Ae(n||"bottom",i,Oe);const r=e.canvas.createLinearGradient(Ce.x,Ce.y,Oe.x,Oe.y),l={type:a,style:r};return We(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ue(s||"center",i,Ye),Ue(n||"bottom",i,Xe);const l=e.canvas.createRadialGradient(Ye.x,Ye.y,0,Ye.x,Ye.y,Me(Ye,Xe)),d={type:a,style:l};We(d,l,t.stops,o);const c=ze(i,Ye,Xe,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ge(s||"center",i,qe),Ge(n||"bottom",i,je);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,qe.x,qe.y):e.canvas.createRadialGradient(qe.x,qe.y,0,qe.x,qe.y,Ne(qe,je)),d={type:a,style:l};We(d,l,t.stops,o);const c=ze(i,qe,je,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:ze},{copy:Ve,toOffsetOutBounds:Qe}=k,Je={},Ze={};function $e(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Ve(Je,t.bounds),Je.x+=i.x-o.x,Je.y+=i.y-o.y,s){const{fitMatrix:t}=n;Je.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Je.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Je.width*=s,Je.height*=s}t.copyWorld(n.canvas,t.bounds,Je)}else s&&(Ve(Je,i),Je.x-=i.width/2*(s-1),Je.y-=i.height/2*(s-1),Je.width*=s,Je.height*=s),t.copyWorld(n.canvas,o,s?Je:i)}const{toOffsetOutBounds:Ke}=k,ti={};const ei={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=r.length-1;Qe(d,Ze),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Ze.offsetX+r.x*h*w,Ze.offsetY+r.y*u*w,r.blur*h*w,X.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*w:0,$e(p,Ze,n,i),s=d,r.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,d,a,"copy"),s=a),l?p.copyWorld(l,a,a,"destination-out"):p.copyWorld(i.canvas,c,d,"destination-out")),f.copyCanvasByWorld(t,e,p,s,r.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=r.length-1;Ke(d,ti),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(ti.offsetX+r.x*h*w,ti.offsetY+r.y*u*w,r.blur*h*w),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*w:0,$e(p,ti,n,i),p.restore(),l?(p.copyWorld(p,d,a,"copy"),p.copyWorld(l,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,c,d,"source-out"),s=d),p.fillWorld(s,X.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,p,s,r.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ii}=g;let si;function ni(t,e,i,s,n,a,o,r){switch(e){case"grayscale":si||(si=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);oi(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":oi(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function ai(t){return t.getSameCanvas(!1,!0)}function oi(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}G.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],r=i.__.mask,r){o&&(ni(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,si=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=ai(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=ai(t)),n||(n=ai(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||ii(i,e)||i.__render(t,e);continue}const c=1===a&&i.__.__blendMode;c&&ni(this,o,t,n,s,a,void 0,!1),ii(i,e)||i.__render(n||t,e),c&&ni(this,o,t,n,s,a,c,!1)}ni(this,o,t,n,s,a,void 0,!0)};const ri=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",li=ri+"_#~&*+\\=|≮≯≈≠=…",di=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 ci(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const hi=ci("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ui=ci("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fi=ci(ri),pi=ci(li),gi=ci("- —/~|┆·");var _i;!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"}(_i||(_i={}));const{Letter:wi,Single:yi,Before:mi,After:vi,Symbol:xi,Break:bi}=_i;function Si(t){return hi[t]?wi:gi[t]?bi:ui[t]?mi:fi[t]?vi:pi[t]?xi:di.test(t)?yi:wi}const Bi={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ki(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:Ri}=Bi,{Letter:Ei,Single:Li,Before:Ai,After:Ti,Symbol:Ci,Break:Oi}=_i;let Wi,Di,Mi,Pi,Fi,Ii,Ui,Yi,Xi,zi,Ni,Gi,qi,ji,Hi,Vi,Qi,Ji=[];function Zi(t,e){Xi&&!Yi&&(Yi=Xi),Wi.data.push({char:t,width:e}),Mi+=e}function $i(){Pi+=Mi,Wi.width=Mi,Di.words.push(Wi),Wi={data:[]},Mi=0}function Ki(){ji&&(Hi.paraNumber++,Di.paraStart=!0,ji=!1),Xi&&(Di.startCharSize=Yi,Di.endCharSize=Xi,Yi=0),Di.width=Pi,Vi.width?Ri(Di):Qi&&ts(),Ji.push(Di),Di={words:[]},Pi=0}function ts(){Pi>(Hi.maxWidth||0)&&(Hi.maxWidth=Pi)}const{top:es,right:is,bottom:ss,left:ns}=P;function as(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const os={getDrawData:function(t,i){L(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(a?(s=d[ns],a-=d[is]+d[ns]):i.autoSizeAlign||(s=d[ns]),o?(n=d[es],o-=d[es]+d[ss]):i.autoSizeAlign||(n=d[es]));const c={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Hi=t,Ji=t.rows,Vi=t.bounds,Qi=!Vi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:l,height:d}=Vi;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;ji=!0,Ni=null,Yi=Ui=Xi=Mi=Pi=0,Wi={data:[]},Di={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Ii=i[s],"\n"===Ii?(Mi&&$i(),Di.paraEnd=!0,Ki(),ji=!0):(zi=Si(Ii),zi===Ei&&"none"!==o&&(Ii=ki(Ii,o,!Mi)),Ui=r.measureText(Ii).width,n&&(n<0&&(Xi=Ui),Ui+=n),Gi=zi===Li&&(Ni===Li||Ni===Ei)||Ni===Li&&zi!==Ti,qi=!(zi!==Ai&&zi!==Li||Ni!==Ci&&Ni!==Ti),Fi=ji&&a?l-a:l,t&&l&&Pi+Mi+Ui>Fi&&(e?(Mi&&$i(),Pi&&Ki()):(qi||(qi=zi===Ei&&Ni==Ti),Gi||qi||zi===Oi||zi===Ai||zi===Li||Mi+Ui>Fi?(Mi&&$i(),Pi&&Ki()):Pi&&Ki()))," "===Ii&&!0!==ji&&Pi+Mi===0||(zi===Oi?(" "===Ii&&Mi&&$i(),Zi(Ii,Ui),$i()):Gi||qi?(Mi&&$i(),Zi(Ii,Ui)):Zi(Ii,Ui)),Ni=zi);Mi&&$i(),Pi&&Ki(),Ji.length>0&&(Ji[Ji.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Hi.paraNumber++,Pi=r.measureText(t).width,Ji.push({x:a||0,text:t,width:Pi,paraStart:!0}),Qi&&ts()})}(c,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":as(e,"x",t[ns]);break;case"right":as(e,"x",-t[is])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":as(e,"y",t[es]);break;case"bottom":as(e,"y",-t[ss])}}(d,c,i,a,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=n;o<c;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&o>0&&(y+=h),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)})),t.words=null)})}(c,i,a),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=s+n-d;("none"===i.textWrap?a:[a[o-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:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,i,s,a),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,B(n)?(i=n.type,n.color&&(t.decorationColor=X.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(c,i),c}};const rs={string:function(t,e){const i=F(e)&&e<1;if(L(t)){if(!i||!X.object)return t;t=X.object(t)}let s=E(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(q,os),Object.assign(X,rs),Object.assign(Y,Nt),Object.assign(U,Le),Object.assign(z,He),Object.assign(j,ei);const{setPoint:ls,addPoint:ds,toBounds:cs}=H;const hs={syncExport(t,e,i){let s;N.running=!0;try{const n=Q.fileType(e),a=e.includes(".");i=Q.getExportOptions(i);const{toURL:o}=J,{download:r}=J.origin;if("json"===n)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!a||t.toJSON(i.json)};else if("svg"===n)a&&r(o(t.toSVG(),"svg"),e),s={data:!!a||t.toSVG()};else{let n,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=i,y=Z(i.smooth)?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&Z(i.fill)?t.fill:i.fill,x=Q.isOpaqueImage(e)||v,b=new $;if(g)n=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}n=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};K.getScaleData(i.scale,i.size,n,S);let B=i.pixelRatio||1,{x:k,y:R,width:E,height:L}=new V(n).scale(S.scaleX,S.scaleY);f&&(k+=f.x,R+=f.y,E=f.width,L=f.height);const A={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-k,-R).withScale(1/o*S.scaleX,1/r*S.scaleY)};let T,C=tt.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:B,smooth:y,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=c||t,A.bounds=C.bounds),C.save(),h&&!Z(v)){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,a,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,a=(r-n)/e,o?ds(o,n,a):ls(o={},n,a)),r++;const l=new V;return o&&(cs(o,l),l.scale(1/t.pixelRatio).ceil()),l}(C);const t=C,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:B};C=tt.canvas(s),C.copyWorld(t,a,s),t.destroy()}if(_){const[t,e,i,s]=K.fourNumber(_),n=C,{width:a,height:o}=n;C=tt.canvas({width:a+s+e,height:o+t+i,pixelRatio:B}),C.copyWorld(n,n.bounds,{x:s,y:t,width:a,height:o}),n.destroy()}x&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),w&&w(C);s={data:"canvas"===e?C:C.export(e,i),width:C.pixelWidth,height:C.pixelHeight,renderBounds:n,trimBounds:a}}}catch(t){s={data:"",error:t}}return N.running=!1,s},export(t,e,i){return N.running=!0,function(t){us||(us=new et);return new Promise(e=>{us.add(()=>rt(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const a=()=>rt(this,void 0,void 0,function*(){if(!it.isComplete)return J.requestRender(a);const o=N.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()});t.updateLayout(),fs(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))}};let us;function fs(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>fs(t))}const ps=st.prototype,gs=nt.get("@leafer-in/export");ps.export=function(t,e){const{quality:i,blob:s}=Q.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},ps.toBlob=function(t,e){return new Promise(i=>{J.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{gs.error(t),i(null)})})},ps.toDataURL=function(t,e){return J.origin.canvasToDataURL(this.view,t,e)},ps.saveAs=function(t,e){return new Promise(i=>{J.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{gs.error(t),i(!1)})})},at.add("export"),Object.assign(N,hs),ot.prototype.export=function(t,e){return N.export(this,t,e)},ot.prototype.syncExport=function(t,e){return N.syncExport(this,t,e)};export{St as Layouter,lt as LeaferCanvas,kt as Renderer,ut as Watcher,ht as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as a,LeaferImage as n,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,ResizeEvent as S,isObject as B,BoundsHelper as k,Matrix as R,isUndefined as E,isString as L,getMatrixData as A,MatrixHelper as T,MathHelper as C,AlignHelper as O,PointHelper as M,ImageEvent as W,AroundHelper as D,Direction4 as P,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as I}from"fs";import{PaintImage as U,Paint as Y,ColorConvert as X,PaintGradient as z,Export as N,Effect as q,Group as G,TextConvert as j,TwoPointBoundsHelper as H,Bounds as V,FileHelper as Q,Platform as J,isUndefined as Z,Matrix as $,MathHelper as K,Creator as tt,TaskProcessor as et,Resource as it,LeaferCanvasBase as st,Debug as at,Plugin as nt,UI as ot}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function rt(t,e,i,s){return new(i||(i=Promise))(function(a,n){function o(t){try{l(s.next(t))}catch(t){n(t)}}function r(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(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class lt 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:dt,fileType:ct}=s;function ht(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(dt(e),i),canvasToBolb:(t,e,i)=>rt(this,void 0,void 0,function*(){return t.toBuffer(dt(e),i)}),canvasSaveAs:(t,e,i)=>rt(this,void 0,void 0,function*(){return I(e,t.toBuffer(dt(ct(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 lt(t,e),image:t=>new n(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ut{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,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.__updatedList.add(t.target),this.update()}__onChildEvent(t){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 r,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:ft,updateBounds:pt,updateChange:gt}=f,{pushAllChildBranch:_t,pushAllParent:wt}=p;const{worldBounds:yt}=g;class mt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,yt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,yt),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:vt,updateAllChange:xt}=f,bt=y.get("Layouter");class St{constructor(t,e){this.totalTimes=0,this.config={},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){bt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?bt.warn("layouting"):this.times>3?bt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:o}=v,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new v(a,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(ft(t,!0),e.add(t),t.isBranch&&_t(t,e),wt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),wt(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||pt(s[t])}pt(i)}})}(this.__levelList),function(t){t.list.forEach(gt)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new v(n,r,this.times)),i.emitEvent(new v(o,r,this.times)),this.addBlocks(r),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 r(e));e.emitEvent(new v(i,n,this.times)),St.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){vt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),xt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new mt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new mt(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 Bt=y.get("Renderer");class kt{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.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.__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 _,Bt.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,Bt.error(t)}Bt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Bt.warn("rendering");if(this.times>3)return Bt.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(kt.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,e){const{canvas:i}=this,s=t.includes(this.target.__world),a=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(i,t),this.target.__render(i,a),this.renderBounds=e=e||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}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);const i=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-i),{maxFPS:a}=this.config;if(a&&t>a-.5)return e.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};e.requestRender(s)}__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||Bt.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)}}function Rt(t,e){const i=t.__,{rows:s,decorationY:a}=i.__textDrawData;let n;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.fillText(t.char,t.x,n.y)});if(a){const{decorationColor:t,decorationHeight:n}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>a.forEach(i=>e.fillRect(t.x,t.y+i,t.width,n)))}}function Et(t,e){t.__.__font?Rt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Lt(t,e,i){switch(e.__.strokeAlign){case"center":At(t,1,e,i);break;case"inside":Tt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?At(t,2,e,i):Tt(t,"outside",e,i)}}function At(t,e,i,s){const a=i.__;B(t)?Ot(t,e,!0,i,s):(s.setStroke(t,a.__strokeWidth*e,a),Ct(i,s))}function Tt(t,e,i,s){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,At(t,2,i,a),a.blendMode="outside"===e?"destination-out":"destination-in",Rt(i,a),a.blendMode="normal",f.copyCanvasByWorld(i,s,a),a.recycle(i.__nowWorld)}function Ct(t,e){let i,s=t.__.__textDrawData;const{rows:a,decorationY:n}=s;for(let t=0,s=a.length;t<s;t++)i=a[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(n){const{decorationHeight:t}=s;a.forEach(i=>n.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Ot(t,e,i,s,a){let n;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||a.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,d=t.length;l<d;l++)if(n=t[l],(!n.image||!U.checkImage(s,a,n,!1))&&n.style){if(r){const{strokeStyle:t}=n;t?a.setStroke(n.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(n.style,o.__strokeWidth*e,o)}else a.strokeStyle=n.style;n.blendMode?(a.saveBlendMode(n.blendMode),i?Ct(s,a):a.stroke(),a.restoreBlendMode()):i?Ct(s,a):a.stroke()}}function Mt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Lt(t,e,i);else switch(s.strokeAlign){case"center":Wt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Wt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Wt(t,2,e,i);else{const{renderBounds:a}=e.__layout,n=i.getSameCanvas(!0,!0);e.__drawRenderPath(n),Wt(t,2,e,n),n.clipUI(s),n.clearWorld(a),f.copyCanvasByWorld(e,i,n),n.recycle(e.__nowWorld)}}(t,e,i)}}function Wt(t,e,i,s){const a=i.__;B(t)?Ot(t,e,!1,i,s):(s.setStroke(t,a.__strokeWidth*e,a),s.stroke()),a.__useArrow&&Y.strokeArrow(t,i,s)}kt.clipSpread=10,Object.assign(a,{watcher:(t,e)=>new ut(t,e),layouter:(t,e)=>new St(t,e),renderer:(t,e,i)=>new kt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=St.fullLayout;const{getSpread:Dt,getOuterOf:Pt,getByMove:Ft,getIntersectData:It}=k;let Ut;const{stintSet:Yt}=l,{hasTransparent:Xt}=X;function zt(t,e,i){if(!B(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:a}=i.__layout;switch(e.type){case"image":s=U.image(i,t,e,a,!Ut||!Ut[e.url]);break;case"linear":s=z.linearGradient(e,a);break;case"radial":s=z.radialGradient(e,a);break;case"angular":s=z.conicGradient(e,a);break;case"solid":const{type:n,color:o,opacity:r}=e;s={type:n,style:X.string(o,r)};break;default:E(e.r)||(s={type:"solid",style:X.string(e)})}if(s){if(L(s.style)&&Xt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Nt={compute:function(t,e){const i=e.__,s=[];let a,n,o,r=i.__input[t];w(r)||(r=[r]),Ut=U.recycleImage(t,i);for(let i,a=0,n=r.length;a<n;a++)(i=zt(t,r[a],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,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?(Yt(i,"__isAlphaPixelFill",a),Yt(i,"__isTransparentFill",n)):(Yt(i,"__isAlphaPixelStroke",a),Yt(i,"__isTransparentStroke",n),Yt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,Et(e,i)},fills:function(t,e,i){let s;for(let a=0,n=t.length;a<n;a++){if(s=t[a],s.image){if(U.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:a}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&a>1)&&i.scale(1/t,1/a)}s.blendMode&&(i.blendMode=s.blendMode),Et(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Et(e,i),i.restoreBlendMode()):Et(e,i)}},fillPathOrText:Et,fillText:Rt,stroke:Mt,strokes:function(t,e,i){Mt(t,e,i)},strokeText:Lt,drawTextStroke:Ct,shape:function(t,i,s){const a=i.getSameCanvas(),n=t.__nowWorld,o=i.bounds;let r,l,d,c,h,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(n))h=a,r=c=n;else{const{renderShapeSpread:a}=t.__layout;let p;if(e.fullImageShadow)p=n;else{const t=a?Dt(o,u===f?a*u:[a*f,a*u]):o;p=It(t,n)}d=o.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=i.getSameCanvas(),t.__renderShape(h,s),u*=g,f*=_),c=Pt(n,d),r=Ft(c,-d.e,-d.f);const w=s.matrix;w?(l=new R(d),l.multiply(w),g*=w.scaleX,_*=w.scaleY):l=d,l.withScale(g,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(a,s),{canvas:a,matrix:l,fitMatrix:d,bounds:r,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let qt={},Gt=A();const{get:jt,rotateOfOuter:Ht,translate:Vt,scaleOfOuter:Qt,multiplyParent:Jt,scale:Zt,rotate:$t,skew:Kt}=T;function te(t,e,i,s,a,n,o){const r=jt();Vt(r,e.x+i,e.y+s),Zt(r,a,n),o&&Ht(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function ee(t,e,i,s,a,n,o,r,l){const d=jt();se(d,e,i,s,a,n,o,r),l&&(Gt.a=e.width/l.width,Gt.d=e.height/l.height,Jt(d,Gt)),t.transform=d}function ie(t,e,i,s,a,n,o,r,l,d,c,h){const u=jt();if(h)se(u,e,a,n,o,r,l,d);else{if(l)if("center"===c)Ht(u,{x:i/2,y:s/2},l);else switch($t(u,l),l){case 90:Vt(u,s,0);break;case 180:Vt(u,i,s);break;case 270:Vt(u,0,i)}qt.x=e.x+a,qt.y=e.y+n,Vt(u,qt.x,qt.y),o&&Qt(u,qt,o,r)}t.transform=u}function se(t,e,i,s,a,n,o,r){o&&$t(t,o),r&&Kt(t,r.x,r.y),a&&Zt(t,a,n),Vt(t,e.x+i,e.y+s)}const{get:ae,translate:ne}=T,oe=new _,re={},le={};function de(t,e,i,s){const{changeful:a,sync:n,scaleFixed:o}=i;a&&(t.changeful=a),n&&(t.sync=n),o&&(t.scaleFixed=o),t.data=ce(i,s,e)}function ce(t,e,i){t.padding&&(e=oe.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:a}=i;const{opacity:n,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===s&&e.height===a,y={mode:o},m="center"!==r&&(h||0)%180==90;let v,x;switch(k.set(le,0,0,m?a:s,m?s:a),o&&"cover"!==o&&"fit"!==o?((d||c)&&(C.getScaleData(d,c,i,re),v=re.scaleX,x=re.scaleY),(r||g||p)&&(v&&k.scale(le,v,x,!0),r&&O.toPoint(r,le,e,le,!0,!0))):w&&!h||(v=x=k.getFitScale(e,le,"fit"!==o),k.put(e,i,r,v,!1,le),k.scale(le,v,x,!0)),l&&M.move(le,l),o){case"stretch":w||(s=e.width,a=e.height);break;case"normal":case"clip":(le.x||le.y||v||f||h||u)&&ee(y,e,le.x,le.y,v,x,h,u,t.clipSize);break;case"repeat":(!w||v||h||u)&&ie(y,e,s,a,le.x,le.y,v,x,h,u,r,t.freeTransform),p||(y.repeat="repeat");const i=B(p);(g||i)&&(y.gap=function(t,e,i,s,a){let n,o;B(t)?(n=t.x,o=t.y):n=o=t;return{x:he(n,i,a.width,e&&e.x),y:he(o,s,a.height,e&&e.y)}}(g,i&&p,le.width,le.height,e));break;default:v&&te(y,e,le.x,le.y,v,x,h)}return y.transform||(e.x||e.y)&&(y.transform=ae(),ne(y.transform,e.x,e.y)),v&&"stretch"!==o&&(y.scaleX=v,y.scaleY=x),y.width=s,y.height=a,n&&(y.opacity=n),_&&(y.filters=_),p&&(y.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),y}function he(t,e,i,s){const a=L(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let ue,fe=new _;const{isSame:pe}=k;function ge(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||de(a,s,i,n),!0}function _e(t,e){me(t,W.LOAD,e)}function we(t,e){me(t,W.LOADED,e)}function ye(t,e,i){e.error=i,t.forceUpdate("surface"),me(t,W.ERROR,e)}function me(t,e,i){t.hasEvent(e)&&t.emitEvent(new W(e,i))}function ve(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:xe,scale:be,copy:Se}=T,{floor:Be,ceil:ke,max:Re,abs:Ee}=Math;function Le(t,i,s){let{scaleX:a,scaleY:n}=t.getRenderScaleData(!0,i.scaleFixed);const o=a+"-"+n+"-"+s;if(i.patternId===o||t.destroyed)return!1;{const{image:r,data:l}=i;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;a*=s,n*=s,f&&(f=Ee(f),p=Ee(p),c=xe(),Se(c,g),be(c,1/f,1/p),a*=f,n*=p),h*=a,u*=n;const y=h*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(r.isSVG){const t=h/r.width;t>1&&(d=t/ke(t))}else{const t=r.width*r.height;m>t&&(m=t)}y>m&&(d=Math.sqrt(y/m)),d&&(a/=d,n/=d,h/=d,u/=d),f&&(a/=f,n/=p);const v=w&&w.x*a,x=w&&w.y*n;if(g||1!==a||1!==n){const t=h+(v||0),e=u+(x||0);a/=t/Re(Be(t),1),n/=e/Re(Be(e),1),c||(c=xe(),g&&Se(c,g)),be(c,1/a,1/n)}const b=r.getCanvas(h,u,l.opacity,l.filters,v,x,t.leafer&&t.leafer.config.smooth),S=r.getPattern(b,_||e.origin.noRepeat||"no-repeat",c,i);return i.style=S,i.patternId=o,!0}}const Ae={image:function(t,e,i,s,a){let n,o;const r=b.get(i);return ue&&i===ue.paint&&pe(s,ue.boxBounds)?n=ue.leafPaint:(n={type:i.type,image:r},r.hasAlphaPixel&&(n.isTransparent=!0),ue=r.use>1?{leafPaint:n,paint:i,boxBounds:fe.set(s)}:null),(a||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ge(t,e,i,r,n,s),a&&(_e(t,o),we(t,o))):r.error?a&&ye(t,o,r.error):(a&&(ve(t,!0),_e(t,o)),n.loadId=r.load(()=>{ve(t,!1),t.destroyed||(ge(t,e,i,r,n,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),we(t,o)),n.loadId=void 0},e=>{ve(t,!1),ye(t,o,e),n.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),n},checkImage:function(t,i,s,a){const{scaleX:n,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=i,{data:l}=s;if(!l||s.patternId===n+"-"+o+"-"+r&&!N.running)return!1;if(a)if(l.repeat)a=!1;else if(!(s.changeful||"miniapp"===e.name&&S.isResizing(t)||N.running)){let{width:t,height:i}=l;t*=n*r,i*=o*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),a=t*i>e.image.maxCacheSize}return a?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||N.running?Le(t,s,r):s.patternTask||(s.patternTask=b.patternTasker.add(()=>rt(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&Le(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:Le,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,a,n,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],a=s.image,r=a&&a.url,r&&(n||(n={}),n[r]=!0,b.recycle(a),a.loading&&(o||(o=e.__input&&e.__input[t]||[],w(o)||(o=[o])),a.unload(i[l].loadId,!o.some(t=>t.url===r))));return n}return null},createData:de,getPatternData:ce,fillOrFitMode:te,clipMode:ee,repeatMode:ie},{toPoint:Te}=D,{hasTransparent:Ce}=X,Oe={},Me={};function We(t,e,i,s){if(i){let a,n,o,r;for(let t=0,l=i.length;t<l;t++)a=i[t],L(a)?(o=t/(l-1),n=X.string(a,s)):(o=a.offset,n=X.string(a.color,s)),e.addColorStop(o,n),!r&&Ce(n)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:De,getDistance:Pe}=M,{get:Fe,rotateOfOuter:Ie,scaleOfOuter:Ue}=T,{toPoint:Ye}=D,Xe={},ze={};function Ne(t,e,i,s,a){let n;const{width:o,height:r}=t;if(o!==r||s){const t=De(e,i);n=Fe(),a?(Ue(n,e,o/r*(s||1),1),Ie(n,e,t+90)):(Ue(n,e,1,o/r*(s||1)),Ie(n,e,t))}return n}const{getDistance:qe}=M,{toPoint:Ge}=D,je={},He={};const Ve={linearGradient:function(t,i){let{from:s,to:a,type:n,opacity:o}=t;Te(s||"top",i,Oe),Te(a||"bottom",i,Me);const r=e.canvas.createLinearGradient(Oe.x,Oe.y,Me.x,Me.y),l={type:n,style:r};return We(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:a,type:n,opacity:o,stretch:r}=t;Ye(s||"center",i,Xe),Ye(a||"bottom",i,ze);const l=e.canvas.createRadialGradient(Xe.x,Xe.y,0,Xe.x,Xe.y,Pe(Xe,ze)),d={type:n,style:l};We(d,l,t.stops,o);const c=Ne(i,Xe,ze,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:a,type:n,opacity:o,stretch:r}=t;Ge(s||"center",i,je),Ge(a||"bottom",i,He);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,je.x,je.y):e.canvas.createRadialGradient(je.x,je.y,0,je.x,je.y,qe(je,He)),d={type:n,style:l};We(d,l,t.stops,o);const c=Ne(i,je,He,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ne},{copy:Qe,toOffsetOutBounds:Je}=k,Ze={},$e={};function Ke(t,i,s,a){const{bounds:n,shapeBounds:o}=a;if(e.fullImageShadow){if(Qe(Ze,t.bounds),Ze.x+=i.x-o.x,Ze.y+=i.y-o.y,s){const{fitMatrix:t}=a;Ze.x-=(n.x+(t?t.e:0)+n.width/2)*(s-1),Ze.y-=(n.y+(t?t.f:0)+n.height/2)*(s-1),Ze.width*=s,Ze.height*=s}t.copyWorld(a.canvas,t.bounds,Ze)}else s&&(Qe(Ze,i),Ze.x-=i.width/2*(s-1),Ze.y-=i.height/2*(s-1),Ze.width*=s,Ze.height*=s),t.copyWorld(a.canvas,o,s?Ze:i)}const{toOffsetOutBounds:ti}=k,ei={};const ii={shadow:function(t,e,i){let s,a;const{__nowWorld:n,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=r.length-1;Je(d,$e),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}p.setWorldShadow($e.offsetX+r.x*h*w,$e.offsetY+r.y*u*w,r.blur*h*w,X.string(r.color)),a=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*w:0,Ke(p,$e,a,i),s=d,r.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,d,n,"copy"),s=n),l?p.copyWorld(l,n,n,"destination-out"):p.copyWorld(i.canvas,c,d,"destination-out")),q.isTransformShadow(r)?q.renderTransformShadow(t,e,p,s,r):f.copyCanvasByWorld(t,e,p,s,r.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=r.length-1;ti(d,ei),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(ei.offsetX+r.x*h*w,ei.offsetY+r.y*u*w,r.blur*h*w),a=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*w:0,Ke(p,ei,a,i),p.restore(),l?(p.copyWorld(p,d,n,"copy"),p.copyWorld(l,n,n,"source-out"),s=n):(p.copyWorld(i.canvas,c,d,"source-out"),s=d),p.fillWorld(s,X.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,p,s,r.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowSpread:function(t,e){let i=0;return e.forEach(t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),i},isTransformShadow(t){}},{excludeRenderBounds:si}=g;let ai;function ni(t,e,i,s,a,n,o,r){switch(e){case"grayscale":ai||(ai=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),n&&s.recycle(o);ri(t,e,i,1,a,n)}(t,i,s,a,o,r);break;case"opacity-path":ri(t,i,s,n,o,r);break;case"path":r&&i.restore()}}function oi(t){return t.getSameCanvas(!1,!0)}function ri(t,e,i,s,a,n){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,a),n?i.recycle(o):i.clearWorld(o)}G.prototype.__renderMask=function(t,e){let i,s,a,n,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],r=i.__.mask,r){o&&(ni(this,o,t,a,s,n,void 0,!0),s=a=null),n=i.__.opacity,ai=!1,"path"===r||"clipping-path"===r?(n<1?(o="opacity-path",a||(a=oi(t))):(o="path",t.save()),i.__clip(a||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=oi(t)),a||(a=oi(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||si(i,e)||i.__render(t,e);continue}const c=1===n&&i.__.__blendMode;c&&ni(this,o,t,a,s,n,void 0,!1),si(i,e)||i.__render(a||t,e),c&&ni(this,o,t,a,s,n,c,!1)}ni(this,o,t,a,s,n,void 0,!0)};const li=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",di=li+"_#~&*+\\=|≮≯≈≠=…",ci=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 hi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ui=hi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),fi=hi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pi=hi(li),gi=hi(di),_i=hi("- —/~|┆·");var wi;!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"}(wi||(wi={}));const{Letter:yi,Single:mi,Before:vi,After:xi,Symbol:bi,Break:Si}=wi;function Bi(t){return ui[t]?yi:_i[t]?Si:fi[t]?vi:pi[t]?xi:gi[t]?bi:ci.test(t)?mi:yi}const ki={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 Ri(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:Ei}=ki,{Letter:Li,Single:Ai,Before:Ti,After:Ci,Symbol:Oi,Break:Mi}=wi;let Wi,Di,Pi,Fi,Ii,Ui,Yi,Xi,zi,Ni,qi,Gi,ji,Hi,Vi,Qi,Ji,Zi=[];function $i(t,e){zi&&!Xi&&(Xi=zi),Wi.data.push({char:t,width:e}),Pi+=e}function Ki(){Fi+=Pi,Wi.width=Pi,Di.words.push(Wi),Wi={data:[]},Pi=0}function ts(){Hi&&(Vi.paraNumber++,Di.paraStart=!0,Hi=!1),zi&&(Di.startCharSize=Xi,Di.endCharSize=zi,Xi=0),Di.width=Fi,Qi.width?Ei(Di):Ji&&es(),Zi.push(Di),Di={words:[]},Fi=0}function es(){Fi>(Vi.maxWidth||0)&&(Vi.maxWidth=Fi)}const{top:is,right:ss,bottom:as,left:ns}=P;function os(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 rs={getDrawData:function(t,i){L(t)||(t=String(t));let s=0,a=0,n=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(n?(s=d[ns],n-=d[ss]+d[ns]):i.autoSizeAlign||(s=d[ns]),o?(a=d[is],o-=d[is]+d[as]):i.autoSizeAlign||(a=d[is]));const c={bounds:{x:s,y:a,width:n,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Vi=t,Zi=t.rows,Qi=t.bounds,Ji=!Qi.width&&!s.autoSizeAlign;const{__letterSpacing:a,paraIndent:n,textCase:o}=s,{canvas:r}=e,{width:l,height:d}=Qi;if(l||d||a||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Hi=!0,qi=null,Xi=Yi=zi=Pi=Fi=0,Wi={data:[]},Di={words:[]},a&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Ui=i[s],"\n"===Ui?(Pi&&Ki(),Di.paraEnd=!0,ts(),Hi=!0):(Ni=Bi(Ui),Ni===Li&&"none"!==o&&(Ui=Ri(Ui,o,!Pi)),Yi=r.measureText(Ui).width,a&&(a<0&&(zi=Yi),Yi+=a),Gi=Ni===Ai&&(qi===Ai||qi===Li)||qi===Ai&&Ni!==Ci,ji=!(Ni!==Ti&&Ni!==Ai||qi!==Oi&&qi!==Ci),Ii=Hi&&n?l-n:l,t&&l&&Fi+Pi+Yi>Ii&&(e?(Pi&&Ki(),Fi&&ts()):(ji||(ji=Ni===Li&&qi==Ci),Gi||ji||Ni===Mi||Ni===Ti||Ni===Ai||Pi+Yi>Ii?(Pi&&Ki(),Fi&&ts()):Fi&&ts()))," "===Ui&&!0!==Hi&&Fi+Pi===0||(Ni===Mi?(" "===Ui&&Pi&&Ki(),$i(Ui,Yi),Ki()):Gi||ji?(Pi&&Ki(),$i(Ui,Yi)):$i(Ui,Yi)),qi=Ni);Pi&&Ki(),Fi&&ts(),Zi.length>0&&(Zi[Zi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Vi.paraNumber++,Fi=r.measureText(t).width,Zi.push({x:n||0,text:t,width:Fi,paraStart:!0}),Ji&&es()})}(c,t,i),d&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":os(e,"x",t[ns]);break;case"right":os(e,"x",-t[ss])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":os(e,"y",t[is]);break;case"bottom":os(e,"y",-t[as])}}(d,c,i,n,o),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=n*a+(h?h*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,n),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=a;o<c;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&o>0&&(y+=h),m.y=y,y+=n,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n,letterSpacing:o}=e;let r,l,d,c,h,u;s.forEach(t=>{t.words&&(d=n&&t.paraStart?n:0,u=t.words.length,l=i&&("justify"===a||"both"===a)&&u>1?(i-t.width-d)/(u-1):0,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==a||i===u-1||(r+=l,t.width+=l)})),t.words=null)})}(c,i,n),c.overflow&&function(t,i,s,a){if(!a)return;const{rows:n,overflow:o}=t;let{textOverflow:r}=i;if(n.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=s+a-d;("none"===i.textWrap?n:[n[o-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:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,i,s,n),"none"!==r&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,B(n)?(i=n.type,n.color&&(t.decorationColor=X.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]}}(c,i),c}};const ls={string:function(t,e){const i=F(e)&&e<1;if(L(t)){if(!i||!X.object)return t;t=X.object(t)}let s=E(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(j,rs),Object.assign(X,ls),Object.assign(Y,Nt),Object.assign(U,Ae),Object.assign(z,Ve),Object.assign(q,ii);const{setPoint:ds,addPoint:cs,toBounds:hs}=H;const us={syncExport(t,e,i){let s;N.running=!0;try{const a=Q.fileType(e),n=e.includes(".");i=Q.getExportOptions(i);const{toURL:o}=J,{download:r}=J.origin;if("json"===a)n&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!n||t.toJSON(i.json)};else if("svg"===a)n&&r(o(t.toSVG(),"svg"),e),s={data:!!n||t.toSVG()};else{let a,n,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=i,y=Z(i.smooth)?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&Z(i.fill)?t.fill:i.fill,x=Q.isOpaqueImage(e)||v,b=new $;if(g)a=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}a=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};K.getScaleData(i.scale,i.size,a,S);let B=i.pixelRatio||1,{x:k,y:R,width:E,height:L}=new V(a).scale(S.scaleX,S.scaleY);f&&(k+=f.x,R+=f.y,E=f.width,L=f.height);const A={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-k,-R).withScale(1/o*S.scaleX,1/r*S.scaleY)};let T,C=tt.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:B,smooth:y,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=c||t,A.bounds=C.bounds),C.save(),h&&!Z(v)){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let a,n,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=r%e,n=(r-a)/e,o?cs(o,a,n):ds(o={},a,n)),r++;const l=new V;return o&&(hs(o,l),l.scale(1/t.pixelRatio).ceil()),l}(C);const t=C,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:B};C=tt.canvas(s),C.copyWorld(t,n,s),t.destroy()}if(_){const[t,e,i,s]=K.fourNumber(_),a=C,{width:n,height:o}=a;C=tt.canvas({width:n+s+e,height:o+t+i,pixelRatio:B}),C.copyWorld(a,a.bounds,{x:s,y:t,width:n,height:o}),a.destroy()}x&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),w&&w(C);s={data:"canvas"===e?C:C.export(e,i),width:C.pixelWidth,height:C.pixelHeight,renderBounds:a,trimBounds:n};const O=c&&c.app;O&&O.canvasManager&&O.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return N.running=!1,s},export(t,e,i){return N.running=!0,function(t){fs||(fs=new et);return new Promise(e=>{fs.add(()=>rt(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(a=>{const n=()=>rt(this,void 0,void 0,function*(){if(!it.isComplete)return J.requestRender(n);const o=N.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),a()});t.updateLayout(),ps(t);const{leafer:o}=t;o?o.waitViewCompleted(n):n()}))}};let fs;function ps(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>ps(t))}const gs=st.prototype,_s=at.get("@leafer-in/export");gs.export=function(t,e){const{quality:i,blob:s}=Q.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},gs.toBlob=function(t,e){return new Promise(i=>{J.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{_s.error(t),i(null)})})},gs.toDataURL=function(t,e){return J.origin.canvasToDataURL(this.view,t,e)},gs.saveAs=function(t,e){return new Promise(i=>{J.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{_s.error(t),i(!1)})})},nt.add("export"),Object.assign(N,us),ot.prototype.export=function(t,e){return N.export(this,t,e)},ot.prototype.syncExport=function(t,e){return N.syncExport(this,t,e)};export{St as Layouter,lt as LeaferCanvas,kt as Renderer,ut as Watcher,ht as useCanvas};
2
2
  //# sourceMappingURL=node.esm.min.js.map