kritzel-stencil 0.0.118 → 0.0.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-CXT94beA.js → index-BcrLbdO1.js} +50 -10
- package/dist/cjs/index-BcrLbdO1.js.map +1 -0
- package/dist/cjs/index-BjLSiQIM.js +2342 -0
- package/dist/cjs/index-BjLSiQIM.js.map +1 -0
- package/dist/cjs/index.cjs.js +8 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +362 -1743
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/stencil.cjs.js +3 -3
- package/dist/cjs/stencil.cjs.js.map +1 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +2 -0
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +4 -0
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/image.class.js +23 -2
- package/dist/collection/classes/objects/image.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +15 -5
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +2 -1
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/store.class.js +2 -13
- package/dist/collection/classes/store.class.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +6 -23
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +4 -13
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/viewport.class.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +217 -13
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +158 -68
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +104 -4
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +30 -9
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
- package/dist/collection/configs/default-brush-tool.config.js +60 -0
- package/dist/collection/configs/default-brush-tool.config.js.map +1 -0
- package/dist/collection/configs/default-engine-state.js +6 -2
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/configs/default-text-tool.config.js +32 -0
- package/dist/collection/configs/default-text-tool.config.js.map +1 -0
- package/dist/collection/constants/engine.constants.js +3 -0
- package/dist/collection/constants/engine.constants.js.map +1 -0
- package/dist/collection/index.js +8 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/context-menu-item.interface.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/object.interface.js.map +1 -1
- package/dist/components/index.js +4 -4
- package/dist/components/kritzel-brush-style.js +1 -1
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-control-brush-config.js +1 -1
- package/dist/components/kritzel-control-text-config.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +110 -68
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/{p-CtNzxQ7T.js → p--2FkikYE.js} +4 -4
- package/dist/components/{p-CtNzxQ7T.js.map → p--2FkikYE.js.map} +1 -1
- package/dist/components/{p-LIijWPsT.js → p--tElassI.js} +4 -4
- package/dist/components/{p-LIijWPsT.js.map → p--tElassI.js.map} +1 -1
- package/dist/components/{p-C6kzcN4b.js → p-B2wWYPH8.js} +4 -4
- package/dist/components/{p-C6kzcN4b.js.map → p-B2wWYPH8.js.map} +1 -1
- package/dist/components/{p-93b-eQ0s.js → p-BAMl2Ww6.js} +29 -27
- package/dist/components/p-BAMl2Ww6.js.map +1 -0
- package/dist/components/{p-B8nuvSxt.js → p-BSS4UREq.js} +10 -10
- package/dist/components/{p-B8nuvSxt.js.map → p-BSS4UREq.js.map} +1 -1
- package/dist/components/{p-JQA2FRVr.js → p-C3E9PtD3.js} +11 -11
- package/dist/components/{p-JQA2FRVr.js.map → p-C3E9PtD3.js.map} +1 -1
- package/dist/components/{p-B57pFHwJ.js → p-CDpq9L_H.js} +4 -4
- package/dist/components/{p-B57pFHwJ.js.map → p-CDpq9L_H.js.map} +1 -1
- package/dist/components/p-CEYRFk55.js +119 -0
- package/dist/components/p-CEYRFk55.js.map +1 -0
- package/dist/components/{p-BV9-NuyD.js → p-CIb4IA9u.js} +6 -6
- package/dist/components/{p-BV9-NuyD.js.map → p-CIb4IA9u.js.map} +1 -1
- package/dist/components/{p-eBBOf568.js → p-CqPrOhzi.js} +5 -5
- package/dist/components/{p-eBBOf568.js.map → p-CqPrOhzi.js.map} +1 -1
- package/dist/components/{p-CaQ7Iei7.js → p-CxmkJbeV.js} +4 -4
- package/dist/components/{p-CaQ7Iei7.js.map → p-CxmkJbeV.js.map} +1 -1
- package/dist/components/{p-yBnfPxIa.js → p-D-Rf05Ov.js} +5 -5
- package/dist/components/{p-yBnfPxIa.js.map → p-D-Rf05Ov.js.map} +1 -1
- package/dist/components/{p-CSSrNLad.js → p-D0L3GqSK.js} +4 -4
- package/dist/components/{p-CSSrNLad.js.map → p-D0L3GqSK.js.map} +1 -1
- package/dist/components/{p-fmNiA3Yr.js → p-D1oFXBAp.js} +5 -5
- package/dist/components/{p-fmNiA3Yr.js.map → p-D1oFXBAp.js.map} +1 -1
- package/dist/components/{p-DRuQsvUx.js → p-DC3j4P1n.js} +23 -8
- package/dist/components/p-DC3j4P1n.js.map +1 -0
- package/dist/components/{p-D04aTZsR.js → p-DbPbyRLO.js} +5 -5
- package/dist/components/{p-D04aTZsR.js.map → p-DbPbyRLO.js.map} +1 -1
- package/dist/components/{p-DoQOtXjT.js → p-dCaxwGmu.js} +44 -9
- package/dist/components/p-dCaxwGmu.js.map +1 -0
- package/dist/components/{p-DuWb7MaD.js → p-eS30Bqrc.js} +136 -125
- package/dist/components/p-eS30Bqrc.js.map +1 -0
- package/dist/components/{p-BBIuV3j1.js → p-gDLg_PJJ.js} +5 -5
- package/dist/components/{p-BBIuV3j1.js.map → p-gDLg_PJJ.js.map} +1 -1
- package/dist/esm/{index-CGHvfMWF.js → index-BPFXWTBp.js} +50 -10
- package/dist/esm/index-BPFXWTBp.js.map +1 -0
- package/dist/esm/index-DsUDklEm.js +2318 -0
- package/dist/esm/index-DsUDklEm.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-brush-style_18.entry.js +332 -1713
- package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/stencil.js +4 -4
- package/dist/esm/stencil.js.map +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-0ae72b0d.entry.js +2 -0
- package/dist/stencil/p-0ae72b0d.entry.js.map +1 -0
- package/dist/stencil/p-BPFXWTBp.js +3 -0
- package/dist/stencil/p-BPFXWTBp.js.map +1 -0
- package/dist/stencil/p-DsUDklEm.js +2 -0
- package/dist/stencil/p-DsUDklEm.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/stencil/stencil.esm.js.map +1 -1
- package/dist/types/classes/objects/base-object.class.d.ts +3 -1
- package/dist/types/classes/objects/image.class.d.ts +8 -0
- package/dist/types/classes/objects/path.class.d.ts +9 -0
- package/dist/types/classes/objects/text.class.d.ts +2 -1
- package/dist/types/classes/store.class.d.ts +1 -1
- package/dist/types/classes/tools/image-tool.class.d.ts +0 -4
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +9 -3
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +12 -4
- package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +8 -0
- package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +2 -1
- package/dist/types/components.d.ts +77 -22
- package/dist/types/configs/default-brush-tool.config.d.ts +2 -0
- package/dist/types/configs/default-text-tool.config.d.ts +2 -0
- package/dist/types/constants/engine.constants.d.ts +2 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/interfaces/context-menu-item.interface.d.ts +13 -2
- package/dist/types/interfaces/engine-state.interface.d.ts +5 -1
- package/dist/types/interfaces/object.interface.d.ts +2 -0
- package/package.json +1 -1
- package/dist/cjs/index-CXT94beA.js.map +0 -1
- package/dist/cjs/index-aaWestcD.js +0 -827
- package/dist/cjs/index-aaWestcD.js.map +0 -1
- package/dist/collection/configs/default-toolbar-controls.js +0 -139
- package/dist/collection/configs/default-toolbar-controls.js.map +0 -1
- package/dist/components/p-93b-eQ0s.js.map +0 -1
- package/dist/components/p-CYnE3twZ.js +0 -49
- package/dist/components/p-CYnE3twZ.js.map +0 -1
- package/dist/components/p-DRuQsvUx.js.map +0 -1
- package/dist/components/p-DoQOtXjT.js.map +0 -1
- package/dist/components/p-DuWb7MaD.js.map +0 -1
- package/dist/esm/index-CGHvfMWF.js.map +0 -1
- package/dist/esm/index-Dn7aP72S.js +0 -814
- package/dist/esm/index-Dn7aP72S.js.map +0 -1
- package/dist/stencil/p-6c35ba88.entry.js +0 -2
- package/dist/stencil/p-6c35ba88.entry.js.map +0 -1
- package/dist/stencil/p-CGHvfMWF.js +0 -3
- package/dist/stencil/p-CGHvfMWF.js.map +0 -1
- package/dist/stencil/p-Dn7aP72S.js +0 -2
- package/dist/stencil/p-Dn7aP72S.js.map +0 -1
- package/dist/types/configs/default-toolbar-controls.d.ts +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var index$1 = require('./index-
|
|
3
|
+
var index = require('./index-BcrLbdO1.js');
|
|
4
|
+
var index$1 = require('./index-BjLSiQIM.js');
|
|
5
5
|
|
|
6
6
|
const kritzelBrushStyleCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.brush-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:default;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}";
|
|
7
7
|
|
|
@@ -128,17 +128,82 @@ const KritzelContextMenu = class {
|
|
|
128
128
|
constructor(hostRef) {
|
|
129
129
|
index.registerInstance(this, hostRef);
|
|
130
130
|
this.actionSelected = index.createEvent(this, "actionSelected");
|
|
131
|
+
this.disabledStates = new Map();
|
|
132
|
+
this.visibleItems = [];
|
|
131
133
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
componentWillLoad() {
|
|
135
|
+
this.resolveVisibleItems();
|
|
136
|
+
this.resolveDisabledStates();
|
|
137
|
+
}
|
|
138
|
+
onItemsChanged() {
|
|
139
|
+
this.resolveVisibleItems();
|
|
140
|
+
this.resolveDisabledStates();
|
|
141
|
+
}
|
|
142
|
+
handleItemClick(item, index) {
|
|
143
|
+
if (!this.disabledStates.get(index)) {
|
|
135
144
|
this.actionSelected.emit(item);
|
|
136
145
|
}
|
|
137
146
|
}
|
|
147
|
+
async resolveVisibleItems() {
|
|
148
|
+
const visibleItems = [];
|
|
149
|
+
const visibilityPromises = this.items.map(async (item, index) => {
|
|
150
|
+
let isVisible = true;
|
|
151
|
+
if (item.visible !== undefined) {
|
|
152
|
+
if (typeof item.visible === 'boolean') {
|
|
153
|
+
isVisible = item.visible;
|
|
154
|
+
}
|
|
155
|
+
else if (typeof item.visible === 'function') {
|
|
156
|
+
const result = item.visible(null, this.objects);
|
|
157
|
+
if (result instanceof Promise) {
|
|
158
|
+
isVisible = await result;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
isVisible = result;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { item, index, isVisible };
|
|
166
|
+
});
|
|
167
|
+
const visibilityResults = await Promise.all(visibilityPromises);
|
|
168
|
+
visibilityResults.forEach(({ item, isVisible }) => {
|
|
169
|
+
if (isVisible) {
|
|
170
|
+
visibleItems.push(item);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
this.visibleItems = visibleItems;
|
|
174
|
+
}
|
|
175
|
+
async resolveDisabledStates() {
|
|
176
|
+
const newStates = new Map();
|
|
177
|
+
const disabledPromises = this.visibleItems.map(async (item, index) => {
|
|
178
|
+
let isDisabled = false;
|
|
179
|
+
if (typeof item.disabled === 'boolean') {
|
|
180
|
+
isDisabled = item.disabled;
|
|
181
|
+
}
|
|
182
|
+
else if (typeof item.disabled === 'function') {
|
|
183
|
+
const result = item.disabled(null, this.objects);
|
|
184
|
+
if (result instanceof Promise) {
|
|
185
|
+
isDisabled = await result;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
isDisabled = result;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
newStates.set(index, isDisabled);
|
|
192
|
+
});
|
|
193
|
+
await Promise.all(disabledPromises);
|
|
194
|
+
this.disabledStates = new Map(newStates);
|
|
195
|
+
}
|
|
138
196
|
render() {
|
|
139
|
-
return (index.h(index.Host, { key: '
|
|
197
|
+
return (index.h(index.Host, { key: '3265d2e63ff1e1f91faf1c6c5da3490687f3adb1' }, index.h("div", { key: '80b2100e2ffcaba25ca08cfec650b1f7558c5d25', class: "menu-container" }, this.visibleItems.map((item, index$1) => {
|
|
198
|
+
var _a;
|
|
199
|
+
const isDisabled = (_a = this.disabledStates.get(index$1)) !== null && _a !== void 0 ? _a : false;
|
|
200
|
+
return (index.h("button", { key: `${item.label}-${index$1}`, class: { 'menu-item': true, 'disabled': isDisabled }, onClick: () => this.handleItemClick(item, index$1), onTouchStart: () => this.handleItemClick(item, index$1), disabled: isDisabled }, item.icon && index.h("kritzel-icon", { name: item.icon, size: 16 }), index.h("span", { class: "label" }, item.label)));
|
|
201
|
+
}))));
|
|
140
202
|
}
|
|
141
203
|
get hostElement() { return index.getElement(this); }
|
|
204
|
+
static get watchers() { return {
|
|
205
|
+
"items": ["onItemsChanged"]
|
|
206
|
+
}; }
|
|
142
207
|
};
|
|
143
208
|
KritzelContextMenu.style = kritzelContextMenuCss;
|
|
144
209
|
|
|
@@ -226,118 +291,6 @@ const KritzelControlTextConfig = class {
|
|
|
226
291
|
};
|
|
227
292
|
KritzelControlTextConfig.style = kritzelControlTextConfigCss;
|
|
228
293
|
|
|
229
|
-
class KritzelBrushTool extends index$1.KritzelBaseTool {
|
|
230
|
-
constructor(store) {
|
|
231
|
-
super(store);
|
|
232
|
-
this.type = 'pen';
|
|
233
|
-
this.color = '#000000';
|
|
234
|
-
this.size = 6;
|
|
235
|
-
this.palettes = {
|
|
236
|
-
pen: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#808080', '#C0C0C0', '#800000', '#008000', '#000080', '#808000', '#800080'],
|
|
237
|
-
highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
handlePointerDown(event) {
|
|
241
|
-
if (event.cancelable) {
|
|
242
|
-
event.preventDefault();
|
|
243
|
-
}
|
|
244
|
-
if (event.pointerType === 'mouse') {
|
|
245
|
-
if (index$1.KritzelEventHelper.isLeftClick(event)) {
|
|
246
|
-
this._store.state.isDrawing = true;
|
|
247
|
-
const x = event.clientX - this._store.offsetX;
|
|
248
|
-
const y = event.clientY - this._store.offsetY;
|
|
249
|
-
this._store.state.currentPath = index$1.KritzelPath.create(this._store, {
|
|
250
|
-
points: [[x, y]],
|
|
251
|
-
translateX: -this._store.state.translateX,
|
|
252
|
-
translateY: -this._store.state.translateY,
|
|
253
|
-
scale: this._store.state.scale,
|
|
254
|
-
fill: this.color,
|
|
255
|
-
strokeWidth: this.size,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (event.pointerType === 'touch') {
|
|
260
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
261
|
-
if (activePointers.length === 1) {
|
|
262
|
-
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
263
|
-
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
264
|
-
this._store.state.isDrawing = true;
|
|
265
|
-
this._store.state.currentPath = index$1.KritzelPath.create(this._store, {
|
|
266
|
-
points: [[x, y]],
|
|
267
|
-
translateX: -this._store.state.translateX,
|
|
268
|
-
translateY: -this._store.state.translateY,
|
|
269
|
-
scale: this._store.state.scale,
|
|
270
|
-
fill: this.color,
|
|
271
|
-
strokeWidth: this.size,
|
|
272
|
-
});
|
|
273
|
-
this._store.rerender();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
handlePointerMove(event) {
|
|
278
|
-
if (event.cancelable) {
|
|
279
|
-
event.preventDefault();
|
|
280
|
-
}
|
|
281
|
-
if (event.pointerType === 'mouse') {
|
|
282
|
-
if (this._store.state.isDrawing) {
|
|
283
|
-
const x = event.clientX - this._store.offsetX;
|
|
284
|
-
const y = event.clientY - this._store.offsetY;
|
|
285
|
-
this._store.state.currentPath = index$1.KritzelPath.create(this._store, {
|
|
286
|
-
points: [...this._store.state.currentPath.points, [x, y]],
|
|
287
|
-
translateX: -this._store.state.translateX,
|
|
288
|
-
translateY: -this._store.state.translateY,
|
|
289
|
-
scale: this._store.state.scale,
|
|
290
|
-
fill: this.color,
|
|
291
|
-
strokeWidth: this.size,
|
|
292
|
-
});
|
|
293
|
-
this._store.rerender();
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
if (event.pointerType === 'touch') {
|
|
297
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
298
|
-
if (activePointers.length === 1) {
|
|
299
|
-
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
300
|
-
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
301
|
-
this._store.state.currentPath = index$1.KritzelPath.create(this._store, {
|
|
302
|
-
points: [...this._store.state.currentPath.points, [x, y]],
|
|
303
|
-
translateX: -this._store.state.translateX,
|
|
304
|
-
translateY: -this._store.state.translateY,
|
|
305
|
-
scale: this._store.state.scale,
|
|
306
|
-
fill: this.color,
|
|
307
|
-
strokeWidth: this.size,
|
|
308
|
-
});
|
|
309
|
-
this._store.rerender();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
handlePointerUp(event) {
|
|
314
|
-
if (event.cancelable) {
|
|
315
|
-
event.preventDefault();
|
|
316
|
-
}
|
|
317
|
-
if (event.pointerType === 'mouse') {
|
|
318
|
-
if (this._store.state.isDrawing) {
|
|
319
|
-
this._store.state.isDrawing = false;
|
|
320
|
-
if (this._store.state.currentPath) {
|
|
321
|
-
this._store.state.currentPath.zIndex = this._store.currentZIndex;
|
|
322
|
-
this._store.history.executeCommand(new index$1.AddObjectCommand(this._store, this, this._store.state.currentPath));
|
|
323
|
-
}
|
|
324
|
-
this._store.state.currentPath = undefined;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
if (event.pointerType === 'touch') {
|
|
328
|
-
if (this._store.state.isDrawing) {
|
|
329
|
-
this._store.state.isDrawing = false;
|
|
330
|
-
if (this._store.state.currentPath) {
|
|
331
|
-
this._store.state.currentPath.zIndex = this._store.currentZIndex;
|
|
332
|
-
this._store.history.executeCommand(new index$1.AddObjectCommand(this._store, this, this._store.state.currentPath));
|
|
333
|
-
}
|
|
334
|
-
this._store.state.currentPath = undefined;
|
|
335
|
-
this._store.rerender();
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
294
|
class KritzelDevicesHelper {
|
|
342
295
|
static isTouchDevice() {
|
|
343
296
|
return window.matchMedia('(any-pointer: coarse)').matches;
|
|
@@ -352,8 +305,9 @@ const KritzelControls = class {
|
|
|
352
305
|
this.isControlsReady = index.createEvent(this, "isControlsReady");
|
|
353
306
|
this.controls = [];
|
|
354
307
|
this.activeControl = null;
|
|
308
|
+
this.isUtilityPanelVisible = true;
|
|
355
309
|
this.firstConfig = null;
|
|
356
|
-
this.
|
|
310
|
+
this.isTooltipVisible = false;
|
|
357
311
|
this.isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
358
312
|
this.kritzelEngine = null;
|
|
359
313
|
}
|
|
@@ -367,12 +321,12 @@ const KritzelControls = class {
|
|
|
367
321
|
if (!this.kritzelEngine || element.closest('.kritzel-tooltip')) {
|
|
368
322
|
return;
|
|
369
323
|
}
|
|
370
|
-
this.
|
|
324
|
+
this.isTooltipVisible = false;
|
|
371
325
|
this.kritzelEngine.enable();
|
|
372
326
|
}
|
|
373
327
|
async closeTooltip() {
|
|
374
328
|
var _a;
|
|
375
|
-
this.
|
|
329
|
+
this.isTooltipVisible = false;
|
|
376
330
|
(_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.enable();
|
|
377
331
|
}
|
|
378
332
|
get activeToolAsTextTool() {
|
|
@@ -422,7 +376,7 @@ const KritzelControls = class {
|
|
|
422
376
|
}
|
|
423
377
|
handleConfigClick(event) {
|
|
424
378
|
event.stopPropagation();
|
|
425
|
-
this.
|
|
379
|
+
this.isTooltipVisible = !this.isTooltipVisible;
|
|
426
380
|
this.kritzelEngine.disable();
|
|
427
381
|
}
|
|
428
382
|
async handleToolChange(event) {
|
|
@@ -432,13 +386,13 @@ const KritzelControls = class {
|
|
|
432
386
|
render() {
|
|
433
387
|
var _a, _b;
|
|
434
388
|
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;
|
|
435
|
-
return (index.h(index.Host, { key: '
|
|
389
|
+
return (index.h(index.Host, { key: '5531510d4b95c082148ce3e8f5d3048f808162b2', class: {
|
|
436
390
|
mobile: this.isTouchDevice,
|
|
437
|
-
} }, index.h("kritzel-utility-panel", { key: '
|
|
391
|
+
} }, this.isUtilityPanelVisible && (index.h("kritzel-utility-panel", { key: 'e7e58ee4ae6a8a77918d5c8a954c2dcae287b265', style: {
|
|
438
392
|
position: 'absolute',
|
|
439
393
|
bottom: '56px',
|
|
440
394
|
left: '12px',
|
|
441
|
-
}, 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: '
|
|
395
|
+
}, 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: '65ad87089a38f3e89f8332fc6f261555c2e7eb40', class: "kritzel-controls" }, this.controls.map(control => {
|
|
442
396
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
443
397
|
if (control.type === 'tool') {
|
|
444
398
|
return (index.h("button", { class: {
|
|
@@ -450,10 +404,10 @@ const KritzelControls = class {
|
|
|
450
404
|
return index.h("div", { class: "kritzel-divider", key: control.name });
|
|
451
405
|
}
|
|
452
406
|
if (control.type === 'config' && control.name === ((_b = this.firstConfig) === null || _b === void 0 ? void 0 : _b.name) && this.activeControl) {
|
|
453
|
-
return (index.h("div", { class: "kritzel-config-container", key: control.name }, index.h("kritzel-tooltip", { isVisible: this.
|
|
407
|
+
return (index.h("div", { class: "kritzel-config-container", key: control.name }, index.h("kritzel-tooltip", { isVisible: this.isTooltipVisible, anchorElement: (_c = this.host.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.kritzel-config-container') }, index.h("div", { style: { width: '294px', height: '100%' } }, this.activeControl.name === 'brush' && (index.h("kritzel-control-brush-config", { tool: this.activeToolAsBrushTool, onToolChange: event => { var _a; return (_a = this.handleToolChange) === null || _a === void 0 ? void 0 : _a.call(this, event); } })), this.activeControl.name === 'text' && (index.h("kritzel-control-text-config", { tool: this.activeToolAsTextTool, onToolChange: event => { var _a; return (_a = this.handleToolChange) === null || _a === void 0 ? void 0 : _a.call(this, event); } })))), index.h("div", { class: "kritzel-config", onClick: event => { var _a; return (_a = this.handleConfigClick) === null || _a === void 0 ? void 0 : _a.call(this, event); }, style: {
|
|
454
408
|
cursor: this.activeControl.config ? 'pointer' : 'default',
|
|
455
409
|
pointerEvents: hasNoConfig ? 'none' : 'auto',
|
|
456
|
-
} }, this.activeControl.tool instanceof KritzelBrushTool && (index.h("div", { class: "color-container" }, index.h("kritzel-color", { value: (_d = this.activeToolAsBrushTool) === null || _d === void 0 ? void 0 : _d.color, size: (_e = this.activeToolAsBrushTool) === null || _e === void 0 ? void 0 : _e.size, style: {
|
|
410
|
+
} }, this.activeControl.tool instanceof index$1.KritzelBrushTool && (index.h("div", { class: "color-container" }, index.h("kritzel-color", { value: (_d = this.activeToolAsBrushTool) === null || _d === void 0 ? void 0 : _d.color, size: (_e = this.activeToolAsBrushTool) === null || _e === void 0 ? void 0 : _e.size, style: {
|
|
457
411
|
borderRadius: '50%',
|
|
458
412
|
border: 'none',
|
|
459
413
|
} }))), this.activeControl.tool instanceof index$1.KritzelTextTool && (index.h("div", { class: "font-container" }, index.h("kritzel-font", { fontFamily: (_f = this.activeToolAsTextTool) === null || _f === void 0 ? void 0 : _f.fontFamily, size: (_g = this.activeToolAsTextTool) === null || _g === void 0 ? void 0 : _g.fontSize, color: (_h = this.activeToolAsTextTool) === null || _h === void 0 ? void 0 : _h.fontColor }))), hasNoConfig && index.h("div", { class: "no-config" }))));
|
|
@@ -576,1538 +530,119 @@ const KritzelDropdown = class {
|
|
|
576
530
|
const newHasContent = this.suffixSlotElement.assignedNodes({ flatten: true }).length > 0;
|
|
577
531
|
if (this.hasSuffixContent !== newHasContent) {
|
|
578
532
|
this.hasSuffixContent = newHasContent;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
if (this.hasSuffixContent !== false) {
|
|
583
|
-
this.hasSuffixContent = false;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
};
|
|
587
|
-
this.evaluatePrefixContent = () => {
|
|
588
|
-
if (this.prefixSlotElement) {
|
|
589
|
-
const newHasContent = this.prefixSlotElement.assignedNodes({ flatten: true }).length > 0;
|
|
590
|
-
if (this.hasPrefixContent !== newHasContent) {
|
|
591
|
-
this.hasPrefixContent = newHasContent;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
else {
|
|
595
|
-
if (this.hasPrefixContent !== false) {
|
|
596
|
-
this.hasPrefixContent = false;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
componentWillLoad() {
|
|
602
|
-
this.updateInternalValue(this.value, false);
|
|
603
|
-
this.evaluateSuffixContent();
|
|
604
|
-
this.evaluatePrefixContent();
|
|
605
|
-
}
|
|
606
|
-
externalValueChanged(newValue) {
|
|
607
|
-
if (newValue !== this.internalValue) {
|
|
608
|
-
this.updateInternalValue(newValue, false);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
optionsChanged() {
|
|
612
|
-
this.updateInternalValue(this.internalValue, true);
|
|
613
|
-
}
|
|
614
|
-
updateInternalValue(proposedValue, emitChange) {
|
|
615
|
-
let finalValue = proposedValue;
|
|
616
|
-
if (this.options && this.options.length > 0) {
|
|
617
|
-
const isValidValue = this.options.some(opt => opt.value === finalValue);
|
|
618
|
-
if (!finalValue || !isValidValue) {
|
|
619
|
-
finalValue = this.options[0].value;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
finalValue = undefined;
|
|
624
|
-
}
|
|
625
|
-
if (this.internalValue !== finalValue) {
|
|
626
|
-
this.internalValue = finalValue;
|
|
627
|
-
if (emitChange || (proposedValue !== finalValue && proposedValue !== undefined)) {
|
|
628
|
-
this.valueChanged.emit(this.internalValue);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
render() {
|
|
633
|
-
const selectClasses = {
|
|
634
|
-
'custom-select': true,
|
|
635
|
-
'has-suffix-border': this.hasSuffixContent,
|
|
636
|
-
'has-prefix-border': this.hasPrefixContent,
|
|
637
|
-
};
|
|
638
|
-
return (index.h(index.Host, { key: '32c5f5a4f807c1e316c91b795c005b8d30ce6189' }, index.h("div", { key: 'b1cbeff18e688da4a2f7472be290b9527a619f07', class: "dropdown-wrapper" }, index.h("slot", { key: 'b3bbb7e21c6f5620cab41aa4b1c7206b6c75fd86', name: "prefix", ref: el => this.prefixSlotElement = el, onSlotchange: this.evaluatePrefixContent }), index.h("select", { key: '8b2dcdc125bee59cf29fce7c980b755e78d5816e', class: selectClasses, style: Object.assign(Object.assign({}, this.selectStyles), { width: this.width }), onInput: this.handleSelectChange }, this.options.map(option => (index.h("option", { value: option.value, style: option.style, selected: option.value === this.internalValue }, option.label)))), index.h("slot", { key: '8d83f0dea41ac959bf2392948efef33bb70d0154', name: "suffix", ref: el => this.suffixSlotElement = el, onSlotchange: this.evaluateSuffixContent }))));
|
|
639
|
-
}
|
|
640
|
-
static get watchers() { return {
|
|
641
|
-
"value": ["externalValueChanged"],
|
|
642
|
-
"options": ["optionsChanged"]
|
|
643
|
-
}; }
|
|
644
|
-
};
|
|
645
|
-
KritzelDropdown.style = kritzelDropdownCss;
|
|
646
|
-
|
|
647
|
-
class KritzelIconRegistry {
|
|
648
|
-
static register(name, svgContent) {
|
|
649
|
-
if (this.registry.has(name)) {
|
|
650
|
-
console.warn(`[IconRegistry] Icon "${name}" is already registered. It will be overwritten.`);
|
|
651
|
-
}
|
|
652
|
-
this.registry.set(name, svgContent);
|
|
653
|
-
}
|
|
654
|
-
static get(name) {
|
|
655
|
-
return this.registry.get(name);
|
|
656
|
-
}
|
|
657
|
-
static registerIcons(icons) {
|
|
658
|
-
for (const name in icons) {
|
|
659
|
-
if (Object.prototype.hasOwnProperty.call(icons, name)) {
|
|
660
|
-
this.register(name, icons[name]);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
static has(name) {
|
|
665
|
-
return this.registry.has(name);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
KritzelIconRegistry.registry = new Map();
|
|
669
|
-
KritzelIconRegistry.registerIcons({
|
|
670
|
-
'cursor': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',
|
|
671
|
-
'pen': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',
|
|
672
|
-
'highlighter': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',
|
|
673
|
-
'eraser': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',
|
|
674
|
-
'type': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',
|
|
675
|
-
'image': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
|
|
676
|
-
'chevron-down': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',
|
|
677
|
-
'chevron-up': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',
|
|
678
|
-
'copy': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
|
|
679
|
-
'paste': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',
|
|
680
|
-
'cut': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',
|
|
681
|
-
'delete': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',
|
|
682
|
-
'bring-to-front': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',
|
|
683
|
-
'send-to-back': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',
|
|
684
|
-
'select-all': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',
|
|
685
|
-
'download': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',
|
|
686
|
-
'undo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',
|
|
687
|
-
'redo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>'
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
class BatchCommand extends index$1.KritzelBaseCommand {
|
|
691
|
-
constructor(store, initiator, commands) {
|
|
692
|
-
super(store, initiator);
|
|
693
|
-
this.commands = commands;
|
|
694
|
-
}
|
|
695
|
-
execute() {
|
|
696
|
-
this.commands.forEach(command => command.execute());
|
|
697
|
-
}
|
|
698
|
-
undo() {
|
|
699
|
-
this.commands.forEach(command => command.undo());
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
class RemoveObjectCommand extends index$1.KritzelBaseCommand {
|
|
704
|
-
constructor(store, initiator, object) {
|
|
705
|
-
super(store, initiator);
|
|
706
|
-
this.object = object;
|
|
707
|
-
}
|
|
708
|
-
execute() {
|
|
709
|
-
this._store.state.objectsOctree.remove(object => object.id === this.object.id);
|
|
710
|
-
}
|
|
711
|
-
undo() {
|
|
712
|
-
this._store.state.objectsOctree.insert(this.object);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
class KritzelEraserTool extends index$1.KritzelBaseTool {
|
|
717
|
-
constructor(store) {
|
|
718
|
-
super(store);
|
|
719
|
-
this.touchStartTimeout = null;
|
|
720
|
-
}
|
|
721
|
-
handlePointerDown(event) {
|
|
722
|
-
if (event.pointerType === 'mouse') {
|
|
723
|
-
if (index$1.KritzelEventHelper.isLeftClick(event)) {
|
|
724
|
-
this._store.state.isErasing = true;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
if (event.pointerType === 'touch') {
|
|
728
|
-
this.touchStartTimeout = setTimeout(() => {
|
|
729
|
-
if (this._store.state.pointers.size === 1 && !this._store.state.isScaling) {
|
|
730
|
-
this._store.state.isErasing = true;
|
|
731
|
-
}
|
|
732
|
-
}, 80);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
handlePointerMove(event) {
|
|
736
|
-
var _a, _b;
|
|
737
|
-
if (event.pointerType === 'mouse') {
|
|
738
|
-
if (this._store.state.isErasing) {
|
|
739
|
-
const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
|
|
740
|
-
if (!shadowRoot)
|
|
741
|
-
return;
|
|
742
|
-
const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
|
|
743
|
-
if (!selectedObject)
|
|
744
|
-
return;
|
|
745
|
-
selectedObject.markedForRemoval = true;
|
|
746
|
-
this._store.rerender();
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
if (event.pointerType === 'touch') {
|
|
750
|
-
if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
|
|
751
|
-
const shadowRoot = (_b = this._store.state.host) === null || _b === void 0 ? void 0 : _b.shadowRoot;
|
|
752
|
-
if (!shadowRoot)
|
|
753
|
-
return;
|
|
754
|
-
const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
|
|
755
|
-
if (!selectedObject)
|
|
756
|
-
return;
|
|
757
|
-
selectedObject.markedForRemoval = true;
|
|
758
|
-
this._store.rerender();
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
handlePointerUp(event) {
|
|
763
|
-
if (event.pointerType === 'mouse') {
|
|
764
|
-
if (this._store.state.isErasing) {
|
|
765
|
-
const removeCommands = this._store.allObjects
|
|
766
|
-
.filter(object => object.markedForRemoval)
|
|
767
|
-
.map(object => {
|
|
768
|
-
object.markedForRemoval = false;
|
|
769
|
-
return new RemoveObjectCommand(this._store, this, object);
|
|
770
|
-
});
|
|
771
|
-
if (removeCommands.length > 0) {
|
|
772
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
|
|
773
|
-
}
|
|
774
|
-
this._store.state.isErasing = false;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
if (event.pointerType === 'touch') {
|
|
778
|
-
clearTimeout(this.touchStartTimeout);
|
|
779
|
-
if (this._store.state.isErasing) {
|
|
780
|
-
const removeCommands = this._store.allObjects
|
|
781
|
-
.filter(object => object.markedForRemoval)
|
|
782
|
-
.map(object => {
|
|
783
|
-
object.markedForRemoval = false;
|
|
784
|
-
return new RemoveObjectCommand(this._store, this, object);
|
|
785
|
-
});
|
|
786
|
-
if (removeCommands.length > 0) {
|
|
787
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
|
|
788
|
-
}
|
|
789
|
-
this._store.state.isErasing = false;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
class RemoveSelectionGroupCommand extends index$1.KritzelBaseCommand {
|
|
796
|
-
constructor(store, initiator) {
|
|
797
|
-
super(store, initiator);
|
|
798
|
-
this.previousSelectionGroup = this._store.state.selectionGroup;
|
|
799
|
-
}
|
|
800
|
-
execute() {
|
|
801
|
-
this._store.state.objectsOctree.remove(object => { var _a; return object.id === ((_a = this.previousSelectionGroup) === null || _a === void 0 ? void 0 : _a.id); });
|
|
802
|
-
this._store.state.selectionGroup = null;
|
|
803
|
-
}
|
|
804
|
-
undo() {
|
|
805
|
-
if (this.previousSelectionGroup) {
|
|
806
|
-
this._store.state.objectsOctree.insert(this.previousSelectionGroup);
|
|
807
|
-
this._store.state.selectionGroup = this.previousSelectionGroup;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
class MoveSelectionGroupCommand extends index$1.KritzelBaseCommand {
|
|
813
|
-
constructor(store, initiator, startX, startY, endX, endY, skipFirstExecution = false) {
|
|
814
|
-
super(store, initiator);
|
|
815
|
-
this.startX = startX;
|
|
816
|
-
this.startY = startY;
|
|
817
|
-
this.endX = endX;
|
|
818
|
-
this.endY = endY;
|
|
819
|
-
this.skipExecution = skipFirstExecution;
|
|
820
|
-
this.selectionGroup = this._store.state.selectionGroup;
|
|
821
|
-
}
|
|
822
|
-
execute() {
|
|
823
|
-
if (this.skipExecution) {
|
|
824
|
-
this.skipExecution = false;
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
this._store.state.selectionGroup = this.selectionGroup;
|
|
828
|
-
this._store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
|
|
829
|
-
}
|
|
830
|
-
undo() {
|
|
831
|
-
this._store.state.selectionGroup = this.selectionGroup;
|
|
832
|
-
this._store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
class KritzelBaseHandler {
|
|
837
|
-
constructor(store) {
|
|
838
|
-
this._store = store;
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
class KritzelMoveHandler extends KritzelBaseHandler {
|
|
843
|
-
constructor(store) {
|
|
844
|
-
super(store);
|
|
845
|
-
}
|
|
846
|
-
handlePointerDown(event) {
|
|
847
|
-
var _a, _b;
|
|
848
|
-
if (event.pointerType === 'mouse') {
|
|
849
|
-
if (index$1.KritzelEventHelper.isLeftClick(event)) {
|
|
850
|
-
if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
|
|
851
|
-
const clientX = event.clientX - this._store.offsetX;
|
|
852
|
-
const clientY = event.clientY - this._store.offsetY;
|
|
853
|
-
this._store.state.isDragging = true;
|
|
854
|
-
this.dragStartX = clientX;
|
|
855
|
-
this.dragStartY = clientY;
|
|
856
|
-
this.startX = this.dragStartX;
|
|
857
|
-
this.startY = this.dragStartY;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
if (event.pointerType === 'touch') {
|
|
862
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
863
|
-
if (this._store.state.pointers.size === 1) {
|
|
864
|
-
if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
|
|
865
|
-
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
866
|
-
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
867
|
-
this.dragStartX = x;
|
|
868
|
-
this.dragStartY = y;
|
|
869
|
-
this.startX = x;
|
|
870
|
-
this.startY = y;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
handlePointerMove(event) {
|
|
876
|
-
if (event.pointerType === 'mouse') {
|
|
877
|
-
if (this._store.state.isDragging && this._store.state.selectionGroup) {
|
|
878
|
-
const clientX = event.clientX - this._store.offsetX;
|
|
879
|
-
const clientY = event.clientY - this._store.offsetY;
|
|
880
|
-
this.endX = clientX;
|
|
881
|
-
this.endY = clientY;
|
|
882
|
-
this._store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
|
|
883
|
-
this.dragStartX = clientX;
|
|
884
|
-
this.dragStartY = clientY;
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
if (event.pointerType === 'touch') {
|
|
888
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
889
|
-
if (this._store.state.pointers.size === 1 && this._store.state.selectionGroup && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
|
|
890
|
-
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
891
|
-
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
892
|
-
this._store.state.isDragging = true;
|
|
893
|
-
this.endX = x;
|
|
894
|
-
this.endY = y;
|
|
895
|
-
const moveDeltaX = Math.abs(x - this.startX);
|
|
896
|
-
const moveDeltaY = Math.abs(y - this.startY);
|
|
897
|
-
const moveThreshold = 5;
|
|
898
|
-
if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
|
|
899
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
900
|
-
this._store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
|
|
901
|
-
this.dragStartX = x;
|
|
902
|
-
this.dragStartY = y;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
handlePointerUp(event) {
|
|
908
|
-
if (event.pointerType === 'mouse') {
|
|
909
|
-
if (this._store.state.isDragging) {
|
|
910
|
-
this._store.state.isDragging = false;
|
|
911
|
-
this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
if (event.pointerType === 'touch') {
|
|
915
|
-
if (this._store.state.isDragging) {
|
|
916
|
-
this._store.state.isDragging = false;
|
|
917
|
-
this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
var KritzelHandleType;
|
|
924
|
-
(function (KritzelHandleType) {
|
|
925
|
-
KritzelHandleType["TopLeft"] = "top-left";
|
|
926
|
-
KritzelHandleType["TopRight"] = "top-right";
|
|
927
|
-
KritzelHandleType["BottomLeft"] = "bottom-left";
|
|
928
|
-
KritzelHandleType["BottomRight"] = "bottom-right";
|
|
929
|
-
})(KritzelHandleType || (KritzelHandleType = {}));
|
|
930
|
-
|
|
931
|
-
class ResizeSelectionGroupCommand extends index$1.KritzelBaseCommand {
|
|
932
|
-
constructor(store, initiator, previousSize, newSize) {
|
|
933
|
-
super(store, initiator);
|
|
934
|
-
this.previousSize = previousSize;
|
|
935
|
-
this.newSize = newSize;
|
|
936
|
-
this.selectionGroup = this._store.state.selectionGroup;
|
|
937
|
-
}
|
|
938
|
-
execute() {
|
|
939
|
-
this._store.state.selectionGroup = this.selectionGroup;
|
|
940
|
-
this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
941
|
-
}
|
|
942
|
-
undo() {
|
|
943
|
-
this._store.state.selectionGroup = this.selectionGroup;
|
|
944
|
-
this._store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
class KritzelResizeHandler extends KritzelBaseHandler {
|
|
949
|
-
constructor(store) {
|
|
950
|
-
super(store);
|
|
951
|
-
this.initialMouseX = 0;
|
|
952
|
-
this.initialMouseY = 0;
|
|
953
|
-
this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
954
|
-
this.newSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
955
|
-
}
|
|
956
|
-
handlePointerDown(event) {
|
|
957
|
-
if (event.pointerType === 'mouse') {
|
|
958
|
-
if (index$1.KritzelEventHelper.isLeftClick(event)) {
|
|
959
|
-
if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
|
|
960
|
-
const clientX = event.clientX - this._store.offsetX;
|
|
961
|
-
const clientY = event.clientY - this._store.offsetY;
|
|
962
|
-
this._store.state.isResizing = true;
|
|
963
|
-
this.initialMouseX = clientX;
|
|
964
|
-
this.initialMouseY = clientY;
|
|
965
|
-
this.initialSize.width = this._store.state.selectionGroup.width;
|
|
966
|
-
this.initialSize.height = this._store.state.selectionGroup.height;
|
|
967
|
-
this.initialSize.x = this._store.state.selectionGroup.translateX;
|
|
968
|
-
this.initialSize.y = this._store.state.selectionGroup.translateY;
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
if (event.pointerType === 'touch') {
|
|
973
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
974
|
-
const firstTouch = activePointers[0];
|
|
975
|
-
if (!firstTouch) {
|
|
976
|
-
return;
|
|
977
|
-
}
|
|
978
|
-
if (activePointers.length === 1) {
|
|
979
|
-
if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
|
|
980
|
-
const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
|
|
981
|
-
const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
|
|
982
|
-
this._store.state.isResizing = true;
|
|
983
|
-
this.initialMouseX = clientX;
|
|
984
|
-
this.initialMouseY = clientY;
|
|
985
|
-
this.initialSize.width = this._store.state.selectionGroup.width;
|
|
986
|
-
this.initialSize.height = this._store.state.selectionGroup.height;
|
|
987
|
-
this.initialSize.x = this._store.state.selectionGroup.translateX;
|
|
988
|
-
this.initialSize.y = this._store.state.selectionGroup.translateY;
|
|
989
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
handlePointerMove(event) {
|
|
995
|
-
if (event.pointerType === 'mouse') {
|
|
996
|
-
if (this._store.state.isResizing && this._store.state.selectionGroup) {
|
|
997
|
-
const clientX = event.clientX - this._store.offsetX;
|
|
998
|
-
const clientY = event.clientY - this._store.offsetY;
|
|
999
|
-
const dx = clientX - this.initialMouseX;
|
|
1000
|
-
const dy = clientY - this.initialMouseY;
|
|
1001
|
-
switch (this._store.state.resizeHandleType) {
|
|
1002
|
-
case KritzelHandleType.TopLeft:
|
|
1003
|
-
this.newSize.width = this.initialSize.width - dx;
|
|
1004
|
-
this.newSize.height = this.initialSize.height - dy;
|
|
1005
|
-
this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
|
|
1006
|
-
this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
|
|
1007
|
-
break;
|
|
1008
|
-
case KritzelHandleType.TopRight:
|
|
1009
|
-
this.newSize.width = this.initialSize.width + dx;
|
|
1010
|
-
this.newSize.height = this.initialSize.height - dy;
|
|
1011
|
-
this.newSize.x = this.initialSize.x;
|
|
1012
|
-
this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
|
|
1013
|
-
break;
|
|
1014
|
-
case KritzelHandleType.BottomLeft:
|
|
1015
|
-
this.newSize.width = this.initialSize.width - dx;
|
|
1016
|
-
this.newSize.height = this.initialSize.height + dy;
|
|
1017
|
-
this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
|
|
1018
|
-
this.newSize.y = this.initialSize.y;
|
|
1019
|
-
break;
|
|
1020
|
-
case KritzelHandleType.BottomRight:
|
|
1021
|
-
this.newSize.width = this.initialSize.width + dx;
|
|
1022
|
-
this.newSize.height = this.initialSize.height + dy;
|
|
1023
|
-
this.newSize.x = this.initialSize.x;
|
|
1024
|
-
this.newSize.y = this.initialSize.y;
|
|
1025
|
-
break;
|
|
1026
|
-
}
|
|
1027
|
-
this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1028
|
-
this._store.rerender();
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
if (event.pointerType === 'touch') {
|
|
1032
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
1033
|
-
const oneFingerTouch = activePointers[0];
|
|
1034
|
-
if (!oneFingerTouch) {
|
|
1035
|
-
return;
|
|
1036
|
-
}
|
|
1037
|
-
if (this._store.state.isResizing && this._store.state.selectionGroup) {
|
|
1038
|
-
const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
|
|
1039
|
-
const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
|
|
1040
|
-
const dx = clientX - this.initialMouseX;
|
|
1041
|
-
const dy = clientY - this.initialMouseY;
|
|
1042
|
-
switch (this._store.state.resizeHandleType) {
|
|
1043
|
-
case KritzelHandleType.TopLeft:
|
|
1044
|
-
this.newSize.width = this.initialSize.width - dx;
|
|
1045
|
-
this.newSize.height = this.initialSize.height - dy;
|
|
1046
|
-
this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
|
|
1047
|
-
this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
|
|
1048
|
-
break;
|
|
1049
|
-
case KritzelHandleType.TopRight:
|
|
1050
|
-
this.newSize.width = this.initialSize.width + dx;
|
|
1051
|
-
this.newSize.height = this.initialSize.height - dy;
|
|
1052
|
-
this.newSize.x = this.initialSize.x;
|
|
1053
|
-
this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
|
|
1054
|
-
break;
|
|
1055
|
-
case KritzelHandleType.BottomLeft:
|
|
1056
|
-
this.newSize.width = this.initialSize.width - dx;
|
|
1057
|
-
this.newSize.height = this.initialSize.height + dy;
|
|
1058
|
-
this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
|
|
1059
|
-
this.newSize.y = this.initialSize.y;
|
|
1060
|
-
break;
|
|
1061
|
-
case KritzelHandleType.BottomRight:
|
|
1062
|
-
this.newSize.width = this.initialSize.width + dx;
|
|
1063
|
-
this.newSize.height = this.initialSize.height + dy;
|
|
1064
|
-
this.newSize.x = this.initialSize.x;
|
|
1065
|
-
this.newSize.y = this.initialSize.y;
|
|
1066
|
-
break;
|
|
1067
|
-
}
|
|
1068
|
-
this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1069
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
handlePointerUp(event) {
|
|
1074
|
-
if (event.pointerType === 'mouse') {
|
|
1075
|
-
if (this._store.state.isResizing) {
|
|
1076
|
-
const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
|
|
1077
|
-
this._store.history.executeCommand(resizeSelectionGroupCommand);
|
|
1078
|
-
this._store.state.isResizing = false;
|
|
1079
|
-
this._store.rerender();
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
if (event.pointerType === 'touch') {
|
|
1083
|
-
if (this._store.state.isResizing) {
|
|
1084
|
-
const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
|
|
1085
|
-
this._store.history.executeCommand(resizeSelectionGroupCommand);
|
|
1086
|
-
this._store.state.isResizing = false;
|
|
1087
|
-
this._store.rerender();
|
|
1088
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
class RotateSelectionGroupCommand extends index$1.KritzelBaseCommand {
|
|
1095
|
-
constructor(store, initiator, rotation) {
|
|
1096
|
-
super(store, initiator);
|
|
1097
|
-
this.rotation = rotation;
|
|
1098
|
-
this.initialRotation = this._store.state.selectionGroup.rotation;
|
|
1099
|
-
this.selectionGroup = this._store.state.selectionGroup;
|
|
1100
|
-
}
|
|
1101
|
-
execute() {
|
|
1102
|
-
this._store.state.selectionGroup = this.selectionGroup;
|
|
1103
|
-
this._store.state.selectionGroup.rotate(this.rotation);
|
|
1104
|
-
this._store.state.selectionGroup.objects.forEach(object => {
|
|
1105
|
-
this._store.state.objectsOctree.update(object);
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
undo() {
|
|
1109
|
-
this._store.state.selectionGroup = this.selectionGroup;
|
|
1110
|
-
this._store.state.selectionGroup.rotate(this.rotation - this.initialRotation);
|
|
1111
|
-
this._store.state.selectionGroup.objects.forEach(object => {
|
|
1112
|
-
this._store.state.objectsOctree.update(object);
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
class KritzelRotationHandler extends KritzelBaseHandler {
|
|
1118
|
-
constructor(store) {
|
|
1119
|
-
super(store);
|
|
1120
|
-
this.initialRotation = 0;
|
|
1121
|
-
this.rotation = 0;
|
|
1122
|
-
}
|
|
1123
|
-
handlePointerDown(event) {
|
|
1124
|
-
if (event.pointerType === 'mouse') {
|
|
1125
|
-
if (index$1.KritzelEventHelper.isLeftClick(event)) {
|
|
1126
|
-
if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
|
|
1127
|
-
const clientX = event.clientX - this._store.offsetX;
|
|
1128
|
-
const clientY = event.clientY - this._store.offsetY;
|
|
1129
|
-
this._store.state.isRotating = true;
|
|
1130
|
-
const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
|
|
1131
|
-
const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
|
|
1132
|
-
const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
1133
|
-
const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
1134
|
-
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
if (event.pointerType === 'touch') {
|
|
1139
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
1140
|
-
const firstTouch = activePointers[0];
|
|
1141
|
-
if (!firstTouch) {
|
|
1142
|
-
return;
|
|
1143
|
-
}
|
|
1144
|
-
if (activePointers.length === 1) {
|
|
1145
|
-
if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
|
|
1146
|
-
const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
|
|
1147
|
-
const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
|
|
1148
|
-
this._store.state.isRotating = true;
|
|
1149
|
-
const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
|
|
1150
|
-
const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
|
|
1151
|
-
const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
1152
|
-
const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
1153
|
-
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
|
|
1154
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
handlePointerMove(event) {
|
|
1160
|
-
if (event.pointerType === 'mouse') {
|
|
1161
|
-
if (this._store.state.isRotating && this._store.state.selectionGroup) {
|
|
1162
|
-
const clientX = event.clientX - this._store.offsetX;
|
|
1163
|
-
const clientY = event.clientY - this._store.offsetY;
|
|
1164
|
-
const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
|
|
1165
|
-
const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
|
|
1166
|
-
const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
1167
|
-
const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
1168
|
-
const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
|
|
1169
|
-
this.rotation = currentRotation - this.initialRotation;
|
|
1170
|
-
this._store.state.selectionGroup.rotate(this.rotation);
|
|
1171
|
-
this._store.rerender();
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
if (event.pointerType === 'touch') {
|
|
1175
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
1176
|
-
const firstTouch = activePointers[0];
|
|
1177
|
-
if (!firstTouch) {
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
if (this._store.state.isRotating && this._store.state.selectionGroup) {
|
|
1181
|
-
const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
|
|
1182
|
-
const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
|
|
1183
|
-
const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
|
|
1184
|
-
const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
|
|
1185
|
-
const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
1186
|
-
const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
1187
|
-
const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
|
|
1188
|
-
this.rotation = currentRotation - this.initialRotation;
|
|
1189
|
-
this._store.state.selectionGroup.rotate(this.rotation);
|
|
1190
|
-
this._store.rerender();
|
|
1191
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
handlePointerUp(event) {
|
|
1196
|
-
if (event.pointerType === 'mouse') {
|
|
1197
|
-
if (this._store.state.isRotating) {
|
|
1198
|
-
this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
|
|
1199
|
-
this._store.state.isRotating = false;
|
|
1200
|
-
this.initialRotation = 0;
|
|
1201
|
-
this.rotation = 0;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
if (event.pointerType === 'touch') {
|
|
1205
|
-
if (this._store.state.isRotating) {
|
|
1206
|
-
this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
|
|
1207
|
-
this._store.state.isRotating = false;
|
|
1208
|
-
this.initialRotation = 0;
|
|
1209
|
-
this.rotation = 0;
|
|
1210
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
class KritzelGeometryHelper {
|
|
1217
|
-
static doPolygonsIntersect(polygon1, polygon2) {
|
|
1218
|
-
// 1. Convert polygons to array of points for easier processing
|
|
1219
|
-
const points1 = [polygon1.bottomLeft, polygon1.bottomRight, polygon1.topRight, polygon1.topLeft];
|
|
1220
|
-
const points2 = [polygon2.bottomLeft, polygon2.bottomRight, polygon2.topRight, polygon2.topLeft];
|
|
1221
|
-
// 2. Check if any point of polygon1 is inside polygon2
|
|
1222
|
-
for (const point of points1) {
|
|
1223
|
-
if (this.isPointInPolygon(point, points2)) {
|
|
1224
|
-
return true;
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
// 3. Check if any point of polygon2 is inside polygon1
|
|
1228
|
-
for (const point of points2) {
|
|
1229
|
-
if (this.isPointInPolygon(point, points1)) {
|
|
1230
|
-
return true;
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
// 4. Check for edge intersections (more complex)
|
|
1234
|
-
for (let i = 0; i < points1.length; i++) {
|
|
1235
|
-
const p1a = points1[i];
|
|
1236
|
-
const p1b = points1[(i + 1) % points1.length]; // Wrap around to the first point
|
|
1237
|
-
for (let j = 0; j < points2.length; j++) {
|
|
1238
|
-
const p2a = points2[j];
|
|
1239
|
-
const p2b = points2[(j + 1) % points2.length];
|
|
1240
|
-
if (this.intersectLines(p1a, p1b, p2a, p2b)) {
|
|
1241
|
-
return true;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
return false; // No intersection found
|
|
1246
|
-
}
|
|
1247
|
-
static isPointInPolygon(point, polygon) {
|
|
1248
|
-
let inside = false;
|
|
1249
|
-
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
1250
|
-
const xi = polygon[i].x, yi = polygon[i].y;
|
|
1251
|
-
const xj = polygon[j].x, yj = polygon[j].y;
|
|
1252
|
-
const intersect = yi > point.y !== yj > point.y && point.x < ((xj - xi) * (point.y - yi)) / (yj - yi) + xi;
|
|
1253
|
-
if (intersect)
|
|
1254
|
-
inside = !inside;
|
|
1255
|
-
}
|
|
1256
|
-
return inside;
|
|
1257
|
-
}
|
|
1258
|
-
static intersectLines(p1a, p1b, p2a, p2b) {
|
|
1259
|
-
const det = (p1b.x - p1a.x) * (p2b.y - p2a.y) - (p1b.y - p1a.y) * (p2b.x - p2a.x);
|
|
1260
|
-
if (det === 0) {
|
|
1261
|
-
return false; // Lines are parallel
|
|
1262
|
-
}
|
|
1263
|
-
const t = ((p2a.x - p1a.x) * (p2b.y - p2a.y) - (p2a.y - p1a.y) * (p2b.x - p2a.x)) / det;
|
|
1264
|
-
const u = -((p1a.x - p2a.x) * (p1b.y - p1a.y) - (p1a.y - p2a.y) * (p1b.x - p1a.x)) / det;
|
|
1265
|
-
return t >= 0 && t <= 1 && u >= 0 && u <= 1;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
class KrtizelSelectionBox extends index$1.KritzelBaseObject {
|
|
1270
|
-
constructor() {
|
|
1271
|
-
super(...arguments);
|
|
1272
|
-
this.__class__ = 'KrtizelSelectionBox';
|
|
1273
|
-
this.objects = [];
|
|
1274
|
-
}
|
|
1275
|
-
static create(store) {
|
|
1276
|
-
const object = new KrtizelSelectionBox();
|
|
1277
|
-
object._store = store;
|
|
1278
|
-
object.id = object.generateId();
|
|
1279
|
-
object.scale = store.state.scale;
|
|
1280
|
-
object.zIndex = 99999;
|
|
1281
|
-
object.backgroundColor = 'var(--kritzel-selection-box-background-color, rgba(14, 17, 17, 0.2))';
|
|
1282
|
-
object.borderColor = 'var(--kritzel-selection-box-border-color, rgba(14, 17, 17, 0.5))';
|
|
1283
|
-
object.borderWidth = 2;
|
|
1284
|
-
object.height = 0;
|
|
1285
|
-
object.width = 0;
|
|
1286
|
-
return object;
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
class AddSelectionGroupCommand extends index$1.KritzelBaseCommand {
|
|
1291
|
-
constructor(store, initiator, selectionGroup) {
|
|
1292
|
-
super(store, initiator);
|
|
1293
|
-
this.selectionGroup = selectionGroup;
|
|
1294
|
-
}
|
|
1295
|
-
execute() {
|
|
1296
|
-
this._store.state.objectsOctree.remove(object => object instanceof KrtizelSelectionBox);
|
|
1297
|
-
this._store.state.objectsOctree.insert(this.selectionGroup);
|
|
1298
|
-
this._store.state.selectionGroup = this.selectionGroup;
|
|
1299
|
-
}
|
|
1300
|
-
undo() {
|
|
1301
|
-
this._store.state.objectsOctree.remove(object => object.id === this.selectionGroup.id);
|
|
1302
|
-
this._store.state.selectionGroup = null;
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
1307
|
-
get isSelectionClick() {
|
|
1308
|
-
return this._store.state.selectionBox && this._store.state.selectionBox.width === 0 && this._store.state.selectionBox.height === 0;
|
|
1309
|
-
}
|
|
1310
|
-
get isSelectionDrag() {
|
|
1311
|
-
return this._store.state.selectionBox && (this._store.state.selectionBox.width > 0 || this._store.state.selectionBox.height > 0);
|
|
1312
|
-
}
|
|
1313
|
-
constructor(store) {
|
|
1314
|
-
super(store);
|
|
1315
|
-
this.touchStartX = 0;
|
|
1316
|
-
this.touchStartY = 0;
|
|
1317
|
-
this.touchStartTimeout = null;
|
|
1318
|
-
}
|
|
1319
|
-
handlePointerDown(event) {
|
|
1320
|
-
if (event.pointerType === 'mouse') {
|
|
1321
|
-
if (index$1.KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
|
|
1322
|
-
this.startMouseSelection(event);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
if (event.pointerType === 'touch') {
|
|
1326
|
-
this.touchStartTimeout = setTimeout(() => {
|
|
1327
|
-
if (this._store.state.pointers.size === 1 && !this._store.state.isScaling && !this._store.state.selectionGroup) {
|
|
1328
|
-
this.startTouchSelection();
|
|
1329
|
-
this.updateTouchSelection();
|
|
1330
|
-
}
|
|
1331
|
-
}, 80);
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
handlePointerMove(event) {
|
|
1335
|
-
if (event.pointerType === 'mouse') {
|
|
1336
|
-
if (this._store.state.isSelecting) {
|
|
1337
|
-
this.updateMouseSelection(event);
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
if (event.pointerType === 'touch') {
|
|
1341
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
1342
|
-
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
1343
|
-
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
1344
|
-
const moveDeltaX = Math.abs(x - this.touchStartX);
|
|
1345
|
-
const moveDeltaY = Math.abs(y - this.touchStartY);
|
|
1346
|
-
const moveThreshold = 5;
|
|
1347
|
-
if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._store.state.isSelecting) {
|
|
1348
|
-
this.updateTouchSelection();
|
|
1349
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
handlePointerUp(event) {
|
|
1354
|
-
if (event.pointerType === 'mouse') {
|
|
1355
|
-
if (index$1.KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
|
|
1356
|
-
if (this.isSelectionClick) {
|
|
1357
|
-
this.updateMouseSelection(event);
|
|
1358
|
-
this.addSelectedObjectAtIndexToSelectionGroup(0);
|
|
1359
|
-
this.removeSelectionBox();
|
|
1360
|
-
}
|
|
1361
|
-
if (this.isSelectionDrag) {
|
|
1362
|
-
this.updateMouseSelection(event);
|
|
1363
|
-
this.addSelectedObjectsToSelectionGroup();
|
|
1364
|
-
this.removeSelectionBox();
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
if (event.pointerType === 'touch') {
|
|
1369
|
-
clearTimeout(this.touchStartTimeout);
|
|
1370
|
-
if (this._store.state.isSelecting) {
|
|
1371
|
-
if (this.isSelectionClick) {
|
|
1372
|
-
this.updateTouchSelection();
|
|
1373
|
-
this.addSelectedObjectAtIndexToSelectionGroup(0);
|
|
1374
|
-
this.removeSelectionBox();
|
|
1375
|
-
}
|
|
1376
|
-
if (this.isSelectionDrag) {
|
|
1377
|
-
this.updateTouchSelection();
|
|
1378
|
-
this.addSelectedObjectsToSelectionGroup();
|
|
1379
|
-
this.removeSelectionBox();
|
|
1380
|
-
}
|
|
1381
|
-
this._store.state.skipContextMenu = false;
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
removeSelectionBox() {
|
|
1386
|
-
this._store.state.selectionBox = null;
|
|
1387
|
-
this._store.state.isSelecting = false;
|
|
1388
|
-
this._store.state.objectsOctree.remove(o => o instanceof KrtizelSelectionBox);
|
|
1389
|
-
this._store.rerender();
|
|
1390
|
-
}
|
|
1391
|
-
startMouseSelection(event) {
|
|
1392
|
-
let clientX, clientY;
|
|
1393
|
-
clientX = event.clientX - this._store.offsetX;
|
|
1394
|
-
clientY = event.clientY - this._store.offsetY;
|
|
1395
|
-
const selectionBox = KrtizelSelectionBox.create(this._store);
|
|
1396
|
-
this.startX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
1397
|
-
this.startY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
1398
|
-
selectionBox.translateX = this.startX;
|
|
1399
|
-
selectionBox.translateY = this.startY;
|
|
1400
|
-
this._store.state.selectionGroup = null;
|
|
1401
|
-
this._store.state.selectionBox = selectionBox;
|
|
1402
|
-
this._store.state.isSelecting = true;
|
|
1403
|
-
this._store.state.objectsOctree.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
1404
|
-
this._store.state.objectsOctree.insert(selectionBox);
|
|
1405
|
-
}
|
|
1406
|
-
startTouchSelection() {
|
|
1407
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
1408
|
-
const firstTouch = activePointers[0];
|
|
1409
|
-
if (!firstTouch) {
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
let clientX, clientY;
|
|
1413
|
-
clientX = Math.round(firstTouch.clientX - this._store.offsetX);
|
|
1414
|
-
clientY = Math.round(firstTouch.clientY - this._store.offsetY);
|
|
1415
|
-
this.touchStartX = clientX;
|
|
1416
|
-
this.touchStartY = clientY;
|
|
1417
|
-
const selectionBox = KrtizelSelectionBox.create(this._store);
|
|
1418
|
-
this.startX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
1419
|
-
this.startY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
1420
|
-
selectionBox.translateX = this.startX;
|
|
1421
|
-
selectionBox.translateY = this.startY;
|
|
1422
|
-
this._store.state.selectionGroup = null;
|
|
1423
|
-
this._store.state.selectionBox = selectionBox;
|
|
1424
|
-
this._store.state.isSelecting = true;
|
|
1425
|
-
this._store.state.objectsOctree.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
1426
|
-
this._store.state.objectsOctree.insert(selectionBox);
|
|
1427
|
-
}
|
|
1428
|
-
updateMouseSelection(event) {
|
|
1429
|
-
let clientX, clientY;
|
|
1430
|
-
clientX = event.clientX - this._store.offsetX;
|
|
1431
|
-
clientY = event.clientY - this._store.offsetY;
|
|
1432
|
-
const selectionBox = this._store.state.selectionBox;
|
|
1433
|
-
if (selectionBox) {
|
|
1434
|
-
const currentX = (clientX - this._store.state.translateX) / selectionBox.scale;
|
|
1435
|
-
const currentY = (clientY - this._store.state.translateY) / selectionBox.scale;
|
|
1436
|
-
selectionBox.width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
1437
|
-
selectionBox.height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
1438
|
-
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
1439
|
-
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
1440
|
-
this.updateSelectedObjects();
|
|
1441
|
-
this._store.rerender();
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
updateTouchSelection() {
|
|
1445
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
1446
|
-
const firstTouch = activePointers[0];
|
|
1447
|
-
if (!firstTouch) {
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
let clientX, clientY;
|
|
1451
|
-
clientX = Math.round(firstTouch.clientX - this._store.offsetX);
|
|
1452
|
-
clientY = Math.round(firstTouch.clientY - this._store.offsetY);
|
|
1453
|
-
const selectionBox = this._store.state.selectionBox;
|
|
1454
|
-
if (selectionBox) {
|
|
1455
|
-
const currentX = (clientX - this._store.state.translateX) / selectionBox.scale;
|
|
1456
|
-
const currentY = (clientY - this._store.state.translateY) / selectionBox.scale;
|
|
1457
|
-
selectionBox.width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
1458
|
-
selectionBox.height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
1459
|
-
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
1460
|
-
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
1461
|
-
this.updateSelectedObjects();
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
updateSelectedObjects() {
|
|
1465
|
-
this._store.allObjects
|
|
1466
|
-
.filter(o => !(o instanceof KrtizelSelectionBox))
|
|
1467
|
-
.forEach(object => {
|
|
1468
|
-
const objectPolygon = object.rotatedPolygon;
|
|
1469
|
-
const selectionBoxPolygon = this._store.state.selectionBox.rotatedPolygon;
|
|
1470
|
-
object.selected = KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, selectionBoxPolygon);
|
|
1471
|
-
});
|
|
1472
|
-
}
|
|
1473
|
-
addSelectedObjectAtIndexToSelectionGroup(index) {
|
|
1474
|
-
const selectedObjects = this._store.selectedObjects.sort((a, b) => b.zIndex - a.zIndex);
|
|
1475
|
-
const selectedObject = selectedObjects[index];
|
|
1476
|
-
if (!selectedObject) {
|
|
1477
|
-
return;
|
|
1478
|
-
}
|
|
1479
|
-
selectedObjects.forEach(o => (o.selected = false));
|
|
1480
|
-
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
1481
|
-
this._store.state.selectionGroup.addOrRemove(selectedObject);
|
|
1482
|
-
this._store.state.selectionGroup.selected = true;
|
|
1483
|
-
this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
|
|
1484
|
-
this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
1485
|
-
}
|
|
1486
|
-
addSelectedObjectsToSelectionGroup() {
|
|
1487
|
-
const selectedObjects = this._store.selectedObjects;
|
|
1488
|
-
if (selectedObjects.length === 0) {
|
|
1489
|
-
return;
|
|
1490
|
-
}
|
|
1491
|
-
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
1492
|
-
selectedObjects.forEach(o => {
|
|
1493
|
-
o.selected = false;
|
|
1494
|
-
this._store.state.selectionGroup.addOrRemove(o);
|
|
1495
|
-
});
|
|
1496
|
-
this._store.state.selectionGroup.selected = true;
|
|
1497
|
-
if (this._store.state.selectionGroup.length === 1) {
|
|
1498
|
-
this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
|
|
1499
|
-
}
|
|
1500
|
-
this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
class KritzelSelectionTool extends index$1.KritzelBaseTool {
|
|
1505
|
-
constructor(store) {
|
|
1506
|
-
super(store);
|
|
1507
|
-
this.selectionHandler = new KritzelSelectionHandler(this._store);
|
|
1508
|
-
this.moveHandler = new KritzelMoveHandler(this._store);
|
|
1509
|
-
this.resizeHandler = new KritzelResizeHandler(this._store);
|
|
1510
|
-
this.rotationHandler = new KritzelRotationHandler(this._store);
|
|
1511
|
-
}
|
|
1512
|
-
handlePointerDown(event) {
|
|
1513
|
-
if (event.cancelable) {
|
|
1514
|
-
event.preventDefault();
|
|
1515
|
-
}
|
|
1516
|
-
if (event.pointerType === 'mouse') {
|
|
1517
|
-
if (index$1.KritzelEventHelper.isLeftClick(event)) {
|
|
1518
|
-
this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
1519
|
-
this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
1520
|
-
this._store.state.resizeHandleType = this.getHandleType(event);
|
|
1521
|
-
const selectedObject = this.getSelectedObject(event);
|
|
1522
|
-
const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
|
|
1523
|
-
if ((selectedObject === null || isDifferentObject) &&
|
|
1524
|
-
this._store.state.selectionGroup &&
|
|
1525
|
-
!this._store.state.isResizeHandleSelected &&
|
|
1526
|
-
!this._store.state.isRotationHandleSelected) {
|
|
1527
|
-
this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
|
|
1528
|
-
}
|
|
1529
|
-
if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
|
|
1530
|
-
setTimeout(() => {
|
|
1531
|
-
if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
|
|
1532
|
-
selectedObject.objects[0].onSelectedClick();
|
|
1533
|
-
}
|
|
1534
|
-
}, 100);
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
this.moveHandler.handlePointerDown(event);
|
|
1538
|
-
this.selectionHandler.handlePointerDown(event);
|
|
1539
|
-
this.resizeHandler.handlePointerDown(event);
|
|
1540
|
-
this.rotationHandler.handlePointerDown(event);
|
|
1541
|
-
this._store.rerender();
|
|
1542
|
-
}
|
|
1543
|
-
if (event.pointerType === 'touch') {
|
|
1544
|
-
if (this._store.state.isScaling === true) {
|
|
1545
|
-
return;
|
|
533
|
+
}
|
|
1546
534
|
}
|
|
1547
|
-
|
|
1548
|
-
this.
|
|
1549
|
-
|
|
1550
|
-
this._store.state.resizeHandleType = this.getHandleType(event);
|
|
1551
|
-
const selectedObject = this.getSelectedObject(event);
|
|
1552
|
-
const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
|
|
1553
|
-
if (!this._store.state.selectionGroup && selectedObject) {
|
|
1554
|
-
this._store.state.skipContextMenu = true;
|
|
535
|
+
else {
|
|
536
|
+
if (this.hasSuffixContent !== false) {
|
|
537
|
+
this.hasSuffixContent = false;
|
|
1555
538
|
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
this.evaluatePrefixContent = () => {
|
|
542
|
+
if (this.prefixSlotElement) {
|
|
543
|
+
const newHasContent = this.prefixSlotElement.assignedNodes({ flatten: true }).length > 0;
|
|
544
|
+
if (this.hasPrefixContent !== newHasContent) {
|
|
545
|
+
this.hasPrefixContent = newHasContent;
|
|
1561
546
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
}
|
|
1567
|
-
}, 100);
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
if (this.hasPrefixContent !== false) {
|
|
550
|
+
this.hasPrefixContent = false;
|
|
1568
551
|
}
|
|
1569
552
|
}
|
|
1570
|
-
|
|
1571
|
-
this.resizeHandler.handlePointerDown(event);
|
|
1572
|
-
this.moveHandler.handlePointerDown(event);
|
|
1573
|
-
this.selectionHandler.handlePointerDown(event);
|
|
1574
|
-
}
|
|
553
|
+
};
|
|
1575
554
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
if (event.pointerType === 'mouse') {
|
|
1581
|
-
this.moveHandler.handlePointerMove(event);
|
|
1582
|
-
this.selectionHandler.handlePointerMove(event);
|
|
1583
|
-
this.resizeHandler.handlePointerMove(event);
|
|
1584
|
-
this.rotationHandler.handlePointerMove(event);
|
|
1585
|
-
this._store.rerender();
|
|
1586
|
-
}
|
|
1587
|
-
if (event.pointerType === 'touch') {
|
|
1588
|
-
if (this._store.state.isScaling === true) {
|
|
1589
|
-
return;
|
|
1590
|
-
}
|
|
1591
|
-
this.rotationHandler.handlePointerMove(event);
|
|
1592
|
-
this.resizeHandler.handlePointerMove(event);
|
|
1593
|
-
this.moveHandler.handlePointerMove(event);
|
|
1594
|
-
this.selectionHandler.handlePointerMove(event);
|
|
1595
|
-
this._store.rerender();
|
|
1596
|
-
}
|
|
555
|
+
componentWillLoad() {
|
|
556
|
+
this.updateInternalValue(this.value, false);
|
|
557
|
+
this.evaluateSuffixContent();
|
|
558
|
+
this.evaluatePrefixContent();
|
|
1597
559
|
}
|
|
1598
|
-
|
|
1599
|
-
if (
|
|
1600
|
-
|
|
1601
|
-
}
|
|
1602
|
-
if (event.pointerType === 'mouse') {
|
|
1603
|
-
this.moveHandler.handlePointerUp(event);
|
|
1604
|
-
this.selectionHandler.handlePointerUp(event);
|
|
1605
|
-
this.resizeHandler.handlePointerUp(event);
|
|
1606
|
-
this.rotationHandler.handlePointerUp(event);
|
|
1607
|
-
this._store.rerender();
|
|
1608
|
-
}
|
|
1609
|
-
if (event.pointerType === 'touch') {
|
|
1610
|
-
if (this._store.state.isScaling === true) {
|
|
1611
|
-
return;
|
|
1612
|
-
}
|
|
1613
|
-
this.rotationHandler.handlePointerUp(event);
|
|
1614
|
-
this.resizeHandler.handlePointerUp(event);
|
|
1615
|
-
this.moveHandler.handlePointerUp(event);
|
|
1616
|
-
this.selectionHandler.handlePointerUp(event);
|
|
560
|
+
externalValueChanged(newValue) {
|
|
561
|
+
if (newValue !== this.internalValue) {
|
|
562
|
+
this.updateInternalValue(newValue, false);
|
|
1617
563
|
}
|
|
1618
564
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
565
|
+
optionsChanged() {
|
|
566
|
+
this.updateInternalValue(this.internalValue, true);
|
|
567
|
+
}
|
|
568
|
+
updateInternalValue(proposedValue, emitChange) {
|
|
569
|
+
let finalValue = proposedValue;
|
|
570
|
+
if (this.options && this.options.length > 0) {
|
|
571
|
+
const isValidValue = this.options.some(opt => opt.value === finalValue);
|
|
572
|
+
if (!finalValue || !isValidValue) {
|
|
573
|
+
finalValue = this.options[0].value;
|
|
574
|
+
}
|
|
1628
575
|
}
|
|
1629
576
|
else {
|
|
1630
|
-
|
|
1631
|
-
group.translateX = 0;
|
|
1632
|
-
group.translateY = 0;
|
|
1633
|
-
group.addOrRemove(object);
|
|
1634
|
-
return group;
|
|
577
|
+
finalValue = undefined;
|
|
1635
578
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
if (!shadowRoot)
|
|
1641
|
-
return;
|
|
1642
|
-
const point = event instanceof TouchEvent ? event.touches[0] : event;
|
|
1643
|
-
const elementAtPoint = shadowRoot.elementFromPoint(point.clientX, point.clientY);
|
|
1644
|
-
const handle = elementAtPoint.closest('.resize-handle-overlay');
|
|
1645
|
-
return handle === null || handle === void 0 ? void 0 : handle.classList[1];
|
|
1646
|
-
}
|
|
1647
|
-
isHandleSelected(event) {
|
|
1648
|
-
var _a;
|
|
1649
|
-
const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
|
|
1650
|
-
if (!shadowRoot)
|
|
1651
|
-
return false;
|
|
1652
|
-
const point = event instanceof TouchEvent ? event.touches[0] : event;
|
|
1653
|
-
const elementAtPoint = shadowRoot.elementFromPoint(point.clientX, point.clientY);
|
|
1654
|
-
return elementAtPoint === null || elementAtPoint === void 0 ? void 0 : elementAtPoint.classList.contains('resize-handle-overlay');
|
|
1655
|
-
}
|
|
1656
|
-
isRotationHandleSelected(event) {
|
|
1657
|
-
const path = event.composedPath();
|
|
1658
|
-
return !!path.find(element => element.classList && element.classList.contains('rotation-handle-overlay'));
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
class KritzelReviver {
|
|
1663
|
-
constructor(store) {
|
|
1664
|
-
this._store = store;
|
|
1665
|
-
}
|
|
1666
|
-
revive(obj) {
|
|
1667
|
-
if (obj && typeof obj === 'object') {
|
|
1668
|
-
if (obj.__class__) {
|
|
1669
|
-
let revivedObj;
|
|
1670
|
-
switch (obj.__class__) {
|
|
1671
|
-
case 'KritzelPath':
|
|
1672
|
-
revivedObj = index$1.KritzelPath.create(this._store).revive(obj);
|
|
1673
|
-
break;
|
|
1674
|
-
case 'KritzelText':
|
|
1675
|
-
revivedObj = index$1.KritzelText.create(this._store, obj.fontSize, obj.fontFamily).revive(obj);
|
|
1676
|
-
break;
|
|
1677
|
-
case 'KritzelImage':
|
|
1678
|
-
revivedObj = index$1.KritzelImage.create(this._store).revive(obj);
|
|
1679
|
-
break;
|
|
1680
|
-
case 'KritzelSelectionGroup':
|
|
1681
|
-
revivedObj = KritzelSelectionGroup.create(this._store).revive(obj);
|
|
1682
|
-
break;
|
|
1683
|
-
case 'KritzelBrushTool':
|
|
1684
|
-
revivedObj = new KritzelBrushTool(this._store);
|
|
1685
|
-
break;
|
|
1686
|
-
case 'KritzelEraserTool':
|
|
1687
|
-
revivedObj = new KritzelEraserTool(this._store);
|
|
1688
|
-
break;
|
|
1689
|
-
case 'KritzelImageTool':
|
|
1690
|
-
revivedObj = new KritzelImageTool(this._store);
|
|
1691
|
-
break;
|
|
1692
|
-
case 'KritzelSelectionTool':
|
|
1693
|
-
revivedObj = new KritzelSelectionTool(this._store);
|
|
1694
|
-
break;
|
|
1695
|
-
case 'KritzelTextTool':
|
|
1696
|
-
revivedObj = new index$1.KritzelTextTool(this._store);
|
|
1697
|
-
break;
|
|
1698
|
-
default:
|
|
1699
|
-
revivedObj = obj;
|
|
1700
|
-
}
|
|
1701
|
-
return revivedObj;
|
|
1702
|
-
}
|
|
1703
|
-
const newObj = Array.isArray(obj) ? [] : {};
|
|
1704
|
-
for (const key in obj) {
|
|
1705
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1706
|
-
newObj[key] = this.revive(obj[key]);
|
|
1707
|
-
}
|
|
579
|
+
if (this.internalValue !== finalValue) {
|
|
580
|
+
this.internalValue = finalValue;
|
|
581
|
+
if (emitChange || (proposedValue !== finalValue && proposedValue !== undefined)) {
|
|
582
|
+
this.valueChanged.emit(this.internalValue);
|
|
1708
583
|
}
|
|
1709
|
-
return newObj;
|
|
1710
584
|
}
|
|
1711
|
-
return obj;
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
class KritzelSelectionGroup extends index$1.KritzelBaseObject {
|
|
1716
|
-
constructor() {
|
|
1717
|
-
super(...arguments);
|
|
1718
|
-
this.__class__ = 'KritzelSelectionGroup';
|
|
1719
|
-
this.objects = [];
|
|
1720
|
-
this.unchangedObjects = [];
|
|
1721
585
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
object.scale = store.state.scale;
|
|
1730
|
-
object.zIndex = 99999;
|
|
1731
|
-
return object;
|
|
586
|
+
render() {
|
|
587
|
+
const selectClasses = {
|
|
588
|
+
'custom-select': true,
|
|
589
|
+
'has-suffix-border': this.hasSuffixContent,
|
|
590
|
+
'has-prefix-border': this.hasPrefixContent,
|
|
591
|
+
};
|
|
592
|
+
return (index.h(index.Host, { key: '32c5f5a4f807c1e316c91b795c005b8d30ce6189' }, index.h("div", { key: 'b1cbeff18e688da4a2f7472be290b9527a619f07', class: "dropdown-wrapper" }, index.h("slot", { key: 'b3bbb7e21c6f5620cab41aa4b1c7206b6c75fd86', name: "prefix", ref: el => this.prefixSlotElement = el, onSlotchange: this.evaluatePrefixContent }), index.h("select", { key: '8b2dcdc125bee59cf29fce7c980b755e78d5816e', class: selectClasses, style: Object.assign(Object.assign({}, this.selectStyles), { width: this.width }), onInput: this.handleSelectChange }, this.options.map(option => (index.h("option", { value: option.value, style: option.style, selected: option.value === this.internalValue }, option.label)))), index.h("slot", { key: '8d83f0dea41ac959bf2392948efef33bb70d0154', name: "suffix", ref: el => this.suffixSlotElement = el, onSlotchange: this.evaluateSuffixContent }))));
|
|
1732
593
|
}
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
594
|
+
static get watchers() { return {
|
|
595
|
+
"value": ["externalValueChanged"],
|
|
596
|
+
"options": ["optionsChanged"]
|
|
597
|
+
}; }
|
|
598
|
+
};
|
|
599
|
+
KritzelDropdown.style = kritzelDropdownCss;
|
|
600
|
+
|
|
601
|
+
class KritzelIconRegistry {
|
|
602
|
+
static register(name, svgContent) {
|
|
603
|
+
if (this.registry.has(name)) {
|
|
604
|
+
console.warn(`[IconRegistry] Icon "${name}" is already registered. It will be overwritten.`);
|
|
1740
605
|
}
|
|
1741
|
-
this.
|
|
1742
|
-
this.refreshObjectDimensions();
|
|
1743
|
-
}
|
|
1744
|
-
deselectAllChildren() {
|
|
1745
|
-
this.objects.forEach(obj => (obj.selected = false));
|
|
1746
|
-
}
|
|
1747
|
-
updatePosition(x, y) {
|
|
1748
|
-
this.objects.forEach(obj => {
|
|
1749
|
-
const deltaX = obj.translateX - this.translateX;
|
|
1750
|
-
const deltaY = obj.translateY - this.translateY;
|
|
1751
|
-
obj.translateX = x + deltaX;
|
|
1752
|
-
obj.translateY = y + deltaY;
|
|
1753
|
-
this._store.state.objectsOctree.update(obj);
|
|
1754
|
-
});
|
|
1755
|
-
this.unchangedObjects.forEach(obj => {
|
|
1756
|
-
const deltaX = obj.translateX - this.translateX;
|
|
1757
|
-
const deltaY = obj.translateY - this.translateY;
|
|
1758
|
-
obj.translateX = x + deltaX;
|
|
1759
|
-
obj.translateY = y + deltaY;
|
|
1760
|
-
});
|
|
1761
|
-
this.translateX = x;
|
|
1762
|
-
this.translateY = y;
|
|
1763
|
-
this._store.state.objectsOctree.update(this);
|
|
1764
|
-
}
|
|
1765
|
-
move(startX, startY, endX, endY) {
|
|
1766
|
-
const deltaX = (startX - endX) / this._store.state.scale;
|
|
1767
|
-
const deltaY = (startY - endY) / this._store.state.scale;
|
|
1768
|
-
this.translateX += deltaX;
|
|
1769
|
-
this.translateY += deltaY;
|
|
1770
|
-
this._store.state.objectsOctree.update(this);
|
|
1771
|
-
this.objects.forEach(obj => {
|
|
1772
|
-
obj.translateX += deltaX;
|
|
1773
|
-
obj.translateY += deltaY;
|
|
1774
|
-
this._store.state.objectsOctree.update(obj);
|
|
1775
|
-
});
|
|
1776
|
-
this.unchangedObjects.forEach(obj => {
|
|
1777
|
-
obj.translateX += deltaX;
|
|
1778
|
-
obj.translateY += deltaY;
|
|
1779
|
-
});
|
|
1780
|
-
}
|
|
1781
|
-
resize(x, y, width, height) {
|
|
1782
|
-
const widthScaleFactor = width / this.width;
|
|
1783
|
-
const heightScaleFactor = height / this.height;
|
|
1784
|
-
const deltaX = x - this.translateX;
|
|
1785
|
-
const deltaY = y - this.translateY;
|
|
1786
|
-
this.objects.forEach(child => {
|
|
1787
|
-
const updatedWidth = child.width * widthScaleFactor;
|
|
1788
|
-
const updatedHeight = child.height * heightScaleFactor;
|
|
1789
|
-
const updatedX = child.translateX + deltaX + (child.translateX - this.translateX) * (widthScaleFactor - 1);
|
|
1790
|
-
const updatedY = child.translateY + deltaY + (child.translateY - this.translateY) * (heightScaleFactor - 1);
|
|
1791
|
-
child.resize(updatedX, updatedY, updatedWidth, updatedHeight);
|
|
1792
|
-
this._store.state.objectsOctree.update(child);
|
|
1793
|
-
});
|
|
1794
|
-
this.refreshObjectDimensions();
|
|
1795
|
-
this.unchangedObjects = index$1.ObjectHelper.clone(this.objects);
|
|
1796
|
-
}
|
|
1797
|
-
rotate(value) {
|
|
1798
|
-
this.rotation = value;
|
|
1799
|
-
const centerX = this.translateX + this.totalWidth / 2 / this.scale;
|
|
1800
|
-
const centerY = this.translateY + this.totalHeight / 2 / this.scale;
|
|
1801
|
-
const angle = value;
|
|
1802
|
-
const cos = Math.cos(angle);
|
|
1803
|
-
const sin = Math.sin(angle);
|
|
1804
|
-
this.objects.forEach(child => {
|
|
1805
|
-
const unchangedChild = this.getUnchangedObject(child.id);
|
|
1806
|
-
const offsetX = this.getOffsetXToCenter(unchangedChild);
|
|
1807
|
-
const offsetY = this.getOffsetYToCenter(unchangedChild);
|
|
1808
|
-
const rotatedX = cos * offsetX - sin * offsetY;
|
|
1809
|
-
const rotatedY = sin * offsetX + cos * offsetY;
|
|
1810
|
-
child.translateX = centerX + rotatedX - child.totalWidth / 2 / child.scale;
|
|
1811
|
-
child.translateY = centerY + rotatedY - child.totalHeight / 2 / child.scale;
|
|
1812
|
-
child.rotation = this.objects.length === 1 ? value : value + unchangedChild.rotation;
|
|
1813
|
-
this._store.state.objectsOctree.update(child);
|
|
1814
|
-
});
|
|
606
|
+
this.registry.set(name, svgContent);
|
|
1815
607
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
let currentZIndex = this._store.currentZIndex;
|
|
1819
|
-
this.objects.forEach(obj => {
|
|
1820
|
-
const copiedObject = obj.copy();
|
|
1821
|
-
copiedObject.zIndex = currentZIndex;
|
|
1822
|
-
selectionGroup.addOrRemove(copiedObject);
|
|
1823
|
-
currentZIndex++;
|
|
1824
|
-
});
|
|
1825
|
-
selectionGroup.unchangedObjects = index$1.ObjectHelper.clone(selectionGroup.objects);
|
|
1826
|
-
if (this.objects.length === 1) {
|
|
1827
|
-
selectionGroup.rotation = this.objects[0].rotation;
|
|
1828
|
-
}
|
|
1829
|
-
return selectionGroup;
|
|
1830
|
-
}
|
|
1831
|
-
refreshObjectDimensions() {
|
|
1832
|
-
if (this.objects.length === 1) {
|
|
1833
|
-
const obj = this.objects[0];
|
|
1834
|
-
this.minX = obj.boundingBox.x / this.scale;
|
|
1835
|
-
this.maxX = obj.boundingBox.x / this.scale + obj.boundingBox.width;
|
|
1836
|
-
this.minY = obj.boundingBox.y / this.scale;
|
|
1837
|
-
this.maxY = obj.boundingBox.y / this.scale + obj.boundingBox.height;
|
|
1838
|
-
this.translateX = (this.minX - this.padding) * this.scale;
|
|
1839
|
-
this.translateY = (this.minY - this.padding) * this.scale;
|
|
1840
|
-
this.width = (this.maxX - this.minX - this.padding) * this.scale;
|
|
1841
|
-
this.height = (this.maxY - this.minY - this.padding) * this.scale;
|
|
1842
|
-
}
|
|
1843
|
-
else {
|
|
1844
|
-
this.minX = Math.min(...this.objects.map(obj => obj.minXRotated));
|
|
1845
|
-
this.maxX = Math.max(...this.objects.map(obj => obj.maxXRotated));
|
|
1846
|
-
this.minY = Math.min(...this.objects.map(obj => obj.minYRotated));
|
|
1847
|
-
this.maxY = Math.max(...this.objects.map(obj => obj.maxYRotated));
|
|
1848
|
-
this.translateX = this.minX - this.padding;
|
|
1849
|
-
this.translateY = this.minY - this.padding;
|
|
1850
|
-
this.width = (this.maxX - this.minX - this.padding) * this.scale;
|
|
1851
|
-
this.height = (this.maxY - this.minY - this.padding) * this.scale;
|
|
1852
|
-
}
|
|
1853
|
-
this._store.state.objectsOctree.update(this);
|
|
1854
|
-
}
|
|
1855
|
-
getOffsetXToCenter(obj) {
|
|
1856
|
-
const objCenterX = obj.translateX + obj.totalWidth / obj.scale / 2;
|
|
1857
|
-
const groupCenterX = this.translateX + this.totalWidth / this.scale / 2;
|
|
1858
|
-
return objCenterX - groupCenterX;
|
|
1859
|
-
}
|
|
1860
|
-
getOffsetYToCenter(obj) {
|
|
1861
|
-
const objCenterY = obj.translateY + obj.totalHeight / obj.scale / 2;
|
|
1862
|
-
const groupCenterY = this.translateY + this.totalHeight / this.scale / 2;
|
|
1863
|
-
return objCenterY - groupCenterY;
|
|
1864
|
-
}
|
|
1865
|
-
getUnchangedObject(objectId) {
|
|
1866
|
-
const obj = this.unchangedObjects.find(obj => obj.id === objectId);
|
|
1867
|
-
const reviver = new KritzelReviver(this._store);
|
|
1868
|
-
return reviver.revive(obj);
|
|
608
|
+
static get(name) {
|
|
609
|
+
return this.registry.get(name);
|
|
1869
610
|
}
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
* by Donald <donaldcwl@gmail.com>
|
|
1876
|
-
* https://github.com/Donaldcwl/browser-image-compression
|
|
1877
|
-
*/
|
|
1878
|
-
|
|
1879
|
-
function _mergeNamespaces$1(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:true,get:function(){return t[r]}});}}));})),Object.freeze(e)}function copyExifWithoutOrientation(e,t){return new Promise((function(r,i){let o;return getApp1Segment(e).then((function(e){try{return o=e,r(new Blob([t.slice(0,2),o,t.slice(2)],{type:"image/jpeg"}))}catch(e){return i(e)}}),i)}))}const getApp1Segment=e=>new Promise(((t,r)=>{const i=new FileReader;i.addEventListener("load",(({target:{result:e}})=>{const i=new DataView(e);let o=0;if(65496!==i.getUint16(o))return r("not a valid JPEG");for(o+=2;;){const a=i.getUint16(o);if(65498===a)break;const s=i.getUint16(o+2);if(65505===a&&1165519206===i.getUint32(o+4)){const a=o+10;let f;switch(i.getUint16(a)){case 18761:f=true;break;case 19789:f=false;break;default:return r("TIFF header contains invalid endian")}if(42!==i.getUint16(a+2,f))return r("TIFF header contains invalid version");const l=i.getUint32(a+4,f),c=a+l+2+12*i.getUint16(a+l,f);for(let e=a+l+2;e<c;e+=12){if(274==i.getUint16(e,f)){if(3!==i.getUint16(e+2,f))return r("Orientation data type is invalid");if(1!==i.getUint32(e+4,f))return r("Orientation data count is invalid");i.setUint16(e+8,1,f);break}}return t(e.slice(o,o+2+s))}o+=2+s;}return t(new Blob)})),i.readAsArrayBuffer(e);}));var e={},t={get exports(){return e},set exports(t){e=t;}};!function(e){var r,i,UZIP={};t.exports=UZIP,UZIP.parse=function(e,t){for(var r=UZIP.bin.readUshort,i=UZIP.bin.readUint,o=0,a={},s=new Uint8Array(e),f=s.length-4;101010256!=i(s,f);)f--;o=f;o+=4;var l=r(s,o+=4);r(s,o+=2);var c=i(s,o+=2),u=i(s,o+=4);o+=4,o=u;for(var h=0;h<l;h++){i(s,o),o+=4,o+=4,o+=4,i(s,o+=4);c=i(s,o+=4);var d=i(s,o+=4),A=r(s,o+=4),g=r(s,o+2),p=r(s,o+4);o+=6;var m=i(s,o+=8);o+=4,o+=A+g+p,UZIP._readLocal(s,m,a,c,d,t);}return a},UZIP._readLocal=function(e,t,r,i,o,a){var s=UZIP.bin.readUshort,f=UZIP.bin.readUint;f(e,t),s(e,t+=4),s(e,t+=2);var l=s(e,t+=2);f(e,t+=2),f(e,t+=4),t+=4;var c=s(e,t+=8),u=s(e,t+=2);t+=2;var h=UZIP.bin.readUTF8(e,t,c);if(t+=c,t+=u,a)r[h]={size:o,csize:i};else {var d=new Uint8Array(e.buffer,t);if(0==l)r[h]=new Uint8Array(d.buffer.slice(t,t+i));else {if(8!=l)throw "unknown compression method: "+l;var A=new Uint8Array(o);UZIP.inflateRaw(d,A),r[h]=A;}}},UZIP.inflateRaw=function(e,t){return UZIP.F.inflate(e,t)},UZIP.inflate=function(e,t){return UZIP.inflateRaw(new Uint8Array(e.buffer,e.byteOffset+2,e.length-6),t)},UZIP.deflate=function(e,t){null==t&&(t={level:6});var r=0,i=new Uint8Array(50+Math.floor(1.1*e.length));i[r]=120,i[r+1]=156,r+=2,r=UZIP.F.deflateRaw(e,i,r,t.level);var o=UZIP.adler(e,0,e.length);return i[r+0]=o>>>24&255,i[r+1]=o>>>16&255,i[r+2]=o>>>8&255,i[r+3]=o>>>0&255,new Uint8Array(i.buffer,0,r+4)},UZIP.deflateRaw=function(e,t){null==t&&(t={level:6});var r=new Uint8Array(50+Math.floor(1.1*e.length)),i=UZIP.F.deflateRaw(e,r,i,t.level);return new Uint8Array(r.buffer,0,i)},UZIP.encode=function(e,t){null==t&&(t=false);var r=0,i=UZIP.bin.writeUint,o=UZIP.bin.writeUshort,a={};for(var s in e){var f=!UZIP._noNeed(s)&&!t,l=e[s],c=UZIP.crc.crc(l,0,l.length);a[s]={cpr:f,usize:l.length,crc:c,file:f?UZIP.deflateRaw(l):l};}for(var s in a)r+=a[s].file.length+30+46+2*UZIP.bin.sizeUTF8(s);r+=22;var u=new Uint8Array(r),h=0,d=[];for(var s in a){var A=a[s];d.push(h),h=UZIP._writeHeader(u,h,s,A,0);}var g=0,p=h;for(var s in a){A=a[s];d.push(h),h=UZIP._writeHeader(u,h,s,A,1,d[g++]);}var m=h-p;return i(u,h,101010256),h+=4,o(u,h+=4,g),o(u,h+=2,g),i(u,h+=2,m),i(u,h+=4,p),h+=4,h+=2,u.buffer},UZIP._noNeed=function(e){var t=e.split(".").pop().toLowerCase();return -1!="png,jpg,jpeg,zip".indexOf(t)},UZIP._writeHeader=function(e,t,r,i,o,a){var s=UZIP.bin.writeUint,f=UZIP.bin.writeUshort,l=i.file;return s(e,t,0==o?67324752:33639248),t+=4,1==o&&(t+=2),f(e,t,20),f(e,t+=2,0),f(e,t+=2,i.cpr?8:0),s(e,t+=2,0),s(e,t+=4,i.crc),s(e,t+=4,l.length),s(e,t+=4,i.usize),f(e,t+=4,UZIP.bin.sizeUTF8(r)),f(e,t+=2,0),t+=2,1==o&&(t+=2,t+=2,s(e,t+=6,a),t+=4),t+=UZIP.bin.writeUTF8(e,t,r),0==o&&(e.set(l,t),t+=l.length),t},UZIP.crc={table:function(){for(var e=new Uint32Array(256),t=0;t<256;t++){for(var r=t,i=0;i<8;i++)1&r?r=3988292384^r>>>1:r>>>=1;e[t]=r;}return e}(),update:function(e,t,r,i){for(var o=0;o<i;o++)e=UZIP.crc.table[255&(e^t[r+o])]^e>>>8;return e},crc:function(e,t,r){return 4294967295^UZIP.crc.update(4294967295,e,t,r)}},UZIP.adler=function(e,t,r){for(var i=1,o=0,a=t,s=t+r;a<s;){for(var f=Math.min(a+5552,s);a<f;)o+=i+=e[a++];i%=65521,o%=65521;}return o<<16|i},UZIP.bin={readUshort:function(e,t){return e[t]|e[t+1]<<8},writeUshort:function(e,t,r){e[t]=255&r,e[t+1]=r>>8&255;},readUint:function(e,t){return 16777216*e[t+3]+(e[t+2]<<16|e[t+1]<<8|e[t])},writeUint:function(e,t,r){e[t]=255&r,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255;},readASCII:function(e,t,r){for(var i="",o=0;o<r;o++)i+=String.fromCharCode(e[t+o]);return i},writeASCII:function(e,t,r){for(var i=0;i<r.length;i++)e[t+i]=r.charCodeAt(i);},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(e,t,r){for(var i,o="",a=0;a<r;a++)o+="%"+UZIP.bin.pad(e[t+a].toString(16));try{i=decodeURIComponent(o);}catch(i){return UZIP.bin.readASCII(e,t,r)}return i},writeUTF8:function(e,t,r){for(var i=r.length,o=0,a=0;a<i;a++){var s=r.charCodeAt(a);if(0==(4294967168&s))e[t+o]=s,o++;else if(0==(4294965248&s))e[t+o]=192|s>>6,e[t+o+1]=128|s>>0&63,o+=2;else if(0==(4294901760&s))e[t+o]=224|s>>12,e[t+o+1]=128|s>>6&63,e[t+o+2]=128|s>>0&63,o+=3;else {if(0!=(4292870144&s))throw "e";e[t+o]=240|s>>18,e[t+o+1]=128|s>>12&63,e[t+o+2]=128|s>>6&63,e[t+o+3]=128|s>>0&63,o+=4;}}return o},sizeUTF8:function(e){for(var t=e.length,r=0,i=0;i<t;i++){var o=e.charCodeAt(i);if(0==(4294967168&o))r++;else if(0==(4294965248&o))r+=2;else if(0==(4294901760&o))r+=3;else {if(0!=(4292870144&o))throw "e";r+=4;}}return r}},UZIP.F={},UZIP.F.deflateRaw=function(e,t,r,i){var o=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][i],a=UZIP.F.U,s=UZIP.F._goodIndex;var f=UZIP.F._putsE,l=0,c=r<<3,u=0,h=e.length;if(0==i){for(;l<h;){f(t,c,l+(_=Math.min(65535,h-l))==h?1:0),c=UZIP.F._copyExact(e,l,_,t,c+8),l+=_;}return c>>>3}var d=a.lits,A=a.strt,g=a.prev,p=0,m=0,w=0,v=0,b=0,y=0;for(h>2&&(A[y=UZIP.F._hash(e,0)]=0),l=0;l<h;l++){if(b=y,l+1<h-2){y=UZIP.F._hash(e,l+1);var E=l+1&32767;g[E]=A[y],A[y]=E;}if(u<=l){(p>14e3||m>26697)&&h-l>100&&(u<l&&(d[p]=l-u,p+=2,u=l),c=UZIP.F._writeBlock(l==h-1||u==h?1:0,d,p,v,e,w,l-w,t,c),p=m=v=0,w=l);var F=0;l<h-2&&(F=UZIP.F._bestMatch(e,l,g,b,Math.min(o[2],h-l),o[3]));var _=F>>>16,B=65535&F;if(0!=F){B=65535&F;var U=s(_=F>>>16,a.of0);a.lhst[257+U]++;var C=s(B,a.df0);a.dhst[C]++,v+=a.exb[U]+a.dxb[C],d[p]=_<<23|l-u,d[p+1]=B<<16|U<<8|C,p+=2,u=l+_;}else a.lhst[e[l]]++;m++;}}for(w==l&&0!=e.length||(u<l&&(d[p]=l-u,p+=2,u=l),c=UZIP.F._writeBlock(1,d,p,v,e,w,l-w,t,c),p=0,m=0,p=m=v=0,w=l);0!=(7&c);)c++;return c>>>3},UZIP.F._bestMatch=function(e,t,r,i,o,a){var s=32767&t,f=r[s],l=s-f+32768&32767;if(f==s||i!=UZIP.F._hash(e,t-l))return 0;for(var c=0,u=0,h=Math.min(32767,t);l<=h&&0!=--a&&f!=s;){if(0==c||e[t+c]==e[t+c-l]){var d=UZIP.F._howLong(e,t,l);if(d>c){if(u=l,(c=d)>=o)break;l+2<d&&(d=l+2);for(var A=0,g=0;g<d-2;g++){var p=t-l+g+32768&32767,m=p-r[p]+32768&32767;m>A&&(A=m,f=p);}}}l+=(s=f)-(f=r[s])+32768&32767;}return c<<16|u},UZIP.F._howLong=function(e,t,r){if(e[t]!=e[t-r]||e[t+1]!=e[t+1-r]||e[t+2]!=e[t+2-r])return 0;var i=t,o=Math.min(e.length,t+258);for(t+=3;t<o&&e[t]==e[t-r];)t++;return t-i},UZIP.F._hash=function(e,t){return (e[t]<<8|e[t+1])+(e[t+2]<<4)&65535},UZIP.saved=0,UZIP.F._writeBlock=function(e,t,r,i,o,a,s,f,l){var c,u,h,d,A,g,p,m,w,v=UZIP.F.U,b=UZIP.F._putsF,y=UZIP.F._putsE;v.lhst[256]++,u=(c=UZIP.F.getTrees())[0],h=c[1],d=c[2],A=c[3],g=c[4],p=c[5],m=c[6],w=c[7];var E=32+(0==(l+3&7)?0:8-(l+3&7))+(s<<3),F=i+UZIP.F.contSize(v.fltree,v.lhst)+UZIP.F.contSize(v.fdtree,v.dhst),_=i+UZIP.F.contSize(v.ltree,v.lhst)+UZIP.F.contSize(v.dtree,v.dhst);_+=14+3*p+UZIP.F.contSize(v.itree,v.ihst)+(2*v.ihst[16]+3*v.ihst[17]+7*v.ihst[18]);for(var B=0;B<286;B++)v.lhst[B]=0;for(B=0;B<30;B++)v.dhst[B]=0;for(B=0;B<19;B++)v.ihst[B]=0;var U=E<F&&E<_?0:F<_?1:2;if(b(f,l,e),b(f,l+1,U),l+=3,0==U){for(;0!=(7&l);)l++;l=UZIP.F._copyExact(o,a,s,f,l);}else {var C,I;if(1==U&&(C=v.fltree,I=v.fdtree),2==U){UZIP.F.makeCodes(v.ltree,u),UZIP.F.revCodes(v.ltree,u),UZIP.F.makeCodes(v.dtree,h),UZIP.F.revCodes(v.dtree,h),UZIP.F.makeCodes(v.itree,d),UZIP.F.revCodes(v.itree,d),C=v.ltree,I=v.dtree,y(f,l,A-257),y(f,l+=5,g-1),y(f,l+=5,p-4),l+=4;for(var Q=0;Q<p;Q++)y(f,l+3*Q,v.itree[1+(v.ordr[Q]<<1)]);l+=3*p,l=UZIP.F._codeTiny(m,v.itree,f,l),l=UZIP.F._codeTiny(w,v.itree,f,l);}for(var M=a,x=0;x<r;x+=2){for(var S=t[x],R=S>>>23,T=M+(8388607&S);M<T;)l=UZIP.F._writeLit(o[M++],C,f,l);if(0!=R){var O=t[x+1],P=O>>16,H=O>>8&255,L=255&O;y(f,l=UZIP.F._writeLit(257+H,C,f,l),R-v.of0[H]),l+=v.exb[H],b(f,l=UZIP.F._writeLit(L,I,f,l),P-v.df0[L]),l+=v.dxb[L],M+=R;}}l=UZIP.F._writeLit(256,C,f,l);}return l},UZIP.F._copyExact=function(e,t,r,i,o){var a=o>>>3;return i[a]=r,i[a+1]=r>>>8,i[a+2]=255-i[a],i[a+3]=255-i[a+1],a+=4,i.set(new Uint8Array(e.buffer,t,r),a),o+(r+4<<3)},UZIP.F.getTrees=function(){for(var e=UZIP.F.U,t=UZIP.F._hufTree(e.lhst,e.ltree,15),r=UZIP.F._hufTree(e.dhst,e.dtree,15),i=[],o=UZIP.F._lenCodes(e.ltree,i),a=[],s=UZIP.F._lenCodes(e.dtree,a),f=0;f<i.length;f+=2)e.ihst[i[f]]++;for(f=0;f<a.length;f+=2)e.ihst[a[f]]++;for(var l=UZIP.F._hufTree(e.ihst,e.itree,7),c=19;c>4&&0==e.itree[1+(e.ordr[c-1]<<1)];)c--;return [t,r,l,o,s,c,i,a]},UZIP.F.getSecond=function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(e[r+1]);return t},UZIP.F.nonZero=function(e){for(var t="",r=0;r<e.length;r+=2)0!=e[r+1]&&(t+=(r>>1)+",");return t},UZIP.F.contSize=function(e,t){for(var r=0,i=0;i<t.length;i++)r+=t[i]*e[1+(i<<1)];return r},UZIP.F._codeTiny=function(e,t,r,i){for(var o=0;o<e.length;o+=2){var a=e[o],s=e[o+1];i=UZIP.F._writeLit(a,t,r,i);var f=16==a?2:17==a?3:7;a>15&&(UZIP.F._putsE(r,i,s,f),i+=f);}return i},UZIP.F._lenCodes=function(e,t){for(var r=e.length;2!=r&&0==e[r-1];)r-=2;for(var i=0;i<r;i+=2){var o=e[i+1],a=i+3<r?e[i+3]:-1,s=i+5<r?e[i+5]:-1,f=0==i?-1:e[i-1];if(0==o&&a==o&&s==o){for(var l=i+5;l+2<r&&e[l+2]==o;)l+=2;(c=Math.min(l+1-i>>>1,138))<11?t.push(17,c-3):t.push(18,c-11),i+=2*c-2;}else if(o==f&&a==o&&s==o){for(l=i+5;l+2<r&&e[l+2]==o;)l+=2;var c=Math.min(l+1-i>>>1,6);t.push(16,c-3),i+=2*c-2;}else t.push(o,0);}return r>>>1},UZIP.F._hufTree=function(e,t,r){var i=[],o=e.length,a=t.length,s=0;for(s=0;s<a;s+=2)t[s]=0,t[s+1]=0;for(s=0;s<o;s++)0!=e[s]&&i.push({lit:s,f:e[s]});var f=i.length,l=i.slice(0);if(0==f)return 0;if(1==f){var c=i[0].lit;l=0==c?1:0;return t[1+(c<<1)]=1,t[1+(l<<1)]=1,1}i.sort((function(e,t){return e.f-t.f}));var u=i[0],h=i[1],d=0,A=1,g=2;for(i[0]={lit:-1,f:u.f+h.f,l:u,r:h,d:0};A!=f-1;)u=d!=A&&(g==f||i[d].f<i[g].f)?i[d++]:i[g++],h=d!=A&&(g==f||i[d].f<i[g].f)?i[d++]:i[g++],i[A++]={lit:-1,f:u.f+h.f,l:u,r:h};var p=UZIP.F.setDepth(i[A-1],0);for(p>r&&(UZIP.F.restrictDepth(l,r,p),p=r),s=0;s<f;s++)t[1+(l[s].lit<<1)]=l[s].d;return p},UZIP.F.setDepth=function(e,t){return -1!=e.lit?(e.d=t,t):Math.max(UZIP.F.setDepth(e.l,t+1),UZIP.F.setDepth(e.r,t+1))},UZIP.F.restrictDepth=function(e,t,r){var i=0,o=1<<r-t,a=0;for(e.sort((function(e,t){return t.d==e.d?e.f-t.f:t.d-e.d})),i=0;i<e.length&&e[i].d>t;i++){var s=e[i].d;e[i].d=t,a+=o-(1<<r-s);}for(a>>>=r-t;a>0;){(s=e[i].d)<t?(e[i].d++,a-=1<<t-s-1):i++;}for(;i>=0;i--)e[i].d==t&&a<0&&(e[i].d--,a++);0!=a&&console.log("debt left");},UZIP.F._goodIndex=function(e,t){var r=0;return t[16|r]<=e&&(r|=16),t[8|r]<=e&&(r|=8),t[4|r]<=e&&(r|=4),t[2|r]<=e&&(r|=2),t[1|r]<=e&&(r|=1),r},UZIP.F._writeLit=function(e,t,r,i){return UZIP.F._putsF(r,i,t[e<<1]),i+t[1+(e<<1)]},UZIP.F.inflate=function(e,t){var r=Uint8Array;if(3==e[0]&&0==e[1])return t||new r(0);var i=UZIP.F,o=i._bitsF,a=i._bitsE,s=i._decodeTiny,f=i.makeCodes,l=i.codes2map,c=i._get17,u=i.U,h=null==t;h&&(t=new r(e.length>>>2<<3));for(var d,A,g=0,p=0,m=0,w=0,v=0,b=0,y=0,E=0,F=0;0==g;)if(g=o(e,F,1),p=o(e,F+1,2),F+=3,0!=p){if(h&&(t=UZIP.F._check(t,E+(1<<17))),1==p&&(d=u.flmap,A=u.fdmap,b=511,y=31),2==p){m=a(e,F,5)+257,w=a(e,F+5,5)+1,v=a(e,F+10,4)+4,F+=14;for(var _=0;_<38;_+=2)u.itree[_]=0,u.itree[_+1]=0;var B=1;for(_=0;_<v;_++){var U=a(e,F+3*_,3);u.itree[1+(u.ordr[_]<<1)]=U,U>B&&(B=U);}F+=3*v,f(u.itree,B),l(u.itree,B,u.imap),d=u.lmap,A=u.dmap,F=s(u.imap,(1<<B)-1,m+w,e,F,u.ttree);var C=i._copyOut(u.ttree,0,m,u.ltree);b=(1<<C)-1;var I=i._copyOut(u.ttree,m,w,u.dtree);y=(1<<I)-1,f(u.ltree,C),l(u.ltree,C,d),f(u.dtree,I),l(u.dtree,I,A);}for(;;){var Q=d[c(e,F)&b];F+=15&Q;var M=Q>>>4;if(M>>>8==0)t[E++]=M;else {if(256==M)break;var x=E+M-254;if(M>264){var S=u.ldef[M-257];x=E+(S>>>3)+a(e,F,7&S),F+=7&S;}var R=A[c(e,F)&y];F+=15&R;var T=R>>>4,O=u.ddef[T],P=(O>>>4)+o(e,F,15&O);for(F+=15&O,h&&(t=UZIP.F._check(t,E+(1<<17)));E<x;)t[E]=t[E++-P],t[E]=t[E++-P],t[E]=t[E++-P],t[E]=t[E++-P];E=x;}}}else {0!=(7&F)&&(F+=8-(7&F));var H=4+(F>>>3),L=e[H-4]|e[H-3]<<8;h&&(t=UZIP.F._check(t,E+L)),t.set(new r(e.buffer,e.byteOffset+H,L),E),F=H+L<<3,E+=L;}return t.length==E?t:t.slice(0,E)},UZIP.F._check=function(e,t){var r=e.length;if(t<=r)return e;var i=new Uint8Array(Math.max(r<<1,t));return i.set(e,0),i},UZIP.F._decodeTiny=function(e,t,r,i,o,a){for(var s=UZIP.F._bitsE,f=UZIP.F._get17,l=0;l<r;){var c=e[f(i,o)&t];o+=15&c;var u=c>>>4;if(u<=15)a[l]=u,l++;else {var h=0,d=0;16==u?(d=3+s(i,o,2),o+=2,h=a[l-1]):17==u?(d=3+s(i,o,3),o+=3):18==u&&(d=11+s(i,o,7),o+=7);for(var A=l+d;l<A;)a[l]=h,l++;}}return o},UZIP.F._copyOut=function(e,t,r,i){for(var o=0,a=0,s=i.length>>>1;a<r;){var f=e[a+t];i[a<<1]=0,i[1+(a<<1)]=f,f>o&&(o=f),a++;}for(;a<s;)i[a<<1]=0,i[1+(a<<1)]=0,a++;return o},UZIP.F.makeCodes=function(e,t){for(var r,i,o,a,s=UZIP.F.U,f=e.length,l=s.bl_count,c=0;c<=t;c++)l[c]=0;for(c=1;c<f;c+=2)l[e[c]]++;var u=s.next_code;for(r=0,l[0]=0,i=1;i<=t;i++)r=r+l[i-1]<<1,u[i]=r;for(o=0;o<f;o+=2)0!=(a=e[o+1])&&(e[o]=u[a],u[a]++);},UZIP.F.codes2map=function(e,t,r){for(var i=e.length,o=UZIP.F.U.rev15,a=0;a<i;a+=2)if(0!=e[a+1])for(var s=a>>1,f=e[a+1],l=s<<4|f,c=t-f,u=e[a]<<c,h=u+(1<<c);u!=h;){r[o[u]>>>15-t]=l,u++;}},UZIP.F.revCodes=function(e,t){for(var r=UZIP.F.U.rev15,i=15-t,o=0;o<e.length;o+=2){var a=e[o]<<t-e[o+1];e[o]=r[a]>>>i;}},UZIP.F._putsE=function(e,t,r){r<<=7&t;var i=t>>>3;e[i]|=r,e[i+1]|=r>>>8;},UZIP.F._putsF=function(e,t,r){r<<=7&t;var i=t>>>3;e[i]|=r,e[i+1]|=r>>>8,e[i+2]|=r>>>16;},UZIP.F._bitsE=function(e,t,r){return (e[t>>>3]|e[1+(t>>>3)]<<8)>>>(7&t)&(1<<r)-1},UZIP.F._bitsF=function(e,t,r){return (e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)&(1<<r)-1},UZIP.F._get17=function(e,t){return (e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)},UZIP.F._get25=function(e,t){return (e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16|e[3+(t>>>3)]<<24)>>>(7&t)},UZIP.F.U=(r=Uint16Array,i=Uint32Array,{next_code:new r(16),bl_count:new r(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new r(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new i(32),flmap:new r(512),fltree:[],fdmap:new r(32),fdtree:[],lmap:new r(32768),ltree:[],ttree:[],dmap:new r(32768),dtree:[],imap:new r(512),itree:[],rev15:new r(32768),lhst:new i(286),dhst:new i(30),ihst:new i(19),lits:new i(15e3),strt:new r(65536),prev:new r(32768)}),function(){for(var e=UZIP.F.U,t=0;t<32768;t++){var r=t;r=(4278255360&(r=(4042322160&(r=(3435973836&(r=(2863311530&r)>>>1|(1431655765&r)<<1))>>>2|(858993459&r)<<2))>>>4|(252645135&r)<<4))>>>8|(16711935&r)<<8,e.rev15[t]=(r>>>16|r<<16)>>>17;}function pushV(e,t,r){for(;0!=t--;)e.push(0,r);}for(t=0;t<32;t++)e.ldef[t]=e.of0[t]<<3|e.exb[t],e.ddef[t]=e.df0[t]<<4|e.dxb[t];pushV(e.fltree,144,8),pushV(e.fltree,112,9),pushV(e.fltree,24,7),pushV(e.fltree,8,8),UZIP.F.makeCodes(e.fltree,9),UZIP.F.codes2map(e.fltree,9,e.flmap),UZIP.F.revCodes(e.fltree,9),pushV(e.fdtree,32,5),UZIP.F.makeCodes(e.fdtree,5),UZIP.F.codes2map(e.fdtree,5,e.fdmap),UZIP.F.revCodes(e.fdtree,5),pushV(e.itree,19,0),pushV(e.ltree,286,0),pushV(e.dtree,30,0),pushV(e.ttree,320,0);}();}();var UZIP=_mergeNamespaces$1({__proto__:null,default:e},[e]);const UPNG=function(){var e={nextZero(e,t){for(;0!=e[t];)t++;return t},readUshort:(e,t)=>e[t]<<8|e[t+1],writeUshort(e,t,r){e[t]=r>>8&255,e[t+1]=255&r;},readUint:(e,t)=>16777216*e[t]+(e[t+1]<<16|e[t+2]<<8|e[t+3]),writeUint(e,t,r){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r;},readASCII(e,t,r){let i="";for(let o=0;o<r;o++)i+=String.fromCharCode(e[t+o]);return i},writeASCII(e,t,r){for(let i=0;i<r.length;i++)e[t+i]=r.charCodeAt(i);},readBytes(e,t,r){const i=[];for(let o=0;o<r;o++)i.push(e[t+o]);return i},pad:e=>e.length<2?`0${e}`:e,readUTF8(t,r,i){let o,a="";for(let o=0;o<i;o++)a+=`%${e.pad(t[r+o].toString(16))}`;try{o=decodeURIComponent(a);}catch(o){return e.readASCII(t,r,i)}return o}};function decodeImage(t,r,i,o){const a=r*i,s=_getBPP(o),f=Math.ceil(r*s/8),l=new Uint8Array(4*a),c=new Uint32Array(l.buffer),{ctype:u}=o,{depth:h}=o,d=e.readUshort;if(6==u){const e=a<<2;if(8==h)for(var A=0;A<e;A+=4)l[A]=t[A],l[A+1]=t[A+1],l[A+2]=t[A+2],l[A+3]=t[A+3];if(16==h)for(A=0;A<e;A++)l[A]=t[A<<1];}else if(2==u){const e=o.tabs.tRNS;if(null==e){if(8==h)for(A=0;A<a;A++){var g=3*A;c[A]=255<<24|t[g+2]<<16|t[g+1]<<8|t[g];}if(16==h)for(A=0;A<a;A++){g=6*A;c[A]=255<<24|t[g+4]<<16|t[g+2]<<8|t[g];}}else {var p=e[0];const r=e[1],i=e[2];if(8==h)for(A=0;A<a;A++){var m=A<<2;g=3*A;c[A]=255<<24|t[g+2]<<16|t[g+1]<<8|t[g],t[g]==p&&t[g+1]==r&&t[g+2]==i&&(l[m+3]=0);}if(16==h)for(A=0;A<a;A++){m=A<<2,g=6*A;c[A]=255<<24|t[g+4]<<16|t[g+2]<<8|t[g],d(t,g)==p&&d(t,g+2)==r&&d(t,g+4)==i&&(l[m+3]=0);}}}else if(3==u){const e=o.tabs.PLTE,s=o.tabs.tRNS,c=s?s.length:0;if(1==h)for(var w=0;w<i;w++){var v=w*f,b=w*r;for(A=0;A<r;A++){m=b+A<<2;var y=3*(E=t[v+(A>>3)]>>7-((7&A)<<0)&1);l[m]=e[y],l[m+1]=e[y+1],l[m+2]=e[y+2],l[m+3]=E<c?s[E]:255;}}if(2==h)for(w=0;w<i;w++)for(v=w*f,b=w*r,A=0;A<r;A++){m=b+A<<2,y=3*(E=t[v+(A>>2)]>>6-((3&A)<<1)&3);l[m]=e[y],l[m+1]=e[y+1],l[m+2]=e[y+2],l[m+3]=E<c?s[E]:255;}if(4==h)for(w=0;w<i;w++)for(v=w*f,b=w*r,A=0;A<r;A++){m=b+A<<2,y=3*(E=t[v+(A>>1)]>>4-((1&A)<<2)&15);l[m]=e[y],l[m+1]=e[y+1],l[m+2]=e[y+2],l[m+3]=E<c?s[E]:255;}if(8==h)for(A=0;A<a;A++){var E;m=A<<2,y=3*(E=t[A]);l[m]=e[y],l[m+1]=e[y+1],l[m+2]=e[y+2],l[m+3]=E<c?s[E]:255;}}else if(4==u){if(8==h)for(A=0;A<a;A++){m=A<<2;var F=t[_=A<<1];l[m]=F,l[m+1]=F,l[m+2]=F,l[m+3]=t[_+1];}if(16==h)for(A=0;A<a;A++){var _;m=A<<2,F=t[_=A<<2];l[m]=F,l[m+1]=F,l[m+2]=F,l[m+3]=t[_+2];}}else if(0==u)for(p=o.tabs.tRNS?o.tabs.tRNS:-1,w=0;w<i;w++){const e=w*f,i=w*r;if(1==h)for(var B=0;B<r;B++){var U=(F=255*(t[e+(B>>>3)]>>>7-(7&B)&1))==255*p?0:255;c[i+B]=U<<24|F<<16|F<<8|F;}else if(2==h)for(B=0;B<r;B++){U=(F=85*(t[e+(B>>>2)]>>>6-((3&B)<<1)&3))==85*p?0:255;c[i+B]=U<<24|F<<16|F<<8|F;}else if(4==h)for(B=0;B<r;B++){U=(F=17*(t[e+(B>>>1)]>>>4-((1&B)<<2)&15))==17*p?0:255;c[i+B]=U<<24|F<<16|F<<8|F;}else if(8==h)for(B=0;B<r;B++){U=(F=t[e+B])==p?0:255;c[i+B]=U<<24|F<<16|F<<8|F;}else if(16==h)for(B=0;B<r;B++){F=t[e+(B<<1)],U=d(t,e+(B<<1))==p?0:255;c[i+B]=U<<24|F<<16|F<<8|F;}}return l}function _decompress(e,r,i,o){const a=_getBPP(e),s=Math.ceil(i*a/8),f=new Uint8Array((s+1+e.interlace)*o);return r=e.tabs.CgBI?t(r,f):_inflate(r,f),0==e.interlace?r=_filterZero(r,e,0,i,o):1==e.interlace&&(r=function _readInterlace(e,t){const r=t.width,i=t.height,o=_getBPP(t),a=o>>3,s=Math.ceil(r*o/8),f=new Uint8Array(i*s);let l=0;const c=[0,0,4,0,2,0,1],u=[0,4,0,2,0,1,0],h=[8,8,8,4,4,2,2],d=[8,8,4,4,2,2,1];let A=0;for(;A<7;){const p=h[A],m=d[A];let w=0,v=0,b=c[A];for(;b<i;)b+=p,v++;let y=u[A];for(;y<r;)y+=m,w++;const E=Math.ceil(w*o/8);_filterZero(e,t,l,w,v);let F=0,_=c[A];for(;_<i;){let t=u[A],i=l+F*E<<3;for(;t<r;){var g;if(1==o)g=(g=e[i>>3])>>7-(7&i)&1,f[_*s+(t>>3)]|=g<<7-((7&t)<<0);if(2==o)g=(g=e[i>>3])>>6-(7&i)&3,f[_*s+(t>>2)]|=g<<6-((3&t)<<1);if(4==o)g=(g=e[i>>3])>>4-(7&i)&15,f[_*s+(t>>1)]|=g<<4-((1&t)<<2);if(o>=8){const r=_*s+t*a;for(let t=0;t<a;t++)f[r+t]=e[(i>>3)+t];}i+=o,t+=m;}F++,_+=p;}w*v!=0&&(l+=v*(1+E)),A+=1;}return f}(r,e)),r}function _inflate(e,r){return t(new Uint8Array(e.buffer,2,e.length-6),r)}var t=function(){const e={H:{}};return e.H.N=function(t,r){const i=Uint8Array;let o,a,s=0,f=0,l=0,c=0,u=0,h=0,d=0,A=0,g=0;if(3==t[0]&&0==t[1])return r||new i(0);const p=e.H,m=p.b,w=p.e,v=p.R,b=p.n,y=p.A,E=p.Z,F=p.m,_=null==r;for(_&&(r=new i(t.length>>>2<<5));0==s;)if(s=m(t,g,1),f=m(t,g+1,2),g+=3,0!=f){if(_&&(r=e.H.W(r,A+(1<<17))),1==f&&(o=F.J,a=F.h,h=511,d=31),2==f){l=w(t,g,5)+257,c=w(t,g+5,5)+1,u=w(t,g+10,4)+4,g+=14;let e=1;for(var B=0;B<38;B+=2)F.Q[B]=0,F.Q[B+1]=0;for(B=0;B<u;B++){const r=w(t,g+3*B,3);F.Q[1+(F.X[B]<<1)]=r,r>e&&(e=r);}g+=3*u,b(F.Q,e),y(F.Q,e,F.u),o=F.w,a=F.d,g=v(F.u,(1<<e)-1,l+c,t,g,F.v);const r=p.V(F.v,0,l,F.C);h=(1<<r)-1;const i=p.V(F.v,l,c,F.D);d=(1<<i)-1,b(F.C,r),y(F.C,r,o),b(F.D,i),y(F.D,i,a);}for(;;){const e=o[E(t,g)&h];g+=15&e;const i=e>>>4;if(i>>>8==0)r[A++]=i;else {if(256==i)break;{let e=A+i-254;if(i>264){const r=F.q[i-257];e=A+(r>>>3)+w(t,g,7&r),g+=7&r;}const o=a[E(t,g)&d];g+=15&o;const s=o>>>4,f=F.c[s],l=(f>>>4)+m(t,g,15&f);for(g+=15&f;A<e;)r[A]=r[A++-l],r[A]=r[A++-l],r[A]=r[A++-l],r[A]=r[A++-l];A=e;}}}}else {0!=(7&g)&&(g+=8-(7&g));const o=4+(g>>>3),a=t[o-4]|t[o-3]<<8;_&&(r=e.H.W(r,A+a)),r.set(new i(t.buffer,t.byteOffset+o,a),A),g=o+a<<3,A+=a;}return r.length==A?r:r.slice(0,A)},e.H.W=function(e,t){const r=e.length;if(t<=r)return e;const i=new Uint8Array(r<<1);return i.set(e,0),i},e.H.R=function(t,r,i,o,a,s){const f=e.H.e,l=e.H.Z;let c=0;for(;c<i;){const e=t[l(o,a)&r];a+=15&e;const i=e>>>4;if(i<=15)s[c]=i,c++;else {let e=0,t=0;16==i?(t=3+f(o,a,2),a+=2,e=s[c-1]):17==i?(t=3+f(o,a,3),a+=3):18==i&&(t=11+f(o,a,7),a+=7);const r=c+t;for(;c<r;)s[c]=e,c++;}}return a},e.H.V=function(e,t,r,i){let o=0,a=0;const s=i.length>>>1;for(;a<r;){const r=e[a+t];i[a<<1]=0,i[1+(a<<1)]=r,r>o&&(o=r),a++;}for(;a<s;)i[a<<1]=0,i[1+(a<<1)]=0,a++;return o},e.H.n=function(t,r){const i=e.H.m,o=t.length;let a,s,f;let l;const c=i.j;for(var u=0;u<=r;u++)c[u]=0;for(u=1;u<o;u+=2)c[t[u]]++;const h=i.K;for(a=0,c[0]=0,s=1;s<=r;s++)a=a+c[s-1]<<1,h[s]=a;for(f=0;f<o;f+=2)l=t[f+1],0!=l&&(t[f]=h[l],h[l]++);},e.H.A=function(t,r,i){const o=t.length,a=e.H.m.r;for(let e=0;e<o;e+=2)if(0!=t[e+1]){const o=e>>1,s=t[e+1],f=o<<4|s,l=r-s;let c=t[e]<<l;const u=c+(1<<l);for(;c!=u;){i[a[c]>>>15-r]=f,c++;}}},e.H.l=function(t,r){const i=e.H.m.r,o=15-r;for(let e=0;e<t.length;e+=2){const a=t[e]<<r-t[e+1];t[e]=i[a]>>>o;}},e.H.M=function(e,t,r){r<<=7&t;const i=t>>>3;e[i]|=r,e[i+1]|=r>>>8;},e.H.I=function(e,t,r){r<<=7&t;const i=t>>>3;e[i]|=r,e[i+1]|=r>>>8,e[i+2]|=r>>>16;},e.H.e=function(e,t,r){return (e[t>>>3]|e[1+(t>>>3)]<<8)>>>(7&t)&(1<<r)-1},e.H.b=function(e,t,r){return (e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)&(1<<r)-1},e.H.Z=function(e,t){return (e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)},e.H.i=function(e,t){return (e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16|e[3+(t>>>3)]<<24)>>>(7&t)},e.H.m=function(){const e=Uint16Array,t=Uint32Array;return {K:new e(16),j:new e(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new e(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new t(32),J:new e(512),_:[],h:new e(32),$:[],w:new e(32768),C:[],v:[],d:new e(32768),D:[],u:new e(512),Q:[],r:new e(32768),s:new t(286),Y:new t(30),a:new t(19),t:new t(15e3),k:new e(65536),g:new e(32768)}}(),function(){const t=e.H.m;for(var r=0;r<32768;r++){let e=r;e=(2863311530&e)>>>1|(1431655765&e)<<1,e=(3435973836&e)>>>2|(858993459&e)<<2,e=(4042322160&e)>>>4|(252645135&e)<<4,e=(4278255360&e)>>>8|(16711935&e)<<8,t.r[r]=(e>>>16|e<<16)>>>17;}function n(e,t,r){for(;0!=t--;)e.push(0,r);}for(r=0;r<32;r++)t.q[r]=t.S[r]<<3|t.T[r],t.c[r]=t.p[r]<<4|t.z[r];n(t._,144,8),n(t._,112,9),n(t._,24,7),n(t._,8,8),e.H.n(t._,9),e.H.A(t._,9,t.J),e.H.l(t._,9),n(t.$,32,5),e.H.n(t.$,5),e.H.A(t.$,5,t.h),e.H.l(t.$,5),n(t.Q,19,0),n(t.C,286,0),n(t.D,30,0),n(t.v,320,0);}(),e.H.N}();function _getBPP(e){return [1,null,3,1,2,null,4][e.ctype]*e.depth}function _filterZero(e,t,r,i,o){let a=_getBPP(t);const s=Math.ceil(i*a/8);let f,l;a=Math.ceil(a/8);let c=e[r],u=0;if(c>1&&(e[r]=[0,0,1][c-2]),3==c)for(u=a;u<s;u++)e[u+1]=e[u+1]+(e[u+1-a]>>>1)&255;for(let t=0;t<o;t++)if(f=r+t*s,l=f+t+1,c=e[l-1],u=0,0==c)for(;u<s;u++)e[f+u]=e[l+u];else if(1==c){for(;u<a;u++)e[f+u]=e[l+u];for(;u<s;u++)e[f+u]=e[l+u]+e[f+u-a];}else if(2==c)for(;u<s;u++)e[f+u]=e[l+u]+e[f+u-s];else if(3==c){for(;u<a;u++)e[f+u]=e[l+u]+(e[f+u-s]>>>1);for(;u<s;u++)e[f+u]=e[l+u]+(e[f+u-s]+e[f+u-a]>>>1);}else {for(;u<a;u++)e[f+u]=e[l+u]+_paeth(0,e[f+u-s],0);for(;u<s;u++)e[f+u]=e[l+u]+_paeth(e[f+u-a],e[f+u-s],e[f+u-a-s]);}return e}function _paeth(e,t,r){const i=e+t-r,o=i-e,a=i-t,s=i-r;return o*o<=a*a&&o*o<=s*s?e:a*a<=s*s?t:r}function _IHDR(t,r,i){i.width=e.readUint(t,r),r+=4,i.height=e.readUint(t,r),r+=4,i.depth=t[r],r++,i.ctype=t[r],r++,i.compress=t[r],r++,i.filter=t[r],r++,i.interlace=t[r],r++;}function _copyTile(e,t,r,i,o,a,s,f,l){const c=Math.min(t,o),u=Math.min(r,a);let h=0,d=0;for(let r=0;r<u;r++)for(let a=0;a<c;a++)if(s>=0&&f>=0?(h=r*t+a<<2,d=(f+r)*o+s+a<<2):(h=(-f+r)*t-s+a<<2,d=r*o+a<<2),0==l)i[d]=e[h],i[d+1]=e[h+1],i[d+2]=e[h+2],i[d+3]=e[h+3];else if(1==l){var A=e[h+3]*(1/255),g=e[h]*A,p=e[h+1]*A,m=e[h+2]*A,w=i[d+3]*(1/255),v=i[d]*w,b=i[d+1]*w,y=i[d+2]*w;const t=1-A,r=A+w*t,o=0==r?0:1/r;i[d+3]=255*r,i[d+0]=(g+v*t)*o,i[d+1]=(p+b*t)*o,i[d+2]=(m+y*t)*o;}else if(2==l){A=e[h+3],g=e[h],p=e[h+1],m=e[h+2],w=i[d+3],v=i[d],b=i[d+1],y=i[d+2];A==w&&g==v&&p==b&&m==y?(i[d]=0,i[d+1]=0,i[d+2]=0,i[d+3]=0):(i[d]=g,i[d+1]=p,i[d+2]=m,i[d+3]=A);}else if(3==l){A=e[h+3],g=e[h],p=e[h+1],m=e[h+2],w=i[d+3],v=i[d],b=i[d+1],y=i[d+2];if(A==w&&g==v&&p==b&&m==y)continue;if(A<220&&w>20)return false}return true}return {decode:function decode(r){const i=new Uint8Array(r);let o=8;const a=e,s=a.readUshort,f=a.readUint,l={tabs:{},frames:[]},c=new Uint8Array(i.length);let u,h=0,d=0;const A=[137,80,78,71,13,10,26,10];for(var g=0;g<8;g++)if(i[g]!=A[g])throw "The input is not a PNG file!";for(;o<i.length;){const e=a.readUint(i,o);o+=4;const r=a.readASCII(i,o,4);if(o+=4,"IHDR"==r)_IHDR(i,o,l);else if("iCCP"==r){for(var p=o;0!=i[p];)p++;a.readASCII(i,o,p-o);const s=i.slice(p+2,o+e);let f=null;try{f=_inflate(s);}catch(e){f=t(s);}l.tabs[r]=f;}else if("CgBI"==r)l.tabs[r]=i.slice(o,o+4);else if("IDAT"==r){for(g=0;g<e;g++)c[h+g]=i[o+g];h+=e;}else if("acTL"==r)l.tabs[r]={num_frames:f(i,o),num_plays:f(i,o+4)},u=new Uint8Array(i.length);else if("fcTL"==r){if(0!=d)(E=l.frames[l.frames.length-1]).data=_decompress(l,u.slice(0,d),E.rect.width,E.rect.height),d=0;const e={x:f(i,o+12),y:f(i,o+16),width:f(i,o+4),height:f(i,o+8)};let t=s(i,o+22);t=s(i,o+20)/(0==t?100:t);const r={rect:e,delay:Math.round(1e3*t),dispose:i[o+24],blend:i[o+25]};l.frames.push(r);}else if("fdAT"==r){for(g=0;g<e-4;g++)u[d+g]=i[o+g+4];d+=e-4;}else if("pHYs"==r)l.tabs[r]=[a.readUint(i,o),a.readUint(i,o+4),i[o+8]];else if("cHRM"==r){l.tabs[r]=[];for(g=0;g<8;g++)l.tabs[r].push(a.readUint(i,o+4*g));}else if("tEXt"==r||"zTXt"==r){null==l.tabs[r]&&(l.tabs[r]={});var m=a.nextZero(i,o),w=a.readASCII(i,o,m-o),v=o+e-m-1;if("tEXt"==r)y=a.readASCII(i,m+1,v);else {var b=_inflate(i.slice(m+2,m+2+v));y=a.readUTF8(b,0,b.length);}l.tabs[r][w]=y;}else if("iTXt"==r){null==l.tabs[r]&&(l.tabs[r]={});m=0,p=o;m=a.nextZero(i,p);w=a.readASCII(i,p,m-p);const t=i[p=m+1];var y;p+=2,m=a.nextZero(i,p),a.readASCII(i,p,m-p),p=m+1,m=a.nextZero(i,p),a.readUTF8(i,p,m-p);v=e-((p=m+1)-o);if(0==t)y=a.readUTF8(i,p,v);else {b=_inflate(i.slice(p,p+v));y=a.readUTF8(b,0,b.length);}l.tabs[r][w]=y;}else if("PLTE"==r)l.tabs[r]=a.readBytes(i,o,e);else if("hIST"==r){const e=l.tabs.PLTE.length/3;l.tabs[r]=[];for(g=0;g<e;g++)l.tabs[r].push(s(i,o+2*g));}else if("tRNS"==r)3==l.ctype?l.tabs[r]=a.readBytes(i,o,e):0==l.ctype?l.tabs[r]=s(i,o):2==l.ctype&&(l.tabs[r]=[s(i,o),s(i,o+2),s(i,o+4)]);else if("gAMA"==r)l.tabs[r]=a.readUint(i,o)/1e5;else if("sRGB"==r)l.tabs[r]=i[o];else if("bKGD"==r)0==l.ctype||4==l.ctype?l.tabs[r]=[s(i,o)]:2==l.ctype||6==l.ctype?l.tabs[r]=[s(i,o),s(i,o+2),s(i,o+4)]:3==l.ctype&&(l.tabs[r]=i[o]);else if("IEND"==r)break;o+=e,a.readUint(i,o),o+=4;}var E;return 0!=d&&((E=l.frames[l.frames.length-1]).data=_decompress(l,u.slice(0,d),E.rect.width,E.rect.height)),l.data=_decompress(l,c,l.width,l.height),delete l.compress,delete l.interlace,delete l.filter,l},toRGBA8:function toRGBA8(e){const t=e.width,r=e.height;if(null==e.tabs.acTL)return [decodeImage(e.data,t,r,e).buffer];const i=[];null==e.frames[0].data&&(e.frames[0].data=e.data);const o=t*r*4,a=new Uint8Array(o),s=new Uint8Array(o),f=new Uint8Array(o);for(let c=0;c<e.frames.length;c++){const u=e.frames[c],h=u.rect.x,d=u.rect.y,A=u.rect.width,g=u.rect.height,p=decodeImage(u.data,A,g,e);if(0!=c)for(var l=0;l<o;l++)f[l]=a[l];if(0==u.blend?_copyTile(p,A,g,a,t,r,h,d,0):1==u.blend&&_copyTile(p,A,g,a,t,r,h,d,1),i.push(a.buffer.slice(0)),0==u.dispose);else if(1==u.dispose)_copyTile(s,A,g,a,t,r,h,d,0);else if(2==u.dispose)for(l=0;l<o;l++)a[l]=f[l];}return i},_paeth:_paeth,_copyTile:_copyTile,_bin:e}}();!function(){const{_copyTile:e}=UPNG,{_bin:t}=UPNG,r=UPNG._paeth;var i={table:function(){const e=new Uint32Array(256);for(let t=0;t<256;t++){let r=t;for(let e=0;e<8;e++)1&r?r=3988292384^r>>>1:r>>>=1;e[t]=r;}return e}(),update(e,t,r,o){for(let a=0;a<o;a++)e=i.table[255&(e^t[r+a])]^e>>>8;return e},crc:(e,t,r)=>4294967295^i.update(4294967295,e,t,r)};function addErr(e,t,r,i){t[r]+=e[0]*i>>4,t[r+1]+=e[1]*i>>4,t[r+2]+=e[2]*i>>4,t[r+3]+=e[3]*i>>4;}function N(e){return Math.max(0,Math.min(255,e))}function D(e,t){const r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2],a=e[3]-t[3];return r*r+i*i+o*o+a*a}function dither(e,t,r,i,o,a,s){null==s&&(s=1);const f=i.length,l=[];for(var c=0;c<f;c++){const e=i[c];l.push([e>>>0&255,e>>>8&255,e>>>16&255,e>>>24&255]);}for(c=0;c<f;c++){let e=4294967295;for(var u=0,h=0;h<f;h++){var d=D(l[c],l[h]);h!=c&&d<e&&(e=d,u=h);}}const A=new Uint32Array(o.buffer),g=new Int16Array(t*r*4),p=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(c=0;c<p.length;c++)p[c]=255*((p[c]+.5)/16-.5);for(let o=0;o<r;o++)for(let w=0;w<t;w++){var m;c=4*(o*t+w);if(2!=s)m=[N(e[c]+g[c]),N(e[c+1]+g[c+1]),N(e[c+2]+g[c+2]),N(e[c+3]+g[c+3])];else {d=p[4*(3&o)+(3&w)];m=[N(e[c]+d),N(e[c+1]+d),N(e[c+2]+d),N(e[c+3]+d)];}u=0;let v=16777215;for(h=0;h<f;h++){const e=D(m,l[h]);e<v&&(v=e,u=h);}const b=l[u],y=[m[0]-b[0],m[1]-b[1],m[2]-b[2],m[3]-b[3]];1==s&&(w!=t-1&&addErr(y,g,c+4,7),o!=r-1&&(0!=w&&addErr(y,g,c+4*t-4,3),addErr(y,g,c+4*t,5),w!=t-1&&addErr(y,g,c+4*t+4,1))),a[c>>2]=u,A[c>>2]=i[u];}}function _main(e,r,o,a,s){null==s&&(s={});const{crc:f}=i,l=t.writeUint,c=t.writeUshort,u=t.writeASCII;let h=8;const d=e.frames.length>1;let A,g=false,p=33+(d?20:0);if(null!=s.sRGB&&(p+=13),null!=s.pHYs&&(p+=21),null!=s.iCCP&&(A=pako.deflate(s.iCCP),p+=21+A.length+4),3==e.ctype){for(var m=e.plte.length,w=0;w<m;w++)e.plte[w]>>>24!=255&&(g=true);p+=8+3*m+4+(g?8+1*m+4:0);}for(var v=0;v<e.frames.length;v++){d&&(p+=38),p+=(F=e.frames[v]).cimg.length+12,0!=v&&(p+=4);}p+=12;const b=new Uint8Array(p),y=[137,80,78,71,13,10,26,10];for(w=0;w<8;w++)b[w]=y[w];if(l(b,h,13),h+=4,u(b,h,"IHDR"),h+=4,l(b,h,r),h+=4,l(b,h,o),h+=4,b[h]=e.depth,h++,b[h]=e.ctype,h++,b[h]=0,h++,b[h]=0,h++,b[h]=0,h++,l(b,h,f(b,h-17,17)),h+=4,null!=s.sRGB&&(l(b,h,1),h+=4,u(b,h,"sRGB"),h+=4,b[h]=s.sRGB,h++,l(b,h,f(b,h-5,5)),h+=4),null!=s.iCCP){const e=13+A.length;l(b,h,e),h+=4,u(b,h,"iCCP"),h+=4,u(b,h,"ICC profile"),h+=11,h+=2,b.set(A,h),h+=A.length,l(b,h,f(b,h-(e+4),e+4)),h+=4;}if(null!=s.pHYs&&(l(b,h,9),h+=4,u(b,h,"pHYs"),h+=4,l(b,h,s.pHYs[0]),h+=4,l(b,h,s.pHYs[1]),h+=4,b[h]=s.pHYs[2],h++,l(b,h,f(b,h-13,13)),h+=4),d&&(l(b,h,8),h+=4,u(b,h,"acTL"),h+=4,l(b,h,e.frames.length),h+=4,l(b,h,null!=s.loop?s.loop:0),h+=4,l(b,h,f(b,h-12,12)),h+=4),3==e.ctype){l(b,h,3*(m=e.plte.length)),h+=4,u(b,h,"PLTE"),h+=4;for(w=0;w<m;w++){const t=3*w,r=e.plte[w],i=255&r,o=r>>>8&255,a=r>>>16&255;b[h+t+0]=i,b[h+t+1]=o,b[h+t+2]=a;}if(h+=3*m,l(b,h,f(b,h-3*m-4,3*m+4)),h+=4,g){l(b,h,m),h+=4,u(b,h,"tRNS"),h+=4;for(w=0;w<m;w++)b[h+w]=e.plte[w]>>>24&255;h+=m,l(b,h,f(b,h-m-4,m+4)),h+=4;}}let E=0;for(v=0;v<e.frames.length;v++){var F=e.frames[v];d&&(l(b,h,26),h+=4,u(b,h,"fcTL"),h+=4,l(b,h,E++),h+=4,l(b,h,F.rect.width),h+=4,l(b,h,F.rect.height),h+=4,l(b,h,F.rect.x),h+=4,l(b,h,F.rect.y),h+=4,c(b,h,a[v]),h+=2,c(b,h,1e3),h+=2,b[h]=F.dispose,h++,b[h]=F.blend,h++,l(b,h,f(b,h-30,30)),h+=4);const t=F.cimg;l(b,h,(m=t.length)+(0==v?0:4)),h+=4;const r=h;u(b,h,0==v?"IDAT":"fdAT"),h+=4,0!=v&&(l(b,h,E++),h+=4),b.set(t,h),h+=m,l(b,h,f(b,r,h-r)),h+=4;}return l(b,h,0),h+=4,u(b,h,"IEND"),h+=4,l(b,h,f(b,h-4,4)),h+=4,b.buffer}function compressPNG(e,t,r){for(let i=0;i<e.frames.length;i++){const o=e.frames[i];const a=o.rect.height,s=new Uint8Array(a*o.bpl+a);o.cimg=_filterZero(o.img,a,o.bpp,o.bpl,s,t,r);}}function compress(t,r,i,o,a){const s=a[0],f=a[1],l=a[2],c=a[3],u=a[4],h=a[5];let d=6,A=8,g=255;for(var p=0;p<t.length;p++){const e=new Uint8Array(t[p]);for(var m=e.length,w=0;w<m;w+=4)g&=e[w+3];}const v=255!=g,b=function framize(t,r,i,o,a,s){const f=[];for(var l=0;l<t.length;l++){const h=new Uint8Array(t[l]),A=new Uint32Array(h.buffer);var c;let g=0,p=0,m=r,w=i,v=o?1:0;if(0!=l){const b=s||o||1==l||0!=f[l-2].dispose?1:2;let y=0,E=1e9;for(let e=0;e<b;e++){var u=new Uint8Array(t[l-1-e]);const o=new Uint32Array(t[l-1-e]);let s=r,f=i,c=-1,h=-1;for(let e=0;e<i;e++)for(let t=0;t<r;t++){A[d=e*r+t]!=o[d]&&(t<s&&(s=t),t>c&&(c=t),e<f&&(f=e),e>h&&(h=e));} -1==c&&(s=f=c=h=0),a&&(1==(1&s)&&s--,1==(1&f)&&f--);const v=(c-s+1)*(h-f+1);v<E&&(E=v,y=e,g=s,p=f,m=c-s+1,w=h-f+1);}u=new Uint8Array(t[l-1-y]);1==y&&(f[l-1].dispose=2),c=new Uint8Array(m*w*4),e(u,r,i,c,m,w,-g,-p,0),v=e(h,r,i,c,m,w,-g,-p,3)?1:0,1==v?_prepareDiff(h,r,i,c,{x:g,y:p,width:m,height:w}):e(h,r,i,c,m,w,-g,-p,0);}else c=h.slice(0);f.push({rect:{x:g,y:p,width:m,height:w},img:c,blend:v,dispose:0});}if(o)for(l=0;l<f.length;l++){if(1==(A=f[l]).blend)continue;const e=A.rect,o=f[l-1].rect,s=Math.min(e.x,o.x),c=Math.min(e.y,o.y),u={x:s,y:c,width:Math.max(e.x+e.width,o.x+o.width)-s,height:Math.max(e.y+e.height,o.y+o.height)-c};f[l-1].dispose=1,l-1!=0&&_updateFrame(t,r,i,f,l-1,u,a),_updateFrame(t,r,i,f,l,u,a);}let h=0;if(1!=t.length)for(var d=0;d<f.length;d++){var A;h+=(A=f[d]).rect.width*A.rect.height;}return f}(t,r,i,s,f,l),y={},E=[],F=[];if(0!=o){const e=[];for(w=0;w<b.length;w++)e.push(b[w].img.buffer);const t=function concatRGBA(e){let t=0;for(var r=0;r<e.length;r++)t+=e[r].byteLength;const i=new Uint8Array(t);let o=0;for(r=0;r<e.length;r++){const t=new Uint8Array(e[r]),a=t.length;for(let e=0;e<a;e+=4){let r=t[e],a=t[e+1],s=t[e+2];const f=t[e+3];0==f&&(r=a=s=0),i[o+e]=r,i[o+e+1]=a,i[o+e+2]=s,i[o+e+3]=f;}o+=a;}return i.buffer}(e),r=quantize(t,o);for(w=0;w<r.plte.length;w++)E.push(r.plte[w].est.rgba);let i=0;for(w=0;w<b.length;w++){const e=(B=b[w]).img.length;var _=new Uint8Array(r.inds.buffer,i>>2,e>>2);F.push(_);const t=new Uint8Array(r.abuf,i,e);h&&dither(B.img,B.rect.width,B.rect.height,E,t,_),B.img.set(t),i+=e;}}else for(p=0;p<b.length;p++){var B=b[p];const e=new Uint32Array(B.img.buffer);var U=B.rect.width;m=e.length,_=new Uint8Array(m);F.push(_);for(w=0;w<m;w++){const t=e[w];if(0!=w&&t==e[w-1])_[w]=_[w-1];else if(w>U&&t==e[w-U])_[w]=_[w-U];else {let e=y[t];if(null==e&&(y[t]=e=E.length,E.push(t),E.length>=300))break;_[w]=e;}}}const C=E.length;C<=256&&0==u&&(A=C<=2?1:C<=4?2:C<=16?4:8,A=Math.max(A,c));for(p=0;p<b.length;p++){(B=b[p]).rect.x;U=B.rect.width;const e=B.rect.height;let t=B.img;let r=4*U,i=4;if(C<=256&&0==u){r=Math.ceil(A*U/8);var I=new Uint8Array(r*e);const o=F[p];for(let t=0;t<e;t++){w=t*r;const e=t*U;if(8==A)for(var Q=0;Q<U;Q++)I[w+Q]=o[e+Q];else if(4==A)for(Q=0;Q<U;Q++)I[w+(Q>>1)]|=o[e+Q]<<4-4*(1&Q);else if(2==A)for(Q=0;Q<U;Q++)I[w+(Q>>2)]|=o[e+Q]<<6-2*(3&Q);else if(1==A)for(Q=0;Q<U;Q++)I[w+(Q>>3)]|=o[e+Q]<<7-1*(7&Q);}t=I,d=3,i=1;}else if(0==v&&1==b.length){I=new Uint8Array(U*e*3);const o=U*e;for(w=0;w<o;w++){const e=3*w,r=4*w;I[e]=t[r],I[e+1]=t[r+1],I[e+2]=t[r+2];}t=I,d=2,i=3,r=3*U;}B.img=t,B.bpl=r,B.bpp=i;}return {ctype:d,depth:A,plte:E,frames:b}}function _updateFrame(t,r,i,o,a,s,f){const l=Uint8Array,c=Uint32Array,u=new l(t[a-1]),h=new c(t[a-1]),d=a+1<t.length?new l(t[a+1]):null,A=new l(t[a]),g=new c(A.buffer);let p=r,m=i,w=-1,v=-1;for(let e=0;e<s.height;e++)for(let t=0;t<s.width;t++){const i=s.x+t,f=s.y+e,l=f*r+i,c=g[l];0==c||0==o[a-1].dispose&&h[l]==c&&(null==d||0!=d[4*l+3])||(i<p&&(p=i),i>w&&(w=i),f<m&&(m=f),f>v&&(v=f));} -1==w&&(p=m=w=v=0),f&&(1==(1&p)&&p--,1==(1&m)&&m--),s={x:p,y:m,width:w-p+1,height:v-m+1};const b=o[a];b.rect=s,b.blend=1,b.img=new Uint8Array(s.width*s.height*4),0==o[a-1].dispose?(e(u,r,i,b.img,s.width,s.height,-s.x,-s.y,0),_prepareDiff(A,r,i,b.img,s)):e(A,r,i,b.img,s.width,s.height,-s.x,-s.y,0);}function _prepareDiff(t,r,i,o,a){e(t,r,i,o,a.width,a.height,-a.x,-a.y,2);}function _filterZero(e,t,r,i,o,a,s){const f=[];let l,c=[0,1,2,3,4];-1!=a?c=[a]:(t*i>5e5||1==r)&&(c=[0]),s&&(l={level:0});const u=UZIP;for(var h=0;h<c.length;h++){for(let a=0;a<t;a++)_filterLine(o,e,a,i,r,c[h]);f.push(u.deflate(o,l));}let d,A=1e9;for(h=0;h<f.length;h++)f[h].length<A&&(d=h,A=f[h].length);return f[d]}function _filterLine(e,t,i,o,a,s){const f=i*o;let l=f+i;if(e[l]=s,l++,0==s)if(o<500)for(var c=0;c<o;c++)e[l+c]=t[f+c];else e.set(new Uint8Array(t.buffer,f,o),l);else if(1==s){for(c=0;c<a;c++)e[l+c]=t[f+c];for(c=a;c<o;c++)e[l+c]=t[f+c]-t[f+c-a]+256&255;}else if(0==i){for(c=0;c<a;c++)e[l+c]=t[f+c];if(2==s)for(c=a;c<o;c++)e[l+c]=t[f+c];if(3==s)for(c=a;c<o;c++)e[l+c]=t[f+c]-(t[f+c-a]>>1)+256&255;if(4==s)for(c=a;c<o;c++)e[l+c]=t[f+c]-r(t[f+c-a],0,0)+256&255;}else {if(2==s)for(c=0;c<o;c++)e[l+c]=t[f+c]+256-t[f+c-o]&255;if(3==s){for(c=0;c<a;c++)e[l+c]=t[f+c]+256-(t[f+c-o]>>1)&255;for(c=a;c<o;c++)e[l+c]=t[f+c]+256-(t[f+c-o]+t[f+c-a]>>1)&255;}if(4==s){for(c=0;c<a;c++)e[l+c]=t[f+c]+256-r(0,t[f+c-o],0)&255;for(c=a;c<o;c++)e[l+c]=t[f+c]+256-r(t[f+c-a],t[f+c-o],t[f+c-a-o])&255;}}}function quantize(e,t){const r=new Uint8Array(e),i=r.slice(0),o=new Uint32Array(i.buffer),a=getKDtree(i,t),s=a[0],f=a[1],l=r.length,c=new Uint8Array(l>>2);let u;if(r.length<2e7)for(var h=0;h<l;h+=4){u=getNearest(s,d=r[h]*(1/255),A=r[h+1]*(1/255),g=r[h+2]*(1/255),p=r[h+3]*(1/255)),c[h>>2]=u.ind,o[h>>2]=u.est.rgba;}else for(h=0;h<l;h+=4){var d=r[h]*(1/255),A=r[h+1]*(1/255),g=r[h+2]*(1/255),p=r[h+3]*(1/255);for(u=s;u.left;)u=planeDst(u.est,d,A,g,p)<=0?u.left:u.right;c[h>>2]=u.ind,o[h>>2]=u.est.rgba;}return {abuf:i.buffer,inds:c,plte:f}}function getKDtree(e,t,r){null==r&&(r=1e-4);const i=new Uint32Array(e.buffer),o={i0:0,i1:e.length,bst:null,est:null,tdst:0,left:null,right:null};o.bst=stats(e,o.i0,o.i1),o.est=estats(o.bst);const a=[o];for(;a.length<t;){let t=0,o=0;for(var s=0;s<a.length;s++)a[s].est.L>t&&(t=a[s].est.L,o=s);if(t<r)break;const f=a[o],l=splitPixels(e,i,f.i0,f.i1,f.est.e,f.est.eMq255);if(f.i0>=l||f.i1<=l){f.est.L=0;continue}const c={i0:f.i0,i1:l,bst:null,est:null,tdst:0,left:null,right:null};c.bst=stats(e,c.i0,c.i1),c.est=estats(c.bst);const u={i0:l,i1:f.i1,bst:null,est:null,tdst:0,left:null,right:null};u.bst={R:[],m:[],N:f.bst.N-c.bst.N};for(s=0;s<16;s++)u.bst.R[s]=f.bst.R[s]-c.bst.R[s];for(s=0;s<4;s++)u.bst.m[s]=f.bst.m[s]-c.bst.m[s];u.est=estats(u.bst),f.left=c,f.right=u,a[o]=c,a.push(u);}a.sort(((e,t)=>t.bst.N-e.bst.N));for(s=0;s<a.length;s++)a[s].ind=s;return [o,a]}function getNearest(e,t,r,i,o){if(null==e.left)return e.tdst=function dist(e,t,r,i,o){const a=t-e[0],s=r-e[1],f=i-e[2],l=o-e[3];return a*a+s*s+f*f+l*l}(e.est.q,t,r,i,o),e;const a=planeDst(e.est,t,r,i,o);let s=e.left,f=e.right;a>0&&(s=e.right,f=e.left);const l=getNearest(s,t,r,i,o);if(l.tdst<=a*a)return l;const c=getNearest(f,t,r,i,o);return c.tdst<l.tdst?c:l}function planeDst(e,t,r,i,o){const{e:a}=e;return a[0]*t+a[1]*r+a[2]*i+a[3]*o-e.eMq}function splitPixels(e,t,r,i,o,a){for(i-=4;r<i;){for(;vecDot(e,r,o)<=a;)r+=4;for(;vecDot(e,i,o)>a;)i-=4;if(r>=i)break;const s=t[r>>2];t[r>>2]=t[i>>2],t[i>>2]=s,r+=4,i-=4;}for(;vecDot(e,r,o)>a;)r-=4;return r+4}function vecDot(e,t,r){return e[t]*r[0]+e[t+1]*r[1]+e[t+2]*r[2]+e[t+3]*r[3]}function stats(e,t,r){const i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o=[0,0,0,0],a=r-t>>2;for(let a=t;a<r;a+=4){const t=e[a]*(1/255),r=e[a+1]*(1/255),s=e[a+2]*(1/255),f=e[a+3]*(1/255);o[0]+=t,o[1]+=r,o[2]+=s,o[3]+=f,i[0]+=t*t,i[1]+=t*r,i[2]+=t*s,i[3]+=t*f,i[5]+=r*r,i[6]+=r*s,i[7]+=r*f,i[10]+=s*s,i[11]+=s*f,i[15]+=f*f;}return i[4]=i[1],i[8]=i[2],i[9]=i[6],i[12]=i[3],i[13]=i[7],i[14]=i[11],{R:i,m:o,N:a}}function estats(e){const{R:t}=e,{m:r}=e,{N:i}=e,a=r[0],s=r[1],f=r[2],l=r[3],c=0==i?0:1/i,u=[t[0]-a*a*c,t[1]-a*s*c,t[2]-a*f*c,t[3]-a*l*c,t[4]-s*a*c,t[5]-s*s*c,t[6]-s*f*c,t[7]-s*l*c,t[8]-f*a*c,t[9]-f*s*c,t[10]-f*f*c,t[11]-f*l*c,t[12]-l*a*c,t[13]-l*s*c,t[14]-l*f*c,t[15]-l*l*c],h=u,d=o;let A=[Math.random(),Math.random(),Math.random(),Math.random()],g=0,p=0;if(0!=i)for(let e=0;e<16&&(A=d.multVec(h,A),p=Math.sqrt(d.dot(A,A)),A=d.sml(1/p,A),!(0!=e&&Math.abs(p-g)<1e-9));e++)g=p;const m=[a*c,s*c,f*c,l*c];return {Cov:u,q:m,e:A,L:g,eMq255:d.dot(d.sml(255,m),A),eMq:d.dot(A,m),rgba:(Math.round(255*m[3])<<24|Math.round(255*m[2])<<16|Math.round(255*m[1])<<8|Math.round(255*m[0])<<0)>>>0}}var o={multVec:(e,t)=>[e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7]*t[3],e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11]*t[3],e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]*t[3]],dot:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],sml:(e,t)=>[e*t[0],e*t[1],e*t[2],e*t[3]]};UPNG.encode=function encode(e,t,r,i,o,a,s){null==i&&(i=0),null==s&&(s=false);const f=compress(e,t,r,i,[false,false,false,0,s,false]);return compressPNG(f,-1),_main(f,t,r,o,a)},UPNG.encodeLL=function encodeLL(e,t,r,i,o,a,s,f){const l={ctype:0+(1==i?0:2)+(0==o?0:4),depth:a,frames:[]},c=(i+o)*a,u=c*t;for(let i=0;i<e.length;i++)l.frames.push({rect:{x:0,y:0,width:t,height:r},img:new Uint8Array(e[i]),blend:0,dispose:1,bpp:Math.ceil(c/8),bpl:Math.ceil(u/8)});return compressPNG(l,0,true),_main(l,t,r,s,f)},UPNG.encode.compress=compress,UPNG.encode.dither=dither,UPNG.quantize=quantize,UPNG.quantize.getKDtree=getKDtree,UPNG.quantize.getNearest=getNearest;}();const r={toArrayBuffer(e,t){const i=e.width,o=e.height,a=i<<2,s=e.getContext("2d").getImageData(0,0,i,o),f=new Uint32Array(s.data.buffer),l=(32*i+31)/32<<2,c=l*o,u=122+c,h=new ArrayBuffer(u),d=new DataView(h),A=1<<20;let g,p,m,w,v=A,b=0,y=0,E=0;function set16(e){d.setUint16(y,e,true),y+=2;}function set32(e){d.setUint32(y,e,true),y+=4;}function seek(e){y+=e;}set16(19778),set32(u),seek(4),set32(122),set32(108),set32(i),set32(-o>>>0),set16(1),set16(32),set32(3),set32(c),set32(2835),set32(2835),seek(8),set32(16711680),set32(65280),set32(255),set32(4278190080),set32(1466527264),function convert(){for(;b<o&&v>0;){for(w=122+b*l,g=0;g<a;)v--,p=f[E++],m=p>>>24,d.setUint32(w+g,p<<8|m),g+=4;b++;}E<f.length?(v=A,setTimeout(convert,r._dly)):t(h);}();},toBlob(e,t){this.toArrayBuffer(e,(e=>{t(new Blob([e],{type:"image/bmp"}));}));},_dly:9};var i={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},o={[i.CHROME]:16384,[i.FIREFOX]:11180,[i.DESKTOP_SAFARI]:16384,[i.IE]:8192,[i.IOS]:4096,[i.ETC]:8192};const a="undefined"!=typeof window,s="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,f=a&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),CustomFile=(a||s)&&(f&&f.getOriginalSymbol(window,"File")||"undefined"!=typeof File&&File),CustomFileReader=(a||s)&&(f&&f.getOriginalSymbol(window,"FileReader")||"undefined"!=typeof FileReader&&FileReader);function getFilefromDataUrl(e,t,r=Date.now()){return new Promise((i=>{const o=e.split(","),a=o[0].match(/:(.*?);/)[1],s=globalThis.atob(o[1]);let f=s.length;const l=new Uint8Array(f);for(;f--;)l[f]=s.charCodeAt(f);const c=new Blob([l],{type:a});c.name=t,c.lastModified=r,i(c);}))}function getDataUrlFromFile(e){return new Promise(((t,r)=>{const i=new CustomFileReader;i.onload=()=>t(i.result),i.onerror=e=>r(e),i.readAsDataURL(e);}))}function loadImage(e){return new Promise(((t,r)=>{const i=new Image;i.onload=()=>t(i),i.onerror=e=>r(e),i.src=e;}))}function getBrowserName(){if(void 0!==getBrowserName.cachedResult)return getBrowserName.cachedResult;let e=i.ETC;const{userAgent:t}=navigator;return /Chrom(e|ium)/i.test(t)?e=i.CHROME:/iP(ad|od|hone)/i.test(t)&&/WebKit/i.test(t)?e=i.IOS:/Safari/i.test(t)?e=i.DESKTOP_SAFARI:/Firefox/i.test(t)?e=i.FIREFOX:(/MSIE/i.test(t)||true==!!document.documentMode)&&(e=i.IE),getBrowserName.cachedResult=e,getBrowserName.cachedResult}function approximateBelowMaximumCanvasSizeOfBrowser(e,t){const r=getBrowserName(),i=o[r];let a=e,s=t,f=a*s;const l=a>s?s/a:a/s;for(;f>i*i;){const e=(i+a)/2,t=(i+s)/2;e<t?(s=t,a=t*l):(s=e*l,a=e),f=a*s;}return {width:a,height:s}}function getNewCanvasAndCtx(e,t){let r,i;try{if(r=new OffscreenCanvas(e,t),i=r.getContext("2d"),null===i)throw new Error("getContext of OffscreenCanvas returns null")}catch(e){r=document.createElement("canvas"),i=r.getContext("2d");}return r.width=e,r.height=t,[r,i]}function drawImageInCanvas(e,t){const{width:r,height:i}=approximateBelowMaximumCanvasSizeOfBrowser(e.width,e.height),[o,a]=getNewCanvasAndCtx(r,i);return t&&/jpe?g/.test(t)&&(a.fillStyle="white",a.fillRect(0,0,o.width,o.height)),a.drawImage(e,0,0,o.width,o.height),o}function isIOS(){return void 0!==isIOS.cachedResult||(isIOS.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"undefined"!=typeof document&&"ontouchend"in document),isIOS.cachedResult}function drawFileInCanvas(e,t={}){return new Promise((function(r,o){let a,s;var $Try_2_Post=function(){try{return s=drawImageInCanvas(a,t.fileType||e.type),r([a,s])}catch(e){return o(e)}},$Try_2_Catch=function(t){try{var $Try_3_Catch=function(e){try{throw e}catch(e){return o(e)}};try{let t;return getDataUrlFromFile(e).then((function(e){try{return t=e,loadImage(t).then((function(e){try{return a=e,function(){try{return $Try_2_Post()}catch(e){return o(e)}}()}catch(e){return $Try_3_Catch(e)}}),$Try_3_Catch)}catch(e){return $Try_3_Catch(e)}}),$Try_3_Catch)}catch(e){$Try_3_Catch(e);}}catch(e){return o(e)}};try{if(isIOS()||[i.DESKTOP_SAFARI,i.MOBILE_SAFARI].includes(getBrowserName()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(e).then((function(e){try{return a=e,$Try_2_Post()}catch(e){return $Try_2_Catch()}}),$Try_2_Catch)}catch(e){$Try_2_Catch();}}))}function canvasToFile(e,t,i,o,a=1){return new Promise((function(s,f){let l;if("image/png"===t){let c,u,h;return c=e.getContext("2d"),({data:u}=c.getImageData(0,0,e.width,e.height)),h=UPNG.encode([u.buffer],e.width,e.height,4096*a),l=new Blob([h],{type:t}),l.name=i,l.lastModified=o,$If_4.call(this)}{if("image/bmp"===t)return new Promise((t=>r.toBlob(e,t))).then(function(e){try{return l=e,l.name=i,l.lastModified=o,$If_5.call(this)}catch(e){return f(e)}}.bind(this),f);{if("function"==typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return e.convertToBlob({type:t,quality:a}).then(function(e){try{return l=e,l.name=i,l.lastModified=o,$If_6.call(this)}catch(e){return f(e)}}.bind(this),f);{let d;return d=e.toDataURL(t,a),getFilefromDataUrl(d,i,o).then(function(e){try{return l=e,$If_6.call(this)}catch(e){return f(e)}}.bind(this),f)}function $If_6(){return $If_5.call(this)}}function $If_5(){return $If_4.call(this)}}function $If_4(){return s(l)}}))}function cleanupCanvasMemory(e){e.width=0,e.height=0;}function isAutoOrientationInBrowser(){return new Promise((function(e,t){let i,o,a,s;return void 0!==isAutoOrientationInBrowser.cachedResult?e(isAutoOrientationInBrowser.cachedResult):(getFilefromDataUrl("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(r){try{return i=r,drawFileInCanvas(i).then((function(r){try{return o=r[1],canvasToFile(o,i.type,i.name,i.lastModified).then((function(r){try{return a=r,cleanupCanvasMemory(o),drawFileInCanvas(a).then((function(r){try{return s=r[0],isAutoOrientationInBrowser.cachedResult=1===s.width&&2===s.height,e(isAutoOrientationInBrowser.cachedResult)}catch(e){return t(e)}}),t)}catch(e){return t(e)}}),t)}catch(e){return t(e)}}),t)}catch(e){return t(e)}}),t))}))}function getExifOrientation(e){return new Promise(((t,r)=>{const i=new CustomFileReader;i.onload=e=>{const r=new DataView(e.target.result);if(65496!=r.getUint16(0,false))return t(-2);const i=r.byteLength;let o=2;for(;o<i;){if(r.getUint16(o+2,false)<=8)return t(-1);const e=r.getUint16(o,false);if(o+=2,65505==e){if(1165519206!=r.getUint32(o+=2,false))return t(-1);const e=18761==r.getUint16(o+=6,false);o+=r.getUint32(o+4,e);const i=r.getUint16(o,e);o+=2;for(let a=0;a<i;a++)if(274==r.getUint16(o+12*a,e))return t(r.getUint16(o+12*a+8,e))}else {if(65280!=(65280&e))break;o+=r.getUint16(o,false);}}return t(-1)},i.onerror=e=>r(e),i.readAsArrayBuffer(e);}))}function handleMaxWidthOrHeight(e,t){const{width:r}=e,{height:i}=e,{maxWidthOrHeight:o}=t;let a,s=e;return isFinite(o)&&(r>o||i>o)&&([s,a]=getNewCanvasAndCtx(r,i),r>i?(s.width=o,s.height=i/r*o):(s.width=r/i*o,s.height=o),a.drawImage(e,0,0,s.width,s.height),cleanupCanvasMemory(e)),s}function followExifOrientation(e,t){const{width:r}=e,{height:i}=e,[o,a]=getNewCanvasAndCtx(r,i);switch(t>4&&t<9?(o.width=i,o.height=r):(o.width=r,o.height=i),t){case 2:a.transform(-1,0,0,1,r,0);break;case 3:a.transform(-1,0,0,-1,r,i);break;case 4:a.transform(1,0,0,-1,0,i);break;case 5:a.transform(0,1,1,0,0,0);break;case 6:a.transform(0,1,-1,0,i,0);break;case 7:a.transform(0,-1,-1,0,i,r);break;case 8:a.transform(0,-1,1,0,0,r);}return a.drawImage(e,0,0,r,i),cleanupCanvasMemory(e),o}function compress(e,t,r=0){return new Promise((function(i,o){let a,s,f,l,c,u,h,d,A,g,p,m,w,v,b,y,E,F,_,B;function incProgress(e=5){if(t.signal&&t.signal.aborted)throw t.signal.reason;a+=e,t.onProgress(Math.min(a,100));}function setProgress(e){if(t.signal&&t.signal.aborted)throw t.signal.reason;a=Math.min(Math.max(e,a),100),t.onProgress(a);}return a=r,s=t.maxIteration||10,f=1024*t.maxSizeMB*1024,incProgress(),drawFileInCanvas(e,t).then(function(r){try{return [,l]=r,incProgress(),c=handleMaxWidthOrHeight(l,t),incProgress(),new Promise((function(r,i){var o;if(!(o=t.exifOrientation))return getExifOrientation(e).then(function(e){try{return o=e,$If_2.call(this)}catch(e){return i(e)}}.bind(this),i);function $If_2(){return r(o)}return $If_2.call(this)})).then(function(r){try{return u=r,incProgress(),isAutoOrientationInBrowser().then(function(r){try{return h=r?c:followExifOrientation(c,u),incProgress(),d=t.initialQuality||1,A=t.fileType||e.type,canvasToFile(h,A,e.name,e.lastModified,d).then(function(r){try{{if(g=r,incProgress(),p=g.size>f,m=g.size>e.size,!p&&!m)return setProgress(100),i(g);var a;function $Loop_3(){if(s--&&(b>f||b>w)){let t,r;return t=B?.95*_.width:_.width,r=B?.95*_.height:_.height,[E,F]=getNewCanvasAndCtx(t,r),F.drawImage(_,0,0,t,r),d*="image/png"===A?.85:.95,canvasToFile(E,A,e.name,e.lastModified,d).then((function(e){try{return y=e,cleanupCanvasMemory(_),_=E,b=y.size,setProgress(Math.min(99,Math.floor((v-b)/(v-f)*100))),$Loop_3}catch(e){return o(e)}}),o)}return [1]}return w=e.size,v=g.size,b=v,_=h,B=!t.alwaysKeepResolution&&p,(a=function(e){for(;e;){if(e.then)return void e.then(a,o);try{if(e.pop){if(e.length)return e.pop()?$Loop_3_exit.call(this):e;e=$Loop_3;}else e=e.call(this);}catch(e){return o(e)}}}.bind(this))($Loop_3);function $Loop_3_exit(){return cleanupCanvasMemory(_),cleanupCanvasMemory(E),cleanupCanvasMemory(c),cleanupCanvasMemory(h),cleanupCanvasMemory(l),setProgress(100),i(y)}}}catch(u){return o(u)}}.bind(this),o)}catch(e){return o(e)}}.bind(this),o)}catch(e){return o(e)}}.bind(this),o)}catch(e){return o(e)}}.bind(this),o)}))}const l="\nlet scriptImported = false\nself.addEventListener('message', async (e) => {\n const { file, id, imageCompressionLibUrl, options } = e.data\n options.onProgress = (progress) => self.postMessage({ progress, id })\n try {\n if (!scriptImported) {\n // console.log('[worker] importScripts', imageCompressionLibUrl)\n self.importScripts(imageCompressionLibUrl)\n scriptImported = true\n }\n // console.log('[worker] self', self)\n const compressedFile = await imageCompression(file, options)\n self.postMessage({ file: compressedFile, id })\n } catch (e) {\n // console.error('[worker] error', e)\n self.postMessage({ error: e.message + '\\n' + e.stack, id })\n }\n})\n";let c;function compressOnWebWorker(e,t){return new Promise(((r,i)=>{c||(c=function createWorkerScriptURL(e){const t=[];return t.push(e),URL.createObjectURL(new Blob(t))}(l));const o=new Worker(c);o.addEventListener("message",(function handler(e){if(t.signal&&t.signal.aborted)o.terminate();else if(void 0===e.data.progress){if(e.data.error)return i(new Error(e.data.error)),void o.terminate();r(e.data.file),o.terminate();}else t.onProgress(e.data.progress);})),o.addEventListener("error",i),t.signal&&t.signal.addEventListener("abort",(()=>{i(t.signal.reason),o.terminate();})),o.postMessage({file:e,imageCompressionLibUrl:t.libURL,options:{...t,onProgress:void 0,signal:void 0}});}))}function imageCompression(e,t){return new Promise((function(r,i){let o,a,s,f,l,c;if(o={...t},s=0,({onProgress:f}=o),o.maxSizeMB=o.maxSizeMB||Number.POSITIVE_INFINITY,l="boolean"!=typeof o.useWebWorker||o.useWebWorker,delete o.useWebWorker,o.onProgress=e=>{s=e,"function"==typeof f&&f(s);},!(e instanceof Blob||e instanceof CustomFile))return i(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return i(new Error("The file given is not an image"));if(c="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,!l||"function"!=typeof Worker||c)return compress(e,o).then(function(e){try{return a=e,$If_4.call(this)}catch(e){return i(e)}}.bind(this),i);var u=function(){try{return $If_4.call(this)}catch(e){return i(e)}}.bind(this),$Try_1_Catch=function(t){try{return compress(e,o).then((function(e){try{return a=e,u()}catch(e){return i(e)}}),i)}catch(e){return i(e)}};try{return o.libURL=o.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",compressOnWebWorker(e,o).then((function(e){try{return a=e,u()}catch(e){return $Try_1_Catch()}}),$Try_1_Catch)}catch(e){$Try_1_Catch();}function $If_4(){try{a.name=e.name,a.lastModified=e.lastModified;}catch(e){}try{o.preserveExif&&"image/jpeg"===e.type&&(!o.fileType||o.fileType&&o.fileType===e.type)&&(a=copyExifWithoutOrientation(e,a));}catch(e){}return r(a)}}))}imageCompression.getDataUrlFromFile=getDataUrlFromFile,imageCompression.getFilefromDataUrl=getFilefromDataUrl,imageCompression.loadImage=loadImage,imageCompression.drawImageInCanvas=drawImageInCanvas,imageCompression.drawFileInCanvas=drawFileInCanvas,imageCompression.canvasToFile=canvasToFile,imageCompression.getExifOrientation=getExifOrientation,imageCompression.handleMaxWidthOrHeight=handleMaxWidthOrHeight,imageCompression.followExifOrientation=followExifOrientation,imageCompression.cleanupCanvasMemory=cleanupCanvasMemory,imageCompression.isAutoOrientationInBrowser=isAutoOrientationInBrowser,imageCompression.approximateBelowMaximumCanvasSizeOfBrowser=approximateBelowMaximumCanvasSizeOfBrowser,imageCompression.copyExifWithoutOrientation=copyExifWithoutOrientation,imageCompression.getBrowserName=getBrowserName,imageCompression.version="2.0.2";
|
|
1880
|
-
|
|
1881
|
-
class KritzelImageTool extends index$1.KritzelBaseTool {
|
|
1882
|
-
constructor(store) {
|
|
1883
|
-
super(store);
|
|
1884
|
-
this.fileInput = null;
|
|
1885
|
-
this.maxWidth = 300;
|
|
1886
|
-
this.maxHeight = 300;
|
|
1887
|
-
this.maxCompressionSize = 300;
|
|
1888
|
-
this.setupFileInput();
|
|
1889
|
-
}
|
|
1890
|
-
onActivate() {
|
|
1891
|
-
this.openFilePicker();
|
|
1892
|
-
}
|
|
1893
|
-
openFilePicker() {
|
|
1894
|
-
this.fileInput.click();
|
|
1895
|
-
}
|
|
1896
|
-
setupFileInput() {
|
|
1897
|
-
this.fileInput = document.createElement('input');
|
|
1898
|
-
this.fileInput.type = 'file';
|
|
1899
|
-
this.fileInput.accept = 'image/*';
|
|
1900
|
-
this.fileInput.style.display = 'none';
|
|
1901
|
-
this.fileInput.addEventListener('change', this.handleFileSelect.bind(this));
|
|
1902
|
-
this.fileInput.addEventListener('cancel', this.handleCancel.bind(this));
|
|
1903
|
-
document.body.appendChild(this.fileInput);
|
|
1904
|
-
}
|
|
1905
|
-
handleFileSelect(event) {
|
|
1906
|
-
const input = event.target;
|
|
1907
|
-
if (input.files && input.files[0]) {
|
|
1908
|
-
const file = input.files[0];
|
|
1909
|
-
imageCompression(file, {
|
|
1910
|
-
maxWidthOrHeight: this.maxCompressionSize,
|
|
1911
|
-
})
|
|
1912
|
-
.then(compressedFile => {
|
|
1913
|
-
this.readFile(compressedFile);
|
|
1914
|
-
})
|
|
1915
|
-
.catch(error => {
|
|
1916
|
-
console.error('Error during image compression or processing:', error);
|
|
1917
|
-
this.handleCancel();
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
else {
|
|
1921
|
-
console.info('File selection cancelled by user.');
|
|
1922
|
-
this.handleCancel();
|
|
1923
|
-
}
|
|
1924
|
-
if (input) {
|
|
1925
|
-
input.value = '';
|
|
611
|
+
static registerIcons(icons) {
|
|
612
|
+
for (const name in icons) {
|
|
613
|
+
if (Object.prototype.hasOwnProperty.call(icons, name)) {
|
|
614
|
+
this.register(name, icons[name]);
|
|
615
|
+
}
|
|
1926
616
|
}
|
|
1927
617
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
reader.onload = e => {
|
|
1931
|
-
var _a;
|
|
1932
|
-
const img = new Image();
|
|
1933
|
-
img.src = (_a = e.target) === null || _a === void 0 ? void 0 : _a.result;
|
|
1934
|
-
img.onload = () => this.processImage(img);
|
|
1935
|
-
};
|
|
1936
|
-
reader.readAsDataURL(file);
|
|
1937
|
-
}
|
|
1938
|
-
processImage(img) {
|
|
1939
|
-
const { scaledWidth, scaledHeight } = this.calculateScaledDimensions(img);
|
|
1940
|
-
const image = this.createKritzelImage(img, scaledWidth, scaledHeight);
|
|
1941
|
-
this.addImageToStore(image);
|
|
1942
|
-
}
|
|
1943
|
-
calculateScaledDimensions(img) {
|
|
1944
|
-
let scaledWidth = img.width;
|
|
1945
|
-
let scaledHeight = img.height;
|
|
1946
|
-
if (img.width > this.maxWidth || img.height > this.maxHeight) {
|
|
1947
|
-
const widthRatio = this.maxWidth / img.width;
|
|
1948
|
-
const heightRatio = this.maxHeight / img.height;
|
|
1949
|
-
const scaleRatio = Math.min(widthRatio, heightRatio);
|
|
1950
|
-
scaledWidth = img.width * scaleRatio;
|
|
1951
|
-
scaledHeight = img.height * scaleRatio;
|
|
1952
|
-
}
|
|
1953
|
-
return { scaledWidth, scaledHeight };
|
|
1954
|
-
}
|
|
1955
|
-
createKritzelImage(img, width, height) {
|
|
1956
|
-
const image = index$1.KritzelImage.create(this._store);
|
|
1957
|
-
image.src = img.src;
|
|
1958
|
-
image.width = width;
|
|
1959
|
-
image.height = height;
|
|
1960
|
-
image.zIndex = this._store.currentZIndex;
|
|
1961
|
-
image.centerInViewport();
|
|
1962
|
-
return image;
|
|
1963
|
-
}
|
|
1964
|
-
addImageToStore(image) {
|
|
1965
|
-
const selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
1966
|
-
selectionGroup.addOrRemove(image);
|
|
1967
|
-
selectionGroup.selected = true;
|
|
1968
|
-
const addImageCommand = new index$1.AddObjectCommand(this._store, this, image);
|
|
1969
|
-
const addSelectionGroupCommand = new AddSelectionGroupCommand(this._store, this, selectionGroup);
|
|
1970
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, [addImageCommand, addSelectionGroupCommand]));
|
|
1971
|
-
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
1972
|
-
}
|
|
1973
|
-
handleCancel() {
|
|
1974
|
-
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
618
|
+
static has(name) {
|
|
619
|
+
return this.registry.has(name);
|
|
1975
620
|
}
|
|
1976
621
|
}
|
|
622
|
+
KritzelIconRegistry.registry = new Map();
|
|
623
|
+
KritzelIconRegistry.registerIcons({
|
|
624
|
+
'cursor': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',
|
|
625
|
+
'pen': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',
|
|
626
|
+
'highlighter': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',
|
|
627
|
+
'eraser': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',
|
|
628
|
+
'type': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',
|
|
629
|
+
'image': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
|
|
630
|
+
'chevron-down': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',
|
|
631
|
+
'chevron-up': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',
|
|
632
|
+
'copy': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
|
|
633
|
+
'paste': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',
|
|
634
|
+
'cut': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',
|
|
635
|
+
'delete': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',
|
|
636
|
+
'bring-to-front': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',
|
|
637
|
+
'send-to-back': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',
|
|
638
|
+
'select-all': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',
|
|
639
|
+
'download': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',
|
|
640
|
+
'undo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',
|
|
641
|
+
'redo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>'
|
|
642
|
+
});
|
|
1977
643
|
|
|
1978
|
-
const
|
|
1979
|
-
|
|
1980
|
-
color: '#000000',
|
|
1981
|
-
size: 16,
|
|
1982
|
-
palettes: {
|
|
1983
|
-
pen: [
|
|
1984
|
-
'#000000',
|
|
1985
|
-
'#ff5252',
|
|
1986
|
-
'#ffbc00',
|
|
1987
|
-
'#00c853',
|
|
1988
|
-
'#0000FF',
|
|
1989
|
-
'#d500f9',
|
|
1990
|
-
'#fafafa',
|
|
1991
|
-
'#a52714',
|
|
1992
|
-
'#ee8100',
|
|
1993
|
-
'#558b2f',
|
|
1994
|
-
'#01579b',
|
|
1995
|
-
'#8e24aa',
|
|
1996
|
-
'#90a4ae',
|
|
1997
|
-
'#ff4081',
|
|
1998
|
-
'#ff6e40',
|
|
1999
|
-
'#aeea00',
|
|
2000
|
-
'#304ffe',
|
|
2001
|
-
'#7c4dff',
|
|
2002
|
-
'#cfd8dc',
|
|
2003
|
-
'#f8bbd0',
|
|
2004
|
-
'#ffccbc',
|
|
2005
|
-
'#f0f4c3',
|
|
2006
|
-
'#9fa8da',
|
|
2007
|
-
'#d1c4e9',
|
|
2008
|
-
],
|
|
2009
|
-
highlighter: [
|
|
2010
|
-
'#0000006e',
|
|
2011
|
-
'#ff52526e',
|
|
2012
|
-
'#ffbb006e',
|
|
2013
|
-
'#00c8536e',
|
|
2014
|
-
'#0000FF6e',
|
|
2015
|
-
'#d500f96e',
|
|
2016
|
-
'#fafafa6e',
|
|
2017
|
-
'#a527146e',
|
|
2018
|
-
'#ee81006e',
|
|
2019
|
-
'#558b2f6e',
|
|
2020
|
-
'#01579b6e',
|
|
2021
|
-
'#8e24aa6e',
|
|
2022
|
-
'#90a4ae6e',
|
|
2023
|
-
'#ff40816e',
|
|
2024
|
-
'#ff6e406e',
|
|
2025
|
-
'#aeea006e',
|
|
2026
|
-
'#304ffe6e',
|
|
2027
|
-
'#7c4dff6e',
|
|
2028
|
-
'#cfd8dc6e',
|
|
2029
|
-
'#f8bbd06e',
|
|
2030
|
-
'#ffccbc6e',
|
|
2031
|
-
'#f0f4c36e',
|
|
2032
|
-
'#9fa8da6e',
|
|
2033
|
-
'#d1c4e96e',
|
|
2034
|
-
],
|
|
2035
|
-
},
|
|
2036
|
-
};
|
|
2037
|
-
const DEFAULT_TEXT_CONFIG = {
|
|
2038
|
-
color: '#000000',
|
|
2039
|
-
size: 8,
|
|
2040
|
-
fontFamily: 'Arial',
|
|
2041
|
-
palette: [
|
|
2042
|
-
'#000000',
|
|
2043
|
-
'#ff5252',
|
|
2044
|
-
'#ffbc00',
|
|
2045
|
-
'#00c853',
|
|
2046
|
-
'#0000FF',
|
|
2047
|
-
'#d500f9',
|
|
2048
|
-
'#fafafa',
|
|
2049
|
-
'#a52714',
|
|
2050
|
-
'#ee8100',
|
|
2051
|
-
'#558b2f',
|
|
2052
|
-
'#01579b',
|
|
2053
|
-
'#8e24aa',
|
|
2054
|
-
'#90a4ae',
|
|
2055
|
-
'#ff4081',
|
|
2056
|
-
'#ff6e40',
|
|
2057
|
-
'#aeea00',
|
|
2058
|
-
'#304ffe',
|
|
2059
|
-
'#7c4dff',
|
|
2060
|
-
'#cfd8dc',
|
|
2061
|
-
'#f8bbd0',
|
|
2062
|
-
'#ffccbc',
|
|
2063
|
-
'#f0f4c3',
|
|
2064
|
-
'#9fa8da',
|
|
2065
|
-
'#d1c4e9',
|
|
2066
|
-
],
|
|
2067
|
-
};
|
|
2068
|
-
const DEFAULT_KRITZEL_CONTROLS = [
|
|
2069
|
-
{
|
|
2070
|
-
name: 'selection',
|
|
2071
|
-
type: 'tool',
|
|
2072
|
-
tool: KritzelSelectionTool,
|
|
2073
|
-
icon: 'cursor',
|
|
2074
|
-
},
|
|
2075
|
-
{
|
|
2076
|
-
name: 'brush',
|
|
2077
|
-
type: 'tool',
|
|
2078
|
-
tool: KritzelBrushTool,
|
|
2079
|
-
isDefault: true,
|
|
2080
|
-
icon: 'pen',
|
|
2081
|
-
config: DEFAULT_BRUSH_CONFIG,
|
|
2082
|
-
},
|
|
2083
|
-
{
|
|
2084
|
-
name: 'eraser',
|
|
2085
|
-
type: 'tool',
|
|
2086
|
-
tool: KritzelEraserTool,
|
|
2087
|
-
icon: 'eraser',
|
|
2088
|
-
},
|
|
2089
|
-
{
|
|
2090
|
-
name: 'text',
|
|
2091
|
-
type: 'tool',
|
|
2092
|
-
tool: index$1.KritzelTextTool,
|
|
2093
|
-
icon: 'type',
|
|
2094
|
-
config: DEFAULT_TEXT_CONFIG,
|
|
2095
|
-
},
|
|
2096
|
-
{
|
|
2097
|
-
name: 'image',
|
|
2098
|
-
type: 'tool',
|
|
2099
|
-
tool: KritzelImageTool,
|
|
2100
|
-
icon: 'image',
|
|
2101
|
-
},
|
|
2102
|
-
{
|
|
2103
|
-
name: 'divider',
|
|
2104
|
-
type: 'divider',
|
|
2105
|
-
},
|
|
2106
|
-
{
|
|
2107
|
-
name: 'config',
|
|
2108
|
-
type: 'config',
|
|
2109
|
-
},
|
|
2110
|
-
];
|
|
644
|
+
const ABSOLUTE_SCALE_MAX = 1000;
|
|
645
|
+
const ABSOLUTE_SCALE_MIN = 0.0001;
|
|
2111
646
|
|
|
2112
647
|
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}";
|
|
2113
648
|
|
|
@@ -2115,9 +650,88 @@ const KritzelEditor = class {
|
|
|
2115
650
|
constructor(hostRef) {
|
|
2116
651
|
index.registerInstance(this, hostRef);
|
|
2117
652
|
this.isReady = index.createEvent(this, "isReady");
|
|
2118
|
-
this.
|
|
653
|
+
this.scaleMax = ABSOLUTE_SCALE_MAX;
|
|
654
|
+
this.scaleMin = ABSOLUTE_SCALE_MIN;
|
|
655
|
+
this.controls = [
|
|
656
|
+
{
|
|
657
|
+
name: 'selection',
|
|
658
|
+
type: 'tool',
|
|
659
|
+
tool: index$1.KritzelSelectionTool,
|
|
660
|
+
icon: 'cursor',
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
name: 'brush',
|
|
664
|
+
type: 'tool',
|
|
665
|
+
tool: index$1.KritzelBrushTool,
|
|
666
|
+
isDefault: true,
|
|
667
|
+
icon: 'pen',
|
|
668
|
+
config: index$1.DEFAULT_BRUSH_CONFIG,
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: 'eraser',
|
|
672
|
+
type: 'tool',
|
|
673
|
+
tool: index$1.KritzelEraserTool,
|
|
674
|
+
icon: 'eraser',
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
name: 'text',
|
|
678
|
+
type: 'tool',
|
|
679
|
+
tool: index$1.KritzelTextTool,
|
|
680
|
+
icon: 'type',
|
|
681
|
+
config: index$1.DEFAULT_TEXT_CONFIG,
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
name: 'image',
|
|
685
|
+
type: 'tool',
|
|
686
|
+
tool: index$1.KritzelImageTool,
|
|
687
|
+
icon: 'image',
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
name: 'divider',
|
|
691
|
+
type: 'divider',
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
name: 'config',
|
|
695
|
+
type: 'config',
|
|
696
|
+
},
|
|
697
|
+
];
|
|
698
|
+
this.globalContextMenuItems = [
|
|
699
|
+
{
|
|
700
|
+
label: 'Paste',
|
|
701
|
+
icon: 'paste',
|
|
702
|
+
disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
|
|
703
|
+
action: menu => this.engineRef.paste(menu.x, menu.y),
|
|
704
|
+
},
|
|
705
|
+
{ label: 'Select All', icon: 'select-all', action: () => this.selectAllObjectsInViewport() },
|
|
706
|
+
];
|
|
707
|
+
this.objectContextMenuItems = [
|
|
708
|
+
{
|
|
709
|
+
label: 'Edit',
|
|
710
|
+
icon: 'pen',
|
|
711
|
+
visible: (_, objects) => objects.length === 1 && objects[0].isEditable,
|
|
712
|
+
action: (_, objects) => {
|
|
713
|
+
if (objects.length === 1) {
|
|
714
|
+
const object = objects[0];
|
|
715
|
+
if (object.isEditable) {
|
|
716
|
+
object.edit();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
{ label: 'Copy', icon: 'copy', action: () => this.engineRef.copy() },
|
|
722
|
+
{
|
|
723
|
+
label: 'Paste',
|
|
724
|
+
icon: 'paste',
|
|
725
|
+
disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
|
|
726
|
+
action: menu => this.engineRef.paste(menu.x, menu.y),
|
|
727
|
+
},
|
|
728
|
+
{ label: 'Delete', icon: 'delete', action: () => this.engineRef.delete() },
|
|
729
|
+
{ label: 'Bring to Front', icon: 'bring-to-front', action: () => this.engineRef.moveToTop() },
|
|
730
|
+
{ label: 'Send to Back', icon: 'send-to-back', action: () => this.engineRef.moveToBottom() },
|
|
731
|
+
];
|
|
2119
732
|
this.customSvgIcons = {};
|
|
2120
|
-
this.
|
|
733
|
+
this.isControlsVisible = true;
|
|
734
|
+
this.isUtilityPanelVisible = true;
|
|
2121
735
|
this.isEngineReady = false;
|
|
2122
736
|
this.isControlsReady = false;
|
|
2123
737
|
}
|
|
@@ -2188,7 +802,7 @@ const KritzelEditor = class {
|
|
|
2188
802
|
}
|
|
2189
803
|
}
|
|
2190
804
|
render() {
|
|
2191
|
-
return (index.h(index.Host, { key: '
|
|
805
|
+
return (index.h(index.Host, { key: '512d901979a81f1affdda0e920d7216e7605863a' }, index.h("kritzel-engine", { key: '9828d5a1e78f6ce66fde98e95d82947cd8efba25', ref: el => (this.engineRef = el), onIsEngineReady: () => (this.isEngineReady = true), scaleMax: this.scaleMax, scaleMin: this.scaleMin, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems }), index.h("kritzel-controls", { key: 'a8d52ab6fce293a97c34aeb2a03823916dcdf947', ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, style: this.isControlsVisible ? { display: 'flex' } : { display: 'none' }, onIsControlsReady: () => (this.isControlsReady = true) })));
|
|
2192
806
|
}
|
|
2193
807
|
get host() { return index.getElement(this); }
|
|
2194
808
|
static get watchers() { return {
|
|
@@ -2648,13 +1262,17 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
2648
1262
|
cursorX: 0,
|
|
2649
1263
|
cursorY: 0,
|
|
2650
1264
|
scale: 1,
|
|
2651
|
-
scaleMax:
|
|
2652
|
-
scaleMin:
|
|
1265
|
+
scaleMax: 1,
|
|
1266
|
+
scaleMin: 1,
|
|
2653
1267
|
scaleStep: 0.05,
|
|
2654
1268
|
startX: 0,
|
|
2655
1269
|
startY: 0,
|
|
2656
1270
|
translateX: 0,
|
|
1271
|
+
translateXMax: 400,
|
|
1272
|
+
translateXMin: 0,
|
|
2657
1273
|
translateY: 0,
|
|
1274
|
+
translateYMax: 400,
|
|
1275
|
+
translateYMin: 0,
|
|
2658
1276
|
viewportWidth: 0,
|
|
2659
1277
|
viewportHeight: 0,
|
|
2660
1278
|
historyBufferSize: 1000,
|
|
@@ -2671,13 +1289,13 @@ class KritzelStore {
|
|
|
2671
1289
|
return this._state;
|
|
2672
1290
|
}
|
|
2673
1291
|
get currentZIndex() {
|
|
2674
|
-
return this._state.objectsOctree.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox)).length;
|
|
1292
|
+
return this._state.objectsOctree.filter(o => !(o instanceof index$1.KritzelSelectionGroup) && !(o instanceof index$1.KrtizelSelectionBox)).length;
|
|
2675
1293
|
}
|
|
2676
1294
|
get allObjects() {
|
|
2677
1295
|
return this._state.objectsOctree.allObjects();
|
|
2678
1296
|
}
|
|
2679
1297
|
get selectedObjects() {
|
|
2680
|
-
return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup)).filter(o => o.selected);
|
|
1298
|
+
return this.allObjects.filter(o => !(o instanceof index$1.KritzelSelectionGroup)).filter(o => o.selected);
|
|
2681
1299
|
}
|
|
2682
1300
|
get offsetX() {
|
|
2683
1301
|
return this._state.host.getBoundingClientRect().left;
|
|
@@ -2724,7 +1342,7 @@ class KritzelStore {
|
|
|
2724
1342
|
}
|
|
2725
1343
|
deselectAllObjects() {
|
|
2726
1344
|
if (this._state.selectionGroup) {
|
|
2727
|
-
this._history.executeCommand(new RemoveSelectionGroupCommand(this, this));
|
|
1345
|
+
this._history.executeCommand(new index$1.RemoveSelectionGroupCommand(this, this));
|
|
2728
1346
|
}
|
|
2729
1347
|
}
|
|
2730
1348
|
onStateChange(property, listener) {
|
|
@@ -2746,16 +1364,16 @@ class KritzelStore {
|
|
|
2746
1364
|
if (!this.state.selectionGroup) {
|
|
2747
1365
|
return;
|
|
2748
1366
|
}
|
|
2749
|
-
const deleteSelectedObjectsCommand = this.state.selectionGroup.objects.map(obj => new RemoveObjectCommand(this, this.state.selectionGroup, obj));
|
|
2750
|
-
const removeSelectionGroupCommand = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);
|
|
1367
|
+
const deleteSelectedObjectsCommand = this.state.selectionGroup.objects.map(obj => new index$1.RemoveObjectCommand(this, this.state.selectionGroup, obj));
|
|
1368
|
+
const removeSelectionGroupCommand = new index$1.RemoveSelectionGroupCommand(this, this.state.selectionGroup);
|
|
2751
1369
|
const commands = [...deleteSelectedObjectsCommand, removeSelectionGroupCommand];
|
|
2752
|
-
this.history.executeCommand(new BatchCommand(this, this.state.selectionGroup, commands));
|
|
1370
|
+
this.history.executeCommand(new index$1.BatchCommand(this, this.state.selectionGroup, commands));
|
|
2753
1371
|
}
|
|
2754
1372
|
deleteObject(id, isHistoryUpdated = true) {
|
|
2755
1373
|
const object = this.findObjectById(id);
|
|
2756
1374
|
if (object) {
|
|
2757
1375
|
if (isHistoryUpdated) {
|
|
2758
|
-
const removeObjectCommand = new RemoveObjectCommand(this, this, object);
|
|
1376
|
+
const removeObjectCommand = new index$1.RemoveObjectCommand(this, this, object);
|
|
2759
1377
|
this.history.executeCommand(removeObjectCommand);
|
|
2760
1378
|
}
|
|
2761
1379
|
else {
|
|
@@ -2774,12 +1392,12 @@ class KritzelStore {
|
|
|
2774
1392
|
this.state.copiedObjects.updatePosition(adjustedX, adjustedY);
|
|
2775
1393
|
const commands = [];
|
|
2776
1394
|
if (this.state.selectionGroup !== null) {
|
|
2777
|
-
commands.push(new RemoveSelectionGroupCommand(this, this.state.selectionGroup));
|
|
1395
|
+
commands.push(new index$1.RemoveSelectionGroupCommand(this, this.state.selectionGroup));
|
|
2778
1396
|
}
|
|
2779
1397
|
const addCopiedObjectsCommands = this.state.copiedObjects.objects.map(obj => new index$1.AddObjectCommand(this, this, obj));
|
|
2780
|
-
const addCopiedObjectsAsSelectionGroupCommand = new AddSelectionGroupCommand(this, this, this.state.copiedObjects);
|
|
1398
|
+
const addCopiedObjectsAsSelectionGroupCommand = new index$1.AddSelectionGroupCommand(this, this, this.state.copiedObjects);
|
|
2781
1399
|
commands.push(...addCopiedObjectsCommands, addCopiedObjectsAsSelectionGroupCommand);
|
|
2782
|
-
this.history.executeCommand(new BatchCommand(this, this, commands));
|
|
1400
|
+
this.history.executeCommand(new index$1.BatchCommand(this, this, commands));
|
|
2783
1401
|
this.state.isSelecting = false;
|
|
2784
1402
|
this.state.copiedObjects = this.state.selectionGroup.copy();
|
|
2785
1403
|
this.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
@@ -2793,7 +1411,7 @@ class KritzelStore {
|
|
|
2793
1411
|
}
|
|
2794
1412
|
return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex + 1 });
|
|
2795
1413
|
});
|
|
2796
|
-
this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));
|
|
1414
|
+
this.history.executeCommand(new index$1.BatchCommand(this, this, increaseZIndexCommands));
|
|
2797
1415
|
}
|
|
2798
1416
|
sendBackward(object) {
|
|
2799
1417
|
const min = 0;
|
|
@@ -2804,7 +1422,7 @@ class KritzelStore {
|
|
|
2804
1422
|
}
|
|
2805
1423
|
return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex - 1 });
|
|
2806
1424
|
});
|
|
2807
|
-
this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));
|
|
1425
|
+
this.history.executeCommand(new index$1.BatchCommand(this, this, decreaseZIndexCommands));
|
|
2808
1426
|
}
|
|
2809
1427
|
bringToFront(object) {
|
|
2810
1428
|
const max = this.allObjects.length + 1;
|
|
@@ -2812,7 +1430,7 @@ class KritzelStore {
|
|
|
2812
1430
|
const increaseZIndexCommands = objects.map(obj => {
|
|
2813
1431
|
return new UpdateObjectCommand(this, this, obj, { zIndex: max });
|
|
2814
1432
|
});
|
|
2815
|
-
this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));
|
|
1433
|
+
this.history.executeCommand(new index$1.BatchCommand(this, this, increaseZIndexCommands));
|
|
2816
1434
|
}
|
|
2817
1435
|
sendToBack(object) {
|
|
2818
1436
|
const min = -1;
|
|
@@ -2820,13 +1438,13 @@ class KritzelStore {
|
|
|
2820
1438
|
const decreaseZIndexCommands = objects.map(obj => {
|
|
2821
1439
|
return new UpdateObjectCommand(this, this, obj, { zIndex: min });
|
|
2822
1440
|
});
|
|
2823
|
-
this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));
|
|
1441
|
+
this.history.executeCommand(new index$1.BatchCommand(this, this, decreaseZIndexCommands));
|
|
2824
1442
|
}
|
|
2825
1443
|
selectObjects(objects) {
|
|
2826
1444
|
if (objects.length === 0) {
|
|
2827
1445
|
return;
|
|
2828
1446
|
}
|
|
2829
|
-
const selectionGroup = KritzelSelectionGroup.create(this);
|
|
1447
|
+
const selectionGroup = index$1.KritzelSelectionGroup.create(this);
|
|
2830
1448
|
objects.forEach(obj => {
|
|
2831
1449
|
obj.selected = false;
|
|
2832
1450
|
selectionGroup.addOrRemove(obj);
|
|
@@ -2836,7 +1454,7 @@ class KritzelStore {
|
|
|
2836
1454
|
if (objects.length === 1) {
|
|
2837
1455
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
2838
1456
|
}
|
|
2839
|
-
this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));
|
|
1457
|
+
this.history.executeCommand(new index$1.AddSelectionGroupCommand(this, this, selectionGroup));
|
|
2840
1458
|
}
|
|
2841
1459
|
selectAllObjectsInViewport() {
|
|
2842
1460
|
const objectsInViewport = this._state.objectsOctree
|
|
@@ -2848,9 +1466,9 @@ class KritzelStore {
|
|
|
2848
1466
|
height: this._state.viewportHeight / this._state.scale,
|
|
2849
1467
|
depth: 100,
|
|
2850
1468
|
})
|
|
2851
|
-
.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox) && !(o instanceof KritzelContextMenu));
|
|
1469
|
+
.filter(o => !(o instanceof index$1.KritzelSelectionGroup) && !(o instanceof index$1.KrtizelSelectionBox) && !(o instanceof KritzelContextMenu));
|
|
2852
1470
|
if (objectsInViewport.length > 0) {
|
|
2853
|
-
const selectionGroup = KritzelSelectionGroup.create(this);
|
|
1471
|
+
const selectionGroup = index$1.KritzelSelectionGroup.create(this);
|
|
2854
1472
|
objectsInViewport.forEach(obj => {
|
|
2855
1473
|
obj.selected = false;
|
|
2856
1474
|
selectionGroup.addOrRemove(obj);
|
|
@@ -2860,12 +1478,12 @@ class KritzelStore {
|
|
|
2860
1478
|
if (objectsInViewport.length === 1) {
|
|
2861
1479
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
2862
1480
|
}
|
|
2863
|
-
this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));
|
|
1481
|
+
this.history.executeCommand(new index$1.AddSelectionGroupCommand(this, this, selectionGroup));
|
|
2864
1482
|
this.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
2865
1483
|
}
|
|
2866
1484
|
}
|
|
2867
1485
|
clearSelection() {
|
|
2868
|
-
const command = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);
|
|
1486
|
+
const command = new index$1.RemoveSelectionGroupCommand(this, this.state.selectionGroup);
|
|
2869
1487
|
this.history.executeCommand(command);
|
|
2870
1488
|
this.state.selectionGroup = null;
|
|
2871
1489
|
this.state.selectionBox = null;
|
|
@@ -2885,19 +1503,8 @@ class KritzelStore {
|
|
|
2885
1503
|
const shadowRoot = (_a = this.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
|
|
2886
1504
|
if (!shadowRoot)
|
|
2887
1505
|
return null;
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
if ('touches' in event) {
|
|
2891
|
-
const touch = event.touches[0];
|
|
2892
|
-
if (!touch)
|
|
2893
|
-
return null;
|
|
2894
|
-
clientX = touch.clientX;
|
|
2895
|
-
clientY = touch.clientY;
|
|
2896
|
-
}
|
|
2897
|
-
else {
|
|
2898
|
-
clientX = event.clientX;
|
|
2899
|
-
clientY = event.clientY;
|
|
2900
|
-
}
|
|
1506
|
+
const clientX = event.clientX;
|
|
1507
|
+
const clientY = event.clientY;
|
|
2901
1508
|
const elementAtPoint = shadowRoot.elementFromPoint(clientX, clientY);
|
|
2902
1509
|
if (!elementAtPoint)
|
|
2903
1510
|
return null;
|
|
@@ -2909,7 +1516,7 @@ class KritzelStore {
|
|
|
2909
1516
|
}
|
|
2910
1517
|
}
|
|
2911
1518
|
|
|
2912
|
-
class KritzelKeyHandler extends KritzelBaseHandler {
|
|
1519
|
+
class KritzelKeyHandler extends index$1.KritzelBaseHandler {
|
|
2913
1520
|
constructor(store) {
|
|
2914
1521
|
super(store);
|
|
2915
1522
|
}
|
|
@@ -2988,7 +1595,7 @@ class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
2988
1595
|
}
|
|
2989
1596
|
}
|
|
2990
1597
|
|
|
2991
|
-
class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
1598
|
+
class KritzelContextMenuHandler extends index$1.KritzelBaseHandler {
|
|
2992
1599
|
constructor(store, globalContextMenuItems, objectContextMenuItems) {
|
|
2993
1600
|
super(store);
|
|
2994
1601
|
this.globalContextMenuItems = [];
|
|
@@ -3002,13 +1609,13 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
3002
1609
|
return;
|
|
3003
1610
|
}
|
|
3004
1611
|
const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
|
|
3005
|
-
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
|
|
3006
|
-
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
1612
|
+
if (selectedObject && !(selectedObject instanceof index$1.KritzelSelectionGroup)) {
|
|
1613
|
+
this._store.state.selectionGroup = index$1.KritzelSelectionGroup.create(this._store);
|
|
3007
1614
|
this._store.state.selectionGroup.addOrRemove(selectedObject);
|
|
3008
1615
|
this._store.state.selectionGroup.selected = true;
|
|
3009
1616
|
this._store.state.selectionGroup.rotation = selectedObject.rotation;
|
|
3010
1617
|
this._store.state.isSelecting = false;
|
|
3011
|
-
this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
1618
|
+
this._store.history.executeCommand(new index$1.AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
3012
1619
|
}
|
|
3013
1620
|
this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
|
|
3014
1621
|
let x = event.clientX - this._store.offsetX;
|
|
@@ -3041,66 +1648,51 @@ class KritzelClassHelper {
|
|
|
3041
1648
|
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}";
|
|
3042
1649
|
|
|
3043
1650
|
const KritzelEngine = class {
|
|
1651
|
+
validateScaleMax(newValue) {
|
|
1652
|
+
if (newValue > ABSOLUTE_SCALE_MAX) {
|
|
1653
|
+
console.warn(`scaleMax cannot be greater than ${ABSOLUTE_SCALE_MAX}.`);
|
|
1654
|
+
this.scaleMax = ABSOLUTE_SCALE_MAX;
|
|
1655
|
+
this.store.state.scaleMax = this.scaleMax;
|
|
1656
|
+
}
|
|
1657
|
+
else {
|
|
1658
|
+
this.store.state.scaleMax = newValue;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
validateScaleMin(newValue) {
|
|
1662
|
+
if (newValue < ABSOLUTE_SCALE_MIN) {
|
|
1663
|
+
console.warn(`scaleMin cannot be less than ${ABSOLUTE_SCALE_MIN}.`);
|
|
1664
|
+
this.scaleMin = ABSOLUTE_SCALE_MIN;
|
|
1665
|
+
this.store.state.scaleMin = this.scaleMin;
|
|
1666
|
+
}
|
|
1667
|
+
else {
|
|
1668
|
+
this.store.state.scaleMin = newValue;
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
3044
1671
|
get isSelecting() {
|
|
3045
|
-
return this.store.state.activeTool instanceof KritzelSelectionTool && this.store.state.isSelecting;
|
|
1672
|
+
return this.store.state.activeTool instanceof index$1.KritzelSelectionTool && this.store.state.isSelecting;
|
|
3046
1673
|
}
|
|
3047
1674
|
get isSelectionActive() {
|
|
3048
|
-
return this.store.state.activeTool instanceof KritzelSelectionTool && this.store.state.selectionGroup !== null;
|
|
1675
|
+
return this.store.state.activeTool instanceof index$1.KritzelSelectionTool && this.store.state.selectionGroup !== null;
|
|
3049
1676
|
}
|
|
3050
1677
|
constructor(hostRef) {
|
|
3051
1678
|
index.registerInstance(this, hostRef);
|
|
3052
1679
|
this.isEngineReady = index.createEvent(this, "isEngineReady");
|
|
3053
1680
|
this.activeToolChange = index.createEvent(this, "activeToolChange");
|
|
3054
|
-
this.
|
|
3055
|
-
|
|
3056
|
-
label: 'Paste',
|
|
3057
|
-
icon: 'paste',
|
|
3058
|
-
disabled: () => this.store.state.copiedObjects === null,
|
|
3059
|
-
action: () => {
|
|
3060
|
-
const x = (-this.store.state.translateX + this.store.state.contextMenuX) / this.store.state.scale;
|
|
3061
|
-
const y = (-this.store.state.translateY + this.store.state.contextMenuY) / this.store.state.scale;
|
|
3062
|
-
this.paste(x, y);
|
|
3063
|
-
},
|
|
3064
|
-
},
|
|
3065
|
-
{ label: 'Select All', icon: 'select-all', action: () => this.selectAllObjectsInViewport() },
|
|
3066
|
-
];
|
|
3067
|
-
this.objectContextMenuItems = [
|
|
3068
|
-
{ label: 'Copy', icon: 'copy', action: () => this.copy() },
|
|
3069
|
-
{
|
|
3070
|
-
label: 'Paste',
|
|
3071
|
-
icon: 'paste',
|
|
3072
|
-
disabled: () => this.store.state.copiedObjects === null,
|
|
3073
|
-
action: () => {
|
|
3074
|
-
const x = (-this.store.state.translateX + this.store.state.contextMenuX) / this.store.state.scale;
|
|
3075
|
-
const y = (-this.store.state.translateY + this.store.state.contextMenuY) / this.store.state.scale;
|
|
3076
|
-
this.paste(x, y);
|
|
3077
|
-
},
|
|
3078
|
-
},
|
|
3079
|
-
{ label: 'Delete', icon: 'delete', action: () => this.delete() },
|
|
3080
|
-
{ label: 'Bring to Front', icon: 'bring-to-front', action: () => this.moveToTop() },
|
|
3081
|
-
{ label: 'Send to Back', icon: 'send-to-back', action: () => this.moveToBottom() },
|
|
3082
|
-
];
|
|
1681
|
+
this.scaleMax = ABSOLUTE_SCALE_MAX;
|
|
1682
|
+
this.scaleMin = ABSOLUTE_SCALE_MIN;
|
|
3083
1683
|
this.forceUpdate = 0;
|
|
3084
1684
|
this.contextMenuElement = null;
|
|
3085
1685
|
this.store = new KritzelStore(this);
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
this.
|
|
3089
|
-
|
|
3090
|
-
this.store.clearSelection();
|
|
3091
|
-
}
|
|
3092
|
-
this.store.state.skipContextMenu = false;
|
|
3093
|
-
this.activeToolChange.emit(activeTool);
|
|
3094
|
-
index$1.KritzelKeyboardHelper.forceHideKeyboard();
|
|
3095
|
-
});
|
|
3096
|
-
this.store.onStateChange('isFocused', (isFocused) => {
|
|
3097
|
-
if (!isFocused) {
|
|
3098
|
-
this.store.resetActiveText();
|
|
3099
|
-
}
|
|
3100
|
-
});
|
|
1686
|
+
}
|
|
1687
|
+
componentWillLoad() {
|
|
1688
|
+
this.validateScaleMax(this.scaleMax);
|
|
1689
|
+
this.validateScaleMin(this.scaleMin);
|
|
3101
1690
|
}
|
|
3102
1691
|
componentDidLoad() {
|
|
1692
|
+
this.contextMenuHandler = new KritzelContextMenuHandler(this.store, this.globalContextMenuItems, this.objectContextMenuItems);
|
|
1693
|
+
this.keyHandler = new KritzelKeyHandler(this.store);
|
|
3103
1694
|
this.viewport = new KritzelViewport(this.store, this.host);
|
|
1695
|
+
this._registerStateChangeListeners();
|
|
3104
1696
|
if (this.store.state.isReady === false) {
|
|
3105
1697
|
this.store.state.isReady = true;
|
|
3106
1698
|
this.isEngineReady.emit();
|
|
@@ -3124,7 +1716,7 @@ const KritzelEngine = class {
|
|
|
3124
1716
|
return;
|
|
3125
1717
|
}
|
|
3126
1718
|
index$1.KritzelEventHelper.onLongTouchPress(ev, (event) => {
|
|
3127
|
-
if (!(this.store.state.activeTool instanceof KritzelSelectionTool)) {
|
|
1719
|
+
if (!(this.store.state.activeTool instanceof index$1.KritzelSelectionTool)) {
|
|
3128
1720
|
return;
|
|
3129
1721
|
}
|
|
3130
1722
|
this.contextMenuHandler.handleContextMenu(event);
|
|
@@ -3190,10 +1782,6 @@ const KritzelEngine = class {
|
|
|
3190
1782
|
const isInKritzelEngine = path.includes(kritzelEngineElement || this.host);
|
|
3191
1783
|
this.store.setState('isFocused', isInside && isInKritzelEngine);
|
|
3192
1784
|
}
|
|
3193
|
-
handleContextMenuAction(event) {
|
|
3194
|
-
event.detail.action();
|
|
3195
|
-
this.hideContextMenu();
|
|
3196
|
-
}
|
|
3197
1785
|
async registerTool(toolName, toolClass, toolConfig) {
|
|
3198
1786
|
if (typeof toolClass !== 'function' || !(toolClass.prototype instanceof index$1.KritzelBaseTool)) {
|
|
3199
1787
|
console.error(`Failed to register tool "${toolName}": Tool class must be a constructor function`);
|
|
@@ -3281,7 +1869,7 @@ const KritzelEngine = class {
|
|
|
3281
1869
|
}
|
|
3282
1870
|
async removeObject(object) {
|
|
3283
1871
|
this.store.deselectAllObjects();
|
|
3284
|
-
const command = new RemoveObjectCommand(this.store, this, object);
|
|
1872
|
+
const command = new index$1.RemoveObjectCommand(this.store, this, object);
|
|
3285
1873
|
this.store.history.executeCommand(command);
|
|
3286
1874
|
return object;
|
|
3287
1875
|
}
|
|
@@ -3312,21 +1900,42 @@ const KritzelEngine = class {
|
|
|
3312
1900
|
this.store.history.executeCommand(command);
|
|
3313
1901
|
return object;
|
|
3314
1902
|
}
|
|
1903
|
+
async getCopiedObjects() {
|
|
1904
|
+
var _a;
|
|
1905
|
+
return ((_a = this.store.state.copiedObjects) === null || _a === void 0 ? void 0 : _a.objects) || [];
|
|
1906
|
+
}
|
|
1907
|
+
_registerStateChangeListeners() {
|
|
1908
|
+
this.store.onStateChange('activeTool', this._handleActiveToolChange.bind(this));
|
|
1909
|
+
this.store.onStateChange('isFocused', this._handleIsFocusedChange.bind(this));
|
|
1910
|
+
}
|
|
1911
|
+
_handleActiveToolChange(activeTool) {
|
|
1912
|
+
if (!(activeTool instanceof index$1.KritzelSelectionTool)) {
|
|
1913
|
+
this.store.clearSelection();
|
|
1914
|
+
}
|
|
1915
|
+
this.store.state.skipContextMenu = false;
|
|
1916
|
+
this.activeToolChange.emit(activeTool);
|
|
1917
|
+
index$1.KritzelKeyboardHelper.forceHideKeyboard();
|
|
1918
|
+
}
|
|
1919
|
+
_handleIsFocusedChange(isFocused) {
|
|
1920
|
+
if (!isFocused) {
|
|
1921
|
+
this.store.resetActiveText();
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
3315
1924
|
render() {
|
|
3316
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
1925
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
3317
1926
|
const computedStyle = window.getComputedStyle(this.host);
|
|
3318
1927
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
3319
1928
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
3320
1929
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
3321
|
-
return (index.h(index.Host, { key: '
|
|
3322
|
-
_a.translateX), index.h("div", { key: '
|
|
3323
|
-
_b.translateY), index.h("div", { key: '
|
|
3324
|
-
_c.viewportWidth), index.h("div", { key: '
|
|
3325
|
-
_d.viewportHeight), index.h("div", { key: '
|
|
3326
|
-
_e.scale), index.h("div", { key: '
|
|
3327
|
-
_g.name), index.h("div", { key: '
|
|
3328
|
-
_m.cursorX), index.h("div", { key: '
|
|
3329
|
-
_o.cursorY)), index.h("div", { key: '
|
|
1930
|
+
return (index.h(index.Host, { key: 'd484b59ebdea9e7b9e8e086c39e7b3a339fb034d' }, index.h("div", { key: 'ea68c0a3c0020110b5aca6f3a7bdfab223b64744', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: '4a7c60073190f2123dbb6bda4e206a1b488db7ac' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
1931
|
+
_a.translateX), index.h("div", { key: 'c4fe558accb441fb06ff048f41b07b520ffde505' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
1932
|
+
_b.translateY), index.h("div", { key: '00d5fd0b0ec3c79f9ab1dc9a1032fa2f70c7c246' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
1933
|
+
_c.viewportWidth), index.h("div", { key: '87c8f03bfcc6de031e3d9d74576a6028bfc155bc' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
1934
|
+
_d.viewportHeight), index.h("div", { key: 'f4e82ddee133818b6ad60b5b6c5e9e721fce4968' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '4f9018ce1184b676248614d4edfdeffd49ac7ce2' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
1935
|
+
_e.scale), index.h("div", { key: 'cc5d72952bc4b80a42d26ca1b1e56bcab96ab76c' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
1936
|
+
_g.name), index.h("div", { key: '387071b0ea3f2064d1ea0e0495aa92de8072a900' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: 'a386b4fb631860b94f710cb601b1809283ab9664' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: 'a67ad19caa6a6cafa8b19dace26c25d60347090a' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '9fe3152ba0a3e936b6c6551673de3a67bd5de0d1' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: '8103da258c7bdede340c6c64188a2f9657af16c3' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '10b315366f6cf8eb2f27a20083094c9e483c2fe3' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: 'b65926aca01fe6b41f70e8d7484674f568e9945a' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: '5e95a4268ab30bf06918e83aa5f7e96b5ee1dbe2' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '3922b7fcb2b74ec28f515db8254f05b454ef6b12' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: '13c162ec56f0990948bac4569c28a6076582c7ea' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: 'f909cbc959961e47dbff28e5c620175dc04f6873' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: '505122e286976b8fa9e9fac5b131bcecb359eaae' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
1937
|
+
_m.cursorX), index.h("div", { key: '116217379cf67a0a268e97912ec44d52a98c434b' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
1938
|
+
_o.cursorY)), index.h("div", { key: 'b0bcbb90404d0cbc1281b932bd13e67df612d58d', class: "origin", style: {
|
|
3330
1939
|
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})`,
|
|
3331
1940
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
3332
1941
|
_t.map(object => {
|
|
@@ -3423,7 +2032,7 @@ const KritzelEngine = class {
|
|
|
3423
2032
|
fill: 'transparent',
|
|
3424
2033
|
cursor: 'grab',
|
|
3425
2034
|
}, 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)))))));
|
|
3426
|
-
}), index.h("svg", { key: '
|
|
2035
|
+
}), index.h("svg", { key: '4fd9e58c617eaf428edbdc3491d3f4fabe3ce564', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
3427
2036
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
3428
2037
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
3429
2038
|
left: '0',
|
|
@@ -3433,14 +2042,24 @@ const KritzelEngine = class {
|
|
|
3433
2042
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
3434
2043
|
transformOrigin: 'top left',
|
|
3435
2044
|
overflow: 'visible',
|
|
3436
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '
|
|
2045
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: 'ac88c3b66d642bbe42a0ac5345b4f4d6cddef5a3', 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: '75d7dfe1ef3ab64ae960c69a471224095a812cb8', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, objects: ((_2 = this.store.state.selectionGroup) === null || _2 === void 0 ? void 0 : _2.objects) || [], style: {
|
|
3437
2046
|
position: 'fixed',
|
|
3438
2047
|
left: `${this.store.state.contextMenuX}px`,
|
|
3439
2048
|
top: `${this.store.state.contextMenuY}px`,
|
|
3440
2049
|
zIndex: '10000',
|
|
3441
|
-
}, onActionSelected: event =>
|
|
2050
|
+
}, onActionSelected: event => {
|
|
2051
|
+
event.detail.action({
|
|
2052
|
+
x: (-this.store.state.translateX + this.store.state.contextMenuX) / this.store.state.scale,
|
|
2053
|
+
y: (-this.store.state.translateY + this.store.state.contextMenuY) / this.store.state.scale,
|
|
2054
|
+
}, this.store.state.selectionGroup.objects);
|
|
2055
|
+
this.hideContextMenu();
|
|
2056
|
+
} })), ((_3 = this.store.state) === null || _3 === void 0 ? void 0 : _3.activeTool) instanceof index$1.KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: 'a056ea6d5c4271f6af82d259d6d8126fef07c7bd', store: this.store })));
|
|
3442
2057
|
}
|
|
3443
2058
|
get host() { return index.getElement(this); }
|
|
2059
|
+
static get watchers() { return {
|
|
2060
|
+
"scaleMax": ["validateScaleMax"],
|
|
2061
|
+
"scaleMin": ["validateScaleMin"]
|
|
2062
|
+
}; }
|
|
3444
2063
|
};
|
|
3445
2064
|
KritzelEngine.style = kritzelEngineCss;
|
|
3446
2065
|
|