leafer-ui 1.9.7 → 1.9.8
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/README.md +96 -85
- package/dist/web.cjs +107 -80
- package/dist/web.esm.js +109 -82
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +237 -175
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +245 -175
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
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 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:e,height:i,pixelRatio:s}=this,{style:n}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:s}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=n.width||""),n.width=e.width+"px"):t.isUndefined(i)||(n.width=i),e.height?(t.isUndefined(s)&&(this.autoHeightStr=n.height||""),n.height=e.height+"px"):t.isUndefined(s)||(n.height=s)}else n.width=e+"px",n.height=i+"px",this.view.width=Math.ceil(e*s),this.view.height=Math.ceil(i*s)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;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()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||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})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}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.stopListenPixelRatio(),!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:w,updateAllChange:_}=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){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(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:120},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),s.clipWorld(n),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),t.Platform.render(this.target,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(),s=()=>{const e=1e3/(Date.now()-i),{maxFPS:n}=this.config;if(n&&e>n-.5)return t.Platform.requestRender(s);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.Platform.requestRender(s)}__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.config={},this.target=this.canvas=null)}}b.clipSpread=10;const{hitRadiusPoint:L}=t.BoundsHelper;class E{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&&(!s.isLeafer||"draw"!==s.mode));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||L(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),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 P{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new E(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 P(t,e)}),t.Platform.layout=y.fullLayout,t.Platform.render=function(e,i,s){const n=Object.assign(Object.assign({},s),{topRendering:!0});s.topList=new t.LeafList,e.__render(i,s),s.topList.length&&s.topList.forEach(t=>t.__render(i,n))};const B={convert(t,i){const s=e.InteractionHelper.getBase(t),{x:n,y:o}=i,r=Object.assign(Object.assign({},s),{x:n,y:o,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===r.pointerType&&(r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist),r},convertMouse(t,i){const s=e.InteractionHelper.getBase(t),{x:n,y:o}=i;return Object.assign(Object.assign({},s),{x:n,y:o,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const s=B.getTouch(t),n=e.InteractionHelper.getBase(t),{x:o,y:r}=i;return Object.assign(Object.assign({},n),{x:o,y:r,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:s.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:S}=e.InteractionHelper;class k 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(R.convert(t))}onKeyUp(t){this.keyUp(R.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(B.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(B.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=B.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(B.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(B.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(B.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(B.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=B.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&S(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(B.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=B.getTouch(t);this.pointerMove(B.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=B.getTouch(t);this.pointerUp(B.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 C(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?C(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function M(t,e,i){switch(e.__.strokeAlign){case"center":O(t,1,e,i);break;case"inside":A(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?O(t,2,e,i):A(t,"outside",e,i)}}function O(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 A(e,i,s,n){const o=n.getSameCanvas(!0,!0);o.font=s.__.__font,O(e,2,s,o),o.blendMode="outside"===i?"destination-out":"destination-in",C(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:U}=t.BoundsHelper;let G;const{stintSet:Y}=t.DataHelper,{hasTransparent:V}=i.ColorConvert;function X(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,!G||!G[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)&&V(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]),G=i.PaintImage.recycleImage(e,n);for(let t,i=0,n=l.length;i<n;i++)(t=X(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:C,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,r=i.bounds;let a,h,l,c,d,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(o))d=n,a=c=o;else{const{renderShapeSpread:n}=e.__layout;let p;if(t.Platform.fullImageShadow)p=o;else{const t=n?z(r,u===f?n*u:[n*f,n*u]):r;p=U(t,o)}l=r.getFitMatrix(p);let{a:g,d:v}=l;l.a<1&&(d=i.getSameCanvas(),e.__renderShape(d,s),u*=g,f*=v),c=j(o,l),a=F(c,-l.e,-l.f);const w=s.matrix;w?(h=new t.Matrix(l),h.multiply(w),g*=w.scaleX,v*=w.scaleY):h=l,h.withScale(g,v),s=Object.assign(Object.assign({},s),{matrix:h})}return e.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:l,bounds:a,worldCanvas:d,shapeBounds:c,scaleX:u,scaleY:f}}};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:w}=e,_=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))):_&&!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":_||(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":(!_||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),w&&(m.filters=w),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,wt=new t.Bounds;const{isSame:_t}=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){Lt(e,t.ImageEvent.LOAD,i)}function xt(e,i){Lt(e,t.ImageEvent.LOADED,i)}function bt(e,i,s){i.error=s,e.forceUpdate("surface"),Lt(e,t.ImageEvent.ERROR,i)}function Lt(e,i,s){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,s))}function Et(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Pt,scale:Bt,copy:Rt}=t.MatrixHelper,{floor:St,ceil:kt,max:Ct,abs:Tt}=Math;function Mt(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:a,data:h}=i;let l,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:v,gap:w}=h;n*=s,o*=s,f&&(f=Tt(f),p=Tt(p),c=Pt(),Rt(c,g),Bt(c,1/f,1/p),n*=f,o*=p),d*=n,u*=o;const _=d*u;if(!v&&_>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(a.isSVG){const t=d/a.width;t>1&&(l=t/kt(t))}else{const t=a.width*a.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(n/=l,o/=l,d/=l,u/=l),f&&(n/=f,o/=p);const y=w&&w.x*n,x=w&&w.y*o;if(g||1!==n||1!==o){const t=d+(y||0),e=u+(x||0);n/=t/Ct(St(t),1),o/=e/Ct(St(e),1),c||(c=Pt(),g&&Rt(c,g)),Bt(c,1/n,1/o)}const b=a.getCanvas(d,u,h.opacity,h.filters,y,x,e.leafer&&e.leafer.config.smooth),L=a.getPattern(b,v||t.Platform.origin.noRepeat||"no-repeat",c,i);return i.style=L,i.patternId=r,!0}}function Ot(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&&_t(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:wt.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&&(Et(e,!0),yt(e,a)),r.loadId=h.load(()=>{Et(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=>{Et(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?Mt(e,n,h):n.patternTask||(n.patternTask=t.ImageManager.patternTasker.add(()=>Ot(this,void 0,void 0,function*(){n.patternTask=null,s.bounds.hit(e.__nowWorld)&&Mt(e,n,h),e.forceUpdate("surface")}),300)),!1)},createPattern:Mt,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:Dt}=t.AroundHelper,{hasTransparent:Wt}=i.ColorConvert,It={},Ht={};function zt(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&&Wt(a)&&(l=!0);l&&(e.isTransparent=!0)}}const{getAngle:jt,getDistance:Ft}=t.PointHelper,{get:Ut,rotateOfOuter:Gt,scaleOfOuter:Yt}=t.MatrixHelper,{toPoint:Vt}=t.AroundHelper,Xt={},Nt={};function qt(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=jt(e,i);o=Ut(),n?(Yt(o,e,r/a*(s||1),1),Gt(o,e,t+90)):(Yt(o,e,1,r/a*(s||1)),Gt(o,e,t))}return o}const{getDistance:Kt}=t.PointHelper,{toPoint:Qt}=t.AroundHelper,$t={},Zt={};const Jt={linearGradient:function(e,i){let{from:s,to:n,type:o,opacity:r}=e;Dt(s||"top",i,It),Dt(n||"bottom",i,Ht);const a=t.Platform.canvas.createLinearGradient(It.x,It.y,Ht.x,Ht.y),h={type:o,style:a};return zt(h,a,e.stops,r),h},radialGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;Vt(s||"center",i,Xt),Vt(n||"bottom",i,Nt);const h=t.Platform.canvas.createRadialGradient(Xt.x,Xt.y,0,Xt.x,Xt.y,Ft(Xt,Nt)),l={type:o,style:h};zt(l,h,e.stops,r);const c=qt(i,Xt,Nt,a,!0);return c&&(l.transform=c),l},conicGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;Qt(s||"center",i,$t),Qt(n||"bottom",i,Zt);const h=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,$t.x,$t.y):t.Platform.canvas.createRadialGradient($t.x,$t.y,0,$t.x,$t.y,Kt($t,Zt)),l={type:o,style:h};zt(l,h,e.stops,r);const c=qt(i,$t,Zt,a||1,t.Platform.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:qt},{copy:te,toOffsetOutBounds:ee}=t.BoundsHelper,ie={},se={};function ne(e,i,s,n){const{bounds:o,shapeBounds:r}=n;if(t.Platform.fullImageShadow){if(te(ie,e.bounds),ie.x+=i.x-r.x,ie.y+=i.y-r.y,s){const{fitMatrix:t}=n;ie.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),ie.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),ie.width*=s,ie.height*=s}e.copyWorld(n.canvas,e.bounds,ie)}else s&&(te(ie,i),ie.x-=i.width/2*(s-1),ie.y-=i.height/2*(s-1),ie.width*=s,ie.height*=s),e.copyWorld(n.canvas,r,s?ie:i)}const{toOffsetOutBounds:oe}=t.BoundsHelper,re={};const ae={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;ee(d,se),l.forEach((l,w)=>{let _=1;if(l.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}g.setWorldShadow(se.offsetX+l.x*f*_,se.offsetY+l.y*p*_,l.blur*f*_,i.ColorConvert.string(l.color)),r=l.spread?1+2*l.spread/(h.boxBounds.width+2*(h.strokeBoxSpread||0))*_:0,ne(g,se,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")),i.Effect.isTransformShadow(l)?i.Effect.renderTransformShadow(e,s,g,o,l):t.LeafHelper.copyCanvasByWorld(e,s,g,o,l.blendMode),v&&w<v&&g.clearWorld(o)}),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;oe(d,re),l.forEach((l,w)=>{let _=1;if(l.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}g.save(),g.setWorldShadow(re.offsetX+l.x*f*_,re.offsetY+l.y*p*_,l.blur*f*_),r=l.spread?1-2*l.spread/(h.boxBounds.width+2*(h.strokeBoxSpread||0))*_:0,ne(g,re,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&&w<v&&g.clearWorld(o)}),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){},getShadowSpread:function(t,e){let i=0;return e.forEach(t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),i},isTransformShadow(t){}},{excludeRenderBounds:he}=t.LeafBoundsHelper;let le;function ce(t,e,i,s,n,o,r,a){switch(e){case"grayscale":le||(le=!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);ue(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":ue(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function de(t){return t.getSameCanvas(!1,!0)}function ue(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)}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&&(ce(this,r,t,n,s,o,void 0,!0),s=n=null),o=i.__.opacity,le=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=de(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=de(t)),n||(n=de(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a||he(i,e)||i.__render(t,e);continue}const c=1===o&&i.__.__blendMode;c&&ce(this,r,t,n,s,o,void 0,!1),he(i,e)||i.__render(n||t,e),c&&ce(this,r,t,n,s,o,c,!1)}ce(this,r,t,n,s,o,void 0,!0)};const fe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",pe=fe+"_#~&*+\\=|≮≯≈≠=…",ge=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 ve(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const we=ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),_e=ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),me=ve(fe),ye=ve(pe),xe=ve("- —/~|┆·");var be;!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"}(be||(be={}));const{Letter:Le,Single:Ee,Before:Pe,After:Be,Symbol:Re,Break:Se}=be;function ke(t){return we[t]?Le:xe[t]?Se:_e[t]?Pe:me[t]?Be:ye[t]?Re:ge.test(t)?Ee:Le}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 Te(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:Me}=Ce,{Letter:Oe,Single:Ae,Before:De,After:We,Symbol:Ie,Break:He}=be;let ze,je,Fe,Ue,Ge,Ye,Ve,Xe,Ne,qe,Ke,Qe,$e,Ze,Je,ti,ei,ii=[];function si(t,e){Ne&&!Xe&&(Xe=Ne),ze.data.push({char:t,width:e}),Fe+=e}function ni(){Ue+=Fe,ze.width=Fe,je.words.push(ze),ze={data:[]},Fe=0}function oi(){Ze&&(Je.paraNumber++,je.paraStart=!0,Ze=!1),Ne&&(je.startCharSize=Xe,je.endCharSize=Ne,Xe=0),je.width=Ue,ti.width?Me(je):ei&&ri(),ii.push(je),je={words:[]},Ue=0}function ri(){Ue>(Je.maxWidth||0)&&(Je.maxWidth=Ue)}const{top:ai,right:hi,bottom:li,left:ci}=t.Direction4;function di(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 ui={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[ci],r-=c[hi]+c[ci]):s.autoSizeAlign||(n=c[ci]),a?(o=c[ai],a-=c[ai]+c[li]):s.autoSizeAlign||(o=c[ai]));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){Je=e,ii=e.rows,ti=e.bounds,ei=!ti.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=t.Platform,{width:h,height:l}=ti;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Ze=!0,Ke=null,Xe=Ve=Ne=Fe=Ue=0,ze={data:[]},je={words:[]},n&&(i=[...i]);for(let s=0,l=i.length;s<l;s++)Ye=i[s],"\n"===Ye?(Fe&&ni(),je.paraEnd=!0,oi(),Ze=!0):(qe=ke(Ye),qe===Oe&&"none"!==r&&(Ye=Te(Ye,r,!Fe)),Ve=a.measureText(Ye).width,n&&(n<0&&(Ne=Ve),Ve+=n),Qe=qe===Ae&&(Ke===Ae||Ke===Oe)||Ke===Ae&&qe!==We,$e=!(qe!==De&&qe!==Ae||Ke!==Ie&&Ke!==We),Ge=Ze&&o?h-o:h,t&&h&&Ue+Fe+Ve>Ge&&(e?(Fe&&ni(),Ue&&oi()):($e||($e=qe===Oe&&Ke==We),Qe||$e||qe===He||qe===De||qe===Ae||Fe+Ve>Ge?(Fe&&ni(),Ue&&oi()):Ue&&oi()))," "===Ye&&!0!==Ze&&Ue+Fe===0||(qe===He?(" "===Ye&&Fe&&ni(),si(Ye,Ve),ni()):Qe||$e?(Fe&&ni(),si(Ye,Ve)):si(Ye,Ve)),Ke=qe);Fe&&ni(),Ue&&oi(),ii.length>0&&(ii[ii.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Je.paraNumber++,Ue=a.measureText(t).width,ii.push({x:o||0,text:t,width:Ue,paraStart:!0}),ei&&ri()})}(d,e,s),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":di(e,"x",t[ci]);break;case"right":di(e,"x",-t[hi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":di(e,"y",t[ai]);break;case"bottom":di(e,"y",-t[li])}}(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,w=o*n+(d?d*(t.paraNumber-1):0),_=r;if(h&&w>v)w=Math.max(v,o),n>1&&(t.overflow=n);else if(v||u)switch(c){case"middle":p+=(v-w)/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&&(_+=d),m.y=_,_+=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=w}(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,o=0;const{fontSize:r,textDecoration:a}=s;switch(e.decorationHeight=r/11,t.isObject(a)?(n=a.type,a.color&&(e.decorationColor=i.ColorConvert.string(a.color)),a.offset&&(o=Math.min(.3*r,Math.max(a.offset,.15*-r)))):n=a,n){case"under":e.decorationY=[.15*r+o];break;case"delete":e.decorationY=[.35*-r];break;case"under-delete":e.decorationY=[.15*r+o,.35*-r]}}(d,s),d}};const fi={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,ui),Object.assign(i.ColorConvert,fi),Object.assign(i.Paint,N),Object.assign(i.PaintImage,At),Object.assign(i.PaintGradient,Jt),Object.assign(i.Effect,ae),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new k(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=k,exports.Layouter=y,exports.LeaferCanvas=n,exports.Picker=E,exports.Renderer=b,exports.Selector=P,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&&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:e,height:i,pixelRatio:s}=this,{style:n}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:s}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=n.width||""),n.width=e.width+"px"):t.isUndefined(i)||(n.width=i),e.height?(t.isUndefined(s)&&(this.autoHeightStr=n.height||""),n.height=e.height+"px"):t.isUndefined(s)||(n.height=s)}else n.width=e+"px",n.height=i+"px",this.view.width=Math.ceil(e*s),this.view.height=Math.ceil(i*s)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;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()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||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})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}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.stopListenPixelRatio(),!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:w,updateAllChange:_}=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){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(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:120},this.frames=[],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),s.clipWorld(n),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),t.Platform.render(this.target,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);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&e>s)return t.Platform.requestRender(i);const{frames:n}=this;n.length>30&&n.shift(),n.push(e),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__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.config={},this.target=this.canvas=null)}}b.clipSpread=10;const{hitRadiusPoint:L}=t.BoundsHelper;class E{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&&(!s.isLeafer||"draw"!==s.mode));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||L(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),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 P{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new E(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 P(t,e)}),t.Platform.layout=y.fullLayout,t.Platform.render=function(e,i,s){const n=Object.assign(Object.assign({},s),{topRendering:!0});s.topList=new t.LeafList,e.__render(i,s),s.topList.length&&s.topList.forEach(t=>t.__render(i,n))};const B={convert(t,i){const s=e.InteractionHelper.getBase(t),{x:n,y:o}=i,r=Object.assign(Object.assign({},s),{x:n,y:o,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===r.pointerType&&(r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist),r},convertMouse(t,i){const s=e.InteractionHelper.getBase(t),{x:n,y:o}=i;return Object.assign(Object.assign({},s),{x:n,y:o,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const s=B.getTouch(t),n=e.InteractionHelper.getBase(t),{x:o,y:r}=i;return Object.assign(Object.assign({},n),{x:o,y:r,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:s.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},S={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 k 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(S.convert(t))}onKeyUp(t){this.keyUp(S.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(B.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(B.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=B.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(B.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(B.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(B.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(B.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=B.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(B.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=B.getTouch(t);this.pointerMove(B.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=B.getTouch(t);this.pointerUp(B.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 C(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?C(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function M(t,e,i){switch(e.__.strokeAlign){case"center":O(t,1,e,i);break;case"inside":A(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?O(t,2,e,i):A(t,"outside",e,i)}}function O(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 A(e,i,s,n){const o=n.getSameCanvas(!0,!0);o.font=s.__.__font,O(e,2,s,o),o.blendMode="outside"===i?"destination-out":"destination-in",C(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,copyAndSpread:F,toOuterOf:j,getOuterOf:U,getByMove:G,move:Y,getIntersectData:V}=t.BoundsHelper,X={};let N;const{stintSet:q}=t.DataHelper,{hasTransparent:K}=i.ColorConvert;function Q(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,!N||!N[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)&&K(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 $={compute:function(e,s){const n=s.__,o=[];let r,a,h,l=n.__input[e];t.isArray(l)||(l=[l]),N=i.PaintImage.recycleImage(e,n);for(let t,i=0,n=l.length;i<n;i++)(t=Q(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?(q(n,"__isAlphaPixelFill",r),q(n,"__isTransparentFill",a)):(q(n,"__isAlphaPixelStroke",r),q(n,"__isTransparentStroke",a),q(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:C,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=i.bounds,r=e.__nowWorld,a=e.__layout,h=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let l,c,d,u,f,p;j(a.strokeSpread?(F(X,a.boxBounds,a.strokeSpread),X):a.boxBounds,r,h);let{scaleX:g,scaleY:v}=e.getRenderScaleData(!0);if(o.includes(h))p=n,l=f=h,c=r;else{let n;if(t.Platform.fullImageShadow)n=h;else{const e=a.renderShapeSpread?z(o,t.FourNumberHelper.swapAndScale(a.renderShapeSpread,g,v)):o;n=V(e,h)}u=o.getFitMatrix(n);let{a:w,d:_}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,s),g*=w,v*=_),f=U(h,u),l=G(f,-u.e,-u.f),c=U(r,u),Y(c,-u.e,-u.f);const m=s.matrix;m?(d=new t.Matrix(u),d.multiply(m),w*=m.scaleX,_*=m.scaleY):d=u,d.withScale(w,_),s=Object.assign(Object.assign({},s),{matrix:d})}return e.__renderShape(n,s),{canvas:n,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:v}}};let Z={},J=t.getMatrixData();const{get:tt,rotateOfOuter:et,translate:it,scaleOfOuter:st,multiplyParent:nt,scale:ot,rotate:rt,skew:at}=t.MatrixHelper;function ht(t,e,i,s,n,o,r){const a=tt();it(a,e.x+i,e.y+s),ot(a,n,o),r&&et(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function lt(t,e,i,s,n,o,r,a,h,l){const c=tt();dt(c,e,i,s,n,o,r,a),h&&(J.a=h,J.d=l,nt(c,J)),t.transform=c}function ct(t,e,i,s,n,o,r,a,h,l,c,d){const u=tt();if(d)dt(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)et(u,{x:i/2,y:s/2},h);else switch(rt(u,h),h){case 90:it(u,s,0);break;case 180:it(u,i,s);break;case 270:it(u,0,i)}Z.x=e.x+n,Z.y=e.y+o,it(u,Z.x,Z.y),r&&st(u,Z,r,a)}t.transform=u}function dt(t,e,i,s,n,o,r,a){r&&rt(t,r),a&&at(t,a.x,a.y),n&&ot(t,n,o),it(t,e.x+i,e.y+s)}const{get:ut,translate:ft}=t.MatrixHelper,pt=new t.Bounds,gt={},vt={};function wt(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=_t(i,s,e)}function _t(e,i,s){e.padding&&(i=pt.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:w}=e,_=i.width===n&&i.height===o,m={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(vt,0,0,y?o:n,y?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(t.MathHelper.getScaleData(c,d,s,gt),x=gt.scaleX,b=gt.scaleY),(h||v||g)&&(x&&t.BoundsHelper.scale(vt,x,b,!0),h&&t.AlignHelper.toPoint(h,vt,i,vt,!0,!0))):_&&!u||(x=b=t.BoundsHelper.getFitScale(i,vt,"fit"!==a),t.BoundsHelper.put(i,s,h,x,!1,vt),t.BoundsHelper.scale(vt,x,b,!0)),l&&t.PointHelper.move(vt,l),a){case"stretch":_||(n=i.width,o=i.height);break;case"normal":case"clip":if(vt.x||vt.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),lt(m,i,vt.x,vt.y,x,b,u,f,t,e),t&&(x=x?x*t:x,b=b?b*e:e)}break;case"repeat":(!_||x||u||f)&&ct(m,i,n,o,vt.x,vt.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:mt(r,s,o.width,i&&i.x),y:mt(a,n,o.height,i&&i.y)}}(v,s&&g,vt.width,vt.height,i));break;default:x&&ht(m,i,vt.x,vt.y,x,b,u)}return m.transform||(i.x||i.y)&&(m.transform=ut(),ft(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),w&&(m.filters=w),g&&(m.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),m}function mt(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 yt,xt=new t.Bounds;const{isSame:bt}=t.BoundsHelper;function Lt(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||wt(n,s,i,o),!0}function Et(e,i){St(e,t.ImageEvent.LOAD,i)}function Pt(e,i){St(e,t.ImageEvent.LOADED,i)}function Bt(e,i,s){i.error=s,e.forceUpdate("surface"),St(e,t.ImageEvent.ERROR,i)}function St(e,i,s){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,s))}function Rt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:kt,scale:Ct,copy:Tt}=t.MatrixHelper,{floor:Mt,ceil:Ot,max:At,abs:Dt}=Math;function Wt(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:a,data:h}=i;let l,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:v,gap:w}=h;n*=s,o*=s,f&&(f=Dt(f),p=Dt(p),c=kt(),Tt(c,g),Ct(c,1/f,1/p),n*=f,o*=p),d*=n,u*=o;const _=d*u;if(!v&&_>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(a.isSVG){const t=d/a.width;t>1&&(l=t/Ot(t))}else{const t=a.width*a.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(n/=l,o/=l,d/=l,u/=l),f&&(n/=f,o/=p);const y=w&&w.x*n,x=w&&w.y*o;if(g||1!==n||1!==o){const t=d+(y||0),e=u+(x||0);n/=t/At(Mt(t),1),o/=e/At(Mt(e),1),c||(c=kt(),g&&Tt(c,g)),Ct(c,1/n,1/o)}const b=a.getCanvas(d,u,h.opacity,h.filters,y,x,e.leafer&&e.leafer.config.smooth),L=a.getPattern(b,v||t.Platform.origin.noRepeat||"no-repeat",c,i);return i.style=L,i.patternId=r,!0}}function It(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 Ht={image:function(e,i,s,n,o){let r,a;const h=t.ImageManager.get(s);return yt&&s===yt.paint&&bt(n,yt.boxBounds)?r=yt.leafPaint:(r={type:s.type,image:h},h.hasAlphaPixel&&(r.isTransparent=!0),yt=h.use>1?{leafPaint:r,paint:s,boxBounds:xt.set(n)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:s}),h.ready?(Lt(e,i,s,h,r,n),o&&(Et(e,a),Pt(e,a))):h.error?o&&Bt(e,a,h.error):(o&&(Rt(e,!0),Et(e,a)),r.loadId=h.load(()=>{Rt(e,!1),e.destroyed||(Lt(e,i,s,h,r,n)&&(h.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),Pt(e,a)),r.loadId=void 0},t=>{Rt(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?Wt(e,n,h):n.patternTask||(n.patternTask=t.ImageManager.patternTasker.add(()=>It(this,void 0,void 0,function*(){n.patternTask=null,s.bounds.hit(e.__nowWorld)&&Wt(e,n,h),e.forceUpdate("surface")}),300)),!1)},createPattern:Wt,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:wt,getPatternData:_t,fillOrFitMode:ht,clipMode:lt,repeatMode:ct},{toPoint:zt}=t.AroundHelper,{hasTransparent:Ft}=i.ColorConvert,jt={},Ut={};function Gt(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&&Ft(a)&&(l=!0);l&&(e.isTransparent=!0)}}const{getAngle:Yt,getDistance:Vt}=t.PointHelper,{get:Xt,rotateOfOuter:Nt,scaleOfOuter:qt}=t.MatrixHelper,{toPoint:Kt}=t.AroundHelper,Qt={},$t={};function Zt(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Yt(e,i);o=Xt(),n?(qt(o,e,r/a*(s||1),1),Nt(o,e,t+90)):(qt(o,e,1,r/a*(s||1)),Nt(o,e,t))}return o}const{getDistance:Jt}=t.PointHelper,{toPoint:te}=t.AroundHelper,ee={},ie={};const se={linearGradient:function(e,i){let{from:s,to:n,type:o,opacity:r}=e;zt(s||"top",i,jt),zt(n||"bottom",i,Ut);const a=t.Platform.canvas.createLinearGradient(jt.x,jt.y,Ut.x,Ut.y),h={type:o,style:a};return Gt(h,a,e.stops,r),h},radialGradient: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.canvas.createRadialGradient(Qt.x,Qt.y,0,Qt.x,Qt.y,Vt(Qt,$t)),l={type:o,style:h};Gt(l,h,e.stops,r);const c=Zt(i,Qt,$t,a,!0);return c&&(l.transform=c),l},conicGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;te(s||"center",i,ee),te(n||"bottom",i,ie);const h=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,ee.x,ee.y):t.Platform.canvas.createRadialGradient(ee.x,ee.y,0,ee.x,ee.y,Jt(ee,ie)),l={type:o,style:h};Gt(l,h,e.stops,r);const c=Zt(i,ee,ie,a||1,t.Platform.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Zt},{copy:ne,move:oe,toOffsetOutBounds:re}=t.BoundsHelper,{max:ae}=Math,he={},le=new t.Matrix,ce={};function de(t,e){let i,s,n,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=t.spread||0,o=1.5*(t.blur||0),r=ae(r,n+o-s),a=ae(a,n+o+i),h=ae(h,n+o+s),l=ae(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function ue(t,e,i,s,n,o,r){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*o*(r?-1:1);return le.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),le}}function fe(e,i,s){const{shapeBounds:n}=s;let o,r;t.Platform.fullImageShadow?(ne(he,e.bounds),oe(he,i.x-n.x,i.y-n.y),o=e.bounds,r=he):(o=n,r=i),e.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:pe}=t.BoundsHelper,ge={};const ve=de;const we={shadow:function(e,s,n){let o,r;const{__nowWorld:a}=e,{shadow:h}=e.__,{worldCanvas:l,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=n,g=s.getSameCanvas(),v=h.length-1;re(c,ce,d),h.forEach((h,w)=>{let _=1;if(h.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}g.setWorldShadow(ce.offsetX+h.x*f*_,ce.offsetY+h.y*p*_,h.blur*f*_,i.ColorConvert.string(h.color)),r=ue(e,g,n,h,ce,_),r&&g.setTransform(r),fe(g,ce,n),r&&g.resetTransform(),o=d,h.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),o=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(n.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,s,g,o,h.blendMode),v&&w<v&&g.clearWorld(o)}),g.recycle(o)},innerShadow:function(e,s,n){let o,r;const{__nowWorld:a}=e,{innerShadow:h}=e.__,{worldCanvas:l,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=n,g=s.getSameCanvas(),v=h.length-1;pe(c,ge,d),h.forEach((h,w)=>{let _=1;if(h.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}g.save(),g.setWorldShadow(ge.offsetX+h.x*f*_,ge.offsetY+h.y*p*_,h.blur*f*_),r=ue(e,g,0,h,ge,_,!0),r&&g.setTransform(r),fe(g,ge,n),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),o=a):(g.copyWorld(n.canvas,u,c,"source-out"),o=d),g.fillWorld(o,i.ColorConvert.string(h.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,s,g,o,h.blendMode),v&&w<v&&g.clearWorld(o)}),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){},getShadowRenderSpread:de,getShadowTransform:ue,isTransformShadow(t){},getInnerShadowSpread:ve},{excludeRenderBounds:_e}=t.LeafBoundsHelper;let me;function ye(t,e,i,s,n,o,r,a){switch(e){case"grayscale":me||(me=!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);be(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":be(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function xe(t){return t.getSameCanvas(!1,!0)}function be(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)}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&&(ye(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||_e(i,e)||i.__render(t,e),o=i.__.opacity,me=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=xe(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=xe(t)),n||(n=xe(t)),i.__render(s,e));continue}const c=1===o&&i.__.__blendMode;c&&ye(this,r,t,n,s,o,void 0,!1),_e(i,e)||i.__render(n||t,e),c&&ye(this,r,t,n,s,o,c,!1)}ye(this,r,t,n,s,o,void 0,!0)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ee=Le+"_#~&*+\\=|≮≯≈≠=…",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 Be(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Se=Be("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Re=Be("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ke=Be(Le),Ce=Be(Ee),Te=Be("- —/~|┆·");var Me;!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"}(Me||(Me={}));const{Letter:Oe,Single:Ae,Before:De,After:We,Symbol:Ie,Break:He}=Me;function ze(t){return Se[t]?Oe:Te[t]?He:Re[t]?De:ke[t]?We:Ce[t]?Ie:Pe.test(t)?Ae:Oe}const Fe={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 je(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ue}=Fe,{Letter:Ge,Single:Ye,Before:Ve,After:Xe,Symbol:Ne,Break:qe}=Me;let Ke,Qe,$e,Ze,Je,ti,ei,ii,si,ni,oi,ri,ai,hi,li,ci,di,ui=[];function fi(t,e){si&&!ii&&(ii=si),Ke.data.push({char:t,width:e}),$e+=e}function pi(){Ze+=$e,Ke.width=$e,Qe.words.push(Ke),Ke={data:[]},$e=0}function gi(){hi&&(li.paraNumber++,Qe.paraStart=!0,hi=!1),si&&(Qe.startCharSize=ii,Qe.endCharSize=si,ii=0),Qe.width=Ze,ci.width?Ue(Qe):di&&vi(),ui.push(Qe),Qe={words:[]},Ze=0}function vi(){Ze>(li.maxWidth||0)&&(li.maxWidth=Ze)}const{top:wi,right:_i,bottom:mi,left:yi}=t.Direction4;function xi(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 bi={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[yi],r-=c[_i]+c[yi]):s.autoSizeAlign||(n=c[yi]),a?(o=c[wi],a-=c[wi]+c[mi]):s.autoSizeAlign||(o=c[wi]));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){li=e,ui=e.rows,ci=e.bounds,di=!ci.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=t.Platform,{width:h,height:l}=ci;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;hi=!0,oi=null,ii=ei=si=$e=Ze=0,Ke={data:[]},Qe={words:[]},n&&(i=[...i]);for(let s=0,l=i.length;s<l;s++)ti=i[s],"\n"===ti?($e&&pi(),Qe.paraEnd=!0,gi(),hi=!0):(ni=ze(ti),ni===Ge&&"none"!==r&&(ti=je(ti,r,!$e)),ei=a.measureText(ti).width,n&&(n<0&&(si=ei),ei+=n),ri=ni===Ye&&(oi===Ye||oi===Ge)||oi===Ye&&ni!==Xe,ai=!(ni!==Ve&&ni!==Ye||oi!==Ne&&oi!==Xe),Je=hi&&o?h-o:h,t&&h&&Ze+$e+ei>Je&&(e?($e&&pi(),Ze&&gi()):(ai||(ai=ni===Ge&&oi==Xe),ri||ai||ni===qe||ni===Ve||ni===Ye||$e+ei>Je?($e&&pi(),Ze&&gi()):Ze&&gi()))," "===ti&&!0!==hi&&Ze+$e===0||(ni===qe?(" "===ti&&$e&&pi(),fi(ti,ei),pi()):ri||ai?($e&&pi(),fi(ti,ei)):fi(ti,ei)),oi=ni);$e&&pi(),Ze&&gi(),ui.length>0&&(ui[ui.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{li.paraNumber++,Ze=a.measureText(t).width,ui.push({x:o||0,text:t,width:Ze,paraStart:!0}),di&&vi()})}(d,e,s),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":xi(e,"x",t[yi]);break;case"right":xi(e,"x",-t[_i])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":xi(e,"y",t[wi]);break;case"bottom":xi(e,"y",-t[mi])}}(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,w=o*n+(d?d*(t.paraNumber-1):0),_=r;if(h&&w>v)w=Math.max(v,o),n>1&&(t.overflow=n);else if(v||u)switch(c){case"middle":p+=(v-w)/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&&(_+=d),m.y=_,_+=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=w}(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,o=0;const{fontSize:r,textDecoration:a}=s;switch(e.decorationHeight=r/11,t.isObject(a)?(n=a.type,a.color&&(e.decorationColor=i.ColorConvert.string(a.color)),a.offset&&(o=Math.min(.3*r,Math.max(a.offset,.15*-r)))):n=a,n){case"under":e.decorationY=[.15*r+o];break;case"delete":e.decorationY=[.35*-r];break;case"under-delete":e.decorationY=[.15*r+o,.35*-r]}}(d,s),d}};const Li={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,bi),Object.assign(i.ColorConvert,Li),Object.assign(i.Paint,$),Object.assign(i.PaintImage,Ht),Object.assign(i.PaintGradient,se),Object.assign(i.Effect,we),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new k(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=k,exports.Layouter=y,exports.LeaferCanvas=n,exports.Picker=E,exports.Renderer=b,exports.Selector=P,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
|