@visulima/string 1.2.3 → 1.3.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.
- package/CHANGELOG.md +11 -0
- package/README.md +46 -0
- package/dist/case/camel-case.cjs +1 -59
- package/dist/case/camel-case.mjs +1 -57
- package/dist/case/capital-case.cjs +1 -51
- package/dist/case/capital-case.mjs +1 -49
- package/dist/case/constant-case.cjs +1 -11
- package/dist/case/constant-case.mjs +1 -9
- package/dist/case/dot-case.cjs +1 -11
- package/dist/case/dot-case.mjs +1 -9
- package/dist/case/flat-case.cjs +1 -11
- package/dist/case/flat-case.mjs +1 -9
- package/dist/case/flip-case.cjs +1 -61
- package/dist/case/flip-case.mjs +1 -57
- package/dist/case/identify-case.cjs +1 -69
- package/dist/case/identify-case.mjs +1 -67
- package/dist/case/index.cjs +1 -47
- package/dist/case/index.mjs +1 -20
- package/dist/case/kebab-case.cjs +1 -61
- package/dist/case/kebab-case.mjs +1 -57
- package/dist/case/lower-first.cjs +1 -13
- package/dist/case/lower-first.mjs +1 -11
- package/dist/case/no-case.cjs +1 -11
- package/dist/case/no-case.mjs +1 -9
- package/dist/case/pascal-case.cjs +1 -52
- package/dist/case/pascal-case.mjs +1 -50
- package/dist/case/pascal-snake-case.cjs +1 -32
- package/dist/case/pascal-snake-case.mjs +1 -30
- package/dist/case/path-case.cjs +1 -11
- package/dist/case/path-case.mjs +1 -9
- package/dist/case/sentence-case.cjs +1 -58
- package/dist/case/sentence-case.mjs +1 -56
- package/dist/case/snake-case.cjs +1 -11
- package/dist/case/snake-case.mjs +1 -9
- package/dist/case/split-by-case.cjs +1 -641
- package/dist/case/split-by-case.mjs +1 -637
- package/dist/case/title-case.cjs +1 -47
- package/dist/case/title-case.mjs +1 -45
- package/dist/case/train-case.cjs +1 -44
- package/dist/case/train-case.mjs +1 -42
- package/dist/case/upper-first.cjs +1 -13
- package/dist/case/upper-first.mjs +1 -11
- package/dist/get-string-truncated-width.cjs +1 -422
- package/dist/get-string-truncated-width.mjs +1 -418
- package/dist/get-string-width.cjs +1 -11
- package/dist/get-string-width.mjs +1 -7
- package/dist/index.cjs +1 -66
- package/dist/index.d.cts +12 -3
- package/dist/index.d.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.mjs +1 -29
- package/dist/outdent.cjs +1 -125
- package/dist/outdent.mjs +1 -121
- package/dist/packem_shared/LRUCache-Bjo6gsbC.mjs +1 -0
- package/dist/packem_shared/LRUCache-TYqfUYE5.cjs +1 -0
- package/dist/packem_shared/WrapMode-BL2dnSc8.cjs +8 -0
- package/dist/packem_shared/WrapMode-DxH5g69E.mjs +8 -0
- package/dist/packem_shared/alignText-BCKbnqhC.mjs +2 -0
- package/dist/packem_shared/alignText-CLZJuPP6.cjs +2 -0
- package/dist/packem_shared/constants-Cd17VNEv.mjs +1 -0
- package/dist/packem_shared/constants-D3K8u3G8.cjs +1 -0
- package/dist/packem_shared/generate-cache-key-BZf0GiMs.cjs +1 -0
- package/dist/packem_shared/generate-cache-key-DPByFaMH.mjs +1 -0
- package/dist/packem_shared/joinSegments-CDHNMXsF.cjs +1 -0
- package/dist/packem_shared/joinSegments-H7QJ7rwJ.mjs +1 -0
- package/dist/packem_shared/normalize-german-eszett-4k1qRtEP.mjs +1 -0
- package/dist/packem_shared/normalize-german-eszett-Bop4wOp9.cjs +1 -0
- package/dist/packem_shared/replaceString-Ce8TI_-L.cjs +1 -0
- package/dist/packem_shared/replaceString-D7R-5VFX.mjs +1 -0
- package/dist/packem_shared/slugify-B1vlQQO1.mjs +1 -0
- package/dist/packem_shared/slugify-CH3GI7E5.cjs +1 -0
- package/dist/packem_shared/transliterate-BXaP38Sh.mjs +5 -0
- package/dist/packem_shared/transliterate-CToQ-aeM.cjs +5 -0
- package/dist/slice.cjs +1 -419
- package/dist/slice.mjs +1 -415
- package/dist/test/utils.cjs +13 -74
- package/dist/test/utils.mjs +14 -69
- package/dist/test/vitest.cjs +1 -11
- package/dist/test/vitest.mjs +1 -7
- package/dist/truncate.cjs +1 -101
- package/dist/truncate.mjs +1 -97
- package/dist/utils.cjs +1 -65
- package/dist/utils.mjs +1 -56
- package/package.json +8 -1
- package/dist/packem_shared/LRUCache-Crb-m7cw.cjs +0 -53
- package/dist/packem_shared/LRUCache-udNErhWw.mjs +0 -51
- package/dist/packem_shared/WrapMode-BCVbMqYK.mjs +0 -545
- package/dist/packem_shared/WrapMode-DebG_Nll.cjs +0 -550
- package/dist/packem_shared/constants-6-GJ6zA-.cjs +0 -150
- package/dist/packem_shared/constants-CKdlkHVU.mjs +0 -99
- package/dist/packem_shared/generate-cache-key-D8f1auDB.cjs +0 -10
- package/dist/packem_shared/generate-cache-key-YSju5pj2.mjs +0 -8
- package/dist/packem_shared/joinSegments-BfSDBmPF.mjs +0 -46
- package/dist/packem_shared/joinSegments-HYXurfoq.cjs +0 -48
- package/dist/packem_shared/normalize-german-eszett-DJK0S2qj.cjs +0 -11
- package/dist/packem_shared/normalize-german-eszett-fpJ4lZL6.mjs +0 -9
- package/dist/packem_shared/replaceString-C7Dp5vAg.mjs +0 -200
- package/dist/packem_shared/replaceString-iYo1cDfZ.cjs +0 -202
- package/dist/packem_shared/slugify-SKjCL8DF.cjs +0 -50
- package/dist/packem_shared/slugify-pbxTlzeQ.mjs +0 -48
- package/dist/packem_shared/transliterate-4P32b49d.mjs +0 -47780
- package/dist/packem_shared/transliterate-CtOTNpLs.cjs +0 -47782
|
@@ -1,637 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { j as RE_EMOJI, s as stripEmoji, k as RE_SEPARATORS, 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_KANJI, q as RE_HEBREW, r as RE_ARABIC, t as RE_HANGUL, u as RE_UZBEK_LATIN_MODIFIER, v as RE_KATAKANA, w as RE_HIRAGANA, 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-CKdlkHVU.mjs';
|
|
3
|
-
import LRUCache from '../packem_shared/LRUCache-udNErhWw.mjs';
|
|
4
|
-
|
|
5
|
-
var __defProp$2 = Object.defineProperty;
|
|
6
|
-
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
7
|
-
const regexCache = new LRUCache(1e3);
|
|
8
|
-
const getSeparatorsRegex = /* @__PURE__ */ __name$2((separators) => {
|
|
9
|
-
const key = separators.join("");
|
|
10
|
-
if (regexCache.has(key)) {
|
|
11
|
-
return regexCache.get(key);
|
|
12
|
-
}
|
|
13
|
-
const pattern = separators.map((s) => s.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
14
|
-
const regex = new RegExp(pattern, "g");
|
|
15
|
-
regexCache.set(key, regex);
|
|
16
|
-
return regex;
|
|
17
|
-
}, "getSeparatorsRegex");
|
|
18
|
-
|
|
19
|
-
var __defProp$1 = Object.defineProperty;
|
|
20
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
21
|
-
const splitByEmoji = /* @__PURE__ */ __name$1((text) => {
|
|
22
|
-
const segments = [];
|
|
23
|
-
let lastIndex = 0;
|
|
24
|
-
let match;
|
|
25
|
-
RE_EMOJI.lastIndex = 0;
|
|
26
|
-
while ((match = RE_EMOJI.exec(text)) !== null) {
|
|
27
|
-
if (match.index > lastIndex) {
|
|
28
|
-
segments.push(text.slice(lastIndex, match.index));
|
|
29
|
-
}
|
|
30
|
-
segments.push(match[0]);
|
|
31
|
-
lastIndex = RE_EMOJI.lastIndex;
|
|
32
|
-
}
|
|
33
|
-
if (lastIndex < text.length) {
|
|
34
|
-
segments.push(text.slice(lastIndex));
|
|
35
|
-
}
|
|
36
|
-
return segments.filter(Boolean);
|
|
37
|
-
}, "splitByEmoji");
|
|
38
|
-
|
|
39
|
-
var __defProp = Object.defineProperty;
|
|
40
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
41
|
-
const isUpperCode = new Uint8Array(128);
|
|
42
|
-
const isLowerCode = new Uint8Array(128);
|
|
43
|
-
const isDigitCode = new Uint8Array(128);
|
|
44
|
-
for (let index = 0; index < 128; index++) {
|
|
45
|
-
isUpperCode[index] = index >= 65 && index <= 90 ? 1 : 0;
|
|
46
|
-
isLowerCode[index] = index >= 97 && index <= 122 ? 1 : 0;
|
|
47
|
-
isDigitCode[index] = index >= 48 && index <= 57 ? 1 : 0;
|
|
48
|
-
}
|
|
49
|
-
const isUpper = /* @__PURE__ */ __name((code) => isUpperCode[code], "isUpper");
|
|
50
|
-
const isLower = /* @__PURE__ */ __name((code) => isLowerCode[code], "isLower");
|
|
51
|
-
const isDigit = /* @__PURE__ */ __name((code) => isDigitCode[code], "isDigit");
|
|
52
|
-
const handleScriptTransitions = /* @__PURE__ */ __name((s, scriptDetectors, caseSensitive, locale, customSplitLogic) => {
|
|
53
|
-
if (s.length === 0) {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
let hasDetectedScript = false;
|
|
57
|
-
for (const detector of Object.values(scriptDetectors)) {
|
|
58
|
-
if (detector(s[0])) {
|
|
59
|
-
hasDetectedScript = true;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (!hasDetectedScript && !caseSensitive) {
|
|
64
|
-
return [s];
|
|
65
|
-
}
|
|
66
|
-
const chars = [...s];
|
|
67
|
-
const result = [];
|
|
68
|
-
let currentSegment = chars[0];
|
|
69
|
-
let previousType = "other";
|
|
70
|
-
for (const [type, detector] of Object.entries(scriptDetectors)) {
|
|
71
|
-
if (detector(chars[0])) {
|
|
72
|
-
previousType = type;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
let previousIsUpper = caseSensitive && locale ? chars[0] === chars[0].toLocaleUpperCase(locale) : false;
|
|
77
|
-
for (let index = 1; index < chars.length; index++) {
|
|
78
|
-
const char = chars[index];
|
|
79
|
-
let currentType = "other";
|
|
80
|
-
for (const [type, detector] of Object.entries(scriptDetectors)) {
|
|
81
|
-
if (detector(char)) {
|
|
82
|
-
currentType = type;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const isUpperCaseChar = caseSensitive && locale ? char === char.toLocaleUpperCase(locale) : false;
|
|
87
|
-
let shouldSplit = false;
|
|
88
|
-
if (customSplitLogic) {
|
|
89
|
-
shouldSplit = customSplitLogic(previousType, currentType, previousIsUpper, isUpperCaseChar, char, index, chars);
|
|
90
|
-
} else {
|
|
91
|
-
if (previousType !== currentType && previousType !== "other" && currentType !== "other") {
|
|
92
|
-
shouldSplit = true;
|
|
93
|
-
}
|
|
94
|
-
if (caseSensitive && currentType !== "other" && !previousIsUpper && isUpperCaseChar) {
|
|
95
|
-
shouldSplit = true;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (shouldSplit) {
|
|
99
|
-
result.push(currentSegment);
|
|
100
|
-
currentSegment = char;
|
|
101
|
-
} else {
|
|
102
|
-
currentSegment += char;
|
|
103
|
-
}
|
|
104
|
-
previousType = currentType;
|
|
105
|
-
if (caseSensitive) {
|
|
106
|
-
previousIsUpper = isUpperCaseChar;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (currentSegment && currentSegment.length > 0) {
|
|
110
|
-
result.push(currentSegment);
|
|
111
|
-
}
|
|
112
|
-
return result.length > 0 ? result : [s];
|
|
113
|
-
}, "handleScriptTransitions");
|
|
114
|
-
const splitCamelCaseFast = /* @__PURE__ */ __name((s, knownAcronyms = /* @__PURE__ */ new Set()) => {
|
|
115
|
-
if (s.length === 0) {
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
if (s.toUpperCase() === s) {
|
|
119
|
-
return [s];
|
|
120
|
-
}
|
|
121
|
-
let start = 0;
|
|
122
|
-
const tokens = [];
|
|
123
|
-
const width = s.length;
|
|
124
|
-
for (let index = 1; index < width; index++) {
|
|
125
|
-
const previousCode = s.codePointAt(index - 1);
|
|
126
|
-
const currentCode = s.codePointAt(index);
|
|
127
|
-
if (knownAcronyms.size > 0) {
|
|
128
|
-
for (const acronym of knownAcronyms) {
|
|
129
|
-
if (s.startsWith(acronym, start)) {
|
|
130
|
-
tokens.push(acronym);
|
|
131
|
-
start += acronym.length;
|
|
132
|
-
index = start - 1;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (index < start) {
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const previousIsUpper = previousCode && previousCode < 128 && isUpper(previousCode);
|
|
141
|
-
const currentIsUpper = currentCode && currentCode < 128 && isUpper(currentCode);
|
|
142
|
-
const previousIsLower = previousCode && previousCode < 128 && isLower(previousCode);
|
|
143
|
-
const previousIsDigit = previousCode && previousCode < 128 && isDigit(previousCode);
|
|
144
|
-
const currentIsDigit = currentCode && currentCode < 128 && isDigit(currentCode);
|
|
145
|
-
if (previousIsLower && currentIsUpper) {
|
|
146
|
-
tokens.push(s.slice(start, index));
|
|
147
|
-
start = index;
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (previousIsDigit && !currentIsDigit || !previousIsDigit && currentIsDigit) {
|
|
151
|
-
tokens.push(s.slice(start, index));
|
|
152
|
-
start = index;
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
if (currentIsDigit && !previousIsDigit) {
|
|
156
|
-
let isNextUpper = false;
|
|
157
|
-
let isNextDigit = false;
|
|
158
|
-
if (index + 1 < width) {
|
|
159
|
-
const nextCode = s.codePointAt(index + 1);
|
|
160
|
-
isNextUpper = nextCode && nextCode < 128 && isUpper(nextCode);
|
|
161
|
-
isNextDigit = nextCode && nextCode < 128 && isDigit(nextCode);
|
|
162
|
-
}
|
|
163
|
-
if (!isNextDigit && isNextUpper) {
|
|
164
|
-
tokens.push(s.slice(start, index), s.slice(index, index + 1));
|
|
165
|
-
start = index + 1;
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (index + 1 < width) {
|
|
170
|
-
const nextCode = s.codePointAt(index + 1);
|
|
171
|
-
const nextIsLower = nextCode && nextCode < 128 && isLower(nextCode);
|
|
172
|
-
if (previousIsUpper && currentIsUpper && nextIsLower) {
|
|
173
|
-
const candidate = s.slice(start, index + 1);
|
|
174
|
-
if (!knownAcronyms.has(candidate)) {
|
|
175
|
-
tokens.push(s.slice(start, index));
|
|
176
|
-
start = index;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (start < width) {
|
|
182
|
-
tokens.push(s.slice(start));
|
|
183
|
-
}
|
|
184
|
-
return tokens.filter((token) => token !== "");
|
|
185
|
-
}, "splitCamelCaseFast");
|
|
186
|
-
const splitCamelCaseLocale = /* @__PURE__ */ __name((s, locale, knownAcronyms) => {
|
|
187
|
-
if (s.length === 0) {
|
|
188
|
-
return [];
|
|
189
|
-
}
|
|
190
|
-
const isUpperCase = s === s.toLocaleUpperCase(locale);
|
|
191
|
-
if (locale.startsWith("de")) {
|
|
192
|
-
if (!isUpperCase && s.replaceAll("ß", "SS") === s.toLocaleUpperCase(locale)) {
|
|
193
|
-
return [s];
|
|
194
|
-
}
|
|
195
|
-
const chars2 = [...s];
|
|
196
|
-
const width_2 = chars2.length;
|
|
197
|
-
const result2 = [];
|
|
198
|
-
let currentSegment2 = chars2[0];
|
|
199
|
-
let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
|
|
200
|
-
let isInUpperSequence = previousIsUpper2;
|
|
201
|
-
let upperSequenceStart = previousIsUpper2 ? 0 : -1;
|
|
202
|
-
for (let index = 1; index < width_2; index++) {
|
|
203
|
-
const char = chars2[index];
|
|
204
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
205
|
-
if (isUpperCaseChar === previousIsUpper2) {
|
|
206
|
-
currentSegment2 += char;
|
|
207
|
-
} else if (isUpperCaseChar) {
|
|
208
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
209
|
-
result2.push(currentSegment2);
|
|
210
|
-
currentSegment2 = char;
|
|
211
|
-
}
|
|
212
|
-
isInUpperSequence = true;
|
|
213
|
-
upperSequenceStart = index;
|
|
214
|
-
} else {
|
|
215
|
-
if (isInUpperSequence && index - upperSequenceStart > 1) {
|
|
216
|
-
const lastUpperChar = chars2[index - 1];
|
|
217
|
-
const withoutLastUpper = currentSegment2.slice(0, -1);
|
|
218
|
-
if (withoutLastUpper && withoutLastUpper.length > 0) {
|
|
219
|
-
result2.push(withoutLastUpper);
|
|
220
|
-
}
|
|
221
|
-
currentSegment2 = lastUpperChar + char;
|
|
222
|
-
} else {
|
|
223
|
-
currentSegment2 += char;
|
|
224
|
-
}
|
|
225
|
-
isInUpperSequence = false;
|
|
226
|
-
upperSequenceStart = -1;
|
|
227
|
-
}
|
|
228
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
229
|
-
}
|
|
230
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
231
|
-
result2.push(currentSegment2);
|
|
232
|
-
}
|
|
233
|
-
return result2;
|
|
234
|
-
}
|
|
235
|
-
if (locale.startsWith("uk") || locale.startsWith("ru") || locale.startsWith("bg") || locale.startsWith("sr") || locale.startsWith("mk") || locale.startsWith("be")) {
|
|
236
|
-
if (!RE_CYRILLIC.test(s) && !RE_LATIN.test(s)) {
|
|
237
|
-
return [s];
|
|
238
|
-
}
|
|
239
|
-
const chars2 = [...s];
|
|
240
|
-
const width_2 = chars2.length;
|
|
241
|
-
const result2 = [];
|
|
242
|
-
let currentSegment2 = chars2[0];
|
|
243
|
-
let previousType = RE_CYRILLIC.test(chars2[0]) ? 1 : RE_LATIN.test(chars2[0]) ? 2 : 0;
|
|
244
|
-
let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
|
|
245
|
-
for (let index = 1; index < width_2; index++) {
|
|
246
|
-
const char = chars2[index];
|
|
247
|
-
const currentType = RE_CYRILLIC.test(char) ? 1 : RE_LATIN.test(char) ? 2 : 0;
|
|
248
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
249
|
-
if (previousType !== currentType && (previousType === 1 || previousType === 2) && (currentType === 1 || currentType === 2) || currentType === previousType && !previousIsUpper2 && isUpperCaseChar) {
|
|
250
|
-
result2.push(currentSegment2);
|
|
251
|
-
currentSegment2 = char;
|
|
252
|
-
} else {
|
|
253
|
-
currentSegment2 += char;
|
|
254
|
-
}
|
|
255
|
-
previousType = currentType;
|
|
256
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
257
|
-
}
|
|
258
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
259
|
-
result2.push(currentSegment2);
|
|
260
|
-
}
|
|
261
|
-
const finalResult = [];
|
|
262
|
-
for (let index = 0; index < result2.length; index++) {
|
|
263
|
-
if (index < result2.length - 1 && // eslint-disable-next-line security/detect-object-injection
|
|
264
|
-
result2[index].length === 1 && // eslint-disable-next-line security/detect-object-injection
|
|
265
|
-
RE_LATIN.test(result2[index]) && RE_CYRILLIC.test(result2[index + 1][0])) {
|
|
266
|
-
finalResult.push(result2[index] + result2[index + 1]);
|
|
267
|
-
index++;
|
|
268
|
-
} else {
|
|
269
|
-
finalResult.push(result2[index]);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return finalResult;
|
|
273
|
-
}
|
|
274
|
-
if (locale.startsWith("el")) {
|
|
275
|
-
if (!RE_GREEK.test(s) && !RE_LATIN.test(s)) {
|
|
276
|
-
return [s];
|
|
277
|
-
}
|
|
278
|
-
const parts = s.match(RE_GREEK_LATIN_SPLIT) ?? [s];
|
|
279
|
-
const result2 = [];
|
|
280
|
-
const width = parts.length;
|
|
281
|
-
if (width === 1) {
|
|
282
|
-
const part = parts[0];
|
|
283
|
-
if (!part || !RE_GREEK.test(part[0]) || part.length === 1) {
|
|
284
|
-
return [part || s];
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
for (const part of parts) {
|
|
288
|
-
if (!part) {
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
if (!RE_GREEK.test(part[0]) || part.length === 1) {
|
|
292
|
-
result2.push(part);
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
const partLength = part.length;
|
|
296
|
-
let word = part[0];
|
|
297
|
-
let previousIsUpper2 = part[0] === part[0].toLocaleUpperCase(locale);
|
|
298
|
-
for (let index = 1; index < partLength; index++) {
|
|
299
|
-
const char = part[index];
|
|
300
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
301
|
-
if (!previousIsUpper2 && isUpperCaseChar) {
|
|
302
|
-
result2.push(word);
|
|
303
|
-
word = char;
|
|
304
|
-
} else {
|
|
305
|
-
word += char;
|
|
306
|
-
}
|
|
307
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
308
|
-
}
|
|
309
|
-
if (word) {
|
|
310
|
-
result2.push(word);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return result2;
|
|
314
|
-
}
|
|
315
|
-
if (locale.startsWith("ja") || locale.startsWith("ko")) {
|
|
316
|
-
const isJapanese = locale.startsWith("ja");
|
|
317
|
-
const scriptDetectors = isJapanese ? {
|
|
318
|
-
hiragana: /* @__PURE__ */ __name((char) => RE_HIRAGANA.test(char), "hiragana"),
|
|
319
|
-
kanji: /* @__PURE__ */ __name((char) => RE_KANJI.test(char), "kanji"),
|
|
320
|
-
katakana: /* @__PURE__ */ __name((char) => RE_KATAKANA.test(char), "katakana"),
|
|
321
|
-
latin: /* @__PURE__ */ __name((char) => RE_LATIN.test(char), "latin")
|
|
322
|
-
} : {
|
|
323
|
-
hangul: /* @__PURE__ */ __name((char) => RE_HANGUL.test(char), "hangul"),
|
|
324
|
-
latin: /* @__PURE__ */ __name((char) => RE_LATIN.test(char), "latin")
|
|
325
|
-
};
|
|
326
|
-
const particles = /* @__PURE__ */ new Set(["と", "に", "へ", "を", "は", "が", "の", "で", "や", "も"]);
|
|
327
|
-
if (isJapanese) {
|
|
328
|
-
const baseSegments = handleScriptTransitions(
|
|
329
|
-
s,
|
|
330
|
-
scriptDetectors,
|
|
331
|
-
false,
|
|
332
|
-
locale,
|
|
333
|
-
(previousType, currentType) => previousType === "hiragana" && currentType === "katakana" || // hiragana -> katakana
|
|
334
|
-
previousType === "katakana" && currentType === "hiragana" || // katakana -> hiragana
|
|
335
|
-
previousType === "hiragana" && currentType === "latin" || // hiragana -> latin
|
|
336
|
-
previousType === "katakana" && currentType === "latin" || // katakana -> latin
|
|
337
|
-
previousType === "kanji" && currentType === "latin" || // kanji -> latin
|
|
338
|
-
previousType === "latin" && (currentType === "hiragana" || currentType === "katakana" || currentType === "kanji")
|
|
339
|
-
// latin -> japanese
|
|
340
|
-
);
|
|
341
|
-
const result2 = [];
|
|
342
|
-
for (const segment of baseSegments) {
|
|
343
|
-
if (segment.length === 1 && particles.has(segment) && result2.length > 0) {
|
|
344
|
-
result2[result2.length - 1] += segment;
|
|
345
|
-
} else {
|
|
346
|
-
result2.push(segment);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
return result2.length > 0 ? result2 : [s];
|
|
350
|
-
}
|
|
351
|
-
return handleScriptTransitions(
|
|
352
|
-
s,
|
|
353
|
-
scriptDetectors,
|
|
354
|
-
false,
|
|
355
|
-
locale,
|
|
356
|
-
(previousType, currentType) => previousType === "hangul" && currentType === "latin" || // hangul -> latin
|
|
357
|
-
previousType === "latin" && currentType === "hangul"
|
|
358
|
-
// latin -> hangul
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
if (locale.startsWith("sl")) {
|
|
362
|
-
const chars2 = [...s];
|
|
363
|
-
const width_2 = chars2.length;
|
|
364
|
-
const result2 = [];
|
|
365
|
-
let currentSegment2 = chars2[0];
|
|
366
|
-
let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
|
|
367
|
-
for (let index = 1; index < width_2; index++) {
|
|
368
|
-
const char = chars2[index];
|
|
369
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
370
|
-
const isSpecialChar = /[ČŠŽĐ]/i.test(char);
|
|
371
|
-
const nextIsUpper = index < width_2 - 1 && chars2[index + 1] === chars2[index + 1].toLocaleUpperCase(locale);
|
|
372
|
-
if (!previousIsUpper2 && isUpperCaseChar || isSpecialChar && nextIsUpper) {
|
|
373
|
-
result2.push(currentSegment2);
|
|
374
|
-
currentSegment2 = char;
|
|
375
|
-
if (isSpecialChar && nextIsUpper) {
|
|
376
|
-
result2.push(currentSegment2);
|
|
377
|
-
currentSegment2 = "";
|
|
378
|
-
}
|
|
379
|
-
} else {
|
|
380
|
-
currentSegment2 += char;
|
|
381
|
-
}
|
|
382
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
383
|
-
}
|
|
384
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
385
|
-
result2.push(currentSegment2);
|
|
386
|
-
}
|
|
387
|
-
return result2;
|
|
388
|
-
}
|
|
389
|
-
if (locale.startsWith("zh")) {
|
|
390
|
-
return handleScriptTransitions(
|
|
391
|
-
s,
|
|
392
|
-
{
|
|
393
|
-
han: /* @__PURE__ */ __name((char) => RE_KANJI.test(char), "han"),
|
|
394
|
-
latin: /* @__PURE__ */ __name((char) => RE_LATIN.test(char), "latin")
|
|
395
|
-
},
|
|
396
|
-
false,
|
|
397
|
-
locale
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
if (["ar", "fa", "he", "ur"].includes(locale.split("-")[0])) {
|
|
401
|
-
const isRtlChar = /* @__PURE__ */ __name((ch) => RE_HEBREW.test(ch) || RE_ARABIC.test(ch), "isRtlChar");
|
|
402
|
-
return handleScriptTransitions(
|
|
403
|
-
s,
|
|
404
|
-
{
|
|
405
|
-
latin: /* @__PURE__ */ __name((char) => RE_LATIN.test(char), "latin"),
|
|
406
|
-
rtl: /* @__PURE__ */ __name((char) => isRtlChar(char), "rtl")
|
|
407
|
-
},
|
|
408
|
-
false,
|
|
409
|
-
locale
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
if ([
|
|
413
|
-
"am",
|
|
414
|
-
// Amharic
|
|
415
|
-
"bn",
|
|
416
|
-
// Bengali
|
|
417
|
-
"gu",
|
|
418
|
-
// Gujarati
|
|
419
|
-
"hi",
|
|
420
|
-
// Hindi
|
|
421
|
-
"km",
|
|
422
|
-
// Khmer
|
|
423
|
-
"kn",
|
|
424
|
-
// Kannada
|
|
425
|
-
"lo",
|
|
426
|
-
// Lao
|
|
427
|
-
"ml",
|
|
428
|
-
// Malayalam
|
|
429
|
-
"mr",
|
|
430
|
-
// Marathi
|
|
431
|
-
"ne",
|
|
432
|
-
// Nepali
|
|
433
|
-
"or",
|
|
434
|
-
// Oriya
|
|
435
|
-
"pa",
|
|
436
|
-
// Punjabi
|
|
437
|
-
"si",
|
|
438
|
-
// Sinhala
|
|
439
|
-
"ta",
|
|
440
|
-
// Tamil
|
|
441
|
-
"te",
|
|
442
|
-
// Telugu
|
|
443
|
-
"th"
|
|
444
|
-
// Thai
|
|
445
|
-
].includes(locale.split("-")[0])) {
|
|
446
|
-
const isIndicChar = /* @__PURE__ */ __name((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), "isIndicChar");
|
|
447
|
-
return handleScriptTransitions(
|
|
448
|
-
s,
|
|
449
|
-
{
|
|
450
|
-
indic: /* @__PURE__ */ __name((char) => isIndicChar(char), "indic"),
|
|
451
|
-
latin: /* @__PURE__ */ __name((char) => RE_LATIN.test(char), "latin")
|
|
452
|
-
},
|
|
453
|
-
false,
|
|
454
|
-
locale
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
if (["be", "bg", "ru", "sr", "uk"].includes(locale)) {
|
|
458
|
-
return handleScriptTransitions(
|
|
459
|
-
s,
|
|
460
|
-
{
|
|
461
|
-
cyrillic: /* @__PURE__ */ __name((char) => RE_CYRILLIC.test(char), "cyrillic"),
|
|
462
|
-
latin: /* @__PURE__ */ __name((char) => RE_LATIN.test(char), "latin")
|
|
463
|
-
},
|
|
464
|
-
true,
|
|
465
|
-
// Enable case-sensitive splitting
|
|
466
|
-
locale
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
if (["ar", "fa", "he"].includes(locale)) {
|
|
470
|
-
return handleScriptTransitions(
|
|
471
|
-
s,
|
|
472
|
-
{
|
|
473
|
-
latin: /* @__PURE__ */ __name((char) => RE_LATIN.test(char), "latin"),
|
|
474
|
-
rtl: /* @__PURE__ */ __name((char) => RE_HEBREW.test(char) || RE_ARABIC.test(char), "rtl")
|
|
475
|
-
},
|
|
476
|
-
false,
|
|
477
|
-
locale
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
if (locale.startsWith("ko")) {
|
|
481
|
-
return handleScriptTransitions(
|
|
482
|
-
s,
|
|
483
|
-
{
|
|
484
|
-
hangul: /* @__PURE__ */ __name((char) => RE_HANGUL.test(char), "hangul"),
|
|
485
|
-
latin: /* @__PURE__ */ __name((char) => RE_LATIN.test(char), "latin")
|
|
486
|
-
},
|
|
487
|
-
false,
|
|
488
|
-
locale
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
if (locale.startsWith("uz")) {
|
|
492
|
-
if (!RE_CYRILLIC.test(s) && !RE_LATIN.test(s)) {
|
|
493
|
-
return [s];
|
|
494
|
-
}
|
|
495
|
-
const chars2 = [...s];
|
|
496
|
-
const width_2 = chars2.length;
|
|
497
|
-
const result2 = [];
|
|
498
|
-
let currentSegment2 = chars2[0];
|
|
499
|
-
let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
|
|
500
|
-
for (let index = 1; index < width_2; index++) {
|
|
501
|
-
const char = chars2[index];
|
|
502
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
503
|
-
if (RE_UZBEK_LATIN_MODIFIER.test(char) || RE_UZBEK_LATIN_MODIFIER.test(chars2[index - 1])) {
|
|
504
|
-
currentSegment2 += char;
|
|
505
|
-
continue;
|
|
506
|
-
}
|
|
507
|
-
if (!previousIsUpper2 && isUpperCaseChar) {
|
|
508
|
-
result2.push(currentSegment2);
|
|
509
|
-
currentSegment2 = char;
|
|
510
|
-
} else {
|
|
511
|
-
currentSegment2 += char;
|
|
512
|
-
}
|
|
513
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
514
|
-
}
|
|
515
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
516
|
-
result2.push(currentSegment2);
|
|
517
|
-
}
|
|
518
|
-
return result2;
|
|
519
|
-
}
|
|
520
|
-
const chars = [...s];
|
|
521
|
-
const width_ = chars.length;
|
|
522
|
-
const result = [];
|
|
523
|
-
let currentSegment = chars[0];
|
|
524
|
-
let previousIsUpper = chars[0] === chars[0].toLocaleUpperCase(locale);
|
|
525
|
-
for (const acronym of knownAcronyms) {
|
|
526
|
-
if (s.startsWith(acronym)) {
|
|
527
|
-
result.push(acronym);
|
|
528
|
-
currentSegment = chars[acronym.length];
|
|
529
|
-
previousIsUpper = currentSegment === currentSegment.toLocaleUpperCase(locale);
|
|
530
|
-
break;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
for (let index = 1; index < width_; index++) {
|
|
534
|
-
const char = chars[index];
|
|
535
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
536
|
-
let isAcronym = false;
|
|
537
|
-
for (const acronym of knownAcronyms) {
|
|
538
|
-
if (s.startsWith(acronym, index)) {
|
|
539
|
-
result.push(currentSegment, acronym);
|
|
540
|
-
index += acronym.length - 1;
|
|
541
|
-
currentSegment = "";
|
|
542
|
-
isAcronym = true;
|
|
543
|
-
break;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
if (isAcronym) {
|
|
547
|
-
continue;
|
|
548
|
-
}
|
|
549
|
-
if (!previousIsUpper && isUpperCaseChar) {
|
|
550
|
-
result.push(currentSegment);
|
|
551
|
-
currentSegment = char;
|
|
552
|
-
} else {
|
|
553
|
-
currentSegment += char;
|
|
554
|
-
}
|
|
555
|
-
previousIsUpper = isUpperCaseChar;
|
|
556
|
-
}
|
|
557
|
-
if (currentSegment) {
|
|
558
|
-
result.push(currentSegment);
|
|
559
|
-
}
|
|
560
|
-
return result;
|
|
561
|
-
}, "splitCamelCaseLocale");
|
|
562
|
-
const processTextWithAnsiEmoji = /* @__PURE__ */ __name((text, locale, knownAcronyms) => {
|
|
563
|
-
const result = [];
|
|
564
|
-
const segments = RE_FAST_ANSI.test(text) ? text.split(RE_FAST_ANSI).filter(Boolean) : [text];
|
|
565
|
-
for (const seg of segments) {
|
|
566
|
-
if (RE_FAST_ANSI.test(seg)) {
|
|
567
|
-
result.push(seg);
|
|
568
|
-
} else {
|
|
569
|
-
const subs = RE_EMOJI.test(seg) ? splitByEmoji(seg).filter(Boolean) : [seg];
|
|
570
|
-
for (const sub of subs) {
|
|
571
|
-
if (RE_EMOJI.test(sub)) {
|
|
572
|
-
result.push(sub);
|
|
573
|
-
} else {
|
|
574
|
-
if (locale) {
|
|
575
|
-
const normalizedLocale = locale.toLowerCase().split("-")[0];
|
|
576
|
-
result.push(...splitCamelCaseLocale(sub, normalizedLocale, knownAcronyms));
|
|
577
|
-
} else {
|
|
578
|
-
result.push(...splitCamelCaseFast(sub, knownAcronyms));
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
return result;
|
|
585
|
-
}, "processTextWithAnsiEmoji");
|
|
586
|
-
const splitByCase = /* @__PURE__ */ __name((input, options = {}) => {
|
|
587
|
-
if (!input || typeof input !== "string") {
|
|
588
|
-
return [];
|
|
589
|
-
}
|
|
590
|
-
const {
|
|
591
|
-
handleAnsi = false,
|
|
592
|
-
handleEmoji = false,
|
|
593
|
-
knownAcronyms = [],
|
|
594
|
-
locale,
|
|
595
|
-
normalize = false,
|
|
596
|
-
separators,
|
|
597
|
-
stripAnsi: stripAnsiOption = false,
|
|
598
|
-
stripEmoji: stripEmojiOption = false
|
|
599
|
-
} = options;
|
|
600
|
-
const acronymSet = new Set([...knownAcronyms].sort((a, b) => b.length - a.length));
|
|
601
|
-
let cleanedInput = input;
|
|
602
|
-
if (stripAnsiOption) {
|
|
603
|
-
cleanedInput = stripVTControlCharacters(cleanedInput);
|
|
604
|
-
}
|
|
605
|
-
if (stripEmojiOption) {
|
|
606
|
-
cleanedInput = stripEmoji(cleanedInput);
|
|
607
|
-
}
|
|
608
|
-
const separatorRegex = Array.isArray(separators) ? getSeparatorsRegex(separators) : separators instanceof RegExp ? separators : RE_SEPARATORS;
|
|
609
|
-
const parts = cleanedInput.split(separatorRegex).filter(Boolean);
|
|
610
|
-
let tokens = [];
|
|
611
|
-
for (const part of parts) {
|
|
612
|
-
if (handleAnsi || handleEmoji) {
|
|
613
|
-
tokens.push(...processTextWithAnsiEmoji(part, locale, acronymSet));
|
|
614
|
-
} else if (locale) {
|
|
615
|
-
tokens.push(...splitCamelCaseLocale(part, locale, acronymSet));
|
|
616
|
-
} else {
|
|
617
|
-
tokens.push(...splitCamelCaseFast(part, acronymSet));
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
if (normalize) {
|
|
621
|
-
tokens = tokens.map((token) => {
|
|
622
|
-
if (acronymSet.has(token)) {
|
|
623
|
-
return token;
|
|
624
|
-
}
|
|
625
|
-
if (locale && token === token.toLocaleUpperCase(locale)) {
|
|
626
|
-
return token[0] + token.slice(1).toLocaleLowerCase(locale);
|
|
627
|
-
}
|
|
628
|
-
if (token.toUpperCase() === token && !acronymSet.has(token)) {
|
|
629
|
-
return token.slice(0, 1) + token.slice(1).toLowerCase();
|
|
630
|
-
}
|
|
631
|
-
return token;
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
return tokens;
|
|
635
|
-
}, "splitByCase");
|
|
636
|
-
|
|
637
|
-
export { splitByCase };
|
|
1
|
+
var D=Object.defineProperty;var m=(t,s)=>D(t,"name",{value:s,configurable:!0});import{stripVTControlCharacters as z}from"node:util";import{j as I,s as F,k as J,R as j,l as k,m as C,n as W,o as Y,p as $,q as N,r as V,t as B,u as O,v as S,w as q,x as Z,y as Q,z as X,A as tt,B as et,C as st,D as at,E as nt,F as rt,G as lt,H as ot,I as it,J as ct,K as pt,L as ft,M as x}from"../packem_shared/constants-Cd17VNEv.mjs";import ht from"../packem_shared/LRUCache-Bjo6gsbC.mjs";var ut=Object.defineProperty,gt=m((t,s)=>ut(t,"name",{value:s,configurable:!0}),"g");const T=new ht(1e3),At=gt(t=>{const s=t.join("");if(T.has(s))return T.get(s);const p=t.map(R=>R.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),u=new RegExp(p,"g");return T.set(s,u),u},"getSeparatorsRegex");var Et=Object.defineProperty,Rt=m((t,s)=>Et(t,"name",{value:s,configurable:!0}),"t");const Lt=Rt(t=>{const s=[];let p=0,u;for(I.lastIndex=0;(u=I.exec(t))!==null;)u.index>p&&s.push(t.slice(p,u.index)),s.push(u[0]),p=I.lastIndex;return p<t.length&&s.push(t.slice(p)),s.filter(Boolean)},"splitByEmoji");var Ct=Object.defineProperty,g=m((t,s)=>Ct(t,"name",{value:s,configurable:!0}),"u");const G=new Uint8Array(128),K=new Uint8Array(128),M=new Uint8Array(128);for(let t=0;t<128;t++)G[t]=t>=65&&t<=90?1:0,K[t]=t>=97&&t<=122?1:0,M[t]=t>=48&&t<=57?1:0;const y=g(t=>G[t],"isUpper"),v=g(t=>K[t],"isLower"),w=g(t=>M[t],"isDigit"),_=g((t,s,p,u,R)=>{if(t.length===0)return[];let c=!1;for(const r of Object.values(s))if(r(t[0])){c=!0;break}if(!c&&!p)return[t];const A=[...t],h=[];let L=A[0],e="other";for(const[r,a]of Object.entries(s))if(a(A[0])){e=r;break}let l=p&&u?A[0]===A[0].toLocaleUpperCase(u):!1;for(let r=1;r<A.length;r++){const a=A[r];let o="other";for(const[f,E]of Object.entries(s))if(E(a)){o=f;break}const i=p&&u?a===a.toLocaleUpperCase(u):!1;let n=!1;R?n=R(e,o,l,i,a,r,A):(e!==o&&e!=="other"&&o!=="other"&&(n=!0),p&&o!=="other"&&!l&&i&&(n=!0)),n?(h.push(L),L=a):L+=a,e=o,p&&(l=i)}return L&&L.length>0&&h.push(L),h.length>0?h:[t]},"handleScriptTransitions"),H=g((t,s=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let p=0;const u=[],R=t.length;for(let c=1;c<R;c++){const A=t.codePointAt(c-1),h=t.codePointAt(c);if(s.size>0){for(const o of s)if(t.startsWith(o,p)){u.push(o),p+=o.length,c=p-1;break}if(c<p)continue}const L=A&&A<128&&y(A),e=h&&h<128&&y(h),l=A&&A<128&&v(A),r=A&&A<128&&w(A),a=h&&h<128&&w(h);if(l&&e){u.push(t.slice(p,c)),p=c;continue}if(r&&!a||!r&&a){u.push(t.slice(p,c)),p=c;continue}if(a&&!r){let o=!1,i=!1;if(c+1<R){const n=t.codePointAt(c+1);o=n&&n<128&&y(n),i=n&&n<128&&w(n)}if(!i&&o){u.push(t.slice(p,c),t.slice(c,c+1)),p=c+1;continue}}if(c+1<R){const o=t.codePointAt(c+1),i=o&&o<128&&v(o);if(L&&e&&i){const n=t.slice(p,c+1);s.has(n)||(u.push(t.slice(p,c)),p=c)}}}return p<R&&u.push(t.slice(p)),u.filter(c=>c!=="")},"splitCamelCaseFast"),P=g((t,s,p)=>{if(t.length===0)return[];const u=t===t.toLocaleUpperCase(s);if(s.startsWith("de")){if(!u&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(s))return[t];const e=[...t],l=e.length,r=[];let a=e[0],o=e[0]===e[0].toLocaleUpperCase(s),i=o,n=o?0:-1;for(let f=1;f<l;f++){const E=e[f],U=E===E.toLocaleUpperCase(s);if(U===o)a+=E;else if(U)a&&a.length>0&&(r.push(a),a=E),i=!0,n=f;else{if(i&&f-n>1){const d=e[f-1],b=a.slice(0,-1);b&&b.length>0&&r.push(b),a=d+E}else a+=E;i=!1,n=-1}o=U}return a&&a.length>0&&r.push(a),r}if(s.startsWith("uk")||s.startsWith("ru")||s.startsWith("bg")||s.startsWith("sr")||s.startsWith("mk")||s.startsWith("be")){if(!k.test(t)&&!C.test(t))return[t];const e=[...t],l=e.length,r=[];let a=e[0],o=k.test(e[0])?1:C.test(e[0])?2:0,i=e[0]===e[0].toLocaleUpperCase(s);for(let f=1;f<l;f++){const E=e[f],U=k.test(E)?1:C.test(E)?2:0,d=E===E.toLocaleUpperCase(s);o!==U&&(o===1||o===2)&&(U===1||U===2)||U===o&&!i&&d?(r.push(a),a=E):a+=E,o=U,i=d}a&&a.length>0&&r.push(a);const n=[];for(let f=0;f<r.length;f++)f<r.length-1&&r[f].length===1&&C.test(r[f])&&k.test(r[f+1][0])?(n.push(r[f]+r[f+1]),f++):n.push(r[f]);return n}if(s.startsWith("el")){if(!W.test(t)&&!C.test(t))return[t];const e=t.match(Y)??[t],l=[];if(e.length===1){const r=e[0];if(!r||!W.test(r[0])||r.length===1)return[r||t]}for(const r of e){if(!r)continue;if(!W.test(r[0])||r.length===1){l.push(r);continue}const a=r.length;let o=r[0],i=r[0]===r[0].toLocaleUpperCase(s);for(let n=1;n<a;n++){const f=r[n],E=f===f.toLocaleUpperCase(s);!i&&E?(l.push(o),o=f):o+=f,i=E}o&&l.push(o)}return l}if(s.startsWith("ja")||s.startsWith("ko")){const e=s.startsWith("ja"),l=e?{hiragana:g(a=>V.test(a),"hiragana"),kanji:g(a=>N.test(a),"kanji"),katakana:g(a=>$.test(a),"katakana"),latin:g(a=>C.test(a),"latin")}:{hangul:g(a=>B.test(a),"hangul"),latin:g(a=>C.test(a),"latin")},r=new Set(["と","に","へ","を","は","が","の","で","や","も"]);if(e){const a=_(t,l,!1,s,(i,n)=>i==="hiragana"&&n==="katakana"||i==="katakana"&&n==="hiragana"||i==="hiragana"&&n==="latin"||i==="katakana"&&n==="latin"||i==="kanji"&&n==="latin"||i==="latin"&&(n==="hiragana"||n==="katakana"||n==="kanji")),o=[];for(const i of a)i.length===1&&r.has(i)&&o.length>0?o[o.length-1]+=i:o.push(i);return o.length>0?o:[t]}return _(t,l,!1,s,(a,o)=>a==="hangul"&&o==="latin"||a==="latin"&&o==="hangul")}if(s.startsWith("sl")){const e=[...t],l=e.length,r=[];let a=e[0],o=e[0]===e[0].toLocaleUpperCase(s);for(let i=1;i<l;i++){const n=e[i],f=n===n.toLocaleUpperCase(s),E=/[ČŠŽĐ]/i.test(n),U=i<l-1&&e[i+1]===e[i+1].toLocaleUpperCase(s);!o&&f||E&&U?(r.push(a),a=n,E&&U&&(r.push(a),a="")):a+=n,o=f}return a&&a.length>0&&r.push(a),r}if(s.startsWith("zh"))return _(t,{han:g(e=>N.test(e),"han"),latin:g(e=>C.test(e),"latin")},!1,s);if(["ar","fa","he","ur"].includes(s.split("-")[0])){const e=g(l=>O.test(l)||S.test(l),"isRtlChar");return _(t,{latin:g(l=>C.test(l),"latin"),rtl:g(l=>e(l),"rtl")},!1,s)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(s.split("-")[0])){const e=g(l=>q.test(l)||Z.test(l)||Q.test(l)||X.test(l)||tt.test(l)||et.test(l)||st.test(l)||at.test(l)||nt.test(l)||rt.test(l)||lt.test(l)||ot.test(l)||it.test(l)||ct.test(l)||pt.test(l)||ft.test(l),"isIndicChar");return _(t,{indic:g(l=>e(l),"indic"),latin:g(l=>C.test(l),"latin")},!1,s)}if(["be","bg","ru","sr","uk"].includes(s))return _(t,{cyrillic:g(e=>k.test(e),"cyrillic"),latin:g(e=>C.test(e),"latin")},!0,s);if(["ar","fa","he"].includes(s))return _(t,{latin:g(e=>C.test(e),"latin"),rtl:g(e=>O.test(e)||S.test(e),"rtl")},!1,s);if(s.startsWith("ko"))return _(t,{hangul:g(e=>B.test(e),"hangul"),latin:g(e=>C.test(e),"latin")},!1,s);if(s.startsWith("uz")){if(!k.test(t)&&!C.test(t))return[t];const e=[...t],l=e.length,r=[];let a=e[0],o=e[0]===e[0].toLocaleUpperCase(s);for(let i=1;i<l;i++){const n=e[i],f=n===n.toLocaleUpperCase(s);if(x.test(n)||x.test(e[i-1])){a+=n;continue}!o&&f?(r.push(a),a=n):a+=n,o=f}return a&&a.length>0&&r.push(a),r}const R=[...t],c=R.length,A=[];let h=R[0],L=R[0]===R[0].toLocaleUpperCase(s);for(const e of p)if(t.startsWith(e)){A.push(e),h=R[e.length],L=h===h.toLocaleUpperCase(s);break}for(let e=1;e<c;e++){const l=R[e],r=l===l.toLocaleUpperCase(s);let a=!1;for(const o of p)if(t.startsWith(o,e)){A.push(h,o),e+=o.length-1,h="",a=!0;break}a||(!L&&r?(A.push(h),h=l):h+=l,L=r)}return h&&A.push(h),A},"splitCamelCaseLocale"),Ut=g((t,s,p)=>{const u=[],R=j.test(t)?t.split(j).filter(Boolean):[t];for(const c of R)if(j.test(c))u.push(c);else{const A=I.test(c)?Lt(c).filter(Boolean):[c];for(const h of A)if(I.test(h))u.push(h);else if(s){const L=s.toLowerCase().split("-")[0];u.push(...P(h,L,p))}else u.push(...H(h,p))}return u},"processTextWithAnsiEmoji"),mt=g((t,s={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:p=!1,handleEmoji:u=!1,knownAcronyms:R=[],locale:c,normalize:A=!1,separators:h,stripAnsi:L=!1,stripEmoji:e=!1}=s,l=new Set([...R].sort((n,f)=>f.length-n.length));let r=t;L&&(r=z(r)),e&&(r=F(r));const a=Array.isArray(h)?At(h):h instanceof RegExp?h:J,o=r.split(a).filter(Boolean);let i=[];for(const n of o)p||u?i.push(...Ut(n,c,l)):c?i.push(...P(n,c,l)):i.push(...H(n,l));return A&&(i=i.map(n=>l.has(n)?n:c&&n===n.toLocaleUpperCase(c)?n[0]+n.slice(1).toLocaleLowerCase(c):n.toUpperCase()===n&&!l.has(n)?n.slice(0,1)+n.slice(1).toLowerCase():n)),i},"splitByCase");export{mt as splitByCase};
|