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