export type DocumentSearchMatchField = "title" | "content" | "recent";

export type DocumentSearchTimeRange = "any" | "7d" | "30d";
export type DocumentSearchTimeField = "updated" | "created";

export interface DocumentSearchFilters {
  titleOnly: boolean;
  exact: boolean;
  onlyCurrentPage: boolean;
  includeOcr: boolean;
  timeRange: DocumentSearchTimeRange;
  timeField: DocumentSearchTimeField;
  customRange?: {
    from?: string;
    to?: string;
  };
}

export interface DocumentSearchRequest {
  workspaceId: string;
  documentId?: string;
  query?: string;
  filters: DocumentSearchFilters;
  limit?: number;
}

export interface DocumentSearchResult {
  id: string;
  title: string | null;
  snippet: string;
  updatedAt: string | null;
  createdAt: string | null;
  matchField: DocumentSearchMatchField;
  hasOcr: boolean;
  publicPath: string;
  score: number;
  nodeId?: string | null;
  subtreeRootId?: string | null;
  evidence?: Array<{
    kind: string;
    nodeId?: string | null;
    snippet: string;
  }>;
}

export interface DocumentSearchResponse {
  results: DocumentSearchResult[];
  recent: DocumentSearchResult[];
}

export interface ReferenceTarget {
  id: string;
  title: string | null;
}
