@leafer-ui/worker 1.6.2 → 1.6.4

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