"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateAdminOverviewPage = generateAdminOverviewPage;
const Generator = __importStar(require("@postxl/generator"));
const utils_1 = require("../utils");
/**
 * Generator function that generates the Admin overview page at /admin
 */
function generateAdminOverviewPage({ context }) {
    const imports = Generator.ImportGenerator
        //
        .from(context.admin.pages.overview.pageComponent.location);
    const { schemas: sortedSchemas, modelsBySchema } = (0, utils_1.groupAndSortModelsBySchema)(context);
    // Generate the schema sections
    const schemaSections = sortedSchemas
        .map((schema) => {
        const models = modelsBySchema.get(schema);
        const modelCards = models
            .map((model) => `
            <Link
              key="${model.name}"
              to="${model.route}"
              className="block p-6 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg hover:shadow-lg hover:border-blue-500 dark:hover:border-blue-400 transition-all"
            >
              <h3 className="text-lg font-semibold mb-2">${model.userFriendlyName}</h3>
              <p className="text-sm text-gray-600 dark:text-gray-400">Manage ${model.userFriendlyName.toLowerCase()} records</p>
            </Link>`)
            .join('');
        return `
        <section key="${schema}" className="mb-8">
          <h2 className="text-2xl font-bold mb-4 pb-2 border-b border-gray-200 dark:border-gray-700">${schema}</h2>
          <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
            ${modelCards}
          </div>
        </section>`;
    })
        .join('');
    return `
import { Link } from "@tanstack/react-router";
${imports.generate()}

export default function AdminOverviewPage() {
  return (
    <div className="min-h-full p-8">
      <div className="max-w-7xl mx-auto">
        <h1 className="text-4xl font-bold mb-8">Admin Dashboard</h1>
        <p className="text-gray-600 dark:text-gray-400 mb-8">
          Select a model to manage its records
        </p>

        ${schemaSections}
        {import.meta.env.NEXT_PUBLIC_ALLOW_ADMIN === 'true' && (
          <section key="Advanced" className="mb-8">
            <h2 className="text-2xl font-bold mb-4 pb-2 border-b border-gray-200 dark:border-gray-700">
              Advanced (Dev Only)
            </h2>
            <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
              <Link
                key="DataManagement"
                to="/admin/data-management"
                className="block p-6 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg hover:shadow-lg hover:border-blue-500 dark:hover:border-blue-400 transition-all"
              >
                <h3 className="text-lg font-semibold mb-2">Data Management</h3>
                <p className="text-sm text-gray-600 dark:text-gray-400">
                  Advanced import/export tools for database management
                </p>
              </Link>
            </div>
          </section>
        )}
      </div>
    </div>
  )
}
`;
}
//# sourceMappingURL=admin-overview-page.generator.js.map