@leafer-draw/worker 2.0.8 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.cjs CHANGED
@@ -784,6 +784,8 @@ function stroke(stroke, ui, canvas, renderOptions) {
784
784
  if (!data.__strokeWidth) return;
785
785
  if (data.__font) {
786
786
  draw.Paint.strokeText(stroke, ui, canvas, renderOptions);
787
+ } else if (data.__pathForStroke) {
788
+ draw.Paint.fillStroke(stroke, ui, canvas, renderOptions);
787
789
  } else {
788
790
  switch (data.strokeAlign) {
789
791
  case "center":
@@ -788,6 +788,8 @@ function stroke(stroke, ui, canvas, renderOptions) {
788
788
  if (!data.__strokeWidth) return;
789
789
  if (data.__font) {
790
790
  Paint.strokeText(stroke, ui, canvas, renderOptions);
791
+ } else if (data.__pathForStroke) {
792
+ Paint.fillStroke(stroke, ui, canvas, renderOptions);
791
793
  } else {
792
794
  switch (data.strokeAlign) {
793
795
  case "center":
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as a,LeaferImage as s,defineKey as n,FileHelper as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as m,Debug as w,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as E,Matrix as R,isUndefined as L,isString as T,ImageEvent as A,MatrixHelper as P,MathHelper as O,AlignHelper as C,PointHelper as W,isNumber as M,getMatrixData as D,AroundHelper as I,OneRadian as F,Direction4 as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as X,PaintImage as U,ColorConvert as G,PaintGradient as q,Effect as z,Group as N,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var H;function V(t,e,i,a){return new(i||(i=Promise))(function(s,n){function r(t){try{l(a.next(t))}catch(t){n(t)}}function o(t){try{l(a.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(H||(H={})),"function"==typeof SuppressedError&&SuppressedError;class Q extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function Z(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((a,s)=>{t.convertToBlob({type:r.mimeType(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)}).catch(t=>{s(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:r.mimeType(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:(t,i,a)=>new Promise((i,a)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then(t=>{i(t)}).catch(t=>{a(t)})},s.onerror=t=>a(t),s.send()}),loadContent(t){return V(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype),Object.assign(a,{canvas:(t,e)=>new Q(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},n(e,"devicePixelRatio",{get:()=>1});const{userAgent:$}=navigator;$.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),$.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):$.indexOf("Mac")>-1?e.os="Mac":$.indexOf("Linux")>-1&&(e.os="Linux");class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:tt,updateChange:et}=f,{pushAllChildBranch:it,pushAllParent:at}=g;const{worldBounds:st}=p;class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,m(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),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:rt,updateAllChange:ot}=f,lt=w.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){lt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?lt.warn("layouting"):this.times>3?lt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:s,LAYOUT:n,AFTER:r}=x,o=this.getBlocks(a);o.forEach(t=>t.setBefore()),i.emitEvent(new x(s,o,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?(K(t,!0),e.add(t),t.isBranch&&it(t,e),at(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),at(t,e)))})}(a,this.__levelList),function(t){let e,i,a;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){a=i.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||tt(a[t])}tt(i)}})}(this.__levelList),function(t){t.list.forEach(et)}(a),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(n,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=x,n=this.getBlocks(new o(e));e.emitEvent(new x(i,n,this.times)),dt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new x(a,n,this.times)),e.emitEvent(new x(s,n,this.times)),this.addBlocks(n),v.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=w.get("Renderer");class ht{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ct.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,a=t.getIntersect(i.bounds),s=new _(a);i.save(),a.spread(ht.clipSpread).ceil();const{ceilPartPixel:n}=this.config;i.clipWorld(a,n),i.clearWorld(a,n),this.__render(a,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:a,target:s}=this,n=t.includes(s.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&a.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(a,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(s,a,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),a.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:a}=this.config;if(a&&t>a)return e.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ut(t,e,i){t.__.__font?X.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ft(t,e,i,a,s){const n=i.__;k(t)?X.drawStrokesStyle(t,e,!1,i,a,s):(a.setStroke(t,n.__strokeWidth*e,n),a.stroke()),n.__useArrow&&X.strokeArrow(t,i,a,s)}function gt(t,e,i,a,s){const n=i.__;k(t)?X.drawStrokesStyle(t,e,!0,i,a,s):(a.setStroke(t,n.__strokeWidth*e,n),X.drawTextStroke(i,a,s))}function pt(t,e,i,a,s){const n=a.getSameCanvas(!0,!0);n.font=i.__.__font,gt(t,2,i,n,s),n.blendMode="outside"===e?"destination-out":"destination-in",X.fillText(i,n,s),n.blendMode="normal",f.copyCanvasByWorld(i,a,n),n.recycle(i.__nowWorld)}ht.clipSpread=10,Object.assign(a,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new ht(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,a)=>{}}),e.layout=dt.fullLayout,e.render=function(t,e,i){const a=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,a))};const{getSpread:_t,copyAndSpread:mt,toOuterOf:wt,getOuterOf:yt,getByMove:xt,move:vt,getIntersectData:St}=B,bt={};let kt;const{stintSet:Bt}=l,{hasTransparent:Et}=G;function Rt(t,e,i){if(!k(e)||!1===e.visible||0===e.opacity)return;let a;const{boxBounds:s}=i.__layout,{type:n}=e;switch(n){case"image":case"film":case"video":if(!e.url)return;a=U.image(i,t,e,s,!kt||!kt[e.url]),"image"!==n&&U[n](a);break;case"linear":a=q.linearGradient(e,s);break;case"radial":a=q.radialGradient(e,s);break;case"angular":a=q.conicGradient(e,s);break;case"solid":const{color:r,opacity:o}=e;a={type:n,style:G.string(r,o)};break;default:L(e.r)||(a={type:"solid",style:G.string(e)})}if(a&&(a.originPaint=e,T(a.style)&&Et(a.style)&&(a.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;a.strokeStyle=e.style}return a}const Lt={compute:function(t,e){const i=e.__,a=[];let s,n,r,o=i.__input[t];m(o)||(o=[o]),kt=U.recycleImage(t,i);for(let i,s=0,n=o.length;s<n;s++)(i=Rt(t,o[s],e))&&(a.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=a.length?a:void 0,a.length?(a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(s=!0),n=!0),"fill"===t?(Bt(i,"__isAlphaPixelFill",s),Bt(i,"__isTransparentFill",n)):(Bt(i,"__isAlphaPixelStroke",s),Bt(i,"__isTransparentStroke",n),Bt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,a){i.fillStyle=t,ut(e,i,a)},fills:function(t,e,i,a){let s,n,r;for(let o=0,l=t.length;o<l;o++){if(s=t[o],n=s.originPaint,s.image){if(r?r++:r=1,U.checkImage(s,!e.__.__font,e,i,a))continue;if(!s.style){1===r&&s.image.isPlacehold&&e.drawImagePlaceholder(s,i,a);continue}}if(i.fillStyle=s.style,s.transform||n.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),n.scaleFixed){const{scaleX:t,scaleY:a}=e.getRenderScaleData(!0,n.scaleFixed,!1);1!==t&&i.scale(t,a)}n.blendMode&&(i.blendMode=n.blendMode),ut(e,i,a),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),ut(e,i,a),i.restoreBlendMode()):ut(e,i,a)}},fillPathOrText:ut,fillText:function(t,e,i){const a=t.__,{rows:s,decorationY:n}=a.__textDrawData;let r;a.__isPlacehold&&a.placeholderColor&&(e.fillStyle=a.placeholderColor);for(let t=0,i=s.length;t<i;t++)r=s[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(n){const{decorationColor:t,decorationHeight:i}=a.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(a=>e.fillRect(t.x,t.y+a,t.width,i)))}},stroke:function(t,e,i,a){const s=e.__;if(s.__strokeWidth)if(s.__font)X.strokeText(t,e,i,a);else switch(s.strokeAlign){case"center":ft(t,1,e,i,a);break;case"inside":!function(t,e,i,a){i.save(),i.clipUI(e),ft(t,2,e,i,a),i.restore()}(t,e,i,a);break;case"outside":!function(t,e,i,a){const s=e.__;if(s.__fillAfterStroke)ft(t,2,e,i,a);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),ft(t,2,e,r,a),r.clipUI(s),r.clearWorld(n),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,a)}},strokes:function(t,e,i,a){X.stroke(t,e,i,a)},strokeText:function(t,e,i,a){switch(e.__.strokeAlign){case"center":gt(t,1,e,i,a);break;case"inside":pt(t,"inside",e,i,a);break;case"outside":e.__.__fillAfterStroke?gt(t,2,e,i,a):pt(t,"outside",e,i,a)}},drawTextStroke:function(t,e,i){let a,s=t.__.__textDrawData;const{rows:n,decorationY:r}=s;for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.strokeText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.strokeText(t.char,t.x,a.y)});if(r){const{decorationHeight:t}=s;n.forEach(i=>r.forEach(a=>e.strokeRect(i.x,i.y+a,i.width,t)))}},drawStrokesStyle:function(t,e,i,a,s,n){let r;const o=a.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!U.checkImage(r,!1,a,s,n))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):s.setStroke(r.style,o.__strokeWidth*e,o)}else s.strokeStyle=r.style;r.originPaint.blendMode?(s.saveBlendMode(r.originPaint.blendMode),i?X.drawTextStroke(a,s,n):s.stroke(),s.restoreBlendMode()):i?X.drawTextStroke(a,s,n):s.stroke()}},shape:function(t,i,a){const s=i.getSameCanvas(),n=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;wt(o.strokeSpread?(mt(bt,o.boxBounds,o.strokeSpread),bt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=s,d=f=l,c=r;else{let s;if(e.fullImageShadow)s=l;else{const t=o.renderShapeSpread?_t(n,E.swapAndScale(o.renderShapeSpread,p,_)):n;s=St(t,l)}u=n.getFitMatrix(s);let{a:m,d:w}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,a),p*=m,_*=w),f=yt(l,u),d=xt(f,-u.e,-u.f),c=yt(r,u),vt(c,-u.e,-u.f);const y=a.matrix;y?(h=new R(u),h.multiply(y),m*=y.scaleX,w*=y.scaleY):h=u,h.withScale(m,w),a=Object.assign(Object.assign({},a),{matrix:h})}return t.__renderShape(s,a),{canvas:s,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Tt,At=new _;const{isSame:Pt}=B;function Ot(t,e,i,a,s,n){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=a.width/o.pixelRatio,o.__naturalHeight=a.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate("width"),f.updateBounds(t),t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),!s.data){U.createData(s,a,i,n);const{transform:t}=s.data,{opacity:e,blendMode:r}=i,l=t&&!t.onlyScale||o.path||o.cornerRadius;(l||e&&e<1||r)&&(s.complex=!l||2)}return i.filter&&U.applyFilter(s,a,i.filter,t),r}function Ct(t,e){Dt(t,A.LOAD,e)}function Wt(t,e){Dt(t,A.LOADED,e)}function Mt(t,e,i){e.error=i,t.forceUpdate("surface"),Dt(t,A.ERROR,e)}function Dt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function It(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ft,translate:Yt}=P,Xt=new _,Ut={},Gt={};function qt(t,e,i,a){const s=T(t)||a?(a?i-a*e:i%e)/((a||Math.floor(i/e))-1):t;return"auto"===t&&s<0?0:s}let zt={},Nt=D();const{get:jt,set:Ht,rotateOfOuter:Vt,translate:Qt,scaleOfOuter:Zt,multiplyParent:$t,scale:Jt,rotate:Kt,skew:te}=P;function ee(t,e,i,a,s,n,r,o){r&&Kt(t,r),o&&te(t,o.x,o.y),s&&Jt(t,s,n),Qt(t,e.x+i,e.y+a)}const{get:ie,scale:ae,copy:se}=P,{getFloorScale:ne}=O,{abs:re}=Math;const oe={image:function(t,e,i,a,s){let n,r;const o=S.get(i,i.type);return Tt&&i===Tt.paint&&Pt(a,Tt.boxBounds)?n=Tt.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Tt=o.use>1?{leafPaint:n,paint:i,boxBounds:At.set(a)}:null),(s||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Ot(t,e,i,o,n,a),s&&(Ct(t,r),Wt(t,r))):o.error?s&&Mt(t,r,o.error):(s&&(It(t,!0),Ct(t,r)),n.loadId=o.load(()=>{It(t,!1),t.destroyed||(Ot(t,e,i,o,n,a)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Wt(t,r)),n.loadId=void 0},e=>{It(t,!1),Mt(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,i,a,s,n){const{scaleX:r,scaleY:o}=U.getImageRenderScaleData(t,a,s,n),l=t.film?t.nowIndex:r+"-"+o,{image:d,data:c,originPaint:h}=t,{exporting:u,snapshot:f}=n;return!(!c||t.patternId===l&&!u||f)&&(i&&(c.repeat?i=!1:h.changeful||t.film||"miniapp"===e.name||u||(i=e.image.isLarge(d,r,o)||d.width*r>8096||d.height*o>8096)),i?(a.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),U.drawImage(t,r,o,a,s,n),!0):(!t.style||h.sync||u?U.createPattern(t,a,s,n):U.createPatternTask(t,a,s,n),!1))},drawImage:function(t,e,i,a,s,n){const{data:r,image:o,complex:l}=t;let{width:d,height:c}=o;if(l){const{blendMode:n,opacity:h}=t.originPaint,{transform:u}=r;s.save(),2===l&&s.clipUI(a),n&&(s.blendMode=n),h&&(s.opacity*=h),u&&s.transform(u),o.render(s,0,0,d,c,a,t,e,i),s.restore()}else r.scaleX&&(d*=r.scaleX,c*=r.scaleY),o.render(s,0,0,d,c,a,t,e,i)},getImageRenderScaleData:function(t,e,i,a){const s=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(i){const{pixelRatio:t}=i;s.scaleX*=t,s.scaleY*=t}return n&&n.scaleX&&(s.scaleX*=Math.abs(n.scaleX),s.scaleY*=Math.abs(n.scaleY)),s},recycleImage:function(t,e){const i=e["_"+t];if(m(i)){let a,s,n,r,o;for(let l=0,d=i.length;l<d;l++)a=i[l],s=a.image,o=s&&s.url,o&&(n||(n={}),n[o]=!0,S.recyclePaint(a),e.__willDestroy&&s.parent&&U.recycleFilter(s,e.__leaf),s.loading&&(r||(r=e.__input&&e.__input[t]||[],m(r)||(r=[r])),s.unload(i[l].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,a){t.patternTask||(t.patternTask=S.patternTasker.add(()=>V(this,void 0,void 0,function*(){U.createPattern(t,e,i,a),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,a,s){let{scaleX:n,scaleY:r}=U.getImageRenderScaleData(t,i,a,s),o=t.film?t.nowIndex:n+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:a,data:s}=t,{opacity:l}=t.originPaint,{transform:d,gap:c}=s,h=U.getPatternFixScale(t,n,r);let u,f,g,{width:p,height:_}=a;h&&(n*=h,r*=h),p*=n,_*=r,c&&(f=c.x*n/re(s.scaleX||1),g=c.y*r/re(s.scaleY||1)),(d||1!==n||1!==r)&&(n*=ne(p+(f||0)),r*=ne(_+(g||0)),u=ie(),d&&se(u,d),ae(u,1/n,1/r));const m=a.getCanvas(p,_,l,void 0,f,g,i.leafer&&i.leafer.config.smooth,s.interlace),w=a.getPattern(m,s.repeat||e.origin.noRepeat||"no-repeat",u,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,a){const{image:s}=t;let n,r=e.image.maxPatternSize,o=s.width*s.height;return s.isSVG?i>1&&(n=Math.ceil(i)/i):r>o&&(r=o),(o*=i*a)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,a){t.data=U.getPatternData(i,a,e)},getPatternData:function(t,e,i){t.padding&&(e=Xt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:s}=i,{mode:n,align:r,offset:o,scale:l,size:d,rotation:c,skew:h,clipSize:u,repeat:f,gap:g,interlace:p}=t,_=e.width===a&&e.height===s,m={mode:n},w="center"!==r&&(c||0)%180==90;let y,x;switch(B.set(Gt,0,0,w?s:a,w?a:s),n&&"cover"!==n&&"fit"!==n?((l||d)&&(O.getScaleData(l,d,i,Ut),y=Ut.scaleX,x=Ut.scaleY),(r||g||f)&&(y&&B.scale(Gt,y,x,!0),r&&C.toPoint(r,Gt,e,Gt,!0,!0))):_&&!c||(y=x=B.getFitScale(e,Gt,"fit"!==n),B.put(e,i,r,y,!1,Gt),B.scale(Gt,y,x,!0)),o&&W.move(Gt,o),n){case"stretch":_?y&&(y=x=void 0):(y=e.width/a,x=e.height/s,U.stretchMode(m,e,y,x));break;case"normal":case"clip":if(Gt.x||Gt.y||y||u||c||h){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),U.clipMode(m,e,Gt.x,Gt.y,y,x,c,h,t,i),t&&(y=y?y*t:t,x=x?x*i:i)}break;case"repeat":(!_||y||c||h)&&U.repeatMode(m,e,a,s,Gt.x,Gt.y,y,x,c,h,r,t.freeTransform),f||(m.repeat="repeat");const i=k(f);(g||i)&&(m.gap=function(t,e,i,a,s){let n,r;k(t)?(n=t.x,r=t.y):n=r=t;return{x:qt(n,i,s.width,e&&e.x),y:qt(r,a,s.height,e&&e.y)}}(g,i&&f,Gt.width,Gt.height,e));break;default:y&&U.fillOrFitMode(m,e,Gt.x,Gt.y,y,x,c)}return m.transform||(e.x||e.y)&&Yt(m.transform=Ft(),e.x,e.y),y&&(m.scaleX=y,m.scaleY=x),f&&(m.repeat=T(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),p&&(m.interlace=M(p)||"percent"===p.type?{type:"x",offset:p}:p),m},stretchMode:function(t,e,i,a){const s=jt(),{x:n,y:r}=e;n||r?Qt(s,n,r):i>0&&a>0&&(s.onlyScale=!0),Jt(s,i,a),t.transform=s},fillOrFitMode:function(t,e,i,a,s,n,r){const o=jt();Qt(o,e.x+i,e.y+a),Jt(o,s,n),r&&Vt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,a,s,n,r,o,l,d){const c=jt();ee(c,e,i,a,s,n,r,o),l&&(r||o?(Ht(Nt),Zt(Nt,e,l,d),$t(c,Nt)):Zt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,a,s,n,r,o,l,d,c,h){const u=jt();if(h)ee(u,e,s,n,r,o,l,d);else{if(l)if("center"===c)Vt(u,{x:i/2,y:a/2},l);else switch(Kt(u,l),l){case 90:Qt(u,a,0);break;case 180:Qt(u,i,a);break;case 270:Qt(u,0,i)}zt.x=e.x+s,zt.y=e.y+n,Qt(u,zt.x,zt.y),r&&Zt(u,zt,r,o)}t.transform=u}},{toPoint:le}=I,{hasTransparent:de}=G,ce={},he={};function ue(t,e,i,a){if(i){let s,n,r,o;for(let t=0,l=i.length;t<l;t++)s=i[t],T(s)?(r=t/(l-1),n=G.string(s,a)):(r=s.offset,n=G.string(s.color,a)),e.addColorStop(r,n),!o&&de(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:fe,getDistance:ge}=W,{get:pe,rotateOfOuter:_e,scaleOfOuter:me}=P,{toPoint:we}=I,ye={},xe={};function ve(t,e,i,a,s){let n;const{width:r,height:o}=t;if(r!==o||a){const t=fe(e,i);n=pe(),s?(me(n,e,r/o*(a||1),1),_e(n,e,t+90)):(me(n,e,1,r/o*(a||1)),_e(n,e,t))}return n}const{getDistance:Se}=W,{toPoint:be}=I,ke={},Be={};const Ee={linearGradient:function(t,i){let{from:a,to:s,type:n,opacity:r}=t;le(a||"top",i,ce),le(s||"bottom",i,he);const o=e.canvas.createLinearGradient(ce.x,ce.y,he.x,he.y),l={type:n,style:o};return ue(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:a,to:s,type:n,opacity:r,stretch:o}=t;we(a||"center",i,ye),we(s||"bottom",i,xe);const l=e.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,ge(ye,xe)),d={type:n,style:l};ue(d,l,t.stops,r);const c=ve(i,ye,xe,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:a,to:s,type:n,opacity:r,rotation:o,stretch:l}=t;be(a||"center",i,ke),be(s||"bottom",i,Be);const d=e.conicGradientSupport?e.canvas.createConicGradient(o?o*F:0,ke.x,ke.y):e.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Se(ke,Be)),c={type:n,style:d};ue(c,d,t.stops,r);const h=ve(i,ke,Be,l||1,e.conicGradientRotate90);return h&&(c.transform=h),c},getTransform:ve},{copy:Re,move:Le,toOffsetOutBounds:Te}=B,{max:Ae,abs:Pe}=Math,Oe={},Ce=new R,We={};function Me(t,e){let i,a,s,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,a=t.y||0,n=1.5*(t.blur||0),s=Pe(t.spread||0),r=Ae(r,s+n-a),o=Ae(o,s+n+i),l=Ae(l,s+n+a),d=Ae(d,s+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function De(t,i,a){const{shapeBounds:s}=a;let n,r;e.fullImageShadow?(Re(Oe,t.bounds),Le(Oe,i.x-s.x,i.y-s.y),n=t.bounds,r=Oe):(n=s,r=i),t.copyWorld(a.canvas,n,r)}const{toOffsetOutBounds:Ie}=B,Fe={};const Ye=Me;const Xe={shadow:function(t,e,i){let a,s;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Te(l,We,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.setWorldShadow(We.offsetX+(r.x||0)*h*m,We.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m,G.string(r.color)),s=z.getShadowTransform(t,g,i,r,We,m),s&&g.setTransform(s),De(g,We,i),s&&g.resetTransform(),a=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),a=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,a,r.blendMode),p&&_<p&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(t,e,i){let a,s;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ie(l,Fe,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.save(),g.setWorldShadow(Fe.offsetX+(r.x||0)*h*m,Fe.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m),s=z.getShadowTransform(t,g,i,r,Fe,m,!0),s&&g.setTransform(s),De(g,Fe,i),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),a=n):(g.copyWorld(i.canvas,c,l,"source-out"),a=d),g.fillWorld(a,G.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,a,r.blendMode),p&&_<p&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:a}=t.__;i.setWorldBlur(a*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Me,getShadowTransform:function(t,e,i,a,s,n,r){if(a.spread){const i=2*a.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Ce.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/o,1+i/l),Ce}},isTransformShadow(t){},getInnerShadowSpread:Ye},{excludeRenderBounds:Ue}=p;let Ge;function qe(t,e,i,a,s,n,r,o){switch(e){case"grayscale":Ge||(Ge=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,a,s,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(a,r),n&&a.recycle(r);Ne(t,e,i,1,s,n)}(t,i,a,s,r,o);break;case"opacity-path":Ne(t,i,a,n,r,o);break;case"path":o&&i.restore()}}function ze(t){return t.getSameCanvas(!1,!0)}function Ne(t,e,i,a,s,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(i,r,void 0,s),n?i.recycle(r):i.clearWorld(r)}N.prototype.__renderMask=function(t,e){let i,a,s,n,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&&(qe(this,r,t,s,a,n,void 0,!0),a=s=null),"clipping"!==o&&"clipping-path"!==o||Ue(i,e)||i.__render(t,e),n=i.__.opacity,Ge=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",s||(s=ze(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=ze(t)),s||(s=ze(t)),i.__render(a,e));continue}const c=1===n&&i.__.__blendMode;c&&qe(this,r,t,s,a,n,void 0,!1),Ue(i,e)||i.__render(s||t,e),c&&qe(this,r,t,s,a,n,c,!1)}qe(this,r,t,s,a,n,void 0,!0)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",He=je+"_#~&*+\\=|≮≯≈≠=…",Ve=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 Qe(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Ze=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Je=Qe(je),Ke=Qe(He),ti=Qe("- —/~|┆·");var ei;!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"}(ei||(ei={}));const{Letter:ii,Single:ai,Before:si,After:ni,Symbol:ri,Break:oi}=ei;function li(t){return Ze[t]?ii:ti[t]?oi:$e[t]?si:Je[t]?ni:Ke[t]?ri:Ve.test(t)?ai:ii}const di={trimRight(t){const{words:e}=t;let i,a=0,s=e.length;for(let n=s-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)a++,t.width-=i.width;a&&e.splice(s-a,a)}};function ci(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:hi}=di,{Letter:ui,Single:fi,Before:gi,After:pi,Symbol:_i,Break:mi}=ei;let wi,yi,xi,vi,Si,bi,ki,Bi,Ei,Ri,Li,Ti,Ai,Pi,Oi,Ci,Wi,Mi=[];function Di(t,e){Ei&&!Bi&&(Bi=Ei),wi.data.push({char:t,width:e}),xi+=e}function Ii(){vi+=xi,wi.width=xi,yi.words.push(wi),wi={data:[]},xi=0}function Fi(){Pi&&(Oi.paraNumber++,yi.paraStart=!0,Pi=!1),Ei&&(yi.startCharSize=Bi,yi.endCharSize=Ei,Bi=0),yi.width=vi,Ci.width?hi(yi):Wi&&Yi(),Mi.push(yi),yi={words:[]},vi=0}function Yi(){vi>(Oi.maxWidth||0)&&(Oi.maxWidth=vi)}const{top:Xi,right:Ui,bottom:Gi,left:qi}=Y;function zi(t,e,i){const{bounds:a,rows:s}=t;a[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ni={getDrawData:function(t,i){T(t)||(t=String(t));let a=0,s=0,n=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(n?(a=o[qi],n-=o[Ui]+o[qi],!n&&(n=.01)):i.autoSizeAlign||(a=o[qi]),r?(s=o[Xi],r-=o[Xi]+o[Gi],!r&&(r=.01)):i.autoSizeAlign||(s=o[Xi]));const l={bounds:{x:a,y:s,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,a){Oi=t,Mi=t.rows,Ci=t.bounds,Wi=!Ci.width&&!a.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:r}=a,{canvas:o}=e,{width:l}=Ci;if(a.__isCharMode){const t="none"!==a.textWrap,e="break"===a.textWrap;Pi=!0,Li=null,Bi=ki=Ei=xi=vi=0,wi={data:[]},yi={words:[]};for(let a=0,d=(i=[...i]).length;a<d;a++)bi=i[a],"\n"===bi?(xi&&Ii(),yi.paraEnd=!0,Fi(),Pi=!0):(Ri=li(bi),Ri===ui&&"none"!==r&&(bi=ci(bi,r,!xi)),ki=o.measureText(bi).width,s&&(s<0&&(Ei=ki),ki+=s),Ti=Ri===fi&&(Li===fi||Li===ui)||Li===fi&&Ri!==pi,Ai=!(Ri!==gi&&Ri!==fi||Li!==_i&&Li!==pi),Si=Pi&&n?l-n:l,t&&l&&vi+xi+ki>Si&&(e?(xi&&Ii(),vi&&Fi()):(Ai||(Ai=Ri===ui&&Li==pi),Ti||Ai||Ri===mi||Ri===gi||Ri===fi||xi+ki>Si?(xi&&Ii(),vi&&Fi()):vi&&Fi()))," "===bi&&!0!==Pi&&vi+xi===0||(Ri===mi?(" "===bi&&xi&&Ii(),Di(bi,ki),Ii()):Ti||Ai?(xi&&Ii(),Di(bi,ki)):Di(bi,ki)),Li=Ri);xi&&Ii(),vi&&Fi(),Mi.length>0&&(Mi[Mi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Oi.paraNumber++,vi=o.measureText(t).width,Mi.push({x:n||0,text:t,width:vi,paraStart:!0}),Wi&&Yi()})}(l,t,i),o&&function(t,e,i,a,s){if(!a&&i.autoSizeAlign)switch(i.textAlign){case"left":zi(e,"x",t[qi]);break;case"right":zi(e,"x",-t[Ui])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":zi(e,"y",t[Xi]);break;case"bottom":zi(e,"y",-t[Gi])}}(o,l,i,n,r),function(t,e){const{rows:i,bounds:a}=t,s=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=a,m=n*s+(h?h*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(e.__autoHeight?m:_,n),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":g+=(_-m)/2;break;case"bottom":g+=_-m}w+=g;let y,x,v,S=p||u?p:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=i[r],y.x=f,y.width<p||y.width>p&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=n,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<a.x&&(a.x=x),v>a.width&&(a.width=v),l&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}a.y=g,a.height=m}(l,i),i.__isCharMode&&function(t,e,i){const{rows:a}=t,{textAlign:s,paraIndent:n,__letterSpacing:r}=e,o=i&&s.includes("both"),l=o||i&&s.includes("justify"),d=l&&s.includes("letter");let c,h,u,f,g,p,_,m,w,y;a.forEach(t=>{t.words&&(g=n&&t.paraStart?n:0,m=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?h/(m-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,a,s){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(w=i===m-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(l,i,n),l.overflow&&function(t,i,a,s){const{rows:n,overflow:r}=t;let{textOverflow:o}=i;if(r&&n.splice(r),s&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=a+s-d;("none"===i.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let a=i;a>-1&&(t=e.data[a],l=t.x+t.width,!(a===i&&l<c));a--){if(l<c&&" "!==t.char||!a){e.data.splice(a+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,a,n),"none"!==i.textDecoration&&function(t,e){let i,a=0;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,k(n)?(i=n.type,n.color&&(t.decorationColor=G.string(n.color)),n.offset&&(a=Math.min(.3*s,Math.max(n.offset,.15*-s)))):i=n,i){case"under":t.decorationY=[.15*s+a];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s+a,.35*-s]}}(l,i),l}};const ji={string:function(t,e){if(!t)return"#000";const i=M(e)&&e<1;if(T(t)){if(!i||!G.object)return t;t=G.object(t)}let a=L(t.a)?1:t.a;i&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(j,Ni),Object.assign(G,ji),Object.assign(X,Lt),Object.assign(U,oe),Object.assign(q,Ee),Object.assign(z,Xe),Z();export{dt as Layouter,Q as LeaferCanvas,H as PathNodeHandleType,ht as Renderer,J as Watcher,Z as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as a,LeaferImage as s,defineKey as n,FileHelper as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as m,Debug as w,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as E,Matrix as R,isUndefined as L,isString as T,ImageEvent as A,MatrixHelper as P,MathHelper as O,AlignHelper as C,PointHelper as W,isNumber as M,getMatrixData as D,AroundHelper as I,OneRadian as F,Direction4 as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as X,PaintImage as U,ColorConvert as G,PaintGradient as q,Effect as z,Group as N,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var H;function V(t,e,i,a){return new(i||(i=Promise))(function(s,n){function r(t){try{l(a.next(t))}catch(t){n(t)}}function o(t){try{l(a.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(H||(H={})),"function"==typeof SuppressedError&&SuppressedError;class Q extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function Z(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((a,s)=>{t.convertToBlob({type:r.mimeType(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)}).catch(t=>{s(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:r.mimeType(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:(t,i,a)=>new Promise((i,a)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then(t=>{i(t)}).catch(t=>{a(t)})},s.onerror=t=>a(t),s.send()}),loadContent(t){return V(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype),Object.assign(a,{canvas:(t,e)=>new Q(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},n(e,"devicePixelRatio",{get:()=>1});const{userAgent:$}=navigator;$.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),$.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):$.indexOf("Mac")>-1?e.os="Mac":$.indexOf("Linux")>-1&&(e.os="Linux");class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:tt,updateChange:et}=f,{pushAllChildBranch:it,pushAllParent:at}=g;const{worldBounds:st}=p;class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,m(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),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:rt,updateAllChange:ot}=f,lt=w.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){lt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?lt.warn("layouting"):this.times>3?lt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:s,LAYOUT:n,AFTER:r}=x,o=this.getBlocks(a);o.forEach(t=>t.setBefore()),i.emitEvent(new x(s,o,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?(K(t,!0),e.add(t),t.isBranch&&it(t,e),at(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),at(t,e)))})}(a,this.__levelList),function(t){let e,i,a;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){a=i.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||tt(a[t])}tt(i)}})}(this.__levelList),function(t){t.list.forEach(et)}(a),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(n,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=x,n=this.getBlocks(new o(e));e.emitEvent(new x(i,n,this.times)),dt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new x(a,n,this.times)),e.emitEvent(new x(s,n,this.times)),this.addBlocks(n),v.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=w.get("Renderer");class ht{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ct.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,a=t.getIntersect(i.bounds),s=new _(a);i.save(),a.spread(ht.clipSpread).ceil();const{ceilPartPixel:n}=this.config;i.clipWorld(a,n),i.clearWorld(a,n),this.__render(a,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:a,target:s}=this,n=t.includes(s.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&a.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(a,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(s,a,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),a.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:a}=this.config;if(a&&t>a)return e.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ut(t,e,i){t.__.__font?X.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ft(t,e,i,a,s){const n=i.__;k(t)?X.drawStrokesStyle(t,e,!1,i,a,s):(a.setStroke(t,n.__strokeWidth*e,n),a.stroke()),n.__useArrow&&X.strokeArrow(t,i,a,s)}function gt(t,e,i,a,s){const n=i.__;k(t)?X.drawStrokesStyle(t,e,!0,i,a,s):(a.setStroke(t,n.__strokeWidth*e,n),X.drawTextStroke(i,a,s))}function pt(t,e,i,a,s){const n=a.getSameCanvas(!0,!0);n.font=i.__.__font,gt(t,2,i,n,s),n.blendMode="outside"===e?"destination-out":"destination-in",X.fillText(i,n,s),n.blendMode="normal",f.copyCanvasByWorld(i,a,n),n.recycle(i.__nowWorld)}ht.clipSpread=10,Object.assign(a,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new ht(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,a)=>{}}),e.layout=dt.fullLayout,e.render=function(t,e,i){const a=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,a))};const{getSpread:_t,copyAndSpread:mt,toOuterOf:wt,getOuterOf:yt,getByMove:xt,move:vt,getIntersectData:St}=B,bt={};let kt;const{stintSet:Bt}=l,{hasTransparent:Et}=G;function Rt(t,e,i){if(!k(e)||!1===e.visible||0===e.opacity)return;let a;const{boxBounds:s}=i.__layout,{type:n}=e;switch(n){case"image":case"film":case"video":if(!e.url)return;a=U.image(i,t,e,s,!kt||!kt[e.url]),"image"!==n&&U[n](a);break;case"linear":a=q.linearGradient(e,s);break;case"radial":a=q.radialGradient(e,s);break;case"angular":a=q.conicGradient(e,s);break;case"solid":const{color:r,opacity:o}=e;a={type:n,style:G.string(r,o)};break;default:L(e.r)||(a={type:"solid",style:G.string(e)})}if(a&&(a.originPaint=e,T(a.style)&&Et(a.style)&&(a.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;a.strokeStyle=e.style}return a}const Lt={compute:function(t,e){const i=e.__,a=[];let s,n,r,o=i.__input[t];m(o)||(o=[o]),kt=U.recycleImage(t,i);for(let i,s=0,n=o.length;s<n;s++)(i=Rt(t,o[s],e))&&(a.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=a.length?a:void 0,a.length?(a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(s=!0),n=!0),"fill"===t?(Bt(i,"__isAlphaPixelFill",s),Bt(i,"__isTransparentFill",n)):(Bt(i,"__isAlphaPixelStroke",s),Bt(i,"__isTransparentStroke",n),Bt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,a){i.fillStyle=t,ut(e,i,a)},fills:function(t,e,i,a){let s,n,r;for(let o=0,l=t.length;o<l;o++){if(s=t[o],n=s.originPaint,s.image){if(r?r++:r=1,U.checkImage(s,!e.__.__font,e,i,a))continue;if(!s.style){1===r&&s.image.isPlacehold&&e.drawImagePlaceholder(s,i,a);continue}}if(i.fillStyle=s.style,s.transform||n.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),n.scaleFixed){const{scaleX:t,scaleY:a}=e.getRenderScaleData(!0,n.scaleFixed,!1);1!==t&&i.scale(t,a)}n.blendMode&&(i.blendMode=n.blendMode),ut(e,i,a),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),ut(e,i,a),i.restoreBlendMode()):ut(e,i,a)}},fillPathOrText:ut,fillText:function(t,e,i){const a=t.__,{rows:s,decorationY:n}=a.__textDrawData;let r;a.__isPlacehold&&a.placeholderColor&&(e.fillStyle=a.placeholderColor);for(let t=0,i=s.length;t<i;t++)r=s[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(n){const{decorationColor:t,decorationHeight:i}=a.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(a=>e.fillRect(t.x,t.y+a,t.width,i)))}},stroke:function(t,e,i,a){const s=e.__;if(s.__strokeWidth)if(s.__font)X.strokeText(t,e,i,a);else if(s.__pathForStroke)X.fillStroke(t,e,i,a);else switch(s.strokeAlign){case"center":ft(t,1,e,i,a);break;case"inside":!function(t,e,i,a){i.save(),i.clipUI(e),ft(t,2,e,i,a),i.restore()}(t,e,i,a);break;case"outside":!function(t,e,i,a){const s=e.__;if(s.__fillAfterStroke)ft(t,2,e,i,a);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),ft(t,2,e,r,a),r.clipUI(s),r.clearWorld(n),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,a)}},strokes:function(t,e,i,a){X.stroke(t,e,i,a)},strokeText:function(t,e,i,a){switch(e.__.strokeAlign){case"center":gt(t,1,e,i,a);break;case"inside":pt(t,"inside",e,i,a);break;case"outside":e.__.__fillAfterStroke?gt(t,2,e,i,a):pt(t,"outside",e,i,a)}},drawTextStroke:function(t,e,i){let a,s=t.__.__textDrawData;const{rows:n,decorationY:r}=s;for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.strokeText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.strokeText(t.char,t.x,a.y)});if(r){const{decorationHeight:t}=s;n.forEach(i=>r.forEach(a=>e.strokeRect(i.x,i.y+a,i.width,t)))}},drawStrokesStyle:function(t,e,i,a,s,n){let r;const o=a.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!U.checkImage(r,!1,a,s,n))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):s.setStroke(r.style,o.__strokeWidth*e,o)}else s.strokeStyle=r.style;r.originPaint.blendMode?(s.saveBlendMode(r.originPaint.blendMode),i?X.drawTextStroke(a,s,n):s.stroke(),s.restoreBlendMode()):i?X.drawTextStroke(a,s,n):s.stroke()}},shape:function(t,i,a){const s=i.getSameCanvas(),n=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;wt(o.strokeSpread?(mt(bt,o.boxBounds,o.strokeSpread),bt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=s,d=f=l,c=r;else{let s;if(e.fullImageShadow)s=l;else{const t=o.renderShapeSpread?_t(n,E.swapAndScale(o.renderShapeSpread,p,_)):n;s=St(t,l)}u=n.getFitMatrix(s);let{a:m,d:w}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,a),p*=m,_*=w),f=yt(l,u),d=xt(f,-u.e,-u.f),c=yt(r,u),vt(c,-u.e,-u.f);const y=a.matrix;y?(h=new R(u),h.multiply(y),m*=y.scaleX,w*=y.scaleY):h=u,h.withScale(m,w),a=Object.assign(Object.assign({},a),{matrix:h})}return t.__renderShape(s,a),{canvas:s,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Tt,At=new _;const{isSame:Pt}=B;function Ot(t,e,i,a,s,n){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=a.width/o.pixelRatio,o.__naturalHeight=a.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate("width"),f.updateBounds(t),t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),!s.data){U.createData(s,a,i,n);const{transform:t}=s.data,{opacity:e,blendMode:r}=i,l=t&&!t.onlyScale||o.path||o.cornerRadius;(l||e&&e<1||r)&&(s.complex=!l||2)}return i.filter&&U.applyFilter(s,a,i.filter,t),r}function Ct(t,e){Dt(t,A.LOAD,e)}function Wt(t,e){Dt(t,A.LOADED,e)}function Mt(t,e,i){e.error=i,t.forceUpdate("surface"),Dt(t,A.ERROR,e)}function Dt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function It(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ft,translate:Yt}=P,Xt=new _,Ut={},Gt={};function qt(t,e,i,a){const s=T(t)||a?(a?i-a*e:i%e)/((a||Math.floor(i/e))-1):t;return"auto"===t&&s<0?0:s}let zt={},Nt=D();const{get:jt,set:Ht,rotateOfOuter:Vt,translate:Qt,scaleOfOuter:Zt,multiplyParent:$t,scale:Jt,rotate:Kt,skew:te}=P;function ee(t,e,i,a,s,n,r,o){r&&Kt(t,r),o&&te(t,o.x,o.y),s&&Jt(t,s,n),Qt(t,e.x+i,e.y+a)}const{get:ie,scale:ae,copy:se}=P,{getFloorScale:ne}=O,{abs:re}=Math;const oe={image:function(t,e,i,a,s){let n,r;const o=S.get(i,i.type);return Tt&&i===Tt.paint&&Pt(a,Tt.boxBounds)?n=Tt.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Tt=o.use>1?{leafPaint:n,paint:i,boxBounds:At.set(a)}:null),(s||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Ot(t,e,i,o,n,a),s&&(Ct(t,r),Wt(t,r))):o.error?s&&Mt(t,r,o.error):(s&&(It(t,!0),Ct(t,r)),n.loadId=o.load(()=>{It(t,!1),t.destroyed||(Ot(t,e,i,o,n,a)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Wt(t,r)),n.loadId=void 0},e=>{It(t,!1),Mt(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,i,a,s,n){const{scaleX:r,scaleY:o}=U.getImageRenderScaleData(t,a,s,n),l=t.film?t.nowIndex:r+"-"+o,{image:d,data:c,originPaint:h}=t,{exporting:u,snapshot:f}=n;return!(!c||t.patternId===l&&!u||f)&&(i&&(c.repeat?i=!1:h.changeful||t.film||"miniapp"===e.name||u||(i=e.image.isLarge(d,r,o)||d.width*r>8096||d.height*o>8096)),i?(a.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),U.drawImage(t,r,o,a,s,n),!0):(!t.style||h.sync||u?U.createPattern(t,a,s,n):U.createPatternTask(t,a,s,n),!1))},drawImage:function(t,e,i,a,s,n){const{data:r,image:o,complex:l}=t;let{width:d,height:c}=o;if(l){const{blendMode:n,opacity:h}=t.originPaint,{transform:u}=r;s.save(),2===l&&s.clipUI(a),n&&(s.blendMode=n),h&&(s.opacity*=h),u&&s.transform(u),o.render(s,0,0,d,c,a,t,e,i),s.restore()}else r.scaleX&&(d*=r.scaleX,c*=r.scaleY),o.render(s,0,0,d,c,a,t,e,i)},getImageRenderScaleData:function(t,e,i,a){const s=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(i){const{pixelRatio:t}=i;s.scaleX*=t,s.scaleY*=t}return n&&n.scaleX&&(s.scaleX*=Math.abs(n.scaleX),s.scaleY*=Math.abs(n.scaleY)),s},recycleImage:function(t,e){const i=e["_"+t];if(m(i)){let a,s,n,r,o;for(let l=0,d=i.length;l<d;l++)a=i[l],s=a.image,o=s&&s.url,o&&(n||(n={}),n[o]=!0,S.recyclePaint(a),e.__willDestroy&&s.parent&&U.recycleFilter(s,e.__leaf),s.loading&&(r||(r=e.__input&&e.__input[t]||[],m(r)||(r=[r])),s.unload(i[l].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,a){t.patternTask||(t.patternTask=S.patternTasker.add(()=>V(this,void 0,void 0,function*(){U.createPattern(t,e,i,a),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,a,s){let{scaleX:n,scaleY:r}=U.getImageRenderScaleData(t,i,a,s),o=t.film?t.nowIndex:n+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:a,data:s}=t,{opacity:l}=t.originPaint,{transform:d,gap:c}=s,h=U.getPatternFixScale(t,n,r);let u,f,g,{width:p,height:_}=a;h&&(n*=h,r*=h),p*=n,_*=r,c&&(f=c.x*n/re(s.scaleX||1),g=c.y*r/re(s.scaleY||1)),(d||1!==n||1!==r)&&(n*=ne(p+(f||0)),r*=ne(_+(g||0)),u=ie(),d&&se(u,d),ae(u,1/n,1/r));const m=a.getCanvas(p,_,l,void 0,f,g,i.leafer&&i.leafer.config.smooth,s.interlace),w=a.getPattern(m,s.repeat||e.origin.noRepeat||"no-repeat",u,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,a){const{image:s}=t;let n,r=e.image.maxPatternSize,o=s.width*s.height;return s.isSVG?i>1&&(n=Math.ceil(i)/i):r>o&&(r=o),(o*=i*a)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,a){t.data=U.getPatternData(i,a,e)},getPatternData:function(t,e,i){t.padding&&(e=Xt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:s}=i,{mode:n,align:r,offset:o,scale:l,size:d,rotation:c,skew:h,clipSize:u,repeat:f,gap:g,interlace:p}=t,_=e.width===a&&e.height===s,m={mode:n},w="center"!==r&&(c||0)%180==90;let y,x;switch(B.set(Gt,0,0,w?s:a,w?a:s),n&&"cover"!==n&&"fit"!==n?((l||d)&&(O.getScaleData(l,d,i,Ut),y=Ut.scaleX,x=Ut.scaleY),(r||g||f)&&(y&&B.scale(Gt,y,x,!0),r&&C.toPoint(r,Gt,e,Gt,!0,!0))):_&&!c||(y=x=B.getFitScale(e,Gt,"fit"!==n),B.put(e,i,r,y,!1,Gt),B.scale(Gt,y,x,!0)),o&&W.move(Gt,o),n){case"stretch":_?y&&(y=x=void 0):(y=e.width/a,x=e.height/s,U.stretchMode(m,e,y,x));break;case"normal":case"clip":if(Gt.x||Gt.y||y||u||c||h){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),U.clipMode(m,e,Gt.x,Gt.y,y,x,c,h,t,i),t&&(y=y?y*t:t,x=x?x*i:i)}break;case"repeat":(!_||y||c||h)&&U.repeatMode(m,e,a,s,Gt.x,Gt.y,y,x,c,h,r,t.freeTransform),f||(m.repeat="repeat");const i=k(f);(g||i)&&(m.gap=function(t,e,i,a,s){let n,r;k(t)?(n=t.x,r=t.y):n=r=t;return{x:qt(n,i,s.width,e&&e.x),y:qt(r,a,s.height,e&&e.y)}}(g,i&&f,Gt.width,Gt.height,e));break;default:y&&U.fillOrFitMode(m,e,Gt.x,Gt.y,y,x,c)}return m.transform||(e.x||e.y)&&Yt(m.transform=Ft(),e.x,e.y),y&&(m.scaleX=y,m.scaleY=x),f&&(m.repeat=T(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),p&&(m.interlace=M(p)||"percent"===p.type?{type:"x",offset:p}:p),m},stretchMode:function(t,e,i,a){const s=jt(),{x:n,y:r}=e;n||r?Qt(s,n,r):i>0&&a>0&&(s.onlyScale=!0),Jt(s,i,a),t.transform=s},fillOrFitMode:function(t,e,i,a,s,n,r){const o=jt();Qt(o,e.x+i,e.y+a),Jt(o,s,n),r&&Vt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,a,s,n,r,o,l,d){const c=jt();ee(c,e,i,a,s,n,r,o),l&&(r||o?(Ht(Nt),Zt(Nt,e,l,d),$t(c,Nt)):Zt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,a,s,n,r,o,l,d,c,h){const u=jt();if(h)ee(u,e,s,n,r,o,l,d);else{if(l)if("center"===c)Vt(u,{x:i/2,y:a/2},l);else switch(Kt(u,l),l){case 90:Qt(u,a,0);break;case 180:Qt(u,i,a);break;case 270:Qt(u,0,i)}zt.x=e.x+s,zt.y=e.y+n,Qt(u,zt.x,zt.y),r&&Zt(u,zt,r,o)}t.transform=u}},{toPoint:le}=I,{hasTransparent:de}=G,ce={},he={};function ue(t,e,i,a){if(i){let s,n,r,o;for(let t=0,l=i.length;t<l;t++)s=i[t],T(s)?(r=t/(l-1),n=G.string(s,a)):(r=s.offset,n=G.string(s.color,a)),e.addColorStop(r,n),!o&&de(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:fe,getDistance:ge}=W,{get:pe,rotateOfOuter:_e,scaleOfOuter:me}=P,{toPoint:we}=I,ye={},xe={};function ve(t,e,i,a,s){let n;const{width:r,height:o}=t;if(r!==o||a){const t=fe(e,i);n=pe(),s?(me(n,e,r/o*(a||1),1),_e(n,e,t+90)):(me(n,e,1,r/o*(a||1)),_e(n,e,t))}return n}const{getDistance:Se}=W,{toPoint:be}=I,ke={},Be={};const Ee={linearGradient:function(t,i){let{from:a,to:s,type:n,opacity:r}=t;le(a||"top",i,ce),le(s||"bottom",i,he);const o=e.canvas.createLinearGradient(ce.x,ce.y,he.x,he.y),l={type:n,style:o};return ue(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:a,to:s,type:n,opacity:r,stretch:o}=t;we(a||"center",i,ye),we(s||"bottom",i,xe);const l=e.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,ge(ye,xe)),d={type:n,style:l};ue(d,l,t.stops,r);const c=ve(i,ye,xe,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:a,to:s,type:n,opacity:r,rotation:o,stretch:l}=t;be(a||"center",i,ke),be(s||"bottom",i,Be);const d=e.conicGradientSupport?e.canvas.createConicGradient(o?o*F:0,ke.x,ke.y):e.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Se(ke,Be)),c={type:n,style:d};ue(c,d,t.stops,r);const h=ve(i,ke,Be,l||1,e.conicGradientRotate90);return h&&(c.transform=h),c},getTransform:ve},{copy:Re,move:Le,toOffsetOutBounds:Te}=B,{max:Ae,abs:Pe}=Math,Oe={},Ce=new R,We={};function Me(t,e){let i,a,s,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,a=t.y||0,n=1.5*(t.blur||0),s=Pe(t.spread||0),r=Ae(r,s+n-a),o=Ae(o,s+n+i),l=Ae(l,s+n+a),d=Ae(d,s+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function De(t,i,a){const{shapeBounds:s}=a;let n,r;e.fullImageShadow?(Re(Oe,t.bounds),Le(Oe,i.x-s.x,i.y-s.y),n=t.bounds,r=Oe):(n=s,r=i),t.copyWorld(a.canvas,n,r)}const{toOffsetOutBounds:Ie}=B,Fe={};const Ye=Me;const Xe={shadow:function(t,e,i){let a,s;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Te(l,We,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.setWorldShadow(We.offsetX+(r.x||0)*h*m,We.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m,G.string(r.color)),s=z.getShadowTransform(t,g,i,r,We,m),s&&g.setTransform(s),De(g,We,i),s&&g.resetTransform(),a=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),a=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,a,r.blendMode),p&&_<p&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(t,e,i){let a,s;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ie(l,Fe,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.save(),g.setWorldShadow(Fe.offsetX+(r.x||0)*h*m,Fe.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m),s=z.getShadowTransform(t,g,i,r,Fe,m,!0),s&&g.setTransform(s),De(g,Fe,i),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),a=n):(g.copyWorld(i.canvas,c,l,"source-out"),a=d),g.fillWorld(a,G.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,a,r.blendMode),p&&_<p&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:a}=t.__;i.setWorldBlur(a*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Me,getShadowTransform:function(t,e,i,a,s,n,r){if(a.spread){const i=2*a.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Ce.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/o,1+i/l),Ce}},isTransformShadow(t){},getInnerShadowSpread:Ye},{excludeRenderBounds:Ue}=p;let Ge;function qe(t,e,i,a,s,n,r,o){switch(e){case"grayscale":Ge||(Ge=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,a,s,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(a,r),n&&a.recycle(r);Ne(t,e,i,1,s,n)}(t,i,a,s,r,o);break;case"opacity-path":Ne(t,i,a,n,r,o);break;case"path":o&&i.restore()}}function ze(t){return t.getSameCanvas(!1,!0)}function Ne(t,e,i,a,s,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(i,r,void 0,s),n?i.recycle(r):i.clearWorld(r)}N.prototype.__renderMask=function(t,e){let i,a,s,n,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&&(qe(this,r,t,s,a,n,void 0,!0),a=s=null),"clipping"!==o&&"clipping-path"!==o||Ue(i,e)||i.__render(t,e),n=i.__.opacity,Ge=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",s||(s=ze(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=ze(t)),s||(s=ze(t)),i.__render(a,e));continue}const c=1===n&&i.__.__blendMode;c&&qe(this,r,t,s,a,n,void 0,!1),Ue(i,e)||i.__render(s||t,e),c&&qe(this,r,t,s,a,n,c,!1)}qe(this,r,t,s,a,n,void 0,!0)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",He=je+"_#~&*+\\=|≮≯≈≠=…",Ve=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 Qe(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Ze=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Je=Qe(je),Ke=Qe(He),ti=Qe("- —/~|┆·");var ei;!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"}(ei||(ei={}));const{Letter:ii,Single:ai,Before:si,After:ni,Symbol:ri,Break:oi}=ei;function li(t){return Ze[t]?ii:ti[t]?oi:$e[t]?si:Je[t]?ni:Ke[t]?ri:Ve.test(t)?ai:ii}const di={trimRight(t){const{words:e}=t;let i,a=0,s=e.length;for(let n=s-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)a++,t.width-=i.width;a&&e.splice(s-a,a)}};function ci(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:hi}=di,{Letter:ui,Single:fi,Before:gi,After:pi,Symbol:_i,Break:mi}=ei;let wi,yi,xi,vi,Si,bi,ki,Bi,Ei,Ri,Li,Ti,Ai,Pi,Oi,Ci,Wi,Mi=[];function Di(t,e){Ei&&!Bi&&(Bi=Ei),wi.data.push({char:t,width:e}),xi+=e}function Ii(){vi+=xi,wi.width=xi,yi.words.push(wi),wi={data:[]},xi=0}function Fi(){Pi&&(Oi.paraNumber++,yi.paraStart=!0,Pi=!1),Ei&&(yi.startCharSize=Bi,yi.endCharSize=Ei,Bi=0),yi.width=vi,Ci.width?hi(yi):Wi&&Yi(),Mi.push(yi),yi={words:[]},vi=0}function Yi(){vi>(Oi.maxWidth||0)&&(Oi.maxWidth=vi)}const{top:Xi,right:Ui,bottom:Gi,left:qi}=Y;function zi(t,e,i){const{bounds:a,rows:s}=t;a[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ni={getDrawData:function(t,i){T(t)||(t=String(t));let a=0,s=0,n=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(n?(a=o[qi],n-=o[Ui]+o[qi],!n&&(n=.01)):i.autoSizeAlign||(a=o[qi]),r?(s=o[Xi],r-=o[Xi]+o[Gi],!r&&(r=.01)):i.autoSizeAlign||(s=o[Xi]));const l={bounds:{x:a,y:s,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,a){Oi=t,Mi=t.rows,Ci=t.bounds,Wi=!Ci.width&&!a.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:r}=a,{canvas:o}=e,{width:l}=Ci;if(a.__isCharMode){const t="none"!==a.textWrap,e="break"===a.textWrap;Pi=!0,Li=null,Bi=ki=Ei=xi=vi=0,wi={data:[]},yi={words:[]};for(let a=0,d=(i=[...i]).length;a<d;a++)bi=i[a],"\n"===bi?(xi&&Ii(),yi.paraEnd=!0,Fi(),Pi=!0):(Ri=li(bi),Ri===ui&&"none"!==r&&(bi=ci(bi,r,!xi)),ki=o.measureText(bi).width,s&&(s<0&&(Ei=ki),ki+=s),Ti=Ri===fi&&(Li===fi||Li===ui)||Li===fi&&Ri!==pi,Ai=!(Ri!==gi&&Ri!==fi||Li!==_i&&Li!==pi),Si=Pi&&n?l-n:l,t&&l&&vi+xi+ki>Si&&(e?(xi&&Ii(),vi&&Fi()):(Ai||(Ai=Ri===ui&&Li==pi),Ti||Ai||Ri===mi||Ri===gi||Ri===fi||xi+ki>Si?(xi&&Ii(),vi&&Fi()):vi&&Fi()))," "===bi&&!0!==Pi&&vi+xi===0||(Ri===mi?(" "===bi&&xi&&Ii(),Di(bi,ki),Ii()):Ti||Ai?(xi&&Ii(),Di(bi,ki)):Di(bi,ki)),Li=Ri);xi&&Ii(),vi&&Fi(),Mi.length>0&&(Mi[Mi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Oi.paraNumber++,vi=o.measureText(t).width,Mi.push({x:n||0,text:t,width:vi,paraStart:!0}),Wi&&Yi()})}(l,t,i),o&&function(t,e,i,a,s){if(!a&&i.autoSizeAlign)switch(i.textAlign){case"left":zi(e,"x",t[qi]);break;case"right":zi(e,"x",-t[Ui])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":zi(e,"y",t[Xi]);break;case"bottom":zi(e,"y",-t[Gi])}}(o,l,i,n,r),function(t,e){const{rows:i,bounds:a}=t,s=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=a,m=n*s+(h?h*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(e.__autoHeight?m:_,n),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":g+=(_-m)/2;break;case"bottom":g+=_-m}w+=g;let y,x,v,S=p||u?p:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=i[r],y.x=f,y.width<p||y.width>p&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=n,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<a.x&&(a.x=x),v>a.width&&(a.width=v),l&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}a.y=g,a.height=m}(l,i),i.__isCharMode&&function(t,e,i){const{rows:a}=t,{textAlign:s,paraIndent:n,__letterSpacing:r}=e,o=i&&s.includes("both"),l=o||i&&s.includes("justify"),d=l&&s.includes("letter");let c,h,u,f,g,p,_,m,w,y;a.forEach(t=>{t.words&&(g=n&&t.paraStart?n:0,m=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?h/(m-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,a,s){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(w=i===m-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(l,i,n),l.overflow&&function(t,i,a,s){const{rows:n,overflow:r}=t;let{textOverflow:o}=i;if(r&&n.splice(r),s&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=a+s-d;("none"===i.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let a=i;a>-1&&(t=e.data[a],l=t.x+t.width,!(a===i&&l<c));a--){if(l<c&&" "!==t.char||!a){e.data.splice(a+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,a,n),"none"!==i.textDecoration&&function(t,e){let i,a=0;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,k(n)?(i=n.type,n.color&&(t.decorationColor=G.string(n.color)),n.offset&&(a=Math.min(.3*s,Math.max(n.offset,.15*-s)))):i=n,i){case"under":t.decorationY=[.15*s+a];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s+a,.35*-s]}}(l,i),l}};const ji={string:function(t,e){if(!t)return"#000";const i=M(e)&&e<1;if(T(t)){if(!i||!G.object)return t;t=G.object(t)}let a=L(t.a)?1:t.a;i&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(j,Ni),Object.assign(G,ji),Object.assign(X,Lt),Object.assign(U,oe),Object.assign(q,Ee),Object.assign(z,Xe),Z();export{dt as Layouter,Q as LeaferCanvas,H as PathNodeHandleType,ht as Renderer,J as Watcher,Z as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map