import { jsx as e, jsxs as U } from "react/jsx-runtime";
import { useMemo as N, useEffect as K } from "react";
import { noop as O } from "es-toolkit/function";
import { compact as b } from "es-toolkit/compat";
import { MAP_TYPE_DEFAULT as t, MAP_TYPE_FLEET_STYLE as n, MAP_TYPE_TERRAIN as s, MAP_TYPE_SATELLITE as p, MAP_TYPE_NIGHT as _ } from "../../../constants.js";
import W from "../MapSettingsPanel.js";
import M from "../MapSettingsItem.js";
import $ from "../MapSettingsTile.js";
import { MapIcon as a, MAP_TYPE_NIGHT_INACTIVE as Y, MAP_TYPE_NIGHT_ACTIVE as q, MAP_TYPE_SATELLITE_INACTIVE as V, MAP_TYPE_SATELLITE_ACTIVE as z, MAP_TYPE_TERRAIN_INACTIVE as F, MAP_TYPE_TERRAIN_ACTIVE as B, MAP_TYPE_FLAT_TRUCK_INACTIVE as k, MAP_TYPE_FLAT_TRUCK_ACTIVE as J, MAP_TYPE_FLAT_INACTIVE as D, MAP_TYPE_FLAT_ACTIVE as Q } from "../../../../icons/MapIcon.js";
import X from "../items/MapSettingsDropdownHeader.js";
const le = (R) => {
  const {
    mapType: T,
    onMapTypeChange: c = O,
    enableNightMap: H = !0,
    visibleMapTypes: g = [
      t,
      n,
      s,
      p,
      _
    ],
    defaultTypeLabel: A,
    truckTypeLabel: E,
    terrainTypeLabel: I,
    satelliteTypeLabel: y,
    nightTypeLabel: P,
    dropdownHeaderText: v,
    ...w
  } = R, l = N(() => new Set(g), [g]), i = (o) => l.has(o), m = i(_) && H, f = N(
    () => b([
      l.has(t) && !A && t,
      l.has(n) && !E && n,
      l.has(s) && !I && s,
      l.has(p) && !y && p,
      m && !P && _
    ]),
    [
      A,
      m,
      P,
      y,
      I,
      E,
      l
    ]
  );
  K(() => {
    typeof process < "u" && process.env.NODE_ENV === "production" || f.length !== 0 && console.warn(
      `[MapTypeSettings] Missing labels for visible map types: ${f.join(", ")}. Pass the corresponding \`...TypeLabel\` props to improve clarity.`
    );
  }, [f]);
  const r = N(
    () => ({
      isDefault: T === t,
      isFleetStyle: T === n,
      isTerrain: T === s,
      isSatellite: T === p,
      isNight: T === _
    }),
    [T]
  ), x = (o) => {
    if (o.isDefault)
      return /* @__PURE__ */ e(a, { name: D });
    if (o.isFleetStyle)
      return /* @__PURE__ */ e(a, { name: k });
    if (o.isTerrain)
      return /* @__PURE__ */ e(a, { name: F });
    if (o.isSatellite)
      return /* @__PURE__ */ e(a, { name: V });
    if (o.isNight)
      return /* @__PURE__ */ e(a, { name: Y });
  }, j = v && /* @__PURE__ */ e(X, { label: v }, "mapTypeDropdownHeader"), S = /* @__PURE__ */ e(
    M,
    {
      className: "MapTypeNight",
      onClick: () => c(_),
      isActive: r.isNight,
      activeIcon: /* @__PURE__ */ e(a, { name: q }),
      inactiveIcon: /* @__PURE__ */ e(a, { name: Y }),
      label: P
    },
    "MapTypeNight"
  ), h = /* @__PURE__ */ e(
    M,
    {
      className: "MapTypeSatellite",
      onClick: () => c(p),
      isActive: r.isSatellite,
      activeIcon: /* @__PURE__ */ e(a, { name: z }),
      inactiveIcon: /* @__PURE__ */ e(a, { name: V }),
      label: y
    },
    "MapTypeSatellite"
  ), L = /* @__PURE__ */ e(
    M,
    {
      className: "MapTypeTerrain",
      onClick: () => c(s),
      isActive: r.isTerrain,
      activeIcon: /* @__PURE__ */ e(a, { name: B }),
      inactiveIcon: /* @__PURE__ */ e(a, { name: F }),
      label: I
    },
    "MapTypeTerrain"
  ), u = /* @__PURE__ */ e(
    M,
    {
      className: "MapTypeFlatTruck",
      onClick: () => c(n),
      isActive: r.isFleetStyle,
      activeIcon: /* @__PURE__ */ e(a, { name: J }),
      inactiveIcon: /* @__PURE__ */ e(a, { name: k }),
      label: E
    },
    "MapTypeFlatTruck"
  ), d = /* @__PURE__ */ e(
    M,
    {
      className: "MapTypeFlat",
      onClick: () => c(t),
      isActive: r.isDefault,
      activeIcon: /* @__PURE__ */ e(a, { name: Q }),
      inactiveIcon: /* @__PURE__ */ e(a, { name: D }),
      label: A
    },
    "MapTypeFlat"
  ), G = b([
    j,
    m && S,
    i(p) && h,
    i(s) && L,
    i(n) && u,
    i(t) && d
  ]), C = b([
    i(t) && A,
    i(n) && E,
    i(s) && I,
    i(p) && y,
    m && P
  ]).length > 0;
  return /* @__PURE__ */ e(
    $,
    {
      className: "MapTypeSettings",
      inactiveIcon: x(r),
      items: C ? G : void 0,
      panel: !C && /* @__PURE__ */ U(W, { children: [
        m && S,
        i(p) && h,
        i(s) && L,
        i(n) && u,
        i(t) && d
      ] }),
      ...w
    }
  );
};
export {
  le as default
};
//# sourceMappingURL=MapTypeSettings.js.map
