/**
 * @file Dynamic Main Entry Point
 * @author Matthew Raymer
 *
 * This file dynamically loads the appropriate platform-specific main entry point
 * based on the current environment and build configuration.
 */

import { logger } from "./utils/logger";

// Check the platform from environment variables
const platform = process.env.VITE_PLATFORM || "web";

logger.info(`[Main] 🚀 Loading TimeSafari for platform: ${platform}`);

// Log all relevant environment variables for boot-time debugging
logger.info("[Main] 🌍 Boot-time environment configuration:", {
  platform: process.env.VITE_PLATFORM,
  defaultEndorserApiServer: process.env.VITE_DEFAULT_ENDORSER_API_SERVER,
  defaultPartnerApiServer: process.env.VITE_DEFAULT_PARTNER_API_SERVER,
  nodeEnv: process.env.NODE_ENV,
  timestamp: new Date().toISOString(),
});

// Dynamically import the appropriate main entry point
if (platform === "capacitor") {
  logger.debug(`[Main] 📱 Loading Capacitor-specific entry point`);
  import("./main.capacitor");
} else if (platform === "electron") {
  logger.debug(`[Main] 💻 Loading Electron-specific entry point`);
  import("./main.electron");
} else {
  logger.debug(`[Main] 🌐 Loading Web-specific entry point`);
  import("./main.web");
}
