import { MAP_TYPE_TERRAIN as _, MAP_TYPE_FLEET_STYLE as v, MAP_TYPE_DEFAULT as M, MAP_TYPE_NIGHT as p, MAP_TYPE_SATELLITE as A, ENGINE_TYPE_HARP as d, ENGINE_TYPE_P2D as l, DEFAULT_RASTER_LAYER_FORMAT as L } from "../components/constants.js";
const h = () => window.devicePixelRatio >= 1.7 ? 200 : 100, u = (r, e) => r && e !== _ && e !== v, w = (r) => (
  // Initiate and authenticate your connection to the HERE platform:
  new H.service.Platform({
    apikey: r.apikey ?? "",
    useHTTPS: location.protocol === "https:"
  })
), P = (r, e, a, t) => {
  const n = new H.service.rasterTile.Provider(r, {
    engineType: e,
    tileSize: 512
  }), s = new H.map.layer.TileLayer(n);
  return s.setMin(a), s.setMax(t), s;
}, E = (r, e, a, t) => r?.getRasterTileService({
  format: L,
  queryParams: {
    // https://www.here.com/docs/bundle/raster-tile-api-migration-guide/page/README.html#5-language
    lang: t,
    ppi: h(),
    style: e,
    features: a
  }
}), S = (r, e) => {
  switch (r) {
    case v:
    case _:
      return l;
    default:
      return e ? d : l;
  }
}, b = async ({
  baseLayerName: r,
  defaultLayers: e,
  enableWebGL: a,
  platform: t,
  engineType: n,
  language: s,
  minZoom: i,
  maxZoom: c
}) => {
  const T = "pois:all,environmental_zones:all,congestion_zones:all,vehicle_restrictions:disabled";
  if (a && r === M)
    return e?.vector.normal.map.setMin(i), e?.vector.normal.map.setMax(c), {
      baseLayer: e?.vector.normal.map
    };
  switch (r) {
    case A: {
      if (a) {
        const y = {
          base: {
            style: "oslo",
            scheme: "hybrid.day"
          }
        };
        await t.createHybridLayers(
          y,
          // biome-ignore lint/suspicious/noExplicitAny: whatever layer type
          (o) => (o.raster.setMin(i), o.raster.setMax(c), o.vector.setMin(i), o.vector.setMax(c), {
            baseLayer: o.raster,
            overlayLayer: o.vector
          }),
          console.error
        );
      }
      return {
        baseLayer: P(
          E(t, "explore.satellite.day", T, s),
          n,
          i,
          c
        )
      };
    }
    case _:
      return {
        baseLayer: P(
          E(t, "topo.day", T, s),
          n,
          i,
          c
        )
      };
    case v:
      return {
        baseLayer: P(
          E(t, "logistics.day", T, s),
          l,
          i,
          c
        )
      };
    case p:
      return a ? (e?.vector.normal.mapnight.setMin(i), e?.vector.normal.mapnight.setMax(c), {
        // @ts-expect-error-next-line "vector.normal.mapnight" is newer than the types
        baseLayer: e.vector.normal.mapnight
      }) : {
        baseLayer: P(
          E(t, "explore.night", T, s),
          n,
          i,
          c
        )
      };
    default:
      return {
        baseLayer: P(
          E(t, "explore.day", T, s),
          n,
          i,
          c
        )
      };
  }
};
export {
  b as getBaseLayer,
  E as getBaseRasterTileService,
  P as getBaseTileLayer,
  S as getEngineType,
  h as getPPI,
  w as getPlatform,
  u as isVectorBased
};
//# sourceMappingURL=rendering.js.map
