leafer-draw 1.3.3 → 1.4.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.cjs +18 -12
- package/dist/web.cjs.map +1 -0
- package/dist/web.esm.js +18 -12
- package/dist/web.esm.js.map +1 -0
- package/dist/web.esm.min.js +2 -1
- package/dist/web.esm.min.js.map +1 -0
- package/dist/web.js +73 -65
- package/dist/web.js.map +1 -0
- package/dist/web.min.cjs +2 -1
- package/dist/web.min.cjs.map +1 -0
- package/dist/web.min.js +2 -1
- package/dist/web.min.js.map +1 -0
- package/dist/web.module.js +73 -65
- package/dist/web.module.js.map +1 -0
- package/dist/web.module.min.js +2 -1
- package/dist/web.module.min.js.map +1 -0
- package/package.json +7 -7
package/dist/web.min.cjs
CHANGED
|
@@ -1 +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",(()=>{const e=t.Platform.devicePixelRatio;if(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: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.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),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.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)=>t.toDataURL(s(e),n),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:()=>Math.max(1,devicePixelRatio)});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(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:h,updateAllWorldOpacity:c}=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||h(i[t])}h(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(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 B(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[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)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}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?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",B(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;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[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)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}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: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: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?B(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?B(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?B(n,i):o?i.fill(o):i.fill())},fillText:B,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(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)E(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:E,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,c=O(i?S(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),r=C(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:h}}};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 h=D();if(d)if("center"===l)z(h,{x:n/2,y:i/2},d);else switch(G(h,d),d){case 90:H(h,i,0);break;case 180:H(h,n,i);break;case 270:H(h,0,n)}T.x=e.x+s,T.y=e.y+o,H(h,T.x,T.y),a&&F(h,T,a,r),t.transform=h}const{get:N,translate:q}=t.MatrixHelper,X=new t.Bounds,Q={},Z={};function $(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=K(n,i,e)}function K(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:h,size:c,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==d&&(u||0)%180==90,w=_?o:s,m=_?s:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,Z),y=Z.scaleX,v=Z.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*y)/2,b+=(n.height-o*v)/2}if(d){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(d,e,n,Q,!0),x+=Q.x,b+=Q.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&Y(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&U(g,n,s,o,x,b,y,v,u,d),f||(g.repeat="repeat");break;default:y&&j(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=N(),q(g.transform,n.x,n.y)),y&&"stretch"!==r&&(g.scaleX=y,g.scaleY=v),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}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||$(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:ht}=t.MatrixHelper,{ceil:ct,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:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=dt(),ht(l,g),lt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,h*=s,c*=o;const w=h*c;if(!_&&w>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)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,h/=d,c/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=dt(),g&&ht(l,g)),lt(l,1/s,1/o));const y=e.getCanvas(ct(h)||1,ct(c)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,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.view,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)))));return o}return null},createData:$,getPatternData:K,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:Bt,rotateOfOuter:Et,scaleOfOuter:Rt}=t.MatrixHelper,{toPoint:Lt}=t.AroundHelper,kt={},Pt={};function St(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=xt(e,n);o=Bt(),s?(Rt(o,e,a/r*(i||1),1),Et(o,e,t+90)):(Rt(o,e,1,a/r*(i||1)),Et(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: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 h={type:o,style:l},c=St(n,kt,Pt,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},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,Ct(Ot,Wt));vt(l,e.stops,a);const h={type:o,style:l},c=St(n,Ot,Wt,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:St},{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:h,shapeBounds:c,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;Tt(h,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=h,d.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,h,a,"copy"),s=a),l?p.copyWorld(l,a,a,"destination-out"):p.copyWorld(i.canvas,c,h,"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:h,shapeBounds:c,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;Ft(h,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,h,a,"copy"),p.copyWorld(l,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,c,h,"source-out"),s=h),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,h=d.length;l<h;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 Zt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Zt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Kt=Zt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Zt(qt),te=Zt(Xt),ee=Zt("- —/~|┆·");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 $t[t]?ie:ee[t]?de:Kt[t]?oe:Jt[t]?ae:te[t]?re:Qt.test(t)?se:ie}const he={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:ue}=he,{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:we,Break:me}=ne;let ye,ve,xe,be,Be,Ee,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 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(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[Ye],o-=l[Ge]+l[Ye]):n.autoSizeAlign||(i=l[Ye]),a?(s=l[Ve],a-=l[Ve]+l[je]):n.autoSizeAlign||(s=l[Ve]));const h={bounds:{x:i,y:s,width:o,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: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,Se=null,Le=Re=ke=xe=be=0,ye={data:[]},ve={words:[]};for(let i=0,l=n.length;i<l;i++)Ee=n[i],"\n"===Ee?(xe&&ze(),ve.paraEnd=!0,He(),Oe=!0):(Pe=le(Ee),Pe===fe&&"none"!==a&&(Ee=ce(Ee,a,!xe)),Re=r.measureText(Ee).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),Be=Oe&&o?d-o:d,t&&d&&be+xe+Re>Be&&(e?(xe&&ze(),be&&He()):(Ae||(Ae=Pe===fe&&Se==_e),Ce||Ae||Pe===me||Pe===ge||Pe===pe||xe+Re>Be?(xe&&ze(),be&&He()):be&&He()))," "===Ee&&!0!==Oe&&be+xe===0||(Pe===me?(" "===Ee&&xe&&ze(),De(Ee,Re),ze()):Ce||Ae?(xe&&ze(),De(Ee,Re)):De(Ee,Re)),Se=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,e,n),l&&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])}}(l,h,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(h?h*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||c)switch(l){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||c?p:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(d){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&h&&o>0&&(w+=h),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,h,c;i.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,d=n&&("justify"===s||"both"===s)&&t.words.length>1?(n-t.width-l)/(t.words.length-1):0,h=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach((e=>{1===h?(c={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):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||(r+=d,t.width+=d)}))),t.words=null)}))}(h,n,o),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,h=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<h));i--){if(d<h&&" "!==e.char){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,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),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.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: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("Safari")>-1&&-1===r.indexOf("Chrome")&&(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:h,updateAllWorldOpacity:c}=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||h(i[t])}h(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(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;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[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)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}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;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[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)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}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: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: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:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,c=O(i?S(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),r=C(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:h}}};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 h=D();if(d)if("center"===l)z(h,{x:n/2,y:i/2},d);else switch(G(h,d),d){case 90:H(h,i,0);break;case 180:H(h,n,i);break;case 270:H(h,0,n)}T.x=e.x+s,T.y=e.y+o,H(h,T.x,T.y),a&&F(h,T,a,r),t.transform=h}const{get:N,translate:q}=t.MatrixHelper,X=new t.Bounds,Q={},Z={};function $(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=K(n,i,e)}function K(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:h,size:c,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==d&&(u||0)%180==90,w=_?o:s,m=_?s:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,Z),y=Z.scaleX,v=Z.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*y)/2,b+=(n.height-o*v)/2}if(d){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(d,e,n,Q,!0),x+=Q.x,b+=Q.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&Y(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&U(g,n,s,o,x,b,y,v,u,d),f||(g.repeat="repeat");break;default:y&&j(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=N(),q(g.transform,n.x,n.y)),y&&"stretch"!==r&&(g.scaleX=y,g.scaleY=v),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}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||$(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:ht}=t.MatrixHelper,{ceil:ct,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:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=dt(),ht(l,g),lt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,h*=s,c*=o;const w=h*c;if(!_&&w>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)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,h/=d,c/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=dt(),g&&ht(l,g)),lt(l,1/s,1/o));const y=e.getCanvas(ct(h)||1,ct(c)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,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.view,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)))));return o}return null},createData:$,getPatternData:K,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 St(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:Ct}=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 h={type:o,style:l},c=St(n,kt,Pt,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},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,Ct(Ot,Wt));vt(l,e.stops,a);const h={type:o,style:l},c=St(n,Ot,Wt,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:St},{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:h,shapeBounds:c,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;Tt(h,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=h,d.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,h,a,"copy"),s=a),l?p.copyWorld(l,a,a,"destination-out"):p.copyWorld(i.canvas,c,h,"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:h,shapeBounds:c,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;Ft(h,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,h,a,"copy"),p.copyWorld(l,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,c,h,"source-out"),s=h),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,h=d.length;l<h;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 Zt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Zt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Kt=Zt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Zt(qt),te=Zt(Xt),ee=Zt("- —/~|┆·");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 $t[t]?ie:ee[t]?de:Kt[t]?oe:Jt[t]?ae:te[t]?re:Qt.test(t)?se:ie}const he={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:ue}=he,{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 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(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[Ye],o-=l[Ge]+l[Ye]):n.autoSizeAlign||(i=l[Ye]),a?(s=l[Ve],a-=l[Ve]+l[je]):n.autoSizeAlign||(s=l[Ve]));const h={bounds:{x:i,y:s,width:o,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: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,Se=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=ce(Be,a,!xe)),Re=r.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?d-o:d,t&&d&&be+xe+Re>Ee&&(e?(xe&&ze(),be&&He()):(Ae||(Ae=Pe===fe&&Se==_e),Ce||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()):Ce||Ae?(xe&&ze(),De(Be,Re)):De(Be,Re)),Se=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,e,n),l&&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])}}(l,h,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(h?h*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||c)switch(l){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||c?p:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(d){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&h&&o>0&&(w+=h),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,h,c,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,h=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===h?(c={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):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,n,o),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,h=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<h));i--){if(d<h&&" "!==e.char){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,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),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]}})}));
|
|
2
|
+
//# sourceMappingURL=web.min.cjs.map
|