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