@leafer-ui/node 1.0.0-rc.2 → 1.0.0-rc.21

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 +1 @@
1
- import{LeafList as t,DataHelper as e,RenderEvent as s,ChildEvent as i,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as f,Run as _,ImageManager as g,Platform as p,AnimateEvent as w,ResizeEvent as y,Creator as m,LeaferCanvasBase as v,LeaferImage as x,InteractionBase as b,MatrixHelper as B,ImageEvent as R,PointHelper as E,MathHelper as L,TaskProcessor as k}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as S,Paint as A,Effect as O,TextConvert as C,Export as M}from"@leafer-ui/core";export*from"@leafer-ui/core";class T{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(s,i){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=s,i&&(this.config=e.default(i,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(s.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===i.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([i.ADD,i.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:I,updateAllWorldOpacity:W}=a,{pushAllChildBranch:D,pushAllParent:P}=o;const{worldBounds:F}=h,{setByListWithHandle:N}=l;class U{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){N(this.beforeBounds,this.updatedList.list,F)}setAfter(){N(this.afterBounds,this.updatedList.list,F),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:Y,updateAllChange:H}=a,{pushAllBranchStack:V,updateWorldBoundsByBranchStack:j}=o,q=c.get("Layouter");class X{constructor(t,s){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,s&&(this.config=e.default(s,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(f.START),this.layoutOnce(),t.emitEvent(new f(f.END,this.layoutedBlocks,this.times))}catch(t){q.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?q.warn("layouting"):this.times>3?q.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.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=_.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=f,o=this.getBlocks(i);o.forEach((t=>{t.setBefore()})),s.emitEvent(new f(n,o,this.times)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(I(t),e.push(t),t.isBranch&&D(t,e),P(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),P(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&W(t),t.__updateChange()}))}(i),o.forEach((t=>t.setAfter())),s.emitEvent(new f(r,o,this.times)),s.emitEvent(new f(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,_.end(e)}fullLayout(){const e=_.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=f,a=this.getBlocks(new t(s));s.emitEvent(new f(i,a,this.times)),X.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new f(n,a,this.times)),s.emitEvent(new f(r,a,this.times)),this.addBlocks(a),_.end(e)}static fullLayout(t){if(Y(t),t.isBranch){const e=[t];V(t,e),j(e)}else t.__updateWorldBounds();H(t)}createBlock(t){return new U(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_(f.REQUEST,this.layout,this),t.on_(f.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const G=c.get("Renderer");class z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=s,i&&(this.config=e.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(f.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,G.log(e.innerName,"---\x3e");try{this.emitRender(s.START),this.renderOnce(t),this.emitRender(s.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,G.error(t)}G.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?G.warn("rendering"):this.times>3?G.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(s.BEFORE),t()):(this.requestLayout(),this.emitRender(s.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(s.RENDER,this.renderBounds,this.renderOptions),this.emitRender(s.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return G.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=_.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world),r=(new d).copy(i);s.save(),n&&!c.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,r),s.restore(),_.end(e)}fullRender(){const t=_.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),_.end(t)}__render(t,e){const s=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:s}=t.old;new d(0,0,e,s).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||G.warn(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 s(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(s.REQUEST,this.update,this),t.on_(f.END,this.__onLayoutEnd,this),t.on_(s.AGAIN,this.renderAgain,this),t.on_(y.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:Q}=l;class Z{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:s,y:i}=this.point,n={x:s,y:i,radiusX:0,radiusY:0};for(let s=0,i=t.length;s<i;s++)if(e=t[s],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const s=new t;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||Q(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class K{constructor(t,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,s&&(this.config=e.default(s,this.config)),this.findPath=new Z(t,this),this.__listenEvents()}getByPoint(t,e,s){return"node"===p.name&&this.target.emit(f.CHECK_UPDATE),this.findPath.getByPoint(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(i.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new T(t,e),layouter:(t,e)=>new X(t,e),renderer:(t,e,s)=>new z(t,e,s),selector:(t,e)=>new K(t,e)}),p.layout=X.fullLayout;class $ extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}function J(t,e){if(!p.origin){if("skia"===t){const{Canvas:t,loadImage:s}=e;p.origin={createCanvas:(e,s,i)=>new t(e,s,i),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),loadImage:s}}p.canvas=m.canvas()}}Object.assign(m,{canvas:(t,e)=>new $(t,e),image:t=>new x(t),hitCanvas:(t,e)=>new $(t,e),interaction:(t,e,s,i)=>new b(t,e,s,i)}),p.name="node",p.requestRender=function(t){setTimeout(t)},p.devicePixelRatio=1,p.conicGradientSupport=!0,p.realtimeLayout=!0;const{get:tt,rotateOfOuter:et,translate:st,scaleOfOuter:it,scale:nt,rotate:rt}=B;const{get:at,translate:ot}=B;function dt(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(f.transform=at(),ot(f.transform,i.x,i.y));break;case"clip":(d||h||l)&&function(t,e,s,i,n){const r=tt();st(r,e.x,e.y),s&&st(r,s.x,s.y),i&&("number"==typeof i?nt(r,i):nt(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&rt(r,n),t.transform=r}(f,i,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,s,i,n,r){const a=tt();if(r)switch(rt(a,r),r){case 90:st(a,i,0);break;case 180:st(a,s,i);break;case 270:st(a,0,s)}st(a,e.x,e.y),n&&(it(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,i,n,r,h,l);break;default:u&&!l||function(t,e,s,i,n,r){const a=tt(),o=r&&180!==r,d=s.width/(o?n:i),h=s.height/(o?i:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=s.x+(s.width-i*l)/2,u=s.y+(s.height-n*l)/2;st(a,c,u),nt(a,l),r&&et(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(f,o,i,n,r,l)}f.width=n,f.height=r,a&&(f.opacity=a)}function ht(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function lt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new R(t,e))}function ct(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:ut,scale:ft,copy:_t}=B;function gt(t,e,s){let{scaleX:i,scaleY:n}=t.__world;const r=i+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,i=Math.abs(i),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:f,scaleY:_,opacity:g,transform:w,mode:y}=a;f&&(l=ut(),_t(l,w),ft(l,1/f,1/_),i*=f,n*=_),i*=s,n*=s,c*=i,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(i/=h,n/=h,c/=h,u/=h),f&&(i/=f,n/=_),(w||1!==i||1!==n)&&(l||(l=ut(),w&&_t(l,w)),ft(l,1/i,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===y?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function pt(t,e,s,i){const{scaleX:n,scaleY:r}=t.__world;if(s.data&&s.patternId!==n+"-"+r){if(i)if(s.image.isSVG&&"repeat"!==s.data.mode){let{width:t,height:a}=s.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,i=t>4096||a>4096}else i=!1;if(i){e.save(),e.clip();const{data:t}=s;return s.blendMode&&(e.blendMode=s.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(s.image.view,0,0,t.width,t.height),e.restore(),!0}return s.style?g.patternTasker.add((()=>ct(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&&gt(t,s,e.pixelRatio)&&t.forceUpdate("surface")}))),300):gt(t,s,e.pixelRatio),!1}return!1}function wt(t,e){const s="fill"===e?t._fill:t._stroke;if(s instanceof Array){let i,n,r,a;for(let o=0,d=s.length;o<d;o++)i=s[o].image,a=i&&i.url,a&&(n||(n={}),n[a]=!0,g.recycle(i),i.loading&&(r||(r=t.__input&&t.__input[e]||[],r instanceof Array||(r=[r])),i.unload(s[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function yt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function mt(t,e,s){const{strokeAlign:i}=t.__,n="string"!=typeof s;switch(i){case"center":e.setStroke(n?void 0:s,t.__.strokeWidth,t.__),n?bt(t,s,e,!0):xt(t,e);break;case"inside":vt(t,e,s,"inside",n);break;case"outside":vt(t,e,s,"outside",n)}}function vt(t,e,s,i,n){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(n?void 0:s,2*r,t.__),o.font=a,n?bt(t,s,o,!0):xt(t,o),o.blendMode="outside"===i?"destination-out":"destination-in",yt(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function xt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.strokeText(t.char,t.x,s.y)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function bt(t,e,s,i){let n;for(let r=0,a=e.length;r<a;r++)n=e[r],n.image&&pt(t,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),i?xt(t,s):s.stroke(),s.restoreBlendMode()):i?xt(t,s):s.stroke())}const{getSpread:Bt,getOuterOf:Rt,getByMove:Et,getIntersectData:Lt}=l;const kt={x:.5,y:0},St={x:.5,y:1};function At(t,e,s){let i;for(let n=0,r=e.length;n<r;n++)i=e[n],t.addColorStop(i.offset,S.string(i.color,s))}const{set:Ot,getAngle:Ct,getDistance:Mt}=E,{get:Tt,rotateOfOuter:It,scaleOfOuter:Wt}=B,Dt={x:.5,y:.5},Pt={x:.5,y:1},Ft={},Nt={};const{set:Ut,getAngle:Yt,getDistance:Ht}=E,{get:Vt,rotateOfOuter:jt,scaleOfOuter:qt}=B,Xt={x:.5,y:.5},Gt={x:.5,y:1},zt={},Qt={};let Zt;function Kt(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:S.string(a,o)};case"image":return function(t,e,s,i,n){const r={type:s.type},a=r.image=g.get(s),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:s};return a.ready?(ht(t,e,a)&&dt(r,a,s,i),n&&(lt(R.LOAD,o),lt(R.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,lt(R.ERROR,o)):(n&&lt(R.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(ht(t,e,a)&&(dt(r,a,s,i),t.forceUpdate("surface")),lt(R.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,lt(R.ERROR,o)}))),r}(t,s,e,i,!Zt||!Zt[e.url]);case"linear":return function(t,e){let{from:s,to:i,type:n,blendMode:r,opacity:a}=t;s||(s=kt),i||(i=St);const o=p.canvas.createLinearGradient(e.x+s.x*e.width,e.y+s.y*e.height,e.x+i.x*e.width,e.y+i.y*e.height);At(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,i);case"radial":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Dt),i||(i=Pt);const{x:d,y:h,width:l,height:c}=e;let u;Ot(Ft,d+s.x*l,h+s.y*c),Ot(Nt,d+i.x*l,h+i.y*c),(l!==c||o)&&(u=Tt(),Wt(u,Ft,l/c*(o||1),1),It(u,Ft,Ct(Ft,Nt)+90));const f=p.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Mt(Ft,Nt));At(f,t.stops,r);const _={type:n,style:f,transform:u};return a&&(_.blendMode=a),_}(e,i);case"angular":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Xt),i||(i=Gt);const{x:d,y:h,width:l,height:c}=e;Ut(zt,d+s.x*l,h+s.y*c),Ut(Qt,d+i.x*l,h+i.y*c);const u=Vt(),f=Yt(zt,Qt);p.conicGradientRotate90?(qt(u,zt,l/c*(o||1),1),jt(u,zt,f+90)):(qt(u,zt,1,l/c*(o||1)),jt(u,zt,f));const _=p.conicGradientSupport?p.canvas.createConicGradient(0,zt.x,zt.y):p.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Ht(zt,Qt));At(_,t.stops,r);const g={type:n,style:_,transform:u};return a&&(g.blendMode=a),g}(e,i);default:return e.r?{type:"solid",style:S.string(e)}:void 0}}var $t=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let i,n=t.__.__input[e];n instanceof Array||(n=[n]),Zt=wt(t.__,e);for(let r=0,a=n.length;r<a;r++)i=Kt(t,n[r],e),i&&s.push(i);t.__["_"+e]=s.length?s:void 0},drawTextStroke:xt,fill:function(t,e,s){e.fillStyle=s,t.__.__font?yt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:yt,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)i=s[a],i.image&&pt(t,e,i,!r)||i.style&&(e.fillStyle=i.style,i.transform?(e.save(),e.transform(i.transform),i.blendMode&&(e.blendMode=i.blendMode),r?yt(t,e):n?e.fill(n):e.fill(),e.restore()):i.blendMode?(e.saveBlendMode(i.blendMode),r?yt(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):r?yt(t,e):n?e.fill(n):e.fill())},recycleImage:wt,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,s.matrix))s.matrix?(h*=s.matrix.a,l*=s.matrix.d,n=a=Rt(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=Lt(i?Bt(e.bounds,i*h,i*l):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),h*=r.a,l*=r.d),a=Rt(d,r),n=Et(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)mt(t,e,s);else switch(r){case"center":e.setStroke(s,n,i),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*n,t.__),t.__drawRenderPath(r),r.stroke(),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:mt,strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)mt(t,e,s);else switch(r){case"center":e.setStroke(void 0,n,i),bt(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),bt(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*n,t.__),bt(t,s,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:Jt,toOffsetOutBounds:te}=l,ee={},se={};function ie(t,e,s,i){const{bounds:n,shapeBounds:r}=i;if(p.fullImageShadow){if(Jt(ee,t.bounds),ee.x+=e.x-r.x,ee.y+=e.y-r.y,s){const{matrix:t}=i;ee.x-=(n.x+(t?t.e:0)+n.width/2)*(s-1),ee.y-=(n.y+(t?t.f:0)+n.height/2)*(s-1),ee.width*=s,ee.height*=s}t.copyWorld(i.canvas,t.bounds,ee)}else s&&(Jt(ee,e),ee.x-=e.width/2*(s-1),ee.y-=e.height/2*(s-1),ee.width*=s,ee.height*=s),t.copyWorld(i.canvas,r,s?ee:e)}const{toOffsetOutBounds:ne}=l,re={};var ae=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;ne(l,re),d.forEach(((i,d)=>{_.save(),_.setWorldShadow(re.offsetX+i.x*u,re.offsetY+i.y*f,i.blur*u),r=i.spread?1-2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,ie(_,re,r,s),_.restore(),h?(_.copyWorld(_,l,a,"copy"),_.copyWorld(h,a,a,"source-out"),n=a):(_.copyWorld(s.canvas,c,l,"source-out"),n=l),_.fillWorld(n,i.color,"source-in"),t.__hasMirror?e.copyWorldByReset(_,n,a,i.blendMode):e.copyWorldToInner(_,n,o.renderBounds,i.blendMode),g&&d<g&&_.clear()})),_.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;te(l,se),d.forEach(((i,d)=>{_.setWorldShadow(se.offsetX+i.x*u,se.offsetY+i.y*f,i.blur*u,i.color),r=i.spread?1+2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,ie(_,se,r,s),n=l,i.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,a,"copy"),n=a),h?_.copyWorld(h,a,a,"destination-out"):_.copyWorld(s.canvas,c,l,"destination-out")),t.__hasMirror?e.copyWorldByReset(_,n,a,i.blendMode):e.copyWorldToInner(_,n,o.renderBounds,i.blendMode),g&&d<g&&_.clear()})),_.recycle()}});const oe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",de=oe+"_#~&*+\\=|≮≯≈≠=…",he=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function le(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ce=le("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ue=le("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fe=le(oe),_e=le(de),ge=le("- —/~|┆·");var pe;!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"}(pe||(pe={}));const{Letter:we,Single:ye,Before:me,After:ve,Symbol:xe,Break:be}=pe;function Be(t){return ce[t]?we:ge[t]?be:ue[t]?me:fe[t]?ve:_e[t]?xe:he.test(t)?ye:we}const Re={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Ee(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Le}=Re,{Letter:ke,Single:Se,Before:Ae,After:Oe,Symbol:Ce,Break:Me}=pe;let Te,Ie,We,De,Pe,Fe,Ne,Ue,Ye,He,Ve,je,qe,Xe,Ge=[];function ze(t,e){Te.data.push({char:t,width:e}),We+=e}function Qe(){De+=We,Te.width=We,Ie.words.push(Te),Te={data:[]},We=0}function Ze(){je&&(qe.paraNumber++,Ie.paraStart=!0,je=!1),Ie.width=De,Xe.width&&Le(Ie),Ge.push(Ie),Ie={words:[]},De=0}const Ke={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let s=0,i=0,{width:n,height:r,padding:a}=e;const{textDecoration:o,textOverflow:d,__font:h}=e;if(n||(n=0),a){const[t,e,o,d]=L.fourNumber(a);n&&(s=d,n-=e+d),r&&(i=t,r-=t+o)}const l={bounds:{x:s,y:i,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=h};return function(t,e,s){qe=t,Ge=t.rows,Xe=t.bounds;const{__letterSpacing:i,paraIndent:n,textCase:r}=s,{canvas:a}=p,{width:o,height:d}=Xe;if(o||d||i||"none"!==r){je=!0,Ye=null,We=De=0,Te={data:[]},Ie={words:[]};for(let t=0,s=e.length;t<s;t++)Fe=e[t],"\n"===Fe?(We&&Qe(),Ie.paraEnd=!0,Ze(),je=!0):(Ue=Be(Fe),Ue===ke&&"none"!==r&&(Fe=Ee(Fe,r,!We)),Ne=a.measureText(Fe).width,i&&(Ne+=i),He=Ue===Se&&(Ye===Se||Ye===ke)||Ye===Se&&Ue!==Oe,Ve=!(Ue!==Ae&&Ue!==Se||Ye!==Ce&&Ye!==Oe),Pe=je&&n?o-n:o,o&&De+We+Ne>Pe&&(Ve||(Ve=Ue===ke&&Ye==Oe),He||Ve||Ue===Me||Ue===Ae||Ue===Se||We+Ne>Pe?(We&&Qe(),Ze()):Ze())," "===Fe&&!0!==je&&De+We===0||(Ue===Me?(" "===Fe&&We&&Qe(),ze(Fe,Ne),Qe()):He||Ve?(We&&Qe(),ze(Fe,Ne)):ze(Fe,Ne)),Ye=Ue);We&&Qe(),De&&Ze(),Ge.length>0&&(Ge[Ge.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{qe.paraNumber++,Ge.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,textAlign:a,verticalAlign:o,paraSpacing:d,textOverflow:h}=e;let l,{x:c,y:u,width:f,height:_}=i,g=n*s.length+(d?d*(t.paraNumber-1):0),p=r;if("show"!==h&&g>_)g=Math.max(_,n),t.overflow=s.length;else switch(o){case"middle":u+=(_-g)/2;break;case"bottom":u+=_-g}p+=u;for(let r=0,o=s.length;r<o;r++){switch(l=s[r],l.x=c,a){case"center":l.x+=(f-l.width)/2;break;case"right":l.x+=f-l.width}if(l.paraStart&&d&&r>0&&(p+=d),l.y=p,p+=n,t.overflow>r&&p>g&&(l.isOverflow=!0,t.overflow=r+1),l.width<0){const t=l.words[0].data[0].width,s=l.x+l.width;s<i.x&&(i.x=s-t),-l.width>i.width&&(i.width=-l.width+e.fontSize+t)}else l.x<i.x&&(i.x=l.x),l.width>i.width&&(i.width=l.width)}i.y=u,i.height=g}(l,e),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=s&&"justify"===r&&t.words.length>1?(s-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:s,overflow:i}=t;if(s.splice(i),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=s[i-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,d),"none"!==o&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(l,e),l}},$e={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},Je={export(t,e,s){return function(t){ts||(ts=new k);return new Promise((e=>{ts.add((()=>ct(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((i=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>ct(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof s){case"object":s.quality&&(t=s.quality),s.blob&&(a=!0);break;case"number":t=s;break;case"boolean":a=s}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),i({data:o}),n(),h&&d.recycle()})))):(i({data:!1}),n())}))))}};let ts;Object.assign(A,$t),Object.assign(O,ae),Object.assign(C,Ke),Object.assign(S,$e),Object.assign(M,Je);export{X as Layouter,$ as LeaferCanvas,z as Renderer,K as Selector,T as Watcher,J as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as n,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as _,LeafBoundsHelper as g,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as B,BoundsHelper as b,Answer as R,MatrixHelper as k,ImageEvent as E,PointHelper as L,Direction4 as S,TwoPointBoundsHelper as M,TaskProcessor as A,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as T}from"fs";import{InteractionBase as W,HitCanvasManager as O}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as P,PaintGradient as D,Export as F,Group as Y,TextConvert as N,Paint as U,Effect as X}from"@leafer-ui/draw";function H(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{d(s.next(t))}catch(t){a(t)}}function r(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class G 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:V,fileType:j}=a;function q(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:s},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(V(e),i),canvasToBolb:(t,e,i)=>H(this,void 0,void 0,(function*(){return t.toBuffer(V(e),i)})),canvasSaveAs:(t,e,i)=>H(this,void 0,void 0,(function*(){return T(e,t.toBuffer(V(j(e)),i))})),download(t,e){},loadImage:s}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new G(t,e),image:t=>new n(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=r.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 l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.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:Q,updateBounds:Z,updateAllWorldOpacity:K}=u,{pushAllChildBranch:$,pushAllParent:J}=f;const{worldBounds:tt}=g,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,tt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(et):this.afterBounds.setListWithFn(t,tt),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:st,updateAllChange:nt}=u,at=p.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.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(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){at.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?at.warn("layouting"):this.times>3?at.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.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=m.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new y(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?(Q(t,!0),e.add(t),t.isBranch&&$(t,e),J(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),J(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||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&K(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),ot.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(s,a,this.times)),e.emitEvent(new y(n,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){st(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new it([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new it(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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=p.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,rt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,rt.error(t)}rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return rt.warn("rendering");if(this.times>3)return rt.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;if(!e)return rt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new _(s);i.save(),n&&!p.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(s),p.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}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(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||rt.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_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(B.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ht}=b;class lt{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=i.findList||[],i.findList||this.eachFind(a.children,a.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),d=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:d,target:r,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],u.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;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 o,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}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||ht(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ct,NoAndSkip:ut,YesAndSkip:ft}=R;class _t{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new lt(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&u.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,a;for(let o=0,r=t.length;o<r;o++){if(n=t[o],a=e(n,s),a===ct||a===ft){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<ut&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function gt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,a)}function pt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?mt(t,!0,e,i):yt(e,i);break;case"inside":wt("inside",t,n,e,i);break;case"outside":wt("outside",t,n,e,i)}}function wt(t,e,i,s,n){const{__strokeWidth:a,__font:o}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,s.__),r.font=o,i?mt(e,!0,s,r):yt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",gt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function yt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;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)})),n&&e.strokeRect(i.x,i.y+n,i.width,a)}function mt(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&I.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?yt(i,s):s.stroke(),s.restoreBlendMode()):e?yt(i,s):s.stroke())}Object.assign(s,{watcher:(t,e)=>new z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ot.fullLayout;const{getSpread:vt,getOuterOf:xt,getByMove:Bt,getIntersectData:bt}=b;let Rt;function kt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:a,color:o,opacity:r}=e;return{type:n,blendMode:a,style:P.string(o,r)};case"image":return I.image(i,t,e,s,!Rt||!Rt[e.url]);case"linear":return D.linearGradient(e,s);case"radial":return D.radialGradient(e,s);case"angular":return D.conicGradient(e,s);default:return e.r?{type:"solid",style:P.string(e)}:void 0}}const Et={compute:function(t,e){const i=e.__,s=[];let n,a=i.__input[t];a instanceof Array||(a=[a]),Rt=I.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)i=kt(t,a[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?gt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&I.checkImage(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?gt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?gt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?gt(e,i):n?i.fill(n):i.fill())},fillText:gt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)pt(t,e,i);else switch(a){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*n,s),e.__drawRenderPath(a),a.stroke(),s.windingRule?a.clip(s.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 s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)pt(t,e,i);else switch(a){case"center":i.setStroke(void 0,n,s),mt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),mt(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*n,s),mt(t,!1,e,o),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:pt,drawTextStroke:yt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=n;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(n))d=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=bt(s?vt(e.bounds,s*h,s*l):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=xt(n,o),a=Bt(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:d,shapeBounds:r,scaleX:h,scaleY:l}}};let Lt={};const{get:St,rotateOfOuter:Mt,translate:At,scaleOfOuter:Ct,scale:Tt,rotate:Wt}=k;function Ot(t,e,i,s,n,a){const o=St(),r=a&&180!==a,d=i.width/(r?n:s),h=i.height/(r?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;At(o,c,u),Tt(o,l),a&&Mt(o,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=o}function It(t,e,i,s,n,a,o){const r=St();At(r,e.x,e.y),(i||s)&&At(r,i,s),n&&(Tt(r,n,a),t.scaleX=r.a,t.scaleY=r.d),o&&Wt(r,o),t.transform=r}function Pt(t,e,i,s,n,a,o,r,d){const h=St();if(d)switch(Wt(h,d),d){case 90:At(h,s,0);break;case 180:At(h,i,s);break;case 270:At(h,0,i)}Lt.x=e.x,Lt.y=e.y,(n||a)&&(Lt.x+=n,Lt.y+=a),At(h,Lt.x,Lt.y),o&&(Ct(h,Lt,o,r),t.scaleX=o,t.scaleY=r),t.transform=h}const{get:Dt,translate:Ft}=k,Yt=new _;function Nt(t,e,i,s){let{width:n,height:a}=e;i.padding&&(s=Yt.set(s).shrink(i.padding));const{opacity:o,mode:r,offset:d,scale:h,size:l,rotation:c,blendMode:u,repeat:f}=i,_=s.width===n&&s.height===a;u&&(t.blendMode=u);const g=t.data={mode:r};let p,w,y,m;switch(d&&(p=d.x,w=d.y),l?(y=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/a):h&&(y="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y),r){case"strench":_||(n=s.width,a=s.height);break;case"clip":(d||y||c)&&It(g,s,p,w,y,m,c);break;case"repeat":(!_||y||c)&&Pt(g,s,n,a,p,w,y,m,c),f||(g.repeat="repeat");break;default:_&&!c||Ot(g,r,s,n,a,c)}g.transform||(s.x||s.y)&&(g.transform=Dt(),Ft(g.transform,s.x,s.y)),g.width=n,g.height=a,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Ut,Xt=new _;const{isSame:Ht}=b;function Gt(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||Nt(n,s,i,a),!0}function Vt(t,e){zt(t,E.LOAD,e)}function jt(t,e){zt(t,E.LOADED,e)}function qt(t,e,i){e.error=i,t.forceUpdate("surface"),zt(t,E.ERROR,e)}function zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function Qt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Zt,scale:Kt,copy:$t}=k,{ceil:Jt,abs:te}=Math;function ee(t,i,s){let{scaleX:n,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=n+"-"+a;if(i.patternId===o||t.destroyed)return!1;{n=te(n),a=te(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(h=Zt(),$t(h,g),Kt(h,1/u,1/f),n*=u,a*=f),n*=s,a*=s,l*=n,c*=a;const w=l*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&&(n/=d,a/=d,l/=d,c/=d),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(h||(h=Zt(),g&&$t(h,g)),Kt(h,1/n,1/a));const m=t.getCanvas(Jt(l)||1,Jt(c)||1,_),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}const{abs:ie}=Math;const se={image:function(t,e,i,s,n){let a,o;const r=v.get(i);return Ut&&i===Ut.paint&&Ht(s,Ut.boxBounds)?a=Ut.leafPaint:(a={type:i.type,image:r},Ut=r.use>1?{leafPaint:a,paint:i,boxBounds:Xt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Gt(t,e,i,r,a,s),n&&(Vt(t,o),jt(t,o))):r.error?n&&qt(t,o,r.error):(Qt(t,!0),n&&Vt(t,o),a.loadId=r.load((()=>{Qt(t,!1),t.destroyed||(Gt(t,e,i,r,a,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),jt(t,o)),a.loadId=null}),(e=>{Qt(t,!1),qt(t,o,e),a.loadId=null}))),a},createData:Nt,fillOrFitMode:Ot,clipMode:It,repeatMode:Pt,createPattern:ee,checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;if(s.data&&s.patternId!==a+"-"+o){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=ie(a)*i.pixelRatio,s*=ie(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||F.running?ee(t,s,i.pixelRatio):s.patternTask||(s.patternTask=v.patternTasker.add((()=>H(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ee(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o;for(let r=0,d=i.length;r<d;r++)s=i[r].image,o=s&&s.url,o&&(n||(n={}),n[o]=!0,v.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[r].loadId,!a.some((t=>t.url===o)))));return n}return null}},ne={x:.5,y:0},ae={x:.5,y:1};function oe(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,P.string(s.color,i))}const{set:re,getAngle:de,getDistance:he}=L,{get:le,rotateOfOuter:ce,scaleOfOuter:ue}=k,fe={x:.5,y:.5},_e={x:.5,y:1},ge={},pe={};const{set:we,getAngle:ye,getDistance:me}=L,{get:ve,rotateOfOuter:xe,scaleOfOuter:Be}=k,be={x:.5,y:.5},Re={x:.5,y:1},ke={},Ee={};const Le={linearGradient:function(t,i){let{from:s,to:n,type:a,blendMode:o,opacity:r}=t;s||(s=ne),n||(n=ae);const d=e.canvas.createLinearGradient(i.x+s.x*i.width,i.y+s.y*i.height,i.x+n.x*i.width,i.y+n.y*i.height);oe(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=fe),n||(n=_e);const{x:h,y:l,width:c,height:u}=i;let f;re(ge,h+s.x*c,l+s.y*u),re(pe,h+n.x*c,l+n.y*u),(c!==u||d)&&(f=le(),ue(f,ge,c/u*(d||1),1),ce(f,ge,de(ge,pe)+90));const _=e.canvas.createRadialGradient(ge.x,ge.y,0,ge.x,ge.y,he(ge,pe));oe(_,t.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=be),n||(n=Re);const{x:h,y:l,width:c,height:u}=i;we(ke,h+s.x*c,l+s.y*u),we(Ee,h+n.x*c,l+n.y*u);const f=ve(),_=ye(ke,Ee);e.conicGradientRotate90?(Be(f,ke,c/u*(d||1),1),xe(f,ke,_+90)):(Be(f,ke,1,c/u*(d||1)),xe(f,ke,_));const g=e.conicGradientSupport?e.canvas.createConicGradient(0,ke.x,ke.y):e.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,me(ke,Ee));oe(g,t.stops,o);const p={type:a,style:g,transform:f};return r&&(p.blendMode=r),p}},{copy:Se,toOffsetOutBounds:Me}=b,Ae={},Ce={};function Te(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Se(Ae,t.bounds),Ae.x+=i.x-o.x,Ae.y+=i.y-o.y,s){const{matrix:t}=n;Ae.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Ae.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Ae.width*=s,Ae.height*=s}t.copyWorld(n.canvas,t.bounds,Ae)}else s&&(Se(Ae,i),Ae.x-=i.width/2*(s-1),Ae.y-=i.height/2*(s-1),Ae.width*=s,Ae.height*=s),t.copyWorld(n.canvas,o,s?Ae:i)}const{toOffsetOutBounds:We}=b,Oe={};const Ie={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Me(h,Ce),r.forEach(((r,g)=>{f.setWorldShadow(Ce.offsetX+r.x*c,Ce.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Te(f,Ce,n,i),s=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),_&&g<_&&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:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;We(h,Oe),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Oe.offsetX+r.x*c,Oe.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Te(f,Oe,n,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,h,"source-out"),s=h),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),_&&g<_&&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:Pe}=g;function De(t,e,i,s,n,a){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ye(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ye(t,i,s,a);break;case"path":i.restore()}}function Fe(t){return t.getSameCanvas(!1,!0)}function Ye(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;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(De(this,o,t,n,s,a),s=n=null),"path"===i.__.maskType?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=Fe(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="alpha",s||(s=Fe(t)),n||(n=Fe(t)),i.__render(s,e)),"clipping"!==i.__.maskType)||Pe(i,e)||i.__render(n||t,e);De(this,o,t,n,s,a)};const Ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=Ne+"_#~&*+\\=|≮≯≈≠=…",Xe=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 He(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ge=He("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ve=He("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),je=He(Ne),qe=He(Ue),ze=He("- —/~|┆·");var Qe;!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"}(Qe||(Qe={}));const{Letter:Ze,Single:Ke,Before:$e,After:Je,Symbol:ti,Break:ei}=Qe;function ii(t){return Ge[t]?Ze:ze[t]?ei:Ve[t]?$e:je[t]?Je:qe[t]?ti:Xe.test(t)?Ke:Ze}const si={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 ni(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:ai}=si,{Letter:oi,Single:ri,Before:di,After:hi,Symbol:li,Break:ci}=Qe;let ui,fi,_i,gi,pi,wi,yi,mi,vi,xi,Bi,bi,Ri,ki,Ei,Li,Si=[];function Mi(t,e){vi&&!mi&&(mi=vi),ui.data.push({char:t,width:e}),_i+=e}function Ai(){gi+=_i,ui.width=_i,fi.words.push(ui),ui={data:[]},_i=0}function Ci(){ki&&(Ei.paraNumber++,fi.paraStart=!0,ki=!1),vi&&(fi.startCharSize=mi,fi.endCharSize=vi,mi=0),fi.width=gi,Li.width&&ai(fi),Si.push(fi),fi={words:[]},gi=0}const Ti=0,Wi=1,Oi=2;const{top:Ii,right:Pi,bottom:Di,left:Fi}=S;function Yi(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 Ni={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:d,__padding:h}=i;h&&(a&&(s=h[Fi],a-=h[Pi]+h[Fi]),o&&(n=h[Ii],o-=h[Ii]+h[Di]));const l={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){Ei=t,Si=t.rows,Li=t.bounds;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:d,height:h}=Li;if(d||h||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;ki=!0,Bi=null,mi=yi=vi=_i=gi=0,ui={data:[]},fi={words:[]};for(let s=0,h=i.length;s<h;s++)wi=i[s],"\n"===wi?(_i&&Ai(),fi.paraEnd=!0,Ci(),ki=!0):(xi=ii(wi),xi===oi&&"none"!==o&&(wi=ni(wi,o,!_i)),yi=r.measureText(wi).width,n&&(n<0&&(vi=yi),yi+=n),bi=xi===ri&&(Bi===ri||Bi===oi)||Bi===ri&&xi!==hi,Ri=!(xi!==di&&xi!==ri||Bi!==li&&Bi!==hi),pi=ki&&a?d-a:d,t&&d&&gi+_i+yi>pi&&(e?(_i&&Ai(),Ci()):(Ri||(Ri=xi===oi&&Bi==hi),bi||Ri||xi===ci||xi===di||xi===ri||_i+yi>pi?(_i&&Ai(),Ci()):Ci()))," "===wi&&!0!==ki&&gi+_i===0||(xi===ci?(" "===wi&&_i&&Ai(),Mi(wi,yi),Ai()):bi||Ri?(_i&&Ai(),Mi(wi,yi)):Mi(wi,yi)),Bi=xi);_i&&Ai(),gi&&Ci(),Si.length>0&&(Si[Si.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ei.paraNumber++,Si.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Yi(e,"x",t[Fi]);break;case"right":Yi(e,"x",-t[Pi])}if(!n)switch(i.verticalAlign){case"top":Yi(e,"y",t[Ii]);break;case"bottom":Yi(e,"y",-t[Di])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=n,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ti:h>.01?Wi:Oi,t.isOverflow&&!r&&(t.textMode=!0),c===Oi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Wi?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:a}=i;if(s.splice(n),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],o=t.x+t.width,!(s===i&&o<d));s--){if(o<d&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"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}}(l,i),l}};const Ui={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Xi,addPoint:Hi,toBounds:Gi}=M;const Vi={export(t,e,i){return this.running=!0,function(t){ji||(ji=new A);return new Promise((e=>{ji.add((()=>H(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=t=>{n(t),o(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>H(this,void 0,void 0,(function*(){i=a.getExportOptions(i);let n,o,h=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:g,trim:p,onCanvas:w}=i,y=i.scale||1,m=i.pixelRatio||1,v=i.screenshot||t.isApp,x=u&&v&&void 0===i.fill?t.fill:i.fill,B=a.isOpaqueImage(e)||x,b=new C;if(v)n=!0===v?u?d.canvas.bounds:t.worldRenderBounds:v;else{let e=i.relative||(u?"inner":"local");switch(h=c.scaleX,l=c.scaleY,e){case"inner":b.set(c);break;case"local":b.set(c).divide(t.localTransform),h/=t.scaleX,l/=t.scaleY;break;case"world":h=1,l=1;break;case"page":e=t.leafer;default:b.set(c).divide(t.getTransform(e));const i=e.worldTransform;h/=h/i.scaleX,l/=l/i.scaleY}n=t.getBounds("render",e)}const{x:R,y:k,width:E,height:L}=new _(n).scale(y);let S=s.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const M={matrix:b.scale(1/y).invert().translate(-R,-k).withScale(1/h*y,1/l*y)};if(g&&(t=d,M.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,M),t.fill=e}else t.__render(S,M);if(S.restore(),p){o=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?Hi(o,n,a):Xi(o={},n,a)),r++;const d=new _;return Gi(o,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:m};S=s.canvas(n),S.copyWorld(t,o,n)}B&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const A="canvas"===e?S:yield S.export(e,i);r({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:n,trimBounds:o})})))):r({data:!1})}))))}};let ji;const qi=t.prototype,zi=p.get("@leafer-ui/export");qi.export=function(t,e){const{quality:i,blob:s}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},qi.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{zi.error(t),s(null)}))}))},qi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},qi.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{zi.error(t),s(!1)}))}))},Object.assign(N,Ni),Object.assign(P,Ui),Object.assign(U,Et),Object.assign(I,se),Object.assign(D,Le),Object.assign(X,Ie),Object.assign(F,Vi),Object.assign(s,{interaction:(t,e,i,s)=>new W(t,e,i,s),hitCanvas:(t,e)=>new G(t,e),hitCanvasManager:()=>new O});export{ot as Layouter,G as LeaferCanvas,dt as Renderer,_t as Selector,z as Watcher,q as useCanvas};
package/dist/node.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core");class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(e,s){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,s&&(this.config=t.DataHelper.default(s,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.push(e.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:i,updateAllWorldOpacity:n}=t.LeafHelper,{pushAllChildBranch:r,pushAllParent:a}=t.BranchHelper;const{worldBounds:o}=t.LeafBoundsHelper,{setByListWithHandle:d}=t.BoundsHelper;class l{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){d(this.beforeBounds,this.updatedList.list,o)}setAfter(){d(this.afterBounds,this.updatedList.list,o),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:h,updateAllChange:c}=t.LeafHelper,{pushAllBranchStack:u,updateWorldBoundsByBranchStack:f}=t.BranchHelper,g=t.Debug.get("Layouter");class _{constructor(e,s){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,s&&(this.config=t.DataHelper.default(s,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){g.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?g.warn("layouting"):this.times>3?g.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const s=t.Run.start("PartLayout"),{target:o,__updatedList:d}=this,{BEFORE:l,LAYOUT:h,AFTER:c}=t.LayoutEvent,u=this.getBlocks(d);u.forEach((t=>{t.setBefore()})),o.emitEvent(new t.LayoutEvent(l,u,this.times)),d.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(i(t),e.push(t),t.isBranch&&r(t,e),a(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),a(t,e)))}))}(d,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&n(t),t.__updateChange()}))}(d),u.forEach((t=>t.setAfter())),o.emitEvent(new t.LayoutEvent(h,u,this.times)),o.emitEvent(new t.LayoutEvent(c,u,this.times)),this.addBlocks(u),this.__levelList.reset(),this.__updatedList=null,t.Run.end(s)}fullLayout(){const e=t.Run.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(s));s.emitEvent(new t.LayoutEvent(i,a,this.times)),_.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new t.LayoutEvent(n,a,this.times)),s.emitEvent(new t.LayoutEvent(r,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(t){if(h(t),t.isBranch){const e=[t];u(t,e),f(e)}else t.__updateWorldBounds();c(t)}createBlock(t){return new l(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:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const p=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=s,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:s}=this;this.times=0,this.totalBounds=new t.Bounds,p.log(s.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,p.error(t)}p.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){return this.rendering?p.warn("rendering"):this.times>3?p.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e?(this.emitRender(t.RenderEvent.BEFORE),e()):(this.requestLayout(),this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return p.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const s=t.Run.start("PartRender"),{canvas:i}=this,n=e.getIntersect(i.bounds),r=e.includes(this.target.__world),a=(new t.Bounds).copy(n);i.save(),r&&!t.Debug.showRepaint?i.clear():(n.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,a),i.restore(),t.Run.end(s)}fullRender(){const e=t.Run.start("FullRender"),{canvas:s}=this;s.save(),s.clear(),this.__render(s.bounds),s.restore(),t.Run.end(e)}__render(e,s){const i=(null==e?void 0:e.includes(this.target.__world))?{}:{bounds:e};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,i),this.renderBounds=s||e,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(i),t.Debug.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const s=new t.Bounds;s.setByList(e),e.length=0,e.push(s)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(t.AnimateEvent.FRAME),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:s,height:i}=e.old;new t.Bounds(0,0,s,i).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||p.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,s,i){this.target.emitEvent(new t.RenderEvent(e,this.times,s,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:w}=t.BoundsHelper;class m{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:e}=this;if(e.length>1){let s;this.findList=[];const{x:i,y:n}=this.point,r={x:i,y:n,radiusX:0,radiusY:0};for(let i=0,n=e.length;i<n;i++)if(s=e[i],t.LeafHelper.worldHittable(s)&&(this.hitChild(s,r),this.findList.length))return this.findList[0]}return e[0]}getPath(e){const s=new t.LeafList;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t.LeafList;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||w(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class v{constructor(e,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=e,s&&(this.config=t.DataHelper.default(s,this.config)),this.findPath=new m(e,this),this.__listenEvents()}getByPoint(e,s,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.findPath.getByPoint(e,s,i)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new _(t,e),renderer:(t,e,s)=>new y(t,e,s),selector:(t,e)=>new v(t,e)}),t.Platform.layout=_.fullLayout;class x extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}Object.assign(t.Creator,{canvas:(t,e)=>new x(t,e),image:e=>new t.LeaferImage(e),hitCanvas:(t,e)=>new x(t,e),interaction:(e,s,i,n)=>new t.InteractionBase(e,s,i,n)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0,t.Platform.realtimeLayout=!0;const{get:b,rotateOfOuter:B,translate:E,scaleOfOuter:L,scale:R,rotate:k}=t.MatrixHelper;const{get:S,translate:C}=t.MatrixHelper;function P(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:l,rotation:h,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(f.transform=S(),C(f.transform,i.x,i.y));break;case"clip":(d||l||h)&&function(t,e,s,i,n){const r=b();E(r,e.x,e.y),s&&E(r,s.x,s.y),i&&("number"==typeof i?R(r,i):R(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&k(r,n),t.transform=r}(f,i,d,l,h);break;case"repeat":(!u||l||h)&&function(t,e,s,i,n,r){const a=b();if(r)switch(k(a,r),r){case 90:E(a,i,0);break;case 180:E(a,s,i);break;case 270:E(a,0,s)}E(a,e.x,e.y),n&&(L(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,i,n,r,l,h);break;default:u&&!h||function(t,e,s,i,n,r){const a=b(),o=r&&180!==r,d=s.width/(o?n:i),l=s.height/(o?i:n),h="fit"===e?Math.min(d,l):Math.max(d,l),c=s.x+(s.width-i*h)/2,u=s.y+(s.height-n*h)/2;E(a,c,u),R(a,h),r&&B(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=h,t.transform=a}(f,o,i,n,r,h)}f.width=n,f.height=r,a&&(f.opacity=a)}function A(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function O(e,s){s.target.hasEvent(e)&&s.target.emitEvent(new t.ImageEvent(e,s))}function M(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:I,scale:T,copy:W}=t.MatrixHelper;function D(e,s,i){let{scaleX:n,scaleY:r}=e.__world;const a=n+"-"+r;if(s.patternId===a||e.destroyed)return!1;{s.patternId=a,n=Math.abs(n),r=Math.abs(r);const{image:e,data:o}=s,d=e.isSVG?4096:Math.min(e.width,4096),l=e.isSVG?4096:Math.min(e.height,4096);let h,c,{width:u,height:f,scaleX:g,scaleY:_,opacity:p,transform:y,mode:w}=o;g&&(c=I(),W(c,y),T(c,1/g,1/_),n*=g,r*=_),n*=i,r*=i,u*=n,f*=r,(u>d||f>l)&&(h=Math.max(u/d,f/l)),h&&(n/=h,r/=h,u/=h,f/=h),g&&(n/=g,r/=_),(y||1!==n||1!==r)&&(c||(c=I(),y&&W(c,y)),T(c,1/n,1/r));const m=t.Platform.canvas.createPattern(e.getCanvas(u<1?1:u,f<1?1:f,p),"repeat"===w?"repeat":t.Platform.origin.noRepeat||"no-repeat");try{s.transform&&(s.transform=null),c&&(m.setTransform?m.setTransform(c):s.transform=c)}catch(t){s.transform=c}return s.style=m,!0}}function H(e,s,i,n){const{scaleX:r,scaleY:a}=e.__world;if(i.data&&i.patternId!==r+"-"+a){if(n)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:e}=i.data;t*=r*s.pixelRatio,e*=a*s.pixelRatio,n=t>4096||e>4096}else n=!1;if(n){s.save(),s.clip();const{data:t}=i;return i.blendMode&&(s.blendMode=i.blendMode),t.opacity&&(s.opacity*=t.opacity),t.transform&&s.transform(t.transform),s.drawImage(i.image.view,0,0,t.width,t.height),s.restore(),!0}return i.style?t.ImageManager.patternTasker.add((()=>M(this,void 0,void 0,(function*(){s.bounds.hit(e.__world)&&D(e,i,s.pixelRatio)&&e.forceUpdate("surface")}))),300):D(e,i,s.pixelRatio),!1}return!1}function F(e,s){const i="fill"===s?e._fill:e._stroke;if(i instanceof Array){let n,r,a,o;for(let d=0,l=i.length;d<l;d++)n=i[d].image,o=n&&n.url,o&&(r||(r={}),r[o]=!0,t.ImageManager.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[s]||[],a instanceof Array||(a=[a])),n.unload(i[d].loadId,!a.some((t=>t.url===o)))));return r}return null}function N(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function j(t,e,s){const{strokeAlign:i}=t.__,n="string"!=typeof s;switch(i){case"center":e.setStroke(n?void 0:s,t.__.strokeWidth,t.__),n?V(t,s,e,!0):Y(t,e);break;case"inside":U(t,e,s,"inside",n);break;case"outside":U(t,e,s,"outside",n)}}function U(t,e,s,i,n){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(n?void 0:s,2*r,t.__),o.font=a,n?V(t,s,o,!0):Y(t,o),o.blendMode="outside"===i?"destination-out":"destination-in",N(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function Y(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.strokeText(t.char,t.x,s.y)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function V(t,e,s,i){let n;for(let r=0,a=e.length;r<a;r++)n=e[r],n.image&&H(t,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),i?Y(t,s):s.stroke(),s.restoreBlendMode()):i?Y(t,s):s.stroke())}const{getSpread:q,getOuterOf:X,getByMove:G,getIntersectData:z}=t.BoundsHelper;const Q={x:.5,y:0},Z={x:.5,y:1};function K(t,s,i){let n;for(let r=0,a=s.length;r<a;r++)n=s[r],t.addColorStop(n.offset,e.ColorConvert.string(n.color,i))}const{set:$,getAngle:J,getDistance:tt}=t.PointHelper,{get:et,rotateOfOuter:st,scaleOfOuter:it}=t.MatrixHelper,nt={x:.5,y:.5},rt={x:.5,y:1},at={},ot={};const{set:dt,getAngle:lt,getDistance:ht}=t.PointHelper,{get:ct,rotateOfOuter:ut,scaleOfOuter:ft}=t.MatrixHelper,gt={x:.5,y:.5},_t={x:.5,y:1},pt={},yt={};let wt;function mt(s,i,n){if("object"!=typeof i||!1===i.visible||0===i.opacity)return;const{boxBounds:r}=s.__layout;switch(i.type){case"solid":let{type:a,blendMode:o,color:d,opacity:l}=i;return{type:a,blendMode:o,style:e.ColorConvert.string(d,l)};case"image":return function(e,s,i,n,r){const a={type:i.type},o=a.image=t.ImageManager.get(i),d=(r||o.loading)&&{target:e,image:o,attrName:s,attrValue:i};return o.ready?(A(e,s,o)&&P(a,o,i,n),r&&(O(t.ImageEvent.LOAD,d),O(t.ImageEvent.LOADED,d))):o.error?r&&(e.forceUpdate("surface"),d.error=o.error,O(t.ImageEvent.ERROR,d)):(r&&O(t.ImageEvent.LOAD,d),a.loadId=o.load((()=>{e.destroyed||(A(e,s,o)&&(P(a,o,i,n),e.forceUpdate("surface")),O(t.ImageEvent.LOADED,d))}),(s=>{e.forceUpdate("surface"),d.error=s,O(t.ImageEvent.ERROR,d)}))),a}(s,n,i,r,!wt||!wt[i.url]);case"linear":return function(e,s){let{from:i,to:n,type:r,blendMode:a,opacity:o}=e;i||(i=Q),n||(n=Z);const d=t.Platform.canvas.createLinearGradient(s.x+i.x*s.width,s.y+i.y*s.height,s.x+n.x*s.width,s.y+n.y*s.height);K(d,e.stops,o);const l={type:r,style:d};return a&&(l.blendMode=a),l}(i,r);case"radial":return function(e,s){let{from:i,to:n,type:r,opacity:a,blendMode:o,stretch:d}=e;i||(i=nt),n||(n=rt);const{x:l,y:h,width:c,height:u}=s;let f;$(at,l+i.x*c,h+i.y*u),$(ot,l+n.x*c,h+n.y*u),(c!==u||d)&&(f=et(),it(f,at,c/u*(d||1),1),st(f,at,J(at,ot)+90));const g=t.Platform.canvas.createRadialGradient(at.x,at.y,0,at.x,at.y,tt(at,ot));K(g,e.stops,a);const _={type:r,style:g,transform:f};return o&&(_.blendMode=o),_}(i,r);case"angular":return function(e,s){let{from:i,to:n,type:r,opacity:a,blendMode:o,stretch:d}=e;i||(i=gt),n||(n=_t);const{x:l,y:h,width:c,height:u}=s;dt(pt,l+i.x*c,h+i.y*u),dt(yt,l+n.x*c,h+n.y*u);const f=ct(),g=lt(pt,yt);t.Platform.conicGradientRotate90?(ft(f,pt,c/u*(d||1),1),ut(f,pt,g+90)):(ft(f,pt,1,c/u*(d||1)),ut(f,pt,g));const _=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,pt.x,pt.y):t.Platform.canvas.createRadialGradient(pt.x,pt.y,0,pt.x,pt.y,ht(pt,yt));K(_,e.stops,a);const p={type:r,style:_,transform:f};return o&&(p.blendMode=o),p}(i,r);default:return i.r?{type:"solid",style:e.ColorConvert.string(i)}:void 0}}var vt=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let i,n=t.__.__input[e];n instanceof Array||(n=[n]),wt=F(t.__,e);for(let r=0,a=n.length;r<a;r++)i=mt(t,n[r],e),i&&s.push(i);t.__["_"+e]=s.length?s:void 0},drawTextStroke:Y,fill:function(t,e,s){e.fillStyle=s,t.__.__font?N(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:N,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)i=s[a],i.image&&H(t,e,i,!r)||i.style&&(e.fillStyle=i.style,i.transform?(e.save(),e.transform(i.transform),i.blendMode&&(e.blendMode=i.blendMode),r?N(t,e):n?e.fill(n):e.fill(),e.restore()):i.blendMode?(e.saveBlendMode(i.blendMode),r?N(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):r?N(t,e):n?e.fill(n):e.fill())},recycleImage:F,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:l,scaleY:h}=d;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(d,s.matrix))s.matrix?(l*=s.matrix.a,h*=s.matrix.d,n=a=X(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=z(i?q(e.bounds,i*l,i*h):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),l*=r.a,h*=r.d),a=X(d,r),n=G(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:l,scaleY:h}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)j(t,e,s);else switch(r){case"center":e.setStroke(s,n,i),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*n,t.__),t.__drawRenderPath(r),r.stroke(),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:j,strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)j(t,e,s);else switch(r){case"center":e.setStroke(void 0,n,i),V(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),V(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*n,t.__),V(t,s,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:xt,toOffsetOutBounds:bt}=t.BoundsHelper,Bt={},Et={};function Lt(e,s,i,n){const{bounds:r,shapeBounds:a}=n;if(t.Platform.fullImageShadow){if(xt(Bt,e.bounds),Bt.x+=s.x-a.x,Bt.y+=s.y-a.y,i){const{matrix:t}=n;Bt.x-=(r.x+(t?t.e:0)+r.width/2)*(i-1),Bt.y-=(r.y+(t?t.f:0)+r.height/2)*(i-1),Bt.width*=i,Bt.height*=i}e.copyWorld(n.canvas,e.bounds,Bt)}else i&&(xt(Bt,s),Bt.x-=s.width/2*(i-1),Bt.y-=s.height/2*(i-1),Bt.width*=i,Bt.height*=i),e.copyWorld(n.canvas,a,i?Bt:s)}const{toOffsetOutBounds:Rt}=t.BoundsHelper,kt={};var St=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:l,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=s,g=e.getSameCanvas(),_=d.length-1;Rt(h,kt),d.forEach(((i,d)=>{g.save(),g.setWorldShadow(kt.offsetX+i.x*u,kt.offsetY+i.y*f,i.blur*u),r=i.spread?1-2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Lt(g,kt,r,s),g.restore(),l?(g.copyWorld(g,h,a,"copy"),g.copyWorld(l,a,a,"source-out"),n=a):(g.copyWorld(s.canvas,c,h,"source-out"),n=h),g.fillWorld(n,i.color,"source-in"),t.__hasMirror?e.copyWorldByReset(g,n,a,i.blendMode):e.copyWorldToInner(g,n,o.renderBounds,i.blendMode),_&&d<_&&g.clear()})),g.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:l,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=s,g=e.getSameCanvas(),_=d.length-1;bt(h,Et),d.forEach(((i,d)=>{g.setWorldShadow(Et.offsetX+i.x*u,Et.offsetY+i.y*f,i.blur*u,i.color),r=i.spread?1+2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Lt(g,Et,r,s),n=h,i.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,h,a,"copy"),n=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(s.canvas,c,h,"destination-out")),t.__hasMirror?e.copyWorldByReset(g,n,a,i.blendMode):e.copyWorldToInner(g,n,o.renderBounds,i.blendMode),_&&d<_&&g.clear()})),g.recycle()}});const Ct=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Pt=Ct+"_#~&*+\\=|≮≯≈≠=…",At=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 Ot(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Mt=Ot("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),It=Ot("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Tt=Ot(Ct),Wt=Ot(Pt),Dt=Ot("- —/~|┆·");var Ht;!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"}(Ht||(Ht={}));const{Letter:Ft,Single:Nt,Before:jt,After:Ut,Symbol:Yt,Break:Vt}=Ht;function qt(t){return Mt[t]?Ft:Dt[t]?Vt:It[t]?jt:Tt[t]?Ut:Wt[t]?Yt:At.test(t)?Nt:Ft}const Xt={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Gt(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:zt}=Xt,{Letter:Qt,Single:Zt,Before:Kt,After:$t,Symbol:Jt,Break:te}=Ht;let ee,se,ie,ne,re,ae,oe,de,le,he,ce,ue,fe,ge,_e=[];function pe(t,e){ee.data.push({char:t,width:e}),ie+=e}function ye(){ne+=ie,ee.width=ie,se.words.push(ee),ee={data:[]},ie=0}function we(){ue&&(fe.paraNumber++,se.paraStart=!0,ue=!1),se.width=ne,ge.width&&zt(se),_e.push(se),se={words:[]},ne=0}const me={getDrawData(e,s){"string"!=typeof e&&(e=String(e));let i=0,n=0,{width:r,height:a,padding:o}=s;const{textDecoration:d,textOverflow:l,__font:h}=s;if(r||(r=0),o){const[e,s,d,l]=t.MathHelper.fourNumber(o);r&&(i=l,r-=s+l),a&&(n=e,a-=e+d)}const c={bounds:{x:i,y:n,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,s,i){fe=e,_e=e.rows,ge=e.bounds;const{__letterSpacing:n,paraIndent:r,textCase:a}=i,{canvas:o}=t.Platform,{width:d,height:l}=ge;if(d||l||n||"none"!==a){ue=!0,le=null,ie=ne=0,ee={data:[]},se={words:[]};for(let t=0,e=s.length;t<e;t++)ae=s[t],"\n"===ae?(ie&&ye(),se.paraEnd=!0,we(),ue=!0):(de=qt(ae),de===Qt&&"none"!==a&&(ae=Gt(ae,a,!ie)),oe=o.measureText(ae).width,n&&(oe+=n),he=de===Zt&&(le===Zt||le===Qt)||le===Zt&&de!==$t,ce=!(de!==Kt&&de!==Zt||le!==Jt&&le!==$t),re=ue&&r?d-r:d,d&&ne+ie+oe>re&&(ce||(ce=de===Qt&&le==$t),he||ce||de===te||de===Kt||de===Zt||ie+oe>re?(ie&&ye(),we()):we())," "===ae&&!0!==ue&&ne+ie===0||(de===te?(" "===ae&&ie&&ye(),pe(ae,oe),ye()):he||ce?(ie&&ye(),pe(ae,oe)):pe(ae,oe)),le=de);ie&&ye(),ne&&we(),_e.length>0&&(_e[_e.length-1].paraEnd=!0)}else s.split("\n").forEach((t=>{fe.paraNumber++,_e.push({x:r||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(c,e,s),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,textAlign:a,verticalAlign:o,paraSpacing:d,textOverflow:l}=e;let h,{x:c,y:u,width:f,height:g}=i,_=n*s.length+(d?d*(t.paraNumber-1):0),p=r;if("show"!==l&&_>g)_=Math.max(g,n),t.overflow=s.length;else switch(o){case"middle":u+=(g-_)/2;break;case"bottom":u+=g-_}p+=u;for(let r=0,o=s.length;r<o;r++){switch(h=s[r],h.x=c,a){case"center":h.x+=(f-h.width)/2;break;case"right":h.x+=f-h.width}if(h.paraStart&&d&&r>0&&(p+=d),h.y=p,p+=n,t.overflow>r&&p>_&&(h.isOverflow=!0,t.overflow=r+1),h.width<0){const t=h.words[0].data[0].width,s=h.x+h.width;s<i.x&&(i.x=s-t),-h.width>i.width&&(i.width=-h.width+e.fontSize+t)}else h.x<i.x&&(i.x=h.x),h.width>i.width&&(i.width=h.width)}i.y=u,i.height=_}(c,s),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,l,h,c,u;n.forEach((t=>{t.words&&(h=a&&t.paraStart?a:0,l=s&&"justify"===r&&t.words.length>1?(s-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?0:l>.01?1:2,2===c?(t.text="",t.x+=h,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,s,r),c.overflow&&function(e,s){const{rows:i,overflow:n}=e;if(i.splice(n),"hide"!==s){"ellipsis"===s&&(s="...");const r=t.Platform.canvas.measureText(s).width,a=i[n-1];let o,d,l=a.data.length-1;const{x:h,width:c}=e.bounds,u=h+c-r;for(let t=l;t>-1&&(o=a.data[t],d=o.x+o.width,!(t===l&&d<u));t--){if(d<u&&" "!==o.char){a.data.splice(t+1),a.width-=o.width;break}a.width-=o.width}a.width+=r,a.data.push({char:s,x:d})}}(c,l),"none"!==d&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(c,s),c}},ve={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},xe={export(e,s,i){return function(e){be||(be=new t.TaskProcessor);return new Promise((t=>{be.add((()=>M(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((t=>new Promise((n=>{const{leafer:r}=e;r?r.waitViewCompleted((()=>M(this,void 0,void 0,(function*(){let e,a,o,{canvas:d}=r,{unreal:l}=d;switch(l&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof i){case"object":i.quality&&(e=i.quality),i.blob&&(a=!0);break;case"number":e=i;break;case"boolean":a=i}o=s.includes(".")?yield d.saveAs(s,e):a?yield d.toBlob(s,e):yield d.toDataURL(s,e),t({data:o}),n(),l&&d.recycle()})))):(t({data:!1}),n())}))))}};let be;Object.assign(e.Paint,vt),Object.assign(e.Effect,St),Object.assign(e.TextConvert,me),Object.assign(e.ColorConvert,ve),Object.assign(e.Export,xe),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=_,exports.LeaferCanvas=x,exports.Renderer=y,exports.Selector=v,exports.Watcher=s,exports.useCanvas=function(e,s){if(!t.Platform.origin){if("skia"===e){const{Canvas:e,loadImage:i}=s;t.Platform.origin={createCanvas:(t,s,i)=>new e(t,s,i),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),loadImage:i}}t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function r(t){try{d(i.next(t))}catch(t){a(t)}}function o(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:r,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class d{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:l,updateBounds:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,g),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:y,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,d,this.times)),i.emitEvent(new t.LayoutEvent(o,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),v.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){y(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(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:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.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;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),r=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,r),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:n,height:i}=e.old;new t.Bounds(0,0,n,i).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.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:b}=t.BoundsHelper;class E{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,n){e||(e=0),n||(n={});const i=n.through||!1,s=n.ignoreHittable||!1,a=n.target||this.target;this.exclude=n.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=n.findList||[],n.findList||this.eachFind(a.children,a.__onlyHitMask);const r=this.findList,o=this.getBestMatchLeaf(),d=s?this.getPath(o):this.getHitablePath(o);return this.clear(),i?{path:d,target:o,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:o}}getBestMatchLeaf(){const{findList:e}=this;if(e.length>1){let n;this.findList=[];const{x:i,y:s}=this.point,a={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=e.length;i<s;i++)if(n=e[i],t.LeafHelper.worldHittable(n)&&(this.hitChild(n,a),this.findList.length))return this.findList[0]}return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)n.add(r)}return n}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&!this.findList.length&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:L,NoAndSkip:R,YesAndSkip:k}=t.Answer;class P{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new E(e,this),this.__listenEvents()}getBy(t,e,n,i){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return n?s:s?[s]:[];case"string":switch(t[0]){case"#":const i=this.getById(t.substring(1),e);return n?i:i?[i]:[];case".":return this.getByMethod(this.methods.className,e,n,t.substring(1));default:return this.getByMethod(this.methods.tag,e,n,t)}case"function":return this.getByMethod(t,e,n,i)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let r=0,o=t.length;r<o;r++){if(s=t[r],a=e(s,i),a===L||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function C(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function M(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?A(t,!0,e,n):I(e,n);break;case"inside":S("inside",t,s,e,n);break;case"outside":S("outside",t,s,e,n)}}function S(t,e,n,i,s){const{__strokeWidth:a,__font:r}=i.__,o=s.getSameCanvas(!0,!0);o.setStroke(n?void 0:e,2*a,i.__),o.font=r,n?A(e,!0,i,o):I(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",C(i,o),o.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(o,i.__nowWorld):s.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function I(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function A(t,e,n,s){let a;for(let r=0,o=t.length;r<o;r++)a=t[r],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?I(n,s):s.stroke(),s.restoreBlendMode()):e?I(n,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new P(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:W,getOuterOf:O,getByMove:T,getIntersectData:D}=t.BoundsHelper;let H;function F(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:r,color:o,opacity:d}=e;return{type:a,blendMode:r,style:i.ColorConvert.string(o,d)};case"image":return i.PaintImage.image(n,t,e,s,!H||!H[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const Y={compute:function(t,e){const n=e.__,s=[];let a,r=n.__input[t];r instanceof Array||(r=[r]),H=i.PaintImage.recycleImage(t,n);for(let n,i=0,a=r.length;i<a;i++)n=F(t,r[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?C(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:r}=e.__;for(let o=0,d=t.length;o<d;o++)s=t[o],s.image&&i.PaintImage.checkImage(e,n,s,!r)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),r?C(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),r?C(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):r?C(e,n):a?n.fill(a):n.fill())},fillText:C,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)M(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)M(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),A(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),A(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),A(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,a),r.recycle(e.__nowWorld)}},strokeText:M,drawTextStroke:I,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=o=s;else{const{renderShapeSpread:i}=t.__layout,c=D(i?W(e.bounds,i*l,i*h):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),o=O(s,r),a=T(o,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let N={};const{get:G,rotateOfOuter:U,translate:j,scaleOfOuter:X,scale:q,rotate:V}=t.MatrixHelper;function z(t,e,n,i,s,a){const r=G(),o=a&&180!==a,d=n.width/(o?s:i),l=n.height/(o?i:s),h="fit"===e?Math.min(d,l):Math.max(d,l),c=n.x+(n.width-i*h)/2,u=n.y+(n.height-s*h)/2;j(r,c,u),q(r,h),a&&U(r,{x:n.x+n.width/2,y:n.y+n.height/2},a),t.scaleX=t.scaleY=h,t.transform=r}function Q(t,e,n,i,s,a,r){const o=G();j(o,e.x,e.y),(n||i)&&j(o,n,i),s&&(q(o,s,a),t.scaleX=o.a,t.scaleY=o.d),r&&V(o,r),t.transform=o}function Z(t,e,n,i,s,a,r,o,d){const l=G();if(d)switch(V(l,d),d){case 90:j(l,i,0);break;case 180:j(l,n,i);break;case 270:j(l,0,n)}N.x=e.x,N.y=e.y,(s||a)&&(N.x+=s,N.y+=a),j(l,N.x,N.y),r&&(X(l,N,r,o),t.scaleX=r,t.scaleY=o),t.transform=l}const{get:K,translate:$}=t.MatrixHelper,J=new t.Bounds;function tt(t,e,n,i){let{width:s,height:a}=e;n.padding&&(i=J.set(i).shrink(n.padding));const{opacity:r,mode:o,offset:d,scale:l,size:h,rotation:c,blendMode:u,repeat:f}=n,g=i.width===s&&i.height===a;u&&(t.blendMode=u);const p=t.data={mode:o};let _,y,w,m;switch(d&&(_=d.x,y=d.y),h?(w=("number"==typeof h?h:h.width)/s,m=("number"==typeof h?h:h.height)/a):l&&(w="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),o){case"strench":g||(s=i.width,a=i.height);break;case"clip":(d||w||c)&&Q(p,i,_,y,w,m,c);break;case"repeat":(!g||w||c)&&Z(p,i,s,a,_,y,w,m,c),f||(p.repeat="repeat");break;default:g&&!c||z(p,o,i,s,a,c)}p.transform||(i.x||i.y)&&(p.transform=K(),$(p.transform,i.x,i.y)),p.width=s,p.height=a,r&&(p.opacity=r),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let et,nt=new t.Bounds;const{isSame:it}=t.BoundsHelper;function st(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.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||tt(s,i,n,a),!0}function at(e,n){dt(e,t.ImageEvent.LOAD,n)}function rt(e,n){dt(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function lt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ht,scale:ct,copy:ut}=t.MatrixHelper,{ceil:ft,abs:gt}=Math;function pt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{s=gt(s),a=gt(a);const{image:e,data:o}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=o;u&&(l=ht(),ut(l,p),ct(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const y=h*c;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=ht(),p&&ut(l,p)),ct(l,1/s,1/a));const m=e.getCanvas(ft(h)||1,ft(c)||1,g),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}const{abs:_t}=Math;const yt={image:function(e,n,i,s,a){let r,o;const d=t.ImageManager.get(i);return et&&i===et.paint&&it(s,et.boxBounds)?r=et.leafPaint:(r={type:i.type,image:d},et=d.use>1?{leafPaint:r,paint:i,boxBounds:nt.set(s)}:null),(a||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(st(e,n,i,d,r,s),a&&(at(e,o),rt(e,o))):d.error?a&&ot(e,o,d.error):(lt(e,!0),a&&at(e,o),r.loadId=d.load((()=>{lt(e,!1),e.destroyed||(st(e,n,i,d,r,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,o)),r.loadId=null}),(t=>{lt(e,!1),ot(e,o,t),r.loadId=null}))),r},createData:tt,fillOrFitMode:z,clipMode:Q,repeatMode:Z,createPattern:pt,checkImage:function(e,n,a,r){const{scaleX:o,scaleY:d}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;if(a.data&&a.patternId!==o+"-"+d){const{data:l}=a;if(r)if(l.repeat)r=!1;else{let{width:e,height:i}=l;e*=_t(o)*n.pixelRatio,i*=_t(d)*n.pixelRatio,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),r=e*i>t.Platform.image.maxCacheSize}return r?(n.save(),n.clip(),a.blendMode&&(n.blendMode=a.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(a.image.view,0,0,l.width,l.height),n.restore(),!0):(!a.style||i.Export.running?pt(e,a,n.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__nowWorld)&&pt(e,a,n.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,r,o;for(let d=0,l=i.length;d<l;d++)s=i[d].image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null}},wt={x:.5,y:0},mt={x:.5,y:1};function vt(t,e,n){let s;for(let a=0,r=e.length;a<r;a++)s=e[a],t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}const{set:xt,getAngle:Bt,getDistance:bt}=t.PointHelper,{get:Et,rotateOfOuter:Lt,scaleOfOuter:Rt}=t.MatrixHelper,kt={x:.5,y:.5},Pt={x:.5,y:1},Ct={},Mt={};const{set:St,getAngle:It,getDistance:At}=t.PointHelper,{get:Wt,rotateOfOuter:Ot,scaleOfOuter:Tt}=t.MatrixHelper,Dt={x:.5,y:.5},Ht={x:.5,y:1},Ft={},Yt={};const Nt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:r,opacity:o}=e;i||(i=wt),s||(s=mt);const d=t.Platform.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+s.x*n.width,n.y+s.y*n.height);vt(d,e.stops,o);const l={type:a,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;i||(i=kt),s||(s=Pt);const{x:l,y:h,width:c,height:u}=n;let f;xt(Ct,l+i.x*c,h+i.y*u),xt(Mt,l+s.x*c,h+s.y*u),(c!==u||d)&&(f=Et(),Rt(f,Ct,c/u*(d||1),1),Lt(f,Ct,Bt(Ct,Mt)+90));const g=t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,bt(Ct,Mt));vt(g,e.stops,r);const p={type:a,style:g,transform:f};return o&&(p.blendMode=o),p},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;i||(i=Dt),s||(s=Ht);const{x:l,y:h,width:c,height:u}=n;St(Ft,l+i.x*c,h+i.y*u),St(Yt,l+s.x*c,h+s.y*u);const f=Wt(),g=It(Ft,Yt);t.Platform.conicGradientRotate90?(Tt(f,Ft,c/u*(d||1),1),Ot(f,Ft,g+90)):(Tt(f,Ft,1,c/u*(d||1)),Ot(f,Ft,g));const p=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ft.x,Ft.y):t.Platform.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,At(Ft,Yt));vt(p,e.stops,r);const _={type:a,style:p,transform:f};return o&&(_.blendMode=o),_}},{copy:Gt,toOffsetOutBounds:Ut}=t.BoundsHelper,jt={},Xt={};function qt(e,n,i,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Gt(jt,e.bounds),jt.x+=n.x-r.x,jt.y+=n.y-r.y,i){const{matrix:t}=s;jt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),jt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),jt.width*=i,jt.height*=i}e.copyWorld(s.canvas,e.bounds,jt)}else i&&(Gt(jt,n),jt.x-=n.width/2*(i-1),jt.y-=n.height/2*(i-1),jt.width*=i,jt.height*=i),e.copyWorld(s.canvas,r,i?jt:n)}const{toOffsetOutBounds:Vt}=t.BoundsHelper,zt={};const Qt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;Ut(l,Xt),o.forEach(((o,p)=>{f.setWorldShadow(Xt.offsetX+o.x*c,Xt.offsetY+o.y*u,o.blur*c,o.color),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,qt(f,Xt,s,n),i=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;Vt(l,zt),o.forEach(((o,p)=>{f.save(),f.setWorldShadow(zt.offsetX+o.x*c,zt.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,qt(f,zt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,o.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Zt}=t.LeafBoundsHelper;function Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Jt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Jt(t,n,i,a);break;case"path":n.restore()}}function $t(t){return t.getSameCanvas(!1,!0)}function Jt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,r;const{children:o}=this;for(let d=0,l=o.length;d<l;d++)n=o[d],n.__.mask&&(r&&(Kt(this,r,t,s,i,a),i=s=null),"path"===n.__.maskType?(n.opacity<1?(r="opacity-path",a=n.opacity,s||(s=$t(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="alpha",i||(i=$t(t)),s||(s=$t(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||Zt(n,e)||n.__render(s||t,e);Kt(this,r,t,s,i,a)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=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 ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ae=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),re=ie(te),oe=ie(ee),de=ie("- —/~|┆·");var le;!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"}(le||(le={}));const{Letter:he,Single:ce,Before:ue,After:fe,Symbol:ge,Break:pe}=le;function _e(t){return se[t]?he:de[t]?pe:ae[t]?ue:re[t]?fe:oe[t]?ge:ne.test(t)?ce:he}const ye={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function we(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:me}=ye,{Letter:ve,Single:xe,Before:Be,After:be,Symbol:Ee,Break:Le}=le;let Re,ke,Pe,Ce,Me,Se,Ie,Ae,We,Oe,Te,De,He,Fe,Ye,Ne,Ge=[];function Ue(t,e){We&&!Ae&&(Ae=We),Re.data.push({char:t,width:e}),Pe+=e}function je(){Ce+=Pe,Re.width=Pe,ke.words.push(Re),Re={data:[]},Pe=0}function Xe(){Fe&&(Ye.paraNumber++,ke.paraStart=!0,Fe=!1),We&&(ke.startCharSize=Ae,ke.endCharSize=We,Ae=0),ke.width=Ce,Ne.width&&me(ke),Ge.push(ke),ke={words:[]},Ce=0}const qe=0,Ve=1,ze=2;const{top:Qe,right:Ze,bottom:Ke,left:$e}=t.Direction4;function Je(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const tn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=n;l&&(a&&(i=l[$e],a-=l[Ze]+l[$e]),r&&(s=l[Qe],r-=l[Qe]+l[Ke]));const h={bounds:{x:i,y:s,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ye=e,Ge=e.rows,Ne=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=Ne;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Fe=!0,Te=null,Ae=Ie=We=Pe=Ce=0,Re={data:[]},ke={words:[]};for(let i=0,l=n.length;i<l;i++)Se=n[i],"\n"===Se?(Pe&&je(),ke.paraEnd=!0,Xe(),Fe=!0):(Oe=_e(Se),Oe===ve&&"none"!==r&&(Se=we(Se,r,!Pe)),Ie=o.measureText(Se).width,s&&(s<0&&(We=Ie),Ie+=s),De=Oe===xe&&(Te===xe||Te===ve)||Te===xe&&Oe!==be,He=!(Oe!==Be&&Oe!==xe||Te!==Ee&&Te!==be),Me=Fe&&a?d-a:d,t&&d&&Ce+Pe+Ie>Me&&(e?(Pe&&je(),Xe()):(He||(He=Oe===ve&&Te==be),De||He||Oe===Le||Oe===Be||Oe===xe||Pe+Ie>Me?(Pe&&je(),Xe()):Xe()))," "===Se&&!0!==Fe&&Ce+Pe===0||(Oe===Le?(" "===Se&&Pe&&je(),Ue(Se,Ie),je()):De||He?(Pe&&je(),Ue(Se,Ie)):Ue(Se,Ie)),Te=Oe);Pe&&je(),Ce&&Xe(),Ge.length>0&&(Ge[Ge.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ye.paraNumber++,Ge.push({x:a||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(h,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Je(e,"x",t[$e]);break;case"right":Je(e,"x",-t[Ze])}if(!s)switch(n.verticalAlign){case"top":Je(e,"y",t[Qe]);break;case"bottom":Je(e,"y",-t[Ke])}}(l,h,n,a,r),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:g,y:p,width:_,height:y}=i,w=s*n.length+(h?h*(t.paraNumber-1):0),m=a;if(o&&w>y)w=Math.max(y,s),t.overflow=n.length;else switch(l){case"middle":p+=(y-w)/2;break;case"bottom":p+=y-w}m+=p;for(let a=0,l=n.length;a<l;a++){switch(c=n[a],c.x=g,d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&a>0&&(m+=h),c.y=m,m+=s,t.overflow>a&&m>w&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<i.x&&(i.x=u),f>i.width&&(i.width=f),o&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=r&&t.paraStart?r:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?qe:l>.01?Ve:ze,t.isOverflow&&!o&&(t.textMode=!0),c===ze?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Ve?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n){const{rows:i,overflow:s}=e;let{textOverflow:a}=n;if(i.splice(s),"hide"!==a){let e,r;"ellipsis"===a&&(a="...");const o=t.Platform.canvas.measureText(a).width,d=n.x+n.width-o;("none"===n.textWrap?i:[i[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],r=e.x+e.width,!(i===n&&r<d));i--){if(r<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=o,t.data.push({char:a,x:r}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n),"none"!==o&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const en={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:nn,addPoint:sn,toBounds:an}=t.TwoPointBoundsHelper;const rn={export(e,n,i){return this.running=!0,function(e){on||(on=new t.TaskProcessor);return new Promise((t=>{on.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const o=t=>{a(t),r(),this.running=!1},{leafer:d}=e;d?d.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){i=t.FileHelper.getExportOptions(i);let s,a,r=1,l=1;const{worldTransform:h,isLeafer:c,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=i,_=i.scale||1,y=i.pixelRatio||1,w=i.screenshot||e.isApp,m=c&&w&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||m,x=new t.Matrix;if(w)s=!0===w?c?d.canvas.bounds:e.worldRenderBounds:w;else{let t=i.relative||(c?"inner":"local");switch(r=h.scaleX,l=h.scaleY,t){case"inner":x.set(h);break;case"local":x.set(h).divide(e.localTransform),r/=e.scaleX,l/=e.scaleY;break;case"world":r=1,l=1;break;case"page":t=e.leafer;default:x.set(h).divide(e.getTransform(t));const n=t.worldTransform;r/=r/n.scaleX,l/=l/n.scaleY}s=e.getBounds("render",t)}const{x:B,y:b,width:E,height:L}=new t.Bounds(s).scale(_);let R=t.Creator.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:y});const k={matrix:x.scale(1/_).invert().translate(-B,-b).withScale(1/r*_,1/l*_)};if(f&&(e=d,k.bounds=R.bounds),R.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(R,k),e.fill=t}else e.__render(R,k);if(R.restore(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,r,o,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,r=(d-a)/n,o?sn(o,a,r):nn(o={},a,r)),d++;const l=new t.Bounds;return an(o,l),l.scale(1/e.pixelRatio).ceil()}(R);const e=R,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:y};R=t.Creator.canvas(s),R.copyWorld(e,a,s)}v&&R.fillWorld(R.bounds,m||"#FFFFFF","destination-over"),p&&p(R);const P="canvas"===n?R:yield R.export(n,i);o({data:P,width:R.pixelWidth,height:R.pixelHeight,renderBounds:s,trimBounds:a})})))):o({data:!1})}))))}};let on;const dn=t.LeaferCanvasBase.prototype,ln=t.Debug.get("@leafer-ui/export");dn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},dn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{ln.error(t),i(null)}))}))},dn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},dn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{ln.error(t),i(!1)}))}))},Object.assign(i.TextConvert,tn),Object.assign(i.ColorConvert,en),Object.assign(i.Paint,Y),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,Nt),Object.assign(i.Effect,Qt),Object.assign(i.Export,rn),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=P,exports.Watcher=d,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:a}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(r(e),n),canvasToBolb:(t,e,n)=>s(this,void 0,void 0,(function*(){return t.toBuffer(r(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(r(o(n)),i))})),download(t,e){},loadImage:a}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/node",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.21",
4
4
  "description": "@leafer-ui/node",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -8,7 +8,8 @@
8
8
  "main": "dist/core.esm.js",
9
9
  "exports": {
10
10
  "import": "./dist/node.esm.js",
11
- "require": "./dist/node.cjs"
11
+ "require": "./dist/node.cjs",
12
+ "types": "./types/index.d.ts"
12
13
  },
13
14
  "types": "types/index.d.ts",
14
15
  "files": [
@@ -29,10 +30,13 @@
29
30
  "leaferjs"
30
31
  ],
31
32
  "dependencies": {
32
- "@leafer/node": "1.0.0-rc.2",
33
- "@leafer-ui/core": "1.0.0-rc.2",
34
- "@leafer-ui/partner": "1.0.0-rc.2",
35
- "@leafer-ui/interface": "1.0.0-rc.2",
36
- "leafer-in": "1.0.0-rc.2"
33
+ "@leafer/core": "1.0.0-rc.21",
34
+ "@leafer/node": "1.0.0-rc.21",
35
+ "@leafer/partner": "1.0.0-rc.21",
36
+ "@leafer/interface": "1.0.0-rc.21",
37
+ "@leafer-ui/draw": "1.0.0-rc.21",
38
+ "@leafer-ui/core": "1.0.0-rc.21",
39
+ "@leafer-ui/partner": "1.0.0-rc.21",
40
+ "@leafer-ui/interface": "1.0.0-rc.21"
37
41
  }
38
42
  }
package/src/index.ts CHANGED
@@ -1,3 +1,16 @@
1
1
  export * from '@leafer/node'
2
+ export * from '@leafer/partner'
3
+
2
4
  export * from '@leafer-ui/core'
3
5
  export * from '@leafer-ui/partner'
6
+
7
+ import { ICreator } from '@leafer/interface'
8
+ import { Creator, LeaferCanvas } from '@leafer/node'
9
+ import { InteractionBase, HitCanvasManager } from '@leafer-ui/core'
10
+
11
+
12
+ Object.assign(Creator, {
13
+ interaction: (target, canvas, selector, options?) => { return new InteractionBase(target, canvas, selector, options) },
14
+ hitCanvas: (options?, manager?) => new LeaferCanvas(options, manager),
15
+ hitCanvasManager: () => new HitCanvasManager()
16
+ } as ICreator)
package/types/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from '@leafer/node'
2
- export * from '@leafer-ui/core'
3
- export * from '@leafer-ui/partner'
1
+ export * from '@leafer/node';
2
+ export * from '@leafer/partner';
3
+ export * from '@leafer-ui/core';
4
+ export * from '@leafer-ui/partner';