
import { FC } from 'react';

export interface IRepositories {
  getSystems: (params?: any) => Promise<any>;
  getResources: (params?: any) => Promise<any>;
  getPlans: (params?: any) => Promise<any>;
  getLocations: (params?: any) => Promise<any>;
  getApprovalGroups: (params?: any) => Promise<any>;
  resolveSystems: (ids: string[]) => Promise<Map<string, any>>;
  resolveResources: (ids: string[]) => Promise<Map<string, any>>;
  resolvePlans: (ids: string[]) => Promise<Map<string, any>>;
  resolveLocations: (ids: string[]) => Promise<Map<string, string>>;
}

export interface EntitlementObject {
  objectType: string;
  name: string;
  tags: string[];
  configuration: Record<string, unknown>;
  schedules: any[];
}

/** JSON-Schema-backed descriptor of a single AI tool the editor exposes. */
export interface EditorAiToolSpec {
  name: string;
  description: string;
  parameters: Record<string, unknown>;
}
/** Result of invoking an AI tool. A rejected mutation leaves the model unchanged. */
export interface EditorToolResult {
  ok: boolean;
  result?: unknown;
  rejected?: boolean;
  reason?: string;
}
/**
 * The editor's AI capability. Beyond read/mutate/validate tools it also exposes
 * non-mutating viewport + selection tools (get_canvas_view, set_canvas_view,
 * fit_view, focus_schedule, set_graph_selection, auto_layout_graph) so an
 * assistant can show the user what it means without changing the graph.
 */
export interface EditorAiCapability {
  kind: string;
  targetId?: string;
  guidelines: string;
  tools: EditorAiToolSpec[];
  invoke: (toolName: string, args: Record<string, unknown>) => Promise<EditorToolResult>;
}

export interface EntitlementEditorProps {
  initialData: EntitlementObject;
  repositories?: IRepositories;
  onSave?: (data: EntitlementObject) => void;
  onSaveAndReturn?: (data: EntitlementObject) => void;
  onBack?: () => void;
  additionalCanvasMenuItems?: any[];
  additionalNodeMenuItems?: (node: any) => any[];
  /** Called with the editor's AI capability once ready, and with null on unmount. */
  onAiCapabilityReady?: (cap: EditorAiCapability | null) => void;
}

declare const EntitlementEditor: FC<EntitlementEditorProps>;
export default EntitlementEditor;
export { EntitlementEditor };

export interface RepositoryProviderProps {
  children: React.ReactNode;
  repositories: IRepositories;
}

export declare const RepositoryProvider: FC<RepositoryProviderProps>;
export declare const useRepositories: () => IRepositories;
