@leafer-draw/miniapp 1.5.3 → 1.6.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/miniapp.cjs +68 -71
- package/dist/miniapp.cjs.map +1 -1
- package/dist/miniapp.esm.js +68 -71
- package/dist/miniapp.esm.js.map +1 -1
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +260 -165
- package/dist/miniapp.module.js.map +1 -1
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +9 -8
- package/src/core.ts +143 -0
- package/src/index.ts +2 -2
- package/types/index.d.ts +8 -1
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,FileHelper as a,Creator as r,LeaferImage as d,defineKey as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as _,BranchHelper as g,LeafBoundsHelper as w,Bounds as y,Debug as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as S,MathHelper as k,AlignHelper as E,ImageEvent as A,AroundHelper as L,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as C,ColorConvert as O,PaintGradient as M,Export as P,Group as I,TextConvert as z,Paint as D,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class U extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:V,fileType:Y}=a;function G(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(V(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(V(Y(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=r.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new U(t,e),image:t=>new d(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},l(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class N{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(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:j,updateBounds:q,updateAllWorldOpacity:X}=_,{pushAllChildBranch:H,pushAllParent:Q}=g;const{worldBounds:Z}=w,$={x:0,y:0,width:1e5,height:1e5};class J{constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Z)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set($):this.afterBounds.setListWithFn(t,Z),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:K,updateAllChange:tt}=_,et=m.get("Layouter");class it{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.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){et.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?et.warn("layouting"):this.times>3?et.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER: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?(j(t,!0),e.add(t),t.isBranch&&H(t,e),Q(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Q(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){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&X(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(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)),it.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){K(t,!0),t.isBranch?g.updateBounds(t):_.updateBounds(t),tt(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(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const st=m.get("Renderer");class nt{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)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new y,st.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(h.CHILD_START,e),this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,st.error(t)}st.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return st.warn("rendering");if(this.times>3)return st.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.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=t.includes(this.target.__world),o=new y(s);i.save(),n&&!m.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),m.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),m.showHitView&&this.renderHitView(s),m.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new y(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new y(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||st.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 h(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(h.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function ot(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=s;t&&(e.fillStyle=t),n.forEach((t=>o.forEach((s=>e.fillRect(t.x,t.y+s,t.width,i)))))}}function at(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?lt(t,!0,e,i):dt(e,i);break;case"inside":rt("inside",t,n,e,i);break;case"outside":rt("outside",t,n,e,i)}}function rt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?lt(e,!0,s,r):dt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",ot(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function dt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=s;n.forEach((i=>o.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function lt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&C.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?dt(i,s):s.stroke(),s.restoreBlendMode()):e?dt(i,s):s.stroke())}function ct(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(r,{watcher:(t,e)=>new N(t,e),layouter:(t,e)=>new it(t,e),renderer:(t,e,i)=>new nt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=it.fullLayout;const{getSpread:ht,getOuterOf:ut,getByMove:ft,getIntersectData:pt}=R;let _t;function gt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:O.string(a,r)};case"image":return C.image(i,t,e,s,!_t||!_t[e.url]);case"linear":return M.linearGradient(e,s);case"radial":return M.radialGradient(e,s);case"angular":return M.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:O.string(e)}:void 0}}const wt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),_t=C.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=gt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?ot(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&C.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?ot(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?ot(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?ot(e,i):n?i.fill(n):i.fill())},fillText:ot,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)at(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&ct(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)at(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),lt(t,!1,e,i),s.__useArrow&&ct(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),lt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),lt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:at,drawTextStroke:dt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))d=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,h=pt(s?ht(e.bounds,l===c?s*l:[s*c,s*l]):e.bounds,n);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=ut(n,a),o=ft(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:c}}};let yt={};const{get:mt,rotateOfOuter:vt,translate:xt,scaleOfOuter:bt,scale:Bt,rotate:Rt}=S;function St(t,e,i,s,n,o,a){const r=mt();xt(r,e.x+i,e.y+s),Bt(r,n,o),a&&vt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function kt(t,e,i,s,n,o,a){const r=mt();xt(r,e.x+i,e.y+s),n&&Bt(r,n,o),a&&Rt(r,a),t.transform=r}function Et(t,e,i,s,n,o,a,r,d,l){const c=mt();if(d)if("center"===l)vt(c,{x:i/2,y:s/2},d);else switch(Rt(c,d),d){case 90:xt(c,s,0);break;case 180:xt(c,i,s);break;case 270:xt(c,0,i)}yt.x=e.x+n,yt.y=e.y+o,xt(c,yt.x,yt.y),a&&bt(c,yt,a,r),t.transform=c}const{get:At,translate:Lt}=S,Wt=new y,Tt={},Ct={};function Ot(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=Mt(i,s,e)}function Mt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Wt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===s&&e.height===n,_={mode:a},g="center"!==r&&(h||0)%180==90,w=g?n:s,y=g?s:n;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,i,Ct),m=Ct.scaleX,v=Ct.scaleY);else if(!p||h){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-s*m)/2,b+=(e.height-n*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),E.toPoint(r,t,e,Tt,!0),x+=Tt.x,b+=Tt.y}switch(d&&(x+=d.x,b+=d.y),a){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(x||b||m||h)&&kt(_,e,x,b,m,v,h);break;case"repeat":(!p||m||h)&&Et(_,e,s,n,x,b,m,v,h,r),u||(_.repeat="repeat");break;default:m&&St(_,e,x,b,m,v,h)}return _.transform||(e.x||e.y)&&(_.transform=At(),Lt(_.transform,e.x,e.y)),m&&"stretch"!==a&&(_.scaleX=m,_.scaleY=v),_.width=s,_.height=n,o&&(_.opacity=o),f&&(_.filters=f),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Pt,It=new y;const{isSame:zt}=R;function Dt(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||Ot(n,s,i,o),!0}function Ft(t,e){Yt(t,A.LOAD,e)}function Ut(t,e){Yt(t,A.LOADED,e)}function Vt(t,e,i){e.error=i,t.forceUpdate("surface"),Yt(t,A.ERROR,e)}function Yt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Gt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Nt,scale:jt,copy:qt}=S,{ceil:Xt,abs:Ht}=Math;function Qt(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(i.patternId===a||t.destroyed)return!1;{n=Ht(n),o=Ht(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:_}=r;u&&(l=Nt(),qt(l,p),jt(l,1/u,1/f),n*=u,o*=f),n*=s,o*=s,c*=n,h*=o;const g=c*h;if(!_&&g>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}g>w&&(d=Math.sqrt(g/w)),d&&(n/=d,o/=d,c/=d,h/=d),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(l||(l=Nt(),p&&qt(l,p)),jt(l,1/n,1/o));const y=t.getCanvas(Xt(c)||1,Xt(h)||1,r.opacity,r.filters),m=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=a,!0}}function Zt(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:$t}=Math;const Jt={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Pt&&i===Pt.paint&&zt(s,Pt.boxBounds)?o=Pt.leafPaint:(o={type:i.type,image:r},Pt=r.use>1?{leafPaint:o,paint:i,boxBounds:It.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Dt(t,e,i,r,o,s),n&&(Ft(t,a),Ut(t,a))):r.error?n&&Vt(t,a,r.error):(n&&(Gt(t,!0),Ft(t,a)),o.loadId=r.load((()=>{Gt(t,!1),t.destroyed||(Dt(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ut(t,a)),o.loadId=null}),(e=>{Gt(t,!1),Vt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!s.data||s.patternId===o+"-"+a+"-"+r&&!P.running)return!1;{const{data:d}=s;if(n)if(d.repeat)n=!1;else{let{width:t,height:i}=d;t*=$t(o)*r,i*=$t(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),n=t*i>e.image.maxCacheSize||P.running}return n?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.getFull(d.filters),0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||P.running?Qt(t,s,r):s.patternTask||(s.patternTask=B.patternTasker.add((()=>Zt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&Qt(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Qt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,d=i.length;r<d;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,B.recycle(s),s.loading?(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))):i[r].style=null);return n}return null},createData:Ot,getPatternData:Mt,fillOrFitMode:St,clipMode:kt,repeatMode:Et},{toPoint:Kt}=L,te={},ee={};function ie(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),O.string(s,i)):t.addColorStop(s.offset,O.string(s.color,i))}}const{getAngle:se,getDistance:ne}=W,{get:oe,rotateOfOuter:ae,scaleOfOuter:re}=S,{toPoint:de}=L,le={},ce={};function he(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=se(e,i);o=oe(),n?(re(o,e,a/r*(s||1),1),ae(o,e,t+90)):(re(o,e,1,a/r*(s||1)),ae(o,e,t))}return o}const{getDistance:ue}=W,{toPoint:fe}=L,pe={},_e={};const ge={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;Kt(s||"top",i,te),Kt(n||"bottom",i,ee);const d=e.canvas.createLinearGradient(te.x,te.y,ee.x,ee.y);ie(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:d}=t;de(s||"center",i,le),de(n||"bottom",i,ce);const l=e.canvas.createRadialGradient(le.x,le.y,0,le.x,le.y,ne(le,ce));ie(l,t.stops,a);const c={type:o,style:l},h=he(i,le,ce,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:d}=t;fe(s||"center",i,pe),fe(n||"bottom",i,_e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,pe.x,pe.y):e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,ue(pe,_e));ie(l,t.stops,a);const c={type:o,style:l},h=he(i,pe,_e,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:he},{copy:we,toOffsetOutBounds:ye}=R,me={},ve={};function xe(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(we(me,t.bounds),me.x+=i.x-a.x,me.y+=i.y-a.y,s){const{matrix:t}=n;me.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),me.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),me.width*=s,me.height*=s}t.copyWorld(n.canvas,t.bounds,me)}else s&&(we(me,i),me.x-=i.width/2*(s-1),me.y-=i.height/2*(s-1),me.width*=s,me.height*=s),t.copyWorld(n.canvas,a,s?me:i)}const{toOffsetOutBounds:be}=R,Be={};const Re={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ye(l,ve),r.forEach(((r,_)=>{f.setWorldShadow(ve.offsetX+r.x*h,ve.offsetY+r.y*u,r.blur*h,O.string(r.color)),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,ve,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,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&_<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:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;be(l,Be),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Be.offsetX+r.x*h,Be.offsetY+r.y*u,r.blur*h),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,Be,n,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,l,"source-out"),s=l),f.fillWorld(s,O.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&_<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:Se}=w;function ke(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),Ae(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ae(t,i,s,o);break;case"path":i.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Ae(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}I.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(a&&(ke(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=Ee(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Ee(t)),n||(n=Ee(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Se(i,e)||i.__render(n||t,e);ke(this,a,t,n,s,o)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",We=Le+"_#~&*+\\=|≮≯≈≠=…",Te=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 Ce(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Oe=Ce("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Me=Ce("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Pe=Ce(Le),Ie=Ce(We),ze=Ce("- —/~|┆·");var De;!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"}(De||(De={}));const{Letter:Fe,Single:Ue,Before:Ve,After:Ye,Symbol:Ge,Break:Ne}=De;function je(t){return Oe[t]?Fe:ze[t]?Ne:Me[t]?Ve:Pe[t]?Ye:Ie[t]?Ge:Te.test(t)?Ue:Fe}const qe={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 Xe(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:He}=qe,{Letter:Qe,Single:Ze,Before:$e,After:Je,Symbol:Ke,Break:ti}=De;let ei,ii,si,ni,oi,ai,ri,di,li,ci,hi,ui,fi,pi,_i,gi,wi,yi=[];function mi(t,e){li&&!di&&(di=li),ei.data.push({char:t,width:e}),si+=e}function vi(){ni+=si,ei.width=si,ii.words.push(ei),ei={data:[]},si=0}function xi(){pi&&(_i.paraNumber++,ii.paraStart=!0,pi=!1),li&&(ii.startCharSize=di,ii.endCharSize=li,di=0),ii.width=ni,gi.width?He(ii):wi&&bi(),yi.push(ii),ii={words:[]},ni=0}function bi(){ni>(_i.maxWidth||0)&&(_i.maxWidth=ni)}const{top:Bi,right:Ri,bottom:Si,left:ki}=T;function Ei(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 Ai={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o?(s=l[ki],o-=l[Ri]+l[ki]):i.autoSizeAlign||(s=l[ki]),a?(n=l[Bi],a-=l[Bi]+l[Si]):i.autoSizeAlign||(n=l[Bi]));const c={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){_i=t,yi=t.rows,gi=t.bounds,wi=!gi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:d,height:l}=gi;if(d||l||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;pi=!0,hi=null,di=ri=li=si=ni=0,ei={data:[]},ii={words:[]};for(let s=0,l=i.length;s<l;s++)ai=i[s],"\n"===ai?(si&&vi(),ii.paraEnd=!0,xi(),pi=!0):(ci=je(ai),ci===Qe&&"none"!==a&&(ai=Xe(ai,a,!si)),ri=r.measureText(ai).width,n&&(n<0&&(li=ri),ri+=n),ui=ci===Ze&&(hi===Ze||hi===Qe)||hi===Ze&&ci!==Je,fi=!(ci!==$e&&ci!==Ze||hi!==Ke&&hi!==Je),oi=pi&&o?d-o:d,t&&d&&ni+si+ri>oi&&(e?(si&&vi(),ni&&xi()):(fi||(fi=ci===Qe&&hi==Je),ui||fi||ci===ti||ci===$e||ci===Ze||si+ri>oi?(si&&vi(),ni&&xi()):ni&&xi()))," "===ai&&!0!==pi&&ni+si===0||(ci===ti?(" "===ai&&si&&vi(),mi(ai,ri),vi()):ui||fi?(si&&vi(),mi(ai,ri)):mi(ai,ri)),hi=ci);si&&vi(),ni&&xi(),yi.length>0&&(yi[yi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{_i.paraNumber++,ni=r.measureText(t).width,yi.push({x:o||0,text:t,width:ni,paraStart:!0}),wi&&bi()}))}(c,t,i),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ei(e,"x",t[ki]);break;case"right":Ei(e,"x",-t[Ri])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ei(e,"y",t[Bi]);break;case"bottom":Ei(e,"y",-t[Si])}}(l,c,i,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:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:_,height:g}=s,w=o*n+(h?h*(t.paraNumber-1):0),y=a;if(d&&w>g)w=Math.max(g,o),n>1&&(t.overflow=n);else if(g||u)switch(c){case"middle":p+=(g-w)/2;break;case"bottom":p+=g-w}y+=p;let m,v,x,b=_||u?_:t.maxWidth;for(let a=0,c=n;a<c;a++){if(m=i[a],m.x=f,m.width<_||m.width>_&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&a>0&&(y+=h),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&&_&&_<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h,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,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):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)}))}(c,i,o),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=s+n-l;("none"===i.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<c));s--){if(d<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,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=O.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,i),c}};const Li={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!O.object)return t;t=O.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,Ai),Object.assign(O,Li),Object.assign(D,wt),Object.assign(C,Jt),Object.assign(M,ge),Object.assign(F,Re);try{wx&&G(0,wx)}catch(t){}export{it as Layouter,U as LeaferCanvas,nt as Renderer,N as Watcher,G as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,FileHelper as a,Creator as r,LeaferImage as d,defineKey as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as _,BranchHelper as g,LeafBoundsHelper as w,Bounds as y,Debug as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as S,MathHelper as k,AlignHelper as E,ImageEvent as A,AroundHelper as L,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as C,ColorConvert as O,PaintGradient as M,Export as P,Group as D,TextConvert as I,Paint as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class U extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:s,pixelRatio:o}=this.config,a={width:n||t.width,height:s||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:Y,fileType:G}=a;function N(t,i){e.origin={createCanvas:(t,e,n)=>{const s={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(s):i.createOffScreenCanvas(s)},canvasToDataURL:(t,e,i)=>t.toDataURL(Y(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(Y(G(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=r.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new U(t,e),image:t=>new d(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},l(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class j{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=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(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:X,updateAllWorldOpacity:V}=_,{pushAllChildBranch:H,pushAllParent:Q}=g;const{worldBounds:Z}=w;class ${constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Z)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Z),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:J,updateAllChange:K}=_,tt=m.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,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.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){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new x(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&H(t,e),Q(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Q(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||X(n[t])}X(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&V(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),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:n,AFTER:s}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),et.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(n,o,this.times)),e.emitEvent(new x(s,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){J(t,!0),t.isBranch?g.updateBounds(t):_.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new $([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new $(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const it=m.get("Renderer");class nt{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(x.REQUEST)}checkRender(){this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT))}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new y,it.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,it.error(t)}it.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return it.warn("rendering");if(this.times>3)return it.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.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,n=t.getIntersect(i.bounds),s=new y(n);i.save(),n.spread(nt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,t.includes(this.target.__world),s),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const{canvas:n}=this,s=e?{includes:e}:{bounds:t,includes:e};this.needFill&&n.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(n,t),this.target.__render(n,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(t.parentApp)return t.parentApp.renderer.update(!1);if(this.requestTime)return;const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,t.isApp&&(t.emit(h.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(h.CHILD_END,t)),this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new y(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new y(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||it.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 h(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(h.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function st(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=n;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}function ot(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?dt(t,!0,e,i):rt(e,i);break;case"inside":at("inside",t,s,e,i);break;case"outside":at("outside",t,s,e,i)}}function at(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?dt(e,!0,n,r):rt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",st(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function rt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[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}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function dt(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&C.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?rt(i,n):n.stroke(),n.restoreBlendMode()):e?rt(i,n):n.stroke())}function lt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}nt.clipSpread=10,Object.assign(r,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,i)=>new nt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=et.fullLayout;const{getSpread:ct,getOuterOf:ht,getByMove:ut,getIntersectData:ft}=R;let pt;function _t(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:O.string(a,r)};case"image":return C.image(i,t,e,n,!pt||!pt[e.url]);case"linear":return M.linearGradient(e,n);case"radial":return M.radialGradient(e,n);case"angular":return M.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:O.string(e)}:void 0}}const gt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),pt=C.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=_t(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?st(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&C.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?st(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?st(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?st(e,i):s?i.fill(s):i.fill())},fillText:st,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ot(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&<(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ot(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),dt(t,!1,e,i),n.__useArrow&<(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),dt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),dt(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ot,drawTextStroke:rt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=ft(n?ct(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=ht(s,a),o=ut(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(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let wt={};const{get:yt,rotateOfOuter:mt,translate:vt,scaleOfOuter:xt,scale:bt,rotate:Bt}=S;function Rt(t,e,i,n,s,o,a){const r=yt();vt(r,e.x+i,e.y+n),bt(r,s,o),a&&mt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function St(t,e,i,n,s,o,a){const r=yt();vt(r,e.x+i,e.y+n),s&&bt(r,s,o),a&&Bt(r,a),t.transform=r}function kt(t,e,i,n,s,o,a,r,d,l){const c=yt();if(d)if("center"===l)mt(c,{x:i/2,y:n/2},d);else switch(Bt(c,d),d){case 90:vt(c,n,0);break;case 180:vt(c,i,n);break;case 270:vt(c,0,i)}wt.x=e.x+s,wt.y=e.y+o,vt(c,wt.x,wt.y),a&&xt(c,wt,a,r),t.transform=c}const{get:Et,translate:At}=S,Lt=new y,Wt={},Tt={};function Ct(t,e,i,n){const{blendMode:s,changeful:o,sync:a}=i;s&&(t.blendMode=s),o&&(t.changeful=o),a&&(t.sync=a),t.data=Ot(i,n,e)}function Ot(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Lt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===n&&e.height===s,_={mode:a},g="center"!==r&&(h||0)%180==90,w=g?s:n,y=g?n:s;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,i,Tt),m=Tt.scaleX,v=Tt.scaleY);else if(!p||h){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-n*m)/2,b+=(e.height-s*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),E.toPoint(r,t,e,Wt,!0),x+=Wt.x,b+=Wt.y}switch(d&&(x+=d.x,b+=d.y),a){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||h)&&St(_,e,x,b,m,v,h);break;case"repeat":(!p||m||h)&&kt(_,e,n,s,x,b,m,v,h,r),u||(_.repeat="repeat");break;default:m&&Rt(_,e,x,b,m,v,h)}return _.transform||(e.x||e.y)&&(_.transform=Et(),At(_.transform,e.x,e.y)),m&&"stretch"!==a&&(_.scaleX=m,_.scaleY=v),_.width=n,_.height=s,o&&(_.opacity=o),f&&(_.filters=f),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Mt,Pt=new y;const{isSame:Dt}=R;function It(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Ct(s,n,i,o),!0}function zt(t,e){Yt(t,A.LOAD,e)}function Ft(t,e){Yt(t,A.LOADED,e)}function Ut(t,e,i){e.error=i,t.forceUpdate("surface"),Yt(t,A.ERROR,e)}function Yt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Gt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Nt,scale:jt,copy:qt}=S,{ceil:Xt,abs:Vt}=Math;function Ht(t,i,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=Vt(s),o=Vt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:_}=r;u&&(l=Nt(),qt(l,p),jt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const g=c*h;if(!_&&g>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}g>w&&(d=Math.sqrt(g/w)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Nt(),p&&qt(l,p)),jt(l,1/s,1/o));const y=t.getCanvas(Xt(c)||1,Xt(h)||1,r.opacity,r.filters),m=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=a,!0}}function Qt(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Zt}=Math;const $t={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return Mt&&i===Mt.paint&&Dt(n,Mt.boxBounds)?o=Mt.leafPaint:(o={type:i.type,image:r},Mt=r.use>1?{leafPaint:o,paint:i,boxBounds:Pt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(It(t,e,i,r,o,n),s&&(zt(t,a),Ft(t,a))):r.error?s&&Ut(t,a,r.error):(s&&(Gt(t,!0),zt(t,a)),o.loadId=r.load((()=>{Gt(t,!1),t.destroyed||(It(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ft(t,a)),o.loadId=null}),(e=>{Gt(t,!1),Ut(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=i,{data:l}=n;if(!l||n.patternId===a+"-"+r+"-"+d&&!P.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||o.isResizing(t)||P.running)){let{width:t,height:i}=l;t*=Zt(a)*d,i*=Zt(r)*d,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,l),!0):(!n.style||n.sync||P.running?Ht(t,n,d):n.patternTask||(n.patternTask=B.patternTasker.add((()=>Qt(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Ht(t,n,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:Ht,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a,r;for(let d=0,l=i.length;d<l;d++)n=i[d],s=n.image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,B.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Ct,getPatternData:Ot,fillOrFitMode:Rt,clipMode:St,repeatMode:kt},{toPoint:Jt}=L,Kt={},te={};function ee(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),O.string(n,i)):t.addColorStop(n.offset,O.string(n.color,i))}}const{getAngle:ie,getDistance:ne}=W,{get:se,rotateOfOuter:oe,scaleOfOuter:ae}=S,{toPoint:re}=L,de={},le={};function ce(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=ie(e,i);o=se(),s?(ae(o,e,a/r*(n||1),1),oe(o,e,t+90)):(ae(o,e,1,a/r*(n||1)),oe(o,e,t))}return o}const{getDistance:he}=W,{toPoint:ue}=L,fe={},pe={};const _e={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;Jt(n||"top",i,Kt),Jt(s||"bottom",i,te);const d=e.canvas.createLinearGradient(Kt.x,Kt.y,te.x,te.y);ee(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;re(n||"center",i,de),re(s||"bottom",i,le);const l=e.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ne(de,le));ee(l,t.stops,a);const c={type:o,style:l},h=ce(i,de,le,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ue(n||"center",i,fe),ue(s||"bottom",i,pe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,fe.x,fe.y):e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,he(fe,pe));ee(l,t.stops,a);const c={type:o,style:l},h=ce(i,fe,pe,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ce},{copy:ge,toOffsetOutBounds:we}=R,ye={},me={};function ve(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ge(ye,t.bounds),ye.x+=i.x-a.x,ye.y+=i.y-a.y,n){const{matrix:t}=s;ye.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),ye.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),ye.width*=n,ye.height*=n}t.copyWorld(s.canvas,t.bounds,ye)}else n&&(ge(ye,i),ye.x-=i.width/2*(n-1),ye.y-=i.height/2*(n-1),ye.width*=n,ye.height*=n),t.copyWorld(s.canvas,a,n?ye:i)}const{toOffsetOutBounds:xe}=R,be={};const Be={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;we(l,me),r.forEach(((r,_)=>{f.setWorldShadow(me.offsetX+r.x*h,me.offsetY+r.y*u,r.blur*h,O.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,me,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;xe(l,be),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,be,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,O.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Re}=w;function Se(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ee(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ee(t,i,n,o);break;case"path":i.restore()}}function ke(t){return t.getSameCanvas(!1,!0)}function Ee(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}D.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(a&&(Se(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=ke(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=ke(t)),s||(s=ke(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Re(i,e)||i.__render(s||t,e);Se(this,a,t,s,n,o)};const Ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Le=Ae+"_#~&*+\\=|≮≯≈≠=…",We=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 Te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ce=Te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Oe=Te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Me=Te(Ae),Pe=Te(Le),De=Te("- —/~|┆·");var Ie;!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"}(Ie||(Ie={}));const{Letter:ze,Single:Fe,Before:Ue,After:Ye,Symbol:Ge,Break:Ne}=Ie;function je(t){return Ce[t]?ze:De[t]?Ne:Oe[t]?Ue:Me[t]?Ye:Pe[t]?Ge:We.test(t)?Fe:ze}const qe={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Xe(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:Ve}=qe,{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Je,Break:Ke}=Ie;let ti,ei,ii,ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,_i,gi,wi=[];function yi(t,e){di&&!ri&&(ri=di),ti.data.push({char:t,width:e}),ii+=e}function mi(){ni+=ii,ti.width=ii,ei.words.push(ti),ti={data:[]},ii=0}function vi(){fi&&(pi.paraNumber++,ei.paraStart=!0,fi=!1),di&&(ei.startCharSize=ri,ei.endCharSize=di,ri=0),ei.width=ni,_i.width?Ve(ei):gi&&xi(),wi.push(ei),ei={words:[]},ni=0}function xi(){ni>(pi.maxWidth||0)&&(pi.maxWidth=ni)}const{top:bi,right:Bi,bottom:Ri,left:Si}=T;function ki(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ei={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o?(n=l[Si],o-=l[Bi]+l[Si]):i.autoSizeAlign||(n=l[Si]),a?(s=l[bi],a-=l[bi]+l[Ri]):i.autoSizeAlign||(s=l[bi]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){pi=t,wi=t.rows,_i=t.bounds,gi=!_i.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=_i;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;fi=!0,ci=null,ri=ai=di=ii=ni=0,ti={data:[]},ei={words:[]};for(let n=0,l=i.length;n<l;n++)oi=i[n],"\n"===oi?(ii&&mi(),ei.paraEnd=!0,vi(),fi=!0):(li=je(oi),li===He&&"none"!==a&&(oi=Xe(oi,a,!ii)),ai=r.measureText(oi).width,s&&(s<0&&(di=ai),ai+=s),hi=li===Qe&&(ci===Qe||ci===He)||ci===Qe&&li!==$e,ui=!(li!==Ze&&li!==Qe||ci!==Je&&ci!==$e),si=fi&&o?d-o:d,t&&d&&ni+ii+ai>si&&(e?(ii&&mi(),ni&&vi()):(ui||(ui=li===He&&ci==$e),hi||ui||li===Ke||li===Ze||li===Qe||ii+ai>si?(ii&&mi(),ni&&vi()):ni&&vi()))," "===oi&&!0!==fi&&ni+ii===0||(li===Ke?(" "===oi&&ii&&mi(),yi(oi,ai),mi()):hi||ui?(ii&&mi(),yi(oi,ai)):yi(oi,ai)),ci=li);ii&&mi(),ni&&vi(),wi.length>0&&(wi[wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{pi.paraNumber++,ni=r.measureText(t).width,wi.push({x:o||0,text:t,width:ni,paraStart:!0}),gi&&xi()}))}(c,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ki(e,"x",t[Si]);break;case"right":ki(e,"x",-t[Bi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ki(e,"y",t[bi]);break;case"bottom":ki(e,"y",-t[Ri])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:_,height:g}=n,w=o*s+(h?h*(t.paraNumber-1):0),y=a;if(d&&w>g)w=Math.max(g,o),s>1&&(t.overflow=s);else if(g||u)switch(c){case"middle":p+=(g-w)/2;break;case"bottom":p+=g-w}y+=p;let m,v,x,b=_||u?_:t.maxWidth;for(let a=0,c=s;a<c;a++){if(m=i[a],m.x=f,m.width<_||m.width>_&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&a>0&&(y+=h),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<n.x&&(n.x=v),x>n.width&&(n.width=x),d&&_&&_<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(c,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char||!n){e.data.splice(n+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)}}))}}(c,i,n,o),"none"!==r&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=O.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(c,i),c}};const Ai={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!O.object)return t;t=O.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(I,Ei),Object.assign(O,Ai),Object.assign(z,gt),Object.assign(C,$t),Object.assign(M,_e),Object.assign(F,Be);try{wx&&N(0,wx)}catch(t){}export{et as Layouter,U as LeaferCanvas,nt as Renderer,j as Watcher,N as useCanvas};
|
|
2
2
|
//# sourceMappingURL=miniapp.esm.min.js.map
|