@leafer-draw/worker 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.
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as s,FileHelper as i,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as m,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,isObject as k,BoundsHelper as B,FourNumberHelper as E,Matrix as R,isUndefined as A,isString as L,getMatrixData as T,MatrixHelper as O,MathHelper as W,AlignHelper as C,PointHelper as M,ImageEvent as D,AroundHelper as P,Direction4 as I,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as Y,Paint as z,ColorConvert as U,PaintGradient as G,Export as q,Effect as X,Group as N,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=Math.ceil(t*s),this.view.height=Math.ceil(e*s),this.clientBounds=this.bounds}}s(OffscreenCanvasRenderingContext2D.prototype),s(Path2D.prototype);const{mineType:V}=i;function Q(t,s){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,s)=>new Promise((i,n)=>{t.convertToBlob({type:V(e),quality:s}).then(t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,s)=>t.convertToBlob({type:V(e),quality:s}),canvasSaveAs:(t,e,s)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((s,i)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{s(t)}).catch(t=>{i(t)})},n.onerror=t=>i(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new H(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:Z}=navigator;Z.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),Z.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):Z.indexOf("Mac")>-1?e.os="Mac":Z.indexOf("Linux")>-1&&(e.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=f,{pushAllChildBranch:et,pushAllParent:st}=p;const{worldBounds:it}=g;class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,it),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:at,updateAllChange:rt}=f,ot=m.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(i);o.forEach(t=>t.setBefore()),s.emitEvent(new x(n,o,this.times)),this.extraBlock=null,i.sort(),function(t,e){let s;t.list.forEach(t=>{s=t.__layout,e.without(t)&&!s.proxyZoom&&(s.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),st(t,e)):s.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),st(t,e)))})}(i,this.__levelList),function(t){let e,s,i;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(s=e[t],s.isBranch&&s.__tempNumber){i=s.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||K(i[t])}K(s)}})}(this.__levelList),function(t){t.list.forEach(tt)}(i),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),s.emitEvent(new x(a,o,this.times)),s.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:s,LAYOUT:i,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(s,a,this.times)),lt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(i,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){at(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:s}=this.extraBlock||(this.extraBlock=new nt([]));e.length?s.add(t.__world):s.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=m.get("Renderer");class ct{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,s&&(this.config=l.default(s,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,dt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=new _(i);s.save(),i.spread(ct.clipSpread).ceil(),s.clearWorld(i),s.clipWorld(i),this.__render(i,n),s.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,s){const{canvas:i}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(i,t),e.render(this.target,i,a),this.renderBounds=s=s||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),i.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const s=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return e.requestRender(s);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:s}=t.old;if(!new _(0,0,e,s).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(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||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,s){this.target.emitEvent(new d(t,this.times,e,s))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.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 ht(t,e){const s=t.__,{rows:i,decorationY:n}=s.__textDrawData;let a;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,s=i.length;t<s;t++)a=i[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=s.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,a)))}}function ut(t,e){t.__.__font?ht(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ft(t,e,s){switch(e.__.strokeAlign){case"center":pt(t,1,e,s);break;case"inside":gt(t,"inside",e,s);break;case"outside":e.__.__fillAfterStroke?pt(t,2,e,s):gt(t,"outside",e,s)}}function pt(t,e,s,i){const n=s.__;k(t)?wt(t,e,!0,s,i):(i.setStroke(t,n.__strokeWidth*e,n),_t(s,i))}function gt(t,e,s,i){const n=i.getSameCanvas(!0,!0);n.font=s.__.__font,pt(t,2,s,n),n.blendMode="outside"===e?"destination-out":"destination-in",ht(s,n),n.blendMode="normal",f.copyCanvasByWorld(s,i,n),n.recycle(s.__nowWorld)}function _t(t,e){let s,i=t.__.__textDrawData;const{rows:n,decorationY:a}=i;for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(a){const{decorationHeight:t}=i;n.forEach(s=>a.forEach(i=>e.strokeRect(s.x,s.y+i,s.width,t)))}}function wt(t,e,s,i,n){let a;const r=i.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!Y.checkImage(i,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),s?_t(i,n):n.stroke(),n.restoreBlendMode()):s?_t(i,n):n.stroke()}}function mt(t,e,s){const i=e.__;if(i.__strokeWidth)if(i.__font)ft(t,e,s);else switch(i.strokeAlign){case"center":yt(t,1,e,s);break;case"inside":!function(t,e,s){s.save(),s.clipUI(e),yt(t,2,e,s),s.restore()}(t,e,s);break;case"outside":!function(t,e,s){const i=e.__;if(i.__fillAfterStroke)yt(t,2,e,s);else{const{renderBounds:n}=e.__layout,a=s.getSameCanvas(!0,!0);e.__drawRenderPath(a),yt(t,2,e,a),a.clipUI(i),a.clearWorld(n),f.copyCanvasByWorld(e,s,a),a.recycle(e.__nowWorld)}}(t,e,s)}}function yt(t,e,s,i){const n=s.__;k(t)?wt(t,e,!1,s,i):(i.setStroke(t,n.__strokeWidth*e,n),i.stroke()),n.__useArrow&&z.strokeArrow(t,s,i)}ct.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,s)=>new ct(t,e,s),selector:(t,e)=>{},interaction:(t,e,s,i)=>{}}),e.layout=lt.fullLayout,e.render=function(t,e,s){const i=Object.assign(Object.assign({},s),{topRendering:!0});s.topList=new o,t.__render(e,s),s.topList.length&&s.topList.forEach(t=>t.__render(e,i))};const{getSpread:xt,copyAndSpread:vt,toOuterOf:bt,getOuterOf:St,getByMove:kt,move:Bt,getIntersectData:Et}=B,Rt={};let At;const{stintSet:Lt}=l,{hasTransparent:Tt}=U;function Ot(t,e,s){if(!k(e)||!1===e.visible||0===e.opacity)return;let i;const{boxBounds:n}=s.__layout;switch(e.type){case"image":i=Y.image(s,t,e,n,!At||!At[e.url]);break;case"linear":i=G.linearGradient(e,n);break;case"radial":i=G.radialGradient(e,n);break;case"angular":i=G.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;i={type:a,style:U.string(r,o)};break;default:A(e.r)||(i={type:"solid",style:U.string(e)})}if(i){if(L(i.style)&&Tt(i.style)&&(i.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;i.strokeStyle=e.style}e.editing&&(i.editing=e.editing),e.blendMode&&(i.blendMode=e.blendMode)}return i}const Wt={compute:function(t,e){const s=e.__,i=[];let n,a,r,o=s.__input[t];w(o)||(o=[o]),At=Y.recycleImage(t,s);for(let s,n=0,a=o.length;n<a;n++)(s=Ot(t,o[n],e))&&(i.push(s),s.strokeStyle&&(r||(r=1),s.strokeStyle.strokeWidth&&(r=Math.max(r,s.strokeStyle.strokeWidth))));s["_"+t]=i.length?i:void 0,i.length&&i.every(t=>t.isTransparent)&&(i.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Lt(s,"__isAlphaPixelFill",n),Lt(s,"__isTransparentFill",a)):(Lt(s,"__isAlphaPixelStroke",n),Lt(s,"__isTransparentStroke",a),Lt(s,"__hasMultiStrokeStyle",r))},fill:function(t,e,s){s.fillStyle=t,ut(e,s)},fills:function(t,e,s){let i;for(let n=0,a=t.length;n<a;n++){if(i=t[n],i.image){if(Y.checkImage(e,s,i,!e.__.__font))continue;if(!i.style){!n&&i.image.isPlacehold&&e.drawImagePlaceholder(s,i.image);continue}}if(s.fillStyle=i.style,i.transform||i.scaleFixed){if(s.save(),i.transform&&s.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&n>1)&&s.scale(1/t,1/n)}i.blendMode&&(s.blendMode=i.blendMode),ut(e,s),s.restore()}else i.blendMode?(s.saveBlendMode(i.blendMode),ut(e,s),s.restoreBlendMode()):ut(e,s)}},fillPathOrText:ut,fillText:ht,stroke:mt,strokes:function(t,e,s){mt(t,e,s)},strokeText:ft,drawTextStroke:_t,shape:function(t,s,i){const n=s.getSameCanvas(),a=s.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;bt(o.strokeSpread?(vt(Rt,o.boxBounds,o.strokeSpread),Rt):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,d=f=l,c=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?xt(a,E.swapAndScale(o.renderShapeSpread,g,_)):a;n=Et(t,l)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=s.getSameCanvas(),t.__renderShape(p,i),g*=w,_*=m),f=St(l,u),d=kt(f,-u.e,-u.f),c=St(r,u),Bt(c,-u.e,-u.f);const y=i.matrix;y?(h=new R(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),i=Object.assign(Object.assign({},i),{matrix:h})}return t.__renderShape(n,i),{canvas:n,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Ct={},Mt=T();const{get:Dt,set:Pt,rotateOfOuter:It,translate:Ft,scaleOfOuter:Yt,multiplyParent:zt,scale:Ut,rotate:Gt,skew:qt}=O;function Xt(t,e,s,i){const n=Dt();Ft(n,e.x,e.y),s&&Ut(n,s,i),t.transform=n}function Nt(t,e,s,i,n,a,r){const o=Dt();Ft(o,e.x+s,e.y+i),Ut(o,n,a),r&&It(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function jt(t,e,s,i,n,a,r,o,l,d){const c=Dt();Vt(c,e,s,i,n,a,r,o),l&&(r||o?(Pt(Mt),Yt(Mt,e,l,d),zt(c,Mt)):Yt(c,e,l,d)),t.transform=c}function Ht(t,e,s,i,n,a,r,o,l,d,c,h){const u=Dt();if(h)Vt(u,e,n,a,r,o,l,d);else{if(l)if("center"===c)It(u,{x:s/2,y:i/2},l);else switch(Gt(u,l),l){case 90:Ft(u,i,0);break;case 180:Ft(u,s,i);break;case 270:Ft(u,0,s)}Ct.x=e.x+n,Ct.y=e.y+a,Ft(u,Ct.x,Ct.y),r&&Yt(u,Ct,r,o)}t.transform=u}function Vt(t,e,s,i,n,a,r,o){r&&Gt(t,r),o&&qt(t,o.x,o.y),n&&Ut(t,n,a),Ft(t,e.x+s,e.y+i)}const{get:Qt,translate:Zt}=O,$t=new _,Jt={},Kt={};function te(t,e,s,i){const{changeful:n,sync:a,scaleFixed:r}=s;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=ee(s,i,e)}function ee(t,e,s){t.padding&&(e=$t.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:i,height:n}=s;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===i&&e.height===n,m={mode:r},y="center"!==o&&(h||0)%180==90;let x,v;switch(B.set(Kt,0,0,y?n:i,y?i:n),r&&"cover"!==r&&"fit"!==r?((d||c)&&(W.getScaleData(d,c,s,Jt),x=Jt.scaleX,v=Jt.scaleY),(o||g||p)&&(x&&B.scale(Kt,x,v,!0),o&&C.toPoint(o,Kt,e,Kt,!0,!0))):w&&!h||(x=v=B.getFitScale(e,Kt,"fit"!==r),B.put(e,s,o,x,!1,Kt),B.scale(Kt,x,v,!0)),l&&M.move(Kt,l),r){case"stretch":w||(x=e.width/i,v=e.height/n,Xt(m,e,x,v));break;case"normal":case"clip":if(Kt.x||Kt.y||x||f||h||u){let t,s;f&&(t=e.width/f.width,s=e.height/f.height),jt(m,e,Kt.x,Kt.y,x,v,h,u,t,s),t&&(x=x?x*t:t,v=v?v*s:s)}break;case"repeat":(!w||x||h||u)&&Ht(m,e,i,n,Kt.x,Kt.y,x,v,h,u,o,t.freeTransform),p||(m.repeat="repeat");const s=k(p);(g||s)&&(m.gap=function(t,e,s,i,n){let a,r;k(t)?(a=t.x,r=t.y):a=r=t;return{x:se(a,s,n.width,e&&e.x),y:se(r,i,n.height,e&&e.y)}}(g,s&&p,Kt.width,Kt.height,e));break;default:x&&Nt(m,e,Kt.x,Kt.y,x,v,h)}return m.transform||(e.x||e.y)&&Zt(m.transform=Qt(),e.x,e.y),m.width=i,m.height=n,x&&(m.scaleX=x,m.scaleY=v),a&&(m.opacity=a),_&&(m.filters=_),p&&(m.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m}function se(t,e,s,i){const n=L(t)||i?(i?s-i*e:s%e)/((i||Math.floor(s/e))-1):t;return"auto"===t&&n<0?0:n}let ie,ne=new _;const{isSame:ae}=B;function re(t,e,s,i,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||te(n,i,s,a),!0}function oe(t,e){ce(t,D.LOAD,e)}function le(t,e){ce(t,D.LOADED,e)}function de(t,e,s){e.error=s,t.forceUpdate("surface"),ce(t,D.ERROR,e)}function ce(t,e,s){t.hasEvent(e)&&t.emitEvent(new D(e,s))}function he(t,e){const{leafer:s}=t;s&&s.viewReady&&(s.renderer.ignore=e)}const{get:ue,scale:fe,copy:pe}=O,{floor:ge,ceil:_e,max:we,abs:me}=Math;function ye(t,s,i){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,s.scaleFixed);const r=n+"-"+a+"-"+i;if(s.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=s;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=i,a*=i,f&&(f=me(f),p=me(p),c=ue(),pe(c,g),fe(c,1/f,1/p),n*=f,a*=p),h*=n,u*=a;const m=h*u;if(!_&&m>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/_e(t))}else{const t=o.width*o.height;y>t&&(y=t)}m>y&&(d=Math.sqrt(m/y)),d&&(n/=d,a/=d,h/=d,u/=d),f&&(n/=f,a/=p);const x=w&&w.x*n,v=w&&w.y*a;if(g||1!==n||1!==a){const t=h+(x||0),e=u+(v||0);n/=t/we(ge(t),1),a/=e/we(ge(e),1),c||(c=ue(),g&&pe(c,g)),fe(c,1/n,1/a)}const b=o.getCanvas(h,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),S=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",c,s);return s.style=S,s.patternId=r,!0}}function xe(t,e,s,i){return new(s||(s=Promise))(function(n,a){function r(t){try{l(i.next(t))}catch(t){a(t)}}function o(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(r,o)}l((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const ve={image:function(t,e,s,i,n){let a,r;const o=b.get(s);return ie&&s===ie.paint&&ae(i,ie.boxBounds)?a=ie.leafPaint:(a={type:s.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),ie=o.use>1?{leafPaint:a,paint:s,boxBounds:ne.set(i)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:s}),o.ready?(re(t,e,s,o,a,i),n&&(oe(t,r),le(t,r))):o.error?n&&de(t,r,o.error):(n&&(he(t,!0),oe(t,r)),a.loadId=o.load(()=>{he(t,!1),t.destroyed||(re(t,e,s,o,a,i)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),le(t,r)),a.loadId=void 0},e=>{he(t,!1),de(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,s,i,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:o}=s,{data:l}=i;if(!l||i.patternId===a+"-"+r+"-"+o&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(i.changeful||"miniapp"===e.name&&S.isResizing(t)||q.running)){let{width:t,height:s}=l;t*=a*o,s*=r*o,l.scaleX&&(t*=l.scaleX,s*=l.scaleY),n=t*s>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(s.fillStyle=i.style||"#000",s.fill()),function(t,e,s,i){e.save(),e.clipUI(t),s.blendMode&&(e.blendMode=s.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(s.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(t,s,i,l),!0):(!i.style||i.sync||q.running?ye(t,i,o):i.patternTask||(i.patternTask=b.patternTasker.add(()=>xe(this,void 0,void 0,function*(){i.patternTask=null,s.bounds.hit(t.__nowWorld)&&ye(t,i,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ye,recycleImage:function(t,e){const s=e["_"+t];if(w(s)){let i,n,a,r,o;for(let l=0,d=s.length;l<d;l++)i=s[l],n=i.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(s[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:te,getPatternData:ee,stretchMode:Xt,fillOrFitMode:Nt,clipMode:jt,repeatMode:Ht},{toPoint:be}=P,{hasTransparent:Se}=U,ke={},Be={};function Ee(t,e,s,i){if(s){let n,a,r,o;for(let t=0,l=s.length;t<l;t++)n=s[t],L(n)?(r=t/(l-1),a=U.string(n,i)):(r=n.offset,a=U.string(n.color,i)),e.addColorStop(r,a),!o&&Se(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Re,getDistance:Ae}=M,{get:Le,rotateOfOuter:Te,scaleOfOuter:Oe}=O,{toPoint:We}=P,Ce={},Me={};function De(t,e,s,i,n){let a;const{width:r,height:o}=t;if(r!==o||i){const t=Re(e,s);a=Le(),n?(Oe(a,e,r/o*(i||1),1),Te(a,e,t+90)):(Oe(a,e,1,r/o*(i||1)),Te(a,e,t))}return a}const{getDistance:Pe}=M,{toPoint:Ie}=P,Fe={},Ye={};const ze={linearGradient:function(t,s){let{from:i,to:n,type:a,opacity:r}=t;be(i||"top",s,ke),be(n||"bottom",s,Be);const o=e.canvas.createLinearGradient(ke.x,ke.y,Be.x,Be.y),l={type:a,style:o};return Ee(l,o,t.stops,r),l},radialGradient:function(t,s){let{from:i,to:n,type:a,opacity:r,stretch:o}=t;We(i||"center",s,Ce),We(n||"bottom",s,Me);const l=e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,Ae(Ce,Me)),d={type:a,style:l};Ee(d,l,t.stops,r);const c=De(s,Ce,Me,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,s){let{from:i,to:n,type:a,opacity:r,stretch:o}=t;Ie(i||"center",s,Fe),Ie(n||"bottom",s,Ye);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Fe.x,Fe.y):e.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,Pe(Fe,Ye)),d={type:a,style:l};Ee(d,l,t.stops,r);const c=De(s,Fe,Ye,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:De},{copy:Ue,move:Ge,toOffsetOutBounds:qe}=B,{max:Xe,abs:Ne}=Math,je={},He=new R,Ve={};function Qe(t,e){let s,i,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{s=t.x||0,i=t.y||0,a=1.5*(t.blur||0),n=Ne(t.spread||0),r=Xe(r,n+a-i),o=Xe(o,n+a+s),l=Xe(l,n+a+i),d=Xe(d,n+a-s)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ze(t,s,i){const{shapeBounds:n}=i;let a,r;e.fullImageShadow?(Ue(je,t.bounds),Ge(je,s.x-n.x,s.y-n.y),a=t.bounds,r=je):(a=n,r=s),t.copyWorld(i.canvas,a,r)}const{toOffsetOutBounds:$e}=B,Je={};const Ke=Qe;const ts={shadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=r.length-1;qe(l,Ve,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Ve.offsetX+(r.x||0)*h*w,Ve.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w,U.string(r.color)),n=X.getShadowTransform(t,p,s,r,Ve,w),n&&p.setTransform(n),Ze(p,Ve,s),n&&p.resetTransform(),i=d,r.box&&(p.restore(),p.save(),o&&(p.copyWorld(p,d,a,"copy"),i=a),o?p.copyWorld(o,a,a,"destination-out"):p.copyWorld(s.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,p,i,r.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},innerShadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=r.length-1;$e(l,Je,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(Je.offsetX+(r.x||0)*h*w,Je.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w),n=X.getShadowTransform(t,p,s,r,Je,w,!0),n&&p.setTransform(n),Ze(p,Je,s),p.restore(),o?(p.copyWorld(p,d,a,"copy"),p.copyWorld(o,a,a,"source-out"),i=a):(p.copyWorld(s.canvas,c,l,"source-out"),i=d),p.fillWorld(i,U.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,p,i,r.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__nowWorld.a),s.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),s.filter="none"},backgroundBlur:function(t,e,s){},getShadowRenderSpread:Qe,getShadowTransform:function(t,e,s,i,n,a,r){if(i.spread){const s=2*i.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return He.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+s/o,1+s/l),He}},isTransformShadow(t){},getInnerShadowSpread:Ke},{excludeRenderBounds:es}=g;let ss;function is(t,e,s,i,n,a,r,o){switch(e){case"grayscale":ss||(ss=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,s,i,n,a){const r=t.__nowWorld;s.resetTransform(),s.opacity=1,s.useMask(i,r),a&&i.recycle(r);as(t,e,s,1,n,a)}(t,s,i,n,r,o);break;case"opacity-path":as(t,s,i,a,r,o);break;case"path":o&&s.restore()}}function ns(t){return t.getSameCanvas(!1,!0)}function as(t,e,s,i,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(s,r,void 0,n),a?s.recycle(r):s.clearWorld(r)}N.prototype.__renderMask=function(t,e){let s,i,n,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(s=l[d],o=s.__.mask,o){r&&(is(this,r,t,n,i,a,void 0,!0),i=n=null),"clipping"!==o&&"clipping-path"!==o||es(s,e)||s.__render(t,e),a=s.__.opacity,ss=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=ns(t))):(r="path",t.save()),s.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",i||(i=ns(t)),n||(n=ns(t)),s.__render(i,e));continue}const c=1===a&&s.__.__blendMode;c&&is(this,r,t,n,i,a,void 0,!1),es(s,e)||s.__render(n||t,e),c&&is(this,r,t,n,i,a,c,!1)}is(this,r,t,n,i,a,void 0,!0)};const rs=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",os=rs+"_#~&*+\\=|≮≯≈≠=…",ls=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 ds(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const cs=ds("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),hs=ds("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),us=ds(rs),fs=ds(os),ps=ds("- —/~|┆·");var gs;!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"}(gs||(gs={}));const{Letter:_s,Single:ws,Before:ms,After:ys,Symbol:xs,Break:vs}=gs;function bs(t){return cs[t]?_s:ps[t]?vs:hs[t]?ms:us[t]?ys:fs[t]?xs:ls.test(t)?ws:_s}const Ss={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let a=n-1;a>-1&&(s=e[a].data[0]," "===s.char);a--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function ks(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Bs}=Ss,{Letter:Es,Single:Rs,Before:As,After:Ls,Symbol:Ts,Break:Os}=gs;let Ws,Cs,Ms,Ds,Ps,Is,Fs,Ys,zs,Us,Gs,qs,Xs,Ns,js,Hs,Vs,Qs=[];function Zs(t,e){zs&&!Ys&&(Ys=zs),Ws.data.push({char:t,width:e}),Ms+=e}function $s(){Ds+=Ms,Ws.width=Ms,Cs.words.push(Ws),Ws={data:[]},Ms=0}function Js(){Ns&&(js.paraNumber++,Cs.paraStart=!0,Ns=!1),zs&&(Cs.startCharSize=Ys,Cs.endCharSize=zs,Ys=0),Cs.width=Ds,Hs.width?Bs(Cs):Vs&&Ks(),Qs.push(Cs),Cs={words:[]},Ds=0}function Ks(){Ds>(js.maxWidth||0)&&(js.maxWidth=Ds)}const{top:ti,right:ei,bottom:si,left:ii}=I;function ni(t,e,s){const{bounds:i,rows:n}=t;i[e]+=s;for(let t=0;t<n.length;t++)n[t][e]+=s}const ai={getDrawData:function(t,s){L(t)||(t=String(t));let i=0,n=0,a=s.__getInput("width")||0,r=s.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=s;d&&(a?(i=d[ii],a-=d[ei]+d[ii]):s.autoSizeAlign||(i=d[ii]),r?(n=d[ti],r-=d[ti]+d[si]):s.autoSizeAlign||(n=d[ti]));const c={bounds:{x:i,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,s,i){js=t,Qs=t.rows,Hs=t.bounds,Vs=!Hs.width&&!i.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=i,{canvas:o}=e,{width:l,height:d}=Hs;if(l||d||n||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Ns=!0,Gs=null,Ys=Fs=zs=Ms=Ds=0,Ws={data:[]},Cs={words:[]},n&&(s=[...s]);for(let i=0,d=s.length;i<d;i++)Is=s[i],"\n"===Is?(Ms&&$s(),Cs.paraEnd=!0,Js(),Ns=!0):(Us=bs(Is),Us===Es&&"none"!==r&&(Is=ks(Is,r,!Ms)),Fs=o.measureText(Is).width,n&&(n<0&&(zs=Fs),Fs+=n),qs=Us===Rs&&(Gs===Rs||Gs===Es)||Gs===Rs&&Us!==Ls,Xs=!(Us!==As&&Us!==Rs||Gs!==Ts&&Gs!==Ls),Ps=Ns&&a?l-a:l,t&&l&&Ds+Ms+Fs>Ps&&(e?(Ms&&$s(),Ds&&Js()):(Xs||(Xs=Us===Es&&Gs==Ls),qs||Xs||Us===Os||Us===As||Us===Rs||Ms+Fs>Ps?(Ms&&$s(),Ds&&Js()):Ds&&Js()))," "===Is&&!0!==Ns&&Ds+Ms===0||(Us===Os?(" "===Is&&Ms&&$s(),Zs(Is,Fs),$s()):qs||Xs?(Ms&&$s(),Zs(Is,Fs)):Zs(Is,Fs)),Gs=Us);Ms&&$s(),Ds&&Js(),Qs.length>0&&(Qs[Qs.length-1].paraEnd=!0)}else s.split("\n").forEach(t=>{js.paraNumber++,Ds=o.measureText(t).width,Qs.push({x:a||0,text:t,width:Ds,paraStart:!0}),Vs&&Ks()})}(c,t,s),d&&function(t,e,s,i,n){if(!i&&s.autoSizeAlign)switch(s.textAlign){case"left":ni(e,"x",t[ii]);break;case"right":ni(e,"x",-t[ei])}if(!n&&s.autoSizeAlign)switch(s.verticalAlign){case"top":ni(e,"y",t[ti]);break;case"bottom":ni(e,"y",-t[si])}}(d,c,s,a,r),function(t,e){const{rows:s,bounds:i}=t,n=s.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:_}=i,w=a*n+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(y=s[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=a,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<i.x&&(i.x=x),v>i.width&&(i.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=s.length))}i.y=p,i.height=w}(c,s),function(t,e,s){const{rows:i}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,c,h,u;i.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=s&&("justify"===n||"both"===n)&&u>1?(s-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,s)=>{1===c?(h={char:"",x:o},o=function(t,e,s){return t.forEach(t=>{s.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,s,i){return t.forEach(t=>{(i||" "!==t.char)&&(t.x=e,s.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||s===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,s,a),c.overflow&&function(t,s,i,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=s;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=i+n-d;("none"===s.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let s=e.data.length-1;for(let i=s;i>-1&&(t=e.data[i],l=t.x+t.width,!(i===s&&l<c));i--){if(l<c&&" "!==t.char||!i){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,s,i,a),"none"!==o&&function(t,e){let s,i=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,k(a)?(s=a.type,a.color&&(t.decorationColor=U.string(a.color)),a.offset&&(i=Math.min(.3*n,Math.max(a.offset,.15*-n)))):s=a,s){case"under":t.decorationY=[.15*n+i];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+i,.35*-n]}}(c,s),c}};const ri={string:function(t,e){if(!t)return"#000";const s=F(e)&&e<1;if(L(t)){if(!s||!U.object)return t;t=U.object(t)}let i=A(t.a)?1:t.a;s&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}};Object.assign(j,ai),Object.assign(U,ri),Object.assign(z,Wt),Object.assign(Y,ve),Object.assign(G,ze),Object.assign(X,ts),Q();export{lt as Layouter,H as LeaferCanvas,ct as Renderer,$ as Watcher,Q as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as s,FileHelper as a,Creator as i,LeaferImage as n,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as m,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as R,Matrix as E,isUndefined as T,isString as A,ImageEvent as L,MatrixHelper as O,MathHelper as M,AlignHelper as W,PointHelper as C,getMatrixData as D,AroundHelper as P,Direction4 as I,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{Paint as Y,PaintImage as X,ColorConvert as U,PaintGradient as G,Effect as z,Group as q,TextConvert as N}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class j extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=Math.ceil(t*s),this.view.height=Math.ceil(e*s),this.clientBounds=this.bounds}}s(OffscreenCanvasRenderingContext2D.prototype),s(Path2D.prototype);const{mineType:H}=a;function V(t,s){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,s)=>new Promise((a,i)=>{t.convertToBlob({type:H(e),quality:s}).then(t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>i(t),e.readAsDataURL(t)}).catch(t=>{i(t)})}),canvasToBolb:(t,e,s)=>t.convertToBlob({type:H(e),quality:s}),canvasSaveAs:(t,e,s)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((s,a)=>{let i=new XMLHttpRequest;i.open("GET",e.image.getRealURL(t),!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then(t=>{s(t)}).catch(t=>{a(t)})},i.onerror=t=>a(t),i.send()})},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new j(t,e),image:t=>new n(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:Q}=navigator;Q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),Q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):Q.indexOf("Mac")>-1?e.os="Mac":Q.indexOf("Linux")>-1&&(e.os="Linux");class Z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:$,updateBounds:J,updateChange:K}=f,{pushAllChildBranch:tt,pushAllParent:et}=g;const{worldBounds:st}=p;class at{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:it,updateAllChange:nt}=f,rt=m.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:s,__updatedList:a}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=x,o=this.getBlocks(a);o.forEach(t=>t.setBefore()),s.emitEvent(new x(i,o,this.times)),this.extraBlock=null,a.sort(),function(t,e){let s;t.list.forEach(t=>{s=t.__layout,e.without(t)&&!s.proxyZoom&&(s.matrixChanged?($(t,!0),e.add(t),t.isBranch&&tt(t,e),et(t,e)):s.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),et(t,e)))})}(a,this.__levelList),function(t){let e,s,a;t.sort(!0),t.levels.forEach(i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber){a=s.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||J(a[t])}J(s)}})}(this.__levelList),function(t){t.list.forEach(K)}(a),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),s.emitEvent(new x(n,o,this.times)),s.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:s,LAYOUT:a,AFTER:i}=x,n=this.getBlocks(new o(e));e.emitEvent(new x(s,n,this.times)),ot.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new x(a,n,this.times)),e.emitEvent(new x(i,n,this.times)),this.addBlocks(n),v.end(t)}static fullLayout(t){it(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:s}=this.extraBlock||(this.extraBlock=new at([]));e.length?s.add(t.__world):s.set(t.__world),e.add(t)}}createBlock(t){return new at(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const lt=m.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,s&&(this.config=l.default(s,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,lt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,lt.error(t)}lt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return lt.warn("rendering");if(this.times>3)return lt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:s}=this,a=t.getIntersect(s.bounds),i=new _(a);s.save(),a.spread(dt.clipSpread).ceil(),s.clearWorld(a),s.clipWorld(a),this.__render(a,i),s.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,s){const{canvas:a}=this,i=t.includes(this.target.__world),n=i?{includes:i}:{bounds:t,includes:i};this.needFill&&a.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(a,t),e.render(this.target,a,n),this.renderBounds=s=s||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),a.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const s=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:a}=this.config;if(a&&t>a)return e.requestRender(s);const{frames:i}=this;i.length>30&&i.shift(),i.push(t),this.FPS=Math.round(i.reduce((t,e)=>t+e,0)/i.length),this.requestTime=0,this.checkRender()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:s}=t.old;if(!new _(0,0,e,s).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(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||lt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,s){this.target.emitEvent(new d(t,this.times,e,s))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.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 ct(t,e,s){t.__.__font?Y.fillText(t,e,s):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ht(t,e,s,a,i){const n=s.__;k(t)?Y.drawStrokesStyle(t,e,!1,s,a,i):(a.setStroke(t,n.__strokeWidth*e,n),a.stroke()),n.__useArrow&&Y.strokeArrow(t,s,a,i)}function ut(t,e,s,a,i){const n=s.__;k(t)?Y.drawStrokesStyle(t,e,!0,s,a,i):(a.setStroke(t,n.__strokeWidth*e,n),Y.drawTextStroke(s,a,i))}function ft(t,e,s,a,i){const n=a.getSameCanvas(!0,!0);n.font=s.__.__font,ut(t,2,s,n,i),n.blendMode="outside"===e?"destination-out":"destination-in",Y.fillText(s,n,i),n.blendMode="normal",f.copyCanvasByWorld(s,a,n),n.recycle(s.__nowWorld)}dt.clipSpread=10,Object.assign(i,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,s)=>new dt(t,e,s),selector:(t,e)=>{},interaction:(t,e,s,a)=>{}}),e.layout=ot.fullLayout,e.render=function(t,e,s){const a=Object.assign(Object.assign({},s),{topRendering:!0});s.topList=new o,t.__render(e,s),s.topList.length&&s.topList.forEach(t=>t.__render(e,a))};const{getSpread:gt,copyAndSpread:pt,toOuterOf:_t,getOuterOf:wt,getByMove:mt,move:yt,getIntersectData:xt}=B,vt={};let St;const{stintSet:bt}=l,{hasTransparent:kt}=U;function Bt(t,e,s){if(!k(e)||!1===e.visible||0===e.opacity)return;let a;const{boxBounds:i}=s.__layout;switch(e.type){case"image":a=X.image(s,t,e,i,!St||!St[e.url]);break;case"linear":a=G.linearGradient(e,i);break;case"radial":a=G.radialGradient(e,i);break;case"angular":a=G.conicGradient(e,i);break;case"solid":const{type:n,color:r,opacity:o}=e;a={type:n,style:U.string(r,o)};break;default:T(e.r)||(a={type:"solid",style:U.string(e)})}if(a){if(A(a.style)&&kt(a.style)&&(a.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;a.strokeStyle=e.style}e.editing&&(a.editing=e.editing),e.blendMode&&(a.blendMode=e.blendMode)}return a}const Rt={compute:function(t,e){const s=e.__,a=[];let i,n,r,o=s.__input[t];w(o)||(o=[o]),St=X.recycleImage(t,s);for(let s,i=0,n=o.length;i<n;i++)(s=Bt(t,o[i],e))&&(a.push(s),s.strokeStyle&&(r||(r=1),s.strokeStyle.strokeWidth&&(r=Math.max(r,s.strokeStyle.strokeWidth))));s["_"+t]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(i=!0),n=!0),"fill"===t?(bt(s,"__isAlphaPixelFill",i),bt(s,"__isTransparentFill",n)):(bt(s,"__isAlphaPixelStroke",i),bt(s,"__isTransparentStroke",n),bt(s,"__hasMultiStrokeStyle",r))},fill:function(t,e,s,a){s.fillStyle=t,ct(e,s,a)},fills:function(t,e,s,a){let i;for(let n=0,r=t.length;n<r;n++){if(i=t[n],i.image){if(X.checkImage(i,!e.__.__font,e,s,a))continue;if(!i.style){!n&&i.image.isPlacehold&&e.drawImagePlaceholder(i.image,s,a);continue}}if(s.fillStyle=i.style,i.transform||i.scaleFixed){if(s.save(),i.transform&&s.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:a}=e.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&a>1)&&s.scale(1/t,1/a)}i.blendMode&&(s.blendMode=i.blendMode),ct(e,s,a),s.restore()}else i.blendMode?(s.saveBlendMode(i.blendMode),ct(e,s,a),s.restoreBlendMode()):ct(e,s,a)}},fillPathOrText:ct,fillText:function(t,e,s){const a=t.__,{rows:i,decorationY:n}=a.__textDrawData;let r;a.__isPlacehold&&a.placeholderColor&&(e.fillStyle=a.placeholderColor);for(let t=0,s=i.length;t<s;t++)r=i[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(n){const{decorationColor:t,decorationHeight:s}=a.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>n.forEach(a=>e.fillRect(t.x,t.y+a,t.width,s)))}},stroke:function(t,e,s,a){const i=e.__;if(i.__strokeWidth)if(i.__font)Y.strokeText(t,e,s,a);else switch(i.strokeAlign){case"center":ht(t,1,e,s,a);break;case"inside":!function(t,e,s,a){s.save(),s.clipUI(e),ht(t,2,e,s,a),s.restore()}(t,e,s,a);break;case"outside":!function(t,e,s,a){const i=e.__;if(i.__fillAfterStroke)ht(t,2,e,s,a);else{const{renderBounds:n}=e.__layout,r=s.getSameCanvas(!0,!0);e.__drawRenderPath(r),ht(t,2,e,r,a),r.clipUI(i),r.clearWorld(n),f.copyCanvasByWorld(e,s,r),r.recycle(e.__nowWorld)}}(t,e,s,a)}},strokes:function(t,e,s,a){Y.stroke(t,e,s,a)},strokeText:function(t,e,s,a){switch(e.__.strokeAlign){case"center":ut(t,1,e,s,a);break;case"inside":ft(t,"inside",e,s,a);break;case"outside":e.__.__fillAfterStroke?ut(t,2,e,s,a):ft(t,"outside",e,s,a)}},drawTextStroke:function(t,e,s){let a,i=t.__.__textDrawData;const{rows:n,decorationY:r}=i;for(let t=0,s=n.length;t<s;t++)a=n[t],a.text?e.strokeText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.strokeText(t.char,t.x,a.y)});if(r){const{decorationHeight:t}=i;n.forEach(s=>r.forEach(a=>e.strokeRect(s.x,s.y+a,s.width,t)))}},drawStrokesStyle:function(t,e,s,a,i,n){let r;const o=a.__,{__hasMultiStrokeStyle:l}=o;l||i.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!X.checkImage(r,!1,a,i,n))&&r.style){if(l){const{strokeStyle:t}=r;t?i.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):i.setStroke(r.style,o.__strokeWidth*e,o)}else i.strokeStyle=r.style;r.blendMode?(i.saveBlendMode(r.blendMode),s?Y.drawTextStroke(a,i,n):i.stroke(),i.restoreBlendMode()):s?Y.drawTextStroke(a,i,n):i.stroke()}},shape:function(t,s,a){const i=s.getSameCanvas(),n=s.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;_t(o.strokeSpread?(pt(vt,o.boxBounds,o.strokeSpread),vt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=i,d=f=l,c=r;else{let i;if(e.fullImageShadow)i=l;else{const t=o.renderShapeSpread?gt(n,R.swapAndScale(o.renderShapeSpread,p,_)):n;i=xt(t,l)}u=n.getFitMatrix(i);let{a:w,d:m}=u;u.a<1&&(g=s.getSameCanvas(),t.__renderShape(g,a),p*=w,_*=m),f=wt(l,u),d=mt(f,-u.e,-u.f),c=wt(r,u),yt(c,-u.e,-u.f);const y=a.matrix;y?(h=new E(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),a=Object.assign(Object.assign({},a),{matrix:h})}return t.__renderShape(i,a),{canvas:i,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Et,Tt=new _;const{isSame:At}=B;function Lt(t,e,s,a,i,n){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=a.width/e.pixelRatio,e.__naturalHeight=a.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||X.createData(i,a,s,n),!0}function Ot(t,e){Ct(t,L.LOAD,e)}function Mt(t,e){Ct(t,L.LOADED,e)}function Wt(t,e,s){e.error=s,t.forceUpdate("surface"),Ct(t,L.ERROR,e)}function Ct(t,e,s){t.hasEvent(e)&&t.emitEvent(new L(e,s))}function Dt(t,e){const{leafer:s}=t;s&&s.viewReady&&(s.renderer.ignore=e)}const{get:Pt,translate:It}=O,Ft=new _,Yt={},Xt={};function Ut(t,e,s,a){const i=A(t)||a?(a?s-a*e:s%e)/((a||Math.floor(s/e))-1):t;return"auto"===t&&i<0?0:i}let Gt={},zt=D();const{get:qt,set:Nt,rotateOfOuter:jt,translate:Ht,scaleOfOuter:Vt,multiplyParent:Qt,scale:Zt,rotate:$t,skew:Jt}=O;function Kt(t,e,s,a,i,n,r,o){r&&$t(t,r),o&&Jt(t,o.x,o.y),i&&Zt(t,i,n),Ht(t,e.x+s,e.y+a)}function te(t,e,s,a){return new(s||(s=Promise))(function(i,n){function r(t){try{l(a.next(t))}catch(t){n(t)}}function o(t){try{l(a.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ee,scale:se,copy:ae}=O,{getFloorScale:ie}=M,{abs:ne}=Math;const re={image:function(t,e,s,a,i){let n,r;const o=S.get(s);return Et&&s===Et.paint&&At(a,Et.boxBounds)?n=Et.leafPaint:(n={type:s.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Et=o.use>1?{leafPaint:n,paint:s,boxBounds:Tt.set(a)}:null),(i||o.loading)&&(r={image:o,attrName:e,attrValue:s}),o.ready?(Lt(t,e,s,o,n,a),i&&(Ot(t,r),Mt(t,r))):o.error?i&&Wt(t,r,o.error):(i&&(Dt(t,!0),Ot(t,r)),n.loadId=o.load(()=>{Dt(t,!1),t.destroyed||(Lt(t,e,s,o,n,a)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Mt(t,r)),n.loadId=void 0},e=>{Dt(t,!1),Wt(t,r,e),n.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,s,a,i,n){const{scaleX:r,scaleY:o}=X.getImageRenderScaleData(t,a,i,n),{image:l,data:d}=t,{exporting:c}=n;return!(!d||t.patternId===r+"-"+o&&!c)&&(s&&(d.repeat?s=!1:t.changeful||"miniapp"===e.name&&b.isResizing(a)||c||(s=e.image.isLarge(l,r,o))),s?(a.__.__isFastShadow&&(i.fillStyle=t.style||"#000",i.fill()),X.drawImage(t,r,o,a,i,n),!0):(!t.style||t.sync||c?X.createPattern(t,a,i,n):X.createPatternTask(t,a,i,n),!1))},drawImage:function(t,e,s,a,i,n){const{data:r,image:o,blendMode:l}=t,{opacity:d,transform:c}=r,h=o.getFull(r.filters),u=a.__;let f,{width:g,height:p}=o;c&&!c.onlyScale||(f=u.path||u.cornerRadius)||d||l?(i.save(),f&&i.clipUI(a),l&&(i.blendMode=l),d&&(i.opacity*=d),c&&i.transform(c),i.drawImage(h,0,0,g,p),i.restore()):(r.scaleX&&(g*=r.scaleX,p*=r.scaleY),i.drawImage(h,0,0,g,p))},getImageRenderScaleData:function(t,e,s,a){const i=e.getRenderScaleData(!0,t.scaleFixed),{data:n}=t;if(s){const{pixelRatio:t}=s;i.scaleX*=t,i.scaleY*=t}return n&&n.scaleX&&(i.scaleX*=Math.abs(n.scaleX),i.scaleY*=Math.abs(n.scaleY)),i},recycleImage:function(t,e){const s=e["_"+t];if(w(s)){let a,i,n,r,o;for(let l=0,d=s.length;l<d;l++)a=s[l],i=a.image,o=i&&i.url,o&&(n||(n={}),n[o]=!0,S.recycle(i),i.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),i.unload(s[l].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,s,a){t.patternTask||(t.patternTask=S.patternTasker.add(()=>te(this,void 0,void 0,function*(){t.patternTask=null,s.bounds.hit(e.__nowWorld)&&X.createPattern(t,e,s,a),e.forceUpdate("surface")}),300))},createPattern:function(t,s,a,i){let{scaleX:n,scaleY:r}=X.getImageRenderScaleData(t,s,a,i),o=n+"-"+r;if(t.patternId!==o&&!s.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:a,data:i}=t,{transform:l,gap:d}=i,c=X.getPatternFixScale(t,n,r);let h,u,f,{width:g,height:p}=a;c&&(n*=c,r*=c),g*=n,p*=r,d&&(u=d.x*n/ne(i.scaleX||1),f=d.y*r/ne(i.scaleY||1)),(l||1!==n||1!==r)&&(n*=ie(g+(u||0)),r*=ie(p+(f||0)),h=ee(),l&&ae(h,l),se(h,1/n,1/r));const _=a.getCanvas(g,p,i.opacity,i.filters,u,f,s.leafer&&s.leafer.config.smooth),w=a.getPattern(_,i.repeat||e.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,s,a){const{image:i}=t;let n,r=e.image.maxPatternSize,o=i.width*i.height;return i.isSVG?s>1&&(n=Math.ceil(s)/s):r>o&&(r=o),(o*=s*a)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,s,a){const{changeful:i,sync:n,scaleFixed:r}=s;i&&(t.changeful=i),n&&(t.sync=n),r&&(t.scaleFixed=r),t.data=X.getPatternData(s,a,e)},getPatternData:function(t,e,s){t.padding&&(e=Ft.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:i}=s,{opacity:n,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===a&&e.height===i,m={mode:r},y="center"!==o&&(h||0)%180==90;let x,v;switch(B.set(Xt,0,0,y?i:a,y?a:i),r&&"cover"!==r&&"fit"!==r?((d||c)&&(M.getScaleData(d,c,s,Yt),x=Yt.scaleX,v=Yt.scaleY),(o||p||g)&&(x&&B.scale(Xt,x,v,!0),o&&W.toPoint(o,Xt,e,Xt,!0,!0))):w&&!h||(x=v=B.getFitScale(e,Xt,"fit"!==r),B.put(e,s,o,x,!1,Xt),B.scale(Xt,x,v,!0)),l&&C.move(Xt,l),r){case"stretch":w?x&&(x=v=void 0):(x=e.width/a,v=e.height/i,X.stretchMode(m,e,x,v));break;case"normal":case"clip":if(Xt.x||Xt.y||x||f||h||u){let t,s;f&&(t=e.width/f.width,s=e.height/f.height),X.clipMode(m,e,Xt.x,Xt.y,x,v,h,u,t,s),t&&(x=x?x*t:t,v=v?v*s:s)}break;case"repeat":(!w||x||h||u)&&X.repeatMode(m,e,a,i,Xt.x,Xt.y,x,v,h,u,o,t.freeTransform),g||(m.repeat="repeat");const s=k(g);(p||s)&&(m.gap=function(t,e,s,a,i){let n,r;k(t)?(n=t.x,r=t.y):n=r=t;return{x:Ut(n,s,i.width,e&&e.x),y:Ut(r,a,i.height,e&&e.y)}}(p,s&&g,Xt.width,Xt.height,e));break;default:x&&X.fillOrFitMode(m,e,Xt.x,Xt.y,x,v,h)}return m.transform||(e.x||e.y)&&It(m.transform=Pt(),e.x,e.y),x&&(m.scaleX=x,m.scaleY=v),n&&n<1&&(m.opacity=n),_&&(m.filters=_),g&&(m.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),m},stretchMode:function(t,e,s,a){const i=qt(),{x:n,y:r}=e;n||r?Ht(i,n,r):i.onlyScale=!0,Zt(i,s,a),t.transform=i},fillOrFitMode:function(t,e,s,a,i,n,r){const o=qt();Ht(o,e.x+s,e.y+a),Zt(o,i,n),r&&jt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,s,a,i,n,r,o,l,d){const c=qt();Kt(c,e,s,a,i,n,r,o),l&&(r||o?(Nt(zt),Vt(zt,e,l,d),Qt(c,zt)):Vt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,s,a,i,n,r,o,l,d,c,h){const u=qt();if(h)Kt(u,e,i,n,r,o,l,d);else{if(l)if("center"===c)jt(u,{x:s/2,y:a/2},l);else switch($t(u,l),l){case 90:Ht(u,a,0);break;case 180:Ht(u,s,a);break;case 270:Ht(u,0,s)}Gt.x=e.x+i,Gt.y=e.y+n,Ht(u,Gt.x,Gt.y),r&&Vt(u,Gt,r,o)}t.transform=u}},{toPoint:oe}=P,{hasTransparent:le}=U,de={},ce={};function he(t,e,s,a){if(s){let i,n,r,o;for(let t=0,l=s.length;t<l;t++)i=s[t],A(i)?(r=t/(l-1),n=U.string(i,a)):(r=i.offset,n=U.string(i.color,a)),e.addColorStop(r,n),!o&&le(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:ue,getDistance:fe}=C,{get:ge,rotateOfOuter:pe,scaleOfOuter:_e}=O,{toPoint:we}=P,me={},ye={};function xe(t,e,s,a,i){let n;const{width:r,height:o}=t;if(r!==o||a){const t=ue(e,s);n=ge(),i?(_e(n,e,r/o*(a||1),1),pe(n,e,t+90)):(_e(n,e,1,r/o*(a||1)),pe(n,e,t))}return n}const{getDistance:ve}=C,{toPoint:Se}=P,be={},ke={};const Be={linearGradient:function(t,s){let{from:a,to:i,type:n,opacity:r}=t;oe(a||"top",s,de),oe(i||"bottom",s,ce);const o=e.canvas.createLinearGradient(de.x,de.y,ce.x,ce.y),l={type:n,style:o};return he(l,o,t.stops,r),l},radialGradient:function(t,s){let{from:a,to:i,type:n,opacity:r,stretch:o}=t;we(a||"center",s,me),we(i||"bottom",s,ye);const l=e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,fe(me,ye)),d={type:n,style:l};he(d,l,t.stops,r);const c=xe(s,me,ye,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,s){let{from:a,to:i,type:n,opacity:r,stretch:o}=t;Se(a||"center",s,be),Se(i||"bottom",s,ke);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,be.x,be.y):e.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,ve(be,ke)),d={type:n,style:l};he(d,l,t.stops,r);const c=xe(s,be,ke,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:xe},{copy:Re,move:Ee,toOffsetOutBounds:Te}=B,{max:Ae,abs:Le}=Math,Oe={},Me=new E,We={};function Ce(t,e){let s,a,i,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{s=t.x||0,a=t.y||0,n=1.5*(t.blur||0),i=Le(t.spread||0),r=Ae(r,i+n-a),o=Ae(o,i+n+s),l=Ae(l,i+n+a),d=Ae(d,i+n-s)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function De(t,s,a){const{shapeBounds:i}=a;let n,r;e.fullImageShadow?(Re(Oe,t.bounds),Ee(Oe,s.x-i.x,s.y-i.y),n=t.bounds,r=Oe):(n=i,r=s),t.copyWorld(a.canvas,n,r)}const{toOffsetOutBounds:Pe}=B,Ie={};const Fe=Ce;const Ye={shadow:function(t,e,s){let a,i;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,g=e.getSameCanvas(),p=r.length-1;Te(l,We,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}g.setWorldShadow(We.offsetX+(r.x||0)*h*w,We.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w,U.string(r.color)),i=z.getShadowTransform(t,g,s,r,We,w),i&&g.setTransform(i),De(g,We,s),i&&g.resetTransform(),a=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),a=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(s.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,a,r.blendMode),p&&_<p&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(t,e,s){let a,i;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,g=e.getSameCanvas(),p=r.length-1;Pe(l,Ie,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(Ie.offsetX+(r.x||0)*h*w,Ie.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w),i=z.getShadowTransform(t,g,s,r,Ie,w,!0),i&&g.setTransform(i),De(g,Ie,s),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),a=n):(g.copyWorld(s.canvas,c,l,"source-out"),a=d),g.fillWorld(a,U.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,a,r.blendMode),p&&_<p&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,s){const{blur:a}=t.__;s.setWorldBlur(a*t.__nowWorld.a),s.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),s.filter="none"},backgroundBlur:function(t,e,s){},getShadowRenderSpread:Ce,getShadowTransform:function(t,e,s,a,i,n,r){if(a.spread){const s=2*a.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Me.set().scaleOfOuter({x:(i.x+i.width/2)*e.pixelRatio,y:(i.y+i.height/2)*e.pixelRatio},1+s/o,1+s/l),Me}},isTransformShadow(t){},getInnerShadowSpread:Fe},{excludeRenderBounds:Xe}=p;let Ue;function Ge(t,e,s,a,i,n,r,o){switch(e){case"grayscale":Ue||(Ue=!0,i.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,s,a,i,n){const r=t.__nowWorld;s.resetTransform(),s.opacity=1,s.useMask(a,r),n&&a.recycle(r);qe(t,e,s,1,i,n)}(t,s,a,i,r,o);break;case"opacity-path":qe(t,s,a,n,r,o);break;case"path":o&&s.restore()}}function ze(t){return t.getSameCanvas(!1,!0)}function qe(t,e,s,a,i,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(s,r,void 0,i),n?s.recycle(r):s.clearWorld(r)}q.prototype.__renderMask=function(t,e){let s,a,i,n,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(s=l[d],o=s.__.mask,o){r&&(Ge(this,r,t,i,a,n,void 0,!0),a=i=null),"clipping"!==o&&"clipping-path"!==o||Xe(s,e)||s.__render(t,e),n=s.__.opacity,Ue=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",i||(i=ze(t))):(r="path",t.save()),s.__clip(i||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=ze(t)),i||(i=ze(t)),s.__render(a,e));continue}const c=1===n&&s.__.__blendMode;c&&Ge(this,r,t,i,a,n,void 0,!1),Xe(s,e)||s.__render(i||t,e),c&&Ge(this,r,t,i,a,n,c,!1)}Ge(this,r,t,i,a,n,void 0,!0)};const Ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",je=Ne+"_#~&*+\\=|≮≯≈≠=…",He=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 Ve(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Qe=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ze=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$e=Ve(Ne),Je=Ve(je),Ke=Ve("- —/~|┆·");var ts;!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"}(ts||(ts={}));const{Letter:es,Single:ss,Before:as,After:is,Symbol:ns,Break:rs}=ts;function os(t){return Qe[t]?es:Ke[t]?rs:Ze[t]?as:$e[t]?is:Je[t]?ns:He.test(t)?ss:es}const ls={trimRight(t){const{words:e}=t;let s,a=0,i=e.length;for(let n=i-1;n>-1&&(s=e[n].data[0]," "===s.char);n--)a++,t.width-=s.width;a&&e.splice(i-a,a)}};function ds(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:cs}=ls,{Letter:hs,Single:us,Before:fs,After:gs,Symbol:ps,Break:_s}=ts;let ws,ms,ys,xs,vs,Ss,bs,ks,Bs,Rs,Es,Ts,As,Ls,Os,Ms,Ws,Cs=[];function Ds(t,e){Bs&&!ks&&(ks=Bs),ws.data.push({char:t,width:e}),ys+=e}function Ps(){xs+=ys,ws.width=ys,ms.words.push(ws),ws={data:[]},ys=0}function Is(){Ls&&(Os.paraNumber++,ms.paraStart=!0,Ls=!1),Bs&&(ms.startCharSize=ks,ms.endCharSize=Bs,ks=0),ms.width=xs,Ms.width?cs(ms):Ws&&Fs(),Cs.push(ms),ms={words:[]},xs=0}function Fs(){xs>(Os.maxWidth||0)&&(Os.maxWidth=xs)}const{top:Ys,right:Xs,bottom:Us,left:Gs}=I;function zs(t,e,s){const{bounds:a,rows:i}=t;a[e]+=s;for(let t=0;t<i.length;t++)i[t][e]+=s}const qs={getDrawData:function(t,s){A(t)||(t=String(t));let a=0,i=0,n=s.__getInput("width")||0,r=s.__getInput("height")||0;const{__padding:o}=s;o&&(n?(a=o[Gs],n-=o[Xs]+o[Gs],!n&&(n=.01)):s.autoSizeAlign||(a=o[Gs]),r?(i=o[Ys],r-=o[Ys]+o[Us],!r&&(r=.01)):s.autoSizeAlign||(i=o[Ys]));const l={bounds:{x:a,y:i,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=s.__font};return function(t,s,a){Os=t,Cs=t.rows,Ms=t.bounds,Ws=!Ms.width&&!a.autoSizeAlign;const{__letterSpacing:i,paraIndent:n,textCase:r}=a,{canvas:o}=e,{width:l}=Ms;if(a.__isCharMode){const t="none"!==a.textWrap,e="break"===a.textWrap;Ls=!0,Es=null,ks=bs=Bs=ys=xs=0,ws={data:[]},ms={words:[]},i&&(s=[...s]);for(let a=0,d=s.length;a<d;a++)Ss=s[a],"\n"===Ss?(ys&&Ps(),ms.paraEnd=!0,Is(),Ls=!0):(Rs=os(Ss),Rs===hs&&"none"!==r&&(Ss=ds(Ss,r,!ys)),bs=o.measureText(Ss).width,i&&(i<0&&(Bs=bs),bs+=i),Ts=Rs===us&&(Es===us||Es===hs)||Es===us&&Rs!==gs,As=!(Rs!==fs&&Rs!==us||Es!==ps&&Es!==gs),vs=Ls&&n?l-n:l,t&&l&&xs+ys+bs>vs&&(e?(ys&&Ps(),xs&&Is()):(As||(As=Rs===hs&&Es==gs),Ts||As||Rs===_s||Rs===fs||Rs===us||ys+bs>vs?(ys&&Ps(),xs&&Is()):xs&&Is()))," "===Ss&&!0!==Ls&&xs+ys===0||(Rs===_s?(" "===Ss&&ys&&Ps(),Ds(Ss,bs),Ps()):Ts||As?(ys&&Ps(),Ds(Ss,bs)):Ds(Ss,bs)),Es=Rs);ys&&Ps(),xs&&Is(),Cs.length>0&&(Cs[Cs.length-1].paraEnd=!0)}else s.split("\n").forEach(t=>{Os.paraNumber++,xs=o.measureText(t).width,Cs.push({x:n||0,text:t,width:xs,paraStart:!0}),Ws&&Fs()})}(l,t,s),o&&function(t,e,s,a,i){if(!a&&s.autoSizeAlign)switch(s.textAlign){case"left":zs(e,"x",t[Gs]);break;case"right":zs(e,"x",-t[Xs])}if(!i&&s.autoSizeAlign)switch(s.verticalAlign){case"top":zs(e,"y",t[Ys]);break;case"bottom":zs(e,"y",-t[Us])}}(o,l,s,n,r),function(t,e){const{rows:s,bounds:a}=t,i=s.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=a,w=n*i+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(_,n),i>1&&(t.overflow=i);else if(_||u)switch(c){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}m+=g;let y,x,v,S=p||u?p:t.maxWidth;for(let r=0,c=i;r<c;r++){if(y=s[r],y.x=f,y.width<p||y.width>p&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=n,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<a.x&&(a.x=x),v>a.width&&(a.width=v),l&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=s.length))}a.y=g,a.height=w}(l,s),s.__isCharMode&&function(t,e,s){const{rows:a}=t,{textAlign:i,paraIndent:n,letterSpacing:r}=e,o=s&&i.includes("both"),l=o||s&&i.includes("justify"),d=l&&i.includes("letter");let c,h,u,f,g,p,_,w,m,y;a.forEach(t=>{t.words&&(g=n&&t.paraStart?n:0,w=t.words.length,l&&(y=!t.paraEnd||o,h=s-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,s)=>{1===p?(_={char:"",x:c},c=function(t,e,s){return t.forEach(t=>{s.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,s,a,i){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,s.push(t)),e+=t.width,i&&(e+=i)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(m=s===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(l,s,n),l.overflow&&function(t,s,a,i){if(!i)return;const{rows:n,overflow:r}=t;let{textOverflow:o}=s;if(n.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=a+i-d;("none"===s.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let s=e.data.length-1;for(let a=s;a>-1&&(t=e.data[a],l=t.x+t.width,!(a===s&&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(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,s,a,n),"none"!==s.textDecoration&&function(t,e){let s,a=0;const{fontSize:i,textDecoration:n}=e;switch(t.decorationHeight=i/11,k(n)?(s=n.type,n.color&&(t.decorationColor=U.string(n.color)),n.offset&&(a=Math.min(.3*i,Math.max(n.offset,.15*-i)))):s=n,s){case"under":t.decorationY=[.15*i+a];break;case"delete":t.decorationY=[.35*-i];break;case"under-delete":t.decorationY=[.15*i+a,.35*-i]}}(l,s),l}};const Ns={string:function(t,e){if(!t)return"#000";const s=F(e)&&e<1;if(A(t)){if(!s||!U.object)return t;t=U.object(t)}let a=T(t.a)?1:t.a;s&&(a*=e);const i=t.r+","+t.g+","+t.b;return 1===a?"rgb("+i+")":"rgba("+i+","+a+")"}};Object.assign(N,qs),Object.assign(U,Ns),Object.assign(Y,Rt),Object.assign(X,re),Object.assign(G,Be),Object.assign(z,Ye),V();export{ot as Layouter,j as LeaferCanvas,dt as Renderer,Z as Watcher,V as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map