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



/**
 * See the [Rust documentation for `WordBreak`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html) for more information.
 */
export class WordBreak {
    #value = undefined;

    static #values = new Map([
        ["Other", 0],
        ["ALetter", 1],
        ["Format", 2],
        ["Katakana", 3],
        ["MidLetter", 4],
        ["MidNum", 5],
        ["Numeric", 6],
        ["ExtendNumLet", 7],
        ["Cr", 8],
        ["Extend", 9],
        ["Lf", 10],
        ["MidNumLet", 11],
        ["Newline", 12],
        ["RegionalIndicator", 13],
        ["HebrewLetter", 14],
        ["SingleQuote", 15],
        ["DoubleQuote", 16],
        ["EBase", 17],
        ["EBaseGaz", 18],
        ["EModifier", 19],
        ["GlueAfterZwj", 20],
        ["Zwj", 21],
        ["WSegSpace", 22]
    ]);

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

        if (value instanceof WordBreak) {
            return value;
        }

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

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

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

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

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

    /** @internal */
    get ffiValue(){
        return this.#value;
    }
    static #objectValues = [
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21),
        new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22),
    ];

    /**
     * See the [Rust documentation for `Other`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.Other) for more information.
     */
    static Other = WordBreak.#objectValues[0];
    /**
     * See the [Rust documentation for `ALetter`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.ALetter) for more information.
     */
    static ALetter = WordBreak.#objectValues[1];
    /**
     * See the [Rust documentation for `Format`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.Format) for more information.
     */
    static Format = WordBreak.#objectValues[2];
    /**
     * See the [Rust documentation for `Katakana`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.Katakana) for more information.
     */
    static Katakana = WordBreak.#objectValues[3];
    /**
     * See the [Rust documentation for `MidLetter`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.MidLetter) for more information.
     */
    static MidLetter = WordBreak.#objectValues[4];
    /**
     * See the [Rust documentation for `MidNum`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.MidNum) for more information.
     */
    static MidNum = WordBreak.#objectValues[5];
    /**
     * See the [Rust documentation for `Numeric`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.Numeric) for more information.
     */
    static Numeric = WordBreak.#objectValues[6];
    /**
     * See the [Rust documentation for `ExtendNumLet`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.ExtendNumLet) for more information.
     */
    static ExtendNumLet = WordBreak.#objectValues[7];
    /**
     * See the [Rust documentation for `CR`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.CR) for more information.
     */
    static Cr = WordBreak.#objectValues[8];
    /**
     * See the [Rust documentation for `Extend`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.Extend) for more information.
     */
    static Extend = WordBreak.#objectValues[9];
    /**
     * See the [Rust documentation for `LF`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.LF) for more information.
     */
    static Lf = WordBreak.#objectValues[10];
    /**
     * See the [Rust documentation for `MidNumLet`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.MidNumLet) for more information.
     */
    static MidNumLet = WordBreak.#objectValues[11];
    /**
     * See the [Rust documentation for `Newline`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.Newline) for more information.
     */
    static Newline = WordBreak.#objectValues[12];
    /**
     * See the [Rust documentation for `RegionalIndicator`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.RegionalIndicator) for more information.
     */
    static RegionalIndicator = WordBreak.#objectValues[13];
    /**
     * See the [Rust documentation for `HebrewLetter`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.HebrewLetter) for more information.
     */
    static HebrewLetter = WordBreak.#objectValues[14];
    /**
     * See the [Rust documentation for `SingleQuote`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.SingleQuote) for more information.
     */
    static SingleQuote = WordBreak.#objectValues[15];
    /**
     * See the [Rust documentation for `DoubleQuote`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.DoubleQuote) for more information.
     */
    static DoubleQuote = WordBreak.#objectValues[16];
    /**
     * See the [Rust documentation for `EBase`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.EBase) for more information.
     */
    static EBase = WordBreak.#objectValues[17];
    /**
     * See the [Rust documentation for `EBaseGAZ`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.EBaseGAZ) for more information.
     */
    static EBaseGaz = WordBreak.#objectValues[18];
    /**
     * See the [Rust documentation for `EModifier`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.EModifier) for more information.
     */
    static EModifier = WordBreak.#objectValues[19];
    /**
     * See the [Rust documentation for `GlueAfterZwj`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.GlueAfterZwj) for more information.
     */
    static GlueAfterZwj = WordBreak.#objectValues[20];
    /**
     * See the [Rust documentation for `ZWJ`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.ZWJ) for more information.
     */
    static Zwj = WordBreak.#objectValues[21];
    /**
     * See the [Rust documentation for `WSegSpace`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#associatedconstant.WSegSpace) for more information.
     */
    static WSegSpace = WordBreak.#objectValues[22];


    /**
     * See the [Rust documentation for `for_char`](https://docs.rs/icu/2.2.0/icu/properties/props/trait.EnumeratedProperty.html#tymethod.for_char) for more information.
     */
    static forChar(ch) {

        const result = wasm.icu4x_WordBreak_for_char_mv1(ch);

        try {
            return new WordBreak(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * Get the "long" name of this property value (returns empty if property value is unknown)
     *
     * See the [Rust documentation for `get`](https://docs.rs/icu/2.2.0/icu/properties/struct.PropertyNamesLongBorrowed.html#method.get) for more information.
     */
    longName() {
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);


        const result = wasm.icu4x_WordBreak_long_name_mv1(diplomatReceive.buffer, this.ffiValue);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer,  "string8", []).getValue();
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            diplomatReceive.free();
        }
    }

    /**
     * Get the "short" name of this property value (returns empty if property value is unknown)
     *
     * See the [Rust documentation for `get`](https://docs.rs/icu/2.2.0/icu/properties/struct.PropertyNamesShortBorrowed.html#method.get) for more information.
     */
    shortName() {
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);


        const result = wasm.icu4x_WordBreak_short_name_mv1(diplomatReceive.buffer, this.ffiValue);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer,  "string8", []).getValue();
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            diplomatReceive.free();
        }
    }

    /**
     * Convert to an integer value usable with ICU4C and `CodePointMapData`
     *
     * See the [Rust documentation for `to_icu4c_value`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#method.to_icu4c_value) for more information.
     */
    toIntegerValue() {

        const result = wasm.icu4x_WordBreak_to_integer_value_mv1(this.ffiValue);

        try {
            return result;
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * Convert from an integer value from ICU4C or `CodePointMapData`
     *
     * See the [Rust documentation for `from_icu4c_value`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.WordBreak.html#method.from_icu4c_value) for more information.
     */
    static fromIntegerValue(other) {
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);


        const result = wasm.icu4x_WordBreak_from_integer_value_mv1(diplomatReceive.buffer, other);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            diplomatReceive.free();
        }
    }

    static tryFromStr(s) {
        let functionCleanupArena = new diplomatRuntime.CleanupArena();

        const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, s)));
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);


        const result = wasm.icu4x_WordBreak_try_from_str_mv1(diplomatReceive.buffer, sSlice.ptr);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new WordBreak(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            functionCleanupArena.free();

            diplomatReceive.free();
        }
    }

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