/**
 * NextAuth.js Type Extensions
 *
 * Extends the default NextAuth types to include custom properties
 * used in the Mawidi application for session management.
 */

import 'next-auth';
import 'next-auth/jwt';

declare module 'next-auth' {
  /**
   * Extended Session interface with custom user properties
   */
  interface Session {
    user: {
      id: string;
      email: string;
      name?: string | null;
      image?: string | null;
      role?: string;
      stripeCustomerId?: string | null;
      organizationId?: string | null;
      orgRole?: string | null;
      allowedTabs?: string[] | null;
    };
  }

  /**
   * Extended User interface with custom properties
   */
  interface User {
    id: string;
    email: string;
    name?: string | null;
    role?: string;
    stripeCustomerId?: string | null;
  }
}

declare module 'next-auth/jwt' {
  /**
   * Extended JWT interface with custom token properties
   */
  interface JWT {
    id?: string;
    name?: string | null;
    email?: string | null;
    role?: string;
    stripeCustomerId?: string | null;
    organizationId?: string | null;
    orgRole?: string | null;
    allowedTabs?: string[] | null;
    exp?: number;
  }
}
