import { z } from 'zod'

export const userStatusSchema = z.enum(['active', 'banned'])

export const onlineStatusSchema = z.enum(['online', 'offline', 'banned'])

export const userSchema = z.object({
  id: z.union([z.string(), z.number()]),
  username: z.string(),
  email: z.string().optional().nullable(),
  device_id: z.string().optional().nullable(),
  avatar: z.string().optional().nullable(),
  status: userStatusSchema,
  online_status: onlineStatusSchema.optional(),
  device_count: z.number().default(0),
  application_id: z.union([z.string(), z.number()]).nullable(),
  balance: z.number().nullable(),
  expiry_at: z.string().optional().nullable(),
  last_login_at: z.string().optional().nullable(),
  last_heartbeat_at: z.string().optional().nullable(),
  is_trial_user: z.boolean().default(false),
  trial_start_at: z.string().optional().nullable(),
  trial_end_at: z.string().optional().nullable(),
  created_at: z.string(),
  updated_at: z.string().optional(),
  application: z.object({
    id: z.union([z.string(), z.number()]),
    name: z.string(),
    billing_type: z.string().optional().nullable(),
  }).optional().nullable(),
})

export type User = z.infer<typeof userSchema>
export type UserStatus = z.infer<typeof userStatusSchema>
export type OnlineStatus = z.infer<typeof onlineStatusSchema>
