maplibre-gl-layer-control 0.18.0 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -370,7 +370,7 @@ function cacheOriginalLayerStyle(map, layerId, originalStyles) {
370
370
  }
371
371
  const paint = {};
372
372
  const style = map.getStyle();
373
- const layerDef = (_a = style.layers) == null ? void 0 : _a.find((l) => l.id === layerId);
373
+ const layerDef = (_a = style.layers) == null ? void 0 : _a.find((l2) => l2.id === layerId);
374
374
  if (layer.type === "raster") {
375
375
  const rasterDefaults = {
376
376
  "raster-opacity": 1,
@@ -417,36 +417,194 @@ function restoreOriginalStyle(map, layerId, originalStyles) {
417
417
  });
418
418
  return applied;
419
419
  }
420
- function rgbToHex(r, g, b) {
421
- const clamp2 = (v) => Math.max(0, Math.min(255, Math.round(v)));
422
- const toHex = (v) => {
423
- const hex = clamp2(v).toString(16);
420
+ for (var r = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, t = function(r2) {
421
+ return "string" == typeof r2 ? r2.length > 0 : "number" == typeof r2;
422
+ }, n = function(r2, t2, n2) {
423
+ return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r2) / n2 + 0;
424
+ }, u = function(r2, t2, n2) {
425
+ return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r2 > n2 ? n2 : r2 > t2 ? r2 : t2;
426
+ }, e$1 = function(r2) {
427
+ return (r2 = isFinite(r2) ? r2 % 360 : 0) < 0 ? r2 + 360 : r2;
428
+ }, o = function(r2, t2) {
429
+ return void 0 === t2 && (t2 = 0), n(r2, t2) % 360;
430
+ }, a = function(r2) {
431
+ return { r: u(r2.r, 0, 255), g: u(r2.g, 0, 255), b: u(r2.b, 0, 255), a: u(r2.a) };
432
+ }, i = function(r2) {
433
+ return { r: n(r2.r), g: n(r2.g), b: n(r2.b), a: n(r2.a, 3) };
434
+ }, s = /^#([0-9a-f]{3,8})$/i, d = function(r2, t2) {
435
+ var n2 = r2.charCodeAt(t2);
436
+ return (15 & n2) + 9 * (n2 >> 6);
437
+ }, h = function(r2, t2) {
438
+ return d(r2, t2) << 4 | d(r2, t2 + 1);
439
+ }, b = [], f = 0; f < 256; f++) b.push((f < 16 ? "0" : "") + f.toString(16));
440
+ var g = function(r) {
441
+ return b[u(r, 0, 255)];
442
+ }, c = function(r) {
443
+ var t = r.r, n = r.g, u = r.b, e2 = r.a, o = Math.max(t, n, u), a = o - Math.min(t, n, u), i = a ? o === t ? (n - u) / a : o === n ? 2 + (u - t) / a : 4 + (t - n) / a : 0;
444
+ return { h: 60 * (i < 0 ? i + 6 : i), s: o ? a / o * 100 : 0, v: o / 255 * 100, a: e2 };
445
+ }, v = function(r) {
446
+ var t = r.h, n = r.s, u = r.v, e2 = r.a;
447
+ t = t / 360 * 6, n /= 100, u /= 100;
448
+ var o = Math.floor(t), a = u * (1 - n), i = u * (1 - (t - o) * n), s = u * (1 - (1 - t + o) * n), d = o % 6;
449
+ return { r: 255 * [u, i, a, a, s, u][d], g: 255 * [s, u, u, i, a, a][d], b: 255 * [a, a, s, u, u, i][d], a: e2 };
450
+ }, l = function(r) {
451
+ return { h: e$1(r.h), s: u(r.s, 0, 100), l: u(r.l, 0, 100), a: u(r.a) };
452
+ }, p = function(r) {
453
+ return { h: o(r.h), s: n(r.s), l: n(r.l), a: n(r.a, 3) };
454
+ }, m = function(r) {
455
+ return v((n = (t = r).s, { h: t.h, s: (n *= ((u = t.l) < 50 ? u : 100 - u) / 100) > 0 ? 2 * n / (u + n) * 100 : 0, v: u + n, a: t.a }));
456
+ var t, n, u;
457
+ }, y = function(r) {
458
+ return { h: (t = c(r)).h, s: (e2 = (200 - (n = t.s)) * (u = t.v) / 100) > 0 && e2 < 200 ? n * u / 100 / (e2 <= 100 ? e2 : 200 - e2) * 100 : 0, l: e2 / 2, a: t.a };
459
+ var t, n, u, e2;
460
+ }, N = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i, x = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s+([+-]?(?:\d*\.\d+|\d+))%\s+([+-]?(?:\d*\.\d+|\d+))%\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i, M = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i, H = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i, $ = { string: [[function(r) {
461
+ if (!s.test(r)) return null;
462
+ var t = r.length;
463
+ return t <= 5 ? { r: 17 * d(r, 1), g: 17 * d(r, 2), b: 17 * d(r, 3), a: 5 === t ? n(17 * d(r, 4) / 255, 2) : 1 } : 7 === t || 9 === t ? { r: h(r, 1), g: h(r, 3), b: h(r, 5), a: 9 === t ? n(h(r, 7) / 255, 2) : 1 } : null;
464
+ }, "hex"], [function(r) {
465
+ var t = M.exec(r) || H.exec(r);
466
+ return t ? t[2] !== t[4] || t[4] !== t[6] ? null : a({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: void 0 === t[7] ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
467
+ }, "rgb"], [function(t) {
468
+ var n = N.exec(t) || x.exec(t);
469
+ if (!n) return null;
470
+ var u, e2, o = l({ h: (u = n[1], e2 = n[2], void 0 === e2 && (e2 = "deg"), Number(u) * (r[e2] || 1)), s: Number(n[3]), l: Number(n[4]), a: void 0 === n[5] ? 1 : Number(n[5]) / (n[6] ? 100 : 1) });
471
+ return m(o);
472
+ }, "hsl"]], object: [[function(r) {
473
+ var n = r.r, u = r.g, e2 = r.b, o = r.a, i = void 0 === o ? 1 : o;
474
+ return t(n) && t(u) && t(e2) ? a({ r: Number(n), g: Number(u), b: Number(e2), a: Number(i) }) : null;
475
+ }, "rgb"], [function(r) {
476
+ var n = r.h, u = r.s, e2 = r.l, o = r.a, a = void 0 === o ? 1 : o;
477
+ if (!t(n) || !t(u) || !t(e2)) return null;
478
+ var i = l({ h: Number(n), s: Number(u), l: Number(e2), a: Number(a) });
479
+ return m(i);
480
+ }, "hsl"], [function(r) {
481
+ var n = r.h, o = r.s, a = r.v, i = r.a, s = void 0 === i ? 1 : i;
482
+ if (!t(n) || !t(o) || !t(a)) return null;
483
+ var d = (function(r2) {
484
+ return { h: e$1(r2.h), s: u(r2.s, 0, 100), v: u(r2.v, 0, 100), a: u(r2.a) };
485
+ })({ h: Number(n), s: Number(o), v: Number(a), a: Number(s) });
486
+ return v(d);
487
+ }, "hsv"]] }, j = function(r, t) {
488
+ for (var n = 0; n < t.length; n++) {
489
+ var u = t[n][0](r);
490
+ if (u) return [u, t[n][1]];
491
+ }
492
+ return [null, void 0];
493
+ }, w = function(r) {
494
+ return "string" == typeof r ? j(r.trim(), $.string) : "object" == typeof r && null !== r ? j(r, $.object) : [null, void 0];
495
+ }, k = function(r, t) {
496
+ var n = y(r);
497
+ return { h: n.h, s: u(n.s + 100 * t, 0, 100), l: n.l, a: n.a };
498
+ }, E = function(r) {
499
+ return (299 * r.r + 587 * r.g + 114 * r.b) / 1e3 / 255;
500
+ }, R = function(r, t) {
501
+ var n = y(r);
502
+ return { h: n.h, s: n.s, l: u(n.l + 100 * t, 0, 100), a: n.a };
503
+ }, q = (function() {
504
+ function r(r2) {
505
+ this.parsed = w(r2)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
506
+ }
507
+ return r.prototype.isValid = function() {
508
+ return null !== this.parsed;
509
+ }, r.prototype.brightness = function() {
510
+ return n(E(this.rgba), 2);
511
+ }, r.prototype.isDark = function() {
512
+ return E(this.rgba) < 0.5;
513
+ }, r.prototype.isLight = function() {
514
+ return E(this.rgba) >= 0.5;
515
+ }, r.prototype.toHex = function() {
516
+ return r2 = i(this.rgba), t = r2.r, u = r2.g, e2 = r2.b, a = (o = r2.a) < 1 ? g(n(255 * o)) : "", "#" + g(t) + g(u) + g(e2) + a;
517
+ var r2, t, u, e2, o, a;
518
+ }, r.prototype.toRgb = function() {
519
+ return i(this.rgba);
520
+ }, r.prototype.toRgbString = function() {
521
+ return r2 = i(this.rgba), t = r2.r, n = r2.g, u = r2.b, (e2 = r2.a) < 1 ? "rgba(" + t + ", " + n + ", " + u + ", " + e2 + ")" : "rgb(" + t + ", " + n + ", " + u + ")";
522
+ var r2, t, n, u, e2;
523
+ }, r.prototype.toHsl = function() {
524
+ return p(y(this.rgba));
525
+ }, r.prototype.toHslString = function() {
526
+ return r2 = p(y(this.rgba)), t = r2.h, n = r2.s, u = r2.l, (e2 = r2.a) < 1 ? "hsla(" + t + ", " + n + "%, " + u + "%, " + e2 + ")" : "hsl(" + t + ", " + n + "%, " + u + "%)";
527
+ var r2, t, n, u, e2;
528
+ }, r.prototype.toHsv = function() {
529
+ return r2 = c(this.rgba), { h: o(r2.h), s: n(r2.s), v: n(r2.v), a: n(r2.a, 3) };
530
+ var r2;
531
+ }, r.prototype.invert = function() {
532
+ return A({ r: 255 - (r2 = this.rgba).r, g: 255 - r2.g, b: 255 - r2.b, a: r2.a });
533
+ var r2;
534
+ }, r.prototype.saturate = function(r2) {
535
+ return void 0 === r2 && (r2 = 0.1), A(k(this.rgba, r2));
536
+ }, r.prototype.desaturate = function(r2) {
537
+ return void 0 === r2 && (r2 = 0.1), A(k(this.rgba, -r2));
538
+ }, r.prototype.grayscale = function() {
539
+ return A(k(this.rgba, -1));
540
+ }, r.prototype.lighten = function(r2) {
541
+ return void 0 === r2 && (r2 = 0.1), A(R(this.rgba, r2));
542
+ }, r.prototype.darken = function(r2) {
543
+ return void 0 === r2 && (r2 = 0.1), A(R(this.rgba, -r2));
544
+ }, r.prototype.rotate = function(r2) {
545
+ return void 0 === r2 && (r2 = 15), this.hue(y(this.rgba).h + r2);
546
+ }, r.prototype.alpha = function(r2) {
547
+ return "number" == typeof r2 ? A({ r: (t = this.rgba).r, g: t.g, b: t.b, a: r2 }) : n(this.rgba.a, 3);
548
+ var t;
549
+ }, r.prototype.hue = function(r2) {
550
+ var t = y(this.rgba);
551
+ return "number" == typeof r2 ? A({ h: r2, s: t.s, l: t.l, a: t.a }) : o(t.h);
552
+ }, r.prototype.isEqual = function(r2) {
553
+ return this.toHex() === A(r2).toHex();
554
+ }, r;
555
+ })(), A = function(r) {
556
+ return r instanceof q ? r : new q(r);
557
+ }, C = [], D = function(r) {
558
+ r.forEach(function(r2) {
559
+ C.indexOf(r2) < 0 && (r2(q, $), C.push(r2));
560
+ });
561
+ };
562
+ var e = function(e2, f) {
563
+ var a = { white: "#ffffff", bisque: "#ffe4c4", blue: "#0000ff", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", antiquewhite: "#faebd7", aqua: "#00ffff", azure: "#f0ffff", whitesmoke: "#f5f5f5", papayawhip: "#ffefd5", plum: "#dda0dd", blanchedalmond: "#ffebcd", black: "#000000", gold: "#ffd700", goldenrod: "#daa520", gainsboro: "#dcdcdc", cornsilk: "#fff8dc", cornflowerblue: "#6495ed", burlywood: "#deb887", aquamarine: "#7fffd4", beige: "#f5f5dc", crimson: "#dc143c", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkkhaki: "#bdb76b", darkgray: "#a9a9a9", darkgreen: "#006400", darkgrey: "#a9a9a9", peachpuff: "#ffdab9", darkmagenta: "#8b008b", darkred: "#8b0000", darkorchid: "#9932cc", darkorange: "#ff8c00", darkslateblue: "#483d8b", gray: "#808080", darkslategray: "#2f4f4f", darkslategrey: "#2f4f4f", deeppink: "#ff1493", deepskyblue: "#00bfff", wheat: "#f5deb3", firebrick: "#b22222", floralwhite: "#fffaf0", ghostwhite: "#f8f8ff", darkviolet: "#9400d3", magenta: "#ff00ff", green: "#008000", dodgerblue: "#1e90ff", grey: "#808080", honeydew: "#f0fff0", hotpink: "#ff69b4", blueviolet: "#8a2be2", forestgreen: "#228b22", lawngreen: "#7cfc00", indianred: "#cd5c5c", indigo: "#4b0082", fuchsia: "#ff00ff", brown: "#a52a2a", maroon: "#800000", mediumblue: "#0000cd", lightcoral: "#f08080", darkturquoise: "#00ced1", lightcyan: "#e0ffff", ivory: "#fffff0", lightyellow: "#ffffe0", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", linen: "#faf0e6", mediumaquamarine: "#66cdaa", lemonchiffon: "#fffacd", lime: "#00ff00", khaki: "#f0e68c", mediumseagreen: "#3cb371", limegreen: "#32cd32", mediumspringgreen: "#00fa9a", lightskyblue: "#87cefa", lightblue: "#add8e6", midnightblue: "#191970", lightpink: "#ffb6c1", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", mintcream: "#f5fffa", lightslategray: "#778899", lightslategrey: "#778899", navajowhite: "#ffdead", navy: "#000080", mediumvioletred: "#c71585", powderblue: "#b0e0e6", palegoldenrod: "#eee8aa", oldlace: "#fdf5e6", paleturquoise: "#afeeee", mediumturquoise: "#48d1cc", mediumorchid: "#ba55d3", rebeccapurple: "#663399", lightsteelblue: "#b0c4de", mediumslateblue: "#7b68ee", thistle: "#d8bfd8", tan: "#d2b48c", orchid: "#da70d6", mediumpurple: "#9370db", purple: "#800080", pink: "#ffc0cb", skyblue: "#87ceeb", springgreen: "#00ff7f", palegreen: "#98fb98", red: "#ff0000", yellow: "#ffff00", slateblue: "#6a5acd", lavenderblush: "#fff0f5", peru: "#cd853f", palevioletred: "#db7093", violet: "#ee82ee", teal: "#008080", slategray: "#708090", slategrey: "#708090", aliceblue: "#f0f8ff", darkseagreen: "#8fbc8f", darkolivegreen: "#556b2f", greenyellow: "#adff2f", seagreen: "#2e8b57", seashell: "#fff5ee", tomato: "#ff6347", silver: "#c0c0c0", sienna: "#a0522d", lavender: "#e6e6fa", lightgreen: "#90ee90", orange: "#ffa500", orangered: "#ff4500", steelblue: "#4682b4", royalblue: "#4169e1", turquoise: "#40e0d0", yellowgreen: "#9acd32", salmon: "#fa8072", saddlebrown: "#8b4513", sandybrown: "#f4a460", rosybrown: "#bc8f8f", darksalmon: "#e9967a", lightgoldenrodyellow: "#fafad2", snow: "#fffafa", lightgrey: "#d3d3d3", lightgray: "#d3d3d3", dimgray: "#696969", dimgrey: "#696969", olivedrab: "#6b8e23", olive: "#808000" }, r = {};
564
+ for (var d in a) r[a[d]] = d;
565
+ var l2 = {};
566
+ e2.prototype.toName = function(f2) {
567
+ if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b)) return "transparent";
568
+ var d2, i, n = r[this.toHex()];
569
+ if (n) return n;
570
+ if (null == f2 ? void 0 : f2.closest) {
571
+ var o = this.toRgb(), t = 1 / 0, b = "black";
572
+ if (!l2.length) for (var c2 in a) l2[c2] = new e2(a[c2]).toRgb();
573
+ for (var g2 in a) {
574
+ var u = (d2 = o, i = l2[g2], Math.pow(d2.r - i.r, 2) + Math.pow(d2.g - i.g, 2) + Math.pow(d2.b - i.b, 2));
575
+ u < t && (t = u, b = g2);
576
+ }
577
+ return b;
578
+ }
579
+ };
580
+ f.string.push([function(f2) {
581
+ var r2 = f2.toLowerCase(), d2 = "transparent" === r2 ? "#0000" : a[r2];
582
+ return d2 ? new e2(d2).toRgb() : null;
583
+ }, "name"]);
584
+ };
585
+ D([e]);
586
+ function rgbToHex(r, g2, b) {
587
+ const clamp2 = (v2) => Math.max(0, Math.min(255, Math.round(v2)));
588
+ const toHex = (v2) => {
589
+ const hex = clamp2(v2).toString(16);
424
590
  return hex.length === 1 ? `0${hex}` : hex;
425
591
  };
426
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
592
+ return `#${toHex(r)}${toHex(g2)}${toHex(b)}`;
427
593
  }
428
594
  function normalizeColor(value) {
429
595
  if (typeof value === "string") {
430
- if (value.startsWith("#")) {
431
- if (value.length === 4) {
432
- const r = value[1];
433
- const g = value[2];
434
- const b = value[3];
435
- return `#${r}${r}${g}${g}${b}${b}`;
436
- }
437
- return value;
438
- }
439
- if (value.startsWith("rgb")) {
440
- const match = value.match(/\d+/g);
441
- if (match && match.length >= 3) {
442
- const [r, g, b] = match.map((num) => parseInt(num, 10));
443
- return rgbToHex(r, g, b);
444
- }
596
+ const color = A(value);
597
+ if (!color.isValid()) return null;
598
+ const { r, g: g2, b } = color.toRgb();
599
+ return rgbToHex(r, g2, b);
600
+ }
601
+ if (Array.isArray(value) && value.length >= 3) {
602
+ const [r, g2, b] = value;
603
+ if (typeof r === "number" && Number.isFinite(r) && typeof g2 === "number" && Number.isFinite(g2) && typeof b === "number" && Number.isFinite(b)) {
604
+ return rgbToHex(r, g2, b);
445
605
  }
446
- } else if (Array.isArray(value) && value.length >= 3) {
447
- return rgbToHex(value[0], value[1], value[2]);
448
606
  }
449
- return "#3388ff";
607
+ return null;
450
608
  }
451
609
  function formatNumericValue(value, step) {
452
610
  let decimals = 0;
@@ -470,17 +628,49 @@ const COLOR_PROPERTY_MAP = {
470
628
  heatmap: ["heatmap-color"],
471
629
  "fill-extrusion": ["fill-extrusion-color"]
472
630
  };
473
- function extractColorFromExpression(expression) {
474
- if (!Array.isArray(expression) || expression.length === 0) return null;
475
- for (const item of expression) {
631
+ function isExpressionArray(value) {
632
+ return Array.isArray(value);
633
+ }
634
+ function extractColorFromExpression(expression, preserveFormat = false) {
635
+ if (!isExpressionArray(expression) || expression.length === 0) return null;
636
+ const operator = expression[0];
637
+ const components = expression.slice(1);
638
+ if (operator === "rgb" && components.length === 3 || operator === "rgba" && components.length === 4) {
639
+ if (components.every(
640
+ (component) => typeof component === "number" && Number.isFinite(component)
641
+ )) {
642
+ const color = `${operator}(${components.join(", ")})`;
643
+ return preserveFormat ? color : normalizeColor(color);
644
+ }
645
+ }
646
+ let index = 0;
647
+ let stride = 1;
648
+ let end = expression.length;
649
+ let fallbackIndex = -1;
650
+ let firstResultIndex = 0;
651
+ if (operator === "case" || operator === "match") {
652
+ firstResultIndex = operator === "case" ? 2 : 3;
653
+ index = firstResultIndex;
654
+ stride = 2;
655
+ end = expression.length - 1;
656
+ fallbackIndex = expression.length - 1;
657
+ } else if (operator === "interpolate") {
658
+ index = 4;
659
+ stride = 2;
660
+ }
661
+ const resolve = (item) => {
476
662
  if (typeof item === "string") {
477
- if (item.startsWith("#") || item.startsWith("rgb") || item.startsWith("hsl")) {
478
- return normalizeColor(item);
479
- }
480
- } else if (Array.isArray(item)) {
481
- const result = extractColorFromExpression(item);
482
- if (result) return result;
663
+ const color = normalizeColor(item);
664
+ return color !== null && preserveFormat ? item : color;
483
665
  }
666
+ return isExpressionArray(item) ? extractColorFromExpression(item, preserveFormat) : null;
667
+ };
668
+ for (; index < end; index += stride) {
669
+ const color = resolve(expression[index]);
670
+ if (color !== null) return color;
671
+ }
672
+ if (fallbackIndex >= firstResultIndex) {
673
+ return resolve(expression[fallbackIndex]);
484
674
  }
485
675
  return null;
486
676
  }
@@ -493,28 +683,30 @@ function getLayerColor(map, layerId, layerType) {
493
683
  const runtimeColor = map.getPaintProperty(layerId, propertyName);
494
684
  if (runtimeColor) {
495
685
  if (typeof runtimeColor === "string") {
496
- return normalizeColor(runtimeColor);
686
+ const color = normalizeColor(runtimeColor);
687
+ if (color !== null) return color;
497
688
  }
498
689
  if (Array.isArray(runtimeColor)) {
499
690
  const extracted = extractColorFromExpression(runtimeColor);
500
- if (extracted) return extracted;
691
+ if (extracted !== null) return extracted;
501
692
  }
502
693
  }
503
694
  } catch {
504
695
  }
505
696
  const style = map.getStyle();
506
697
  const layer = (_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.find(
507
- (l) => l.id === layerId
698
+ (styleLayer) => styleLayer.id === layerId
508
699
  );
509
700
  if (layer && "paint" in layer && layer.paint) {
510
701
  const paintColor = layer.paint[propertyName];
511
702
  if (paintColor) {
512
703
  if (typeof paintColor === "string") {
513
- return normalizeColor(paintColor);
704
+ const color = normalizeColor(paintColor);
705
+ if (color !== null) return color;
514
706
  }
515
707
  if (Array.isArray(paintColor)) {
516
708
  const extracted = extractColorFromExpression(paintColor);
517
- if (extracted) return extracted;
709
+ if (extracted !== null) return extracted;
518
710
  }
519
711
  }
520
712
  }
@@ -529,17 +721,81 @@ function getLayerColorFromSpec(layer) {
529
721
  const paintColor = layer.paint[propertyName];
530
722
  if (paintColor) {
531
723
  if (typeof paintColor === "string") {
532
- return normalizeColor(paintColor);
724
+ const color = normalizeColor(paintColor);
725
+ if (color !== null) return color;
533
726
  }
534
727
  if (Array.isArray(paintColor)) {
535
728
  const extracted = extractColorFromExpression(paintColor);
536
- if (extracted) return extracted;
729
+ if (extracted !== null) return extracted;
537
730
  }
538
731
  }
539
732
  }
540
733
  }
541
734
  return null;
542
735
  }
736
+ function extractDasharray(value) {
737
+ if (!Array.isArray(value)) return null;
738
+ if (value.length > 0 && value.every((item) => typeof item === "number" && Number.isFinite(item))) {
739
+ const dasharray = value;
740
+ if (dasharray.every((item) => item >= 0) && dasharray.some((item) => item > 0)) {
741
+ return dasharray;
742
+ }
743
+ return null;
744
+ }
745
+ for (const item of value) {
746
+ if (Array.isArray(item)) {
747
+ const dasharray = extractDasharray(item);
748
+ if (dasharray) return dasharray;
749
+ }
750
+ }
751
+ return null;
752
+ }
753
+ function resolveSymbolStyle(layerType, getPaint) {
754
+ if (layerType === "line") {
755
+ const dasharray = extractDasharray(getPaint("line-dasharray"));
756
+ return dasharray ? { dasharray } : {};
757
+ }
758
+ if (layerType === "circle") {
759
+ if (getPaint("circle-stroke-width") === 0) {
760
+ return { strokeColor: null };
761
+ }
762
+ const color = getPaint("circle-stroke-color");
763
+ if (typeof color === "string") {
764
+ return { strokeColor: color };
765
+ }
766
+ if (isExpressionArray(color)) {
767
+ const strokeColor = extractColorFromExpression(color, true);
768
+ return strokeColor ? { strokeColor } : {};
769
+ }
770
+ }
771
+ return {};
772
+ }
773
+ function getLayerSymbolStyle(map, layerId, layerType) {
774
+ const getPaint = (property) => {
775
+ var _a, _b;
776
+ let value;
777
+ try {
778
+ value = map.getPaintProperty(layerId, property);
779
+ } catch {
780
+ }
781
+ if (value !== void 0 && value !== null) return value;
782
+ const layer = (_b = (_a = map.getStyle()) == null ? void 0 : _a.layers) == null ? void 0 : _b.find((item) => item.id === layerId);
783
+ if (layer && "paint" in layer && layer.paint) {
784
+ return layer.paint[property];
785
+ }
786
+ return void 0;
787
+ };
788
+ return resolveSymbolStyle(layerType, getPaint);
789
+ }
790
+ function getLayerSymbolStyleFromSpec(layer) {
791
+ const getPaint = (property) => {
792
+ if ("paint" in layer && layer.paint) {
793
+ return layer.paint[property];
794
+ }
795
+ return void 0;
796
+ };
797
+ return resolveSymbolStyle(layer.type, getPaint);
798
+ }
543
799
  function darkenColor(hexColor, amount) {
544
800
  let hex = hexColor.replace("#", "");
545
801
  if (hex.length === 3) {
@@ -549,7 +805,7 @@ function darkenColor(hexColor, amount) {
549
805
  0,
550
806
  parseInt(hex.slice(0, 2), 16) - Math.round(255 * amount)
551
807
  );
552
- const g = Math.max(
808
+ const g2 = Math.max(
553
809
  0,
554
810
  parseInt(hex.slice(2, 4), 16) - Math.round(255 * amount)
555
811
  );
@@ -557,7 +813,7 @@ function darkenColor(hexColor, amount) {
557
813
  0,
558
814
  parseInt(hex.slice(4, 6), 16) - Math.round(255 * amount)
559
815
  );
560
- return rgbToHex(r, g, b);
816
+ return rgbToHex(r, g2, b);
561
817
  }
562
818
  function createFillSymbol(size, color) {
563
819
  const padding = 2;
@@ -567,22 +823,32 @@ function createFillSymbol(size, color) {
567
823
  fill="${color}" stroke="${borderColor}" stroke-width="1" rx="1"/>
568
824
  </svg>`;
569
825
  }
570
- function createLineSymbol(size, color, strokeWidth = 2) {
571
- const y = size / 2;
826
+ function createLineSymbol(size, color, strokeWidth = 2, dasharray) {
827
+ const y2 = size / 2;
572
828
  const padding = 2;
829
+ let dashAttributes = 'stroke-linecap="round"';
830
+ if (dasharray && dasharray.length > 0) {
831
+ const lineLength = size - padding * 2;
832
+ const dashLength = dasharray[0];
833
+ const gapLength = dasharray.length > 1 ? dasharray[1] : dashLength;
834
+ const fitLength = dashLength + gapLength + dashLength;
835
+ const scale = fitLength > 0 ? Math.min(strokeWidth, lineLength / fitLength) : strokeWidth;
836
+ const scaledDasharray = dasharray.map((value) => Number((value * scale).toFixed(2))).join(" ");
837
+ dashAttributes = `stroke-linecap="butt" stroke-dasharray="${scaledDasharray}"`;
838
+ }
573
839
  return `<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}" xmlns="http://www.w3.org/2000/svg">
574
- <line x1="${padding}" y1="${y}" x2="${size - padding}" y2="${y}"
575
- stroke="${color}" stroke-width="${strokeWidth}" stroke-linecap="round"/>
840
+ <line x1="${padding}" y1="${y2}" x2="${size - padding}" y2="${y2}"
841
+ stroke="${color}" stroke-width="${strokeWidth}" ${dashAttributes}/>
576
842
  </svg>`;
577
843
  }
578
- function createCircleSymbol(size, color) {
844
+ function createCircleSymbol(size, color, strokeColor) {
579
845
  const cx = size / 2;
580
846
  const cy = size / 2;
581
847
  const r = size / 2 - 3;
582
- const borderColor = darkenColor(color, 0.3);
848
+ const borderAttributes = strokeColor === void 0 ? `stroke="${darkenColor(color, 0.3)}" stroke-width="1"` : strokeColor === null ? 'stroke="none"' : `stroke="${strokeColor}" stroke-width="1"`;
583
849
  return `<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}" xmlns="http://www.w3.org/2000/svg">
584
850
  <circle cx="${cx}" cy="${cy}" r="${r}" fill="${color}"
585
- stroke="${borderColor}" stroke-width="1"/>
851
+ ${borderAttributes}/>
586
852
  </svg>`;
587
853
  }
588
854
  function createMarkerSymbol(size, color) {
@@ -729,9 +995,9 @@ function createLayerSymbolSVG(layerType, color, options = {}) {
729
995
  case "fill":
730
996
  return createFillSymbol(size, fillColor);
731
997
  case "line":
732
- return createLineSymbol(size, fillColor, strokeWidth);
998
+ return createLineSymbol(size, fillColor, strokeWidth, options.dasharray);
733
999
  case "circle":
734
- return createCircleSymbol(size, fillColor);
1000
+ return createCircleSymbol(size, fillColor, options.strokeColor);
735
1001
  case "symbol":
736
1002
  return createMarkerSymbol(size, fillColor);
737
1003
  case "raster":
@@ -1176,7 +1442,7 @@ class LayerControl {
1176
1442
  } else if (src.data && typeof src.data === "string") {
1177
1443
  try {
1178
1444
  const url = new URL(src.data);
1179
- const isBasemap = knownBasemapProviders.some((p) => url.hostname.includes(p)) || basemapDomains.has(url.hostname);
1445
+ const isBasemap = knownBasemapProviders.some((p2) => url.hostname.includes(p2)) || basemapDomains.has(url.hostname);
1180
1446
  if (!isBasemap) {
1181
1447
  userAddedSources.add(sourceId);
1182
1448
  }
@@ -1580,8 +1846,8 @@ class LayerControl {
1580
1846
  */
1581
1847
  setupEventListeners() {
1582
1848
  this.button.addEventListener("click", () => this.toggle());
1583
- document.addEventListener("click", (e) => {
1584
- const target = e.target;
1849
+ document.addEventListener("click", (e2) => {
1850
+ const target = e2.target;
1585
1851
  if (this.contextMenuEl && this.state.contextMenu.visible) {
1586
1852
  if (!this.contextMenuEl.contains(target)) {
1587
1853
  this.hideContextMenu();
@@ -1615,16 +1881,16 @@ class LayerControl {
1615
1881
  this.checkForNewLayers();
1616
1882
  }, 100);
1617
1883
  });
1618
- this.map.on("data", (e) => {
1619
- if (e.sourceDataType === "content") {
1884
+ this.map.on("data", (e2) => {
1885
+ if (e2.sourceDataType === "content") {
1620
1886
  setTimeout(() => {
1621
1887
  this.updateLayerStatesFromMap();
1622
1888
  this.checkForNewLayers();
1623
1889
  }, 100);
1624
1890
  }
1625
1891
  });
1626
- this.map.on("sourcedata", (e) => {
1627
- if (e.sourceDataType === "metadata") {
1892
+ this.map.on("sourcedata", (e2) => {
1893
+ if (e2.sourceDataType === "metadata") {
1628
1894
  setTimeout(() => {
1629
1895
  this.checkForNewLayers();
1630
1896
  }, 150);
@@ -1827,9 +2093,9 @@ class LayerControl {
1827
2093
  toggle.innerHTML = `<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
1828
2094
  <path d="M6 4l4 4-4 4z"/>
1829
2095
  </svg>`;
1830
- toggle.addEventListener("click", (e) => {
2096
+ toggle.addEventListener("click", (e2) => {
1831
2097
  var _a;
1832
- e.stopPropagation();
2098
+ e2.stopPropagation();
1833
2099
  this.setGroupCollapsed(group.id, !((_a = this.groupStates.get(group.id)) == null ? void 0 : _a.collapsed));
1834
2100
  });
1835
2101
  row.appendChild(toggle);
@@ -2059,10 +2325,10 @@ class LayerControl {
2059
2325
  }
2060
2326
  item.appendChild(row);
2061
2327
  if (this.enableContextMenu && layerId !== "Background") {
2062
- row.addEventListener("contextmenu", (e) => {
2063
- e.preventDefault();
2064
- e.stopPropagation();
2065
- this.showContextMenu(layerId, e.clientX, e.clientY);
2328
+ row.addEventListener("contextmenu", (e2) => {
2329
+ e2.preventDefault();
2330
+ e2.stopPropagation();
2331
+ this.showContextMenu(layerId, e2.clientX, e2.clientY);
2066
2332
  });
2067
2333
  }
2068
2334
  container.appendChild(item);
@@ -2088,7 +2354,8 @@ class LayerControl {
2088
2354
  if (!layer) return null;
2089
2355
  const layerType = layer.type;
2090
2356
  const color = getLayerColor(this.map, layerId, layerType);
2091
- const svgMarkup = createLayerSymbolSVG(layerType, color);
2357
+ const symbolStyle = getLayerSymbolStyle(this.map, layerId, layerType);
2358
+ const svgMarkup = createLayerSymbolSVG(layerType, color, symbolStyle);
2092
2359
  const symbolContainer = document.createElement("span");
2093
2360
  symbolContainer.className = "layer-control-symbol";
2094
2361
  symbolContainer.innerHTML = svgMarkup;
@@ -2102,7 +2369,11 @@ class LayerControl {
2102
2369
  */
2103
2370
  createBackgroundLayerSymbol(layer) {
2104
2371
  const color = getLayerColorFromSpec(layer);
2105
- const svgMarkup = createLayerSymbolSVG(layer.type, color, { size: 14 });
2372
+ const symbolStyle = getLayerSymbolStyleFromSpec(layer);
2373
+ const svgMarkup = createLayerSymbolSVG(layer.type, color, {
2374
+ size: 14,
2375
+ ...symbolStyle
2376
+ });
2106
2377
  const symbolContainer = document.createElement("span");
2107
2378
  symbolContainer.className = "background-legend-layer-symbol";
2108
2379
  symbolContainer.innerHTML = svgMarkup;
@@ -2359,8 +2630,8 @@ class LayerControl {
2359
2630
  "aria-expanded",
2360
2631
  String(this.state.backgroundLegendOpen)
2361
2632
  );
2362
- button.addEventListener("click", (e) => {
2363
- e.stopPropagation();
2633
+ button.addEventListener("click", (e2) => {
2634
+ e2.stopPropagation();
2364
2635
  this.toggleBackgroundLegend();
2365
2636
  });
2366
2637
  return button;
@@ -2444,8 +2715,8 @@ class LayerControl {
2444
2715
  closeBtn.className = "background-legend-close";
2445
2716
  closeBtn.innerHTML = "&times;";
2446
2717
  closeBtn.title = "Close";
2447
- closeBtn.addEventListener("click", (e) => {
2448
- e.stopPropagation();
2718
+ closeBtn.addEventListener("click", (e2) => {
2719
+ e2.stopPropagation();
2449
2720
  this.closeBackgroundLegend();
2450
2721
  });
2451
2722
  header.appendChild(title);
@@ -2552,12 +2823,12 @@ class LayerControl {
2552
2823
  applyBtn.disabled = !hasSelection;
2553
2824
  deleteBtn.disabled = !hasSelection;
2554
2825
  });
2555
- applyBtn.addEventListener("click", (e) => {
2556
- e.stopPropagation();
2826
+ applyBtn.addEventListener("click", (e2) => {
2827
+ e2.stopPropagation();
2557
2828
  if (select.value) this.applyBackgroundPreset(select.value);
2558
2829
  });
2559
- deleteBtn.addEventListener("click", (e) => {
2560
- e.stopPropagation();
2830
+ deleteBtn.addEventListener("click", (e2) => {
2831
+ e2.stopPropagation();
2561
2832
  if (select.value) {
2562
2833
  this.deleteBackgroundPreset(select.value);
2563
2834
  refreshSelect();
@@ -2584,13 +2855,13 @@ class LayerControl {
2584
2855
  nameInput.value = "";
2585
2856
  refreshSelect(name);
2586
2857
  };
2587
- saveBtn.addEventListener("click", (e) => {
2588
- e.stopPropagation();
2858
+ saveBtn.addEventListener("click", (e2) => {
2859
+ e2.stopPropagation();
2589
2860
  commitSave();
2590
2861
  });
2591
- nameInput.addEventListener("keydown", (e) => {
2592
- if (e.key === "Enter") {
2593
- e.preventDefault();
2862
+ nameInput.addEventListener("keydown", (e2) => {
2863
+ if (e2.key === "Enter") {
2864
+ e2.preventDefault();
2594
2865
  commitSave();
2595
2866
  }
2596
2867
  });
@@ -2909,8 +3180,8 @@ class LayerControl {
2909
3180
  button.title = "Edit layer style";
2910
3181
  button.setAttribute("aria-label", `Edit style for ${layerId}`);
2911
3182
  }
2912
- button.addEventListener("click", (e) => {
2913
- e.stopPropagation();
3183
+ button.addEventListener("click", (e2) => {
3184
+ e2.stopPropagation();
2914
3185
  this.toggleStyleEditor(layerId);
2915
3186
  });
2916
3187
  return button;
@@ -3004,8 +3275,8 @@ class LayerControl {
3004
3275
  closeBtn.className = "style-editor-close";
3005
3276
  closeBtn.innerHTML = "&times;";
3006
3277
  closeBtn.title = "Close";
3007
- closeBtn.addEventListener("click", (e) => {
3008
- e.stopPropagation();
3278
+ closeBtn.addEventListener("click", (e2) => {
3279
+ e2.stopPropagation();
3009
3280
  this.closeStyleEditor(layerId);
3010
3281
  });
3011
3282
  header.appendChild(title);
@@ -3022,8 +3293,8 @@ class LayerControl {
3022
3293
  removeBtn.className = "style-editor-button style-editor-button-remove";
3023
3294
  removeBtn.textContent = "Remove Layer";
3024
3295
  removeBtn.title = "Remove layer from map";
3025
- removeBtn.addEventListener("click", (e) => {
3026
- e.stopPropagation();
3296
+ removeBtn.addEventListener("click", (e2) => {
3297
+ e2.stopPropagation();
3027
3298
  this.showRemoveConfirmation(editor, () => {
3028
3299
  this.closeStyleEditor(layerId);
3029
3300
  this.removeLayer(layerId);
@@ -3032,8 +3303,8 @@ class LayerControl {
3032
3303
  const closeActionBtn = document.createElement("button");
3033
3304
  closeActionBtn.className = "style-editor-button style-editor-button-close";
3034
3305
  closeActionBtn.textContent = "Close";
3035
- closeActionBtn.addEventListener("click", (e) => {
3036
- e.stopPropagation();
3306
+ closeActionBtn.addEventListener("click", (e2) => {
3307
+ e2.stopPropagation();
3037
3308
  this.closeStyleEditor(layerId);
3038
3309
  });
3039
3310
  actions.appendChild(removeBtn);
@@ -3071,8 +3342,8 @@ class LayerControl {
3071
3342
  closeBtn.className = "style-editor-close";
3072
3343
  closeBtn.innerHTML = "&times;";
3073
3344
  closeBtn.title = "Close";
3074
- closeBtn.addEventListener("click", (e) => {
3075
- e.stopPropagation();
3345
+ closeBtn.addEventListener("click", (e2) => {
3346
+ e2.stopPropagation();
3076
3347
  this.closeStyleEditor(layerId);
3077
3348
  });
3078
3349
  header.appendChild(title);
@@ -3102,8 +3373,8 @@ class LayerControl {
3102
3373
  const resetBtn = document.createElement("button");
3103
3374
  resetBtn.className = "style-editor-button style-editor-button-reset";
3104
3375
  resetBtn.textContent = "Reset Style";
3105
- resetBtn.addEventListener("click", (e) => {
3106
- e.stopPropagation();
3376
+ resetBtn.addEventListener("click", (e2) => {
3377
+ e2.stopPropagation();
3107
3378
  for (const nativeId of nativeLayerIds) {
3108
3379
  restoreOriginalStyle(this.map, nativeId, this.state.originalStyles);
3109
3380
  }
@@ -3115,10 +3386,10 @@ class LayerControl {
3115
3386
  if (!property || !sourceId) return;
3116
3387
  const value = this.map.getPaintProperty(sourceId, property);
3117
3388
  if (value !== void 0) {
3118
- this.notifyLayerStyleChange(
3119
- property,
3120
- typeof value === "number" ? value : normalizeColor(value)
3121
- );
3389
+ const color = typeof value === "number" ? value : normalizeColor(value);
3390
+ if (color !== null) {
3391
+ this.notifyLayerStyleChange(property, color);
3392
+ }
3122
3393
  }
3123
3394
  });
3124
3395
  }
@@ -3129,8 +3400,8 @@ class LayerControl {
3129
3400
  removeBtn.className = "style-editor-button style-editor-button-remove";
3130
3401
  removeBtn.textContent = "Remove Layer";
3131
3402
  removeBtn.title = "Remove layer from map";
3132
- removeBtn.addEventListener("click", (e) => {
3133
- e.stopPropagation();
3403
+ removeBtn.addEventListener("click", (e2) => {
3404
+ e2.stopPropagation();
3134
3405
  this.showRemoveConfirmation(editor, () => {
3135
3406
  this.closeStyleEditor(layerId);
3136
3407
  this.removeLayer(layerId);
@@ -3139,8 +3410,8 @@ class LayerControl {
3139
3410
  const closeActionBtn = document.createElement("button");
3140
3411
  closeActionBtn.className = "style-editor-button style-editor-button-close";
3141
3412
  closeActionBtn.textContent = "Close";
3142
- closeActionBtn.addEventListener("click", (e) => {
3143
- e.stopPropagation();
3413
+ closeActionBtn.addEventListener("click", (e2) => {
3414
+ e2.stopPropagation();
3144
3415
  this.closeStyleEditor(layerId);
3145
3416
  });
3146
3417
  actions.appendChild(resetBtn);
@@ -3189,8 +3460,8 @@ class LayerControl {
3189
3460
  closeBtn.className = "style-editor-close";
3190
3461
  closeBtn.innerHTML = "&times;";
3191
3462
  closeBtn.title = "Close";
3192
- closeBtn.addEventListener("click", (e) => {
3193
- e.stopPropagation();
3463
+ closeBtn.addEventListener("click", (e2) => {
3464
+ e2.stopPropagation();
3194
3465
  this.closeStyleEditor(layerId);
3195
3466
  });
3196
3467
  header.appendChild(title);
@@ -3204,16 +3475,16 @@ class LayerControl {
3204
3475
  const resetBtn = document.createElement("button");
3205
3476
  resetBtn.className = "style-editor-button style-editor-button-reset";
3206
3477
  resetBtn.textContent = "Reset Style";
3207
- resetBtn.addEventListener("click", (e) => {
3208
- e.stopPropagation();
3478
+ resetBtn.addEventListener("click", (e2) => {
3479
+ e2.stopPropagation();
3209
3480
  this.resetLayerStyle(layerId);
3210
3481
  });
3211
3482
  const removeBtn = document.createElement("button");
3212
3483
  removeBtn.className = "style-editor-button style-editor-button-remove";
3213
3484
  removeBtn.textContent = "Remove Layer";
3214
3485
  removeBtn.title = "Remove layer from map";
3215
- removeBtn.addEventListener("click", (e) => {
3216
- e.stopPropagation();
3486
+ removeBtn.addEventListener("click", (e2) => {
3487
+ e2.stopPropagation();
3217
3488
  this.showRemoveConfirmation(editor, () => {
3218
3489
  this.closeStyleEditor(layerId);
3219
3490
  this.removeLayer(layerId);
@@ -3222,8 +3493,8 @@ class LayerControl {
3222
3493
  const closeActionBtn = document.createElement("button");
3223
3494
  closeActionBtn.className = "style-editor-button style-editor-button-close";
3224
3495
  closeActionBtn.textContent = "Close";
3225
- closeActionBtn.addEventListener("click", (e) => {
3226
- e.stopPropagation();
3496
+ closeActionBtn.addEventListener("click", (e2) => {
3497
+ e2.stopPropagation();
3227
3498
  this.closeStyleEditor(layerId);
3228
3499
  });
3229
3500
  actions.appendChild(resetBtn);
@@ -3264,7 +3535,7 @@ class LayerControl {
3264
3535
  addFillControls(container, layerId) {
3265
3536
  var _a;
3266
3537
  const style = this.map.getStyle();
3267
- const layer = (_a = style.layers) == null ? void 0 : _a.find((l) => l.id === layerId);
3538
+ const layer = (_a = style.layers) == null ? void 0 : _a.find((l2) => l2.id === layerId);
3268
3539
  let fillColor = void 0;
3269
3540
  if (layer && "paint" in layer && layer.paint && "fill-color" in layer.paint) {
3270
3541
  fillColor = layer.paint["fill-color"];
@@ -3272,13 +3543,16 @@ class LayerControl {
3272
3543
  if (!fillColor) {
3273
3544
  fillColor = this.map.getPaintProperty(layerId, "fill-color");
3274
3545
  }
3275
- this.createColorControl(
3276
- container,
3277
- layerId,
3278
- "fill-color",
3279
- "Fill Color",
3280
- normalizeColor(fillColor || "#088")
3281
- );
3546
+ const normalizedFillColor = normalizeColor(fillColor || "#088");
3547
+ if (normalizedFillColor !== null) {
3548
+ this.createColorControl(
3549
+ container,
3550
+ layerId,
3551
+ "fill-color",
3552
+ "Fill Color",
3553
+ normalizedFillColor
3554
+ );
3555
+ }
3282
3556
  const fillOpacity = this.map.getPaintProperty(layerId, "fill-opacity");
3283
3557
  if (fillOpacity !== void 0 && typeof fillOpacity === "number") {
3284
3558
  this.createSliderControl(
@@ -3297,13 +3571,16 @@ class LayerControl {
3297
3571
  "fill-outline-color"
3298
3572
  );
3299
3573
  if (outlineColor !== void 0) {
3300
- this.createColorControl(
3301
- container,
3302
- layerId,
3303
- "fill-outline-color",
3304
- "Outline Color",
3305
- normalizeColor(outlineColor)
3306
- );
3574
+ const normalizedOutlineColor = normalizeColor(outlineColor);
3575
+ if (normalizedOutlineColor !== null) {
3576
+ this.createColorControl(
3577
+ container,
3578
+ layerId,
3579
+ "fill-outline-color",
3580
+ "Outline Color",
3581
+ normalizedOutlineColor
3582
+ );
3583
+ }
3307
3584
  }
3308
3585
  }
3309
3586
  /**
@@ -3312,7 +3589,7 @@ class LayerControl {
3312
3589
  addLineControls(container, layerId) {
3313
3590
  var _a;
3314
3591
  const style = this.map.getStyle();
3315
- const layer = (_a = style.layers) == null ? void 0 : _a.find((l) => l.id === layerId);
3592
+ const layer = (_a = style.layers) == null ? void 0 : _a.find((l2) => l2.id === layerId);
3316
3593
  let lineColor = void 0;
3317
3594
  if (layer && "paint" in layer && layer.paint && "line-color" in layer.paint) {
3318
3595
  lineColor = layer.paint["line-color"];
@@ -3320,13 +3597,16 @@ class LayerControl {
3320
3597
  if (!lineColor) {
3321
3598
  lineColor = this.map.getPaintProperty(layerId, "line-color");
3322
3599
  }
3323
- this.createColorControl(
3324
- container,
3325
- layerId,
3326
- "line-color",
3327
- "Line Color",
3328
- normalizeColor(lineColor || "#000")
3329
- );
3600
+ const normalizedLineColor = normalizeColor(lineColor || "#000");
3601
+ if (normalizedLineColor !== null) {
3602
+ this.createColorControl(
3603
+ container,
3604
+ layerId,
3605
+ "line-color",
3606
+ "Line Color",
3607
+ normalizedLineColor
3608
+ );
3609
+ }
3330
3610
  const lineWidth = this.map.getPaintProperty(layerId, "line-width");
3331
3611
  this.createSliderControl(
3332
3612
  container,
@@ -3371,7 +3651,7 @@ class LayerControl {
3371
3651
  addCircleControls(container, layerId) {
3372
3652
  var _a;
3373
3653
  const style = this.map.getStyle();
3374
- const layer = (_a = style.layers) == null ? void 0 : _a.find((l) => l.id === layerId);
3654
+ const layer = (_a = style.layers) == null ? void 0 : _a.find((l2) => l2.id === layerId);
3375
3655
  let circleColor = void 0;
3376
3656
  if (layer && "paint" in layer && layer.paint && "circle-color" in layer.paint) {
3377
3657
  circleColor = layer.paint["circle-color"];
@@ -3379,13 +3659,16 @@ class LayerControl {
3379
3659
  if (!circleColor) {
3380
3660
  circleColor = this.map.getPaintProperty(layerId, "circle-color");
3381
3661
  }
3382
- this.createColorControl(
3383
- container,
3384
- layerId,
3385
- "circle-color",
3386
- "Circle Color",
3387
- normalizeColor(circleColor || "#000")
3388
- );
3662
+ const normalizedCircleColor = normalizeColor(circleColor || "#000");
3663
+ if (normalizedCircleColor !== null) {
3664
+ this.createColorControl(
3665
+ container,
3666
+ layerId,
3667
+ "circle-color",
3668
+ "Circle Color",
3669
+ normalizedCircleColor
3670
+ );
3671
+ }
3389
3672
  const circleRadius = this.map.getPaintProperty(layerId, "circle-radius");
3390
3673
  this.createSliderControl(
3391
3674
  container,
@@ -3415,13 +3698,16 @@ class LayerControl {
3415
3698
  "circle-stroke-color"
3416
3699
  );
3417
3700
  if (strokeColor !== void 0) {
3418
- this.createColorControl(
3419
- container,
3420
- layerId,
3421
- "circle-stroke-color",
3422
- "Stroke Color",
3423
- normalizeColor(strokeColor)
3424
- );
3701
+ const normalizedStrokeColor = normalizeColor(strokeColor);
3702
+ if (normalizedStrokeColor !== null) {
3703
+ this.createColorControl(
3704
+ container,
3705
+ layerId,
3706
+ "circle-stroke-color",
3707
+ "Stroke Color",
3708
+ normalizedStrokeColor
3709
+ );
3710
+ }
3425
3711
  }
3426
3712
  const strokeWidth = this.map.getPaintProperty(
3427
3713
  layerId,
@@ -3523,13 +3809,16 @@ class LayerControl {
3523
3809
  addSymbolControls(container, layerId) {
3524
3810
  const textColor = this.map.getPaintProperty(layerId, "text-color");
3525
3811
  if (textColor !== void 0) {
3526
- this.createColorControl(
3527
- container,
3528
- layerId,
3529
- "text-color",
3530
- "Text Color",
3531
- normalizeColor(textColor)
3532
- );
3812
+ const normalizedTextColor = normalizeColor(textColor);
3813
+ if (normalizedTextColor !== null) {
3814
+ this.createColorControl(
3815
+ container,
3816
+ layerId,
3817
+ "text-color",
3818
+ "Text Color",
3819
+ normalizedTextColor
3820
+ );
3821
+ }
3533
3822
  }
3534
3823
  const textOpacity = this.map.getPaintProperty(layerId, "text-opacity");
3535
3824
  if (textOpacity !== void 0 && typeof textOpacity === "number") {
@@ -3630,6 +3919,7 @@ class LayerControl {
3630
3919
  const value = this.map.getPaintProperty(sourceId, property);
3631
3920
  if (value !== void 0) {
3632
3921
  const hexColor = normalizeColor(value);
3922
+ if (hexColor === null) return;
3633
3923
  picker.value = hexColor;
3634
3924
  const hexDisplay = (_a = picker.parentElement) == null ? void 0 : _a.querySelector(
3635
3925
  ".style-control-color-value"
@@ -3753,6 +4043,7 @@ class LayerControl {
3753
4043
  const value = this.map.getPaintProperty(layerId, property);
3754
4044
  if (value !== void 0) {
3755
4045
  const hexColor = normalizeColor(value);
4046
+ if (hexColor === null) return;
3756
4047
  picker.value = hexColor;
3757
4048
  const hexDisplay = (_a = picker.parentElement) == null ? void 0 : _a.querySelector(
3758
4049
  ".style-control-color-value"
@@ -4079,8 +4370,8 @@ class LayerControl {
4079
4370
  labelEl.textContent = label;
4080
4371
  item.appendChild(iconEl);
4081
4372
  item.appendChild(labelEl);
4082
- item.addEventListener("click", (e) => {
4083
- e.stopPropagation();
4373
+ item.addEventListener("click", (e2) => {
4374
+ e2.stopPropagation();
4084
4375
  onClick();
4085
4376
  });
4086
4377
  return item;
@@ -4088,17 +4379,17 @@ class LayerControl {
4088
4379
  /**
4089
4380
  * Show context menu at position
4090
4381
  */
4091
- showContextMenu(layerId, x, y) {
4382
+ showContextMenu(layerId, x2, y2) {
4092
4383
  if (!this.contextMenuEl) return;
4093
4384
  this.state.contextMenu = {
4094
4385
  visible: true,
4095
4386
  targetLayerId: layerId,
4096
- x,
4097
- y
4387
+ x: x2,
4388
+ y: y2
4098
4389
  };
4099
4390
  const mapRect = this.mapContainer.getBoundingClientRect();
4100
- let menuX = x - mapRect.left;
4101
- let menuY = y - mapRect.top;
4391
+ let menuX = x2 - mapRect.left;
4392
+ let menuY = y2 - mapRect.top;
4102
4393
  this.contextMenuEl.style.display = "block";
4103
4394
  const menuRect = this.contextMenuEl.getBoundingClientRect();
4104
4395
  if (menuX + menuRect.width > mapRect.width) {
@@ -4157,12 +4448,12 @@ class LayerControl {
4157
4448
  this.state.renamingLayerId = null;
4158
4449
  };
4159
4450
  input.addEventListener("blur", finishRename);
4160
- input.addEventListener("keydown", (e) => {
4161
- if (e.key === "Enter") {
4162
- e.preventDefault();
4451
+ input.addEventListener("keydown", (e2) => {
4452
+ if (e2.key === "Enter") {
4453
+ e2.preventDefault();
4163
4454
  finishRename();
4164
- } else if (e.key === "Escape") {
4165
- e.preventDefault();
4455
+ } else if (e2.key === "Escape") {
4456
+ e2.preventDefault();
4166
4457
  const newNameEl = document.createElement("span");
4167
4458
  newNameEl.className = "layer-control-name";
4168
4459
  newNameEl.textContent = currentName;
@@ -4247,7 +4538,7 @@ class LayerControl {
4247
4538
  var _a;
4248
4539
  const style = this.map.getStyle();
4249
4540
  if (!(style == null ? void 0 : style.layers)) return [];
4250
- const mapLayerIds = style.layers.map((l) => l.id);
4541
+ const mapLayerIds = style.layers.map((l2) => l2.id);
4251
4542
  const indexById = new Map(mapLayerIds.map((id, i) => [id, i]));
4252
4543
  const userLayerIds = Object.keys(this.state.layerStates).filter(
4253
4544
  (id) => id !== "Background"
@@ -4345,7 +4636,7 @@ class LayerControl {
4345
4636
  try {
4346
4637
  const targetBeforeId = index >= 2 ? this.findNextMapLibreLayer(layerIds, index - 2, -1) : void 0;
4347
4638
  this.map.moveLayer(layerId, targetBeforeId);
4348
- } catch (e) {
4639
+ } catch (e2) {
4349
4640
  }
4350
4641
  }
4351
4642
  const newLayerStates = {};
@@ -4364,7 +4655,7 @@ class LayerControl {
4364
4655
  });
4365
4656
  this.state.layerStates = newLayerStates;
4366
4657
  this.buildLayerItems();
4367
- (_b = this.onLayerReorder) == null ? void 0 : _b.call(this, this.getUserLayerIdsInMapOrder());
4658
+ (_b = this.onLayerReorder) == null ? void 0 : _b.call(this, orderedIds);
4368
4659
  }
4369
4660
  /**
4370
4661
  * Move a layer to the top (highest rendering order)
@@ -4382,7 +4673,7 @@ class LayerControl {
4382
4673
  if (!isCustom && this.isMapLibreLayer(layerId)) {
4383
4674
  try {
4384
4675
  this.map.moveLayer(layerId);
4385
- } catch (e) {
4676
+ } catch (e2) {
4386
4677
  }
4387
4678
  }
4388
4679
  const newLayerStates = {};
@@ -4399,7 +4690,7 @@ class LayerControl {
4399
4690
  });
4400
4691
  this.state.layerStates = newLayerStates;
4401
4692
  this.buildLayerItems();
4402
- (_b = this.onLayerReorder) == null ? void 0 : _b.call(this, this.getUserLayerIdsInMapOrder());
4693
+ (_b = this.onLayerReorder) == null ? void 0 : _b.call(this, orderedIds);
4403
4694
  }
4404
4695
  /**
4405
4696
  * Move a layer down in UI (lower rendering order = move to lower z-index)
@@ -4419,7 +4710,7 @@ class LayerControl {
4419
4710
  if (belowLayerId) {
4420
4711
  try {
4421
4712
  this.map.moveLayer(layerId, belowLayerId);
4422
- } catch (e) {
4713
+ } catch (e2) {
4423
4714
  }
4424
4715
  }
4425
4716
  }
@@ -4439,7 +4730,7 @@ class LayerControl {
4439
4730
  });
4440
4731
  this.state.layerStates = newLayerStates;
4441
4732
  this.buildLayerItems();
4442
- (_b = this.onLayerReorder) == null ? void 0 : _b.call(this, this.getUserLayerIdsInMapOrder());
4733
+ (_b = this.onLayerReorder) == null ? void 0 : _b.call(this, orderedIds);
4443
4734
  }
4444
4735
  /**
4445
4736
  * Move a layer to the bottom (lowest rendering order among user layers)
@@ -4464,7 +4755,7 @@ class LayerControl {
4464
4755
  if (bottomLayerId && bottomLayerId !== layerId) {
4465
4756
  try {
4466
4757
  this.map.moveLayer(layerId, bottomLayerId);
4467
- } catch (e) {
4758
+ } catch (e2) {
4468
4759
  }
4469
4760
  }
4470
4761
  }
@@ -4482,7 +4773,7 @@ class LayerControl {
4482
4773
  });
4483
4774
  this.state.layerStates = newLayerStates;
4484
4775
  this.buildLayerItems();
4485
- (_b = this.onLayerReorder) == null ? void 0 : _b.call(this, this.getUserLayerIdsInMapOrder());
4776
+ (_b = this.onLayerReorder) == null ? void 0 : _b.call(this, orderedIds);
4486
4777
  }
4487
4778
  /**
4488
4779
  * Move a layer within its own group (or among the top-level rows), so the
@@ -4584,15 +4875,15 @@ class LayerControl {
4584
4875
  const cancelBtn = document.createElement("button");
4585
4876
  cancelBtn.className = "layer-control-remove-confirm-btn layer-control-remove-confirm-btn-cancel";
4586
4877
  cancelBtn.textContent = "Cancel";
4587
- cancelBtn.addEventListener("click", (e) => {
4588
- e.stopPropagation();
4878
+ cancelBtn.addEventListener("click", (e2) => {
4879
+ e2.stopPropagation();
4589
4880
  confirmEl.remove();
4590
4881
  });
4591
4882
  const confirmBtn = document.createElement("button");
4592
4883
  confirmBtn.className = "layer-control-remove-confirm-btn layer-control-remove-confirm-btn-confirm";
4593
4884
  confirmBtn.textContent = "Remove";
4594
- confirmBtn.addEventListener("click", (e) => {
4595
- e.stopPropagation();
4885
+ confirmBtn.addEventListener("click", (e2) => {
4886
+ e2.stopPropagation();
4596
4887
  confirmEl.remove();
4597
4888
  onConfirm();
4598
4889
  });
@@ -4625,12 +4916,12 @@ class LayerControl {
4625
4916
  if (sourceId) {
4626
4917
  const style = this.map.getStyle();
4627
4918
  const sourceStillUsed = (_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.some(
4628
- (l) => l.source === sourceId
4919
+ (l2) => l2.source === sourceId
4629
4920
  );
4630
4921
  if (!sourceStillUsed) {
4631
4922
  try {
4632
4923
  this.map.removeSource(sourceId);
4633
- } catch (e) {
4924
+ } catch (e2) {
4634
4925
  }
4635
4926
  }
4636
4927
  }
@@ -4666,10 +4957,10 @@ class LayerControl {
4666
4957
  <circle cx="11" cy="13" r="1.5"/>
4667
4958
  </svg>`;
4668
4959
  handle.title = "Drag to reorder";
4669
- handle.addEventListener("pointerdown", (e) => {
4670
- e.preventDefault();
4671
- e.stopPropagation();
4672
- this.startDrag(layerId, e);
4960
+ handle.addEventListener("pointerdown", (e2) => {
4961
+ e2.preventDefault();
4962
+ e2.stopPropagation();
4963
+ this.startDrag(layerId, e2);
4673
4964
  });
4674
4965
  return handle;
4675
4966
  }
@@ -4692,7 +4983,7 @@ class LayerControl {
4692
4983
  /**
4693
4984
  * Start dragging a layer
4694
4985
  */
4695
- startDrag(layerId, e) {
4986
+ startDrag(layerId, e2) {
4696
4987
  var _a;
4697
4988
  const itemEl = this.panel.querySelector(
4698
4989
  `[data-layer-id="${layerId}"]`
@@ -4702,8 +4993,8 @@ class LayerControl {
4702
4993
  this.state.drag = {
4703
4994
  active: true,
4704
4995
  layerId,
4705
- startY: e.clientY,
4706
- currentY: e.clientY,
4996
+ startY: e2.clientY,
4997
+ currentY: e2.clientY,
4707
4998
  placeholder: null,
4708
4999
  draggedElement: null
4709
5000
  };
@@ -4736,26 +5027,26 @@ class LayerControl {
4736
5027
  /**
4737
5028
  * Handle drag move
4738
5029
  */
4739
- onDragMove(e) {
5030
+ onDragMove(e2) {
4740
5031
  var _a, _b;
4741
5032
  if (!this.state.drag.active || !this.state.drag.draggedElement) return;
4742
5033
  const placeholder = this.state.drag.placeholder;
4743
5034
  if (!placeholder) return;
4744
- const deltaY = e.clientY - this.state.drag.startY;
5035
+ const deltaY = e2.clientY - this.state.drag.startY;
4745
5036
  const clone = this.state.drag.draggedElement;
4746
5037
  const currentTop = parseFloat(clone.style.top) || 0;
4747
5038
  clone.style.top = `${currentTop + deltaY}px`;
4748
- this.state.drag.startY = e.clientY;
4749
- this.state.drag.currentY = e.clientY;
5039
+ this.state.drag.startY = e2.clientY;
5040
+ this.state.drag.currentY = e2.clientY;
4750
5041
  const scope = placeholder.parentElement;
4751
5042
  const items = Array.from((scope == null ? void 0 : scope.children) ?? []).filter(
4752
5043
  (item) => (item.classList.contains("layer-control-item") || item.classList.contains("layer-control-group")) && !item.classList.contains("dragging") && item.dataset.layerId !== "Background"
4753
5044
  );
4754
5045
  for (const item of items) {
4755
5046
  const itemRect = item.getBoundingClientRect();
4756
- if (e.clientY >= itemRect.top && e.clientY <= itemRect.bottom) {
5047
+ if (e2.clientY >= itemRect.top && e2.clientY <= itemRect.bottom) {
4757
5048
  const itemMiddle = itemRect.top + itemRect.height / 2;
4758
- if (e.clientY < itemMiddle) {
5049
+ if (e2.clientY < itemMiddle) {
4759
5050
  if (placeholder.nextSibling !== item) {
4760
5051
  (_a = item.parentNode) == null ? void 0 : _a.insertBefore(placeholder, item);
4761
5052
  }
@@ -4833,22 +5124,22 @@ class LayerControl {
4833
5124
  var _a;
4834
5125
  this.state.isStyleOperationInProgress = true;
4835
5126
  const style = this.map.getStyle();
4836
- const mapLibreLayerIds = new Set(((_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.map((l) => l.id)) || []);
5127
+ const mapLibreLayerIds = new Set(((_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.map((l2) => l2.id)) || []);
4837
5128
  for (let i = 0; i < uiLayerIds.length; i++) {
4838
5129
  const layerId = uiLayerIds[i];
4839
5130
  if (!mapLibreLayerIds.has(layerId)) {
4840
5131
  continue;
4841
5132
  }
4842
5133
  let beforeId = void 0;
4843
- for (let j = i - 1; j >= 0; j--) {
4844
- if (mapLibreLayerIds.has(uiLayerIds[j])) {
4845
- beforeId = uiLayerIds[j];
5134
+ for (let j2 = i - 1; j2 >= 0; j2--) {
5135
+ if (mapLibreLayerIds.has(uiLayerIds[j2])) {
5136
+ beforeId = uiLayerIds[j2];
4846
5137
  break;
4847
5138
  }
4848
5139
  }
4849
5140
  try {
4850
5141
  this.map.moveLayer(layerId, beforeId);
4851
- } catch (e) {
5142
+ } catch (e2) {
4852
5143
  }
4853
5144
  }
4854
5145
  setTimeout(() => {
@@ -4867,6 +5158,8 @@ export {
4867
5158
  getLayerColor,
4868
5159
  getLayerColorFromSpec,
4869
5160
  getLayerOpacity,
5161
+ getLayerSymbolStyle,
5162
+ getLayerSymbolStyleFromSpec,
4870
5163
  getLayerType,
4871
5164
  isStyleableLayerType,
4872
5165
  normalizeColor,