@leafer-draw/miniapp 2.2.6 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/miniapp.cjs CHANGED
@@ -304,6 +304,7 @@ class Watcher {
304
304
  }
305
305
  constructor(target, userConfig) {
306
306
  this.totalTimes = 0;
307
+ this.changed = 0;
307
308
  this.config = {};
308
309
  this.__updatedList = new core.LeafList;
309
310
  this.target = target;
@@ -323,8 +324,10 @@ class Watcher {
323
324
  this.disabled = true;
324
325
  }
325
326
  update() {
326
- this.changed = true;
327
- if (this.running) this.target.emit(core.RenderEvent.REQUEST);
327
+ if (this.changed < 100) {
328
+ this.changed++;
329
+ if (this.running) this.target.emit(core.RenderEvent.REQUEST);
330
+ }
328
331
  }
329
332
  __onAttrChange(event) {
330
333
  this.add(event.target);
@@ -333,18 +336,21 @@ class Watcher {
333
336
  if (this.config.usePartLayout) this.__updatedList.add(leaf);
334
337
  this.update();
335
338
  }
336
- __onChildEvent(event) {
339
+ addChild(child, parent, eventType) {
337
340
  if (this.config.usePartLayout) {
338
- if (event.type === core.ChildEvent.ADD) {
341
+ if (eventType === core.ChildEvent.ADD) {
339
342
  this.hasAdd = true;
340
- this.__pushChild(event.child);
343
+ this.__pushChild(child);
341
344
  } else {
342
345
  this.hasRemove = true;
343
- this.__updatedList.add(event.parent);
346
+ this.__updatedList.add(parent);
344
347
  }
345
348
  }
346
349
  this.update();
347
350
  }
351
+ __onChildEvent(event) {
352
+ this.addChild(event.child, event.parent, event.type);
353
+ }
348
354
  __pushChild(child) {
349
355
  this.__updatedList.add(child);
350
356
  if (child.isBranch) this.__loopChildren(child);
@@ -359,7 +365,8 @@ class Watcher {
359
365
  }));
360
366
  this.__updatedList = new core.LeafList;
361
367
  this.totalTimes++;
362
- this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
368
+ this.hasVisible = this.hasRemove = this.hasAdd = false;
369
+ this.changed = 0;
363
370
  }
364
371
  __listenEvents() {
365
372
  this.__eventIds = [ this.target.on_([ [ core.PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ core.ChildEvent.ADD, core.ChildEvent.REMOVE ], this.__onChildEvent, this ], [ core.WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
@@ -380,47 +387,57 @@ const {updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, update
380
387
 
381
388
  const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = core.BranchHelper;
382
389
 
383
- function updateMatrix(updateList, levelList) {
384
- let layout;
385
- updateList.list.forEach(leaf => {
386
- layout = leaf.__layout;
387
- if (levelList.without(leaf) && !layout.proxyZoom) {
388
- if (layout.matrixChanged) {
389
- updateAllMatrix$1(leaf, true);
390
- levelList.add(leaf);
391
- if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
392
- pushAllParent(leaf, levelList);
393
- } else if (layout.boundsChanged) {
394
- levelList.add(leaf);
395
- if (leaf.isBranch) leaf.__tempNumber = 0;
396
- pushAllParent(leaf, levelList);
390
+ const LayouterHelper = {
391
+ updateMatrix(updateList, levelList) {
392
+ let index = 0, leaf, layout;
393
+ const {list: list} = updateList;
394
+ while (index < list.length) {
395
+ leaf = list[index];
396
+ layout = leaf.__layout;
397
+ if (levelList.without(leaf) && !layout.proxyZoom) {
398
+ if (layout.matrixChanged) {
399
+ updateAllMatrix$1(leaf, true);
400
+ if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
401
+ push(leaf, levelList);
402
+ } else if (layout.boundsChanged) {
403
+ if (leaf.isBranch) leaf.__tempNumber = 0;
404
+ push(leaf, levelList);
405
+ }
397
406
  }
407
+ index++;
398
408
  }
399
- });
400
- }
401
-
402
- function updateBounds(boundsList) {
403
- let list, branch, children;
404
- boundsList.sort(true);
405
- boundsList.levels.forEach(level => {
406
- list = boundsList.levelMap[level];
407
- for (let i = 0, len = list.length; i < len; i++) {
408
- branch = list[i];
409
- if (branch.isBranch && branch.__tempNumber) {
410
- children = branch.children;
411
- for (let j = 0, jLen = children.length; j < jLen; j++) {
412
- if (!children[j].isBranch) {
413
- updateOneBounds(children[j]);
409
+ },
410
+ updateBounds(boundsList) {
411
+ let index = 0, level, list, branch, children;
412
+ const {levels: levels, levelMap: levelMap} = boundsList;
413
+ boundsList.sort(true);
414
+ while (index < levels.length) {
415
+ level = levels[index];
416
+ list = levelMap[level];
417
+ for (let i = 0, len = list.length; i < len; i++) {
418
+ branch = list[i];
419
+ if (branch.isBranch && branch.__tempNumber) {
420
+ children = branch.children;
421
+ for (let j = 0, jLen = children.length; j < jLen; j++) {
422
+ if (!children[j].isBranch) {
423
+ updateOneBounds(children[j]);
424
+ }
414
425
  }
415
426
  }
427
+ updateOneBounds(branch);
416
428
  }
417
- updateOneBounds(branch);
429
+ index++;
418
430
  }
419
- });
420
- }
431
+ },
432
+ updateChange(updateList) {
433
+ updateList.list.forEach(updateOneChange);
434
+ },
435
+ push: push
436
+ };
421
437
 
422
- function updateChange(updateList) {
423
- updateList.list.forEach(updateOneChange);
438
+ function push(leaf, levelList) {
439
+ levelList.add(leaf);
440
+ pushAllParent(leaf, levelList);
424
441
  }
425
442
 
426
443
  const {worldBounds: worldBounds} = core.LeafBoundsHelper;
@@ -527,9 +544,9 @@ class Layouter {
527
544
  target.emitEvent(new core.LayoutEvent(BEFORE, blocks, this.times));
528
545
  this.extraBlock = null;
529
546
  updateList.sort();
530
- updateMatrix(updateList, this.__levelList);
531
- updateBounds(this.__levelList);
532
- updateChange(updateList);
547
+ LayouterHelper.updateMatrix(updateList, this.__levelList);
548
+ LayouterHelper.updateBounds(this.__levelList);
549
+ LayouterHelper.updateChange(updateList);
533
550
  if (this.extraBlock) blocks.push(this.extraBlock);
534
551
  blocks.forEach(item => item.setAfter());
535
552
  target.emitEvent(new core.LayoutEvent(LAYOUT, blocks, this.times));
@@ -559,11 +576,16 @@ class Layouter {
559
576
  if (target.isBranch) core.BranchHelper.updateBounds(target); else core.LeafHelper.updateBounds(target);
560
577
  updateAllChange(target);
561
578
  }
562
- addExtra(leaf) {
579
+ addExtra(leaf, updateBounds) {
563
580
  if (!this.__updatedList.has(leaf)) {
564
581
  const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
565
582
  updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
566
583
  updatedList.add(leaf);
584
+ if (updateBounds) {
585
+ const list = this.__levelList;
586
+ LayouterHelper.push(leaf, list);
587
+ list.sort(true);
588
+ }
567
589
  }
568
590
  }
569
591
  createBlock(data) {
@@ -1285,7 +1307,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1285
1307
  data.__naturalHeight = image.height / data.pixelRatio;
1286
1308
  if (data.__autoSide) {
1287
1309
  ui.forceUpdate();
1288
- core.LeafHelper.updateBounds(ui);
1310
+ core.LeafHelper.updateBounds(ui, true);
1289
1311
  ui.__layout.boundsChanged = true;
1290
1312
  if (ui.__proxyData) {
1291
1313
  ui.setProxyAttr("width", data.width);
@@ -2616,6 +2638,8 @@ Object.defineProperty(exports, "LeaferVideo", {
2616
2638
 
2617
2639
  exports.Layouter = Layouter;
2618
2640
 
2641
+ exports.LayouterHelper = LayouterHelper;
2642
+
2619
2643
  exports.LeaferCanvas = LeaferCanvas;
2620
2644
 
2621
2645
  exports.Renderer = Renderer;
@@ -308,6 +308,7 @@ class Watcher {
308
308
  }
309
309
  constructor(target, userConfig) {
310
310
  this.totalTimes = 0;
311
+ this.changed = 0;
311
312
  this.config = {};
312
313
  this.__updatedList = new LeafList;
313
314
  this.target = target;
@@ -327,8 +328,10 @@ class Watcher {
327
328
  this.disabled = true;
328
329
  }
329
330
  update() {
330
- this.changed = true;
331
- if (this.running) this.target.emit(RenderEvent.REQUEST);
331
+ if (this.changed < 100) {
332
+ this.changed++;
333
+ if (this.running) this.target.emit(RenderEvent.REQUEST);
334
+ }
332
335
  }
333
336
  __onAttrChange(event) {
334
337
  this.add(event.target);
@@ -337,18 +340,21 @@ class Watcher {
337
340
  if (this.config.usePartLayout) this.__updatedList.add(leaf);
338
341
  this.update();
339
342
  }
340
- __onChildEvent(event) {
343
+ addChild(child, parent, eventType) {
341
344
  if (this.config.usePartLayout) {
342
- if (event.type === ChildEvent.ADD) {
345
+ if (eventType === ChildEvent.ADD) {
343
346
  this.hasAdd = true;
344
- this.__pushChild(event.child);
347
+ this.__pushChild(child);
345
348
  } else {
346
349
  this.hasRemove = true;
347
- this.__updatedList.add(event.parent);
350
+ this.__updatedList.add(parent);
348
351
  }
349
352
  }
350
353
  this.update();
351
354
  }
355
+ __onChildEvent(event) {
356
+ this.addChild(event.child, event.parent, event.type);
357
+ }
352
358
  __pushChild(child) {
353
359
  this.__updatedList.add(child);
354
360
  if (child.isBranch) this.__loopChildren(child);
@@ -363,7 +369,8 @@ class Watcher {
363
369
  }));
364
370
  this.__updatedList = new LeafList;
365
371
  this.totalTimes++;
366
- this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
372
+ this.hasVisible = this.hasRemove = this.hasAdd = false;
373
+ this.changed = 0;
367
374
  }
368
375
  __listenEvents() {
369
376
  this.__eventIds = [ this.target.on_([ [ PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ ChildEvent.ADD, ChildEvent.REMOVE ], this.__onChildEvent, this ], [ WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
@@ -384,47 +391,57 @@ const {updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, update
384
391
 
385
392
  const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = BranchHelper;
386
393
 
387
- function updateMatrix(updateList, levelList) {
388
- let layout;
389
- updateList.list.forEach(leaf => {
390
- layout = leaf.__layout;
391
- if (levelList.without(leaf) && !layout.proxyZoom) {
392
- if (layout.matrixChanged) {
393
- updateAllMatrix$1(leaf, true);
394
- levelList.add(leaf);
395
- if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
396
- pushAllParent(leaf, levelList);
397
- } else if (layout.boundsChanged) {
398
- levelList.add(leaf);
399
- if (leaf.isBranch) leaf.__tempNumber = 0;
400
- pushAllParent(leaf, levelList);
394
+ const LayouterHelper = {
395
+ updateMatrix(updateList, levelList) {
396
+ let index = 0, leaf, layout;
397
+ const {list: list} = updateList;
398
+ while (index < list.length) {
399
+ leaf = list[index];
400
+ layout = leaf.__layout;
401
+ if (levelList.without(leaf) && !layout.proxyZoom) {
402
+ if (layout.matrixChanged) {
403
+ updateAllMatrix$1(leaf, true);
404
+ if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
405
+ push(leaf, levelList);
406
+ } else if (layout.boundsChanged) {
407
+ if (leaf.isBranch) leaf.__tempNumber = 0;
408
+ push(leaf, levelList);
409
+ }
401
410
  }
411
+ index++;
402
412
  }
403
- });
404
- }
405
-
406
- function updateBounds(boundsList) {
407
- let list, branch, children;
408
- boundsList.sort(true);
409
- boundsList.levels.forEach(level => {
410
- list = boundsList.levelMap[level];
411
- for (let i = 0, len = list.length; i < len; i++) {
412
- branch = list[i];
413
- if (branch.isBranch && branch.__tempNumber) {
414
- children = branch.children;
415
- for (let j = 0, jLen = children.length; j < jLen; j++) {
416
- if (!children[j].isBranch) {
417
- updateOneBounds(children[j]);
413
+ },
414
+ updateBounds(boundsList) {
415
+ let index = 0, level, list, branch, children;
416
+ const {levels: levels, levelMap: levelMap} = boundsList;
417
+ boundsList.sort(true);
418
+ while (index < levels.length) {
419
+ level = levels[index];
420
+ list = levelMap[level];
421
+ for (let i = 0, len = list.length; i < len; i++) {
422
+ branch = list[i];
423
+ if (branch.isBranch && branch.__tempNumber) {
424
+ children = branch.children;
425
+ for (let j = 0, jLen = children.length; j < jLen; j++) {
426
+ if (!children[j].isBranch) {
427
+ updateOneBounds(children[j]);
428
+ }
418
429
  }
419
430
  }
431
+ updateOneBounds(branch);
420
432
  }
421
- updateOneBounds(branch);
433
+ index++;
422
434
  }
423
- });
424
- }
435
+ },
436
+ updateChange(updateList) {
437
+ updateList.list.forEach(updateOneChange);
438
+ },
439
+ push: push
440
+ };
425
441
 
426
- function updateChange(updateList) {
427
- updateList.list.forEach(updateOneChange);
442
+ function push(leaf, levelList) {
443
+ levelList.add(leaf);
444
+ pushAllParent(leaf, levelList);
428
445
  }
429
446
 
430
447
  const {worldBounds: worldBounds} = LeafBoundsHelper;
@@ -531,9 +548,9 @@ class Layouter {
531
548
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
532
549
  this.extraBlock = null;
533
550
  updateList.sort();
534
- updateMatrix(updateList, this.__levelList);
535
- updateBounds(this.__levelList);
536
- updateChange(updateList);
551
+ LayouterHelper.updateMatrix(updateList, this.__levelList);
552
+ LayouterHelper.updateBounds(this.__levelList);
553
+ LayouterHelper.updateChange(updateList);
537
554
  if (this.extraBlock) blocks.push(this.extraBlock);
538
555
  blocks.forEach(item => item.setAfter());
539
556
  target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
@@ -563,11 +580,16 @@ class Layouter {
563
580
  if (target.isBranch) BranchHelper.updateBounds(target); else LeafHelper.updateBounds(target);
564
581
  updateAllChange(target);
565
582
  }
566
- addExtra(leaf) {
583
+ addExtra(leaf, updateBounds) {
567
584
  if (!this.__updatedList.has(leaf)) {
568
585
  const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
569
586
  updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
570
587
  updatedList.add(leaf);
588
+ if (updateBounds) {
589
+ const list = this.__levelList;
590
+ LayouterHelper.push(leaf, list);
591
+ list.sort(true);
592
+ }
571
593
  }
572
594
  }
573
595
  createBlock(data) {
@@ -1289,7 +1311,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1289
1311
  data.__naturalHeight = image.height / data.pixelRatio;
1290
1312
  if (data.__autoSide) {
1291
1313
  ui.forceUpdate();
1292
- LeafHelper.updateBounds(ui);
1314
+ LeafHelper.updateBounds(ui, true);
1293
1315
  ui.__layout.boundsChanged = true;
1294
1316
  if (ui.__proxyData) {
1295
1317
  ui.setProxyAttr("width", data.width);
@@ -2597,4 +2619,4 @@ try {
2597
2619
  if (wx) useCanvas("miniapp", wx);
2598
2620
  } catch (_a) {}
2599
2621
 
2600
- export { Layouter, LeaferCanvas, PathNodeHandleType, Renderer, Watcher, useCanvas };
2622
+ export { Layouter, LayouterHelper, LeaferCanvas, PathNodeHandleType, Renderer, Watcher, useCanvas };
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as n,DataHelper as a,canvasSizeAttrs as r,isUndefined as o,ResizeEvent as l,Creator as c,LeaferImage as d,FileHelper as h,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as x,Bounds as v,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as E,isObject as T,BoundsHelper as L,FourNumberHelper as A,Matrix as P,ImageEvent as C,MatrixHelper as O,MathHelper as W,AlignHelper as M,PointHelper as D,getMatrixData as I,AroundHelper as F,OneRadian as z,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as Y,PaintImage as X,ColorConvert as q,PaintGradient as N,Effect as G,Group as j,TextConvert as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var H;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(H||(H={}));class Q extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:e,height:a,pixelRatio:r}=this.config,o={width:e||t.width,height:a||t.height,pixelRatio:r};this.resize(o),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,a){this.context.roundRect(t,e,i,n,s(a)?[a]:a)}),n(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,this.updateViewSize(),t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};a.copyAttrs(e,this,r),this.resize(t),o(this.width)||this.resizeListener(new l(t,e))}}function Z(t,e){i.origin={createCanvas:(t,i,s)=>{const n={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(n):e.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(h.mimeType(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(h.mimeType(h.fileType(e)),s);return n=n.substring(n.indexOf("64,")+3),i.origin.download(n,e)},download:(t,s)=>new Promise((n,a)=>{let r;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,r=!0);const o=e.getFileSystemManager();o.writeFile({filePath:s,data:t,encoding:"base64",success(){r?i.miniapp.saveToAlbum(s).then(()=>{o.unlink({filePath:s}),n()}):n()},fail(t){a(t)}})}),loadImage:(t,e,s)=>new Promise((e,s)=>{const n=i.getCanvas().view.createImage();n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),loadContent:(t,i="text")=>new Promise((s,n)=>e.request({url:t,responseType:"arrayBuffer"===i?"arraybuffer":"text",success:t=>s("json"===i&&"string"==typeof t.data?JSON.parse(t.data):t.data),fail:n})),noRepeat:"repeat-x"},i.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient,u(i,"devicePixelRatio",{get:()=>Math.max(1,e.getWindowInfo?e.getWindowInfo().pixelRatio:e.getSystemInfoSync().pixelRatio)})}Object.assign(c,{canvas:(t,e)=>new Q(t,e),image:t=>new d(t)}),i.name="miniapp",i.getCanvas=function(){const{renderCanvas:t}=i;return t&&t.view?t:i.canvas},i.requestRender=function(t){const{view:e}=i.getCanvas();e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)};class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new f;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 f,this.target=t,e&&(this.config=a.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(p.REQUEST)}__onAttrChange(t){this.add(t.target)}add(t){this.config.usePartLayout&&this.__updatedList.add(t),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===g.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 _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=m,{pushAllChildBranch:et,pushAllParent:it}=y;const{worldBounds:st}=x;class nt{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:at,updateAllChange:rt}=m,ot=b.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new k,this.target=t,e&&(this.config=a.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(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=B,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new B(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(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||K(s[t])}K(i)}})}(this.__levelList),function(t){t.list.forEach(tt)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new B(a,o,this.times)),i.emitEvent(new B(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),lt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),R.end(t)}static fullLayout(t){at(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(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_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=b.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=a.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,ct.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new v,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.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=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new v(s);i.save(),s.spread(dt.clipSpread).ceil();const{ceilPartPixel:a}=this.config;i.clipWorld(s,a),i.clearWorld(s,a),this.__render(s,n),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:s,target:n}=this,a=t.includes(n.__world),r=a?{includes:a}:{bounds:t,includes:a};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),i.render(n,s,r),this.renderBounds=e=e||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(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 v(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[l.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 ht(t,e,i){t.__.__font?Y.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ut(t,e,i,s,n){const a=i.__;T(t)?Y.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),s.stroke()),a.__useArrow&&Y.strokeArrow(t,i,s,n)}function ft(t,e,i,s,n){const a=i.__;T(t)?Y.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),Y.drawTextStroke(i,s,n))}function pt(t,e,i,s,n){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,ft(t,2,i,a,n),a.blendMode="outside"===e?"destination-out":"destination-in",Y.fillText(i,a,n),a.blendMode="normal",m.copyCanvasByWorld(i,s,a),a.recycle(i.__nowWorld)}dt.clipSpread=10,Object.assign(c,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=lt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:gt,copyAndSpread:_t,toOuterOf:wt,getOuterOf:mt,getByMove:yt,move:xt,getIntersectData:vt}=L,St={};let bt;const{stintSet:kt}=a,{hasTransparent:Bt}=q;function Rt(t,i,s){if(!T(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout,{type:r}=i;switch(r){case"image":case"film":case"video":if(!i.url)return;n=X.image(s,t,i,a,!bt||!bt[i.url]),"image"!==r&&X[r](n);break;case"linear":n=N.linearGradient(i,a);break;case"radial":n=N.radialGradient(i,a);break;case"angular":n=N.conicGradient(i,a);break;case"solid":const{color:e,opacity:l}=i;n={type:r,style:q.string(e,l)};break;default:o(i.r)||(n={type:"solid",style:q.string(i)})}if(n&&(n.originPaint=i,e(n.style)&&Bt(n.style)&&(n.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}return n}const Et={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];S(o)||(o=[o]),bt=X.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Rt(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));s.length?(i["_"+t]=s,s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",n),kt(i,"__isTransparentFill",a)):(kt(i,"__isAlphaPixelStroke",n),kt(i,"__isTransparentStroke",a),kt(i,"__hasMultiStrokeStyle",r))):(i.__removePaint(t,!1),i["_"+t]="")},fill:function(t,e,i,s){i.fillStyle=t,ht(e,i,s)},fills:function(t,e,i,s){let n,a,r;for(let o=0,l=t.length;o<l;o++){if(n=t[o],a=n.originPaint,n.image){if(r?r++:r=1,X.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===r&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||a.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),a.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0,a.scaleFixed,!1);1!==t&&i.scale(t,s)}a.blendMode&&(i.blendMode=a.blendMode),ht(e,i,s),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),ht(e,i,s),i.restoreBlendMode()):ht(e,i,s)}},fillPathOrText:ht,fillText:function(t,e,i){if(t.motionText)return Y.fillMotionText(t,e,i);const s=t.__,{rows:n,decorationY:a}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>a.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)Y.strokeText(t,e,i,s);else if(n.__pathForStroke)Y.fillStroke(t,e,i,s);else switch(n.strokeAlign){case"center":ut(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),ut(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)ut(t,2,e,i,s);else{const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),ut(t,2,e,r,s),r.clipUI(n),r.clearWorld(a),m.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Y.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":ft(t,1,e,i,s);break;case"inside":pt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?ft(t,2,e,i,s):pt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:a,decorationY:r}=n;for(let t=0,i=a.length;t<i;t++)s=a[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=n;a.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||n.setStroke(void 0,o.__strokeWidth*e,o);for(let c=0,d=t.length;c<d;c++)if(r=t[c],(!r.image||!X.checkImage(r,!1,s,n,a))&&r.style){if(l){const{strokeStyle:t}=r;t?n.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(r.style,o.__strokeWidth*e,o)}else n.strokeStyle=r.style;r.originPaint.blendMode?(n.saveBlendMode(r.originPaint.blendMode),i?Y.drawTextStroke(s,n,a):n.stroke(),n.restoreBlendMode()):i?Y.drawTextStroke(s,n,a):n.stroke()}},shape:function(t,e,s){const n=e.getSameCanvas(),a=e.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let c,d,h,u,f,p;wt(o.strokeSpread?(_t(St,o.boxBounds,o.strokeSpread),St):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,c=f=l,d=r;else{let n;if(i.fullImageShadow)n=l;else{const t=o.renderShapeSpread?gt(a,A.swapAndScale(o.renderShapeSpread,g,_)):a;n=vt(t,l)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=mt(l,u),c=yt(f,-u.e,-u.f),d=mt(r,u),xt(d,-u.e,-u.f);const y=s.matrix;y?(h=new P(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:u,bounds:c,renderBounds:d,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Tt,Lt=new v;const{isSame:At}=L;function Pt(t,e,i,s,n,a){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=s.width/o.pixelRatio,o.__naturalHeight=s.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate(),m.updateBounds(t),t.__layout.boundsChanged=!0,t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),"brush"===i.mode&&X.brush(t,e,n),!n.data){X.createData(n,s,i,a);const{transform:t}=n.data,{opacity:e}=i,r=(t&&!t.onlyScale||o.path||o.cornerRadius)&&!n.brush;(r||e&&e<1||i.blendMode)&&(n.complex=!r||2)}return i.filter&&X.applyFilter(n,s,i.filter,t),r}function Ct(t,e){Mt(t,C.LOAD,e)}function Ot(t,e){Mt(t,C.LOADED,e)}function Wt(t,e,i){e.error=i,t.forceUpdate("surface"),Mt(t,C.ERROR,e)}function Mt(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function Dt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:It,translate:Ft}=O,zt=new v,Ut={},Yt={};function Xt(t,i,s,n){const a=e(t)||n?(n?s-n*i:s%i)/((n||Math.floor(s/i))-1):t;return"auto"===t&&a<0?0:a}let qt={},Nt=I();const{get:Gt,set:jt,rotateOfOuter:Vt,translate:Ht,scaleOfOuter:Qt,multiplyParent:Zt,scale:$t,rotate:Jt,skew:Kt}=O;function te(t,e,i,s,n,a,r,o){r&&Jt(t,r),o&&Kt(t,o.x,o.y),n&&$t(t,n,a),Ht(t,e.x+i,e.y+s)}function ee(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(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(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ie,scale:se,copy:ne}=O,{getFloorScale:ae}=W,{abs:re}=Math;const oe={image:function(t,e,i,s,n){let a,r;const o=E.get(i,i.type);return Tt&&i===Tt.paint&&At(s,Tt.boxBounds)?a=Tt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Tt=o.use>1?{leafPaint:a,paint:i,boxBounds:Lt.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Pt(t,e,i,o,a,s),n&&(Ct(t,r),Ot(t,r))):o.error?n&&Wt(t,r,o.error):(n&&(Dt(t,!0),Ct(t,r)),a.loadId=o.load(()=>{Dt(t,!1),t.destroyed||(Pt(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ot(t,r)),a.loadId=void 0},e=>{Dt(t,!1),Wt(t,r,e),a.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,e,s,n,a){const{scaleX:r,scaleY:o}=X.getImageRenderScaleData(t,s,n,a),l=t.film?t.nowIndex:r+"-"+o,{image:c,brush:d,data:h,originPaint:u}=t,{exporting:f,snapshot:p}=a;if(!h||t.patternId===l&&!f||p){if(!d||!t.style)return!1}else if(e&&(h.repeat?e=!1:u.changeful||t.film||"miniapp"===i.name||f||(e=i.image.isLarge(c,r,o)||c.width*r>8096||c.height*o>8096)),e)s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill());else if(!t.style||u.sync||f?X.createPattern(t,s,n,a):X.createPatternTask(t,s,n,a),!d||!t.style)return!1;return X.drawImage(t,r,o,s,n,a),!0},drawImage:function(t,e,i,s,n,a){const{data:r,image:o,brush:l,complex:c}=t;let{width:d,height:h}=o,u=l||o;if(c){const{blendMode:a,opacity:o}=t.originPaint,{transform:l}=r;n.save(),2===c&&n.clipUI(s),a&&(n.blendMode=a),o&&(n.opacity*=o),l&&n.transform(l),u.render(n,0,0,d,h,s,t,e,i),n.restore()}else r.scaleX&&(d*=r.scaleX,h*=r.scaleY),u.render(n,0,0,d,h,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:a}=t;if(t.brush&&X.addBrushScale(n,t,e),i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return a&&a.scaleX&&(n.scaleX*=Math.abs(a.scaleX),n.scaleY*=Math.abs(a.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(S(i)){let s,n,a,r,o;const l=e.__leaf;for(let c=0,d=i.length;c<d;c++)s=i[c],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,E.recyclePaint(s),s.brush&&X.recycleBrush(s,l),e.__willDestroy&&n.parent&&X.recycleFilter(n,l),n.loading&&(r||(r=e.__input&&e.__input[t]||[],S(r)||(r=[r])),n.unload(i[c].loadId,!r.some(t=>t.url===o))));return a}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=E.patternTasker.add(()=>ee(this,void 0,void 0,function*(){X.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,s,n){let{scaleX:a,scaleY:r}=X.getImageRenderScaleData(t,e,s,n),o=t.film?t.nowIndex:a+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!i.image.isLarge(t.image,a,r)||t.data.repeat)){const{image:l,brush:c,data:d}=t,{transform:h,gap:u}=d,f=X.getPatternFixScale(t,a,r);let p,g,_,{width:w,height:m}=l,{opacity:y}=t.originPaint;(c||1===y)&&(y=void 0),f&&(a*=f,r*=f),w*=a,m*=r,u&&!c&&(g=u.x*a/re(d.scaleX||1),_=u.y*r/re(d.scaleY||1)),(h||1!==a||1!==r)&&(a*=ae(w+(g||0)),r*=ae(m+(_||0)),p=ie(),h&&ne(p,h),se(p,1/a,1/r));const x=l.getCanvas(w,m,y,void 0,g,_,e.leafer&&e.leafer.config.smooth,d.interlace);c?(t.style=x,X.cacheBrush(t,e,s,n)):t.style=l.getPattern(x,d.repeat||i.origin.noRepeat||"no-repeat",p,t),t.patternId=o}},getPatternFixScale:function(t,e,s){const{image:n}=t;let a,r=i.image.maxPatternSize,o=n.width*n.height;return n.isSVG?e>1&&(a=Math.ceil(e)/e):r>o&&(r=o),(o*=e*s)>r&&(a=Math.sqrt(r/o)),a},createData:function(t,e,i,s){t.data=X.getPatternData(i,s,e)},getPatternData:function(t,i,n){t.padding&&(i=zt.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:r}=n,{mode:o,align:l,offset:c,scale:d,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,interlace:w}=t,m=i.width===a&&i.height===r,y={mode:o},x="center"!==l&&(u||0)%180==90;let v,S;switch(L.set(Yt,0,0,x?r:a,x?a:r),o&&"cover"!==o&&"fit"!==o?((d||h)&&(W.getScaleData(d,h,n,Ut),v=Ut.scaleX,S=Ut.scaleY),(l||_||g)&&(v&&L.scale(Yt,v,S,!0),l&&M.toPoint(l,Yt,i,Yt,!0,!0))):m&&!u||(v=S=L.getFitScale(i,Yt,"fit"!==o),L.put(i,n,l,v,!1,Yt),L.scale(Yt,v,S,!0)),c&&D.move(Yt,c),o){case"stretch":m?v&&(v=S=void 0):(v=i.width/a,S=i.height/r,X.stretchMode(y,i,v,S));break;case"normal":case"clip":if(Yt.x||Yt.y||v||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),X.clipMode(y,i,Yt.x,Yt.y,v,S,u,f,t,e),t&&(v=v?v*t:t,S=S?S*e:e)}break;case"repeat":(!m||v||u||f)&&X.repeatMode(y,i,a,r,Yt.x,Yt.y,v,S,u,f,l,t.freeTransform);case"brush":g||(y.repeat="repeat");const e=T(g);(_||e)&&(y.gap=function(t,e,i,s,n){let a,r;T(t)?(a=t.x,r=t.y):a=r=t;return{x:Xt(a,i,n.width,e&&e.x),y:Xt(r,s,n.height,e&&e.y)}}(_,e&&g,Yt.width,Yt.height,i));break;default:v&&X.fillOrFitMode(y,i,Yt.x,Yt.y,v,S,u)}return y.transform||"brush"===o||(i.x||i.y)&&Ft(y.transform=It(),i.x,i.y),v&&(y.scaleX=v,y.scaleY=S),g&&(y.repeat=e(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w&&(y.interlace=s(w)||"percent"===w.type?{type:"x",offset:w}:w),y},stretchMode:function(t,e,i,s){const n=Gt(),{x:a,y:r}=e;a||r?Ht(n,a,r):i>0&&s>0&&(n.onlyScale=!0),$t(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,a,r){const o=Gt();Ht(o,e.x+i,e.y+s),$t(o,n,a),r&&Vt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,n,a,r,o,l,c){const d=Gt();te(d,e,i,s,n,a,r,o),l&&(r||o?(jt(Nt),Qt(Nt,e,l,c),Zt(d,Nt)):Qt(d,e,l,c)),t.transform=d},repeatMode:function(t,e,i,s,n,a,r,o,l,c,d,h){const u=Gt();if(h)te(u,e,n,a,r,o,l,c);else{if(l)if("center"===d)Vt(u,{x:i/2,y:s/2},l);else switch(Jt(u,l),l){case 90:Ht(u,s,0);break;case 180:Ht(u,i,s);break;case 270:Ht(u,0,i)}qt.x=e.x+n,qt.y=e.y+a,Ht(u,qt.x,qt.y),r&&Qt(u,qt,r,o)}t.transform=u}},{toPoint:le}=F,{hasTransparent:ce}=q,de={},he={};function ue(t,i,s,n){if(s){let a,r,o,l;for(let t=0,c=s.length;t<c;t++)a=s[t],e(a)?(o=t/(c-1),r=q.string(a,n)):(o=a.offset,r=q.string(a.color,n)),i.addColorStop(o,r),!l&&ce(r)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:fe,getDistance:pe}=D,{get:ge,rotateOfOuter:_e,scaleOfOuter:we}=O,{toPoint:me}=F,ye={},xe={};function ve(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=fe(e,i);a=ge(),n?(we(a,e,r/o*(s||1),1),_e(a,e,t+90)):(we(a,e,1,r/o*(s||1)),_e(a,e,t))}return a}const{getDistance:Se}=D,{toPoint:be}=F,ke={},Be={};const Re={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:r}=t;le(s||"top",e,de),le(n||"bottom",e,he);const o=i.canvas.createLinearGradient(de.x,de.y,he.x,he.y),l={type:a,style:o};return ue(l,o,t.stops,r),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;me(s||"center",e,ye),me(n||"bottom",e,xe);const l=i.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,pe(ye,xe)),c={type:a,style:l};ue(c,l,t.stops,r);const d=ve(e,ye,xe,o,!0);return d&&(c.transform=d),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:r,rotation:o,stretch:l}=t;be(s||"center",e,ke),be(n||"bottom",e,Be);const c=i.conicGradientSupport?i.canvas.createConicGradient(o?o*z:0,ke.x,ke.y):i.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Se(ke,Be)),d={type:a,style:c};ue(d,c,t.stops,r);const h=ve(e,ke,Be,l||1,i.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:ve},{copy:Ee,move:Te,toOffsetOutBounds:Le}=L,{max:Ae,abs:Pe}=Math,Ce={},Oe=new P,We={};function Me(t,e){let i,s,n,a,r=0,o=0,l=0,c=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,a=1.5*(t.blur||0),n=Pe(t.spread||0),r=Ae(r,n+a-s),o=Ae(o,n+a+i),l=Ae(l,n+a+s),c=Ae(c,n+a-i)}),r===o&&o===l&&l===c?r:[r,o,l,c]}function De(t,e,s){const{shapeBounds:n}=s;let a,r;i.fullImageShadow?(Ee(Ce,t.bounds),Te(Ce,e.x-n.x,e.y-n.y),a=t.bounds,r=Ce):(a=n,r=e),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:Ie}=L,Fe={};const ze=Me;const Ue={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Le(l,We,c),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(We.offsetX+(r.x||0)*h*_,We.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_,q.string(r.color)),n=G.getShadowTransform(t,f,i,r,We,_),n&&f.setTransform(n),De(f,We,i),n&&f.resetTransform(),s=c,r.box&&(f.restore(),f.save(),o&&(f.copyWorld(f,c,a,"copy"),s=a),o?f.copyWorld(o,a,a,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ie(l,Fe,c),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Fe.offsetX+(r.x||0)*h*_,Fe.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_),n=G.getShadowTransform(t,f,i,r,Fe,_,!0),n&&f.setTransform(n),De(f,Fe,i),f.restore(),o?(f.copyWorld(f,c,a,"copy"),f.copyWorld(o,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,d,l,"source-out"),s=c),f.fillWorld(s,q.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Me,getShadowTransform:function(t,e,i,s,n,a,r){if(s.spread){const i=2*s.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Oe.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/o,1+i/l),Oe}},isTransformShadow(t){},getInnerShadowSpread:ze},{excludeRenderBounds:Ye}=x;let Xe;function qe(t,e,i,s,n,a,r,o){switch(e){case"grayscale":Xe||(Xe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);Ge(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":Ge(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function Ge(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}j.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let c=0,d=l.length;c<d;c++){if(i=l[c],o=i.__.mask,o){r&&(qe(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||Ye(i,e)||i.__render(t,e),a=i.__.opacity,Xe=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Ne(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ne(t)),n||(n=Ne(t)),i.__render(s,e));continue}const d=1===a&&i.__.__blendMode;d&&qe(this,r,t,n,s,a,void 0,!1),Ye(i,e)||i.__render(n||t,e),d&&qe(this,r,t,n,s,a,d,!1)}qe(this,r,t,n,s,a,void 0,!0)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=je+"_#~&*+\\=|≮≯≈≠=…",He=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 Qe(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Ze=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Je=Qe(je),Ke=Qe(Ve),ti=Qe("- —/~|┆·");var ei;!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"}(ei||(ei={}));const{Letter:ii,Single:si,Before:ni,After:ai,Symbol:ri,Break:oi}=ei;function li(t){return Ze[t]?ii:ti[t]?oi:$e[t]?ni:Je[t]?ai:Ke[t]?ri:He.test(t)?si:ii}const ci={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 di(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:hi}=ci,{Letter:ui,Single:fi,Before:pi,After:gi,Symbol:_i,Break:wi}=ei;let mi,yi,xi,vi,Si,bi,ki,Bi,Ri,Ei,Ti,Li,Ai,Pi,Ci,Oi,Wi,Mi=[];function Di(t,e){Ri&&!Bi&&(Bi=Ri),mi.data.push({char:t,width:e}),xi+=e}function Ii(){vi+=xi,mi.width=xi,yi.words.push(mi),mi={data:[]},xi=0}function Fi(){Pi&&(Ci.paraNumber++,yi.paraStart=!0,Pi=!1),Ri&&(yi.startCharSize=Bi,yi.endCharSize=Ri,Bi=0),yi.width=vi,Oi.width?hi(yi):Wi&&zi(),Mi.push(yi),yi={words:[]},vi=0}function zi(){vi>(Ci.maxWidth||0)&&(Ci.maxWidth=vi)}const{top:Ui,right:Yi,bottom:Xi,left:qi}=U;function Ni(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 Gi={getDrawData:function(t,s){e(t)||(t=String(t));let n=0,a=0,r=s.__getInput("width")||0,o=s.__getInput("height")||0;const{__padding:l}=s;s.motionText&&(r=o=0),l&&(r?(n=l[qi],r-=l[Yi]+l[qi],!r&&(r=.01)):s.autoSizeAlign||(n=l[qi]),o?(a=l[Ui],o-=l[Ui]+l[Xi],!o&&(o=.01)):s.autoSizeAlign||(a=l[Ui]));const c={bounds:{x:n,y:a,width:r,height:o},rows:[],paraNumber:0,font:i.canvas.font=s.__font};return function(t,e,s){Ci=t,Mi=t.rows,Oi=t.bounds,Wi=!Oi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=i,{width:l}=Oi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Pi=!0,Ti=null,Bi=ki=Ri=xi=vi=0,mi={data:[]},yi={words:[]};for(let s=0,c=(e=[...e]).length;s<c;s++)bi=e[s],"\n"===bi?(xi&&Ii(),yi.paraEnd=!0,Fi(),Pi=!0):(Ei=li(bi),Ei===ui&&"none"!==r&&(bi=di(bi,r,!xi)),ki=o.measureText(bi).width,n&&(n<0&&(Ri=ki),ki+=n),Li=Ei===fi&&(Ti===fi||Ti===ui)||Ti===fi&&Ei!==gi,Ai=!(Ei!==pi&&Ei!==fi||Ti!==_i&&Ti!==gi),Si=Pi&&a?l-a:l,t&&l&&vi+xi+ki>Si&&(i?(xi&&Ii(),vi&&Fi()):(Ai||(Ai=Ei===ui&&Ti==gi),Li||Ai||Ei===wi||Ei===pi||Ei===fi||xi+ki>Si?(xi&&Ii(),vi&&Fi()):vi&&Fi()))," "===bi&&!0!==Pi&&vi+xi===0||(Ei===wi?(" "===bi&&xi&&Ii(),Di(bi,ki),Ii()):Li||Ai?(xi&&Ii(),Di(bi,ki)):Di(bi,ki)),Ti=Ei);xi&&Ii(),vi&&Fi(),Mi.length>0&&(Mi[Mi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Ci.paraNumber++,vi=o.measureText(t).width,Mi.push({x:a||0,text:t,width:vi,paraStart:!0}),Wi&&zi()})}(c,t,s),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ni(e,"x",t[qi]);break;case"right":Ni(e,"x",-t[Yi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ni(e,"y",t[Ui]);break;case"bottom":Ni(e,"y",-t[Xi])}}(l,c,s,r,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:c,verticalAlign:d,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(e.__autoHeight?w:_,a),n>1&&(t.overflow=n);else if(_||u)switch(d){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,S=g||u?g:t.maxWidth;for(let r=0,d=n;r<d;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(c){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=a,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,s),s.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a}=e,r=e.__letterSpacing||e.motionText,o=i&&n.includes("both"),l=o||i&&n.includes("justify"),c=l&&n.includes("letter");let d,h,u,f,p,g,_,w,m,y;s.forEach(t=>{t.words&&(p=a&&t.paraStart?a:0,w=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-p,c?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=r||t.isOverflow||c?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(_={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):d=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,d,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(d+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(c,s,r),c.overflow&&function(t,e,s,n){const{rows:a,overflow:r}=t;let{textOverflow:o}=e;if(r&&a.splice(r),n&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const c=o?i.canvas.measureText(o).width:0,d=s+n-c;("none"===e.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<d));s--){if(l<d&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=c,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,s,n,r),"none"!==s.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,T(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,s),c}};const ji={string:function(t,i){if(!t)return"#000";const n=s(i)&&i<1;if(e(t)){if(!n||!q.object)return t;t=q.object(t)}let a=o(t.a)?1:t.a;n&&(a*=i);const r=t.r+","+t.g+","+t.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(V,Gi),Object.assign(q,ji),Object.assign(Y,Et),Object.assign(X,oe),Object.assign(N,Re),Object.assign(G,Ue);try{wx&&Z(0,wx)}catch(t){}export{lt as Layouter,Q as LeaferCanvas,H as PathNodeHandleType,dt as Renderer,$ as Watcher,Z as useCanvas};
1
+ import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as a,DataHelper as n,canvasSizeAttrs as r,isUndefined as o,ResizeEvent as l,Creator as d,LeaferImage as c,FileHelper as h,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as x,Bounds as v,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as E,isObject as L,BoundsHelper as T,FourNumberHelper as A,Matrix as P,ImageEvent as C,MatrixHelper as O,MathHelper as W,AlignHelper as M,PointHelper as D,getMatrixData as I,AroundHelper as F,OneRadian as z,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as Y,PaintImage as X,ColorConvert as q,PaintGradient as N,Effect as G,Group as j,TextConvert as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var H;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(H||(H={}));class Q extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:e,height:n,pixelRatio:r}=this.config,o={width:e||t.width,height:n||t.height,pixelRatio:r};this.resize(o),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,a,n){this.context.roundRect(t,e,i,a,s(n)?[n]:n)}),a(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,this.updateViewSize(),t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,r),this.resize(t),o(this.width)||this.resizeListener(new l(t,e))}}function Z(t,e){i.origin={createCanvas:(t,i,s)=>{const a={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(a):e.createOffScreenCanvas(a)},canvasToDataURL:(t,e,i)=>t.toDataURL(h.mimeType(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let a=t.toDataURL(h.mimeType(h.fileType(e)),s);return a=a.substring(a.indexOf("64,")+3),i.origin.download(a,e)},download:(t,s)=>new Promise((a,n)=>{let r;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,r=!0);const o=e.getFileSystemManager();o.writeFile({filePath:s,data:t,encoding:"base64",success(){r?i.miniapp.saveToAlbum(s).then(()=>{o.unlink({filePath:s}),a()}):a()},fail(t){n(t)}})}),loadImage:(t,e,s)=>new Promise((e,s)=>{const a=i.getCanvas().view.createImage();a.onload=()=>{e(a)},a.onerror=t=>{s(t)},a.src=i.image.getRealURL(t)}),loadContent:(t,i="text")=>new Promise((s,a)=>e.request({url:t,responseType:"arrayBuffer"===i?"arraybuffer":"text",success:t=>s("json"===i&&"string"==typeof t.data?JSON.parse(t.data):t.data),fail:a})),noRepeat:"repeat-x"},i.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=d.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient,u(i,"devicePixelRatio",{get:()=>Math.max(1,e.getWindowInfo?e.getWindowInfo().pixelRatio:e.getSystemInfoSync().pixelRatio)})}Object.assign(d,{canvas:(t,e)=>new Q(t,e),image:t=>new c(t)}),i.name="miniapp",i.getCanvas=function(){const{renderCanvas:t}=i;return t&&t.view?t:i.canvas},i.requestRender=function(t){const{view:e}=i.getCanvas();e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)};class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.changed=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed<100&&(this.changed++,this.running&&this.target.emit(p.REQUEST))}__onAttrChange(t){this.add(t.target)}add(t){this.config.usePartLayout&&this.__updatedList.add(t),this.update()}addChild(t,e,i){this.config.usePartLayout&&(i===g.ADD?(this.hasAdd=!0,this.__pushChild(t)):(this.hasRemove=!0,this.__updatedList.add(e))),this.update()}__onChildEvent(t){this.addChild(t.child,t.parent,t.type)}__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 _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.hasVisible=this.hasRemove=this.hasAdd=!1,this.changed=0}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=m,{pushAllChildBranch:et,pushAllParent:it}=y,st={updateMatrix(t,e){let i,s,a=0;const{list:n}=t;for(;a<n.length;)i=n[a],s=i.__layout,e.without(i)&&!s.proxyZoom&&(s.matrixChanged?(J(i,!0),i.isBranch&&et(i,e),at(i,e)):s.boundsChanged&&(i.isBranch&&(i.__tempNumber=0),at(i,e))),a++},updateBounds(t){let e,i,s,a,n=0;const{levels:r,levelMap:o}=t;for(t.sort(!0);n<r.length;){e=r[n],i=o[e];for(let t=0,e=i.length;t<e;t++){if(s=i[t],s.isBranch&&s.__tempNumber){a=s.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||K(a[t])}K(s)}n++}},updateChange(t){t.list.forEach(tt)},push:at};function at(t,e){e.add(t),it(t,e)}const{worldBounds:nt}=x;class rt{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,nt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,nt),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:ot,updateAllChange:lt}=m,dt=b.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new k,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:r}=B,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new B(a,o,this.times)),this.extraBlock=null,s.sort(),st.updateMatrix(s,this.__levelList),st.updateBounds(this.__levelList),st.updateChange(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new B(n,o,this.times)),i.emitEvent(new B(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=B,n=this.getBlocks(new f(e));e.emitEvent(new B(i,n,this.times)),ct.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,n,this.times)),e.emitEvent(new B(a,n,this.times)),this.addBlocks(n),R.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),lt(t)}addExtra(t,e){if(!this.__updatedList.has(t)){const{updatedList:i,beforeBounds:s}=this.extraBlock||(this.extraBlock=new rt([]));if(i.length?s.add(t.__world):s.set(t.__world),i.add(t),e){const e=this.__levelList;st.push(t,e),e.sort(!0)}}}createBlock(t){return new rt(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_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=b.get("Renderer");class ut{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=n.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,ht.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new v,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.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=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),a=new v(s);i.save(),s.spread(ut.clipSpread).ceil();const{ceilPartPixel:n}=this.config;i.clipWorld(s,n),i.clearWorld(s,n),this.__render(s,a),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:s,target:a}=this,n=t.includes(a.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),i.render(a,s,r),this.renderBounds=e=e||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:a}=this;a.length>30&&a.shift(),a.push(t),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(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 v(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ht.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[l.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 ft(t,e,i){t.__.__font?Y.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function pt(t,e,i,s,a){const n=i.__;L(t)?Y.drawStrokesStyle(t,e,!1,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&Y.strokeArrow(t,i,s,a)}function gt(t,e,i,s,a){const n=i.__;L(t)?Y.drawStrokesStyle(t,e,!0,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),Y.drawTextStroke(i,s,a))}function _t(t,e,i,s,a){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,gt(t,2,i,n,a),n.blendMode="outside"===e?"destination-out":"destination-in",Y.fillText(i,n,a),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}ut.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=ct.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:wt,copyAndSpread:mt,toOuterOf:yt,getOuterOf:xt,getByMove:vt,move:St,getIntersectData:bt}=T,kt={};let Bt;const{stintSet:Rt}=n,{hasTransparent:Et}=q;function Lt(t,i,s){if(!L(i)||!1===i.visible||0===i.opacity)return;let a;const{boxBounds:n}=s.__layout,{type:r}=i;switch(r){case"image":case"film":case"video":if(!i.url)return;a=X.image(s,t,i,n,!Bt||!Bt[i.url]),"image"!==r&&X[r](a);break;case"linear":a=N.linearGradient(i,n);break;case"radial":a=N.radialGradient(i,n);break;case"angular":a=N.conicGradient(i,n);break;case"solid":const{color:e,opacity:l}=i;a={type:r,style:q.string(e,l)};break;default:o(i.r)||(a={type:"solid",style:q.string(i)})}if(a&&(a.originPaint=i,e(a.style)&&Et(a.style)&&(a.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;a.strokeStyle=i.style}return a}const Tt={compute:function(t,e){const i=e.__,s=[];let a,n,r,o=i.__input[t];S(o)||(o=[o]),Bt=X.recycleImage(t,i);for(let i,a=0,n=o.length;a<n;a++)(i=Lt(t,o[a],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));s.length?(i["_"+t]=s,s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(a=!0),n=!0),"fill"===t?(Rt(i,"__isAlphaPixelFill",a),Rt(i,"__isTransparentFill",n)):(Rt(i,"__isAlphaPixelStroke",a),Rt(i,"__isTransparentStroke",n),Rt(i,"__hasMultiStrokeStyle",r))):(i.__removePaint(t,!1),i["_"+t]="")},fill:function(t,e,i,s){i.fillStyle=t,ft(e,i,s)},fills:function(t,e,i,s){let a,n,r;for(let o=0,l=t.length;o<l;o++){if(a=t[o],n=a.originPaint,a.image){if(r?r++:r=1,X.checkImage(a,!e.__.__font,e,i,s))continue;if(!a.style){1===r&&a.image.isPlacehold&&e.drawImagePlaceholder(a,i,s);continue}}if(i.fillStyle=a.style,a.transform||n.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0,n.scaleFixed,!1);1!==t&&i.scale(t,s)}n.blendMode&&(i.blendMode=n.blendMode),ft(e,i,s),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),ft(e,i,s),i.restoreBlendMode()):ft(e,i,s)}},fillPathOrText:ft,fillText:function(t,e,i){if(t.motionText)return Y.fillMotionText(t,e,i);const s=t.__,{rows:a,decorationY:n}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=a.length;t<i;t++)r=a[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(n){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const a=e.__;if(a.__strokeWidth)if(a.__font)Y.strokeText(t,e,i,s);else if(a.__pathForStroke)Y.fillStroke(t,e,i,s);else switch(a.strokeAlign){case"center":pt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),pt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const a=e.__;if(a.__fillAfterStroke)pt(t,2,e,i,s);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),pt(t,2,e,r,s),r.clipUI(a),r.clearWorld(n),m.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Y.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":gt(t,1,e,i,s);break;case"inside":_t(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?gt(t,2,e,i,s):_t(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,a=t.__.__textDrawData;const{rows:n,decorationY:r}=a;for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=a;n.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,a,n){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!X.checkImage(r,!1,s,a,n))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.originPaint.blendMode?(a.saveBlendMode(r.originPaint.blendMode),i?Y.drawTextStroke(s,a,n):a.stroke(),a.restoreBlendMode()):i?Y.drawTextStroke(s,a,n):a.stroke()}},shape:function(t,e,s){const a=e.getSameCanvas(),n=e.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;yt(o.strokeSpread?(mt(kt,o.boxBounds,o.strokeSpread),kt):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))p=a,d=f=l,c=r;else{let a;if(i.fullImageShadow)a=l;else{const t=o.renderShapeSpread?wt(n,A.swapAndScale(o.renderShapeSpread,g,_)):n;a=bt(t,l)}u=n.getFitMatrix(a);let{a:w,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=xt(l,u),d=vt(f,-u.e,-u.f),c=xt(r,u),St(c,-u.e,-u.f);const y=s.matrix;y?(h=new P(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(a,s),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let At,Pt=new v;const{isSame:Ct}=T;function Ot(t,e,i,s,a,n){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=s.width/o.pixelRatio,o.__naturalHeight=s.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate(),m.updateBounds(t,!0),t.__layout.boundsChanged=!0,t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),"brush"===i.mode&&X.brush(t,e,a),!a.data){X.createData(a,s,i,n);const{transform:t}=a.data,{opacity:e}=i,r=(t&&!t.onlyScale||o.path||o.cornerRadius)&&!a.brush;(r||e&&e<1||i.blendMode)&&(a.complex=!r||2)}return i.filter&&X.applyFilter(a,s,i.filter,t),r}function Wt(t,e){It(t,C.LOAD,e)}function Mt(t,e){It(t,C.LOADED,e)}function Dt(t,e,i){e.error=i,t.forceUpdate("surface"),It(t,C.ERROR,e)}function It(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function Ft(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:zt,translate:Ut}=O,Yt=new v,Xt={},qt={};function Nt(t,i,s,a){const n=e(t)||a?(a?s-a*i:s%i)/((a||Math.floor(s/i))-1):t;return"auto"===t&&n<0?0:n}let Gt={},jt=I();const{get:Vt,set:Ht,rotateOfOuter:Qt,translate:Zt,scaleOfOuter:$t,multiplyParent:Jt,scale:Kt,rotate:te,skew:ee}=O;function ie(t,e,i,s,a,n,r,o){r&&te(t,r),o&&ee(t,o.x,o.y),a&&Kt(t,a,n),Zt(t,e.x+i,e.y+s)}function se(t,e,i,s){return new(i||(i=Promise))(function(a,n){function r(t){try{l(s.next(t))}catch(t){n(t)}}function o(t){try{l(s.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ae,scale:ne,copy:re}=O,{getFloorScale:oe}=W,{abs:le}=Math;const de={image:function(t,e,i,s,a){let n,r;const o=E.get(i,i.type);return At&&i===At.paint&&Ct(s,At.boxBounds)?n=At.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),At=o.use>1?{leafPaint:n,paint:i,boxBounds:Pt.set(s)}:null),(a||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Ot(t,e,i,o,n,s),a&&(Wt(t,r),Mt(t,r))):o.error?a&&Dt(t,r,o.error):(a&&(Ft(t,!0),Wt(t,r)),n.loadId=o.load(()=>{Ft(t,!1),t.destroyed||(Ot(t,e,i,o,n,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Mt(t,r)),n.loadId=void 0},e=>{Ft(t,!1),Dt(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,e,s,a,n){const{scaleX:r,scaleY:o}=X.getImageRenderScaleData(t,s,a,n),l=t.film?t.nowIndex:r+"-"+o,{image:d,brush:c,data:h,originPaint:u}=t,{exporting:f,snapshot:p}=n;if(!h||t.patternId===l&&!f||p){if(!c||!t.style)return!1}else if(e&&(h.repeat?e=!1:u.changeful||t.film||"miniapp"===i.name||f||(e=i.image.isLarge(d,r,o)||d.width*r>8096||d.height*o>8096)),e)s.__.__isFastShadow&&(a.fillStyle=t.style||"#000",a.fill());else if(!t.style||u.sync||f?X.createPattern(t,s,a,n):X.createPatternTask(t,s,a,n),!c||!t.style)return!1;return X.drawImage(t,r,o,s,a,n),!0},drawImage:function(t,e,i,s,a,n){const{data:r,image:o,brush:l,complex:d}=t;let{width:c,height:h}=o,u=l||o;if(d){const{blendMode:n,opacity:o}=t.originPaint,{transform:l}=r;a.save(),2===d&&a.clipUI(s),n&&(a.blendMode=n),o&&(a.opacity*=o),l&&a.transform(l),u.render(a,0,0,c,h,s,t,e,i),a.restore()}else r.scaleX&&(c*=r.scaleX,h*=r.scaleY),u.render(a,0,0,c,h,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const a=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(t.brush&&X.addBrushScale(a,t,e),i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return n&&n.scaleX&&(a.scaleX*=Math.abs(n.scaleX),a.scaleY*=Math.abs(n.scaleY)),a},recycleImage:function(t,e){const i=e["_"+t];if(S(i)){let s,a,n,r,o;const l=e.__leaf;for(let d=0,c=i.length;d<c;d++)s=i[d],a=s.image,o=a&&a.url,o&&(n||(n={}),n[o]=!0,E.recyclePaint(s),s.brush&&X.recycleBrush(s,l),e.__willDestroy&&a.parent&&X.recycleFilter(a,l),a.loading&&(r||(r=e.__input&&e.__input[t]||[],S(r)||(r=[r])),a.unload(i[d].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=E.patternTasker.add(()=>se(this,void 0,void 0,function*(){X.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,s,a){let{scaleX:n,scaleY:r}=X.getImageRenderScaleData(t,e,s,a),o=t.film?t.nowIndex:n+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!i.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:l,brush:d,data:c}=t,{transform:h,gap:u}=c,f=X.getPatternFixScale(t,n,r);let p,g,_,{width:w,height:m}=l,{opacity:y}=t.originPaint;(d||1===y)&&(y=void 0),f&&(n*=f,r*=f),w*=n,m*=r,u&&!d&&(g=u.x*n/le(c.scaleX||1),_=u.y*r/le(c.scaleY||1)),(h||1!==n||1!==r)&&(n*=oe(w+(g||0)),r*=oe(m+(_||0)),p=ae(),h&&re(p,h),ne(p,1/n,1/r));const x=l.getCanvas(w,m,y,void 0,g,_,e.leafer&&e.leafer.config.smooth,c.interlace);d?(t.style=x,X.cacheBrush(t,e,s,a)):t.style=l.getPattern(x,c.repeat||i.origin.noRepeat||"no-repeat",p,t),t.patternId=o}},getPatternFixScale:function(t,e,s){const{image:a}=t;let n,r=i.image.maxPatternSize,o=a.width*a.height;return a.isSVG?e>1&&(n=Math.ceil(e)/e):r>o&&(r=o),(o*=e*s)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=X.getPatternData(i,s,e)},getPatternData:function(t,i,a){t.padding&&(i=Yt.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:n,height:r}=a,{mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,interlace:w}=t,m=i.width===n&&i.height===r,y={mode:o},x="center"!==l&&(u||0)%180==90;let v,S;switch(T.set(qt,0,0,x?r:n,x?n:r),o&&"cover"!==o&&"fit"!==o?((c||h)&&(W.getScaleData(c,h,a,Xt),v=Xt.scaleX,S=Xt.scaleY),(l||_||g)&&(v&&T.scale(qt,v,S,!0),l&&M.toPoint(l,qt,i,qt,!0,!0))):m&&!u||(v=S=T.getFitScale(i,qt,"fit"!==o),T.put(i,a,l,v,!1,qt),T.scale(qt,v,S,!0)),d&&D.move(qt,d),o){case"stretch":m?v&&(v=S=void 0):(v=i.width/n,S=i.height/r,X.stretchMode(y,i,v,S));break;case"normal":case"clip":if(qt.x||qt.y||v||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),X.clipMode(y,i,qt.x,qt.y,v,S,u,f,t,e),t&&(v=v?v*t:t,S=S?S*e:e)}break;case"repeat":(!m||v||u||f)&&X.repeatMode(y,i,n,r,qt.x,qt.y,v,S,u,f,l,t.freeTransform);case"brush":g||(y.repeat="repeat");const e=L(g);(_||e)&&(y.gap=function(t,e,i,s,a){let n,r;L(t)?(n=t.x,r=t.y):n=r=t;return{x:Nt(n,i,a.width,e&&e.x),y:Nt(r,s,a.height,e&&e.y)}}(_,e&&g,qt.width,qt.height,i));break;default:v&&X.fillOrFitMode(y,i,qt.x,qt.y,v,S,u)}return y.transform||"brush"===o||(i.x||i.y)&&Ut(y.transform=zt(),i.x,i.y),v&&(y.scaleX=v,y.scaleY=S),g&&(y.repeat=e(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w&&(y.interlace=s(w)||"percent"===w.type?{type:"x",offset:w}:w),y},stretchMode:function(t,e,i,s){const a=Vt(),{x:n,y:r}=e;n||r?Zt(a,n,r):i>0&&s>0&&(a.onlyScale=!0),Kt(a,i,s),t.transform=a},fillOrFitMode:function(t,e,i,s,a,n,r){const o=Vt();Zt(o,e.x+i,e.y+s),Kt(o,a,n),r&&Qt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,a,n,r,o,l,d){const c=Vt();ie(c,e,i,s,a,n,r,o),l&&(r||o?(Ht(jt),$t(jt,e,l,d),Jt(c,jt)):$t(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,s,a,n,r,o,l,d,c,h){const u=Vt();if(h)ie(u,e,a,n,r,o,l,d);else{if(l)if("center"===c)Qt(u,{x:i/2,y:s/2},l);else switch(te(u,l),l){case 90:Zt(u,s,0);break;case 180:Zt(u,i,s);break;case 270:Zt(u,0,i)}Gt.x=e.x+a,Gt.y=e.y+n,Zt(u,Gt.x,Gt.y),r&&$t(u,Gt,r,o)}t.transform=u}},{toPoint:ce}=F,{hasTransparent:he}=q,ue={},fe={};function pe(t,i,s,a){if(s){let n,r,o,l;for(let t=0,d=s.length;t<d;t++)n=s[t],e(n)?(o=t/(d-1),r=q.string(n,a)):(o=n.offset,r=q.string(n.color,a)),i.addColorStop(o,r),!l&&he(r)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:ge,getDistance:_e}=D,{get:we,rotateOfOuter:me,scaleOfOuter:ye}=O,{toPoint:xe}=F,ve={},Se={};function be(t,e,i,s,a){let n;const{width:r,height:o}=t;if(r!==o||s){const t=ge(e,i);n=we(),a?(ye(n,e,r/o*(s||1),1),me(n,e,t+90)):(ye(n,e,1,r/o*(s||1)),me(n,e,t))}return n}const{getDistance:ke}=D,{toPoint:Be}=F,Re={},Ee={};const Le={linearGradient:function(t,e){let{from:s,to:a,type:n,opacity:r}=t;ce(s||"top",e,ue),ce(a||"bottom",e,fe);const o=i.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y),l={type:n,style:o};return pe(l,o,t.stops,r),l},radialGradient:function(t,e){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;xe(s||"center",e,ve),xe(a||"bottom",e,Se);const l=i.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,_e(ve,Se)),d={type:n,style:l};pe(d,l,t.stops,r);const c=be(e,ve,Se,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,e){let{from:s,to:a,type:n,opacity:r,rotation:o,stretch:l}=t;Be(s||"center",e,Re),Be(a||"bottom",e,Ee);const d=i.conicGradientSupport?i.canvas.createConicGradient(o?o*z:0,Re.x,Re.y):i.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,ke(Re,Ee)),c={type:n,style:d};pe(c,d,t.stops,r);const h=be(e,Re,Ee,l||1,i.conicGradientRotate90);return h&&(c.transform=h),c},getTransform:be},{copy:Te,move:Ae,toOffsetOutBounds:Pe}=T,{max:Ce,abs:Oe}=Math,We={},Me=new P,De={};function Ie(t,e){let i,s,a,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=1.5*(t.blur||0),a=Oe(t.spread||0),r=Ce(r,a+n-s),o=Ce(o,a+n+i),l=Ce(l,a+n+s),d=Ce(d,a+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Fe(t,e,s){const{shapeBounds:a}=s;let n,r;i.fullImageShadow?(Te(We,t.bounds),Ae(We,e.x-a.x,e.y-a.y),n=t.bounds,r=We):(n=a,r=e),t.copyWorld(s.canvas,n,r)}const{toOffsetOutBounds:ze}=T,Ue={};const Ye=Ie;const Xe={shadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Pe(l,De,d),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(_=1/t)}f.setWorldShadow(De.offsetX+(r.x||0)*h*_,De.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_,q.string(r.color)),a=G.getShadowTransform(t,f,i,r,De,_),a&&f.setTransform(a),Fe(f,De,i),a&&f.resetTransform(),s=d,r.box&&(f.restore(),f.save(),o&&(f.copyWorld(f,d,n,"copy"),s=n),o?f.copyWorld(o,n,n,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ze(l,Ue,d),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Ue.offsetX+(r.x||0)*h*_,Ue.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_),a=G.getShadowTransform(t,f,i,r,Ue,_,!0),a&&f.setTransform(a),Fe(f,Ue,i),f.restore(),o?(f.copyWorld(f,d,n,"copy"),f.copyWorld(o,n,n,"source-out"),s=n):(f.copyWorld(i.canvas,c,l,"source-out"),s=d),f.fillWorld(s,q.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Ie,getShadowTransform:function(t,e,i,s,a,n,r){if(s.spread){const i=2*s.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Me.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/o,1+i/l),Me}},isTransformShadow(t){},getInnerShadowSpread:Ye},{excludeRenderBounds:qe}=x;let Ne;function Ge(t,e,i,s,a,n,r,o){switch(e){case"grayscale":Ne||(Ne=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),n&&s.recycle(r);Ve(t,e,i,1,a,n)}(t,i,s,a,r,o);break;case"opacity-path":Ve(t,i,s,n,r,o);break;case"path":o&&i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function Ve(t,e,i,s,a,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,a),n?i.recycle(r):i.clearWorld(r)}j.prototype.__renderMask=function(t,e){let i,s,a,n,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(Ge(this,r,t,a,s,n,void 0,!0),s=a=null),"clipping"!==o&&"clipping-path"!==o||qe(i,e)||i.__render(t,e),n=i.__.opacity,Ne=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",a||(a=je(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=je(t)),a||(a=je(t)),i.__render(s,e));continue}const c=1===n&&i.__.__blendMode;c&&Ge(this,r,t,a,s,n,void 0,!1),qe(i,e)||i.__render(a||t,e),c&&Ge(this,r,t,a,s,n,c,!1)}Ge(this,r,t,a,s,n,void 0,!0)};const He=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=He+"_#~&*+\\=|≮≯≈≠=…",Ze=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 $e(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Je=$e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=$e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=$e(He),ei=$e(Qe),ii=$e("- —/~|┆·");var si;!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"}(si||(si={}));const{Letter:ai,Single:ni,Before:ri,After:oi,Symbol:li,Break:di}=si;function ci(t){return Je[t]?ai:ii[t]?di:Ke[t]?ri:ti[t]?oi:ei[t]?li:Ze.test(t)?ni:ai}const hi={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 ui(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:fi}=hi,{Letter:pi,Single:gi,Before:_i,After:wi,Symbol:mi,Break:yi}=si;let xi,vi,Si,bi,ki,Bi,Ri,Ei,Li,Ti,Ai,Pi,Ci,Oi,Wi,Mi,Di,Ii=[];function Fi(t,e){Li&&!Ei&&(Ei=Li),xi.data.push({char:t,width:e}),Si+=e}function zi(){bi+=Si,xi.width=Si,vi.words.push(xi),xi={data:[]},Si=0}function Ui(){Oi&&(Wi.paraNumber++,vi.paraStart=!0,Oi=!1),Li&&(vi.startCharSize=Ei,vi.endCharSize=Li,Ei=0),vi.width=bi,Mi.width?fi(vi):Di&&Yi(),Ii.push(vi),vi={words:[]},bi=0}function Yi(){bi>(Wi.maxWidth||0)&&(Wi.maxWidth=bi)}const{top:Xi,right:qi,bottom:Ni,left:Gi}=U;function ji(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 Vi={getDrawData:function(t,s){e(t)||(t=String(t));let a=0,n=0,r=s.__getInput("width")||0,o=s.__getInput("height")||0;const{__padding:l}=s;s.motionText&&(r=o=0),l&&(r?(a=l[Gi],r-=l[qi]+l[Gi],!r&&(r=.01)):s.autoSizeAlign||(a=l[Gi]),o?(n=l[Xi],o-=l[Xi]+l[Ni],!o&&(o=.01)):s.autoSizeAlign||(n=l[Xi]));const d={bounds:{x:a,y:n,width:r,height:o},rows:[],paraNumber:0,font:i.canvas.font=s.__font};return function(t,e,s){Wi=t,Ii=t.rows,Mi=t.bounds,Di=!Mi.width&&!s.autoSizeAlign;const{__letterSpacing:a,paraIndent:n,textCase:r}=s,{canvas:o}=i,{width:l}=Mi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Oi=!0,Ai=null,Ei=Ri=Li=Si=bi=0,xi={data:[]},vi={words:[]};for(let s=0,d=(e=[...e]).length;s<d;s++)Bi=e[s],"\n"===Bi?(Si&&zi(),vi.paraEnd=!0,Ui(),Oi=!0):(Ti=ci(Bi),Ti===pi&&"none"!==r&&(Bi=ui(Bi,r,!Si)),Ri=o.measureText(Bi).width,a&&(a<0&&(Li=Ri),Ri+=a),Pi=Ti===gi&&(Ai===gi||Ai===pi)||Ai===gi&&Ti!==wi,Ci=!(Ti!==_i&&Ti!==gi||Ai!==mi&&Ai!==wi),ki=Oi&&n?l-n:l,t&&l&&bi+Si+Ri>ki&&(i?(Si&&zi(),bi&&Ui()):(Ci||(Ci=Ti===pi&&Ai==wi),Pi||Ci||Ti===yi||Ti===_i||Ti===gi||Si+Ri>ki?(Si&&zi(),bi&&Ui()):bi&&Ui()))," "===Bi&&!0!==Oi&&bi+Si===0||(Ti===yi?(" "===Bi&&Si&&zi(),Fi(Bi,Ri),zi()):Pi||Ci?(Si&&zi(),Fi(Bi,Ri)):Fi(Bi,Ri)),Ai=Ti);Si&&zi(),bi&&Ui(),Ii.length>0&&(Ii[Ii.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Wi.paraNumber++,bi=o.measureText(t).width,Ii.push({x:n||0,text:t,width:bi,paraStart:!0}),Di&&Yi()})}(d,t,s),l&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ji(e,"x",t[Gi]);break;case"right":ji(e,"x",-t[qi])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ji(e,"y",t[Xi]);break;case"bottom":ji(e,"y",-t[Ni])}}(l,d,s,r,o),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=n*a+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(e.__autoHeight?w:_,n),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,S=g||u?g:t.maxWidth;for(let r=0,c=a;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=n,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(d,s),s.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n}=e,r=e.__letterSpacing||e.motionText,o=i&&a.includes("both"),l=o||i&&a.includes("justify"),d=l&&a.includes("letter");let c,h,u,f,p,g,_,w,m,y;s.forEach(t=>{t.words&&(p=n&&t.paraStart?n:0,w=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,s,a){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(d,s,r),d.overflow&&function(t,e,s,a){const{rows:n,overflow:r}=t;let{textOverflow:o}=e;if(r&&n.splice(r),a&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?i.canvas.measureText(o).width:0,c=s+a-d;("none"===e.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,s,a,r),"none"!==s.textDecoration&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,L(n)?(i=n.type,n.color&&(t.decorationColor=q.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]}}(d,s),d}};const Hi={string:function(t,i){if(!t)return"#000";const a=s(i)&&i<1;if(e(t)){if(!a||!q.object)return t;t=q.object(t)}let n=o(t.a)?1:t.a;a&&(n*=i);const r=t.r+","+t.g+","+t.b;return 1===n?"rgb("+r+")":"rgba("+r+","+n+")"}};Object.assign(V,Vi),Object.assign(q,Hi),Object.assign(Y,Tt),Object.assign(X,de),Object.assign(N,Le),Object.assign(G,Xe);try{wx&&Z(0,wx)}catch(t){}export{ct as Layouter,st as LayouterHelper,Q as LeaferCanvas,H as PathNodeHandleType,ut as Renderer,$ as Watcher,Z as useCanvas};
2
2
  //# sourceMappingURL=miniapp.esm.min.js.map