@leafer-ui/worker 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as x,ImageManager as v,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as E,MathHelper as S,AlignHelper as R,PointHelper as L,ImageEvent as A,AroundHelper as T,Direction4 as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as C,InteractionBase as W}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,Paint as M,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as U,Effect as G}from"@leafer-ui/draw";class z extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__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}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:N}=s;function X(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:N(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:N(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then((t=>{i(t)})).catch((t=>{s(t)}))},n.onerror=t=>s(t),n.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new z(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):j.indexOf("Safari")>-1&&-1===j.indexOf("Chrome")&&(e.fullImageShadow=!0),j.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):j.indexOf("Mac")>-1?e.os="Mac":j.indexOf("Linux")>-1&&(e.os="Linux");class q{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=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:H,updateBounds:V,updateChange:Q}=f,{pushAllChildBranch:Z,pushAllParent:$}=g;const{worldBounds:J}=p;class K{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,J)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,J),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:tt,updateAllChange:et}=f,it=w.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=m,o=this.getBlocks(s);o.forEach((t=>t.setBefore())),i.emitEvent(new m(n,o,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?(H(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(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||V(s[t])}V(i)}}))}(this.__levelList),function(t){t.list.forEach(Q)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new m(a,o,this.times)),i.emitEvent(new m(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=m,a=this.getBlocks(new o(e));e.emitEvent(new m(i,a,this.times)),st.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(s,a,this.times)),e.emitEvent(new m(n,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new K([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new K(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=w.get("Renderer");class at{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(l.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(l.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,nt.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(at.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||nt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[l.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[l.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}at.clipSpread=10;const{hitRadiusPoint:rt}=B;class ot{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,n),l=n?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:s,y:n}=this.point,a={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new 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,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||rt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class dt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new ot(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function lt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function ht(t,e){t.__.__font?lt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ct(t,e,i){switch(e.__.strokeAlign){case"center":ut(t,1,e,i);break;case"inside":ft(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ut(t,2,e,i):ft(t,"outside",e,i)}}function ut(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?_t(t,!0,i,s):pt(i,s)}function ft(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ut(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",lt(i,n),n.blendMode="normal",gt(s,n,i),n.recycle(i.__nowWorld)}function gt(t,i,s){s.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(i,s.__nowWorld):t.copyWorldToInner(i,s.__nowWorld,s.__layout.renderBounds)}function pt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=s;n.forEach((i=>a.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function _t(t,e,i,s){let n;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&P.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?pt(i,s):s.stroke(),s.restoreBlendMode()):e?pt(i,s):s.stroke())}function wt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ct(t,e,i);else switch(s.strokeAlign){case"center":yt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),yt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)yt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),yt(t,2,e,a),a.clipUI(s),a.clearWorld(n),gt(i,a,e),a.recycle(e.__nowWorld)}}(t,e,i)}}function yt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?_t(t,!1,i,s):s.stroke(),n.__useArrow&&M.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new at(t,e,i),selector:(t,e)=>new dt(t,e)}),e.layout=st.fullLayout;const{getSpread:mt,getOuterOf:xt,getByMove:vt,getIntersectData:bt}=B;let Bt;const{stintSet:kt}=d,{hasTransparent:Et}=D;function St(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=P.image(i,t,e,n,!Bt||!Bt[e.url]);break;case"linear":s=I.linearGradient(e,n);break;case"radial":s=I.radialGradient(e,n);break;case"angular":s=I.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:D.string(r,o)};break;default:void 0!==e.r&&(s={type:"solid",style:D.string(e)})}return s&&("string"==typeof s.style&&Et(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const Rt={compute:function(t,e){const i=e.__,s=[];let n,a,r=i.__input[t];r instanceof Array||(r=[r]),Bt=P.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=St(t,r[n],e))&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),a=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",n),kt(i,"__isTransparentFill",a)):(kt(i,"__isAlphaPixelStroke",n),kt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,ht(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(P.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),ht(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),ht(e,i),i.restoreBlendMode()):ht(e,i)}},fillPathOrText:ht,fillText:lt,stroke:wt,strokes:function(t,e,i){wt(t,e,i)},strokeText:ct,drawTextStroke:pt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=n;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(n))d=s,a=o=n;else{const{renderShapeSpread:s}=t.__layout,c=bt(s?mt(e.bounds,l===h?s*l:[s*h,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),o=xt(n,r),a=vt(o,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let Lt={};const{get:At,rotateOfOuter:Tt,translate:Ot,scaleOfOuter:Ct,scale:Wt,rotate:Pt,skew:Mt}=E;function Dt(t,e,i,s,n,a,r){const o=At();Ot(o,e.x+i,e.y+s),Wt(o,n,a),r&&Tt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function It(t,e,i,s,n,a,r,o){const d=At();r&&Pt(d,r),o&&Mt(d,o.x,o.y),n&&Wt(d,n,a),Ot(d,e.x+i,e.y+s),t.transform=d}function Ft(t,e,i,s,n,a,r,o,d,l){const h=At();if(d)if("center"===l)Tt(h,{x:i/2,y:s/2},d);else switch(Pt(h,d),d){case 90:Ot(h,s,0);break;case 180:Ot(h,i,s);break;case 270:Ot(h,0,i)}Lt.x=e.x+n,Lt.y=e.y+a,Ot(h,Lt.x,Lt.y),r&&Ct(h,Lt,r,o),t.transform=h}const{get:Yt,translate:Ut}=E,Gt=new _,zt={},Nt={};function Xt(t,e,i,s){const{changeful:n,sync:a,editing:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.editing=r),t.data=jt(i,s,e)}function jt(t,e,i){t.padding&&(e=Gt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:d,scale:l,size:h,rotation:c,skew:u,repeat:f,filters:g}=t,p=e.width===s&&e.height===n,_={mode:r},w="center"!==o&&(c||0)%180==90;let y,m;switch(B.set(Nt,0,0,w?n:s,w?s:n),r&&"cover"!==r&&"fit"!==r?((l||h)&&(S.getScaleData(l,h,i,zt),y=zt.scaleX,m=zt.scaleY),o&&(y&&B.scale(Nt,y,m,!0),R.toPoint(o,Nt,e,Nt,!0,!0))):p&&!c||(y=m=B.getFitScale(e,Nt,"fit"!==r),B.put(e,i,o,y,!1,Nt),B.scale(Nt,y,m,!0)),d&&L.move(Nt,d),r){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(Nt.x||Nt.y||y||c||u)&&It(_,e,Nt.x,Nt.y,y,m,c,u);break;case"repeat":(!p||y||c)&&Ft(_,e,s,n,Nt.x,Nt.y,y,m,c,o),f||(_.repeat="repeat");break;default:y&&Dt(_,e,Nt.x,Nt.y,y,m,c)}return _.transform||(e.x||e.y)&&(_.transform=Yt(),Ut(_.transform,e.x,e.y)),y&&"stretch"!==r&&(_.scaleX=y,_.scaleY=m),_.width=s,_.height=n,a&&(_.opacity=a),g&&(_.filters=g),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let qt,Ht=new _;const{isSame:Vt}=B;function Qt(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||Xt(n,s,i,a),!0}function Zt(t,e){Kt(t,A.LOAD,e)}function $t(t,e){Kt(t,A.LOADED,e)}function Jt(t,e,i){e.error=i,t.forceUpdate("surface"),Kt(t,A.ERROR,e)}function Kt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function te(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ee,scale:ie,copy:se}=E,{ceil:ne,abs:ae}=Math;function re(t,i,s){let{scaleX:n,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{n=ae(n),a=ae(a);const{image:t,data:o}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=o;u&&(u=ae(u),f=ae(f),l=ee(),se(l,g),ie(l,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const _=h*c;if(!p&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(d=Math.sqrt(_/w)),d&&(n/=d,a/=d,h/=d,c/=d),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(l||(l=ee(),g&&se(l,g)),ie(l,1/n,1/a));const y=t.getCanvas(ne(h)||1,ne(c)||1,o.opacity,o.filters),m=t.getPattern(y,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=r,!0}}function oe(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{d(s.next(t))}catch(t){a(t)}}function o(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(r,o)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:de}=Math;const le={image:function(t,e,i,s,n){let a,r;const o=v.get(i);return qt&&i===qt.paint&&Vt(s,qt.boxBounds)?a=qt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),qt=o.use>1?{leafPaint:a,paint:i,boxBounds:Ht.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Qt(t,e,i,o,a,s),n&&(Zt(t,r),$t(t,r))):o.error?n&&Jt(t,r,o.error):(n&&(te(t,!0),Zt(t,r)),a.loadId=o.load((()=>{te(t,!1),t.destroyed||(Qt(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),$t(t,r)),a.loadId=void 0}),(e=>{te(t,!1),Jt(t,r,e),a.loadId=void 0})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=v.patternLocked?t.__world:t.__nowWorld,{pixelRatio:o}=i,{data:d}=s;if(!d||s.patternId===a+"-"+r+"-"+o&&!F.running)return!1;if(n)if(d.repeat)n=!1;else if(!(s.changeful||b.isResizing(t)||F.running)){let{width:t,height:i}=d;t*=de(a)*o,i*=de(r)*o,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),n=t*i>e.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,d),!0):(!s.style||s.sync||F.running?re(t,s,o):s.patternTask||(s.patternTask=v.patternTasker.add((()=>oe(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&re(t,s,o),t.forceUpdate("surface")}))),300)),!1)},createPattern:re,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,r,o;for(let d=0,l=i.length;d<l;d++)s=i[d],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,v.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),n.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null},createData:Xt,getPatternData:jt,fillOrFitMode:Dt,clipMode:It,repeatMode:Ft},{toPoint:he}=T,{hasTransparent:ce}=D,ue={},fe={};function ge(t,e,i,s){if(i){let n,a,r,o;for(let t=0,d=i.length;t<d;t++)n=i[t],"string"==typeof n?(r=t/(d-1),a=D.string(n,s)):(r=n.offset,a=D.string(n.color,s)),e.addColorStop(r,a),!o&&ce(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:pe,getDistance:_e}=L,{get:we,rotateOfOuter:ye,scaleOfOuter:me}=E,{toPoint:xe}=T,ve={},be={};function Be(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=pe(e,i);a=we(),n?(me(a,e,r/o*(s||1),1),ye(a,e,t+90)):(me(a,e,1,r/o*(s||1)),ye(a,e,t))}return a}const{getDistance:ke}=L,{toPoint:Ee}=T,Se={},Re={};const Le={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;he(s||"top",i,ue),he(n||"bottom",i,fe);const o=e.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y),d={type:a,style:o};return ge(d,o,t.stops,r),d},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;xe(s||"center",i,ve),xe(n||"bottom",i,be);const d=e.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,_e(ve,be)),l={type:a,style:d};ge(l,d,t.stops,r);const h=Be(i,ve,be,o,!0);return h&&(l.transform=h),l},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Ee(s||"center",i,Se),Ee(n||"bottom",i,Re);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,Se.x,Se.y):e.canvas.createRadialGradient(Se.x,Se.y,0,Se.x,Se.y,ke(Se,Re)),l={type:a,style:d};ge(l,d,t.stops,r);const h=Be(i,Se,Re,o||1,e.conicGradientRotate90);return h&&(l.transform=h),l},getTransform:Be},{copy:Ae,toOffsetOutBounds:Te}=B,Oe={},Ce={};function We(t,i,s,n){const{bounds:a,shapeBounds:r}=n;if(e.fullImageShadow){if(Ae(Oe,t.bounds),Oe.x+=i.x-r.x,Oe.y+=i.y-r.y,s){const{matrix:t}=n;Oe.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Oe.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Oe.width*=s,Oe.height*=s}t.copyWorld(n.canvas,t.bounds,Oe)}else s&&(Ae(Oe,i),Oe.x-=i.width/2*(s-1),Oe.y-=i.height/2*(s-1),Oe.width*=s,Oe.height*=s),t.copyWorld(n.canvas,r,s?Oe:i)}const{toOffsetOutBounds:Pe}=B,Me={};const De={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=o.length-1;Te(l,Ce),o.forEach(((o,p)=>{f.setWorldShadow(Ce.offsetX+o.x*c,Ce.offsetY+o.y*u,o.blur*c,D.string(o.color)),n=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(f,Ce,n,i),s=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,o.blendMode):e.copyWorldToInner(f,s,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=o.length-1;Pe(l,Me),o.forEach(((o,p)=>{f.save(),f.setWorldShadow(Me.offsetX+o.x*c,Me.offsetY+o.y*u,o.blur*c),n=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(f,Me,n,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,l,"source-out"),s=l),f.fillWorld(s,D.string(o.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,o.blendMode):e.copyWorldToInner(f,s,r.renderBounds,o.blendMode),g&&p<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:Ie}=p;function Fe(t,e,i,s,n,a){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ue(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ue(t,i,s,a);break;case"path":i.restore()}}function Ye(t){return t.getSameCanvas(!1,!0)}function Ue(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,r,o;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],o=i.__.mask,o&&(r&&(Fe(this,r,t,n,s,a),s=n=null),"path"===o||"clipping-path"===o?(i.opacity<1?(r="opacity-path",a=i.opacity,n||(n=Ye(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ye(t)),n||(n=Ye(t)),i.__render(s,e)),"clipping"!==o&&"clipping-path"!==o)||Ie(i,e)||i.__render(n||t,e);Fe(this,r,t,n,s,a)};const Ge=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ze=Ge+"_#~&*+\\=|≮≯≈≠=…",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 Xe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const je=Xe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=Xe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),He=Xe(Ge),Ve=Xe(ze),Qe=Xe("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:$e,Single:Je,Before:Ke,After:ti,Symbol:ei,Break:ii}=Ze;function si(t){return je[t]?$e:Qe[t]?ii:qe[t]?Ke:He[t]?ti:Ve[t]?ei:Ne.test(t)?Je:$e}const ni={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 ai(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:ri}=ni,{Letter:oi,Single:di,Before:li,After:hi,Symbol:ci,Break:ui}=Ze;let fi,gi,pi,_i,wi,yi,mi,xi,vi,bi,Bi,ki,Ei,Si,Ri,Li,Ai,Ti=[];function Oi(t,e){vi&&!xi&&(xi=vi),fi.data.push({char:t,width:e}),pi+=e}function Ci(){_i+=pi,fi.width=pi,gi.words.push(fi),fi={data:[]},pi=0}function Wi(){Si&&(Ri.paraNumber++,gi.paraStart=!0,Si=!1),vi&&(gi.startCharSize=xi,gi.endCharSize=vi,xi=0),gi.width=_i,Li.width?ri(gi):Ai&&Pi(),Ti.push(gi),gi={words:[]},_i=0}function Pi(){_i>(Ri.maxWidth||0)&&(Ri.maxWidth=_i)}const{top:Mi,right:Di,bottom:Ii,left:Fi}=O;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 Ui={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=i;l&&(a?(s=l[Fi],a-=l[Di]+l[Fi]):i.autoSizeAlign||(s=l[Fi]),r?(n=l[Mi],r-=l[Mi]+l[Ii]):i.autoSizeAlign||(n=l[Mi]));const h={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){Ri=t,Ti=t.rows,Li=t.bounds,Ai=!Li.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:d,height:l}=Li;if(d||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Si=!0,Bi=null,xi=mi=vi=pi=_i=0,fi={data:[]},gi={words:[]},n&&(i=[...i]);for(let s=0,l=i.length;s<l;s++)yi=i[s],"\n"===yi?(pi&&Ci(),gi.paraEnd=!0,Wi(),Si=!0):(bi=si(yi),bi===oi&&"none"!==r&&(yi=ai(yi,r,!pi)),mi=o.measureText(yi).width,n&&(n<0&&(vi=mi),mi+=n),ki=bi===di&&(Bi===di||Bi===oi)||Bi===di&&bi!==hi,Ei=!(bi!==li&&bi!==di||Bi!==ci&&Bi!==hi),wi=Si&&a?d-a:d,t&&d&&_i+pi+mi>wi&&(e?(pi&&Ci(),_i&&Wi()):(Ei||(Ei=bi===oi&&Bi==hi),ki||Ei||bi===ui||bi===li||bi===di||pi+mi>wi?(pi&&Ci(),_i&&Wi()):_i&&Wi()))," "===yi&&!0!==Si&&_i+pi===0||(bi===ui?(" "===yi&&pi&&Ci(),Oi(yi,mi),Ci()):ki||Ei?(pi&&Ci(),Oi(yi,mi)):Oi(yi,mi)),Bi=bi);pi&&Ci(),_i&&Wi(),Ti.length>0&&(Ti[Ti.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ri.paraNumber++,_i=o.measureText(t).width,Ti.push({x:a||0,text:t,width:_i,paraStart:!0}),Ai&&Pi()}))}(h,t,i),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Yi(e,"x",t[Fi]);break;case"right":Yi(e,"x",-t[Di])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Yi(e,"y",t[Mi]);break;case"bottom":Yi(e,"y",-t[Ii])}}(l,h,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(d&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),d&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,d,l,h,c,u;s.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,u=t.words.length,d=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,h=r||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,o=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,o,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==n||i===u-1||(o+=d,t.width+=d)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,d;"hide"===o?o="":"ellipsis"===o&&(o="...");const l=o?e.canvas.measureText(o).width:0,h=s+n-l;("none"===i.textWrap?a:[a[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<h));s--){if(d<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:o,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,s,a),"none"!==o&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=D.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const Gi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(U,Ui),Object.assign(D,Gi),Object.assign(M,Rt),Object.assign(P,le),Object.assign(I,Le),Object.assign(G,De),Object.assign(n,{interaction:(t,e,i,s)=>new W(t,e,i,s),hitCanvas:(t,e)=>new z(t,e),hitCanvasManager:()=>new C}),X();export{st as Layouter,z as LeaferCanvas,ot as Picker,at as Renderer,dt as Selector,q as Watcher,X as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,Debug as y,LeafLevelList as w,LayoutEvent as m,Run as x,ImageManager as v,ResizeEvent as b,BoundsHelper as k,Plugin as B,getMatrixData as S,MatrixHelper as E,MathHelper as R,AlignHelper as L,PointHelper as A,ImageEvent as T,AroundHelper as C,Direction4 as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as W,InteractionBase as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,Paint as D,ColorConvert as I,PaintGradient as F,Export as Y,Group as z,TextConvert as U,Effect as G}from"@leafer-ui/draw";class j extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__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}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:X}=s;function N(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:X(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:X(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then((t=>{i(t)})).catch((t=>{s(t)}))},n.onerror=t=>s(t),n.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new j(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):q.indexOf("Safari")>-1&&-1===q.indexOf("Chrome")&&(e.fullImageShadow=!0),q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):q.indexOf("Mac")>-1?e.os="Mac":q.indexOf("Linux")>-1&&(e.os="Linux");class H{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=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:V,updateBounds:Q,updateChange:Z}=f,{pushAllChildBranch:$,pushAllParent:J}=g;const{worldBounds:K}=p;class tt{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,K)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,K),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:et,updateAllChange:it}=f,st=y.get("Layouter");class nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=m,o=this.getBlocks(s);o.forEach((t=>t.setBefore())),i.emitEvent(new m(n,o,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?(V(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||Q(s[t])}Q(i)}}))}(this.__levelList),function(t){t.list.forEach(Z)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new m(a,o,this.times)),i.emitEvent(new m(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=m,a=this.getBlocks(new o(e));e.emitEvent(new m(i,a,this.times)),nt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(s,a,this.times)),e.emitEvent(new m(n,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){et(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=y.get("Renderer");class rt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,at.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,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(rt.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||at.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}rt.clipSpread=10;const{hitRadiusPoint:ot}=k;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=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:s,y:n}=this.point,a={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new 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,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ot(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class dt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new lt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):B.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function ht(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function ct(t,e){t.__.__font?ht(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ut(t,e,i){switch(e.__.strokeAlign){case"center":ft(t,1,e,i);break;case"inside":gt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ft(t,2,e,i):gt(t,"outside",e,i)}}function ft(t,e,i,s){const n=i.__;"object"==typeof t?_t(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),pt(i,s))}function gt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ft(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",ht(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function pt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=s;n.forEach((i=>a.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function _t(t,e,i,s,n){let a;const r=s.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!M.checkImage(s,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?pt(s,n):n.stroke(),n.restoreBlendMode()):i?pt(s,n):n.stroke()}}function yt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ut(t,e,i);else switch(s.strokeAlign){case"center":wt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),wt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)wt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),wt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function wt(t,e,i,s){const n=i.__;"object"==typeof t?_t(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&D.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new H(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>new dt(t,e)}),e.layout=nt.fullLayout;const{getSpread:mt,getOuterOf:xt,getByMove:vt,getIntersectData:bt}=k;let kt;const{stintSet:Bt}=l,{hasTransparent:St}=I;function Et(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=M.image(i,t,e,n,!kt||!kt[e.url]);break;case"linear":s=F.linearGradient(e,n);break;case"radial":s=F.radialGradient(e,n);break;case"angular":s=F.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:I.string(r,o)};break;default:void 0!==e.r&&(s={type:"solid",style:I.string(e)})}if(s){if("string"==typeof s.style&&St(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.blendMode&&(s.blendMode=e.blendMode)}return s}const Rt={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];o instanceof Array||(o=[o]),kt=M.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Et(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),a=!0),"fill"===t?(Bt(i,"__isAlphaPixelFill",n),Bt(i,"__isTransparentFill",a)):(Bt(i,"__isAlphaPixelStroke",n),Bt(i,"__isTransparentStroke",a),Bt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,ct(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(M.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);i.scale(1/t,1/s)}s.blendMode&&(i.blendMode=s.blendMode),ct(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),ct(e,i),i.restoreBlendMode()):ct(e,i)}},fillPathOrText:ct,fillText:ht,stroke:yt,strokes:function(t,e,i){yt(t,e,i)},strokeText:ut,drawTextStroke:pt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,r,o,l,{scaleX:d,scaleY:h}=n;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(n))l=s,a=o=n;else{const{renderShapeSpread:s}=t.__layout,c=bt(s?mt(e.bounds,d===h?s*d:[s*h,s*d]):e.bounds,n);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),o=xt(n,r),a=vt(o,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:a,worldCanvas:l,shapeBounds:o,scaleX:d,scaleY:h}}};let Lt={},At=S();const{get:Tt,rotateOfOuter:Ct,translate:Ot,scaleOfOuter:Wt,multiplyParent:Pt,scale:Mt,rotate:Dt,skew:It}=E;function Ft(t,e,i,s,n,a,r){const o=Tt();Ot(o,e.x+i,e.y+s),Mt(o,n,a),r&&Ct(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Yt(t,e,i,s,n,a,r,o,l){const d=Tt();r&&Dt(d,r),o&&It(d,o.x,o.y),n&&Mt(d,n,a),Ot(d,e.x+i,e.y+s),l&&(At.a=e.width/l.width,At.d=e.height/l.height,Pt(d,At)),t.transform=d}function zt(t,e,i,s,n,a,r,o,l,d){const h=Tt();if(l)if("center"===d)Ct(h,{x:i/2,y:s/2},l);else switch(Dt(h,l),l){case 90:Ot(h,s,0);break;case 180:Ot(h,i,s);break;case 270:Ot(h,0,i)}Lt.x=e.x+n,Lt.y=e.y+a,Ot(h,Lt.x,Lt.y),r&&Wt(h,Lt,r,o),t.transform=h}const{get:Ut,translate:Gt}=E,jt=new _,Xt={},Nt={};function qt(t,e,i,s){const{changeful:n,sync:a,editing:r,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.editing=r),o&&(t.scaleFixed=o),t.data=Ht(i,s,e)}function Ht(t,e,i){t.padding&&(e=jt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,filters:p}=t,_=e.width===s&&e.height===n,y={mode:r},w="center"!==o&&(c||0)%180==90;let m,x;switch(k.set(Nt,0,0,w?n:s,w?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(R.getScaleData(d,h,i,Xt),m=Xt.scaleX,x=Xt.scaleY),o&&(m&&k.scale(Nt,m,x,!0),L.toPoint(o,Nt,e,Nt,!0,!0))):_&&!c||(m=x=k.getFitScale(e,Nt,"fit"!==r),k.put(e,i,o,m,!1,Nt),k.scale(Nt,m,x,!0)),l&&A.move(Nt,l),r){case"stretch":_||(s=e.width,n=e.height);break;case"normal":case"clip":(Nt.x||Nt.y||m||f||c||u)&&Yt(y,e,Nt.x,Nt.y,m,x,c,u,t.clipSize);break;case"repeat":(!_||m||c)&&zt(y,e,s,n,Nt.x,Nt.y,m,x,c,o),g||(y.repeat="repeat");break;default:m&&Ft(y,e,Nt.x,Nt.y,m,x,c)}return y.transform||(e.x||e.y)&&(y.transform=Ut(),Gt(y.transform,e.x,e.y)),m&&"stretch"!==r&&(y.scaleX=m,y.scaleY=x),y.width=s,y.height=n,a&&(y.opacity=a),p&&(y.filters=p),g&&(y.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat"),y}let Vt,Qt=new _;const{isSame:Zt}=k;function $t(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||qt(n,s,i,a),!0}function Jt(t,e){ee(t,T.LOAD,e)}function Kt(t,e){ee(t,T.LOADED,e)}function te(t,e,i){e.error=i,t.forceUpdate("surface"),ee(t,T.ERROR,e)}function ee(t,e,i){t.hasEvent(e)&&t.emitEvent(new T(e,i))}function ie(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:se,scale:ne,copy:ae}=E,{ceil:re,abs:oe}=Math;function le(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:t,data:o}=i;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=o;u&&(u=oe(u),f=oe(f),d=se(),ae(d,g),ne(d,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const _=h*c;if(!p&&_>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}_>y&&(l=Math.sqrt(_/y)),l&&(n/=l,a/=l,h/=l,c/=l),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(d||(d=se(),g&&ae(d,g)),ne(d,1/n,1/a));const w=t.getCanvas(re(h)||1,re(c)||1,o.opacity,o.filters),m=t.getPattern(w,p||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=r,!0}}function de(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const he={image:function(t,e,i,s,n){let a,r;const o=v.get(i);return Vt&&i===Vt.paint&&Zt(s,Vt.boxBounds)?a=Vt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Vt=o.use>1?{leafPaint:a,paint:i,boxBounds:Qt.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?($t(t,e,i,o,a,s),n&&(Jt(t,r),Kt(t,r))):o.error?n&&te(t,r,o.error):(n&&(ie(t,!0),Jt(t,r)),a.loadId=o.load((()=>{ie(t,!1),t.destroyed||($t(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,r)),a.loadId=void 0}),(e=>{ie(t,!1),te(t,r,e),a.loadId=void 0})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!Y.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||b.isResizing(t)||Y.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||Y.running?le(t,s,o):s.patternTask||(s.patternTask=v.patternTasker.add((()=>de(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&le(t,s,o),t.forceUpdate("surface")}))),300)),!1)},createPattern:le,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,v.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),n.unload(i[l].loadId,!r.some((t=>t.url===o)))));return a}return null},createData:qt,getPatternData:Ht,fillOrFitMode:Ft,clipMode:Yt,repeatMode:zt},{toPoint:ce}=C,{hasTransparent:ue}=I,fe={},ge={};function pe(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],"string"==typeof n?(r=t/(l-1),a=I.string(n,s)):(r=n.offset,a=I.string(n.color,s)),e.addColorStop(r,a),!o&&ue(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:_e,getDistance:ye}=A,{get:we,rotateOfOuter:me,scaleOfOuter:xe}=E,{toPoint:ve}=C,be={},ke={};function Be(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=_e(e,i);a=we(),n?(xe(a,e,r/o*(s||1),1),me(a,e,t+90)):(xe(a,e,1,r/o*(s||1)),me(a,e,t))}return a}const{getDistance:Se}=A,{toPoint:Ee}=C,Re={},Le={};const Ae={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;ce(s||"top",i,fe),ce(n||"bottom",i,ge);const o=e.canvas.createLinearGradient(fe.x,fe.y,ge.x,ge.y),l={type:a,style:o};return pe(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;ve(s||"center",i,be),ve(n||"bottom",i,ke);const l=e.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,ye(be,ke)),d={type:a,style:l};pe(d,l,t.stops,r);const h=Be(i,be,ke,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Ee(s||"center",i,Re),Ee(n||"bottom",i,Le);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Re.x,Re.y):e.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,Se(Re,Le)),d={type:a,style:l};pe(d,l,t.stops,r);const h=Be(i,Re,Le,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Be},{copy:Te,toOffsetOutBounds:Ce}=k,Oe={},We={};function Pe(t,i,s,n){const{bounds:a,shapeBounds:r}=n;if(e.fullImageShadow){if(Te(Oe,t.bounds),Oe.x+=i.x-r.x,Oe.y+=i.y-r.y,s){const{matrix:t}=n;Oe.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Oe.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Oe.width*=s,Oe.height*=s}t.copyWorld(n.canvas,t.bounds,Oe)}else s&&(Te(Oe,i),Oe.x-=i.width/2*(s-1),Oe.y-=i.height/2*(s-1),Oe.width*=s,Oe.height*=s),t.copyWorld(n.canvas,r,s?Oe:i)}const{toOffsetOutBounds:Me}=k,De={};const Ie={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=o.length-1;Ce(d,We),o.forEach(((o,_)=>{g.setWorldShadow(We.offsetX+o.x*c,We.offsetY+o.y*u,o.blur*c,I.string(o.color)),n=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Pe(g,We,n,i),s=d,o.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),s=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(i.canvas,h,d,"destination-out")),f.copyCanvasByWorld(t,e,g,s,o.blendMode),p&&_<p&&g.clearWorld(s,!0)})),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=o.length-1;Me(d,De),o.forEach(((o,_)=>{g.save(),g.setWorldShadow(De.offsetX+o.x*c,De.offsetY+o.y*u,o.blur*c),n=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Pe(g,De,n,i),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,d,"source-out"),s=d),g.fillWorld(s,I.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,o.blendMode),p&&_<p&&g.clearWorld(s,!0)})),g.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:Fe}=p;function Ye(t,e,i,s,n,a){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ue(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ue(t,i,s,a);break;case"path":i.restore()}}function ze(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}z.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],o=i.__.mask,o?(r&&(Ye(this,r,t,n,s,a),s=n=null),"path"===o||"clipping-path"===o?(i.opacity<1?(r="opacity-path",a=i.opacity,n||(n=ze(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=ze(t)),n||(n=ze(t)),i.__render(s,e)),"clipping"!==o&&"clipping-path"!==o||Fe(i,e)||i.__render(t,e)):Fe(i,e)||i.__render(n||t,e);Ye(this,r,t,n,s,a)};const Ge=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",je=Ge+"_#~&*+\\=|≮≯≈≠=…",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 Ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qe=Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),He=Ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ve=Ne(Ge),Qe=Ne(je),Ze=Ne("- —/~|┆·");var $e;!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"}($e||($e={}));const{Letter:Je,Single:Ke,Before:ti,After:ei,Symbol:ii,Break:si}=$e;function ni(t){return qe[t]?Je:Ze[t]?si:He[t]?ti:Ve[t]?ei:Qe[t]?ii:Xe.test(t)?Ke:Je}const ai={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 ri(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:oi}=ai,{Letter:li,Single:di,Before:hi,After:ci,Symbol:ui,Break:fi}=$e;let gi,pi,_i,yi,wi,mi,xi,vi,bi,ki,Bi,Si,Ei,Ri,Li,Ai,Ti,Ci=[];function Oi(t,e){bi&&!vi&&(vi=bi),gi.data.push({char:t,width:e}),_i+=e}function Wi(){yi+=_i,gi.width=_i,pi.words.push(gi),gi={data:[]},_i=0}function Pi(){Ri&&(Li.paraNumber++,pi.paraStart=!0,Ri=!1),bi&&(pi.startCharSize=vi,pi.endCharSize=bi,vi=0),pi.width=yi,Ai.width?oi(pi):Ti&&Mi(),Ci.push(pi),pi={words:[]},yi=0}function Mi(){yi>(Li.maxWidth||0)&&(Li.maxWidth=yi)}const{top:Di,right:Ii,bottom:Fi,left:Yi}=O;function zi(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 Ui={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[Yi],a-=d[Ii]+d[Yi]):i.autoSizeAlign||(s=d[Yi]),r?(n=d[Di],r-=d[Di]+d[Fi]):i.autoSizeAlign||(n=d[Di]));const h={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Li=t,Ci=t.rows,Ai=t.bounds,Ti=!Ai.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=Ai;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Ri=!0,Bi=null,vi=xi=bi=_i=yi=0,gi={data:[]},pi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)mi=i[s],"\n"===mi?(_i&&Wi(),pi.paraEnd=!0,Pi(),Ri=!0):(ki=ni(mi),ki===li&&"none"!==r&&(mi=ri(mi,r,!_i)),xi=o.measureText(mi).width,n&&(n<0&&(bi=xi),xi+=n),Si=ki===di&&(Bi===di||Bi===li)||Bi===di&&ki!==ci,Ei=!(ki!==hi&&ki!==di||Bi!==ui&&Bi!==ci),wi=Ri&&a?l-a:l,t&&l&&yi+_i+xi>wi&&(e?(_i&&Wi(),yi&&Pi()):(Ei||(Ei=ki===li&&Bi==ci),Si||Ei||ki===fi||ki===hi||ki===di||_i+xi>wi?(_i&&Wi(),yi&&Pi()):yi&&Pi()))," "===mi&&!0!==Ri&&yi+_i===0||(ki===fi?(" "===mi&&_i&&Wi(),Oi(mi,xi),Wi()):Si||Ei?(_i&&Wi(),Oi(mi,xi)):Oi(mi,xi)),Bi=ki);_i&&Wi(),yi&&Pi(),Ci.length>0&&(Ci[Ci.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Li.paraNumber++,yi=o.measureText(t).width,Ci.push({x:a||0,text:t,width:yi,paraStart:!0}),Ti&&Mi()}))}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":zi(e,"x",t[Yi]);break;case"right":zi(e,"x",-t[Ii])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":zi(e,"y",t[Di]);break;case"bottom":zi(e,"y",-t[Fi])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,y=a*n+(c?c*(t.paraNumber-1):0),w=r;if(l&&y>_)y=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-y)/2;break;case"bottom":g+=_-y}w+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(w+=c),m.y=w,w+=a,t.overflow>r&&w>y&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;s.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,h=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,s,a),"none"!==o&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=I.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const Gi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(U,Ui),Object.assign(I,Gi),Object.assign(D,Rt),Object.assign(M,he),Object.assign(F,Ae),Object.assign(G,Ie),Object.assign(n,{interaction:(t,e,i,s)=>new P(t,e,i,s),hitCanvas:(t,e)=>new j(t,e),hitCanvasManager:()=>new W}),N();export{nt as Layouter,j as LeaferCanvas,lt as Picker,rt as Renderer,dt as Selector,H as Watcher,N as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map