var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var DotLayer_exports = {};
__export(DotLayer_exports, {
  DotLayer: () => DotLayer
});
module.exports = __toCommonJS(DotLayer_exports);
var import_react = __toESM(require("react"));
var import_maplibre = require("react-map-gl/maplibre");
var import_BackgroundLayer = require("./BackgroundLayer.js");
var import_DotLayerTooltip = require("./DotLayerTooltip.js");
var import_parse_dot_data_to_geo_json = require("./functions/parse-dot-data-to-geo-json.js");
var import_constants = require("../../constants.js");
var import_tooltip_type_guards = require("../../functions/tooltip-type-guards.js");
var import_use_layer_coloring_strategy = require("../../hooks/use-layer-coloring-strategy.js");
var import_use_legend_interaction_highlighting = require("../../hooks/use-legend-interaction-highlighting.js");
var import_use_legend_interaction_visibility = require("../../hooks/use-legend-interaction-visibility.js");
var import_use_load_symbol_into_map = require("../../hooks/use-load-symbol-into-map.js");
var import_use_resolve_color = require("../../hooks/use-resolve-color.js");
var import_use_tooltip_template = require("../../hooks/use-tooltip-template.js");
var import_DotLayerTooltip2 = require("../../slots/DotLayerTooltip.js");
const DotLayer = (props) => {
  const {
    data,
    layerId,
    bearing = 0,
    children,
    shape = "pin",
    background = false,
    shapeSize = import_constants.DEFAULT_SYMBOL_SIZE
  } = props;
  const { symbolName, symbolType } = (0, import_use_load_symbol_into_map.useLoadSymbolIntoMap)(
    shape,
    layerId,
    shapeSize
  );
  const defaultSymbolColor = symbolType === "shape" ? import_constants.DEFAULT_SHAPE_COLOR : import_constants.DEFAULT_ICON_COLOR;
  const colorParser = (0, import_use_layer_coloring_strategy.useLayerColoringStrategy)();
  const shapeColor = (0, import_use_resolve_color.useResolveColor)(defaultSymbolColor, props, colorParser);
  const tooltipTemplate = (0, import_use_tooltip_template.useTooltipTemplate)(children, import_DotLayerTooltip2.DotLayerTooltip);
  const sourceId = `source-${layerId}`;
  (0, import_use_legend_interaction_highlighting.useLegendInteractionHighlighting)(props, sourceId);
  (0, import_use_legend_interaction_visibility.useLegendInteractionVisibility)(props, layerId);
  const dataGeoJson = (0, import_parse_dot_data_to_geo_json.parseDotDataToGeoJSON)(data, shapeColor, bearing);
  const iconAnchor = shape === "pin" ? "bottom" : "center";
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_maplibre.Source, { id: sourceId, type: "geojson", data: dataGeoJson, generateId: true }, /* @__PURE__ */ import_react.default.createElement(
    import_maplibre.Layer,
    {
      type: "symbol",
      id: layerId,
      layout: {
        "icon-image": symbolName,
        "icon-size": import_constants.DEFAULT_ICON_SIZE_RATIO,
        "icon-rotate": ["get", "__bearing"],
        // https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-ignore-placement
        "icon-ignore-placement": true,
        "icon-anchor": iconAnchor
      },
      paint: {
        "icon-color": ["get", "__color"],
        "icon-opacity": [
          "case",
          ["boolean", ["feature-state", "legendHover"], true],
          import_constants.SHAPE_OPACITY,
          import_constants.LEGEND_DIM_OPACITY
        ]
      }
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    import_BackgroundLayer.BackgroundLayer,
    {
      background,
      beforeId: layerId,
      source: sourceId,
      radius: shapeSize / 2,
      iconAnchor
    }
  )), /* @__PURE__ */ import_react.default.createElement(
    import_DotLayerTooltip.DotLayerTooltip,
    {
      layerId,
      tooltipTemplate: (0, import_tooltip_type_guards.isDotTooltipTemplate)(tooltipTemplate) ? tooltipTemplate : void 0
    }
  ));
};
DotLayer["displayName"] = "DotLayer";
