"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveEstateScope = resolveEstateScope;
const common_1 = require("@nestjs/common");
const client_1 = require("@prisma/client");
function resolveEstateScope(user, estateId) {
    if (user.role === client_1.UserRole.SUPER_ADMIN) {
        if (!estateId) {
            throw new common_1.ForbiddenException('estateId is required for super admin requests');
        }
        return estateId;
    }
    if (!user.estateId || (estateId && estateId !== user.estateId)) {
        throw new common_1.ForbiddenException('Cross-estate access is not allowed');
    }
    return user.estateId;
}
//# sourceMappingURL=estate-scope.js.map