"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.RouterController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const router_service_1 = require("./router.service");
const jwt_auth_guard_1 = require("../common/guard/jwt-auth.guard");
const current_business_decorator_1 = require("../common/decorators/current-business.decorator");
const router_dto_1 = require("./dto/router.dto");
let RouterController = class RouterController {
    constructor(routerService) {
        this.routerService = routerService;
    }
    async listRouters(business) {
        return this.routerService.getBusinessRouters(business.id);
    }
    async addRouter(dto, business) {
        return this.routerService.addRouter(dto, business.id);
    }
    async updateRouter(id, dto) {
        return this.routerService.updateRouter(id, dto);
    }
    async deleteRouter(id) {
        await this.routerService.deleteRouter(id);
    }
    async testConnection(dto) {
        return this.routerService.testConnection(dto.routerId);
    }
    async getRouterStatus(id) {
        return this.routerService.getRouterStatus(id);
    }
    async getRouterSessions(id) {
        return this.routerService.getRouterSessions(id);
    }
    async reconnectRouter(id) {
        return this.routerService.reconnectRouter(id);
    }
};
exports.RouterController = RouterController;
__decorate([
    (0, common_1.Get)(),
    (0, swagger_1.ApiOperation)({ summary: 'List all routers for the current business' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Returns list of routers' }),
    __param(0, (0, current_business_decorator_1.CurrentBusiness)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], RouterController.prototype, "listRouters", null);
__decorate([
    (0, common_1.Post)(),
    (0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
    (0, swagger_1.ApiOperation)({ summary: 'Add a new router' }),
    (0, swagger_1.ApiResponse)({ status: 201, description: 'Router created successfully' }),
    (0, swagger_1.ApiResponse)({ status: 400, description: 'Validation error' }),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_business_decorator_1.CurrentBusiness)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [router_dto_1.AddRouterDto, Object]),
    __metadata("design:returntype", Promise)
], RouterController.prototype, "addRouter", null);
__decorate([
    (0, common_1.Put)(':id'),
    (0, swagger_1.ApiOperation)({ summary: 'Update an existing router' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Router updated successfully' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Router not found' }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, router_dto_1.UpdateRouterDto]),
    __metadata("design:returntype", Promise)
], RouterController.prototype, "updateRouter", null);
__decorate([
    (0, common_1.Delete)(':id'),
    (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
    (0, swagger_1.ApiOperation)({ summary: 'Soft-delete a router' }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'Router deleted' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Router not found' }),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], RouterController.prototype, "deleteRouter", null);
__decorate([
    (0, common_1.Post)('test'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiOperation)({ summary: 'Test connection to a router' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Test result' }),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [router_dto_1.TestRouterDto]),
    __metadata("design:returntype", Promise)
], RouterController.prototype, "testConnection", null);
__decorate([
    (0, common_1.Get)(':id/status'),
    (0, swagger_1.ApiOperation)({ summary: 'Get router status' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Router status' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Router not found' }),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], RouterController.prototype, "getRouterStatus", null);
__decorate([
    (0, common_1.Get)(':id/sessions'),
    (0, swagger_1.ApiOperation)({ summary: 'Get active sessions on a router' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'List of active sessions' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Router not found' }),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], RouterController.prototype, "getRouterSessions", null);
__decorate([
    (0, common_1.Post)(':id/reconnect'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiOperation)({ summary: 'Reconnect to a router' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Reconnection result' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Router not found' }),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], RouterController.prototype, "reconnectRouter", null);
exports.RouterController = RouterController = __decorate([
    (0, swagger_1.ApiTags)('Routers'),
    (0, common_1.Controller)('routers'),
    (0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
    (0, swagger_1.ApiBearerAuth)(),
    __metadata("design:paramtypes", [router_service_1.RouterService])
], RouterController);
