export interface UserAccount {
  id: number;
  username: string;
  roles: string[];
  groups: string[];
  is_admin: boolean;
  is_super_admin?: boolean;
  primary_role?: string | null;
  full_name?: string | null;
  first_name?: string | null;
  last_name?: string | null;
  email?: string | null;
  job_title?: string | null;
  organization?: string | null;
  phone?: string | null;
  mobile_phone?: string | null;
  enabled?: boolean | null;
  node_id?: number | null;
  created_at?: string | null;
  updated_at?: string | null;
  created_by?: string | null;
  updated_by?: string | null;
  properties?: Record<string, string | number | boolean | null>;
}

export interface LoginResponse {
  access_token: string;
  token_type: string;
  refresh_token?: string;
  expires_in?: number;
  user: UserAccount;
}

export interface Transaction {
  id: number;
  transaction_number: string;
  transaction_type: string;
  transaction_type_label: string;
  transaction_status_label: string;
  application_date?: string;
  complete_date?: string;
  instrument_number?: string;
  page_number?: string;
  volume?: string;
  old_property_id?: string;
  target_property_ids?: string;
  source_property_ids?: string;
}

export interface AnalyticsBreakdown {
  label: string;
  count: number;
  percentage?: number;
  [key: string]: string | number | undefined;
}

export interface AnalyticsOwnerRow {
  transactionId: number;
  transactionNumber?: string;
  documentId?: number | null;
  ownerType?: string;
  ownerFullName?: string;
  ownerFirstName?: string | null;
  ownerLastName?: string | null;
  ownerGender?: string;
  ownershipType?: string;
  ownershipCategory?: string;
  propertyUniqueId?: string | null;
  propertyUpin?: string | null;
  cofoIssuanceDate?: string | null;
  cofoRegistrationDate?: string | null;
  documentNumber?: string | null;
  documentType?: string | null;
  documentTypeCode?: string | null;
  referenceNumber?: string | null;
  instrumentNumber?: string | null;
  pageNumber?: string | null;
  volumeNumber?: string | null;
  documentReference?: string | null;
  ownerGroup?: string | null;
  partyRole?: string | null;
  ownerEmail?: string | null;
  ownerPhoneNumber?: string | null;
  ownerOccupation?: string | null;
  propertyList?: string[];
}

export interface AnalyticsOptions {
  ownerTypes?: string[];
  ownerGenders?: string[];
  ownershipTypes?: string[];
  ownershipCategories?: string[];
  documentTypes?: string[];
}

export interface AnalyticsResponse {
  filters: Record<string, any>;
  availableYears: number[];
  summary: {
    totalTransactions: number;
    totalOwnerRows?: number;
    uniqueProperties?: number;
    totalDocuments?: number;
    ownerTypeBreakdown: AnalyticsBreakdown[];
    ownershipCategoryCards: { label: string; count: number }[];
    ownershipTrend: { label: string; count: number }[];
    documentTypeBreakdown?: { label: string; count: number }[];
    monthlyTrend?: { label: string; count: number }[];
  };
  options?: AnalyticsOptions;
  tables: {
    owners: AnalyticsOwnerRow[];
    ownershipCategories: { ownershipCategory: string; transactionCount: number }[];
  };
  meta: {
    totalOwnerRows: number;
    limit: number;
    offset: number;
    totalTransactions?: number;
  };
}

