@leafer-ui/node 2.0.5 → 2.0.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/node.cjs CHANGED
@@ -1342,17 +1342,19 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1342
1342
  }
1343
1343
 
1344
1344
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1345
+ let needUpdate = true;
1345
1346
  const data = ui.__;
1346
1347
  if (attrName === "fill" && !data.__naturalWidth) {
1347
1348
  data.__naturalWidth = image.width / data.pixelRatio;
1348
1349
  data.__naturalHeight = image.height / data.pixelRatio;
1349
1350
  if (data.__autoSide) {
1350
1351
  ui.forceUpdate("width");
1352
+ core.LeafHelper.updateBounds(ui);
1351
1353
  if (ui.__proxyData) {
1352
1354
  ui.setProxyAttr("width", data.width);
1353
1355
  ui.setProxyAttr("height", data.height);
1354
1356
  }
1355
- return false;
1357
+ needUpdate = false;
1356
1358
  }
1357
1359
  }
1358
1360
  if (!leafPaint.data) {
@@ -1362,7 +1364,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1362
1364
  if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1363
1365
  }
1364
1366
  if (paint.filter) draw.PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
1365
- return true;
1367
+ return needUpdate;
1366
1368
  }
1367
1369
 
1368
1370
  function onLoad(ui, event) {
@@ -1812,10 +1814,10 @@ const realFrom = {};
1812
1814
  const realTo = {};
1813
1815
 
1814
1816
  function conicGradient(paint, box) {
1815
- let {from: from, to: to, type: type, opacity: opacity, stretch: stretch} = paint;
1817
+ let {from: from, to: to, type: type, opacity: opacity, rotation: rotation, stretch: stretch} = paint;
1816
1818
  toPoint(from || "center", box, realFrom);
1817
1819
  toPoint(to || "bottom", box, realTo);
1818
- const style = core.Platform.conicGradientSupport ? core.Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : core.Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
1820
+ const style = core.Platform.conicGradientSupport ? core.Platform.canvas.createConicGradient(rotation ? rotation * core.OneRadian : 0, realFrom.x, realFrom.y) : core.Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
1819
1821
  const data = {
1820
1822
  type: type,
1821
1823
  style: style
package/dist/node.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, PointHelper, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, isUndefined, isString, ImageEvent, MatrixHelper, MathHelper, AlignHelper, isNumber, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
1
+ import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, PointHelper, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, isUndefined, isString, ImageEvent, MatrixHelper, MathHelper, AlignHelper, isNumber, getMatrixData, AroundHelper, OneRadian, Direction4 } from "@leafer/core";
2
2
 
3
3
  export * from "@leafer/core";
4
4
 
@@ -1346,17 +1346,19 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1346
1346
  }
1347
1347
 
1348
1348
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1349
+ let needUpdate = true;
1349
1350
  const data = ui.__;
1350
1351
  if (attrName === "fill" && !data.__naturalWidth) {
1351
1352
  data.__naturalWidth = image.width / data.pixelRatio;
1352
1353
  data.__naturalHeight = image.height / data.pixelRatio;
1353
1354
  if (data.__autoSide) {
1354
1355
  ui.forceUpdate("width");
1356
+ LeafHelper.updateBounds(ui);
1355
1357
  if (ui.__proxyData) {
1356
1358
  ui.setProxyAttr("width", data.width);
1357
1359
  ui.setProxyAttr("height", data.height);
1358
1360
  }
1359
- return false;
1361
+ needUpdate = false;
1360
1362
  }
1361
1363
  }
1362
1364
  if (!leafPaint.data) {
@@ -1366,7 +1368,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1366
1368
  if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1367
1369
  }
1368
1370
  if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
1369
- return true;
1371
+ return needUpdate;
1370
1372
  }
1371
1373
 
1372
1374
  function onLoad(ui, event) {
@@ -1816,10 +1818,10 @@ const realFrom = {};
1816
1818
  const realTo = {};
1817
1819
 
1818
1820
  function conicGradient(paint, box) {
1819
- let {from: from, to: to, type: type, opacity: opacity, stretch: stretch} = paint;
1821
+ let {from: from, to: to, type: type, opacity: opacity, rotation: rotation, stretch: stretch} = paint;
1820
1822
  toPoint(from || "center", box, realFrom);
1821
1823
  toPoint(to || "bottom", box, realTo);
1822
- const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
1824
+ const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(rotation ? rotation * OneRadian : 0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
1823
1825
  const data = {
1824
1826
  type: type,
1825
1827
  style: style
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,defineKey as a,FileHelper as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as y,Debug as w,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,PointHelper as k,BoundsHelper as B,Plugin as R,isObject as L,FourNumberHelper as E,Matrix as T,isUndefined as P,isString as A,ImageEvent as C,MatrixHelper as O,MathHelper as M,AlignHelper as W,isNumber as D,getMatrixData as F,AroundHelper as I,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{writeFileSync as Y}from"fs";import{HitCanvasManager as X,InteractionBase as N}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as q,PaintImage as j,ColorConvert as z,PaintGradient as G,Effect as H,Group as V,TextConvert as Q,TwoPointBoundsHelper as J,Bounds as Z,Export as $,FileHelper as K,Platform as tt,isUndefined as et,Matrix as it,MathHelper as nt,Creator as st,TaskProcessor as at,Resource as rt,LeaferCanvasBase as ot,Debug as lt,Plugin as dt,UI as ct}from"@leafer-ui/draw";var ht;function ut(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(ht||(ht={})),"function"==typeof SuppressedError&&SuppressedError;class ft extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function gt(t){return ut(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})}function pt(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL?t.toDataURL(r.mimeType(e),i):(t.toDataURLSync||t.toURLSync)(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:(t,i,s)=>n(e.image.getRealURL(t)),loadContent:gt},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(r.mimeType(e),i),canvasToBolb:(t,e,i)=>ut(this,void 0,void 0,function*(){return t.toBuffer(r.mimeType(e),i)}),canvasSaveAs:(t,e,i)=>ut(this,void 0,void 0,function*(){return Y(e,t.toBuffer(r.mimeType(r.fileType(e)),i))}),download(t,e){},loadImage:(t,i,s)=>n(e.image.getRealURL(t)),loadContent:gt}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new ft(t,e),image:t=>new s(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class _t{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:yt,updateBounds:wt,updateChange:mt}=f,{pushAllChildBranch:xt,pushAllParent:vt}=g;const{worldBounds:bt}=p;class St{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,y(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,bt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,bt),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:kt,updateAllChange:Bt}=f,Rt=w.get("Layouter");class Lt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){Rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Rt.warn("layouting"):this.times>3?Rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(n);o.forEach(t=>t.setBefore()),i.emitEvent(new x(s,o,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(yt(t,!0),e.add(t),t.isBranch&&xt(t,e),vt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),vt(t,e)))})}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||wt(n[t])}wt(i)}})}(this.__levelList),function(t){t.list.forEach(mt)}(n),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),Lt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(n,a,this.times)),e.emitEvent(new x(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){kt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),Bt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new St([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new St(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Et=w.get("Renderer");class Tt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Et.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,Et.error(t)}Et.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Et.warn("rendering");if(this.times>3)return Et.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(Tt.clipSpread).ceil();const{ceilPartPixel:a}=this.config;i.clipWorld(n,a),i.clearWorld(n,a),this.__render(n,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:n,target:s}=this,a=t.includes(s.__world),r=a?{includes:a}:{bounds:t,includes:a};this.needFill&&n.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(n,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(s,n,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&t>n)return e.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Et.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 d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Tt.clipSpread=10;const Pt={},{copyRadiusPoint:At}=k,{hitRadiusPoint:Ct}=B;class Ot{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,s,!!i.findList),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),n?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,n){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return n?null:i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o,i=[],{target:n}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==n););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==n););}),n&&e.add(n),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,r=i.length;t<r;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n,s;const{point:a}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],s=i.__,s.visible&&(!e||s.mask))if(n=Ct(i.__world,s.hitRadius?At(Pt,a,s.hitRadius):a),i.isBranch){if(n||i.__ignoreHitWorld){if(i.isBranchLeaf&&s.__clipAfterFill&&!i.__hitWorld(a,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,a)}}else n&&this.hitChild(i,a)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask){let i,s=[];const{children:a}=n;for(let n=0,r=a.length;n<r;n++)if(i=a[n],i.__.mask&&s.push(i),i===t){if(s&&!s.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Mt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Ot(this.target=t,this),this.finder=n.finder&&n.finder(t,this.config)}getByPoint(t,i,n){const{target:s,picker:a}=this;return e.backgrounder&&s&&s.updateLayout(),a.getByPoint(t,i,n)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Wt(t,e,i){t.__.__font?q.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Dt(t,e,i,n,s){const a=i.__;L(t)?q.drawStrokesStyle(t,e,!1,i,n,s):(n.setStroke(t,a.__strokeWidth*e,a),n.stroke()),a.__useArrow&&q.strokeArrow(t,i,n,s)}function Ft(t,e,i,n,s){const a=i.__;L(t)?q.drawStrokesStyle(t,e,!0,i,n,s):(n.setStroke(t,a.__strokeWidth*e,a),q.drawTextStroke(i,n,s))}function It(t,e,i,n,s){const a=n.getSameCanvas(!0,!0);a.font=i.__.__font,Ft(t,2,i,a,s),a.blendMode="outside"===e?"destination-out":"destination-in",q.fillText(i,a,s),a.blendMode="normal",f.copyCanvasByWorld(i,n,a),a.recycle(i.__nowWorld)}Object.assign(n,{watcher:(t,e)=>new _t(t,e),layouter:(t,e)=>new Lt(t,e),renderer:(t,e,i)=>new Tt(t,e,i),selector:(t,e)=>new Mt(t,e)}),e.layout=Lt.fullLayout,e.render=function(t,e,i){const n=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,n))};const{getSpread:Ut,copyAndSpread:Yt,toOuterOf:Xt,getOuterOf:Nt,getByMove:qt,move:jt,getIntersectData:zt}=B,Gt={};let Ht;const{stintSet:Vt}=l,{hasTransparent:Qt}=z;function Jt(t,e,i){if(!L(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:s}=i.__layout,{type:a}=e;switch(a){case"image":case"film":case"video":if(!e.url)return;n=j.image(i,t,e,s,!Ht||!Ht[e.url]),"image"!==a&&j[a](n);break;case"linear":n=G.linearGradient(e,s);break;case"radial":n=G.radialGradient(e,s);break;case"angular":n=G.conicGradient(e,s);break;case"solid":const{color:r,opacity:o}=e;n={type:a,style:z.string(r,o)};break;default:P(e.r)||(n={type:"solid",style:z.string(e)})}if(n&&(n.originPaint=e,A(n.style)&&Qt(n.style)&&(n.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}return n}const Zt={compute:function(t,e){const i=e.__,n=[];let s,a,r,o=i.__input[t];y(o)||(o=[o]),Ht=j.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)(i=Jt(t,o[s],e))&&(n.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=n.length?n:void 0,n.length?(n.every(t=>t.isTransparent)&&(n.some(t=>t.image)&&(s=!0),a=!0),"fill"===t?(Vt(i,"__isAlphaPixelFill",s),Vt(i,"__isTransparentFill",a)):(Vt(i,"__isAlphaPixelStroke",s),Vt(i,"__isTransparentStroke",a),Vt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,n){i.fillStyle=t,Wt(e,i,n)},fills:function(t,e,i,n){let s,a,r;for(let o=0,l=t.length;o<l;o++){if(s=t[o],a=s.originPaint,s.image){if(r?r++:r=1,j.checkImage(s,!e.__.__font,e,i,n))continue;if(!s.style){1===r&&s.image.isPlacehold&&e.drawImagePlaceholder(s,i,n);continue}}if(i.fillStyle=s.style,s.transform||a.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),a.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0,a.scaleFixed,!1);1!==t&&i.scale(t,n)}a.blendMode&&(i.blendMode=a.blendMode),Wt(e,i,n),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),Wt(e,i,n),i.restoreBlendMode()):Wt(e,i,n)}},fillPathOrText:Wt,fillText:function(t,e,i){const n=t.__,{rows:s,decorationY:a}=n.__textDrawData;let r;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,i=s.length;t<i;t++)r=s[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:i}=n.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>a.forEach(n=>e.fillRect(t.x,t.y+n,t.width,i)))}},stroke:function(t,e,i,n){const s=e.__;if(s.__strokeWidth)if(s.__font)q.strokeText(t,e,i,n);else switch(s.strokeAlign){case"center":Dt(t,1,e,i,n);break;case"inside":!function(t,e,i,n){i.save(),i.clipUI(e),Dt(t,2,e,i,n),i.restore()}(t,e,i,n);break;case"outside":!function(t,e,i,n){const s=e.__;if(s.__fillAfterStroke)Dt(t,2,e,i,n);else{const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),Dt(t,2,e,r,n),r.clipUI(s),r.clearWorld(a),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,n)}},strokes:function(t,e,i,n){q.stroke(t,e,i,n)},strokeText:function(t,e,i,n){switch(e.__.strokeAlign){case"center":Ft(t,1,e,i,n);break;case"inside":It(t,"inside",e,i,n);break;case"outside":e.__.__fillAfterStroke?Ft(t,2,e,i,n):It(t,"outside",e,i,n)}},drawTextStroke:function(t,e,i){let n,s=t.__.__textDrawData;const{rows:a,decorationY:r}=s;for(let t=0,i=a.length;t<i;t++)n=a[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.strokeText(t.char,t.x,n.y)});if(r){const{decorationHeight:t}=s;a.forEach(i=>r.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}},drawStrokesStyle:function(t,e,i,n,s,a){let r;const o=n.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!j.checkImage(r,!1,n,s,a))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):s.setStroke(r.style,o.__strokeWidth*e,o)}else s.strokeStyle=r.style;r.originPaint.blendMode?(s.saveBlendMode(r.originPaint.blendMode),i?q.drawTextStroke(n,s,a):s.stroke(),s.restoreBlendMode()):i?q.drawTextStroke(n,s,a):s.stroke()}},shape:function(t,i,n){const s=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;Xt(o.strokeSpread?(Yt(Gt,o.boxBounds,o.strokeSpread),Gt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=s,d=f=l,c=r;else{let s;if(e.fullImageShadow)s=l;else{const t=o.renderShapeSpread?Ut(a,E.swapAndScale(o.renderShapeSpread,p,_)):a;s=zt(t,l)}u=a.getFitMatrix(s);let{a:y,d:w}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,n),p*=y,_*=w),f=Nt(l,u),d=qt(f,-u.e,-u.f),c=Nt(r,u),jt(c,-u.e,-u.f);const m=n.matrix;m?(h=new T(u),h.multiply(m),y*=m.scaleX,w*=m.scaleY):h=u,h.withScale(y,w),n=Object.assign(Object.assign({},n),{matrix:h})}return t.__renderShape(s,n),{canvas:s,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let $t,Kt=new _;const{isSame:te}=B;function ee(t,e,i,n,s,a){const r=t.__;if("fill"===e&&!r.__naturalWidth&&(r.__naturalWidth=n.width/r.pixelRatio,r.__naturalHeight=n.height/r.pixelRatio,r.__autoSide))return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",r.width),t.setProxyAttr("height",r.height)),!1;if(!s.data){j.createData(s,n,i,a);const{transform:t}=s.data,{opacity:e,blendMode:o}=i,l=t&&!t.onlyScale||r.path||r.cornerRadius;(l||e&&e<1||o)&&(s.complex=!l||2)}return i.filter&&j.applyFilter(s,n,i.filter,t),!0}function ie(t,e){ae(t,C.LOAD,e)}function ne(t,e){ae(t,C.LOADED,e)}function se(t,e,i){e.error=i,t.forceUpdate("surface"),ae(t,C.ERROR,e)}function ae(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function re(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:oe,translate:le}=O,de=new _,ce={},he={};function ue(t,e,i,n){const s=A(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&s<0?0:s}let fe={},ge=F();const{get:pe,set:_e,rotateOfOuter:ye,translate:we,scaleOfOuter:me,multiplyParent:xe,scale:ve,rotate:be,skew:Se}=O;function ke(t,e,i,n,s,a,r,o){r&&be(t,r),o&&Se(t,o.x,o.y),s&&ve(t,s,a),we(t,e.x+i,e.y+n)}const{get:Be,scale:Re,copy:Le}=O,{getFloorScale:Ee}=M,{abs:Te}=Math;const Pe={image:function(t,e,i,n,s){let a,r;const o=b.get(i,i.type);return $t&&i===$t.paint&&te(n,$t.boxBounds)?a=$t.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),$t=o.use>1?{leafPaint:a,paint:i,boxBounds:Kt.set(n)}:null),(s||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(ee(t,e,i,o,a,n),s&&(ie(t,r),ne(t,r))):o.error?s&&se(t,r,o.error):(s&&(re(t,!0),ie(t,r)),a.loadId=o.load(()=>{re(t,!1),t.destroyed||(ee(t,e,i,o,a,n)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ne(t,r)),a.loadId=void 0},e=>{re(t,!1),se(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,i,n,s,a){const{scaleX:r,scaleY:o}=j.getImageRenderScaleData(t,n,s,a),l=t.film?t.nowIndex:r+"-"+o,{image:d,data:c,originPaint:h}=t,{exporting:u,snapshot:f}=a;return!(!c||t.patternId===l&&!u||f)&&(i&&(c.repeat?i=!1:h.changeful||t.film||"miniapp"===e.name||u||(i=e.image.isLarge(d,r,o)||d.width*r>8096||d.height*o>8096)),i?(n.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),j.drawImage(t,r,o,n,s,a),!0):(!t.style||h.sync||u?j.createPattern(t,n,s,a):j.createPatternTask(t,n,s,a),!1))},drawImage:function(t,e,i,n,s,a){const{data:r,image:o,complex:l}=t;let{width:d,height:c}=o;if(l){const{blendMode:a,opacity:h}=t.originPaint,{transform:u}=r;s.save(),2===l&&s.clipUI(n),a&&(s.blendMode=a),h&&(s.opacity*=h),u&&s.transform(u),o.render(s,0,0,d,c,n,t,e,i),s.restore()}else r.scaleX&&(d*=r.scaleX,c*=r.scaleY),o.render(s,0,0,d,c,n,t,e,i)},getImageRenderScaleData:function(t,e,i,n){const s=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:a}=t;if(i){const{pixelRatio:t}=i;s.scaleX*=t,s.scaleY*=t}return a&&a.scaleX&&(s.scaleX*=Math.abs(a.scaleX),s.scaleY*=Math.abs(a.scaleY)),s},recycleImage:function(t,e){const i=e["_"+t];if(y(i)){let n,s,a,r,o;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,b.recyclePaint(n),e.__willDestroy&&s.parent&&j.recycleFilter(s,e.__leaf),s.loading&&(r||(r=e.__input&&e.__input[t]||[],y(r)||(r=[r])),s.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createPatternTask:function(t,e,i,n){t.patternTask||(t.patternTask=b.patternTasker.add(()=>ut(this,void 0,void 0,function*(){j.createPattern(t,e,i,n),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,n,s){let{scaleX:a,scaleY:r}=j.getImageRenderScaleData(t,i,n,s),o=t.film?t.nowIndex:a+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,a,r)||t.data.repeat)){const{image:n,data:s}=t,{opacity:l}=t.originPaint,{transform:d,gap:c}=s,h=j.getPatternFixScale(t,a,r);let u,f,g,{width:p,height:_}=n;h&&(a*=h,r*=h),p*=a,_*=r,c&&(f=c.x*a/Te(s.scaleX||1),g=c.y*r/Te(s.scaleY||1)),(d||1!==a||1!==r)&&(a*=Ee(p+(f||0)),r*=Ee(_+(g||0)),u=Be(),d&&Le(u,d),Re(u,1/a,1/r));const y=n.getCanvas(p,_,l,void 0,f,g,i.leafer&&i.leafer.config.smooth,s.interlace),w=n.getPattern(y,s.repeat||e.origin.noRepeat||"no-repeat",u,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,n){const{image:s}=t;let a,r=e.image.maxPatternSize,o=s.width*s.height;return s.isSVG?i>1&&(a=Math.ceil(i)/i):r>o&&(r=o),(o*=i*n)>r&&(a=Math.sqrt(r/o)),a},createData:function(t,e,i,n){t.data=j.getPatternData(i,n,e)},getPatternData:function(t,e,i){t.padding&&(e=de.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:n,height:s}=i,{mode:a,align:r,offset:o,scale:l,size:d,rotation:c,skew:h,clipSize:u,repeat:f,gap:g,interlace:p}=t,_=e.width===n&&e.height===s,y={mode:a},w="center"!==r&&(c||0)%180==90;let m,x;switch(B.set(he,0,0,w?s:n,w?n:s),a&&"cover"!==a&&"fit"!==a?((l||d)&&(M.getScaleData(l,d,i,ce),m=ce.scaleX,x=ce.scaleY),(r||g||f)&&(m&&B.scale(he,m,x,!0),r&&W.toPoint(r,he,e,he,!0,!0))):_&&!c||(m=x=B.getFitScale(e,he,"fit"!==a),B.put(e,i,r,m,!1,he),B.scale(he,m,x,!0)),o&&k.move(he,o),a){case"stretch":_?m&&(m=x=void 0):(m=e.width/n,x=e.height/s,j.stretchMode(y,e,m,x));break;case"normal":case"clip":if(he.x||he.y||m||u||c||h){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),j.clipMode(y,e,he.x,he.y,m,x,c,h,t,i),t&&(m=m?m*t:t,x=x?x*i:i)}break;case"repeat":(!_||m||c||h)&&j.repeatMode(y,e,n,s,he.x,he.y,m,x,c,h,r,t.freeTransform),f||(y.repeat="repeat");const i=L(f);(g||i)&&(y.gap=function(t,e,i,n,s){let a,r;L(t)?(a=t.x,r=t.y):a=r=t;return{x:ue(a,i,s.width,e&&e.x),y:ue(r,n,s.height,e&&e.y)}}(g,i&&f,he.width,he.height,e));break;default:m&&j.fillOrFitMode(y,e,he.x,he.y,m,x,c)}return y.transform||(e.x||e.y)&&le(y.transform=oe(),e.x,e.y),m&&(y.scaleX=m,y.scaleY=x),f&&(y.repeat=A(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),p&&(y.interlace=D(p)||"percent"===p.type?{type:"x",offset:p}:p),y},stretchMode:function(t,e,i,n){const s=pe(),{x:a,y:r}=e;a||r?we(s,a,r):i>0&&n>0&&(s.onlyScale=!0),ve(s,i,n),t.transform=s},fillOrFitMode:function(t,e,i,n,s,a,r){const o=pe();we(o,e.x+i,e.y+n),ve(o,s,a),r&&ye(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,n,s,a,r,o,l,d){const c=pe();ke(c,e,i,n,s,a,r,o),l&&(r||o?(_e(ge),me(ge,e,l,d),xe(c,ge)):me(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,n,s,a,r,o,l,d,c,h){const u=pe();if(h)ke(u,e,s,a,r,o,l,d);else{if(l)if("center"===c)ye(u,{x:i/2,y:n/2},l);else switch(be(u,l),l){case 90:we(u,n,0);break;case 180:we(u,i,n);break;case 270:we(u,0,i)}fe.x=e.x+s,fe.y=e.y+a,we(u,fe.x,fe.y),r&&me(u,fe,r,o)}t.transform=u}},{toPoint:Ae}=I,{hasTransparent:Ce}=z,Oe={},Me={};function We(t,e,i,n){if(i){let s,a,r,o;for(let t=0,l=i.length;t<l;t++)s=i[t],A(s)?(r=t/(l-1),a=z.string(s,n)):(r=s.offset,a=z.string(s.color,n)),e.addColorStop(r,a),!o&&Ce(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:De,getDistance:Fe}=k,{get:Ie,rotateOfOuter:Ue,scaleOfOuter:Ye}=O,{toPoint:Xe}=I,Ne={},qe={};function je(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=De(e,i);a=Ie(),s?(Ye(a,e,r/o*(n||1),1),Ue(a,e,t+90)):(Ye(a,e,1,r/o*(n||1)),Ue(a,e,t))}return a}const{getDistance:ze}=k,{toPoint:Ge}=I,He={},Ve={};const Qe={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:r}=t;Ae(n||"top",i,Oe),Ae(s||"bottom",i,Me);const o=e.canvas.createLinearGradient(Oe.x,Oe.y,Me.x,Me.y),l={type:a,style:o};return We(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=t;Xe(n||"center",i,Ne),Xe(s||"bottom",i,qe);const l=e.canvas.createRadialGradient(Ne.x,Ne.y,0,Ne.x,Ne.y,Fe(Ne,qe)),d={type:a,style:l};We(d,l,t.stops,r);const c=je(i,Ne,qe,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=t;Ge(n||"center",i,He),Ge(s||"bottom",i,Ve);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,He.x,He.y):e.canvas.createRadialGradient(He.x,He.y,0,He.x,He.y,ze(He,Ve)),d={type:a,style:l};We(d,l,t.stops,r);const c=je(i,He,Ve,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:je},{copy:Je,move:Ze,toOffsetOutBounds:$e}=B,{max:Ke,abs:ti}=Math,ei={},ii=new T,ni={};function si(t,e){let i,n,s,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,a=1.5*(t.blur||0),s=ti(t.spread||0),r=Ke(r,s+a-n),o=Ke(o,s+a+i),l=Ke(l,s+a+n),d=Ke(d,s+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function ai(t,i,n){const{shapeBounds:s}=n;let a,r;e.fullImageShadow?(Je(ei,t.bounds),Ze(ei,i.x-s.x,i.y-s.y),a=t.bounds,r=ei):(a=s,r=i),t.copyWorld(n.canvas,a,r)}const{toOffsetOutBounds:ri}=B,oi={};const li=si;const di={shadow:function(t,e,i){let n,s;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;$e(l,ni,d),r.forEach((r,_)=>{let y=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.setWorldShadow(ni.offsetX+(r.x||0)*h*y,ni.offsetY+(r.y||0)*u*y,(r.blur||0)*h*y,z.string(r.color)),s=H.getShadowTransform(t,g,i,r,ni,y),s&&g.setTransform(s),ai(g,ni,i),s&&g.resetTransform(),n=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),n=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,n,r.blendMode),p&&_<p&&g.clearWorld(n)}),g.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;ri(l,oi,d),r.forEach((r,_)=>{let y=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(oi.offsetX+(r.x||0)*h*y,oi.offsetY+(r.y||0)*u*y,(r.blur||0)*h*y),s=H.getShadowTransform(t,g,i,r,oi,y,!0),s&&g.setTransform(s),ai(g,oi,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),n=a):(g.copyWorld(i.canvas,c,l,"source-out"),n=d),g.fillWorld(n,z.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,n,r.blendMode),p&&_<p&&g.clearWorld(n)}),g.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:si,getShadowTransform:function(t,e,i,n,s,a,r){if(n.spread){const i=2*n.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return ii.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/o,1+i/l),ii}},isTransformShadow(t){},getInnerShadowSpread:li},{excludeRenderBounds:ci}=p;let hi;function ui(t,e,i,n,s,a,r,o){switch(e){case"grayscale":hi||(hi=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);gi(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":gi(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function fi(t){return t.getSameCanvas(!1,!0)}function gi(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}V.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(ui(this,r,t,s,n,a,void 0,!0),n=s=null),"clipping"!==o&&"clipping-path"!==o||ci(i,e)||i.__render(t,e),a=i.__.opacity,hi=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=fi(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=fi(t)),s||(s=fi(t)),i.__render(n,e));continue}const c=1===a&&i.__.__blendMode;c&&ui(this,r,t,s,n,a,void 0,!1),ci(i,e)||i.__render(s||t,e),c&&ui(this,r,t,s,n,a,c,!1)}ui(this,r,t,s,n,a,void 0,!0)};const pi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",_i=pi+"_#~&*+\\=|≮≯≈≠=…",yi=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function wi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const mi=wi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),xi=wi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),vi=wi(pi),bi=wi(_i),Si=wi("- —/~|┆·");var ki;!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"}(ki||(ki={}));const{Letter:Bi,Single:Ri,Before:Li,After:Ei,Symbol:Ti,Break:Pi}=ki;function Ai(t){return mi[t]?Bi:Si[t]?Pi:xi[t]?Li:vi[t]?Ei:bi[t]?Ti:yi.test(t)?Ri:Bi}const Ci={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Oi(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:Mi}=Ci,{Letter:Wi,Single:Di,Before:Fi,After:Ii,Symbol:Ui,Break:Yi}=ki;let Xi,Ni,qi,ji,zi,Gi,Hi,Vi,Qi,Ji,Zi,$i,Ki,tn,en,nn,sn,an=[];function rn(t,e){Qi&&!Vi&&(Vi=Qi),Xi.data.push({char:t,width:e}),qi+=e}function on(){ji+=qi,Xi.width=qi,Ni.words.push(Xi),Xi={data:[]},qi=0}function ln(){tn&&(en.paraNumber++,Ni.paraStart=!0,tn=!1),Qi&&(Ni.startCharSize=Vi,Ni.endCharSize=Qi,Vi=0),Ni.width=ji,nn.width?Mi(Ni):sn&&dn(),an.push(Ni),Ni={words:[]},ji=0}function dn(){ji>(en.maxWidth||0)&&(en.maxWidth=ji)}const{top:cn,right:hn,bottom:un,left:fn}=U;function gn(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const pn={getDrawData:function(t,i){A(t)||(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(a?(n=o[fn],a-=o[hn]+o[fn],!a&&(a=.01)):i.autoSizeAlign||(n=o[fn]),r?(s=o[cn],r-=o[cn]+o[un],!r&&(r=.01)):i.autoSizeAlign||(s=o[cn]));const l={bounds:{x:n,y:s,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,n){en=t,an=t.rows,nn=t.bounds,sn=!nn.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=e,{width:l}=nn;if(n.__isCharMode){const t="none"!==n.textWrap,e="break"===n.textWrap;tn=!0,Zi=null,Vi=Hi=Qi=qi=ji=0,Xi={data:[]},Ni={words:[]};for(let n=0,d=(i=[...i]).length;n<d;n++)Gi=i[n],"\n"===Gi?(qi&&on(),Ni.paraEnd=!0,ln(),tn=!0):(Ji=Ai(Gi),Ji===Wi&&"none"!==r&&(Gi=Oi(Gi,r,!qi)),Hi=o.measureText(Gi).width,s&&(s<0&&(Qi=Hi),Hi+=s),$i=Ji===Di&&(Zi===Di||Zi===Wi)||Zi===Di&&Ji!==Ii,Ki=!(Ji!==Fi&&Ji!==Di||Zi!==Ui&&Zi!==Ii),zi=tn&&a?l-a:l,t&&l&&ji+qi+Hi>zi&&(e?(qi&&on(),ji&&ln()):(Ki||(Ki=Ji===Wi&&Zi==Ii),$i||Ki||Ji===Yi||Ji===Fi||Ji===Di||qi+Hi>zi?(qi&&on(),ji&&ln()):ji&&ln()))," "===Gi&&!0!==tn&&ji+qi===0||(Ji===Yi?(" "===Gi&&qi&&on(),rn(Gi,Hi),on()):$i||Ki?(qi&&on(),rn(Gi,Hi)):rn(Gi,Hi)),Zi=Ji);qi&&on(),ji&&ln(),an.length>0&&(an[an.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{en.paraNumber++,ji=o.measureText(t).width,an.push({x:a||0,text:t,width:ji,paraStart:!0}),sn&&dn()})}(l,t,i),o&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":gn(e,"x",t[fn]);break;case"right":gn(e,"x",-t[hn])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":gn(e,"y",t[cn]);break;case"bottom":gn(e,"y",-t[un])}}(o,l,i,a,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=n,y=a*s+(h?h*(t.paraNumber-1):0),w=r;if(l&&y>_)y=Math.max(e.__autoHeight?y:_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":g+=(_-y)/2;break;case"bottom":g+=_-y}w+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,c=s;r<c;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&r>0&&(w+=h),m.y=w,w+=a,t.overflow>r&&w>y&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<n.x&&(n.x=x),v>n.width&&(n.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=y}(l,i),i.__isCharMode&&function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,__letterSpacing:r}=e,o=i&&s.includes("both"),l=o||i&&s.includes("justify"),d=l&&s.includes("letter");let c,h,u,f,g,p,_,y,w,m;n.forEach(t=>{t.words&&(g=a&&t.paraStart?a:0,y=t.words.length,l&&(m=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=y>1?h/(y-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,n,s){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,c,t.data,t.isOverflow,m&&f),m&&(w=i===y-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(l,i,a),l.overflow&&function(t,i,n,s){const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(r&&a.splice(r),s&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],l=t.x+t.width,!(n===i&&l<c));n--){if(l<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,n,a),"none"!==i.textDecoration&&function(t,e){let i,n=0;const{fontSize:s,textDecoration:a}=e;switch(t.decorationHeight=s/11,L(a)?(i=a.type,a.color&&(t.decorationColor=z.string(a.color)),a.offset&&(n=Math.min(.3*s,Math.max(a.offset,.15*-s)))):i=a,i){case"under":t.decorationY=[.15*s+n];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s+n,.35*-s]}}(l,i),l}};const _n={string:function(t,e){if(!t)return"#000";const i=D(e)&&e<1;if(A(t)){if(!i||!z.object)return t;t=z.object(t)}let n=P(t.a)?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(Q,pn),Object.assign(z,_n),Object.assign(q,Zt),Object.assign(j,Pe),Object.assign(G,Qe),Object.assign(H,di);const{setPoint:yn,addPoint:wn,toBounds:mn}=J;const xn={syncExport(t,e,i){let n;$.running=!0;try{const s=K.fileType(e),a=e.includes(".");i=K.getExportOptions(i);const{toURL:r}=tt,{download:o}=tt.origin;if("json"===s)a&&o(r(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!a||t.toJSON(i.json)};else if("svg"===s)a&&o(r(t.toSVG(),"svg"),e),n={data:!!a||t.toSVG()};else{let s,a,r=1,o=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:g,screenshot:p,padding:_,onCanvas:y}=i,w=et(i.smooth)?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),x=d&&p&&et(i.fill)?t.fill:i.fill,v=K.isOpaqueImage(e)||x,b=new it;if(p)s=!0===p?d?c.canvas.bounds:t.worldRenderBounds:p;else{let e=i.relative||(d?"inner":"local");switch(r=l.scaleX,o=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),r/=t.scaleX,o/=t.scaleY;break;case"world":r=1,o=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;r/=r/i.scaleX,o/=o/i.scaleY}s=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};nt.getScaleData(i.scale,i.size,s,S);let k=i.pixelRatio||1,{x:B,y:R,width:L,height:E}=new Z(s).scale(S.scaleX,S.scaleY);f&&(B+=f.x,R+=f.y,L=f.width,E=f.height,f.rotation&&b.rotateOfInner({x:B,y:R},-f.rotation));const T={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-B,-R).withScale(1/r*S.scaleX,1/o*S.scaleY)};let P,A=st.canvas({width:Math.floor(L),height:Math.floor(E),pixelRatio:k,smooth:w,contextSettings:m});u&&(P=t,P.__worldOpacity=0,t=c||t,T.bounds=A.bounds),A.save();const C=h&&!et(x),O=t.get("fill");if(C&&(t.fill=""),tt.render(t,A,T),C&&(t.fill=O),A.restore(),P&&P.__updateWorldOpacity(),g){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,r,o=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=o%e,a=(o-s)/e,r?wn(r,s,a):yn(r={},s,a)),o++;const l=new Z;return r&&(mn(r,l),l.scale(1/t.pixelRatio).ceil()),l}(A);const t=A,{width:e,height:i}=a,n={x:0,y:0,width:e,height:i,pixelRatio:k};A=st.canvas(n),A.copyWorld(t,a,n),t.destroy()}if(_){const[t,e,i,n]=nt.fourNumber(_),s=A,{width:a,height:r}=s;A=st.canvas({width:a+n+e,height:r+t+i,pixelRatio:k}),A.copyWorld(s,s.bounds,{x:n,y:t,width:a,height:r}),s.destroy()}v&&A.fillWorld(A.bounds,x||"#FFFFFF","destination-over"),y&&y(A);n={data:"canvas"===e?A:A.export(e,i),width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:a};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){n={data:"",error:t}}return $.running=!1,n},export(t,e,i){return $.running=!0,function(t){vn||(vn=new at);return new Promise(e=>{vn.add(()=>ut(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(n=>new Promise(s=>{const a=()=>ut(this,void 0,void 0,function*(){if(!rt.isComplete)return tt.requestRender(a);const r=$.syncExport(t,e,i);r.data instanceof Promise&&(r.data=yield r.data),n(r),s()});t.updateLayout(),bn(t);const{leafer:r}=t;r?r.waitViewCompleted(a):a()}))}};let vn;function bn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>bn(t))}const Sn=ot.prototype,kn=lt.get("@leafer-in/export");Sn.export=function(t,e){const{quality:i,blob:n}=K.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Sn.toBlob=function(t,e){return new Promise(i=>{tt.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{kn.error(t),i(null)})})},Sn.toDataURL=function(t,e){return tt.origin.canvasToDataURL(this.view,t,e)},Sn.saveAs=function(t,e){return new Promise(i=>{tt.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{kn.error(t),i(!1)})})},dt.add("export"),Object.assign($,xn),ct.prototype.export=function(t,e){return $.export(this,t,e)},ct.prototype.syncExport=function(t,e){return $.syncExport(this,t,e)},Object.assign(n,{interaction:(t,e,i,n)=>new N(t,e,i,n),hitCanvas:(t,e)=>new ft(t,e),hitCanvasManager:()=>new X});export{Lt as Layouter,ft as LeaferCanvas,ht as PathNodeHandleType,Ot as Picker,Tt as Renderer,Mt as Selector,_t as Watcher,pt as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,defineKey as a,FileHelper as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as y,Debug as w,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,PointHelper as k,BoundsHelper as B,Plugin as R,isObject as L,FourNumberHelper as E,Matrix as T,isUndefined as P,isString as A,ImageEvent as C,MatrixHelper as O,MathHelper as M,AlignHelper as W,isNumber as D,getMatrixData as F,AroundHelper as I,OneRadian as U,Direction4 as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{writeFileSync as X}from"fs";import{HitCanvasManager as N,InteractionBase as q}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as j,PaintImage as z,ColorConvert as G,PaintGradient as H,Effect as V,Group as Q,TextConvert as J,TwoPointBoundsHelper as Z,Bounds as $,Export as K,FileHelper as tt,Platform as et,isUndefined as it,Matrix as nt,MathHelper as st,Creator as at,TaskProcessor as rt,Resource as ot,LeaferCanvasBase as lt,Debug as dt,Plugin as ct,UI as ht}from"@leafer-ui/draw";var ut;function ft(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(ut||(ut={})),"function"==typeof SuppressedError&&SuppressedError;class gt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function pt(t){return ft(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})}function _t(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL?t.toDataURL(r.mimeType(e),i):(t.toDataURLSync||t.toURLSync)(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:(t,i,s)=>n(e.image.getRealURL(t)),loadContent:pt},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(r.mimeType(e),i),canvasToBolb:(t,e,i)=>ft(this,void 0,void 0,function*(){return t.toBuffer(r.mimeType(e),i)}),canvasSaveAs:(t,e,i)=>ft(this,void 0,void 0,function*(){return X(e,t.toBuffer(r.mimeType(r.fileType(e)),i))}),download(t,e){},loadImage:(t,i,s)=>n(e.image.getRealURL(t)),loadContent:pt}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new gt(t,e),image:t=>new s(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class yt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:wt,updateBounds:mt,updateChange:xt}=f,{pushAllChildBranch:vt,pushAllParent:bt}=g;const{worldBounds:St}=p;class kt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,y(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,St)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,St),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:Bt,updateAllChange:Rt}=f,Lt=w.get("Layouter");class Et{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){Lt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Lt.warn("layouting"):this.times>3?Lt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(n);o.forEach(t=>t.setBefore()),i.emitEvent(new x(s,o,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(wt(t,!0),e.add(t),t.isBranch&&vt(t,e),bt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),bt(t,e)))})}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||mt(n[t])}mt(i)}})}(this.__levelList),function(t){t.list.forEach(xt)}(n),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),Et.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(n,a,this.times)),e.emitEvent(new x(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){Bt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),Rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new kt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new kt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Tt=w.get("Renderer");class Pt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Tt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,Tt.error(t)}Tt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Tt.warn("rendering");if(this.times>3)return Tt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(Pt.clipSpread).ceil();const{ceilPartPixel:a}=this.config;i.clipWorld(n,a),i.clearWorld(n,a),this.__render(n,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:n,target:s}=this,a=t.includes(s.__world),r=a?{includes:a}:{bounds:t,includes:a};this.needFill&&n.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(n,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(s,n,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&t>n)return e.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Tt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Pt.clipSpread=10;const At={},{copyRadiusPoint:Ct}=k,{hitRadiusPoint:Ot}=B;class Mt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,s,!!i.findList),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),n?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,n){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return n?null:i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o,i=[],{target:n}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==n););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==n););}),n&&e.add(n),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,r=i.length;t<r;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n,s;const{point:a}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],s=i.__,s.visible&&(!e||s.mask))if(n=Ot(i.__world,s.hitRadius?Ct(At,a,s.hitRadius):a),i.isBranch){if(n||i.__ignoreHitWorld){if(i.isBranchLeaf&&s.__clipAfterFill&&!i.__hitWorld(a,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,a)}}else n&&this.hitChild(i,a)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask){let i,s=[];const{children:a}=n;for(let n=0,r=a.length;n<r;n++)if(i=a[n],i.__.mask&&s.push(i),i===t){if(s&&!s.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Wt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Mt(this.target=t,this),this.finder=n.finder&&n.finder(t,this.config)}getByPoint(t,i,n){const{target:s,picker:a}=this;return e.backgrounder&&s&&s.updateLayout(),a.getByPoint(t,i,n)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Dt(t,e,i){t.__.__font?j.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Ft(t,e,i,n,s){const a=i.__;L(t)?j.drawStrokesStyle(t,e,!1,i,n,s):(n.setStroke(t,a.__strokeWidth*e,a),n.stroke()),a.__useArrow&&j.strokeArrow(t,i,n,s)}function It(t,e,i,n,s){const a=i.__;L(t)?j.drawStrokesStyle(t,e,!0,i,n,s):(n.setStroke(t,a.__strokeWidth*e,a),j.drawTextStroke(i,n,s))}function Ut(t,e,i,n,s){const a=n.getSameCanvas(!0,!0);a.font=i.__.__font,It(t,2,i,a,s),a.blendMode="outside"===e?"destination-out":"destination-in",j.fillText(i,a,s),a.blendMode="normal",f.copyCanvasByWorld(i,n,a),a.recycle(i.__nowWorld)}Object.assign(n,{watcher:(t,e)=>new yt(t,e),layouter:(t,e)=>new Et(t,e),renderer:(t,e,i)=>new Pt(t,e,i),selector:(t,e)=>new Wt(t,e)}),e.layout=Et.fullLayout,e.render=function(t,e,i){const n=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,n))};const{getSpread:Yt,copyAndSpread:Xt,toOuterOf:Nt,getOuterOf:qt,getByMove:jt,move:zt,getIntersectData:Gt}=B,Ht={};let Vt;const{stintSet:Qt}=l,{hasTransparent:Jt}=G;function Zt(t,e,i){if(!L(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:s}=i.__layout,{type:a}=e;switch(a){case"image":case"film":case"video":if(!e.url)return;n=z.image(i,t,e,s,!Vt||!Vt[e.url]),"image"!==a&&z[a](n);break;case"linear":n=H.linearGradient(e,s);break;case"radial":n=H.radialGradient(e,s);break;case"angular":n=H.conicGradient(e,s);break;case"solid":const{color:r,opacity:o}=e;n={type:a,style:G.string(r,o)};break;default:P(e.r)||(n={type:"solid",style:G.string(e)})}if(n&&(n.originPaint=e,A(n.style)&&Jt(n.style)&&(n.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}return n}const $t={compute:function(t,e){const i=e.__,n=[];let s,a,r,o=i.__input[t];y(o)||(o=[o]),Vt=z.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)(i=Zt(t,o[s],e))&&(n.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=n.length?n:void 0,n.length?(n.every(t=>t.isTransparent)&&(n.some(t=>t.image)&&(s=!0),a=!0),"fill"===t?(Qt(i,"__isAlphaPixelFill",s),Qt(i,"__isTransparentFill",a)):(Qt(i,"__isAlphaPixelStroke",s),Qt(i,"__isTransparentStroke",a),Qt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,n){i.fillStyle=t,Dt(e,i,n)},fills:function(t,e,i,n){let s,a,r;for(let o=0,l=t.length;o<l;o++){if(s=t[o],a=s.originPaint,s.image){if(r?r++:r=1,z.checkImage(s,!e.__.__font,e,i,n))continue;if(!s.style){1===r&&s.image.isPlacehold&&e.drawImagePlaceholder(s,i,n);continue}}if(i.fillStyle=s.style,s.transform||a.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),a.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0,a.scaleFixed,!1);1!==t&&i.scale(t,n)}a.blendMode&&(i.blendMode=a.blendMode),Dt(e,i,n),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),Dt(e,i,n),i.restoreBlendMode()):Dt(e,i,n)}},fillPathOrText:Dt,fillText:function(t,e,i){const n=t.__,{rows:s,decorationY:a}=n.__textDrawData;let r;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,i=s.length;t<i;t++)r=s[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:i}=n.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>a.forEach(n=>e.fillRect(t.x,t.y+n,t.width,i)))}},stroke:function(t,e,i,n){const s=e.__;if(s.__strokeWidth)if(s.__font)j.strokeText(t,e,i,n);else switch(s.strokeAlign){case"center":Ft(t,1,e,i,n);break;case"inside":!function(t,e,i,n){i.save(),i.clipUI(e),Ft(t,2,e,i,n),i.restore()}(t,e,i,n);break;case"outside":!function(t,e,i,n){const s=e.__;if(s.__fillAfterStroke)Ft(t,2,e,i,n);else{const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),Ft(t,2,e,r,n),r.clipUI(s),r.clearWorld(a),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,n)}},strokes:function(t,e,i,n){j.stroke(t,e,i,n)},strokeText:function(t,e,i,n){switch(e.__.strokeAlign){case"center":It(t,1,e,i,n);break;case"inside":Ut(t,"inside",e,i,n);break;case"outside":e.__.__fillAfterStroke?It(t,2,e,i,n):Ut(t,"outside",e,i,n)}},drawTextStroke:function(t,e,i){let n,s=t.__.__textDrawData;const{rows:a,decorationY:r}=s;for(let t=0,i=a.length;t<i;t++)n=a[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.strokeText(t.char,t.x,n.y)});if(r){const{decorationHeight:t}=s;a.forEach(i=>r.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}},drawStrokesStyle:function(t,e,i,n,s,a){let r;const o=n.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!z.checkImage(r,!1,n,s,a))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):s.setStroke(r.style,o.__strokeWidth*e,o)}else s.strokeStyle=r.style;r.originPaint.blendMode?(s.saveBlendMode(r.originPaint.blendMode),i?j.drawTextStroke(n,s,a):s.stroke(),s.restoreBlendMode()):i?j.drawTextStroke(n,s,a):s.stroke()}},shape:function(t,i,n){const s=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;Nt(o.strokeSpread?(Xt(Ht,o.boxBounds,o.strokeSpread),Ht):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=s,d=f=l,c=r;else{let s;if(e.fullImageShadow)s=l;else{const t=o.renderShapeSpread?Yt(a,E.swapAndScale(o.renderShapeSpread,p,_)):a;s=Gt(t,l)}u=a.getFitMatrix(s);let{a:y,d:w}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,n),p*=y,_*=w),f=qt(l,u),d=jt(f,-u.e,-u.f),c=qt(r,u),zt(c,-u.e,-u.f);const m=n.matrix;m?(h=new T(u),h.multiply(m),y*=m.scaleX,w*=m.scaleY):h=u,h.withScale(y,w),n=Object.assign(Object.assign({},n),{matrix:h})}return t.__renderShape(s,n),{canvas:s,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Kt,te=new _;const{isSame:ee}=B;function ie(t,e,i,n,s,a){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=n.width/o.pixelRatio,o.__naturalHeight=n.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate("width"),f.updateBounds(t),t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),!s.data){z.createData(s,n,i,a);const{transform:t}=s.data,{opacity:e,blendMode:r}=i,l=t&&!t.onlyScale||o.path||o.cornerRadius;(l||e&&e<1||r)&&(s.complex=!l||2)}return i.filter&&z.applyFilter(s,n,i.filter,t),r}function ne(t,e){re(t,C.LOAD,e)}function se(t,e){re(t,C.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,C.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function oe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,translate:de}=O,ce=new _,he={},ue={};function fe(t,e,i,n){const s=A(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&s<0?0:s}let ge={},pe=F();const{get:_e,set:ye,rotateOfOuter:we,translate:me,scaleOfOuter:xe,multiplyParent:ve,scale:be,rotate:Se,skew:ke}=O;function Be(t,e,i,n,s,a,r,o){r&&Se(t,r),o&&ke(t,o.x,o.y),s&&be(t,s,a),me(t,e.x+i,e.y+n)}const{get:Re,scale:Le,copy:Ee}=O,{getFloorScale:Te}=M,{abs:Pe}=Math;const Ae={image:function(t,e,i,n,s){let a,r;const o=b.get(i,i.type);return Kt&&i===Kt.paint&&ee(n,Kt.boxBounds)?a=Kt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Kt=o.use>1?{leafPaint:a,paint:i,boxBounds:te.set(n)}:null),(s||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(ie(t,e,i,o,a,n),s&&(ne(t,r),se(t,r))):o.error?s&&ae(t,r,o.error):(s&&(oe(t,!0),ne(t,r)),a.loadId=o.load(()=>{oe(t,!1),t.destroyed||(ie(t,e,i,o,a,n)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),se(t,r)),a.loadId=void 0},e=>{oe(t,!1),ae(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,i,n,s,a){const{scaleX:r,scaleY:o}=z.getImageRenderScaleData(t,n,s,a),l=t.film?t.nowIndex:r+"-"+o,{image:d,data:c,originPaint:h}=t,{exporting:u,snapshot:f}=a;return!(!c||t.patternId===l&&!u||f)&&(i&&(c.repeat?i=!1:h.changeful||t.film||"miniapp"===e.name||u||(i=e.image.isLarge(d,r,o)||d.width*r>8096||d.height*o>8096)),i?(n.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),z.drawImage(t,r,o,n,s,a),!0):(!t.style||h.sync||u?z.createPattern(t,n,s,a):z.createPatternTask(t,n,s,a),!1))},drawImage:function(t,e,i,n,s,a){const{data:r,image:o,complex:l}=t;let{width:d,height:c}=o;if(l){const{blendMode:a,opacity:h}=t.originPaint,{transform:u}=r;s.save(),2===l&&s.clipUI(n),a&&(s.blendMode=a),h&&(s.opacity*=h),u&&s.transform(u),o.render(s,0,0,d,c,n,t,e,i),s.restore()}else r.scaleX&&(d*=r.scaleX,c*=r.scaleY),o.render(s,0,0,d,c,n,t,e,i)},getImageRenderScaleData:function(t,e,i,n){const s=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:a}=t;if(i){const{pixelRatio:t}=i;s.scaleX*=t,s.scaleY*=t}return a&&a.scaleX&&(s.scaleX*=Math.abs(a.scaleX),s.scaleY*=Math.abs(a.scaleY)),s},recycleImage:function(t,e){const i=e["_"+t];if(y(i)){let n,s,a,r,o;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,b.recyclePaint(n),e.__willDestroy&&s.parent&&z.recycleFilter(s,e.__leaf),s.loading&&(r||(r=e.__input&&e.__input[t]||[],y(r)||(r=[r])),s.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createPatternTask:function(t,e,i,n){t.patternTask||(t.patternTask=b.patternTasker.add(()=>ft(this,void 0,void 0,function*(){z.createPattern(t,e,i,n),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,n,s){let{scaleX:a,scaleY:r}=z.getImageRenderScaleData(t,i,n,s),o=t.film?t.nowIndex:a+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,a,r)||t.data.repeat)){const{image:n,data:s}=t,{opacity:l}=t.originPaint,{transform:d,gap:c}=s,h=z.getPatternFixScale(t,a,r);let u,f,g,{width:p,height:_}=n;h&&(a*=h,r*=h),p*=a,_*=r,c&&(f=c.x*a/Pe(s.scaleX||1),g=c.y*r/Pe(s.scaleY||1)),(d||1!==a||1!==r)&&(a*=Te(p+(f||0)),r*=Te(_+(g||0)),u=Re(),d&&Ee(u,d),Le(u,1/a,1/r));const y=n.getCanvas(p,_,l,void 0,f,g,i.leafer&&i.leafer.config.smooth,s.interlace),w=n.getPattern(y,s.repeat||e.origin.noRepeat||"no-repeat",u,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,n){const{image:s}=t;let a,r=e.image.maxPatternSize,o=s.width*s.height;return s.isSVG?i>1&&(a=Math.ceil(i)/i):r>o&&(r=o),(o*=i*n)>r&&(a=Math.sqrt(r/o)),a},createData:function(t,e,i,n){t.data=z.getPatternData(i,n,e)},getPatternData:function(t,e,i){t.padding&&(e=ce.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:n,height:s}=i,{mode:a,align:r,offset:o,scale:l,size:d,rotation:c,skew:h,clipSize:u,repeat:f,gap:g,interlace:p}=t,_=e.width===n&&e.height===s,y={mode:a},w="center"!==r&&(c||0)%180==90;let m,x;switch(B.set(ue,0,0,w?s:n,w?n:s),a&&"cover"!==a&&"fit"!==a?((l||d)&&(M.getScaleData(l,d,i,he),m=he.scaleX,x=he.scaleY),(r||g||f)&&(m&&B.scale(ue,m,x,!0),r&&W.toPoint(r,ue,e,ue,!0,!0))):_&&!c||(m=x=B.getFitScale(e,ue,"fit"!==a),B.put(e,i,r,m,!1,ue),B.scale(ue,m,x,!0)),o&&k.move(ue,o),a){case"stretch":_?m&&(m=x=void 0):(m=e.width/n,x=e.height/s,z.stretchMode(y,e,m,x));break;case"normal":case"clip":if(ue.x||ue.y||m||u||c||h){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),z.clipMode(y,e,ue.x,ue.y,m,x,c,h,t,i),t&&(m=m?m*t:t,x=x?x*i:i)}break;case"repeat":(!_||m||c||h)&&z.repeatMode(y,e,n,s,ue.x,ue.y,m,x,c,h,r,t.freeTransform),f||(y.repeat="repeat");const i=L(f);(g||i)&&(y.gap=function(t,e,i,n,s){let a,r;L(t)?(a=t.x,r=t.y):a=r=t;return{x:fe(a,i,s.width,e&&e.x),y:fe(r,n,s.height,e&&e.y)}}(g,i&&f,ue.width,ue.height,e));break;default:m&&z.fillOrFitMode(y,e,ue.x,ue.y,m,x,c)}return y.transform||(e.x||e.y)&&de(y.transform=le(),e.x,e.y),m&&(y.scaleX=m,y.scaleY=x),f&&(y.repeat=A(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),p&&(y.interlace=D(p)||"percent"===p.type?{type:"x",offset:p}:p),y},stretchMode:function(t,e,i,n){const s=_e(),{x:a,y:r}=e;a||r?me(s,a,r):i>0&&n>0&&(s.onlyScale=!0),be(s,i,n),t.transform=s},fillOrFitMode:function(t,e,i,n,s,a,r){const o=_e();me(o,e.x+i,e.y+n),be(o,s,a),r&&we(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,n,s,a,r,o,l,d){const c=_e();Be(c,e,i,n,s,a,r,o),l&&(r||o?(ye(pe),xe(pe,e,l,d),ve(c,pe)):xe(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,n,s,a,r,o,l,d,c,h){const u=_e();if(h)Be(u,e,s,a,r,o,l,d);else{if(l)if("center"===c)we(u,{x:i/2,y:n/2},l);else switch(Se(u,l),l){case 90:me(u,n,0);break;case 180:me(u,i,n);break;case 270:me(u,0,i)}ge.x=e.x+s,ge.y=e.y+a,me(u,ge.x,ge.y),r&&xe(u,ge,r,o)}t.transform=u}},{toPoint:Ce}=I,{hasTransparent:Oe}=G,Me={},We={};function De(t,e,i,n){if(i){let s,a,r,o;for(let t=0,l=i.length;t<l;t++)s=i[t],A(s)?(r=t/(l-1),a=G.string(s,n)):(r=s.offset,a=G.string(s.color,n)),e.addColorStop(r,a),!o&&Oe(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Fe,getDistance:Ie}=k,{get:Ue,rotateOfOuter:Ye,scaleOfOuter:Xe}=O,{toPoint:Ne}=I,qe={},je={};function ze(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Fe(e,i);a=Ue(),s?(Xe(a,e,r/o*(n||1),1),Ye(a,e,t+90)):(Xe(a,e,1,r/o*(n||1)),Ye(a,e,t))}return a}const{getDistance:Ge}=k,{toPoint:He}=I,Ve={},Qe={};const Je={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:r}=t;Ce(n||"top",i,Me),Ce(s||"bottom",i,We);const o=e.canvas.createLinearGradient(Me.x,Me.y,We.x,We.y),l={type:a,style:o};return De(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=t;Ne(n||"center",i,qe),Ne(s||"bottom",i,je);const l=e.canvas.createRadialGradient(qe.x,qe.y,0,qe.x,qe.y,Ie(qe,je)),d={type:a,style:l};De(d,l,t.stops,r);const c=ze(i,qe,je,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,rotation:o,stretch:l}=t;He(n||"center",i,Ve),He(s||"bottom",i,Qe);const d=e.conicGradientSupport?e.canvas.createConicGradient(o?o*U:0,Ve.x,Ve.y):e.canvas.createRadialGradient(Ve.x,Ve.y,0,Ve.x,Ve.y,Ge(Ve,Qe)),c={type:a,style:d};De(c,d,t.stops,r);const h=ze(i,Ve,Qe,l||1,e.conicGradientRotate90);return h&&(c.transform=h),c},getTransform:ze},{copy:Ze,move:$e,toOffsetOutBounds:Ke}=B,{max:ti,abs:ei}=Math,ii={},ni=new T,si={};function ai(t,e){let i,n,s,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,a=1.5*(t.blur||0),s=ei(t.spread||0),r=ti(r,s+a-n),o=ti(o,s+a+i),l=ti(l,s+a+n),d=ti(d,s+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function ri(t,i,n){const{shapeBounds:s}=n;let a,r;e.fullImageShadow?(Ze(ii,t.bounds),$e(ii,i.x-s.x,i.y-s.y),a=t.bounds,r=ii):(a=s,r=i),t.copyWorld(n.canvas,a,r)}const{toOffsetOutBounds:oi}=B,li={};const di=ai;const ci={shadow:function(t,e,i){let n,s;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ke(l,si,d),r.forEach((r,_)=>{let y=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.setWorldShadow(si.offsetX+(r.x||0)*h*y,si.offsetY+(r.y||0)*u*y,(r.blur||0)*h*y,G.string(r.color)),s=V.getShadowTransform(t,g,i,r,si,y),s&&g.setTransform(s),ri(g,si,i),s&&g.resetTransform(),n=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),n=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,n,r.blendMode),p&&_<p&&g.clearWorld(n)}),g.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;oi(l,li,d),r.forEach((r,_)=>{let y=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(li.offsetX+(r.x||0)*h*y,li.offsetY+(r.y||0)*u*y,(r.blur||0)*h*y),s=V.getShadowTransform(t,g,i,r,li,y,!0),s&&g.setTransform(s),ri(g,li,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),n=a):(g.copyWorld(i.canvas,c,l,"source-out"),n=d),g.fillWorld(n,G.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,n,r.blendMode),p&&_<p&&g.clearWorld(n)}),g.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:ai,getShadowTransform:function(t,e,i,n,s,a,r){if(n.spread){const i=2*n.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return ni.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/o,1+i/l),ni}},isTransformShadow(t){},getInnerShadowSpread:di},{excludeRenderBounds:hi}=p;let ui;function fi(t,e,i,n,s,a,r,o){switch(e){case"grayscale":ui||(ui=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);pi(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":pi(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function gi(t){return t.getSameCanvas(!1,!0)}function pi(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}Q.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(fi(this,r,t,s,n,a,void 0,!0),n=s=null),"clipping"!==o&&"clipping-path"!==o||hi(i,e)||i.__render(t,e),a=i.__.opacity,ui=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=gi(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=gi(t)),s||(s=gi(t)),i.__render(n,e));continue}const c=1===a&&i.__.__blendMode;c&&fi(this,r,t,s,n,a,void 0,!1),hi(i,e)||i.__render(s||t,e),c&&fi(this,r,t,s,n,a,c,!1)}fi(this,r,t,s,n,a,void 0,!0)};const _i=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",yi=_i+"_#~&*+\\=|≮≯≈≠=…",wi=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function mi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const xi=mi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),vi=mi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),bi=mi(_i),Si=mi(yi),ki=mi("- —/~|┆·");var Bi;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Bi||(Bi={}));const{Letter:Ri,Single:Li,Before:Ei,After:Ti,Symbol:Pi,Break:Ai}=Bi;function Ci(t){return xi[t]?Ri:ki[t]?Ai:vi[t]?Ei:bi[t]?Ti:Si[t]?Pi:wi.test(t)?Li:Ri}const Oi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Mi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Wi}=Oi,{Letter:Di,Single:Fi,Before:Ii,After:Ui,Symbol:Yi,Break:Xi}=Bi;let Ni,qi,ji,zi,Gi,Hi,Vi,Qi,Ji,Zi,$i,Ki,tn,en,nn,sn,an,rn=[];function on(t,e){Ji&&!Qi&&(Qi=Ji),Ni.data.push({char:t,width:e}),ji+=e}function ln(){zi+=ji,Ni.width=ji,qi.words.push(Ni),Ni={data:[]},ji=0}function dn(){en&&(nn.paraNumber++,qi.paraStart=!0,en=!1),Ji&&(qi.startCharSize=Qi,qi.endCharSize=Ji,Qi=0),qi.width=zi,sn.width?Wi(qi):an&&cn(),rn.push(qi),qi={words:[]},zi=0}function cn(){zi>(nn.maxWidth||0)&&(nn.maxWidth=zi)}const{top:hn,right:un,bottom:fn,left:gn}=Y;function pn(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const _n={getDrawData:function(t,i){A(t)||(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(a?(n=o[gn],a-=o[un]+o[gn],!a&&(a=.01)):i.autoSizeAlign||(n=o[gn]),r?(s=o[hn],r-=o[hn]+o[fn],!r&&(r=.01)):i.autoSizeAlign||(s=o[hn]));const l={bounds:{x:n,y:s,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,n){nn=t,rn=t.rows,sn=t.bounds,an=!sn.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=e,{width:l}=sn;if(n.__isCharMode){const t="none"!==n.textWrap,e="break"===n.textWrap;en=!0,$i=null,Qi=Vi=Ji=ji=zi=0,Ni={data:[]},qi={words:[]};for(let n=0,d=(i=[...i]).length;n<d;n++)Hi=i[n],"\n"===Hi?(ji&&ln(),qi.paraEnd=!0,dn(),en=!0):(Zi=Ci(Hi),Zi===Di&&"none"!==r&&(Hi=Mi(Hi,r,!ji)),Vi=o.measureText(Hi).width,s&&(s<0&&(Ji=Vi),Vi+=s),Ki=Zi===Fi&&($i===Fi||$i===Di)||$i===Fi&&Zi!==Ui,tn=!(Zi!==Ii&&Zi!==Fi||$i!==Yi&&$i!==Ui),Gi=en&&a?l-a:l,t&&l&&zi+ji+Vi>Gi&&(e?(ji&&ln(),zi&&dn()):(tn||(tn=Zi===Di&&$i==Ui),Ki||tn||Zi===Xi||Zi===Ii||Zi===Fi||ji+Vi>Gi?(ji&&ln(),zi&&dn()):zi&&dn()))," "===Hi&&!0!==en&&zi+ji===0||(Zi===Xi?(" "===Hi&&ji&&ln(),on(Hi,Vi),ln()):Ki||tn?(ji&&ln(),on(Hi,Vi)):on(Hi,Vi)),$i=Zi);ji&&ln(),zi&&dn(),rn.length>0&&(rn[rn.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{nn.paraNumber++,zi=o.measureText(t).width,rn.push({x:a||0,text:t,width:zi,paraStart:!0}),an&&cn()})}(l,t,i),o&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":pn(e,"x",t[gn]);break;case"right":pn(e,"x",-t[un])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":pn(e,"y",t[hn]);break;case"bottom":pn(e,"y",-t[fn])}}(o,l,i,a,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=n,y=a*s+(h?h*(t.paraNumber-1):0),w=r;if(l&&y>_)y=Math.max(e.__autoHeight?y:_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":g+=(_-y)/2;break;case"bottom":g+=_-y}w+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,c=s;r<c;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&r>0&&(w+=h),m.y=w,w+=a,t.overflow>r&&w>y&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<n.x&&(n.x=x),v>n.width&&(n.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=y}(l,i),i.__isCharMode&&function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,__letterSpacing:r}=e,o=i&&s.includes("both"),l=o||i&&s.includes("justify"),d=l&&s.includes("letter");let c,h,u,f,g,p,_,y,w,m;n.forEach(t=>{t.words&&(g=a&&t.paraStart?a:0,y=t.words.length,l&&(m=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=y>1?h/(y-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,n,s){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,c,t.data,t.isOverflow,m&&f),m&&(w=i===y-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(l,i,a),l.overflow&&function(t,i,n,s){const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(r&&a.splice(r),s&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],l=t.x+t.width,!(n===i&&l<c));n--){if(l<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,n,a),"none"!==i.textDecoration&&function(t,e){let i,n=0;const{fontSize:s,textDecoration:a}=e;switch(t.decorationHeight=s/11,L(a)?(i=a.type,a.color&&(t.decorationColor=G.string(a.color)),a.offset&&(n=Math.min(.3*s,Math.max(a.offset,.15*-s)))):i=a,i){case"under":t.decorationY=[.15*s+n];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s+n,.35*-s]}}(l,i),l}};const yn={string:function(t,e){if(!t)return"#000";const i=D(e)&&e<1;if(A(t)){if(!i||!G.object)return t;t=G.object(t)}let n=P(t.a)?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(J,_n),Object.assign(G,yn),Object.assign(j,$t),Object.assign(z,Ae),Object.assign(H,Je),Object.assign(V,ci);const{setPoint:wn,addPoint:mn,toBounds:xn}=Z;const vn={syncExport(t,e,i){let n;K.running=!0;try{const s=tt.fileType(e),a=e.includes(".");i=tt.getExportOptions(i);const{toURL:r}=et,{download:o}=et.origin;if("json"===s)a&&o(r(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!a||t.toJSON(i.json)};else if("svg"===s)a&&o(r(t.toSVG(),"svg"),e),n={data:!!a||t.toSVG()};else{let s,a,r=1,o=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:g,screenshot:p,padding:_,onCanvas:y}=i,w=it(i.smooth)?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),x=d&&p&&it(i.fill)?t.fill:i.fill,v=tt.isOpaqueImage(e)||x,b=new nt;if(p)s=!0===p?d?c.canvas.bounds:t.worldRenderBounds:p;else{let e=i.relative||(d?"inner":"local");switch(r=l.scaleX,o=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),r/=t.scaleX,o/=t.scaleY;break;case"world":r=1,o=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;r/=r/i.scaleX,o/=o/i.scaleY}s=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};st.getScaleData(i.scale,i.size,s,S);let k=i.pixelRatio||1,{x:B,y:R,width:L,height:E}=new $(s).scale(S.scaleX,S.scaleY);f&&(B+=f.x,R+=f.y,L=f.width,E=f.height,f.rotation&&b.rotateOfInner({x:B,y:R},-f.rotation));const T={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-B,-R).withScale(1/r*S.scaleX,1/o*S.scaleY)};let P,A=at.canvas({width:Math.floor(L),height:Math.floor(E),pixelRatio:k,smooth:w,contextSettings:m});u&&(P=t,P.__worldOpacity=0,t=c||t,T.bounds=A.bounds),A.save();const C=h&&!it(x),O=t.get("fill");if(C&&(t.fill=""),et.render(t,A,T),C&&(t.fill=O),A.restore(),P&&P.__updateWorldOpacity(),g){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,r,o=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=o%e,a=(o-s)/e,r?mn(r,s,a):wn(r={},s,a)),o++;const l=new $;return r&&(xn(r,l),l.scale(1/t.pixelRatio).ceil()),l}(A);const t=A,{width:e,height:i}=a,n={x:0,y:0,width:e,height:i,pixelRatio:k};A=at.canvas(n),A.copyWorld(t,a,n),t.destroy()}if(_){const[t,e,i,n]=st.fourNumber(_),s=A,{width:a,height:r}=s;A=at.canvas({width:a+n+e,height:r+t+i,pixelRatio:k}),A.copyWorld(s,s.bounds,{x:n,y:t,width:a,height:r}),s.destroy()}v&&A.fillWorld(A.bounds,x||"#FFFFFF","destination-over"),y&&y(A);n={data:"canvas"===e?A:A.export(e,i),width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:a};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){n={data:"",error:t}}return K.running=!1,n},export(t,e,i){return K.running=!0,function(t){bn||(bn=new rt);return new Promise(e=>{bn.add(()=>ft(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(n=>new Promise(s=>{const a=()=>ft(this,void 0,void 0,function*(){if(!ot.isComplete)return et.requestRender(a);const r=K.syncExport(t,e,i);r.data instanceof Promise&&(r.data=yield r.data),n(r),s()});t.updateLayout(),Sn(t);const{leafer:r}=t;r?r.waitViewCompleted(a):a()}))}};let bn;function Sn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Sn(t))}const kn=lt.prototype,Bn=dt.get("@leafer-in/export");kn.export=function(t,e){const{quality:i,blob:n}=tt.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},kn.toBlob=function(t,e){return new Promise(i=>{et.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{Bn.error(t),i(null)})})},kn.toDataURL=function(t,e){return et.origin.canvasToDataURL(this.view,t,e)},kn.saveAs=function(t,e){return new Promise(i=>{et.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{Bn.error(t),i(!1)})})},ct.add("export"),Object.assign(K,vn),ht.prototype.export=function(t,e){return K.export(this,t,e)},ht.prototype.syncExport=function(t,e){return K.syncExport(this,t,e)},Object.assign(n,{interaction:(t,e,i,n)=>new q(t,e,i,n),hitCanvas:(t,e)=>new gt(t,e),hitCanvasManager:()=>new N});export{Et as Layouter,gt as LeaferCanvas,ut as PathNodeHandleType,Mt as Picker,Pt as Renderer,Wt as Selector,yt as Watcher,_t as useCanvas};
2
2
  //# sourceMappingURL=node.esm.min.js.map