"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.DuplicateController = void 0;
const openapi = require("@nestjs/swagger");
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const decorators_1 = require("../decorators");
const asset_ids_response_dto_1 = require("../dtos/asset-ids.response.dto");
const duplicate_dto_1 = require("../dtos/duplicate.dto");
const enum_1 = require("../enum");
const auth_guard_1 = require("../middleware/auth.guard");
const duplicate_service_1 = require("../services/duplicate.service");
const validation_1 = require("../validation");
let DuplicateController = class DuplicateController {
    service;
    constructor(service) {
        this.service = service;
    }
    getAssetDuplicates(auth) {
        return this.service.getDuplicates(auth);
    }
    deleteDuplicates(auth, dto) {
        return this.service.deleteAll(auth, dto);
    }
    deleteDuplicate(auth, { id }) {
        return this.service.delete(auth, id);
    }
    resolveDuplicates(auth, dto) {
        return this.service.resolve(auth, dto);
    }
};
exports.DuplicateController = DuplicateController;
__decorate([
    (0, common_1.Get)(),
    (0, auth_guard_1.Authenticated)({ permission: enum_1.Permission.DuplicateRead }),
    (0, decorators_1.Endpoint)({
        summary: 'Retrieve duplicates',
        description: 'Retrieve a list of duplicate assets available to the authenticated user.',
        history: new decorators_1.HistoryBuilder().added('v1').beta('v1').stable('v2'),
    }),
    openapi.ApiResponse({ status: 200, type: [require("../dtos/duplicate.dto").DuplicateResponseDto] }),
    __param(0, (0, auth_guard_1.Auth)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], DuplicateController.prototype, "getAssetDuplicates", null);
__decorate([
    (0, common_1.Delete)(),
    (0, auth_guard_1.Authenticated)({ permission: enum_1.Permission.DuplicateDelete }),
    (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
    (0, decorators_1.Endpoint)({
        summary: 'Delete duplicates',
        description: 'Delete multiple duplicate assets specified by their IDs.',
        history: new decorators_1.HistoryBuilder().added('v1').beta('v1').stable('v2'),
    }),
    openapi.ApiResponse({ status: common_1.HttpStatus.NO_CONTENT }),
    __param(0, (0, auth_guard_1.Auth)()),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, asset_ids_response_dto_1.BulkIdsDto]),
    __metadata("design:returntype", Promise)
], DuplicateController.prototype, "deleteDuplicates", null);
__decorate([
    (0, common_1.Delete)(':id'),
    (0, auth_guard_1.Authenticated)({ permission: enum_1.Permission.DuplicateDelete }),
    (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
    (0, decorators_1.Endpoint)({
        summary: 'Dismiss a duplicate group',
        description: 'Dismiss a duplicate group by its ID, unlinking all assets in the group without deleting them.',
        history: new decorators_1.HistoryBuilder().added('v1').beta('v1').stable('v2'),
    }),
    openapi.ApiResponse({ status: common_1.HttpStatus.NO_CONTENT }),
    __param(0, (0, auth_guard_1.Auth)()),
    __param(1, (0, common_1.Param)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, validation_1.UUIDParamDto]),
    __metadata("design:returntype", Promise)
], DuplicateController.prototype, "deleteDuplicate", null);
__decorate([
    (0, common_1.Post)('resolve'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, auth_guard_1.Authenticated)({ permission: enum_1.Permission.DuplicateDelete }),
    (0, decorators_1.Endpoint)({
        summary: 'Resolve duplicate groups',
        description: 'Resolve duplicate groups by synchronizing metadata across assets and deleting/trashing duplicates.',
        history: new decorators_1.HistoryBuilder().added('v3.0.0').alpha('v3.0.0'),
    }),
    openapi.ApiResponse({ status: common_1.HttpStatus.OK, type: [require("../dtos/asset-ids.response.dto").BulkIdResponseDto] }),
    __param(0, (0, auth_guard_1.Auth)()),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, duplicate_dto_1.DuplicateResolveDto]),
    __metadata("design:returntype", Promise)
], DuplicateController.prototype, "resolveDuplicates", null);
exports.DuplicateController = DuplicateController = __decorate([
    (0, swagger_1.ApiTags)(enum_1.ApiTag.Duplicates),
    (0, common_1.Controller)('duplicates'),
    __metadata("design:paramtypes", [duplicate_service_1.DuplicateService])
], DuplicateController);
//# sourceMappingURL=duplicate.controller.js.map