package dev.photosync.core.config;

import lombok.Builder;

/**
 * The one-line messages that appear in the bottom-left corner.
 *
 * <p>Each event is switchable on its own, because the useful setting for a
 * player running auto-capture every thirty seconds is different from the one for
 * a player who screenshots twice an hour.
 */
@Builder(toBuilder = true)
public record NotificationSettings(
        boolean enabled,
        boolean onCapture,
        boolean onUploaded,
        boolean onFailed,
        int lingerMillis) {

    public static NotificationSettings defaults() {
        return NotificationSettings.builder()
                .enabled(true)
                .onCapture(true)
                .onUploaded(true)
                .onFailed(true)
                .lingerMillis(3000)
                .build();
    }

    NotificationSettings normalized() {
        return toBuilder()
                .lingerMillis(Math.min(15_000, Math.max(500, lingerMillis)))
                .build();
    }

    public boolean shows(NotificationKind kind) {
        if (!enabled) {
            return false;
        }
        return switch (kind) {
            case CAPTURED -> onCapture;
            case UPLOADED -> onUploaded;
            case FAILED -> onFailed;
        };
    }
}
