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