import type Currency from '../models/Currency';

export type FeatureMultipliers = Record<string, number> & {
    bonusChance: number;
};

export interface CasinoRoundsIndicatorData
{
    issued: number;
    left: number;
}

export interface BonusIndicatorData extends CasinoRoundsIndicatorData
{
    title: string;
}

export interface ModeView
{
    lines: unknown;
    gameData: unknown;
    bonusIndicatorData: BonusIndicatorData;
    casinoRoundsIndicatorData: CasinoRoundsIndicatorData;
    isRoundStarted(): boolean;
    isCasinoRoundsMode(): boolean;
    isBonusMode(): boolean;
}

export interface PaytableDescriptor
{
    symbols: readonly string[];
    scatterSymbols: readonly string[];
    wildSymbols: readonly string[];
    betDivider: number;
    get(symbol: string): number[];
}

/** Threshold configuration for auto-game guards. */
export interface AutoGameThreshold
{
    enabled: boolean;
    threshold: number;
}

/** Advanced auto-game settings toggled by the HUD. */
export interface AutoGameAdvancedSettings
{
    anyWin: boolean;
    bonusGameWon: boolean;
    singleWin: AutoGameThreshold;
    balanceIncrease: AutoGameThreshold;
    balanceDecrease: AutoGameThreshold;
}

/** Payload forwarded to the model when auto-game is configured. */
export interface AutoGameSettingsPayload
{
    issued: number | string;
    startingBalance: number;
    advanced: Partial<AutoGameAdvancedSettings>;
}

/** Single bet option presented in bet pickers. */
export interface BetOption
{
    value: string;
    selected: boolean;
    available: boolean;
}

/** Contract consumed by UI view models to interact with the slot model. */
export interface SlotModel
{
    title?: string;
    balance: number;
    bet: number;
    bets: number[];
    betFeatureActive: boolean;
    featureMultipliers: FeatureMultipliers;
    currency: Currency;
    win: number | null;
    totalWin: number | null;
    turboMode: boolean;
    waitingForModeSwitch: boolean;
    currentMode: ModeView;
    autoRoundsLeft: number;
    isRoundEndProcessing: boolean;
    isSpaceBarHandlingActive: boolean;
    isSkipAnimation: boolean;
    paytable: PaytableDescriptor;

    performSpinButtonAction(): void;
    performSpinButtonReleaseUp(): void;
    handleSpinButtonHolding(): void;
    handleSpinButtonReleasing(): void;

    canBuyBonus(): boolean;
    performBuyBonusButtonAction(): void;

    setBetByValue(value: number): void;
    decreaseBet(): void;
    increaseBet(): void;
    areBetsLocked(): boolean;
    resolveFeatureStake(value: number): number;

    canStartAutoGame(): boolean;
    isAutoGameActive(): boolean;
    stopAutoGame(): void;
    performAutoGame(settings: AutoGameSettingsPayload): void;

    isRoundStarted(): boolean;
    performEndRound(): void;
    addWinAmount(amount: number): void;
    isFastStopActive(): boolean;
    isTurboModeForced(): boolean;
    isBigWinAchieved(): boolean;

    muteAll(): void;
    unmuteAll(): void;
    isMute(): boolean;

    toggleSpaceBarHandling(): void;
    toggleMusicMute(): void;
    toggleSFXMute(): void;
    isMusicMute(): boolean;
    isSFXMute(): boolean;
    getVolume(): number;
    setVolume(value: number): void;
    saveVolume(): void;

    performHomeButtonAction(): void;
    performPaytableAction(): void;
    performRulesAction(): void;

    buyFreespins(): void;
    buyBonus(): void;
    toggleBetFeatureActive(): void;

    isAutoGameBlockedByBO(): boolean
}
