import type { EffectComposer } from "postprocessing";
import type { ToneMapping } from "three";
import type { EffectComposer as ThreeEffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";

/**
 * Minimal interface for a postprocessing effect as seen by the core stack.
 * Implemented by `PostProcessingEffect` in engine-components.
 */
export interface IPostProcessingEffect {
    readonly active: boolean;
    readonly enabled: boolean;
    /** When true, this effect is a tonemapping effect. The core stack uses this to detect tonemapping-only scenarios. */
    readonly isToneMapping?: boolean;
}

/**
 * Extended interface for tonemapping effects.
 * When ONLY tonemapping effects are in the stack, the core applies tonemapping
 * directly to the renderer instead of creating a full postprocessing pipeline.
 */
export interface ITonemappingEffect extends IPostProcessingEffect {
    readonly isToneMapping: true;
    /** The three.js ToneMapping enum value to apply to the renderer */
    readonly threeToneMapping: ToneMapping;
    /** The exposure value to apply to the renderer */
    readonly toneMappingExposure: number;
}

/**
 * Interface for the pipeline builder that manages the EffectComposer.
 * Implemented by `PostProcessingHandler` in engine-components.
 */
export interface IPostProcessingHandler {
    readonly composer: EffectComposer | ThreeEffectComposer | null;
    readonly hasSmaaEffect: boolean;
    multisampling: number;
    adaptivePixelRatio: boolean;

    apply(effects: IPostProcessingEffect[]): Promise<void>;
    unapply(dispose?: boolean): void;
    updateAdaptivePixelRatio(): void;
    dispose(): void;
}
