"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivityStatisticsResponseDto = exports.ActivitySearchDto = exports.ActivityDto = exports.ActivityCreateDto = exports.ActivityResponseDto = exports.mapActivity = exports.ReactionType = exports.ReactionLevel = void 0;
const openapi = require("@nestjs/swagger");
const nestjs_zod_1 = require("nestjs-zod");
const user_dto_1 = require("./user.dto");
const validation_1 = require("../validation");
const zod_1 = __importDefault(require("zod"));
var ReactionLevel;
(function (ReactionLevel) {
    ReactionLevel["ALBUM"] = "album";
    ReactionLevel["ASSET"] = "asset";
})(ReactionLevel || (exports.ReactionLevel = ReactionLevel = {}));
const ReactionLevelSchema = zod_1.default.enum(ReactionLevel).describe('Reaction level').meta({ id: 'ReactionLevel' });
var ReactionType;
(function (ReactionType) {
    ReactionType["COMMENT"] = "comment";
    ReactionType["LIKE"] = "like";
})(ReactionType || (exports.ReactionType = ReactionType = {}));
const ReactionTypeSchema = zod_1.default.enum(ReactionType).describe('Reaction type').meta({ id: 'ReactionType' });
const ActivityResponseSchema = zod_1.default
    .object({
    id: zod_1.default.uuidv4().describe('Activity ID'),
    createdAt: validation_1.isoDatetimeToDate.describe('Creation date'),
    user: user_dto_1.UserResponseSchema,
    assetId: zod_1.default.uuidv4().nullable().describe('Asset ID (if activity is for an asset)'),
    type: ReactionTypeSchema,
    comment: zod_1.default.string().nullish().describe('Comment text (for comment activities)'),
})
    .meta({ id: 'ActivityResponseDto' });
const ActivityStatisticsResponseSchema = zod_1.default
    .object({
    comments: zod_1.default.int().min(0).describe('Number of comments'),
    likes: zod_1.default.int().min(0).describe('Number of likes'),
})
    .meta({ id: 'ActivityStatisticsResponseDto' });
const ActivitySchema = zod_1.default.object({
    albumId: zod_1.default.uuidv4().describe('Album ID'),
    assetId: zod_1.default.uuidv4().optional().describe('Asset ID (if activity is for an asset)'),
});
const ActivitySearchSchema = ActivitySchema.extend({
    type: ReactionTypeSchema.optional(),
    level: ReactionLevelSchema.optional(),
    userId: zod_1.default.uuidv4().optional().describe('Filter by user ID'),
});
const ActivityCreateSchema = ActivitySchema.extend({
    type: ReactionTypeSchema,
    assetId: zod_1.default.uuidv4().optional().describe('Asset ID (if activity is for an asset)'),
    comment: zod_1.default.string().optional().describe('Comment text (required if type is comment)'),
})
    .refine((data) => data.type !== ReactionType.COMMENT || (data.comment && data.comment.trim() !== ''), {
    error: 'Comment is required when type is COMMENT',
    path: ['comment'],
})
    .refine((data) => data.type === ReactionType.COMMENT || !data.comment, {
    error: 'Comment must not be provided when type is not COMMENT',
    path: ['comment'],
})
    .describe('Activity create');
const mapActivity = (activity) => {
    return {
        id: activity.id,
        assetId: activity.assetId,
        createdAt: activity.createdAt,
        comment: activity.comment,
        type: activity.isLiked ? ReactionType.LIKE : ReactionType.COMMENT,
        user: (0, user_dto_1.mapUser)(activity.user),
    };
};
exports.mapActivity = mapActivity;
class ActivityResponseDto extends (0, nestjs_zod_1.createZodDto)(ActivityResponseSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.ActivityResponseDto = ActivityResponseDto;
class ActivityCreateDto extends (0, nestjs_zod_1.createZodDto)(ActivityCreateSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.ActivityCreateDto = ActivityCreateDto;
class ActivityDto extends (0, nestjs_zod_1.createZodDto)(ActivitySchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.ActivityDto = ActivityDto;
class ActivitySearchDto extends (0, nestjs_zod_1.createZodDto)(ActivitySearchSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.ActivitySearchDto = ActivitySearchDto;
class ActivityStatisticsResponseDto extends (0, nestjs_zod_1.createZodDto)(ActivityStatisticsResponseSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.ActivityStatisticsResponseDto = ActivityStatisticsResponseDto;
//# sourceMappingURL=activity.dto.js.map