leafer-draw 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +77 -47
- package/dist/web.esm.js +78 -48
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +230 -134
- 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 +228 -134
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
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 a,FileHelper as r,Creator as d,LeaferImage as l,defineKey as h,LeafList as c,RenderEvent as u,ChildEvent as f,WatchEvent as p,PropertyEvent as g,LeafHelper as _,BranchHelper as w,LeafBoundsHelper as y,Bounds as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as k,MatrixHelper as E,MathHelper as R,AlignHelper as S,PointHelper as L,ImageEvent as A,AroundHelper as O,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as T,Paint as W,ColorConvert as D,PaintGradient as I,Export as M,Group as P,TextConvert as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const U=t.get("LeaferCanvas");class V 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 U.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),U.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:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}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()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:Y,fileType:G}=r;function N(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=Y(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,Y(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(Y(G(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=d.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(d,{canvas:(t,e)=>new V(t,e),image:t=>new l(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},h(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):j.indexOf("AppleWebKit")>-1&&(i.fullImageShadow=!0),j.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):j.indexOf("Mac")>-1?i.os="Mac":j.indexOf("Linux")>-1&&(i.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,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===f.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 p(p.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[g.CHANGE,this.__onAttrChange,this],[[f.ADD,f.REMOVE],this.__onChildEvent,this],[p.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:X,updateBounds:H,updateChange:Q}=_,{pushAllChildBranch:Z,pushAllParent:$}=w;const{worldBounds:K}=y;class J{constructor(t){this.updatedBounds=new m,this.beforeBounds=new m,this.afterBounds=new m,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,K),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:tt,updateAllChange:et}=_,it=t.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(p.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,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?(X(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(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||H(s[t])}H(i)}}))}(this.__levelList),function(t){t.list.forEach(Q)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),st.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new J([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new J(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[p.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=t.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(u.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(u.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new m,nt.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,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new m,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new m(s);i.save(),s.spread(ot.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new m;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 m(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 m(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||nt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new u(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[u.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[u.AGAIN,this.renderAgain,this],[o.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function at(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function rt(t,e){t.__.__font?at(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function dt(t,e,i){switch(e.__.strokeAlign){case"center":lt(t,1,e,i);break;case"inside":ht(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?lt(t,2,e,i):ht(t,"outside",e,i)}}function lt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?ft(t,!0,i,s):ut(i,s)}function ht(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,lt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",at(i,n),n.blendMode="normal",ct(s,n,i),n.recycle(i.__nowWorld)}function ct(t,e,s){s.__worldFlipped||i.fullImageShadow?t.copyWorldByReset(e,s.__nowWorld):t.copyWorldToInner(e,s.__nowWorld,s.__layout.renderBounds)}function ut(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 ft(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&T.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?ut(i,s):s.stroke(),s.restoreBlendMode()):e?ut(i,s):s.stroke())}function pt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)dt(t,e,i);else switch(s.strokeAlign){case"center":gt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),gt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)gt(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),gt(t,2,e,o),o.clipUI(s),o.clearWorld(n),ct(i,o,e),o.recycle(e.__nowWorld)}}(t,e,i)}}function gt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?ft(t,!1,i,s):s.stroke(),n.__useArrow&&W.strokeArrow(t,i,s)}ot.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=st.fullLayout;const{getSpread:_t,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=k;let vt;const{stintSet:xt}=s,{hasTransparent:bt}=D;function Bt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=T.image(i,t,e,n,!vt||!vt[e.url]);break;case"linear":s=I.linearGradient(e,n);break;case"radial":s=I.radialGradient(e,n);break;case"angular":s=I.conicGradient(e,n);break;case"solid":const{type:o,color:a,opacity:r}=e;s={type:o,style:D.string(a,r)};break;default:void 0!==e.r&&(s={type:"solid",style:D.string(e)})}return s&&("string"==typeof s.style&&bt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const kt={compute:function(t,e){const i=e.__,s=[];let n,o,a=i.__input[t];a instanceof Array||(a=[a]),vt=T.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Bt(t,a[n],e))&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),o=!0),"fill"===t?(xt(i,"__isAlphaPixelFill",n),xt(i,"__isTransparentFill",o)):(xt(i,"__isAlphaPixelStroke",n),xt(i,"__isTransparentStroke",o))},fill:function(t,e,i){i.fillStyle=t,rt(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(T.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),rt(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),rt(e,i),i.restoreBlendMode()):rt(e,i)}},fillPathOrText:rt,fillText:at,stroke:pt,strokes:function(t,e,i){pt(t,e,i)},strokeText:dt,drawTextStroke:ut,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:h}=n;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(n))d=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=mt(s?_t(e.bounds,l===h?s*l:[s*h,s*l]):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=wt(n,a),o=yt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Et={};const{get:Rt,rotateOfOuter:St,translate:Lt,scaleOfOuter:At,scale:Ot,rotate:Ct,skew:Tt}=E;function Wt(t,e,i,s,n,o,a){const r=Rt();Lt(r,e.x+i,e.y+s),Ot(r,n,o),a&&St(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Dt(t,e,i,s,n,o,a,r){const d=Rt();a&&Ct(d,a),r&&Tt(d,r.x,r.y),n&&Ot(d,n,o),Lt(d,e.x+i,e.y+s),t.transform=d}function It(t,e,i,s,n,o,a,r,d,l){const h=Rt();if(d)if("center"===l)St(h,{x:i/2,y:s/2},d);else switch(Ct(h,d),d){case 90:Lt(h,s,0);break;case 180:Lt(h,i,s);break;case 270:Lt(h,0,i)}Et.x=e.x+n,Et.y=e.y+o,Lt(h,Et.x,Et.y),a&&At(h,Et,a,r),t.transform=h}const{get:Mt,translate:Pt}=E,zt=new m,Ft={},Ut={};function Vt(t,e,i,s){const{changeful:n,sync:o,editing:a}=i;n&&(t.changeful=n),o&&(t.sync=o),a&&(t.editing=a),t.data=Yt(i,s,e)}function Yt(t,e,i){t.padding&&(e=zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:o,mode:a,align:r,offset:d,scale:l,size:h,rotation:c,skew:u,repeat:f,filters:p}=t,g=e.width===s&&e.height===n,_={mode:a},w="center"!==r&&(c||0)%180==90;let y,m;switch(k.set(Ut,0,0,w?n:s,w?s:n),a&&"cover"!==a&&"fit"!==a?((l||h)&&(R.getScaleData(l,h,i,Ft),y=Ft.scaleX,m=Ft.scaleY),r&&(y&&k.scale(Ut,y,m,!0),S.toPoint(r,Ut,e,Ut,!0,!0))):g&&!c||(y=m=k.getFitScale(e,Ut,"fit"!==a),k.put(e,i,r,y,!1,Ut),k.scale(Ut,y,m,!0)),d&&L.move(Ut,d),a){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(Ut.x||Ut.y||y||c||u)&&Dt(_,e,Ut.x,Ut.y,y,m,c,u);break;case"repeat":(!g||y||c)&&It(_,e,s,n,Ut.x,Ut.y,y,m,c,r),f||(_.repeat="repeat");break;default:y&&Wt(_,e,Ut.x,Ut.y,y,m,c)}return _.transform||(e.x||e.y)&&(_.transform=Mt(),Pt(_.transform,e.x,e.y)),y&&"stretch"!==a&&(_.scaleX=y,_.scaleY=m),_.width=s,_.height=n,o&&(_.opacity=o),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let Gt,Nt=new m;const{isSame:jt}=k;function qt(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||Vt(n,s,i,o),!0}function Xt(t,e){Zt(t,A.LOAD,e)}function Ht(t,e){Zt(t,A.LOADED,e)}function Qt(t,e,i){e.error=i,t.forceUpdate("surface"),Zt(t,A.ERROR,e)}function Zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function $t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Kt,scale:Jt,copy:te}=E,{ceil:ee,abs:ie}=Math;function se(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(e.patternId===a||t.destroyed)return!1;{n=ie(n),o=ie(o);const{image:t,data:r}=e;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(u=ie(u),f=ie(f),l=Kt(),te(l,p),Jt(l,1/u,1/f),n*=u,o*=f),n*=s,o*=s,h*=n,c*=o;const _=h*c;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&&(d=Math.sqrt(_/w)),d&&(n/=d,o/=d,h/=d,c/=d),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(l||(l=Kt(),p&&te(l,p)),Jt(l,1/n,1/o));const y=t.getCanvas(ee(h)||1,ee(c)||1,r.opacity,r.filters),m=t.getPattern(y,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=a,!0}}function ne(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{d(s.next(t))}catch(t){o(t)}}function r(t){try{d(s.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:oe}=Math;const ae={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Gt&&i===Gt.paint&&jt(s,Gt.boxBounds)?o=Gt.leafPaint:(o={type:i.type,image:r},r.hasAlphaPixel&&(o.isTransparent=!0),Gt=r.use>1?{leafPaint:o,paint:i,boxBounds:Nt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(qt(t,e,i,r,o,s),n&&(Xt(t,a),Ht(t,a))):r.error?n&&Qt(t,a,r.error):(n&&($t(t,!0),Xt(t,a)),o.loadId=r.load((()=>{$t(t,!1),t.destroyed||(qt(t,e,i,r,o,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ht(t,a)),o.loadId=void 0}),(e=>{$t(t,!1),Qt(t,a,e),o.loadId=void 0})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=e,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+d&&!M.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||M.running)){let{width:t,height:e}=l;t*=oe(a)*d,e*=oe(r)*d,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,l),!0):(!s.style||s.sync||M.running?se(t,s,d):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ne(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&se(t,s,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:se,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a,r;for(let d=0,l=i.length;d<l;d++)s=i[d],n=s.image,r=n&&n.url,r&&(o||(o={}),o[r]=!0,B.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Vt,getPatternData:Yt,fillOrFitMode:Wt,clipMode:Dt,repeatMode:It},{toPoint:re}=O,{hasTransparent:de}=D,le={},he={};function ce(t,e,i,s){if(i){let n,o,a,r;for(let t=0,d=i.length;t<d;t++)n=i[t],"string"==typeof n?(a=t/(d-1),o=D.string(n,s)):(a=n.offset,o=D.string(n.color,s)),e.addColorStop(a,o),!r&&de(o)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:ue,getDistance:fe}=L,{get:pe,rotateOfOuter:ge,scaleOfOuter:_e}=E,{toPoint:we}=O,ye={},me={};function ve(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=ue(e,i);o=pe(),n?(_e(o,e,a/r*(s||1),1),ge(o,e,t+90)):(_e(o,e,1,a/r*(s||1)),ge(o,e,t))}return o}const{getDistance:xe}=L,{toPoint:be}=O,Be={},ke={};const Ee={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:a}=t;re(s||"top",e,le),re(n||"bottom",e,he);const r=i.canvas.createLinearGradient(le.x,le.y,he.x,he.y),d={type:o,style:r};return ce(d,r,t.stops,a),d},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;we(s||"center",e,ye),we(n||"bottom",e,me);const d=i.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,fe(ye,me)),l={type:o,style:d};ce(l,d,t.stops,a);const h=ve(e,ye,me,r,!0);return h&&(l.transform=h),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;be(s||"center",e,Be),be(n||"bottom",e,ke);const d=i.conicGradientSupport?i.canvas.createConicGradient(0,Be.x,Be.y):i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,xe(Be,ke)),l={type:o,style:d};ce(l,d,t.stops,a);const h=ve(e,Be,ke,r||1,i.conicGradientRotate90);return h&&(l.transform=h),l},getTransform:ve},{copy:Re,toOffsetOutBounds:Se}=k,Le={},Ae={};function Oe(t,e,s,n){const{bounds:o,shapeBounds:a}=n;if(i.fullImageShadow){if(Re(Le,t.bounds),Le.x+=e.x-a.x,Le.y+=e.y-a.y,s){const{matrix:t}=n;Le.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Le.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Le.width*=s,Le.height*=s}t.copyWorld(n.canvas,t.bounds,Le)}else s&&(Re(Le,e),Le.x-=e.width/2*(s-1),Le.y-=e.height/2*(s-1),Le.width*=s,Le.height*=s),t.copyWorld(n.canvas,a,s?Le:e)}const{toOffsetOutBounds:Ce}=k,Te={};const We={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Se(l,Ae),r.forEach(((r,g)=>{f.setWorldShadow(Ae.offsetX+r.x*c,Ae.offsetY+r.y*u,r.blur*c,D.string(r.color)),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Oe(f,Ae,n,i),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),s=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ce(l,Te),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Te.offsetX+r.x*c,Te.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Oe(f,Te,n,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,h,l,"source-out"),s=l),f.fillWorld(s,D.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:De}=y;function Ie(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),Pe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Pe(t,i,s,o);break;case"path":i.restore()}}function Me(t){return t.getSameCanvas(!1,!0)}function Pe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}P.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(a&&(Ie(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Me(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Me(t)),n||(n=Me(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||De(i,e)||i.__render(n||t,e);Ie(this,a,t,n,s,o)};const ze=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Fe=ze+"_#~&*+\\=|≮≯≈≠=…",Ue=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ye=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ge=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ne=Ve(ze),je=Ve(Fe),qe=Ve("- —/~|┆·");var Xe;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Xe||(Xe={}));const{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Ke,Break:Je}=Xe;function ti(t){return Ye[t]?He:qe[t]?Je:Ge[t]?Ze:Ne[t]?$e:je[t]?Ke:Ue.test(t)?Qe:He}const ei={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 ii(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:si}=ei,{Letter:ni,Single:oi,Before:ai,After:ri,Symbol:di,Break:li}=Xe;let hi,ci,ui,fi,pi,gi,_i,wi,yi,mi,vi,xi,bi,Bi,ki,Ei,Ri,Si=[];function Li(t,e){yi&&!wi&&(wi=yi),hi.data.push({char:t,width:e}),ui+=e}function Ai(){fi+=ui,hi.width=ui,ci.words.push(hi),hi={data:[]},ui=0}function Oi(){Bi&&(ki.paraNumber++,ci.paraStart=!0,Bi=!1),yi&&(ci.startCharSize=wi,ci.endCharSize=yi,wi=0),ci.width=fi,Ei.width?si(ci):Ri&&Ci(),Si.push(ci),ci={words:[]},fi=0}function Ci(){fi>(ki.maxWidth||0)&&(ki.maxWidth=fi)}const{top:Ti,right:Wi,bottom:Di,left:Ii}=C;function Mi(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 Pi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o?(s=l[Ii],o-=l[Wi]+l[Ii]):e.autoSizeAlign||(s=l[Ii]),a?(n=l[Ti],a-=l[Ti]+l[Di]):e.autoSizeAlign||(n=l[Ti]));const h={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){ki=t,Si=t.rows,Ei=t.bounds,Ri=!Ei.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=i,{width:d,height:l}=Ei;if(d||l||n||"none"!==a){const t="none"!==s.textWrap,i="break"===s.textWrap;Bi=!0,vi=null,wi=_i=yi=ui=fi=0,hi={data:[]},ci={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)gi=e[s],"\n"===gi?(ui&&Ai(),ci.paraEnd=!0,Oi(),Bi=!0):(mi=ti(gi),mi===ni&&"none"!==a&&(gi=ii(gi,a,!ui)),_i=r.measureText(gi).width,n&&(n<0&&(yi=_i),_i+=n),xi=mi===oi&&(vi===oi||vi===ni)||vi===oi&&mi!==ri,bi=!(mi!==ai&&mi!==oi||vi!==di&&vi!==ri),pi=Bi&&o?d-o:d,t&&d&&fi+ui+_i>pi&&(i?(ui&&Ai(),fi&&Oi()):(bi||(bi=mi===ni&&vi==ri),xi||bi||mi===li||mi===ai||mi===oi||ui+_i>pi?(ui&&Ai(),fi&&Oi()):fi&&Oi()))," "===gi&&!0!==Bi&&fi+ui===0||(mi===li?(" "===gi&&ui&&Ai(),Li(gi,_i),Ai()):xi||bi?(ui&&Ai(),Li(gi,_i)):Li(gi,_i)),vi=mi);ui&&Ai(),fi&&Oi(),Si.length>0&&(Si[Si.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{ki.paraNumber++,fi=r.measureText(t).width,Si.push({x:o||0,text:t,width:fi,paraStart:!0}),Ri&&Ci()}))}(h,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Mi(e,"x",t[Ii]);break;case"right":Mi(e,"x",-t[Wi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Mi(e,"y",t[Ti]);break;case"bottom":Mi(e,"y",-t[Di])}}(l,h,e,o,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=o*n+(c?c*(t.paraNumber-1):0),y=a;if(d&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let a=0,h=n;a<h;a++){if(m=i[a],m.x=f,m.width<g||m.width>g&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&a>0&&(y+=c),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),d&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(h,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:a}=e;let r,d,l,h,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,h=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==n||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(h,e,o),h.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,h=s+n-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<h));s--){if(d<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e,s,o),"none"!==r&&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=D.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]}}(h,e),h}};const zi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.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(z,Pi),Object.assign(D,zi),Object.assign(W,kt),Object.assign(T,ae),Object.assign(I,Ee),Object.assign(F,We),N();export{st as Layouter,V as LeaferCanvas,ot as Renderer,q as Watcher,N as useCanvas};
|
|
1
|
+
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as a,canvasPatch as o,FileHelper as r,Creator as l,LeaferImage as d,defineKey as h,LeafList as c,RenderEvent as u,ChildEvent as f,WatchEvent as p,PropertyEvent as g,LeafHelper as _,BranchHelper as w,LeafBoundsHelper as y,Bounds as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as k,BoundsHelper as B,getMatrixData as S,MatrixHelper as E,MathHelper as R,AlignHelper as A,PointHelper as L,ImageEvent as C,AroundHelper as O,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as W,Paint as D,ColorConvert as P,PaintGradient as M,Export as I,Group as z,TextConvert as F,Effect as U}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const Y=t.get("LeaferCanvas");class V 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 Y.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),Y.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:a,height:o}=this.autoBounds.getBoundsFrom(t),r={width:a,height:o,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}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 a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}o(CanvasRenderingContext2D.prototype),o(Path2D.prototype);const{mineType:G,fileType:N}=r;function j(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=G(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,G(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(G(N(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:a}=i.image;a&&(n.setAttribute("crossOrigin",a),n.crossOrigin=a),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=l.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(l,{canvas:(t,e)=>new V(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},h(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:X}=navigator;X.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):X.indexOf("AppleWebKit")>-1&&(i.fullImageShadow=!0),X.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):X.indexOf("Mac")>-1?i.os="Mac":X.indexOf("Linux")>-1&&(i.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,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===f.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 p(p.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[g.CHANGE,this.__onAttrChange,this],[[f.ADD,f.REMOVE],this.__onChildEvent,this],[p.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:H,updateBounds:Q,updateChange:Z}=_,{pushAllChildBranch:$,pushAllParent:K}=w;const{worldBounds:J}=y;class tt{constructor(t){this.updatedBounds=new m,this.beforeBounds=new m,this.afterBounds=new m,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,J)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,J),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:et,updateAllChange:it}=_,st=t.get("Layouter");class nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(p.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,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?(H(t,!0),e.add(t),t.isBranch&&$(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(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||Q(s[t])}Q(i)}}))}(this.__levelList),function(t){t.list.forEach(Z)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(a,r,this.times)),i.emitEvent(new x(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new c(e));e.emitEvent(new x(i,a,this.times)),nt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),b.end(t)}static fullLayout(t){et(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[p.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=t.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(u.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(u.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new m,at.log(e.innerName,"---\x3e");try{this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),k.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new m,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new m(s);i.save(),s.spread(ot.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),a=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,a),this.renderBounds=i=i||e,this.renderOptions=a,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 m;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 m(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 m(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||at.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new u(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[u.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[u.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function rt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function lt(t,e){t.__.__font?rt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function dt(t,e,i){switch(e.__.strokeAlign){case"center":ht(t,1,e,i);break;case"inside":ct(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ht(t,2,e,i):ct(t,"outside",e,i)}}function ht(t,e,i,s){const n=i.__;"object"==typeof t?ft(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),ut(i,s))}function ct(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ht(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",rt(i,n),n.blendMode="normal",_.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function ut(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=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(a){const{decorationHeight:t}=s;n.forEach((i=>a.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function ft(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!W.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?ut(s,n):n.stroke(),n.restoreBlendMode()):i?ut(s,n):n.stroke()}}function pt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)dt(t,e,i);else switch(s.strokeAlign){case"center":gt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),gt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)gt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),gt(t,2,e,a),a.clipUI(s),a.clearWorld(n),_.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function gt(t,e,i,s){const n=i.__;"object"==typeof t?ft(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&D.strokeArrow(t,i,s)}ot.clipSpread=10,Object.assign(l,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=nt.fullLayout;const{getSpread:_t,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=B;let vt;const{stintSet:xt}=s,{hasTransparent:bt}=P;function kt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=W.image(i,t,e,n,!vt||!vt[e.url]);break;case"linear":s=M.linearGradient(e,n);break;case"radial":s=M.radialGradient(e,n);break;case"angular":s=M.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:P.string(o,r)};break;default:void 0!==e.r&&(s={type:"solid",style:P.string(e)})}if(s){if("string"==typeof s.style&&bt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.blendMode&&(s.blendMode=e.blendMode)}return s}const Bt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];r instanceof Array||(r=[r]),vt=W.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=kt(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),a=!0),"fill"===t?(xt(i,"__isAlphaPixelFill",n),xt(i,"__isTransparentFill",a)):(xt(i,"__isAlphaPixelStroke",n),xt(i,"__isTransparentStroke",a),xt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,lt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(W.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);i.scale(1/t,1/s)}s.blendMode&&(i.blendMode=s.blendMode),lt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),lt(e,i),i.restoreBlendMode()):lt(e,i)}},fillPathOrText:lt,fillText:rt,stroke:pt,strokes:function(t,e,i){pt(t,e,i)},strokeText:dt,drawTextStroke:ut,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:h}=n;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(n))l=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=mt(s?_t(e.bounds,d===h?s*d:[s*h,s*d]):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),r=wt(n,o),a=yt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let St={},Et=S();const{get:Rt,rotateOfOuter:At,translate:Lt,scaleOfOuter:Ct,multiplyParent:Ot,scale:Tt,rotate:Wt,skew:Dt}=E;function Pt(t,e,i,s,n,a,o){const r=Rt();Lt(r,e.x+i,e.y+s),Tt(r,n,a),o&&At(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Mt(t,e,i,s,n,a,o,r,l){const d=Rt();o&&Wt(d,o),r&&Dt(d,r.x,r.y),n&&Tt(d,n,a),Lt(d,e.x+i,e.y+s),l&&(Et.a=e.width/l.width,Et.d=e.height/l.height,Ot(d,Et)),t.transform=d}function It(t,e,i,s,n,a,o,r,l,d){const h=Rt();if(l)if("center"===d)At(h,{x:i/2,y:s/2},l);else switch(Wt(h,l),l){case 90:Lt(h,s,0);break;case 180:Lt(h,i,s);break;case 270:Lt(h,0,i)}St.x=e.x+n,St.y=e.y+a,Lt(h,St.x,St.y),o&&Ct(h,St,o,r),t.transform=h}const{get:zt,translate:Ft}=E,Ut=new m,Yt={},Vt={};function Gt(t,e,i,s){const{changeful:n,sync:a,editing:o,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.editing=o),r&&(t.scaleFixed=r),t.data=Nt(i,s,e)}function Nt(t,e,i){t.padding&&(e=Ut.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:p,filters:g}=t,_=e.width===s&&e.height===n,w={mode:o},y="center"!==r&&(c||0)%180==90;let m,v;switch(B.set(Vt,0,0,y?n:s,y?s:n),o&&"cover"!==o&&"fit"!==o?((d||h)&&(R.getScaleData(d,h,i,Yt),m=Yt.scaleX,v=Yt.scaleY),r&&(m&&B.scale(Vt,m,v,!0),A.toPoint(r,Vt,e,Vt,!0,!0))):_&&!c||(m=v=B.getFitScale(e,Vt,"fit"!==o),B.put(e,i,r,m,!1,Vt),B.scale(Vt,m,v,!0)),l&&L.move(Vt,l),o){case"stretch":_||(s=e.width,n=e.height);break;case"normal":case"clip":(Vt.x||Vt.y||m||f||c||u)&&Mt(w,e,Vt.x,Vt.y,m,v,c,u,t.clipSize);break;case"repeat":(!_||m||c)&&It(w,e,s,n,Vt.x,Vt.y,m,v,c,r),p||(w.repeat="repeat");break;default:m&&Pt(w,e,Vt.x,Vt.y,m,v,c)}return w.transform||(e.x||e.y)&&(w.transform=zt(),Ft(w.transform,e.x,e.y)),m&&"stretch"!==o&&(w.scaleX=m,w.scaleY=v),w.width=s,w.height=n,a&&(w.opacity=a),g&&(w.filters=g),p&&(w.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat"),w}let jt,Xt=new m;const{isSame:qt}=B;function Ht(t,e,i,s,n,a){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||Gt(n,s,i,a),!0}function Qt(t,e){Kt(t,C.LOAD,e)}function Zt(t,e){Kt(t,C.LOADED,e)}function $t(t,e,i){e.error=i,t.forceUpdate("surface"),Kt(t,C.ERROR,e)}function Kt(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function Jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:te,scale:ee,copy:ie}=E,{ceil:se,abs:ne}=Math;function ae(t,e,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,e.scaleFixed);const o=n+"-"+a+"-"+s;if(e.patternId===o||t.destroyed)return!1;{const{image:t,data:r}=e;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(u=ne(u),f=ne(f),d=te(),ie(d,p),ee(d,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const _=h*c;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&&(l=Math.sqrt(_/w)),l&&(n/=l,a/=l,h/=l,c/=l),u&&(n/=u,a/=f),(p||1!==n||1!==a)&&(d||(d=te(),p&&ie(d,p)),ee(d,1/n,1/a));const y=t.getCanvas(se(h)||1,se(c)||1,r.opacity,r.filters),m=t.getPattern(y,g||i.origin.noRepeat||"no-repeat",d,e);return e.style=m,e.patternId=o,!0}}function oe(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const re={image:function(t,e,i,s,n){let a,o;const r=k.get(i);return jt&&i===jt.paint&&qt(s,jt.boxBounds)?a=jt.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),jt=r.use>1?{leafPaint:a,paint:i,boxBounds:Xt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Ht(t,e,i,r,a,s),n&&(Qt(t,o),Zt(t,o))):r.error?n&&$t(t,o,r.error):(n&&(Jt(t,!0),Qt(t,o)),a.loadId=r.load((()=>{Jt(t,!1),t.destroyed||(Ht(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Zt(t,o)),a.loadId=void 0}),(e=>{Jt(t,!1),$t(t,o,e),a.loadId=void 0})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=e,{data:d}=s;if(!d||s.patternId===o+"-"+r+"-"+l&&!I.running)return!1;if(n)if(d.repeat)n=!1;else if(!(s.changeful||a.isResizing(t)||I.running)){let{width:t,height:e}=d;t*=o*l,e*=r*l,d.scaleX&&(t*=d.scaleX,e*=d.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,d),!0):(!s.style||s.sync||I.running?ae(t,s,l):s.patternTask||(s.patternTask=k.patternTasker.add((()=>oe(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&ae(t,s,l),t.forceUpdate("surface")}))),300)),!1)},createPattern:ae,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,k.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:Gt,getPatternData:Nt,fillOrFitMode:Pt,clipMode:Mt,repeatMode:It},{toPoint:le}=O,{hasTransparent:de}=P,he={},ce={};function ue(t,e,i,s){if(i){let n,a,o,r;for(let t=0,l=i.length;t<l;t++)n=i[t],"string"==typeof n?(o=t/(l-1),a=P.string(n,s)):(o=n.offset,a=P.string(n.color,s)),e.addColorStop(o,a),!r&&de(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:fe,getDistance:pe}=L,{get:ge,rotateOfOuter:_e,scaleOfOuter:we}=E,{toPoint:ye}=O,me={},ve={};function xe(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=fe(e,i);a=ge(),n?(we(a,e,o/r*(s||1),1),_e(a,e,t+90)):(we(a,e,1,o/r*(s||1)),_e(a,e,t))}return a}const{getDistance:be}=L,{toPoint:ke}=O,Be={},Se={};const Ee={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;le(s||"top",e,he),le(n||"bottom",e,ce);const r=i.canvas.createLinearGradient(he.x,he.y,ce.x,ce.y),l={type:a,style:r};return ue(l,r,t.stops,o),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;ye(s||"center",e,me),ye(n||"bottom",e,ve);const l=i.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,pe(me,ve)),d={type:a,style:l};ue(d,l,t.stops,o);const h=xe(e,me,ve,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;ke(s||"center",e,Be),ke(n||"bottom",e,Se);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,Be.x,Be.y):i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,be(Be,Se)),d={type:a,style:l};ue(d,l,t.stops,o);const h=xe(e,Be,Se,r||1,i.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:xe},{copy:Re,toOffsetOutBounds:Ae}=B,Le={},Ce={};function Oe(t,e,s,n){const{bounds:a,shapeBounds:o}=n;if(i.fullImageShadow){if(Re(Le,t.bounds),Le.x+=e.x-o.x,Le.y+=e.y-o.y,s){const{matrix:t}=n;Le.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Le.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Le.width*=s,Le.height*=s}t.copyWorld(n.canvas,t.bounds,Le)}else s&&(Re(Le,e),Le.x-=e.width/2*(s-1),Le.y-=e.height/2*(s-1),Le.width*=s,Le.height*=s),t.copyWorld(n.canvas,o,s?Le:e)}const{toOffsetOutBounds:Te}=B,We={};const De={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ae(d,Ce),r.forEach(((r,g)=>{f.setWorldShadow(Ce.offsetX+r.x*c,Ce.offsetY+r.y*u,r.blur*c,P.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Oe(f,Ce,n,i),s=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),s=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),_.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Te(d,We),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(We.offsetX+r.x*c,We.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Oe(f,We,n,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,d,"source-out"),s=d),f.fillWorld(s,P.string(r.color),"source-in"),_.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Pe}=y;function Me(t,e,i,s,n,a){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),ze(t,e,i,1)}(t,i,s,n);break;case"opacity-path":ze(t,i,s,a);break;case"path":i.restore()}}function Ie(t){return t.getSameCanvas(!1,!0)}function ze(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}z.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],r=i.__.mask,r?(o&&(Me(this,o,t,n,s,a),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=Ie(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=Ie(t)),n||(n=Ie(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||Pe(i,e)||i.__render(t,e)):Pe(i,e)||i.__render(n||t,e);Me(this,o,t,n,s,a)};const Fe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=Fe+"_#~&*+\\=|≮≯≈≠=…",Ye=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ge=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ne=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),je=Ve(Fe),Xe=Ve(Ue),qe=Ve("- —/~|┆·");var He;!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"}(He||(He={}));const{Letter:Qe,Single:Ze,Before:$e,After:Ke,Symbol:Je,Break:ti}=He;function ei(t){return Ge[t]?Qe:qe[t]?ti:Ne[t]?$e:je[t]?Ke:Xe[t]?Je:Ye.test(t)?Ze:Qe}const ii={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function si(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:ni}=ii,{Letter:ai,Single:oi,Before:ri,After:li,Symbol:di,Break:hi}=He;let ci,ui,fi,pi,gi,_i,wi,yi,mi,vi,xi,bi,ki,Bi,Si,Ei,Ri,Ai=[];function Li(t,e){mi&&!yi&&(yi=mi),ci.data.push({char:t,width:e}),fi+=e}function Ci(){pi+=fi,ci.width=fi,ui.words.push(ci),ci={data:[]},fi=0}function Oi(){Bi&&(Si.paraNumber++,ui.paraStart=!0,Bi=!1),mi&&(ui.startCharSize=yi,ui.endCharSize=mi,yi=0),ui.width=pi,Ei.width?ni(ui):Ri&&Ti(),Ai.push(ui),ui={words:[]},pi=0}function Ti(){pi>(Si.maxWidth||0)&&(Si.maxWidth=pi)}const{top:Wi,right:Di,bottom:Pi,left:Mi}=T;function Ii(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 zi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=e.__getInput("width")||0,o=e.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=e;d&&(a?(s=d[Mi],a-=d[Di]+d[Mi]):e.autoSizeAlign||(s=d[Mi]),o?(n=d[Wi],o-=d[Wi]+d[Pi]):e.autoSizeAlign||(n=d[Wi]));const h={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:i.canvas.font=l};return function(t,e,s){Si=t,Ai=t.rows,Ei=t.bounds,Ri=!Ei.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:l,height:d}=Ei;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,i="break"===s.textWrap;Bi=!0,xi=null,yi=wi=mi=fi=pi=0,ci={data:[]},ui={words:[]},n&&(e=[...e]);for(let s=0,d=e.length;s<d;s++)_i=e[s],"\n"===_i?(fi&&Ci(),ui.paraEnd=!0,Oi(),Bi=!0):(vi=ei(_i),vi===ai&&"none"!==o&&(_i=si(_i,o,!fi)),wi=r.measureText(_i).width,n&&(n<0&&(mi=wi),wi+=n),bi=vi===oi&&(xi===oi||xi===ai)||xi===oi&&vi!==li,ki=!(vi!==ri&&vi!==oi||xi!==di&&xi!==li),gi=Bi&&a?l-a:l,t&&l&&pi+fi+wi>gi&&(i?(fi&&Ci(),pi&&Oi()):(ki||(ki=vi===ai&&xi==li),bi||ki||vi===hi||vi===ri||vi===oi||fi+wi>gi?(fi&&Ci(),pi&&Oi()):pi&&Oi()))," "===_i&&!0!==Bi&&pi+fi===0||(vi===hi?(" "===_i&&fi&&Ci(),Li(_i,wi),Ci()):bi||ki?(fi&&Ci(),Li(_i,wi)):Li(_i,wi)),xi=vi);fi&&Ci(),pi&&Oi(),Ai.length>0&&(Ai[Ai.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Si.paraNumber++,pi=r.measureText(t).width,Ai.push({x:a||0,text:t,width:pi,paraStart:!0}),Ri&&Ti()}))}(h,t,e),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ii(e,"x",t[Mi]);break;case"right":Ii(e,"x",-t[Di])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ii(e,"y",t[Wi]);break;case"bottom":Ii(e,"y",-t[Pi])}}(d,h,e,a,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,h=n;o<h;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&o>0&&(y+=c),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(h,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,h,c,u;s.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,e,a),h.overflow&&function(t,e,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=e;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?i.canvas.measureText(r).width:0,h=s+n-d;("none"===e.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e,s,a),"none"!==r&&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=P.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]}}(h,e),h}};const Fi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.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(F,zi),Object.assign(P,Fi),Object.assign(D,Bt),Object.assign(W,re),Object.assign(M,Ee),Object.assign(U,De),j();export{nt as Layouter,V as LeaferCanvas,ot as Renderer,q as Watcher,j as useCanvas};
|
|
2
2
|
//# sourceMappingURL=web.esm.min.js.map
|