@forward-widget/danmu-universe 0.0.13 → 0.0.15

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.
Files changed (2) hide show
  1. package/dist/danmu-universe.js +341 -177
  2. package/package.json +3 -2
@@ -549,7 +549,7 @@ var __webpack_modules__ = {
549
549
  for(var t = e.length, n = [], r = 0; r < t; r += 2)n[r >>> 3] |= parseInt(e.substr(r, 2), 16) << 24 - r % 8 * 4;
550
550
  return new l.init(n, t / 2);
551
551
  }
552
- }, p = c.Latin1 = {
552
+ }, f = c.Latin1 = {
553
553
  stringify: function(e) {
554
554
  for(var t = e.words, n = e.sigBytes, r = [], i = 0; i < n; i++){
555
555
  var o = t[i >>> 2] >>> 24 - i % 4 * 8 & 0xff;
@@ -561,23 +561,23 @@ var __webpack_modules__ = {
561
561
  for(var t = e.length, n = [], r = 0; r < t; r++)n[r >>> 2] |= (0xff & e.charCodeAt(r)) << 24 - r % 4 * 8;
562
562
  return new l.init(n, t);
563
563
  }
564
- }, f = c.Utf8 = {
564
+ }, p = c.Utf8 = {
565
565
  stringify: function(e) {
566
566
  try {
567
- return decodeURIComponent(escape(p.stringify(e)));
567
+ return decodeURIComponent(escape(f.stringify(e)));
568
568
  } catch (e) {
569
569
  throw Error('Malformed UTF-8 data');
570
570
  }
571
571
  },
572
572
  parse: function(e) {
573
- return p.parse(unescape(encodeURIComponent(e)));
573
+ return f.parse(unescape(encodeURIComponent(e)));
574
574
  }
575
575
  }, h = a.BufferedBlockAlgorithm = u.extend({
576
576
  reset: function() {
577
577
  this._data = new l.init(), this._nDataBytes = 0;
578
578
  },
579
579
  _append: function(e) {
580
- 'string' == typeof e && (e = f.parse(e)), this._data.concat(e), this._nDataBytes += e.sigBytes;
580
+ 'string' == typeof e && (e = p.parse(e)), this._data.concat(e), this._nDataBytes += e.sigBytes;
581
581
  },
582
582
  _process: function(t) {
583
583
  var n, r = this._data, i = r.words, o = r.sigBytes, s = this.blockSize, a = o / (4 * s), u = (a = t ? e.ceil(a) : e.max((0 | a) - this._minBufferSize, 0)) * s, c = e.min(4 * u, o);
@@ -695,8 +695,8 @@ var __webpack_modules__ = {
695
695
  var r = t + n, i = e[r];
696
696
  e[r] = (i << 8 | i >>> 24) & 0x00ff00ff | (i << 24 | i >>> 8) & 0xff00ff00;
697
697
  }
698
- var o = this._hash.words, s = e[t + 0], u = e[t + 1], f = e[t + 2], h = e[t + 3], m = e[t + 4], g = e[t + 5], v = e[t + 6], y = e[t + 7], b = e[t + 8], _ = e[t + 9], w = e[t + 10], k = e[t + 11], x = e[t + 12], S = e[t + 13], E = e[t + 14], z = e[t + 15], O = o[0], I = o[1], $ = o[2], P = o[3];
699
- O = l(O, I, $, P, s, 7, a[0]), P = l(P, O, I, $, u, 12, a[1]), $ = l($, P, O, I, f, 17, a[2]), I = l(I, $, P, O, h, 22, a[3]), O = l(O, I, $, P, m, 7, a[4]), P = l(P, O, I, $, g, 12, a[5]), $ = l($, P, O, I, v, 17, a[6]), I = l(I, $, P, O, y, 22, a[7]), O = l(O, I, $, P, b, 7, a[8]), P = l(P, O, I, $, _, 12, a[9]), $ = l($, P, O, I, w, 17, a[10]), I = l(I, $, P, O, k, 22, a[11]), O = l(O, I, $, P, x, 7, a[12]), P = l(P, O, I, $, S, 12, a[13]), $ = l($, P, O, I, E, 17, a[14]), I = l(I, $, P, O, z, 22, a[15]), O = c(O, I, $, P, u, 5, a[16]), P = c(P, O, I, $, v, 9, a[17]), $ = c($, P, O, I, k, 14, a[18]), I = c(I, $, P, O, s, 20, a[19]), O = c(O, I, $, P, g, 5, a[20]), P = c(P, O, I, $, w, 9, a[21]), $ = c($, P, O, I, z, 14, a[22]), I = c(I, $, P, O, m, 20, a[23]), O = c(O, I, $, P, _, 5, a[24]), P = c(P, O, I, $, E, 9, a[25]), $ = c($, P, O, I, h, 14, a[26]), I = c(I, $, P, O, b, 20, a[27]), O = c(O, I, $, P, S, 5, a[28]), P = c(P, O, I, $, f, 9, a[29]), $ = c($, P, O, I, y, 14, a[30]), I = c(I, $, P, O, x, 20, a[31]), O = d(O, I, $, P, g, 4, a[32]), P = d(P, O, I, $, b, 11, a[33]), $ = d($, P, O, I, k, 16, a[34]), I = d(I, $, P, O, E, 23, a[35]), O = d(O, I, $, P, u, 4, a[36]), P = d(P, O, I, $, m, 11, a[37]), $ = d($, P, O, I, y, 16, a[38]), I = d(I, $, P, O, w, 23, a[39]), O = d(O, I, $, P, S, 4, a[40]), P = d(P, O, I, $, s, 11, a[41]), $ = d($, P, O, I, h, 16, a[42]), I = d(I, $, P, O, v, 23, a[43]), O = d(O, I, $, P, _, 4, a[44]), P = d(P, O, I, $, x, 11, a[45]), $ = d($, P, O, I, z, 16, a[46]), I = d(I, $, P, O, f, 23, a[47]), O = p(O, I, $, P, s, 6, a[48]), P = p(P, O, I, $, y, 10, a[49]), $ = p($, P, O, I, E, 15, a[50]), I = p(I, $, P, O, g, 21, a[51]), O = p(O, I, $, P, x, 6, a[52]), P = p(P, O, I, $, h, 10, a[53]), $ = p($, P, O, I, w, 15, a[54]), I = p(I, $, P, O, u, 21, a[55]), O = p(O, I, $, P, b, 6, a[56]), P = p(P, O, I, $, z, 10, a[57]), $ = p($, P, O, I, v, 15, a[58]), I = p(I, $, P, O, S, 21, a[59]), O = p(O, I, $, P, m, 6, a[60]), P = p(P, O, I, $, k, 10, a[61]), $ = p($, P, O, I, f, 15, a[62]), I = p(I, $, P, O, _, 21, a[63]), o[0] = o[0] + O | 0, o[1] = o[1] + I | 0, o[2] = o[2] + $ | 0, o[3] = o[3] + P | 0;
698
+ var o = this._hash.words, s = e[t + 0], u = e[t + 1], p = e[t + 2], h = e[t + 3], m = e[t + 4], g = e[t + 5], v = e[t + 6], y = e[t + 7], b = e[t + 8], _ = e[t + 9], w = e[t + 10], k = e[t + 11], x = e[t + 12], E = e[t + 13], S = e[t + 14], z = e[t + 15], O = o[0], I = o[1], $ = o[2], P = o[3];
699
+ O = l(O, I, $, P, s, 7, a[0]), P = l(P, O, I, $, u, 12, a[1]), $ = l($, P, O, I, p, 17, a[2]), I = l(I, $, P, O, h, 22, a[3]), O = l(O, I, $, P, m, 7, a[4]), P = l(P, O, I, $, g, 12, a[5]), $ = l($, P, O, I, v, 17, a[6]), I = l(I, $, P, O, y, 22, a[7]), O = l(O, I, $, P, b, 7, a[8]), P = l(P, O, I, $, _, 12, a[9]), $ = l($, P, O, I, w, 17, a[10]), I = l(I, $, P, O, k, 22, a[11]), O = l(O, I, $, P, x, 7, a[12]), P = l(P, O, I, $, E, 12, a[13]), $ = l($, P, O, I, S, 17, a[14]), I = l(I, $, P, O, z, 22, a[15]), O = c(O, I, $, P, u, 5, a[16]), P = c(P, O, I, $, v, 9, a[17]), $ = c($, P, O, I, k, 14, a[18]), I = c(I, $, P, O, s, 20, a[19]), O = c(O, I, $, P, g, 5, a[20]), P = c(P, O, I, $, w, 9, a[21]), $ = c($, P, O, I, z, 14, a[22]), I = c(I, $, P, O, m, 20, a[23]), O = c(O, I, $, P, _, 5, a[24]), P = c(P, O, I, $, S, 9, a[25]), $ = c($, P, O, I, h, 14, a[26]), I = c(I, $, P, O, b, 20, a[27]), O = c(O, I, $, P, E, 5, a[28]), P = c(P, O, I, $, p, 9, a[29]), $ = c($, P, O, I, y, 14, a[30]), I = c(I, $, P, O, x, 20, a[31]), O = d(O, I, $, P, g, 4, a[32]), P = d(P, O, I, $, b, 11, a[33]), $ = d($, P, O, I, k, 16, a[34]), I = d(I, $, P, O, S, 23, a[35]), O = d(O, I, $, P, u, 4, a[36]), P = d(P, O, I, $, m, 11, a[37]), $ = d($, P, O, I, y, 16, a[38]), I = d(I, $, P, O, w, 23, a[39]), O = d(O, I, $, P, E, 4, a[40]), P = d(P, O, I, $, s, 11, a[41]), $ = d($, P, O, I, h, 16, a[42]), I = d(I, $, P, O, v, 23, a[43]), O = d(O, I, $, P, _, 4, a[44]), P = d(P, O, I, $, x, 11, a[45]), $ = d($, P, O, I, z, 16, a[46]), I = d(I, $, P, O, p, 23, a[47]), O = f(O, I, $, P, s, 6, a[48]), P = f(P, O, I, $, y, 10, a[49]), $ = f($, P, O, I, S, 15, a[50]), I = f(I, $, P, O, g, 21, a[51]), O = f(O, I, $, P, x, 6, a[52]), P = f(P, O, I, $, h, 10, a[53]), $ = f($, P, O, I, w, 15, a[54]), I = f(I, $, P, O, u, 21, a[55]), O = f(O, I, $, P, b, 6, a[56]), P = f(P, O, I, $, z, 10, a[57]), $ = f($, P, O, I, v, 15, a[58]), I = f(I, $, P, O, E, 21, a[59]), O = f(O, I, $, P, m, 6, a[60]), P = f(P, O, I, $, k, 10, a[61]), $ = f($, P, O, I, p, 15, a[62]), I = f(I, $, P, O, _, 21, a[63]), o[0] = o[0] + O | 0, o[1] = o[1] + I | 0, o[2] = o[2] + $ | 0, o[3] = o[3] + P | 0;
700
700
  },
701
701
  _doFinalize: function() {
702
702
  var e = this._data, n = e.words, r = 8 * this._nDataBytes, i = 8 * e.sigBytes;
@@ -726,7 +726,7 @@ var __webpack_modules__ = {
726
726
  var a = e + (t ^ n ^ r) + i + s;
727
727
  return (a << o | a >>> 32 - o) + t;
728
728
  }
729
- function p(e, t, n, r, i, o, s) {
729
+ function f(e, t, n, r, i, o, s) {
730
730
  var a = e + (n ^ (t | ~r)) + i + s;
731
731
  return (a << o | a >>> 32 - o) + t;
732
732
  }
@@ -787,12 +787,12 @@ var __webpack_modules__ = {
787
787
  }
788
788
  throw Error("invalid varint encoding");
789
789
  }
790
- function p(e, t) {
790
+ function f(e, t) {
791
791
  return (e[t - 4] | e[t - 3] << 8 | e[t - 2] << 16 | e[t - 1] << 24) >>> 0;
792
792
  }
793
- function f() {
793
+ function p() {
794
794
  if (this.pos + 8 > this.len) throw a(this, 8);
795
- return new o(p(this.buf, this.pos += 4), p(this.buf, this.pos += 4));
795
+ return new o(f(this.buf, this.pos += 4), f(this.buf, this.pos += 4));
796
796
  }
797
797
  u.create = c(), u.prototype._slice = i.Array.prototype.subarray || i.Array.prototype.slice, u.prototype.uint32 = function() {
798
798
  var e = 4294967295;
@@ -810,10 +810,10 @@ var __webpack_modules__ = {
810
810
  return 0 !== this.uint32();
811
811
  }, u.prototype.fixed32 = function() {
812
812
  if (this.pos + 4 > this.len) throw a(this, 4);
813
- return p(this.buf, this.pos += 4);
813
+ return f(this.buf, this.pos += 4);
814
814
  }, u.prototype.sfixed32 = function() {
815
815
  if (this.pos + 4 > this.len) throw a(this, 4);
816
- return 0 | p(this.buf, this.pos += 4);
816
+ return 0 | f(this.buf, this.pos += 4);
817
817
  }, u.prototype.float = function() {
818
818
  if (this.pos + 4 > this.len) throw a(this, 4);
819
819
  var e = i.float.readFloatLE(this.buf, this.pos);
@@ -876,10 +876,10 @@ var __webpack_modules__ = {
876
876
  return d.call(this).zzDecode()[t](!1);
877
877
  },
878
878
  fixed64: function() {
879
- return f.call(this)[t](!0);
879
+ return p.call(this)[t](!0);
880
880
  },
881
881
  sfixed64: function() {
882
- return f.call(this)[t](!1);
882
+ return p.call(this)[t](!1);
883
883
  }
884
884
  });
885
885
  };
@@ -1102,7 +1102,7 @@ var __webpack_modules__ = {
1102
1102
  function d() {
1103
1103
  this.len = 0, this.head = new u(l, 0, 0), this.tail = this.head, this.states = null;
1104
1104
  }
1105
- var p = function() {
1105
+ var f = function() {
1106
1106
  return i.Buffer ? function() {
1107
1107
  return (d.create = function() {
1108
1108
  return new r();
@@ -1111,7 +1111,7 @@ var __webpack_modules__ = {
1111
1111
  return new d();
1112
1112
  };
1113
1113
  };
1114
- function f(e, t, n) {
1114
+ function p(e, t, n) {
1115
1115
  t[n] = 255 & e;
1116
1116
  }
1117
1117
  function h(e, t, n) {
@@ -1129,7 +1129,7 @@ var __webpack_modules__ = {
1129
1129
  function v(e, t, n) {
1130
1130
  t[n] = 255 & e, t[n + 1] = e >>> 8 & 255, t[n + 2] = e >>> 16 & 255, t[n + 3] = e >>> 24;
1131
1131
  }
1132
- d.create = p(), d.alloc = function(e) {
1132
+ d.create = f(), d.alloc = function(e) {
1133
1133
  return new i.Array(e);
1134
1134
  }, i.Array !== Array && (d.alloc = i.pool(d.alloc, i.Array.prototype.subarray)), d.prototype._push = function(e, t, n) {
1135
1135
  return this.tail = this.tail.next = new u(e, t, n), this.len += t, this;
@@ -1146,7 +1146,7 @@ var __webpack_modules__ = {
1146
1146
  var t = o.from(e).zzEncode();
1147
1147
  return this._push(g, t.length(), t);
1148
1148
  }, d.prototype.bool = function(e) {
1149
- return this._push(f, 1, +!!e);
1149
+ return this._push(p, 1, +!!e);
1150
1150
  }, d.prototype.fixed32 = function(e) {
1151
1151
  return this._push(v, 4, e >>> 0);
1152
1152
  }, d.prototype.sfixed32 = d.prototype.fixed32, d.prototype.fixed64 = function(e) {
@@ -1164,7 +1164,7 @@ var __webpack_modules__ = {
1164
1164
  };
1165
1165
  d.prototype.bytes = function(e) {
1166
1166
  var t = e.length >>> 0;
1167
- if (!t) return this._push(f, 1, 0);
1167
+ if (!t) return this._push(p, 1, 0);
1168
1168
  if (i.isString(e)) {
1169
1169
  var n = d.alloc(t = s.length(e));
1170
1170
  s.decode(e, n, 0), e = n;
@@ -1172,7 +1172,7 @@ var __webpack_modules__ = {
1172
1172
  return this.uint32(t)._push(y, t, e);
1173
1173
  }, d.prototype.string = function(e) {
1174
1174
  var t = a.length(e);
1175
- return t ? this.uint32(t)._push(a.write, t, e) : this._push(f, 1, 0);
1175
+ return t ? this.uint32(t)._push(a.write, t, e) : this._push(p, 1, 0);
1176
1176
  }, d.prototype.fork = function() {
1177
1177
  return this.states = new c(this), this.head = this.tail = new u(l, 0, 0), this.len = 0, this;
1178
1178
  }, d.prototype.reset = function() {
@@ -1184,7 +1184,7 @@ var __webpack_modules__ = {
1184
1184
  for(var e = this.head.next, t = this.constructor.alloc(this.len), n = 0; e;)e.fn(e.val, t, n), n += e.len, e = e.next;
1185
1185
  return t;
1186
1186
  }, d._configure = function(e) {
1187
- r = e, d.create = p(), r._configure();
1187
+ r = e, d.create = f(), r._configure();
1188
1188
  };
1189
1189
  },
1190
1190
  491: function(e, t, n) {
@@ -1271,7 +1271,7 @@ var __webpack_modules__ = {
1271
1271
  function d(e) {
1272
1272
  return (e || '').toString().replace(o, '');
1273
1273
  }
1274
- var p = [
1274
+ var f = [
1275
1275
  [
1276
1276
  '#',
1277
1277
  'hash'
@@ -1312,16 +1312,16 @@ var __webpack_modules__ = {
1312
1312
  1,
1313
1313
  1
1314
1314
  ]
1315
- ], f = {
1315
+ ], p = {
1316
1316
  hash: 1,
1317
1317
  query: 1
1318
1318
  };
1319
1319
  function h(e) {
1320
1320
  var t, r, i = (t = 'undefined' != typeof window ? window : void 0 !== n.g ? n.g : 'undefined' != typeof self ? self : {}).location || {}, o = {}, s = typeof (e = e || i);
1321
1321
  if ('blob:' === e.protocol) o = new y(unescape(e.pathname), {});
1322
- else if ('string' === s) for(r in o = new y(e, {}), f)delete o[r];
1322
+ else if ('string' === s) for(r in o = new y(e, {}), p)delete o[r];
1323
1323
  else if ('object' === s) {
1324
- for(r in e)r in f || (o[r] = e[r]);
1324
+ for(r in e)r in p || (o[r] = e[r]);
1325
1325
  void 0 === o.slashes && (o.slashes = a.test(e.href));
1326
1326
  }
1327
1327
  return o;
@@ -1346,7 +1346,7 @@ var __webpack_modules__ = {
1346
1346
  }
1347
1347
  function y(e, t, n) {
1348
1348
  if (e = (e = d(e)).replace(s, ''), !(this instanceof y)) return new y(e, t, n);
1349
- var o, a, u, l, f, b, _ = p.slice(), w = typeof t, k = this, x = 0;
1349
+ var o, a, u, l, p, b, _ = f.slice(), w = typeof t, k = this, x = 0;
1350
1350
  for('object' !== w && 'string' !== w && (n = t, t = null), n && 'function' != typeof n && (n = i.parse), o = !(a = g(e || '', t = h(t))).protocol && !a.slashes, k.slashes = a.slashes || o && t.slashes, k.protocol = a.protocol || t.protocol || '', e = a.rest, ('file:' === a.protocol && (2 !== a.slashesCount || c.test(e)) || !a.slashes && (a.protocol || a.slashesCount < 2 || !m(k.protocol))) && (_[3] = [
1351
1351
  /(.*)/,
1352
1352
  'pathname'
@@ -1355,9 +1355,9 @@ var __webpack_modules__ = {
1355
1355
  e = l(e, k);
1356
1356
  continue;
1357
1357
  }
1358
- u = l[0], b = l[1], u != u ? k[b] = e : 'string' == typeof u ? ~(f = '@' === u ? e.lastIndexOf(u) : e.indexOf(u)) && ('number' == typeof l[2] ? (k[b] = e.slice(0, f), e = e.slice(f + l[2])) : (k[b] = e.slice(f), e = e.slice(0, f))) : (f = u.exec(e)) && (k[b] = f[1], e = e.slice(0, f.index)), k[b] = k[b] || o && l[3] && t[b] || '', l[4] && (k[b] = k[b].toLowerCase());
1358
+ u = l[0], b = l[1], u != u ? k[b] = e : 'string' == typeof u ? ~(p = '@' === u ? e.lastIndexOf(u) : e.indexOf(u)) && ('number' == typeof l[2] ? (k[b] = e.slice(0, p), e = e.slice(p + l[2])) : (k[b] = e.slice(p), e = e.slice(0, p))) : (p = u.exec(e)) && (k[b] = p[1], e = e.slice(0, p.index)), k[b] = k[b] || o && l[3] && t[b] || '', l[4] && (k[b] = k[b].toLowerCase());
1359
1359
  }
1360
- n && (k.query = n(k.query)), o && t.slashes && '/' !== k.pathname.charAt(0) && ('' !== k.pathname || '' !== t.pathname) && (k.pathname = v(k.pathname, t.pathname)), '/' !== k.pathname.charAt(0) && m(k.protocol) && (k.pathname = '/' + k.pathname), r(k.port, k.protocol) || (k.host = k.hostname, k.port = ''), k.username = k.password = '', k.auth && (~(f = k.auth.indexOf(':')) ? (k.username = k.auth.slice(0, f), k.username = encodeURIComponent(decodeURIComponent(k.username)), k.password = k.auth.slice(f + 1), k.password = encodeURIComponent(decodeURIComponent(k.password))) : k.username = encodeURIComponent(decodeURIComponent(k.auth)), k.auth = k.password ? k.username + ':' + k.password : k.username), k.origin = 'file:' !== k.protocol && m(k.protocol) && k.host ? k.protocol + '//' + k.host : 'null', k.href = k.toString();
1360
+ n && (k.query = n(k.query)), o && t.slashes && '/' !== k.pathname.charAt(0) && ('' !== k.pathname || '' !== t.pathname) && (k.pathname = v(k.pathname, t.pathname)), '/' !== k.pathname.charAt(0) && m(k.protocol) && (k.pathname = '/' + k.pathname), r(k.port, k.protocol) || (k.host = k.hostname, k.port = ''), k.username = k.password = '', k.auth && (~(p = k.auth.indexOf(':')) ? (k.username = k.auth.slice(0, p), k.username = encodeURIComponent(decodeURIComponent(k.username)), k.password = k.auth.slice(p + 1), k.password = encodeURIComponent(decodeURIComponent(k.password))) : k.username = encodeURIComponent(decodeURIComponent(k.auth)), k.auth = k.password ? k.username + ':' + k.password : k.username), k.origin = 'file:' !== k.protocol && m(k.protocol) && k.host ? k.protocol + '//' + k.host : 'null', k.href = k.toString();
1361
1361
  }
1362
1362
  y.prototype = {
1363
1363
  set: function(e, t, n) {
@@ -1393,8 +1393,8 @@ var __webpack_modules__ = {
1393
1393
  var a = t.indexOf(':');
1394
1394
  ~a ? (o.username = t.slice(0, a), o.username = encodeURIComponent(decodeURIComponent(o.username)), o.password = t.slice(a + 1), o.password = encodeURIComponent(decodeURIComponent(o.password))) : o.username = encodeURIComponent(decodeURIComponent(t));
1395
1395
  }
1396
- for(var l = 0; l < p.length; l++){
1397
- var c = p[l];
1396
+ for(var l = 0; l < f.length; l++){
1397
+ var c = f[l];
1398
1398
  c[4] && (o[c[1]] = o[c[1]].toLowerCase());
1399
1399
  }
1400
1400
  return o.auth = o.password ? o.username + ':' + o.password : o.username, o.origin = 'file:' !== o.protocol && m(o.protocol) && o.host ? o.protocol + '//' + o.host : 'null', o.href = o.toString(), o;
@@ -1493,15 +1493,20 @@ class $ZodAsyncError extends Error {
1493
1493
  super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
1494
1494
  }
1495
1495
  }
1496
+ class $ZodEncodeError extends Error {
1497
+ constructor(e){
1498
+ super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
1499
+ }
1500
+ }
1496
1501
  const globalConfig = {};
1497
1502
  function core_config(e) {
1498
1503
  return e && Object.assign(globalConfig, e), globalConfig;
1499
1504
  }
1500
- const cuid = /^[cC][^\s-]{8,}$/, cuid2 = /^[0-9a-z]+$/, ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, xid = /^[0-9a-vA-V]{20}$/, ksuid = /^[A-Za-z0-9]{27}$/, nanoid = /^[a-zA-Z0-9_-]{21}$/, regexes_duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, uuid = (e)=>e ? RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/, email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
1505
+ const cuid = /^[cC][^\s-]{8,}$/, cuid2 = /^[0-9a-z]+$/, ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, xid = /^[0-9a-vA-V]{20}$/, ksuid = /^[A-Za-z0-9]{27}$/, nanoid = /^[a-zA-Z0-9_-]{21}$/, regexes_duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, uuid = (e)=>e ? RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
1501
1506
  function emoji() {
1502
1507
  return RegExp(_emoji, "u");
1503
1508
  }
1504
- const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/, cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, base64url = /^[A-Za-z0-9_-]*$/, hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/, e164 = /^\+(?:[0-9]){6,14}[0-9]$/, dateSource = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))", regexes_date = RegExp(`^${dateSource}$`);
1509
+ const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/, cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, regexes_base64url = /^[A-Za-z0-9_-]*$/, hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/, e164 = /^\+(?:[0-9]){6,14}[0-9]$/, dateSource = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))", regexes_date = RegExp(`^${dateSource}$`);
1505
1510
  function timeSource(e) {
1506
1511
  let t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
1507
1512
  return "number" == typeof e.precision ? -1 === e.precision ? `${t}` : 0 === e.precision ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
@@ -1702,7 +1707,9 @@ function omit(e, t) {
1702
1707
  }
1703
1708
  function extend(e, t) {
1704
1709
  if (!isPlainObject(t)) throw Error("Invalid input to extend: expected a plain object");
1705
- let n = mergeDefs(e._zod.def, {
1710
+ let n = e._zod.def.checks;
1711
+ if (n && n.length > 0) throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
1712
+ let r = mergeDefs(e._zod.def, {
1706
1713
  get shape () {
1707
1714
  let n = {
1708
1715
  ...e._zod.def.shape,
@@ -1712,6 +1719,21 @@ function extend(e, t) {
1712
1719
  },
1713
1720
  checks: []
1714
1721
  });
1722
+ return clone(e, r);
1723
+ }
1724
+ function safeExtend(e, t) {
1725
+ if (!isPlainObject(t)) throw Error("Invalid input to safeExtend: expected a plain object");
1726
+ let n = {
1727
+ ...e._zod.def,
1728
+ get shape () {
1729
+ let n = {
1730
+ ...e._zod.def.shape,
1731
+ ...t
1732
+ };
1733
+ return assignProp(this, "shape", n), n;
1734
+ },
1735
+ checks: e._zod.def.checks
1736
+ };
1715
1737
  return clone(e, n);
1716
1738
  }
1717
1739
  function merge(e, t) {
@@ -1777,6 +1799,7 @@ function required(e, t, n) {
1777
1799
  return clone(t, r);
1778
1800
  }
1779
1801
  function aborted(e, t = 0) {
1802
+ if (!0 === e.aborted) return !0;
1780
1803
  for(let n = t; n < e.issues.length; n++)if (e.issues[n]?.continue !== !0) return !0;
1781
1804
  return !1;
1782
1805
  }
@@ -2233,10 +2256,38 @@ const _parse = (e)=>(t, n, r, i)=>{
2233
2256
  success: !0,
2234
2257
  data: o.value
2235
2258
  };
2236
- }, safeParseAsync = _safeParseAsync($ZodRealError), versions_version = {
2259
+ }, safeParseAsync = _safeParseAsync($ZodRealError), _encode = (e)=>(t, n, r)=>{
2260
+ let i = r ? Object.assign(r, {
2261
+ direction: "backward"
2262
+ }) : {
2263
+ direction: "backward"
2264
+ };
2265
+ return _parse(e)(t, n, i);
2266
+ }, _decode = (e)=>(t, n, r)=>_parse(e)(t, n, r), _encodeAsync = (e)=>async (t, n, r)=>{
2267
+ let i = r ? Object.assign(r, {
2268
+ direction: "backward"
2269
+ }) : {
2270
+ direction: "backward"
2271
+ };
2272
+ return _parseAsync(e)(t, n, i);
2273
+ }, _decodeAsync = (e)=>async (t, n, r)=>_parseAsync(e)(t, n, r), _safeEncode = (e)=>(t, n, r)=>{
2274
+ let i = r ? Object.assign(r, {
2275
+ direction: "backward"
2276
+ }) : {
2277
+ direction: "backward"
2278
+ };
2279
+ return _safeParse(e)(t, n, i);
2280
+ }, _safeDecode = (e)=>(t, n, r)=>_safeParse(e)(t, n, r), _safeEncodeAsync = (e)=>async (t, n, r)=>{
2281
+ let i = r ? Object.assign(r, {
2282
+ direction: "backward"
2283
+ }) : {
2284
+ direction: "backward"
2285
+ };
2286
+ return _safeParseAsync(e)(t, n, i);
2287
+ }, _safeDecodeAsync = (e)=>async (t, n, r)=>_safeParseAsync(e)(t, n, r), versions_version = {
2237
2288
  major: 4,
2238
- minor: 0,
2239
- patch: 17
2289
+ minor: 1,
2290
+ patch: 5
2240
2291
  }, $ZodType = $constructor("$ZodType", (e, t)=>{
2241
2292
  var n;
2242
2293
  e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = versions_version;
@@ -2265,14 +2316,33 @@ const _parse = (e)=>(t, n, r, i)=>{
2265
2316
  }
2266
2317
  }
2267
2318
  return r ? r.then(()=>e) : e;
2319
+ }, n = (n, i, o)=>{
2320
+ if (aborted(n)) return n.aborted = !0, n;
2321
+ let s = t(i, r, o);
2322
+ if (s instanceof Promise) {
2323
+ if (!1 === o.async) throw new $ZodAsyncError();
2324
+ return s.then((t)=>e._zod.parse(t, o));
2325
+ }
2326
+ return e._zod.parse(s, o);
2268
2327
  };
2269
- e._zod.run = (n, i)=>{
2270
- let o = e._zod.parse(n, i);
2271
- if (o instanceof Promise) {
2272
- if (!1 === i.async) throw new $ZodAsyncError();
2273
- return o.then((e)=>t(e, r, i));
2328
+ e._zod.run = (i, o)=>{
2329
+ if (o.skipChecks) return e._zod.parse(i, o);
2330
+ if ("backward" === o.direction) {
2331
+ let t = e._zod.parse({
2332
+ value: i.value,
2333
+ issues: []
2334
+ }, {
2335
+ ...o,
2336
+ skipChecks: !0
2337
+ });
2338
+ return t instanceof Promise ? t.then((e)=>n(e, i, o)) : n(t, i, o);
2339
+ }
2340
+ let s = e._zod.parse(i, o);
2341
+ if (s instanceof Promise) {
2342
+ if (!1 === o.async) throw new $ZodAsyncError();
2343
+ return s.then((e)=>t(e, r, o));
2274
2344
  }
2275
- return t(o, r, i);
2345
+ return t(s, r, o);
2276
2346
  };
2277
2347
  }
2278
2348
  e["~standard"] = {
@@ -2449,12 +2519,12 @@ const $ZodBase64 = $constructor("$ZodBase64", (e, t)=>{
2449
2519
  };
2450
2520
  });
2451
2521
  function isValidBase64URL(e) {
2452
- if (!base64url.test(e)) return !1;
2522
+ if (!regexes_base64url.test(e)) return !1;
2453
2523
  let t = e.replace(/[-_]/g, (e)=>"-" === e ? "+" : "/");
2454
2524
  return isValidBase64(t.padEnd(4 * Math.ceil(t.length / 4), "="));
2455
2525
  }
2456
2526
  const $ZodBase64URL = $constructor("$ZodBase64URL", (e, t)=>{
2457
- t.pattern ?? (t.pattern = base64url), $ZodStringFormat.init(e, t), e._zod.onattach.push((e)=>{
2527
+ t.pattern ?? (t.pattern = regexes_base64url), $ZodStringFormat.init(e, t), e._zod.onattach.push((e)=>{
2458
2528
  e._zod.bag.contentEncoding = "base64url";
2459
2529
  }), e._zod.check = (n)=>{
2460
2530
  isValidBase64URL(n.value) || n.issues.push({
@@ -2561,21 +2631,43 @@ const $ZodArray = $constructor("$ZodArray", (e, t)=>{
2561
2631
  function handlePropertyResult(e, t, n, r) {
2562
2632
  e.issues.length && t.issues.push(...prefixIssues(n, e.issues)), void 0 === e.value ? n in r && (t.value[n] = void 0) : t.value[n] = e.value;
2563
2633
  }
2634
+ function normalizeDef(e) {
2635
+ let t = Object.keys(e.shape);
2636
+ for (let n of t)if (!e.shape[n]._zod.traits.has("$ZodType")) throw Error(`Invalid element at key "${n}": expected a Zod schema`);
2637
+ let n = optionalKeys(e.shape);
2638
+ return {
2639
+ ...e,
2640
+ keys: t,
2641
+ keySet: new Set(t),
2642
+ numKeys: t.length,
2643
+ optionalKeys: new Set(n)
2644
+ };
2645
+ }
2646
+ function handleCatchall(e, t, n, r, i, o) {
2647
+ let s = [], a = i.keySet, u = i.catchall._zod, l = u.def.type;
2648
+ for (let i of Object.keys(t)){
2649
+ if (a.has(i)) continue;
2650
+ if ("never" === l) {
2651
+ s.push(i);
2652
+ continue;
2653
+ }
2654
+ let o = u.run({
2655
+ value: t[i],
2656
+ issues: []
2657
+ }, r);
2658
+ o instanceof Promise ? e.push(o.then((e)=>handlePropertyResult(e, n, i, t))) : handlePropertyResult(o, n, i, t);
2659
+ }
2660
+ return (s.length && n.issues.push({
2661
+ code: "unrecognized_keys",
2662
+ keys: s,
2663
+ input: t,
2664
+ inst: o
2665
+ }), e.length) ? Promise.all(e).then(()=>n) : n;
2666
+ }
2564
2667
  const $ZodObject = $constructor("$ZodObject", (e, t)=>{
2565
- let n, r;
2668
+ let n;
2566
2669
  $ZodType.init(e, t);
2567
- let i = util_cached(()=>{
2568
- let e = Object.keys(t.shape);
2569
- for (let n of e)if (!t.shape[n]._zod.traits.has("$ZodType")) throw Error(`Invalid element at key "${n}": expected a Zod schema`);
2570
- let n = optionalKeys(t.shape);
2571
- return {
2572
- shape: t.shape,
2573
- keys: e,
2574
- keySet: new Set(e),
2575
- numKeys: e.length,
2576
- optionalKeys: new Set(n)
2577
- };
2578
- });
2670
+ let r = util_cached(()=>normalizeDef(t));
2579
2671
  defineLazy(e._zod, "propValues", ()=>{
2580
2672
  let e = t.shape, n = {};
2581
2673
  for(let t in e){
@@ -2584,83 +2676,74 @@ const $ZodObject = $constructor("$ZodObject", (e, t)=>{
2584
2676
  }
2585
2677
  return n;
2586
2678
  });
2587
- let o = (e)=>{
2679
+ let i = util_isObject, o = t.catchall;
2680
+ e._zod.parse = (t, s)=>{
2681
+ n ?? (n = r.value);
2682
+ let a = t.value;
2683
+ if (!i(a)) return t.issues.push({
2684
+ expected: "object",
2685
+ code: "invalid_type",
2686
+ input: a,
2687
+ inst: e
2688
+ }), t;
2689
+ t.value = {};
2690
+ let u = [], l = n.shape;
2691
+ for (let e of n.keys){
2692
+ let n = l[e]._zod.run({
2693
+ value: a[e],
2694
+ issues: []
2695
+ }, s);
2696
+ n instanceof Promise ? u.push(n.then((n)=>handlePropertyResult(n, t, e, a))) : handlePropertyResult(n, t, e, a);
2697
+ }
2698
+ return o ? handleCatchall(u, a, t, s, r.value, e) : u.length ? Promise.all(u).then(()=>t) : t;
2699
+ };
2700
+ }), $ZodObjectJIT = $constructor("$ZodObjectJIT", (e, t)=>{
2701
+ let n, r;
2702
+ $ZodObject.init(e, t);
2703
+ let i = e._zod.parse, o = util_cached(()=>normalizeDef(t)), s = (e)=>{
2588
2704
  let t = new Doc([
2589
2705
  "shape",
2590
2706
  "payload",
2591
2707
  "ctx"
2592
- ]), n = i.value, r = (e)=>{
2708
+ ]), n = o.value, r = (e)=>{
2593
2709
  let t = esc(e);
2594
2710
  return `shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`;
2595
2711
  };
2596
2712
  t.write("const input = payload.value;");
2597
- let o = Object.create(null), s = 0;
2598
- for (let e of n.keys)o[e] = `key_${s++}`;
2713
+ let i = Object.create(null), s = 0;
2714
+ for (let e of n.keys)i[e] = `key_${s++}`;
2599
2715
  for (let e of (t.write("const newResult = {}"), n.keys)){
2600
- let n = o[e], i = esc(e);
2716
+ let n = i[e], o = esc(e);
2601
2717
  t.write(`const ${n} = ${r(e)};`), t.write(`
2602
2718
  if (${n}.issues.length) {
2603
2719
  payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
2604
2720
  ...iss,
2605
- path: iss.path ? [${i}, ...iss.path] : [${i}]
2721
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
2606
2722
  })));
2607
2723
  }
2608
2724
 
2609
2725
  if (${n}.value === undefined) {
2610
- if (${i} in input) {
2611
- newResult[${i}] = undefined;
2726
+ if (${o} in input) {
2727
+ newResult[${o}] = undefined;
2612
2728
  }
2613
2729
  } else {
2614
- newResult[${i}] = ${n}.value;
2730
+ newResult[${o}] = ${n}.value;
2615
2731
  }
2616
2732
  `);
2617
2733
  }
2618
2734
  t.write("payload.value = newResult;"), t.write("return payload;");
2619
2735
  let a = t.compile();
2620
2736
  return (t, n)=>a(e, t, n);
2621
- }, s = util_isObject, a = !globalConfig.jitless, u = util_allowsEval, l = a && u.value, c = t.catchall;
2622
- e._zod.parse = (u, d)=>{
2623
- r ?? (r = i.value);
2624
- let p = u.value;
2625
- if (!s(p)) return u.issues.push({
2737
+ }, a = util_isObject, u = !globalConfig.jitless, l = util_allowsEval, c = u && l.value, d = t.catchall;
2738
+ e._zod.parse = (l, f)=>{
2739
+ r ?? (r = o.value);
2740
+ let p = l.value;
2741
+ return a(p) ? u && c && f?.async === !1 && !0 !== f.jitless ? (n || (n = s(t.shape)), l = n(l, f), d) ? handleCatchall([], p, l, f, r, e) : l : i(l, f) : (l.issues.push({
2626
2742
  expected: "object",
2627
2743
  code: "invalid_type",
2628
2744
  input: p,
2629
2745
  inst: e
2630
- }), u;
2631
- let f = [];
2632
- if (a && l && d?.async === !1 && !0 !== d.jitless) n || (n = o(t.shape)), u = n(u, d);
2633
- else {
2634
- u.value = {};
2635
- let e = r.shape;
2636
- for (let t of r.keys){
2637
- let n = e[t]._zod.run({
2638
- value: p[t],
2639
- issues: []
2640
- }, d);
2641
- n instanceof Promise ? f.push(n.then((e)=>handlePropertyResult(e, u, t, p))) : handlePropertyResult(n, u, t, p);
2642
- }
2643
- }
2644
- if (!c) return f.length ? Promise.all(f).then(()=>u) : u;
2645
- let h = [], m = r.keySet, g = c._zod, v = g.def.type;
2646
- for (let e of Object.keys(p)){
2647
- if (m.has(e)) continue;
2648
- if ("never" === v) {
2649
- h.push(e);
2650
- continue;
2651
- }
2652
- let t = g.run({
2653
- value: p[e],
2654
- issues: []
2655
- }, d);
2656
- t instanceof Promise ? f.push(t.then((t)=>handlePropertyResult(t, u, e, p))) : handlePropertyResult(t, u, e, p);
2657
- }
2658
- return (h.length && u.issues.push({
2659
- code: "unrecognized_keys",
2660
- keys: h,
2661
- input: p,
2662
- inst: e
2663
- }), f.length) ? Promise.all(f).then(()=>u) : u;
2746
+ }), l);
2664
2747
  };
2665
2748
  });
2666
2749
  function handleUnionResults(e, t, n, r) {
@@ -2855,11 +2938,12 @@ const $ZodRecord = $constructor("$ZodRecord", (e, t)=>{
2855
2938
  }), n;
2856
2939
  };
2857
2940
  }), $ZodTransform = $constructor("$ZodTransform", (e, t)=>{
2858
- $ZodType.init(e, t), e._zod.parse = (e, n)=>{
2859
- let r = t.transform(e.value, e);
2860
- if (n.async) return (r instanceof Promise ? r : Promise.resolve(r)).then((t)=>(e.value = t, e));
2861
- if (r instanceof Promise) throw new $ZodAsyncError();
2862
- return e.value = r, e;
2941
+ $ZodType.init(e, t), e._zod.parse = (n, r)=>{
2942
+ if ("backward" === r.direction) throw new $ZodEncodeError(e.constructor.name);
2943
+ let i = t.transform(n.value, n);
2944
+ if (r.async) return (i instanceof Promise ? i : Promise.resolve(i)).then((e)=>(n.value = e, n));
2945
+ if (i instanceof Promise) throw new $ZodAsyncError();
2946
+ return n.value = i, n;
2863
2947
  };
2864
2948
  });
2865
2949
  function handleOptionalResult(e, t) {
@@ -2892,6 +2976,7 @@ const $ZodOptional = $constructor("$ZodOptional", (e, t)=>{
2892
2976
  ]) : void 0), e._zod.parse = (e, n)=>null === e.value ? e : t.innerType._zod.run(e, n);
2893
2977
  }), $ZodDefault = $constructor("$ZodDefault", (e, t)=>{
2894
2978
  $ZodType.init(e, t), e._zod.optin = "optional", defineLazy(e._zod, "values", ()=>t.innerType._zod.values), e._zod.parse = (e, n)=>{
2979
+ if ("backward" === n.direction) return t.innerType._zod.run(e, n);
2895
2980
  if (void 0 === e.value) return e.value = t.defaultValue, e;
2896
2981
  let r = t.innerType._zod.run(e, n);
2897
2982
  return r instanceof Promise ? r.then((e)=>handleDefaultResult(e, t)) : handleDefaultResult(r, t);
@@ -2901,7 +2986,7 @@ function handleDefaultResult(e, t) {
2901
2986
  return void 0 === e.value && (e.value = t.defaultValue), e;
2902
2987
  }
2903
2988
  const $ZodPrefault = $constructor("$ZodPrefault", (e, t)=>{
2904
- $ZodType.init(e, t), e._zod.optin = "optional", defineLazy(e._zod, "values", ()=>t.innerType._zod.values), e._zod.parse = (e, n)=>(void 0 === e.value && (e.value = t.defaultValue), t.innerType._zod.run(e, n));
2989
+ $ZodType.init(e, t), e._zod.optin = "optional", defineLazy(e._zod, "values", ()=>t.innerType._zod.values), e._zod.parse = (e, n)=>("backward" === n.direction || void 0 === e.value && (e.value = t.defaultValue), t.innerType._zod.run(e, n));
2905
2990
  }), $ZodNonOptional = $constructor("$ZodNonOptional", (e, t)=>{
2906
2991
  $ZodType.init(e, t), defineLazy(e._zod, "values", ()=>{
2907
2992
  let e = t.innerType._zod.values;
@@ -2923,6 +3008,7 @@ function handleNonOptionalResult(e, t) {
2923
3008
  }
2924
3009
  const $ZodCatch = $constructor("$ZodCatch", (e, t)=>{
2925
3010
  $ZodType.init(e, t), defineLazy(e._zod, "optin", ()=>t.innerType._zod.optin), defineLazy(e._zod, "optout", ()=>t.innerType._zod.optout), defineLazy(e._zod, "values", ()=>t.innerType._zod.values), e._zod.parse = (e, n)=>{
3011
+ if ("backward" === n.direction) return t.innerType._zod.run(e, n);
2926
3012
  let r = t.innerType._zod.run(e, n);
2927
3013
  return r instanceof Promise ? r.then((r)=>(e.value = r.value, r.issues.length && (e.value = t.catchValue({
2928
3014
  ...e,
@@ -2940,18 +3026,23 @@ const $ZodCatch = $constructor("$ZodCatch", (e, t)=>{
2940
3026
  };
2941
3027
  }), $ZodPipe = $constructor("$ZodPipe", (e, t)=>{
2942
3028
  $ZodType.init(e, t), defineLazy(e._zod, "values", ()=>t.in._zod.values), defineLazy(e._zod, "optin", ()=>t.in._zod.optin), defineLazy(e._zod, "optout", ()=>t.out._zod.optout), defineLazy(e._zod, "propValues", ()=>t.in._zod.propValues), e._zod.parse = (e, n)=>{
3029
+ if ("backward" === n.direction) {
3030
+ let r = t.out._zod.run(e, n);
3031
+ return r instanceof Promise ? r.then((e)=>handlePipeResult(e, t.in, n)) : handlePipeResult(r, t.in, n);
3032
+ }
2943
3033
  let r = t.in._zod.run(e, n);
2944
- return r instanceof Promise ? r.then((e)=>handlePipeResult(e, t, n)) : handlePipeResult(r, t, n);
3034
+ return r instanceof Promise ? r.then((e)=>handlePipeResult(e, t.out, n)) : handlePipeResult(r, t.out, n);
2945
3035
  };
2946
3036
  });
2947
3037
  function handlePipeResult(e, t, n) {
2948
- return e.issues.length ? e : t.out._zod.run({
3038
+ return e.issues.length ? (e.aborted = !0, e) : t._zod.run({
2949
3039
  value: e.value,
2950
3040
  issues: e.issues
2951
3041
  }, n);
2952
3042
  }
2953
3043
  const $ZodReadonly = $constructor("$ZodReadonly", (e, t)=>{
2954
3044
  $ZodType.init(e, t), defineLazy(e._zod, "propValues", ()=>t.innerType._zod.propValues), defineLazy(e._zod, "values", ()=>t.innerType._zod.values), defineLazy(e._zod, "optin", ()=>t.innerType._zod.optin), defineLazy(e._zod, "optout", ()=>t.innerType._zod.optout), e._zod.parse = (e, n)=>{
3045
+ if ("backward" === n.direction) return t.innerType._zod.run(e, n);
2955
3046
  let r = t.innerType._zod.run(e, n);
2956
3047
  return r instanceof Promise ? r.then(handleReadonlyResult) : handleReadonlyResult(r);
2957
3048
  };
@@ -3273,6 +3364,14 @@ function _number(e, t) {
3273
3364
  ...normalizeParams(t)
3274
3365
  });
3275
3366
  }
3367
+ function _coercedNumber(e, t) {
3368
+ return new e({
3369
+ type: "number",
3370
+ coerce: !0,
3371
+ checks: [],
3372
+ ...normalizeParams(t)
3373
+ });
3374
+ }
3276
3375
  function _int(e, t) {
3277
3376
  return new e({
3278
3377
  type: "number",
@@ -3505,7 +3604,7 @@ const classic_errors_initializer = (e, t)=>{
3505
3604
  $constructor("ZodError", classic_errors_initializer);
3506
3605
  const ZodRealError = $constructor("ZodError", classic_errors_initializer, {
3507
3606
  Parent: Error
3508
- }), parse_parse = _parse(ZodRealError), parse_parseAsync = _parseAsync(ZodRealError), parse_safeParse = _safeParse(ZodRealError), parse_safeParseAsync = _safeParseAsync(ZodRealError), ZodType = $constructor("ZodType", (e, t)=>($ZodType.init(e, t), e.def = t, Object.defineProperty(e, "_def", {
3607
+ }), classic_parse_parse = _parse(ZodRealError), classic_parse_parseAsync = _parseAsync(ZodRealError), parse_safeParse = _safeParse(ZodRealError), parse_safeParseAsync = _safeParseAsync(ZodRealError), parse_encode = _encode(ZodRealError), parse_decode = _decode(ZodRealError), parse_encodeAsync = _encodeAsync(ZodRealError), parse_decodeAsync = _decodeAsync(ZodRealError), parse_safeEncode = _safeEncode(ZodRealError), parse_safeDecode = _safeDecode(ZodRealError), parse_safeEncodeAsync = _safeEncodeAsync(ZodRealError), parse_safeDecodeAsync = _safeDecodeAsync(ZodRealError), ZodType = $constructor("ZodType", (e, t)=>($ZodType.init(e, t), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", {
3509
3608
  value: t
3510
3609
  }), e.check = (...n)=>e.clone({
3511
3610
  ...t,
@@ -3521,11 +3620,11 @@ const ZodRealError = $constructor("ZodError", classic_errors_initializer, {
3521
3620
  }
3522
3621
  } : e)
3523
3622
  ]
3524
- }), e.clone = (t, n)=>clone(e, t, n), e.brand = ()=>e, e.register = (t, n)=>(t.add(e, n), e), e.parse = (t, n)=>parse_parse(e, t, n, {
3623
+ }), e.clone = (t, n)=>clone(e, t, n), e.brand = ()=>e, e.register = (t, n)=>(t.add(e, n), e), e.parse = (t, n)=>classic_parse_parse(e, t, n, {
3525
3624
  callee: e.parse
3526
- }), e.safeParse = (t, n)=>parse_safeParse(e, t, n), e.parseAsync = async (t, n)=>parse_parseAsync(e, t, n, {
3625
+ }), e.safeParse = (t, n)=>parse_safeParse(e, t, n), e.parseAsync = async (t, n)=>classic_parse_parseAsync(e, t, n, {
3527
3626
  callee: e.parseAsync
3528
- }), e.safeParseAsync = async (t, n)=>parse_safeParseAsync(e, t, n), e.spa = e.safeParseAsync, e.refine = (t, n)=>e.check(refine(t, n)), e.superRefine = (t)=>e.check(superRefine(t)), e.overwrite = (t)=>e.check(_overwrite(t)), e.optional = ()=>optional(e), e.nullable = ()=>nullable(e), e.nullish = ()=>optional(nullable(e)), e.nonoptional = (t)=>nonoptional(e, t), e.array = ()=>schemas_array(e), e.or = (t)=>union([
3627
+ }), e.safeParseAsync = async (t, n)=>parse_safeParseAsync(e, t, n), e.spa = e.safeParseAsync, e.encode = (t, n)=>parse_encode(e, t, n), e.decode = (t, n)=>parse_decode(e, t, n), e.encodeAsync = async (t, n)=>parse_encodeAsync(e, t, n), e.decodeAsync = async (t, n)=>parse_decodeAsync(e, t, n), e.safeEncode = (t, n)=>parse_safeEncode(e, t, n), e.safeDecode = (t, n)=>parse_safeDecode(e, t, n), e.safeEncodeAsync = async (t, n)=>parse_safeEncodeAsync(e, t, n), e.safeDecodeAsync = async (t, n)=>parse_safeDecodeAsync(e, t, n), e.refine = (t, n)=>e.check(refine(t, n)), e.superRefine = (t)=>e.check(superRefine(t)), e.overwrite = (t)=>e.check(_overwrite(t)), e.optional = ()=>optional(e), e.nullable = ()=>nullable(e), e.nullish = ()=>optional(nullable(e)), e.nonoptional = (t)=>nonoptional(e, t), e.array = ()=>schemas_array(e), e.or = (t)=>union([
3529
3628
  e,
3530
3629
  t
3531
3630
  ]), e.and = (t)=>intersection(e, t), e.transform = (t)=>pipe(e, transform(t)), e.default = (t)=>schemas_default(e, t), e.prefault = (t)=>prefault(e, t), e.catch = (t)=>schemas_catch(e, t), e.pipe = (t)=>pipe(e, t), e.readonly = ()=>readonly(e), e.describe = (t)=>{
@@ -3629,7 +3728,7 @@ function schemas_array(e, t) {
3629
3728
  return _array(ZodArray, e, t);
3630
3729
  }
3631
3730
  const ZodObject = $constructor("ZodObject", (e, t)=>{
3632
- $ZodObject.init(e, t), ZodType.init(e, t), defineLazy(e, "shape", ()=>t.shape), e.keyof = ()=>schemas_enum(Object.keys(e._zod.def.shape)), e.catchall = (t)=>e.clone({
3731
+ $ZodObjectJIT.init(e, t), ZodType.init(e, t), defineLazy(e, "shape", ()=>t.shape), e.keyof = ()=>schemas_enum(Object.keys(e._zod.def.shape)), e.catchall = (t)=>e.clone({
3633
3732
  ...e._zod.def,
3634
3733
  catchall: t
3635
3734
  }), e.passthrough = ()=>e.clone({
@@ -3644,7 +3743,7 @@ const ZodObject = $constructor("ZodObject", (e, t)=>{
3644
3743
  }), e.strip = ()=>e.clone({
3645
3744
  ...e._zod.def,
3646
3745
  catchall: void 0
3647
- }), e.extend = (t)=>extend(e, t), e.merge = (t)=>merge(e, t), e.pick = (t)=>pick(e, t), e.omit = (t)=>omit(e, t), e.partial = (...t)=>partial(ZodOptional, e, t[0]), e.required = (...t)=>required(ZodNonOptional, e, t[0]);
3746
+ }), e.extend = (t)=>extend(e, t), e.safeExtend = (t)=>safeExtend(e, t), e.merge = (t)=>merge(e, t), e.pick = (t)=>pick(e, t), e.omit = (t)=>omit(e, t), e.partial = (...t)=>partial(ZodOptional, e, t[0]), e.required = (...t)=>required(ZodNonOptional, e, t[0]);
3648
3747
  });
3649
3748
  function schemas_object(e, t) {
3650
3749
  return new ZodObject({
@@ -3752,6 +3851,7 @@ function literal(e, t) {
3752
3851
  }
3753
3852
  const ZodTransform = $constructor("ZodTransform", (e, t)=>{
3754
3853
  $ZodTransform.init(e, t), ZodType.init(e, t), e._zod.parse = (n, r)=>{
3854
+ if ("backward" === r.direction) throw new $ZodEncodeError(e.constructor.name);
3755
3855
  n.addIssue = (r)=>{
3756
3856
  if ("string" == typeof r) n.issues.push(util_issue(r, n.value, t));
3757
3857
  else {
@@ -3902,7 +4002,7 @@ function safeJsonParseWithZod(e, t) {
3902
4002
  let { success: r, data: i, error: o } = t.safeParse(n);
3903
4003
  return r ? i : (console.warn(`Failed to parse JSON with Zod: ${e}`, o), null);
3904
4004
  }
3905
- function base64ToUint8Array(e) {
4005
+ function utils_base64ToUint8Array(e) {
3906
4006
  let t = enc_base64_default().parse(e), n = new Uint8Array(t.sigBytes);
3907
4007
  for(let e = 0; e < t.sigBytes; e++){
3908
4008
  let r = e >>> 2, i = e % 4;
@@ -3986,6 +4086,14 @@ class HttpStatusError extends Error {
3986
4086
  });
3987
4087
  }
3988
4088
  }
4089
+ class HttpSchemaError extends Error {
4090
+ constructor(e, t, n){
4091
+ super(`Failed to parse response with schema: ${prettifyError(n)}`), fetch_define_property(this, "context", void 0), fetch_define_property(this, "response", void 0), fetch_define_property(this, "error", void 0), this.context = e, this.response = t, this.error = n, this.name = "HttpSchemaError", console.error(`\u{1F6AB} HTTP Request Failed Failed to parse response with schema: ${prettifyError(n)}: ${e.method} ${e.url}`), console.error("Response:", {
4092
+ headers: t.headers,
4093
+ data: t.data
4094
+ });
4095
+ }
4096
+ }
3989
4097
  class Fetch {
3990
4098
  setCookie(e) {
3991
4099
  this.cookie = merge_merge(this.cookie, e);
@@ -4047,16 +4155,13 @@ class Fetch {
4047
4155
  }, s), r = storage.getJson(n);
4048
4156
  if (r) return console.debug("fetch cache hit", n), Promise.resolve(r);
4049
4157
  }
4050
- let a = o ? void 0 : n, { timeout: u, schema: l, params: c, ...d } = s, p = t;
4051
- c && (p = `${t}?${url_parse.qs.stringify(c)}`), console.debug("\u2B06\uFE0F fetch", t, null != a ? a : "", {
4052
- ...d,
4053
- params: c
4054
- });
4055
- let f = o ? Widget.http.get(p, d) : Widget.http.post(p, a, d);
4158
+ let a = o ? void 0 : n, { timeout: u, schema: l, params: c, ...d } = s, f = t;
4159
+ c && (f = `${t}?${url_parse.qs.stringify(c)}`), console.debug("\u2B06\uFE0F fetch", f, null != a ? a : "", d);
4160
+ let p = o ? Widget.http.get(f, d) : Widget.http.post(f, a, d);
4056
4161
  return u && u > 0 ? Promise.race([
4057
- f,
4162
+ p,
4058
4163
  this.createTimeoutPromise(u)
4059
- ]) : f;
4164
+ ]) : p;
4060
4165
  }
4061
4166
  getCacheKey(e, t) {
4062
4167
  var n;
@@ -4067,6 +4172,11 @@ class Fetch {
4067
4172
  fetch_define_property(this, "cookie", void 0), fetch_define_property(this, "headers", void 0), fetch_define_property(this, "handleResponse", void 0), this.cookie = e, this.headers = t, this.handleResponse = (e, t, n)=>{
4068
4173
  var r;
4069
4174
  if ((null == n || null == (r = n.successStatus) ? void 0 : r.length) && !n.successStatus.includes(e.statusCode)) throw new HttpStatusError(e.statusCode, n.successStatus, t, e);
4175
+ if (null == n ? void 0 : n.schema) {
4176
+ let r = n.schema.safeParse(e.data);
4177
+ if (!r.success) throw new HttpSchemaError(t, e, r.error);
4178
+ e.data = r.data;
4179
+ }
4070
4180
  let i = e.headers["set-cookie"] || e.headers["Set-Cookie"];
4071
4181
  if (i) {
4072
4182
  let e = i.split(",").reduce((e, t)=>{
@@ -4082,23 +4192,67 @@ class Fetch {
4082
4192
  ttl: n.cache.ttl
4083
4193
  });
4084
4194
  }
4085
- if (null == n ? void 0 : n.schema) {
4086
- let r = n.schema.safeParse(e.data);
4087
- return r.success || (console.error(t.url, "Failed to parse response with schema:", prettifyError(r.error)), console.error("Response:", e.data)), {
4088
- ...e,
4089
- data: r.data
4090
- };
4091
- }
4092
4195
  return e;
4093
4196
  };
4094
4197
  }
4095
4198
  }
4096
- const getExternalIdsByTmdbId = async (e, t)=>{
4199
+ function coerce_number(e) {
4200
+ return _coercedNumber(ZodNumber, e);
4201
+ }
4202
+ const BASE_URL = "https://api.imdbapi.dev", fetch = new Fetch(), episodesRequestSchema = schemas_object({
4203
+ season: coerce_number().optional().default(1),
4204
+ pageSize: coerce_number().optional().default(20),
4205
+ pageToken: schemas_string().optional()
4206
+ }), getImdbEpisodes = async (e, t)=>{
4207
+ let { season: n, pageSize: r, pageToken: i } = episodesRequestSchema.parse(null != t ? t : {});
4208
+ return (await fetch.get(`${BASE_URL}/titles/${e}/episodes`, {
4209
+ params: {
4210
+ season: n,
4211
+ pageSize: r,
4212
+ pageToken: i
4213
+ },
4214
+ cache: {
4215
+ cacheKey: [
4216
+ "imdb",
4217
+ "episodes",
4218
+ e,
4219
+ n,
4220
+ r,
4221
+ i
4222
+ ].filter(Boolean).join(":")
4223
+ },
4224
+ successStatus: [
4225
+ 200
4226
+ ],
4227
+ schema: schemas_object({
4228
+ episodes: schemas_array(schemas_object({
4229
+ id: schemas_string(),
4230
+ title: schemas_string().optional(),
4231
+ episodeNumber: schemas_number().optional()
4232
+ })),
4233
+ totalCount: schemas_number(),
4234
+ nextPageToken: schemas_string().optional()
4235
+ })
4236
+ })).data;
4237
+ }, getImdbSeasons = async (e)=>(await fetch.get(`${BASE_URL}/titles/${e}/seasons`, {
4238
+ cache: {
4239
+ cacheKey: [
4240
+ "imdb:seasons",
4241
+ e
4242
+ ].join(":")
4243
+ },
4244
+ schema: schemas_object({
4245
+ seasons: schemas_array(schemas_object({
4246
+ season: schemas_string(),
4247
+ episodeCount: schemas_number().optional()
4248
+ }))
4249
+ })
4250
+ })).data, getExternalIdsByTmdbId = async (e, t)=>{
4097
4251
  let n = null, r = `tmdb:${e}:${t}:external_ids`, i = storage.getJson(r);
4098
4252
  return i ? n = i : (n = await Widget.tmdb.get(`/${e}/${t}/external_ids`), storage.setJson(r, n, {
4099
4253
  ttl: TTL_7_DAYS
4100
4254
  })), n;
4101
- }, fetch = new Fetch(), doubanImdbResponseSchema = schemas_object({
4255
+ }, douban_fetch = new Fetch(), doubanImdbResponseSchema = schemas_object({
4102
4256
  id: schemas_string(),
4103
4257
  rating: schemas_object({
4104
4258
  min: schemas_number(),
@@ -4115,9 +4269,19 @@ const getExternalIdsByTmdbId = async (e, t)=>{
4115
4269
  count: schemas_number().optional(),
4116
4270
  name: schemas_string().optional()
4117
4271
  })).optional()
4118
- }), getDoubanInfoByImdbId = async (e)=>{
4119
- var t, n, r, i;
4120
- let o = await fetch.post(`https://api.douban.com/v2/movie/imdb/${e}`, {
4272
+ }), getDoubanInfoByImdbId = async (e, t)=>{
4273
+ var n, r, i, o, s, a;
4274
+ let u = e;
4275
+ if (t && "1" !== t.toString()) {
4276
+ let n = await getImdbSeasons(e);
4277
+ if (!n || parseInt(t.toString()) > n.seasons.length) return null;
4278
+ let r = await getImdbEpisodes(e, {
4279
+ season: t
4280
+ });
4281
+ u = null != (s = null == r || null == (o = r.episodes.find((e)=>1 === e.episodeNumber)) ? void 0 : o.id) ? s : "";
4282
+ }
4283
+ u || (u = e), console.log("Get douban info by imdb id", u);
4284
+ let l = await douban_fetch.post(`https://api.douban.com/v2/movie/imdb/${u}`, {
4121
4285
  apikey: DOUBAN_API_KEY
4122
4286
  }, {
4123
4287
  headers: {
@@ -4125,20 +4289,20 @@ const getExternalIdsByTmdbId = async (e, t)=>{
4125
4289
  },
4126
4290
  schema: doubanImdbResponseSchema,
4127
4291
  cache: {
4128
- cacheKey: `douban:imdb:${e}`,
4292
+ cacheKey: `douban:imdb:${u}`,
4129
4293
  ttl: TTL_7_DAYS
4130
4294
  }
4131
4295
  });
4132
- if (200 !== o.statusCode) throw Error(`Failed to get Douban info: ${o.statusCode}, ${JSON.stringify(o.data)}`);
4133
- let s = null == (r = o.data) || null == (n = r.id) || null == (t = n.split("/")) ? void 0 : t.pop();
4134
- if (!s) throw Error(`Failed to extract Douban ID from response: ${null == (i = o.data) ? void 0 : i.id}`);
4135
- return /\d+/.test(s) ? {
4136
- doubanId: s,
4137
- originResponse: o.data
4296
+ if (200 !== l.statusCode) throw Error(`Failed to get Douban info: ${l.statusCode}, ${JSON.stringify(l.data)}`);
4297
+ let c = null == (i = l.data) || null == (r = i.id) || null == (n = r.split("/")) ? void 0 : n.pop();
4298
+ if (!c) throw Error(`Failed to extract Douban ID from response: ${null == (a = l.data) ? void 0 : a.id}`);
4299
+ return /\d+/.test(c) ? {
4300
+ doubanId: c,
4301
+ originResponse: l.data
4138
4302
  } : null;
4139
- }, getDoubanInfoByTmdbId = async (e, t)=>{
4140
- let n = await getExternalIdsByTmdbId(e, t);
4141
- return (console.log("Get external ids by tmdb id", n), n.imdb_id) ? getDoubanInfoByImdbId(n.imdb_id) : null;
4303
+ }, getDoubanInfoByTmdbId = async (e, t, n)=>{
4304
+ let r = await getExternalIdsByTmdbId(e, t);
4305
+ return (console.log("Get external ids by tmdb id", r), r.imdb_id) ? getDoubanInfoByImdbId(r.imdb_id, n) : null;
4142
4306
  }, doubanInfoResponseSchema = schemas_object({
4143
4307
  is_tv: schemas_boolean().optional(),
4144
4308
  vendors: schemas_array(schemas_object({
@@ -4148,7 +4312,7 @@ const getExternalIdsByTmdbId = async (e, t)=>{
4148
4312
  }))
4149
4313
  }), getVideoPlatformInfoByDoubanId = async (e)=>{
4150
4314
  var t, n, r;
4151
- let i = await fetch.get(`https://m.douban.com/rexxar/api/v2/movie/${e}?for_mobile=1`, {
4315
+ let i = await douban_fetch.get(`https://m.douban.com/rexxar/api/v2/movie/${e}?for_mobile=1`, {
4152
4316
  headers: {
4153
4317
  Referer: `https://m.douban.com/movie/subject/${e}/?dt_dapp=1`,
4154
4318
  "Content-Type": "application/json"
@@ -4377,7 +4541,7 @@ class BilibiliScraper extends BaseScraper {
4377
4541
  base64Data: !0
4378
4542
  });
4379
4543
  if (404 === r.statusCode || 304 === r.statusCode) return null;
4380
- let i = this.DmSegMobileReply.decode(base64ToUint8Array(r.data));
4544
+ let i = this.DmSegMobileReply.decode(utils_base64ToUint8Array(r.data));
4381
4545
  return console.log(i), i.elems;
4382
4546
  } catch (r) {
4383
4547
  console.error(`\u{83B7}\u{53D6}\u{5206}\u{6BB5} ${n} \u{5931}\u{8D25} (aid=${e}, cid=${t}): ${r}`);
@@ -4799,9 +4963,9 @@ const parseXml = function(e) {
4799
4963
  } else {
4800
4964
  let s = readTagExp(e, o, this.options.removeNSPrefix), a = s.tagName, u = s.rawTagName, l = s.tagExp, c = s.attrExpPresent, d = s.closeIndex;
4801
4965
  this.options.transformTagName && (a = this.options.transformTagName(a)), n && r && '!xml' !== n.tagname && (r = this.saveTextToParentTag(r, n, i, !1));
4802
- let p = n;
4803
- p && -1 !== this.options.unpairedTags.indexOf(p.tagname) && (n = this.tagsNodeStack.pop(), i = i.substring(0, i.lastIndexOf("."))), a !== t.tagname && (i += i ? "." + a : a);
4804
- let f = o;
4966
+ let f = n;
4967
+ f && -1 !== this.options.unpairedTags.indexOf(f.tagname) && (n = this.tagsNodeStack.pop(), i = i.substring(0, i.lastIndexOf("."))), a !== t.tagname && (i += i ? "." + a : a);
4968
+ let p = o;
4805
4969
  if (this.isItStopNode(this.options.stopNodes, i, a)) {
4806
4970
  let t = "";
4807
4971
  if (l.length > 0 && l.lastIndexOf("/") === l.length - 1) "/" === a[a.length - 1] ? (a = a.substr(0, a.length - 1), i = i.substr(0, i.length - 1), l = a) : l = l.substr(0, l.length - 1), o = s.closeIndex;
@@ -4812,15 +4976,15 @@ const parseXml = function(e) {
4812
4976
  o = n.i, t = n.tagContent;
4813
4977
  }
4814
4978
  let r = new XmlNode(a);
4815
- a !== l && c && (r[":@"] = this.buildAttributesMap(l, i, a)), t && (t = this.parseTextData(t, a, i, !0, c, !0, !0)), i = i.substr(0, i.lastIndexOf(".")), r.add(this.options.textNodeName, t), this.addChild(n, r, i, f);
4979
+ a !== l && c && (r[":@"] = this.buildAttributesMap(l, i, a)), t && (t = this.parseTextData(t, a, i, !0, c, !0, !0)), i = i.substr(0, i.lastIndexOf(".")), r.add(this.options.textNodeName, t), this.addChild(n, r, i, p);
4816
4980
  } else {
4817
4981
  if (l.length > 0 && l.lastIndexOf("/") === l.length - 1) {
4818
4982
  "/" === a[a.length - 1] ? (a = a.substr(0, a.length - 1), i = i.substr(0, i.length - 1), l = a) : l = l.substr(0, l.length - 1), this.options.transformTagName && (a = this.options.transformTagName(a));
4819
4983
  let e = new XmlNode(a);
4820
- a !== l && c && (e[":@"] = this.buildAttributesMap(l, i, a)), this.addChild(n, e, i, f), i = i.substr(0, i.lastIndexOf("."));
4984
+ a !== l && c && (e[":@"] = this.buildAttributesMap(l, i, a)), this.addChild(n, e, i, p), i = i.substr(0, i.lastIndexOf("."));
4821
4985
  } else {
4822
4986
  let e = new XmlNode(a);
4823
- this.tagsNodeStack.push(n), a !== l && c && (e[":@"] = this.buildAttributesMap(l, i, a)), this.addChild(n, e, i, f), n = e;
4987
+ this.tagsNodeStack.push(n), a !== l && c && (e[":@"] = this.buildAttributesMap(l, i, a)), this.addChild(n, e, i, p), n = e;
4824
4988
  }
4825
4989
  r = "", o = d;
4826
4990
  }
@@ -5696,8 +5860,8 @@ class YoukuScraper extends BaseScraper {
5696
5860
  if (d) return [
5697
5861
  n(d, u)
5698
5862
  ];
5699
- let p = Number(null != (i = null == o ? void 0 : o.total) ? i : 0), f = Math.max(1, Math.ceil(p / a)), h = Array.from({
5700
- length: f
5863
+ let f = Number(null != (i = null == o ? void 0 : o.total) ? i : 0), p = Math.max(1, Math.ceil(f / a)), h = Array.from({
5864
+ length: p
5701
5865
  }, (e, t)=>t + 1).filter((e)=>e !== l), m = [];
5702
5866
  for (let e of h){
5703
5867
  await this.sleep(500);
@@ -6022,7 +6186,7 @@ class scrapers_Scraper {
6022
6186
  });
6023
6187
  }
6024
6188
  }
6025
- const widgetVersion = "0.0.13";
6189
+ const widgetVersion = "0.0.15";
6026
6190
  WidgetMetadata = {
6027
6191
  id: "baranwang.danmu.universe",
6028
6192
  title: "\u901A\u7528\u5F39\u5E55",
@@ -6066,13 +6230,13 @@ const src_scraper = new scrapers_Scraper();
6066
6230
  searchDanmu = async (e)=>{
6067
6231
  var t;
6068
6232
  storage.cleanup();
6069
- let { tmdbId: n, type: r, episode: i } = e;
6233
+ let { tmdbId: n, type: r, season: i, episode: o } = e;
6070
6234
  if (!n) return {
6071
6235
  animes: []
6072
6236
  };
6073
- let o = await getDoubanInfoByTmdbId(r, n);
6237
+ let s = await getDoubanInfoByTmdbId(r, n, i);
6074
6238
  return {
6075
- animes: (await src_scraper.getDetailWithDoubanId(null != (t = null == o ? void 0 : o.doubanId) ? t : "", r, i)).map((e)=>{
6239
+ animes: (await src_scraper.getDetailWithDoubanId(null != (t = null == s ? void 0 : s.doubanId) ? t : "", r, o)).map((e)=>{
6076
6240
  let t = `[${PROVIDER_NAMES[e.provider]}] `;
6077
6241
  return e.episodeTitle && (t += e.episodeTitle), {
6078
6242
  animeId: e.episodeId,
@@ -6082,25 +6246,25 @@ searchDanmu = async (e)=>{
6082
6246
  };
6083
6247
  }, getDetail = async (e)=>{
6084
6248
  var t;
6085
- let { animeId: n, tmdbId: r, type: i, episode: o } = e;
6249
+ let { animeId: n, tmdbId: r, type: i, season: o, episode: s } = e;
6086
6250
  if (!r && !n) return null;
6087
- if (n) return src_scraper.getDetailWithAnimeId(n.toString(), i, o);
6088
- let s = await getDoubanInfoByTmdbId(i, null != r ? r : "");
6089
- return src_scraper.getDetailWithDoubanId(null != (t = null == s ? void 0 : s.doubanId) ? t : "", i, o);
6251
+ if (n) return src_scraper.getDetailWithAnimeId(n.toString(), i, s);
6252
+ let a = await getDoubanInfoByTmdbId(i, null != r ? r : "", o);
6253
+ return src_scraper.getDetailWithDoubanId(null != (t = null == a ? void 0 : a.doubanId) ? t : "", i, s);
6090
6254
  }, getComments = async (e)=>{
6091
- let { animeId: t, commentId: n, segmentTime: r, tmdbId: i, type: o, episode: s } = e, a = null != n ? n : t;
6092
- if (!a) {
6093
- var u;
6255
+ let { animeId: t, commentId: n, segmentTime: r, tmdbId: i, type: o, season: s, episode: a } = e, u = null != n ? n : t;
6256
+ if (!u) {
6257
+ var l;
6094
6258
  if (!i) return null;
6095
- let e = await getDoubanInfoByTmdbId(o, i);
6096
- a = (await src_scraper.getDetailWithDoubanId(null != (u = null == e ? void 0 : e.doubanId) ? u : "", o, s)).map((e)=>[
6259
+ let e = await getDoubanInfoByTmdbId(o, i, s);
6260
+ u = (await src_scraper.getDetailWithDoubanId(null != (l = null == e ? void 0 : e.doubanId) ? l : "", o, a)).map((e)=>[
6097
6261
  e.provider,
6098
6262
  e.episodeId
6099
6263
  ].join(":")).join(",");
6100
6264
  }
6101
- let l = await src_scraper.getDanmuWithSegmentTimeByVideoId(a.toString(), r);
6265
+ let c = await src_scraper.getDanmuWithSegmentTimeByVideoId(u.toString(), r);
6102
6266
  return {
6103
- comments: l,
6104
- count: l.length
6267
+ comments: c,
6268
+ count: c.length
6105
6269
  };
6106
6270
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forward-widget/danmu-universe",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "main": "./dist/danmu-universe.js",
6
6
  "exports": {
@@ -16,11 +16,12 @@
16
16
  "p-limit": "^6.2.0",
17
17
  "protobufjs": "^7.5.4",
18
18
  "url-parse": "^1.5.10",
19
- "zod": "^4.0.17"
19
+ "zod": "^4.1.5"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@forward-widget/libs": "^1.8.4",
23
23
  "@forward-widget/rslib-plugin": "^1.8.4",
24
+ "@rsdoctor/rspack-plugin": "^1.2.3",
24
25
  "@rslib/core": "^0.12.4",
25
26
  "@rstest/core": "^0.3.1",
26
27
  "@types/crypto-js": "^4.2.2",