/**
 * @license
 * Copyright 2025-2026 Open Home Foundation
 * SPDX-License-Identifier: Apache-2.0
 */
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
function getMatterVersion() {
  const matterMainUrl = import.meta.resolve("@matter/main");
  const matterMainPath = fileURLToPath(matterMainUrl);
  let dir = dirname(matterMainPath);
  while (dir !== "/") {
    try {
      const packageJsonPath = join(dir, "package.json");
      const content = readFileSync(packageJsonPath, "utf-8");
      const pkg = JSON.parse(content);
      if (pkg.name === "@matter/main") {
        return pkg.version;
      }
    } catch {
    }
    dir = dirname(dir);
  }
  throw new Error("Could not find @matter/main package.json");
}
const MATTER_VERSION = getMatterVersion();
export {
  MATTER_VERSION,
  getMatterVersion
};
//# sourceMappingURL=matterVersion.js.map
