@leafer-ui/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 +11 -11
package/dist/worker.cjs
CHANGED
|
@@ -1799,8 +1799,8 @@ function shadow(ui, current, shape) {
|
|
|
1799
1799
|
const sx = Math.abs(nowWorld.scaleX);
|
|
1800
1800
|
if (sx > 1) otherScale = 1 / sx;
|
|
1801
1801
|
}
|
|
1802
|
-
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));
|
|
1803
|
-
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
1802
|
+
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));
|
|
1803
|
+
transform = draw.Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
1804
1804
|
if (transform) other.setTransform(transform);
|
|
1805
1805
|
drawWorldShadow(other, offsetOutBounds$1, shape);
|
|
1806
1806
|
if (transform) other.resetTransform();
|
|
@@ -1876,8 +1876,8 @@ function innerShadow(ui, current, shape) {
|
|
|
1876
1876
|
if (sx > 1) otherScale = 1 / sx;
|
|
1877
1877
|
}
|
|
1878
1878
|
other.save();
|
|
1879
|
-
other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
|
|
1880
|
-
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
1879
|
+
other.setWorldShadow(offsetOutBounds.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale);
|
|
1880
|
+
transform = draw.Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
1881
1881
|
if (transform) other.setTransform(transform);
|
|
1882
1882
|
drawWorldShadow(other, offsetOutBounds, shape);
|
|
1883
1883
|
other.restore();
|
|
@@ -2513,6 +2513,7 @@ const TextConvertModule = {
|
|
|
2513
2513
|
};
|
|
2514
2514
|
|
|
2515
2515
|
function string(color, opacity) {
|
|
2516
|
+
if (!color) return "#000";
|
|
2516
2517
|
const doOpacity = core.isNumber(opacity) && opacity < 1;
|
|
2517
2518
|
if (core.isString(color)) {
|
|
2518
2519
|
if (doOpacity && draw.ColorConvert.object) color = draw.ColorConvert.object(color); else return color;
|
package/dist/worker.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ import { HitCanvasManager, InteractionBase } from "@leafer-ui/core";
|
|
|
8
8
|
|
|
9
9
|
export * from "@leafer-ui/core";
|
|
10
10
|
|
|
11
|
-
import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert
|
|
11
|
+
import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Effect, Group, TextConvert } from "@leafer-ui/draw";
|
|
12
12
|
|
|
13
13
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
14
14
|
get allowBackgroundColor() {
|
|
@@ -1803,8 +1803,8 @@ function shadow(ui, current, shape) {
|
|
|
1803
1803
|
const sx = Math.abs(nowWorld.scaleX);
|
|
1804
1804
|
if (sx > 1) otherScale = 1 / sx;
|
|
1805
1805
|
}
|
|
1806
|
-
other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
|
|
1807
|
-
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
1806
|
+
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));
|
|
1807
|
+
transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
1808
1808
|
if (transform) other.setTransform(transform);
|
|
1809
1809
|
drawWorldShadow(other, offsetOutBounds$1, shape);
|
|
1810
1810
|
if (transform) other.resetTransform();
|
|
@@ -1880,8 +1880,8 @@ function innerShadow(ui, current, shape) {
|
|
|
1880
1880
|
if (sx > 1) otherScale = 1 / sx;
|
|
1881
1881
|
}
|
|
1882
1882
|
other.save();
|
|
1883
|
-
other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
|
|
1884
|
-
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
1883
|
+
other.setWorldShadow(offsetOutBounds.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale);
|
|
1884
|
+
transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
1885
1885
|
if (transform) other.setTransform(transform);
|
|
1886
1886
|
drawWorldShadow(other, offsetOutBounds, shape);
|
|
1887
1887
|
other.restore();
|
|
@@ -2517,6 +2517,7 @@ const TextConvertModule = {
|
|
|
2517
2517
|
};
|
|
2518
2518
|
|
|
2519
2519
|
function string(color, opacity) {
|
|
2520
|
+
if (!color) return "#000";
|
|
2520
2521
|
const doOpacity = isNumber(opacity) && opacity < 1;
|
|
2521
2522
|
if (isString(color)) {
|
|
2522
2523
|
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 i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as k,BoundsHelper as B,Plugin as S,isObject as E,FourNumberHelper as R,Matrix as L,isUndefined as A,isString as T,getMatrixData as C,MatrixHelper as O,MathHelper as W,AlignHelper as P,PointHelper as M,ImageEvent as D,AroundHelper as F,Direction4 as I,isNumber as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as z,InteractionBase as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as G,Paint as X,ColorConvert as q,PaintGradient as N,Export as j,Group as H,TextConvert as V,Effect as Q}from"@leafer-ui/draw";class Z 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:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:$}=s;function J(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:$(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:$(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Z(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:K}=navigator;K.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),K.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):K.indexOf("Mac")>-1?e.os="Mac":K.indexOf("Linux")>-1&&(e.os="Linux");class tt{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===h.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 c(c.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],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:et,updateBounds:it,updateChange:st}=f,{pushAllChildBranch:nt,pushAllParent:at}=g;const{worldBounds:rt}=p;class ot{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,rt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,rt),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:lt,updateAllChange:dt}=f,ht=y.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,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){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(et(t,!0),e.add(t),t.isBranch&&nt(t,e),at(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),at(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||it(s[t])}it(i)}})}(this.__levelList),function(t){t.list.forEach(st)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.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:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ct.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){lt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),dt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(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],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ut=y.get("Renderer");class ft{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.__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 _,ut.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,ut.error(t)}ut.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ut.warn("rendering");if(this.times>3)return ut.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:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(ft.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.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,i){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}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:s}=this.config;if(s&&t>s)return e.requestRender(i);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(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||ut.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],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[k.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}ft.clipSpread=10;const{hitRadiusPoint:gt}=B;class pt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class _t{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function wt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[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}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function yt(t,e){t.__.__font?wt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function mt(t,e,i){switch(e.__.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":vt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?xt(t,2,e,i):vt(t,"outside",e,i)}}function xt(t,e,i,s){const n=i.__;E(t)?kt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),bt(i,s))}function vt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,xt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",wt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function bt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;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(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function kt(t,e,i,s,n){let a;const r=s.__,{__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||!G.checkImage(s,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),i?bt(s,n):n.stroke(),n.restoreBlendMode()):i?bt(s,n):n.stroke()}}function Bt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)mt(t,e,i);else switch(s.strokeAlign){case"center":St(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),St(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)St(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),St(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function St(t,e,i,s){const n=i.__;E(t)?kt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&X.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new tt(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ct.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:Et,copyAndSpread:Rt,toOuterOf:Lt,getOuterOf:At,getByMove:Tt,move:Ct,getIntersectData:Ot}=B,Wt={};let Pt;const{stintSet:Mt}=l,{hasTransparent:Dt}=q;function Ft(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=G.image(i,t,e,n,!Pt||!Pt[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:q.string(r,o)};break;default:A(e.r)||(s={type:"solid",style:q.string(e)})}if(s){if(T(s.style)&&Dt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const It={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),Pt=G.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Ft(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Mt(i,"__isAlphaPixelFill",n),Mt(i,"__isTransparentFill",a)):(Mt(i,"__isAlphaPixelStroke",n),Mt(i,"__isTransparentStroke",a),Mt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,yt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(G.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),yt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),yt(e,i),i.restoreBlendMode()):yt(e,i)}},fillPathOrText:yt,fillText:wt,stroke:Bt,strokes:function(t,e,i){Bt(t,e,i)},strokeText:mt,drawTextStroke:bt,shape:function(t,i,s){const n=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,h,c,u,f,g;Lt(o.strokeSpread?(Rt(Wt,o.boxBounds,o.strokeSpread),Wt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=n,d=f=l,h=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?Et(a,R.swapAndScale(o.renderShapeSpread,p,_)):a;n=Ot(t,l)}u=a.getFitMatrix(n);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=At(l,u),d=Tt(f,-u.e,-u.f),h=At(r,u),Ct(h,-u.e,-u.f);const m=s.matrix;m?(c=new L(u),c.multiply(m),w*=m.scaleX,y*=m.scaleY):c=u,c.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:c})}return t.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Yt={},zt=C();const{get:Ut,rotateOfOuter:Gt,translate:Xt,scaleOfOuter:qt,multiplyParent:Nt,scale:jt,rotate:Ht,skew:Vt}=O;function Qt(t,e,i,s,n,a,r){const o=Ut();Xt(o,e.x+i,e.y+s),jt(o,n,a),r&&Gt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Zt(t,e,i,s,n,a,r,o,l,d){const h=Ut();Jt(h,e,i,s,n,a,r,o),l&&(zt.a=l,zt.d=d,Nt(h,zt)),t.transform=h}function $t(t,e,i,s,n,a,r,o,l,d,h,c){const u=Ut();if(c)Jt(u,e,n,a,r,o,l,d);else{if(l)if("center"===h)Gt(u,{x:i/2,y:s/2},l);else switch(Ht(u,l),l){case 90:Xt(u,s,0);break;case 180:Xt(u,i,s);break;case 270:Xt(u,0,i)}Yt.x=e.x+n,Yt.y=e.y+a,Xt(u,Yt.x,Yt.y),r&&qt(u,Yt,r,o)}t.transform=u}function Jt(t,e,i,s,n,a,r,o){r&&Ht(t,r),o&&Vt(t,o.x,o.y),n&&jt(t,n,a),Xt(t,e.x+i,e.y+s)}const{get:Kt,translate:te}=O,ee=new _,ie={},se={};function ne(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=ae(i,s,e)}function ae(t,e,i){t.padding&&(e=ee.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(B.set(se,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(W.getScaleData(d,h,i,ie),x=ie.scaleX,v=ie.scaleY),(o||p||g)&&(x&&B.scale(se,x,v,!0),o&&P.toPoint(o,se,e,se,!0,!0))):w&&!c||(x=v=B.getFitScale(e,se,"fit"!==r),B.put(e,i,o,x,!1,se),B.scale(se,x,v,!0)),l&&M.move(se,l),r){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":if(se.x||se.y||x||f||c||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),Zt(y,e,se.x,se.y,x,v,c,u,t,i),t&&(x=x?x*t:x,v=v?v*i:i)}break;case"repeat":(!w||x||c||u)&&$t(y,e,s,n,se.x,se.y,x,v,c,u,o,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(p||i)&&(y.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:re(a,i,n.width,e&&e.x),y:re(r,s,n.height,e&&e.y)}}(p,i&&g,se.width,se.height,e));break;default:x&&Qt(y,e,se.x,se.y,x,v,c)}return y.transform||(e.x||e.y)&&(y.transform=Kt(),te(y.transform,e.x,e.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=v),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),g&&(y.repeat=T(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function re(t,e,i,s){const n=T(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let oe,le=new _;const{isSame:de}=B;function he(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||ne(n,s,i,a),!0}function ce(t,e){ge(t,D.LOAD,e)}function ue(t,e){ge(t,D.LOADED,e)}function fe(t,e,i){e.error=i,t.forceUpdate("surface"),ge(t,D.ERROR,e)}function ge(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function pe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:_e,scale:we,copy:ye}=O,{floor:me,ceil:xe,max:ve,abs:be}=Math;function ke(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:g,transform:p,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=be(f),g=be(g),h=_e(),ye(h,p),we(h,1/f,1/g),n*=f,a*=g),c*=n,u*=a;const y=c*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/xe(t))}else{const t=o.width*o.height;m>t&&(m=t)}y>m&&(d=Math.sqrt(y/m)),d&&(n/=d,a/=d,c/=d,u/=d),f&&(n/=f,a/=g);const x=w&&w.x*n,v=w&&w.y*a;if(p||1!==n||1!==a){const t=c+(x||0),e=u+(v||0);n/=t/ve(me(t),1),a/=e/ve(me(e),1),h||(h=_e(),p&&ye(h,p)),we(h,1/n,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),k=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",h,i);return i.style=k,i.patternId=r,!0}}function Be(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Se={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return oe&&i===oe.paint&&de(s,oe.boxBounds)?a=oe.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),oe=o.use>1?{leafPaint:a,paint:i,boxBounds:le.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(he(t,e,i,o,a,s),n&&(ce(t,r),ue(t,r))):o.error?n&&fe(t,r,o.error):(n&&(pe(t,!0),ce(t,r)),a.loadId=o.load(()=>{pe(t,!1),t.destroyed||(he(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ue(t,r)),a.loadId=void 0},e=>{pe(t,!1),fe(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,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!j.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&k.isResizing(t)||j.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||j.running?ke(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>Be(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ke(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ke,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.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(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:ne,getPatternData:ae,fillOrFitMode:Qt,clipMode:Zt,repeatMode:$t},{toPoint:Ee}=F,{hasTransparent:Re}=q,Le={},Ae={};function Te(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],T(n)?(r=t/(l-1),a=q.string(n,s)):(r=n.offset,a=q.string(n.color,s)),e.addColorStop(r,a),!o&&Re(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Ce,getDistance:Oe}=M,{get:We,rotateOfOuter:Pe,scaleOfOuter:Me}=O,{toPoint:De}=F,Fe={},Ie={};function Ye(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=Ce(e,i);a=We(),n?(Me(a,e,r/o*(s||1),1),Pe(a,e,t+90)):(Me(a,e,1,r/o*(s||1)),Pe(a,e,t))}return a}const{getDistance:ze}=M,{toPoint:Ue}=F,Ge={},Xe={};const qe={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;Ee(s||"top",i,Le),Ee(n||"bottom",i,Ae);const o=e.canvas.createLinearGradient(Le.x,Le.y,Ae.x,Ae.y),l={type:a,style:o};return Te(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;De(s||"center",i,Fe),De(n||"bottom",i,Ie);const l=e.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,Oe(Fe,Ie)),d={type:a,style:l};Te(d,l,t.stops,r);const h=Ye(i,Fe,Ie,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Ue(s||"center",i,Ge),Ue(n||"bottom",i,Xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ge.x,Ge.y):e.canvas.createRadialGradient(Ge.x,Ge.y,0,Ge.x,Ge.y,ze(Ge,Xe)),d={type:a,style:l};Te(d,l,t.stops,r);const h=Ye(i,Ge,Xe,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ye},{copy:Ne,move:je,toOffsetOutBounds:He}=B,{max:Ve}=Math,Qe={},Ze=new L,$e={};function Je(t,e){let i,s,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=t.spread||0,a=1.5*(t.blur||0),r=Ve(r,n+a-s),o=Ve(o,n+a+i),l=Ve(l,n+a+s),d=Ve(d,n+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ke(t,e,i,s,n,a,r){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return Ze.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),Ze}}function ti(t,i,s){const{shapeBounds:n}=s;let a,r;e.fullImageShadow?(Ne(Qe,t.bounds),je(Qe,i.x-n.x,i.y-n.y),a=t.bounds,r=Qe):(a=n,r=i),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:ei}=B,ii={};const si=Je;const ni={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;He(l,$e,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow($e.offsetX+r.x*c*w,$e.offsetY+r.y*u*w,r.blur*c*w,q.string(r.color)),n=Ke(t,g,i,r,$e,w),n&&g.setTransform(n),ti(g,$e,i),n&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),s=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,h,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;ei(l,ii,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(ii.offsetX+r.x*c*w,ii.offsetY+r.y*u*w,r.blur*c*w),n=Ke(t,g,0,r,ii,w,!0),n&&g.setTransform(n),ti(g,ii,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,l,"source-out"),s=d),g.fillWorld(s,q.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Je,getShadowTransform:Ke,isTransformShadow(t){},getInnerShadowSpread:si},{excludeRenderBounds:ai}=p;let ri;function oi(t,e,i,s,n,a,r,o){switch(e){case"grayscale":ri||(ri=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);di(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":di(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function li(t){return t.getSameCanvas(!1,!0)}function di(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}H.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],o=i.__.mask,o){r&&(oi(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||ai(i,e)||i.__render(t,e),a=i.__.opacity,ri=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=li(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=li(t)),n||(n=li(t)),i.__render(s,e));continue}const h=1===a&&i.__.__blendMode;h&&oi(this,r,t,n,s,a,void 0,!1),ai(i,e)||i.__render(n||t,e),h&&oi(this,r,t,n,s,a,h,!1)}oi(this,r,t,n,s,a,void 0,!0)};const hi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ci=hi+"_#~&*+\\=|≮≯≈≠=…",ui=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 fi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const gi=fi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),pi=fi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),_i=fi(hi),wi=fi(ci),yi=fi("- —/~|┆·");var mi;!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"}(mi||(mi={}));const{Letter:xi,Single:vi,Before:bi,After:ki,Symbol:Bi,Break:Si}=mi;function Ei(t){return gi[t]?xi:yi[t]?Si:pi[t]?bi:_i[t]?ki:wi[t]?Bi:ui.test(t)?vi:xi}const Ri={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Li(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:Ai}=Ri,{Letter:Ti,Single:Ci,Before:Oi,After:Wi,Symbol:Pi,Break:Mi}=mi;let Di,Fi,Ii,Yi,zi,Ui,Gi,Xi,qi,Ni,ji,Hi,Vi,Qi,Zi,$i,Ji,Ki=[];function ts(t,e){qi&&!Xi&&(Xi=qi),Di.data.push({char:t,width:e}),Ii+=e}function es(){Yi+=Ii,Di.width=Ii,Fi.words.push(Di),Di={data:[]},Ii=0}function is(){Qi&&(Zi.paraNumber++,Fi.paraStart=!0,Qi=!1),qi&&(Fi.startCharSize=Xi,Fi.endCharSize=qi,Xi=0),Fi.width=Yi,$i.width?Ai(Fi):Ji&&ss(),Ki.push(Fi),Fi={words:[]},Yi=0}function ss(){Yi>(Zi.maxWidth||0)&&(Zi.maxWidth=Yi)}const{top:ns,right:as,bottom:rs,left:os}=I;function ls(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ds={getDrawData:function(t,i){T(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[os],a-=d[as]+d[os]):i.autoSizeAlign||(s=d[os]),r?(n=d[ns],r-=d[ns]+d[rs]):i.autoSizeAlign||(n=d[ns]));const h={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Zi=t,Ki=t.rows,$i=t.bounds,Ji=!$i.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=$i;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Qi=!0,ji=null,Xi=Gi=qi=Ii=Yi=0,Di={data:[]},Fi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Ui=i[s],"\n"===Ui?(Ii&&es(),Fi.paraEnd=!0,is(),Qi=!0):(Ni=Ei(Ui),Ni===Ti&&"none"!==r&&(Ui=Li(Ui,r,!Ii)),Gi=o.measureText(Ui).width,n&&(n<0&&(qi=Gi),Gi+=n),Hi=Ni===Ci&&(ji===Ci||ji===Ti)||ji===Ci&&Ni!==Wi,Vi=!(Ni!==Oi&&Ni!==Ci||ji!==Pi&&ji!==Wi),zi=Qi&&a?l-a:l,t&&l&&Yi+Ii+Gi>zi&&(e?(Ii&&es(),Yi&&is()):(Vi||(Vi=Ni===Ti&&ji==Wi),Hi||Vi||Ni===Mi||Ni===Oi||Ni===Ci||Ii+Gi>zi?(Ii&&es(),Yi&&is()):Yi&&is()))," "===Ui&&!0!==Qi&&Yi+Ii===0||(Ni===Mi?(" "===Ui&&Ii&&es(),ts(Ui,Gi),es()):Hi||Vi?(Ii&&es(),ts(Ui,Gi)):ts(Ui,Gi)),ji=Ni);Ii&&es(),Yi&&is(),Ki.length>0&&(Ki[Ki.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Zi.paraNumber++,Yi=o.measureText(t).width,Ki.push({x:a||0,text:t,width:Yi,paraStart:!0}),Ji&&ss()})}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ls(e,"x",t[os]);break;case"right":ls(e,"x",-t[as])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ls(e,"y",t[ns]);break;case"bottom":ls(e,"y",-t[rs])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(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,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;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,h=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+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)}})}}(h,i,s,a),"none"!==o&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,E(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(h,i),h}};const hs={string:function(t,e){const i=Y(e)&&e<1;if(T(t)){if(!i||!q.object)return t;t=q.object(t)}let s=A(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(V,ds),Object.assign(q,hs),Object.assign(X,It),Object.assign(G,Se),Object.assign(N,qe),Object.assign(Q,ni),Object.assign(n,{interaction:(t,e,i,s)=>new U(t,e,i,s),hitCanvas:(t,e)=>new Z(t,e),hitCanvasManager:()=>new z}),J();export{ct as Layouter,Z as LeaferCanvas,pt as Picker,ft as Renderer,_t as Selector,tt as Watcher,J as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as k,BoundsHelper as B,Plugin as S,isObject as E,FourNumberHelper as R,Matrix as L,isUndefined as A,isString as T,getMatrixData as C,MatrixHelper as O,MathHelper as W,AlignHelper as P,PointHelper as M,ImageEvent as D,AroundHelper as F,Direction4 as I,isNumber as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as z,InteractionBase as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as G,Paint as X,ColorConvert as q,PaintGradient as N,Export as j,Effect as H,Group as V,TextConvert as Q}from"@leafer-ui/draw";class Z 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:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:$}=s;function J(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:$(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:$(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Z(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:K}=navigator;K.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),K.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):K.indexOf("Mac")>-1?e.os="Mac":K.indexOf("Linux")>-1&&(e.os="Linux");class tt{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===h.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 c(c.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],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:et,updateBounds:it,updateChange:st}=f,{pushAllChildBranch:nt,pushAllParent:at}=g;const{worldBounds:rt}=p;class ot{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,rt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,rt),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:lt,updateAllChange:dt}=f,ht=y.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,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){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(et(t,!0),e.add(t),t.isBranch&&nt(t,e),at(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),at(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||it(s[t])}it(i)}})}(this.__levelList),function(t){t.list.forEach(st)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.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:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ct.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){lt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),dt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(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],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ut=y.get("Renderer");class ft{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.__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 _,ut.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,ut.error(t)}ut.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ut.warn("rendering");if(this.times>3)return ut.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:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(ft.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.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,i){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}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:s}=this.config;if(s&&t>s)return e.requestRender(i);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(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||ut.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],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[k.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}ft.clipSpread=10;const{hitRadiusPoint:gt}=B;class pt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class _t{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function wt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[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}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function yt(t,e){t.__.__font?wt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function mt(t,e,i){switch(e.__.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":vt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?xt(t,2,e,i):vt(t,"outside",e,i)}}function xt(t,e,i,s){const n=i.__;E(t)?kt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),bt(i,s))}function vt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,xt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",wt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function bt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;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(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function kt(t,e,i,s,n){let a;const r=s.__,{__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||!G.checkImage(s,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),i?bt(s,n):n.stroke(),n.restoreBlendMode()):i?bt(s,n):n.stroke()}}function Bt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)mt(t,e,i);else switch(s.strokeAlign){case"center":St(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),St(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)St(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),St(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function St(t,e,i,s){const n=i.__;E(t)?kt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&X.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new tt(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ct.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:Et,copyAndSpread:Rt,toOuterOf:Lt,getOuterOf:At,getByMove:Tt,move:Ct,getIntersectData:Ot}=B,Wt={};let Pt;const{stintSet:Mt}=l,{hasTransparent:Dt}=q;function Ft(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=G.image(i,t,e,n,!Pt||!Pt[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:q.string(r,o)};break;default:A(e.r)||(s={type:"solid",style:q.string(e)})}if(s){if(T(s.style)&&Dt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const It={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),Pt=G.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Ft(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Mt(i,"__isAlphaPixelFill",n),Mt(i,"__isTransparentFill",a)):(Mt(i,"__isAlphaPixelStroke",n),Mt(i,"__isTransparentStroke",a),Mt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,yt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(G.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),yt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),yt(e,i),i.restoreBlendMode()):yt(e,i)}},fillPathOrText:yt,fillText:wt,stroke:Bt,strokes:function(t,e,i){Bt(t,e,i)},strokeText:mt,drawTextStroke:bt,shape:function(t,i,s){const n=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,h,c,u,f,g;Lt(o.strokeSpread?(Rt(Wt,o.boxBounds,o.strokeSpread),Wt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=n,d=f=l,h=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?Et(a,R.swapAndScale(o.renderShapeSpread,p,_)):a;n=Ot(t,l)}u=a.getFitMatrix(n);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=At(l,u),d=Tt(f,-u.e,-u.f),h=At(r,u),Ct(h,-u.e,-u.f);const m=s.matrix;m?(c=new L(u),c.multiply(m),w*=m.scaleX,y*=m.scaleY):c=u,c.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:c})}return t.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Yt={},zt=C();const{get:Ut,rotateOfOuter:Gt,translate:Xt,scaleOfOuter:qt,multiplyParent:Nt,scale:jt,rotate:Ht,skew:Vt}=O;function Qt(t,e,i,s,n,a,r){const o=Ut();Xt(o,e.x+i,e.y+s),jt(o,n,a),r&&Gt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Zt(t,e,i,s,n,a,r,o,l,d){const h=Ut();Jt(h,e,i,s,n,a,r,o),l&&(zt.a=l,zt.d=d,Nt(h,zt)),t.transform=h}function $t(t,e,i,s,n,a,r,o,l,d,h,c){const u=Ut();if(c)Jt(u,e,n,a,r,o,l,d);else{if(l)if("center"===h)Gt(u,{x:i/2,y:s/2},l);else switch(Ht(u,l),l){case 90:Xt(u,s,0);break;case 180:Xt(u,i,s);break;case 270:Xt(u,0,i)}Yt.x=e.x+n,Yt.y=e.y+a,Xt(u,Yt.x,Yt.y),r&&qt(u,Yt,r,o)}t.transform=u}function Jt(t,e,i,s,n,a,r,o){r&&Ht(t,r),o&&Vt(t,o.x,o.y),n&&jt(t,n,a),Xt(t,e.x+i,e.y+s)}const{get:Kt,translate:te}=O,ee=new _,ie={},se={};function ne(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=ae(i,s,e)}function ae(t,e,i){t.padding&&(e=ee.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(B.set(se,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(W.getScaleData(d,h,i,ie),x=ie.scaleX,v=ie.scaleY),(o||p||g)&&(x&&B.scale(se,x,v,!0),o&&P.toPoint(o,se,e,se,!0,!0))):w&&!c||(x=v=B.getFitScale(e,se,"fit"!==r),B.put(e,i,o,x,!1,se),B.scale(se,x,v,!0)),l&&M.move(se,l),r){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":if(se.x||se.y||x||f||c||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),Zt(y,e,se.x,se.y,x,v,c,u,t,i),t&&(x=x?x*t:x,v=v?v*i:i)}break;case"repeat":(!w||x||c||u)&&$t(y,e,s,n,se.x,se.y,x,v,c,u,o,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(p||i)&&(y.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:re(a,i,n.width,e&&e.x),y:re(r,s,n.height,e&&e.y)}}(p,i&&g,se.width,se.height,e));break;default:x&&Qt(y,e,se.x,se.y,x,v,c)}return y.transform||(e.x||e.y)&&(y.transform=Kt(),te(y.transform,e.x,e.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=v),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),g&&(y.repeat=T(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function re(t,e,i,s){const n=T(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let oe,le=new _;const{isSame:de}=B;function he(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||ne(n,s,i,a),!0}function ce(t,e){ge(t,D.LOAD,e)}function ue(t,e){ge(t,D.LOADED,e)}function fe(t,e,i){e.error=i,t.forceUpdate("surface"),ge(t,D.ERROR,e)}function ge(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function pe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:_e,scale:we,copy:ye}=O,{floor:me,ceil:xe,max:ve,abs:be}=Math;function ke(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:g,transform:p,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=be(f),g=be(g),h=_e(),ye(h,p),we(h,1/f,1/g),n*=f,a*=g),c*=n,u*=a;const y=c*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/xe(t))}else{const t=o.width*o.height;m>t&&(m=t)}y>m&&(d=Math.sqrt(y/m)),d&&(n/=d,a/=d,c/=d,u/=d),f&&(n/=f,a/=g);const x=w&&w.x*n,v=w&&w.y*a;if(p||1!==n||1!==a){const t=c+(x||0),e=u+(v||0);n/=t/ve(me(t),1),a/=e/ve(me(e),1),h||(h=_e(),p&&ye(h,p)),we(h,1/n,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),k=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",h,i);return i.style=k,i.patternId=r,!0}}function Be(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Se={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return oe&&i===oe.paint&&de(s,oe.boxBounds)?a=oe.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),oe=o.use>1?{leafPaint:a,paint:i,boxBounds:le.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(he(t,e,i,o,a,s),n&&(ce(t,r),ue(t,r))):o.error?n&&fe(t,r,o.error):(n&&(pe(t,!0),ce(t,r)),a.loadId=o.load(()=>{pe(t,!1),t.destroyed||(he(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ue(t,r)),a.loadId=void 0},e=>{pe(t,!1),fe(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,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!j.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&k.isResizing(t)||j.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||j.running?ke(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>Be(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ke(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ke,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.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(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:ne,getPatternData:ae,fillOrFitMode:Qt,clipMode:Zt,repeatMode:$t},{toPoint:Ee}=F,{hasTransparent:Re}=q,Le={},Ae={};function Te(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],T(n)?(r=t/(l-1),a=q.string(n,s)):(r=n.offset,a=q.string(n.color,s)),e.addColorStop(r,a),!o&&Re(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Ce,getDistance:Oe}=M,{get:We,rotateOfOuter:Pe,scaleOfOuter:Me}=O,{toPoint:De}=F,Fe={},Ie={};function Ye(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=Ce(e,i);a=We(),n?(Me(a,e,r/o*(s||1),1),Pe(a,e,t+90)):(Me(a,e,1,r/o*(s||1)),Pe(a,e,t))}return a}const{getDistance:ze}=M,{toPoint:Ue}=F,Ge={},Xe={};const qe={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;Ee(s||"top",i,Le),Ee(n||"bottom",i,Ae);const o=e.canvas.createLinearGradient(Le.x,Le.y,Ae.x,Ae.y),l={type:a,style:o};return Te(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;De(s||"center",i,Fe),De(n||"bottom",i,Ie);const l=e.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,Oe(Fe,Ie)),d={type:a,style:l};Te(d,l,t.stops,r);const h=Ye(i,Fe,Ie,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Ue(s||"center",i,Ge),Ue(n||"bottom",i,Xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ge.x,Ge.y):e.canvas.createRadialGradient(Ge.x,Ge.y,0,Ge.x,Ge.y,ze(Ge,Xe)),d={type:a,style:l};Te(d,l,t.stops,r);const h=Ye(i,Ge,Xe,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ye},{copy:Ne,move:je,toOffsetOutBounds:He}=B,{max:Ve}=Math,Qe={},Ze=new L,$e={};function Je(t,e){let i,s,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=t.spread||0,a=1.5*(t.blur||0),r=Ve(r,n+a-s),o=Ve(o,n+a+i),l=Ve(l,n+a+s),d=Ve(d,n+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ke(t,i,s){const{shapeBounds:n}=s;let a,r;e.fullImageShadow?(Ne(Qe,t.bounds),je(Qe,i.x-n.x,i.y-n.y),a=t.bounds,r=Qe):(a=n,r=i),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:ti}=B,ei={};const ii=Je;const si={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;He(l,$e,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow($e.offsetX+(r.x||0)*c*w,$e.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w,q.string(r.color)),n=H.getShadowTransform(t,g,i,r,$e,w),n&&g.setTransform(n),Ke(g,$e,i),n&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),s=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,h,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;ti(l,ei,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(ei.offsetX+(r.x||0)*c*w,ei.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w),n=H.getShadowTransform(t,g,i,r,ei,w,!0),n&&g.setTransform(n),Ke(g,ei,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,l,"source-out"),s=d),g.fillWorld(s,q.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Je,getShadowTransform:function(t,e,i,s,n,a,r){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return Ze.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),Ze}},isTransformShadow(t){},getInnerShadowSpread:ii},{excludeRenderBounds:ni}=p;let ai;function ri(t,e,i,s,n,a,r,o){switch(e){case"grayscale":ai||(ai=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);li(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":li(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function oi(t){return t.getSameCanvas(!1,!0)}function li(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}V.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],o=i.__.mask,o){r&&(ri(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||ni(i,e)||i.__render(t,e),a=i.__.opacity,ai=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=oi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=oi(t)),n||(n=oi(t)),i.__render(s,e));continue}const h=1===a&&i.__.__blendMode;h&&ri(this,r,t,n,s,a,void 0,!1),ni(i,e)||i.__render(n||t,e),h&&ri(this,r,t,n,s,a,h,!1)}ri(this,r,t,n,s,a,void 0,!0)};const di=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",hi=di+"_#~&*+\\=|≮≯≈≠=…",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 ui(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const fi=ui("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),gi=ui("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pi=ui(di),_i=ui(hi),wi=ui("- —/~|┆·");var yi;!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"}(yi||(yi={}));const{Letter:mi,Single:xi,Before:vi,After:bi,Symbol:ki,Break:Bi}=yi;function Si(t){return fi[t]?mi:wi[t]?Bi:gi[t]?vi:pi[t]?bi:_i[t]?ki:ci.test(t)?xi:mi}const Ei={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};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:Li}=Ei,{Letter:Ai,Single:Ti,Before:Ci,After:Oi,Symbol:Wi,Break:Pi}=yi;let Mi,Di,Fi,Ii,Yi,zi,Ui,Gi,Xi,qi,Ni,ji,Hi,Vi,Qi,Zi,$i,Ji=[];function Ki(t,e){Xi&&!Gi&&(Gi=Xi),Mi.data.push({char:t,width:e}),Fi+=e}function ts(){Ii+=Fi,Mi.width=Fi,Di.words.push(Mi),Mi={data:[]},Fi=0}function es(){Vi&&(Qi.paraNumber++,Di.paraStart=!0,Vi=!1),Xi&&(Di.startCharSize=Gi,Di.endCharSize=Xi,Gi=0),Di.width=Ii,Zi.width?Li(Di):$i&&is(),Ji.push(Di),Di={words:[]},Ii=0}function is(){Ii>(Qi.maxWidth||0)&&(Qi.maxWidth=Ii)}const{top:ss,right:ns,bottom:as,left:rs}=I;function os(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ls={getDrawData:function(t,i){T(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[rs],a-=d[ns]+d[rs]):i.autoSizeAlign||(s=d[rs]),r?(n=d[ss],r-=d[ss]+d[as]):i.autoSizeAlign||(n=d[ss]));const h={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Qi=t,Ji=t.rows,Zi=t.bounds,$i=!Zi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=Zi;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Vi=!0,Ni=null,Gi=Ui=Xi=Fi=Ii=0,Mi={data:[]},Di={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)zi=i[s],"\n"===zi?(Fi&&ts(),Di.paraEnd=!0,es(),Vi=!0):(qi=Si(zi),qi===Ai&&"none"!==r&&(zi=Ri(zi,r,!Fi)),Ui=o.measureText(zi).width,n&&(n<0&&(Xi=Ui),Ui+=n),ji=qi===Ti&&(Ni===Ti||Ni===Ai)||Ni===Ti&&qi!==Oi,Hi=!(qi!==Ci&&qi!==Ti||Ni!==Wi&&Ni!==Oi),Yi=Vi&&a?l-a:l,t&&l&&Ii+Fi+Ui>Yi&&(e?(Fi&&ts(),Ii&&es()):(Hi||(Hi=qi===Ai&&Ni==Oi),ji||Hi||qi===Pi||qi===Ci||qi===Ti||Fi+Ui>Yi?(Fi&&ts(),Ii&&es()):Ii&&es()))," "===zi&&!0!==Vi&&Ii+Fi===0||(qi===Pi?(" "===zi&&Fi&&ts(),Ki(zi,Ui),ts()):ji||Hi?(Fi&&ts(),Ki(zi,Ui)):Ki(zi,Ui)),Ni=qi);Fi&&ts(),Ii&&es(),Ji.length>0&&(Ji[Ji.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Qi.paraNumber++,Ii=o.measureText(t).width,Ji.push({x:a||0,text:t,width:Ii,paraStart:!0}),$i&&is()})}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":os(e,"x",t[rs]);break;case"right":os(e,"x",-t[ns])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":os(e,"y",t[ss]);break;case"bottom":os(e,"y",-t[as])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(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,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;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,h=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+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)}})}}(h,i,s,a),"none"!==o&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,E(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(h,i),h}};const ds={string:function(t,e){if(!t)return"#000";const i=Y(e)&&e<1;if(T(t)){if(!i||!q.object)return t;t=q.object(t)}let s=A(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(Q,ls),Object.assign(q,ds),Object.assign(X,It),Object.assign(G,Se),Object.assign(N,qe),Object.assign(H,si),Object.assign(n,{interaction:(t,e,i,s)=>new U(t,e,i,s),hitCanvas:(t,e)=>new Z(t,e),hitCanvasManager:()=>new z}),J();export{ct as Layouter,Z as LeaferCanvas,pt as Picker,ft as Renderer,_t as Selector,tt as Watcher,J as useCanvas};
|
|
2
2
|
//# sourceMappingURL=worker.esm.min.js.map
|