function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { Style } from "ol/style";
import TrafimageMapboxLayer from "../../layers/TrafimageMapboxLayer";
import { createPointStyleRenderer } from "../../utils/highlightPointStyle";
import { getNetzkarteLayers } from "../ch.sbb.netzkarte";
import { BAHNHOFPLAENE_LAYER_NAME, MapsHandicapFilter, NETZKARTE_DARK_LAYER_NAME, NETZKARTE_LAYER_NAME, STATIONS_LAYER_NAME } from "../../utils/constants";
import HandicapLayer from "../../layers/HandicapLayer";

// eslint-disable-next-line import/prefer-default-export
export const getHandicapLayers = () => {
  const layers = getNetzkarteLayers();
  const netzkarteLayer = layers.find(l => l.name === NETZKARTE_LAYER_NAME);
  const netzkarteNight = layers.find(l => l.name === NETZKARTE_DARK_LAYER_NAME);
  const stationsLayer = layers.find(l => l.name === STATIONS_LAYER_NAME);
  const bahnhofplaene = layers.find(l => l.name === BAHNHOFPLAENE_LAYER_NAME);
  const handicapDataLayer = new TrafimageMapboxLayer({
    name: "ch.sbb.handicap.data",
    visible: true,
    zIndex: -1,
    // Add zIndex as the MapboxLayer would block tiled layers (buslines)
    style: "basemap_bright_ch.sbb.handicap_v2",
    properties: {
      hideInLegend: true
    },
    mapOptions: {
      preserveDrawingBuffer: true
    },
    group: "data"
  });
  const handicapLight = netzkarteLayer.clone({
    mapboxLayer: handicapDataLayer,
    style: "basemap_bright_ch.sbb.handicap_v2"
  });
  const handicapDark = netzkarteNight.clone({
    mapboxLayer: handicapDataLayer,
    style: "basemap_dark_ch.sbb.handicap_v2"
  });
  const handicapHighlightStyleMain = new Style({
    renderer: createPointStyleRenderer([{
      offsetX: 0,
      offsetY: -25,
      radius: 25,
      resolution: 19.5
    }, {
      offsetX: 0,
      offsetY: -28,
      radius: 25,
      resolution: 9
    }, {
      offsetX: 0,
      offsetY: -32,
      radius: 25,
      resolution: 4.8
    }, {
      offsetX: 0,
      offsetY: -35,
      radius: 25,
      resolution: 2.5
    }, {
      offsetX: -1,
      offsetY: -32,
      radius: 25,
      resolution: 0.8
    }])
  });
  const handicapHighlightStyleSecondary = new Style({
    renderer: createPointStyleRenderer([{
      offsetX: 0,
      offsetY: -15,
      radius: 15,
      resolution: 5
    }, {
      offsetX: 0,
      offsetY: -18,
      radius: 18,
      resolution: 2.4
    }, {
      offsetX: 0,
      offsetY: -20,
      radius: 20,
      resolution: 2
    }, {
      offsetX: 0,
      offsetY: -22,
      radius: 20,
      resolution: 1.7
    }, {
      offsetX: 0,
      offsetY: -25,
      radius: 22,
      resolution: 1.5
    }, {
      offsetX: -1,
      offsetY: -25,
      radius: 22,
      resolution: 0.4
    }])
  });
  const barrierefrei = new HandicapLayer({
    name: "ch.sbb.barrierfreierbahnhoefe",
    mapboxLayer: handicapDataLayer,
    styleLayersFilter: _ref => {
      let {
        metadata
      } = _ref;
      return /^symbol.barrierefrei/.test(metadata === null || metadata === void 0 ? void 0 : metadata[MapsHandicapFilter]);
    },
    properties: {
      isQueryable: true,
      useOverlay: true,
      popupComponent: "StopPlacePopup",
      highlightPointStyle: handicapHighlightStyleMain,
      hasInfos: true,
      layerInfoComponent: "HandicapLayerInfo",
      color: "#01973D"
    }
  });
  const nichtBarrierefrei = new HandicapLayer({
    name: "ch.sbb.nichtbarrierfreierbahnhoefe",
    mapboxLayer: handicapDataLayer,
    styleLayersFilter: _ref2 => {
      let {
        metadata
      } = _ref2;
      return /^symbol.nichtbarrierefrei/.test(metadata === null || metadata === void 0 ? void 0 : metadata[MapsHandicapFilter]);
    },
    properties: {
      isQueryable: true,
      useOverlay: true,
      popupComponent: "StopPlacePopup",
      highlightPointStyle: handicapHighlightStyleSecondary,
      hasInfos: true,
      layerInfoComponent: "HandicapLayerInfo",
      color: "#C60019"
    }
  });
  const teilBarrierefrei = new HandicapLayer({
    name: "ch.sbb.teilbarrierefreiebahnhoefe",
    mapboxLayer: handicapDataLayer,
    styleLayersFilter: _ref3 => {
      let {
        metadata
      } = _ref3;
      return /^symbol.teilbarrierefrei/.test(metadata === null || metadata === void 0 ? void 0 : metadata[MapsHandicapFilter]);
    },
    properties: {
      isQueryable: true,
      useOverlay: true,
      popupComponent: "StopPlacePopup",
      highlightPointStyle: handicapHighlightStyleMain,
      hasInfos: true,
      layerInfoComponent: "HandicapLayerInfo",
      color: "#F17E00"
    }
  });

  // TODO: We need to wait for ROKAS to add data for this layer.
  // const shuttle = new MapboxStyleLayer({
  //   name: "ch.sbb.shuttle",
  //   mapboxLayer: handicapDataLayer,
  //   styleLayersFilter: ({ metadata }) => {
  //     return /^symbol.shuttle/.test(metadata?.[MapsHandicapFilter]);
  //   },
  //   properties: {
  //     isQueryable: true,
  //     useOverlay: true,
  //     popupComponent: "StopPlacePopup",
  //     highlightPointStyle: handicapHighlightStyleSecondary,
  //   },
  // });

  const statusUnbekannt = new HandicapLayer({
    name: "ch.sbb.status_unbekannt",
    mapboxLayer: handicapDataLayer,
    styleLayersFilter: _ref4 => {
      let {
        metadata
      } = _ref4;
      return /^symbol.statusunbekannt/.test(metadata === null || metadata === void 0 ? void 0 : metadata[MapsHandicapFilter]);
    },
    properties: {
      isQueryable: true,
      useOverlay: true,
      popupComponent: "StopPlacePopup",
      highlightPointStyle: handicapHighlightStyleSecondary,
      hasInfos: true,
      layerInfoComponent: "HandicapLayerInfo",
      color: "#686868"
    }
  });
  return [handicapDataLayer, handicapLight, handicapDark, stationsLayer.clone({
    mapboxLayer: handicapDataLayer
  }), bahnhofplaene.clone({
    children: bahnhofplaene.children.map(layer => layer.clone({
      mapboxLayer: handicapDataLayer
    })),
    properties: _objectSpread(_objectSpread({}, bahnhofplaene.getProperties()), {}, {
      dataLink: null,
      dataService: false
    })
  }), statusUnbekannt, nichtBarrierefrei, teilBarrierefrei, barrierefrei];
};
//# sourceMappingURL=index.js.map