@leafer-draw/worker 1.3.1 → 1.3.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.
package/dist/worker.cjs CHANGED
@@ -346,7 +346,7 @@ class Layouter {
346
346
  }
347
347
  partLayout() {
348
348
  var _a;
349
- if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
349
+ if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
350
350
  return;
351
351
  const t = core.Run.start('PartLayout');
352
352
  const { target, __updatedList: updateList } = this;
@@ -533,7 +533,7 @@ class Renderer {
533
533
  partRender() {
534
534
  const { canvas, updateBlocks: list } = this;
535
535
  if (!list)
536
- return debug.warn('PartRender: need update attr');
536
+ return;
537
537
  this.mergeBlocks();
538
538
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
539
539
  this.clipRender(block); });
@@ -1269,7 +1269,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1269
1269
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1270
1270
  PERFORMANCE OF THIS SOFTWARE.
1271
1271
  ***************************************************************************** */
1272
- /* global Reflect, Promise, SuppressedError, Symbol */
1272
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1273
1273
 
1274
1274
 
1275
1275
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -1330,7 +1330,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1330
1330
  }
1331
1331
  else {
1332
1332
  if (!paint.patternTask) {
1333
- paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1333
+ paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
1334
1334
  paint.patternTask = null;
1335
1335
  if (canvas.bounds.hit(ui.__nowWorld))
1336
1336
  createPattern(ui, paint, pixelRatio);
@@ -1486,7 +1486,7 @@ function shadow(ui, current, shape) {
1486
1486
  const end = shadow.length - 1;
1487
1487
  toOffsetOutBounds$1(bounds, offsetOutBounds$1);
1488
1488
  shadow.forEach((item, index) => {
1489
- other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
1489
+ other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, draw.ColorConvert.string(item.color));
1490
1490
  spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
1491
1491
  drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
1492
1492
  copyBounds = bounds;
@@ -1562,7 +1562,7 @@ function innerShadow(ui, current, shape) {
1562
1562
  other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
1563
1563
  copyBounds = bounds;
1564
1564
  }
1565
- other.fillWorld(copyBounds, item.color, 'source-in');
1565
+ other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
1566
1566
  if (ui.__worldFlipped) {
1567
1567
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1568
1568
  }
@@ -1924,7 +1924,7 @@ function layoutChar(drawData, style, width, _height) {
1924
1924
  rows.forEach(row => {
1925
1925
  if (row.words) {
1926
1926
  indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
1927
- addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
1927
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
1928
1928
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
1929
1929
  if (row.isOverflow && !letterSpacing)
1930
1930
  row.textMode = true;
@@ -1946,7 +1946,7 @@ function layoutChar(drawData, style, width, _height) {
1946
1946
  else {
1947
1947
  charX = toChar(word.data, charX, row.data, row.isOverflow);
1948
1948
  }
1949
- if (!row.paraEnd && addWordWidth) {
1949
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
1950
1950
  charX += addWordWidth;
1951
1951
  row.width += addWordWidth;
1952
1952
  }
@@ -347,7 +347,7 @@ class Layouter {
347
347
  }
348
348
  partLayout() {
349
349
  var _a;
350
- if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
350
+ if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
351
351
  return;
352
352
  const t = Run.start('PartLayout');
353
353
  const { target, __updatedList: updateList } = this;
@@ -534,7 +534,7 @@ class Renderer {
534
534
  partRender() {
535
535
  const { canvas, updateBlocks: list } = this;
536
536
  if (!list)
537
- return debug.warn('PartRender: need update attr');
537
+ return;
538
538
  this.mergeBlocks();
539
539
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
540
540
  this.clipRender(block); });
@@ -1270,7 +1270,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1270
1270
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1271
1271
  PERFORMANCE OF THIS SOFTWARE.
1272
1272
  ***************************************************************************** */
1273
- /* global Reflect, Promise, SuppressedError, Symbol */
1273
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1274
1274
 
1275
1275
 
1276
1276
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -1331,7 +1331,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1331
1331
  }
1332
1332
  else {
1333
1333
  if (!paint.patternTask) {
1334
- paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1334
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
1335
1335
  paint.patternTask = null;
1336
1336
  if (canvas.bounds.hit(ui.__nowWorld))
1337
1337
  createPattern(ui, paint, pixelRatio);
@@ -1487,7 +1487,7 @@ function shadow(ui, current, shape) {
1487
1487
  const end = shadow.length - 1;
1488
1488
  toOffsetOutBounds$1(bounds, offsetOutBounds$1);
1489
1489
  shadow.forEach((item, index) => {
1490
- other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
1490
+ other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, ColorConvert.string(item.color));
1491
1491
  spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
1492
1492
  drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
1493
1493
  copyBounds = bounds;
@@ -1563,7 +1563,7 @@ function innerShadow(ui, current, shape) {
1563
1563
  other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
1564
1564
  copyBounds = bounds;
1565
1565
  }
1566
- other.fillWorld(copyBounds, item.color, 'source-in');
1566
+ other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
1567
1567
  if (ui.__worldFlipped) {
1568
1568
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1569
1569
  }
@@ -1925,7 +1925,7 @@ function layoutChar(drawData, style, width, _height) {
1925
1925
  rows.forEach(row => {
1926
1926
  if (row.words) {
1927
1927
  indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
1928
- addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
1928
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
1929
1929
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
1930
1930
  if (row.isOverflow && !letterSpacing)
1931
1931
  row.textMode = true;
@@ -1947,7 +1947,7 @@ function layoutChar(drawData, style, width, _height) {
1947
1947
  else {
1948
1948
  charX = toChar(word.data, charX, row.data, row.isOverflow);
1949
1949
  }
1950
- if (!row.paraEnd && addWordWidth) {
1950
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
1951
1951
  charX += addWordWidth;
1952
1952
  row.width += addWordWidth;
1953
1953
  }
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,defineKey as o,FileHelper as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as _,Bounds as p,LeafBoundsHelper as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as k,AlignHelper as E,ImageEvent as S,AroundHelper as L,PointHelper as A,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,ColorConvert as T,PaintGradient as M,Export as C,Group as D,TextConvert as I,Paint as P,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class G 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:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:Y}=a;function z(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:Y(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:Y(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new G(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},o(e,"devicePixelRatio",{get:()=>1});const{userAgent:U}=navigator;U.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):U.indexOf("Safari")>-1&&-1===U.indexOf("Chrome")&&(e.fullImageShadow=!0),U.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):U.indexOf("Mac")>-1?e.os="Mac":U.indexOf("Linux")>-1&&(e.os="Linux");class N{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=d.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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:X,updateAllWorldOpacity:j}=f,{pushAllChildBranch:V,pushAllParent:H}=_;const{worldBounds:Q}=g,Z={x:0,y:0,width:1e5,height:1e5};class ${constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Z):this.afterBounds.setListWithFn(t,Q),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:J,updateAllChange:K}=f,tt=w.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&V(t,e),H(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),H(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||X(i[t])}X(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&j(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),et.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){J(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new $([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new $(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_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=w.get("Renderer");class it{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new p,nt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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;if(!e)return nt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new p(i);n.save(),s&&!w.showRepaint?n.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,o),n.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),w.showHitView&&this.renderHitView(i),w.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new p(0,0,e,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new p(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||nt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function st(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function ot(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?dt(t,!0,e,n):rt(e,n);break;case"inside":at("inside",t,s,e,n);break;case"outside":at("outside",t,s,e,n)}}function at(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?dt(e,!0,i,r):rt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",st(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function rt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function dt(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?rt(n,i):i.stroke(),i.restoreBlendMode()):e?rt(n,i):i.stroke())}function lt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(i,{watcher:(t,e)=>new N(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,n)=>new it(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=et.fullLayout;const{getSpread:ct,getOuterOf:ht,getByMove:ut,getIntersectData:ft}=B;let _t;function pt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:T.string(a,r)};case"image":return O.image(n,t,e,i,!_t||!_t[e.url]);case"linear":return M.linearGradient(e,i);case"radial":return M.radialGradient(e,i);case"angular":return M.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:T.string(e)}:void 0}}const gt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),_t=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=pt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?st(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&O.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?st(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?st(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?st(e,n):s?n.fill(s):n.fill())},fillText:st,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&lt(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),dt(t,!1,e,n),i.__useArrow&&lt(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),dt(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),dt(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ot,drawTextStroke:rt,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=ft(i?ct(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ht(s,a),o=ut(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let wt={};const{get:yt,rotateOfOuter:mt,translate:vt,scaleOfOuter:xt,scale:bt,rotate:Bt}=R;function Rt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),bt(r,s,o),a&&mt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function kt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),s&&bt(r,s,o),a&&Bt(r,a),t.transform=r}function Et(t,e,n,i,s,o,a,r,d,l){const c=yt();if(d)if("center"===l)mt(c,{x:n/2,y:i/2},d);else switch(Bt(c,d),d){case 90:vt(c,i,0);break;case 180:vt(c,n,i);break;case 270:vt(c,0,n)}wt.x=e.x+s,wt.y=e.y+o,vt(c,wt.x,wt.y),a&&xt(c,wt,a,r),t.transform=c}const{get:St,translate:Lt}=R,At=new p,Wt={},Ot={};function Tt(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Mt(n,i,e)}function Mt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=At.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===i&&e.height===s,_={mode:a},p="center"!==r&&(h||0)%180==90,g=p?s:i,w=p?i:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,n,Ot),y=Ot.scaleX,m=Ot.scaleY);else if(!f||h){const t=e.width/g,n=e.height/w;y=m="fit"===a?Math.min(t,n):Math.max(t,n),v+=(e.width-i*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:g,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Wt,!0),v+=Wt.x,x+=Wt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&kt(_,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Et(_,e,i,s,v,x,y,m,h,r),u||(_.repeat="repeat");break;default:y&&Rt(_,e,v,x,y,m,h)}return _.transform||(e.x||e.y)&&(_.transform=St(),Lt(_.transform,e.x,e.y)),y&&"stretch"!==a&&(_.scaleX=y,_.scaleY=m),_.width=i,_.height=s,o&&(_.opacity=o),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Ct,Dt=new p;const{isSame:It}=B;function Pt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Tt(s,i,n,o),!0}function Ft(t,e){zt(t,S.LOAD,e)}function Gt(t,e){zt(t,S.LOADED,e)}function Yt(t,e,n){e.error=n,t.forceUpdate("surface"),zt(t,S.ERROR,e)}function zt(t,e,n){t.hasEvent(e)&&t.emitEvent(new S(e,n))}function Ut(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Nt,scale:qt,copy:Xt}=R,{ceil:jt,abs:Vt}=Math;function Ht(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=Vt(s),o=Vt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Nt(),Xt(l,p),qt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Nt(),p&&Xt(l,p)),qt(l,1/s,1/o));const m=t.getCanvas(jt(c)||1,jt(h)||1,_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}function Qt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Zt}=Math;const $t={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return Ct&&n===Ct.paint&&It(i,Ct.boxBounds)?o=Ct.leafPaint:(o={type:n.type,image:r},Ct=r.use>1?{leafPaint:o,paint:n,boxBounds:Dt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Pt(t,e,n,r,o,i),s&&(Ft(t,a),Gt(t,a))):r.error?s&&Yt(t,a,r.error):(s&&(Ut(t,!0),Ft(t,a)),o.loadId=r.load((()=>{Ut(t,!1),t.destroyed||(Pt(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{Ut(t,!1),Yt(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n;if(!i.data||i.patternId===o+"-"+a+"-"+r&&!C.running)return!1;{const{data:d}=i;if(s)if(d.repeat)s=!1;else{let{width:t,height:n}=d;t*=Zt(o)*r,n*=Zt(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize||C.running}return s?(n.save(),t.windingRule?n.clip(t.windingRule):n.clip(),i.blendMode&&(n.blendMode=i.blendMode),d.opacity&&(n.opacity*=d.opacity),d.transform&&n.transform(d.transform),n.drawImage(i.image.view,0,0,d.width,d.height),n.restore(),!0):(!i.style||i.sync||C.running?Ht(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Qt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Ht(t,i,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Ht,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a;for(let r=0,d=n.length;r<d;r++)i=n[r].image,a=i&&i.url,a&&(s||(s={}),s[a]=!0,x.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),i.unload(n[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Tt,getPatternData:Mt,fillOrFitMode:Rt,clipMode:kt,repeatMode:Et},{toPoint:Jt}=L,Kt={},te={};function ee(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),T.string(i,n)):t.addColorStop(i.offset,T.string(i.color,n))}}const{getAngle:ne,getDistance:ie}=A,{get:se,rotateOfOuter:oe,scaleOfOuter:ae}=R,{toPoint:re}=L,de={},le={};function ce(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ne(e,n);o=se(),s?(ae(o,e,a/r*(i||1),1),oe(o,e,t+90)):(ae(o,e,1,a/r*(i||1)),oe(o,e,t))}return o}const{getDistance:he}=A,{toPoint:ue}=L,fe={},_e={};const pe={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;Jt(i||"top",n,Kt),Jt(s||"bottom",n,te);const d=e.canvas.createLinearGradient(Kt.x,Kt.y,te.x,te.y);ee(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;re(i||"center",n,de),re(s||"bottom",n,le);const l=e.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ie(de,le));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,de,le,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ue(i||"center",n,fe),ue(s||"bottom",n,_e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,fe.x,fe.y):e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,he(fe,_e));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,fe,_e,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ce},{copy:ge,toOffsetOutBounds:we}=B,ye={},me={};function ve(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ge(ye,t.bounds),ye.x+=n.x-a.x,ye.y+=n.y-a.y,i){const{matrix:t}=s;ye.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),ye.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),ye.width*=i,ye.height*=i}t.copyWorld(s.canvas,t.bounds,ye)}else i&&(ge(ye,n),ye.x-=n.width/2*(i-1),ye.y-=n.height/2*(i-1),ye.width*=i,ye.height*=i),t.copyWorld(s.canvas,a,i?ye:n)}const{toOffsetOutBounds:xe}=B,be={};const Be={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;we(l,me),r.forEach(((r,p)=>{f.setWorldShadow(me.offsetX+r.x*h,me.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,me,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;xe(l,be),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,be,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Re}=g;function ke(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Se(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Se(t,n,i,o);break;case"path":n.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Se(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}D.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(ke(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ee(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ee(t)),s||(s=Ee(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Re(n,e)||n.__render(s||t,e);ke(this,a,t,s,i,o)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Le+"_#~&*+\\=|≮≯≈≠=…",We=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Te=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Me=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ce=Oe(Le),De=Oe(Ae),Ie=Oe("- —/~|┆·");var Pe;!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"}(Pe||(Pe={}));const{Letter:Fe,Single:Ge,Before:Ye,After:ze,Symbol:Ue,Break:Ne}=Pe;function qe(t){return Te[t]?Fe:Ie[t]?Ne:Me[t]?Ye:Ce[t]?ze:De[t]?Ue:We.test(t)?Ge:Fe}const Xe={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function je(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ve}=Xe,{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Je,Break:Ke}=Pe;let tn,en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,_n,pn,gn,wn,yn=[];function mn(t,e){ln&&!dn&&(dn=ln),tn.data.push({char:t,width:e}),nn+=e}function vn(){sn+=nn,tn.width=nn,en.words.push(tn),tn={data:[]},nn=0}function xn(){_n&&(pn.paraNumber++,en.paraStart=!0,_n=!1),ln&&(en.startCharSize=dn,en.endCharSize=ln,dn=0),en.width=sn,gn.width?Ve(en):wn&&bn(),yn.push(en),en={words:[]},sn=0}function bn(){sn>(pn.maxWidth||0)&&(pn.maxWidth=sn)}const Bn=0,Rn=1,kn=2;const{top:En,right:Sn,bottom:Ln,left:An}=W;function Wn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const On={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[An],o-=l[Sn]+l[An]):n.autoSizeAlign||(i=l[An]),a?(s=l[En],a-=l[En]+l[Ln]):n.autoSizeAlign||(s=l[En]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){pn=t,yn=t.rows,gn=t.bounds,wn=!gn.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=gn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;_n=!0,hn=null,dn=rn=ln=nn=sn=0,tn={data:[]},en={words:[]};for(let i=0,l=n.length;i<l;i++)an=n[i],"\n"===an?(nn&&vn(),en.paraEnd=!0,xn(),_n=!0):(cn=qe(an),cn===He&&"none"!==a&&(an=je(an,a,!nn)),rn=r.measureText(an).width,s&&(s<0&&(ln=rn),rn+=s),un=cn===Qe&&(hn===Qe||hn===He)||hn===Qe&&cn!==$e,fn=!(cn!==Ze&&cn!==Qe||hn!==Je&&hn!==$e),on=_n&&o?d-o:d,t&&d&&sn+nn+rn>on&&(e?(nn&&vn(),sn&&xn()):(fn||(fn=cn===He&&hn==$e),un||fn||cn===Ke||cn===Ze||cn===Qe||nn+rn>on?(nn&&vn(),sn&&xn()):sn&&xn()))," "===an&&!0!==_n&&sn+nn===0||(cn===Ke?(" "===an&&nn&&vn(),mn(an,rn),vn()):un||fn?(nn&&vn(),mn(an,rn)):mn(an,rn)),hn=cn);nn&&vn(),sn&&xn(),yn.length>0&&(yn[yn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{pn.paraNumber++,sn=r.measureText(t).width,yn.push({x:o||0,text:t,width:sn,paraStart:!0}),wn&&bn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Wn(e,"x",t[An]);break;case"right":Wn(e,"x",-t[Sn])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Wn(e,"y",t[En]);break;case"bottom":Wn(e,"y",-t[Ln])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:_,height:p}=i,g=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&g>p)g=Math.max(p,s),t.overflow=n.length;else if(p||h)switch(l){case"middle":f+=(p-g)/2;break;case"bottom":f+=p-g}w+=f;let y,m,v,x=_||h?_:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(y=n[o],y.x=u,y.width<_||y.width>_&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=s,t.overflow>o&&w>g&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&_&&_<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=g}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Bn:l>.01?Rn:kn,t.isOverflow&&!r&&(t.textMode=!0),h===kn?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Rn?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Tn={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!T.object)return t;t=T.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(I,On),Object.assign(T,Tn),Object.assign(P,gt),Object.assign(O,$t),Object.assign(M,pe),Object.assign(F,Be),z();export{et as Layouter,G as LeaferCanvas,it as Renderer,N as Watcher,z as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,defineKey as o,FileHelper as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as _,Bounds as p,LeafBoundsHelper as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as k,AlignHelper as E,ImageEvent as S,AroundHelper as L,PointHelper as A,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,ColorConvert as T,PaintGradient as M,Export as C,Group as D,TextConvert as I,Paint as P,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class G 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:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:Y}=a;function z(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:Y(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:Y(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new G(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},o(e,"devicePixelRatio",{get:()=>1});const{userAgent:U}=navigator;U.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):U.indexOf("Safari")>-1&&-1===U.indexOf("Chrome")&&(e.fullImageShadow=!0),U.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):U.indexOf("Mac")>-1?e.os="Mac":U.indexOf("Linux")>-1&&(e.os="Linux");class N{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=d.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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:X,updateAllWorldOpacity:j}=f,{pushAllChildBranch:V,pushAllParent:H}=_;const{worldBounds:Q}=g,Z={x:0,y:0,width:1e5,height:1e5};class ${constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Z):this.afterBounds.setListWithFn(t,Q),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:J,updateAllChange:K}=f,tt=w.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&V(t,e),H(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),H(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||X(i[t])}X(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&j(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),et.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){J(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new $([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new $(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_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=w.get("Renderer");class it{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new p,nt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new p(i);n.save(),s&&!w.showRepaint?n.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,o),n.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),w.showHitView&&this.renderHitView(i),w.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new p(0,0,e,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new p(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||nt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function st(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function ot(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?dt(t,!0,e,n):rt(e,n);break;case"inside":at("inside",t,s,e,n);break;case"outside":at("outside",t,s,e,n)}}function at(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?dt(e,!0,i,r):rt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",st(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function rt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function dt(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?rt(n,i):i.stroke(),i.restoreBlendMode()):e?rt(n,i):i.stroke())}function lt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(i,{watcher:(t,e)=>new N(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,n)=>new it(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=et.fullLayout;const{getSpread:ct,getOuterOf:ht,getByMove:ut,getIntersectData:ft}=B;let _t;function pt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:T.string(a,r)};case"image":return O.image(n,t,e,i,!_t||!_t[e.url]);case"linear":return M.linearGradient(e,i);case"radial":return M.radialGradient(e,i);case"angular":return M.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:T.string(e)}:void 0}}const gt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),_t=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=pt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?st(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&O.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?st(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?st(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?st(e,n):s?n.fill(s):n.fill())},fillText:st,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&lt(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),dt(t,!1,e,n),i.__useArrow&&lt(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),dt(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),dt(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ot,drawTextStroke:rt,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=ft(i?ct(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ht(s,a),o=ut(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let wt={};const{get:yt,rotateOfOuter:mt,translate:vt,scaleOfOuter:xt,scale:bt,rotate:Bt}=R;function Rt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),bt(r,s,o),a&&mt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function kt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),s&&bt(r,s,o),a&&Bt(r,a),t.transform=r}function Et(t,e,n,i,s,o,a,r,d,l){const c=yt();if(d)if("center"===l)mt(c,{x:n/2,y:i/2},d);else switch(Bt(c,d),d){case 90:vt(c,i,0);break;case 180:vt(c,n,i);break;case 270:vt(c,0,n)}wt.x=e.x+s,wt.y=e.y+o,vt(c,wt.x,wt.y),a&&xt(c,wt,a,r),t.transform=c}const{get:St,translate:Lt}=R,At=new p,Wt={},Ot={};function Tt(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Mt(n,i,e)}function Mt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=At.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===i&&e.height===s,_={mode:a},p="center"!==r&&(h||0)%180==90,g=p?s:i,w=p?i:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,n,Ot),y=Ot.scaleX,m=Ot.scaleY);else if(!f||h){const t=e.width/g,n=e.height/w;y=m="fit"===a?Math.min(t,n):Math.max(t,n),v+=(e.width-i*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:g,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Wt,!0),v+=Wt.x,x+=Wt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&kt(_,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Et(_,e,i,s,v,x,y,m,h,r),u||(_.repeat="repeat");break;default:y&&Rt(_,e,v,x,y,m,h)}return _.transform||(e.x||e.y)&&(_.transform=St(),Lt(_.transform,e.x,e.y)),y&&"stretch"!==a&&(_.scaleX=y,_.scaleY=m),_.width=i,_.height=s,o&&(_.opacity=o),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Ct,Dt=new p;const{isSame:It}=B;function Pt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Tt(s,i,n,o),!0}function Ft(t,e){zt(t,S.LOAD,e)}function Gt(t,e){zt(t,S.LOADED,e)}function Yt(t,e,n){e.error=n,t.forceUpdate("surface"),zt(t,S.ERROR,e)}function zt(t,e,n){t.hasEvent(e)&&t.emitEvent(new S(e,n))}function Ut(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Nt,scale:qt,copy:Xt}=R,{ceil:jt,abs:Vt}=Math;function Ht(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=Vt(s),o=Vt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Nt(),Xt(l,p),qt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Nt(),p&&Xt(l,p)),qt(l,1/s,1/o));const m=t.getCanvas(jt(c)||1,jt(h)||1,_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}function Qt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Zt}=Math;const $t={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return Ct&&n===Ct.paint&&It(i,Ct.boxBounds)?o=Ct.leafPaint:(o={type:n.type,image:r},Ct=r.use>1?{leafPaint:o,paint:n,boxBounds:Dt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Pt(t,e,n,r,o,i),s&&(Ft(t,a),Gt(t,a))):r.error?s&&Yt(t,a,r.error):(s&&(Ut(t,!0),Ft(t,a)),o.loadId=r.load((()=>{Ut(t,!1),t.destroyed||(Pt(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{Ut(t,!1),Yt(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n;if(!i.data||i.patternId===o+"-"+a+"-"+r&&!C.running)return!1;{const{data:d}=i;if(s)if(d.repeat)s=!1;else{let{width:t,height:n}=d;t*=Zt(o)*r,n*=Zt(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize||C.running}return s?(n.save(),t.windingRule?n.clip(t.windingRule):n.clip(),i.blendMode&&(n.blendMode=i.blendMode),d.opacity&&(n.opacity*=d.opacity),d.transform&&n.transform(d.transform),n.drawImage(i.image.view,0,0,d.width,d.height),n.restore(),!0):(!i.style||i.sync||C.running?Ht(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Qt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Ht(t,i,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Ht,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a;for(let r=0,d=n.length;r<d;r++)i=n[r].image,a=i&&i.url,a&&(s||(s={}),s[a]=!0,x.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),i.unload(n[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Tt,getPatternData:Mt,fillOrFitMode:Rt,clipMode:kt,repeatMode:Et},{toPoint:Jt}=L,Kt={},te={};function ee(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),T.string(i,n)):t.addColorStop(i.offset,T.string(i.color,n))}}const{getAngle:ne,getDistance:ie}=A,{get:se,rotateOfOuter:oe,scaleOfOuter:ae}=R,{toPoint:re}=L,de={},le={};function ce(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ne(e,n);o=se(),s?(ae(o,e,a/r*(i||1),1),oe(o,e,t+90)):(ae(o,e,1,a/r*(i||1)),oe(o,e,t))}return o}const{getDistance:he}=A,{toPoint:ue}=L,fe={},_e={};const pe={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;Jt(i||"top",n,Kt),Jt(s||"bottom",n,te);const d=e.canvas.createLinearGradient(Kt.x,Kt.y,te.x,te.y);ee(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;re(i||"center",n,de),re(s||"bottom",n,le);const l=e.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ie(de,le));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,de,le,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ue(i||"center",n,fe),ue(s||"bottom",n,_e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,fe.x,fe.y):e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,he(fe,_e));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,fe,_e,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ce},{copy:ge,toOffsetOutBounds:we}=B,ye={},me={};function ve(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ge(ye,t.bounds),ye.x+=n.x-a.x,ye.y+=n.y-a.y,i){const{matrix:t}=s;ye.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),ye.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),ye.width*=i,ye.height*=i}t.copyWorld(s.canvas,t.bounds,ye)}else i&&(ge(ye,n),ye.x-=n.width/2*(i-1),ye.y-=n.height/2*(i-1),ye.width*=i,ye.height*=i),t.copyWorld(s.canvas,a,i?ye:n)}const{toOffsetOutBounds:xe}=B,be={};const Be={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;we(l,me),r.forEach(((r,p)=>{f.setWorldShadow(me.offsetX+r.x*h,me.offsetY+r.y*u,r.blur*h,T.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,me,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;xe(l,be),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,be,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,T.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Re}=g;function ke(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Se(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Se(t,n,i,o);break;case"path":n.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Se(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}D.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(ke(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ee(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ee(t)),s||(s=Ee(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Re(n,e)||n.__render(s||t,e);ke(this,a,t,s,i,o)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Le+"_#~&*+\\=|≮≯≈≠=…",We=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Te=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Me=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ce=Oe(Le),De=Oe(Ae),Ie=Oe("- —/~|┆·");var Pe;!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"}(Pe||(Pe={}));const{Letter:Fe,Single:Ge,Before:Ye,After:ze,Symbol:Ue,Break:Ne}=Pe;function qe(t){return Te[t]?Fe:Ie[t]?Ne:Me[t]?Ye:Ce[t]?ze:De[t]?Ue:We.test(t)?Ge:Fe}const Xe={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function je(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ve}=Xe,{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Je,Break:Ke}=Pe;let tn,en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,_n,pn,gn,wn,yn=[];function mn(t,e){ln&&!dn&&(dn=ln),tn.data.push({char:t,width:e}),nn+=e}function vn(){sn+=nn,tn.width=nn,en.words.push(tn),tn={data:[]},nn=0}function xn(){_n&&(pn.paraNumber++,en.paraStart=!0,_n=!1),ln&&(en.startCharSize=dn,en.endCharSize=ln,dn=0),en.width=sn,gn.width?Ve(en):wn&&bn(),yn.push(en),en={words:[]},sn=0}function bn(){sn>(pn.maxWidth||0)&&(pn.maxWidth=sn)}const{top:Bn,right:Rn,bottom:kn,left:En}=W;function Sn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Ln={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[En],o-=l[Rn]+l[En]):n.autoSizeAlign||(i=l[En]),a?(s=l[Bn],a-=l[Bn]+l[kn]):n.autoSizeAlign||(s=l[Bn]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){pn=t,yn=t.rows,gn=t.bounds,wn=!gn.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=gn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;_n=!0,hn=null,dn=rn=ln=nn=sn=0,tn={data:[]},en={words:[]};for(let i=0,l=n.length;i<l;i++)an=n[i],"\n"===an?(nn&&vn(),en.paraEnd=!0,xn(),_n=!0):(cn=qe(an),cn===He&&"none"!==a&&(an=je(an,a,!nn)),rn=r.measureText(an).width,s&&(s<0&&(ln=rn),rn+=s),un=cn===Qe&&(hn===Qe||hn===He)||hn===Qe&&cn!==$e,fn=!(cn!==Ze&&cn!==Qe||hn!==Je&&hn!==$e),on=_n&&o?d-o:d,t&&d&&sn+nn+rn>on&&(e?(nn&&vn(),sn&&xn()):(fn||(fn=cn===He&&hn==$e),un||fn||cn===Ke||cn===Ze||cn===Qe||nn+rn>on?(nn&&vn(),sn&&xn()):sn&&xn()))," "===an&&!0!==_n&&sn+nn===0||(cn===Ke?(" "===an&&nn&&vn(),mn(an,rn),vn()):un||fn?(nn&&vn(),mn(an,rn)):mn(an,rn)),hn=cn);nn&&vn(),sn&&xn(),yn.length>0&&(yn[yn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{pn.paraNumber++,sn=r.measureText(t).width,yn.push({x:o||0,text:t,width:sn,paraStart:!0}),wn&&bn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Sn(e,"x",t[En]);break;case"right":Sn(e,"x",-t[Rn])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Sn(e,"y",t[Bn]);break;case"bottom":Sn(e,"y",-t[kn])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:_,height:p}=i,g=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&g>p)g=Math.max(p,s),t.overflow=n.length;else if(p||h)switch(l){case"middle":f+=(p-g)/2;break;case"bottom":f+=p-g}w+=f;let y,m,v,x=_||h?_:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(y=n[o],y.x=u,y.width<_||y.width>_&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=s,t.overflow>o&&w>g&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&_&&_<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=g}(c,n),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h;i.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,d=n&&("justify"===s||"both"===s)&&t.words.length>1?(n-t.width-l)/(t.words.length-1):0,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach((e=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||(r+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const An={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!T.object)return t;t=T.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(I,Ln),Object.assign(T,An),Object.assign(P,gt),Object.assign(O,$t),Object.assign(M,pe),Object.assign(F,Be),z();export{et as Layouter,G as LeaferCanvas,it as Renderer,N as Watcher,z as useCanvas};