var oe = Object.defineProperty; var ae = (t, e, r) => e in t ? oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; var T = (t, e, r) => (ae(t, typeof e != "symbol" ? e + "" : e, r), r), k = (t, e, r) => { if (!e.has(t)) throw TypeError("Cannot " + r); }; var l = (t, e, r) => (k(t, e, "read from private field"), r ? r.call(t) : e.get(t)), P = (t, e, r) => { if (e.has(t)) throw TypeError("Cannot add the same private member more than once"); e instanceof WeakSet ? e.add(t) : e.set(t, r); }, $ = (t, e, r, o) => (k(t, e, "write to private field"), o ? o.call(t, r) : e.set(t, r), r); function te(t) { return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; } function ie(t) { if (t.length >= 255) throw new TypeError("Alphabet too long"); for (var e = new Uint8Array(256), r = 0; r < e.length; r++) e[r] = 255; for (var o = 0; o < t.length; o++) { var c = t.charAt(o), p = c.charCodeAt(0); if (e[p] !== 255) throw new TypeError(c + " is ambiguous"); e[p] = o; } var g = t.length, N = t.charAt(0), B = Math.log(g) / Math.log(256), I = Math.log(256) / Math.log(g); function q(n) { if (n instanceof Uint8Array || (ArrayBuffer.isView(n) ? n = new Uint8Array(n.buffer, n.byteOffset, n.byteLength) : Array.isArray(n) && (n = Uint8Array.from(n))), !(n instanceof Uint8Array)) throw new TypeError("Expected Uint8Array"); if (n.length === 0) return ""; for (var s = 0, f = 0, a = 0, h = n.length; a !== h && n[a] === 0; ) a++, s++; for (var u = (h - a) * I + 1 >>> 0, d = new Uint8Array(u); a !== h; ) { for (var O = n[a], b = 0, v = u - 1; (O !== 0 || b < f) && v !== -1; v--, b++) O += 256 * d[v] >>> 0, d[v] = O % g >>> 0, O = O / g >>> 0; if (O !== 0) throw new Error("Non-zero carry"); f = b, a++; } for (var i = u - f; i !== u && d[i] === 0; ) i++; for (var w = N.repeat(s); i < u; ++i) w += t.charAt(d[i]); return w; } function U(n) { if (typeof n != "string") throw new TypeError("Expected String"); if (n.length === 0) return new Uint8Array(); for (var s = 0, f = 0, a = 0; n[s] === N; ) f++, s++; for (var h = (n.length - s) * B + 1 >>> 0, u = new Uint8Array(h); n[s]; ) { var d = e[n.charCodeAt(s)]; if (d === 255) return; for (var O = 0, b = h - 1; (d !== 0 || O < a) && b !== -1; b--, O++) d += g * u[b] >>> 0, u[b] = d % 256 >>> 0, d = d / 256 >>> 0; if (d !== 0) throw new Error("Non-zero carry"); a = O, s++; } for (var v = h - a; v !== h && u[v] === 0; ) v++; for (var i = new Uint8Array(f + (h - v)), w = f; v !== h; ) i[w++] = u[v++]; return i; } function D(n) { var s = U(n); if (s) return s; throw new Error("Non-base" + g + " character"); } return { encode: q, decodeUnsafe: U, decode: D }; } var fe = ie; const he = /* @__PURE__ */ te(fe); var re = {}; (function(t) { (function(e) { e([], function() { var r = -1, o = -2, c = -3, p = -4, g = -5, N = function(s, f) { f = f || {}; var a = f.verbose || !1; a && console.log("Normalize the JSON Object"), s = typeof s == "string" ? this.JSON.parse(s) : s, a && console.log("Creating a empty dictionary"); var h = { strings: [], integers: [], floats: [] }; a && console.log("Creating the AST"); var u = function v(i) { a && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(i)); var w = typeof i; if (i === null) return { type: "null", index: c }; if (typeof i > "u") return { type: "undefined", index: g }; if (i instanceof Array) { var S = ["@"]; for (var E in i) i.hasOwnProperty(E) && S.push(v(i[E])); return S; } if (w === "object") { var S = ["$"]; for (var x in i) i.hasOwnProperty(x) && (S.push(v(x)), S.push(v(i[x]))); return S; } if (i === "") return { type: "empty", index: p }; if (w === "string") { var A = n.call(h.strings, i); return A == -1 && (h.strings.push(I(i)), A = h.strings.length - 1), { type: "strings", index: A }; } if (w === "number" && i % 1 === 0) { var A = n.call(h.integers, i); return A == -1 && (h.integers.push(U(i)), A = h.integers.length - 1), { type: "integers", index: A }; } if (w === "number") { var A = n.call(h.floats, i); return A == -1 && (h.floats.push(i), A = h.floats.length - 1), { type: "floats", index: A }; } if (w === "boolean") return { type: "boolean", index: i ? r : o }; throw new Error("Unexpected argument of type " + typeof i); }(s), d = h.strings.length, O = h.integers.length; h.floats.length, a && console.log("Parsing the dictionary"); var b = h.strings.join("|"); return b += "^" + h.integers.join("|"), b += "^" + h.floats.join("|"), a && console.log("Parsing the structure"), b += "^" + function v(i) { if (a && console.log("Calling a recursiveParser with " + this.JSON.stringify(i)), i instanceof Array) { var w = i.shift(); for (var S in i) i.hasOwnProperty(S) && (w += v(i[S]) + "|"); return (w[w.length - 1] === "|" ? w.slice(0, -1) : w) + "]"; } var E = i.type, x = i.index; if (E === "strings") return U(x); if (E === "integers") return U(d + x); if (E === "floats") return U(d + O + x); if (E === "boolean") return i.index; if (E === "null") return c; if (E === "undefined") return g; if (E === "empty") return p; throw new TypeError("The item is alien!"); }(u), a && console.log("Ending parser"), f.debug ? { dictionary: h, ast: u, packed: b } : b; }, B = function(s, f) { f = f || {}; var a = s.split("^"); f.verbose && console.log("Building dictionary"); var h = [], u = a[0]; if (u !== "") { u = u.split("|"), f.verbose && console.log("Parse the strings dictionary"); for (var d = 0, O = u.length; d < O; d++) h.push(q(u[d])); } if (u = a[1], u !== "") { u = u.split("|"), f.verbose && console.log("Parse the integers dictionary"); for (var d = 0, O = u.length; d < O; d++) h.push(D(u[d])); } if (u = a[2], u !== "") { u = u.split("|"), f.verbose && console.log("Parse the floats dictionary"); for (var d = 0, O = u.length; d < O; d++) h.push(parseFloat(u[d])); } u = null, f.verbose && console.log("Tokenizing the structure"); for (var b = "", v = [], i = a[3].length, d = 0; d < i; d++) { var w = a[3].charAt(d); w === "|" || w === "$" || w === "@" || w === "]" ? (b && (v.push(D(b)), b = ""), w !== "|" && v.push(w)) : b += w; } var S = v.length, E = 0; return f.verbose && console.log("Starting recursive parser"), function x() { var A = v[E++]; if (f.verbose && console.log("Reading collection type " + (A === "$" ? "object" : "Array")), A === "@") { for (var y = []; E < S; E++) { var C = v[E]; if (f.verbose && console.log("Read " + C + " symbol"), C === "]") return y; if (C === "@" || C === "$") y.push(x()); else switch (C) { case r: y.push(!0); break; case o: y.push(!1); break; case c: y.push(null); break; case g: y.push(void 0); break; case p: y.push(""); break; default: y.push(h[C]); } } return f.verbose && console.log("Parsed " + this.JSON.stringify(y)), y; } if (A === "$") { for (var y = {}; E < S; E++) { var _ = v[E]; if (_ === "]") return y; _ === p ? _ = "" : _ = h[_]; var C = v[++E]; if (C === "@" || C === "$") y[_] = x(); else switch (C) { case r: y[_] = !0; break; case o: y[_] = !1; break; case c: y[_] = null; break; case g: y[_] = void 0; break; case p: y[_] = ""; break; default: y[_] = h[C]; } } return f.verbose && console.log("Parsed " + this.JSON.stringify(y)), y; } throw new TypeError("Bad token " + A + " isn't a type"); }(); }, I = function(s) { return typeof s != "string" ? s : s.replace(/[\+ \|\^\%]/g, function(f) { return { " ": "+", "+": "%2B", "|": "%7C", "^": "%5E", "%": "%25" }[f]; }); }, q = function(s) { return typeof s != "string" ? s : s.replace(/\+|%2B|%7C|%5E|%25/g, function(f) { return { "+": " ", "%2B": "+", "%7C": "|", "%5E": "^", "%25": "%" }[f]; }); }, U = function(s) { return Number.prototype.toString.call(s, 36).toUpperCase(); }, D = function(s) { return parseInt(s, 36); }, n = Array.prototype.indexOf || function(s, f) { for (var a = f || 0, h = this.length; a < h; a++) if (this[a] === s) return a; return -1; }; return { JSON, pack: N, unpack: B }; }); })(function(e, r) { var o = r(); for (var c in o) t[c] = o[c]; }); })(re); const ee = /* @__PURE__ */ te(re); var J, z, j, M, L, H, K, V, Y; class X { constructor(e, r, o, c, p) { T(this, "code", 0); T(this, "message", "操作成功"); T(this, "data", null); T(this, "url", ""); T(this, "res", ""); // static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined } P(this, J, null); // 判断返回 Response 对象, 还是 Response 中的 data P(this, z, !0); // 判罚是否已经给出错误提示 P(this, j, !0); P(this, M, { get: (e, r) => l(this, L).call(this, r), ownKeys: () => Object.keys(l(this, M).getPrototypeOf() || {}), getPrototypeOf: () => l(this, z) ? this : this.data, getOwnPropertyDescriptor: () => ({ configurable: !0, enumerable: !0, writable: !0, value: l(this, M).getPrototypeOf() }) }); P(this, L, (e) => e === "$toast" ? l(this, K) : e === "msg" ? l(this, H) : e === "then" || e === "resp" ? ($(this, j, !0), $(this, z, e === "resp"), l(this, V)) : e === "catch" ? l(this, Y) : e === "IS_ECHO_MSG" ? l(this, j) : Reflect.get(this, e)); P(this, H, (e = (o) => o, r = !1) => (l(this, K).call(this), $(this, z, r), Promise.resolve(e == null ? void 0 : e(l(this, M).getPrototypeOf())))); P(this, K, () => { l(this, j) && ($(this, j, !1), we.onToast(this.code, this.message)); }); P(this, V, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(l(this, M).getPrototypeOf())) : Promise.reject(l(this, J))); P(this, Y, (e) => Promise.resolve(e(l(this, J)))); return this.code = e, this.message = r, this.data = o, this.url = c, this.res = p, $(this, J, new Proxy(this, l(this, M))); } } J = new WeakMap(), z = new WeakMap(), j = new WeakMap(), M = new WeakMap(), L = new WeakMap(), H = new WeakMap(), K = new WeakMap(), V = new WeakMap(), Y = new WeakMap(); const W = (t, e, r, o = "/", c = "") => new X(t, e, r, o, c); var ne = [ "utf8", "utf-8", "unicode-1-1-utf-8" ]; function le(t) { if (ne.indexOf(t) < 0 && typeof t < "u" && t != null) throw new RangeError("Invalid encoding type. Only utf-8 is supported"); this.encoding = "utf-8", this.encode = function(e) { if (typeof e != "string") throw new TypeError("passed argument must be of tye string"); var r = unescape(encodeURIComponent(e)), o = new Uint8Array(r.length); const c = r.split(""); for (let p = 0; p < c.length; p++) o[p] = c[p].charCodeAt(0); return o; }; } function ue(t) { if (ne.indexOf(t) < 0 && typeof t < "u" && t != null) throw new RangeError("Invalid encoding type. Only utf-8 is supported"); this.encoding = "utf-8", this.decode = function(e, r) { if (typeof e > "u") return ""; var o = typeof r < "u" && o in r ? r.stream : !1; if (typeof o != "boolean") throw new TypeError("stream option must be boolean"); if (ArrayBuffer.isView(e)) { var c = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), p = new Array(c.length); for (let g = 0; g < c.length; g++) p[g] = String.fromCharCode(c[g]); return decodeURIComponent(escape(p.join(""))); } else throw new TypeError("passed argument must be an array buffer view"); }; } var se = { TextEncoder: le, TextDecoder: ue }; const ce = new se.TextEncoder("utf8"), ge = new se.TextDecoder("utf8"), de = (t) => { let e = 5381; for (let r = 0; r < t.length; r++) e = e * 33 ^ t.charCodeAt(r); return (e >>> 0).toString(16); }, be = (t, e) => t.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), pe = (t) => ce.encode(t || ""), ve = (t) => ge.decode(new DataView(t), {}); var F, G, Q, m, R; class Z { constructor(e, r, o = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) { P(this, F, void 0); P(this, G, void 0); P(this, Q, void 0); P(this, m, { "#": /* @__PURE__ */ new Map(), // 系统缓存 $: /* @__PURE__ */ new Map() // 普通缓存 }); P(this, R, /* @__PURE__ */ new Map()); T(this, "request", ({ url: e = "/", method: r = "GET", ...o }, c = !1) => { var U, D; const p = r.toUpperCase(), g = de(JSON.stringify([e, p, o])), N = (U = e == null ? void 0 : e.includes) != null && U.call(e, "/_/") ? "#" : "$", { promise: B, resolve: I, reject: q } = Promise.withResolvers(); return l(this, m)[N].has(g) ? (console.log("缓存命中", e), I(l(this, m)[N].get(g))) : (l(this, R).has(g) ? l(this, R).get(g).push([I, q]) : l(this, R).set(g, [[I, q]]), (D = l(this, R).get(g)) != null && D.some((n) => n) && l(this, F).call(this, { url: e, method: p, ...o }).then((n) => { if (![0, 1].includes(n.code)) throw W(n.code, n.msg, n.data, e, n == null ? void 0 : n.res); return [n.code, n.msg, n.data, e, n == null ? void 0 : n.res]; }).then((n) => ((N == "#" || c && p === "GET") && l(this, m)[N].set(g, n), n)).then((n) => l(this, R).get(g).forEach((s, f, a) => { s && s[0](n), delete a[f]; })).catch((n) => { l(this, m)[N].delete(g), l(this, R).get(g).forEach((s, f, a) => { s && s[1](n instanceof X ? n : W(-1, n, null, e)), delete a[f]; }); }).finally(() => l(this, R).delete(g))), new Proxy(B, { get: (n, s) => (...f) => n.then((a) => W(...a)[s](...f)).catch((a) => { if (!a instanceof X) throw a; return typeof a[s] == "function" ? a[s](...f) : a[s]; }) }); }); T(this, "get", (e, r = {}) => this.request({ url: e, method: "GET", params: r })); T(this, "post", (e, r = {}, o = {}) => this.request({ url: e, method: "POST", data: r, params: o })); T(this, "put", (e, r = {}, o = {}) => this.request({ url: e, method: "PUT", data: r, params: o })); T(this, "del", (e, r = {}, o = {}) => this.request({ url: e, method: "DELETE", data: r, params: o })); T(this, "download", (e, r) => { }); T(this, "cache", (e, r = {}) => this.request({ url: e, method: "GET", params: r }, !0)); T(this, "list", (e, r = {}) => this.get(`/api/${e}/${this.encode(r)}`)); T(this, "getAppInfo", () => { }); T(this, "refreshCache", (e = !1) => { e && l(this, m)["#"].clear(), l(this, m).$.clear(); }); T(this, "decode", (e = "", r = {}) => { if (e === void 0 || e === "" || e === null) return r; try { const o = l(this, G).decode(e).buffer; return ee.unpack(ve(o)); } catch { return console.warn("core.decode", e), r; } }); T(this, "encode", (e = {}) => { const r = JSON.stringify(e, (o, c) => c === void 0 ? null : c); return l(this, G).encode(pe(ee.pack(r))); }); $(this, Q, e), $(this, F, o), $(this, G, he(r)); } } F = new WeakMap(), G = new WeakMap(), Q = new WeakMap(), m = new WeakMap(), R = new WeakMap(); const we = Z; Z.onUnhandledRejection = (t) => { var e, r, o, c, p, g; t != null && t.IS_ECHO_MSG ? ((e = t == null ? void 0 : t.$toast) == null || e.call(t), (r = t == null ? void 0 : t.preventDefault) == null || r.call(t)) : (o = t.reason) != null && o.IS_ECHO_MSG && ((p = (c = t.reason) == null ? void 0 : c.$toast) == null || p.call(c), (g = t == null ? void 0 : t.preventDefault) == null || g.call(t)); }; Z.onToast = (t, e) => [0, 1].includes(t) ? console.log(e) : console.warn(e); export { we as default, de as signature, pe as str2uint8array, be as trim, ve as uint8array2str };