kritzel-stencil 0.0.108 → 0.0.109

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.
Files changed (97) hide show
  1. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +853 -832
  2. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/stencil.cjs.js +1 -1
  5. package/dist/collection/classes/handlers/context-menu.handler.js +2 -47
  6. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  7. package/dist/collection/classes/handlers/move.handler.js +62 -55
  8. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  9. package/dist/collection/classes/handlers/resize.handler.js +122 -113
  10. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  11. package/dist/collection/classes/handlers/rotation.handler.js +74 -66
  12. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  13. package/dist/collection/classes/handlers/selection.handler.js +59 -50
  14. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  15. package/dist/collection/classes/objects/base-object.class.js +3 -0
  16. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  17. package/dist/collection/classes/objects/text.class.js +11 -1
  18. package/dist/collection/classes/objects/text.class.js.map +1 -1
  19. package/dist/collection/classes/tools/base-tool.class.js +3 -18
  20. package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
  21. package/dist/collection/classes/tools/brush-tool.class.js +79 -71
  22. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  23. package/dist/collection/classes/tools/eraser-tool.class.js +61 -56
  24. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  25. package/dist/collection/classes/tools/selection-tool.class.js +93 -73
  26. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  27. package/dist/collection/classes/tools/text-tool.class.js +73 -70
  28. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  29. package/dist/collection/classes/viewport.class.js +76 -69
  30. package/dist/collection/classes/viewport.class.js.map +1 -1
  31. package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +6 -0
  32. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +6 -0
  33. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +66 -120
  34. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  35. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -16
  36. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
  37. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +10 -2
  38. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +9 -4
  39. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  40. package/dist/collection/configs/default-engine-state.js +1 -1
  41. package/dist/collection/configs/default-engine-state.js.map +1 -1
  42. package/dist/collection/helpers/devices.helper.js +6 -0
  43. package/dist/collection/helpers/devices.helper.js.map +1 -0
  44. package/dist/collection/helpers/event.helper.js +43 -34
  45. package/dist/collection/helpers/event.helper.js.map +1 -1
  46. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  47. package/dist/collection/interfaces/object.interface.js.map +1 -1
  48. package/dist/collection/interfaces/tool.interface.js.map +1 -1
  49. package/dist/components/kritzel-context-menu.js +1 -1
  50. package/dist/components/kritzel-controls.js +1 -1
  51. package/dist/components/kritzel-editor.js +5 -5
  52. package/dist/components/kritzel-editor.js.map +1 -1
  53. package/dist/components/kritzel-engine.js +1 -1
  54. package/dist/components/{p-BNfHRlWL.js → p-7Ns73-wN.js} +237 -220
  55. package/dist/components/p-7Ns73-wN.js.map +1 -0
  56. package/dist/components/{p-Cbu5RSmC.js → p-BmAloSfd.js} +3 -4
  57. package/dist/components/p-BmAloSfd.js.map +1 -0
  58. package/dist/components/{p-CqJr3YCp.js → p-BmrZipyu.js} +617 -621
  59. package/dist/components/p-BmrZipyu.js.map +1 -0
  60. package/dist/components/{p-Box62paJ.js → p-Ch6TgHX3.js} +18 -8
  61. package/dist/components/p-Ch6TgHX3.js.map +1 -0
  62. package/dist/esm/kritzel-brush-style_18.entry.js +853 -832
  63. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  64. package/dist/esm/loader.js +1 -1
  65. package/dist/esm/stencil.js +1 -1
  66. package/dist/stencil/p-c976660c.entry.js +2 -0
  67. package/dist/stencil/p-c976660c.entry.js.map +1 -0
  68. package/dist/stencil/stencil.esm.js +1 -1
  69. package/dist/types/classes/handlers/context-menu.handler.d.ts +1 -2
  70. package/dist/types/classes/handlers/move.handler.d.ts +3 -6
  71. package/dist/types/classes/handlers/resize.handler.d.ts +3 -6
  72. package/dist/types/classes/handlers/rotation.handler.d.ts +3 -6
  73. package/dist/types/classes/handlers/selection.handler.d.ts +3 -6
  74. package/dist/types/classes/objects/base-object.class.d.ts +1 -0
  75. package/dist/types/classes/objects/text.class.d.ts +1 -0
  76. package/dist/types/classes/tools/base-tool.class.d.ts +3 -8
  77. package/dist/types/classes/tools/brush-tool.class.d.ts +3 -6
  78. package/dist/types/classes/tools/eraser-tool.class.d.ts +3 -6
  79. package/dist/types/classes/tools/selection-tool.class.d.ts +4 -7
  80. package/dist/types/classes/tools/text-tool.class.d.ts +2 -4
  81. package/dist/types/classes/viewport.class.d.ts +3 -6
  82. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +5 -10
  83. package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +0 -1
  84. package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +1 -0
  85. package/dist/types/components.d.ts +0 -2
  86. package/dist/types/helpers/devices.helper.d.ts +3 -0
  87. package/dist/types/helpers/event.helper.d.ts +2 -6
  88. package/dist/types/interfaces/engine-state.interface.d.ts +1 -1
  89. package/dist/types/interfaces/object.interface.d.ts +1 -0
  90. package/dist/types/interfaces/tool.interface.d.ts +3 -8
  91. package/package.json +1 -1
  92. package/dist/components/p-BNfHRlWL.js.map +0 -1
  93. package/dist/components/p-Box62paJ.js.map +0 -1
  94. package/dist/components/p-Cbu5RSmC.js.map +0 -1
  95. package/dist/components/p-CqJr3YCp.js.map +0 -1
  96. package/dist/stencil/p-3a7d7b58.entry.js +0 -2
  97. package/dist/stencil/p-3a7d7b58.entry.js.map +0 -1
@@ -127,7 +127,6 @@ const KritzelContextMenu = class {
127
127
  constructor(hostRef) {
128
128
  index.registerInstance(this, hostRef);
129
129
  this.actionSelected = index.createEvent(this, "actionSelected");
130
- this.close = index.createEvent(this, "close");
131
130
  }
132
131
  handleItemClick(item) {
133
132
  const isDisabled = typeof item.disabled === 'function' ? item.disabled() : item.disabled;
@@ -136,7 +135,7 @@ const KritzelContextMenu = class {
136
135
  }
137
136
  }
138
137
  render() {
139
- return (index.h(index.Host, { key: 'db318a0936f89f202ef5101447b723c0ba7aa139' }, index.h("div", { key: '53da01021464f605e08c5f910997bb8f21d481a1', class: "menu-container" }, this.items.map(item => (index.h("button", { key: `${item.label}-${this.items.indexOf(item)}`, class: { 'menu-item': true, 'disabled': typeof item.disabled === 'function' ? item.disabled() : item.disabled }, onClick: () => this.handleItemClick(item), onTouchStart: () => this.handleItemClick(item), disabled: typeof item.disabled === 'function' ? item.disabled() : item.disabled }, item.icon && index.h("kritzel-icon", { name: item.icon, size: 16 }), index.h("span", { class: "label" }, item.label)))))));
138
+ return (index.h(index.Host, { key: '92cf80d71faae3e33bc29d9e9b3a81b4b6ee6c87' }, index.h("div", { key: '838734ed3f1e3af86a5db7312c2206e90835a8f0', class: "menu-container" }, this.items.map(item => (index.h("button", { key: `${item.label}-${this.items.indexOf(item)}`, class: { 'menu-item': true, 'disabled': typeof item.disabled === 'function' ? item.disabled() : item.disabled }, onClick: () => this.handleItemClick(item), onTouchStart: () => this.handleItemClick(item), disabled: typeof item.disabled === 'function' ? item.disabled() : item.disabled }, item.icon && index.h("kritzel-icon", { name: item.icon, size: 16 }), index.h("span", { class: "label" }, item.label)))))));
140
139
  }
141
140
  get hostElement() { return index.getElement(this); }
142
141
  };
@@ -243,43 +242,52 @@ class KritzelEventHelper {
243
242
  static isMainMouseWheel(event) {
244
243
  return Math.abs(event.deltaY) > 0 && Math.abs(event.deltaX) === 0 && Number.isInteger(event.deltaY);
245
244
  }
246
- static detectDoubleTap() {
247
- const currentTime = Date.now();
248
- const tapLength = currentTime - KritzelEventHelper.lastTapTimestamp;
249
- if (KritzelEventHelper.twoFingerTouchDetected) {
250
- KritzelEventHelper.lastTapTimestamp = 0;
251
- KritzelEventHelper.twoFingerTouchDetected = false;
252
- if (KritzelEventHelper.tapTimeoutId) {
253
- clearTimeout(KritzelEventHelper.tapTimeoutId);
254
- KritzelEventHelper.tapTimeoutId = null;
245
+ static isPointerEventOnContextMenu(event) {
246
+ const path = event.composedPath();
247
+ const contextMenu = path.find(element => element.classList && element.classList.contains('context-menu'));
248
+ return !!contextMenu;
249
+ }
250
+ static onLongTouchPress(event, onSuccess, onCancel) {
251
+ if (event.pointerType !== 'touch') {
252
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
253
+ return () => { };
254
+ }
255
+ const longPressTimeout = 400;
256
+ const moveThreshold = 10;
257
+ const startX = event.clientX;
258
+ const startY = event.clientY;
259
+ const target = event.target;
260
+ const timer = setTimeout(() => {
261
+ removeListeners();
262
+ onSuccess(event);
263
+ }, longPressTimeout);
264
+ const cancel = () => {
265
+ clearTimeout(timer);
266
+ removeListeners();
267
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
268
+ };
269
+ const onPointerMove = (e) => {
270
+ if (Math.abs(e.clientX - startX) > moveThreshold || Math.abs(e.clientY - startY) > moveThreshold) {
271
+ cancel();
255
272
  }
256
- return false;
257
- }
258
- if (KritzelEventHelper.tapTimeoutId) {
259
- clearTimeout(KritzelEventHelper.tapTimeoutId);
260
- KritzelEventHelper.tapTimeoutId = null;
261
- }
262
- if (tapLength < KritzelEventHelper.doubleTapTimeout && tapLength > 0) {
263
- KritzelEventHelper.lastTapTimestamp = 0;
264
- return true;
265
- }
266
- else {
267
- KritzelEventHelper.lastTapTimestamp = currentTime;
268
- KritzelEventHelper.tapTimeoutId = setTimeout(() => {
269
- KritzelEventHelper.tapTimeoutId = null;
270
- KritzelEventHelper.twoFingerTouchDetected = false;
271
- }, KritzelEventHelper.doubleTapTimeout);
272
- return false;
273
- }
274
- }
275
- static notifyTwoFingerTouch() {
276
- KritzelEventHelper.twoFingerTouchDetected = true;
273
+ };
274
+ const onPointerUp = () => {
275
+ cancel();
276
+ };
277
+ const onPointerCancel = () => {
278
+ cancel();
279
+ };
280
+ const removeListeners = () => {
281
+ target.removeEventListener('pointermove', onPointerMove);
282
+ target.removeEventListener('pointerup', onPointerUp);
283
+ target.removeEventListener('pointercancel', onPointerCancel);
284
+ };
285
+ target.addEventListener('pointermove', onPointerMove, { passive: true });
286
+ target.addEventListener('pointerup', onPointerUp, { once: true });
287
+ target.addEventListener('pointercancel', onPointerCancel, { once: true });
288
+ return cancel;
277
289
  }
278
290
  }
279
- KritzelEventHelper.lastTapTimestamp = 0;
280
- KritzelEventHelper.tapTimeoutId = null;
281
- KritzelEventHelper.doubleTapTimeout = 300;
282
- KritzelEventHelper.twoFingerTouchDetected = false;
283
291
 
284
292
  class KritzelBaseCommand {
285
293
  constructor(store, initiator) {
@@ -540,6 +548,9 @@ class KritzelBaseObject {
540
548
  copiedObject.isMounted = false;
541
549
  return copiedObject;
542
550
  }
551
+ onSelectedClick() {
552
+ // This method can be overridden by subclasses to handle click events when the object is selected.
553
+ }
543
554
  revive(object) {
544
555
  Object.assign(this, object);
545
556
  return this;
@@ -676,28 +687,13 @@ class KritzelBaseTool {
676
687
  onDeactivate() {
677
688
  // default implementation
678
689
  }
679
- handleMouseDown(_event) {
680
- // default implementation
681
- }
682
- handleMouseMove(_event) {
683
- // default implementation
684
- }
685
- handleMouseUp(_event) {
686
- // default implementation
687
- }
688
- handleDoubleClick(_event) {
689
- // default implementation
690
- }
691
- handleDoubleTap(_event) {
692
- // default implementation
693
- }
694
- handleTouchStart(_event) {
690
+ handlePointerDown(_event) {
695
691
  // default implementation
696
692
  }
697
- handleTouchMove(_event) {
693
+ handlePointerMove(_event) {
698
694
  // default implementation
699
695
  }
700
- handleTouchEnd(_event) {
696
+ handlePointerUp(_event) {
701
697
  // default implementation
702
698
  }
703
699
  handleWheel(_event) {
@@ -720,90 +716,116 @@ class KritzelBrushTool extends KritzelBaseTool {
720
716
  highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
721
717
  };
722
718
  }
723
- handleMouseDown(event) {
724
- if (KritzelEventHelper.isLeftClick(event)) {
725
- this._store.state.isDrawing = true;
726
- const x = event.clientX - this._store.offsetX;
727
- const y = event.clientY - this._store.offsetY;
728
- this._store.state.currentPath = KritzelPath.create(this._store, {
729
- points: [[x, y]],
730
- translateX: -this._store.state.translateX,
731
- translateY: -this._store.state.translateY,
732
- scale: this._store.state.scale,
733
- fill: this.color,
734
- strokeWidth: this.size,
735
- });
719
+ handlePointerDown(event) {
720
+ if (event.pointerType === 'mouse') {
721
+ if (KritzelEventHelper.isLeftClick(event)) {
722
+ this._store.state.isDrawing = true;
723
+ const x = event.clientX - this._store.offsetX;
724
+ const y = event.clientY - this._store.offsetY;
725
+ this._store.state.currentPath = KritzelPath.create(this._store, {
726
+ points: [[x, y]],
727
+ translateX: -this._store.state.translateX,
728
+ translateY: -this._store.state.translateY,
729
+ scale: this._store.state.scale,
730
+ fill: this.color,
731
+ strokeWidth: this.size,
732
+ });
733
+ }
736
734
  }
737
- }
738
- handleMouseMove(event) {
739
- if (this._store.state.isDrawing) {
740
- const x = event.clientX - this._store.offsetX;
741
- const y = event.clientY - this._store.offsetY;
742
- this._store.state.currentPath = KritzelPath.create(this._store, {
743
- points: [...this._store.state.currentPath.points, [x, y]],
744
- translateX: -this._store.state.translateX,
745
- translateY: -this._store.state.translateY,
746
- scale: this._store.state.scale,
747
- fill: this.color,
748
- strokeWidth: this.size,
749
- });
750
- this._store.rerender();
735
+ if (event.pointerType === 'touch') {
736
+ const activePointers = Array.from(this._store.state.pointers.values());
737
+ if (activePointers.length === 1) {
738
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
739
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
740
+ this._store.state.isDrawing = true;
741
+ this._store.state.currentPath = KritzelPath.create(this._store, {
742
+ points: [[x, y]],
743
+ translateX: -this._store.state.translateX,
744
+ translateY: -this._store.state.translateY,
745
+ scale: this._store.state.scale,
746
+ fill: this.color,
747
+ strokeWidth: this.size,
748
+ });
749
+ this._store.rerender();
750
+ }
751
751
  }
752
752
  }
753
- handleMouseUp(_event) {
754
- if (this._store.state.isDrawing) {
755
- this._store.state.isDrawing = false;
756
- if (this._store.state.currentPath) {
757
- this._store.state.currentPath.zIndex = this._store.currentZIndex;
758
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
753
+ handlePointerMove(event) {
754
+ if (event.pointerType === 'mouse') {
755
+ if (this._store.state.isDrawing) {
756
+ const x = event.clientX - this._store.offsetX;
757
+ const y = event.clientY - this._store.offsetY;
758
+ this._store.state.currentPath = KritzelPath.create(this._store, {
759
+ points: [...this._store.state.currentPath.points, [x, y]],
760
+ translateX: -this._store.state.translateX,
761
+ translateY: -this._store.state.translateY,
762
+ scale: this._store.state.scale,
763
+ fill: this.color,
764
+ strokeWidth: this.size,
765
+ });
766
+ this._store.rerender();
759
767
  }
760
- this._store.state.currentPath = undefined;
761
768
  }
762
- }
763
- handleTouchStart(event) {
764
- if (this._store.state.touchCount === 1) {
765
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
766
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
767
- this._store.state.isDrawing = true;
768
- this._store.state.currentPath = KritzelPath.create(this._store, {
769
- points: [[x, y]],
770
- translateX: -this._store.state.translateX,
771
- translateY: -this._store.state.translateY,
772
- scale: this._store.state.scale,
773
- fill: this.color,
774
- strokeWidth: this.size,
775
- });
776
- this._store.rerender();
769
+ if (event.pointerType === 'touch') {
770
+ const activePointers = Array.from(this._store.state.pointers.values());
771
+ if (activePointers.length === 1) {
772
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
773
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
774
+ this._store.state.currentPath = KritzelPath.create(this._store, {
775
+ points: [...this._store.state.currentPath.points, [x, y]],
776
+ translateX: -this._store.state.translateX,
777
+ translateY: -this._store.state.translateY,
778
+ scale: this._store.state.scale,
779
+ fill: this.color,
780
+ strokeWidth: this.size,
781
+ });
782
+ this._store.rerender();
783
+ }
777
784
  }
778
785
  }
779
- handleTouchMove(event) {
780
- if (this._store.state.touchCount === 1) {
781
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
782
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
783
- this._store.state.currentPath = KritzelPath.create(this._store, {
784
- points: [...this._store.state.currentPath.points, [x, y]],
785
- translateX: -this._store.state.translateX,
786
- translateY: -this._store.state.translateY,
787
- scale: this._store.state.scale,
788
- fill: this.color,
789
- strokeWidth: this.size,
790
- });
791
- this._store.rerender();
786
+ handlePointerUp(event) {
787
+ if (event.pointerType === 'mouse') {
788
+ if (this._store.state.isDrawing) {
789
+ this._store.state.isDrawing = false;
790
+ if (this._store.state.currentPath) {
791
+ this._store.state.currentPath.zIndex = this._store.currentZIndex;
792
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
793
+ }
794
+ this._store.state.currentPath = undefined;
795
+ }
792
796
  }
793
- }
794
- handleTouchEnd(_event) {
795
- if (this._store.state.isDrawing) {
796
- this._store.state.isDrawing = false;
797
- if (this._store.state.currentPath) {
798
- this._store.state.currentPath.zIndex = this._store.currentZIndex;
799
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
797
+ if (event.pointerType === 'touch') {
798
+ if (this._store.state.isDrawing) {
799
+ this._store.state.isDrawing = false;
800
+ if (this._store.state.currentPath) {
801
+ this._store.state.currentPath.zIndex = this._store.currentZIndex;
802
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
803
+ }
804
+ this._store.state.currentPath = undefined;
805
+ this._store.rerender();
800
806
  }
801
- this._store.state.currentPath = undefined;
802
- this._store.rerender();
803
807
  }
804
808
  }
805
809
  }
806
810
 
811
+ class KritzelToolRegistry {
812
+ static registerTool(toolName, constructor, store) {
813
+ const toolInstance = new constructor(store);
814
+ toolInstance.name = toolName;
815
+ this.registry[toolName] = toolInstance;
816
+ return toolInstance;
817
+ }
818
+ static getTool(toolName) {
819
+ const toolInstance = this.registry[toolName];
820
+ if (!toolInstance) {
821
+ console.warn(`Unknown tool: ${toolName}`);
822
+ return null;
823
+ }
824
+ return toolInstance;
825
+ }
826
+ }
827
+ KritzelToolRegistry.registry = {};
828
+
807
829
  class KritzelText extends KritzelBaseObject {
808
830
  get isReadonly() {
809
831
  return !(this._store.state.activeTool instanceof KritzelTextTool);
@@ -826,7 +848,7 @@ class KritzelText extends KritzelBaseObject {
826
848
  this.fontSize = config.fontSize || 8;
827
849
  this.fontFamily = config.fontFamily || 'Arial';
828
850
  this.fontColor = config.fontColor || '#000000';
829
- this.height = config.height || (this.fontSize * 1.2);
851
+ this.height = config.height || this.fontSize * 1.2;
830
852
  this.width = config.width || 0;
831
853
  this.scale = config.scale || 1;
832
854
  }
@@ -930,6 +952,15 @@ class KritzelText extends KritzelBaseObject {
930
952
  }
931
953
  }
932
954
  }
955
+ onSelectedClick() {
956
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
957
+ this._store.state.selectionGroup = null;
958
+ this._store.state.selectionBox = null;
959
+ this._store.state.activeText = this;
960
+ setTimeout(() => {
961
+ this.focus();
962
+ }, 300);
963
+ }
933
964
  }
934
965
 
935
966
  class KritzelKeyboardHelper {
@@ -963,24 +994,6 @@ class KritzelKeyboardHelper {
963
994
  }
964
995
  }
965
996
 
966
- class KritzelToolRegistry {
967
- static registerTool(toolName, constructor, store) {
968
- const toolInstance = new constructor(store);
969
- toolInstance.name = toolName;
970
- this.registry[toolName] = toolInstance;
971
- return toolInstance;
972
- }
973
- static getTool(toolName) {
974
- const toolInstance = this.registry[toolName];
975
- if (!toolInstance) {
976
- console.warn(`Unknown tool: ${toolName}`);
977
- return null;
978
- }
979
- return toolInstance;
980
- }
981
- }
982
- KritzelToolRegistry.registry = {};
983
-
984
997
  class KritzelTextTool extends KritzelBaseTool {
985
998
  constructor(store) {
986
999
  super(store);
@@ -1005,84 +1018,93 @@ class KritzelTextTool extends KritzelBaseTool {
1005
1018
  '#800080',
1006
1019
  ];
1007
1020
  }
1008
- handleMouseDown(event) {
1009
- const path = event.composedPath().slice(1);
1010
- const objectElement = path.find(element => element.classList && element.classList.contains('object'));
1011
- const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
1012
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
1013
- this._store.state.activeText = object;
1014
- object.focus();
1015
- return;
1016
- }
1017
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
1018
- object.focus();
1019
- return;
1020
- }
1021
- if (this._store.state.activeText !== null) {
1022
- this._store.resetActiveText();
1023
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1024
- return;
1025
- }
1026
- if (KritzelEventHelper.isLeftClick(event) === false) {
1027
- return;
1021
+ handlePointerDown(event) {
1022
+ if (event.pointerType === 'mouse') {
1023
+ const path = event.composedPath().slice(1);
1024
+ const objectElement = path.find(element => element.classList && element.classList.contains('object'));
1025
+ const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
1026
+ if (this._store.state.activeText === null && object && object instanceof KritzelText) {
1027
+ this._store.state.activeText = object;
1028
+ object.focus();
1029
+ return;
1030
+ }
1031
+ if (this._store.state.activeText !== null && object instanceof KritzelText) {
1032
+ object.focus();
1033
+ return;
1034
+ }
1035
+ if (this._store.state.activeText !== null) {
1036
+ this._store.resetActiveText();
1037
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1038
+ return;
1039
+ }
1040
+ if (KritzelEventHelper.isLeftClick(event) === false) {
1041
+ return;
1042
+ }
1043
+ const clientX = event.clientX - this._store.offsetX;
1044
+ const clientY = event.clientY - this._store.offsetY;
1045
+ const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
1046
+ text.fontColor = this.fontColor;
1047
+ text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
1048
+ text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
1049
+ text.zIndex = this._store.currentZIndex;
1050
+ this._store.state.activeText = text;
1051
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
1052
+ }
1053
+ if (event.pointerType === 'touch') {
1054
+ const activePointers = Array.from(this._store.state.pointers.values());
1055
+ const path = event.composedPath().slice(1);
1056
+ const objectElement = path.find(element => element.classList && element.classList.contains('object'));
1057
+ const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
1058
+ if (this._store.state.activeText === null && object && object instanceof KritzelText) {
1059
+ this._store.state.activeText = object;
1060
+ object.focus();
1061
+ return;
1062
+ }
1063
+ if (this._store.state.activeText !== null && object instanceof KritzelText) {
1064
+ object.focus();
1065
+ return;
1066
+ }
1067
+ if (this._store.state.activeText !== null) {
1068
+ this._store.resetActiveText();
1069
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1070
+ return;
1071
+ }
1072
+ if (activePointers.length > 1) {
1073
+ return;
1074
+ }
1075
+ KritzelKeyboardHelper.disableInteractiveWidget();
1076
+ const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);
1077
+ const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);
1078
+ const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
1079
+ text.fontColor = this.fontColor;
1080
+ text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
1081
+ text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
1082
+ text.zIndex = this._store.currentZIndex;
1083
+ this._store.state.activeText = text;
1084
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
1085
+ }
1086
+ }
1087
+ handlePointerUp(event) {
1088
+ var _a, _b, _c, _d;
1089
+ if (event.pointerType === 'mouse') {
1090
+ (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.adjustTextareaSize();
1091
+ (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.focus();
1092
+ }
1093
+ if (event.pointerType === 'touch') {
1094
+ (_c = this._store.state.activeText) === null || _c === void 0 ? void 0 : _c.adjustTextareaSize();
1095
+ (_d = this._store.state.activeText) === null || _d === void 0 ? void 0 : _d.focus();
1096
+ KritzelKeyboardHelper.enableInteractiveWidget();
1028
1097
  }
1029
- const clientX = event.clientX - this._store.offsetX;
1030
- const clientY = event.clientY - this._store.offsetY;
1031
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
1032
- text.fontColor = this.fontColor;
1033
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
1034
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
1035
- text.zIndex = this._store.currentZIndex;
1036
- text.adjustTextareaSize();
1037
- this._store.state.activeText = text;
1038
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
1039
- }
1040
- handleMouseUp(_event) {
1041
- var _a, _b;
1042
- (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.focus();
1043
- (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.adjustTextareaSize();
1044
1098
  }
1045
- handleTouchStart(event) {
1046
- const path = event.composedPath().slice(1);
1047
- const objectElement = path.find(element => element.classList && element.classList.contains('object'));
1048
- const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
1049
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
1050
- this._store.state.activeText = object;
1051
- object.focus();
1052
- return;
1053
- }
1054
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
1055
- object.focus();
1056
- return;
1057
- }
1058
- if (this._store.state.activeText !== null) {
1059
- this._store.resetActiveText();
1060
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1061
- return;
1062
- }
1063
- if (this._store.state.touchCount > 1) {
1064
- return;
1065
- }
1066
- KritzelKeyboardHelper.disableInteractiveWidget();
1067
- const clientX = Math.round(event.touches[0].clientX - this._store.offsetX);
1068
- const clientY = Math.round(event.touches[0].clientY - this._store.offsetY);
1069
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
1070
- text.fontColor = this.fontColor;
1071
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
1072
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
1073
- text.zIndex = this._store.currentZIndex;
1074
- this._store.state.activeText = text;
1075
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
1076
- }
1077
- handleTouchEnd(_event) {
1078
- var _a, _b;
1079
- (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.focus();
1080
- (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.adjustTextareaSize();
1081
- KritzelKeyboardHelper.enableInteractiveWidget();
1099
+ }
1100
+
1101
+ class KritzelDevicesHelper {
1102
+ static isTouchDevice() {
1103
+ return window.matchMedia('(any-pointer: coarse)').matches;
1082
1104
  }
1083
1105
  }
1084
1106
 
1085
- const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 8px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid hsl(0, 0%, 0%, 4.3%));border-radius:var(--kritzel-controls-border-radius, 8px);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 8px);padding:var(--kritzel-controls-control-padding, 8px);border:none;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #0E1111);color:var(--kritzel-controls-control-selected-color, #ffffff)}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:66px;left:50%;transform:translateX(-50%);z-index:10001}";
1107
+ const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 8px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid hsl(0, 0%, 0%, 4.3%));border-radius:var(--kritzel-controls-border-radius, 8px);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 8px);padding:var(--kritzel-controls-control-padding, 8px);border:none;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.mobile) .kritzel-control:hover{background-color:unset}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}:host(.mobile) .kritzel-control:active{background-color:unset}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #0E1111) !important;color:var(--kritzel-controls-control-selected-color, #ffffff) !important}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:66px;left:50%;transform:translateX(-50%);z-index:10001}";
1086
1108
 
1087
1109
  const KritzelControls = class {
1088
1110
  constructor(hostRef) {
@@ -1092,6 +1114,7 @@ const KritzelControls = class {
1092
1114
  this.activeControl = null;
1093
1115
  this.firstConfig = null;
1094
1116
  this.tooltipVisible = false;
1117
+ this.isTouchDevice = KritzelDevicesHelper.isTouchDevice();
1095
1118
  this.kritzelEngine = null;
1096
1119
  }
1097
1120
  get activeToolAsTextTool() {
@@ -1172,16 +1195,18 @@ const KritzelControls = class {
1172
1195
  render() {
1173
1196
  var _a, _b;
1174
1197
  const hasNoConfig = ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.config) === undefined || ((_b = this.activeControl) === null || _b === void 0 ? void 0 : _b.config) === null;
1175
- return (index.h(index.Host, { key: '2b13783ef0f1638ad76bfcef22c17c3eeb849d67' }, index.h("kritzel-utility-panel", { key: '1babeb88133cebc9057c85723b812b99152316c6', style: {
1198
+ return (index.h(index.Host, { key: 'e5bfc1952235cb3524849733015d14e629f36f9d', class: {
1199
+ mobile: this.isTouchDevice,
1200
+ } }, index.h("kritzel-utility-panel", { key: '8b89423a1d1d4d93945f774f0867b2fd8bd4b0bf', style: {
1176
1201
  position: 'absolute',
1177
1202
  bottom: '56px',
1178
1203
  left: '12px',
1179
- }, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } }), index.h("div", { key: '8fafebdf6726dd2bffe85cb2b3ada5f4885a2bf8', class: "kritzel-controls" }, this.controls.map(control => {
1204
+ }, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } }), index.h("div", { key: '8b58a76ff194663f312cfe55fd3e29e78b8067d1', class: "kritzel-controls" }, this.controls.map(control => {
1180
1205
  var _a, _b, _c, _d, _e, _f, _g, _h;
1181
1206
  if (control.type === 'tool') {
1182
1207
  return (index.h("button", { class: {
1183
1208
  'kritzel-control': true,
1184
- 'selected': ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.name) === (control === null || control === void 0 ? void 0 : control.name),
1209
+ selected: ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.name) === (control === null || control === void 0 ? void 0 : control.name),
1185
1210
  }, key: control.name, onClick: _event => { var _a; return (_a = this.handleControlClick) === null || _a === void 0 ? void 0 : _a.call(this, control); } }, index.h("kritzel-icon", { name: control.icon })));
1186
1211
  }
1187
1212
  if (control.type === 'divider') {
@@ -1466,71 +1491,76 @@ class KritzelEraserTool extends KritzelBaseTool {
1466
1491
  super(store);
1467
1492
  this.touchStartTimeout = null;
1468
1493
  }
1469
- handleMouseDown(event) {
1470
- if (KritzelEventHelper.isLeftClick(event)) {
1471
- this._store.state.isErasing = true;
1494
+ handlePointerDown(event) {
1495
+ if (event.pointerType === 'mouse') {
1496
+ if (KritzelEventHelper.isLeftClick(event)) {
1497
+ this._store.state.isErasing = true;
1498
+ }
1472
1499
  }
1473
- }
1474
- handleMouseMove(event) {
1475
- var _a;
1476
- if (this._store.state.isErasing) {
1477
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1478
- if (!shadowRoot)
1479
- return;
1480
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1481
- if (!selectedObject)
1482
- return;
1483
- selectedObject.markedForRemoval = true;
1484
- this._store.rerender();
1500
+ if (event.pointerType === 'touch') {
1501
+ this.touchStartTimeout = setTimeout(() => {
1502
+ if (this._store.state.pointers.size === 1 && !this._store.state.isScaling) {
1503
+ this._store.state.isErasing = true;
1504
+ }
1505
+ }, 80);
1485
1506
  }
1486
1507
  }
1487
- handleMouseUp(_event) {
1488
- if (this._store.state.isErasing) {
1489
- const removeCommands = this._store.allObjects
1490
- .filter(object => object.markedForRemoval)
1491
- .map(object => {
1492
- object.markedForRemoval = false;
1493
- return new RemoveObjectCommand(this._store, this, object);
1494
- });
1495
- if (removeCommands.length > 0) {
1496
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1508
+ handlePointerMove(event) {
1509
+ var _a, _b;
1510
+ if (event.pointerType === 'mouse') {
1511
+ if (this._store.state.isErasing) {
1512
+ const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1513
+ if (!shadowRoot)
1514
+ return;
1515
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1516
+ if (!selectedObject)
1517
+ return;
1518
+ selectedObject.markedForRemoval = true;
1519
+ this._store.rerender();
1497
1520
  }
1498
- this._store.state.isErasing = false;
1499
1521
  }
1500
- }
1501
- handleTouchStart(_event) {
1502
- this.touchStartTimeout = setTimeout(() => {
1503
- if (this._store.state.touchCount === 1 && !this._store.state.isScaling) {
1504
- this._store.state.isErasing = true;
1522
+ if (event.pointerType === 'touch') {
1523
+ if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
1524
+ const shadowRoot = (_b = this._store.state.host) === null || _b === void 0 ? void 0 : _b.shadowRoot;
1525
+ if (!shadowRoot)
1526
+ return;
1527
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1528
+ if (!selectedObject)
1529
+ return;
1530
+ selectedObject.markedForRemoval = true;
1531
+ this._store.rerender();
1505
1532
  }
1506
- }, 80);
1507
- }
1508
- handleTouchMove(event) {
1509
- var _a;
1510
- if (this._store.state.touchCount === 1 && this._store.state.isErasing) {
1511
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1512
- if (!shadowRoot)
1513
- return;
1514
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1515
- if (!selectedObject)
1516
- return;
1517
- selectedObject.markedForRemoval = true;
1518
- this._store.rerender();
1519
1533
  }
1520
1534
  }
1521
- handleTouchEnd(_event) {
1522
- clearTimeout(this.touchStartTimeout);
1523
- if (this._store.state.isErasing) {
1524
- const removeCommands = this._store.allObjects
1525
- .filter(object => object.markedForRemoval)
1526
- .map(object => {
1527
- object.markedForRemoval = false;
1528
- return new RemoveObjectCommand(this._store, this, object);
1529
- });
1530
- if (removeCommands.length > 0) {
1531
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1535
+ handlePointerUp(event) {
1536
+ if (event.pointerType === 'mouse') {
1537
+ if (this._store.state.isErasing) {
1538
+ const removeCommands = this._store.allObjects
1539
+ .filter(object => object.markedForRemoval)
1540
+ .map(object => {
1541
+ object.markedForRemoval = false;
1542
+ return new RemoveObjectCommand(this._store, this, object);
1543
+ });
1544
+ if (removeCommands.length > 0) {
1545
+ this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1546
+ }
1547
+ this._store.state.isErasing = false;
1548
+ }
1549
+ }
1550
+ if (event.pointerType === 'touch') {
1551
+ clearTimeout(this.touchStartTimeout);
1552
+ if (this._store.state.isErasing) {
1553
+ const removeCommands = this._store.allObjects
1554
+ .filter(object => object.markedForRemoval)
1555
+ .map(object => {
1556
+ object.markedForRemoval = false;
1557
+ return new RemoveObjectCommand(this._store, this, object);
1558
+ });
1559
+ if (removeCommands.length > 0) {
1560
+ this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1561
+ }
1562
+ this._store.state.isErasing = false;
1532
1563
  }
1533
- this._store.state.isErasing = false;
1534
1564
  }
1535
1565
  }
1536
1566
  }
@@ -1617,72 +1647,79 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1617
1647
  constructor(store) {
1618
1648
  super(store);
1619
1649
  }
1620
- handleMouseDown(event) {
1621
- var _a;
1622
- if (KritzelEventHelper.isLeftClick(event)) {
1623
- if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1650
+ handlePointerDown(event) {
1651
+ var _a, _b;
1652
+ if (event.pointerType === 'mouse') {
1653
+ if (KritzelEventHelper.isLeftClick(event)) {
1654
+ if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1655
+ const clientX = event.clientX - this._store.offsetX;
1656
+ const clientY = event.clientY - this._store.offsetY;
1657
+ this._store.state.isDragging = true;
1658
+ this.dragStartX = clientX;
1659
+ this.dragStartY = clientY;
1660
+ this.startX = this.dragStartX;
1661
+ this.startY = this.dragStartY;
1662
+ }
1663
+ }
1664
+ }
1665
+ if (event.pointerType === 'touch') {
1666
+ const activePointers = Array.from(this._store.state.pointers.values());
1667
+ if (this._store.state.pointers.size === 1) {
1668
+ if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1669
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1670
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1671
+ this.dragStartX = x;
1672
+ this.dragStartY = y;
1673
+ this.startX = x;
1674
+ this.startY = y;
1675
+ }
1676
+ }
1677
+ }
1678
+ }
1679
+ handlePointerMove(event) {
1680
+ if (event.pointerType === 'mouse') {
1681
+ if (this._store.state.isDragging && this._store.state.selectionGroup) {
1624
1682
  const clientX = event.clientX - this._store.offsetX;
1625
1683
  const clientY = event.clientY - this._store.offsetY;
1626
- this._store.state.isDragging = true;
1684
+ this.endX = clientX;
1685
+ this.endY = clientY;
1686
+ this._store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
1627
1687
  this.dragStartX = clientX;
1628
1688
  this.dragStartY = clientY;
1629
- this.startX = this.dragStartX;
1630
- this.startY = this.dragStartY;
1631
1689
  }
1632
1690
  }
1633
- }
1634
- handleMouseMove(event) {
1635
- if (this._store.state.isDragging && this._store.state.selectionGroup) {
1636
- const clientX = event.clientX - this._store.offsetX;
1637
- const clientY = event.clientY - this._store.offsetY;
1638
- this.endX = clientX;
1639
- this.endY = clientY;
1640
- this._store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
1641
- this.dragStartX = clientX;
1642
- this.dragStartY = clientY;
1643
- }
1644
- }
1645
- handleMouseUp(_event) {
1646
- if (this._store.state.isDragging) {
1647
- this._store.state.isDragging = false;
1648
- this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
1649
- }
1650
- }
1651
- handleTouchStart(event) {
1652
- var _a;
1653
- if (this._store.state.touchCount === 1) {
1654
- if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1655
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
1656
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
1657
- this.dragStartX = x;
1658
- this.dragStartY = y;
1659
- this.startX = x;
1660
- this.startY = y;
1691
+ if (event.pointerType === 'touch') {
1692
+ const activePointers = Array.from(this._store.state.pointers.values());
1693
+ if (this._store.state.pointers.size === 1 && this._store.state.selectionGroup && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1694
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1695
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1696
+ this._store.state.isDragging = true;
1697
+ this.endX = x;
1698
+ this.endY = y;
1699
+ const moveDeltaX = Math.abs(x - this.startX);
1700
+ const moveDeltaY = Math.abs(y - this.startY);
1701
+ const moveThreshold = 5;
1702
+ if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
1703
+ clearTimeout(this._store.state.longTouchTimeout);
1704
+ this._store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
1705
+ this.dragStartX = x;
1706
+ this.dragStartY = y;
1707
+ }
1661
1708
  }
1662
1709
  }
1663
1710
  }
1664
- handleTouchMove(event) {
1665
- if (this._store.state.touchCount === 1 && this._store.state.selectionGroup && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1666
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
1667
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
1668
- this._store.state.isDragging = true;
1669
- this.endX = x;
1670
- this.endY = y;
1671
- const moveDeltaX = Math.abs(x - this.startX);
1672
- const moveDeltaY = Math.abs(y - this.startY);
1673
- const moveThreshold = 5;
1674
- if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
1675
- clearTimeout(this._store.state.longTouchTimeout);
1676
- this._store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
1677
- this.dragStartX = x;
1678
- this.dragStartY = y;
1711
+ handlePointerUp(event) {
1712
+ if (event.pointerType === 'mouse') {
1713
+ if (this._store.state.isDragging) {
1714
+ this._store.state.isDragging = false;
1715
+ this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
1679
1716
  }
1680
1717
  }
1681
- }
1682
- handleTouchEnd(_event) {
1683
- if (this._store.state.isDragging) {
1684
- this._store.state.isDragging = false;
1685
- this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
1718
+ if (event.pointerType === 'touch') {
1719
+ if (this._store.state.isDragging) {
1720
+ this._store.state.isDragging = false;
1721
+ this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
1722
+ }
1686
1723
  }
1687
1724
  }
1688
1725
  }
@@ -1720,131 +1757,140 @@ class KritzelResizeHandler extends KritzelBaseHandler {
1720
1757
  this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
1721
1758
  this.newSize = { x: 0, y: 0, width: 0, height: 0 };
1722
1759
  }
1723
- handleMouseDown(event) {
1724
- if (KritzelEventHelper.isLeftClick(event)) {
1725
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1726
- const clientX = event.clientX - this._store.offsetX;
1727
- const clientY = event.clientY - this._store.offsetY;
1728
- this._store.state.isResizing = true;
1729
- this.initialMouseX = clientX;
1730
- this.initialMouseY = clientY;
1731
- this.initialSize.width = this._store.state.selectionGroup.width;
1732
- this.initialSize.height = this._store.state.selectionGroup.height;
1733
- this.initialSize.x = this._store.state.selectionGroup.translateX;
1734
- this.initialSize.y = this._store.state.selectionGroup.translateY;
1760
+ handlePointerDown(event) {
1761
+ if (event.pointerType === 'mouse') {
1762
+ if (KritzelEventHelper.isLeftClick(event)) {
1763
+ if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1764
+ const clientX = event.clientX - this._store.offsetX;
1765
+ const clientY = event.clientY - this._store.offsetY;
1766
+ this._store.state.isResizing = true;
1767
+ this.initialMouseX = clientX;
1768
+ this.initialMouseY = clientY;
1769
+ this.initialSize.width = this._store.state.selectionGroup.width;
1770
+ this.initialSize.height = this._store.state.selectionGroup.height;
1771
+ this.initialSize.x = this._store.state.selectionGroup.translateX;
1772
+ this.initialSize.y = this._store.state.selectionGroup.translateY;
1773
+ }
1735
1774
  }
1736
1775
  }
1737
- }
1738
- handleMouseMove(event) {
1739
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
1740
- const clientX = event.clientX - this._store.offsetX;
1741
- const clientY = event.clientY - this._store.offsetY;
1742
- const dx = clientX - this.initialMouseX;
1743
- const dy = clientY - this.initialMouseY;
1744
- switch (this._store.state.resizeHandleType) {
1745
- case KritzelHandleType.TopLeft:
1746
- this.newSize.width = this.initialSize.width - dx;
1747
- this.newSize.height = this.initialSize.height - dy;
1748
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1749
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1750
- break;
1751
- case KritzelHandleType.TopRight:
1752
- this.newSize.width = this.initialSize.width + dx;
1753
- this.newSize.height = this.initialSize.height - dy;
1754
- this.newSize.x = this.initialSize.x;
1755
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1756
- break;
1757
- case KritzelHandleType.BottomLeft:
1758
- this.newSize.width = this.initialSize.width - dx;
1759
- this.newSize.height = this.initialSize.height + dy;
1760
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1761
- this.newSize.y = this.initialSize.y;
1762
- break;
1763
- case KritzelHandleType.BottomRight:
1764
- this.newSize.width = this.initialSize.width + dx;
1765
- this.newSize.height = this.initialSize.height + dy;
1766
- this.newSize.x = this.initialSize.x;
1767
- this.newSize.y = this.initialSize.y;
1768
- break;
1776
+ if (event.pointerType === 'touch') {
1777
+ const activePointers = Array.from(this._store.state.pointers.values());
1778
+ const firstTouch = activePointers[0];
1779
+ if (!firstTouch) {
1780
+ return;
1781
+ }
1782
+ if (activePointers.length === 1) {
1783
+ if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1784
+ const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1785
+ const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1786
+ this._store.state.isResizing = true;
1787
+ this.initialMouseX = clientX;
1788
+ this.initialMouseY = clientY;
1789
+ this.initialSize.width = this._store.state.selectionGroup.width;
1790
+ this.initialSize.height = this._store.state.selectionGroup.height;
1791
+ this.initialSize.x = this._store.state.selectionGroup.translateX;
1792
+ this.initialSize.y = this._store.state.selectionGroup.translateY;
1793
+ clearTimeout(this._store.state.longTouchTimeout);
1794
+ }
1769
1795
  }
1770
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1771
- this._store.rerender();
1772
- }
1773
- }
1774
- handleMouseUp(_event) {
1775
- if (this._store.state.isResizing) {
1776
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1777
- this._store.history.executeCommand(resizeSelectionGroupCommand);
1778
- this._store.state.isResizing = false;
1779
- this._store.rerender();
1780
1796
  }
1781
1797
  }
1782
- handleTouchStart(event) {
1783
- const firstTouch = event.touches[0];
1784
- if (!firstTouch) {
1785
- return;
1798
+ handlePointerMove(event) {
1799
+ if (event.pointerType === 'mouse') {
1800
+ if (this._store.state.isResizing && this._store.state.selectionGroup) {
1801
+ const clientX = event.clientX - this._store.offsetX;
1802
+ const clientY = event.clientY - this._store.offsetY;
1803
+ const dx = clientX - this.initialMouseX;
1804
+ const dy = clientY - this.initialMouseY;
1805
+ switch (this._store.state.resizeHandleType) {
1806
+ case KritzelHandleType.TopLeft:
1807
+ this.newSize.width = this.initialSize.width - dx;
1808
+ this.newSize.height = this.initialSize.height - dy;
1809
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1810
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1811
+ break;
1812
+ case KritzelHandleType.TopRight:
1813
+ this.newSize.width = this.initialSize.width + dx;
1814
+ this.newSize.height = this.initialSize.height - dy;
1815
+ this.newSize.x = this.initialSize.x;
1816
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1817
+ break;
1818
+ case KritzelHandleType.BottomLeft:
1819
+ this.newSize.width = this.initialSize.width - dx;
1820
+ this.newSize.height = this.initialSize.height + dy;
1821
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1822
+ this.newSize.y = this.initialSize.y;
1823
+ break;
1824
+ case KritzelHandleType.BottomRight:
1825
+ this.newSize.width = this.initialSize.width + dx;
1826
+ this.newSize.height = this.initialSize.height + dy;
1827
+ this.newSize.x = this.initialSize.x;
1828
+ this.newSize.y = this.initialSize.y;
1829
+ break;
1830
+ }
1831
+ this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1832
+ this._store.rerender();
1833
+ }
1786
1834
  }
1787
- if (this._store.state.touchCount === 1) {
1788
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1789
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1790
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1791
- this._store.state.isResizing = true;
1792
- this.initialMouseX = clientX;
1793
- this.initialMouseY = clientY;
1794
- this.initialSize.width = this._store.state.selectionGroup.width;
1795
- this.initialSize.height = this._store.state.selectionGroup.height;
1796
- this.initialSize.x = this._store.state.selectionGroup.translateX;
1797
- this.initialSize.y = this._store.state.selectionGroup.translateY;
1835
+ if (event.pointerType === 'touch') {
1836
+ const activePointers = Array.from(this._store.state.pointers.values());
1837
+ const oneFingerTouch = activePointers[0];
1838
+ if (!oneFingerTouch) {
1839
+ return;
1840
+ }
1841
+ if (this._store.state.isResizing && this._store.state.selectionGroup) {
1842
+ const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
1843
+ const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
1844
+ const dx = clientX - this.initialMouseX;
1845
+ const dy = clientY - this.initialMouseY;
1846
+ switch (this._store.state.resizeHandleType) {
1847
+ case KritzelHandleType.TopLeft:
1848
+ this.newSize.width = this.initialSize.width - dx;
1849
+ this.newSize.height = this.initialSize.height - dy;
1850
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1851
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1852
+ break;
1853
+ case KritzelHandleType.TopRight:
1854
+ this.newSize.width = this.initialSize.width + dx;
1855
+ this.newSize.height = this.initialSize.height - dy;
1856
+ this.newSize.x = this.initialSize.x;
1857
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1858
+ break;
1859
+ case KritzelHandleType.BottomLeft:
1860
+ this.newSize.width = this.initialSize.width - dx;
1861
+ this.newSize.height = this.initialSize.height + dy;
1862
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1863
+ this.newSize.y = this.initialSize.y;
1864
+ break;
1865
+ case KritzelHandleType.BottomRight:
1866
+ this.newSize.width = this.initialSize.width + dx;
1867
+ this.newSize.height = this.initialSize.height + dy;
1868
+ this.newSize.x = this.initialSize.x;
1869
+ this.newSize.y = this.initialSize.y;
1870
+ break;
1871
+ }
1872
+ this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1798
1873
  clearTimeout(this._store.state.longTouchTimeout);
1799
1874
  }
1800
1875
  }
1801
1876
  }
1802
- handleTouchMove(event) {
1803
- const oneFingerTouch = event.touches[0];
1804
- if (!oneFingerTouch) {
1805
- return;
1806
- }
1807
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
1808
- const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
1809
- const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
1810
- const dx = clientX - this.initialMouseX;
1811
- const dy = clientY - this.initialMouseY;
1812
- switch (this._store.state.resizeHandleType) {
1813
- case KritzelHandleType.TopLeft:
1814
- this.newSize.width = this.initialSize.width - dx;
1815
- this.newSize.height = this.initialSize.height - dy;
1816
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1817
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1818
- break;
1819
- case KritzelHandleType.TopRight:
1820
- this.newSize.width = this.initialSize.width + dx;
1821
- this.newSize.height = this.initialSize.height - dy;
1822
- this.newSize.x = this.initialSize.x;
1823
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1824
- break;
1825
- case KritzelHandleType.BottomLeft:
1826
- this.newSize.width = this.initialSize.width - dx;
1827
- this.newSize.height = this.initialSize.height + dy;
1828
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1829
- this.newSize.y = this.initialSize.y;
1830
- break;
1831
- case KritzelHandleType.BottomRight:
1832
- this.newSize.width = this.initialSize.width + dx;
1833
- this.newSize.height = this.initialSize.height + dy;
1834
- this.newSize.x = this.initialSize.x;
1835
- this.newSize.y = this.initialSize.y;
1836
- break;
1877
+ handlePointerUp(event) {
1878
+ if (event.pointerType === 'mouse') {
1879
+ if (this._store.state.isResizing) {
1880
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1881
+ this._store.history.executeCommand(resizeSelectionGroupCommand);
1882
+ this._store.state.isResizing = false;
1883
+ this._store.rerender();
1837
1884
  }
1838
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1839
- clearTimeout(this._store.state.longTouchTimeout);
1840
1885
  }
1841
- }
1842
- handleTouchEnd(_event) {
1843
- if (this._store.state.isResizing) {
1844
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1845
- this._store.history.executeCommand(resizeSelectionGroupCommand);
1846
- this._store.state.isResizing = false;
1847
- clearTimeout(this._store.state.longTouchTimeout);
1886
+ if (event.pointerType === 'touch') {
1887
+ if (this._store.state.isResizing) {
1888
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1889
+ this._store.history.executeCommand(resizeSelectionGroupCommand);
1890
+ this._store.state.isResizing = false;
1891
+ this._store.rerender();
1892
+ clearTimeout(this._store.state.longTouchTimeout);
1893
+ }
1848
1894
  }
1849
1895
  }
1850
1896
  }
@@ -1878,87 +1924,95 @@ class KritzelRotationHandler extends KritzelBaseHandler {
1878
1924
  this.initialRotation = 0;
1879
1925
  this.rotation = 0;
1880
1926
  }
1881
- handleMouseDown(event) {
1882
- if (KritzelEventHelper.isLeftClick(event)) {
1883
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1927
+ handlePointerDown(event) {
1928
+ if (event.pointerType === 'mouse') {
1929
+ if (KritzelEventHelper.isLeftClick(event)) {
1930
+ if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1931
+ const clientX = event.clientX - this._store.offsetX;
1932
+ const clientY = event.clientY - this._store.offsetY;
1933
+ this._store.state.isRotating = true;
1934
+ const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1935
+ const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1936
+ const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1937
+ const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1938
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1939
+ }
1940
+ }
1941
+ }
1942
+ if (event.pointerType === 'touch') {
1943
+ const activePointers = Array.from(this._store.state.pointers.values());
1944
+ const firstTouch = activePointers[0];
1945
+ if (!firstTouch) {
1946
+ return;
1947
+ }
1948
+ if (activePointers.length === 1) {
1949
+ if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1950
+ const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1951
+ const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1952
+ this._store.state.isRotating = true;
1953
+ const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1954
+ const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1955
+ const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1956
+ const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1957
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1958
+ clearTimeout(this._store.state.longTouchTimeout);
1959
+ }
1960
+ }
1961
+ }
1962
+ }
1963
+ handlePointerMove(event) {
1964
+ if (event.pointerType === 'mouse') {
1965
+ if (this._store.state.isRotating && this._store.state.selectionGroup) {
1884
1966
  const clientX = event.clientX - this._store.offsetX;
1885
1967
  const clientY = event.clientY - this._store.offsetY;
1886
- this._store.state.isRotating = true;
1887
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1888
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1968
+ const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1969
+ const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1889
1970
  const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1890
1971
  const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1891
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1972
+ const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1973
+ this.rotation = currentRotation - this.initialRotation;
1974
+ this._store.state.selectionGroup.rotate(this.rotation);
1975
+ this._store.rerender();
1892
1976
  }
1893
1977
  }
1894
- }
1895
- handleMouseMove(event) {
1896
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
1897
- const clientX = event.clientX - this._store.offsetX;
1898
- const clientY = event.clientY - this._store.offsetY;
1899
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1900
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1901
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1902
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1903
- const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1904
- this.rotation = currentRotation - this.initialRotation;
1905
- this._store.state.selectionGroup.rotate(this.rotation);
1906
- this._store.rerender();
1907
- }
1908
- }
1909
- handleMouseUp(_event) {
1910
- if (this._store.state.isRotating) {
1911
- this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
1912
- this._store.state.isRotating = false;
1913
- this.initialRotation = 0;
1914
- this.rotation = 0;
1915
- }
1916
- }
1917
- handleTouchStart(event) {
1918
- const firstTouch = event.touches[0];
1919
- if (!firstTouch) {
1920
- return;
1921
- }
1922
- if (this._store.state.touchCount === 1) {
1923
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1978
+ if (event.pointerType === 'touch') {
1979
+ const activePointers = Array.from(this._store.state.pointers.values());
1980
+ const firstTouch = activePointers[0];
1981
+ if (!firstTouch) {
1982
+ return;
1983
+ }
1984
+ if (this._store.state.isRotating && this._store.state.selectionGroup) {
1924
1985
  const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1925
1986
  const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1926
- this._store.state.isRotating = true;
1927
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1928
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1987
+ const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1988
+ const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1929
1989
  const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1930
1990
  const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1931
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1991
+ const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1992
+ this.rotation = currentRotation - this.initialRotation;
1993
+ this._store.state.selectionGroup.rotate(this.rotation);
1994
+ this._store.rerender();
1932
1995
  clearTimeout(this._store.state.longTouchTimeout);
1933
1996
  }
1934
1997
  }
1935
1998
  }
1936
- handleTouchMove(event) {
1937
- const firstTouch = event.touches[0];
1938
- if (!firstTouch) {
1939
- return;
1940
- }
1941
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
1942
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1943
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1944
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1945
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1946
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1947
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1948
- const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1949
- this.rotation = currentRotation - this.initialRotation;
1950
- this._store.state.selectionGroup.rotate(this.rotation);
1951
- this._store.rerender();
1952
- clearTimeout(this._store.state.longTouchTimeout);
1999
+ handlePointerUp(event) {
2000
+ if (event.pointerType === 'mouse') {
2001
+ if (this._store.state.isRotating) {
2002
+ this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
2003
+ this._store.state.isRotating = false;
2004
+ this.initialRotation = 0;
2005
+ this.rotation = 0;
2006
+ }
1953
2007
  }
1954
- }
1955
- handleTouchEnd(_event) {
1956
- if (this._store.state.isRotating) {
1957
- this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
1958
- this._store.state.isRotating = false;
1959
- this.initialRotation = 0;
1960
- this.rotation = 0;
1961
- clearTimeout(this._store.state.longTouchTimeout);
2008
+ if (event.pointerType === 'touch') {
2009
+ if (this._store.state.isRotating) {
2010
+ this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
2011
+ this._store.state.isRotating = false;
2012
+ this.initialRotation = 0;
2013
+ this.rotation = 0;
2014
+ clearTimeout(this._store.state.longTouchTimeout);
2015
+ }
1962
2016
  }
1963
2017
  }
1964
2018
  }
@@ -2066,63 +2120,70 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
2066
2120
  this.touchStartY = 0;
2067
2121
  this.touchStartTimeout = null;
2068
2122
  }
2069
- handleMouseDown(event) {
2070
- if (KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
2071
- this.startMouseSelection(event);
2123
+ handlePointerDown(event) {
2124
+ if (event.pointerType === 'mouse') {
2125
+ if (KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
2126
+ this.startMouseSelection(event);
2127
+ }
2072
2128
  }
2073
- }
2074
- handleMouseMove(event) {
2075
- if (this._store.state.isSelecting) {
2076
- this.updateMouseSelection(event);
2129
+ if (event.pointerType === 'touch') {
2130
+ this.touchStartTimeout = setTimeout(() => {
2131
+ if (this._store.state.pointers.size === 1 && !this._store.state.isScaling && !this._store.state.selectionGroup) {
2132
+ this.startTouchSelection();
2133
+ this.updateTouchSelection();
2134
+ }
2135
+ }, 80);
2077
2136
  }
2078
2137
  }
2079
- handleMouseUp(event) {
2080
- if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
2081
- if (this.isSelectionClick) {
2138
+ handlePointerMove(event) {
2139
+ if (event.pointerType === 'mouse') {
2140
+ if (this._store.state.isSelecting) {
2082
2141
  this.updateMouseSelection(event);
2083
- this.addSelectedObjectAtIndexToSelectionGroup(0);
2084
- this.removeSelectionBox();
2085
2142
  }
2086
- if (this.isSelectionDrag) {
2087
- this.updateMouseSelection(event);
2088
- this.addSelectedObjectsToSelectionGroup();
2089
- this.removeSelectionBox();
2143
+ }
2144
+ if (event.pointerType === 'touch') {
2145
+ const activePointers = Array.from(this._store.state.pointers.values());
2146
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
2147
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
2148
+ const moveDeltaX = Math.abs(x - this.touchStartX);
2149
+ const moveDeltaY = Math.abs(y - this.touchStartY);
2150
+ const moveThreshold = 5;
2151
+ if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._store.state.isSelecting) {
2152
+ this.updateTouchSelection();
2153
+ clearTimeout(this._store.state.longTouchTimeout);
2090
2154
  }
2091
2155
  }
2092
2156
  }
2093
- handleTouchStart(event) {
2094
- this.touchStartTimeout = setTimeout(() => {
2095
- if (this._store.state.touchCount === 1 && !this._store.state.isScaling && !this._store.state.selectionGroup) {
2096
- this.startTouchSelection(event);
2097
- this.updateTouchSelection(event);
2098
- }
2099
- }, 80);
2100
- }
2101
- handleTouchMove(event) {
2102
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
2103
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
2104
- const moveDeltaX = Math.abs(x - this.touchStartX);
2105
- const moveDeltaY = Math.abs(y - this.touchStartY);
2106
- const moveThreshold = 5;
2107
- if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._store.state.isSelecting) {
2108
- this.updateTouchSelection(event);
2109
- clearTimeout(this._store.state.longTouchTimeout);
2110
- }
2111
- }
2112
- handleTouchEnd(event) {
2113
- clearTimeout(this.touchStartTimeout);
2114
- if (this._store.state.isSelecting) {
2115
- if (this.isSelectionClick) {
2116
- this.updateTouchSelection(event);
2117
- this.addSelectedObjectAtIndexToSelectionGroup(0);
2118
- this.removeSelectionBox();
2157
+ handlePointerUp(event) {
2158
+ if (event.pointerType === 'mouse') {
2159
+ if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
2160
+ if (this.isSelectionClick) {
2161
+ this.updateMouseSelection(event);
2162
+ this.addSelectedObjectAtIndexToSelectionGroup(0);
2163
+ this.removeSelectionBox();
2164
+ }
2165
+ if (this.isSelectionDrag) {
2166
+ this.updateMouseSelection(event);
2167
+ this.addSelectedObjectsToSelectionGroup();
2168
+ this.removeSelectionBox();
2169
+ }
2119
2170
  }
2120
- if (this.isSelectionDrag) {
2121
- this.updateTouchSelection(event);
2122
- this.addSelectedObjectsToSelectionGroup();
2123
- this.removeSelectionBox();
2171
+ }
2172
+ if (event.pointerType === 'touch') {
2173
+ clearTimeout(this.touchStartTimeout);
2174
+ if (this._store.state.isSelecting) {
2175
+ if (this.isSelectionClick) {
2176
+ this.updateTouchSelection();
2177
+ this.addSelectedObjectAtIndexToSelectionGroup(0);
2178
+ this.removeSelectionBox();
2179
+ }
2180
+ if (this.isSelectionDrag) {
2181
+ this.updateTouchSelection();
2182
+ this.addSelectedObjectsToSelectionGroup();
2183
+ this.removeSelectionBox();
2184
+ }
2185
+ this._store.state.skipContextMenu = false;
2124
2186
  }
2125
- this._store.state.skipContextMenu = false;
2126
2187
  }
2127
2188
  }
2128
2189
  removeSelectionBox() {
@@ -2146,8 +2207,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
2146
2207
  this._store.state.objectsOctree.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
2147
2208
  this._store.state.objectsOctree.insert(selectionBox);
2148
2209
  }
2149
- startTouchSelection(event) {
2150
- const firstTouch = event.touches[0];
2210
+ startTouchSelection() {
2211
+ const activePointers = Array.from(this._store.state.pointers.values());
2212
+ const firstTouch = activePointers[0];
2151
2213
  if (!firstTouch) {
2152
2214
  return;
2153
2215
  }
@@ -2183,8 +2245,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
2183
2245
  this._store.rerender();
2184
2246
  }
2185
2247
  }
2186
- updateTouchSelection(event) {
2187
- const firstTouch = event.touches[0];
2248
+ updateTouchSelection() {
2249
+ const activePointers = Array.from(this._store.state.pointers.values());
2250
+ const firstTouch = activePointers[0];
2188
2251
  if (!firstTouch) {
2189
2252
  return;
2190
2253
  }
@@ -2250,39 +2313,103 @@ class KritzelSelectionTool extends KritzelBaseTool {
2250
2313
  this.resizeHandler = new KritzelResizeHandler(this._store);
2251
2314
  this.rotationHandler = new KritzelRotationHandler(this._store);
2252
2315
  }
2253
- handleMouseDown(event) {
2254
- if (KritzelEventHelper.isLeftClick(event)) {
2255
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2256
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2257
- this._store.state.resizeHandleType = this.getHandleType(event);
2258
- const selectedObject = this.getSelectedObject(event);
2259
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2260
- if ((selectedObject === null || isDifferentObject) &&
2261
- this._store.state.selectionGroup &&
2262
- !this._store.state.isResizeHandleSelected &&
2263
- !this._store.state.isRotationHandleSelected) {
2264
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2316
+ handlePointerDown(event) {
2317
+ if (event.pointerType === 'mouse') {
2318
+ if (KritzelEventHelper.isLeftClick(event)) {
2319
+ this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2320
+ this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2321
+ this._store.state.resizeHandleType = this.getHandleType(event);
2322
+ const selectedObject = this.getSelectedObject(event);
2323
+ const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2324
+ if ((selectedObject === null || isDifferentObject) &&
2325
+ this._store.state.selectionGroup &&
2326
+ !this._store.state.isResizeHandleSelected &&
2327
+ !this._store.state.isRotationHandleSelected) {
2328
+ this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2329
+ }
2330
+ if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
2331
+ setTimeout(() => {
2332
+ if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
2333
+ selectedObject.objects[0].onSelectedClick();
2334
+ }
2335
+ }, 100);
2336
+ }
2265
2337
  }
2338
+ this.moveHandler.handlePointerDown(event);
2339
+ this.selectionHandler.handlePointerDown(event);
2340
+ this.resizeHandler.handlePointerDown(event);
2341
+ this.rotationHandler.handlePointerDown(event);
2342
+ this._store.rerender();
2343
+ }
2344
+ if (event.pointerType === 'touch') {
2345
+ if (this._store.state.isScaling === true) {
2346
+ return;
2347
+ }
2348
+ if (this._store.state.pointers.size === 1) {
2349
+ this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2350
+ this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2351
+ this._store.state.resizeHandleType = this.getHandleType(event);
2352
+ const selectedObject = this.getSelectedObject(event);
2353
+ const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2354
+ if (!this._store.state.selectionGroup && selectedObject) {
2355
+ this._store.state.skipContextMenu = true;
2356
+ }
2357
+ if ((selectedObject === null || isDifferentObject) &&
2358
+ this._store.state.selectionGroup &&
2359
+ !this._store.state.isResizeHandleSelected &&
2360
+ !this._store.state.isRotationHandleSelected) {
2361
+ this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2362
+ }
2363
+ if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
2364
+ setTimeout(() => {
2365
+ if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
2366
+ selectedObject.objects[0].onSelectedClick();
2367
+ }
2368
+ }, 100);
2369
+ }
2370
+ }
2371
+ this.rotationHandler.handlePointerDown(event);
2372
+ this.resizeHandler.handlePointerDown(event);
2373
+ this.moveHandler.handlePointerDown(event);
2374
+ this.selectionHandler.handlePointerDown(event);
2375
+ }
2376
+ }
2377
+ handlePointerMove(event) {
2378
+ if (event.pointerType === 'mouse') {
2379
+ this.moveHandler.handlePointerMove(event);
2380
+ this.selectionHandler.handlePointerMove(event);
2381
+ this.resizeHandler.handlePointerMove(event);
2382
+ this.rotationHandler.handlePointerMove(event);
2383
+ this._store.rerender();
2384
+ }
2385
+ if (event.pointerType === 'touch') {
2386
+ if (this._store.state.isScaling === true) {
2387
+ return;
2388
+ }
2389
+ this.rotationHandler.handlePointerMove(event);
2390
+ this.resizeHandler.handlePointerMove(event);
2391
+ this.moveHandler.handlePointerMove(event);
2392
+ this.selectionHandler.handlePointerMove(event);
2393
+ this._store.rerender();
2266
2394
  }
2267
- this.moveHandler.handleMouseDown(event);
2268
- this.selectionHandler.handleMouseDown(event);
2269
- this.resizeHandler.handleMouseDown(event);
2270
- this.rotationHandler.handleMouseDown(event);
2271
- this._store.rerender();
2272
- }
2273
- handleMouseMove(event) {
2274
- this.moveHandler.handleMouseMove(event);
2275
- this.selectionHandler.handleMouseMove(event);
2276
- this.resizeHandler.handleMouseMove(event);
2277
- this.rotationHandler.handleMouseMove(event);
2278
- this._store.rerender();
2279
2395
  }
2280
- handleMouseUp(event) {
2281
- this.moveHandler.handleMouseUp(event);
2282
- this.selectionHandler.handleMouseUp(event);
2283
- this.resizeHandler.handleMouseUp(event);
2284
- this.rotationHandler.handleMouseUp(event);
2285
- this._store.rerender();
2396
+ handlePointerUp(event) {
2397
+ if (event.pointerType === 'mouse') {
2398
+ this.moveHandler.handlePointerUp(event);
2399
+ this.selectionHandler.handlePointerUp(event);
2400
+ this.resizeHandler.handlePointerUp(event);
2401
+ this.rotationHandler.handlePointerUp(event);
2402
+ this._store.rerender();
2403
+ }
2404
+ if (event.pointerType === 'touch') {
2405
+ if (this._store.state.isScaling === true) {
2406
+ return;
2407
+ }
2408
+ this.rotationHandler.handlePointerUp(event);
2409
+ this.resizeHandler.handlePointerUp(event);
2410
+ this.moveHandler.handlePointerUp(event);
2411
+ this.selectionHandler.handlePointerUp(event);
2412
+ }
2286
2413
  }
2287
2414
  handleDoubleClick(event) {
2288
2415
  var _a;
@@ -2314,50 +2441,6 @@ class KritzelSelectionTool extends KritzelBaseTool {
2314
2441
  }, 300);
2315
2442
  }
2316
2443
  }
2317
- handleTouchStart(event) {
2318
- if (this._store.state.isScaling === true) {
2319
- return;
2320
- }
2321
- if (this._store.state.touchCount === 1) {
2322
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2323
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2324
- this._store.state.resizeHandleType = this.getHandleType(event);
2325
- const selectedObject = this.getSelectedObject(event);
2326
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2327
- if (!this._store.state.selectionGroup && selectedObject) {
2328
- this._store.state.skipContextMenu = true;
2329
- }
2330
- if ((selectedObject === null || isDifferentObject) &&
2331
- this._store.state.selectionGroup &&
2332
- !this._store.state.isResizeHandleSelected &&
2333
- !this._store.state.isRotationHandleSelected) {
2334
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2335
- }
2336
- }
2337
- this.rotationHandler.handleTouchStart(event);
2338
- this.resizeHandler.handleTouchStart(event);
2339
- this.moveHandler.handleTouchStart(event);
2340
- this.selectionHandler.handleTouchStart(event);
2341
- }
2342
- handleTouchMove(event) {
2343
- if (this._store.state.isScaling === true) {
2344
- return;
2345
- }
2346
- this.rotationHandler.handleTouchMove(event);
2347
- this.resizeHandler.handleTouchMove(event);
2348
- this.moveHandler.handleTouchMove(event);
2349
- this.selectionHandler.handleTouchMove(event);
2350
- this._store.rerender();
2351
- }
2352
- handleTouchEnd(event) {
2353
- if (this._store.state.isScaling === true) {
2354
- return;
2355
- }
2356
- this.rotationHandler.handleTouchEnd(event);
2357
- this.resizeHandler.handleTouchEnd(event);
2358
- this.moveHandler.handleTouchEnd(event);
2359
- this.selectionHandler.handleTouchEnd(event);
2360
- }
2361
2444
  getSelectedObject(event) {
2362
2445
  const path = event.composedPath().slice(1);
2363
2446
  const objectElement = path.find(element => element.classList && element.classList.contains('object'));
@@ -2851,7 +2934,7 @@ const DEFAULT_KRITZEL_CONTROLS = [
2851
2934
  },
2852
2935
  ];
2853
2936
 
2854
- const kritzelEditorCss = "kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none}kritzel-controls{position:absolute;bottom:28px}";
2937
+ const kritzelEditorCss = "kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-controls{position:absolute;bottom:28px}";
2855
2938
 
2856
2939
  const KritzelEditor = class {
2857
2940
  constructor(hostRef) {
@@ -2900,85 +2983,91 @@ class KritzelViewport {
2900
2983
  this._store.state.hasViewportChanged = true;
2901
2984
  this._store.rerender();
2902
2985
  }
2903
- handleMouseDown(event) {
2904
- const adjustedClientX = event.clientX - this._store.offsetX;
2905
- const adjustedClientY = event.clientY - this._store.offsetY;
2906
- if (KritzelEventHelper.isRightClick(event)) {
2907
- this._store.state.isPanning = true;
2908
- this._store.state.startX = adjustedClientX;
2909
- this._store.state.startY = adjustedClientY;
2910
- }
2911
- }
2912
- handleMouseMove(event) {
2913
- const adjustedClientX = event.clientX - this._store.offsetX;
2914
- const adjustedClientY = event.clientY - this._store.offsetY;
2915
- this._store.state.cursorX = adjustedClientX;
2916
- this._store.state.cursorY = adjustedClientY;
2917
- if (this._store.state.isPanning) {
2918
- this._store.state.translateX -= this._store.state.startX - adjustedClientX;
2919
- this._store.state.translateY -= this._store.state.startY - adjustedClientY;
2920
- this._store.state.startX = adjustedClientX;
2921
- this._store.state.startY = adjustedClientY;
2922
- this._store.state.hasViewportChanged = true;
2923
- this._store.state.skipContextMenu = true;
2924
- this._store.rerender();
2986
+ handlePointerDown(event) {
2987
+ if (event.pointerType === 'mouse') {
2988
+ const adjustedClientX = event.clientX - this._store.offsetX;
2989
+ const adjustedClientY = event.clientY - this._store.offsetY;
2990
+ if (event.button === KritzelMouseButton.Right) {
2991
+ this._store.state.isPanning = true;
2992
+ this._store.state.startX = adjustedClientX;
2993
+ this._store.state.startY = adjustedClientY;
2994
+ }
2925
2995
  }
2926
- }
2927
- handleMouseUp(_event) {
2928
- if (this._store.state.isPanning) {
2929
- this._store.state.isPanning = false;
2930
- this._store.rerender();
2996
+ if (event.pointerType === 'touch') {
2997
+ const activePointers = Array.from(this._store.state.pointers.values());
2998
+ if (activePointers.length === 2) {
2999
+ this._store.state.currentPath = null;
3000
+ this._store.state.isScaling = true;
3001
+ const firstTouchX = activePointers[0].clientX - this._store.offsetX;
3002
+ const firstTouchY = activePointers[0].clientY - this._store.offsetY;
3003
+ const secondTouchX = activePointers[1].clientX - this._store.offsetX;
3004
+ const secondTouchY = activePointers[1].clientY - this._store.offsetY;
3005
+ this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
3006
+ this.startX = (firstTouchX + secondTouchX) / 2;
3007
+ this.startY = (firstTouchY + secondTouchY) / 2;
3008
+ this._store.rerender();
3009
+ }
2931
3010
  }
2932
3011
  }
2933
- handleTouchStart(event) {
2934
- this._store.state.touchCount = event.touches.length;
2935
- if (this._store.state.touchCount === 2) {
2936
- this._store.state.currentPath = null;
2937
- this._store.state.isScaling = true;
2938
- const firstTouchX = event.touches[0].clientX - this._store.offsetX;
2939
- const firstTouchY = event.touches[0].clientY - this._store.offsetY;
2940
- const secondTouchX = event.touches[1].clientX - this._store.offsetX;
2941
- const secondTouchY = event.touches[1].clientY - this._store.offsetY;
2942
- this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
2943
- this.startX = (firstTouchX + secondTouchX) / 2;
2944
- this.startY = (firstTouchY + secondTouchY) / 2;
2945
- this._store.rerender();
3012
+ handlePointerMove(event) {
3013
+ if (event.pointerType === 'mouse') {
3014
+ const adjustedClientX = event.clientX - this._store.offsetX;
3015
+ const adjustedClientY = event.clientY - this._store.offsetY;
3016
+ this._store.state.cursorX = adjustedClientX;
3017
+ this._store.state.cursorY = adjustedClientY;
3018
+ if (this._store.state.isPanning) {
3019
+ this._store.state.translateX -= this._store.state.startX - adjustedClientX;
3020
+ this._store.state.translateY -= this._store.state.startY - adjustedClientY;
3021
+ this._store.state.startX = adjustedClientX;
3022
+ this._store.state.startY = adjustedClientY;
3023
+ this._store.state.hasViewportChanged = true;
3024
+ this._store.state.skipContextMenu = true;
3025
+ this._store.rerender();
3026
+ }
2946
3027
  }
2947
- }
2948
- handleTouchMove(event) {
2949
- if (this._store.state.touchCount === 2) {
2950
- const firstTouchX = event.touches[0].clientX - this._store.offsetX;
2951
- const firstTouchY = event.touches[0].clientY - this._store.offsetY;
2952
- const secondTouchX = event.touches[1].clientX - this._store.offsetX;
2953
- const secondTouchY = event.touches[1].clientY - this._store.offsetY;
2954
- const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
2955
- const midpointX = (firstTouchX + secondTouchX) / 2;
2956
- const midpointY = (firstTouchY + secondTouchY) / 2;
2957
- const scaleRatio = currentTouchDistance / this.initialTouchDistance;
2958
- const newScale = this._store.state.scale * scaleRatio;
2959
- if (newScale > this._store.state.scaleMax || newScale < this._store.state.scaleMin) {
2960
- this._store.state.translateX += midpointX - this.startX;
2961
- this._store.state.translateY += midpointY - this.startY;
3028
+ if (event.pointerType === 'touch') {
3029
+ const activePointers = Array.from(this._store.state.pointers.values());
3030
+ if (activePointers.length === 2) {
3031
+ const firstTouchX = activePointers[0].clientX - this._store.offsetX;
3032
+ const firstTouchY = activePointers[0].clientY - this._store.offsetY;
3033
+ const secondTouchX = activePointers[1].clientX - this._store.offsetX;
3034
+ const secondTouchY = activePointers[1].clientY - this._store.offsetY;
3035
+ const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
3036
+ const midpointX = (firstTouchX + secondTouchX) / 2;
3037
+ const midpointY = (firstTouchY + secondTouchY) / 2;
3038
+ const scaleRatio = currentTouchDistance / this.initialTouchDistance;
3039
+ const newScale = this._store.state.scale * scaleRatio;
3040
+ if (newScale > this._store.state.scaleMax || newScale < this._store.state.scaleMin) {
3041
+ this._store.state.translateX += midpointX - this.startX;
3042
+ this._store.state.translateY += midpointY - this.startY;
3043
+ }
3044
+ else {
3045
+ const translateXAdjustment = (midpointX - this._store.state.translateX) * (scaleRatio - 1);
3046
+ const translateYAdjustment = (midpointY - this._store.state.translateY) * (scaleRatio - 1);
3047
+ this._store.state.translateX += midpointX - this.startX - translateXAdjustment;
3048
+ this._store.state.translateY += midpointY - this.startY - translateYAdjustment;
3049
+ this._store.state.scale = newScale;
3050
+ this.initialTouchDistance = currentTouchDistance;
3051
+ }
3052
+ this.startX = midpointX;
3053
+ this.startY = midpointY;
3054
+ this._store.state.hasViewportChanged = true;
3055
+ this._store.rerender();
2962
3056
  }
2963
- else {
2964
- const translateXAdjustment = (midpointX - this._store.state.translateX) * (scaleRatio - 1);
2965
- const translateYAdjustment = (midpointY - this._store.state.translateY) * (scaleRatio - 1);
2966
- this._store.state.translateX += midpointX - this.startX - translateXAdjustment;
2967
- this._store.state.translateY += midpointY - this.startY - translateYAdjustment;
2968
- this._store.state.scale = newScale;
2969
- this.initialTouchDistance = currentTouchDistance;
3057
+ }
3058
+ }
3059
+ handlePointerUp(event) {
3060
+ if (event.pointerType === 'mouse') {
3061
+ if (this._store.state.isPanning) {
3062
+ this._store.state.isPanning = false;
3063
+ this._store.rerender();
2970
3064
  }
2971
- this.startX = midpointX;
2972
- this.startY = midpointY;
2973
- this._store.state.hasViewportChanged = true;
3065
+ }
3066
+ if (event.pointerType === 'touch') {
3067
+ this._store.state.isScaling = false;
2974
3068
  this._store.rerender();
2975
3069
  }
2976
3070
  }
2977
- handleTouchEnd(_event) {
2978
- this._store.state.touchCount = 0;
2979
- this._store.state.isScaling = false;
2980
- this._store.rerender();
2981
- }
2982
3071
  handleWheel(event) {
2983
3072
  event.preventDefault();
2984
3073
  if (event.ctrlKey === true && KritzelEventHelper.isMainMouseWheel(event)) {
@@ -3333,9 +3422,9 @@ const DEFAULT_ENGINE_STATE = {
3333
3422
  viewportWidth: 0,
3334
3423
  viewportHeight: 0,
3335
3424
  historyBufferSize: 1000,
3336
- touchCount: 0,
3337
3425
  longTouchTimeout: null,
3338
3426
  longTouchDelay: 300,
3427
+ pointers: new Map()
3339
3428
  };
3340
3429
 
3341
3430
  class KritzelStore {
@@ -3667,46 +3756,6 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
3667
3756
  this.objectContextMenuItems = objectContextMenuItems;
3668
3757
  }
3669
3758
  handleContextMenu(event) {
3670
- if (event.cancelable) {
3671
- event.preventDefault();
3672
- }
3673
- if (!(this._store.state.activeTool instanceof KritzelSelectionTool)) {
3674
- return;
3675
- }
3676
- if (this._store.state.skipContextMenu) {
3677
- this._store.state.skipContextMenu = false;
3678
- return;
3679
- }
3680
- this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
3681
- let x = event.clientX - this._store.offsetX;
3682
- let y = event.clientY - this._store.offsetY;
3683
- const menuWidthEstimate = 150;
3684
- const menuHeightEstimate = 200;
3685
- const margin = 10;
3686
- if (x + menuWidthEstimate > window.innerWidth - margin) {
3687
- x = window.innerWidth - menuWidthEstimate - margin;
3688
- }
3689
- if (y + menuHeightEstimate > window.innerHeight - margin) {
3690
- y = window.innerHeight - menuHeightEstimate - margin;
3691
- }
3692
- x = Math.max(margin, x);
3693
- y = Math.max(margin, y);
3694
- this._store.state.contextMenuX = x;
3695
- this._store.state.contextMenuY = y;
3696
- this._store.state.isContextMenuVisible = true;
3697
- this._store.state.isEnabled = false;
3698
- this._store.rerender();
3699
- }
3700
- handleContextMenuTouch(event) {
3701
- if (event.cancelable) {
3702
- event.preventDefault();
3703
- }
3704
- if (this._store.state.touchCount > 1 || !(this._store.state.activeTool instanceof KritzelSelectionTool)) {
3705
- return;
3706
- }
3707
- if ('vibrate' in navigator) {
3708
- navigator.vibrate(25);
3709
- }
3710
3759
  const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
3711
3760
  if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
3712
3761
  this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
@@ -3717,12 +3766,8 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
3717
3766
  this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
3718
3767
  }
3719
3768
  this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
3720
- const firstTouch = event.touches[0];
3721
- if (!firstTouch) {
3722
- return;
3723
- }
3724
- let x = Math.round(firstTouch.clientX - this._store.offsetX);
3725
- let y = Math.round(firstTouch.clientY - this._store.offsetY);
3769
+ let x = event.clientX - this._store.offsetX;
3770
+ let y = event.clientY - this._store.offsetY;
3726
3771
  const menuWidthEstimate = 150;
3727
3772
  const menuHeightEstimate = 200;
3728
3773
  const margin = 10;
@@ -3742,7 +3787,7 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
3742
3787
  }
3743
3788
  }
3744
3789
 
3745
- const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
3790
+ const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
3746
3791
 
3747
3792
  const KritzelEngine = class {
3748
3793
  get isSelecting() {
@@ -3807,78 +3852,50 @@ const KritzelEngine = class {
3807
3852
  this.viewport = new KritzelViewport(this.store, this.host);
3808
3853
  this.engineReady.emit();
3809
3854
  }
3810
- handleContextMenu(ev) {
3811
- if (this.store.state.isEnabled === false) {
3812
- return;
3813
- }
3814
- this.contextMenuHandler.handleContextMenu(ev);
3815
- }
3816
- handleMouseDown(ev) {
3855
+ handleWheel(ev) {
3817
3856
  var _a, _b;
3818
3857
  if (this.store.state.isContextMenuVisible) {
3819
3858
  this.hideContextMenu();
3820
- return;
3821
3859
  }
3822
- if (this.store.state.isEnabled === false) {
3823
- return;
3824
- }
3825
- this.viewport.handleMouseDown(ev);
3826
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseDown(ev);
3827
- }
3828
- handleMouseMove(ev) {
3829
- var _a, _b;
3830
- if (this.store.state.isEnabled === false) {
3831
- return;
3832
- }
3833
- this.viewport.handleMouseMove(ev);
3834
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseMove(ev);
3860
+ this.viewport.handleWheel(ev);
3861
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleWheel(ev);
3835
3862
  }
3836
- handleMouseUp(ev) {
3863
+ handlePointerDown(ev) {
3837
3864
  var _a, _b;
3838
- if (this.store.state.isEnabled === false) {
3865
+ if (KritzelEventHelper.isPointerEventOnContextMenu(ev) === false && this.store.state.isContextMenuVisible) {
3866
+ this.hideContextMenu();
3839
3867
  return;
3840
3868
  }
3841
- this.viewport.handleMouseUp(ev);
3842
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseUp(ev);
3843
- }
3844
- handleDoubleClick(ev) {
3845
- var _a, _b;
3846
3869
  if (this.store.state.isEnabled === false) {
3847
3870
  return;
3848
3871
  }
3849
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleDoubleClick(ev);
3850
- }
3851
- handleDoubleTap(ev) {
3852
- var _a, _b;
3853
- if (this.store.state.isEnabled === false) {
3854
- return;
3872
+ if (ev.cancelable) {
3873
+ ev.preventDefault();
3855
3874
  }
3856
- const touchEvent = ev instanceof CustomEvent && ev.detail ? ev.detail : ev;
3857
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleDoubleTap(touchEvent);
3875
+ KritzelEventHelper.onLongTouchPress(ev, (event) => {
3876
+ if (!(this.store.state.activeTool instanceof KritzelSelectionTool)) {
3877
+ return;
3878
+ }
3879
+ this.contextMenuHandler.handleContextMenu(event);
3880
+ });
3881
+ this.host.setPointerCapture(ev.pointerId);
3882
+ this.store.state.pointers.set(ev.pointerId, ev);
3883
+ this.viewport.handlePointerDown(ev);
3884
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerDown(ev);
3858
3885
  }
3859
- handleTouchStart(ev) {
3886
+ handlePointerMove(ev) {
3860
3887
  var _a, _b;
3861
3888
  if (this.store.state.isEnabled === false) {
3862
3889
  return;
3863
3890
  }
3864
- if (ev.touches.length === 2) {
3865
- KritzelEventHelper.notifyTwoFingerTouch();
3866
- }
3867
- if (KritzelEventHelper.detectDoubleTap()) {
3868
- const doubleTapEvent = new CustomEvent('doubletap', { detail: event, bubbles: true, composed: true });
3869
- this.host.dispatchEvent(doubleTapEvent);
3870
- }
3871
- if (ev.touches.length > 1) {
3872
- clearTimeout(this.store.state.longTouchTimeout);
3873
- }
3874
3891
  if (ev.cancelable) {
3875
3892
  ev.preventDefault();
3876
3893
  }
3877
- this.store.state.longTouchTimeout = setTimeout(() => this.contextMenuHandler.handleContextMenuTouch(ev), this.store.state.longTouchDelay);
3878
- this.viewport.handleTouchStart(ev);
3879
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchStart(ev);
3894
+ this.store.state.pointers.set(ev.pointerId, ev);
3895
+ this.viewport.handlePointerMove(ev);
3896
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerMove(ev);
3880
3897
  }
3881
- handleTouchMove(ev) {
3898
+ handlePointerUp(ev) {
3882
3899
  var _a, _b;
3883
3900
  if (this.store.state.isEnabled === false) {
3884
3901
  return;
@@ -3886,10 +3903,12 @@ const KritzelEngine = class {
3886
3903
  if (ev.cancelable) {
3887
3904
  ev.preventDefault();
3888
3905
  }
3889
- this.viewport.handleTouchMove(ev);
3890
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchMove(ev);
3906
+ this.store.state.pointers.delete(ev.pointerId);
3907
+ this.host.releasePointerCapture(ev.pointerId);
3908
+ this.viewport.handlePointerUp(ev);
3909
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
3891
3910
  }
3892
- handleTouchEnd(ev) {
3911
+ handlePointerCancel(ev) {
3893
3912
  var _a, _b;
3894
3913
  if (this.store.state.isEnabled === false) {
3895
3914
  return;
@@ -3897,20 +3916,20 @@ const KritzelEngine = class {
3897
3916
  if (ev.cancelable) {
3898
3917
  ev.preventDefault();
3899
3918
  }
3900
- clearTimeout(this.store.state.longTouchTimeout);
3901
- this.viewport.handleTouchEnd(ev);
3902
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchEnd(ev);
3919
+ this.host.releasePointerCapture(ev.pointerId);
3920
+ this.store.state.pointers.delete(ev.pointerId);
3921
+ this.viewport.handlePointerUp(ev);
3922
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
3903
3923
  }
3904
- handleTouchCancel(_ev) {
3905
- clearTimeout(this.store.state.longTouchTimeout);
3906
- }
3907
- handleWheel(ev) {
3908
- var _a, _b;
3909
- if (this.store.state.isContextMenuVisible) {
3910
- this.hideContextMenu();
3924
+ handleContextMenu(ev) {
3925
+ ev.preventDefault();
3926
+ if (this.store.state.isEnabled === false) {
3927
+ return;
3911
3928
  }
3912
- this.viewport.handleWheel(ev);
3913
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleWheel(ev);
3929
+ if (ev.pointerType === 'touch') {
3930
+ return;
3931
+ }
3932
+ this.contextMenuHandler.handleContextMenu(ev);
3914
3933
  }
3915
3934
  handleResize() {
3916
3935
  this.viewport.handleResize();
@@ -3987,6 +4006,7 @@ const KritzelEngine = class {
3987
4006
  this.store.history.redo();
3988
4007
  }
3989
4008
  async hideContextMenu() {
4009
+ this.store.state.pointers.clear();
3990
4010
  this.store.state.isContextMenuVisible = false;
3991
4011
  this.store.state.selectionBox = null;
3992
4012
  this.store.state.isSelecting = false;
@@ -4039,15 +4059,15 @@ const KritzelEngine = class {
4039
4059
  const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
4040
4060
  const baseHandleSize = parseFloat(baseHandleSizePx);
4041
4061
  const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
4042
- return (index.h(index.Host, { key: '7592f0cc9b3c4f5c2c68b8a69151e57e254e1bcd' }, index.h("div", { key: '83d550a8b257c6c30915b4125633410b935df1c7', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: 'aaebf84d2344cf117d7e2b221f4675abfa3e2423' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
4043
- _a.translateX), index.h("div", { key: '0dff156e5b57abe1919af5a14da374ee86f62821' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
4044
- _b.translateY), index.h("div", { key: 'bb7fe1f8442c70e1bd7655ea222f37ed55c0cf8f' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
4045
- _c.viewportWidth), index.h("div", { key: 'c0399a368afa2186ba45e7be6fa69495f77912b2' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
4046
- _d.viewportHeight), index.h("div", { key: '2506ae215413710417a9b494dfeaa06a95381e1e' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '858e6cff62c24d97f36560ca57c59eb90d7fe253' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
4047
- _e.scale), index.h("div", { key: 'b7dd1926a2a374b34ccb0f1af2f5100bb256a323' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
4048
- _g.name), index.h("div", { key: 'e75a98de366a36b9e4a478119db1754df85ce149' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: 'c78c09fbb6efc97be8cde8bc55d2c9ca724d913e' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: '7864d38c808ff8fa01fc24d150ac03ec56eb2111' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '8ce8b3522065ad221d0cac69366199fa78e6c985' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: 'f2dc96d374c66798ab0ec6f4759a851448375def' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '7a8642ee44c2c6d6419da80c2a27b0370c51c67d' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: '9f819435c8ad8c2f836edca397918bd98e2ed34d' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: '252201d35275563594bfe13ae19ded7289d4860a' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '45056c11f0733c433f9a91008d021702df660063' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: 'a6fedfe47aac88ffa4df90da060a28d83f8bf1cf' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: '30b311e5dee2174ba0baea6e5bc9f1fca1a01fac' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: 'e2d1936e16dd5a268dd1efab8b7e67b567170e9b' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
4049
- _m.cursorX), index.h("div", { key: 'bb1e751d01b31ca727c01537927808daec4425e9' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
4050
- _o.cursorY)), index.h("div", { key: 'a5ccd3e025b425660a1dd9ef523db203fcbde610', class: "origin", style: {
4062
+ return (index.h(index.Host, { key: 'a797514d787c08c2cd6a2e526ace31fecddf8956' }, index.h("div", { key: 'd0d23c34809f26ab3c21f756923d1ef7a00ebb41', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: '302b23a9028483c7dc31f4ca983c8036f6de5b25' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
4063
+ _a.translateX), index.h("div", { key: '2224e2bb5bd1feea8a65ac4f082342a40e8e18b5' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
4064
+ _b.translateY), index.h("div", { key: '02108ee26500eb97a08d8460b6b71cdc553d6c90' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
4065
+ _c.viewportWidth), index.h("div", { key: '8e87161155f4e2960985292be3101e9f57893381' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
4066
+ _d.viewportHeight), index.h("div", { key: 'aa2469bda052787a93ea615451676dba4b4fb53e' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '593aaf98bfaec8aae03bd7a3f37e46e14f454333' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
4067
+ _e.scale), index.h("div", { key: '6c9799e82d30236c6f1277830dec32358bfccd93' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
4068
+ _g.name), index.h("div", { key: '3dbbec42f8a699a97ef65b5da35f2611866797e5' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: '03a71e1efab2801e77e0d8dffc7a4814469613c7' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: '7663ed6cad2ed3b9b74bad5cb238a4cf0310e9e1' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '957a1b0906ad9cecc46f470db1ad402d19f94d22' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: 'b73277742d0966445b6f49a0fb1433f80cab1d60' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '6a4e0ca6d868b1f8ccfe2957f352fc454b3527ea' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: 'da9dce9f4c38cd740f27ecc8de3c32edac2a7fe2' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: 'f6b0d7cc9e828cac5a65879b9973944a444be6b1' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '3ef7c46329e47a97703e49f47c8f5325f0d4b9b2' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: 'cab4fb21ede0b4f4925e9d7d2175ad8661f07907' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: '2f4eeaa711a56e2246495fe1eee46d5629c93364' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: 'ee2e5edcd140da8b957b468989c71e7c247063bb' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
4069
+ _m.cursorX), index.h("div", { key: '1fea9888ca2f1a9fed25ad0cac065d8278c78227' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
4070
+ _o.cursorY)), index.h("div", { key: '226c675711317ff06f1db5165fa19794310f2e1e', class: "origin", style: {
4051
4071
  transform: `matrix(${(_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale}, 0, 0, ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale}, ${(_r = this.store.state) === null || _r === void 0 ? void 0 : _r.translateX}, ${(_s = this.store.state) === null || _s === void 0 ? void 0 : _s.translateY})`,
4052
4072
  } }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
4053
4073
  _t.map(object => {
@@ -4094,6 +4114,7 @@ const KritzelEngine = class {
4094
4114
  display: 'block',
4095
4115
  padding: '1px',
4096
4116
  whiteSpace: 'nowrap',
4117
+ pointerEvents: object.isReadonly ? 'none' : 'auto',
4097
4118
  cursor: object.isReadonly ? 'default' : 'text',
4098
4119
  caretColor: object.isReadonly ? 'transparent' : 'auto',
4099
4120
  } })), object instanceof KritzelSelectionGroup && (index.h("div", { ref: el => object.mount(el), style: {
@@ -4143,7 +4164,7 @@ const KritzelEngine = class {
4143
4164
  fill: 'transparent',
4144
4165
  cursor: 'grab',
4145
4166
  }, visibility: object.selected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, index.h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.debugInfoVisible ? 'block' : 'none' } }, index.h("div", { style: { width: '100%', height: '100%' } }, index.h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), index.h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), index.h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), index.h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), index.h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), index.h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), index.h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation)))))));
4146
- }), index.h("svg", { key: 'c2b10893d4bea0e25c98058e640ad8eef6135a80', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
4167
+ }), index.h("svg", { key: '34f891f9408d3b0174c67b869f49cce7329fd84a', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
4147
4168
  height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
4148
4169
  width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
4149
4170
  left: '0',
@@ -4153,12 +4174,12 @@ const KritzelEngine = class {
4153
4174
  transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
4154
4175
  transformOrigin: 'top left',
4155
4176
  overflow: 'visible',
4156
- }, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '84b018b26b93e0f382062ac2e24efbce8bc07e3f', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (index.h("kritzel-context-menu", { key: 'c372bd8595656b35d7eed2e38400490e7d71808b', ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
4177
+ }, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '97360b7270a285a87a45459e497968a444cc83cb', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (index.h("kritzel-context-menu", { key: '111d7b1daccd69aaf914dfcd51f525f2ad81802e', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
4157
4178
  position: 'fixed',
4158
4179
  left: `${this.store.state.contextMenuX}px`,
4159
4180
  top: `${this.store.state.contextMenuY}px`,
4160
4181
  zIndex: '10000',
4161
- }, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: 'ce67e9df4714a9585bb1a8db3780baff6faeb66d' })));
4182
+ }, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: '9814ec7d95a84edc8af1bff319eff5f59b8cfc86' })));
4162
4183
  }
4163
4184
  get host() { return index.getElement(this); }
4164
4185
  };