import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Public } from '@edr/api-common';

import { AiBookingRequestDto } from './dto/ai-booking-request.dto';
import { AiBookingResult } from './types/ai-booking-result.type';
import { MockAiService } from './mock-ai.service';

// @Public() — TODO: swap for real guard when this leaves dev/testing.
// Safe while public: extracts + validates text only, never creates or
// dispatches anything.
@Public()
@ApiTags('AI Assistant (mock)')
@Controller('ai')
export class AiController {
  constructor(private readonly mockAiService: MockAiService) {}

  @Post('booking/extract')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({
    summary:
      'Mock AI: extract structured booking fields from free-text request',
  })
  @ApiOkResponse({
    description:
      'Extracted fields, validation result, and next-step recommendation',
  })
  extractBooking(@Body() dto: AiBookingRequestDto): AiBookingResult {
    return this.mockAiService.extractBooking(dto.text);
  }
}
