@leafer-ui/worker 1.6.2 → 1.6.3

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 n,Creator as s,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 R,MathHelper as E,AlignHelper as S,PointHelper as L,ImageEvent as A,AroundHelper as T,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{Platform as O,HitCanvasManager as C,InteractionBase as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as G,Paint as z,Effect as U}from"@leafer-ui/draw";class N 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}=n;function j(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:X(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:X(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 N(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}=p;const{worldBounds:K}=g;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,nt=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){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.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:a,AFTER:r}=m,o=this.getBlocks(n);o.forEach((t=>t.setBefore())),i.emitEvent(new m(s,o,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?(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)))}))}(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||Q(n[t])}Q(i)}}))}(this.__levelList),function(t){t.list.forEach(Z)}(n),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:n,AFTER:s}=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(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){et(t,!0),t.isBranch?p.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=w.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,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(rt.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 _;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}=B;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),n?{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:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new 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,n=new o;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 o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;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&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||ot(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=l.default(e,this.config)),this.picker=new lt(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:a}=this;return e.backgrounder&&s&&s.updateLayout(),a.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function ht(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[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(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.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()}Object.assign(s,{watcher:(t,e)=>new H(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>new dt(t,e)}),e.layout=st.fullLayout;const ut={};function ft(t,e,i){switch(e.__.strokeAlign){case"center":pt(t,1,e,i);break;case"inside":gt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?pt(t,2,e,i):gt(t,"outside",e,i)}}function pt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?wt(t,!0,i,n):_t(i,n)}function gt(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,pt(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",ht(i,s),s.blendMode="normal",i.__worldFlipped||O.fullImageShadow?n.copyWorldByReset(s,i.__nowWorld):n.copyWorldToInner(s,i.__nowWorld,i.__layout.renderBounds),s.recycle(i.__nowWorld)}function _t(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=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(a){const{decorationHeight:t}=n;s.forEach((i=>a.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function wt(t,e,i,n){let s;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&M.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?_t(i,n):n.stroke(),n.restoreBlendMode()):e?_t(i,n):n.stroke())}function yt(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)ft(t,e,i);else switch(n.strokeAlign){case"center":mt(t,1,e,i);break;case"inside":!function(t,e,i){const n=e.__;i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),mt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)mt(t,2,e,i);else{const{renderBounds:s}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),mt(t,2,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(s),e.__worldFlipped||O.fullImageShadow?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,s),a.recycle(e.__nowWorld)}}(t,e,i)}}function mt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?wt(t,!1,i,n):n.stroke(),s.__useArrow&&ut.strokeArrow(t,i,n)}const{getSpread:xt,getOuterOf:vt,getByMove:bt,getIntersectData:Bt}=B;let kt;const{stintSet:Rt}=l,{hasTransparent:Et}=D;function St(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:s}=i.__layout;switch(e.type){case"image":n=M.image(i,t,e,s,!kt||!kt[e.url]);break;case"linear":n=I.linearGradient(e,s);break;case"radial":n=I.radialGradient(e,s);break;case"angular":n=I.conicGradient(e,s);break;case"solid":const{type:a,blendMode:r,color:o,opacity:l}=e;n={type:a,blendMode:r,style:D.string(o,l)};break;default:void 0!==e.r&&(n={type:"solid",style:D.string(e)})}return n&&("string"==typeof n.style&&Et(n.style)&&(n.isTransparent=!0),e.blendMode&&(n.blendMode=e.blendMode)),n}const Lt={compute:function(t,e){const i=e.__,n=[];let s,a,r=i.__input[t];r instanceof Array||(r=[r]),kt=M.recycleImage(t,i);for(let i,s=0,a=r.length;s<a;s++)i=St(t,r[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n.every((t=>t.isTransparent))&&(n.some((t=>t.image))&&(s=!0),a=!0),"fill"===t?(Rt(i,"__isAlphaPixelFill",s),Rt(i,"__isTransparentFill",a)):(Rt(i,"__isAlphaPixelStroke",s),Rt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,ct(e,i)},fills:function(t,e,i){let n;for(let s=0,a=t.length;s<a;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),ct(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.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:ft,drawTextStroke:_t,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,l,{scaleX:d,scaleY:h}=s;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(s))l=n,a=o=s;else{const{renderShapeSpread:n}=t.__layout,c=Bt(n?xt(e.bounds,d===h?n*d:[n*h,n*d]):e.bounds,s);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=vt(s,r),a=bt(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(n,i),{canvas:n,matrix:r,bounds:a,worldCanvas:l,shapeBounds:o,scaleX:d,scaleY:h}}};let At={};const{get:Tt,rotateOfOuter:Wt,translate:Ot,scaleOfOuter:Ct,scale:Pt,rotate:Mt}=R;function Dt(t,e,i,n,s,a,r){const o=Tt();Ot(o,e.x+i,e.y+n),Pt(o,s,a),r&&Wt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function It(t,e,i,n,s,a,r){const o=Tt();Ot(o,e.x+i,e.y+n),s&&Pt(o,s,a),r&&Mt(o,r),t.transform=o}function Ft(t,e,i,n,s,a,r,o,l,d){const h=Tt();if(l)if("center"===d)Wt(h,{x:i/2,y:n/2},l);else switch(Mt(h,l),l){case 90:Ot(h,n,0);break;case 180:Ot(h,i,n);break;case 270:Ot(h,0,i)}At.x=e.x+s,At.y=e.y+a,Ot(h,At.x,At.y),r&&Ct(h,At,r,o),t.transform=h}const{get:Yt,translate:Gt}=R,zt=new _,Ut={},Nt={};function Xt(t,e,i,n){const{changeful:s,sync:a}=i;s&&(t.changeful=s),a&&(t.sync=a),t.data=jt(i,n,e)}function jt(t,e,i){t.padding&&(e=zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:s}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,repeat:u,filters:f}=t,p=e.width===n&&e.height===s,g={mode:r},_="center"!==o&&(c||0)%180==90;let w,y;switch(B.set(Nt,0,0,_?s:n,_?n:s),r&&"cover"!==r&&"fit"!==r?((d||h)&&(E.getScaleData(d,h,i,Ut),w=Ut.scaleX,y=Ut.scaleY),o&&(w&&B.scale(Nt,w,y,!0),S.toPoint(o,Nt,e,Nt,!0,!0))):p&&!c||(w=y=B.getFitScale(e,Nt,"fit"!==r),B.put(e,i,o,w,!1,Nt),B.scale(Nt,w,y,!0)),l&&L.move(Nt,l),r){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(Nt.x||Nt.y||w||c)&&It(g,e,Nt.x,Nt.y,w,y,c);break;case"repeat":(!p||w||c)&&Ft(g,e,n,s,Nt.x,Nt.y,w,y,c,o),u||(g.repeat="repeat");break;default:w&&Dt(g,e,Nt.x,Nt.y,w,y,c)}return g.transform||(e.x||e.y)&&(g.transform=Yt(),Gt(g.transform,e.x,e.y)),w&&"stretch"!==r&&(g.scaleX=w,g.scaleY=y),g.width=n,g.height=s,a&&(g.opacity=a),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let qt,Ht=new _;const{isSame:Vt}=B;function Qt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Xt(s,n,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:ne}=R,{ceil:se,abs:ae}=Math;function re(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const r=s+"-"+a+"-"+n;if(i.patternId===r||t.destroyed)return!1;{s=ae(s),a=ae(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=ee(),ne(d,p),ie(d,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,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&&(s/=l,a/=l,h/=l,c/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=ee(),p&&ne(d,p)),ie(d,1/s,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 oe(t,e,i,n){return new(i||(i=Promise))((function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:le}=Math;const de={image:function(t,e,i,n,s){let a,r;const o=v.get(i);return qt&&i===qt.paint&&Vt(n,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(n)}:null),(s||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Qt(t,e,i,o,a,n),s&&(Zt(t,r),$t(t,r))):o.error?s&&Jt(t,r,o.error):(s&&(te(t,!0),Zt(t,r)),a.loadId=o.load((()=>{te(t,!1),t.destroyed||(Qt(t,e,i,o,a,n)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),$t(t,r)),a.loadId=null}),(e=>{te(t,!1),Jt(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,n,s){const{scaleX:a,scaleY:r}=v.patternLocked?t.__world:t.__nowWorld,{pixelRatio:o}=i,{data:l}=n;if(!l||n.patternId===a+"-"+r+"-"+o&&!F.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||F.running)){let{width:t,height:i}=l;t*=le(a)*o,i*=le(r)*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,l),!0):(!n.style||n.sync||F.running?re(t,n,o):n.patternTask||(n.patternTask=v.patternTasker.add((()=>oe(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&re(t,n,o),t.forceUpdate("surface")}))),300)),!1)},createPattern:re,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,r,o;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,v.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[l].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 pe(t,e,i,n){if(i){let s,a,r,o;for(let t=0,l=i.length;t<l;t++)s=i[t],"string"==typeof s?(r=t/(l-1),a=D.string(s,n)):(r=s.offset,a=D.string(s.color,n)),e.addColorStop(r,a),!o&&ce(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:ge,getDistance:_e}=L,{get:we,rotateOfOuter:ye,scaleOfOuter:me}=R,{toPoint:xe}=T,ve={},be={};function Be(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=ge(e,i);a=we(),s?(me(a,e,r/o*(n||1),1),ye(a,e,t+90)):(me(a,e,1,r/o*(n||1)),ye(a,e,t))}return a}const{getDistance:ke}=L,{toPoint:Re}=T,Ee={},Se={};const Le={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:r}=t;he(n||"top",i,ue),he(s||"bottom",i,fe);const o=e.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y),l={type:a,style:o};return pe(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=t;xe(n||"center",i,ve),xe(s||"bottom",i,be);const l=e.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,_e(ve,be)),d={type:a,style:l};pe(d,l,t.stops,r);const h=Be(i,ve,be,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=t;Re(n||"center",i,Ee),Re(s||"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,ke(Ee,Se)),d={type:a,style:l};pe(d,l,t.stops,r);const h=Be(i,Ee,Se,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Be},{copy:Ae,toOffsetOutBounds:Te}=B,We={},Oe={};function Ce(t,i,n,s){const{bounds:a,shapeBounds:r}=s;if(e.fullImageShadow){if(Ae(We,t.bounds),We.x+=i.x-r.x,We.y+=i.y-r.y,n){const{matrix:t}=s;We.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),We.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),We.width*=n,We.height*=n}t.copyWorld(s.canvas,t.bounds,We)}else n&&(Ae(We,i),We.x-=i.width/2*(n-1),We.y-=i.height/2*(n-1),We.width*=n,We.height*=n),t.copyWorld(s.canvas,r,n?We:i)}const{toOffsetOutBounds:Pe}=B,Me={};const De={shadow:function(t,e,i){let n,s;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;Te(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)),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ce(f,Oe,s,i),n=d,o.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),n=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,o.blendMode):e.copyWorldToInner(f,n,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;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;Pe(d,Me),o.forEach(((o,g)=>{f.save(),f.setWorldShadow(Me.offsetX+o.x*c,Me.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ce(f,Me,s,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,d,"source-out"),n=d),f.fillWorld(n,D.string(o.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,o.blendMode):e.copyWorldToInner(f,n,r.renderBounds,o.blendMode),p&&g<p&&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:Ie}=g;function Fe(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ge(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ge(t,i,n,a);break;case"path":i.restore()}}function Ye(t){return t.getSameCanvas(!1,!0)}function Ge(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],o=i.__.mask,o&&(r&&(Fe(this,r,t,s,n,a),n=s=null),"path"===o||"clipping-path"===o?(i.opacity<1?(r="opacity-path",a=i.opacity,s||(s=Ye(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=Ye(t)),s||(s=Ye(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o)||Ie(i,e)||i.__render(s||t,e);Fe(this,r,t,s,n,a)};const ze=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=ze+"_#~&*+\\=|≮≯≈≠=…",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(ze),Ve=Xe(Ue),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 ni(t){return je[t]?$e:Qe[t]?ii:qe[t]?Ke:He[t]?ti:Ve[t]?ei:Ne.test(t)?Je:$e}const si={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function 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}=si,{Letter:oi,Single:li,Before:di,After:hi,Symbol:ci,Break:ui}=Ze;let fi,pi,gi,_i,wi,yi,mi,xi,vi,bi,Bi,ki,Ri,Ei,Si,Li,Ai,Ti=[];function Wi(t,e){vi&&!xi&&(xi=vi),fi.data.push({char:t,width:e}),gi+=e}function Oi(){_i+=gi,fi.width=gi,pi.words.push(fi),fi={data:[]},gi=0}function Ci(){Ei&&(Si.paraNumber++,pi.paraStart=!0,Ei=!1),vi&&(pi.startCharSize=xi,pi.endCharSize=vi,xi=0),pi.width=_i,Li.width?ri(pi):Ai&&Pi(),Ti.push(pi),pi={words:[]},_i=0}function Pi(){_i>(Si.maxWidth||0)&&(Si.maxWidth=_i)}const{top:Mi,right:Di,bottom:Ii,left:Fi}=W;function Yi(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 Gi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(n=d[Fi],a-=d[Di]+d[Fi]):i.autoSizeAlign||(n=d[Fi]),r?(s=d[Mi],r-=d[Mi]+d[Ii]):i.autoSizeAlign||(s=d[Mi]));const h={bounds:{x:n,y:s,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,n){Si=t,Ti=t.rows,Li=t.bounds,Ai=!Li.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=e,{width:l,height:d}=Li;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ei=!0,Bi=null,xi=mi=vi=gi=_i=0,fi={data:[]},pi={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)yi=i[n],"\n"===yi?(gi&&Oi(),pi.paraEnd=!0,Ci(),Ei=!0):(bi=ni(yi),bi===oi&&"none"!==r&&(yi=ai(yi,r,!gi)),mi=o.measureText(yi).width,s&&(s<0&&(vi=mi),mi+=s),ki=bi===li&&(Bi===li||Bi===oi)||Bi===li&&bi!==hi,Ri=!(bi!==di&&bi!==li||Bi!==ci&&Bi!==hi),wi=Ei&&a?l-a:l,t&&l&&_i+gi+mi>wi&&(e?(gi&&Oi(),_i&&Ci()):(Ri||(Ri=bi===oi&&Bi==hi),ki||Ri||bi===ui||bi===di||bi===li||gi+mi>wi?(gi&&Oi(),_i&&Ci()):_i&&Ci()))," "===yi&&!0!==Ei&&_i+gi===0||(bi===ui?(" "===yi&&gi&&Oi(),Wi(yi,mi),Oi()):ki||Ri?(gi&&Oi(),Wi(yi,mi)):Wi(yi,mi)),Bi=bi);gi&&Oi(),_i&&Ci(),Ti.length>0&&(Ti[Ti.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Si.paraNumber++,_i=o.measureText(t).width,Ti.push({x:a||0,text:t,width:_i,paraStart:!0}),Ai&&Pi()}))}(h,t,i),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Yi(e,"x",t[Fi]);break;case"right":Yi(e,"x",-t[Di])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Yi(e,"y",t[Mi]);break;case"bottom":Yi(e,"y",-t[Ii])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:n}=t,s=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:_}=n,w=a*s+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),s>1&&(t.overflow=s);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=s;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<n.x&&(n.x=x),v>n.width&&(n.width=v),l&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;n.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&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,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,n,s){if(!s)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=n+s-d;("none"===i.textWrap?a:[a[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],l=t.x+t.width,!(n===i&&l<h));n--){if(l<h&&" "!==t.char||!n){e.data.splice(n+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,n,a),"none"!==o&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=D.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(h,i),h}};const zi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(G,Gi),Object.assign(D,zi),Object.assign(z,Lt),Object.assign(M,de),Object.assign(I,Le),Object.assign(U,De),Object.assign(s,{interaction:(t,e,i,n)=>new P(t,e,i,n),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new C}),j();export{st as Layouter,N as LeaferCanvas,lt as Picker,rt as Renderer,dt as Selector,H as Watcher,j as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map