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