leafer-ui 1.9.7 → 1.9.9

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.
@@ -1,2 +1,2 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,isUndefined as n,DataHelper as o,canvasSizeAttrs as r,ResizeEvent as a,canvasPatch as h,FileHelper as l,Creator as c,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as w,PropertyEvent as _,LeafHelper as v,BranchHelper as m,LeafBoundsHelper as y,Bounds as x,isArray as b,LeafLevelList as B,LayoutEvent as k,Run as L,ImageManager as E,BoundsHelper as S,Plugin as T,MathHelper as R,isObject as P,Matrix as M,getMatrixData as C,MatrixHelper as A,AlignHelper as O,PointHelper as D,ImageEvent as W,AroundHelper as I,Direction4 as z,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as j,InteractionBase as U,Cursor as G,HitCanvasManager as Y}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as V,Paint as X,ColorConvert as H,PaintGradient as N,Export as q,Effect as K,Group as Q,TextConvert as $}from"@leafer-ui/draw";const Z=t.get("LeaferCanvas");class J extends e{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:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):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"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else Z.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;if(this.unreal){const{config:t,autoWidthStr:e,autoHeightStr:i}=this;t.width?(n(e)&&(this.autoWidthStr=s.width||""),s.width=t.width+"px"):n(e)||(s.width=e),t.height?(n(i)&&(this.autoHeightStr=s.height||""),s.height=t.height+"px"):n(i)||(s.height=i)}else s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(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),Z.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()),i.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;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(t){const e={};o.copyAttrs(e,this,r),this.resize(t),this.resizeListener&&!n(this.width)&&this.resizeListener(new a(t,e))}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()}}}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype);const{mineType:tt,fileType:et}=l;function it(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=tt(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,tt(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(tt(et(e)),s);return i.origin.download(n,e)},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:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new J(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:st}=navigator;st.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),st.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):st.indexOf("Mac")>-1?i.os="Mac":st.indexOf("Linux")>-1&&(i.os="Linux");class nt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=o.default(e,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(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.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 w(w.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[_.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[w.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:ot,updateBounds:rt,updateChange:at}=v,{pushAllChildBranch:ht,pushAllParent:lt}=m;const{worldBounds:ct}=y;class dt{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ct)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ct),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:ut,updateAllChange:ft}=v,pt=t.get("Layouter");class gt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new B,this.target=t,e&&(this.config=o.default(e,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:t}=this;this.times=0;try{t.emit(k.START),this.layoutOnce(),t.emitEvent(new k(k.END,this.layoutedBlocks,this.times))}catch(t){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(w.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=L.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=k,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new k(n,a,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(ot(t,!0),e.add(t),t.isBranch&&ht(t,e),lt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),lt(t,e)))})}(s,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||rt(s[t])}rt(i)}})}(this.__levelList),function(t){t.list.forEach(at)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new k(o,a,this.times)),i.emitEvent(new k(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,L.end(e)}fullLayout(){const t=L.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=k,o=this.getBlocks(new f(e));e.emitEvent(new k(i,o,this.times)),gt.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new k(s,o,this.times)),e.emitEvent(new k(n,o,this.times)),this.addBlocks(o),L.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?m.updateBounds(t):v.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new dt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new dt(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_([[k.REQUEST,this.layout,this],[k.AGAIN,this.layoutAgain,this],[w.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const wt=t.get("Renderer");class _t{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=t,this.canvas=e,i&&(this.config=o.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(k.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,wt.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,wt.error(t)}wt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return wt.warn("rendering");if(this.times>3)return wt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.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(t){const e=L.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(_t.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),L.end(e)}fullRender(){const t=L.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),L.end(t)}__render(e,s){const{canvas:n}=this,o=e.includes(this.target.__world),r=o?{includes:o}:{bounds:e,includes:o};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),i.render(this.target,n,r),this.renderBounds=s=s||e,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),n.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const e=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-e),{maxFPS:n}=this.config;if(n&&t>n-.5)return i.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};i.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(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||wt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[k.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}_t.clipSpread=10;const{hitRadiusPoint:vt}=S;class mt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new f(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new f;if(t.length){let e;const{x:n,y:o}=this.point,r={x:n,y:o,radiusX:0,radiusY:0};for(let n=0,o=t.length;n<o;n++)if(e=t[n],(i||v.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&v.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>v.worldHittable(t))}getPath(t){const e=new f;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new f;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}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||vt(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 yt{constructor(t,e){this.config={},e&&(this.config=o.default(e,this.config)),this.picker=new mt(this.target=t,this),this.finder=c.finder&&c.finder()}getByPoint(t,e,s){const{target:n,picker:o}=this;return i.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,e,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):T.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(c,{watcher:(t,e)=>new nt(t,e),layouter:(t,e)=>new gt(t,e),renderer:(t,e,i)=>new _t(t,e,i),selector:(t,e)=>new yt(t,e)}),i.layout=gt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const xt={convert(t,e){const i=j.getBase(t),{x:s,y:n}=e,o=Object.assign(Object.assign({},i),{x:s,y:n,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===o.pointerType&&(o.tangentialPressure=t.tangentialPressure,o.tiltX=t.tiltX,o.tiltY=t.tiltY,o.twist=t.twist),o},convertMouse(t,e){const i=j.getBase(t),{x:s,y:n}=e;return Object.assign(Object.assign({},i),{x:s,y:n,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=xt.getTouch(t),s=j.getBase(t),{x:n,y:o}=e;return Object.assign(Object.assign({},s),{x:n,y:o,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},bt={convert(t){const e=j.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:Bt}=j;class kt extends U{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(bt.convert(t))}onKeyUp(t){this.keyUp(bt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(xt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(xt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=xt.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(xt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(xt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(xt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(xt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=xt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&Bt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(xt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=xt.getTouch(t);this.pointerMove(xt.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=xt.getTouch(t);this.pointerUp(xt.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 e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(j.getBase(t),i),this.touches=e)}}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({},j.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(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=j.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),P(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>P(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,b(t))t.forEach(t=>this.eachCursor(t,e,i));else{const n=s(t)&&G.get(t);n&&i<2?this.eachCursor(n,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Lt(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 Et(t,e){t.__.__font?Lt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function St(t,e,i){switch(e.__.strokeAlign){case"center":Tt(t,1,e,i);break;case"inside":Rt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Tt(t,2,e,i):Rt(t,"outside",e,i)}}function Tt(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Pt(i,s))}function Rt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Tt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Lt(i,n),n.blendMode="normal",v.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Pt(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 Mt(t,e,i,s,n){let o;const r=s.__,{__hasMultiStrokeStyle:a}=r;a||n.setStroke(void 0,r.__strokeWidth*e,r);for(let h=0,l=t.length;h<l;h++)if(o=t[h],(!o.image||!V.checkImage(s,n,o,!1))&&o.style){if(a){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.blendMode?(n.saveBlendMode(o.blendMode),i?Pt(s,n):n.stroke(),n.restoreBlendMode()):i?Pt(s,n):n.stroke()}}function Ct(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)St(t,e,i);else switch(s.strokeAlign){case"center":At(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),At(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)At(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),At(t,2,e,o),o.clipUI(s),o.clearWorld(n),v.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i)}}function At(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&X.strokeArrow(t,i,s)}const{getSpread:Ot,getOuterOf:Dt,getByMove:Wt,getIntersectData:It}=S;let zt;const{stintSet:Ft}=o,{hasTransparent:jt}=H;function Ut(t,e,i){if(!P(e)||!1===e.visible||0===e.opacity)return;let o;const{boxBounds:r}=i.__layout;switch(e.type){case"image":o=V.image(i,t,e,r,!zt||!zt[e.url]);break;case"linear":o=N.linearGradient(e,r);break;case"radial":o=N.radialGradient(e,r);break;case"angular":o=N.conicGradient(e,r);break;case"solid":const{type:s,color:a,opacity:h}=e;o={type:s,style:H.string(a,h)};break;default:n(e.r)||(o={type:"solid",style:H.string(e)})}if(o){if(s(o.style)&&jt(o.style)&&(o.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;o.strokeStyle=e.style}e.editing&&(o.editing=e.editing),e.blendMode&&(o.blendMode=e.blendMode)}return o}const Gt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),zt=V.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Ut(t,a[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),o=!0),"fill"===t?(Ft(i,"__isAlphaPixelFill",n),Ft(i,"__isTransparentFill",o)):(Ft(i,"__isAlphaPixelStroke",n),Ft(i,"__isTransparentStroke",o),Ft(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,Et(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(V.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),Et(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Et(e,i),i.restoreBlendMode()):Et(e,i)}},fillPathOrText:Et,fillText:Lt,stroke:Ct,strokes:function(t,e,i){Ct(t,e,i)},strokeText:St,drawTextStroke:Pt,shape:function(t,e,s){const n=e.getSameCanvas(),o=t.__nowWorld,r=e.bounds;let a,h,l,c,d,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(r.includes(o))d=n,a=c=o;else{const{renderShapeSpread:n}=t.__layout;let p;if(i.fullImageShadow)p=o;else{const t=n?Ot(r,u===f?n*u:[n*f,n*u]):r;p=It(t,o)}l=r.getFitMatrix(p);let{a:g,d:w}=l;l.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,s),u*=g,f*=w),c=Dt(o,l),a=Wt(c,-l.e,-l.f);const _=s.matrix;_?(h=new M(l),h.multiply(_),g*=_.scaleX,w*=_.scaleY):h=l,h.withScale(g,w),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:l,bounds:a,worldCanvas:d,shapeBounds:c,scaleX:u,scaleY:f}}};let Yt={},Vt=C();const{get:Xt,rotateOfOuter:Ht,translate:Nt,scaleOfOuter:qt,multiplyParent:Kt,scale:Qt,rotate:$t,skew:Zt}=A;function Jt(t,e,i,s,n,o,r){const a=Xt();Nt(a,e.x+i,e.y+s),Qt(a,n,o),r&&Ht(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function te(t,e,i,s,n,o,r,a,h){const l=Xt();ie(l,e,i,s,n,o,r,a),h&&(Vt.a=e.width/h.width,Vt.d=e.height/h.height,Kt(l,Vt)),t.transform=l}function ee(t,e,i,s,n,o,r,a,h,l,c,d){const u=Xt();if(d)ie(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)Ht(u,{x:i/2,y:s/2},h);else switch($t(u,h),h){case 90:Nt(u,s,0);break;case 180:Nt(u,i,s);break;case 270:Nt(u,0,i)}Yt.x=e.x+n,Yt.y=e.y+o,Nt(u,Yt.x,Yt.y),r&&qt(u,Yt,r,a)}t.transform=u}function ie(t,e,i,s,n,o,r,a){r&&$t(t,r),a&&Zt(t,a.x,a.y),n&&Qt(t,n,o),Nt(t,e.x+i,e.y+s)}const{get:se,translate:ne}=A,oe=new x,re={},ae={};function he(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=le(i,s,e)}function le(t,e,i){t.padding&&(e=oe.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:o}=i;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:w,filters:_}=t,v=e.width===n&&e.height===o,m={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(S.set(ae,0,0,y?o:n,y?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(R.getScaleData(c,d,i,re),x=re.scaleX,b=re.scaleY),(h||w||g)&&(x&&S.scale(ae,x,b,!0),h&&O.toPoint(h,ae,e,ae,!0,!0))):v&&!u||(x=b=S.getFitScale(e,ae,"fit"!==a),S.put(e,i,h,x,!1,ae),S.scale(ae,x,b,!0)),l&&D.move(ae,l),a){case"stretch":v||(n=e.width,o=e.height);break;case"normal":case"clip":(ae.x||ae.y||x||p||u||f)&&te(m,e,ae.x,ae.y,x,b,u,f,t.clipSize);break;case"repeat":(!v||x||u||f)&&ee(m,e,n,o,ae.x,ae.y,x,b,u,f,h,t.freeTransform),g||(m.repeat="repeat");const i=P(g);(w||i)&&(m.gap=function(t,e,i,s,n){let o,r;P(t)?(o=t.x,r=t.y):o=r=t;return{x:ce(o,i,n.width,e&&e.x),y:ce(r,s,n.height,e&&e.y)}}(w,i&&g,ae.width,ae.height,e));break;default:x&&Jt(m,e,ae.x,ae.y,x,b,u)}return m.transform||(e.x||e.y)&&(m.transform=se(),ne(m.transform,e.x,e.y)),x&&"stretch"!==a&&(m.scaleX=x,m.scaleY=b),m.width=n,m.height=o,r&&(m.opacity=r),_&&(m.filters=_),g&&(m.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),m}function ce(t,e,i,n){const o=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&o<0?0:o}let de,ue=new x;const{isSame:fe}=S;function pe(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||he(n,s,i,o),!0}function ge(t,e){ve(t,W.LOAD,e)}function we(t,e){ve(t,W.LOADED,e)}function _e(t,e,i){e.error=i,t.forceUpdate("surface"),ve(t,W.ERROR,e)}function ve(t,e,i){t.hasEvent(e)&&t.emitEvent(new W(e,i))}function me(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ye,scale:xe,copy:be}=A,{floor:Be,ceil:ke,max:Le,abs:Ee}=Math;function Se(t,e,s){let{scaleX:n,scaleY:o}=t.getRenderScaleData(!0,e.scaleFixed);const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{const{image:a,data:h}=e;let l,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:w,gap:_}=h;n*=s,o*=s,f&&(f=Ee(f),p=Ee(p),c=ye(),be(c,g),xe(c,1/f,1/p),n*=f,o*=p),d*=n,u*=o;const v=d*u;if(!w&&v>i.image.maxCacheSize)return!1;let m=i.image.maxPatternSize;if(a.isSVG){const t=d/a.width;t>1&&(l=t/ke(t))}else{const t=a.width*a.height;m>t&&(m=t)}v>m&&(l=Math.sqrt(v/m)),l&&(n/=l,o/=l,d/=l,u/=l),f&&(n/=f,o/=p);const y=_&&_.x*n,x=_&&_.y*o;if(g||1!==n||1!==o){const t=d+(y||0),e=u+(x||0);n/=t/Le(Be(t),1),o/=e/Le(Be(e),1),c||(c=ye(),g&&be(c,g)),xe(c,1/n,1/o)}const b=a.getCanvas(d,u,h.opacity,h.filters,y,x,t.leafer&&t.leafer.config.smooth),B=a.getPattern(b,w||i.origin.noRepeat||"no-repeat",c,e);return e.style=B,e.patternId=r,!0}}function Te(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 Re={image:function(t,e,i,s,n){let o,r;const a=E.get(i);return de&&i===de.paint&&fe(s,de.boxBounds)?o=de.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),de=a.use>1?{leafPaint:o,paint:i,boxBounds:ue.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(pe(t,e,i,a,o,s),n&&(ge(t,r),we(t,r))):a.error?n&&_e(t,r,a.error):(n&&(me(t,!0),ge(t,r)),o.loadId=a.load(()=>{me(t,!1),t.destroyed||(pe(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),we(t,r)),o.loadId=void 0},e=>{me(t,!1),_e(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:h}=e,{data:l}=s;if(!l||s.patternId===o+"-"+r+"-"+h&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&a.isResizing(t)||q.running)){let{width:t,height:e}=l;t*=o*h,e*=r*h,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.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()}(t,e,s,l),!0):(!s.style||s.sync||q.running?Se(t,s,h):s.patternTask||(s.patternTask=E.patternTasker.add(()=>Te(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&Se(t,s,h),t.forceUpdate("surface")}),300)),!1)},createPattern:Se,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,E.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],b(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createData:he,getPatternData:le,fillOrFitMode:Jt,clipMode:te,repeatMode:ee},{toPoint:Pe}=I,{hasTransparent:Me}=H,Ce={},Ae={};function Oe(t,e,i,n){if(i){let o,r,a,h;for(let t=0,l=i.length;t<l;t++)o=i[t],s(o)?(a=t/(l-1),r=H.string(o,n)):(a=o.offset,r=H.string(o.color,n)),e.addColorStop(a,r),!h&&Me(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:De,getDistance:We}=D,{get:Ie,rotateOfOuter:ze,scaleOfOuter:Fe}=A,{toPoint:je}=I,Ue={},Ge={};function Ye(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=De(e,i);o=Ie(),n?(Fe(o,e,r/a*(s||1),1),ze(o,e,t+90)):(Fe(o,e,1,r/a*(s||1)),ze(o,e,t))}return o}const{getDistance:Ve}=D,{toPoint:Xe}=I,He={},Ne={};const qe={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;Pe(s||"top",e,Ce),Pe(n||"bottom",e,Ae);const a=i.canvas.createLinearGradient(Ce.x,Ce.y,Ae.x,Ae.y),h={type:o,style:a};return Oe(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;je(s||"center",e,Ue),je(n||"bottom",e,Ge);const h=i.canvas.createRadialGradient(Ue.x,Ue.y,0,Ue.x,Ue.y,We(Ue,Ge)),l={type:o,style:h};Oe(l,h,t.stops,r);const c=Ye(e,Ue,Ge,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Xe(s||"center",e,He),Xe(n||"bottom",e,Ne);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,He.x,He.y):i.canvas.createRadialGradient(He.x,He.y,0,He.x,He.y,Ve(He,Ne)),l={type:o,style:h};Oe(l,h,t.stops,r);const c=Ye(e,He,Ne,a||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Ye},{copy:Ke,toOffsetOutBounds:Qe}=S,$e={},Ze={};function Je(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Ke($e,t.bounds),$e.x+=e.x-r.x,$e.y+=e.y-r.y,s){const{fitMatrix:t}=n;$e.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),$e.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),$e.width*=s,$e.height*=s}t.copyWorld(n.canvas,t.bounds,$e)}else s&&(Ke($e,e),$e.x-=e.width/2*(s-1),$e.y-=e.height/2*(s-1),$e.width*=s,$e.height*=s),t.copyWorld(n.canvas,r,s?$e:e)}const{toOffsetOutBounds:ti}=S,ei={};const ii={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=a.length-1;Qe(l,Ze),a.forEach((a,g)=>{let w=1;if(a.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.setWorldShadow(Ze.offsetX+a.x*d*w,Ze.offsetY+a.y*u*w,a.blur*d*w,H.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*w:0,Je(f,Ze,n,i),s=l,a.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),K.isTransformShadow(a)?K.renderTransformShadow(t,e,f,s,a):v.copyCanvasByWorld(t,e,f,s,a.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=a.length-1;ti(l,ei),a.forEach((a,g)=>{let w=1;if(a.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.save(),f.setWorldShadow(ei.offsetX+a.x*d*w,ei.offsetY+a.y*u*w,a.blur*d*w),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*w:0,Je(f,ei,n,i),f.restore(),h?(f.copyWorld(f,l,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,l,"source-out"),s=l),f.fillWorld(s,H.string(a.color),"source-in"),v.copyCanvasByWorld(t,e,f,s,a.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},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:si}=y;let ni;function oi(t,e,i,s,n,o,r,a){switch(e){case"grayscale":ni||(ni=!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);ai(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":ai(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function ri(t){return t.getSameCanvas(!1,!0)}function ai(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)}Q.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&&(oi(this,r,t,n,s,o,void 0,!0),s=n=null),o=i.__.opacity,ni=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=ri(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=ri(t)),n||(n=ri(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a||si(i,e)||i.__render(t,e);continue}const c=1===o&&i.__.__blendMode;c&&oi(this,r,t,n,s,o,void 0,!1),si(i,e)||i.__render(n||t,e),c&&oi(this,r,t,n,s,o,c,!1)}oi(this,r,t,n,s,o,void 0,!0)};const hi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",li=hi+"_#~&*+\\=|≮≯≈≠=…",ci=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 di(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ui=di("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),fi=di("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pi=di(hi),gi=di(li),wi=di("- —/~|┆·");var _i;!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"}(_i||(_i={}));const{Letter:vi,Single:mi,Before:yi,After:xi,Symbol:bi,Break:Bi}=_i;function ki(t){return ui[t]?vi:wi[t]?Bi:fi[t]?yi:pi[t]?xi:gi[t]?bi:ci.test(t)?mi:vi}const Li={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 Ei(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:Si}=Li,{Letter:Ti,Single:Ri,Before:Pi,After:Mi,Symbol:Ci,Break:Ai}=_i;let Oi,Di,Wi,Ii,zi,Fi,ji,Ui,Gi,Yi,Vi,Xi,Hi,Ni,qi,Ki,Qi,$i=[];function Zi(t,e){Gi&&!Ui&&(Ui=Gi),Oi.data.push({char:t,width:e}),Wi+=e}function Ji(){Ii+=Wi,Oi.width=Wi,Di.words.push(Oi),Oi={data:[]},Wi=0}function ts(){Ni&&(qi.paraNumber++,Di.paraStart=!0,Ni=!1),Gi&&(Di.startCharSize=Ui,Di.endCharSize=Gi,Ui=0),Di.width=Ii,Ki.width?Si(Di):Qi&&es(),$i.push(Di),Di={words:[]},Ii=0}function es(){Ii>(qi.maxWidth||0)&&(qi.maxWidth=Ii)}const{top:is,right:ss,bottom:ns,left:os}=z;function rs(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 as={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,o=0,r=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=e;c&&(r?(n=c[os],r-=c[ss]+c[os]):e.autoSizeAlign||(n=c[os]),a?(o=c[is],a-=c[is]+c[ns]):e.autoSizeAlign||(o=c[is]));const d={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:i.canvas.font=l};return function(t,e,s){qi=t,$i=t.rows,Ki=t.bounds,Qi=!Ki.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Ki;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;Ni=!0,Vi=null,Ui=ji=Gi=Wi=Ii=0,Oi={data:[]},Di={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)Fi=e[s],"\n"===Fi?(Wi&&Ji(),Di.paraEnd=!0,ts(),Ni=!0):(Yi=ki(Fi),Yi===Ti&&"none"!==r&&(Fi=Ei(Fi,r,!Wi)),ji=a.measureText(Fi).width,n&&(n<0&&(Gi=ji),ji+=n),Xi=Yi===Ri&&(Vi===Ri||Vi===Ti)||Vi===Ri&&Yi!==Mi,Hi=!(Yi!==Pi&&Yi!==Ri||Vi!==Ci&&Vi!==Mi),zi=Ni&&o?h-o:h,t&&h&&Ii+Wi+ji>zi&&(i?(Wi&&Ji(),Ii&&ts()):(Hi||(Hi=Yi===Ti&&Vi==Mi),Xi||Hi||Yi===Ai||Yi===Pi||Yi===Ri||Wi+ji>zi?(Wi&&Ji(),Ii&&ts()):Ii&&ts()))," "===Fi&&!0!==Ni&&Ii+Wi===0||(Yi===Ai?(" "===Fi&&Wi&&Ji(),Zi(Fi,ji),Ji()):Xi||Hi?(Wi&&Ji(),Zi(Fi,ji)):Zi(Fi,ji)),Vi=Yi);Wi&&Ji(),Ii&&ts(),$i.length>0&&($i[$i.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{qi.paraNumber++,Ii=a.measureText(t).width,$i.push({x:o||0,text:t,width:Ii,paraStart:!0}),Qi&&es()})}(d,t,e),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":rs(e,"x",t[os]);break;case"right":rs(e,"x",-t[ss])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":rs(e,"y",t[is]);break;case"bottom":rs(e,"y",-t[ns])}}(c,d,e,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:w}=s,_=o*n+(d?d*(t.paraNumber-1):0),v=r;if(h&&_>w)_=Math.max(w,o),n>1&&(t.overflow=n);else if(w||u)switch(c){case"middle":p+=(w-_)/2;break;case"bottom":p+=w-_}v+=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&&(v+=d),m.y=v,v+=o,t.overflow>r&&v>_&&(m.isOverflow=!0,t.overflow=r+1),y=m.x,x=m.width,a<0&&(m.width<0?(x=-m.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<s.x&&(s.x=y),x>s.width&&(s.width=x),h&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(d,e),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,e,r),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,e,n,r),"none"!==h&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,P(o)?(i=o.type,o.color&&(t.decorationColor=H.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(d,e),d}};const hs={string:function(t,e){const i=F(e)&&e<1;if(s(t)){if(!i||!H.object)return t;t=H.object(t)}let o=n(t.a)?1:t.a;i&&(o*=e);const r=t.r+","+t.g+","+t.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign($,as),Object.assign(H,hs),Object.assign(X,Gt),Object.assign(V,Re),Object.assign(N,qe),Object.assign(K,ii),Object.assign(c,{interaction:(t,e,i,s)=>new kt(t,e,i,s),hitCanvas:(t,e)=>new J(t,e),hitCanvasManager:()=>new Y}),it();export{kt as Interaction,gt as Layouter,J as LeaferCanvas,mt as Picker,_t as Renderer,yt as Selector,nt as Watcher,it as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,isUndefined as n,DataHelper as o,canvasSizeAttrs as r,ResizeEvent as a,canvasPatch as h,FileHelper as l,Creator as c,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as w,PropertyEvent as _,LeafHelper as m,BranchHelper as v,LeafBoundsHelper as y,Bounds as x,isArray as b,LeafLevelList as B,LayoutEvent as S,Run as k,ImageManager as L,BoundsHelper as E,Plugin as T,MathHelper as R,isObject as P,FourNumberHelper as C,Matrix as M,getMatrixData as A,MatrixHelper as O,AlignHelper as D,PointHelper as W,ImageEvent as I,AroundHelper as F,Direction4 as z,isNumber as j}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as G,Cursor as Y,HitCanvasManager as V}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as X,Paint as H,ColorConvert as N,PaintGradient as q,Export as K,Effect as Q,Group as $,TextConvert as Z}from"@leafer-ui/draw";const J=t.get("LeaferCanvas");class tt extends e{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:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):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"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else J.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;if(this.unreal){const{config:t,autoWidthStr:e,autoHeightStr:i}=this;t.width?(n(e)&&(this.autoWidthStr=s.width||""),s.width=t.width+"px"):n(e)||(s.width=e),t.height?(n(i)&&(this.autoHeightStr=s.height||""),s.height=t.height+"px"):n(i)||(s.height=i)}else s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(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),J.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()),i.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;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(t){const e={};o.copyAttrs(e,this,r),this.resize(t),this.resizeListener&&!n(this.width)&&this.resizeListener(new a(t,e))}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()}}}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype);const{mineType:et,fileType:it}=l;function st(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=et(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,et(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(et(it(e)),s);return i.origin.download(n,e)},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:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new tt(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),nt.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):nt.indexOf("Mac")>-1?i.os="Mac":nt.indexOf("Linux")>-1&&(i.os="Linux");class ot{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=o.default(e,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(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.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 w(w.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[_.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[w.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:rt,updateBounds:at,updateChange:ht}=m,{pushAllChildBranch:lt,pushAllParent:ct}=v;const{worldBounds:dt}=y;class ut{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,dt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,dt),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:ft,updateAllChange:pt}=m,gt=t.get("Layouter");class wt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new B,this.target=t,e&&(this.config=o.default(e,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:t}=this;this.times=0;try{t.emit(S.START),this.layoutOnce(),t.emitEvent(new S(S.END,this.layoutedBlocks,this.times))}catch(t){gt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gt.warn("layouting"):this.times>3?gt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(w.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=k.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=S,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new S(n,a,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(rt(t,!0),e.add(t),t.isBranch&&lt(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(t,e)))})}(s,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||at(s[t])}at(i)}})}(this.__levelList),function(t){t.list.forEach(ht)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new S(o,a,this.times)),i.emitEvent(new S(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,k.end(e)}fullLayout(){const t=k.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=S,o=this.getBlocks(new f(e));e.emitEvent(new S(i,o,this.times)),wt.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new S(s,o,this.times)),e.emitEvent(new S(n,o,this.times)),this.addBlocks(o),k.end(t)}static fullLayout(t){ft(t,!0),t.isBranch?v.updateBounds(t):m.updateBounds(t),pt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ut([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ut(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_([[S.REQUEST,this.layout,this],[S.AGAIN,this.layoutAgain,this],[w.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const _t=t.get("Renderer");class mt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=o.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(S.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,_t.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),L.clearRecycled()}catch(t){this.rendering=!1,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.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(t){const e=k.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(mt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),k.end(e)}fullRender(){const t=k.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),k.end(t)}__render(e,s){const{canvas:n}=this,o=e.includes(this.target.__world),r=o?{includes:o}:{bounds:e,includes:o};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),i.render(this.target,n,r),this.renderBounds=s=s||e,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),n.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(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||_t.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[S.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}mt.clipSpread=10;const{hitRadiusPoint:vt}=E;class yt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new f(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new f;if(t.length){let e;const{x:n,y:o}=this.point,r={x:n,y:o,radiusX:0,radiusY:0};for(let n=0,o=t.length;n<o;n++)if(e=t[n],(i||m.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&m.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>m.worldHittable(t))}getPath(t){const e=new f;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new f;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}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||vt(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 xt{constructor(t,e){this.config={},e&&(this.config=o.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=c.finder&&c.finder()}getByPoint(t,e,s){const{target:n,picker:o}=this;return i.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,e,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):T.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(c,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new wt(t,e),renderer:(t,e,i)=>new mt(t,e,i),selector:(t,e)=>new xt(t,e)}),i.layout=wt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const bt={convert(t,e){const i=U.getBase(t),{x:s,y:n}=e,o=Object.assign(Object.assign({},i),{x:s,y:n,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===o.pointerType&&(o.tangentialPressure=t.tangentialPressure,o.tiltX=t.tiltX,o.tiltY=t.tiltY,o.twist=t.twist),o},convertMouse(t,e){const i=U.getBase(t),{x:s,y:n}=e;return Object.assign(Object.assign({},i),{x:s,y:n,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=bt.getTouch(t),s=U.getBase(t),{x:n,y:o}=e;return Object.assign(Object.assign({},s),{x:n,y:o,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},Bt={convert(t){const e=U.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:St}=U;class kt extends G{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(Bt.convert(t))}onKeyUp(t){this.keyUp(Bt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(bt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(bt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=bt.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(bt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(bt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(bt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(bt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=bt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&St(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(bt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=bt.getTouch(t);this.pointerMove(bt.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=bt.getTouch(t);this.pointerUp(bt.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 e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(U.getBase(t),i),this.touches=e)}}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({},U.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(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=U.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),P(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>P(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,b(t))t.forEach(t=>this.eachCursor(t,e,i));else{const n=s(t)&&Y.get(t);n&&i<2?this.eachCursor(n,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Lt(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 Et(t,e){t.__.__font?Lt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,i){switch(e.__.strokeAlign){case"center":Rt(t,1,e,i);break;case"inside":Pt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Rt(t,2,e,i):Pt(t,"outside",e,i)}}function Rt(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Ct(i,s))}function Pt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Rt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Lt(i,n),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Ct(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 Mt(t,e,i,s,n){let o;const r=s.__,{__hasMultiStrokeStyle:a}=r;a||n.setStroke(void 0,r.__strokeWidth*e,r);for(let h=0,l=t.length;h<l;h++)if(o=t[h],(!o.image||!X.checkImage(s,n,o,!1))&&o.style){if(a){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.blendMode?(n.saveBlendMode(o.blendMode),i?Ct(s,n):n.stroke(),n.restoreBlendMode()):i?Ct(s,n):n.stroke()}}function At(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Tt(t,e,i);else switch(s.strokeAlign){case"center":Ot(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Ot(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Ot(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),Ot(t,2,e,o),o.clipUI(s),o.clearWorld(n),m.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i)}}function Ot(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&H.strokeArrow(t,i,s)}const{getSpread:Dt,copyAndSpread:Wt,toOuterOf:It,getOuterOf:Ft,getByMove:zt,move:jt,getIntersectData:Ut}=E,Gt={};let Yt;const{stintSet:Vt}=o,{hasTransparent:Xt}=N;function Ht(t,e,i){if(!P(e)||!1===e.visible||0===e.opacity)return;let o;const{boxBounds:r}=i.__layout;switch(e.type){case"image":o=X.image(i,t,e,r,!Yt||!Yt[e.url]);break;case"linear":o=q.linearGradient(e,r);break;case"radial":o=q.radialGradient(e,r);break;case"angular":o=q.conicGradient(e,r);break;case"solid":const{type:s,color:a,opacity:h}=e;o={type:s,style:N.string(a,h)};break;default:n(e.r)||(o={type:"solid",style:N.string(e)})}if(o){if(s(o.style)&&Xt(o.style)&&(o.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;o.strokeStyle=e.style}e.editing&&(o.editing=e.editing),e.blendMode&&(o.blendMode=e.blendMode)}return o}const Nt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),Yt=X.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Ht(t,a[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),o=!0),"fill"===t?(Vt(i,"__isAlphaPixelFill",n),Vt(i,"__isTransparentFill",o)):(Vt(i,"__isAlphaPixelStroke",n),Vt(i,"__isTransparentStroke",o),Vt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,Et(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(X.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),Et(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Et(e,i),i.restoreBlendMode()):Et(e,i)}},fillPathOrText:Et,fillText:Lt,stroke:At,strokes:function(t,e,i){At(t,e,i)},strokeText:Tt,drawTextStroke:Ct,shape:function(t,e,s){const n=e.getSameCanvas(),o=e.bounds,r=t.__nowWorld,a=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let l,c,d,u,f,p;It(a.strokeSpread?(Wt(Gt,a.boxBounds,a.strokeSpread),Gt):a.boxBounds,r,h);let{scaleX:g,scaleY:w}=t.getRenderScaleData(!0);if(o.includes(h))p=n,l=f=h,c=r;else{let n;if(i.fullImageShadow)n=h;else{const t=a.renderShapeSpread?Dt(o,C.swapAndScale(a.renderShapeSpread,g,w)):o;n=Ut(t,h)}u=o.getFitMatrix(n);let{a:_,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=_,w*=m),f=Ft(h,u),l=zt(f,-u.e,-u.f),c=Ft(r,u),jt(c,-u.e,-u.f);const v=s.matrix;v?(d=new M(u),d.multiply(v),_*=v.scaleX,m*=v.scaleY):d=u,d.withScale(_,m),s=Object.assign(Object.assign({},s),{matrix:d})}return t.__renderShape(n,s),{canvas:n,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:w}}};let qt={},Kt=A();const{get:Qt,rotateOfOuter:$t,translate:Zt,scaleOfOuter:Jt,multiplyParent:te,scale:ee,rotate:ie,skew:se}=O;function ne(t,e,i,s,n,o,r){const a=Qt();Zt(a,e.x+i,e.y+s),ee(a,n,o),r&&$t(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function oe(t,e,i,s,n,o,r,a,h,l){const c=Qt();ae(c,e,i,s,n,o,r,a),h&&(Kt.a=h,Kt.d=l,te(c,Kt)),t.transform=c}function re(t,e,i,s,n,o,r,a,h,l,c,d){const u=Qt();if(d)ae(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)$t(u,{x:i/2,y:s/2},h);else switch(ie(u,h),h){case 90:Zt(u,s,0);break;case 180:Zt(u,i,s);break;case 270:Zt(u,0,i)}qt.x=e.x+n,qt.y=e.y+o,Zt(u,qt.x,qt.y),r&&Jt(u,qt,r,a)}t.transform=u}function ae(t,e,i,s,n,o,r,a){r&&ie(t,r),a&&se(t,a.x,a.y),n&&ee(t,n,o),Zt(t,e.x+i,e.y+s)}const{get:he,translate:le}=O,ce=new x,de={},ue={};function fe(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=pe(i,s,e)}function pe(t,e,i){t.padding&&(e=ce.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:o}=i;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:w,filters:_}=t,m=e.width===n&&e.height===o,v={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(E.set(ue,0,0,y?o:n,y?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(R.getScaleData(c,d,i,de),x=de.scaleX,b=de.scaleY),(h||w||g)&&(x&&E.scale(ue,x,b,!0),h&&D.toPoint(h,ue,e,ue,!0,!0))):m&&!u||(x=b=E.getFitScale(e,ue,"fit"!==a),E.put(e,i,h,x,!1,ue),E.scale(ue,x,b,!0)),l&&W.move(ue,l),a){case"stretch":m||(n=e.width,o=e.height);break;case"normal":case"clip":if(ue.x||ue.y||x||p||u||f){let t,i;p&&(t=e.width/p.width,i=e.height/p.height),oe(v,e,ue.x,ue.y,x,b,u,f,t,i),t&&(x=x?x*t:x,b=b?b*i:i)}break;case"repeat":(!m||x||u||f)&&re(v,e,n,o,ue.x,ue.y,x,b,u,f,h,t.freeTransform),g||(v.repeat="repeat");const i=P(g);(w||i)&&(v.gap=function(t,e,i,s,n){let o,r;P(t)?(o=t.x,r=t.y):o=r=t;return{x:ge(o,i,n.width,e&&e.x),y:ge(r,s,n.height,e&&e.y)}}(w,i&&g,ue.width,ue.height,e));break;default:x&&ne(v,e,ue.x,ue.y,x,b,u)}return v.transform||(e.x||e.y)&&(v.transform=he(),le(v.transform,e.x,e.y)),x&&"stretch"!==a&&(v.scaleX=x,v.scaleY=b),v.width=n,v.height=o,r&&(v.opacity=r),_&&(v.filters=_),g&&(v.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),v}function ge(t,e,i,n){const o=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&o<0?0:o}let we,_e=new x;const{isSame:me}=E;function ve(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||fe(n,s,i,o),!0}function ye(t,e){Be(t,I.LOAD,e)}function xe(t,e){Be(t,I.LOADED,e)}function be(t,e,i){e.error=i,t.forceUpdate("surface"),Be(t,I.ERROR,e)}function Be(t,e,i){t.hasEvent(e)&&t.emitEvent(new I(e,i))}function Se(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ke,scale:Le,copy:Ee}=O,{floor:Te,ceil:Re,max:Pe,abs:Ce}=Math;function Me(t,e,s){let{scaleX:n,scaleY:o}=t.getRenderScaleData(!0,e.scaleFixed);const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{const{image:a,data:h}=e;let l,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:w,gap:_}=h;n*=s,o*=s,f&&(f=Ce(f),p=Ce(p),c=ke(),Ee(c,g),Le(c,1/f,1/p),n*=f,o*=p),d*=n,u*=o;const m=d*u;if(!w&&m>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(a.isSVG){const t=d/a.width;t>1&&(l=t/Re(t))}else{const t=a.width*a.height;v>t&&(v=t)}m>v&&(l=Math.sqrt(m/v)),l&&(n/=l,o/=l,d/=l,u/=l),f&&(n/=f,o/=p);const y=_&&_.x*n,x=_&&_.y*o;if(g||1!==n||1!==o){const t=d+(y||0),e=u+(x||0);n/=t/Pe(Te(t),1),o/=e/Pe(Te(e),1),c||(c=ke(),g&&Ee(c,g)),Le(c,1/n,1/o)}const b=a.getCanvas(d,u,h.opacity,h.filters,y,x,t.leafer&&t.leafer.config.smooth),B=a.getPattern(b,w||i.origin.noRepeat||"no-repeat",c,e);return e.style=B,e.patternId=r,!0}}function Ae(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 Oe={image:function(t,e,i,s,n){let o,r;const a=L.get(i);return we&&i===we.paint&&me(s,we.boxBounds)?o=we.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),we=a.use>1?{leafPaint:o,paint:i,boxBounds:_e.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(ve(t,e,i,a,o,s),n&&(ye(t,r),xe(t,r))):a.error?n&&be(t,r,a.error):(n&&(Se(t,!0),ye(t,r)),o.loadId=a.load(()=>{Se(t,!1),t.destroyed||(ve(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),xe(t,r)),o.loadId=void 0},e=>{Se(t,!1),be(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:h}=e,{data:l}=s;if(!l||s.patternId===o+"-"+r+"-"+h&&!K.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&a.isResizing(t)||K.running)){let{width:t,height:e}=l;t*=o*h,e*=r*h,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.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()}(t,e,s,l),!0):(!s.style||s.sync||K.running?Me(t,s,h):s.patternTask||(s.patternTask=L.patternTasker.add(()=>Ae(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&Me(t,s,h),t.forceUpdate("surface")}),300)),!1)},createPattern:Me,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,L.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],b(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createData:fe,getPatternData:pe,fillOrFitMode:ne,clipMode:oe,repeatMode:re},{toPoint:De}=F,{hasTransparent:We}=N,Ie={},Fe={};function ze(t,e,i,n){if(i){let o,r,a,h;for(let t=0,l=i.length;t<l;t++)o=i[t],s(o)?(a=t/(l-1),r=N.string(o,n)):(a=o.offset,r=N.string(o.color,n)),e.addColorStop(a,r),!h&&We(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:je,getDistance:Ue}=W,{get:Ge,rotateOfOuter:Ye,scaleOfOuter:Ve}=O,{toPoint:Xe}=F,He={},Ne={};function qe(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=je(e,i);o=Ge(),n?(Ve(o,e,r/a*(s||1),1),Ye(o,e,t+90)):(Ve(o,e,1,r/a*(s||1)),Ye(o,e,t))}return o}const{getDistance:Ke}=W,{toPoint:Qe}=F,$e={},Ze={};const Je={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;De(s||"top",e,Ie),De(n||"bottom",e,Fe);const a=i.canvas.createLinearGradient(Ie.x,Ie.y,Fe.x,Fe.y),h={type:o,style:a};return ze(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Xe(s||"center",e,He),Xe(n||"bottom",e,Ne);const h=i.canvas.createRadialGradient(He.x,He.y,0,He.x,He.y,Ue(He,Ne)),l={type:o,style:h};ze(l,h,t.stops,r);const c=qe(e,He,Ne,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Qe(s||"center",e,$e),Qe(n||"bottom",e,Ze);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,$e.x,$e.y):i.canvas.createRadialGradient($e.x,$e.y,0,$e.x,$e.y,Ke($e,Ze)),l={type:o,style:h};ze(l,h,t.stops,r);const c=qe(e,$e,Ze,a||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:qe},{copy:ti,move:ei,toOffsetOutBounds:ii}=E,{max:si}=Math,ni={},oi=new M,ri={};function ai(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=si(r,n+o-s),a=si(a,n+o+i),h=si(h,n+o+s),l=si(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function hi(t,e,s){const{shapeBounds:n}=s;let o,r;i.fullImageShadow?(ti(ni,t.bounds),ei(ni,e.x-n.x,e.y-n.y),o=t.bounds,r=ni):(o=n,r=e),t.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:li}=E,ci={};const di=ai;const ui={shadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ii(h,ri,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.setWorldShadow(ri.offsetX+(r.x||0)*d*w,ri.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w,N.string(r.color)),n=Q.getShadowTransform(t,f,i,r,ri,w),n&&f.setTransform(n),hi(f,ri,i),n&&f.resetTransform(),s=l,r.box&&(f.restore(),f.save(),a&&(f.copyWorld(f,l,o,"copy"),s=o),a?f.copyWorld(a,o,o,"destination-out"):f.copyWorld(i.canvas,c,h,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;li(h,ci,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.save(),f.setWorldShadow(ci.offsetX+(r.x||0)*d*w,ci.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w),n=Q.getShadowTransform(t,f,i,r,ci,w,!0),n&&f.setTransform(n),hi(f,ci,i),f.restore(),a?(f.copyWorld(f,l,o,"copy"),f.copyWorld(a,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,h,"source-out"),s=l),f.fillWorld(s,N.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},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:ai,getShadowTransform:function(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 oi.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),oi}},isTransformShadow(t){},getInnerShadowSpread:di},{excludeRenderBounds:fi}=y;let pi;function gi(t,e,i,s,n,o,r,a){switch(e){case"grayscale":pi||(pi=!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);_i(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":_i(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function wi(t){return t.getSameCanvas(!1,!0)}function _i(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)}$.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&&(gi(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||fi(i,e)||i.__render(t,e),o=i.__.opacity,pi=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=wi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=wi(t)),n||(n=wi(t)),i.__render(s,e));continue}const c=1===o&&i.__.__blendMode;c&&gi(this,r,t,n,s,o,void 0,!1),fi(i,e)||i.__render(n||t,e),c&&gi(this,r,t,n,s,o,c,!1)}gi(this,r,t,n,s,o,void 0,!0)};const mi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",vi=mi+"_#~&*+\\=|≮≯≈≠=…",yi=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 xi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const bi=xi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Bi=xi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Si=xi(mi),ki=xi(vi),Li=xi("- —/~|┆·");var Ei;!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"}(Ei||(Ei={}));const{Letter:Ti,Single:Ri,Before:Pi,After:Ci,Symbol:Mi,Break:Ai}=Ei;function Oi(t){return bi[t]?Ti:Li[t]?Ai:Bi[t]?Pi:Si[t]?Ci:ki[t]?Mi:yi.test(t)?Ri:Ti}const Di={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 Wi(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:Ii}=Di,{Letter:Fi,Single:zi,Before:ji,After:Ui,Symbol:Gi,Break:Yi}=Ei;let Vi,Xi,Hi,Ni,qi,Ki,Qi,$i,Zi,Ji,ts,es,is,ss,ns,os,rs,as=[];function hs(t,e){Zi&&!$i&&($i=Zi),Vi.data.push({char:t,width:e}),Hi+=e}function ls(){Ni+=Hi,Vi.width=Hi,Xi.words.push(Vi),Vi={data:[]},Hi=0}function cs(){ss&&(ns.paraNumber++,Xi.paraStart=!0,ss=!1),Zi&&(Xi.startCharSize=$i,Xi.endCharSize=Zi,$i=0),Xi.width=Ni,os.width?Ii(Xi):rs&&ds(),as.push(Xi),Xi={words:[]},Ni=0}function ds(){Ni>(ns.maxWidth||0)&&(ns.maxWidth=Ni)}const{top:us,right:fs,bottom:ps,left:gs}=z;function ws(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 _s={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,o=0,r=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=e;c&&(r?(n=c[gs],r-=c[fs]+c[gs]):e.autoSizeAlign||(n=c[gs]),a?(o=c[us],a-=c[us]+c[ps]):e.autoSizeAlign||(o=c[us]));const d={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:i.canvas.font=l};return function(t,e,s){ns=t,as=t.rows,os=t.bounds,rs=!os.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=os;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;ss=!0,ts=null,$i=Qi=Zi=Hi=Ni=0,Vi={data:[]},Xi={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)Ki=e[s],"\n"===Ki?(Hi&&ls(),Xi.paraEnd=!0,cs(),ss=!0):(Ji=Oi(Ki),Ji===Fi&&"none"!==r&&(Ki=Wi(Ki,r,!Hi)),Qi=a.measureText(Ki).width,n&&(n<0&&(Zi=Qi),Qi+=n),es=Ji===zi&&(ts===zi||ts===Fi)||ts===zi&&Ji!==Ui,is=!(Ji!==ji&&Ji!==zi||ts!==Gi&&ts!==Ui),qi=ss&&o?h-o:h,t&&h&&Ni+Hi+Qi>qi&&(i?(Hi&&ls(),Ni&&cs()):(is||(is=Ji===Fi&&ts==Ui),es||is||Ji===Yi||Ji===ji||Ji===zi||Hi+Qi>qi?(Hi&&ls(),Ni&&cs()):Ni&&cs()))," "===Ki&&!0!==ss&&Ni+Hi===0||(Ji===Yi?(" "===Ki&&Hi&&ls(),hs(Ki,Qi),ls()):es||is?(Hi&&ls(),hs(Ki,Qi)):hs(Ki,Qi)),ts=Ji);Hi&&ls(),Ni&&cs(),as.length>0&&(as[as.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{ns.paraNumber++,Ni=a.measureText(t).width,as.push({x:o||0,text:t,width:Ni,paraStart:!0}),rs&&ds()})}(d,t,e),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ws(e,"x",t[gs]);break;case"right":ws(e,"x",-t[fs])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ws(e,"y",t[us]);break;case"bottom":ws(e,"y",-t[ps])}}(c,d,e,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:w}=s,_=o*n+(d?d*(t.paraNumber-1):0),m=r;if(h&&_>w)_=Math.max(w,o),n>1&&(t.overflow=n);else if(w||u)switch(c){case"middle":p+=(w-_)/2;break;case"bottom":p+=w-_}m+=p;let v,y,x,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(v=i[r],v.x=f,v.width<g||v.width>g&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&d&&r>0&&(m+=d),v.y=m,m+=o,t.overflow>r&&m>_&&(v.isOverflow=!0,t.overflow=r+1),y=v.x,x=v.width,a<0&&(v.width<0?(x=-v.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&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(d,e),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,e,r),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,e,n,r),"none"!==h&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,P(o)?(i=o.type,o.color&&(t.decorationColor=N.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(d,e),d}};const ms={string:function(t,e){if(!t)return"#000";const i=j(e)&&e<1;if(s(t)){if(!i||!N.object)return t;t=N.object(t)}let o=n(t.a)?1:t.a;i&&(o*=e);const r=t.r+","+t.g+","+t.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign(Z,_s),Object.assign(N,ms),Object.assign(H,Nt),Object.assign(X,Oe),Object.assign(q,Je),Object.assign(Q,ui),Object.assign(c,{interaction:(t,e,i,s)=>new kt(t,e,i,s),hitCanvas:(t,e)=>new tt(t,e),hitCanvasManager:()=>new V}),st();export{kt as Interaction,wt as Layouter,tt as LeaferCanvas,yt as Picker,mt as Renderer,xt as Selector,ot as Watcher,st as useCanvas};
2
2
  //# sourceMappingURL=web.esm.min.js.map