@leafer-ui/node 1.4.0 → 1.4.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,Creator as n,LeaferImage as s,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,Bounds as _,LeafBoundsHelper as p,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 L,ImageEvent as E,AroundHelper as A,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{InteractionBase as C,HitCanvasManager 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,Bounds as j,TwoPointBoundsHelper as z,FileHelper as G,TaskProcessor as H,Platform as q,Matrix as V,MathHelper as Q,Creator as J,LeaferCanvasBase as Z,Debug as $,Plugin as K,UI as tt}from"@leafer-ui/draw";function et(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(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(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class it 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:st}=o;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(nt(e),i),canvasToBolb:(t,e,i)=>et(this,void 0,void 0,(function*(){return t.toBuffer(nt(e),i)})),canvasSaveAs:(t,e,i)=>et(this,void 0,void 0,(function*(){return O(e,t.toBuffer(nt(st(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=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new it(t,e),image:t=>new s(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ot{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:rt,updateBounds:dt,updateAllWorldOpacity:lt}=f,{pushAllChildBranch:ht,pushAllParent:ct}=g;const{worldBounds:ut}=p,ft={x:0,y:0,width:1e5,height:1e5};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,ut)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ft):this.afterBounds.setListWithFn(t,ut),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:pt}=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=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){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:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=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?(rt(t,!0),e.add(t),t.isBranch&&ht(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(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&&lt(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(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:n,AFTER:s}=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(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){_t(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),pt(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_(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=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 _,mt.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,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(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),a=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,a),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||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 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: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,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,d=this.getBestMatchLeaf(o,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):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,a={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,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,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,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!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=d.default(e,this.config)),this.picker=new bt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,n){return e.backgrounder&&this.target&&this.target.updateLayout(),this.picker.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){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;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,a)}function kt(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?Et(t,!0,e,i):Lt(e,i);break;case"inside":St("inside",t,s,e,i);break;case"outside":St("outside",t,s,e,i)}}function St(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?Et(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;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;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,a)}function Et(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],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 At(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(n,{watcher:(t,e)=>new ot(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:Tt,getByMove:Ot,getIntersectData:Ct}=B;let Mt;function Pt(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:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:D.string(o,r)};case"image":return P.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 Dt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Mt=P.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Pt(t,a[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?Rt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&P.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?Rt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?Rt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?Rt(e,i):s?i.fill(s):i.fill())},fillText:Rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)kt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&At(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 a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)kt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),Et(t,!1,e,i),n.__useArrow&&At(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Et(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),Et(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:kt,drawTextStroke:Lt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Ct(n?Wt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Tt(s,o),a=Ot(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(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let It={};const{get:Ft,rotateOfOuter:Yt,translate:Ut,scaleOfOuter:Xt,scale:Nt,rotate:jt}=k;function zt(t,e,i,n,s,a,o){const r=Ft();Ut(r,e.x+i,e.y+n),Nt(r,s,a),o&&Yt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Gt(t,e,i,n,s,a,o){const r=Ft();Ut(r,e.x+i,e.y+n),s&&Nt(r,s,a),o&&jt(r,o),t.transform=r}function Ht(t,e,i,n,s,a,o,r,d,l){const h=Ft();if(d)if("center"===l)Yt(h,{x:i/2,y:n/2},d);else switch(jt(h,d),d){case 90:Ut(h,n,0);break;case 180:Ut(h,i,n);break;case 270:Ut(h,0,i)}It.x=e.x+s,It.y=e.y+a,Ut(h,It.x,It.y),o&&Xt(h,It,o,r),t.transform=h}const{get:qt,translate:Vt}=k,Qt=new _,Jt={},Zt={};function $t(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Kt(i,n,e)}function Kt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(c||0)%180==90,p=_?s:n,w=_?n:s;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(S.getScaleData(l,h,i,Zt),y=Zt.scaleX,m=Zt.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),L.toPoint(r,t,e,Jt,!0),v+=Jt.x,x+=Jt.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Gt(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Ht(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&zt(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=qt(),Vt(g.transform,e.x,e.y)),y&&"stretch"!==o&&(g.scaleX=y,g.scaleY=m),g.width=n,g.height=s,a&&(g.opacity=a),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let te,ee=new _;const{isSame:ie}=B;function ne(t,e,i,n,s,a){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||$t(s,n,i,a),!0}function se(t,e){re(t,E.LOAD,e)}function ae(t,e){re(t,E.LOADED,e)}function oe(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,E.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,scale:he,copy:ce}=k,{ceil:ue,abs:fe}=Math;function ge(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=fe(s),a=fe(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(l=le(),ce(l,_),he(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=le(),_&&ce(l,_)),he(l,1/s,1/a));const m=t.getCanvas(ue(h)||1,ue(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}const{abs:_e}=Math;const pe={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return te&&i===te.paint&&ie(n,te.boxBounds)?a=te.leafPaint:(a={type:i.type,image:r},te=r.use>1?{leafPaint:a,paint:i,boxBounds:ee.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ne(t,e,i,r,a,n),s&&(se(t,o),ae(t,o))):r.error?s&&oe(t,o,r.error):(s&&(de(t,!0),se(t,o)),a.loadId=r.load((()=>{de(t,!1),t.destroyed||(ne(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,o)),a.loadId=null}),(e=>{de(t,!1),oe(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===a+"-"+o+"-"+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(a)*r,i*=_e(o)*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.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||F.running?ge(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>et(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ge(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:ge,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,x.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:$t,getPatternData:Kt,fillOrFitMode:zt,clipMode:Gt,repeatMode:Ht},{toPoint:we}=A,ye={},me={};function ve(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:xe,getDistance:be}=W,{get:Be,rotateOfOuter:Re,scaleOfOuter:ke}=k,{toPoint:Se}=A,Le={},Ee={};function Ae(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=xe(e,i);a=Be(),s?(ke(a,e,o/r*(n||1),1),Re(a,e,t+90)):(ke(a,e,1,o/r*(n||1)),Re(a,e,t))}return a}const{getDistance:We}=W,{toPoint:Te}=A,Oe={},Ce={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;we(n||"top",i,ye),we(s||"bottom",i,me);const d=e.canvas.createLinearGradient(ye.x,ye.y,me.x,me.y);ve(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Se(n||"center",i,Le),Se(s||"bottom",i,Ee);const l=e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,be(Le,Ee));ve(l,t.stops,o);const h={type:a,style:l},c=Ae(i,Le,Ee,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Te(n||"center",i,Oe),Te(s||"bottom",i,Ce);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Oe.x,Oe.y):e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,We(Oe,Ce));ve(l,t.stops,o);const h={type:a,style:l},c=Ae(i,Oe,Ce,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Ae},{copy:Pe,toOffsetOutBounds:De}=B,Ie={},Fe={};function Ye(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Pe(Ie,t.bounds),Ie.x+=i.x-o.x,Ie.y+=i.y-o.y,n){const{matrix:t}=s;Ie.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ie.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ie.width*=n,Ie.height*=n}t.copyWorld(s.canvas,t.bounds,Ie)}else n&&(Pe(Ie,i),Ie.x-=i.width/2*(n-1),Ie.y-=i.height/2*(n-1),Ie.width*=n,Ie.height*=n),t.copyWorld(s.canvas,o,n?Ie:i)}const{toOffsetOutBounds:Ue}=B,Xe={};const Ne={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;De(l,Fe),r.forEach(((r,_)=>{f.setWorldShadow(Fe.offsetX+r.x*c,Fe.offsetY+r.y*u,r.blur*c,D.string(r.color)),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Fe,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ue(l,Xe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Xe.offsetX+r.x*c,Xe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Xe,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(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,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<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:je}=p;function ze(t,e,i,n,s,a){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,a);break;case"path":i.restore()}}function Ge(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,a,o,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(o&&(ze(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ge(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Ge(t)),s||(s=Ge(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||je(i,e)||i.__render(s||t,e);ze(this,o,t,s,n,a)};const qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=qe+"_#~&*+\\=|≮≯≈≠=…",Qe=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 Je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ze=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Je(qe),ti=Je(Ve),ei=Je("- —/~|┆·");var ii;!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"}(ii||(ii={}));const{Letter:ni,Single:si,Before:ai,After:oi,Symbol:ri,Break:di}=ii;function li(t){return Ze[t]?ni:ei[t]?di:$e[t]?ai:Ke[t]?oi:ti[t]?ri:Qe.test(t)?si:ni}const hi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ci(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:ui}=hi,{Letter:fi,Single:gi,Before:_i,After:pi,Symbol:wi,Break:yi}=ii;let mi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ai,Wi,Ti,Oi,Ci,Mi,Pi,Di=[];function Ii(t,e){Li&&!Si&&(Si=Li),mi.data.push({char:t,width:e}),xi+=e}function Fi(){bi+=xi,mi.width=xi,vi.words.push(mi),mi={data:[]},xi=0}function Yi(){Oi&&(Ci.paraNumber++,vi.paraStart=!0,Oi=!1),Li&&(vi.startCharSize=Si,vi.endCharSize=Li,Si=0),vi.width=bi,Mi.width?ui(vi):Pi&&Ui(),Di.push(vi),vi={words:[]},bi=0}function Ui(){bi>(Ci.maxWidth||0)&&(Ci.maxWidth=bi)}const{top:Xi,right:Ni,bottom:ji,left:zi}=T;function Gi(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,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[zi],a-=l[Ni]+l[zi]):i.autoSizeAlign||(n=l[zi]),o?(s=l[Xi],o-=l[Xi]+l[ji]):i.autoSizeAlign||(s=l[Xi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Ci=t,Di=t.rows,Mi=t.bounds,Pi=!Mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=Mi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Oi=!0,Ai=null,Si=ki=Li=xi=bi=0,mi={data:[]},vi={words:[]};for(let n=0,l=i.length;n<l;n++)Ri=i[n],"\n"===Ri?(xi&&Fi(),vi.paraEnd=!0,Yi(),Oi=!0):(Ei=li(Ri),Ei===fi&&"none"!==o&&(Ri=ci(Ri,o,!xi)),ki=r.measureText(Ri).width,s&&(s<0&&(Li=ki),ki+=s),Wi=Ei===gi&&(Ai===gi||Ai===fi)||Ai===gi&&Ei!==pi,Ti=!(Ei!==_i&&Ei!==gi||Ai!==wi&&Ai!==pi),Bi=Oi&&a?d-a:d,t&&d&&bi+xi+ki>Bi&&(e?(xi&&Fi(),bi&&Yi()):(Ti||(Ti=Ei===fi&&Ai==pi),Wi||Ti||Ei===yi||Ei===_i||Ei===gi||xi+ki>Bi?(xi&&Fi(),bi&&Yi()):bi&&Yi()))," "===Ri&&!0!==Oi&&bi+xi===0||(Ei===yi?(" "===Ri&&xi&&Fi(),Ii(Ri,ki),Fi()):Wi||Ti?(xi&&Fi(),Ii(Ri,ki)):Ii(Ri,ki)),Ai=Ei);xi&&Fi(),bi&&Yi(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ci.paraNumber++,bi=r.measureText(t).width,Di.push({x:a||0,text:t,width:bi,paraStart:!0}),Pi&&Ui()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Gi(e,"x",t[zi]);break;case"right":Gi(e,"x",-t[Ni])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Gi(e,"y",t[Xi]);break;case"bottom":Gi(e,"y",-t[ji])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:_}=n,p=s*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>_)p=Math.max(_,s),t.overflow=i.length;else if(_||c)switch(l){case"middle":f+=(_-p)/2;break;case"bottom":f+=_-p}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<g||y.width>g&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=p}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,d,l,h,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,h=o||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!o&&(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,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),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?a:[a[o-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){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,a),"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 qi={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,qi),Object.assign(X,Dt),Object.assign(P,pe),Object.assign(I,Me),Object.assign(N,Ne);const{setPoint:Vi,addPoint:Qi,toBounds:Ji}=z;const Zi={export(t,e,i){this.running=!0;const n=G.fileType(e),s=e.includes(".");return i=G.getExportOptions(i),function(t){$i||($i=new H);return new Promise((e=>{$i.add((()=>et(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((o=>{const r=t=>{a(t),o(),this.running=!1},{toURL:d}=q,{download:l}=q.origin;if("json"===n)return s&&l(d(JSON.stringify(t.toJSON(i.json)),"text"),e),r({data:!!s||t.toJSON(i.json)});if("svg"===n)return s&&l(d(t.toSVG(),"svg"),e),r({data:!!s||t.toSVG()});const{leafer:h}=t;h?(Ki(t),h.waitViewCompleted((()=>et(this,void 0,void 0,(function*(){let n,s,a=1,o=1;const{worldTransform:d,isLeafer:l,isFrame:c}=t,{slice:u,trim:f,padding:g,onCanvas:_}=i,p=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,y=i.screenshot||t.isApp,m=l&&y&&void 0===i.fill?t.fill:i.fill,v=G.isOpaqueImage(e)||m,x=new V;if(y)n=!0===y?l?h.canvas.bounds:t.worldRenderBounds:y;else{let e=i.relative||(l?"inner":"local");switch(a=d.scaleX,o=d.scaleY,e){case"inner":x.set(d);break;case"local":x.set(d).divide(t.localTransform),a/=t.scaleX,o/=t.scaleY;break;case"world":a=1,o=1;break;case"page":e=t.leafer;default:x.set(d).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,o/=o/i.scaleY}n=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};Q.getScaleData(i.scale,i.size,n,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:L}=new j(n).scale(b.scaleX,b.scaleY),E={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-k).withScale(1/a*b.scaleX,1/o*b.scaleY)};let A,W=J.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:B,smooth:p,contextSettings:w});if(u&&(A=t,A.__worldOpacity=0,t=h,E.bounds=W.bounds),W.save(),c&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(W,E),t.fill=e}else t.__render(W,E);if(W.restore(),A&&A.__updateWorldOpacity(),f){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Qi(o,s,a):Vi(o={},s,a)),r++;const d=new j;return Ji(o,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:B};W=J.canvas(n),W.copyWorld(t,s,n)}if(g){const[t,e,i,n]=Q.fourNumber(g),s=W,{width:a,height:o}=s;W=J.canvas({width:a+n+e,height:o+t+i,pixelRatio:B}),W.copyWorld(s,s.bounds,{x:n,y:t,width:a,height:o})}v&&W.fillWorld(W.bounds,m||"#FFFFFF","destination-over"),_&&_(W);const T="canvas"===e?W:yield W.export(e,i);r({data:T,width:W.pixelWidth,height:W.pixelHeight,renderBounds:n,trimBounds:s})}))))):r({data:!1})}))))}};let $i;function Ki(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ki(t)))}const tn=Z.prototype,en=$.get("@leafer-in/export");tn.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)},tn.toBlob=function(t,e){return new Promise((i=>{q.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(t,e){return q.origin.canvasToDataURL(this.view,t,e)},tn.saveAs=function(t,e){return new Promise((i=>{q.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},K.add("export"),Object.assign(F,Zi),tt.prototype.export=function(t,e){return F.export(this,t,e)},Object.assign(n,{interaction:(t,e,i,n)=>new C(t,e,i,n),hitCanvas:(t,e)=>new it(t,e),hitCanvasManager:()=>new M});export{yt as Layouter,it as LeaferCanvas,bt as Picker,vt as Renderer,Bt as Selector,ot as Watcher,at as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as a,defineKey as o,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 _,Bounds as p,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 L,ImageEvent as E,AroundHelper as A,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{HitCanvasManager as C,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,TaskProcessor as H,Platform as q,Matrix as V,MathHelper as Q,Creator as J,LeaferCanvasBase as Z,Debug as $,Plugin as K,UI as tt}from"@leafer-ui/draw";function et(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(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(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class it 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:st}=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(nt(e),i),canvasToBolb:(t,e,i)=>et(this,void 0,void 0,(function*(){return t.toBuffer(nt(e),i)})),canvasSaveAs:(t,e,i)=>et(this,void 0,void 0,(function*(){return O(e,t.toBuffer(nt(st(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 it(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 ot{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:rt,updateBounds:dt,updateAllWorldOpacity:lt}=f,{pushAllChildBranch:ht,pushAllParent:ct}=g;const{worldBounds:ut}=_,ft={x:0,y:0,width:1e5,height:1e5};class gt{constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ut)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ft):this.afterBounds.setListWithFn(t,ut),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:pt}=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=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){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:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=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?(rt(t,!0),e.add(t),t.isBranch&&ht(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(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&&lt(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(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:n,AFTER:s}=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(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){_t(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),pt(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_(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=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 p,mt.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,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 p,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),a=new p(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,a),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 p;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 p(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 p(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 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: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,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,d=this.getBestMatchLeaf(o,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):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,a={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,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,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,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!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=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:a}=this;return e.backgrounder&&s&&s.updateLayout(),a.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){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;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,a)}function kt(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?Et(t,!0,e,i):Lt(e,i);break;case"inside":St("inside",t,s,e,i);break;case"outside":St("outside",t,s,e,i)}}function St(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?Et(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;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;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,a)}function Et(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],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 At(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(s,{watcher:(t,e)=>new ot(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:Tt,getByMove:Ot,getIntersectData:Ct}=B;let Mt;function Pt(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:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:D.string(o,r)};case"image":return P.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 Dt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Mt=P.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Pt(t,a[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?Rt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&P.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?Rt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?Rt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?Rt(e,i):s?i.fill(s):i.fill())},fillText:Rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)kt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&At(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 a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)kt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),Et(t,!1,e,i),n.__useArrow&&At(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Et(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),Et(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:kt,drawTextStroke:Lt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Ct(n?Wt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Tt(s,o),a=Ot(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(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let It={};const{get:Ft,rotateOfOuter:Yt,translate:Ut,scaleOfOuter:Xt,scale:Nt,rotate:jt}=k;function zt(t,e,i,n,s,a,o){const r=Ft();Ut(r,e.x+i,e.y+n),Nt(r,s,a),o&&Yt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Gt(t,e,i,n,s,a,o){const r=Ft();Ut(r,e.x+i,e.y+n),s&&Nt(r,s,a),o&&jt(r,o),t.transform=r}function Ht(t,e,i,n,s,a,o,r,d,l){const h=Ft();if(d)if("center"===l)Yt(h,{x:i/2,y:n/2},d);else switch(jt(h,d),d){case 90:Ut(h,n,0);break;case 180:Ut(h,i,n);break;case 270:Ut(h,0,i)}It.x=e.x+s,It.y=e.y+a,Ut(h,It.x,It.y),o&&Xt(h,It,o,r),t.transform=h}const{get:qt,translate:Vt}=k,Qt=new p,Jt={},Zt={};function $t(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Kt(i,n,e)}function Kt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u,filters:f}=t,g=e.width===n&&e.height===s,_={mode:o},p="center"!==r&&(c||0)%180==90,w=p?s:n,y=p?n:s;let m,v,x=0,b=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(S.getScaleData(l,h,i,Zt),m=Zt.scaleX,v=Zt.scaleY);else if(!g||c){const t=e.width/w,i=e.height/y;m=v="fit"===o?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),L.toPoint(r,t,e,Jt,!0),x+=Jt.x,b+=Jt.y}switch(d&&(x+=d.x,b+=d.y),o){case"stretch":g||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||c)&&Gt(_,e,x,b,m,v,c);break;case"repeat":(!g||m||c)&&Ht(_,e,n,s,x,b,m,v,c,r),u||(_.repeat="repeat");break;default:m&&zt(_,e,x,b,m,v,c)}return _.transform||(e.x||e.y)&&(_.transform=qt(),Vt(_.transform,e.x,e.y)),m&&"stretch"!==o&&(_.scaleX=m,_.scaleY=v),_.width=n,_.height=s,a&&(_.opacity=a),f&&(_.filters=f),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let te,ee=new p;const{isSame:ie}=B;function ne(t,e,i,n,s,a){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||$t(s,n,i,a),!0}function se(t,e){re(t,E.LOAD,e)}function ae(t,e){re(t,E.LOADED,e)}function oe(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,E.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,scale:he,copy:ce}=k,{ceil:ue,abs:fe}=Math;function ge(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=fe(s),a=fe(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:_}=r;u&&(l=le(),ce(l,g),he(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const p=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)}p>w&&(d=Math.sqrt(p/w)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(g||1!==s||1!==a)&&(l||(l=le(),g&&ce(l,g)),he(l,1/s,1/a));const y=t.getCanvas(ue(h)||1,ue(c)||1,r.opacity,r.filters),m=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=o,!0}}const{abs:_e}=Math;const pe={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return te&&i===te.paint&&ie(n,te.boxBounds)?a=te.leafPaint:(a={type:i.type,image:r},te=r.use>1?{leafPaint:a,paint:i,boxBounds:ee.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ne(t,e,i,r,a,n),s&&(se(t,o),ae(t,o))):r.error?s&&oe(t,o,r.error):(s&&(de(t,!0),se(t,o)),a.loadId=r.load((()=>{de(t,!1),t.destroyed||(ne(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,o)),a.loadId=null}),(e=>{de(t,!1),oe(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===a+"-"+o+"-"+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(a)*r,i*=_e(o)*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?ge(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>et(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ge(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:ge,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,x.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:$t,getPatternData:Kt,fillOrFitMode:zt,clipMode:Gt,repeatMode:Ht},{toPoint:we}=A,ye={},me={};function ve(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:xe,getDistance:be}=W,{get:Be,rotateOfOuter:Re,scaleOfOuter:ke}=k,{toPoint:Se}=A,Le={},Ee={};function Ae(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=xe(e,i);a=Be(),s?(ke(a,e,o/r*(n||1),1),Re(a,e,t+90)):(ke(a,e,1,o/r*(n||1)),Re(a,e,t))}return a}const{getDistance:We}=W,{toPoint:Te}=A,Oe={},Ce={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;we(n||"top",i,ye),we(s||"bottom",i,me);const d=e.canvas.createLinearGradient(ye.x,ye.y,me.x,me.y);ve(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Se(n||"center",i,Le),Se(s||"bottom",i,Ee);const l=e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,be(Le,Ee));ve(l,t.stops,o);const h={type:a,style:l},c=Ae(i,Le,Ee,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Te(n||"center",i,Oe),Te(s||"bottom",i,Ce);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Oe.x,Oe.y):e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,We(Oe,Ce));ve(l,t.stops,o);const h={type:a,style:l},c=Ae(i,Oe,Ce,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Ae},{copy:Pe,toOffsetOutBounds:De}=B,Ie={},Fe={};function Ye(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Pe(Ie,t.bounds),Ie.x+=i.x-o.x,Ie.y+=i.y-o.y,n){const{matrix:t}=s;Ie.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ie.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ie.width*=n,Ie.height*=n}t.copyWorld(s.canvas,t.bounds,Ie)}else n&&(Pe(Ie,i),Ie.x-=i.width/2*(n-1),Ie.y-=i.height/2*(n-1),Ie.width*=n,Ie.height*=n),t.copyWorld(s.canvas,o,n?Ie:i)}const{toOffsetOutBounds:Ue}=B,Xe={};const Ne={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;De(l,Fe),r.forEach(((r,_)=>{f.setWorldShadow(Fe.offsetX+r.x*c,Fe.offsetY+r.y*u,r.blur*c,D.string(r.color)),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Fe,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ue(l,Xe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Xe.offsetX+r.x*c,Xe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Xe,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(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,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<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:je}=_;function ze(t,e,i,n,s,a){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,a);break;case"path":i.restore()}}function Ge(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,a,o,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(o&&(ze(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ge(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Ge(t)),s||(s=Ge(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||je(i,e)||i.__render(s||t,e);ze(this,o,t,s,n,a)};const qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=qe+"_#~&*+\\=|≮≯≈≠=…",Qe=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 Je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ze=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Je(qe),ti=Je(Ve),ei=Je("- —/~|┆·");var ii;!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"}(ii||(ii={}));const{Letter:ni,Single:si,Before:ai,After:oi,Symbol:ri,Break:di}=ii;function li(t){return Ze[t]?ni:ei[t]?di:$e[t]?ai:Ke[t]?oi:ti[t]?ri:Qe.test(t)?si:ni}const hi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ci(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:ui}=hi,{Letter:fi,Single:gi,Before:_i,After:pi,Symbol:wi,Break:yi}=ii;let mi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ai,Wi,Ti,Oi,Ci,Mi,Pi,Di=[];function Ii(t,e){Li&&!Si&&(Si=Li),mi.data.push({char:t,width:e}),xi+=e}function Fi(){bi+=xi,mi.width=xi,vi.words.push(mi),mi={data:[]},xi=0}function Yi(){Oi&&(Ci.paraNumber++,vi.paraStart=!0,Oi=!1),Li&&(vi.startCharSize=Si,vi.endCharSize=Li,Si=0),vi.width=bi,Mi.width?ui(vi):Pi&&Ui(),Di.push(vi),vi={words:[]},bi=0}function Ui(){bi>(Ci.maxWidth||0)&&(Ci.maxWidth=bi)}const{top:Xi,right:Ni,bottom:ji,left:zi}=T;function Gi(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,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[zi],a-=l[Ni]+l[zi]):i.autoSizeAlign||(n=l[zi]),o?(s=l[Xi],o-=l[Xi]+l[ji]):i.autoSizeAlign||(s=l[Xi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Ci=t,Di=t.rows,Mi=t.bounds,Pi=!Mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=Mi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Oi=!0,Ai=null,Si=ki=Li=xi=bi=0,mi={data:[]},vi={words:[]};for(let n=0,l=i.length;n<l;n++)Ri=i[n],"\n"===Ri?(xi&&Fi(),vi.paraEnd=!0,Yi(),Oi=!0):(Ei=li(Ri),Ei===fi&&"none"!==o&&(Ri=ci(Ri,o,!xi)),ki=r.measureText(Ri).width,s&&(s<0&&(Li=ki),ki+=s),Wi=Ei===gi&&(Ai===gi||Ai===fi)||Ai===gi&&Ei!==pi,Ti=!(Ei!==_i&&Ei!==gi||Ai!==wi&&Ai!==pi),Bi=Oi&&a?d-a:d,t&&d&&bi+xi+ki>Bi&&(e?(xi&&Fi(),bi&&Yi()):(Ti||(Ti=Ei===fi&&Ai==pi),Wi||Ti||Ei===yi||Ei===_i||Ei===gi||xi+ki>Bi?(xi&&Fi(),bi&&Yi()):bi&&Yi()))," "===Ri&&!0!==Oi&&bi+xi===0||(Ei===yi?(" "===Ri&&xi&&Fi(),Ii(Ri,ki),Fi()):Wi||Ti?(xi&&Fi(),Ii(Ri,ki)):Ii(Ri,ki)),Ai=Ei);xi&&Fi(),bi&&Yi(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ci.paraNumber++,bi=r.measureText(t).width,Di.push({x:a||0,text:t,width:bi,paraStart:!0}),Pi&&Ui()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Gi(e,"x",t[zi]);break;case"right":Gi(e,"x",-t[Ni])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Gi(e,"y",t[Xi]);break;case"bottom":Gi(e,"y",-t[ji])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:_}=n,p=s*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>_)p=Math.max(_,s),t.overflow=i.length;else if(_||c)switch(l){case"middle":f+=(_-p)/2;break;case"bottom":f+=_-p}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<g||y.width>g&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=p}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,d,l,h,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,h=o||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!o&&(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,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),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?a:[a[o-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){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,a),"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 qi={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,qi),Object.assign(X,Dt),Object.assign(P,pe),Object.assign(I,Me),Object.assign(N,Ne);const{setPoint:Vi,addPoint:Qi,toBounds:Ji}=j;const Zi={export(t,e,i){this.running=!0;const n=G.fileType(e),s=e.includes(".");return i=G.getExportOptions(i),function(t){$i||($i=new H);return new Promise((e=>{$i.add((()=>et(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((o=>{const r=t=>{a(t),o(),this.running=!1},{toURL:d}=q,{download:l}=q.origin;if("json"===n)return s&&l(d(JSON.stringify(t.toJSON(i.json)),"text"),e),r({data:!!s||t.toJSON(i.json)});if("svg"===n)return s&&l(d(t.toSVG(),"svg"),e),r({data:!!s||t.toSVG()});const{leafer:h}=t;h?(Ki(t),h.waitViewCompleted((()=>et(this,void 0,void 0,(function*(){let n,s,a=1,o=1;const{worldTransform:d,isLeafer:l,isFrame:c}=t,{slice:u,trim:f,padding:g,onCanvas:_}=i,p=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,y=i.screenshot||t.isApp,m=l&&y&&void 0===i.fill?t.fill:i.fill,v=G.isOpaqueImage(e)||m,x=new V;if(y)n=!0===y?l?h.canvas.bounds:t.worldRenderBounds:y;else{let e=i.relative||(l?"inner":"local");switch(a=d.scaleX,o=d.scaleY,e){case"inner":x.set(d);break;case"local":x.set(d).divide(t.localTransform),a/=t.scaleX,o/=t.scaleY;break;case"world":a=1,o=1;break;case"page":e=t.leafer;default:x.set(d).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,o/=o/i.scaleY}n=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};Q.getScaleData(i.scale,i.size,n,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:L}=new z(n).scale(b.scaleX,b.scaleY),E={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-k).withScale(1/a*b.scaleX,1/o*b.scaleY)};let A,W=J.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:B,smooth:p,contextSettings:w});if(u&&(A=t,A.__worldOpacity=0,t=h,E.bounds=W.bounds),W.save(),c&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(W,E),t.fill=e}else t.__render(W,E);if(W.restore(),A&&A.__updateWorldOpacity(),f){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Qi(o,s,a):Vi(o={},s,a)),r++;const d=new z;return Ji(o,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:B};W=J.canvas(n),W.copyWorld(t,s,n)}if(g){const[t,e,i,n]=Q.fourNumber(g),s=W,{width:a,height:o}=s;W=J.canvas({width:a+n+e,height:o+t+i,pixelRatio:B}),W.copyWorld(s,s.bounds,{x:n,y:t,width:a,height:o})}v&&W.fillWorld(W.bounds,m||"#FFFFFF","destination-over"),_&&_(W);const T="canvas"===e?W:yield W.export(e,i);r({data:T,width:W.pixelWidth,height:W.pixelHeight,renderBounds:n,trimBounds:s})}))))):r({data:!1})}))))}};let $i;function Ki(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ki(t)))}const tn=Z.prototype,en=$.get("@leafer-in/export");tn.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)},tn.toBlob=function(t,e){return new Promise((i=>{q.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(t,e){return q.origin.canvasToDataURL(this.view,t,e)},tn.saveAs=function(t,e){return new Promise((i=>{q.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},K.add("export"),Object.assign(F,Zi),tt.prototype.export=function(t,e){return F.export(this,t,e)},Object.assign(s,{interaction:(t,e,i,n)=>new M(t,e,i,n),hitCanvas:(t,e)=>new it(t,e),hitCanvasManager:()=>new C});export{yt as Layouter,it as LeaferCanvas,bt as Picker,vt as Renderer,Bt as Selector,ot as Watcher,at as useCanvas};
2
2
  //# sourceMappingURL=node.esm.min.js.map