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