import { InitResp, SpinResp } from '../types/api';
import { createBetData } from './utils';

export const FreeRoundsTypes = {
    TRANSACTIONAL: 'transactional',
    CUMULATIVE: 'cumulative',
};

/** Returns current free rounds type. */
export function getFreeRoundsType(): 'transactional' | 'cumulative'
{
    return __OPTIONS__.freespinsType;
}

/** Checks if free rounds are transactional. */
export function isTransactionalFreeRounds()
{
    return getFreeRoundsType() === FreeRoundsTypes.TRANSACTIONAL;
}

/** Checks if free rounds are cumulative. */
export function isCumulativeFreeRounds()
{
    return getFreeRoundsType() === FreeRoundsTypes.CUMULATIVE;
}

/**
 * Builds bet data for casino rounds from raw response.
 * Keeps the original API (takes full rawData), but internally
 * delegates to createBetData for consistency.
 * @param rawData
 */
export function createCasinoRoundsBetData(rawData: InitResp | SpinResp)
{
    const value = Number(rawData?.free_rounds?.bet_value);
    const bet = Number.isFinite(value) ? value : 0;

    return createBetData([bet], 0, 0);
}

