@leafer-ui/worker 1.0.0-beta.18 → 1.0.0-rc.3

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.
@@ -1809,7 +1809,7 @@ function getTextCase(char, textCase, firstChar) {
1809
1809
  const { trimRight } = TextRowHelper;
1810
1810
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
1811
1811
  let word, row, wordWidth, rowWidth, realWidth;
1812
- let char, charWidth, charType, lastCharType, langBreak, afterBreak, paraStart;
1812
+ let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
1813
1813
  let textDrawData, rows = [], bounds;
1814
1814
  function createRows(drawData, content, style) {
1815
1815
  textDrawData = drawData;
@@ -1822,7 +1822,7 @@ function createRows(drawData, content, style) {
1822
1822
  if (charMode) {
1823
1823
  paraStart = true;
1824
1824
  lastCharType = null;
1825
- wordWidth = rowWidth = 0;
1825
+ startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
1826
1826
  word = { data: [] }, row = { words: [] };
1827
1827
  for (let i = 0, len = content.length; i < len; i++) {
1828
1828
  char = content[i];
@@ -1838,8 +1838,11 @@ function createRows(drawData, content, style) {
1838
1838
  if (charType === Letter && textCase !== 'none')
1839
1839
  char = getTextCase(char, textCase, !wordWidth);
1840
1840
  charWidth = canvas.measureText(char).width;
1841
- if (__letterSpacing)
1841
+ if (__letterSpacing) {
1842
+ if (__letterSpacing < 0)
1843
+ charSize = charWidth;
1842
1844
  charWidth += __letterSpacing;
1845
+ }
1843
1846
  langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
1844
1847
  afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
1845
1848
  realWidth = paraStart && paraIndent ? width - paraIndent : width;
@@ -1889,6 +1892,8 @@ function createRows(drawData, content, style) {
1889
1892
  }
1890
1893
  }
1891
1894
  function addChar(char, width) {
1895
+ if (charSize && !startCharSize)
1896
+ startCharSize = charSize;
1892
1897
  word.data.push({ char, width });
1893
1898
  wordWidth += width;
1894
1899
  }
@@ -1905,6 +1910,11 @@ function addRow() {
1905
1910
  row.paraStart = true;
1906
1911
  paraStart = false;
1907
1912
  }
1913
+ if (charSize) {
1914
+ row.startCharSize = startCharSize;
1915
+ row.endCharSize = charSize;
1916
+ startCharSize = 0;
1917
+ }
1908
1918
  row.width = rowWidth;
1909
1919
  if (bounds.width)
1910
1920
  trimRight(row);
@@ -1978,7 +1988,7 @@ function toChar(data, charX, rowData) {
1978
1988
 
1979
1989
  function layoutText(drawData, style) {
1980
1990
  const { rows, bounds } = drawData;
1981
- const { __lineHeight, __baseLine, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
1991
+ const { __lineHeight, __baseLine, __letterSpacing, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
1982
1992
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
1983
1993
  let starY = __baseLine;
1984
1994
  if (textOverflow !== 'show' && realHeight > height) {
@@ -1995,7 +2005,7 @@ function layoutText(drawData, style) {
1995
2005
  }
1996
2006
  }
1997
2007
  starY += y;
1998
- let row;
2008
+ let row, rowX, rowWidth;
1999
2009
  for (let i = 0, len = rows.length; i < len; i++) {
2000
2010
  row = rows[i];
2001
2011
  row.x = x;
@@ -2014,20 +2024,22 @@ function layoutText(drawData, style) {
2014
2024
  row.isOverflow = true;
2015
2025
  drawData.overflow = i + 1;
2016
2026
  }
2017
- if (row.width < 0) {
2018
- const charWidth = row.words[0].data[0].width;
2019
- const rowX = row.x + row.width;
2020
- if (rowX < bounds.x)
2021
- bounds.x = rowX - charWidth;
2022
- if (-row.width > bounds.width)
2023
- bounds.width = -row.width + style.fontSize + charWidth;
2024
- }
2025
- else {
2026
- if (row.x < bounds.x)
2027
- bounds.x = row.x;
2028
- if (row.width > bounds.width)
2029
- bounds.width = row.width;
2027
+ rowX = row.x;
2028
+ rowWidth = row.width;
2029
+ if (__letterSpacing < 0) {
2030
+ if (row.width < 0) {
2031
+ rowWidth = -row.width + style.fontSize + __letterSpacing;
2032
+ rowX -= rowWidth;
2033
+ rowWidth += style.fontSize;
2034
+ }
2035
+ else {
2036
+ rowWidth -= __letterSpacing;
2037
+ }
2030
2038
  }
2039
+ if (rowX < bounds.x)
2040
+ bounds.x = rowX;
2041
+ if (rowWidth > bounds.width)
2042
+ bounds.width = rowWidth;
2031
2043
  }
2032
2044
  bounds.y = y;
2033
2045
  bounds.height = realHeight;
@@ -2079,10 +2091,9 @@ const TextConvert = {
2079
2091
  if (typeof content !== 'string')
2080
2092
  content = String(content);
2081
2093
  let x = 0, y = 0;
2082
- let { width, height, padding } = style;
2083
- const { textDecoration, textOverflow, __font } = style;
2084
- if (!width)
2085
- width = 0;
2094
+ let width = style.__getInput('width') || 0;
2095
+ let height = style.__getInput('height') || 0;
2096
+ const { textDecoration, textOverflow, __font, padding } = style;
2086
2097
  if (padding) {
2087
2098
  const [top, right, bottom, left] = MathHelper.fourNumber(padding);
2088
2099
  if (width) {
@@ -1 +1 @@
1
- import{LeafList as t,DataHelper as e,RenderEvent as s,ChildEvent as i,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as f,Run as _,ImageManager as g,Platform as p,AnimateEvent as w,ResizeEvent as y,Creator as m,LeaferCanvasBase as v,canvasPatch as x,LeaferImage as b,InteractionBase as B,FileHelper as R,MatrixHelper as L,ImageEvent as E,PointHelper as k,MathHelper as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as O,Paint as C,Effect as M,TextConvert as T,Export as W}from"@leafer-ui/core";export*from"@leafer-ui/core";class I{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(s,i){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=s,i&&(this.config=e.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(s.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===i.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([i.ADD,i.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:D,updateAllWorldOpacity:P}=a,{pushAllChildBranch:F,pushAllParent:N}=o;const{worldBounds:Y}=h,{setByListWithHandle:U}=l;class H{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){U(this.beforeBounds,this.updatedList.list,Y)}setAfter(){U(this.afterBounds,this.updatedList.list,Y),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:V,updateAllChange:G}=a,{pushAllBranchStack:j,updateWorldBoundsByBranchStack:q}=o,X=c.get("Layouter");class z{constructor(t,s){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,s&&(this.config=e.default(s,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.running)return;const{target:t}=this;this.times=0;try{t.emit(f.START),this.layoutOnce(),t.emitEvent(new f(f.END,this.layoutedBlocks,this.times))}catch(t){X.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?X.warn("layouting"):this.times>3?X.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=_.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=f,o=this.getBlocks(i);o.forEach((t=>{t.setBefore()})),s.emitEvent(new f(n,o,this.times)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(D(t),e.push(t),t.isBranch&&F(t,e),N(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),N(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&P(t),t.__updateChange()}))}(i),o.forEach((t=>t.setAfter())),s.emitEvent(new f(r,o,this.times)),s.emitEvent(new f(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,_.end(e)}fullLayout(){const e=_.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=f,a=this.getBlocks(new t(s));s.emitEvent(new f(i,a,this.times)),z.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new f(n,a,this.times)),s.emitEvent(new f(r,a,this.times)),this.addBlocks(a),_.end(e)}static fullLayout(t){if(V(t),t.isBranch){const e=[t];j(t,e),q(e)}else t.__updateWorldBounds();G(t)}createBlock(t){return new H(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(){const{target:t}=this;this.__eventIds=[t.on_(f.REQUEST,this.layout,this),t.on_(f.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const Q=c.get("Renderer");class Z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=s,i&&(this.config=e.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(f.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Q.log(e.innerName,"---\x3e");try{this.emitRender(s.START),this.renderOnce(t),this.emitRender(s.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,Q.error(t)}Q.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Q.warn("rendering"):this.times>3?Q.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(s.BEFORE),t()):(this.requestLayout(),this.emitRender(s.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(s.RENDER,this.renderBounds,this.renderOptions),this.emitRender(s.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Q.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=_.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world),r=(new d).copy(i);s.save(),n&&!c.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,r),s.restore(),_.end(e)}fullRender(){const t=_.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),_.end(t)}__render(t,e){const s=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:s}=t.old;new d(0,0,e,s).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Q.warn(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 s(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(s.REQUEST,this.update,this),t.on_(f.END,this.__onLayoutEnd,this),t.on_(s.AGAIN,this.renderAgain,this),t.on_(y.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:K}=l;class ${constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:s,y:i}=this.point,n={x:s,y:i,radiusX:0,radiusY:0};for(let s=0,i=t.length;s<i;s++)if(e=t[s],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const s=new t;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||K(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class J{constructor(t,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,s&&(this.config=e.default(s,this.config)),this.findPath=new $(t,this),this.__listenEvents()}getByPoint(t,e,s){return"node"===p.name&&this.target.emit(f.CHECK_UPDATE),this.findPath.getByPoint(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(i.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new I(t,e),layouter:(t,e)=>new z(t,e),renderer:(t,e,s)=>new Z(t,e,s),selector:(t,e)=>new J(t,e)}),p.layout=z.fullLayout;class tt extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}x(OffscreenCanvasRenderingContext2D.prototype),x(Path2D.prototype);const{mineType:et}=R;function st(t,e){p.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,s)=>new Promise(((i,n)=>{t.convertToBlob({type:et(e),quality:s}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,s)=>t.convertToBlob({type:et(e),quality:s}),canvasSaveAs:(t,e,s)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,s)=>{!t.startsWith("data:")&&p.imageSuffix&&(t+=(t.includes("?")?"&":"?")+p.imageSuffix);let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then((t=>{e(t)})).catch((t=>{s(t)}))},i.onerror=t=>s(t),i.send()}))},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new tt(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new tt(t,e),interaction:(t,e,s,i)=>new B(t,e,s,i)}),p.name="web",p.isWorker=!0,p.requestRender=function(t){requestAnimationFrame(t)},p.devicePixelRatio=1,p.realtimeLayout=!0;const{userAgent:it}=navigator;it.indexOf("Firefox")>-1?(p.conicGradientRotate90=!0,p.intWheelDeltaY=!0):it.indexOf("Safari")>-1&&-1===it.indexOf("Chrome")&&(p.fullImageShadow=!0),it.indexOf("Windows")>-1?(p.os="Windows",p.intWheelDeltaY=!0):it.indexOf("Mac")>-1?p.os="Mac":it.indexOf("Linux")>-1&&(p.os="Linux");const{get:nt,rotateOfOuter:rt,translate:at,scaleOfOuter:ot,scale:dt,rotate:ht}=L;const{get:lt,translate:ct}=L;function ut(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(f.transform=lt(),ct(f.transform,i.x,i.y));break;case"clip":(d||h||l)&&function(t,e,s,i,n){const r=nt();at(r,e.x,e.y),s&&at(r,s.x,s.y),i&&("number"==typeof i?dt(r,i):dt(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&ht(r,n),t.transform=r}(f,i,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,s,i,n,r){const a=nt();if(r)switch(ht(a,r),r){case 90:at(a,i,0);break;case 180:at(a,s,i);break;case 270:at(a,0,s)}at(a,e.x,e.y),n&&(ot(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,i,n,r,h,l);break;default:u&&!l||function(t,e,s,i,n,r){const a=nt(),o=r&&180!==r,d=s.width/(o?n:i),h=s.height/(o?i:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=s.x+(s.width-i*l)/2,u=s.y+(s.height-n*l)/2;at(a,c,u),dt(a,l),r&&rt(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(f,o,i,n,r,l)}f.width=n,f.height=r,a&&(f.opacity=a)}function ft(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function _t(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new E(t,e))}function gt(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:pt,scale:wt,copy:yt}=L;function mt(t,e,s){let{scaleX:i,scaleY:n}=t.__world;const r=i+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,i=Math.abs(i),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:f,scaleY:_,opacity:g,transform:w,mode:y}=a;f&&(l=pt(),yt(l,w),wt(l,1/f,1/_),i*=f,n*=_),i*=s,n*=s,c*=i,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(i/=h,n/=h,c/=h,u/=h),f&&(i/=f,n/=_),(w||1!==i||1!==n)&&(l||(l=pt(),w&&yt(l,w)),wt(l,1/i,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===y?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function vt(t,e,s,i){const{scaleX:n,scaleY:r}=t.__world;if(s.data&&s.patternId!==n+"-"+r){if(i)if(s.image.isSVG&&"repeat"!==s.data.mode){let{width:t,height:a}=s.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,i=t>4096||a>4096}else i=!1;if(i){e.save(),e.clip();const{data:t}=s;return s.blendMode&&(e.blendMode=s.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(s.image.view,0,0,t.width,t.height),e.restore(),!0}return s.style?g.patternTasker.add((()=>gt(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&&mt(t,s,e.pixelRatio)&&t.forceUpdate("surface")}))),300):mt(t,s,e.pixelRatio),!1}return!1}function xt(t,e){const s="fill"===e?t._fill:t._stroke;if(s instanceof Array){let i,n,r,a;for(let o=0,d=s.length;o<d;o++)i=s[o].image,a=i&&i.url,a&&(n||(n={}),n[a]=!0,g.recycle(i),i.loading&&(r||(r=t.__input&&t.__input[e]||[],r instanceof Array||(r=[r])),i.unload(s[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function bt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function Bt(t,e,s){const{strokeAlign:i}=t.__,n="string"!=typeof s;switch(i){case"center":e.setStroke(n?void 0:s,t.__.strokeWidth,t.__),n?Et(t,s,e,!0):Lt(t,e);break;case"inside":Rt(t,e,s,"inside",n);break;case"outside":Rt(t,e,s,"outside",n)}}function Rt(t,e,s,i,n){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(n?void 0:s,2*r,t.__),o.font=a,n?Et(t,s,o,!0):Lt(t,o),o.blendMode="outside"===i?"destination-out":"destination-in",bt(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function Lt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[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)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function Et(t,e,s,i){let n;for(let r=0,a=e.length;r<a;r++)n=e[r],n.image&&vt(t,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),i?Lt(t,s):s.stroke(),s.restoreBlendMode()):i?Lt(t,s):s.stroke())}const{getSpread:kt,getOuterOf:St,getByMove:At,getIntersectData:Ot}=l;const Ct={x:.5,y:0},Mt={x:.5,y:1};function Tt(t,e,s){let i;for(let n=0,r=e.length;n<r;n++)i=e[n],t.addColorStop(i.offset,O.string(i.color,s))}const{set:Wt,getAngle:It,getDistance:Dt}=k,{get:Pt,rotateOfOuter:Ft,scaleOfOuter:Nt}=L,Yt={x:.5,y:.5},Ut={x:.5,y:1},Ht={},Vt={};const{set:Gt,getAngle:jt,getDistance:qt}=k,{get:Xt,rotateOfOuter:zt,scaleOfOuter:Qt}=L,Zt={x:.5,y:.5},Kt={x:.5,y:1},$t={},Jt={};let te;function ee(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:O.string(a,o)};case"image":return function(t,e,s,i,n){const r={type:s.type},a=r.image=g.get(s),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:s};return a.ready?(ft(t,e,a)&&ut(r,a,s,i),n&&(_t(E.LOAD,o),_t(E.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,_t(E.ERROR,o)):(n&&_t(E.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(ft(t,e,a)&&(ut(r,a,s,i),t.forceUpdate("surface")),_t(E.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,_t(E.ERROR,o)}))),r}(t,s,e,i,!te||!te[e.url]);case"linear":return function(t,e){let{from:s,to:i,type:n,blendMode:r,opacity:a}=t;s||(s=Ct),i||(i=Mt);const o=p.canvas.createLinearGradient(e.x+s.x*e.width,e.y+s.y*e.height,e.x+i.x*e.width,e.y+i.y*e.height);Tt(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,i);case"radial":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Yt),i||(i=Ut);const{x:d,y:h,width:l,height:c}=e;let u;Wt(Ht,d+s.x*l,h+s.y*c),Wt(Vt,d+i.x*l,h+i.y*c),(l!==c||o)&&(u=Pt(),Nt(u,Ht,l/c*(o||1),1),Ft(u,Ht,It(Ht,Vt)+90));const f=p.canvas.createRadialGradient(Ht.x,Ht.y,0,Ht.x,Ht.y,Dt(Ht,Vt));Tt(f,t.stops,r);const _={type:n,style:f,transform:u};return a&&(_.blendMode=a),_}(e,i);case"angular":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Zt),i||(i=Kt);const{x:d,y:h,width:l,height:c}=e;Gt($t,d+s.x*l,h+s.y*c),Gt(Jt,d+i.x*l,h+i.y*c);const u=Xt(),f=jt($t,Jt);p.conicGradientRotate90?(Qt(u,$t,l/c*(o||1),1),zt(u,$t,f+90)):(Qt(u,$t,1,l/c*(o||1)),zt(u,$t,f));const _=p.conicGradientSupport?p.canvas.createConicGradient(0,$t.x,$t.y):p.canvas.createRadialGradient($t.x,$t.y,0,$t.x,$t.y,qt($t,Jt));Tt(_,t.stops,r);const g={type:n,style:_,transform:u};return a&&(g.blendMode=a),g}(e,i);default:return e.r?{type:"solid",style:O.string(e)}:void 0}}var se=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let i,n=t.__.__input[e];n instanceof Array||(n=[n]),te=xt(t.__,e);for(let r=0,a=n.length;r<a;r++)i=ee(t,n[r],e),i&&s.push(i);t.__["_"+e]=s.length?s:void 0},drawTextStroke:Lt,fill:function(t,e,s){e.fillStyle=s,t.__.__font?bt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:bt,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)i=s[a],i.image&&vt(t,e,i,!r)||i.style&&(e.fillStyle=i.style,i.transform?(e.save(),e.transform(i.transform),i.blendMode&&(e.blendMode=i.blendMode),r?bt(t,e):n?e.fill(n):e.fill(),e.restore()):i.blendMode?(e.saveBlendMode(i.blendMode),r?bt(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):r?bt(t,e):n?e.fill(n):e.fill())},recycleImage:xt,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,s.matrix))s.matrix?(h*=s.matrix.a,l*=s.matrix.d,n=a=St(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=Ot(i?kt(e.bounds,i*h,i*l):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),h*=r.a,l*=r.d),a=St(d,r),n=At(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)Bt(t,e,s);else switch(r){case"center":e.setStroke(s,n,i),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*n,t.__),t.__drawRenderPath(r),r.stroke(),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:Bt,strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)Bt(t,e,s);else switch(r){case"center":e.setStroke(void 0,n,i),Et(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),Et(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*n,t.__),Et(t,s,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:ie,toOffsetOutBounds:ne}=l,re={},ae={};function oe(t,e,s,i){const{bounds:n,shapeBounds:r}=i;if(p.fullImageShadow){if(ie(re,t.bounds),re.x+=e.x-r.x,re.y+=e.y-r.y,s){const{matrix:t}=i;re.x-=(n.x+(t?t.e:0)+n.width/2)*(s-1),re.y-=(n.y+(t?t.f:0)+n.height/2)*(s-1),re.width*=s,re.height*=s}t.copyWorld(i.canvas,t.bounds,re)}else s&&(ie(re,e),re.x-=e.width/2*(s-1),re.y-=e.height/2*(s-1),re.width*=s,re.height*=s),t.copyWorld(i.canvas,r,s?re:e)}const{toOffsetOutBounds:de}=l,he={};var le=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;de(l,he),d.forEach(((i,d)=>{_.save(),_.setWorldShadow(he.offsetX+i.x*u,he.offsetY+i.y*f,i.blur*u),r=i.spread?1-2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,oe(_,he,r,s),_.restore(),h?(_.copyWorld(_,l,a,"copy"),_.copyWorld(h,a,a,"source-out"),n=a):(_.copyWorld(s.canvas,c,l,"source-out"),n=l),_.fillWorld(n,i.color,"source-in"),t.__hasMirror?e.copyWorldByReset(_,n,a,i.blendMode):e.copyWorldToInner(_,n,o.renderBounds,i.blendMode),g&&d<g&&_.clear()})),_.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;ne(l,ae),d.forEach(((i,d)=>{_.setWorldShadow(ae.offsetX+i.x*u,ae.offsetY+i.y*f,i.blur*u,i.color),r=i.spread?1+2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,oe(_,ae,r,s),n=l,i.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,a,"copy"),n=a),h?_.copyWorld(h,a,a,"destination-out"):_.copyWorld(s.canvas,c,l,"destination-out")),t.__hasMirror?e.copyWorldByReset(_,n,a,i.blendMode):e.copyWorldToInner(_,n,o.renderBounds,i.blendMode),g&&d<g&&_.clear()})),_.recycle()}});const ce=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ue=ce+"_#~&*+\\=|≮≯≈≠=…",fe=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 _e(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ge=_e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),pe=_e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),we=_e(ce),ye=_e(ue),me=_e("- —/~|┆·");var ve;!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"}(ve||(ve={}));const{Letter:xe,Single:be,Before:Be,After:Re,Symbol:Le,Break:Ee}=ve;function ke(t){return ge[t]?xe:me[t]?Ee:pe[t]?Be:we[t]?Re:ye[t]?Le:fe.test(t)?be:xe}const Se={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Ae(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Oe}=Se,{Letter:Ce,Single:Me,Before:Te,After:We,Symbol:Ie,Break:De}=ve;let Pe,Fe,Ne,Ye,Ue,He,Ve,Ge,je,qe,Xe,ze,Qe,Ze,Ke=[];function $e(t,e){Pe.data.push({char:t,width:e}),Ne+=e}function Je(){Ye+=Ne,Pe.width=Ne,Fe.words.push(Pe),Pe={data:[]},Ne=0}function ts(){ze&&(Qe.paraNumber++,Fe.paraStart=!0,ze=!1),Fe.width=Ye,Ze.width&&Oe(Fe),Ke.push(Fe),Fe={words:[]},Ye=0}const es={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let s=0,i=0,{width:n,height:r,padding:a}=e;const{textDecoration:o,textOverflow:d,__font:h}=e;if(n||(n=0),a){const[t,e,o,d]=S.fourNumber(a);n&&(s=d,n-=e+d),r&&(i=t,r-=t+o)}const l={bounds:{x:s,y:i,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=h};return function(t,e,s){Qe=t,Ke=t.rows,Ze=t.bounds;const{__letterSpacing:i,paraIndent:n,textCase:r}=s,{canvas:a}=p,{width:o,height:d}=Ze;if(o||d||i||"none"!==r){ze=!0,je=null,Ne=Ye=0,Pe={data:[]},Fe={words:[]};for(let t=0,s=e.length;t<s;t++)He=e[t],"\n"===He?(Ne&&Je(),Fe.paraEnd=!0,ts(),ze=!0):(Ge=ke(He),Ge===Ce&&"none"!==r&&(He=Ae(He,r,!Ne)),Ve=a.measureText(He).width,i&&(Ve+=i),qe=Ge===Me&&(je===Me||je===Ce)||je===Me&&Ge!==We,Xe=!(Ge!==Te&&Ge!==Me||je!==Ie&&je!==We),Ue=ze&&n?o-n:o,o&&Ye+Ne+Ve>Ue&&(Xe||(Xe=Ge===Ce&&je==We),qe||Xe||Ge===De||Ge===Te||Ge===Me||Ne+Ve>Ue?(Ne&&Je(),ts()):ts())," "===He&&!0!==ze&&Ye+Ne===0||(Ge===De?(" "===He&&Ne&&Je(),$e(He,Ve),Je()):qe||Xe?(Ne&&Je(),$e(He,Ve)):$e(He,Ve)),je=Ge);Ne&&Je(),Ye&&ts(),Ke.length>0&&(Ke[Ke.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Qe.paraNumber++,Ke.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,textAlign:a,verticalAlign:o,paraSpacing:d,textOverflow:h}=e;let l,{x:c,y:u,width:f,height:_}=i,g=n*s.length+(d?d*(t.paraNumber-1):0),p=r;if("show"!==h&&g>_)g=Math.max(_,n),t.overflow=s.length;else switch(o){case"middle":u+=(_-g)/2;break;case"bottom":u+=_-g}p+=u;for(let r=0,o=s.length;r<o;r++){switch(l=s[r],l.x=c,a){case"center":l.x+=(f-l.width)/2;break;case"right":l.x+=f-l.width}if(l.paraStart&&d&&r>0&&(p+=d),l.y=p,p+=n,t.overflow>r&&p>g&&(l.isOverflow=!0,t.overflow=r+1),l.width<0){const t=l.words[0].data[0].width,s=l.x+l.width;s<i.x&&(i.x=s-t),-l.width>i.width&&(i.width=-l.width+e.fontSize+t)}else l.x<i.x&&(i.x=l.x),l.width>i.width&&(i.width=l.width)}i.y=u,i.height=g}(l,e),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=s&&"justify"===r&&t.words.length>1?(s-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:s,overflow:i}=t;if(s.splice(i),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=s[i-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,d),"none"!==o&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(l,e),l}},ss={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},is={export(t,e,s){return function(t){ns||(ns=new A);return new Promise((e=>{ns.add((()=>gt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((i=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>gt(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof s){case"object":s.quality&&(t=s.quality),s.blob&&(a=!0);break;case"number":t=s;break;case"boolean":a=s}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),i({data:o}),n(),h&&d.recycle()})))):(i({data:!1}),n())}))))}};let ns;Object.assign(C,se),Object.assign(M,le),Object.assign(T,es),Object.assign(O,ss),Object.assign(W,is),st();export{z as Layouter,tt as LeaferCanvas,Z as Renderer,J as Selector,I as Watcher,st as useCanvas};
1
+ import{LeafList as t,DataHelper as e,RenderEvent as s,ChildEvent as i,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as f,Run as _,ImageManager as g,Platform as p,AnimateEvent as w,ResizeEvent as y,Creator as m,LeaferCanvasBase as v,canvasPatch as x,LeaferImage as b,InteractionBase as B,FileHelper as R,MatrixHelper as L,ImageEvent as E,PointHelper as k,MathHelper as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as O,Paint as C,Effect as M,TextConvert as T,Export as I}from"@leafer-ui/core";export*from"@leafer-ui/core";class W{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(s,i){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=s,i&&(this.config=e.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(s.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===i.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([i.ADD,i.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:D,updateAllWorldOpacity:P}=a,{pushAllChildBranch:F,pushAllParent:N}=o;const{worldBounds:Y}=h,{setByListWithHandle:U}=l;class H{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){U(this.beforeBounds,this.updatedList.list,Y)}setAfter(){U(this.afterBounds,this.updatedList.list,Y),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:V,updateAllChange:G}=a,{pushAllBranchStack:j,updateWorldBoundsByBranchStack:q}=o,X=c.get("Layouter");class z{constructor(t,s){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,s&&(this.config=e.default(s,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.running)return;const{target:t}=this;this.times=0;try{t.emit(f.START),this.layoutOnce(),t.emitEvent(new f(f.END,this.layoutedBlocks,this.times))}catch(t){X.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?X.warn("layouting"):this.times>3?X.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=_.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=f,o=this.getBlocks(i);o.forEach((t=>{t.setBefore()})),s.emitEvent(new f(n,o,this.times)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(D(t),e.push(t),t.isBranch&&F(t,e),N(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),N(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&P(t),t.__updateChange()}))}(i),o.forEach((t=>t.setAfter())),s.emitEvent(new f(r,o,this.times)),s.emitEvent(new f(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,_.end(e)}fullLayout(){const e=_.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=f,a=this.getBlocks(new t(s));s.emitEvent(new f(i,a,this.times)),z.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new f(n,a,this.times)),s.emitEvent(new f(r,a,this.times)),this.addBlocks(a),_.end(e)}static fullLayout(t){if(V(t),t.isBranch){const e=[t];j(t,e),q(e)}else t.__updateWorldBounds();G(t)}createBlock(t){return new H(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(){const{target:t}=this;this.__eventIds=[t.on_(f.REQUEST,this.layout,this),t.on_(f.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const Q=c.get("Renderer");class Z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=s,i&&(this.config=e.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(f.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Q.log(e.innerName,"---\x3e");try{this.emitRender(s.START),this.renderOnce(t),this.emitRender(s.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,Q.error(t)}Q.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Q.warn("rendering"):this.times>3?Q.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(s.BEFORE),t()):(this.requestLayout(),this.emitRender(s.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(s.RENDER,this.renderBounds,this.renderOptions),this.emitRender(s.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Q.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=_.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world),r=(new d).copy(i);s.save(),n&&!c.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,r),s.restore(),_.end(e)}fullRender(){const t=_.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),_.end(t)}__render(t,e){const s=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:s}=t.old;new d(0,0,e,s).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Q.warn(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 s(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(s.REQUEST,this.update,this),t.on_(f.END,this.__onLayoutEnd,this),t.on_(s.AGAIN,this.renderAgain,this),t.on_(y.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:K}=l;class ${constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:s,y:i}=this.point,n={x:s,y:i,radiusX:0,radiusY:0};for(let s=0,i=t.length;s<i;s++)if(e=t[s],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const s=new t;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||K(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class J{constructor(t,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,s&&(this.config=e.default(s,this.config)),this.findPath=new $(t,this),this.__listenEvents()}getByPoint(t,e,s){return"node"===p.name&&this.target.emit(f.CHECK_UPDATE),this.findPath.getByPoint(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(i.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new W(t,e),layouter:(t,e)=>new z(t,e),renderer:(t,e,s)=>new Z(t,e,s),selector:(t,e)=>new J(t,e)}),p.layout=z.fullLayout;class tt extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}x(OffscreenCanvasRenderingContext2D.prototype),x(Path2D.prototype);const{mineType:et}=R;function st(t,e){p.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,s)=>new Promise(((i,n)=>{t.convertToBlob({type:et(e),quality:s}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,s)=>t.convertToBlob({type:et(e),quality:s}),canvasSaveAs:(t,e,s)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,s)=>{!t.startsWith("data:")&&p.imageSuffix&&(t+=(t.includes("?")?"&":"?")+p.imageSuffix);let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then((t=>{e(t)})).catch((t=>{s(t)}))},i.onerror=t=>s(t),i.send()}))},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new tt(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new tt(t,e),interaction:(t,e,s,i)=>new B(t,e,s,i)}),p.name="web",p.isWorker=!0,p.requestRender=function(t){requestAnimationFrame(t)},p.devicePixelRatio=1,p.realtimeLayout=!0;const{userAgent:it}=navigator;it.indexOf("Firefox")>-1?(p.conicGradientRotate90=!0,p.intWheelDeltaY=!0):it.indexOf("Safari")>-1&&-1===it.indexOf("Chrome")&&(p.fullImageShadow=!0),it.indexOf("Windows")>-1?(p.os="Windows",p.intWheelDeltaY=!0):it.indexOf("Mac")>-1?p.os="Mac":it.indexOf("Linux")>-1&&(p.os="Linux");const{get:nt,rotateOfOuter:rt,translate:at,scaleOfOuter:ot,scale:dt,rotate:ht}=L;const{get:lt,translate:ct}=L;function ut(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(f.transform=lt(),ct(f.transform,i.x,i.y));break;case"clip":(d||h||l)&&function(t,e,s,i,n){const r=nt();at(r,e.x,e.y),s&&at(r,s.x,s.y),i&&("number"==typeof i?dt(r,i):dt(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&ht(r,n),t.transform=r}(f,i,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,s,i,n,r){const a=nt();if(r)switch(ht(a,r),r){case 90:at(a,i,0);break;case 180:at(a,s,i);break;case 270:at(a,0,s)}at(a,e.x,e.y),n&&(ot(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,i,n,r,h,l);break;default:u&&!l||function(t,e,s,i,n,r){const a=nt(),o=r&&180!==r,d=s.width/(o?n:i),h=s.height/(o?i:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=s.x+(s.width-i*l)/2,u=s.y+(s.height-n*l)/2;at(a,c,u),dt(a,l),r&&rt(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(f,o,i,n,r,l)}f.width=n,f.height=r,a&&(f.opacity=a)}function ft(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function _t(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new E(t,e))}function gt(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:pt,scale:wt,copy:yt}=L;function mt(t,e,s){let{scaleX:i,scaleY:n}=t.__world;const r=i+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,i=Math.abs(i),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:f,scaleY:_,opacity:g,transform:w,mode:y}=a;f&&(l=pt(),yt(l,w),wt(l,1/f,1/_),i*=f,n*=_),i*=s,n*=s,c*=i,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(i/=h,n/=h,c/=h,u/=h),f&&(i/=f,n/=_),(w||1!==i||1!==n)&&(l||(l=pt(),w&&yt(l,w)),wt(l,1/i,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===y?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function vt(t,e,s,i){const{scaleX:n,scaleY:r}=t.__world;if(s.data&&s.patternId!==n+"-"+r){if(i)if(s.image.isSVG&&"repeat"!==s.data.mode){let{width:t,height:a}=s.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,i=t>4096||a>4096}else i=!1;if(i){e.save(),e.clip();const{data:t}=s;return s.blendMode&&(e.blendMode=s.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(s.image.view,0,0,t.width,t.height),e.restore(),!0}return s.style?g.patternTasker.add((()=>gt(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&&mt(t,s,e.pixelRatio)&&t.forceUpdate("surface")}))),300):mt(t,s,e.pixelRatio),!1}return!1}function xt(t,e){const s="fill"===e?t._fill:t._stroke;if(s instanceof Array){let i,n,r,a;for(let o=0,d=s.length;o<d;o++)i=s[o].image,a=i&&i.url,a&&(n||(n={}),n[a]=!0,g.recycle(i),i.loading&&(r||(r=t.__input&&t.__input[e]||[],r instanceof Array||(r=[r])),i.unload(s[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function bt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function Bt(t,e,s){const{strokeAlign:i}=t.__,n="string"!=typeof s;switch(i){case"center":e.setStroke(n?void 0:s,t.__.strokeWidth,t.__),n?Et(t,s,e,!0):Lt(t,e);break;case"inside":Rt(t,e,s,"inside",n);break;case"outside":Rt(t,e,s,"outside",n)}}function Rt(t,e,s,i,n){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(n?void 0:s,2*r,t.__),o.font=a,n?Et(t,s,o,!0):Lt(t,o),o.blendMode="outside"===i?"destination-out":"destination-in",bt(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function Lt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[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)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function Et(t,e,s,i){let n;for(let r=0,a=e.length;r<a;r++)n=e[r],n.image&&vt(t,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),i?Lt(t,s):s.stroke(),s.restoreBlendMode()):i?Lt(t,s):s.stroke())}const{getSpread:kt,getOuterOf:St,getByMove:At,getIntersectData:Ot}=l;const Ct={x:.5,y:0},Mt={x:.5,y:1};function Tt(t,e,s){let i;for(let n=0,r=e.length;n<r;n++)i=e[n],t.addColorStop(i.offset,O.string(i.color,s))}const{set:It,getAngle:Wt,getDistance:Dt}=k,{get:Pt,rotateOfOuter:Ft,scaleOfOuter:Nt}=L,Yt={x:.5,y:.5},Ut={x:.5,y:1},Ht={},Vt={};const{set:Gt,getAngle:jt,getDistance:qt}=k,{get:Xt,rotateOfOuter:zt,scaleOfOuter:Qt}=L,Zt={x:.5,y:.5},Kt={x:.5,y:1},$t={},Jt={};let te;function ee(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:O.string(a,o)};case"image":return function(t,e,s,i,n){const r={type:s.type},a=r.image=g.get(s),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:s};return a.ready?(ft(t,e,a)&&ut(r,a,s,i),n&&(_t(E.LOAD,o),_t(E.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,_t(E.ERROR,o)):(n&&_t(E.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(ft(t,e,a)&&(ut(r,a,s,i),t.forceUpdate("surface")),_t(E.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,_t(E.ERROR,o)}))),r}(t,s,e,i,!te||!te[e.url]);case"linear":return function(t,e){let{from:s,to:i,type:n,blendMode:r,opacity:a}=t;s||(s=Ct),i||(i=Mt);const o=p.canvas.createLinearGradient(e.x+s.x*e.width,e.y+s.y*e.height,e.x+i.x*e.width,e.y+i.y*e.height);Tt(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,i);case"radial":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Yt),i||(i=Ut);const{x:d,y:h,width:l,height:c}=e;let u;It(Ht,d+s.x*l,h+s.y*c),It(Vt,d+i.x*l,h+i.y*c),(l!==c||o)&&(u=Pt(),Nt(u,Ht,l/c*(o||1),1),Ft(u,Ht,Wt(Ht,Vt)+90));const f=p.canvas.createRadialGradient(Ht.x,Ht.y,0,Ht.x,Ht.y,Dt(Ht,Vt));Tt(f,t.stops,r);const _={type:n,style:f,transform:u};return a&&(_.blendMode=a),_}(e,i);case"angular":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Zt),i||(i=Kt);const{x:d,y:h,width:l,height:c}=e;Gt($t,d+s.x*l,h+s.y*c),Gt(Jt,d+i.x*l,h+i.y*c);const u=Xt(),f=jt($t,Jt);p.conicGradientRotate90?(Qt(u,$t,l/c*(o||1),1),zt(u,$t,f+90)):(Qt(u,$t,1,l/c*(o||1)),zt(u,$t,f));const _=p.conicGradientSupport?p.canvas.createConicGradient(0,$t.x,$t.y):p.canvas.createRadialGradient($t.x,$t.y,0,$t.x,$t.y,qt($t,Jt));Tt(_,t.stops,r);const g={type:n,style:_,transform:u};return a&&(g.blendMode=a),g}(e,i);default:return e.r?{type:"solid",style:O.string(e)}:void 0}}var se=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let i,n=t.__.__input[e];n instanceof Array||(n=[n]),te=xt(t.__,e);for(let r=0,a=n.length;r<a;r++)i=ee(t,n[r],e),i&&s.push(i);t.__["_"+e]=s.length?s:void 0},drawTextStroke:Lt,fill:function(t,e,s){e.fillStyle=s,t.__.__font?bt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:bt,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)i=s[a],i.image&&vt(t,e,i,!r)||i.style&&(e.fillStyle=i.style,i.transform?(e.save(),e.transform(i.transform),i.blendMode&&(e.blendMode=i.blendMode),r?bt(t,e):n?e.fill(n):e.fill(),e.restore()):i.blendMode?(e.saveBlendMode(i.blendMode),r?bt(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):r?bt(t,e):n?e.fill(n):e.fill())},recycleImage:xt,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,s.matrix))s.matrix?(h*=s.matrix.a,l*=s.matrix.d,n=a=St(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=Ot(i?kt(e.bounds,i*h,i*l):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),h*=r.a,l*=r.d),a=St(d,r),n=At(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)Bt(t,e,s);else switch(r){case"center":e.setStroke(s,n,i),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*n,t.__),t.__drawRenderPath(r),r.stroke(),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:Bt,strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)Bt(t,e,s);else switch(r){case"center":e.setStroke(void 0,n,i),Et(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),Et(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*n,t.__),Et(t,s,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:ie,toOffsetOutBounds:ne}=l,re={},ae={};function oe(t,e,s,i){const{bounds:n,shapeBounds:r}=i;if(p.fullImageShadow){if(ie(re,t.bounds),re.x+=e.x-r.x,re.y+=e.y-r.y,s){const{matrix:t}=i;re.x-=(n.x+(t?t.e:0)+n.width/2)*(s-1),re.y-=(n.y+(t?t.f:0)+n.height/2)*(s-1),re.width*=s,re.height*=s}t.copyWorld(i.canvas,t.bounds,re)}else s&&(ie(re,e),re.x-=e.width/2*(s-1),re.y-=e.height/2*(s-1),re.width*=s,re.height*=s),t.copyWorld(i.canvas,r,s?re:e)}const{toOffsetOutBounds:de}=l,he={};var le=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;de(l,he),d.forEach(((i,d)=>{_.save(),_.setWorldShadow(he.offsetX+i.x*u,he.offsetY+i.y*f,i.blur*u),r=i.spread?1-2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,oe(_,he,r,s),_.restore(),h?(_.copyWorld(_,l,a,"copy"),_.copyWorld(h,a,a,"source-out"),n=a):(_.copyWorld(s.canvas,c,l,"source-out"),n=l),_.fillWorld(n,i.color,"source-in"),t.__hasMirror?e.copyWorldByReset(_,n,a,i.blendMode):e.copyWorldToInner(_,n,o.renderBounds,i.blendMode),g&&d<g&&_.clear()})),_.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;ne(l,ae),d.forEach(((i,d)=>{_.setWorldShadow(ae.offsetX+i.x*u,ae.offsetY+i.y*f,i.blur*u,i.color),r=i.spread?1+2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,oe(_,ae,r,s),n=l,i.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,a,"copy"),n=a),h?_.copyWorld(h,a,a,"destination-out"):_.copyWorld(s.canvas,c,l,"destination-out")),t.__hasMirror?e.copyWorldByReset(_,n,a,i.blendMode):e.copyWorldToInner(_,n,o.renderBounds,i.blendMode),g&&d<g&&_.clear()})),_.recycle()}});const ce=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ue=ce+"_#~&*+\\=|≮≯≈≠=…",fe=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 _e(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ge=_e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),pe=_e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),we=_e(ce),ye=_e(ue),me=_e("- —/~|┆·");var ve;!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"}(ve||(ve={}));const{Letter:xe,Single:be,Before:Be,After:Re,Symbol:Le,Break:Ee}=ve;function ke(t){return ge[t]?xe:me[t]?Ee:pe[t]?Be:we[t]?Re:ye[t]?Le:fe.test(t)?be:xe}const Se={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Ae(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Oe}=Se,{Letter:Ce,Single:Me,Before:Te,After:Ie,Symbol:We,Break:De}=ve;let Pe,Fe,Ne,Ye,Ue,He,Ve,Ge,je,qe,Xe,ze,Qe,Ze,Ke,$e,Je=[];function ts(t,e){je&&!Ge&&(Ge=je),Pe.data.push({char:t,width:e}),Ne+=e}function es(){Ye+=Ne,Pe.width=Ne,Fe.words.push(Pe),Pe={data:[]},Ne=0}function ss(){Ze&&(Ke.paraNumber++,Fe.paraStart=!0,Ze=!1),je&&(Fe.startCharSize=Ge,Fe.endCharSize=je,Ge=0),Fe.width=Ye,$e.width&&Oe(Fe),Je.push(Fe),Fe={words:[]},Ye=0}const is={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let s=0,i=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,textOverflow:o,__font:d,padding:h}=e;if(h){const[t,e,a,o]=S.fourNumber(h);n&&(s=o,n-=e+o),r&&(i=t,r-=t+a)}const l={bounds:{x:s,y:i,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=d};return function(t,e,s){Ke=t,Je=t.rows,$e=t.bounds;const{__letterSpacing:i,paraIndent:n,textCase:r}=s,{canvas:a}=p,{width:o,height:d}=$e;if(o||d||i||"none"!==r){Ze=!0,Xe=null,Ge=Ve=je=Ne=Ye=0,Pe={data:[]},Fe={words:[]};for(let t=0,s=e.length;t<s;t++)He=e[t],"\n"===He?(Ne&&es(),Fe.paraEnd=!0,ss(),Ze=!0):(qe=ke(He),qe===Ce&&"none"!==r&&(He=Ae(He,r,!Ne)),Ve=a.measureText(He).width,i&&(i<0&&(je=Ve),Ve+=i),ze=qe===Me&&(Xe===Me||Xe===Ce)||Xe===Me&&qe!==Ie,Qe=!(qe!==Te&&qe!==Me||Xe!==We&&Xe!==Ie),Ue=Ze&&n?o-n:o,o&&Ye+Ne+Ve>Ue&&(Qe||(Qe=qe===Ce&&Xe==Ie),ze||Qe||qe===De||qe===Te||qe===Me||Ne+Ve>Ue?(Ne&&es(),ss()):ss())," "===He&&!0!==Ze&&Ye+Ne===0||(qe===De?(" "===He&&Ne&&es(),ts(He,Ve),es()):ze||Qe?(Ne&&es(),ts(He,Ve)):ts(He,Ve)),Xe=qe);Ne&&es(),Ye&&ss(),Je.length>0&&(Je[Je.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ke.paraNumber++,Je.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:h,textOverflow:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=i,y=n*s.length+(h?h*(t.paraNumber-1):0),m=r;if("show"!==l&&y>w)y=Math.max(w,n),t.overflow=s.length;else switch(d){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let r=0,d=s.length;r<d;r++){switch(c=s[r],c.x=_,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&h&&r>0&&(m+=h),c.y=m,m+=n,t.overflow>r&&m>y&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<i.x&&(i.x=u),f>i.width&&(i.width=f)}i.y=g,i.height=y}(l,e),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=s&&"justify"===r&&t.words.length>1?(s-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:s,overflow:i}=t;if(s.splice(i),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=s[i-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,o),"none"!==a&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(l,e),l}},ns={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},rs={export(t,e,s){return function(t){as||(as=new A);return new Promise((e=>{as.add((()=>gt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((i=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>gt(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof s){case"object":s.quality&&(t=s.quality),s.blob&&(a=!0);break;case"number":t=s;break;case"boolean":a=s}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),i({data:o}),n(),h&&d.recycle()})))):(i({data:!1}),n())}))))}};let as;Object.assign(C,se),Object.assign(M,le),Object.assign(T,is),Object.assign(O,ns),Object.assign(I,rs),st();export{z as Layouter,tt as LeaferCanvas,Z as Renderer,J as Selector,W as Watcher,st as useCanvas};
package/dist/worker.js CHANGED
@@ -1051,6 +1051,9 @@ var LeaferUI = (function (exports) {
1051
1051
  }
1052
1052
  }
1053
1053
  },
1054
+ has(type) {
1055
+ return !!this.nameList[type];
1056
+ },
1054
1057
  get(type, ...params) {
1055
1058
  return new nameList[type](...params);
1056
1059
  }
@@ -5161,6 +5164,8 @@ var LeaferUI = (function (exports) {
5161
5164
  this.on(type, listener, { once: true, capture });
5162
5165
  },
5163
5166
  emit(type, event, capture) {
5167
+ if (!event && EventCreator.has(type))
5168
+ event = EventCreator.get(type, { type, target: this, current: this });
5164
5169
  const map = __getListenerMap(this, capture);
5165
5170
  const list = map[type];
5166
5171
  if (list) {
@@ -7816,14 +7821,19 @@ var LeaferUI = (function (exports) {
7816
7821
  __updateRenderPath() {
7817
7822
  if (this.__.points && this.__.curve) {
7818
7823
  drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, true);
7819
- this.__updateNaturalSize();
7820
7824
  }
7821
7825
  else {
7822
7826
  super.__updateRenderPath();
7823
7827
  }
7824
7828
  }
7825
7829
  __updateBoxBounds() {
7826
- this.__.points ? toBounds$2(this.__.path, this.__layout.boxBounds) : super.__updateBoxBounds();
7830
+ if (this.__.points) {
7831
+ toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
7832
+ this.__updateNaturalSize();
7833
+ }
7834
+ else {
7835
+ super.__updateBoxBounds();
7836
+ }
7827
7837
  }
7828
7838
  };
7829
7839
  __decorate([
@@ -7917,7 +7927,7 @@ var LeaferUI = (function (exports) {
7917
7927
  }
7918
7928
  __updateBoxBounds() {
7919
7929
  if (this.points) {
7920
- toBounds$1(this.__.path, this.__layout.boxBounds);
7930
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
7921
7931
  this.__updateNaturalSize();
7922
7932
  }
7923
7933
  else {
@@ -9543,7 +9553,7 @@ var LeaferUI = (function (exports) {
9543
9553
  const { trimRight } = TextRowHelper;
9544
9554
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
9545
9555
  let word, row, wordWidth, rowWidth, realWidth;
9546
- let char, charWidth, charType, lastCharType, langBreak, afterBreak, paraStart;
9556
+ let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
9547
9557
  let textDrawData, rows = [], bounds;
9548
9558
  function createRows(drawData, content, style) {
9549
9559
  textDrawData = drawData;
@@ -9556,7 +9566,7 @@ var LeaferUI = (function (exports) {
9556
9566
  if (charMode) {
9557
9567
  paraStart = true;
9558
9568
  lastCharType = null;
9559
- wordWidth = rowWidth = 0;
9569
+ startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
9560
9570
  word = { data: [] }, row = { words: [] };
9561
9571
  for (let i = 0, len = content.length; i < len; i++) {
9562
9572
  char = content[i];
@@ -9572,8 +9582,11 @@ var LeaferUI = (function (exports) {
9572
9582
  if (charType === Letter && textCase !== 'none')
9573
9583
  char = getTextCase(char, textCase, !wordWidth);
9574
9584
  charWidth = canvas.measureText(char).width;
9575
- if (__letterSpacing)
9585
+ if (__letterSpacing) {
9586
+ if (__letterSpacing < 0)
9587
+ charSize = charWidth;
9576
9588
  charWidth += __letterSpacing;
9589
+ }
9577
9590
  langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
9578
9591
  afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
9579
9592
  realWidth = paraStart && paraIndent ? width - paraIndent : width;
@@ -9623,6 +9636,8 @@ var LeaferUI = (function (exports) {
9623
9636
  }
9624
9637
  }
9625
9638
  function addChar(char, width) {
9639
+ if (charSize && !startCharSize)
9640
+ startCharSize = charSize;
9626
9641
  word.data.push({ char, width });
9627
9642
  wordWidth += width;
9628
9643
  }
@@ -9639,6 +9654,11 @@ var LeaferUI = (function (exports) {
9639
9654
  row.paraStart = true;
9640
9655
  paraStart = false;
9641
9656
  }
9657
+ if (charSize) {
9658
+ row.startCharSize = startCharSize;
9659
+ row.endCharSize = charSize;
9660
+ startCharSize = 0;
9661
+ }
9642
9662
  row.width = rowWidth;
9643
9663
  if (bounds.width)
9644
9664
  trimRight(row);
@@ -9712,7 +9732,7 @@ var LeaferUI = (function (exports) {
9712
9732
 
9713
9733
  function layoutText(drawData, style) {
9714
9734
  const { rows, bounds } = drawData;
9715
- const { __lineHeight, __baseLine, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
9735
+ const { __lineHeight, __baseLine, __letterSpacing, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
9716
9736
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
9717
9737
  let starY = __baseLine;
9718
9738
  if (textOverflow !== 'show' && realHeight > height) {
@@ -9729,7 +9749,7 @@ var LeaferUI = (function (exports) {
9729
9749
  }
9730
9750
  }
9731
9751
  starY += y;
9732
- let row;
9752
+ let row, rowX, rowWidth;
9733
9753
  for (let i = 0, len = rows.length; i < len; i++) {
9734
9754
  row = rows[i];
9735
9755
  row.x = x;
@@ -9748,20 +9768,22 @@ var LeaferUI = (function (exports) {
9748
9768
  row.isOverflow = true;
9749
9769
  drawData.overflow = i + 1;
9750
9770
  }
9751
- if (row.width < 0) {
9752
- const charWidth = row.words[0].data[0].width;
9753
- const rowX = row.x + row.width;
9754
- if (rowX < bounds.x)
9755
- bounds.x = rowX - charWidth;
9756
- if (-row.width > bounds.width)
9757
- bounds.width = -row.width + style.fontSize + charWidth;
9758
- }
9759
- else {
9760
- if (row.x < bounds.x)
9761
- bounds.x = row.x;
9762
- if (row.width > bounds.width)
9763
- bounds.width = row.width;
9771
+ rowX = row.x;
9772
+ rowWidth = row.width;
9773
+ if (__letterSpacing < 0) {
9774
+ if (row.width < 0) {
9775
+ rowWidth = -row.width + style.fontSize + __letterSpacing;
9776
+ rowX -= rowWidth;
9777
+ rowWidth += style.fontSize;
9778
+ }
9779
+ else {
9780
+ rowWidth -= __letterSpacing;
9781
+ }
9764
9782
  }
9783
+ if (rowX < bounds.x)
9784
+ bounds.x = rowX;
9785
+ if (rowWidth > bounds.width)
9786
+ bounds.width = rowWidth;
9765
9787
  }
9766
9788
  bounds.y = y;
9767
9789
  bounds.height = realHeight;
@@ -9813,10 +9835,9 @@ var LeaferUI = (function (exports) {
9813
9835
  if (typeof content !== 'string')
9814
9836
  content = String(content);
9815
9837
  let x = 0, y = 0;
9816
- let { width, height, padding } = style;
9817
- const { textDecoration, textOverflow, __font } = style;
9818
- if (!width)
9819
- width = 0;
9838
+ let width = style.__getInput('width') || 0;
9839
+ let height = style.__getInput('height') || 0;
9840
+ const { textDecoration, textOverflow, __font, padding } = style;
9820
9841
  if (padding) {
9821
9842
  const [top, right, bottom, left] = MathHelper.fourNumber(padding);
9822
9843
  if (width) {