@base-web-kits/base-tools-web 1.1.3 → 1.1.6

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