leafer-ui 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +16 -15
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +16 -15
- package/dist/web.esm.js.map +1 -1
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +27 -23
- package/dist/web.js.map +1 -1
- 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 +27 -23
- package/dist/web.module.js.map +1 -1
- 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 l,defineKey as c,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 b,Run as x,ImageManager as B,BoundsHelper as E,Plugin as L,MathHelper as R,MatrixHelper as k,AlignHelper as T,ImageEvent as S,AroundHelper as M,PointHelper as C,Direction4 as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as P,InteractionBase as O,Cursor as W,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as z,PaintGradient as F,Export as j,Group as G,TextConvert as U,Paint 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 l(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},c(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=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:J,updateAllWorldOpacity: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.running)return;const{target:t}=this;this.times=0;try{t.emit(b.START),this.layoutOnce(),t.emitEvent(new b(b.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=b,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new b(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){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new b(o,a,this.times)),i.emitEvent(new b(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=b,o=this.getBlocks(new d(e));e.emitEvent(new b(i,o,this.times)),ht.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new b(s,o,this.times)),e.emitEvent(new b(n,o,this.times)),this.addBlocks(o),x.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(){const{target:t}=this;this.__eventIds=[t.on_(b.REQUEST,this.layout,this),t.on_(b.AGAIN,this.layoutAgain,this),t.on_(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 ct{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(b.REQUEST)}checkRender(){this.running&&(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,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 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=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new y(s);i.save(),s.spread(ct.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,t.includes(this.target.__world),n),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(e,i,s){const{canvas:n}=this,o=i?{includes:i}:{bounds:e,includes:i};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),this.target.__render(n,o),this.renderBounds=s=s||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),n.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(t.parentApp)return t.parentApp.renderer.update(!1);if(this.requestTime)return;const e=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,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.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||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(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(b.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(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)}}ct.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 ct(t,e,i),selector:(t,e)=>new pt(t,e)}),i.layout=ht.fullLayout;const ft={convert(t,e){const i=P.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=P.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=P.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=P.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:_t}=P;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(P.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({},P.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=P.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"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){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.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=s;t&&(e.fillStyle=t),n.forEach((t=>o.forEach((s=>e.fillRect(t.x,t.y+s,t.width,i)))))}}function yt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?xt(t,!0,e,i):bt(e,i);break;case"inside":mt("inside",t,n,e,i);break;case"outside":mt("outside",t,n,e,i)}}function mt(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?xt(e,!0,s,a):bt(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",vt(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function bt(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 xt(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?bt(i,s):s.stroke(),s.restoreBlendMode()):e?bt(i,s):s.stroke())}function Bt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:Et,getOuterOf:Lt,getByMove:Rt,getIntersectData:kt}=E;let Tt;function St(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:z.string(r,a)};case"image":return I.image(i,t,e,s,!Tt||!Tt[e.url]);case"linear":return F.linearGradient(e,s);case"radial":return F.radialGradient(e,s);case"angular":return F.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:z.string(e)}:void 0}}const Mt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Tt=I.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=St(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?vt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&I.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?vt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?vt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?vt(e,i):n?i.fill(n):i.fill())},fillText:vt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)yt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&Bt(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)yt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),xt(t,!1,e,i),s.__useArrow&&Bt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),xt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),xt(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:yt,drawTextStroke:bt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,d=kt(s?Et(e.bounds,l===c?s*l:[s*c,s*l]):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),l*=u,c*=p),a=Lt(n,r),o=Rt(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:l,scaleY:c}}};let Ct={};const{get:At,rotateOfOuter:Pt,translate:Ot,scaleOfOuter:Wt,scale:Dt,rotate:It}=k;function zt(t,e,i,s,n,o,r){const a=At();Ot(a,e.x+i,e.y+s),Dt(a,n,o),r&&Pt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Ft(t,e,i,s,n,o,r){const a=At();Ot(a,e.x+i,e.y+s),n&&Dt(a,n,o),r&&It(a,r),t.transform=a}function jt(t,e,i,s,n,o,r,a,h,l){const c=At();if(h)if("center"===l)Pt(c,{x:i/2,y:s/2},h);else switch(It(c,h),h){case 90:Ot(c,s,0);break;case 180:Ot(c,i,s);break;case 270:Ot(c,0,i)}Ct.x=e.x+n,Ct.y=e.y+o,Ot(c,Ct.x,Ct.y),r&&Wt(c,Ct,r,a),t.transform=c}const{get:Gt,translate:Ut}=k,Yt=new y,Vt={},Xt={};function Nt(t,e,i,s){const{blendMode:n,changeful:o,sync:r}=i;n&&(t.blendMode=n),o&&(t.changeful=o),r&&(t.sync=r),t.data=Ht(i,s,e)}function Ht(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Yt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:h,scale:l,size:c,rotation:d,repeat:u,filters:p}=t,f=e.width===s&&e.height===n,g={mode:r},_="center"!==a&&(d||0)%180==90,w=_?n:s,v=_?s:n;let y,m,b=0,x=0;if(r&&"cover"!==r&&"fit"!==r)(l||c)&&(R.getScaleData(l,c,i,Xt),y=Xt.scaleX,m=Xt.scaleY);else if(!f||d){const t=e.width/w,i=e.height/v;y=m="fit"===r?Math.min(t,i):Math.max(t,i),b+=(e.width-s*y)/2,x+=(e.height-n*m)/2}if(a){const t={x:b,y:x,width:w,height:v};y&&(t.width*=y,t.height*=m),T.toPoint(a,t,e,Vt,!0),b+=Vt.x,x+=Vt.y}switch(h&&(b+=h.x,x+=h.y),r){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(b||x||y||d)&&Ft(g,e,b,x,y,m,d);break;case"repeat":(!f||y||d)&&jt(g,e,s,n,b,x,y,m,d,a),u||(g.repeat="repeat");break;default:y&&zt(g,e,b,x,y,m,d)}return g.transform||(e.x||e.y)&&(g.transform=Gt(),Ut(g.transform,e.x,e.y)),y&&"stretch"!==r&&(g.scaleX=y,g.scaleY=m),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 qt,Kt=new y;const{isSame:Qt}=E;function $t(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||Nt(n,s,i,o),!0}function Zt(t,e){ee(t,S.LOAD,e)}function Jt(t,e){ee(t,S.LOADED,e)}function te(t,e,i){e.error=i,t.forceUpdate("surface"),ee(t,S.ERROR,e)}function ee(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function ie(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:se,scale:ne,copy:oe}=k,{ceil:re,abs:ae}=Math;function he(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=ae(n),o=ae(o);const{image:t,data:a}=e;let h,l,{width:c,height:d,scaleX:u,scaleY:p,transform:f,repeat:g}=a;u&&(l=se(),oe(l,f),ne(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,c*=n,d*=o;const _=c*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,c/=h,d/=h),u&&(n/=u,o/=p),(f||1!==n||1!==o)&&(l||(l=se(),f&&oe(l,f)),ne(l,1/n,1/o));const v=t.getCanvas(re(c)||1,re(d)||1,a.opacity,a.filters),y=t.getPattern(v,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=y,e.patternId=r,!0}}function le(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:ce}=Math;const de={image:function(t,e,i,s,n){let o,r;const a=B.get(i);return qt&&i===qt.paint&&Qt(s,qt.boxBounds)?o=qt.leafPaint:(o={type:i.type,image:a},qt=a.use>1?{leafPaint:o,paint:i,boxBounds:Kt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?($t(t,e,i,a,o,s),n&&(Zt(t,r),Jt(t,r))):a.error?n&&te(t,r,a.error):(n&&(ie(t,!0),Zt(t,r)),o.loadId=a.load((()=>{ie(t,!1),t.destroyed||($t(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Jt(t,r)),o.loadId=null}),(e=>{ie(t,!1),te(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:r,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:h}=e,{data:l}=s;if(!l||s.patternId===r+"-"+a+"-"+h&&!j.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||j.running)){let{width:t,height:e}=l;t*=ce(r)*h,e*=ce(a)*h,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,l),!0):(!s.style||s.sync||j.running?he(t,s,h):s.patternTask||(s.patternTask=B.patternTasker.add((()=>le(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&he(t,s,h),t.forceUpdate("surface")}))),300)),!1)},createPattern:he,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,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:Nt,getPatternData:Ht,fillOrFitMode:zt,clipMode:Ft,repeatMode:jt},{toPoint:ue}=M,pe={},fe={};function ge(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),z.string(s,i)):t.addColorStop(s.offset,z.string(s.color,i))}}const{getAngle:_e,getDistance:we}=C,{get:ve,rotateOfOuter:ye,scaleOfOuter:me}=k,{toPoint:be}=M,xe={},Be={};function Ee(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=_e(e,i);o=ve(),n?(me(o,e,r/a*(s||1),1),ye(o,e,t+90)):(me(o,e,1,r/a*(s||1)),ye(o,e,t))}return o}const{getDistance:Le}=C,{toPoint:Re}=M,ke={},Te={};const Se={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:r,opacity:a}=t;ue(s||"top",e,pe),ue(n||"bottom",e,fe);const h=i.canvas.createLinearGradient(pe.x,pe.y,fe.x,fe.y);ge(h,t.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;be(s||"center",e,xe),be(n||"bottom",e,Be);const l=i.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,we(xe,Be));ge(l,t.stops,r);const c={type:o,style:l},d=Ee(e,xe,Be,h,!0);return d&&(c.transform=d),a&&(c.blendMode=a),c},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;Re(s||"center",e,ke),Re(n||"bottom",e,Te);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,ke.x,ke.y):i.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Le(ke,Te));ge(l,t.stops,r);const c={type:o,style:l},d=Ee(e,ke,Te,h||1,i.conicGradientRotate90);return d&&(c.transform=d),a&&(c.blendMode=a),c},getTransform:Ee},{copy:Me,toOffsetOutBounds:Ce}=E,Ae={},Pe={};function Oe(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Me(Ae,t.bounds),Ae.x+=e.x-r.x,Ae.y+=e.y-r.y,s){const{matrix:t}=n;Ae.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Ae.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Ae.width*=s,Ae.height*=s}t.copyWorld(n.canvas,t.bounds,Ae)}else s&&(Me(Ae,e),Ae.x-=e.width/2*(s-1),Ae.y-=e.height/2*(s-1),Ae.width*=s,Ae.height*=s),t.copyWorld(n.canvas,r,s?Ae:e)}const{toOffsetOutBounds:We}=E,De={};const Ie={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Ce(l,Pe),a.forEach(((a,g)=>{p.setWorldShadow(Pe.offsetX+a.x*d,Pe.offsetY+a.y*u,a.blur*d,z.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Oe(p,Pe,n,i),s=l,a.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,l,o,"copy"),s=o),h?p.copyWorld(h,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"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:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;We(l,De),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(De.offsetX+a.x*d,De.offsetY+a.y*u,a.blur*d),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Oe(p,De,n,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,c,l,"source-out"),s=l),p.fillWorld(s,z.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:ze}=v;function Fe(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),Ge(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ge(t,i,s,o);break;case"path":i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function Ge(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 l=0,c=h.length;l<c;l++)i=h[l],a=i.__.mask,a&&(r&&(Fe(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=je(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=je(t)),n||(n=je(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a)||ze(i,e)||i.__render(n||t,e);Fe(this,r,t,n,s,o)};const Ue=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ye=Ue+"_#~&*+\\=|≮≯≈≠=…",Ve=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 Xe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ne=Xe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),He=Xe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),qe=Xe(Ue),Ke=Xe(Ye),Qe=Xe("- —/~|┆·");var $e;!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"}($e||($e={}));const{Letter:Ze,Single:Je,Before:ti,After:ei,Symbol:ii,Break:si}=$e;function ni(t){return Ne[t]?Ze:Qe[t]?si:He[t]?ti:qe[t]?ei:Ke[t]?ii:Ve.test(t)?Je:Ze}const oi={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 ri(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:ai}=oi,{Letter:hi,Single:li,Before:ci,After:di,Symbol:ui,Break:pi}=$e;let fi,gi,_i,wi,vi,yi,mi,bi,xi,Bi,Ei,Li,Ri,ki,Ti,Si,Mi,Ci=[];function Ai(t,e){xi&&!bi&&(bi=xi),fi.data.push({char:t,width:e}),_i+=e}function Pi(){wi+=_i,fi.width=_i,gi.words.push(fi),fi={data:[]},_i=0}function Oi(){ki&&(Ti.paraNumber++,gi.paraStart=!0,ki=!1),xi&&(gi.startCharSize=bi,gi.endCharSize=xi,bi=0),gi.width=wi,Si.width?ai(gi):Mi&&Wi(),Ci.push(gi),gi={words:[]},wi=0}function Wi(){wi>(Ti.maxWidth||0)&&(Ti.maxWidth=wi)}const{top:Di,right:Ii,bottom:zi,left:Fi}=A;function ji(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 Gi={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:l}=e;l&&(o?(s=l[Fi],o-=l[Ii]+l[Fi]):e.autoSizeAlign||(s=l[Fi]),r?(n=l[Di],r-=l[Di]+l[zi]):e.autoSizeAlign||(n=l[Di]));const c={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=h};return function(t,e,s){Ti=t,Ci=t.rows,Si=t.bounds,Mi=!Si.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Si;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;ki=!0,Ei=null,bi=mi=xi=_i=wi=0,fi={data:[]},gi={words:[]};for(let s=0,l=e.length;s<l;s++)yi=e[s],"\n"===yi?(_i&&Pi(),gi.paraEnd=!0,Oi(),ki=!0):(Bi=ni(yi),Bi===hi&&"none"!==r&&(yi=ri(yi,r,!_i)),mi=a.measureText(yi).width,n&&(n<0&&(xi=mi),mi+=n),Li=Bi===li&&(Ei===li||Ei===hi)||Ei===li&&Bi!==di,Ri=!(Bi!==ci&&Bi!==li||Ei!==ui&&Ei!==di),vi=ki&&o?h-o:h,t&&h&&wi+_i+mi>vi&&(i?(_i&&Pi(),wi&&Oi()):(Ri||(Ri=Bi===hi&&Ei==di),Li||Ri||Bi===pi||Bi===ci||Bi===li||_i+mi>vi?(_i&&Pi(),wi&&Oi()):wi&&Oi()))," "===yi&&!0!==ki&&wi+_i===0||(Bi===pi?(" "===yi&&_i&&Pi(),Ai(yi,mi),Pi()):Li||Ri?(_i&&Pi(),Ai(yi,mi)):Ai(yi,mi)),Ei=Bi);_i&&Pi(),wi&&Oi(),Ci.length>0&&(Ci[Ci.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ti.paraNumber++,wi=a.measureText(t).width,Ci.push({x:o||0,text:t,width:wi,paraStart:!0}),Mi&&Wi()}))}(c,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ji(e,"x",t[Fi]);break;case"right":ji(e,"x",-t[Ii])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ji(e,"y",t[Di]);break;case"bottom":ji(e,"y",-t[zi])}}(l,c,e,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x: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(c){case"middle":f+=(_-w)/2;break;case"bottom":f+=_-w}v+=f;let y,m,b,x=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(y=i[r],y.x=p,y.width<g||y.width>g&&!h)switch(l){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-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,b=y.width,a<0&&(y.width<0?(b=-y.width+e.fontSize+a,m-=b,b+=e.fontSize):b-=a),m<s.x&&(s.x=m),b>s.width&&(s.width=b),h&&g&&g<b&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=f,s.height=w}(c,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,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=z.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]}}(c,e),c}};const Ui={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!z.object)return t;t=z.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(U,Gi),Object.assign(z,Ui),Object.assign(Y,Mt),Object.assign(I,de),Object.assign(F,Se),Object.assign(V,Ie),Object.assign(h,{interaction:(t,e,i,s)=>new wt(t,e,i,s),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new D}),K();export{wt as Interaction,ht as Layouter,N as LeaferCanvas,ut as Picker,ct 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 l,defineKey as c,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 b,Run as x,ImageManager as B,BoundsHelper as E,Plugin as L,MathHelper as R,MatrixHelper as k,AlignHelper as T,ImageEvent as S,AroundHelper as M,PointHelper as C,Direction4 as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as P,InteractionBase as O,Cursor as W,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as z,PaintGradient as F,Export as j,Group as G,TextConvert as U,Paint 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 l(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},c(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=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:J,updateAllWorldOpacity: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.running)return;const{target:t}=this;this.times=0;try{t.emit(b.START),this.layoutOnce(),t.emitEvent(new b(b.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=b,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new b(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){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new b(o,a,this.times)),i.emitEvent(new b(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=b,o=this.getBlocks(new d(e));e.emitEvent(new b(i,o,this.times)),ht.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new b(s,o,this.times)),e.emitEvent(new b(n,o,this.times)),this.addBlocks(o),x.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(){const{target:t}=this;this.__eventIds=[t.on_(b.REQUEST,this.layout,this),t.on_(b.AGAIN,this.layoutAgain,this),t.on_(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 ct{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(b.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,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 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=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new y(s);i.save(),s.spread(ct.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.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||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(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(b.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(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)}}ct.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 ct(t,e,i),selector:(t,e)=>new pt(t,e)}),i.layout=ht.fullLayout;const ft={convert(t,e){const i=P.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=P.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=P.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=P.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:_t}=P;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(P.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({},P.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=P.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"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){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.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=s;t&&(e.fillStyle=t),n.forEach((t=>o.forEach((s=>e.fillRect(t.x,t.y+s,t.width,i)))))}}function yt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?xt(t,!0,e,i):bt(e,i);break;case"inside":mt("inside",t,n,e,i);break;case"outside":mt("outside",t,n,e,i)}}function mt(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?xt(e,!0,s,a):bt(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",vt(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function bt(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 xt(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?bt(i,s):s.stroke(),s.restoreBlendMode()):e?bt(i,s):s.stroke())}function Bt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:Et,getOuterOf:Lt,getByMove:Rt,getIntersectData:kt}=E;let Tt;function St(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:z.string(r,a)};case"image":return I.image(i,t,e,s,!Tt||!Tt[e.url]);case"linear":return F.linearGradient(e,s);case"radial":return F.radialGradient(e,s);case"angular":return F.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:z.string(e)}:void 0}}const Mt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Tt=I.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=St(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?vt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&I.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?vt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?vt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?vt(e,i):n?i.fill(n):i.fill())},fillText:vt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)yt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&Bt(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)yt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),xt(t,!1,e,i),s.__useArrow&&Bt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),xt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),xt(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:yt,drawTextStroke:bt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,d=kt(s?Et(e.bounds,l===c?s*l:[s*c,s*l]):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),l*=u,c*=p),a=Lt(n,r),o=Rt(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:l,scaleY:c}}};let Ct={};const{get:At,rotateOfOuter:Pt,translate:Ot,scaleOfOuter:Wt,scale:Dt,rotate:It}=k;function zt(t,e,i,s,n,o,r){const a=At();Ot(a,e.x+i,e.y+s),Dt(a,n,o),r&&Pt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Ft(t,e,i,s,n,o,r){const a=At();Ot(a,e.x+i,e.y+s),n&&Dt(a,n,o),r&&It(a,r),t.transform=a}function jt(t,e,i,s,n,o,r,a,h,l){const c=At();if(h)if("center"===l)Pt(c,{x:i/2,y:s/2},h);else switch(It(c,h),h){case 90:Ot(c,s,0);break;case 180:Ot(c,i,s);break;case 270:Ot(c,0,i)}Ct.x=e.x+n,Ct.y=e.y+o,Ot(c,Ct.x,Ct.y),r&&Wt(c,Ct,r,a),t.transform=c}const{get:Gt,translate:Ut}=k,Yt=new y,Vt={},Xt={};function Nt(t,e,i,s){const{blendMode:n,changeful:o,sync:r}=i;n&&(t.blendMode=n),o&&(t.changeful=o),r&&(t.sync=r),t.data=Ht(i,s,e)}function Ht(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Yt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:h,scale:l,size:c,rotation:d,repeat:u,filters:p}=t,f=e.width===s&&e.height===n,g={mode:r},_="center"!==a&&(d||0)%180==90,w=_?n:s,v=_?s:n;let y,m,b=0,x=0;if(r&&"cover"!==r&&"fit"!==r)(l||c)&&(R.getScaleData(l,c,i,Xt),y=Xt.scaleX,m=Xt.scaleY);else if(!f||d){const t=e.width/w,i=e.height/v;y=m="fit"===r?Math.min(t,i):Math.max(t,i),b+=(e.width-s*y)/2,x+=(e.height-n*m)/2}if(a){const t={x:b,y:x,width:w,height:v};y&&(t.width*=y,t.height*=m),T.toPoint(a,t,e,Vt,!0),b+=Vt.x,x+=Vt.y}switch(h&&(b+=h.x,x+=h.y),r){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(b||x||y||d)&&Ft(g,e,b,x,y,m,d);break;case"repeat":(!f||y||d)&&jt(g,e,s,n,b,x,y,m,d,a),u||(g.repeat="repeat");break;default:y&&zt(g,e,b,x,y,m,d)}return g.transform||(e.x||e.y)&&(g.transform=Gt(),Ut(g.transform,e.x,e.y)),y&&"stretch"!==r&&(g.scaleX=y,g.scaleY=m),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 qt,Kt=new y;const{isSame:Qt}=E;function $t(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||Nt(n,s,i,o),!0}function Zt(t,e){ee(t,S.LOAD,e)}function Jt(t,e){ee(t,S.LOADED,e)}function te(t,e,i){e.error=i,t.forceUpdate("surface"),ee(t,S.ERROR,e)}function ee(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function ie(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:se,scale:ne,copy:oe}=k,{ceil:re,abs:ae}=Math;function he(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=ae(n),o=ae(o);const{image:t,data:a}=e;let h,l,{width:c,height:d,scaleX:u,scaleY:p,transform:f,repeat:g}=a;u&&(l=se(),oe(l,f),ne(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,c*=n,d*=o;const _=c*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,c/=h,d/=h),u&&(n/=u,o/=p),(f||1!==n||1!==o)&&(l||(l=se(),f&&oe(l,f)),ne(l,1/n,1/o));const v=t.getCanvas(re(c)||1,re(d)||1,a.opacity,a.filters),y=t.getPattern(v,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=y,e.patternId=r,!0}}function le(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:ce}=Math;const de={image:function(t,e,i,s,n){let o,r;const a=B.get(i);return qt&&i===qt.paint&&Qt(s,qt.boxBounds)?o=qt.leafPaint:(o={type:i.type,image:a},qt=a.use>1?{leafPaint:o,paint:i,boxBounds:Kt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?($t(t,e,i,a,o,s),n&&(Zt(t,r),Jt(t,r))):a.error?n&&te(t,r,a.error):(n&&(ie(t,!0),Zt(t,r)),o.loadId=a.load((()=>{ie(t,!1),t.destroyed||($t(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Jt(t,r)),o.loadId=null}),(e=>{ie(t,!1),te(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:r,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:h}=e,{data:l}=s;if(!l||s.patternId===r+"-"+a+"-"+h&&!j.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||j.running)){let{width:t,height:e}=l;t*=ce(r)*h,e*=ce(a)*h,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,l),!0):(!s.style||s.sync||j.running?he(t,s,h):s.patternTask||(s.patternTask=B.patternTasker.add((()=>le(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&he(t,s,h),t.forceUpdate("surface")}))),300)),!1)},createPattern:he,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,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:Nt,getPatternData:Ht,fillOrFitMode:zt,clipMode:Ft,repeatMode:jt},{toPoint:ue}=M,pe={},fe={};function ge(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),z.string(s,i)):t.addColorStop(s.offset,z.string(s.color,i))}}const{getAngle:_e,getDistance:we}=C,{get:ve,rotateOfOuter:ye,scaleOfOuter:me}=k,{toPoint:be}=M,xe={},Be={};function Ee(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=_e(e,i);o=ve(),n?(me(o,e,r/a*(s||1),1),ye(o,e,t+90)):(me(o,e,1,r/a*(s||1)),ye(o,e,t))}return o}const{getDistance:Le}=C,{toPoint:Re}=M,ke={},Te={};const Se={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:r,opacity:a}=t;ue(s||"top",e,pe),ue(n||"bottom",e,fe);const h=i.canvas.createLinearGradient(pe.x,pe.y,fe.x,fe.y);ge(h,t.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;be(s||"center",e,xe),be(n||"bottom",e,Be);const l=i.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,we(xe,Be));ge(l,t.stops,r);const c={type:o,style:l},d=Ee(e,xe,Be,h,!0);return d&&(c.transform=d),a&&(c.blendMode=a),c},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;Re(s||"center",e,ke),Re(n||"bottom",e,Te);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,ke.x,ke.y):i.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Le(ke,Te));ge(l,t.stops,r);const c={type:o,style:l},d=Ee(e,ke,Te,h||1,i.conicGradientRotate90);return d&&(c.transform=d),a&&(c.blendMode=a),c},getTransform:Ee},{copy:Me,toOffsetOutBounds:Ce}=E,Ae={},Pe={};function Oe(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Me(Ae,t.bounds),Ae.x+=e.x-r.x,Ae.y+=e.y-r.y,s){const{matrix:t}=n;Ae.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Ae.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Ae.width*=s,Ae.height*=s}t.copyWorld(n.canvas,t.bounds,Ae)}else s&&(Me(Ae,e),Ae.x-=e.width/2*(s-1),Ae.y-=e.height/2*(s-1),Ae.width*=s,Ae.height*=s),t.copyWorld(n.canvas,r,s?Ae:e)}const{toOffsetOutBounds:We}=E,De={};const Ie={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Ce(l,Pe),a.forEach(((a,g)=>{p.setWorldShadow(Pe.offsetX+a.x*d,Pe.offsetY+a.y*u,a.blur*d,z.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Oe(p,Pe,n,i),s=l,a.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,l,o,"copy"),s=o),h?p.copyWorld(h,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"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:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;We(l,De),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(De.offsetX+a.x*d,De.offsetY+a.y*u,a.blur*d),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Oe(p,De,n,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,c,l,"source-out"),s=l),p.fillWorld(s,z.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:ze}=v;function Fe(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),Ge(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ge(t,i,s,o);break;case"path":i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function Ge(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 l=0,c=h.length;l<c;l++)i=h[l],a=i.__.mask,a&&(r&&(Fe(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=je(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=je(t)),n||(n=je(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a)||ze(i,e)||i.__render(n||t,e);Fe(this,r,t,n,s,o)};const Ue=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ye=Ue+"_#~&*+\\=|≮≯≈≠=…",Ve=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 Xe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ne=Xe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),He=Xe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),qe=Xe(Ue),Ke=Xe(Ye),Qe=Xe("- —/~|┆·");var $e;!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"}($e||($e={}));const{Letter:Ze,Single:Je,Before:ti,After:ei,Symbol:ii,Break:si}=$e;function ni(t){return Ne[t]?Ze:Qe[t]?si:He[t]?ti:qe[t]?ei:Ke[t]?ii:Ve.test(t)?Je:Ze}const oi={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 ri(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:ai}=oi,{Letter:hi,Single:li,Before:ci,After:di,Symbol:ui,Break:pi}=$e;let fi,gi,_i,wi,vi,yi,mi,bi,xi,Bi,Ei,Li,Ri,ki,Ti,Si,Mi,Ci=[];function Ai(t,e){xi&&!bi&&(bi=xi),fi.data.push({char:t,width:e}),_i+=e}function Pi(){wi+=_i,fi.width=_i,gi.words.push(fi),fi={data:[]},_i=0}function Oi(){ki&&(Ti.paraNumber++,gi.paraStart=!0,ki=!1),xi&&(gi.startCharSize=bi,gi.endCharSize=xi,bi=0),gi.width=wi,Si.width?ai(gi):Mi&&Wi(),Ci.push(gi),gi={words:[]},wi=0}function Wi(){wi>(Ti.maxWidth||0)&&(Ti.maxWidth=wi)}const{top:Di,right:Ii,bottom:zi,left:Fi}=A;function ji(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 Gi={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:l}=e;l&&(o?(s=l[Fi],o-=l[Ii]+l[Fi]):e.autoSizeAlign||(s=l[Fi]),r?(n=l[Di],r-=l[Di]+l[zi]):e.autoSizeAlign||(n=l[Di]));const c={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=h};return function(t,e,s){Ti=t,Ci=t.rows,Si=t.bounds,Mi=!Si.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Si;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;ki=!0,Ei=null,bi=mi=xi=_i=wi=0,fi={data:[]},gi={words:[]};for(let s=0,l=e.length;s<l;s++)yi=e[s],"\n"===yi?(_i&&Pi(),gi.paraEnd=!0,Oi(),ki=!0):(Bi=ni(yi),Bi===hi&&"none"!==r&&(yi=ri(yi,r,!_i)),mi=a.measureText(yi).width,n&&(n<0&&(xi=mi),mi+=n),Li=Bi===li&&(Ei===li||Ei===hi)||Ei===li&&Bi!==di,Ri=!(Bi!==ci&&Bi!==li||Ei!==ui&&Ei!==di),vi=ki&&o?h-o:h,t&&h&&wi+_i+mi>vi&&(i?(_i&&Pi(),wi&&Oi()):(Ri||(Ri=Bi===hi&&Ei==di),Li||Ri||Bi===pi||Bi===ci||Bi===li||_i+mi>vi?(_i&&Pi(),wi&&Oi()):wi&&Oi()))," "===yi&&!0!==ki&&wi+_i===0||(Bi===pi?(" "===yi&&_i&&Pi(),Ai(yi,mi),Pi()):Li||Ri?(_i&&Pi(),Ai(yi,mi)):Ai(yi,mi)),Ei=Bi);_i&&Pi(),wi&&Oi(),Ci.length>0&&(Ci[Ci.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ti.paraNumber++,wi=a.measureText(t).width,Ci.push({x:o||0,text:t,width:wi,paraStart:!0}),Mi&&Wi()}))}(c,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ji(e,"x",t[Fi]);break;case"right":ji(e,"x",-t[Ii])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ji(e,"y",t[Di]);break;case"bottom":ji(e,"y",-t[zi])}}(l,c,e,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x: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(c){case"middle":f+=(_-w)/2;break;case"bottom":f+=_-w}v+=f;let y,m,b,x=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(y=i[r],y.x=p,y.width<g||y.width>g&&!h)switch(l){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-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,b=y.width,a<0&&(y.width<0?(b=-y.width+e.fontSize+a,m-=b,b+=e.fontSize):b-=a),m<s.x&&(s.x=m),b>s.width&&(s.width=b),h&&g&&g<b&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=f,s.height=w}(c,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,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=z.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]}}(c,e),c}};const Ui={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!z.object)return t;t=z.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(U,Gi),Object.assign(z,Ui),Object.assign(Y,Mt),Object.assign(I,de),Object.assign(F,Se),Object.assign(V,Ie),Object.assign(h,{interaction:(t,e,i,s)=>new wt(t,e,i,s),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new D}),K();export{wt as Interaction,ht as Layouter,N as LeaferCanvas,ut as Picker,ct as Renderer,pt as Selector,$ as Watcher,K as useCanvas};
|
|
2
2
|
//# sourceMappingURL=web.esm.min.js.map
|