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 ConnectionLayer_exports = {};
__export(ConnectionLayer_exports, {
  ConnectionLayer: () => ConnectionLayer
});
module.exports = __toCommonJS(ConnectionLayer_exports);
var import_react = __toESM(require("react"));
var import_maplibre = require("react-map-gl/maplibre");
var import_ConnectionLayerDirection = require("./ConnectionLayerDirection.js");
var import_ConnectionLayerTooltip = require("./ConnectionLayerTooltip.js");
var import_parse_connection_data_to_geo_json = require("./functions/parse-connection-data-to-geo-json.js");
var import_use_connection_layer_mouse_move = require("./hooks/use-connection-layer-mouse-move.js");
var import_constants = require("../../constants.js");
var import_tooltip_type_guards = require("../../functions/tooltip-type-guards.js");
var import_use_tooltip_template = require("../../hooks/use-tooltip-template.js");
var import_ConnectionLayerTooltip2 = require("../../slots/ConnectionLayerTooltip.js");
const ConnectionLayer = (props) => {
  const {
    data,
    layerId,
    children,
    color = import_constants.DEFAULT_LINE_COLOR,
    curve,
    directionIndicator,
    line,
    thickness = import_constants.DEFAULT_LINE_THICKNESS
  } = props;
  const sourceId = `source-${layerId}`;
  const geoJsonData = (0, import_parse_connection_data_to_geo_json.parseConnectionDataToGeoJSON)(
    data,
    thickness,
    color,
    curve
  );
  const tooltipTemplate = (0, import_use_tooltip_template.useTooltipTemplate)(
    children,
    import_ConnectionLayerTooltip2.ConnectionLayerTooltip
  );
  const { layerIds } = (0, import_use_connection_layer_mouse_move.useConnectionLayerMouseMove)(geoJsonData.length, layerId);
  return geoJsonData.map((featureCollection, index) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, { key: index }, /* @__PURE__ */ import_react.default.createElement(
    import_maplibre.Source,
    {
      id: `${sourceId}-${index}`,
      type: "geojson",
      data: featureCollection,
      promoteId: "id"
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_maplibre.Layer,
      {
        type: "line",
        id: layerIds[index],
        layout: {
          "line-cap": import_constants.DEFAULT_LINE_CAP,
          "line-join": import_constants.DEFAULT_LINE_JOIN
        },
        paint: {
          "line-color": [
            "case",
            ["boolean", ["feature-state", "hover"], false],
            ["get", "__lineHoveredColor"],
            ["get", "__lineColor"]
          ],
          "line-width": ["get", "__lineWidth"],
          ...line && line === "dashed" ? { "line-dasharray": import_constants.DEFAULT_LINE_DASH_ARRAY } : null
        }
      }
    )
  ), /* @__PURE__ */ import_react.default.createElement(
    import_ConnectionLayerTooltip.ConnectionLayerTooltip,
    {
      layerId: layerIds[index],
      tooltipTemplate: (0, import_tooltip_type_guards.isConnectionTooltipTemplate)(tooltipTemplate) ? tooltipTemplate : void 0
    }
  ), directionIndicator && /* @__PURE__ */ import_react.default.createElement(
    import_ConnectionLayerDirection.ConnectionLayerDirection,
    {
      geoJsonData: featureCollection,
      layerId: layerIds[index],
      directionIndicator
    }
  )));
};
ConnectionLayer["displayName"] = "ConnectionLayer";
