leafer-draw 1.5.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>{const i=s(e),o=t.toDataURL(i,n);return"image/bmp"===i?o.replace("image/png;","image/bmp;"):o},canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("AppleWebKit")>-1&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class d{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),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:w,updateAllChange:m}=t.LeafHelper,y=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,d,this.times)),i.emitEvent(new t.LayoutEvent(r,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),v.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}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(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(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||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function E(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)}));if(o){const{decorationColor:t,decorationHeight:n}=i;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((i=>e.fillRect(t.x,t.y+i,t.width,n)))))}}function B(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?k(t,!0,e,n):L(e,n);break;case"inside":R("inside",t,s,e,n);break;case"outside":R("outside",t,s,e,n)}}function R(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?k(e,!0,i,r):L(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",E(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function L(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)}));if(o){const{decorationHeight:t}=i;s.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function k(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}function P(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=v.fullLayout;const{getSpread:C,getOuterOf:S,getByMove:A,getIntersectData:O}=t.BoundsHelper;let W;function M(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:d}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,d)};case"image":return e.PaintImage.image(i,t,n,s,!W||!W[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const I={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),W=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=M(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?E(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,d=t.length;r<d;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?E(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?E(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?E(n,i):o?i.fill(o):i.fill())},fillText:E,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)B(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)B(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),k(t,!1,e,n),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),k(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),k(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:B,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?C(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=S(s,a),o=A(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let T={};const{get:D,rotateOfOuter:z,translate:H,scaleOfOuter:F,scale:V,rotate:G}=t.MatrixHelper;function j(t,e,n,i,s,o,a){const r=D();H(r,e.x+n,e.y+i),V(r,s,o),a&&z(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Y(t,e,n,i,s,o,a){const r=D();H(r,e.x+n,e.y+i),s&&V(r,s,o),a&&G(r,a),t.transform=r}function U(t,e,n,i,s,o,a,r,d,l){const c=D();if(d)if("center"===l)z(c,{x:n/2,y:i/2},d);else switch(G(c,d),d){case 90:H(c,i,0);break;case 180:H(c,n,i);break;case 270:H(c,0,n)}T.x=e.x+s,T.y=e.y+o,H(c,T.x,T.y),a&&F(c,T,a,r),t.transform=c}const{get:N,translate:q}=t.MatrixHelper,X=new t.Bounds,Q={},K={};function Z(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=$(n,i,e)}function $(e,n,i){let{width:s,height:o}=i;e.padding&&(n=X.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:d,offset:l,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===o,_={mode:r},w="center"!==d&&(u||0)%180==90,m=w?o:s,y=w?s:o;let v,x,b=0,E=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,K),v=K.scaleX,x=K.scaleY);else if(!g||u){const t=n.width/m,e=n.height/y;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,E+=(n.height-o*x)/2}if(d){const e={x:b,y:E,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(d,e,n,Q,!0),b+=Q.x,E+=Q.y}switch(l&&(b+=l.x,E+=l.y),r){case"stretch":g||(s=n.width,o=n.height);break;case"normal":case"clip":(b||E||v||u)&&Y(_,n,b,E,v,x,u);break;case"repeat":(!g||v||u)&&U(_,n,s,o,b,E,v,x,u,d),f||(_.repeat="repeat");break;default:v&&j(_,n,b,E,v,x,u)}return _.transform||(n.x||n.y)&&(_.transform=N(),q(_.transform,n.x,n.y)),v&&"stretch"!==r&&(_.scaleX=v,_.scaleY=x),_.width=s,_.height=o,a&&(_.opacity=a),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let J,tt=new t.Bounds;const{isSame:et}=t.BoundsHelper;function nt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Z(s,i,n,o),!0}function it(e,n){at(e,t.ImageEvent.LOAD,n)}function st(e,n){at(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),at(e,t.ImageEvent.ERROR,n)}function at(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function rt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:dt,scale:lt,copy:ct}=t.MatrixHelper,{ceil:ht,abs:ut}=Math;function ft(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=ut(s),o=ut(o);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(l=dt(),ct(l,p),lt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}_>w&&(d=Math.sqrt(_/w)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=dt(),p&&ct(l,p)),lt(l,1/s,1/o));const m=e.getCanvas(ht(c)||1,ht(h)||1,r.opacity,r.filters),y=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=y,n.patternId=a,!0}}function pt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:gt}=Math;const _t={image:function(e,n,i,s,o){let a,r;const d=t.ImageManager.get(i);return J&&i===J.paint&&et(s,J.boxBounds)?a=J.leafPaint:(a={type:i.type,image:d},J=d.use>1?{leafPaint:a,paint:i,boxBounds:tt.set(s)}:null),(o||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?(nt(e,n,i,d,a,s),o&&(it(e,r),st(e,r))):d.error?o&&ot(e,r,d.error):(o&&(rt(e,!0),it(e,r)),a.loadId=d.load((()=>{rt(e,!1),e.destroyed||(nt(e,n,i,d,a,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),st(e,r)),a.loadId=null}),(t=>{rt(e,!1),ot(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:d}=i;if(!s.data||s.patternId===a+"-"+r+"-"+d&&!e.Export.running)return!1;{const{data:l}=s;if(o)if(l.repeat)o=!1;else{let{width:n,height:i}=l;n*=gt(a)*d,i*=gt(r)*d,l.scaleX&&(n*=l.scaleX,i*=l.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),l.opacity&&(i.opacity*=l.opacity),l.transform&&i.transform(l.transform),i.drawImage(s.image.getFull(l.filters),0,0,l.width,l.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ft(n,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>pt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ft(n,s,d),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ft,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let d=0,l=i.length;d<l;d++)s=i[d].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading?(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[d].loadId,!a.some((t=>t.url===r)))):i[d].style=null);return o}return null},createData:Z,getPatternData:$,fillOrFitMode:j,clipMode:Y,repeatMode:U},{toPoint:wt}=t.AroundHelper,mt={},yt={};function vt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:xt,getDistance:bt}=t.PointHelper,{get:Et,rotateOfOuter:Bt,scaleOfOuter:Rt}=t.MatrixHelper,{toPoint:Lt}=t.AroundHelper,kt={},Pt={};function Ct(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=xt(e,n);o=Et(),s?(Rt(o,e,a/r*(i||1),1),Bt(o,e,t+90)):(Rt(o,e,1,a/r*(i||1)),Bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:At}=t.AroundHelper,Ot={},Wt={};const Mt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;wt(i||"top",n,mt),wt(s||"bottom",n,yt);const d=t.Platform.canvas.createLinearGradient(mt.x,mt.y,yt.x,yt.y);vt(d,e.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=e;Lt(i||"center",n,kt),Lt(s||"bottom",n,Pt);const l=t.Platform.canvas.createRadialGradient(kt.x,kt.y,0,kt.x,kt.y,bt(kt,Pt));vt(l,e.stops,a);const c={type:o,style:l},h=Ct(n,kt,Pt,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=e;At(i||"center",n,Ot),At(s||"bottom",n,Wt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,St(Ot,Wt));vt(l,e.stops,a);const c={type:o,style:l},h=Ct(n,Ot,Wt,d||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Ct},{copy:It,toOffsetOutBounds:Tt}=t.BoundsHelper,Dt={},zt={};function Ht(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(It(Dt,e.bounds),Dt.x+=n.x-a.x,Dt.y+=n.y-a.y,i){const{matrix:t}=s;Dt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Dt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Dt.width*=i,Dt.height*=i}e.copyWorld(s.canvas,e.bounds,Dt)}else i&&(It(Dt,n),Dt.x-=n.width/2*(i-1),Dt.y-=n.height/2*(i-1),Dt.width*=i,Dt.height*=i),e.copyWorld(s.canvas,a,i?Dt:n)}const{toOffsetOutBounds:Ft}=t.BoundsHelper,Vt={};const Gt={shadow:function(t,n,i){let s,o;const{__nowWorld:a,__layout:r}=t,{shadow:d}=t.__,{worldCanvas:l,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;Tt(c,zt),d.forEach(((d,_)=>{p.setWorldShadow(zt.offsetX+d.x*u,zt.offsetY+d.y*f,d.blur*u,e.ColorConvert.string(d.color)),o=d.spread?1+2*d.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ht(p,zt,o,i),s=c,d.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,c,a,"copy"),s=a),l?p.copyWorld(l,a,a,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,a,d.blendMode):n.copyWorldToInner(p,s,r.renderBounds,d.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,n,i){let s,o;const{__nowWorld:a,__layout:r}=t,{innerShadow:d}=t.__,{worldCanvas:l,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;Ft(c,Vt),d.forEach(((d,_)=>{p.save(),p.setWorldShadow(Vt.offsetX+d.x*u,Vt.offsetY+d.y*f,d.blur*u),o=d.spread?1-2*d.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ht(p,Vt,o,i),p.restore(),l?(p.copyWorld(p,c,a,"copy"),p.copyWorld(l,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(d.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,a,d.blendMode):n.copyWorldToInner(p,s,r.renderBounds,d.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:jt}=t.LeafBoundsHelper;function Yt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Nt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Nt(t,n,i,o);break;case"path":n.restore()}}function Ut(t){return t.getSameCanvas(!1,!0)}function Nt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(Yt(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ut(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ut(t)),s||(s=Ut(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||jt(n,e)||n.__render(s||t,e);Yt(this,a,t,s,i,o)};const qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Xt=qt+"_#~&*+\\=|≮≯≈≠=…",Qt=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 Kt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Zt=Kt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$t=Kt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Kt(qt),te=Kt(Xt),ee=Kt("- —/~|┆·");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:ie,Single:se,Before:oe,After:ae,Symbol:re,Break:de}=ne;function le(t){return Zt[t]?ie:ee[t]?de:$t[t]?oe:Jt[t]?ae:te[t]?re:Qt.test(t)?se:ie}const ce={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function he(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ue}=ce,{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:we,Break:me}=ne;let ye,ve,xe,be,Ee,Be,Re,Le,ke,Pe,Ce,Se,Ae,Oe,We,Me,Ie,Te=[];function De(t,e){ke&&!Le&&(Le=ke),ye.data.push({char:t,width:e}),xe+=e}function ze(){be+=xe,ye.width=xe,ve.words.push(ye),ye={data:[]},xe=0}function He(){Oe&&(We.paraNumber++,ve.paraStart=!0,Oe=!1),ke&&(ve.startCharSize=Le,ve.endCharSize=ke,Le=0),ve.width=be,Me.width?ue(ve):Ie&&Fe(),Te.push(ve),ve={words:[]},be=0}function Fe(){be>(We.maxWidth||0)&&(We.maxWidth=be)}const{top:Ve,right:Ge,bottom:je,left:Ye}=t.Direction4;function Ue(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Ne={getDrawData:function(n,i){"string"!=typeof n&&(n=String(n));let s=0,o=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:d,__font:l,__padding:c}=i;c&&(a?(s=c[Ye],a-=c[Ge]+c[Ye]):i.autoSizeAlign||(s=c[Ye]),r?(o=c[Ve],r-=c[Ve]+c[je]):i.autoSizeAlign||(o=c[Ve]));const h={bounds:{x:s,y:o,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){We=e,Te=e.rows,Me=e.bounds,Ie=!Me.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:d,height:l}=Me;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Ce=null,Le=Re=ke=xe=be=0,ye={data:[]},ve={words:[]};for(let i=0,l=n.length;i<l;i++)Be=n[i],"\n"===Be?(xe&&ze(),ve.paraEnd=!0,He(),Oe=!0):(Pe=le(Be),Pe===fe&&"none"!==a&&(Be=he(Be,a,!xe)),Re=r.measureText(Be).width,s&&(s<0&&(ke=Re),Re+=s),Se=Pe===pe&&(Ce===pe||Ce===fe)||Ce===pe&&Pe!==_e,Ae=!(Pe!==ge&&Pe!==pe||Ce!==we&&Ce!==_e),Ee=Oe&&o?d-o:d,t&&d&&be+xe+Re>Ee&&(e?(xe&&ze(),be&&He()):(Ae||(Ae=Pe===fe&&Ce==_e),Se||Ae||Pe===me||Pe===ge||Pe===pe||xe+Re>Ee?(xe&&ze(),be&&He()):be&&He()))," "===Be&&!0!==Oe&&be+xe===0||(Pe===me?(" "===Be&&xe&&ze(),De(Be,Re),ze()):Se||Ae?(xe&&ze(),De(Be,Re)):De(Be,Re)),Ce=Pe);xe&&ze(),be&&He(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,be=r.measureText(t).width,Te.push({x:o||0,text:t,width:be,paraStart:!0}),Ie&&Fe()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ue(e,"x",t[Ye]);break;case"right":Ue(e,"x",-t[Ge])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ue(e,"y",t[Ve]);break;case"bottom":Ue(e,"y",-t[je])}}(c,h,i,a,r),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=o*s+(h?h*(t.paraNumber-1):0),m=a;if(d&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let a=0,c=s;a<c;a++){if(y=n[a],y.x=f,y.width<g||y.width>g&&!d)switch(l){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&a>0&&(m+=h),y.y=m,m+=o,t.overflow>a&&m>w&&(y.isOverflow=!0,t.overflow=a+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),d&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h,u;i.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-l)/(u-1):0,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||n===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(h,i,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],d=e.x+e.width,!(i===n&&d<c));i--){if(d<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,a),"none"!==d&&function(t,n){let i;const{fontSize:s,textDecoration:o}=n;switch(t.decorationHeight=s/11,"object"==typeof o?(i=o.type,o.color&&(t.decorationColor=e.ColorConvert.string(o.color))):i=o,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 qe={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(e.TextConvert,Ne),Object.assign(e.ColorConvert,qe),Object.assign(e.Paint,I),Object.assign(e.PaintImage,_t),Object.assign(e.PaintGradient,Mt),Object.assign(e.Effect,Gt),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=i,exports.Renderer=b,exports.Watcher=d,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:r}=this.autoBounds.getBoundsFrom(e),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function r(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>{const i=s(e),o=t.toDataURL(i,n);return"image/bmp"===i?o.replace("image/png;","image/bmp;"):o},canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const r=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(r,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:a}=navigator;a.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):a.indexOf("AppleWebKit")>-1&&(t.Platform.fullImageShadow=!0),a.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):a.indexOf("Mac")>-1?t.Platform.os="Mac":a.indexOf("Linux")>-1&&(t.Platform.os="Linux");class d{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),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:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,d,this.times)),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),y.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(o,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}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(t.LayoutEvent.REQUEST)}checkRender(){this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=new t.Bounds(s);i.save(),s.spread(x.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,e.includes(this.target.__world),o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const{canvas:s}=this,o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(e.parentApp)return e.parentApp.renderer.update(!1);if(this.requestTime)return;const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.checkRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function b(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)}));if(o){const{decorationColor:t,decorationHeight:n}=i;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((i=>e.fillRect(t.x,t.y+i,t.width,n)))))}}function E(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?L(t,!0,e,n):R(e,n);break;case"inside":B("inside",t,s,e,n);break;case"outside":B("outside",t,s,e,n)}}function B(t,e,n,i,s){const{__strokeWidth:o,__font:r}=i.__,a=s.getSameCanvas(!0,!0);a.setStroke(n?void 0:e,2*o,i.__),a.font=r,n?L(e,!0,i,a):R(i,a),a.blendMode="outside"===t?"destination-out":"destination-in",b(i,a),a.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(a,i.__nowWorld):s.copyWorldToInner(a,i.__nowWorld,i.__layout.renderBounds),a.recycle(i.__nowWorld)}function R(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)}));if(o){const{decorationHeight:t}=i;s.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function L(t,n,i,s){let o;for(let r=0,a=t.length;r<a;r++)o=t[r],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?R(i,s):s.stroke(),s.restoreBlendMode()):n?R(i,s):s.stroke())}function k(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:P,getOuterOf:S,getByMove:C,getIntersectData:A}=t.BoundsHelper;let O;function W(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:r,color:a,opacity:d}=n;return{type:o,blendMode:r,style:e.ColorConvert.string(a,d)};case"image":return e.PaintImage.image(i,t,n,s,!O||!O[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const M={compute:function(t,n){const i=n.__,s=[];let o,r=i.__input[t];r instanceof Array||(r=[r]),O=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=r.length;i<o;i++)e=W(t,r[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?b(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:r}=n.__;for(let a=0,d=t.length;a<d;a++)s=t[a],s.image&&e.PaintImage.checkImage(n,i,s,!r)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),r?b(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),r?b(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):r?b(n,i):o?i.fill(o):i.fill())},fillText:b,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=i;if(s)if(r)E(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&k(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=i;if(s)if(r)E(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),L(t,!1,e,n),i.__useArrow&&k(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),L(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),L(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:E,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=a=s;else{const{renderShapeSpread:i}=t.__layout,h=A(i?P(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);r=e.bounds.getFitMatrix(h);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),a=S(s,r),o=C(a,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:o,worldCanvas:d,shapeBounds:a,scaleX:l,scaleY:c}}};let I={};const{get:T,rotateOfOuter:D,translate:z,scaleOfOuter:F,scale:H,rotate:G}=t.MatrixHelper;function j(t,e,n,i,s,o,r){const a=T();z(a,e.x+n,e.y+i),H(a,s,o),r&&D(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function V(t,e,n,i,s,o,r){const a=T();z(a,e.x+n,e.y+i),s&&H(a,s,o),r&&G(a,r),t.transform=a}function Y(t,e,n,i,s,o,r,a,d,l){const c=T();if(d)if("center"===l)D(c,{x:n/2,y:i/2},d);else switch(G(c,d),d){case 90:z(c,i,0);break;case 180:z(c,n,i);break;case 270:z(c,0,n)}I.x=e.x+s,I.y=e.y+o,z(c,I.x,I.y),r&&F(c,I,r,a),t.transform=c}const{get:N,translate:U}=t.MatrixHelper,q=new t.Bounds,X={},Q={};function K(t,e,n,i){const{blendMode:s,changeful:o,sync:r}=n;s&&(t.blendMode=s),o&&(t.changeful=o),r&&(t.sync=r),t.data=Z(n,i,e)}function Z(e,n,i){let{width:s,height:o}=i;e.padding&&(n=q.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:r,mode:a,align:d,offset:l,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===o,_={mode:a},w="center"!==d&&(u||0)%180==90,m=w?o:s,y=w?s:o;let v,x,b=0,E=0;if(a&&"cover"!==a&&"fit"!==a)(c||h)&&(t.MathHelper.getScaleData(c,h,i,Q),v=Q.scaleX,x=Q.scaleY);else if(!g||u){const t=n.width/m,e=n.height/y;v=x="fit"===a?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,E+=(n.height-o*x)/2}if(d){const e={x:b,y:E,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(d,e,n,X,!0),b+=X.x,E+=X.y}switch(l&&(b+=l.x,E+=l.y),a){case"stretch":g||(s=n.width,o=n.height);break;case"normal":case"clip":(b||E||v||u)&&V(_,n,b,E,v,x,u);break;case"repeat":(!g||v||u)&&Y(_,n,s,o,b,E,v,x,u,d),f||(_.repeat="repeat");break;default:v&&j(_,n,b,E,v,x,u)}return _.transform||(n.x||n.y)&&(_.transform=N(),U(_.transform,n.x,n.y)),v&&"stretch"!==a&&(_.scaleX=v,_.scaleY=x),_.width=s,_.height=o,r&&(_.opacity=r),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let $,J=new t.Bounds;const{isSame:tt}=t.BoundsHelper;function et(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||K(s,i,n,o),!0}function nt(e,n){ot(e,t.ImageEvent.LOAD,n)}function it(e,n){ot(e,t.ImageEvent.LOADED,n)}function st(e,n,i){n.error=i,e.forceUpdate("surface"),ot(e,t.ImageEvent.ERROR,n)}function ot(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function rt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:at,scale:dt,copy:lt}=t.MatrixHelper,{ceil:ct,abs:ht}=Math;function ut(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+o+"-"+i;if(n.patternId===r||e.destroyed)return!1;{s=ht(s),o=ht(o);const{image:e,data:a}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=a;u&&(l=at(),lt(l,p),dt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}_>w&&(d=Math.sqrt(_/w)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=at(),p&&lt(l,p)),dt(l,1/s,1/o));const m=e.getCanvas(ct(c)||1,ct(h)||1,a.opacity,a.filters),y=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=y,n.patternId=r,!0}}function ft(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{d(i.next(t))}catch(t){o(t)}}function a(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:pt}=Math;const gt={image:function(e,n,i,s,o){let r,a;const d=t.ImageManager.get(i);return $&&i===$.paint&&tt(s,$.boxBounds)?r=$.leafPaint:(r={type:i.type,image:d},$=d.use>1?{leafPaint:r,paint:i,boxBounds:J.set(s)}:null),(o||d.loading)&&(a={image:d,attrName:n,attrValue:i}),d.ready?(et(e,n,i,d,r,s),o&&(nt(e,a),it(e,a))):d.error?o&&st(e,a,d.error):(o&&(rt(e,!0),nt(e,a)),r.loadId=d.load((()=>{rt(e,!1),e.destroyed||(et(e,n,i,d,r,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),it(e,a)),r.loadId=null}),(t=>{rt(e,!1),st(e,a,t),r.loadId=null}))),r},checkImage:function(n,i,s,o){const{scaleX:r,scaleY:a}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:d}=i,{data:l}=s;if(!l||s.patternId===r+"-"+a+"-"+d&&!e.Export.running)return!1;if(o)if(l.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=l;e*=pt(r)*d,n*=pt(a)*d,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(n,i,s,l),!0):(!s.style||s.sync||e.Export.running?ut(n,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ft(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ut(n,s,d),n.forceUpdate("surface")}))),300)),!1)},createPattern:ut,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,r,a,d;for(let l=0,c=i.length;l<c;l++)s=i[l],o=s.image,d=o&&o.url,d&&(r||(r={}),r[d]=!0,t.ImageManager.recycle(o),o.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),o.unload(i[l].loadId,!a.some((t=>t.url===d)))));return r}return null},createData:K,getPatternData:Z,fillOrFitMode:j,clipMode:V,repeatMode:Y},{toPoint:_t}=t.AroundHelper,wt={},mt={};function yt(t,n,i){if(n){let s;for(let o=0,r=n.length;o<r;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(r-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:vt,getDistance:xt}=t.PointHelper,{get:bt,rotateOfOuter:Et,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Rt}=t.AroundHelper,Lt={},kt={};function Pt(t,e,n,i,s){let o;const{width:r,height:a}=t;if(r!==a||i){const t=vt(e,n);o=bt(),s?(Bt(o,e,r/a*(i||1),1),Et(o,e,t+90)):(Bt(o,e,1,r/a*(i||1)),Et(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Ct}=t.AroundHelper,At={},Ot={};const Wt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:r,opacity:a}=e;_t(i||"top",n,wt),_t(s||"bottom",n,mt);const d=t.Platform.canvas.createLinearGradient(wt.x,wt.y,mt.x,mt.y);yt(d,e.stops,a);const l={type:o,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:r,blendMode:a,stretch:d}=e;Rt(i||"center",n,Lt),Rt(s||"bottom",n,kt);const l=t.Platform.canvas.createRadialGradient(Lt.x,Lt.y,0,Lt.x,Lt.y,xt(Lt,kt));yt(l,e.stops,r);const c={type:o,style:l},h=Pt(n,Lt,kt,d,!0);return h&&(c.transform=h),a&&(c.blendMode=a),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:r,blendMode:a,stretch:d}=e;Ct(i||"center",n,At),Ct(s||"bottom",n,Ot);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,St(At,Ot));yt(l,e.stops,r);const c={type:o,style:l},h=Pt(n,At,Ot,d||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),a&&(c.blendMode=a),c},getTransform:Pt},{copy:Mt,toOffsetOutBounds:It}=t.BoundsHelper,Tt={},Dt={};function zt(e,n,i,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Mt(Tt,e.bounds),Tt.x+=n.x-r.x,Tt.y+=n.y-r.y,i){const{matrix:t}=s;Tt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Tt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(s.canvas,e.bounds,Tt)}else i&&(Mt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(s.canvas,r,i?Tt:n)}const{toOffsetOutBounds:Ft}=t.BoundsHelper,Ht={};const Gt={shadow:function(t,n,i){let s,o;const{__nowWorld:r,__layout:a}=t,{shadow:d}=t.__,{worldCanvas:l,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;It(c,Dt),d.forEach(((d,_)=>{p.setWorldShadow(Dt.offsetX+d.x*u,Dt.offsetY+d.y*f,d.blur*u,e.ColorConvert.string(d.color)),o=d.spread?1+2*d.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,zt(p,Dt,o,i),s=c,d.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,c,r,"copy"),s=r),l?p.copyWorld(l,r,r,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,r,d.blendMode):n.copyWorldToInner(p,s,a.renderBounds,d.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,n,i){let s,o;const{__nowWorld:r,__layout:a}=t,{innerShadow:d}=t.__,{worldCanvas:l,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;Ft(c,Ht),d.forEach(((d,_)=>{p.save(),p.setWorldShadow(Ht.offsetX+d.x*u,Ht.offsetY+d.y*f,d.blur*u),o=d.spread?1-2*d.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,zt(p,Ht,o,i),p.restore(),l?(p.copyWorld(p,c,r,"copy"),p.copyWorld(l,r,r,"source-out"),s=r):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(d.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,r,d.blendMode):n.copyWorldToInner(p,s,a.renderBounds,d.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:jt}=t.LeafBoundsHelper;function Vt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Nt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Nt(t,n,i,o);break;case"path":n.restore()}}function Yt(t){return t.getSameCanvas(!1,!0)}function Nt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,r,a;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],a=n.__.mask,a&&(r&&(Vt(this,r,t,s,i,o),i=s=null),"path"===a||"clipping-path"===a?(n.opacity<1?(r="opacity-path",o=n.opacity,s||(s=Yt(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",i||(i=Yt(t)),s||(s=Yt(t)),n.__render(i,e)),"clipping"!==a&&"clipping-path"!==a)||jt(n,e)||n.__render(s||t,e);Vt(this,r,t,s,i,o)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qt=Ut+"_#~&*+\\=|≮≯≈≠=…",Xt=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 Qt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Kt=Qt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Zt=Qt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$t=Qt(Ut),Jt=Qt(qt),te=Qt("- —/~|┆·");var ee;!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"}(ee||(ee={}));const{Letter:ne,Single:ie,Before:se,After:oe,Symbol:re,Break:ae}=ee;function de(t){return Kt[t]?ne:te[t]?ae:Zt[t]?se:$t[t]?oe:Jt[t]?re:Xt.test(t)?ie:ne}const le={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function ce(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:he}=le,{Letter:ue,Single:fe,Before:pe,After:ge,Symbol:_e,Break:we}=ee;let me,ye,ve,xe,be,Ee,Be,Re,Le,ke,Pe,Se,Ce,Ae,Oe,We,Me,Ie=[];function Te(t,e){Le&&!Re&&(Re=Le),me.data.push({char:t,width:e}),ve+=e}function De(){xe+=ve,me.width=ve,ye.words.push(me),me={data:[]},ve=0}function ze(){Ae&&(Oe.paraNumber++,ye.paraStart=!0,Ae=!1),Le&&(ye.startCharSize=Re,ye.endCharSize=Le,Re=0),ye.width=xe,We.width?he(ye):Me&&Fe(),Ie.push(ye),ye={words:[]},xe=0}function Fe(){xe>(Oe.maxWidth||0)&&(Oe.maxWidth=xe)}const{top:He,right:Ge,bottom:je,left:Ve}=t.Direction4;function Ye(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Ne={getDrawData:function(n,i){"string"!=typeof n&&(n=String(n));let s=0,o=0,r=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:d,__font:l,__padding:c}=i;c&&(r?(s=c[Ve],r-=c[Ge]+c[Ve]):i.autoSizeAlign||(s=c[Ve]),a?(o=c[He],a-=c[He]+c[je]):i.autoSizeAlign||(o=c[He]));const h={bounds:{x:s,y:o,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Oe=e,Ie=e.rows,We=e.bounds,Me=!We.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=i,{canvas:a}=t.Platform,{width:d,height:l}=We;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,Pe=null,Re=Be=Le=ve=xe=0,me={data:[]},ye={words:[]};for(let i=0,l=n.length;i<l;i++)Ee=n[i],"\n"===Ee?(ve&&De(),ye.paraEnd=!0,ze(),Ae=!0):(ke=de(Ee),ke===ue&&"none"!==r&&(Ee=ce(Ee,r,!ve)),Be=a.measureText(Ee).width,s&&(s<0&&(Le=Be),Be+=s),Se=ke===fe&&(Pe===fe||Pe===ue)||Pe===fe&&ke!==ge,Ce=!(ke!==pe&&ke!==fe||Pe!==_e&&Pe!==ge),be=Ae&&o?d-o:d,t&&d&&xe+ve+Be>be&&(e?(ve&&De(),xe&&ze()):(Ce||(Ce=ke===ue&&Pe==ge),Se||Ce||ke===we||ke===pe||ke===fe||ve+Be>be?(ve&&De(),xe&&ze()):xe&&ze()))," "===Ee&&!0!==Ae&&xe+ve===0||(ke===we?(" "===Ee&&ve&&De(),Te(Ee,Be),De()):Se||Ce?(ve&&De(),Te(Ee,Be)):Te(Ee,Be)),Pe=ke);ve&&De(),xe&&ze(),Ie.length>0&&(Ie[Ie.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Oe.paraNumber++,xe=a.measureText(t).width,Ie.push({x:o||0,text:t,width:xe,paraStart:!0}),Me&&Fe()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ye(e,"x",t[Ve]);break;case"right":Ye(e,"x",-t[Ge])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ye(e,"y",t[He]);break;case"bottom":Ye(e,"y",-t[je])}}(c,h,i,r,a),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=o*s+(h?h*(t.paraNumber-1):0),m=r;if(d&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=n[r],y.x=f,y.width<g||y.width>g&&!d)switch(l){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=o,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,a<0&&(y.width<0?(x=-y.width+e.fontSize+a,v-=x,x+=e.fontSize):x-=a),v<i.x&&(i.x=v),x>i.width&&(i.width=x),d&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let a,d,l,c,h,u;i.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-l)/(u-1):0,c=r||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(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,n)=>{1===c?(h={char:"",x:a},a=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,a,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):a=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||n===u-1||(a+=d,t.width+=d)}))),t.words=null)}))}(h,i,r),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=n;if(o.splice(r),a&&"show"!==a){let e,d;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.Platform.canvas.measureText(a).width:0,c=i+s-l;("none"===n.textWrap?o:[o[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],d=e.x+e.width,!(i===n&&d<c));i--){if(d<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,r),"none"!==d&&function(t,n){let i;const{fontSize:s,textDecoration:o}=n;switch(t.decorationHeight=s/11,"object"==typeof o?(i=o.type,o.color&&(t.decorationColor=e.ColorConvert.string(o.color))):i=o,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 Ue={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(e.TextConvert,Ne),Object.assign(e.ColorConvert,Ue),Object.assign(e.Paint,M),Object.assign(e.PaintImage,gt),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,Gt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Watcher=d,exports.useCanvas=r,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
2
2
  //# sourceMappingURL=web.min.cjs.map