"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkspaceController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const workspace_service_1 = require("./workspace.service");
const search_workspace_dto_1 = require("./dto/search-workspace.dto");
const file_tree_dto_1 = require("./dto/file-tree.dto");
let WorkspaceController = class WorkspaceController {
    constructor(workspaceService) {
        this.workspaceService = workspaceService;
    }
    async getFileTree() {
        return this.workspaceService.getFileTree();
    }
    async invalidateFileTreeCache() {
        return this.workspaceService.invalidateFileTreeCache();
    }
    async search(query) {
        const { q, type, page, limit } = query;
        return this.workspaceService.search(q, type, page, limit);
    }
    async getFileContent(path) {
        const content = await this.workspaceService.getFileContent(path);
        return { content };
    }
};
exports.WorkspaceController = WorkspaceController;
__decorate([
    (0, common_1.Get)('file-tree'),
    (0, swagger_1.ApiOperation)({
        summary: 'Get project file tree',
        description: 'Returns the hierarchical directory structure for the current project. Used by the frontend for file navigation and tree views.',
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'File tree structure',
        type: file_tree_dto_1.FileTreeResponseDto,
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], WorkspaceController.prototype, "getFileTree", null);
__decorate([
    (0, common_1.Post)('file-tree/invalidate'),
    (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
    (0, swagger_1.ApiOperation)({
        summary: 'Invalidate file tree cache',
        description: 'Clears the cached file tree. Call this when files are changed externally (e.g., git operations, external editors).',
    }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'Cache invalidated' }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], WorkspaceController.prototype, "invalidateFileTreeCache", null);
__decorate([
    (0, common_1.Get)('search'),
    (0, swagger_1.ApiOperation)({
        summary: 'Search files in workspace',
        description: 'Fuzzy search for files by name or content. Used for Cmd+P-style quick file opening. Uses ripgrep for fast searching.',
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Search results with file paths and matches',
        type: search_workspace_dto_1.SearchWorkspaceResponseDto,
    }),
    __param(0, (0, common_1.Query)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [search_workspace_dto_1.SearchWorkspaceQueryDto]),
    __metadata("design:returntype", Promise)
], WorkspaceController.prototype, "search", null);
__decorate([
    (0, common_1.Get)('file-content'),
    (0, swagger_1.ApiOperation)({
        summary: 'Get file content',
        description: 'Read the content of a specific file. Path is relative to project root.',
    }),
    (0, swagger_1.ApiQuery)({
        name: 'path',
        description: 'Relative path to the file',
        example: 'src/index.ts',
        required: true,
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'File content',
        schema: { properties: { content: { type: 'string' } } },
    }),
    __param(0, (0, common_1.Query)('path')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], WorkspaceController.prototype, "getFileContent", null);
exports.WorkspaceController = WorkspaceController = __decorate([
    (0, swagger_1.ApiTags)('workspace'),
    (0, common_1.Controller)('workspace'),
    __metadata("design:paramtypes", [workspace_service_1.WorkspaceService])
], WorkspaceController);
//# sourceMappingURL=workspace.controller.js.map