@base-web-kits/base-tools-web 1.1.8 → 1.1.11

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/dist/index.cjs CHANGED
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
8
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __pow = Math.pow;
10
13
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
14
  var __spreadValues = (a, b) => {
12
15
  for (var prop in b || (b = {}))
@@ -32,7 +35,17 @@ var __copyProps = (to, from, except, desc) => {
32
35
  }
33
36
  return to;
34
37
  };
38
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
39
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
40
+ // If the importer is in node compatibility mode or this is not an ESM
41
+ // file that has been converted to a CommonJS file using a Babel-
42
+ // compatible transform (i.e. "__esModule" has not been set), then set
43
+ // "default" to the CommonJS "module.exports" for node compatibility.
44
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
45
+ mod
46
+ ));
35
47
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
36
49
  var __async = (__this, __arguments, generator) => {
37
50
  return new Promise((resolve, reject) => {
38
51
  var fulfilled = (value) => {
@@ -623,8 +636,999 @@ function preloadImage(src) {
623
636
  });
624
637
  }
625
638
 
639
+ // src/ts/index.ts
640
+ var ts_exports = {};
641
+ __export(ts_exports, {
642
+ BigNumber: () => import_bignumber.default,
643
+ EventBus: () => EventBus,
644
+ appendUrlParam: () => appendUrlParam,
645
+ arrayMove: () => arrayMove,
646
+ buildOSSUrl: () => buildOSSUrl,
647
+ createTimeRandId: () => createTimeRandId,
648
+ createUUID: () => createUUID,
649
+ createViewRandId: () => createViewRandId,
650
+ dayjs: () => import_dayjs.default,
651
+ getAgeByBirthdate: () => getAgeByBirthdate,
652
+ getByteLength: () => getByteLength,
653
+ getCountdownParts: () => getCountdownParts,
654
+ getDateRangeAfter: () => getDateRangeAfter,
655
+ getDateRangeBefore: () => getDateRangeBefore,
656
+ getFileSuffix: () => getFileSuffix,
657
+ getFileType: () => getFileType,
658
+ getOSSAudio: () => getOSSAudio,
659
+ getOSSHls: () => getOSSHls,
660
+ getOSSImg: () => getOSSImg,
661
+ getOSSVideo: () => getOSSVideo,
662
+ getObjectKeys: () => getObjectKeys,
663
+ getObjectValue: () => getObjectValue,
664
+ getQnAudio: () => getQnAudio,
665
+ getQnHls: () => getQnHls,
666
+ getQnImg: () => getQnImg,
667
+ getQnVideo: () => getQnVideo,
668
+ isBankCard: () => isBankCard,
669
+ isChinese: () => isChinese,
670
+ isChineseName: () => isChineseName,
671
+ isDigits: () => isDigits,
672
+ isEmail: () => isEmail,
673
+ isHKMOPermit: () => isHKMOPermit,
674
+ isHexColor: () => isHexColor,
675
+ isIP: () => isIP,
676
+ isIPRange: () => isIPRange,
677
+ isIPv6: () => isIPv6,
678
+ isIdentityCard: () => isIdentityCard,
679
+ isLandline: () => isLandline,
680
+ isLatitude: () => isLatitude,
681
+ isLetter: () => isLetter,
682
+ isLicensePlate: () => isLicensePlate,
683
+ isLongitude: () => isLongitude,
684
+ isMilitaryId: () => isMilitaryId,
685
+ isMobilePhone: () => isMobilePhone,
686
+ isNumeric: () => isNumeric,
687
+ isOfficerId: () => isOfficerId,
688
+ isPassport: () => isPassport,
689
+ isPhone: () => isPhone,
690
+ isPortNumber: () => isPortNumber,
691
+ isSoldierId: () => isSoldierId,
692
+ isTaiwanPermit: () => isTaiwanPermit,
693
+ isTaxID: () => isTaxID,
694
+ isURL: () => isURL,
695
+ mathCompare: () => mathCompare,
696
+ mathDiv: () => mathDiv,
697
+ mathEqual: () => mathEqual,
698
+ mathFixed: () => mathFixed,
699
+ mathGreaterThan: () => mathGreaterThan,
700
+ mathGreaterThanOrEqual: () => mathGreaterThanOrEqual,
701
+ mathLessThan: () => mathLessThan,
702
+ mathLessThanOrEqual: () => mathLessThanOrEqual,
703
+ mathMinus: () => mathMinus,
704
+ mathPlus: () => mathPlus,
705
+ mathPow: () => mathPow,
706
+ mathRound: () => mathRound,
707
+ mathTimes: () => mathTimes,
708
+ randomBoolean: () => randomBoolean,
709
+ setObjectValue: () => setObjectValue,
710
+ toAsync: () => toAsync,
711
+ toChineseCurrency: () => toChineseCurrency,
712
+ toChineseNum: () => toChineseNum,
713
+ toDayjs: () => toDayjs,
714
+ toMaskName: () => toMaskName,
715
+ toMaskPhone: () => toMaskPhone,
716
+ toMaskText: () => toMaskText,
717
+ toThousandth: () => toThousandth,
718
+ withDistance: () => withDistance,
719
+ withUnit: () => withUnit,
720
+ withUnitPx: () => withUnitPx,
721
+ zeroPad: () => zeroPad
722
+ });
723
+
724
+ // src/ts/array/index.ts
725
+ function arrayMove(list, fromIndex, toIndex) {
726
+ const newList = [...list];
727
+ const [removed] = newList.splice(fromIndex, 1);
728
+ newList.splice(toIndex, 0, removed);
729
+ return newList;
730
+ }
731
+
732
+ // src/ts/async/index.ts
733
+ function toAsync(p) {
734
+ return __async(this, null, function* () {
735
+ try {
736
+ const data = yield p;
737
+ return [data, null];
738
+ } catch (err) {
739
+ return [null, err];
740
+ }
741
+ });
742
+ }
743
+
744
+ // src/ts/bean/EventBus.ts
745
+ var import_mitt = __toESM(require("mitt"), 1);
746
+ var EventBus = class {
747
+ constructor() {
748
+ __publicField(this, "_emitter", (0, import_mitt.default)());
749
+ }
750
+ /** 订阅 */
751
+ on(type, fn) {
752
+ this._emitter.on(type, fn);
753
+ return this;
754
+ }
755
+ /** 订阅一次 */
756
+ once(type, fn) {
757
+ const wrap = (event) => {
758
+ this._emitter.off(type, wrap);
759
+ fn(event);
760
+ };
761
+ this._emitter.on(type, wrap);
762
+ return this;
763
+ }
764
+ /** 发布 */
765
+ emit(type, event) {
766
+ this._emitter.emit(type, event);
767
+ return this;
768
+ }
769
+ /** 移除 */
770
+ off(type, fn) {
771
+ this._emitter.off(type, fn);
772
+ return this;
773
+ }
774
+ /** 清空 */
775
+ clear() {
776
+ this._emitter.all.clear();
777
+ return this;
778
+ }
779
+ };
780
+
781
+ // src/ts/day/index.ts
782
+ var import_dayjs = __toESM(require("dayjs"), 1);
783
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"), 1);
784
+ var import_utc = __toESM(require("dayjs/plugin/utc"), 1);
785
+ var import_timezone = __toESM(require("dayjs/plugin/timezone"), 1);
786
+ var import_relativeTime = __toESM(require("dayjs/plugin/relativeTime"), 1);
787
+ var import_advancedFormat = __toESM(require("dayjs/plugin/advancedFormat"), 1);
788
+ var import_zh_cn = require("dayjs/locale/zh-cn");
789
+
790
+ // src/ts/number/big.ts
791
+ var import_bignumber = __toESM(require("bignumber.js"), 1);
792
+ function big(x) {
793
+ return x instanceof import_bignumber.default ? x : new import_bignumber.default(x);
794
+ }
795
+ function mathPlus(...rest) {
796
+ let acc = big(rest[0]);
797
+ for (const x of rest.slice(1)) acc = acc.plus(big(x));
798
+ return acc.toNumber();
799
+ }
800
+ function mathMinus(...rest) {
801
+ let acc = big(rest[0]);
802
+ for (const x of rest.slice(1)) acc = acc.minus(big(x));
803
+ return acc.toNumber();
804
+ }
805
+ function mathTimes(...rest) {
806
+ let acc = big(rest[0]);
807
+ for (const x of rest.slice(1)) acc = acc.times(big(x));
808
+ return acc.toNumber();
809
+ }
810
+ function mathDiv(...rest) {
811
+ let acc = big(rest[0]);
812
+ for (const x of rest.slice(1)) acc = acc.div(big(x));
813
+ return acc.toNumber();
814
+ }
815
+ function mathPow(x, y) {
816
+ return big(x).pow(big(y)).toNumber();
817
+ }
818
+ function mathRound(x, dp = 0, rm = import_bignumber.default.ROUND_HALF_UP) {
819
+ return big(x).decimalPlaces(dp, rm).toNumber();
820
+ }
821
+ function mathFixed(x, dp = 2, rm = import_bignumber.default.ROUND_HALF_UP) {
822
+ return big(x).toFixed(dp, rm);
823
+ }
824
+ function mathCompare(a, b) {
825
+ return big(a).comparedTo(big(b));
826
+ }
827
+ function mathEqual(a, b) {
828
+ return big(a).isEqualTo(big(b));
829
+ }
830
+ function mathGreaterThan(a, b) {
831
+ return big(a).isGreaterThan(big(b));
832
+ }
833
+ function mathGreaterThanOrEqual(a, b) {
834
+ return big(a).isGreaterThanOrEqualTo(big(b));
835
+ }
836
+ function mathLessThan(a, b) {
837
+ return big(a).isLessThan(big(b));
838
+ }
839
+ function mathLessThanOrEqual(a, b) {
840
+ return big(a).isLessThanOrEqualTo(big(b));
841
+ }
842
+
843
+ // src/ts/number/format.ts
844
+ function zeroPad(n, len = 2) {
845
+ return String(n).padStart(len, "0");
846
+ }
847
+ function withUnit(num, unit = "") {
848
+ if (num === null || num === void 0 || num === "") return "";
849
+ if (typeof num === "number") return `${num}${unit}`;
850
+ const str = String(num).trim();
851
+ if (str === "") return "";
852
+ return isNaN(+str) ? str : `${str}${unit}`;
853
+ }
854
+ function withUnitPx(num) {
855
+ return withUnit(num, "px");
856
+ }
857
+ function withDistance(m) {
858
+ const n = Number(m != null ? m : 0);
859
+ if (!Number.isFinite(n)) return "0m";
860
+ return n >= 1e3 ? `${+(n / 1e3).toFixed(2)}km` : `${+n.toFixed(2)}m`;
861
+ }
862
+ function toThousandth(str) {
863
+ const v = String(str != null ? str : "").trim();
864
+ if (v === "") return "";
865
+ let sign = "";
866
+ let num = v;
867
+ if (num[0] === "-" || num[0] === "+") {
868
+ sign = num[0];
869
+ num = num.slice(1);
870
+ }
871
+ const [intPart, decPart] = num.split(".");
872
+ const groupedInt = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
873
+ return decPart !== void 0 && decPart !== "" ? `${sign}${groupedInt}.${decPart}` : `${sign}${groupedInt}`;
874
+ }
875
+ function toChineseNum(num) {
876
+ const numInt = Math.trunc(+num);
877
+ if (numInt === 0) return "\u96F6";
878
+ const digit = ["\u96F6", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u4E03", "\u516B", "\u4E5D"];
879
+ const unit = ["", "\u5341", "\u767E", "\u5343"];
880
+ const bigUnit = ["", "\u4E07", "\u4EBF", "\u5146"];
881
+ const section4 = (n2) => {
882
+ let str = "", zeroFlag = false;
883
+ for (let i = 0; i < 4; i++) {
884
+ const d = n2 % 10;
885
+ n2 = Math.floor(n2 / 10);
886
+ if (d === 0) {
887
+ zeroFlag = true;
888
+ continue;
889
+ }
890
+ if (zeroFlag) str = digit[0] + str;
891
+ str = digit[d] + unit[i] + str;
892
+ zeroFlag = false;
893
+ }
894
+ return str;
895
+ };
896
+ let res = "";
897
+ let sectionIndex = 0;
898
+ let n = Math.abs(numInt);
899
+ while (n > 0) {
900
+ const seg = n % 1e4;
901
+ n = Math.floor(n / 1e4);
902
+ if (seg) {
903
+ const segStr = section4(seg);
904
+ res = segStr + (sectionIndex ? bigUnit[sectionIndex] : "") + res;
905
+ } else if (res && !res.startsWith("\u96F6")) {
906
+ res = `\u96F6${res}`;
907
+ }
908
+ sectionIndex++;
909
+ }
910
+ res = res.replace(/^一十/, "\u5341");
911
+ return numInt < 0 ? `\u8D1F${res}` : res;
912
+ }
913
+ function toChineseCurrency(amount, opts = {}) {
914
+ var _a, _b, _c;
915
+ const dp = (_a = opts.precision) != null ? _a : 2;
916
+ const rm = (_b = opts.rm) != null ? _b : import_bignumber.default.ROUND_HALF_UP;
917
+ const yuan = (_c = opts.yuanChar) != null ? _c : "\u5143";
918
+ if (amount === null || amount === void 0) return "";
919
+ const bn = new import_bignumber.default(amount);
920
+ if (!bn.isFinite()) return "";
921
+ const s = bn.toFixed(dp, rm);
922
+ const sign = s.startsWith("-") ? "\u8D1F" : "";
923
+ const [intStr, decStr = ""] = s.replace(/^-/, "").split(".");
924
+ const digit = ["\u96F6", "\u58F9", "\u8D30", "\u53C1", "\u8086", "\u4F0D", "\u9646", "\u67D2", "\u634C", "\u7396"];
925
+ const unit = ["", "\u62FE", "\u4F70", "\u4EDF"];
926
+ const bigUnit = ["", "\u4E07", "\u4EBF", "\u5146"];
927
+ const smallUnit = ["\u89D2", "\u5206", "\u5398"];
928
+ const section4 = (n) => {
929
+ let str = "";
930
+ let zeroFlag = false;
931
+ for (let i = 0; i < 4; i++) {
932
+ const d = n.mod(10).toNumber();
933
+ n = n.idiv(10);
934
+ if (d === 0) {
935
+ zeroFlag = true;
936
+ continue;
937
+ }
938
+ if (zeroFlag) str = digit[0] + str;
939
+ str = digit[d] + unit[i] + str;
940
+ zeroFlag = false;
941
+ }
942
+ return str.replace(/零+$/g, "");
943
+ };
944
+ const intNum = new import_bignumber.default(intStr);
945
+ let res = "";
946
+ if (intNum.isZero()) {
947
+ res = digit[0];
948
+ } else {
949
+ let n = intNum.abs();
950
+ let sectionIndex = 0;
951
+ while (n.gt(0)) {
952
+ const seg = n.mod(1e4);
953
+ n = n.idiv(1e4);
954
+ if (seg.gt(0)) {
955
+ const segStr = section4(seg);
956
+ const needZero = res && !res.startsWith(digit[0]) && (seg.lt(1e3) || seg.mod(1e3).isZero());
957
+ const bu = sectionIndex ? bigUnit[sectionIndex] : "";
958
+ res = segStr + bu + (needZero ? digit[0] : "") + res;
959
+ } else if (res && !res.startsWith(digit[0])) {
960
+ res = digit[0] + res;
961
+ }
962
+ sectionIndex++;
963
+ }
964
+ res = res.replace(/^壹拾/, "\u62FE");
965
+ }
966
+ let frac = "";
967
+ for (let i = 0; i < Math.min(3, dp); i++) {
968
+ const ch = decStr[i] || "0";
969
+ const d = ch.charCodeAt(0) - 48;
970
+ if (d > 0) frac += digit[d] + smallUnit[i];
971
+ }
972
+ return frac ? `${sign}${res}${yuan}${frac}` : `${sign}${res}${yuan}\u6574`;
973
+ }
974
+
975
+ // src/ts/number/random.ts
976
+ function randomBoolean() {
977
+ return Math.random() < 0.5;
978
+ }
979
+
980
+ // src/ts/day/index.ts
981
+ import_dayjs.default.extend(import_customParseFormat.default);
982
+ import_dayjs.default.extend(import_utc.default);
983
+ import_dayjs.default.extend(import_timezone.default);
984
+ import_dayjs.default.extend(import_relativeTime.default);
985
+ import_dayjs.default.extend(import_advancedFormat.default);
986
+ import_dayjs.default.locale("zh-cn");
987
+ function toDayjs(t, fmt) {
988
+ if (t === null || t === void 0) return (0, import_dayjs.default)();
989
+ if (typeof t === "number") {
990
+ const s = String(Math.trunc(t));
991
+ return (0, import_dayjs.default)(s.length === 10 ? t * 1e3 : t, fmt);
992
+ }
993
+ if (typeof t === "string") {
994
+ const s = t.trim();
995
+ if (/^\d{10}$/.test(s)) return (0, import_dayjs.default)(Number(s) * 1e3, fmt);
996
+ if (/^\d{13}$/.test(s)) return (0, import_dayjs.default)(Number(s), fmt);
997
+ if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return (0, import_dayjs.default)(s, fmt || "YYYY-MM-DD");
998
+ if (/^\d{4}\/\d{2}\/\d{2}$/.test(s)) return (0, import_dayjs.default)(s, fmt || "YYYY/MM/DD");
999
+ if (/^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}$/.test(s))
1000
+ return (0, import_dayjs.default)(s, fmt || "YYYY-MM-DD HH:mm:ss");
1001
+ if (/^\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}$/.test(s))
1002
+ return (0, import_dayjs.default)(s, fmt || "YYYY/MM/DD HH:mm:ss");
1003
+ return (0, import_dayjs.default)(s, fmt);
1004
+ }
1005
+ return (0, import_dayjs.default)(t, fmt);
1006
+ }
1007
+ function getDateRangeBefore(offset, fmt = "YYYY-MM-DD") {
1008
+ const now = toDayjs(Date.now());
1009
+ const n = Math.max(0, Math.trunc(offset));
1010
+ const hasTime = /H|h|m|s|S|A|a|x|X/.test(fmt);
1011
+ const startDay = now.add(-n, "day");
1012
+ const endDay = now;
1013
+ const start = (hasTime ? startDay.startOf("day") : startDay).format(fmt);
1014
+ const end = (hasTime ? endDay.endOf("day") : endDay).format(fmt);
1015
+ return [start, end];
1016
+ }
1017
+ function getDateRangeAfter(offset, fmt = "YYYY-MM-DD") {
1018
+ const now = toDayjs(Date.now());
1019
+ const n = Math.max(0, Math.trunc(offset));
1020
+ const hasTime = /H|h|m|s|S|A|a|x|X/.test(fmt);
1021
+ const startDay = now;
1022
+ const endDay = now.add(n, "day");
1023
+ const start = (hasTime ? startDay.startOf("day") : startDay).format(fmt);
1024
+ const end = (hasTime ? endDay.endOf("day") : endDay).format(fmt);
1025
+ return [start, end];
1026
+ }
1027
+ function getCountdownParts(diff) {
1028
+ if (diff <= 0) return { d: "00", h: "00", m: "00", s: "00", ms: "000" };
1029
+ const d = Math.floor(diff / (1e3 * 60 * 60 * 24));
1030
+ const h = Math.floor(diff / (1e3 * 60 * 60) % 24);
1031
+ const m = Math.floor(diff / (1e3 * 60) % 60);
1032
+ const s = Math.floor(diff / 1e3 % 60);
1033
+ const ms = diff % 1e3;
1034
+ return {
1035
+ d: zeroPad(d),
1036
+ h: zeroPad(h),
1037
+ m: zeroPad(m),
1038
+ s: zeroPad(s),
1039
+ ms: zeroPad(ms, 3)
1040
+ };
1041
+ }
1042
+ function getAgeByBirthdate(birthdate) {
1043
+ const birth = toDayjs(birthdate, "YYYY-MM-DD");
1044
+ const now = toDayjs(Date.now());
1045
+ const totalMonths = (now.year() - birth.year()) * 12 + (now.month() - birth.month());
1046
+ const adjustedMonths = now.date() < birth.date() ? totalMonths - 1 : totalMonths;
1047
+ if (adjustedMonths >= 12) {
1048
+ let age = Math.floor(adjustedMonths / 12);
1049
+ const birthdayThisYear = birth.add(age, "year");
1050
+ if (now.isBefore(birthdayThisYear)) {
1051
+ age--;
1052
+ }
1053
+ return { age, type: "year" };
1054
+ }
1055
+ return { age: adjustedMonths, type: "month" };
1056
+ }
1057
+
1058
+ // src/ts/es-toolkit/index.ts
1059
+ var es_toolkit_exports = {};
1060
+ __reExport(es_toolkit_exports, require("es-toolkit"));
1061
+
1062
+ // src/ts/index.ts
1063
+ __reExport(ts_exports, es_toolkit_exports);
1064
+
1065
+ // src/ts/object/index.ts
1066
+ var import_compat = require("es-toolkit/compat");
1067
+ function getObjectKeys(obj) {
1068
+ return Object.keys(obj);
1069
+ }
1070
+ var getObjectValue = import_compat.get;
1071
+ var setObjectValue = import_compat.set;
1072
+
1073
+ // src/ts/string/format.ts
1074
+ function toMaskText(s, keepLeft = 1, keepRight = 0, maskChar = "*") {
1075
+ if (!s) return "";
1076
+ const v = String(s);
1077
+ const l = Math.max(0, keepLeft);
1078
+ const r = Math.max(0, keepRight);
1079
+ const len = v.length;
1080
+ const left = Math.min(l, len);
1081
+ const right = Math.min(r, len - left);
1082
+ const mid = len - left - right;
1083
+ if (mid <= 0) return v;
1084
+ const m = maskChar && maskChar.length > 0 ? maskChar : "*";
1085
+ return v.slice(0, left) + m.repeat(mid) + v.slice(len - right);
1086
+ }
1087
+ function toMaskPhone(phone) {
1088
+ return toMaskText(phone, 3, 4);
1089
+ }
1090
+ function toMaskName(name) {
1091
+ if (!name) return "";
1092
+ const v = String(name);
1093
+ return v.length <= 2 ? toMaskText(v, 1, 0) : toMaskText(v, 1, 1);
1094
+ }
1095
+
1096
+ // src/ts/string/random.ts
1097
+ function createUUID() {
1098
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1099
+ const r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
1100
+ return v.toString(16);
1101
+ });
1102
+ }
1103
+ function createViewRandId(prefix = "id_") {
1104
+ return `${prefix}${Math.random().toString(36).substring(2, 16)}`;
1105
+ }
1106
+ function createTimeRandId(digits = 6) {
1107
+ const base = __pow(10, digits - 1);
1108
+ const range = 9 * base;
1109
+ const int = Math.floor(Math.random() * range) + base;
1110
+ return `${Date.now()}${int}`;
1111
+ }
1112
+
1113
+ // src/ts/string/other.ts
1114
+ function getByteLength(data) {
1115
+ if (typeof data === "string") {
1116
+ let byteLen = 0;
1117
+ for (let i = 0; i < data.length; i++) {
1118
+ const code = data.charCodeAt(i);
1119
+ if (code <= 127) {
1120
+ byteLen += 1;
1121
+ } else if (code <= 2047) {
1122
+ byteLen += 2;
1123
+ } else if (code >= 55296 && code <= 56319) {
1124
+ byteLen += 4;
1125
+ i++;
1126
+ } else {
1127
+ byteLen += 3;
1128
+ }
1129
+ }
1130
+ return byteLen;
1131
+ }
1132
+ if ("byteLength" in data) return data.byteLength;
1133
+ if ("size" in data) return data.size;
1134
+ throw new TypeError("getByteLength: Unsupported type");
1135
+ }
1136
+
1137
+ // src/ts/url/file/index.ts
1138
+ var FILE_TYPE = {
1139
+ img: ["png", "jpg", "jpeg", "gif", "svg", "webp"],
1140
+ video: ["mp4", "mov", "m4v"],
1141
+ voice: ["mp3", "wav", "m4a"],
1142
+ excel: ["csv", "xls", "xlsx", "xlsm", "ods"],
1143
+ word: ["txt", "doc", "docx", "pdf", "md", "wps"],
1144
+ zip: ["zip", "gz", "tar", "rar", "7z"],
1145
+ ppt: ["ppt", "pptx", "odp"],
1146
+ app: ["apk", "ipa"]
1147
+ };
1148
+ function getFileSuffix(fileName) {
1149
+ if (fileName.startsWith(".")) return "";
1150
+ const idx = fileName.lastIndexOf(".");
1151
+ return idx > 0 ? fileName.slice(idx + 1).toLowerCase() : "";
1152
+ }
1153
+ function getFileType(fileName) {
1154
+ const suffix = getFileSuffix(fileName);
1155
+ if (!suffix) return "unknown";
1156
+ const keys = getObjectKeys(FILE_TYPE);
1157
+ for (const key of keys) {
1158
+ if (FILE_TYPE[key].includes(suffix)) {
1159
+ return key;
1160
+ }
1161
+ }
1162
+ return "unknown";
1163
+ }
1164
+
1165
+ // src/ts/url/oss/index.ts
1166
+ function getOSSImg(src, option) {
1167
+ return buildOSSUrl(src, "image", option);
1168
+ }
1169
+ function getOSSVideo(src, option) {
1170
+ return buildOSSUrl(src, "video", option);
1171
+ }
1172
+ function getOSSAudio(src, option) {
1173
+ return buildOSSUrl(src, "audio", option);
1174
+ }
1175
+ function getOSSHls(src, option) {
1176
+ return buildOSSUrl(src, "hls", option);
1177
+ }
1178
+ function buildOSSUrl(src, type, option) {
1179
+ if (!src || !option) return src;
1180
+ if (src.startsWith("blob:")) return src;
1181
+ if (src.includes(".svg")) return src;
1182
+ const segs = [];
1183
+ for (const [k, v] of Object.entries(option)) {
1184
+ const seg = k === "watermark" ? getWatermark(v) : getOSSSegs(k, v);
1185
+ if (seg) segs.push(seg);
1186
+ }
1187
+ if (!segs.length) return src;
1188
+ const base = src.split("?")[0];
1189
+ return `${base}?x-oss-process=${type}/${segs.join("/")}`;
1190
+ }
1191
+ function getOSSSegs(type, option) {
1192
+ if (!option && option !== 0) return "";
1193
+ if (option === true) return type;
1194
+ if (typeof option === "number" || typeof option === "string") return `${type},${option}`;
1195
+ const segs = Object.entries(option).map(([k, v]) => `${k}_${v}`).join(",");
1196
+ return segs ? `${type},${segs}` : "";
1197
+ }
1198
+ function getWatermark(w) {
1199
+ if (!w) return "";
1200
+ if (w.image) w.image = toBase64Url(w.image);
1201
+ if (w.text) w.text = toBase64Url(w.text);
1202
+ if (w.type) w.type = toBase64Url(w.type);
1203
+ return getOSSSegs("watermark", w);
1204
+ }
1205
+ function toBase64Url(s) {
1206
+ let b64 = "";
1207
+ if (typeof Buffer !== "undefined") {
1208
+ const buf = Buffer.from(s, "utf-8");
1209
+ b64 = buf.toString("base64");
1210
+ } else {
1211
+ try {
1212
+ b64 = btoa(unescape(encodeURIComponent(s)));
1213
+ } catch (e) {
1214
+ b64 = "";
1215
+ }
1216
+ }
1217
+ return b64.replace(/=+$/g, "").replace(/\+/g, "-").replace(/\//g, "_");
1218
+ }
1219
+
1220
+ // src/ts/url/param/index.ts
1221
+ function appendUrlParam(url, param) {
1222
+ if (!param || typeof param !== "object") return url;
1223
+ const hashIndex = url.indexOf("#");
1224
+ const baseWithoutHash = hashIndex >= 0 ? url.slice(0, hashIndex) : url;
1225
+ const hash = hashIndex >= 0 ? url.slice(hashIndex) : "";
1226
+ const [base, existingQs] = baseWithoutHash.split("?");
1227
+ const parts = [];
1228
+ if (existingQs) parts.push(existingQs);
1229
+ for (const key in param) {
1230
+ const rawVal = param[key];
1231
+ if (rawVal === null || rawVal === void 0) continue;
1232
+ const val = typeof rawVal === "object" ? JSON.stringify(rawVal) : String(rawVal);
1233
+ parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(val)}`);
1234
+ }
1235
+ const qs = parts.filter(Boolean).join("&");
1236
+ return base + (qs ? `?${qs}` : "") + hash;
1237
+ }
1238
+
1239
+ // src/ts/url/qn/index.ts
1240
+ function getQnImg(src, option) {
1241
+ var _a;
1242
+ if (!src || !option) return src;
1243
+ if (src.startsWith("blob:")) return src;
1244
+ if (src.includes(".svg")) return src;
1245
+ const segs = [];
1246
+ if (option.imageslim) segs.push("imageslim");
1247
+ if (option.imageView2) segs.push(getImageView2(option.imageView2));
1248
+ const mogr = getImageMogr2((_a = option.imageMogr2) != null ? _a : option);
1249
+ if (mogr) segs.push(mogr);
1250
+ if (option.watermark) segs.push(getWatermark2(option.watermark));
1251
+ if (option.imageInfo) segs.push("imageInfo");
1252
+ if (!segs.length) return src;
1253
+ const base = src.split("?")[0];
1254
+ return `${base}?${segs.join("|")}`;
1255
+ }
1256
+ function getQnVideo(src, option) {
1257
+ if (!src || !option) return src;
1258
+ if (src.startsWith("blob:")) return src;
1259
+ if (src.includes(".svg")) return src;
1260
+ const segs = [];
1261
+ if (option.avthumb) segs.push(getAvthumb(option.avthumb));
1262
+ if (option.vframe) segs.push(getVframe(option.vframe));
1263
+ if (!segs.length) return src;
1264
+ const base = src.split("?")[0];
1265
+ return `${base}?${segs.join("|")}`;
1266
+ }
1267
+ function getQnAudio(src, option) {
1268
+ if (!src || !option) return src;
1269
+ if (src.startsWith("blob:")) return src;
1270
+ const segs = [];
1271
+ if (option.avthumb) segs.push(getAvthumb(option.avthumb));
1272
+ if (!segs.length) return src;
1273
+ const base = src.split("?")[0];
1274
+ return `${base}?${segs.join("|")}`;
1275
+ }
1276
+ function getQnHls(src, option) {
1277
+ if (!src || !option) return src;
1278
+ if (src.startsWith("blob:")) return src;
1279
+ const seg = getAvcvt(option);
1280
+ if (!seg) return src;
1281
+ const base = src.split("?")[0];
1282
+ return `${base}?${seg}`;
1283
+ }
1284
+ function getImageView2(opt) {
1285
+ if (!opt) return "";
1286
+ const mode = typeof opt.mode === "number" ? opt.mode : 0;
1287
+ const kv = [];
1288
+ for (const [k, v] of Object.entries(opt)) {
1289
+ if (k === "mode") continue;
1290
+ if (typeof v === "boolean") {
1291
+ if (v) kv.push(`${k}/1`);
1292
+ } else if (typeof v === "number" || typeof v === "string") {
1293
+ kv.push(`${k}/${v}`);
1294
+ }
1295
+ }
1296
+ return kv.length ? `imageView2/${mode}/${kv.join("/")}` : `imageView2/${mode}`;
1297
+ }
1298
+ function getImageMogr2(opt) {
1299
+ if (!opt) return "";
1300
+ const parts = [];
1301
+ const tn = opt.thumbnail;
1302
+ if (typeof tn !== "undefined") parts.push(`thumbnail/${tn}`);
1303
+ const cp = opt.crop;
1304
+ if (typeof cp !== "undefined") parts.push(`crop/${cp}`);
1305
+ const rot = opt.rotate;
1306
+ if (typeof rot === "number") parts.push(`rotate/${rot}`);
1307
+ const ao = opt["auto-orient"];
1308
+ if (ao) parts.push("auto-orient");
1309
+ const fmt = opt.format;
1310
+ if (typeof fmt === "string") parts.push(`format/${fmt}`);
1311
+ const il = opt.interlace;
1312
+ if (il === 0 || il === 1) parts.push(`interlace/${il}`);
1313
+ const bg = opt.background;
1314
+ if (typeof bg === "string") parts.push(`background/${bg}`);
1315
+ const q = opt.q;
1316
+ if (typeof q === "number") parts.push(`q/${q}`);
1317
+ const blur = opt.blur;
1318
+ if (typeof blur !== "undefined") {
1319
+ if (typeof blur === "string") parts.push(`blur/${blur}`);
1320
+ else parts.push(`blur/${blur.r}x${blur.s}`);
1321
+ }
1322
+ const colors = opt.colors;
1323
+ if (typeof colors === "number") parts.push(`colors/${colors}`);
1324
+ return parts.length ? `imageMogr2/${parts.join("/")}` : "";
1325
+ }
1326
+ function getWatermark2(w) {
1327
+ if (!w) return "";
1328
+ const mode = w.type === "image" ? 1 : w.type === "text" ? 2 : typeof w.type === "number" ? w.type : 2;
1329
+ const segs = [`watermark/${mode}`];
1330
+ if (mode === 1 && w.image) segs.push(`image/${toBase64Url2(w.image)}`);
1331
+ if (mode === 2 && w.text) segs.push(`text/${toBase64Url2(w.text)}`);
1332
+ if (w.font) segs.push(`font/${toBase64Url2(w.font)}`);
1333
+ if (typeof w.fontsize === "number") segs.push(`fontsize/${w.fontsize}`);
1334
+ if (w.fill) segs.push(`fill/${toBase64Url2(w.fill)}`);
1335
+ if (w.gravity) segs.push(`gravity/${w.gravity}`);
1336
+ if (typeof w.dx === "number") segs.push(`dx/${w.dx}`);
1337
+ if (typeof w.dy === "number") segs.push(`dy/${w.dy}`);
1338
+ if (typeof w.dissolve === "number") segs.push(`dissolve/${w.dissolve}`);
1339
+ return segs.join("/");
1340
+ }
1341
+ function toBase64Url2(s) {
1342
+ let b64 = "";
1343
+ if (typeof Buffer !== "undefined") {
1344
+ const buf = Buffer.from(s, "utf-8");
1345
+ b64 = buf.toString("base64");
1346
+ } else {
1347
+ try {
1348
+ b64 = btoa(unescape(encodeURIComponent(s)));
1349
+ } catch (e) {
1350
+ b64 = "";
1351
+ }
1352
+ }
1353
+ return b64.replace(/=+$/g, "").replace(/\+/g, "-").replace(/\//g, "_");
1354
+ }
1355
+ function getAvthumb(opt) {
1356
+ const parts = [];
1357
+ if (opt.format) parts.push(`avthumb/${opt.format}`);
1358
+ else parts.push("avthumb");
1359
+ if (opt.s) parts.push(`s/${opt.s}`);
1360
+ if (opt.vcodec) parts.push(`vcodec/${opt.vcodec}`);
1361
+ if (typeof opt.vb !== "undefined") parts.push(`vb/${opt.vb}`);
1362
+ if (typeof opt.r === "number") parts.push(`r/${opt.r}`);
1363
+ if (typeof opt.ab !== "undefined") parts.push(`ab/${opt.ab}`);
1364
+ if (typeof opt.ar === "number") parts.push(`ar/${opt.ar}`);
1365
+ if (opt.acodec) parts.push(`acodec/${opt.acodec}`);
1366
+ return parts.join("/");
1367
+ }
1368
+ function getVframe(opt) {
1369
+ const parts = [];
1370
+ parts.push(`vframe/${opt.format || "jpg"}`);
1371
+ if (typeof opt.offset === "number") parts.push(`offset/${opt.offset}`);
1372
+ if (typeof opt.w === "number") parts.push(`w/${opt.w}`);
1373
+ if (typeof opt.h === "number") parts.push(`h/${opt.h}`);
1374
+ return parts.join("/");
1375
+ }
1376
+ function getAvcvt(opt) {
1377
+ const parts = [];
1378
+ const level = typeof opt.level === "number" ? `/${opt.level}` : "/3";
1379
+ parts.push(`avcvt${level}`);
1380
+ parts.push(`format/${opt.format || "m3u8"}`);
1381
+ if (typeof opt.segtime === "number") parts.push(`segtime/${opt.segtime}`);
1382
+ if (typeof opt.t === "string") parts.push(`t/${opt.t}`);
1383
+ if (opt.vcodec) parts.push(`vcodec/${opt.vcodec}`);
1384
+ if (typeof opt.vb !== "undefined") parts.push(`vb/${opt.vb}`);
1385
+ if (typeof opt.r === "number") parts.push(`r/${opt.r}`);
1386
+ if (typeof opt.s === "string") parts.push(`s/${opt.s}`);
1387
+ if (opt.acodec) parts.push(`acodec/${opt.acodec}`);
1388
+ if (typeof opt.ab !== "undefined") parts.push(`ab/${opt.ab}`);
1389
+ if (typeof opt.ar === "number") parts.push(`ar/${opt.ar}`);
1390
+ if (typeof opt.output === "string") parts.push(`output/${toBase64Url2(opt.output)}`);
1391
+ return parts.join("/");
1392
+ }
1393
+
1394
+ // src/ts/validator/index.ts
1395
+ function isLetter(s) {
1396
+ return /^[a-zA-Z]*$/.test(s);
1397
+ }
1398
+ function isChinese(s) {
1399
+ const v = String(s != null ? s : "").trim();
1400
+ return /^[\u4E00-\u9FA5]+$/.test(v);
1401
+ }
1402
+ function isDigits(s) {
1403
+ return /^[0-9]+$/.test(s);
1404
+ }
1405
+ function isNumeric(value, options) {
1406
+ const { negative = false, decimal = 2, thousands = false, leadZero = false } = options || {};
1407
+ if (value === null || value === void 0 || value === "") return false;
1408
+ const str = String(value).trim();
1409
+ const sign = negative && str.startsWith("-") ? "-" : "";
1410
+ const body = sign ? str.slice(1) : str;
1411
+ const thousandsPart = thousands ? "(?:[1-9]\\d{0,2}(,\\d{3})*|0)" : "(?:\\d+)";
1412
+ const intPart = thousands ? thousandsPart : leadZero ? "(?:\\d+)" : "(?:0|[1-9]\\d*)";
1413
+ const fracPart = decimal === 0 ? "" : `(\\.\\d{1,${decimal}})`;
1414
+ const pattern = `^${intPart}${fracPart}$`;
1415
+ const reg = new RegExp(pattern);
1416
+ return reg.test(body);
1417
+ }
1418
+ function isMobilePhone(s) {
1419
+ const v = String(s != null ? s : "").trim();
1420
+ return /^1[3-9]\d{9}$/.test(v);
1421
+ }
1422
+ function isLandline(s) {
1423
+ const v = String(s != null ? s : "").trim();
1424
+ return /^0\d{2,3}-?\d{7,8}(?:-\d{1,6})?$/.test(v);
1425
+ }
1426
+ function isPhone(s) {
1427
+ return isMobilePhone(s) || isLandline(s);
1428
+ }
1429
+ function isEmail(s) {
1430
+ const v = String(s != null ? s : "").trim();
1431
+ if (v === "") return false;
1432
+ 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])?)+$/;
1433
+ return emailRegex.test(v);
1434
+ }
1435
+ function isChineseName(s) {
1436
+ const v = String(s != null ? s : "").trim();
1437
+ return /^[\u4E00-\u9FA5·]{2,20}$/.test(v);
1438
+ }
1439
+ function isIdentityCard(code) {
1440
+ const v = String(code != null ? code : "").trim();
1441
+ if (v === "") return false;
1442
+ const isValidDate = (yyyymmdd) => {
1443
+ const y = Number(yyyymmdd.slice(0, 4));
1444
+ const m = Number(yyyymmdd.slice(4, 6));
1445
+ const d = Number(yyyymmdd.slice(6, 8));
1446
+ if (y < 1900 || y > 2100) return false;
1447
+ const date = new Date(y, m - 1, d);
1448
+ return date.getFullYear() === y && date.getMonth() === m - 1 && date.getDate() === d;
1449
+ };
1450
+ if (/^\d{17}[\dXx]$/.test(v)) {
1451
+ const birth = v.slice(6, 14);
1452
+ if (!isValidDate(birth)) return false;
1453
+ const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
1454
+ const checkMap = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
1455
+ let sum = 0;
1456
+ for (let i = 0; i < 17; i++) sum += Number(v[i]) * weights[i];
1457
+ const mod = sum % 11;
1458
+ const code18 = v[17].toUpperCase();
1459
+ return checkMap[mod] === code18;
1460
+ }
1461
+ if (/^\d{15}$/.test(v)) {
1462
+ const birth = v.slice(6, 12);
1463
+ const y = Number(`19${birth.slice(0, 2)}`);
1464
+ const m = Number(birth.slice(2, 4));
1465
+ const d = Number(birth.slice(4, 6));
1466
+ const date = new Date(y, m - 1, d);
1467
+ return date.getFullYear() === y && date.getMonth() === m - 1 && date.getDate() === d;
1468
+ }
1469
+ if (/^[A-Za-z][12]\d{8}$/.test(v)) return true;
1470
+ if (/^[A-Za-z]{1,2}\d{6}\(?[0-9A]\)?$/.test(v)) return true;
1471
+ if (/^[157]\d{6}\(?\d\)?$/.test(v)) return true;
1472
+ return false;
1473
+ }
1474
+ function isPassport(s) {
1475
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim();
1476
+ if (t === "") return false;
1477
+ if (/^[EG]\d{8}$/.test(t)) return true;
1478
+ if (/^[DPS]\d{7}$/.test(t)) return true;
1479
+ if (/^[A-Za-z]\d{8}$/.test(t)) return true;
1480
+ if (/^[A-Za-z0-9]{6,9}$/.test(t)) return true;
1481
+ return false;
1482
+ }
1483
+ function isHKMOPermit(s) {
1484
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim().toUpperCase();
1485
+ return /^[HM]\d{8,10}$/.test(t);
1486
+ }
1487
+ function isTaiwanPermit(s) {
1488
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim().toUpperCase();
1489
+ if (/^\d{8}$/.test(t)) return true;
1490
+ if (/^[A-Z]\d{8}$/.test(t)) return true;
1491
+ if (/^\d{10}$/.test(t)) return true;
1492
+ return false;
1493
+ }
1494
+ function isOfficerId(s) {
1495
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim().toUpperCase();
1496
+ return /^[A-Z0-9]{7,18}$/.test(t);
1497
+ }
1498
+ function isSoldierId(s) {
1499
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim().toUpperCase();
1500
+ return /^[A-Z0-9]{7,18}$/.test(t);
1501
+ }
1502
+ function isMilitaryId(s) {
1503
+ return isOfficerId(s) || isSoldierId(s);
1504
+ }
1505
+ function isBankCard(s) {
1506
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim();
1507
+ if (!/^\d{12,19}$/.test(t)) return false;
1508
+ let sum = 0;
1509
+ let shouldDouble = false;
1510
+ for (let i = t.length - 1; i >= 0; i--) {
1511
+ let digit = Number(t[i]);
1512
+ if (shouldDouble) {
1513
+ digit *= 2;
1514
+ if (digit > 9) digit -= 9;
1515
+ }
1516
+ sum += digit;
1517
+ shouldDouble = !shouldDouble;
1518
+ }
1519
+ return sum % 10 === 0;
1520
+ }
1521
+ function isLicensePlate(s) {
1522
+ const v = String(s != null ? s : "").trim().toUpperCase();
1523
+ 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";
1524
+ 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]$`);
1525
+ const ne1 = new RegExp(`^[${prov}][A-HJ-NP-Z][DF][A-HJ-NP-Z0-9]{5}$`);
1526
+ const ne2 = new RegExp(`^[${prov}][A-HJ-NP-Z][A-HJ-NP-Z0-9]{5}[DF]$`);
1527
+ return std.test(v) || ne1.test(v) || ne2.test(v);
1528
+ }
1529
+ function isTaxID(code) {
1530
+ const v = String(code != null ? code : "").trim();
1531
+ if (!/^[0-9A-HJ-NPQRTUWXY]{18}$/.test(v)) return false;
1532
+ const charset = "0123456789ABCDEFGHJKLMNPQRTUWXY";
1533
+ const weights = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28];
1534
+ const map = {};
1535
+ for (let i = 0; i < charset.length; i++) map[charset[i]] = i;
1536
+ let sum = 0;
1537
+ for (let i = 0; i < 17; i++) {
1538
+ sum += map[v[i]] * weights[i];
1539
+ }
1540
+ const logicCheck = (31 - sum % 31) % 31;
1541
+ const expected = charset[logicCheck];
1542
+ return v[17] === expected;
1543
+ }
1544
+ function isHexColor(s) {
1545
+ const v = String(s != null ? s : "").trim();
1546
+ return /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(v);
1547
+ }
1548
+ function isURL(s) {
1549
+ const v = String(s != null ? s : "").trim();
1550
+ if (v === "") return false;
1551
+ try {
1552
+ const u = new URL(v);
1553
+ return ["http:", "https:", "ftp:"].includes(u.protocol) && !!u.hostname;
1554
+ } catch (e) {
1555
+ return false;
1556
+ }
1557
+ }
1558
+ function isIPv4(s) {
1559
+ const v = String(s != null ? s : "").trim();
1560
+ if (v === "") return false;
1561
+ const parts = v.split(".");
1562
+ if (parts.length !== 4) return false;
1563
+ for (const p of parts) {
1564
+ if (!/^\d+$/.test(p)) return false;
1565
+ if (p.length > 1 && p.startsWith("0")) return false;
1566
+ const n = Number(p);
1567
+ if (n < 0 || n > 255) return false;
1568
+ }
1569
+ return true;
1570
+ }
1571
+ function isIPv6(s) {
1572
+ const v = String(s != null ? s : "").trim();
1573
+ if (v === "") return false;
1574
+ const lastColon = v.lastIndexOf(":");
1575
+ if (lastColon !== -1 && v.includes(".")) {
1576
+ const ipv6Part = v.slice(0, lastColon);
1577
+ const ipv4Part = v.slice(lastColon + 1);
1578
+ return isIPv6(ipv6Part) && isIPv4(ipv4Part);
1579
+ }
1580
+ const dblColonCount = (v.match(/::/g) || []).length;
1581
+ if (dblColonCount > 1) return false;
1582
+ const segments = v.split(":");
1583
+ if (v.startsWith("::")) segments.shift();
1584
+ if (v.endsWith("::")) segments.pop();
1585
+ const segmentsFiltered = segments.filter((seg) => seg !== "");
1586
+ if (dblColonCount === 0 && segmentsFiltered.length !== 8) return false;
1587
+ if (dblColonCount === 1 && segmentsFiltered.length >= 1 && segmentsFiltered.length <= 7) {
1588
+ } else if (dblColonCount === 1 && segments.length === 0) {
1589
+ return true;
1590
+ } else if (dblColonCount === 0 && segmentsFiltered.length === 8) {
1591
+ } else {
1592
+ return false;
1593
+ }
1594
+ return segmentsFiltered.every(
1595
+ (seg) => seg.length >= 1 && seg.length <= 4 && /^[0-9a-fA-F]{1,4}$/.test(seg)
1596
+ );
1597
+ }
1598
+ function isIP(s, version) {
1599
+ if (version === 4 || version === "4") return isIPv4(s);
1600
+ if (version === 6 || version === "6") return isIPv6(s);
1601
+ return isIPv4(s) || isIPv6(s);
1602
+ }
1603
+ function isIPRange(s) {
1604
+ const v = String(s != null ? s : "").trim();
1605
+ if (v === "") return false;
1606
+ const parts = v.split("/");
1607
+ if (parts.length !== 2) return false;
1608
+ const [ip, prefixStr] = parts;
1609
+ if (!/^\d+$/.test(prefixStr)) return false;
1610
+ const prefix = Number(prefixStr);
1611
+ if (ip.includes(":")) {
1612
+ if (!isIPv6(ip)) return false;
1613
+ return prefix >= 0 && prefix <= 128;
1614
+ }
1615
+ if (!isIPv4(ip)) return false;
1616
+ return prefix >= 0 && prefix <= 32;
1617
+ }
1618
+ function isPortNumber(s) {
1619
+ const v = typeof s === "number" ? s : Number(String(s != null ? s : "").trim());
1620
+ return Number.isInteger(v) && v >= 0 && v <= 65535;
1621
+ }
1622
+ function isLatitude(s) {
1623
+ const v = typeof s === "number" ? s : Number(String(s != null ? s : "").trim());
1624
+ return Number.isFinite(v) && v >= -90 && v <= 90;
1625
+ }
1626
+ function isLongitude(s) {
1627
+ const v = typeof s === "number" ? s : Number(String(s != null ? s : "").trim());
1628
+ return Number.isFinite(v) && v >= -180 && v <= 180;
1629
+ }
1630
+
626
1631
  // src/web/network/request.ts
627
- var import_base_tools_ts = require("@base-web-kits/base-tools-ts");
628
1632
  var requestCache = /* @__PURE__ */ new Map();
629
1633
  function request(config) {
630
1634
  const controller = new AbortController();
@@ -662,18 +1666,19 @@ function request(config) {
662
1666
  timeout = 6e4
663
1667
  } = config;
664
1668
  const isGet = method === "GET";
665
- const isObjectData = (0, import_base_tools_ts.isPlainObject)(data);
1669
+ const isObjectData = (0, ts_exports.isPlainObject)(data);
666
1670
  const isArrayData = !isObjectData && Array.isArray(data);
667
- const fillData = isObjectData ? (0, import_base_tools_ts.pickBy)(data, (val) => val !== void 0) : data;
668
- const fillHeader = header ? (0, import_base_tools_ts.pickBy)(header, (val) => !!val) : {};
1671
+ const fillData = isObjectData ? (0, ts_exports.pickBy)(data, (val) => val !== void 0) : data;
1672
+ const emptyValue = [void 0, null, ""];
1673
+ const fillHeader = header ? (0, ts_exports.pickBy)(header, (val) => !emptyValue.includes(val)) : {};
669
1674
  const contentTypeKey = Object.keys(fillHeader).find(
670
1675
  (k) => k.toLowerCase() === "content-type"
671
1676
  );
672
- const contentType = contentTypeKey ? fillHeader[contentTypeKey].toLowerCase() : "";
1677
+ const contentType = contentTypeKey ? String(fillHeader[contentTypeKey]).toLowerCase() : "";
673
1678
  if (!isGet && fillData && (isObjectData || isArrayData) && !contentType) {
674
1679
  fillHeader["Content-Type"] = "application/json";
675
1680
  }
676
- const fillUrl = isGet && isObjectData ? (0, import_base_tools_ts.appendUrlParam)(url, fillData) : url;
1681
+ const fillUrl = isGet && isObjectData ? appendUrlParam(url, fillData) : url;
677
1682
  let fillBody;
678
1683
  if (!isGet && fillData) {
679
1684
  if (isObjectData && contentType.includes("application/x-www-form-urlencoded")) {
@@ -733,9 +1738,9 @@ function request(config) {
733
1738
  const resData = yield parseResponse(response, responseType);
734
1739
  if (showLoading) (_d = appConfig2.hideLoading) == null ? void 0 : _d.call(appConfig2);
735
1740
  const res = responseInterceptor ? responseInterceptor(resData) : resData;
736
- const code = (0, import_base_tools_ts.getObjectValue)(res, codeKey);
737
- const scode = successKey ? (0, import_base_tools_ts.getObjectValue)(res, successKey) : code;
738
- const msg = (0, import_base_tools_ts.getObjectValue)(res, msgKey);
1741
+ const code = getObjectValue(res, codeKey);
1742
+ const scode = successKey ? getObjectValue(res, successKey) : code;
1743
+ const msg = getObjectValue(res, msgKey);
739
1744
  const isSuccess = successCode.includes(scode);
740
1745
  const isRelogin = reloginCode.includes(code);
741
1746
  logRequestInfo({ status: "success", config: logConfig, startTime, res });
@@ -787,12 +1792,12 @@ function logRequestInfo(options) {
787
1792
  method,
788
1793
  header,
789
1794
  fromCache,
790
- startTime: (0, import_base_tools_ts.toDayjs)(startTime).format(fmt),
791
- endTime: (0, import_base_tools_ts.toDayjs)(endTime).format(fmt),
1795
+ startTime: toDayjs(startTime).format(fmt),
1796
+ endTime: toDayjs(endTime).format(fmt),
792
1797
  duration: endTime - startTime
793
1798
  }, extraLog);
794
1799
  if (status === "success") {
795
- info.res = (0, import_base_tools_ts.cloneDeep)(res);
1800
+ info.res = (0, ts_exports.cloneDeep)(res);
796
1801
  log("info", info);
797
1802
  } else {
798
1803
  info.e = e;
@@ -801,7 +1806,7 @@ function logRequestInfo(options) {
801
1806
  }
802
1807
  function getResult(res, resKey) {
803
1808
  if (!res || !resKey || typeof res !== "object") return res;
804
- return (0, import_base_tools_ts.getObjectValue)(res, resKey);
1809
+ return getObjectValue(res, resKey);
805
1810
  }
806
1811
  function checkCache(cacheKey) {
807
1812
  const cached = requestCache.get(cacheKey);