/**
 * Global window type definitions for WooNooW
 */

interface WNW_API_Config {
  root: string;
  nonce: string;
  isDev: boolean;
}

interface WNW_Config {
  siteTitle?: string;
}

interface WNW_WC_MENUS {
  items?: any[];
}

interface WNW_CONFIG {
  standaloneMode?: boolean;
  restUrl?: string;
  wpAdminUrl?: string;
  siteUrl?: string;
  siteName?: string;
  isAuthenticated?: boolean;
  currentUser?: {
    id: number;
    name: string;
    email: string;
  };
  user?: {
    id: number;
    name: string;
    email: string;
  };
  store?: {
    currency: string;
    currencySymbol: string;
    currencyPosition: string;
    thousandSeparator: string;
    decimalSeparator: string;
    decimals: number;
  };
  storeUrl?: string;
  customerSpaEnabled?: boolean;
  nonce?: string;
  pluginUrl?: string;
  onboardingCompleted?: boolean;
}

interface WNW_Store {
  locale?: string;
  currency?: string;
  currency_symbol?: string;
  currency_pos?: string;
  thousand_sep?: string;
  decimal_sep?: string;
  decimals?: number;
  symbol?: string; // Sometimes mapped
  position?: string;
}

interface WNW_NavNode {
  key: string;
  path: string;
  icon: string;
  label: string;
  children?: any[];
}

declare global {
  interface Window {
    WNW_API: WNW_API_Config; // Make required to avoid "possibly undefined" check in every usage if we are sure it exists
    wnw?: WNW_Config;
    WNW_WC_MENUS?: WNW_WC_MENUS;
    WNW_CONFIG?: WNW_CONFIG;
    WNW_STORE?: WNW_Store;
    WNW_NAV_TREE?: WNW_NavNode[];
    WNW_ADDON_ROUTES?: Array<{
      path: string;
      component_url: string;
      props?: Record<string, any>;
    }>;
  }

  interface WindowEventMap {
    'woonoow:navigation-updated': CustomEvent<{
      moduleId?: string;
      enabled?: boolean;
    }>;
  }
}

export { };
