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



/**
 * ECMA-402 compatible sign display preference.
 *
 * See the [Rust documentation for `SignDisplay`](https://docs.rs/fixed_decimal/0.7.2/fixed_decimal/enum.SignDisplay.html) for more information.
 */
export class DecimalSignDisplay {
    #value = undefined;

    static #values = new Map([
        ["Auto", 0],
        ["Never", 1],
        ["Always", 2],
        ["ExceptZero", 3],
        ["Negative", 4]
    ]);

    static getAllEntries() {
        return DecimalSignDisplay.#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 DecimalSignDisplay.#objectValues[arguments[1]];
        }

        if (value instanceof DecimalSignDisplay) {
            return value;
        }

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

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

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

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

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

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

    static Auto = DecimalSignDisplay.#objectValues[0];
    static Never = DecimalSignDisplay.#objectValues[1];
    static Always = DecimalSignDisplay.#objectValues[2];
    static ExceptZero = DecimalSignDisplay.#objectValues[3];
    static Negative = DecimalSignDisplay.#objectValues[4];


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