@edugis-org/webmapx 0.1.7 → 0.1.9

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