// Weft Sandbox Core Types

export interface WeftConfig {
  artifact: {
    id: string;
    name: string;
    generatedAt: string;
    intentHash: string;
    originalSpec: string;
  };
  mockData: Record<string, any>;
  apiStubs: ApiStub[];
  navigation: {
    onSuccess?: string;
    onCancel?: string;
    onError?: string;
  };
}

export interface ApiStub {
  method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
  endpoint: string;
  description: string;
  requestSchema?: Record<string, string>;
  mockResponse: any;
  mockStatus?: number;
  mockDelay?: number;
}

export interface ActionLog {
  id: string;
  timestamp: Date;
  actionType: 'CLICK' | 'INPUT' | 'SUBMIT' | 'NAVIGATE' | 'API_CALL' | 'SELECT' | 'HOVER';
  element: {
    type: string;
    id?: string;
    text?: string;
    selector: string;
    value?: any;
  };
  wouldTrigger: {
    endpoint?: string;
    method?: string;
    payload?: any;
    navigation?: string;
  };
  mockResult?: any;
  duration?: number;
}

export interface MockDataProvider {
  data: Record<string, any>;
  get(path: string): any;
  set(path: string, value: any): void;
  reset(): void;
  export(): Record<string, any>;
}

export interface StubHooksConfig {
  stubs: ApiStub[];
  onAction: (action: ActionLog) => void;
}

export interface SandboxState {
  isRunning: boolean;
  actionLogs: ActionLog[];
  currentMockData: Record<string, any>;
  errors: SandboxError[];
}

export interface SandboxError {
  id: string;
  timestamp: Date;
  type: 'runtime' | 'network' | 'validation' | 'render';
  message: string;
  stack?: string;
  context?: Record<string, any>;
}
