import {
  AccountBlockingState,
  AccountLimits,
  AccountTypes,
  BlockedFeature,
  KBRoles,
  KnowledgeBoxMode,
  WorkflowType,
} from '@nuclia/core';
import { ZoneSummary } from '../manage-zones/zone.models';
import { AccountLabels } from './regional-account.models';

export interface AccountSummary {
  id: string;
  slug: string;
  title: string;
  type: AccountTypes;
  created: string;
  email: string;
  labels: AccountLabels | null;
}

export interface AccountDetails extends AccountSummary {
  blockingState?: AccountBlockingState;
  limits: AccountLimits;
  maxKbs: number;
  maxAgents: number;
  maxMemories: number;
  trialExpirationDate?: string;
  users: AccountUser[];
  workflow?: WorkflowType;
  allowAccessNonEnterpriseModels: boolean;
}

export interface KbSummary {
  id: string;
  slug: string;
  title: string;
  accountId: string;
  zone: ZoneSummary;
  private: boolean;
  activity: {
    redash: string;
    grafana: string;
  };
  kbMode: KnowledgeBoxMode;
}

export interface KbCounters {
  [kbId: string]: {
    resources: { total: number; pending: number; error: number };
    paragraphs: number;
    fields: number;
    sentences: number;
    index_size: number;
  };
}

export interface KbDetails extends KbSummary {
  created: string;
  contributors: KbUser[];
  members: KbUser[];
  owners: KbUser[];
  prewarm_enabled?: boolean;
}

export interface KbUser {
  id: string;
  name: string;
  email: string;
  role: KBRoles;
}

export interface AccountUser {
  id: string;
  name: string | null;
  email: string;
  isManager?: boolean;
}

export type BlockedFeatureFormValues = Record<BlockedFeature, boolean>;

export interface AccountConfigurationPayload {
  email: string;
  maxKbs: number;
  maxMemories: number;
  maxAgents: number;
  slug: string;
  trialExpirationDate?: string | null;
  type: AccountTypes;
  workflow?: WorkflowType | null;
  allowAccessNonEnterpriseModels: boolean;
  labels: AccountLabels | null;
}
