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