globalThis.process ??= {}; globalThis.process.env ??= {};
import { c as createJsonResponse } from '../../../../chunks/apiHelpers_DEg9ljrb.mjs';
import { f as fetchApiIndex } from '../../../../chunks/fetch_CoXtH9RF.mjs';
import { a as getTokensForCategory, b as getTokenCategories, c as filterTokens } from '../../../../chunks/tokens_CcR1QBlJ.mjs';
export { r as renderers } from '../../../../chunks/_@astro-renderers_OzpRq-hZ.mjs';

const prerender = false;
const GET = async ({ params, url }) => {
  const { version, category } = params;
  if (!version || !category) {
    return createJsonResponse(
      { error: "Version and category parameters are required" },
      400
    );
  }
  try {
    const index = await fetchApiIndex(url);
    if (!index.versions.includes(version)) {
      return createJsonResponse(
        { error: `Version '${version}' not found` },
        404
      );
    }
    const tokens = getTokensForCategory(category);
    if (!tokens) {
      const validCategories = getTokenCategories();
      return createJsonResponse(
        {
          error: `Category '${category}' not found`,
          validCategories
        },
        404
      );
    }
    const filterParam = url.searchParams.get("filter");
    const filteredTokens = filterParam ? filterTokens(tokens, filterParam) : tokens;
    return createJsonResponse(filteredTokens);
  } catch (error) {
    return createJsonResponse(
      { error: "Failed to load tokens", details: error },
      500
    );
  }
};

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

const page = () => _page;

export { page };
