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