"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.AdminController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const client_1 = require("@prisma/client");
const require_role_decorator_1 = require("../auth/require-role.decorator");
const current_user_decorator_1 = require("../common/current-user.decorator");
const feature_catalog_1 = require("../features/feature-catalog");
const require_feature_decorator_1 = require("../features/require-feature.decorator");
const swagger_docs_1 = require("../common/swagger-docs");
const admin_service_1 = require("./admin.service");
const admin_dto_1 = require("./dto/admin.dto");
let AdminController = class AdminController {
    adminService;
    constructor(adminService) {
        this.adminService = adminService;
    }
    dashboard(user) {
        return this.adminService.dashboard(user);
    }
    listUsers(user, estateId, role, status) {
        return this.adminService.listUsers(user, estateId, role, status);
    }
    updateUser(id, dto, user) {
        return this.adminService.updateUser(id, dto, user);
    }
    listEstates(user) {
        return this.adminService.listEstates(user);
    }
    listEstateSignups(status, user) {
        return this.adminService.listEstateSignups(status, user);
    }
    reviewEstateSignup(estateId, dto, user) {
        return this.adminService.reviewEstateSignup(estateId, dto, user);
    }
    confirmEstatePayment(estateId, dto, user) {
        return this.adminService.confirmEstatePayment(estateId, dto, user);
    }
    listSubscriptionPlans(includeInactive) {
        return this.adminService.listSubscriptionPlans(includeInactive);
    }
    createSubscriptionPlan(dto, user) {
        return this.adminService.createSubscriptionPlan(dto, user);
    }
    getOtpConfig() {
        return this.adminService.getOtpConfig();
    }
    updateOtpConfig(dto, user) {
        return this.adminService.updateOtpConfig(dto, user);
    }
    listIntegrationTemplates() {
        return this.adminService.listIntegrationTemplates();
    }
    listIntegrationConfigs() {
        return this.adminService.listIntegrationConfigs();
    }
    getIntegrationConfig(provider) {
        return this.adminService.getIntegrationConfig(provider);
    }
    updateIntegrationConfig(provider, dto, user) {
        return this.adminService.updateIntegrationConfig(provider, dto, user);
    }
    updateSubscriptionPlan(code, dto, user) {
        return this.adminService.updateSubscriptionPlan(code, dto, user);
    }
    listPaymentProviders(estateId) {
        return this.adminService.listPaymentProviders(estateId);
    }
    updateGlobalPaymentProvider(provider, dto, user) {
        return this.adminService.updateGlobalPaymentProvider(provider, dto, user);
    }
    updateEstatePaymentProvider(estateId, provider, dto, user) {
        return this.adminService.updateEstatePaymentProvider(estateId, provider, dto, user);
    }
    listSalesPartners() {
        return this.adminService.listSalesPartners();
    }
    getMySalesPartnerProfile(user) {
        return this.adminService.getMySalesPartnerProfile(user);
    }
    getMySalesPartnerEarnings(user) {
        return this.adminService.getMySalesPartnerEarnings(user);
    }
    getSalesPartnerEarnings(salesAdminId, user) {
        return this.adminService.getSalesPartnerEarnings(salesAdminId, user);
    }
    updateSalesPartnerProfile(salesAdminId, dto, user) {
        return this.adminService.updateSalesPartnerProfile(salesAdminId, dto, user);
    }
    assignEstateSalesPartner(id, dto, user) {
        return this.adminService.assignEstateSalesPartner(id, dto, user);
    }
    contactEstateAdmin(estateId, dto, user) {
        return this.adminService.contactEstateAdmin(estateId, dto, user);
    }
    updateEstate(id, dto, user) {
        return this.adminService.updateEstate(id, dto, user);
    }
    listResidents(user, estateId) {
        return this.adminService.listResidents(user, estateId);
    }
    updateResident(id, dto, user) {
        return this.adminService.updateResident(id, dto, user);
    }
    listGuards(user, estateId) {
        return this.adminService.listGuards(user, estateId);
    }
    updateGuard(id, dto, user) {
        return this.adminService.updateGuard(id, dto, user);
    }
    listVisitors(user, estateId) {
        return this.adminService.listVisitors(user, estateId);
    }
    updateVisitor(id, dto, user) {
        return this.adminService.updateVisitor(id, dto, user);
    }
    listVisitorPasses(user, estateId, status) {
        return this.adminService.listVisitorPasses(user, estateId, status);
    }
    updateVisitorPass(id, dto, user) {
        return this.adminService.updateVisitorPass(id, dto, user);
    }
    listVisitSessions(user, estateId) {
        return this.adminService.listVisitSessions(user, estateId);
    }
    listIncidents(user, estateId) {
        return this.adminService.listIncidents(user, estateId);
    }
    updateIncident(id, dto, user) {
        return this.adminService.updateIncident(id, dto, user);
    }
    listAuditLogs(estateId, user) {
        return this.adminService.listAuditLogs(estateId, user);
    }
};
exports.AdminController = AdminController;
__decorate([
    (0, common_1.Get)('dashboard'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.PLATFORM_DASHBOARD),
    (0, swagger_1.ApiOperation)({
        summary: 'Super admin dashboard summary',
        description: 'Returns platform-wide counts and recent audit logs for the super-admin dashboard.'
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Dashboard summary returned.',
        schema: {
            example: {
                totals: {
                    estates: 1,
                    users: 4,
                    residents: 1,
                    guards: 1,
                    visitors: 10,
                    activePasses: 3,
                    openVisits: 1,
                    incidents: 2
                },
                recentAuditLogs: []
            }
        }
    }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "dashboard", null);
__decorate([
    (0, common_1.Get)('users'),
    (0, require_role_decorator_1.RequireRole)(client_1.UserRole.SUPER_ADMIN, client_1.UserRole.ESTATE_ADMIN),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.USERS_VIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'List users',
        description: 'Lists platform users for super admins or same-estate users for estate admins, with optional role and status filters.'
    }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiQuery)({ name: 'role', required: false, example: 'RESIDENT' }),
    (0, swagger_1.ApiQuery)({ name: 'status', required: false, example: 'ACTIVE' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Users returned.',
        schema: { example: [{ id: swagger_docs_1.USER_ID_EXAMPLE, estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, phone: '+2348000000003', name: 'Ade Okafor', role: 'RESIDENT', status: 'ACTIVE' }] }
    }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)('estateId')),
    __param(2, (0, common_1.Query)('role')),
    __param(3, (0, common_1.Query)('status')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, String, String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listUsers", null);
__decorate([
    (0, common_1.Patch)('users/:id'),
    (0, require_role_decorator_1.RequireRole)(client_1.UserRole.SUPER_ADMIN, client_1.UserRole.ESTATE_ADMIN),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.USERS_MANAGE),
    (0, swagger_1.ApiOperation)({
        summary: 'Update user',
        description: 'Updates a user account and synchronizes matching resident or guard profile fields where applicable. Estate admins are restricted to users in their estate.'
    }),
    (0, swagger_1.ApiParam)({ name: 'id', example: swagger_docs_1.USER_ID_EXAMPLE, description: 'User ID to update.' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateUserDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'User updated.', schema: { example: { id: swagger_docs_1.USER_ID_EXAMPLE, status: 'SUSPENDED' } } }),
    (0, swagger_docs_1.ApiNotFoundError)('User'),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateUserDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateUser", null);
__decorate([
    (0, common_1.Get)('estates'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.ESTATES_VIEW),
    (0, swagger_1.ApiOperation)({ summary: 'List all estates', description: 'Lists all estates for super-admin operations.' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Estates returned.', schema: { example: [{ id: swagger_docs_1.ESTATE_ID_EXAMPLE, name: 'GreenPark Estate', location: 'Lagos, Nigeria' }] } }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listEstates", null);
__decorate([
    (0, common_1.Get)('estate-signups'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.ESTATE_SIGNUPS_VIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'List estate admin signup leads',
        description: 'Lists estate-admin lead records by signup status for super-admin review.'
    }),
    (0, swagger_1.ApiQuery)({ name: 'status', required: false, example: 'PENDING_APPROVAL' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Estate signup leads returned.',
        schema: {
            example: [
                {
                    id: swagger_docs_1.ESTATE_ID_EXAMPLE,
                    name: 'GreenPark Estate',
                    unitCount: 120,
                    estateType: 'Residential gated community',
                    status: 'PENDING',
                    signupStatus: 'PENDING_APPROVAL'
                }
            ]
        }
    }),
    __param(0, (0, common_1.Query)('status')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listEstateSignups", null);
__decorate([
    (0, common_1.Patch)('estate-signups/:estateId/review'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.ESTATE_SIGNUPS_REVIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'Review estate admin signup',
        description: 'Approves, rejects, or suspends an estate-admin signup lead. Approval allows plan selection, but app access remains disabled until payment confirmation.'
    }),
    (0, swagger_1.ApiParam)({ name: 'estateId', example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.ReviewEstateSignupDto }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Estate signup reviewed.',
        schema: { example: { id: swagger_docs_1.ESTATE_ID_EXAMPLE, signupStatus: 'APPROVED', status: 'PENDING' } }
    }),
    __param(0, (0, common_1.Param)('estateId')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.ReviewEstateSignupDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "reviewEstateSignup", null);
__decorate([
    (0, common_1.Patch)('estate-signups/:estateId/confirm-payment'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.PAYMENTS_CONFIRM),
    (0, swagger_1.ApiOperation)({
        summary: 'Confirm estate payment and activate estate',
        description: 'Confirms the latest pending payment, verifies hosted checkout payments against the provider sandbox, activates the estate, activates the estate admin account, and enables normal app access.'
    }),
    (0, swagger_1.ApiParam)({ name: 'estateId', example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.ConfirmEstatePaymentDto }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Payment confirmed and estate activated.',
        schema: {
            example: {
                estate: { id: swagger_docs_1.ESTATE_ID_EXAMPLE, status: 'ACTIVE', subscriptionStatus: 'ACTIVE' },
                payment: { id: 'payment-uuid', status: 'CONFIRMED' }
            }
        }
    }),
    __param(0, (0, common_1.Param)('estateId')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.ConfirmEstatePaymentDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "confirmEstatePayment", null);
__decorate([
    (0, common_1.Get)('subscription-plans'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.SUBSCRIPTION_PLANS_VIEW),
    (0, swagger_1.ApiOperation)({ summary: 'List subscription plans', description: 'Lists plan definitions and prices for super-admin management.' }),
    (0, swagger_1.ApiQuery)({ name: 'includeInactive', required: false, example: 'true' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Plans returned.',
        schema: {
            example: [{ code: 'STARTER', name: 'GateWise Starter', minResidents: 0, maxResidents: 100, monthlyPriceKobo: 20000000 }]
        }
    }),
    __param(0, (0, common_1.Query)('includeInactive')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listSubscriptionPlans", null);
__decorate([
    (0, common_1.Post)('subscription-plans'),
    (0, swagger_1.ApiOperation)({
        summary: 'Create subscription plan',
        description: 'Creates a super-admin-owned subscription plan with its allowed feature list. Estate admins cannot enable resident or guard features outside their estate plan.'
    }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.CreateSubscriptionPlanDto }),
    (0, swagger_1.ApiResponse)({ status: 201, description: 'Plan created.', schema: { example: { code: 'CUSTOM_LUXURY', features: ['CHECKIN_SCAN'] } } }),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [admin_dto_1.CreateSubscriptionPlanDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "createSubscriptionPlan", null);
__decorate([
    (0, common_1.Get)('otp/config'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.OTP_PROVIDERS_MANAGE),
    (0, swagger_1.ApiOperation)({
        summary: 'View OTP delivery configuration',
        description: 'Shows the active OTP provider, OTP expiry policy, and whether Termii, Africa\'s Talking, or a custom HTTP SMS endpoint is configured. Secrets are never returned.'
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'OTP configuration returned.',
        schema: {
            example: {
                provider: 'DEV',
                enabledProviders: ['DEV'],
                providerPriority: ['DEV'],
                availableProviders: ['DEV', 'TERMII', 'AFRICAS_TALKING', 'CUSTOM_HTTP'],
                providers: [
                    { provider: 'DEV', enabled: true, priority: 1, configured: true, activePrimary: true },
                    { provider: 'TERMII', enabled: false, priority: null, configured: false, activePrimary: false }
                ],
                codeLength: 6,
                expiresInSeconds: 300,
                maxAttempts: 5,
                devOtpExposed: true,
                termii: { configured: false, baseUrl: 'https://api.ng.termii.com', senderId: 'SmartEstate', channel: 'dnd' },
                africasTalking: { configured: false, baseUrl: 'https://api.africastalking.com/version1/messaging', username: 'sandbox' },
                customHttp: { configured: false, url: '', method: 'POST', hasHeaders: false, hasBodyTemplate: false }
            }
        }
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "getOtpConfig", null);
__decorate([
    (0, common_1.Patch)('otp/config'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.OTP_PROVIDERS_MANAGE),
    (0, swagger_1.ApiOperation)({
        summary: 'Update OTP delivery configuration',
        description: 'Switches OTP delivery between DEV, Termii, Africa\'s Talking, and a custom HTTP SMS endpoint at runtime. Super admins can enable or disable providers and define fallback priority. Runtime changes are in-memory; copy stable values into .env for production.'
    }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateOtpConfigDto }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'OTP configuration updated. Secrets are not returned.',
        schema: {
            example: {
                provider: 'TERMII',
                enabledProviders: ['TERMII', 'AFRICAS_TALKING'],
                providerPriority: ['TERMII', 'AFRICAS_TALKING'],
                expiresInSeconds: 300,
                termii: { configured: true, channel: 'dnd' }
            }
        }
    }),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [admin_dto_1.UpdateOtpConfigDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateOtpConfig", null);
__decorate([
    (0, common_1.Get)('integrations/templates'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.INTEGRATIONS_MANAGE),
    (0, swagger_1.ApiOperation)({
        summary: 'List third-party integration templates',
        description: 'Returns known payment, SMS, and email providers with public and secret key names so a super-admin UI can render update forms.'
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Integration templates returned.',
        schema: {
            example: [
                {
                    category: 'PAYMENT',
                    provider: 'FLUTTERWAVE',
                    displayName: 'Flutterwave',
                    publicKeys: ['baseUrl', 'publicKey'],
                    secretKeys: ['secretKey', 'encryptionKey']
                }
            ]
        }
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listIntegrationTemplates", null);
__decorate([
    (0, common_1.Get)('integrations/config'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.INTEGRATIONS_MANAGE),
    (0, swagger_1.ApiOperation)({
        summary: 'List third-party integration configuration',
        description: 'Lists configured payment gateways, SMS providers, and email providers. Secret values are never returned; each secret key only reports configured status and a masked suffix.'
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Integration configuration returned.',
        schema: {
            example: [
                {
                    category: 'PAYMENT',
                    provider: 'PAYSTACK',
                    displayName: 'Paystack',
                    enabled: true,
                    configured: true,
                    publicConfig: { baseUrl: 'https://api.paystack.co', publicKey: 'pk_live_xxx' },
                    secrets: { secretKey: { configured: true, masked: '****abcd' } }
                }
            ]
        }
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listIntegrationConfigs", null);
__decorate([
    (0, common_1.Get)('integrations/config/:provider'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.INTEGRATIONS_MANAGE),
    (0, swagger_1.ApiOperation)({
        summary: 'View one third-party integration configuration',
        description: 'Returns sanitized config for one provider. Secrets are masked and never returned in full.'
    }),
    (0, swagger_1.ApiParam)({ name: 'provider', example: 'FLUTTERWAVE' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Integration configuration returned.' }),
    __param(0, (0, common_1.Param)('provider')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "getIntegrationConfig", null);
__decorate([
    (0, common_1.Patch)('integrations/config/:provider'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.INTEGRATIONS_MANAGE),
    (0, swagger_1.ApiOperation)({
        summary: 'Update third-party integration keys',
        description: 'Creates or updates payment gateway, SMS provider, email provider, or custom integration keys. publicConfig is readable by super admins; secretConfig is encrypted at rest and write-only. Updates take effect immediately for payment and OTP providers without redeploying.'
    }),
    (0, swagger_1.ApiParam)({ name: 'provider', example: 'FLUTTERWAVE' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateIntegrationConfigDto }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Integration configuration updated. Secrets are not returned.',
        schema: {
            example: {
                category: 'PAYMENT',
                provider: 'FLUTTERWAVE',
                enabled: true,
                configured: true,
                publicConfig: { baseUrl: 'https://api.flutterwave.com/v3' },
                secrets: { secretKey: { configured: true, masked: '****abcd' } }
            }
        }
    }),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('provider')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateIntegrationConfigDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateIntegrationConfig", null);
__decorate([
    (0, common_1.Patch)('subscription-plans/:code'),
    (0, swagger_1.ApiOperation)({ summary: 'Update subscription plan', description: 'Updates subscription plan pricing, resident ranges, or availability.' }),
    (0, swagger_1.ApiParam)({ name: 'code', example: 'STARTER' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateSubscriptionPlanDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Plan updated.', schema: { example: { code: 'STARTER', monthlyPriceKobo: 20000000 } } }),
    __param(0, (0, common_1.Param)('code')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateSubscriptionPlanDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateSubscriptionPlan", null);
__decorate([
    (0, common_1.Get)('payment-providers'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.PAYMENT_PROVIDERS_VIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'List payment provider settings',
        description: 'Lists global provider settings and effective estate overrides when estateId is supplied.'
    }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Payment providers returned.',
        schema: {
            example: [
                {
                    provider: 'FLUTTERWAVE',
                    displayName: 'Flutterwave',
                    globallyEnabled: true,
                    estateEnabled: null,
                    effectiveEnabled: true,
                    sandboxMode: 'sandbox',
                    sandboxConfigured: true,
                    sandboxBaseUrl: 'https://api.flutterwave.com/v3'
                }
            ]
        }
    }),
    __param(0, (0, common_1.Query)('estateId')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listPaymentProviders", null);
__decorate([
    (0, common_1.Patch)('payment-providers/:provider'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.PAYMENT_PROVIDERS_MANAGE),
    (0, swagger_1.ApiOperation)({ summary: 'Toggle global payment provider', description: 'Enables or disables a payment provider globally.' }),
    (0, swagger_1.ApiParam)({ name: 'provider', enum: client_1.PaymentProvider, example: client_1.PaymentProvider.FLUTTERWAVE }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdatePaymentProviderSettingDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Global provider setting updated.', schema: { example: { provider: 'FLUTTERWAVE', enabled: true } } }),
    __param(0, (0, common_1.Param)('provider')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdatePaymentProviderSettingDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateGlobalPaymentProvider", null);
__decorate([
    (0, common_1.Patch)('estates/:estateId/payment-providers/:provider'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.PAYMENT_PROVIDERS_MANAGE),
    (0, swagger_1.ApiOperation)({
        summary: 'Toggle estate payment provider override',
        description: 'Enables or disables a provider for one estate, overriding the global setting.'
    }),
    (0, swagger_1.ApiParam)({ name: 'estateId', example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiParam)({ name: 'provider', enum: client_1.PaymentProvider, example: client_1.PaymentProvider.PAYSTACK }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdatePaymentProviderSettingDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Estate provider override updated.', schema: { example: { estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, provider: 'PAYSTACK', enabled: true } } }),
    __param(0, (0, common_1.Param)('estateId')),
    __param(1, (0, common_1.Param)('provider')),
    __param(2, (0, common_1.Body)()),
    __param(3, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, admin_dto_1.UpdatePaymentProviderSettingDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateEstatePaymentProvider", null);
__decorate([
    (0, common_1.Get)('sales-partners'),
    (0, swagger_1.ApiOperation)({
        summary: 'List sales admins and partner status',
        description: 'Super-admin-only list of sales admins, partner earning status, commission percentage, and assigned estates.'
    }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Sales partner profiles returned.' }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listSalesPartners", null);
__decorate([
    (0, common_1.Get)('sales-partners/me'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.SALES_PARTNER_PROFILE_VIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'View my sales partner profile',
        description: 'Returns the signed-in sales admin profile. profileLabel is Partner only when super admin has activated partner earnings.'
    }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Partner profile returned.' }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "getMySalesPartnerProfile", null);
__decorate([
    (0, common_1.Get)('sales-partners/me/earnings'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.SALES_PARTNER_EARNINGS_VIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'View my partner earnings',
        description: 'Returns estimated commission for confirmed payments on estates assigned to the signed-in sales admin.'
    }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Partner earnings returned.' }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "getMySalesPartnerEarnings", null);
__decorate([
    (0, common_1.Get)('sales-partners/:salesAdminId/earnings'),
    (0, swagger_1.ApiOperation)({
        summary: 'View sales partner earnings',
        description: 'Super-admin-only earnings view for a sales admin partner profile.'
    }),
    (0, swagger_1.ApiParam)({ name: 'salesAdminId', example: swagger_docs_1.USER_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Partner earnings returned.' }),
    __param(0, (0, common_1.Param)('salesAdminId')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "getSalesPartnerEarnings", null);
__decorate([
    (0, common_1.Patch)('sales-partners/:salesAdminId'),
    (0, swagger_1.ApiOperation)({
        summary: 'Update sales partner earnings',
        description: 'Super-admin-only control for enabling partner status and setting commission percentage for a sales admin. Enabling this makes the profileLabel return Partner.'
    }),
    (0, swagger_1.ApiParam)({ name: 'salesAdminId', example: swagger_docs_1.USER_ID_EXAMPLE }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateSalesPartnerProfileDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Sales partner profile updated.' }),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('salesAdminId')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateSalesPartnerProfileDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateSalesPartnerProfile", null);
__decorate([
    (0, common_1.Patch)('estates/:id/sales-partner'),
    (0, swagger_1.ApiOperation)({
        summary: 'Assign estate to sales partner',
        description: 'Super-admin-only assignment of an estate to a sales admin. Sales admins can access only estates assigned to them.'
    }),
    (0, swagger_1.ApiParam)({ name: 'id', example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.AssignEstatePartnerDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Estate partner assignment updated.' }),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.AssignEstatePartnerDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "assignEstateSalesPartner", null);
__decorate([
    (0, common_1.Post)('estates/:estateId/admin-contact'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.SALES_PARTNER_ADMIN_CONTACT),
    (0, swagger_1.ApiOperation)({
        summary: 'Contact assigned estate admins',
        description: 'Queues or records a sales partner message to estate admins. Sales admins can contact only admins for estates assigned to them.'
    }),
    (0, swagger_1.ApiParam)({ name: 'estateId', example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.ContactEstateAdminDto }),
    (0, swagger_1.ApiResponse)({ status: 201, description: 'Contact request queued.' }),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('estateId')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.ContactEstateAdminDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "contactEstateAdmin", null);
__decorate([
    (0, common_1.Patch)('estates/:id'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.ESTATES_MANAGE),
    (0, swagger_1.ApiOperation)({ summary: 'Update estate', description: 'Updates estate details, settings, and branding JSON.' }),
    (0, swagger_1.ApiParam)({ name: 'id', example: swagger_docs_1.ESTATE_ID_EXAMPLE, description: 'Estate ID to update.' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateEstateDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Estate updated.', schema: { example: { id: swagger_docs_1.ESTATE_ID_EXAMPLE, name: 'GreenPark Estate', location: 'Lagos, Nigeria' } } }),
    (0, swagger_docs_1.ApiNotFoundError)('Estate'),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateEstateDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateEstate", null);
__decorate([
    (0, common_1.Get)('residents'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.RESIDENTS_VIEW),
    (0, swagger_1.ApiOperation)({ summary: 'List residents', description: 'Lists residents across the platform or within a single estate.' }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Residents returned.', schema: { example: [{ id: swagger_docs_1.RESIDENT_ID_EXAMPLE, estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, name: 'Ade Okafor', unit: 'A12', status: 'ACTIVE' }] } }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)('estateId')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listResidents", null);
__decorate([
    (0, common_1.Patch)('residents/:id'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.RESIDENTS_MANAGE),
    (0, swagger_1.ApiOperation)({ summary: 'Update resident', description: 'Updates resident profile fields and synchronized user fields.' }),
    (0, swagger_1.ApiParam)({ name: 'id', example: swagger_docs_1.RESIDENT_ID_EXAMPLE, description: 'Resident ID to update.' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateResidentDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Resident updated.', schema: { example: { id: swagger_docs_1.RESIDENT_ID_EXAMPLE, unit: 'B14', status: 'ACTIVE' } } }),
    (0, swagger_docs_1.ApiNotFoundError)('Resident'),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateResidentDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateResident", null);
__decorate([
    (0, common_1.Get)('guards'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.GUARDS_VIEW),
    (0, swagger_1.ApiOperation)({ summary: 'List guards', description: 'Lists guards across the platform or within a single estate.' }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Guards returned.', schema: { example: [{ id: swagger_docs_1.GUARD_ID_EXAMPLE, estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, name: 'Main Gate Guard', deviceId: 'guard-device-001', status: 'ACTIVE' }] } }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)('estateId')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listGuards", null);
__decorate([
    (0, common_1.Patch)('guards/:id'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.GUARDS_MANAGE),
    (0, swagger_1.ApiOperation)({ summary: 'Update guard', description: 'Updates guard profile fields and synchronized user fields.' }),
    (0, swagger_1.ApiParam)({ name: 'id', example: swagger_docs_1.GUARD_ID_EXAMPLE, description: 'Guard ID to update.' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateGuardDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Guard updated.', schema: { example: { id: swagger_docs_1.GUARD_ID_EXAMPLE, deviceId: 'guard-device-002', status: 'ACTIVE' } } }),
    (0, swagger_docs_1.ApiNotFoundError)('Guard'),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateGuardDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateGuard", null);
__decorate([
    (0, common_1.Get)('visitors'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.VISITORS_VIEW),
    (0, swagger_1.ApiOperation)({ summary: 'List visitors', description: 'Lists estate-scoped visitor records across the platform or within a single estate.' }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Visitors returned.', schema: { example: [{ id: swagger_docs_1.VISITOR_ID_EXAMPLE, estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, name: 'Ade Okafor', vehiclePlate: 'LND-123-AB' }] } }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)('estateId')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listVisitors", null);
__decorate([
    (0, common_1.Patch)('visitors/:id'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.VISITORS_MANAGE),
    (0, swagger_1.ApiOperation)({ summary: 'Update visitor', description: 'Updates visitor identity, vehicle, photo, or estate assignment.' }),
    (0, swagger_1.ApiParam)({ name: 'id', example: swagger_docs_1.VISITOR_ID_EXAMPLE, description: 'Visitor ID to update.' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateVisitorDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Visitor updated.', schema: { example: { id: swagger_docs_1.VISITOR_ID_EXAMPLE, name: 'Ade Okafor', vehiclePlate: 'LND-123-AB' } } }),
    (0, swagger_docs_1.ApiNotFoundError)('Visitor'),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateVisitorDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateVisitor", null);
__decorate([
    (0, common_1.Get)('visitor-passes'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.VISITOR_PASSES_VIEW),
    (0, swagger_1.ApiOperation)({ summary: 'List visitor passes', description: 'Lists visitor passes with optional estate and status filters.' }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiQuery)({ name: 'status', required: false, example: 'ACTIVE' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Visitor passes returned.', schema: { example: [{ id: swagger_docs_1.VISITOR_PASS_ID_EXAMPLE, estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, status: 'ACTIVE', passType: 'SINGLE_USE' }] } }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)('estateId')),
    __param(2, (0, common_1.Query)('status')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listVisitorPasses", null);
__decorate([
    (0, common_1.Patch)('visitor-passes/:id'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.VISITOR_PASSES_REVOKE),
    (0, swagger_1.ApiOperation)({ summary: 'Update visitor pass', description: 'Updates pass status, type, validity window, or entry counts.' }),
    (0, swagger_1.ApiParam)({ name: 'id', example: swagger_docs_1.VISITOR_PASS_ID_EXAMPLE, description: 'Visitor pass ID to update.' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateVisitorPassDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Visitor pass updated.', schema: { example: { id: swagger_docs_1.VISITOR_PASS_ID_EXAMPLE, status: 'REVOKED', revokedAt: '2026-05-16T12:00:00.000Z' } } }),
    (0, swagger_docs_1.ApiNotFoundError)('Visitor pass'),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateVisitorPassDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateVisitorPass", null);
__decorate([
    (0, common_1.Get)('visit-sessions'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.VISIT_SESSIONS_VIEW),
    (0, swagger_1.ApiOperation)({ summary: 'List visit sessions', description: 'Lists visit sessions with visitor pass and guard context.' }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Visit sessions returned.', schema: { example: [{ id: swagger_docs_1.VISIT_SESSION_ID_EXAMPLE, estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, guardId: swagger_docs_1.GUARD_ID_EXAMPLE, status: 'CHECKED_IN' }] } }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)('estateId')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listVisitSessions", null);
__decorate([
    (0, common_1.Get)('incidents'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.INCIDENTS_VIEW),
    (0, swagger_1.ApiOperation)({ summary: 'List incidents', description: 'Lists incident reports with guard and estate context.' }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Incidents returned.', schema: { example: [{ id: 'incident-uuid', estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, guardId: swagger_docs_1.GUARD_ID_EXAMPLE, type: 'SECURITY' }] } }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)('estateId')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listIncidents", null);
__decorate([
    (0, common_1.Patch)('incidents/:id'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.INCIDENTS_MANAGE),
    (0, swagger_1.ApiOperation)({ summary: 'Update incident', description: 'Updates incident assignment, type, description, or metadata.' }),
    (0, swagger_1.ApiParam)({ name: 'id', example: 'incident-uuid', description: 'Incident ID to update.' }),
    (0, swagger_1.ApiBody)({ type: admin_dto_1.UpdateIncidentDto }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Incident updated.', schema: { example: { id: 'incident-uuid', type: 'SECURITY', description: 'Updated incident description' } } }),
    (0, swagger_docs_1.ApiNotFoundError)('Incident'),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, admin_dto_1.UpdateIncidentDto, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "updateIncident", null);
__decorate([
    (0, common_1.Get)('audit-logs'),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.PLATFORM_DASHBOARD),
    (0, swagger_1.ApiOperation)({ summary: 'List audit logs', description: 'Lists recent audit logs across the platform or within a single estate.' }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Audit logs returned.', schema: { example: [{ id: 'audit-log-uuid', estateId: swagger_docs_1.ESTATE_ID_EXAMPLE, actorType: 'USER', actorId: swagger_docs_1.USER_ID_EXAMPLE, action: 'USER_SIGNED_UP' }] } }),
    __param(0, (0, common_1.Query)('estateId')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", void 0)
], AdminController.prototype, "listAuditLogs", null);
exports.AdminController = AdminController = __decorate([
    (0, swagger_1.ApiTags)('Admin'),
    (0, swagger_docs_1.ApiProtectedEndpoint)(),
    (0, common_1.Controller)({ path: 'admin', version: '1' }),
    (0, require_role_decorator_1.RequireRole)(client_1.UserRole.SUPER_ADMIN),
    __metadata("design:paramtypes", [admin_service_1.AdminService])
], AdminController);
//# sourceMappingURL=admin.controller.js.map