type SocialMedia = {
  id: number;
  name: string;
  link: string;
  icon: string | null;
};

type AuthProvider = {
  id: string;
  name: string;
  is_enabled: boolean;
};

type OTPConfig = {
  expire_time: number;
  digit_range: [number, number];
};

export type Currency = {
  name: string;
  code: string;
  symbol: string;
  symbol_position: "left" | "right";
  thousand_separator: string;
  decimal_separator: string;
  precision: number;
  rate: string;
  status: "active" | "inactive";
  is_default: boolean;
};

type ConfigItem = {
  is_enabled: boolean;
  title: string;
  description: string;
};

type SystemConfig = {
  user_registration: ConfigItem;
  agreement_terms_and_policy: ConfigItem;
  force_secure_password: ConfigItem;
  email_verification: ConfigItem;
  phone_verification: ConfigItem;
  force_https: ConfigItem;
  email_notification: ConfigItem;
  phone_notification: ConfigItem;
  push_notification: ConfigItem;
  kyc_verification: ConfigItem;
  share_transfer: ConfigItem;
};

// Utility type to extract just the is_enabled values
export type SystemConfigEnabled = {
  [K in keyof SystemConfig]: boolean;
};

type PaginationConfig = {
  per_page: number;
  data_limit: number;
  cache_time: number;
};

type CookieConsent = {
  is_enabled: boolean;
  title: string;
  description: string;
};

type ExtraService = {
  system_config: SystemConfig;
  site_pagination_config: PaginationConfig;
  cookie_consent: CookieConsent;
};

type CompanyInfo = {
  name: string;
  email: string;
  phone: string;
  website: string;
};

type LogoFavicon = {
  logo_light: string;
  logo_dark: string;
  favicon: string;
};

type Address = {
  country: string;
  state: string;
  city: string;
  postal_code: string;
  address: string;
};

export interface FooterSocialLink {
  name: string;
  link: string;
  icon: string;
}

export interface FooterContent {
  description: string;
  email: string;
  phone: string;
  footer_text: string;
  social_links: FooterSocialLink[];
}

export interface Footer {
  id: number;
  title: string;
  icon: string;
  slug: string;
  hint: string;
  content: FooterContent;
}

type ApplicationInfo = {
  company_info: CompanyInfo;
  logo_favicon: LogoFavicon;
  address: Address;
  timezone: string;
  social_medias: SocialMedia[];
  otp: OTPConfig;
  default_currency: string[];
  auth_providers: AuthProvider[];
  footer_text: string;
  defaultCurrency: Currency;
  extra_service: ExtraService;
  share_transfer_commission: number;
  theme: {
    template: {
      primary: string;
      secondary: string;
      tertiary: string;
    };
  };
};

interface RecaptchaConfig {
  name: string;
  icon: string;
  is_enabled: boolean;
  site_key: string;
  secret_key: string;
}

interface GoogleAnalyticsConfig {
  name: string;
  icon: string;
  is_enabled: boolean;
  measurement_id: string;
}

interface TawkToConfig {
  name: string;
  icon: string;
  is_enabled: boolean;
  project_id: string;
  widget_id: string;
}

interface Extensions {
  recaptcha: RecaptchaConfig;
  google_analytics: GoogleAnalyticsConfig;
  tawk_to: TawkToConfig;
}

export type AppConfig = {
  application_info: ApplicationInfo;
  extensions: Extensions;
  service_switch: {
    system_config: SystemConfig;
    site_pagination_config: PaginationConfig;
    cookie_consent: CookieConsent;
    pagination: null;
  };
  firebase: {
    apiKey: string;
    authDomain: string;
    projectId: string;
    storageBucket: string;
    messagingSenderId: string;
    appId: string;
    measurementId: string;
    vapidKey: string;
  };
  footer: Footer;
};
