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