leafer-ui 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");const n=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:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.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:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}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:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}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:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const i=this.view,{x:n,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}=i;t.marginLeft=n+"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 i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,i))}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:r}=t.FileHelper;function a(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const n=o(e),s=t.toDataURL(n,i);return"image/bmp"===n?s.replace("image/png;","image/bmp;"):s},canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,o(e),i))),canvasSaveAs:(e,i,n)=>{const s=e.toDataURL(o(r(i)),n);return t.Platform.origin.download(s,i)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:e=>new Promise(((i,n)=>{const s=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{i(s)},s.onerror=t=>{n(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:h}=navigator;h.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):h.indexOf("AppleWebKit")>-1&&(t.Platform.fullImageShadow=!0),h.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):h.indexOf("Mac")>-1?t.Platform.os="Mac":h.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,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,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,i=e.length;t<i;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:d,updateChange:u}=t.LeafHelper,{pushAllChildBranch:p,pushAllParent:f}=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:v,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,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){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 i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=t.LayoutEvent,h=this.getBlocks(s);h.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(o,h,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(c(t,!0),e.add(t),t.isBranch&&p(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||d(n[t])}d(i)}}))}(this.__levelList),function(t){t.list.forEach(u)}(s),this.extraBlock&&h.push(this.extraBlock),h.forEach((t=>t.setAfter())),n.emitEvent(new t.LayoutEvent(r,h,this.times)),n.emitEvent(new t.LayoutEvent(a,h,this.times)),this.addBlocks(h),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(o,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){v(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:i}=this.extraBlock||(this.extraBlock=new _([]));e.length?i.add(t.__world):i.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,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,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:i}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(i.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 i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=new t.Bounds(s);n.save(),s.spread(b.clipSpread).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0),this.__render(s,o),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),this.target.__render(n,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const i=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).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,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__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)}}b.clipSpread=10;const{hitRadiusPoint:E}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(r);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,n.bottomList,o),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:a.length?this.getThroughPath(a):l}:{path:l,target:h}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,r),this.findList.length))return this.findList.list[0]}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,o,r;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!o||!o.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||E(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class B{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new L(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){const{target:s,picker:o}=this;return t.Platform.backgrounder&&s&&s.updateLayout(),o.getByPoint(e,i,n)}getBy(e,i,n,s){return this.finder?this.finder.getBy(e,i,n,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new b(t,e,i),selector:(t,e)=>new B(t,e)}),t.Platform.layout=y.fullLayout;const P={convert(t,i){const n=e.InteractionHelper.getBase(t),s=Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,i){const n=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const n=P.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},R={convert(t){const i=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},i),{code:t.code,key:t.key})}},{pathCanDrag:k}=e.InteractionHelper;class C extends e.InteractionBase{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,n=t.length;i<n;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(R.convert(t))}onKeyUp(t){this.keyUp(R.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(P.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(P.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=P.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(P.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(P.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(P.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(P.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=P.getTouch(t),i=this.getLocal(e,!0),{preventDefault:n}=this.config.touch;(!0===n||"auto"===n&&k(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(P.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=P.getTouch(t);this.pointerMove(P.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=P.getTouch(t);this.pointerUp(P.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})})),n}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},e.InteractionHelper.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(i){if(this.useMultiTouch)return;this.preventDefaultWheel(i);const n=e.InteractionHelper.getBase(i);Object.assign(n,this.getLocal(i));const s=i.scale/this.lastGestureScale,o=(i.rotation-this.lastGestureRotation)/Math.PI*180*(t.MathHelper.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},n),{scale:s*s})),this.rotate(Object.assign(Object.assign({},n),{rotation:o})),this.lastGestureScale=i.scale,this.lastGestureRotation=i.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,i,n=0){if(n++,t instanceof Array)t.forEach((t=>this.eachCursor(t,i,n)));else{const s="string"==typeof t&&e.Cursor.get(t);s&&n<2?this.eachCursor(s,i,n):i.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function T(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(s){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function S(t,e){t.__.__font?T(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function M(t,e,i){switch(e.__.strokeAlign){case"center":A(t,1,e,i);break;case"inside":O(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?A(t,2,e,i):O(t,"outside",e,i)}}function A(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?I(t,!0,i,n):W(i,n)}function O(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,A(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",T(i,s),s.blendMode="normal",D(n,s,i),s.recycle(i.__nowWorld)}function D(e,i,n){n.__worldFlipped||t.Platform.fullImageShadow?e.copyWorldByReset(i,n.__nowWorld):e.copyWorldToInner(i,n.__nowWorld,n.__layout.renderBounds)}function W(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function I(t,e,n,s){let o;for(let r=0,a=t.length;r<a;r++)o=t[r],o.image&&i.PaintImage.checkImage(n,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),e?W(n,s):s.stroke(),s.restoreBlendMode()):e?W(n,s):s.stroke())}function H(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)M(t,e,i);else switch(n.strokeAlign){case"center":z(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),z(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)z(t,2,e,i);else{const{renderBounds:s}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),z(t,2,e,o),o.clipUI(n),o.clearWorld(s),D(i,o,e),o.recycle(e.__nowWorld)}}(t,e,i)}}function z(t,e,n,s){const o=n.__;s.setStroke(!o.__isStrokes&&t,o.__strokeWidth*e,o),o.__isStrokes?I(t,!1,n,s):s.stroke(),o.__useArrow&&i.Paint.strokeArrow(t,n,s)}const{getSpread:j,getOuterOf:F,getByMove:G,getIntersectData:U}=t.BoundsHelper;let Y;const{stintSet:V}=t.DataHelper,{hasTransparent:X}=i.ColorConvert;function N(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:o}=n.__layout;switch(e.type){case"image":s=i.PaintImage.image(n,t,e,o,!Y||!Y[e.url]);break;case"linear":s=i.PaintGradient.linearGradient(e,o);break;case"radial":s=i.PaintGradient.radialGradient(e,o);break;case"angular":s=i.PaintGradient.conicGradient(e,o);break;case"solid":const{type:r,color:a,opacity:h}=e;s={type:r,style:i.ColorConvert.string(a,h)};break;default:void 0!==e.r&&(s={type:"solid",style:i.ColorConvert.string(e)})}return s&&("string"==typeof s.style&&X(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const q={compute:function(t,e){const n=e.__,s=[];let o,r,a=n.__input[t];a instanceof Array||(a=[a]),Y=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=a.length;n<o;n++)(i=N(t,a[n],e))&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(o=!0),r=!0),"fill"===t?(V(n,"__isAlphaPixelFill",o),V(n,"__isTransparentFill",r)):(V(n,"__isAlphaPixelStroke",o),V(n,"__isTransparentStroke",r))},fill:function(t,e,i){i.fillStyle=t,S(e,i)},fills:function(t,e,n){let s;for(let o=0,r=t.length;o<r;o++){if(s=t[o],s.image){if(i.PaintImage.checkImage(e,n,s,!e.__.__font))continue;if(!s.style){!o&&s.image.isPlacehold&&e.drawImagePlaceholder(n,s.image);continue}}n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),S(e,n),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),S(e,n),n.restoreBlendMode()):S(e,n)}},fillPathOrText:S,fillText:T,stroke:H,strokes:function(t,e,i){H(t,e,i)},strokeText:M,drawTextStroke:W,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))h=n,o=a=s;else{const{renderShapeSpread:n}=t.__layout,d=U(n?j(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(d);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,c*=p),a=F(s,r),o=G(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:c}}};let K={};const{get:Q,rotateOfOuter:$,translate:Z,scaleOfOuter:J,scale:tt,rotate:et,skew:it}=t.MatrixHelper;function nt(t,e,i,n,s,o,r){const a=Q();Z(a,e.x+i,e.y+n),tt(a,s,o),r&&$(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function st(t,e,i,n,s,o,r,a){const h=Q();r&&et(h,r),a&&it(h,a.x,a.y),s&&tt(h,s,o),Z(h,e.x+i,e.y+n),t.transform=h}function ot(t,e,i,n,s,o,r,a,h,l){const c=Q();if(h)if("center"===l)$(c,{x:i/2,y:n/2},h);else switch(et(c,h),h){case 90:Z(c,n,0);break;case 180:Z(c,i,n);break;case 270:Z(c,0,i)}K.x=e.x+s,K.y=e.y+o,Z(c,K.x,K.y),r&&J(c,K,r,a),t.transform=c}const{get:rt,translate:at}=t.MatrixHelper,ht=new t.Bounds,lt={},ct={};function dt(t,e,i,n){const{changeful:s,sync:o,editing:r}=i;s&&(t.changeful=s),o&&(t.sync=o),r&&(t.editing=r),t.data=ut(i,n,e)}function ut(e,i,n){e.padding&&(i=ht.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:o}=n;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:p,repeat:f,filters:g}=e,_=i.width===s&&i.height===o,v={mode:a},w="center"!==h&&(u||0)%180==90;let m,y;switch(t.BoundsHelper.set(ct,0,0,w?o:s,w?s:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(t.MathHelper.getScaleData(c,d,n,lt),m=lt.scaleX,y=lt.scaleY),h&&(m&&t.BoundsHelper.scale(ct,m,y,!0),t.AlignHelper.toPoint(h,ct,i,ct,!0,!0))):_&&!u||(m=y=t.BoundsHelper.getFitScale(i,ct,"fit"!==a),t.BoundsHelper.put(i,n,h,m,!1,ct),t.BoundsHelper.scale(ct,m,y,!0)),l&&t.PointHelper.move(ct,l),a){case"stretch":_||(s=i.width,o=i.height);break;case"normal":case"clip":(ct.x||ct.y||m||u||p)&&st(v,i,ct.x,ct.y,m,y,u,p);break;case"repeat":(!_||m||u)&&ot(v,i,s,o,ct.x,ct.y,m,y,u,h),f||(v.repeat="repeat");break;default:m&&nt(v,i,ct.x,ct.y,m,y,u)}return v.transform||(i.x||i.y)&&(v.transform=rt(),at(v.transform,i.x,i.y)),m&&"stretch"!==a&&(v.scaleX=m,v.scaleY=y),v.width=s,v.height=o,r&&(v.opacity=r),g&&(v.filters=g),f&&(v.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),v}let pt,ft=new t.Bounds;const{isSame:gt}=t.BoundsHelper;function _t(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||dt(s,n,i,o),!0}function vt(e,i){yt(e,t.ImageEvent.LOAD,i)}function wt(e,i){yt(e,t.ImageEvent.LOADED,i)}function mt(e,i,n){i.error=n,e.forceUpdate("surface"),yt(e,t.ImageEvent.ERROR,i)}function yt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function xt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:bt,scale:Et,copy:Lt}=t.MatrixHelper,{ceil:Bt,abs:Pt}=Math;function Rt(e,i,n){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+o+"-"+n;if(i.patternId===r||e.destroyed)return!1;{s=Pt(s),o=Pt(o);const{image:e,data:a}=i;let h,l,{width:c,height:d,scaleX:u,scaleY:p,transform:f,repeat:g}=a;u&&(u=Pt(u),p=Pt(p),l=bt(),Lt(l,f),Et(l,1/u,1/p),s*=u,o*=p),s*=n,o*=n,c*=s,d*=o;const _=c*d;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let v=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;v>t&&(v=t)}_>v&&(h=Math.sqrt(_/v)),h&&(s/=h,o/=h,c/=h,d/=h),u&&(s/=u,o/=p),(f||1!==s||1!==o)&&(l||(l=bt(),f&&Lt(l,f)),Et(l,1/s,1/o));const w=e.getCanvas(Bt(c)||1,Bt(d)||1,a.opacity,a.filters),m=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=r,!0}}function kt(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Ct}=Math;const Tt={image:function(e,i,n,s,o){let r,a;const h=t.ImageManager.get(n);return pt&&n===pt.paint&&gt(s,pt.boxBounds)?r=pt.leafPaint:(r={type:n.type,image:h},h.hasAlphaPixel&&(r.isTransparent=!0),pt=h.use>1?{leafPaint:r,paint:n,boxBounds:ft.set(s)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:n}),h.ready?(_t(e,i,n,h,r,s),o&&(vt(e,a),wt(e,a))):h.error?o&&mt(e,a,h.error):(o&&(xt(e,!0),vt(e,a)),r.loadId=h.load((()=>{xt(e,!1),e.destroyed||(_t(e,i,n,h,r,s)&&(h.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),wt(e,a)),r.loadId=void 0}),(t=>{xt(e,!1),mt(e,a,t),r.loadId=void 0})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{h.ready||(h.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):h.isPlacehold=!0)),r},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:h}=n,{data:l}=s;if(!l||s.patternId===r+"-"+a+"-"+h&&!i.Export.running)return!1;if(o)if(l.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:i}=l;e*=Ct(r)*h,i*=Ct(a)*h,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),o=e*i>t.Platform.image.maxCacheSize}return o?(function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(e,n,s,l),!0):(!s.style||s.sync||i.Export.running?Rt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>kt(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Rt(e,s,h),e.forceUpdate("surface")}))),300)),!1)},createPattern:Rt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,o,r,a,h;for(let l=0,c=n.length;l<c;l++)s=n[l],o=s.image,h=o&&o.url,h&&(r||(r={}),r[h]=!0,t.ImageManager.recycle(o),o.loading&&(a||(a=i.__input&&i.__input[e]||[],a instanceof Array||(a=[a])),o.unload(n[l].loadId,!a.some((t=>t.url===h)))));return r}return null},createData:dt,getPatternData:ut,fillOrFitMode:nt,clipMode:st,repeatMode:ot},{toPoint:St}=t.AroundHelper,{hasTransparent:Mt}=i.ColorConvert,At={},Ot={};function Dt(t,e,n,s){if(n){let o,r,a,h;for(let t=0,l=n.length;t<l;t++)o=n[t],"string"==typeof o?(a=t/(l-1),r=i.ColorConvert.string(o,s)):(a=o.offset,r=i.ColorConvert.string(o.color,s)),e.addColorStop(a,r),!h&&Mt(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Wt,getDistance:It}=t.PointHelper,{get:Ht,rotateOfOuter:zt,scaleOfOuter:jt}=t.MatrixHelper,{toPoint:Ft}=t.AroundHelper,Gt={},Ut={};function Yt(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=Wt(e,i);o=Ht(),s?(jt(o,e,r/a*(n||1),1),zt(o,e,t+90)):(jt(o,e,1,r/a*(n||1)),zt(o,e,t))}return o}const{getDistance:Vt}=t.PointHelper,{toPoint:Xt}=t.AroundHelper,Nt={},qt={};const Kt={linearGradient:function(e,i){let{from:n,to:s,type:o,opacity:r}=e;St(n||"top",i,At),St(s||"bottom",i,Ot);const a=t.Platform.canvas.createLinearGradient(At.x,At.y,Ot.x,Ot.y),h={type:o,style:a};return Dt(h,a,e.stops,r),h},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=e;Ft(n||"center",i,Gt),Ft(s||"bottom",i,Ut);const h=t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,It(Gt,Ut)),l={type:o,style:h};Dt(l,h,e.stops,r);const c=Yt(i,Gt,Ut,a,!0);return c&&(l.transform=c),l},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=e;Xt(n||"center",i,Nt),Xt(s||"bottom",i,qt);const h=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Nt.x,Nt.y):t.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Vt(Nt,qt)),l={type:o,style:h};Dt(l,h,e.stops,r);const c=Yt(i,Nt,qt,a||1,t.Platform.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Yt},{copy:Qt,toOffsetOutBounds:$t}=t.BoundsHelper,Zt={},Jt={};function te(e,i,n,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Qt(Zt,e.bounds),Zt.x+=i.x-r.x,Zt.y+=i.y-r.y,n){const{matrix:t}=s;Zt.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Zt.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Zt.width*=n,Zt.height*=n}e.copyWorld(s.canvas,e.bounds,Zt)}else n&&(Qt(Zt,i),Zt.x-=i.width/2*(n-1),Zt.y-=i.height/2*(n-1),Zt.width*=n,Zt.height*=n),e.copyWorld(s.canvas,r,n?Zt:i)}const{toOffsetOutBounds:ee}=t.BoundsHelper,ie={};const ne={shadow:function(t,e,n){let s,o;const{__nowWorld:r,__layout:a}=t,{shadow:h}=t.__,{worldCanvas:l,bounds:c,shapeBounds:d,scaleX:u,scaleY:p}=n,f=e.getSameCanvas(),g=h.length-1;$t(c,Jt),h.forEach(((h,_)=>{f.setWorldShadow(Jt.offsetX+h.x*u,Jt.offsetY+h.y*p,h.blur*u,i.ColorConvert.string(h.color)),o=h.spread?1+2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,te(f,Jt,o,n),s=c,h.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,c,r,"copy"),s=r),l?f.copyWorld(l,r,r,"destination-out"):f.copyWorld(n.canvas,d,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,r,h.blendMode):e.copyWorldToInner(f,s,a.renderBounds,h.blendMode),g&&_<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,n){let s,o;const{__nowWorld:r,__layout:a}=t,{innerShadow:h}=t.__,{worldCanvas:l,bounds:c,shapeBounds:d,scaleX:u,scaleY:p}=n,f=e.getSameCanvas(),g=h.length-1;ee(c,ie),h.forEach(((h,_)=>{f.save(),f.setWorldShadow(ie.offsetX+h.x*u,ie.offsetY+h.y*p,h.blur*u),o=h.spread?1-2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,te(f,ie,o,n),f.restore(),l?(f.copyWorld(f,c,r,"copy"),f.copyWorld(l,r,r,"source-out"),s=r):(f.copyWorld(n.canvas,d,c,"source-out"),s=c),f.fillWorld(s,i.ColorConvert.string(h.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,r,h.blendMode):e.copyWorldToInner(f,s,a.renderBounds,h.blendMode),g&&_<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:se}=t.LeafBoundsHelper;function oe(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),ae(t,e,i,1)}(t,i,n,s);break;case"opacity-path":ae(t,i,n,o);break;case"path":i.restore()}}function re(t){return t.getSameCanvas(!1,!0)}function ae(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++)i=h[l],a=i.__.mask,a&&(r&&(oe(this,r,t,s,n,o),n=s=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,s||(s=re(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=re(t)),s||(s=re(t)),i.__render(n,e)),"clipping"!==a&&"clipping-path"!==a)||se(i,e)||i.__render(s||t,e);oe(this,r,t,s,n,o)};const he=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",le=he+"_#~&*+\\=|≮≯≈≠=…",ce=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 de(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ue=de("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),pe=de("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fe=de(he),ge=de(le),_e=de("- —/~|┆·");var ve;!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"}(ve||(ve={}));const{Letter:we,Single:me,Before:ye,After:xe,Symbol:be,Break:Ee}=ve;function Le(t){return ue[t]?we:_e[t]?Ee:pe[t]?ye:fe[t]?xe:ge[t]?be:ce.test(t)?me:we}const Be={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Pe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Re}=Be,{Letter:ke,Single:Ce,Before:Te,After:Se,Symbol:Me,Break:Ae}=ve;let Oe,De,We,Ie,He,ze,je,Fe,Ge,Ue,Ye,Ve,Xe,Ne,qe,Ke,Qe,$e=[];function Ze(t,e){Ge&&!Fe&&(Fe=Ge),Oe.data.push({char:t,width:e}),We+=e}function Je(){Ie+=We,Oe.width=We,De.words.push(Oe),Oe={data:[]},We=0}function ti(){Ne&&(qe.paraNumber++,De.paraStart=!0,Ne=!1),Ge&&(De.startCharSize=Fe,De.endCharSize=Ge,Fe=0),De.width=Ie,Ke.width?Re(De):Qe&&ei(),$e.push(De),De={words:[]},Ie=0}function ei(){Ie>(qe.maxWidth||0)&&(qe.maxWidth=Ie)}const{top:ii,right:ni,bottom:si,left:oi}=t.Direction4;function ri(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const ai={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let s=0,o=0,r=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=n;c&&(r?(s=c[oi],r-=c[ni]+c[oi]):n.autoSizeAlign||(s=c[oi]),a?(o=c[ii],a-=c[ii]+c[si]):n.autoSizeAlign||(o=c[ii]));const d={bounds:{x:s,y:o,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,i,n){qe=e,$e=e.rows,Ke=e.bounds,Qe=!Ke.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=t.Platform,{width:h,height:l}=Ke;if(h||l||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ne=!0,Ye=null,Fe=je=Ge=We=Ie=0,Oe={data:[]},De={words:[]},s&&(i=[...i]);for(let n=0,l=i.length;n<l;n++)ze=i[n],"\n"===ze?(We&&Je(),De.paraEnd=!0,ti(),Ne=!0):(Ue=Le(ze),Ue===ke&&"none"!==r&&(ze=Pe(ze,r,!We)),je=a.measureText(ze).width,s&&(s<0&&(Ge=je),je+=s),Ve=Ue===Ce&&(Ye===Ce||Ye===ke)||Ye===Ce&&Ue!==Se,Xe=!(Ue!==Te&&Ue!==Ce||Ye!==Me&&Ye!==Se),He=Ne&&o?h-o:h,t&&h&&Ie+We+je>He&&(e?(We&&Je(),Ie&&ti()):(Xe||(Xe=Ue===ke&&Ye==Se),Ve||Xe||Ue===Ae||Ue===Te||Ue===Ce||We+je>He?(We&&Je(),Ie&&ti()):Ie&&ti()))," "===ze&&!0!==Ne&&Ie+We===0||(Ue===Ae?(" "===ze&&We&&Je(),Ze(ze,je),Je()):Ve||Xe?(We&&Je(),Ze(ze,je)):Ze(ze,je)),Ye=Ue);We&&Je(),Ie&&ti(),$e.length>0&&($e[$e.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{qe.paraNumber++,Ie=a.measureText(t).width,$e.push({x:o||0,text:t,width:Ie,paraStart:!0}),Qe&&ei()}))}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ri(e,"x",t[oi]);break;case"right":ri(e,"x",-t[ni])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ri(e,"y",t[ii]);break;case"bottom":ri(e,"y",-t[si])}}(c,d,n,r,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:p,y:f,width:g,height:_}=n,v=o*s+(d?d*(t.paraNumber-1):0),w=r;if(h&&v>_)v=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":f+=(_-v)/2;break;case"bottom":f+=_-v}w+=f;let m,y,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(m=i[r],m.x=p,m.width<g||m.width>g&&!h)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&d&&r>0&&(w+=d),m.y=w,w+=o,t.overflow>r&&w>v&&(m.isOverflow=!0,t.overflow=r+1),y=m.x,x=m.width,a<0&&(m.width<0?(x=-m.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<n.x&&(n.x=y),x>n.width&&(n.width=x),h&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=v}(d,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==s||i===u-1||(a+=h,t.width+=h)}))),t.words=null)}))}(d,n,r),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.Platform.canvas.measureText(a).width:0,c=n+s-l;("none"===i.textWrap?o:[o[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],h=e.x+e.width,!(n===i&&h<c));n--){if(h<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,n,s,r),"none"!==h&&function(t,e){let n;const{fontSize:s,textDecoration:o}=e;switch(t.decorationHeight=s/11,"object"==typeof o?(n=o.type,o.color&&(t.decorationColor=i.ColorConvert.string(o.color))):n=o,n){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,n),d}};const hi={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(i.TextConvert,ai),Object.assign(i.ColorConvert,hi),Object.assign(i.Paint,q),Object.assign(i.PaintImage,Tt),Object.assign(i.PaintGradient,Kt),Object.assign(i.Effect,ne),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new C(t,e,i,n),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=C,exports.Layouter=y,exports.LeaferCanvas=s,exports.Picker=L,exports.Renderer=b,exports.Selector=B,exports.Watcher=l,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/core"),i=require("@leafer-ui/draw");const s=t.Debug.get("LeaferCanvas");class n 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:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(s.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(e){let i=t.isString(e)?document.getElementById(e):e;if(i)if(i instanceof HTMLCanvasElement)this.view=i;else{let t=i;if(i===window||i===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else s.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}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),s.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:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const i=this.view,{x:s,y:n,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}=i;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}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:r}=t.FileHelper;function a(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=o(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,o(e),i)),canvasSaveAs:(e,i,s)=>{const n=e.toDataURL(o(r(i)),s);return t.Platform.origin.download(n,i)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:e=>new Promise((i,s)=>{const n=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.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 n(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:h}=navigator;h.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),h.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):h.indexOf("Mac")>-1?t.Platform.os="Mac":h.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,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,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,i=e.length;t<i;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:d,updateChange:u}=t.LeafHelper,{pushAllChildBranch:f,pushAllParent:p}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper;class v{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(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:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,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){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 i=t.Run.start("PartLayout"),{target:s,__updatedList:n}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=t.LayoutEvent,h=this.getBlocks(n);h.forEach(t=>t.setBefore()),s.emitEvent(new t.LayoutEvent(o,h,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(c(t,!0),e.add(t),t.isBranch&&f(t,e),p(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),p(t,e)))})}(n,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||d(s[t])}d(i)}})}(this.__levelList),function(t){t.list.forEach(u)}(n),this.extraBlock&&h.push(this.extraBlock),h.forEach(t=>t.setAfter()),s.emitEvent(new t.LayoutEvent(r,h,this.times)),s.emitEvent(new t.LayoutEvent(a,h,this.times)),this.addBlocks(h),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(s,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(n,r,this.times)),i.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:i}=this.extraBlock||(this.extraBlock=new v([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new v(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,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=i,s&&(this.config=t.DataHelper.default(s,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:i}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(i.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 i=t.Run.start("PartRender"),{canvas:s}=this,n=e.getIntersect(s.bounds),o=new t.Bounds(n);s.save(),n.spread(b.clipSpread).ceil(),s.clearWorld(n,!0),s.clipWorld(n,!0),this.__render(n,o),s.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const i=this.requestTime=Date.now();t.Platform.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()})}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:s}=e.old;if(!new t.Bounds(0,0,i,s).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,i,s){this.target.emitEvent(new t.RenderEvent(e,this.times,i,s))}__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)}}b.clipSpread=10;const{hitRadiusPoint:E}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,s){i||(i=0),s||(s={});const n=s.through||!1,o=s.ignoreHittable||!1,r=s.target||this.target;this.exclude=s.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(s.findList),s.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,s.bottomList,o),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),n?{path:l,target:h,throughPath:a.length?this.getThroughPath(a):l}:{path:l,target:h}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(e,i,s){const n=this.findList=new t.LeafList;if(e.length){let i;const{x:o,y:r}=this.point,a={x:o,y:r,radiusX:0,radiusY:0};for(let o=0,r=e.length;o<r;o++)if(i=e[o],(s||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,a),n.length)){if(i.isBranchLeaf&&e.some(e=>e!==i&&t.LeafHelper.hasParent(e,i))){n.reset();break}return n.list[0]}}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),n.length)return n.list[0];return s?e[0]:e.find(e=>t.LeafHelper.worldHittable(e))}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let s,n=new t.LeafList;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.addAt(s,0),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t.LeafList,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,o,r;for(let t=0,e=s.length;t<e;t++){n=s[t],o=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!o||!o.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||E(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class B{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new L(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,s){const{target:n,picker:o}=this;return t.Platform.backgrounder&&n&&n.updateLayout(),o.getByPoint(e,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(e,i,s,n){return this.finder?this.finder.getBy(e,i,s,n):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new b(t,e,i),selector:(t,e)=>new B(t,e)}),t.Platform.layout=y.fullLayout;const P={convert(t,i){const s=e.InteractionHelper.getBase(t),n=Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===n.pointerType&&(n.tangentialPressure=t.tangentialPressure,n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n},convertMouse(t,i){const s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const s=P.getTouch(t),n=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:s.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},k={convert(t){const i=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},i),{code:t.code,key:t.key})}},{pathCanDrag:R}=e.InteractionHelper;class C extends e.InteractionBase{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(k.convert(t))}onKeyUp(t){this.keyUp(k.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(P.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(P.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=P.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(P.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(P.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(P.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(P.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=P.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&R(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(P.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=P.getTouch(t);this.pointerMove(P.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=P.getTouch(t);this.pointerUp(P.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),s=this.getKeepTouchList(this.touches,i);s.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),s),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},e.InteractionHelper.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(i){if(this.useMultiTouch)return;this.preventDefaultWheel(i);const s=e.InteractionHelper.getBase(i);Object.assign(s,this.getLocal(i));const n=i.scale/this.lastGestureScale,o=(i.rotation-this.lastGestureRotation)/Math.PI*180*(t.MathHelper.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},s),{scale:n*n})),this.rotate(Object.assign(Object.assign({},s),{rotation:o})),this.lastGestureScale=i.scale,this.lastGestureRotation=i.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(e){super.setCursor(e);const i=[];this.eachCursor(e,i),t.isObject(i[i.length-1])&&i.push("default"),this.canvas.view.style.cursor=i.map(e=>t.isObject(e)?`url(${e.url}) ${e.x||0} ${e.y||0}`:e).join(",")}eachCursor(i,s,n=0){if(n++,t.isArray(i))i.forEach(t=>this.eachCursor(t,s,n));else{const o=t.isString(i)&&e.Cursor.get(i);o&&n<2?this.eachCursor(o,s,n):s.push(i)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function S(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[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(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,o)))}}function T(t,e){t.__.__font?S(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function M(t,e,i){switch(e.__.strokeAlign){case"center":A(t,1,e,i);break;case"inside":O(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?A(t,2,e,i):O(t,"outside",e,i)}}function A(e,i,s,n){const o=s.__;t.isObject(e)?W(e,i,!0,s,n):(n.setStroke(e,o.__strokeWidth*i,o),D(s,n))}function O(e,i,s,n){const o=n.getSameCanvas(!0,!0);o.font=s.__.__font,A(e,2,s,o),o.blendMode="outside"===i?"destination-out":"destination-in",S(s,o),o.blendMode="normal",t.LeafHelper.copyCanvasByWorld(s,n,o),o.recycle(s.__nowWorld)}function D(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(o){const{decorationHeight:t}=s;n.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function W(t,e,s,n,o){let r;const a=n.__,{__hasMultiStrokeStyle:h}=a;h||o.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,c=t.length;l<c;l++)if(r=t[l],(!r.image||!i.PaintImage.checkImage(n,o,r,!1))&&r.style){if(h){const{strokeStyle:t}=r;t?o.setStroke(r.style,a.__getRealStrokeWidth(t)*e,a,t):o.setStroke(r.style,a.__strokeWidth*e,a)}else o.strokeStyle=r.style;r.blendMode?(o.saveBlendMode(r.blendMode),s?D(n,o):o.stroke(),o.restoreBlendMode()):s?D(n,o):o.stroke()}}function I(e,i,s){const n=i.__;if(n.__strokeWidth)if(n.__font)M(e,i,s);else switch(n.strokeAlign){case"center":H(e,1,i,s);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),H(t,2,e,i),i.restore()}(e,i,s);break;case"outside":!function(e,i,s){const n=i.__;if(n.__fillAfterStroke)H(e,2,i,s);else{const{renderBounds:o}=i.__layout,r=s.getSameCanvas(!0,!0);i.__drawRenderPath(r),H(e,2,i,r),r.clipUI(n),r.clearWorld(o),t.LeafHelper.copyCanvasByWorld(i,s,r),r.recycle(i.__nowWorld)}}(e,i,s)}}function H(e,s,n,o){const r=n.__;t.isObject(e)?W(e,s,!1,n,o):(o.setStroke(e,r.__strokeWidth*s,r),o.stroke()),r.__useArrow&&i.Paint.strokeArrow(e,n,o)}const{getSpread:z,getOuterOf:j,getByMove:F,getIntersectData:G}=t.BoundsHelper;let U;const{stintSet:Y}=t.DataHelper,{hasTransparent:X}=i.ColorConvert;function V(e,s,n){if(!t.isObject(s)||!1===s.visible||0===s.opacity)return;let o;const{boxBounds:r}=n.__layout;switch(s.type){case"image":o=i.PaintImage.image(n,e,s,r,!U||!U[s.url]);break;case"linear":o=i.PaintGradient.linearGradient(s,r);break;case"radial":o=i.PaintGradient.radialGradient(s,r);break;case"angular":o=i.PaintGradient.conicGradient(s,r);break;case"solid":const{type:a,color:h,opacity:l}=s;o={type:a,style:i.ColorConvert.string(h,l)};break;default:t.isUndefined(s.r)||(o={type:"solid",style:i.ColorConvert.string(s)})}if(o){if(t.isString(o.style)&&X(o.style)&&(o.isTransparent=!0),s.style){if(0===s.style.strokeWidth)return;o.strokeStyle=s.style}s.editing&&(o.editing=s.editing),s.blendMode&&(o.blendMode=s.blendMode)}return o}const N={compute:function(e,s){const n=s.__,o=[];let r,a,h,l=n.__input[e];t.isArray(l)||(l=[l]),U=i.PaintImage.recycleImage(e,n);for(let t,i=0,n=l.length;i<n;i++)(t=V(e,l[i],s))&&(o.push(t),t.strokeStyle&&(h||(h=1),t.strokeStyle.strokeWidth&&(h=Math.max(h,t.strokeStyle.strokeWidth))));n["_"+e]=o.length?o:void 0,o.length&&o.every(t=>t.isTransparent)&&(o.some(t=>t.image)&&(r=!0),a=!0),"fill"===e?(Y(n,"__isAlphaPixelFill",r),Y(n,"__isTransparentFill",a)):(Y(n,"__isAlphaPixelStroke",r),Y(n,"__isTransparentStroke",a),Y(n,"__hasMultiStrokeStyle",h))},fill:function(t,e,i){i.fillStyle=t,T(e,i)},fills:function(t,e,s){let n;for(let o=0,r=t.length;o<r;o++){if(n=t[o],n.image){if(i.PaintImage.checkImage(e,s,n,!e.__.__font))continue;if(!n.style){!o&&n.image.isPlacehold&&e.drawImagePlaceholder(s,n.image);continue}}if(s.fillStyle=n.style,n.transform||n.scaleFixed){if(s.save(),n.transform&&s.transform(n.transform),n.scaleFixed){const{scaleX:t,scaleY:i}=e.getRenderScaleData(!0);(!0===n.scaleFixed||"zoom-in"===n.scaleFixed&&t>1&&i>1)&&s.scale(1/t,1/i)}n.blendMode&&(s.blendMode=n.blendMode),T(e,s),s.restore()}else n.blendMode?(s.saveBlendMode(n.blendMode),T(e,s),s.restoreBlendMode()):T(e,s)}},fillPathOrText:T,fillText:S,stroke:I,strokes:function(t,e,i){I(t,e,i)},strokeText:M,drawTextStroke:D,shape:function(e,i,s){const n=i.getSameCanvas(),o=e.__nowWorld;let r,a,h,l,c,{scaleX:d,scaleY:u}=o;if(d<0&&(d=-d),u<0&&(u=-u),i.bounds.includes(o))c=n,r=l=o;else{const{renderShapeSpread:n}=e.__layout,f=G(n?z(i.bounds,d===u?n*d:[n*u,n*d]):i.bounds,o);h=i.bounds.getFitMatrix(f);let{a:p,d:g}=h;h.a<1&&(c=i.getSameCanvas(),e.__renderShape(c,s),d*=p,u*=g),l=j(o,h),r=F(l,-h.e,-h.f);const v=s.matrix;v?(a=new t.Matrix(h),a.multiply(v),p*=v.scaleX,g*=v.scaleY):a=h,a.withScale(p,g),s=Object.assign(Object.assign({},s),{matrix:a})}return e.__renderShape(n,s),{canvas:n,matrix:a,fitMatrix:h,bounds:r,worldCanvas:c,shapeBounds:l,scaleX:d,scaleY:u}}};let q={},K=t.getMatrixData();const{get:Q,rotateOfOuter:$,translate:Z,scaleOfOuter:J,multiplyParent:tt,scale:et,rotate:it,skew:st}=t.MatrixHelper;function nt(t,e,i,s,n,o,r){const a=Q();Z(a,e.x+i,e.y+s),et(a,n,o),r&&$(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function ot(t,e,i,s,n,o,r,a,h){const l=Q();at(l,e,i,s,n,o,r,a),h&&(K.a=e.width/h.width,K.d=e.height/h.height,tt(l,K)),t.transform=l}function rt(t,e,i,s,n,o,r,a,h,l,c,d){const u=Q();if(d)at(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)$(u,{x:i/2,y:s/2},h);else switch(it(u,h),h){case 90:Z(u,s,0);break;case 180:Z(u,i,s);break;case 270:Z(u,0,i)}q.x=e.x+n,q.y=e.y+o,Z(u,q.x,q.y),r&&J(u,q,r,a)}t.transform=u}function at(t,e,i,s,n,o,r,a){r&&it(t,r),a&&st(t,a.x,a.y),n&&et(t,n,o),Z(t,e.x+i,e.y+s)}const{get:ht,translate:lt}=t.MatrixHelper,ct=new t.Bounds,dt={},ut={};function ft(t,e,i,s){const{changeful:n,sync:o,scaleFixed:r}=i;n&&(t.changeful=n),o&&(t.sync=o),r&&(t.scaleFixed=r),t.data=pt(i,s,e)}function pt(e,i,s){e.padding&&(i=ct.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:n,height:o}=s;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:v,filters:_}=e,w=i.width===n&&i.height===o,m={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(ut,0,0,y?o:n,y?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(t.MathHelper.getScaleData(c,d,s,dt),x=dt.scaleX,b=dt.scaleY),(h||v||g)&&(x&&t.BoundsHelper.scale(ut,x,b,!0),h&&t.AlignHelper.toPoint(h,ut,i,ut,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,ut,"fit"!==a),t.BoundsHelper.put(i,s,h,x,!1,ut),t.BoundsHelper.scale(ut,x,b,!0)),l&&t.PointHelper.move(ut,l),a){case"stretch":w||(n=i.width,o=i.height);break;case"normal":case"clip":(ut.x||ut.y||x||p||u||f)&&ot(m,i,ut.x,ut.y,x,b,u,f,e.clipSize);break;case"repeat":(!w||x||u||f)&&rt(m,i,n,o,ut.x,ut.y,x,b,u,f,h,e.freeTransform),g||(m.repeat="repeat");const s=t.isObject(g);(v||s)&&(m.gap=function(e,i,s,n,o){let r,a;t.isObject(e)?(r=e.x,a=e.y):r=a=e;return{x:gt(r,s,o.width,i&&i.x),y:gt(a,n,o.height,i&&i.y)}}(v,s&&g,ut.width,ut.height,i));break;default:x&&nt(m,i,ut.x,ut.y,x,b,u)}return m.transform||(i.x||i.y)&&(m.transform=ht(),lt(m.transform,i.x,i.y)),x&&"stretch"!==a&&(m.scaleX=x,m.scaleY=b),m.width=n,m.height=o,r&&(m.opacity=r),_&&(m.filters=_),g&&(m.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),m}function gt(e,i,s,n){const o=t.isString(e)||n?(n?s-n*i:s%i)/((n||Math.floor(s/i))-1):e;return"auto"===e&&o<0?0:o}let vt,_t=new t.Bounds;const{isSame:wt}=t.BoundsHelper;function mt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||ft(n,s,i,o),!0}function yt(e,i){Et(e,t.ImageEvent.LOAD,i)}function xt(e,i){Et(e,t.ImageEvent.LOADED,i)}function bt(e,i,s){i.error=s,e.forceUpdate("surface"),Et(e,t.ImageEvent.ERROR,i)}function Et(e,i,s){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,s))}function Lt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Bt,scale:Pt,copy:kt}=t.MatrixHelper,{floor:Rt,max:Ct,abs:St}=Math;function Tt(e,i,s){let{scaleX:n,scaleY:o}=e.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+o+"-"+s;if(i.patternId===r||e.destroyed)return!1;{const{image:e,data:a}=i;let h,l,{width:c,height:d,scaleX:u,scaleY:f,transform:p,repeat:g,gap:v}=a;n*=s,o*=s;const _=v&&v.x*n,w=v&&v.y*o;u&&(u=St(u),f=St(f),l=Bt(),kt(l,p),Pt(l,1/u,1/f),n*=u,o*=f),c*=n,d*=o;const m=c*d;if(!g&&m>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}if(m>y&&(h=Math.sqrt(m/y)),h&&(n/=h,o/=h,c/=h,d/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(l||(l=Bt(),p&&kt(l,p)),Pt(l,1/n,1/o)),l){const t=c+(_||0),e=d+(w||0);Pt(l,t/Ct(Rt(t),1),e/Ct(Rt(e),1))}const x=e.getCanvas(c,d,a.opacity,a.filters,_,w),b=e.getPattern(x,g||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=b,i.patternId=r,!0}}function Mt(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const At={image:function(e,i,s,n,o){let r,a;const h=t.ImageManager.get(s);return vt&&s===vt.paint&&wt(n,vt.boxBounds)?r=vt.leafPaint:(r={type:s.type,image:h},h.hasAlphaPixel&&(r.isTransparent=!0),vt=h.use>1?{leafPaint:r,paint:s,boxBounds:_t.set(n)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:s}),h.ready?(mt(e,i,s,h,r,n),o&&(yt(e,a),xt(e,a))):h.error?o&&bt(e,a,h.error):(o&&(Lt(e,!0),yt(e,a)),r.loadId=h.load(()=>{Lt(e,!1),e.destroyed||(mt(e,i,s,h,r,n)&&(h.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),xt(e,a)),r.loadId=void 0},t=>{Lt(e,!1),bt(e,a,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{h.ready||(h.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):h.isPlacehold=!0)),r},checkImage:function(e,s,n,o){const{scaleX:r,scaleY:a}=e.getRenderScaleData(!0,n.scaleFixed),{pixelRatio:h}=s,{data:l}=n;if(!l||n.patternId===r+"-"+a+"-"+h&&!i.Export.running)return!1;if(o)if(l.repeat)o=!1;else if(!(n.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:i}=l;e*=r*h,i*=a*h,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),o=e*i>t.Platform.image.maxCacheSize}return o?(e.__.__isFastShadow&&(s.fillStyle=n.style||"#000",s.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(e,s,n,l),!0):(!n.style||n.sync||i.Export.running?Tt(e,n,h):n.patternTask||(n.patternTask=t.ImageManager.patternTasker.add(()=>Mt(this,void 0,void 0,function*(){n.patternTask=null,s.bounds.hit(e.__nowWorld)&&Tt(e,n,h),e.forceUpdate("surface")}),300)),!1)},createPattern:Tt,recycleImage:function(e,i){const s=i["_"+e];if(t.isArray(s)){let n,o,r,a,h;for(let l=0,c=s.length;l<c;l++)n=s[l],o=n.image,h=o&&o.url,h&&(r||(r={}),r[h]=!0,t.ImageManager.recycle(o),o.loading&&(a||(a=i.__input&&i.__input[e]||[],t.isArray(a)||(a=[a])),o.unload(s[l].loadId,!a.some(t=>t.url===h))));return r}return null},createData:ft,getPatternData:pt,fillOrFitMode:nt,clipMode:ot,repeatMode:rt},{toPoint:Ot}=t.AroundHelper,{hasTransparent:Dt}=i.ColorConvert,Wt={},It={};function Ht(e,s,n,o){if(n){let r,a,h,l;for(let e=0,c=n.length;e<c;e++)r=n[e],t.isString(r)?(h=e/(c-1),a=i.ColorConvert.string(r,o)):(h=r.offset,a=i.ColorConvert.string(r.color,o)),s.addColorStop(h,a),!l&&Dt(a)&&(l=!0);l&&(e.isTransparent=!0)}}const{getAngle:zt,getDistance:jt}=t.PointHelper,{get:Ft,rotateOfOuter:Gt,scaleOfOuter:Ut}=t.MatrixHelper,{toPoint:Yt}=t.AroundHelper,Xt={},Vt={};function Nt(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=zt(e,i);o=Ft(),n?(Ut(o,e,r/a*(s||1),1),Gt(o,e,t+90)):(Ut(o,e,1,r/a*(s||1)),Gt(o,e,t))}return o}const{getDistance:qt}=t.PointHelper,{toPoint:Kt}=t.AroundHelper,Qt={},$t={};const Zt={linearGradient:function(e,i){let{from:s,to:n,type:o,opacity:r}=e;Ot(s||"top",i,Wt),Ot(n||"bottom",i,It);const a=t.Platform.canvas.createLinearGradient(Wt.x,Wt.y,It.x,It.y),h={type:o,style:a};return Ht(h,a,e.stops,r),h},radialGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;Yt(s||"center",i,Xt),Yt(n||"bottom",i,Vt);const h=t.Platform.canvas.createRadialGradient(Xt.x,Xt.y,0,Xt.x,Xt.y,jt(Xt,Vt)),l={type:o,style:h};Ht(l,h,e.stops,r);const c=Nt(i,Xt,Vt,a,!0);return c&&(l.transform=c),l},conicGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;Kt(s||"center",i,Qt),Kt(n||"bottom",i,$t);const h=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Qt.x,Qt.y):t.Platform.canvas.createRadialGradient(Qt.x,Qt.y,0,Qt.x,Qt.y,qt(Qt,$t)),l={type:o,style:h};Ht(l,h,e.stops,r);const c=Nt(i,Qt,$t,a||1,t.Platform.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Nt},{copy:Jt,toOffsetOutBounds:te}=t.BoundsHelper,ee={},ie={};function se(e,i,s,n){const{bounds:o,shapeBounds:r}=n;if(t.Platform.fullImageShadow){if(Jt(ee,e.bounds),ee.x+=i.x-r.x,ee.y+=i.y-r.y,s){const{fitMatrix:t}=n;ee.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),ee.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),ee.width*=s,ee.height*=s}e.copyWorld(n.canvas,e.bounds,ee)}else s&&(Jt(ee,i),ee.x-=i.width/2*(s-1),ee.y-=i.height/2*(s-1),ee.width*=s,ee.height*=s),e.copyWorld(n.canvas,r,s?ee:i)}const{toOffsetOutBounds:ne}=t.BoundsHelper,oe={};const re={shadow:function(e,s,n){let o,r;const{__nowWorld:a,__layout:h}=e,{shadow:l}=e.__,{worldCanvas:c,bounds:d,shapeBounds:u,scaleX:f,scaleY:p}=n,g=s.getSameCanvas(),v=l.length-1;te(d,ie),l.forEach((l,_)=>{let w=1;if(l.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ie.offsetX+l.x*f*w,ie.offsetY+l.y*p*w,l.blur*f*w,i.ColorConvert.string(l.color)),r=l.spread?1+2*l.spread/(h.boxBounds.width+2*(h.strokeBoxSpread||0))*w:0,se(g,ie,r,n),o=d,l.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,d,a,"copy"),o=a),c?g.copyWorld(c,a,a,"destination-out"):g.copyWorld(n.canvas,u,d,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,s,g,o,l.blendMode),v&&_<v&&g.clearWorld(o,!0)}),g.recycle(o)},innerShadow:function(e,s,n){let o,r;const{__nowWorld:a,__layout:h}=e,{innerShadow:l}=e.__,{worldCanvas:c,bounds:d,shapeBounds:u,scaleX:f,scaleY:p}=n,g=s.getSameCanvas(),v=l.length-1;ne(d,oe),l.forEach((l,_)=>{let w=1;if(l.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(oe.offsetX+l.x*f*w,oe.offsetY+l.y*p*w,l.blur*f*w),r=l.spread?1-2*l.spread/(h.boxBounds.width+2*(h.strokeBoxSpread||0))*w:0,se(g,oe,r,n),g.restore(),c?(g.copyWorld(g,d,a,"copy"),g.copyWorld(c,a,a,"source-out"),o=a):(g.copyWorld(n.canvas,u,d,"source-out"),o=d),g.fillWorld(o,i.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,s,g,o,l.blendMode),v&&_<v&&g.clearWorld(o,!0)}),g.recycle(o)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ae}=t.LeafBoundsHelper;let he;function le(t,e,i,s,n,o,r,a){switch(e){case"grayscale":he||(he=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);de(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":de(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function ce(t){return t.getSameCanvas(!1,!0)}function de(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r,!0)}i.Group.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(le(this,r,t,n,s,o,void 0,!0),s=n=null),o=i.__.opacity,he=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=ce(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=ce(t)),n||(n=ce(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a||ae(i,e)||i.__render(t,e);continue}const c=1===o&&i.__.__blendMode;c&&le(this,r,t,n,s,o,void 0,!1),ae(i,e)||i.__render(n||t,e),c&&le(this,r,t,n,s,o,c,!1)}le(this,r,t,n,s,o,void 0,!0)};const ue=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",fe=ue+"_#~&*+\\=|≮≯≈≠=…",pe=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 ge(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ve=ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),_e=ge("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),we=ge(ue),me=ge(fe),ye=ge("- —/~|┆·");var xe;!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"}(xe||(xe={}));const{Letter:be,Single:Ee,Before:Le,After:Be,Symbol:Pe,Break:ke}=xe;function Re(t){return ve[t]?be:ye[t]?ke:_e[t]?Le:we[t]?Be:me[t]?Pe:pe.test(t)?Ee:be}const Ce={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Se(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Te}=Ce,{Letter:Me,Single:Ae,Before:Oe,After:De,Symbol:We,Break:Ie}=xe;let He,ze,je,Fe,Ge,Ue,Ye,Xe,Ve,Ne,qe,Ke,Qe,$e,Ze,Je,ti,ei=[];function ii(t,e){Ve&&!Xe&&(Xe=Ve),He.data.push({char:t,width:e}),je+=e}function si(){Fe+=je,He.width=je,ze.words.push(He),He={data:[]},je=0}function ni(){$e&&(Ze.paraNumber++,ze.paraStart=!0,$e=!1),Ve&&(ze.startCharSize=Xe,ze.endCharSize=Ve,Xe=0),ze.width=Fe,Je.width?Te(ze):ti&&oi(),ei.push(ze),ze={words:[]},Fe=0}function oi(){Fe>(Ze.maxWidth||0)&&(Ze.maxWidth=Fe)}const{top:ri,right:ai,bottom:hi,left:li}=t.Direction4;function ci(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const di={getDrawData:function(e,s){t.isString(e)||(e=String(e));let n=0,o=0,r=s.__getInput("width")||0,a=s.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=s;c&&(r?(n=c[li],r-=c[ai]+c[li]):s.autoSizeAlign||(n=c[li]),a?(o=c[ri],a-=c[ri]+c[hi]):s.autoSizeAlign||(o=c[ri]));const d={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,i,s){Ze=e,ei=e.rows,Je=e.bounds,ti=!Je.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=t.Platform,{width:h,height:l}=Je;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;$e=!0,qe=null,Xe=Ye=Ve=je=Fe=0,He={data:[]},ze={words:[]},n&&(i=[...i]);for(let s=0,l=i.length;s<l;s++)Ue=i[s],"\n"===Ue?(je&&si(),ze.paraEnd=!0,ni(),$e=!0):(Ne=Re(Ue),Ne===Me&&"none"!==r&&(Ue=Se(Ue,r,!je)),Ye=a.measureText(Ue).width,n&&(n<0&&(Ve=Ye),Ye+=n),Ke=Ne===Ae&&(qe===Ae||qe===Me)||qe===Ae&&Ne!==De,Qe=!(Ne!==Oe&&Ne!==Ae||qe!==We&&qe!==De),Ge=$e&&o?h-o:h,t&&h&&Fe+je+Ye>Ge&&(e?(je&&si(),Fe&&ni()):(Qe||(Qe=Ne===Me&&qe==De),Ke||Qe||Ne===Ie||Ne===Oe||Ne===Ae||je+Ye>Ge?(je&&si(),Fe&&ni()):Fe&&ni()))," "===Ue&&!0!==$e&&Fe+je===0||(Ne===Ie?(" "===Ue&&je&&si(),ii(Ue,Ye),si()):Ke||Qe?(je&&si(),ii(Ue,Ye)):ii(Ue,Ye)),qe=Ne);je&&si(),Fe&&ni(),ei.length>0&&(ei[ei.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ze.paraNumber++,Fe=a.measureText(t).width,ei.push({x:o||0,text:t,width:Fe,paraStart:!0}),ti&&oi()})}(d,e,s),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ci(e,"x",t[li]);break;case"right":ci(e,"x",-t[ai])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ci(e,"y",t[ri]);break;case"bottom":ci(e,"y",-t[hi])}}(c,d,s,r,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:v}=s,_=o*n+(d?d*(t.paraNumber-1):0),w=r;if(h&&_>v)_=Math.max(v,o),n>1&&(t.overflow=n);else if(v||u)switch(c){case"middle":p+=(v-_)/2;break;case"bottom":p+=v-_}w+=p;let m,y,x,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(m=i[r],m.x=f,m.width<g||m.width>g&&!h)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&d&&r>0&&(w+=d),m.y=w,w+=o,t.overflow>r&&w>_&&(m.isOverflow=!0,t.overflow=r+1),y=m.x,x=m.width,a<0&&(m.width<0?(x=-m.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<s.x&&(s.x=y),x>s.width&&(s.width=x),h&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(d,s),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;s.forEach(t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(d,s,r),d.overflow&&function(e,i,s,n){if(!n)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.Platform.canvas.measureText(a).width:0,c=s+n-l;("none"===i.textWrap?o:[o[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let s=i;s>-1&&(e=t.data[s],h=e.x+e.width,!(s===i&&h<c));s--){if(h<c&&" "!==e.char||!s){t.data.splice(s+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(d,s,n,r),"none"!==h&&function(e,s){let n;const{fontSize:o,textDecoration:r}=s;switch(e.decorationHeight=o/11,t.isObject(r)?(n=r.type,r.color&&(e.decorationColor=i.ColorConvert.string(r.color))):n=r,n){case"under":e.decorationY=[.15*o];break;case"delete":e.decorationY=[.35*-o];break;case"under-delete":e.decorationY=[.15*o,.35*-o]}}(d,s),d}};const ui={string:function(e,s){const n=t.isNumber(s)&&s<1;if(t.isString(e)){if(!n||!i.ColorConvert.object)return e;e=i.ColorConvert.object(e)}let o=t.isUndefined(e.a)?1:e.a;n&&(o*=s);const r=e.r+","+e.g+","+e.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign(i.TextConvert,di),Object.assign(i.ColorConvert,ui),Object.assign(i.Paint,N),Object.assign(i.PaintImage,At),Object.assign(i.PaintGradient,Zt),Object.assign(i.Effect,re),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new C(t,e,i,s),hitCanvas:(t,e)=>new n(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=C,exports.Layouter=y,exports.LeaferCanvas=n,exports.Picker=L,exports.Renderer=b,exports.Selector=B,exports.Watcher=l,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
2
  //# sourceMappingURL=web.min.cjs.map