mtranserver 4.0.18 → 4.0.20

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/main.js CHANGED
@@ -46,7 +46,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
46
46
 
47
47
  // node_modules/swagger-ui-dist/absolute-path.js
48
48
  var require_absolute_path = __commonJS((exports, module) => {
49
- var __dirname = "/home/xxnuo/projects/MTran/MTranServer/node_modules/swagger-ui-dist";
49
+ var __dirname = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/node_modules/swagger-ui-dist";
50
50
  var getAbsoluteFSPath = function() {
51
51
  if (typeof module !== "undefined" && module.exports) {
52
52
  return __require("path").resolve(__dirname);
@@ -437,7 +437,7 @@ function getConfig() {
437
437
  logConsole: getBool("--log-console", "MT_LOG_CONSOLE", true),
438
438
  logRequests: getBool("--log-requests", "MT_LOG_REQUESTS", false),
439
439
  checkUpdate: getBool("--check-update", "MT_CHECK_UPDATE", true),
440
- cacheSize: getInt("--cache-size", "MT_CACHE_SIZE", 0)
440
+ cacheSize: getInt("--cache-size", "MT_CACHE_SIZE", 1000)
441
441
  };
442
442
  return globalConfig;
443
443
  }
@@ -1357,7 +1357,7 @@ function getLanguagePairs() {
1357
1357
  return [];
1358
1358
  const pairs = new Set;
1359
1359
  for (const record of globalRecords.data) {
1360
- pairs.add(`${record.sourceLanguage}-${record.targetLanguage}`);
1360
+ pairs.add(`${record.sourceLanguage}_${record.targetLanguage}`);
1361
1361
  }
1362
1362
  return Array.from(pairs);
1363
1363
  }
@@ -1774,10 +1774,10 @@ class TranslationEngine {
1774
1774
  return chunks;
1775
1775
  }
1776
1776
  _hideEmojis(text) {
1777
- const emojiRegex = /(\p{Emoji_Presentation}|\p{Extended_Pictographic})/gu;
1777
+ const emojiRegex = /(\p{RI}\p{RI}|\p{Emoji_Presentation}|\p{Extended_Pictographic})/gu;
1778
1778
  const replacements = [];
1779
1779
  const cleanText = text.replace(emojiRegex, (match) => {
1780
- const placeholder = `[EE${replacements.length}]`;
1780
+ const placeholder = `<e${replacements.length}>`;
1781
1781
  replacements.push({ original: match, placeholder });
1782
1782
  return placeholder;
1783
1783
  });
@@ -4706,23 +4706,23 @@ var init_bergamot_translator = () => {};
4706
4706
 
4707
4707
  // src/lib/cld2/cld2.js
4708
4708
  var require_cld2 = __commonJS((exports, module) => {
4709
- var __dirname = "/home/xxnuo/projects/MTran/MTranServer/src/lib/cld2", __filename = "/home/xxnuo/projects/MTran/MTranServer/src/lib/cld2/cld2.js";
4709
+ var __dirname = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/src/lib/cld2", __filename = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/src/lib/cld2/cld2.js";
4710
4710
  var loadCLD2 = (() => {
4711
4711
  var _scriptName = globalThis.document?.currentScript?.src;
4712
4712
  return async function(moduleArg = {}) {
4713
4713
  var moduleRtn;
4714
- function aa(a) {
4714
+ function ba(a) {
4715
4715
  var b = 0;
4716
4716
  return function() {
4717
4717
  return b < a.length ? { done: false, value: a[b++] } : { done: true };
4718
4718
  };
4719
4719
  }
4720
- function g(a) {
4720
+ function h(a) {
4721
4721
  var b = typeof Symbol != "undefined" && Symbol.iterator && a[Symbol.iterator];
4722
4722
  if (b)
4723
4723
  return b.call(a);
4724
4724
  if (typeof a.length == "number")
4725
- return { next: aa(a) };
4725
+ return { next: ba(a) };
4726
4726
  throw Error(String(a) + " is not an iterable or ArrayLike");
4727
4727
  }
4728
4728
  var l = typeof Object.defineProperties == "function" ? Object.defineProperty : function(a, b, c) {
@@ -4731,7 +4731,7 @@ var require_cld2 = __commonJS((exports, module) => {
4731
4731
  a[b] = c.value;
4732
4732
  return a;
4733
4733
  };
4734
- function ba(a) {
4734
+ function ca(a) {
4735
4735
  a = [typeof globalThis == "object" && globalThis, a, typeof window == "object" && window, typeof self == "object" && self, typeof global == "object" && global];
4736
4736
  for (var b = 0;b < a.length; ++b) {
4737
4737
  var c = a[b];
@@ -4740,17 +4740,17 @@ var require_cld2 = __commonJS((exports, module) => {
4740
4740
  }
4741
4741
  throw Error("Cannot find global object");
4742
4742
  }
4743
- var p = ba(this);
4743
+ var n = ca(this);
4744
4744
  function r(a, b) {
4745
4745
  if (b)
4746
4746
  a: {
4747
- var c = p;
4747
+ var c = n;
4748
4748
  a = a.split(".");
4749
4749
  for (var d = 0;d < a.length - 1; d++) {
4750
- var f = a[d];
4751
- if (!(f in c))
4750
+ var e = a[d];
4751
+ if (!(e in c))
4752
4752
  break a;
4753
- c = c[f];
4753
+ c = c[e];
4754
4754
  }
4755
4755
  a = a[a.length - 1];
4756
4756
  d = c[a];
@@ -4759,138 +4759,138 @@ var require_cld2 = __commonJS((exports, module) => {
4759
4759
  }
4760
4760
  }
4761
4761
  function t() {
4762
- this.G = false;
4763
- this.B = null;
4764
- this.C = undefined;
4765
- this.v = 1;
4766
- this.J = this.F = 0;
4767
- this.D = null;
4762
+ this.H = false;
4763
+ this.C = null;
4764
+ this.D = undefined;
4765
+ this.A = 1;
4766
+ this.K = this.G = 0;
4767
+ this.F = null;
4768
4768
  }
4769
4769
  function u(a) {
4770
- if (a.G)
4770
+ if (a.H)
4771
4771
  throw new TypeError("Generator is already running");
4772
- a.G = true;
4772
+ a.H = true;
4773
4773
  }
4774
- t.prototype.H = function(a) {
4775
- this.C = a;
4774
+ t.prototype.I = function(a) {
4775
+ this.D = a;
4776
4776
  };
4777
4777
  function v(a, b) {
4778
- a.D = { R: b, $: true };
4779
- a.v = a.F || a.J;
4778
+ a.F = { S: b, aa: true };
4779
+ a.A = a.G || a.K;
4780
4780
  }
4781
4781
  t.prototype.return = function(a) {
4782
- this.D = { return: a };
4783
- this.v = this.J;
4782
+ this.F = { return: a };
4783
+ this.A = this.K;
4784
4784
  };
4785
- function x(a, b, c) {
4786
- a.v = c;
4785
+ function w(a, b, c) {
4786
+ a.A = c;
4787
4787
  return { value: b };
4788
4788
  }
4789
4789
  function y(a) {
4790
- a.F = 0;
4791
- var b = a.D.R;
4792
- a.D = null;
4790
+ a.G = 0;
4791
+ var b = a.F.S;
4792
+ a.F = null;
4793
4793
  return b;
4794
4794
  }
4795
- function ca(a) {
4796
- this.v = new t;
4797
- this.B = a;
4795
+ function da(a) {
4796
+ this.A = new t;
4797
+ this.C = a;
4798
4798
  }
4799
- function da(a, b) {
4800
- u(a.v);
4801
- var c = a.v.B;
4799
+ function ea(a, b) {
4800
+ u(a.A);
4801
+ var c = a.A.C;
4802
4802
  if (c)
4803
4803
  return z(a, "return" in c ? c["return"] : function(d) {
4804
4804
  return { value: d, done: true };
4805
- }, b, a.v.return);
4806
- a.v.return(b);
4805
+ }, b, a.A.return);
4806
+ a.A.return(b);
4807
4807
  return C(a);
4808
4808
  }
4809
4809
  function z(a, b, c, d) {
4810
4810
  try {
4811
- var f = b.call(a.v.B, c);
4812
- if (!(f instanceof Object))
4813
- throw new TypeError("Iterator result " + f + " is not an object");
4814
- if (!f.done)
4815
- return a.v.G = false, f;
4816
- var h = f.value;
4817
- } catch (e) {
4818
- return a.v.B = null, v(a.v, e), C(a);
4819
- }
4820
- a.v.B = null;
4821
- d.call(a.v, h);
4811
+ var e = b.call(a.A.C, c);
4812
+ if (!(e instanceof Object))
4813
+ throw new TypeError("Iterator result " + e + " is not an object");
4814
+ if (!e.done)
4815
+ return a.A.H = false, e;
4816
+ var g = e.value;
4817
+ } catch (f) {
4818
+ return a.A.C = null, v(a.A, f), C(a);
4819
+ }
4820
+ a.A.C = null;
4821
+ d.call(a.A, g);
4822
4822
  return C(a);
4823
4823
  }
4824
4824
  function C(a) {
4825
- for (;a.v.v; )
4825
+ for (;a.A.A; )
4826
4826
  try {
4827
- var b = a.B(a.v);
4827
+ var b = a.C(a.A);
4828
4828
  if (b)
4829
- return a.v.G = false, { value: b.value, done: false };
4829
+ return a.A.H = false, { value: b.value, done: false };
4830
4830
  } catch (c) {
4831
- a.v.C = undefined, v(a.v, c);
4832
- }
4833
- a.v.G = false;
4834
- if (a.v.D) {
4835
- b = a.v.D;
4836
- a.v.D = null;
4837
- if (b.$)
4838
- throw b.R;
4831
+ a.A.D = undefined, v(a.A, c);
4832
+ }
4833
+ a.A.H = false;
4834
+ if (a.A.F) {
4835
+ b = a.A.F;
4836
+ a.A.F = null;
4837
+ if (b.aa)
4838
+ throw b.S;
4839
4839
  return { value: b.return, done: true };
4840
4840
  }
4841
4841
  return { value: undefined, done: true };
4842
4842
  }
4843
- function ea(a) {
4843
+ function fa(a) {
4844
4844
  this.next = function(b) {
4845
- u(a.v);
4846
- a.v.B ? b = z(a, a.v.B.next, b, a.v.H) : (a.v.H(b), b = C(a));
4845
+ u(a.A);
4846
+ a.A.C ? b = z(a, a.A.C.next, b, a.A.I) : (a.A.I(b), b = C(a));
4847
4847
  return b;
4848
4848
  };
4849
4849
  this.throw = function(b) {
4850
- u(a.v);
4851
- a.v.B ? b = z(a, a.v.B["throw"], b, a.v.H) : (v(a.v, b), b = C(a));
4850
+ u(a.A);
4851
+ a.A.C ? b = z(a, a.A.C["throw"], b, a.A.I) : (v(a.A, b), b = C(a));
4852
4852
  return b;
4853
4853
  };
4854
4854
  this.return = function(b) {
4855
- return da(a, b);
4855
+ return ea(a, b);
4856
4856
  };
4857
4857
  this[Symbol.iterator] = function() {
4858
4858
  return this;
4859
4859
  };
4860
4860
  }
4861
- function fa(a) {
4861
+ function ha(a) {
4862
4862
  function b(d) {
4863
4863
  return a.next(d);
4864
4864
  }
4865
4865
  function c(d) {
4866
4866
  return a.throw(d);
4867
4867
  }
4868
- return new Promise(function(d, f) {
4869
- function h(e) {
4870
- e.done ? d(e.value) : Promise.resolve(e.value).then(b, c).then(h, f);
4868
+ return new Promise(function(d, e) {
4869
+ function g(f) {
4870
+ f.done ? d(f.value) : Promise.resolve(f.value).then(b, c).then(g, e);
4871
4871
  }
4872
- h(a.next());
4872
+ g(a.next());
4873
4873
  });
4874
4874
  }
4875
4875
  function D(a) {
4876
- return fa(new ea(new ca(a)));
4876
+ return ha(new fa(new da(a)));
4877
4877
  }
4878
4878
  r("Symbol", function(a) {
4879
- function b(h) {
4879
+ function b(g) {
4880
4880
  if (this instanceof b)
4881
4881
  throw new TypeError("Symbol is not a constructor");
4882
- return new c(d + (h || "") + "_" + f++, h);
4882
+ return new c(d + (g || "") + "_" + e++, g);
4883
4883
  }
4884
- function c(h, e) {
4885
- this.v = h;
4886
- l(this, "description", { configurable: true, writable: true, value: e });
4884
+ function c(g, f) {
4885
+ this.A = g;
4886
+ l(this, "description", { configurable: true, writable: true, value: f });
4887
4887
  }
4888
4888
  if (a)
4889
4889
  return a;
4890
4890
  c.prototype.toString = function() {
4891
- return this.v;
4891
+ return this.A;
4892
4892
  };
4893
- var d = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", f = 0;
4893
+ var d = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", e = 0;
4894
4894
  return b;
4895
4895
  });
4896
4896
  r("Symbol.iterator", function(a) {
@@ -4898,14 +4898,14 @@ var require_cld2 = __commonJS((exports, module) => {
4898
4898
  return a;
4899
4899
  a = Symbol("Symbol.iterator");
4900
4900
  for (var b = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), c = 0;c < b.length; c++) {
4901
- var d = p[b[c]];
4901
+ var d = n[b[c]];
4902
4902
  typeof d === "function" && typeof d.prototype[a] != "function" && l(d.prototype, a, { configurable: true, writable: true, value: function() {
4903
- return ha(aa(this));
4903
+ return ia(ba(this));
4904
4904
  } });
4905
4905
  }
4906
4906
  return a;
4907
4907
  });
4908
- function ha(a) {
4908
+ function ia(a) {
4909
4909
  a = { next: a };
4910
4910
  a[Symbol.iterator] = function() {
4911
4911
  return this;
@@ -4913,82 +4913,82 @@ var require_cld2 = __commonJS((exports, module) => {
4913
4913
  return a;
4914
4914
  }
4915
4915
  r("Promise", function(a) {
4916
- function b(e) {
4917
- this.B = 0;
4918
- this.C = undefined;
4919
- this.v = [];
4920
- this.H = false;
4921
- var k = this.D();
4916
+ function b(f) {
4917
+ this.C = 0;
4918
+ this.D = undefined;
4919
+ this.A = [];
4920
+ this.I = false;
4921
+ var k = this.F();
4922
4922
  try {
4923
- e(k.resolve, k.reject);
4923
+ f(k.resolve, k.reject);
4924
4924
  } catch (m) {
4925
4925
  k.reject(m);
4926
4926
  }
4927
4927
  }
4928
4928
  function c() {
4929
- this.v = null;
4929
+ this.A = null;
4930
4930
  }
4931
- function d(e) {
4932
- return e instanceof b ? e : new b(function(k) {
4933
- k(e);
4931
+ function d(f) {
4932
+ return f instanceof b ? f : new b(function(k) {
4933
+ k(f);
4934
4934
  });
4935
4935
  }
4936
4936
  if (a)
4937
4937
  return a;
4938
- c.prototype.B = function(e) {
4939
- if (this.v == null) {
4940
- this.v = [];
4938
+ c.prototype.C = function(f) {
4939
+ if (this.A == null) {
4940
+ this.A = [];
4941
4941
  var k = this;
4942
- this.C(function() {
4943
- k.F();
4942
+ this.D(function() {
4943
+ k.G();
4944
4944
  });
4945
4945
  }
4946
- this.v.push(e);
4946
+ this.A.push(f);
4947
4947
  };
4948
- var f = p.setTimeout;
4949
- c.prototype.C = function(e) {
4950
- f(e, 0);
4948
+ var e = n.setTimeout;
4949
+ c.prototype.D = function(f) {
4950
+ e(f, 0);
4951
4951
  };
4952
- c.prototype.F = function() {
4953
- for (;this.v && this.v.length; ) {
4954
- var e = this.v;
4955
- this.v = [];
4956
- for (var k = 0;k < e.length; ++k) {
4957
- var m = e[k];
4958
- e[k] = null;
4952
+ c.prototype.G = function() {
4953
+ for (;this.A && this.A.length; ) {
4954
+ var f = this.A;
4955
+ this.A = [];
4956
+ for (var k = 0;k < f.length; ++k) {
4957
+ var m = f[k];
4958
+ f[k] = null;
4959
4959
  try {
4960
4960
  m();
4961
- } catch (n) {
4962
- this.D(n);
4961
+ } catch (p) {
4962
+ this.F(p);
4963
4963
  }
4964
4964
  }
4965
4965
  }
4966
- this.v = null;
4966
+ this.A = null;
4967
4967
  };
4968
- c.prototype.D = function(e) {
4969
- this.C(function() {
4970
- throw e;
4968
+ c.prototype.F = function(f) {
4969
+ this.D(function() {
4970
+ throw f;
4971
4971
  });
4972
4972
  };
4973
- b.prototype.D = function() {
4974
- function e(n) {
4973
+ b.prototype.F = function() {
4974
+ function f(p) {
4975
4975
  return function(q) {
4976
- m || (m = true, n.call(k, q));
4976
+ m || (m = true, p.call(k, q));
4977
4977
  };
4978
4978
  }
4979
4979
  var k = this, m = false;
4980
- return { resolve: e(this.V), reject: e(this.F) };
4980
+ return { resolve: f(this.W), reject: f(this.G) };
4981
4981
  };
4982
- b.prototype.V = function(e) {
4983
- if (e === this)
4984
- this.F(new TypeError("A Promise cannot resolve to itself"));
4985
- else if (e instanceof b)
4986
- this.X(e);
4982
+ b.prototype.W = function(f) {
4983
+ if (f === this)
4984
+ this.G(new TypeError("A Promise cannot resolve to itself"));
4985
+ else if (f instanceof b)
4986
+ this.Y(f);
4987
4987
  else {
4988
4988
  a:
4989
- switch (typeof e) {
4989
+ switch (typeof f) {
4990
4990
  case "object":
4991
- var k = e != null;
4991
+ var k = f != null;
4992
4992
  break a;
4993
4993
  case "function":
4994
4994
  k = true;
@@ -4996,144 +4996,144 @@ var require_cld2 = __commonJS((exports, module) => {
4996
4996
  default:
4997
4997
  k = false;
4998
4998
  }
4999
- k ? this.U(e) : this.G(e);
4999
+ k ? this.V(f) : this.H(f);
5000
5000
  }
5001
5001
  };
5002
- b.prototype.U = function(e) {
5002
+ b.prototype.V = function(f) {
5003
5003
  var k = undefined;
5004
5004
  try {
5005
- k = e.then;
5005
+ k = f.then;
5006
5006
  } catch (m) {
5007
- this.F(m);
5007
+ this.G(m);
5008
5008
  return;
5009
5009
  }
5010
- typeof k == "function" ? this.Y(k, e) : this.G(e);
5010
+ typeof k == "function" ? this.Z(k, f) : this.H(f);
5011
5011
  };
5012
- b.prototype.F = function(e) {
5013
- this.J(2, e);
5012
+ b.prototype.G = function(f) {
5013
+ this.K(2, f);
5014
5014
  };
5015
- b.prototype.G = function(e) {
5016
- this.J(1, e);
5015
+ b.prototype.H = function(f) {
5016
+ this.K(1, f);
5017
5017
  };
5018
- b.prototype.J = function(e, k) {
5019
- if (this.B != 0)
5020
- throw Error("Cannot settle(" + e + ", " + k + "): Promise already settled in state" + this.B);
5021
- this.B = e;
5022
- this.C = k;
5023
- this.B === 2 && this.W();
5024
- this.S();
5018
+ b.prototype.K = function(f, k) {
5019
+ if (this.C != 0)
5020
+ throw Error("Cannot settle(" + f + ", " + k + "): Promise already settled in state" + this.C);
5021
+ this.C = f;
5022
+ this.D = k;
5023
+ this.C === 2 && this.X();
5024
+ this.T();
5025
5025
  };
5026
- b.prototype.W = function() {
5027
- var e = this;
5028
- f(function() {
5029
- if (e.T()) {
5030
- var k = p.console;
5031
- typeof k !== "undefined" && k.error(e.C);
5026
+ b.prototype.X = function() {
5027
+ var f = this;
5028
+ e(function() {
5029
+ if (f.U()) {
5030
+ var k = n.console;
5031
+ typeof k !== "undefined" && k.error(f.D);
5032
5032
  }
5033
5033
  }, 1);
5034
5034
  };
5035
- b.prototype.T = function() {
5036
- if (this.H)
5035
+ b.prototype.U = function() {
5036
+ if (this.I)
5037
5037
  return false;
5038
- var { CustomEvent: e, Event: k, dispatchEvent: m } = p;
5038
+ var { CustomEvent: f, Event: k, dispatchEvent: m } = n;
5039
5039
  if (typeof m === "undefined")
5040
5040
  return true;
5041
- 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));
5042
- e.promise = this;
5043
- e.reason = this.C;
5044
- return m(e);
5041
+ 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));
5042
+ f.promise = this;
5043
+ f.reason = this.D;
5044
+ return m(f);
5045
5045
  };
5046
- b.prototype.S = function() {
5047
- if (this.v != null) {
5048
- for (var e = 0;e < this.v.length; ++e)
5049
- h.B(this.v[e]);
5050
- this.v = null;
5046
+ b.prototype.T = function() {
5047
+ if (this.A != null) {
5048
+ for (var f = 0;f < this.A.length; ++f)
5049
+ g.C(this.A[f]);
5050
+ this.A = null;
5051
5051
  }
5052
5052
  };
5053
- var h = new c;
5054
- b.prototype.X = function(e) {
5055
- var k = this.D();
5056
- e.N(k.resolve, k.reject);
5053
+ var g = new c;
5054
+ b.prototype.Y = function(f) {
5055
+ var k = this.F();
5056
+ f.O(k.resolve, k.reject);
5057
5057
  };
5058
- b.prototype.Y = function(e, k) {
5059
- var m = this.D();
5058
+ b.prototype.Z = function(f, k) {
5059
+ var m = this.F();
5060
5060
  try {
5061
- e.call(k, m.resolve, m.reject);
5062
- } catch (n) {
5063
- m.reject(n);
5061
+ f.call(k, m.resolve, m.reject);
5062
+ } catch (p) {
5063
+ m.reject(p);
5064
5064
  }
5065
5065
  };
5066
- b.prototype.then = function(e, k) {
5067
- function m(w, A) {
5068
- return typeof w == "function" ? function(Y) {
5066
+ b.prototype.then = function(f, k) {
5067
+ function m(x, A) {
5068
+ return typeof x == "function" ? function(Z) {
5069
5069
  try {
5070
- n(w(Y));
5071
- } catch (Z) {
5072
- q(Z);
5070
+ p(x(Z));
5071
+ } catch (aa) {
5072
+ q(aa);
5073
5073
  }
5074
5074
  } : A;
5075
5075
  }
5076
- var n, q, B = new b(function(w, A) {
5077
- n = w;
5076
+ var p, q, B = new b(function(x, A) {
5077
+ p = x;
5078
5078
  q = A;
5079
5079
  });
5080
- this.N(m(e, n), m(k, q));
5080
+ this.O(m(f, p), m(k, q));
5081
5081
  return B;
5082
5082
  };
5083
- b.prototype.catch = function(e) {
5084
- return this.then(undefined, e);
5083
+ b.prototype.catch = function(f) {
5084
+ return this.then(undefined, f);
5085
5085
  };
5086
- b.prototype.N = function(e, k) {
5086
+ b.prototype.O = function(f, k) {
5087
5087
  function m() {
5088
- switch (n.B) {
5088
+ switch (p.C) {
5089
5089
  case 1:
5090
- e(n.C);
5090
+ f(p.D);
5091
5091
  break;
5092
5092
  case 2:
5093
- k(n.C);
5093
+ k(p.D);
5094
5094
  break;
5095
5095
  default:
5096
- throw Error("Unexpected state: " + n.B);
5096
+ throw Error("Unexpected state: " + p.C);
5097
5097
  }
5098
5098
  }
5099
- var n = this;
5100
- this.v == null ? h.B(m) : this.v.push(m);
5101
- this.H = true;
5099
+ var p = this;
5100
+ this.A == null ? g.C(m) : this.A.push(m);
5101
+ this.I = true;
5102
5102
  };
5103
5103
  b.resolve = d;
5104
- b.reject = function(e) {
5104
+ b.reject = function(f) {
5105
5105
  return new b(function(k, m) {
5106
- m(e);
5106
+ m(f);
5107
5107
  });
5108
5108
  };
5109
- b.race = function(e) {
5109
+ b.race = function(f) {
5110
5110
  return new b(function(k, m) {
5111
- for (var n = g(e), q = n.next();!q.done; q = n.next())
5112
- d(q.value).N(k, m);
5111
+ for (var p = h(f), q = p.next();!q.done; q = p.next())
5112
+ d(q.value).O(k, m);
5113
5113
  });
5114
5114
  };
5115
- b.all = function(e) {
5116
- var k = g(e), m = k.next();
5117
- return m.done ? d([]) : new b(function(n, q) {
5118
- function B(Y) {
5119
- return function(Z) {
5120
- w[Y] = Z;
5115
+ b.all = function(f) {
5116
+ var k = h(f), m = k.next();
5117
+ return m.done ? d([]) : new b(function(p, q) {
5118
+ function B(Z) {
5119
+ return function(aa) {
5120
+ x[Z] = aa;
5121
5121
  A--;
5122
- A == 0 && n(w);
5122
+ A == 0 && p(x);
5123
5123
  };
5124
5124
  }
5125
- var w = [], A = 0;
5125
+ var x = [], A = 0;
5126
5126
  do
5127
- w.push(undefined), A++, d(m.value).N(B(w.length - 1), q), m = k.next();
5127
+ x.push(undefined), A++, d(m.value).O(B(x.length - 1), q), m = k.next();
5128
5128
  while (!m.done);
5129
5129
  });
5130
5130
  };
5131
5131
  return b;
5132
5132
  });
5133
5133
  r("globalThis", function(a) {
5134
- return a || p;
5134
+ return a || n;
5135
5135
  });
5136
- function ia(a, b, c) {
5136
+ function ja(a, b, c) {
5137
5137
  if (a == null)
5138
5138
  throw new TypeError("The 'this' value for String.prototype." + c + " must not be null or undefined");
5139
5139
  if (b instanceof RegExp)
@@ -5142,61 +5142,61 @@ var require_cld2 = __commonJS((exports, module) => {
5142
5142
  }
5143
5143
  r("String.prototype.startsWith", function(a) {
5144
5144
  return a ? a : function(b, c) {
5145
- var d = ia(this, b, "startsWith"), f = d.length, h = b.length;
5145
+ var d = ja(this, b, "startsWith"), e = d.length, g = b.length;
5146
5146
  c = Math.max(0, Math.min(c | 0, d.length));
5147
- for (var e = 0;e < h && c < f; )
5148
- if (d[c++] != b[e++])
5147
+ for (var f = 0;f < g && c < e; )
5148
+ if (d[c++] != b[f++])
5149
5149
  return false;
5150
- return e >= h;
5150
+ return f >= g;
5151
5151
  };
5152
5152
  });
5153
5153
  r("String.prototype.codePointAt", function(a) {
5154
5154
  return a ? a : function(b) {
5155
- var c = ia(this, null, "codePointAt"), d = c.length;
5155
+ var c = ja(this, null, "codePointAt"), d = c.length;
5156
5156
  b = Number(b) || 0;
5157
5157
  if (0 <= b && b < d) {
5158
5158
  b |= 0;
5159
- var f = c.charCodeAt(b);
5160
- if (55296 > f || 56319 < f || b + 1 === d)
5161
- return f;
5159
+ var e = c.charCodeAt(b);
5160
+ if (55296 > e || 56319 < e || b + 1 === d)
5161
+ return e;
5162
5162
  b = c.charCodeAt(b + 1);
5163
- return 56320 > b || 57343 < b ? f : 1024 * (f - 55296) + b + 9216;
5163
+ return 56320 > b || 57343 < b ? e : 1024 * (e - 55296) + b + 9216;
5164
5164
  }
5165
5165
  };
5166
5166
  });
5167
- function ja(a, b) {
5167
+ function ka(a, b) {
5168
5168
  a instanceof String && (a += "");
5169
- var c = 0, d = false, f = { next: function() {
5169
+ var c = 0, d = false, e = { next: function() {
5170
5170
  if (!d && c < a.length) {
5171
- var h = c++;
5172
- return { value: b(h, a[h]), done: false };
5171
+ var g = c++;
5172
+ return { value: b(g, a[g]), done: false };
5173
5173
  }
5174
5174
  d = true;
5175
5175
  return { done: true, value: undefined };
5176
5176
  } };
5177
- f[Symbol.iterator] = function() {
5178
- return f;
5177
+ e[Symbol.iterator] = function() {
5178
+ return e;
5179
5179
  };
5180
- return f;
5180
+ return e;
5181
5181
  }
5182
5182
  r("Array.prototype.keys", function(a) {
5183
5183
  return a ? a : function() {
5184
- return ja(this, function(b) {
5184
+ return ka(this, function(b) {
5185
5185
  return b;
5186
5186
  });
5187
5187
  };
5188
5188
  });
5189
- 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";
5190
- typeof __filename != "undefined" ? _scriptName = __filename : la && (_scriptName = self.location.href);
5191
- var F = "", qa, G;
5192
- if (pa) {
5189
+ 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";
5190
+ typeof __filename != "undefined" ? _scriptName = __filename : ma && (_scriptName = self.location.href);
5191
+ var F = "", ra, G;
5192
+ if (qa) {
5193
5193
  var fs5 = __require("fs");
5194
5194
  F = __dirname + "/";
5195
5195
  G = function(a) {
5196
5196
  a = H(a) ? new URL(a) : a;
5197
5197
  return fs5.readFileSync(a);
5198
5198
  };
5199
- qa = function(a) {
5199
+ ra = function(a) {
5200
5200
  var b = b === undefined ? true : b;
5201
5201
  var c;
5202
5202
  return D(function(d) {
@@ -5206,46 +5206,46 @@ var require_cld2 = __commonJS((exports, module) => {
5206
5206
  });
5207
5207
  };
5208
5208
  process.argv.slice(2);
5209
- } else if (ka || la) {
5209
+ } else if (la || ma) {
5210
5210
  try {
5211
5211
  F = new URL(".", _scriptName).href;
5212
5212
  } catch (a) {}
5213
- la && (G = function(a) {
5213
+ ma && (G = function(a) {
5214
5214
  var b = new XMLHttpRequest;
5215
5215
  b.open("GET", a, false);
5216
5216
  b.responseType = "arraybuffer";
5217
5217
  b.send(null);
5218
5218
  return new Uint8Array(b.response);
5219
5219
  });
5220
- qa = function(a) {
5220
+ ra = function(a) {
5221
5221
  var b;
5222
5222
  return D(function(c) {
5223
- if (c.v == 1)
5224
- return H(a) ? c.return(new Promise(function(d, f) {
5225
- var h = new XMLHttpRequest;
5226
- h.open("GET", a, true);
5227
- h.responseType = "arraybuffer";
5228
- h.onload = function() {
5229
- h.status == 200 || h.status == 0 && h.response ? d(h.response) : f(h.status);
5223
+ if (c.A == 1)
5224
+ return H(a) ? c.return(new Promise(function(d, e) {
5225
+ var g = new XMLHttpRequest;
5226
+ g.open("GET", a, true);
5227
+ g.responseType = "arraybuffer";
5228
+ g.onload = function() {
5229
+ g.status == 200 || g.status == 0 && g.response ? d(g.response) : e(g.status);
5230
5230
  };
5231
- h.onerror = f;
5232
- h.send(null);
5233
- })) : x(c, fetch(a, { credentials: "same-origin" }), 2);
5234
- b = c.C;
5231
+ g.onerror = e;
5232
+ g.send(null);
5233
+ })) : w(c, fetch(a, { credentials: "same-origin" }), 2);
5234
+ b = c.D;
5235
5235
  if (b.ok)
5236
5236
  return c.return(b.arrayBuffer());
5237
5237
  throw Error(b.status + " : " + b.url);
5238
5238
  });
5239
5239
  };
5240
5240
  }
5241
- var ra = console.log.bind(console), I = console.error.bind(console), J, sa = false;
5241
+ var sa = console.log.bind(console), I = console.error.bind(console), J, ta = false;
5242
5242
  function H(a) {
5243
5243
  return a.startsWith("file://");
5244
5244
  }
5245
- var ta, ua, va, K, L, wa = false;
5246
- function xa() {
5245
+ var ua, va, wa, K, L, xa = false;
5246
+ function ya() {
5247
5247
  var a = M.buffer;
5248
- va = new Int8Array(a);
5248
+ wa = new Int8Array(a);
5249
5249
  new Int16Array(a);
5250
5250
  K = new Uint8Array(a);
5251
5251
  new Uint16Array(a);
@@ -5261,130 +5261,130 @@ var require_cld2 = __commonJS((exports, module) => {
5261
5261
  (b = E.onAbort) == null || b.call(E, a);
5262
5262
  a = "Aborted(" + a + ")";
5263
5263
  I(a);
5264
- sa = true;
5264
+ ta = true;
5265
5265
  a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
5266
5266
  var c;
5267
- (c = ua) == null || c(a);
5267
+ (c = va) == null || c(a);
5268
5268
  throw a;
5269
5269
  }
5270
5270
  var O;
5271
- function ya(a) {
5271
+ function za(a) {
5272
5272
  var b;
5273
5273
  return D(function(c) {
5274
- switch (c.v) {
5274
+ switch (c.A) {
5275
5275
  case 1:
5276
5276
  if (J) {
5277
- c.v = 2;
5277
+ c.A = 2;
5278
5278
  break;
5279
5279
  }
5280
- c.F = 3;
5281
- return x(c, qa(a), 5);
5280
+ c.G = 3;
5281
+ return w(c, ra(a), 5);
5282
5282
  case 5:
5283
- return b = c.C, c.return(new Uint8Array(b));
5283
+ return b = c.D, c.return(new Uint8Array(b));
5284
5284
  case 3:
5285
5285
  y(c);
5286
5286
  case 2:
5287
5287
  var d = c.return;
5288
5288
  if (a == O && J)
5289
- var f = new Uint8Array(J);
5289
+ var e = new Uint8Array(J);
5290
5290
  else if (G)
5291
- f = G(a);
5291
+ e = G(a);
5292
5292
  else
5293
5293
  throw "both async and sync fetching of the wasm failed";
5294
- return d.call(c, f);
5294
+ return d.call(c, e);
5295
5295
  }
5296
5296
  });
5297
5297
  }
5298
- function za(a, b) {
5299
- var c, d, f;
5300
- return D(function(h) {
5301
- switch (h.v) {
5298
+ function Aa(a, b) {
5299
+ var c, d, e;
5300
+ return D(function(g) {
5301
+ switch (g.A) {
5302
5302
  case 1:
5303
- return h.F = 2, x(h, ya(a), 4);
5303
+ return g.G = 2, w(g, za(a), 4);
5304
5304
  case 4:
5305
- return c = h.C, x(h, WebAssembly.instantiate(c, b), 5);
5305
+ return c = g.D, w(g, WebAssembly.instantiate(c, b), 5);
5306
5306
  case 5:
5307
- return d = h.C, h.return(d);
5307
+ return d = g.D, g.return(d);
5308
5308
  case 2:
5309
- f = y(h), I("failed to asynchronously prepare wasm: " + f), N(f), h.v = 0;
5309
+ e = y(g), I("failed to asynchronously prepare wasm: " + e), N(e), g.A = 0;
5310
5310
  }
5311
5311
  });
5312
5312
  }
5313
- function Aa(a) {
5314
- var b = J, c = O, d, f, h;
5315
- return D(function(e) {
5316
- switch (e.v) {
5313
+ function Ba(a) {
5314
+ var b = J, c = O, d, e, g;
5315
+ return D(function(f) {
5316
+ switch (f.A) {
5317
5317
  case 1:
5318
- if (b || H(c) || pa) {
5319
- e.v = 2;
5318
+ if (b || H(c) || qa) {
5319
+ f.A = 2;
5320
5320
  break;
5321
5321
  }
5322
- e.F = 3;
5322
+ f.G = 3;
5323
5323
  d = fetch(c, { credentials: "same-origin" });
5324
- return x(e, WebAssembly.instantiateStreaming(d, a), 5);
5324
+ return w(f, WebAssembly.instantiateStreaming(d, a), 5);
5325
5325
  case 5:
5326
- return f = e.C, e.return(f);
5326
+ return e = f.D, f.return(e);
5327
5327
  case 3:
5328
- h = y(e), I("wasm streaming compile failed: " + h), I("falling back to ArrayBuffer instantiation");
5328
+ g = y(f), I("wasm streaming compile failed: " + g), I("falling back to ArrayBuffer instantiation");
5329
5329
  case 2:
5330
- return e.return(za(c, a));
5330
+ return f.return(Aa(c, a));
5331
5331
  }
5332
5332
  });
5333
5333
  }
5334
- function Ba(a) {
5334
+ function Ca(a) {
5335
5335
  for (;0 < a.length; )
5336
5336
  a.shift()(E);
5337
5337
  }
5338
- var Ca = [], Da = [];
5339
- function Ea() {
5338
+ var Da = [], Ea = [];
5339
+ function Fa() {
5340
5340
  var a = E.preRun.shift();
5341
- Da.push(a);
5341
+ Ea.push(a);
5342
5342
  }
5343
- function Fa(a) {
5344
- this.A = a - 24;
5343
+ function Ga(a) {
5344
+ this.B = a - 24;
5345
5345
  }
5346
- var Ga = 0, Ha = 0, Ia = [null, [], []], Ja = globalThis.TextDecoder && new TextDecoder;
5347
- function Ka(a, b) {
5346
+ var Ha = 0, Ia = 0, Ja = [null, [], []], Ka = globalThis.TextDecoder && new TextDecoder;
5347
+ function La(a, b) {
5348
5348
  b = b === undefined ? 0 : b;
5349
5349
  var c = b;
5350
5350
  for (var d = c + undefined;a[c] && !(c >= d); )
5351
5351
  ++c;
5352
- if (16 < c - b && a.buffer && Ja)
5353
- return Ja.decode(a.subarray(b, c));
5352
+ if (16 < c - b && a.buffer && Ka)
5353
+ return Ka.decode(a.subarray(b, c));
5354
5354
  for (d = "";b < c; ) {
5355
- var f = a[b++];
5356
- if (f & 128) {
5357
- var h = a[b++] & 63;
5358
- if ((f & 224) == 192)
5359
- d += String.fromCharCode((f & 31) << 6 | h);
5355
+ var e = a[b++];
5356
+ if (e & 128) {
5357
+ var g = a[b++] & 63;
5358
+ if ((e & 224) == 192)
5359
+ d += String.fromCharCode((e & 31) << 6 | g);
5360
5360
  else {
5361
- var e = a[b++] & 63;
5362
- f = (f & 240) == 224 ? (f & 15) << 12 | h << 6 | e : (f & 7) << 18 | h << 12 | e << 6 | a[b++] & 63;
5363
- 65536 > f ? d += String.fromCharCode(f) : (f -= 65536, d += String.fromCharCode(55296 | f >> 10, 56320 | f & 1023));
5361
+ var f = a[b++] & 63;
5362
+ e = (e & 240) == 224 ? (e & 15) << 12 | g << 6 | f : (e & 7) << 18 | g << 12 | f << 6 | a[b++] & 63;
5363
+ 65536 > e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
5364
5364
  }
5365
5365
  } else
5366
- d += String.fromCharCode(f);
5366
+ d += String.fromCharCode(e);
5367
5367
  }
5368
5368
  return d;
5369
5369
  }
5370
- function La(a) {
5371
- return a ? Ka(K, a) : "";
5370
+ function Ma(a) {
5371
+ return a ? La(K, a) : "";
5372
5372
  }
5373
- var Ma = [];
5374
- E.print && (ra = E.print);
5373
+ var Na = [];
5374
+ E.print && (sa = E.print);
5375
5375
  E.printErr && (I = E.printErr);
5376
5376
  E.wasmBinary && (J = E.wasmBinary);
5377
5377
  if (E.preInit)
5378
5378
  for (typeof E.preInit == "function" && (E.preInit = [E.preInit]);0 < E.preInit.length; )
5379
5379
  E.preInit.shift()();
5380
- var Na, Oa, Pa, Qa, Ra, Sa, Ta, Ua, Va, Wa, Xa, Ya, M, Za = { a: function(a, b, c) {
5381
- var d = new Fa(a);
5382
- L[d.A + 16 >> 2] = 0;
5383
- L[d.A + 4 >> 2] = b;
5384
- L[d.A + 8 >> 2] = c;
5385
- Ga = a;
5386
- Ha++;
5387
- throw Ga;
5380
+ var Oa, Pa, Qa, Ra, Sa, Ta, Ua, Va, Wa, Xa, Ya, Za, $a, ab2, M, bb = { a: function(a, b, c) {
5381
+ var d = new Ga(a);
5382
+ L[d.B + 16 >> 2] = 0;
5383
+ L[d.B + 4 >> 2] = b;
5384
+ L[d.B + 8 >> 2] = c;
5385
+ Ha = a;
5386
+ Ia++;
5387
+ throw Ha;
5388
5388
  }, c: function() {
5389
5389
  return N("");
5390
5390
  }, e: function(a, b) {
@@ -5401,89 +5401,91 @@ var require_cld2 = __commonJS((exports, module) => {
5401
5401
  d = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, d) / 65536)) - M.buffer.byteLength + 65535) / 65536 | 0;
5402
5402
  try {
5403
5403
  M.grow(d);
5404
- xa();
5405
- var f = 1;
5404
+ ya();
5405
+ var e = 1;
5406
5406
  break a;
5407
- } catch (h) {}
5408
- f = undefined;
5407
+ } catch (g) {}
5408
+ e = undefined;
5409
5409
  }
5410
- if (f)
5410
+ if (e)
5411
5411
  return true;
5412
5412
  }
5413
5413
  return false;
5414
5414
  }, b: function(a, b, c, d) {
5415
- for (var f = 0, h = 0;h < c; h++) {
5416
- var e = L[b >> 2], k = L[b + 4 >> 2];
5415
+ for (var e = 0, g = 0;g < c; g++) {
5416
+ var f = L[b >> 2], k = L[b + 4 >> 2];
5417
5417
  b += 8;
5418
5418
  for (var m = 0;m < k; m++) {
5419
- var n = a, q = K[e + m], B = Ia[n];
5420
- q === 0 || q === 10 ? ((n === 1 ? ra : I)(Ka(B)), B.length = 0) : B.push(q);
5419
+ var p = a, q = K[f + m], B = Ja[p];
5420
+ q === 0 || q === 10 ? ((p === 1 ? sa : I)(La(B)), B.length = 0) : B.push(q);
5421
5421
  }
5422
- f += k;
5422
+ e += k;
5423
5423
  }
5424
- L[d >> 2] = f;
5424
+ L[d >> 2] = e;
5425
5425
  return 0;
5426
5426
  } }, P;
5427
5427
  P = await function() {
5428
- function a(f) {
5429
- f = P = f.exports;
5430
- E._webidl_free = f.h;
5431
- E._webidl_malloc = f.i;
5432
- Na = E._emscripten_bind_Language_getLanguageCode_0 = f.j;
5433
- Oa = E._emscripten_bind_Language___destroy___0 = f.k;
5434
- Pa = E._emscripten_bind_VoidPtr___destroy___0 = f.l;
5435
- Qa = E._emscripten_bind_LanguageGuess_getPercent_0 = f.m;
5436
- Ra = E._emscripten_bind_LanguageGuess_getLanguageCode_0 = f.n;
5437
- Sa = E._emscripten_bind_LanguageGuess___destroy___0 = f.o;
5438
- Ta = E._emscripten_bind_LanguageInfo_detectLanguage_2 = f.p;
5439
- Ua = E._emscripten_bind_LanguageInfo_detectLanguage_5 = f.q;
5440
- Va = E._emscripten_bind_LanguageInfo_getIsReliable_0 = f.r;
5441
- Wa = E._emscripten_bind_LanguageInfo_getLanguageCode_0 = f.s;
5442
- Xa = E._emscripten_bind_LanguageInfo_get_languages_1 = f.t;
5443
- Ya = E._emscripten_bind_LanguageInfo___destroy___0 = f.u;
5444
- M = f.f;
5445
- xa();
5428
+ function a(e) {
5429
+ e = P = e.exports;
5430
+ E._webidl_free = e.h;
5431
+ E._webidl_malloc = e.i;
5432
+ Oa = E._emscripten_bind_Language_getLanguageCode_0 = e.j;
5433
+ Pa = E._emscripten_bind_Language___destroy___0 = e.k;
5434
+ Qa = E._emscripten_bind_VoidPtr___destroy___0 = e.l;
5435
+ Ra = E._emscripten_bind_LanguageGuess_getPercent_0 = e.m;
5436
+ Sa = E._emscripten_bind_LanguageGuess_getLanguageCode_0 = e.n;
5437
+ Ta = E._emscripten_bind_LanguageGuess___destroy___0 = e.o;
5438
+ Ua = E._emscripten_bind_LanguageInfo_detectLanguageWithLength_3 = e.p;
5439
+ Va = E._emscripten_bind_LanguageInfo_detectLanguageWithLength_6 = e.q;
5440
+ Wa = E._emscripten_bind_LanguageInfo_detectLanguage_2 = e.r;
5441
+ Xa = E._emscripten_bind_LanguageInfo_detectLanguage_5 = e.s;
5442
+ Ya = E._emscripten_bind_LanguageInfo_getIsReliable_0 = e.t;
5443
+ Za = E._emscripten_bind_LanguageInfo_getLanguageCode_0 = e.u;
5444
+ $a = E._emscripten_bind_LanguageInfo_get_languages_1 = e.v;
5445
+ ab2 = E._emscripten_bind_LanguageInfo___destroy___0 = e.w;
5446
+ M = e.f;
5447
+ ya();
5446
5448
  return P;
5447
5449
  }
5448
5450
  var b, c, d;
5449
- return D(function(f) {
5450
- if (f.v == 1) {
5451
- b = { a: Za };
5451
+ return D(function(e) {
5452
+ if (e.A == 1) {
5453
+ b = { a: bb };
5452
5454
  if (E.instantiateWasm)
5453
- return f.return(new Promise(function(h) {
5454
- E.instantiateWasm(b, function(e, k) {
5455
- h(a(e, k));
5455
+ return e.return(new Promise(function(g) {
5456
+ E.instantiateWasm(b, function(f, k) {
5457
+ g(a(f, k));
5456
5458
  });
5457
5459
  }));
5458
5460
  O != null || (O = E.locateFile ? E.locateFile("cld2.wasm", F) : F + "cld2.wasm");
5459
- return x(f, Aa(b), 2);
5461
+ return w(e, Ba(b), 2);
5460
5462
  }
5461
- c = f.C;
5463
+ c = e.D;
5462
5464
  d = a(c.instance);
5463
- return f.return(d);
5465
+ return e.return(d);
5464
5466
  });
5465
5467
  }();
5466
5468
  (function() {
5467
5469
  function a() {
5468
5470
  E.calledRun = true;
5469
- if (!sa) {
5470
- wa = true;
5471
- Ba(Ma);
5471
+ if (!ta) {
5472
+ xa = true;
5473
+ Ca(Na);
5472
5474
  P.g();
5473
5475
  var b;
5474
- (b = ta) == null || b(E);
5476
+ (b = ua) == null || b(E);
5475
5477
  var c;
5476
5478
  (c = E.onRuntimeInitialized) == null || c.call(E);
5477
5479
  if (E.postRun)
5478
5480
  for (typeof E.postRun == "function" && (E.postRun = [E.postRun]);E.postRun.length; )
5479
- b = E.postRun.shift(), Ca.push(b);
5480
- Ba(Ca);
5481
+ b = E.postRun.shift(), Da.push(b);
5482
+ Ca(Da);
5481
5483
  }
5482
5484
  }
5483
5485
  if (E.preRun)
5484
5486
  for (typeof E.preRun == "function" && (E.preRun = [E.preRun]);E.preRun.length; )
5485
- Ea();
5486
- Ba(Da);
5487
+ Fa();
5488
+ Ca(Ea);
5487
5489
  E.setStatus ? (E.setStatus("Running..."), setTimeout(function() {
5488
5490
  setTimeout(function() {
5489
5491
  return E.setStatus("");
@@ -5494,61 +5496,61 @@ var require_cld2 = __commonJS((exports, module) => {
5494
5496
  function Q() {}
5495
5497
  Q.prototype = Object.create(Q.prototype);
5496
5498
  Q.prototype.constructor = Q;
5497
- Q.prototype.I = Q;
5498
- Q.K = {};
5499
+ Q.prototype.J = Q;
5500
+ Q.L = {};
5499
5501
  E.WrapperObject = Q;
5500
- function $a(a) {
5501
- return (a || Q).K;
5502
+ function cb(a) {
5503
+ return (a || Q).L;
5502
5504
  }
5503
- E.getCache = $a;
5505
+ E.getCache = cb;
5504
5506
  function R(a, b) {
5505
- var c = $a(b), d = c[a];
5507
+ var c = cb(b), d = c[a];
5506
5508
  if (d)
5507
5509
  return d;
5508
5510
  d = Object.create((b || Q).prototype);
5509
- d.A = a;
5511
+ d.B = a;
5510
5512
  return c[a] = d;
5511
5513
  }
5512
5514
  E.wrapPointer = R;
5513
5515
  E.castObject = function(a, b) {
5514
- return R(a.A, b);
5516
+ return R(a.B, b);
5515
5517
  };
5516
5518
  E.NULL = R(0);
5517
5519
  E.destroy = function(a) {
5518
5520
  if (!a.__destroy__)
5519
5521
  throw "Error: Cannot destroy object. (Did you create it yourself?)";
5520
5522
  a.__destroy__();
5521
- delete $a(a.I)[a.A];
5523
+ delete cb(a.J)[a.B];
5522
5524
  };
5523
5525
  E.compare = function(a, b) {
5524
- return a.A === b.A;
5526
+ return a.B === b.B;
5525
5527
  };
5526
5528
  E.getPointer = function(a) {
5527
- return a.A;
5529
+ return a.B;
5528
5530
  };
5529
5531
  E.getClass = function(a) {
5530
- return a.I;
5532
+ return a.J;
5531
5533
  };
5532
- var S = { buffer: 0, size: 0, M: 0, O: [], L: 0, P: function() {
5533
- if (S.L) {
5534
- for (var a = 0;a < S.O.length; a++)
5535
- E._webidl_free(S.O[a]);
5536
- S.O.length = 0;
5534
+ var S = { buffer: 0, size: 0, N: 0, R: [], M: 0, P: function() {
5535
+ if (S.M) {
5536
+ for (var a = 0;a < S.R.length; a++)
5537
+ E._webidl_free(S.R[a]);
5538
+ S.R.length = 0;
5537
5539
  E._webidl_free(S.buffer);
5538
5540
  S.buffer = 0;
5539
- S.size += S.L;
5540
- S.L = 0;
5541
+ S.size += S.M;
5542
+ S.M = 0;
5541
5543
  }
5542
5544
  S.buffer || (S.size += 128, S.buffer = E._webidl_malloc(S.size), S.buffer || N());
5543
- S.M = 0;
5545
+ S.N = 0;
5544
5546
  }, alloc: function(a, b) {
5545
5547
  S.buffer || N();
5546
5548
  a = a.length * b.BYTES_PER_ELEMENT;
5547
5549
  a = 8 * Math.ceil(a / 8);
5548
- 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);
5550
+ 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);
5549
5551
  return b;
5550
5552
  } };
5551
- function ab2(a) {
5553
+ function T(a) {
5552
5554
  if (typeof a === "string") {
5553
5555
  for (var b = 0, c = 0;c < a.length; ++c) {
5554
5556
  var d = a.charCodeAt(c);
@@ -5559,119 +5561,129 @@ var require_cld2 = __commonJS((exports, module) => {
5559
5561
  c = 0;
5560
5562
  if (0 < d) {
5561
5563
  d = c + d - 1;
5562
- for (var f = 0;f < a.length; ++f) {
5563
- var h = a.codePointAt(f);
5564
- if (127 >= h) {
5564
+ for (var e = 0;e < a.length; ++e) {
5565
+ var g = a.codePointAt(e);
5566
+ if (127 >= g) {
5565
5567
  if (c >= d)
5566
5568
  break;
5567
- b[c++] = h;
5568
- } else if (2047 >= h) {
5569
+ b[c++] = g;
5570
+ } else if (2047 >= g) {
5569
5571
  if (c + 1 >= d)
5570
5572
  break;
5571
- b[c++] = 192 | h >> 6;
5572
- b[c++] = 128 | h & 63;
5573
- } else if (65535 >= h) {
5573
+ b[c++] = 192 | g >> 6;
5574
+ b[c++] = 128 | g & 63;
5575
+ } else if (65535 >= g) {
5574
5576
  if (c + 2 >= d)
5575
5577
  break;
5576
- b[c++] = 224 | h >> 12;
5577
- b[c++] = 128 | h >> 6 & 63;
5578
- b[c++] = 128 | h & 63;
5578
+ b[c++] = 224 | g >> 12;
5579
+ b[c++] = 128 | g >> 6 & 63;
5580
+ b[c++] = 128 | g & 63;
5579
5581
  } else {
5580
5582
  if (c + 3 >= d)
5581
5583
  break;
5582
- b[c++] = 240 | h >> 18;
5583
- b[c++] = 128 | h >> 12 & 63;
5584
- b[c++] = 128 | h >> 6 & 63;
5585
- b[c++] = 128 | h & 63;
5586
- f++;
5584
+ b[c++] = 240 | g >> 18;
5585
+ b[c++] = 128 | g >> 12 & 63;
5586
+ b[c++] = 128 | g >> 6 & 63;
5587
+ b[c++] = 128 | g & 63;
5588
+ e++;
5587
5589
  }
5588
5590
  }
5589
5591
  b[c] = 0;
5590
5592
  }
5591
- a = S.alloc(b, va);
5593
+ a = S.alloc(b, wa);
5592
5594
  for (c = 0;c < b.length; c++)
5593
- va[a + c] = b[c];
5595
+ wa[a + c] = b[c];
5594
5596
  return a;
5595
5597
  }
5596
5598
  return a;
5597
5599
  }
5598
- function T() {
5599
- throw "cannot construct a Language, no constructor in IDL";
5600
- }
5601
- T.prototype = Object.create(Q.prototype);
5602
- T.prototype.constructor = T;
5603
- T.prototype.I = T;
5604
- T.K = {};
5605
- E.Language = T;
5606
- T.prototype.getLanguageCode = function() {
5607
- return La(Na(this.A));
5608
- };
5609
- T.prototype.__destroy__ = function() {
5610
- Oa(this.A);
5611
- };
5612
5600
  function U() {
5613
- throw "cannot construct a VoidPtr, no constructor in IDL";
5601
+ throw "cannot construct a Language, no constructor in IDL";
5614
5602
  }
5615
5603
  U.prototype = Object.create(Q.prototype);
5616
5604
  U.prototype.constructor = U;
5617
- U.prototype.I = U;
5618
- U.K = {};
5619
- E.VoidPtr = U;
5605
+ U.prototype.J = U;
5606
+ U.L = {};
5607
+ E.Language = U;
5608
+ U.prototype.getLanguageCode = function() {
5609
+ return Ma(Oa(this.B));
5610
+ };
5620
5611
  U.prototype.__destroy__ = function() {
5621
- Pa(this.A);
5612
+ Pa(this.B);
5622
5613
  };
5623
5614
  function V() {
5624
- throw "cannot construct a LanguageGuess, no constructor in IDL";
5615
+ throw "cannot construct a VoidPtr, no constructor in IDL";
5625
5616
  }
5626
- V.prototype = Object.create(T.prototype);
5617
+ V.prototype = Object.create(Q.prototype);
5627
5618
  V.prototype.constructor = V;
5628
- V.prototype.I = V;
5629
- V.K = {};
5630
- E.LanguageGuess = V;
5631
- V.prototype.getPercent = function() {
5632
- return Qa(this.A);
5633
- };
5634
- V.prototype.getLanguageCode = function() {
5635
- return La(Ra(this.A));
5636
- };
5619
+ V.prototype.J = V;
5620
+ V.L = {};
5621
+ E.VoidPtr = V;
5637
5622
  V.prototype.__destroy__ = function() {
5638
- Sa(this.A);
5623
+ Qa(this.B);
5639
5624
  };
5640
5625
  function W() {
5641
- throw "cannot construct a LanguageInfo, no constructor in IDL";
5626
+ throw "cannot construct a LanguageGuess, no constructor in IDL";
5642
5627
  }
5643
- W.prototype = Object.create(T.prototype);
5628
+ W.prototype = Object.create(U.prototype);
5644
5629
  W.prototype.constructor = W;
5645
- W.prototype.I = W;
5646
- W.K = {};
5647
- E.LanguageInfo = W;
5648
- W.prototype.detectLanguage = function(a, b, c, d, f) {
5630
+ W.prototype.J = W;
5631
+ W.L = {};
5632
+ E.LanguageGuess = W;
5633
+ W.prototype.getPercent = function() {
5634
+ return Ra(this.B);
5635
+ };
5636
+ W.prototype.getLanguageCode = function() {
5637
+ return Ma(Sa(this.B));
5638
+ };
5639
+ W.prototype.__destroy__ = function() {
5640
+ Ta(this.B);
5641
+ };
5642
+ function X() {
5643
+ throw "cannot construct a LanguageInfo, no constructor in IDL";
5644
+ }
5645
+ X.prototype = Object.create(U.prototype);
5646
+ X.prototype.constructor = X;
5647
+ X.prototype.J = X;
5648
+ X.L = {};
5649
+ E.LanguageInfo = X;
5650
+ X.prototype.detectLanguageWithLength = function(a, b, c, d, e, g) {
5649
5651
  S.P();
5650
- a = a && typeof a === "object" ? a.A : ab2(a);
5651
- b && typeof b === "object" && (b = b.A);
5652
- c = c && typeof c === "object" ? c.A : ab2(c);
5653
- d && typeof d === "object" && (d = d.A);
5654
- f = f && typeof f === "object" ? f.A : ab2(f);
5655
- 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);
5652
+ a = a && typeof a === "object" ? a.B : T(a);
5653
+ b && typeof b === "object" && (b = b.B);
5654
+ c && typeof c === "object" && (c = c.B);
5655
+ d = d && typeof d === "object" ? d.B : T(d);
5656
+ e && typeof e === "object" && (e = e.B);
5657
+ g = g && typeof g === "object" ? g.B : T(g);
5658
+ 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);
5656
5659
  };
5657
- W.prototype.getIsReliable = function() {
5658
- return !!Va(this.A);
5660
+ X.prototype.detectLanguage = function(a, b, c, d, e) {
5661
+ S.P();
5662
+ a = a && typeof a === "object" ? a.B : T(a);
5663
+ b && typeof b === "object" && (b = b.B);
5664
+ c = c && typeof c === "object" ? c.B : T(c);
5665
+ d && typeof d === "object" && (d = d.B);
5666
+ e = e && typeof e === "object" ? e.B : T(e);
5667
+ 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);
5659
5668
  };
5660
- W.prototype.getLanguageCode = function() {
5661
- return La(Wa(this.A));
5669
+ X.prototype.getIsReliable = function() {
5670
+ return !!Ya(this.B);
5662
5671
  };
5663
- W.prototype.get_languages = W.prototype.Z = function(a) {
5664
- var b = this.A;
5665
- a && typeof a === "object" && (a = a.A);
5666
- return R(Xa(b, a), V);
5672
+ X.prototype.getLanguageCode = function() {
5673
+ return Ma(Za(this.B));
5667
5674
  };
5668
- Object.defineProperty(W.prototype, "languages", { get: W.prototype.Z });
5669
- W.prototype.__destroy__ = function() {
5670
- Ya(this.A);
5675
+ X.prototype.get_languages = X.prototype.$ = function(a) {
5676
+ var b = this.B;
5677
+ a && typeof a === "object" && (a = a.B);
5678
+ return R($a(b, a), W);
5679
+ };
5680
+ Object.defineProperty(X.prototype, "languages", { get: X.prototype.$ });
5681
+ X.prototype.__destroy__ = function() {
5682
+ ab2(this.B);
5671
5683
  };
5672
5684
  S.alloc = S.alloc.bind(S);
5673
5685
  S.P = S.P.bind(S);
5674
- for (var X = {
5686
+ for (var Y = {
5675
5687
  ISO_8859_1: 0,
5676
5688
  ISO_8859_2: 1,
5677
5689
  ISO_8859_3: 2,
@@ -5772,14 +5784,14 @@ var require_cld2 = __commonJS((exports, module) => {
5772
5784
  KDDI_ISO_2022_JP: 73,
5773
5785
  ISO_2022_JP: 73,
5774
5786
  SOFTBANK_ISO_2022_JP: 74
5775
- }, bb = g(Object.keys(X)), cb = bb.next();!cb.done; cb = bb.next()) {
5776
- var db = cb.value;
5777
- db.includes("_") && (X[db.replace(/_/g, "")] = X[db]);
5778
- }
5779
- E.Encodings = X;
5780
- wa ? moduleRtn = E : moduleRtn = new Promise(function(a, b) {
5781
- ta = a;
5782
- ua = b;
5787
+ }, db = h(Object.keys(Y)), eb = db.next();!eb.done; eb = db.next()) {
5788
+ var fb = eb.value;
5789
+ fb.includes("_") && (Y[fb.replace(/_/g, "")] = Y[fb]);
5790
+ }
5791
+ E.Encodings = Y;
5792
+ xa ? moduleRtn = E : moduleRtn = new Promise(function(a, b) {
5793
+ ua = a;
5794
+ va = b;
5783
5795
  });
5784
5796
  return moduleRtn;
5785
5797
  };
@@ -5792,7 +5804,7 @@ var require_cld2 = __commonJS((exports, module) => {
5792
5804
  });
5793
5805
 
5794
5806
  // src/lib/cld2/cld2.wasm
5795
- var cld2_default = "./cld2-8mh0n580.wasm";
5807
+ var cld2_default = "./cld2-22jkf0ae.wasm";
5796
5808
  var init_cld2 = () => {};
5797
5809
 
5798
5810
  // src/services/detector.ts
@@ -5806,6 +5818,52 @@ __export(exports_detector, {
5806
5818
  import path5 from "path";
5807
5819
  import { fileURLToPath } from "url";
5808
5820
  import { readFile } from "fs/promises";
5821
+ function sanitizeInput(text) {
5822
+ let sanitized = text.replace(/\0/g, "");
5823
+ sanitized = sanitized.replace(/[\x01-\x08\x0B-\x0C\x0E-\x1F\x7F]/g, "");
5824
+ return sanitized;
5825
+ }
5826
+ function truncateByUtf8Bytes(text, maxBytes) {
5827
+ const encoder = new TextEncoder;
5828
+ const bytes = encoder.encode(text);
5829
+ if (bytes.length <= maxBytes) {
5830
+ return text;
5831
+ }
5832
+ let truncated = bytes.slice(0, maxBytes);
5833
+ while (truncated.length > 0) {
5834
+ try {
5835
+ return new TextDecoder("utf-8", { fatal: true }).decode(truncated);
5836
+ } catch {
5837
+ truncated = truncated.slice(0, -1);
5838
+ }
5839
+ }
5840
+ return "";
5841
+ }
5842
+ function validateAndSanitizeInput(text, maxBytes = MAX_DETECTION_BYTES) {
5843
+ if (!text || text.length === 0) {
5844
+ return text;
5845
+ }
5846
+ const sanitized = sanitizeInput(text);
5847
+ const truncated = truncateByUtf8Bytes(sanitized, maxBytes);
5848
+ if (truncated !== text) {
5849
+ debug(`Input sanitized/truncated: ${text.length} → ${truncated.length} chars (limit: ${maxBytes})`);
5850
+ }
5851
+ return truncated;
5852
+ }
5853
+ function handleCldError(error2, context) {
5854
+ const errStr = error2.toString();
5855
+ if (errStr.includes("RuntimeError") || errStr.includes("memory access")) {
5856
+ error("CLD2 crashed (RuntimeError), resetting module", {
5857
+ error: errStr,
5858
+ stack: error2.stack,
5859
+ textLength: context?.text?.length,
5860
+ textPreview: context?.text?.substring(0, 100),
5861
+ operation: context?.operation
5862
+ });
5863
+ cldModule = null;
5864
+ initPromise = null;
5865
+ }
5866
+ }
5809
5867
  async function initCLD() {
5810
5868
  if (cldModule)
5811
5869
  return;
@@ -5823,8 +5881,13 @@ async function initCLD() {
5823
5881
  printErr: (msg) => error(`[CLD2 Error]: ${msg}`),
5824
5882
  wasmBinary: wasmBuffer
5825
5883
  });
5826
- if (module.LanguageInfo && module.LanguageInfo.prototype && module.LanguageInfo.prototype.detectLanguage) {
5827
- module.LanguageInfo.detectLanguage = module.LanguageInfo.prototype.detectLanguage;
5884
+ if (module.LanguageInfo && module.LanguageInfo.prototype) {
5885
+ if (module.LanguageInfo.prototype.detectLanguage) {
5886
+ module.LanguageInfo.detectLanguage = module.LanguageInfo.prototype.detectLanguage;
5887
+ }
5888
+ if (module.LanguageInfo.prototype.detectLanguageWithLength) {
5889
+ module.LanguageInfo.detectLanguageWithLength = module.LanguageInfo.prototype.detectLanguageWithLength;
5890
+ }
5828
5891
  }
5829
5892
  cldModule = module;
5830
5893
  debug("CLD2 language detector initialized");
@@ -5835,15 +5898,25 @@ async function initCLD() {
5835
5898
  })();
5836
5899
  return initPromise;
5837
5900
  }
5838
- function detectLanguageWithCLD(text, isHTML = false) {
5901
+ function detectLanguageWithCLD(text, isHTML = false, maxBytes = MAX_DETECTION_BYTES) {
5839
5902
  if (!cldModule) {
5840
5903
  throw new Error("CLD2 module not initialized");
5841
5904
  }
5905
+ const validatedText = validateAndSanitizeInput(text, maxBytes);
5906
+ if (!validatedText) {
5907
+ warn("Input validation resulted in empty text");
5908
+ return {
5909
+ language: "un",
5910
+ confident: false,
5911
+ languages: [],
5912
+ percentScore: 0
5913
+ };
5914
+ }
5842
5915
  const LanguageInfo = cldModule.LanguageInfo;
5843
5916
  if (!LanguageInfo || !LanguageInfo.detectLanguage) {
5844
5917
  throw new Error("CLD2 LanguageInfo or detectLanguage not available");
5845
5918
  }
5846
- const result = LanguageInfo.detectLanguage(text, !isHTML);
5919
+ const result = LanguageInfo.detectLanguage(validatedText, !isHTML);
5847
5920
  const languages = Array(3).fill(0).map((_, i) => {
5848
5921
  const lang = result.get_languages(i);
5849
5922
  return {
@@ -5868,26 +5941,27 @@ function bcp47Normalize(code) {
5868
5941
  return code.toLowerCase();
5869
5942
  }
5870
5943
  }
5871
- async function detectLanguage(text) {
5944
+ async function detectLanguage(text, maxBytes = MAX_DETECTION_BYTES) {
5872
5945
  if (!text) {
5873
5946
  return "";
5874
5947
  }
5875
5948
  await initCLD();
5876
5949
  try {
5877
- const result = detectLanguageWithCLD(text);
5950
+ const result = detectLanguageWithCLD(text, false, maxBytes);
5878
5951
  return bcp47Normalize(result.language);
5879
5952
  } catch (error2) {
5880
5953
  warn(`Language detection failed: ${error2}`);
5954
+ handleCldError(error2, { text, operation: "detectLanguage" });
5881
5955
  return "en";
5882
5956
  }
5883
5957
  }
5884
- async function detectLanguageWithConfidence(text, minConfidence = DEFAULT_CONFIDENCE_THRESHOLD) {
5958
+ async function detectLanguageWithConfidence(text, minConfidence = DEFAULT_CONFIDENCE_THRESHOLD, maxBytes = MAX_DETECTION_BYTES) {
5885
5959
  if (!text) {
5886
5960
  return { language: "", confidence: 0 };
5887
5961
  }
5888
5962
  await initCLD();
5889
5963
  try {
5890
- const result = detectLanguageWithCLD(text);
5964
+ const result = detectLanguageWithCLD(text, false, maxBytes);
5891
5965
  const confidence = result.percentScore / 100;
5892
5966
  if (confidence < minConfidence) {
5893
5967
  return { language: "", confidence };
@@ -5898,6 +5972,7 @@ async function detectLanguageWithConfidence(text, minConfidence = DEFAULT_CONFID
5898
5972
  };
5899
5973
  } catch (error2) {
5900
5974
  warn(`Language detection with confidence failed: ${error2}`);
5975
+ handleCldError(error2, { text, operation: "detectLanguageWithConfidence" });
5901
5976
  return { language: "en", confidence: 0 };
5902
5977
  }
5903
5978
  }
@@ -5917,6 +5992,28 @@ function hasMixedScripts(text) {
5917
5992
  }
5918
5993
  return false;
5919
5994
  }
5995
+ function getScriptType(text) {
5996
+ let hasCJK = false;
5997
+ let hasLatin = false;
5998
+ for (const char of text) {
5999
+ const code = char.charCodeAt(0);
6000
+ if (code >= 19968 && code <= 40959 || code >= 12352 && code <= 12447 || code >= 12448 && code <= 12543 || code >= 44032 && code <= 55215) {
6001
+ hasCJK = true;
6002
+ } else if (code >= 65 && code <= 90 || code >= 97 && code <= 122) {
6003
+ hasLatin = true;
6004
+ }
6005
+ if (hasCJK && hasLatin)
6006
+ return "Mixed";
6007
+ }
6008
+ if (hasCJK)
6009
+ return "CJK";
6010
+ if (hasLatin)
6011
+ return "Latin";
6012
+ return "Other";
6013
+ }
6014
+ function isCJKLanguage(lang) {
6015
+ return ["zh", "zh-Hans", "zh-Hant", "ja", "ko"].includes(lang) || lang.startsWith("zh-");
6016
+ }
5920
6017
  async function detectMultipleLanguages(text) {
5921
6018
  return detectMultipleLanguagesWithThreshold(text, DEFAULT_CONFIDENCE_THRESHOLD);
5922
6019
  }
@@ -5925,7 +6022,7 @@ async function detectMultipleLanguagesWithThreshold(text, threshold) {
5925
6022
  return [];
5926
6023
  }
5927
6024
  await initCLD();
5928
- const fallbackLang = await detectLanguage(text);
6025
+ const fallbackLang = await detectLanguage(text, MAX_FALLBACK_DETECTION_BYTES);
5929
6026
  const effectiveFallback = fallbackLang || "en";
5930
6027
  if (!hasMixedScripts(text)) {
5931
6028
  debug(`DetectMultipleLanguages: no mixed scripts, using single language: ${effectiveFallback}`);
@@ -5943,18 +6040,43 @@ async function detectMultipleLanguagesWithThreshold(text, threshold) {
5943
6040
  const sentenceSegments = Array.from(segmenterAny.segment(text));
5944
6041
  for (const { segment, index } of sentenceSegments) {
5945
6042
  try {
6043
+ await initCLD();
5946
6044
  const result = detectLanguageWithCLD(segment);
5947
6045
  const detectedLang = bcp47Normalize(result.language);
5948
6046
  const confidence = result.percentScore / 100;
6047
+ const scriptType = getScriptType(segment);
6048
+ let finalLang = effectiveFallback;
6049
+ let usedLogic = "fallback";
6050
+ if (confidence >= threshold) {
6051
+ finalLang = detectedLang;
6052
+ usedLogic = "confidence";
6053
+ } else {
6054
+ if (scriptType === "Latin" && isCJKLanguage(effectiveFallback)) {
6055
+ if (detectedLang && detectedLang !== "un") {
6056
+ finalLang = detectedLang;
6057
+ usedLogic = "script-override-latin";
6058
+ } else {
6059
+ finalLang = "en";
6060
+ usedLogic = "script-override-en";
6061
+ }
6062
+ } else if (scriptType === "CJK" && !isCJKLanguage(effectiveFallback)) {
6063
+ if (detectedLang && detectedLang !== "un") {
6064
+ finalLang = detectedLang;
6065
+ usedLogic = "script-override-cjk";
6066
+ }
6067
+ }
6068
+ }
6069
+ debug(`Segment[${segments.length}]: "${segment.replace(/\n/g, "\\n")}" -> lang=${detectedLang}, conf=${confidence.toFixed(2)}, script=${scriptType}, final=${finalLang} (${usedLogic})`);
5949
6070
  segments.push({
5950
6071
  text: segment,
5951
- language: confidence >= threshold ? detectedLang : effectiveFallback,
6072
+ language: finalLang,
5952
6073
  start: index,
5953
6074
  end: index + segment.length,
5954
6075
  confidence
5955
6076
  });
5956
6077
  } catch (error2) {
5957
6078
  warn(`Failed to detect language for segment: ${error2}`);
6079
+ handleCldError(error2, { text: segment, operation: "detectMultipleLanguages" });
5958
6080
  segments.push({
5959
6081
  text: segment,
5960
6082
  language: effectiveFallback,
@@ -6014,7 +6136,7 @@ function limitLanguages(segments, originalText, maxLangs) {
6014
6136
  debug(`limitLanguages: reduced to ${maxLangs} languages, ${result.length} segments`);
6015
6137
  return result;
6016
6138
  }
6017
- var import_cld2, DEFAULT_CONFIDENCE_THRESHOLD = 0.5, MAXIMUM_LANGUAGES_IN_ONE_TEXT = 2, cldModule = null, initPromise = null;
6139
+ 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;
6018
6140
  var init_detector = __esm(() => {
6019
6141
  init_cld2();
6020
6142
  init_logger();
@@ -6049,11 +6171,11 @@ class Stack {
6049
6171
  return this.heap[--this.length];
6050
6172
  }
6051
6173
  }
6052
- var perf, warned, PROCESS, emitWarning = (msg, type, code, fn) => {
6174
+ var defaultPerf, warned, PROCESS, emitWarning = (msg, type, code, fn) => {
6053
6175
  typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
6054
6176
  }, AC, AS, shouldWarn = (code) => !warned.has(code), TYPE, isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n), getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null, ZeroArray, LRUCache;
6055
6177
  var init_esm2 = __esm(() => {
6056
- perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
6178
+ defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
6057
6179
  warned = new Set;
6058
6180
  PROCESS = typeof process === "object" && !!process ? process : {};
6059
6181
  AC = globalThis.AbortController;
@@ -6103,9 +6225,14 @@ var init_esm2 = __esm(() => {
6103
6225
  #max;
6104
6226
  #maxSize;
6105
6227
  #dispose;
6228
+ #onInsert;
6106
6229
  #disposeAfter;
6107
6230
  #fetchMethod;
6108
6231
  #memoMethod;
6232
+ #perf;
6233
+ get perf() {
6234
+ return this.#perf;
6235
+ }
6109
6236
  ttl;
6110
6237
  ttlResolution;
6111
6238
  ttlAutopurge;
@@ -6135,13 +6262,16 @@ var init_esm2 = __esm(() => {
6135
6262
  #sizes;
6136
6263
  #starts;
6137
6264
  #ttls;
6265
+ #autopurgeTimers;
6138
6266
  #hasDispose;
6139
6267
  #hasFetchMethod;
6140
6268
  #hasDisposeAfter;
6269
+ #hasOnInsert;
6141
6270
  static unsafeExposeInternals(c) {
6142
6271
  return {
6143
6272
  starts: c.#starts,
6144
6273
  ttls: c.#ttls,
6274
+ autopurgeTimers: c.#autopurgeTimers,
6145
6275
  sizes: c.#sizes,
6146
6276
  keyMap: c.#keyMap,
6147
6277
  keyList: c.#keyList,
@@ -6184,11 +6314,20 @@ var init_esm2 = __esm(() => {
6184
6314
  get dispose() {
6185
6315
  return this.#dispose;
6186
6316
  }
6317
+ get onInsert() {
6318
+ return this.#onInsert;
6319
+ }
6187
6320
  get disposeAfter() {
6188
6321
  return this.#disposeAfter;
6189
6322
  }
6190
6323
  constructor(options) {
6191
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
6324
+ const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf } = options;
6325
+ if (perf !== undefined) {
6326
+ if (typeof perf?.now !== "function") {
6327
+ throw new TypeError("perf option must have a now() method if specified");
6328
+ }
6329
+ }
6330
+ this.#perf = perf ?? defaultPerf;
6192
6331
  if (max !== 0 && !isPosInt(max)) {
6193
6332
  throw new TypeError("max option must be a nonnegative integer");
6194
6333
  }
@@ -6230,6 +6369,9 @@ var init_esm2 = __esm(() => {
6230
6369
  if (typeof dispose === "function") {
6231
6370
  this.#dispose = dispose;
6232
6371
  }
6372
+ if (typeof onInsert === "function") {
6373
+ this.#onInsert = onInsert;
6374
+ }
6233
6375
  if (typeof disposeAfter === "function") {
6234
6376
  this.#disposeAfter = disposeAfter;
6235
6377
  this.#disposed = [];
@@ -6238,6 +6380,7 @@ var init_esm2 = __esm(() => {
6238
6380
  this.#disposed = undefined;
6239
6381
  }
6240
6382
  this.#hasDispose = !!this.#dispose;
6383
+ this.#hasOnInsert = !!this.#onInsert;
6241
6384
  this.#hasDisposeAfter = !!this.#disposeAfter;
6242
6385
  this.noDisposeOnSet = !!noDisposeOnSet;
6243
6386
  this.noUpdateTTL = !!noUpdateTTL;
@@ -6289,10 +6432,16 @@ var init_esm2 = __esm(() => {
6289
6432
  const starts = new ZeroArray(this.#max);
6290
6433
  this.#ttls = ttls;
6291
6434
  this.#starts = starts;
6292
- this.#setItemTTL = (index, ttl, start = perf.now()) => {
6435
+ const purgeTimers = this.ttlAutopurge ? new Array(this.#max) : undefined;
6436
+ this.#autopurgeTimers = purgeTimers;
6437
+ this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
6293
6438
  starts[index] = ttl !== 0 ? start : 0;
6294
6439
  ttls[index] = ttl;
6295
- if (ttl !== 0 && this.ttlAutopurge) {
6440
+ if (purgeTimers?.[index]) {
6441
+ clearTimeout(purgeTimers[index]);
6442
+ purgeTimers[index] = undefined;
6443
+ }
6444
+ if (ttl !== 0 && purgeTimers) {
6296
6445
  const t = setTimeout(() => {
6297
6446
  if (this.#isStale(index)) {
6298
6447
  this.#delete(this.#keyList[index], "expire");
@@ -6301,10 +6450,11 @@ var init_esm2 = __esm(() => {
6301
6450
  if (t.unref) {
6302
6451
  t.unref();
6303
6452
  }
6453
+ purgeTimers[index] = t;
6304
6454
  }
6305
6455
  };
6306
6456
  this.#updateItemAge = (index) => {
6307
- starts[index] = ttls[index] !== 0 ? perf.now() : 0;
6457
+ starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
6308
6458
  };
6309
6459
  this.#statusTTL = (status, index) => {
6310
6460
  if (ttls[index]) {
@@ -6321,7 +6471,7 @@ var init_esm2 = __esm(() => {
6321
6471
  };
6322
6472
  let cachedNow = 0;
6323
6473
  const getNow = () => {
6324
- const n = perf.now();
6474
+ const n = this.#perf.now();
6325
6475
  if (this.ttlResolution > 0) {
6326
6476
  cachedNow = n;
6327
6477
  const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
@@ -6543,7 +6693,7 @@ var init_esm2 = __esm(() => {
6543
6693
  const ttl = this.#ttls[i];
6544
6694
  const start = this.#starts[i];
6545
6695
  if (ttl && start) {
6546
- const remain = ttl - (perf.now() - start);
6696
+ const remain = ttl - (this.#perf.now() - start);
6547
6697
  entry.ttl = remain;
6548
6698
  entry.start = Date.now();
6549
6699
  }
@@ -6564,7 +6714,7 @@ var init_esm2 = __esm(() => {
6564
6714
  const entry = { value };
6565
6715
  if (this.#ttls && this.#starts) {
6566
6716
  entry.ttl = this.#ttls[i];
6567
- const age = perf.now() - this.#starts[i];
6717
+ const age = this.#perf.now() - this.#starts[i];
6568
6718
  entry.start = Math.floor(Date.now() - age);
6569
6719
  }
6570
6720
  if (this.#sizes) {
@@ -6579,7 +6729,7 @@ var init_esm2 = __esm(() => {
6579
6729
  for (const [key, entry] of arr) {
6580
6730
  if (entry.start) {
6581
6731
  const age = Date.now() - entry.start;
6582
- entry.start = perf.now() - age;
6732
+ entry.start = this.#perf.now() - age;
6583
6733
  }
6584
6734
  this.set(key, entry.value, entry);
6585
6735
  }
@@ -6614,6 +6764,9 @@ var init_esm2 = __esm(() => {
6614
6764
  if (status)
6615
6765
  status.set = "add";
6616
6766
  noUpdateTTL = false;
6767
+ if (this.#hasOnInsert) {
6768
+ this.#onInsert?.(v, k, "add");
6769
+ }
6617
6770
  } else {
6618
6771
  this.#moveToTail(index);
6619
6772
  const oldVal = this.#valList[index];
@@ -6649,6 +6802,9 @@ var init_esm2 = __esm(() => {
6649
6802
  } else if (status) {
6650
6803
  status.set = "update";
6651
6804
  }
6805
+ if (this.#hasOnInsert) {
6806
+ this.onInsert?.(v, k, v === oldVal ? "update" : "replace");
6807
+ }
6652
6808
  }
6653
6809
  if (ttl !== 0 && !this.#ttls) {
6654
6810
  this.#initializeTTLTracking();
@@ -6707,6 +6863,10 @@ var init_esm2 = __esm(() => {
6707
6863
  }
6708
6864
  }
6709
6865
  this.#removeItemSize(head);
6866
+ if (this.#autopurgeTimers?.[head]) {
6867
+ clearTimeout(this.#autopurgeTimers[head]);
6868
+ this.#autopurgeTimers[head] = undefined;
6869
+ }
6710
6870
  if (free) {
6711
6871
  this.#keyList[head] = undefined;
6712
6872
  this.#valList[head] = undefined;
@@ -6789,9 +6949,10 @@ var init_esm2 = __esm(() => {
6789
6949
  return fetchFail(ac.signal.reason);
6790
6950
  }
6791
6951
  const bf2 = p;
6792
- if (this.#valList[index] === p) {
6952
+ const vl = this.#valList[index];
6953
+ if (vl === p || ignoreAbort && updateCache && vl === undefined) {
6793
6954
  if (v2 === undefined) {
6794
- if (bf2.__staleWhileFetching) {
6955
+ if (bf2.__staleWhileFetching !== undefined) {
6795
6956
  this.#valList[index] = bf2.__staleWhileFetching;
6796
6957
  } else {
6797
6958
  this.#delete(k, "fetch");
@@ -7040,6 +7201,10 @@ var init_esm2 = __esm(() => {
7040
7201
  if (this.#size !== 0) {
7041
7202
  const index = this.#keyMap.get(k);
7042
7203
  if (index !== undefined) {
7204
+ if (this.#autopurgeTimers?.[index]) {
7205
+ clearTimeout(this.#autopurgeTimers?.[index]);
7206
+ this.#autopurgeTimers[index] = undefined;
7207
+ }
7043
7208
  deleted = true;
7044
7209
  if (this.#size === 1) {
7045
7210
  this.#clear(reason);
@@ -7107,6 +7272,11 @@ var init_esm2 = __esm(() => {
7107
7272
  if (this.#ttls && this.#starts) {
7108
7273
  this.#ttls.fill(0);
7109
7274
  this.#starts.fill(0);
7275
+ for (const t of this.#autopurgeTimers ?? []) {
7276
+ if (t !== undefined)
7277
+ clearTimeout(t);
7278
+ }
7279
+ this.#autopurgeTimers?.fill(undefined);
7110
7280
  }
7111
7281
  if (this.#sizes) {
7112
7282
  this.#sizes.fill(0);
@@ -24789,7 +24959,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
24789
24959
 
24790
24960
  // node_modules/typescript/lib/typescript.js
24791
24961
  var require_typescript = __commonJS((exports, module) => {
24792
- var __dirname = "/home/xxnuo/projects/MTran/MTranServer/node_modules/typescript/lib", __filename = "/home/xxnuo/projects/MTran/MTranServer/node_modules/typescript/lib/typescript.js";
24962
+ var __dirname = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/node_modules/typescript/lib", __filename = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/node_modules/typescript/lib/typescript.js";
24793
24963
  /*! *****************************************************************************
24794
24964
  Copyright (c) Microsoft Corporation. All rights reserved.
24795
24965
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -193798,11 +193968,11 @@ var require_decoratorUtils = __commonJS((exports) => {
193798
193968
  }
193799
193969
  });
193800
193970
 
193801
- // node_modules/lru-cache/dist/commonjs/index.js
193971
+ // node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js
193802
193972
  var require_commonjs2 = __commonJS((exports) => {
193803
193973
  Object.defineProperty(exports, "__esModule", { value: true });
193804
193974
  exports.LRUCache = undefined;
193805
- var perf2 = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
193975
+ var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
193806
193976
  var warned2 = new Set;
193807
193977
  var PROCESS2 = typeof process === "object" && !!process ? process : {};
193808
193978
  var emitWarning2 = (msg, type, code, fn) => {
@@ -194074,7 +194244,7 @@ var require_commonjs2 = __commonJS((exports) => {
194074
194244
  const starts = new ZeroArray2(this.#max);
194075
194245
  this.#ttls = ttls;
194076
194246
  this.#starts = starts;
194077
- this.#setItemTTL = (index, ttl, start = perf2.now()) => {
194247
+ this.#setItemTTL = (index, ttl, start = perf.now()) => {
194078
194248
  starts[index] = ttl !== 0 ? start : 0;
194079
194249
  ttls[index] = ttl;
194080
194250
  if (ttl !== 0 && this.ttlAutopurge) {
@@ -194089,7 +194259,7 @@ var require_commonjs2 = __commonJS((exports) => {
194089
194259
  }
194090
194260
  };
194091
194261
  this.#updateItemAge = (index) => {
194092
- starts[index] = ttls[index] !== 0 ? perf2.now() : 0;
194262
+ starts[index] = ttls[index] !== 0 ? perf.now() : 0;
194093
194263
  };
194094
194264
  this.#statusTTL = (status, index) => {
194095
194265
  if (ttls[index]) {
@@ -194106,7 +194276,7 @@ var require_commonjs2 = __commonJS((exports) => {
194106
194276
  };
194107
194277
  let cachedNow = 0;
194108
194278
  const getNow = () => {
194109
- const n = perf2.now();
194279
+ const n = perf.now();
194110
194280
  if (this.ttlResolution > 0) {
194111
194281
  cachedNow = n;
194112
194282
  const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
@@ -194328,7 +194498,7 @@ var require_commonjs2 = __commonJS((exports) => {
194328
194498
  const ttl = this.#ttls[i];
194329
194499
  const start = this.#starts[i];
194330
194500
  if (ttl && start) {
194331
- const remain = ttl - (perf2.now() - start);
194501
+ const remain = ttl - (perf.now() - start);
194332
194502
  entry.ttl = remain;
194333
194503
  entry.start = Date.now();
194334
194504
  }
@@ -194349,7 +194519,7 @@ var require_commonjs2 = __commonJS((exports) => {
194349
194519
  const entry = { value };
194350
194520
  if (this.#ttls && this.#starts) {
194351
194521
  entry.ttl = this.#ttls[i];
194352
- const age = perf2.now() - this.#starts[i];
194522
+ const age = perf.now() - this.#starts[i];
194353
194523
  entry.start = Math.floor(Date.now() - age);
194354
194524
  }
194355
194525
  if (this.#sizes) {
@@ -194364,7 +194534,7 @@ var require_commonjs2 = __commonJS((exports) => {
194364
194534
  for (const [key, entry] of arr) {
194365
194535
  if (entry.start) {
194366
194536
  const age = Date.now() - entry.start;
194367
- entry.start = perf2.now() - age;
194537
+ entry.start = perf.now() - age;
194368
194538
  }
194369
194539
  this.set(key, entry.value, entry);
194370
194540
  }
@@ -208867,7 +209037,7 @@ var require_routeGenerator = __commonJS((exports) => {
208867
209037
 
208868
209038
  // node_modules/@tsoa/cli/dist/routeGeneration/defaultRouteGenerator.js
208869
209039
  var require_defaultRouteGenerator = __commonJS((exports) => {
208870
- var __dirname = "/home/xxnuo/projects/MTran/MTranServer/node_modules/@tsoa/cli/dist/routeGeneration";
209040
+ var __dirname = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/node_modules/@tsoa/cli/dist/routeGeneration";
208871
209041
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
208872
209042
  if (k2 === undefined)
208873
209043
  k2 = k;
@@ -208993,7 +209163,7 @@ var require_defaultRouteGenerator = __commonJS((exports) => {
208993
209163
 
208994
209164
  // node_modules/@tsoa/cli/dist/module/generate-routes.js
208995
209165
  var require_generate_routes = __commonJS((exports) => {
208996
- var __dirname = "/home/xxnuo/projects/MTran/MTranServer/node_modules/@tsoa/cli/dist/module";
209166
+ var __dirname = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/node_modules/@tsoa/cli/dist/module";
208997
209167
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
208998
209168
  if (k2 === undefined)
208999
209169
  k2 = k;
@@ -211922,7 +212092,7 @@ var require_require_directory = __commonJS((exports, module) => {
211922
212092
 
211923
212093
  // node_modules/yargs/build/index.cjs
211924
212094
  var require_build4 = __commonJS((exports, module) => {
211925
- var __dirname = "/home/xxnuo/projects/MTran/MTranServer/node_modules/yargs/build";
212095
+ var __dirname = "/Volumes/MacData/Users/xxnuo/projects/MTranServer/node_modules/yargs/build";
211926
212096
  var t = __require("assert");
211927
212097
 
211928
212098
  class e extends Error {
@@ -214138,7 +214308,7 @@ var require_dist4 = __commonJS((exports) => {
214138
214308
  });
214139
214309
 
214140
214310
  // src/utils/lang-alias.ts
214141
- function normalizeLanguageCode(code) {
214311
+ function NormalizeLanguageCode(code) {
214142
214312
  if (!code)
214143
214313
  return "";
214144
214314
  const normalized = code.toLowerCase().replace(/_/g, "-");
@@ -214237,10 +214407,10 @@ var init_memory = () => {};
214237
214407
  // src/utils/index.ts
214238
214408
  var exports_utils = {};
214239
214409
  __export(exports_utils, {
214240
- normalizeLanguageCode: () => normalizeLanguageCode,
214241
214410
  getLargestVersion: () => getLargestVersion,
214242
214411
  getFreePort: () => getFreePort,
214243
- getAvailableMemoryMB: () => getAvailableMemoryMB
214412
+ getAvailableMemoryMB: () => getAvailableMemoryMB,
214413
+ NormalizeLanguageCode: () => NormalizeLanguageCode
214244
214414
  });
214245
214415
  var init_utils = __esm(() => {
214246
214416
  init_lang_alias();
@@ -214257,7 +214427,7 @@ __export(exports_version, {
214257
214427
  function getVersion() {
214258
214428
  return VERSION;
214259
214429
  }
214260
- var VERSION = "4.0.18";
214430
+ var VERSION = "4.0.20";
214261
214431
 
214262
214432
  // src/server/index.ts
214263
214433
  init_config();
@@ -214371,18 +214541,18 @@ var import_runtime = __toESM(require_dist(), 1);
214371
214541
  var import_tsoa = __toESM(require_dist4(), 1);
214372
214542
  class TranslateController extends import_tsoa.Controller {
214373
214543
  async translate(body) {
214374
- const { normalizeLanguageCode: normalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214544
+ const { NormalizeLanguageCode: NormalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214375
214545
  const { translateWithPivot: translateWithPivot2 } = await Promise.resolve().then(() => (init_services(), exports_services));
214376
- const normalizedFrom = normalizeLanguageCode2(body.from);
214377
- const normalizedTo = normalizeLanguageCode2(body.to);
214546
+ const normalizedFrom = NormalizeLanguageCode2(body.from);
214547
+ const normalizedTo = NormalizeLanguageCode2(body.to);
214378
214548
  const result = await translateWithPivot2(normalizedFrom, normalizedTo, body.text, body.html || false);
214379
214549
  return { result };
214380
214550
  }
214381
214551
  async translateBatch(body) {
214382
- const { normalizeLanguageCode: normalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214552
+ const { NormalizeLanguageCode: NormalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214383
214553
  const { translateWithPivot: translateWithPivot2 } = await Promise.resolve().then(() => (init_services(), exports_services));
214384
- const normalizedFrom = normalizeLanguageCode2(body.from);
214385
- const normalizedTo = normalizeLanguageCode2(body.to);
214554
+ const normalizedFrom = NormalizeLanguageCode2(body.from);
214555
+ const normalizedTo = NormalizeLanguageCode2(body.to);
214386
214556
  const results = [];
214387
214557
  for (let i = 0;i < body.texts.length; i++) {
214388
214558
  const result = await translateWithPivot2(normalizedFrom, normalizedTo, body.texts[i], body.html || false);
@@ -214476,7 +214646,7 @@ class LanguageController extends import_tsoa3.Controller {
214476
214646
  const languages = getSupportedLanguages2();
214477
214647
  const pairStrings = getLanguagePairs2();
214478
214648
  const pairs = pairStrings.map((p) => {
214479
- const [from, to] = p.split("-");
214649
+ const [from, to] = p.split("_");
214480
214650
  return { from, to };
214481
214651
  });
214482
214652
  return { languages, pairs };
@@ -214520,10 +214690,10 @@ LanguageController = __legacyDecorateClassTS([
214520
214690
  var import_tsoa4 = __toESM(require_dist4(), 1);
214521
214691
  class KissController extends import_tsoa4.Controller {
214522
214692
  async translate(body) {
214523
- const { normalizeLanguageCode: normalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214693
+ const { NormalizeLanguageCode: NormalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214524
214694
  const { translateWithPivot: translateWithPivot2 } = await Promise.resolve().then(() => (init_services(), exports_services));
214525
- const fromLang = normalizeLanguageCode2(body.from);
214526
- const toLang = normalizeLanguageCode2(body.to);
214695
+ const fromLang = NormalizeLanguageCode2(body.from);
214696
+ const toLang = NormalizeLanguageCode2(body.to);
214527
214697
  if (body.texts && Array.isArray(body.texts) && body.texts.length > 0) {
214528
214698
  const translations = [];
214529
214699
  for (const text of body.texts) {
@@ -214565,7 +214735,7 @@ KissController = __legacyDecorateClassTS([
214565
214735
  var import_tsoa5 = __toESM(require_dist4(), 1);
214566
214736
  class ImmeController extends import_tsoa5.Controller {
214567
214737
  async translate(body, token) {
214568
- const { normalizeLanguageCode: normalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214738
+ const { NormalizeLanguageCode: NormalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214569
214739
  const { translateWithPivot: translateWithPivot2 } = await Promise.resolve().then(() => (init_services(), exports_services));
214570
214740
  const { getConfig: getConfig2 } = await Promise.resolve().then(() => (init_config(), exports_config));
214571
214741
  const logger = await Promise.resolve().then(() => (init_logger(), exports_logger));
@@ -214575,8 +214745,8 @@ class ImmeController extends import_tsoa5.Controller {
214575
214745
  this.setStatus(401);
214576
214746
  throw new Error("Unauthorized");
214577
214747
  }
214578
- const sourceLang = normalizeLanguageCode2(body.source_lang);
214579
- const targetLang = normalizeLanguageCode2(body.target_lang);
214748
+ const sourceLang = NormalizeLanguageCode2(body.source_lang);
214749
+ const targetLang = NormalizeLanguageCode2(body.target_lang);
214580
214750
  const translations = [];
214581
214751
  for (let i = 0;i < body.text_list.length; i++) {
214582
214752
  const text = body.text_list[i];
@@ -214746,11 +214916,11 @@ HcfyController = __legacyDecorateClassTS([
214746
214916
  var import_tsoa7 = __toESM(require_dist4(), 1);
214747
214917
  class GoogleController extends import_tsoa7.Controller {
214748
214918
  async translateCompat(body) {
214749
- const { normalizeLanguageCode: normalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214919
+ const { NormalizeLanguageCode: NormalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214750
214920
  const { translateWithPivot: translateWithPivot2 } = await Promise.resolve().then(() => (init_services(), exports_services));
214751
214921
  const queries = Array.isArray(body.q) ? body.q : [body.q];
214752
- const sourceBCP47 = normalizeLanguageCode2(body.source);
214753
- const targetBCP47 = normalizeLanguageCode2(body.target);
214922
+ const sourceBCP47 = NormalizeLanguageCode2(body.source);
214923
+ const targetBCP47 = NormalizeLanguageCode2(body.target);
214754
214924
  const isHTML = body.format === "html";
214755
214925
  const translations = [];
214756
214926
  for (const q of queries) {
@@ -214765,7 +214935,7 @@ class GoogleController extends import_tsoa7.Controller {
214765
214935
  };
214766
214936
  }
214767
214937
  async translateSingle(sl = "auto", tl, q) {
214768
- const { normalizeLanguageCode: normalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214938
+ const { NormalizeLanguageCode: NormalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214769
214939
  const { translateWithPivot: translateWithPivot2 } = await Promise.resolve().then(() => (init_services(), exports_services));
214770
214940
  const bcp47ToGoogleLang = {
214771
214941
  "zh-Hans": "zh-CN",
@@ -214774,8 +214944,8 @@ class GoogleController extends import_tsoa7.Controller {
214774
214944
  function convertBCP47ToGoogleLang(bcp47Lang) {
214775
214945
  return bcp47ToGoogleLang[bcp47Lang] || bcp47Lang;
214776
214946
  }
214777
- const sourceBCP47 = normalizeLanguageCode2(sl);
214778
- const targetBCP47 = normalizeLanguageCode2(tl);
214947
+ const sourceBCP47 = NormalizeLanguageCode2(sl);
214948
+ const targetBCP47 = NormalizeLanguageCode2(tl);
214779
214949
  const result = await translateWithPivot2(sourceBCP47, targetBCP47, q, false);
214780
214950
  const detectedLang = convertBCP47ToGoogleLang(sourceBCP47);
214781
214951
  return [
@@ -214825,7 +214995,7 @@ GoogleController = __legacyDecorateClassTS([
214825
214995
  var import_tsoa8 = __toESM(require_dist4(), 1);
214826
214996
  class DeeplController extends import_tsoa8.Controller {
214827
214997
  async translate(body, authorization) {
214828
- const { normalizeLanguageCode: normalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214998
+ const { NormalizeLanguageCode: NormalizeLanguageCode2 } = await Promise.resolve().then(() => (init_utils(), exports_utils));
214829
214999
  const { translateWithPivot: translateWithPivot2 } = await Promise.resolve().then(() => (init_services(), exports_services));
214830
215000
  const { getConfig: getConfig2 } = await Promise.resolve().then(() => (init_config(), exports_config));
214831
215001
  const config2 = getConfig2();
@@ -214855,8 +215025,8 @@ class DeeplController extends import_tsoa8.Controller {
214855
215025
  return bcp47ToDeeplLang[bcp47Lang] || bcp47Lang.toUpperCase();
214856
215026
  }
214857
215027
  const textArray = Array.isArray(body.text) ? body.text : [body.text];
214858
- const sourceLang = body.source_lang ? normalizeLanguageCode2(body.source_lang) : "auto";
214859
- const targetLang = normalizeLanguageCode2(body.target_lang);
215028
+ const sourceLang = body.source_lang ? NormalizeLanguageCode2(body.source_lang) : "auto";
215029
+ const targetLang = NormalizeLanguageCode2(body.target_lang);
214860
215030
  const isHTML = body.tag_handling === "html" || body.tag_handling === "xml";
214861
215031
  const translations = [];
214862
215032
  for (let i = 0;i < textArray.length; i++) {
@@ -215894,7 +216064,7 @@ var swagger_default = {
215894
216064
  },
215895
216065
  info: {
215896
216066
  title: "MTranServer API",
215897
- version: "4.0.18",
216067
+ version: "4.0.20",
215898
216068
  description: "Translation server API",
215899
216069
  license: {
215900
216070
  name: "Apache-2.0"
@@ -216367,28 +216537,32 @@ var swagger_default = {
216367
216537
 
216368
216538
  // src/middleware/ui.ts
216369
216539
  import { readFile as readFile3 } from "fs/promises";
216540
+ import { dirname, resolve, isAbsolute } from "path";
216541
+ import { fileURLToPath as fileURLToPath3 } from "url";
216370
216542
 
216371
216543
  // ui/dist/icon.png
216372
- var icon_default = "./icon-tjp1feba.png";
216544
+ var icon_default = "./icon-2r5te9sp.png";
216373
216545
 
216374
- // ui/dist/assets/index-B7vzjIqN.css
216375
- var index_B7vzjIqN_default = "./index-B7vzjIqN-ma6ncj8z.css";
216546
+ // ui/dist/index.html
216547
+ var dist_default = "./index-wzc7qnpt.html";
216376
216548
 
216377
- // ui/dist/assets/index-D6lVFqDO.js
216378
- var index_D6lVFqDO_default = "./index-D6lVFqDO-3a1nn40g.js";
216549
+ // ui/dist/assets/index-CViVzJTS.js
216550
+ var index_CViVzJTS_default = "./index-CViVzJTS-xrkq8wea.js";
216379
216551
 
216380
- // ui/dist/index.html
216381
- var dist_default = "./index-g3cdpfvc.html";
216552
+ // ui/dist/assets/index-B5MwS93W.css
216553
+ var index_B5MwS93W_default = "./index-B5MwS93W-8btbkjwj.css";
216382
216554
 
216383
216555
  // src/assets/ui.ts
216384
216556
  var assets = {
216385
216557
  "/icon.png": icon_default,
216386
- "/assets/index-B7vzjIqN.css": index_B7vzjIqN_default,
216387
- "/assets/index-D6lVFqDO.js": index_D6lVFqDO_default,
216388
- "/index.html": dist_default
216558
+ "/index.html": dist_default,
216559
+ "/assets/index-CViVzJTS.js": index_CViVzJTS_default,
216560
+ "/assets/index-B5MwS93W.css": index_B5MwS93W_default
216389
216561
  };
216390
216562
 
216391
216563
  // src/middleware/ui.ts
216564
+ var __filename2 = fileURLToPath3(import.meta.url);
216565
+ var __dirname2 = dirname(__filename2);
216392
216566
  var mimeTypes = {
216393
216567
  ".html": "text/html",
216394
216568
  ".css": "text/css",
@@ -216411,13 +216585,15 @@ var uiStatic = async (req, res, next) => {
216411
216585
  const ext = filePath.substring(filePath.lastIndexOf("."));
216412
216586
  const mimeType = mimeTypes[ext] || "application/octet-stream";
216413
216587
  res.setHeader("Content-Type", mimeType);
216414
- const buffer = await readFile3(assetPath);
216588
+ const resolvedPath = isAbsolute(assetPath) ? assetPath : resolve(__dirname2, assetPath);
216589
+ const buffer = await readFile3(resolvedPath);
216415
216590
  res.send(buffer);
216416
216591
  } else {
216417
216592
  const indexPath = assets["/index.html"];
216418
216593
  if (indexPath) {
216419
216594
  res.setHeader("Content-Type", "text/html");
216420
- const buffer = await readFile3(indexPath);
216595
+ const resolvedIndexPath = isAbsolute(indexPath) ? indexPath : resolve(__dirname2, indexPath);
216596
+ const buffer = await readFile3(resolvedIndexPath);
216421
216597
  res.send(buffer);
216422
216598
  } else {
216423
216599
  next();
@@ -216427,15 +216603,20 @@ var uiStatic = async (req, res, next) => {
216427
216603
 
216428
216604
  // src/middleware/swagger.ts
216429
216605
  import { readFile as readFile4 } from "fs/promises";
216606
+ import { dirname as dirname2, resolve as resolve2, isAbsolute as isAbsolute2 } from "path";
216607
+ import { fileURLToPath as fileURLToPath4 } from "url";
216430
216608
 
216431
- // node_modules/swagger-ui-dist/swagger-ui.css
216432
- var swagger_ui_default = "./swagger-ui-bfxfcsxh.css";
216609
+ // node_modules/swagger-ui-dist/favicon-16x16.png
216610
+ var favicon_16x16_default = "./favicon-16x16-xwsy16sv.png";
216611
+
216612
+ // node_modules/swagger-ui-dist/swagger-ui.js
216613
+ var swagger_ui_default = "./swagger-ui-bycaq9jd.js";
216433
216614
 
216434
216615
  // node_modules/swagger-ui-dist/oauth2-redirect.js
216435
216616
  var oauth2_redirect_default = "./oauth2-redirect-bqxabm9x.js";
216436
216617
 
216437
- // node_modules/swagger-ui-dist/swagger-initializer.js
216438
- var swagger_initializer_default = "./swagger-initializer-55m7yyx2.js";
216618
+ // node_modules/swagger-ui-dist/swagger-ui.css
216619
+ var swagger_ui_default2 = "./swagger-ui-bfxfcsxh.css";
216439
216620
 
216440
216621
  // node_modules/swagger-ui-dist/swagger-ui-bundle.js
216441
216622
  var swagger_ui_bundle_default = "./swagger-ui-bundle-a3dgbj09.js";
@@ -216443,28 +216624,27 @@ var swagger_ui_bundle_default = "./swagger-ui-bundle-a3dgbj09.js";
216443
216624
  // node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js
216444
216625
  var swagger_ui_standalone_preset_default = "./swagger-ui-standalone-preset-9dtac9s6.js";
216445
216626
 
216446
- // node_modules/swagger-ui-dist/swagger-ui.js
216447
- var swagger_ui_default2 = "./swagger-ui-bycaq9jd.js";
216448
-
216449
- // node_modules/swagger-ui-dist/favicon-16x16.png
216450
- var favicon_16x16_default = "./favicon-16x16-xwsy16sv.png";
216627
+ // node_modules/swagger-ui-dist/swagger-initializer.js
216628
+ var swagger_initializer_default = "./swagger-initializer-55m7yyx2.js";
216451
216629
 
216452
216630
  // node_modules/swagger-ui-dist/favicon-32x32.png
216453
216631
  var favicon_32x32_default = "./favicon-32x32-zstv2hmc.png";
216454
216632
 
216455
216633
  // src/assets/swagger.ts
216456
216634
  var swaggerAssets = {
216457
- "/swagger-ui.css": swagger_ui_default,
216635
+ "/favicon-16x16.png": favicon_16x16_default,
216636
+ "/swagger-ui.js": swagger_ui_default,
216458
216637
  "/oauth2-redirect.js": oauth2_redirect_default,
216459
- "/swagger-initializer.js": swagger_initializer_default,
216638
+ "/swagger-ui.css": swagger_ui_default2,
216460
216639
  "/swagger-ui-bundle.js": swagger_ui_bundle_default,
216461
216640
  "/swagger-ui-standalone-preset.js": swagger_ui_standalone_preset_default,
216462
- "/swagger-ui.js": swagger_ui_default2,
216463
- "/favicon-16x16.png": favicon_16x16_default,
216641
+ "/swagger-initializer.js": swagger_initializer_default,
216464
216642
  "/favicon-32x32.png": favicon_32x32_default
216465
216643
  };
216466
216644
 
216467
216645
  // src/middleware/swagger.ts
216646
+ var __filename3 = fileURLToPath4(import.meta.url);
216647
+ var __dirname3 = dirname2(__filename3);
216468
216648
  var mimeTypes2 = {
216469
216649
  ".css": "text/css",
216470
216650
  ".js": "application/javascript",
@@ -216477,7 +216657,8 @@ var swaggerStatic = async (req, res, next) => {
216477
216657
  const ext = filePath.substring(filePath.lastIndexOf("."));
216478
216658
  const mimeType = mimeTypes2[ext] || "application/octet-stream";
216479
216659
  res.setHeader("Content-Type", mimeType);
216480
- const buffer = await readFile4(assetPath);
216660
+ const resolvedPath = isAbsolute2(assetPath) ? assetPath : resolve2(__dirname3, assetPath);
216661
+ const buffer = await readFile4(resolvedPath);
216481
216662
  res.send(buffer);
216482
216663
  } else {
216483
216664
  next();
@@ -216558,6 +216739,7 @@ async function run() {
216558
216739
  app.use((_, res) => res.status(404).send("404"));
216559
216740
  app.use(errorHandler());
216560
216741
  const server2 = app.listen(parseInt(config2.port), config2.host, () => {
216742
+ important(`MTranServer v${VERSION} is running!`);
216561
216743
  important(`Web UI: http://${config2.host}:${config2.port}/ui/`);
216562
216744
  important(`Swagger Docs: http://${config2.host}:${config2.port}/docs/`);
216563
216745
  important(`Log level set to: ${config2.logLevel}`);
@@ -216583,7 +216765,81 @@ async function run() {
216583
216765
  }
216584
216766
 
216585
216767
  // src/main.ts
216768
+ init_config();
216769
+ init_logger();
216770
+
216771
+ // src/server/download.ts
216586
216772
  init_logger();
216773
+ init_utils();
216774
+ async function DownloadCommand(globalRecords2, downloadModel2) {
216775
+ const downloadIndex = process.argv.indexOf("--download");
216776
+ const inputPairs = [];
216777
+ for (let i = downloadIndex + 1;i < process.argv.length; i++) {
216778
+ const arg = process.argv[i];
216779
+ if (arg.startsWith("-"))
216780
+ break;
216781
+ inputPairs.push(arg);
216782
+ }
216783
+ if (inputPairs.length === 0) {
216784
+ error("Please specify at least one language pair (e.g., --download en-zh)");
216785
+ process.exit(1);
216786
+ }
216787
+ const availablePairs = [];
216788
+ const recordsData = globalRecords2.data;
216789
+ for (const inputPair of inputPairs) {
216790
+ const delimiter = inputPair.includes("_") ? "_" : "-";
216791
+ const parts = inputPair.split(delimiter);
216792
+ if (parts.length !== 2) {
216793
+ warn(`Invalid language pair: ${inputPair}. Use format from-to or from_to.`);
216794
+ continue;
216795
+ }
216796
+ const fromLang = NormalizeLanguageCode(parts[0]);
216797
+ const toLang = NormalizeLanguageCode(parts[1]);
216798
+ const exactMatch = recordsData.find((r) => NormalizeLanguageCode(r.sourceLanguage) === fromLang && NormalizeLanguageCode(r.targetLanguage) === toLang);
216799
+ if (exactMatch) {
216800
+ availablePairs.push({ from: exactMatch.sourceLanguage, to: exactMatch.targetLanguage });
216801
+ } else {
216802
+ warn(`Could not find model for pair: ${inputPair} (normalized: ${fromLang}_${toLang})`);
216803
+ }
216804
+ }
216805
+ if (availablePairs.length === 0) {
216806
+ warn("No valid models found to download.");
216807
+ } else {
216808
+ info(`Found ${availablePairs.length} pair(s) to download...`);
216809
+ const unique = availablePairs.filter((v, i, a) => a.findIndex((t) => t.from === v.from && t.to === v.to) === i);
216810
+ for (const pair of unique) {
216811
+ await downloadModel2(pair.to, pair.from);
216812
+ }
216813
+ }
216814
+ process.exit(0);
216815
+ }
216816
+
216817
+ // src/server/languages.ts
216818
+ init_utils();
216819
+ async function LanguagesCommand(getLanguagePairs2) {
216820
+ const argIndex = process.argv.findIndex((a) => a === "--languages" || a === "--language");
216821
+ const filterArg = process.argv[argIndex + 1];
216822
+ const filter = filterArg && !filterArg.startsWith("-") ? NormalizeLanguageCode(filterArg) : null;
216823
+ const pairs = getLanguagePairs2();
216824
+ console.log("Available language pairs:");
216825
+ let currentRow = "";
216826
+ for (const pair of pairs.sort()) {
216827
+ const [from, to] = pair.split("_");
216828
+ if (filter && NormalizeLanguageCode(from) !== filter && NormalizeLanguageCode(to) !== filter) {
216829
+ continue;
216830
+ }
216831
+ if (currentRow.length > 80) {
216832
+ console.log(currentRow);
216833
+ currentRow = "";
216834
+ }
216835
+ currentRow += pair + " ";
216836
+ }
216837
+ if (currentRow)
216838
+ console.log(currentRow);
216839
+ process.exit(0);
216840
+ }
216841
+
216842
+ // src/main.ts
216587
216843
  if (process.argv.includes("--help") || process.argv.includes("-h")) {
216588
216844
  console.log(`
216589
216845
  MTranServer - Machine Translation Server
@@ -216607,6 +216863,10 @@ Options:
216607
216863
  --no-log-console Disable logging to console
216608
216864
  --check-update / --no-check-update Enable/Disable update check (default: true)
216609
216865
 
216866
+ Commands:
216867
+ --download <pairs...> Download models for specified pairs (e.g., --download en-zh zh-en)
216868
+ --language / --languages [filter] List available language pairs
216869
+
216610
216870
  Environment Variables:
216611
216871
  MT_HOST, MT_PORT, MT_LOG_LEVEL, MT_CONFIG_DIR, MT_MODEL_DIR,
216612
216872
  MT_LOG_DIR, MT_ENABLE_UI, MT_OFFLINE, MT_WORKER_IDLE_TIMEOUT,
@@ -216615,6 +216875,30 @@ Environment Variables:
216615
216875
  `);
216616
216876
  process.exit(0);
216617
216877
  }
216878
+ if (process.argv.includes("--languages") || process.argv.includes("--language") || process.argv.includes("--download")) {
216879
+ try {
216880
+ const config2 = getConfig();
216881
+ if (config2.enableOfflineMode) {
216882
+ error("This command is not available in offline mode.");
216883
+ error("Please disable offline mode to use this feature.");
216884
+ process.exit(1);
216885
+ }
216886
+ const models2 = await Promise.resolve().then(() => (init_models(), exports_models));
216887
+ await models2.initRecords();
216888
+ if (!models2.globalRecords) {
216889
+ throw new Error("Failed to Initialize records");
216890
+ }
216891
+ if (process.argv.includes("--languages") || process.argv.includes("--language")) {
216892
+ LanguagesCommand(models2.getLanguagePairs);
216893
+ }
216894
+ if (process.argv.includes("--download")) {
216895
+ DownloadCommand(models2.globalRecords, models2.downloadModel);
216896
+ }
216897
+ } catch (error2) {
216898
+ fatal("Error:", error2);
216899
+ process.exit(1);
216900
+ }
216901
+ }
216618
216902
  process.on("uncaughtException", (error2) => {
216619
216903
  fatal("Uncaught Exception:", error2);
216620
216904
  });
@@ -216625,5 +216909,5 @@ run().catch((error2) => {
216625
216909
  fatal("Failed to start server:", error2);
216626
216910
  });
216627
216911
 
216628
- //# debugId=CB75FB2114D7B08B64756E2164756E21
216912
+ //# debugId=91A4B0E803737D0C64756E2164756E21
216629
216913
  //# sourceMappingURL=main.js.map