@leafer-ui/node 1.5.1 → 1.5.2

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.
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as o,defineKey as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as R,MatrixHelper as k,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as C}from"fs";import{HitCanvasManager as O,InteractionBase as M}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as U,Paint as X,Effect as N,TwoPointBoundsHelper as j,Bounds as z,FileHelper as G,Platform as H,Matrix as q,MathHelper as V,Creator as Q,TaskProcessor as J,Resource as Z,LeaferCanvasBase as $,Debug as K,Plugin as tt,UI as et}from"@leafer-ui/draw";function it(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class nt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:st,fileType:ot}=n;function at(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.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},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(st(e),i),canvasToBolb:(t,e,i)=>it(this,void 0,void 0,(function*(){return t.toBuffer(st(e),i)})),canvasSaveAs:(t,e,i)=>it(this,void 0,void 0,(function*(){return C(e,t.toBuffer(st(ot(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new nt(t,e),image:t=>new o(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class rt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:dt,updateBounds:lt,updateAllWorldOpacity:ht}=f,{pushAllChildBranch:ct,pushAllParent:ut}=g;const{worldBounds:ft}=p,gt={x:0,y:0,width:1e5,height:1e5};class pt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ft)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(gt):this.afterBounds.setListWithFn(t,ft),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:_t,updateAllChange:wt}=f,yt=w.get("Layouter");class mt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){yt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?yt.warn("layouting"):this.times>3?yt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,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?(dt(t,!0),e.add(t),t.isBranch&&ct(t,e),ut(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ut(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||lt(n[t])}lt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&ht(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(o,r,this.times)),i.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(i,o,this.times)),mt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){_t(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),wt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new pt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new pt(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(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const vt=w.get("Renderer");class xt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,vt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,vt.error(t)}vt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return vt.warn("rendering");if(this.times>3)return vt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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=t.includes(this.target.__world),o=new _(n);i.save(),s&&!w.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(n),w.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||vt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:bt}=B;class Bt{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,d=this.getBestMatchLeaf(a,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:a.length?this.getThroughPath(a):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,o={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.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),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,o;for(let t=0,a=i.length;t<a;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(o=n.list[t],!s||!s.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||bt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Rt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new Bt(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:o}=this;return e.backgrounder&&s&&s.updateLayout(),o.getByPoint(t,i,n)}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 kt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function St(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?At(t,!0,e,i):Lt(e,i);break;case"inside":Et("inside",t,s,e,i);break;case"outside":Et("outside",t,s,e,i)}}function Et(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?At(e,!0,n,r):Lt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",kt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function Lt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function At(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Lt(i,n):n.stroke(),n.restoreBlendMode()):e?Lt(i,n):n.stroke())}function Wt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(s,{watcher:(t,e)=>new rt(t,e),layouter:(t,e)=>new mt(t,e),renderer:(t,e,i)=>new xt(t,e,i),selector:(t,e)=>new Rt(t,e)}),e.layout=mt.fullLayout;const{getSpread:Tt,getOuterOf:Ct,getByMove:Ot,getIntersectData:Mt}=B;let Pt;function Dt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return P.image(i,t,e,n,!Pt||!Pt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const It={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),Pt=P.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=Dt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?kt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&P.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?kt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?kt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?kt(e,i):s?i.fill(s):i.fill())},fillText:kt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)St(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&Wt(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)St(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),At(t,!1,e,i),n.__useArrow&&Wt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),At(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),At(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:St,drawTextStroke:Lt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Mt(n?Tt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Ct(s,a),o=Ot(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Ft={};const{get:Yt,rotateOfOuter:Ut,translate:Xt,scaleOfOuter:Nt,scale:jt,rotate:zt}=k;function Gt(t,e,i,n,s,o,a){const r=Yt();Xt(r,e.x+i,e.y+n),jt(r,s,o),a&&Ut(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Ht(t,e,i,n,s,o,a){const r=Yt();Xt(r,e.x+i,e.y+n),s&&jt(r,s,o),a&&zt(r,a),t.transform=r}function qt(t,e,i,n,s,o,a,r,d,l){const h=Yt();if(d)if("center"===l)Ut(h,{x:i/2,y:n/2},d);else switch(zt(h,d),d){case 90:Xt(h,n,0);break;case 180:Xt(h,i,n);break;case 270:Xt(h,0,i)}Ft.x=e.x+s,Ft.y=e.y+o,Xt(h,Ft.x,Ft.y),a&&Nt(h,Ft,a,r),t.transform=h}const{get:Vt,translate:Qt}=k,Jt=new _,Zt={},$t={};function Kt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=te(i,n,e)}function te(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Jt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u,filters:f}=t,g=e.width===n&&e.height===s,p={mode:a},_="center"!==r&&(c||0)%180==90,w=_?s:n,y=_?n:s;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(l||h)&&(S.getScaleData(l,h,i,$t),m=$t.scaleX,v=$t.scaleY);else if(!g||c){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-n*m)/2,b+=(e.height-s*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),E.toPoint(r,t,e,Zt,!0),x+=Zt.x,b+=Zt.y}switch(d&&(x+=d.x,b+=d.y),a){case"stretch":g||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||c)&&Ht(p,e,x,b,m,v,c);break;case"repeat":(!g||m||c)&&qt(p,e,n,s,x,b,m,v,c,r),u||(p.repeat="repeat");break;default:m&&Gt(p,e,x,b,m,v,c)}return p.transform||(e.x||e.y)&&(p.transform=Vt(),Qt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=v),p.width=n,p.height=s,o&&(p.opacity=o),f&&(p.filters=f),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let ee,ie=new _;const{isSame:ne}=B;function se(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Kt(s,n,i,o),!0}function oe(t,e){de(t,L.LOAD,e)}function ae(t,e){de(t,L.LOADED,e)}function re(t,e,i){e.error=i,t.forceUpdate("surface"),de(t,L.ERROR,e)}function de(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function le(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:he,scale:ce,copy:ue}=k,{ceil:fe,abs:ge}=Math;function pe(t,i,n){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=ge(s),o=ge(o);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(l=he(),ue(l,g),ce(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,h*=s,c*=o;const _=h*c;if(!p&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(d=Math.sqrt(_/w)),d&&(s/=d,o/=d,h/=d,c/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=he(),g&&ue(l,g)),ce(l,1/s,1/o));const y=t.getCanvas(fe(h)||1,fe(c)||1,r.opacity,r.filters),m=t.getPattern(y,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=a,!0}}const{abs:_e}=Math;const we={image:function(t,e,i,n,s){let o,a;const r=x.get(i);return ee&&i===ee.paint&&ne(n,ee.boxBounds)?o=ee.leafPaint:(o={type:i.type,image:r},ee=r.use>1?{leafPaint:o,paint:i,boxBounds:ie.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(se(t,e,i,r,o,n),s&&(oe(t,a),ae(t,a))):r.error?s&&re(t,a,r.error):(s&&(le(t,!0),oe(t,a)),o.loadId=r.load((()=>{le(t,!1),t.destroyed||(se(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,a)),o.loadId=null}),(e=>{le(t,!1),re(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!F.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=_e(o)*r,i*=_e(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||F.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.getFull(d.filters),0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||F.running?pe(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>it(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&pe(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:pe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,x.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Kt,getPatternData:te,fillOrFitMode:Gt,clipMode:Ht,repeatMode:qt},{toPoint:ye}=A,me={},ve={};function xe(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:be,getDistance:Be}=W,{get:Re,rotateOfOuter:ke,scaleOfOuter:Se}=k,{toPoint:Ee}=A,Le={},Ae={};function We(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=be(e,i);o=Re(),s?(Se(o,e,a/r*(n||1),1),ke(o,e,t+90)):(Se(o,e,1,a/r*(n||1)),ke(o,e,t))}return o}const{getDistance:Te}=W,{toPoint:Ce}=A,Oe={},Me={};const Pe={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ye(n||"top",i,me),ye(s||"bottom",i,ve);const d=e.canvas.createLinearGradient(me.x,me.y,ve.x,ve.y);xe(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;Ee(n||"center",i,Le),Ee(s||"bottom",i,Ae);const l=e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,Be(Le,Ae));xe(l,t.stops,a);const h={type:o,style:l},c=We(i,Le,Ae,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;Ce(n||"center",i,Oe),Ce(s||"bottom",i,Me);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Oe.x,Oe.y):e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Te(Oe,Me));xe(l,t.stops,a);const h={type:o,style:l},c=We(i,Oe,Me,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:We},{copy:De,toOffsetOutBounds:Ie}=B,Fe={},Ye={};function Ue(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(De(Fe,t.bounds),Fe.x+=i.x-a.x,Fe.y+=i.y-a.y,n){const{matrix:t}=s;Fe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Fe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Fe.width*=n,Fe.height*=n}t.copyWorld(s.canvas,t.bounds,Fe)}else n&&(De(Fe,i),Fe.x-=i.width/2*(n-1),Fe.y-=i.height/2*(n-1),Fe.width*=n,Fe.height*=n),t.copyWorld(s.canvas,a,n?Fe:i)}const{toOffsetOutBounds:Xe}=B,Ne={};const je={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ie(l,Ye),r.forEach(((r,p)=>{f.setWorldShadow(Ye.offsetX+r.x*c,Ye.offsetY+r.y*u,r.blur*c,D.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ue(f,Ye,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Xe(l,Ne),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Ne.offsetX+r.x*c,Ne.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ue(f,Ne,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,D.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.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){}},{excludeRenderBounds:ze}=p;function Ge(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),qe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":qe(t,i,n,o);break;case"path":i.restore()}}function He(t){return t.getSameCanvas(!1,!0)}function qe(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(a&&(Ge(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=He(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=He(t)),s||(s=He(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||ze(i,e)||i.__render(s||t,e);Ge(this,a,t,s,n,o)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=Ve+"_#~&*+\\=|≮≯≈≠=…",Je=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 Ze(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $e=Ze("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=Ze("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=Ze(Ve),ei=Ze(Qe),ii=Ze("- —/~|┆·");var ni;!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"}(ni||(ni={}));const{Letter:si,Single:oi,Before:ai,After:ri,Symbol:di,Break:li}=ni;function hi(t){return $e[t]?si:ii[t]?li:Ke[t]?ai:ti[t]?ri:ei[t]?di:Je.test(t)?oi:si}const ci={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ui(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:fi}=ci,{Letter:gi,Single:pi,Before:_i,After:wi,Symbol:yi,Break:mi}=ni;let vi,xi,bi,Bi,Ri,ki,Si,Ei,Li,Ai,Wi,Ti,Ci,Oi,Mi,Pi,Di,Ii=[];function Fi(t,e){Li&&!Ei&&(Ei=Li),vi.data.push({char:t,width:e}),bi+=e}function Yi(){Bi+=bi,vi.width=bi,xi.words.push(vi),vi={data:[]},bi=0}function Ui(){Oi&&(Mi.paraNumber++,xi.paraStart=!0,Oi=!1),Li&&(xi.startCharSize=Ei,xi.endCharSize=Li,Ei=0),xi.width=Bi,Pi.width?fi(xi):Di&&Xi(),Ii.push(xi),xi={words:[]},Bi=0}function Xi(){Bi>(Mi.maxWidth||0)&&(Mi.maxWidth=Bi)}const{top:Ni,right:ji,bottom:zi,left:Gi}=T;function Hi(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 qi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o?(n=l[Gi],o-=l[ji]+l[Gi]):i.autoSizeAlign||(n=l[Gi]),a?(s=l[Ni],a-=l[Ni]+l[zi]):i.autoSizeAlign||(s=l[Ni]));const h={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Mi=t,Ii=t.rows,Pi=t.bounds,Di=!Pi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=Pi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Oi=!0,Wi=null,Ei=Si=Li=bi=Bi=0,vi={data:[]},xi={words:[]};for(let n=0,l=i.length;n<l;n++)ki=i[n],"\n"===ki?(bi&&Yi(),xi.paraEnd=!0,Ui(),Oi=!0):(Ai=hi(ki),Ai===gi&&"none"!==a&&(ki=ui(ki,a,!bi)),Si=r.measureText(ki).width,s&&(s<0&&(Li=Si),Si+=s),Ti=Ai===pi&&(Wi===pi||Wi===gi)||Wi===pi&&Ai!==wi,Ci=!(Ai!==_i&&Ai!==pi||Wi!==yi&&Wi!==wi),Ri=Oi&&o?d-o:d,t&&d&&Bi+bi+Si>Ri&&(e?(bi&&Yi(),Bi&&Ui()):(Ci||(Ci=Ai===gi&&Wi==wi),Ti||Ci||Ai===mi||Ai===_i||Ai===pi||bi+Si>Ri?(bi&&Yi(),Bi&&Ui()):Bi&&Ui()))," "===ki&&!0!==Oi&&Bi+bi===0||(Ai===mi?(" "===ki&&bi&&Yi(),Fi(ki,Si),Yi()):Ti||Ci?(bi&&Yi(),Fi(ki,Si)):Fi(ki,Si)),Wi=Ai);bi&&Yi(),Bi&&Ui(),Ii.length>0&&(Ii[Ii.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Mi.paraNumber++,Bi=r.measureText(t).width,Ii.push({x:o||0,text:t,width:Bi,paraStart:!0}),Di&&Xi()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Hi(e,"x",t[Gi]);break;case"right":Hi(e,"x",-t[ji])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Hi(e,"y",t[Ni]);break;case"bottom":Hi(e,"y",-t[zi])}}(l,h,i,o,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=n,w=o*s+(c?c*(t.paraNumber-1):0),y=a;if(d&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let a=0,h=s;a<h;a++){if(m=i[a],m.x=f,m.width<p||m.width>p&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&a>0&&(y+=c),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<n.x&&(n.x=v),x>n.width&&(n.width=x),d&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=w}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,h,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,h=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(h,i,o),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,i),h}};const Vi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let n=void 0===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(U,qi),Object.assign(D,Vi),Object.assign(X,It),Object.assign(P,we),Object.assign(I,Pe),Object.assign(N,je);const{setPoint:Qi,addPoint:Ji,toBounds:Zi}=j;const $i={syncExport(t,e,i){let n;this.running=!0;const s=G.fileType(e),o=e.includes(".");i=G.getExportOptions(i);const{toURL:a}=H,{download:r}=H.origin;if("json"===s)o&&r(a(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!o||t.toJSON(i.json)};else if("svg"===s)o&&r(a(t.toSVG(),"svg"),e),n={data:!!o||t.toSVG()};else{let s,o,a=1,r=1;const{worldTransform:d,isLeafer:l,leafer:h,isFrame:c}=t,{slice:u,trim:f,padding:g,onCanvas:p}=i,_=void 0===i.smooth?!h||h.config.smooth:i.smooth,w=i.contextSettings||(h?h.config.contextSettings:void 0),y=i.screenshot||t.isApp,m=l&&y&&void 0===i.fill?t.fill:i.fill,v=G.isOpaqueImage(e)||m,x=new q;if(y)s=!0===y?l?h.canvas.bounds:t.worldRenderBounds:y;else{let e=i.relative||(l?"inner":"local");switch(a=d.scaleX,r=d.scaleY,e){case"inner":x.set(d);break;case"local":x.set(d).divide(t.localTransform),a/=t.scaleX,r/=t.scaleY;break;case"world":a=1,r=1;break;case"page":e=h||t;default:x.set(d).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};V.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;t.isApp&&(b.scaleX*=B,b.scaleY*=B,B=t.app.pixelRatio);const{x:R,y:k,width:S,height:E}=new z(s).scale(b.scaleX,b.scaleY),L={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-k).withScale(1/a*b.scaleX,1/r*b.scaleY)};let A,W=Q.canvas({width:Math.floor(S),height:Math.floor(E),pixelRatio:B,smooth:_,contextSettings:w});if(u&&(A=t,A.__worldOpacity=0,t=h||t,L.bounds=W.bounds),W.save(),c&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(W,L),t.fill=e}else t.__render(W,L);if(W.restore(),A&&A.__updateWorldOpacity(),f){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Ji(a,s,o):Qi(a={},s,o)),r++;const d=new z;return Zi(a,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:B};W=Q.canvas(n),W.copyWorld(t,o,n)}if(g){const[t,e,i,n]=V.fourNumber(g),s=W,{width:o,height:a}=s;W=Q.canvas({width:o+n+e,height:a+t+i,pixelRatio:B}),W.copyWorld(s,s.bounds,{x:n,y:t,width:o,height:a})}v&&W.fillWorld(W.bounds,m||"#FFFFFF","destination-over"),p&&p(W);n={data:"canvas"===e?W:W.export(e,i),width:W.pixelWidth,height:W.pixelHeight,renderBounds:s,trimBounds:o}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){Ki||(Ki=new J);return new Promise((e=>{Ki.add((()=>it(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const o=()=>it(this,void 0,void 0,(function*(){if(!Z.isComplete)return H.requestRender(o);const a=$i.syncExport(t,e,i);a.data instanceof Promise&&(a.data=yield a.data),n(a),s()}));t.updateLayout(),tn(t);const{leafer:a}=t;a?a.waitViewCompleted(o):o()}))))}};let Ki;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=$.prototype,nn=K.get("@leafer-in/export");en.export=function(t,e){const{quality:i,blob:n}=G.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},en.toBlob=function(t,e){return new Promise((i=>{H.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(t,e){return H.origin.canvasToDataURL(this.view,t,e)},en.saveAs=function(t,e){return new Promise((i=>{H.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},tt.add("export"),Object.assign(F,$i),et.prototype.export=function(t,e){return F.export(this,t,e)},et.prototype.syncExport=function(t,e){return F.syncExport(this,t,e)},Object.assign(s,{interaction:(t,e,i,n)=>new M(t,e,i,n),hitCanvas:(t,e)=>new nt(t,e),hitCanvasManager:()=>new O});export{mt as Layouter,nt as LeaferCanvas,Bt as Picker,xt as Renderer,Rt as Selector,rt as Watcher,at as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as o,defineKey as a,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as R,MatrixHelper as k,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as C}from"fs";import{HitCanvasManager as O,InteractionBase as M}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as U,Paint as X,Effect as N,TwoPointBoundsHelper as j,Bounds as z,FileHelper as G,Platform as H,Matrix as q,MathHelper as V,Creator as Q,TaskProcessor as J,Resource as Z,LeaferCanvasBase as $,Debug as K,Plugin as tt,UI as et}from"@leafer-ui/draw";function it(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{l(n.next(t))}catch(t){o(t)}}function r(t){try{l(n.throw(t))}catch(t){o(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(a,r)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class nt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:st,fileType:ot}=n;function at(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.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},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(st(e),i),canvasToBolb:(t,e,i)=>it(this,void 0,void 0,(function*(){return t.toBuffer(st(e),i)})),canvasSaveAs:(t,e,i)=>it(this,void 0,void 0,(function*(){return C(e,t.toBuffer(st(ot(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new nt(t,e),image:t=>new o(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class rt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:lt,updateBounds:dt,updateAllWorldOpacity:ht}=f,{pushAllChildBranch:ct,pushAllParent:ut}=g;const{worldBounds:ft}=p,gt={x:0,y:0,width:1e5,height:1e5};class pt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ft)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(gt):this.afterBounds.setListWithFn(t,ft),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:_t,updateAllChange:wt}=f,yt=w.get("Layouter");class mt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,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.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){yt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?yt.warn("layouting"):this.times>3?yt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,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?(lt(t,!0),e.add(t),t.isBranch&&ct(t,e),ut(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ut(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||dt(n[t])}dt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&ht(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(o,r,this.times)),i.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(i,o,this.times)),mt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){_t(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),wt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new pt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new pt(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(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const vt=w.get("Renderer");class xt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,vt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(d.CHILD_START,e),this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,vt.error(t)}vt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return vt.warn("rendering");if(this.times>3)return vt.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=t.includes(this.target.__world),o=new _(n);i.save(),s&&!w.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(n),w.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||vt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:bt}=B;class Bt{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,l=this.getBestMatchLeaf(a,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),n?{path:d,target:l,throughPath:a.length?this.getThroughPath(a):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,o={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.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),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,o;for(let t=0,a=i.length;t<a;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(o=n.list[t],!s||!s.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||bt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Rt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Bt(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:o}=this;return e.backgrounder&&s&&s.updateLayout(),o.getByPoint(t,i,n)}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 kt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=n;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}function St(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?At(t,!0,e,i):Lt(e,i);break;case"inside":Et("inside",t,s,e,i);break;case"outside":Et("outside",t,s,e,i)}}function Et(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?At(e,!0,n,r):Lt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",kt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function Lt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function At(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Lt(i,n):n.stroke(),n.restoreBlendMode()):e?Lt(i,n):n.stroke())}function Wt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(s,{watcher:(t,e)=>new rt(t,e),layouter:(t,e)=>new mt(t,e),renderer:(t,e,i)=>new xt(t,e,i),selector:(t,e)=>new Rt(t,e)}),e.layout=mt.fullLayout;const{getSpread:Tt,getOuterOf:Ct,getByMove:Ot,getIntersectData:Mt}=B;let Pt;function Dt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return P.image(i,t,e,n,!Pt||!Pt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const It={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),Pt=P.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=Dt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?kt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&P.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?kt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?kt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?kt(e,i):s?i.fill(s):i.fill())},fillText:kt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)St(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&Wt(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)St(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),At(t,!1,e,i),n.__useArrow&&Wt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),At(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),At(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:St,drawTextStroke:Lt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:h}=s;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(s))l=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Mt(n?Tt(e.bounds,d===h?n*d:[n*h,n*d]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),r=Ct(s,a),o=Ot(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let Ft={};const{get:Yt,rotateOfOuter:Ut,translate:Xt,scaleOfOuter:Nt,scale:jt,rotate:zt}=k;function Gt(t,e,i,n,s,o,a){const r=Yt();Xt(r,e.x+i,e.y+n),jt(r,s,o),a&&Ut(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Ht(t,e,i,n,s,o,a){const r=Yt();Xt(r,e.x+i,e.y+n),s&&jt(r,s,o),a&&zt(r,a),t.transform=r}function qt(t,e,i,n,s,o,a,r,l,d){const h=Yt();if(l)if("center"===d)Ut(h,{x:i/2,y:n/2},l);else switch(zt(h,l),l){case 90:Xt(h,n,0);break;case 180:Xt(h,i,n);break;case 270:Xt(h,0,i)}Ft.x=e.x+s,Ft.y=e.y+o,Xt(h,Ft.x,Ft.y),a&&Nt(h,Ft,a,r),t.transform=h}const{get:Vt,translate:Qt}=k,Jt=new _,Zt={},$t={};function Kt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=te(i,n,e)}function te(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Jt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:l,scale:d,size:h,rotation:c,repeat:u,filters:f}=t,g=e.width===n&&e.height===s,p={mode:a},_="center"!==r&&(c||0)%180==90,w=_?s:n,y=_?n:s;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(d||h)&&(S.getScaleData(d,h,i,$t),m=$t.scaleX,v=$t.scaleY);else if(!g||c){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-n*m)/2,b+=(e.height-s*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),E.toPoint(r,t,e,Zt,!0),x+=Zt.x,b+=Zt.y}switch(l&&(x+=l.x,b+=l.y),a){case"stretch":g||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||c)&&Ht(p,e,x,b,m,v,c);break;case"repeat":(!g||m||c)&&qt(p,e,n,s,x,b,m,v,c,r),u||(p.repeat="repeat");break;default:m&&Gt(p,e,x,b,m,v,c)}return p.transform||(e.x||e.y)&&(p.transform=Vt(),Qt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=v),p.width=n,p.height=s,o&&(p.opacity=o),f&&(p.filters=f),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let ee,ie=new _;const{isSame:ne}=B;function se(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Kt(s,n,i,o),!0}function oe(t,e){le(t,L.LOAD,e)}function ae(t,e){le(t,L.LOADED,e)}function re(t,e,i){e.error=i,t.forceUpdate("surface"),le(t,L.ERROR,e)}function le(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:he,scale:ce,copy:ue}=k,{ceil:fe,abs:ge}=Math;function pe(t,i,n){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=ge(s),o=ge(o);const{image:t,data:r}=i;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(d=he(),ue(d,g),ce(d,1/u,1/f),s*=u,o*=f),s*=n,o*=n,h*=s,c*=o;const _=h*c;if(!p&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,o/=l,h/=l,c/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=he(),g&&ue(d,g)),ce(d,1/s,1/o));const y=t.getCanvas(fe(h)||1,fe(c)||1,r.opacity,r.filters),m=t.getPattern(y,p||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=a,!0}}const{abs:_e}=Math;const we={image:function(t,e,i,n,s){let o,a;const r=x.get(i);return ee&&i===ee.paint&&ne(n,ee.boxBounds)?o=ee.leafPaint:(o={type:i.type,image:r},ee=r.use>1?{leafPaint:o,paint:i,boxBounds:ie.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(se(t,e,i,r,o,n),s&&(oe(t,a),ae(t,a))):r.error?s&&re(t,a,r.error):(s&&(de(t,!0),oe(t,a)),o.loadId=r.load((()=>{de(t,!1),t.destroyed||(se(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,a)),o.loadId=null}),(e=>{de(t,!1),re(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!F.running)return!1;{const{data:l}=n;if(s)if(l.repeat)s=!1;else{let{width:t,height:i}=l;t*=_e(o)*r,i*=_e(a)*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),s=t*i>e.image.maxCacheSize||F.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),l.opacity&&(i.opacity*=l.opacity),l.transform&&i.transform(l.transform),i.drawImage(n.image.getFull(l.filters),0,0,l.width,l.height),i.restore(),!0):(!n.style||n.sync||F.running?pe(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>it(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&pe(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:pe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,l=i.length;r<l;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,x.recycle(n),n.loading?(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))):i[r].style=null);return s}return null},createData:Kt,getPatternData:te,fillOrFitMode:Gt,clipMode:Ht,repeatMode:qt},{toPoint:ye}=A,me={},ve={};function xe(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:be,getDistance:Be}=W,{get:Re,rotateOfOuter:ke,scaleOfOuter:Se}=k,{toPoint:Ee}=A,Le={},Ae={};function We(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=be(e,i);o=Re(),s?(Se(o,e,a/r*(n||1),1),ke(o,e,t+90)):(Se(o,e,1,a/r*(n||1)),ke(o,e,t))}return o}const{getDistance:Te}=W,{toPoint:Ce}=A,Oe={},Me={};const Pe={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ye(n||"top",i,me),ye(s||"bottom",i,ve);const l=e.canvas.createLinearGradient(me.x,me.y,ve.x,ve.y);xe(l,t.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:l}=t;Ee(n||"center",i,Le),Ee(s||"bottom",i,Ae);const d=e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,Be(Le,Ae));xe(d,t.stops,a);const h={type:o,style:d},c=We(i,Le,Ae,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:l}=t;Ce(n||"center",i,Oe),Ce(s||"bottom",i,Me);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,Oe.x,Oe.y):e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Te(Oe,Me));xe(d,t.stops,a);const h={type:o,style:d},c=We(i,Oe,Me,l||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:We},{copy:De,toOffsetOutBounds:Ie}=B,Fe={},Ye={};function Ue(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(De(Fe,t.bounds),Fe.x+=i.x-a.x,Fe.y+=i.y-a.y,n){const{matrix:t}=s;Fe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Fe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Fe.width*=n,Fe.height*=n}t.copyWorld(s.canvas,t.bounds,Fe)}else n&&(De(Fe,i),Fe.x-=i.width/2*(n-1),Fe.y-=i.height/2*(n-1),Fe.width*=n,Fe.height*=n),t.copyWorld(s.canvas,a,n?Fe:i)}const{toOffsetOutBounds:Xe}=B,Ne={};const je={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ie(d,Ye),r.forEach(((r,p)=>{f.setWorldShadow(Ye.offsetX+r.x*c,Ye.offsetY+r.y*u,r.blur*c,D.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ue(f,Ye,s,i),n=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),n=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Xe(d,Ne),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Ne.offsetX+r.x*c,Ne.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ue(f,Ne,s,i),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,h,d,"source-out"),n=d),f.fillWorld(n,D.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.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){}},{excludeRenderBounds:ze}=p;function Ge(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),qe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":qe(t,i,n,o);break;case"path":i.restore()}}function He(t){return t.getSameCanvas(!1,!0)}function qe(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],r=i.__.mask,r&&(a&&(Ge(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=He(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=He(t)),s||(s=He(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||ze(i,e)||i.__render(s||t,e);Ge(this,a,t,s,n,o)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=Ve+"_#~&*+\\=|≮≯≈≠=…",Je=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 Ze(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $e=Ze("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=Ze("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=Ze(Ve),ei=Ze(Qe),ii=Ze("- —/~|┆·");var ni;!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"}(ni||(ni={}));const{Letter:si,Single:oi,Before:ai,After:ri,Symbol:li,Break:di}=ni;function hi(t){return $e[t]?si:ii[t]?di:Ke[t]?ai:ti[t]?ri:ei[t]?li:Je.test(t)?oi:si}const ci={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ui(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:fi}=ci,{Letter:gi,Single:pi,Before:_i,After:wi,Symbol:yi,Break:mi}=ni;let vi,xi,bi,Bi,Ri,ki,Si,Ei,Li,Ai,Wi,Ti,Ci,Oi,Mi,Pi,Di,Ii=[];function Fi(t,e){Li&&!Ei&&(Ei=Li),vi.data.push({char:t,width:e}),bi+=e}function Yi(){Bi+=bi,vi.width=bi,xi.words.push(vi),vi={data:[]},bi=0}function Ui(){Oi&&(Mi.paraNumber++,xi.paraStart=!0,Oi=!1),Li&&(xi.startCharSize=Ei,xi.endCharSize=Li,Ei=0),xi.width=Bi,Pi.width?fi(xi):Di&&Xi(),Ii.push(xi),xi={words:[]},Bi=0}function Xi(){Bi>(Mi.maxWidth||0)&&(Mi.maxWidth=Bi)}const{top:Ni,right:ji,bottom:zi,left:Gi}=T;function Hi(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 qi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(o?(n=d[Gi],o-=d[ji]+d[Gi]):i.autoSizeAlign||(n=d[Gi]),a?(s=d[Ni],a-=d[Ni]+d[zi]):i.autoSizeAlign||(s=d[Ni]));const h={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,n){Mi=t,Ii=t.rows,Pi=t.bounds,Di=!Pi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:l,height:d}=Pi;if(l||d||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Oi=!0,Wi=null,Ei=Si=Li=bi=Bi=0,vi={data:[]},xi={words:[]};for(let n=0,d=i.length;n<d;n++)ki=i[n],"\n"===ki?(bi&&Yi(),xi.paraEnd=!0,Ui(),Oi=!0):(Ai=hi(ki),Ai===gi&&"none"!==a&&(ki=ui(ki,a,!bi)),Si=r.measureText(ki).width,s&&(s<0&&(Li=Si),Si+=s),Ti=Ai===pi&&(Wi===pi||Wi===gi)||Wi===pi&&Ai!==wi,Ci=!(Ai!==_i&&Ai!==pi||Wi!==yi&&Wi!==wi),Ri=Oi&&o?l-o:l,t&&l&&Bi+bi+Si>Ri&&(e?(bi&&Yi(),Bi&&Ui()):(Ci||(Ci=Ai===gi&&Wi==wi),Ti||Ci||Ai===mi||Ai===_i||Ai===pi||bi+Si>Ri?(bi&&Yi(),Bi&&Ui()):Bi&&Ui()))," "===ki&&!0!==Oi&&Bi+bi===0||(Ai===mi?(" "===ki&&bi&&Yi(),Fi(ki,Si),Yi()):Ti||Ci?(bi&&Yi(),Fi(ki,Si)):Fi(ki,Si)),Wi=Ai);bi&&Yi(),Bi&&Ui(),Ii.length>0&&(Ii[Ii.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Mi.paraNumber++,Bi=r.measureText(t).width,Ii.push({x:o||0,text:t,width:Bi,paraStart:!0}),Di&&Xi()}))}(h,t,i),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Hi(e,"x",t[Gi]);break;case"right":Hi(e,"x",-t[ji])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Hi(e,"y",t[Ni]);break;case"bottom":Hi(e,"y",-t[zi])}}(d,h,i,o,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=n,w=o*s+(c?c*(t.paraNumber-1):0),y=a;if(l&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let a=0,h=s;a<h;a++){if(m=i[a],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&&c&&a>0&&(y+=c),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=w}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,l,d,h,c,u;n.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-d)/(u-1):0,h=a||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,i,o),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,h=n+s-d;("none"===i.textWrap?o:[o[a-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<h));n--){if(l<h&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,o),"none"!==r&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=D.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(h,i),h}};const Vi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let n=void 0===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(U,qi),Object.assign(D,Vi),Object.assign(X,It),Object.assign(P,we),Object.assign(I,Pe),Object.assign(N,je);const{setPoint:Qi,addPoint:Ji,toBounds:Zi}=j;const $i={syncExport(t,e,i){let n;this.running=!0;const s=G.fileType(e),o=e.includes(".");i=G.getExportOptions(i);const{toURL:a}=H,{download:r}=H.origin;if("json"===s)o&&r(a(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!o||t.toJSON(i.json)};else if("svg"===s)o&&r(a(t.toSVG(),"svg"),e),n={data:!!o||t.toSVG()};else{let s,o,a=1,r=1;const{worldTransform:l,isLeafer:d,leafer:h,isFrame:c}=t,{slice:u,trim:f,padding:g,onCanvas:p}=i,_=void 0===i.smooth?!h||h.config.smooth:i.smooth,w=i.contextSettings||(h?h.config.contextSettings:void 0),y=i.screenshot||t.isApp,m=d&&y&&void 0===i.fill?t.fill:i.fill,v=G.isOpaqueImage(e)||m,x=new q;if(y)s=!0===y?d?h.canvas.bounds:t.worldRenderBounds:y;else{let e=i.relative||(d?"inner":"local");switch(a=l.scaleX,r=l.scaleY,e){case"inner":x.set(l);break;case"local":x.set(l).divide(t.localTransform),a/=t.scaleX,r/=t.scaleY;break;case"world":a=1,r=1;break;case"page":e=h||t;default:x.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};V.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;t.isApp&&(b.scaleX*=B,b.scaleY*=B,B=t.app.pixelRatio);const{x:R,y:k,width:S,height:E}=new z(s).scale(b.scaleX,b.scaleY),L={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-k).withScale(1/a*b.scaleX,1/r*b.scaleY)};let A,W=Q.canvas({width:Math.floor(S),height:Math.floor(E),pixelRatio:B,smooth:_,contextSettings:w});if(u&&(A=t,A.__worldOpacity=0,t=h||t,L.bounds=W.bounds),W.save(),c&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(W,L),t.fill=e}else t.__render(W,L);if(W.restore(),A&&A.__updateWorldOpacity(),f){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Ji(a,s,o):Qi(a={},s,o)),r++;const l=new z;return Zi(a,l),l.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:B};W=Q.canvas(n),W.copyWorld(t,o,n)}if(g){const[t,e,i,n]=V.fourNumber(g),s=W,{width:o,height:a}=s;W=Q.canvas({width:o+n+e,height:a+t+i,pixelRatio:B}),W.copyWorld(s,s.bounds,{x:n,y:t,width:o,height:a})}v&&W.fillWorld(W.bounds,m||"#FFFFFF","destination-over"),p&&p(W);n={data:"canvas"===e?W:W.export(e,i),width:W.pixelWidth,height:W.pixelHeight,renderBounds:s,trimBounds:o}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){Ki||(Ki=new J);return new Promise((e=>{Ki.add((()=>it(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const o=()=>it(this,void 0,void 0,(function*(){if(!Z.isComplete)return H.requestRender(o);const a=$i.syncExport(t,e,i);a.data instanceof Promise&&(a.data=yield a.data),n(a),s()}));t.updateLayout(),tn(t);const{leafer:a}=t;a?a.waitViewCompleted(o):o()}))))}};let Ki;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=$.prototype,nn=K.get("@leafer-in/export");en.export=function(t,e){const{quality:i,blob:n}=G.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},en.toBlob=function(t,e){return new Promise((i=>{H.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(t,e){return H.origin.canvasToDataURL(this.view,t,e)},en.saveAs=function(t,e){return new Promise((i=>{H.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},tt.add("export"),Object.assign(F,$i),et.prototype.export=function(t,e){return F.export(this,t,e)},et.prototype.syncExport=function(t,e){return F.syncExport(this,t,e)},Object.assign(s,{interaction:(t,e,i,n)=>new M(t,e,i,n),hitCanvas:(t,e)=>new nt(t,e),hitCanvasManager:()=>new O});export{mt as Layouter,nt as LeaferCanvas,Bt as Picker,xt as Renderer,Rt as Selector,rt as Watcher,at as useCanvas};
2
2
  //# sourceMappingURL=node.esm.min.js.map