function generateRuntimePackageJson(context) {
  const { spec } = context;
  const scanTimeline = (views) => views && typeof views === "object" && Object.values(views).some((v) => String(v?.type).toLowerCase() === "timeline");
  const hasTimeline = scanTimeline(spec?.views) || Object.values(spec?.components ?? {}).some((c) => scanTimeline(c?.views));
  const manifest = context.manifest;
  const inner = manifest?.manifests ? Object.values(manifest.manifests)[0] : manifest;
  const tlMap = Array.isArray(inner?.capabilityMappings) ? inner.capabilityMappings.find((m) => m?.capability === "view.timeline") : null;
  const timelineRenderer = tlMap?.implementation ?? tlMap?.instanceFactory ?? inner?.["view.timeline"] ?? (hasTimeline ? "VisTimeline" : void 0);
  const useVisTimeline = timelineRenderer === "VisTimeline";
  const appName = spec.metadata?.component?.toLowerCase() || "frontend";
  const version = spec.metadata?.version || "1.0.0";
  const description = spec.metadata?.description || "Frontend application";
  const pkg = {
    name: `${appName}-frontend`,
    version,
    description,
    private: true,
    type: "module",
    scripts: {
      dev: "vite",
      build: "tsc && vite build",
      preview: "vite preview",
      test: "echo 'No tests configured for frontend'",
      lint: "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
    },
    dependencies: {
      "react": "^18.2.0",
      "react-dom": "^18.2.0",
      "react-router-dom": "^6.18.0",
      "@tanstack/react-query": "^5.0.0",
      "@specverse/runtime": "^5.0.0",
      "js-yaml": "^4.1.0",
      "react-hook-form": "^7.48.0",
      "zod": "^3.22.0",
      "@hookform/resolvers": "^3.3.0",
      ...useVisTimeline ? { "vis-timeline": "^7.7.3", "vis-data": "^7.1.9" } : {}
    },
    devDependencies: {
      "@types/react": "^18.2.0",
      "@types/react-dom": "^18.2.0",
      "@types/js-yaml": "^4.0.9",
      "@vitejs/plugin-react": "^4.2.0",
      "autoprefixer": "^10.4.20",
      "postcss": "^8.4.47",
      "tailwindcss": "^3.4.13",
      "typescript": "^5.2.0",
      "vite": "^6.0.0",
      "eslint": "^9.0.0",
      "@typescript-eslint/eslint-plugin": "^8.0.0",
      "@typescript-eslint/parser": "^8.0.0",
      "eslint-plugin-react-hooks": "^5.0.0",
      "eslint-plugin-react-refresh": "^0.4.4"
    }
  };
  return JSON.stringify(pkg, null, 2);
}
export {
  generateRuntimePackageJson as default
};
