function env(name: keyof ImportMetaEnv, fallback: string): string {
  const value = import.meta.env[name];
  return typeof value === "string" && value.trim() ? value.trim() : fallback;
}

export const privacyConfig = {
  siteName: "Plimi",
  siteUrl: env("VITE_SITE_URL", window.location.origin),
  controllerName: env("VITE_LEGAL_NAME", "Plimi website operator"),
  privacyEmail: env("VITE_PRIVACY_EMAIL", "privacy@example.com"),
  controllerCountry: env("VITE_LEGAL_COUNTRY", "Not configured"),
  policyEffectiveDate: env("VITE_PRIVACY_EFFECTIVE_DATE", "2026-06-07"),
  analyticsProvider: env("VITE_ANALYTICS_PROVIDER_NAME", "Umami"),
  analyticsScriptUrl: env(
    "VITE_ANALYTICS_SCRIPT_URL",
    "https://u.achraf.app/script.js"
  ),
  analyticsWebsiteId: env(
    "VITE_ANALYTICS_WEBSITE_ID",
    "89d0f8d2-5b59-438c-b1f6-ab2655e97f6e"
  ),
  analyticsHost: env("VITE_ANALYTICS_HOST", "u.achraf.app"),
  analyticsHostCountry: env(
    "VITE_ANALYTICS_HOST_COUNTRY",
    "Not configured"
  ),
  analyticsRetentionMonths: env("VITE_ANALYTICS_RETENTION_MONTHS", "13"),
};

export const hasAnalyticsConfiguration = Boolean(
  privacyConfig.analyticsScriptUrl && privacyConfig.analyticsWebsiteId
);
