// SPDX-FileCopyrightText: 2026 Marco Allegretti
// SPDX-License-Identifier: EUPL-1.2

import QtQuick

import org.kde.kirigami as Kirigami
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings

pragma Singleton

QtObject {
    id: root

    enum Type {
        Press,
        Standard,
        StandardAccel,
        StandardDecel,
        Emphasized,
        EmphasizedAccel,
        EmphasizedDecel,
        SpatialFast,
        SpatialDefault,
        SpatialSlow,
        SpatialExtended,
        SpatialVerySlow,
        EffectsFast,
        EffectsDefault,
        EffectsSlow
    }

    readonly property bool enabled: ShellSettings.Settings.animationsEnabled

    readonly property int pressDuration: enabled ? Math.round(Kirigami.Units.shortDuration / 2) : 0
    readonly property int standardDuration: enabled ? Kirigami.Units.longDuration : 0
    readonly property int emphasizedDuration: enabled ? Kirigami.Units.longDuration + Kirigami.Units.shortDuration : 0
    readonly property int spatialFastDuration: enabled ? Kirigami.Units.shortDuration : 0
    readonly property int spatialDefaultDuration: enabled ? Kirigami.Units.longDuration : 0
    readonly property int spatialSlowDuration: enabled ? Kirigami.Units.veryLongDuration : 0
    readonly property int spatialExtendedDuration: enabled ? Kirigami.Units.longDuration * 2 : 0
    readonly property int spatialVerySlowDuration: enabled ? Kirigami.Units.longDuration * 4 : 0
    readonly property int effectsFastDuration: enabled ? Kirigami.Units.shortDuration : 0
    readonly property int effectsDefaultDuration: enabled ? Kirigami.Units.longDuration : 0
    readonly property int effectsSlowDuration: enabled ? Kirigami.Units.veryLongDuration : 0

    readonly property real pressScaleIn: enabled ? 0.94 : 1
    readonly property real pressScaleOut: enabled ? 1.08 : 1
    readonly property real previewPressScale: enabled ? 0.95 : 1
    readonly property real hiddenScale: enabled ? 0.72 : 1
    readonly property real closeScaleOut: enabled ? 0.9 : 1

    function duration(type: int): int {
        switch (type) {
        case Motion.Press:
            return pressDuration;
        case Motion.Emphasized:
        case Motion.EmphasizedAccel:
        case Motion.EmphasizedDecel:
            return emphasizedDuration;
        case Motion.SpatialFast:
            return spatialFastDuration;
        case Motion.SpatialDefault:
            return spatialDefaultDuration;
        case Motion.SpatialSlow:
            return spatialSlowDuration;
        case Motion.SpatialExtended:
            return spatialExtendedDuration;
        case Motion.SpatialVerySlow:
            return spatialVerySlowDuration;
        case Motion.EffectsFast:
            return effectsFastDuration;
        case Motion.EffectsDefault:
            return effectsDefaultDuration;
        case Motion.EffectsSlow:
            return effectsSlowDuration;
        default:
            return standardDuration;
        }
    }

    function easing(type: int): int {
        switch (type) {
        case Motion.StandardAccel:
        case Motion.EmphasizedAccel:
            return Easing.InQuart;
        case Motion.StandardDecel:
        case Motion.EmphasizedDecel:
            return Easing.OutQuart;
        case Motion.Emphasized:
            return Easing.OutQuint;
        case Motion.SpatialFast:
        case Motion.SpatialDefault:
        case Motion.SpatialSlow:
        case Motion.SpatialExtended:
        case Motion.SpatialVerySlow:
            return Easing.OutExpo;
        case Motion.Press:
        case Motion.EffectsFast:
        case Motion.EffectsDefault:
        case Motion.EffectsSlow:
            return Easing.OutCubic;
        default:
            return Easing.InOutQuad;
        }
    }
}