@edugis-org/webmapx 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist-lib/alert-C_G5X6J8.js +311 -0
  2. package/dist-lib/button-BlZd3WPH.js +744 -0
  3. package/dist-lib/checkbox-DB4oPyyw.js +287 -0
  4. package/dist-lib/chunk.36O46B5H-km1dakSW.js +77 -0
  5. package/dist-lib/chunk.3RPBFEDE-Cxq6VVR6.js +138 -0
  6. package/dist-lib/chunk.3Y6SB6QS-DUJ8Ickw.js +18 -0
  7. package/dist-lib/chunk.5JY5FUCG-CYkzbQXS.js +1071 -0
  8. package/dist-lib/chunk.6CTB5ZDJ-DjZrBd6Y.js +99 -0
  9. package/dist-lib/chunk.AJ3ENQ5C-DXVGX5Dn.js +177 -0
  10. package/dist-lib/chunk.LD4M4QGE-CiCfhE8r.js +8 -0
  11. package/dist-lib/chunk.NYIIDP5N-B4UCI-rQ.js +34 -0
  12. package/dist-lib/chunk.RWUUFNUL-DFztA4uV.js +43 -0
  13. package/dist-lib/chunk.SI4ACBFK-CLb9VfMG.js +61 -0
  14. package/dist-lib/chunk.YHLNUJ7P-ByKy0MKm.js +251 -0
  15. package/dist-lib/{decorate-DnZTfaod.js → decorate-CKr8yG1g.js} +1 -1
  16. package/dist-lib/divider-BOFbR_Ny.js +41 -0
  17. package/dist-lib/icon-CBNpO1lq.js +9 -0
  18. package/dist-lib/icon-button-B5rXu3Gg.js +410 -0
  19. package/dist-lib/input-B212BH6L.js +575 -0
  20. package/dist-lib/option-BQN9Zz_8.js +1108 -0
  21. package/dist-lib/spinner-DdcBaa3z.js +6 -0
  22. package/dist-lib/{toast-BsoXOdeA.js → toast-Bq2PmEpm.js} +1 -1
  23. package/dist-lib/tooltip-CBGOiZwJ.js +197 -0
  24. package/dist-lib/{webmapx-3d-tool-CLppA7mK.js → webmapx-3d-tool-CKoLGMpk.js} +2 -2
  25. package/dist-lib/{webmapx-base-tool-DfRa7TlD.js → webmapx-base-tool-Bc9Wz0yA.js} +1 -1
  26. package/dist-lib/{webmapx-config-edit-tool-BztWspia.js → webmapx-config-edit-tool-7265_DNz.js} +7 -7
  27. package/dist-lib/{webmapx-coordinates-tool-DnTSkrRG.js → webmapx-coordinates-tool-C964bdEG.js} +3 -3
  28. package/dist-lib/{webmapx-core-bundle-CH-5vYXU.js → webmapx-core-bundle-Q6mWOib1.js} +1579 -671
  29. package/dist-lib/webmapx-draw-tool-6QRr5Gip.js +4315 -0
  30. package/dist-lib/{webmapx-geolocation-tool-DIMh2kIr.js → webmapx-geolocation-tool-qxN5aaVB.js} +6 -7
  31. package/dist-lib/{webmapx-import-layer-tool-DMiC1TpU.js → webmapx-import-layer-tool-tJ374qHR.js} +2 -2
  32. package/dist-lib/{webmapx-info-tool-D-XbAU9J.js → webmapx-info-tool-C3txgv3v.js} +4 -4
  33. package/dist-lib/{webmapx-language-osmvector-BAw9TR-M.js → webmapx-language-osmvector-jQzTOPU1.js} +3 -4
  34. package/dist-lib/{webmapx-measure-tool-CXlg11s8.js → webmapx-measure-tool-Cxxrzgdf.js} +4 -4
  35. package/dist-lib/{webmapx-modal-tool-Cs7LRrgW.js → webmapx-modal-tool-DQVHNXqX.js} +2 -2
  36. package/dist-lib/{webmapx-plugin-tool-qe2yTrWB.js → webmapx-plugin-tool-BNZ61x6s.js} +1 -1
  37. package/dist-lib/{webmapx-print-tool-DrK9sLC7.js → webmapx-print-tool-BDOTbS6u.js} +7 -8
  38. package/dist-lib/{webmapx-search-tool-H7NisgWH.js → webmapx-search-tool-CHlsE2Wx.js} +2 -2
  39. package/dist-lib/webmapx-settings-B0AT9Vjn.js +482 -0
  40. package/dist-lib/{webmapx-truearea-tool-CSU9mE1D.js → webmapx-truearea-tool-dxSgcbOj.js} +2 -2
  41. package/dist-lib/{webmapx-view-mode-tool-D1QyQfq8.js → webmapx-view-mode-tool-DVSMakdh.js} +2 -2
  42. package/dist-lib/webmapx.js +312 -311
  43. package/package.json +1 -1
  44. package/dist-lib/webmapx-draw-tool-DxQgUF1Q.js +0 -2117
  45. package/dist-lib/webmapx-settings-EHSm-AGU.js +0 -167
@@ -0,0 +1,4315 @@
1
+ import { a as e, i as t, n, r, t as i } from "./chunk.YHLNUJ7P-ByKy0MKm.js";
2
+ import { t as a } from "./decorate-CKr8yG1g.js";
3
+ import { a as o, i as s, o as c, s as l, t as u } from "./chunk.AJ3ENQ5C-DXVGX5Dn.js";
4
+ import { t as d } from "./chunk.NYIIDP5N-B4UCI-rQ.js";
5
+ import { t as f } from "./chunk.6CTB5ZDJ-DjZrBd6Y.js";
6
+ import "./icon-CBNpO1lq.js";
7
+ import "./chunk.36O46B5H-km1dakSW.js";
8
+ import { i as p, n as ee, r as te, t as ne } from "./chunk.3RPBFEDE-Cxq6VVR6.js";
9
+ import { t as re } from "./button-BlZd3WPH.js";
10
+ import { n as ie, t as ae } from "./input-B212BH6L.js";
11
+ import { t as oe } from "./chunk.SI4ACBFK-CLb9VfMG.js";
12
+ import { t as m } from "./tooltip-CBGOiZwJ.js";
13
+ import { n as se, t as ce } from "./icon-button-B5rXu3Gg.js";
14
+ import { a as le, i as ue, t as de } from "./zip.js-DVhmtjxZ.js";
15
+ import { t as fe } from "./chunk.5JY5FUCG-CYkzbQXS.js";
16
+ import { t as pe } from "./webmapx-modal-tool-DQVHNXqX.js";
17
+ import "./option-BQN9Zz_8.js";
18
+ import { r as me } from "./map-layer-registry-2cmkiRDK.js";
19
+ import { LitElement as he, css as h, html as g } from "lit";
20
+ import { customElement as ge, eventOptions as _e, property as _, query as v, state as y } from "lit/decorators.js";
21
+ import { classMap as b } from "lit/directives/class-map.js";
22
+ import { ifDefined as x } from "lit/directives/if-defined.js";
23
+ import { styleMap as S } from "lit/directives/style-map.js";
24
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.B63YXDJO.js
25
+ var ve = h`
26
+ :host {
27
+ display: block;
28
+ }
29
+
30
+ .form-control {
31
+ position: relative;
32
+ border: none;
33
+ padding: 0;
34
+ margin: 0;
35
+ }
36
+
37
+ .form-control__label {
38
+ padding: 0;
39
+ }
40
+
41
+ .radio-group--required .radio-group__label::after {
42
+ content: var(--sl-input-required-content);
43
+ margin-inline-start: var(--sl-input-required-content-offset);
44
+ }
45
+
46
+ .visually-hidden {
47
+ position: absolute;
48
+ width: 1px;
49
+ height: 1px;
50
+ padding: 0;
51
+ margin: -1px;
52
+ overflow: hidden;
53
+ clip: rect(0, 0, 0, 0);
54
+ white-space: nowrap;
55
+ border: 0;
56
+ }
57
+ `, ye = h`
58
+ :host {
59
+ display: inline-block;
60
+ }
61
+
62
+ .button-group {
63
+ display: flex;
64
+ flex-wrap: nowrap;
65
+ }
66
+ `, C = class extends n {
67
+ constructor() {
68
+ super(...arguments), this.disableRole = !1, this.label = "";
69
+ }
70
+ handleFocus(e) {
71
+ w(e.target)?.toggleAttribute("data-sl-button-group__button--focus", !0);
72
+ }
73
+ handleBlur(e) {
74
+ w(e.target)?.toggleAttribute("data-sl-button-group__button--focus", !1);
75
+ }
76
+ handleMouseOver(e) {
77
+ w(e.target)?.toggleAttribute("data-sl-button-group__button--hover", !0);
78
+ }
79
+ handleMouseOut(e) {
80
+ w(e.target)?.toggleAttribute("data-sl-button-group__button--hover", !1);
81
+ }
82
+ handleSlotChange() {
83
+ let e = [...this.defaultSlot.assignedElements({ flatten: !0 })];
84
+ e.forEach((t) => {
85
+ let n = e.indexOf(t), r = w(t);
86
+ r && (r.toggleAttribute("data-sl-button-group__button", !0), r.toggleAttribute("data-sl-button-group__button--first", n === 0), r.toggleAttribute("data-sl-button-group__button--inner", n > 0 && n < e.length - 1), r.toggleAttribute("data-sl-button-group__button--last", n === e.length - 1), r.toggleAttribute("data-sl-button-group__button--radio", r.tagName.toLowerCase() === "sl-radio-button"));
87
+ });
88
+ }
89
+ render() {
90
+ return g`
91
+ <div
92
+ part="base"
93
+ class="button-group"
94
+ role="${this.disableRole ? "presentation" : "group"}"
95
+ aria-label=${this.label}
96
+ @focusout=${this.handleBlur}
97
+ @focusin=${this.handleFocus}
98
+ @mouseover=${this.handleMouseOver}
99
+ @mouseout=${this.handleMouseOut}
100
+ >
101
+ <slot @slotchange=${this.handleSlotChange}></slot>
102
+ </div>
103
+ `;
104
+ }
105
+ };
106
+ C.styles = [r, ye], e([v("slot")], C.prototype, "defaultSlot", 2), e([y()], C.prototype, "disableRole", 2), e([_()], C.prototype, "label", 2);
107
+ function w(e) {
108
+ let t = "sl-button, sl-radio-button";
109
+ return e.closest(t) ?? e.querySelector(t);
110
+ }
111
+ //#endregion
112
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.ZJNIZFRS.js
113
+ var T = class extends n {
114
+ constructor() {
115
+ super(...arguments), this.formControlController = new ne(this), this.hasSlotController = new d(this, "help-text", "label"), this.customValidityMessage = "", this.hasButtonGroup = !1, this.errorMessage = "", this.defaultValue = "", this.label = "", this.helpText = "", this.name = "option", this.value = "", this.size = "medium", this.form = "", this.required = !1;
116
+ }
117
+ get validity() {
118
+ let e = this.required && !this.value;
119
+ return this.customValidityMessage === "" ? e ? p : te : ee;
120
+ }
121
+ get validationMessage() {
122
+ let e = this.required && !this.value;
123
+ return this.customValidityMessage === "" ? e ? this.validationInput.validationMessage : "" : this.customValidityMessage;
124
+ }
125
+ connectedCallback() {
126
+ super.connectedCallback(), this.defaultValue = this.value;
127
+ }
128
+ firstUpdated() {
129
+ this.formControlController.updateValidity();
130
+ }
131
+ getAllRadios() {
132
+ return [...this.querySelectorAll("sl-radio, sl-radio-button")];
133
+ }
134
+ handleRadioClick(e) {
135
+ let t = e.target.closest("sl-radio, sl-radio-button"), n = this.getAllRadios(), r = this.value;
136
+ !t || t.disabled || (this.value = t.value, n.forEach((e) => e.checked = e === t), this.value !== r && (this.emit("sl-change"), this.emit("sl-input")));
137
+ }
138
+ handleKeyDown(e) {
139
+ if (![
140
+ "ArrowUp",
141
+ "ArrowDown",
142
+ "ArrowLeft",
143
+ "ArrowRight",
144
+ " "
145
+ ].includes(e.key)) return;
146
+ let t = this.getAllRadios().filter((e) => !e.disabled), n = t.find((e) => e.checked) ?? t[0], r = e.key === " " ? 0 : ["ArrowUp", "ArrowLeft"].includes(e.key) ? -1 : 1, i = this.value, a = t.indexOf(n) + r;
147
+ a < 0 && (a = t.length - 1), a > t.length - 1 && (a = 0), this.getAllRadios().forEach((e) => {
148
+ e.checked = !1, this.hasButtonGroup || e.setAttribute("tabindex", "-1");
149
+ }), this.value = t[a].value, t[a].checked = !0, this.hasButtonGroup ? t[a].shadowRoot.querySelector("button").focus() : (t[a].setAttribute("tabindex", "0"), t[a].focus()), this.value !== i && (this.emit("sl-change"), this.emit("sl-input")), e.preventDefault();
150
+ }
151
+ handleLabelClick() {
152
+ this.focus();
153
+ }
154
+ handleInvalid(e) {
155
+ this.formControlController.setValidity(!1), this.formControlController.emitInvalidEvent(e);
156
+ }
157
+ async syncRadioElements() {
158
+ let e = this.getAllRadios();
159
+ if (await Promise.all(e.map(async (e) => {
160
+ await e.updateComplete, e.checked = e.value === this.value, e.size = this.size;
161
+ })), this.hasButtonGroup = e.some((e) => e.tagName.toLowerCase() === "sl-radio-button"), e.length > 0 && !e.some((e) => e.checked)) if (this.hasButtonGroup) {
162
+ let t = e[0].shadowRoot?.querySelector("button");
163
+ t && t.setAttribute("tabindex", "0");
164
+ } else e[0].setAttribute("tabindex", "0");
165
+ if (this.hasButtonGroup) {
166
+ let e = this.shadowRoot?.querySelector("sl-button-group");
167
+ e && (e.disableRole = !0);
168
+ }
169
+ }
170
+ syncRadios() {
171
+ if (customElements.get("sl-radio") && customElements.get("sl-radio-button")) {
172
+ this.syncRadioElements();
173
+ return;
174
+ }
175
+ customElements.get("sl-radio") ? this.syncRadioElements() : customElements.whenDefined("sl-radio").then(() => this.syncRadios()), customElements.get("sl-radio-button") ? this.syncRadioElements() : customElements.whenDefined("sl-radio-button").then(() => this.syncRadios());
176
+ }
177
+ updateCheckedRadio() {
178
+ this.getAllRadios().forEach((e) => e.checked = e.value === this.value), this.formControlController.setValidity(this.validity.valid);
179
+ }
180
+ handleSizeChange() {
181
+ this.syncRadios();
182
+ }
183
+ handleValueChange() {
184
+ this.hasUpdated && this.updateCheckedRadio();
185
+ }
186
+ checkValidity() {
187
+ let e = this.required && !this.value, t = this.customValidityMessage !== "";
188
+ return e || t ? (this.formControlController.emitInvalidEvent(), !1) : !0;
189
+ }
190
+ getForm() {
191
+ return this.formControlController.getForm();
192
+ }
193
+ reportValidity() {
194
+ let e = this.validity.valid;
195
+ return this.errorMessage = this.customValidityMessage || e ? "" : this.validationInput.validationMessage, this.formControlController.setValidity(e), this.validationInput.hidden = !0, clearTimeout(this.validationTimeout), e || (this.validationInput.hidden = !1, this.validationInput.reportValidity(), this.validationTimeout = setTimeout(() => this.validationInput.hidden = !0, 1e4)), e;
196
+ }
197
+ setCustomValidity(e = "") {
198
+ this.customValidityMessage = e, this.errorMessage = e, this.validationInput.setCustomValidity(e), this.formControlController.updateValidity();
199
+ }
200
+ focus(e) {
201
+ let t = this.getAllRadios(), n = t.find((e) => e.checked), r = t.find((e) => !e.disabled), i = n || r;
202
+ i && i.focus(e);
203
+ }
204
+ render() {
205
+ let e = this.hasSlotController.test("label"), t = this.hasSlotController.test("help-text"), n = this.label ? !0 : !!e, r = this.helpText ? !0 : !!t, i = g`
206
+ <slot @slotchange=${this.syncRadios} @click=${this.handleRadioClick} @keydown=${this.handleKeyDown}></slot>
207
+ `;
208
+ return g`
209
+ <fieldset
210
+ part="form-control"
211
+ class=${b({
212
+ "form-control": !0,
213
+ "form-control--small": this.size === "small",
214
+ "form-control--medium": this.size === "medium",
215
+ "form-control--large": this.size === "large",
216
+ "form-control--radio-group": !0,
217
+ "form-control--has-label": n,
218
+ "form-control--has-help-text": r
219
+ })}
220
+ role="radiogroup"
221
+ aria-labelledby="label"
222
+ aria-describedby="help-text"
223
+ aria-errormessage="error-message"
224
+ >
225
+ <label
226
+ part="form-control-label"
227
+ id="label"
228
+ class="form-control__label"
229
+ aria-hidden=${n ? "false" : "true"}
230
+ @click=${this.handleLabelClick}
231
+ >
232
+ <slot name="label">${this.label}</slot>
233
+ </label>
234
+
235
+ <div part="form-control-input" class="form-control-input">
236
+ <div class="visually-hidden">
237
+ <div id="error-message" aria-live="assertive">${this.errorMessage}</div>
238
+ <label class="radio-group__validation">
239
+ <input
240
+ type="text"
241
+ class="radio-group__validation-input"
242
+ ?required=${this.required}
243
+ tabindex="-1"
244
+ hidden
245
+ @invalid=${this.handleInvalid}
246
+ />
247
+ </label>
248
+ </div>
249
+
250
+ ${this.hasButtonGroup ? g`
251
+ <sl-button-group part="button-group" exportparts="base:button-group__base" role="presentation">
252
+ ${i}
253
+ </sl-button-group>
254
+ ` : i}
255
+ </div>
256
+
257
+ <div
258
+ part="form-control-help-text"
259
+ id="help-text"
260
+ class="form-control__help-text"
261
+ aria-hidden=${r ? "false" : "true"}
262
+ >
263
+ <slot name="help-text">${this.helpText}</slot>
264
+ </div>
265
+ </fieldset>
266
+ `;
267
+ }
268
+ };
269
+ //#endregion
270
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.2PCBEMQZ.js
271
+ T.styles = [
272
+ r,
273
+ oe,
274
+ ve
275
+ ], T.dependencies = { "sl-button-group": C }, e([v("slot:not([name])")], T.prototype, "defaultSlot", 2), e([v(".radio-group__validation-input")], T.prototype, "validationInput", 2), e([y()], T.prototype, "hasButtonGroup", 2), e([y()], T.prototype, "errorMessage", 2), e([y()], T.prototype, "defaultValue", 2), e([_()], T.prototype, "label", 2), e([_({ attribute: "help-text" })], T.prototype, "helpText", 2), e([_()], T.prototype, "name", 2), e([_({ reflect: !0 })], T.prototype, "value", 2), e([_({ reflect: !0 })], T.prototype, "size", 2), e([_({ reflect: !0 })], T.prototype, "form", 2), e([_({
276
+ type: Boolean,
277
+ reflect: !0
278
+ })], T.prototype, "required", 2), e([t("size", { waitUntilFirstUpdate: !0 })], T.prototype, "handleSizeChange", 1), e([t("value")], T.prototype, "handleValueChange", 1), T.define("sl-radio-group");
279
+ //#endregion
280
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.FKMWLPHV.js
281
+ var be = h`
282
+ :host {
283
+ display: block;
284
+ }
285
+
286
+ :host(:focus-visible) {
287
+ outline: 0px;
288
+ }
289
+
290
+ .radio {
291
+ display: inline-flex;
292
+ align-items: top;
293
+ font-family: var(--sl-input-font-family);
294
+ font-size: var(--sl-input-font-size-medium);
295
+ font-weight: var(--sl-input-font-weight);
296
+ color: var(--sl-input-label-color);
297
+ vertical-align: middle;
298
+ cursor: pointer;
299
+ }
300
+
301
+ .radio--small {
302
+ --toggle-size: var(--sl-toggle-size-small);
303
+ font-size: var(--sl-input-font-size-small);
304
+ }
305
+
306
+ .radio--medium {
307
+ --toggle-size: var(--sl-toggle-size-medium);
308
+ font-size: var(--sl-input-font-size-medium);
309
+ }
310
+
311
+ .radio--large {
312
+ --toggle-size: var(--sl-toggle-size-large);
313
+ font-size: var(--sl-input-font-size-large);
314
+ }
315
+
316
+ .radio__checked-icon {
317
+ display: inline-flex;
318
+ width: var(--toggle-size);
319
+ height: var(--toggle-size);
320
+ }
321
+
322
+ .radio__control {
323
+ flex: 0 0 auto;
324
+ position: relative;
325
+ display: inline-flex;
326
+ align-items: center;
327
+ justify-content: center;
328
+ width: var(--toggle-size);
329
+ height: var(--toggle-size);
330
+ border: solid var(--sl-input-border-width) var(--sl-input-border-color);
331
+ border-radius: 50%;
332
+ background-color: var(--sl-input-background-color);
333
+ color: transparent;
334
+ transition:
335
+ var(--sl-transition-fast) border-color,
336
+ var(--sl-transition-fast) background-color,
337
+ var(--sl-transition-fast) color,
338
+ var(--sl-transition-fast) box-shadow;
339
+ }
340
+
341
+ .radio__input {
342
+ position: absolute;
343
+ opacity: 0;
344
+ padding: 0;
345
+ margin: 0;
346
+ pointer-events: none;
347
+ }
348
+
349
+ /* Hover */
350
+ .radio:not(.radio--checked):not(.radio--disabled) .radio__control:hover {
351
+ border-color: var(--sl-input-border-color-hover);
352
+ background-color: var(--sl-input-background-color-hover);
353
+ }
354
+
355
+ /* Checked */
356
+ .radio--checked .radio__control {
357
+ color: var(--sl-color-neutral-0);
358
+ border-color: var(--sl-color-primary-600);
359
+ background-color: var(--sl-color-primary-600);
360
+ }
361
+
362
+ /* Checked + hover */
363
+ .radio.radio--checked:not(.radio--disabled) .radio__control:hover {
364
+ border-color: var(--sl-color-primary-500);
365
+ background-color: var(--sl-color-primary-500);
366
+ }
367
+
368
+ /* Checked + focus */
369
+ :host(:focus-visible) .radio__control {
370
+ outline: var(--sl-focus-ring);
371
+ outline-offset: var(--sl-focus-ring-offset);
372
+ }
373
+
374
+ /* Disabled */
375
+ .radio--disabled {
376
+ opacity: 0.5;
377
+ cursor: not-allowed;
378
+ }
379
+
380
+ /* When the control isn't checked, hide the circle for Windows High Contrast mode a11y */
381
+ .radio:not(.radio--checked) svg circle {
382
+ opacity: 0;
383
+ }
384
+
385
+ .radio__label {
386
+ display: inline-block;
387
+ color: var(--sl-input-label-color);
388
+ line-height: var(--toggle-size);
389
+ margin-inline-start: 0.5em;
390
+ user-select: none;
391
+ -webkit-user-select: none;
392
+ }
393
+ `, E = class extends n {
394
+ constructor() {
395
+ super(), this.checked = !1, this.hasFocus = !1, this.size = "medium", this.disabled = !1, this.handleBlur = () => {
396
+ this.hasFocus = !1, this.emit("sl-blur");
397
+ }, this.handleClick = () => {
398
+ this.disabled || (this.checked = !0);
399
+ }, this.handleFocus = () => {
400
+ this.hasFocus = !0, this.emit("sl-focus");
401
+ }, this.addEventListener("blur", this.handleBlur), this.addEventListener("click", this.handleClick), this.addEventListener("focus", this.handleFocus);
402
+ }
403
+ connectedCallback() {
404
+ super.connectedCallback(), this.setInitialAttributes();
405
+ }
406
+ setInitialAttributes() {
407
+ this.setAttribute("role", "radio"), this.setAttribute("tabindex", "-1"), this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
408
+ }
409
+ handleCheckedChange() {
410
+ this.setAttribute("aria-checked", this.checked ? "true" : "false"), this.setAttribute("tabindex", this.checked ? "0" : "-1");
411
+ }
412
+ handleDisabledChange() {
413
+ this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
414
+ }
415
+ render() {
416
+ return g`
417
+ <span
418
+ part="base"
419
+ class=${b({
420
+ radio: !0,
421
+ "radio--checked": this.checked,
422
+ "radio--disabled": this.disabled,
423
+ "radio--focused": this.hasFocus,
424
+ "radio--small": this.size === "small",
425
+ "radio--medium": this.size === "medium",
426
+ "radio--large": this.size === "large"
427
+ })}
428
+ >
429
+ <span part="${`control${this.checked ? " control--checked" : ""}`}" class="radio__control">
430
+ ${this.checked ? g` <sl-icon part="checked-icon" class="radio__checked-icon" library="system" name="radio"></sl-icon> ` : ""}
431
+ </span>
432
+
433
+ <slot part="label" class="radio__label"></slot>
434
+ </span>
435
+ `;
436
+ }
437
+ };
438
+ //#endregion
439
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.MSKEYBDI.js
440
+ E.styles = [r, be], E.dependencies = { "sl-icon": i }, e([y()], E.prototype, "checked", 2), e([y()], E.prototype, "hasFocus", 2), e([_()], E.prototype, "value", 2), e([_({ reflect: !0 })], E.prototype, "size", 2), e([_({
441
+ type: Boolean,
442
+ reflect: !0
443
+ })], E.prototype, "disabled", 2), e([t("checked")], E.prototype, "handleCheckedChange", 1), e([t("disabled", { waitUntilFirstUpdate: !0 })], E.prototype, "handleDisabledChange", 1), E.define("sl-radio");
444
+ //#endregion
445
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.YKKSQ2FG.js
446
+ var xe = h`
447
+ :host(:not(:focus-within)) {
448
+ position: absolute !important;
449
+ width: 1px !important;
450
+ height: 1px !important;
451
+ clip: rect(0 0 0 0) !important;
452
+ clip-path: inset(50%) !important;
453
+ border: none !important;
454
+ overflow: hidden !important;
455
+ white-space: nowrap !important;
456
+ padding: 0 !important;
457
+ }
458
+ `, Se = class extends n {
459
+ render() {
460
+ return g` <slot></slot> `;
461
+ }
462
+ };
463
+ Se.styles = [r, xe];
464
+ //#endregion
465
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.ESELY2US.js
466
+ function D(e, t) {
467
+ function n(n) {
468
+ let r = e.getBoundingClientRect(), i = e.ownerDocument.defaultView, a = r.left + i.scrollX, o = r.top + i.scrollY, s = n.pageX - a, c = n.pageY - o;
469
+ t?.onMove && t.onMove(s, c);
470
+ }
471
+ function r() {
472
+ document.removeEventListener("pointermove", n), document.removeEventListener("pointerup", r), t?.onStop && t.onStop();
473
+ }
474
+ document.addEventListener("pointermove", n, { passive: !0 }), document.addEventListener("pointerup", r), t?.initialEvent instanceof PointerEvent && n(t.initialEvent);
475
+ }
476
+ //#endregion
477
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.LXP7GVU3.js
478
+ var Ce = h`
479
+ :host {
480
+ display: inline-block;
481
+ }
482
+
483
+ .dropdown::part(popup) {
484
+ z-index: var(--sl-z-index-dropdown);
485
+ }
486
+
487
+ .dropdown[data-current-placement^='top']::part(popup) {
488
+ transform-origin: bottom;
489
+ }
490
+
491
+ .dropdown[data-current-placement^='bottom']::part(popup) {
492
+ transform-origin: top;
493
+ }
494
+
495
+ .dropdown[data-current-placement^='left']::part(popup) {
496
+ transform-origin: right;
497
+ }
498
+
499
+ .dropdown[data-current-placement^='right']::part(popup) {
500
+ transform-origin: left;
501
+ }
502
+
503
+ .dropdown__trigger {
504
+ display: block;
505
+ }
506
+
507
+ .dropdown__panel {
508
+ font-family: var(--sl-font-sans);
509
+ font-size: var(--sl-font-size-medium);
510
+ font-weight: var(--sl-font-weight-normal);
511
+ box-shadow: var(--sl-shadow-large);
512
+ border-radius: var(--sl-border-radius-medium);
513
+ pointer-events: none;
514
+ }
515
+
516
+ .dropdown--open .dropdown__panel {
517
+ display: block;
518
+ pointer-events: all;
519
+ }
520
+
521
+ /* When users slot a menu, make sure it conforms to the popup's auto-size */
522
+ ::slotted(sl-menu) {
523
+ max-width: var(--auto-size-available-width) !important;
524
+ max-height: var(--auto-size-available-height) !important;
525
+ }
526
+ `, O = class extends n {
527
+ constructor() {
528
+ super(...arguments), this.localize = new f(this), this.open = !1, this.placement = "bottom-start", this.disabled = !1, this.stayOpenOnSelect = !1, this.distance = 0, this.skidding = 0, this.hoist = !1, this.sync = void 0, this.handleKeyDown = (e) => {
529
+ this.open && e.key === "Escape" && (e.stopPropagation(), this.hide(), this.focusOnTrigger());
530
+ }, this.handleDocumentKeyDown = (e) => {
531
+ if (e.key === "Escape" && this.open && !this.closeWatcher) {
532
+ e.stopPropagation(), this.focusOnTrigger(), this.hide();
533
+ return;
534
+ }
535
+ if (e.key === "Tab") {
536
+ if (this.open && document.activeElement?.tagName.toLowerCase() === "sl-menu-item") {
537
+ e.preventDefault(), this.hide(), this.focusOnTrigger();
538
+ return;
539
+ }
540
+ let t = (e, n) => {
541
+ if (!e) return null;
542
+ let r = e.closest(n);
543
+ if (r) return r;
544
+ let i = e.getRootNode();
545
+ return i instanceof ShadowRoot ? t(i.host, n) : null;
546
+ };
547
+ setTimeout(() => {
548
+ let e = this.containingElement?.getRootNode() instanceof ShadowRoot ? ce() : document.activeElement;
549
+ (!this.containingElement || t(e, this.containingElement.tagName.toLowerCase()) !== this.containingElement) && this.hide();
550
+ });
551
+ }
552
+ }, this.handleDocumentMouseDown = (e) => {
553
+ let t = e.composedPath();
554
+ this.containingElement && !t.includes(this.containingElement) && this.hide();
555
+ }, this.handlePanelSelect = (e) => {
556
+ let t = e.target;
557
+ !this.stayOpenOnSelect && t.tagName.toLowerCase() === "sl-menu" && (this.hide(), this.focusOnTrigger());
558
+ };
559
+ }
560
+ connectedCallback() {
561
+ super.connectedCallback(), this.containingElement ||= this;
562
+ }
563
+ firstUpdated() {
564
+ this.panel.hidden = !this.open, this.open && (this.addOpenListeners(), this.popup.active = !0);
565
+ }
566
+ disconnectedCallback() {
567
+ super.disconnectedCallback(), this.removeOpenListeners(), this.hide();
568
+ }
569
+ focusOnTrigger() {
570
+ let e = this.trigger.assignedElements({ flatten: !0 })[0];
571
+ typeof e?.focus == "function" && e.focus();
572
+ }
573
+ getMenu() {
574
+ return this.panel.assignedElements({ flatten: !0 }).find((e) => e.tagName.toLowerCase() === "sl-menu");
575
+ }
576
+ handleTriggerClick() {
577
+ this.open ? this.hide() : (this.show(), this.focusOnTrigger());
578
+ }
579
+ async handleTriggerKeyDown(e) {
580
+ if ([" ", "Enter"].includes(e.key)) {
581
+ e.preventDefault(), this.handleTriggerClick();
582
+ return;
583
+ }
584
+ let t = this.getMenu();
585
+ if (t) {
586
+ let n = t.getAllItems(), r = n[0], i = n[n.length - 1];
587
+ [
588
+ "ArrowDown",
589
+ "ArrowUp",
590
+ "Home",
591
+ "End"
592
+ ].includes(e.key) && (e.preventDefault(), this.open || (this.show(), await this.updateComplete), n.length > 0 && this.updateComplete.then(() => {
593
+ (e.key === "ArrowDown" || e.key === "Home") && (t.setCurrentItem(r), r.focus()), (e.key === "ArrowUp" || e.key === "End") && (t.setCurrentItem(i), i.focus());
594
+ }));
595
+ }
596
+ }
597
+ handleTriggerKeyUp(e) {
598
+ e.key === " " && e.preventDefault();
599
+ }
600
+ handleTriggerSlotChange() {
601
+ this.updateAccessibleTrigger();
602
+ }
603
+ updateAccessibleTrigger() {
604
+ let e = this.trigger.assignedElements({ flatten: !0 }).find((e) => se(e).start), t;
605
+ if (e) {
606
+ switch (e.tagName.toLowerCase()) {
607
+ case "sl-button":
608
+ case "sl-icon-button":
609
+ t = e.button;
610
+ break;
611
+ default: t = e;
612
+ }
613
+ t.setAttribute("aria-haspopup", "true"), t.setAttribute("aria-expanded", this.open ? "true" : "false");
614
+ }
615
+ }
616
+ async show() {
617
+ if (!this.open) return this.open = !0, o(this, "sl-after-show");
618
+ }
619
+ async hide() {
620
+ if (this.open) return this.open = !1, o(this, "sl-after-hide");
621
+ }
622
+ reposition() {
623
+ this.popup.reposition();
624
+ }
625
+ addOpenListeners() {
626
+ var e;
627
+ this.panel.addEventListener("sl-select", this.handlePanelSelect), "CloseWatcher" in window ? ((e = this.closeWatcher) == null || e.destroy(), this.closeWatcher = new CloseWatcher(), this.closeWatcher.onclose = () => {
628
+ this.hide(), this.focusOnTrigger();
629
+ }) : this.panel.addEventListener("keydown", this.handleKeyDown), document.addEventListener("keydown", this.handleDocumentKeyDown), document.addEventListener("mousedown", this.handleDocumentMouseDown);
630
+ }
631
+ removeOpenListeners() {
632
+ var e;
633
+ this.panel && (this.panel.removeEventListener("sl-select", this.handlePanelSelect), this.panel.removeEventListener("keydown", this.handleKeyDown)), document.removeEventListener("keydown", this.handleDocumentKeyDown), document.removeEventListener("mousedown", this.handleDocumentMouseDown), (e = this.closeWatcher) == null || e.destroy();
634
+ }
635
+ async handleOpenChange() {
636
+ if (this.disabled) {
637
+ this.open = !1;
638
+ return;
639
+ }
640
+ if (this.updateAccessibleTrigger(), this.open) {
641
+ this.emit("sl-show"), this.addOpenListeners(), await s(this), this.panel.hidden = !1, this.popup.active = !0;
642
+ let { keyframes: e, options: t } = c(this, "dropdown.show", { dir: this.localize.dir() });
643
+ await u(this.popup.popup, e, t), this.emit("sl-after-show");
644
+ } else {
645
+ this.emit("sl-hide"), this.removeOpenListeners(), await s(this);
646
+ let { keyframes: e, options: t } = c(this, "dropdown.hide", { dir: this.localize.dir() });
647
+ await u(this.popup.popup, e, t), this.panel.hidden = !0, this.popup.active = !1, this.emit("sl-after-hide");
648
+ }
649
+ }
650
+ render() {
651
+ return g`
652
+ <sl-popup
653
+ part="base"
654
+ exportparts="popup:base__popup"
655
+ id="dropdown"
656
+ placement=${this.placement}
657
+ distance=${this.distance}
658
+ skidding=${this.skidding}
659
+ strategy=${this.hoist ? "fixed" : "absolute"}
660
+ flip
661
+ shift
662
+ auto-size="vertical"
663
+ auto-size-padding="10"
664
+ sync=${x(this.sync ? this.sync : void 0)}
665
+ class=${b({
666
+ dropdown: !0,
667
+ "dropdown--open": this.open
668
+ })}
669
+ >
670
+ <slot
671
+ name="trigger"
672
+ slot="anchor"
673
+ part="trigger"
674
+ class="dropdown__trigger"
675
+ @click=${this.handleTriggerClick}
676
+ @keydown=${this.handleTriggerKeyDown}
677
+ @keyup=${this.handleTriggerKeyUp}
678
+ @slotchange=${this.handleTriggerSlotChange}
679
+ ></slot>
680
+
681
+ <div aria-hidden=${this.open ? "false" : "true"} aria-labelledby="dropdown">
682
+ <slot part="panel" class="dropdown__panel"></slot>
683
+ </div>
684
+ </sl-popup>
685
+ `;
686
+ }
687
+ };
688
+ O.styles = [r, Ce], O.dependencies = { "sl-popup": fe }, e([v(".dropdown")], O.prototype, "popup", 2), e([v(".dropdown__trigger")], O.prototype, "trigger", 2), e([v(".dropdown__panel")], O.prototype, "panel", 2), e([_({
689
+ type: Boolean,
690
+ reflect: !0
691
+ })], O.prototype, "open", 2), e([_({ reflect: !0 })], O.prototype, "placement", 2), e([_({
692
+ type: Boolean,
693
+ reflect: !0
694
+ })], O.prototype, "disabled", 2), e([_({
695
+ attribute: "stay-open-on-select",
696
+ type: Boolean,
697
+ reflect: !0
698
+ })], O.prototype, "stayOpenOnSelect", 2), e([_({ attribute: !1 })], O.prototype, "containingElement", 2), e([_({ type: Number })], O.prototype, "distance", 2), e([_({ type: Number })], O.prototype, "skidding", 2), e([_({ type: Boolean })], O.prototype, "hoist", 2), e([_({ reflect: !0 })], O.prototype, "sync", 2), e([t("open", { waitUntilFirstUpdate: !0 })], O.prototype, "handleOpenChange", 1), l("dropdown.show", {
699
+ keyframes: [{
700
+ opacity: 0,
701
+ scale: .9
702
+ }, {
703
+ opacity: 1,
704
+ scale: 1
705
+ }],
706
+ options: {
707
+ duration: 100,
708
+ easing: "ease"
709
+ }
710
+ }), l("dropdown.hide", {
711
+ keyframes: [{
712
+ opacity: 1,
713
+ scale: 1
714
+ }, {
715
+ opacity: 0,
716
+ scale: .9
717
+ }],
718
+ options: {
719
+ duration: 100,
720
+ easing: "ease"
721
+ }
722
+ });
723
+ //#endregion
724
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.O6CEROC7.js
725
+ var we = h`
726
+ :host {
727
+ --grid-width: 280px;
728
+ --grid-height: 200px;
729
+ --grid-handle-size: 16px;
730
+ --slider-height: 15px;
731
+ --slider-handle-size: 17px;
732
+ --swatch-size: 25px;
733
+
734
+ display: inline-block;
735
+ }
736
+
737
+ .color-picker {
738
+ width: var(--grid-width);
739
+ font-family: var(--sl-font-sans);
740
+ font-size: var(--sl-font-size-medium);
741
+ font-weight: var(--sl-font-weight-normal);
742
+ color: var(--color);
743
+ background-color: var(--sl-panel-background-color);
744
+ border-radius: var(--sl-border-radius-medium);
745
+ user-select: none;
746
+ -webkit-user-select: none;
747
+ }
748
+
749
+ .color-picker--inline {
750
+ border: solid var(--sl-panel-border-width) var(--sl-panel-border-color);
751
+ }
752
+
753
+ .color-picker--inline:focus-visible {
754
+ outline: var(--sl-focus-ring);
755
+ outline-offset: var(--sl-focus-ring-offset);
756
+ }
757
+
758
+ .color-picker__grid {
759
+ position: relative;
760
+ height: var(--grid-height);
761
+ background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 100%),
762
+ linear-gradient(to right, #fff 0%, rgba(255, 255, 255, 0) 100%);
763
+ border-top-left-radius: var(--sl-border-radius-medium);
764
+ border-top-right-radius: var(--sl-border-radius-medium);
765
+ cursor: crosshair;
766
+ forced-color-adjust: none;
767
+ }
768
+
769
+ .color-picker__grid-handle {
770
+ position: absolute;
771
+ width: var(--grid-handle-size);
772
+ height: var(--grid-handle-size);
773
+ border-radius: 50%;
774
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
775
+ border: solid 2px white;
776
+ margin-top: calc(var(--grid-handle-size) / -2);
777
+ margin-left: calc(var(--grid-handle-size) / -2);
778
+ transition: var(--sl-transition-fast) scale;
779
+ }
780
+
781
+ .color-picker__grid-handle--dragging {
782
+ cursor: none;
783
+ scale: 1.5;
784
+ }
785
+
786
+ .color-picker__grid-handle:focus-visible {
787
+ outline: var(--sl-focus-ring);
788
+ }
789
+
790
+ .color-picker__controls {
791
+ padding: var(--sl-spacing-small);
792
+ display: flex;
793
+ align-items: center;
794
+ }
795
+
796
+ .color-picker__sliders {
797
+ flex: 1 1 auto;
798
+ }
799
+
800
+ .color-picker__slider {
801
+ position: relative;
802
+ height: var(--slider-height);
803
+ border-radius: var(--sl-border-radius-pill);
804
+ box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
805
+ forced-color-adjust: none;
806
+ }
807
+
808
+ .color-picker__slider:not(:last-of-type) {
809
+ margin-bottom: var(--sl-spacing-small);
810
+ }
811
+
812
+ .color-picker__slider-handle {
813
+ position: absolute;
814
+ top: calc(50% - var(--slider-handle-size) / 2);
815
+ width: var(--slider-handle-size);
816
+ height: var(--slider-handle-size);
817
+ background-color: white;
818
+ border-radius: 50%;
819
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
820
+ margin-left: calc(var(--slider-handle-size) / -2);
821
+ }
822
+
823
+ .color-picker__slider-handle:focus-visible {
824
+ outline: var(--sl-focus-ring);
825
+ }
826
+
827
+ .color-picker__hue {
828
+ background-image: linear-gradient(
829
+ to right,
830
+ rgb(255, 0, 0) 0%,
831
+ rgb(255, 255, 0) 17%,
832
+ rgb(0, 255, 0) 33%,
833
+ rgb(0, 255, 255) 50%,
834
+ rgb(0, 0, 255) 67%,
835
+ rgb(255, 0, 255) 83%,
836
+ rgb(255, 0, 0) 100%
837
+ );
838
+ }
839
+
840
+ .color-picker__alpha .color-picker__alpha-gradient {
841
+ position: absolute;
842
+ top: 0;
843
+ left: 0;
844
+ width: 100%;
845
+ height: 100%;
846
+ border-radius: inherit;
847
+ }
848
+
849
+ .color-picker__preview {
850
+ flex: 0 0 auto;
851
+ display: inline-flex;
852
+ align-items: center;
853
+ justify-content: center;
854
+ position: relative;
855
+ width: 2.25rem;
856
+ height: 2.25rem;
857
+ border: none;
858
+ border-radius: var(--sl-border-radius-circle);
859
+ background: none;
860
+ margin-left: var(--sl-spacing-small);
861
+ cursor: copy;
862
+ forced-color-adjust: none;
863
+ }
864
+
865
+ .color-picker__preview:before {
866
+ content: '';
867
+ position: absolute;
868
+ top: 0;
869
+ left: 0;
870
+ width: 100%;
871
+ height: 100%;
872
+ border-radius: inherit;
873
+ box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
874
+
875
+ /* We use a custom property in lieu of currentColor because of https://bugs.webkit.org/show_bug.cgi?id=216780 */
876
+ background-color: var(--preview-color);
877
+ }
878
+
879
+ .color-picker__preview:focus-visible {
880
+ outline: var(--sl-focus-ring);
881
+ outline-offset: var(--sl-focus-ring-offset);
882
+ }
883
+
884
+ .color-picker__preview-color {
885
+ position: absolute;
886
+ top: 0;
887
+ left: 0;
888
+ width: 100%;
889
+ height: 100%;
890
+ border: solid 1px rgba(0, 0, 0, 0.125);
891
+ }
892
+
893
+ .color-picker__preview-color--copied {
894
+ animation: pulse 0.75s;
895
+ }
896
+
897
+ @keyframes pulse {
898
+ 0% {
899
+ box-shadow: 0 0 0 0 var(--sl-color-primary-500);
900
+ }
901
+ 70% {
902
+ box-shadow: 0 0 0 0.5rem transparent;
903
+ }
904
+ 100% {
905
+ box-shadow: 0 0 0 0 transparent;
906
+ }
907
+ }
908
+
909
+ .color-picker__user-input {
910
+ display: flex;
911
+ padding: 0 var(--sl-spacing-small) var(--sl-spacing-small) var(--sl-spacing-small);
912
+ }
913
+
914
+ .color-picker__user-input sl-input {
915
+ min-width: 0; /* fix input width in Safari */
916
+ flex: 1 1 auto;
917
+ }
918
+
919
+ .color-picker__user-input sl-button-group {
920
+ margin-left: var(--sl-spacing-small);
921
+ }
922
+
923
+ .color-picker__user-input sl-button {
924
+ min-width: 3.25rem;
925
+ max-width: 3.25rem;
926
+ font-size: 1rem;
927
+ }
928
+
929
+ .color-picker__swatches {
930
+ display: grid;
931
+ grid-template-columns: repeat(8, 1fr);
932
+ grid-gap: 0.5rem;
933
+ justify-items: center;
934
+ border-top: solid 1px var(--sl-color-neutral-200);
935
+ padding: var(--sl-spacing-small);
936
+ forced-color-adjust: none;
937
+ }
938
+
939
+ .color-picker__swatch {
940
+ position: relative;
941
+ width: var(--swatch-size);
942
+ height: var(--swatch-size);
943
+ border-radius: var(--sl-border-radius-small);
944
+ }
945
+
946
+ .color-picker__swatch .color-picker__swatch-color {
947
+ position: absolute;
948
+ top: 0;
949
+ left: 0;
950
+ width: 100%;
951
+ height: 100%;
952
+ border: solid 1px rgba(0, 0, 0, 0.125);
953
+ border-radius: inherit;
954
+ cursor: pointer;
955
+ }
956
+
957
+ .color-picker__swatch:focus-visible {
958
+ outline: var(--sl-focus-ring);
959
+ outline-offset: var(--sl-focus-ring-offset);
960
+ }
961
+
962
+ .color-picker__transparent-bg {
963
+ background-image: linear-gradient(45deg, var(--sl-color-neutral-300) 25%, transparent 25%),
964
+ linear-gradient(45deg, transparent 75%, var(--sl-color-neutral-300) 75%),
965
+ linear-gradient(45deg, transparent 75%, var(--sl-color-neutral-300) 75%),
966
+ linear-gradient(45deg, var(--sl-color-neutral-300) 25%, transparent 25%);
967
+ background-size: 10px 10px;
968
+ background-position:
969
+ 0 0,
970
+ 0 0,
971
+ -5px -5px,
972
+ 5px 5px;
973
+ }
974
+
975
+ .color-picker--disabled {
976
+ opacity: 0.5;
977
+ cursor: not-allowed;
978
+ }
979
+
980
+ .color-picker--disabled .color-picker__grid,
981
+ .color-picker--disabled .color-picker__grid-handle,
982
+ .color-picker--disabled .color-picker__slider,
983
+ .color-picker--disabled .color-picker__slider-handle,
984
+ .color-picker--disabled .color-picker__preview,
985
+ .color-picker--disabled .color-picker__swatch,
986
+ .color-picker--disabled .color-picker__swatch-color {
987
+ pointer-events: none;
988
+ }
989
+
990
+ /*
991
+ * Color dropdown
992
+ */
993
+
994
+ .color-dropdown::part(panel) {
995
+ max-height: none;
996
+ background-color: var(--sl-panel-background-color);
997
+ border: solid var(--sl-panel-border-width) var(--sl-panel-border-color);
998
+ border-radius: var(--sl-border-radius-medium);
999
+ overflow: visible;
1000
+ }
1001
+
1002
+ .color-dropdown__trigger {
1003
+ display: inline-block;
1004
+ position: relative;
1005
+ background-color: transparent;
1006
+ border: none;
1007
+ cursor: pointer;
1008
+ forced-color-adjust: none;
1009
+ }
1010
+
1011
+ .color-dropdown__trigger.color-dropdown__trigger--small {
1012
+ width: var(--sl-input-height-small);
1013
+ height: var(--sl-input-height-small);
1014
+ border-radius: var(--sl-border-radius-circle);
1015
+ }
1016
+
1017
+ .color-dropdown__trigger.color-dropdown__trigger--medium {
1018
+ width: var(--sl-input-height-medium);
1019
+ height: var(--sl-input-height-medium);
1020
+ border-radius: var(--sl-border-radius-circle);
1021
+ }
1022
+
1023
+ .color-dropdown__trigger.color-dropdown__trigger--large {
1024
+ width: var(--sl-input-height-large);
1025
+ height: var(--sl-input-height-large);
1026
+ border-radius: var(--sl-border-radius-circle);
1027
+ }
1028
+
1029
+ .color-dropdown__trigger:before {
1030
+ content: '';
1031
+ position: absolute;
1032
+ top: 0;
1033
+ left: 0;
1034
+ width: 100%;
1035
+ height: 100%;
1036
+ border-radius: inherit;
1037
+ background-color: currentColor;
1038
+ box-shadow:
1039
+ inset 0 0 0 2px var(--sl-input-border-color),
1040
+ inset 0 0 0 4px var(--sl-color-neutral-0);
1041
+ }
1042
+
1043
+ .color-dropdown__trigger--empty:before {
1044
+ background-color: transparent;
1045
+ }
1046
+
1047
+ .color-dropdown__trigger:focus-visible {
1048
+ outline: none;
1049
+ }
1050
+
1051
+ .color-dropdown__trigger:focus-visible:not(.color-dropdown__trigger--disabled) {
1052
+ outline: var(--sl-focus-ring);
1053
+ outline-offset: var(--sl-focus-ring-offset);
1054
+ }
1055
+
1056
+ .color-dropdown__trigger.color-dropdown__trigger--disabled {
1057
+ opacity: 0.5;
1058
+ cursor: not-allowed;
1059
+ }
1060
+ `;
1061
+ //#endregion
1062
+ //#region node_modules/@ctrl/tinycolor/dist/module/util.js
1063
+ function k(e, t) {
1064
+ Te(e) && (e = "100%");
1065
+ let n = Ee(e);
1066
+ return e = t === 360 ? e : Math.min(t, Math.max(0, parseFloat(e))), n && (e = parseInt(String(e * t), 10) / 100), Math.abs(e - t) < 1e-6 ? 1 : (e = t === 360 ? (e < 0 ? e % t + t : e % t) / parseFloat(String(t)) : e % t / parseFloat(String(t)), e);
1067
+ }
1068
+ function A(e) {
1069
+ return Math.min(1, Math.max(0, e));
1070
+ }
1071
+ function Te(e) {
1072
+ return typeof e == "string" && e.indexOf(".") !== -1 && parseFloat(e) === 1;
1073
+ }
1074
+ function Ee(e) {
1075
+ return typeof e == "string" && e.indexOf("%") !== -1;
1076
+ }
1077
+ function De(e) {
1078
+ return e = parseFloat(e), (isNaN(e) || e < 0 || e > 1) && (e = 1), e;
1079
+ }
1080
+ function j(e) {
1081
+ return Number(e) <= 1 ? `${Number(e) * 100}%` : e;
1082
+ }
1083
+ function M(e) {
1084
+ return e.length === 1 ? "0" + e : String(e);
1085
+ }
1086
+ //#endregion
1087
+ //#region node_modules/@ctrl/tinycolor/dist/module/conversion.js
1088
+ function Oe(e, t, n) {
1089
+ return {
1090
+ r: k(e, 255) * 255,
1091
+ g: k(t, 255) * 255,
1092
+ b: k(n, 255) * 255
1093
+ };
1094
+ }
1095
+ function ke(e, t, n) {
1096
+ e = k(e, 255), t = k(t, 255), n = k(n, 255);
1097
+ let r = Math.max(e, t, n), i = Math.min(e, t, n), a = 0, o = 0, s = (r + i) / 2;
1098
+ if (r === i) o = 0, a = 0;
1099
+ else {
1100
+ let c = r - i;
1101
+ switch (o = s > .5 ? c / (2 - r - i) : c / (r + i), r) {
1102
+ case e:
1103
+ a = (t - n) / c + (t < n ? 6 : 0);
1104
+ break;
1105
+ case t:
1106
+ a = (n - e) / c + 2;
1107
+ break;
1108
+ case n:
1109
+ a = (e - t) / c + 4;
1110
+ break;
1111
+ default: break;
1112
+ }
1113
+ a /= 6;
1114
+ }
1115
+ return {
1116
+ h: a,
1117
+ s: o,
1118
+ l: s
1119
+ };
1120
+ }
1121
+ function N(e, t, n) {
1122
+ return n < 0 && (n += 1), n > 1 && --n, n < 1 / 6 ? e + (t - e) * (6 * n) : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * (2 / 3 - n) * 6 : e;
1123
+ }
1124
+ function Ae(e, t, n) {
1125
+ let r, i, a;
1126
+ if (e = k(e, 360), t = k(t, 100), n = k(n, 100), t === 0) i = n, a = n, r = n;
1127
+ else {
1128
+ let o = n < .5 ? n * (1 + t) : n + t - n * t, s = 2 * n - o;
1129
+ r = N(s, o, e + 1 / 3), i = N(s, o, e), a = N(s, o, e - 1 / 3);
1130
+ }
1131
+ return {
1132
+ r: r * 255,
1133
+ g: i * 255,
1134
+ b: a * 255
1135
+ };
1136
+ }
1137
+ function je(e, t, n) {
1138
+ e = k(e, 255), t = k(t, 255), n = k(n, 255);
1139
+ let r = Math.max(e, t, n), i = Math.min(e, t, n), a = 0, o = r, s = r - i, c = r === 0 ? 0 : s / r;
1140
+ if (r === i) a = 0;
1141
+ else {
1142
+ switch (r) {
1143
+ case e:
1144
+ a = (t - n) / s + (t < n ? 6 : 0);
1145
+ break;
1146
+ case t:
1147
+ a = (n - e) / s + 2;
1148
+ break;
1149
+ case n:
1150
+ a = (e - t) / s + 4;
1151
+ break;
1152
+ default: break;
1153
+ }
1154
+ a /= 6;
1155
+ }
1156
+ return {
1157
+ h: a,
1158
+ s: c,
1159
+ v: o
1160
+ };
1161
+ }
1162
+ function Me(e, t, n) {
1163
+ e = k(e, 360) * 6, t = k(t, 100), n = k(n, 100);
1164
+ let r = Math.floor(e), i = e - r, a = n * (1 - t), o = n * (1 - i * t), s = n * (1 - (1 - i) * t), c = r % 6, l = [
1165
+ n,
1166
+ o,
1167
+ a,
1168
+ a,
1169
+ s,
1170
+ n
1171
+ ][c], u = [
1172
+ s,
1173
+ n,
1174
+ n,
1175
+ o,
1176
+ a,
1177
+ a
1178
+ ][c], d = [
1179
+ a,
1180
+ a,
1181
+ s,
1182
+ n,
1183
+ n,
1184
+ o
1185
+ ][c];
1186
+ return {
1187
+ r: l * 255,
1188
+ g: u * 255,
1189
+ b: d * 255
1190
+ };
1191
+ }
1192
+ function Ne(e, t, n, r) {
1193
+ let i = [
1194
+ M(Math.round(e).toString(16)),
1195
+ M(Math.round(t).toString(16)),
1196
+ M(Math.round(n).toString(16))
1197
+ ];
1198
+ return r && i[0].startsWith(i[0].charAt(1)) && i[1].startsWith(i[1].charAt(1)) && i[2].startsWith(i[2].charAt(1)) ? i[0].charAt(0) + i[1].charAt(0) + i[2].charAt(0) : i.join("");
1199
+ }
1200
+ function Pe(e, t, n, r, i) {
1201
+ let a = [
1202
+ M(Math.round(e).toString(16)),
1203
+ M(Math.round(t).toString(16)),
1204
+ M(Math.round(n).toString(16)),
1205
+ M(Le(r))
1206
+ ];
1207
+ return i && a[0].startsWith(a[0].charAt(1)) && a[1].startsWith(a[1].charAt(1)) && a[2].startsWith(a[2].charAt(1)) && a[3].startsWith(a[3].charAt(1)) ? a[0].charAt(0) + a[1].charAt(0) + a[2].charAt(0) + a[3].charAt(0) : a.join("");
1208
+ }
1209
+ function Fe(e, t, n, r) {
1210
+ let i = e / 100, a = t / 100, o = n / 100, s = r / 100;
1211
+ return {
1212
+ r: 255 * (1 - i) * (1 - s),
1213
+ g: 255 * (1 - a) * (1 - s),
1214
+ b: 255 * (1 - o) * (1 - s)
1215
+ };
1216
+ }
1217
+ function Ie(e, t, n) {
1218
+ let r = 1 - e / 255, i = 1 - t / 255, a = 1 - n / 255, o = Math.min(r, i, a);
1219
+ return o === 1 ? (r = 0, i = 0, a = 0) : (r = (r - o) / (1 - o) * 100, i = (i - o) / (1 - o) * 100, a = (a - o) / (1 - o) * 100), o *= 100, {
1220
+ c: Math.round(r),
1221
+ m: Math.round(i),
1222
+ y: Math.round(a),
1223
+ k: Math.round(o)
1224
+ };
1225
+ }
1226
+ function Le(e) {
1227
+ return Math.round(parseFloat(e) * 255).toString(16);
1228
+ }
1229
+ function Re(e) {
1230
+ return P(e) / 255;
1231
+ }
1232
+ function P(e) {
1233
+ return parseInt(e, 16);
1234
+ }
1235
+ function ze(e) {
1236
+ return {
1237
+ r: e >> 16,
1238
+ g: (e & 65280) >> 8,
1239
+ b: e & 255
1240
+ };
1241
+ }
1242
+ //#endregion
1243
+ //#region node_modules/@ctrl/tinycolor/dist/module/css-color-names.js
1244
+ var F = {
1245
+ aliceblue: "#f0f8ff",
1246
+ antiquewhite: "#faebd7",
1247
+ aqua: "#00ffff",
1248
+ aquamarine: "#7fffd4",
1249
+ azure: "#f0ffff",
1250
+ beige: "#f5f5dc",
1251
+ bisque: "#ffe4c4",
1252
+ black: "#000000",
1253
+ blanchedalmond: "#ffebcd",
1254
+ blue: "#0000ff",
1255
+ blueviolet: "#8a2be2",
1256
+ brown: "#a52a2a",
1257
+ burlywood: "#deb887",
1258
+ cadetblue: "#5f9ea0",
1259
+ chartreuse: "#7fff00",
1260
+ chocolate: "#d2691e",
1261
+ coral: "#ff7f50",
1262
+ cornflowerblue: "#6495ed",
1263
+ cornsilk: "#fff8dc",
1264
+ crimson: "#dc143c",
1265
+ cyan: "#00ffff",
1266
+ darkblue: "#00008b",
1267
+ darkcyan: "#008b8b",
1268
+ darkgoldenrod: "#b8860b",
1269
+ darkgray: "#a9a9a9",
1270
+ darkgreen: "#006400",
1271
+ darkgrey: "#a9a9a9",
1272
+ darkkhaki: "#bdb76b",
1273
+ darkmagenta: "#8b008b",
1274
+ darkolivegreen: "#556b2f",
1275
+ darkorange: "#ff8c00",
1276
+ darkorchid: "#9932cc",
1277
+ darkred: "#8b0000",
1278
+ darksalmon: "#e9967a",
1279
+ darkseagreen: "#8fbc8f",
1280
+ darkslateblue: "#483d8b",
1281
+ darkslategray: "#2f4f4f",
1282
+ darkslategrey: "#2f4f4f",
1283
+ darkturquoise: "#00ced1",
1284
+ darkviolet: "#9400d3",
1285
+ deeppink: "#ff1493",
1286
+ deepskyblue: "#00bfff",
1287
+ dimgray: "#696969",
1288
+ dimgrey: "#696969",
1289
+ dodgerblue: "#1e90ff",
1290
+ firebrick: "#b22222",
1291
+ floralwhite: "#fffaf0",
1292
+ forestgreen: "#228b22",
1293
+ fuchsia: "#ff00ff",
1294
+ gainsboro: "#dcdcdc",
1295
+ ghostwhite: "#f8f8ff",
1296
+ goldenrod: "#daa520",
1297
+ gold: "#ffd700",
1298
+ gray: "#808080",
1299
+ green: "#008000",
1300
+ greenyellow: "#adff2f",
1301
+ grey: "#808080",
1302
+ honeydew: "#f0fff0",
1303
+ hotpink: "#ff69b4",
1304
+ indianred: "#cd5c5c",
1305
+ indigo: "#4b0082",
1306
+ ivory: "#fffff0",
1307
+ khaki: "#f0e68c",
1308
+ lavenderblush: "#fff0f5",
1309
+ lavender: "#e6e6fa",
1310
+ lawngreen: "#7cfc00",
1311
+ lemonchiffon: "#fffacd",
1312
+ lightblue: "#add8e6",
1313
+ lightcoral: "#f08080",
1314
+ lightcyan: "#e0ffff",
1315
+ lightgoldenrodyellow: "#fafad2",
1316
+ lightgray: "#d3d3d3",
1317
+ lightgreen: "#90ee90",
1318
+ lightgrey: "#d3d3d3",
1319
+ lightpink: "#ffb6c1",
1320
+ lightsalmon: "#ffa07a",
1321
+ lightseagreen: "#20b2aa",
1322
+ lightskyblue: "#87cefa",
1323
+ lightslategray: "#778899",
1324
+ lightslategrey: "#778899",
1325
+ lightsteelblue: "#b0c4de",
1326
+ lightyellow: "#ffffe0",
1327
+ lime: "#00ff00",
1328
+ limegreen: "#32cd32",
1329
+ linen: "#faf0e6",
1330
+ magenta: "#ff00ff",
1331
+ maroon: "#800000",
1332
+ mediumaquamarine: "#66cdaa",
1333
+ mediumblue: "#0000cd",
1334
+ mediumorchid: "#ba55d3",
1335
+ mediumpurple: "#9370db",
1336
+ mediumseagreen: "#3cb371",
1337
+ mediumslateblue: "#7b68ee",
1338
+ mediumspringgreen: "#00fa9a",
1339
+ mediumturquoise: "#48d1cc",
1340
+ mediumvioletred: "#c71585",
1341
+ midnightblue: "#191970",
1342
+ mintcream: "#f5fffa",
1343
+ mistyrose: "#ffe4e1",
1344
+ moccasin: "#ffe4b5",
1345
+ navajowhite: "#ffdead",
1346
+ navy: "#000080",
1347
+ oldlace: "#fdf5e6",
1348
+ olive: "#808000",
1349
+ olivedrab: "#6b8e23",
1350
+ orange: "#ffa500",
1351
+ orangered: "#ff4500",
1352
+ orchid: "#da70d6",
1353
+ palegoldenrod: "#eee8aa",
1354
+ palegreen: "#98fb98",
1355
+ paleturquoise: "#afeeee",
1356
+ palevioletred: "#db7093",
1357
+ papayawhip: "#ffefd5",
1358
+ peachpuff: "#ffdab9",
1359
+ peru: "#cd853f",
1360
+ pink: "#ffc0cb",
1361
+ plum: "#dda0dd",
1362
+ powderblue: "#b0e0e6",
1363
+ purple: "#800080",
1364
+ rebeccapurple: "#663399",
1365
+ red: "#ff0000",
1366
+ rosybrown: "#bc8f8f",
1367
+ royalblue: "#4169e1",
1368
+ saddlebrown: "#8b4513",
1369
+ salmon: "#fa8072",
1370
+ sandybrown: "#f4a460",
1371
+ seagreen: "#2e8b57",
1372
+ seashell: "#fff5ee",
1373
+ sienna: "#a0522d",
1374
+ silver: "#c0c0c0",
1375
+ skyblue: "#87ceeb",
1376
+ slateblue: "#6a5acd",
1377
+ slategray: "#708090",
1378
+ slategrey: "#708090",
1379
+ snow: "#fffafa",
1380
+ springgreen: "#00ff7f",
1381
+ steelblue: "#4682b4",
1382
+ tan: "#d2b48c",
1383
+ teal: "#008080",
1384
+ thistle: "#d8bfd8",
1385
+ tomato: "#ff6347",
1386
+ turquoise: "#40e0d0",
1387
+ violet: "#ee82ee",
1388
+ wheat: "#f5deb3",
1389
+ white: "#ffffff",
1390
+ whitesmoke: "#f5f5f5",
1391
+ yellow: "#ffff00",
1392
+ yellowgreen: "#9acd32"
1393
+ };
1394
+ //#endregion
1395
+ //#region node_modules/@ctrl/tinycolor/dist/module/format-input.js
1396
+ function Be(e) {
1397
+ let t = {
1398
+ r: 0,
1399
+ g: 0,
1400
+ b: 0
1401
+ }, n = 1, r = null, i = null, a = null, o = !1, s = !1;
1402
+ return typeof e == "string" && (e = Ve(e)), typeof e == "object" && (L(e.r) && L(e.g) && L(e.b) ? (t = Oe(e.r, e.g, e.b), o = !0, s = String(e.r).substr(-1) === "%" ? "prgb" : "rgb") : L(e.h) && L(e.s) && L(e.v) ? (r = j(e.s), i = j(e.v), t = Me(e.h, r, i), o = !0, s = "hsv") : L(e.h) && L(e.s) && L(e.l) ? (r = j(e.s), a = j(e.l), t = Ae(e.h, r, a), o = !0, s = "hsl") : L(e.c) && L(e.m) && L(e.y) && L(e.k) && (t = Fe(e.c, e.m, e.y, e.k), o = !0, s = "cmyk"), Object.prototype.hasOwnProperty.call(e, "a") && (n = e.a)), n = De(n), {
1403
+ ok: o,
1404
+ format: e.format || s,
1405
+ r: Math.min(255, Math.max(t.r, 0)),
1406
+ g: Math.min(255, Math.max(t.g, 0)),
1407
+ b: Math.min(255, Math.max(t.b, 0)),
1408
+ a: n
1409
+ };
1410
+ }
1411
+ var I = {
1412
+ CSS_UNIT: /* @__PURE__ */ RegExp("(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)"),
1413
+ rgb: /* @__PURE__ */ RegExp("rgb[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
1414
+ rgba: /* @__PURE__ */ RegExp("rgba[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
1415
+ hsl: /* @__PURE__ */ RegExp("hsl[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
1416
+ hsla: /* @__PURE__ */ RegExp("hsla[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
1417
+ hsv: /* @__PURE__ */ RegExp("hsv[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
1418
+ hsva: /* @__PURE__ */ RegExp("hsva[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
1419
+ cmyk: /* @__PURE__ */ RegExp("cmyk[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
1420
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1421
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1422
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1423
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1424
+ };
1425
+ function Ve(e) {
1426
+ if (e = e.trim().toLowerCase(), e.length === 0) return !1;
1427
+ let t = !1;
1428
+ if (F[e]) e = F[e], t = !0;
1429
+ else if (e === "transparent") return {
1430
+ r: 0,
1431
+ g: 0,
1432
+ b: 0,
1433
+ a: 0,
1434
+ format: "name"
1435
+ };
1436
+ let n = I.rgb.exec(e);
1437
+ return n ? {
1438
+ r: n[1],
1439
+ g: n[2],
1440
+ b: n[3]
1441
+ } : (n = I.rgba.exec(e), n ? {
1442
+ r: n[1],
1443
+ g: n[2],
1444
+ b: n[3],
1445
+ a: n[4]
1446
+ } : (n = I.hsl.exec(e), n ? {
1447
+ h: n[1],
1448
+ s: n[2],
1449
+ l: n[3]
1450
+ } : (n = I.hsla.exec(e), n ? {
1451
+ h: n[1],
1452
+ s: n[2],
1453
+ l: n[3],
1454
+ a: n[4]
1455
+ } : (n = I.hsv.exec(e), n ? {
1456
+ h: n[1],
1457
+ s: n[2],
1458
+ v: n[3]
1459
+ } : (n = I.hsva.exec(e), n ? {
1460
+ h: n[1],
1461
+ s: n[2],
1462
+ v: n[3],
1463
+ a: n[4]
1464
+ } : (n = I.cmyk.exec(e), n ? {
1465
+ c: n[1],
1466
+ m: n[2],
1467
+ y: n[3],
1468
+ k: n[4]
1469
+ } : (n = I.hex8.exec(e), n ? {
1470
+ r: P(n[1]),
1471
+ g: P(n[2]),
1472
+ b: P(n[3]),
1473
+ a: Re(n[4]),
1474
+ format: t ? "name" : "hex8"
1475
+ } : (n = I.hex6.exec(e), n ? {
1476
+ r: P(n[1]),
1477
+ g: P(n[2]),
1478
+ b: P(n[3]),
1479
+ format: t ? "name" : "hex"
1480
+ } : (n = I.hex4.exec(e), n ? {
1481
+ r: P(n[1] + n[1]),
1482
+ g: P(n[2] + n[2]),
1483
+ b: P(n[3] + n[3]),
1484
+ a: Re(n[4] + n[4]),
1485
+ format: t ? "name" : "hex8"
1486
+ } : (n = I.hex3.exec(e), n ? {
1487
+ r: P(n[1] + n[1]),
1488
+ g: P(n[2] + n[2]),
1489
+ b: P(n[3] + n[3]),
1490
+ format: t ? "name" : "hex"
1491
+ } : !1))))))))));
1492
+ }
1493
+ function L(e) {
1494
+ return typeof e == "number" ? !Number.isNaN(e) : I.CSS_UNIT.test(e);
1495
+ }
1496
+ //#endregion
1497
+ //#region node_modules/@ctrl/tinycolor/dist/module/index.js
1498
+ var He = class e {
1499
+ constructor(t = "", n = {}) {
1500
+ if (t instanceof e) return t;
1501
+ typeof t == "number" && (t = ze(t)), this.originalInput = t;
1502
+ let r = Be(t);
1503
+ this.originalInput = t, this.r = r.r, this.g = r.g, this.b = r.b, this.a = r.a, this.roundA = Math.round(100 * this.a) / 100, this.format = n.format ?? r.format, this.gradientType = n.gradientType, this.r < 1 && (this.r = Math.round(this.r)), this.g < 1 && (this.g = Math.round(this.g)), this.b < 1 && (this.b = Math.round(this.b)), this.isValid = r.ok;
1504
+ }
1505
+ isDark() {
1506
+ return this.getBrightness() < 128;
1507
+ }
1508
+ isLight() {
1509
+ return !this.isDark();
1510
+ }
1511
+ getBrightness() {
1512
+ let e = this.toRgb();
1513
+ return (e.r * 299 + e.g * 587 + e.b * 114) / 1e3;
1514
+ }
1515
+ getLuminance() {
1516
+ let e = this.toRgb(), t, n, r, i = e.r / 255, a = e.g / 255, o = e.b / 255;
1517
+ return t = i <= .03928 ? i / 12.92 : ((i + .055) / 1.055) ** 2.4, n = a <= .03928 ? a / 12.92 : ((a + .055) / 1.055) ** 2.4, r = o <= .03928 ? o / 12.92 : ((o + .055) / 1.055) ** 2.4, .2126 * t + .7152 * n + .0722 * r;
1518
+ }
1519
+ getAlpha() {
1520
+ return this.a;
1521
+ }
1522
+ setAlpha(e) {
1523
+ return this.a = De(e), this.roundA = Math.round(100 * this.a) / 100, this;
1524
+ }
1525
+ isMonochrome() {
1526
+ let { s: e } = this.toHsl();
1527
+ return e === 0;
1528
+ }
1529
+ toHsv() {
1530
+ let e = je(this.r, this.g, this.b);
1531
+ return {
1532
+ h: e.h * 360,
1533
+ s: e.s,
1534
+ v: e.v,
1535
+ a: this.a
1536
+ };
1537
+ }
1538
+ toHsvString() {
1539
+ let e = je(this.r, this.g, this.b), t = Math.round(e.h * 360), n = Math.round(e.s * 100), r = Math.round(e.v * 100);
1540
+ return this.a === 1 ? `hsv(${t}, ${n}%, ${r}%)` : `hsva(${t}, ${n}%, ${r}%, ${this.roundA})`;
1541
+ }
1542
+ toHsl() {
1543
+ let e = ke(this.r, this.g, this.b);
1544
+ return {
1545
+ h: e.h * 360,
1546
+ s: e.s,
1547
+ l: e.l,
1548
+ a: this.a
1549
+ };
1550
+ }
1551
+ toHslString() {
1552
+ let e = ke(this.r, this.g, this.b), t = Math.round(e.h * 360), n = Math.round(e.s * 100), r = Math.round(e.l * 100);
1553
+ return this.a === 1 ? `hsl(${t}, ${n}%, ${r}%)` : `hsla(${t}, ${n}%, ${r}%, ${this.roundA})`;
1554
+ }
1555
+ toHex(e = !1) {
1556
+ return Ne(this.r, this.g, this.b, e);
1557
+ }
1558
+ toHexString(e = !1) {
1559
+ return "#" + this.toHex(e);
1560
+ }
1561
+ toHex8(e = !1) {
1562
+ return Pe(this.r, this.g, this.b, this.a, e);
1563
+ }
1564
+ toHex8String(e = !1) {
1565
+ return "#" + this.toHex8(e);
1566
+ }
1567
+ toHexShortString(e = !1) {
1568
+ return this.a === 1 ? this.toHexString(e) : this.toHex8String(e);
1569
+ }
1570
+ toRgb() {
1571
+ return {
1572
+ r: Math.round(this.r),
1573
+ g: Math.round(this.g),
1574
+ b: Math.round(this.b),
1575
+ a: this.a
1576
+ };
1577
+ }
1578
+ toRgbString() {
1579
+ let e = Math.round(this.r), t = Math.round(this.g), n = Math.round(this.b);
1580
+ return this.a === 1 ? `rgb(${e}, ${t}, ${n})` : `rgba(${e}, ${t}, ${n}, ${this.roundA})`;
1581
+ }
1582
+ toPercentageRgb() {
1583
+ let e = (e) => `${Math.round(k(e, 255) * 100)}%`;
1584
+ return {
1585
+ r: e(this.r),
1586
+ g: e(this.g),
1587
+ b: e(this.b),
1588
+ a: this.a
1589
+ };
1590
+ }
1591
+ toPercentageRgbString() {
1592
+ let e = (e) => Math.round(k(e, 255) * 100);
1593
+ return this.a === 1 ? `rgb(${e(this.r)}%, ${e(this.g)}%, ${e(this.b)}%)` : `rgba(${e(this.r)}%, ${e(this.g)}%, ${e(this.b)}%, ${this.roundA})`;
1594
+ }
1595
+ toCmyk() {
1596
+ return { ...Ie(this.r, this.g, this.b) };
1597
+ }
1598
+ toCmykString() {
1599
+ let { c: e, m: t, y: n, k: r } = Ie(this.r, this.g, this.b);
1600
+ return `cmyk(${e}, ${t}, ${n}, ${r})`;
1601
+ }
1602
+ toName() {
1603
+ if (this.a === 0) return "transparent";
1604
+ if (this.a < 1) return !1;
1605
+ let e = "#" + Ne(this.r, this.g, this.b, !1);
1606
+ for (let [t, n] of Object.entries(F)) if (e === n) return t;
1607
+ return !1;
1608
+ }
1609
+ toString(e) {
1610
+ let t = !!e;
1611
+ e ??= this.format;
1612
+ let n = !1, r = this.a < 1 && this.a >= 0;
1613
+ return !t && r && (e.startsWith("hex") || e === "name") ? e === "name" && this.a === 0 ? this.toName() : this.toRgbString() : (e === "rgb" && (n = this.toRgbString()), e === "prgb" && (n = this.toPercentageRgbString()), (e === "hex" || e === "hex6") && (n = this.toHexString()), e === "hex3" && (n = this.toHexString(!0)), e === "hex4" && (n = this.toHex8String(!0)), e === "hex8" && (n = this.toHex8String()), e === "name" && (n = this.toName()), e === "hsl" && (n = this.toHslString()), e === "hsv" && (n = this.toHsvString()), e === "cmyk" && (n = this.toCmykString()), n || this.toHexString());
1614
+ }
1615
+ toNumber() {
1616
+ return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
1617
+ }
1618
+ clone() {
1619
+ return new e(this.toString());
1620
+ }
1621
+ lighten(t = 10) {
1622
+ let n = this.toHsl();
1623
+ return n.l += t / 100, n.l = A(n.l), new e(n);
1624
+ }
1625
+ brighten(t = 10) {
1626
+ let n = this.toRgb();
1627
+ return n.r = Math.max(0, Math.min(255, n.r - Math.round(255 * -(t / 100)))), n.g = Math.max(0, Math.min(255, n.g - Math.round(255 * -(t / 100)))), n.b = Math.max(0, Math.min(255, n.b - Math.round(255 * -(t / 100)))), new e(n);
1628
+ }
1629
+ darken(t = 10) {
1630
+ let n = this.toHsl();
1631
+ return n.l -= t / 100, n.l = A(n.l), new e(n);
1632
+ }
1633
+ tint(e = 10) {
1634
+ return this.mix("white", e);
1635
+ }
1636
+ shade(e = 10) {
1637
+ return this.mix("black", e);
1638
+ }
1639
+ desaturate(t = 10) {
1640
+ let n = this.toHsl();
1641
+ return n.s -= t / 100, n.s = A(n.s), new e(n);
1642
+ }
1643
+ saturate(t = 10) {
1644
+ let n = this.toHsl();
1645
+ return n.s += t / 100, n.s = A(n.s), new e(n);
1646
+ }
1647
+ greyscale() {
1648
+ return this.desaturate(100);
1649
+ }
1650
+ spin(t) {
1651
+ let n = this.toHsl(), r = (n.h + t) % 360;
1652
+ return n.h = r < 0 ? 360 + r : r, new e(n);
1653
+ }
1654
+ mix(t, n = 50) {
1655
+ let r = this.toRgb(), i = new e(t).toRgb(), a = n / 100;
1656
+ return new e({
1657
+ r: (i.r - r.r) * a + r.r,
1658
+ g: (i.g - r.g) * a + r.g,
1659
+ b: (i.b - r.b) * a + r.b,
1660
+ a: (i.a - r.a) * a + r.a
1661
+ });
1662
+ }
1663
+ analogous(t = 6, n = 30) {
1664
+ let r = this.toHsl(), i = 360 / n, a = [this];
1665
+ for (r.h = (r.h - (i * t >> 1) + 720) % 360; --t;) r.h = (r.h + i) % 360, a.push(new e(r));
1666
+ return a;
1667
+ }
1668
+ complement() {
1669
+ let t = this.toHsl();
1670
+ return t.h = (t.h + 180) % 360, new e(t);
1671
+ }
1672
+ monochromatic(t = 6) {
1673
+ let n = this.toHsv(), { h: r } = n, { s: i } = n, { v: a } = n, o = [], s = 1 / t;
1674
+ for (; t--;) o.push(new e({
1675
+ h: r,
1676
+ s: i,
1677
+ v: a
1678
+ })), a = (a + s) % 1;
1679
+ return o;
1680
+ }
1681
+ splitcomplement() {
1682
+ let t = this.toHsl(), { h: n } = t;
1683
+ return [
1684
+ this,
1685
+ new e({
1686
+ h: (n + 72) % 360,
1687
+ s: t.s,
1688
+ l: t.l
1689
+ }),
1690
+ new e({
1691
+ h: (n + 216) % 360,
1692
+ s: t.s,
1693
+ l: t.l
1694
+ })
1695
+ ];
1696
+ }
1697
+ onBackground(t) {
1698
+ let n = this.toRgb(), r = new e(t).toRgb(), i = n.a + r.a * (1 - n.a);
1699
+ return new e({
1700
+ r: (n.r * n.a + r.r * r.a * (1 - n.a)) / i,
1701
+ g: (n.g * n.a + r.g * r.a * (1 - n.a)) / i,
1702
+ b: (n.b * n.a + r.b * r.a * (1 - n.a)) / i,
1703
+ a: i
1704
+ });
1705
+ }
1706
+ triad() {
1707
+ return this.polyad(3);
1708
+ }
1709
+ tetrad() {
1710
+ return this.polyad(4);
1711
+ }
1712
+ polyad(t) {
1713
+ let n = this.toHsl(), { h: r } = n, i = [this], a = 360 / t;
1714
+ for (let o = 1; o < t; o++) i.push(new e({
1715
+ h: (r + o * a) % 360,
1716
+ s: n.s,
1717
+ l: n.l
1718
+ }));
1719
+ return i;
1720
+ }
1721
+ equals(t) {
1722
+ let n = new e(t);
1723
+ return this.format === "cmyk" || n.format === "cmyk" ? this.toCmykString() === n.toCmykString() : this.toRgbString() === n.toRgbString();
1724
+ }
1725
+ }, Ue = "EyeDropper" in window, R = class extends n {
1726
+ constructor() {
1727
+ super(), this.formControlController = new ne(this), this.isSafeValue = !1, this.localize = new f(this), this.hasFocus = !1, this.isDraggingGridHandle = !1, this.isEmpty = !1, this.inputValue = "", this.hue = 0, this.saturation = 100, this.brightness = 100, this.alpha = 100, this.value = "", this.defaultValue = "", this.label = "", this.format = "hex", this.inline = !1, this.size = "medium", this.noFormatToggle = !1, this.name = "", this.disabled = !1, this.hoist = !1, this.opacity = !1, this.uppercase = !1, this.swatches = "", this.form = "", this.required = !1, this.handleFocusIn = () => {
1728
+ this.hasFocus = !0, this.emit("sl-focus");
1729
+ }, this.handleFocusOut = () => {
1730
+ this.hasFocus = !1, this.emit("sl-blur");
1731
+ }, this.addEventListener("focusin", this.handleFocusIn), this.addEventListener("focusout", this.handleFocusOut);
1732
+ }
1733
+ get validity() {
1734
+ return this.input.validity;
1735
+ }
1736
+ get validationMessage() {
1737
+ return this.input.validationMessage;
1738
+ }
1739
+ firstUpdated() {
1740
+ this.input.updateComplete.then(() => {
1741
+ this.formControlController.updateValidity();
1742
+ });
1743
+ }
1744
+ handleCopy() {
1745
+ this.input.select(), document.execCommand("copy"), this.previewButton.focus(), this.previewButton.classList.add("color-picker__preview-color--copied"), this.previewButton.addEventListener("animationend", () => {
1746
+ this.previewButton.classList.remove("color-picker__preview-color--copied");
1747
+ });
1748
+ }
1749
+ handleFormatToggle() {
1750
+ let e = [
1751
+ "hex",
1752
+ "rgb",
1753
+ "hsl",
1754
+ "hsv"
1755
+ ], t = (e.indexOf(this.format) + 1) % e.length;
1756
+ this.format = e[t], this.setColor(this.value), this.emit("sl-change"), this.emit("sl-input");
1757
+ }
1758
+ handleAlphaDrag(e) {
1759
+ let t = this.shadowRoot.querySelector(".color-picker__slider.color-picker__alpha"), n = t.querySelector(".color-picker__slider-handle"), { width: r } = t.getBoundingClientRect(), i = this.value, a = this.value;
1760
+ n.focus(), e.preventDefault(), D(t, {
1761
+ onMove: (e) => {
1762
+ this.alpha = m(e / r * 100, 0, 100), this.syncValues(), this.value !== a && (a = this.value, this.emit("sl-input"));
1763
+ },
1764
+ onStop: () => {
1765
+ this.value !== i && (i = this.value, this.emit("sl-change"));
1766
+ },
1767
+ initialEvent: e
1768
+ });
1769
+ }
1770
+ handleHueDrag(e) {
1771
+ let t = this.shadowRoot.querySelector(".color-picker__slider.color-picker__hue"), n = t.querySelector(".color-picker__slider-handle"), { width: r } = t.getBoundingClientRect(), i = this.value, a = this.value;
1772
+ n.focus(), e.preventDefault(), D(t, {
1773
+ onMove: (e) => {
1774
+ this.hue = m(e / r * 360, 0, 360), this.syncValues(), this.value !== a && (a = this.value, this.emit("sl-input"));
1775
+ },
1776
+ onStop: () => {
1777
+ this.value !== i && (i = this.value, this.emit("sl-change"));
1778
+ },
1779
+ initialEvent: e
1780
+ });
1781
+ }
1782
+ handleGridDrag(e) {
1783
+ let t = this.shadowRoot.querySelector(".color-picker__grid"), n = t.querySelector(".color-picker__grid-handle"), { width: r, height: i } = t.getBoundingClientRect(), a = this.value, o = this.value;
1784
+ n.focus(), e.preventDefault(), this.isDraggingGridHandle = !0, D(t, {
1785
+ onMove: (e, t) => {
1786
+ this.saturation = m(e / r * 100, 0, 100), this.brightness = m(100 - t / i * 100, 0, 100), this.syncValues(), this.value !== o && (o = this.value, this.emit("sl-input"));
1787
+ },
1788
+ onStop: () => {
1789
+ this.isDraggingGridHandle = !1, this.value !== a && (a = this.value, this.emit("sl-change"));
1790
+ },
1791
+ initialEvent: e
1792
+ });
1793
+ }
1794
+ handleAlphaKeyDown(e) {
1795
+ let t = e.shiftKey ? 10 : 1, n = this.value;
1796
+ e.key === "ArrowLeft" && (e.preventDefault(), this.alpha = m(this.alpha - t, 0, 100), this.syncValues()), e.key === "ArrowRight" && (e.preventDefault(), this.alpha = m(this.alpha + t, 0, 100), this.syncValues()), e.key === "Home" && (e.preventDefault(), this.alpha = 0, this.syncValues()), e.key === "End" && (e.preventDefault(), this.alpha = 100, this.syncValues()), this.value !== n && (this.emit("sl-change"), this.emit("sl-input"));
1797
+ }
1798
+ handleHueKeyDown(e) {
1799
+ let t = e.shiftKey ? 10 : 1, n = this.value;
1800
+ e.key === "ArrowLeft" && (e.preventDefault(), this.hue = m(this.hue - t, 0, 360), this.syncValues()), e.key === "ArrowRight" && (e.preventDefault(), this.hue = m(this.hue + t, 0, 360), this.syncValues()), e.key === "Home" && (e.preventDefault(), this.hue = 0, this.syncValues()), e.key === "End" && (e.preventDefault(), this.hue = 360, this.syncValues()), this.value !== n && (this.emit("sl-change"), this.emit("sl-input"));
1801
+ }
1802
+ handleGridKeyDown(e) {
1803
+ let t = e.shiftKey ? 10 : 1, n = this.value;
1804
+ e.key === "ArrowLeft" && (e.preventDefault(), this.saturation = m(this.saturation - t, 0, 100), this.syncValues()), e.key === "ArrowRight" && (e.preventDefault(), this.saturation = m(this.saturation + t, 0, 100), this.syncValues()), e.key === "ArrowUp" && (e.preventDefault(), this.brightness = m(this.brightness + t, 0, 100), this.syncValues()), e.key === "ArrowDown" && (e.preventDefault(), this.brightness = m(this.brightness - t, 0, 100), this.syncValues()), this.value !== n && (this.emit("sl-change"), this.emit("sl-input"));
1805
+ }
1806
+ handleInputChange(e) {
1807
+ let t = e.target, n = this.value;
1808
+ e.stopPropagation(), this.input.value ? (this.setColor(t.value), t.value = this.value) : this.value = "", this.value !== n && (this.emit("sl-change"), this.emit("sl-input"));
1809
+ }
1810
+ handleInputInput(e) {
1811
+ this.formControlController.updateValidity(), e.stopPropagation();
1812
+ }
1813
+ handleInputKeyDown(e) {
1814
+ if (e.key === "Enter") {
1815
+ let e = this.value;
1816
+ this.input.value ? (this.setColor(this.input.value), this.input.value = this.value, this.value !== e && (this.emit("sl-change"), this.emit("sl-input")), setTimeout(() => this.input.select())) : this.hue = 0;
1817
+ }
1818
+ }
1819
+ handleInputInvalid(e) {
1820
+ this.formControlController.setValidity(!1), this.formControlController.emitInvalidEvent(e);
1821
+ }
1822
+ handleTouchMove(e) {
1823
+ e.preventDefault();
1824
+ }
1825
+ parseColor(e) {
1826
+ let t = new He(e);
1827
+ if (!t.isValid) return null;
1828
+ let n = t.toHsl(), r = {
1829
+ h: n.h,
1830
+ s: n.s * 100,
1831
+ l: n.l * 100,
1832
+ a: n.a
1833
+ }, i = t.toRgb(), a = t.toHexString(), o = t.toHex8String(), s = t.toHsv(), c = {
1834
+ h: s.h,
1835
+ s: s.s * 100,
1836
+ v: s.v * 100,
1837
+ a: s.a
1838
+ };
1839
+ return {
1840
+ hsl: {
1841
+ h: r.h,
1842
+ s: r.s,
1843
+ l: r.l,
1844
+ string: this.setLetterCase(`hsl(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%)`)
1845
+ },
1846
+ hsla: {
1847
+ h: r.h,
1848
+ s: r.s,
1849
+ l: r.l,
1850
+ a: r.a,
1851
+ string: this.setLetterCase(`hsla(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%, ${r.a.toFixed(2).toString()})`)
1852
+ },
1853
+ hsv: {
1854
+ h: c.h,
1855
+ s: c.s,
1856
+ v: c.v,
1857
+ string: this.setLetterCase(`hsv(${Math.round(c.h)}, ${Math.round(c.s)}%, ${Math.round(c.v)}%)`)
1858
+ },
1859
+ hsva: {
1860
+ h: c.h,
1861
+ s: c.s,
1862
+ v: c.v,
1863
+ a: c.a,
1864
+ string: this.setLetterCase(`hsva(${Math.round(c.h)}, ${Math.round(c.s)}%, ${Math.round(c.v)}%, ${c.a.toFixed(2).toString()})`)
1865
+ },
1866
+ rgb: {
1867
+ r: i.r,
1868
+ g: i.g,
1869
+ b: i.b,
1870
+ string: this.setLetterCase(`rgb(${Math.round(i.r)}, ${Math.round(i.g)}, ${Math.round(i.b)})`)
1871
+ },
1872
+ rgba: {
1873
+ r: i.r,
1874
+ g: i.g,
1875
+ b: i.b,
1876
+ a: i.a,
1877
+ string: this.setLetterCase(`rgba(${Math.round(i.r)}, ${Math.round(i.g)}, ${Math.round(i.b)}, ${i.a.toFixed(2).toString()})`)
1878
+ },
1879
+ hex: this.setLetterCase(a),
1880
+ hexa: this.setLetterCase(o)
1881
+ };
1882
+ }
1883
+ setColor(e) {
1884
+ let t = this.parseColor(e);
1885
+ return t === null ? !1 : (this.hue = t.hsva.h, this.saturation = t.hsva.s, this.brightness = t.hsva.v, this.alpha = this.opacity ? t.hsva.a * 100 : 100, this.syncValues(), !0);
1886
+ }
1887
+ setLetterCase(e) {
1888
+ return typeof e == "string" ? this.uppercase ? e.toUpperCase() : e.toLowerCase() : "";
1889
+ }
1890
+ async syncValues() {
1891
+ let e = this.parseColor(`hsva(${this.hue}, ${this.saturation}%, ${this.brightness}%, ${this.alpha / 100})`);
1892
+ e !== null && (this.format === "hsl" ? this.inputValue = this.opacity ? e.hsla.string : e.hsl.string : this.format === "rgb" ? this.inputValue = this.opacity ? e.rgba.string : e.rgb.string : this.format === "hsv" ? this.inputValue = this.opacity ? e.hsva.string : e.hsv.string : this.inputValue = this.opacity ? e.hexa : e.hex, this.isSafeValue = !0, this.value = this.inputValue, await this.updateComplete, this.isSafeValue = !1);
1893
+ }
1894
+ handleAfterHide() {
1895
+ this.previewButton.classList.remove("color-picker__preview-color--copied");
1896
+ }
1897
+ handleEyeDropper() {
1898
+ Ue && new EyeDropper().open().then((e) => {
1899
+ let t = this.value;
1900
+ this.setColor(e.sRGBHex), this.value !== t && (this.emit("sl-change"), this.emit("sl-input"));
1901
+ }).catch(() => {});
1902
+ }
1903
+ selectSwatch(e) {
1904
+ let t = this.value;
1905
+ this.disabled || (this.setColor(e), this.value !== t && (this.emit("sl-change"), this.emit("sl-input")));
1906
+ }
1907
+ getHexString(e, t, n, r = 100) {
1908
+ let i = new He(`hsva(${e}, ${t}%, ${n}%, ${r / 100})`);
1909
+ return i.isValid ? i.toHex8String() : "";
1910
+ }
1911
+ stopNestedEventPropagation(e) {
1912
+ e.stopImmediatePropagation();
1913
+ }
1914
+ handleFormatChange() {
1915
+ this.syncValues();
1916
+ }
1917
+ handleOpacityChange() {
1918
+ this.alpha = 100;
1919
+ }
1920
+ handleValueChange(e, t) {
1921
+ if (this.isEmpty = !t, t || (this.hue = 0, this.saturation = 0, this.brightness = 100, this.alpha = 100), !this.isSafeValue) {
1922
+ let n = this.parseColor(t);
1923
+ n === null ? this.inputValue = e ?? "" : (this.inputValue = this.value, this.hue = n.hsva.h, this.saturation = n.hsva.s, this.brightness = n.hsva.v, this.alpha = n.hsva.a * 100, this.syncValues());
1924
+ }
1925
+ }
1926
+ focus(e) {
1927
+ this.inline ? this.base.focus(e) : this.trigger.focus(e);
1928
+ }
1929
+ blur() {
1930
+ let e = this.inline ? this.base : this.trigger;
1931
+ this.hasFocus && (e.focus({ preventScroll: !0 }), e.blur()), this.dropdown?.open && this.dropdown.hide();
1932
+ }
1933
+ getFormattedValue(e = "hex") {
1934
+ let t = this.parseColor(`hsva(${this.hue}, ${this.saturation}%, ${this.brightness}%, ${this.alpha / 100})`);
1935
+ if (t === null) return "";
1936
+ switch (e) {
1937
+ case "hex": return t.hex;
1938
+ case "hexa": return t.hexa;
1939
+ case "rgb": return t.rgb.string;
1940
+ case "rgba": return t.rgba.string;
1941
+ case "hsl": return t.hsl.string;
1942
+ case "hsla": return t.hsla.string;
1943
+ case "hsv": return t.hsv.string;
1944
+ case "hsva": return t.hsva.string;
1945
+ default: return "";
1946
+ }
1947
+ }
1948
+ checkValidity() {
1949
+ return this.input.checkValidity();
1950
+ }
1951
+ getForm() {
1952
+ return this.formControlController.getForm();
1953
+ }
1954
+ reportValidity() {
1955
+ return !this.inline && !this.validity.valid ? (this.dropdown.show(), this.addEventListener("sl-after-show", () => this.input.reportValidity(), { once: !0 }), this.disabled || this.formControlController.emitInvalidEvent(), !1) : this.input.reportValidity();
1956
+ }
1957
+ setCustomValidity(e) {
1958
+ this.input.setCustomValidity(e), this.formControlController.updateValidity();
1959
+ }
1960
+ render() {
1961
+ let e = this.saturation, t = 100 - this.brightness, n = Array.isArray(this.swatches) ? this.swatches : this.swatches.split(";").filter((e) => e.trim() !== ""), r = g`
1962
+ <div
1963
+ part="base"
1964
+ class=${b({
1965
+ "color-picker": !0,
1966
+ "color-picker--inline": this.inline,
1967
+ "color-picker--disabled": this.disabled,
1968
+ "color-picker--focused": this.hasFocus
1969
+ })}
1970
+ aria-disabled=${this.disabled ? "true" : "false"}
1971
+ aria-labelledby="label"
1972
+ tabindex=${this.inline ? "0" : "-1"}
1973
+ >
1974
+ ${this.inline ? g`
1975
+ <sl-visually-hidden id="label">
1976
+ <slot name="label">${this.label}</slot>
1977
+ </sl-visually-hidden>
1978
+ ` : null}
1979
+
1980
+ <div
1981
+ part="grid"
1982
+ class="color-picker__grid"
1983
+ style=${S({ backgroundColor: this.getHexString(this.hue, 100, 100) })}
1984
+ @pointerdown=${this.handleGridDrag}
1985
+ @touchmove=${this.handleTouchMove}
1986
+ >
1987
+ <span
1988
+ part="grid-handle"
1989
+ class=${b({
1990
+ "color-picker__grid-handle": !0,
1991
+ "color-picker__grid-handle--dragging": this.isDraggingGridHandle
1992
+ })}
1993
+ style=${S({
1994
+ top: `${t}%`,
1995
+ left: `${e}%`,
1996
+ backgroundColor: this.getHexString(this.hue, this.saturation, this.brightness, this.alpha)
1997
+ })}
1998
+ role="application"
1999
+ aria-label="HSV"
2000
+ tabindex=${x(this.disabled ? void 0 : "0")}
2001
+ @keydown=${this.handleGridKeyDown}
2002
+ ></span>
2003
+ </div>
2004
+
2005
+ <div class="color-picker__controls">
2006
+ <div class="color-picker__sliders">
2007
+ <div
2008
+ part="slider hue-slider"
2009
+ class="color-picker__hue color-picker__slider"
2010
+ @pointerdown=${this.handleHueDrag}
2011
+ @touchmove=${this.handleTouchMove}
2012
+ >
2013
+ <span
2014
+ part="slider-handle hue-slider-handle"
2015
+ class="color-picker__slider-handle"
2016
+ style=${S({ left: `${this.hue === 0 ? 0 : 100 / (360 / this.hue)}%` })}
2017
+ role="slider"
2018
+ aria-label="hue"
2019
+ aria-orientation="horizontal"
2020
+ aria-valuemin="0"
2021
+ aria-valuemax="360"
2022
+ aria-valuenow=${`${Math.round(this.hue)}`}
2023
+ tabindex=${x(this.disabled ? void 0 : "0")}
2024
+ @keydown=${this.handleHueKeyDown}
2025
+ ></span>
2026
+ </div>
2027
+
2028
+ ${this.opacity ? g`
2029
+ <div
2030
+ part="slider opacity-slider"
2031
+ class="color-picker__alpha color-picker__slider color-picker__transparent-bg"
2032
+ @pointerdown="${this.handleAlphaDrag}"
2033
+ @touchmove=${this.handleTouchMove}
2034
+ >
2035
+ <div
2036
+ class="color-picker__alpha-gradient"
2037
+ style=${S({ backgroundImage: `linear-gradient(
2038
+ to right,
2039
+ ${this.getHexString(this.hue, this.saturation, this.brightness, 0)} 0%,
2040
+ ${this.getHexString(this.hue, this.saturation, this.brightness, 100)} 100%
2041
+ )` })}
2042
+ ></div>
2043
+ <span
2044
+ part="slider-handle opacity-slider-handle"
2045
+ class="color-picker__slider-handle"
2046
+ style=${S({ left: `${this.alpha}%` })}
2047
+ role="slider"
2048
+ aria-label="alpha"
2049
+ aria-orientation="horizontal"
2050
+ aria-valuemin="0"
2051
+ aria-valuemax="100"
2052
+ aria-valuenow=${Math.round(this.alpha)}
2053
+ tabindex=${x(this.disabled ? void 0 : "0")}
2054
+ @keydown=${this.handleAlphaKeyDown}
2055
+ ></span>
2056
+ </div>
2057
+ ` : ""}
2058
+ </div>
2059
+
2060
+ <button
2061
+ type="button"
2062
+ part="preview"
2063
+ class="color-picker__preview color-picker__transparent-bg"
2064
+ aria-label=${this.localize.term("copy")}
2065
+ style=${S({ "--preview-color": this.getHexString(this.hue, this.saturation, this.brightness, this.alpha) })}
2066
+ @click=${this.handleCopy}
2067
+ ></button>
2068
+ </div>
2069
+
2070
+ <div class="color-picker__user-input" aria-live="polite">
2071
+ <sl-input
2072
+ part="input"
2073
+ type="text"
2074
+ name=${this.name}
2075
+ autocomplete="off"
2076
+ autocorrect="off"
2077
+ autocapitalize="off"
2078
+ spellcheck="false"
2079
+ value=${this.isEmpty ? "" : this.inputValue}
2080
+ ?required=${this.required}
2081
+ ?disabled=${this.disabled}
2082
+ aria-label=${this.localize.term("currentValue")}
2083
+ @keydown=${this.handleInputKeyDown}
2084
+ @sl-change=${this.handleInputChange}
2085
+ @sl-input=${this.handleInputInput}
2086
+ @sl-invalid=${this.handleInputInvalid}
2087
+ @sl-blur=${this.stopNestedEventPropagation}
2088
+ @sl-focus=${this.stopNestedEventPropagation}
2089
+ ></sl-input>
2090
+
2091
+ <sl-button-group>
2092
+ ${this.noFormatToggle ? "" : g`
2093
+ <sl-button
2094
+ part="format-button"
2095
+ aria-label=${this.localize.term("toggleColorFormat")}
2096
+ exportparts="
2097
+ base:format-button__base,
2098
+ prefix:format-button__prefix,
2099
+ label:format-button__label,
2100
+ suffix:format-button__suffix,
2101
+ caret:format-button__caret
2102
+ "
2103
+ @click=${this.handleFormatToggle}
2104
+ @sl-blur=${this.stopNestedEventPropagation}
2105
+ @sl-focus=${this.stopNestedEventPropagation}
2106
+ >
2107
+ ${this.setLetterCase(this.format)}
2108
+ </sl-button>
2109
+ `}
2110
+ ${Ue ? g`
2111
+ <sl-button
2112
+ part="eye-dropper-button"
2113
+ exportparts="
2114
+ base:eye-dropper-button__base,
2115
+ prefix:eye-dropper-button__prefix,
2116
+ label:eye-dropper-button__label,
2117
+ suffix:eye-dropper-button__suffix,
2118
+ caret:eye-dropper-button__caret
2119
+ "
2120
+ @click=${this.handleEyeDropper}
2121
+ @sl-blur=${this.stopNestedEventPropagation}
2122
+ @sl-focus=${this.stopNestedEventPropagation}
2123
+ >
2124
+ <sl-icon
2125
+ library="system"
2126
+ name="eyedropper"
2127
+ label=${this.localize.term("selectAColorFromTheScreen")}
2128
+ ></sl-icon>
2129
+ </sl-button>
2130
+ ` : ""}
2131
+ </sl-button-group>
2132
+ </div>
2133
+
2134
+ ${n.length > 0 ? g`
2135
+ <div part="swatches" class="color-picker__swatches">
2136
+ ${n.map((e) => {
2137
+ let t = this.parseColor(e);
2138
+ return t ? g`
2139
+ <div
2140
+ part="swatch"
2141
+ class="color-picker__swatch color-picker__transparent-bg"
2142
+ tabindex=${x(this.disabled ? void 0 : "0")}
2143
+ role="button"
2144
+ aria-label=${e}
2145
+ @click=${() => this.selectSwatch(e)}
2146
+ @keydown=${(e) => !this.disabled && e.key === "Enter" && this.setColor(t.hexa)}
2147
+ >
2148
+ <div
2149
+ class="color-picker__swatch-color"
2150
+ style=${S({ backgroundColor: t.hexa })}
2151
+ ></div>
2152
+ </div>
2153
+ ` : (console.error(`Unable to parse swatch color: "${e}"`, this), "");
2154
+ })}
2155
+ </div>
2156
+ ` : ""}
2157
+ </div>
2158
+ `;
2159
+ return this.inline ? r : g`
2160
+ <sl-dropdown
2161
+ class="color-dropdown"
2162
+ aria-disabled=${this.disabled ? "true" : "false"}
2163
+ .containingElement=${this}
2164
+ ?disabled=${this.disabled}
2165
+ ?hoist=${this.hoist}
2166
+ @sl-after-hide=${this.handleAfterHide}
2167
+ >
2168
+ <button
2169
+ part="trigger"
2170
+ slot="trigger"
2171
+ class=${b({
2172
+ "color-dropdown__trigger": !0,
2173
+ "color-dropdown__trigger--disabled": this.disabled,
2174
+ "color-dropdown__trigger--small": this.size === "small",
2175
+ "color-dropdown__trigger--medium": this.size === "medium",
2176
+ "color-dropdown__trigger--large": this.size === "large",
2177
+ "color-dropdown__trigger--empty": this.isEmpty,
2178
+ "color-dropdown__trigger--focused": this.hasFocus,
2179
+ "color-picker__transparent-bg": !0
2180
+ })}
2181
+ style=${S({ color: this.getHexString(this.hue, this.saturation, this.brightness, this.alpha) })}
2182
+ type="button"
2183
+ >
2184
+ <sl-visually-hidden>
2185
+ <slot name="label">${this.label}</slot>
2186
+ </sl-visually-hidden>
2187
+ </button>
2188
+ ${r}
2189
+ </sl-dropdown>
2190
+ `;
2191
+ }
2192
+ };
2193
+ //#endregion
2194
+ //#region node_modules/@shoelace-style/shoelace/dist/chunks/chunk.BQVAQ53I.js
2195
+ R.styles = [r, we], R.dependencies = {
2196
+ "sl-button-group": C,
2197
+ "sl-button": re,
2198
+ "sl-dropdown": O,
2199
+ "sl-icon": i,
2200
+ "sl-input": ae,
2201
+ "sl-visually-hidden": Se
2202
+ }, e([v("[part~=\"base\"]")], R.prototype, "base", 2), e([v("[part~=\"input\"]")], R.prototype, "input", 2), e([v(".color-dropdown")], R.prototype, "dropdown", 2), e([v("[part~=\"preview\"]")], R.prototype, "previewButton", 2), e([v("[part~=\"trigger\"]")], R.prototype, "trigger", 2), e([y()], R.prototype, "hasFocus", 2), e([y()], R.prototype, "isDraggingGridHandle", 2), e([y()], R.prototype, "isEmpty", 2), e([y()], R.prototype, "inputValue", 2), e([y()], R.prototype, "hue", 2), e([y()], R.prototype, "saturation", 2), e([y()], R.prototype, "brightness", 2), e([y()], R.prototype, "alpha", 2), e([_()], R.prototype, "value", 2), e([ie()], R.prototype, "defaultValue", 2), e([_()], R.prototype, "label", 2), e([_()], R.prototype, "format", 2), e([_({
2203
+ type: Boolean,
2204
+ reflect: !0
2205
+ })], R.prototype, "inline", 2), e([_({ reflect: !0 })], R.prototype, "size", 2), e([_({
2206
+ attribute: "no-format-toggle",
2207
+ type: Boolean
2208
+ })], R.prototype, "noFormatToggle", 2), e([_()], R.prototype, "name", 2), e([_({
2209
+ type: Boolean,
2210
+ reflect: !0
2211
+ })], R.prototype, "disabled", 2), e([_({ type: Boolean })], R.prototype, "hoist", 2), e([_({ type: Boolean })], R.prototype, "opacity", 2), e([_({ type: Boolean })], R.prototype, "uppercase", 2), e([_()], R.prototype, "swatches", 2), e([_({ reflect: !0 })], R.prototype, "form", 2), e([_({
2212
+ type: Boolean,
2213
+ reflect: !0
2214
+ })], R.prototype, "required", 2), e([_e({ passive: !1 })], R.prototype, "handleTouchMove", 1), e([t("format", { waitUntilFirstUpdate: !0 })], R.prototype, "handleFormatChange", 1), e([t("opacity", { waitUntilFirstUpdate: !0 })], R.prototype, "handleOpacityChange", 1), e([t("value")], R.prototype, "handleValueChange", 1), R.define("sl-color-picker");
2215
+ //#endregion
2216
+ //#region src/components/webmapx-draw-layer-dialog.ts
2217
+ var We = {
2218
+ Point: [
2219
+ "string",
2220
+ "number",
2221
+ "longitude",
2222
+ "latitude",
2223
+ "linkURL",
2224
+ "imageURL",
2225
+ "create-time",
2226
+ "update-time"
2227
+ ],
2228
+ LineString: [
2229
+ "string",
2230
+ "number",
2231
+ "length",
2232
+ "linkURL",
2233
+ "imageURL",
2234
+ "create-time",
2235
+ "update-time"
2236
+ ],
2237
+ Polygon: [
2238
+ "string",
2239
+ "number",
2240
+ "area",
2241
+ "perimeter",
2242
+ "longitude",
2243
+ "latitude",
2244
+ "linkURL",
2245
+ "imageURL",
2246
+ "create-time",
2247
+ "update-time"
2248
+ ]
2249
+ }, Ge = [{
2250
+ name: "id",
2251
+ type: "number"
2252
+ }, {
2253
+ name: "name",
2254
+ type: "string"
2255
+ }], Ke = {
2256
+ Point: "#0f62fe",
2257
+ LineString: "#0f62fe",
2258
+ Polygon: "#0f62fe"
2259
+ };
2260
+ function z(e) {
2261
+ return {
2262
+ id: `layer-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
2263
+ name: "",
2264
+ type: e,
2265
+ color: Ke[e],
2266
+ properties: Ge.map((e) => ({ ...e }))
2267
+ };
2268
+ }
2269
+ var B = class extends he {
2270
+ constructor(...e) {
2271
+ super(...e), this.geometryType = "Point", this.existingLayers = [], this.mapLayers = [], this.step = "select", this.selectedId = "new", this.layer = z("Point"), this.nameError = !1, this.newPropName = "", this.newPropType = "string", this.allowedAttributes = null;
2272
+ }
2273
+ static {
2274
+ this.styles = h`
2275
+ :host { display: block; }
2276
+
2277
+ sl-dialog::part(panel) {
2278
+ min-width: min(420px, 90vw);
2279
+ }
2280
+
2281
+ .layer-list {
2282
+ display: flex;
2283
+ flex-direction: column;
2284
+ gap: 0.25rem;
2285
+ max-height: 220px;
2286
+ overflow-y: auto;
2287
+ margin-bottom: 1rem;
2288
+ }
2289
+
2290
+ .layer-option {
2291
+ display: flex;
2292
+ align-items: center;
2293
+ gap: 0.5rem;
2294
+ padding: 0.4rem 0.6rem;
2295
+ border-radius: 4px;
2296
+ cursor: pointer;
2297
+ border: 1px solid transparent;
2298
+ font-size: 0.9rem;
2299
+ }
2300
+
2301
+ .layer-option:hover { background: var(--sl-color-neutral-100); }
2302
+
2303
+ .layer-option.selected {
2304
+ background: var(--sl-color-primary-100);
2305
+ border-color: var(--sl-color-primary-400);
2306
+ }
2307
+
2308
+ .color-dot {
2309
+ width: 12px; height: 12px;
2310
+ border-radius: 50%;
2311
+ flex-shrink: 0;
2312
+ }
2313
+
2314
+ .new-icon { color: var(--sl-color-neutral-500); font-size: 1rem; }
2315
+
2316
+ .prop-table {
2317
+ width: 100%;
2318
+ border-collapse: collapse;
2319
+ font-size: 0.85rem;
2320
+ margin-top: 0.5rem;
2321
+ }
2322
+
2323
+ .prop-table th {
2324
+ text-align: left;
2325
+ background: var(--sl-color-neutral-100);
2326
+ padding: 0.25rem 0.4rem;
2327
+ border-bottom: 1px solid var(--sl-color-neutral-200);
2328
+ }
2329
+
2330
+ .prop-table td {
2331
+ padding: 0.2rem 0.4rem;
2332
+ border-bottom: 1px solid var(--sl-color-neutral-100);
2333
+ vertical-align: middle;
2334
+ }
2335
+
2336
+ .prop-table tr:last-child td { border-bottom: none; }
2337
+
2338
+ .prop-row-auto td { color: var(--sl-color-neutral-400); font-style: italic; }
2339
+
2340
+ .type-computed { color: var(--sl-color-primary-600); font-size: 0.75rem; }
2341
+
2342
+ .add-row td { background: var(--sl-color-neutral-50); }
2343
+
2344
+ .add-row sl-input,
2345
+ .add-row sl-select { font-size: 0.85rem; }
2346
+
2347
+ .name-input-row {
2348
+ display: flex;
2349
+ align-items: center;
2350
+ gap: 0.5rem;
2351
+ margin-bottom: 0.75rem;
2352
+ }
2353
+
2354
+ .color-swatch {
2355
+ width: 32px; height: 32px;
2356
+ border-radius: 4px;
2357
+ border: 1px solid var(--sl-color-neutral-300);
2358
+ cursor: pointer;
2359
+ flex-shrink: 0;
2360
+ }
2361
+
2362
+ .footer {
2363
+ display: flex;
2364
+ justify-content: flex-end;
2365
+ gap: 0.5rem;
2366
+ margin-top: 1rem;
2367
+ }
2368
+
2369
+ .error-msg {
2370
+ color: var(--sl-color-danger-600);
2371
+ font-size: 0.8rem;
2372
+ margin-top: 0.25rem;
2373
+ }
2374
+ `;
2375
+ }
2376
+ open() {
2377
+ this.step = "select", this.selectedId = this.existingLayers.length === 0 ? "new" : this.existingLayers[0].id, this.layer = z(this.geometryType), this.newPropName = "", this.newPropType = "string", this.nameError = !1, this.dialog?.show();
2378
+ }
2379
+ close() {
2380
+ this.dialog?.hide();
2381
+ }
2382
+ selectOption(e) {
2383
+ this.selectedId = e;
2384
+ }
2385
+ goToDetail() {
2386
+ if (this.selectedId === "new") this.layer = z(this.geometryType), this.allowedAttributes = null;
2387
+ else {
2388
+ let e = this.existingLayers.find((e) => e.id === this.selectedId);
2389
+ if (e) this.layer = {
2390
+ ...e,
2391
+ properties: e.properties.map((e) => ({ ...e }))
2392
+ }, this.allowedAttributes = null;
2393
+ else {
2394
+ let e = this.mapLayers.find((e) => e.layerId === this.selectedId);
2395
+ this.layer = {
2396
+ ...z(this.geometryType),
2397
+ name: e?.label ?? this.selectedId,
2398
+ properties: e?.properties?.map((e) => ({ ...e })) ?? Ge.map((e) => ({ ...e })),
2399
+ borrowedSourceId: e?.sourceId
2400
+ }, this.allowedAttributes = e?.allowedAttributes ?? null;
2401
+ }
2402
+ }
2403
+ this.step = "detail", this.updateComplete.then(() => this.renderRoot.querySelector("sl-input[name=\"layername\"]")?.focus());
2404
+ }
2405
+ goBack() {
2406
+ this.step = "select";
2407
+ }
2408
+ addProperty() {
2409
+ this.newPropName.trim() && (this.layer = {
2410
+ ...this.layer,
2411
+ properties: [...this.layer.properties, {
2412
+ name: this.newPropName.trim(),
2413
+ type: this.newPropType
2414
+ }]
2415
+ }, this.newPropName = "", this.newPropType = "string");
2416
+ }
2417
+ removeProperty(e) {
2418
+ let t = [...this.layer.properties];
2419
+ t.splice(e, 1), this.layer = {
2420
+ ...this.layer,
2421
+ properties: t
2422
+ };
2423
+ }
2424
+ confirm() {
2425
+ let e = this.renderRoot.querySelector("sl-input[name=\"layername\"]")?.value?.trim() ?? this.layer.name;
2426
+ if (!e) {
2427
+ this.nameError = !0, this.requestUpdate();
2428
+ return;
2429
+ }
2430
+ this.nameError = !1;
2431
+ let t = this.newPropName.trim(), n = t ? [...this.layer.properties, {
2432
+ name: t,
2433
+ type: this.newPropType
2434
+ }] : [...this.layer.properties], r = {
2435
+ ...this.layer,
2436
+ name: e,
2437
+ properties: n
2438
+ };
2439
+ this.dispatchEvent(new CustomEvent("webmapx-draw-layer-confirm", {
2440
+ detail: r,
2441
+ bubbles: !0,
2442
+ composed: !0
2443
+ })), this.dialog.hide();
2444
+ }
2445
+ cancel() {
2446
+ this.dispatchEvent(new CustomEvent("webmapx-draw-layer-cancel", {
2447
+ bubbles: !0,
2448
+ composed: !0
2449
+ })), this.dialog.hide();
2450
+ }
2451
+ renderSelectStep() {
2452
+ let e = this.geometryType === "LineString" ? "Line" : this.geometryType;
2453
+ return g`
2454
+ <div class="layer-list">
2455
+ <div class="layer-option ${this.selectedId === "new" ? "selected" : ""}"
2456
+ @click=${() => this.selectOption("new")}
2457
+ @dblclick=${() => {
2458
+ this.selectOption("new"), this.goToDetail();
2459
+ }}>
2460
+ <span class="new-icon">+</span>
2461
+ <span>New ${e} layer</span>
2462
+ </div>
2463
+ ${this.existingLayers.map((e) => g`
2464
+ <div class="layer-option ${this.selectedId === e.id ? "selected" : ""}"
2465
+ @click=${() => this.selectOption(e.id)}
2466
+ @dblclick=${() => {
2467
+ this.selectOption(e.id), this.goToDetail();
2468
+ }}>
2469
+ <span class="color-dot" style="background:${e.color}"></span>
2470
+ <span>${e.name}</span>
2471
+ </div>
2472
+ `)}
2473
+ ${this.mapLayers.length > 0 ? g`
2474
+ <div style="font-size:0.72rem;color:var(--sl-color-neutral-500);padding:0.4rem 0.2rem 0.1rem;text-transform:uppercase;letter-spacing:0.05em">Map layers</div>
2475
+ ${this.mapLayers.map((e) => g`
2476
+ <div class="layer-option ${this.selectedId === e.layerId ? "selected" : ""}"
2477
+ @click=${() => this.selectOption(e.layerId)}
2478
+ @dblclick=${() => {
2479
+ this.selectOption(e.layerId), this.goToDetail();
2480
+ }}>
2481
+ <span class="new-icon" style="color:var(--sl-color-warning-600)">✎</span>
2482
+ <span>${e.label}</span>
2483
+ <span style="font-size:0.7rem;color:var(--sl-color-neutral-400);margin-left:auto">map layer</span>
2484
+ </div>
2485
+ `)}
2486
+ ` : ""}
2487
+ </div>
2488
+ <div class="footer">
2489
+ <sl-button @click=${this.cancel}>Cancel</sl-button>
2490
+ <sl-button autofocus variant="primary" @click=${this.goToDetail}>Next →</sl-button>
2491
+ </div>
2492
+ `;
2493
+ }
2494
+ renderDetailStep() {
2495
+ let e = We[this.geometryType], t = {
2496
+ longitude: "longitude (auto)",
2497
+ latitude: "latitude (auto)",
2498
+ area: "area (auto)",
2499
+ perimeter: "perimeter (auto)",
2500
+ length: "length (auto)",
2501
+ linkURL: "link URL",
2502
+ imageURL: "image URL",
2503
+ "create-time": "create-time (auto)",
2504
+ "update-time": "update-time (auto)"
2505
+ };
2506
+ return g`
2507
+ <div class="name-input-row">
2508
+ <sl-input name="layername"
2509
+ style="flex:1"
2510
+ placeholder="Layer name"
2511
+ aria-label="Layer name"
2512
+ value=${this.layer.name}
2513
+ @keydown=${(e) => e.key === "Enter" && this.renderRoot.querySelector("#new-prop-name")?.focus()}
2514
+ ></sl-input>
2515
+ <div class="color-swatch"
2516
+ style="background:${this.layer.color}"
2517
+ title="Layer color"
2518
+ @click=${() => this.renderRoot.querySelector("input[type=color]")?.click()}>
2519
+ </div>
2520
+ <input type="color" style="display:none" .value=${this.layer.color}
2521
+ @input=${(e) => {
2522
+ this.layer = {
2523
+ ...this.layer,
2524
+ color: e.target.value
2525
+ };
2526
+ }}>
2527
+ </div>
2528
+ ${this.nameError ? g`<div class="error-msg">Enter a layer name.</div>` : ""}
2529
+
2530
+ <table class="prop-table">
2531
+ <thead>
2532
+ <tr><th>Property</th><th>Type</th><th style="width:2rem"></th></tr>
2533
+ </thead>
2534
+ <tbody>
2535
+ ${this.layer.properties.map((e, t) => g`
2536
+ <tr class="${e.name === "id" ? "prop-row-auto" : ""}">
2537
+ <td>${e.name}</td>
2538
+ <td class="${[
2539
+ "string",
2540
+ "number",
2541
+ "linkURL",
2542
+ "imageURL"
2543
+ ].includes(e.type) ? "" : "type-computed"}">${e.type}${e.name === "id" ? " (auto)" : ""}</td>
2544
+ <td>
2545
+ ${t === 0 ? "" : g`
2546
+ <sl-icon-button name="x" @click=${() => this.removeProperty(t)}></sl-icon-button>
2547
+ `}
2548
+ </td>
2549
+ </tr>
2550
+ `)}
2551
+ <tr class="add-row">
2552
+ <td>
2553
+ ${this.allowedAttributes ? g`
2554
+ <sl-select id="new-prop-name" size="small" aria-label="Property name"
2555
+ .value=${this.newPropName}
2556
+ @sl-change=${(e) => this.newPropName = e.target.value}>
2557
+ <sl-option value="">— select —</sl-option>
2558
+ ${this.allowedAttributes.filter((e) => !this.layer.properties.find((t) => t.name === e)).map((e) => g`<sl-option value=${e}>${e}</sl-option>`)}
2559
+ </sl-select>
2560
+ ` : g`
2561
+ <sl-input id="new-prop-name" size="small" placeholder="property name" aria-label="Property name"
2562
+ .value=${this.newPropName}
2563
+ @sl-input=${(e) => this.newPropName = e.target.value}
2564
+ @keydown=${(e) => e.key === "Enter" && this.addProperty()}>
2565
+ </sl-input>
2566
+ `}
2567
+ </td>
2568
+ <td>
2569
+ <sl-select id="new-prop-type" size="small" .value=${this.newPropType}
2570
+ @sl-change=${(e) => this.newPropType = e.target.value}>
2571
+ ${e.map((e) => g`<sl-option value=${e}>${t[e] ?? e}</sl-option>`)}
2572
+ </sl-select>
2573
+ </td>
2574
+ <td>
2575
+ <sl-icon-button name="plus" @click=${this.addProperty}></sl-icon-button>
2576
+ </td>
2577
+ </tr>
2578
+ </tbody>
2579
+ </table>
2580
+
2581
+ <div class="footer">
2582
+ <sl-button @click=${this.goBack}>← Back</sl-button>
2583
+ <sl-button @click=${this.cancel}>Cancel</sl-button>
2584
+ <sl-button variant="primary" @click=${this.confirm}>OK</sl-button>
2585
+ </div>
2586
+ `;
2587
+ }
2588
+ render() {
2589
+ let e = this.geometryType === "LineString" ? "Line" : this.geometryType;
2590
+ return g`
2591
+ <sl-dialog label="${this.step === "select" ? `Select ${e} layer` : `Configure ${e} layer`}"
2592
+ @sl-request-close=${(e) => {
2593
+ e.detail?.source === "overlay" && this.cancel();
2594
+ }}>
2595
+ ${this.step === "select" ? this.renderSelectStep() : this.renderDetailStep()}
2596
+ </sl-dialog>
2597
+ `;
2598
+ }
2599
+ };
2600
+ a([_({ type: String })], B.prototype, "geometryType", void 0), a([_({ attribute: !1 })], B.prototype, "existingLayers", void 0), a([_({ attribute: !1 })], B.prototype, "mapLayers", void 0), a([y()], B.prototype, "step", void 0), a([y()], B.prototype, "selectedId", void 0), a([y()], B.prototype, "layer", void 0), a([y()], B.prototype, "nameError", void 0), a([y()], B.prototype, "newPropName", void 0), a([y()], B.prototype, "newPropType", void 0), a([y()], B.prototype, "allowedAttributes", void 0), a([v("sl-dialog")], B.prototype, "dialog", void 0), B = a([ge("webmapx-draw-layer-dialog")], B);
2601
+ //#endregion
2602
+ //#region src/utils/snap-utils.ts
2603
+ function qe(e) {
2604
+ return e.type === "Point" ? [e.coordinates] : e.type === "MultiPoint" || e.type === "LineString" ? e.coordinates : e.type === "MultiLineString" || e.type === "Polygon" ? e.coordinates.flat() : e.type === "MultiPolygon" ? e.coordinates.flat(2) : [];
2605
+ }
2606
+ function Je(e) {
2607
+ let t = [], n = (e) => {
2608
+ for (let n = 0; n < e.length - 1; n++) t.push([e[n], e[n + 1]]);
2609
+ };
2610
+ return e.type === "LineString" ? n(e.coordinates) : e.type === "MultiLineString" ? e.coordinates.forEach((e) => n(e)) : e.type === "Polygon" ? e.coordinates.forEach((e) => n(e)) : e.type === "MultiPolygon" && e.coordinates.forEach((e) => e.forEach((e) => n(e))), t;
2611
+ }
2612
+ function Ye(e, t, n, r = {}) {
2613
+ let i = r.threshold ?? 16, a = r.edgePenalty ?? 8, o = null, s = i;
2614
+ for (let r of t) {
2615
+ for (let t of qe(r)) {
2616
+ let r = n(t), i = Math.hypot(r[0] - e[0], r[1] - e[1]);
2617
+ i < s && (s = i, o = t);
2618
+ }
2619
+ for (let [t, i] of Je(r)) {
2620
+ let r = n(t), c = n(i), l = c[0] - r[0], u = c[1] - r[1], d = l * l + u * u;
2621
+ if (d === 0) continue;
2622
+ let f = Math.max(0, Math.min(1, ((e[0] - r[0]) * l + (e[1] - r[1]) * u) / d)), p = Math.hypot(r[0] + f * l - e[0], r[1] + f * u - e[1]);
2623
+ p + a < s && (s = p + a, o = [t[0] + f * (i[0] - t[0]), t[1] + f * (i[1] - t[1])]);
2624
+ }
2625
+ }
2626
+ return o;
2627
+ }
2628
+ //#endregion
2629
+ //#region src/components/webmapx-draw-tool.ts
2630
+ var V = "webmapx-draw-rubber-source", Xe = "webmapx-draw-rubber-line", H = "webmapx-draw-vertex-source", Ze = "webmapx-draw-vertex-layer";
2631
+ function U(e) {
2632
+ return `webmapx-draw-src-${e}`;
2633
+ }
2634
+ function Qe(e) {
2635
+ return `${e}-map`;
2636
+ }
2637
+ var W = "#888888", $e = "#ff3b30", et = 10, G = "webmapx-draw-sel-source", tt = "webmapx-draw-sel-point", K = "webmapx-draw-draft-source", nt = "webmapx-draw-draft-points", q = "webmapx-draw-edit-vert-source", rt = "webmapx-draw-edit-vert", J = "webmapx-draw-edit-mid-source", it = "webmapx-draw-edit-mid", Y = "webmapx-draw-sel-vert-source", at = "webmapx-draw-sel-vert", ot = 12, X = "webmapx-draw-snap-source", st = "webmapx-draw-snap-layer", ct = 16, Z = class extends pe {
2638
+ constructor(...e) {
2639
+ super(...e), this.toolId = "draw", this.mode = "select", this.drawLayers = [], this.features = [], this.selectedFeatureId = null, this.helpText = "", this.pendingMode = null, this.uiVersion = 0, this.draftPoints = [], this.draftRedoStack = [], this.cursorPos = null, this.activeLayerIds = {}, this.history = [], this.historyIndex = -1, this.sharedLayersCreated = !1, this.createdDrawLayerIds = /* @__PURE__ */ new Set(), this.touchMQ = window.matchMedia("(pointer: coarse)"), this.isTouchDevice = this.touchMQ.matches, this.onTouchMQChange = (e) => {
2640
+ this.isTouchDevice = e.matches;
2641
+ }, this.snapEnabled = !0, this.altActive = !1, this.snapPos = null, this.lastCursorPx = null, this.editState = "none", this.editHandles = [], this.hoveredHandle = null, this.dragging = null, this.selectedHandle = null, this.featureDrag = null, this.unsubClick = null, this.unsubMove = null, this.unsubCtx = null, this.unsubDown = null, this.unsubUp = null, this.exportFilename = "draw-export", this.exportMode = "combined", this.onKeyDown = (e) => {
2642
+ if (this.isRelevantTarget(e)) {
2643
+ if (e.key === "Alt") {
2644
+ e.preventDefault(), this.altActive || (this.altActive = !0, this.snapPos = null, this.updateRubberband(), this.updateSnapIndicator());
2645
+ return;
2646
+ }
2647
+ if (!this.isTypingTarget(e)) {
2648
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z") {
2649
+ e.preventDefault(), this.undoOrDraftBack();
2650
+ return;
2651
+ }
2652
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "y") {
2653
+ e.preventDefault(), this.redoOrDraftForward();
2654
+ return;
2655
+ }
2656
+ (e.key === "Delete" || e.key === "Backspace") && (this.draftPoints.length > 0 ? (e.preventDefault(), this.removeLastDraftPoint()) : this.selectedHandle ? (e.preventDefault(), this.deleteSelectedVertex()) : this.selectedFeatureId && (e.preventDefault(), this.deleteSelected()));
2657
+ }
2658
+ }
2659
+ }, this.onWindowBlur = () => {
2660
+ this.altActive && (this.altActive = !1, (this.mode === "draw-point" || this.mode === "draw-line" || this.mode === "draw-polygon") && this.updateRubberband());
2661
+ }, this.onKeyUp = (e) => {
2662
+ e.key === "Alt" && (this.altActive = !1, (this.mode === "draw-point" || this.mode === "draw-line" || this.mode === "draw-polygon") && this.updateRubberband());
2663
+ };
2664
+ }
2665
+ connectedCallback() {
2666
+ super.connectedCallback(), this.touchMQ.addEventListener("change", this.onTouchMQChange);
2667
+ }
2668
+ get effectiveSnap() {
2669
+ return this.snapEnabled && !this.altActive;
2670
+ }
2671
+ static {
2672
+ this.styles = h`
2673
+ :host {
2674
+ display: flex;
2675
+ flex-direction: column;
2676
+ padding: var(--webmapx-tool-padding, 0);
2677
+ min-width: 200px;
2678
+ max-height: var(--webmapx-draw-tool-max-height, 100%);
2679
+ overflow: hidden;
2680
+ }
2681
+
2682
+ .scroll-content {
2683
+ flex: 1;
2684
+ overflow-y: auto;
2685
+ min-height: 0;
2686
+ }
2687
+
2688
+ .toolbar {
2689
+ display: flex;
2690
+ gap: 0.25rem;
2691
+ flex-wrap: wrap;
2692
+ margin-bottom: 0.5rem;
2693
+ flex-shrink: 0;
2694
+ }
2695
+
2696
+ sl-icon-button[active]::part(base) {
2697
+ color: var(--sl-color-primary-600);
2698
+ background: var(--sl-color-primary-100);
2699
+ border-radius: 4px;
2700
+ }
2701
+
2702
+ .help {
2703
+ font-size: 0.8rem;
2704
+ color: var(--sl-color-neutral-600);
2705
+ margin-bottom: 0.5rem;
2706
+ min-height: 2.5em;
2707
+ }
2708
+
2709
+ .layers-section {
2710
+ margin-top: 0.5rem;
2711
+ }
2712
+
2713
+ .section-label {
2714
+ font-size: 0.7rem;
2715
+ text-transform: uppercase;
2716
+ letter-spacing: 0.06em;
2717
+ color: var(--sl-color-neutral-500);
2718
+ margin-bottom: 0.25rem;
2719
+ }
2720
+
2721
+ .layer-row {
2722
+ display: flex;
2723
+ align-items: center;
2724
+ gap: 0.4rem;
2725
+ padding: 0.2rem 0.4rem;
2726
+ border-radius: 4px;
2727
+ font-size: 0.85rem;
2728
+ cursor: pointer;
2729
+ }
2730
+
2731
+ .layer-row:hover {
2732
+ background: var(--sl-color-neutral-100);
2733
+ }
2734
+
2735
+ .remove-layer-btn {
2736
+ font-size: 0.75rem;
2737
+ opacity: 0;
2738
+ transition: opacity 0.1s;
2739
+ }
2740
+
2741
+ .layer-row:hover .remove-layer-btn {
2742
+ opacity: 1;
2743
+ }
2744
+
2745
+ .color-dot {
2746
+ width: 10px; height: 10px;
2747
+ border-radius: 50%;
2748
+ flex-shrink: 0;
2749
+ }
2750
+
2751
+ .layer-name { flex: 1; }
2752
+
2753
+ .layer-type {
2754
+ font-size: 0.7rem;
2755
+ color: var(--sl-color-neutral-500);
2756
+ }
2757
+
2758
+ .features-section {
2759
+ margin-top: 0.25rem;
2760
+ max-height: 180px;
2761
+ overflow-y: auto;
2762
+ }
2763
+
2764
+ .feature-row {
2765
+ display: flex;
2766
+ align-items: center;
2767
+ gap: 0.4rem;
2768
+ padding: 0.2rem 0.6rem;
2769
+ border-radius: 4px;
2770
+ cursor: pointer;
2771
+ font-size: 0.82rem;
2772
+ }
2773
+
2774
+ .feature-row:hover { background: var(--sl-color-neutral-100); }
2775
+ .feature-row.selected { background: var(--sl-color-primary-100); }
2776
+
2777
+ .divider {
2778
+ width: 1px; height: 1.2rem;
2779
+ background: var(--sl-color-neutral-200);
2780
+ margin: 0 0.1rem;
2781
+ }
2782
+
2783
+ .prop-row { display: flex; gap: 0.4rem; align-items: center; font-size: 0.82rem; margin-bottom: 0.2rem; }
2784
+ .prop-label { width: 80px; color: var(--sl-color-neutral-500); flex-shrink: 0; }
2785
+ .prop-value { flex: 1; min-width: 0; }
2786
+ .prop-link { display: block; width: 100%; font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2787
+ .prop-img { max-width: 100%; max-height: 80px; border-radius: 3px; object-fit: cover; }
2788
+ .prop-img-error { font-size: 0.75rem; color: var(--sl-color-danger-600, #c0392b); font-style: italic; }
2789
+ .prop-url-wrap { flex: 1; min-width: 0; overflow: hidden; display: flex; flex-direction: column; gap: 0.2rem; }
2790
+ `;
2791
+ }
2792
+ onActivate() {
2793
+ if (this.adapter?.store.getState().mapLoaded) this.createSharedLayers();
2794
+ else {
2795
+ let e = this.adapter?.store.subscribe((t) => {
2796
+ t.mapLoaded && (e?.(), this.createSharedLayers());
2797
+ });
2798
+ }
2799
+ for (let e of this.drawLayers) this.createdDrawLayerIds.has(e.id) || (this.addMapLayersForDrawLayer(e), this.refreshDrawLayerSource(e.id)), e.borrowedSourceId && this.adapter?.getSource(e.borrowedSourceId)?.setData({
2800
+ type: "FeatureCollection",
2801
+ features: []
2802
+ });
2803
+ this.bindEvents(), window.addEventListener("keydown", this.onKeyDown, !0), window.addEventListener("keyup", this.onKeyUp), window.addEventListener("blur", this.onWindowBlur), this.setModeInternal("select");
2804
+ }
2805
+ onDeactivate() {
2806
+ this.unbindEvents(), window.removeEventListener("keydown", this.onKeyDown, !0), window.removeEventListener("keyup", this.onKeyUp), window.removeEventListener("blur", this.onWindowBlur), this.altActive = !1;
2807
+ for (let e of this.drawLayers) e.borrowedSourceId && this.restoreBorrowedLayer(e), this.suspendDrawLayerFromMap(e);
2808
+ this.draftPoints = [], this.cursorPos = null, this.snapPos = null, this.lastCursorPx = null, this.dragging = null, this.featureDrag = null, this.selectedFeatureId = null, this.editState = "none", this.editHandles = [], this.hoveredHandle = null, this.adapter?.setPanEnabled(!0), this.adapter?.setDoubleClickZoomEnabled(!0), this.updateSelectedSource(), this.removeSharedLayers(), this.adapter?.setCursor("");
2809
+ }
2810
+ disconnectedCallback() {
2811
+ this.touchMQ.removeEventListener("change", this.onTouchMQChange), this.removeAllMapLayers(), super.disconnectedCallback();
2812
+ }
2813
+ onMapAttached(e) {
2814
+ super.onMapAttached(e);
2815
+ }
2816
+ onMapDetached() {
2817
+ this.removeAllMapLayers(), super.onMapDetached();
2818
+ }
2819
+ createSharedLayers() {
2820
+ if (!this.sharedLayersCreated) {
2821
+ this.dispatch("webmapx-add-source", {
2822
+ id: V,
2823
+ config: {
2824
+ type: "geojson",
2825
+ data: {
2826
+ type: "FeatureCollection",
2827
+ features: []
2828
+ }
2829
+ }
2830
+ }), this.dispatch("webmapx-add-source", {
2831
+ id: H,
2832
+ config: {
2833
+ type: "geojson",
2834
+ data: {
2835
+ type: "FeatureCollection",
2836
+ features: []
2837
+ }
2838
+ }
2839
+ }), this.dispatch("webmapx-add-layer", {
2840
+ id: Xe,
2841
+ type: "line",
2842
+ source: V,
2843
+ metadata: {
2844
+ isToolLayer: !0,
2845
+ hideFromLegend: !0
2846
+ },
2847
+ paint: {
2848
+ "line-color": "#0f62fe",
2849
+ "line-width": 2,
2850
+ "line-dasharray": [4, 4]
2851
+ }
2852
+ }), this.dispatch("webmapx-add-layer", {
2853
+ id: Ze,
2854
+ type: "circle",
2855
+ source: H,
2856
+ metadata: {
2857
+ isToolLayer: !0,
2858
+ hideFromLegend: !0
2859
+ },
2860
+ paint: {
2861
+ "circle-radius": 8,
2862
+ "circle-color": "transparent",
2863
+ "circle-stroke-width": 2,
2864
+ "circle-stroke-color": "#ff6600"
2865
+ }
2866
+ }), this.dispatch("webmapx-add-source", {
2867
+ id: G,
2868
+ config: {
2869
+ type: "geojson",
2870
+ data: {
2871
+ type: "FeatureCollection",
2872
+ features: []
2873
+ }
2874
+ }
2875
+ }), this.dispatch("webmapx-add-layer", {
2876
+ id: tt,
2877
+ type: "circle",
2878
+ source: G,
2879
+ metadata: {
2880
+ isToolLayer: !0,
2881
+ hideFromLegend: !0
2882
+ },
2883
+ paint: {
2884
+ "circle-radius": et,
2885
+ "circle-color": this.cssVar("--webmapx-draw-selected-color", $e)
2886
+ }
2887
+ }), this.dispatch("webmapx-add-source", {
2888
+ id: K,
2889
+ config: {
2890
+ type: "geojson",
2891
+ data: {
2892
+ type: "FeatureCollection",
2893
+ features: []
2894
+ }
2895
+ }
2896
+ }), this.dispatch("webmapx-add-layer", {
2897
+ id: nt,
2898
+ type: "circle",
2899
+ source: K,
2900
+ metadata: {
2901
+ isToolLayer: !0,
2902
+ hideFromLegend: !0
2903
+ },
2904
+ paint: {
2905
+ "circle-radius": 5,
2906
+ "circle-color": "#fff",
2907
+ "circle-stroke-width": 2,
2908
+ "circle-stroke-color": "#0f62fe"
2909
+ }
2910
+ }), this.dispatch("webmapx-add-source", {
2911
+ id: q,
2912
+ config: {
2913
+ type: "geojson",
2914
+ data: {
2915
+ type: "FeatureCollection",
2916
+ features: []
2917
+ }
2918
+ }
2919
+ }), this.dispatch("webmapx-add-layer", {
2920
+ id: rt,
2921
+ type: "circle",
2922
+ source: q,
2923
+ metadata: {
2924
+ isToolLayer: !0,
2925
+ hideFromLegend: !0
2926
+ },
2927
+ paint: {
2928
+ "circle-radius": 6,
2929
+ "circle-color": "#fff",
2930
+ "circle-stroke-width": 2,
2931
+ "circle-stroke-color": "#0f62fe"
2932
+ }
2933
+ }), this.dispatch("webmapx-add-source", {
2934
+ id: J,
2935
+ config: {
2936
+ type: "geojson",
2937
+ data: {
2938
+ type: "FeatureCollection",
2939
+ features: []
2940
+ }
2941
+ }
2942
+ }), this.dispatch("webmapx-add-layer", {
2943
+ id: it,
2944
+ type: "circle",
2945
+ source: J,
2946
+ metadata: {
2947
+ isToolLayer: !0,
2948
+ hideFromLegend: !0
2949
+ },
2950
+ paint: {
2951
+ "circle-radius": 4,
2952
+ "circle-color": "#fff",
2953
+ "circle-stroke-width": 1.5,
2954
+ "circle-stroke-color": "#0f62fe",
2955
+ "circle-opacity": .7
2956
+ }
2957
+ }), this.dispatch("webmapx-add-source", {
2958
+ id: Y,
2959
+ config: {
2960
+ type: "geojson",
2961
+ data: {
2962
+ type: "FeatureCollection",
2963
+ features: []
2964
+ }
2965
+ }
2966
+ }), this.dispatch("webmapx-add-layer", {
2967
+ id: at,
2968
+ type: "circle",
2969
+ source: Y,
2970
+ metadata: {
2971
+ isToolLayer: !0,
2972
+ hideFromLegend: !0
2973
+ },
2974
+ paint: {
2975
+ "circle-radius": et,
2976
+ "circle-color": this.cssVar("--webmapx-draw-selected-color", $e),
2977
+ "circle-stroke-width": 2,
2978
+ "circle-stroke-color": "#fff"
2979
+ }
2980
+ }), this.dispatch("webmapx-add-source", {
2981
+ id: X,
2982
+ config: {
2983
+ type: "geojson",
2984
+ data: {
2985
+ type: "FeatureCollection",
2986
+ features: []
2987
+ }
2988
+ }
2989
+ }), this.dispatch("webmapx-add-layer", {
2990
+ id: st,
2991
+ type: "circle",
2992
+ source: X,
2993
+ metadata: {
2994
+ isToolLayer: !0,
2995
+ hideFromLegend: !0
2996
+ },
2997
+ paint: {
2998
+ "circle-radius": 7,
2999
+ "circle-color": "#ffdd00",
3000
+ "circle-stroke-width": 2,
3001
+ "circle-stroke-color": "#fff",
3002
+ "circle-opacity": .9
3003
+ }
3004
+ }), this.sharedLayersCreated = !0;
3005
+ for (let e of this.drawLayers) this.addMapLayersForDrawLayer(e), this.refreshDrawLayerSource(e.id);
3006
+ }
3007
+ }
3008
+ addMapLayersForDrawLayer(e) {
3009
+ if (this.createdDrawLayerIds.has(e.id)) return;
3010
+ let t = U(e.id);
3011
+ this.dispatch("webmapx-add-source", {
3012
+ id: t,
3013
+ config: {
3014
+ type: "geojson",
3015
+ data: {
3016
+ type: "FeatureCollection",
3017
+ features: []
3018
+ }
3019
+ }
3020
+ }), e.type === "Polygon" ? (this.dispatch("webmapx-add-layer", {
3021
+ id: e.id,
3022
+ type: "fill",
3023
+ source: t,
3024
+ title: e.name,
3025
+ metadata: {
3026
+ label: e.name,
3027
+ legendRole: "overlay",
3028
+ hideFromLegend: !0
3029
+ },
3030
+ paint: {
3031
+ "fill-color": e.color,
3032
+ "fill-opacity": .35
3033
+ }
3034
+ }), this.dispatch("webmapx-add-layer", {
3035
+ id: `${e.id}-outline`,
3036
+ type: "line",
3037
+ source: t,
3038
+ title: e.name,
3039
+ metadata: {
3040
+ label: e.name,
3041
+ legendRole: "overlay",
3042
+ hideFromLegend: !0
3043
+ },
3044
+ paint: {
3045
+ "line-color": e.color,
3046
+ "line-width": 2
3047
+ }
3048
+ })) : e.type === "LineString" ? this.dispatch("webmapx-add-layer", {
3049
+ id: e.id,
3050
+ type: "line",
3051
+ source: t,
3052
+ title: e.name,
3053
+ metadata: {
3054
+ label: e.name,
3055
+ legendRole: "overlay",
3056
+ hideFromLegend: !0
3057
+ },
3058
+ paint: {
3059
+ "line-color": e.color,
3060
+ "line-width": 2
3061
+ }
3062
+ }) : this.dispatch("webmapx-add-layer", {
3063
+ id: e.id,
3064
+ type: "circle",
3065
+ source: t,
3066
+ title: e.name,
3067
+ metadata: {
3068
+ label: e.name,
3069
+ legendRole: "overlay",
3070
+ hideFromLegend: !0
3071
+ },
3072
+ paint: {
3073
+ "circle-radius": 6,
3074
+ "circle-color": e.color,
3075
+ "circle-stroke-width": 2,
3076
+ "circle-stroke-color": "#fff"
3077
+ }
3078
+ }), this.createdDrawLayerIds.add(e.id), e.type === "Polygon" && this.createdDrawLayerIds.add(`${e.id}-outline`);
3079
+ }
3080
+ removeMapLayersForDrawLayer(e) {
3081
+ e.type === "Polygon" && this.dispatch("webmapx-remove-layer", `${e.id}-outline`), this.dispatch("webmapx-remove-layer", e.id), this.dispatch("webmapx-remove-source", U(e.id)), this.adapter?.store && me(this.adapter.store, e.id), this.createdDrawLayerIds.delete(e.id), e.type === "Polygon" && this.createdDrawLayerIds.delete(`${e.id}-outline`);
3082
+ }
3083
+ removeSharedLayers() {
3084
+ for (let e of [
3085
+ Xe,
3086
+ Ze,
3087
+ tt,
3088
+ nt,
3089
+ rt,
3090
+ it,
3091
+ at,
3092
+ st
3093
+ ]) this.dispatch("webmapx-remove-layer", e);
3094
+ for (let e of [
3095
+ V,
3096
+ H,
3097
+ G,
3098
+ K,
3099
+ q,
3100
+ J,
3101
+ Y,
3102
+ X
3103
+ ]) this.dispatch("webmapx-remove-source", e);
3104
+ this.sharedLayersCreated = !1;
3105
+ }
3106
+ removeAllMapLayers() {
3107
+ this.removeSharedLayers();
3108
+ for (let e of this.drawLayers) this.removeMapLayersForDrawLayer(e);
3109
+ this.createdDrawLayerIds.clear();
3110
+ }
3111
+ refreshDrawLayerSource(e) {
3112
+ let t = this.features.filter((t) => t.layerId === e).map((e) => ({
3113
+ type: "Feature",
3114
+ id: e.id,
3115
+ geometry: {
3116
+ type: e.type,
3117
+ coordinates: e.coordinates
3118
+ },
3119
+ properties: e.properties
3120
+ }));
3121
+ this.dispatch("webmapx-set-source-data", {
3122
+ id: U(e),
3123
+ data: {
3124
+ type: "FeatureCollection",
3125
+ features: t
3126
+ }
3127
+ });
3128
+ }
3129
+ cssVar(e, t) {
3130
+ return getComputedStyle(this).getPropertyValue(e).trim() || t;
3131
+ }
3132
+ get modKey() {
3133
+ return /Mac|iPhone|iPad/.test(navigator.platform) ? "Cmd" : "Ctrl";
3134
+ }
3135
+ isTypingTarget(e) {
3136
+ let t = e.composedPath()[0], n = t?.tagName?.toLowerCase();
3137
+ return n === "input" || n === "textarea" || n === "sl-input" || n === "sl-textarea" || t?.isContentEditable === !0;
3138
+ }
3139
+ isRelevantTarget(e) {
3140
+ let t = e.composedPath(), n = this.mapHost;
3141
+ if (t.includes(this) || n && t.includes(n)) return !0;
3142
+ let r = t[0];
3143
+ return r === document.body || r === document.documentElement;
3144
+ }
3145
+ bindEvents() {
3146
+ this.adapter && (this.unsubClick = this.adapter.events.on("click", (e) => this.handleClick(e)), this.unsubMove = this.adapter.events.on("pointer-move", (e) => this.handlePointerMove(e)), this.unsubCtx = this.adapter.events.on("contextmenu", (e) => this.handleContextMenu(e)), this.unsubDown = this.adapter.events.on("pointer-down", (e) => this.handlePointerDown(e)), this.unsubUp = this.adapter.events.on("pointer-up", (e) => this.handlePointerUp(e)));
3147
+ }
3148
+ unbindEvents() {
3149
+ this.unsubClick?.(), this.unsubClick = null, this.unsubMove?.(), this.unsubMove = null, this.unsubCtx?.(), this.unsubCtx = null, this.unsubDown?.(), this.unsubDown = null, this.unsubUp?.(), this.unsubUp = null;
3150
+ }
3151
+ async requestDrawMode(e) {
3152
+ let t = Q(e);
3153
+ if (!t) {
3154
+ this.setModeInternal(e);
3155
+ return;
3156
+ }
3157
+ if (this.activeLayerIds[t]) {
3158
+ this.setModeInternal(e);
3159
+ return;
3160
+ }
3161
+ await this.openLayerDialog(e);
3162
+ }
3163
+ async openLayerDialog(e) {
3164
+ let t = Q(e);
3165
+ if (!t) return;
3166
+ this.pendingMode = e;
3167
+ let n = this.drawLayers.filter((e) => e.type === t && !e.borrowedSourceId), r = this.adapter ? await this.getEditableMapLayers(t) : [], i = this.activeLayerIds[t], a = this.drawLayers.find((e) => e.id === i && e.borrowedSourceId), o = a?.borrowedSourceId, s = o ? r.find((e) => e.sourceId === o)?.layerId : void 0;
3168
+ if (a && s) {
3169
+ let e = r.find((e) => e.layerId === s);
3170
+ e && (e.properties = a.properties.map((e) => ({ ...e })));
3171
+ }
3172
+ this.layerDialog.geometryType = t, this.layerDialog.existingLayers = n, this.layerDialog.mapLayers = r, this.layerDialog.open(), s && (this.layerDialog.selectedId = s);
3173
+ }
3174
+ async getEditableMapLayers(e) {
3175
+ if (!this.adapter) return [];
3176
+ let t = this.adapter.store.getState().mapLayers ?? {}, n = /* @__PURE__ */ new Set(), r = [], i = this.activeLayerIds[e], a = new Set(this.drawLayers.filter((e) => e.borrowedSourceId && e.id !== i).map((e) => e.borrowedSourceId));
3177
+ for (let [i, o] of Object.entries(t)) {
3178
+ if (o.isToolLayer || this.createdDrawLayerIds.has(i)) continue;
3179
+ let t = typeof o.sourceId == "string" ? o.sourceId : null;
3180
+ if (!t || n.has(t) || a.has(t)) continue;
3181
+ let s = this.adapter.getSourceData(t);
3182
+ if (!s) continue;
3183
+ let c = await this.resolveFeatureCollection(s);
3184
+ if (typeof s == "string") {
3185
+ let a = c?.features[0]?.geometry?.type, s = a ? this.geometryFamilyForGeoJSONType(a) : null, l = this.geometryFamilyForLayerType(o.layerType);
3186
+ if ((s ?? l) !== e) continue;
3187
+ n.add(t), r.push({
3188
+ layerId: i,
3189
+ sourceId: t,
3190
+ label: o.label ?? i,
3191
+ properties: o.properties ?? (c ? this.inferPropertyDefs(c) : void 0),
3192
+ allowedAttributes: o.attributes?.allowedAttributes ?? void 0
3193
+ });
3194
+ continue;
3195
+ }
3196
+ let l = s.features[0]?.geometry?.type, u = l ? this.geometryFamilyForGeoJSONType(l) : null, d = this.geometryFamilyForLayerType(o.layerType);
3197
+ (u ?? d) === e && (n.add(t), r.push({
3198
+ layerId: i,
3199
+ sourceId: t,
3200
+ label: o.label ?? i,
3201
+ properties: o.properties ?? this.inferPropertyDefs(s),
3202
+ allowedAttributes: o.attributes?.allowedAttributes ?? void 0
3203
+ }));
3204
+ }
3205
+ return r;
3206
+ }
3207
+ async resolveFeatureCollection(e) {
3208
+ if (typeof e != "string") return e;
3209
+ try {
3210
+ let t = await fetch(e);
3211
+ return t.ok ? await t.json() : null;
3212
+ } catch {
3213
+ return null;
3214
+ }
3215
+ }
3216
+ geometryFamilyForGeoJSONType(e) {
3217
+ return e === "Point" || e === "MultiPoint" ? "Point" : e === "LineString" || e === "MultiLineString" ? "LineString" : e === "Polygon" || e === "MultiPolygon" ? "Polygon" : null;
3218
+ }
3219
+ geometryFamilyForLayerType(e) {
3220
+ return e === "circle" ? "Point" : e === "line" ? "LineString" : e === "fill" ? "Polygon" : null;
3221
+ }
3222
+ inferPropertyDefs(e) {
3223
+ let t = e.features.find((e) => e.properties && Object.keys(e.properties).length > 0)?.properties;
3224
+ return t ? Object.entries(t).map(([e, t]) => ({
3225
+ name: e,
3226
+ type: typeof t == "number" ? "number" : "string"
3227
+ })) : [{
3228
+ name: "id",
3229
+ type: "number"
3230
+ }, {
3231
+ name: "name",
3232
+ type: "string"
3233
+ }];
3234
+ }
3235
+ setModeInternal(e) {
3236
+ switch (this.mode = e, this.draftPoints = [], this.cursorPos = null, this.snapPos = null, this.lastCursorPx = null, this.updateRubberband(), e) {
3237
+ case "select":
3238
+ this.adapter?.setDoubleClickZoomEnabled(!0), this.adapter?.setCursor(""), this.editState = "none", this.editHandles = [], this.updateEditHandles(), this.helpText = "Click a feature to select it.";
3239
+ break;
3240
+ case "draw-point":
3241
+ case "draw-line":
3242
+ case "draw-polygon":
3243
+ this.adapter?.setDoubleClickZoomEnabled(!1), this.editState = "none", this.editHandles = [], this.hoveredHandle = null, this.selectedFeatureId = null, this.updateEditHandles(), this.updateSelectedSource(), this.adapter?.setCursor("crosshair"), this.helpText = this.mode === "draw-point" ? "Click to place a point." : this.mode === "draw-line" ? "Click to add vertices. Right-click or double-click to finish." : "Click to add vertices. Click first point or double-click to close.";
3244
+ break;
3245
+ }
3246
+ }
3247
+ async handleLayerConfirm(e) {
3248
+ let t = e.detail, n = this.activeLayerIds[t.type];
3249
+ if (n && n !== t.id) {
3250
+ let e = this.drawLayers.find((e) => e.id === n);
3251
+ e && this.releaseLayer(e);
3252
+ }
3253
+ let r = this.drawLayers.findIndex((e) => e.id === t.id);
3254
+ if (r >= 0) this.drawLayers = this.drawLayers.map((e, n) => n === r ? t : e);
3255
+ else if (t.borrowedSourceId || (t = {
3256
+ ...t,
3257
+ borrowedSourceId: this.createPermLayer(t)
3258
+ }), this.drawLayers = [...this.drawLayers, t], this.addMapLayersForDrawLayer(t), t.borrowedSourceId && this.adapter) {
3259
+ let e = this.adapter.getSourceData(t.borrowedSourceId), n = e ? await this.resolveFeatureCollection(e) : null;
3260
+ if (n) {
3261
+ let e = [];
3262
+ for (let r of n.features) {
3263
+ if (!r.geometry || !lt(r.geometry.type)) continue;
3264
+ let n = { ...r.properties };
3265
+ e.push({
3266
+ id: this.newId(),
3267
+ layerId: t.id,
3268
+ type: r.geometry.type,
3269
+ coordinates: r.geometry.coordinates,
3270
+ properties: n
3271
+ });
3272
+ }
3273
+ if (this.features = [...this.features, ...e], t.properties.length <= 2) {
3274
+ let e = this.inferPropertyDefs(n);
3275
+ t = {
3276
+ ...t,
3277
+ properties: e
3278
+ }, this.drawLayers = this.drawLayers.map((e) => e.id === t.id ? t : e);
3279
+ }
3280
+ }
3281
+ this.adapter.getSource(t.borrowedSourceId)?.setData({
3282
+ type: "FeatureCollection",
3283
+ features: []
3284
+ });
3285
+ }
3286
+ this.activeLayerIds[t.type] = t.id, this.refreshDrawLayerSource(t.id);
3287
+ let i = Qe(t.id);
3288
+ if (this.adapter?.store) {
3289
+ let e = this.adapter.store.getState().mapLayers ?? {}, n = e[i];
3290
+ n && this.adapter.store.dispatch({ mapLayers: {
3291
+ ...e,
3292
+ [i]: {
3293
+ ...n,
3294
+ properties: t.properties
3295
+ }
3296
+ } }, "MAP");
3297
+ }
3298
+ this.pendingMode &&= (this.setModeInternal(this.pendingMode), null);
3299
+ }
3300
+ restoreBorrowedLayer(e) {
3301
+ if (!e.borrowedSourceId || !this.adapter) return;
3302
+ let t = this.features.filter((t) => t.layerId === e.id).map((e) => ({
3303
+ type: "Feature",
3304
+ geometry: {
3305
+ type: e.type,
3306
+ coordinates: e.coordinates
3307
+ },
3308
+ properties: { ...e.properties }
3309
+ }));
3310
+ this.adapter.getSource(e.borrowedSourceId)?.setData({
3311
+ type: "FeatureCollection",
3312
+ features: t
3313
+ });
3314
+ }
3315
+ createPermLayer(e) {
3316
+ let t = `webmapx-perm-src-${e.id}`;
3317
+ this.dispatch("webmapx-add-source", {
3318
+ id: t,
3319
+ config: {
3320
+ type: "geojson",
3321
+ data: {
3322
+ type: "FeatureCollection",
3323
+ features: []
3324
+ }
3325
+ }
3326
+ });
3327
+ let n = Qe(e.id);
3328
+ return e.type === "Polygon" ? (this.dispatch("webmapx-add-layer", {
3329
+ id: n,
3330
+ type: "fill",
3331
+ source: t,
3332
+ title: e.name,
3333
+ metadata: {
3334
+ label: e.name,
3335
+ legendRole: "overlay",
3336
+ properties: e.properties
3337
+ },
3338
+ paint: {
3339
+ "fill-color": W,
3340
+ "fill-opacity": .35
3341
+ }
3342
+ }), this.dispatch("webmapx-add-layer", {
3343
+ id: `${n}-outline`,
3344
+ type: "line",
3345
+ source: t,
3346
+ title: e.name,
3347
+ metadata: {
3348
+ label: e.name,
3349
+ legendRole: "overlay",
3350
+ hideFromLegend: !0,
3351
+ properties: e.properties
3352
+ },
3353
+ paint: {
3354
+ "line-color": W,
3355
+ "line-width": 2
3356
+ }
3357
+ })) : e.type === "LineString" ? this.dispatch("webmapx-add-layer", {
3358
+ id: n,
3359
+ type: "line",
3360
+ source: t,
3361
+ title: e.name,
3362
+ metadata: {
3363
+ label: e.name,
3364
+ legendRole: "overlay",
3365
+ properties: e.properties
3366
+ },
3367
+ paint: {
3368
+ "line-color": W,
3369
+ "line-width": 2
3370
+ }
3371
+ }) : this.dispatch("webmapx-add-layer", {
3372
+ id: n,
3373
+ type: "circle",
3374
+ source: t,
3375
+ title: e.name,
3376
+ metadata: {
3377
+ label: e.name,
3378
+ legendRole: "overlay",
3379
+ properties: e.properties
3380
+ },
3381
+ paint: {
3382
+ "circle-radius": 5,
3383
+ "circle-color": W,
3384
+ "circle-stroke-width": 1,
3385
+ "circle-stroke-color": "#555"
3386
+ }
3387
+ }), t;
3388
+ }
3389
+ releaseBorrowedLayer(e) {
3390
+ if (e.borrowedSourceId) {
3391
+ this.restoreBorrowedLayer(e), this.removeMapLayersForDrawLayer(e), this.features = this.features.filter((t) => t.layerId !== e.id), this.drawLayers = this.drawLayers.filter((t) => t.id !== e.id);
3392
+ for (let [t, n] of Object.entries(this.activeLayerIds)) n === e.id && delete this.activeLayerIds[t];
3393
+ }
3394
+ }
3395
+ suspendDrawLayerFromMap(e) {
3396
+ e.type === "Polygon" && this.dispatch("webmapx-remove-layer", `${e.id}-outline`), this.dispatch("webmapx-remove-layer", e.id), this.dispatch("webmapx-remove-source", U(e.id)), this.adapter?.store && me(this.adapter.store, e.id), this.createdDrawLayerIds.delete(e.id), e.type === "Polygon" && this.createdDrawLayerIds.delete(`${e.id}-outline`);
3397
+ }
3398
+ releaseLayer(e) {
3399
+ this.releaseBorrowedLayer(e);
3400
+ }
3401
+ removeFromEditing(e) {
3402
+ let t = this.activeLayerIds[e.type] === e.id;
3403
+ this.releaseLayer(e), t && this.setModeInternal("select");
3404
+ }
3405
+ handleLayerCancel() {
3406
+ this.pendingMode = null;
3407
+ }
3408
+ handleClick(e) {
3409
+ let t = this.effectiveSnap && this.snapPos ? this.snapPos : e.coords, n = Q(this.mode), r = n ? this.activeLayerIds[n] : null;
3410
+ if (!(!r && this.mode !== "select")) {
3411
+ if (this.mode === "draw-point") {
3412
+ this.commitFeature({
3413
+ id: this.newId(),
3414
+ layerId: r,
3415
+ type: "Point",
3416
+ coordinates: t,
3417
+ properties: this.defaultProperties(r)
3418
+ });
3419
+ return;
3420
+ }
3421
+ if (this.mode === "draw-line" || this.mode === "draw-polygon") {
3422
+ if (this.draftPoints.length >= 2) {
3423
+ let e = this.draftPoints[this.draftPoints.length - 1];
3424
+ if (this.withinPixelThreshold(t, e, 10) || this.mode === "draw-polygon" && this.withinPixelThreshold(t, this.draftPoints[0], 14)) {
3425
+ this.finishDraft(r);
3426
+ return;
3427
+ }
3428
+ }
3429
+ this.draftPoints.length === 0 && this.selectedFeatureId && (this.selectedFeatureId = null, this.editState = "none", this.editHandles = [], this.updateSelectedSource(), this.updateEditHandles()), this.draftPoints.push(t), this.draftRedoStack = [], this.uiVersion++, this.updateRubberband(), this.updateHelpTextDuring();
3430
+ return;
3431
+ }
3432
+ if (this.mode === "select") {
3433
+ let e = this.adapter.project(t), n = [e[0], e[1]], r = this.findFeatureAt(n, t);
3434
+ r && r.id === this.selectedFeatureId && this.editState === "selected" && (ut(r.type) || dt(r.type)) ? this.enterEditMode(r.id) : r && r.id === this.selectedFeatureId && this.editState === "editing" || (r ? (this.selectedFeatureId = r.id, this.editState = $(r.type) ? "editing" : "selected", this.editState === "selected" ? this.helpText = "Click again to edit vertices." : $(r.type) && (this.helpText = "Drag to move point."), this.updateSelectedSource(), this.updateEditHandles(), this.requestUpdate()) : this.editState === "editing" ? (this.editState = "selected", this.updateEditHandles(), this.requestUpdate()) : (this.selectedFeatureId = null, this.editState = "none", this.updateSelectedSource(), this.updateEditHandles(), this.requestUpdate()));
3435
+ }
3436
+ }
3437
+ }
3438
+ handlePointerMove(e) {
3439
+ if (this.cursorPos = e.coords, this.featureDrag) {
3440
+ let t = this.features.find((e) => e.id === this.featureDrag.featureId);
3441
+ if (t) {
3442
+ let n = e.coords[0] - this.featureDrag.startCoords[0], r = e.coords[1] - this.featureDrag.startCoords[1];
3443
+ t.coordinates = this.translateCoordsGeoPreserving(this.featureDrag.origCoords, t.type, n, r, this.featureDrag.origCentroidLng, this.featureDrag.origCentroidLat), this.refreshDrawLayerSource(t.layerId), this.updateEditHandles(), this.updateSelectedSource();
3444
+ }
3445
+ return;
3446
+ }
3447
+ if (this.dragging) {
3448
+ let t = this.features.find((e) => e.id === this.dragging.handle.featureId);
3449
+ if (t) {
3450
+ let n = e.coords;
3451
+ if (this.effectiveSnap && this.features.length > 0) {
3452
+ let r = this.adapter.project(e.coords), i = this.computeSnapExcluding([r[0], r[1]], this.dragging.handle.featureId, $(t.type));
3453
+ this.snapPos = i, i && (n = i);
3454
+ } else this.snapPos = null;
3455
+ this.applyDragMove(t, this.dragging.handle, n), this.dragging.lastCoords = e.coords, this.refreshDrawLayerSource(t.layerId), this.updateEditHandles(), this.updateSelectedSource(), this.updateSnapIndicator();
3456
+ let r = this.dragging.handle;
3457
+ this.selectedHandle && r.kind === "vertex" && this.selectedHandle.featureId === r.featureId && this.selectedHandle.partIdx === r.partIdx && this.selectedHandle.ringIdx === r.ringIdx && this.selectedHandle.vertIdx === r.vertIdx && (this.selectedHandle.coords = r.coords, this.updateSelectedVertexSource());
3458
+ }
3459
+ return;
3460
+ }
3461
+ if (this.mode === "draw-point" || this.mode === "draw-line" || this.mode === "draw-polygon") {
3462
+ if (this.effectiveSnap && this.features.length > 0) {
3463
+ let t = this.adapter.project(e.coords), n = [t[0], t[1]];
3464
+ (!this.lastCursorPx || Math.hypot(n[0] - this.lastCursorPx[0], n[1] - this.lastCursorPx[1]) > .5) && (this.lastCursorPx = n, this.snapPos = this.computeSnap(n));
3465
+ } else this.snapPos = null;
3466
+ this.updateRubberband();
3467
+ return;
3468
+ }
3469
+ if (this.mode === "select") {
3470
+ let t = this.adapter.project(e.coords), n = this.findFeatureAt([t[0], t[1]], e.coords);
3471
+ this.editState === "selected" && this.selectedFeatureId ? this.adapter?.setCursor(n?.id === this.selectedFeatureId ? "grab" : "") : this.editState === "none" && this.adapter?.setCursor(n ? "pointer" : "");
3472
+ }
3473
+ if (this.mode === "select" && this.editState === "editing" && this.editHandles.length > 0) {
3474
+ let t = this.adapter.project(e.coords), n = this.findHandleAt([t[0], t[1]]);
3475
+ n !== this.hoveredHandle && (this.hoveredHandle = n, this.adapter?.setCursor(n ? "grab" : ""));
3476
+ }
3477
+ }
3478
+ handlePointerDown(e) {
3479
+ if (e.button !== 0) return;
3480
+ if (this.editState === "selected" && this.selectedFeatureId) {
3481
+ let t = [e.pixel[0], e.pixel[1]], n = this.findFeatureAt(t, e.coords);
3482
+ if (n && n.id === this.selectedFeatureId) {
3483
+ let t = this.centroid(n);
3484
+ this.featureDrag = {
3485
+ featureId: n.id,
3486
+ startCoords: e.coords,
3487
+ origCoords: JSON.parse(JSON.stringify(n.coordinates)),
3488
+ origCentroidLat: t[1],
3489
+ origCentroidLng: t[0]
3490
+ }, this.adapter?.setPanEnabled(!1), this.adapter?.setCursor("grabbing");
3491
+ }
3492
+ return;
3493
+ }
3494
+ if (this.editState !== "editing") return;
3495
+ let t = [e.pixel[0], e.pixel[1]], n = this.findHandleAt(t);
3496
+ if (!n) {
3497
+ this.selectedHandle && (this.selectedHandle = null, this.updateSelectedVertexSource());
3498
+ return;
3499
+ }
3500
+ if (this.selectedHandle = n.kind === "vertex" ? n : null, this.updateSelectedVertexSource(), this.dragging = {
3501
+ handle: n,
3502
+ lastCoords: e.coords
3503
+ }, this.adapter?.setPanEnabled(!1), this.adapter?.setCursor("grabbing"), n.kind === "midpoint") {
3504
+ let t = this.features.find((e) => e.id === n.featureId);
3505
+ if (t) {
3506
+ this.insertVertex(t, n);
3507
+ let r = n.afterVertIdx + 1, i = {
3508
+ kind: "vertex",
3509
+ featureId: n.featureId,
3510
+ partIdx: n.partIdx,
3511
+ ringIdx: n.ringIdx,
3512
+ vertIdx: r,
3513
+ coords: n.coords
3514
+ };
3515
+ this.dragging = {
3516
+ handle: i,
3517
+ lastCoords: e.coords
3518
+ }, this.selectedHandle = i, this.updateSelectedVertexSource(), this.refreshDrawLayerSource(t.layerId), this.updateEditHandles();
3519
+ }
3520
+ }
3521
+ }
3522
+ handlePointerUp(e) {
3523
+ if (this.featureDrag) {
3524
+ let e = this.features.find((e) => e.id === this.featureDrag.featureId);
3525
+ if (e) {
3526
+ let t = this.drawLayers.find((t) => t.id === e.layerId);
3527
+ t && this.computeSpecialProperties(e, t), this.pushHistory({
3528
+ type: "update",
3529
+ features: [{ ...e }]
3530
+ }), this.features = [...this.features], this.refreshDrawLayerSource(e.layerId);
3531
+ }
3532
+ this.featureDrag = null, this.adapter?.setPanEnabled(!0), this.adapter?.setCursor("");
3533
+ return;
3534
+ }
3535
+ if (!this.dragging) return;
3536
+ this.snapPos = null, this.updateSnapIndicator(), this.adapter?.setPanEnabled(!0), this.adapter?.setCursor(this.hoveredHandle ? "grab" : "");
3537
+ let t = this.features.find((e) => e.id === this.dragging.handle.featureId);
3538
+ if (t) {
3539
+ let e = this.drawLayers.find((e) => e.id === t.layerId);
3540
+ e && this.computeSpecialProperties(t, e), this.pushHistory({
3541
+ type: "update",
3542
+ features: [{ ...t }]
3543
+ }), this.features = [...this.features], this.refreshDrawLayerSource(t.layerId);
3544
+ }
3545
+ this.dragging = null;
3546
+ }
3547
+ handleContextMenu(e) {
3548
+ let t = Q(this.mode), n = t ? this.activeLayerIds[t] : null;
3549
+ n && (this.mode === "draw-line" || this.mode === "draw-polygon") && this.finishDraft(n);
3550
+ }
3551
+ defaultProperties(e) {
3552
+ let t = this.drawLayers.find((t) => t.id === e);
3553
+ return t ? Object.fromEntries(t.properties.map((e) => [e.name, null])) : {};
3554
+ }
3555
+ finishDraft(e) {
3556
+ let t = this.draftPoints;
3557
+ if (this.mode === "draw-line" && t.length >= 2) this.commitFeature({
3558
+ id: this.newId(),
3559
+ layerId: e,
3560
+ type: "LineString",
3561
+ coordinates: t.map((e) => [e[0], e[1]]),
3562
+ properties: this.defaultProperties(e)
3563
+ }, t);
3564
+ else if (this.mode === "draw-polygon" && t.length >= 3) {
3565
+ let n = [...t.map((e) => [e[0], e[1]]), [t[0][0], t[0][1]]];
3566
+ this.commitFeature({
3567
+ id: this.newId(),
3568
+ layerId: e,
3569
+ type: "Polygon",
3570
+ coordinates: [n],
3571
+ properties: this.defaultProperties(e)
3572
+ }, t);
3573
+ }
3574
+ this.draftPoints = [], this.draftRedoStack = [], this.cursorPos = null, this.updateRubberband();
3575
+ }
3576
+ computeSnap(e) {
3577
+ return this.computeSnapExcluding(e, null, this.mode === "draw-point");
3578
+ }
3579
+ computeSnapExcluding(e, t, n) {
3580
+ return this.adapter ? Ye(e, this.features.filter((e) => e.id !== t && !(n && $(e.type))), (e) => {
3581
+ let t = this.adapter.project(e);
3582
+ return [t[0], t[1]];
3583
+ }, {
3584
+ threshold: ct,
3585
+ edgePenalty: 8
3586
+ }) : null;
3587
+ }
3588
+ updateSnapIndicator() {
3589
+ if (!this.sharedLayersCreated) return;
3590
+ let e = this.effectiveSnap && this.snapPos ? [{
3591
+ type: "Feature",
3592
+ geometry: {
3593
+ type: "Point",
3594
+ coordinates: this.snapPos
3595
+ },
3596
+ properties: {}
3597
+ }] : [];
3598
+ this.dispatch("webmapx-set-source-data", {
3599
+ id: X,
3600
+ data: {
3601
+ type: "FeatureCollection",
3602
+ features: e
3603
+ }
3604
+ });
3605
+ }
3606
+ updateRubberband() {
3607
+ if (!this.sharedLayersCreated) return;
3608
+ let e = [], t = [], n = this.mode === "draw-point" || this.mode === "draw-line" || this.mode === "draw-polygon", r = this.effectiveSnap && this.snapPos ? this.snapPos : this.cursorPos;
3609
+ if (n && this.draftPoints.length > 0 && r) {
3610
+ let n = [...this.draftPoints.map((e) => [e[0], e[1]]), [r[0], r[1]]];
3611
+ e.push({
3612
+ type: "Feature",
3613
+ geometry: {
3614
+ type: "LineString",
3615
+ coordinates: n
3616
+ },
3617
+ properties: {}
3618
+ });
3619
+ for (let e of this.draftPoints) t.push({
3620
+ type: "Feature",
3621
+ geometry: {
3622
+ type: "Point",
3623
+ coordinates: [e[0], e[1]]
3624
+ },
3625
+ properties: {}
3626
+ });
3627
+ }
3628
+ this.dispatch("webmapx-set-source-data", {
3629
+ id: V,
3630
+ data: {
3631
+ type: "FeatureCollection",
3632
+ features: e
3633
+ }
3634
+ }), this.dispatch("webmapx-set-source-data", {
3635
+ id: K,
3636
+ data: {
3637
+ type: "FeatureCollection",
3638
+ features: t
3639
+ }
3640
+ });
3641
+ let i = n && this.effectiveSnap && this.snapPos ? [{
3642
+ type: "Feature",
3643
+ geometry: {
3644
+ type: "Point",
3645
+ coordinates: this.snapPos
3646
+ },
3647
+ properties: {}
3648
+ }] : [];
3649
+ this.dispatch("webmapx-set-source-data", {
3650
+ id: X,
3651
+ data: {
3652
+ type: "FeatureCollection",
3653
+ features: i
3654
+ }
3655
+ });
3656
+ }
3657
+ updateSelectedSource() {
3658
+ if (!this.sharedLayersCreated) return;
3659
+ let e = this.features.find((e) => e.id === this.selectedFeatureId), t = e && $(e.type) ? [{
3660
+ type: "Feature",
3661
+ id: e.id,
3662
+ geometry: {
3663
+ type: e.type,
3664
+ coordinates: e.coordinates
3665
+ },
3666
+ properties: {}
3667
+ }] : [];
3668
+ this.dispatch("webmapx-set-source-data", {
3669
+ id: G,
3670
+ data: {
3671
+ type: "FeatureCollection",
3672
+ features: t
3673
+ }
3674
+ });
3675
+ }
3676
+ enterEditMode(e) {
3677
+ this.editState = "editing", this.helpText = "Drag points to move. Drag midpoints to add a point. Click a point and press Delete to remove it. Click empty to exit.", this.updateEditHandles(), this.adapter?.setCursor("default"), this.requestUpdate();
3678
+ }
3679
+ computeHandles(e) {
3680
+ let t = [];
3681
+ if (e.type === "Point") return t.push({
3682
+ kind: "vertex",
3683
+ featureId: e.id,
3684
+ partIdx: 0,
3685
+ ringIdx: 0,
3686
+ vertIdx: 0,
3687
+ coords: e.coordinates
3688
+ }), t;
3689
+ if (e.type === "MultiPoint") return e.coordinates.forEach((n, r) => {
3690
+ t.push({
3691
+ kind: "vertex",
3692
+ featureId: e.id,
3693
+ partIdx: r,
3694
+ ringIdx: 0,
3695
+ vertIdx: 0,
3696
+ coords: n
3697
+ });
3698
+ }), t;
3699
+ let n = (n, r, i, a) => {
3700
+ let o = a ? n.length - 1 : n.length;
3701
+ for (let s = 0; s < o; s++) {
3702
+ if (t.push({
3703
+ kind: "vertex",
3704
+ featureId: e.id,
3705
+ partIdx: r,
3706
+ ringIdx: i,
3707
+ vertIdx: s,
3708
+ coords: n[s]
3709
+ }), !a && s === o - 1) continue;
3710
+ let c = (s + 1) % o, l = [(n[s][0] + n[c][0]) / 2, (n[s][1] + n[c][1]) / 2];
3711
+ t.push({
3712
+ kind: "midpoint",
3713
+ featureId: e.id,
3714
+ partIdx: r,
3715
+ ringIdx: i,
3716
+ afterVertIdx: s,
3717
+ coords: l
3718
+ });
3719
+ }
3720
+ };
3721
+ return e.type === "LineString" ? n(e.coordinates, 0, 0, !1) : e.type === "MultiLineString" ? e.coordinates.forEach((e, t) => n(e, t, 0, !1)) : e.type === "Polygon" ? e.coordinates.forEach((e, t) => n(e, 0, t, !0)) : e.type === "MultiPolygon" && e.coordinates.forEach((e, t) => {
3722
+ e.forEach((e, r) => n(e, t, r, !0));
3723
+ }), t;
3724
+ }
3725
+ updateEditHandles() {
3726
+ if (!this.sharedLayersCreated) return;
3727
+ let e = this.selectedFeatureId ? this.features.find((e) => e.id === this.selectedFeatureId) : null;
3728
+ if (!e) {
3729
+ this.editHandles = [], this.selectedHandle = null, this.updateSelectedVertexSource(), this.dispatch("webmapx-set-source-data", {
3730
+ id: q,
3731
+ data: {
3732
+ type: "FeatureCollection",
3733
+ features: []
3734
+ }
3735
+ }), this.dispatch("webmapx-set-source-data", {
3736
+ id: J,
3737
+ data: {
3738
+ type: "FeatureCollection",
3739
+ features: []
3740
+ }
3741
+ });
3742
+ return;
3743
+ }
3744
+ this.selectedHandle && this.selectedHandle.featureId !== e.id && (this.selectedHandle = null, this.updateSelectedVertexSource()), this.editHandles = this.computeHandles(e);
3745
+ let t = this.editState === "editing", n = this.editHandles.filter((e) => e.kind === "vertex").map((e) => ({
3746
+ type: "Feature",
3747
+ geometry: {
3748
+ type: "Point",
3749
+ coordinates: e.coords
3750
+ },
3751
+ properties: {}
3752
+ })), r = t ? this.editHandles.filter((e) => e.kind === "midpoint").map((e) => ({
3753
+ type: "Feature",
3754
+ geometry: {
3755
+ type: "Point",
3756
+ coordinates: e.coords
3757
+ },
3758
+ properties: {}
3759
+ })) : [];
3760
+ this.dispatch("webmapx-set-source-data", {
3761
+ id: q,
3762
+ data: {
3763
+ type: "FeatureCollection",
3764
+ features: n
3765
+ }
3766
+ }), this.dispatch("webmapx-set-source-data", {
3767
+ id: J,
3768
+ data: {
3769
+ type: "FeatureCollection",
3770
+ features: r
3771
+ }
3772
+ });
3773
+ }
3774
+ findHandleAt(e) {
3775
+ let t = null, n = ot;
3776
+ for (let r of this.editHandles) {
3777
+ let i = this.adapter.project(r.coords), a = Math.hypot(e[0] - i[0], e[1] - i[1]);
3778
+ a < n && (n = a, t = r);
3779
+ }
3780
+ return t;
3781
+ }
3782
+ applyDragMove(e, t, n) {
3783
+ let r = JSON.parse(JSON.stringify(e.coordinates));
3784
+ if (t.kind !== "vertex") return;
3785
+ let { partIdx: i, ringIdx: a, vertIdx: o } = t;
3786
+ if (e.type === "Point") {
3787
+ e.coordinates = [n[0], n[1]], t.coords = n;
3788
+ return;
3789
+ } else if (e.type === "MultiPoint") r[i] = [n[0], n[1]];
3790
+ else if (e.type === "LineString") r[o] = [n[0], n[1]];
3791
+ else if (e.type === "MultiLineString") r[i][o] = [n[0], n[1]];
3792
+ else if (e.type === "Polygon") {
3793
+ r[a][o] = [n[0], n[1]];
3794
+ let e = r[a];
3795
+ o === 0 && (e[e.length - 1] = e[0]);
3796
+ } else if (e.type === "MultiPolygon") {
3797
+ r[i][a][o] = [n[0], n[1]];
3798
+ let e = r[i][a];
3799
+ o === 0 && (e[e.length - 1] = e[0]);
3800
+ }
3801
+ e.coordinates = r, t.coords = n;
3802
+ }
3803
+ translateCoordsGeoPreserving(e, t, n, r, i, a) {
3804
+ if (!isFinite(a) || !isFinite(i)) return this.translateCoords(e, t, n, r);
3805
+ let o = a + r, s = Math.cos(a * Math.PI / 180), c = Math.cos(o * Math.PI / 180), l = c > 1e-6 ? s / c : 1, u = i + n, d = (e) => [u + (e[0] - i) * l, e[1] + r];
3806
+ return t === "Point" ? d(e) : t === "MultiPoint" || t === "LineString" ? e.map(d) : t === "MultiLineString" ? e.map((e) => e.map(d)) : t === "Polygon" ? e.map((e) => e.map(d)) : t === "MultiPolygon" ? e.map((e) => e.map((e) => e.map(d))) : e;
3807
+ }
3808
+ translateCoords(e, t, n, r) {
3809
+ let i = (e) => [e[0] + n, e[1] + r];
3810
+ return t === "Point" ? i(e) : t === "MultiPoint" || t === "LineString" ? e.map(i) : t === "MultiLineString" ? e.map((e) => e.map(i)) : t === "Polygon" ? e.map((e) => e.map(i)) : t === "MultiPolygon" ? e.map((e) => e.map((e) => e.map(i))) : e;
3811
+ }
3812
+ insertVertex(e, t) {
3813
+ let n = JSON.parse(JSON.stringify(e.coordinates)), { partIdx: r, ringIdx: i, afterVertIdx: a } = t;
3814
+ e.type === "LineString" ? n.splice(a + 1, 0, [t.coords[0], t.coords[1]]) : e.type === "MultiLineString" ? n[r].splice(a + 1, 0, [t.coords[0], t.coords[1]]) : e.type === "Polygon" ? n[i].splice(a + 1, 0, [t.coords[0], t.coords[1]]) : e.type === "MultiPolygon" && n[r][i].splice(a + 1, 0, [t.coords[0], t.coords[1]]), e.coordinates = n, this.pushHistory({
3815
+ type: "update",
3816
+ features: [{ ...e }]
3817
+ });
3818
+ }
3819
+ updateSelectedVertexSource() {
3820
+ if (this.uiVersion++, !this.sharedLayersCreated) return;
3821
+ let e = this.selectedHandle ? [{
3822
+ type: "Feature",
3823
+ geometry: {
3824
+ type: "Point",
3825
+ coordinates: this.selectedHandle.coords
3826
+ },
3827
+ properties: {}
3828
+ }] : [];
3829
+ this.dispatch("webmapx-set-source-data", {
3830
+ id: Y,
3831
+ data: {
3832
+ type: "FeatureCollection",
3833
+ features: e
3834
+ }
3835
+ });
3836
+ }
3837
+ deleteSelectedVertex() {
3838
+ let e = this.selectedHandle;
3839
+ if (!e) return;
3840
+ let t = this.features.find((t) => t.id === e.featureId);
3841
+ if (!t) return;
3842
+ let n = JSON.parse(JSON.stringify(t.coordinates)), { partIdx: r, ringIdx: i, vertIdx: a } = e;
3843
+ if (t.type === "LineString") {
3844
+ if (n.length <= 2) return;
3845
+ n.splice(a, 1);
3846
+ } else if (t.type === "MultiLineString") {
3847
+ if (n[r].length <= 2) return;
3848
+ n[r].splice(a, 1);
3849
+ } else if (t.type === "Polygon") {
3850
+ let e = n[i];
3851
+ if (e.length - 1 <= 3) return;
3852
+ a === 0 || a === e.length - 1 ? (e.splice(e.length - 1, 1), e.splice(0, 1), e.push([...e[0]])) : e.splice(a, 1);
3853
+ } else if (t.type === "MultiPolygon") {
3854
+ let e = n[r][i];
3855
+ if (e.length - 1 <= 3) return;
3856
+ a === 0 || a === e.length - 1 ? (e.splice(e.length - 1, 1), e.splice(0, 1), e.push([...e[0]])) : e.splice(a, 1);
3857
+ } else if (t.type === "MultiPoint") {
3858
+ if (n.length <= 1) return;
3859
+ n.splice(r, 1);
3860
+ } else return;
3861
+ t.coordinates = n;
3862
+ let o = this.drawLayers.find((e) => e.id === t.layerId);
3863
+ o && this.computeSpecialProperties(t, o), this.pushHistory({
3864
+ type: "update",
3865
+ features: [{ ...t }]
3866
+ }), this.features = [...this.features], this.refreshDrawLayerSource(t.layerId), this.selectedHandle = null, this.updateSelectedVertexSource(), this.updateEditHandles();
3867
+ }
3868
+ commitFeature(e, t) {
3869
+ let n = this.features.filter((t) => t.layerId === e.layerId).reduce((e, t) => {
3870
+ let n = parseInt(String(t.properties.id ?? 0), 10);
3871
+ return isNaN(n) ? e : Math.max(e, n);
3872
+ }, 0);
3873
+ e.properties.id = n + 1;
3874
+ let r = this.drawLayers.find((t) => t.id === e.layerId);
3875
+ if (r && this.computeSpecialProperties(e, r), r) for (let t of r.properties) t.type === "create-time" && (e.properties[t.name] = Date.now());
3876
+ this.pushHistory(t ? {
3877
+ type: "finish",
3878
+ features: [e],
3879
+ draftPoints: t.map((e) => [e[0], e[1]])
3880
+ } : {
3881
+ type: "add",
3882
+ features: [e]
3883
+ }), this.features = [...this.features, e], this.refreshDrawLayerSource(e.layerId), this.setModeInternal(this.mode), this.selectedFeatureId = e.id, this.editState = $(e.type) ? "editing" : "selected", this.updateSelectedSource(), this.updateEditHandles();
3884
+ }
3885
+ deleteSelected() {
3886
+ if (!this.selectedFeatureId) return;
3887
+ let e = this.features.filter((e) => e.id === this.selectedFeatureId);
3888
+ this.pushHistory({
3889
+ type: "delete",
3890
+ features: e
3891
+ }), this.features = this.features.filter((e) => e.id !== this.selectedFeatureId), new Set(e.map((e) => e.layerId)).forEach((e) => this.refreshDrawLayerSource(e)), this.selectedFeatureId = null, this.editState = "none", this.editHandles = [], this.adapter?.setCursor(""), this.updateSelectedSource(), this.updateEditHandles();
3892
+ }
3893
+ pushHistory(e) {
3894
+ this.history = this.history.slice(0, this.historyIndex + 1), this.history.push(e), this.historyIndex = this.history.length - 1, this.uiVersion++;
3895
+ }
3896
+ removeLastDraftPoint() {
3897
+ this.draftRedoStack.push(this.draftPoints.pop()), this.uiVersion++, this.updateRubberband(), this.updateHelpTextDuring();
3898
+ }
3899
+ undoOrDraftBack() {
3900
+ this.draftPoints.length > 0 ? this.removeLastDraftPoint() : this.undo();
3901
+ }
3902
+ redoOrDraftForward() {
3903
+ this.draftRedoStack.length > 0 ? (this.draftPoints.push(this.draftRedoStack.pop()), this.uiVersion++, this.updateRubberband(), this.updateHelpTextDuring()) : this.redo();
3904
+ }
3905
+ undo() {
3906
+ if (this.historyIndex < 0) return;
3907
+ let e = this.history[this.historyIndex--];
3908
+ this.uiVersion++;
3909
+ let t = /* @__PURE__ */ new Set();
3910
+ if (e.type === "add" || e.type === "finish") {
3911
+ let n = new Set(e.features.map((e) => e.id));
3912
+ this.features = this.features.filter((e) => !n.has(e.id)), e.features.forEach((e) => t.add(e.layerId));
3913
+ } else e.type === "delete" ? (this.features = [...this.features, ...e.features], e.features.forEach((e) => t.add(e.layerId))) : e.type === "update" && (this.features = this.features.map((n) => {
3914
+ let r = e.features.find((e) => e.id === n.id);
3915
+ return r ? (t.add(n.layerId), {
3916
+ ...n,
3917
+ coordinates: r.coordinates
3918
+ }) : n;
3919
+ }));
3920
+ if (this.selectedFeatureId = null, this.editState = "none", this.updateSelectedSource(), this.updateEditHandles(), t.forEach((e) => this.refreshDrawLayerSource(e)), e.type === "finish" && e.draftPoints) {
3921
+ let t = e.features[0];
3922
+ this.mode = t.type === "LineString" ? "draw-line" : "draw-polygon", this.draftPoints = e.draftPoints.map((e) => [e[0], e[1]]), this.draftRedoStack = [], this.cursorPos = this.draftPoints[this.draftPoints.length - 1], this.updateRubberband(), this.updateHelpTextDuring();
3923
+ }
3924
+ }
3925
+ redo() {
3926
+ if (this.historyIndex >= this.history.length - 1) return;
3927
+ let e = this.history[++this.historyIndex];
3928
+ this.uiVersion++;
3929
+ let t = /* @__PURE__ */ new Set();
3930
+ if (e.type === "add" || e.type === "finish") this.features = [...this.features, ...e.features], e.features.forEach((e) => t.add(e.layerId));
3931
+ else if (e.type === "delete") {
3932
+ let n = new Set(e.features.map((e) => e.id));
3933
+ this.features = this.features.filter((e) => !n.has(e.id)), e.features.forEach((e) => t.add(e.layerId));
3934
+ } else e.type === "update" && (this.features = this.features.map((n) => {
3935
+ let r = e.features.find((e) => e.id === n.id);
3936
+ return r ? (t.add(n.layerId), {
3937
+ ...n,
3938
+ coordinates: r.coordinates
3939
+ }) : n;
3940
+ }));
3941
+ if (t.forEach((e) => this.refreshDrawLayerSource(e)), e.type === "finish") {
3942
+ let t = e.features[0];
3943
+ this.draftPoints = [], this.draftRedoStack = [], this.cursorPos = null, this.selectedFeatureId = t.id, this.editState = $(t.type) ? "editing" : "selected", this.updateSelectedSource(), this.updateEditHandles(), this.updateRubberband();
3944
+ }
3945
+ }
3946
+ exportGeoJSON() {
3947
+ this.exportFilename = "draw-export", this.exportMode = "combined", this.exportDialog.show();
3948
+ }
3949
+ async doExport() {
3950
+ this.exportDialog.hide();
3951
+ let e = this.exportFilename.trim() || "draw-export";
3952
+ if (this.drawLayers.length <= 1 || this.exportMode === "combined") {
3953
+ let t = {
3954
+ type: "FeatureCollection",
3955
+ features: this.features.map((e) => ({
3956
+ type: "Feature",
3957
+ id: e.id,
3958
+ geometry: {
3959
+ type: e.type,
3960
+ coordinates: e.coordinates
3961
+ },
3962
+ properties: {
3963
+ ...e.properties,
3964
+ _layer: this.drawLayers.find((t) => t.id === e.layerId)?.name ?? e.layerId
3965
+ }
3966
+ }))
3967
+ };
3968
+ this.downloadBlob(new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), `${e}.geojson`);
3969
+ } else {
3970
+ let t = new de(new ue("application/zip"));
3971
+ for (let e of this.drawLayers) {
3972
+ let n = {
3973
+ type: "FeatureCollection",
3974
+ features: this.features.filter((t) => t.layerId === e.id).map((e) => ({
3975
+ type: "Feature",
3976
+ id: e.id,
3977
+ geometry: {
3978
+ type: e.type,
3979
+ coordinates: e.coordinates
3980
+ },
3981
+ properties: { ...e.properties }
3982
+ }))
3983
+ }, r = e.name.replace(/[/\\?%*:|"<>]/g, "_");
3984
+ await t.add(`${r}.geojson`, new le(JSON.stringify(n, null, 2)));
3985
+ }
3986
+ this.downloadBlob(await t.close(), `${e}.zip`);
3987
+ }
3988
+ }
3989
+ downloadBlob(e, t) {
3990
+ let n = URL.createObjectURL(e), r = document.createElement("a");
3991
+ r.href = n, r.download = t, r.click(), URL.revokeObjectURL(n);
3992
+ }
3993
+ newId() {
3994
+ return `draw-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
3995
+ }
3996
+ computeSpecialProperties(e, t) {
3997
+ for (let n of t.properties) switch (n.type) {
3998
+ case "longitude":
3999
+ case "latitude": {
4000
+ let t = e.type === "Point" ? e.coordinates : this.centroid(e);
4001
+ e.properties[n.name] = n.type === "longitude" ? t[0] : t[1];
4002
+ break;
4003
+ }
4004
+ case "area":
4005
+ e.properties[n.name] = e.type === "Polygon" ? this.polygonArea(e.coordinates) : null;
4006
+ break;
4007
+ case "perimeter":
4008
+ case "length":
4009
+ e.properties[n.name] = e.type === "Polygon" ? this.ringLength(e.coordinates[0]) : e.type === "LineString" ? this.ringLength(e.coordinates, !1) : null;
4010
+ break;
4011
+ case "update-time":
4012
+ e.properties[n.name] = Date.now();
4013
+ break;
4014
+ }
4015
+ }
4016
+ centroid(e) {
4017
+ let t;
4018
+ switch (e.type) {
4019
+ case "Point":
4020
+ t = [e.coordinates];
4021
+ break;
4022
+ case "MultiPoint":
4023
+ t = e.coordinates;
4024
+ break;
4025
+ case "LineString":
4026
+ t = e.coordinates;
4027
+ break;
4028
+ case "MultiLineString":
4029
+ t = e.coordinates.flat();
4030
+ break;
4031
+ case "Polygon":
4032
+ t = e.coordinates[0];
4033
+ break;
4034
+ case "MultiPolygon":
4035
+ t = e.coordinates.flat(2);
4036
+ break;
4037
+ default: t = [];
4038
+ }
4039
+ if (t.length === 0) return [0, 0];
4040
+ let n = t.reduce((e, t) => [e[0] + t[0], e[1] + t[1]], [0, 0]);
4041
+ return [n[0] / t.length, n[1] / t.length];
4042
+ }
4043
+ haversineKm(e, t) {
4044
+ let n = (t[1] - e[1]) * Math.PI / 180, r = (t[0] - e[0]) * Math.PI / 180, i = Math.sin(n / 2) ** 2 + Math.cos(e[1] * Math.PI / 180) * Math.cos(t[1] * Math.PI / 180) * Math.sin(r / 2) ** 2;
4045
+ return 6371 * 2 * Math.atan2(Math.sqrt(i), Math.sqrt(1 - i));
4046
+ }
4047
+ ringLength(e, t = !0) {
4048
+ let n = 0, r = e.length - 1;
4049
+ for (let t = 0; t < r; t++) n += this.haversineKm(e[t], e[t + 1]);
4050
+ return Math.round(n * 1e3);
4051
+ }
4052
+ polygonArea(e) {
4053
+ let t = e[0], n = 0;
4054
+ for (let e = 0, r = t.length - 1; e < t.length; r = e++) n += (t[r][0] + t[e][0]) * (t[r][1] - t[e][1]);
4055
+ let r = Math.abs(n / 2), i = t[0][1] * Math.PI / 180;
4056
+ return Math.round(111320 * Math.cos(i) * r * 111320);
4057
+ }
4058
+ withinPixelThreshold(e, t, n) {
4059
+ if (!this.adapter) return !1;
4060
+ let r = this.adapter.project(e), i = this.adapter.project(t);
4061
+ return Math.hypot(r[0] - i[0], r[1] - i[1]) < n;
4062
+ }
4063
+ findFeatureAt(e, t) {
4064
+ for (let n of [...this.features].reverse()) if (n.type === "Point") {
4065
+ let t = this.adapter.project(n.coordinates);
4066
+ if (Math.hypot(t[0] - e[0], t[1] - e[1]) < 10) return n;
4067
+ } else if (n.type === "MultiPoint") for (let t of n.coordinates) {
4068
+ let r = this.adapter.project(t);
4069
+ if (Math.hypot(r[0] - e[0], r[1] - e[1]) < 10) return n;
4070
+ }
4071
+ else if (n.type === "LineString") {
4072
+ if (this.pixelNearPolyline(e, n.coordinates, 10)) return n;
4073
+ } else if (n.type === "MultiLineString") {
4074
+ if (n.coordinates.some((t) => this.pixelNearPolyline(e, t, 10))) return n;
4075
+ } else if (n.type === "Polygon") {
4076
+ if (this.pointInRing(t, n.coordinates[0]) || this.pixelNearPolyline(e, n.coordinates[0], 10)) return n;
4077
+ } else if (n.type === "MultiPolygon") for (let r of n.coordinates) {
4078
+ let i = r[0];
4079
+ if (i && (this.pointInRing(t, i) || this.pixelNearPolyline(e, i, 10))) return n;
4080
+ }
4081
+ return null;
4082
+ }
4083
+ pixelNearPolyline(e, t, n) {
4084
+ for (let r = 0; r < t.length - 1; r++) {
4085
+ let i = this.adapter.project(t[r]), a = this.adapter.project(t[r + 1]);
4086
+ if (this.distToSegment(e, i, a) < n) return !0;
4087
+ }
4088
+ return !1;
4089
+ }
4090
+ distToSegment(e, t, n) {
4091
+ let r = n[0] - t[0], i = n[1] - t[1];
4092
+ if (r === 0 && i === 0) return Math.hypot(e[0] - t[0], e[1] - t[1]);
4093
+ let a = Math.max(0, Math.min(1, ((e[0] - t[0]) * r + (e[1] - t[1]) * i) / (r * r + i * i)));
4094
+ return Math.hypot(e[0] - (t[0] + a * r), e[1] - (t[1] + a * i));
4095
+ }
4096
+ pointInRing(e, t) {
4097
+ let n = !1;
4098
+ for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
4099
+ let a = t[r][0], o = t[r][1], s = t[i][0], c = t[i][1];
4100
+ o > e[1] != c > e[1] && e[0] < (s - a) * (e[1] - o) / (c - o) + a && (n = !n);
4101
+ }
4102
+ return n;
4103
+ }
4104
+ dispatch(e, t) {
4105
+ this.dispatchEvent(new CustomEvent(e, {
4106
+ detail: t,
4107
+ bubbles: !0,
4108
+ composed: !0
4109
+ }));
4110
+ }
4111
+ updateHelpTextDuring() {
4112
+ let e = this.draftPoints.length;
4113
+ this.mode === "draw-line" ? this.helpText = `${e} pt${e === 1 ? "" : "s"}. Double-click or right-click to finish.` : this.mode === "draw-polygon" && (this.helpText = e >= 3 ? `${e} pts. Click first point, double-click, or right-click to close.` : `${e} pt${e === 1 ? "" : "s"}. Need at least 3 to close.`);
4114
+ }
4115
+ render() {
4116
+ let e = this.features.find((e) => e.id === this.selectedFeatureId), t = e ? this.drawLayers.find((t) => t.id === e.layerId) : null;
4117
+ return g`
4118
+ <div class="toolbar">
4119
+ <sl-tooltip content="Select">
4120
+ <sl-icon-button name="cursor"
4121
+ ?active=${this.mode === "select"}
4122
+ @click=${() => this.requestDrawMode("select")}>
4123
+ </sl-icon-button>
4124
+ </sl-tooltip>
4125
+ <sl-tooltip content="Draw point">
4126
+ <sl-icon-button name="geo-fill"
4127
+ ?active=${this.mode === "draw-point"}
4128
+ @click=${() => this.requestDrawMode("draw-point")}>
4129
+ </sl-icon-button>
4130
+ </sl-tooltip>
4131
+ <sl-tooltip content="Draw line">
4132
+ <sl-icon-button name="slash-lg"
4133
+ ?active=${this.mode === "draw-line"}
4134
+ @click=${() => this.requestDrawMode("draw-line")}>
4135
+ </sl-icon-button>
4136
+ </sl-tooltip>
4137
+ <sl-tooltip content="Draw polygon">
4138
+ <sl-icon-button name="pentagon"
4139
+ ?active=${this.mode === "draw-polygon"}
4140
+ @click=${() => this.requestDrawMode("draw-polygon")}>
4141
+ </sl-icon-button>
4142
+ </sl-tooltip>
4143
+
4144
+ <div class="divider"></div>
4145
+
4146
+ <sl-tooltip content="Snap to points and edges (${this.snapEnabled ? "on" : "off"}) — hold Alt to toggle">
4147
+ <sl-icon-button name="magnet"
4148
+ ?active=${this.effectiveSnap}
4149
+ @click=${() => {
4150
+ this.snapEnabled = !this.snapEnabled, this.snapEnabled || (this.snapPos = null, this.updateRubberband());
4151
+ }}>
4152
+ </sl-icon-button>
4153
+ </sl-tooltip>
4154
+
4155
+ <div class="divider"></div>
4156
+
4157
+ <sl-tooltip content="Undo (${this.modKey}+Z)">
4158
+ <sl-icon-button name="arrow-counterclockwise"
4159
+ ?disabled=${this.historyIndex < 0 && this.draftPoints.length === 0}
4160
+ @click=${() => this.undoOrDraftBack()}>
4161
+ </sl-icon-button>
4162
+ </sl-tooltip>
4163
+ <sl-tooltip content="Redo (${this.modKey}+Y)">
4164
+ <sl-icon-button name="arrow-clockwise"
4165
+ ?disabled=${this.historyIndex >= this.history.length - 1 && this.draftRedoStack.length === 0}
4166
+ @click=${() => this.redoOrDraftForward()}>
4167
+ </sl-icon-button>
4168
+ </sl-tooltip>
4169
+
4170
+ <div class="divider"></div>
4171
+
4172
+ <sl-tooltip content=${this.draftPoints.length > 0 ? "Remove last point" : this.selectedHandle ? "Delete selected point" : "Delete selected"}>
4173
+ <sl-icon-button name="trash"
4174
+ ?disabled=${this.draftPoints.length === 0 && !this.selectedFeatureId && !this.selectedHandle}
4175
+ @click=${() => this.draftPoints.length > 0 ? this.removeLastDraftPoint() : this.selectedHandle ? this.deleteSelectedVertex() : this.deleteSelected()}>
4176
+ </sl-icon-button>
4177
+ </sl-tooltip>
4178
+ <sl-tooltip content="Export GeoJSON">
4179
+ <sl-icon-button name="download"
4180
+ ?disabled=${this.features.length === 0}
4181
+ @click=${() => this.exportGeoJSON()}>
4182
+ </sl-icon-button>
4183
+ </sl-tooltip>
4184
+ </div>
4185
+
4186
+ <div class="scroll-content">
4187
+ <div class="help">${this.helpText}</div>
4188
+
4189
+ ${this.isTouchDevice && (this.mode === "draw-line" || this.mode === "draw-polygon") && this.draftPoints.length >= (this.mode === "draw-line" ? 2 : 3) ? g`
4190
+ <sl-button size="small" variant="primary" style="margin-bottom:.4rem;width:100%"
4191
+ @click=${() => {
4192
+ let e = Q(this.mode), t = e ? this.activeLayerIds[e] : null;
4193
+ t && this.finishDraft(t);
4194
+ }}>
4195
+ Finish
4196
+ </sl-button>
4197
+ ` : ""}
4198
+
4199
+ ${this.drawLayers.length > 0 ? g`
4200
+ <div class="layers-section">
4201
+ <div class="section-label">Editing</div>
4202
+ ${this.drawLayers.map((e) => g`
4203
+ <div class="layer-row" title="Click to change layer"
4204
+ @click=${() => this.openLayerDialog(e.type === "Point" ? "draw-point" : e.type === "LineString" ? "draw-line" : "draw-polygon")}>
4205
+ <span class="color-dot" style="background:${e.color}"></span>
4206
+ <span class="layer-name">${e.name}</span>
4207
+ <span class="layer-type">${e.type === "LineString" ? "Line" : e.type}</span>
4208
+ <small style="color:var(--sl-color-neutral-400);font-size:.7rem">${this.features.filter((t) => t.layerId === e.id).length}</small>
4209
+ ${this.drawLayers.length > 1 ? g`
4210
+ <sl-tooltip content="Stop editing">
4211
+ <sl-icon-button name="x" class="remove-layer-btn"
4212
+ @click=${(t) => {
4213
+ t.stopPropagation(), this.removeFromEditing(e);
4214
+ }}>
4215
+ </sl-icon-button>
4216
+ </sl-tooltip>
4217
+ ` : ""}
4218
+ </div>
4219
+ `)}
4220
+ </div>
4221
+ ` : ""}
4222
+
4223
+ ${e && t ? g`
4224
+ <div class="section-label" style="margin-top:.5rem">Selected: ${t.name}</div>
4225
+ ${t.properties.map((n) => g`
4226
+ <div class="prop-row">
4227
+ <span class="prop-label">${n.name}</span>
4228
+ ${n.name === "id" || [
4229
+ "longitude",
4230
+ "latitude",
4231
+ "area",
4232
+ "perimeter",
4233
+ "length",
4234
+ "create-time",
4235
+ "update-time"
4236
+ ].includes(n.type) ? g`<span class="prop-value" style="color:var(--sl-color-neutral-400);font-style:italic;padding:0 0.3rem">${["create-time", "update-time"].includes(n.type) ? e.properties[n.name] ? new Date(e.properties[n.name]).toLocaleString() : "—" : e.properties[n.name] ?? "—"}</span>` : n.type === "imageURL" ? g`<div class="prop-url-wrap">
4237
+ <sl-input size="small"
4238
+ .value=${String(e.properties[n.name] ?? "")}
4239
+ placeholder="image URL"
4240
+ @sl-change=${(r) => {
4241
+ e.properties[n.name] = r.target.value, t && this.computeSpecialProperties(e, t), this.features = [...this.features], this.refreshDrawLayerSource(e.layerId);
4242
+ }}></sl-input>
4243
+ ${e.properties[n.name] ? g`<img class="prop-img" src=${String(e.properties[n.name])} @error=${(e) => {
4244
+ let t = e.target, n = document.createElement("span");
4245
+ n.className = "prop-img-error", n.textContent = "⚠ invalid image", t.replaceWith(n);
4246
+ }}>` : ""}
4247
+ </div>` : n.type === "linkURL" ? g`<div class="prop-url-wrap">
4248
+ <sl-input size="small"
4249
+ .value=${String(e.properties[n.name] ?? "")}
4250
+ placeholder="link URL"
4251
+ @sl-change=${(r) => {
4252
+ e.properties[n.name] = r.target.value, t && this.computeSpecialProperties(e, t), this.features = [...this.features], this.refreshDrawLayerSource(e.layerId);
4253
+ }}></sl-input>
4254
+ ${e.properties[n.name] ? g`<a class="prop-link" href=${String(e.properties[n.name])} target="_blank" rel="noopener noreferrer">${e.properties[n.name]}</a>` : ""}
4255
+ </div>` : g`<sl-input size="small" class="prop-value"
4256
+ .value=${String(e.properties[n.name] ?? "")}
4257
+ @sl-change=${(r) => {
4258
+ e.properties[n.name] = r.target.value, t && this.computeSpecialProperties(e, t), this.features = [...this.features], this.refreshDrawLayerSource(e.layerId);
4259
+ }}></sl-input>`}
4260
+ </div>
4261
+ `)}
4262
+ ` : ""}
4263
+ </div>
4264
+
4265
+ <webmapx-draw-layer-dialog
4266
+ @webmapx-draw-layer-confirm=${this.handleLayerConfirm}
4267
+ @webmapx-draw-layer-cancel=${this.handleLayerCancel}>
4268
+ </webmapx-draw-layer-dialog>
4269
+
4270
+ <sl-dialog id="export-dialog" label="Export GeoJSON">
4271
+ <div class="prop-row">
4272
+ <span class="prop-label">Filename</span>
4273
+ <sl-input class="prop-value" size="small"
4274
+ .value=${this.exportFilename}
4275
+ @sl-input=${(e) => {
4276
+ this.exportFilename = e.target.value;
4277
+ }}>
4278
+ <span slot="suffix">${this.exportMode === "separate" ? ".zip" : ".geojson"}</span>
4279
+ </sl-input>
4280
+ </div>
4281
+ ${this.drawLayers.length > 1 ? g`
4282
+ <div style="margin-top:.6rem">
4283
+ <sl-radio-group label="Export as" .value=${this.exportMode}
4284
+ @sl-change=${(e) => {
4285
+ this.exportMode = e.target.value;
4286
+ }}>
4287
+ <sl-radio value="combined">Single GeoJSON file (all layers combined)</sl-radio>
4288
+ <sl-radio value="separate">Separate files per layer (ZIP archive)</sl-radio>
4289
+ </sl-radio-group>
4290
+ </div>
4291
+ ` : ""}
4292
+ <sl-button slot="footer" variant="primary" autofocus @click=${() => this.doExport()}>Download</sl-button>
4293
+ <sl-button slot="footer" variant="default" @click=${() => this.exportDialog.hide()}>Cancel</sl-button>
4294
+ </sl-dialog>
4295
+ `;
4296
+ }
4297
+ };
4298
+ a([y()], Z.prototype, "mode", void 0), a([y()], Z.prototype, "drawLayers", void 0), a([y()], Z.prototype, "features", void 0), a([y()], Z.prototype, "selectedFeatureId", void 0), a([y()], Z.prototype, "helpText", void 0), a([y()], Z.prototype, "pendingMode", void 0), a([y()], Z.prototype, "uiVersion", void 0), a([y()], Z.prototype, "isTouchDevice", void 0), a([y()], Z.prototype, "snapEnabled", void 0), a([y()], Z.prototype, "altActive", void 0), a([y()], Z.prototype, "editState", void 0), a([v("webmapx-draw-layer-dialog")], Z.prototype, "layerDialog", void 0), a([v("#export-dialog")], Z.prototype, "exportDialog", void 0), a([y()], Z.prototype, "exportFilename", void 0), a([y()], Z.prototype, "exportMode", void 0), Z = a([ge("webmapx-draw-tool")], Z);
4299
+ function Q(e) {
4300
+ return e === "draw-point" ? "Point" : e === "draw-line" ? "LineString" : e === "draw-polygon" ? "Polygon" : null;
4301
+ }
4302
+ function lt(e) {
4303
+ return e === "Point" || e === "MultiPoint" || e === "LineString" || e === "MultiLineString" || e === "Polygon" || e === "MultiPolygon";
4304
+ }
4305
+ function $(e) {
4306
+ return e === "Point" || e === "MultiPoint";
4307
+ }
4308
+ function ut(e) {
4309
+ return e === "LineString" || e === "MultiLineString";
4310
+ }
4311
+ function dt(e) {
4312
+ return e === "Polygon" || e === "MultiPolygon";
4313
+ }
4314
+ //#endregion
4315
+ export { Z as WebmapxDrawTool };