/**
 * Adapter for rawData outcomes.
 *
 * Some games use a single outcome object (`rawData.outcome`),
 * while others use an array of outcomes (`rawData.outcomes`).
 * This view provides a unified interface to access them
 * without changing the original rawData structure, so both
 * formats remain supported.
 *
 * Usage:
 *   const view = new OutcomesView(rawData);
 *   view.list       // always returns an array of outcomes
 *   view.first      // first outcome or null
 *   view.firstBet   // bet value from the first outcome or 0
 *   view.hasAny     // boolean flag, true if at least one outcome exists
 */
export default class OutcomesView
{
    constructor(rawData)
    {
        this.raw = rawData;
    }

    /** @returns {Array} Always returns an array of outcomes */
    get list()
    {
        const { outcomes, outcome } = this.raw;

        if (Array.isArray(outcomes)) return outcomes;

        return outcome ? [outcome] : [];
    }

    /** @returns {object | null} The first outcome object or null if none exist */
    get first()
    {
        return this.list[0] ?? null;
    }

    /** @returns {number} Bet value from the first outcome or 0 if missing */
    get firstBet()
    {
        return this.first?.bet ?? 0;
    }

    /** @returns {boolean} True if there is at least one outcome */
    get hasAny()
    {
        return this.list.length > 0;
    }
}
