leafer-draw 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/web.cjs +5 -4
- package/dist/web.esm.js +6 -5
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +6 -5
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +6 -5
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
package/dist/web.js
CHANGED
|
@@ -6409,7 +6409,7 @@ var LeaferUI = function(exports) {
|
|
|
6409
6409
|
this.levelMap = null;
|
|
6410
6410
|
}
|
|
6411
6411
|
}
|
|
6412
|
-
const version = "1.9.
|
|
6412
|
+
const version = "1.9.9";
|
|
6413
6413
|
const debug$4 = Debug.get("LeaferCanvas");
|
|
6414
6414
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6415
6415
|
set zIndex(zIndex) {
|
|
@@ -9814,8 +9814,8 @@ var LeaferUI = function(exports) {
|
|
|
9814
9814
|
const sx = Math.abs(nowWorld.scaleX);
|
|
9815
9815
|
if (sx > 1) otherScale = 1 / sx;
|
|
9816
9816
|
}
|
|
9817
|
-
other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
|
|
9818
|
-
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
9817
|
+
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));
|
|
9818
|
+
transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
9819
9819
|
if (transform) other.setTransform(transform);
|
|
9820
9820
|
drawWorldShadow(other, offsetOutBounds$1, shape);
|
|
9821
9821
|
if (transform) other.resetTransform();
|
|
@@ -9885,8 +9885,8 @@ var LeaferUI = function(exports) {
|
|
|
9885
9885
|
if (sx > 1) otherScale = 1 / sx;
|
|
9886
9886
|
}
|
|
9887
9887
|
other.save();
|
|
9888
|
-
other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
|
|
9889
|
-
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
9888
|
+
other.setWorldShadow(offsetOutBounds.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale);
|
|
9889
|
+
transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
9890
9890
|
if (transform) other.setTransform(transform);
|
|
9891
9891
|
drawWorldShadow(other, offsetOutBounds, shape);
|
|
9892
9892
|
other.restore();
|
|
@@ -10460,6 +10460,7 @@ var LeaferUI = function(exports) {
|
|
|
10460
10460
|
getDrawData: getDrawData
|
|
10461
10461
|
};
|
|
10462
10462
|
function string(color, opacity) {
|
|
10463
|
+
if (!color) return "#000";
|
|
10463
10464
|
const doOpacity = isNumber(opacity) && opacity < 1;
|
|
10464
10465
|
if (isString(color)) {
|
|
10465
10466
|
if (doOpacity && ColorConvert.object) color = ColorConvert.object(color); else return color;
|
package/dist/web.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const i=t.Debug.get("LeaferCanvas");class n extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(e){let n=t.isString(e)?document.getElementById(e):e;if(n)if(n instanceof HTMLCanvasElement)this.view=n;else{let t=n;if(n===window||n===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else i.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:e,height:i,pixelRatio:n}=this,{style:s}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:n}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=s.width||""),s.width=e.width+"px"):t.isUndefined(i)||(s.width=i),e.height?(t.isUndefined(n)&&(this.autoHeightStr=s.height||""),s.height=e.height+"px"):t.isUndefined(n)||(s.height=n)}else s.width=e+"px",s.height=i+"px",this.view.width=Math.ceil(e*n),this.view.height=Math.ceil(i*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),i.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:a,height:r}=this.autoBounds.getBoundsFrom(e),o={width:a,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(o)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(o)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:a}=t.FileHelper;function r(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const n=s(e),a=t.toDataURL(n,i);return"image/bmp"===n?a.replace("image/png;","image/bmp;"):a},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,s(e),i)),canvasSaveAs:(e,i,n)=>{const r=e.toDataURL(s(a(i)),n);return t.Platform.origin.download(r,i)},download:(t,e)=>new Promise(i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()}),loadImage:e=>new Promise((i,n)=>{const s=new t.Platform.origin.Image,{crossOrigin:a}=t.Platform.image;a&&(s.setAttribute("crossOrigin",a),s.crossOrigin=a),s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.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 t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:h,updateChange:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),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:_,updateAllChange:m}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(s);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,l,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?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||h(n[t])}h(i)}})}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new g(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_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,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(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.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(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(x.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),t.Platform.render(this.target,n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&e>n)return t.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(e),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.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 b(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[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(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,i){switch(e.__.strokeAlign){case"center":R(t,1,e,i);break;case"inside":L(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,i):L(t,"outside",e,i)}}function R(e,i,n,s){const a=n.__;t.isObject(e)?k(e,i,!0,n,s):(s.setStroke(e,a.__strokeWidth*i,a),S(n,s))}function L(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,R(e,2,n,a),a.blendMode="outside"===i?"destination-out":"destination-in",b(n,a),a.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,a),a.recycle(n.__nowWorld)}function S(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[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}=n;s.forEach(i=>a.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function k(t,i,n,s,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*i,o);for(let d=0,h=t.length;d<h;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(s,a,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*i,o,t):a.setStroke(r.style,o.__strokeWidth*i,o)}else a.strokeStyle=r.style;r.blendMode?(a.saveBlendMode(r.blendMode),n?S(s,a):a.stroke(),a.restoreBlendMode()):n?S(s,a):a.stroke()}}function P(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)B(e,i,n);else switch(s.strokeAlign){case"center":C(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),C(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)C(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),C(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function C(i,n,s,a){const r=s.__;t.isObject(i)?k(i,n,!1,s,a):(a.setStroke(i,r.__strokeWidth*n,r),a.stroke()),r.__useArrow&&e.Paint.strokeArrow(i,s,a)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),t.Platform.layout=y.fullLayout,t.Platform.render=function(e,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new t.LeafList,e.__render(i,n),n.topList.length&&n.topList.forEach(t=>t.__render(i,s))};const{getSpread:A,copyAndSpread:O,toOuterOf:T,getOuterOf:D,getByMove:W,move:M,getIntersectData:I}=t.BoundsHelper,z={};let H;const{stintSet:F}=t.DataHelper,{hasTransparent:U}=e.ColorConvert;function j(i,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=e.PaintImage.image(s,i,n,r,!H||!H[n.url]);break;case"linear":a=e.PaintGradient.linearGradient(n,r);break;case"radial":a=e.PaintGradient.radialGradient(n,r);break;case"angular":a=e.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;a={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:e.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&U(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const G={compute:function(i,n){const s=n.__,a=[];let r,o,l,d=s.__input[i];t.isArray(d)||(d=[d]),H=e.PaintImage.recycleImage(i,s);for(let t,e=0,s=d.length;e<s;e++)(t=j(i,d[e],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+i]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(F(s,"__isAlphaPixelFill",r),F(s,"__isTransparentFill",o)):(F(s,"__isAlphaPixelStroke",r),F(s,"__isTransparentStroke",o),F(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,E(e,i)},fills:function(t,i,n){let s;for(let a=0,r=t.length;a<r;a++){if(s=t[a],s.image){if(e.PaintImage.checkImage(i,n,s,!i.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&i.drawImagePlaceholder(n,s.image);continue}}if(n.fillStyle=s.style,s.transform||s.scaleFixed){if(n.save(),s.transform&&n.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:e}=i.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&e>1)&&n.scale(1/t,1/e)}s.blendMode&&(n.blendMode=s.blendMode),E(i,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),E(i,n),n.restoreBlendMode()):E(i,n)}},fillPathOrText:E,fillText:b,stroke:P,strokes:function(t,e,i){P(t,e,i)},strokeText:B,drawTextStroke:S,shape:function(e,i,n){const s=i.getSameCanvas(),a=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,h,c,u,f,p;T(o.strokeSpread?(O(z,o.boxBounds,o.strokeSpread),z):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=e.getRenderScaleData(!0);if(a.includes(l))p=s,d=f=l,h=r;else{let s;if(t.Platform.fullImageShadow)s=l;else{const e=o.renderShapeSpread?A(a,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):a;s=I(e,l)}u=a.getFitMatrix(s);let{a:m,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,n),g*=m,_*=w),f=D(l,u),d=W(f,-u.e,-u.f),h=D(r,u),M(h,-u.e,-u.f);const y=n.matrix;y?(c=new t.Matrix(u),c.multiply(y),m*=y.scaleX,w*=y.scaleY):c=u,c.withScale(m,w),n=Object.assign(Object.assign({},n),{matrix:c})}return e.__renderShape(s,n),{canvas:s,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let V={},Y=t.getMatrixData();const{get:N,rotateOfOuter:q,translate:X,scaleOfOuter:Q,multiplyParent:Z,scale:$,rotate:K,skew:J}=t.MatrixHelper;function tt(t,e,i,n,s,a,r){const o=N();X(o,e.x+i,e.y+n),$(o,s,a),r&&q(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function et(t,e,i,n,s,a,r,o,l,d){const h=N();nt(h,e,i,n,s,a,r,o),l&&(Y.a=l,Y.d=d,Z(h,Y)),t.transform=h}function it(t,e,i,n,s,a,r,o,l,d,h,c){const u=N();if(c)nt(u,e,s,a,r,o,l,d);else{if(l)if("center"===h)q(u,{x:i/2,y:n/2},l);else switch(K(u,l),l){case 90:X(u,n,0);break;case 180:X(u,i,n);break;case 270:X(u,0,i)}V.x=e.x+s,V.y=e.y+a,X(u,V.x,V.y),r&&Q(u,V,r,o)}t.transform=u}function nt(t,e,i,n,s,a,r,o){r&&K(t,r),o&&J(t,o.x,o.y),s&&$(t,s,a),X(t,e.x+i,e.y+n)}const{get:st,translate:at}=t.MatrixHelper,rt=new t.Bounds,ot={},lt={};function dt(t,e,i,n){const{changeful:s,sync:a,scaleFixed:r}=i;s&&(t.changeful=s),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=ht(i,n,e)}function ht(e,i,n){e.padding&&(i=rt.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=n;const{opacity:r,mode:o,align:l,offset:d,scale:h,size:c,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,w=i.width===s&&i.height===a,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(lt,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((h||c)&&(t.MathHelper.getScaleData(h,c,n,ot),x=ot.scaleX,b=ot.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(lt,x,b,!0),l&&t.AlignHelper.toPoint(l,lt,i,lt,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,lt,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,lt),t.BoundsHelper.scale(lt,x,b,!0)),d&&t.PointHelper.move(lt,d),o){case"stretch":w||(s=i.width,a=i.height);break;case"normal":case"clip":if(lt.x||lt.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),et(y,i,lt.x,lt.y,x,b,u,f,t,e),t&&(x=x?x*t:x,b=b?b*e:e)}break;case"repeat":(!w||x||u||f)&&it(y,i,s,a,lt.x,lt.y,x,b,u,f,l,e.freeTransform),g||(y.repeat="repeat");const n=t.isObject(g);(_||n)&&(y.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:ct(r,n,a.width,i&&i.x),y:ct(o,s,a.height,i&&i.y)}}(_,n&&g,lt.width,lt.height,i));break;default:x&&tt(y,i,lt.x,lt.y,x,b,u)}return y.transform||(i.x||i.y)&&(y.transform=st(),at(y.transform,i.x,i.y)),x&&"stretch"!==o&&(y.scaleX=x,y.scaleY=b),y.width=s,y.height=a,r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ct(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let ut,ft=new t.Bounds;const{isSame:pt}=t.BoundsHelper;function gt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||dt(s,n,i,a),!0}function _t(e,i){yt(e,t.ImageEvent.LOAD,i)}function mt(e,i){yt(e,t.ImageEvent.LOADED,i)}function wt(e,i,n){i.error=n,e.forceUpdate("surface"),yt(e,t.ImageEvent.ERROR,i)}function yt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function vt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:xt,scale:bt,copy:Et}=t.MatrixHelper,{floor:Bt,ceil:Rt,max:Lt,abs:St}=Math;function kt(e,i,n){let{scaleX:s,scaleY:a}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+a+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;s*=n,a*=n,f&&(f=St(f),p=St(p),h=xt(),Et(h,g),bt(h,1/f,1/p),s*=f,a*=p),c*=s,u*=a;const w=c*u;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/Rt(t))}else{const t=o.width*o.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,c/=d,u/=d),f&&(s/=f,a/=p);const v=m&&m.x*s,x=m&&m.y*a;if(g||1!==s||1!==a){const t=c+(v||0),e=u+(x||0);s/=t/Lt(Bt(t),1),a/=e/Lt(Bt(e),1),h||(h=xt(),g&&Et(h,g)),bt(h,1/s,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",h,i);return i.style=E,i.patternId=r,!0}}function Pt(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Ct={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return ut&&n===ut.paint&&pt(s,ut.boxBounds)?r=ut.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),ut=l.use>1?{leafPaint:r,paint:n,boxBounds:ft.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(gt(e,i,n,l,r,s),a&&(_t(e,o),mt(e,o))):l.error?a&&wt(e,o,l.error):(a&&(vt(e,!0),_t(e,o)),r.loadId=l.load(()=>{vt(e,!1),e.destroyed||(gt(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),mt(e,o)),r.loadId=void 0},t=>{vt(e,!1),wt(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(i,n,s,a){const{scaleX:r,scaleY:o}=i.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=n,{data:d}=s;if(!d||s.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(a)if(d.repeat)a=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(i)||e.Export.running)){let{width:e,height:i}=d;e*=r*l,i*=o*l,d.scaleX&&(e*=d.scaleX,i*=d.scaleY),a=e*i>t.Platform.image.maxCacheSize}return a?(i.__.__isFastShadow&&(n.fillStyle=s.style||"#000",n.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(i,n,s,d),!0):(!s.style||s.sync||e.Export.running?kt(i,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Pt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(i.__nowWorld)&&kt(i,s,l),i.forceUpdate("surface")}),300)),!1)},createPattern:kt,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let d=0,h=n.length;d<h;d++)s=n[d],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:dt,getPatternData:ht,fillOrFitMode:tt,clipMode:et,repeatMode:it},{toPoint:At}=t.AroundHelper,{hasTransparent:Ot}=e.ColorConvert,Tt={},Dt={};function Wt(i,n,s,a){if(s){let r,o,l,d;for(let i=0,h=s.length;i<h;i++)r=s[i],t.isString(r)?(l=i/(h-1),o=e.ColorConvert.string(r,a)):(l=r.offset,o=e.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!d&&Ot(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:Mt,getDistance:It}=t.PointHelper,{get:zt,rotateOfOuter:Ht,scaleOfOuter:Ft}=t.MatrixHelper,{toPoint:Ut}=t.AroundHelper,jt={},Gt={};function Vt(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Mt(e,i);a=zt(),s?(Ft(a,e,r/o*(n||1),1),Ht(a,e,t+90)):(Ft(a,e,1,r/o*(n||1)),Ht(a,e,t))}return a}const{getDistance:Yt}=t.PointHelper,{toPoint:Nt}=t.AroundHelper,qt={},Xt={};const Qt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;At(n||"top",i,Tt),At(s||"bottom",i,Dt);const o=t.Platform.canvas.createLinearGradient(Tt.x,Tt.y,Dt.x,Dt.y),l={type:a,style:o};return Wt(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;Ut(n||"center",i,jt),Ut(s||"bottom",i,Gt);const l=t.Platform.canvas.createRadialGradient(jt.x,jt.y,0,jt.x,jt.y,It(jt,Gt)),d={type:a,style:l};Wt(d,l,e.stops,r);const h=Vt(i,jt,Gt,o,!0);return h&&(d.transform=h),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;Nt(n||"center",i,qt),Nt(s||"bottom",i,Xt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,qt.x,qt.y):t.Platform.canvas.createRadialGradient(qt.x,qt.y,0,qt.x,qt.y,Yt(qt,Xt)),d={type:a,style:l};Wt(d,l,e.stops,r);const h=Vt(i,qt,Xt,o||1,t.Platform.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Vt},{copy:Zt,move:$t,toOffsetOutBounds:Kt}=t.BoundsHelper,{max:Jt}=Math,te={},ee=new t.Matrix,ie={};function ne(t,e){let i,n,s,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,s=t.spread||0,a=1.5*(t.blur||0),r=Jt(r,s+a-n),o=Jt(o,s+a+i),l=Jt(l,s+a+n),d=Jt(d,s+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function se(t,e,i,n,s,a,r){if(n.spread){const i=1+2*n.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return ee.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},i),ee}}function ae(e,i,n){const{shapeBounds:s}=n;let a,r;t.Platform.fullImageShadow?(Zt(te,e.bounds),$t(te,i.x-s.x,i.y-s.y),a=e.bounds,r=te):(a=s,r=i),e.copyWorld(n.canvas,a,r)}const{toOffsetOutBounds:re}=t.BoundsHelper,oe={};const le=ne;const de={shadow:function(i,n,s){let a,r;const{__nowWorld:o}=i,{shadow:l}=i.__,{worldCanvas:d,bounds:h,renderBounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;Kt(h,ie,c),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ie.offsetX+l.x*f*w,ie.offsetY+l.y*p*w,l.blur*f*w,e.ColorConvert.string(l.color)),r=se(i,g,s,l,ie,w),r&&g.setTransform(r),ae(g,ie,s),r&&g.resetTransform(),a=c,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,c,o,"copy"),a=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(s.canvas,u,h,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(i,n,s){let a,r;const{__nowWorld:o}=i,{innerShadow:l}=i.__,{worldCanvas:d,bounds:h,renderBounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;re(h,oe,c),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(oe.offsetX+l.x*f*w,oe.offsetY+l.y*p*w,l.blur*f*w),r=se(i,g,0,l,oe,w,!0),r&&g.setTransform(r),ae(g,oe,s),g.restore(),d?(g.copyWorld(g,c,o,"copy"),g.copyWorld(d,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,h,"source-out"),a=c),g.fillWorld(a,e.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:ne,getShadowTransform:se,isTransformShadow(t){},getInnerShadowSpread:le},{excludeRenderBounds:he}=t.LeafBoundsHelper;let ce;function ue(t,e,i,n,s,a,r,o){switch(e){case"grayscale":ce||(ce=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);pe(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":pe(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function fe(t){return t.getSameCanvas(!1,!0)}function pe(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,n,s,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&&(ue(this,r,t,s,n,a,void 0,!0),n=s=null),"clipping"!==o&&"clipping-path"!==o||he(i,e)||i.__render(t,e),a=i.__.opacity,ce=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=fe(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=fe(t)),s||(s=fe(t)),i.__render(n,e));continue}const h=1===a&&i.__.__blendMode;h&&ue(this,r,t,s,n,a,void 0,!1),he(i,e)||i.__render(s||t,e),h&&ue(this,r,t,s,n,a,h,!1)}ue(this,r,t,s,n,a,void 0,!0)};const ge=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",_e=ge+"_#~&*+\\=|≮≯≈≠=…",me=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 we(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ye=we("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ve=we("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),xe=we(ge),be=we(_e),Ee=we("- —/~|┆·");var Be;!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"}(Be||(Be={}));const{Letter:Re,Single:Le,Before:Se,After:ke,Symbol:Pe,Break:Ce}=Be;function Ae(t){return ye[t]?Re:Ee[t]?Ce:ve[t]?Se:xe[t]?ke:be[t]?Pe:me.test(t)?Le:Re}const Oe={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Te(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:De}=Oe,{Letter:We,Single:Me,Before:Ie,After:ze,Symbol:He,Break:Fe}=Be;let Ue,je,Ge,Ve,Ye,Ne,qe,Xe,Qe,Ze,$e,Ke,Je,ti,ei,ii,ni,si=[];function ai(t,e){Qe&&!Xe&&(Xe=Qe),Ue.data.push({char:t,width:e}),Ge+=e}function ri(){Ve+=Ge,Ue.width=Ge,je.words.push(Ue),Ue={data:[]},Ge=0}function oi(){ti&&(ei.paraNumber++,je.paraStart=!0,ti=!1),Qe&&(je.startCharSize=Xe,je.endCharSize=Qe,Xe=0),je.width=Ve,ii.width?De(je):ni&&li(),si.push(je),je={words:[]},Ve=0}function li(){Ve>(ei.maxWidth||0)&&(ei.maxWidth=Ve)}const{top:di,right:hi,bottom:ci,left:ui}=t.Direction4;function fi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const pi={getDrawData:function(i,n){t.isString(i)||(i=String(i));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:h}=n;h&&(r?(s=h[ui],r-=h[hi]+h[ui]):n.autoSizeAlign||(s=h[ui]),o?(a=h[di],o-=h[di]+h[ci]):n.autoSizeAlign||(a=h[di]));const c={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,i,n){ei=e,si=e.rows,ii=e.bounds,ni=!ii.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=ii;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;ti=!0,$e=null,Xe=qe=Qe=Ge=Ve=0,Ue={data:[]},je={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Ne=i[n],"\n"===Ne?(Ge&&ri(),je.paraEnd=!0,oi(),ti=!0):(Ze=Ae(Ne),Ze===We&&"none"!==r&&(Ne=Te(Ne,r,!Ge)),qe=o.measureText(Ne).width,s&&(s<0&&(Qe=qe),qe+=s),Ke=Ze===Me&&($e===Me||$e===We)||$e===Me&&Ze!==ze,Je=!(Ze!==Ie&&Ze!==Me||$e!==He&&$e!==ze),Ye=ti&&a?l-a:l,t&&l&&Ve+Ge+qe>Ye&&(e?(Ge&&ri(),Ve&&oi()):(Je||(Je=Ze===We&&$e==ze),Ke||Je||Ze===Fe||Ze===Ie||Ze===Me||Ge+qe>Ye?(Ge&&ri(),Ve&&oi()):Ve&&oi()))," "===Ne&&!0!==ti&&Ve+Ge===0||(Ze===Fe?(" "===Ne&&Ge&&ri(),ai(Ne,qe),ri()):Ke||Je?(Ge&&ri(),ai(Ne,qe)):ai(Ne,qe)),$e=Ze);Ge&&ri(),Ve&&oi(),si.length>0&&(si[si.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{ei.paraNumber++,Ve=o.measureText(t).width,si.push({x:a||0,text:t,width:Ve,paraStart:!0}),ni&&li()})}(c,i,n),h&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":fi(e,"x",t[ui]);break;case"right":fi(e,"x",-t[hi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":fi(e,"y",t[di]);break;case"bottom":fi(e,"y",-t[ci])}}(h,c,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=a*s+(c?c*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(y=i[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&&c&&r>0&&(w+=c),y.y=w,w+=a,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=m}(c,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;n.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&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,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,n,r),c.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,h=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<h));n--){if(l<h&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(c,n,s,r),"none"!==l&&function(i,n){let s,a=0;const{fontSize:r,textDecoration:o}=n;switch(i.decorationHeight=r/11,t.isObject(o)?(s=o.type,o.color&&(i.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(a=Math.min(.3*r,Math.max(o.offset,.15*-r)))):s=o,s){case"under":i.decorationY=[.15*r+a];break;case"delete":i.decorationY=[.35*-r];break;case"under-delete":i.decorationY=[.15*r+a,.35*-r]}}(c,n),c}};const gi={string:function(i,n){const s=t.isNumber(n)&&n<1;if(t.isString(i)){if(!s||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let a=t.isUndefined(i.a)?1:i.a;s&&(a*=n);const r=i.r+","+i.g+","+i.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(e.TextConvert,pi),Object.assign(e.ColorConvert,gi),Object.assign(e.Paint,G),Object.assign(e.PaintImage,Ct),Object.assign(e.PaintGradient,Qt),Object.assign(e.Effect,de),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,Object.keys(t).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const i=t.Debug.get("LeaferCanvas");class n extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(e){let n=t.isString(e)?document.getElementById(e):e;if(n)if(n instanceof HTMLCanvasElement)this.view=n;else{let t=n;if(n===window||n===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else i.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:e,height:i,pixelRatio:n}=this,{style:s}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:n}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=s.width||""),s.width=e.width+"px"):t.isUndefined(i)||(s.width=i),e.height?(t.isUndefined(n)&&(this.autoHeightStr=s.height||""),s.height=e.height+"px"):t.isUndefined(n)||(s.height=n)}else s.width=e+"px",s.height=i+"px",this.view.width=Math.ceil(e*n),this.view.height=Math.ceil(i*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),i.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:a,height:r}=this.autoBounds.getBoundsFrom(e),o={width:a,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(o)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(o)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:a}=t.FileHelper;function r(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const n=s(e),a=t.toDataURL(n,i);return"image/bmp"===n?a.replace("image/png;","image/bmp;"):a},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,s(e),i)),canvasSaveAs:(e,i,n)=>{const r=e.toDataURL(s(a(i)),n);return t.Platform.origin.download(r,i)},download:(t,e)=>new Promise(i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()}),loadImage:e=>new Promise((i,n)=>{const s=new t.Platform.origin.Image,{crossOrigin:a}=t.Platform.image;a&&(s.setAttribute("crossOrigin",a),s.crossOrigin=a),s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.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 t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:h,updateChange:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),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:_,updateAllChange:m}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(s);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,l,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?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||h(n[t])}h(i)}})}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new g(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_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,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(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.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(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(x.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),t.Platform.render(this.target,n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&e>n)return t.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(e),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.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 b(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[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(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,i){switch(e.__.strokeAlign){case"center":R(t,1,e,i);break;case"inside":S(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,i):S(t,"outside",e,i)}}function R(e,i,n,s){const a=n.__;t.isObject(e)?k(e,i,!0,n,s):(s.setStroke(e,a.__strokeWidth*i,a),L(n,s))}function S(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,R(e,2,n,a),a.blendMode="outside"===i?"destination-out":"destination-in",b(n,a),a.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,a),a.recycle(n.__nowWorld)}function L(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[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}=n;s.forEach(i=>a.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function k(t,i,n,s,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*i,o);for(let d=0,h=t.length;d<h;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(s,a,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*i,o,t):a.setStroke(r.style,o.__strokeWidth*i,o)}else a.strokeStyle=r.style;r.blendMode?(a.saveBlendMode(r.blendMode),n?L(s,a):a.stroke(),a.restoreBlendMode()):n?L(s,a):a.stroke()}}function P(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)B(e,i,n);else switch(s.strokeAlign){case"center":C(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),C(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)C(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),C(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function C(i,n,s,a){const r=s.__;t.isObject(i)?k(i,n,!1,s,a):(a.setStroke(i,r.__strokeWidth*n,r),a.stroke()),r.__useArrow&&e.Paint.strokeArrow(i,s,a)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),t.Platform.layout=y.fullLayout,t.Platform.render=function(e,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new t.LeafList,e.__render(i,n),n.topList.length&&n.topList.forEach(t=>t.__render(i,s))};const{getSpread:A,copyAndSpread:O,toOuterOf:T,getOuterOf:D,getByMove:W,move:M,getIntersectData:I}=t.BoundsHelper,z={};let H;const{stintSet:F}=t.DataHelper,{hasTransparent:U}=e.ColorConvert;function j(i,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=e.PaintImage.image(s,i,n,r,!H||!H[n.url]);break;case"linear":a=e.PaintGradient.linearGradient(n,r);break;case"radial":a=e.PaintGradient.radialGradient(n,r);break;case"angular":a=e.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;a={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:e.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&U(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const G={compute:function(i,n){const s=n.__,a=[];let r,o,l,d=s.__input[i];t.isArray(d)||(d=[d]),H=e.PaintImage.recycleImage(i,s);for(let t,e=0,s=d.length;e<s;e++)(t=j(i,d[e],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+i]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(F(s,"__isAlphaPixelFill",r),F(s,"__isTransparentFill",o)):(F(s,"__isAlphaPixelStroke",r),F(s,"__isTransparentStroke",o),F(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,E(e,i)},fills:function(t,i,n){let s;for(let a=0,r=t.length;a<r;a++){if(s=t[a],s.image){if(e.PaintImage.checkImage(i,n,s,!i.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&i.drawImagePlaceholder(n,s.image);continue}}if(n.fillStyle=s.style,s.transform||s.scaleFixed){if(n.save(),s.transform&&n.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:e}=i.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&e>1)&&n.scale(1/t,1/e)}s.blendMode&&(n.blendMode=s.blendMode),E(i,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),E(i,n),n.restoreBlendMode()):E(i,n)}},fillPathOrText:E,fillText:b,stroke:P,strokes:function(t,e,i){P(t,e,i)},strokeText:B,drawTextStroke:L,shape:function(e,i,n){const s=i.getSameCanvas(),a=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,h,c,u,f,p;T(o.strokeSpread?(O(z,o.boxBounds,o.strokeSpread),z):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=e.getRenderScaleData(!0);if(a.includes(l))p=s,d=f=l,h=r;else{let s;if(t.Platform.fullImageShadow)s=l;else{const e=o.renderShapeSpread?A(a,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):a;s=I(e,l)}u=a.getFitMatrix(s);let{a:m,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,n),g*=m,_*=w),f=D(l,u),d=W(f,-u.e,-u.f),h=D(r,u),M(h,-u.e,-u.f);const y=n.matrix;y?(c=new t.Matrix(u),c.multiply(y),m*=y.scaleX,w*=y.scaleY):c=u,c.withScale(m,w),n=Object.assign(Object.assign({},n),{matrix:c})}return e.__renderShape(s,n),{canvas:s,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let V={},Y=t.getMatrixData();const{get:N,rotateOfOuter:q,translate:X,scaleOfOuter:Q,multiplyParent:Z,scale:$,rotate:K,skew:J}=t.MatrixHelper;function tt(t,e,i,n,s,a,r){const o=N();X(o,e.x+i,e.y+n),$(o,s,a),r&&q(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function et(t,e,i,n,s,a,r,o,l,d){const h=N();nt(h,e,i,n,s,a,r,o),l&&(Y.a=l,Y.d=d,Z(h,Y)),t.transform=h}function it(t,e,i,n,s,a,r,o,l,d,h,c){const u=N();if(c)nt(u,e,s,a,r,o,l,d);else{if(l)if("center"===h)q(u,{x:i/2,y:n/2},l);else switch(K(u,l),l){case 90:X(u,n,0);break;case 180:X(u,i,n);break;case 270:X(u,0,i)}V.x=e.x+s,V.y=e.y+a,X(u,V.x,V.y),r&&Q(u,V,r,o)}t.transform=u}function nt(t,e,i,n,s,a,r,o){r&&K(t,r),o&&J(t,o.x,o.y),s&&$(t,s,a),X(t,e.x+i,e.y+n)}const{get:st,translate:at}=t.MatrixHelper,rt=new t.Bounds,ot={},lt={};function dt(t,e,i,n){const{changeful:s,sync:a,scaleFixed:r}=i;s&&(t.changeful=s),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=ht(i,n,e)}function ht(e,i,n){e.padding&&(i=rt.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=n;const{opacity:r,mode:o,align:l,offset:d,scale:h,size:c,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,w=i.width===s&&i.height===a,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(lt,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((h||c)&&(t.MathHelper.getScaleData(h,c,n,ot),x=ot.scaleX,b=ot.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(lt,x,b,!0),l&&t.AlignHelper.toPoint(l,lt,i,lt,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,lt,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,lt),t.BoundsHelper.scale(lt,x,b,!0)),d&&t.PointHelper.move(lt,d),o){case"stretch":w||(s=i.width,a=i.height);break;case"normal":case"clip":if(lt.x||lt.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),et(y,i,lt.x,lt.y,x,b,u,f,t,e),t&&(x=x?x*t:x,b=b?b*e:e)}break;case"repeat":(!w||x||u||f)&&it(y,i,s,a,lt.x,lt.y,x,b,u,f,l,e.freeTransform),g||(y.repeat="repeat");const n=t.isObject(g);(_||n)&&(y.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:ct(r,n,a.width,i&&i.x),y:ct(o,s,a.height,i&&i.y)}}(_,n&&g,lt.width,lt.height,i));break;default:x&&tt(y,i,lt.x,lt.y,x,b,u)}return y.transform||(i.x||i.y)&&(y.transform=st(),at(y.transform,i.x,i.y)),x&&"stretch"!==o&&(y.scaleX=x,y.scaleY=b),y.width=s,y.height=a,r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ct(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let ut,ft=new t.Bounds;const{isSame:pt}=t.BoundsHelper;function gt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||dt(s,n,i,a),!0}function _t(e,i){yt(e,t.ImageEvent.LOAD,i)}function mt(e,i){yt(e,t.ImageEvent.LOADED,i)}function wt(e,i,n){i.error=n,e.forceUpdate("surface"),yt(e,t.ImageEvent.ERROR,i)}function yt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function vt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:xt,scale:bt,copy:Et}=t.MatrixHelper,{floor:Bt,ceil:Rt,max:St,abs:Lt}=Math;function kt(e,i,n){let{scaleX:s,scaleY:a}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+a+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;s*=n,a*=n,f&&(f=Lt(f),p=Lt(p),h=xt(),Et(h,g),bt(h,1/f,1/p),s*=f,a*=p),c*=s,u*=a;const w=c*u;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/Rt(t))}else{const t=o.width*o.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,c/=d,u/=d),f&&(s/=f,a/=p);const v=m&&m.x*s,x=m&&m.y*a;if(g||1!==s||1!==a){const t=c+(v||0),e=u+(x||0);s/=t/St(Bt(t),1),a/=e/St(Bt(e),1),h||(h=xt(),g&&Et(h,g)),bt(h,1/s,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",h,i);return i.style=E,i.patternId=r,!0}}function Pt(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Ct={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return ut&&n===ut.paint&&pt(s,ut.boxBounds)?r=ut.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),ut=l.use>1?{leafPaint:r,paint:n,boxBounds:ft.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(gt(e,i,n,l,r,s),a&&(_t(e,o),mt(e,o))):l.error?a&&wt(e,o,l.error):(a&&(vt(e,!0),_t(e,o)),r.loadId=l.load(()=>{vt(e,!1),e.destroyed||(gt(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),mt(e,o)),r.loadId=void 0},t=>{vt(e,!1),wt(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(i,n,s,a){const{scaleX:r,scaleY:o}=i.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=n,{data:d}=s;if(!d||s.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(a)if(d.repeat)a=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(i)||e.Export.running)){let{width:e,height:i}=d;e*=r*l,i*=o*l,d.scaleX&&(e*=d.scaleX,i*=d.scaleY),a=e*i>t.Platform.image.maxCacheSize}return a?(i.__.__isFastShadow&&(n.fillStyle=s.style||"#000",n.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(i,n,s,d),!0):(!s.style||s.sync||e.Export.running?kt(i,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Pt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(i.__nowWorld)&&kt(i,s,l),i.forceUpdate("surface")}),300)),!1)},createPattern:kt,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let d=0,h=n.length;d<h;d++)s=n[d],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:dt,getPatternData:ht,fillOrFitMode:tt,clipMode:et,repeatMode:it},{toPoint:At}=t.AroundHelper,{hasTransparent:Ot}=e.ColorConvert,Tt={},Dt={};function Wt(i,n,s,a){if(s){let r,o,l,d;for(let i=0,h=s.length;i<h;i++)r=s[i],t.isString(r)?(l=i/(h-1),o=e.ColorConvert.string(r,a)):(l=r.offset,o=e.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!d&&Ot(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:Mt,getDistance:It}=t.PointHelper,{get:zt,rotateOfOuter:Ht,scaleOfOuter:Ft}=t.MatrixHelper,{toPoint:Ut}=t.AroundHelper,jt={},Gt={};function Vt(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Mt(e,i);a=zt(),s?(Ft(a,e,r/o*(n||1),1),Ht(a,e,t+90)):(Ft(a,e,1,r/o*(n||1)),Ht(a,e,t))}return a}const{getDistance:Yt}=t.PointHelper,{toPoint:Nt}=t.AroundHelper,qt={},Xt={};const Qt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;At(n||"top",i,Tt),At(s||"bottom",i,Dt);const o=t.Platform.canvas.createLinearGradient(Tt.x,Tt.y,Dt.x,Dt.y),l={type:a,style:o};return Wt(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;Ut(n||"center",i,jt),Ut(s||"bottom",i,Gt);const l=t.Platform.canvas.createRadialGradient(jt.x,jt.y,0,jt.x,jt.y,It(jt,Gt)),d={type:a,style:l};Wt(d,l,e.stops,r);const h=Vt(i,jt,Gt,o,!0);return h&&(d.transform=h),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;Nt(n||"center",i,qt),Nt(s||"bottom",i,Xt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,qt.x,qt.y):t.Platform.canvas.createRadialGradient(qt.x,qt.y,0,qt.x,qt.y,Yt(qt,Xt)),d={type:a,style:l};Wt(d,l,e.stops,r);const h=Vt(i,qt,Xt,o||1,t.Platform.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Vt},{copy:Zt,move:$t,toOffsetOutBounds:Kt}=t.BoundsHelper,{max:Jt}=Math,te={},ee=new t.Matrix,ie={};function ne(t,e){let i,n,s,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,s=t.spread||0,a=1.5*(t.blur||0),r=Jt(r,s+a-n),o=Jt(o,s+a+i),l=Jt(l,s+a+n),d=Jt(d,s+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function se(e,i,n){const{shapeBounds:s}=n;let a,r;t.Platform.fullImageShadow?(Zt(te,e.bounds),$t(te,i.x-s.x,i.y-s.y),a=e.bounds,r=te):(a=s,r=i),e.copyWorld(n.canvas,a,r)}const{toOffsetOutBounds:ae}=t.BoundsHelper,re={};const oe=ne;const le={shadow:function(i,n,s){let a,r;const{__nowWorld:o}=i,{shadow:l}=i.__,{worldCanvas:d,bounds:h,renderBounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;Kt(h,ie,c),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ie.offsetX+(l.x||0)*f*w,ie.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w,e.ColorConvert.string(l.color)),r=e.Effect.getShadowTransform(i,g,s,l,ie,w),r&&g.setTransform(r),se(g,ie,s),r&&g.resetTransform(),a=c,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,c,o,"copy"),a=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(s.canvas,u,h,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(i,n,s){let a,r;const{__nowWorld:o}=i,{innerShadow:l}=i.__,{worldCanvas:d,bounds:h,renderBounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;ae(h,re,c),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(re.offsetX+(l.x||0)*f*w,re.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w),r=e.Effect.getShadowTransform(i,g,s,l,re,w,!0),r&&g.setTransform(r),se(g,re,s),g.restore(),d?(g.copyWorld(g,c,o,"copy"),g.copyWorld(d,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,h,"source-out"),a=c),g.fillWorld(a,e.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:ne,getShadowTransform:function(t,e,i,n,s,a,r){if(n.spread){const i=1+2*n.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return ee.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},i),ee}},isTransformShadow(t){},getInnerShadowSpread:oe},{excludeRenderBounds:de}=t.LeafBoundsHelper;let he;function ce(t,e,i,n,s,a,r,o){switch(e){case"grayscale":he||(he=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);fe(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":fe(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function ue(t){return t.getSameCanvas(!1,!0)}function fe(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,n,s,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&&(ce(this,r,t,s,n,a,void 0,!0),n=s=null),"clipping"!==o&&"clipping-path"!==o||de(i,e)||i.__render(t,e),a=i.__.opacity,he=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=ue(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ue(t)),s||(s=ue(t)),i.__render(n,e));continue}const h=1===a&&i.__.__blendMode;h&&ce(this,r,t,s,n,a,void 0,!1),de(i,e)||i.__render(s||t,e),h&&ce(this,r,t,s,n,a,h,!1)}ce(this,r,t,s,n,a,void 0,!0)};const pe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ge=pe+"_#~&*+\\=|≮≯≈≠=…",_e=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 me(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const we=me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ye=me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ve=me(pe),xe=me(ge),be=me("- —/~|┆·");var Ee;!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"}(Ee||(Ee={}));const{Letter:Be,Single:Re,Before:Se,After:Le,Symbol:ke,Break:Pe}=Ee;function Ce(t){return we[t]?Be:be[t]?Pe:ye[t]?Se:ve[t]?Le:xe[t]?ke:_e.test(t)?Re:Be}const Ae={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Oe(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:Te}=Ae,{Letter:De,Single:We,Before:Me,After:Ie,Symbol:ze,Break:He}=Ee;let Fe,Ue,je,Ge,Ve,Ye,Ne,qe,Xe,Qe,Ze,$e,Ke,Je,ti,ei,ii,ni=[];function si(t,e){Xe&&!qe&&(qe=Xe),Fe.data.push({char:t,width:e}),je+=e}function ai(){Ge+=je,Fe.width=je,Ue.words.push(Fe),Fe={data:[]},je=0}function ri(){Je&&(ti.paraNumber++,Ue.paraStart=!0,Je=!1),Xe&&(Ue.startCharSize=qe,Ue.endCharSize=Xe,qe=0),Ue.width=Ge,ei.width?Te(Ue):ii&&oi(),ni.push(Ue),Ue={words:[]},Ge=0}function oi(){Ge>(ti.maxWidth||0)&&(ti.maxWidth=Ge)}const{top:li,right:di,bottom:hi,left:ci}=t.Direction4;function ui(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const fi={getDrawData:function(i,n){t.isString(i)||(i=String(i));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:h}=n;h&&(r?(s=h[ci],r-=h[di]+h[ci]):n.autoSizeAlign||(s=h[ci]),o?(a=h[li],o-=h[li]+h[hi]):n.autoSizeAlign||(a=h[li]));const c={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,i,n){ti=e,ni=e.rows,ei=e.bounds,ii=!ei.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=ei;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Je=!0,Ze=null,qe=Ne=Xe=je=Ge=0,Fe={data:[]},Ue={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Ye=i[n],"\n"===Ye?(je&&ai(),Ue.paraEnd=!0,ri(),Je=!0):(Qe=Ce(Ye),Qe===De&&"none"!==r&&(Ye=Oe(Ye,r,!je)),Ne=o.measureText(Ye).width,s&&(s<0&&(Xe=Ne),Ne+=s),$e=Qe===We&&(Ze===We||Ze===De)||Ze===We&&Qe!==Ie,Ke=!(Qe!==Me&&Qe!==We||Ze!==ze&&Ze!==Ie),Ve=Je&&a?l-a:l,t&&l&&Ge+je+Ne>Ve&&(e?(je&&ai(),Ge&&ri()):(Ke||(Ke=Qe===De&&Ze==Ie),$e||Ke||Qe===He||Qe===Me||Qe===We||je+Ne>Ve?(je&&ai(),Ge&&ri()):Ge&&ri()))," "===Ye&&!0!==Je&&Ge+je===0||(Qe===He?(" "===Ye&&je&&ai(),si(Ye,Ne),ai()):$e||Ke?(je&&ai(),si(Ye,Ne)):si(Ye,Ne)),Ze=Qe);je&&ai(),Ge&&ri(),ni.length>0&&(ni[ni.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{ti.paraNumber++,Ge=o.measureText(t).width,ni.push({x:a||0,text:t,width:Ge,paraStart:!0}),ii&&oi()})}(c,i,n),h&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ui(e,"x",t[ci]);break;case"right":ui(e,"x",-t[di])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ui(e,"y",t[li]);break;case"bottom":ui(e,"y",-t[hi])}}(h,c,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=a*s+(c?c*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(y=i[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&&c&&r>0&&(w+=c),y.y=w,w+=a,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=m}(c,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;n.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&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,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,n,r),c.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,h=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<h));n--){if(l<h&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(c,n,s,r),"none"!==l&&function(i,n){let s,a=0;const{fontSize:r,textDecoration:o}=n;switch(i.decorationHeight=r/11,t.isObject(o)?(s=o.type,o.color&&(i.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(a=Math.min(.3*r,Math.max(o.offset,.15*-r)))):s=o,s){case"under":i.decorationY=[.15*r+a];break;case"delete":i.decorationY=[.35*-r];break;case"under-delete":i.decorationY=[.15*r+a,.35*-r]}}(c,n),c}};const pi={string:function(i,n){if(!i)return"#000";const s=t.isNumber(n)&&n<1;if(t.isString(i)){if(!s||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let a=t.isUndefined(i.a)?1:i.a;s&&(a*=n);const r=i.r+","+i.g+","+i.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(e.TextConvert,fi),Object.assign(e.ColorConvert,pi),Object.assign(e.Paint,G),Object.assign(e.PaintImage,Ct),Object.assign(e.PaintGradient,Qt),Object.assign(e.Effect,le),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,Object.keys(t).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
|
|
2
2
|
//# sourceMappingURL=web.min.cjs.map
|