mtranserver 4.0.18 → 4.0.19

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.
package/dist/index.js CHANGED
@@ -131,7 +131,7 @@ function getConfig() {
131
131
  logConsole: getBool("--log-console", "MT_LOG_CONSOLE", true),
132
132
  logRequests: getBool("--log-requests", "MT_LOG_REQUESTS", false),
133
133
  checkUpdate: getBool("--check-update", "MT_CHECK_UPDATE", true),
134
- cacheSize: getInt("--cache-size", "MT_CACHE_SIZE", 0)
134
+ cacheSize: getInt("--cache-size", "MT_CACHE_SIZE", 1000)
135
135
  };
136
136
  return globalConfig;
137
137
  }
@@ -1051,7 +1051,7 @@ function getLanguagePairs() {
1051
1051
  return [];
1052
1052
  const pairs = new Set;
1053
1053
  for (const record of globalRecords.data) {
1054
- pairs.add(`${record.sourceLanguage}-${record.targetLanguage}`);
1054
+ pairs.add(`${record.sourceLanguage}_${record.targetLanguage}`);
1055
1055
  }
1056
1056
  return Array.from(pairs);
1057
1057
  }
@@ -1468,10 +1468,10 @@ class TranslationEngine {
1468
1468
  return chunks;
1469
1469
  }
1470
1470
  _hideEmojis(text) {
1471
- const emojiRegex = /(\p{Emoji_Presentation}|\p{Extended_Pictographic})/gu;
1471
+ const emojiRegex = /(\p{RI}\p{RI}|\p{Emoji_Presentation}|\p{Extended_Pictographic})/gu;
1472
1472
  const replacements = [];
1473
1473
  const cleanText = text.replace(emojiRegex, (match) => {
1474
- const placeholder = `[EE${replacements.length}]`;
1474
+ const placeholder = `<e${replacements.length}>`;
1475
1475
  replacements.push({ original: match, placeholder });
1476
1476
  return placeholder;
1477
1477
  });
@@ -4400,23 +4400,23 @@ var init_bergamot_translator = () => {};
4400
4400
 
4401
4401
  // src/lib/cld2/cld2.js
4402
4402
  var require_cld2 = __commonJS((exports, module) => {
4403
- var __dirname = "/home/xxnuo/projects/MTran/MTranServer/src/lib/cld2", __filename = "/home/xxnuo/projects/MTran/MTranServer/src/lib/cld2/cld2.js";
4403
+ var __dirname = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/src/lib/cld2", __filename = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/src/lib/cld2/cld2.js";
4404
4404
  var loadCLD2 = (() => {
4405
4405
  var _scriptName = globalThis.document?.currentScript?.src;
4406
4406
  return async function(moduleArg = {}) {
4407
4407
  var moduleRtn;
4408
- function aa(a) {
4408
+ function ba(a) {
4409
4409
  var b = 0;
4410
4410
  return function() {
4411
4411
  return b < a.length ? { done: false, value: a[b++] } : { done: true };
4412
4412
  };
4413
4413
  }
4414
- function g(a) {
4414
+ function h(a) {
4415
4415
  var b = typeof Symbol != "undefined" && Symbol.iterator && a[Symbol.iterator];
4416
4416
  if (b)
4417
4417
  return b.call(a);
4418
4418
  if (typeof a.length == "number")
4419
- return { next: aa(a) };
4419
+ return { next: ba(a) };
4420
4420
  throw Error(String(a) + " is not an iterable or ArrayLike");
4421
4421
  }
4422
4422
  var l = typeof Object.defineProperties == "function" ? Object.defineProperty : function(a, b, c) {
@@ -4425,7 +4425,7 @@ var require_cld2 = __commonJS((exports, module) => {
4425
4425
  a[b] = c.value;
4426
4426
  return a;
4427
4427
  };
4428
- function ba(a) {
4428
+ function ca(a) {
4429
4429
  a = [typeof globalThis == "object" && globalThis, a, typeof window == "object" && window, typeof self == "object" && self, typeof global == "object" && global];
4430
4430
  for (var b = 0;b < a.length; ++b) {
4431
4431
  var c = a[b];
@@ -4434,17 +4434,17 @@ var require_cld2 = __commonJS((exports, module) => {
4434
4434
  }
4435
4435
  throw Error("Cannot find global object");
4436
4436
  }
4437
- var p = ba(this);
4437
+ var n = ca(this);
4438
4438
  function r(a, b) {
4439
4439
  if (b)
4440
4440
  a: {
4441
- var c = p;
4441
+ var c = n;
4442
4442
  a = a.split(".");
4443
4443
  for (var d = 0;d < a.length - 1; d++) {
4444
- var f = a[d];
4445
- if (!(f in c))
4444
+ var e = a[d];
4445
+ if (!(e in c))
4446
4446
  break a;
4447
- c = c[f];
4447
+ c = c[e];
4448
4448
  }
4449
4449
  a = a[a.length - 1];
4450
4450
  d = c[a];
@@ -4453,138 +4453,138 @@ var require_cld2 = __commonJS((exports, module) => {
4453
4453
  }
4454
4454
  }
4455
4455
  function t() {
4456
- this.G = false;
4457
- this.B = null;
4458
- this.C = undefined;
4459
- this.v = 1;
4460
- this.J = this.F = 0;
4461
- this.D = null;
4456
+ this.H = false;
4457
+ this.C = null;
4458
+ this.D = undefined;
4459
+ this.A = 1;
4460
+ this.K = this.G = 0;
4461
+ this.F = null;
4462
4462
  }
4463
4463
  function u(a) {
4464
- if (a.G)
4464
+ if (a.H)
4465
4465
  throw new TypeError("Generator is already running");
4466
- a.G = true;
4466
+ a.H = true;
4467
4467
  }
4468
- t.prototype.H = function(a) {
4469
- this.C = a;
4468
+ t.prototype.I = function(a) {
4469
+ this.D = a;
4470
4470
  };
4471
4471
  function v(a, b) {
4472
- a.D = { R: b, $: true };
4473
- a.v = a.F || a.J;
4472
+ a.F = { S: b, aa: true };
4473
+ a.A = a.G || a.K;
4474
4474
  }
4475
4475
  t.prototype.return = function(a) {
4476
- this.D = { return: a };
4477
- this.v = this.J;
4476
+ this.F = { return: a };
4477
+ this.A = this.K;
4478
4478
  };
4479
- function x(a, b, c) {
4480
- a.v = c;
4479
+ function w(a, b, c) {
4480
+ a.A = c;
4481
4481
  return { value: b };
4482
4482
  }
4483
4483
  function y(a) {
4484
- a.F = 0;
4485
- var b = a.D.R;
4486
- a.D = null;
4484
+ a.G = 0;
4485
+ var b = a.F.S;
4486
+ a.F = null;
4487
4487
  return b;
4488
4488
  }
4489
- function ca(a) {
4490
- this.v = new t;
4491
- this.B = a;
4489
+ function da(a) {
4490
+ this.A = new t;
4491
+ this.C = a;
4492
4492
  }
4493
- function da(a, b) {
4494
- u(a.v);
4495
- var c = a.v.B;
4493
+ function ea(a, b) {
4494
+ u(a.A);
4495
+ var c = a.A.C;
4496
4496
  if (c)
4497
4497
  return z(a, "return" in c ? c["return"] : function(d) {
4498
4498
  return { value: d, done: true };
4499
- }, b, a.v.return);
4500
- a.v.return(b);
4499
+ }, b, a.A.return);
4500
+ a.A.return(b);
4501
4501
  return C(a);
4502
4502
  }
4503
4503
  function z(a, b, c, d) {
4504
4504
  try {
4505
- var f = b.call(a.v.B, c);
4506
- if (!(f instanceof Object))
4507
- throw new TypeError("Iterator result " + f + " is not an object");
4508
- if (!f.done)
4509
- return a.v.G = false, f;
4510
- var h = f.value;
4511
- } catch (e) {
4512
- return a.v.B = null, v(a.v, e), C(a);
4513
- }
4514
- a.v.B = null;
4515
- d.call(a.v, h);
4505
+ var e = b.call(a.A.C, c);
4506
+ if (!(e instanceof Object))
4507
+ throw new TypeError("Iterator result " + e + " is not an object");
4508
+ if (!e.done)
4509
+ return a.A.H = false, e;
4510
+ var g = e.value;
4511
+ } catch (f) {
4512
+ return a.A.C = null, v(a.A, f), C(a);
4513
+ }
4514
+ a.A.C = null;
4515
+ d.call(a.A, g);
4516
4516
  return C(a);
4517
4517
  }
4518
4518
  function C(a) {
4519
- for (;a.v.v; )
4519
+ for (;a.A.A; )
4520
4520
  try {
4521
- var b = a.B(a.v);
4521
+ var b = a.C(a.A);
4522
4522
  if (b)
4523
- return a.v.G = false, { value: b.value, done: false };
4523
+ return a.A.H = false, { value: b.value, done: false };
4524
4524
  } catch (c) {
4525
- a.v.C = undefined, v(a.v, c);
4525
+ a.A.D = undefined, v(a.A, c);
4526
4526
  }
4527
- a.v.G = false;
4528
- if (a.v.D) {
4529
- b = a.v.D;
4530
- a.v.D = null;
4531
- if (b.$)
4532
- throw b.R;
4527
+ a.A.H = false;
4528
+ if (a.A.F) {
4529
+ b = a.A.F;
4530
+ a.A.F = null;
4531
+ if (b.aa)
4532
+ throw b.S;
4533
4533
  return { value: b.return, done: true };
4534
4534
  }
4535
4535
  return { value: undefined, done: true };
4536
4536
  }
4537
- function ea(a) {
4537
+ function fa(a) {
4538
4538
  this.next = function(b) {
4539
- u(a.v);
4540
- a.v.B ? b = z(a, a.v.B.next, b, a.v.H) : (a.v.H(b), b = C(a));
4539
+ u(a.A);
4540
+ a.A.C ? b = z(a, a.A.C.next, b, a.A.I) : (a.A.I(b), b = C(a));
4541
4541
  return b;
4542
4542
  };
4543
4543
  this.throw = function(b) {
4544
- u(a.v);
4545
- a.v.B ? b = z(a, a.v.B["throw"], b, a.v.H) : (v(a.v, b), b = C(a));
4544
+ u(a.A);
4545
+ a.A.C ? b = z(a, a.A.C["throw"], b, a.A.I) : (v(a.A, b), b = C(a));
4546
4546
  return b;
4547
4547
  };
4548
4548
  this.return = function(b) {
4549
- return da(a, b);
4549
+ return ea(a, b);
4550
4550
  };
4551
4551
  this[Symbol.iterator] = function() {
4552
4552
  return this;
4553
4553
  };
4554
4554
  }
4555
- function fa(a) {
4555
+ function ha(a) {
4556
4556
  function b(d) {
4557
4557
  return a.next(d);
4558
4558
  }
4559
4559
  function c(d) {
4560
4560
  return a.throw(d);
4561
4561
  }
4562
- return new Promise(function(d, f) {
4563
- function h(e) {
4564
- e.done ? d(e.value) : Promise.resolve(e.value).then(b, c).then(h, f);
4562
+ return new Promise(function(d, e) {
4563
+ function g(f) {
4564
+ f.done ? d(f.value) : Promise.resolve(f.value).then(b, c).then(g, e);
4565
4565
  }
4566
- h(a.next());
4566
+ g(a.next());
4567
4567
  });
4568
4568
  }
4569
4569
  function D(a) {
4570
- return fa(new ea(new ca(a)));
4570
+ return ha(new fa(new da(a)));
4571
4571
  }
4572
4572
  r("Symbol", function(a) {
4573
- function b(h) {
4573
+ function b(g) {
4574
4574
  if (this instanceof b)
4575
4575
  throw new TypeError("Symbol is not a constructor");
4576
- return new c(d + (h || "") + "_" + f++, h);
4576
+ return new c(d + (g || "") + "_" + e++, g);
4577
4577
  }
4578
- function c(h, e) {
4579
- this.v = h;
4580
- l(this, "description", { configurable: true, writable: true, value: e });
4578
+ function c(g, f) {
4579
+ this.A = g;
4580
+ l(this, "description", { configurable: true, writable: true, value: f });
4581
4581
  }
4582
4582
  if (a)
4583
4583
  return a;
4584
4584
  c.prototype.toString = function() {
4585
- return this.v;
4585
+ return this.A;
4586
4586
  };
4587
- var d = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", f = 0;
4587
+ var d = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", e = 0;
4588
4588
  return b;
4589
4589
  });
4590
4590
  r("Symbol.iterator", function(a) {
@@ -4592,14 +4592,14 @@ var require_cld2 = __commonJS((exports, module) => {
4592
4592
  return a;
4593
4593
  a = Symbol("Symbol.iterator");
4594
4594
  for (var b = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), c = 0;c < b.length; c++) {
4595
- var d = p[b[c]];
4595
+ var d = n[b[c]];
4596
4596
  typeof d === "function" && typeof d.prototype[a] != "function" && l(d.prototype, a, { configurable: true, writable: true, value: function() {
4597
- return ha(aa(this));
4597
+ return ia(ba(this));
4598
4598
  } });
4599
4599
  }
4600
4600
  return a;
4601
4601
  });
4602
- function ha(a) {
4602
+ function ia(a) {
4603
4603
  a = { next: a };
4604
4604
  a[Symbol.iterator] = function() {
4605
4605
  return this;
@@ -4607,82 +4607,82 @@ var require_cld2 = __commonJS((exports, module) => {
4607
4607
  return a;
4608
4608
  }
4609
4609
  r("Promise", function(a) {
4610
- function b(e) {
4611
- this.B = 0;
4612
- this.C = undefined;
4613
- this.v = [];
4614
- this.H = false;
4615
- var k = this.D();
4610
+ function b(f) {
4611
+ this.C = 0;
4612
+ this.D = undefined;
4613
+ this.A = [];
4614
+ this.I = false;
4615
+ var k = this.F();
4616
4616
  try {
4617
- e(k.resolve, k.reject);
4617
+ f(k.resolve, k.reject);
4618
4618
  } catch (m) {
4619
4619
  k.reject(m);
4620
4620
  }
4621
4621
  }
4622
4622
  function c() {
4623
- this.v = null;
4623
+ this.A = null;
4624
4624
  }
4625
- function d(e) {
4626
- return e instanceof b ? e : new b(function(k) {
4627
- k(e);
4625
+ function d(f) {
4626
+ return f instanceof b ? f : new b(function(k) {
4627
+ k(f);
4628
4628
  });
4629
4629
  }
4630
4630
  if (a)
4631
4631
  return a;
4632
- c.prototype.B = function(e) {
4633
- if (this.v == null) {
4634
- this.v = [];
4632
+ c.prototype.C = function(f) {
4633
+ if (this.A == null) {
4634
+ this.A = [];
4635
4635
  var k = this;
4636
- this.C(function() {
4637
- k.F();
4636
+ this.D(function() {
4637
+ k.G();
4638
4638
  });
4639
4639
  }
4640
- this.v.push(e);
4640
+ this.A.push(f);
4641
4641
  };
4642
- var f = p.setTimeout;
4643
- c.prototype.C = function(e) {
4644
- f(e, 0);
4642
+ var e = n.setTimeout;
4643
+ c.prototype.D = function(f) {
4644
+ e(f, 0);
4645
4645
  };
4646
- c.prototype.F = function() {
4647
- for (;this.v && this.v.length; ) {
4648
- var e = this.v;
4649
- this.v = [];
4650
- for (var k = 0;k < e.length; ++k) {
4651
- var m = e[k];
4652
- e[k] = null;
4646
+ c.prototype.G = function() {
4647
+ for (;this.A && this.A.length; ) {
4648
+ var f = this.A;
4649
+ this.A = [];
4650
+ for (var k = 0;k < f.length; ++k) {
4651
+ var m = f[k];
4652
+ f[k] = null;
4653
4653
  try {
4654
4654
  m();
4655
- } catch (n) {
4656
- this.D(n);
4655
+ } catch (p) {
4656
+ this.F(p);
4657
4657
  }
4658
4658
  }
4659
4659
  }
4660
- this.v = null;
4660
+ this.A = null;
4661
4661
  };
4662
- c.prototype.D = function(e) {
4663
- this.C(function() {
4664
- throw e;
4662
+ c.prototype.F = function(f) {
4663
+ this.D(function() {
4664
+ throw f;
4665
4665
  });
4666
4666
  };
4667
- b.prototype.D = function() {
4668
- function e(n) {
4667
+ b.prototype.F = function() {
4668
+ function f(p) {
4669
4669
  return function(q) {
4670
- m || (m = true, n.call(k, q));
4670
+ m || (m = true, p.call(k, q));
4671
4671
  };
4672
4672
  }
4673
4673
  var k = this, m = false;
4674
- return { resolve: e(this.V), reject: e(this.F) };
4674
+ return { resolve: f(this.W), reject: f(this.G) };
4675
4675
  };
4676
- b.prototype.V = function(e) {
4677
- if (e === this)
4678
- this.F(new TypeError("A Promise cannot resolve to itself"));
4679
- else if (e instanceof b)
4680
- this.X(e);
4676
+ b.prototype.W = function(f) {
4677
+ if (f === this)
4678
+ this.G(new TypeError("A Promise cannot resolve to itself"));
4679
+ else if (f instanceof b)
4680
+ this.Y(f);
4681
4681
  else {
4682
4682
  a:
4683
- switch (typeof e) {
4683
+ switch (typeof f) {
4684
4684
  case "object":
4685
- var k = e != null;
4685
+ var k = f != null;
4686
4686
  break a;
4687
4687
  case "function":
4688
4688
  k = true;
@@ -4690,144 +4690,144 @@ var require_cld2 = __commonJS((exports, module) => {
4690
4690
  default:
4691
4691
  k = false;
4692
4692
  }
4693
- k ? this.U(e) : this.G(e);
4693
+ k ? this.V(f) : this.H(f);
4694
4694
  }
4695
4695
  };
4696
- b.prototype.U = function(e) {
4696
+ b.prototype.V = function(f) {
4697
4697
  var k = undefined;
4698
4698
  try {
4699
- k = e.then;
4699
+ k = f.then;
4700
4700
  } catch (m) {
4701
- this.F(m);
4701
+ this.G(m);
4702
4702
  return;
4703
4703
  }
4704
- typeof k == "function" ? this.Y(k, e) : this.G(e);
4704
+ typeof k == "function" ? this.Z(k, f) : this.H(f);
4705
4705
  };
4706
- b.prototype.F = function(e) {
4707
- this.J(2, e);
4706
+ b.prototype.G = function(f) {
4707
+ this.K(2, f);
4708
4708
  };
4709
- b.prototype.G = function(e) {
4710
- this.J(1, e);
4709
+ b.prototype.H = function(f) {
4710
+ this.K(1, f);
4711
4711
  };
4712
- b.prototype.J = function(e, k) {
4713
- if (this.B != 0)
4714
- throw Error("Cannot settle(" + e + ", " + k + "): Promise already settled in state" + this.B);
4715
- this.B = e;
4716
- this.C = k;
4717
- this.B === 2 && this.W();
4718
- this.S();
4712
+ b.prototype.K = function(f, k) {
4713
+ if (this.C != 0)
4714
+ throw Error("Cannot settle(" + f + ", " + k + "): Promise already settled in state" + this.C);
4715
+ this.C = f;
4716
+ this.D = k;
4717
+ this.C === 2 && this.X();
4718
+ this.T();
4719
4719
  };
4720
- b.prototype.W = function() {
4721
- var e = this;
4722
- f(function() {
4723
- if (e.T()) {
4724
- var k = p.console;
4725
- typeof k !== "undefined" && k.error(e.C);
4720
+ b.prototype.X = function() {
4721
+ var f = this;
4722
+ e(function() {
4723
+ if (f.U()) {
4724
+ var k = n.console;
4725
+ typeof k !== "undefined" && k.error(f.D);
4726
4726
  }
4727
4727
  }, 1);
4728
4728
  };
4729
- b.prototype.T = function() {
4730
- if (this.H)
4729
+ b.prototype.U = function() {
4730
+ if (this.I)
4731
4731
  return false;
4732
- var { CustomEvent: e, Event: k, dispatchEvent: m } = p;
4732
+ var { CustomEvent: f, Event: k, dispatchEvent: m } = n;
4733
4733
  if (typeof m === "undefined")
4734
4734
  return true;
4735
- typeof e === "function" ? e = new e("unhandledrejection", { cancelable: true }) : typeof k === "function" ? e = new k("unhandledrejection", { cancelable: true }) : (e = p.document.createEvent("CustomEvent"), e.initCustomEvent("unhandledrejection", false, true, e));
4736
- e.promise = this;
4737
- e.reason = this.C;
4738
- return m(e);
4735
+ typeof f === "function" ? f = new f("unhandledrejection", { cancelable: true }) : typeof k === "function" ? f = new k("unhandledrejection", { cancelable: true }) : (f = n.document.createEvent("CustomEvent"), f.initCustomEvent("unhandledrejection", false, true, f));
4736
+ f.promise = this;
4737
+ f.reason = this.D;
4738
+ return m(f);
4739
4739
  };
4740
- b.prototype.S = function() {
4741
- if (this.v != null) {
4742
- for (var e = 0;e < this.v.length; ++e)
4743
- h.B(this.v[e]);
4744
- this.v = null;
4740
+ b.prototype.T = function() {
4741
+ if (this.A != null) {
4742
+ for (var f = 0;f < this.A.length; ++f)
4743
+ g.C(this.A[f]);
4744
+ this.A = null;
4745
4745
  }
4746
4746
  };
4747
- var h = new c;
4748
- b.prototype.X = function(e) {
4749
- var k = this.D();
4750
- e.N(k.resolve, k.reject);
4747
+ var g = new c;
4748
+ b.prototype.Y = function(f) {
4749
+ var k = this.F();
4750
+ f.O(k.resolve, k.reject);
4751
4751
  };
4752
- b.prototype.Y = function(e, k) {
4753
- var m = this.D();
4752
+ b.prototype.Z = function(f, k) {
4753
+ var m = this.F();
4754
4754
  try {
4755
- e.call(k, m.resolve, m.reject);
4756
- } catch (n) {
4757
- m.reject(n);
4755
+ f.call(k, m.resolve, m.reject);
4756
+ } catch (p) {
4757
+ m.reject(p);
4758
4758
  }
4759
4759
  };
4760
- b.prototype.then = function(e, k) {
4761
- function m(w, A) {
4762
- return typeof w == "function" ? function(Y) {
4760
+ b.prototype.then = function(f, k) {
4761
+ function m(x, A) {
4762
+ return typeof x == "function" ? function(Z) {
4763
4763
  try {
4764
- n(w(Y));
4765
- } catch (Z) {
4766
- q(Z);
4764
+ p(x(Z));
4765
+ } catch (aa) {
4766
+ q(aa);
4767
4767
  }
4768
4768
  } : A;
4769
4769
  }
4770
- var n, q, B = new b(function(w, A) {
4771
- n = w;
4770
+ var p, q, B = new b(function(x, A) {
4771
+ p = x;
4772
4772
  q = A;
4773
4773
  });
4774
- this.N(m(e, n), m(k, q));
4774
+ this.O(m(f, p), m(k, q));
4775
4775
  return B;
4776
4776
  };
4777
- b.prototype.catch = function(e) {
4778
- return this.then(undefined, e);
4777
+ b.prototype.catch = function(f) {
4778
+ return this.then(undefined, f);
4779
4779
  };
4780
- b.prototype.N = function(e, k) {
4780
+ b.prototype.O = function(f, k) {
4781
4781
  function m() {
4782
- switch (n.B) {
4782
+ switch (p.C) {
4783
4783
  case 1:
4784
- e(n.C);
4784
+ f(p.D);
4785
4785
  break;
4786
4786
  case 2:
4787
- k(n.C);
4787
+ k(p.D);
4788
4788
  break;
4789
4789
  default:
4790
- throw Error("Unexpected state: " + n.B);
4790
+ throw Error("Unexpected state: " + p.C);
4791
4791
  }
4792
4792
  }
4793
- var n = this;
4794
- this.v == null ? h.B(m) : this.v.push(m);
4795
- this.H = true;
4793
+ var p = this;
4794
+ this.A == null ? g.C(m) : this.A.push(m);
4795
+ this.I = true;
4796
4796
  };
4797
4797
  b.resolve = d;
4798
- b.reject = function(e) {
4798
+ b.reject = function(f) {
4799
4799
  return new b(function(k, m) {
4800
- m(e);
4800
+ m(f);
4801
4801
  });
4802
4802
  };
4803
- b.race = function(e) {
4803
+ b.race = function(f) {
4804
4804
  return new b(function(k, m) {
4805
- for (var n = g(e), q = n.next();!q.done; q = n.next())
4806
- d(q.value).N(k, m);
4805
+ for (var p = h(f), q = p.next();!q.done; q = p.next())
4806
+ d(q.value).O(k, m);
4807
4807
  });
4808
4808
  };
4809
- b.all = function(e) {
4810
- var k = g(e), m = k.next();
4811
- return m.done ? d([]) : new b(function(n, q) {
4812
- function B(Y) {
4813
- return function(Z) {
4814
- w[Y] = Z;
4809
+ b.all = function(f) {
4810
+ var k = h(f), m = k.next();
4811
+ return m.done ? d([]) : new b(function(p, q) {
4812
+ function B(Z) {
4813
+ return function(aa) {
4814
+ x[Z] = aa;
4815
4815
  A--;
4816
- A == 0 && n(w);
4816
+ A == 0 && p(x);
4817
4817
  };
4818
4818
  }
4819
- var w = [], A = 0;
4819
+ var x = [], A = 0;
4820
4820
  do
4821
- w.push(undefined), A++, d(m.value).N(B(w.length - 1), q), m = k.next();
4821
+ x.push(undefined), A++, d(m.value).O(B(x.length - 1), q), m = k.next();
4822
4822
  while (!m.done);
4823
4823
  });
4824
4824
  };
4825
4825
  return b;
4826
4826
  });
4827
4827
  r("globalThis", function(a) {
4828
- return a || p;
4828
+ return a || n;
4829
4829
  });
4830
- function ia(a, b, c) {
4830
+ function ja(a, b, c) {
4831
4831
  if (a == null)
4832
4832
  throw new TypeError("The 'this' value for String.prototype." + c + " must not be null or undefined");
4833
4833
  if (b instanceof RegExp)
@@ -4836,61 +4836,61 @@ var require_cld2 = __commonJS((exports, module) => {
4836
4836
  }
4837
4837
  r("String.prototype.startsWith", function(a) {
4838
4838
  return a ? a : function(b, c) {
4839
- var d = ia(this, b, "startsWith"), f = d.length, h = b.length;
4839
+ var d = ja(this, b, "startsWith"), e = d.length, g = b.length;
4840
4840
  c = Math.max(0, Math.min(c | 0, d.length));
4841
- for (var e = 0;e < h && c < f; )
4842
- if (d[c++] != b[e++])
4841
+ for (var f = 0;f < g && c < e; )
4842
+ if (d[c++] != b[f++])
4843
4843
  return false;
4844
- return e >= h;
4844
+ return f >= g;
4845
4845
  };
4846
4846
  });
4847
4847
  r("String.prototype.codePointAt", function(a) {
4848
4848
  return a ? a : function(b) {
4849
- var c = ia(this, null, "codePointAt"), d = c.length;
4849
+ var c = ja(this, null, "codePointAt"), d = c.length;
4850
4850
  b = Number(b) || 0;
4851
4851
  if (0 <= b && b < d) {
4852
4852
  b |= 0;
4853
- var f = c.charCodeAt(b);
4854
- if (55296 > f || 56319 < f || b + 1 === d)
4855
- return f;
4853
+ var e = c.charCodeAt(b);
4854
+ if (55296 > e || 56319 < e || b + 1 === d)
4855
+ return e;
4856
4856
  b = c.charCodeAt(b + 1);
4857
- return 56320 > b || 57343 < b ? f : 1024 * (f - 55296) + b + 9216;
4857
+ return 56320 > b || 57343 < b ? e : 1024 * (e - 55296) + b + 9216;
4858
4858
  }
4859
4859
  };
4860
4860
  });
4861
- function ja(a, b) {
4861
+ function ka(a, b) {
4862
4862
  a instanceof String && (a += "");
4863
- var c = 0, d = false, f = { next: function() {
4863
+ var c = 0, d = false, e = { next: function() {
4864
4864
  if (!d && c < a.length) {
4865
- var h = c++;
4866
- return { value: b(h, a[h]), done: false };
4865
+ var g = c++;
4866
+ return { value: b(g, a[g]), done: false };
4867
4867
  }
4868
4868
  d = true;
4869
4869
  return { done: true, value: undefined };
4870
4870
  } };
4871
- f[Symbol.iterator] = function() {
4872
- return f;
4871
+ e[Symbol.iterator] = function() {
4872
+ return e;
4873
4873
  };
4874
- return f;
4874
+ return e;
4875
4875
  }
4876
4876
  r("Array.prototype.keys", function(a) {
4877
4877
  return a ? a : function() {
4878
- return ja(this, function(b) {
4878
+ return ka(this, function(b) {
4879
4879
  return b;
4880
4880
  });
4881
4881
  };
4882
4882
  });
4883
- var E = moduleArg, ka = !!globalThis.window, la = !!globalThis.WorkerGlobalScope, ma, na, oa, pa = ((ma = globalThis.process) == null ? undefined : (na = ma.versions) == null ? undefined : na.node) && ((oa = globalThis.process) == null ? undefined : oa.type) != "renderer";
4884
- typeof __filename != "undefined" ? _scriptName = __filename : la && (_scriptName = self.location.href);
4885
- var F = "", qa, G;
4886
- if (pa) {
4883
+ var E = moduleArg, la = !!globalThis.window, ma = !!globalThis.WorkerGlobalScope, na, oa, pa, qa = ((na = globalThis.process) == null ? undefined : (oa = na.versions) == null ? undefined : oa.node) && ((pa = globalThis.process) == null ? undefined : pa.type) != "renderer";
4884
+ typeof __filename != "undefined" ? _scriptName = __filename : ma && (_scriptName = self.location.href);
4885
+ var F = "", ra, G;
4886
+ if (qa) {
4887
4887
  var fs5 = __require("fs");
4888
4888
  F = __dirname + "/";
4889
4889
  G = function(a) {
4890
4890
  a = H(a) ? new URL(a) : a;
4891
4891
  return fs5.readFileSync(a);
4892
4892
  };
4893
- qa = function(a) {
4893
+ ra = function(a) {
4894
4894
  var b = b === undefined ? true : b;
4895
4895
  var c;
4896
4896
  return D(function(d) {
@@ -4900,46 +4900,46 @@ var require_cld2 = __commonJS((exports, module) => {
4900
4900
  });
4901
4901
  };
4902
4902
  process.argv.slice(2);
4903
- } else if (ka || la) {
4903
+ } else if (la || ma) {
4904
4904
  try {
4905
4905
  F = new URL(".", _scriptName).href;
4906
4906
  } catch (a) {}
4907
- la && (G = function(a) {
4907
+ ma && (G = function(a) {
4908
4908
  var b = new XMLHttpRequest;
4909
4909
  b.open("GET", a, false);
4910
4910
  b.responseType = "arraybuffer";
4911
4911
  b.send(null);
4912
4912
  return new Uint8Array(b.response);
4913
4913
  });
4914
- qa = function(a) {
4914
+ ra = function(a) {
4915
4915
  var b;
4916
4916
  return D(function(c) {
4917
- if (c.v == 1)
4918
- return H(a) ? c.return(new Promise(function(d, f) {
4919
- var h = new XMLHttpRequest;
4920
- h.open("GET", a, true);
4921
- h.responseType = "arraybuffer";
4922
- h.onload = function() {
4923
- h.status == 200 || h.status == 0 && h.response ? d(h.response) : f(h.status);
4917
+ if (c.A == 1)
4918
+ return H(a) ? c.return(new Promise(function(d, e) {
4919
+ var g = new XMLHttpRequest;
4920
+ g.open("GET", a, true);
4921
+ g.responseType = "arraybuffer";
4922
+ g.onload = function() {
4923
+ g.status == 200 || g.status == 0 && g.response ? d(g.response) : e(g.status);
4924
4924
  };
4925
- h.onerror = f;
4926
- h.send(null);
4927
- })) : x(c, fetch(a, { credentials: "same-origin" }), 2);
4928
- b = c.C;
4925
+ g.onerror = e;
4926
+ g.send(null);
4927
+ })) : w(c, fetch(a, { credentials: "same-origin" }), 2);
4928
+ b = c.D;
4929
4929
  if (b.ok)
4930
4930
  return c.return(b.arrayBuffer());
4931
4931
  throw Error(b.status + " : " + b.url);
4932
4932
  });
4933
4933
  };
4934
4934
  }
4935
- var ra = console.log.bind(console), I = console.error.bind(console), J, sa = false;
4935
+ var sa = console.log.bind(console), I = console.error.bind(console), J, ta = false;
4936
4936
  function H(a) {
4937
4937
  return a.startsWith("file://");
4938
4938
  }
4939
- var ta, ua, va, K, L, wa = false;
4940
- function xa() {
4939
+ var ua, va, wa, K, L, xa = false;
4940
+ function ya() {
4941
4941
  var a = M.buffer;
4942
- va = new Int8Array(a);
4942
+ wa = new Int8Array(a);
4943
4943
  new Int16Array(a);
4944
4944
  K = new Uint8Array(a);
4945
4945
  new Uint16Array(a);
@@ -4955,130 +4955,130 @@ var require_cld2 = __commonJS((exports, module) => {
4955
4955
  (b = E.onAbort) == null || b.call(E, a);
4956
4956
  a = "Aborted(" + a + ")";
4957
4957
  I(a);
4958
- sa = true;
4958
+ ta = true;
4959
4959
  a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
4960
4960
  var c;
4961
- (c = ua) == null || c(a);
4961
+ (c = va) == null || c(a);
4962
4962
  throw a;
4963
4963
  }
4964
4964
  var O;
4965
- function ya(a) {
4965
+ function za(a) {
4966
4966
  var b;
4967
4967
  return D(function(c) {
4968
- switch (c.v) {
4968
+ switch (c.A) {
4969
4969
  case 1:
4970
4970
  if (J) {
4971
- c.v = 2;
4971
+ c.A = 2;
4972
4972
  break;
4973
4973
  }
4974
- c.F = 3;
4975
- return x(c, qa(a), 5);
4974
+ c.G = 3;
4975
+ return w(c, ra(a), 5);
4976
4976
  case 5:
4977
- return b = c.C, c.return(new Uint8Array(b));
4977
+ return b = c.D, c.return(new Uint8Array(b));
4978
4978
  case 3:
4979
4979
  y(c);
4980
4980
  case 2:
4981
4981
  var d = c.return;
4982
4982
  if (a == O && J)
4983
- var f = new Uint8Array(J);
4983
+ var e = new Uint8Array(J);
4984
4984
  else if (G)
4985
- f = G(a);
4985
+ e = G(a);
4986
4986
  else
4987
4987
  throw "both async and sync fetching of the wasm failed";
4988
- return d.call(c, f);
4988
+ return d.call(c, e);
4989
4989
  }
4990
4990
  });
4991
4991
  }
4992
- function za(a, b) {
4993
- var c, d, f;
4994
- return D(function(h) {
4995
- switch (h.v) {
4992
+ function Aa(a, b) {
4993
+ var c, d, e;
4994
+ return D(function(g) {
4995
+ switch (g.A) {
4996
4996
  case 1:
4997
- return h.F = 2, x(h, ya(a), 4);
4997
+ return g.G = 2, w(g, za(a), 4);
4998
4998
  case 4:
4999
- return c = h.C, x(h, WebAssembly.instantiate(c, b), 5);
4999
+ return c = g.D, w(g, WebAssembly.instantiate(c, b), 5);
5000
5000
  case 5:
5001
- return d = h.C, h.return(d);
5001
+ return d = g.D, g.return(d);
5002
5002
  case 2:
5003
- f = y(h), I("failed to asynchronously prepare wasm: " + f), N(f), h.v = 0;
5003
+ e = y(g), I("failed to asynchronously prepare wasm: " + e), N(e), g.A = 0;
5004
5004
  }
5005
5005
  });
5006
5006
  }
5007
- function Aa(a) {
5008
- var b = J, c = O, d, f, h;
5009
- return D(function(e) {
5010
- switch (e.v) {
5007
+ function Ba(a) {
5008
+ var b = J, c = O, d, e, g;
5009
+ return D(function(f) {
5010
+ switch (f.A) {
5011
5011
  case 1:
5012
- if (b || H(c) || pa) {
5013
- e.v = 2;
5012
+ if (b || H(c) || qa) {
5013
+ f.A = 2;
5014
5014
  break;
5015
5015
  }
5016
- e.F = 3;
5016
+ f.G = 3;
5017
5017
  d = fetch(c, { credentials: "same-origin" });
5018
- return x(e, WebAssembly.instantiateStreaming(d, a), 5);
5018
+ return w(f, WebAssembly.instantiateStreaming(d, a), 5);
5019
5019
  case 5:
5020
- return f = e.C, e.return(f);
5020
+ return e = f.D, f.return(e);
5021
5021
  case 3:
5022
- h = y(e), I("wasm streaming compile failed: " + h), I("falling back to ArrayBuffer instantiation");
5022
+ g = y(f), I("wasm streaming compile failed: " + g), I("falling back to ArrayBuffer instantiation");
5023
5023
  case 2:
5024
- return e.return(za(c, a));
5024
+ return f.return(Aa(c, a));
5025
5025
  }
5026
5026
  });
5027
5027
  }
5028
- function Ba(a) {
5028
+ function Ca(a) {
5029
5029
  for (;0 < a.length; )
5030
5030
  a.shift()(E);
5031
5031
  }
5032
- var Ca = [], Da = [];
5033
- function Ea() {
5032
+ var Da = [], Ea = [];
5033
+ function Fa() {
5034
5034
  var a = E.preRun.shift();
5035
- Da.push(a);
5035
+ Ea.push(a);
5036
5036
  }
5037
- function Fa(a) {
5038
- this.A = a - 24;
5037
+ function Ga(a) {
5038
+ this.B = a - 24;
5039
5039
  }
5040
- var Ga = 0, Ha = 0, Ia = [null, [], []], Ja = globalThis.TextDecoder && new TextDecoder;
5041
- function Ka(a, b) {
5040
+ var Ha = 0, Ia = 0, Ja = [null, [], []], Ka = globalThis.TextDecoder && new TextDecoder;
5041
+ function La(a, b) {
5042
5042
  b = b === undefined ? 0 : b;
5043
5043
  var c = b;
5044
5044
  for (var d = c + undefined;a[c] && !(c >= d); )
5045
5045
  ++c;
5046
- if (16 < c - b && a.buffer && Ja)
5047
- return Ja.decode(a.subarray(b, c));
5046
+ if (16 < c - b && a.buffer && Ka)
5047
+ return Ka.decode(a.subarray(b, c));
5048
5048
  for (d = "";b < c; ) {
5049
- var f = a[b++];
5050
- if (f & 128) {
5051
- var h = a[b++] & 63;
5052
- if ((f & 224) == 192)
5053
- d += String.fromCharCode((f & 31) << 6 | h);
5049
+ var e = a[b++];
5050
+ if (e & 128) {
5051
+ var g = a[b++] & 63;
5052
+ if ((e & 224) == 192)
5053
+ d += String.fromCharCode((e & 31) << 6 | g);
5054
5054
  else {
5055
- var e = a[b++] & 63;
5056
- f = (f & 240) == 224 ? (f & 15) << 12 | h << 6 | e : (f & 7) << 18 | h << 12 | e << 6 | a[b++] & 63;
5057
- 65536 > f ? d += String.fromCharCode(f) : (f -= 65536, d += String.fromCharCode(55296 | f >> 10, 56320 | f & 1023));
5055
+ var f = a[b++] & 63;
5056
+ e = (e & 240) == 224 ? (e & 15) << 12 | g << 6 | f : (e & 7) << 18 | g << 12 | f << 6 | a[b++] & 63;
5057
+ 65536 > e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
5058
5058
  }
5059
5059
  } else
5060
- d += String.fromCharCode(f);
5060
+ d += String.fromCharCode(e);
5061
5061
  }
5062
5062
  return d;
5063
5063
  }
5064
- function La(a) {
5065
- return a ? Ka(K, a) : "";
5064
+ function Ma(a) {
5065
+ return a ? La(K, a) : "";
5066
5066
  }
5067
- var Ma = [];
5068
- E.print && (ra = E.print);
5067
+ var Na = [];
5068
+ E.print && (sa = E.print);
5069
5069
  E.printErr && (I = E.printErr);
5070
5070
  E.wasmBinary && (J = E.wasmBinary);
5071
5071
  if (E.preInit)
5072
5072
  for (typeof E.preInit == "function" && (E.preInit = [E.preInit]);0 < E.preInit.length; )
5073
5073
  E.preInit.shift()();
5074
- var Na, Oa, Pa, Qa, Ra, Sa, Ta, Ua, Va, Wa, Xa, Ya, M, Za = { a: function(a, b, c) {
5075
- var d = new Fa(a);
5076
- L[d.A + 16 >> 2] = 0;
5077
- L[d.A + 4 >> 2] = b;
5078
- L[d.A + 8 >> 2] = c;
5079
- Ga = a;
5080
- Ha++;
5081
- throw Ga;
5074
+ var Oa, Pa, Qa, Ra, Sa, Ta, Ua, Va, Wa, Xa, Ya, Za, $a, ab2, M, bb = { a: function(a, b, c) {
5075
+ var d = new Ga(a);
5076
+ L[d.B + 16 >> 2] = 0;
5077
+ L[d.B + 4 >> 2] = b;
5078
+ L[d.B + 8 >> 2] = c;
5079
+ Ha = a;
5080
+ Ia++;
5081
+ throw Ha;
5082
5082
  }, c: function() {
5083
5083
  return N("");
5084
5084
  }, e: function(a, b) {
@@ -5095,89 +5095,91 @@ var require_cld2 = __commonJS((exports, module) => {
5095
5095
  d = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, d) / 65536)) - M.buffer.byteLength + 65535) / 65536 | 0;
5096
5096
  try {
5097
5097
  M.grow(d);
5098
- xa();
5099
- var f = 1;
5098
+ ya();
5099
+ var e = 1;
5100
5100
  break a;
5101
- } catch (h) {}
5102
- f = undefined;
5101
+ } catch (g) {}
5102
+ e = undefined;
5103
5103
  }
5104
- if (f)
5104
+ if (e)
5105
5105
  return true;
5106
5106
  }
5107
5107
  return false;
5108
5108
  }, b: function(a, b, c, d) {
5109
- for (var f = 0, h = 0;h < c; h++) {
5110
- var e = L[b >> 2], k = L[b + 4 >> 2];
5109
+ for (var e = 0, g = 0;g < c; g++) {
5110
+ var f = L[b >> 2], k = L[b + 4 >> 2];
5111
5111
  b += 8;
5112
5112
  for (var m = 0;m < k; m++) {
5113
- var n = a, q = K[e + m], B = Ia[n];
5114
- q === 0 || q === 10 ? ((n === 1 ? ra : I)(Ka(B)), B.length = 0) : B.push(q);
5113
+ var p = a, q = K[f + m], B = Ja[p];
5114
+ q === 0 || q === 10 ? ((p === 1 ? sa : I)(La(B)), B.length = 0) : B.push(q);
5115
5115
  }
5116
- f += k;
5116
+ e += k;
5117
5117
  }
5118
- L[d >> 2] = f;
5118
+ L[d >> 2] = e;
5119
5119
  return 0;
5120
5120
  } }, P;
5121
5121
  P = await function() {
5122
- function a(f) {
5123
- f = P = f.exports;
5124
- E._webidl_free = f.h;
5125
- E._webidl_malloc = f.i;
5126
- Na = E._emscripten_bind_Language_getLanguageCode_0 = f.j;
5127
- Oa = E._emscripten_bind_Language___destroy___0 = f.k;
5128
- Pa = E._emscripten_bind_VoidPtr___destroy___0 = f.l;
5129
- Qa = E._emscripten_bind_LanguageGuess_getPercent_0 = f.m;
5130
- Ra = E._emscripten_bind_LanguageGuess_getLanguageCode_0 = f.n;
5131
- Sa = E._emscripten_bind_LanguageGuess___destroy___0 = f.o;
5132
- Ta = E._emscripten_bind_LanguageInfo_detectLanguage_2 = f.p;
5133
- Ua = E._emscripten_bind_LanguageInfo_detectLanguage_5 = f.q;
5134
- Va = E._emscripten_bind_LanguageInfo_getIsReliable_0 = f.r;
5135
- Wa = E._emscripten_bind_LanguageInfo_getLanguageCode_0 = f.s;
5136
- Xa = E._emscripten_bind_LanguageInfo_get_languages_1 = f.t;
5137
- Ya = E._emscripten_bind_LanguageInfo___destroy___0 = f.u;
5138
- M = f.f;
5139
- xa();
5122
+ function a(e) {
5123
+ e = P = e.exports;
5124
+ E._webidl_free = e.h;
5125
+ E._webidl_malloc = e.i;
5126
+ Oa = E._emscripten_bind_Language_getLanguageCode_0 = e.j;
5127
+ Pa = E._emscripten_bind_Language___destroy___0 = e.k;
5128
+ Qa = E._emscripten_bind_VoidPtr___destroy___0 = e.l;
5129
+ Ra = E._emscripten_bind_LanguageGuess_getPercent_0 = e.m;
5130
+ Sa = E._emscripten_bind_LanguageGuess_getLanguageCode_0 = e.n;
5131
+ Ta = E._emscripten_bind_LanguageGuess___destroy___0 = e.o;
5132
+ Ua = E._emscripten_bind_LanguageInfo_detectLanguageWithLength_3 = e.p;
5133
+ Va = E._emscripten_bind_LanguageInfo_detectLanguageWithLength_6 = e.q;
5134
+ Wa = E._emscripten_bind_LanguageInfo_detectLanguage_2 = e.r;
5135
+ Xa = E._emscripten_bind_LanguageInfo_detectLanguage_5 = e.s;
5136
+ Ya = E._emscripten_bind_LanguageInfo_getIsReliable_0 = e.t;
5137
+ Za = E._emscripten_bind_LanguageInfo_getLanguageCode_0 = e.u;
5138
+ $a = E._emscripten_bind_LanguageInfo_get_languages_1 = e.v;
5139
+ ab2 = E._emscripten_bind_LanguageInfo___destroy___0 = e.w;
5140
+ M = e.f;
5141
+ ya();
5140
5142
  return P;
5141
5143
  }
5142
5144
  var b, c, d;
5143
- return D(function(f) {
5144
- if (f.v == 1) {
5145
- b = { a: Za };
5145
+ return D(function(e) {
5146
+ if (e.A == 1) {
5147
+ b = { a: bb };
5146
5148
  if (E.instantiateWasm)
5147
- return f.return(new Promise(function(h) {
5148
- E.instantiateWasm(b, function(e, k) {
5149
- h(a(e, k));
5149
+ return e.return(new Promise(function(g) {
5150
+ E.instantiateWasm(b, function(f, k) {
5151
+ g(a(f, k));
5150
5152
  });
5151
5153
  }));
5152
5154
  O != null || (O = E.locateFile ? E.locateFile("cld2.wasm", F) : F + "cld2.wasm");
5153
- return x(f, Aa(b), 2);
5155
+ return w(e, Ba(b), 2);
5154
5156
  }
5155
- c = f.C;
5157
+ c = e.D;
5156
5158
  d = a(c.instance);
5157
- return f.return(d);
5159
+ return e.return(d);
5158
5160
  });
5159
5161
  }();
5160
5162
  (function() {
5161
5163
  function a() {
5162
5164
  E.calledRun = true;
5163
- if (!sa) {
5164
- wa = true;
5165
- Ba(Ma);
5165
+ if (!ta) {
5166
+ xa = true;
5167
+ Ca(Na);
5166
5168
  P.g();
5167
5169
  var b;
5168
- (b = ta) == null || b(E);
5170
+ (b = ua) == null || b(E);
5169
5171
  var c;
5170
5172
  (c = E.onRuntimeInitialized) == null || c.call(E);
5171
5173
  if (E.postRun)
5172
5174
  for (typeof E.postRun == "function" && (E.postRun = [E.postRun]);E.postRun.length; )
5173
- b = E.postRun.shift(), Ca.push(b);
5174
- Ba(Ca);
5175
+ b = E.postRun.shift(), Da.push(b);
5176
+ Ca(Da);
5175
5177
  }
5176
5178
  }
5177
5179
  if (E.preRun)
5178
5180
  for (typeof E.preRun == "function" && (E.preRun = [E.preRun]);E.preRun.length; )
5179
- Ea();
5180
- Ba(Da);
5181
+ Fa();
5182
+ Ca(Ea);
5181
5183
  E.setStatus ? (E.setStatus("Running..."), setTimeout(function() {
5182
5184
  setTimeout(function() {
5183
5185
  return E.setStatus("");
@@ -5188,61 +5190,61 @@ var require_cld2 = __commonJS((exports, module) => {
5188
5190
  function Q() {}
5189
5191
  Q.prototype = Object.create(Q.prototype);
5190
5192
  Q.prototype.constructor = Q;
5191
- Q.prototype.I = Q;
5192
- Q.K = {};
5193
+ Q.prototype.J = Q;
5194
+ Q.L = {};
5193
5195
  E.WrapperObject = Q;
5194
- function $a(a) {
5195
- return (a || Q).K;
5196
+ function cb(a) {
5197
+ return (a || Q).L;
5196
5198
  }
5197
- E.getCache = $a;
5199
+ E.getCache = cb;
5198
5200
  function R(a, b) {
5199
- var c = $a(b), d = c[a];
5201
+ var c = cb(b), d = c[a];
5200
5202
  if (d)
5201
5203
  return d;
5202
5204
  d = Object.create((b || Q).prototype);
5203
- d.A = a;
5205
+ d.B = a;
5204
5206
  return c[a] = d;
5205
5207
  }
5206
5208
  E.wrapPointer = R;
5207
5209
  E.castObject = function(a, b) {
5208
- return R(a.A, b);
5210
+ return R(a.B, b);
5209
5211
  };
5210
5212
  E.NULL = R(0);
5211
5213
  E.destroy = function(a) {
5212
5214
  if (!a.__destroy__)
5213
5215
  throw "Error: Cannot destroy object. (Did you create it yourself?)";
5214
5216
  a.__destroy__();
5215
- delete $a(a.I)[a.A];
5217
+ delete cb(a.J)[a.B];
5216
5218
  };
5217
5219
  E.compare = function(a, b) {
5218
- return a.A === b.A;
5220
+ return a.B === b.B;
5219
5221
  };
5220
5222
  E.getPointer = function(a) {
5221
- return a.A;
5223
+ return a.B;
5222
5224
  };
5223
5225
  E.getClass = function(a) {
5224
- return a.I;
5226
+ return a.J;
5225
5227
  };
5226
- var S = { buffer: 0, size: 0, M: 0, O: [], L: 0, P: function() {
5227
- if (S.L) {
5228
- for (var a = 0;a < S.O.length; a++)
5229
- E._webidl_free(S.O[a]);
5230
- S.O.length = 0;
5228
+ var S = { buffer: 0, size: 0, N: 0, R: [], M: 0, P: function() {
5229
+ if (S.M) {
5230
+ for (var a = 0;a < S.R.length; a++)
5231
+ E._webidl_free(S.R[a]);
5232
+ S.R.length = 0;
5231
5233
  E._webidl_free(S.buffer);
5232
5234
  S.buffer = 0;
5233
- S.size += S.L;
5234
- S.L = 0;
5235
+ S.size += S.M;
5236
+ S.M = 0;
5235
5237
  }
5236
5238
  S.buffer || (S.size += 128, S.buffer = E._webidl_malloc(S.size), S.buffer || N());
5237
- S.M = 0;
5239
+ S.N = 0;
5238
5240
  }, alloc: function(a, b) {
5239
5241
  S.buffer || N();
5240
5242
  a = a.length * b.BYTES_PER_ELEMENT;
5241
5243
  a = 8 * Math.ceil(a / 8);
5242
- S.M + a >= S.size ? (0 < a || N(), S.L += a, b = E._webidl_malloc(a), S.O.push(b)) : (b = S.buffer + S.M, S.M += a);
5244
+ S.N + a >= S.size ? (0 < a || N(), S.M += a, b = E._webidl_malloc(a), S.R.push(b)) : (b = S.buffer + S.N, S.N += a);
5243
5245
  return b;
5244
5246
  } };
5245
- function ab2(a) {
5247
+ function T(a) {
5246
5248
  if (typeof a === "string") {
5247
5249
  for (var b = 0, c = 0;c < a.length; ++c) {
5248
5250
  var d = a.charCodeAt(c);
@@ -5253,119 +5255,129 @@ var require_cld2 = __commonJS((exports, module) => {
5253
5255
  c = 0;
5254
5256
  if (0 < d) {
5255
5257
  d = c + d - 1;
5256
- for (var f = 0;f < a.length; ++f) {
5257
- var h = a.codePointAt(f);
5258
- if (127 >= h) {
5258
+ for (var e = 0;e < a.length; ++e) {
5259
+ var g = a.codePointAt(e);
5260
+ if (127 >= g) {
5259
5261
  if (c >= d)
5260
5262
  break;
5261
- b[c++] = h;
5262
- } else if (2047 >= h) {
5263
+ b[c++] = g;
5264
+ } else if (2047 >= g) {
5263
5265
  if (c + 1 >= d)
5264
5266
  break;
5265
- b[c++] = 192 | h >> 6;
5266
- b[c++] = 128 | h & 63;
5267
- } else if (65535 >= h) {
5267
+ b[c++] = 192 | g >> 6;
5268
+ b[c++] = 128 | g & 63;
5269
+ } else if (65535 >= g) {
5268
5270
  if (c + 2 >= d)
5269
5271
  break;
5270
- b[c++] = 224 | h >> 12;
5271
- b[c++] = 128 | h >> 6 & 63;
5272
- b[c++] = 128 | h & 63;
5272
+ b[c++] = 224 | g >> 12;
5273
+ b[c++] = 128 | g >> 6 & 63;
5274
+ b[c++] = 128 | g & 63;
5273
5275
  } else {
5274
5276
  if (c + 3 >= d)
5275
5277
  break;
5276
- b[c++] = 240 | h >> 18;
5277
- b[c++] = 128 | h >> 12 & 63;
5278
- b[c++] = 128 | h >> 6 & 63;
5279
- b[c++] = 128 | h & 63;
5280
- f++;
5278
+ b[c++] = 240 | g >> 18;
5279
+ b[c++] = 128 | g >> 12 & 63;
5280
+ b[c++] = 128 | g >> 6 & 63;
5281
+ b[c++] = 128 | g & 63;
5282
+ e++;
5281
5283
  }
5282
5284
  }
5283
5285
  b[c] = 0;
5284
5286
  }
5285
- a = S.alloc(b, va);
5287
+ a = S.alloc(b, wa);
5286
5288
  for (c = 0;c < b.length; c++)
5287
- va[a + c] = b[c];
5289
+ wa[a + c] = b[c];
5288
5290
  return a;
5289
5291
  }
5290
5292
  return a;
5291
5293
  }
5292
- function T() {
5293
- throw "cannot construct a Language, no constructor in IDL";
5294
- }
5295
- T.prototype = Object.create(Q.prototype);
5296
- T.prototype.constructor = T;
5297
- T.prototype.I = T;
5298
- T.K = {};
5299
- E.Language = T;
5300
- T.prototype.getLanguageCode = function() {
5301
- return La(Na(this.A));
5302
- };
5303
- T.prototype.__destroy__ = function() {
5304
- Oa(this.A);
5305
- };
5306
5294
  function U() {
5307
- throw "cannot construct a VoidPtr, no constructor in IDL";
5295
+ throw "cannot construct a Language, no constructor in IDL";
5308
5296
  }
5309
5297
  U.prototype = Object.create(Q.prototype);
5310
5298
  U.prototype.constructor = U;
5311
- U.prototype.I = U;
5312
- U.K = {};
5313
- E.VoidPtr = U;
5299
+ U.prototype.J = U;
5300
+ U.L = {};
5301
+ E.Language = U;
5302
+ U.prototype.getLanguageCode = function() {
5303
+ return Ma(Oa(this.B));
5304
+ };
5314
5305
  U.prototype.__destroy__ = function() {
5315
- Pa(this.A);
5306
+ Pa(this.B);
5316
5307
  };
5317
5308
  function V() {
5318
- throw "cannot construct a LanguageGuess, no constructor in IDL";
5309
+ throw "cannot construct a VoidPtr, no constructor in IDL";
5319
5310
  }
5320
- V.prototype = Object.create(T.prototype);
5311
+ V.prototype = Object.create(Q.prototype);
5321
5312
  V.prototype.constructor = V;
5322
- V.prototype.I = V;
5323
- V.K = {};
5324
- E.LanguageGuess = V;
5325
- V.prototype.getPercent = function() {
5326
- return Qa(this.A);
5327
- };
5328
- V.prototype.getLanguageCode = function() {
5329
- return La(Ra(this.A));
5330
- };
5313
+ V.prototype.J = V;
5314
+ V.L = {};
5315
+ E.VoidPtr = V;
5331
5316
  V.prototype.__destroy__ = function() {
5332
- Sa(this.A);
5317
+ Qa(this.B);
5333
5318
  };
5334
5319
  function W() {
5335
- throw "cannot construct a LanguageInfo, no constructor in IDL";
5320
+ throw "cannot construct a LanguageGuess, no constructor in IDL";
5336
5321
  }
5337
- W.prototype = Object.create(T.prototype);
5322
+ W.prototype = Object.create(U.prototype);
5338
5323
  W.prototype.constructor = W;
5339
- W.prototype.I = W;
5340
- W.K = {};
5341
- E.LanguageInfo = W;
5342
- W.prototype.detectLanguage = function(a, b, c, d, f) {
5324
+ W.prototype.J = W;
5325
+ W.L = {};
5326
+ E.LanguageGuess = W;
5327
+ W.prototype.getPercent = function() {
5328
+ return Ra(this.B);
5329
+ };
5330
+ W.prototype.getLanguageCode = function() {
5331
+ return Ma(Sa(this.B));
5332
+ };
5333
+ W.prototype.__destroy__ = function() {
5334
+ Ta(this.B);
5335
+ };
5336
+ function X() {
5337
+ throw "cannot construct a LanguageInfo, no constructor in IDL";
5338
+ }
5339
+ X.prototype = Object.create(U.prototype);
5340
+ X.prototype.constructor = X;
5341
+ X.prototype.J = X;
5342
+ X.L = {};
5343
+ E.LanguageInfo = X;
5344
+ X.prototype.detectLanguageWithLength = function(a, b, c, d, e, g) {
5345
+ S.P();
5346
+ a = a && typeof a === "object" ? a.B : T(a);
5347
+ b && typeof b === "object" && (b = b.B);
5348
+ c && typeof c === "object" && (c = c.B);
5349
+ d = d && typeof d === "object" ? d.B : T(d);
5350
+ e && typeof e === "object" && (e = e.B);
5351
+ g = g && typeof g === "object" ? g.B : T(g);
5352
+ return d === undefined ? R(Ua(a, b, c), X) : e === undefined ? R(_emscripten_bind_LanguageInfo_detectLanguageWithLength_4(a, b, c, d), X) : g === undefined ? R(_emscripten_bind_LanguageInfo_detectLanguageWithLength_5(a, b, c, d, e), X) : R(Va(a, b, c, d, e, g), X);
5353
+ };
5354
+ X.prototype.detectLanguage = function(a, b, c, d, e) {
5343
5355
  S.P();
5344
- a = a && typeof a === "object" ? a.A : ab2(a);
5345
- b && typeof b === "object" && (b = b.A);
5346
- c = c && typeof c === "object" ? c.A : ab2(c);
5347
- d && typeof d === "object" && (d = d.A);
5348
- f = f && typeof f === "object" ? f.A : ab2(f);
5349
- return c === undefined ? R(Ta(a, b), W) : d === undefined ? R(_emscripten_bind_LanguageInfo_detectLanguage_3(a, b, c), W) : f === undefined ? R(_emscripten_bind_LanguageInfo_detectLanguage_4(a, b, c, d), W) : R(Ua(a, b, c, d, f), W);
5356
+ a = a && typeof a === "object" ? a.B : T(a);
5357
+ b && typeof b === "object" && (b = b.B);
5358
+ c = c && typeof c === "object" ? c.B : T(c);
5359
+ d && typeof d === "object" && (d = d.B);
5360
+ e = e && typeof e === "object" ? e.B : T(e);
5361
+ return c === undefined ? R(Wa(a, b), X) : d === undefined ? R(_emscripten_bind_LanguageInfo_detectLanguage_3(a, b, c), X) : e === undefined ? R(_emscripten_bind_LanguageInfo_detectLanguage_4(a, b, c, d), X) : R(Xa(a, b, c, d, e), X);
5350
5362
  };
5351
- W.prototype.getIsReliable = function() {
5352
- return !!Va(this.A);
5363
+ X.prototype.getIsReliable = function() {
5364
+ return !!Ya(this.B);
5353
5365
  };
5354
- W.prototype.getLanguageCode = function() {
5355
- return La(Wa(this.A));
5366
+ X.prototype.getLanguageCode = function() {
5367
+ return Ma(Za(this.B));
5356
5368
  };
5357
- W.prototype.get_languages = W.prototype.Z = function(a) {
5358
- var b = this.A;
5359
- a && typeof a === "object" && (a = a.A);
5360
- return R(Xa(b, a), V);
5369
+ X.prototype.get_languages = X.prototype.$ = function(a) {
5370
+ var b = this.B;
5371
+ a && typeof a === "object" && (a = a.B);
5372
+ return R($a(b, a), W);
5361
5373
  };
5362
- Object.defineProperty(W.prototype, "languages", { get: W.prototype.Z });
5363
- W.prototype.__destroy__ = function() {
5364
- Ya(this.A);
5374
+ Object.defineProperty(X.prototype, "languages", { get: X.prototype.$ });
5375
+ X.prototype.__destroy__ = function() {
5376
+ ab2(this.B);
5365
5377
  };
5366
5378
  S.alloc = S.alloc.bind(S);
5367
5379
  S.P = S.P.bind(S);
5368
- for (var X = {
5380
+ for (var Y = {
5369
5381
  ISO_8859_1: 0,
5370
5382
  ISO_8859_2: 1,
5371
5383
  ISO_8859_3: 2,
@@ -5466,14 +5478,14 @@ var require_cld2 = __commonJS((exports, module) => {
5466
5478
  KDDI_ISO_2022_JP: 73,
5467
5479
  ISO_2022_JP: 73,
5468
5480
  SOFTBANK_ISO_2022_JP: 74
5469
- }, bb = g(Object.keys(X)), cb = bb.next();!cb.done; cb = bb.next()) {
5470
- var db = cb.value;
5471
- db.includes("_") && (X[db.replace(/_/g, "")] = X[db]);
5472
- }
5473
- E.Encodings = X;
5474
- wa ? moduleRtn = E : moduleRtn = new Promise(function(a, b) {
5475
- ta = a;
5476
- ua = b;
5481
+ }, db = h(Object.keys(Y)), eb = db.next();!eb.done; eb = db.next()) {
5482
+ var fb = eb.value;
5483
+ fb.includes("_") && (Y[fb.replace(/_/g, "")] = Y[fb]);
5484
+ }
5485
+ E.Encodings = Y;
5486
+ xa ? moduleRtn = E : moduleRtn = new Promise(function(a, b) {
5487
+ ua = a;
5488
+ va = b;
5477
5489
  });
5478
5490
  return moduleRtn;
5479
5491
  };
@@ -5486,7 +5498,7 @@ var require_cld2 = __commonJS((exports, module) => {
5486
5498
  });
5487
5499
 
5488
5500
  // src/lib/cld2/cld2.wasm
5489
- var cld2_default = "./cld2-8mh0n580.wasm";
5501
+ var cld2_default = "./cld2-22jkf0ae.wasm";
5490
5502
  var init_cld2 = () => {};
5491
5503
 
5492
5504
  // src/services/detector.ts
@@ -5500,6 +5512,52 @@ __export(exports_detector, {
5500
5512
  import path5 from "path";
5501
5513
  import { fileURLToPath } from "url";
5502
5514
  import { readFile } from "fs/promises";
5515
+ function sanitizeInput(text) {
5516
+ let sanitized = text.replace(/\0/g, "");
5517
+ sanitized = sanitized.replace(/[\x01-\x08\x0B-\x0C\x0E-\x1F\x7F]/g, "");
5518
+ return sanitized;
5519
+ }
5520
+ function truncateByUtf8Bytes(text, maxBytes) {
5521
+ const encoder = new TextEncoder;
5522
+ const bytes = encoder.encode(text);
5523
+ if (bytes.length <= maxBytes) {
5524
+ return text;
5525
+ }
5526
+ let truncated = bytes.slice(0, maxBytes);
5527
+ while (truncated.length > 0) {
5528
+ try {
5529
+ return new TextDecoder("utf-8", { fatal: true }).decode(truncated);
5530
+ } catch {
5531
+ truncated = truncated.slice(0, -1);
5532
+ }
5533
+ }
5534
+ return "";
5535
+ }
5536
+ function validateAndSanitizeInput(text, maxBytes = MAX_DETECTION_BYTES) {
5537
+ if (!text || text.length === 0) {
5538
+ return text;
5539
+ }
5540
+ const sanitized = sanitizeInput(text);
5541
+ const truncated = truncateByUtf8Bytes(sanitized, maxBytes);
5542
+ if (truncated !== text) {
5543
+ debug(`Input sanitized/truncated: ${text.length} → ${truncated.length} chars (limit: ${maxBytes})`);
5544
+ }
5545
+ return truncated;
5546
+ }
5547
+ function handleCldError(error2, context) {
5548
+ const errStr = error2.toString();
5549
+ if (errStr.includes("RuntimeError") || errStr.includes("memory access")) {
5550
+ error("CLD2 crashed (RuntimeError), resetting module", {
5551
+ error: errStr,
5552
+ stack: error2.stack,
5553
+ textLength: context?.text?.length,
5554
+ textPreview: context?.text?.substring(0, 100),
5555
+ operation: context?.operation
5556
+ });
5557
+ cldModule = null;
5558
+ initPromise = null;
5559
+ }
5560
+ }
5503
5561
  async function initCLD() {
5504
5562
  if (cldModule)
5505
5563
  return;
@@ -5517,8 +5575,13 @@ async function initCLD() {
5517
5575
  printErr: (msg) => error(`[CLD2 Error]: ${msg}`),
5518
5576
  wasmBinary: wasmBuffer
5519
5577
  });
5520
- if (module.LanguageInfo && module.LanguageInfo.prototype && module.LanguageInfo.prototype.detectLanguage) {
5521
- module.LanguageInfo.detectLanguage = module.LanguageInfo.prototype.detectLanguage;
5578
+ if (module.LanguageInfo && module.LanguageInfo.prototype) {
5579
+ if (module.LanguageInfo.prototype.detectLanguage) {
5580
+ module.LanguageInfo.detectLanguage = module.LanguageInfo.prototype.detectLanguage;
5581
+ }
5582
+ if (module.LanguageInfo.prototype.detectLanguageWithLength) {
5583
+ module.LanguageInfo.detectLanguageWithLength = module.LanguageInfo.prototype.detectLanguageWithLength;
5584
+ }
5522
5585
  }
5523
5586
  cldModule = module;
5524
5587
  debug("CLD2 language detector initialized");
@@ -5529,15 +5592,25 @@ async function initCLD() {
5529
5592
  })();
5530
5593
  return initPromise;
5531
5594
  }
5532
- function detectLanguageWithCLD(text, isHTML = false) {
5595
+ function detectLanguageWithCLD(text, isHTML = false, maxBytes = MAX_DETECTION_BYTES) {
5533
5596
  if (!cldModule) {
5534
5597
  throw new Error("CLD2 module not initialized");
5535
5598
  }
5599
+ const validatedText = validateAndSanitizeInput(text, maxBytes);
5600
+ if (!validatedText) {
5601
+ warn("Input validation resulted in empty text");
5602
+ return {
5603
+ language: "un",
5604
+ confident: false,
5605
+ languages: [],
5606
+ percentScore: 0
5607
+ };
5608
+ }
5536
5609
  const LanguageInfo = cldModule.LanguageInfo;
5537
5610
  if (!LanguageInfo || !LanguageInfo.detectLanguage) {
5538
5611
  throw new Error("CLD2 LanguageInfo or detectLanguage not available");
5539
5612
  }
5540
- const result = LanguageInfo.detectLanguage(text, !isHTML);
5613
+ const result = LanguageInfo.detectLanguage(validatedText, !isHTML);
5541
5614
  const languages = Array(3).fill(0).map((_, i) => {
5542
5615
  const lang = result.get_languages(i);
5543
5616
  return {
@@ -5562,26 +5635,27 @@ function bcp47Normalize(code) {
5562
5635
  return code.toLowerCase();
5563
5636
  }
5564
5637
  }
5565
- async function detectLanguage(text) {
5638
+ async function detectLanguage(text, maxBytes = MAX_DETECTION_BYTES) {
5566
5639
  if (!text) {
5567
5640
  return "";
5568
5641
  }
5569
5642
  await initCLD();
5570
5643
  try {
5571
- const result = detectLanguageWithCLD(text);
5644
+ const result = detectLanguageWithCLD(text, false, maxBytes);
5572
5645
  return bcp47Normalize(result.language);
5573
5646
  } catch (error2) {
5574
5647
  warn(`Language detection failed: ${error2}`);
5648
+ handleCldError(error2, { text, operation: "detectLanguage" });
5575
5649
  return "en";
5576
5650
  }
5577
5651
  }
5578
- async function detectLanguageWithConfidence(text, minConfidence = DEFAULT_CONFIDENCE_THRESHOLD) {
5652
+ async function detectLanguageWithConfidence(text, minConfidence = DEFAULT_CONFIDENCE_THRESHOLD, maxBytes = MAX_DETECTION_BYTES) {
5579
5653
  if (!text) {
5580
5654
  return { language: "", confidence: 0 };
5581
5655
  }
5582
5656
  await initCLD();
5583
5657
  try {
5584
- const result = detectLanguageWithCLD(text);
5658
+ const result = detectLanguageWithCLD(text, false, maxBytes);
5585
5659
  const confidence = result.percentScore / 100;
5586
5660
  if (confidence < minConfidence) {
5587
5661
  return { language: "", confidence };
@@ -5592,6 +5666,7 @@ async function detectLanguageWithConfidence(text, minConfidence = DEFAULT_CONFID
5592
5666
  };
5593
5667
  } catch (error2) {
5594
5668
  warn(`Language detection with confidence failed: ${error2}`);
5669
+ handleCldError(error2, { text, operation: "detectLanguageWithConfidence" });
5595
5670
  return { language: "en", confidence: 0 };
5596
5671
  }
5597
5672
  }
@@ -5611,6 +5686,28 @@ function hasMixedScripts(text) {
5611
5686
  }
5612
5687
  return false;
5613
5688
  }
5689
+ function getScriptType(text) {
5690
+ let hasCJK = false;
5691
+ let hasLatin = false;
5692
+ for (const char of text) {
5693
+ const code = char.charCodeAt(0);
5694
+ if (code >= 19968 && code <= 40959 || code >= 12352 && code <= 12447 || code >= 12448 && code <= 12543 || code >= 44032 && code <= 55215) {
5695
+ hasCJK = true;
5696
+ } else if (code >= 65 && code <= 90 || code >= 97 && code <= 122) {
5697
+ hasLatin = true;
5698
+ }
5699
+ if (hasCJK && hasLatin)
5700
+ return "Mixed";
5701
+ }
5702
+ if (hasCJK)
5703
+ return "CJK";
5704
+ if (hasLatin)
5705
+ return "Latin";
5706
+ return "Other";
5707
+ }
5708
+ function isCJKLanguage(lang) {
5709
+ return ["zh", "zh-Hans", "zh-Hant", "ja", "ko"].includes(lang) || lang.startsWith("zh-");
5710
+ }
5614
5711
  async function detectMultipleLanguages(text) {
5615
5712
  return detectMultipleLanguagesWithThreshold(text, DEFAULT_CONFIDENCE_THRESHOLD);
5616
5713
  }
@@ -5619,7 +5716,7 @@ async function detectMultipleLanguagesWithThreshold(text, threshold) {
5619
5716
  return [];
5620
5717
  }
5621
5718
  await initCLD();
5622
- const fallbackLang = await detectLanguage(text);
5719
+ const fallbackLang = await detectLanguage(text, MAX_FALLBACK_DETECTION_BYTES);
5623
5720
  const effectiveFallback = fallbackLang || "en";
5624
5721
  if (!hasMixedScripts(text)) {
5625
5722
  debug(`DetectMultipleLanguages: no mixed scripts, using single language: ${effectiveFallback}`);
@@ -5637,18 +5734,43 @@ async function detectMultipleLanguagesWithThreshold(text, threshold) {
5637
5734
  const sentenceSegments = Array.from(segmenterAny.segment(text));
5638
5735
  for (const { segment, index } of sentenceSegments) {
5639
5736
  try {
5737
+ await initCLD();
5640
5738
  const result = detectLanguageWithCLD(segment);
5641
5739
  const detectedLang = bcp47Normalize(result.language);
5642
5740
  const confidence = result.percentScore / 100;
5741
+ const scriptType = getScriptType(segment);
5742
+ let finalLang = effectiveFallback;
5743
+ let usedLogic = "fallback";
5744
+ if (confidence >= threshold) {
5745
+ finalLang = detectedLang;
5746
+ usedLogic = "confidence";
5747
+ } else {
5748
+ if (scriptType === "Latin" && isCJKLanguage(effectiveFallback)) {
5749
+ if (detectedLang && detectedLang !== "un") {
5750
+ finalLang = detectedLang;
5751
+ usedLogic = "script-override-latin";
5752
+ } else {
5753
+ finalLang = "en";
5754
+ usedLogic = "script-override-en";
5755
+ }
5756
+ } else if (scriptType === "CJK" && !isCJKLanguage(effectiveFallback)) {
5757
+ if (detectedLang && detectedLang !== "un") {
5758
+ finalLang = detectedLang;
5759
+ usedLogic = "script-override-cjk";
5760
+ }
5761
+ }
5762
+ }
5763
+ debug(`Segment[${segments.length}]: "${segment.replace(/\n/g, "\\n")}" -> lang=${detectedLang}, conf=${confidence.toFixed(2)}, script=${scriptType}, final=${finalLang} (${usedLogic})`);
5643
5764
  segments.push({
5644
5765
  text: segment,
5645
- language: confidence >= threshold ? detectedLang : effectiveFallback,
5766
+ language: finalLang,
5646
5767
  start: index,
5647
5768
  end: index + segment.length,
5648
5769
  confidence
5649
5770
  });
5650
5771
  } catch (error2) {
5651
5772
  warn(`Failed to detect language for segment: ${error2}`);
5773
+ handleCldError(error2, { text: segment, operation: "detectMultipleLanguages" });
5652
5774
  segments.push({
5653
5775
  text: segment,
5654
5776
  language: effectiveFallback,
@@ -5708,7 +5830,7 @@ function limitLanguages(segments, originalText, maxLangs) {
5708
5830
  debug(`limitLanguages: reduced to ${maxLangs} languages, ${result.length} segments`);
5709
5831
  return result;
5710
5832
  }
5711
- var import_cld2, DEFAULT_CONFIDENCE_THRESHOLD = 0.5, MAXIMUM_LANGUAGES_IN_ONE_TEXT = 2, cldModule = null, initPromise = null;
5833
+ var import_cld2, DEFAULT_CONFIDENCE_THRESHOLD = 0.5, MAXIMUM_LANGUAGES_IN_ONE_TEXT = 2, MAX_DETECTION_BYTES = 512, MAX_FALLBACK_DETECTION_BYTES = 1024, cldModule = null, initPromise = null;
5712
5834
  var init_detector = __esm(() => {
5713
5835
  init_cld2();
5714
5836
  init_logger();
@@ -7110,7 +7232,7 @@ var init_services = __esm(() => {
7110
7232
  });
7111
7233
 
7112
7234
  // src/utils/lang-alias.ts
7113
- function normalizeLanguageCode(code) {
7235
+ function NormalizeLanguageCode(code) {
7114
7236
  if (!code)
7115
7237
  return "";
7116
7238
  const normalized = code.toLowerCase().replace(/_/g, "-");
@@ -7209,10 +7331,10 @@ var init_memory = () => {};
7209
7331
  // src/utils/index.ts
7210
7332
  var exports_utils = {};
7211
7333
  __export(exports_utils, {
7212
- normalizeLanguageCode: () => normalizeLanguageCode,
7213
7334
  getLargestVersion: () => getLargestVersion,
7214
7335
  getFreePort: () => getFreePort,
7215
- getAvailableMemoryMB: () => getAvailableMemoryMB
7336
+ getAvailableMemoryMB: () => getAvailableMemoryMB,
7337
+ NormalizeLanguageCode: () => NormalizeLanguageCode
7216
7338
  });
7217
7339
  var init_utils = __esm(() => {
7218
7340
  init_lang_alias();
@@ -7237,16 +7359,16 @@ class MTran {
7237
7359
  await initRecords();
7238
7360
  }
7239
7361
  async translate(from, to, text, html = false) {
7240
- const normalizedFrom = from === "auto" ? "auto" : normalizeLanguageCode(from);
7241
- const normalizedTo = normalizeLanguageCode(to);
7362
+ const normalizedFrom = from === "auto" ? "auto" : NormalizeLanguageCode(from);
7363
+ const normalizedTo = NormalizeLanguageCode(to);
7242
7364
  return translateWithPivot(normalizedFrom, normalizedTo, text, html);
7243
7365
  }
7244
7366
  async detect(text) {
7245
7367
  return detectLanguage(text);
7246
7368
  }
7247
7369
  async downloadModel(from, to) {
7248
- const normalizedFrom = normalizeLanguageCode(from);
7249
- const normalizedTo = normalizeLanguageCode(to);
7370
+ const normalizedFrom = NormalizeLanguageCode(from);
7371
+ const normalizedTo = NormalizeLanguageCode(to);
7250
7372
  await downloadModel(normalizedTo, normalizedFrom);
7251
7373
  }
7252
7374
  async close() {
@@ -7263,7 +7385,6 @@ init_models();
7263
7385
  init_utils();
7264
7386
  export {
7265
7387
  setConfig,
7266
- normalizeLanguageCode,
7267
7388
  initRecords,
7268
7389
  hasLanguagePair,
7269
7390
  globalRecords,
@@ -7275,8 +7396,9 @@ export {
7275
7396
  getConfig,
7276
7397
  getAvailableMemoryMB,
7277
7398
  downloadModel,
7399
+ NormalizeLanguageCode,
7278
7400
  MTran
7279
7401
  };
7280
7402
 
7281
- //# debugId=AE42296278362FEE64756E2164756E21
7403
+ //# debugId=9F381F630EAFB36264756E2164756E21
7282
7404
  //# sourceMappingURL=index.js.map