globalThis.process ??= {}; globalThis.process.env ??= {};
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
export { r as renderers } from '../chunks/_@astro-renderers_B-gIj2th.mjs';

async function getConfig(fileLocation) {
  try {
    const { config } = await import(fileLocation);
    return config;
  } catch (e) {
    if (["ERR_MODULE_NOT_FOUND", "MODULE_NOT_FOUND"].includes(e.code)) {
      console.error(
        "pf-docs.config.mjs not found, have you created it at the root of your package?"
      );
      return;
    }
    console.error(e);
    return;
  }
}

const prerender = false;
async function GET({ request }) {
  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 queryParams = new URL(request.url).searchParams;
  const components = queryParams.get("components");
  const componentsArray = components?.split(",");
  const propsData = componentsArray?.map((component) => props[component]);
  return new Response(JSON.stringify(propsData));
}

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

const page = () => _page;

export { page };
