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/ticketBooking/utils/productCache.ts
var productCache_exports = {};
__export(productCache_exports, {
  clearAllCache: () => clearAllCache,
  clearAllCacheByOsKey: () => clearAllCacheByOsKey,
  clearAllProductCache: () => clearAllProductCache,
  clearBoardConfigCache: () => clearBoardConfigCache,
  clearCache: () => clearCache,
  clearProductCache: () => clearProductCache,
  getBoardConfigCache: () => getBoardConfigCache,
  getCache: () => getCache,
  getProductCache: () => getProductCache,
  setBoardConfigCache: () => setBoardConfigCache,
  setCache: () => setCache,
  setProductCache: () => setProductCache
});
module.exports = __toCommonJS(productCache_exports);
var generateCacheKey = (osKey, cacheType = "product") => {
  return `${cacheType}_cache_${osKey}`;
};
var getCache = (osKey, cacheType = "product", maxAge) => {
  try {
    const cacheKey = generateCacheKey(osKey, cacheType);
    const cacheStr = localStorage.getItem(cacheKey);
    if (!cacheStr) {
      return null;
    }
    const cache = JSON.parse(cacheStr);
    if (maxAge && Date.now() - cache.timestamp > maxAge) {
      localStorage.removeItem(cacheKey);
      return null;
    }
    return cache.data;
  } catch (error) {
    console.error(`Failed to get ${cacheType} cache:`, error);
    return null;
  }
};
var getProductCache = (osKey, maxAge) => {
  return getCache(osKey, "product", maxAge);
};
var setCache = (osKey, data, cacheType = "product") => {
  try {
    const cacheKey = generateCacheKey(osKey, cacheType);
    const cache = {
      data,
      timestamp: Date.now()
    };
    localStorage.setItem(cacheKey, JSON.stringify(cache));
  } catch (error) {
    console.error(`Failed to set ${cacheType} cache:`, error);
  }
};
var setProductCache = (osKey, data) => {
  setCache(osKey, data, "product");
};
var clearCache = (osKey, cacheType = "product") => {
  try {
    const keys = Object.keys(localStorage);
    const prefix = `${cacheType}_cache_${osKey}`;
    keys.forEach((key) => {
      if (key.startsWith(prefix)) {
        localStorage.removeItem(key);
      }
    });
  } catch (error) {
    console.error(`Failed to clear ${cacheType} cache:`, error);
  }
};
var clearProductCache = (osKey) => {
  clearCache(osKey, "product");
};
var clearBoardConfigCache = (osKey) => {
  clearCache(osKey, "boardConfig");
};
var clearAllCacheByOsKey = (osKey) => {
  clearCache(osKey, "product");
  clearCache(osKey, "boardConfig");
};
var clearAllProductCache = () => {
  try {
    const keys = Object.keys(localStorage);
    const prefix = "product_cache_";
    keys.forEach((key) => {
      if (key.startsWith(prefix)) {
        localStorage.removeItem(key);
      }
    });
  } catch (error) {
    console.error("Failed to clear all product cache:", error);
  }
};
var clearAllCache = () => {
  try {
    const keys = Object.keys(localStorage);
    const prefixes = ["product_cache_", "boardConfig_cache_"];
    keys.forEach((key) => {
      if (prefixes.some((prefix) => key.startsWith(prefix))) {
        localStorage.removeItem(key);
      }
    });
  } catch (error) {
    console.error("Failed to clear all cache:", error);
  }
};
var getBoardConfigCache = (osKey, maxAge) => {
  return getCache(osKey, "boardConfig", maxAge);
};
var setBoardConfigCache = (osKey, data) => {
  setCache(osKey, data, "boardConfig");
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  clearAllCache,
  clearAllCacheByOsKey,
  clearAllProductCache,
  clearBoardConfigCache,
  clearCache,
  clearProductCache,
  getBoardConfigCache,
  getCache,
  getProductCache,
  setBoardConfigCache,
  setCache,
  setProductCache
});
