maplibre-gl-layer-control 0.18.1 → 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.cjs CHANGED
@@ -372,7 +372,7 @@ function cacheOriginalLayerStyle(map, layerId, originalStyles) {
372
372
  }
373
373
  const paint = {};
374
374
  const style = map.getStyle();
375
- const layerDef = (_a = style.layers) == null ? void 0 : _a.find((l) => l.id === layerId);
375
+ const layerDef = (_a = style.layers) == null ? void 0 : _a.find((l2) => l2.id === layerId);
376
376
  if (layer.type === "raster") {
377
377
  const rasterDefaults = {
378
378
  "raster-opacity": 1,
@@ -419,36 +419,194 @@ function restoreOriginalStyle(map, layerId, originalStyles) {
419
419
  });
420
420
  return applied;
421
421
  }
422
- function rgbToHex(r, g, b) {
423
- const clamp2 = (v) => Math.max(0, Math.min(255, Math.round(v)));
424
- const toHex = (v) => {
425
- const hex = clamp2(v).toString(16);
422
+ for (var r = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, t = function(r2) {
423
+ return "string" == typeof r2 ? r2.length > 0 : "number" == typeof r2;
424
+ }, n = function(r2, t2, n2) {
425
+ return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r2) / n2 + 0;
426
+ }, u = function(r2, t2, n2) {
427
+ return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r2 > n2 ? n2 : r2 > t2 ? r2 : t2;
428
+ }, e$1 = function(r2) {
429
+ return (r2 = isFinite(r2) ? r2 % 360 : 0) < 0 ? r2 + 360 : r2;
430
+ }, o = function(r2, t2) {
431
+ return void 0 === t2 && (t2 = 0), n(r2, t2) % 360;
432
+ }, a = function(r2) {
433
+ return { r: u(r2.r, 0, 255), g: u(r2.g, 0, 255), b: u(r2.b, 0, 255), a: u(r2.a) };
434
+ }, i = function(r2) {
435
+ return { r: n(r2.r), g: n(r2.g), b: n(r2.b), a: n(r2.a, 3) };
436
+ }, s = /^#([0-9a-f]{3,8})$/i, d = function(r2, t2) {
437
+ var n2 = r2.charCodeAt(t2);
438
+ return (15 & n2) + 9 * (n2 >> 6);
439
+ }, h = function(r2, t2) {
440
+ return d(r2, t2) << 4 | d(r2, t2 + 1);
441
+ }, b = [], f = 0; f < 256; f++) b.push((f < 16 ? "0" : "") + f.toString(16));
442
+ var g = function(r) {
443
+ return b[u(r, 0, 255)];
444
+ }, c = function(r) {
445
+ 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;
446
+ return { h: 60 * (i < 0 ? i + 6 : i), s: o ? a / o * 100 : 0, v: o / 255 * 100, a: e2 };
447
+ }, v = function(r) {
448
+ var t = r.h, n = r.s, u = r.v, e2 = r.a;
449
+ t = t / 360 * 6, n /= 100, u /= 100;
450
+ 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;
451
+ 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 };
452
+ }, l = function(r) {
453
+ return { h: e$1(r.h), s: u(r.s, 0, 100), l: u(r.l, 0, 100), a: u(r.a) };
454
+ }, p = function(r) {
455
+ return { h: o(r.h), s: n(r.s), l: n(r.l), a: n(r.a, 3) };
456
+ }, m = function(r) {
457
+ 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 }));
458
+ var t, n, u;
459
+ }, y = function(r) {
460
+ 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 };
461
+ var t, n, u, e2;
462
+ }, 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) {
463
+ if (!s.test(r)) return null;
464
+ var t = r.length;
465
+ 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;
466
+ }, "hex"], [function(r) {
467
+ var t = M.exec(r) || H.exec(r);
468
+ 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;
469
+ }, "rgb"], [function(t) {
470
+ var n = N.exec(t) || x.exec(t);
471
+ if (!n) return null;
472
+ 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) });
473
+ return m(o);
474
+ }, "hsl"]], object: [[function(r) {
475
+ var n = r.r, u = r.g, e2 = r.b, o = r.a, i = void 0 === o ? 1 : o;
476
+ return t(n) && t(u) && t(e2) ? a({ r: Number(n), g: Number(u), b: Number(e2), a: Number(i) }) : null;
477
+ }, "rgb"], [function(r) {
478
+ var n = r.h, u = r.s, e2 = r.l, o = r.a, a = void 0 === o ? 1 : o;
479
+ if (!t(n) || !t(u) || !t(e2)) return null;
480
+ var i = l({ h: Number(n), s: Number(u), l: Number(e2), a: Number(a) });
481
+ return m(i);
482
+ }, "hsl"], [function(r) {
483
+ var n = r.h, o = r.s, a = r.v, i = r.a, s = void 0 === i ? 1 : i;
484
+ if (!t(n) || !t(o) || !t(a)) return null;
485
+ var d = (function(r2) {
486
+ return { h: e$1(r2.h), s: u(r2.s, 0, 100), v: u(r2.v, 0, 100), a: u(r2.a) };
487
+ })({ h: Number(n), s: Number(o), v: Number(a), a: Number(s) });
488
+ return v(d);
489
+ }, "hsv"]] }, j = function(r, t) {
490
+ for (var n = 0; n < t.length; n++) {
491
+ var u = t[n][0](r);
492
+ if (u) return [u, t[n][1]];
493
+ }
494
+ return [null, void 0];
495
+ }, w = function(r) {
496
+ return "string" == typeof r ? j(r.trim(), $.string) : "object" == typeof r && null !== r ? j(r, $.object) : [null, void 0];
497
+ }, k = function(r, t) {
498
+ var n = y(r);
499
+ return { h: n.h, s: u(n.s + 100 * t, 0, 100), l: n.l, a: n.a };
500
+ }, E = function(r) {
501
+ return (299 * r.r + 587 * r.g + 114 * r.b) / 1e3 / 255;
502
+ }, R = function(r, t) {
503
+ var n = y(r);
504
+ return { h: n.h, s: n.s, l: u(n.l + 100 * t, 0, 100), a: n.a };
505
+ }, q = (function() {
506
+ function r(r2) {
507
+ this.parsed = w(r2)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
508
+ }
509
+ return r.prototype.isValid = function() {
510
+ return null !== this.parsed;
511
+ }, r.prototype.brightness = function() {
512
+ return n(E(this.rgba), 2);
513
+ }, r.prototype.isDark = function() {
514
+ return E(this.rgba) < 0.5;
515
+ }, r.prototype.isLight = function() {
516
+ return E(this.rgba) >= 0.5;
517
+ }, r.prototype.toHex = function() {
518
+ 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;
519
+ var r2, t, u, e2, o, a;
520
+ }, r.prototype.toRgb = function() {
521
+ return i(this.rgba);
522
+ }, r.prototype.toRgbString = function() {
523
+ 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 + ")";
524
+ var r2, t, n, u, e2;
525
+ }, r.prototype.toHsl = function() {
526
+ return p(y(this.rgba));
527
+ }, r.prototype.toHslString = function() {
528
+ 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 + "%)";
529
+ var r2, t, n, u, e2;
530
+ }, r.prototype.toHsv = function() {
531
+ return r2 = c(this.rgba), { h: o(r2.h), s: n(r2.s), v: n(r2.v), a: n(r2.a, 3) };
532
+ var r2;
533
+ }, r.prototype.invert = function() {
534
+ return A({ r: 255 - (r2 = this.rgba).r, g: 255 - r2.g, b: 255 - r2.b, a: r2.a });
535
+ var r2;
536
+ }, r.prototype.saturate = function(r2) {
537
+ return void 0 === r2 && (r2 = 0.1), A(k(this.rgba, r2));
538
+ }, r.prototype.desaturate = function(r2) {
539
+ return void 0 === r2 && (r2 = 0.1), A(k(this.rgba, -r2));
540
+ }, r.prototype.grayscale = function() {
541
+ return A(k(this.rgba, -1));
542
+ }, r.prototype.lighten = function(r2) {
543
+ return void 0 === r2 && (r2 = 0.1), A(R(this.rgba, r2));
544
+ }, r.prototype.darken = function(r2) {
545
+ return void 0 === r2 && (r2 = 0.1), A(R(this.rgba, -r2));
546
+ }, r.prototype.rotate = function(r2) {
547
+ return void 0 === r2 && (r2 = 15), this.hue(y(this.rgba).h + r2);
548
+ }, r.prototype.alpha = function(r2) {
549
+ return "number" == typeof r2 ? A({ r: (t = this.rgba).r, g: t.g, b: t.b, a: r2 }) : n(this.rgba.a, 3);
550
+ var t;
551
+ }, r.prototype.hue = function(r2) {
552
+ var t = y(this.rgba);
553
+ return "number" == typeof r2 ? A({ h: r2, s: t.s, l: t.l, a: t.a }) : o(t.h);
554
+ }, r.prototype.isEqual = function(r2) {
555
+ return this.toHex() === A(r2).toHex();
556
+ }, r;
557
+ })(), A = function(r) {
558
+ return r instanceof q ? r : new q(r);
559
+ }, C = [], D = function(r) {
560
+ r.forEach(function(r2) {
561
+ C.indexOf(r2) < 0 && (r2(q, $), C.push(r2));
562
+ });
563
+ };
564
+ var e = function(e2, f) {
565
+ 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 = {};
566
+ for (var d in a) r[a[d]] = d;
567
+ var l2 = {};
568
+ e2.prototype.toName = function(f2) {
569
+ if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b)) return "transparent";
570
+ var d2, i, n = r[this.toHex()];
571
+ if (n) return n;
572
+ if (null == f2 ? void 0 : f2.closest) {
573
+ var o = this.toRgb(), t = 1 / 0, b = "black";
574
+ if (!l2.length) for (var c2 in a) l2[c2] = new e2(a[c2]).toRgb();
575
+ for (var g2 in a) {
576
+ 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));
577
+ u < t && (t = u, b = g2);
578
+ }
579
+ return b;
580
+ }
581
+ };
582
+ f.string.push([function(f2) {
583
+ var r2 = f2.toLowerCase(), d2 = "transparent" === r2 ? "#0000" : a[r2];
584
+ return d2 ? new e2(d2).toRgb() : null;
585
+ }, "name"]);
586
+ };
587
+ D([e]);
588
+ function rgbToHex(r, g2, b) {
589
+ const clamp2 = (v2) => Math.max(0, Math.min(255, Math.round(v2)));
590
+ const toHex = (v2) => {
591
+ const hex = clamp2(v2).toString(16);
426
592
  return hex.length === 1 ? `0${hex}` : hex;
427
593
  };
428
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
594
+ return `#${toHex(r)}${toHex(g2)}${toHex(b)}`;
429
595
  }
430
596
  function normalizeColor(value) {
431
597
  if (typeof value === "string") {
432
- if (value.startsWith("#")) {
433
- if (value.length === 4) {
434
- const r = value[1];
435
- const g = value[2];
436
- const b = value[3];
437
- return `#${r}${r}${g}${g}${b}${b}`;
438
- }
439
- return value;
440
- }
441
- if (value.startsWith("rgb")) {
442
- const match = value.match(/\d+/g);
443
- if (match && match.length >= 3) {
444
- const [r, g, b] = match.map((num) => parseInt(num, 10));
445
- return rgbToHex(r, g, b);
446
- }
598
+ const color = A(value);
599
+ if (!color.isValid()) return null;
600
+ const { r, g: g2, b } = color.toRgb();
601
+ return rgbToHex(r, g2, b);
602
+ }
603
+ if (Array.isArray(value) && value.length >= 3) {
604
+ const [r, g2, b] = value;
605
+ if (typeof r === "number" && Number.isFinite(r) && typeof g2 === "number" && Number.isFinite(g2) && typeof b === "number" && Number.isFinite(b)) {
606
+ return rgbToHex(r, g2, b);
447
607
  }
448
- } else if (Array.isArray(value) && value.length >= 3) {
449
- return rgbToHex(value[0], value[1], value[2]);
450
608
  }
451
- return "#3388ff";
609
+ return null;
452
610
  }
453
611
  function formatNumericValue(value, step) {
454
612
  let decimals = 0;
@@ -472,17 +630,49 @@ const COLOR_PROPERTY_MAP = {
472
630
  heatmap: ["heatmap-color"],
473
631
  "fill-extrusion": ["fill-extrusion-color"]
474
632
  };
475
- function extractColorFromExpression(expression) {
476
- if (!Array.isArray(expression) || expression.length === 0) return null;
477
- for (const item of expression) {
633
+ function isExpressionArray(value) {
634
+ return Array.isArray(value);
635
+ }
636
+ function extractColorFromExpression(expression, preserveFormat = false) {
637
+ if (!isExpressionArray(expression) || expression.length === 0) return null;
638
+ const operator = expression[0];
639
+ const components = expression.slice(1);
640
+ if (operator === "rgb" && components.length === 3 || operator === "rgba" && components.length === 4) {
641
+ if (components.every(
642
+ (component) => typeof component === "number" && Number.isFinite(component)
643
+ )) {
644
+ const color = `${operator}(${components.join(", ")})`;
645
+ return preserveFormat ? color : normalizeColor(color);
646
+ }
647
+ }
648
+ let index = 0;
649
+ let stride = 1;
650
+ let end = expression.length;
651
+ let fallbackIndex = -1;
652
+ let firstResultIndex = 0;
653
+ if (operator === "case" || operator === "match") {
654
+ firstResultIndex = operator === "case" ? 2 : 3;
655
+ index = firstResultIndex;
656
+ stride = 2;
657
+ end = expression.length - 1;
658
+ fallbackIndex = expression.length - 1;
659
+ } else if (operator === "interpolate") {
660
+ index = 4;
661
+ stride = 2;
662
+ }
663
+ const resolve = (item) => {
478
664
  if (typeof item === "string") {
479
- if (item.startsWith("#") || item.startsWith("rgb") || item.startsWith("hsl")) {
480
- return normalizeColor(item);
481
- }
482
- } else if (Array.isArray(item)) {
483
- const result = extractColorFromExpression(item);
484
- if (result) return result;
665
+ const color = normalizeColor(item);
666
+ return color !== null && preserveFormat ? item : color;
485
667
  }
668
+ return isExpressionArray(item) ? extractColorFromExpression(item, preserveFormat) : null;
669
+ };
670
+ for (; index < end; index += stride) {
671
+ const color = resolve(expression[index]);
672
+ if (color !== null) return color;
673
+ }
674
+ if (fallbackIndex >= firstResultIndex) {
675
+ return resolve(expression[fallbackIndex]);
486
676
  }
487
677
  return null;
488
678
  }
@@ -495,28 +685,30 @@ function getLayerColor(map, layerId, layerType) {
495
685
  const runtimeColor = map.getPaintProperty(layerId, propertyName);
496
686
  if (runtimeColor) {
497
687
  if (typeof runtimeColor === "string") {
498
- return normalizeColor(runtimeColor);
688
+ const color = normalizeColor(runtimeColor);
689
+ if (color !== null) return color;
499
690
  }
500
691
  if (Array.isArray(runtimeColor)) {
501
692
  const extracted = extractColorFromExpression(runtimeColor);
502
- if (extracted) return extracted;
693
+ if (extracted !== null) return extracted;
503
694
  }
504
695
  }
505
696
  } catch {
506
697
  }
507
698
  const style = map.getStyle();
508
699
  const layer = (_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.find(
509
- (l) => l.id === layerId
700
+ (styleLayer) => styleLayer.id === layerId
510
701
  );
511
702
  if (layer && "paint" in layer && layer.paint) {
512
703
  const paintColor = layer.paint[propertyName];
513
704
  if (paintColor) {
514
705
  if (typeof paintColor === "string") {
515
- return normalizeColor(paintColor);
706
+ const color = normalizeColor(paintColor);
707
+ if (color !== null) return color;
516
708
  }
517
709
  if (Array.isArray(paintColor)) {
518
710
  const extracted = extractColorFromExpression(paintColor);
519
- if (extracted) return extracted;
711
+ if (extracted !== null) return extracted;
520
712
  }
521
713
  }
522
714
  }
@@ -531,17 +723,81 @@ function getLayerColorFromSpec(layer) {
531
723
  const paintColor = layer.paint[propertyName];
532
724
  if (paintColor) {
533
725
  if (typeof paintColor === "string") {
534
- return normalizeColor(paintColor);
726
+ const color = normalizeColor(paintColor);
727
+ if (color !== null) return color;
535
728
  }
536
729
  if (Array.isArray(paintColor)) {
537
730
  const extracted = extractColorFromExpression(paintColor);
538
- if (extracted) return extracted;
731
+ if (extracted !== null) return extracted;
539
732
  }
540
733
  }
541
734
  }
542
735
  }
543
736
  return null;
544
737
  }
738
+ function extractDasharray(value) {
739
+ if (!Array.isArray(value)) return null;
740
+ if (value.length > 0 && value.every((item) => typeof item === "number" && Number.isFinite(item))) {
741
+ const dasharray = value;
742
+ if (dasharray.every((item) => item >= 0) && dasharray.some((item) => item > 0)) {
743
+ return dasharray;
744
+ }
745
+ return null;
746
+ }
747
+ for (const item of value) {
748
+ if (Array.isArray(item)) {
749
+ const dasharray = extractDasharray(item);
750
+ if (dasharray) return dasharray;
751
+ }
752
+ }
753
+ return null;
754
+ }
755
+ function resolveSymbolStyle(layerType, getPaint) {
756
+ if (layerType === "line") {
757
+ const dasharray = extractDasharray(getPaint("line-dasharray"));
758
+ return dasharray ? { dasharray } : {};
759
+ }
760
+ if (layerType === "circle") {
761
+ if (getPaint("circle-stroke-width") === 0) {
762
+ return { strokeColor: null };
763
+ }
764
+ const color = getPaint("circle-stroke-color");
765
+ if (typeof color === "string") {
766
+ return { strokeColor: color };
767
+ }
768
+ if (isExpressionArray(color)) {
769
+ const strokeColor = extractColorFromExpression(color, true);
770
+ return strokeColor ? { strokeColor } : {};
771
+ }
772
+ }
773
+ return {};
774
+ }
775
+ function getLayerSymbolStyle(map, layerId, layerType) {
776
+ const getPaint = (property) => {
777
+ var _a, _b;
778
+ let value;
779
+ try {
780
+ value = map.getPaintProperty(layerId, property);
781
+ } catch {
782
+ }
783
+ if (value !== void 0 && value !== null) return value;
784
+ const layer = (_b = (_a = map.getStyle()) == null ? void 0 : _a.layers) == null ? void 0 : _b.find((item) => item.id === layerId);
785
+ if (layer && "paint" in layer && layer.paint) {
786
+ return layer.paint[property];
787
+ }
788
+ return void 0;
789
+ };
790
+ return resolveSymbolStyle(layerType, getPaint);
791
+ }
792
+ function getLayerSymbolStyleFromSpec(layer) {
793
+ const getPaint = (property) => {
794
+ if ("paint" in layer && layer.paint) {
795
+ return layer.paint[property];
796
+ }
797
+ return void 0;
798
+ };
799
+ return resolveSymbolStyle(layer.type, getPaint);
800
+ }
545
801
  function darkenColor(hexColor, amount) {
546
802
  let hex = hexColor.replace("#", "");
547
803
  if (hex.length === 3) {
@@ -551,7 +807,7 @@ function darkenColor(hexColor, amount) {
551
807
  0,
552
808
  parseInt(hex.slice(0, 2), 16) - Math.round(255 * amount)
553
809
  );
554
- const g = Math.max(
810
+ const g2 = Math.max(
555
811
  0,
556
812
  parseInt(hex.slice(2, 4), 16) - Math.round(255 * amount)
557
813
  );
@@ -559,7 +815,7 @@ function darkenColor(hexColor, amount) {
559
815
  0,
560
816
  parseInt(hex.slice(4, 6), 16) - Math.round(255 * amount)
561
817
  );
562
- return rgbToHex(r, g, b);
818
+ return rgbToHex(r, g2, b);
563
819
  }
564
820
  function createFillSymbol(size, color) {
565
821
  const padding = 2;
@@ -569,22 +825,32 @@ function createFillSymbol(size, color) {
569
825
  fill="${color}" stroke="${borderColor}" stroke-width="1" rx="1"/>
570
826
  </svg>`;
571
827
  }
572
- function createLineSymbol(size, color, strokeWidth = 2) {
573
- const y = size / 2;
828
+ function createLineSymbol(size, color, strokeWidth = 2, dasharray) {
829
+ const y2 = size / 2;
574
830
  const padding = 2;
831
+ let dashAttributes = 'stroke-linecap="round"';
832
+ if (dasharray && dasharray.length > 0) {
833
+ const lineLength = size - padding * 2;
834
+ const dashLength = dasharray[0];
835
+ const gapLength = dasharray.length > 1 ? dasharray[1] : dashLength;
836
+ const fitLength = dashLength + gapLength + dashLength;
837
+ const scale = fitLength > 0 ? Math.min(strokeWidth, lineLength / fitLength) : strokeWidth;
838
+ const scaledDasharray = dasharray.map((value) => Number((value * scale).toFixed(2))).join(" ");
839
+ dashAttributes = `stroke-linecap="butt" stroke-dasharray="${scaledDasharray}"`;
840
+ }
575
841
  return `<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}" xmlns="http://www.w3.org/2000/svg">
576
- <line x1="${padding}" y1="${y}" x2="${size - padding}" y2="${y}"
577
- stroke="${color}" stroke-width="${strokeWidth}" stroke-linecap="round"/>
842
+ <line x1="${padding}" y1="${y2}" x2="${size - padding}" y2="${y2}"
843
+ stroke="${color}" stroke-width="${strokeWidth}" ${dashAttributes}/>
578
844
  </svg>`;
579
845
  }
580
- function createCircleSymbol(size, color) {
846
+ function createCircleSymbol(size, color, strokeColor) {
581
847
  const cx = size / 2;
582
848
  const cy = size / 2;
583
849
  const r = size / 2 - 3;
584
- const borderColor = darkenColor(color, 0.3);
850
+ const borderAttributes = strokeColor === void 0 ? `stroke="${darkenColor(color, 0.3)}" stroke-width="1"` : strokeColor === null ? 'stroke="none"' : `stroke="${strokeColor}" stroke-width="1"`;
585
851
  return `<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}" xmlns="http://www.w3.org/2000/svg">
586
852
  <circle cx="${cx}" cy="${cy}" r="${r}" fill="${color}"
587
- stroke="${borderColor}" stroke-width="1"/>
853
+ ${borderAttributes}/>
588
854
  </svg>`;
589
855
  }
590
856
  function createMarkerSymbol(size, color) {
@@ -731,9 +997,9 @@ function createLayerSymbolSVG(layerType, color, options = {}) {
731
997
  case "fill":
732
998
  return createFillSymbol(size, fillColor);
733
999
  case "line":
734
- return createLineSymbol(size, fillColor, strokeWidth);
1000
+ return createLineSymbol(size, fillColor, strokeWidth, options.dasharray);
735
1001
  case "circle":
736
- return createCircleSymbol(size, fillColor);
1002
+ return createCircleSymbol(size, fillColor, options.strokeColor);
737
1003
  case "symbol":
738
1004
  return createMarkerSymbol(size, fillColor);
739
1005
  case "raster":
@@ -1178,7 +1444,7 @@ class LayerControl {
1178
1444
  } else if (src.data && typeof src.data === "string") {
1179
1445
  try {
1180
1446
  const url = new URL(src.data);
1181
- const isBasemap = knownBasemapProviders.some((p) => url.hostname.includes(p)) || basemapDomains.has(url.hostname);
1447
+ const isBasemap = knownBasemapProviders.some((p2) => url.hostname.includes(p2)) || basemapDomains.has(url.hostname);
1182
1448
  if (!isBasemap) {
1183
1449
  userAddedSources.add(sourceId);
1184
1450
  }
@@ -1582,8 +1848,8 @@ class LayerControl {
1582
1848
  */
1583
1849
  setupEventListeners() {
1584
1850
  this.button.addEventListener("click", () => this.toggle());
1585
- document.addEventListener("click", (e) => {
1586
- const target = e.target;
1851
+ document.addEventListener("click", (e2) => {
1852
+ const target = e2.target;
1587
1853
  if (this.contextMenuEl && this.state.contextMenu.visible) {
1588
1854
  if (!this.contextMenuEl.contains(target)) {
1589
1855
  this.hideContextMenu();
@@ -1617,16 +1883,16 @@ class LayerControl {
1617
1883
  this.checkForNewLayers();
1618
1884
  }, 100);
1619
1885
  });
1620
- this.map.on("data", (e) => {
1621
- if (e.sourceDataType === "content") {
1886
+ this.map.on("data", (e2) => {
1887
+ if (e2.sourceDataType === "content") {
1622
1888
  setTimeout(() => {
1623
1889
  this.updateLayerStatesFromMap();
1624
1890
  this.checkForNewLayers();
1625
1891
  }, 100);
1626
1892
  }
1627
1893
  });
1628
- this.map.on("sourcedata", (e) => {
1629
- if (e.sourceDataType === "metadata") {
1894
+ this.map.on("sourcedata", (e2) => {
1895
+ if (e2.sourceDataType === "metadata") {
1630
1896
  setTimeout(() => {
1631
1897
  this.checkForNewLayers();
1632
1898
  }, 150);
@@ -1829,9 +2095,9 @@ class LayerControl {
1829
2095
  toggle.innerHTML = `<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
1830
2096
  <path d="M6 4l4 4-4 4z"/>
1831
2097
  </svg>`;
1832
- toggle.addEventListener("click", (e) => {
2098
+ toggle.addEventListener("click", (e2) => {
1833
2099
  var _a;
1834
- e.stopPropagation();
2100
+ e2.stopPropagation();
1835
2101
  this.setGroupCollapsed(group.id, !((_a = this.groupStates.get(group.id)) == null ? void 0 : _a.collapsed));
1836
2102
  });
1837
2103
  row.appendChild(toggle);
@@ -2061,10 +2327,10 @@ class LayerControl {
2061
2327
  }
2062
2328
  item.appendChild(row);
2063
2329
  if (this.enableContextMenu && layerId !== "Background") {
2064
- row.addEventListener("contextmenu", (e) => {
2065
- e.preventDefault();
2066
- e.stopPropagation();
2067
- this.showContextMenu(layerId, e.clientX, e.clientY);
2330
+ row.addEventListener("contextmenu", (e2) => {
2331
+ e2.preventDefault();
2332
+ e2.stopPropagation();
2333
+ this.showContextMenu(layerId, e2.clientX, e2.clientY);
2068
2334
  });
2069
2335
  }
2070
2336
  container.appendChild(item);
@@ -2090,7 +2356,8 @@ class LayerControl {
2090
2356
  if (!layer) return null;
2091
2357
  const layerType = layer.type;
2092
2358
  const color = getLayerColor(this.map, layerId, layerType);
2093
- const svgMarkup = createLayerSymbolSVG(layerType, color);
2359
+ const symbolStyle = getLayerSymbolStyle(this.map, layerId, layerType);
2360
+ const svgMarkup = createLayerSymbolSVG(layerType, color, symbolStyle);
2094
2361
  const symbolContainer = document.createElement("span");
2095
2362
  symbolContainer.className = "layer-control-symbol";
2096
2363
  symbolContainer.innerHTML = svgMarkup;
@@ -2104,7 +2371,11 @@ class LayerControl {
2104
2371
  */
2105
2372
  createBackgroundLayerSymbol(layer) {
2106
2373
  const color = getLayerColorFromSpec(layer);
2107
- const svgMarkup = createLayerSymbolSVG(layer.type, color, { size: 14 });
2374
+ const symbolStyle = getLayerSymbolStyleFromSpec(layer);
2375
+ const svgMarkup = createLayerSymbolSVG(layer.type, color, {
2376
+ size: 14,
2377
+ ...symbolStyle
2378
+ });
2108
2379
  const symbolContainer = document.createElement("span");
2109
2380
  symbolContainer.className = "background-legend-layer-symbol";
2110
2381
  symbolContainer.innerHTML = svgMarkup;
@@ -2361,8 +2632,8 @@ class LayerControl {
2361
2632
  "aria-expanded",
2362
2633
  String(this.state.backgroundLegendOpen)
2363
2634
  );
2364
- button.addEventListener("click", (e) => {
2365
- e.stopPropagation();
2635
+ button.addEventListener("click", (e2) => {
2636
+ e2.stopPropagation();
2366
2637
  this.toggleBackgroundLegend();
2367
2638
  });
2368
2639
  return button;
@@ -2446,8 +2717,8 @@ class LayerControl {
2446
2717
  closeBtn.className = "background-legend-close";
2447
2718
  closeBtn.innerHTML = "&times;";
2448
2719
  closeBtn.title = "Close";
2449
- closeBtn.addEventListener("click", (e) => {
2450
- e.stopPropagation();
2720
+ closeBtn.addEventListener("click", (e2) => {
2721
+ e2.stopPropagation();
2451
2722
  this.closeBackgroundLegend();
2452
2723
  });
2453
2724
  header.appendChild(title);
@@ -2554,12 +2825,12 @@ class LayerControl {
2554
2825
  applyBtn.disabled = !hasSelection;
2555
2826
  deleteBtn.disabled = !hasSelection;
2556
2827
  });
2557
- applyBtn.addEventListener("click", (e) => {
2558
- e.stopPropagation();
2828
+ applyBtn.addEventListener("click", (e2) => {
2829
+ e2.stopPropagation();
2559
2830
  if (select.value) this.applyBackgroundPreset(select.value);
2560
2831
  });
2561
- deleteBtn.addEventListener("click", (e) => {
2562
- e.stopPropagation();
2832
+ deleteBtn.addEventListener("click", (e2) => {
2833
+ e2.stopPropagation();
2563
2834
  if (select.value) {
2564
2835
  this.deleteBackgroundPreset(select.value);
2565
2836
  refreshSelect();
@@ -2586,13 +2857,13 @@ class LayerControl {
2586
2857
  nameInput.value = "";
2587
2858
  refreshSelect(name);
2588
2859
  };
2589
- saveBtn.addEventListener("click", (e) => {
2590
- e.stopPropagation();
2860
+ saveBtn.addEventListener("click", (e2) => {
2861
+ e2.stopPropagation();
2591
2862
  commitSave();
2592
2863
  });
2593
- nameInput.addEventListener("keydown", (e) => {
2594
- if (e.key === "Enter") {
2595
- e.preventDefault();
2864
+ nameInput.addEventListener("keydown", (e2) => {
2865
+ if (e2.key === "Enter") {
2866
+ e2.preventDefault();
2596
2867
  commitSave();
2597
2868
  }
2598
2869
  });
@@ -2911,8 +3182,8 @@ class LayerControl {
2911
3182
  button.title = "Edit layer style";
2912
3183
  button.setAttribute("aria-label", `Edit style for ${layerId}`);
2913
3184
  }
2914
- button.addEventListener("click", (e) => {
2915
- e.stopPropagation();
3185
+ button.addEventListener("click", (e2) => {
3186
+ e2.stopPropagation();
2916
3187
  this.toggleStyleEditor(layerId);
2917
3188
  });
2918
3189
  return button;
@@ -3006,8 +3277,8 @@ class LayerControl {
3006
3277
  closeBtn.className = "style-editor-close";
3007
3278
  closeBtn.innerHTML = "&times;";
3008
3279
  closeBtn.title = "Close";
3009
- closeBtn.addEventListener("click", (e) => {
3010
- e.stopPropagation();
3280
+ closeBtn.addEventListener("click", (e2) => {
3281
+ e2.stopPropagation();
3011
3282
  this.closeStyleEditor(layerId);
3012
3283
  });
3013
3284
  header.appendChild(title);
@@ -3024,8 +3295,8 @@ class LayerControl {
3024
3295
  removeBtn.className = "style-editor-button style-editor-button-remove";
3025
3296
  removeBtn.textContent = "Remove Layer";
3026
3297
  removeBtn.title = "Remove layer from map";
3027
- removeBtn.addEventListener("click", (e) => {
3028
- e.stopPropagation();
3298
+ removeBtn.addEventListener("click", (e2) => {
3299
+ e2.stopPropagation();
3029
3300
  this.showRemoveConfirmation(editor, () => {
3030
3301
  this.closeStyleEditor(layerId);
3031
3302
  this.removeLayer(layerId);
@@ -3034,8 +3305,8 @@ class LayerControl {
3034
3305
  const closeActionBtn = document.createElement("button");
3035
3306
  closeActionBtn.className = "style-editor-button style-editor-button-close";
3036
3307
  closeActionBtn.textContent = "Close";
3037
- closeActionBtn.addEventListener("click", (e) => {
3038
- e.stopPropagation();
3308
+ closeActionBtn.addEventListener("click", (e2) => {
3309
+ e2.stopPropagation();
3039
3310
  this.closeStyleEditor(layerId);
3040
3311
  });
3041
3312
  actions.appendChild(removeBtn);
@@ -3073,8 +3344,8 @@ class LayerControl {
3073
3344
  closeBtn.className = "style-editor-close";
3074
3345
  closeBtn.innerHTML = "&times;";
3075
3346
  closeBtn.title = "Close";
3076
- closeBtn.addEventListener("click", (e) => {
3077
- e.stopPropagation();
3347
+ closeBtn.addEventListener("click", (e2) => {
3348
+ e2.stopPropagation();
3078
3349
  this.closeStyleEditor(layerId);
3079
3350
  });
3080
3351
  header.appendChild(title);
@@ -3104,8 +3375,8 @@ class LayerControl {
3104
3375
  const resetBtn = document.createElement("button");
3105
3376
  resetBtn.className = "style-editor-button style-editor-button-reset";
3106
3377
  resetBtn.textContent = "Reset Style";
3107
- resetBtn.addEventListener("click", (e) => {
3108
- e.stopPropagation();
3378
+ resetBtn.addEventListener("click", (e2) => {
3379
+ e2.stopPropagation();
3109
3380
  for (const nativeId of nativeLayerIds) {
3110
3381
  restoreOriginalStyle(this.map, nativeId, this.state.originalStyles);
3111
3382
  }
@@ -3117,10 +3388,10 @@ class LayerControl {
3117
3388
  if (!property || !sourceId) return;
3118
3389
  const value = this.map.getPaintProperty(sourceId, property);
3119
3390
  if (value !== void 0) {
3120
- this.notifyLayerStyleChange(
3121
- property,
3122
- typeof value === "number" ? value : normalizeColor(value)
3123
- );
3391
+ const color = typeof value === "number" ? value : normalizeColor(value);
3392
+ if (color !== null) {
3393
+ this.notifyLayerStyleChange(property, color);
3394
+ }
3124
3395
  }
3125
3396
  });
3126
3397
  }
@@ -3131,8 +3402,8 @@ class LayerControl {
3131
3402
  removeBtn.className = "style-editor-button style-editor-button-remove";
3132
3403
  removeBtn.textContent = "Remove Layer";
3133
3404
  removeBtn.title = "Remove layer from map";
3134
- removeBtn.addEventListener("click", (e) => {
3135
- e.stopPropagation();
3405
+ removeBtn.addEventListener("click", (e2) => {
3406
+ e2.stopPropagation();
3136
3407
  this.showRemoveConfirmation(editor, () => {
3137
3408
  this.closeStyleEditor(layerId);
3138
3409
  this.removeLayer(layerId);
@@ -3141,8 +3412,8 @@ class LayerControl {
3141
3412
  const closeActionBtn = document.createElement("button");
3142
3413
  closeActionBtn.className = "style-editor-button style-editor-button-close";
3143
3414
  closeActionBtn.textContent = "Close";
3144
- closeActionBtn.addEventListener("click", (e) => {
3145
- e.stopPropagation();
3415
+ closeActionBtn.addEventListener("click", (e2) => {
3416
+ e2.stopPropagation();
3146
3417
  this.closeStyleEditor(layerId);
3147
3418
  });
3148
3419
  actions.appendChild(resetBtn);
@@ -3191,8 +3462,8 @@ class LayerControl {
3191
3462
  closeBtn.className = "style-editor-close";
3192
3463
  closeBtn.innerHTML = "&times;";
3193
3464
  closeBtn.title = "Close";
3194
- closeBtn.addEventListener("click", (e) => {
3195
- e.stopPropagation();
3465
+ closeBtn.addEventListener("click", (e2) => {
3466
+ e2.stopPropagation();
3196
3467
  this.closeStyleEditor(layerId);
3197
3468
  });
3198
3469
  header.appendChild(title);
@@ -3206,16 +3477,16 @@ class LayerControl {
3206
3477
  const resetBtn = document.createElement("button");
3207
3478
  resetBtn.className = "style-editor-button style-editor-button-reset";
3208
3479
  resetBtn.textContent = "Reset Style";
3209
- resetBtn.addEventListener("click", (e) => {
3210
- e.stopPropagation();
3480
+ resetBtn.addEventListener("click", (e2) => {
3481
+ e2.stopPropagation();
3211
3482
  this.resetLayerStyle(layerId);
3212
3483
  });
3213
3484
  const removeBtn = document.createElement("button");
3214
3485
  removeBtn.className = "style-editor-button style-editor-button-remove";
3215
3486
  removeBtn.textContent = "Remove Layer";
3216
3487
  removeBtn.title = "Remove layer from map";
3217
- removeBtn.addEventListener("click", (e) => {
3218
- e.stopPropagation();
3488
+ removeBtn.addEventListener("click", (e2) => {
3489
+ e2.stopPropagation();
3219
3490
  this.showRemoveConfirmation(editor, () => {
3220
3491
  this.closeStyleEditor(layerId);
3221
3492
  this.removeLayer(layerId);
@@ -3224,8 +3495,8 @@ class LayerControl {
3224
3495
  const closeActionBtn = document.createElement("button");
3225
3496
  closeActionBtn.className = "style-editor-button style-editor-button-close";
3226
3497
  closeActionBtn.textContent = "Close";
3227
- closeActionBtn.addEventListener("click", (e) => {
3228
- e.stopPropagation();
3498
+ closeActionBtn.addEventListener("click", (e2) => {
3499
+ e2.stopPropagation();
3229
3500
  this.closeStyleEditor(layerId);
3230
3501
  });
3231
3502
  actions.appendChild(resetBtn);
@@ -3266,7 +3537,7 @@ class LayerControl {
3266
3537
  addFillControls(container, layerId) {
3267
3538
  var _a;
3268
3539
  const style = this.map.getStyle();
3269
- const layer = (_a = style.layers) == null ? void 0 : _a.find((l) => l.id === layerId);
3540
+ const layer = (_a = style.layers) == null ? void 0 : _a.find((l2) => l2.id === layerId);
3270
3541
  let fillColor = void 0;
3271
3542
  if (layer && "paint" in layer && layer.paint && "fill-color" in layer.paint) {
3272
3543
  fillColor = layer.paint["fill-color"];
@@ -3274,13 +3545,16 @@ class LayerControl {
3274
3545
  if (!fillColor) {
3275
3546
  fillColor = this.map.getPaintProperty(layerId, "fill-color");
3276
3547
  }
3277
- this.createColorControl(
3278
- container,
3279
- layerId,
3280
- "fill-color",
3281
- "Fill Color",
3282
- normalizeColor(fillColor || "#088")
3283
- );
3548
+ const normalizedFillColor = normalizeColor(fillColor || "#088");
3549
+ if (normalizedFillColor !== null) {
3550
+ this.createColorControl(
3551
+ container,
3552
+ layerId,
3553
+ "fill-color",
3554
+ "Fill Color",
3555
+ normalizedFillColor
3556
+ );
3557
+ }
3284
3558
  const fillOpacity = this.map.getPaintProperty(layerId, "fill-opacity");
3285
3559
  if (fillOpacity !== void 0 && typeof fillOpacity === "number") {
3286
3560
  this.createSliderControl(
@@ -3299,13 +3573,16 @@ class LayerControl {
3299
3573
  "fill-outline-color"
3300
3574
  );
3301
3575
  if (outlineColor !== void 0) {
3302
- this.createColorControl(
3303
- container,
3304
- layerId,
3305
- "fill-outline-color",
3306
- "Outline Color",
3307
- normalizeColor(outlineColor)
3308
- );
3576
+ const normalizedOutlineColor = normalizeColor(outlineColor);
3577
+ if (normalizedOutlineColor !== null) {
3578
+ this.createColorControl(
3579
+ container,
3580
+ layerId,
3581
+ "fill-outline-color",
3582
+ "Outline Color",
3583
+ normalizedOutlineColor
3584
+ );
3585
+ }
3309
3586
  }
3310
3587
  }
3311
3588
  /**
@@ -3314,7 +3591,7 @@ class LayerControl {
3314
3591
  addLineControls(container, layerId) {
3315
3592
  var _a;
3316
3593
  const style = this.map.getStyle();
3317
- const layer = (_a = style.layers) == null ? void 0 : _a.find((l) => l.id === layerId);
3594
+ const layer = (_a = style.layers) == null ? void 0 : _a.find((l2) => l2.id === layerId);
3318
3595
  let lineColor = void 0;
3319
3596
  if (layer && "paint" in layer && layer.paint && "line-color" in layer.paint) {
3320
3597
  lineColor = layer.paint["line-color"];
@@ -3322,13 +3599,16 @@ class LayerControl {
3322
3599
  if (!lineColor) {
3323
3600
  lineColor = this.map.getPaintProperty(layerId, "line-color");
3324
3601
  }
3325
- this.createColorControl(
3326
- container,
3327
- layerId,
3328
- "line-color",
3329
- "Line Color",
3330
- normalizeColor(lineColor || "#000")
3331
- );
3602
+ const normalizedLineColor = normalizeColor(lineColor || "#000");
3603
+ if (normalizedLineColor !== null) {
3604
+ this.createColorControl(
3605
+ container,
3606
+ layerId,
3607
+ "line-color",
3608
+ "Line Color",
3609
+ normalizedLineColor
3610
+ );
3611
+ }
3332
3612
  const lineWidth = this.map.getPaintProperty(layerId, "line-width");
3333
3613
  this.createSliderControl(
3334
3614
  container,
@@ -3373,7 +3653,7 @@ class LayerControl {
3373
3653
  addCircleControls(container, layerId) {
3374
3654
  var _a;
3375
3655
  const style = this.map.getStyle();
3376
- const layer = (_a = style.layers) == null ? void 0 : _a.find((l) => l.id === layerId);
3656
+ const layer = (_a = style.layers) == null ? void 0 : _a.find((l2) => l2.id === layerId);
3377
3657
  let circleColor = void 0;
3378
3658
  if (layer && "paint" in layer && layer.paint && "circle-color" in layer.paint) {
3379
3659
  circleColor = layer.paint["circle-color"];
@@ -3381,13 +3661,16 @@ class LayerControl {
3381
3661
  if (!circleColor) {
3382
3662
  circleColor = this.map.getPaintProperty(layerId, "circle-color");
3383
3663
  }
3384
- this.createColorControl(
3385
- container,
3386
- layerId,
3387
- "circle-color",
3388
- "Circle Color",
3389
- normalizeColor(circleColor || "#000")
3390
- );
3664
+ const normalizedCircleColor = normalizeColor(circleColor || "#000");
3665
+ if (normalizedCircleColor !== null) {
3666
+ this.createColorControl(
3667
+ container,
3668
+ layerId,
3669
+ "circle-color",
3670
+ "Circle Color",
3671
+ normalizedCircleColor
3672
+ );
3673
+ }
3391
3674
  const circleRadius = this.map.getPaintProperty(layerId, "circle-radius");
3392
3675
  this.createSliderControl(
3393
3676
  container,
@@ -3417,13 +3700,16 @@ class LayerControl {
3417
3700
  "circle-stroke-color"
3418
3701
  );
3419
3702
  if (strokeColor !== void 0) {
3420
- this.createColorControl(
3421
- container,
3422
- layerId,
3423
- "circle-stroke-color",
3424
- "Stroke Color",
3425
- normalizeColor(strokeColor)
3426
- );
3703
+ const normalizedStrokeColor = normalizeColor(strokeColor);
3704
+ if (normalizedStrokeColor !== null) {
3705
+ this.createColorControl(
3706
+ container,
3707
+ layerId,
3708
+ "circle-stroke-color",
3709
+ "Stroke Color",
3710
+ normalizedStrokeColor
3711
+ );
3712
+ }
3427
3713
  }
3428
3714
  const strokeWidth = this.map.getPaintProperty(
3429
3715
  layerId,
@@ -3525,13 +3811,16 @@ class LayerControl {
3525
3811
  addSymbolControls(container, layerId) {
3526
3812
  const textColor = this.map.getPaintProperty(layerId, "text-color");
3527
3813
  if (textColor !== void 0) {
3528
- this.createColorControl(
3529
- container,
3530
- layerId,
3531
- "text-color",
3532
- "Text Color",
3533
- normalizeColor(textColor)
3534
- );
3814
+ const normalizedTextColor = normalizeColor(textColor);
3815
+ if (normalizedTextColor !== null) {
3816
+ this.createColorControl(
3817
+ container,
3818
+ layerId,
3819
+ "text-color",
3820
+ "Text Color",
3821
+ normalizedTextColor
3822
+ );
3823
+ }
3535
3824
  }
3536
3825
  const textOpacity = this.map.getPaintProperty(layerId, "text-opacity");
3537
3826
  if (textOpacity !== void 0 && typeof textOpacity === "number") {
@@ -3632,6 +3921,7 @@ class LayerControl {
3632
3921
  const value = this.map.getPaintProperty(sourceId, property);
3633
3922
  if (value !== void 0) {
3634
3923
  const hexColor = normalizeColor(value);
3924
+ if (hexColor === null) return;
3635
3925
  picker.value = hexColor;
3636
3926
  const hexDisplay = (_a = picker.parentElement) == null ? void 0 : _a.querySelector(
3637
3927
  ".style-control-color-value"
@@ -3755,6 +4045,7 @@ class LayerControl {
3755
4045
  const value = this.map.getPaintProperty(layerId, property);
3756
4046
  if (value !== void 0) {
3757
4047
  const hexColor = normalizeColor(value);
4048
+ if (hexColor === null) return;
3758
4049
  picker.value = hexColor;
3759
4050
  const hexDisplay = (_a = picker.parentElement) == null ? void 0 : _a.querySelector(
3760
4051
  ".style-control-color-value"
@@ -4081,8 +4372,8 @@ class LayerControl {
4081
4372
  labelEl.textContent = label;
4082
4373
  item.appendChild(iconEl);
4083
4374
  item.appendChild(labelEl);
4084
- item.addEventListener("click", (e) => {
4085
- e.stopPropagation();
4375
+ item.addEventListener("click", (e2) => {
4376
+ e2.stopPropagation();
4086
4377
  onClick();
4087
4378
  });
4088
4379
  return item;
@@ -4090,17 +4381,17 @@ class LayerControl {
4090
4381
  /**
4091
4382
  * Show context menu at position
4092
4383
  */
4093
- showContextMenu(layerId, x, y) {
4384
+ showContextMenu(layerId, x2, y2) {
4094
4385
  if (!this.contextMenuEl) return;
4095
4386
  this.state.contextMenu = {
4096
4387
  visible: true,
4097
4388
  targetLayerId: layerId,
4098
- x,
4099
- y
4389
+ x: x2,
4390
+ y: y2
4100
4391
  };
4101
4392
  const mapRect = this.mapContainer.getBoundingClientRect();
4102
- let menuX = x - mapRect.left;
4103
- let menuY = y - mapRect.top;
4393
+ let menuX = x2 - mapRect.left;
4394
+ let menuY = y2 - mapRect.top;
4104
4395
  this.contextMenuEl.style.display = "block";
4105
4396
  const menuRect = this.contextMenuEl.getBoundingClientRect();
4106
4397
  if (menuX + menuRect.width > mapRect.width) {
@@ -4159,12 +4450,12 @@ class LayerControl {
4159
4450
  this.state.renamingLayerId = null;
4160
4451
  };
4161
4452
  input.addEventListener("blur", finishRename);
4162
- input.addEventListener("keydown", (e) => {
4163
- if (e.key === "Enter") {
4164
- e.preventDefault();
4453
+ input.addEventListener("keydown", (e2) => {
4454
+ if (e2.key === "Enter") {
4455
+ e2.preventDefault();
4165
4456
  finishRename();
4166
- } else if (e.key === "Escape") {
4167
- e.preventDefault();
4457
+ } else if (e2.key === "Escape") {
4458
+ e2.preventDefault();
4168
4459
  const newNameEl = document.createElement("span");
4169
4460
  newNameEl.className = "layer-control-name";
4170
4461
  newNameEl.textContent = currentName;
@@ -4249,7 +4540,7 @@ class LayerControl {
4249
4540
  var _a;
4250
4541
  const style = this.map.getStyle();
4251
4542
  if (!(style == null ? void 0 : style.layers)) return [];
4252
- const mapLayerIds = style.layers.map((l) => l.id);
4543
+ const mapLayerIds = style.layers.map((l2) => l2.id);
4253
4544
  const indexById = new Map(mapLayerIds.map((id, i) => [id, i]));
4254
4545
  const userLayerIds = Object.keys(this.state.layerStates).filter(
4255
4546
  (id) => id !== "Background"
@@ -4347,7 +4638,7 @@ class LayerControl {
4347
4638
  try {
4348
4639
  const targetBeforeId = index >= 2 ? this.findNextMapLibreLayer(layerIds, index - 2, -1) : void 0;
4349
4640
  this.map.moveLayer(layerId, targetBeforeId);
4350
- } catch (e) {
4641
+ } catch (e2) {
4351
4642
  }
4352
4643
  }
4353
4644
  const newLayerStates = {};
@@ -4384,7 +4675,7 @@ class LayerControl {
4384
4675
  if (!isCustom && this.isMapLibreLayer(layerId)) {
4385
4676
  try {
4386
4677
  this.map.moveLayer(layerId);
4387
- } catch (e) {
4678
+ } catch (e2) {
4388
4679
  }
4389
4680
  }
4390
4681
  const newLayerStates = {};
@@ -4421,7 +4712,7 @@ class LayerControl {
4421
4712
  if (belowLayerId) {
4422
4713
  try {
4423
4714
  this.map.moveLayer(layerId, belowLayerId);
4424
- } catch (e) {
4715
+ } catch (e2) {
4425
4716
  }
4426
4717
  }
4427
4718
  }
@@ -4466,7 +4757,7 @@ class LayerControl {
4466
4757
  if (bottomLayerId && bottomLayerId !== layerId) {
4467
4758
  try {
4468
4759
  this.map.moveLayer(layerId, bottomLayerId);
4469
- } catch (e) {
4760
+ } catch (e2) {
4470
4761
  }
4471
4762
  }
4472
4763
  }
@@ -4586,15 +4877,15 @@ class LayerControl {
4586
4877
  const cancelBtn = document.createElement("button");
4587
4878
  cancelBtn.className = "layer-control-remove-confirm-btn layer-control-remove-confirm-btn-cancel";
4588
4879
  cancelBtn.textContent = "Cancel";
4589
- cancelBtn.addEventListener("click", (e) => {
4590
- e.stopPropagation();
4880
+ cancelBtn.addEventListener("click", (e2) => {
4881
+ e2.stopPropagation();
4591
4882
  confirmEl.remove();
4592
4883
  });
4593
4884
  const confirmBtn = document.createElement("button");
4594
4885
  confirmBtn.className = "layer-control-remove-confirm-btn layer-control-remove-confirm-btn-confirm";
4595
4886
  confirmBtn.textContent = "Remove";
4596
- confirmBtn.addEventListener("click", (e) => {
4597
- e.stopPropagation();
4887
+ confirmBtn.addEventListener("click", (e2) => {
4888
+ e2.stopPropagation();
4598
4889
  confirmEl.remove();
4599
4890
  onConfirm();
4600
4891
  });
@@ -4627,12 +4918,12 @@ class LayerControl {
4627
4918
  if (sourceId) {
4628
4919
  const style = this.map.getStyle();
4629
4920
  const sourceStillUsed = (_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.some(
4630
- (l) => l.source === sourceId
4921
+ (l2) => l2.source === sourceId
4631
4922
  );
4632
4923
  if (!sourceStillUsed) {
4633
4924
  try {
4634
4925
  this.map.removeSource(sourceId);
4635
- } catch (e) {
4926
+ } catch (e2) {
4636
4927
  }
4637
4928
  }
4638
4929
  }
@@ -4668,10 +4959,10 @@ class LayerControl {
4668
4959
  <circle cx="11" cy="13" r="1.5"/>
4669
4960
  </svg>`;
4670
4961
  handle.title = "Drag to reorder";
4671
- handle.addEventListener("pointerdown", (e) => {
4672
- e.preventDefault();
4673
- e.stopPropagation();
4674
- this.startDrag(layerId, e);
4962
+ handle.addEventListener("pointerdown", (e2) => {
4963
+ e2.preventDefault();
4964
+ e2.stopPropagation();
4965
+ this.startDrag(layerId, e2);
4675
4966
  });
4676
4967
  return handle;
4677
4968
  }
@@ -4694,7 +4985,7 @@ class LayerControl {
4694
4985
  /**
4695
4986
  * Start dragging a layer
4696
4987
  */
4697
- startDrag(layerId, e) {
4988
+ startDrag(layerId, e2) {
4698
4989
  var _a;
4699
4990
  const itemEl = this.panel.querySelector(
4700
4991
  `[data-layer-id="${layerId}"]`
@@ -4704,8 +4995,8 @@ class LayerControl {
4704
4995
  this.state.drag = {
4705
4996
  active: true,
4706
4997
  layerId,
4707
- startY: e.clientY,
4708
- currentY: e.clientY,
4998
+ startY: e2.clientY,
4999
+ currentY: e2.clientY,
4709
5000
  placeholder: null,
4710
5001
  draggedElement: null
4711
5002
  };
@@ -4738,26 +5029,26 @@ class LayerControl {
4738
5029
  /**
4739
5030
  * Handle drag move
4740
5031
  */
4741
- onDragMove(e) {
5032
+ onDragMove(e2) {
4742
5033
  var _a, _b;
4743
5034
  if (!this.state.drag.active || !this.state.drag.draggedElement) return;
4744
5035
  const placeholder = this.state.drag.placeholder;
4745
5036
  if (!placeholder) return;
4746
- const deltaY = e.clientY - this.state.drag.startY;
5037
+ const deltaY = e2.clientY - this.state.drag.startY;
4747
5038
  const clone = this.state.drag.draggedElement;
4748
5039
  const currentTop = parseFloat(clone.style.top) || 0;
4749
5040
  clone.style.top = `${currentTop + deltaY}px`;
4750
- this.state.drag.startY = e.clientY;
4751
- this.state.drag.currentY = e.clientY;
5041
+ this.state.drag.startY = e2.clientY;
5042
+ this.state.drag.currentY = e2.clientY;
4752
5043
  const scope = placeholder.parentElement;
4753
5044
  const items = Array.from((scope == null ? void 0 : scope.children) ?? []).filter(
4754
5045
  (item) => (item.classList.contains("layer-control-item") || item.classList.contains("layer-control-group")) && !item.classList.contains("dragging") && item.dataset.layerId !== "Background"
4755
5046
  );
4756
5047
  for (const item of items) {
4757
5048
  const itemRect = item.getBoundingClientRect();
4758
- if (e.clientY >= itemRect.top && e.clientY <= itemRect.bottom) {
5049
+ if (e2.clientY >= itemRect.top && e2.clientY <= itemRect.bottom) {
4759
5050
  const itemMiddle = itemRect.top + itemRect.height / 2;
4760
- if (e.clientY < itemMiddle) {
5051
+ if (e2.clientY < itemMiddle) {
4761
5052
  if (placeholder.nextSibling !== item) {
4762
5053
  (_a = item.parentNode) == null ? void 0 : _a.insertBefore(placeholder, item);
4763
5054
  }
@@ -4835,22 +5126,22 @@ class LayerControl {
4835
5126
  var _a;
4836
5127
  this.state.isStyleOperationInProgress = true;
4837
5128
  const style = this.map.getStyle();
4838
- const mapLibreLayerIds = new Set(((_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.map((l) => l.id)) || []);
5129
+ const mapLibreLayerIds = new Set(((_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.map((l2) => l2.id)) || []);
4839
5130
  for (let i = 0; i < uiLayerIds.length; i++) {
4840
5131
  const layerId = uiLayerIds[i];
4841
5132
  if (!mapLibreLayerIds.has(layerId)) {
4842
5133
  continue;
4843
5134
  }
4844
5135
  let beforeId = void 0;
4845
- for (let j = i - 1; j >= 0; j--) {
4846
- if (mapLibreLayerIds.has(uiLayerIds[j])) {
4847
- beforeId = uiLayerIds[j];
5136
+ for (let j2 = i - 1; j2 >= 0; j2--) {
5137
+ if (mapLibreLayerIds.has(uiLayerIds[j2])) {
5138
+ beforeId = uiLayerIds[j2];
4848
5139
  break;
4849
5140
  }
4850
5141
  }
4851
5142
  try {
4852
5143
  this.map.moveLayer(layerId, beforeId);
4853
- } catch (e) {
5144
+ } catch (e2) {
4854
5145
  }
4855
5146
  }
4856
5147
  setTimeout(() => {
@@ -4868,6 +5159,8 @@ exports.formatNumericValue = formatNumericValue;
4868
5159
  exports.getLayerColor = getLayerColor;
4869
5160
  exports.getLayerColorFromSpec = getLayerColorFromSpec;
4870
5161
  exports.getLayerOpacity = getLayerOpacity;
5162
+ exports.getLayerSymbolStyle = getLayerSymbolStyle;
5163
+ exports.getLayerSymbolStyleFromSpec = getLayerSymbolStyleFromSpec;
4871
5164
  exports.getLayerType = getLayerType;
4872
5165
  exports.isStyleableLayerType = isStyleableLayerType;
4873
5166
  exports.normalizeColor = normalizeColor;