xk-gibbonlibs
Version:
GIBBON 公共工具库
762 lines (761 loc) • 23.6 kB
JavaScript
const L = (t, e, r, ...n) => async () => {
const s = [];
for (let o = 0; o < t; o++) {
const c = await new Promise((a, i) => {
setTimeout(async () => {
try {
const l = await e[o](...n);
a(l);
} catch (l) {
i(l);
}
}, r);
});
s.push(c);
}
return s;
}, J = (t, e, r) => {
let n, s = !1, o = {};
const c = async (l) => {
clearTimeout(n);
const u = await e(l), f = l !== o;
r(l, u, f), !f && !s && (n = setTimeout(() => c(l), t));
};
return {
run: (l) => {
s = !1, o = { ...l }, c(o);
},
destroy: () => {
s = !0, clearTimeout(n);
}
};
}, H = (t) => {
const e = [];
let r = 0;
const n = () => {
r--, e.length > 0 && e.shift()();
}, s = async (a, i, ...l) => {
r++;
const u = (async () => a(...l))();
try {
const f = await u;
i(f);
} catch (f) {
console.error(f);
}
n();
}, o = (a, i, ...l) => {
e.push(s.bind(null, a, i, ...l)), r < t && e.length > 0 && e.shift()();
};
return (a, ...i) => new Promise((l) => {
o(a, l, ...i);
});
}, Z = (t, e) => {
function* r() {
for (let c = 0; c < t.length; c++)
yield t[c];
}
const n = r(), s = () => new Promise((c, a) => {
o(n.next(), c, a);
});
function o(c, a, i) {
c.done ? a() : c.value(
() => {
const l = n.next();
l.done ? a() : o(l, a, i);
},
e,
(l) => {
i(l);
}
);
}
return s();
}, q = (t, e) => {
const r = {
1: "\\d",
a: "[a-z]",
A: "[A-Z]",
"@": "[^\\w\\s]",
汉: "[一-龥]"
}, n = t.split(":");
let s = "^", o = 0;
return n.forEach((a) => {
r[a] ? s += `(?=.*${r[a]})` : isNaN(Number(a)) || (o = Number(a));
}), s += `.{${o},}$`, new RegExp(s).test(e);
}, B = (t) => {
if (t == null || t === "" || t.length !== 10)
return !1;
let e = t.substring(0, 1);
const r = t.substring(1, 10), n = t.substring(1, 2);
e = e.toUpperCase();
const s = /^[0-9]+$/, o = /^[A-Za-z]+$/;
if (!s.test(r) || n !== "1" && n !== "2" || !o.test(e))
return !1;
const c = "ABCDEFGHJKLMNPQRSTUVXYWZIO", a = [
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31",
"32",
"33",
"34",
"35"
], i = c.indexOf(e);
if (i === -1)
return !1;
const l = a[i].substring(0, 1), u = a[i].substring(1, 2), p = (parseInt(l) + 9 * parseInt(u) + 8 * parseInt(r.substring(0, 1)) + 7 * parseInt(r.substring(1, 2)) + 6 * parseInt(r.substring(2, 3)) + 5 * parseInt(r.substring(3, 4)) + 4 * parseInt(r.substring(4, 5)) + 3 * parseInt(r.substring(5, 6)) + 2 * parseInt(r.substring(6, 7)) + parseInt(r.substring(7, 8))) % 10;
return 10 - p === parseInt(r.substring(8, 9)) ? !0 : p === 10 && parseInt(r.substring(8, 9)) === 0;
}, _ = (t) => {
if (!/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}[\dXx]$/.test(t))
return !1;
const r = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], n = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"], s = t.toUpperCase().split("");
let o = 0;
for (let i = 0; i < 17; i++)
o += parseInt(s[i]) * r[i];
const c = o % 11;
return n[c] === s[17];
}, z = (t) => /^[EGSD]\d{8}$/.test(t), X = (t) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t), G = (t) => {
if (!/^[A-Z]{1,2}\d{6}\([0-9A]\)$/.test(t))
return !1;
const r = (u) => u >= "A" && u <= "Z" ? u.charCodeAt(0) - 55 : parseInt(u, 10), n = t.match(/^([A-Z]{1,2})(\d{6})\(([0-9A])\)$/);
if (!n)
return !1;
let s = 0;
const o = n[1].split(""), c = n[2].split(""), a = n[3];
o.length === 2 ? (s += r(o[0]) * 9, s += r(o[1]) * 8) : (s += 324, s += r(o[0]) * 8);
for (let u = 0; u < 6; u++)
s += parseInt(c[u], 10) * (7 - u);
const i = s % 11;
return (i === 0 ? "0" : i === 1 ? "A" : (11 - i).toString()) === a.toUpperCase();
}, K = (t) => /^[15]\d{7}$/.test(t), Q = (t, e) => {
const r = t.split(":");
let n = !1, s = !1, o = !1, c = null;
r.forEach((l) => {
l === "P" ? n = !0 : l === "N" ? s = !0 : l === "NZ" ? o = !0 : l.startsWith("D") && (c = parseInt(l.slice(1), 10));
});
let a = "^";
return n && s ? a += "-?\\d+" : n ? a += "[1-9]\\d*" : s ? a += "-[1-9]\\d*" : a += "-?\\d+(\\.\\d+)?", c !== null ? a += `\\.\\d{${c}}` : t.includes("D") && (a += "(\\.\\d+)?"), a += "$", !(!new RegExp(a).test(e) || o && parseFloat(e) === 0);
}, tt = (t, e) => {
const r = {
fcp: "first-contentful-paint:paint"
};
t = t && t.toLowerCase() || "fcp";
let [n, s] = (r[t] || "first-contentful-paint:paint").split(":"), o = null;
const c = (l) => {
for (const u of l.getEntries())
u.name === n && (o == null || o.disconnect()), typeof e == "function" && e(u);
};
return {
mount: () => {
o = new PerformanceObserver(c), o.observe({ type: s, buffered: !0 });
},
unmount: () => {
o && (o.disconnect(), o = null);
}
};
}, et = (t, e, r = !1) => {
let n = null;
const s = function(...o) {
const c = this;
if (n && clearTimeout(n), r) {
const a = !n;
n = setTimeout(() => {
n = null;
}, e), a && t.apply(c, o);
} else
n = setTimeout(() => {
t.apply(c, o);
}, e);
};
return s.remove = () => {
n && (clearTimeout(n), n = null);
}, s;
}, rt = (t, e) => {
let r = null, n = (/* @__PURE__ */ new Date()).getTime();
return function(...s) {
const o = this, c = (/* @__PURE__ */ new Date()).getTime();
clearTimeout(r), c - n >= e ? (t.apply(o, s), n = c) : r = setTimeout(() => {
t.apply(o, s);
}, e);
};
}, nt = (t, e = "id", r = "parentId", n = "children") => {
if (!Array.isArray(t))
throw new TypeError("Expected an array of items");
const s = {}, o = [];
return t.forEach((c) => {
if (!c[e])
throw new Error(`Item is missing the '${e}' field`);
s[c[e]] = { ...c, [n]: [] };
}), t.forEach((c) => {
if (typeof c[r] > "u" || c[r] === null)
o.push(s[c[e]]);
else if (s[c[r]])
s[c[r]][n].push(s[c[e]]);
else
throw new Error(`Parent ID '${c[r]}' not found for item with ID '${c[e]}'`);
}), o;
}, st = (t, e = "id", r = "parentId", n = "children") => {
if (!Array.isArray(t))
throw new TypeError("Expected an array of tree nodes");
const s = [], o = (c, a) => {
const i = { ...c };
delete i[n], i[r] = a, s.push(i), c[n] && Array.isArray(c[n]) && c[n].forEach((l) => o(l, c[e]));
};
return t.forEach((c) => {
if (!c[e])
throw new Error(`Root node is missing the '${e}' field`);
o(c, null);
}), s;
}, ot = (t, e, r, n = "children") => {
if (!Array.isArray(t))
throw new TypeError("Expected an array of tree nodes");
if (typeof e != "string")
throw new TypeError("Expected key to be a string");
let s = [];
const o = (c, a) => {
for (const i of c) {
const l = [...a, i];
if (i[e] === r)
return s = l, !0;
if (i[n] && Array.isArray(i[n]) && i[n].length > 0 && o(i[n], l))
return !0;
}
return !1;
};
return o(t, []), s;
}, w = (t) => {
if (t === null || typeof t != "object")
return t;
if (Array.isArray(t))
return t.map((r) => w(r));
const e = {};
for (const r of Object.keys(t))
e[r] = w(t[r]);
return e;
}, A = (t, e, r) => {
if (!(r === null || typeof r != "object"))
if (Array.isArray(r))
Array.isArray(t) || (t = []), r.forEach((n, s) => {
typeof e[s] < "u" && (typeof t[s] == "object" ? A(t[s], e[s], n) : t[s] = w(e[s]));
});
else {
(typeof t != "object" || t === null) && (t = {});
for (const n of Object.keys(r))
typeof e[n] < "u" && (e[n] !== null && typeof e[n] == "object" && n in t ? A(t[n], e[n], r[n]) : t[n] = w(e[n]));
}
}, ct = (t, e) => (A(e, t, e), e), at = (t, e = null, r = !1) => {
if (Array.isArray(t))
return r ? P(t, e) : x(t, e);
throw new Error("Invalid input: input should be an array or an array of objects.");
}, x = (t, e) => t.length === 0 || typeof t[0] != "object" && e !== null ? O(t) : v(t, e), O = (t) => {
let e = [], r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
for (let s of t)
r.has(s) ? n.add(s) : r.add(s);
return e = Array.from(n), e;
}, P = (t, e) => t.length === 0 || typeof t[0] != "object" && e !== null ? [...new Set(t)] : T(t, e), T = (t, e) => {
let r = [], n = /* @__PURE__ */ new Set();
for (let s of t) {
let o = e ? s[e] : JSON.stringify(s);
n.has(o) || (n.add(o), r.push(s));
}
return r;
}, v = (t, e) => {
let r = [], n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
for (let o of t) {
let c = e ? o[e] : JSON.stringify(o);
n.has(c) ? s.add(c) : n.add(c);
}
return s.forEach((o) => {
e ? r.push(t.find((c) => c[e] === o)) : r.push(JSON.parse(o));
}), r;
}, it = (t, e) => {
const r = t.reduce((n, s) => {
const o = s[e];
return n[o] || (n[o] = []), n[o].push(s), n;
}, {});
return Object.values(r);
}, lt = (t, e = null) => {
if (!Array.isArray(t))
throw new Error("Invalid input: input should be an array or an array of objects.");
return t.length === 0 ? t : typeof t[0] == "object" && e ? t.slice().sort((r, n) => r[e] < n[e] ? -1 : r[e] > n[e] ? 1 : 0) : t.slice().sort();
}, ut = (t, e) => {
const r = [], n = (s, o) => {
if (o === e.length) {
r.push({ ...s, sku: Object.values(s).join("-") });
return;
}
const c = e[o];
t[c].forEach((i) => {
n({ ...s, [c]: i }, o + 1);
});
};
return n({}, 0), r;
}, ft = (t, e) => {
if (Array.isArray(t))
return t.map((r) => {
if (typeof r == "object" && r !== null) {
const { [e]: n, ...s } = r;
return s;
}
return r;
});
if (typeof t == "object" && t !== null) {
const { [e]: r, ...n } = t;
return n;
}
return t;
}, gt = (t, e, r) => {
const n = (o) => JSON.parse(JSON.stringify(o)), s = (o) => typeof o == "object" && o !== null ? typeof r == "string" && typeof o[r] < "u" ? { ...o, [e]: n(o[r]) } : { ...o, [e]: n(r) } : o;
return Array.isArray(t) ? t.map((o) => s(o)) : typeof t == "object" && t !== null ? s(t) : t;
}, C = (t) => Array.isArray(t), $ = (t, e) => {
const r = (n) => n && typeof n == "object";
return !r(t) || !r(e) ? e : (Object.keys(e).forEach((n) => {
const s = t[n], o = e[n];
C(s) && C(o) ? t[n] = s.concat(o) : r(s) && r(o) ? t[n] = $(Object.assign({}, s), o) : t[n] = o;
}), t);
}, ht = (t, e, r, n, s = "children") => {
const o = [], c = (a) => {
for (let i of a)
i[e] === r && o.push(n ? n(i) : i), i[s] && Array.isArray(i[s]) && c(i[s]);
};
return c(t), o;
}, dt = (t, e) => new Date(t, e - 1, 1).getDay(), yt = (t, e) => new Date(t, e, 0).getDate(), pt = (t, e) => {
const r = [], n = k(t, e);
let o = U(t, e - 1);
for (; r.length < n; )
r.push(o--);
return r.reverse();
}, k = (t, e) => new Date(t, e - 1, 1).getDay(), U = (t, e) => new Date(t, e, 0).getDate(), mt = (t, e) => {
const r = N(t, e), n = j(t, e), o = 42 - (r + n), c = [], a = 1;
for (let i = a; i <= o; i++)
c.push(i);
return c;
}, N = (t, e) => new Date(t, e - 1, 1).getDay(), j = (t, e) => new Date(t, e, 0).getDate(), wt = (t) => {
const e = t ? new Date(t) : /* @__PURE__ */ new Date();
return [
e.getFullYear(),
e.getMonth() + 1,
e.getDate()
];
}, Dt = (t, e, r, n = "-") => {
const s = [t, e, r];
for (let o = 1; o < s.length; o++)
s[o] < 10 && (s[o] = "0" + s[o]);
return s.join(n);
}, St = (t, e) => {
e = e - 1;
const r = new Date(t, e, 1), n = r.getMonth() === 0 ? new Date(t - 1, 11) : new Date(t, r.getMonth() - 1);
return {
lastYear: n.getFullYear(),
lastMonth: n.getMonth() + 1
};
}, At = (t, e) => {
const r = new Date(t, e, 1);
return e === 12 ? (r.setFullYear(t + 1), r.setMonth(0)) : r.setMonth(e), {
nextYear: r.getFullYear(),
nextMonth: r.getMonth() + 1
// 修正此处,getMonth() 从0开始
};
}, R = (t, e) => {
const r = t.getFullYear(), n = (t.getMonth() + 1).toString().padStart(2, "0"), s = t.getDate().toString().padStart(2, "0"), o = t.getHours().toString().padStart(2, "0"), c = t.getMinutes().toString().padStart(2, "0"), a = t.getSeconds().toString().padStart(2, "0"), i = V(t), l = {
Y: r.toString(),
M: n,
D: s,
h: o,
m: c,
s: a,
W: i
};
let u = "";
for (let f = 0; f < e.length; f++) {
const p = e[f];
typeof l[p] < "u" ? u += l[p] : u += p;
}
return u;
}, V = (t) => {
const r = new Date(t.getFullYear(), t.getMonth(), 1).getDay();
return `第${Math.ceil((t.getDate() + r - 1) / 7)}周`;
}, Et = (t, e) => {
let r;
if (typeof t == "string") {
const n = t.split("-");
if (n.length === 3) {
r = new Date(Number(n[0]), Number(n[1]) - 1, Number(n[2]));
const s = /* @__PURE__ */ new Date();
r.setHours(s.getHours(), s.getMinutes(), s.getSeconds());
} else
r = new Date(t);
} else typeof t == "number" ? r = new Date(t) : r = /* @__PURE__ */ new Date();
return R(r, e);
}, bt = (t, e, r) => {
const n = {
Y: "",
M: "",
D: "",
h: "",
m: "",
s: "",
W: ""
};
let s = 0;
for (let a = 0; a < e.length; a++) {
const i = e[a];
if (typeof n[i] < "u") {
let l = "";
for (; s < t.length && t[s] !== e[a + 1]; )
l += t[s], s++;
n[i] = l;
} else
s++;
}
if (n.W) {
const a = parseInt(n.Y), i = parseInt(n.M) - 1, l = parseInt(n.W.replace("第", "").replace("周", "")), u = new Date(a, i, 1), f = u.getDay();
u.setDate(u.getDate() + (l - 1) * 7 - f + 1), n.D = u.getDate().toString().padStart(2, "0");
}
const o = /* @__PURE__ */ new Date();
n.h = n.h || o.getHours().toString().padStart(2, "0"), n.m = n.m || o.getMinutes().toString().padStart(2, "0"), n.s = n.s || o.getSeconds().toString().padStart(2, "0");
let c = "";
for (let a = 0; a < r.length; a++) {
const i = r[a];
n[i] !== void 0 ? c += n[i] : c += i;
}
return c;
}, Ct = (t) => Array.isArray(t), It = (t) => typeof t == "function", Mt = (t) => typeof t == "number", xt = (t) => t !== null && typeof t == "object" && !Array.isArray(t), Ot = (t) => typeof t == "string", F = (t) => t !== null && typeof t == "object" && !Array.isArray(t), W = (t) => Array.isArray(t), Pt = (t) => t == null || F(t) && Object.keys(t).length === 0 || W(t) && t.length === 0, Tt = (t = null, e) => {
if (typeof e != "object" || e === null)
throw new Error("第二个参数必须是对象");
const r = t || window.location.href, n = new URL(r);
return Object.keys(e).forEach((o) => {
n.searchParams.append(o, e[o]);
}), n.origin + n.search;
}, vt = (t = null) => {
const e = t || window.location.href, r = new URL(e), n = new URLSearchParams(r.search), s = {};
return n.forEach((o, c) => {
s[c] = o;
}), s;
}, $t = {
/**
* 设置本地存储项
* @param {string} key - 存储项的键
* @param {any} value - 存储项的值
*/
setItem(t, e) {
try {
const r = JSON.stringify(e);
localStorage.setItem(t, r);
} catch (r) {
console.error("Error setting item to localStorage", r);
}
},
/**
* 获取本地存储项
* @param {string} key - 存储项的键
* @returns {any} - 存储项的值,如果解析失败则返回 null
*/
getItem(t) {
try {
const e = localStorage.getItem(t);
return e === null ? null : JSON.parse(e);
} catch (e) {
return console.error("Error getting item from localStorage", e), null;
}
},
/**
* 删除本地存储项
* @param {string} key - 存储项的键
*/
removeItem(t) {
try {
localStorage.removeItem(t);
} catch (e) {
console.error("Error removing item from localStorage", e);
}
},
/**
* 清空本地存储
*/
clear() {
try {
localStorage.clear();
} catch (t) {
console.error("Error clearing localStorage", t);
}
},
/**
* 获取所有本地存储项
* @returns {object} - 包含所有本地存储项的对象
*/
getAllItems() {
try {
const t = {};
for (let e = 0; e < localStorage.length; e++) {
const r = localStorage.key(e);
if (r !== null) {
const n = this.getItem(r);
t[r] = n;
}
}
return t;
} catch (t) {
return console.error("Error getting all items from localStorage", t), {};
}
}
}, kt = {
/**
* 设置会话存储项
* @param {string} key - 存储项的键
* @param {any} value - 存储项的值
*/
setItem(t, e) {
try {
const r = JSON.stringify(e);
sessionStorage.setItem(t, r);
} catch (r) {
console.error("Error setting item to sessionStorage", r);
}
},
/**
* 获取会话存储项
* @param {string} key - 存储项的键
* @returns {any} - 存储项的值,如果解析失败则返回 null
*/
getItem(t) {
try {
const e = sessionStorage.getItem(t);
return e === null ? null : JSON.parse(e);
} catch (e) {
return console.error("Error getting item from sessionStorage", e), null;
}
},
/**
* 删除会话存储项
* @param {string} key - 存储项的键
*/
removeItem(t) {
try {
sessionStorage.removeItem(t);
} catch (e) {
console.error("Error removing item from sessionStorage", e);
}
},
/**
* 清空会话存储
*/
clear() {
try {
sessionStorage.clear();
} catch (t) {
console.error("Error clearing sessionStorage", t);
}
},
/**
* 获取所有会话存储项
* @returns {object} - 包含所有会话存储项的对象
*/
getAllItems() {
try {
const t = {};
for (let e = 0; e < sessionStorage.length; e++) {
const r = sessionStorage.key(e);
if (r !== null) {
const n = this.getItem(r);
t[r] = n;
}
}
return t;
} catch (t) {
return console.error("Error getting all items from sessionStorage", t), {};
}
}
}, Ut = {
/**
* 设置 cookie
* @param {string} name - cookie 的名称
* @param {string} value - cookie 的值
* @param {number} [days] - cookie 的有效天数,可以是小数
* @param {string} [path] - cookie 的路径
*/
setCookie(t, e, r, n = "/") {
let s = "";
if (typeof r < "u") {
const o = /* @__PURE__ */ new Date(), c = r * 24 * 60 * 60 * 1e3;
o.setTime(o.getTime() + c), s = "; expires=" + o.toUTCString();
}
document.cookie = `${t}=${e || ""}${s}; path=${n}`;
},
/**
* 获取 cookie
* @param {string} name - cookie 的名称
* @returns {string | null} - cookie 的值,如果未找到则返回 null
*/
getCookie(t) {
const e = t + "=", r = document.cookie.split(";");
for (let n = 0; n < r.length; n++) {
let s = r[n];
for (; s.charAt(0) === " "; ) s = s.substring(1, s.length);
if (s.indexOf(e) === 0) return s.substring(e.length, s.length);
}
return null;
},
/**
* 删除 cookie
* @param {string} name - cookie 的名称
* @param {string} [path] - cookie 的路径
*/
eraseCookie(t, e = "/") {
document.cookie = `${t}=; Max-Age=-99999999; path=${e}`;
},
/**
* 获取所有 cookies
* @returns {object} - 包含所有 cookies 的对象
*/
getAllCookies() {
const t = {}, e = document.cookie.split(";");
for (let r = 0; r < e.length; r++) {
let n = e[r].trim();
const [s, o] = n.split("=");
t[s] = o;
}
return t;
}
}, Y = (t) => {
const r = t.toString().replace(/e\+|e-|E\+|E-/g, "").split(".")[1];
return r !== void 0 && r.length > 2;
}, Nt = (t, e = !1) => {
const r = ["元", "角", "分"], n = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], s = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"], o = ["", "拾", "佰", "仟"], c = ["", "万", "亿", "兆"], a = ["角", "分"];
if (typeof t != "number")
throw new Error("toChineseMonetaryValue函数第一位参数请输入数字");
if (typeof e != "boolean")
throw new Error("toChineseMonetaryValue函数第二位参数请输入布尔值");
if (e && Y(t))
throw new Error("小数金额不能为低过分的单位");
const i = t < 0;
t = Math.abs(t);
const [l, u] = e ? t.toFixed(2).split(".") : t.toString().split("."), f = (g) => {
const d = g.length;
if (parseInt(g) === 0) return n[0];
let h = "", y = 0;
for (let D = 0; D < d; D++) {
const E = +g.charAt(D), S = d - D - 1, M = o[S % 4], b = c[Math.floor(S / 4)];
E === 0 ? (y++, S % 4 === 0 && y < 4 && (h += b)) : (y > 0 && (h += n[0]), h += n[E] + M, S % 4 === 0 && (h += b), y = 0);
}
return h;
}, p = (g) => {
let d = "";
for (let h = 0; h < g.length; h++) {
const y = +g.charAt(h);
y !== 0 && (d += n[y] + a[h]);
}
return d;
}, I = (g) => {
let d = "";
for (let h = 0; h < g.length; h++) {
const y = +g.charAt(h);
d += s[y];
}
return d;
};
let m = "";
if (e) {
const g = f(l), d = p(u);
u === "00" ? m = g ? g + r[0] + "整" : "" : (m = g ? g + r[0] : "", m += d || "");
} else
m = parseInt(l) === 0 ? n[0] : f(l), u != "00" && u && (m += "点" + I(u));
return i ? "负" + m : m;
}, jt = (t, e = 0) => new Promise((r, n) => {
if (typeof document > "u") {
n(new Error("当前环境不支持 document 对象"));
return;
}
const s = document.createElement("video");
s.muted = !0, s.autoplay = !0, s.src = URL.createObjectURL(t), s.onloadedmetadata = () => {
if (e > s.duration) {
n(new Error("指定的时间超过了视频的长度"));
return;
}
s.currentTime = e;
}, s.oncanplay = () => {
const o = document.createElement("canvas");
o.width = s.videoWidth, o.height = s.videoHeight;
const c = o.getContext("2d");
c ? (c.drawImage(s, 0, 0, o.width, o.height), o.toBlob((a) => {
if (a) {
const i = URL.createObjectURL(a);
r({ url: i, blob: a });
} else
n(new Error("无法生成 Blob 对象"));
})) : n(new Error("无法获取 CanvasRenderingContext2D 上下文"));
}, s.onerror = () => {
n(new Error("视频加载失败"));
};
});
export {
Tt as appendUrlParams,
at as arrayDeduplication,
nt as arrayToTree,
J as asyncPooling,
L as asyncSeriesExecutor,
it as classifyArrayByKey,
q as combiRE,
Ut as cookiesUtil,
et as debounce,
ct as deepCopyAssign,
Z as executeMiddlewares,
ot as findNodeAndParents,
ht as findValues,
ut as generateSKUs,
wt as getDateInfo,
dt as getFirstWeekDay,
Et as getFormattedDate,
Dt as getJoinDate,
pt as getLastMonthRestDays,
St as getLastYearMonth,
yt as getMonthDayCount,
mt as getNextMonthRestDays,
At as getNextYearMonth,
bt as getReformatDate,
vt as getUrlParams,
jt as getVideoFrame,
Ct as isArray,
Pt as isEmpty,
It as isFunction,
Mt as isNumber,
xt as isObject,
Ot as isString,
_ as isValidChineseIDCard,
z as isValidChinesePassport,
X as isValidEmail,
G as isValidHKIDCard,
K as isValidMacauIDCard,
Q as isValidNumber,
B as isValidTaiwanIDCard,
H as limitConcurrency,
$t as localStorageUtil,
$ as mergeDeep,
gt as modifyObject,
tt as performanceHandler,
ft as removeKey,
kt as sessionStorageUtil,
lt as sortArray,
rt as throttle,
Nt as toChineseMonetaryValue,
st as treeToArray
};