@visulima/string 3.0.0-alpha.9 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/LICENSE.md +68 -3
  3. package/README.md +80 -2
  4. package/dist/align-text.d.ts +35 -0
  5. package/dist/align-text.js +2 -34
  6. package/dist/case/camel-case.d.ts +17 -3
  7. package/dist/case/camel-case.js +1 -55
  8. package/dist/case/capital-case.d.ts +14 -3
  9. package/dist/case/capital-case.js +1 -47
  10. package/dist/case/constant-case.d.ts +14 -3
  11. package/dist/case/constant-case.js +1 -7
  12. package/dist/case/dot-case.d.ts +14 -3
  13. package/dist/case/dot-case.js +1 -7
  14. package/dist/case/flat-case.d.ts +12 -3
  15. package/dist/case/flat-case.js +1 -7
  16. package/dist/case/flip-case.d.ts +16 -3
  17. package/dist/case/flip-case.js +1 -82
  18. package/dist/case/identify-case.d.ts +15 -3
  19. package/dist/case/identify-case.js +1 -66
  20. package/dist/case/index.d.ts +8 -3
  21. package/dist/case/index.js +1 -20
  22. package/dist/case/kebab-case.d.ts +25 -3
  23. package/dist/case/kebab-case.js +1 -55
  24. package/dist/case/lower-first.d.ts +13 -3
  25. package/dist/case/lower-first.js +1 -9
  26. package/dist/case/no-case.d.ts +14 -3
  27. package/dist/case/no-case.js +1 -7
  28. package/dist/case/pascal-case.d.ts +17 -3
  29. package/dist/case/pascal-case.js +1 -48
  30. package/dist/case/pascal-snake-case.d.ts +14 -3
  31. package/dist/case/pascal-snake-case.js +1 -28
  32. package/dist/case/path-case.d.ts +14 -3
  33. package/dist/case/path-case.js +1 -7
  34. package/dist/case/sentence-case.d.ts +14 -3
  35. package/dist/case/sentence-case.js +1 -54
  36. package/dist/case/snake-case.d.ts +14 -3
  37. package/dist/case/snake-case.js +1 -7
  38. package/dist/case/split-by-case.d.ts +29 -3
  39. package/dist/case/split-by-case.js +1 -763
  40. package/dist/case/title-case.d.ts +12 -3
  41. package/dist/case/title-case.js +1 -40
  42. package/dist/case/train-case.d.ts +14 -3
  43. package/dist/case/train-case.js +1 -40
  44. package/dist/case/upper-first.d.ts +13 -3
  45. package/dist/case/upper-first.js +1 -9
  46. package/dist/closest-string.d.ts +32 -0
  47. package/dist/closest-string.js +1 -22
  48. package/dist/compare-similarity.d.ts +37 -0
  49. package/dist/compare-similarity.js +1 -12
  50. package/dist/count-occurrences.d.ts +9 -0
  51. package/dist/count-occurrences.js +1 -0
  52. package/dist/direction.d.ts +7 -0
  53. package/dist/direction.js +1 -0
  54. package/dist/east-asian-width.d.ts +52 -0
  55. package/dist/east-asian-width.js +1 -0
  56. package/dist/excerpt.d.ts +25 -0
  57. package/dist/excerpt.js +53 -0
  58. package/dist/get-string-truncated-width.d.ts +151 -0
  59. package/dist/get-string-truncated-width.js +1 -332
  60. package/dist/get-string-width.d.ts +58 -0
  61. package/dist/get-string-width.js +1 -5
  62. package/dist/indent.d.ts +87 -0
  63. package/dist/indent.js +1 -0
  64. package/dist/index.d.ts +12 -20
  65. package/dist/index.js +1 -44
  66. package/dist/is-fullwidth-code-point.d.ts +7 -0
  67. package/dist/is-fullwidth-code-point.js +1 -0
  68. package/dist/levenshtein.d.ts +25 -0
  69. package/dist/levenshtein.js +1 -0
  70. package/dist/native-string-types.d.ts +239 -0
  71. package/dist/outdent.d.ts +74 -0
  72. package/dist/outdent.js +1 -109
  73. package/dist/packem_shared/_isFullWidth-Dqc3MWgl.js +1 -0
  74. package/dist/packem_shared/closest-C6YDQs4m.js +1 -0
  75. package/dist/packem_shared/constants-aPzGW29R.js +1 -0
  76. package/dist/packem_shared/dedent-CPjAYUXh.js +1 -0
  77. package/dist/packem_shared/eastAsianWidth-DJV8Kqd-.js +1 -0
  78. package/dist/packem_shared/generate-cache-key-BqU1Cqwm.js +1 -0
  79. package/dist/packem_shared/indent-cz8WMI0e.js +1 -0
  80. package/dist/packem_shared/joinSegments-CaHT-45s.js +1 -0
  81. package/dist/packem_shared/lru-cache-BtMSrYQJ.js +1 -0
  82. package/dist/packem_shared/normalize-german-eszett-hNMwtGjd.js +1 -0
  83. package/dist/packem_shared/redent-ByOoJ6fN.js +1 -0
  84. package/dist/packem_shared/types.d-CmNvyl4l.d.ts +360 -0
  85. package/dist/packem_shared/types.d-fhe030jX.d.ts +402 -0
  86. package/dist/replace-string.d.ts +10 -0
  87. package/dist/replace-string.js +1 -0
  88. package/dist/slice.d.ts +42 -0
  89. package/dist/slice.js +1 -415
  90. package/dist/slugify.d.ts +10 -1
  91. package/dist/slugify.js +1 -46
  92. package/dist/test/utils.d.ts +17 -0
  93. package/dist/test/utils.js +13 -88
  94. package/dist/test/vitest.d.ts +3 -0
  95. package/dist/test/vitest.js +1 -5
  96. package/dist/transliterate.d.ts +10 -0
  97. package/dist/transliterate.js +5 -0
  98. package/dist/truncate.d.ts +43 -0
  99. package/dist/truncate.js +1 -112
  100. package/dist/utilities.d.ts +28 -2
  101. package/dist/utilities.js +1 -52
  102. package/dist/word-similarity-sort.d.ts +34 -0
  103. package/dist/word-similarity-sort.js +1 -22
  104. package/dist/word-wrap.d.ts +44 -0
  105. package/dist/word-wrap.js +8 -639
  106. package/package.json +70 -36
  107. package/dist/packem_shared/LRUCache-3r3SovvR.js +0 -46
  108. package/dist/packem_shared/closest-IHuSvnSn.js +0 -139
  109. package/dist/packem_shared/closestN-DUsjgiXb.js +0 -25
  110. package/dist/packem_shared/constants-BsZS5f0z.js +0 -95
  111. package/dist/packem_shared/countOccurrences-CS9XprQN.js +0 -22
  112. package/dist/packem_shared/direction-C9gfWWTK.js +0 -16
  113. package/dist/packem_shared/eastAsianWidthType-SD3YniiT.js +0 -20
  114. package/dist/packem_shared/excerpt-COsVNttN.js +0 -1502
  115. package/dist/packem_shared/generate-cache-key-DdayDfjV.js +0 -6
  116. package/dist/packem_shared/indent-D3DSCa6s.js +0 -33
  117. package/dist/packem_shared/isFullwidthCodePoint-IFXZxNjq.js +0 -10
  118. package/dist/packem_shared/joinSegments-CvxSgKz0.js +0 -44
  119. package/dist/packem_shared/lookup-BE8lEqy4.js +0 -104
  120. package/dist/packem_shared/lru-cache.d-BsP6kbVJ.d.ts +0 -13
  121. package/dist/packem_shared/normalize-german-eszett-4p3yKEzn.js +0 -8
  122. package/dist/packem_shared/redent-DSb1IJWn.js +0 -8
  123. package/dist/packem_shared/replaceString-Ce8X2ZQ-.js +0 -192
  124. package/dist/packem_shared/stripIndent-D_TRjxZ_.js +0 -20
  125. package/dist/packem_shared/transliterate-CKt9VK7D.js +0 -47756
  126. package/dist/packem_shared/types.d-BVNv675q.d.ts +0 -61
  127. package/dist/packem_shared/types.d-DfgbcNKh.d.ts +0 -57
@@ -1,763 +1 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- stripVTControlCharacters
22
- } = __cjs_getBuiltinModule("node:util");
23
- import { i as RE_EMOJI, s as stripEmoji, R as RE_FAST_ANSI, l as RE_CYRILLIC, m as RE_LATIN, n as RE_GREEK, o as RE_GREEK_LATIN_SPLIT, p as RE_UZBEK_LATIN_MODIFIER, q as RE_KATAKANA, r as RE_KANJI, t as RE_HIRAGANA, u as RE_HANGUL, v as RE_HEBREW, w as RE_ARABIC, x as RE_SEPARATORS, y as RE_DEVANAGARI, z as RE_BENGALI, A as RE_GUJARATI, B as RE_GURMUKHI, C as RE_KANNADA, D as RE_TAMIL, E as RE_TELUGU, F as RE_MALAYALAM, G as RE_SINHALA, H as RE_THAI, I as RE_LAO, J as RE_TIBETAN, K as RE_MYANMAR, L as RE_ETHIOPIC, M as RE_KHMER, N as RE_ORIYA } from '../packem_shared/constants-BsZS5f0z.js';
24
- import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
25
-
26
- const regexCache = new LRUCache(1e3);
27
- const RE_ESCAPE_SPECIAL = /[.*+?^${}()|[\]\\]/g;
28
- const getSeparatorsRegex = (separators) => {
29
- const key = separators.join("");
30
- if (regexCache.has(key)) {
31
- return regexCache.get(key);
32
- }
33
- const pattern = separators.map((s) => s.replaceAll(RE_ESCAPE_SPECIAL, String.raw`\$&`)).join("|");
34
- const regex = new RegExp(pattern, "g");
35
- regexCache.set(key, regex);
36
- return regex;
37
- };
38
-
39
- const splitByEmoji = (text) => {
40
- const segments = [];
41
- let lastIndex = 0;
42
- let match;
43
- RE_EMOJI.lastIndex = 0;
44
- while ((match = RE_EMOJI.exec(text)) !== null) {
45
- if (match.index > lastIndex) {
46
- segments.push(text.slice(lastIndex, match.index));
47
- }
48
- segments.push(match[0]);
49
- lastIndex = RE_EMOJI.lastIndex;
50
- }
51
- if (lastIndex < text.length) {
52
- segments.push(text.slice(lastIndex));
53
- }
54
- return segments.filter(Boolean);
55
- };
56
-
57
- const RE_SLOVENIAN_SPECIAL = /[ČŠŽĐ]/i;
58
- const isUpperCode = new Uint8Array(128);
59
- const isLowerCode = new Uint8Array(128);
60
- const isDigitCode = new Uint8Array(128);
61
- for (let index = 0; index < 128; index++) {
62
- isUpperCode[index] = index >= 65 && index <= 90 ? 1 : 0;
63
- isLowerCode[index] = index >= 97 && index <= 122 ? 1 : 0;
64
- isDigitCode[index] = index >= 48 && index <= 57 ? 1 : 0;
65
- }
66
- const isUpper = (code) => isUpperCode[code];
67
- const isLower = (code) => isLowerCode[code];
68
- const isDigit = (code) => isDigitCode[code];
69
- const handleScriptTransitions = (s, scriptDetectors, caseSensitive, locale, customSplitLogic) => {
70
- if (s.length === 0) {
71
- return [];
72
- }
73
- let hasDetectedScript = false;
74
- const detectorValues = Object.values(scriptDetectors);
75
- for (const detectorValue of detectorValues) {
76
- if (detectorValue(s[0])) {
77
- hasDetectedScript = true;
78
- break;
79
- }
80
- }
81
- if (!hasDetectedScript && !caseSensitive) {
82
- return [s];
83
- }
84
- const chars = [...s];
85
- const result = [];
86
- let currentSegment = chars[0];
87
- let previousType = "other";
88
- const scriptEntries = Object.entries(scriptDetectors);
89
- for (const scriptEntry of scriptEntries) {
90
- const [type, detector] = scriptEntry;
91
- if (detector(chars[0])) {
92
- previousType = type;
93
- break;
94
- }
95
- }
96
- let previousIsUpper = caseSensitive && locale ? chars[0] === chars[0].toLocaleUpperCase(locale) : false;
97
- for (let index = 1; index < chars.length; index++) {
98
- const char = chars[index];
99
- let currentType = "other";
100
- for (const scriptEntry of scriptEntries) {
101
- const [type, detector] = scriptEntry;
102
- if (detector(char)) {
103
- currentType = type;
104
- break;
105
- }
106
- }
107
- const isUpperCaseChar = caseSensitive && locale ? char === char.toLocaleUpperCase(locale) : false;
108
- let shouldSplit = false;
109
- if (customSplitLogic) {
110
- shouldSplit = customSplitLogic(previousType, currentType, previousIsUpper, isUpperCaseChar, char, index, chars);
111
- } else {
112
- if (previousType !== currentType && previousType !== "other" && currentType !== "other") {
113
- shouldSplit = true;
114
- }
115
- if (caseSensitive && currentType !== "other" && !previousIsUpper && isUpperCaseChar) {
116
- shouldSplit = true;
117
- }
118
- }
119
- if (shouldSplit) {
120
- result.push(currentSegment);
121
- currentSegment = char;
122
- } else {
123
- currentSegment += char;
124
- }
125
- previousType = currentType;
126
- if (caseSensitive) {
127
- previousIsUpper = isUpperCaseChar;
128
- }
129
- }
130
- if (currentSegment && currentSegment.length > 0) {
131
- result.push(currentSegment);
132
- }
133
- return result.length > 0 ? result : [s];
134
- };
135
- const detectAndProcessAcronym = (s, start, knownAcronyms, tokens) => {
136
- if (knownAcronyms.size === 0) {
137
- return start;
138
- }
139
- for (const acronym of knownAcronyms) {
140
- if (s.startsWith(acronym, start)) {
141
- tokens.push(acronym);
142
- return start + acronym.length;
143
- }
144
- }
145
- return start;
146
- };
147
- const splitCamelCaseFast = (s, knownAcronyms = /* @__PURE__ */ new Set()) => {
148
- if (s.length === 0) {
149
- return [];
150
- }
151
- if (s.toUpperCase() === s) {
152
- return [s];
153
- }
154
- let start = 0;
155
- const tokens = [];
156
- const width = s.length;
157
- for (let index = 1; index < width; index++) {
158
- const newStart = detectAndProcessAcronym(s, start, knownAcronyms, tokens);
159
- if (newStart !== start) {
160
- start = newStart;
161
- index = start - 1;
162
- continue;
163
- }
164
- const previousCode = s.codePointAt(index - 1);
165
- const currentCode = s.codePointAt(index);
166
- const previousIsUpper = previousCode && previousCode < 128 && isUpper(previousCode);
167
- const currentIsUpper = currentCode && currentCode < 128 && isUpper(currentCode);
168
- const previousIsLower = previousCode && previousCode < 128 && isLower(previousCode);
169
- const previousIsDigit = previousCode && previousCode < 128 && isDigit(previousCode);
170
- const currentIsDigit = currentCode && currentCode < 128 && isDigit(currentCode);
171
- if (previousIsLower && currentIsUpper) {
172
- tokens.push(s.slice(start, index));
173
- start = index;
174
- continue;
175
- }
176
- if (previousIsDigit && !currentIsDigit || !previousIsDigit && currentIsDigit) {
177
- tokens.push(s.slice(start, index));
178
- start = index;
179
- continue;
180
- }
181
- if (currentIsDigit && !previousIsDigit) {
182
- let isNextUpper = false;
183
- let isNextDigit = false;
184
- if (index + 1 < width) {
185
- const nextCode = s.codePointAt(index + 1);
186
- isNextUpper = nextCode && nextCode < 128 && isUpper(nextCode);
187
- isNextDigit = nextCode && nextCode < 128 && isDigit(nextCode);
188
- }
189
- if (!isNextDigit && isNextUpper) {
190
- tokens.push(s.slice(start, index), s.slice(index, index + 1));
191
- start = index + 1;
192
- continue;
193
- }
194
- }
195
- if (index + 1 < width) {
196
- const nextCode = s.codePointAt(index + 1);
197
- const nextIsLower = nextCode && nextCode < 128 && isLower(nextCode);
198
- if (previousIsUpper && currentIsUpper && nextIsLower) {
199
- const candidate = s.slice(start, index + 1);
200
- if (!knownAcronyms.has(candidate)) {
201
- tokens.push(s.slice(start, index));
202
- start = index;
203
- }
204
- }
205
- }
206
- }
207
- if (start < width) {
208
- tokens.push(s.slice(start));
209
- }
210
- return tokens.filter((token) => token !== "");
211
- };
212
- const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
213
- if (s.length === 0) {
214
- return [];
215
- }
216
- const isUpperCase = s === s.toLocaleUpperCase(locale);
217
- if (locale.startsWith("de")) {
218
- if (!isUpperCase && s.replaceAll("ß", "SS") === s.toLocaleUpperCase(locale)) {
219
- return [s];
220
- }
221
- const chars2 = [...s];
222
- const width_2 = chars2.length;
223
- const result2 = [];
224
- let currentSegment2 = chars2[0];
225
- let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
226
- let isInUpperSequence = previousIsUpper2;
227
- let upperSequenceStart = previousIsUpper2 ? 0 : -1;
228
- for (let index = 1; index < width_2; index++) {
229
- const char = chars2[index];
230
- const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
231
- if (isUpperCaseChar === previousIsUpper2) {
232
- currentSegment2 += char;
233
- } else if (isUpperCaseChar) {
234
- if (currentSegment2 && currentSegment2.length > 0) {
235
- result2.push(currentSegment2);
236
- currentSegment2 = char;
237
- }
238
- isInUpperSequence = true;
239
- upperSequenceStart = index;
240
- } else {
241
- if (isInUpperSequence && index - upperSequenceStart > 1) {
242
- const lastUpperChar = chars2[index - 1];
243
- const withoutLastUpper = currentSegment2.slice(0, -1);
244
- if (withoutLastUpper && withoutLastUpper.length > 0) {
245
- result2.push(withoutLastUpper);
246
- }
247
- currentSegment2 = lastUpperChar + char;
248
- } else {
249
- currentSegment2 += char;
250
- }
251
- isInUpperSequence = false;
252
- upperSequenceStart = -1;
253
- }
254
- previousIsUpper2 = isUpperCaseChar;
255
- }
256
- if (currentSegment2 && currentSegment2.length > 0) {
257
- result2.push(currentSegment2);
258
- }
259
- return result2;
260
- }
261
- if (locale.startsWith("uk") || locale.startsWith("ru") || locale.startsWith("bg") || locale.startsWith("sr") || locale.startsWith("mk") || locale.startsWith("be")) {
262
- if (!RE_CYRILLIC.test(s) && !RE_LATIN.test(s)) {
263
- return [s];
264
- }
265
- const chars2 = [...s];
266
- const width_2 = chars2.length;
267
- const result2 = [];
268
- let currentSegment2 = chars2[0];
269
- const firstChar = chars2[0];
270
- let previousType;
271
- if (RE_CYRILLIC.test(firstChar)) {
272
- previousType = 1;
273
- } else if (RE_LATIN.test(firstChar)) {
274
- previousType = 2;
275
- } else {
276
- previousType = 0;
277
- }
278
- let previousIsUpper2 = firstChar === firstChar.toLocaleUpperCase(locale);
279
- for (let index = 1; index < width_2; index++) {
280
- const char = chars2[index];
281
- let currentType;
282
- if (RE_CYRILLIC.test(char)) {
283
- currentType = 1;
284
- } else if (RE_LATIN.test(char)) {
285
- currentType = 2;
286
- } else {
287
- currentType = 0;
288
- }
289
- const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
290
- if (previousType !== currentType && (previousType === 1 || previousType === 2) && (currentType === 1 || currentType === 2) || currentType === previousType && !previousIsUpper2 && isUpperCaseChar) {
291
- result2.push(currentSegment2);
292
- currentSegment2 = char;
293
- } else {
294
- currentSegment2 += char;
295
- }
296
- previousType = currentType;
297
- previousIsUpper2 = isUpperCaseChar;
298
- }
299
- if (currentSegment2 && currentSegment2.length > 0) {
300
- result2.push(currentSegment2);
301
- }
302
- const finalResult = [];
303
- for (let index = 0; index < result2.length; index++) {
304
- if (index < result2.length - 1 && result2[index].length === 1 && RE_LATIN.test(result2[index]) && RE_CYRILLIC.test(result2[index + 1][0])) {
305
- finalResult.push(result2[index] + result2[index + 1]);
306
- index += 1;
307
- } else {
308
- finalResult.push(result2[index]);
309
- }
310
- }
311
- return finalResult;
312
- }
313
- if (locale.startsWith("el")) {
314
- if (!RE_GREEK.test(s) && !RE_LATIN.test(s)) {
315
- return [s];
316
- }
317
- const parts = [];
318
- RE_GREEK_LATIN_SPLIT.lastIndex = 0;
319
- let greekExecMatch;
320
- while ((greekExecMatch = RE_GREEK_LATIN_SPLIT.exec(s)) !== null) {
321
- parts.push(greekExecMatch[0]);
322
- }
323
- if (parts.length === 0) {
324
- parts.push(s);
325
- }
326
- const result2 = [];
327
- const width = parts.length;
328
- if (width === 1) {
329
- const part = parts[0];
330
- if (!part || !RE_GREEK.test(part[0]) || part.length === 1) {
331
- return [part ?? s];
332
- }
333
- }
334
- for (const greekPart of parts) {
335
- if (!greekPart) {
336
- continue;
337
- }
338
- if (!RE_GREEK.test(greekPart[0]) || greekPart.length === 1) {
339
- result2.push(greekPart);
340
- continue;
341
- }
342
- const partLength = greekPart.length;
343
- let word = greekPart[0];
344
- let previousIsUpper2 = greekPart[0] === greekPart[0].toLocaleUpperCase(locale);
345
- for (let index = 1; index < partLength; index++) {
346
- const char = greekPart[index];
347
- const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
348
- if (!previousIsUpper2 && isUpperCaseChar) {
349
- result2.push(word);
350
- word = char;
351
- } else {
352
- word += char;
353
- }
354
- previousIsUpper2 = isUpperCaseChar;
355
- }
356
- if (word) {
357
- result2.push(word);
358
- }
359
- }
360
- return result2;
361
- }
362
- if (locale.startsWith("ja") || locale.startsWith("ko")) {
363
- const isJapanese = locale.startsWith("ja");
364
- const scriptDetectors = isJapanese ? {
365
- hiragana: (char) => RE_HIRAGANA.test(char),
366
- kanji: (char) => RE_KANJI.test(char),
367
- katakana: (char) => RE_KATAKANA.test(char),
368
- latin: (char) => RE_LATIN.test(char)
369
- } : {
370
- hangul: (char) => RE_HANGUL.test(char),
371
- latin: (char) => RE_LATIN.test(char)
372
- };
373
- const particles = /* @__PURE__ */ new Set(["が", "で", "と", "に", "の", "は", "へ", "も", "や", "を"]);
374
- if (isJapanese) {
375
- const baseSegments = handleScriptTransitions(
376
- s,
377
- scriptDetectors,
378
- false,
379
- locale,
380
- (previousType, currentType) => previousType === "hiragana" && currentType === "katakana" || previousType === "katakana" && currentType === "hiragana" || previousType === "hiragana" && currentType === "latin" || previousType === "katakana" && currentType === "latin" || previousType === "kanji" && currentType === "latin" || previousType === "latin" && (currentType === "hiragana" || currentType === "katakana" || currentType === "kanji")
381
- // latin -> japanese
382
- );
383
- const result2 = [];
384
- for (const baseSegment of baseSegments) {
385
- const segment = baseSegment;
386
- if (segment.length === 1 && particles.has(segment) && result2.length > 0) {
387
- result2[result2.length - 1] = result2.at(-1) + segment;
388
- } else {
389
- result2.push(segment);
390
- }
391
- }
392
- return result2.length > 0 ? result2 : [s];
393
- }
394
- return handleScriptTransitions(
395
- s,
396
- scriptDetectors,
397
- false,
398
- locale,
399
- (previousType, currentType) => previousType === "hangul" && currentType === "latin" || previousType === "latin" && currentType === "hangul"
400
- // latin -> hangul
401
- );
402
- }
403
- if (locale.startsWith("sl")) {
404
- const chars2 = [...s];
405
- const width_2 = chars2.length;
406
- const result2 = [];
407
- let currentSegment2 = chars2[0];
408
- let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
409
- for (let index = 1; index < width_2; index++) {
410
- const char = chars2[index];
411
- const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
412
- const isSpecialChar = RE_SLOVENIAN_SPECIAL.test(char);
413
- const nextIsUpper = index < width_2 - 1 && chars2[index + 1] === chars2[index + 1].toLocaleUpperCase(locale);
414
- if (!previousIsUpper2 && isUpperCaseChar || isSpecialChar && nextIsUpper) {
415
- result2.push(currentSegment2);
416
- currentSegment2 = char;
417
- if (isSpecialChar && nextIsUpper) {
418
- result2.push(currentSegment2);
419
- currentSegment2 = "";
420
- }
421
- } else {
422
- currentSegment2 += char;
423
- }
424
- previousIsUpper2 = isUpperCaseChar;
425
- }
426
- if (currentSegment2 && currentSegment2.length > 0) {
427
- result2.push(currentSegment2);
428
- }
429
- return result2;
430
- }
431
- if (locale.startsWith("zh")) {
432
- return handleScriptTransitions(
433
- s,
434
- {
435
- han: (char) => RE_KANJI.test(char),
436
- latin: (char) => RE_LATIN.test(char)
437
- },
438
- false,
439
- locale
440
- );
441
- }
442
- if (["ar", "fa", "he", "ur"].includes(locale.split("-")[0])) {
443
- const isRtlChar = (ch) => RE_HEBREW.test(ch) || RE_ARABIC.test(ch);
444
- return handleScriptTransitions(
445
- s,
446
- {
447
- latin: (char) => RE_LATIN.test(char),
448
- rtl: (char) => isRtlChar(char)
449
- },
450
- false,
451
- locale
452
- );
453
- }
454
- if ([
455
- "am",
456
- // Amharic
457
- "bn",
458
- // Bengali
459
- "gu",
460
- // Gujarati
461
- "hi",
462
- // Hindi
463
- "km",
464
- // Khmer
465
- "kn",
466
- // Kannada
467
- "lo",
468
- // Lao
469
- "ml",
470
- // Malayalam
471
- "mr",
472
- // Marathi
473
- "ne",
474
- // Nepali
475
- "or",
476
- // Oriya
477
- "pa",
478
- // Punjabi
479
- "si",
480
- // Sinhala
481
- "ta",
482
- // Tamil
483
- "te",
484
- // Telugu
485
- "th"
486
- // Thai
487
- ].includes(locale.split("-")[0])) {
488
- const isIndicChar = (ch) => RE_DEVANAGARI.test(ch) || RE_BENGALI.test(ch) || RE_GUJARATI.test(ch) || RE_GURMUKHI.test(ch) || RE_KANNADA.test(ch) || RE_TAMIL.test(ch) || RE_TELUGU.test(ch) || RE_MALAYALAM.test(ch) || RE_SINHALA.test(ch) || RE_THAI.test(ch) || RE_LAO.test(ch) || RE_TIBETAN.test(ch) || RE_MYANMAR.test(ch) || RE_ETHIOPIC.test(ch) || RE_KHMER.test(ch) || RE_ORIYA.test(ch);
489
- return handleScriptTransitions(
490
- s,
491
- {
492
- indic: (char) => isIndicChar(char),
493
- latin: (char) => RE_LATIN.test(char)
494
- },
495
- false,
496
- locale
497
- );
498
- }
499
- if (["be", "bg", "ru", "sr", "uk"].includes(locale)) {
500
- return handleScriptTransitions(
501
- s,
502
- {
503
- cyrillic: (char) => RE_CYRILLIC.test(char),
504
- latin: (char) => RE_LATIN.test(char)
505
- },
506
- true,
507
- // Enable case-sensitive splitting
508
- locale
509
- );
510
- }
511
- if (["ar", "fa", "he"].includes(locale)) {
512
- return handleScriptTransitions(
513
- s,
514
- {
515
- latin: (char) => RE_LATIN.test(char),
516
- rtl: (char) => RE_HEBREW.test(char) || RE_ARABIC.test(char)
517
- },
518
- false,
519
- locale
520
- );
521
- }
522
- if (locale.startsWith("ko")) {
523
- return handleScriptTransitions(
524
- s,
525
- {
526
- hangul: (char) => RE_HANGUL.test(char),
527
- latin: (char) => RE_LATIN.test(char)
528
- },
529
- false,
530
- locale
531
- );
532
- }
533
- if (locale.startsWith("uz")) {
534
- if (!RE_CYRILLIC.test(s) && !RE_LATIN.test(s)) {
535
- return [s];
536
- }
537
- const chars2 = [...s];
538
- const width_2 = chars2.length;
539
- const result2 = [];
540
- let currentSegment2 = chars2[0];
541
- let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
542
- for (let index = 1; index < width_2; index++) {
543
- const char = chars2[index];
544
- const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
545
- if (RE_UZBEK_LATIN_MODIFIER.test(char) || RE_UZBEK_LATIN_MODIFIER.test(chars2[index - 1])) {
546
- currentSegment2 += char;
547
- continue;
548
- }
549
- if (!previousIsUpper2 && isUpperCaseChar) {
550
- result2.push(currentSegment2);
551
- currentSegment2 = char;
552
- } else {
553
- currentSegment2 += char;
554
- }
555
- previousIsUpper2 = isUpperCaseChar;
556
- }
557
- if (currentSegment2 && currentSegment2.length > 0) {
558
- result2.push(currentSegment2);
559
- }
560
- return result2;
561
- }
562
- const chars = [...s];
563
- const width_ = chars.length;
564
- const result = [];
565
- let currentSegment = chars[0];
566
- let previousIsUpper = chars[0] === chars[0].toLocaleUpperCase(locale);
567
- for (const acronym of knownAcronyms) {
568
- if (s.startsWith(acronym)) {
569
- result.push(acronym);
570
- currentSegment = chars[acronym.length];
571
- previousIsUpper = currentSegment === currentSegment.toLocaleUpperCase(locale);
572
- break;
573
- }
574
- }
575
- for (let index = 1; index < width_; index++) {
576
- const char = chars[index];
577
- const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
578
- let acronymLength = 0;
579
- for (const acronym of knownAcronyms) {
580
- if (s.startsWith(acronym, index)) {
581
- result.push(currentSegment, acronym);
582
- acronymLength = acronym.length;
583
- currentSegment = "";
584
- const lastAcronymChar = acronym.at(-1);
585
- if (lastAcronymChar) {
586
- previousIsUpper = lastAcronymChar === lastAcronymChar.toLocaleUpperCase(locale);
587
- }
588
- break;
589
- }
590
- }
591
- if (acronymLength > 0) {
592
- index += acronymLength - 1;
593
- continue;
594
- }
595
- if (!previousIsUpper && isUpperCaseChar) {
596
- result.push(currentSegment);
597
- currentSegment = char;
598
- } else {
599
- currentSegment += char;
600
- }
601
- previousIsUpper = isUpperCaseChar;
602
- }
603
- if (currentSegment) {
604
- result.push(currentSegment);
605
- }
606
- return result;
607
- };
608
- const processTextWithAnsiEmoji = (text, locale, knownAcronyms) => {
609
- const result = [];
610
- const segments = RE_FAST_ANSI.test(text) ? text.split(RE_FAST_ANSI).filter(Boolean) : [text];
611
- for (const segment of segments) {
612
- const seg = segment;
613
- if (RE_FAST_ANSI.test(seg)) {
614
- result.push(seg);
615
- } else {
616
- const subs = RE_EMOJI.test(seg) ? splitByEmoji(seg).filter(Boolean) : [seg];
617
- for (const emojiSub of subs) {
618
- if (RE_EMOJI.test(emojiSub)) {
619
- result.push(emojiSub);
620
- } else {
621
- if (locale) {
622
- const normalizedLocale = locale.toLowerCase().split("-")[0];
623
- result.push(...splitCamelCaseLocale(emojiSub, normalizedLocale, knownAcronyms));
624
- } else {
625
- result.push(...splitCamelCaseFast(emojiSub, knownAcronyms));
626
- }
627
- }
628
- }
629
- }
630
- }
631
- return result;
632
- };
633
- const splitByCase = (input, options = {}) => {
634
- if (!input || typeof input !== "string") {
635
- return [];
636
- }
637
- const {
638
- handleAnsi = false,
639
- handleEmoji = false,
640
- knownAcronyms = [],
641
- locale,
642
- normalize = false,
643
- separators,
644
- stripAnsi: stripAnsiOption = false,
645
- stripEmoji: stripEmojiOption = false
646
- } = options;
647
- const acronymSet = new Set([...knownAcronyms].toSorted((a, b) => b.length - a.length));
648
- let cleanedInput = input;
649
- if (stripAnsiOption) {
650
- cleanedInput = stripVTControlCharacters(cleanedInput);
651
- }
652
- if (stripEmojiOption) {
653
- cleanedInput = stripEmoji(cleanedInput);
654
- }
655
- let separatorRegex;
656
- if (Array.isArray(separators)) {
657
- separatorRegex = getSeparatorsRegex(separators);
658
- } else if (separators instanceof RegExp) {
659
- separatorRegex = separators;
660
- } else {
661
- separatorRegex = RE_SEPARATORS;
662
- }
663
- const parts = [];
664
- let workingInput = cleanedInput;
665
- const regex = separatorRegex.flags.includes("g") ? separatorRegex : new RegExp(separatorRegex.source, `${separatorRegex.flags}g`);
666
- while (workingInput.length > 0) {
667
- const match = regex.exec(workingInput);
668
- if (!match) {
669
- if (workingInput === "..") {
670
- parts.push("..");
671
- } else if (workingInput === ".") {
672
- parts.push(".");
673
- } else if (workingInput.length > 0) {
674
- parts.push(workingInput);
675
- }
676
- break;
677
- }
678
- const matchIndex = match.index;
679
- const matchText = match[0];
680
- const matchLength = matchText.length;
681
- const beforeMatch = workingInput.slice(0, matchIndex);
682
- const afterMatch = workingInput.slice(matchIndex + matchLength);
683
- if (matchText.startsWith("../")) {
684
- parts.push("..");
685
- workingInput = workingInput.slice(matchIndex + 3);
686
- } else if (matchText.startsWith("./")) {
687
- parts.push(".");
688
- workingInput = workingInput.slice(matchIndex + 2);
689
- } else if (matchIndex === 0 && matchText === "..") {
690
- parts.push("..");
691
- workingInput = workingInput.slice(2);
692
- } else if (matchIndex === 0 && matchText === ".") {
693
- parts.push(".");
694
- workingInput = workingInput.slice(1);
695
- } else {
696
- if (beforeMatch.length > 0) {
697
- parts.push(beforeMatch);
698
- }
699
- let pos = 0;
700
- while ((pos = matchText.indexOf("../", pos)) !== -1) {
701
- parts.push("..");
702
- pos += 3;
703
- }
704
- pos = 0;
705
- while ((pos = matchText.indexOf("./", pos)) !== -1) {
706
- if (pos === 0 || matchText[pos - 1] !== ".") {
707
- parts.push(".");
708
- }
709
- pos += 2;
710
- }
711
- let remainingAfterMatch = afterMatch;
712
- while (remainingAfterMatch.startsWith("../")) {
713
- parts.push("..");
714
- remainingAfterMatch = remainingAfterMatch.slice(3);
715
- }
716
- while (remainingAfterMatch.startsWith("./")) {
717
- parts.push(".");
718
- remainingAfterMatch = remainingAfterMatch.slice(2);
719
- }
720
- if (remainingAfterMatch === "..") {
721
- parts.push("..");
722
- break;
723
- } else if (remainingAfterMatch === ".") {
724
- parts.push(".");
725
- break;
726
- } else {
727
- workingInput = remainingAfterMatch;
728
- }
729
- }
730
- regex.lastIndex = 0;
731
- }
732
- if (parts.length === 0) {
733
- const standardParts = cleanedInput.split(separatorRegex).filter(Boolean);
734
- parts.push(...standardParts);
735
- }
736
- let tokens = [];
737
- for (const splitPart of parts) {
738
- if (handleAnsi || handleEmoji) {
739
- tokens.push(...processTextWithAnsiEmoji(splitPart, locale, acronymSet));
740
- } else if (locale) {
741
- tokens.push(...splitCamelCaseLocale(splitPart, locale, acronymSet));
742
- } else {
743
- tokens.push(...splitCamelCaseFast(splitPart, acronymSet));
744
- }
745
- }
746
- if (normalize) {
747
- tokens = tokens.map((token) => {
748
- if (acronymSet.has(token)) {
749
- return token;
750
- }
751
- if (locale && token === token.toLocaleUpperCase(locale)) {
752
- return token[0] + token.slice(1).toLocaleLowerCase(locale);
753
- }
754
- if (token.toUpperCase() === token && !acronymSet.has(token)) {
755
- return token.slice(0, 1) + token.slice(1).toLowerCase();
756
- }
757
- return token;
758
- });
759
- }
760
- return tokens;
761
- };
762
-
763
- export { splitByCase };
1
+ import{createRequire as Y}from"node:module";import{b as m,s as Z,l as Q,c as x,m as W,n as C,o as N,p as B,q as S,r as X,t as M,u as ee,v as G,w as K,x as H,y as te,z as se,A as ne,B as re,C as le,D as oe,E as ie,F as ae,G as ce,H as he,I as ue,J as pe,K as fe,L as ge,M as Ae,N as Ee}from"../packem_shared/constants-aPzGW29R.js";import{i as Re}from"../packem_shared/lru-cache-BtMSrYQJ.js";const F=Y(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[r,h]=b.versions.node.split(".").map(Number);if(r>22||r===22&&h>=3||r===20&&h>=16)return b.getBuiltinModule(e)}return F(e)},{stripVTControlCharacters:$}=V("node:util"),T=new Re(1e3),_e=/[.*+?^${}()|[\]\\]/g,Le=e=>{const r=e.join("");if(T.has(r)){const A=T.get(r);return A.lastIndex=0,A}const h=e.map(A=>A.replaceAll(_e,String.raw`\$&`)).join("|"),g=new RegExp(h,"g");return T.set(r,g),g},Ce=e=>{const r=[];let h=0,g;for(m.lastIndex=0;(g=m.exec(e))!==null;)g.index>h&&r.push(e.slice(h,g.index)),r.push(g[0]),h=m.lastIndex;return h<e.length&&r.push(e.slice(h)),r.filter(Boolean)},de=/[ČŠŽĐ]/i,P=new Uint8Array(128),v=new Uint8Array(128),z=new Uint8Array(128);for(let e=0;e<128;e++)P[e]=e>=65&&e<=90?1:0,v[e]=e>=97&&e<=122?1:0,z[e]=e>=48&&e<=57?1:0;const j=e=>P[e],O=e=>v[e],w=e=>z[e],k=(e,r,h,g,A)=>{if(e.length===0)return[];let p=!1;const L=Object.values(r);for(const l of L)if(l(e[0])){p=!0;break}if(!p&&!h)return[e];const f=[...e],R=[];let s=f[0],o="other";const c=Object.entries(r);for(const l of c){const[n,a]=l;if(a(f[0])){o=n;break}}let t=h&&g?f[0]===f[0].toLocaleUpperCase(g):!1;for(let l=1;l<f.length;l++){const n=f[l];let a="other";for(const E of c){const[_,d]=E;if(d(n)){a=_;break}}const u=h&&g?n===n.toLocaleUpperCase(g):!1;let i=!1;A?i=A(o,a,t,u,n,l,f):(o!==a&&o!=="other"&&a!=="other"&&(i=!0),h&&a!=="other"&&!t&&u&&(i=!0)),i?(R.push(s),s=n):s+=n,o=a,h&&(t=u)}return s&&s.length>0&&R.push(s),R.length>0?R:[e]},Ue=(e,r,h,g)=>{if(h.size===0)return r;for(const A of h)if(e.startsWith(A,r))return g.push(A),r+A.length;return r},D=(e,r=new Set)=>{if(e.length===0)return[];if(e.toUpperCase()===e)return[e];let h=0;const g=[],A=e.length;for(let p=1;p<A;p++){const L=Ue(e,h,r,g);if(L!==h){h=L,p=h-1;continue}const f=e.codePointAt(p-1),R=e.codePointAt(p),s=f&&f<128&&j(f),o=R&&R<128&&j(R),c=f&&f<128&&O(f),t=f&&f<128&&w(f),l=R&&R<128&&w(R);if(c&&o){g.push(e.slice(h,p)),h=p;continue}if(t&&!l||!t&&l){g.push(e.slice(h,p)),h=p;continue}if(l&&!t){let n=!1,a=!1;if(p+1<A){const u=e.codePointAt(p+1);n=u&&u<128&&j(u),a=u&&u<128&&w(u)}if(!a&&n){g.push(e.slice(h,p),e.slice(p,p+1)),h=p+1;continue}}if(p+1<A){const n=e.codePointAt(p+1),a=n&&n<128&&O(n);if(s&&o&&a){const u=e.slice(h,p+1);r.has(u)||(g.push(e.slice(h,p)),h=p)}}}return h<A&&g.push(e.slice(h)),g.filter(p=>p!=="")},q=(e,r,h)=>{if(e.length===0)return[];const g=e===e.toLocaleUpperCase(r);if(r.startsWith("de")){if(!g&&e.replaceAll("ß","SS")===e.toLocaleUpperCase(r))return[e];const s=[...e],o=s.length,c=[];let t=s[0],l=s[0]===s[0].toLocaleUpperCase(r),n=l,a=l?0:-1;for(let u=1;u<o;u++){const i=s[u],E=i===i.toLocaleUpperCase(r);if(E===l)t+=i;else if(E)t&&t.length>0&&(c.push(t),t=i),n=!0,a=u;else{if(n&&u-a>1){const _=s[u-1],d=t.slice(0,-1);d&&d.length>0&&c.push(d),t=_+i}else t+=i;n=!1,a=-1}l=E}return t&&t.length>0&&c.push(t),c}if(r.startsWith("uk")||r.startsWith("ru")||r.startsWith("bg")||r.startsWith("sr")||r.startsWith("mk")||r.startsWith("be")){if(!W.test(e)&&!C.test(e))return[e];const s=[...e],o=s.length,c=[];let t=s[0];const l=s[0];let n;W.test(l)?n=1:C.test(l)?n=2:n=0;let a=l===l.toLocaleUpperCase(r);for(let i=1;i<o;i++){const E=s[i];let _;W.test(E)?_=1:C.test(E)?_=2:_=0;const d=E===E.toLocaleUpperCase(r);n!==_&&(n===1||n===2)&&(_===1||_===2)||_===n&&!a&&d?(c.push(t),t=E):t+=E,n=_,a=d}t&&t.length>0&&c.push(t);const u=[];for(let i=0;i<c.length;i++)i<c.length-1&&c[i].length===1&&C.test(c[i])&&W.test(c[i+1][0])?(u.push(c[i]+c[i+1]),i+=1):u.push(c[i]);return u}if(r.startsWith("el")){if(!N.test(e)&&!C.test(e))return[e];const s=[];B.lastIndex=0;let o;for(;(o=B.exec(e))!==null;)s.push(o[0]);s.length===0&&s.push(e);const c=[];if(s.length===1){const t=s[0];if(!t||!N.test(t[0])||t.length===1)return[t??e]}for(const t of s){if(!t)continue;if(!N.test(t[0])||t.length===1){c.push(t);continue}const l=t.length;let n=t[0],a=t[0]===t[0].toLocaleUpperCase(r);for(let u=1;u<l;u++){const i=t[u],E=i===i.toLocaleUpperCase(r);!a&&E?(c.push(n),n=i):n+=i,a=E}n&&c.push(n)}return c}if(r.startsWith("ja")||r.startsWith("ko")){const s=r.startsWith("ja"),o=s?{hiragana:t=>ee.test(t),kanji:t=>M.test(t),katakana:t=>X.test(t),latin:t=>C.test(t)}:{hangul:t=>G.test(t),latin:t=>C.test(t)},c=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(s){const t=k(e,o,!1,r,(n,a)=>n==="hiragana"&&a==="katakana"||n==="katakana"&&a==="hiragana"||n==="hiragana"&&a==="latin"||n==="katakana"&&a==="latin"||n==="kanji"&&a==="latin"||n==="latin"&&(a==="hiragana"||a==="katakana"||a==="kanji")),l=[];for(const n of t){const a=n;a.length===1&&c.has(a)&&l.length>0?l[l.length-1]=l.at(-1)+a:l.push(a)}return l.length>0?l:[e]}return k(e,o,!1,r,(t,l)=>t==="hangul"&&l==="latin"||t==="latin"&&l==="hangul")}if(r.startsWith("sl")){const s=[...e],o=s.length,c=[];let t=s[0],l=s[0]===s[0].toLocaleUpperCase(r);for(let n=1;n<o;n++){const a=s[n],u=a===a.toLocaleUpperCase(r),i=de.test(a),E=n<o-1&&s[n+1]===s[n+1].toLocaleUpperCase(r);!l&&u||i&&E?(c.push(t),t=a,i&&E&&(c.push(t),t="")):t+=a,l=u}return t&&t.length>0&&c.push(t),c}if(r.startsWith("zh"))return k(e,{han:s=>M.test(s),latin:s=>C.test(s)},!1,r);if(["ar","fa","he","ur"].includes(r.split("-")[0])){const s=o=>K.test(o)||H.test(o);return k(e,{latin:o=>C.test(o),rtl:o=>s(o)},!1,r)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(r.split("-")[0])){const s=o=>te.test(o)||se.test(o)||ne.test(o)||re.test(o)||le.test(o)||oe.test(o)||ie.test(o)||ae.test(o)||ce.test(o)||he.test(o)||ue.test(o)||pe.test(o)||fe.test(o)||ge.test(o)||Ae.test(o)||Ee.test(o);return k(e,{indic:o=>s(o),latin:o=>C.test(o)},!1,r)}if(["be","bg","ru","sr","uk"].includes(r))return k(e,{cyrillic:s=>W.test(s),latin:s=>C.test(s)},!0,r);if(["ar","fa","he"].includes(r))return k(e,{latin:s=>C.test(s),rtl:s=>K.test(s)||H.test(s)},!1,r);if(r.startsWith("ko"))return k(e,{hangul:s=>G.test(s),latin:s=>C.test(s)},!1,r);if(r.startsWith("uz")){if(!W.test(e)&&!C.test(e))return[e];const s=[...e],o=s.length,c=[];let t=s[0],l=s[0]===s[0].toLocaleUpperCase(r);for(let n=1;n<o;n++){const a=s[n],u=a===a.toLocaleUpperCase(r);if(S.test(a)||S.test(s[n-1])){t+=a;continue}!l&&u?(c.push(t),t=a):t+=a,l=u}return t&&t.length>0&&c.push(t),c}const A=[...e],p=A.length,L=[];let f=A[0],R=A[0]===A[0].toLocaleUpperCase(r);for(const s of h)if(e.startsWith(s)){L.push(s),f=A[s.length],R=f===f.toLocaleUpperCase(r);break}for(let s=1;s<p;s++){const o=A[s],c=o===o.toLocaleUpperCase(r);let t=0;for(const l of h)if(e.startsWith(l,s)){L.push(f,l),t=l.length,f="";const n=l.at(-1);n&&(R=n===n.toLocaleUpperCase(r));break}if(t>0){s+=t-1;continue}!R&&c?(L.push(f),f=o):f+=o,R=c}return f&&L.push(f),L},Ie=(e,r,h)=>{const g=[],A=x.test(e)?e.split(x).filter(Boolean):[e];for(const p of A){const L=p;if(x.test(L))g.push(L);else{m.lastIndex=0;const f=m.test(L)?Ce(L).filter(Boolean):[L];for(const R of f)if(m.lastIndex=0,m.test(R))g.push(R);else if(r){const s=r.toLowerCase().split("-")[0];g.push(...q(R,s,h))}else g.push(...D(R,h))}}return g},be=(e,r={})=>{if(!e||typeof e!="string")return[];const{handleAnsi:h=!1,handleEmoji:g=!1,knownAcronyms:A=[],locale:p,normalize:L=!1,separators:f,stripAnsi:R=!1,stripEmoji:s=!1}=r,o=new Set([...A].toSorted((i,E)=>E.length-i.length));let c=e;R&&(c=$(c)),s&&(c=Z(c));let t;Array.isArray(f)?t=Le(f):f instanceof RegExp?t=f:t=Q;const l=[];let n=c;const a=t.flags.includes("g")?t:new RegExp(t.source,`${t.flags}g`);for(;n.length>0;){const i=a.exec(n);if(!i){n===".."?l.push(".."):n==="."?l.push("."):n.length>0&&l.push(n);break}const E=i.index,_=i[0],d=_.length,y=n.slice(0,E),J=n.slice(E+d);if(_.startsWith("../"))l.push(".."),n=n.slice(E+3);else if(_.startsWith("./"))l.push("."),n=n.slice(E+2);else if(E===0&&_==="..")l.push(".."),n=n.slice(2);else if(E===0&&_===".")l.push("."),n=n.slice(1);else{y.length>0&&l.push(y);let U=0;for(;(U=_.indexOf("../",U))!==-1;)l.push(".."),U+=3;for(U=0;(U=_.indexOf("./",U))!==-1;)(U===0||_[U-1]!==".")&&l.push("."),U+=2;let I=J;for(;I.startsWith("../");)l.push(".."),I=I.slice(3);for(;I.startsWith("./");)l.push("."),I=I.slice(2);if(I===".."){l.push("..");break}else if(I==="."){l.push(".");break}else n=I}a.lastIndex=0}if(l.length===0){const i=c.split(t).filter(Boolean);l.push(...i)}let u=[];for(const i of l)h||g?u.push(...Ie(i,p,o)):p?u.push(...q(i,p,o)):u.push(...D(i,o));return L&&(u=u.map(i=>o.has(i)?i:p&&i===i.toLocaleUpperCase(p)?i[0]+i.slice(1).toLocaleLowerCase(p):i.toUpperCase()===i&&!o.has(i)?i.slice(0,1)+i.slice(1).toLowerCase():i)),u};export{be as splitByCase};