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