@base-web-kits/base-tools-ts 0.0.3 → 0.0.5

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 (51) hide show
  1. package/README.md +31 -2
  2. package/dist/array/index.d.ts +9 -0
  3. package/dist/array/index.d.ts.map +1 -0
  4. package/dist/async/index.d.ts +14 -0
  5. package/dist/async/index.d.ts.map +1 -0
  6. package/dist/bean/EventBus.d.ts +30 -0
  7. package/dist/bean/EventBus.d.ts.map +1 -0
  8. package/dist/bean/index.d.ts +2 -0
  9. package/dist/bean/index.d.ts.map +1 -0
  10. package/dist/day/index.d.ts +100 -0
  11. package/dist/day/index.d.ts.map +1 -0
  12. package/dist/index.d.ts +15 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +1140 -0
  15. package/dist/lodash/index.d.ts +5 -0
  16. package/dist/lodash/index.d.ts.map +1 -0
  17. package/dist/number/big.d.ts +137 -0
  18. package/dist/number/big.d.ts.map +1 -0
  19. package/dist/number/format.d.ts +88 -0
  20. package/dist/number/format.d.ts.map +1 -0
  21. package/dist/number/index.d.ts +4 -0
  22. package/dist/number/index.d.ts.map +1 -0
  23. package/dist/number/random.d.ts +33 -0
  24. package/dist/number/random.d.ts.map +1 -0
  25. package/dist/object/index.d.ts +11 -0
  26. package/dist/object/index.d.ts.map +1 -0
  27. package/dist/string/format.d.ts +33 -0
  28. package/dist/string/format.d.ts.map +1 -0
  29. package/dist/string/index.d.ts +4 -0
  30. package/dist/string/index.d.ts.map +1 -0
  31. package/dist/string/other.d.ts +15 -0
  32. package/dist/string/other.d.ts.map +1 -0
  33. package/dist/string/random.d.ts +27 -0
  34. package/dist/string/random.d.ts.map +1 -0
  35. package/dist/typing/index.d.ts +134 -0
  36. package/dist/typing/index.d.ts.map +1 -0
  37. package/dist/url/file/index.d.ts +22 -0
  38. package/dist/url/file/index.d.ts.map +1 -0
  39. package/dist/url/index.d.ts +5 -0
  40. package/dist/url/index.d.ts.map +1 -0
  41. package/dist/url/oss/index.d.ts +77 -0
  42. package/dist/url/oss/index.d.ts.map +1 -0
  43. package/dist/url/param/index.d.ts +49 -0
  44. package/dist/url/param/index.d.ts.map +1 -0
  45. package/dist/url/qn/index.d.ts +58 -0
  46. package/dist/url/qn/index.d.ts.map +1 -0
  47. package/dist/validator/index.d.ts +296 -0
  48. package/dist/validator/index.d.ts.map +1 -0
  49. package/package.json +9 -7
  50. package/index.d.ts +0 -1
  51. package/index.js +0 -1
package/dist/index.js ADDED
@@ -0,0 +1,1140 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+
19
+ // src/ts/index.ts
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ BigNumber: () => BigNumber,
23
+ appendUrlParam: () => appendUrlParam,
24
+ arrayMove: () => arrayMove,
25
+ big: () => big,
26
+ bigAdd: () => bigAdd,
27
+ bigCompare: () => bigCompare,
28
+ bigDiv: () => bigDiv,
29
+ bigEqual: () => bigEqual,
30
+ bigGt: () => bigGt,
31
+ bigGte: () => bigGte,
32
+ bigLt: () => bigLt,
33
+ bigLte: () => bigLte,
34
+ bigMul: () => bigMul,
35
+ bigPow: () => bigPow,
36
+ bigRound: () => bigRound,
37
+ bigSub: () => bigSub,
38
+ buildOssUrl: () => buildOssUrl,
39
+ createRandId: () => createRandId,
40
+ createTimeRandId: () => createTimeRandId,
41
+ createUuid: () => createUuid,
42
+ dayjs: () => dayjs,
43
+ getAgeByBirthdate: () => getAgeByBirthdate,
44
+ getCountdownParts: () => getCountdownParts,
45
+ getDateRangeAfter: () => getDateRangeAfter,
46
+ getDateRangeBefore: () => getDateRangeBefore,
47
+ getFileSuffix: () => getFileSuffix,
48
+ getFileType: () => getFileType,
49
+ getObjectKeys: () => getObjectKeys,
50
+ getOssAudio: () => getOssAudio,
51
+ getOssHls: () => getOssHls,
52
+ getOssImg: () => getOssImg,
53
+ getOssVideo: () => getOssVideo,
54
+ getQnAudio: () => getQnAudio,
55
+ getQnHls: () => getQnHls,
56
+ getQnImg: () => getQnImg,
57
+ getQnVideo: () => getQnVideo,
58
+ getStringByteLength: () => getStringByteLength,
59
+ getUrlNumber: () => getUrlNumber,
60
+ getUrlParam: () => getUrlParam,
61
+ getUrlParamAll: () => getUrlParamAll,
62
+ isBankCard: () => isBankCard,
63
+ isChinese: () => isChinese,
64
+ isChineseName: () => isChineseName,
65
+ isDigits: () => isDigits,
66
+ isEmail: () => isEmail,
67
+ isHKMOPermit: () => isHKMOPermit,
68
+ isHexColor: () => isHexColor,
69
+ isIP: () => isIP,
70
+ isIPRange: () => isIPRange,
71
+ isIPv6: () => isIPv6,
72
+ isIdentityCard: () => isIdentityCard,
73
+ isJSON: () => isJSON,
74
+ isLandline: () => isLandline,
75
+ isLatitude: () => isLatitude,
76
+ isLetter: () => isLetter,
77
+ isLicensePlate: () => isLicensePlate,
78
+ isLongitude: () => isLongitude,
79
+ isMilitaryId: () => isMilitaryId,
80
+ isMobilePhone: () => isMobilePhone,
81
+ isNumeric: () => isNumeric,
82
+ isOfficerId: () => isOfficerId,
83
+ isPassport: () => isPassport,
84
+ isPhone: () => isPhone,
85
+ isPortNumber: () => isPortNumber,
86
+ isSoldierId: () => isSoldierId,
87
+ isTaiwanPermit: () => isTaiwanPermit,
88
+ isTaxID: () => isTaxID,
89
+ isURL: () => isURL,
90
+ randomBoolean: () => randomBoolean,
91
+ randomFloat: () => randomFloat,
92
+ randomInt: () => randomInt,
93
+ toAsync: () => toAsync,
94
+ toChineseCurrency: () => toChineseCurrency,
95
+ toChineseNum: () => toChineseNum,
96
+ toDayjs: () => toDayjs,
97
+ toFixed: () => toFixed,
98
+ toMaskName: () => toMaskName,
99
+ toMaskPhone: () => toMaskPhone,
100
+ toMaskText: () => toMaskText,
101
+ toThousandth: () => toThousandth,
102
+ withDistance: () => withDistance,
103
+ withUnit: () => withUnit,
104
+ withUnitPx: () => withUnitPx,
105
+ zeroPad: () => zeroPad
106
+ });
107
+
108
+ // src/ts/array/index.ts
109
+ function arrayMove(list, fromIndex, toIndex) {
110
+ const newList = [...list];
111
+ const [removed] = newList.splice(fromIndex, 1);
112
+ newList.splice(toIndex, 0, removed);
113
+ return newList;
114
+ }
115
+
116
+ // src/ts/async/index.ts
117
+ async function toAsync(p) {
118
+ try {
119
+ const data = await p;
120
+ return [data, null];
121
+ } catch (err) {
122
+ return [null, err];
123
+ }
124
+ }
125
+
126
+ // src/ts/day/index.ts
127
+ import dayjs from "dayjs";
128
+ import customParseFormat from "dayjs/plugin/customParseFormat";
129
+ import utc from "dayjs/plugin/utc";
130
+ import timezone from "dayjs/plugin/timezone";
131
+ import relativeTime from "dayjs/plugin/relativeTime";
132
+ import advancedFormat from "dayjs/plugin/advancedFormat";
133
+ import "dayjs/locale/zh-cn";
134
+
135
+ // src/ts/number/big.ts
136
+ import BigNumber from "bignumber.js";
137
+ function big(x) {
138
+ return x instanceof BigNumber ? x : new BigNumber(x);
139
+ }
140
+ function bigAdd(a, ...rest) {
141
+ let acc = big(a);
142
+ for (const x of rest) acc = acc.plus(big(x));
143
+ return acc.toNumber();
144
+ }
145
+ function bigSub(a, ...rest) {
146
+ let acc = big(a);
147
+ for (const x of rest) acc = acc.minus(big(x));
148
+ return acc.toNumber();
149
+ }
150
+ function bigMul(a, ...rest) {
151
+ let acc = big(a);
152
+ for (const x of rest) acc = acc.times(big(x));
153
+ return acc.toNumber();
154
+ }
155
+ function bigDiv(a, ...rest) {
156
+ let acc = big(a);
157
+ for (const x of rest) acc = acc.div(big(x));
158
+ return acc.toNumber();
159
+ }
160
+ function bigPow(x, y) {
161
+ return big(x).pow(big(y)).toNumber();
162
+ }
163
+ function bigRound(x, dp = 0, rm = BigNumber.ROUND_HALF_UP) {
164
+ return big(x).decimalPlaces(dp, rm).toNumber();
165
+ }
166
+ function toFixed(x, dp = 2, rm = BigNumber.ROUND_HALF_UP) {
167
+ return big(x).toFixed(dp, rm);
168
+ }
169
+ function bigCompare(a, b) {
170
+ return big(a).comparedTo(big(b));
171
+ }
172
+ function bigEqual(a, b) {
173
+ return big(a).isEqualTo(big(b));
174
+ }
175
+ function bigGt(a, b) {
176
+ return big(a).isGreaterThan(big(b));
177
+ }
178
+ function bigGte(a, b) {
179
+ return big(a).isGreaterThanOrEqualTo(big(b));
180
+ }
181
+ function bigLt(a, b) {
182
+ return big(a).isLessThan(big(b));
183
+ }
184
+ function bigLte(a, b) {
185
+ return big(a).isLessThanOrEqualTo(big(b));
186
+ }
187
+
188
+ // src/ts/number/format.ts
189
+ function zeroPad(n, len = 2) {
190
+ return String(n).padStart(len, "0");
191
+ }
192
+ function withUnit(num, unit = "") {
193
+ if (num === null || num === void 0 || num === "") return "";
194
+ if (typeof num === "number") return `${num}${unit}`;
195
+ const str = String(num).trim();
196
+ if (str === "") return "";
197
+ return isNaN(+str) ? str : `${str}${unit}`;
198
+ }
199
+ function withUnitPx(num) {
200
+ return withUnit(num, "px");
201
+ }
202
+ function withDistance(m) {
203
+ const n = Number(m ?? 0);
204
+ if (!Number.isFinite(n)) return "0m";
205
+ return n >= 1e3 ? `${+(n / 1e3).toFixed(2)}km` : `${+n.toFixed(2)}m`;
206
+ }
207
+ function toThousandth(str) {
208
+ const v = String(str ?? "").trim();
209
+ if (v === "") return "";
210
+ let sign = "";
211
+ let num = v;
212
+ if (num[0] === "-" || num[0] === "+") {
213
+ sign = num[0];
214
+ num = num.slice(1);
215
+ }
216
+ const [intPart, decPart] = num.split(".");
217
+ const groupedInt = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
218
+ return decPart !== void 0 && decPart !== "" ? `${sign}${groupedInt}.${decPart}` : `${sign}${groupedInt}`;
219
+ }
220
+ function toChineseNum(num) {
221
+ const numInt = Math.trunc(+num);
222
+ if (numInt === 0) return "\u96F6";
223
+ const digit = ["\u96F6", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u4E03", "\u516B", "\u4E5D"];
224
+ const unit = ["", "\u5341", "\u767E", "\u5343"];
225
+ const bigUnit = ["", "\u4E07", "\u4EBF", "\u5146"];
226
+ const section4 = (n2) => {
227
+ let str = "", zeroFlag = false;
228
+ for (let i = 0; i < 4; i++) {
229
+ const d = n2 % 10;
230
+ n2 = Math.floor(n2 / 10);
231
+ if (d === 0) {
232
+ zeroFlag = true;
233
+ continue;
234
+ }
235
+ if (zeroFlag) str = digit[0] + str;
236
+ str = digit[d] + unit[i] + str;
237
+ zeroFlag = false;
238
+ }
239
+ return str;
240
+ };
241
+ let res = "";
242
+ let sectionIndex = 0;
243
+ let n = Math.abs(numInt);
244
+ while (n > 0) {
245
+ const seg = n % 1e4;
246
+ n = Math.floor(n / 1e4);
247
+ if (seg) {
248
+ const segStr = section4(seg);
249
+ res = segStr + (sectionIndex ? bigUnit[sectionIndex] : "") + res;
250
+ } else if (res && !res.startsWith("\u96F6")) {
251
+ res = `\u96F6${res}`;
252
+ }
253
+ sectionIndex++;
254
+ }
255
+ res = res.replace(/^一十/, "\u5341");
256
+ return numInt < 0 ? `\u8D1F${res}` : res;
257
+ }
258
+ function toChineseCurrency(amount, opts = {}) {
259
+ const dp = opts.precision ?? 2;
260
+ const rm = opts.rm ?? BigNumber.ROUND_HALF_UP;
261
+ const yuan = opts.yuanChar ?? "\u5143";
262
+ if (amount === null || amount === void 0) return "";
263
+ const bn = new BigNumber(amount);
264
+ if (!bn.isFinite()) return "";
265
+ const s = bn.toFixed(dp, rm);
266
+ const sign = s.startsWith("-") ? "\u8D1F" : "";
267
+ const [intStr, decStr = ""] = s.replace(/^-/, "").split(".");
268
+ const digit = ["\u96F6", "\u58F9", "\u8D30", "\u53C1", "\u8086", "\u4F0D", "\u9646", "\u67D2", "\u634C", "\u7396"];
269
+ const unit = ["", "\u62FE", "\u4F70", "\u4EDF"];
270
+ const bigUnit = ["", "\u4E07", "\u4EBF", "\u5146"];
271
+ const smallUnit = ["\u89D2", "\u5206", "\u5398"];
272
+ const section4 = (n) => {
273
+ let str = "";
274
+ let zeroFlag = false;
275
+ for (let i = 0; i < 4; i++) {
276
+ const d = n.mod(10).toNumber();
277
+ n = n.idiv(10);
278
+ if (d === 0) {
279
+ zeroFlag = true;
280
+ continue;
281
+ }
282
+ if (zeroFlag) str = digit[0] + str;
283
+ str = digit[d] + unit[i] + str;
284
+ zeroFlag = false;
285
+ }
286
+ return str.replace(/零+$/g, "");
287
+ };
288
+ const intNum = new BigNumber(intStr);
289
+ let res = "";
290
+ if (intNum.isZero()) {
291
+ res = digit[0];
292
+ } else {
293
+ let n = intNum.abs();
294
+ let sectionIndex = 0;
295
+ while (n.gt(0)) {
296
+ const seg = n.mod(1e4);
297
+ n = n.idiv(1e4);
298
+ if (seg.gt(0)) {
299
+ const segStr = section4(seg);
300
+ const needZero = res && !res.startsWith(digit[0]) && (seg.lt(1e3) || seg.mod(1e3).isZero());
301
+ const bu = sectionIndex ? bigUnit[sectionIndex] : "";
302
+ res = segStr + bu + (needZero ? digit[0] : "") + res;
303
+ } else if (res && !res.startsWith(digit[0])) {
304
+ res = digit[0] + res;
305
+ }
306
+ sectionIndex++;
307
+ }
308
+ res = res.replace(/^壹拾/, "\u62FE");
309
+ }
310
+ let frac = "";
311
+ for (let i = 0; i < Math.min(3, dp); i++) {
312
+ const ch = decStr[i] || "0";
313
+ const d = ch.charCodeAt(0) - 48;
314
+ if (d > 0) frac += digit[d] + smallUnit[i];
315
+ }
316
+ return frac ? `${sign}${res}${yuan}${frac}` : `${sign}${res}${yuan}\u6574`;
317
+ }
318
+
319
+ // src/ts/number/random.ts
320
+ function randomInt(a, b) {
321
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
322
+ throw new TypeError("min \u548C max \u5FC5\u987B\u662F\u6709\u9650\u6570\u503C");
323
+ }
324
+ const low = Math.min(a, b);
325
+ const high = Math.max(a, b);
326
+ const minInt = Math.ceil(low);
327
+ const maxInt = Math.floor(high);
328
+ if (maxInt < minInt) {
329
+ throw new RangeError("\u53D6\u6574\u540E\u533A\u95F4\u4E3A\u7A7A");
330
+ }
331
+ if (maxInt === minInt) return minInt;
332
+ return Math.floor(Math.random() * (maxInt - minInt + 1)) + minInt;
333
+ }
334
+ function randomFloat(a, b) {
335
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
336
+ throw new TypeError("min \u548C max \u5FC5\u987B\u662F\u6709\u9650\u6570\u503C");
337
+ }
338
+ const low = Math.min(a, b);
339
+ const high = Math.max(a, b);
340
+ if (high === low) return low;
341
+ return Math.random() * (high - low) + low;
342
+ }
343
+ function randomBoolean() {
344
+ return Math.random() < 0.5;
345
+ }
346
+
347
+ // src/ts/day/index.ts
348
+ dayjs.extend(customParseFormat);
349
+ dayjs.extend(utc);
350
+ dayjs.extend(timezone);
351
+ dayjs.extend(relativeTime);
352
+ dayjs.extend(advancedFormat);
353
+ dayjs.locale("zh-cn");
354
+ function toDayjs(t, fmt) {
355
+ if (t === null || t === void 0) return dayjs();
356
+ if (typeof t === "number") {
357
+ const s = String(Math.trunc(t));
358
+ return dayjs(s.length === 10 ? t * 1e3 : t, fmt);
359
+ }
360
+ if (typeof t === "string") {
361
+ const s = t.trim();
362
+ if (/^\d{10}$/.test(s)) return dayjs(Number(s) * 1e3, fmt);
363
+ if (/^\d{13}$/.test(s)) return dayjs(Number(s), fmt);
364
+ if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return dayjs(s, fmt || "YYYY-MM-DD");
365
+ if (/^\d{4}\/\d{2}\/\d{2}$/.test(s)) return dayjs(s, fmt || "YYYY/MM/DD");
366
+ if (/^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}$/.test(s))
367
+ return dayjs(s, fmt || "YYYY-MM-DD HH:mm:ss");
368
+ if (/^\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}$/.test(s))
369
+ return dayjs(s, fmt || "YYYY/MM/DD HH:mm:ss");
370
+ return dayjs(s, fmt);
371
+ }
372
+ return dayjs(t, fmt);
373
+ }
374
+ function getDateRangeBefore(offset, fmt = "YYYY-MM-DD") {
375
+ const now = toDayjs(Date.now());
376
+ const n = Math.max(0, Math.trunc(offset));
377
+ const hasTime = /H|h|m|s|S|A|a|x|X/.test(fmt);
378
+ const startDay = now.add(-n, "day");
379
+ const endDay = now;
380
+ const start = (hasTime ? startDay.startOf("day") : startDay).format(fmt);
381
+ const end = (hasTime ? endDay.endOf("day") : endDay).format(fmt);
382
+ return [start, end];
383
+ }
384
+ function getDateRangeAfter(offset, fmt = "YYYY-MM-DD") {
385
+ const now = toDayjs(Date.now());
386
+ const n = Math.max(0, Math.trunc(offset));
387
+ const hasTime = /H|h|m|s|S|A|a|x|X/.test(fmt);
388
+ const startDay = now;
389
+ const endDay = now.add(n, "day");
390
+ const start = (hasTime ? startDay.startOf("day") : startDay).format(fmt);
391
+ const end = (hasTime ? endDay.endOf("day") : endDay).format(fmt);
392
+ return [start, end];
393
+ }
394
+ function getCountdownParts(diff) {
395
+ if (diff <= 0) return { d: "00", h: "00", m: "00", s: "00", ms: "000" };
396
+ const d = Math.floor(diff / (1e3 * 60 * 60 * 24));
397
+ const h = Math.floor(diff / (1e3 * 60 * 60) % 24);
398
+ const m = Math.floor(diff / (1e3 * 60) % 60);
399
+ const s = Math.floor(diff / 1e3 % 60);
400
+ const ms = diff % 1e3;
401
+ return {
402
+ d: zeroPad(d),
403
+ h: zeroPad(h),
404
+ m: zeroPad(m),
405
+ s: zeroPad(s),
406
+ ms: zeroPad(ms, 3)
407
+ };
408
+ }
409
+ function getAgeByBirthdate(birthdate) {
410
+ const birth = toDayjs(birthdate, "YYYY-MM-DD");
411
+ const now = toDayjs(Date.now());
412
+ const totalMonths = (now.year() - birth.year()) * 12 + (now.month() - birth.month());
413
+ const adjustedMonths = now.date() < birth.date() ? totalMonths - 1 : totalMonths;
414
+ if (adjustedMonths >= 12) {
415
+ let age = Math.floor(adjustedMonths / 12);
416
+ const birthdayThisYear = birth.add(age, "year");
417
+ if (now.isBefore(birthdayThisYear)) {
418
+ age--;
419
+ }
420
+ return { age, type: "year" };
421
+ }
422
+ return { age: adjustedMonths, type: "month" };
423
+ }
424
+
425
+ // src/ts/lodash/index.ts
426
+ var lodash_exports = {};
427
+ __reExport(lodash_exports, lodash_es_star);
428
+ import * as lodash_es_star from "lodash-es";
429
+
430
+ // src/ts/index.ts
431
+ __reExport(index_exports, lodash_exports);
432
+
433
+ // src/ts/object/index.ts
434
+ function getObjectKeys(obj) {
435
+ return Object.keys(obj);
436
+ }
437
+
438
+ // src/ts/string/format.ts
439
+ function toMaskText(s, keepLeft = 1, keepRight = 0, maskChar = "*") {
440
+ if (!s) return "";
441
+ const v = String(s);
442
+ const l = Math.max(0, keepLeft);
443
+ const r = Math.max(0, keepRight);
444
+ const len = v.length;
445
+ const left = Math.min(l, len);
446
+ const right = Math.min(r, len - left);
447
+ const mid = len - left - right;
448
+ if (mid <= 0) return v;
449
+ const m = maskChar && maskChar.length > 0 ? maskChar : "*";
450
+ return v.slice(0, left) + m.repeat(mid) + v.slice(len - right);
451
+ }
452
+ function toMaskPhone(phone) {
453
+ return toMaskText(phone, 3, 4);
454
+ }
455
+ function toMaskName(name) {
456
+ if (!name) return "";
457
+ const v = String(name);
458
+ return v.length <= 2 ? toMaskText(v, 1, 0) : toMaskText(v, 1, 1);
459
+ }
460
+
461
+ // src/ts/string/random.ts
462
+ function createUuid() {
463
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
464
+ const r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
465
+ return v.toString(16);
466
+ });
467
+ }
468
+ function createRandId(prefix = "id_") {
469
+ return `${prefix}${Math.random().toString(36).substring(2, 16)}`;
470
+ }
471
+ function createTimeRandId(digits = 6) {
472
+ const base = 10 ** (digits - 1);
473
+ const range = 9 * base;
474
+ const randomInt2 = Math.floor(Math.random() * range) + base;
475
+ return `${Date.now()}${randomInt2}`;
476
+ }
477
+
478
+ // src/ts/string/other.ts
479
+ function getStringByteLength(str) {
480
+ let byteLen = 0;
481
+ for (let i = 0; i < str.length; i++) {
482
+ const code = str.charCodeAt(i);
483
+ if (code <= 127) {
484
+ byteLen += 1;
485
+ } else if (code <= 2047) {
486
+ byteLen += 2;
487
+ } else if (code >= 55296 && code <= 56319) {
488
+ byteLen += 4;
489
+ i++;
490
+ } else {
491
+ byteLen += 3;
492
+ }
493
+ }
494
+ return byteLen;
495
+ }
496
+
497
+ // src/ts/url/file/index.ts
498
+ var FILE_TYPE = {
499
+ img: ["png", "jpg", "jpeg", "gif", "svg", "webp"],
500
+ video: ["mp4", "mov", "m4v"],
501
+ voice: ["mp3", "wav", "m4a"],
502
+ excel: ["csv", "xls", "xlsx", "xlsm", "ods"],
503
+ word: ["txt", "doc", "docx", "pdf", "md", "wps"],
504
+ zip: ["zip", "gz", "tar", "rar", "7z"],
505
+ ppt: ["ppt", "pptx", "odp"],
506
+ app: ["apk", "ipa"]
507
+ };
508
+ function getFileSuffix(fileName) {
509
+ if (fileName.startsWith(".")) return "";
510
+ const idx = fileName.lastIndexOf(".");
511
+ return idx > 0 ? fileName.slice(idx + 1).toLowerCase() : "";
512
+ }
513
+ function getFileType(fileName) {
514
+ const suffix = getFileSuffix(fileName);
515
+ if (!suffix) return "unknown";
516
+ const keys = getObjectKeys(FILE_TYPE);
517
+ for (const key of keys) {
518
+ if (FILE_TYPE[key].includes(suffix)) {
519
+ return key;
520
+ }
521
+ }
522
+ return "unknown";
523
+ }
524
+
525
+ // src/ts/url/oss/index.ts
526
+ function getOssImg(src, option) {
527
+ return buildOssUrl(src, "image", option);
528
+ }
529
+ function getOssVideo(src, option) {
530
+ return buildOssUrl(src, "video", option);
531
+ }
532
+ function getOssAudio(src, option) {
533
+ return buildOssUrl(src, "audio", option);
534
+ }
535
+ function getOssHls(src, option) {
536
+ return buildOssUrl(src, "hls", option);
537
+ }
538
+ function buildOssUrl(src, type, option) {
539
+ if (!src || !option) return src;
540
+ if (src.startsWith("blob:")) return src;
541
+ if (src.includes(".svg")) return src;
542
+ const segs = [];
543
+ for (const [k, v] of Object.entries(option)) {
544
+ const seg = k === "watermark" ? getWatermark(v) : getOssSegs(k, v);
545
+ if (seg) segs.push(seg);
546
+ }
547
+ if (!segs.length) return src;
548
+ const base = src.split("?")[0];
549
+ return `${base}?x-oss-process=${type}/${segs.join("/")}`;
550
+ }
551
+ function getOssSegs(type, option) {
552
+ if (!option && option !== 0) return "";
553
+ if (option === true) return type;
554
+ if (typeof option === "number" || typeof option === "string") return `${type},${option}`;
555
+ const segs = Object.entries(option).map(([k, v]) => `${k}_${v}`).join(",");
556
+ return segs ? `${type},${segs}` : "";
557
+ }
558
+ function getWatermark(w) {
559
+ if (!w) return "";
560
+ if (w.image) w.image = toBase64Url(w.image);
561
+ if (w.text) w.text = toBase64Url(w.text);
562
+ if (w.type) w.type = toBase64Url(w.type);
563
+ return getOssSegs("watermark", w);
564
+ }
565
+ function toBase64Url(s) {
566
+ let b64 = "";
567
+ if (typeof Buffer !== "undefined") {
568
+ const buf = Buffer.from(s, "utf-8");
569
+ b64 = buf.toString("base64");
570
+ } else {
571
+ try {
572
+ b64 = btoa(unescape(encodeURIComponent(s)));
573
+ } catch {
574
+ b64 = "";
575
+ }
576
+ }
577
+ return b64.replace(/=+$/g, "").replace(/\+/g, "-").replace(/\//g, "_");
578
+ }
579
+
580
+ // src/ts/url/param/index.ts
581
+ function getUrlParam(key, url) {
582
+ const raw = url.includes("?") ? url.slice(url.indexOf("?") + 1) : url.includes("=") ? url : "";
583
+ const qs = raw.split("#")[0];
584
+ if (!qs) return null;
585
+ const pairs = qs.split("&").filter(Boolean);
586
+ const decode = (s) => {
587
+ try {
588
+ return decodeURIComponent(s.replace(/\+/g, " "));
589
+ } catch {
590
+ return s;
591
+ }
592
+ };
593
+ for (const pair of pairs) {
594
+ const i = pair.indexOf("=");
595
+ const k = i >= 0 ? pair.slice(0, i) : pair;
596
+ if (decode(k) === key) {
597
+ const v = i >= 0 ? decode(pair.slice(i + 1)) : "";
598
+ return v !== "null" && v !== "undefined" ? v : null;
599
+ }
600
+ }
601
+ return null;
602
+ }
603
+ function getUrlNumber(key, url) {
604
+ const str = getUrlParam(key, url);
605
+ if (!str) return null;
606
+ const num = Number(str);
607
+ return isNaN(num) ? null : num;
608
+ }
609
+ function getUrlParamAll(url) {
610
+ const raw = url.includes("?") ? url.slice(url.indexOf("?") + 1) : url.includes("=") ? url : "";
611
+ const qs = raw.split("#")[0];
612
+ const result = {};
613
+ if (!qs) return result;
614
+ const decode = (s) => {
615
+ try {
616
+ return decodeURIComponent(s.replace(/\+/g, " "));
617
+ } catch {
618
+ return s;
619
+ }
620
+ };
621
+ for (const seg of qs.split("&")) {
622
+ if (!seg) continue;
623
+ const i = seg.indexOf("=");
624
+ const k = i >= 0 ? seg.slice(0, i) : seg;
625
+ const v = i >= 0 ? seg.slice(i + 1) : "";
626
+ const dv = decode(v);
627
+ if (dv !== "null" && dv !== "undefined") {
628
+ result[decode(k)] = dv;
629
+ }
630
+ }
631
+ return result;
632
+ }
633
+ function appendUrlParam(url, param) {
634
+ if (!param || typeof param !== "object") return url;
635
+ const hashIndex = url.indexOf("#");
636
+ const baseWithoutHash = hashIndex >= 0 ? url.slice(0, hashIndex) : url;
637
+ const hash = hashIndex >= 0 ? url.slice(hashIndex) : "";
638
+ const [base, existingQs] = baseWithoutHash.split("?");
639
+ const parts = [];
640
+ if (existingQs) parts.push(existingQs);
641
+ for (const key in param) {
642
+ const rawVal = param[key];
643
+ if (rawVal === null || rawVal === void 0) continue;
644
+ const val = typeof rawVal === "object" ? JSON.stringify(rawVal) : String(rawVal);
645
+ parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(val)}`);
646
+ }
647
+ const qs = parts.filter(Boolean).join("&");
648
+ return base + (qs ? `?${qs}` : "") + hash;
649
+ }
650
+
651
+ // src/ts/url/qn/index.ts
652
+ function getQnImg(src, option) {
653
+ if (!src || !option) return src;
654
+ if (src.startsWith("blob:")) return src;
655
+ if (src.includes(".svg")) return src;
656
+ const segs = [];
657
+ if (option.imageslim) segs.push("imageslim");
658
+ if (option.imageView2) segs.push(getImageView2(option.imageView2));
659
+ const mogr = getImageMogr2(option.imageMogr2 ?? option);
660
+ if (mogr) segs.push(mogr);
661
+ if (option.watermark) segs.push(getWatermark2(option.watermark));
662
+ if (option.imageInfo) segs.push("imageInfo");
663
+ if (!segs.length) return src;
664
+ const base = src.split("?")[0];
665
+ return `${base}?${segs.join("|")}`;
666
+ }
667
+ function getQnVideo(src, option) {
668
+ if (!src || !option) return src;
669
+ if (src.startsWith("blob:")) return src;
670
+ if (src.includes(".svg")) return src;
671
+ const segs = [];
672
+ if (option.avthumb) segs.push(getAvthumb(option.avthumb));
673
+ if (option.vframe) segs.push(getVframe(option.vframe));
674
+ if (!segs.length) return src;
675
+ const base = src.split("?")[0];
676
+ return `${base}?${segs.join("|")}`;
677
+ }
678
+ function getQnAudio(src, option) {
679
+ if (!src || !option) return src;
680
+ if (src.startsWith("blob:")) return src;
681
+ const segs = [];
682
+ if (option.avthumb) segs.push(getAvthumb(option.avthumb));
683
+ if (!segs.length) return src;
684
+ const base = src.split("?")[0];
685
+ return `${base}?${segs.join("|")}`;
686
+ }
687
+ function getQnHls(src, option) {
688
+ if (!src || !option) return src;
689
+ if (src.startsWith("blob:")) return src;
690
+ const seg = getAvcvt(option);
691
+ if (!seg) return src;
692
+ const base = src.split("?")[0];
693
+ return `${base}?${seg}`;
694
+ }
695
+ function getImageView2(opt) {
696
+ if (!opt) return "";
697
+ const mode = typeof opt.mode === "number" ? opt.mode : 0;
698
+ const kv = [];
699
+ for (const [k, v] of Object.entries(opt)) {
700
+ if (k === "mode") continue;
701
+ if (typeof v === "boolean") {
702
+ if (v) kv.push(`${k}/1`);
703
+ } else if (typeof v === "number" || typeof v === "string") {
704
+ kv.push(`${k}/${v}`);
705
+ }
706
+ }
707
+ return kv.length ? `imageView2/${mode}/${kv.join("/")}` : `imageView2/${mode}`;
708
+ }
709
+ function getImageMogr2(opt) {
710
+ if (!opt) return "";
711
+ const parts = [];
712
+ const tn = opt.thumbnail;
713
+ if (typeof tn !== "undefined") parts.push(`thumbnail/${tn}`);
714
+ const cp = opt.crop;
715
+ if (typeof cp !== "undefined") parts.push(`crop/${cp}`);
716
+ const rot = opt.rotate;
717
+ if (typeof rot === "number") parts.push(`rotate/${rot}`);
718
+ const ao = opt["auto-orient"];
719
+ if (ao) parts.push("auto-orient");
720
+ const fmt = opt.format;
721
+ if (typeof fmt === "string") parts.push(`format/${fmt}`);
722
+ const il = opt.interlace;
723
+ if (il === 0 || il === 1) parts.push(`interlace/${il}`);
724
+ const bg = opt.background;
725
+ if (typeof bg === "string") parts.push(`background/${bg}`);
726
+ const q = opt.q;
727
+ if (typeof q === "number") parts.push(`q/${q}`);
728
+ const blur = opt.blur;
729
+ if (typeof blur !== "undefined") {
730
+ if (typeof blur === "string") parts.push(`blur/${blur}`);
731
+ else parts.push(`blur/${blur.r}x${blur.s}`);
732
+ }
733
+ const colors = opt.colors;
734
+ if (typeof colors === "number") parts.push(`colors/${colors}`);
735
+ return parts.length ? `imageMogr2/${parts.join("/")}` : "";
736
+ }
737
+ function getWatermark2(w) {
738
+ if (!w) return "";
739
+ const mode = w.type === "image" ? 1 : w.type === "text" ? 2 : typeof w.type === "number" ? w.type : 2;
740
+ const segs = [`watermark/${mode}`];
741
+ if (mode === 1 && w.image) segs.push(`image/${toBase64Url2(w.image)}`);
742
+ if (mode === 2 && w.text) segs.push(`text/${toBase64Url2(w.text)}`);
743
+ if (w.font) segs.push(`font/${toBase64Url2(w.font)}`);
744
+ if (typeof w.fontsize === "number") segs.push(`fontsize/${w.fontsize}`);
745
+ if (w.fill) segs.push(`fill/${toBase64Url2(w.fill)}`);
746
+ if (w.gravity) segs.push(`gravity/${w.gravity}`);
747
+ if (typeof w.dx === "number") segs.push(`dx/${w.dx}`);
748
+ if (typeof w.dy === "number") segs.push(`dy/${w.dy}`);
749
+ if (typeof w.dissolve === "number") segs.push(`dissolve/${w.dissolve}`);
750
+ return segs.join("/");
751
+ }
752
+ function toBase64Url2(s) {
753
+ let b64 = "";
754
+ if (typeof Buffer !== "undefined") {
755
+ const buf = Buffer.from(s, "utf-8");
756
+ b64 = buf.toString("base64");
757
+ } else {
758
+ try {
759
+ b64 = btoa(unescape(encodeURIComponent(s)));
760
+ } catch {
761
+ b64 = "";
762
+ }
763
+ }
764
+ return b64.replace(/=+$/g, "").replace(/\+/g, "-").replace(/\//g, "_");
765
+ }
766
+ function getAvthumb(opt) {
767
+ const parts = [];
768
+ if (opt.format) parts.push(`avthumb/${opt.format}`);
769
+ else parts.push("avthumb");
770
+ if (opt.s) parts.push(`s/${opt.s}`);
771
+ if (opt.vcodec) parts.push(`vcodec/${opt.vcodec}`);
772
+ if (typeof opt.vb !== "undefined") parts.push(`vb/${opt.vb}`);
773
+ if (typeof opt.r === "number") parts.push(`r/${opt.r}`);
774
+ if (typeof opt.ab !== "undefined") parts.push(`ab/${opt.ab}`);
775
+ if (typeof opt.ar === "number") parts.push(`ar/${opt.ar}`);
776
+ if (opt.acodec) parts.push(`acodec/${opt.acodec}`);
777
+ return parts.join("/");
778
+ }
779
+ function getVframe(opt) {
780
+ const parts = [];
781
+ parts.push(`vframe/${opt.format || "jpg"}`);
782
+ if (typeof opt.offset === "number") parts.push(`offset/${opt.offset}`);
783
+ if (typeof opt.w === "number") parts.push(`w/${opt.w}`);
784
+ if (typeof opt.h === "number") parts.push(`h/${opt.h}`);
785
+ return parts.join("/");
786
+ }
787
+ function getAvcvt(opt) {
788
+ const parts = [];
789
+ const level = typeof opt.level === "number" ? `/${opt.level}` : "/3";
790
+ parts.push(`avcvt${level}`);
791
+ parts.push(`format/${opt.format || "m3u8"}`);
792
+ if (typeof opt.segtime === "number") parts.push(`segtime/${opt.segtime}`);
793
+ if (typeof opt.t === "string") parts.push(`t/${opt.t}`);
794
+ if (opt.vcodec) parts.push(`vcodec/${opt.vcodec}`);
795
+ if (typeof opt.vb !== "undefined") parts.push(`vb/${opt.vb}`);
796
+ if (typeof opt.r === "number") parts.push(`r/${opt.r}`);
797
+ if (typeof opt.s === "string") parts.push(`s/${opt.s}`);
798
+ if (opt.acodec) parts.push(`acodec/${opt.acodec}`);
799
+ if (typeof opt.ab !== "undefined") parts.push(`ab/${opt.ab}`);
800
+ if (typeof opt.ar === "number") parts.push(`ar/${opt.ar}`);
801
+ if (typeof opt.output === "string") parts.push(`output/${toBase64Url2(opt.output)}`);
802
+ return parts.join("/");
803
+ }
804
+
805
+ // src/ts/validator/index.ts
806
+ function isLetter(s) {
807
+ return /^[a-zA-Z]*$/.test(s);
808
+ }
809
+ function isChinese(s) {
810
+ const v = String(s ?? "").trim();
811
+ return /^[\u4E00-\u9FA5]+$/.test(v);
812
+ }
813
+ function isDigits(s) {
814
+ return /^[0-9]+$/.test(s);
815
+ }
816
+ function isNumeric(value, options) {
817
+ const { negative = false, decimal = 2, thousands = false, leadZero = false } = options || {};
818
+ if (value === null || value === void 0 || value === "") return false;
819
+ const str = String(value).trim();
820
+ const sign = negative && str.startsWith("-") ? "-" : "";
821
+ const body = sign ? str.slice(1) : str;
822
+ const thousandsPart = thousands ? "(?:[1-9]\\d{0,2}(,\\d{3})*|0)" : "(?:\\d+)";
823
+ const intPart = thousands ? thousandsPart : leadZero ? "(?:\\d+)" : "(?:0|[1-9]\\d*)";
824
+ const fracPart = decimal === 0 ? "" : `(\\.\\d{1,${decimal}})`;
825
+ const pattern = `^${intPart}${fracPart}$`;
826
+ const reg = new RegExp(pattern);
827
+ return reg.test(body);
828
+ }
829
+ function isMobilePhone(s) {
830
+ const v = String(s ?? "").trim();
831
+ return /^1[3-9]\d{9}$/.test(v);
832
+ }
833
+ function isLandline(s) {
834
+ const v = String(s ?? "").trim();
835
+ return /^0\d{2,3}-?\d{7,8}(?:-\d{1,6})?$/.test(v);
836
+ }
837
+ function isPhone(s) {
838
+ return isMobilePhone(s) || isLandline(s);
839
+ }
840
+ function isEmail(s) {
841
+ const v = String(s ?? "").trim();
842
+ if (v === "") return false;
843
+ const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/;
844
+ return emailRegex.test(v);
845
+ }
846
+ function isChineseName(s) {
847
+ const v = String(s ?? "").trim();
848
+ return /^[\u4E00-\u9FA5·]{2,20}$/.test(v);
849
+ }
850
+ function isIdentityCard(code) {
851
+ const v = String(code ?? "").trim();
852
+ if (v === "") return false;
853
+ const isValidDate = (yyyymmdd) => {
854
+ const y = Number(yyyymmdd.slice(0, 4));
855
+ const m = Number(yyyymmdd.slice(4, 6));
856
+ const d = Number(yyyymmdd.slice(6, 8));
857
+ if (y < 1900 || y > 2100) return false;
858
+ const date = new Date(y, m - 1, d);
859
+ return date.getFullYear() === y && date.getMonth() === m - 1 && date.getDate() === d;
860
+ };
861
+ if (/^\d{17}[\dXx]$/.test(v)) {
862
+ const birth = v.slice(6, 14);
863
+ if (!isValidDate(birth)) return false;
864
+ const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
865
+ const checkMap = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
866
+ let sum = 0;
867
+ for (let i = 0; i < 17; i++) sum += Number(v[i]) * weights[i];
868
+ const mod = sum % 11;
869
+ const code18 = v[17].toUpperCase();
870
+ return checkMap[mod] === code18;
871
+ }
872
+ if (/^\d{15}$/.test(v)) {
873
+ const birth = v.slice(6, 12);
874
+ const y = Number(`19${birth.slice(0, 2)}`);
875
+ const m = Number(birth.slice(2, 4));
876
+ const d = Number(birth.slice(4, 6));
877
+ const date = new Date(y, m - 1, d);
878
+ return date.getFullYear() === y && date.getMonth() === m - 1 && date.getDate() === d;
879
+ }
880
+ if (/^[A-Za-z][12]\d{8}$/.test(v)) return true;
881
+ if (/^[A-Za-z]{1,2}\d{6}\(?[0-9A]\)?$/.test(v)) return true;
882
+ if (/^[157]\d{6}\(?\d\)?$/.test(v)) return true;
883
+ return false;
884
+ }
885
+ function isPassport(s) {
886
+ const t = String(s ?? "").replace(/[-\s]/g, "").trim();
887
+ if (t === "") return false;
888
+ if (/^[EG]\d{8}$/.test(t)) return true;
889
+ if (/^[DPS]\d{7}$/.test(t)) return true;
890
+ if (/^[A-Za-z]\d{8}$/.test(t)) return true;
891
+ if (/^[A-Za-z0-9]{6,9}$/.test(t)) return true;
892
+ return false;
893
+ }
894
+ function isHKMOPermit(s) {
895
+ const t = String(s ?? "").replace(/[-\s]/g, "").trim().toUpperCase();
896
+ return /^[HM]\d{8,10}$/.test(t);
897
+ }
898
+ function isTaiwanPermit(s) {
899
+ const t = String(s ?? "").replace(/[-\s]/g, "").trim().toUpperCase();
900
+ if (/^\d{8}$/.test(t)) return true;
901
+ if (/^[A-Z]\d{8}$/.test(t)) return true;
902
+ if (/^\d{10}$/.test(t)) return true;
903
+ return false;
904
+ }
905
+ function isOfficerId(s) {
906
+ const t = String(s ?? "").replace(/[-\s]/g, "").trim().toUpperCase();
907
+ return /^[A-Z0-9]{7,18}$/.test(t);
908
+ }
909
+ function isSoldierId(s) {
910
+ const t = String(s ?? "").replace(/[-\s]/g, "").trim().toUpperCase();
911
+ return /^[A-Z0-9]{7,18}$/.test(t);
912
+ }
913
+ function isMilitaryId(s) {
914
+ return isOfficerId(s) || isSoldierId(s);
915
+ }
916
+ function isBankCard(s) {
917
+ const t = String(s ?? "").replace(/[-\s]/g, "").trim();
918
+ if (!/^\d{12,19}$/.test(t)) return false;
919
+ let sum = 0;
920
+ let shouldDouble = false;
921
+ for (let i = t.length - 1; i >= 0; i--) {
922
+ let digit = Number(t[i]);
923
+ if (shouldDouble) {
924
+ digit *= 2;
925
+ if (digit > 9) digit -= 9;
926
+ }
927
+ sum += digit;
928
+ shouldDouble = !shouldDouble;
929
+ }
930
+ return sum % 10 === 0;
931
+ }
932
+ function isLicensePlate(s) {
933
+ const v = String(s ?? "").trim().toUpperCase();
934
+ const prov = "\u4EAC\u6CAA\u6D25\u6E1D\u5180\u8C6B\u4E91\u8FBD\u9ED1\u6E58\u7696\u9C81\u65B0\u82CF\u6D59\u8D63\u9102\u6842\u7518\u664B\u8499\u9655\u5409\u95FD\u8D35\u9752\u85CF\u5DDD\u5B81\u743C\u7CA4";
935
+ const std = new RegExp(`^[${prov}][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9\u6302\u5B66\u8B66\u6E2F\u6FB3]$`);
936
+ const ne1 = new RegExp(`^[${prov}][A-HJ-NP-Z][DF][A-HJ-NP-Z0-9]{5}$`);
937
+ const ne2 = new RegExp(`^[${prov}][A-HJ-NP-Z][A-HJ-NP-Z0-9]{5}[DF]$`);
938
+ return std.test(v) || ne1.test(v) || ne2.test(v);
939
+ }
940
+ function isTaxID(code) {
941
+ const v = String(code ?? "").trim();
942
+ if (!/^[0-9A-HJ-NPQRTUWXY]{18}$/.test(v)) return false;
943
+ const charset = "0123456789ABCDEFGHJKLMNPQRTUWXY";
944
+ const weights = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28];
945
+ const map = {};
946
+ for (let i = 0; i < charset.length; i++) map[charset[i]] = i;
947
+ let sum = 0;
948
+ for (let i = 0; i < 17; i++) {
949
+ sum += map[v[i]] * weights[i];
950
+ }
951
+ const logicCheck = (31 - sum % 31) % 31;
952
+ const expected = charset[logicCheck];
953
+ return v[17] === expected;
954
+ }
955
+ function isJSON(input) {
956
+ if (typeof input === "string") {
957
+ const s = input.trim();
958
+ if (s === "") return false;
959
+ try {
960
+ JSON.parse(s);
961
+ return true;
962
+ } catch {
963
+ return false;
964
+ }
965
+ }
966
+ if (input !== null && typeof input === "object") return true;
967
+ return false;
968
+ }
969
+ function isHexColor(s) {
970
+ const v = String(s ?? "").trim();
971
+ return /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(v);
972
+ }
973
+ function isURL(s) {
974
+ const v = String(s ?? "").trim();
975
+ if (v === "") return false;
976
+ try {
977
+ const u = new URL(v);
978
+ return ["http:", "https:", "ftp:"].includes(u.protocol) && !!u.hostname;
979
+ } catch {
980
+ return false;
981
+ }
982
+ }
983
+ function isIPv4(s) {
984
+ const v = String(s ?? "").trim();
985
+ if (v === "") return false;
986
+ const parts = v.split(".");
987
+ if (parts.length !== 4) return false;
988
+ for (const p of parts) {
989
+ if (!/^\d+$/.test(p)) return false;
990
+ if (p.length > 1 && p.startsWith("0")) return false;
991
+ const n = Number(p);
992
+ if (n < 0 || n > 255) return false;
993
+ }
994
+ return true;
995
+ }
996
+ function isIPv6(s) {
997
+ const v = String(s ?? "").trim();
998
+ if (v === "") return false;
999
+ const lastColon = v.lastIndexOf(":");
1000
+ if (lastColon !== -1 && v.includes(".")) {
1001
+ const ipv6Part = v.slice(0, lastColon);
1002
+ const ipv4Part = v.slice(lastColon + 1);
1003
+ return isIPv6(ipv6Part) && isIPv4(ipv4Part);
1004
+ }
1005
+ const dblColonCount = (v.match(/::/g) || []).length;
1006
+ if (dblColonCount > 1) return false;
1007
+ const segments = v.split(":");
1008
+ if (v.startsWith("::")) segments.shift();
1009
+ if (v.endsWith("::")) segments.pop();
1010
+ const segmentsFiltered = segments.filter((seg) => seg !== "");
1011
+ if (dblColonCount === 0 && segmentsFiltered.length !== 8) return false;
1012
+ if (dblColonCount === 1 && segmentsFiltered.length >= 1 && segmentsFiltered.length <= 7) {
1013
+ } else if (dblColonCount === 1 && segments.length === 0) {
1014
+ return true;
1015
+ } else if (dblColonCount === 0 && segmentsFiltered.length === 8) {
1016
+ } else {
1017
+ return false;
1018
+ }
1019
+ return segmentsFiltered.every(
1020
+ (seg) => seg.length >= 1 && seg.length <= 4 && /^[0-9a-fA-F]{1,4}$/.test(seg)
1021
+ );
1022
+ }
1023
+ function isIP(s, version) {
1024
+ if (version === 4 || version === "4") return isIPv4(s);
1025
+ if (version === 6 || version === "6") return isIPv6(s);
1026
+ return isIPv4(s) || isIPv6(s);
1027
+ }
1028
+ function isIPRange(s) {
1029
+ const v = String(s ?? "").trim();
1030
+ if (v === "") return false;
1031
+ const parts = v.split("/");
1032
+ if (parts.length !== 2) return false;
1033
+ const [ip, prefixStr] = parts;
1034
+ if (!/^\d+$/.test(prefixStr)) return false;
1035
+ const prefix = Number(prefixStr);
1036
+ if (ip.includes(":")) {
1037
+ if (!isIPv6(ip)) return false;
1038
+ return prefix >= 0 && prefix <= 128;
1039
+ }
1040
+ if (!isIPv4(ip)) return false;
1041
+ return prefix >= 0 && prefix <= 32;
1042
+ }
1043
+ function isPortNumber(s) {
1044
+ const v = typeof s === "number" ? s : Number(String(s ?? "").trim());
1045
+ return Number.isInteger(v) && v >= 0 && v <= 65535;
1046
+ }
1047
+ function isLatitude(s) {
1048
+ const v = typeof s === "number" ? s : Number(String(s ?? "").trim());
1049
+ return Number.isFinite(v) && v >= -90 && v <= 90;
1050
+ }
1051
+ function isLongitude(s) {
1052
+ const v = typeof s === "number" ? s : Number(String(s ?? "").trim());
1053
+ return Number.isFinite(v) && v >= -180 && v <= 180;
1054
+ }
1055
+ export {
1056
+ BigNumber,
1057
+ appendUrlParam,
1058
+ arrayMove,
1059
+ big,
1060
+ bigAdd,
1061
+ bigCompare,
1062
+ bigDiv,
1063
+ bigEqual,
1064
+ bigGt,
1065
+ bigGte,
1066
+ bigLt,
1067
+ bigLte,
1068
+ bigMul,
1069
+ bigPow,
1070
+ bigRound,
1071
+ bigSub,
1072
+ buildOssUrl,
1073
+ createRandId,
1074
+ createTimeRandId,
1075
+ createUuid,
1076
+ dayjs,
1077
+ getAgeByBirthdate,
1078
+ getCountdownParts,
1079
+ getDateRangeAfter,
1080
+ getDateRangeBefore,
1081
+ getFileSuffix,
1082
+ getFileType,
1083
+ getObjectKeys,
1084
+ getOssAudio,
1085
+ getOssHls,
1086
+ getOssImg,
1087
+ getOssVideo,
1088
+ getQnAudio,
1089
+ getQnHls,
1090
+ getQnImg,
1091
+ getQnVideo,
1092
+ getStringByteLength,
1093
+ getUrlNumber,
1094
+ getUrlParam,
1095
+ getUrlParamAll,
1096
+ isBankCard,
1097
+ isChinese,
1098
+ isChineseName,
1099
+ isDigits,
1100
+ isEmail,
1101
+ isHKMOPermit,
1102
+ isHexColor,
1103
+ isIP,
1104
+ isIPRange,
1105
+ isIPv6,
1106
+ isIdentityCard,
1107
+ isJSON,
1108
+ isLandline,
1109
+ isLatitude,
1110
+ isLetter,
1111
+ isLicensePlate,
1112
+ isLongitude,
1113
+ isMilitaryId,
1114
+ isMobilePhone,
1115
+ isNumeric,
1116
+ isOfficerId,
1117
+ isPassport,
1118
+ isPhone,
1119
+ isPortNumber,
1120
+ isSoldierId,
1121
+ isTaiwanPermit,
1122
+ isTaxID,
1123
+ isURL,
1124
+ randomBoolean,
1125
+ randomFloat,
1126
+ randomInt,
1127
+ toAsync,
1128
+ toChineseCurrency,
1129
+ toChineseNum,
1130
+ toDayjs,
1131
+ toFixed,
1132
+ toMaskName,
1133
+ toMaskPhone,
1134
+ toMaskText,
1135
+ toThousandth,
1136
+ withDistance,
1137
+ withUnit,
1138
+ withUnitPx,
1139
+ zeroPad
1140
+ };