var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellFloorMapLayout/utils/floorMapDropUtils.ts
var floorMapDropUtils_exports = {};
__export(floorMapDropUtils_exports, {
  FLOOR_MAP_PALETTE_DRAG_MIME: () => FLOOR_MAP_PALETTE_DRAG_MIME,
  isFloorMapPaletteDrag: () => isFloorMapPaletteDrag,
  parsePaletteDragPayload: () => parsePaletteDragPayload,
  sceneXYFromContentDropOffset: () => sceneXYFromContentDropOffset
});
module.exports = __toCommonJS(floorMapDropUtils_exports);
var FLOOR_MAP_PALETTE_DRAG_MIME = "application/x-pisell-floor-map-element";
function sceneXYFromContentDropOffset(offsetX, offsetY, contentOffset) {
  return {
    x: Math.round(offsetX - contentOffset.x),
    y: Math.round(offsetY - contentOffset.y)
  };
}
function isFloorMapPaletteDrag(dt) {
  if (!dt) return false;
  return Array.from(dt.types ?? []).includes(FLOOR_MAP_PALETTE_DRAG_MIME);
}
function parsePaletteDragPayload(dt) {
  try {
    const raw = dt.getData(FLOOR_MAP_PALETTE_DRAG_MIME);
    if (!raw) return null;
    const o = JSON.parse(raw);
    if (!o || typeof o !== "object") return null;
    const rec = o;
    const elementKind = rec.elementKind;
    if (typeof elementKind !== "string" || !elementKind) return null;
    const dataSourceKey = typeof rec.dataSourceKey === "string" ? rec.dataSourceKey : void 0;
    const recordId = typeof rec.recordId === "string" ? rec.recordId : void 0;
    let recordIds;
    const rawIds = rec.recordIds;
    if (Array.isArray(rawIds)) {
      recordIds = rawIds.filter((x) => typeof x === "string" && x);
      if (recordIds.length === 0) recordIds = void 0;
    }
    return { elementKind, dataSourceKey, recordId, recordIds };
  } catch {
    return null;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FLOOR_MAP_PALETTE_DRAG_MIME,
  isFloorMapPaletteDrag,
  parsePaletteDragPayload,
  sceneXYFromContentDropOffset
});
