leafer-draw 1.9.4 → 1.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.cjs CHANGED
@@ -93,10 +93,22 @@ class LeaferCanvas extends core.LeaferCanvasBase {
93
93
  updateViewSize() {
94
94
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
95
95
  const {style: style} = this.view;
96
- style.width = width + "px";
97
- style.height = height + "px";
98
- this.view.width = Math.ceil(width * pixelRatio);
99
- this.view.height = Math.ceil(height * pixelRatio);
96
+ if (this.unreal) {
97
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
98
+ if (config.width) {
99
+ if (core.isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
100
+ style.width = config.width + "px";
101
+ } else if (!core.isUndefined(autoWidthStr)) style.width = autoWidthStr;
102
+ if (config.height) {
103
+ if (core.isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
104
+ style.height = config.height + "px";
105
+ } else if (!core.isUndefined(autoHeightStr)) style.height = autoHeightStr;
106
+ } else {
107
+ style.width = width + "px";
108
+ style.height = height + "px";
109
+ this.view.width = Math.ceil(width * pixelRatio);
110
+ this.view.height = Math.ceil(height * pixelRatio);
111
+ }
100
112
  }
101
113
  updateClientBounds() {
102
114
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -105,6 +117,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
105
117
  this.resizeListener = listener;
106
118
  if (autoBounds) {
107
119
  this.autoBounds = autoBounds;
120
+ if (this.resizeObserver) return;
108
121
  try {
109
122
  this.resizeObserver = new ResizeObserver(entries => {
110
123
  this.updateClientBounds();
@@ -121,18 +134,10 @@ class LeaferCanvas extends core.LeaferCanvasBase {
121
134
  } catch (_a) {
122
135
  this.imitateResizeObserver();
123
136
  }
137
+ this.stopListenPixelRatio();
124
138
  } else {
125
- window.addEventListener("resize", this.windowListener = () => {
126
- const pixelRatio = core.Platform.devicePixelRatio;
127
- if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
128
- const {width: width, height: height} = this;
129
- this.emitResize({
130
- width: width,
131
- height: height,
132
- pixelRatio: pixelRatio
133
- });
134
- }
135
- });
139
+ this.listenPixelRatio();
140
+ if (this.unreal) this.updateViewSize();
136
141
  }
137
142
  }
138
143
  imitateResizeObserver() {
@@ -141,6 +146,25 @@ class LeaferCanvas extends core.LeaferCanvasBase {
141
146
  core.Platform.requestRender(this.imitateResizeObserver.bind(this));
142
147
  }
143
148
  }
149
+ listenPixelRatio() {
150
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
151
+ const pixelRatio = core.Platform.devicePixelRatio;
152
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
153
+ const {width: width, height: height} = this;
154
+ this.emitResize({
155
+ width: width,
156
+ height: height,
157
+ pixelRatio: pixelRatio
158
+ });
159
+ }
160
+ });
161
+ }
162
+ stopListenPixelRatio() {
163
+ if (this.windowListener) {
164
+ window.removeEventListener("resize", this.windowListener);
165
+ this.windowListener = null;
166
+ }
167
+ }
144
168
  checkAutoBounds(parentSize) {
145
169
  const view = this.view;
146
170
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -178,10 +202,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
178
202
  destroy() {
179
203
  if (this.view) {
180
204
  this.stopAutoLayout();
181
- if (this.windowListener) {
182
- window.removeEventListener("resize", this.windowListener);
183
- this.windowListener = null;
184
- }
205
+ this.stopListenPixelRatio();
185
206
  if (!this.unreal) {
186
207
  const view = this.view;
187
208
  if (view.parentElement) view.remove();
@@ -610,7 +631,7 @@ class Renderer {
610
631
  this.times = 0;
611
632
  this.config = {
612
633
  usePartRender: true,
613
- maxFPS: 60
634
+ maxFPS: 120
614
635
  };
615
636
  this.target = target;
616
637
  this.canvas = canvas;
@@ -765,11 +786,15 @@ class Renderer {
765
786
  if (this.requestTime || !target) return;
766
787
  if (target.parentApp) return target.parentApp.requestRender(false);
767
788
  const requestTime = this.requestTime = Date.now();
768
- core.Platform.requestRender(() => {
769
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
789
+ const render = () => {
790
+ const nowFPS = 1e3 / (Date.now() - requestTime);
791
+ const {maxFPS: maxFPS} = this.config;
792
+ if (maxFPS && nowFPS > maxFPS - .5) return core.Platform.requestRender(render);
793
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
770
794
  this.requestTime = 0;
771
795
  this.checkRender();
772
- });
796
+ };
797
+ core.Platform.requestRender(render);
773
798
  }
774
799
  __onResize(e) {
775
800
  if (this.canvas.unreal) return;
@@ -812,7 +837,8 @@ class Renderer {
812
837
  if (this.target) {
813
838
  this.stop();
814
839
  this.__removeListenEvents();
815
- this.target = this.canvas = this.config = null;
840
+ this.config = {};
841
+ this.target = this.canvas = null;
816
842
  }
817
843
  }
818
844
  }
@@ -1451,7 +1477,7 @@ function ignoreRender(ui, value) {
1451
1477
 
1452
1478
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1453
1479
 
1454
- const {floor: floor, max: max, abs: abs} = Math;
1480
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1455
1481
 
1456
1482
  function createPattern(ui, paint, pixelRatio) {
1457
1483
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1461,8 +1487,6 @@ function createPattern(ui, paint, pixelRatio) {
1461
1487
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1462
1488
  scaleX *= pixelRatio;
1463
1489
  scaleY *= pixelRatio;
1464
- const xGap = gap && gap.x * scaleX;
1465
- const yGap = gap && gap.y * scaleY;
1466
1490
  if (sx) {
1467
1491
  sx = abs(sx);
1468
1492
  sy = abs(sy);
@@ -1479,7 +1503,10 @@ function createPattern(ui, paint, pixelRatio) {
1479
1503
  if (size > core.Platform.image.maxCacheSize) return false;
1480
1504
  }
1481
1505
  let maxSize = core.Platform.image.maxPatternSize;
1482
- if (!image.isSVG) {
1506
+ if (image.isSVG) {
1507
+ const ws = width / image.width;
1508
+ if (ws > 1) imageScale = ws / ceil(ws);
1509
+ } else {
1483
1510
  const imageSize = image.width * image.height;
1484
1511
  if (maxSize > imageSize) maxSize = imageSize;
1485
1512
  }
@@ -1494,18 +1521,20 @@ function createPattern(ui, paint, pixelRatio) {
1494
1521
  scaleX /= sx;
1495
1522
  scaleY /= sy;
1496
1523
  }
1524
+ const xGap = gap && gap.x * scaleX;
1525
+ const yGap = gap && gap.y * scaleY;
1497
1526
  if (transform || scaleX !== 1 || scaleY !== 1) {
1527
+ const canvasWidth = width + (xGap || 0);
1528
+ const canvasHeight = height + (yGap || 0);
1529
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1530
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1498
1531
  if (!imageMatrix) {
1499
1532
  imageMatrix = get$1();
1500
1533
  if (transform) copy$1(imageMatrix, transform);
1501
1534
  }
1502
1535
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1503
1536
  }
1504
- if (imageMatrix) {
1505
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1506
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1507
- }
1508
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1537
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1509
1538
  const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1510
1539
  paint.style = pattern;
1511
1540
  paint.patternId = id;
package/dist/web.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Debug, LeaferCanvasBase, Platform, isString, DataHelper, canvasSizeAttrs, isUndefined, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, LeafLevelList, LayoutEvent, Run, ImageManager, isObject, BoundsHelper, Matrix, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
1
+ import { Debug, LeaferCanvasBase, Platform, isString, isUndefined, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, LeafLevelList, LayoutEvent, Run, ImageManager, isObject, BoundsHelper, Matrix, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
2
2
 
3
3
  export * from "@leafer/core";
4
4
 
@@ -97,10 +97,22 @@ class LeaferCanvas extends LeaferCanvasBase {
97
97
  updateViewSize() {
98
98
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
99
99
  const {style: style} = this.view;
100
- style.width = width + "px";
101
- style.height = height + "px";
102
- this.view.width = Math.ceil(width * pixelRatio);
103
- this.view.height = Math.ceil(height * pixelRatio);
100
+ if (this.unreal) {
101
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
102
+ if (config.width) {
103
+ if (isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
104
+ style.width = config.width + "px";
105
+ } else if (!isUndefined(autoWidthStr)) style.width = autoWidthStr;
106
+ if (config.height) {
107
+ if (isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
108
+ style.height = config.height + "px";
109
+ } else if (!isUndefined(autoHeightStr)) style.height = autoHeightStr;
110
+ } else {
111
+ style.width = width + "px";
112
+ style.height = height + "px";
113
+ this.view.width = Math.ceil(width * pixelRatio);
114
+ this.view.height = Math.ceil(height * pixelRatio);
115
+ }
104
116
  }
105
117
  updateClientBounds() {
106
118
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -109,6 +121,7 @@ class LeaferCanvas extends LeaferCanvasBase {
109
121
  this.resizeListener = listener;
110
122
  if (autoBounds) {
111
123
  this.autoBounds = autoBounds;
124
+ if (this.resizeObserver) return;
112
125
  try {
113
126
  this.resizeObserver = new ResizeObserver(entries => {
114
127
  this.updateClientBounds();
@@ -125,18 +138,10 @@ class LeaferCanvas extends LeaferCanvasBase {
125
138
  } catch (_a) {
126
139
  this.imitateResizeObserver();
127
140
  }
141
+ this.stopListenPixelRatio();
128
142
  } else {
129
- window.addEventListener("resize", this.windowListener = () => {
130
- const pixelRatio = Platform.devicePixelRatio;
131
- if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
132
- const {width: width, height: height} = this;
133
- this.emitResize({
134
- width: width,
135
- height: height,
136
- pixelRatio: pixelRatio
137
- });
138
- }
139
- });
143
+ this.listenPixelRatio();
144
+ if (this.unreal) this.updateViewSize();
140
145
  }
141
146
  }
142
147
  imitateResizeObserver() {
@@ -145,6 +150,25 @@ class LeaferCanvas extends LeaferCanvasBase {
145
150
  Platform.requestRender(this.imitateResizeObserver.bind(this));
146
151
  }
147
152
  }
153
+ listenPixelRatio() {
154
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
155
+ const pixelRatio = Platform.devicePixelRatio;
156
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
157
+ const {width: width, height: height} = this;
158
+ this.emitResize({
159
+ width: width,
160
+ height: height,
161
+ pixelRatio: pixelRatio
162
+ });
163
+ }
164
+ });
165
+ }
166
+ stopListenPixelRatio() {
167
+ if (this.windowListener) {
168
+ window.removeEventListener("resize", this.windowListener);
169
+ this.windowListener = null;
170
+ }
171
+ }
148
172
  checkAutoBounds(parentSize) {
149
173
  const view = this.view;
150
174
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -182,10 +206,7 @@ class LeaferCanvas extends LeaferCanvasBase {
182
206
  destroy() {
183
207
  if (this.view) {
184
208
  this.stopAutoLayout();
185
- if (this.windowListener) {
186
- window.removeEventListener("resize", this.windowListener);
187
- this.windowListener = null;
188
- }
209
+ this.stopListenPixelRatio();
189
210
  if (!this.unreal) {
190
211
  const view = this.view;
191
212
  if (view.parentElement) view.remove();
@@ -614,7 +635,7 @@ class Renderer {
614
635
  this.times = 0;
615
636
  this.config = {
616
637
  usePartRender: true,
617
- maxFPS: 60
638
+ maxFPS: 120
618
639
  };
619
640
  this.target = target;
620
641
  this.canvas = canvas;
@@ -769,11 +790,15 @@ class Renderer {
769
790
  if (this.requestTime || !target) return;
770
791
  if (target.parentApp) return target.parentApp.requestRender(false);
771
792
  const requestTime = this.requestTime = Date.now();
772
- Platform.requestRender(() => {
773
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
793
+ const render = () => {
794
+ const nowFPS = 1e3 / (Date.now() - requestTime);
795
+ const {maxFPS: maxFPS} = this.config;
796
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
797
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
774
798
  this.requestTime = 0;
775
799
  this.checkRender();
776
- });
800
+ };
801
+ Platform.requestRender(render);
777
802
  }
778
803
  __onResize(e) {
779
804
  if (this.canvas.unreal) return;
@@ -816,7 +841,8 @@ class Renderer {
816
841
  if (this.target) {
817
842
  this.stop();
818
843
  this.__removeListenEvents();
819
- this.target = this.canvas = this.config = null;
844
+ this.config = {};
845
+ this.target = this.canvas = null;
820
846
  }
821
847
  }
822
848
  }
@@ -1455,7 +1481,7 @@ function ignoreRender(ui, value) {
1455
1481
 
1456
1482
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1457
1483
 
1458
- const {floor: floor, max: max, abs: abs} = Math;
1484
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1459
1485
 
1460
1486
  function createPattern(ui, paint, pixelRatio) {
1461
1487
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1465,8 +1491,6 @@ function createPattern(ui, paint, pixelRatio) {
1465
1491
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1466
1492
  scaleX *= pixelRatio;
1467
1493
  scaleY *= pixelRatio;
1468
- const xGap = gap && gap.x * scaleX;
1469
- const yGap = gap && gap.y * scaleY;
1470
1494
  if (sx) {
1471
1495
  sx = abs(sx);
1472
1496
  sy = abs(sy);
@@ -1483,7 +1507,10 @@ function createPattern(ui, paint, pixelRatio) {
1483
1507
  if (size > Platform.image.maxCacheSize) return false;
1484
1508
  }
1485
1509
  let maxSize = Platform.image.maxPatternSize;
1486
- if (!image.isSVG) {
1510
+ if (image.isSVG) {
1511
+ const ws = width / image.width;
1512
+ if (ws > 1) imageScale = ws / ceil(ws);
1513
+ } else {
1487
1514
  const imageSize = image.width * image.height;
1488
1515
  if (maxSize > imageSize) maxSize = imageSize;
1489
1516
  }
@@ -1498,18 +1525,20 @@ function createPattern(ui, paint, pixelRatio) {
1498
1525
  scaleX /= sx;
1499
1526
  scaleY /= sy;
1500
1527
  }
1528
+ const xGap = gap && gap.x * scaleX;
1529
+ const yGap = gap && gap.y * scaleY;
1501
1530
  if (transform || scaleX !== 1 || scaleY !== 1) {
1531
+ const canvasWidth = width + (xGap || 0);
1532
+ const canvasHeight = height + (yGap || 0);
1533
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1534
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1502
1535
  if (!imageMatrix) {
1503
1536
  imageMatrix = get$1();
1504
1537
  if (transform) copy$1(imageMatrix, transform);
1505
1538
  }
1506
1539
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1507
1540
  }
1508
- if (imageMatrix) {
1509
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1510
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1511
- }
1512
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1541
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1513
1542
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1514
1543
  paint.style = pattern;
1515
1544
  paint.patternId = id;
@@ -1,2 +1,2 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,DataHelper as n,canvasSizeAttrs as a,isUndefined as o,ResizeEvent as r,canvasPatch as l,FileHelper as d,Creator as h,LeaferImage as c,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as y,BranchHelper as m,LeafBoundsHelper as v,Bounds as x,isArray as b,LeafLevelList as k,LayoutEvent as B,Run as S,ImageManager as E,isObject as R,BoundsHelper as L,Matrix as A,getMatrixData as C,MatrixHelper as O,MathHelper as T,AlignHelper as W,PointHelper as D,ImageEvent as M,AroundHelper as P,Direction4 as I,isNumber as z}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as F,Paint as U,ColorConvert as V,PaintGradient as Y,Export as G,Group as N,TextConvert as X,Effect as q}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const j=t.get("LeaferCanvas");class H extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else j.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),j.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:a,height:o}=this.autoBounds.getBoundsFrom(t),r={width:a,height:o,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};n.copyAttrs(e,this,a),this.resize(t),this.resizeListener&&!o(this.width)&&this.resizeListener(new r(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}l(CanvasRenderingContext2D.prototype),l(Path2D.prototype);const{mineType:Q,fileType:Z}=d;function $(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=Q(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,Q(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(Q(Z(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:a}=i.image;a&&(n.setAttribute("crossOrigin",a),n.crossOrigin=a),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=h.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(h,{canvas:(t,e)=>new H(t,e),image:t=>new c(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:J}=navigator;J.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),J.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):J.indexOf("Mac")>-1?i.os="Mac":J.indexOf("Linux")>-1&&(i.os="Linux");class K{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:tt,updateBounds:et,updateChange:it}=y,{pushAllChildBranch:st,pushAllParent:nt}=m;const{worldBounds:at}=v;class ot{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:rt,updateAllChange:lt}=y,dt=t.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.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=S.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=B,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new B(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||et(s[t])}et(i)}})}(this.__levelList),function(t){t.list.forEach(it)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new B(a,r,this.times)),i.emitEvent(new B(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,S.end(e)}fullLayout(){const t=S.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),ht.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),S.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?m.updateBounds(t):y.updateBounds(t),lt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=t.get("Renderer");class ut{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=n.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,ct.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=S.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(ut.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),S.end(e)}fullRender(){const t=S.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),S.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),a=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const e=this.requestTime=Date.now();i.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.checkRender()})}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[r.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function ft(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function pt(t,e){t.__.__font?ft(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function gt(t,e,i){switch(e.__.strokeAlign){case"center":_t(t,1,e,i);break;case"inside":wt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?_t(t,2,e,i):wt(t,"outside",e,i)}}function _t(t,e,i,s){const n=i.__;R(t)?mt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),yt(i,s))}function wt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,_t(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",ft(i,n),n.blendMode="normal",y.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function yt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function mt(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!F.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?yt(s,n):n.stroke(),n.restoreBlendMode()):i?yt(s,n):n.stroke()}}function vt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)gt(t,e,i);else switch(s.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),xt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)xt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),xt(t,2,e,a),a.clipUI(s),a.clearWorld(n),y.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function xt(t,e,i,s){const n=i.__;R(t)?mt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&U.strokeArrow(t,i,s)}ut.clipSpread=10,Object.assign(h,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=ht.fullLayout;const{getSpread:bt,getOuterOf:kt,getByMove:Bt,getIntersectData:St}=L;let Et;const{stintSet:Rt}=n,{hasTransparent:Lt}=V;function At(t,e,i){if(!R(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:a}=i.__layout;switch(e.type){case"image":n=F.image(i,t,e,a,!Et||!Et[e.url]);break;case"linear":n=Y.linearGradient(e,a);break;case"radial":n=Y.radialGradient(e,a);break;case"angular":n=Y.conicGradient(e,a);break;case"solid":const{type:s,color:r,opacity:l}=e;n={type:s,style:V.string(r,l)};break;default:o(e.r)||(n={type:"solid",style:V.string(e)})}if(n){if(s(n.style)&&Lt(n.style)&&(n.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}e.editing&&(n.editing=e.editing),e.blendMode&&(n.blendMode=e.blendMode)}return n}const Ct={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];b(r)||(r=[r]),Et=F.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=At(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Rt(i,"__isAlphaPixelFill",n),Rt(i,"__isTransparentFill",a)):(Rt(i,"__isAlphaPixelStroke",n),Rt(i,"__isTransparentStroke",a),Rt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,pt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(F.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),pt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),pt(e,i),i.restoreBlendMode()):pt(e,i)}},fillPathOrText:pt,fillText:ft,stroke:vt,strokes:function(t,e,i){vt(t,e,i)},strokeText:gt,drawTextStroke:yt,shape:function(t,e,s){const n=e.getSameCanvas(),a=t.__nowWorld,o=e.bounds;let r,l,d,h,c,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))c=n,r=h=a;else{const{renderShapeSpread:n}=t.__layout;let p;if(i.fullImageShadow)p=a;else{const t=n?bt(o,u===f?n*u:[n*f,n*u]):o;p=St(t,a)}d=o.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(c=e.getSameCanvas(),t.__renderShape(c,s),u*=g,f*=_),h=kt(a,d),r=Bt(h,-d.e,-d.f);const w=s.matrix;w?(l=new A(d),l.multiply(w),g*=w.scaleX,_*=w.scaleY):l=d,l.withScale(g,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:d,bounds:r,worldCanvas:c,shapeBounds:h,scaleX:u,scaleY:f}}};let Ot={},Tt=C();const{get:Wt,rotateOfOuter:Dt,translate:Mt,scaleOfOuter:Pt,multiplyParent:It,scale:zt,rotate:Ft,skew:Ut}=O;function Vt(t,e,i,s,n,a,o){const r=Wt();Mt(r,e.x+i,e.y+s),zt(r,n,a),o&&Dt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Yt(t,e,i,s,n,a,o,r,l){const d=Wt();Nt(d,e,i,s,n,a,o,r),l&&(Tt.a=e.width/l.width,Tt.d=e.height/l.height,It(d,Tt)),t.transform=d}function Gt(t,e,i,s,n,a,o,r,l,d,h,c){const u=Wt();if(c)Nt(u,e,n,a,o,r,l,d);else{if(l)if("center"===h)Dt(u,{x:i/2,y:s/2},l);else switch(Ft(u,l),l){case 90:Mt(u,s,0);break;case 180:Mt(u,i,s);break;case 270:Mt(u,0,i)}Ot.x=e.x+n,Ot.y=e.y+a,Mt(u,Ot.x,Ot.y),o&&Pt(u,Ot,o,r)}t.transform=u}function Nt(t,e,i,s,n,a,o,r){o&&Ft(t,o),r&&Ut(t,r.x,r.y),n&&zt(t,n,a),Mt(t,e.x+i,e.y+s)}const{get:Xt,translate:qt}=O,jt=new x,Ht={},Qt={};function Zt(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=$t(i,s,e)}function $t(t,e,i){t.padding&&(e=jt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:a}=i;const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,y=e.width===n&&e.height===a,m={mode:r},v="center"!==l&&(u||0)%180==90;let x,b;switch(L.set(Qt,0,0,v?a:n,v?n:a),r&&"cover"!==r&&"fit"!==r?((h||c)&&(T.getScaleData(h,c,i,Ht),x=Ht.scaleX,b=Ht.scaleY),(l||_||g)&&(x&&L.scale(Qt,x,b,!0),l&&W.toPoint(l,Qt,e,Qt,!0,!0))):y&&!u||(x=b=L.getFitScale(e,Qt,"fit"!==r),L.put(e,i,l,x,!1,Qt),L.scale(Qt,x,b,!0)),d&&D.move(Qt,d),r){case"stretch":y||(n=e.width,a=e.height);break;case"normal":case"clip":(Qt.x||Qt.y||x||p||u||f)&&Yt(m,e,Qt.x,Qt.y,x,b,u,f,t.clipSize);break;case"repeat":(!y||x||u||f)&&Gt(m,e,n,a,Qt.x,Qt.y,x,b,u,f,l,t.freeTransform),g||(m.repeat="repeat");const i=R(g);(_||i)&&(m.gap=function(t,e,i,s,n){let a,o;R(t)?(a=t.x,o=t.y):a=o=t;return{x:Jt(a,i,n.width,e&&e.x),y:Jt(o,s,n.height,e&&e.y)}}(_,i&&g,Qt.width,Qt.height,e));break;default:x&&Vt(m,e,Qt.x,Qt.y,x,b,u)}return m.transform||(e.x||e.y)&&(m.transform=Xt(),qt(m.transform,e.x,e.y)),x&&"stretch"!==r&&(m.scaleX=x,m.scaleY=b),m.width=n,m.height=a,o&&(m.opacity=o),w&&(m.filters=w),g&&(m.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),m}function Jt(t,e,i,n){const a=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let Kt,te=new x;const{isSame:ee}=L;function ie(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Zt(n,s,i,a),!0}function se(t,e){oe(t,M.LOAD,e)}function ne(t,e){oe(t,M.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),oe(t,M.ERROR,e)}function oe(t,e,i){t.hasEvent(e)&&t.emitEvent(new M(e,i))}function re(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,scale:de,copy:he}=O,{floor:ce,max:ue,abs:fe}=Math;function pe(t,e,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,e.scaleFixed);const o=n+"-"+a+"-"+s;if(e.patternId===o||t.destroyed)return!1;{const{image:t,data:r}=e;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g,gap:_}=r;n*=s,a*=s;const w=_&&_.x*n,y=_&&_.y*a;u&&(u=fe(u),f=fe(f),d=le(),he(d,p),de(d,1/u,1/f),n*=u,a*=f),h*=n,c*=a;const m=h*c;if(!g&&m>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}if(m>v&&(l=Math.sqrt(m/v)),l&&(n/=l,a/=l,h/=l,c/=l),u&&(n/=u,a/=f),(p||1!==n||1!==a)&&(d||(d=le(),p&&he(d,p)),de(d,1/n,1/a)),d){const t=h+(w||0),e=c+(y||0);de(d,t/ue(ce(t),1),e/ue(ce(e),1))}const x=t.getCanvas(h,c,r.opacity,r.filters,w,y),b=t.getPattern(x,g||i.origin.noRepeat||"no-repeat",d,e);return e.style=b,e.patternId=o,!0}}function ge(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const _e={image:function(t,e,i,s,n){let a,o;const r=E.get(i);return Kt&&i===Kt.paint&&ee(s,Kt.boxBounds)?a=Kt.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Kt=r.use>1?{leafPaint:a,paint:i,boxBounds:te.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ie(t,e,i,r,a,s),n&&(se(t,o),ne(t,o))):r.error?n&&ae(t,o,r.error):(n&&(re(t,!0),se(t,o)),a.loadId=r.load(()=>{re(t,!1),t.destroyed||(ie(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ne(t,o)),a.loadId=void 0},e=>{re(t,!1),ae(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=e,{data:d}=s;if(!d||s.patternId===a+"-"+o+"-"+l&&!G.running)return!1;if(n)if(d.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&r.isResizing(t)||G.running)){let{width:t,height:e}=d;t*=a*l,e*=o*l,d.scaleX&&(t*=d.scaleX,e*=d.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,d),!0):(!s.style||s.sync||G.running?pe(t,s,l):s.patternTask||(s.patternTask=E.patternTasker.add(()=>ge(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&pe(t,s,l),t.forceUpdate("surface")}),300)),!1)},createPattern:pe,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,E.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],b(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:Zt,getPatternData:$t,fillOrFitMode:Vt,clipMode:Yt,repeatMode:Gt},{toPoint:we}=P,{hasTransparent:ye}=V,me={},ve={};function xe(t,e,i,n){if(i){let a,o,r,l;for(let t=0,d=i.length;t<d;t++)a=i[t],s(a)?(r=t/(d-1),o=V.string(a,n)):(r=a.offset,o=V.string(a.color,n)),e.addColorStop(r,o),!l&&ye(o)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:be,getDistance:ke}=D,{get:Be,rotateOfOuter:Se,scaleOfOuter:Ee}=O,{toPoint:Re}=P,Le={},Ae={};function Ce(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=be(e,i);a=Be(),n?(Ee(a,e,o/r*(s||1),1),Se(a,e,t+90)):(Ee(a,e,1,o/r*(s||1)),Se(a,e,t))}return a}const{getDistance:Oe}=D,{toPoint:Te}=P,We={},De={};const Me={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;we(s||"top",e,me),we(n||"bottom",e,ve);const r=i.canvas.createLinearGradient(me.x,me.y,ve.x,ve.y),l={type:a,style:r};return xe(l,r,t.stops,o),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Re(s||"center",e,Le),Re(n||"bottom",e,Ae);const l=i.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,ke(Le,Ae)),d={type:a,style:l};xe(d,l,t.stops,o);const h=Ce(e,Le,Ae,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Te(s||"center",e,We),Te(n||"bottom",e,De);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,We.x,We.y):i.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Oe(We,De)),d={type:a,style:l};xe(d,l,t.stops,o);const h=Ce(e,We,De,r||1,i.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ce},{copy:Pe,toOffsetOutBounds:Ie}=L,ze={},Fe={};function Ue(t,e,s,n){const{bounds:a,shapeBounds:o}=n;if(i.fullImageShadow){if(Pe(ze,t.bounds),ze.x+=e.x-o.x,ze.y+=e.y-o.y,s){const{fitMatrix:t}=n;ze.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),ze.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),ze.width*=s,ze.height*=s}t.copyWorld(n.canvas,t.bounds,ze)}else s&&(Pe(ze,e),ze.x-=e.width/2*(s-1),ze.y-=e.height/2*(s-1),ze.width*=s,ze.height*=s),t.copyWorld(n.canvas,o,s?ze:e)}const{toOffsetOutBounds:Ve}=L,Ye={};const Ge={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ie(d,Fe),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Fe.offsetX+r.x*c*_,Fe.offsetY+r.y*u*_,r.blur*c*_,V.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Ue(f,Fe,n,i),s=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),s=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),y.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ve(d,Ye),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Ye.offsetX+r.x*c*_,Ye.offsetY+r.y*u*_,r.blur*c*_),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Ue(f,Ye,n,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,d,"source-out"),s=d),f.fillWorld(s,V.string(r.color),"source-in"),y.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ne}=v;let Xe;function qe(t,e,i,s,n,a,o,r){switch(e){case"grayscale":Xe||(Xe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);He(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":He(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}N.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],r=i.__.mask,r){o&&(qe(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,Xe=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=je(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=je(t)),n||(n=je(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||Ne(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&qe(this,o,t,n,s,a,void 0,!1),Ne(i,e)||i.__render(n||t,e),h&&qe(this,o,t,n,s,a,h,!1)}qe(this,o,t,n,s,a,void 0,!0)};const Qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ze=Qe+"_#~&*+\\=|≮≯≈≠=…",$e=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function Je(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Ke=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ti=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ei=Je(Qe),ii=Je(Ze),si=Je("- —/~|┆·");var ni;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ni||(ni={}));const{Letter:ai,Single:oi,Before:ri,After:li,Symbol:di,Break:hi}=ni;function ci(t){return Ke[t]?ai:si[t]?hi:ti[t]?ri:ei[t]?li:ii[t]?di:$e.test(t)?oi:ai}const ui={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function fi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:pi}=ui,{Letter:gi,Single:_i,Before:wi,After:yi,Symbol:mi,Break:vi}=ni;let xi,bi,ki,Bi,Si,Ei,Ri,Li,Ai,Ci,Oi,Ti,Wi,Di,Mi,Pi,Ii,zi=[];function Fi(t,e){Ai&&!Li&&(Li=Ai),xi.data.push({char:t,width:e}),ki+=e}function Ui(){Bi+=ki,xi.width=ki,bi.words.push(xi),xi={data:[]},ki=0}function Vi(){Di&&(Mi.paraNumber++,bi.paraStart=!0,Di=!1),Ai&&(bi.startCharSize=Li,bi.endCharSize=Ai,Li=0),bi.width=Bi,Pi.width?pi(bi):Ii&&Yi(),zi.push(bi),bi={words:[]},Bi=0}function Yi(){Bi>(Mi.maxWidth||0)&&(Mi.maxWidth=Bi)}const{top:Gi,right:Ni,bottom:Xi,left:qi}=I;function ji(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Hi={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,a=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:h}=e;h&&(o?(n=h[qi],o-=h[Ni]+h[qi]):e.autoSizeAlign||(n=h[qi]),r?(a=h[Gi],r-=h[Gi]+h[Xi]):e.autoSizeAlign||(a=h[Gi]));const c={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){Mi=t,zi=t.rows,Pi=t.bounds,Ii=!Pi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:l,height:d}=Pi;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,i="break"===s.textWrap;Di=!0,Oi=null,Li=Ri=Ai=ki=Bi=0,xi={data:[]},bi={words:[]},n&&(e=[...e]);for(let s=0,d=e.length;s<d;s++)Ei=e[s],"\n"===Ei?(ki&&Ui(),bi.paraEnd=!0,Vi(),Di=!0):(Ci=ci(Ei),Ci===gi&&"none"!==o&&(Ei=fi(Ei,o,!ki)),Ri=r.measureText(Ei).width,n&&(n<0&&(Ai=Ri),Ri+=n),Ti=Ci===_i&&(Oi===_i||Oi===gi)||Oi===_i&&Ci!==yi,Wi=!(Ci!==wi&&Ci!==_i||Oi!==mi&&Oi!==yi),Si=Di&&a?l-a:l,t&&l&&Bi+ki+Ri>Si&&(i?(ki&&Ui(),Bi&&Vi()):(Wi||(Wi=Ci===gi&&Oi==yi),Ti||Wi||Ci===vi||Ci===wi||Ci===_i||ki+Ri>Si?(ki&&Ui(),Bi&&Vi()):Bi&&Vi()))," "===Ei&&!0!==Di&&Bi+ki===0||(Ci===vi?(" "===Ei&&ki&&Ui(),Fi(Ei,Ri),Ui()):Ti||Wi?(ki&&Ui(),Fi(Ei,Ri)):Fi(Ei,Ri)),Oi=Ci);ki&&Ui(),Bi&&Vi(),zi.length>0&&(zi[zi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Mi.paraNumber++,Bi=r.measureText(t).width,zi.push({x:a||0,text:t,width:Bi,paraStart:!0}),Ii&&Yi()})}(c,t,e),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ji(e,"x",t[qi]);break;case"right":ji(e,"x",-t[Ni])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ji(e,"y",t[Gi]);break;case"bottom":ji(e,"y",-t[Xi])}}(h,c,e,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,h=n;o<h;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&o>0&&(y+=c),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)})),t.words=null)})}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=e;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?i.canvas.measureText(r).width:0,h=s+n-d;("none"===e.textWrap?a:[a[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,e,n,o),"none"!==l&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,R(n)?(i=n.type,n.color&&(t.decorationColor=V.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(c,e),c}};const Qi={string:function(t,e){const i=z(e)&&e<1;if(s(t)){if(!i||!V.object)return t;t=V.object(t)}let n=o(t.a)?1:t.a;i&&(n*=e);const a=t.r+","+t.g+","+t.b;return 1===n?"rgb("+a+")":"rgba("+a+","+n+")"}};Object.assign(X,Hi),Object.assign(V,Qi),Object.assign(U,Ct),Object.assign(F,_e),Object.assign(Y,Me),Object.assign(q,Ge),$();export{ht as Layouter,H as LeaferCanvas,ut as Renderer,K as Watcher,$ as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,isUndefined as n,DataHelper as a,canvasSizeAttrs as o,ResizeEvent as r,canvasPatch as l,FileHelper as d,Creator as h,LeaferImage as c,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as v,Bounds as x,isArray as b,LeafLevelList as k,LayoutEvent as S,Run as B,ImageManager as R,isObject as E,BoundsHelper as L,Matrix as A,getMatrixData as C,MatrixHelper as O,MathHelper as T,AlignHelper as W,PointHelper as D,ImageEvent as P,AroundHelper as M,Direction4 as I,isNumber as z}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as F,Paint as U,ColorConvert as V,PaintGradient as Y,Export as G,Group as N,TextConvert as X,Effect as q}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const j=t.get("LeaferCanvas");class H extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else j.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;if(this.unreal){const{config:t,autoWidthStr:e,autoHeightStr:i}=this;t.width?(n(e)&&(this.autoWidthStr=s.width||""),s.width=t.width+"px"):n(e)||(s.width=e),t.height?(n(i)&&(this.autoHeightStr=s.height||""),s.height=t.height+"px"):n(i)||(s.height=i)}else s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),j.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:a,height:o}=this.autoBounds.getBoundsFrom(t),r={width:a,height:o,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};a.copyAttrs(e,this,o),this.resize(t),this.resizeListener&&!n(this.width)&&this.resizeListener(new r(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}l(CanvasRenderingContext2D.prototype),l(Path2D.prototype);const{mineType:Q,fileType:Z}=d;function $(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=Q(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,Q(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(Q(Z(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:a}=i.image;a&&(n.setAttribute("crossOrigin",a),n.crossOrigin=a),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=h.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(h,{canvas:(t,e)=>new H(t,e),image:t=>new c(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:J}=navigator;J.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),J.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):J.indexOf("Mac")>-1?i.os="Mac":J.indexOf("Linux")>-1&&(i.os="Linux");class K{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=a.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:tt,updateBounds:et,updateChange:it}=m,{pushAllChildBranch:st,pushAllParent:nt}=y;const{worldBounds:at}=v;class ot{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:rt,updateAllChange:lt}=m,dt=t.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=a.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(S.START),this.layoutOnce(),t.emitEvent(new S(S.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.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=B.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=S,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new S(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||et(s[t])}et(i)}})}(this.__levelList),function(t){t.list.forEach(it)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new S(a,r,this.times)),i.emitEvent(new S(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,B.end(e)}fullLayout(){const t=B.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=S,a=this.getBlocks(new f(e));e.emitEvent(new S(i,a,this.times)),ht.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new S(s,a,this.times)),e.emitEvent(new S(n,a,this.times)),this.addBlocks(a),B.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),lt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[S.REQUEST,this.layout,this],[S.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=t.get("Renderer");class ut{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=t,this.canvas=e,i&&(this.config=a.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(S.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,ct.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),R.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=B.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(ut.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),B.end(e)}fullRender(){const t=B.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),B.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),a=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const e=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-e),{maxFPS:n}=this.config;if(n&&t>n-.5)return i.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};i.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[S.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[r.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ft(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function pt(t,e){t.__.__font?ft(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function gt(t,e,i){switch(e.__.strokeAlign){case"center":_t(t,1,e,i);break;case"inside":wt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?_t(t,2,e,i):wt(t,"outside",e,i)}}function _t(t,e,i,s){const n=i.__;E(t)?yt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),mt(i,s))}function wt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,_t(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",ft(i,n),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function mt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function yt(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!F.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?mt(s,n):n.stroke(),n.restoreBlendMode()):i?mt(s,n):n.stroke()}}function vt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)gt(t,e,i);else switch(s.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),xt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)xt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),xt(t,2,e,a),a.clipUI(s),a.clearWorld(n),m.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function xt(t,e,i,s){const n=i.__;E(t)?yt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&U.strokeArrow(t,i,s)}ut.clipSpread=10,Object.assign(h,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=ht.fullLayout;const{getSpread:bt,getOuterOf:kt,getByMove:St,getIntersectData:Bt}=L;let Rt;const{stintSet:Et}=a,{hasTransparent:Lt}=V;function At(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let a;const{boxBounds:o}=i.__layout;switch(e.type){case"image":a=F.image(i,t,e,o,!Rt||!Rt[e.url]);break;case"linear":a=Y.linearGradient(e,o);break;case"radial":a=Y.radialGradient(e,o);break;case"angular":a=Y.conicGradient(e,o);break;case"solid":const{type:s,color:r,opacity:l}=e;a={type:s,style:V.string(r,l)};break;default:n(e.r)||(a={type:"solid",style:V.string(e)})}if(a){if(s(a.style)&&Lt(a.style)&&(a.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;a.strokeStyle=e.style}e.editing&&(a.editing=e.editing),e.blendMode&&(a.blendMode=e.blendMode)}return a}const Ct={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];b(r)||(r=[r]),Rt=F.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=At(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Et(i,"__isAlphaPixelFill",n),Et(i,"__isTransparentFill",a)):(Et(i,"__isAlphaPixelStroke",n),Et(i,"__isTransparentStroke",a),Et(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,pt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(F.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),pt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),pt(e,i),i.restoreBlendMode()):pt(e,i)}},fillPathOrText:pt,fillText:ft,stroke:vt,strokes:function(t,e,i){vt(t,e,i)},strokeText:gt,drawTextStroke:mt,shape:function(t,e,s){const n=e.getSameCanvas(),a=t.__nowWorld,o=e.bounds;let r,l,d,h,c,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))c=n,r=h=a;else{const{renderShapeSpread:n}=t.__layout;let p;if(i.fullImageShadow)p=a;else{const t=n?bt(o,u===f?n*u:[n*f,n*u]):o;p=Bt(t,a)}d=o.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(c=e.getSameCanvas(),t.__renderShape(c,s),u*=g,f*=_),h=kt(a,d),r=St(h,-d.e,-d.f);const w=s.matrix;w?(l=new A(d),l.multiply(w),g*=w.scaleX,_*=w.scaleY):l=d,l.withScale(g,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:d,bounds:r,worldCanvas:c,shapeBounds:h,scaleX:u,scaleY:f}}};let Ot={},Tt=C();const{get:Wt,rotateOfOuter:Dt,translate:Pt,scaleOfOuter:Mt,multiplyParent:It,scale:zt,rotate:Ft,skew:Ut}=O;function Vt(t,e,i,s,n,a,o){const r=Wt();Pt(r,e.x+i,e.y+s),zt(r,n,a),o&&Dt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Yt(t,e,i,s,n,a,o,r,l){const d=Wt();Nt(d,e,i,s,n,a,o,r),l&&(Tt.a=e.width/l.width,Tt.d=e.height/l.height,It(d,Tt)),t.transform=d}function Gt(t,e,i,s,n,a,o,r,l,d,h,c){const u=Wt();if(c)Nt(u,e,n,a,o,r,l,d);else{if(l)if("center"===h)Dt(u,{x:i/2,y:s/2},l);else switch(Ft(u,l),l){case 90:Pt(u,s,0);break;case 180:Pt(u,i,s);break;case 270:Pt(u,0,i)}Ot.x=e.x+n,Ot.y=e.y+a,Pt(u,Ot.x,Ot.y),o&&Mt(u,Ot,o,r)}t.transform=u}function Nt(t,e,i,s,n,a,o,r){o&&Ft(t,o),r&&Ut(t,r.x,r.y),n&&zt(t,n,a),Pt(t,e.x+i,e.y+s)}const{get:Xt,translate:qt}=O,jt=new x,Ht={},Qt={};function Zt(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=$t(i,s,e)}function $t(t,e,i){t.padding&&(e=jt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:a}=i;const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,m=e.width===n&&e.height===a,y={mode:r},v="center"!==l&&(u||0)%180==90;let x,b;switch(L.set(Qt,0,0,v?a:n,v?n:a),r&&"cover"!==r&&"fit"!==r?((h||c)&&(T.getScaleData(h,c,i,Ht),x=Ht.scaleX,b=Ht.scaleY),(l||_||g)&&(x&&L.scale(Qt,x,b,!0),l&&W.toPoint(l,Qt,e,Qt,!0,!0))):m&&!u||(x=b=L.getFitScale(e,Qt,"fit"!==r),L.put(e,i,l,x,!1,Qt),L.scale(Qt,x,b,!0)),d&&D.move(Qt,d),r){case"stretch":m||(n=e.width,a=e.height);break;case"normal":case"clip":(Qt.x||Qt.y||x||p||u||f)&&Yt(y,e,Qt.x,Qt.y,x,b,u,f,t.clipSize);break;case"repeat":(!m||x||u||f)&&Gt(y,e,n,a,Qt.x,Qt.y,x,b,u,f,l,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(_||i)&&(y.gap=function(t,e,i,s,n){let a,o;E(t)?(a=t.x,o=t.y):a=o=t;return{x:Jt(a,i,n.width,e&&e.x),y:Jt(o,s,n.height,e&&e.y)}}(_,i&&g,Qt.width,Qt.height,e));break;default:x&&Vt(y,e,Qt.x,Qt.y,x,b,u)}return y.transform||(e.x||e.y)&&(y.transform=Xt(),qt(y.transform,e.x,e.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=b),y.width=n,y.height=a,o&&(y.opacity=o),w&&(y.filters=w),g&&(y.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function Jt(t,e,i,n){const a=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let Kt,te=new x;const{isSame:ee}=L;function ie(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Zt(n,s,i,a),!0}function se(t,e){oe(t,P.LOAD,e)}function ne(t,e){oe(t,P.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),oe(t,P.ERROR,e)}function oe(t,e,i){t.hasEvent(e)&&t.emitEvent(new P(e,i))}function re(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,scale:de,copy:he}=O,{floor:ce,ceil:ue,max:fe,abs:pe}=Math;function ge(t,e,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,e.scaleFixed);const o=n+"-"+a+"-"+s;if(e.patternId===o||t.destroyed)return!1;{const{image:r,data:l}=e;let d,h,{width:c,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=pe(f),p=pe(p),h=le(),he(h,g),de(h,1/f,1/p),n*=f,a*=p),c*=n,u*=a;const m=c*u;if(!_&&m>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(r.isSVG){const t=c/r.width;t>1&&(d=t/ue(t))}else{const t=r.width*r.height;y>t&&(y=t)}m>y&&(d=Math.sqrt(m/y)),d&&(n/=d,a/=d,c/=d,u/=d),f&&(n/=f,a/=p);const v=w&&w.x*n,x=w&&w.y*a;if(g||1!==n||1!==a){const t=c+(v||0),e=u+(x||0);n/=t/fe(ce(t),1),a/=e/fe(ce(e),1),h||(h=le(),g&&he(h,g)),de(h,1/n,1/a)}const b=r.getCanvas(c,u,l.opacity,l.filters,v,x,t.leafer&&t.leafer.config.smooth),k=r.getPattern(b,_||i.origin.noRepeat||"no-repeat",h,e);return e.style=k,e.patternId=o,!0}}function _e(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const we={image:function(t,e,i,s,n){let a,o;const r=R.get(i);return Kt&&i===Kt.paint&&ee(s,Kt.boxBounds)?a=Kt.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Kt=r.use>1?{leafPaint:a,paint:i,boxBounds:te.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ie(t,e,i,r,a,s),n&&(se(t,o),ne(t,o))):r.error?n&&ae(t,o,r.error):(n&&(re(t,!0),se(t,o)),a.loadId=r.load(()=>{re(t,!1),t.destroyed||(ie(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ne(t,o)),a.loadId=void 0},e=>{re(t,!1),ae(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=e,{data:d}=s;if(!d||s.patternId===a+"-"+o+"-"+l&&!G.running)return!1;if(n)if(d.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&r.isResizing(t)||G.running)){let{width:t,height:e}=d;t*=a*l,e*=o*l,d.scaleX&&(t*=d.scaleX,e*=d.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,d),!0):(!s.style||s.sync||G.running?ge(t,s,l):s.patternTask||(s.patternTask=R.patternTasker.add(()=>_e(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&ge(t,s,l),t.forceUpdate("surface")}),300)),!1)},createPattern:ge,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,R.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],b(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:Zt,getPatternData:$t,fillOrFitMode:Vt,clipMode:Yt,repeatMode:Gt},{toPoint:me}=M,{hasTransparent:ye}=V,ve={},xe={};function be(t,e,i,n){if(i){let a,o,r,l;for(let t=0,d=i.length;t<d;t++)a=i[t],s(a)?(r=t/(d-1),o=V.string(a,n)):(r=a.offset,o=V.string(a.color,n)),e.addColorStop(r,o),!l&&ye(o)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:ke,getDistance:Se}=D,{get:Be,rotateOfOuter:Re,scaleOfOuter:Ee}=O,{toPoint:Le}=M,Ae={},Ce={};function Oe(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=ke(e,i);a=Be(),n?(Ee(a,e,o/r*(s||1),1),Re(a,e,t+90)):(Ee(a,e,1,o/r*(s||1)),Re(a,e,t))}return a}const{getDistance:Te}=D,{toPoint:We}=M,De={},Pe={};const Me={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;me(s||"top",e,ve),me(n||"bottom",e,xe);const r=i.canvas.createLinearGradient(ve.x,ve.y,xe.x,xe.y),l={type:a,style:r};return be(l,r,t.stops,o),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Le(s||"center",e,Ae),Le(n||"bottom",e,Ce);const l=i.canvas.createRadialGradient(Ae.x,Ae.y,0,Ae.x,Ae.y,Se(Ae,Ce)),d={type:a,style:l};be(d,l,t.stops,o);const h=Oe(e,Ae,Ce,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;We(s||"center",e,De),We(n||"bottom",e,Pe);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,De.x,De.y):i.canvas.createRadialGradient(De.x,De.y,0,De.x,De.y,Te(De,Pe)),d={type:a,style:l};be(d,l,t.stops,o);const h=Oe(e,De,Pe,r||1,i.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Oe},{copy:Ie,toOffsetOutBounds:ze}=L,Fe={},Ue={};function Ve(t,e,s,n){const{bounds:a,shapeBounds:o}=n;if(i.fullImageShadow){if(Ie(Fe,t.bounds),Fe.x+=e.x-o.x,Fe.y+=e.y-o.y,s){const{fitMatrix:t}=n;Fe.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Fe.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Fe.width*=s,Fe.height*=s}t.copyWorld(n.canvas,t.bounds,Fe)}else s&&(Ie(Fe,e),Fe.x-=e.width/2*(s-1),Fe.y-=e.height/2*(s-1),Fe.width*=s,Fe.height*=s),t.copyWorld(n.canvas,o,s?Fe:e)}const{toOffsetOutBounds:Ye}=L,Ge={};const Ne={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ze(d,Ue),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Ue.offsetX+r.x*c*_,Ue.offsetY+r.y*u*_,r.blur*c*_,V.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Ve(f,Ue,n,i),s=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),s=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ye(d,Ge),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Ge.offsetX+r.x*c*_,Ge.offsetY+r.y*u*_,r.blur*c*_),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Ve(f,Ge,n,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,d,"source-out"),s=d),f.fillWorld(s,V.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Xe}=v;let qe;function je(t,e,i,s,n,a,o,r){switch(e){case"grayscale":qe||(qe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);Qe(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":Qe(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function He(t){return t.getSameCanvas(!1,!0)}function Qe(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}N.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],r=i.__.mask,r){o&&(je(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,qe=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=He(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=He(t)),n||(n=He(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||Xe(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&je(this,o,t,n,s,a,void 0,!1),Xe(i,e)||i.__render(n||t,e),h&&je(this,o,t,n,s,a,h,!1)}je(this,o,t,n,s,a,void 0,!0)};const Ze=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",$e=Ze+"_#~&*+\\=|≮≯≈≠=…",Je=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 Ke(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ti=Ke("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ei=Ke("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ii=Ke(Ze),si=Ke($e),ni=Ke("- —/~|┆·");var ai;!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"}(ai||(ai={}));const{Letter:oi,Single:ri,Before:li,After:di,Symbol:hi,Break:ci}=ai;function ui(t){return ti[t]?oi:ni[t]?ci:ei[t]?li:ii[t]?di:si[t]?hi:Je.test(t)?ri:oi}const fi={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function pi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:gi}=fi,{Letter:_i,Single:wi,Before:mi,After:yi,Symbol:vi,Break:xi}=ai;let bi,ki,Si,Bi,Ri,Ei,Li,Ai,Ci,Oi,Ti,Wi,Di,Pi,Mi,Ii,zi,Fi=[];function Ui(t,e){Ci&&!Ai&&(Ai=Ci),bi.data.push({char:t,width:e}),Si+=e}function Vi(){Bi+=Si,bi.width=Si,ki.words.push(bi),bi={data:[]},Si=0}function Yi(){Pi&&(Mi.paraNumber++,ki.paraStart=!0,Pi=!1),Ci&&(ki.startCharSize=Ai,ki.endCharSize=Ci,Ai=0),ki.width=Bi,Ii.width?gi(ki):zi&&Gi(),Fi.push(ki),ki={words:[]},Bi=0}function Gi(){Bi>(Mi.maxWidth||0)&&(Mi.maxWidth=Bi)}const{top:Ni,right:Xi,bottom:qi,left:ji}=I;function Hi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Qi={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,a=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:h}=e;h&&(o?(n=h[ji],o-=h[Xi]+h[ji]):e.autoSizeAlign||(n=h[ji]),r?(a=h[Ni],r-=h[Ni]+h[qi]):e.autoSizeAlign||(a=h[Ni]));const c={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){Mi=t,Fi=t.rows,Ii=t.bounds,zi=!Ii.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:l,height:d}=Ii;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,i="break"===s.textWrap;Pi=!0,Ti=null,Ai=Li=Ci=Si=Bi=0,bi={data:[]},ki={words:[]},n&&(e=[...e]);for(let s=0,d=e.length;s<d;s++)Ei=e[s],"\n"===Ei?(Si&&Vi(),ki.paraEnd=!0,Yi(),Pi=!0):(Oi=ui(Ei),Oi===_i&&"none"!==o&&(Ei=pi(Ei,o,!Si)),Li=r.measureText(Ei).width,n&&(n<0&&(Ci=Li),Li+=n),Wi=Oi===wi&&(Ti===wi||Ti===_i)||Ti===wi&&Oi!==yi,Di=!(Oi!==mi&&Oi!==wi||Ti!==vi&&Ti!==yi),Ri=Pi&&a?l-a:l,t&&l&&Bi+Si+Li>Ri&&(i?(Si&&Vi(),Bi&&Yi()):(Di||(Di=Oi===_i&&Ti==yi),Wi||Di||Oi===xi||Oi===mi||Oi===wi||Si+Li>Ri?(Si&&Vi(),Bi&&Yi()):Bi&&Yi()))," "===Ei&&!0!==Pi&&Bi+Si===0||(Oi===xi?(" "===Ei&&Si&&Vi(),Ui(Ei,Li),Vi()):Wi||Di?(Si&&Vi(),Ui(Ei,Li)):Ui(Ei,Li)),Ti=Oi);Si&&Vi(),Bi&&Yi(),Fi.length>0&&(Fi[Fi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Mi.paraNumber++,Bi=r.measureText(t).width,Fi.push({x:a||0,text:t,width:Bi,paraStart:!0}),zi&&Gi()})}(c,t,e),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Hi(e,"x",t[ji]);break;case"right":Hi(e,"x",-t[Xi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Hi(e,"y",t[Ni]);break;case"bottom":Hi(e,"y",-t[qi])}}(h,c,e,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let o=0,h=n;o<h;o++){if(y=i[o],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&c&&o>0&&(m+=c),y.y=m,m+=a,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)})),t.words=null)})}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=e;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?i.canvas.measureText(r).width:0,h=s+n-d;("none"===e.textWrap?a:[a[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,e,n,o),"none"!==l&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,E(n)?(i=n.type,n.color&&(t.decorationColor=V.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(c,e),c}};const Zi={string:function(t,e){const i=z(e)&&e<1;if(s(t)){if(!i||!V.object)return t;t=V.object(t)}let a=n(t.a)?1:t.a;i&&(a*=e);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}};Object.assign(X,Qi),Object.assign(V,Zi),Object.assign(U,Ct),Object.assign(F,we),Object.assign(Y,Me),Object.assign(q,Ne),$();export{ht as Layouter,H as LeaferCanvas,ut as Renderer,K as Watcher,$ as useCanvas};
2
2
  //# sourceMappingURL=web.esm.min.js.map