@microblink/blinkid-core 7.4.3 → 7.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/blinkid-core.js +18 -18
  2. package/dist/resources/blinkid-worker.js +445 -399
  3. package/dist/resources/full/advanced/BlinkIdModule.data +0 -0
  4. package/dist/resources/full/advanced/BlinkIdModule.js +124 -138
  5. package/dist/resources/full/advanced/BlinkIdModule.wasm +0 -0
  6. package/dist/resources/full/advanced-threads/BlinkIdModule.data +0 -0
  7. package/dist/resources/full/advanced-threads/BlinkIdModule.js +145 -162
  8. package/dist/resources/full/advanced-threads/BlinkIdModule.wasm +0 -0
  9. package/dist/resources/full/basic/BlinkIdModule.data +0 -0
  10. package/dist/resources/full/basic/BlinkIdModule.js +120 -134
  11. package/dist/resources/full/basic/BlinkIdModule.wasm +0 -0
  12. package/dist/resources/lightweight/advanced/BlinkIdModule.data +0 -0
  13. package/dist/resources/lightweight/advanced/BlinkIdModule.js +124 -137
  14. package/dist/resources/lightweight/advanced/BlinkIdModule.wasm +0 -0
  15. package/dist/resources/lightweight/advanced-threads/BlinkIdModule.data +0 -0
  16. package/dist/resources/lightweight/advanced-threads/BlinkIdModule.js +145 -162
  17. package/dist/resources/lightweight/advanced-threads/BlinkIdModule.wasm +0 -0
  18. package/dist/resources/lightweight/basic/BlinkIdModule.data +0 -0
  19. package/dist/resources/lightweight/basic/BlinkIdModule.js +120 -133
  20. package/dist/resources/lightweight/basic/BlinkIdModule.wasm +0 -0
  21. package/dist/resources/size-manifest.json +12 -12
  22. package/package.json +1 -1
  23. package/types/deviceInfo/createDerivedDeviceInfo.d.ts +1 -1
  24. package/types/deviceInfo/createDerivedDeviceInfo.d.ts.map +1 -1
  25. package/types/deviceInfo/deviceInfo.d.ts +1 -1
  26. package/types/deviceInfo/deviceInfo.d.ts.map +1 -1
  27. package/types/deviceInfo/getBrowserFromUserAgent.d.ts.map +1 -1
  28. package/types/index.d.ts +1 -1
  29. package/types/index.d.ts.map +1 -1
  30. package/types/index.rollup.d.ts +197 -27
@@ -1,26 +1,34 @@
1
- var Oe = Object.defineProperty;
1
+ var Le = Object.defineProperty;
2
2
  var J = (e) => {
3
3
  throw TypeError(e);
4
4
  };
5
- var Le = (e, t, r) => t in e ? Oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
6
- var B = (e, t, r) => Le(e, typeof t != "symbol" ? t + "" : t, r), $ = (e, t, r) => t.has(e) || J("Cannot " + r);
7
- var m = (e, t, r) => ($(e, t, "read from private field"), r ? r.call(e) : t.get(e)), S = (e, t, r) => t.has(e) ? J("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), x = (e, t, r, o) => ($(e, t, "write to private field"), o ? o.call(e, r) : t.set(e, r), r), v = (e, t, r) => ($(e, t, "access private method"), r);
5
+ var Oe = (e, t, r) => t in e ? Le(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
6
+ var x = (e, t, r) => Oe(e, typeof t != "symbol" ? t + "" : t, r), $ = (e, t, r) => t.has(e) || J("Cannot " + r);
7
+ var d = (e, t, r) => ($(e, t, "read from private field"), r ? r.call(e) : t.get(e)), p = (e, t, r) => t.has(e) ? J("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), y = (e, t, r, s) => ($(e, t, "write to private field"), s ? s.call(e, r) : t.set(e, r), r), R = (e, t, r) => ($(e, t, "access private method"), r);
8
+ var Q = (e, t, r, s) => ({
9
+ set _(n) {
10
+ y(e, t, n, r);
11
+ },
12
+ get _() {
13
+ return d(e, t, s);
14
+ }
15
+ });
8
16
  /**
9
17
  * @license
10
18
  * Copyright 2019 Google LLC
11
19
  * SPDX-License-Identifier: Apache-2.0
12
20
  */
13
- const re = Symbol("Comlink.proxy"), Ae = Symbol("Comlink.endpoint"), Re = Symbol("Comlink.releaseProxy"), z = Symbol("Comlink.finalizer"), N = Symbol("Comlink.thrown"), ne = (e) => typeof e == "object" && e !== null || typeof e == "function", ke = {
14
- canHandle: (e) => ne(e) && e[re],
21
+ const ae = Symbol("Comlink.proxy"), Re = Symbol("Comlink.endpoint"), ve = Symbol("Comlink.releaseProxy"), z = Symbol("Comlink.finalizer"), W = Symbol("Comlink.thrown"), ie = (e) => typeof e == "object" && e !== null || typeof e == "function", Ae = {
22
+ canHandle: (e) => ie(e) && e[ae],
15
23
  serialize(e) {
16
24
  const { port1: t, port2: r } = new MessageChannel();
17
- return V(e, t), [r, [r]];
25
+ return H(e, t), [r, [r]];
18
26
  },
19
27
  deserialize(e) {
20
- return e.start(), ze(e);
28
+ return e.start(), Ie(e);
21
29
  }
22
30
  }, Ue = {
23
- canHandle: (e) => ne(e) && N in e,
31
+ canHandle: (e) => ie(e) && W in e,
24
32
  serialize({ value: e }) {
25
33
  let t;
26
34
  return e instanceof Error ? t = {
@@ -35,48 +43,48 @@ const re = Symbol("Comlink.proxy"), Ae = Symbol("Comlink.endpoint"), Re = Symbol
35
43
  deserialize(e) {
36
44
  throw e.isError ? Object.assign(new Error(e.value.message), e.value) : e.value;
37
45
  }
38
- }, se = /* @__PURE__ */ new Map([
39
- ["proxy", ke],
46
+ }, ce = /* @__PURE__ */ new Map([
47
+ ["proxy", Ae],
40
48
  ["throw", Ue]
41
49
  ]);
42
- function Me(e, t) {
50
+ function Te(e, t) {
43
51
  for (const r of e)
44
52
  if (t === r || r === "*" || r instanceof RegExp && r.test(t))
45
53
  return !0;
46
54
  return !1;
47
55
  }
48
- function V(e, t = globalThis, r = ["*"]) {
49
- t.addEventListener("message", function o(s) {
50
- if (!s || !s.data)
56
+ function H(e, t = globalThis, r = ["*"]) {
57
+ t.addEventListener("message", function s(n) {
58
+ if (!n || !n.data)
51
59
  return;
52
- if (!Me(r, s.origin)) {
53
- console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
60
+ if (!Te(r, n.origin)) {
61
+ console.warn(`Invalid origin '${n.origin}' for comlink proxy`);
54
62
  return;
55
63
  }
56
- const { id: n, type: u, path: a } = Object.assign({ path: [] }, s.data), c = (s.data.argumentList || []).map(E);
64
+ const { id: o, type: c, path: a } = Object.assign({ path: [] }, n.data), l = (n.data.argumentList || []).map(k);
57
65
  let i;
58
66
  try {
59
- const l = a.slice(0, -1).reduce((f, p) => f[p], e), d = a.reduce((f, p) => f[p], e);
60
- switch (u) {
67
+ const u = a.slice(0, -1).reduce((h, w) => h[w], e), f = a.reduce((h, w) => h[w], e);
68
+ switch (c) {
61
69
  case "GET":
62
- i = d;
70
+ i = f;
63
71
  break;
64
72
  case "SET":
65
- l[a.slice(-1)[0]] = E(s.data.value), i = !0;
73
+ u[a.slice(-1)[0]] = k(n.data.value), i = !0;
66
74
  break;
67
75
  case "APPLY":
68
- i = d.apply(l, c);
76
+ i = f.apply(u, l);
69
77
  break;
70
78
  case "CONSTRUCT":
71
79
  {
72
- const f = new d(...c);
73
- i = le(f);
80
+ const h = new f(...l);
81
+ i = me(h);
74
82
  }
75
83
  break;
76
84
  case "ENDPOINT":
77
85
  {
78
- const { port1: f, port2: p } = new MessageChannel();
79
- V(e, p), i = ce(f, [f]);
86
+ const { port1: h, port2: w } = new MessageChannel();
87
+ H(e, w), i = fe(h, [h]);
80
88
  }
81
89
  break;
82
90
  case "RELEASE":
@@ -85,146 +93,146 @@ function V(e, t = globalThis, r = ["*"]) {
85
93
  default:
86
94
  return;
87
95
  }
88
- } catch (l) {
89
- i = { value: l, [N]: 0 };
96
+ } catch (u) {
97
+ i = { value: u, [W]: 0 };
90
98
  }
91
- Promise.resolve(i).catch((l) => ({ value: l, [N]: 0 })).then((l) => {
92
- const [d, f] = j(l);
93
- t.postMessage(Object.assign(Object.assign({}, d), { id: n }), f), u === "RELEASE" && (t.removeEventListener("message", o), oe(t), z in e && typeof e[z] == "function" && e[z]());
94
- }).catch((l) => {
95
- const [d, f] = j({
99
+ Promise.resolve(i).catch((u) => ({ value: u, [W]: 0 })).then((u) => {
100
+ const [f, h] = j(u);
101
+ t.postMessage(Object.assign(Object.assign({}, f), { id: o }), h), c === "RELEASE" && (t.removeEventListener("message", s), le(t), z in e && typeof e[z] == "function" && e[z]());
102
+ }).catch((u) => {
103
+ const [f, h] = j({
96
104
  value: new TypeError("Unserializable return value"),
97
- [N]: 0
105
+ [W]: 0
98
106
  });
99
- t.postMessage(Object.assign(Object.assign({}, d), { id: n }), f);
107
+ t.postMessage(Object.assign(Object.assign({}, f), { id: o }), h);
100
108
  });
101
109
  }), t.start && t.start();
102
110
  }
103
- function Te(e) {
111
+ function Me(e) {
104
112
  return e.constructor.name === "MessagePort";
105
113
  }
106
- function oe(e) {
107
- Te(e) && e.close();
114
+ function le(e) {
115
+ Me(e) && e.close();
108
116
  }
109
- function ze(e, t) {
117
+ function Ie(e, t) {
110
118
  const r = /* @__PURE__ */ new Map();
111
- return e.addEventListener("message", function(s) {
112
- const { data: n } = s;
113
- if (!n || !n.id)
119
+ return e.addEventListener("message", function(n) {
120
+ const { data: o } = n;
121
+ if (!o || !o.id)
114
122
  return;
115
- const u = r.get(n.id);
116
- if (u)
123
+ const c = r.get(o.id);
124
+ if (c)
117
125
  try {
118
- u(n);
126
+ c(o);
119
127
  } finally {
120
- r.delete(n.id);
128
+ r.delete(o.id);
121
129
  }
122
- }), D(e, r, [], t);
130
+ }), _(e, r, [], t);
123
131
  }
124
- function k(e) {
132
+ function M(e) {
125
133
  if (e)
126
134
  throw new Error("Proxy has been released and is not useable");
127
135
  }
128
- function ae(e) {
129
- return O(e, /* @__PURE__ */ new Map(), {
136
+ function ue(e) {
137
+ return L(e, /* @__PURE__ */ new Map(), {
130
138
  type: "RELEASE"
131
139
  }).then(() => {
132
- oe(e);
140
+ le(e);
133
141
  });
134
142
  }
135
- const I = /* @__PURE__ */ new WeakMap(), W = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e) => {
136
- const t = (I.get(e) || 0) - 1;
137
- I.set(e, t), t === 0 && ae(e);
143
+ const B = /* @__PURE__ */ new WeakMap(), C = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e) => {
144
+ const t = (B.get(e) || 0) - 1;
145
+ B.set(e, t), t === 0 && ue(e);
138
146
  });
139
147
  function Ne(e, t) {
140
- const r = (I.get(t) || 0) + 1;
141
- I.set(t, r), W && W.register(e, t, e);
148
+ const r = (B.get(t) || 0) + 1;
149
+ B.set(t, r), C && C.register(e, t, e);
142
150
  }
143
- function Ie(e) {
144
- W && W.unregister(e);
151
+ function ze(e) {
152
+ C && C.unregister(e);
145
153
  }
146
- function D(e, t, r = [], o = function() {
154
+ function _(e, t, r = [], s = function() {
147
155
  }) {
148
- let s = !1;
149
- const n = new Proxy(o, {
150
- get(u, a) {
151
- if (k(s), a === Re)
156
+ let n = !1;
157
+ const o = new Proxy(s, {
158
+ get(c, a) {
159
+ if (M(n), a === ve)
152
160
  return () => {
153
- Ie(n), ae(e), t.clear(), s = !0;
161
+ ze(o), ue(e), t.clear(), n = !0;
154
162
  };
155
163
  if (a === "then") {
156
164
  if (r.length === 0)
157
- return { then: () => n };
158
- const c = O(e, t, {
165
+ return { then: () => o };
166
+ const l = L(e, t, {
159
167
  type: "GET",
160
168
  path: r.map((i) => i.toString())
161
- }).then(E);
162
- return c.then.bind(c);
169
+ }).then(k);
170
+ return l.then.bind(l);
163
171
  }
164
- return D(e, t, [...r, a]);
172
+ return _(e, t, [...r, a]);
165
173
  },
166
- set(u, a, c) {
167
- k(s);
168
- const [i, l] = j(c);
169
- return O(e, t, {
174
+ set(c, a, l) {
175
+ M(n);
176
+ const [i, u] = j(l);
177
+ return L(e, t, {
170
178
  type: "SET",
171
- path: [...r, a].map((d) => d.toString()),
179
+ path: [...r, a].map((f) => f.toString()),
172
180
  value: i
173
- }, l).then(E);
181
+ }, u).then(k);
174
182
  },
175
- apply(u, a, c) {
176
- k(s);
183
+ apply(c, a, l) {
184
+ M(n);
177
185
  const i = r[r.length - 1];
178
- if (i === Ae)
179
- return O(e, t, {
186
+ if (i === Re)
187
+ return L(e, t, {
180
188
  type: "ENDPOINT"
181
- }).then(E);
189
+ }).then(k);
182
190
  if (i === "bind")
183
- return D(e, t, r.slice(0, -1));
184
- const [l, d] = K(c);
185
- return O(e, t, {
191
+ return _(e, t, r.slice(0, -1));
192
+ const [u, f] = Z(l);
193
+ return L(e, t, {
186
194
  type: "APPLY",
187
- path: r.map((f) => f.toString()),
188
- argumentList: l
189
- }, d).then(E);
195
+ path: r.map((h) => h.toString()),
196
+ argumentList: u
197
+ }, f).then(k);
190
198
  },
191
- construct(u, a) {
192
- k(s);
193
- const [c, i] = K(a);
194
- return O(e, t, {
199
+ construct(c, a) {
200
+ M(n);
201
+ const [l, i] = Z(a);
202
+ return L(e, t, {
195
203
  type: "CONSTRUCT",
196
- path: r.map((l) => l.toString()),
197
- argumentList: c
198
- }, i).then(E);
204
+ path: r.map((u) => u.toString()),
205
+ argumentList: l
206
+ }, i).then(k);
199
207
  }
200
208
  });
201
- return Ne(n, e), n;
209
+ return Ne(o, e), o;
202
210
  }
203
211
  function We(e) {
204
212
  return Array.prototype.concat.apply([], e);
205
213
  }
206
- function K(e) {
214
+ function Z(e) {
207
215
  const t = e.map(j);
208
216
  return [t.map((r) => r[0]), We(t.map((r) => r[1]))];
209
217
  }
210
- const ie = /* @__PURE__ */ new WeakMap();
211
- function ce(e, t) {
212
- return ie.set(e, t), e;
218
+ const de = /* @__PURE__ */ new WeakMap();
219
+ function fe(e, t) {
220
+ return de.set(e, t), e;
213
221
  }
214
- function le(e) {
215
- return Object.assign(e, { [re]: !0 });
222
+ function me(e) {
223
+ return Object.assign(e, { [ae]: !0 });
216
224
  }
217
225
  function j(e) {
218
- for (const [t, r] of se)
226
+ for (const [t, r] of ce)
219
227
  if (r.canHandle(e)) {
220
- const [o, s] = r.serialize(e);
228
+ const [s, n] = r.serialize(e);
221
229
  return [
222
230
  {
223
231
  type: "HANDLER",
224
232
  name: t,
225
- value: o
233
+ value: s
226
234
  },
227
- s
235
+ n
228
236
  ];
229
237
  }
230
238
  return [
@@ -232,79 +240,79 @@ function j(e) {
232
240
  type: "RAW",
233
241
  value: e
234
242
  },
235
- ie.get(e) || []
243
+ de.get(e) || []
236
244
  ];
237
245
  }
238
- function E(e) {
246
+ function k(e) {
239
247
  switch (e.type) {
240
248
  case "HANDLER":
241
- return se.get(e.name).deserialize(e.value);
249
+ return ce.get(e.name).deserialize(e.value);
242
250
  case "RAW":
243
251
  return e.value;
244
252
  }
245
253
  }
246
- function O(e, t, r, o) {
247
- return new Promise((s) => {
248
- const n = je();
249
- t.set(n, s), e.start && e.start(), e.postMessage(Object.assign({ id: n }, r), o);
254
+ function L(e, t, r, s) {
255
+ return new Promise((n) => {
256
+ const o = De();
257
+ t.set(o, n), e.start && e.start(), e.postMessage(Object.assign({ id: o }, r), s);
250
258
  });
251
259
  }
252
- function je() {
260
+ function De() {
253
261
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
254
262
  }
255
- const Ce = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 3, 1, 0, 1, 10, 14, 1, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11])), Be = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 2, 8, 1, 1, 97, 1, 98, 3, 127, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 5, 1, 1, 97, 3, 1])), $e = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 7, 1, 5, 0, 208, 112, 26, 11])), De = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 12, 1, 10, 0, 67, 0, 0, 0, 0, 252, 0, 26, 11])), Ve = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 8, 1, 6, 0, 65, 0, 192, 26, 11])), Fe = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11])), He = () => (async (e) => {
263
+ const Be = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 3, 1, 0, 1, 10, 14, 1, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11])), Ce = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 2, 8, 1, 1, 97, 1, 98, 3, 127, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 5, 1, 1, 97, 3, 1])), je = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 7, 1, 5, 0, 208, 112, 26, 11])), Ve = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 12, 1, 10, 0, 67, 0, 0, 0, 0, 252, 0, 26, 11])), $e = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 8, 1, 6, 0, 65, 0, 192, 26, 11])), Fe = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11])), _e = () => (async (e) => {
256
264
  try {
257
265
  return typeof MessageChannel < "u" && new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)), WebAssembly.validate(e);
258
266
  } catch {
259
267
  return !1;
260
268
  }
261
269
  })(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 4, 1, 3, 1, 1, 10, 11, 1, 9, 0, 65, 0, 254, 16, 2, 0, 26, 11]));
262
- function _e() {
270
+ function He() {
263
271
  const e = navigator.userAgent.toLowerCase();
264
272
  return e.includes("safari") && !e.includes("chrome");
265
273
  }
266
274
  async function qe() {
267
- if (!await He()) return !1;
275
+ if (!await _e()) return !1;
268
276
  if (!("importScripts" in self))
269
277
  throw Error("Not implemented");
270
- return _e() ? !1 : "Worker" in self;
278
+ return He() ? !1 : "Worker" in self;
271
279
  }
272
280
  async function Ge() {
273
281
  const e = [
274
- Be(),
275
- $e(),
276
282
  Ce(),
277
- De(),
278
- Ve()
283
+ je(),
284
+ Be(),
285
+ Ve(),
286
+ $e()
279
287
  ];
280
288
  if (!(await Promise.all(e)).every(Boolean))
281
289
  throw new Error("Browser doesn't meet minimum requirements!");
282
290
  return await Fe() ? await qe() ? "advanced-threads" : "advanced" : "basic";
283
291
  }
284
- const Y = "application/javascript", Je = (e, t = {}) => {
292
+ const ee = "application/javascript", Ye = (e, t = {}) => {
285
293
  const r = {
286
294
  skipSameOrigin: !0,
287
295
  useBlob: !0,
288
296
  ...t
289
297
  };
290
298
  return r.skipSameOrigin && new URL(e).origin === self.location.origin ? Promise.resolve(e) : new Promise(
291
- (o, s) => void fetch(e).then((n) => n.text()).then((n) => {
299
+ (s, n) => void fetch(e).then((o) => o.text()).then((o) => {
292
300
  new URL(e).href.split("/").pop();
293
301
  let a = "";
294
302
  if (r.useBlob) {
295
- const c = new Blob([n], { type: Y });
296
- a = URL.createObjectURL(c);
303
+ const l = new Blob([o], { type: ee });
304
+ a = URL.createObjectURL(l);
297
305
  } else
298
- a = `data:${Y},` + encodeURIComponent(n);
299
- o(a);
300
- }).catch(s)
306
+ a = `data:${ee},` + encodeURIComponent(o);
307
+ s(a);
308
+ }).catch(n)
301
309
  );
302
310
  };
303
311
  function Ke() {
304
312
  const e = self.navigator.userAgent.toLowerCase();
305
313
  return /iphone|ipad|ipod/.test(e);
306
314
  }
307
- function Ye(e) {
315
+ function Xe(e) {
308
316
  return {
309
317
  licenseId: e.licenseId,
310
318
  licensee: e.licensee,
@@ -315,7 +323,7 @@ function Ye(e) {
315
323
  sdkVersion: e.sdkVersion
316
324
  };
317
325
  }
318
- async function X(e, t = "https://baltazar.microblink.com/api/v2/status/check") {
326
+ async function te(e, t = "https://baltazar.microblink.com/api/v2/status/check") {
319
327
  if (!t || typeof t != "string")
320
328
  throw new Error("Invalid baltazarUrl: must be a non-empty string");
321
329
  try {
@@ -330,67 +338,21 @@ async function X(e, t = "https://baltazar.microblink.com/api/v2/status/check") {
330
338
  "Content-Type": "application/json"
331
339
  },
332
340
  cache: "no-cache",
333
- body: JSON.stringify(Ye(e))
341
+ body: JSON.stringify(Xe(e))
334
342
  });
335
343
  if (!r.ok)
336
344
  throw new Error(
337
345
  `Server returned error: ${r.status} ${r.statusText}`
338
346
  );
339
- return await r.json();
347
+ return await r.text();
340
348
  } catch (r) {
341
349
  throw console.error("Server permission request failed:", r), r;
342
350
  }
343
351
  }
344
- function Q(e) {
352
+ function re(e) {
345
353
  return Math.ceil(e * 1024 * 1024 / 64 / 1024);
346
354
  }
347
- const Xe = { basic: { full: 3065196, lightweight: 3123869 }, advanced: { full: 3081572, lightweight: 3138602 }, "advanced-threads": { full: 3133721, lightweight: 3189140 } }, Qe = { basic: { full: 9141750, lightweight: 7509065 }, advanced: { full: 9141750, lightweight: 7509065 }, "advanced-threads": { full: 9141750, lightweight: 7509065 } }, Ze = {
348
- wasm: Xe,
349
- data: Qe
350
- };
351
- function et(e, t, r) {
352
- return Ze[e][t][r];
353
- }
354
- async function Z(e, t, r, o, s) {
355
- var d;
356
- const n = await fetch(e);
357
- if (!s)
358
- return n.arrayBuffer();
359
- const u = n.headers.get("Content-Length"), a = u ? parseInt(u, 10) : et(t, r, o);
360
- if (isNaN(a) || a <= 0)
361
- throw new Error(
362
- `Invalid content length for ${t} file: ${a}`
363
- );
364
- let c = 0;
365
- const i = new TransformStream({
366
- transform(f, p) {
367
- c += f.length;
368
- const C = Math.min(
369
- Math.round(c / a * 100),
370
- 100
371
- );
372
- s({
373
- loaded: c,
374
- contentLength: a,
375
- progress: C,
376
- finished: !1
377
- }), p.enqueue(f);
378
- },
379
- flush() {
380
- s({
381
- loaded: c,
382
- contentLength: a,
383
- progress: 100,
384
- finished: !0
385
- });
386
- }
387
- });
388
- return new Response(
389
- (d = n.body) == null ? void 0 : d.pipeThrough(i),
390
- n
391
- ).arrayBuffer();
392
- }
393
- function U(...e) {
355
+ function I(...e) {
394
356
  const t = e.filter((r) => r).join("/").replace(/([^:]\/)\/+/g, "$1");
395
357
  try {
396
358
  new URL(t, "http://example.com");
@@ -399,162 +361,285 @@ function U(...e) {
399
361
  }
400
362
  return t;
401
363
  }
402
- function ue(e) {
364
+ function he(e) {
403
365
  return Object.prototype.toString.call(e).slice(8, -1);
404
366
  }
405
- function M(e) {
406
- if (ue(e) !== "Object")
367
+ function N(e) {
368
+ if (he(e) !== "Object")
407
369
  return !1;
408
370
  const t = Object.getPrototypeOf(e);
409
371
  return !!t && t.constructor === Object && t === Object.prototype;
410
372
  }
411
- function ee(e) {
412
- return ue(e) === "Symbol";
373
+ function ne(e) {
374
+ return he(e) === "Symbol";
413
375
  }
414
- function te(e, t, r, o) {
415
- const s = {}.propertyIsEnumerable.call(o, t) ? "enumerable" : "nonenumerable";
416
- s === "enumerable" && (e[t] = r), s === "nonenumerable" && Object.defineProperty(e, t, {
376
+ function se(e, t, r, s) {
377
+ const n = {}.propertyIsEnumerable.call(s, t) ? "enumerable" : "nonenumerable";
378
+ n === "enumerable" && (e[t] = r), n === "nonenumerable" && Object.defineProperty(e, t, {
417
379
  value: r,
418
380
  enumerable: !1,
419
381
  writable: !0,
420
382
  configurable: !0
421
383
  });
422
384
  }
423
- function de(e, t, r) {
424
- if (!M(t))
385
+ function ge(e, t, r) {
386
+ if (!N(t))
425
387
  return t;
426
- let o = {};
427
- if (M(e)) {
428
- const a = Object.getOwnPropertyNames(e), c = Object.getOwnPropertySymbols(e);
429
- o = [...a, ...c].reduce((i, l) => {
430
- const d = e[l];
431
- return (!ee(l) && !Object.getOwnPropertyNames(t).includes(l) || ee(l) && !Object.getOwnPropertySymbols(t).includes(l)) && te(i, l, d, e), i;
388
+ let s = {};
389
+ if (N(e)) {
390
+ const a = Object.getOwnPropertyNames(e), l = Object.getOwnPropertySymbols(e);
391
+ s = [...a, ...l].reduce((i, u) => {
392
+ const f = e[u];
393
+ return (!ne(u) && !Object.getOwnPropertyNames(t).includes(u) || ne(u) && !Object.getOwnPropertySymbols(t).includes(u)) && se(i, u, f, e), i;
432
394
  }, {});
433
395
  }
434
- const s = Object.getOwnPropertyNames(t), n = Object.getOwnPropertySymbols(t);
435
- return [...s, ...n].reduce((a, c) => {
436
- let i = t[c];
437
- const l = M(e) ? e[c] : void 0;
438
- return l !== void 0 && M(i) && (i = de(l, i)), te(a, c, i, t), a;
439
- }, o);
396
+ const n = Object.getOwnPropertyNames(t), o = Object.getOwnPropertySymbols(t);
397
+ return [...n, ...o].reduce((a, l) => {
398
+ let i = t[l];
399
+ const u = N(e) ? e[l] : void 0;
400
+ return u !== void 0 && N(i) && (i = ge(u, i)), se(a, l, i, t), a;
401
+ }, s);
440
402
  }
441
- function tt(e, ...t) {
442
- return t.reduce((r, o) => de(r, o), e);
403
+ function Je(e, ...t) {
404
+ return t.reduce((r, s) => ge(r, s), e);
443
405
  }
444
- function fe(e) {
406
+ function pe(e) {
445
407
  return {
446
408
  country: (e == null ? void 0 : e.country) ?? void 0,
447
409
  region: (e == null ? void 0 : e.region) ?? void 0,
448
410
  type: (e == null ? void 0 : e.type) ?? void 0
449
411
  };
450
412
  }
451
- const rt = (e) => ({
452
- documentFilter: fe(e.documentFilter),
413
+ const Qe = (e) => ({
414
+ documentFilter: pe(e.documentFilter),
453
415
  fields: e.fields ?? []
454
- }), nt = (e) => ({
455
- documentFilter: fe(e.documentFilter),
416
+ }), Ze = (e) => ({
417
+ documentFilter: pe(e.documentFilter),
456
418
  fields: e.fields || [],
457
419
  documentNumberAnonymizationSettings: e.documentNumberAnonymizationSettings ? {
458
420
  prefixDigitsVisible: e.documentNumberAnonymizationSettings.prefixDigitsVisible,
459
421
  suffixDigitsVisible: e.documentNumberAnonymizationSettings.suffixDigitsVisible
460
422
  } : void 0
461
423
  });
462
- function st(e = {}, t) {
463
- var u, a, c, i;
424
+ function et(e = {}, t) {
425
+ var c, a, l, i;
464
426
  e && (e = Object.fromEntries(
465
- Object.entries(e).filter(([l, d]) => d !== void 0)
427
+ Object.entries(e).filter(([u, f]) => f !== void 0)
466
428
  ));
467
- const r = ((a = (u = e == null ? void 0 : e.scanningSettings) == null ? void 0 : u.customDocumentRules) == null ? void 0 : a.map(
468
- rt
469
- )) ?? [], o = ((i = (c = e == null ? void 0 : e.scanningSettings) == null ? void 0 : c.customDocumentAnonymizationSettings) == null ? void 0 : i.map(
470
- nt
471
- )) ?? [], s = {
429
+ const r = ((a = (c = e == null ? void 0 : e.scanningSettings) == null ? void 0 : c.customDocumentRules) == null ? void 0 : a.map(
430
+ Qe
431
+ )) ?? [], s = ((i = (l = e == null ? void 0 : e.scanningSettings) == null ? void 0 : l.customDocumentAnonymizationSettings) == null ? void 0 : i.map(
432
+ Ze
433
+ )) ?? [], n = {
472
434
  ...e == null ? void 0 : e.scanningSettings,
473
435
  customDocumentRules: r,
474
- customDocumentAnonymizationSettings: o
436
+ customDocumentAnonymizationSettings: s
475
437
  };
476
- return tt(t, {
438
+ return Je(t, {
477
439
  ...e,
478
- scanningSettings: s
440
+ scanningSettings: n
441
+ });
442
+ }
443
+ const tt = { basic: { full: 3242406, lightweight: 3280244 }, advanced: { full: 3261747, lightweight: 3298066 }, "advanced-threads": { full: 3309394, lightweight: 3343706 } }, rt = { basic: { full: 13393962, lightweight: 11761277 }, advanced: { full: 13393962, lightweight: 11761277 }, "advanced-threads": { full: 13393962, lightweight: 11761277 } }, nt = {
444
+ wasm: tt,
445
+ data: rt
446
+ };
447
+ function st(e, t, r) {
448
+ return nt[e][t][r];
449
+ }
450
+ async function oe(e, t, r, s, n) {
451
+ var f;
452
+ const o = await fetch(e);
453
+ if (!n)
454
+ return o.arrayBuffer();
455
+ const c = o.headers.get("Content-Length"), a = c ? parseInt(c, 10) : st(t, r, s);
456
+ if (isNaN(a) || a <= 0)
457
+ throw new Error(
458
+ `Invalid content length for ${t} file: ${a}`
459
+ );
460
+ let l = 0;
461
+ const i = new TransformStream({
462
+ transform(h, w) {
463
+ l += h.length;
464
+ const V = Math.min(
465
+ Math.round(l / a * 100),
466
+ 100
467
+ );
468
+ n({
469
+ loaded: l,
470
+ contentLength: a,
471
+ progress: V,
472
+ finished: !1
473
+ }), w.enqueue(h);
474
+ },
475
+ flush() {
476
+ n({
477
+ loaded: l,
478
+ contentLength: a,
479
+ progress: 100,
480
+ finished: !0
481
+ });
482
+ }
479
483
  });
484
+ return new Response(
485
+ (f = o.body) == null ? void 0 : f.pipeThrough(i),
486
+ o
487
+ ).arrayBuffer();
480
488
  }
481
- class T extends Error {
482
- constructor(t, r) {
483
- super(`Proxy URL validation failed for "${r}": ${t}`), this.url = r, this.name = "ProxyUrlValidationError";
489
+ class F extends Error {
490
+ constructor(t, r, s) {
491
+ super(`Proxy URL validation failed for "${s}": ${r}`), this.code = t, this.url = s, this.name = "ProxyUrlValidationError";
484
492
  }
485
493
  }
486
- class ot extends Error {
487
- constructor(r, o) {
488
- super(r);
489
- B(this, "code");
490
- this.name = "LicenseError", this.code = o;
494
+ function ot(e) {
495
+ const t = e.unlockResult === "requires-server-permission", { allowPingProxy: r, allowBaltazarProxy: s, hasPing: n } = e;
496
+ if (!r && !s)
497
+ throw new Error(
498
+ "Microblink proxy URL is set but your license doesn't permit proxy usage. Check your license."
499
+ );
500
+ if (!t && !n)
501
+ throw new Error(
502
+ "Microblink proxy URL is set but your license doesn't permit proxy usage. Check your license."
503
+ );
504
+ if (!t && n && s && !r || t && !n && !s && r)
505
+ throw new Error(
506
+ "Microblink proxy URL is set but your license doesn't permit proxy usage. Check your license."
507
+ );
508
+ }
509
+ function at(e) {
510
+ let t;
511
+ try {
512
+ t = new URL(e);
513
+ } catch {
514
+ throw new F(
515
+ "INVALID_PROXY_URL",
516
+ `Failed to create URL instance for provided Microblink proxy URL "${e}". Expected format: https://your-proxy.com or https://your-proxy.com/`,
517
+ e
518
+ );
519
+ }
520
+ if (t.protocol !== "https:")
521
+ throw new F(
522
+ "HTTPS_REQUIRED",
523
+ `Proxy URL validation failed for "${e}": HTTPS protocol must be used. Expected format: https://your-proxy.com or https://your-proxy.com/`,
524
+ e
525
+ );
526
+ const r = t.origin;
527
+ try {
528
+ const s = new URL("/api/v2/status/check", r).toString();
529
+ return {
530
+ ping: r,
531
+ baltazar: s
532
+ };
533
+ } catch {
534
+ throw new F(
535
+ "INVALID_PROXY_URL",
536
+ "Failed to build baltazar service URL",
537
+ e
538
+ );
491
539
  }
492
540
  }
493
- var h, L, A, R, w, g, me, he, ge, ye, pe;
494
- class at {
541
+ var m, v, A, U, T, b, O, P, ye, D;
542
+ class it {
495
543
  constructor() {
496
- S(this, g);
544
+ p(this, P);
497
545
  /**
498
546
  * The Wasm module.
499
547
  */
500
- S(this, h);
548
+ p(this, m);
501
549
  /**
502
550
  * The default session settings.
503
551
  *
504
552
  * Must be initialized when calling initBlinkId.
505
553
  */
506
- S(this, L);
554
+ p(this, v);
507
555
  /**
508
556
  * The progress status callback.
509
557
  */
510
- B(this, "progressStatusCallback");
558
+ x(this, "progressStatusCallback");
511
559
  /**
512
560
  * Whether the demo overlay is shown.
513
561
  */
514
- S(this, A, !0);
562
+ p(this, A, !0);
515
563
  /**
516
564
  * Whether the production overlay is shown.
517
565
  */
518
- S(this, R, !0);
566
+ p(this, U, !0);
567
+ /**
568
+ * Current session number.
569
+ */
570
+ p(this, T, 0);
519
571
  /**
520
572
  * Sanitized proxy URLs for Microblink services.
521
573
  */
522
- S(this, w);
574
+ p(this, b);
575
+ p(this, O);
576
+ }
577
+ reportPinglet(t) {
578
+ if (!d(this, m))
579
+ throw new Error("Wasm module not loaded");
580
+ d(this, m).isPingEnabled() && d(this, m).queuePinglet(
581
+ JSON.stringify(t.data),
582
+ t.schemaName,
583
+ t.schemaVersion,
584
+ // session number can be overriden by pinglet, otherwise use current
585
+ // session count
586
+ t.sessionNumber ?? d(this, T)
587
+ );
588
+ }
589
+ sendPinglets() {
590
+ if (!d(this, m))
591
+ throw new Error("Wasm module not loaded");
592
+ d(this, m).sendPinglets();
523
593
  }
524
594
  /**
525
595
  * This method initializes everything.
526
596
  */
527
- async initBlinkId(t, r, o) {
528
- var u;
529
- const s = new URL(
597
+ async initBlinkId(t, r, s) {
598
+ var a;
599
+ const n = new URL(
530
600
  "resources/",
531
601
  t.resourcesLocation
532
602
  ).toString();
533
- if (x(this, L, r), this.progressStatusCallback = o, await v(this, g, me).call(this, {
534
- resourceUrl: s,
603
+ if (y(this, v, r), this.progressStatusCallback = s, y(this, O, t.userId), await R(this, P, ye).call(this, {
604
+ resourceUrl: n,
535
605
  variant: t.wasmVariant,
536
606
  initialMemory: t.initialMemory,
537
607
  useLightweightBuild: t.useLightweightBuild
538
- }), !m(this, h))
608
+ }), !d(this, m))
539
609
  throw new Error("Wasm module not loaded");
540
- const n = m(this, h).initializeWithLicenseKey(
610
+ const o = new lt({
611
+ packageName: self.location.hostname,
612
+ platform: "Emscripten",
613
+ product: "BlinkID",
614
+ userId: d(this, O)
615
+ });
616
+ this.reportPinglet(o), this.sendPinglets();
617
+ const c = d(this, m).initializeWithLicenseKey(
541
618
  t.licenseKey,
542
619
  t.userId,
543
620
  !1
544
621
  );
545
- if (n.licenseError)
546
- throw new ot(
547
- "License unlock error: " + n.licenseError,
622
+ if (this.sendPinglets(), c.licenseError)
623
+ throw R(this, P, D).call(this, {
624
+ errorType: "Crash",
625
+ errorMessage: c.licenseError
626
+ }), this.sendPinglets(), new ut(
627
+ "License unlock error: " + c.licenseError,
548
628
  "LICENSE_ERROR"
549
629
  );
550
- if (t.microblinkProxyUrl && v(this, g, he).call(this, t.microblinkProxyUrl, n), n.unlockResult === "requires-server-permission") {
551
- const a = (u = m(this, w)) == null ? void 0 : u.baltazar, c = a && n.allowBaltazarProxy ? await X(n, a) : await X(n), i = m(this, h).submitServerPermission(
552
- JSON.stringify(c)
630
+ if (t.microblinkProxyUrl && (ot(c), y(this, b, at(t.microblinkProxyUrl)), c.allowPingProxy && c.hasPing && (d(this, m).setPingProxyUrl(d(this, b).ping), console.debug(`Using ping proxy URL: ${d(this, b).ping}`))), c.unlockResult === "requires-server-permission") {
631
+ const i = ((a = d(this, b)) == null ? void 0 : a.baltazar) && c.allowBaltazarProxy ? d(this, b).baltazar : void 0;
632
+ i && console.debug(`Using Baltazar proxy URL: ${i}`);
633
+ const u = i ? await te(c, i) : await te(c), f = d(this, m).submitServerPermission(
634
+ u
553
635
  );
554
- if (i.error)
555
- throw new Error("Server unlock error: " + i.error);
636
+ if (f != null && f.error)
637
+ throw R(this, P, D).call(this, {
638
+ errorType: "Crash",
639
+ errorMessage: f.error
640
+ }), this.sendPinglets(), new Error("Server unlock error: " + f.error);
556
641
  }
557
- x(this, A, n.showDemoOverlay), x(this, R, n.showProductionOverlay);
642
+ console.debug(`BlinkID SDK ${c.sdkVersion} unlocked`), y(this, A, c.showDemoOverlay), y(this, U, c.showProductionOverlay), d(this, m).initializeSdk(t.userId), this.sendPinglets();
558
643
  }
559
644
  /**
560
645
  * This method creates a BlinkID scanning session.
@@ -563,13 +648,16 @@ class at {
563
648
  * @returns The session.
564
649
  */
565
650
  createBlinkIdScanningSession(t) {
566
- if (!m(this, h))
651
+ if (!d(this, m))
567
652
  throw new Error("Wasm module not loaded");
568
- const r = st(
653
+ const r = et(
569
654
  t,
570
- m(this, L)
571
- ), o = m(this, h).createBlinkIdScanningSession(r);
572
- return this.createProxySession(o, r);
655
+ d(this, v)
656
+ ), s = d(this, m).createBlinkIdScanningSession(
657
+ r,
658
+ d(this, O)
659
+ );
660
+ return this.sendPinglets(), Q(this, T)._++, this.createProxySession(s, r);
573
661
  }
574
662
  /**
575
663
  * This method creates a proxy session.
@@ -579,28 +667,33 @@ class at {
579
667
  * @returns The proxy session.
580
668
  */
581
669
  createProxySession(t, r) {
582
- return le({
670
+ return me({
583
671
  getResult: () => t.getResult(),
584
- process: (s) => {
585
- const n = t.process(s);
586
- if ("error" in n)
587
- throw new Error(`Error processing frame: ${n.error}`);
588
- return ce(
672
+ process: (n) => {
673
+ const o = t.process(n);
674
+ if ("error" in o)
675
+ throw R(this, P, D).call(this, {
676
+ errorType: "NonFatal",
677
+ errorMessage: o.error
678
+ }), new Error(`Error processing frame: ${o.error}`);
679
+ return fe(
589
680
  {
590
- ...n,
591
- arrayBuffer: s.data.buffer
681
+ ...o,
682
+ arrayBuffer: n.data.buffer
592
683
  },
593
- [s.data.buffer]
684
+ [n.data.buffer]
594
685
  );
595
686
  },
687
+ ping: (n) => this.reportPinglet(n),
688
+ sendPinglets: () => this.sendPinglets(),
596
689
  getSettings: () => r,
597
690
  reset: () => t.reset(),
598
691
  delete: () => t.delete(),
599
692
  deleteLater: () => t.deleteLater(),
600
693
  isDeleted: () => t.isDeleted(),
601
- isAliasOf: (s) => t.isAliasOf(s),
602
- showDemoOverlay: () => m(this, A),
603
- showProductionOverlay: () => m(this, R)
694
+ isAliasOf: (n) => t.isAliasOf(n),
695
+ showDemoOverlay: () => d(this, A),
696
+ showProductionOverlay: () => d(this, U)
604
697
  });
605
698
  }
606
699
  /**
@@ -611,171 +704,124 @@ class at {
611
704
  /**
612
705
  * Terminates the workers and the Wasm runtime.
613
706
  */
614
- terminate() {
615
- self.close();
616
- }
617
- /**
618
- * If the ping is enabled, this method will return 1.
619
- *
620
- * @returns 1 if the ping is enabled, 0 otherwise.
621
- */
622
- ping() {
623
- return 1;
707
+ async terminate() {
708
+ if (self.setTimeout(() => self.close, 5e3), !d(this, m)) {
709
+ console.warn(
710
+ "No Wasm module loaded during worker termination. Skipping cleanup."
711
+ ), self.close();
712
+ return;
713
+ }
714
+ d(this, m).terminateSdk(), await new Promise((s) => setTimeout(s, 0)), this.sendPinglets();
715
+ const r = Date.now();
716
+ for (; d(this, m).arePingRequestsInProgress() && Date.now() - r < 5e3; )
717
+ await new Promise((s) => setTimeout(s, 100));
718
+ y(this, m, void 0), console.debug("BlinkIdWorker terminated 🔴"), self.close();
624
719
  }
625
720
  }
626
- h = new WeakMap(), L = new WeakMap(), A = new WeakMap(), R = new WeakMap(), w = new WeakMap(), g = new WeakSet(), me = async function({
721
+ m = new WeakMap(), v = new WeakMap(), A = new WeakMap(), U = new WeakMap(), T = new WeakMap(), b = new WeakMap(), O = new WeakMap(), P = new WeakSet(), ye = async function({
627
722
  resourceUrl: t,
628
723
  variant: r,
629
- useLightweightBuild: o,
630
- initialMemory: s
724
+ useLightweightBuild: s,
725
+ initialMemory: n
631
726
  }) {
632
- if (m(this, h)) {
727
+ if (d(this, m)) {
633
728
  console.log("Wasm already loaded");
634
729
  return;
635
730
  }
636
- const n = r ?? await Ge(), u = o ? "lightweight" : "full", a = "BlinkIdModule", c = U(
731
+ const o = r ?? await Ge(), c = s ? "lightweight" : "full", a = "BlinkIdModule", l = I(
637
732
  t,
638
- u,
639
- n
640
- ), i = U(c, `${a}.js`), l = U(c, `${a}.wasm`), d = U(c, `${a}.data`), f = await Je(i), C = (await import(
733
+ c,
734
+ o
735
+ ), i = I(l, `${a}.js`), u = I(l, `${a}.wasm`), f = I(l, `${a}.data`), h = await Ye(i), V = (await import(
641
736
  /* @vite-ignore */
642
- f
737
+ h
643
738
  )).default;
644
- s || (s = Ke() ? 700 : 200);
739
+ n || (n = Ke() ? 700 : 200);
645
740
  const we = new WebAssembly.Memory({
646
- initial: Q(s),
647
- maximum: Q(2048),
648
- shared: n === "advanced-threads"
741
+ initial: re(n),
742
+ maximum: re(2048),
743
+ shared: o === "advanced-threads"
649
744
  });
650
- let b, P, F = 0;
651
- const be = 32, H = () => {
652
- if (!this.progressStatusCallback || !b || !P)
745
+ let S, E, q = 0;
746
+ const be = 32, G = () => {
747
+ if (!this.progressStatusCallback || !S || !E)
653
748
  return;
654
- const y = b.finished && P.finished, _ = b.loaded + P.loaded, q = b.contentLength + P.contentLength, ve = y ? 100 : Math.min(Math.round(_ / q * 100), 100), G = performance.now();
655
- G - F < be || (F = G, this.progressStatusCallback({
656
- loaded: _,
657
- contentLength: q,
658
- progress: ve,
659
- finished: y
749
+ const g = S.finished && E.finished, Y = S.loaded + E.loaded, K = S.contentLength + E.contentLength, ke = g ? 100 : Math.min(Math.round(Y / K * 100), 100), X = performance.now();
750
+ X - q < be || (q = X, this.progressStatusCallback({
751
+ loaded: Y,
752
+ contentLength: K,
753
+ progress: ke,
754
+ finished: g
660
755
  }));
661
- }, Pe = (y) => {
662
- b = y, H();
663
- }, Se = (y) => {
664
- P = y, H();
756
+ }, Pe = (g) => {
757
+ S = g, G();
758
+ }, Se = (g) => {
759
+ E = g, G();
665
760
  }, [Ee, xe] = await Promise.all([
666
- Z(
667
- l,
668
- "wasm",
669
- n,
761
+ oe(
670
762
  u,
763
+ "wasm",
764
+ o,
765
+ c,
671
766
  Pe
672
767
  ),
673
- Z(
674
- d,
768
+ oe(
769
+ f,
675
770
  "data",
676
- n,
677
- u,
771
+ o,
772
+ c,
678
773
  Se
679
774
  )
680
775
  ]);
681
- if (this.progressStatusCallback && b && P) {
682
- const y = b.contentLength + P.contentLength;
776
+ if (this.progressStatusCallback && S && E) {
777
+ const g = S.contentLength + E.contentLength;
683
778
  this.progressStatusCallback({
684
- loaded: y,
685
- contentLength: y,
779
+ loaded: g,
780
+ contentLength: g,
686
781
  progress: 100,
687
782
  finished: !0
688
783
  });
689
784
  }
690
- if (x(this, h, await C({
691
- locateFile: (y) => `${c}/${n}/${y}`,
785
+ if (y(this, m, await V({
786
+ locateFile: (g) => `${l}/${o}/${g}`,
692
787
  // pthreads build breaks without this:
693
788
  // "Failed to execute 'createObjectURL' on 'URL': Overload resolution failed."
694
- mainScriptUrlOrBlob: f,
789
+ mainScriptUrlOrBlob: h,
695
790
  wasmBinary: Ee,
696
791
  getPreloadedPackage() {
697
792
  return xe;
698
793
  },
699
794
  wasmMemory: we,
700
795
  noExitRuntime: !0
701
- })), !m(this, h))
796
+ })), !d(this, m))
702
797
  throw new Error("Failed to load Wasm module");
703
- }, /**
704
- * Configures proxy URLs based on the provided settings and license permissions.
705
- */
706
- he = function(t, r) {
707
- if (!t) {
708
- console.debug(
709
- "No proxy URL configured, using default Microblink servers"
710
- );
711
- return;
712
- }
713
- v(this, g, ge).call(this, r, t);
714
- try {
715
- x(this, w, v(this, g, ye).call(this, t)), r.allowPingProxy && m(this, h).setPingProxyUrl(m(this, w).ping), console.debug("Proxy URLs configured successfully:", {
716
- ping: m(this, w).ping,
717
- baltazar: m(this, w).baltazar
718
- });
719
- } catch (o) {
720
- throw o instanceof T ? new Error(
721
- `${o.message}
722
-
723
- Troubleshooting:
724
- - Ensure the URL is accessible
725
- - Check HTTPS requirements
726
- - Verify proxy server implementation`
727
- ) : o;
728
- }
729
- }, /**
730
- * Validates that the license allows proxy usage.
731
- */
732
- ge = function(t, r) {
733
- if (!t.allowPingProxy && !t.allowBaltazarProxy)
734
- throw new Error(
735
- `Proxy URL "${r}" was provided, but your license does not permit proxy usage.
736
- License permissions: pingProxy=${t.allowPingProxy}, baltazarProxy=${t.allowBaltazarProxy}
737
- Check your license.`
738
- );
739
- if (!t.hasPing && t.unlockResult !== "requires-server-permission")
740
- throw new Error(
741
- `Microblink proxy URL is set but cannot be used because ping and online license check are disabled in your license.
742
- Check your license.`
743
- );
744
- }, /**
745
- * Validates and sanitizes proxy URLs for different Microblink services.
746
- */
747
- ye = function(t) {
748
- let r;
749
- try {
750
- r = new URL(t);
751
- } catch {
752
- throw new T(
753
- `Failed to create URL instance for provided Microblink proxy URL "${t}". Expected format: https://your-proxy.com or https://your-proxy.com/`,
754
- t
755
- );
756
- }
757
- if (r.protocol !== "https:")
758
- throw new T(
759
- `Proxy URL validation failed for "${t}": HTTPS protocol must be used. Expected format: https://your-proxy.com or https://your-proxy.com/`,
760
- t
761
- );
762
- const o = r.origin, s = v(this, g, pe).call(this, o, "/api/v2/status/check");
763
- return {
764
- ping: o,
765
- baltazar: s
798
+ }, D = function(t) {
799
+ const r = {
800
+ data: {
801
+ errorType: t.errorType,
802
+ errorMessage: t.errorMessage
803
+ },
804
+ schemaName: "ping.error",
805
+ schemaVersion: "1.0.0"
766
806
  };
767
- }, /**
768
- * Builds a service URL by combining base URL with service path.
769
- */
770
- pe = function(t, r) {
771
- try {
772
- return new URL(r, t).toString();
773
- } catch {
774
- throw new T(
775
- `Failed to build service URL for path "${r}"`,
776
- t
777
- );
778
- }
807
+ this.reportPinglet(r);
779
808
  };
780
- const it = new at();
781
- V(it);
809
+ const ct = new it();
810
+ H(ct);
811
+ class lt {
812
+ constructor(t) {
813
+ x(this, "data");
814
+ /** Needs to be 0 for sorting purposes */
815
+ x(this, "sessionNumber", 0);
816
+ x(this, "schemaName", "ping.sdk.init.start");
817
+ x(this, "schemaVersion", "1.0.0");
818
+ this.data = t;
819
+ }
820
+ }
821
+ class ut extends Error {
822
+ constructor(r, s) {
823
+ super(r);
824
+ x(this, "code");
825
+ this.name = "LicenseError", this.code = s;
826
+ }
827
+ }