@leafer-draw/node 1.9.12 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node.cjs +385 -383
- package/dist/node.esm.js +387 -385
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +10 -10
package/dist/node.esm.min.js
CHANGED
|
@@ -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 o,LeafList as r,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 v,Run as x,ImageManager as b,ResizeEvent as S,isObject as B,BoundsHelper as k,FourNumberHelper as R,Matrix as E,isUndefined as L,isString as T,getMatrixData as A,MatrixHelper as O,MathHelper as C,AlignHelper as W,PointHelper as M,ImageEvent as D,AroundHelper as P,Direction4 as F,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as U}from"fs";import{PaintImage as Y,Paint as X,ColorConvert as z,PaintGradient as N,Export as q,Effect as j,Group as G,TextConvert as H,TwoPointBoundsHelper as V,Bounds as Q,FileHelper as J,Platform as Z,isUndefined as $,Matrix as K,MathHelper as tt,Creator as et,TaskProcessor as st,Resource as it,LeaferCanvasBase as nt,Debug as at,Plugin as ot,UI as rt}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function lt(t,e,s,i){return new(s||(s=Promise))(function(n,a){function o(t){try{l(i.next(t))}catch(t){a(t)}}function r(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(o,r)}l((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class dt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,s(this.context.__proto__))}__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}}const{mineType:ct,fileType:ht}=i;function ut(t,s){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:i}=s;e.origin={createCanvas:(e,s,i)=>new t(e,s,i),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),download(t,e){},loadImage:t=>i(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:i}=s;e.origin={createCanvas:(e,s,i)=>new t(e,s,i),canvasToDataURL:(t,e,s)=>t.toDataURL(ct(e),s),canvasToBolb:(t,e,s)=>lt(this,void 0,void 0,function*(){return t.toBuffer(ct(e),s)}),canvasSaveAs:(t,e,s)=>lt(this,void 0,void 0,function*(){return U(e,t.toBuffer(ct(ht(e)),s))}),download(t,e){},loadImage:t=>i(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new dt(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ft{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,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 r,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:pt,updateBounds:gt,updateChange:_t}=f,{pushAllChildBranch:wt,pushAllParent:mt}=p;const{worldBounds:yt}=g;class vt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,yt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,yt),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:xt,updateAllChange:bt}=f,St=m.get("Layouter");class Bt{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(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){St.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?St.warn("layouting"):this.times>3?St.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=x.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=v,r=this.getBlocks(i);r.forEach(t=>t.setBefore()),s.emitEvent(new v(n,r,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?(pt(t,!0),e.add(t),t.isBranch&&wt(t,e),mt(t,e)):s.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),mt(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||gt(i[t])}gt(s)}})}(this.__levelList),function(t){t.list.forEach(_t)}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),s.emitEvent(new v(a,r,this.times)),s.emitEvent(new v(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:s,LAYOUT:i,AFTER:n}=v,a=this.getBlocks(new r(e));e.emitEvent(new v(s,a,this.times)),Bt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new v(i,a,this.times)),e.emitEvent(new v(n,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){xt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),bt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:s}=this.extraBlock||(this.extraBlock=new vt([]));e.length?s.add(t.__world):s.set(t.__world),e.add(t)}}createBlock(t){return new vt(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_([[v.REQUEST,this.layout,this],[v.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 kt=m.get("Renderer");class Rt{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(v.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 _,kt.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,kt.error(t)}kt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return kt.warn("rendering");if(this.times>3)return kt.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=x.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=new _(i);s.save(),i.spread(Rt.clipSpread).ceil(),s.clearWorld(i),s.clipWorld(i),this.__render(i,n),s.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.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||kt.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],[v.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 Et(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 Lt(t,e){t.__.__font?Et(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,s){switch(e.__.strokeAlign){case"center":At(t,1,e,s);break;case"inside":Ot(t,"inside",e,s);break;case"outside":e.__.__fillAfterStroke?At(t,2,e,s):Ot(t,"outside",e,s)}}function At(t,e,s,i){const n=s.__;B(t)?Wt(t,e,!0,s,i):(i.setStroke(t,n.__strokeWidth*e,n),Ct(s,i))}function Ot(t,e,s,i){const n=i.getSameCanvas(!0,!0);n.font=s.__.__font,At(t,2,s,n),n.blendMode="outside"===e?"destination-out":"destination-in",Et(s,n),n.blendMode="normal",f.copyCanvasByWorld(s,i,n),n.recycle(s.__nowWorld)}function Ct(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 o=i.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);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(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),s?Ct(i,n):n.stroke(),n.restoreBlendMode()):s?Ct(i,n):n.stroke()}}function Mt(t,e,s){const i=e.__;if(i.__strokeWidth)if(i.__font)Tt(t,e,s);else switch(i.strokeAlign){case"center":Dt(t,1,e,s);break;case"inside":!function(t,e,s){s.save(),s.clipUI(e),Dt(t,2,e,s),s.restore()}(t,e,s);break;case"outside":!function(t,e,s){const i=e.__;if(i.__fillAfterStroke)Dt(t,2,e,s);else{const{renderBounds:n}=e.__layout,a=s.getSameCanvas(!0,!0);e.__drawRenderPath(a),Dt(t,2,e,a),a.clipUI(i),a.clearWorld(n),f.copyCanvasByWorld(e,s,a),a.recycle(e.__nowWorld)}}(t,e,s)}}function Dt(t,e,s,i){const n=s.__;B(t)?Wt(t,e,!1,s,i):(i.setStroke(t,n.__strokeWidth*e,n),i.stroke()),n.__useArrow&&X.strokeArrow(t,s,i)}Rt.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new ft(t,e),layouter:(t,e)=>new Bt(t,e),renderer:(t,e,s)=>new Rt(t,e,s),selector:(t,e)=>{},interaction:(t,e,s,i)=>{}}),e.layout=Bt.fullLayout,e.render=function(t,e,s){const i=Object.assign(Object.assign({},s),{topRendering:!0});s.topList=new r,t.__render(e,s),s.topList.length&&s.topList.forEach(t=>t.__render(e,i))};const{getSpread:Pt,copyAndSpread:Ft,toOuterOf:It,getOuterOf:Ut,getByMove:Yt,move:Xt,getIntersectData:zt}=k,Nt={};let qt;const{stintSet:jt}=l,{hasTransparent:Gt}=z;function Ht(t,e,s){if(!B(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,!qt||!qt[e.url]);break;case"linear":i=N.linearGradient(e,n);break;case"radial":i=N.radialGradient(e,n);break;case"angular":i=N.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;i={type:a,style:z.string(o,r)};break;default:L(e.r)||(i={type:"solid",style:z.string(e)})}if(i){if(T(i.style)&&Gt(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 Vt={compute:function(t,e){const s=e.__,i=[];let n,a,o,r=s.__input[t];w(r)||(r=[r]),qt=Y.recycleImage(t,s);for(let s,n=0,a=r.length;n<a;n++)(s=Ht(t,r[n],e))&&(i.push(s),s.strokeStyle&&(o||(o=1),s.strokeStyle.strokeWidth&&(o=Math.max(o,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?(jt(s,"__isAlphaPixelFill",n),jt(s,"__isTransparentFill",a)):(jt(s,"__isAlphaPixelStroke",n),jt(s,"__isTransparentStroke",a),jt(s,"__hasMultiStrokeStyle",o))},fill:function(t,e,s){s.fillStyle=t,Lt(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),Lt(e,s),s.restore()}else i.blendMode?(s.saveBlendMode(i.blendMode),Lt(e,s),s.restoreBlendMode()):Lt(e,s)}},fillPathOrText:Lt,fillText:Et,stroke:Mt,strokes:function(t,e,s){Mt(t,e,s)},strokeText:Tt,drawTextStroke:Ct,shape:function(t,s,i){const n=s.getSameCanvas(),a=s.bounds,o=t.__nowWorld,r=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;It(r.strokeSpread?(Ft(Nt,r.boxBounds,r.strokeSpread),Nt):r.boxBounds,o,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,d=f=l,c=o;else{let n;if(e.fullImageShadow)n=l;else{const t=r.renderShapeSpread?Pt(a,R.swapAndScale(r.renderShapeSpread,g,_)):a;n=zt(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=Ut(l,u),d=Yt(f,-u.e,-u.f),c=Ut(o,u),Xt(c,-u.e,-u.f);const y=i.matrix;y?(h=new E(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 Qt={},Jt=A();const{get:Zt,set:$t,rotateOfOuter:Kt,translate:te,scaleOfOuter:ee,multiplyParent:se,scale:ie,rotate:ne,skew:ae}=O;function oe(t,e,s,i){const n=Zt();te(n,e.x,e.y),s&&ie(n,s,i),t.transform=n}function re(t,e,s,i,n,a,o){const r=Zt();te(r,e.x+s,e.y+i),ie(r,n,a),o&&Kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function le(t,e,s,i,n,a,o,r,l,d){const c=Zt();ce(c,e,s,i,n,a,o,r),l&&(o||r?($t(Jt),ee(Jt,e,l,d),se(c,Jt)):ee(c,e,l,d)),t.transform=c}function de(t,e,s,i,n,a,o,r,l,d,c,h){const u=Zt();if(h)ce(u,e,n,a,o,r,l,d);else{if(l)if("center"===c)Kt(u,{x:s/2,y:i/2},l);else switch(ne(u,l),l){case 90:te(u,i,0);break;case 180:te(u,s,i);break;case 270:te(u,0,s)}Qt.x=e.x+n,Qt.y=e.y+a,te(u,Qt.x,Qt.y),o&&ee(u,Qt,o,r)}t.transform=u}function ce(t,e,s,i,n,a,o,r){o&&ne(t,o),r&&ae(t,r.x,r.y),n&&ie(t,n,a),te(t,e.x+s,e.y+i)}const{get:he,translate:ue}=O,fe=new _,pe={},ge={};function _e(t,e,s,i){const{changeful:n,sync:a,scaleFixed:o}=s;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=we(s,i,e)}function we(t,e,s){t.padding&&(e=fe.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:i,height:n}=s;const{opacity:a,mode:o,align:r,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:o},y="center"!==r&&(h||0)%180==90;let v,x;switch(k.set(ge,0,0,y?n:i,y?i:n),o&&"cover"!==o&&"fit"!==o?((d||c)&&(C.getScaleData(d,c,s,pe),v=pe.scaleX,x=pe.scaleY),(r||g||p)&&(v&&k.scale(ge,v,x,!0),r&&W.toPoint(r,ge,e,ge,!0,!0))):w&&!h||(v=x=k.getFitScale(e,ge,"fit"!==o),k.put(e,s,r,v,!1,ge),k.scale(ge,v,x,!0)),l&&M.move(ge,l),o){case"stretch":w||(v=e.width/i,x=e.height/n,oe(m,e,v,x));break;case"normal":case"clip":if(ge.x||ge.y||v||f||h||u){let t,s;f&&(t=e.width/f.width,s=e.height/f.height),le(m,e,ge.x,ge.y,v,x,h,u,t,s),t&&(v=v?v*t:t,x=x?x*s:s)}break;case"repeat":(!w||v||h||u)&&de(m,e,i,n,ge.x,ge.y,v,x,h,u,r,t.freeTransform),p||(m.repeat="repeat");const s=B(p);(g||s)&&(m.gap=function(t,e,s,i,n){let a,o;B(t)?(a=t.x,o=t.y):a=o=t;return{x:me(a,s,n.width,e&&e.x),y:me(o,i,n.height,e&&e.y)}}(g,s&&p,ge.width,ge.height,e));break;default:v&&re(m,e,ge.x,ge.y,v,x,h)}return m.transform||(e.x||e.y)&&ue(m.transform=he(),e.x,e.y),m.width=i,m.height=n,v&&(m.scaleX=v,m.scaleY=x),a&&(m.opacity=a),_&&(m.filters=_),p&&(m.repeat=T(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m}function me(t,e,s,i){const n=T(t)||i?(i?s-i*e:s%e)/((i||Math.floor(s/e))-1):t;return"auto"===t&&n<0?0:n}let ye,ve=new _;const{isSame:xe}=k;function be(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||_e(n,i,s,a),!0}function Se(t,e){Re(t,D.LOAD,e)}function Be(t,e){Re(t,D.LOADED,e)}function ke(t,e,s){e.error=s,t.forceUpdate("surface"),Re(t,D.ERROR,e)}function Re(t,e,s){t.hasEvent(e)&&t.emitEvent(new D(e,s))}function Ee(t,e){const{leafer:s}=t;s&&s.viewReady&&(s.renderer.ignore=e)}const{get:Le,scale:Te,copy:Ae}=O,{floor:Oe,ceil:Ce,max:We,abs:Me}=Math;function De(t,s,i){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,s.scaleFixed);const o=n+"-"+a+"-"+i;if(s.patternId===o||t.destroyed)return!1;{const{image:r,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=Le(),Ae(c,g),Te(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(r.isSVG){const t=h/r.width;t>1&&(d=t/Ce(t))}else{const t=r.width*r.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 v=w&&w.x*n,x=w&&w.y*a;if(g||1!==n||1!==a){const t=h+(v||0),e=u+(x||0);n/=t/We(Oe(t),1),a/=e/We(Oe(e),1),c||(c=Le(),g&&Ae(c,g)),Te(c,1/n,1/a)}const b=r.getCanvas(h,u,l.opacity,l.filters,v,x,t.leafer&&t.leafer.config.smooth),S=r.getPattern(b,_||e.origin.noRepeat||"no-repeat",c,s);return s.style=S,s.patternId=o,!0}}const Pe={image:function(t,e,s,i,n){let a,o;const r=b.get(s);return ye&&s===ye.paint&&xe(i,ye.boxBounds)?a=ye.leafPaint:(a={type:s.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),ye=r.use>1?{leafPaint:a,paint:s,boxBounds:ve.set(i)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:s}),r.ready?(be(t,e,s,r,a,i),n&&(Se(t,o),Be(t,o))):r.error?n&&ke(t,o,r.error):(n&&(Ee(t,!0),Se(t,o)),a.loadId=r.load(()=>{Ee(t,!1),t.destroyed||(be(t,e,s,r,a,i)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Be(t,o)),a.loadId=void 0},e=>{Ee(t,!1),ke(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,s,i,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:r}=s,{data:l}=i;if(!l||i.patternId===a+"-"+o+"-"+r&&!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*r,s*=o*r,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?De(t,i,r):i.patternTask||(i.patternTask=b.patternTasker.add(()=>lt(this,void 0,void 0,function*(){i.patternTask=null,s.bounds.hit(t.__nowWorld)&&De(t,i,r),t.forceUpdate("surface")}),300)),!1)},createPattern:De,recycleImage:function(t,e){const s=e["_"+t];if(w(s)){let i,n,a,o,r;for(let l=0,d=s.length;l<d;l++)i=s[l],n=i.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,b.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],w(o)||(o=[o])),n.unload(s[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:_e,getPatternData:we,stretchMode:oe,fillOrFitMode:re,clipMode:le,repeatMode:de},{toPoint:Fe}=P,{hasTransparent:Ie}=z,Ue={},Ye={};function Xe(t,e,s,i){if(s){let n,a,o,r;for(let t=0,l=s.length;t<l;t++)n=s[t],T(n)?(o=t/(l-1),a=z.string(n,i)):(o=n.offset,a=z.string(n.color,i)),e.addColorStop(o,a),!r&&Ie(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:ze,getDistance:Ne}=M,{get:qe,rotateOfOuter:je,scaleOfOuter:Ge}=O,{toPoint:He}=P,Ve={},Qe={};function Je(t,e,s,i,n){let a;const{width:o,height:r}=t;if(o!==r||i){const t=ze(e,s);a=qe(),n?(Ge(a,e,o/r*(i||1),1),je(a,e,t+90)):(Ge(a,e,1,o/r*(i||1)),je(a,e,t))}return a}const{getDistance:Ze}=M,{toPoint:$e}=P,Ke={},ts={};const es={linearGradient:function(t,s){let{from:i,to:n,type:a,opacity:o}=t;Fe(i||"top",s,Ue),Fe(n||"bottom",s,Ye);const r=e.canvas.createLinearGradient(Ue.x,Ue.y,Ye.x,Ye.y),l={type:a,style:r};return Xe(l,r,t.stops,o),l},radialGradient:function(t,s){let{from:i,to:n,type:a,opacity:o,stretch:r}=t;He(i||"center",s,Ve),He(n||"bottom",s,Qe);const l=e.canvas.createRadialGradient(Ve.x,Ve.y,0,Ve.x,Ve.y,Ne(Ve,Qe)),d={type:a,style:l};Xe(d,l,t.stops,o);const c=Je(s,Ve,Qe,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,s){let{from:i,to:n,type:a,opacity:o,stretch:r}=t;$e(i||"center",s,Ke),$e(n||"bottom",s,ts);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ke.x,Ke.y):e.canvas.createRadialGradient(Ke.x,Ke.y,0,Ke.x,Ke.y,Ze(Ke,ts)),d={type:a,style:l};Xe(d,l,t.stops,o);const c=Je(s,Ke,ts,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Je},{copy:ss,move:is,toOffsetOutBounds:ns}=k,{max:as,abs:os}=Math,rs={},ls=new E,ds={};function cs(t,e){let s,i,n,a,o=0,r=0,l=0,d=0;return e.forEach(t=>{s=t.x||0,i=t.y||0,a=1.5*(t.blur||0),n=os(t.spread||0),o=as(o,n+a-i),r=as(r,n+a+s),l=as(l,n+a+i),d=as(d,n+a-s)}),o===r&&r===l&&l===d?o:[o,r,l,d]}function hs(t,s,i){const{shapeBounds:n}=i;let a,o;e.fullImageShadow?(ss(rs,t.bounds),is(rs,s.x-n.x,s.y-n.y),a=t.bounds,o=rs):(a=n,o=s),t.copyWorld(i.canvas,a,o)}const{toOffsetOutBounds:us}=k,fs={};const ps=cs;const gs={shadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=o.length-1;ns(l,ds,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow(ds.offsetX+(o.x||0)*h*w,ds.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w,z.string(o.color)),n=j.getShadowTransform(t,p,s,o,ds,w),n&&p.setTransform(n),hs(p,ds,s),n&&p.resetTransform(),i=d,o.box&&(p.restore(),p.save(),r&&(p.copyWorld(p,d,a,"copy"),i=a),r?p.copyWorld(r,a,a,"destination-out"):p.copyWorld(s.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,p,i,o.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},innerShadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=o.length-1;us(l,fs,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(fs.offsetX+(o.x||0)*h*w,fs.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w),n=j.getShadowTransform(t,p,s,o,fs,w,!0),n&&p.setTransform(n),hs(p,fs,s),p.restore(),r?(p.copyWorld(p,d,a,"copy"),p.copyWorld(r,a,a,"source-out"),i=a):(p.copyWorld(s.canvas,c,l,"source-out"),i=d),p.fillWorld(i,z.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,p,i,o.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:cs,getShadowTransform:function(t,e,s,i,n,a,o){if(i.spread){const s=2*i.spread*a*(o?-1:1),{width:r,height:l}=t.__layout.strokeBounds;return ls.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+s/r,1+s/l),ls}},isTransformShadow(t){},getInnerShadowSpread:ps},{excludeRenderBounds:_s}=g;let ws;function ms(t,e,s,i,n,a,o,r){switch(e){case"grayscale":ws||(ws=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,s,i,n,a){const o=t.__nowWorld;s.resetTransform(),s.opacity=1,s.useMask(i,o),a&&i.recycle(o);vs(t,e,s,1,n,a)}(t,s,i,n,o,r);break;case"opacity-path":vs(t,s,i,a,o,r);break;case"path":r&&s.restore()}}function ys(t){return t.getSameCanvas(!1,!0)}function vs(t,e,s,i,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(s,o,void 0,n),a?s.recycle(o):s.clearWorld(o)}G.prototype.__renderMask=function(t,e){let s,i,n,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(s=l[d],r=s.__.mask,r){o&&(ms(this,o,t,n,i,a,void 0,!0),i=n=null),"clipping"!==r&&"clipping-path"!==r||_s(s,e)||s.__render(t,e),a=s.__.opacity,ws=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=ys(t))):(o="path",t.save()),s.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=ys(t)),n||(n=ys(t)),s.__render(i,e));continue}const c=1===a&&s.__.__blendMode;c&&ms(this,o,t,n,i,a,void 0,!1),_s(s,e)||s.__render(n||t,e),c&&ms(this,o,t,n,i,a,c,!1)}ms(this,o,t,n,i,a,void 0,!0)};const xs=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",bs=xs+"_#~&*+\\=|≮≯≈≠=…",Ss=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 Bs(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ks=Bs("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Rs=Bs("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Es=Bs(xs),Ls=Bs(bs),Ts=Bs("- —/~|┆·");var As;!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"}(As||(As={}));const{Letter:Os,Single:Cs,Before:Ws,After:Ms,Symbol:Ds,Break:Ps}=As;function Fs(t){return ks[t]?Os:Ts[t]?Ps:Rs[t]?Ws:Es[t]?Ms:Ls[t]?Ds:Ss.test(t)?Cs:Os}const Is={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 Us(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:Ys}=Is,{Letter:Xs,Single:zs,Before:Ns,After:qs,Symbol:js,Break:Gs}=As;let Hs,Vs,Qs,Js,Zs,$s,Ks,ti,ei,si,ii,ni,ai,oi,ri,li,di,ci=[];function hi(t,e){ei&&!ti&&(ti=ei),Hs.data.push({char:t,width:e}),Qs+=e}function ui(){Js+=Qs,Hs.width=Qs,Vs.words.push(Hs),Hs={data:[]},Qs=0}function fi(){oi&&(ri.paraNumber++,Vs.paraStart=!0,oi=!1),ei&&(Vs.startCharSize=ti,Vs.endCharSize=ei,ti=0),Vs.width=Js,li.width?Ys(Vs):di&&pi(),ci.push(Vs),Vs={words:[]},Js=0}function pi(){Js>(ri.maxWidth||0)&&(ri.maxWidth=Js)}const{top:gi,right:_i,bottom:wi,left:mi}=F;function yi(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 vi={getDrawData:function(t,s){T(t)||(t=String(t));let i=0,n=0,a=s.__getInput("width")||0,o=s.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=s;d&&(a?(i=d[mi],a-=d[_i]+d[mi]):s.autoSizeAlign||(i=d[mi]),o?(n=d[gi],o-=d[gi]+d[wi]):s.autoSizeAlign||(n=d[gi]));const c={bounds:{x:i,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,s,i){ri=t,ci=t.rows,li=t.bounds,di=!li.width&&!i.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=i,{canvas:r}=e,{width:l,height:d}=li;if(l||d||n||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;oi=!0,ii=null,ti=Ks=ei=Qs=Js=0,Hs={data:[]},Vs={words:[]},n&&(s=[...s]);for(let i=0,d=s.length;i<d;i++)$s=s[i],"\n"===$s?(Qs&&ui(),Vs.paraEnd=!0,fi(),oi=!0):(si=Fs($s),si===Xs&&"none"!==o&&($s=Us($s,o,!Qs)),Ks=r.measureText($s).width,n&&(n<0&&(ei=Ks),Ks+=n),ni=si===zs&&(ii===zs||ii===Xs)||ii===zs&&si!==qs,ai=!(si!==Ns&&si!==zs||ii!==js&&ii!==qs),Zs=oi&&a?l-a:l,t&&l&&Js+Qs+Ks>Zs&&(e?(Qs&&ui(),Js&&fi()):(ai||(ai=si===Xs&&ii==qs),ni||ai||si===Gs||si===Ns||si===zs||Qs+Ks>Zs?(Qs&&ui(),Js&&fi()):Js&&fi()))," "===$s&&!0!==oi&&Js+Qs===0||(si===Gs?(" "===$s&&Qs&&ui(),hi($s,Ks),ui()):ni||ai?(Qs&&ui(),hi($s,Ks)):hi($s,Ks)),ii=si);Qs&&ui(),Js&&fi(),ci.length>0&&(ci[ci.length-1].paraEnd=!0)}else s.split("\n").forEach(t=>{ri.paraNumber++,Js=r.measureText(t).width,ci.push({x:a||0,text:t,width:Js,paraStart:!0}),di&&pi()})}(c,t,s),d&&function(t,e,s,i,n){if(!i&&s.autoSizeAlign)switch(s.textAlign){case"left":yi(e,"x",t[mi]);break;case"right":yi(e,"x",-t[_i])}if(!n&&s.autoSizeAlign)switch(s.verticalAlign){case"top":yi(e,"y",t[gi]);break;case"bottom":yi(e,"y",-t[wi])}}(d,c,s,a,o),function(t,e){const{rows:s,bounds:i}=t,n=s.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__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=o;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,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=n;o<c;o++){if(y=s[o],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&&o>0&&(m+=h),y.y=m,m+=a,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(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:o}=e;let r,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=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(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,r=t.x,t.data=[],t.words.forEach((e,s)=>{1===c?(h={char:"",x:r},r=function(t,e,s){return t.forEach(t=>{s.char+=t.char,e+=t.width}),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,s,i){return t.forEach(t=>{(i||" "!==t.char)&&(t.x=e,s.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||s===u-1||(r+=l,t.width+=l)})),t.words=null)})}(c,s,a),c.overflow&&function(t,s,i,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=s;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=i+n-d;("none"===s.textWrap?a:[a[o-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:r,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"!==r&&function(t,e){let s,i=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,B(a)?(s=a.type,a.color&&(t.decorationColor=z.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 xi={string:function(t,e){if(!t)return"#000";const s=I(e)&&e<1;if(T(t)){if(!s||!z.object)return t;t=z.object(t)}let i=L(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(H,vi),Object.assign(z,xi),Object.assign(X,Vt),Object.assign(Y,Pe),Object.assign(N,es),Object.assign(j,gs);const{setPoint:bi,addPoint:Si,toBounds:Bi}=V;const ki={syncExport(t,e,s){let i;q.running=!0;try{const n=J.fileType(e),a=e.includes(".");s=J.getExportOptions(s);const{toURL:o}=Z,{download:r}=Z.origin;if("json"===n)a&&r(o(JSON.stringify(t.toJSON(s.json)),"text"),e),i={data:!!a||t.toJSON(s.json)};else if("svg"===n)a&&r(o(t.toSVG(),"svg"),e),i={data:!!a||t.toSVG()};else{let n,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=s,m=$(s.smooth)?!c||c.config.smooth:s.smooth,y=s.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&$(s.fill)?t.fill:s.fill,x=J.isOpaqueImage(e)||v,b=new K;if(g)n=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=s.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const s=e.worldTransform;o/=o/s.scaleX,r/=r/s.scaleY}n=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};tt.getScaleData(s.scale,s.size,n,S);let B=s.pixelRatio||1,{x:k,y:R,width:E,height:L}=new Q(n).scale(S.scaleX,S.scaleY);f&&(k+=f.x,R+=f.y,E=f.width,L=f.height);const T={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-k,-R).withScale(1/o*S.scaleX,1/r*S.scaleY)};let A,O=et.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:B,smooth:m,contextSettings:y});u&&(A=t,A.__worldOpacity=0,t=c||t,T.bounds=O.bounds),O.save();const C=h&&!$(v),W=t.get("fill");if(C&&(t.fill=""),Z.render(t,O,T),C&&(t.fill=W),O.restore(),A&&A.__updateWorldOpacity(),p){a=function(t){const{width:e,height:s}=t.view,{data:i}=t.context.getImageData(0,0,e,s);let n,a,o,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(n=r%e,a=(r-n)/e,o?Si(o,n,a):bi(o={},n,a)),r++;const l=new Q;return o&&(Bi(o,l),l.scale(1/t.pixelRatio).ceil()),l}(O);const t=O,{width:e,height:s}=a,i={x:0,y:0,width:e,height:s,pixelRatio:B};O=et.canvas(i),O.copyWorld(t,a,i),t.destroy()}if(_){const[t,e,s,i]=tt.fourNumber(_),n=O,{width:a,height:o}=n;O=et.canvas({width:a+i+e,height:o+t+s,pixelRatio:B}),O.copyWorld(n,n.bounds,{x:i,y:t,width:a,height:o}),n.destroy()}x&&O.fillWorld(O.bounds,v||"#FFFFFF","destination-over"),w&&w(O);i={data:"canvas"===e?O:O.export(e,s),width:O.pixelWidth,height:O.pixelHeight,renderBounds:n,trimBounds:a};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){i={data:"",error:t}}return q.running=!1,i},export(t,e,s){return q.running=!0,function(t){Ri||(Ri=new st);return new Promise(e=>{Ri.add(()=>lt(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(i=>new Promise(n=>{const a=()=>lt(this,void 0,void 0,function*(){if(!it.isComplete)return Z.requestRender(a);const o=q.syncExport(t,e,s);o.data instanceof Promise&&(o.data=yield o.data),i(o),n()});t.updateLayout(),Ei(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))}};let Ri;function Ei(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Ei(t))}const Li=nt.prototype,Ti=at.get("@leafer-in/export");Li.export=function(t,e){const{quality:s,blob:i}=J.getExportOptions(e);return t.includes(".")?this.saveAs(t,s):i?this.toBlob(t,s):this.toDataURL(t,s)},Li.toBlob=function(t,e){return new Promise(s=>{Z.origin.canvasToBolb(this.view,t,e).then(t=>{s(t)}).catch(t=>{Ti.error(t),s(null)})})},Li.toDataURL=function(t,e){return Z.origin.canvasToDataURL(this.view,t,e)},Li.saveAs=function(t,e){return new Promise(s=>{Z.origin.canvasSaveAs(this.view,t,e).then(()=>{s(!0)}).catch(t=>{Ti.error(t),s(!1)})})},ot.add("export"),Object.assign(q,ki),rt.prototype.export=function(t,e){return q.export(this,t,e)},rt.prototype.syncExport=function(t,e){return q.syncExport(this,t,e)};export{Bt as Layouter,dt as LeaferCanvas,Rt as Renderer,ft as Watcher,ut as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as a,FileHelper as s,Creator as i,LeaferImage as n,defineKey as o,LeafList as r,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 v,Run as x,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as R,Matrix as E,isUndefined as T,isString as L,ImageEvent as A,MatrixHelper as O,MathHelper as M,AlignHelper as C,PointHelper as W,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{writeFileSync as Y}from"fs";import{Paint as U,PaintImage as X,ColorConvert as N,PaintGradient as q,Effect as z,Group as j,TextConvert as G,TwoPointBoundsHelper as H,Bounds as V,Export as Q,FileHelper as J,Platform as Z,isUndefined as $,Matrix as K,MathHelper as tt,Creator as et,TaskProcessor as at,Resource as st,LeaferCanvasBase as it,Debug as nt,Plugin as ot,UI as rt}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function lt(t,e,a,s){return new(a||(a=Promise))(function(i,n){function o(t){try{l(s.next(t))}catch(t){n(t)}}function r(t){try{l(s.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof a?e:new a(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class dt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,a(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:a}=this;this.view.width=Math.ceil(t*a),this.view.height=Math.ceil(e*a),this.clientBounds=this.bounds}}const{mineType:ct,fileType:ht}=s;function ut(t,a){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=a;e.origin={createCanvas:(e,a,s)=>new t(e,a,s),canvasToDataURL:(t,e,a)=>t.toDataURLSync(e,{quality:a}),canvasToBolb:(t,e,a)=>t.toBuffer(e,{quality:a}),canvasSaveAs:(t,e,a)=>t.saveAs(e,{quality:a}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=a;e.origin={createCanvas:(e,a,s)=>new t(e,a,s),canvasToDataURL:(t,e,a)=>t.toDataURL(ct(e),a),canvasToBolb:(t,e,a)=>lt(this,void 0,void 0,function*(){return t.toBuffer(ct(e),a)}),canvasSaveAs:(t,e,a)=>lt(this,void 0,void 0,function*(){return Y(e,t.toBuffer(ct(ht(e)),a))}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=i.canvas()}}Object.assign(i,{canvas:(t,e)=>new dt(t,e),image:t=>new n(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ft{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,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,a=e.length;t<a;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,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:pt,updateBounds:gt,updateChange:_t}=f,{pushAllChildBranch:wt,pushAllParent:mt}=p;const{worldBounds:yt}=g;class vt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,yt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,yt),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:xt,updateAllChange:St}=f,bt=m.get("Layouter");class kt{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(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){bt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?bt.warn("layouting"):this.times>3?bt.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=x.start("PartLayout"),{target:a,__updatedList:s}=this,{BEFORE:i,LAYOUT:n,AFTER:o}=v,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),a.emitEvent(new v(i,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let a;t.list.forEach(t=>{a=t.__layout,e.without(t)&&!a.proxyZoom&&(a.matrixChanged?(pt(t,!0),e.add(t),t.isBranch&&wt(t,e),mt(t,e)):a.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),mt(t,e)))})}(s,this.__levelList),function(t){let e,a,s;t.sort(!0),t.levels.forEach(i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(a=e[t],a.isBranch&&a.__tempNumber){s=a.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||gt(s[t])}gt(a)}})}(this.__levelList),function(t){t.list.forEach(_t)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),a.emitEvent(new v(n,r,this.times)),a.emitEvent(new v(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:a,LAYOUT:s,AFTER:i}=v,n=this.getBlocks(new r(e));e.emitEvent(new v(a,n,this.times)),kt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new v(s,n,this.times)),e.emitEvent(new v(i,n,this.times)),this.addBlocks(n),x.end(t)}static fullLayout(t){xt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),St(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:a}=this.extraBlock||(this.extraBlock=new vt([]));e.length?a.add(t.__world):a.set(t.__world),e.add(t)}}createBlock(t){return new vt(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_([[v.REQUEST,this.layout,this],[v.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 Bt=m.get("Renderer");class Rt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,a&&(this.config=l.default(a,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(v.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 _,Bt.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,Bt.error(t)}Bt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Bt.warn("rendering");if(this.times>3)return Bt.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=x.start("PartRender"),{canvas:a}=this,s=t.getIntersect(a.bounds),i=new _(s);a.save(),s.spread(Rt.clipSpread).ceil(),a.clearWorld(s),a.clipWorld(s),this.__render(s,i),a.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,a){const{canvas:s}=this,i=t.includes(this.target.__world),n=i?{includes:i}:{bounds:t,includes:i};this.needFill&&s.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(s,t),e.render(this.target,s,n),this.renderBounds=a=a||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=a:this.totalBounds.add(a),s.updateRender(a)}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 a=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(a);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(a)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:a}=t.old;if(!new _(0,0,e,a).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||Bt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,a){this.target.emitEvent(new d(t,this.times,e,a))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[v.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 Et(t,e,a){t.__.__font?U.fillText(t,e,a):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,a,s,i){const n=a.__;k(t)?U.drawStrokesStyle(t,e,!1,a,s,i):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&U.strokeArrow(t,a,s,i)}function Lt(t,e,a,s,i){const n=a.__;k(t)?U.drawStrokesStyle(t,e,!0,a,s,i):(s.setStroke(t,n.__strokeWidth*e,n),U.drawTextStroke(a,s,i))}function At(t,e,a,s,i){const n=s.getSameCanvas(!0,!0);n.font=a.__.__font,Lt(t,2,a,n,i),n.blendMode="outside"===e?"destination-out":"destination-in",U.fillText(a,n,i),n.blendMode="normal",f.copyCanvasByWorld(a,s,n),n.recycle(a.__nowWorld)}Rt.clipSpread=10,Object.assign(i,{watcher:(t,e)=>new ft(t,e),layouter:(t,e)=>new kt(t,e),renderer:(t,e,a)=>new Rt(t,e,a),selector:(t,e)=>{},interaction:(t,e,a,s)=>{}}),e.layout=kt.fullLayout,e.render=function(t,e,a){const s=Object.assign(Object.assign({},a),{topRendering:!0});a.topList=new r,t.__render(e,a),a.topList.length&&a.topList.forEach(t=>t.__render(e,s))};const{getSpread:Ot,copyAndSpread:Mt,toOuterOf:Ct,getOuterOf:Wt,getByMove:Dt,move:Pt,getIntersectData:It}=B,Ft={};let Yt;const{stintSet:Ut}=l,{hasTransparent:Xt}=N;function Nt(t,e,a){if(!k(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:i}=a.__layout;switch(e.type){case"image":s=X.image(a,t,e,i,!Yt||!Yt[e.url]);break;case"linear":s=q.linearGradient(e,i);break;case"radial":s=q.radialGradient(e,i);break;case"angular":s=q.conicGradient(e,i);break;case"solid":const{type:n,color:o,opacity:r}=e;s={type:n,style:N.string(o,r)};break;default:T(e.r)||(s={type:"solid",style:N.string(e)})}if(s){if(L(s.style)&&Xt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const qt={compute:function(t,e){const a=e.__,s=[];let i,n,o,r=a.__input[t];w(r)||(r=[r]),Yt=X.recycleImage(t,a);for(let a,i=0,n=r.length;i<n;i++)(a=Nt(t,r[i],e))&&(s.push(a),a.strokeStyle&&(o||(o=1),a.strokeStyle.strokeWidth&&(o=Math.max(o,a.strokeStyle.strokeWidth))));a["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(i=!0),n=!0),"fill"===t?(Ut(a,"__isAlphaPixelFill",i),Ut(a,"__isTransparentFill",n)):(Ut(a,"__isAlphaPixelStroke",i),Ut(a,"__isTransparentStroke",n),Ut(a,"__hasMultiStrokeStyle",o))},fill:function(t,e,a,s){a.fillStyle=t,Et(e,a,s)},fills:function(t,e,a,s){let i;for(let n=0,o=t.length;n<o;n++){if(i=t[n],i.image){if(X.checkImage(i,!e.__.__font,e,a,s))continue;if(!i.style){!n&&i.image.isPlacehold&&e.drawImagePlaceholder(i.image,a,s);continue}}if(a.fillStyle=i.style,i.transform||i.scaleFixed){if(a.save(),i.transform&&a.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&s>1)&&a.scale(1/t,1/s)}i.blendMode&&(a.blendMode=i.blendMode),Et(e,a,s),a.restore()}else i.blendMode?(a.saveBlendMode(i.blendMode),Et(e,a,s),a.restoreBlendMode()):Et(e,a,s)}},fillPathOrText:Et,fillText:function(t,e,a){const s=t.__,{rows:i,decorationY:n}=s.__textDrawData;let o;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,a=i.length;t<a;t++)o=i[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.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)))}},stroke:function(t,e,a,s){const i=e.__;if(i.__strokeWidth)if(i.__font)U.strokeText(t,e,a,s);else switch(i.strokeAlign){case"center":Tt(t,1,e,a,s);break;case"inside":!function(t,e,a,s){a.save(),a.clipUI(e),Tt(t,2,e,a,s),a.restore()}(t,e,a,s);break;case"outside":!function(t,e,a,s){const i=e.__;if(i.__fillAfterStroke)Tt(t,2,e,a,s);else{const{renderBounds:n}=e.__layout,o=a.getSameCanvas(!0,!0);e.__drawRenderPath(o),Tt(t,2,e,o,s),o.clipUI(i),o.clearWorld(n),f.copyCanvasByWorld(e,a,o),o.recycle(e.__nowWorld)}}(t,e,a,s)}},strokes:function(t,e,a,s){U.stroke(t,e,a,s)},strokeText:function(t,e,a,s){switch(e.__.strokeAlign){case"center":Lt(t,1,e,a,s);break;case"inside":At(t,"inside",e,a,s);break;case"outside":e.__.__fillAfterStroke?Lt(t,2,e,a,s):At(t,"outside",e,a,s)}},drawTextStroke:function(t,e,a){let s,i=t.__.__textDrawData;const{rows:n,decorationY:o}=i;for(let t=0,a=n.length;t<a;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(o){const{decorationHeight:t}=i;n.forEach(a=>o.forEach(s=>e.strokeRect(a.x,a.y+s,a.width,t)))}},drawStrokesStyle:function(t,e,a,s,i,n){let o;const r=s.__,{__hasMultiStrokeStyle:l}=r;l||i.setStroke(void 0,r.__strokeWidth*e,r);for(let d=0,c=t.length;d<c;d++)if(o=t[d],(!o.image||!X.checkImage(o,!1,s,i,n))&&o.style){if(l){const{strokeStyle:t}=o;t?i.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):i.setStroke(o.style,r.__strokeWidth*e,r)}else i.strokeStyle=o.style;o.blendMode?(i.saveBlendMode(o.blendMode),a?U.drawTextStroke(s,i,n):i.stroke(),i.restoreBlendMode()):a?U.drawTextStroke(s,i,n):i.stroke()}},shape:function(t,a,s){const i=a.getSameCanvas(),n=a.bounds,o=t.__nowWorld,r=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;Ct(r.strokeSpread?(Mt(Ft,r.boxBounds,r.strokeSpread),Ft):r.boxBounds,o,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))p=i,d=f=l,c=o;else{let i;if(e.fullImageShadow)i=l;else{const t=r.renderShapeSpread?Ot(n,R.swapAndScale(r.renderShapeSpread,g,_)):n;i=It(t,l)}u=n.getFitMatrix(i);let{a:w,d:m}=u;u.a<1&&(p=a.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=Wt(l,u),d=Dt(f,-u.e,-u.f),c=Wt(o,u),Pt(c,-u.e,-u.f);const y=s.matrix;y?(h=new E(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(i,s),{canvas:i,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let zt,jt=new _;const{isSame:Gt}=B;function Ht(t,e,a,s,i,n){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||X.createData(i,s,a,n),!0}function Vt(t,e){Zt(t,A.LOAD,e)}function Qt(t,e){Zt(t,A.LOADED,e)}function Jt(t,e,a){e.error=a,t.forceUpdate("surface"),Zt(t,A.ERROR,e)}function Zt(t,e,a){t.hasEvent(e)&&t.emitEvent(new A(e,a))}function $t(t,e){const{leafer:a}=t;a&&a.viewReady&&(a.renderer.ignore=e)}const{get:Kt,translate:te}=O,ee=new _,ae={},se={};function ie(t,e,a,s){const i=L(t)||s?(s?a-s*e:a%e)/((s||Math.floor(a/e))-1):t;return"auto"===t&&i<0?0:i}let ne={},oe=D();const{get:re,set:le,rotateOfOuter:de,translate:ce,scaleOfOuter:he,multiplyParent:ue,scale:fe,rotate:pe,skew:ge}=O;function _e(t,e,a,s,i,n,o,r){o&&pe(t,o),r&&ge(t,r.x,r.y),i&&fe(t,i,n),ce(t,e.x+a,e.y+s)}const{get:we,scale:me,copy:ye}=O,{getFloorScale:ve}=M,{abs:xe}=Math;const Se={image:function(t,e,a,s,i){let n,o;const r=S.get(a);return zt&&a===zt.paint&&Gt(s,zt.boxBounds)?n=zt.leafPaint:(n={type:a.type,image:r},r.hasAlphaPixel&&(n.isTransparent=!0),zt=r.use>1?{leafPaint:n,paint:a,boxBounds:jt.set(s)}:null),(i||r.loading)&&(o={image:r,attrName:e,attrValue:a}),r.ready?(Ht(t,e,a,r,n,s),i&&(Vt(t,o),Qt(t,o))):r.error?i&&Jt(t,o,r.error):(i&&($t(t,!0),Vt(t,o)),n.loadId=r.load(()=>{$t(t,!1),t.destroyed||(Ht(t,e,a,r,n,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Qt(t,o)),n.loadId=void 0},e=>{$t(t,!1),Jt(t,o,e),n.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),n},checkImage:function(t,a,s,i,n){const{scaleX:o,scaleY:r}=X.getImageRenderScaleData(t,s,i,n),{image:l,data:d}=t,{exporting:c}=n;return!(!d||t.patternId===o+"-"+r&&!c)&&(a&&(d.repeat?a=!1:t.changeful||"miniapp"===e.name&&b.isResizing(s)||c||(a=e.image.isLarge(l,o,r))),a?(s.__.__isFastShadow&&(i.fillStyle=t.style||"#000",i.fill()),X.drawImage(t,o,r,s,i,n),!0):(!t.style||t.sync||c?X.createPattern(t,s,i,n):X.createPatternTask(t,s,i,n),!1))},drawImage:function(t,e,a,s,i,n){const{data:o,image:r,blendMode:l}=t,{opacity:d,transform:c}=o,h=r.getFull(o.filters),u=s.__;let f,{width:p,height:g}=r;c&&!c.onlyScale||(f=u.path||u.cornerRadius)||d||l?(i.save(),f&&i.clipUI(s),l&&(i.blendMode=l),d&&(i.opacity*=d),c&&i.transform(c),i.drawImage(h,0,0,p,g),i.restore()):(o.scaleX&&(p*=o.scaleX,g*=o.scaleY),i.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,a,s){const i=e.getRenderScaleData(!0,t.scaleFixed),{data:n}=t;if(a){const{pixelRatio:t}=a;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 a=e["_"+t];if(w(a)){let s,i,n,o,r;for(let l=0,d=a.length;l<d;l++)s=a[l],i=s.image,r=i&&i.url,r&&(n||(n={}),n[r]=!0,S.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],w(o)||(o=[o])),i.unload(a[l].loadId,!o.some(t=>t.url===r))));return n}return null},createPatternTask:function(t,e,a,s){t.patternTask||(t.patternTask=S.patternTasker.add(()=>lt(this,void 0,void 0,function*(){t.patternTask=null,a.bounds.hit(e.__nowWorld)&&X.createPattern(t,e,a,s),e.forceUpdate("surface")}),300))},createPattern:function(t,a,s,i){let{scaleX:n,scaleY:o}=X.getImageRenderScaleData(t,a,s,i),r=n+"-"+o;if(t.patternId!==r&&!a.destroyed&&(!e.image.isLarge(t.image,n,o)||t.data.repeat)){const{image:s,data:i}=t,{transform:l,gap:d}=i,c=X.getPatternFixScale(t,n,o);let h,u,f,{width:p,height:g}=s;c&&(n*=c,o*=c),p*=n,g*=o,d&&(u=d.x*n/xe(i.scaleX||1),f=d.y*o/xe(i.scaleY||1)),(l||1!==n||1!==o)&&(n*=ve(p+(u||0)),o*=ve(g+(f||0)),h=we(),l&&ye(h,l),me(h,1/n,1/o));const _=s.getCanvas(p,g,i.opacity,i.filters,u,f,a.leafer&&a.leafer.config.smooth),w=s.getPattern(_,i.repeat||e.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=r}},getPatternFixScale:function(t,a,s){const{image:i}=t;let n,o=e.image.maxPatternSize,r=i.width*i.height;return i.isSVG?a>1&&(n=Math.ceil(a)/a):o>r&&(o=r),(r*=a*s)>o&&(n=Math.sqrt(o/r)),n},createData:function(t,e,a,s){const{changeful:i,sync:n,scaleFixed:o}=a;i&&(t.changeful=i),n&&(t.sync=n),o&&(t.scaleFixed=o),t.data=X.getPatternData(a,s,e)},getPatternData:function(t,e,a){t.padding&&(e=ee.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:i}=a,{opacity:n,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===s&&e.height===i,m={mode:o},y="center"!==r&&(h||0)%180==90;let v,x;switch(B.set(se,0,0,y?i:s,y?s:i),o&&"cover"!==o&&"fit"!==o?((d||c)&&(M.getScaleData(d,c,a,ae),v=ae.scaleX,x=ae.scaleY),(r||g||p)&&(v&&B.scale(se,v,x,!0),r&&C.toPoint(r,se,e,se,!0,!0))):w&&!h||(v=x=B.getFitScale(e,se,"fit"!==o),B.put(e,a,r,v,!1,se),B.scale(se,v,x,!0)),l&&W.move(se,l),o){case"stretch":w?v&&(v=x=void 0):(v=e.width/s,x=e.height/i,X.stretchMode(m,e,v,x));break;case"normal":case"clip":if(se.x||se.y||v||f||h||u){let t,a;f&&(t=e.width/f.width,a=e.height/f.height),X.clipMode(m,e,se.x,se.y,v,x,h,u,t,a),t&&(v=v?v*t:t,x=x?x*a:a)}break;case"repeat":(!w||v||h||u)&&X.repeatMode(m,e,s,i,se.x,se.y,v,x,h,u,r,t.freeTransform),p||(m.repeat="repeat");const a=k(p);(g||a)&&(m.gap=function(t,e,a,s,i){let n,o;k(t)?(n=t.x,o=t.y):n=o=t;return{x:ie(n,a,i.width,e&&e.x),y:ie(o,s,i.height,e&&e.y)}}(g,a&&p,se.width,se.height,e));break;default:v&&X.fillOrFitMode(m,e,se.x,se.y,v,x,h)}return m.transform||(e.x||e.y)&&te(m.transform=Kt(),e.x,e.y),v&&(m.scaleX=v,m.scaleY=x),n&&n<1&&(m.opacity=n),_&&(m.filters=_),p&&(m.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m},stretchMode:function(t,e,a,s){const i=re(),{x:n,y:o}=e;n||o?ce(i,n,o):i.onlyScale=!0,fe(i,a,s),t.transform=i},fillOrFitMode:function(t,e,a,s,i,n,o){const r=re();ce(r,e.x+a,e.y+s),fe(r,i,n),o&&de(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r},clipMode:function(t,e,a,s,i,n,o,r,l,d){const c=re();_e(c,e,a,s,i,n,o,r),l&&(o||r?(le(oe),he(oe,e,l,d),ue(c,oe)):he(c,e,l,d)),t.transform=c},repeatMode:function(t,e,a,s,i,n,o,r,l,d,c,h){const u=re();if(h)_e(u,e,i,n,o,r,l,d);else{if(l)if("center"===c)de(u,{x:a/2,y:s/2},l);else switch(pe(u,l),l){case 90:ce(u,s,0);break;case 180:ce(u,a,s);break;case 270:ce(u,0,a)}ne.x=e.x+i,ne.y=e.y+n,ce(u,ne.x,ne.y),o&&he(u,ne,o,r)}t.transform=u}},{toPoint:be}=P,{hasTransparent:ke}=N,Be={},Re={};function Ee(t,e,a,s){if(a){let i,n,o,r;for(let t=0,l=a.length;t<l;t++)i=a[t],L(i)?(o=t/(l-1),n=N.string(i,s)):(o=i.offset,n=N.string(i.color,s)),e.addColorStop(o,n),!r&&ke(n)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Te,getDistance:Le}=W,{get:Ae,rotateOfOuter:Oe,scaleOfOuter:Me}=O,{toPoint:Ce}=P,We={},De={};function Pe(t,e,a,s,i){let n;const{width:o,height:r}=t;if(o!==r||s){const t=Te(e,a);n=Ae(),i?(Me(n,e,o/r*(s||1),1),Oe(n,e,t+90)):(Me(n,e,1,o/r*(s||1)),Oe(n,e,t))}return n}const{getDistance:Ie}=W,{toPoint:Fe}=P,Ye={},Ue={};const Xe={linearGradient:function(t,a){let{from:s,to:i,type:n,opacity:o}=t;be(s||"top",a,Be),be(i||"bottom",a,Re);const r=e.canvas.createLinearGradient(Be.x,Be.y,Re.x,Re.y),l={type:n,style:r};return Ee(l,r,t.stops,o),l},radialGradient:function(t,a){let{from:s,to:i,type:n,opacity:o,stretch:r}=t;Ce(s||"center",a,We),Ce(i||"bottom",a,De);const l=e.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Le(We,De)),d={type:n,style:l};Ee(d,l,t.stops,o);const c=Pe(a,We,De,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,a){let{from:s,to:i,type:n,opacity:o,stretch:r}=t;Fe(s||"center",a,Ye),Fe(i||"bottom",a,Ue);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ye.x,Ye.y):e.canvas.createRadialGradient(Ye.x,Ye.y,0,Ye.x,Ye.y,Ie(Ye,Ue)),d={type:n,style:l};Ee(d,l,t.stops,o);const c=Pe(a,Ye,Ue,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Pe},{copy:Ne,move:qe,toOffsetOutBounds:ze}=B,{max:je,abs:Ge}=Math,He={},Ve=new E,Qe={};function Je(t,e){let a,s,i,n,o=0,r=0,l=0,d=0;return e.forEach(t=>{a=t.x||0,s=t.y||0,n=1.5*(t.blur||0),i=Ge(t.spread||0),o=je(o,i+n-s),r=je(r,i+n+a),l=je(l,i+n+s),d=je(d,i+n-a)}),o===r&&r===l&&l===d?o:[o,r,l,d]}function Ze(t,a,s){const{shapeBounds:i}=s;let n,o;e.fullImageShadow?(Ne(He,t.bounds),qe(He,a.x-i.x,a.y-i.y),n=t.bounds,o=He):(n=i,o=a),t.copyWorld(s.canvas,n,o)}const{toOffsetOutBounds:$e}=B,Ke={};const ta=Je;const ea={shadow:function(t,e,a){let s,i;const{__nowWorld:n}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=a,p=e.getSameCanvas(),g=o.length-1;ze(l,Qe,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Qe.offsetX+(o.x||0)*h*w,Qe.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w,N.string(o.color)),i=z.getShadowTransform(t,p,a,o,Qe,w),i&&p.setTransform(i),Ze(p,Qe,a),i&&p.resetTransform(),s=d,o.box&&(p.restore(),p.save(),r&&(p.copyWorld(p,d,n,"copy"),s=n),r?p.copyWorld(r,n,n,"destination-out"):p.copyWorld(a.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,a){let s,i;const{__nowWorld:n}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=a,p=e.getSameCanvas(),g=o.length-1;$e(l,Ke,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(Ke.offsetX+(o.x||0)*h*w,Ke.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w),i=z.getShadowTransform(t,p,a,o,Ke,w,!0),i&&p.setTransform(i),Ze(p,Ke,a),p.restore(),r?(p.copyWorld(p,d,n,"copy"),p.copyWorld(r,n,n,"source-out"),s=n):(p.copyWorld(a.canvas,c,l,"source-out"),s=d),p.fillWorld(s,N.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},blur:function(t,e,a){const{blur:s}=t.__;a.setWorldBlur(s*t.__nowWorld.a),a.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),a.filter="none"},backgroundBlur:function(t,e,a){},getShadowRenderSpread:Je,getShadowTransform:function(t,e,a,s,i,n,o){if(s.spread){const a=2*s.spread*n*(o?-1:1),{width:r,height:l}=t.__layout.strokeBounds;return Ve.set().scaleOfOuter({x:(i.x+i.width/2)*e.pixelRatio,y:(i.y+i.height/2)*e.pixelRatio},1+a/r,1+a/l),Ve}},isTransformShadow(t){},getInnerShadowSpread:ta},{excludeRenderBounds:aa}=g;let sa;function ia(t,e,a,s,i,n,o,r){switch(e){case"grayscale":sa||(sa=!0,i.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,a,s,i,n){const o=t.__nowWorld;a.resetTransform(),a.opacity=1,a.useMask(s,o),n&&s.recycle(o);oa(t,e,a,1,i,n)}(t,a,s,i,o,r);break;case"opacity-path":oa(t,a,s,n,o,r);break;case"path":r&&a.restore()}}function na(t){return t.getSameCanvas(!1,!0)}function oa(t,e,a,s,i,n){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(a,o,void 0,i),n?a.recycle(o):a.clearWorld(o)}j.prototype.__renderMask=function(t,e){let a,s,i,n,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(a=l[d],r=a.__.mask,r){o&&(ia(this,o,t,i,s,n,void 0,!0),s=i=null),"clipping"!==r&&"clipping-path"!==r||aa(a,e)||a.__render(t,e),n=a.__.opacity,sa=!1,"path"===r||"clipping-path"===r?(n<1?(o="opacity-path",i||(i=na(t))):(o="path",t.save()),a.__clip(i||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=na(t)),i||(i=na(t)),a.__render(s,e));continue}const c=1===n&&a.__.__blendMode;c&&ia(this,o,t,i,s,n,void 0,!1),aa(a,e)||a.__render(i||t,e),c&&ia(this,o,t,i,s,n,c,!1)}ia(this,o,t,i,s,n,void 0,!0)};const ra=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",la=ra+"_#~&*+\\=|≮≯≈≠=…",da=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 ca(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ha=ca("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ua=ca("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fa=ca(ra),pa=ca(la),ga=ca("- —/~|┆·");var _a;!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"}(_a||(_a={}));const{Letter:wa,Single:ma,Before:ya,After:va,Symbol:xa,Break:Sa}=_a;function ba(t){return ha[t]?wa:ga[t]?Sa:ua[t]?ya:fa[t]?va:pa[t]?xa:da.test(t)?ma:wa}const ka={trimRight(t){const{words:e}=t;let a,s=0,i=e.length;for(let n=i-1;n>-1&&(a=e[n].data[0]," "===a.char);n--)s++,t.width-=a.width;s&&e.splice(i-s,s)}};function Ba(t,e,a){switch(e){case"title":return a?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ra}=ka,{Letter:Ea,Single:Ta,Before:La,After:Aa,Symbol:Oa,Break:Ma}=_a;let Ca,Wa,Da,Pa,Ia,Fa,Ya,Ua,Xa,Na,qa,za,ja,Ga,Ha,Va,Qa,Ja=[];function Za(t,e){Xa&&!Ua&&(Ua=Xa),Ca.data.push({char:t,width:e}),Da+=e}function $a(){Pa+=Da,Ca.width=Da,Wa.words.push(Ca),Ca={data:[]},Da=0}function Ka(){Ga&&(Ha.paraNumber++,Wa.paraStart=!0,Ga=!1),Xa&&(Wa.startCharSize=Ua,Wa.endCharSize=Xa,Ua=0),Wa.width=Pa,Va.width?Ra(Wa):Qa&&ts(),Ja.push(Wa),Wa={words:[]},Pa=0}function ts(){Pa>(Ha.maxWidth||0)&&(Ha.maxWidth=Pa)}const{top:es,right:as,bottom:ss,left:is}=I;function ns(t,e,a){const{bounds:s,rows:i}=t;s[e]+=a;for(let t=0;t<i.length;t++)i[t][e]+=a}const os={getDrawData:function(t,a){L(t)||(t=String(t));let s=0,i=0,n=a.__getInput("width")||0,o=a.__getInput("height")||0;const{__padding:r}=a;r&&(n?(s=r[is],n-=r[as]+r[is],!n&&(n=.01)):a.autoSizeAlign||(s=r[is]),o?(i=r[es],o-=r[es]+r[ss],!o&&(o=.01)):a.autoSizeAlign||(i=r[es]));const l={bounds:{x:s,y:i,width:n,height:o},rows:[],paraNumber:0,font:e.canvas.font=a.__font};return function(t,a,s){Ha=t,Ja=t.rows,Va=t.bounds,Qa=!Va.width&&!s.autoSizeAlign;const{__letterSpacing:i,paraIndent:n,textCase:o}=s,{canvas:r}=e,{width:l}=Va;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap;Ga=!0,qa=null,Ua=Ya=Xa=Da=Pa=0,Ca={data:[]},Wa={words:[]},i&&(a=[...a]);for(let s=0,d=a.length;s<d;s++)Fa=a[s],"\n"===Fa?(Da&&$a(),Wa.paraEnd=!0,Ka(),Ga=!0):(Na=ba(Fa),Na===Ea&&"none"!==o&&(Fa=Ba(Fa,o,!Da)),Ya=r.measureText(Fa).width,i&&(i<0&&(Xa=Ya),Ya+=i),za=Na===Ta&&(qa===Ta||qa===Ea)||qa===Ta&&Na!==Aa,ja=!(Na!==La&&Na!==Ta||qa!==Oa&&qa!==Aa),Ia=Ga&&n?l-n:l,t&&l&&Pa+Da+Ya>Ia&&(e?(Da&&$a(),Pa&&Ka()):(ja||(ja=Na===Ea&&qa==Aa),za||ja||Na===Ma||Na===La||Na===Ta||Da+Ya>Ia?(Da&&$a(),Pa&&Ka()):Pa&&Ka()))," "===Fa&&!0!==Ga&&Pa+Da===0||(Na===Ma?(" "===Fa&&Da&&$a(),Za(Fa,Ya),$a()):za||ja?(Da&&$a(),Za(Fa,Ya)):Za(Fa,Ya)),qa=Na);Da&&$a(),Pa&&Ka(),Ja.length>0&&(Ja[Ja.length-1].paraEnd=!0)}else a.split("\n").forEach(t=>{Ha.paraNumber++,Pa=r.measureText(t).width,Ja.push({x:n||0,text:t,width:Pa,paraStart:!0}),Qa&&ts()})}(l,t,a),r&&function(t,e,a,s,i){if(!s&&a.autoSizeAlign)switch(a.textAlign){case"left":ns(e,"x",t[is]);break;case"right":ns(e,"x",-t[as])}if(!i&&a.autoSizeAlign)switch(a.verticalAlign){case"top":ns(e,"y",t[es]);break;case"bottom":ns(e,"y",-t[ss])}}(r,l,a,n,o),function(t,e){const{rows:a,bounds:s}=t,i=a.length,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=n*i+(h?h*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,n),i>1&&(t.overflow=i);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,S=g||u?g:t.maxWidth;for(let o=0,c=i;o<c;o++){if(y=a[o],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&&o>0&&(m+=h),y.y=m,m+=n,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=a.length))}s.y=p,s.height=w}(l,a),a.__isCharMode&&function(t,e,a){const{rows:s}=t,{textAlign:i,paraIndent:n,letterSpacing:o}=e,r=a&&i.includes("both"),l=r||a&&i.includes("justify"),d=l&&i.includes("letter");let c,h,u,f,p,g,_,w,m,y;s.forEach(t=>{t.words&&(p=n&&t.paraStart?n:0,w=t.words.length,l&&(y=!t.paraEnd||r,h=a-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=o||t.isOverflow||d?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,a)=>{1===g?(_={char:"",x:c},c=function(t,e,a){return t.forEach(t=>{a.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,a,s,i){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,a.push(t)),e+=t.width,i&&(e+=i)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(m=a===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(l,a,n),l.overflow&&function(t,a,s,i){if(!i)return;const{rows:n,overflow:o}=t;let{textOverflow:r}=a;if(n.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=s+i-d;("none"===a.textWrap?n:[n[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let a=e.data.length-1;for(let s=a;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===a&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,a,s,n),"none"!==a.textDecoration&&function(t,e){let a,s=0;const{fontSize:i,textDecoration:n}=e;switch(t.decorationHeight=i/11,k(n)?(a=n.type,n.color&&(t.decorationColor=N.string(n.color)),n.offset&&(s=Math.min(.3*i,Math.max(n.offset,.15*-i)))):a=n,a){case"under":t.decorationY=[.15*i+s];break;case"delete":t.decorationY=[.35*-i];break;case"under-delete":t.decorationY=[.15*i+s,.35*-i]}}(l,a),l}};const rs={string:function(t,e){if(!t)return"#000";const a=F(e)&&e<1;if(L(t)){if(!a||!N.object)return t;t=N.object(t)}let s=T(t.a)?1:t.a;a&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}};Object.assign(G,os),Object.assign(N,rs),Object.assign(U,qt),Object.assign(X,Se),Object.assign(q,Xe),Object.assign(z,ea);const{setPoint:ls,addPoint:ds,toBounds:cs}=H;const hs={syncExport(t,e,a){let s;Q.running=!0;try{const i=J.fileType(e),n=e.includes(".");a=J.getExportOptions(a);const{toURL:o}=Z,{download:r}=Z.origin;if("json"===i)n&&r(o(JSON.stringify(t.toJSON(a.json)),"text"),e),s={data:!!n||t.toJSON(a.json)};else if("svg"===i)n&&r(o(t.toSVG(),"svg"),e),s={data:!!n||t.toSVG()};else{let i,n,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=a,m=$(a.smooth)?!c||c.config.smooth:a.smooth,y=a.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&$(a.fill)?t.fill:a.fill,x=J.isOpaqueImage(e)||v,S=new K;if(g)i=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=a.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":S.set(l);break;case"local":S.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:S.set(l).divide(t.getTransform(e));const a=e.worldTransform;o/=o/a.scaleX,r/=r/a.scaleY}i=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};tt.getScaleData(a.scale,a.size,i,b);let k=a.pixelRatio||1,{x:B,y:R,width:E,height:T}=new V(i).scale(b.scaleX,b.scaleY);f&&(B+=f.x,R+=f.y,E=f.width,T=f.height);const L={exporting:!0,matrix:S.scale(1/b.scaleX,1/b.scaleY).invert().translate(-B,-R).withScale(1/o*b.scaleX,1/r*b.scaleY)};let A,O=et.canvas({width:Math.floor(E),height:Math.floor(T),pixelRatio:k,smooth:m,contextSettings:y});u&&(A=t,A.__worldOpacity=0,t=c||t,L.bounds=O.bounds),O.save();const M=h&&!$(v),C=t.get("fill");if(M&&(t.fill=""),Z.render(t,O,L),M&&(t.fill=C),O.restore(),A&&A.__updateWorldOpacity(),p){n=function(t){const{width:e,height:a}=t.view,{data:s}=t.context.getImageData(0,0,e,a);let i,n,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(i=r%e,n=(r-i)/e,o?ds(o,i,n):ls(o={},i,n)),r++;const l=new V;return o&&(cs(o,l),l.scale(1/t.pixelRatio).ceil()),l}(O);const t=O,{width:e,height:a}=n,s={x:0,y:0,width:e,height:a,pixelRatio:k};O=et.canvas(s),O.copyWorld(t,n,s),t.destroy()}if(_){const[t,e,a,s]=tt.fourNumber(_),i=O,{width:n,height:o}=i;O=et.canvas({width:n+s+e,height:o+t+a,pixelRatio:k}),O.copyWorld(i,i.bounds,{x:s,y:t,width:n,height:o}),i.destroy()}x&&O.fillWorld(O.bounds,v||"#FFFFFF","destination-over"),w&&w(O);s={data:"canvas"===e?O:O.export(e,a),width:O.pixelWidth,height:O.pixelHeight,renderBounds:i,trimBounds:n};const W=c&&c.app;W&&W.canvasManager&&W.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return Q.running=!1,s},export(t,e,a){return Q.running=!0,function(t){us||(us=new at);return new Promise(e=>{us.add(()=>lt(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(i=>{const n=()=>lt(this,void 0,void 0,function*(){if(!st.isComplete)return Z.requestRender(n);const o=Q.syncExport(t,e,a);o.data instanceof Promise&&(o.data=yield o.data),s(o),i()});t.updateLayout(),fs(t);const{leafer:o}=t;o?o.waitViewCompleted(n):n()}))}};let us;function fs(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>fs(t))}const ps=it.prototype,gs=nt.get("@leafer-in/export");ps.export=function(t,e){const{quality:a,blob:s}=J.getExportOptions(e);return t.includes(".")?this.saveAs(t,a):s?this.toBlob(t,a):this.toDataURL(t,a)},ps.toBlob=function(t,e){return new Promise(a=>{Z.origin.canvasToBolb(this.view,t,e).then(t=>{a(t)}).catch(t=>{gs.error(t),a(null)})})},ps.toDataURL=function(t,e){return Z.origin.canvasToDataURL(this.view,t,e)},ps.saveAs=function(t,e){return new Promise(a=>{Z.origin.canvasSaveAs(this.view,t,e).then(()=>{a(!0)}).catch(t=>{gs.error(t),a(!1)})})},ot.add("export"),Object.assign(Q,hs),rt.prototype.export=function(t,e){return Q.export(this,t,e)},rt.prototype.syncExport=function(t,e){return Q.syncExport(this,t,e)};export{kt as Layouter,dt as LeaferCanvas,Rt as Renderer,ft as Watcher,ut as useCanvas};
|
|
2
2
|
//# sourceMappingURL=node.esm.min.js.map
|