import { useDzkhFilters } from "../../stores/useDzkhFilters.js";
import { useWeatherFilter } from "../WeatherSlider/useWeatherFilter.js";
import { tempMapper } from "../../config.js";

export const useSourceLayerFilterExpression = () => {
  const {source_filter} = useDzkhFilters();
  const {value: temperature} = useWeatherFilter();
  const t = tempMapper[temperature]
  const consumerFilterExpression = () => {
    if (source_filter) {
      const key = `${source_filter.key}_${t}`;

      return [
        [">=", ["get", key], source_filter.gt],
        ["<=", ["get", key], source_filter.lt],
      ]
    }
    return [];
  }

  return [
    ...consumerFilterExpression()
  ]
}
