globalThis.process ??= {}; globalThis.process.env ??= {};
import { c as createJsonResponse } from '../../../../../chunks/apiHelpers_DEg9ljrb.mjs';
import { g as getConfig } from '../../../../../chunks/getConfig_DO3RhTb7.mjs';
import { join } from 'node:path';
import { readFileSync } from 'node:fs';
import { s as sentenceCase, r as removeSubsection } from '../../../../../chunks/case_Kni3bUiU.mjs';
export { r as renderers } from '../../../../../chunks/_@astro-renderers_OzpRq-hZ.mjs';

const prerender = false;
const GET = async ({ params }) => {
  const { page } = params;
  if (!page) {
    return createJsonResponse(
      { error: "Page parameter is required" },
      400
    );
  }
  try {
    const config = await getConfig(`${process.cwd()}/pf-docs.config.mjs`);
    const outputDir = config?.outputDir || join(process.cwd(), "dist");
    const propsFilePath = join(outputDir, "props.json");
    const propsDataFile = readFileSync(propsFilePath);
    const props = JSON.parse(propsDataFile.toString());
    const propsData = props[sentenceCase(removeSubsection(page))];
    if (propsData === void 0) {
      return createJsonResponse(
        { error: `Props data for ${page} not found` },
        404
      );
    }
    return createJsonResponse(propsData);
  } catch (error) {
    const details = error instanceof Error ? error.message : String(error);
    return createJsonResponse(
      { error: "Props data not found", details },
      500
    );
  }
};

const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  __proto__: null,
  GET,
  prerender
}, Symbol.toStringTag, { value: 'Module' }));

const page = () => _page;

export { page };
