leafer-draw 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.
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: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 l{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:d,updateBounds:c,updateChange: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,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,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?(d(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){t.list.forEach(h)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,l,this.times)),i.emitEvent(new t.LayoutEvent(a,l,this.times)),this.addBlocks(l),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(){if(this.running){const{target:e}=this;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.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,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),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:i}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),this.target.__render(i,o),this.renderBounds=n=n||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}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(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,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){const n=t.__,{rows:i,decorationY:s}=n.__textDrawData;let o;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)o=i[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}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>s.forEach((n=>e.fillRect(t.x,t.y+n,t.width,o)))))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}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:r}=i.__,a=s.getSameCanvas(!0,!0);a.setStroke(n?void 0:e,2*o,i.__),a.font=r,n?k(e,!0,i,a):L(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 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 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?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())}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(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:S,getOuterOf:C,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:r,color:a,opacity:l}=n;return{type:o,blendMode:r,style:e.ColorConvert.string(a,l)};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,r=i.__input[t];r instanceof Array||(r=[r]),W=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=r.length;i<o;i++)e=M(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(e,n)},fills:function(t,n,i){let s;for(let o=0,r=t.length;o<r;o++){if(s=t[o],s.image){if(e.PaintImage.checkImage(n,i,s,!n.__.__font))continue;if(!s.style){!o&&s.image.isPlacehold&&n.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),E(n,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),E(n,i),i.restoreBlendMode()):E(n,i)}},fillPathOrText:E,fillText:b,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=i;if(s)if(r)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:r}=i;if(s)if(r)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,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),k(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:B,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=a=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);r=e.bounds.getFitMatrix(h);let{a:u,d:f}=r;if(r.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),a=C(s,r),o=A(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:l,shapeBounds:a,scaleX:d,scaleY:c}}};let T={};const{get:D,rotateOfOuter:z,translate:F,scaleOfOuter:H,scale:G,rotate:j}=t.MatrixHelper;function V(t,e,n,i,s,o,r){const a=D();F(a,e.x+n,e.y+i),G(a,s,o),r&&z(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Y(t,e,n,i,s,o,r){const a=D();F(a,e.x+n,e.y+i),s&&G(a,s,o),r&&j(a,r),t.transform=a}function U(t,e,n,i,s,o,r,a,l,d){const c=D();if(l)if("center"===d)z(c,{x:n/2,y:i/2},l);else switch(j(c,l),l){case 90:F(c,i,0);break;case 180:F(c,n,i);break;case 270:F(c,0,n)}T.x=e.x+s,T.y=e.y+o,F(c,T.x,T.y),r&&H(c,T,r,a),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,changeful:o,sync:r}=n;s&&(t.blendMode=s),o&&(t.changeful=o),r&&(t.sync=r),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:r,mode:a,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===o,_={mode:a},w="center"!==l&&(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,K),v=K.scaleX,x=K.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(l){const e={x:b,y:E,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(l,e,n,Q,!0),b+=Q.x,E+=Q.y}switch(d&&(b+=d.x,E+=d.y),a){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,l),f||(_.repeat="repeat");break;default:v&&V(_,n,b,E,v,x,u)}return _.transform||(n.x||n.y)&&(_.transform=N(),q(_.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,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){rt(e,t.ImageEvent.LOAD,n)}function st(e,n){rt(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),rt(e,t.ImageEvent.ERROR,n)}function rt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function at(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:lt,scale:dt,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 r=s+"-"+o+"-"+i;if(n.patternId===r||e.destroyed)return!1;{s=ut(s),o=ut(o);const{image:e,data:a}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=a;u&&(d=lt(),ct(d,p),dt(d,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&&(l=Math.sqrt(_/w)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(d||(d=lt(),p&&ct(d,p)),dt(d,1/s,1/o));const m=e.getCanvas(ht(c)||1,ht(h)||1,a.opacity,a.filters),y=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=r,!0}}function pt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:gt}=Math;const _t={image:function(e,n,i,s,o){let r,a;const l=t.ImageManager.get(i);return J&&i===J.paint&&et(s,J.boxBounds)?r=J.leafPaint:(r={type:i.type,image:l},J=l.use>1?{leafPaint:r,paint:i,boxBounds:tt.set(s)}:null),(o||l.loading)&&(a={image:l,attrName:n,attrValue:i}),l.ready?(nt(e,n,i,l,r,s),o&&(it(e,a),st(e,a))):l.error?o&&ot(e,a,l.error):(o&&(at(e,!0),it(e,a)),r.loadId=l.load((()=>{at(e,!1),e.destroyed||(nt(e,n,i,l,r,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),st(e,a)),r.loadId=null}),(t=>{at(e,!1),ot(e,a,t),r.loadId=null})),e.placeholderColor&&setTimeout((()=>{l.ready||l.isPlacehold||(l.isPlacehold=!0,e.forceUpdate("surface"))}),100)),r},checkImage:function(n,i,s,o){const{scaleX:r,scaleY:a}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i,{data:d}=s;if(!d||s.patternId===r+"-"+a+"-"+l&&!e.Export.running)return!1;if(o)if(d.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=gt(r)*l,n*=gt(a)*l,d.scaleX&&(e*=d.scaleX,n*=d.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,d),!0):(!s.style||s.sync||e.Export.running?ft(n,s,l):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,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:ft,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,r,a,l;for(let d=0,c=i.length;d<c;d++)s=i[d],o=s.image,l=o&&o.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(o),o.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),o.unload(i[d].loadId,!a.some((t=>t.url===l)))));return r}return null},createData:Z,getPatternData:$,fillOrFitMode:V,clipMode:Y,repeatMode:U},{toPoint:wt}=t.AroundHelper,mt={},yt={};function vt(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:xt,getDistance:bt}=t.PointHelper,{get:Et,rotateOfOuter:Bt,scaleOfOuter:Rt}=t.MatrixHelper,{toPoint:Lt}=t.AroundHelper,kt={},Pt={};function St(t,e,n,i,s){let o;const{width:r,height:a}=t;if(r!==a||i){const t=xt(e,n);o=Et(),s?(Rt(o,e,r/a*(i||1),1),Bt(o,e,t+90)):(Rt(o,e,1,r/a*(i||1)),Bt(o,e,t))}return o}const{getDistance:Ct}=t.PointHelper,{toPoint:At}=t.AroundHelper,Ot={},Wt={};const Mt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:r,opacity:a}=e;wt(i||"top",n,mt),wt(s||"bottom",n,yt);const l=t.Platform.canvas.createLinearGradient(mt.x,mt.y,yt.x,yt.y);vt(l,e.stops,a);const d={type:o,style:l};return r&&(d.blendMode=r),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:r,blendMode:a,stretch:l}=e;Lt(i||"center",n,kt),Lt(s||"bottom",n,Pt);const d=t.Platform.canvas.createRadialGradient(kt.x,kt.y,0,kt.x,kt.y,bt(kt,Pt));vt(d,e.stops,r);const c={type:o,style:d},h=St(n,kt,Pt,l,!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:l}=e;At(i||"center",n,Ot),At(s||"bottom",n,Wt);const d=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,Ct(Ot,Wt));vt(d,e.stops,r);const c={type:o,style:d},h=St(n,Ot,Wt,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),a&&(c.blendMode=a),c},getTransform:St},{copy:It,toOffsetOutBounds:Tt}=t.BoundsHelper,Dt={},zt={};function Ft(e,n,i,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(It(Dt,e.bounds),Dt.x+=n.x-r.x,Dt.y+=n.y-r.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,r,i?Dt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Gt={};const jt={shadow:function(t,n,i){let s,o;const{__nowWorld:r,__layout:a}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Tt(c,zt),l.forEach(((l,_)=>{p.setWorldShadow(zt.offsetX+l.x*u,zt.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ft(p,zt,o,i),s=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,r,"copy"),s=r),d?p.copyWorld(d,r,r,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,r,l.blendMode):n.copyWorldToInner(p,s,a.renderBounds,l.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:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Ht(c,Gt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Gt.offsetX+l.x*u,Gt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ft(p,Gt,o,i),p.restore(),d?(p.copyWorld(p,c,r,"copy"),p.copyWorld(d,r,r,"source-out"),s=r):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,r,l.blendMode):n.copyWorldToInner(p,s,a.renderBounds,l.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:Vt}=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,r,a;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],a=n.__.mask,a&&(r&&(Yt(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=Ut(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",i||(i=Ut(t)),s||(s=Ut(t)),n.__render(i,e)),"clipping"!==a&&"clipping-path"!==a)||Vt(n,e)||n.__render(s||t,e);Yt(this,r,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:re,Symbol:ae,Break:le}=ne;function de(t){return Zt[t]?ie:ee[t]?le:$t[t]?oe:Jt[t]?re:te[t]?ae: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,Se,Ce,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 Fe(){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&&He(),Te.push(ve),ve={words:[]},be=0}function He(){be>(We.maxWidth||0)&&(We.maxWidth=be)}const{top:Ge,right:je,bottom:Ve,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,r=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=i;c&&(r?(s=c[Ye],r-=c[je]+c[Ye]):i.autoSizeAlign||(s=c[Ye]),a?(o=c[Ge],a-=c[Ge]+c[Ve]):i.autoSizeAlign||(o=c[Ge]));const h={bounds:{x:s,y:o,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){We=e,Te=e.rows,Me=e.bounds,Ie=!Me.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=i,{canvas:a}=t.Platform,{width:l,height:d}=Me;if(l||d||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Se=null,Le=Re=ke=xe=be=0,ye={data:[]},ve={words:[]};for(let i=0,d=n.length;i<d;i++)Be=n[i],"\n"===Be?(xe&&ze(),ve.paraEnd=!0,Fe(),Oe=!0):(Pe=de(Be),Pe===fe&&"none"!==r&&(Be=he(Be,r,!xe)),Re=a.measureText(Be).width,s&&(s<0&&(ke=Re),Re+=s),Ce=Pe===pe&&(Se===pe||Se===fe)||Se===pe&&Pe!==_e,Ae=!(Pe!==ge&&Pe!==pe||Se!==we&&Se!==_e),Ee=Oe&&o?l-o:l,t&&l&&be+xe+Re>Ee&&(e?(xe&&ze(),be&&Fe()):(Ae||(Ae=Pe===fe&&Se==_e),Ce||Ae||Pe===me||Pe===ge||Pe===pe||xe+Re>Ee?(xe&&ze(),be&&Fe()):be&&Fe()))," "===Be&&!0!==Oe&&be+xe===0||(Pe===me?(" "===Be&&xe&&ze(),De(Be,Re),ze()):Ce||Ae?(xe&&ze(),De(Be,Re)):De(Be,Re)),Se=Pe);xe&&ze(),be&&Fe(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,be=a.measureText(t).width,Te.push({x:o||0,text:t,width:be,paraStart:!0}),Ie&&He()}))}(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[je])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ue(e,"y",t[Ge]);break;case"bottom":Ue(e,"y",-t[Ve])}}(c,h,i,r,a),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:l,textAlign:d,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(l&&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&&!l)switch(d){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),l&&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,l,d,c,h,u;i.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,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),!l||t.paraEnd&&"both"!==s||n===u-1||(a+=l,t.width+=l)}))),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,l;"hide"===a?a="":"ellipsis"===a&&(a="...");const d=a?t.Platform.canvas.measureText(a).width:0,c=i+s-d;("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],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:a,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,r),"none"!==l&&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,jt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Watcher=l,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]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw"),n=require("@leafer-ui/core");const i=t.Debug.get("LeaferCanvas");class s 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 i.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,n){if(this.resizeListener=n,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),i.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:o,fileType:a}=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=o(e),s=t.toDataURL(i,n);return"image/bmp"===i?s.replace("image/png;","image/bmp;"):s},canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,o(e),n))),canvasSaveAs:(e,n,i)=>{const s=e.toDataURL(o(a(n)),i);return t.Platform.origin.download(s,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 s(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:l}=navigator;l.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):l.indexOf("AppleWebKit")>-1&&(t.Platform.fullImageShadow=!0),l.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):l.indexOf("Mac")>-1?t.Platform.os="Mac":l.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=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:c,updateBounds:h,updateChange:u}=t.LeafHelper,{pushAllChildBranch:f,pushAllParent:p}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper;class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,g),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:m,updateAllChange:w}=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.layouting||!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,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,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?(c(t,!0),e.add(t),t.isBranch&&f(t,e),p(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),p(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){t.list.forEach(u)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),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){m(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[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)}checkRender(){if(this.running){const{target:e}=this;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.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,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;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(b.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,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),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:i}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),this.target.__render(i,o),this.renderBounds=n=n||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}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(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,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||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(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[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){const n=t.__,{rows:i,decorationY:s}=n.__textDrawData;let o;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)o=i[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}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>s.forEach((n=>e.fillRect(t.x,t.y+n,t.width,o)))))}}function B(t,e){t.__.__font?E(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}b.clipSpread=10,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 R={};function L(t,e,n){switch(e.__.strokeAlign){case"center":k(t,1,e,n);break;case"inside":P(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?k(t,2,e,n):P(t,"outside",e,n)}}function k(t,e,n,i){const s=n.__;i.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?C(t,!0,n,i):S(n,i)}function P(t,e,i,s){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,k(t,2,i,o),o.blendMode="outside"===e?"destination-out":"destination-in",E(i,o),o.blendMode="normal",i.__worldFlipped||n.Platform.fullImageShadow?s.copyWorldByReset(o,i.__nowWorld):s.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function S(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 C(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?S(i,s):s.stroke(),s.restoreBlendMode()):n?S(i,s):s.stroke())}function A(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)L(t,e,i);else switch(s.strokeAlign){case"center":O(t,1,e,i);break;case"inside":!function(t,e,n){const i=e.__;n.save(),i.windingRule?n.clip(i.windingRule):n.clip(),O(t,2,e,n),n.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)O(t,2,e,i);else{const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),O(t,2,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped||n.Platform.fullImageShadow?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}}(t,e,i)}}function O(t,e,n,i){const s=n.__;i.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?C(t,!1,n,i):i.stroke(),s.__useArrow&&R.strokeArrow(t,n,i)}const{getSpread:T,getOuterOf:W,getByMove:I,getIntersectData:D}=t.BoundsHelper;let M;const{stintSet:z}=t.DataHelper,{hasTransparent:H}=e.ColorConvert;function F(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;let s;const{boxBounds:o}=i.__layout;switch(n.type){case"image":s=e.PaintImage.image(i,t,n,o,!M||!M[n.url]);break;case"linear":s=e.PaintGradient.linearGradient(n,o);break;case"radial":s=e.PaintGradient.radialGradient(n,o);break;case"angular":s=e.PaintGradient.conicGradient(n,o);break;case"solid":const{type:a,blendMode:r,color:l,opacity:d}=n;s={type:a,blendMode:r,style:e.ColorConvert.string(l,d)};break;default:void 0!==n.r&&(s={type:"solid",style:e.ColorConvert.string(n)})}return s&&("string"==typeof s.style&&H(s.style)&&(s.isTransparent=!0),n.blendMode&&(s.blendMode=n.blendMode)),s}const G={compute:function(t,n){const i=n.__,s=[];let o,a,r=i.__input[t];r instanceof Array||(r=[r]),M=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=r.length;i<o;i++)e=F(t,r[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(o=!0),a=!0),"fill"===t?(z(i,"__isAlphaPixelFill",o),z(i,"__isTransparentFill",a)):(z(i,"__isAlphaPixelStroke",o),z(i,"__isTransparentStroke",a))},fill:function(t,e,n){n.fillStyle=t,B(e,n)},fills:function(t,n,i){let s;for(let o=0,a=t.length;o<a;o++){if(s=t[o],s.image){if(e.PaintImage.checkImage(n,i,s,!n.__.__font))continue;if(!s.style){!o&&s.image.isPlacehold&&n.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),B(n,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),B(n,i),i.restoreBlendMode()):B(n,i)}},fillPathOrText:B,fillText:E,stroke:A,strokes:function(t,e,n){A(t,e,n)},strokeText:L,drawTextStroke:S,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=D(i?T(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=W(s,a),o=I(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:l,shapeBounds:r,scaleX:d,scaleY:c}}};let j={};const{get:V,rotateOfOuter:Y,translate:U,scaleOfOuter:N,scale:q,rotate:X}=t.MatrixHelper;function Q(t,e,n,i,s,o,a){const r=V();U(r,e.x+n,e.y+i),q(r,s,o),a&&Y(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function K(t,e,n,i,s,o,a){const r=V();U(r,e.x+n,e.y+i),s&&q(r,s,o),a&&X(r,a),t.transform=r}function Z(t,e,n,i,s,o,a,r,l,d){const c=V();if(l)if("center"===d)Y(c,{x:n/2,y:i/2},l);else switch(X(c,l),l){case 90:U(c,i,0);break;case 180:U(c,n,i);break;case 270:U(c,0,n)}j.x=e.x+s,j.y=e.y+o,U(c,j.x,j.y),a&&N(c,j,a,r),t.transform=c}const{get:$,translate:J}=t.MatrixHelper,tt=new t.Bounds,et={},nt={};function it(t,e,n,i){const{changeful:s,sync:o}=n;s&&(t.changeful=s),o&&(t.sync=o),t.data=st(n,i,e)}function st(e,n,i){e.padding&&(n=tt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:o}=i;const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===o,_={mode:r},m="center"!==l&&(u||0)%180==90;let w,y;switch(t.BoundsHelper.set(nt,0,0,m?o:s,m?s:o),r&&"cover"!==r&&"fit"!==r?((c||h)&&(t.MathHelper.getScaleData(c,h,i,et),w=et.scaleX,y=et.scaleY),l&&(w&&t.BoundsHelper.scale(nt,w,y,!0),t.AlignHelper.toPoint(l,nt,n,nt,!0,!0))):g&&!u||(w=y=t.BoundsHelper.getFitScale(n,nt,"fit"!==r),t.BoundsHelper.put(n,i,l,w,!1,nt),t.BoundsHelper.scale(nt,w,y,!0)),d&&t.PointHelper.move(nt,d),r){case"stretch":g||(s=n.width,o=n.height);break;case"normal":case"clip":(nt.x||nt.y||w||u)&&K(_,n,nt.x,nt.y,w,y,u);break;case"repeat":(!g||w||u)&&Z(_,n,s,o,nt.x,nt.y,w,y,u,l),f||(_.repeat="repeat");break;default:w&&Q(_,n,nt.x,nt.y,w,y,u)}return _.transform||(n.x||n.y)&&(_.transform=$(),J(_.transform,n.x,n.y)),w&&"stretch"!==r&&(_.scaleX=w,_.scaleY=y),_.width=s,_.height=o,a&&(_.opacity=a),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let ot,at=new t.Bounds;const{isSame:rt}=t.BoundsHelper;function lt(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||it(s,i,n,o),!0}function dt(e,n){ut(e,t.ImageEvent.LOAD,n)}function ct(e,n){ut(e,t.ImageEvent.LOADED,n)}function ht(e,n,i){n.error=i,e.forceUpdate("surface"),ut(e,t.ImageEvent.ERROR,n)}function ut(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ft(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:pt,scale:gt,copy:_t}=t.MatrixHelper,{ceil:mt,abs:wt}=Math;function yt(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=wt(s),o=wt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=pt(),_t(d,p),gt(d,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 m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(d||(d=pt(),p&&_t(d,p)),gt(d,1/s,1/o));const w=e.getCanvas(mt(c)||1,mt(h)||1,r.opacity,r.filters),y=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function vt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:xt}=Math;const bt={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return ot&&i===ot.paint&&rt(s,ot.boxBounds)?a=ot.leafPaint:(a={type:i.type,image:l},l.hasAlphaPixel&&(a.isTransparent=!0),ot=l.use>1?{leafPaint:a,paint:i,boxBounds:at.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(lt(e,n,i,l,a,s),o&&(dt(e,r),ct(e,r))):l.error?o&&ht(e,r,l.error):(o&&(ft(e,!0),dt(e,r)),a.loadId=l.load((()=>{ft(e,!1),e.destroyed||(lt(e,n,i,l,a,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ct(e,r)),a.loadId=null}),(t=>{ft(e,!1),ht(e,r,t),a.loadId=null})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i,{data:d}=s;if(!d||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;if(o)if(d.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=xt(a)*l,n*=xt(r)*l,d.scaleX&&(e*=d.scaleX,n*=d.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,d),!0):(!s.style||s.sync||e.Export.running?yt(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>vt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&yt(n,s,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:yt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r,l;for(let d=0,c=i.length;d<c;d++)s=i[d],o=s.image,l=o&&o.url,l&&(a||(a={}),a[l]=!0,t.ImageManager.recycle(o),o.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),o.unload(i[d].loadId,!r.some((t=>t.url===l)))));return a}return null},createData:it,getPatternData:st,fillOrFitMode:Q,clipMode:K,repeatMode:Z},{toPoint:Et}=t.AroundHelper,{hasTransparent:Bt}=e.ColorConvert,Rt={},Lt={};function kt(t,n,i,s){if(i){let o,a,r,l;for(let t=0,d=i.length;t<d;t++)o=i[t],"string"==typeof o?(r=t/(d-1),a=e.ColorConvert.string(o,s)):(r=o.offset,a=e.ColorConvert.string(o.color,s)),n.addColorStop(r,a),!l&&Bt(a)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Pt,getDistance:St}=t.PointHelper,{get:Ct,rotateOfOuter:At,scaleOfOuter:Ot}=t.MatrixHelper,{toPoint:Tt}=t.AroundHelper,Wt={},It={};function Dt(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=Pt(e,n);o=Ct(),s?(Ot(o,e,a/r*(i||1),1),At(o,e,t+90)):(Ot(o,e,1,a/r*(i||1)),At(o,e,t))}return o}const{getDistance:Mt}=t.PointHelper,{toPoint:zt}=t.AroundHelper,Ht={},Ft={};const Gt={linearGradient:function(e,n){let{from:i,to:s,type:o,opacity:a}=e;Et(i||"top",n,Rt),Et(s||"bottom",n,Lt);const r=t.Platform.canvas.createLinearGradient(Rt.x,Rt.y,Lt.x,Lt.y),l={type:o,style:r};return kt(l,r,e.stops,a),l},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,stretch:r}=e;Tt(i||"center",n,Wt),Tt(s||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Wt.x,Wt.y,0,Wt.x,Wt.y,St(Wt,It)),d={type:o,style:l};kt(d,l,e.stops,a);const c=Dt(n,Wt,It,r,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,stretch:r}=e;zt(i||"center",n,Ht),zt(s||"bottom",n,Ft);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ht.x,Ht.y):t.Platform.canvas.createRadialGradient(Ht.x,Ht.y,0,Ht.x,Ht.y,Mt(Ht,Ft)),d={type:o,style:l};kt(d,l,e.stops,a);const c=Dt(n,Ht,Ft,r||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Dt},{copy:jt,toOffsetOutBounds:Vt}=t.BoundsHelper,Yt={},Ut={};function Nt(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(jt(Yt,e.bounds),Yt.x+=n.x-a.x,Yt.y+=n.y-a.y,i){const{matrix:t}=s;Yt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Yt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Yt.width*=i,Yt.height*=i}e.copyWorld(s.canvas,e.bounds,Yt)}else i&&(jt(Yt,n),Yt.x-=n.width/2*(i-1),Yt.y-=n.height/2*(i-1),Yt.width*=i,Yt.height*=i),e.copyWorld(s.canvas,a,i?Yt:n)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Xt={};const Qt={shadow:function(t,n,i){let s,o;const{__nowWorld:a,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Vt(c,Ut),l.forEach(((l,_)=>{p.setWorldShadow(Ut.offsetX+l.x*u,Ut.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Nt(p,Ut,o,i),s=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,a,"copy"),s=a),d?p.copyWorld(d,a,a,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,a,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.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:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;qt(c,Xt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Xt.offsetX+l.x*u,Xt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Nt(p,Xt,o,i),p.restore(),d?(p.copyWorld(p,c,a,"copy"),p.copyWorld(d,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,a,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.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:Kt}=t.LeafBoundsHelper;function Zt(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),Jt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Jt(t,n,i,o);break;case"path":n.restore()}}function $t(t){return t.getSameCanvas(!1,!0)}function Jt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(a&&(Zt(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=$t(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=$t(t)),s||(s=$t(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Kt(n,e)||n.__render(s||t,e);Zt(this,a,t,s,i,o)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oe=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ae=ie(te),re=ie(ee),le=ie("- —/~|┆·");var de;!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"}(de||(de={}));const{Letter:ce,Single:he,Before:ue,After:fe,Symbol:pe,Break:ge}=de;function _e(t){return se[t]?ce:le[t]?ge:oe[t]?ue:ae[t]?fe:re[t]?pe:ne.test(t)?he:ce}const me={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 we(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ye}=me,{Letter:ve,Single:xe,Before:be,After:Ee,Symbol:Be,Break:Re}=de;let Le,ke,Pe,Se,Ce,Ae,Oe,Te,We,Ie,De,Me,ze,He,Fe,Ge,je,Ve=[];function Ye(t,e){We&&!Te&&(Te=We),Le.data.push({char:t,width:e}),Pe+=e}function Ue(){Se+=Pe,Le.width=Pe,ke.words.push(Le),Le={data:[]},Pe=0}function Ne(){He&&(Fe.paraNumber++,ke.paraStart=!0,He=!1),We&&(ke.startCharSize=Te,ke.endCharSize=We,Te=0),ke.width=Se,Ge.width?ye(ke):je&&qe(),Ve.push(ke),ke={words:[]},Se=0}function qe(){Se>(Fe.maxWidth||0)&&(Fe.maxWidth=Se)}const{top:Xe,right:Qe,bottom:Ke,left:Ze}=t.Direction4;function $e(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 Je={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:l,__font:d,__padding:c}=i;c&&(a?(s=c[Ze],a-=c[Qe]+c[Ze]):i.autoSizeAlign||(s=c[Ze]),r?(o=c[Xe],r-=c[Xe]+c[Ke]):i.autoSizeAlign||(o=c[Xe]));const h={bounds:{x:s,y:o,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Fe=e,Ve=e.rows,Ge=e.bounds,je=!Ge.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ge;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;He=!0,De=null,Te=Oe=We=Pe=Se=0,Le={data:[]},ke={words:[]},s&&(n=[...n]);for(let i=0,d=n.length;i<d;i++)Ae=n[i],"\n"===Ae?(Pe&&Ue(),ke.paraEnd=!0,Ne(),He=!0):(Ie=_e(Ae),Ie===ve&&"none"!==a&&(Ae=we(Ae,a,!Pe)),Oe=r.measureText(Ae).width,s&&(s<0&&(We=Oe),Oe+=s),Me=Ie===xe&&(De===xe||De===ve)||De===xe&&Ie!==Ee,ze=!(Ie!==be&&Ie!==xe||De!==Be&&De!==Ee),Ce=He&&o?l-o:l,t&&l&&Se+Pe+Oe>Ce&&(e?(Pe&&Ue(),Se&&Ne()):(ze||(ze=Ie===ve&&De==Ee),Me||ze||Ie===Re||Ie===be||Ie===xe||Pe+Oe>Ce?(Pe&&Ue(),Se&&Ne()):Se&&Ne()))," "===Ae&&!0!==He&&Se+Pe===0||(Ie===Re?(" "===Ae&&Pe&&Ue(),Ye(Ae,Oe),Ue()):Me||ze?(Pe&&Ue(),Ye(Ae,Oe)):Ye(Ae,Oe)),De=Ie);Pe&&Ue(),Se&&Ne(),Ve.length>0&&(Ve[Ve.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Fe.paraNumber++,Se=r.measureText(t).width,Ve.push({x:o||0,text:t,width:Se,paraStart:!0}),je&&qe()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":$e(e,"x",t[Ze]);break;case"right":$e(e,"x",-t[Qe])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":$e(e,"y",t[Xe]);break;case"bottom":$e(e,"y",-t[Ke])}}(c,h,i,a,r),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,m=o*s+(h?h*(t.paraNumber-1):0),w=a;if(l&&m>_)m=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=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&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=o,t.overflow>a&&w>m&&(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),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=m}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,l,d,c,h,u;i.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-d)/(u-1):0,c=a||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,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),!l||t.paraEnd&&"both"!==s||n===u-1||(r+=l,t.width+=l)}))),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,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("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],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,a),"none"!==l&&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 tn={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,Je),Object.assign(e.ColorConvert,tn),Object.assign(e.Paint,G),Object.assign(e.PaintImage,bt),Object.assign(e.PaintGradient,Gt),Object.assign(e.Effect,Qt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=s,exports.Renderer=b,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