import { colorGradePixels } from "../../PostProcessPass.js";
import { createProductionPostProcessOutput } from "./ProductionPostProcessTypes.js";
export class ColorGradingPass {
    options;
    name = "production-color-grading";
    enabled;
    lastResult = null;
    constructor(options = {}) {
        this.options = options;
        this.enabled = options.enabled ?? true;
    }
    apply(input) {
        const intensity = this.enabled ? this.options.intensity ?? 1 : 0;
        const result = colorGradePixels(input.pixels, input.width, input.height, {
            contrast: this.options.contrast ?? 1 + 0.14 * intensity,
            saturation: this.options.saturation ?? 1 + 0.08 * intensity,
            vibrance: this.options.vibrance ?? 0.12 * intensity,
            vignette: this.options.vignette ?? 0.16 * intensity,
            sharpening: this.options.sharpening ?? 0.16 * intensity,
            temperature: this.options.temperature ?? 0,
            tint: this.options.tint ?? 0
        });
        this.lastResult = result;
        return createProductionPostProcessOutput(input, this.name, result.pixels, {
            changedPixels: result.changedPixels,
            vignetteDarkenedPixels: result.vignetteDarkenedPixels,
            sharpenedPixels: result.sharpenedPixels
        }, ["ColorGradingPass applies the renderer color-grade pixel kernel and mutates image pixels, not only options metadata."]);
    }
    getLastResult() {
        return this.lastResult ? { ...this.lastResult, pixels: new Uint8Array(this.lastResult.pixels), settings: { ...this.lastResult.settings } } : null;
    }
}
//# sourceMappingURL=ColorGradingPass.js.map