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/hooks/floorMapViewportPersistence.ts
var floorMapViewportPersistence_exports = {};
__export(floorMapViewportPersistence_exports, {
  DEFAULT_BOUNDING_PADDING: () => DEFAULT_BOUNDING_PADDING,
  FIT_BOUNDS_MATCH_POS_EPSILON: () => FIT_BOUNDS_MATCH_POS_EPSILON,
  FIT_BOUNDS_MATCH_SCALE_EPSILON: () => FIT_BOUNDS_MATCH_SCALE_EPSILON,
  VIEWPORT_LOCK_STORAGE_PREFIX: () => VIEWPORT_LOCK_STORAGE_PREFIX,
  VIEWPORT_PERSIST_DEBOUNCE_MS: () => VIEWPORT_PERSIST_DEBOUNCE_MS,
  VIEWPORT_STORAGE_PREFIX: () => VIEWPORT_STORAGE_PREFIX,
  VIEWPORT_TOP_LEFT_MARGIN: () => VIEWPORT_TOP_LEFT_MARGIN,
  readPersistedViewport: () => readPersistedViewport,
  readPersistedViewportLock: () => readPersistedViewportLock,
  writePersistedViewport: () => writePersistedViewport,
  writePersistedViewportLock: () => writePersistedViewportLock
});
module.exports = __toCommonJS(floorMapViewportPersistence_exports);
var DEFAULT_BOUNDING_PADDING = 56;
var VIEWPORT_TOP_LEFT_MARGIN = 16;
var VIEWPORT_STORAGE_PREFIX = "pisell-floor-map-layout.viewport:";
var VIEWPORT_LOCK_STORAGE_PREFIX = "pisell-floor-map-layout.viewport-lock:";
var VIEWPORT_PERSIST_DEBOUNCE_MS = 300;
var FIT_BOUNDS_MATCH_POS_EPSILON = 0.5;
var FIT_BOUNDS_MATCH_SCALE_EPSILON = 5e-3;
function readPersistedViewport(key) {
  if (typeof window === "undefined") return null;
  try {
    const raw = window.localStorage.getItem(VIEWPORT_STORAGE_PREFIX + key);
    if (!raw) return null;
    const parsed = JSON.parse(raw);
    if (!parsed || typeof parsed.x !== "number" || typeof parsed.y !== "number" || typeof parsed.scale !== "number" || !Number.isFinite(parsed.x) || !Number.isFinite(parsed.y) || !Number.isFinite(parsed.scale) || parsed.scale <= 0) {
      return null;
    }
    return { x: parsed.x, y: parsed.y, scale: parsed.scale };
  } catch {
    return null;
  }
}
function writePersistedViewport(key, snapshot) {
  if (typeof window === "undefined") return;
  try {
    window.localStorage.setItem(
      VIEWPORT_STORAGE_PREFIX + key,
      JSON.stringify(snapshot)
    );
  } catch {
  }
}
function readPersistedViewportLock(key) {
  if (typeof window === "undefined") return false;
  try {
    return window.localStorage.getItem(VIEWPORT_LOCK_STORAGE_PREFIX + key) === "1";
  } catch {
    return false;
  }
}
function writePersistedViewportLock(key, locked) {
  if (typeof window === "undefined") return;
  try {
    if (locked) {
      window.localStorage.setItem(VIEWPORT_LOCK_STORAGE_PREFIX + key, "1");
    } else {
      window.localStorage.removeItem(VIEWPORT_LOCK_STORAGE_PREFIX + key);
    }
  } catch {
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  DEFAULT_BOUNDING_PADDING,
  FIT_BOUNDS_MATCH_POS_EPSILON,
  FIT_BOUNDS_MATCH_SCALE_EPSILON,
  VIEWPORT_LOCK_STORAGE_PREFIX,
  VIEWPORT_PERSIST_DEBOUNCE_MS,
  VIEWPORT_STORAGE_PREFIX,
  VIEWPORT_TOP_LEFT_MARGIN,
  readPersistedViewport,
  readPersistedViewportLock,
  writePersistedViewport,
  writePersistedViewportLock
});
