"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Optimizer_1 = require("./backend/Optimizer");
const manifest_json_1 = __importDefault(require("./manifest.json"));
const plugin = {
    manifest: manifest_json_1.default,
    async activate(ctx) {
        // Register for the upload:transform hook
        ctx.hooks.register('upload:transform', async (payload) => {
            const { buffer, mimetype, category } = payload;
            // Only process common image formats
            const imageTypes = ['image/jpeg', 'image/png', 'image/webp', 'image/avif'];
            if (!imageTypes.includes(mimetype)) {
                return null; // Skip non-images
            }
            ctx.logger.info(`[SmartVision] Optimizing image for category: ${category}`);
            const result = await Optimizer_1.ImageOptimizer.optimize(buffer, category);
            return {
                buffer: result.buffer,
                mimetype: result.mimetype
            };
        });
        ctx.logger.info('SmartVision Optimizer activated');
    },
    async deactivate(ctx) {
        ctx.logger.info('SmartVision Optimizer deactivated');
    }
};
exports.default = plugin;
//# sourceMappingURL=index.js.map