leafer-draw 1.7.0 → 1.9.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 +1120 -1027
- package/dist/web.esm.js +1105 -1022
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +4357 -4727
- 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 +5009 -4573
- 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,isString as s,DataHelper as n,canvasSizeAttrs as a,isUndefined as o,ResizeEvent as r,canvasPatch as l,FileHelper as d,Creator as h,LeaferImage as c,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as y,BranchHelper as m,LeafBoundsHelper as v,Bounds as x,isArray as b,LeafLevelList as k,LayoutEvent as B,Run as S,ImageManager as E,isObject as R,BoundsHelper as L,Matrix as A,getMatrixData as C,MatrixHelper as O,MathHelper as T,AlignHelper as W,PointHelper as D,ImageEvent as M,AroundHelper as P,Direction4 as I,isNumber as z}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as F,Paint as U,ColorConvert as V,PaintGradient as Y,Export as G,Group as N,TextConvert as X,Effect as q}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const j=t.get("LeaferCanvas");class H extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else j.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;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),j.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={};n.copyAttrs(e,this,a),this.resize(t),this.resizeListener&&!o(this.width)&&this.resizeListener(new r(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()}}}l(CanvasRenderingContext2D.prototype),l(Path2D.prototype);const{mineType:Q,fileType:Z}=d;function $(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=Q(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,Q(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(Q(Z(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=h.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(h,{canvas:(t,e)=>new H(t,e),image:t=>new c(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:J}=navigator;J.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),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 K{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:tt,updateBounds:et,updateChange:it}=y,{pushAllChildBranch:st,pushAllParent:nt}=m;const{worldBounds:at}=v;class ot{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:rt,updateAllChange:lt}=y,dt=t.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=n.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(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.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=S.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=B,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new B(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?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(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||et(s[t])}et(i)}})}(this.__levelList),function(t){t.list.forEach(it)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new B(a,r,this.times)),i.emitEvent(new B(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,S.end(e)}fullLayout(){const t=S.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),ht.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),S.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?m.updateBounds(t):y.updateBounds(t),lt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=t.get("Renderer");class ut{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=n.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(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,ct.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=S.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(ut.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),S.end(e)}fullRender(){const t=S.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),S.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 x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const e=this.requestTime=Date.now();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 x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[r.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 ft(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 pt(t,e){t.__.__font?ft(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function gt(t,e,i){switch(e.__.strokeAlign){case"center":_t(t,1,e,i);break;case"inside":wt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?_t(t,2,e,i):wt(t,"outside",e,i)}}function _t(t,e,i,s){const n=i.__;R(t)?mt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),yt(i,s))}function wt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,_t(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",ft(i,n),n.blendMode="normal",y.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function yt(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 mt(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||!F.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?yt(s,n):n.stroke(),n.restoreBlendMode()):i?yt(s,n):n.stroke()}}function vt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)gt(t,e,i);else switch(s.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),xt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)xt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),xt(t,2,e,a),a.clipUI(s),a.clearWorld(n),y.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function xt(t,e,i,s){const n=i.__;R(t)?mt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&U.strokeArrow(t,i,s)}ut.clipSpread=10,Object.assign(h,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=ht.fullLayout;const{getSpread:bt,getOuterOf:kt,getByMove:Bt,getIntersectData:St}=L;let Et;const{stintSet:Rt}=n,{hasTransparent:Lt}=V;function At(t,e,i){if(!R(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:a}=i.__layout;switch(e.type){case"image":n=F.image(i,t,e,a,!Et||!Et[e.url]);break;case"linear":n=Y.linearGradient(e,a);break;case"radial":n=Y.radialGradient(e,a);break;case"angular":n=Y.conicGradient(e,a);break;case"solid":const{type:s,color:r,opacity:l}=e;n={type:s,style:V.string(r,l)};break;default:o(e.r)||(n={type:"solid",style:V.string(e)})}if(n){if(s(n.style)&&Lt(n.style)&&(n.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}e.editing&&(n.editing=e.editing),e.blendMode&&(n.blendMode=e.blendMode)}return n}const Ct={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];b(r)||(r=[r]),Et=F.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=At(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?(Rt(i,"__isAlphaPixelFill",n),Rt(i,"__isTransparentFill",a)):(Rt(i,"__isAlphaPixelStroke",n),Rt(i,"__isTransparentStroke",a),Rt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,pt(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(F.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),pt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),pt(e,i),i.restoreBlendMode()):pt(e,i)}},fillPathOrText:pt,fillText:ft,stroke:vt,strokes:function(t,e,i){vt(t,e,i)},strokeText:gt,drawTextStroke:yt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,l,d,{scaleX:h,scaleY:c}=n;if(h<0&&(h=-h),c<0&&(c=-c),e.bounds.includes(n))d=s,a=l=n;else{const{renderShapeSpread:s}=t.__layout,u=St(s?bt(e.bounds,h===c?s*h:[s*c,s*h]):e.bounds,n);r=e.bounds.getFitMatrix(u);let{a:f,d:p}=r;r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=f,c*=p),l=kt(n,r),a=Bt(l,-r.e,-r.f);const g=i.matrix;g?(o=new A(r),o.multiply(g),f*=g.scaleX,p*=g.scaleY):o=r,o.withScale(f,p),i=Object.assign(Object.assign({},i),{matrix:o})}return t.__renderShape(s,i),{canvas:s,matrix:o,fitMatrix:r,bounds:a,worldCanvas:d,shapeBounds:l,scaleX:h,scaleY:c}}};let Ot={},Tt=C();const{get:Wt,rotateOfOuter:Dt,translate:Mt,scaleOfOuter:Pt,multiplyParent:It,scale:zt,rotate:Ft,skew:Ut}=O;function Vt(t,e,i,s,n,a,o){const r=Wt();Mt(r,e.x+i,e.y+s),zt(r,n,a),o&&Dt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Yt(t,e,i,s,n,a,o,r,l){const d=Wt();Nt(d,e,i,s,n,a,o,r),l&&(Tt.a=e.width/l.width,Tt.d=e.height/l.height,It(d,Tt)),t.transform=d}function Gt(t,e,i,s,n,a,o,r,l,d,h,c){const u=Wt();if(c)Nt(u,e,n,a,o,r,l,d);else{if(l)if("center"===h)Dt(u,{x:i/2,y:s/2},l);else switch(Ft(u,l),l){case 90:Mt(u,s,0);break;case 180:Mt(u,i,s);break;case 270:Mt(u,0,i)}Ot.x=e.x+n,Ot.y=e.y+a,Mt(u,Ot.x,Ot.y),o&&Pt(u,Ot,o,r)}t.transform=u}function Nt(t,e,i,s,n,a,o,r){o&&Ft(t,o),r&&Ut(t,r.x,r.y),n&&zt(t,n,a),Mt(t,e.x+i,e.y+s)}const{get:Xt,translate:qt}=O,jt=new x,Ht={},Qt={};function Zt(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=$t(i,s,e)}function $t(t,e,i){t.padding&&(e=jt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:a}=i;const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,y=e.width===n&&e.height===a,m={mode:r},v="center"!==l&&(u||0)%180==90;let x,b;switch(L.set(Qt,0,0,v?a:n,v?n:a),r&&"cover"!==r&&"fit"!==r?((h||c)&&(T.getScaleData(h,c,i,Ht),x=Ht.scaleX,b=Ht.scaleY),(l||_||g)&&(x&&L.scale(Qt,x,b,!0),l&&W.toPoint(l,Qt,e,Qt,!0,!0))):y&&!u||(x=b=L.getFitScale(e,Qt,"fit"!==r),L.put(e,i,l,x,!1,Qt),L.scale(Qt,x,b,!0)),d&&D.move(Qt,d),r){case"stretch":y||(n=e.width,a=e.height);break;case"normal":case"clip":(Qt.x||Qt.y||x||p||u||f)&&Yt(m,e,Qt.x,Qt.y,x,b,u,f,t.clipSize);break;case"repeat":(!y||x||u||f)&&Gt(m,e,n,a,Qt.x,Qt.y,x,b,u,f,l,t.freeTransform),g||(m.repeat="repeat");const i=R(g);(_||i)&&(m.gap=function(t,e,i,s,n){let a,o;R(t)?(a=t.x,o=t.y):a=o=t;return{x:Jt(a,i,n.width,e&&e.x),y:Jt(o,s,n.height,e&&e.y)}}(_,i&&g,Qt.width,Qt.height,e));break;default:x&&Vt(m,e,Qt.x,Qt.y,x,b,u)}return m.transform||(e.x||e.y)&&(m.transform=Xt(),qt(m.transform,e.x,e.y)),x&&"stretch"!==r&&(m.scaleX=x,m.scaleY=b),m.width=n,m.height=a,o&&(m.opacity=o),w&&(m.filters=w),g&&(m.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),m}function Jt(t,e,i,n){const a=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let Kt,te=new x;const{isSame:ee}=L;function ie(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||Zt(n,s,i,a),!0}function se(t,e){oe(t,M.LOAD,e)}function ne(t,e){oe(t,M.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),oe(t,M.ERROR,e)}function oe(t,e,i){t.hasEvent(e)&&t.emitEvent(new M(e,i))}function re(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,scale:de,copy:he}=O,{floor:ce,max:ue,abs:fe}=Math;function pe(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,gap:_}=r;n*=s,a*=s;const w=_&&_.x*n,y=_&&_.y*a;u&&(u=fe(u),f=fe(f),d=le(),he(d,p),de(d,1/u,1/f),n*=u,a*=f),h*=n,c*=a;const m=h*c;if(!g&&m>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}if(m>v&&(l=Math.sqrt(m/v)),l&&(n/=l,a/=l,h/=l,c/=l),u&&(n/=u,a/=f),(p||1!==n||1!==a)&&(d||(d=le(),p&&he(d,p)),de(d,1/n,1/a)),d){const t=h+(w||0),e=c+(y||0);de(d,t/ue(ce(t),1),e/ue(ce(e),1))}const x=t.getCanvas(h,c,r.opacity,r.filters,w,y),b=t.getPattern(x,g||i.origin.noRepeat||"no-repeat",d,e);return e.style=b,e.patternId=o,!0}}function ge(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 _e={image:function(t,e,i,s,n){let a,o;const r=E.get(i);return Kt&&i===Kt.paint&&ee(s,Kt.boxBounds)?a=Kt.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Kt=r.use>1?{leafPaint:a,paint:i,boxBounds:te.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ie(t,e,i,r,a,s),n&&(se(t,o),ne(t,o))):r.error?n&&ae(t,o,r.error):(n&&(re(t,!0),se(t,o)),a.loadId=r.load(()=>{re(t,!1),t.destroyed||(ie(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ne(t,o)),a.loadId=void 0},e=>{re(t,!1),ae(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:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=e,{data:d}=s;if(!d||s.patternId===a+"-"+o+"-"+l&&!G.running)return!1;if(n)if(d.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&r.isResizing(t)||G.running)){let{width:t,height:e}=d;t*=a*l,e*=o*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||G.running?pe(t,s,l):s.patternTask||(s.patternTask=E.patternTasker.add(()=>ge(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&pe(t,s,l),t.forceUpdate("surface")}),300)),!1)},createPattern:pe,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){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,E.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],b(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:Zt,getPatternData:$t,fillOrFitMode:Vt,clipMode:Yt,repeatMode:Gt},{toPoint:we}=P,{hasTransparent:ye}=V,me={},ve={};function xe(t,e,i,n){if(i){let a,o,r,l;for(let t=0,d=i.length;t<d;t++)a=i[t],s(a)?(r=t/(d-1),o=V.string(a,n)):(r=a.offset,o=V.string(a.color,n)),e.addColorStop(r,o),!l&&ye(o)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:be,getDistance:ke}=D,{get:Be,rotateOfOuter:Se,scaleOfOuter:Ee}=O,{toPoint:Re}=P,Le={},Ae={};function Ce(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=be(e,i);a=Be(),n?(Ee(a,e,o/r*(s||1),1),Se(a,e,t+90)):(Ee(a,e,1,o/r*(s||1)),Se(a,e,t))}return a}const{getDistance:Oe}=D,{toPoint:Te}=P,We={},De={};const Me={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;we(s||"top",e,me),we(n||"bottom",e,ve);const r=i.canvas.createLinearGradient(me.x,me.y,ve.x,ve.y),l={type:a,style:r};return xe(l,r,t.stops,o),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Re(s||"center",e,Le),Re(n||"bottom",e,Ae);const l=i.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,ke(Le,Ae)),d={type:a,style:l};xe(d,l,t.stops,o);const h=Ce(e,Le,Ae,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Te(s||"center",e,We),Te(n||"bottom",e,De);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,We.x,We.y):i.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Oe(We,De)),d={type:a,style:l};xe(d,l,t.stops,o);const h=Ce(e,We,De,r||1,i.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ce},{copy:Pe,toOffsetOutBounds:Ie}=L,ze={},Fe={};function Ue(t,e,s,n){const{bounds:a,shapeBounds:o}=n;if(i.fullImageShadow){if(Pe(ze,t.bounds),ze.x+=e.x-o.x,ze.y+=e.y-o.y,s){const{fitMatrix:t}=n;ze.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),ze.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),ze.width*=s,ze.height*=s}t.copyWorld(n.canvas,t.bounds,ze)}else s&&(Pe(ze,e),ze.x-=e.width/2*(s-1),ze.y-=e.height/2*(s-1),ze.width*=s,ze.height*=s),t.copyWorld(n.canvas,o,s?ze:e)}const{toOffsetOutBounds:Ve}=L,Ye={};const Ge={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;Ie(d,Fe),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Fe.offsetX+r.x*c*_,Fe.offsetY+r.y*u*_,r.blur*c*_,V.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Ue(f,Fe,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")),y.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;Ve(d,Ye),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Ye.offsetX+r.x*c*_,Ye.offsetY+r.y*u*_,r.blur*c*_),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Ue(f,Ye,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,V.string(r.color),"source-in"),y.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:Ne}=v;let Xe;function qe(t,e,i,s,n,a,o,r){switch(e){case"grayscale":Xe||(Xe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);He(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":He(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o,!0)}N.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++){if(i=l[d],r=i.__.mask,r){o&&(qe(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,Xe=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=je(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=je(t)),n||(n=je(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||Ne(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&qe(this,o,t,n,s,a,void 0,!1),Ne(i,e)||i.__render(n||t,e),h&&qe(this,o,t,n,s,a,h,!1)}qe(this,o,t,n,s,a,void 0,!0)};const Qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ze=Qe+"_#~&*+\\=|≮≯≈≠=…",$e=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function Je(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Ke=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ti=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ei=Je(Qe),ii=Je(Ze),si=Je("- —/~|┆·");var ni;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ni||(ni={}));const{Letter:ai,Single:oi,Before:ri,After:li,Symbol:di,Break:hi}=ni;function ci(t){return Ke[t]?ai:si[t]?hi:ti[t]?ri:ei[t]?li:ii[t]?di:$e.test(t)?oi:ai}const ui={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 fi(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:pi}=ui,{Letter:gi,Single:_i,Before:wi,After:yi,Symbol:mi,Break:vi}=ni;let xi,bi,ki,Bi,Si,Ei,Ri,Li,Ai,Ci,Oi,Ti,Wi,Di,Mi,Pi,Ii,zi=[];function Fi(t,e){Ai&&!Li&&(Li=Ai),xi.data.push({char:t,width:e}),ki+=e}function Ui(){Bi+=ki,xi.width=ki,bi.words.push(xi),xi={data:[]},ki=0}function Vi(){Di&&(Mi.paraNumber++,bi.paraStart=!0,Di=!1),Ai&&(bi.startCharSize=Li,bi.endCharSize=Ai,Li=0),bi.width=Bi,Pi.width?pi(bi):Ii&&Yi(),zi.push(bi),bi={words:[]},Bi=0}function Yi(){Bi>(Mi.maxWidth||0)&&(Mi.maxWidth=Bi)}const{top:Gi,right:Ni,bottom:Xi,left:qi}=I;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 Hi={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,a=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:h}=e;h&&(o?(n=h[qi],o-=h[Ni]+h[qi]):e.autoSizeAlign||(n=h[qi]),r?(a=h[Gi],r-=h[Gi]+h[Xi]):e.autoSizeAlign||(a=h[Gi]));const c={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){Mi=t,zi=t.rows,Pi=t.bounds,Ii=!Pi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:l,height:d}=Pi;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,i="break"===s.textWrap;Di=!0,Oi=null,Li=Ri=Ai=ki=Bi=0,xi={data:[]},bi={words:[]},n&&(e=[...e]);for(let s=0,d=e.length;s<d;s++)Ei=e[s],"\n"===Ei?(ki&&Ui(),bi.paraEnd=!0,Vi(),Di=!0):(Ci=ci(Ei),Ci===gi&&"none"!==o&&(Ei=fi(Ei,o,!ki)),Ri=r.measureText(Ei).width,n&&(n<0&&(Ai=Ri),Ri+=n),Ti=Ci===_i&&(Oi===_i||Oi===gi)||Oi===_i&&Ci!==yi,Wi=!(Ci!==wi&&Ci!==_i||Oi!==mi&&Oi!==yi),Si=Di&&a?l-a:l,t&&l&&Bi+ki+Ri>Si&&(i?(ki&&Ui(),Bi&&Vi()):(Wi||(Wi=Ci===gi&&Oi==yi),Ti||Wi||Ci===vi||Ci===wi||Ci===_i||ki+Ri>Si?(ki&&Ui(),Bi&&Vi()):Bi&&Vi()))," "===Ei&&!0!==Di&&Bi+ki===0||(Ci===vi?(" "===Ei&&ki&&Ui(),Fi(Ei,Ri),Ui()):Ti||Wi?(ki&&Ui(),Fi(Ei,Ri)):Fi(Ei,Ri)),Oi=Ci);ki&&Ui(),Bi&&Vi(),zi.length>0&&(zi[zi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Mi.paraNumber++,Bi=r.measureText(t).width,zi.push({x:a||0,text:t,width:Bi,paraStart:!0}),Ii&&Yi()})}(c,t,e),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ji(e,"x",t[qi]);break;case"right":ji(e,"x",-t[Ni])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ji(e,"y",t[Gi]);break;case"bottom":ji(e,"y",-t[Xi])}}(h,c,e,o,r),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}(c,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)})}(c,e,o),c.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)}})}}(c,e,n,o),"none"!==l&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,R(n)?(i=n.type,n.color&&(t.decorationColor=V.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 Qi={string:function(t,e){const i=z(e)&&e<1;if(s(t)){if(!i||!V.object)return t;t=V.object(t)}let n=o(t.a)?1:t.a;i&&(n*=e);const a=t.r+","+t.g+","+t.b;return 1===n?"rgb("+a+")":"rgba("+a+","+n+")"}};Object.assign(X,Hi),Object.assign(V,Qi),Object.assign(U,Ct),Object.assign(F,_e),Object.assign(Y,Me),Object.assign(q,Ge),$();export{ht as Layouter,H as LeaferCanvas,ut as Renderer,K as Watcher,$ as useCanvas};
|
|
2
2
|
//# sourceMappingURL=web.esm.min.js.map
|