@leafer-draw/miniapp
Version:
3 lines (2 loc) • 42.6 kB
JavaScript
"use strict";var e,t=require("@leafer/core"),i=require("@leafer-ui/draw");exports.PathNodeHandleType=void 0,(e=exports.PathNodeHandleType||(exports.PathNodeHandleType={}))[e.none=1]="none",e[e.free=2]="free",e[e.mirrorAngle=3]="mirrorAngle",e[e.mirror=4]="mirror";class a 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(e=>{this.initView(e)})):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:i,height:a,pixelRatio:n}=this.config,s={width:i||e.width,height:a||e.height,pixelRatio:n};this.resize(s),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(e,i,a,n,s){this.context.roundRect(e,i,a,n,t.isNumber(s)?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.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(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then(t=>{this.clientBounds=t,this.updateViewSize(),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: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,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))}}function n(e,i){t.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,i,a)=>e.toDataURL(t.FileHelper.mimeType(i),a),canvasToBolb:(e,t,i)=>e.toBuffer(t,{quality:i}),canvasSaveAs:(e,i,a)=>{let n=e.toDataURL(t.FileHelper.mimeType(t.FileHelper.fileType(i)),a);return n=n.substring(n.indexOf("64,")+3),t.Platform.origin.download(n,i)},download:(e,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:e,encoding:"base64",success(){r?t.Platform.miniapp.saveToAlbum(a).then(()=>{o.unlink({filePath:a}),n()}):n()},fail(e){s(e)}})}),loadImage:(e,i,a)=>new Promise((i,a)=>{const n=t.Platform.getCanvas().view.createImage();n.onload=()=>{i(n)},n.onerror=e=>{a(e)},n.src=t.Platform.image.getRealURL(e)}),loadContent:(e,t="text")=>new Promise((a,n)=>i.request({url:e,responseType:"arrayBuffer"===t?"arraybuffer":"text",success:e=>a("json"===t&&"string"==typeof e.data?JSON.parse(e.data):e.data),fail:n})),noRepeat:"repeat-x"},t.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)}},t.Platform.event={stopDefault(e){},stopNow(e){},stop(e){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient,t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,i.getWindowInfo?i.getWindowInfo().pixelRatio:i.getSystemInfoSync().pixelRatio)})}Object.assign(t.Creator,{canvas:(e,t)=>new a(e,t),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.getCanvas=function(){const{renderCanvas:e}=t.Platform;return e&&e.view?e:t.Platform.canvas},t.Platform.requestRender=function(e){const{view:i}=t.Platform.getCanvas();i.requestAnimationFrame?i.requestAnimationFrame(e):setTimeout(e,16)};class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){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(e){this.config.usePartLayout&&this.__updatedList.add(e.target),this.update()}__onChildEvent(e){this.config.usePartLayout&&(e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.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 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:r,updateBounds:o,updateChange:l}=t.LeafHelper,{pushAllChildBranch:d,pushAllParent:c}=t.BranchHelper;const{worldBounds:h}=t.LeafBoundsHelper;class u{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,h)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,h),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:f,updateAllChange:p}=t.LeafHelper,g=t.Debug.get("Layouter");class m{constructor(e,i){this.totalTimes=0,this.config={usePartLayout:!0},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(e){g.error(e)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?g.warn("layouting"):this.times>3?g.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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:a,__updatedList:n}=this,{BEFORE:s,LAYOUT:h,AFTER:u}=t.LayoutEvent,f=this.getBlocks(n);f.forEach(e=>e.setBefore()),a.emitEvent(new t.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?(r(e,!0),t.add(e),e.isBranch&&d(e,t),c(e,t)):i.boundsChanged&&(t.add(e),e.isBranch&&(e.__tempNumber=0),c(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||o(a[e])}o(i)}})}(this.__levelList),function(e){e.list.forEach(l)}(n),this.extraBlock&&f.push(this.extraBlock),f.forEach(e=>e.setAfter()),a.emitEvent(new t.LayoutEvent(h,f,this.times)),a.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:a,LAYOUT:n,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(a,r,this.times)),m.fullLayout(i),r.forEach(e=>{e.setAfter()}),i.emitEvent(new t.LayoutEvent(n,r,this.times)),i.emitEvent(new t.LayoutEvent(s,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){f(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),p(e)}addExtra(e){if(!this.__updatedList.has(e)){const{updatedList:t,beforeBounds:i}=this.extraBlock||(this.extraBlock=new u([]));t.length?i.add(e.__world):i.set(e.__world),t.add(e)}}createBlock(e){return new u(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_([[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 _=t.Debug.get("Renderer");class w{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,a&&(this.config=t.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.requestTime||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(e=>{e.renderer.FPS=this.FPS,e.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,_.log(i.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(e){this.rendering=!1,_.error(e)}_.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return _.warn("rendering");if(this.times>3)return _.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:e,updateBlocks:t}=this;t&&(this.mergeBlocks(),t.forEach(t=>{e.bounds.hit(t)&&!t.isEmpty()&&this.clipRender(t)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:a}=this,n=e.getIntersect(a.bounds),s=new t.Bounds(n);a.save(),n.spread(w.clipSpread).ceil();const{ceilPartPixel:r}=this.config;a.clipWorld(n,r),a.clearWorld(n,r),this.__render(n,s),a.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:a,target:n}=this,s=e.includes(n.__world),r=s?{includes:s}:{bounds:e,includes:s};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),this.config.useCellRender&&(r.cellList=this.getCellList()),t.Platform.render(n,a,r),this.renderBounds=i=i||e,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),a.updateRender(i)}getCellList(){}addBlock(e,t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(e)}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:a}=this.config;if(a&&e>a)return t.Platform.requestRender(i);const{frames:n}=this;n.length>30&&n.shift(),n.push(e),this.FPS=Math.round(n.reduce((e,t)=>e+t,0)/n.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:a}=e.old;if(!new t.Bounds(0,0,i,a).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(e){e.data&&e.data.map(e=>{let t;const{updatedList:i}=e;i&&i.list.some(e=>(t=!e.__world.width||!e.__world.height,t&&(e.isLeafer||_.tip(e.innerName,": empty"),t=!e.isBranch||e.isBranchLeaf),t)),this.addBlock(t?this.canvas.bounds:e.updatedBounds,i)})}emitRender(e,i,a){this.target.emitEvent(new t.RenderEvent(e,this.times,i,a))}__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 y(e,t,a){e.__.__font?i.Paint.fillText(e,t,a):e.__.windingRule?t.fill(e.__.windingRule):t.fill()}function v(e,a,n,s,r){const o=n.__;t.isObject(e)?i.Paint.drawStrokesStyle(e,a,!1,n,s,r):(s.setStroke(e,o.__strokeWidth*a,o),s.stroke()),o.__useArrow&&i.Paint.strokeArrow(e,n,s,r)}function x(e,a,n,s,r){const o=n.__;t.isObject(e)?i.Paint.drawStrokesStyle(e,a,!0,n,s,r):(s.setStroke(e,o.__strokeWidth*a,o),i.Paint.drawTextStroke(n,s,r))}function S(e,a,n,s,r){const o=s.getSameCanvas(!0,!0);o.font=n.__.__font,x(e,2,n,o,r),o.blendMode="outside"===a?"destination-out":"destination-in",i.Paint.fillText(n,o,r),o.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,o),o.recycle(n.__nowWorld)}w.clipSpread=10,Object.assign(t.Creator,{watcher:(e,t)=>new s(e,t),layouter:(e,t)=>new m(e,t),renderer:(e,t,i)=>new w(e,t,i),selector:(e,t)=>{},interaction:(e,t,i,a)=>{}}),t.Platform.layout=m.fullLayout,t.Platform.render=function(e,i,a){const n=Object.assign(Object.assign({},a),{topRendering:!0});a.topList=new t.LeafList,e.__render(i,a),a.topList.length&&a.topList.forEach(e=>e.__render(i,n))};const{getSpread:P,copyAndSpread:b,toOuterOf:B,getOuterOf:E,getByMove:R,move:L,getIntersectData:k}=t.BoundsHelper,C={};let A;const{stintSet:T}=t.DataHelper,{hasTransparent:I}=i.ColorConvert;function O(e,a,n){if(!t.isObject(a)||!1===a.visible||0===a.opacity)return;let s;const{boxBounds:r}=n.__layout,{type:o}=a;switch(o){case"image":case"film":case"video":if(!a.url)return;s=i.PaintImage.image(n,e,a,r,!A||!A[a.url]),"image"!==o&&i.PaintImage[o](s);break;case"linear":s=i.PaintGradient.linearGradient(a,r);break;case"radial":s=i.PaintGradient.radialGradient(a,r);break;case"angular":s=i.PaintGradient.conicGradient(a,r);break;case"solid":const{color:l,opacity:d}=a;s={type:o,style:i.ColorConvert.string(l,d)};break;default:t.isUndefined(a.r)||(s={type:"solid",style:i.ColorConvert.string(a)})}if(s&&(s.originPaint=a,t.isString(s.style)&&I(s.style)&&(s.isTransparent=!0),a.style)){if(0===a.style.strokeWidth)return;s.strokeStyle=a.style}return s}const M={compute:function(e,a){const n=a.__,s=[];let r,o,l,d=n.__input[e];t.isArray(d)||(d=[d]),A=i.PaintImage.recycleImage(e,n);for(let t,i=0,n=d.length;i<n;i++)(t=O(e,d[i],a))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s.length?(n["_"+e]=s,s.every(e=>e.isTransparent)&&(s.some(e=>e.image)&&(r=!0),o=!0),"fill"===e?(T(n,"__isAlphaPixelFill",r),T(n,"__isTransparentFill",o)):(T(n,"__isAlphaPixelStroke",r),T(n,"__isTransparentStroke",o),T(n,"__hasMultiStrokeStyle",l))):(n.__removePaint(e,!1),n["_"+e]="")},fill:function(e,t,i,a){i.fillStyle=e,y(t,i,a)},fills:function(e,t,a,n){let s,r,o;for(let l=0,d=e.length;l<d;l++){if(s=e[l],r=s.originPaint,s.image){if(o?o++:o=1,i.PaintImage.checkImage(s,!t.__.__font,t,a,n))continue;if(!s.style){1===o&&s.image.isPlacehold&&t.drawImagePlaceholder(s,a,n);continue}}if(a.fillStyle=s.style,s.transform||r.scaleFixed){if(a.save(),s.transform&&a.transform(s.transform),r.scaleFixed){const{scaleX:e,scaleY:i}=t.getRenderScaleData(!0,r.scaleFixed,!1);1!==e&&a.scale(e,i)}r.blendMode&&(a.blendMode=r.blendMode),y(t,a,n),a.restore()}else r.blendMode?(a.saveBlendMode(r.blendMode),y(t,a,n),a.restoreBlendMode()):y(t,a,n)}},fillPathOrText:y,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(e,a,n,s){const r=a.__;if(r.__strokeWidth)if(r.__font)i.Paint.strokeText(e,a,n,s);else if(r.__pathForStroke)i.Paint.fillStroke(e,a,n,s);else switch(r.strokeAlign){case"center":v(e,1,a,n,s);break;case"inside":!function(e,t,i,a){i.save(),i.clipUI(t),v(e,2,t,i,a),i.restore()}(e,a,n,s);break;case"outside":!function(e,i,a,n){const s=i.__;if(s.__fillAfterStroke)v(e,2,i,a,n);else{const{renderBounds:r}=i.__layout,o=a.getSameCanvas(!0,!0);i.__drawRenderPath(o),v(e,2,i,o,n),o.clipUI(s),o.clearWorld(r),t.LeafHelper.copyCanvasByWorld(i,a,o),o.recycle(i.__nowWorld)}}(e,a,n,s)}},strokes:function(e,t,a,n){i.Paint.stroke(e,t,a,n)},strokeText:function(e,t,i,a){switch(t.__.strokeAlign){case"center":x(e,1,t,i,a);break;case"inside":S(e,"inside",t,i,a);break;case"outside":t.__.__fillAfterStroke?x(e,2,t,i,a):S(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,t,a,n,s,r){let o;const l=n.__,{__hasMultiStrokeStyle:d}=l;d||s.setStroke(void 0,l.__strokeWidth*t,l);for(let c=0,h=e.length;c<h;c++)if(o=e[c],(!o.image||!i.PaintImage.checkImage(o,!1,n,s,r))&&o.style){if(d){const{strokeStyle:e}=o;e?s.setStroke(o.style,l.__getRealStrokeWidth(e)*t,l,e):s.setStroke(o.style,l.__strokeWidth*t,l)}else s.strokeStyle=o.style;o.originPaint.blendMode?(s.saveBlendMode(o.originPaint.blendMode),a?i.Paint.drawTextStroke(n,s,r):s.stroke(),s.restoreBlendMode()):a?i.Paint.drawTextStroke(n,s,r):s.stroke()}},shape:function(e,i,a){const n=i.getSameCanvas(),s=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,c,h,u,f,p;B(o.strokeSpread?(b(C,o.boxBounds,o.strokeSpread),C):o.boxBounds,r,l);let{scaleX:g,scaleY:m}=e.getRenderScaleData(!0);if(s.includes(l))p=n,d=f=l,c=r;else{let n;if(t.Platform.fullImageShadow)n=l;else{const e=o.renderShapeSpread?P(s,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,m)):s;n=k(e,l)}u=s.getFitMatrix(n);let{a:_,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,a),g*=_,m*=w),f=E(l,u),d=R(f,-u.e,-u.f),c=E(r,u),L(c,-u.e,-u.f);const y=a.matrix;y?(h=new t.Matrix(u),h.multiply(y),_*=y.scaleX,w*=y.scaleY):h=u,h.withScale(_,w),a=Object.assign(Object.assign({},a),{matrix:h})}return e.__renderShape(n,a),{canvas:n,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:m}}};let W,D=new t.Bounds;const{isSame:H}=t.BoundsHelper;function F(e,a,n,s,r,o){let l=!0;const d=e.__;if("fill"!==a||d.__naturalWidth||(d.__naturalWidth=s.width/d.pixelRatio,d.__naturalHeight=s.height/d.pixelRatio,d.__autoSide&&(e.forceUpdate("width"),t.LeafHelper.updateBounds(e),e.__layout.boundsChanged=!0,e.__proxyData&&(e.setProxyAttr("width",d.width),e.setProxyAttr("height",d.height)),l=!1)),"brush"===n.mode&&i.PaintImage.brush(e,a,r),!r.data){i.PaintImage.createData(r,s,n,o);const{transform:e}=r.data,{opacity:t}=n,a=(e&&!e.onlyScale||d.path||d.cornerRadius)&&!r.brush;(a||t&&t<1||n.blendMode)&&(r.complex=!a||2)}return n.filter&&i.PaintImage.applyFilter(r,s,n.filter,e),l}function z(e,i){U(e,t.ImageEvent.LOAD,i)}function j(e,i){U(e,t.ImageEvent.LOADED,i)}function N(e,i,a){i.error=a,e.forceUpdate("surface"),U(e,t.ImageEvent.ERROR,i)}function U(e,i,a){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,a))}function G(e,t){const{leafer:i}=e;i&&i.viewReady&&(i.renderer.ignore=t)}const{get:Y,translate:q}=t.MatrixHelper,X=new t.Bounds,V={},Q={};function Z(e,i,a,n){const s=t.isString(e)||n?(n?a-n*i:a%i)/((n||Math.floor(a/i))-1):e;return"auto"===e&&s<0?0:s}let $={},J=t.getMatrixData();const{get:K,set:ee,rotateOfOuter:te,translate:ie,scaleOfOuter:ae,multiplyParent:ne,scale:se,rotate:re,skew:oe}=t.MatrixHelper;function le(e,t,i,a,n,s,r,o){r&&re(e,r),o&&oe(e,o.x,o.y),n&&se(e,n,s),ie(e,t.x+i,t.y+a)}function de(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:ce,scale:he,copy:ue}=t.MatrixHelper,{getFloorScale:fe}=t.MathHelper,{abs:pe}=Math;const ge={image:function(e,i,a,n,s){let r,o;const l=t.ImageManager.get(a,a.type);return W&&a===W.paint&&H(n,W.boxBounds)?r=W.leafPaint:(r={type:a.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),W=l.use>1?{leafPaint:r,paint:a,boxBounds:D.set(n)}:null),(s||l.loading)&&(o={image:l,attrName:i,attrValue:a}),l.ready?(F(e,i,a,l,r,n),s&&(z(e,o),j(e,o))):l.error?s&&N(e,o,l.error):(s&&(G(e,!0),z(e,o)),r.loadId=l.load(()=>{G(e,!1),e.destroyed||(F(e,i,a,l,r,n)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),j(e,o)),r.loadId=void 0},t=>{G(e,!1),N(e,o,t),r.loadId=void 0},a.lod&&l.getThumbSize(a.lod)),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(e,a,n,s,r){const{scaleX:o,scaleY:l}=i.PaintImage.getImageRenderScaleData(e,n,s,r),d=e.film?e.nowIndex:o+"-"+l,{image:c,brush:h,data:u,originPaint:f}=e,{exporting:p,snapshot:g}=r;if(!u||e.patternId===d&&!p||g){if(!h||!e.style)return!1}else if(a&&(u.repeat?a=!1:f.changeful||e.film||"miniapp"===t.Platform.name||p||(a=t.Platform.image.isLarge(c,o,l)||c.width*o>8096||c.height*l>8096)),a)n.__.__isFastShadow&&(s.fillStyle=e.style||"#000",s.fill());else if(!e.style||f.sync||p?i.PaintImage.createPattern(e,n,s,r):i.PaintImage.createPatternTask(e,n,s,r),!h||!e.style)return!1;return i.PaintImage.drawImage(e,o,l,n,s,r),!0},drawImage:function(e,t,i,a,n,s){const{data:r,image:o,brush:l,complex:d}=e;let{width:c,height:h}=o,u=l||o;if(d){const{blendMode:s,opacity:o}=e.originPaint,{transform:l}=r;n.save(),2===d&&n.clipUI(a),s&&(n.blendMode=s),o&&(n.opacity*=o),l&&n.transform(l),u.render(n,0,0,c,h,a,e,t,i),n.restore()}else r.scaleX&&(c*=r.scaleX,h*=r.scaleY),u.render(n,0,0,c,h,a,e,t,i)},getImageRenderScaleData:function(e,t,a,n){const s=t.getRenderScaleData(!0,e.originPaint.scaleFixed),{data:r}=e;if(e.brush&&i.PaintImage.addBrushScale(s,e,t),a){const{pixelRatio:e}=a;s.scaleX*=e,s.scaleY*=e}return r&&r.scaleX&&(s.scaleX*=Math.abs(r.scaleX),s.scaleY*=Math.abs(r.scaleY)),s},recycleImage:function(e,a){const n=a["_"+e];if(t.isArray(n)){let s,r,o,l,d;const c=a.__leaf;for(let h=0,u=n.length;h<u;h++)s=n[h],r=s.image,d=r&&r.url,d&&(o||(o={}),o[d]=!0,t.ImageManager.recyclePaint(s),s.brush&&i.PaintImage.recycleBrush(s,c),a.__willDestroy&&r.parent&&i.PaintImage.recycleFilter(r,c),r.loading&&(l||(l=a.__input&&a.__input[e]||[],t.isArray(l)||(l=[l])),r.unload(n[h].loadId,!l.some(e=>e.url===d))));return o}return null},createPatternTask:function(e,a,n,s){e.patternTask||(e.patternTask=t.ImageManager.patternTasker.add(()=>de(this,void 0,void 0,function*(){i.PaintImage.createPattern(e,a,n,s),a.forceUpdate("surface")}),0,()=>(e.patternTask=null,n.bounds.hit(a.__nowWorld))))},createPattern:function(e,a,n,s){let{scaleX:r,scaleY:o}=i.PaintImage.getImageRenderScaleData(e,a,n,s),l=e.film?e.nowIndex:r+"-"+o;if(e.patternId!==l&&!a.destroyed&&(!t.Platform.image.isLarge(e.image,r,o)||e.data.repeat)){const{image:d,brush:c,data:h}=e,{transform:u,gap:f}=h,p=i.PaintImage.getPatternFixScale(e,r,o);let g,m,_,{width:w,height:y}=d,{opacity:v}=e.originPaint;if((c||1===v)&&(v=void 0),p&&(r*=p,o*=p),w*=r,y*=o,f&&(m=f.x*r/pe(h.scaleX||1),_=f.y*o/pe(h.scaleY||1),c)){const t=i.PaintImage.getBrushScale(e,a);m/=t,_/=t}(u||1!==r||1!==o)&&(r*=fe(w+(m||0)),o*=fe(y+(_||0)),g=ce(),u&&ue(g,u),he(g,1/r,1/o));const x=d.getCanvas(w,y,v,void 0,m,_,a.leafer&&a.leafer.config.smooth,h.interlace);c?(e.style=x,i.PaintImage.cacheBrush(e,a,n,s)):e.style=d.getPattern(x,h.repeat||t.Platform.origin.noRepeat||"no-repeat",g,e),e.patternId=l}},getPatternFixScale:function(e,i,a){const{image:n}=e;let s,r=t.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,t,a,n){e.data=i.PaintImage.getPatternData(a,n,t)},getPatternData:function(e,a,n){e.padding&&(a=X.set(a).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{width:s,height:r}=n,{mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:m,interlace:_}=e,w=a.width===s&&a.height===r,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,S;switch(t.BoundsHelper.set(Q,0,0,v?r:s,v?s:r),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,n,V),x=V.scaleX,S=V.scaleY),(l||m||g)&&(x&&t.BoundsHelper.scale(Q,x,S,!0),l&&t.AlignHelper.toPoint(l,Q,a,Q,!0,!0))):w&&!u||(x=S=t.BoundsHelper.getFitScale(a,Q,"fit"!==o),t.BoundsHelper.put(a,n,l,x,!1,Q),t.BoundsHelper.scale(Q,x,S,!0)),d&&t.PointHelper.move(Q,d),o){case"stretch":w?x&&(x=S=void 0):(x=a.width/s,S=a.height/r,i.PaintImage.stretchMode(y,a,x,S));break;case"normal":case"clip":if(Q.x||Q.y||x||p||u||f){let e,t;p&&(e=a.width/p.width,t=a.height/p.height),i.PaintImage.clipMode(y,a,Q.x,Q.y,x,S,u,f,e,t),e&&(x=x?x*e:e,S=S?S*t:t)}break;case"repeat":(!w||x||u||f)&&i.PaintImage.repeatMode(y,a,s,r,Q.x,Q.y,x,S,u,f,l,e.freeTransform);case"brush":g||(y.repeat="repeat");const n=t.isObject(g);(m||n)&&(y.gap=function(e,i,a,n,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:Z(r,a,s.width,i&&i.x),y:Z(o,n,s.height,i&&i.y)}}(m,n&&g,Q.width,Q.height,a));break;default:x&&i.PaintImage.fillOrFitMode(y,a,Q.x,Q.y,x,S,u)}return y.transform||"brush"===o||(a.x||a.y)&&q(y.transform=Y(),a.x,a.y),x&&(y.scaleX=x,y.scaleY=S),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),_&&(y.interlace=t.isNumber(_)||"percent"===_.type?{type:"x",offset:_}:_),y},stretchMode:function(e,t,i,a){const n=K(),{x:s,y:r}=t;s||r?ie(n,s,r):i>0&&a>0&&(n.onlyScale=!0),se(n,i,a),e.transform=n},fillOrFitMode:function(e,t,i,a,n,s,r){const o=K();ie(o,t.x+i,t.y+a),se(o,n,s),r&&te(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=K();le(c,t,i,a,n,s,r,o),l&&(r||o?(ee(J),ae(J,t,l,d),ne(c,J)):ae(c,t,l,d)),e.transform=c},repeatMode:function(e,t,i,a,n,s,r,o,l,d,c,h){const u=K();if(h)le(u,t,n,s,r,o,l,d);else{if(l)if("center"===c)te(u,{x:i/2,y:a/2},l);else switch(re(u,l),l){case 90:ie(u,a,0);break;case 180:ie(u,i,a);break;case 270:ie(u,0,i)}$.x=t.x+n,$.y=t.y+s,ie(u,$.x,$.y),r&&ae(u,$,r,o)}e.transform=u}},{toPoint:me}=t.AroundHelper,{hasTransparent:_e}=i.ColorConvert,we={},ye={};function ve(e,a,n,s){if(n){let r,o,l,d;for(let e=0,c=n.length;e<c;e++)r=n[e],t.isString(r)?(l=e/(c-1),o=i.ColorConvert.string(r,s)):(l=r.offset,o=i.ColorConvert.string(r.color,s)),a.addColorStop(l,o),!d&&_e(o)&&(d=!0);d&&(e.isTransparent=!0)}}const{getAngle:xe,getDistance:Se}=t.PointHelper,{get:Pe,rotateOfOuter:be,scaleOfOuter:Be}=t.MatrixHelper,{toPoint:Ee}=t.AroundHelper,Re={},Le={};function ke(e,t,i,a,n){let s;const{width:r,height:o}=e;if(r!==o||a){const e=xe(t,i);s=Pe(),n?(Be(s,t,r/o*(a||1),1),be(s,t,e+90)):(Be(s,t,1,r/o*(a||1)),be(s,t,e))}return s}const{getDistance:Ce}=t.PointHelper,{toPoint:Ae}=t.AroundHelper,Te={},Ie={};const Oe={linearGradient:function(e,i){let{from:a,to:n,type:s,opacity:r}=e;me(a||"top",i,we),me(n||"bottom",i,ye);const o=t.Platform.canvas.createLinearGradient(we.x,we.y,ye.x,ye.y),l={type:s,style:o};return ve(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:a,to:n,type:s,opacity:r,stretch:o}=e;Ee(a||"center",i,Re),Ee(n||"bottom",i,Le);const l=t.Platform.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,Se(Re,Le)),d={type:s,style:l};ve(d,l,e.stops,r);const c=ke(i,Re,Le,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,i){let{from:a,to:n,type:s,opacity:r,rotation:o,stretch:l}=e;Ae(a||"center",i,Te),Ae(n||"bottom",i,Ie);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(o?o*t.OneRadian:0,Te.x,Te.y):t.Platform.canvas.createRadialGradient(Te.x,Te.y,0,Te.x,Te.y,Ce(Te,Ie)),c={type:s,style:d};ve(c,d,e.stops,r);const h=ke(i,Te,Ie,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),c},getTransform:ke},{copy:Me,move:We,toOffsetOutBounds:De}=t.BoundsHelper,{max:He,abs:Fe}=Math,ze={},je=new t.Matrix,Ne={};function Ue(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=He(r,n+s-a),o=He(o,n+s+i),l=He(l,n+s+a),d=He(d,n+s-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ge(e,i,a){const{shapeBounds:n}=a;let s,r;t.Platform.fullImageShadow?(Me(ze,e.bounds),We(ze,i.x-n.x,i.y-n.y),s=e.bounds,r=ze):(s=n,r=i),e.copyWorld(a.canvas,s,r)}const{toOffsetOutBounds:Ye}=t.BoundsHelper,qe={};const Xe=Ue;const Ve={shadow:function(e,a,n){let s,r;const{__nowWorld:o}=e,{shadow:l}=e.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=n,g=a.getSameCanvas(),m=l.length-1;De(c,Ne,h),l.forEach((l,_)=>{let w=1;if(l.scaleFixed){const e=Math.abs(o.scaleX);e>1&&(w=1/e)}g.setWorldShadow(Ne.offsetX+(l.x||0)*f*w,Ne.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w,i.ColorConvert.string(l.color)),r=i.Effect.getShadowTransform(e,g,n,l,Ne,w),r&&g.setTransform(r),Ge(g,Ne,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")),t.LeafHelper.copyCanvasByWorld(e,a,g,s,l.blendMode),m&&_<m&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(e,a,n){let s,r;const{__nowWorld:o}=e,{innerShadow:l}=e.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=n,g=a.getSameCanvas(),m=l.length-1;Ye(c,qe,h),l.forEach((l,_)=>{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=i.Effect.getShadowTransform(e,g,n,l,qe,w,!0),r&&g.setTransform(r),Ge(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,i.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,a,g,s,l.blendMode),m&&_<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:Ue,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 je.set().scaleOfOuter({x:(n.x+n.width/2)*t.pixelRatio,y:(n.y+n.height/2)*t.pixelRatio},1+i/o,1+i/l),je}},isTransformShadow(e){},getInnerShadowSpread:Xe},{excludeRenderBounds:Qe}=t.LeafBoundsHelper;let Ze;function $e(e,t,i,a,n,s,r,o){switch(t){case"grayscale":Ze||(Ze=!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);Ke(e,t,i,1,n,s)}(e,i,a,n,r,o);break;case"opacity-path":Ke(e,i,a,s,r,o);break;case"path":o&&i.restore()}}function Je(e){return e.getSameCanvas(!1,!0)}function Ke(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)}i.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&&($e(this,r,e,n,a,s,void 0,!0),a=n=null),"clipping"!==o&&"clipping-path"!==o||Qe(i,t)||i.__render(e,t),s=i.__.opacity,Ze=!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&&$e(this,r,e,n,a,s,void 0,!1),Qe(i,t)||i.__render(n||e,t),c&&$e(this,r,e,n,a,s,c,!1)}$e(this,r,e,n,a,s,void 0,!0)};const et=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",tt=et+"_#~&*+\\=|≮≯≈≠=…",it=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 at(e){const t={};return e.split("").forEach(e=>t[e]=!0),t}const nt=at("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),st=at("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),rt=at(et),ot=at(tt),lt=at("- —/~|┆·");var dt;!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"}(dt||(dt={}));const{Letter:ct,Single:ht,Before:ut,After:ft,Symbol:pt,Break:gt}=dt;function mt(e){return nt[e]?ct:lt[e]?gt:st[e]?ut:rt[e]?ft:ot[e]?pt:it.test(e)?ht:ct}const _t={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 wt(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:yt}=_t,{Letter:vt,Single:xt,Before:St,After:Pt,Symbol:bt,Break:Bt}=dt;let Et,Rt,Lt,kt,Ct,At,Tt,It,Ot,Mt,Wt,Dt,Ht,Ft,zt,jt,Nt,Ut=[];function Gt(e,t){Ot&&!It&&(It=Ot),Et.data.push({char:e,width:t}),Lt+=t}function Yt(){kt+=Lt,Et.width=Lt,Rt.words.push(Et),Et={data:[]},Lt=0}function qt(){Ft&&(zt.paraNumber++,Rt.paraStart=!0,Ft=!1),Ot&&(Rt.startCharSize=It,Rt.endCharSize=Ot,It=0),Rt.width=kt,jt.width?yt(Rt):Nt&&Xt(),Ut.push(Rt),Rt={words:[]},kt=0}function Xt(){kt>(zt.maxWidth||0)&&(zt.maxWidth=kt)}const{top:Vt,right:Qt,bottom:Zt,left:$t}=t.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 Kt={getDrawData:function(e,a){t.isString(e)||(e=String(e));let n=0,s=0,r=a.__getInput("width")||0,o=a.__getInput("height")||0;const{__padding:l}=a;l&&(r?(n=l[$t],r-=l[Qt]+l[$t],!r&&(r=.01)):a.autoSizeAlign||(n=l[$t]),o?(s=l[Vt],o-=l[Vt]+l[Zt],!o&&(o=.01)):a.autoSizeAlign||(s=l[Vt]));const d={bounds:{x:n,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=a.__font};return function(e,i,a){zt=e,Ut=e.rows,jt=e.bounds,Nt=!jt.width&&!a.autoSizeAlign;const{__letterSpacing:n,paraIndent:s,textCase:r}=a,{canvas:o}=t.Platform,{width:l}=jt;if(a.__isCharMode){const e="none"!==a.textWrap,t="break"===a.textWrap;Ft=!0,Wt=null,It=Tt=Ot=Lt=kt=0,Et={data:[]},Rt={words:[]};for(let a=0,d=(i=[...i]).length;a<d;a++)At=i[a],"\n"===At?(Lt&&Yt(),Rt.paraEnd=!0,qt(),Ft=!0):(Mt=mt(At),Mt===vt&&"none"!==r&&(At=wt(At,r,!Lt)),Tt=o.measureText(At).width,n&&(n<0&&(Ot=Tt),Tt+=n),Dt=Mt===xt&&(Wt===xt||Wt===vt)||Wt===xt&&Mt!==Pt,Ht=!(Mt!==St&&Mt!==xt||Wt!==bt&&Wt!==Pt),Ct=Ft&&s?l-s:l,e&&l&&kt+Lt+Tt>Ct&&(t?(Lt&&Yt(),kt&&qt()):(Ht||(Ht=Mt===vt&&Wt==Pt),Dt||Ht||Mt===Bt||Mt===St||Mt===xt||Lt+Tt>Ct?(Lt&&Yt(),kt&&qt()):kt&&qt()))," "===At&&!0!==Ft&&kt+Lt===0||(Mt===Bt?(" "===At&&Lt&&Yt(),Gt(At,Tt),Yt()):Dt||Ht?(Lt&&Yt(),Gt(At,Tt)):Gt(At,Tt)),Wt=Mt);Lt&&Yt(),kt&&qt(),Ut.length>0&&(Ut[Ut.length-1].paraEnd=!0)}else i.split("\n").forEach(e=>{zt.paraNumber++,kt=o.measureText(e).width,Ut.push({x:s||0,text:e,width:kt,paraStart:!0}),Nt&&Xt()})}(d,e,a),l&&function(e,t,i,a,n){if(!a&&i.autoSizeAlign)switch(i.textAlign){case"left":Jt(t,"x",e[$t]);break;case"right":Jt(t,"x",-e[Qt])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Jt(t,"y",e[Vt]);break;case"bottom":Jt(t,"y",-e[Zt])}}(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:m}=a,_=s*n+(h?h*(e.paraNumber-1):0),w=r;if(l&&_>m)_=Math.max(t.__autoHeight?_:m,s),n>1&&(e.overflow=n);else if(m||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>_&&(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=_}(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,_=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=_>1?h/(_-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?(m={char:"",x:c},c=function(e,t,i){return e.forEach(e=>{i.char+=e.char,t+=e.width}),t}(t.data,c,m),(e.isOverflow||" "!==m.char)&&e.data.push(m)):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===_-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(e,i,a,n){const{rows:s,overflow:r}=e;let{textOverflow:o}=i;if(r&&s.splice(r),n&&o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=a+n-d;("none"===i.textWrap?s:[s[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let a=i;a>-1&&(e=t.data[a],l=e.x+e.width,!(a===i&&l<c));a--){if(l<c&&" "!==e.char||!a){t.data.splice(a+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(e){e.text="",e.data.forEach(t=>{e.text+=t.char}),e.data=null}(t)}})}}(d,a,n,r),"none"!==a.textDecoration&&function(e,a){let n,s=0;const{fontSize:r,textDecoration:o}=a;switch(e.decorationHeight=r/11,t.isObject(o)?(n=o.type,o.color&&(e.decorationColor=i.ColorConvert.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):n=o,n){case"under":e.decorationY=[.15*r+s];break;case"delete":e.decorationY=[.35*-r];break;case"under-delete":e.decorationY=[.15*r+s,.35*-r]}}(d,a),d}};const ei={string:function(e,a){if(!e)return"#000";const n=t.isNumber(a)&&a<1;if(t.isString(e)){if(!n||!i.ColorConvert.object)return e;e=i.ColorConvert.object(e)}let s=t.isUndefined(e.a)?1:e.a;n&&(s*=a);const r=e.r+","+e.g+","+e.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(i.TextConvert,Kt),Object.assign(i.ColorConvert,ei),Object.assign(i.Paint,M),Object.assign(i.PaintImage,ge),Object.assign(i.PaintGradient,Oe),Object.assign(i.Effect,Ve);try{wx&&n(0,wx)}catch(e){}Object.defineProperty(exports,"LeaferFilm",{enumerable:!0,get:function(){return t.LeaferFilm}}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),Object.defineProperty(exports,"LeaferVideo",{enumerable:!0,get:function(){return t.LeaferVideo}}),exports.Layouter=m,exports.LeaferCanvas=a,exports.Renderer=w,exports.Watcher=s,exports.useCanvas=n,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(i).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return i[e]}})});
//# sourceMappingURL=miniapp.min.cjs.map