@inweb/viewer-visualize 26.9.2 → 26.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,14 +17,14 @@
17
17
  });
18
18
  }
19
19
  registerCommandAlias(id, alias) {
20
- this.registerCommand(alias, ((viewer, ...args) => this.executeCommand(id, viewer, ...args)));
20
+ this.registerCommand(alias, (viewer, ...args) => this.executeCommand(id, viewer, ...args));
21
21
  }
22
22
  getCommand(id) {
23
23
  return this._commands.get(id);
24
24
  }
25
25
  getCommands() {
26
26
  const map = new Map;
27
- this._commands.forEach(((value, key) => map.set(key, value)));
27
+ this._commands.forEach((value, key) => map.set(key, value));
28
28
  return map;
29
29
  }
30
30
  executeCommand(id, viewer, ...args) {
@@ -39,7 +39,7 @@
39
39
  }
40
40
  const {handler: handler, thisArg: thisArg} = command;
41
41
  const result = handler.apply(thisArg, [ viewer, ...args ]);
42
- viewer === null || viewer === undefined ? undefined : viewer.emit({
42
+ viewer === null || viewer === void 0 ? void 0 : viewer.emit({
43
43
  type: "command",
44
44
  data: id,
45
45
  args: args
@@ -75,11 +75,11 @@
75
75
  }
76
76
  registerDraggerAlias(name, alias) {
77
77
  const provider = this._providers.get(name);
78
- if (provider) this.registerDragger(alias, (viewer => provider(viewer)));
78
+ if (provider) this.registerDragger(alias, viewer => provider(viewer));
79
79
  }
80
80
  getDraggers() {
81
81
  const map = new Map;
82
- this._providers.forEach(((value, key) => map.set(key, value)));
82
+ this._providers.forEach((value, key) => map.set(key, value));
83
83
  return map;
84
84
  }
85
85
  createDragger(name, viewer) {
@@ -118,11 +118,11 @@
118
118
  }
119
119
  registerComponentAlias(name, alias) {
120
120
  const provider = this._providers.get(name);
121
- if (provider) this.registerComponent(alias, (viewer => provider(viewer)));
121
+ if (provider) this.registerComponent(alias, viewer => provider(viewer));
122
122
  }
123
123
  getComponents() {
124
124
  const map = new Map;
125
- this._providers.forEach(((value, key) => map.set(key, value)));
125
+ this._providers.forEach((value, key) => map.set(key, value));
126
126
  return map;
127
127
  }
128
128
  createComponent(name, viewer) {
@@ -177,18 +177,18 @@
177
177
  }
178
178
  getLoaders() {
179
179
  const map = new Map;
180
- this._providers.forEach(((value, key) => map.set(key, value)));
180
+ this._providers.forEach((value, key) => map.set(key, value));
181
181
  return map;
182
182
  }
183
183
  createLoader(viewer, file, format) {
184
184
  let result = null;
185
- this._providers.forEach(((provider, key) => {
185
+ this._providers.forEach((provider, key) => {
186
186
  const loader = provider(viewer);
187
187
  if (loader.isSupport(file, format)) {
188
188
  result = loader;
189
189
  result.name = key;
190
190
  }
191
- }));
191
+ });
192
192
  return result;
193
193
  }
194
194
  }
@@ -292,10 +292,10 @@
292
292
  resetToDefaults(fields) {
293
293
  if (fields !== undefined) {
294
294
  const defaults = Options.defaults();
295
- const resetData = fields.reduce(((acc, field) => {
295
+ const resetData = fields.reduce((acc, field) => {
296
296
  acc[field] = defaults[field];
297
297
  return acc;
298
- }), {});
298
+ }, {});
299
299
  this.data = {
300
300
  ...this.data,
301
301
  ...resetData
@@ -522,7 +522,7 @@
522
522
  var _a;
523
523
  const extView = this.m_module.getViewer().getActiveTvExtendedView();
524
524
  extView.setView(params.position, params.target, params.upVector, params.viewFieldWidth, params.viewFieldHeight, params.perspective);
525
- (_a = extView.delete) === null || _a === undefined ? undefined : _a.call(extView);
525
+ (_a = extView.delete) === null || _a === void 0 ? void 0 : _a.call(extView);
526
526
  };
527
527
  this.getViewParams = () => {
528
528
  var _a;
@@ -535,7 +535,7 @@
535
535
  viewFieldHeight: view.viewFieldHeight,
536
536
  perspective: view.perspective,
537
537
  };
538
- (_a = view.delete) === null || _a === undefined ? undefined : _a.call(view);
538
+ (_a = view.delete) === null || _a === void 0 ? void 0 : _a.call(view);
539
539
  return obj;
540
540
  };
541
541
  this.m_module = module;
@@ -768,7 +768,7 @@
768
768
  deleteAll(objects) {
769
769
  var _a;
770
770
  for (const obj of objects) {
771
- (_a = obj === null || obj === undefined ? undefined : obj.delete) === null || _a === undefined ? undefined : _a.call(obj);
771
+ (_a = obj === null || obj === void 0 ? void 0 : obj.delete) === null || _a === void 0 ? void 0 : _a.call(obj);
772
772
  }
773
773
  }
774
774
  updatePreview() { }
@@ -1136,7 +1136,7 @@
1136
1136
  };
1137
1137
  this.items = [];
1138
1138
  this.canvasEvents.push("resize");
1139
- this.oldRulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== undefined ? _a : "Default";
1139
+ this.oldRulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
1140
1140
  this.optionsChange = this.optionsChange.bind(this);
1141
1141
  }
1142
1142
  initialize() {
@@ -1250,7 +1250,7 @@
1250
1250
  optionsChange(event) {
1251
1251
  var _a;
1252
1252
  const options = event.data;
1253
- const toUnitName = (_a = options.rulerUnit) !== null && _a !== undefined ? _a : "Default";
1253
+ const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
1254
1254
  if (this.oldRulerUnit === toUnitName)
1255
1255
  return;
1256
1256
  this.oldRulerUnit = toUnitName;
@@ -1370,7 +1370,7 @@
1370
1370
  const model = this.viewer.getActiveModel();
1371
1371
  model.removeEntity(this.cameraId);
1372
1372
  model.delete();
1373
- (_a = this.cameraWalker) === null || _a === undefined ? undefined : _a.delete();
1373
+ (_a = this.cameraWalker) === null || _a === void 0 ? void 0 : _a.delete();
1374
1374
  }
1375
1375
  if (this.viewParams) {
1376
1376
  this.setViewParams(this.viewParams);
@@ -1770,7 +1770,7 @@
1770
1770
  const extView = this.getViewer().getActiveTvExtendedView();
1771
1771
  extView.setView(viewParams.position, viewParams.target, viewParams.upVector, viewParams.viewFieldWidth, viewParams.viewFieldHeight, viewParams.perspective);
1772
1772
  extView.delete();
1773
- (_b = (_a = this._subject.activeDragger()) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
1773
+ (_b = (_a = this._subject.activeDragger()) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
1774
1774
  this._subject.emitEvent({
1775
1775
  type: "orbit",
1776
1776
  });
@@ -1885,7 +1885,7 @@
1885
1885
  deleteAll(objects) {
1886
1886
  var _a;
1887
1887
  for (const obj of objects) {
1888
- (_a = obj === null || obj === undefined ? undefined : obj.delete) === null || _a === undefined ? undefined : _a.call(obj);
1888
+ (_a = obj === null || obj === void 0 ? void 0 : obj.delete) === null || _a === void 0 ? void 0 : _a.call(obj);
1889
1889
  }
1890
1890
  }
1891
1891
  }
@@ -1971,7 +1971,7 @@
1971
1971
  targetWithDelta.delete();
1972
1972
  position.delete();
1973
1973
  positionWithDelta.delete();
1974
- (_b = (_a = this._subject.activeDragger()) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
1974
+ (_b = (_a = this._subject.activeDragger()) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
1975
1975
  this._subject.emitEvent({
1976
1976
  type: "pan",
1977
1977
  x: absoluteX,
@@ -2046,7 +2046,7 @@
2046
2046
  const viewer = this._m_module.getViewer();
2047
2047
  viewer.zoomAt(zoomFactor, x, y);
2048
2048
  this._subject.deviceAutoRegeneration();
2049
- (_b = (_a = this._subject.activeDragger()) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
2049
+ (_b = (_a = this._subject.activeDragger()) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
2050
2050
  this._subject.emitEvent({
2051
2051
  type: "zoomat",
2052
2052
  data: zoomFactor,
@@ -2564,7 +2564,7 @@
2564
2564
  }
2565
2565
  }
2566
2566
  modelItr.delete();
2567
- (_a = visViewer.clearViewExtentsCache) === null || _a === undefined ? undefined : _a.call(visViewer);
2567
+ (_a = visViewer.clearViewExtentsCache) === null || _a === void 0 ? void 0 : _a.call(visViewer);
2568
2568
  viewer.update();
2569
2569
  }
2570
2570
 
@@ -2677,7 +2677,7 @@
2677
2677
  var _a;
2678
2678
  if (!viewer.visualizeJs)
2679
2679
  return "";
2680
- return ((_a = viewer.canvas) === null || _a === undefined ? undefined : _a.toDataURL(type, encoderOptions)) || "";
2680
+ return ((_a = viewer.canvas) === null || _a === void 0 ? void 0 : _a.toDataURL(type, encoderOptions)) || "";
2681
2681
  }
2682
2682
 
2683
2683
  ///////////////////////////////////////////////////////////////////////////////
@@ -3117,7 +3117,7 @@
3117
3117
  const visLib = viewer.visLib();
3118
3118
  const visViewer = viewer.visViewer();
3119
3119
  const selectionSet = new visLib.OdTvSelectionSet();
3120
- handles === null || handles === undefined ? undefined : handles.forEach((handle) => {
3120
+ handles === null || handles === void 0 ? void 0 : handles.forEach((handle) => {
3121
3121
  const entityId = visViewer.getEntityByOriginalHandle(handle + "");
3122
3122
  if (!entityId.isNull())
3123
3123
  selectionSet.appendEntity(entityId);
@@ -3229,7 +3229,7 @@
3229
3229
  if (!entityId.isNull())
3230
3230
  selectionSet.appendEntity(entityId);
3231
3231
  });
3232
- (_a = visViewer.zoomToObjects) === null || _a === undefined ? undefined : _a.call(visViewer, selectionSet);
3232
+ (_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
3233
3233
  viewer.deviceAutoRegeneration();
3234
3234
  viewer.update();
3235
3235
  viewer.emitEvent({ type: "zoom" });
@@ -3264,7 +3264,7 @@
3264
3264
  return;
3265
3265
  const visViewer = viewer.visViewer();
3266
3266
  const selectionSet = visViewer.getSelected();
3267
- (_a = visViewer.zoomToObjects) === null || _a === undefined ? undefined : _a.call(visViewer, selectionSet);
3267
+ (_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
3268
3268
  viewer.deviceAutoRegeneration();
3269
3269
  viewer.update();
3270
3270
  viewer.emitEvent({ type: "zoom" });
@@ -3345,7 +3345,7 @@
3345
3345
  modelPtr.delete();
3346
3346
  }
3347
3347
  modelItr.delete();
3348
- (_a = visViewer.clearViewExtentsCache) === null || _a === undefined ? undefined : _a.call(visViewer);
3348
+ (_a = visViewer.clearViewExtentsCache) === null || _a === void 0 ? void 0 : _a.call(visViewer);
3349
3349
  viewer.update();
3350
3350
  }
3351
3351
 
@@ -4627,7 +4627,7 @@
4627
4627
  }
4628
4628
  removeEventListener(type, listener) {
4629
4629
  if (this._listeners[type] === undefined) return this;
4630
- const listeners = this._listeners[type].filter((x => x !== listener));
4630
+ const listeners = this._listeners[type].filter(x => x !== listener);
4631
4631
  if (listeners.length !== 0) this._listeners[type] = listeners; else delete this._listeners[type];
4632
4632
  return this;
4633
4633
  }
@@ -4638,7 +4638,7 @@
4638
4638
  emitEvent(event) {
4639
4639
  if (this._listeners[event.type] === undefined) return false;
4640
4640
  const invoke = this._listeners[event.type].slice();
4641
- invoke.forEach((listener => listener.call(this, event)));
4641
+ invoke.forEach(listener => listener.call(this, event));
4642
4642
  return true;
4643
4643
  }
4644
4644
  on(type, listener) {
@@ -4741,7 +4741,7 @@
4741
4741
  hasRequiredGlobal = 1;
4742
4742
  (function (exports) {
4743
4743
  Object.defineProperty(exports, "__esModule", { value: true });
4744
- exports._registerNode = exports.Konva = exports.glob = undefined;
4744
+ exports._registerNode = exports.Konva = exports.glob = void 0;
4745
4745
  const PI_OVER_180 = Math.PI / 180;
4746
4746
  function detectBrowser() {
4747
4747
  return (typeof window !== 'undefined' &&
@@ -4757,7 +4757,7 @@
4757
4757
  : {};
4758
4758
  exports.Konva = {
4759
4759
  _global: exports.glob,
4760
- version: '9.3.18',
4760
+ version: '9.3.22',
4761
4761
  isBrowser: detectBrowser(),
4762
4762
  isUnminified: /param/.test(function (param) { }.toString()),
4763
4763
  dblClickWindow: 400,
@@ -4789,7 +4789,7 @@
4789
4789
  },
4790
4790
  isTransforming() {
4791
4791
  var _a;
4792
- return (_a = exports.Konva['Transformer']) === null || _a === undefined ? undefined : _a.isTransforming();
4792
+ return (_a = exports.Konva['Transformer']) === null || _a === void 0 ? void 0 : _a.isTransforming();
4793
4793
  },
4794
4794
  isDragReady() {
4795
4795
  return !!exports.Konva['DD'].node;
@@ -4818,7 +4818,7 @@
4818
4818
  hasRequiredUtil = 1;
4819
4819
  (function (exports) {
4820
4820
  Object.defineProperty(exports, "__esModule", { value: true });
4821
- exports.Util = exports.Transform = undefined;
4821
+ exports.Util = exports.Transform = void 0;
4822
4822
  const Global_1 = requireGlobal();
4823
4823
  class Transform {
4824
4824
  constructor(m = [1, 0, 0, 1, 0, 0]) {
@@ -5627,505 +5627,168 @@
5627
5627
 
5628
5628
  var Node = {};
5629
5629
 
5630
- var Factory = {};
5630
+ var Canvas = {};
5631
5631
 
5632
- var Validators = {};
5632
+ var Context = {};
5633
5633
 
5634
- var hasRequiredValidators;
5634
+ var hasRequiredContext;
5635
5635
 
5636
- function requireValidators () {
5637
- if (hasRequiredValidators) return Validators;
5638
- hasRequiredValidators = 1;
5639
- Object.defineProperty(Validators, "__esModule", { value: true });
5640
- Validators.RGBComponent = RGBComponent;
5641
- Validators.alphaComponent = alphaComponent;
5642
- Validators.getNumberValidator = getNumberValidator;
5643
- Validators.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
5644
- Validators.getNumberOrAutoValidator = getNumberOrAutoValidator;
5645
- Validators.getStringValidator = getStringValidator;
5646
- Validators.getStringOrGradientValidator = getStringOrGradientValidator;
5647
- Validators.getFunctionValidator = getFunctionValidator;
5648
- Validators.getNumberArrayValidator = getNumberArrayValidator;
5649
- Validators.getBooleanValidator = getBooleanValidator;
5650
- Validators.getComponentValidator = getComponentValidator;
5651
- const Global_1 = requireGlobal();
5636
+ function requireContext () {
5637
+ if (hasRequiredContext) return Context;
5638
+ hasRequiredContext = 1;
5639
+ Object.defineProperty(Context, "__esModule", { value: true });
5640
+ Context.HitContext = Context.SceneContext = Context.Context = void 0;
5652
5641
  const Util_1 = requireUtil();
5653
- function _formatValue(val) {
5654
- if (Util_1.Util._isString(val)) {
5655
- return '"' + val + '"';
5642
+ const Global_1 = requireGlobal();
5643
+ function simplifyArray(arr) {
5644
+ const retArr = [], len = arr.length, util = Util_1.Util;
5645
+ for (let n = 0; n < len; n++) {
5646
+ let val = arr[n];
5647
+ if (util._isNumber(val)) {
5648
+ val = Math.round(val * 1000) / 1000;
5649
+ }
5650
+ else if (!util._isString(val)) {
5651
+ val = val + '';
5652
+ }
5653
+ retArr.push(val);
5656
5654
  }
5657
- if (Object.prototype.toString.call(val) === '[object Number]') {
5658
- return val;
5655
+ return retArr;
5656
+ }
5657
+ const COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()', EQUALS = '=', CONTEXT_METHODS = [
5658
+ 'arc',
5659
+ 'arcTo',
5660
+ 'beginPath',
5661
+ 'bezierCurveTo',
5662
+ 'clearRect',
5663
+ 'clip',
5664
+ 'closePath',
5665
+ 'createLinearGradient',
5666
+ 'createPattern',
5667
+ 'createRadialGradient',
5668
+ 'drawImage',
5669
+ 'ellipse',
5670
+ 'fill',
5671
+ 'fillText',
5672
+ 'getImageData',
5673
+ 'createImageData',
5674
+ 'lineTo',
5675
+ 'moveTo',
5676
+ 'putImageData',
5677
+ 'quadraticCurveTo',
5678
+ 'rect',
5679
+ 'roundRect',
5680
+ 'restore',
5681
+ 'rotate',
5682
+ 'save',
5683
+ 'scale',
5684
+ 'setLineDash',
5685
+ 'setTransform',
5686
+ 'stroke',
5687
+ 'strokeText',
5688
+ 'transform',
5689
+ 'translate',
5690
+ ];
5691
+ const CONTEXT_PROPERTIES = [
5692
+ 'fillStyle',
5693
+ 'strokeStyle',
5694
+ 'shadowColor',
5695
+ 'shadowBlur',
5696
+ 'shadowOffsetX',
5697
+ 'shadowOffsetY',
5698
+ 'letterSpacing',
5699
+ 'lineCap',
5700
+ 'lineDashOffset',
5701
+ 'lineJoin',
5702
+ 'lineWidth',
5703
+ 'miterLimit',
5704
+ 'direction',
5705
+ 'font',
5706
+ 'textAlign',
5707
+ 'textBaseline',
5708
+ 'globalAlpha',
5709
+ 'globalCompositeOperation',
5710
+ 'imageSmoothingEnabled',
5711
+ ];
5712
+ const traceArrMax = 100;
5713
+ let Context$1 = class Context {
5714
+ constructor(canvas) {
5715
+ this.canvas = canvas;
5716
+ if (Global_1.Konva.enableTrace) {
5717
+ this.traceArr = [];
5718
+ this._enableTrace();
5719
+ }
5659
5720
  }
5660
- if (Util_1.Util._isBoolean(val)) {
5661
- return val;
5721
+ fillShape(shape) {
5722
+ if (shape.fillEnabled()) {
5723
+ this._fill(shape);
5724
+ }
5662
5725
  }
5663
- return Object.prototype.toString.call(val);
5664
- }
5665
- function RGBComponent(val) {
5666
- if (val > 255) {
5667
- return 255;
5726
+ _fill(shape) {
5668
5727
  }
5669
- else if (val < 0) {
5670
- return 0;
5728
+ strokeShape(shape) {
5729
+ if (shape.hasStroke()) {
5730
+ this._stroke(shape);
5731
+ }
5671
5732
  }
5672
- return Math.round(val);
5673
- }
5674
- function alphaComponent(val) {
5675
- if (val > 1) {
5676
- return 1;
5733
+ _stroke(shape) {
5677
5734
  }
5678
- else if (val < 0.0001) {
5679
- return 0.0001;
5735
+ fillStrokeShape(shape) {
5736
+ if (shape.attrs.fillAfterStrokeEnabled) {
5737
+ this.strokeShape(shape);
5738
+ this.fillShape(shape);
5739
+ }
5740
+ else {
5741
+ this.fillShape(shape);
5742
+ this.strokeShape(shape);
5743
+ }
5680
5744
  }
5681
- return val;
5682
- }
5683
- function getNumberValidator() {
5684
- if (Global_1.Konva.isUnminified) {
5685
- return function (val, attr) {
5686
- if (!Util_1.Util._isNumber(val)) {
5687
- Util_1.Util.warn(_formatValue(val) +
5688
- ' is a not valid value for "' +
5689
- attr +
5690
- '" attribute. The value should be a number.');
5745
+ getTrace(relaxed, rounded) {
5746
+ let traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;
5747
+ for (n = 0; n < len; n++) {
5748
+ trace = traceArr[n];
5749
+ method = trace.method;
5750
+ if (method) {
5751
+ args = trace.args;
5752
+ str += method;
5753
+ if (relaxed) {
5754
+ str += DOUBLE_PAREN;
5755
+ }
5756
+ else {
5757
+ if (Util_1.Util._isArray(args[0])) {
5758
+ str += OPEN_PAREN_BRACKET + args.join(COMMA) + CLOSE_BRACKET_PAREN;
5759
+ }
5760
+ else {
5761
+ if (rounded) {
5762
+ args = args.map((a) => typeof a === 'number' ? Math.floor(a) : a);
5763
+ }
5764
+ str += OPEN_PAREN + args.join(COMMA) + CLOSE_PAREN;
5765
+ }
5766
+ }
5691
5767
  }
5692
- return val;
5693
- };
5694
- }
5695
- }
5696
- function getNumberOrArrayOfNumbersValidator(noOfElements) {
5697
- if (Global_1.Konva.isUnminified) {
5698
- return function (val, attr) {
5699
- let isNumber = Util_1.Util._isNumber(val);
5700
- let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
5701
- if (!isNumber && !isValidArray) {
5702
- Util_1.Util.warn(_formatValue(val) +
5703
- ' is a not valid value for "' +
5704
- attr +
5705
- '" attribute. The value should be a number or Array<number>(' +
5706
- noOfElements +
5707
- ')');
5768
+ else {
5769
+ str += trace.property;
5770
+ if (!relaxed) {
5771
+ str += EQUALS + trace.val;
5772
+ }
5708
5773
  }
5709
- return val;
5710
- };
5774
+ str += SEMICOLON;
5775
+ }
5776
+ return str;
5711
5777
  }
5712
- }
5713
- function getNumberOrAutoValidator() {
5714
- if (Global_1.Konva.isUnminified) {
5715
- return function (val, attr) {
5716
- var isNumber = Util_1.Util._isNumber(val);
5717
- var isAuto = val === 'auto';
5718
- if (!(isNumber || isAuto)) {
5719
- Util_1.Util.warn(_formatValue(val) +
5720
- ' is a not valid value for "' +
5721
- attr +
5722
- '" attribute. The value should be a number or "auto".');
5723
- }
5724
- return val;
5725
- };
5778
+ clearTrace() {
5779
+ this.traceArr = [];
5726
5780
  }
5727
- }
5728
- function getStringValidator() {
5729
- if (Global_1.Konva.isUnminified) {
5730
- return function (val, attr) {
5731
- if (!Util_1.Util._isString(val)) {
5732
- Util_1.Util.warn(_formatValue(val) +
5733
- ' is a not valid value for "' +
5734
- attr +
5735
- '" attribute. The value should be a string.');
5736
- }
5737
- return val;
5738
- };
5781
+ _trace(str) {
5782
+ let traceArr = this.traceArr, len;
5783
+ traceArr.push(str);
5784
+ len = traceArr.length;
5785
+ if (len >= traceArrMax) {
5786
+ traceArr.shift();
5787
+ }
5739
5788
  }
5740
- }
5741
- function getStringOrGradientValidator() {
5742
- if (Global_1.Konva.isUnminified) {
5743
- return function (val, attr) {
5744
- const isString = Util_1.Util._isString(val);
5745
- const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
5746
- (val && val['addColorStop']);
5747
- if (!(isString || isGradient)) {
5748
- Util_1.Util.warn(_formatValue(val) +
5749
- ' is a not valid value for "' +
5750
- attr +
5751
- '" attribute. The value should be a string or a native gradient.');
5752
- }
5753
- return val;
5754
- };
5755
- }
5756
- }
5757
- function getFunctionValidator() {
5758
- if (Global_1.Konva.isUnminified) {
5759
- return function (val, attr) {
5760
- if (!Util_1.Util._isFunction(val)) {
5761
- Util_1.Util.warn(_formatValue(val) +
5762
- ' is a not valid value for "' +
5763
- attr +
5764
- '" attribute. The value should be a function.');
5765
- }
5766
- return val;
5767
- };
5768
- }
5769
- }
5770
- function getNumberArrayValidator() {
5771
- if (Global_1.Konva.isUnminified) {
5772
- return function (val, attr) {
5773
- const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
5774
- if (TypedArray && val instanceof TypedArray) {
5775
- return val;
5776
- }
5777
- if (!Util_1.Util._isArray(val)) {
5778
- Util_1.Util.warn(_formatValue(val) +
5779
- ' is a not valid value for "' +
5780
- attr +
5781
- '" attribute. The value should be a array of numbers.');
5782
- }
5783
- else {
5784
- val.forEach(function (item) {
5785
- if (!Util_1.Util._isNumber(item)) {
5786
- Util_1.Util.warn('"' +
5787
- attr +
5788
- '" attribute has non numeric element ' +
5789
- item +
5790
- '. Make sure that all elements are numbers.');
5791
- }
5792
- });
5793
- }
5794
- return val;
5795
- };
5796
- }
5797
- }
5798
- function getBooleanValidator() {
5799
- if (Global_1.Konva.isUnminified) {
5800
- return function (val, attr) {
5801
- var isBool = val === true || val === false;
5802
- if (!isBool) {
5803
- Util_1.Util.warn(_formatValue(val) +
5804
- ' is a not valid value for "' +
5805
- attr +
5806
- '" attribute. The value should be a boolean.');
5807
- }
5808
- return val;
5809
- };
5810
- }
5811
- }
5812
- function getComponentValidator(components) {
5813
- if (Global_1.Konva.isUnminified) {
5814
- return function (val, attr) {
5815
- if (val === undefined || val === null) {
5816
- return val;
5817
- }
5818
- if (!Util_1.Util.isObject(val)) {
5819
- Util_1.Util.warn(_formatValue(val) +
5820
- ' is a not valid value for "' +
5821
- attr +
5822
- '" attribute. The value should be an object with properties ' +
5823
- components);
5824
- }
5825
- return val;
5826
- };
5827
- }
5828
- }
5829
- return Validators;
5830
- }
5831
-
5832
- var hasRequiredFactory;
5833
-
5834
- function requireFactory () {
5835
- if (hasRequiredFactory) return Factory;
5836
- hasRequiredFactory = 1;
5837
- (function (exports) {
5838
- Object.defineProperty(exports, "__esModule", { value: true });
5839
- exports.Factory = undefined;
5840
- const Util_1 = requireUtil();
5841
- const Validators_1 = requireValidators();
5842
- const GET = 'get';
5843
- const SET = 'set';
5844
- exports.Factory = {
5845
- addGetterSetter(constructor, attr, def, validator, after) {
5846
- exports.Factory.addGetter(constructor, attr, def);
5847
- exports.Factory.addSetter(constructor, attr, validator, after);
5848
- exports.Factory.addOverloadedGetterSetter(constructor, attr);
5849
- },
5850
- addGetter(constructor, attr, def) {
5851
- var method = GET + Util_1.Util._capitalize(attr);
5852
- constructor.prototype[method] =
5853
- constructor.prototype[method] ||
5854
- function () {
5855
- const val = this.attrs[attr];
5856
- return val === undefined ? def : val;
5857
- };
5858
- },
5859
- addSetter(constructor, attr, validator, after) {
5860
- var method = SET + Util_1.Util._capitalize(attr);
5861
- if (!constructor.prototype[method]) {
5862
- exports.Factory.overWriteSetter(constructor, attr, validator, after);
5863
- }
5864
- },
5865
- overWriteSetter(constructor, attr, validator, after) {
5866
- var method = SET + Util_1.Util._capitalize(attr);
5867
- constructor.prototype[method] = function (val) {
5868
- if (validator && val !== undefined && val !== null) {
5869
- val = validator.call(this, val, attr);
5870
- }
5871
- this._setAttr(attr, val);
5872
- if (after) {
5873
- after.call(this);
5874
- }
5875
- return this;
5876
- };
5877
- },
5878
- addComponentsGetterSetter(constructor, attr, components, validator, after) {
5879
- const len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr);
5880
- constructor.prototype[getter] = function () {
5881
- const ret = {};
5882
- for (let n = 0; n < len; n++) {
5883
- const component = components[n];
5884
- ret[component] = this.getAttr(attr + capitalize(component));
5885
- }
5886
- return ret;
5887
- };
5888
- const basicValidator = (0, Validators_1.getComponentValidator)(components);
5889
- constructor.prototype[setter] = function (val) {
5890
- const oldVal = this.attrs[attr];
5891
- if (validator) {
5892
- val = validator.call(this, val, attr);
5893
- }
5894
- if (basicValidator) {
5895
- basicValidator.call(this, val, attr);
5896
- }
5897
- for (const key in val) {
5898
- if (!val.hasOwnProperty(key)) {
5899
- continue;
5900
- }
5901
- this._setAttr(attr + capitalize(key), val[key]);
5902
- }
5903
- if (!val) {
5904
- components.forEach((component) => {
5905
- this._setAttr(attr + capitalize(component), undefined);
5906
- });
5907
- }
5908
- this._fireChangeEvent(attr, oldVal, val);
5909
- if (after) {
5910
- after.call(this);
5911
- }
5912
- return this;
5913
- };
5914
- exports.Factory.addOverloadedGetterSetter(constructor, attr);
5915
- },
5916
- addOverloadedGetterSetter(constructor, attr) {
5917
- var capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;
5918
- constructor.prototype[attr] = function () {
5919
- if (arguments.length) {
5920
- this[setter](arguments[0]);
5921
- return this;
5922
- }
5923
- return this[getter]();
5924
- };
5925
- },
5926
- addDeprecatedGetterSetter(constructor, attr, def, validator) {
5927
- Util_1.Util.error('Adding deprecated ' + attr);
5928
- const method = GET + Util_1.Util._capitalize(attr);
5929
- const message = attr +
5930
- ' property is deprecated and will be removed soon. Look at Konva change log for more information.';
5931
- constructor.prototype[method] = function () {
5932
- Util_1.Util.error(message);
5933
- const val = this.attrs[attr];
5934
- return val === undefined ? def : val;
5935
- };
5936
- exports.Factory.addSetter(constructor, attr, validator, function () {
5937
- Util_1.Util.error(message);
5938
- });
5939
- exports.Factory.addOverloadedGetterSetter(constructor, attr);
5940
- },
5941
- backCompat(constructor, methods) {
5942
- Util_1.Util.each(methods, function (oldMethodName, newMethodName) {
5943
- const method = constructor.prototype[newMethodName];
5944
- const oldGetter = GET + Util_1.Util._capitalize(oldMethodName);
5945
- const oldSetter = SET + Util_1.Util._capitalize(oldMethodName);
5946
- function deprecated() {
5947
- method.apply(this, arguments);
5948
- Util_1.Util.error('"' +
5949
- oldMethodName +
5950
- '" method is deprecated and will be removed soon. Use ""' +
5951
- newMethodName +
5952
- '" instead.');
5953
- }
5954
- constructor.prototype[oldMethodName] = deprecated;
5955
- constructor.prototype[oldGetter] = deprecated;
5956
- constructor.prototype[oldSetter] = deprecated;
5957
- });
5958
- },
5959
- afterSetFilter() {
5960
- this._filterUpToDate = false;
5961
- },
5962
- };
5963
- } (Factory));
5964
- return Factory;
5965
- }
5966
-
5967
- var Canvas = {};
5968
-
5969
- var Context = {};
5970
-
5971
- var hasRequiredContext;
5972
-
5973
- function requireContext () {
5974
- if (hasRequiredContext) return Context;
5975
- hasRequiredContext = 1;
5976
- Object.defineProperty(Context, "__esModule", { value: true });
5977
- Context.HitContext = Context.SceneContext = Context.Context = undefined;
5978
- const Util_1 = requireUtil();
5979
- const Global_1 = requireGlobal();
5980
- function simplifyArray(arr) {
5981
- const retArr = [], len = arr.length, util = Util_1.Util;
5982
- for (let n = 0; n < len; n++) {
5983
- let val = arr[n];
5984
- if (util._isNumber(val)) {
5985
- val = Math.round(val * 1000) / 1000;
5986
- }
5987
- else if (!util._isString(val)) {
5988
- val = val + '';
5989
- }
5990
- retArr.push(val);
5991
- }
5992
- return retArr;
5993
- }
5994
- const COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()', EQUALS = '=', CONTEXT_METHODS = [
5995
- 'arc',
5996
- 'arcTo',
5997
- 'beginPath',
5998
- 'bezierCurveTo',
5999
- 'clearRect',
6000
- 'clip',
6001
- 'closePath',
6002
- 'createLinearGradient',
6003
- 'createPattern',
6004
- 'createRadialGradient',
6005
- 'drawImage',
6006
- 'ellipse',
6007
- 'fill',
6008
- 'fillText',
6009
- 'getImageData',
6010
- 'createImageData',
6011
- 'lineTo',
6012
- 'moveTo',
6013
- 'putImageData',
6014
- 'quadraticCurveTo',
6015
- 'rect',
6016
- 'roundRect',
6017
- 'restore',
6018
- 'rotate',
6019
- 'save',
6020
- 'scale',
6021
- 'setLineDash',
6022
- 'setTransform',
6023
- 'stroke',
6024
- 'strokeText',
6025
- 'transform',
6026
- 'translate',
6027
- ];
6028
- const CONTEXT_PROPERTIES = [
6029
- 'fillStyle',
6030
- 'strokeStyle',
6031
- 'shadowColor',
6032
- 'shadowBlur',
6033
- 'shadowOffsetX',
6034
- 'shadowOffsetY',
6035
- 'letterSpacing',
6036
- 'lineCap',
6037
- 'lineDashOffset',
6038
- 'lineJoin',
6039
- 'lineWidth',
6040
- 'miterLimit',
6041
- 'direction',
6042
- 'font',
6043
- 'textAlign',
6044
- 'textBaseline',
6045
- 'globalAlpha',
6046
- 'globalCompositeOperation',
6047
- 'imageSmoothingEnabled',
6048
- ];
6049
- const traceArrMax = 100;
6050
- let Context$1 = class Context {
6051
- constructor(canvas) {
6052
- this.canvas = canvas;
6053
- if (Global_1.Konva.enableTrace) {
6054
- this.traceArr = [];
6055
- this._enableTrace();
6056
- }
6057
- }
6058
- fillShape(shape) {
6059
- if (shape.fillEnabled()) {
6060
- this._fill(shape);
6061
- }
6062
- }
6063
- _fill(shape) {
6064
- }
6065
- strokeShape(shape) {
6066
- if (shape.hasStroke()) {
6067
- this._stroke(shape);
6068
- }
6069
- }
6070
- _stroke(shape) {
6071
- }
6072
- fillStrokeShape(shape) {
6073
- if (shape.attrs.fillAfterStrokeEnabled) {
6074
- this.strokeShape(shape);
6075
- this.fillShape(shape);
6076
- }
6077
- else {
6078
- this.fillShape(shape);
6079
- this.strokeShape(shape);
6080
- }
6081
- }
6082
- getTrace(relaxed, rounded) {
6083
- let traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;
6084
- for (n = 0; n < len; n++) {
6085
- trace = traceArr[n];
6086
- method = trace.method;
6087
- if (method) {
6088
- args = trace.args;
6089
- str += method;
6090
- if (relaxed) {
6091
- str += DOUBLE_PAREN;
6092
- }
6093
- else {
6094
- if (Util_1.Util._isArray(args[0])) {
6095
- str += OPEN_PAREN_BRACKET + args.join(COMMA) + CLOSE_BRACKET_PAREN;
6096
- }
6097
- else {
6098
- if (rounded) {
6099
- args = args.map((a) => typeof a === 'number' ? Math.floor(a) : a);
6100
- }
6101
- str += OPEN_PAREN + args.join(COMMA) + CLOSE_PAREN;
6102
- }
6103
- }
6104
- }
6105
- else {
6106
- str += trace.property;
6107
- if (!relaxed) {
6108
- str += EQUALS + trace.val;
6109
- }
6110
- }
6111
- str += SEMICOLON;
6112
- }
6113
- return str;
6114
- }
6115
- clearTrace() {
6116
- this.traceArr = [];
6117
- }
6118
- _trace(str) {
6119
- let traceArr = this.traceArr, len;
6120
- traceArr.push(str);
6121
- len = traceArr.length;
6122
- if (len >= traceArrMax) {
6123
- traceArr.shift();
6124
- }
6125
- }
6126
- reset() {
6127
- const pixelRatio = this.getCanvas().getPixelRatio();
6128
- this.setTransform(1 * pixelRatio, 0, 0, 1 * pixelRatio, 0, 0);
5789
+ reset() {
5790
+ const pixelRatio = this.getCanvas().getPixelRatio();
5791
+ this.setTransform(1 * pixelRatio, 0, 0, 1 * pixelRatio, 0, 0);
6129
5792
  }
6130
5793
  getCanvas() {
6131
5794
  return this.canvas;
@@ -6186,581 +5849,915 @@
6186
5849
  if (a.length === 2) {
6187
5850
  return this._context.createImageData(width, height);
6188
5851
  }
6189
- else if (a.length === 1) {
6190
- return this._context.createImageData(width);
5852
+ else if (a.length === 1) {
5853
+ return this._context.createImageData(width);
5854
+ }
5855
+ }
5856
+ createLinearGradient(x0, y0, x1, y1) {
5857
+ return this._context.createLinearGradient(x0, y0, x1, y1);
5858
+ }
5859
+ createPattern(image, repetition) {
5860
+ return this._context.createPattern(image, repetition);
5861
+ }
5862
+ createRadialGradient(x0, y0, r0, x1, y1, r1) {
5863
+ return this._context.createRadialGradient(x0, y0, r0, x1, y1, r1);
5864
+ }
5865
+ drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
5866
+ const a = arguments, _context = this._context;
5867
+ if (a.length === 3) {
5868
+ _context.drawImage(image, sx, sy);
5869
+ }
5870
+ else if (a.length === 5) {
5871
+ _context.drawImage(image, sx, sy, sWidth, sHeight);
5872
+ }
5873
+ else if (a.length === 9) {
5874
+ _context.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
5875
+ }
5876
+ }
5877
+ ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
5878
+ this._context.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);
5879
+ }
5880
+ isPointInPath(x, y, path, fillRule) {
5881
+ if (path) {
5882
+ return this._context.isPointInPath(path, x, y, fillRule);
5883
+ }
5884
+ return this._context.isPointInPath(x, y, fillRule);
5885
+ }
5886
+ fill(...args) {
5887
+ this._context.fill.apply(this._context, args);
5888
+ }
5889
+ fillRect(x, y, width, height) {
5890
+ this._context.fillRect(x, y, width, height);
5891
+ }
5892
+ strokeRect(x, y, width, height) {
5893
+ this._context.strokeRect(x, y, width, height);
5894
+ }
5895
+ fillText(text, x, y, maxWidth) {
5896
+ if (maxWidth) {
5897
+ this._context.fillText(text, x, y, maxWidth);
5898
+ }
5899
+ else {
5900
+ this._context.fillText(text, x, y);
5901
+ }
5902
+ }
5903
+ measureText(text) {
5904
+ return this._context.measureText(text);
5905
+ }
5906
+ getImageData(sx, sy, sw, sh) {
5907
+ return this._context.getImageData(sx, sy, sw, sh);
5908
+ }
5909
+ lineTo(x, y) {
5910
+ this._context.lineTo(x, y);
5911
+ }
5912
+ moveTo(x, y) {
5913
+ this._context.moveTo(x, y);
5914
+ }
5915
+ rect(x, y, width, height) {
5916
+ this._context.rect(x, y, width, height);
5917
+ }
5918
+ roundRect(x, y, width, height, radii) {
5919
+ this._context.roundRect(x, y, width, height, radii);
5920
+ }
5921
+ putImageData(imageData, dx, dy) {
5922
+ this._context.putImageData(imageData, dx, dy);
5923
+ }
5924
+ quadraticCurveTo(cpx, cpy, x, y) {
5925
+ this._context.quadraticCurveTo(cpx, cpy, x, y);
5926
+ }
5927
+ restore() {
5928
+ this._context.restore();
5929
+ }
5930
+ rotate(angle) {
5931
+ this._context.rotate(angle);
5932
+ }
5933
+ save() {
5934
+ this._context.save();
5935
+ }
5936
+ scale(x, y) {
5937
+ this._context.scale(x, y);
5938
+ }
5939
+ setLineDash(segments) {
5940
+ if (this._context.setLineDash) {
5941
+ this._context.setLineDash(segments);
5942
+ }
5943
+ else if ('mozDash' in this._context) {
5944
+ this._context['mozDash'] = segments;
5945
+ }
5946
+ else if ('webkitLineDash' in this._context) {
5947
+ this._context['webkitLineDash'] = segments;
5948
+ }
5949
+ }
5950
+ getLineDash() {
5951
+ return this._context.getLineDash();
5952
+ }
5953
+ setTransform(a, b, c, d, e, f) {
5954
+ this._context.setTransform(a, b, c, d, e, f);
5955
+ }
5956
+ stroke(path2d) {
5957
+ if (path2d) {
5958
+ this._context.stroke(path2d);
5959
+ }
5960
+ else {
5961
+ this._context.stroke();
5962
+ }
5963
+ }
5964
+ strokeText(text, x, y, maxWidth) {
5965
+ this._context.strokeText(text, x, y, maxWidth);
5966
+ }
5967
+ transform(a, b, c, d, e, f) {
5968
+ this._context.transform(a, b, c, d, e, f);
5969
+ }
5970
+ translate(x, y) {
5971
+ this._context.translate(x, y);
5972
+ }
5973
+ _enableTrace() {
5974
+ let that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;
5975
+ const func = function (methodName) {
5976
+ let origMethod = that[methodName], ret;
5977
+ that[methodName] = function () {
5978
+ args = simplifyArray(Array.prototype.slice.call(arguments, 0));
5979
+ ret = origMethod.apply(that, arguments);
5980
+ that._trace({
5981
+ method: methodName,
5982
+ args: args,
5983
+ });
5984
+ return ret;
5985
+ };
5986
+ };
5987
+ for (n = 0; n < len; n++) {
5988
+ func(CONTEXT_METHODS[n]);
5989
+ }
5990
+ that.setAttr = function () {
5991
+ origSetter.apply(that, arguments);
5992
+ const prop = arguments[0];
5993
+ let val = arguments[1];
5994
+ if (prop === 'shadowOffsetX' ||
5995
+ prop === 'shadowOffsetY' ||
5996
+ prop === 'shadowBlur') {
5997
+ val = val / this.canvas.getPixelRatio();
5998
+ }
5999
+ that._trace({
6000
+ property: prop,
6001
+ val: val,
6002
+ });
6003
+ };
6004
+ }
6005
+ _applyGlobalCompositeOperation(node) {
6006
+ const op = node.attrs.globalCompositeOperation;
6007
+ const def = !op || op === 'source-over';
6008
+ if (!def) {
6009
+ this.setAttr('globalCompositeOperation', op);
6010
+ }
6011
+ }
6012
+ };
6013
+ Context.Context = Context$1;
6014
+ CONTEXT_PROPERTIES.forEach(function (prop) {
6015
+ Object.defineProperty(Context$1.prototype, prop, {
6016
+ get() {
6017
+ return this._context[prop];
6018
+ },
6019
+ set(val) {
6020
+ this._context[prop] = val;
6021
+ },
6022
+ });
6023
+ });
6024
+ class SceneContext extends Context$1 {
6025
+ constructor(canvas, { willReadFrequently = false } = {}) {
6026
+ super(canvas);
6027
+ this._context = canvas._canvas.getContext('2d', {
6028
+ willReadFrequently,
6029
+ });
6030
+ }
6031
+ _fillColor(shape) {
6032
+ const fill = shape.fill();
6033
+ this.setAttr('fillStyle', fill);
6034
+ shape._fillFunc(this);
6035
+ }
6036
+ _fillPattern(shape) {
6037
+ this.setAttr('fillStyle', shape._getFillPattern());
6038
+ shape._fillFunc(this);
6039
+ }
6040
+ _fillLinearGradient(shape) {
6041
+ const grd = shape._getLinearGradient();
6042
+ if (grd) {
6043
+ this.setAttr('fillStyle', grd);
6044
+ shape._fillFunc(this);
6045
+ }
6046
+ }
6047
+ _fillRadialGradient(shape) {
6048
+ const grd = shape._getRadialGradient();
6049
+ if (grd) {
6050
+ this.setAttr('fillStyle', grd);
6051
+ shape._fillFunc(this);
6052
+ }
6053
+ }
6054
+ _fill(shape) {
6055
+ const hasColor = shape.fill(), fillPriority = shape.getFillPriority();
6056
+ if (hasColor && fillPriority === 'color') {
6057
+ this._fillColor(shape);
6058
+ return;
6059
+ }
6060
+ const hasPattern = shape.getFillPatternImage();
6061
+ if (hasPattern && fillPriority === 'pattern') {
6062
+ this._fillPattern(shape);
6063
+ return;
6191
6064
  }
6192
- }
6193
- createLinearGradient(x0, y0, x1, y1) {
6194
- return this._context.createLinearGradient(x0, y0, x1, y1);
6195
- }
6196
- createPattern(image, repetition) {
6197
- return this._context.createPattern(image, repetition);
6198
- }
6199
- createRadialGradient(x0, y0, r0, x1, y1, r1) {
6200
- return this._context.createRadialGradient(x0, y0, r0, x1, y1, r1);
6201
- }
6202
- drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
6203
- const a = arguments, _context = this._context;
6204
- if (a.length === 3) {
6205
- _context.drawImage(image, sx, sy);
6065
+ const hasLinearGradient = shape.getFillLinearGradientColorStops();
6066
+ if (hasLinearGradient && fillPriority === 'linear-gradient') {
6067
+ this._fillLinearGradient(shape);
6068
+ return;
6206
6069
  }
6207
- else if (a.length === 5) {
6208
- _context.drawImage(image, sx, sy, sWidth, sHeight);
6070
+ const hasRadialGradient = shape.getFillRadialGradientColorStops();
6071
+ if (hasRadialGradient && fillPriority === 'radial-gradient') {
6072
+ this._fillRadialGradient(shape);
6073
+ return;
6209
6074
  }
6210
- else if (a.length === 9) {
6211
- _context.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
6075
+ if (hasColor) {
6076
+ this._fillColor(shape);
6212
6077
  }
6213
- }
6214
- ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
6215
- this._context.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);
6216
- }
6217
- isPointInPath(x, y, path, fillRule) {
6218
- if (path) {
6219
- return this._context.isPointInPath(path, x, y, fillRule);
6078
+ else if (hasPattern) {
6079
+ this._fillPattern(shape);
6220
6080
  }
6221
- return this._context.isPointInPath(x, y, fillRule);
6222
- }
6223
- fill(...args) {
6224
- this._context.fill.apply(this._context, args);
6225
- }
6226
- fillRect(x, y, width, height) {
6227
- this._context.fillRect(x, y, width, height);
6228
- }
6229
- strokeRect(x, y, width, height) {
6230
- this._context.strokeRect(x, y, width, height);
6231
- }
6232
- fillText(text, x, y, maxWidth) {
6233
- if (maxWidth) {
6234
- this._context.fillText(text, x, y, maxWidth);
6081
+ else if (hasLinearGradient) {
6082
+ this._fillLinearGradient(shape);
6235
6083
  }
6236
- else {
6237
- this._context.fillText(text, x, y);
6084
+ else if (hasRadialGradient) {
6085
+ this._fillRadialGradient(shape);
6238
6086
  }
6239
6087
  }
6240
- measureText(text) {
6241
- return this._context.measureText(text);
6242
- }
6243
- getImageData(sx, sy, sw, sh) {
6244
- return this._context.getImageData(sx, sy, sw, sh);
6245
- }
6246
- lineTo(x, y) {
6247
- this._context.lineTo(x, y);
6088
+ _strokeLinearGradient(shape) {
6089
+ const start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
6090
+ if (colorStops) {
6091
+ for (let n = 0; n < colorStops.length; n += 2) {
6092
+ grd.addColorStop(colorStops[n], colorStops[n + 1]);
6093
+ }
6094
+ this.setAttr('strokeStyle', grd);
6095
+ }
6248
6096
  }
6249
- moveTo(x, y) {
6250
- this._context.moveTo(x, y);
6097
+ _stroke(shape) {
6098
+ const dash = shape.dash(), strokeScaleEnabled = shape.getStrokeScaleEnabled();
6099
+ if (shape.hasStroke()) {
6100
+ if (!strokeScaleEnabled) {
6101
+ this.save();
6102
+ const pixelRatio = this.getCanvas().getPixelRatio();
6103
+ this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
6104
+ }
6105
+ this._applyLineCap(shape);
6106
+ if (dash && shape.dashEnabled()) {
6107
+ this.setLineDash(dash);
6108
+ this.setAttr('lineDashOffset', shape.dashOffset());
6109
+ }
6110
+ this.setAttr('lineWidth', shape.strokeWidth());
6111
+ if (!shape.getShadowForStrokeEnabled()) {
6112
+ this.setAttr('shadowColor', 'rgba(0,0,0,0)');
6113
+ }
6114
+ const hasLinearGradient = shape.getStrokeLinearGradientColorStops();
6115
+ if (hasLinearGradient) {
6116
+ this._strokeLinearGradient(shape);
6117
+ }
6118
+ else {
6119
+ this.setAttr('strokeStyle', shape.stroke());
6120
+ }
6121
+ shape._strokeFunc(this);
6122
+ if (!strokeScaleEnabled) {
6123
+ this.restore();
6124
+ }
6125
+ }
6251
6126
  }
6252
- rect(x, y, width, height) {
6253
- this._context.rect(x, y, width, height);
6127
+ _applyShadow(shape) {
6128
+ var _a, _b, _c;
6129
+ const color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== void 0 ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== void 0 ? _c : {
6130
+ x: 0,
6131
+ y: 0,
6132
+ }, scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;
6133
+ this.setAttr('shadowColor', color);
6134
+ this.setAttr('shadowBlur', blur * Math.min(Math.abs(scaleX), Math.abs(scaleY)));
6135
+ this.setAttr('shadowOffsetX', offset.x * scaleX);
6136
+ this.setAttr('shadowOffsetY', offset.y * scaleY);
6254
6137
  }
6255
- roundRect(x, y, width, height, radii) {
6256
- this._context.roundRect(x, y, width, height, radii);
6138
+ }
6139
+ Context.SceneContext = SceneContext;
6140
+ class HitContext extends Context$1 {
6141
+ constructor(canvas) {
6142
+ super(canvas);
6143
+ this._context = canvas._canvas.getContext('2d', {
6144
+ willReadFrequently: true,
6145
+ });
6257
6146
  }
6258
- putImageData(imageData, dx, dy) {
6259
- this._context.putImageData(imageData, dx, dy);
6147
+ _fill(shape) {
6148
+ this.save();
6149
+ this.setAttr('fillStyle', shape.colorKey);
6150
+ shape._fillFuncHit(this);
6151
+ this.restore();
6260
6152
  }
6261
- quadraticCurveTo(cpx, cpy, x, y) {
6262
- this._context.quadraticCurveTo(cpx, cpy, x, y);
6153
+ strokeShape(shape) {
6154
+ if (shape.hasHitStroke()) {
6155
+ this._stroke(shape);
6156
+ }
6263
6157
  }
6264
- restore() {
6265
- this._context.restore();
6158
+ _stroke(shape) {
6159
+ if (shape.hasHitStroke()) {
6160
+ const strokeScaleEnabled = shape.getStrokeScaleEnabled();
6161
+ if (!strokeScaleEnabled) {
6162
+ this.save();
6163
+ const pixelRatio = this.getCanvas().getPixelRatio();
6164
+ this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
6165
+ }
6166
+ this._applyLineCap(shape);
6167
+ const hitStrokeWidth = shape.hitStrokeWidth();
6168
+ const strokeWidth = hitStrokeWidth === 'auto' ? shape.strokeWidth() : hitStrokeWidth;
6169
+ this.setAttr('lineWidth', strokeWidth);
6170
+ this.setAttr('strokeStyle', shape.colorKey);
6171
+ shape._strokeFuncHit(this);
6172
+ if (!strokeScaleEnabled) {
6173
+ this.restore();
6174
+ }
6175
+ }
6266
6176
  }
6267
- rotate(angle) {
6268
- this._context.rotate(angle);
6177
+ }
6178
+ Context.HitContext = HitContext;
6179
+ return Context;
6180
+ }
6181
+
6182
+ var hasRequiredCanvas;
6183
+
6184
+ function requireCanvas () {
6185
+ if (hasRequiredCanvas) return Canvas;
6186
+ hasRequiredCanvas = 1;
6187
+ Object.defineProperty(Canvas, "__esModule", { value: true });
6188
+ Canvas.HitCanvas = Canvas.SceneCanvas = Canvas.Canvas = void 0;
6189
+ const Util_1 = requireUtil();
6190
+ const Context_1 = requireContext();
6191
+ const Global_1 = requireGlobal();
6192
+ let _pixelRatio;
6193
+ function getDevicePixelRatio() {
6194
+ if (_pixelRatio) {
6195
+ return _pixelRatio;
6269
6196
  }
6270
- save() {
6271
- this._context.save();
6197
+ const canvas = Util_1.Util.createCanvasElement();
6198
+ const context = canvas.getContext('2d');
6199
+ _pixelRatio = (function () {
6200
+ const devicePixelRatio = Global_1.Konva._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||
6201
+ context.mozBackingStorePixelRatio ||
6202
+ context.msBackingStorePixelRatio ||
6203
+ context.oBackingStorePixelRatio ||
6204
+ context.backingStorePixelRatio ||
6205
+ 1;
6206
+ return devicePixelRatio / backingStoreRatio;
6207
+ })();
6208
+ Util_1.Util.releaseCanvas(canvas);
6209
+ return _pixelRatio;
6210
+ }
6211
+ let Canvas$1 = class Canvas {
6212
+ constructor(config) {
6213
+ this.pixelRatio = 1;
6214
+ this.width = 0;
6215
+ this.height = 0;
6216
+ this.isCache = false;
6217
+ const conf = config || {};
6218
+ const pixelRatio = conf.pixelRatio || Global_1.Konva.pixelRatio || getDevicePixelRatio();
6219
+ this.pixelRatio = pixelRatio;
6220
+ this._canvas = Util_1.Util.createCanvasElement();
6221
+ this._canvas.style.padding = '0';
6222
+ this._canvas.style.margin = '0';
6223
+ this._canvas.style.border = '0';
6224
+ this._canvas.style.background = 'transparent';
6225
+ this._canvas.style.position = 'absolute';
6226
+ this._canvas.style.top = '0';
6227
+ this._canvas.style.left = '0';
6272
6228
  }
6273
- scale(x, y) {
6274
- this._context.scale(x, y);
6229
+ getContext() {
6230
+ return this.context;
6275
6231
  }
6276
- setLineDash(segments) {
6277
- if (this._context.setLineDash) {
6278
- this._context.setLineDash(segments);
6279
- }
6280
- else if ('mozDash' in this._context) {
6281
- this._context['mozDash'] = segments;
6282
- }
6283
- else if ('webkitLineDash' in this._context) {
6284
- this._context['webkitLineDash'] = segments;
6285
- }
6232
+ getPixelRatio() {
6233
+ return this.pixelRatio;
6286
6234
  }
6287
- getLineDash() {
6288
- return this._context.getLineDash();
6235
+ setPixelRatio(pixelRatio) {
6236
+ const previousRatio = this.pixelRatio;
6237
+ this.pixelRatio = pixelRatio;
6238
+ this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);
6289
6239
  }
6290
- setTransform(a, b, c, d, e, f) {
6291
- this._context.setTransform(a, b, c, d, e, f);
6240
+ setWidth(width) {
6241
+ this.width = this._canvas.width = width * this.pixelRatio;
6242
+ this._canvas.style.width = width + 'px';
6243
+ const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
6244
+ _context.scale(pixelRatio, pixelRatio);
6292
6245
  }
6293
- stroke(path2d) {
6294
- if (path2d) {
6295
- this._context.stroke(path2d);
6296
- }
6297
- else {
6298
- this._context.stroke();
6299
- }
6246
+ setHeight(height) {
6247
+ this.height = this._canvas.height = height * this.pixelRatio;
6248
+ this._canvas.style.height = height + 'px';
6249
+ const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
6250
+ _context.scale(pixelRatio, pixelRatio);
6300
6251
  }
6301
- strokeText(text, x, y, maxWidth) {
6302
- this._context.strokeText(text, x, y, maxWidth);
6252
+ getWidth() {
6253
+ return this.width;
6303
6254
  }
6304
- transform(a, b, c, d, e, f) {
6305
- this._context.transform(a, b, c, d, e, f);
6255
+ getHeight() {
6256
+ return this.height;
6306
6257
  }
6307
- translate(x, y) {
6308
- this._context.translate(x, y);
6258
+ setSize(width, height) {
6259
+ this.setWidth(width || 0);
6260
+ this.setHeight(height || 0);
6309
6261
  }
6310
- _enableTrace() {
6311
- let that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;
6312
- const func = function (methodName) {
6313
- let origMethod = that[methodName], ret;
6314
- that[methodName] = function () {
6315
- args = simplifyArray(Array.prototype.slice.call(arguments, 0));
6316
- ret = origMethod.apply(that, arguments);
6317
- that._trace({
6318
- method: methodName,
6319
- args: args,
6320
- });
6321
- return ret;
6322
- };
6323
- };
6324
- for (n = 0; n < len; n++) {
6325
- func(CONTEXT_METHODS[n]);
6262
+ toDataURL(mimeType, quality) {
6263
+ try {
6264
+ return this._canvas.toDataURL(mimeType, quality);
6326
6265
  }
6327
- that.setAttr = function () {
6328
- origSetter.apply(that, arguments);
6329
- const prop = arguments[0];
6330
- let val = arguments[1];
6331
- if (prop === 'shadowOffsetX' ||
6332
- prop === 'shadowOffsetY' ||
6333
- prop === 'shadowBlur') {
6334
- val = val / this.canvas.getPixelRatio();
6266
+ catch (e) {
6267
+ try {
6268
+ return this._canvas.toDataURL();
6269
+ }
6270
+ catch (err) {
6271
+ Util_1.Util.error('Unable to get data URL. ' +
6272
+ err.message +
6273
+ ' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');
6274
+ return '';
6335
6275
  }
6336
- that._trace({
6337
- property: prop,
6338
- val: val,
6339
- });
6340
- };
6341
- }
6342
- _applyGlobalCompositeOperation(node) {
6343
- const op = node.attrs.globalCompositeOperation;
6344
- const def = !op || op === 'source-over';
6345
- if (!def) {
6346
- this.setAttr('globalCompositeOperation', op);
6347
6276
  }
6348
6277
  }
6349
6278
  };
6350
- Context.Context = Context$1;
6351
- CONTEXT_PROPERTIES.forEach(function (prop) {
6352
- Object.defineProperty(Context$1.prototype, prop, {
6353
- get() {
6354
- return this._context[prop];
6355
- },
6356
- set(val) {
6357
- this._context[prop] = val;
6358
- },
6359
- });
6360
- });
6361
- class SceneContext extends Context$1 {
6362
- constructor(canvas, { willReadFrequently = false } = {}) {
6363
- super(canvas);
6364
- this._context = canvas._canvas.getContext('2d', {
6365
- willReadFrequently,
6279
+ Canvas.Canvas = Canvas$1;
6280
+ class SceneCanvas extends Canvas$1 {
6281
+ constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
6282
+ super(config);
6283
+ this.context = new Context_1.SceneContext(this, {
6284
+ willReadFrequently: config.willReadFrequently,
6366
6285
  });
6286
+ this.setSize(config.width, config.height);
6367
6287
  }
6368
- _fillColor(shape) {
6369
- const fill = shape.fill();
6370
- this.setAttr('fillStyle', fill);
6371
- shape._fillFunc(this);
6372
- }
6373
- _fillPattern(shape) {
6374
- this.setAttr('fillStyle', shape._getFillPattern());
6375
- shape._fillFunc(this);
6376
- }
6377
- _fillLinearGradient(shape) {
6378
- const grd = shape._getLinearGradient();
6379
- if (grd) {
6380
- this.setAttr('fillStyle', grd);
6381
- shape._fillFunc(this);
6382
- }
6288
+ }
6289
+ Canvas.SceneCanvas = SceneCanvas;
6290
+ class HitCanvas extends Canvas$1 {
6291
+ constructor(config = { width: 0, height: 0 }) {
6292
+ super(config);
6293
+ this.hitCanvas = true;
6294
+ this.context = new Context_1.HitContext(this);
6295
+ this.setSize(config.width, config.height);
6383
6296
  }
6384
- _fillRadialGradient(shape) {
6385
- const grd = shape._getRadialGradient();
6386
- if (grd) {
6387
- this.setAttr('fillStyle', grd);
6388
- shape._fillFunc(this);
6389
- }
6297
+ }
6298
+ Canvas.HitCanvas = HitCanvas;
6299
+ return Canvas;
6300
+ }
6301
+
6302
+ var DragAndDrop = {};
6303
+
6304
+ var hasRequiredDragAndDrop;
6305
+
6306
+ function requireDragAndDrop () {
6307
+ if (hasRequiredDragAndDrop) return DragAndDrop;
6308
+ hasRequiredDragAndDrop = 1;
6309
+ (function (exports) {
6310
+ Object.defineProperty(exports, "__esModule", { value: true });
6311
+ exports.DD = void 0;
6312
+ const Global_1 = requireGlobal();
6313
+ const Util_1 = requireUtil();
6314
+ exports.DD = {
6315
+ get isDragging() {
6316
+ let flag = false;
6317
+ exports.DD._dragElements.forEach((elem) => {
6318
+ if (elem.dragStatus === 'dragging') {
6319
+ flag = true;
6320
+ }
6321
+ });
6322
+ return flag;
6323
+ },
6324
+ justDragged: false,
6325
+ get node() {
6326
+ let node;
6327
+ exports.DD._dragElements.forEach((elem) => {
6328
+ node = elem.node;
6329
+ });
6330
+ return node;
6331
+ },
6332
+ _dragElements: new Map(),
6333
+ _drag(evt) {
6334
+ const nodesToFireEvents = [];
6335
+ exports.DD._dragElements.forEach((elem, key) => {
6336
+ const { node } = elem;
6337
+ const stage = node.getStage();
6338
+ stage.setPointersPositions(evt);
6339
+ if (elem.pointerId === undefined) {
6340
+ elem.pointerId = Util_1.Util._getFirstPointerId(evt);
6341
+ }
6342
+ const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
6343
+ if (!pos) {
6344
+ return;
6345
+ }
6346
+ if (elem.dragStatus !== 'dragging') {
6347
+ const dragDistance = node.dragDistance();
6348
+ const distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));
6349
+ if (distance < dragDistance) {
6350
+ return;
6351
+ }
6352
+ node.startDrag({ evt });
6353
+ if (!node.isDragging()) {
6354
+ return;
6355
+ }
6356
+ }
6357
+ node._setDragPosition(evt, elem);
6358
+ nodesToFireEvents.push(node);
6359
+ });
6360
+ nodesToFireEvents.forEach((node) => {
6361
+ node.fire('dragmove', {
6362
+ type: 'dragmove',
6363
+ target: node,
6364
+ evt: evt,
6365
+ }, true);
6366
+ });
6367
+ },
6368
+ _endDragBefore(evt) {
6369
+ const drawNodes = [];
6370
+ exports.DD._dragElements.forEach((elem) => {
6371
+ const { node } = elem;
6372
+ const stage = node.getStage();
6373
+ if (evt) {
6374
+ stage.setPointersPositions(evt);
6375
+ }
6376
+ const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
6377
+ if (!pos) {
6378
+ return;
6379
+ }
6380
+ if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {
6381
+ exports.DD.justDragged = true;
6382
+ Global_1.Konva._mouseListenClick = false;
6383
+ Global_1.Konva._touchListenClick = false;
6384
+ Global_1.Konva._pointerListenClick = false;
6385
+ elem.dragStatus = 'stopped';
6386
+ }
6387
+ const drawNode = elem.node.getLayer() ||
6388
+ (elem.node instanceof Global_1.Konva['Stage'] && elem.node);
6389
+ if (drawNode && drawNodes.indexOf(drawNode) === -1) {
6390
+ drawNodes.push(drawNode);
6391
+ }
6392
+ });
6393
+ drawNodes.forEach((drawNode) => {
6394
+ drawNode.draw();
6395
+ });
6396
+ },
6397
+ _endDragAfter(evt) {
6398
+ exports.DD._dragElements.forEach((elem, key) => {
6399
+ if (elem.dragStatus === 'stopped') {
6400
+ elem.node.fire('dragend', {
6401
+ type: 'dragend',
6402
+ target: elem.node,
6403
+ evt: evt,
6404
+ }, true);
6405
+ }
6406
+ if (elem.dragStatus !== 'dragging') {
6407
+ exports.DD._dragElements.delete(key);
6408
+ }
6409
+ });
6410
+ },
6411
+ };
6412
+ if (Global_1.Konva.isBrowser) {
6413
+ window.addEventListener('mouseup', exports.DD._endDragBefore, true);
6414
+ window.addEventListener('touchend', exports.DD._endDragBefore, true);
6415
+ window.addEventListener('touchcancel', exports.DD._endDragBefore, true);
6416
+ window.addEventListener('mousemove', exports.DD._drag);
6417
+ window.addEventListener('touchmove', exports.DD._drag);
6418
+ window.addEventListener('mouseup', exports.DD._endDragAfter, false);
6419
+ window.addEventListener('touchend', exports.DD._endDragAfter, false);
6420
+ window.addEventListener('touchcancel', exports.DD._endDragAfter, false);
6421
+ }
6422
+ } (DragAndDrop));
6423
+ return DragAndDrop;
6424
+ }
6425
+
6426
+ var Factory = {};
6427
+
6428
+ var Validators = {};
6429
+
6430
+ var hasRequiredValidators;
6431
+
6432
+ function requireValidators () {
6433
+ if (hasRequiredValidators) return Validators;
6434
+ hasRequiredValidators = 1;
6435
+ Object.defineProperty(Validators, "__esModule", { value: true });
6436
+ Validators.RGBComponent = RGBComponent;
6437
+ Validators.alphaComponent = alphaComponent;
6438
+ Validators.getNumberValidator = getNumberValidator;
6439
+ Validators.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
6440
+ Validators.getNumberOrAutoValidator = getNumberOrAutoValidator;
6441
+ Validators.getStringValidator = getStringValidator;
6442
+ Validators.getStringOrGradientValidator = getStringOrGradientValidator;
6443
+ Validators.getFunctionValidator = getFunctionValidator;
6444
+ Validators.getNumberArrayValidator = getNumberArrayValidator;
6445
+ Validators.getBooleanValidator = getBooleanValidator;
6446
+ Validators.getComponentValidator = getComponentValidator;
6447
+ const Global_1 = requireGlobal();
6448
+ const Util_1 = requireUtil();
6449
+ function _formatValue(val) {
6450
+ if (Util_1.Util._isString(val)) {
6451
+ return '"' + val + '"';
6390
6452
  }
6391
- _fill(shape) {
6392
- const hasColor = shape.fill(), fillPriority = shape.getFillPriority();
6393
- if (hasColor && fillPriority === 'color') {
6394
- this._fillColor(shape);
6395
- return;
6396
- }
6397
- const hasPattern = shape.getFillPatternImage();
6398
- if (hasPattern && fillPriority === 'pattern') {
6399
- this._fillPattern(shape);
6400
- return;
6401
- }
6402
- const hasLinearGradient = shape.getFillLinearGradientColorStops();
6403
- if (hasLinearGradient && fillPriority === 'linear-gradient') {
6404
- this._fillLinearGradient(shape);
6405
- return;
6406
- }
6407
- const hasRadialGradient = shape.getFillRadialGradientColorStops();
6408
- if (hasRadialGradient && fillPriority === 'radial-gradient') {
6409
- this._fillRadialGradient(shape);
6410
- return;
6411
- }
6412
- if (hasColor) {
6413
- this._fillColor(shape);
6414
- }
6415
- else if (hasPattern) {
6416
- this._fillPattern(shape);
6417
- }
6418
- else if (hasLinearGradient) {
6419
- this._fillLinearGradient(shape);
6420
- }
6421
- else if (hasRadialGradient) {
6422
- this._fillRadialGradient(shape);
6423
- }
6453
+ if (Object.prototype.toString.call(val) === '[object Number]') {
6454
+ return val;
6424
6455
  }
6425
- _strokeLinearGradient(shape) {
6426
- const start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
6427
- if (colorStops) {
6428
- for (let n = 0; n < colorStops.length; n += 2) {
6429
- grd.addColorStop(colorStops[n], colorStops[n + 1]);
6430
- }
6431
- this.setAttr('strokeStyle', grd);
6432
- }
6456
+ if (Util_1.Util._isBoolean(val)) {
6457
+ return val;
6433
6458
  }
6434
- _stroke(shape) {
6435
- const dash = shape.dash(), strokeScaleEnabled = shape.getStrokeScaleEnabled();
6436
- if (shape.hasStroke()) {
6437
- if (!strokeScaleEnabled) {
6438
- this.save();
6439
- const pixelRatio = this.getCanvas().getPixelRatio();
6440
- this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
6441
- }
6442
- this._applyLineCap(shape);
6443
- if (dash && shape.dashEnabled()) {
6444
- this.setLineDash(dash);
6445
- this.setAttr('lineDashOffset', shape.dashOffset());
6446
- }
6447
- this.setAttr('lineWidth', shape.strokeWidth());
6448
- if (!shape.getShadowForStrokeEnabled()) {
6449
- this.setAttr('shadowColor', 'rgba(0,0,0,0)');
6450
- }
6451
- const hasLinearGradient = shape.getStrokeLinearGradientColorStops();
6452
- if (hasLinearGradient) {
6453
- this._strokeLinearGradient(shape);
6454
- }
6455
- else {
6456
- this.setAttr('strokeStyle', shape.stroke());
6457
- }
6458
- shape._strokeFunc(this);
6459
- if (!strokeScaleEnabled) {
6460
- this.restore();
6461
- }
6462
- }
6459
+ return Object.prototype.toString.call(val);
6460
+ }
6461
+ function RGBComponent(val) {
6462
+ if (val > 255) {
6463
+ return 255;
6463
6464
  }
6464
- _applyShadow(shape) {
6465
- var _a, _b, _c;
6466
- const color = (_a = shape.getShadowRGBA()) !== null && _a !== undefined ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== undefined ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== undefined ? _c : {
6467
- x: 0,
6468
- y: 0,
6469
- }, scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;
6470
- this.setAttr('shadowColor', color);
6471
- this.setAttr('shadowBlur', blur * Math.min(Math.abs(scaleX), Math.abs(scaleY)));
6472
- this.setAttr('shadowOffsetX', offset.x * scaleX);
6473
- this.setAttr('shadowOffsetY', offset.y * scaleY);
6465
+ else if (val < 0) {
6466
+ return 0;
6474
6467
  }
6468
+ return Math.round(val);
6475
6469
  }
6476
- Context.SceneContext = SceneContext;
6477
- class HitContext extends Context$1 {
6478
- constructor(canvas) {
6479
- super(canvas);
6480
- this._context = canvas._canvas.getContext('2d', {
6481
- willReadFrequently: true,
6482
- });
6483
- }
6484
- _fill(shape) {
6485
- this.save();
6486
- this.setAttr('fillStyle', shape.colorKey);
6487
- shape._fillFuncHit(this);
6488
- this.restore();
6470
+ function alphaComponent(val) {
6471
+ if (val > 1) {
6472
+ return 1;
6489
6473
  }
6490
- strokeShape(shape) {
6491
- if (shape.hasHitStroke()) {
6492
- this._stroke(shape);
6493
- }
6474
+ else if (val < 0.0001) {
6475
+ return 0.0001;
6494
6476
  }
6495
- _stroke(shape) {
6496
- if (shape.hasHitStroke()) {
6497
- const strokeScaleEnabled = shape.getStrokeScaleEnabled();
6498
- if (!strokeScaleEnabled) {
6499
- this.save();
6500
- const pixelRatio = this.getCanvas().getPixelRatio();
6501
- this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
6502
- }
6503
- this._applyLineCap(shape);
6504
- const hitStrokeWidth = shape.hitStrokeWidth();
6505
- const strokeWidth = hitStrokeWidth === 'auto' ? shape.strokeWidth() : hitStrokeWidth;
6506
- this.setAttr('lineWidth', strokeWidth);
6507
- this.setAttr('strokeStyle', shape.colorKey);
6508
- shape._strokeFuncHit(this);
6509
- if (!strokeScaleEnabled) {
6510
- this.restore();
6477
+ return val;
6478
+ }
6479
+ function getNumberValidator() {
6480
+ if (Global_1.Konva.isUnminified) {
6481
+ return function (val, attr) {
6482
+ if (!Util_1.Util._isNumber(val)) {
6483
+ Util_1.Util.warn(_formatValue(val) +
6484
+ ' is a not valid value for "' +
6485
+ attr +
6486
+ '" attribute. The value should be a number.');
6511
6487
  }
6512
- }
6488
+ return val;
6489
+ };
6513
6490
  }
6514
6491
  }
6515
- Context.HitContext = HitContext;
6516
- return Context;
6517
- }
6518
-
6519
- var hasRequiredCanvas;
6520
-
6521
- function requireCanvas () {
6522
- if (hasRequiredCanvas) return Canvas;
6523
- hasRequiredCanvas = 1;
6524
- Object.defineProperty(Canvas, "__esModule", { value: true });
6525
- Canvas.HitCanvas = Canvas.SceneCanvas = Canvas.Canvas = undefined;
6526
- const Util_1 = requireUtil();
6527
- const Context_1 = requireContext();
6528
- const Global_1 = requireGlobal();
6529
- const Factory_1 = requireFactory();
6530
- const Validators_1 = requireValidators();
6531
- let _pixelRatio;
6532
- function getDevicePixelRatio() {
6533
- if (_pixelRatio) {
6534
- return _pixelRatio;
6492
+ function getNumberOrArrayOfNumbersValidator(noOfElements) {
6493
+ if (Global_1.Konva.isUnminified) {
6494
+ return function (val, attr) {
6495
+ let isNumber = Util_1.Util._isNumber(val);
6496
+ let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
6497
+ if (!isNumber && !isValidArray) {
6498
+ Util_1.Util.warn(_formatValue(val) +
6499
+ ' is a not valid value for "' +
6500
+ attr +
6501
+ '" attribute. The value should be a number or Array<number>(' +
6502
+ noOfElements +
6503
+ ')');
6504
+ }
6505
+ return val;
6506
+ };
6535
6507
  }
6536
- const canvas = Util_1.Util.createCanvasElement();
6537
- const context = canvas.getContext('2d');
6538
- _pixelRatio = (function () {
6539
- const devicePixelRatio = Global_1.Konva._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||
6540
- context.mozBackingStorePixelRatio ||
6541
- context.msBackingStorePixelRatio ||
6542
- context.oBackingStorePixelRatio ||
6543
- context.backingStorePixelRatio ||
6544
- 1;
6545
- return devicePixelRatio / backingStoreRatio;
6546
- })();
6547
- Util_1.Util.releaseCanvas(canvas);
6548
- return _pixelRatio;
6549
6508
  }
6550
- let Canvas$1 = class Canvas {
6551
- constructor(config) {
6552
- this.pixelRatio = 1;
6553
- this.width = 0;
6554
- this.height = 0;
6555
- this.isCache = false;
6556
- const conf = config || {};
6557
- const pixelRatio = conf.pixelRatio || Global_1.Konva.pixelRatio || getDevicePixelRatio();
6558
- this.pixelRatio = pixelRatio;
6559
- this._canvas = Util_1.Util.createCanvasElement();
6560
- this._canvas.style.padding = '0';
6561
- this._canvas.style.margin = '0';
6562
- this._canvas.style.border = '0';
6563
- this._canvas.style.background = 'transparent';
6564
- this._canvas.style.position = 'absolute';
6565
- this._canvas.style.top = '0';
6566
- this._canvas.style.left = '0';
6567
- }
6568
- getContext() {
6569
- return this.context;
6570
- }
6571
- getPixelRatio() {
6572
- return this.pixelRatio;
6573
- }
6574
- setPixelRatio(pixelRatio) {
6575
- const previousRatio = this.pixelRatio;
6576
- this.pixelRatio = pixelRatio;
6577
- this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);
6578
- }
6579
- setWidth(width) {
6580
- this.width = this._canvas.width = width * this.pixelRatio;
6581
- this._canvas.style.width = width + 'px';
6582
- const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
6583
- _context.scale(pixelRatio, pixelRatio);
6584
- }
6585
- setHeight(height) {
6586
- this.height = this._canvas.height = height * this.pixelRatio;
6587
- this._canvas.style.height = height + 'px';
6588
- const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
6589
- _context.scale(pixelRatio, pixelRatio);
6509
+ function getNumberOrAutoValidator() {
6510
+ if (Global_1.Konva.isUnminified) {
6511
+ return function (val, attr) {
6512
+ const isNumber = Util_1.Util._isNumber(val);
6513
+ const isAuto = val === 'auto';
6514
+ if (!(isNumber || isAuto)) {
6515
+ Util_1.Util.warn(_formatValue(val) +
6516
+ ' is a not valid value for "' +
6517
+ attr +
6518
+ '" attribute. The value should be a number or "auto".');
6519
+ }
6520
+ return val;
6521
+ };
6590
6522
  }
6591
- getWidth() {
6592
- return this.width;
6523
+ }
6524
+ function getStringValidator() {
6525
+ if (Global_1.Konva.isUnminified) {
6526
+ return function (val, attr) {
6527
+ if (!Util_1.Util._isString(val)) {
6528
+ Util_1.Util.warn(_formatValue(val) +
6529
+ ' is a not valid value for "' +
6530
+ attr +
6531
+ '" attribute. The value should be a string.');
6532
+ }
6533
+ return val;
6534
+ };
6593
6535
  }
6594
- getHeight() {
6595
- return this.height;
6536
+ }
6537
+ function getStringOrGradientValidator() {
6538
+ if (Global_1.Konva.isUnminified) {
6539
+ return function (val, attr) {
6540
+ const isString = Util_1.Util._isString(val);
6541
+ const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
6542
+ (val && val['addColorStop']);
6543
+ if (!(isString || isGradient)) {
6544
+ Util_1.Util.warn(_formatValue(val) +
6545
+ ' is a not valid value for "' +
6546
+ attr +
6547
+ '" attribute. The value should be a string or a native gradient.');
6548
+ }
6549
+ return val;
6550
+ };
6596
6551
  }
6597
- setSize(width, height) {
6598
- this.setWidth(width || 0);
6599
- this.setHeight(height || 0);
6552
+ }
6553
+ function getFunctionValidator() {
6554
+ if (Global_1.Konva.isUnminified) {
6555
+ return function (val, attr) {
6556
+ if (!Util_1.Util._isFunction(val)) {
6557
+ Util_1.Util.warn(_formatValue(val) +
6558
+ ' is a not valid value for "' +
6559
+ attr +
6560
+ '" attribute. The value should be a function.');
6561
+ }
6562
+ return val;
6563
+ };
6600
6564
  }
6601
- toDataURL(mimeType, quality) {
6602
- try {
6603
- return this._canvas.toDataURL(mimeType, quality);
6604
- }
6605
- catch (e) {
6606
- try {
6607
- return this._canvas.toDataURL();
6565
+ }
6566
+ function getNumberArrayValidator() {
6567
+ if (Global_1.Konva.isUnminified) {
6568
+ return function (val, attr) {
6569
+ const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
6570
+ if (TypedArray && val instanceof TypedArray) {
6571
+ return val;
6608
6572
  }
6609
- catch (err) {
6610
- Util_1.Util.error('Unable to get data URL. ' +
6611
- err.message +
6612
- ' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');
6613
- return '';
6573
+ if (!Util_1.Util._isArray(val)) {
6574
+ Util_1.Util.warn(_formatValue(val) +
6575
+ ' is a not valid value for "' +
6576
+ attr +
6577
+ '" attribute. The value should be a array of numbers.');
6614
6578
  }
6615
- }
6579
+ else {
6580
+ val.forEach(function (item) {
6581
+ if (!Util_1.Util._isNumber(item)) {
6582
+ Util_1.Util.warn('"' +
6583
+ attr +
6584
+ '" attribute has non numeric element ' +
6585
+ item +
6586
+ '. Make sure that all elements are numbers.');
6587
+ }
6588
+ });
6589
+ }
6590
+ return val;
6591
+ };
6616
6592
  }
6617
- };
6618
- Canvas.Canvas = Canvas$1;
6619
- Factory_1.Factory.addGetterSetter(Canvas$1, 'pixelRatio', undefined, (0, Validators_1.getNumberValidator)());
6620
- class SceneCanvas extends Canvas$1 {
6621
- constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
6622
- super(config);
6623
- this.context = new Context_1.SceneContext(this, {
6624
- willReadFrequently: config.willReadFrequently,
6625
- });
6626
- this.setSize(config.width, config.height);
6593
+ }
6594
+ function getBooleanValidator() {
6595
+ if (Global_1.Konva.isUnminified) {
6596
+ return function (val, attr) {
6597
+ const isBool = val === true || val === false;
6598
+ if (!isBool) {
6599
+ Util_1.Util.warn(_formatValue(val) +
6600
+ ' is a not valid value for "' +
6601
+ attr +
6602
+ '" attribute. The value should be a boolean.');
6603
+ }
6604
+ return val;
6605
+ };
6627
6606
  }
6628
6607
  }
6629
- Canvas.SceneCanvas = SceneCanvas;
6630
- class HitCanvas extends Canvas$1 {
6631
- constructor(config = { width: 0, height: 0 }) {
6632
- super(config);
6633
- this.hitCanvas = true;
6634
- this.context = new Context_1.HitContext(this);
6635
- this.setSize(config.width, config.height);
6608
+ function getComponentValidator(components) {
6609
+ if (Global_1.Konva.isUnminified) {
6610
+ return function (val, attr) {
6611
+ if (val === undefined || val === null) {
6612
+ return val;
6613
+ }
6614
+ if (!Util_1.Util.isObject(val)) {
6615
+ Util_1.Util.warn(_formatValue(val) +
6616
+ ' is a not valid value for "' +
6617
+ attr +
6618
+ '" attribute. The value should be an object with properties ' +
6619
+ components);
6620
+ }
6621
+ return val;
6622
+ };
6636
6623
  }
6637
6624
  }
6638
- Canvas.HitCanvas = HitCanvas;
6639
- return Canvas;
6625
+ return Validators;
6640
6626
  }
6641
6627
 
6642
- var DragAndDrop = {};
6643
-
6644
- var hasRequiredDragAndDrop;
6628
+ var hasRequiredFactory;
6645
6629
 
6646
- function requireDragAndDrop () {
6647
- if (hasRequiredDragAndDrop) return DragAndDrop;
6648
- hasRequiredDragAndDrop = 1;
6630
+ function requireFactory () {
6631
+ if (hasRequiredFactory) return Factory;
6632
+ hasRequiredFactory = 1;
6649
6633
  (function (exports) {
6650
6634
  Object.defineProperty(exports, "__esModule", { value: true });
6651
- exports.DD = undefined;
6652
- const Global_1 = requireGlobal();
6635
+ exports.Factory = void 0;
6653
6636
  const Util_1 = requireUtil();
6654
- exports.DD = {
6655
- get isDragging() {
6656
- let flag = false;
6657
- exports.DD._dragElements.forEach((elem) => {
6658
- if (elem.dragStatus === 'dragging') {
6659
- flag = true;
6660
- }
6661
- });
6662
- return flag;
6637
+ const Validators_1 = requireValidators();
6638
+ const GET = 'get';
6639
+ const SET = 'set';
6640
+ exports.Factory = {
6641
+ addGetterSetter(constructor, attr, def, validator, after) {
6642
+ exports.Factory.addGetter(constructor, attr, def);
6643
+ exports.Factory.addSetter(constructor, attr, validator, after);
6644
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
6663
6645
  },
6664
- justDragged: false,
6665
- get node() {
6666
- let node;
6667
- exports.DD._dragElements.forEach((elem) => {
6668
- node = elem.node;
6669
- });
6670
- return node;
6646
+ addGetter(constructor, attr, def) {
6647
+ const method = GET + Util_1.Util._capitalize(attr);
6648
+ constructor.prototype[method] =
6649
+ constructor.prototype[method] ||
6650
+ function () {
6651
+ const val = this.attrs[attr];
6652
+ return val === undefined ? def : val;
6653
+ };
6671
6654
  },
6672
- _dragElements: new Map(),
6673
- _drag(evt) {
6674
- const nodesToFireEvents = [];
6675
- exports.DD._dragElements.forEach((elem, key) => {
6676
- const { node } = elem;
6677
- const stage = node.getStage();
6678
- stage.setPointersPositions(evt);
6679
- if (elem.pointerId === undefined) {
6680
- elem.pointerId = Util_1.Util._getFirstPointerId(evt);
6681
- }
6682
- const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
6683
- if (!pos) {
6684
- return;
6655
+ addSetter(constructor, attr, validator, after) {
6656
+ const method = SET + Util_1.Util._capitalize(attr);
6657
+ if (!constructor.prototype[method]) {
6658
+ exports.Factory.overWriteSetter(constructor, attr, validator, after);
6659
+ }
6660
+ },
6661
+ overWriteSetter(constructor, attr, validator, after) {
6662
+ const method = SET + Util_1.Util._capitalize(attr);
6663
+ constructor.prototype[method] = function (val) {
6664
+ if (validator && val !== undefined && val !== null) {
6665
+ val = validator.call(this, val, attr);
6685
6666
  }
6686
- if (elem.dragStatus !== 'dragging') {
6687
- const dragDistance = node.dragDistance();
6688
- const distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));
6689
- if (distance < dragDistance) {
6690
- return;
6691
- }
6692
- node.startDrag({ evt });
6693
- if (!node.isDragging()) {
6694
- return;
6695
- }
6667
+ this._setAttr(attr, val);
6668
+ if (after) {
6669
+ after.call(this);
6696
6670
  }
6697
- node._setDragPosition(evt, elem);
6698
- nodesToFireEvents.push(node);
6699
- });
6700
- nodesToFireEvents.forEach((node) => {
6701
- node.fire('dragmove', {
6702
- type: 'dragmove',
6703
- target: node,
6704
- evt: evt,
6705
- }, true);
6706
- });
6671
+ return this;
6672
+ };
6707
6673
  },
6708
- _endDragBefore(evt) {
6709
- const drawNodes = [];
6710
- exports.DD._dragElements.forEach((elem) => {
6711
- const { node } = elem;
6712
- const stage = node.getStage();
6713
- if (evt) {
6714
- stage.setPointersPositions(evt);
6674
+ addComponentsGetterSetter(constructor, attr, components, validator, after) {
6675
+ const len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr);
6676
+ constructor.prototype[getter] = function () {
6677
+ const ret = {};
6678
+ for (let n = 0; n < len; n++) {
6679
+ const component = components[n];
6680
+ ret[component] = this.getAttr(attr + capitalize(component));
6715
6681
  }
6716
- const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
6717
- if (!pos) {
6718
- return;
6682
+ return ret;
6683
+ };
6684
+ const basicValidator = (0, Validators_1.getComponentValidator)(components);
6685
+ constructor.prototype[setter] = function (val) {
6686
+ const oldVal = this.attrs[attr];
6687
+ if (validator) {
6688
+ val = validator.call(this, val, attr);
6719
6689
  }
6720
- if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {
6721
- exports.DD.justDragged = true;
6722
- Global_1.Konva._mouseListenClick = false;
6723
- Global_1.Konva._touchListenClick = false;
6724
- Global_1.Konva._pointerListenClick = false;
6725
- elem.dragStatus = 'stopped';
6690
+ if (basicValidator) {
6691
+ basicValidator.call(this, val, attr);
6692
+ }
6693
+ for (const key in val) {
6694
+ if (!val.hasOwnProperty(key)) {
6695
+ continue;
6696
+ }
6697
+ this._setAttr(attr + capitalize(key), val[key]);
6698
+ }
6699
+ if (!val) {
6700
+ components.forEach((component) => {
6701
+ this._setAttr(attr + capitalize(component), undefined);
6702
+ });
6726
6703
  }
6727
- const drawNode = elem.node.getLayer() ||
6728
- (elem.node instanceof Global_1.Konva['Stage'] && elem.node);
6729
- if (drawNode && drawNodes.indexOf(drawNode) === -1) {
6730
- drawNodes.push(drawNode);
6704
+ this._fireChangeEvent(attr, oldVal, val);
6705
+ if (after) {
6706
+ after.call(this);
6731
6707
  }
6732
- });
6733
- drawNodes.forEach((drawNode) => {
6734
- drawNode.draw();
6735
- });
6708
+ return this;
6709
+ };
6710
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
6736
6711
  },
6737
- _endDragAfter(evt) {
6738
- exports.DD._dragElements.forEach((elem, key) => {
6739
- if (elem.dragStatus === 'stopped') {
6740
- elem.node.fire('dragend', {
6741
- type: 'dragend',
6742
- target: elem.node,
6743
- evt: evt,
6744
- }, true);
6712
+ addOverloadedGetterSetter(constructor, attr) {
6713
+ const capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;
6714
+ constructor.prototype[attr] = function () {
6715
+ if (arguments.length) {
6716
+ this[setter](arguments[0]);
6717
+ return this;
6745
6718
  }
6746
- if (elem.dragStatus !== 'dragging') {
6747
- exports.DD._dragElements.delete(key);
6719
+ return this[getter]();
6720
+ };
6721
+ },
6722
+ addDeprecatedGetterSetter(constructor, attr, def, validator) {
6723
+ Util_1.Util.error('Adding deprecated ' + attr);
6724
+ const method = GET + Util_1.Util._capitalize(attr);
6725
+ const message = attr +
6726
+ ' property is deprecated and will be removed soon. Look at Konva change log for more information.';
6727
+ constructor.prototype[method] = function () {
6728
+ Util_1.Util.error(message);
6729
+ const val = this.attrs[attr];
6730
+ return val === undefined ? def : val;
6731
+ };
6732
+ exports.Factory.addSetter(constructor, attr, validator, function () {
6733
+ Util_1.Util.error(message);
6734
+ });
6735
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
6736
+ },
6737
+ backCompat(constructor, methods) {
6738
+ Util_1.Util.each(methods, function (oldMethodName, newMethodName) {
6739
+ const method = constructor.prototype[newMethodName];
6740
+ const oldGetter = GET + Util_1.Util._capitalize(oldMethodName);
6741
+ const oldSetter = SET + Util_1.Util._capitalize(oldMethodName);
6742
+ function deprecated() {
6743
+ method.apply(this, arguments);
6744
+ Util_1.Util.error('"' +
6745
+ oldMethodName +
6746
+ '" method is deprecated and will be removed soon. Use ""' +
6747
+ newMethodName +
6748
+ '" instead.');
6748
6749
  }
6750
+ constructor.prototype[oldMethodName] = deprecated;
6751
+ constructor.prototype[oldGetter] = deprecated;
6752
+ constructor.prototype[oldSetter] = deprecated;
6749
6753
  });
6750
6754
  },
6751
- };
6752
- if (Global_1.Konva.isBrowser) {
6753
- window.addEventListener('mouseup', exports.DD._endDragBefore, true);
6754
- window.addEventListener('touchend', exports.DD._endDragBefore, true);
6755
- window.addEventListener('touchcancel', exports.DD._endDragBefore, true);
6756
- window.addEventListener('mousemove', exports.DD._drag);
6757
- window.addEventListener('touchmove', exports.DD._drag);
6758
- window.addEventListener('mouseup', exports.DD._endDragAfter, false);
6759
- window.addEventListener('touchend', exports.DD._endDragAfter, false);
6760
- window.addEventListener('touchcancel', exports.DD._endDragAfter, false);
6761
- }
6762
- } (DragAndDrop));
6763
- return DragAndDrop;
6755
+ afterSetFilter() {
6756
+ this._filterUpToDate = false;
6757
+ },
6758
+ };
6759
+ } (Factory));
6760
+ return Factory;
6764
6761
  }
6765
6762
 
6766
6763
  var hasRequiredNode;
@@ -6769,14 +6766,14 @@
6769
6766
  if (hasRequiredNode) return Node;
6770
6767
  hasRequiredNode = 1;
6771
6768
  Object.defineProperty(Node, "__esModule", { value: true });
6772
- Node.Node = undefined;
6773
- const Util_1 = requireUtil();
6774
- const Factory_1 = requireFactory();
6769
+ Node.Node = void 0;
6775
6770
  const Canvas_1 = requireCanvas();
6776
- const Global_1 = requireGlobal();
6777
6771
  const DragAndDrop_1 = requireDragAndDrop();
6772
+ const Factory_1 = requireFactory();
6773
+ const Global_1 = requireGlobal();
6774
+ const Util_1 = requireUtil();
6778
6775
  const Validators_1 = requireValidators();
6779
- const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
6776
+ const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', POINTERENTER = 'pointerenter', POINTERLEAVE = 'pointerleave', TOUCHENTER = 'touchenter', TOUCHLEAVE = 'touchleave', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
6780
6777
  'xChange.konva',
6781
6778
  'yChange.konva',
6782
6779
  'scaleXChange.konva',
@@ -6855,8 +6852,8 @@
6855
6852
  }
6856
6853
  clearCache() {
6857
6854
  if (this._cache.has(CANVAS)) {
6858
- const { scene, filter, hit } = this._cache.get(CANVAS);
6859
- Util_1.Util.releaseCanvas(scene, filter, hit);
6855
+ const { scene, filter, hit, buffer } = this._cache.get(CANVAS);
6856
+ Util_1.Util.releaseCanvas(scene, filter, hit, buffer);
6860
6857
  this._cache.delete(CANVAS);
6861
6858
  }
6862
6859
  this._clearSelfAndDescendantCache();
@@ -6900,6 +6897,11 @@
6900
6897
  width: width,
6901
6898
  height: height,
6902
6899
  }), sceneContext = cachedSceneCanvas.getContext(), hitContext = cachedHitCanvas.getContext();
6900
+ const bufferCanvas = new Canvas_1.SceneCanvas({
6901
+ width: cachedSceneCanvas.width / cachedSceneCanvas.pixelRatio + Math.abs(x),
6902
+ height: cachedSceneCanvas.height / cachedSceneCanvas.pixelRatio + Math.abs(y),
6903
+ pixelRatio: cachedSceneCanvas.pixelRatio,
6904
+ }), bufferContext = bufferCanvas.getContext();
6903
6905
  cachedHitCanvas.isCache = true;
6904
6906
  cachedSceneCanvas.isCache = true;
6905
6907
  this._cache.delete(CANVAS);
@@ -6910,12 +6912,16 @@
6910
6912
  }
6911
6913
  sceneContext.save();
6912
6914
  hitContext.save();
6915
+ bufferContext.save();
6913
6916
  sceneContext.translate(-x, -y);
6914
6917
  hitContext.translate(-x, -y);
6918
+ bufferContext.translate(-x, -y);
6919
+ bufferCanvas.x = x;
6920
+ bufferCanvas.y = y;
6915
6921
  this._isUnderCache = true;
6916
6922
  this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
6917
6923
  this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);
6918
- this.drawScene(cachedSceneCanvas, this);
6924
+ this.drawScene(cachedSceneCanvas, this, bufferCanvas);
6919
6925
  this.drawHit(cachedHitCanvas, this);
6920
6926
  this._isUnderCache = false;
6921
6927
  sceneContext.restore();
@@ -6934,6 +6940,7 @@
6934
6940
  scene: cachedSceneCanvas,
6935
6941
  filter: cachedFilterCanvas,
6936
6942
  hit: cachedHitCanvas,
6943
+ buffer: bufferCanvas,
6937
6944
  x: x,
6938
6945
  y: y,
6939
6946
  });
@@ -7026,23 +7033,22 @@
7026
7033
  return sceneCanvas;
7027
7034
  }
7028
7035
  on(evtStr, handler) {
7029
- this._cache && this._cache.delete(ALL_LISTENERS);
7036
+ if (this._cache) {
7037
+ this._cache.delete(ALL_LISTENERS);
7038
+ }
7030
7039
  if (arguments.length === 3) {
7031
7040
  return this._delegate.apply(this, arguments);
7032
7041
  }
7033
- let events = evtStr.split(SPACE), len = events.length, n, event, parts, baseEvent, name;
7034
- for (n = 0; n < len; n++) {
7035
- event = events[n];
7036
- parts = event.split('.');
7037
- baseEvent = parts[0];
7038
- name = parts[1] || '';
7042
+ const events = evtStr.split(SPACE);
7043
+ for (let n = 0; n < events.length; n++) {
7044
+ const event = events[n];
7045
+ const parts = event.split('.');
7046
+ const baseEvent = parts[0];
7047
+ const name = parts[1] || '';
7039
7048
  if (!this.eventListeners[baseEvent]) {
7040
7049
  this.eventListeners[baseEvent] = [];
7041
7050
  }
7042
- this.eventListeners[baseEvent].push({
7043
- name: name,
7044
- handler: handler,
7045
- });
7051
+ this.eventListeners[baseEvent].push({ name, handler });
7046
7052
  }
7047
7053
  return this;
7048
7054
  }
@@ -7674,7 +7680,7 @@
7674
7680
  var _a, _b;
7675
7681
  const m = this._cache.get(TRANSFORM) || new Util_1.Transform();
7676
7682
  m.reset();
7677
- const x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== undefined ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== undefined ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
7683
+ const x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
7678
7684
  if (x !== 0 || y !== 0) {
7679
7685
  m.translate(x, y);
7680
7686
  }
@@ -7876,7 +7882,7 @@
7876
7882
  _requestDraw() {
7877
7883
  if (Global_1.Konva.autoDrawEnabled) {
7878
7884
  const drawNode = this.getLayer() || this.getStage();
7879
- drawNode === null || drawNode === undefined ? undefined : drawNode.batchDraw();
7885
+ drawNode === null || drawNode === void 0 ? void 0 : drawNode.batchDraw();
7880
7886
  }
7881
7887
  }
7882
7888
  _setAttr(key, val) {
@@ -7910,14 +7916,22 @@
7910
7916
  if (evt && this.nodeType === SHAPE) {
7911
7917
  evt.target = this;
7912
7918
  }
7913
- const shouldStop = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
7919
+ const nonBubbling = [
7920
+ MOUSEENTER,
7921
+ MOUSELEAVE,
7922
+ POINTERENTER,
7923
+ POINTERLEAVE,
7924
+ TOUCHENTER,
7925
+ TOUCHLEAVE,
7926
+ ];
7927
+ const shouldStop = nonBubbling.indexOf(eventType) !== -1 &&
7914
7928
  ((compareShape &&
7915
7929
  (this === compareShape ||
7916
7930
  (this.isAncestorOf && this.isAncestorOf(compareShape)))) ||
7917
7931
  (this.nodeType === 'Stage' && !compareShape));
7918
7932
  if (!shouldStop) {
7919
7933
  this._fire(eventType, evt);
7920
- const stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
7934
+ const stopBubble = nonBubbling.indexOf(eventType) !== -1 &&
7921
7935
  compareShape &&
7922
7936
  compareShape.isAncestorOf &&
7923
7937
  compareShape.isAncestorOf(this) &&
@@ -7937,13 +7951,13 @@
7937
7951
  }
7938
7952
  _getProtoListeners(eventType) {
7939
7953
  var _a, _b, _c;
7940
- const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !== undefined ? _a : {};
7941
- let events = allListeners === null || allListeners === undefined ? undefined : allListeners[eventType];
7954
+ const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !== void 0 ? _a : {};
7955
+ let events = allListeners === null || allListeners === void 0 ? void 0 : allListeners[eventType];
7942
7956
  if (events === undefined) {
7943
7957
  events = [];
7944
7958
  let obj = Object.getPrototypeOf(this);
7945
7959
  while (obj) {
7946
- const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b === undefined ? undefined : _b[eventType]) !== null && _c !== undefined ? _c : [];
7960
+ const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b === void 0 ? void 0 : _b[eventType]) !== null && _c !== void 0 ? _c : [];
7947
7961
  events.push(...hierarchyEvents);
7948
7962
  obj = Object.getPrototypeOf(obj);
7949
7963
  }
@@ -7958,13 +7972,13 @@
7958
7972
  evt.type = eventType;
7959
7973
  const topListeners = this._getProtoListeners(eventType);
7960
7974
  if (topListeners) {
7961
- for (var i = 0; i < topListeners.length; i++) {
7975
+ for (let i = 0; i < topListeners.length; i++) {
7962
7976
  topListeners[i].handler.call(this, evt);
7963
7977
  }
7964
7978
  }
7965
7979
  const selfListeners = this.eventListeners[eventType];
7966
7980
  if (selfListeners) {
7967
- for (var i = 0; i < selfListeners.length; i++) {
7981
+ for (let i = 0; i < selfListeners.length; i++) {
7968
7982
  selfListeners[i].handler.call(this, evt);
7969
7983
  }
7970
7984
  }
@@ -8209,7 +8223,7 @@
8209
8223
  if (hasRequiredContainer) return Container;
8210
8224
  hasRequiredContainer = 1;
8211
8225
  Object.defineProperty(Container, "__esModule", { value: true });
8212
- Container.Container = undefined;
8226
+ Container.Container = void 0;
8213
8227
  const Factory_1 = requireFactory();
8214
8228
  const Node_1 = requireNode();
8215
8229
  const Validators_1 = requireValidators();
@@ -8219,17 +8233,11 @@
8219
8233
  this.children = [];
8220
8234
  }
8221
8235
  getChildren(filterFunc) {
8222
- if (!filterFunc) {
8223
- return this.children || [];
8224
- }
8225
8236
  const children = this.children || [];
8226
- const results = [];
8227
- children.forEach(function (child) {
8228
- if (filterFunc(child)) {
8229
- results.push(child);
8230
- }
8231
- });
8232
- return results;
8237
+ if (filterFunc) {
8238
+ return children.filter(filterFunc);
8239
+ }
8240
+ return children;
8233
8241
  }
8234
8242
  hasChildren() {
8235
8243
  return this.getChildren().length > 0;
@@ -8366,13 +8374,13 @@
8366
8374
  if (this.isCached()) {
8367
8375
  return;
8368
8376
  }
8369
- (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (node) {
8377
+ (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {
8370
8378
  node._clearSelfAndDescendantCache(attr);
8371
8379
  });
8372
8380
  }
8373
8381
  _setChildrenIndices() {
8374
8382
  var _a;
8375
- (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child, n) {
8383
+ (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {
8376
8384
  child.index = n;
8377
8385
  });
8378
8386
  this._requestDraw();
@@ -8443,7 +8451,7 @@
8443
8451
  context.save();
8444
8452
  context._applyGlobalCompositeOperation(this);
8445
8453
  }
8446
- (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child) {
8454
+ (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
8447
8455
  child[drawMethod](canvas, top, bufferCanvas);
8448
8456
  });
8449
8457
  if (hasComposition) {
@@ -8465,7 +8473,7 @@
8465
8473
  height: 0,
8466
8474
  };
8467
8475
  const that = this;
8468
- (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child) {
8476
+ (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
8469
8477
  if (!child.visible()) {
8470
8478
  return;
8471
8479
  }
@@ -8597,7 +8605,7 @@
8597
8605
  hasRequiredStage = 1;
8598
8606
  (function (exports) {
8599
8607
  Object.defineProperty(exports, "__esModule", { value: true });
8600
- exports.Stage = exports.stages = undefined;
8608
+ exports.Stage = exports.stages = void 0;
8601
8609
  const Util_1 = requireUtil();
8602
8610
  const Factory_1 = requireFactory();
8603
8611
  const Container_1 = requireContainer();
@@ -8623,6 +8631,7 @@
8623
8631
  [POINTERMOVE, '_pointermove'],
8624
8632
  [POINTERUP, '_pointerup'],
8625
8633
  [POINTERCANCEL, '_pointercancel'],
8634
+ [POINTERLEAVE, '_pointerleave'],
8626
8635
  [LOSTPOINTERCAPTURE, '_lostpointercapture'],
8627
8636
  ];
8628
8637
  const EVENTS_MAP = {
@@ -8724,12 +8733,12 @@
8724
8733
  }
8725
8734
  setContainer(container) {
8726
8735
  if (typeof container === STRING) {
8736
+ let id;
8727
8737
  if (container.charAt(0) === '.') {
8728
8738
  const className = container.slice(1);
8729
8739
  container = document.getElementsByClassName(className)[0];
8730
8740
  }
8731
8741
  else {
8732
- var id;
8733
8742
  if (container.charAt(0) !== '#') {
8734
8743
  id = container;
8735
8744
  }
@@ -9314,7 +9323,7 @@
9314
9323
  hasRequiredShape = 1;
9315
9324
  (function (exports) {
9316
9325
  Object.defineProperty(exports, "__esModule", { value: true });
9317
- exports.Shape = exports.shapes = undefined;
9326
+ exports.Shape = exports.shapes = void 0;
9318
9327
  const Global_1 = requireGlobal();
9319
9328
  const Util_1 = requireUtil();
9320
9329
  const Factory_1 = requireFactory();
@@ -9547,7 +9556,7 @@
9547
9556
  }
9548
9557
  _useBufferCanvas(forceFill) {
9549
9558
  var _a;
9550
- const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== undefined ? _a : true;
9559
+ const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
9551
9560
  if (!perfectDrawEnabled) {
9552
9561
  return false;
9553
9562
  }
@@ -9632,8 +9641,8 @@
9632
9641
  }
9633
9642
  drawScene(can, top, bufferCanvas) {
9634
9643
  const layer = this.getLayer();
9635
- let canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferContext;
9636
- const skipBuffer = canvas.isCache;
9644
+ const canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow();
9645
+ let stage;
9637
9646
  const cachingSelf = top === this;
9638
9647
  if (!this.isVisible() && !cachingSelf) {
9639
9648
  return this;
@@ -9650,14 +9659,14 @@
9650
9659
  return this;
9651
9660
  }
9652
9661
  context.save();
9653
- if (this._useBufferCanvas() && !skipBuffer) {
9662
+ if (this._useBufferCanvas() && true) {
9654
9663
  stage = this.getStage();
9655
9664
  const bc = bufferCanvas || stage.bufferCanvas;
9656
- bufferContext = bc.getContext();
9665
+ const bufferContext = bc.getContext();
9657
9666
  bufferContext.clear();
9658
9667
  bufferContext.save();
9659
9668
  bufferContext._applyLineJoin(this);
9660
- var o = this.getAbsoluteTransform(top).getMatrix();
9669
+ const o = this.getAbsoluteTransform(top).getMatrix();
9661
9670
  bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
9662
9671
  drawFunc.call(this, bufferContext, this);
9663
9672
  bufferContext.restore();
@@ -9667,12 +9676,12 @@
9667
9676
  }
9668
9677
  context._applyOpacity(this);
9669
9678
  context._applyGlobalCompositeOperation(this);
9670
- context.drawImage(bc._canvas, 0, 0, bc.width / ratio, bc.height / ratio);
9679
+ context.drawImage(bc._canvas, bc.x || 0, bc.y || 0, bc.width / ratio, bc.height / ratio);
9671
9680
  }
9672
9681
  else {
9673
9682
  context._applyLineJoin(this);
9674
9683
  if (!cachingSelf) {
9675
- var o = this.getAbsoluteTransform(top).getMatrix();
9684
+ const o = this.getAbsoluteTransform(top).getMatrix();
9676
9685
  context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
9677
9686
  context._applyOpacity(this);
9678
9687
  context._applyGlobalCompositeOperation(this);
@@ -9867,7 +9876,7 @@
9867
9876
  if (hasRequiredLayer) return Layer;
9868
9877
  hasRequiredLayer = 1;
9869
9878
  Object.defineProperty(Layer, "__esModule", { value: true });
9870
- Layer.Layer = undefined;
9879
+ Layer.Layer = void 0;
9871
9880
  const Util_1 = requireUtil();
9872
9881
  const Container_1 = requireContainer();
9873
9882
  const Node_1 = requireNode();
@@ -10112,7 +10121,7 @@
10112
10121
  }
10113
10122
  return {};
10114
10123
  }
10115
- drawScene(can, top) {
10124
+ drawScene(can, top, bufferCanvas) {
10116
10125
  const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());
10117
10126
  this._fire(BEFORE_DRAW, {
10118
10127
  node: this,
@@ -10120,7 +10129,7 @@
10120
10129
  if (this.clearBeforeDraw()) {
10121
10130
  canvas.getContext().clear();
10122
10131
  }
10123
- Container_1.Container.prototype.drawScene.call(this, canvas, top);
10132
+ Container_1.Container.prototype.drawScene.call(this, canvas, top, bufferCanvas);
10124
10133
  this._fire(DRAW, {
10125
10134
  node: this,
10126
10135
  });
@@ -10185,7 +10194,7 @@
10185
10194
  if (hasRequiredFastLayer) return FastLayer;
10186
10195
  hasRequiredFastLayer = 1;
10187
10196
  Object.defineProperty(FastLayer, "__esModule", { value: true });
10188
- FastLayer.FastLayer = undefined;
10197
+ FastLayer.FastLayer = void 0;
10189
10198
  const Util_1 = requireUtil();
10190
10199
  const Layer_1 = requireLayer();
10191
10200
  const Global_1 = requireGlobal();
@@ -10210,7 +10219,7 @@
10210
10219
  if (hasRequiredGroup) return Group;
10211
10220
  hasRequiredGroup = 1;
10212
10221
  Object.defineProperty(Group, "__esModule", { value: true });
10213
- Group.Group = undefined;
10222
+ Group.Group = void 0;
10214
10223
  const Util_1 = requireUtil();
10215
10224
  const Container_1 = requireContainer();
10216
10225
  const Global_1 = requireGlobal();
@@ -10236,7 +10245,7 @@
10236
10245
  if (hasRequiredAnimation) return Animation;
10237
10246
  hasRequiredAnimation = 1;
10238
10247
  Object.defineProperty(Animation, "__esModule", { value: true });
10239
- Animation.Animation = undefined;
10248
+ Animation.Animation = void 0;
10240
10249
  const Global_1 = requireGlobal();
10241
10250
  const Util_1 = requireUtil();
10242
10251
  const now = (function () {
@@ -10392,7 +10401,7 @@
10392
10401
  hasRequiredTween = 1;
10393
10402
  (function (exports) {
10394
10403
  Object.defineProperty(exports, "__esModule", { value: true });
10395
- exports.Easings = exports.Tween = undefined;
10404
+ exports.Easings = exports.Tween = void 0;
10396
10405
  const Util_1 = requireUtil();
10397
10406
  const Animation_1 = requireAnimation();
10398
10407
  const Node_1 = requireNode();
@@ -10748,10 +10757,21 @@
10748
10757
  destroy() {
10749
10758
  const nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId];
10750
10759
  this.pause();
10760
+ if (this.anim) {
10761
+ this.anim.stop();
10762
+ }
10751
10763
  for (const key in attrs) {
10752
10764
  delete Tween.tweens[nodeId][key];
10753
10765
  }
10754
10766
  delete Tween.attrs[nodeId][thisId];
10767
+ if (Tween.tweens[nodeId]) {
10768
+ if (Object.keys(Tween.tweens[nodeId]).length === 0) {
10769
+ delete Tween.tweens[nodeId];
10770
+ }
10771
+ if (Object.keys(Tween.attrs[nodeId]).length === 0) {
10772
+ delete Tween.attrs[nodeId];
10773
+ }
10774
+ }
10755
10775
  }
10756
10776
  }
10757
10777
  exports.Tween = Tween;
@@ -10925,7 +10945,7 @@
10925
10945
  hasRequired_CoreInternals = 1;
10926
10946
  (function (exports) {
10927
10947
  Object.defineProperty(exports, "__esModule", { value: true });
10928
- exports.Konva = undefined;
10948
+ exports.Konva = void 0;
10929
10949
  const Global_1 = requireGlobal();
10930
10950
  const Util_1 = requireUtil();
10931
10951
  const Node_1 = requireNode();
@@ -10972,7 +10992,7 @@
10972
10992
  if (hasRequiredArc) return Arc;
10973
10993
  hasRequiredArc = 1;
10974
10994
  Object.defineProperty(Arc, "__esModule", { value: true });
10975
- Arc.Arc = undefined;
10995
+ Arc.Arc = void 0;
10976
10996
  const Factory_1 = requireFactory();
10977
10997
  const Shape_1 = requireShape();
10978
10998
  const Global_1 = requireGlobal();
@@ -11023,7 +11043,12 @@
11023
11043
  Arc.Arc = Arc$1;
11024
11044
  Arc$1.prototype._centroid = true;
11025
11045
  Arc$1.prototype.className = 'Arc';
11026
- Arc$1.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
11046
+ Arc$1.prototype._attrsAffectingSize = [
11047
+ 'innerRadius',
11048
+ 'outerRadius',
11049
+ 'angle',
11050
+ 'clockwise',
11051
+ ];
11027
11052
  (0, Global_2._registerNode)(Arc$1);
11028
11053
  Factory_1.Factory.addGetterSetter(Arc$1, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
11029
11054
  Factory_1.Factory.addGetterSetter(Arc$1, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
@@ -11042,7 +11067,7 @@
11042
11067
  if (hasRequiredLine) return Line;
11043
11068
  hasRequiredLine = 1;
11044
11069
  Object.defineProperty(Line, "__esModule", { value: true });
11045
- Line.Line = undefined;
11070
+ Line.Line = void 0;
11046
11071
  const Factory_1 = requireFactory();
11047
11072
  const Global_1 = requireGlobal();
11048
11073
  const Shape_1 = requireShape();
@@ -11075,15 +11100,16 @@
11075
11100
  });
11076
11101
  }
11077
11102
  _sceneFunc(context) {
11078
- let points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier(), tp, len, n;
11103
+ const points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier();
11079
11104
  if (!length) {
11080
11105
  return;
11081
11106
  }
11107
+ let n = 0;
11082
11108
  context.beginPath();
11083
11109
  context.moveTo(points[0], points[1]);
11084
11110
  if (tension !== 0 && length > 4) {
11085
- tp = this.getTensionPoints();
11086
- len = tp.length;
11111
+ const tp = this.getTensionPoints();
11112
+ const len = tp.length;
11087
11113
  n = closed ? 0 : 4;
11088
11114
  if (!closed) {
11089
11115
  context.quadraticCurveTo(tp[0], tp[1], tp[2], tp[3]);
@@ -11213,7 +11239,7 @@
11213
11239
  hasRequiredBezierFunctions = 1;
11214
11240
  (function (exports) {
11215
11241
  Object.defineProperty(exports, "__esModule", { value: true });
11216
- exports.t2length = exports.getQuadraticArcLength = exports.getCubicArcLength = exports.binomialCoefficients = exports.cValues = exports.tValues = undefined;
11242
+ exports.t2length = exports.getQuadraticArcLength = exports.getCubicArcLength = exports.binomialCoefficients = exports.cValues = exports.tValues = void 0;
11217
11243
  exports.tValues = [
11218
11244
  [],
11219
11245
  [],
@@ -12011,10 +12037,10 @@
12011
12037
  if (hasRequiredPath) return Path;
12012
12038
  hasRequiredPath = 1;
12013
12039
  Object.defineProperty(Path, "__esModule", { value: true });
12014
- Path.Path = undefined;
12040
+ Path.Path = void 0;
12015
12041
  const Factory_1 = requireFactory();
12016
- const Shape_1 = requireShape();
12017
12042
  const Global_1 = requireGlobal();
12043
+ const Shape_1 = requireShape();
12018
12044
  const BezierFunctions_1 = requireBezierFunctions();
12019
12045
  let Path$1 = class Path extends Shape_1.Shape {
12020
12046
  constructor(config) {
@@ -12051,10 +12077,10 @@
12051
12077
  context.quadraticCurveTo(p[0], p[1], p[2], p[3]);
12052
12078
  break;
12053
12079
  case 'A':
12054
- var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6], fs = p[7];
12055
- var r = rx > ry ? rx : ry;
12056
- var scaleX = rx > ry ? 1 : rx / ry;
12057
- var scaleY = rx > ry ? ry / rx : 1;
12080
+ const cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6], fs = p[7];
12081
+ const r = rx > ry ? rx : ry;
12082
+ const scaleX = rx > ry ? 1 : rx / ry;
12083
+ const scaleY = rx > ry ? ry / rx : 1;
12058
12084
  context.translate(cx, cy);
12059
12085
  context.rotate(psi);
12060
12086
  context.scale(scaleX, scaleY);
@@ -12167,11 +12193,20 @@
12167
12193
  };
12168
12194
  }
12169
12195
  if (length < 0.01) {
12170
- points = dataArray[i].points.slice(0, 2);
12171
- return {
12172
- x: points[0],
12173
- y: points[1],
12174
- };
12196
+ const cmd = dataArray[i].command;
12197
+ if (cmd === 'M') {
12198
+ points = dataArray[i].points.slice(0, 2);
12199
+ return {
12200
+ x: points[0],
12201
+ y: points[1],
12202
+ };
12203
+ }
12204
+ else {
12205
+ return {
12206
+ x: dataArray[i].start.x,
12207
+ y: dataArray[i].start.y,
12208
+ };
12209
+ }
12175
12210
  }
12176
12211
  const cp = dataArray[i];
12177
12212
  const p = cp.points;
@@ -12187,15 +12222,16 @@
12187
12222
  return (0, BezierFunctions_1.getQuadraticArcLength)([cp.start.x, p[0], p[2]], [cp.start.y, p[1], p[3]], i);
12188
12223
  }), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);
12189
12224
  case 'A':
12190
- var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6];
12225
+ const cx = p[0], cy = p[1], rx = p[2], ry = p[3], dTheta = p[5], psi = p[6];
12226
+ let theta = p[4];
12191
12227
  theta += (dTheta * length) / cp.pathLength;
12192
12228
  return Path.getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi);
12193
12229
  }
12194
12230
  return null;
12195
12231
  }
12196
12232
  static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
12197
- fromX = fromX !== null && fromX !== undefined ? fromX : P1x;
12198
- fromY = fromY !== null && fromY !== undefined ? fromY : P1y;
12233
+ fromX = fromX !== null && fromX !== void 0 ? fromX : P1x;
12234
+ fromY = fromY !== null && fromY !== void 0 ? fromY : P1y;
12199
12235
  const len = this.getLineLength(P1x, P1y, P2x, P2y);
12200
12236
  if (len < 1e-10) {
12201
12237
  return { x: P1x, y: P1y };
@@ -12233,10 +12269,7 @@
12233
12269
  }
12234
12270
  const x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);
12235
12271
  const y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);
12236
- return {
12237
- x: x,
12238
- y: y,
12239
- };
12272
+ return { x, y };
12240
12273
  }
12241
12274
  static getPointOnQuadraticBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y) {
12242
12275
  function QB1(t) {
@@ -12250,10 +12283,7 @@
12250
12283
  }
12251
12284
  const x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);
12252
12285
  const y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);
12253
- return {
12254
- x: x,
12255
- y: y,
12256
- };
12286
+ return { x, y };
12257
12287
  }
12258
12288
  static getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi) {
12259
12289
  const cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
@@ -12294,7 +12324,7 @@
12294
12324
  'A',
12295
12325
  ];
12296
12326
  cs = cs.replace(new RegExp(' ', 'g'), ',');
12297
- for (var n = 0; n < cc.length; n++) {
12327
+ for (let n = 0; n < cc.length; n++) {
12298
12328
  cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
12299
12329
  }
12300
12330
  const arr = cs.split('|');
@@ -12304,7 +12334,7 @@
12304
12334
  let cpy = 0;
12305
12335
  const re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;
12306
12336
  let match;
12307
- for (n = 1; n < arr.length; n++) {
12337
+ for (let n = 1; n < arr.length; n++) {
12308
12338
  let str = arr[n];
12309
12339
  let c = str.charAt(0);
12310
12340
  str = str.slice(1);
@@ -12333,8 +12363,8 @@
12333
12363
  let cmd = '';
12334
12364
  let points = [];
12335
12365
  const startX = cpx, startY = cpy;
12336
- var prevCmd, ctlPtx, ctlPty;
12337
- var rx, ry, psi, fa, fs, x1, y1;
12366
+ let prevCmd, ctlPtx, ctlPty;
12367
+ let rx, ry, psi, fa, fs, x1, y1;
12338
12368
  switch (c) {
12339
12369
  case 'l':
12340
12370
  cpx += p.shift();
@@ -12348,8 +12378,8 @@
12348
12378
  points.push(cpx, cpy);
12349
12379
  break;
12350
12380
  case 'm':
12351
- var dx = p.shift();
12352
- var dy = p.shift();
12381
+ const dx = p.shift();
12382
+ const dy = p.shift();
12353
12383
  cpx += dx;
12354
12384
  cpy += dy;
12355
12385
  cmd = 'M';
@@ -12532,10 +12562,10 @@
12532
12562
  return (0, BezierFunctions_1.getQuadraticArcLength)([x, points[0], points[2]], [y, points[1], points[3]], 1);
12533
12563
  case 'A':
12534
12564
  len = 0.0;
12535
- var start = points[4];
12536
- var dTheta = points[5];
12537
- var end = points[4] + dTheta;
12538
- var inc = Math.PI / 180.0;
12565
+ const start = points[4];
12566
+ const dTheta = points[5];
12567
+ const end = points[4] + dTheta;
12568
+ let inc = Math.PI / 180.0;
12539
12569
  if (Math.abs(start - end) < inc) {
12540
12570
  inc = Math.abs(start - end);
12541
12571
  }
@@ -12624,7 +12654,7 @@
12624
12654
  if (hasRequiredArrow) return Arrow;
12625
12655
  hasRequiredArrow = 1;
12626
12656
  Object.defineProperty(Arrow, "__esModule", { value: true });
12627
- Arrow.Arrow = undefined;
12657
+ Arrow.Arrow = void 0;
12628
12658
  const Factory_1 = requireFactory();
12629
12659
  const Line_1 = requireLine();
12630
12660
  const Validators_1 = requireValidators();
@@ -12736,7 +12766,7 @@
12736
12766
  if (hasRequiredCircle) return Circle;
12737
12767
  hasRequiredCircle = 1;
12738
12768
  Object.defineProperty(Circle, "__esModule", { value: true });
12739
- Circle.Circle = undefined;
12769
+ Circle.Circle = void 0;
12740
12770
  const Factory_1 = requireFactory();
12741
12771
  const Shape_1 = requireShape();
12742
12772
  const Validators_1 = requireValidators();
@@ -12782,7 +12812,7 @@
12782
12812
  if (hasRequiredEllipse) return Ellipse;
12783
12813
  hasRequiredEllipse = 1;
12784
12814
  Object.defineProperty(Ellipse, "__esModule", { value: true });
12785
- Ellipse.Ellipse = undefined;
12815
+ Ellipse.Ellipse = void 0;
12786
12816
  const Factory_1 = requireFactory();
12787
12817
  const Shape_1 = requireShape();
12788
12818
  const Validators_1 = requireValidators();
@@ -12832,7 +12862,7 @@
12832
12862
  if (hasRequiredImage) return Image$1;
12833
12863
  hasRequiredImage = 1;
12834
12864
  Object.defineProperty(Image$1, "__esModule", { value: true });
12835
- Image$1.Image = undefined;
12865
+ Image$1.Image = void 0;
12836
12866
  const Util_1 = requireUtil();
12837
12867
  const Factory_1 = requireFactory();
12838
12868
  const Shape_1 = requireShape();
@@ -12841,7 +12871,11 @@
12841
12871
  class Image extends Shape_1.Shape {
12842
12872
  constructor(attrs) {
12843
12873
  super(attrs);
12844
- this.on('imageChange.konva', () => {
12874
+ this._loadListener = () => {
12875
+ this._requestDraw();
12876
+ };
12877
+ this.on('imageChange.konva', (props) => {
12878
+ this._removeImageLoad(props.oldVal);
12845
12879
  this._setImageLoad();
12846
12880
  });
12847
12881
  this._setImageLoad();
@@ -12855,11 +12889,19 @@
12855
12889
  return;
12856
12890
  }
12857
12891
  if (image && image['addEventListener']) {
12858
- image['addEventListener']('load', () => {
12859
- this._requestDraw();
12860
- });
12892
+ image['addEventListener']('load', this._loadListener);
12893
+ }
12894
+ }
12895
+ _removeImageLoad(image) {
12896
+ if (image && image['removeEventListener']) {
12897
+ image['removeEventListener']('load', this._loadListener);
12861
12898
  }
12862
12899
  }
12900
+ destroy() {
12901
+ this._removeImageLoad(this.image());
12902
+ super.destroy();
12903
+ return this;
12904
+ }
12863
12905
  _useBufferCanvas() {
12864
12906
  const hasCornerRadius = !!this.cornerRadius();
12865
12907
  const hasShadow = this.hasShadow();
@@ -12923,11 +12965,11 @@
12923
12965
  }
12924
12966
  getWidth() {
12925
12967
  var _a, _b;
12926
- return (_a = this.attrs.width) !== null && _a !== undefined ? _a : (_b = this.image()) === null || _b === undefined ? undefined : _b.width;
12968
+ return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;
12927
12969
  }
12928
12970
  getHeight() {
12929
12971
  var _a, _b;
12930
- return (_a = this.attrs.height) !== null && _a !== undefined ? _a : (_b = this.image()) === null || _b === undefined ? undefined : _b.height;
12972
+ return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
12931
12973
  }
12932
12974
  static fromURL(url, callback, onError = null) {
12933
12975
  const img = Util_1.Util.createImageElement();
@@ -12963,7 +13005,7 @@
12963
13005
  if (hasRequiredLabel) return Label;
12964
13006
  hasRequiredLabel = 1;
12965
13007
  Object.defineProperty(Label, "__esModule", { value: true });
12966
- Label.Tag = Label.Label = undefined;
13008
+ Label.Tag = Label.Label = void 0;
12967
13009
  const Factory_1 = requireFactory();
12968
13010
  const Shape_1 = requireShape();
12969
13011
  const Group_1 = requireGroup();
@@ -13150,7 +13192,7 @@
13150
13192
  if (hasRequiredRect) return Rect;
13151
13193
  hasRequiredRect = 1;
13152
13194
  Object.defineProperty(Rect, "__esModule", { value: true });
13153
- Rect.Rect = undefined;
13195
+ Rect.Rect = void 0;
13154
13196
  const Factory_1 = requireFactory();
13155
13197
  const Shape_1 = requireShape();
13156
13198
  const Global_1 = requireGlobal();
@@ -13185,7 +13227,7 @@
13185
13227
  if (hasRequiredRegularPolygon) return RegularPolygon;
13186
13228
  hasRequiredRegularPolygon = 1;
13187
13229
  Object.defineProperty(RegularPolygon, "__esModule", { value: true });
13188
- RegularPolygon.RegularPolygon = undefined;
13230
+ RegularPolygon.RegularPolygon = void 0;
13189
13231
  const Factory_1 = requireFactory();
13190
13232
  const Shape_1 = requireShape();
13191
13233
  const Validators_1 = requireValidators();
@@ -13263,7 +13305,7 @@
13263
13305
  if (hasRequiredRing) return Ring;
13264
13306
  hasRequiredRing = 1;
13265
13307
  Object.defineProperty(Ring, "__esModule", { value: true });
13266
- Ring.Ring = undefined;
13308
+ Ring.Ring = void 0;
13267
13309
  const Factory_1 = requireFactory();
13268
13310
  const Shape_1 = requireShape();
13269
13311
  const Validators_1 = requireValidators();
@@ -13309,7 +13351,7 @@
13309
13351
  if (hasRequiredSprite) return Sprite;
13310
13352
  hasRequiredSprite = 1;
13311
13353
  Object.defineProperty(Sprite, "__esModule", { value: true });
13312
- Sprite.Sprite = undefined;
13354
+ Sprite.Sprite = void 0;
13313
13355
  const Factory_1 = requireFactory();
13314
13356
  const Shape_1 = requireShape();
13315
13357
  const Animation_1 = requireAnimation();
@@ -13430,7 +13472,7 @@
13430
13472
  if (hasRequiredStar) return Star;
13431
13473
  hasRequiredStar = 1;
13432
13474
  Object.defineProperty(Star, "__esModule", { value: true });
13433
- Star.Star = undefined;
13475
+ Star.Star = void 0;
13434
13476
  const Factory_1 = requireFactory();
13435
13477
  const Shape_1 = requireShape();
13436
13478
  const Validators_1 = requireValidators();
@@ -13481,7 +13523,7 @@
13481
13523
  if (hasRequiredText) return Text;
13482
13524
  hasRequiredText = 1;
13483
13525
  Object.defineProperty(Text, "__esModule", { value: true });
13484
- Text.Text = undefined;
13526
+ Text.Text = void 0;
13485
13527
  Text.stringToArray = stringToArray;
13486
13528
  const Util_1 = requireUtil();
13487
13529
  const Factory_1 = requireFactory();
@@ -13594,8 +13636,6 @@
13594
13636
  (metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2 +
13595
13637
  lineHeightPx / 2;
13596
13638
  }
13597
- var lineTranslateX = 0;
13598
- var lineTranslateY = 0;
13599
13639
  if (direction === RTL) {
13600
13640
  context.setAttr('direction', direction);
13601
13641
  }
@@ -13610,9 +13650,9 @@
13610
13650
  }
13611
13651
  context.translate(padding, alignY + padding);
13612
13652
  for (n = 0; n < textArrLen; n++) {
13613
- var lineTranslateX = 0;
13614
- var lineTranslateY = 0;
13615
- var obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph, spacesNumber, lineWidth;
13653
+ let lineTranslateX = 0;
13654
+ let lineTranslateY = 0;
13655
+ const obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph;
13616
13656
  context.save();
13617
13657
  if (align === RIGHT) {
13618
13658
  lineTranslateX += totalWidth - width - padding * 2;
@@ -13629,9 +13669,7 @@
13629
13669
  const x = lineTranslateX;
13630
13670
  const y = translateY + lineTranslateY + yOffset;
13631
13671
  context.moveTo(x, y);
13632
- spacesNumber = text.split(' ').length - 1;
13633
- lineWidth =
13634
- align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
13672
+ const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
13635
13673
  context.lineTo(x + Math.round(lineWidth), y);
13636
13674
  context.lineWidth = fontSize / 15;
13637
13675
  const gradient = this._getLinearGradient();
@@ -13644,9 +13682,7 @@
13644
13682
  context.beginPath();
13645
13683
  const yOffset = Global_1.Konva._fixTextRendering ? -Math.round(fontSize / 4) : 0;
13646
13684
  context.moveTo(lineTranslateX, translateY + lineTranslateY + yOffset);
13647
- spacesNumber = text.split(' ').length - 1;
13648
- lineWidth =
13649
- align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
13685
+ const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
13650
13686
  context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY + yOffset);
13651
13687
  context.lineWidth = fontSize / 15;
13652
13688
  const gradient = this._getLinearGradient();
@@ -13655,7 +13691,7 @@
13655
13691
  context.restore();
13656
13692
  }
13657
13693
  if (direction !== RTL && (letterSpacing !== 0 || align === JUSTIFY)) {
13658
- spacesNumber = text.split(' ').length - 1;
13694
+ const spacesNumber = text.split(' ').length - 1;
13659
13695
  const array = stringToArray(text);
13660
13696
  for (let li = 0; li < array.length; li++) {
13661
13697
  const letter = array[li];
@@ -13727,17 +13763,17 @@
13727
13763
  _context.restore();
13728
13764
  const scaleFactor = fontSize / 100;
13729
13765
  return {
13730
- actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== undefined ? _a : 71.58203125 * scaleFactor,
13731
- actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== undefined ? _b : 0,
13732
- actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== undefined ? _c : -7.421875 * scaleFactor,
13733
- actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== undefined ? _d : 75.732421875 * scaleFactor,
13734
- alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== undefined ? _e : 0,
13735
- emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== undefined ? _f : 100 * scaleFactor,
13736
- emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== undefined ? _g : -20 * scaleFactor,
13737
- fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== undefined ? _h : 91 * scaleFactor,
13738
- fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== undefined ? _j : 21 * scaleFactor,
13739
- hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== undefined ? _k : 72.80000305175781 * scaleFactor,
13740
- ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== undefined ? _l : -21 * scaleFactor,
13766
+ actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== void 0 ? _a : 71.58203125 * scaleFactor,
13767
+ actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== void 0 ? _b : 0,
13768
+ actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== void 0 ? _c : -7.421875 * scaleFactor,
13769
+ actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== void 0 ? _d : 75.732421875 * scaleFactor,
13770
+ alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== void 0 ? _e : 0,
13771
+ emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== void 0 ? _f : 100 * scaleFactor,
13772
+ emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== void 0 ? _g : -20 * scaleFactor,
13773
+ fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== void 0 ? _h : 91 * scaleFactor,
13774
+ fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== void 0 ? _j : 21 * scaleFactor,
13775
+ hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== void 0 ? _k : 72.80000305175781 * scaleFactor,
13776
+ ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== void 0 ? _l : -21 * scaleFactor,
13741
13777
  width: metrics.width,
13742
13778
  height: fontSize,
13743
13779
  };
@@ -13781,8 +13817,14 @@
13781
13817
  while (line.length > 0) {
13782
13818
  let low = 0, high = stringToArray(line).length, match = '', matchWidth = 0;
13783
13819
  while (low < high) {
13784
- const mid = (low + high) >>> 1, lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr) + additionalWidth;
13785
- if (substrWidth <= maxWidth) {
13820
+ const mid = (low + high) >>> 1, lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr);
13821
+ const shouldConsiderEllipsis = shouldAddEllipsis &&
13822
+ fixedHeight &&
13823
+ currentHeightPx + lineHeightPx > maxHeightPx;
13824
+ const effectiveWidth = shouldConsiderEllipsis
13825
+ ? substrWidth + additionalWidth
13826
+ : substrWidth;
13827
+ if (effectiveWidth <= maxWidth) {
13786
13828
  low = mid + 1;
13787
13829
  match = substr;
13788
13830
  matchWidth = substrWidth;
@@ -13929,7 +13971,7 @@
13929
13971
  if (hasRequiredTextPath) return TextPath;
13930
13972
  hasRequiredTextPath = 1;
13931
13973
  Object.defineProperty(TextPath, "__esModule", { value: true });
13932
- TextPath.TextPath = undefined;
13974
+ TextPath.TextPath = void 0;
13933
13975
  const Util_1 = requireUtil();
13934
13976
  const Factory_1 = requireFactory();
13935
13977
  const Shape_1 = requireShape();
@@ -14179,7 +14221,7 @@
14179
14221
  if (hasRequiredTransformer) return Transformer;
14180
14222
  hasRequiredTransformer = 1;
14181
14223
  Object.defineProperty(Transformer, "__esModule", { value: true });
14182
- Transformer.Transformer = undefined;
14224
+ Transformer.Transformer = void 0;
14183
14225
  const Util_1 = requireUtil();
14184
14226
  const Factory_1 = requireFactory();
14185
14227
  const Node_1 = requireNode();
@@ -14376,10 +14418,12 @@
14376
14418
  this.update();
14377
14419
  }
14378
14420
  };
14379
- const additionalEvents = node._attrsAffectingSize
14380
- .map((prop) => prop + 'Change.' + this._getEventNamespace())
14381
- .join(' ');
14382
- node.on(additionalEvents, onChange);
14421
+ if (node._attrsAffectingSize.length) {
14422
+ const additionalEvents = node._attrsAffectingSize
14423
+ .map((prop) => prop + 'Change.' + this._getEventNamespace())
14424
+ .join(' ');
14425
+ node.on(additionalEvents, onChange);
14426
+ }
14383
14427
  node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);
14384
14428
  node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);
14385
14429
  this._proxyDrag(node);
@@ -14698,10 +14742,10 @@
14698
14742
  else {
14699
14743
  keepProportion = this.keepRatio() || e.shiftKey;
14700
14744
  }
14701
- var centeredScaling = this.centeredScaling() || e.altKey;
14745
+ let centeredScaling = this.centeredScaling() || e.altKey;
14702
14746
  if (this._movingAnchorName === 'top-left') {
14703
14747
  if (keepProportion) {
14704
- var comparePoint = centeredScaling
14748
+ const comparePoint = centeredScaling
14705
14749
  ? {
14706
14750
  x: this.width() / 2,
14707
14751
  y: this.height() / 2,
@@ -14712,8 +14756,8 @@
14712
14756
  };
14713
14757
  newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +
14714
14758
  Math.pow(comparePoint.y - anchorNode.y(), 2));
14715
- var reverseX = this.findOne('.top-left').x() > comparePoint.x ? -1 : 1;
14716
- var reverseY = this.findOne('.top-left').y() > comparePoint.y ? -1 : 1;
14759
+ const reverseX = this.findOne('.top-left').x() > comparePoint.x ? -1 : 1;
14760
+ const reverseY = this.findOne('.top-left').y() > comparePoint.y ? -1 : 1;
14717
14761
  x = newHypotenuse * this.cos * reverseX;
14718
14762
  y = newHypotenuse * this.sin * reverseY;
14719
14763
  this.findOne('.top-left').x(comparePoint.x - x);
@@ -14725,7 +14769,7 @@
14725
14769
  }
14726
14770
  else if (this._movingAnchorName === 'top-right') {
14727
14771
  if (keepProportion) {
14728
- var comparePoint = centeredScaling
14772
+ const comparePoint = centeredScaling
14729
14773
  ? {
14730
14774
  x: this.width() / 2,
14731
14775
  y: this.height() / 2,
@@ -14736,8 +14780,8 @@
14736
14780
  };
14737
14781
  newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +
14738
14782
  Math.pow(comparePoint.y - anchorNode.y(), 2));
14739
- var reverseX = this.findOne('.top-right').x() < comparePoint.x ? -1 : 1;
14740
- var reverseY = this.findOne('.top-right').y() > comparePoint.y ? -1 : 1;
14783
+ const reverseX = this.findOne('.top-right').x() < comparePoint.x ? -1 : 1;
14784
+ const reverseY = this.findOne('.top-right').y() > comparePoint.y ? -1 : 1;
14741
14785
  x = newHypotenuse * this.cos * reverseX;
14742
14786
  y = newHypotenuse * this.sin * reverseY;
14743
14787
  this.findOne('.top-right').x(comparePoint.x + x);
@@ -14755,7 +14799,7 @@
14755
14799
  }
14756
14800
  else if (this._movingAnchorName === 'bottom-left') {
14757
14801
  if (keepProportion) {
14758
- var comparePoint = centeredScaling
14802
+ const comparePoint = centeredScaling
14759
14803
  ? {
14760
14804
  x: this.width() / 2,
14761
14805
  y: this.height() / 2,
@@ -14766,8 +14810,8 @@
14766
14810
  };
14767
14811
  newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +
14768
14812
  Math.pow(anchorNode.y() - comparePoint.y, 2));
14769
- var reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;
14770
- var reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;
14813
+ const reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;
14814
+ const reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;
14771
14815
  x = newHypotenuse * this.cos * reverseX;
14772
14816
  y = newHypotenuse * this.sin * reverseY;
14773
14817
  anchorNode.x(comparePoint.x - x);
@@ -14782,7 +14826,7 @@
14782
14826
  }
14783
14827
  else if (this._movingAnchorName === 'bottom-right') {
14784
14828
  if (keepProportion) {
14785
- var comparePoint = centeredScaling
14829
+ const comparePoint = centeredScaling
14786
14830
  ? {
14787
14831
  x: this.width() / 2,
14788
14832
  y: this.height() / 2,
@@ -14793,8 +14837,8 @@
14793
14837
  };
14794
14838
  newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +
14795
14839
  Math.pow(anchorNode.y() - comparePoint.y, 2));
14796
- var reverseX = this.findOne('.bottom-right').x() < comparePoint.x ? -1 : 1;
14797
- var reverseY = this.findOne('.bottom-right').y() < comparePoint.y ? -1 : 1;
14840
+ const reverseX = this.findOne('.bottom-right').x() < comparePoint.x ? -1 : 1;
14841
+ const reverseY = this.findOne('.bottom-right').y() < comparePoint.y ? -1 : 1;
14798
14842
  x = newHypotenuse * this.cos * reverseX;
14799
14843
  y = newHypotenuse * this.sin * reverseY;
14800
14844
  this.findOne('.bottom-right').x(comparePoint.x + x);
@@ -14805,7 +14849,7 @@
14805
14849
  console.error(new Error('Wrong position argument of selection resizer: ' +
14806
14850
  this._movingAnchorName));
14807
14851
  }
14808
- var centeredScaling = this.centeredScaling() || e.altKey;
14852
+ centeredScaling = this.centeredScaling() || e.altKey;
14809
14853
  if (centeredScaling) {
14810
14854
  const topLeft = this.findOne('.top-left');
14811
14855
  const bottomRight = this.findOne('.bottom-right');
@@ -14854,12 +14898,12 @@
14854
14898
  const node = this.getNode();
14855
14899
  activeTransformersCount--;
14856
14900
  this._fire('transformend', { evt: e, target: node });
14857
- (_a = this.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
14901
+ (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
14858
14902
  if (node) {
14859
14903
  this._nodes.forEach((target) => {
14860
14904
  var _a;
14861
14905
  target._fire('transformend', { evt: e, target });
14862
- (_a = target.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
14906
+ (_a = target.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
14863
14907
  });
14864
14908
  }
14865
14909
  this._movingAnchorName = null;
@@ -14972,7 +15016,7 @@
14972
15016
  .multiply(localTransform);
14973
15017
  const attrs = newLocalTransform.decompose();
14974
15018
  node.setAttrs(attrs);
14975
- (_a = node.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
15019
+ (_a = node.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
14976
15020
  });
14977
15021
  this.rotation(Util_1.Util._getRotation(newAttrs.rotation));
14978
15022
  this._nodes.forEach((node) => {
@@ -15087,7 +15131,7 @@
15087
15131
  styleFunc(node);
15088
15132
  });
15089
15133
  }
15090
- (_a = this.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
15134
+ (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
15091
15135
  }
15092
15136
  isTransforming() {
15093
15137
  return this._transforming;
@@ -15194,7 +15238,7 @@
15194
15238
  if (hasRequiredWedge) return Wedge;
15195
15239
  hasRequiredWedge = 1;
15196
15240
  Object.defineProperty(Wedge, "__esModule", { value: true });
15197
- Wedge.Wedge = undefined;
15241
+ Wedge.Wedge = void 0;
15198
15242
  const Factory_1 = requireFactory();
15199
15243
  const Shape_1 = requireShape();
15200
15244
  const Global_1 = requireGlobal();
@@ -15245,7 +15289,7 @@
15245
15289
  if (hasRequiredBlur) return Blur;
15246
15290
  hasRequiredBlur = 1;
15247
15291
  Object.defineProperty(Blur, "__esModule", { value: true });
15248
- Blur.Blur = undefined;
15292
+ Blur.Blur = void 0;
15249
15293
  const Factory_1 = requireFactory();
15250
15294
  const Node_1 = requireNode();
15251
15295
  const Validators_1 = requireValidators();
@@ -15293,10 +15337,10 @@
15293
15337
  ];
15294
15338
  function filterGaussBlurRGBA(imageData, radius) {
15295
15339
  const pixels = imageData.data, width = imageData.width, height = imageData.height;
15296
- let x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
15340
+ let p, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
15297
15341
  const div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), mul_sum = mul_table[radius], shg_sum = shg_table[radius];
15298
15342
  let stackEnd = null, stack = stackStart, stackIn = null, stackOut = null;
15299
- for (i = 1; i < div; i++) {
15343
+ for (let i = 1; i < div; i++) {
15300
15344
  stack = stack.next = new BlurStack();
15301
15345
  if (i === radiusPlus1) {
15302
15346
  stackEnd = stack;
@@ -15304,7 +15348,7 @@
15304
15348
  }
15305
15349
  stack.next = stackStart;
15306
15350
  yw = yi = 0;
15307
- for (y = 0; y < height; y++) {
15351
+ for (let y = 0; y < height; y++) {
15308
15352
  r_in_sum =
15309
15353
  g_in_sum =
15310
15354
  b_in_sum =
@@ -15323,14 +15367,14 @@
15323
15367
  b_sum += sumFactor * pb;
15324
15368
  a_sum += sumFactor * pa;
15325
15369
  stack = stackStart;
15326
- for (i = 0; i < radiusPlus1; i++) {
15370
+ for (let i = 0; i < radiusPlus1; i++) {
15327
15371
  stack.r = pr;
15328
15372
  stack.g = pg;
15329
15373
  stack.b = pb;
15330
15374
  stack.a = pa;
15331
15375
  stack = stack.next;
15332
15376
  }
15333
- for (i = 1; i < radiusPlus1; i++) {
15377
+ for (let i = 1; i < radiusPlus1; i++) {
15334
15378
  p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
15335
15379
  r_sum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
15336
15380
  g_sum += (stack.g = pg = pixels[p + 1]) * rbs;
@@ -15344,7 +15388,7 @@
15344
15388
  }
15345
15389
  stackIn = stackStart;
15346
15390
  stackOut = stackEnd;
15347
- for (x = 0; x < width; x++) {
15391
+ for (let x = 0; x < width; x++) {
15348
15392
  pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;
15349
15393
  if (pa !== 0) {
15350
15394
  pa = 255 / pa;
@@ -15386,7 +15430,7 @@
15386
15430
  }
15387
15431
  yw += width;
15388
15432
  }
15389
- for (x = 0; x < width; x++) {
15433
+ for (let x = 0; x < width; x++) {
15390
15434
  g_in_sum =
15391
15435
  b_in_sum =
15392
15436
  a_in_sum =
@@ -15406,15 +15450,15 @@
15406
15450
  b_sum += sumFactor * pb;
15407
15451
  a_sum += sumFactor * pa;
15408
15452
  stack = stackStart;
15409
- for (i = 0; i < radiusPlus1; i++) {
15453
+ for (let i = 0; i < radiusPlus1; i++) {
15410
15454
  stack.r = pr;
15411
15455
  stack.g = pg;
15412
15456
  stack.b = pb;
15413
15457
  stack.a = pa;
15414
15458
  stack = stack.next;
15415
15459
  }
15416
- yp = width;
15417
- for (i = 1; i <= radius; i++) {
15460
+ let yp = width;
15461
+ for (let i = 1; i <= radius; i++) {
15418
15462
  yi = (yp + x) << 2;
15419
15463
  r_sum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
15420
15464
  g_sum += (stack.g = pg = pixels[yi + 1]) * rbs;
@@ -15432,7 +15476,7 @@
15432
15476
  yi = x;
15433
15477
  stackIn = stackStart;
15434
15478
  stackOut = stackEnd;
15435
- for (y = 0; y < height; y++) {
15479
+ for (let y = 0; y < height; y++) {
15436
15480
  p = yi << 2;
15437
15481
  pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;
15438
15482
  if (pa > 0) {
@@ -15493,7 +15537,7 @@
15493
15537
  if (hasRequiredBrighten) return Brighten;
15494
15538
  hasRequiredBrighten = 1;
15495
15539
  Object.defineProperty(Brighten, "__esModule", { value: true });
15496
- Brighten.Brighten = undefined;
15540
+ Brighten.Brighten = void 0;
15497
15541
  const Factory_1 = requireFactory();
15498
15542
  const Node_1 = requireNode();
15499
15543
  const Validators_1 = requireValidators();
@@ -15518,7 +15562,7 @@
15518
15562
  if (hasRequiredContrast) return Contrast;
15519
15563
  hasRequiredContrast = 1;
15520
15564
  Object.defineProperty(Contrast, "__esModule", { value: true });
15521
- Contrast.Contrast = undefined;
15565
+ Contrast.Contrast = void 0;
15522
15566
  const Factory_1 = requireFactory();
15523
15567
  const Node_1 = requireNode();
15524
15568
  const Validators_1 = requireValidators();
@@ -15566,7 +15610,7 @@
15566
15610
  if (hasRequiredEmboss) return Emboss;
15567
15611
  hasRequiredEmboss = 1;
15568
15612
  Object.defineProperty(Emboss, "__esModule", { value: true });
15569
- Emboss.Emboss = undefined;
15613
+ Emboss.Emboss = void 0;
15570
15614
  const Factory_1 = requireFactory();
15571
15615
  const Node_1 = requireNode();
15572
15616
  const Util_1 = requireUtil();
@@ -15682,7 +15726,7 @@
15682
15726
  if (hasRequiredEnhance) return Enhance;
15683
15727
  hasRequiredEnhance = 1;
15684
15728
  Object.defineProperty(Enhance, "__esModule", { value: true });
15685
- Enhance.Enhance = undefined;
15729
+ Enhance.Enhance = void 0;
15686
15730
  const Factory_1 = requireFactory();
15687
15731
  const Node_1 = requireNode();
15688
15732
  const Validators_1 = requireValidators();
@@ -15740,7 +15784,7 @@
15740
15784
  bMax = 255;
15741
15785
  bMin = 0;
15742
15786
  }
15743
- let rMid, rGoalMax, rGoalMin, gMid, gGoalMax, gGoalMin, bMid, bGoalMax, bGoalMin;
15787
+ let rGoalMax, rGoalMin, gGoalMax, gGoalMin, bGoalMax, bGoalMin;
15744
15788
  if (enhanceAmount > 0) {
15745
15789
  rGoalMax = rMax + enhanceAmount * (255 - rMax);
15746
15790
  rGoalMin = rMin - enhanceAmount * (rMin - 0);
@@ -15750,13 +15794,13 @@
15750
15794
  bGoalMin = bMin - enhanceAmount * (bMin - 0);
15751
15795
  }
15752
15796
  else {
15753
- rMid = (rMax + rMin) * 0.5;
15797
+ const rMid = (rMax + rMin) * 0.5;
15754
15798
  rGoalMax = rMax + enhanceAmount * (rMax - rMid);
15755
15799
  rGoalMin = rMin + enhanceAmount * (rMin - rMid);
15756
- gMid = (gMax + gMin) * 0.5;
15800
+ const gMid = (gMax + gMin) * 0.5;
15757
15801
  gGoalMax = gMax + enhanceAmount * (gMax - gMid);
15758
15802
  gGoalMin = gMin + enhanceAmount * (gMin - gMid);
15759
- bMid = (bMax + bMin) * 0.5;
15803
+ const bMid = (bMax + bMin) * 0.5;
15760
15804
  bGoalMax = bMax + enhanceAmount * (bMax - bMid);
15761
15805
  bGoalMin = bMin + enhanceAmount * (bMin - bMid);
15762
15806
  }
@@ -15779,7 +15823,7 @@
15779
15823
  if (hasRequiredGrayscale) return Grayscale;
15780
15824
  hasRequiredGrayscale = 1;
15781
15825
  Object.defineProperty(Grayscale, "__esModule", { value: true });
15782
- Grayscale.Grayscale = undefined;
15826
+ Grayscale.Grayscale = void 0;
15783
15827
  const Grayscale$1 = function (imageData) {
15784
15828
  const data = imageData.data, len = data.length;
15785
15829
  for (let i = 0; i < len; i += 4) {
@@ -15801,7 +15845,7 @@
15801
15845
  if (hasRequiredHSL) return HSL;
15802
15846
  hasRequiredHSL = 1;
15803
15847
  Object.defineProperty(HSL, "__esModule", { value: true });
15804
- HSL.HSL = undefined;
15848
+ HSL.HSL = void 0;
15805
15849
  const Factory_1 = requireFactory();
15806
15850
  const Node_1 = requireNode();
15807
15851
  const Validators_1 = requireValidators();
@@ -15838,7 +15882,7 @@
15838
15882
  if (hasRequiredHSV) return HSV;
15839
15883
  hasRequiredHSV = 1;
15840
15884
  Object.defineProperty(HSV, "__esModule", { value: true });
15841
- HSV.HSV = undefined;
15885
+ HSV.HSV = void 0;
15842
15886
  const Factory_1 = requireFactory();
15843
15887
  const Node_1 = requireNode();
15844
15888
  const Validators_1 = requireValidators();
@@ -15848,12 +15892,11 @@
15848
15892
  const rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
15849
15893
  const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
15850
15894
  const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
15851
- let r, g, b, a;
15852
15895
  for (let i = 0; i < nPixels; i += 4) {
15853
- r = data[i + 0];
15854
- g = data[i + 1];
15855
- b = data[i + 2];
15856
- a = data[i + 3];
15896
+ const r = data[i + 0];
15897
+ const g = data[i + 1];
15898
+ const b = data[i + 2];
15899
+ const a = data[i + 3];
15857
15900
  data[i + 0] = rr * r + rg * g + rb * b;
15858
15901
  data[i + 1] = gr * r + gg * g + gb * b;
15859
15902
  data[i + 2] = br * r + bg * g + bb * b;
@@ -15875,7 +15918,7 @@
15875
15918
  if (hasRequiredInvert) return Invert;
15876
15919
  hasRequiredInvert = 1;
15877
15920
  Object.defineProperty(Invert, "__esModule", { value: true });
15878
- Invert.Invert = undefined;
15921
+ Invert.Invert = void 0;
15879
15922
  const Invert$1 = function (imageData) {
15880
15923
  const data = imageData.data, len = data.length;
15881
15924
  for (let i = 0; i < len; i += 4) {
@@ -15896,7 +15939,7 @@
15896
15939
  if (hasRequiredKaleidoscope) return Kaleidoscope;
15897
15940
  hasRequiredKaleidoscope = 1;
15898
15941
  Object.defineProperty(Kaleidoscope, "__esModule", { value: true });
15899
- Kaleidoscope.Kaleidoscope = undefined;
15942
+ Kaleidoscope.Kaleidoscope = void 0;
15900
15943
  const Factory_1 = requireFactory();
15901
15944
  const Node_1 = requireNode();
15902
15945
  const Util_1 = requireUtil();
@@ -16042,7 +16085,7 @@
16042
16085
  if (hasRequiredMask) return Mask;
16043
16086
  hasRequiredMask = 1;
16044
16087
  Object.defineProperty(Mask, "__esModule", { value: true });
16045
- Mask.Mask = undefined;
16088
+ Mask.Mask = void 0;
16046
16089
  const Factory_1 = requireFactory();
16047
16090
  const Node_1 = requireNode();
16048
16091
  const Validators_1 = requireValidators();
@@ -16196,7 +16239,7 @@
16196
16239
  if (hasRequiredNoise) return Noise;
16197
16240
  hasRequiredNoise = 1;
16198
16241
  Object.defineProperty(Noise, "__esModule", { value: true });
16199
- Noise.Noise = undefined;
16242
+ Noise.Noise = void 0;
16200
16243
  const Factory_1 = requireFactory();
16201
16244
  const Node_1 = requireNode();
16202
16245
  const Validators_1 = requireValidators();
@@ -16221,37 +16264,37 @@
16221
16264
  if (hasRequiredPixelate) return Pixelate;
16222
16265
  hasRequiredPixelate = 1;
16223
16266
  Object.defineProperty(Pixelate, "__esModule", { value: true });
16224
- Pixelate.Pixelate = undefined;
16267
+ Pixelate.Pixelate = void 0;
16225
16268
  const Factory_1 = requireFactory();
16226
16269
  const Util_1 = requireUtil();
16227
16270
  const Node_1 = requireNode();
16228
16271
  const Validators_1 = requireValidators();
16229
16272
  const Pixelate$1 = function (imageData) {
16230
- let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, x, y, i, red, green, blue, alpha, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), xBinStart, xBinEnd, yBinStart, yBinEnd, xBin, yBin, pixelsInBin, data = imageData.data;
16273
+ let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), data = imageData.data;
16231
16274
  if (pixelSize <= 0) {
16232
16275
  Util_1.Util.error('pixelSize value can not be <= 0');
16233
16276
  return;
16234
16277
  }
16235
- for (xBin = 0; xBin < nBinsX; xBin += 1) {
16236
- for (yBin = 0; yBin < nBinsY; yBin += 1) {
16237
- red = 0;
16238
- green = 0;
16239
- blue = 0;
16240
- alpha = 0;
16241
- xBinStart = xBin * pixelSize;
16242
- xBinEnd = xBinStart + pixelSize;
16243
- yBinStart = yBin * pixelSize;
16244
- yBinEnd = yBinStart + pixelSize;
16245
- pixelsInBin = 0;
16246
- for (x = xBinStart; x < xBinEnd; x += 1) {
16278
+ for (let xBin = 0; xBin < nBinsX; xBin += 1) {
16279
+ for (let yBin = 0; yBin < nBinsY; yBin += 1) {
16280
+ let red = 0;
16281
+ let green = 0;
16282
+ let blue = 0;
16283
+ let alpha = 0;
16284
+ const xBinStart = xBin * pixelSize;
16285
+ const xBinEnd = xBinStart + pixelSize;
16286
+ const yBinStart = yBin * pixelSize;
16287
+ const yBinEnd = yBinStart + pixelSize;
16288
+ let pixelsInBin = 0;
16289
+ for (let x = xBinStart; x < xBinEnd; x += 1) {
16247
16290
  if (x >= width) {
16248
16291
  continue;
16249
16292
  }
16250
- for (y = yBinStart; y < yBinEnd; y += 1) {
16293
+ for (let y = yBinStart; y < yBinEnd; y += 1) {
16251
16294
  if (y >= height) {
16252
16295
  continue;
16253
16296
  }
16254
- i = (width * y + x) * 4;
16297
+ const i = (width * y + x) * 4;
16255
16298
  red += data[i + 0];
16256
16299
  green += data[i + 1];
16257
16300
  blue += data[i + 2];
@@ -16263,15 +16306,15 @@
16263
16306
  green = green / pixelsInBin;
16264
16307
  blue = blue / pixelsInBin;
16265
16308
  alpha = alpha / pixelsInBin;
16266
- for (x = xBinStart; x < xBinEnd; x += 1) {
16309
+ for (let x = xBinStart; x < xBinEnd; x += 1) {
16267
16310
  if (x >= width) {
16268
16311
  continue;
16269
16312
  }
16270
- for (y = yBinStart; y < yBinEnd; y += 1) {
16313
+ for (let y = yBinStart; y < yBinEnd; y += 1) {
16271
16314
  if (y >= height) {
16272
16315
  continue;
16273
16316
  }
16274
- i = (width * y + x) * 4;
16317
+ const i = (width * y + x) * 4;
16275
16318
  data[i + 0] = red;
16276
16319
  data[i + 1] = green;
16277
16320
  data[i + 2] = blue;
@@ -16294,7 +16337,7 @@
16294
16337
  if (hasRequiredPosterize) return Posterize;
16295
16338
  hasRequiredPosterize = 1;
16296
16339
  Object.defineProperty(Posterize, "__esModule", { value: true });
16297
- Posterize.Posterize = undefined;
16340
+ Posterize.Posterize = void 0;
16298
16341
  const Factory_1 = requireFactory();
16299
16342
  const Node_1 = requireNode();
16300
16343
  const Validators_1 = requireValidators();
@@ -16317,7 +16360,7 @@
16317
16360
  if (hasRequiredRGB) return RGB;
16318
16361
  hasRequiredRGB = 1;
16319
16362
  Object.defineProperty(RGB, "__esModule", { value: true });
16320
- RGB.RGB = undefined;
16363
+ RGB.RGB = void 0;
16321
16364
  const Factory_1 = requireFactory();
16322
16365
  const Node_1 = requireNode();
16323
16366
  const Validators_1 = requireValidators();
@@ -16368,7 +16411,7 @@
16368
16411
  if (hasRequiredRGBA) return RGBA;
16369
16412
  hasRequiredRGBA = 1;
16370
16413
  Object.defineProperty(RGBA, "__esModule", { value: true });
16371
- RGBA.RGBA = undefined;
16414
+ RGBA.RGBA = void 0;
16372
16415
  const Factory_1 = requireFactory();
16373
16416
  const Node_1 = requireNode();
16374
16417
  const Validators_1 = requireValidators();
@@ -16430,7 +16473,7 @@
16430
16473
  if (hasRequiredSepia) return Sepia;
16431
16474
  hasRequiredSepia = 1;
16432
16475
  Object.defineProperty(Sepia, "__esModule", { value: true });
16433
- Sepia.Sepia = undefined;
16476
+ Sepia.Sepia = void 0;
16434
16477
  const Sepia$1 = function (imageData) {
16435
16478
  const data = imageData.data, nPixels = data.length;
16436
16479
  for (let i = 0; i < nPixels; i += 4) {
@@ -16454,7 +16497,7 @@
16454
16497
  if (hasRequiredSolarize) return Solarize;
16455
16498
  hasRequiredSolarize = 1;
16456
16499
  Object.defineProperty(Solarize, "__esModule", { value: true });
16457
- Solarize.Solarize = undefined;
16500
+ Solarize.Solarize = void 0;
16458
16501
  const Solarize$1 = function (imageData) {
16459
16502
  const data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4;
16460
16503
  let y = h;
@@ -16493,7 +16536,7 @@
16493
16536
  if (hasRequiredThreshold) return Threshold;
16494
16537
  hasRequiredThreshold = 1;
16495
16538
  Object.defineProperty(Threshold, "__esModule", { value: true });
16496
- Threshold.Threshold = undefined;
16539
+ Threshold.Threshold = void 0;
16497
16540
  const Factory_1 = requireFactory();
16498
16541
  const Node_1 = requireNode();
16499
16542
  const Validators_1 = requireValidators();
@@ -16514,7 +16557,7 @@
16514
16557
  if (hasRequired_FullInternals) return _FullInternals;
16515
16558
  hasRequired_FullInternals = 1;
16516
16559
  Object.defineProperty(_FullInternals, "__esModule", { value: true });
16517
- _FullInternals.Konva = undefined;
16560
+ _FullInternals.Konva = void 0;
16518
16561
  const _CoreInternals_1 = require_CoreInternals();
16519
16562
  const Arc_1 = requireArc();
16520
16563
  const Arrow_1 = requireArrow();
@@ -16702,7 +16745,7 @@
16702
16745
  } ];
16703
16746
  const konvaPoints = [];
16704
16747
  const wcsPoints = [];
16705
- params.points.forEach((point => {
16748
+ params.points.forEach(point => {
16706
16749
  konvaPoints.push(point.x, point.y);
16707
16750
  const wcsPoint = this._worldTransformer.screenToWorld({
16708
16751
  x: point.x,
@@ -16713,10 +16756,10 @@
16713
16756
  y: wcsPoint.y,
16714
16757
  z: wcsPoint.z
16715
16758
  });
16716
- }));
16759
+ });
16717
16760
  this._ref = new Konva.Line({
16718
- stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
16719
- strokeWidth: (_b = params.width) !== null && _b !== undefined ? _b : 4,
16761
+ stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
16762
+ strokeWidth: (_b = params.width) !== null && _b !== void 0 ? _b : 4,
16720
16763
  globalCompositeOperation: "source-over",
16721
16764
  lineCap: "round",
16722
16765
  lineJoin: "round",
@@ -16726,11 +16769,11 @@
16726
16769
  dash: LineTypeSpecs.get(params.type) || []
16727
16770
  });
16728
16771
  this._ref.setAttr("wcsPoints", wcsPoints);
16729
- this._ref.on("transform", (e => {
16772
+ this._ref.on("transform", e => {
16730
16773
  const attrs = e.target.attrs;
16731
16774
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
16732
- }));
16733
- this._ref.on("transformend", (() => {
16775
+ });
16776
+ this._ref.on("transformend", () => {
16734
16777
  const absoluteTransform = this._ref.getAbsoluteTransform();
16735
16778
  const wcsPoints = [];
16736
16779
  const points = this._ref.points();
@@ -16751,8 +16794,8 @@
16751
16794
  });
16752
16795
  }
16753
16796
  this._ref.setAttr("wcsPoints", wcsPoints);
16754
- }));
16755
- this._ref.on("dragend", (() => {
16797
+ });
16798
+ this._ref.on("dragend", () => {
16756
16799
  const absoluteTransform = this._ref.getAbsoluteTransform();
16757
16800
  const wcsPoints = [];
16758
16801
  const points = this._ref.points();
@@ -16773,7 +16816,7 @@
16773
16816
  });
16774
16817
  }
16775
16818
  this._ref.setAttr("wcsPoints", wcsPoints);
16776
- }));
16819
+ });
16777
16820
  this._ref.id(this._ref._id.toString());
16778
16821
  }
16779
16822
  ref() {
@@ -16844,11 +16887,11 @@
16844
16887
  addPoints(points) {
16845
16888
  let newPoints = this._ref.points();
16846
16889
  const wcsPoints = this._ref.getAttr("wcsPoints");
16847
- points.forEach((point => {
16890
+ points.forEach(point => {
16848
16891
  newPoints = newPoints.concat([ point.x, point.y ]);
16849
16892
  const wcsPoint = this._worldTransformer.screenToWorld(point);
16850
16893
  wcsPoints.push(wcsPoint);
16851
- }));
16894
+ });
16852
16895
  this._ref.points(newPoints);
16853
16896
  }
16854
16897
  updateScreenCoordinates() {
@@ -16856,7 +16899,7 @@
16856
16899
  const points = [];
16857
16900
  let invert = this._ref.getAbsoluteTransform().copy();
16858
16901
  invert = invert.invert();
16859
- wcsPoints.forEach((point => {
16902
+ wcsPoints.forEach(point => {
16860
16903
  let screenPoint = this._worldTransformer.worldToScreen(point);
16861
16904
  screenPoint = invert.point({
16862
16905
  x: screenPoint.x,
@@ -16864,7 +16907,7 @@
16864
16907
  });
16865
16908
  points.push(screenPoint.x);
16866
16909
  points.push(screenPoint.y);
16867
- }));
16910
+ });
16868
16911
  this._ref.points([]);
16869
16912
  this._ref.points(points);
16870
16913
  this._ref.clearCache();
@@ -16897,19 +16940,19 @@
16897
16940
  x: params.position.x,
16898
16941
  y: params.position.y,
16899
16942
  text: params.text,
16900
- fontSize: (_a = params.fontSize) !== null && _a !== undefined ? _a : 34,
16943
+ fontSize: (_a = params.fontSize) !== null && _a !== void 0 ? _a : 34,
16901
16944
  fontFamily: this.TEXT_FONT_FAMILY,
16902
- fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
16945
+ fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
16903
16946
  align: "left",
16904
16947
  draggable: true,
16905
- rotation: (_c = params.rotation) !== null && _c !== undefined ? _c : 0
16948
+ rotation: (_c = params.rotation) !== null && _c !== void 0 ? _c : 0
16906
16949
  });
16907
16950
  this._ref.width(this._ref.getTextWidth());
16908
16951
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
16909
16952
  x: params.position.x,
16910
16953
  y: params.position.y
16911
16954
  }));
16912
- this._ref.on("transform", (e => {
16955
+ this._ref.on("transform", e => {
16913
16956
  const attrs = e.target.attrs;
16914
16957
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
16915
16958
  const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
@@ -16931,8 +16974,8 @@
16931
16974
  x: 1,
16932
16975
  y: 1
16933
16976
  });
16934
- }));
16935
- this._ref.on("transformend", (e => {
16977
+ });
16978
+ this._ref.on("transformend", e => {
16936
16979
  const attrs = e.target.attrs;
16937
16980
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
16938
16981
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
@@ -16941,15 +16984,15 @@
16941
16984
  y: this._ref.y()
16942
16985
  });
16943
16986
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
16944
- }));
16945
- this._ref.on("dragend", (() => {
16987
+ });
16988
+ this._ref.on("dragend", () => {
16946
16989
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
16947
16990
  const position = absoluteTransform.point({
16948
16991
  x: this._ref.x(),
16949
16992
  y: this._ref.y()
16950
16993
  });
16951
16994
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
16952
- }));
16995
+ });
16953
16996
  this._ref.id(this._ref._id.toString());
16954
16997
  }
16955
16998
  ref() {
@@ -17073,15 +17116,15 @@
17073
17116
  }
17074
17117
  }
17075
17118
  this._ref = new Konva.Rect({
17076
- stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
17077
- strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
17119
+ stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
17120
+ strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
17078
17121
  globalCompositeOperation: "source-over",
17079
17122
  lineCap: "round",
17080
17123
  lineJoin: "round",
17081
17124
  x: params.position.x,
17082
17125
  y: params.position.y,
17083
- width: (_c = params.width) !== null && _c !== undefined ? _c : 200,
17084
- height: (_d = params.height) !== null && _d !== undefined ? _d : 200,
17126
+ width: (_c = params.width) !== null && _c !== void 0 ? _c : 200,
17127
+ height: (_d = params.height) !== null && _d !== void 0 ? _d : 200,
17085
17128
  draggable: true,
17086
17129
  strokeScaleEnabled: false
17087
17130
  });
@@ -17093,7 +17136,7 @@
17093
17136
  x: params.position2.x,
17094
17137
  y: params.position2.y
17095
17138
  }));
17096
- this._ref.on("transform", (e => {
17139
+ this._ref.on("transform", e => {
17097
17140
  const attrs = e.target.attrs;
17098
17141
  const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
17099
17142
  const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
@@ -17115,8 +17158,8 @@
17115
17158
  x: 1,
17116
17159
  y: 1
17117
17160
  });
17118
- }));
17119
- this._ref.on("transformend", (e => {
17161
+ });
17162
+ this._ref.on("transformend", e => {
17120
17163
  const attrs = e.target.attrs;
17121
17164
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
17122
17165
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
@@ -17129,8 +17172,8 @@
17129
17172
  x: position.x + this._ref.width(),
17130
17173
  y: position.y + this._ref.height()
17131
17174
  }));
17132
- }));
17133
- this._ref.on("dragend", (() => {
17175
+ });
17176
+ this._ref.on("dragend", () => {
17134
17177
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
17135
17178
  const position = absoluteTransform.point({
17136
17179
  x: this._ref.x(),
@@ -17141,7 +17184,7 @@
17141
17184
  x: position.x + this._ref.width(),
17142
17185
  y: position.y + this._ref.height()
17143
17186
  }));
17144
- }));
17187
+ });
17145
17188
  this._ref.id(this._ref._id.toString());
17146
17189
  }
17147
17190
  getPosition() {
@@ -17282,7 +17325,7 @@
17282
17325
  y: 0
17283
17326
  };
17284
17327
  if (params.position2) {
17285
- (_a = params.radius) !== null && _a !== undefined ? _a : params.radius = {
17328
+ (_a = params.radius) !== null && _a !== void 0 ? _a : params.radius = {
17286
17329
  x: 0,
17287
17330
  y: 0
17288
17331
  };
@@ -17295,8 +17338,8 @@
17295
17338
  };
17296
17339
  }
17297
17340
  this._ref = new Konva.Ellipse({
17298
- stroke: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
17299
- strokeWidth: (_c = params.lineWidth) !== null && _c !== undefined ? _c : 4,
17341
+ stroke: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
17342
+ strokeWidth: (_c = params.lineWidth) !== null && _c !== void 0 ? _c : 4,
17300
17343
  globalCompositeOperation: "source-over",
17301
17344
  lineCap: "round",
17302
17345
  lineJoin: "round",
@@ -17319,7 +17362,7 @@
17319
17362
  x: this._ref.x(),
17320
17363
  y: this._ref.y() + params.radius.y
17321
17364
  }));
17322
- this._ref.on("transform", (e => {
17365
+ this._ref.on("transform", e => {
17323
17366
  const attrs = e.target.attrs;
17324
17367
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
17325
17368
  const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
@@ -17354,8 +17397,8 @@
17354
17397
  x: 1,
17355
17398
  y: 1
17356
17399
  });
17357
- }));
17358
- this._ref.on("transformend", (() => {
17400
+ });
17401
+ this._ref.on("transformend", () => {
17359
17402
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
17360
17403
  const position = absoluteTransform.point({
17361
17404
  x: this._ref.x(),
@@ -17372,8 +17415,8 @@
17372
17415
  y: this._ref.y() + this._ref.radiusY()
17373
17416
  });
17374
17417
  this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld(radiusY));
17375
- }));
17376
- this._ref.on("dragend", (() => {
17418
+ });
17419
+ this._ref.on("dragend", () => {
17377
17420
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
17378
17421
  const position = absoluteTransform.point({
17379
17422
  x: this._ref.x(),
@@ -17390,7 +17433,7 @@
17390
17433
  y: this._ref.y() + this._ref.radiusY()
17391
17434
  });
17392
17435
  this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld(radiusY));
17393
- }));
17436
+ });
17394
17437
  this._ref.id(this._ref._id.toString());
17395
17438
  }
17396
17439
  getPosition() {
@@ -17515,8 +17558,8 @@
17515
17558
  y: 100
17516
17559
  };
17517
17560
  this._ref = new Konva.Arrow({
17518
- stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
17519
- fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
17561
+ stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
17562
+ fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
17520
17563
  strokeWidth: 4,
17521
17564
  globalCompositeOperation: "source-over",
17522
17565
  lineCap: "round",
@@ -17533,7 +17576,7 @@
17533
17576
  x: params.end.x,
17534
17577
  y: params.end.y
17535
17578
  }));
17536
- this._ref.on("transformend", (e => {
17579
+ this._ref.on("transformend", e => {
17537
17580
  const attrs = e.target.attrs;
17538
17581
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
17539
17582
  const points = this._ref.points();
@@ -17548,8 +17591,8 @@
17548
17591
  });
17549
17592
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(transformStart));
17550
17593
  this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld(transformEnd));
17551
- }));
17552
- this._ref.on("dragend", (e => {
17594
+ });
17595
+ this._ref.on("dragend", e => {
17553
17596
  const points = this._ref.points();
17554
17597
  const absoluteTransform = e.target.getAbsoluteTransform();
17555
17598
  const transformStart = absoluteTransform.point({
@@ -17562,7 +17605,7 @@
17562
17605
  });
17563
17606
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(transformStart));
17564
17607
  this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld(transformEnd));
17565
- }));
17608
+ });
17566
17609
  this._ref.id(this._ref._id.toString());
17567
17610
  }
17568
17611
  ref() {
@@ -17749,15 +17792,15 @@
17749
17792
  x: params.position.x,
17750
17793
  y: params.position.y,
17751
17794
  image: this._canvasImage,
17752
- width: (_a = params.width) !== null && _a !== undefined ? _a : 0,
17753
- height: (_b = params.height) !== null && _b !== undefined ? _b : 0,
17795
+ width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
17796
+ height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
17754
17797
  draggable: true
17755
17798
  });
17756
17799
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
17757
17800
  x: params.position.x,
17758
17801
  y: params.position.y
17759
17802
  }));
17760
- this._ref.on("transform", (e => {
17803
+ this._ref.on("transform", e => {
17761
17804
  const attrs = e.target.attrs;
17762
17805
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
17763
17806
  const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
@@ -17786,8 +17829,8 @@
17786
17829
  x: 1,
17787
17830
  y: 1
17788
17831
  });
17789
- }));
17790
- this._ref.on("transformend", (() => {
17832
+ });
17833
+ this._ref.on("transformend", () => {
17791
17834
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
17792
17835
  const position = absoluteTransform.point({
17793
17836
  x: this._ref.x(),
@@ -17798,8 +17841,8 @@
17798
17841
  x: position.x + this._ref.width(),
17799
17842
  y: position.y + this._ref.height()
17800
17843
  }));
17801
- }));
17802
- this._ref.on("dragend", (() => {
17844
+ });
17845
+ this._ref.on("dragend", () => {
17803
17846
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
17804
17847
  const position = absoluteTransform.point({
17805
17848
  x: this._ref.x(),
@@ -17810,7 +17853,7 @@
17810
17853
  x: position.x + this._ref.width(),
17811
17854
  y: position.y + this._ref.height()
17812
17855
  }));
17813
- }));
17856
+ });
17814
17857
  this._ref.id(this._ref._id.toString());
17815
17858
  }
17816
17859
  getSrc() {
@@ -17964,10 +18007,10 @@
17964
18007
  this._ref = new Konva.Shape({
17965
18008
  x: params.position.x,
17966
18009
  y: params.position.y,
17967
- width: (_a = params.width) !== null && _a !== undefined ? _a : 200,
17968
- height: (_b = params.height) !== null && _b !== undefined ? _b : 200,
17969
- stroke: (_c = params.color) !== null && _c !== undefined ? _c : "#ff0000",
17970
- strokeWidth: (_d = params.lineWidth) !== null && _d !== undefined ? _d : 4,
18010
+ width: (_a = params.width) !== null && _a !== void 0 ? _a : 200,
18011
+ height: (_b = params.height) !== null && _b !== void 0 ? _b : 200,
18012
+ stroke: (_c = params.color) !== null && _c !== void 0 ? _c : "#ff0000",
18013
+ strokeWidth: (_d = params.lineWidth) !== null && _d !== void 0 ? _d : 4,
17971
18014
  draggable: true,
17972
18015
  strokeScaleEnabled: false,
17973
18016
  globalCompositeOperation: "source-over",
@@ -18053,7 +18096,7 @@
18053
18096
  x: params.position2.x,
18054
18097
  y: params.position2.y
18055
18098
  }));
18056
- this._ref.on("transform", (e => {
18099
+ this._ref.on("transform", e => {
18057
18100
  const attrs = e.target.attrs;
18058
18101
  const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
18059
18102
  const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
@@ -18073,8 +18116,8 @@
18073
18116
  x: 1,
18074
18117
  y: 1
18075
18118
  });
18076
- }));
18077
- this._ref.on("transformend", (e => {
18119
+ });
18120
+ this._ref.on("transformend", e => {
18078
18121
  const attrs = e.target.attrs;
18079
18122
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
18080
18123
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
@@ -18087,8 +18130,8 @@
18087
18130
  x: position.x + this._ref.width(),
18088
18131
  y: position.y + this._ref.height()
18089
18132
  }));
18090
- }));
18091
- this._ref.on("dragend", (() => {
18133
+ });
18134
+ this._ref.on("dragend", () => {
18092
18135
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
18093
18136
  const position = absoluteTransform.point({
18094
18137
  x: this._ref.x(),
@@ -18099,7 +18142,7 @@
18099
18142
  x: position.x + this._ref.width(),
18100
18143
  y: position.y + this._ref.height()
18101
18144
  }));
18102
- }));
18145
+ });
18103
18146
  this._ref.getSelfRect = () => ({
18104
18147
  x: 0 - ARC_RADIUS,
18105
18148
  y: 0 - ARC_RADIUS,
@@ -18248,10 +18291,10 @@
18248
18291
  if (timeout) {
18249
18292
  clearTimeout(timeout);
18250
18293
  }
18251
- timeout = setTimeout((() => {
18294
+ timeout = setTimeout(() => {
18252
18295
  timeout = null;
18253
18296
  func(...args);
18254
- }), wait);
18297
+ }, wait);
18255
18298
  };
18256
18299
  }
18257
18300
 
@@ -18264,7 +18307,7 @@
18264
18307
  this.fontSize = 34;
18265
18308
  this.changeActiveDragger = event => {
18266
18309
  const draggerName = event.data;
18267
- this._markupContainer.className = this._container.className.split(" ").filter((x => !x.startsWith("oda-cursor-"))).filter((x => x)).concat(`oda-cursor-${draggerName.toLowerCase()}`).join(" ");
18310
+ this._markupContainer.className = this._container.className.split(" ").filter(x => !x.startsWith("oda-cursor-")).filter(x => x).concat(`oda-cursor-${draggerName.toLowerCase()}`).join(" ");
18268
18311
  this.removeTextInput();
18269
18312
  this.removeImageInput();
18270
18313
  this.enableEditMode(draggerName);
@@ -18276,9 +18319,9 @@
18276
18319
  if (!this._konvaStage) return;
18277
18320
  this._konvaStage.width(width);
18278
18321
  this._konvaStage.height(height);
18279
- this.getObjects().forEach((markupObject => {
18322
+ this.getObjects().forEach(markupObject => {
18280
18323
  markupObject.updateScreenCoordinates();
18281
- }));
18324
+ });
18282
18325
  };
18283
18326
  this.resizeViewer = event => {
18284
18327
  const {width: width, height: height} = event;
@@ -18286,19 +18329,19 @@
18286
18329
  if (!this._konvaStage) return;
18287
18330
  this._konvaStage.width(width);
18288
18331
  this._konvaStage.height(height);
18289
- this.getObjects().forEach((markupObject => {
18332
+ this.getObjects().forEach(markupObject => {
18290
18333
  markupObject.updateScreenCoordinates();
18291
- }));
18334
+ });
18292
18335
  };
18293
18336
  this.pan = () => {
18294
- this.getObjects().forEach((markupObject => {
18337
+ this.getObjects().forEach(markupObject => {
18295
18338
  markupObject.updateScreenCoordinates();
18296
- }));
18339
+ });
18297
18340
  };
18298
18341
  this.zoomAt = () => {
18299
- this.getObjects().forEach((markupObject => {
18342
+ this.getObjects().forEach(markupObject => {
18300
18343
  markupObject.updateScreenCoordinates();
18301
- }));
18344
+ });
18302
18345
  };
18303
18346
  this.redirectToViewer = event => {
18304
18347
  if (this._viewer) this._viewer.emit(event);
@@ -18313,7 +18356,7 @@
18313
18356
  initialize(container, containerEvents, viewer, worldTransformer) {
18314
18357
  if (!Konva) throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');
18315
18358
  this._viewer = viewer;
18316
- this._worldTransformer = worldTransformer !== null && worldTransformer !== undefined ? worldTransformer : new WorldTransform;
18359
+ this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform;
18317
18360
  this._container = container;
18318
18361
  this._markupContainer = document.createElement("div");
18319
18362
  this._markupContainer.id = "markup-container";
@@ -18341,9 +18384,9 @@
18341
18384
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
18342
18385
  }
18343
18386
  this.destroyKonva();
18344
- (_a = this._resizeObserver) === null || _a === undefined ? undefined : _a.disconnect();
18387
+ (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
18345
18388
  this._resizeObserver = undefined;
18346
- (_b = this._markupContainer) === null || _b === undefined ? undefined : _b.remove();
18389
+ (_b = this._markupContainer) === null || _b === void 0 ? void 0 : _b.remove();
18347
18390
  this._markupContainer = undefined;
18348
18391
  this._container = undefined;
18349
18392
  this._viewer = undefined;
@@ -18355,7 +18398,7 @@
18355
18398
  this.removeTextInput();
18356
18399
  this.removeImageInput();
18357
18400
  this.clearSelected();
18358
- this.getObjects().forEach((obj => obj.delete()));
18401
+ this.getObjects().forEach(obj => obj.delete());
18359
18402
  }
18360
18403
  getMarkupColor() {
18361
18404
  return this._markupColor.asRGB();
@@ -18374,17 +18417,17 @@
18374
18417
  colorizeAllMarkup(r, g, b) {
18375
18418
  this.setMarkupColor(r, g, b);
18376
18419
  const hexColor = new MarkupColor(r, g, b).asHex();
18377
- this.getObjects().filter((obj => {
18420
+ this.getObjects().filter(obj => {
18378
18421
  var _a;
18379
- return (_a = obj.setColor) === null || _a === undefined ? undefined : _a.call(obj, hexColor);
18380
- }));
18422
+ return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
18423
+ });
18381
18424
  }
18382
18425
  colorizeSelectedMarkups(r, g, b) {
18383
18426
  const hexColor = new MarkupColor(r, g, b).asHex();
18384
- this.getSelectedObjects().filter((obj => {
18427
+ this.getSelectedObjects().filter(obj => {
18385
18428
  var _a;
18386
- return (_a = obj.setColor) === null || _a === undefined ? undefined : _a.call(obj, hexColor);
18387
- }));
18429
+ return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
18430
+ });
18388
18431
  }
18389
18432
  setViewpoint(viewpoint) {
18390
18433
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -18399,51 +18442,51 @@
18399
18442
  x: 0,
18400
18443
  y: 0
18401
18444
  });
18402
- const markupColor = ((_a = viewpoint.custom_fields) === null || _a === undefined ? undefined : _a.markup_color) || {
18445
+ const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || {
18403
18446
  r: 255,
18404
18447
  g: 0,
18405
18448
  b: 0
18406
18449
  };
18407
18450
  this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
18408
- (_b = viewpoint.lines) === null || _b === undefined ? undefined : _b.forEach((line => {
18451
+ (_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach(line => {
18409
18452
  const linePoints = [];
18410
- line.points.forEach((point => {
18453
+ line.points.forEach(point => {
18411
18454
  const screenPoint = this._worldTransformer.worldToScreen(point);
18412
18455
  linePoints.push(screenPoint.x);
18413
18456
  linePoints.push(screenPoint.y);
18414
- }));
18457
+ });
18415
18458
  this.addLine(linePoints, line.color, line.type, line.width, line.id);
18416
- }));
18417
- (_c = viewpoint.texts) === null || _c === undefined ? undefined : _c.forEach((text => {
18459
+ });
18460
+ (_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach(text => {
18418
18461
  const screenPoint = this._worldTransformer.worldToScreen(text.position);
18419
18462
  this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
18420
- }));
18421
- (_d = viewpoint.rectangles) === null || _d === undefined ? undefined : _d.forEach((rect => {
18463
+ });
18464
+ (_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach(rect => {
18422
18465
  const screenPoint = this._worldTransformer.worldToScreen(rect.position);
18423
18466
  const screenPoint2 = rect.position2 ? this._worldTransformer.worldToScreen(rect.position2) : null;
18424
18467
  this.addRectangle(screenPoint, screenPoint2, rect.width, rect.height, rect.line_width, rect.color, rect.id);
18425
- }));
18426
- (_e = viewpoint.ellipses) === null || _e === undefined ? undefined : _e.forEach((ellipse => {
18468
+ });
18469
+ (_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach(ellipse => {
18427
18470
  const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
18428
18471
  const screenPoint2 = ellipse.position2 ? this._worldTransformer.worldToScreen(ellipse.position2) : null;
18429
18472
  const screenPoint3 = ellipse.position3 ? this._worldTransformer.worldToScreen(ellipse.position3) : null;
18430
18473
  this.addEllipse(screenPoint, screenPoint2, screenPoint3, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
18431
- }));
18432
- (_f = viewpoint.arrows) === null || _f === undefined ? undefined : _f.forEach((arrow => {
18474
+ });
18475
+ (_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach(arrow => {
18433
18476
  const startPoint = this._worldTransformer.worldToScreen(arrow.start);
18434
18477
  const endPoint = this._worldTransformer.worldToScreen(arrow.end);
18435
18478
  this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
18436
- }));
18437
- (_g = viewpoint.clouds) === null || _g === undefined ? undefined : _g.forEach((cloud => {
18479
+ });
18480
+ (_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach(cloud => {
18438
18481
  const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
18439
18482
  const screenPoint2 = cloud.position2 ? this._worldTransformer.worldToScreen(cloud.position2) : null;
18440
18483
  this.addCloud(screenPoint, screenPoint2, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
18441
- }));
18442
- (_h = viewpoint.images) === null || _h === undefined ? undefined : _h.forEach((image => {
18484
+ });
18485
+ (_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach(image => {
18443
18486
  const screenPoint = this._worldTransformer.worldToScreen(image.position);
18444
18487
  const screenPoint2 = image.position2 ? this._worldTransformer.worldToScreen(image.position2) : null;
18445
18488
  this.addImage(screenPoint, screenPoint2, image.src, image.width, image.height, image.id);
18446
- }));
18489
+ });
18447
18490
  }
18448
18491
  getViewpoint(viewpoint) {
18449
18492
  if (!viewpoint) viewpoint = {};
@@ -18485,23 +18528,23 @@
18485
18528
  }
18486
18529
  getObjects() {
18487
18530
  const objects = [];
18488
- Object.keys(MarkupMode2Konva).forEach((type => {
18531
+ Object.keys(MarkupMode2Konva).forEach(type => {
18489
18532
  const konvaShape = MarkupMode2Konva[type];
18490
- this.konvaLayerFind(type).forEach((ref => objects.push(konvaShape.initializer(ref, null, this._worldTransformer))));
18491
- }));
18533
+ this.konvaLayerFind(type).forEach(ref => objects.push(konvaShape.initializer(ref, null, this._worldTransformer)));
18534
+ });
18492
18535
  return objects;
18493
18536
  }
18494
18537
  getSelectedObjects() {
18495
18538
  if (!this._konvaTransformer) return [];
18496
- return this._konvaTransformer.nodes().map((ref => {
18539
+ return this._konvaTransformer.nodes().map(ref => {
18497
18540
  const name = ref.className;
18498
- const konvaShape = Object.values(MarkupMode2Konva).find((shape => shape.name === name));
18541
+ const konvaShape = Object.values(MarkupMode2Konva).find(shape => shape.name === name);
18499
18542
  return konvaShape ? konvaShape.initializer(ref, null, this._worldTransformer) : null;
18500
- })).filter((x => x));
18543
+ }).filter(x => x);
18501
18544
  }
18502
18545
  selectObjects(objects) {
18503
18546
  if (!this._konvaTransformer) return;
18504
- const selectedObjs = this._konvaTransformer.nodes().concat(objects.map((x => x.ref())));
18547
+ const selectedObjs = this._konvaTransformer.nodes().concat(objects.map(x => x.ref()));
18505
18548
  this._konvaTransformer.nodes(selectedObjs);
18506
18549
  }
18507
18550
  clearSelected() {
@@ -18514,7 +18557,7 @@
18514
18557
  if (!this._konvaLayer) return [];
18515
18558
  const konvaShape = MarkupMode2Konva[type];
18516
18559
  if (!konvaShape || !konvaShape.initializer) return [];
18517
- return this._konvaLayer.find(konvaShape.name).filter((ref => ref.parent === this._konvaLayer || ref.parent === this._groupImages || ref.parent === this._groupGeometry || ref.parent === this._groupTexts));
18560
+ return this._konvaLayer.find(konvaShape.name).filter(ref => ref.parent === this._konvaLayer || ref.parent === this._groupImages || ref.parent === this._groupGeometry || ref.parent === this._groupTexts);
18518
18561
  }
18519
18562
  initializeKonva() {
18520
18563
  const stage = new Konva.Stage({
@@ -18545,7 +18588,7 @@
18545
18588
  let lastLine;
18546
18589
  let mouseDownPos;
18547
18590
  let lastObj;
18548
- stage.on("mousedown touchstart", (e => {
18591
+ stage.on("mousedown touchstart", e => {
18549
18592
  if (!this._markupIsActive || e.target !== stage || this._markupMode === "Text" || this._markupMode === "Image") return;
18550
18593
  if (e.target === stage && transformer.nodes().length > 0) {
18551
18594
  transformer.nodes([]);
@@ -18553,12 +18596,12 @@
18553
18596
  }
18554
18597
  const pos = this.getRelativePointerPosition(stage);
18555
18598
  mouseDownPos = pos;
18556
- isPaint = [ "Arrow", "Cloud", "Ellipse", "Line", "Rectangle" ].some((m => m === this._markupMode));
18599
+ isPaint = [ "Arrow", "Cloud", "Ellipse", "Line", "Rectangle" ].some(m => m === this._markupMode);
18557
18600
  if (this._markupMode === "Line") {
18558
18601
  lastLine = this.addLine([ pos.x, pos.y, pos.x, pos.y ]);
18559
18602
  }
18560
- }));
18561
- stage.on("mouseup touchend", (() => {
18603
+ });
18604
+ stage.on("mouseup touchend", () => {
18562
18605
  if (!this._markupIsActive) return;
18563
18606
  if (isPaint) {
18564
18607
  const pos = this.getRelativePointerPosition(stage);
@@ -18599,8 +18642,8 @@
18599
18642
  }
18600
18643
  lastObj = undefined;
18601
18644
  isPaint = false;
18602
- }));
18603
- stage.on("mousemove touchmove", (() => {
18645
+ });
18646
+ stage.on("mousemove touchmove", () => {
18604
18647
  if (!this._markupIsActive) return;
18605
18648
  if (!isPaint) {
18606
18649
  return;
@@ -18655,8 +18698,8 @@
18655
18698
  y: startY
18656
18699
  }, null, dX, dY);
18657
18700
  }
18658
- }));
18659
- stage.on("click tap", (e => {
18701
+ });
18702
+ stage.on("click tap", e => {
18660
18703
  if (!this._markupIsActive) return;
18661
18704
  if (e.target === stage) {
18662
18705
  if (this._markupMode === "Text") {
@@ -18698,7 +18741,7 @@
18698
18741
  this.removeImageInput();
18699
18742
  }
18700
18743
  }
18701
- if (transformer.nodes().filter((x => x.className === "Cloud" || x.className === "Image")).length > 0 || e.target.className === "Cloud" || e.target.className === "Image") {
18744
+ if (transformer.nodes().filter(x => x.className === "Cloud" || x.className === "Image").length > 0 || e.target.className === "Cloud" || e.target.className === "Image") {
18702
18745
  transformer.rotateEnabled(false);
18703
18746
  } else {
18704
18747
  transformer.rotateEnabled(true);
@@ -18715,26 +18758,26 @@
18715
18758
  const nodes = transformer.nodes().concat([ e.target ]);
18716
18759
  transformer.nodes(nodes);
18717
18760
  }
18718
- }));
18761
+ });
18719
18762
  const container = stage.container();
18720
18763
  container.tabIndex = 1;
18721
18764
  container.focus();
18722
- container.addEventListener("keydown", (e => {
18765
+ container.addEventListener("keydown", e => {
18723
18766
  if (!this._markupIsActive) return;
18724
18767
  if (e.code === "Delete") {
18725
- this.getSelectedObjects().forEach((obj => obj.delete()));
18768
+ this.getSelectedObjects().forEach(obj => obj.delete());
18726
18769
  this.clearSelected();
18727
18770
  return;
18728
18771
  }
18729
18772
  e.preventDefault();
18730
- }));
18773
+ });
18731
18774
  }
18732
18775
  destroyKonva() {
18733
18776
  var _a;
18734
18777
  this.removeTextInput();
18735
18778
  this.removeImageInput();
18736
18779
  this.clearOverlay();
18737
- (_a = this._konvaStage) === null || _a === undefined ? undefined : _a.destroy();
18780
+ (_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.destroy();
18738
18781
  this._groupImages = undefined;
18739
18782
  this._groupGeometry = undefined;
18740
18783
  this._groupTexts = undefined;
@@ -18744,7 +18787,7 @@
18744
18787
  }
18745
18788
  getMarkupLines() {
18746
18789
  const lines = [];
18747
- this.konvaLayerFind("Line").forEach((ref => {
18790
+ this.konvaLayerFind("Line").forEach(ref => {
18748
18791
  const wcsPoints = ref.getAttr("wcsPoints");
18749
18792
  if (!wcsPoints) return;
18750
18793
  const konvaLine = new KonvaLine(null, ref, this._worldTransformer);
@@ -18756,12 +18799,12 @@
18756
18799
  width: konvaLine.getLineWidth() || this.lineWidth
18757
18800
  };
18758
18801
  lines.push(line);
18759
- }));
18802
+ });
18760
18803
  return lines;
18761
18804
  }
18762
18805
  getMarkupTexts() {
18763
18806
  const texts = [];
18764
- this.konvaLayerFind("Text").forEach((ref => {
18807
+ this.konvaLayerFind("Text").forEach(ref => {
18765
18808
  const textSize = .02;
18766
18809
  const textScale = this._worldTransformer.getScale();
18767
18810
  const wcsPosition = ref.getAttr("wcsStart");
@@ -18777,12 +18820,12 @@
18777
18820
  font_size: shape.getFontSize() * stageAbsoluteTransform.getMatrix()[0]
18778
18821
  };
18779
18822
  texts.push(text);
18780
- }));
18823
+ });
18781
18824
  return texts;
18782
18825
  }
18783
18826
  getMarkupRectangles() {
18784
18827
  const rectangles = [];
18785
- this.konvaLayerFind("Rectangle").forEach((ref => {
18828
+ this.konvaLayerFind("Rectangle").forEach(ref => {
18786
18829
  const wcsStart = ref.getAttr("wcsStart");
18787
18830
  const wcsEnd = ref.getAttr("wcsEnd");
18788
18831
  const screenStart = this._worldTransformer.worldToScreen(wcsStart);
@@ -18798,12 +18841,12 @@
18798
18841
  color: shape.getColor()
18799
18842
  };
18800
18843
  rectangles.push(rectangle);
18801
- }));
18844
+ });
18802
18845
  return rectangles;
18803
18846
  }
18804
18847
  getMarkupEllipses() {
18805
18848
  const ellipses = [];
18806
- this.konvaLayerFind("Ellipse").forEach((ref => {
18849
+ this.konvaLayerFind("Ellipse").forEach(ref => {
18807
18850
  const wcsPosition = ref.getAttr("wcsPosition");
18808
18851
  const wcsPosition2 = ref.getAttr("wcsRadiusX");
18809
18852
  const wcsPosition3 = ref.getAttr("wcsRadiusY");
@@ -18823,12 +18866,12 @@
18823
18866
  color: shape.getColor()
18824
18867
  };
18825
18868
  ellipses.push(ellipse);
18826
- }));
18869
+ });
18827
18870
  return ellipses;
18828
18871
  }
18829
18872
  getMarkupArrows() {
18830
18873
  const arrows = [];
18831
- this.konvaLayerFind("Arrow").forEach((ref => {
18874
+ this.konvaLayerFind("Arrow").forEach(ref => {
18832
18875
  const wcsStart = ref.getAttr("wcsStart");
18833
18876
  const wcsEnd = ref.getAttr("wcsEnd");
18834
18877
  const shape = new KonvaArrow(null, ref, this._worldTransformer);
@@ -18839,12 +18882,12 @@
18839
18882
  color: shape.getColor()
18840
18883
  };
18841
18884
  arrows.push(arrow);
18842
- }));
18885
+ });
18843
18886
  return arrows;
18844
18887
  }
18845
18888
  getMarkupImages() {
18846
18889
  const images = [];
18847
- this.konvaLayerFind("Image").forEach((ref => {
18890
+ this.konvaLayerFind("Image").forEach(ref => {
18848
18891
  const wcsStart = ref.getAttr("wcsStart");
18849
18892
  const wcsEnd = ref.getAttr("wcsEnd");
18850
18893
  const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
@@ -18859,12 +18902,12 @@
18859
18902
  height: shape.getHeight() * scale
18860
18903
  };
18861
18904
  images.push(image);
18862
- }));
18905
+ });
18863
18906
  return images;
18864
18907
  }
18865
18908
  getMarkupClouds() {
18866
18909
  const clouds = [];
18867
- this.konvaLayerFind("Cloud").forEach((ref => {
18910
+ this.konvaLayerFind("Cloud").forEach(ref => {
18868
18911
  const wcsStart = ref.getAttr("wcsStart");
18869
18912
  const wcsEnd = ref.getAttr("wcsEnd");
18870
18913
  const screenStart = this._worldTransformer.worldToScreen(wcsStart);
@@ -18880,7 +18923,7 @@
18880
18923
  color: shape.getColor()
18881
18924
  };
18882
18925
  clouds.push(cloud);
18883
- }));
18926
+ });
18884
18927
  return clouds;
18885
18928
  }
18886
18929
  combineMarkupWithDrawing() {
@@ -18941,23 +18984,23 @@
18941
18984
  };
18942
18985
  if (text) this._textInputRef.value = text;
18943
18986
  document.body.appendChild(this._textInputRef);
18944
- setTimeout((() => {
18987
+ setTimeout(() => {
18945
18988
  this._textInputRef.focus();
18946
- }), 50);
18989
+ }, 50);
18947
18990
  } else {
18948
18991
  this.removeTextInput();
18949
18992
  }
18950
18993
  }
18951
18994
  removeTextInput() {
18952
18995
  var _a;
18953
- (_a = this._textInputRef) === null || _a === undefined ? undefined : _a.remove();
18996
+ (_a = this._textInputRef) === null || _a === void 0 ? void 0 : _a.remove();
18954
18997
  this._textInputRef = null;
18955
18998
  this._textInputPos = null;
18956
18999
  this._textInputAngle = 0;
18957
19000
  }
18958
19001
  createImageInput(pos) {
18959
19002
  if (!this._imageInputRef) {
18960
- const convertBase64 = file => new Promise(((resolve, reject) => {
19003
+ const convertBase64 = file => new Promise((resolve, reject) => {
18961
19004
  const fileReader = new FileReader;
18962
19005
  fileReader.readAsDataURL(file);
18963
19006
  fileReader.onload = () => {
@@ -18966,7 +19009,7 @@
18966
19009
  fileReader.onerror = error => {
18967
19010
  reject(error);
18968
19011
  };
18969
- }));
19012
+ });
18970
19013
  this._imageInputPos = pos;
18971
19014
  this._imageInputRef = document.createElement("input");
18972
19015
  this._imageInputRef.style.display = "none";
@@ -18984,23 +19027,23 @@
18984
19027
  this.removeImageInput();
18985
19028
  };
18986
19029
  document.body.appendChild(this._imageInputRef);
18987
- setTimeout((() => {
19030
+ setTimeout(() => {
18988
19031
  this._imageInputRef.click();
18989
- }), 50);
19032
+ }, 50);
18990
19033
  } else {
18991
19034
  this.removeImageInput();
18992
19035
  }
18993
19036
  }
18994
19037
  removeImageInput() {
18995
19038
  var _a;
18996
- (_a = this._imageInputRef) === null || _a === undefined ? undefined : _a.remove();
19039
+ (_a = this._imageInputRef) === null || _a === void 0 ? void 0 : _a.remove();
18997
19040
  this._imageInputRef = null;
18998
19041
  this._imageInputPos = null;
18999
19042
  }
19000
19043
  addText(text, position, angle, color, textSize, fontSize, id) {
19001
19044
  var _a;
19002
19045
  if (!text) return;
19003
- (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
19046
+ (_a = this.getSelectedObjects().shift()) === null || _a === void 0 ? void 0 : _a.delete();
19004
19047
  this.clearSelected();
19005
19048
  this.removeTextInput();
19006
19049
  const tolerance = 1e-6;
@@ -19079,7 +19122,7 @@
19079
19122
  addImage(position, position2, src, width, height, id) {
19080
19123
  var _a;
19081
19124
  if (!position || !src) return;
19082
- (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
19125
+ (_a = this.getSelectedObjects().shift()) === null || _a === void 0 ? void 0 : _a.delete();
19083
19126
  this.clearSelected();
19084
19127
  this.removeImageInput();
19085
19128
  const konvaImage = new KonvaImage({
@@ -19151,7 +19194,7 @@
19151
19194
  dispose() {
19152
19195
  var _a;
19153
19196
  super.dispose();
19154
- (_a = this.textRef) === null || _a === undefined ? undefined : _a.remove();
19197
+ (_a = this.textRef) === null || _a === void 0 ? void 0 : _a.remove();
19155
19198
  this.textRef = null;
19156
19199
  }
19157
19200
  _finishInput() {
@@ -19159,7 +19202,7 @@
19159
19202
  if (this.textRef && this.textRef.value.trimLeft()) {
19160
19203
  this._updateFrame();
19161
19204
  }
19162
- (_a = this.textRef) === null || _a === undefined ? undefined : _a.remove();
19205
+ (_a = this.textRef) === null || _a === void 0 ? void 0 : _a.remove();
19163
19206
  this.textRef = null;
19164
19207
  }
19165
19208
  start(x, y, absoluteX, absoluteY) {
@@ -19204,7 +19247,7 @@
19204
19247
  const projMtrx = view.projectionMatrix;
19205
19248
  const mtrxNumber = projMtrx.get(1, 1);
19206
19249
  const tol = 1.0e-6;
19207
- if (!(mtrxNumber < tol && mtrxNumber > -1e-6)) {
19250
+ if (!(mtrxNumber < tol && mtrxNumber > -tol)) {
19208
19251
  textScale = 1 / mtrxNumber;
19209
19252
  }
19210
19253
  const geomData = entityPtr.appendText(this.toGePoint(this.m_center), this.textRef.value.trimLeft());
@@ -19511,7 +19554,7 @@
19511
19554
  this._renderTime = 0;
19512
19555
  this.canvasEvents = CANVAS_EVENTS.slice();
19513
19556
  this.canvaseventlistener = (event) => this.emit(event);
19514
- this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== undefined ? _a : true;
19557
+ this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
19515
19558
  this._renderNeeded = false;
19516
19559
  this._isRunAsyncUpdate = false;
19517
19560
  this.render = this.render.bind(this);
@@ -19665,7 +19708,7 @@
19665
19708
  this._renderTime = time;
19666
19709
  this._renderNeeded = !this.visViewer().getActiveDevice().isValid();
19667
19710
  this.visViewer().update();
19668
- (_b = (_a = this._activeDragger) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
19711
+ (_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
19669
19712
  this.emitEvent({ type: "render", time, deltaTime });
19670
19713
  }
19671
19714
  resize() {
@@ -19935,7 +19978,7 @@
19935
19978
  newDragger = draggers.createDragger(name, this);
19936
19979
  if (newDragger) {
19937
19980
  this._activeDragger = newDragger;
19938
- (_b = (_a = this._activeDragger).initialize) === null || _b === undefined ? undefined : _b.call(_a);
19981
+ (_b = (_a = this._activeDragger).initialize) === null || _b === void 0 ? void 0 : _b.call(_a);
19939
19982
  }
19940
19983
  }
19941
19984
  const canvas = this.canvas;
@@ -20034,13 +20077,13 @@
20034
20077
  const projMatrix = this.visViewer().activeView.projectionMatrix;
20035
20078
  const tolerance = 1.0e-6;
20036
20079
  const x = projMatrix.get(0, 0);
20037
- if (x > tolerance || x < -1e-6)
20080
+ if (x > tolerance || x < -tolerance)
20038
20081
  result.x = 1 / x;
20039
20082
  const y = projMatrix.get(1, 1);
20040
- if (y > tolerance || y < -1e-6)
20083
+ if (y > tolerance || y < -tolerance)
20041
20084
  result.y = 1 / y;
20042
20085
  const z = projMatrix.get(2, 2);
20043
- if (z > tolerance || z < -1e-6)
20086
+ if (z > tolerance || z < -tolerance)
20044
20087
  result.z = 1 / z;
20045
20088
  return result;
20046
20089
  }
@@ -20078,7 +20121,7 @@
20078
20121
  if (!model.getReferences)
20079
20122
  return this;
20080
20123
  const abortController = new AbortController();
20081
- (_a = this._abortControllerForReferences) === null || _a === undefined ? undefined : _a.abort();
20124
+ (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
20082
20125
  this._abortControllerForReferences = abortController;
20083
20126
  let references = [];
20084
20127
  await model
@@ -20088,7 +20131,7 @@
20088
20131
  for (const file of references) {
20089
20132
  await this.client
20090
20133
  .downloadFile(file.id, undefined, abortController.signal)
20091
- .then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === undefined ? undefined : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
20134
+ .then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
20092
20135
  .catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
20093
20136
  }
20094
20137
  return this;
@@ -20224,23 +20267,23 @@
20224
20267
  return this;
20225
20268
  this.cancel();
20226
20269
  this.clear();
20227
- this.emitEvent({ type: "open", file: buffer });
20270
+ this.emitEvent({ type: "open", file: "", buffer });
20228
20271
  const visViewer = this.visViewer();
20229
- this.emitEvent({ type: "geometrystart", file: buffer });
20272
+ this.emitEvent({ type: "geometrystart", file: "", buffer });
20230
20273
  try {
20231
20274
  const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
20232
20275
  visViewer.parseFile(data);
20233
20276
  this.syncOptions();
20234
20277
  this.syncOverlay();
20235
20278
  this.update(true);
20236
- this.emitEvent({ type: "geometryprogress", data: 1, file: buffer });
20237
- this.emitEvent({ type: "databasechunk", data, file: buffer });
20279
+ this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
20280
+ this.emitEvent({ type: "databasechunk", data, file: "", buffer });
20238
20281
  }
20239
20282
  catch (error) {
20240
- this.emitEvent({ type: "geometryerror", data: error, file: buffer });
20283
+ this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
20241
20284
  throw error;
20242
20285
  }
20243
- this.emitEvent({ type: "geometryend", file: buffer });
20286
+ this.emitEvent({ type: "geometryend", file: "", buffer });
20244
20287
  return this;
20245
20288
  }
20246
20289
  /**
@@ -20254,28 +20297,28 @@
20254
20297
  return this;
20255
20298
  this.cancel();
20256
20299
  this.clear();
20257
- this.emitEvent({ type: "open", file: buffer });
20300
+ this.emitEvent({ type: "open", file: "", buffer });
20258
20301
  const visViewer = this.visViewer();
20259
- this.emitEvent({ type: "geometrystart", file: buffer });
20302
+ this.emitEvent({ type: "geometrystart", file: "", buffer });
20260
20303
  try {
20261
20304
  const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
20262
20305
  visViewer.parseVsfx(data);
20263
20306
  this.syncOptions();
20264
20307
  this.syncOverlay();
20265
20308
  this.update(true);
20266
- this.emitEvent({ type: "geometryprogress", data: 1, file: buffer });
20267
- this.emitEvent({ type: "databasechunk", data, file: buffer });
20309
+ this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
20310
+ this.emitEvent({ type: "databasechunk", data, file: "", buffer });
20268
20311
  }
20269
20312
  catch (error) {
20270
- this.emitEvent({ type: "geometryerror", data: error, file: buffer });
20313
+ this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
20271
20314
  throw error;
20272
20315
  }
20273
- this.emitEvent({ type: "geometryend", file: buffer });
20316
+ this.emitEvent({ type: "geometryend", file: "", buffer });
20274
20317
  return this;
20275
20318
  }
20276
20319
  cancel() {
20277
20320
  var _a;
20278
- (_a = this._abortControllerForReferences) === null || _a === undefined ? undefined : _a.abort();
20321
+ (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
20279
20322
  this._abortControllerForReferences = undefined;
20280
20323
  this.loaders.forEach((loader) => loader.cancel());
20281
20324
  this.emitEvent({ type: "cancel" });
@@ -20349,7 +20392,7 @@
20349
20392
  var _a;
20350
20393
  if (!this.visualizeJs)
20351
20394
  return;
20352
- const draggerName = (_a = this._activeDragger) === null || _a === undefined ? undefined : _a.name;
20395
+ const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
20353
20396
  this.setActiveDragger();
20354
20397
  this.clearSlices();
20355
20398
  this.clearOverlay();
@@ -20432,7 +20475,7 @@
20432
20475
  return this.getSelected().map((handle) => ({ handle }));
20433
20476
  }
20434
20477
  setSelection(selection) {
20435
- this.setSelected(selection === null || selection === undefined ? undefined : selection.map((component) => component.handle));
20478
+ this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map((component) => component.handle));
20436
20479
  }
20437
20480
  /**
20438
20481
  * Executes the command denoted by the given command. If the command is not found, tries to set active