1declare namespace Intl {
2
3    /**
4     * An object with some or all properties of the `Intl.Segmenter` constructor `options` parameter.
5     *
6     * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters)
7     */
8    interface SegmenterOptions {
9        /** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */
10        localeMatcher?: "best fit" | "lookup" | undefined;
11        /** The type of input to be split */
12        granularity?: "grapheme" | "word" | "sentence" | undefined;
13    }
14
15    interface Segmenter {
16        /**
17         * Returns `Segments` object containing the segments of the input string, using the segmenter's locale and granularity.
18         *
19         * @param input - The text to be segmented as a `string`.
20         *
21         * @returns A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity.
22         */
23        segment(input: string): Segments;
24        resolvedOptions(): ResolvedSegmenterOptions;
25    }
26
27    interface ResolvedSegmenterOptions {
28        locale: string;
29        granularity: "grapheme" | "word" | "sentence";
30    }
31
32    interface Segments {
33        /**
34         * Returns an object describing the segment in the original string that includes the code unit at a specified index.
35         *
36         * @param codeUnitIndex - A number specifying the index of the code unit in the original input string. If the value is omitted, it defaults to `0`.
37         */
38        containing(codeUnitIndex?: number): SegmentData;
39
40        /** Returns an iterator to iterate over the segments. */
41        [Symbol.iterator](): IterableIterator<SegmentData>;
42    }
43
44    interface SegmentData {
45        /** A string containing the segment extracted from the original input string. */
46        segment: string;
47        /** The code unit index in the original input string at which the segment begins. */
48        index: number;
49        /** The complete input string that was segmented. */
50        input: string;
51        /**
52         * A boolean value only if granularity is "word"; otherwise, undefined.
53         * If granularity is "word", then isWordLike is true when the segment is word-like (i.e., consists of letters/numbers/ideographs/etc.); otherwise, false.
54         */
55        isWordLike?: boolean;
56    }
57
58    const Segmenter: {
59        prototype: Segmenter;
60
61        /**
62         * Creates a new `Intl.Segmenter` object.
63         *
64         * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
65         *  For the general form and interpretation of the `locales` argument,
66         *  see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
67         *
68         * @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters)
69         *  with some or all options of `SegmenterOptions`.
70         *
71         * @returns [Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments) object.
72         *
73         * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter).
74         */
75        new(locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: SegmenterOptions): Segmenter;
76
77        /**
78         * Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
79         *
80         * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
81         *  For the general form and interpretation of the `locales` argument,
82         *  see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
83         *
84         * @param options An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf#parameters).
85         *  with some or all possible options.
86         *
87         * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
88         */
89        supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<SegmenterOptions, "localeMatcher">): BCP47LanguageTag[];
90    };
91}
92