"use strict";
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);
var blueprintCache_exports = {};
__export(blueprintCache_exports, {
  BlueprintCache: () => BlueprintCache,
  DEFAULT_BLUEPRINT_CACHE_SIZE: () => DEFAULT_BLUEPRINT_CACHE_SIZE,
  resolveBlueprintCacheSize: () => resolveBlueprintCacheSize
});
module.exports = __toCommonJS(blueprintCache_exports);
const DEFAULT_BLUEPRINT_CACHE_SIZE = 10;
function resolveBlueprintCacheSize() {
  const raw = process.env.SKYRAMP_BLUEPRINT_CACHE_SIZE;
  if (raw === void 0 || raw === "") return DEFAULT_BLUEPRINT_CACHE_SIZE;
  const parsed = Number.parseInt(raw, 10);
  if (!Number.isFinite(parsed) || parsed < 1) {
    console.warn(
      `SKYRAMP_BLUEPRINT_CACHE_SIZE=${raw} is invalid (expected positive integer); using default ${DEFAULT_BLUEPRINT_CACHE_SIZE}`
    );
    return DEFAULT_BLUEPRINT_CACHE_SIZE;
  }
  return parsed;
}
class BlueprintCache {
  constructor(max) {
    this.map = /* @__PURE__ */ new Map();
    if (max < 1)
      throw new Error("BlueprintCache: max must be >= 1");
    this.max = max;
  }
  get(url) {
    const found = this.map.get(url);
    if (!found)
      return void 0;
    this.map.delete(url);
    this.map.set(url, found);
    return found;
  }
  put(url, bp) {
    if (this.map.has(url))
      this.map.delete(url);
    this.map.set(url, bp);
    while (this.map.size > this.max) {
      const oldest = this.map.keys().next().value;
      if (oldest === void 0)
        break;
      this.map.delete(oldest);
    }
  }
  clear() {
    this.map.clear();
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  BlueprintCache,
  DEFAULT_BLUEPRINT_CACHE_SIZE,
  resolveBlueprintCacheSize
});
