@leafer-ui/node 1.6.2 → 1.6.4

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