import type { ComponentId, FactLocation } from "@fragments-sdk/core";

export type ObservedPropKind =
  | "static"
  | "dynamic"
  | "spread"
  | "jsx"
  | "boolean"
  | "null";

export interface ObservedProp {
  name: string;
  kind: ObservedPropKind;
  value?: string | number | boolean | null;
  location?: FactLocation;
}

export interface ObservedInlineStyle {
  property: string;
  valueKind: "static" | "number" | "css-variable";
  value: string;
}

export interface ComponentCallSite {
  componentId: ComponentId;
  element: string;
  filePath: string;
  line: number;
  column: number;
  nodePath: string;
  props: ObservedProp[];
  inlineStyles: ObservedInlineStyle[];
  textChildren: string[];
}

export interface ComponentUsageSummary {
  componentId: ComponentId;
  callSiteCount: number;
  importingFileCount: number;
  propCounts: Record<string, number>;
  staticValueCounts: Record<string, Record<string, number>>;
  dynamicPropCounts: Record<string, number>;
  spreadCount: number;
}

export interface ComponentUsageAnalysis {
  callSites: ComponentCallSite[];
  summaries: ComponentUsageSummary[];
}
