The text to split; whitespace is not trimmed.
Maximum chunk length in UTF-16 code units (positive safe integer).
Literal split points in priority order (default: ['\n', ' ', '.']).
The raw prefix length, including its separator, or 0 for empty text.
Returns the whole length if the text already fits. Otherwise, falls back to the
largest prefix within the limit that does not split a surrogate pair.
With max_length equal to 1, an initial non-BMP code point returns 2.
This is code-point safety, not grapheme safety: combining marks and ZWJ sequences
can still be separated. The returned length may exceed the trimmed chunk's length.
Calculates the optimal length for the next text chunk.
For text exceeding the limit, uses the rightmost eligible occurrence of the first matching separator. Its start must be at least
Math.floor(max_length / 2), and its end must fit within the limit at a code-point boundary.