@invoice-sdk/widget 1.67.0 → 1.67.2

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.
@@ -10,7 +10,7 @@ var mA = (i, A, e) => A in i ? Ee(i, A, { enumerable: !0, configurable: !0, writ
10
10
  Be.call(A, e) && mA(i, e, A[e]);
11
11
  return i;
12
12
  }, v = (i, A) => Ie(i, Qe(A));
13
- var oA = (i, A, e) => new Promise((t, n) => {
13
+ var sA = (i, A, e) => new Promise((t, n) => {
14
14
  var r = (g) => {
15
15
  try {
16
16
  s(e.next(g));
@@ -67,7 +67,7 @@ const l = (i) => typeof i == "string", K = () => {
67
67
  k: r
68
68
  } = V(i, A, Object);
69
69
  n[r] = n[r] || [], n[r].push(e);
70
- }, eA = (i, A) => {
70
+ }, tA = (i, A) => {
71
71
  const {
72
72
  obj: e,
73
73
  k: t
@@ -75,8 +75,8 @@ const l = (i) => typeof i == "string", K = () => {
75
75
  if (e && Object.prototype.hasOwnProperty.call(e, t))
76
76
  return e[t];
77
77
  }, he = (i, A, e) => {
78
- const t = eA(i, e);
79
- return t !== void 0 ? t : eA(A, e);
78
+ const t = tA(i, e);
79
+ return t !== void 0 ? t : tA(A, e);
80
80
  }, MA = (i, A, e) => {
81
81
  for (const t in A)
82
82
  t !== "__proto__" && t !== "constructor" && (t in i ? l(i[t]) || i[t] instanceof String || l(A[t]) || A[t] instanceof String ? e && (i[t] = A[t]) : MA(i[t], A[t], e) : i[t] = A[t]);
@@ -150,7 +150,7 @@ const me = [" ", ",", "?", "!", ";"], ye = new ve(20), Re = (i, A, e) => {
150
150
  (t = (e = console == null ? void 0 : console[i]) == null ? void 0 : e.apply) == null || t.call(e, console, A);
151
151
  }
152
152
  };
153
- class tA {
153
+ class nA {
154
154
  constructor(A, e = {}) {
155
155
  this.init(A, e);
156
156
  }
@@ -173,16 +173,16 @@ class tA {
173
173
  return n && !this.debug ? null : (l(A[0]) && (A[0] = `${t}${this.prefix} ${A[0]}`), this.logger[e](A));
174
174
  }
175
175
  create(A) {
176
- return new tA(this.logger, B({
176
+ return new nA(this.logger, B({
177
177
  prefix: `${this.prefix}:${A}:`
178
178
  }, this.options));
179
179
  }
180
180
  clone(A) {
181
- return A = A || this.options, A.prefix = A.prefix || this.prefix, new tA(this.logger, A);
181
+ return A = A || this.options, A.prefix = A.prefix || this.prefix, new nA(this.logger, A);
182
182
  }
183
183
  }
184
- var k = new tA();
185
- class rA {
184
+ var k = new nA();
185
+ class oA {
186
186
  constructor() {
187
187
  this.observers = {};
188
188
  }
@@ -212,7 +212,7 @@ class rA {
212
212
  });
213
213
  }
214
214
  }
215
- class SA extends rA {
215
+ class SA extends oA {
216
216
  constructor(A, e = {
217
217
  ns: ["translation"],
218
218
  defaultNS: "translation"
@@ -231,7 +231,7 @@ class SA extends rA {
231
231
  const r = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator, o = n.ignoreJSONStructure !== void 0 ? n.ignoreJSONStructure : this.options.ignoreJSONStructure;
232
232
  let s;
233
233
  A.indexOf(".") > -1 ? s = A.split(".") : (s = [A, e], t && (Array.isArray(t) ? s.push(...t) : l(t) && r ? s.push(...t.split(r)) : s.push(t)));
234
- const g = eA(this.data, s);
234
+ const g = tA(this.data, s);
235
235
  return !g && !e && !t && A.indexOf(".") > -1 && (A = s[0], e = s[1], t = s.slice(2).join(".")), g || !o || !l(t) ? g : QA((E = (a = this.data) == null ? void 0 : a[A]) == null ? void 0 : E[e], t, r);
236
236
  }
237
237
  addResource(A, e, t, n, r = {
@@ -256,7 +256,7 @@ class SA extends rA {
256
256
  }) {
257
257
  let s = [A, e];
258
258
  A.indexOf(".") > -1 && (s = A.split("."), n = t, t = e, e = s[1]), this.addNamespaces(e);
259
- let g = eA(this.data, s) || {};
259
+ let g = tA(this.data, s) || {};
260
260
  o.skipCopy || (t = JSON.parse(JSON.stringify(t))), n ? MA(g, t, r) : g = B(B({}, g), t), wA(this.data, s, g), o.silent || this.emit("added", A, e, t);
261
261
  }
262
262
  removeResourceBundle(A, e) {
@@ -292,7 +292,7 @@ var YA = {
292
292
  }
293
293
  };
294
294
  const OA = {}, kA = (i) => !l(i) && typeof i != "boolean" && typeof i != "number";
295
- class nA extends rA {
295
+ class iA extends oA {
296
296
  constructor(A, e = {}) {
297
297
  super(), le(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], A, this), this.options = e, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = k.create("translator");
298
298
  }
@@ -357,7 +357,7 @@ class nA extends rA {
357
357
  } : s;
358
358
  const Q = this.resolve(A, n);
359
359
  let I = Q == null ? void 0 : Q.res;
360
- const u = (Q == null ? void 0 : Q.usedKey) || s, f = (Q == null ? void 0 : Q.exactUsedKey) || s, P = ["[object Number]", "[object Function]", "[object RegExp]"], R = n.joinArrays !== void 0 ? n.joinArrays : this.options.joinArrays, X = !this.i18nFormat || this.i18nFormat.handleAsObject, p = n.count !== void 0 && !l(n.count), b = nA.hasDefaultValue(n), Y = p ? this.pluralResolver.getSuffix(C, n.count, n) : "", L = n.ordinal && p ? this.pluralResolver.getSuffix(C, n.count, {
360
+ const u = (Q == null ? void 0 : Q.usedKey) || s, f = (Q == null ? void 0 : Q.exactUsedKey) || s, P = ["[object Number]", "[object Function]", "[object RegExp]"], R = n.joinArrays !== void 0 ? n.joinArrays : this.options.joinArrays, X = !this.i18nFormat || this.i18nFormat.handleAsObject, p = n.count !== void 0 && !l(n.count), b = iA.hasDefaultValue(n), Y = p ? this.pluralResolver.getSuffix(C, n.count, n) : "", L = n.ordinal && p ? this.pluralResolver.getSuffix(C, n.count, {
361
361
  ordinal: !1
362
362
  }) : "", q = p && !n.ordinal && n.count === 0, m = q && n[`defaultValue${this.options.pluralSeparator}zero`] || n[`defaultValue${Y}`] || n[`defaultValue${L}`] || n.defaultValue;
363
363
  let d = I;
@@ -644,7 +644,7 @@ class we {
644
644
  const XA = (i, A, e, t = ".", n = !0) => {
645
645
  let r = he(i, A, e);
646
646
  return !r && n && l(e) && (r = QA(i, e, t), r === void 0 && (r = QA(A, e, t))), r;
647
- }, sA = (i) => i.replace(/\$/g, "$$$$");
647
+ }, gA = (i) => i.replace(/\$/g, "$$$$");
648
648
  class Se {
649
649
  constructor(A = {}) {
650
650
  var e;
@@ -701,10 +701,10 @@ class Se {
701
701
  const E = (n == null ? void 0 : n.missingInterpolationHandler) || this.options.missingInterpolationHandler, C = ((Q = n == null ? void 0 : n.interpolation) == null ? void 0 : Q.skipOnVariables) !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
702
702
  return [{
703
703
  regex: this.regexpUnescape,
704
- safeValue: (I) => sA(I)
704
+ safeValue: (I) => gA(I)
705
705
  }, {
706
706
  regex: this.regexp,
707
- safeValue: (I) => this.escapeValue ? sA(this.escape(I)) : sA(I)
707
+ safeValue: (I) => this.escapeValue ? gA(this.escape(I)) : gA(I)
708
708
  }].forEach((I) => {
709
709
  for (s = 0; r = I.regex.exec(A); ) {
710
710
  const u = r[1].trim();
@@ -856,7 +856,7 @@ class be {
856
856
  const Le = (i, A) => {
857
857
  i.pending[A] !== void 0 && (delete i.pending[A], i.pendingCount--);
858
858
  };
859
- class De extends rA {
859
+ class De extends oA {
860
860
  constructor(A, e, t, n = {}) {
861
861
  var r, o;
862
862
  super(), this.backend = A, this.store = e, this.services = t, this.languageUtils = t.languageUtils, this.options = n, this.logger = k.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = n.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = n.maxRetries >= 0 ? n.maxRetries : 5, this.retryTimeout = n.retryTimeout >= 1 ? n.retryTimeout : 350, this.state = {}, this.queue = [], (o = (r = this.backend) == null ? void 0 : r.init) == null || o.call(r, t, n.backend, n);
@@ -1053,7 +1053,7 @@ const HA = () => ({
1053
1053
  typeof i[e] == "function" && (i[e] = i[e].bind(i));
1054
1054
  });
1055
1055
  };
1056
- class G extends rA {
1056
+ class G extends oA {
1057
1057
  constructor(A = {}, e) {
1058
1058
  if (super(), this.options = TA(A), this.services = {}, this.logger = k, this.modules = {
1059
1059
  external: []
@@ -1084,7 +1084,7 @@ class G extends rA {
1084
1084
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1085
1085
  }, C.backendConnector = new De(n(this.modules.backend), C.resourceStore, C, this.options), C.backendConnector.on("*", (Q, ...I) => {
1086
1086
  this.emit(Q, ...I);
1087
- }), this.modules.languageDetector && (C.languageDetector = n(this.modules.languageDetector), C.languageDetector.init && C.languageDetector.init(C, this.options.detection, this.options)), this.modules.i18nFormat && (C.i18nFormat = n(this.modules.i18nFormat), C.i18nFormat.init && C.i18nFormat.init(this)), this.translator = new nA(this.services, this.options), this.translator.on("*", (Q, ...I) => {
1087
+ }), this.modules.languageDetector && (C.languageDetector = n(this.modules.languageDetector), C.languageDetector.init && C.languageDetector.init(C, this.options.detection, this.options)), this.modules.i18nFormat && (C.i18nFormat = n(this.modules.i18nFormat), C.i18nFormat.init && C.i18nFormat.init(this)), this.translator = new iA(this.services, this.options), this.translator.on("*", (Q, ...I) => {
1088
1088
  this.emit(Q, ...I);
1089
1089
  }), this.modules.external.forEach((Q) => {
1090
1090
  Q.init && Q.init(this);
@@ -1252,7 +1252,7 @@ class G extends rA {
1252
1252
  const s = Object.keys(this.store.data).reduce((g, a) => (g[a] = B({}, this.store.data[a]), g[a] = Object.keys(g[a]).reduce((E, C) => (E[C] = B({}, g[a][C]), E), g[a]), g), {});
1253
1253
  r.store = new SA(s, n), r.services.resourceStore = r.store;
1254
1254
  }
1255
- return r.translator = new nA(r.services, n), r.translator.on("*", (s, ...g) => {
1255
+ return r.translator = new iA(r.services, n), r.translator.on("*", (s, ...g) => {
1256
1256
  r.emit(s, ...g);
1257
1257
  }), r.init(n, e), r.translator.options = n, r.translator.backendConnector.services.utils = {
1258
1258
  hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
@@ -2075,10 +2075,10 @@ var x = typeof fetch == "function" ? fetch : void 0;
2075
2075
  typeof global != "undefined" && global.fetch ? x = global.fetch : typeof window != "undefined" && window.fetch && (x = window.fetch);
2076
2076
  var M;
2077
2077
  ee() && (typeof global != "undefined" && global.XMLHttpRequest ? M = global.XMLHttpRequest : typeof window != "undefined" && window.XMLHttpRequest && (M = window.XMLHttpRequest));
2078
- var iA;
2079
- typeof ActiveXObject == "function" && (typeof global != "undefined" && global.ActiveXObject ? iA = global.ActiveXObject : typeof window != "undefined" && window.ActiveXObject && (iA = window.ActiveXObject));
2078
+ var rA;
2079
+ typeof ActiveXObject == "function" && (typeof global != "undefined" && global.ActiveXObject ? rA = global.ActiveXObject : typeof window != "undefined" && window.ActiveXObject && (rA = window.ActiveXObject));
2080
2080
  typeof x != "function" && (x = void 0);
2081
- if (!x && !M && !iA)
2081
+ if (!x && !M && !rA)
2082
2082
  try {
2083
2083
  import("./browser-ponyfill-BxQPfTD2.js").then((i) => i.b).then(function(i) {
2084
2084
  x = i.default;
@@ -2140,7 +2140,7 @@ var BA = function(A, e) {
2140
2140
  }, ka = function(A, e, t, n) {
2141
2141
  t && T(t) === "object" && (t = BA("", t).slice(1)), A.queryStringParams && (e = BA(e, A.queryStringParams));
2142
2142
  try {
2143
- var r = M ? new M() : new iA("MSXML2.XMLHTTP.3.0");
2143
+ var r = M ? new M() : new rA("MSXML2.XMLHTTP.3.0");
2144
2144
  r.open(t ? "POST" : "GET", e, 1), A.crossDomain || r.setRequestHeader("X-Requested-With", "XMLHttpRequest"), r.withCredentials = !!A.withCredentials, t && r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), r.overrideMimeType && r.overrideMimeType("application/json");
2145
2145
  var o = A.customHeaders;
2146
2146
  if (o = typeof o == "function" ? o() : o, o)
@@ -2181,7 +2181,7 @@ function FA(i, A) {
2181
2181
  }
2182
2182
  return e;
2183
2183
  }
2184
- function gA(i) {
2184
+ function aA(i) {
2185
2185
  for (var A = 1; A < arguments.length; A++) {
2186
2186
  var e = arguments[A] != null ? arguments[A] : {};
2187
2187
  A % 2 ? FA(Object(e), !0).forEach(function(t) {
@@ -2256,7 +2256,7 @@ var Ha = function() {
2256
2256
  key: "init",
2257
2257
  value: function(e) {
2258
2258
  var t = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2259
- if (this.services = e, this.options = gA(gA(gA({}, Ha()), this.options || {}), n), this.allOptions = r, this.services && this.options.reloadInterval) {
2259
+ if (this.services = e, this.options = aA(aA(aA({}, Ha()), this.options || {}), n), this.allOptions = r, this.services && this.options.reloadInterval) {
2260
2260
  var o = setInterval(function() {
2261
2261
  return t.reload();
2262
2262
  }, this.options.reloadInterval);
@@ -2409,13 +2409,13 @@ function Ja(i = "dev") {
2409
2409
  };
2410
2410
  return A[i] || A.dev;
2411
2411
  }
2412
- let AA = null, lA = !1;
2412
+ let eA = null, lA = !1;
2413
2413
  function re(i) {
2414
2414
  if (!["dev", "uat", "prod", "stag", "pilot"].includes(i))
2415
2415
  throw new Error(
2416
2416
  `Invalid mode: ${i}. Valid modes are 'dev', 'uat', 'prod', 'stag', 'pilot'.`
2417
2417
  );
2418
- AA = i, lA = !0;
2418
+ eA = i, lA = !0;
2419
2419
  try {
2420
2420
  localStorage.setItem("currentMode", i);
2421
2421
  } catch (A) {
@@ -2423,12 +2423,12 @@ function re(i) {
2423
2423
  }
2424
2424
  }
2425
2425
  function Na() {
2426
- if (lA && AA)
2427
- return AA;
2426
+ if (lA && eA)
2427
+ return eA;
2428
2428
  try {
2429
2429
  const i = localStorage.getItem("currentMode");
2430
2430
  if (i)
2431
- return AA = i, lA = !0, i;
2431
+ return eA = i, lA = !0, i;
2432
2432
  } catch (i) {
2433
2433
  console.warn("Could not read from localStorage:", i);
2434
2434
  }
@@ -2605,7 +2605,7 @@ const Ua = "data:image/svg+xml,%3csvg%20width='79'%20height='32'%20viewBox='0%20
2605
2605
  viettel: { isActive: !1 }
2606
2606
  }
2607
2607
  }
2608
- }, aA = /* @__PURE__ */ new Map();
2608
+ }, CA = /* @__PURE__ */ new Map();
2609
2609
  function F(i, A) {
2610
2610
  const e = B({}, i);
2611
2611
  for (const t in A)
@@ -2622,11 +2622,11 @@ function Wa(i, A) {
2622
2622
  function se(i, A, e) {
2623
2623
  var n, r, o, s;
2624
2624
  const t = `${i}:${A}:${e}`;
2625
- if (aA.has(t))
2626
- return aA.get(t);
2625
+ if (CA.has(t))
2626
+ return CA.get(t);
2627
2627
  try {
2628
2628
  let g = F({}, oe[e]);
2629
- return (n = VA[i]) != null && n[e] && (g = F(g, VA[i][e])), (r = ZA[A]) != null && r[e] && (g = F(g, ZA[A][e])), (s = (o = GA[i]) == null ? void 0 : o[A]) != null && s[e] && (g = F(g, GA[i][A][e])), Wa(g, e) ? (aA.set(t, g), g) : (console.error(`[SettingsManager] Invalid configuration for ${i}:${A}:${e}`), null);
2629
+ return (n = VA[i]) != null && n[e] && (g = F(g, VA[i][e])), (r = ZA[A]) != null && r[e] && (g = F(g, ZA[A][e])), (s = (o = GA[i]) == null ? void 0 : o[A]) != null && s[e] && (g = F(g, GA[i][A][e])), Wa(g, e) ? (CA.set(t, g), g) : (console.error(`[SettingsManager] Invalid configuration for ${i}:${A}:${e}`), null);
2630
2630
  } catch (g) {
2631
2631
  return console.error(`[SettingsManager] Error getting settings for ${i}:${A}:${e}:`, g), null;
2632
2632
  }
@@ -2650,53 +2650,57 @@ function Va(i, A) {
2650
2650
  const e = ["dev", "pilot", "stag", "uat", "prod"], t = ["bvb", "ocb", "shb"];
2651
2651
  return e.includes(i) ? t.includes(A) ? !0 : (console.error(`[SettingsManager] Invalid bank: ${A}`), !1) : (console.error(`[SettingsManager] Invalid environment: ${i}`), !1);
2652
2652
  }
2653
- const CA = /* @__PURE__ */ new Map();
2653
+ const EA = /* @__PURE__ */ new Map();
2654
2654
  function Za(i = "dev", A = "bvb") {
2655
2655
  const e = `${i}:${A}`;
2656
- if (CA.has(e))
2657
- return CA.get(e);
2656
+ if (EA.has(e))
2657
+ return EA.get(e);
2658
2658
  const t = Fa(i, A);
2659
- return CA.set(e, t), t;
2659
+ return EA.set(e, t), t;
2660
2660
  }
2661
2661
  function _a(i, A, e) {
2662
2662
  return Va(i, A) ? se(i, A, e) : (console.error(`[SettingsAdapter] Invalid environment or bank: ${i}, ${A}`), null);
2663
2663
  }
2664
- let EA = null, IA = null;
2664
+ let AA = null, IA = null;
2665
2665
  function AC(i) {
2666
- return oA(this, null, function* () {
2666
+ return sA(this, null, function* () {
2667
2667
  if (i.mode && re(i.mode), i.language && ge(i.language), !IA) {
2668
- const { InvoiceRegisterWidget: t } = yield import("./widget-C_Dabu05.js");
2668
+ const { InvoiceRegisterWidget: t } = yield import("./widget-BUVsuvPc.js");
2669
2669
  IA = t;
2670
2670
  }
2671
2671
  const A = typeof i.selector == "string" ? document.querySelector(i.selector) : i.selector;
2672
2672
  if (!A)
2673
2673
  throw new Error(`[WidgetSDK] Mount element not found: ${i.selector}`);
2674
- function e() {
2675
- A.innerHTML = "", i.onClose && i.onClose();
2676
- }
2677
- return IA(
2674
+ const e = yield IA(
2678
2675
  A,
2679
- e,
2676
+ i.onClose || (() => {
2677
+ }),
2680
2678
  i.onShowPolicy || (() => {
2681
2679
  }),
2682
2680
  i.data || {},
2683
2681
  i.theme
2684
- ), { destroy: e };
2682
+ );
2683
+ return { destroy: () => {
2684
+ e && e.destroy && e.destroy();
2685
+ } };
2685
2686
  });
2686
2687
  }
2687
2688
  function eC(i) {
2688
- return oA(this, null, function* () {
2689
- if (i.mode && re(i.mode), i.language && ge(i.language), !EA) {
2690
- const { EContractWidget: t } = yield import("./widget-C_Dabu05.js");
2691
- EA = t;
2689
+ return sA(this, null, function* () {
2690
+ if (i.mode && re(i.mode), i.language && ge(i.language), !AA) {
2691
+ const { EContractWidget: t } = yield import("./widget-BUVsuvPc.js");
2692
+ AA = t;
2692
2693
  }
2693
2694
  const A = typeof i.selector == "string" ? document.querySelector(i.selector) : i.selector;
2694
2695
  if (!A)
2695
2696
  throw new Error(`[WidgetSDK] Mount element not found: ${i.selector}`);
2696
- function e() {
2697
- A.innerHTML = "", i.onClose && i.onClose();
2698
- }
2699
- return EA(A, e, i.data || {}, i.theme), { destroy: e };
2697
+ AA(A, i.onClose || (() => {
2698
+ }), i.data || {}, i.theme);
2699
+ const e = yield AA(A, i.onClose || (() => {
2700
+ }), i.data || {}, i.theme);
2701
+ return { destroy: () => {
2702
+ e && e.destroy && e.destroy();
2703
+ } };
2700
2704
  });
2701
2705
  }
2702
2706
  let uA = /* @__PURE__ */ new Set();
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { h as i, i as s, e as a, r as g, s as r, u as n } from "./index-o2xH290j.js";
1
+ import { h as i, i as s, e as a, r as g, s as r, u as n } from "./index-DWLcFwrQ.js";
2
2
  export {
3
3
  i as getSettings,
4
4
  s as init,