// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";



/**
 * Increment used in a rounding operation.
 *
 * See the [Rust documentation for `RoundingIncrement`](https://docs.rs/fixed_decimal/0.7.2/fixed_decimal/enum.RoundingIncrement.html) for more information.
 */
export class DecimalRoundingIncrement {
    #value = undefined;

    static #values = new Map([
        ["MultiplesOf1", 0],
        ["MultiplesOf2", 1],
        ["MultiplesOf5", 2],
        ["MultiplesOf25", 3]
    ]);

    static getAllEntries() {
        return DecimalRoundingIncrement.#values.entries();
    }

    #internalConstructor(value) {
        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
            // We pass in two internalConstructor arguments to create *new*
            // instances of this type, otherwise the enums are treated as singletons.
            if (arguments[1] === diplomatRuntime.internalConstructor ) {
                this.#value = arguments[2];
                return this;
            }
            return DecimalRoundingIncrement.#objectValues[arguments[1]];
        }

        if (value instanceof DecimalRoundingIncrement) {
            return value;
        }

        let intVal = DecimalRoundingIncrement.#values.get(value);

        // Nullish check, checks for null or undefined
        if (intVal != null) {
            return DecimalRoundingIncrement.#objectValues[intVal];
        }

        throw TypeError(value + " is not a DecimalRoundingIncrement and does not correspond to any of its enumerator values.");
    }

    /** @internal */
    static fromValue(value) {
        return new DecimalRoundingIncrement(value);
    }

    get value(){
        return [...DecimalRoundingIncrement.#values.keys()][this.#value];
    }

    /** @internal */
    get ffiValue(){
        return this.#value;
    }
    static #objectValues = [
        new DecimalRoundingIncrement(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
        new DecimalRoundingIncrement(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
        new DecimalRoundingIncrement(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
        new DecimalRoundingIncrement(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
    ];

    static MultiplesOf1 = DecimalRoundingIncrement.#objectValues[0];
    static MultiplesOf2 = DecimalRoundingIncrement.#objectValues[1];
    static MultiplesOf5 = DecimalRoundingIncrement.#objectValues[2];
    static MultiplesOf25 = DecimalRoundingIncrement.#objectValues[3];


    constructor(value) {
        return this.#internalConstructor(...arguments)
    }
}