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