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