@wemap/camera 14.0.0-0 → 14.0.0-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.
- package/dist/index.js +2944 -20
- package/dist/qr-scanner-worker.min-CdBZO1_x-DAbG1qpa-DsmIQ1ZR-D0bKFp24-Bgg9_K2D-CzQjeLnK-Crw_pXOi-CxBZ0nTY-79jwfh5Z.js +2 -0
- package/dist/qr-scanner-worker.min-CdBZO1_x-DbljhPN5.js +2 -0
- package/dist/qr-scanner-worker.min-CdBZO1_x-j4KIyzGW-CtZ2H-uq-BsxRIRJ2-B58mXfMr-CY7U-8le-BqjFedsp-DkEzaBUL-DmYDsfTA-OFT0YV77-CQI-j0E8-8Zc4Heoq-Bn1EU35u.js +2 -0
- package/dist/qr-scanner-worker.min-CdBZO1_x-zOsA9GqL-spdHzETc-CdfYQy09-yymxaPor-DcsJbmYs-CbrIyAqr-Cmnj38L_.js +2 -0
- package/package.json +1 -1
- /package/dist/{qr-scanner-worker.min-CdBZO1_x-B5PB_bz0-DA0kiTSy.js → qr-scanner-worker.min-CdBZO1_x-B5PB_bz0-DA0kiTSy-NorQ2854-BMBKUWY9-BoVZZTXJ-CkGuQIJj.js} +0 -0
- /package/dist/{qr-scanner-worker.min-CdBZO1_x-BQGmnbPC-DnOUafgV-DWpsR0Js-ZZGQKBrC-DOG-01---DWmsTSae.js → qr-scanner-worker.min-CdBZO1_x-B6z5WmOC-CssviUfq.js} +0 -0
- /package/dist/{qr-scanner-worker.min-CdBZO1_x-BasYyBmn-Sg4PHYpX-k03AL3XJ-Cgjn176v-CDYp3S06.js → qr-scanner-worker.min-CdBZO1_x-BQGmnbPC-DnOUafgV-DWpsR0Js-ZZGQKBrC-DOG-01---DWmsTSae-B_rE_zzG-BqVqc5W7-Hoirdoyc-Dogb-sTf.js} +0 -0
- /package/dist/{qr-scanner-worker.min-CdBZO1_x-Bej9J3jZ-LIy5T9qw-B5AD_dxc-vFmEZ9Jc-C18UJXmQ-ByBto5KP-DEO_S4_W.js → qr-scanner-worker.min-CdBZO1_x-BRbiAMv9-nmIQ9hck-C6vs_IbV-DSY4QR6D.js} +0 -0
- /package/dist/{qr-scanner-worker.min-CdBZO1_x-CBTRGYa-.js → qr-scanner-worker.min-CdBZO1_x-BasYyBmn-Sg4PHYpX-k03AL3XJ-Cgjn176v-CDYp3S06-DEPW_gy0-CqeOxb0L-BxEDkksK-Cp-a8RPF.js} +0 -0
- /package/dist/{qr-scanner-worker.min-CdBZO1_x-DAbG1qpa-DsmIQ1ZR-D0bKFp24-Bgg9_K2D.js → qr-scanner-worker.min-CdBZO1_x-Bej9J3jZ-LIy5T9qw-B5AD_dxc-vFmEZ9Jc-C18UJXmQ-ByBto5KP-DEO_S4_W-BWRiSO9N-BBjAeT1B-DH0W8Rxm-D2jL_VRE.js} +0 -0
- /package/dist/{qr-scanner-worker.min-CdBZO1_x-j4KIyzGW-CtZ2H-uq-BsxRIRJ2-B58mXfMr-CY7U-8le-BqjFedsp-DkEzaBUL-DmYDsfTA.js → qr-scanner-worker.min-CdBZO1_x-CBTRGYa--CBfOUkyb-qo3X-B_9-BkjDc6vN-ypRw_IJJ.js} +0 -0
- /package/dist/{qr-scanner-worker.min-CdBZO1_x-zOsA9GqL-spdHzETc-CdfYQy09.js → qr-scanner-worker.min-CdBZO1_x-CYEYInSi-CIq73T7I-Dk6KCulN.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,13 +1,2937 @@
|
|
|
1
|
-
var __create$
|
|
2
|
-
if (I && typeof I == "object" || typeof I == "function") for (var B = __getOwnPropNames$
|
|
1
|
+
var __create$12 = Object.create, __defProp$33 = Object.defineProperty, __getOwnPropDesc$12 = Object.getOwnPropertyDescriptor, __getOwnPropNames$12 = Object.getOwnPropertyNames, __getProtoOf$12 = Object.getPrototypeOf, __hasOwnProp$12 = Object.prototype.hasOwnProperty, __commonJSMin$12 = (a, N) => () => (N || a((N = { exports: {} }).exports, N), N.exports), __copyProps$12 = (a, I, R, z) => {
|
|
2
|
+
if (I && typeof I == "object" || typeof I == "function") for (var B = __getOwnPropNames$12(I), V = 0, H = B.length, U; V < H; V++) U = B[V], !__hasOwnProp$12.call(a, U) && U !== R && __defProp$33(a, U, {
|
|
3
3
|
get: ((a) => I[a]).bind(null, U),
|
|
4
|
-
enumerable: !(z = __getOwnPropDesc$
|
|
4
|
+
enumerable: !(z = __getOwnPropDesc$12(I, U)) || z.enumerable
|
|
5
5
|
});
|
|
6
6
|
return a;
|
|
7
|
-
}, import_events$
|
|
7
|
+
}, import_events$12 = /* @__PURE__ */ ((P, F, L) => (L = P == null ? {} : __create$12(__getProtoOf$12(P)), __copyProps$12(F || !P || !P.__esModule ? __defProp$33(L, "default", {
|
|
8
8
|
value: P,
|
|
9
9
|
enumerable: !0
|
|
10
|
-
}) : L, P)))((/* @__PURE__ */ __commonJSMin$
|
|
10
|
+
}) : L, P)))((/* @__PURE__ */ __commonJSMin$12(((a, N) => {
|
|
11
|
+
var P = typeof Reflect == "object" ? Reflect : null, F = P && typeof P.apply == "function" ? P.apply : function(a, N, P) {
|
|
12
|
+
return Function.prototype.apply.call(a, N, P);
|
|
13
|
+
}, I = P && typeof P.ownKeys == "function" ? P.ownKeys : Object.getOwnPropertySymbols ? function(a) {
|
|
14
|
+
return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a));
|
|
15
|
+
} : function(a) {
|
|
16
|
+
return Object.getOwnPropertyNames(a);
|
|
17
|
+
};
|
|
18
|
+
function L(a) {
|
|
19
|
+
console && console.warn && console.warn(a);
|
|
20
|
+
}
|
|
21
|
+
var R = Number.isNaN || function(a) {
|
|
22
|
+
return a !== a;
|
|
23
|
+
};
|
|
24
|
+
function z() {
|
|
25
|
+
z.init.call(this);
|
|
26
|
+
}
|
|
27
|
+
N.exports = z, N.exports.once = Z, z.EventEmitter = z, z.prototype._events = void 0, z.prototype._eventsCount = 0, z.prototype._maxListeners = void 0;
|
|
28
|
+
var B = 10;
|
|
29
|
+
function V(a) {
|
|
30
|
+
if (typeof a != "function") throw TypeError("The \"listener\" argument must be of type Function. Received type " + typeof a);
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(z, "defaultMaxListeners", {
|
|
33
|
+
enumerable: !0,
|
|
34
|
+
get: function() {
|
|
35
|
+
return B;
|
|
36
|
+
},
|
|
37
|
+
set: function(a) {
|
|
38
|
+
if (typeof a != "number" || a < 0 || R(a)) throw RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received " + a + ".");
|
|
39
|
+
B = a;
|
|
40
|
+
}
|
|
41
|
+
}), z.init = function() {
|
|
42
|
+
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
43
|
+
}, z.prototype.setMaxListeners = function(a) {
|
|
44
|
+
if (typeof a != "number" || a < 0 || R(a)) throw RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received " + a + ".");
|
|
45
|
+
return this._maxListeners = a, this;
|
|
46
|
+
};
|
|
47
|
+
function H(a) {
|
|
48
|
+
return a._maxListeners === void 0 ? z.defaultMaxListeners : a._maxListeners;
|
|
49
|
+
}
|
|
50
|
+
z.prototype.getMaxListeners = function() {
|
|
51
|
+
return H(this);
|
|
52
|
+
}, z.prototype.emit = function(a) {
|
|
53
|
+
for (var N = [], P = 1; P < arguments.length; P++) N.push(arguments[P]);
|
|
54
|
+
var I = a === "error", L = this._events;
|
|
55
|
+
if (L !== void 0) I &&= L.error === void 0;
|
|
56
|
+
else if (!I) return !1;
|
|
57
|
+
if (I) {
|
|
58
|
+
var R;
|
|
59
|
+
if (N.length > 0 && (R = N[0]), R instanceof Error) throw R;
|
|
60
|
+
var z = /* @__PURE__ */ Error("Unhandled error." + (R ? " (" + R.message + ")" : ""));
|
|
61
|
+
throw z.context = R, z;
|
|
62
|
+
}
|
|
63
|
+
var B = L[a];
|
|
64
|
+
if (B === void 0) return !1;
|
|
65
|
+
if (typeof B == "function") F(B, this, N);
|
|
66
|
+
else for (var V = B.length, H = J(B, V), P = 0; P < V; ++P) F(H[P], this, N);
|
|
67
|
+
return !0;
|
|
68
|
+
};
|
|
69
|
+
function U(a, N, P, F) {
|
|
70
|
+
var I, R, z;
|
|
71
|
+
if (V(P), R = a._events, R === void 0 ? (R = a._events = Object.create(null), a._eventsCount = 0) : (R.newListener !== void 0 && (a.emit("newListener", N, P.listener ? P.listener : P), R = a._events), z = R[N]), z === void 0) z = R[N] = P, ++a._eventsCount;
|
|
72
|
+
else if (typeof z == "function" ? z = R[N] = F ? [P, z] : [z, P] : F ? z.unshift(P) : z.push(P), I = H(a), I > 0 && z.length > I && !z.warned) {
|
|
73
|
+
z.warned = !0;
|
|
74
|
+
var B = /* @__PURE__ */ Error("Possible EventEmitter memory leak detected. " + z.length + " " + String(N) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
75
|
+
B.name = "MaxListenersExceededWarning", B.emitter = a, B.type = N, B.count = z.length, L(B);
|
|
76
|
+
}
|
|
77
|
+
return a;
|
|
78
|
+
}
|
|
79
|
+
z.prototype.addListener = function(a, N) {
|
|
80
|
+
return U(this, a, N, !1);
|
|
81
|
+
}, z.prototype.on = z.prototype.addListener, z.prototype.prependListener = function(a, N) {
|
|
82
|
+
return U(this, a, N, !0);
|
|
83
|
+
};
|
|
84
|
+
function W() {
|
|
85
|
+
if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
86
|
+
}
|
|
87
|
+
function G(a, N, P) {
|
|
88
|
+
var F = {
|
|
89
|
+
fired: !1,
|
|
90
|
+
wrapFn: void 0,
|
|
91
|
+
target: a,
|
|
92
|
+
type: N,
|
|
93
|
+
listener: P
|
|
94
|
+
}, I = W.bind(F);
|
|
95
|
+
return I.listener = P, F.wrapFn = I, I;
|
|
96
|
+
}
|
|
97
|
+
z.prototype.once = function(a, N) {
|
|
98
|
+
return V(N), this.on(a, G(this, a, N)), this;
|
|
99
|
+
}, z.prototype.prependOnceListener = function(a, N) {
|
|
100
|
+
return V(N), this.prependListener(a, G(this, a, N)), this;
|
|
101
|
+
}, z.prototype.removeListener = function(a, N) {
|
|
102
|
+
var P, F, I, L, R;
|
|
103
|
+
if (V(N), F = this._events, F === void 0 || (P = F[a], P === void 0)) return this;
|
|
104
|
+
if (P === N || P.listener === N) --this._eventsCount === 0 ? this._events = Object.create(null) : (delete F[a], F.removeListener && this.emit("removeListener", a, P.listener || N));
|
|
105
|
+
else if (typeof P != "function") {
|
|
106
|
+
for (I = -1, L = P.length - 1; L >= 0; L--) if (P[L] === N || P[L].listener === N) {
|
|
107
|
+
R = P[L].listener, I = L;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (I < 0) return this;
|
|
111
|
+
I === 0 ? P.shift() : Y(P, I), P.length === 1 && (F[a] = P[0]), F.removeListener !== void 0 && this.emit("removeListener", a, R || N);
|
|
112
|
+
}
|
|
113
|
+
return this;
|
|
114
|
+
}, z.prototype.off = z.prototype.removeListener, z.prototype.removeAllListeners = function(a) {
|
|
115
|
+
var N, P = this._events, F;
|
|
116
|
+
if (P === void 0) return this;
|
|
117
|
+
if (P.removeListener === void 0) return arguments.length === 0 ? (this._events = Object.create(null), this._eventsCount = 0) : P[a] !== void 0 && (--this._eventsCount === 0 ? this._events = Object.create(null) : delete P[a]), this;
|
|
118
|
+
if (arguments.length === 0) {
|
|
119
|
+
var I = Object.keys(P), L;
|
|
120
|
+
for (F = 0; F < I.length; ++F) L = I[F], L !== "removeListener" && this.removeAllListeners(L);
|
|
121
|
+
return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this;
|
|
122
|
+
}
|
|
123
|
+
if (N = P[a], typeof N == "function") this.removeListener(a, N);
|
|
124
|
+
else if (N !== void 0) for (F = N.length - 1; F >= 0; F--) this.removeListener(a, N[F]);
|
|
125
|
+
return this;
|
|
126
|
+
};
|
|
127
|
+
function K(a, N, P) {
|
|
128
|
+
var F = a._events;
|
|
129
|
+
if (F === void 0) return [];
|
|
130
|
+
var I = F[N];
|
|
131
|
+
return I === void 0 ? [] : typeof I == "function" ? P ? [I.listener || I] : [I] : P ? X(I) : J(I, I.length);
|
|
132
|
+
}
|
|
133
|
+
z.prototype.listeners = function(a) {
|
|
134
|
+
return K(this, a, !0);
|
|
135
|
+
}, z.prototype.rawListeners = function(a) {
|
|
136
|
+
return K(this, a, !1);
|
|
137
|
+
}, z.listenerCount = function(a, N) {
|
|
138
|
+
return typeof a.listenerCount == "function" ? a.listenerCount(N) : q.call(a, N);
|
|
139
|
+
}, z.prototype.listenerCount = q;
|
|
140
|
+
function q(a) {
|
|
141
|
+
var N = this._events;
|
|
142
|
+
if (N !== void 0) {
|
|
143
|
+
var P = N[a];
|
|
144
|
+
if (typeof P == "function") return 1;
|
|
145
|
+
if (P !== void 0) return P.length;
|
|
146
|
+
}
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
z.prototype.eventNames = function() {
|
|
150
|
+
return this._eventsCount > 0 ? I(this._events) : [];
|
|
151
|
+
};
|
|
152
|
+
function J(a, N) {
|
|
153
|
+
for (var P = Array(N), F = 0; F < N; ++F) P[F] = a[F];
|
|
154
|
+
return P;
|
|
155
|
+
}
|
|
156
|
+
function Y(a, N) {
|
|
157
|
+
for (; N + 1 < a.length; N++) a[N] = a[N + 1];
|
|
158
|
+
a.pop();
|
|
159
|
+
}
|
|
160
|
+
function X(a) {
|
|
161
|
+
for (var N = Array(a.length), P = 0; P < N.length; ++P) N[P] = a[P].listener || a[P];
|
|
162
|
+
return N;
|
|
163
|
+
}
|
|
164
|
+
function Z(a, N) {
|
|
165
|
+
return new Promise(function(P, F) {
|
|
166
|
+
function I(P) {
|
|
167
|
+
a.removeListener(N, L), F(P);
|
|
168
|
+
}
|
|
169
|
+
function L() {
|
|
170
|
+
typeof a.removeListener == "function" && a.removeListener("error", I), P([].slice.call(arguments));
|
|
171
|
+
}
|
|
172
|
+
$(a, N, L, { once: !0 }), N !== "error" && Q(a, I, { once: !0 });
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function Q(a, N, P) {
|
|
176
|
+
typeof a.on == "function" && $(a, "error", N, P);
|
|
177
|
+
}
|
|
178
|
+
function $(a, N, P, F) {
|
|
179
|
+
if (typeof a.on == "function") F.once ? a.once(N, P) : a.on(N, P);
|
|
180
|
+
else if (typeof a.addEventListener == "function") a.addEventListener(N, function I(L) {
|
|
181
|
+
F.once && a.removeEventListener(N, I), P(L);
|
|
182
|
+
});
|
|
183
|
+
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof a);
|
|
184
|
+
}
|
|
185
|
+
})))(), 1), __defProp$32 = Object.defineProperty, __defNormalProp$20 = (a, N, P) => N in a ? __defProp$32(a, N, {
|
|
186
|
+
enumerable: !0,
|
|
187
|
+
configurable: !0,
|
|
188
|
+
writable: !0,
|
|
189
|
+
value: P
|
|
190
|
+
}) : a[N] = P, __publicField$20 = (a, N, P) => (__defNormalProp$20(a, typeof N == "symbol" ? N : N + "", P), P), LEVELS_ORDER$12 = [
|
|
191
|
+
"error",
|
|
192
|
+
"ok",
|
|
193
|
+
"warn",
|
|
194
|
+
"flux",
|
|
195
|
+
"deprecated",
|
|
196
|
+
"info",
|
|
197
|
+
"log",
|
|
198
|
+
"debug"
|
|
199
|
+
];
|
|
200
|
+
function isWindowWithWemap$12(a) {
|
|
201
|
+
return "wemap" in a;
|
|
202
|
+
}
|
|
203
|
+
var _Logger$12 = class a {
|
|
204
|
+
static enable(N) {
|
|
205
|
+
a.ENABLED = !!N;
|
|
206
|
+
}
|
|
207
|
+
static level(N) {
|
|
208
|
+
return arguments.length && (a.LOG_LEVEL = N), a.LOG_LEVEL;
|
|
209
|
+
}
|
|
210
|
+
static clearHistory() {
|
|
211
|
+
a.HISTORY = [];
|
|
212
|
+
}
|
|
213
|
+
static _canUseLog(N) {
|
|
214
|
+
let P = LEVELS_ORDER$12.indexOf(N), F = LEVELS_ORDER$12.indexOf(a.LOG_LEVEL);
|
|
215
|
+
return F === -1 ? !1 : P <= F;
|
|
216
|
+
}
|
|
217
|
+
static _getColorByType(a) {
|
|
218
|
+
let N = null;
|
|
219
|
+
switch (a) {
|
|
220
|
+
case "flux":
|
|
221
|
+
N = "background-color: #0083E0; color: #FFFFFF;";
|
|
222
|
+
break;
|
|
223
|
+
case "ok":
|
|
224
|
+
N = "background-color: #00FF22; color: #272727;";
|
|
225
|
+
break;
|
|
226
|
+
case "deprecated":
|
|
227
|
+
N = "background-color: #CA0AFA; color: #FFFFFF;";
|
|
228
|
+
break;
|
|
229
|
+
case "error":
|
|
230
|
+
N = "background-color: #CC0000; color: #FFFFFF;";
|
|
231
|
+
break;
|
|
232
|
+
case "warn":
|
|
233
|
+
N = "background-color: #DD7908; color: #FFFFFF;";
|
|
234
|
+
break;
|
|
235
|
+
case "debug":
|
|
236
|
+
N = "background-color: #999999; color: #FFFFFF;";
|
|
237
|
+
break;
|
|
238
|
+
case "info":
|
|
239
|
+
N = "background-color: #DCFF4E; color: #000000;";
|
|
240
|
+
break;
|
|
241
|
+
default:
|
|
242
|
+
N = "background-color: #F4F4F4; color: #999999;";
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
return N;
|
|
246
|
+
}
|
|
247
|
+
static _getOriginByType(a, N) {
|
|
248
|
+
let P = null, F = null, I = N;
|
|
249
|
+
if (arguments.length < 2) return "";
|
|
250
|
+
try {
|
|
251
|
+
for (P = "", F = a.stack && a.stack.length ? a.stack.split("\n").splice(3) : [], (I < 0 || I >= F.length) && (I = F.length); I;) P += "\r\n " + F[0].trim(), F = F.splice(1), I--;
|
|
252
|
+
return P;
|
|
253
|
+
} catch {
|
|
254
|
+
return "";
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
static _log(N, P, F) {
|
|
258
|
+
let I = "color: auto;", L = "color: #6A6A6A;", R = typeof window < "u", z, B = null, V = null, H = null, U = null, K = "", q = !1;
|
|
259
|
+
if (B = N, U = Error(P), R && (V = a._getColorByType(N)), H = a._getOriginByType(U, F), B === "deprecated" && (B = "warn", q = "deprecated"), R && (H = a._COLOR_TOKEN + H), z = (R ? a._COLOR_TOKEN : "") + " " + U.message, K = R ? a._COLOR_TOKEN : "", K += a._TYPE_PREFIX, K += q || N, K += a._TYPE_SUFFIX, typeof window < "u" && isWindowWithWemap$12(window)) {
|
|
260
|
+
let a = performance && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime();
|
|
261
|
+
K += "[" + Math.round(a - window.wemap.startTime) + "ms]";
|
|
262
|
+
}
|
|
263
|
+
return z = K + z, a.SHOW_ORIGIN && (z += H), a.HISTORY.push(z), !this._canUseLog(N) || arguments.length < 2 || !a.ENABLED ? !1 : (R ? console && N !== "ok" && N !== "flux" && N !== "deprecated" && console[N] && LEVELS_ORDER$12.indexOf(N) <= LEVELS_ORDER$12.indexOf("info") ? console[N](z, V, I, L) : console.log(z, V, I, L) : console.log(z), !0);
|
|
264
|
+
}
|
|
265
|
+
static external(a) {
|
|
266
|
+
return console.log("LIVEMAP :: " + a);
|
|
267
|
+
}
|
|
268
|
+
static flux(N) {
|
|
269
|
+
return a._log("flux", N, 0);
|
|
270
|
+
}
|
|
271
|
+
static ok(N) {
|
|
272
|
+
return a._log("ok", N, 1);
|
|
273
|
+
}
|
|
274
|
+
static error(N, P = -1) {
|
|
275
|
+
return a._log("error", N, P);
|
|
276
|
+
}
|
|
277
|
+
static warn(N, P = 2) {
|
|
278
|
+
return a._log("warn", N, P);
|
|
279
|
+
}
|
|
280
|
+
static deprecated(N, P = 2) {
|
|
281
|
+
return a._log("deprecated", N, P);
|
|
282
|
+
}
|
|
283
|
+
static debug(N, P = -1) {
|
|
284
|
+
return a._log("debug", N, P);
|
|
285
|
+
}
|
|
286
|
+
static info(N, P = 0) {
|
|
287
|
+
return a._log("info", N, P);
|
|
288
|
+
}
|
|
289
|
+
static log(N, P = 1) {
|
|
290
|
+
return a._log("log", N, P);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
__publicField$20(_Logger$12, "LOG_LEVEL", "debug"), __publicField$20(_Logger$12, "SHOW_ORIGIN", !0), __publicField$20(_Logger$12, "ENABLED", !0), __publicField$20(_Logger$12, "HISTORY", []), __publicField$20(_Logger$12, "_COLOR_TOKEN", "%c"), __publicField$20(_Logger$12, "_TYPE_PREFIX", "<<<< "), __publicField$20(_Logger$12, "_TYPE_SUFFIX", " >>>>");
|
|
294
|
+
var Logger$7 = _Logger$12, e$12 = class a {
|
|
295
|
+
constructor(N, P, F, I, L) {
|
|
296
|
+
this._legacyCanvasSize = a.DEFAULT_CANVAS_SIZE, this._preferredCamera = "environment", this._maxScansPerSecond = 25, this._lastScanTimestamp = -1, this._destroyed = this._flashOn = this._paused = this._active = !1, this.$video = N, this.$canvas = document.createElement("canvas"), F && typeof F == "object" ? this._onDecode = P : (F || I || L ? console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future") : console.warn("Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."), this._legacyOnDecode = P), P = typeof F == "object" ? F : {}, this._onDecodeError = P.onDecodeError || (typeof F == "function" ? F : this._onDecodeError), this._calculateScanRegion = P.calculateScanRegion || (typeof I == "function" ? I : this._calculateScanRegion), this._preferredCamera = P.preferredCamera || L || this._preferredCamera, this._legacyCanvasSize = typeof F == "number" ? F : typeof I == "number" ? I : this._legacyCanvasSize, this._maxScansPerSecond = P.maxScansPerSecond || this._maxScansPerSecond, this._onPlay = this._onPlay.bind(this), this._onLoadedMetaData = this._onLoadedMetaData.bind(this), this._onVisibilityChange = this._onVisibilityChange.bind(this), this._updateOverlay = this._updateOverlay.bind(this), N.disablePictureInPicture = !0, N.playsInline = !0, N.muted = !0;
|
|
297
|
+
let R = !1;
|
|
298
|
+
if (N.hidden && (N.hidden = !1, R = !0), document.body.contains(N) || (document.body.appendChild(N), R = !0), F = N.parentElement, P.highlightScanRegion || P.highlightCodeOutline) {
|
|
299
|
+
if (I = !!P.overlay, this.$overlay = P.overlay || document.createElement("div"), L = this.$overlay.style, L.position = "absolute", L.display = "none", L.pointerEvents = "none", this.$overlay.classList.add("scan-region-highlight"), !I && P.highlightScanRegion) {
|
|
300
|
+
this.$overlay.innerHTML = "<svg class=\"scan-region-highlight-svg\" viewBox=\"0 0 238 238\" preserveAspectRatio=\"none\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round\"><path d=\"M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21\"/></svg>";
|
|
301
|
+
try {
|
|
302
|
+
this.$overlay.firstElementChild.animate({ transform: ["scale(.98)", "scale(1.01)"] }, {
|
|
303
|
+
duration: 400,
|
|
304
|
+
iterations: Infinity,
|
|
305
|
+
direction: "alternate",
|
|
306
|
+
easing: "ease-in-out"
|
|
307
|
+
});
|
|
308
|
+
} catch {}
|
|
309
|
+
F.insertBefore(this.$overlay, this.$video.nextSibling);
|
|
310
|
+
}
|
|
311
|
+
P.highlightCodeOutline && (this.$overlay.insertAdjacentHTML("beforeend", "<svg class=\"code-outline-highlight\" preserveAspectRatio=\"none\" style=\"display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round\"><polygon/></svg>"), this.$codeOutlineHighlight = this.$overlay.lastElementChild);
|
|
312
|
+
}
|
|
313
|
+
this._scanRegion = this._calculateScanRegion(N), requestAnimationFrame(() => {
|
|
314
|
+
let a = window.getComputedStyle(N);
|
|
315
|
+
a.display === "none" && (N.style.setProperty("display", "block", "important"), R = !0), a.visibility !== "visible" && (N.style.setProperty("visibility", "visible", "important"), R = !0), R && (console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."), N.style.opacity = "0", N.style.width = "0", N.style.height = "0", this.$overlay && this.$overlay.parentElement && this.$overlay.parentElement.removeChild(this.$overlay), delete this.$overlay, delete this.$codeOutlineHighlight), this.$overlay && this._updateOverlay();
|
|
316
|
+
}), N.addEventListener("play", this._onPlay), N.addEventListener("loadedmetadata", this._onLoadedMetaData), document.addEventListener("visibilitychange", this._onVisibilityChange), window.addEventListener("resize", this._updateOverlay), this._qrEnginePromise = a.createQrEngine();
|
|
317
|
+
}
|
|
318
|
+
static set WORKER_PATH(a) {
|
|
319
|
+
console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.");
|
|
320
|
+
}
|
|
321
|
+
static async hasCamera() {
|
|
322
|
+
try {
|
|
323
|
+
return !!(await a.listCameras(!1)).length;
|
|
324
|
+
} catch {
|
|
325
|
+
return !1;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
static async listCameras(N = !1) {
|
|
329
|
+
if (!navigator.mediaDevices) return [];
|
|
330
|
+
let P = async () => (await navigator.mediaDevices.enumerateDevices()).filter((a) => a.kind === "videoinput"), F;
|
|
331
|
+
try {
|
|
332
|
+
N && (await P()).every((a) => !a.label) && (F = await navigator.mediaDevices.getUserMedia({
|
|
333
|
+
audio: !1,
|
|
334
|
+
video: !0
|
|
335
|
+
}));
|
|
336
|
+
} catch {}
|
|
337
|
+
try {
|
|
338
|
+
return (await P()).map((a, N) => ({
|
|
339
|
+
id: a.deviceId,
|
|
340
|
+
label: a.label || (N === 0 ? "Default Camera" : `Camera ${N + 1}`)
|
|
341
|
+
}));
|
|
342
|
+
} finally {
|
|
343
|
+
F && (console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"), a._stopVideoStream(F));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
async hasFlash() {
|
|
347
|
+
let N;
|
|
348
|
+
try {
|
|
349
|
+
if (this.$video.srcObject) {
|
|
350
|
+
if (!(this.$video.srcObject instanceof MediaStream)) return !1;
|
|
351
|
+
N = this.$video.srcObject;
|
|
352
|
+
} else N = (await this._getCameraStream()).stream;
|
|
353
|
+
return "torch" in N.getVideoTracks()[0].getSettings();
|
|
354
|
+
} catch {
|
|
355
|
+
return !1;
|
|
356
|
+
} finally {
|
|
357
|
+
N && N !== this.$video.srcObject && (console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"), a._stopVideoStream(N));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
isFlashOn() {
|
|
361
|
+
return this._flashOn;
|
|
362
|
+
}
|
|
363
|
+
async toggleFlash() {
|
|
364
|
+
this._flashOn ? await this.turnFlashOff() : await this.turnFlashOn();
|
|
365
|
+
}
|
|
366
|
+
async turnFlashOn() {
|
|
367
|
+
if (!this._flashOn && !this._destroyed && (this._flashOn = !0, this._active && !this._paused)) try {
|
|
368
|
+
if (!await this.hasFlash()) throw "No flash available";
|
|
369
|
+
await this.$video.srcObject.getVideoTracks()[0].applyConstraints({ advanced: [{ torch: !0 }] });
|
|
370
|
+
} catch (a) {
|
|
371
|
+
throw this._flashOn = !1, a;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
async turnFlashOff() {
|
|
375
|
+
this._flashOn && (this._flashOn = !1, await this._restartVideoStream());
|
|
376
|
+
}
|
|
377
|
+
destroy() {
|
|
378
|
+
this.$video.removeEventListener("loadedmetadata", this._onLoadedMetaData), this.$video.removeEventListener("play", this._onPlay), document.removeEventListener("visibilitychange", this._onVisibilityChange), window.removeEventListener("resize", this._updateOverlay), this._destroyed = !0, this._flashOn = !1, this.stop(), a._postWorkerMessage(this._qrEnginePromise, "close");
|
|
379
|
+
}
|
|
380
|
+
async start() {
|
|
381
|
+
if (this._destroyed) throw Error("The QR scanner can not be started as it had been destroyed.");
|
|
382
|
+
if ((!this._active || this._paused) && (window.location.protocol !== "https:" && console.warn("The camera stream is only accessible if the page is transferred via https."), this._active = !0, !document.hidden)) if (this._paused = !1, this.$video.srcObject) await this.$video.play();
|
|
383
|
+
else try {
|
|
384
|
+
let { stream: N, facingMode: P } = await this._getCameraStream();
|
|
385
|
+
!this._active || this._paused ? a._stopVideoStream(N) : (this._setVideoMirror(P), this.$video.srcObject = N, await this.$video.play(), this._flashOn && (this._flashOn = !1, this.turnFlashOn().catch(() => {})));
|
|
386
|
+
} catch (a) {
|
|
387
|
+
if (!this._paused) throw this._active = !1, a;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
stop() {
|
|
391
|
+
this.pause(), this._active = !1;
|
|
392
|
+
}
|
|
393
|
+
async pause(N = !1) {
|
|
394
|
+
if (this._paused = !0, !this._active) return !0;
|
|
395
|
+
this.$video.pause(), this.$overlay && (this.$overlay.style.display = "none");
|
|
396
|
+
let P = () => {
|
|
397
|
+
this.$video.srcObject instanceof MediaStream && (a._stopVideoStream(this.$video.srcObject), this.$video.srcObject = null);
|
|
398
|
+
};
|
|
399
|
+
return N ? (P(), !0) : (await new Promise((a) => setTimeout(a, 300)), this._paused ? (P(), !0) : !1);
|
|
400
|
+
}
|
|
401
|
+
async setCamera(a) {
|
|
402
|
+
a !== this._preferredCamera && (this._preferredCamera = a, await this._restartVideoStream());
|
|
403
|
+
}
|
|
404
|
+
static async scanImage(N, P, F, I, L = !1, R = !1) {
|
|
405
|
+
let z, B = !1;
|
|
406
|
+
P && ("scanRegion" in P || "qrEngine" in P || "canvas" in P || "disallowCanvasResizing" in P || "alsoTryWithoutScanRegion" in P || "returnDetailedScanResult" in P) ? (z = P.scanRegion, F = P.qrEngine, I = P.canvas, L = P.disallowCanvasResizing || !1, R = P.alsoTryWithoutScanRegion || !1, B = !0) : P || F || I || L || R ? console.warn("You're using a deprecated api for scanImage which will be removed in the future.") : console.warn("Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."), P = !!F;
|
|
407
|
+
try {
|
|
408
|
+
let V, H;
|
|
409
|
+
[F, V] = await Promise.all([F || a.createQrEngine(), a._loadImage(N)]), [I, H] = a._drawToCanvas(V, z, I, L);
|
|
410
|
+
let U;
|
|
411
|
+
if (F instanceof Worker) {
|
|
412
|
+
let N = F;
|
|
413
|
+
P || a._postWorkerMessageSync(N, "inversionMode", "both"), U = await new Promise((P, F) => {
|
|
414
|
+
let L, R, B, V = -1;
|
|
415
|
+
R = (I) => {
|
|
416
|
+
I.data.id === V && (N.removeEventListener("message", R), N.removeEventListener("error", B), clearTimeout(L), I.data.data === null ? F(a.NO_QR_CODE_FOUND) : P({
|
|
417
|
+
data: I.data.data,
|
|
418
|
+
cornerPoints: a._convertPoints(I.data.cornerPoints, z)
|
|
419
|
+
}));
|
|
420
|
+
}, B = (a) => {
|
|
421
|
+
N.removeEventListener("message", R), N.removeEventListener("error", B), clearTimeout(L), F("Scanner error: " + (a ? a.message || a : "Unknown Error"));
|
|
422
|
+
}, N.addEventListener("message", R), N.addEventListener("error", B), L = setTimeout(() => B("timeout"), 1e4);
|
|
423
|
+
let U = H.getImageData(0, 0, I.width, I.height);
|
|
424
|
+
V = a._postWorkerMessageSync(N, "decode", U, [U.data.buffer]);
|
|
425
|
+
});
|
|
426
|
+
} else U = await Promise.race([new Promise((a, N) => window.setTimeout(() => N("Scanner error: timeout"), 1e4)), (async () => {
|
|
427
|
+
try {
|
|
428
|
+
var [P] = await F.detect(I);
|
|
429
|
+
if (!P) throw a.NO_QR_CODE_FOUND;
|
|
430
|
+
return {
|
|
431
|
+
data: P.rawValue,
|
|
432
|
+
cornerPoints: a._convertPoints(P.cornerPoints, z)
|
|
433
|
+
};
|
|
434
|
+
} catch (F) {
|
|
435
|
+
if (P = F.message || F, /not implemented|service unavailable/.test(P)) return a._disableBarcodeDetector = !0, a.scanImage(N, {
|
|
436
|
+
scanRegion: z,
|
|
437
|
+
canvas: I,
|
|
438
|
+
disallowCanvasResizing: L,
|
|
439
|
+
alsoTryWithoutScanRegion: R
|
|
440
|
+
});
|
|
441
|
+
throw `Scanner error: ${P}`;
|
|
442
|
+
}
|
|
443
|
+
})()]);
|
|
444
|
+
return B ? U : U.data;
|
|
445
|
+
} catch (P) {
|
|
446
|
+
if (!z || !R) throw P;
|
|
447
|
+
let V = await a.scanImage(N, {
|
|
448
|
+
qrEngine: F,
|
|
449
|
+
canvas: I,
|
|
450
|
+
disallowCanvasResizing: L
|
|
451
|
+
});
|
|
452
|
+
return B ? V : V.data;
|
|
453
|
+
} finally {
|
|
454
|
+
P || a._postWorkerMessage(F, "close");
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
setGrayscaleWeights(N, P, F, I = !0) {
|
|
458
|
+
a._postWorkerMessage(this._qrEnginePromise, "grayscaleWeights", {
|
|
459
|
+
red: N,
|
|
460
|
+
green: P,
|
|
461
|
+
blue: F,
|
|
462
|
+
useIntegerApproximation: I
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
setInversionMode(N) {
|
|
466
|
+
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
467
|
+
}
|
|
468
|
+
static async createQrEngine(N) {
|
|
469
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
470
|
+
let P = navigator.userAgentData;
|
|
471
|
+
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
472
|
+
}
|
|
473
|
+
_onPlay() {
|
|
474
|
+
this._scanRegion = this._calculateScanRegion(this.$video), this._updateOverlay(), this.$overlay && (this.$overlay.style.display = ""), this._scanFrame();
|
|
475
|
+
}
|
|
476
|
+
_onLoadedMetaData() {
|
|
477
|
+
this._scanRegion = this._calculateScanRegion(this.$video), this._updateOverlay();
|
|
478
|
+
}
|
|
479
|
+
_onVisibilityChange() {
|
|
480
|
+
document.hidden ? this.pause() : this._active && this.start();
|
|
481
|
+
}
|
|
482
|
+
_calculateScanRegion(a) {
|
|
483
|
+
let N = Math.round(2 / 3 * Math.min(a.videoWidth, a.videoHeight));
|
|
484
|
+
return {
|
|
485
|
+
x: Math.round((a.videoWidth - N) / 2),
|
|
486
|
+
y: Math.round((a.videoHeight - N) / 2),
|
|
487
|
+
width: N,
|
|
488
|
+
height: N,
|
|
489
|
+
downScaledWidth: this._legacyCanvasSize,
|
|
490
|
+
downScaledHeight: this._legacyCanvasSize
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
_updateOverlay() {
|
|
494
|
+
requestAnimationFrame(() => {
|
|
495
|
+
if (this.$overlay) {
|
|
496
|
+
var a = this.$video, N = a.videoWidth, P = a.videoHeight, F = a.offsetWidth, I = a.offsetHeight, L = a.offsetLeft, R = a.offsetTop, z = window.getComputedStyle(a), B = z.objectFit, V = N / P, H = F / I;
|
|
497
|
+
switch (B) {
|
|
498
|
+
case "none":
|
|
499
|
+
var U = N, W = P;
|
|
500
|
+
break;
|
|
501
|
+
case "fill":
|
|
502
|
+
U = F, W = I;
|
|
503
|
+
break;
|
|
504
|
+
default: (B === "cover" ? V > H : V < H) ? (W = I, U = W * V) : (U = F, W = U / V), B === "scale-down" && (U = Math.min(U, N), W = Math.min(W, P));
|
|
505
|
+
}
|
|
506
|
+
var [G, K] = z.objectPosition.split(" ").map((a, N) => {
|
|
507
|
+
let P = parseFloat(a);
|
|
508
|
+
return a.endsWith("%") ? (N ? I - W : F - U) * P / 100 : P;
|
|
509
|
+
});
|
|
510
|
+
z = this._scanRegion.width || N, H = this._scanRegion.height || P, B = this._scanRegion.x || 0;
|
|
511
|
+
var q = this._scanRegion.y || 0;
|
|
512
|
+
V = this.$overlay.style, V.width = `${z / N * U}px`, V.height = `${H / P * W}px`, V.top = `${R + K + q / P * W}px`, P = /scaleX\(-1\)/.test(a.style.transform), V.left = `${L + (P ? F - G - U : G) + (P ? N - B - z : B) / N * U}px`, V.transform = a.style.transform;
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
static _convertPoints(a, N) {
|
|
517
|
+
if (!N) return a;
|
|
518
|
+
let P = N.x || 0, F = N.y || 0, I = N.width && N.downScaledWidth ? N.width / N.downScaledWidth : 1;
|
|
519
|
+
N = N.height && N.downScaledHeight ? N.height / N.downScaledHeight : 1;
|
|
520
|
+
for (let L of a) L.x = L.x * I + P, L.y = L.y * N + F;
|
|
521
|
+
return a;
|
|
522
|
+
}
|
|
523
|
+
_scanFrame() {
|
|
524
|
+
!this._active || this.$video.paused || this.$video.ended || ("requestVideoFrameCallback" in this.$video ? this.$video.requestVideoFrameCallback.bind(this.$video) : requestAnimationFrame)(async () => {
|
|
525
|
+
if (!(1 >= this.$video.readyState)) {
|
|
526
|
+
var N = Date.now() - this._lastScanTimestamp, P = 1e3 / this._maxScansPerSecond;
|
|
527
|
+
N < P && await new Promise((a) => setTimeout(a, P - N)), this._lastScanTimestamp = Date.now();
|
|
528
|
+
try {
|
|
529
|
+
var F = await a.scanImage(this.$video, {
|
|
530
|
+
scanRegion: this._scanRegion,
|
|
531
|
+
qrEngine: this._qrEnginePromise,
|
|
532
|
+
canvas: this.$canvas
|
|
533
|
+
});
|
|
534
|
+
} catch (a) {
|
|
535
|
+
if (!this._active) return;
|
|
536
|
+
this._onDecodeError(a);
|
|
537
|
+
}
|
|
538
|
+
!a._disableBarcodeDetector || await this._qrEnginePromise instanceof Worker || (this._qrEnginePromise = a.createQrEngine()), F ? (this._onDecode ? this._onDecode(F) : this._legacyOnDecode && this._legacyOnDecode(F.data), this.$codeOutlineHighlight && (clearTimeout(this._codeOutlineHighlightRemovalTimeout), this._codeOutlineHighlightRemovalTimeout = void 0, this.$codeOutlineHighlight.setAttribute("viewBox", `${this._scanRegion.x || 0} ${this._scanRegion.y || 0} ${this._scanRegion.width || this.$video.videoWidth} ${this._scanRegion.height || this.$video.videoHeight}`), this.$codeOutlineHighlight.firstElementChild.setAttribute("points", F.cornerPoints.map(({ x: a, y: N }) => `${a},${N}`).join(" ")), this.$codeOutlineHighlight.style.display = "")) : this.$codeOutlineHighlight && !this._codeOutlineHighlightRemovalTimeout && (this._codeOutlineHighlightRemovalTimeout = setTimeout(() => this.$codeOutlineHighlight.style.display = "none", 100));
|
|
539
|
+
}
|
|
540
|
+
this._scanFrame();
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
_onDecodeError(N) {
|
|
544
|
+
N !== a.NO_QR_CODE_FOUND && console.log(N);
|
|
545
|
+
}
|
|
546
|
+
async _getCameraStream() {
|
|
547
|
+
if (!navigator.mediaDevices) throw "Camera not found.";
|
|
548
|
+
let a = /^(environment|user)$/.test(this._preferredCamera) ? "facingMode" : "deviceId", N = [
|
|
549
|
+
{ width: { min: 1024 } },
|
|
550
|
+
{ width: { min: 768 } },
|
|
551
|
+
{}
|
|
552
|
+
], P = N.map((N) => Object.assign({}, N, { [a]: { exact: this._preferredCamera } }));
|
|
553
|
+
for (let a of [...P, ...N]) try {
|
|
554
|
+
let N = await navigator.mediaDevices.getUserMedia({
|
|
555
|
+
video: a,
|
|
556
|
+
audio: !1
|
|
557
|
+
});
|
|
558
|
+
return {
|
|
559
|
+
stream: N,
|
|
560
|
+
facingMode: this._getFacingMode(N) || (a.facingMode ? this._preferredCamera : this._preferredCamera === "environment" ? "user" : "environment")
|
|
561
|
+
};
|
|
562
|
+
} catch {}
|
|
563
|
+
throw "Camera not found.";
|
|
564
|
+
}
|
|
565
|
+
async _restartVideoStream() {
|
|
566
|
+
let a = this._paused;
|
|
567
|
+
await this.pause(!0) && !a && this._active && await this.start();
|
|
568
|
+
}
|
|
569
|
+
static _stopVideoStream(a) {
|
|
570
|
+
for (let N of a.getTracks()) N.stop(), a.removeTrack(N);
|
|
571
|
+
}
|
|
572
|
+
_setVideoMirror(a) {
|
|
573
|
+
this.$video.style.transform = "scaleX(" + (a === "user" ? -1 : 1) + ")";
|
|
574
|
+
}
|
|
575
|
+
_getFacingMode(a) {
|
|
576
|
+
return (a = a.getVideoTracks()[0]) ? /rear|back|environment/i.test(a.label) ? "environment" : /front|user|face/i.test(a.label) ? "user" : null : null;
|
|
577
|
+
}
|
|
578
|
+
static _drawToCanvas(a, N, P, F = !1) {
|
|
579
|
+
P ||= document.createElement("canvas");
|
|
580
|
+
let I = N && N.x ? N.x : 0, L = N && N.y ? N.y : 0, R = N && N.width ? N.width : a.videoWidth || a.width, z = N && N.height ? N.height : a.videoHeight || a.height;
|
|
581
|
+
return F || (F = N && N.downScaledWidth ? N.downScaledWidth : R, N = N && N.downScaledHeight ? N.downScaledHeight : z, P.width !== F && (P.width = F), P.height !== N && (P.height = N)), N = P.getContext("2d", { alpha: !1 }), N.imageSmoothingEnabled = !1, N.drawImage(a, I, L, R, z, 0, 0, P.width, P.height), [P, N];
|
|
582
|
+
}
|
|
583
|
+
static async _loadImage(N) {
|
|
584
|
+
if (N instanceof Image) return await a._awaitImageLoad(N), N;
|
|
585
|
+
if (N instanceof HTMLVideoElement || N instanceof HTMLCanvasElement || N instanceof SVGImageElement || "OffscreenCanvas" in window && N instanceof OffscreenCanvas || "ImageBitmap" in window && N instanceof ImageBitmap) return N;
|
|
586
|
+
if (N instanceof File || N instanceof Blob || N instanceof URL || typeof N == "string") {
|
|
587
|
+
let P = new Image();
|
|
588
|
+
P.src = N instanceof File || N instanceof Blob ? URL.createObjectURL(N) : N.toString();
|
|
589
|
+
try {
|
|
590
|
+
return await a._awaitImageLoad(P), P;
|
|
591
|
+
} finally {
|
|
592
|
+
(N instanceof File || N instanceof Blob) && URL.revokeObjectURL(P.src);
|
|
593
|
+
}
|
|
594
|
+
} else throw "Unsupported image type.";
|
|
595
|
+
}
|
|
596
|
+
static async _awaitImageLoad(a) {
|
|
597
|
+
a.complete && a.naturalWidth !== 0 || await new Promise((N, P) => {
|
|
598
|
+
let F = (I) => {
|
|
599
|
+
a.removeEventListener("load", F), a.removeEventListener("error", F), I instanceof ErrorEvent ? P("Image load error") : N();
|
|
600
|
+
};
|
|
601
|
+
a.addEventListener("load", F), a.addEventListener("error", F);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
static async _postWorkerMessage(N, P, F, I) {
|
|
605
|
+
return a._postWorkerMessageSync(await N, P, F, I);
|
|
606
|
+
}
|
|
607
|
+
static _postWorkerMessageSync(N, P, F, I) {
|
|
608
|
+
if (!(N instanceof Worker)) return -1;
|
|
609
|
+
let L = a._workerMessageId++;
|
|
610
|
+
return N.postMessage({
|
|
611
|
+
id: L,
|
|
612
|
+
type: P,
|
|
613
|
+
data: F
|
|
614
|
+
}, I), L;
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
e$12.DEFAULT_CANVAS_SIZE = 400, e$12.NO_QR_CODE_FOUND = "No QR code found", e$12._disableBarcodeDetector = !1, e$12._workerMessageId = 0;
|
|
618
|
+
var __defProp$31 = Object.defineProperty, __defNormalProp$19 = (a, N, P) => N in a ? __defProp$31(a, N, {
|
|
619
|
+
enumerable: !0,
|
|
620
|
+
configurable: !0,
|
|
621
|
+
writable: !0,
|
|
622
|
+
value: P
|
|
623
|
+
}) : a[N] = P, __publicField$19 = (a, N, P) => (__defNormalProp$19(a, typeof N == "symbol" ? N : N + "", P), P), SharedCameras$1$7 = new class extends import_events$12.default {
|
|
624
|
+
constructor() {
|
|
625
|
+
super(...arguments), __publicField$19(this, "_list", []);
|
|
626
|
+
}
|
|
627
|
+
_add(a, N) {
|
|
628
|
+
let P = {
|
|
629
|
+
camera: a,
|
|
630
|
+
container: N
|
|
631
|
+
};
|
|
632
|
+
this._list.push(P), this.emit("added", P);
|
|
633
|
+
}
|
|
634
|
+
_remove(a) {
|
|
635
|
+
this._list = this._list.filter(({ camera: N }) => N !== a), this.emit("removed", { camera: a });
|
|
636
|
+
}
|
|
637
|
+
get list() {
|
|
638
|
+
return this._list;
|
|
639
|
+
}
|
|
640
|
+
getCameraByContainer(a) {
|
|
641
|
+
return this._list.find((N) => N.container === a)?.camera || null;
|
|
642
|
+
}
|
|
643
|
+
}();
|
|
644
|
+
function convertFov$6(a, N) {
|
|
645
|
+
return 2 * Math.atan(Math.tan(a / 180 * Math.PI / 2) * N) * 180 / Math.PI;
|
|
646
|
+
}
|
|
647
|
+
function calcDisplayedFov$6(a, N, P) {
|
|
648
|
+
let F = N.videoWidth, I = N.videoHeight;
|
|
649
|
+
if (!F || !I) return null;
|
|
650
|
+
let L = a.offsetWidth, R = a.offsetHeight, z = F / I, B = L / R, V = P, H = convertFov$6(V, z);
|
|
651
|
+
return B < z ? H = convertFov$6(V, B) : V = convertFov$6(H, 1 / B), {
|
|
652
|
+
vertical: V,
|
|
653
|
+
horizontal: H
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
var _Camera$7 = class a extends import_events$12.default {
|
|
657
|
+
constructor(N, P = {}) {
|
|
658
|
+
super(), __publicField$19(this, "_userMediaConstraints"), __publicField$19(this, "videoStream", null), __publicField$19(this, "videoContainer"), __publicField$19(this, "videoElement"), __publicField$19(this, "fov", null), __publicField$19(this, "_state", "stopped"), __publicField$19(this, "_hardwareVerticalFov", a.GENERIC_HARDWARE_VERTICAL_FOV), __publicField$19(this, "_resizeOnWindowChange"), __publicField$19(this, "notifyContainerSizeChanged", () => {
|
|
659
|
+
this._resizeElement(), this._computeFov();
|
|
660
|
+
}), __publicField$19(this, "_resizeElement", () => {
|
|
661
|
+
if (!this.videoElement) throw Error("No video element found");
|
|
662
|
+
let a = this.videoElement.videoWidth, N = this.videoElement.videoHeight, P = this.videoContainer.offsetWidth, F = this.videoContainer.offsetHeight, I = a / N;
|
|
663
|
+
if (P / F < I) {
|
|
664
|
+
let a = I * F;
|
|
665
|
+
this.videoElement.style.width = a + "px", this.videoElement.style.marginLeft = -(a - P) / 2 + "px", this.videoElement.style.height = F + "px", this.videoElement.style.marginTop = "0px";
|
|
666
|
+
} else {
|
|
667
|
+
let a = 1 / (I / P);
|
|
668
|
+
this.videoElement.style.height = a + "px", this.videoElement.style.marginTop = -(a - F) / 2 + "px", this.videoElement.style.width = P + "px", this.videoElement.style.marginLeft = "0px";
|
|
669
|
+
}
|
|
670
|
+
}), __publicField$19(this, "_computeFov", () => {
|
|
671
|
+
["stopping", "stopped"].includes(this.state) || (this.fov = calcDisplayedFov$6(this.videoContainer, this.videoElement, this._hardwareVerticalFov), this.emit("fov.changed", this.fov));
|
|
672
|
+
}), P = Object.assign({}, a.DEFAULT_OPTIONS, P), SharedCameras$1$7._add(this, N), this.videoContainer = N, this._resizeOnWindowChange = P.resizeOnWindowChange, this._userMediaConstraints = {
|
|
673
|
+
audio: !1,
|
|
674
|
+
video: {
|
|
675
|
+
facingMode: "environment",
|
|
676
|
+
width: { ideal: P.width },
|
|
677
|
+
height: { ideal: P.height },
|
|
678
|
+
resizeMode: "none"
|
|
679
|
+
}
|
|
680
|
+
}, this.videoContainer.style.overflow = "hidden", this.videoElement = document.createElement("video"), this.videoElement.setAttribute("id", "wemap-camera"), this.videoElement.setAttribute("preload", "none"), this.videoElement.setAttribute("muted", ""), this.videoElement.setAttribute("playsinline", ""), this.videoContainer.appendChild(this.videoElement);
|
|
681
|
+
}
|
|
682
|
+
async start(N) {
|
|
683
|
+
if (this._state === "started" || this._state === "starting") throw Error("Camera is already started");
|
|
684
|
+
this._state === "stopping" && await new Promise((a) => this.once("stopped", a)), this._state = "starting", this.emit("starting"), await a.checkAvailability(), typeof N == "object" && Object.assign(this._userMediaConstraints.video, this._userMediaConstraints.video, N);
|
|
685
|
+
let P = await navigator.mediaDevices.getUserMedia(this._userMediaConstraints);
|
|
686
|
+
this.videoElement.oncanplaythrough = () => this.videoElement.play();
|
|
687
|
+
let F = new Promise((a) => this.videoElement.onloadedmetadata = a);
|
|
688
|
+
this.videoElement.srcObject = this.videoStream = P, await F, this._resizeElement(), this._computeFov(), this._resizeOnWindowChange && window.addEventListener("resize", this.notifyContainerSizeChanged), this._state = "started";
|
|
689
|
+
let I = {
|
|
690
|
+
videoElement: this.videoElement,
|
|
691
|
+
stream: P
|
|
692
|
+
};
|
|
693
|
+
return this.emit("started", I), I;
|
|
694
|
+
}
|
|
695
|
+
async stop() {
|
|
696
|
+
if (this._state === "stopped") throw Error("Camera is already stopped");
|
|
697
|
+
this._state === "starting" && await new Promise((a) => this.once("started", a)), this._state = "stopping", this.emit("stopping"), this.videoStream && this.videoStream.getVideoTracks().forEach((a) => a.stop()), this.videoStream = null, this.videoElement.srcObject = null, this._resizeOnWindowChange && window.removeEventListener("resize", this.notifyContainerSizeChanged), this._state = "stopped", this.emit("stopped");
|
|
698
|
+
}
|
|
699
|
+
release() {
|
|
700
|
+
this.videoContainer.removeChild(this.videoElement), SharedCameras$1$7._remove(this);
|
|
701
|
+
}
|
|
702
|
+
static async checkAvailability(a = !1) {
|
|
703
|
+
if (!navigator.mediaDevices) throw Error("navigator.mediaDevices not present in your browser");
|
|
704
|
+
if (!navigator.mediaDevices.enumerateDevices) throw Error("navigator.mediaDevices.enumerateDevices not present in your browser");
|
|
705
|
+
if (!navigator.mediaDevices.getUserMedia) throw Error("navigator.mediaDevices.getUserMedia not present in your browser");
|
|
706
|
+
if (!(await navigator.mediaDevices.enumerateDevices()).find((a) => a.kind === "videoinput")) throw Error("No camera found");
|
|
707
|
+
a && (await navigator.mediaDevices.getUserMedia({
|
|
708
|
+
audio: !1,
|
|
709
|
+
video: { facingMode: "environment" }
|
|
710
|
+
})).getVideoTracks().forEach((a) => a.stop());
|
|
711
|
+
}
|
|
712
|
+
get state() {
|
|
713
|
+
return this._state;
|
|
714
|
+
}
|
|
715
|
+
get hardwareVerticalFov() {
|
|
716
|
+
return this._hardwareVerticalFov;
|
|
717
|
+
}
|
|
718
|
+
set hardwareVerticalFov(a) {
|
|
719
|
+
this._hardwareVerticalFov = a, this._computeFov();
|
|
720
|
+
}
|
|
721
|
+
get currentImage() {
|
|
722
|
+
if (this._state !== "started") return Logger$7.warn("Trying to access image but video is not started"), Promise.resolve(null);
|
|
723
|
+
let { videoWidth: a, videoHeight: N } = this.videoElement, P = document.createElement("canvas"), F = P.getContext("2d");
|
|
724
|
+
return P.width = a, P.height = N, F?.drawImage(this.videoElement, 0, 0, a, N), Promise.resolve(P);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
__publicField$19(_Camera$7, "DEFAULT_OPTIONS", {
|
|
728
|
+
width: 1024,
|
|
729
|
+
height: 768,
|
|
730
|
+
resizeOnWindowChange: !1
|
|
731
|
+
}), __publicField$19(_Camera$7, "GENERIC_HARDWARE_VERTICAL_FOV", 60);
|
|
732
|
+
var Camera = _Camera$7, __create$11 = Object.create, __defProp$30 = Object.defineProperty, __getOwnPropDesc$11 = Object.getOwnPropertyDescriptor, __getOwnPropNames$11 = Object.getOwnPropertyNames, __getProtoOf$11 = Object.getPrototypeOf, __hasOwnProp$11 = Object.prototype.hasOwnProperty, __commonJSMin$11 = (a, N) => () => (N || a((N = { exports: {} }).exports, N), N.exports), __copyProps$11 = (a, N, P, F) => {
|
|
733
|
+
if (N && typeof N == "object" || typeof N == "function") for (var I = __getOwnPropNames$11(N), L = 0, R = I.length, z; L < R; L++) z = I[L], !__hasOwnProp$11.call(a, z) && z !== P && __defProp$30(a, z, {
|
|
734
|
+
get: ((a) => N[a]).bind(null, z),
|
|
735
|
+
enumerable: !(F = __getOwnPropDesc$11(N, z)) || F.enumerable
|
|
736
|
+
});
|
|
737
|
+
return a;
|
|
738
|
+
}, import_events$11 = /* @__PURE__ */ ((a, N, P) => (P = a == null ? {} : __create$11(__getProtoOf$11(a)), __copyProps$11(N || !a || !a.__esModule ? __defProp$30(P, "default", {
|
|
739
|
+
value: a,
|
|
740
|
+
enumerable: !0
|
|
741
|
+
}) : P, a)))((/* @__PURE__ */ __commonJSMin$11(((a, N) => {
|
|
742
|
+
var P = typeof Reflect == "object" ? Reflect : null, F = P && typeof P.apply == "function" ? P.apply : function(a, N, P) {
|
|
743
|
+
return Function.prototype.apply.call(a, N, P);
|
|
744
|
+
}, I = P && typeof P.ownKeys == "function" ? P.ownKeys : Object.getOwnPropertySymbols ? function(a) {
|
|
745
|
+
return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a));
|
|
746
|
+
} : function(a) {
|
|
747
|
+
return Object.getOwnPropertyNames(a);
|
|
748
|
+
};
|
|
749
|
+
function L(a) {
|
|
750
|
+
console && console.warn && console.warn(a);
|
|
751
|
+
}
|
|
752
|
+
var R = Number.isNaN || function(a) {
|
|
753
|
+
return a !== a;
|
|
754
|
+
};
|
|
755
|
+
function z() {
|
|
756
|
+
z.init.call(this);
|
|
757
|
+
}
|
|
758
|
+
N.exports = z, N.exports.once = Z, z.EventEmitter = z, z.prototype._events = void 0, z.prototype._eventsCount = 0, z.prototype._maxListeners = void 0;
|
|
759
|
+
var B = 10;
|
|
760
|
+
function V(a) {
|
|
761
|
+
if (typeof a != "function") throw TypeError("The \"listener\" argument must be of type Function. Received type " + typeof a);
|
|
762
|
+
}
|
|
763
|
+
Object.defineProperty(z, "defaultMaxListeners", {
|
|
764
|
+
enumerable: !0,
|
|
765
|
+
get: function() {
|
|
766
|
+
return B;
|
|
767
|
+
},
|
|
768
|
+
set: function(a) {
|
|
769
|
+
if (typeof a != "number" || a < 0 || R(a)) throw RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received " + a + ".");
|
|
770
|
+
B = a;
|
|
771
|
+
}
|
|
772
|
+
}), z.init = function() {
|
|
773
|
+
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
774
|
+
}, z.prototype.setMaxListeners = function(a) {
|
|
775
|
+
if (typeof a != "number" || a < 0 || R(a)) throw RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received " + a + ".");
|
|
776
|
+
return this._maxListeners = a, this;
|
|
777
|
+
};
|
|
778
|
+
function H(a) {
|
|
779
|
+
return a._maxListeners === void 0 ? z.defaultMaxListeners : a._maxListeners;
|
|
780
|
+
}
|
|
781
|
+
z.prototype.getMaxListeners = function() {
|
|
782
|
+
return H(this);
|
|
783
|
+
}, z.prototype.emit = function(a) {
|
|
784
|
+
for (var N = [], P = 1; P < arguments.length; P++) N.push(arguments[P]);
|
|
785
|
+
var I = a === "error", L = this._events;
|
|
786
|
+
if (L !== void 0) I &&= L.error === void 0;
|
|
787
|
+
else if (!I) return !1;
|
|
788
|
+
if (I) {
|
|
789
|
+
var R;
|
|
790
|
+
if (N.length > 0 && (R = N[0]), R instanceof Error) throw R;
|
|
791
|
+
var z = /* @__PURE__ */ Error("Unhandled error." + (R ? " (" + R.message + ")" : ""));
|
|
792
|
+
throw z.context = R, z;
|
|
793
|
+
}
|
|
794
|
+
var B = L[a];
|
|
795
|
+
if (B === void 0) return !1;
|
|
796
|
+
if (typeof B == "function") F(B, this, N);
|
|
797
|
+
else for (var V = B.length, H = J(B, V), P = 0; P < V; ++P) F(H[P], this, N);
|
|
798
|
+
return !0;
|
|
799
|
+
};
|
|
800
|
+
function U(a, N, P, F) {
|
|
801
|
+
var I, R, z;
|
|
802
|
+
if (V(P), R = a._events, R === void 0 ? (R = a._events = Object.create(null), a._eventsCount = 0) : (R.newListener !== void 0 && (a.emit("newListener", N, P.listener ? P.listener : P), R = a._events), z = R[N]), z === void 0) z = R[N] = P, ++a._eventsCount;
|
|
803
|
+
else if (typeof z == "function" ? z = R[N] = F ? [P, z] : [z, P] : F ? z.unshift(P) : z.push(P), I = H(a), I > 0 && z.length > I && !z.warned) {
|
|
804
|
+
z.warned = !0;
|
|
805
|
+
var B = /* @__PURE__ */ Error("Possible EventEmitter memory leak detected. " + z.length + " " + String(N) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
806
|
+
B.name = "MaxListenersExceededWarning", B.emitter = a, B.type = N, B.count = z.length, L(B);
|
|
807
|
+
}
|
|
808
|
+
return a;
|
|
809
|
+
}
|
|
810
|
+
z.prototype.addListener = function(a, N) {
|
|
811
|
+
return U(this, a, N, !1);
|
|
812
|
+
}, z.prototype.on = z.prototype.addListener, z.prototype.prependListener = function(a, N) {
|
|
813
|
+
return U(this, a, N, !0);
|
|
814
|
+
};
|
|
815
|
+
function W() {
|
|
816
|
+
if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
817
|
+
}
|
|
818
|
+
function G(a, N, P) {
|
|
819
|
+
var F = {
|
|
820
|
+
fired: !1,
|
|
821
|
+
wrapFn: void 0,
|
|
822
|
+
target: a,
|
|
823
|
+
type: N,
|
|
824
|
+
listener: P
|
|
825
|
+
}, I = W.bind(F);
|
|
826
|
+
return I.listener = P, F.wrapFn = I, I;
|
|
827
|
+
}
|
|
828
|
+
z.prototype.once = function(a, N) {
|
|
829
|
+
return V(N), this.on(a, G(this, a, N)), this;
|
|
830
|
+
}, z.prototype.prependOnceListener = function(a, N) {
|
|
831
|
+
return V(N), this.prependListener(a, G(this, a, N)), this;
|
|
832
|
+
}, z.prototype.removeListener = function(a, N) {
|
|
833
|
+
var P, F, I, L, R;
|
|
834
|
+
if (V(N), F = this._events, F === void 0 || (P = F[a], P === void 0)) return this;
|
|
835
|
+
if (P === N || P.listener === N) --this._eventsCount === 0 ? this._events = Object.create(null) : (delete F[a], F.removeListener && this.emit("removeListener", a, P.listener || N));
|
|
836
|
+
else if (typeof P != "function") {
|
|
837
|
+
for (I = -1, L = P.length - 1; L >= 0; L--) if (P[L] === N || P[L].listener === N) {
|
|
838
|
+
R = P[L].listener, I = L;
|
|
839
|
+
break;
|
|
840
|
+
}
|
|
841
|
+
if (I < 0) return this;
|
|
842
|
+
I === 0 ? P.shift() : Y(P, I), P.length === 1 && (F[a] = P[0]), F.removeListener !== void 0 && this.emit("removeListener", a, R || N);
|
|
843
|
+
}
|
|
844
|
+
return this;
|
|
845
|
+
}, z.prototype.off = z.prototype.removeListener, z.prototype.removeAllListeners = function(a) {
|
|
846
|
+
var N, P = this._events, F;
|
|
847
|
+
if (P === void 0) return this;
|
|
848
|
+
if (P.removeListener === void 0) return arguments.length === 0 ? (this._events = Object.create(null), this._eventsCount = 0) : P[a] !== void 0 && (--this._eventsCount === 0 ? this._events = Object.create(null) : delete P[a]), this;
|
|
849
|
+
if (arguments.length === 0) {
|
|
850
|
+
var I = Object.keys(P), L;
|
|
851
|
+
for (F = 0; F < I.length; ++F) L = I[F], L !== "removeListener" && this.removeAllListeners(L);
|
|
852
|
+
return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this;
|
|
853
|
+
}
|
|
854
|
+
if (N = P[a], typeof N == "function") this.removeListener(a, N);
|
|
855
|
+
else if (N !== void 0) for (F = N.length - 1; F >= 0; F--) this.removeListener(a, N[F]);
|
|
856
|
+
return this;
|
|
857
|
+
};
|
|
858
|
+
function K(a, N, P) {
|
|
859
|
+
var F = a._events;
|
|
860
|
+
if (F === void 0) return [];
|
|
861
|
+
var I = F[N];
|
|
862
|
+
return I === void 0 ? [] : typeof I == "function" ? P ? [I.listener || I] : [I] : P ? X(I) : J(I, I.length);
|
|
863
|
+
}
|
|
864
|
+
z.prototype.listeners = function(a) {
|
|
865
|
+
return K(this, a, !0);
|
|
866
|
+
}, z.prototype.rawListeners = function(a) {
|
|
867
|
+
return K(this, a, !1);
|
|
868
|
+
}, z.listenerCount = function(a, N) {
|
|
869
|
+
return typeof a.listenerCount == "function" ? a.listenerCount(N) : q.call(a, N);
|
|
870
|
+
}, z.prototype.listenerCount = q;
|
|
871
|
+
function q(a) {
|
|
872
|
+
var N = this._events;
|
|
873
|
+
if (N !== void 0) {
|
|
874
|
+
var P = N[a];
|
|
875
|
+
if (typeof P == "function") return 1;
|
|
876
|
+
if (P !== void 0) return P.length;
|
|
877
|
+
}
|
|
878
|
+
return 0;
|
|
879
|
+
}
|
|
880
|
+
z.prototype.eventNames = function() {
|
|
881
|
+
return this._eventsCount > 0 ? I(this._events) : [];
|
|
882
|
+
};
|
|
883
|
+
function J(a, N) {
|
|
884
|
+
for (var P = Array(N), F = 0; F < N; ++F) P[F] = a[F];
|
|
885
|
+
return P;
|
|
886
|
+
}
|
|
887
|
+
function Y(a, N) {
|
|
888
|
+
for (; N + 1 < a.length; N++) a[N] = a[N + 1];
|
|
889
|
+
a.pop();
|
|
890
|
+
}
|
|
891
|
+
function X(a) {
|
|
892
|
+
for (var N = Array(a.length), P = 0; P < N.length; ++P) N[P] = a[P].listener || a[P];
|
|
893
|
+
return N;
|
|
894
|
+
}
|
|
895
|
+
function Z(a, N) {
|
|
896
|
+
return new Promise(function(P, F) {
|
|
897
|
+
function I(P) {
|
|
898
|
+
a.removeListener(N, L), F(P);
|
|
899
|
+
}
|
|
900
|
+
function L() {
|
|
901
|
+
typeof a.removeListener == "function" && a.removeListener("error", I), P([].slice.call(arguments));
|
|
902
|
+
}
|
|
903
|
+
$(a, N, L, { once: !0 }), N !== "error" && Q(a, I, { once: !0 });
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
function Q(a, N, P) {
|
|
907
|
+
typeof a.on == "function" && $(a, "error", N, P);
|
|
908
|
+
}
|
|
909
|
+
function $(a, N, P, F) {
|
|
910
|
+
if (typeof a.on == "function") F.once ? a.once(N, P) : a.on(N, P);
|
|
911
|
+
else if (typeof a.addEventListener == "function") a.addEventListener(N, function I(L) {
|
|
912
|
+
F.once && a.removeEventListener(N, I), P(L);
|
|
913
|
+
});
|
|
914
|
+
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof a);
|
|
915
|
+
}
|
|
916
|
+
})))(), 1), __defProp$29 = Object.defineProperty, __defNormalProp$18 = (a, N, P) => N in a ? __defProp$29(a, N, {
|
|
917
|
+
enumerable: !0,
|
|
918
|
+
configurable: !0,
|
|
919
|
+
writable: !0,
|
|
920
|
+
value: P
|
|
921
|
+
}) : a[N] = P, __publicField$18 = (a, N, P) => (__defNormalProp$18(a, typeof N == "symbol" ? N : N + "", P), P), LEVELS_ORDER$11 = [
|
|
922
|
+
"error",
|
|
923
|
+
"ok",
|
|
924
|
+
"warn",
|
|
925
|
+
"flux",
|
|
926
|
+
"deprecated",
|
|
927
|
+
"info",
|
|
928
|
+
"log",
|
|
929
|
+
"debug"
|
|
930
|
+
];
|
|
931
|
+
function isWindowWithWemap$11(a) {
|
|
932
|
+
return "wemap" in a;
|
|
933
|
+
}
|
|
934
|
+
var _Logger$11 = class a {
|
|
935
|
+
static enable(N) {
|
|
936
|
+
a.ENABLED = !!N;
|
|
937
|
+
}
|
|
938
|
+
static level(N) {
|
|
939
|
+
return arguments.length && (a.LOG_LEVEL = N), a.LOG_LEVEL;
|
|
940
|
+
}
|
|
941
|
+
static clearHistory() {
|
|
942
|
+
a.HISTORY = [];
|
|
943
|
+
}
|
|
944
|
+
static _canUseLog(N) {
|
|
945
|
+
let P = LEVELS_ORDER$11.indexOf(N), F = LEVELS_ORDER$11.indexOf(a.LOG_LEVEL);
|
|
946
|
+
return F === -1 ? !1 : P <= F;
|
|
947
|
+
}
|
|
948
|
+
static _getColorByType(a) {
|
|
949
|
+
let N = null;
|
|
950
|
+
switch (a) {
|
|
951
|
+
case "flux":
|
|
952
|
+
N = "background-color: #0083E0; color: #FFFFFF;";
|
|
953
|
+
break;
|
|
954
|
+
case "ok":
|
|
955
|
+
N = "background-color: #00FF22; color: #272727;";
|
|
956
|
+
break;
|
|
957
|
+
case "deprecated":
|
|
958
|
+
N = "background-color: #CA0AFA; color: #FFFFFF;";
|
|
959
|
+
break;
|
|
960
|
+
case "error":
|
|
961
|
+
N = "background-color: #CC0000; color: #FFFFFF;";
|
|
962
|
+
break;
|
|
963
|
+
case "warn":
|
|
964
|
+
N = "background-color: #DD7908; color: #FFFFFF;";
|
|
965
|
+
break;
|
|
966
|
+
case "debug":
|
|
967
|
+
N = "background-color: #999999; color: #FFFFFF;";
|
|
968
|
+
break;
|
|
969
|
+
case "info":
|
|
970
|
+
N = "background-color: #DCFF4E; color: #000000;";
|
|
971
|
+
break;
|
|
972
|
+
default:
|
|
973
|
+
N = "background-color: #F4F4F4; color: #999999;";
|
|
974
|
+
break;
|
|
975
|
+
}
|
|
976
|
+
return N;
|
|
977
|
+
}
|
|
978
|
+
static _getOriginByType(a, N) {
|
|
979
|
+
let P = null, F = null, I = N;
|
|
980
|
+
if (arguments.length < 2) return "";
|
|
981
|
+
try {
|
|
982
|
+
for (P = "", F = a.stack && a.stack.length ? a.stack.split("\n").splice(3) : [], (I < 0 || I >= F.length) && (I = F.length); I;) P += "\r\n " + F[0].trim(), F = F.splice(1), I--;
|
|
983
|
+
return P;
|
|
984
|
+
} catch {
|
|
985
|
+
return "";
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
static _log(N, P, F) {
|
|
989
|
+
let I = "color: auto;", L = "color: #6A6A6A;", R = typeof window < "u", z, B = null, V = null, H = null, U = null, W = "", G = !1;
|
|
990
|
+
if (B = N, U = Error(P), R && (V = a._getColorByType(N)), H = a._getOriginByType(U, F), B === "deprecated" && (B = "warn", G = "deprecated"), R && (H = a._COLOR_TOKEN + H), z = (R ? a._COLOR_TOKEN : "") + " " + U.message, W = R ? a._COLOR_TOKEN : "", W += a._TYPE_PREFIX, W += G || N, W += a._TYPE_SUFFIX, typeof window < "u" && isWindowWithWemap$11(window)) {
|
|
991
|
+
let a = performance && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime();
|
|
992
|
+
W += "[" + Math.round(a - window.wemap.startTime) + "ms]";
|
|
993
|
+
}
|
|
994
|
+
return z = W + z, a.SHOW_ORIGIN && (z += H), a.HISTORY.push(z), !this._canUseLog(N) || arguments.length < 2 || !a.ENABLED ? !1 : (R ? console && N !== "ok" && N !== "flux" && N !== "deprecated" && console[N] && LEVELS_ORDER$11.indexOf(N) <= LEVELS_ORDER$11.indexOf("info") ? console[N](z, V, I, L) : console.log(z, V, I, L) : console.log(z), !0);
|
|
995
|
+
}
|
|
996
|
+
static external(a) {
|
|
997
|
+
return console.log("LIVEMAP :: " + a);
|
|
998
|
+
}
|
|
999
|
+
static flux(N) {
|
|
1000
|
+
return a._log("flux", N, 0);
|
|
1001
|
+
}
|
|
1002
|
+
static ok(N) {
|
|
1003
|
+
return a._log("ok", N, 1);
|
|
1004
|
+
}
|
|
1005
|
+
static error(N, P = -1) {
|
|
1006
|
+
return a._log("error", N, P);
|
|
1007
|
+
}
|
|
1008
|
+
static warn(N, P = 2) {
|
|
1009
|
+
return a._log("warn", N, P);
|
|
1010
|
+
}
|
|
1011
|
+
static deprecated(N, P = 2) {
|
|
1012
|
+
return a._log("deprecated", N, P);
|
|
1013
|
+
}
|
|
1014
|
+
static debug(N, P = -1) {
|
|
1015
|
+
return a._log("debug", N, P);
|
|
1016
|
+
}
|
|
1017
|
+
static info(N, P = 0) {
|
|
1018
|
+
return a._log("info", N, P);
|
|
1019
|
+
}
|
|
1020
|
+
static log(N, P = 1) {
|
|
1021
|
+
return a._log("log", N, P);
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
__publicField$18(_Logger$11, "LOG_LEVEL", "debug"), __publicField$18(_Logger$11, "SHOW_ORIGIN", !0), __publicField$18(_Logger$11, "ENABLED", !0), __publicField$18(_Logger$11, "HISTORY", []), __publicField$18(_Logger$11, "_COLOR_TOKEN", "%c"), __publicField$18(_Logger$11, "_TYPE_PREFIX", "<<<< "), __publicField$18(_Logger$11, "_TYPE_SUFFIX", " >>>>");
|
|
1025
|
+
var Logger$6 = _Logger$11, e$11 = class a {
|
|
1026
|
+
constructor(N, P, F, I, L) {
|
|
1027
|
+
this._legacyCanvasSize = a.DEFAULT_CANVAS_SIZE, this._preferredCamera = "environment", this._maxScansPerSecond = 25, this._lastScanTimestamp = -1, this._destroyed = this._flashOn = this._paused = this._active = !1, this.$video = N, this.$canvas = document.createElement("canvas"), F && typeof F == "object" ? this._onDecode = P : (F || I || L ? console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future") : console.warn("Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."), this._legacyOnDecode = P), P = typeof F == "object" ? F : {}, this._onDecodeError = P.onDecodeError || (typeof F == "function" ? F : this._onDecodeError), this._calculateScanRegion = P.calculateScanRegion || (typeof I == "function" ? I : this._calculateScanRegion), this._preferredCamera = P.preferredCamera || L || this._preferredCamera, this._legacyCanvasSize = typeof F == "number" ? F : typeof I == "number" ? I : this._legacyCanvasSize, this._maxScansPerSecond = P.maxScansPerSecond || this._maxScansPerSecond, this._onPlay = this._onPlay.bind(this), this._onLoadedMetaData = this._onLoadedMetaData.bind(this), this._onVisibilityChange = this._onVisibilityChange.bind(this), this._updateOverlay = this._updateOverlay.bind(this), N.disablePictureInPicture = !0, N.playsInline = !0, N.muted = !0;
|
|
1028
|
+
let R = !1;
|
|
1029
|
+
if (N.hidden && (N.hidden = !1, R = !0), document.body.contains(N) || (document.body.appendChild(N), R = !0), F = N.parentElement, P.highlightScanRegion || P.highlightCodeOutline) {
|
|
1030
|
+
if (I = !!P.overlay, this.$overlay = P.overlay || document.createElement("div"), L = this.$overlay.style, L.position = "absolute", L.display = "none", L.pointerEvents = "none", this.$overlay.classList.add("scan-region-highlight"), !I && P.highlightScanRegion) {
|
|
1031
|
+
this.$overlay.innerHTML = "<svg class=\"scan-region-highlight-svg\" viewBox=\"0 0 238 238\" preserveAspectRatio=\"none\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round\"><path d=\"M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21\"/></svg>";
|
|
1032
|
+
try {
|
|
1033
|
+
this.$overlay.firstElementChild.animate({ transform: ["scale(.98)", "scale(1.01)"] }, {
|
|
1034
|
+
duration: 400,
|
|
1035
|
+
iterations: Infinity,
|
|
1036
|
+
direction: "alternate",
|
|
1037
|
+
easing: "ease-in-out"
|
|
1038
|
+
});
|
|
1039
|
+
} catch {}
|
|
1040
|
+
F.insertBefore(this.$overlay, this.$video.nextSibling);
|
|
1041
|
+
}
|
|
1042
|
+
P.highlightCodeOutline && (this.$overlay.insertAdjacentHTML("beforeend", "<svg class=\"code-outline-highlight\" preserveAspectRatio=\"none\" style=\"display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round\"><polygon/></svg>"), this.$codeOutlineHighlight = this.$overlay.lastElementChild);
|
|
1043
|
+
}
|
|
1044
|
+
this._scanRegion = this._calculateScanRegion(N), requestAnimationFrame(() => {
|
|
1045
|
+
let a = window.getComputedStyle(N);
|
|
1046
|
+
a.display === "none" && (N.style.setProperty("display", "block", "important"), R = !0), a.visibility !== "visible" && (N.style.setProperty("visibility", "visible", "important"), R = !0), R && (console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."), N.style.opacity = "0", N.style.width = "0", N.style.height = "0", this.$overlay && this.$overlay.parentElement && this.$overlay.parentElement.removeChild(this.$overlay), delete this.$overlay, delete this.$codeOutlineHighlight), this.$overlay && this._updateOverlay();
|
|
1047
|
+
}), N.addEventListener("play", this._onPlay), N.addEventListener("loadedmetadata", this._onLoadedMetaData), document.addEventListener("visibilitychange", this._onVisibilityChange), window.addEventListener("resize", this._updateOverlay), this._qrEnginePromise = a.createQrEngine();
|
|
1048
|
+
}
|
|
1049
|
+
static set WORKER_PATH(a) {
|
|
1050
|
+
console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.");
|
|
1051
|
+
}
|
|
1052
|
+
static async hasCamera() {
|
|
1053
|
+
try {
|
|
1054
|
+
return !!(await a.listCameras(!1)).length;
|
|
1055
|
+
} catch {
|
|
1056
|
+
return !1;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
static async listCameras(N = !1) {
|
|
1060
|
+
if (!navigator.mediaDevices) return [];
|
|
1061
|
+
let P = async () => (await navigator.mediaDevices.enumerateDevices()).filter((a) => a.kind === "videoinput"), F;
|
|
1062
|
+
try {
|
|
1063
|
+
N && (await P()).every((a) => !a.label) && (F = await navigator.mediaDevices.getUserMedia({
|
|
1064
|
+
audio: !1,
|
|
1065
|
+
video: !0
|
|
1066
|
+
}));
|
|
1067
|
+
} catch {}
|
|
1068
|
+
try {
|
|
1069
|
+
return (await P()).map((a, N) => ({
|
|
1070
|
+
id: a.deviceId,
|
|
1071
|
+
label: a.label || (N === 0 ? "Default Camera" : `Camera ${N + 1}`)
|
|
1072
|
+
}));
|
|
1073
|
+
} finally {
|
|
1074
|
+
F && (console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"), a._stopVideoStream(F));
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
async hasFlash() {
|
|
1078
|
+
let N;
|
|
1079
|
+
try {
|
|
1080
|
+
if (this.$video.srcObject) {
|
|
1081
|
+
if (!(this.$video.srcObject instanceof MediaStream)) return !1;
|
|
1082
|
+
N = this.$video.srcObject;
|
|
1083
|
+
} else N = (await this._getCameraStream()).stream;
|
|
1084
|
+
return "torch" in N.getVideoTracks()[0].getSettings();
|
|
1085
|
+
} catch {
|
|
1086
|
+
return !1;
|
|
1087
|
+
} finally {
|
|
1088
|
+
N && N !== this.$video.srcObject && (console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"), a._stopVideoStream(N));
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
isFlashOn() {
|
|
1092
|
+
return this._flashOn;
|
|
1093
|
+
}
|
|
1094
|
+
async toggleFlash() {
|
|
1095
|
+
this._flashOn ? await this.turnFlashOff() : await this.turnFlashOn();
|
|
1096
|
+
}
|
|
1097
|
+
async turnFlashOn() {
|
|
1098
|
+
if (!this._flashOn && !this._destroyed && (this._flashOn = !0, this._active && !this._paused)) try {
|
|
1099
|
+
if (!await this.hasFlash()) throw "No flash available";
|
|
1100
|
+
await this.$video.srcObject.getVideoTracks()[0].applyConstraints({ advanced: [{ torch: !0 }] });
|
|
1101
|
+
} catch (a) {
|
|
1102
|
+
throw this._flashOn = !1, a;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
async turnFlashOff() {
|
|
1106
|
+
this._flashOn && (this._flashOn = !1, await this._restartVideoStream());
|
|
1107
|
+
}
|
|
1108
|
+
destroy() {
|
|
1109
|
+
this.$video.removeEventListener("loadedmetadata", this._onLoadedMetaData), this.$video.removeEventListener("play", this._onPlay), document.removeEventListener("visibilitychange", this._onVisibilityChange), window.removeEventListener("resize", this._updateOverlay), this._destroyed = !0, this._flashOn = !1, this.stop(), a._postWorkerMessage(this._qrEnginePromise, "close");
|
|
1110
|
+
}
|
|
1111
|
+
async start() {
|
|
1112
|
+
if (this._destroyed) throw Error("The QR scanner can not be started as it had been destroyed.");
|
|
1113
|
+
if ((!this._active || this._paused) && (window.location.protocol !== "https:" && console.warn("The camera stream is only accessible if the page is transferred via https."), this._active = !0, !document.hidden)) if (this._paused = !1, this.$video.srcObject) await this.$video.play();
|
|
1114
|
+
else try {
|
|
1115
|
+
let { stream: N, facingMode: P } = await this._getCameraStream();
|
|
1116
|
+
!this._active || this._paused ? a._stopVideoStream(N) : (this._setVideoMirror(P), this.$video.srcObject = N, await this.$video.play(), this._flashOn && (this._flashOn = !1, this.turnFlashOn().catch(() => {})));
|
|
1117
|
+
} catch (a) {
|
|
1118
|
+
if (!this._paused) throw this._active = !1, a;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
stop() {
|
|
1122
|
+
this.pause(), this._active = !1;
|
|
1123
|
+
}
|
|
1124
|
+
async pause(N = !1) {
|
|
1125
|
+
if (this._paused = !0, !this._active) return !0;
|
|
1126
|
+
this.$video.pause(), this.$overlay && (this.$overlay.style.display = "none");
|
|
1127
|
+
let P = () => {
|
|
1128
|
+
this.$video.srcObject instanceof MediaStream && (a._stopVideoStream(this.$video.srcObject), this.$video.srcObject = null);
|
|
1129
|
+
};
|
|
1130
|
+
return N ? (P(), !0) : (await new Promise((a) => setTimeout(a, 300)), this._paused ? (P(), !0) : !1);
|
|
1131
|
+
}
|
|
1132
|
+
async setCamera(a) {
|
|
1133
|
+
a !== this._preferredCamera && (this._preferredCamera = a, await this._restartVideoStream());
|
|
1134
|
+
}
|
|
1135
|
+
static async scanImage(N, P, F, I, L = !1, R = !1) {
|
|
1136
|
+
let z, B = !1;
|
|
1137
|
+
P && ("scanRegion" in P || "qrEngine" in P || "canvas" in P || "disallowCanvasResizing" in P || "alsoTryWithoutScanRegion" in P || "returnDetailedScanResult" in P) ? (z = P.scanRegion, F = P.qrEngine, I = P.canvas, L = P.disallowCanvasResizing || !1, R = P.alsoTryWithoutScanRegion || !1, B = !0) : P || F || I || L || R ? console.warn("You're using a deprecated api for scanImage which will be removed in the future.") : console.warn("Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."), P = !!F;
|
|
1138
|
+
try {
|
|
1139
|
+
let V, H;
|
|
1140
|
+
[F, V] = await Promise.all([F || a.createQrEngine(), a._loadImage(N)]), [I, H] = a._drawToCanvas(V, z, I, L);
|
|
1141
|
+
let U;
|
|
1142
|
+
if (F instanceof Worker) {
|
|
1143
|
+
let N = F;
|
|
1144
|
+
P || a._postWorkerMessageSync(N, "inversionMode", "both"), U = await new Promise((P, F) => {
|
|
1145
|
+
let L, R, B, V = -1;
|
|
1146
|
+
R = (I) => {
|
|
1147
|
+
I.data.id === V && (N.removeEventListener("message", R), N.removeEventListener("error", B), clearTimeout(L), I.data.data === null ? F(a.NO_QR_CODE_FOUND) : P({
|
|
1148
|
+
data: I.data.data,
|
|
1149
|
+
cornerPoints: a._convertPoints(I.data.cornerPoints, z)
|
|
1150
|
+
}));
|
|
1151
|
+
}, B = (a) => {
|
|
1152
|
+
N.removeEventListener("message", R), N.removeEventListener("error", B), clearTimeout(L), F("Scanner error: " + (a ? a.message || a : "Unknown Error"));
|
|
1153
|
+
}, N.addEventListener("message", R), N.addEventListener("error", B), L = setTimeout(() => B("timeout"), 1e4);
|
|
1154
|
+
let U = H.getImageData(0, 0, I.width, I.height);
|
|
1155
|
+
V = a._postWorkerMessageSync(N, "decode", U, [U.data.buffer]);
|
|
1156
|
+
});
|
|
1157
|
+
} else U = await Promise.race([new Promise((a, N) => window.setTimeout(() => N("Scanner error: timeout"), 1e4)), (async () => {
|
|
1158
|
+
try {
|
|
1159
|
+
var [P] = await F.detect(I);
|
|
1160
|
+
if (!P) throw a.NO_QR_CODE_FOUND;
|
|
1161
|
+
return {
|
|
1162
|
+
data: P.rawValue,
|
|
1163
|
+
cornerPoints: a._convertPoints(P.cornerPoints, z)
|
|
1164
|
+
};
|
|
1165
|
+
} catch (F) {
|
|
1166
|
+
if (P = F.message || F, /not implemented|service unavailable/.test(P)) return a._disableBarcodeDetector = !0, a.scanImage(N, {
|
|
1167
|
+
scanRegion: z,
|
|
1168
|
+
canvas: I,
|
|
1169
|
+
disallowCanvasResizing: L,
|
|
1170
|
+
alsoTryWithoutScanRegion: R
|
|
1171
|
+
});
|
|
1172
|
+
throw `Scanner error: ${P}`;
|
|
1173
|
+
}
|
|
1174
|
+
})()]);
|
|
1175
|
+
return B ? U : U.data;
|
|
1176
|
+
} catch (P) {
|
|
1177
|
+
if (!z || !R) throw P;
|
|
1178
|
+
let V = await a.scanImage(N, {
|
|
1179
|
+
qrEngine: F,
|
|
1180
|
+
canvas: I,
|
|
1181
|
+
disallowCanvasResizing: L
|
|
1182
|
+
});
|
|
1183
|
+
return B ? V : V.data;
|
|
1184
|
+
} finally {
|
|
1185
|
+
P || a._postWorkerMessage(F, "close");
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
setGrayscaleWeights(N, P, F, I = !0) {
|
|
1189
|
+
a._postWorkerMessage(this._qrEnginePromise, "grayscaleWeights", {
|
|
1190
|
+
red: N,
|
|
1191
|
+
green: P,
|
|
1192
|
+
blue: F,
|
|
1193
|
+
useIntegerApproximation: I
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
setInversionMode(N) {
|
|
1197
|
+
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
1198
|
+
}
|
|
1199
|
+
static async createQrEngine(N) {
|
|
1200
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-DbljhPN5.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
1201
|
+
let P = navigator.userAgentData;
|
|
1202
|
+
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
1203
|
+
}
|
|
1204
|
+
_onPlay() {
|
|
1205
|
+
this._scanRegion = this._calculateScanRegion(this.$video), this._updateOverlay(), this.$overlay && (this.$overlay.style.display = ""), this._scanFrame();
|
|
1206
|
+
}
|
|
1207
|
+
_onLoadedMetaData() {
|
|
1208
|
+
this._scanRegion = this._calculateScanRegion(this.$video), this._updateOverlay();
|
|
1209
|
+
}
|
|
1210
|
+
_onVisibilityChange() {
|
|
1211
|
+
document.hidden ? this.pause() : this._active && this.start();
|
|
1212
|
+
}
|
|
1213
|
+
_calculateScanRegion(a) {
|
|
1214
|
+
let N = Math.round(2 / 3 * Math.min(a.videoWidth, a.videoHeight));
|
|
1215
|
+
return {
|
|
1216
|
+
x: Math.round((a.videoWidth - N) / 2),
|
|
1217
|
+
y: Math.round((a.videoHeight - N) / 2),
|
|
1218
|
+
width: N,
|
|
1219
|
+
height: N,
|
|
1220
|
+
downScaledWidth: this._legacyCanvasSize,
|
|
1221
|
+
downScaledHeight: this._legacyCanvasSize
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
_updateOverlay() {
|
|
1225
|
+
requestAnimationFrame(() => {
|
|
1226
|
+
if (this.$overlay) {
|
|
1227
|
+
var a = this.$video, N = a.videoWidth, P = a.videoHeight, F = a.offsetWidth, I = a.offsetHeight, L = a.offsetLeft, R = a.offsetTop, z = window.getComputedStyle(a), B = z.objectFit, V = N / P, H = F / I;
|
|
1228
|
+
switch (B) {
|
|
1229
|
+
case "none":
|
|
1230
|
+
var U = N, W = P;
|
|
1231
|
+
break;
|
|
1232
|
+
case "fill":
|
|
1233
|
+
U = F, W = I;
|
|
1234
|
+
break;
|
|
1235
|
+
default: (B === "cover" ? V > H : V < H) ? (W = I, U = W * V) : (U = F, W = U / V), B === "scale-down" && (U = Math.min(U, N), W = Math.min(W, P));
|
|
1236
|
+
}
|
|
1237
|
+
var [G, K] = z.objectPosition.split(" ").map((a, N) => {
|
|
1238
|
+
let P = parseFloat(a);
|
|
1239
|
+
return a.endsWith("%") ? (N ? I - W : F - U) * P / 100 : P;
|
|
1240
|
+
});
|
|
1241
|
+
z = this._scanRegion.width || N, H = this._scanRegion.height || P, B = this._scanRegion.x || 0;
|
|
1242
|
+
var q = this._scanRegion.y || 0;
|
|
1243
|
+
V = this.$overlay.style, V.width = `${z / N * U}px`, V.height = `${H / P * W}px`, V.top = `${R + K + q / P * W}px`, P = /scaleX\(-1\)/.test(a.style.transform), V.left = `${L + (P ? F - G - U : G) + (P ? N - B - z : B) / N * U}px`, V.transform = a.style.transform;
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
static _convertPoints(a, N) {
|
|
1248
|
+
if (!N) return a;
|
|
1249
|
+
let P = N.x || 0, F = N.y || 0, I = N.width && N.downScaledWidth ? N.width / N.downScaledWidth : 1;
|
|
1250
|
+
N = N.height && N.downScaledHeight ? N.height / N.downScaledHeight : 1;
|
|
1251
|
+
for (let L of a) L.x = L.x * I + P, L.y = L.y * N + F;
|
|
1252
|
+
return a;
|
|
1253
|
+
}
|
|
1254
|
+
_scanFrame() {
|
|
1255
|
+
!this._active || this.$video.paused || this.$video.ended || ("requestVideoFrameCallback" in this.$video ? this.$video.requestVideoFrameCallback.bind(this.$video) : requestAnimationFrame)(async () => {
|
|
1256
|
+
if (!(1 >= this.$video.readyState)) {
|
|
1257
|
+
var N = Date.now() - this._lastScanTimestamp, P = 1e3 / this._maxScansPerSecond;
|
|
1258
|
+
N < P && await new Promise((a) => setTimeout(a, P - N)), this._lastScanTimestamp = Date.now();
|
|
1259
|
+
try {
|
|
1260
|
+
var F = await a.scanImage(this.$video, {
|
|
1261
|
+
scanRegion: this._scanRegion,
|
|
1262
|
+
qrEngine: this._qrEnginePromise,
|
|
1263
|
+
canvas: this.$canvas
|
|
1264
|
+
});
|
|
1265
|
+
} catch (a) {
|
|
1266
|
+
if (!this._active) return;
|
|
1267
|
+
this._onDecodeError(a);
|
|
1268
|
+
}
|
|
1269
|
+
!a._disableBarcodeDetector || await this._qrEnginePromise instanceof Worker || (this._qrEnginePromise = a.createQrEngine()), F ? (this._onDecode ? this._onDecode(F) : this._legacyOnDecode && this._legacyOnDecode(F.data), this.$codeOutlineHighlight && (clearTimeout(this._codeOutlineHighlightRemovalTimeout), this._codeOutlineHighlightRemovalTimeout = void 0, this.$codeOutlineHighlight.setAttribute("viewBox", `${this._scanRegion.x || 0} ${this._scanRegion.y || 0} ${this._scanRegion.width || this.$video.videoWidth} ${this._scanRegion.height || this.$video.videoHeight}`), this.$codeOutlineHighlight.firstElementChild.setAttribute("points", F.cornerPoints.map(({ x: a, y: N }) => `${a},${N}`).join(" ")), this.$codeOutlineHighlight.style.display = "")) : this.$codeOutlineHighlight && !this._codeOutlineHighlightRemovalTimeout && (this._codeOutlineHighlightRemovalTimeout = setTimeout(() => this.$codeOutlineHighlight.style.display = "none", 100));
|
|
1270
|
+
}
|
|
1271
|
+
this._scanFrame();
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
_onDecodeError(N) {
|
|
1275
|
+
N !== a.NO_QR_CODE_FOUND && console.log(N);
|
|
1276
|
+
}
|
|
1277
|
+
async _getCameraStream() {
|
|
1278
|
+
if (!navigator.mediaDevices) throw "Camera not found.";
|
|
1279
|
+
let a = /^(environment|user)$/.test(this._preferredCamera) ? "facingMode" : "deviceId", N = [
|
|
1280
|
+
{ width: { min: 1024 } },
|
|
1281
|
+
{ width: { min: 768 } },
|
|
1282
|
+
{}
|
|
1283
|
+
], P = N.map((N) => Object.assign({}, N, { [a]: { exact: this._preferredCamera } }));
|
|
1284
|
+
for (let a of [...P, ...N]) try {
|
|
1285
|
+
let N = await navigator.mediaDevices.getUserMedia({
|
|
1286
|
+
video: a,
|
|
1287
|
+
audio: !1
|
|
1288
|
+
});
|
|
1289
|
+
return {
|
|
1290
|
+
stream: N,
|
|
1291
|
+
facingMode: this._getFacingMode(N) || (a.facingMode ? this._preferredCamera : this._preferredCamera === "environment" ? "user" : "environment")
|
|
1292
|
+
};
|
|
1293
|
+
} catch {}
|
|
1294
|
+
throw "Camera not found.";
|
|
1295
|
+
}
|
|
1296
|
+
async _restartVideoStream() {
|
|
1297
|
+
let a = this._paused;
|
|
1298
|
+
await this.pause(!0) && !a && this._active && await this.start();
|
|
1299
|
+
}
|
|
1300
|
+
static _stopVideoStream(a) {
|
|
1301
|
+
for (let N of a.getTracks()) N.stop(), a.removeTrack(N);
|
|
1302
|
+
}
|
|
1303
|
+
_setVideoMirror(a) {
|
|
1304
|
+
this.$video.style.transform = "scaleX(" + (a === "user" ? -1 : 1) + ")";
|
|
1305
|
+
}
|
|
1306
|
+
_getFacingMode(a) {
|
|
1307
|
+
return (a = a.getVideoTracks()[0]) ? /rear|back|environment/i.test(a.label) ? "environment" : /front|user|face/i.test(a.label) ? "user" : null : null;
|
|
1308
|
+
}
|
|
1309
|
+
static _drawToCanvas(a, N, P, F = !1) {
|
|
1310
|
+
P ||= document.createElement("canvas");
|
|
1311
|
+
let I = N && N.x ? N.x : 0, L = N && N.y ? N.y : 0, R = N && N.width ? N.width : a.videoWidth || a.width, z = N && N.height ? N.height : a.videoHeight || a.height;
|
|
1312
|
+
return F || (F = N && N.downScaledWidth ? N.downScaledWidth : R, N = N && N.downScaledHeight ? N.downScaledHeight : z, P.width !== F && (P.width = F), P.height !== N && (P.height = N)), N = P.getContext("2d", { alpha: !1 }), N.imageSmoothingEnabled = !1, N.drawImage(a, I, L, R, z, 0, 0, P.width, P.height), [P, N];
|
|
1313
|
+
}
|
|
1314
|
+
static async _loadImage(N) {
|
|
1315
|
+
if (N instanceof Image) return await a._awaitImageLoad(N), N;
|
|
1316
|
+
if (N instanceof HTMLVideoElement || N instanceof HTMLCanvasElement || N instanceof SVGImageElement || "OffscreenCanvas" in window && N instanceof OffscreenCanvas || "ImageBitmap" in window && N instanceof ImageBitmap) return N;
|
|
1317
|
+
if (N instanceof File || N instanceof Blob || N instanceof URL || typeof N == "string") {
|
|
1318
|
+
let P = new Image();
|
|
1319
|
+
P.src = N instanceof File || N instanceof Blob ? URL.createObjectURL(N) : N.toString();
|
|
1320
|
+
try {
|
|
1321
|
+
return await a._awaitImageLoad(P), P;
|
|
1322
|
+
} finally {
|
|
1323
|
+
(N instanceof File || N instanceof Blob) && URL.revokeObjectURL(P.src);
|
|
1324
|
+
}
|
|
1325
|
+
} else throw "Unsupported image type.";
|
|
1326
|
+
}
|
|
1327
|
+
static async _awaitImageLoad(a) {
|
|
1328
|
+
a.complete && a.naturalWidth !== 0 || await new Promise((N, P) => {
|
|
1329
|
+
let F = (I) => {
|
|
1330
|
+
a.removeEventListener("load", F), a.removeEventListener("error", F), I instanceof ErrorEvent ? P("Image load error") : N();
|
|
1331
|
+
};
|
|
1332
|
+
a.addEventListener("load", F), a.addEventListener("error", F);
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
static async _postWorkerMessage(N, P, F, I) {
|
|
1336
|
+
return a._postWorkerMessageSync(await N, P, F, I);
|
|
1337
|
+
}
|
|
1338
|
+
static _postWorkerMessageSync(N, P, F, I) {
|
|
1339
|
+
if (!(N instanceof Worker)) return -1;
|
|
1340
|
+
let L = a._workerMessageId++;
|
|
1341
|
+
return N.postMessage({
|
|
1342
|
+
id: L,
|
|
1343
|
+
type: P,
|
|
1344
|
+
data: F
|
|
1345
|
+
}, I), L;
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
e$11.DEFAULT_CANVAS_SIZE = 400, e$11.NO_QR_CODE_FOUND = "No QR code found", e$11._disableBarcodeDetector = !1, e$11._workerMessageId = 0;
|
|
1349
|
+
var __defProp$28 = Object.defineProperty, __defNormalProp$17 = (a, N, P) => N in a ? __defProp$28(a, N, {
|
|
1350
|
+
enumerable: !0,
|
|
1351
|
+
configurable: !0,
|
|
1352
|
+
writable: !0,
|
|
1353
|
+
value: P
|
|
1354
|
+
}) : a[N] = P, __publicField$17 = (a, N, P) => (__defNormalProp$17(a, typeof N == "symbol" ? N : N + "", P), P), SharedCameras$1$6 = new class extends import_events$11.default {
|
|
1355
|
+
constructor() {
|
|
1356
|
+
super(...arguments), __publicField$17(this, "_list", []);
|
|
1357
|
+
}
|
|
1358
|
+
_add(a, N) {
|
|
1359
|
+
let P = {
|
|
1360
|
+
camera: a,
|
|
1361
|
+
container: N
|
|
1362
|
+
};
|
|
1363
|
+
this._list.push(P), this.emit("added", P);
|
|
1364
|
+
}
|
|
1365
|
+
_remove(a) {
|
|
1366
|
+
this._list = this._list.filter(({ camera: N }) => N !== a), this.emit("removed", { camera: a });
|
|
1367
|
+
}
|
|
1368
|
+
get list() {
|
|
1369
|
+
return this._list;
|
|
1370
|
+
}
|
|
1371
|
+
getCameraByContainer(a) {
|
|
1372
|
+
return this._list.find((N) => N.container === a)?.camera || null;
|
|
1373
|
+
}
|
|
1374
|
+
}();
|
|
1375
|
+
function convertFov$5(a, N) {
|
|
1376
|
+
return 2 * Math.atan(Math.tan(a / 180 * Math.PI / 2) * N) * 180 / Math.PI;
|
|
1377
|
+
}
|
|
1378
|
+
function calcDisplayedFov$5(a, N, P) {
|
|
1379
|
+
let F = N.videoWidth, I = N.videoHeight;
|
|
1380
|
+
if (!F || !I) return null;
|
|
1381
|
+
let L = a.offsetWidth, R = a.offsetHeight, z = F / I, B = L / R, V = P, H = convertFov$5(V, z);
|
|
1382
|
+
return B < z ? H = convertFov$5(V, B) : V = convertFov$5(H, 1 / B), {
|
|
1383
|
+
vertical: V,
|
|
1384
|
+
horizontal: H
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
var _Camera$6 = class a extends import_events$11.default {
|
|
1388
|
+
constructor(N, P = {}) {
|
|
1389
|
+
super(), __publicField$17(this, "_userMediaConstraints"), __publicField$17(this, "videoStream", null), __publicField$17(this, "videoContainer"), __publicField$17(this, "videoElement"), __publicField$17(this, "fov", null), __publicField$17(this, "_state", "stopped"), __publicField$17(this, "_hardwareVerticalFov", a.GENERIC_HARDWARE_VERTICAL_FOV), __publicField$17(this, "_resizeOnWindowChange"), __publicField$17(this, "notifyContainerSizeChanged", () => {
|
|
1390
|
+
this._resizeElement(), this._computeFov();
|
|
1391
|
+
}), __publicField$17(this, "_resizeElement", () => {
|
|
1392
|
+
if (!this.videoElement) throw Error("No video element found");
|
|
1393
|
+
let a = this.videoElement.videoWidth, N = this.videoElement.videoHeight, P = this.videoContainer.offsetWidth, F = this.videoContainer.offsetHeight, I = a / N;
|
|
1394
|
+
if (P / F < I) {
|
|
1395
|
+
let a = I * F;
|
|
1396
|
+
this.videoElement.style.width = a + "px", this.videoElement.style.marginLeft = -(a - P) / 2 + "px", this.videoElement.style.height = F + "px", this.videoElement.style.marginTop = "0px";
|
|
1397
|
+
} else {
|
|
1398
|
+
let a = 1 / (I / P);
|
|
1399
|
+
this.videoElement.style.height = a + "px", this.videoElement.style.marginTop = -(a - F) / 2 + "px", this.videoElement.style.width = P + "px", this.videoElement.style.marginLeft = "0px";
|
|
1400
|
+
}
|
|
1401
|
+
}), __publicField$17(this, "_computeFov", () => {
|
|
1402
|
+
["stopping", "stopped"].includes(this.state) || (this.fov = calcDisplayedFov$5(this.videoContainer, this.videoElement, this._hardwareVerticalFov), this.emit("fov.changed", this.fov));
|
|
1403
|
+
}), P = Object.assign({}, a.DEFAULT_OPTIONS, P), SharedCameras$1$6._add(this, N), this.videoContainer = N, this._resizeOnWindowChange = P.resizeOnWindowChange, this._userMediaConstraints = {
|
|
1404
|
+
audio: !1,
|
|
1405
|
+
video: {
|
|
1406
|
+
facingMode: "environment",
|
|
1407
|
+
width: { ideal: P.width },
|
|
1408
|
+
height: { ideal: P.height },
|
|
1409
|
+
resizeMode: "none"
|
|
1410
|
+
}
|
|
1411
|
+
}, this.videoContainer.style.overflow = "hidden", this.videoElement = document.createElement("video"), this.videoElement.setAttribute("id", "wemap-camera"), this.videoElement.setAttribute("preload", "none"), this.videoElement.setAttribute("muted", ""), this.videoElement.setAttribute("playsinline", ""), this.videoContainer.appendChild(this.videoElement);
|
|
1412
|
+
}
|
|
1413
|
+
async start(N) {
|
|
1414
|
+
if (this._state === "started" || this._state === "starting") throw Error("Camera is already started");
|
|
1415
|
+
this._state === "stopping" && await new Promise((a) => this.once("stopped", a)), this._state = "starting", this.emit("starting"), await a.checkAvailability(), typeof N == "object" && Object.assign(this._userMediaConstraints.video, this._userMediaConstraints.video, N);
|
|
1416
|
+
let P = await navigator.mediaDevices.getUserMedia(this._userMediaConstraints);
|
|
1417
|
+
this.videoElement.oncanplaythrough = () => this.videoElement.play();
|
|
1418
|
+
let F = new Promise((a) => this.videoElement.onloadedmetadata = a);
|
|
1419
|
+
this.videoElement.srcObject = this.videoStream = P, await F, this._resizeElement(), this._computeFov(), this._resizeOnWindowChange && window.addEventListener("resize", this.notifyContainerSizeChanged), this._state = "started";
|
|
1420
|
+
let I = {
|
|
1421
|
+
videoElement: this.videoElement,
|
|
1422
|
+
stream: P
|
|
1423
|
+
};
|
|
1424
|
+
return this.emit("started", I), I;
|
|
1425
|
+
}
|
|
1426
|
+
async stop() {
|
|
1427
|
+
if (this._state === "stopped") throw Error("Camera is already stopped");
|
|
1428
|
+
this._state === "starting" && await new Promise((a) => this.once("started", a)), this._state = "stopping", this.emit("stopping"), this.videoStream && this.videoStream.getVideoTracks().forEach((a) => a.stop()), this.videoStream = null, this.videoElement.srcObject = null, this._resizeOnWindowChange && window.removeEventListener("resize", this.notifyContainerSizeChanged), this._state = "stopped", this.emit("stopped");
|
|
1429
|
+
}
|
|
1430
|
+
release() {
|
|
1431
|
+
this.videoContainer.removeChild(this.videoElement), SharedCameras$1$6._remove(this);
|
|
1432
|
+
}
|
|
1433
|
+
static async checkAvailability(a = !1) {
|
|
1434
|
+
if (!navigator.mediaDevices) throw Error("navigator.mediaDevices not present in your browser");
|
|
1435
|
+
if (!navigator.mediaDevices.enumerateDevices) throw Error("navigator.mediaDevices.enumerateDevices not present in your browser");
|
|
1436
|
+
if (!navigator.mediaDevices.getUserMedia) throw Error("navigator.mediaDevices.getUserMedia not present in your browser");
|
|
1437
|
+
if (!(await navigator.mediaDevices.enumerateDevices()).find((a) => a.kind === "videoinput")) throw Error("No camera found");
|
|
1438
|
+
a && (await navigator.mediaDevices.getUserMedia({
|
|
1439
|
+
audio: !1,
|
|
1440
|
+
video: { facingMode: "environment" }
|
|
1441
|
+
})).getVideoTracks().forEach((a) => a.stop());
|
|
1442
|
+
}
|
|
1443
|
+
get state() {
|
|
1444
|
+
return this._state;
|
|
1445
|
+
}
|
|
1446
|
+
get hardwareVerticalFov() {
|
|
1447
|
+
return this._hardwareVerticalFov;
|
|
1448
|
+
}
|
|
1449
|
+
set hardwareVerticalFov(a) {
|
|
1450
|
+
this._hardwareVerticalFov = a, this._computeFov();
|
|
1451
|
+
}
|
|
1452
|
+
get currentImage() {
|
|
1453
|
+
if (this._state !== "started") return Logger$6.warn("Trying to access image but video is not started"), Promise.resolve(null);
|
|
1454
|
+
let { videoWidth: a, videoHeight: N } = this.videoElement, P = document.createElement("canvas"), F = P.getContext("2d");
|
|
1455
|
+
return P.width = a, P.height = N, F?.drawImage(this.videoElement, 0, 0, a, N), Promise.resolve(P);
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
__publicField$17(_Camera$6, "DEFAULT_OPTIONS", {
|
|
1459
|
+
width: 1024,
|
|
1460
|
+
height: 768,
|
|
1461
|
+
resizeOnWindowChange: !1
|
|
1462
|
+
}), __publicField$17(_Camera$6, "GENERIC_HARDWARE_VERTICAL_FOV", 60);
|
|
1463
|
+
var Camera$1 = _Camera$6, __create$10 = Object.create, __defProp$27 = Object.defineProperty, __getOwnPropDesc$10 = Object.getOwnPropertyDescriptor, __getOwnPropNames$10 = Object.getOwnPropertyNames, __getProtoOf$10 = Object.getPrototypeOf, __hasOwnProp$10 = Object.prototype.hasOwnProperty, __commonJSMin$10 = (a, N) => () => (N || a((N = { exports: {} }).exports, N), N.exports), __copyProps$10 = (a, N, P, F) => {
|
|
1464
|
+
if (N && typeof N == "object" || typeof N == "function") for (var I = __getOwnPropNames$10(N), L = 0, R = I.length, z; L < R; L++) z = I[L], !__hasOwnProp$10.call(a, z) && z !== P && __defProp$27(a, z, {
|
|
1465
|
+
get: ((a) => N[a]).bind(null, z),
|
|
1466
|
+
enumerable: !(F = __getOwnPropDesc$10(N, z)) || F.enumerable
|
|
1467
|
+
});
|
|
1468
|
+
return a;
|
|
1469
|
+
}, import_events$10 = /* @__PURE__ */ ((a, N, P) => (P = a == null ? {} : __create$10(__getProtoOf$10(a)), __copyProps$10(N || !a || !a.__esModule ? __defProp$27(P, "default", {
|
|
1470
|
+
value: a,
|
|
1471
|
+
enumerable: !0
|
|
1472
|
+
}) : P, a)))((/* @__PURE__ */ __commonJSMin$10(((a, N) => {
|
|
1473
|
+
var P = typeof Reflect == "object" ? Reflect : null, F = P && typeof P.apply == "function" ? P.apply : function(a, N, P) {
|
|
1474
|
+
return Function.prototype.apply.call(a, N, P);
|
|
1475
|
+
}, I = P && typeof P.ownKeys == "function" ? P.ownKeys : Object.getOwnPropertySymbols ? function(a) {
|
|
1476
|
+
return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a));
|
|
1477
|
+
} : function(a) {
|
|
1478
|
+
return Object.getOwnPropertyNames(a);
|
|
1479
|
+
};
|
|
1480
|
+
function L(a) {
|
|
1481
|
+
console && console.warn && console.warn(a);
|
|
1482
|
+
}
|
|
1483
|
+
var R = Number.isNaN || function(a) {
|
|
1484
|
+
return a !== a;
|
|
1485
|
+
};
|
|
1486
|
+
function z() {
|
|
1487
|
+
z.init.call(this);
|
|
1488
|
+
}
|
|
1489
|
+
N.exports = z, N.exports.once = Z, z.EventEmitter = z, z.prototype._events = void 0, z.prototype._eventsCount = 0, z.prototype._maxListeners = void 0;
|
|
1490
|
+
var B = 10;
|
|
1491
|
+
function V(a) {
|
|
1492
|
+
if (typeof a != "function") throw TypeError("The \"listener\" argument must be of type Function. Received type " + typeof a);
|
|
1493
|
+
}
|
|
1494
|
+
Object.defineProperty(z, "defaultMaxListeners", {
|
|
1495
|
+
enumerable: !0,
|
|
1496
|
+
get: function() {
|
|
1497
|
+
return B;
|
|
1498
|
+
},
|
|
1499
|
+
set: function(a) {
|
|
1500
|
+
if (typeof a != "number" || a < 0 || R(a)) throw RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received " + a + ".");
|
|
1501
|
+
B = a;
|
|
1502
|
+
}
|
|
1503
|
+
}), z.init = function() {
|
|
1504
|
+
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
1505
|
+
}, z.prototype.setMaxListeners = function(a) {
|
|
1506
|
+
if (typeof a != "number" || a < 0 || R(a)) throw RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received " + a + ".");
|
|
1507
|
+
return this._maxListeners = a, this;
|
|
1508
|
+
};
|
|
1509
|
+
function H(a) {
|
|
1510
|
+
return a._maxListeners === void 0 ? z.defaultMaxListeners : a._maxListeners;
|
|
1511
|
+
}
|
|
1512
|
+
z.prototype.getMaxListeners = function() {
|
|
1513
|
+
return H(this);
|
|
1514
|
+
}, z.prototype.emit = function(a) {
|
|
1515
|
+
for (var N = [], P = 1; P < arguments.length; P++) N.push(arguments[P]);
|
|
1516
|
+
var I = a === "error", L = this._events;
|
|
1517
|
+
if (L !== void 0) I &&= L.error === void 0;
|
|
1518
|
+
else if (!I) return !1;
|
|
1519
|
+
if (I) {
|
|
1520
|
+
var R;
|
|
1521
|
+
if (N.length > 0 && (R = N[0]), R instanceof Error) throw R;
|
|
1522
|
+
var z = /* @__PURE__ */ Error("Unhandled error." + (R ? " (" + R.message + ")" : ""));
|
|
1523
|
+
throw z.context = R, z;
|
|
1524
|
+
}
|
|
1525
|
+
var B = L[a];
|
|
1526
|
+
if (B === void 0) return !1;
|
|
1527
|
+
if (typeof B == "function") F(B, this, N);
|
|
1528
|
+
else for (var V = B.length, H = J(B, V), P = 0; P < V; ++P) F(H[P], this, N);
|
|
1529
|
+
return !0;
|
|
1530
|
+
};
|
|
1531
|
+
function U(a, N, P, F) {
|
|
1532
|
+
var I, R, z;
|
|
1533
|
+
if (V(P), R = a._events, R === void 0 ? (R = a._events = Object.create(null), a._eventsCount = 0) : (R.newListener !== void 0 && (a.emit("newListener", N, P.listener ? P.listener : P), R = a._events), z = R[N]), z === void 0) z = R[N] = P, ++a._eventsCount;
|
|
1534
|
+
else if (typeof z == "function" ? z = R[N] = F ? [P, z] : [z, P] : F ? z.unshift(P) : z.push(P), I = H(a), I > 0 && z.length > I && !z.warned) {
|
|
1535
|
+
z.warned = !0;
|
|
1536
|
+
var B = /* @__PURE__ */ Error("Possible EventEmitter memory leak detected. " + z.length + " " + String(N) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
1537
|
+
B.name = "MaxListenersExceededWarning", B.emitter = a, B.type = N, B.count = z.length, L(B);
|
|
1538
|
+
}
|
|
1539
|
+
return a;
|
|
1540
|
+
}
|
|
1541
|
+
z.prototype.addListener = function(a, N) {
|
|
1542
|
+
return U(this, a, N, !1);
|
|
1543
|
+
}, z.prototype.on = z.prototype.addListener, z.prototype.prependListener = function(a, N) {
|
|
1544
|
+
return U(this, a, N, !0);
|
|
1545
|
+
};
|
|
1546
|
+
function W() {
|
|
1547
|
+
if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
1548
|
+
}
|
|
1549
|
+
function G(a, N, P) {
|
|
1550
|
+
var F = {
|
|
1551
|
+
fired: !1,
|
|
1552
|
+
wrapFn: void 0,
|
|
1553
|
+
target: a,
|
|
1554
|
+
type: N,
|
|
1555
|
+
listener: P
|
|
1556
|
+
}, I = W.bind(F);
|
|
1557
|
+
return I.listener = P, F.wrapFn = I, I;
|
|
1558
|
+
}
|
|
1559
|
+
z.prototype.once = function(a, N) {
|
|
1560
|
+
return V(N), this.on(a, G(this, a, N)), this;
|
|
1561
|
+
}, z.prototype.prependOnceListener = function(a, N) {
|
|
1562
|
+
return V(N), this.prependListener(a, G(this, a, N)), this;
|
|
1563
|
+
}, z.prototype.removeListener = function(a, N) {
|
|
1564
|
+
var P, F, I, L, R;
|
|
1565
|
+
if (V(N), F = this._events, F === void 0 || (P = F[a], P === void 0)) return this;
|
|
1566
|
+
if (P === N || P.listener === N) --this._eventsCount === 0 ? this._events = Object.create(null) : (delete F[a], F.removeListener && this.emit("removeListener", a, P.listener || N));
|
|
1567
|
+
else if (typeof P != "function") {
|
|
1568
|
+
for (I = -1, L = P.length - 1; L >= 0; L--) if (P[L] === N || P[L].listener === N) {
|
|
1569
|
+
R = P[L].listener, I = L;
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
if (I < 0) return this;
|
|
1573
|
+
I === 0 ? P.shift() : Y(P, I), P.length === 1 && (F[a] = P[0]), F.removeListener !== void 0 && this.emit("removeListener", a, R || N);
|
|
1574
|
+
}
|
|
1575
|
+
return this;
|
|
1576
|
+
}, z.prototype.off = z.prototype.removeListener, z.prototype.removeAllListeners = function(a) {
|
|
1577
|
+
var N, P = this._events, F;
|
|
1578
|
+
if (P === void 0) return this;
|
|
1579
|
+
if (P.removeListener === void 0) return arguments.length === 0 ? (this._events = Object.create(null), this._eventsCount = 0) : P[a] !== void 0 && (--this._eventsCount === 0 ? this._events = Object.create(null) : delete P[a]), this;
|
|
1580
|
+
if (arguments.length === 0) {
|
|
1581
|
+
var I = Object.keys(P), L;
|
|
1582
|
+
for (F = 0; F < I.length; ++F) L = I[F], L !== "removeListener" && this.removeAllListeners(L);
|
|
1583
|
+
return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this;
|
|
1584
|
+
}
|
|
1585
|
+
if (N = P[a], typeof N == "function") this.removeListener(a, N);
|
|
1586
|
+
else if (N !== void 0) for (F = N.length - 1; F >= 0; F--) this.removeListener(a, N[F]);
|
|
1587
|
+
return this;
|
|
1588
|
+
};
|
|
1589
|
+
function K(a, N, P) {
|
|
1590
|
+
var F = a._events;
|
|
1591
|
+
if (F === void 0) return [];
|
|
1592
|
+
var I = F[N];
|
|
1593
|
+
return I === void 0 ? [] : typeof I == "function" ? P ? [I.listener || I] : [I] : P ? X(I) : J(I, I.length);
|
|
1594
|
+
}
|
|
1595
|
+
z.prototype.listeners = function(a) {
|
|
1596
|
+
return K(this, a, !0);
|
|
1597
|
+
}, z.prototype.rawListeners = function(a) {
|
|
1598
|
+
return K(this, a, !1);
|
|
1599
|
+
}, z.listenerCount = function(a, N) {
|
|
1600
|
+
return typeof a.listenerCount == "function" ? a.listenerCount(N) : q.call(a, N);
|
|
1601
|
+
}, z.prototype.listenerCount = q;
|
|
1602
|
+
function q(a) {
|
|
1603
|
+
var N = this._events;
|
|
1604
|
+
if (N !== void 0) {
|
|
1605
|
+
var P = N[a];
|
|
1606
|
+
if (typeof P == "function") return 1;
|
|
1607
|
+
if (P !== void 0) return P.length;
|
|
1608
|
+
}
|
|
1609
|
+
return 0;
|
|
1610
|
+
}
|
|
1611
|
+
z.prototype.eventNames = function() {
|
|
1612
|
+
return this._eventsCount > 0 ? I(this._events) : [];
|
|
1613
|
+
};
|
|
1614
|
+
function J(a, N) {
|
|
1615
|
+
for (var P = Array(N), F = 0; F < N; ++F) P[F] = a[F];
|
|
1616
|
+
return P;
|
|
1617
|
+
}
|
|
1618
|
+
function Y(a, N) {
|
|
1619
|
+
for (; N + 1 < a.length; N++) a[N] = a[N + 1];
|
|
1620
|
+
a.pop();
|
|
1621
|
+
}
|
|
1622
|
+
function X(a) {
|
|
1623
|
+
for (var N = Array(a.length), P = 0; P < N.length; ++P) N[P] = a[P].listener || a[P];
|
|
1624
|
+
return N;
|
|
1625
|
+
}
|
|
1626
|
+
function Z(a, N) {
|
|
1627
|
+
return new Promise(function(P, F) {
|
|
1628
|
+
function I(P) {
|
|
1629
|
+
a.removeListener(N, L), F(P);
|
|
1630
|
+
}
|
|
1631
|
+
function L() {
|
|
1632
|
+
typeof a.removeListener == "function" && a.removeListener("error", I), P([].slice.call(arguments));
|
|
1633
|
+
}
|
|
1634
|
+
$(a, N, L, { once: !0 }), N !== "error" && Q(a, I, { once: !0 });
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
function Q(a, N, P) {
|
|
1638
|
+
typeof a.on == "function" && $(a, "error", N, P);
|
|
1639
|
+
}
|
|
1640
|
+
function $(a, N, P, F) {
|
|
1641
|
+
if (typeof a.on == "function") F.once ? a.once(N, P) : a.on(N, P);
|
|
1642
|
+
else if (typeof a.addEventListener == "function") a.addEventListener(N, function I(L) {
|
|
1643
|
+
F.once && a.removeEventListener(N, I), P(L);
|
|
1644
|
+
});
|
|
1645
|
+
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof a);
|
|
1646
|
+
}
|
|
1647
|
+
})))(), 1), __defProp$26 = Object.defineProperty, __defNormalProp$16 = (a, N, P) => N in a ? __defProp$26(a, N, {
|
|
1648
|
+
enumerable: !0,
|
|
1649
|
+
configurable: !0,
|
|
1650
|
+
writable: !0,
|
|
1651
|
+
value: P
|
|
1652
|
+
}) : a[N] = P, __publicField$16 = (a, N, P) => (__defNormalProp$16(a, typeof N == "symbol" ? N : N + "", P), P), LEVELS_ORDER$10 = [
|
|
1653
|
+
"error",
|
|
1654
|
+
"ok",
|
|
1655
|
+
"warn",
|
|
1656
|
+
"flux",
|
|
1657
|
+
"deprecated",
|
|
1658
|
+
"info",
|
|
1659
|
+
"log",
|
|
1660
|
+
"debug"
|
|
1661
|
+
];
|
|
1662
|
+
function isWindowWithWemap$10(a) {
|
|
1663
|
+
return "wemap" in a;
|
|
1664
|
+
}
|
|
1665
|
+
var _Logger$10 = class a {
|
|
1666
|
+
static enable(N) {
|
|
1667
|
+
a.ENABLED = !!N;
|
|
1668
|
+
}
|
|
1669
|
+
static level(N) {
|
|
1670
|
+
return arguments.length && (a.LOG_LEVEL = N), a.LOG_LEVEL;
|
|
1671
|
+
}
|
|
1672
|
+
static clearHistory() {
|
|
1673
|
+
a.HISTORY = [];
|
|
1674
|
+
}
|
|
1675
|
+
static _canUseLog(N) {
|
|
1676
|
+
let P = LEVELS_ORDER$10.indexOf(N), F = LEVELS_ORDER$10.indexOf(a.LOG_LEVEL);
|
|
1677
|
+
return F === -1 ? !1 : P <= F;
|
|
1678
|
+
}
|
|
1679
|
+
static _getColorByType(a) {
|
|
1680
|
+
let N = null;
|
|
1681
|
+
switch (a) {
|
|
1682
|
+
case "flux":
|
|
1683
|
+
N = "background-color: #0083E0; color: #FFFFFF;";
|
|
1684
|
+
break;
|
|
1685
|
+
case "ok":
|
|
1686
|
+
N = "background-color: #00FF22; color: #272727;";
|
|
1687
|
+
break;
|
|
1688
|
+
case "deprecated":
|
|
1689
|
+
N = "background-color: #CA0AFA; color: #FFFFFF;";
|
|
1690
|
+
break;
|
|
1691
|
+
case "error":
|
|
1692
|
+
N = "background-color: #CC0000; color: #FFFFFF;";
|
|
1693
|
+
break;
|
|
1694
|
+
case "warn":
|
|
1695
|
+
N = "background-color: #DD7908; color: #FFFFFF;";
|
|
1696
|
+
break;
|
|
1697
|
+
case "debug":
|
|
1698
|
+
N = "background-color: #999999; color: #FFFFFF;";
|
|
1699
|
+
break;
|
|
1700
|
+
case "info":
|
|
1701
|
+
N = "background-color: #DCFF4E; color: #000000;";
|
|
1702
|
+
break;
|
|
1703
|
+
default:
|
|
1704
|
+
N = "background-color: #F4F4F4; color: #999999;";
|
|
1705
|
+
break;
|
|
1706
|
+
}
|
|
1707
|
+
return N;
|
|
1708
|
+
}
|
|
1709
|
+
static _getOriginByType(a, N) {
|
|
1710
|
+
let P = null, F = null, I = N;
|
|
1711
|
+
if (arguments.length < 2) return "";
|
|
1712
|
+
try {
|
|
1713
|
+
for (P = "", F = a.stack && a.stack.length ? a.stack.split("\n").splice(3) : [], (I < 0 || I >= F.length) && (I = F.length); I;) P += "\r\n " + F[0].trim(), F = F.splice(1), I--;
|
|
1714
|
+
return P;
|
|
1715
|
+
} catch {
|
|
1716
|
+
return "";
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
static _log(N, P, F) {
|
|
1720
|
+
let I = "color: auto;", L = "color: #6A6A6A;", R = typeof window < "u", z, B = null, V = null, H = null, U = null, W = "", G = !1;
|
|
1721
|
+
if (B = N, U = Error(P), R && (V = a._getColorByType(N)), H = a._getOriginByType(U, F), B === "deprecated" && (B = "warn", G = "deprecated"), R && (H = a._COLOR_TOKEN + H), z = (R ? a._COLOR_TOKEN : "") + " " + U.message, W = R ? a._COLOR_TOKEN : "", W += a._TYPE_PREFIX, W += G || N, W += a._TYPE_SUFFIX, typeof window < "u" && isWindowWithWemap$10(window)) {
|
|
1722
|
+
let a = performance && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime();
|
|
1723
|
+
W += "[" + Math.round(a - window.wemap.startTime) + "ms]";
|
|
1724
|
+
}
|
|
1725
|
+
return z = W + z, a.SHOW_ORIGIN && (z += H), a.HISTORY.push(z), !this._canUseLog(N) || arguments.length < 2 || !a.ENABLED ? !1 : (R ? console && N !== "ok" && N !== "flux" && N !== "deprecated" && console[N] && LEVELS_ORDER$10.indexOf(N) <= LEVELS_ORDER$10.indexOf("info") ? console[N](z, V, I, L) : console.log(z, V, I, L) : console.log(z), !0);
|
|
1726
|
+
}
|
|
1727
|
+
static external(a) {
|
|
1728
|
+
return console.log("LIVEMAP :: " + a);
|
|
1729
|
+
}
|
|
1730
|
+
static flux(N) {
|
|
1731
|
+
return a._log("flux", N, 0);
|
|
1732
|
+
}
|
|
1733
|
+
static ok(N) {
|
|
1734
|
+
return a._log("ok", N, 1);
|
|
1735
|
+
}
|
|
1736
|
+
static error(N, P = -1) {
|
|
1737
|
+
return a._log("error", N, P);
|
|
1738
|
+
}
|
|
1739
|
+
static warn(N, P = 2) {
|
|
1740
|
+
return a._log("warn", N, P);
|
|
1741
|
+
}
|
|
1742
|
+
static deprecated(N, P = 2) {
|
|
1743
|
+
return a._log("deprecated", N, P);
|
|
1744
|
+
}
|
|
1745
|
+
static debug(N, P = -1) {
|
|
1746
|
+
return a._log("debug", N, P);
|
|
1747
|
+
}
|
|
1748
|
+
static info(N, P = 0) {
|
|
1749
|
+
return a._log("info", N, P);
|
|
1750
|
+
}
|
|
1751
|
+
static log(N, P = 1) {
|
|
1752
|
+
return a._log("log", N, P);
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
__publicField$16(_Logger$10, "LOG_LEVEL", "debug"), __publicField$16(_Logger$10, "SHOW_ORIGIN", !0), __publicField$16(_Logger$10, "ENABLED", !0), __publicField$16(_Logger$10, "HISTORY", []), __publicField$16(_Logger$10, "_COLOR_TOKEN", "%c"), __publicField$16(_Logger$10, "_TYPE_PREFIX", "<<<< "), __publicField$16(_Logger$10, "_TYPE_SUFFIX", " >>>>");
|
|
1756
|
+
var Logger$5 = _Logger$10, e$10 = class a {
|
|
1757
|
+
constructor(N, P, F, I, L) {
|
|
1758
|
+
this._legacyCanvasSize = a.DEFAULT_CANVAS_SIZE, this._preferredCamera = "environment", this._maxScansPerSecond = 25, this._lastScanTimestamp = -1, this._destroyed = this._flashOn = this._paused = this._active = !1, this.$video = N, this.$canvas = document.createElement("canvas"), F && typeof F == "object" ? this._onDecode = P : (F || I || L ? console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future") : console.warn("Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."), this._legacyOnDecode = P), P = typeof F == "object" ? F : {}, this._onDecodeError = P.onDecodeError || (typeof F == "function" ? F : this._onDecodeError), this._calculateScanRegion = P.calculateScanRegion || (typeof I == "function" ? I : this._calculateScanRegion), this._preferredCamera = P.preferredCamera || L || this._preferredCamera, this._legacyCanvasSize = typeof F == "number" ? F : typeof I == "number" ? I : this._legacyCanvasSize, this._maxScansPerSecond = P.maxScansPerSecond || this._maxScansPerSecond, this._onPlay = this._onPlay.bind(this), this._onLoadedMetaData = this._onLoadedMetaData.bind(this), this._onVisibilityChange = this._onVisibilityChange.bind(this), this._updateOverlay = this._updateOverlay.bind(this), N.disablePictureInPicture = !0, N.playsInline = !0, N.muted = !0;
|
|
1759
|
+
let R = !1;
|
|
1760
|
+
if (N.hidden && (N.hidden = !1, R = !0), document.body.contains(N) || (document.body.appendChild(N), R = !0), F = N.parentElement, P.highlightScanRegion || P.highlightCodeOutline) {
|
|
1761
|
+
if (I = !!P.overlay, this.$overlay = P.overlay || document.createElement("div"), L = this.$overlay.style, L.position = "absolute", L.display = "none", L.pointerEvents = "none", this.$overlay.classList.add("scan-region-highlight"), !I && P.highlightScanRegion) {
|
|
1762
|
+
this.$overlay.innerHTML = "<svg class=\"scan-region-highlight-svg\" viewBox=\"0 0 238 238\" preserveAspectRatio=\"none\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round\"><path d=\"M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21\"/></svg>";
|
|
1763
|
+
try {
|
|
1764
|
+
this.$overlay.firstElementChild.animate({ transform: ["scale(.98)", "scale(1.01)"] }, {
|
|
1765
|
+
duration: 400,
|
|
1766
|
+
iterations: Infinity,
|
|
1767
|
+
direction: "alternate",
|
|
1768
|
+
easing: "ease-in-out"
|
|
1769
|
+
});
|
|
1770
|
+
} catch {}
|
|
1771
|
+
F.insertBefore(this.$overlay, this.$video.nextSibling);
|
|
1772
|
+
}
|
|
1773
|
+
P.highlightCodeOutline && (this.$overlay.insertAdjacentHTML("beforeend", "<svg class=\"code-outline-highlight\" preserveAspectRatio=\"none\" style=\"display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round\"><polygon/></svg>"), this.$codeOutlineHighlight = this.$overlay.lastElementChild);
|
|
1774
|
+
}
|
|
1775
|
+
this._scanRegion = this._calculateScanRegion(N), requestAnimationFrame(() => {
|
|
1776
|
+
let a = window.getComputedStyle(N);
|
|
1777
|
+
a.display === "none" && (N.style.setProperty("display", "block", "important"), R = !0), a.visibility !== "visible" && (N.style.setProperty("visibility", "visible", "important"), R = !0), R && (console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."), N.style.opacity = "0", N.style.width = "0", N.style.height = "0", this.$overlay && this.$overlay.parentElement && this.$overlay.parentElement.removeChild(this.$overlay), delete this.$overlay, delete this.$codeOutlineHighlight), this.$overlay && this._updateOverlay();
|
|
1778
|
+
}), N.addEventListener("play", this._onPlay), N.addEventListener("loadedmetadata", this._onLoadedMetaData), document.addEventListener("visibilitychange", this._onVisibilityChange), window.addEventListener("resize", this._updateOverlay), this._qrEnginePromise = a.createQrEngine();
|
|
1779
|
+
}
|
|
1780
|
+
static set WORKER_PATH(a) {
|
|
1781
|
+
console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.");
|
|
1782
|
+
}
|
|
1783
|
+
static async hasCamera() {
|
|
1784
|
+
try {
|
|
1785
|
+
return !!(await a.listCameras(!1)).length;
|
|
1786
|
+
} catch {
|
|
1787
|
+
return !1;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
static async listCameras(N = !1) {
|
|
1791
|
+
if (!navigator.mediaDevices) return [];
|
|
1792
|
+
let P = async () => (await navigator.mediaDevices.enumerateDevices()).filter((a) => a.kind === "videoinput"), F;
|
|
1793
|
+
try {
|
|
1794
|
+
N && (await P()).every((a) => !a.label) && (F = await navigator.mediaDevices.getUserMedia({
|
|
1795
|
+
audio: !1,
|
|
1796
|
+
video: !0
|
|
1797
|
+
}));
|
|
1798
|
+
} catch {}
|
|
1799
|
+
try {
|
|
1800
|
+
return (await P()).map((a, N) => ({
|
|
1801
|
+
id: a.deviceId,
|
|
1802
|
+
label: a.label || (N === 0 ? "Default Camera" : `Camera ${N + 1}`)
|
|
1803
|
+
}));
|
|
1804
|
+
} finally {
|
|
1805
|
+
F && (console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"), a._stopVideoStream(F));
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
async hasFlash() {
|
|
1809
|
+
let N;
|
|
1810
|
+
try {
|
|
1811
|
+
if (this.$video.srcObject) {
|
|
1812
|
+
if (!(this.$video.srcObject instanceof MediaStream)) return !1;
|
|
1813
|
+
N = this.$video.srcObject;
|
|
1814
|
+
} else N = (await this._getCameraStream()).stream;
|
|
1815
|
+
return "torch" in N.getVideoTracks()[0].getSettings();
|
|
1816
|
+
} catch {
|
|
1817
|
+
return !1;
|
|
1818
|
+
} finally {
|
|
1819
|
+
N && N !== this.$video.srcObject && (console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"), a._stopVideoStream(N));
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
isFlashOn() {
|
|
1823
|
+
return this._flashOn;
|
|
1824
|
+
}
|
|
1825
|
+
async toggleFlash() {
|
|
1826
|
+
this._flashOn ? await this.turnFlashOff() : await this.turnFlashOn();
|
|
1827
|
+
}
|
|
1828
|
+
async turnFlashOn() {
|
|
1829
|
+
if (!this._flashOn && !this._destroyed && (this._flashOn = !0, this._active && !this._paused)) try {
|
|
1830
|
+
if (!await this.hasFlash()) throw "No flash available";
|
|
1831
|
+
await this.$video.srcObject.getVideoTracks()[0].applyConstraints({ advanced: [{ torch: !0 }] });
|
|
1832
|
+
} catch (a) {
|
|
1833
|
+
throw this._flashOn = !1, a;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
async turnFlashOff() {
|
|
1837
|
+
this._flashOn && (this._flashOn = !1, await this._restartVideoStream());
|
|
1838
|
+
}
|
|
1839
|
+
destroy() {
|
|
1840
|
+
this.$video.removeEventListener("loadedmetadata", this._onLoadedMetaData), this.$video.removeEventListener("play", this._onPlay), document.removeEventListener("visibilitychange", this._onVisibilityChange), window.removeEventListener("resize", this._updateOverlay), this._destroyed = !0, this._flashOn = !1, this.stop(), a._postWorkerMessage(this._qrEnginePromise, "close");
|
|
1841
|
+
}
|
|
1842
|
+
async start() {
|
|
1843
|
+
if (this._destroyed) throw Error("The QR scanner can not be started as it had been destroyed.");
|
|
1844
|
+
if ((!this._active || this._paused) && (window.location.protocol !== "https:" && console.warn("The camera stream is only accessible if the page is transferred via https."), this._active = !0, !document.hidden)) if (this._paused = !1, this.$video.srcObject) await this.$video.play();
|
|
1845
|
+
else try {
|
|
1846
|
+
let { stream: N, facingMode: P } = await this._getCameraStream();
|
|
1847
|
+
!this._active || this._paused ? a._stopVideoStream(N) : (this._setVideoMirror(P), this.$video.srcObject = N, await this.$video.play(), this._flashOn && (this._flashOn = !1, this.turnFlashOn().catch(() => {})));
|
|
1848
|
+
} catch (a) {
|
|
1849
|
+
if (!this._paused) throw this._active = !1, a;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
stop() {
|
|
1853
|
+
this.pause(), this._active = !1;
|
|
1854
|
+
}
|
|
1855
|
+
async pause(N = !1) {
|
|
1856
|
+
if (this._paused = !0, !this._active) return !0;
|
|
1857
|
+
this.$video.pause(), this.$overlay && (this.$overlay.style.display = "none");
|
|
1858
|
+
let P = () => {
|
|
1859
|
+
this.$video.srcObject instanceof MediaStream && (a._stopVideoStream(this.$video.srcObject), this.$video.srcObject = null);
|
|
1860
|
+
};
|
|
1861
|
+
return N ? (P(), !0) : (await new Promise((a) => setTimeout(a, 300)), this._paused ? (P(), !0) : !1);
|
|
1862
|
+
}
|
|
1863
|
+
async setCamera(a) {
|
|
1864
|
+
a !== this._preferredCamera && (this._preferredCamera = a, await this._restartVideoStream());
|
|
1865
|
+
}
|
|
1866
|
+
static async scanImage(N, P, F, I, L = !1, R = !1) {
|
|
1867
|
+
let z, B = !1;
|
|
1868
|
+
P && ("scanRegion" in P || "qrEngine" in P || "canvas" in P || "disallowCanvasResizing" in P || "alsoTryWithoutScanRegion" in P || "returnDetailedScanResult" in P) ? (z = P.scanRegion, F = P.qrEngine, I = P.canvas, L = P.disallowCanvasResizing || !1, R = P.alsoTryWithoutScanRegion || !1, B = !0) : P || F || I || L || R ? console.warn("You're using a deprecated api for scanImage which will be removed in the future.") : console.warn("Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."), P = !!F;
|
|
1869
|
+
try {
|
|
1870
|
+
let V, H;
|
|
1871
|
+
[F, V] = await Promise.all([F || a.createQrEngine(), a._loadImage(N)]), [I, H] = a._drawToCanvas(V, z, I, L);
|
|
1872
|
+
let U;
|
|
1873
|
+
if (F instanceof Worker) {
|
|
1874
|
+
let N = F;
|
|
1875
|
+
P || a._postWorkerMessageSync(N, "inversionMode", "both"), U = await new Promise((P, F) => {
|
|
1876
|
+
let L, R, B, V = -1;
|
|
1877
|
+
R = (I) => {
|
|
1878
|
+
I.data.id === V && (N.removeEventListener("message", R), N.removeEventListener("error", B), clearTimeout(L), I.data.data === null ? F(a.NO_QR_CODE_FOUND) : P({
|
|
1879
|
+
data: I.data.data,
|
|
1880
|
+
cornerPoints: a._convertPoints(I.data.cornerPoints, z)
|
|
1881
|
+
}));
|
|
1882
|
+
}, B = (a) => {
|
|
1883
|
+
N.removeEventListener("message", R), N.removeEventListener("error", B), clearTimeout(L), F("Scanner error: " + (a ? a.message || a : "Unknown Error"));
|
|
1884
|
+
}, N.addEventListener("message", R), N.addEventListener("error", B), L = setTimeout(() => B("timeout"), 1e4);
|
|
1885
|
+
let U = H.getImageData(0, 0, I.width, I.height);
|
|
1886
|
+
V = a._postWorkerMessageSync(N, "decode", U, [U.data.buffer]);
|
|
1887
|
+
});
|
|
1888
|
+
} else U = await Promise.race([new Promise((a, N) => window.setTimeout(() => N("Scanner error: timeout"), 1e4)), (async () => {
|
|
1889
|
+
try {
|
|
1890
|
+
var [P] = await F.detect(I);
|
|
1891
|
+
if (!P) throw a.NO_QR_CODE_FOUND;
|
|
1892
|
+
return {
|
|
1893
|
+
data: P.rawValue,
|
|
1894
|
+
cornerPoints: a._convertPoints(P.cornerPoints, z)
|
|
1895
|
+
};
|
|
1896
|
+
} catch (F) {
|
|
1897
|
+
if (P = F.message || F, /not implemented|service unavailable/.test(P)) return a._disableBarcodeDetector = !0, a.scanImage(N, {
|
|
1898
|
+
scanRegion: z,
|
|
1899
|
+
canvas: I,
|
|
1900
|
+
disallowCanvasResizing: L,
|
|
1901
|
+
alsoTryWithoutScanRegion: R
|
|
1902
|
+
});
|
|
1903
|
+
throw `Scanner error: ${P}`;
|
|
1904
|
+
}
|
|
1905
|
+
})()]);
|
|
1906
|
+
return B ? U : U.data;
|
|
1907
|
+
} catch (P) {
|
|
1908
|
+
if (!z || !R) throw P;
|
|
1909
|
+
let V = await a.scanImage(N, {
|
|
1910
|
+
qrEngine: F,
|
|
1911
|
+
canvas: I,
|
|
1912
|
+
disallowCanvasResizing: L
|
|
1913
|
+
});
|
|
1914
|
+
return B ? V : V.data;
|
|
1915
|
+
} finally {
|
|
1916
|
+
P || a._postWorkerMessage(F, "close");
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
setGrayscaleWeights(N, P, F, I = !0) {
|
|
1920
|
+
a._postWorkerMessage(this._qrEnginePromise, "grayscaleWeights", {
|
|
1921
|
+
red: N,
|
|
1922
|
+
green: P,
|
|
1923
|
+
blue: F,
|
|
1924
|
+
useIntegerApproximation: I
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
setInversionMode(N) {
|
|
1928
|
+
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
1929
|
+
}
|
|
1930
|
+
static async createQrEngine(N) {
|
|
1931
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-B6z5WmOC-CssviUfq.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
1932
|
+
let P = navigator.userAgentData;
|
|
1933
|
+
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
1934
|
+
}
|
|
1935
|
+
_onPlay() {
|
|
1936
|
+
this._scanRegion = this._calculateScanRegion(this.$video), this._updateOverlay(), this.$overlay && (this.$overlay.style.display = ""), this._scanFrame();
|
|
1937
|
+
}
|
|
1938
|
+
_onLoadedMetaData() {
|
|
1939
|
+
this._scanRegion = this._calculateScanRegion(this.$video), this._updateOverlay();
|
|
1940
|
+
}
|
|
1941
|
+
_onVisibilityChange() {
|
|
1942
|
+
document.hidden ? this.pause() : this._active && this.start();
|
|
1943
|
+
}
|
|
1944
|
+
_calculateScanRegion(a) {
|
|
1945
|
+
let N = Math.round(2 / 3 * Math.min(a.videoWidth, a.videoHeight));
|
|
1946
|
+
return {
|
|
1947
|
+
x: Math.round((a.videoWidth - N) / 2),
|
|
1948
|
+
y: Math.round((a.videoHeight - N) / 2),
|
|
1949
|
+
width: N,
|
|
1950
|
+
height: N,
|
|
1951
|
+
downScaledWidth: this._legacyCanvasSize,
|
|
1952
|
+
downScaledHeight: this._legacyCanvasSize
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
_updateOverlay() {
|
|
1956
|
+
requestAnimationFrame(() => {
|
|
1957
|
+
if (this.$overlay) {
|
|
1958
|
+
var a = this.$video, N = a.videoWidth, P = a.videoHeight, F = a.offsetWidth, I = a.offsetHeight, L = a.offsetLeft, R = a.offsetTop, z = window.getComputedStyle(a), B = z.objectFit, V = N / P, H = F / I;
|
|
1959
|
+
switch (B) {
|
|
1960
|
+
case "none":
|
|
1961
|
+
var U = N, W = P;
|
|
1962
|
+
break;
|
|
1963
|
+
case "fill":
|
|
1964
|
+
U = F, W = I;
|
|
1965
|
+
break;
|
|
1966
|
+
default: (B === "cover" ? V > H : V < H) ? (W = I, U = W * V) : (U = F, W = U / V), B === "scale-down" && (U = Math.min(U, N), W = Math.min(W, P));
|
|
1967
|
+
}
|
|
1968
|
+
var [G, K] = z.objectPosition.split(" ").map((a, N) => {
|
|
1969
|
+
let P = parseFloat(a);
|
|
1970
|
+
return a.endsWith("%") ? (N ? I - W : F - U) * P / 100 : P;
|
|
1971
|
+
});
|
|
1972
|
+
z = this._scanRegion.width || N, H = this._scanRegion.height || P, B = this._scanRegion.x || 0;
|
|
1973
|
+
var q = this._scanRegion.y || 0;
|
|
1974
|
+
V = this.$overlay.style, V.width = `${z / N * U}px`, V.height = `${H / P * W}px`, V.top = `${R + K + q / P * W}px`, P = /scaleX\(-1\)/.test(a.style.transform), V.left = `${L + (P ? F - G - U : G) + (P ? N - B - z : B) / N * U}px`, V.transform = a.style.transform;
|
|
1975
|
+
}
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
static _convertPoints(a, N) {
|
|
1979
|
+
if (!N) return a;
|
|
1980
|
+
let P = N.x || 0, F = N.y || 0, I = N.width && N.downScaledWidth ? N.width / N.downScaledWidth : 1;
|
|
1981
|
+
N = N.height && N.downScaledHeight ? N.height / N.downScaledHeight : 1;
|
|
1982
|
+
for (let L of a) L.x = L.x * I + P, L.y = L.y * N + F;
|
|
1983
|
+
return a;
|
|
1984
|
+
}
|
|
1985
|
+
_scanFrame() {
|
|
1986
|
+
!this._active || this.$video.paused || this.$video.ended || ("requestVideoFrameCallback" in this.$video ? this.$video.requestVideoFrameCallback.bind(this.$video) : requestAnimationFrame)(async () => {
|
|
1987
|
+
if (!(1 >= this.$video.readyState)) {
|
|
1988
|
+
var N = Date.now() - this._lastScanTimestamp, P = 1e3 / this._maxScansPerSecond;
|
|
1989
|
+
N < P && await new Promise((a) => setTimeout(a, P - N)), this._lastScanTimestamp = Date.now();
|
|
1990
|
+
try {
|
|
1991
|
+
var F = await a.scanImage(this.$video, {
|
|
1992
|
+
scanRegion: this._scanRegion,
|
|
1993
|
+
qrEngine: this._qrEnginePromise,
|
|
1994
|
+
canvas: this.$canvas
|
|
1995
|
+
});
|
|
1996
|
+
} catch (a) {
|
|
1997
|
+
if (!this._active) return;
|
|
1998
|
+
this._onDecodeError(a);
|
|
1999
|
+
}
|
|
2000
|
+
!a._disableBarcodeDetector || await this._qrEnginePromise instanceof Worker || (this._qrEnginePromise = a.createQrEngine()), F ? (this._onDecode ? this._onDecode(F) : this._legacyOnDecode && this._legacyOnDecode(F.data), this.$codeOutlineHighlight && (clearTimeout(this._codeOutlineHighlightRemovalTimeout), this._codeOutlineHighlightRemovalTimeout = void 0, this.$codeOutlineHighlight.setAttribute("viewBox", `${this._scanRegion.x || 0} ${this._scanRegion.y || 0} ${this._scanRegion.width || this.$video.videoWidth} ${this._scanRegion.height || this.$video.videoHeight}`), this.$codeOutlineHighlight.firstElementChild.setAttribute("points", F.cornerPoints.map(({ x: a, y: N }) => `${a},${N}`).join(" ")), this.$codeOutlineHighlight.style.display = "")) : this.$codeOutlineHighlight && !this._codeOutlineHighlightRemovalTimeout && (this._codeOutlineHighlightRemovalTimeout = setTimeout(() => this.$codeOutlineHighlight.style.display = "none", 100));
|
|
2001
|
+
}
|
|
2002
|
+
this._scanFrame();
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
_onDecodeError(N) {
|
|
2006
|
+
N !== a.NO_QR_CODE_FOUND && console.log(N);
|
|
2007
|
+
}
|
|
2008
|
+
async _getCameraStream() {
|
|
2009
|
+
if (!navigator.mediaDevices) throw "Camera not found.";
|
|
2010
|
+
let a = /^(environment|user)$/.test(this._preferredCamera) ? "facingMode" : "deviceId", N = [
|
|
2011
|
+
{ width: { min: 1024 } },
|
|
2012
|
+
{ width: { min: 768 } },
|
|
2013
|
+
{}
|
|
2014
|
+
], P = N.map((N) => Object.assign({}, N, { [a]: { exact: this._preferredCamera } }));
|
|
2015
|
+
for (let a of [...P, ...N]) try {
|
|
2016
|
+
let N = await navigator.mediaDevices.getUserMedia({
|
|
2017
|
+
video: a,
|
|
2018
|
+
audio: !1
|
|
2019
|
+
});
|
|
2020
|
+
return {
|
|
2021
|
+
stream: N,
|
|
2022
|
+
facingMode: this._getFacingMode(N) || (a.facingMode ? this._preferredCamera : this._preferredCamera === "environment" ? "user" : "environment")
|
|
2023
|
+
};
|
|
2024
|
+
} catch {}
|
|
2025
|
+
throw "Camera not found.";
|
|
2026
|
+
}
|
|
2027
|
+
async _restartVideoStream() {
|
|
2028
|
+
let a = this._paused;
|
|
2029
|
+
await this.pause(!0) && !a && this._active && await this.start();
|
|
2030
|
+
}
|
|
2031
|
+
static _stopVideoStream(a) {
|
|
2032
|
+
for (let N of a.getTracks()) N.stop(), a.removeTrack(N);
|
|
2033
|
+
}
|
|
2034
|
+
_setVideoMirror(a) {
|
|
2035
|
+
this.$video.style.transform = "scaleX(" + (a === "user" ? -1 : 1) + ")";
|
|
2036
|
+
}
|
|
2037
|
+
_getFacingMode(a) {
|
|
2038
|
+
return (a = a.getVideoTracks()[0]) ? /rear|back|environment/i.test(a.label) ? "environment" : /front|user|face/i.test(a.label) ? "user" : null : null;
|
|
2039
|
+
}
|
|
2040
|
+
static _drawToCanvas(a, N, P, F = !1) {
|
|
2041
|
+
P ||= document.createElement("canvas");
|
|
2042
|
+
let I = N && N.x ? N.x : 0, L = N && N.y ? N.y : 0, R = N && N.width ? N.width : a.videoWidth || a.width, z = N && N.height ? N.height : a.videoHeight || a.height;
|
|
2043
|
+
return F || (F = N && N.downScaledWidth ? N.downScaledWidth : R, N = N && N.downScaledHeight ? N.downScaledHeight : z, P.width !== F && (P.width = F), P.height !== N && (P.height = N)), N = P.getContext("2d", { alpha: !1 }), N.imageSmoothingEnabled = !1, N.drawImage(a, I, L, R, z, 0, 0, P.width, P.height), [P, N];
|
|
2044
|
+
}
|
|
2045
|
+
static async _loadImage(N) {
|
|
2046
|
+
if (N instanceof Image) return await a._awaitImageLoad(N), N;
|
|
2047
|
+
if (N instanceof HTMLVideoElement || N instanceof HTMLCanvasElement || N instanceof SVGImageElement || "OffscreenCanvas" in window && N instanceof OffscreenCanvas || "ImageBitmap" in window && N instanceof ImageBitmap) return N;
|
|
2048
|
+
if (N instanceof File || N instanceof Blob || N instanceof URL || typeof N == "string") {
|
|
2049
|
+
let P = new Image();
|
|
2050
|
+
P.src = N instanceof File || N instanceof Blob ? URL.createObjectURL(N) : N.toString();
|
|
2051
|
+
try {
|
|
2052
|
+
return await a._awaitImageLoad(P), P;
|
|
2053
|
+
} finally {
|
|
2054
|
+
(N instanceof File || N instanceof Blob) && URL.revokeObjectURL(P.src);
|
|
2055
|
+
}
|
|
2056
|
+
} else throw "Unsupported image type.";
|
|
2057
|
+
}
|
|
2058
|
+
static async _awaitImageLoad(a) {
|
|
2059
|
+
a.complete && a.naturalWidth !== 0 || await new Promise((N, P) => {
|
|
2060
|
+
let F = (I) => {
|
|
2061
|
+
a.removeEventListener("load", F), a.removeEventListener("error", F), I instanceof ErrorEvent ? P("Image load error") : N();
|
|
2062
|
+
};
|
|
2063
|
+
a.addEventListener("load", F), a.addEventListener("error", F);
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
static async _postWorkerMessage(N, P, F, I) {
|
|
2067
|
+
return a._postWorkerMessageSync(await N, P, F, I);
|
|
2068
|
+
}
|
|
2069
|
+
static _postWorkerMessageSync(N, P, F, I) {
|
|
2070
|
+
if (!(N instanceof Worker)) return -1;
|
|
2071
|
+
let L = a._workerMessageId++;
|
|
2072
|
+
return N.postMessage({
|
|
2073
|
+
id: L,
|
|
2074
|
+
type: P,
|
|
2075
|
+
data: F
|
|
2076
|
+
}, I), L;
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
e$10.DEFAULT_CANVAS_SIZE = 400, e$10.NO_QR_CODE_FOUND = "No QR code found", e$10._disableBarcodeDetector = !1, e$10._workerMessageId = 0;
|
|
2080
|
+
var __defProp$25 = Object.defineProperty, __defNormalProp$15 = (a, N, P) => N in a ? __defProp$25(a, N, {
|
|
2081
|
+
enumerable: !0,
|
|
2082
|
+
configurable: !0,
|
|
2083
|
+
writable: !0,
|
|
2084
|
+
value: P
|
|
2085
|
+
}) : a[N] = P, __publicField$15 = (a, N, P) => (__defNormalProp$15(a, typeof N == "symbol" ? N : N + "", P), P), SharedCameras$1$5 = new class extends import_events$10.default {
|
|
2086
|
+
constructor() {
|
|
2087
|
+
super(...arguments), __publicField$15(this, "_list", []);
|
|
2088
|
+
}
|
|
2089
|
+
_add(a, N) {
|
|
2090
|
+
let P = {
|
|
2091
|
+
camera: a,
|
|
2092
|
+
container: N
|
|
2093
|
+
};
|
|
2094
|
+
this._list.push(P), this.emit("added", P);
|
|
2095
|
+
}
|
|
2096
|
+
_remove(a) {
|
|
2097
|
+
this._list = this._list.filter(({ camera: N }) => N !== a), this.emit("removed", { camera: a });
|
|
2098
|
+
}
|
|
2099
|
+
get list() {
|
|
2100
|
+
return this._list;
|
|
2101
|
+
}
|
|
2102
|
+
getCameraByContainer(a) {
|
|
2103
|
+
return this._list.find((N) => N.container === a)?.camera || null;
|
|
2104
|
+
}
|
|
2105
|
+
}();
|
|
2106
|
+
function convertFov$4(a, N) {
|
|
2107
|
+
return 2 * Math.atan(Math.tan(a / 180 * Math.PI / 2) * N) * 180 / Math.PI;
|
|
2108
|
+
}
|
|
2109
|
+
function calcDisplayedFov$4(a, N, P) {
|
|
2110
|
+
let F = N.videoWidth, I = N.videoHeight;
|
|
2111
|
+
if (!F || !I) return null;
|
|
2112
|
+
let L = a.offsetWidth, R = a.offsetHeight, z = F / I, B = L / R, V = P, H = convertFov$4(V, z);
|
|
2113
|
+
return B < z ? H = convertFov$4(V, B) : V = convertFov$4(H, 1 / B), {
|
|
2114
|
+
vertical: V,
|
|
2115
|
+
horizontal: H
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
var _Camera$5 = class a extends import_events$10.default {
|
|
2119
|
+
constructor(N, P = {}) {
|
|
2120
|
+
super(), __publicField$15(this, "_userMediaConstraints"), __publicField$15(this, "videoStream", null), __publicField$15(this, "videoContainer"), __publicField$15(this, "videoElement"), __publicField$15(this, "fov", null), __publicField$15(this, "_state", "stopped"), __publicField$15(this, "_hardwareVerticalFov", a.GENERIC_HARDWARE_VERTICAL_FOV), __publicField$15(this, "_resizeOnWindowChange"), __publicField$15(this, "notifyContainerSizeChanged", () => {
|
|
2121
|
+
this._resizeElement(), this._computeFov();
|
|
2122
|
+
}), __publicField$15(this, "_resizeElement", () => {
|
|
2123
|
+
if (!this.videoElement) throw Error("No video element found");
|
|
2124
|
+
let a = this.videoElement.videoWidth, N = this.videoElement.videoHeight, P = this.videoContainer.offsetWidth, F = this.videoContainer.offsetHeight, I = a / N;
|
|
2125
|
+
if (P / F < I) {
|
|
2126
|
+
let a = I * F;
|
|
2127
|
+
this.videoElement.style.width = a + "px", this.videoElement.style.marginLeft = -(a - P) / 2 + "px", this.videoElement.style.height = F + "px", this.videoElement.style.marginTop = "0px";
|
|
2128
|
+
} else {
|
|
2129
|
+
let a = 1 / (I / P);
|
|
2130
|
+
this.videoElement.style.height = a + "px", this.videoElement.style.marginTop = -(a - F) / 2 + "px", this.videoElement.style.width = P + "px", this.videoElement.style.marginLeft = "0px";
|
|
2131
|
+
}
|
|
2132
|
+
}), __publicField$15(this, "_computeFov", () => {
|
|
2133
|
+
["stopping", "stopped"].includes(this.state) || (this.fov = calcDisplayedFov$4(this.videoContainer, this.videoElement, this._hardwareVerticalFov), this.emit("fov.changed", this.fov));
|
|
2134
|
+
}), P = Object.assign({}, a.DEFAULT_OPTIONS, P), SharedCameras$1$5._add(this, N), this.videoContainer = N, this._resizeOnWindowChange = P.resizeOnWindowChange, this._userMediaConstraints = {
|
|
2135
|
+
audio: !1,
|
|
2136
|
+
video: {
|
|
2137
|
+
facingMode: "environment",
|
|
2138
|
+
width: { ideal: P.width },
|
|
2139
|
+
height: { ideal: P.height },
|
|
2140
|
+
resizeMode: "none"
|
|
2141
|
+
}
|
|
2142
|
+
}, this.videoContainer.style.overflow = "hidden", this.videoElement = document.createElement("video"), this.videoElement.setAttribute("id", "wemap-camera"), this.videoElement.setAttribute("preload", "none"), this.videoElement.setAttribute("muted", ""), this.videoElement.setAttribute("playsinline", ""), this.videoContainer.appendChild(this.videoElement);
|
|
2143
|
+
}
|
|
2144
|
+
async start(N) {
|
|
2145
|
+
if (this._state === "started" || this._state === "starting") throw Error("Camera is already started");
|
|
2146
|
+
this._state === "stopping" && await new Promise((a) => this.once("stopped", a)), this._state = "starting", this.emit("starting"), await a.checkAvailability(), typeof N == "object" && Object.assign(this._userMediaConstraints.video, this._userMediaConstraints.video, N);
|
|
2147
|
+
let P = await navigator.mediaDevices.getUserMedia(this._userMediaConstraints);
|
|
2148
|
+
this.videoElement.oncanplaythrough = () => this.videoElement.play();
|
|
2149
|
+
let F = new Promise((a) => this.videoElement.onloadedmetadata = a);
|
|
2150
|
+
this.videoElement.srcObject = this.videoStream = P, await F, this._resizeElement(), this._computeFov(), this._resizeOnWindowChange && window.addEventListener("resize", this.notifyContainerSizeChanged), this._state = "started";
|
|
2151
|
+
let I = {
|
|
2152
|
+
videoElement: this.videoElement,
|
|
2153
|
+
stream: P
|
|
2154
|
+
};
|
|
2155
|
+
return this.emit("started", I), I;
|
|
2156
|
+
}
|
|
2157
|
+
async stop() {
|
|
2158
|
+
if (this._state === "stopped") throw Error("Camera is already stopped");
|
|
2159
|
+
this._state === "starting" && await new Promise((a) => this.once("started", a)), this._state = "stopping", this.emit("stopping"), this.videoStream && this.videoStream.getVideoTracks().forEach((a) => a.stop()), this.videoStream = null, this.videoElement.srcObject = null, this._resizeOnWindowChange && window.removeEventListener("resize", this.notifyContainerSizeChanged), this._state = "stopped", this.emit("stopped");
|
|
2160
|
+
}
|
|
2161
|
+
release() {
|
|
2162
|
+
this.videoContainer.removeChild(this.videoElement), SharedCameras$1$5._remove(this);
|
|
2163
|
+
}
|
|
2164
|
+
static async checkAvailability(a = !1) {
|
|
2165
|
+
if (!navigator.mediaDevices) throw Error("navigator.mediaDevices not present in your browser");
|
|
2166
|
+
if (!navigator.mediaDevices.enumerateDevices) throw Error("navigator.mediaDevices.enumerateDevices not present in your browser");
|
|
2167
|
+
if (!navigator.mediaDevices.getUserMedia) throw Error("navigator.mediaDevices.getUserMedia not present in your browser");
|
|
2168
|
+
if (!(await navigator.mediaDevices.enumerateDevices()).find((a) => a.kind === "videoinput")) throw Error("No camera found");
|
|
2169
|
+
a && (await navigator.mediaDevices.getUserMedia({
|
|
2170
|
+
audio: !1,
|
|
2171
|
+
video: { facingMode: "environment" }
|
|
2172
|
+
})).getVideoTracks().forEach((a) => a.stop());
|
|
2173
|
+
}
|
|
2174
|
+
get state() {
|
|
2175
|
+
return this._state;
|
|
2176
|
+
}
|
|
2177
|
+
get hardwareVerticalFov() {
|
|
2178
|
+
return this._hardwareVerticalFov;
|
|
2179
|
+
}
|
|
2180
|
+
set hardwareVerticalFov(a) {
|
|
2181
|
+
this._hardwareVerticalFov = a, this._computeFov();
|
|
2182
|
+
}
|
|
2183
|
+
get currentImage() {
|
|
2184
|
+
if (this._state !== "started") return Logger$5.warn("Trying to access image but video is not started"), Promise.resolve(null);
|
|
2185
|
+
let { videoWidth: a, videoHeight: N } = this.videoElement, P = document.createElement("canvas"), F = P.getContext("2d");
|
|
2186
|
+
return P.width = a, P.height = N, F?.drawImage(this.videoElement, 0, 0, a, N), Promise.resolve(P);
|
|
2187
|
+
}
|
|
2188
|
+
};
|
|
2189
|
+
__publicField$15(_Camera$5, "DEFAULT_OPTIONS", {
|
|
2190
|
+
width: 1024,
|
|
2191
|
+
height: 768,
|
|
2192
|
+
resizeOnWindowChange: !1
|
|
2193
|
+
}), __publicField$15(_Camera$5, "GENERIC_HARDWARE_VERTICAL_FOV", 60);
|
|
2194
|
+
var __create$9 = Object.create, __defProp$24 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __getOwnPropNames$9 = Object.getOwnPropertyNames, __getProtoOf$9 = Object.getPrototypeOf, __hasOwnProp$9 = Object.prototype.hasOwnProperty, __commonJSMin$9 = (a, N) => () => (N || a((N = { exports: {} }).exports, N), N.exports), __copyProps$9 = (a, N, P, F) => {
|
|
2195
|
+
if (N && typeof N == "object" || typeof N == "function") for (var I = __getOwnPropNames$9(N), L = 0, R = I.length, z; L < R; L++) z = I[L], !__hasOwnProp$9.call(a, z) && z !== P && __defProp$24(a, z, {
|
|
2196
|
+
get: ((a) => N[a]).bind(null, z),
|
|
2197
|
+
enumerable: !(F = __getOwnPropDesc$9(N, z)) || F.enumerable
|
|
2198
|
+
});
|
|
2199
|
+
return a;
|
|
2200
|
+
}, import_events$9 = /* @__PURE__ */ ((a, N, P) => (P = a == null ? {} : __create$9(__getProtoOf$9(a)), __copyProps$9(N || !a || !a.__esModule ? __defProp$24(P, "default", {
|
|
2201
|
+
value: a,
|
|
2202
|
+
enumerable: !0
|
|
2203
|
+
}) : P, a)))((/* @__PURE__ */ __commonJSMin$9(((a, N) => {
|
|
2204
|
+
var P = typeof Reflect == "object" ? Reflect : null, F = P && typeof P.apply == "function" ? P.apply : function(a, N, P) {
|
|
2205
|
+
return Function.prototype.apply.call(a, N, P);
|
|
2206
|
+
}, I = P && typeof P.ownKeys == "function" ? P.ownKeys : Object.getOwnPropertySymbols ? function(a) {
|
|
2207
|
+
return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a));
|
|
2208
|
+
} : function(a) {
|
|
2209
|
+
return Object.getOwnPropertyNames(a);
|
|
2210
|
+
};
|
|
2211
|
+
function L(a) {
|
|
2212
|
+
console && console.warn && console.warn(a);
|
|
2213
|
+
}
|
|
2214
|
+
var R = Number.isNaN || function(a) {
|
|
2215
|
+
return a !== a;
|
|
2216
|
+
};
|
|
2217
|
+
function z() {
|
|
2218
|
+
z.init.call(this);
|
|
2219
|
+
}
|
|
2220
|
+
N.exports = z, N.exports.once = Z, z.EventEmitter = z, z.prototype._events = void 0, z.prototype._eventsCount = 0, z.prototype._maxListeners = void 0;
|
|
2221
|
+
var B = 10;
|
|
2222
|
+
function V(a) {
|
|
2223
|
+
if (typeof a != "function") throw TypeError("The \"listener\" argument must be of type Function. Received type " + typeof a);
|
|
2224
|
+
}
|
|
2225
|
+
Object.defineProperty(z, "defaultMaxListeners", {
|
|
2226
|
+
enumerable: !0,
|
|
2227
|
+
get: function() {
|
|
2228
|
+
return B;
|
|
2229
|
+
},
|
|
2230
|
+
set: function(a) {
|
|
2231
|
+
if (typeof a != "number" || a < 0 || R(a)) throw RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received " + a + ".");
|
|
2232
|
+
B = a;
|
|
2233
|
+
}
|
|
2234
|
+
}), z.init = function() {
|
|
2235
|
+
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
2236
|
+
}, z.prototype.setMaxListeners = function(a) {
|
|
2237
|
+
if (typeof a != "number" || a < 0 || R(a)) throw RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received " + a + ".");
|
|
2238
|
+
return this._maxListeners = a, this;
|
|
2239
|
+
};
|
|
2240
|
+
function H(a) {
|
|
2241
|
+
return a._maxListeners === void 0 ? z.defaultMaxListeners : a._maxListeners;
|
|
2242
|
+
}
|
|
2243
|
+
z.prototype.getMaxListeners = function() {
|
|
2244
|
+
return H(this);
|
|
2245
|
+
}, z.prototype.emit = function(a) {
|
|
2246
|
+
for (var N = [], P = 1; P < arguments.length; P++) N.push(arguments[P]);
|
|
2247
|
+
var I = a === "error", L = this._events;
|
|
2248
|
+
if (L !== void 0) I &&= L.error === void 0;
|
|
2249
|
+
else if (!I) return !1;
|
|
2250
|
+
if (I) {
|
|
2251
|
+
var R;
|
|
2252
|
+
if (N.length > 0 && (R = N[0]), R instanceof Error) throw R;
|
|
2253
|
+
var z = /* @__PURE__ */ Error("Unhandled error." + (R ? " (" + R.message + ")" : ""));
|
|
2254
|
+
throw z.context = R, z;
|
|
2255
|
+
}
|
|
2256
|
+
var B = L[a];
|
|
2257
|
+
if (B === void 0) return !1;
|
|
2258
|
+
if (typeof B == "function") F(B, this, N);
|
|
2259
|
+
else for (var V = B.length, H = J(B, V), P = 0; P < V; ++P) F(H[P], this, N);
|
|
2260
|
+
return !0;
|
|
2261
|
+
};
|
|
2262
|
+
function U(a, N, P, F) {
|
|
2263
|
+
var I, R, z;
|
|
2264
|
+
if (V(P), R = a._events, R === void 0 ? (R = a._events = Object.create(null), a._eventsCount = 0) : (R.newListener !== void 0 && (a.emit("newListener", N, P.listener ? P.listener : P), R = a._events), z = R[N]), z === void 0) z = R[N] = P, ++a._eventsCount;
|
|
2265
|
+
else if (typeof z == "function" ? z = R[N] = F ? [P, z] : [z, P] : F ? z.unshift(P) : z.push(P), I = H(a), I > 0 && z.length > I && !z.warned) {
|
|
2266
|
+
z.warned = !0;
|
|
2267
|
+
var B = /* @__PURE__ */ Error("Possible EventEmitter memory leak detected. " + z.length + " " + String(N) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
2268
|
+
B.name = "MaxListenersExceededWarning", B.emitter = a, B.type = N, B.count = z.length, L(B);
|
|
2269
|
+
}
|
|
2270
|
+
return a;
|
|
2271
|
+
}
|
|
2272
|
+
z.prototype.addListener = function(a, N) {
|
|
2273
|
+
return U(this, a, N, !1);
|
|
2274
|
+
}, z.prototype.on = z.prototype.addListener, z.prototype.prependListener = function(a, N) {
|
|
2275
|
+
return U(this, a, N, !0);
|
|
2276
|
+
};
|
|
2277
|
+
function W() {
|
|
2278
|
+
if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
2279
|
+
}
|
|
2280
|
+
function G(a, N, P) {
|
|
2281
|
+
var F = {
|
|
2282
|
+
fired: !1,
|
|
2283
|
+
wrapFn: void 0,
|
|
2284
|
+
target: a,
|
|
2285
|
+
type: N,
|
|
2286
|
+
listener: P
|
|
2287
|
+
}, I = W.bind(F);
|
|
2288
|
+
return I.listener = P, F.wrapFn = I, I;
|
|
2289
|
+
}
|
|
2290
|
+
z.prototype.once = function(a, N) {
|
|
2291
|
+
return V(N), this.on(a, G(this, a, N)), this;
|
|
2292
|
+
}, z.prototype.prependOnceListener = function(a, N) {
|
|
2293
|
+
return V(N), this.prependListener(a, G(this, a, N)), this;
|
|
2294
|
+
}, z.prototype.removeListener = function(a, N) {
|
|
2295
|
+
var P, F, I, L, R;
|
|
2296
|
+
if (V(N), F = this._events, F === void 0 || (P = F[a], P === void 0)) return this;
|
|
2297
|
+
if (P === N || P.listener === N) --this._eventsCount === 0 ? this._events = Object.create(null) : (delete F[a], F.removeListener && this.emit("removeListener", a, P.listener || N));
|
|
2298
|
+
else if (typeof P != "function") {
|
|
2299
|
+
for (I = -1, L = P.length - 1; L >= 0; L--) if (P[L] === N || P[L].listener === N) {
|
|
2300
|
+
R = P[L].listener, I = L;
|
|
2301
|
+
break;
|
|
2302
|
+
}
|
|
2303
|
+
if (I < 0) return this;
|
|
2304
|
+
I === 0 ? P.shift() : Y(P, I), P.length === 1 && (F[a] = P[0]), F.removeListener !== void 0 && this.emit("removeListener", a, R || N);
|
|
2305
|
+
}
|
|
2306
|
+
return this;
|
|
2307
|
+
}, z.prototype.off = z.prototype.removeListener, z.prototype.removeAllListeners = function(a) {
|
|
2308
|
+
var N, P = this._events, F;
|
|
2309
|
+
if (P === void 0) return this;
|
|
2310
|
+
if (P.removeListener === void 0) return arguments.length === 0 ? (this._events = Object.create(null), this._eventsCount = 0) : P[a] !== void 0 && (--this._eventsCount === 0 ? this._events = Object.create(null) : delete P[a]), this;
|
|
2311
|
+
if (arguments.length === 0) {
|
|
2312
|
+
var I = Object.keys(P), L;
|
|
2313
|
+
for (F = 0; F < I.length; ++F) L = I[F], L !== "removeListener" && this.removeAllListeners(L);
|
|
2314
|
+
return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this;
|
|
2315
|
+
}
|
|
2316
|
+
if (N = P[a], typeof N == "function") this.removeListener(a, N);
|
|
2317
|
+
else if (N !== void 0) for (F = N.length - 1; F >= 0; F--) this.removeListener(a, N[F]);
|
|
2318
|
+
return this;
|
|
2319
|
+
};
|
|
2320
|
+
function K(a, N, P) {
|
|
2321
|
+
var F = a._events;
|
|
2322
|
+
if (F === void 0) return [];
|
|
2323
|
+
var I = F[N];
|
|
2324
|
+
return I === void 0 ? [] : typeof I == "function" ? P ? [I.listener || I] : [I] : P ? X(I) : J(I, I.length);
|
|
2325
|
+
}
|
|
2326
|
+
z.prototype.listeners = function(a) {
|
|
2327
|
+
return K(this, a, !0);
|
|
2328
|
+
}, z.prototype.rawListeners = function(a) {
|
|
2329
|
+
return K(this, a, !1);
|
|
2330
|
+
}, z.listenerCount = function(a, N) {
|
|
2331
|
+
return typeof a.listenerCount == "function" ? a.listenerCount(N) : q.call(a, N);
|
|
2332
|
+
}, z.prototype.listenerCount = q;
|
|
2333
|
+
function q(a) {
|
|
2334
|
+
var N = this._events;
|
|
2335
|
+
if (N !== void 0) {
|
|
2336
|
+
var P = N[a];
|
|
2337
|
+
if (typeof P == "function") return 1;
|
|
2338
|
+
if (P !== void 0) return P.length;
|
|
2339
|
+
}
|
|
2340
|
+
return 0;
|
|
2341
|
+
}
|
|
2342
|
+
z.prototype.eventNames = function() {
|
|
2343
|
+
return this._eventsCount > 0 ? I(this._events) : [];
|
|
2344
|
+
};
|
|
2345
|
+
function J(a, N) {
|
|
2346
|
+
for (var P = Array(N), F = 0; F < N; ++F) P[F] = a[F];
|
|
2347
|
+
return P;
|
|
2348
|
+
}
|
|
2349
|
+
function Y(a, N) {
|
|
2350
|
+
for (; N + 1 < a.length; N++) a[N] = a[N + 1];
|
|
2351
|
+
a.pop();
|
|
2352
|
+
}
|
|
2353
|
+
function X(a) {
|
|
2354
|
+
for (var N = Array(a.length), P = 0; P < N.length; ++P) N[P] = a[P].listener || a[P];
|
|
2355
|
+
return N;
|
|
2356
|
+
}
|
|
2357
|
+
function Z(a, N) {
|
|
2358
|
+
return new Promise(function(P, F) {
|
|
2359
|
+
function I(P) {
|
|
2360
|
+
a.removeListener(N, L), F(P);
|
|
2361
|
+
}
|
|
2362
|
+
function L() {
|
|
2363
|
+
typeof a.removeListener == "function" && a.removeListener("error", I), P([].slice.call(arguments));
|
|
2364
|
+
}
|
|
2365
|
+
$(a, N, L, { once: !0 }), N !== "error" && Q(a, I, { once: !0 });
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
function Q(a, N, P) {
|
|
2369
|
+
typeof a.on == "function" && $(a, "error", N, P);
|
|
2370
|
+
}
|
|
2371
|
+
function $(a, N, P, F) {
|
|
2372
|
+
if (typeof a.on == "function") F.once ? a.once(N, P) : a.on(N, P);
|
|
2373
|
+
else if (typeof a.addEventListener == "function") a.addEventListener(N, function I(L) {
|
|
2374
|
+
F.once && a.removeEventListener(N, I), P(L);
|
|
2375
|
+
});
|
|
2376
|
+
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof a);
|
|
2377
|
+
}
|
|
2378
|
+
})))(), 1), __defProp$23 = Object.defineProperty, __defNormalProp$14 = (a, N, P) => N in a ? __defProp$23(a, N, {
|
|
2379
|
+
enumerable: !0,
|
|
2380
|
+
configurable: !0,
|
|
2381
|
+
writable: !0,
|
|
2382
|
+
value: P
|
|
2383
|
+
}) : a[N] = P, __publicField$14 = (a, N, P) => (__defNormalProp$14(a, typeof N == "symbol" ? N : N + "", P), P), LEVELS_ORDER$9 = [
|
|
2384
|
+
"error",
|
|
2385
|
+
"ok",
|
|
2386
|
+
"warn",
|
|
2387
|
+
"flux",
|
|
2388
|
+
"deprecated",
|
|
2389
|
+
"info",
|
|
2390
|
+
"log",
|
|
2391
|
+
"debug"
|
|
2392
|
+
];
|
|
2393
|
+
function isWindowWithWemap$9(a) {
|
|
2394
|
+
return "wemap" in a;
|
|
2395
|
+
}
|
|
2396
|
+
var _Logger$9 = class a {
|
|
2397
|
+
static enable(N) {
|
|
2398
|
+
a.ENABLED = !!N;
|
|
2399
|
+
}
|
|
2400
|
+
static level(N) {
|
|
2401
|
+
return arguments.length && (a.LOG_LEVEL = N), a.LOG_LEVEL;
|
|
2402
|
+
}
|
|
2403
|
+
static clearHistory() {
|
|
2404
|
+
a.HISTORY = [];
|
|
2405
|
+
}
|
|
2406
|
+
static _canUseLog(N) {
|
|
2407
|
+
let P = LEVELS_ORDER$9.indexOf(N), F = LEVELS_ORDER$9.indexOf(a.LOG_LEVEL);
|
|
2408
|
+
return F === -1 ? !1 : P <= F;
|
|
2409
|
+
}
|
|
2410
|
+
static _getColorByType(a) {
|
|
2411
|
+
let N = null;
|
|
2412
|
+
switch (a) {
|
|
2413
|
+
case "flux":
|
|
2414
|
+
N = "background-color: #0083E0; color: #FFFFFF;";
|
|
2415
|
+
break;
|
|
2416
|
+
case "ok":
|
|
2417
|
+
N = "background-color: #00FF22; color: #272727;";
|
|
2418
|
+
break;
|
|
2419
|
+
case "deprecated":
|
|
2420
|
+
N = "background-color: #CA0AFA; color: #FFFFFF;";
|
|
2421
|
+
break;
|
|
2422
|
+
case "error":
|
|
2423
|
+
N = "background-color: #CC0000; color: #FFFFFF;";
|
|
2424
|
+
break;
|
|
2425
|
+
case "warn":
|
|
2426
|
+
N = "background-color: #DD7908; color: #FFFFFF;";
|
|
2427
|
+
break;
|
|
2428
|
+
case "debug":
|
|
2429
|
+
N = "background-color: #999999; color: #FFFFFF;";
|
|
2430
|
+
break;
|
|
2431
|
+
case "info":
|
|
2432
|
+
N = "background-color: #DCFF4E; color: #000000;";
|
|
2433
|
+
break;
|
|
2434
|
+
default:
|
|
2435
|
+
N = "background-color: #F4F4F4; color: #999999;";
|
|
2436
|
+
break;
|
|
2437
|
+
}
|
|
2438
|
+
return N;
|
|
2439
|
+
}
|
|
2440
|
+
static _getOriginByType(a, N) {
|
|
2441
|
+
let P = null, F = null, I = N;
|
|
2442
|
+
if (arguments.length < 2) return "";
|
|
2443
|
+
try {
|
|
2444
|
+
for (P = "", F = a.stack && a.stack.length ? a.stack.split("\n").splice(3) : [], (I < 0 || I >= F.length) && (I = F.length); I;) P += "\r\n " + F[0].trim(), F = F.splice(1), I--;
|
|
2445
|
+
return P;
|
|
2446
|
+
} catch {
|
|
2447
|
+
return "";
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
static _log(N, P, F) {
|
|
2451
|
+
let I = "color: auto;", L = "color: #6A6A6A;", R = typeof window < "u", z, B = null, V = null, H = null, U = null, W = "", G = !1;
|
|
2452
|
+
if (B = N, U = Error(P), R && (V = a._getColorByType(N)), H = a._getOriginByType(U, F), B === "deprecated" && (B = "warn", G = "deprecated"), R && (H = a._COLOR_TOKEN + H), z = (R ? a._COLOR_TOKEN : "") + " " + U.message, W = R ? a._COLOR_TOKEN : "", W += a._TYPE_PREFIX, W += G || N, W += a._TYPE_SUFFIX, typeof window < "u" && isWindowWithWemap$9(window)) {
|
|
2453
|
+
let a = performance && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime();
|
|
2454
|
+
W += "[" + Math.round(a - window.wemap.startTime) + "ms]";
|
|
2455
|
+
}
|
|
2456
|
+
return z = W + z, a.SHOW_ORIGIN && (z += H), a.HISTORY.push(z), !this._canUseLog(N) || arguments.length < 2 || !a.ENABLED ? !1 : (R ? console && N !== "ok" && N !== "flux" && N !== "deprecated" && console[N] && LEVELS_ORDER$9.indexOf(N) <= LEVELS_ORDER$9.indexOf("info") ? console[N](z, V, I, L) : console.log(z, V, I, L) : console.log(z), !0);
|
|
2457
|
+
}
|
|
2458
|
+
static external(a) {
|
|
2459
|
+
return console.log("LIVEMAP :: " + a);
|
|
2460
|
+
}
|
|
2461
|
+
static flux(N) {
|
|
2462
|
+
return a._log("flux", N, 0);
|
|
2463
|
+
}
|
|
2464
|
+
static ok(N) {
|
|
2465
|
+
return a._log("ok", N, 1);
|
|
2466
|
+
}
|
|
2467
|
+
static error(N, P = -1) {
|
|
2468
|
+
return a._log("error", N, P);
|
|
2469
|
+
}
|
|
2470
|
+
static warn(N, P = 2) {
|
|
2471
|
+
return a._log("warn", N, P);
|
|
2472
|
+
}
|
|
2473
|
+
static deprecated(N, P = 2) {
|
|
2474
|
+
return a._log("deprecated", N, P);
|
|
2475
|
+
}
|
|
2476
|
+
static debug(N, P = -1) {
|
|
2477
|
+
return a._log("debug", N, P);
|
|
2478
|
+
}
|
|
2479
|
+
static info(N, P = 0) {
|
|
2480
|
+
return a._log("info", N, P);
|
|
2481
|
+
}
|
|
2482
|
+
static log(N, P = 1) {
|
|
2483
|
+
return a._log("log", N, P);
|
|
2484
|
+
}
|
|
2485
|
+
};
|
|
2486
|
+
__publicField$14(_Logger$9, "LOG_LEVEL", "debug"), __publicField$14(_Logger$9, "SHOW_ORIGIN", !0), __publicField$14(_Logger$9, "ENABLED", !0), __publicField$14(_Logger$9, "HISTORY", []), __publicField$14(_Logger$9, "_COLOR_TOKEN", "%c"), __publicField$14(_Logger$9, "_TYPE_PREFIX", "<<<< "), __publicField$14(_Logger$9, "_TYPE_SUFFIX", " >>>>");
|
|
2487
|
+
var Logger$4 = _Logger$9, e$9 = class a {
|
|
2488
|
+
constructor(N, P, F, I, L) {
|
|
2489
|
+
this._legacyCanvasSize = a.DEFAULT_CANVAS_SIZE, this._preferredCamera = "environment", this._maxScansPerSecond = 25, this._lastScanTimestamp = -1, this._destroyed = this._flashOn = this._paused = this._active = !1, this.$video = N, this.$canvas = document.createElement("canvas"), F && typeof F == "object" ? this._onDecode = P : (F || I || L ? console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future") : console.warn("Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."), this._legacyOnDecode = P), P = typeof F == "object" ? F : {}, this._onDecodeError = P.onDecodeError || (typeof F == "function" ? F : this._onDecodeError), this._calculateScanRegion = P.calculateScanRegion || (typeof I == "function" ? I : this._calculateScanRegion), this._preferredCamera = P.preferredCamera || L || this._preferredCamera, this._legacyCanvasSize = typeof F == "number" ? F : typeof I == "number" ? I : this._legacyCanvasSize, this._maxScansPerSecond = P.maxScansPerSecond || this._maxScansPerSecond, this._onPlay = this._onPlay.bind(this), this._onLoadedMetaData = this._onLoadedMetaData.bind(this), this._onVisibilityChange = this._onVisibilityChange.bind(this), this._updateOverlay = this._updateOverlay.bind(this), N.disablePictureInPicture = !0, N.playsInline = !0, N.muted = !0;
|
|
2490
|
+
let R = !1;
|
|
2491
|
+
if (N.hidden && (N.hidden = !1, R = !0), document.body.contains(N) || (document.body.appendChild(N), R = !0), F = N.parentElement, P.highlightScanRegion || P.highlightCodeOutline) {
|
|
2492
|
+
if (I = !!P.overlay, this.$overlay = P.overlay || document.createElement("div"), L = this.$overlay.style, L.position = "absolute", L.display = "none", L.pointerEvents = "none", this.$overlay.classList.add("scan-region-highlight"), !I && P.highlightScanRegion) {
|
|
2493
|
+
this.$overlay.innerHTML = "<svg class=\"scan-region-highlight-svg\" viewBox=\"0 0 238 238\" preserveAspectRatio=\"none\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round\"><path d=\"M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21\"/></svg>";
|
|
2494
|
+
try {
|
|
2495
|
+
this.$overlay.firstElementChild.animate({ transform: ["scale(.98)", "scale(1.01)"] }, {
|
|
2496
|
+
duration: 400,
|
|
2497
|
+
iterations: Infinity,
|
|
2498
|
+
direction: "alternate",
|
|
2499
|
+
easing: "ease-in-out"
|
|
2500
|
+
});
|
|
2501
|
+
} catch {}
|
|
2502
|
+
F.insertBefore(this.$overlay, this.$video.nextSibling);
|
|
2503
|
+
}
|
|
2504
|
+
P.highlightCodeOutline && (this.$overlay.insertAdjacentHTML("beforeend", "<svg class=\"code-outline-highlight\" preserveAspectRatio=\"none\" style=\"display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round\"><polygon/></svg>"), this.$codeOutlineHighlight = this.$overlay.lastElementChild);
|
|
2505
|
+
}
|
|
2506
|
+
this._scanRegion = this._calculateScanRegion(N), requestAnimationFrame(() => {
|
|
2507
|
+
let a = window.getComputedStyle(N);
|
|
2508
|
+
a.display === "none" && (N.style.setProperty("display", "block", "important"), R = !0), a.visibility !== "visible" && (N.style.setProperty("visibility", "visible", "important"), R = !0), R && (console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."), N.style.opacity = "0", N.style.width = "0", N.style.height = "0", this.$overlay && this.$overlay.parentElement && this.$overlay.parentElement.removeChild(this.$overlay), delete this.$overlay, delete this.$codeOutlineHighlight), this.$overlay && this._updateOverlay();
|
|
2509
|
+
}), N.addEventListener("play", this._onPlay), N.addEventListener("loadedmetadata", this._onLoadedMetaData), document.addEventListener("visibilitychange", this._onVisibilityChange), window.addEventListener("resize", this._updateOverlay), this._qrEnginePromise = a.createQrEngine();
|
|
2510
|
+
}
|
|
2511
|
+
static set WORKER_PATH(a) {
|
|
2512
|
+
console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.");
|
|
2513
|
+
}
|
|
2514
|
+
static async hasCamera() {
|
|
2515
|
+
try {
|
|
2516
|
+
return !!(await a.listCameras(!1)).length;
|
|
2517
|
+
} catch {
|
|
2518
|
+
return !1;
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
static async listCameras(N = !1) {
|
|
2522
|
+
if (!navigator.mediaDevices) return [];
|
|
2523
|
+
let P = async () => (await navigator.mediaDevices.enumerateDevices()).filter((a) => a.kind === "videoinput"), F;
|
|
2524
|
+
try {
|
|
2525
|
+
N && (await P()).every((a) => !a.label) && (F = await navigator.mediaDevices.getUserMedia({
|
|
2526
|
+
audio: !1,
|
|
2527
|
+
video: !0
|
|
2528
|
+
}));
|
|
2529
|
+
} catch {}
|
|
2530
|
+
try {
|
|
2531
|
+
return (await P()).map((a, N) => ({
|
|
2532
|
+
id: a.deviceId,
|
|
2533
|
+
label: a.label || (N === 0 ? "Default Camera" : `Camera ${N + 1}`)
|
|
2534
|
+
}));
|
|
2535
|
+
} finally {
|
|
2536
|
+
F && (console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"), a._stopVideoStream(F));
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
async hasFlash() {
|
|
2540
|
+
let N;
|
|
2541
|
+
try {
|
|
2542
|
+
if (this.$video.srcObject) {
|
|
2543
|
+
if (!(this.$video.srcObject instanceof MediaStream)) return !1;
|
|
2544
|
+
N = this.$video.srcObject;
|
|
2545
|
+
} else N = (await this._getCameraStream()).stream;
|
|
2546
|
+
return "torch" in N.getVideoTracks()[0].getSettings();
|
|
2547
|
+
} catch {
|
|
2548
|
+
return !1;
|
|
2549
|
+
} finally {
|
|
2550
|
+
N && N !== this.$video.srcObject && (console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"), a._stopVideoStream(N));
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
isFlashOn() {
|
|
2554
|
+
return this._flashOn;
|
|
2555
|
+
}
|
|
2556
|
+
async toggleFlash() {
|
|
2557
|
+
this._flashOn ? await this.turnFlashOff() : await this.turnFlashOn();
|
|
2558
|
+
}
|
|
2559
|
+
async turnFlashOn() {
|
|
2560
|
+
if (!this._flashOn && !this._destroyed && (this._flashOn = !0, this._active && !this._paused)) try {
|
|
2561
|
+
if (!await this.hasFlash()) throw "No flash available";
|
|
2562
|
+
await this.$video.srcObject.getVideoTracks()[0].applyConstraints({ advanced: [{ torch: !0 }] });
|
|
2563
|
+
} catch (a) {
|
|
2564
|
+
throw this._flashOn = !1, a;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
async turnFlashOff() {
|
|
2568
|
+
this._flashOn && (this._flashOn = !1, await this._restartVideoStream());
|
|
2569
|
+
}
|
|
2570
|
+
destroy() {
|
|
2571
|
+
this.$video.removeEventListener("loadedmetadata", this._onLoadedMetaData), this.$video.removeEventListener("play", this._onPlay), document.removeEventListener("visibilitychange", this._onVisibilityChange), window.removeEventListener("resize", this._updateOverlay), this._destroyed = !0, this._flashOn = !1, this.stop(), a._postWorkerMessage(this._qrEnginePromise, "close");
|
|
2572
|
+
}
|
|
2573
|
+
async start() {
|
|
2574
|
+
if (this._destroyed) throw Error("The QR scanner can not be started as it had been destroyed.");
|
|
2575
|
+
if ((!this._active || this._paused) && (window.location.protocol !== "https:" && console.warn("The camera stream is only accessible if the page is transferred via https."), this._active = !0, !document.hidden)) if (this._paused = !1, this.$video.srcObject) await this.$video.play();
|
|
2576
|
+
else try {
|
|
2577
|
+
let { stream: N, facingMode: P } = await this._getCameraStream();
|
|
2578
|
+
!this._active || this._paused ? a._stopVideoStream(N) : (this._setVideoMirror(P), this.$video.srcObject = N, await this.$video.play(), this._flashOn && (this._flashOn = !1, this.turnFlashOn().catch(() => {})));
|
|
2579
|
+
} catch (a) {
|
|
2580
|
+
if (!this._paused) throw this._active = !1, a;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
stop() {
|
|
2584
|
+
this.pause(), this._active = !1;
|
|
2585
|
+
}
|
|
2586
|
+
async pause(N = !1) {
|
|
2587
|
+
if (this._paused = !0, !this._active) return !0;
|
|
2588
|
+
this.$video.pause(), this.$overlay && (this.$overlay.style.display = "none");
|
|
2589
|
+
let P = () => {
|
|
2590
|
+
this.$video.srcObject instanceof MediaStream && (a._stopVideoStream(this.$video.srcObject), this.$video.srcObject = null);
|
|
2591
|
+
};
|
|
2592
|
+
return N ? (P(), !0) : (await new Promise((a) => setTimeout(a, 300)), this._paused ? (P(), !0) : !1);
|
|
2593
|
+
}
|
|
2594
|
+
async setCamera(a) {
|
|
2595
|
+
a !== this._preferredCamera && (this._preferredCamera = a, await this._restartVideoStream());
|
|
2596
|
+
}
|
|
2597
|
+
static async scanImage(N, P, F, I, L = !1, R = !1) {
|
|
2598
|
+
let z, B = !1;
|
|
2599
|
+
P && ("scanRegion" in P || "qrEngine" in P || "canvas" in P || "disallowCanvasResizing" in P || "alsoTryWithoutScanRegion" in P || "returnDetailedScanResult" in P) ? (z = P.scanRegion, F = P.qrEngine, I = P.canvas, L = P.disallowCanvasResizing || !1, R = P.alsoTryWithoutScanRegion || !1, B = !0) : P || F || I || L || R ? console.warn("You're using a deprecated api for scanImage which will be removed in the future.") : console.warn("Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."), P = !!F;
|
|
2600
|
+
try {
|
|
2601
|
+
let V, H;
|
|
2602
|
+
[F, V] = await Promise.all([F || a.createQrEngine(), a._loadImage(N)]), [I, H] = a._drawToCanvas(V, z, I, L);
|
|
2603
|
+
let U;
|
|
2604
|
+
if (F instanceof Worker) {
|
|
2605
|
+
let N = F;
|
|
2606
|
+
P || a._postWorkerMessageSync(N, "inversionMode", "both"), U = await new Promise((P, F) => {
|
|
2607
|
+
let L, R, B, V = -1;
|
|
2608
|
+
R = (I) => {
|
|
2609
|
+
I.data.id === V && (N.removeEventListener("message", R), N.removeEventListener("error", B), clearTimeout(L), I.data.data === null ? F(a.NO_QR_CODE_FOUND) : P({
|
|
2610
|
+
data: I.data.data,
|
|
2611
|
+
cornerPoints: a._convertPoints(I.data.cornerPoints, z)
|
|
2612
|
+
}));
|
|
2613
|
+
}, B = (a) => {
|
|
2614
|
+
N.removeEventListener("message", R), N.removeEventListener("error", B), clearTimeout(L), F("Scanner error: " + (a ? a.message || a : "Unknown Error"));
|
|
2615
|
+
}, N.addEventListener("message", R), N.addEventListener("error", B), L = setTimeout(() => B("timeout"), 1e4);
|
|
2616
|
+
let U = H.getImageData(0, 0, I.width, I.height);
|
|
2617
|
+
V = a._postWorkerMessageSync(N, "decode", U, [U.data.buffer]);
|
|
2618
|
+
});
|
|
2619
|
+
} else U = await Promise.race([new Promise((a, N) => window.setTimeout(() => N("Scanner error: timeout"), 1e4)), (async () => {
|
|
2620
|
+
try {
|
|
2621
|
+
var [P] = await F.detect(I);
|
|
2622
|
+
if (!P) throw a.NO_QR_CODE_FOUND;
|
|
2623
|
+
return {
|
|
2624
|
+
data: P.rawValue,
|
|
2625
|
+
cornerPoints: a._convertPoints(P.cornerPoints, z)
|
|
2626
|
+
};
|
|
2627
|
+
} catch (F) {
|
|
2628
|
+
if (P = F.message || F, /not implemented|service unavailable/.test(P)) return a._disableBarcodeDetector = !0, a.scanImage(N, {
|
|
2629
|
+
scanRegion: z,
|
|
2630
|
+
canvas: I,
|
|
2631
|
+
disallowCanvasResizing: L,
|
|
2632
|
+
alsoTryWithoutScanRegion: R
|
|
2633
|
+
});
|
|
2634
|
+
throw `Scanner error: ${P}`;
|
|
2635
|
+
}
|
|
2636
|
+
})()]);
|
|
2637
|
+
return B ? U : U.data;
|
|
2638
|
+
} catch (P) {
|
|
2639
|
+
if (!z || !R) throw P;
|
|
2640
|
+
let V = await a.scanImage(N, {
|
|
2641
|
+
qrEngine: F,
|
|
2642
|
+
canvas: I,
|
|
2643
|
+
disallowCanvasResizing: L
|
|
2644
|
+
});
|
|
2645
|
+
return B ? V : V.data;
|
|
2646
|
+
} finally {
|
|
2647
|
+
P || a._postWorkerMessage(F, "close");
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
setGrayscaleWeights(N, P, F, I = !0) {
|
|
2651
|
+
a._postWorkerMessage(this._qrEnginePromise, "grayscaleWeights", {
|
|
2652
|
+
red: N,
|
|
2653
|
+
green: P,
|
|
2654
|
+
blue: F,
|
|
2655
|
+
useIntegerApproximation: I
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
setInversionMode(N) {
|
|
2659
|
+
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
2660
|
+
}
|
|
2661
|
+
static async createQrEngine(N) {
|
|
2662
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-CYEYInSi-CIq73T7I-Dk6KCulN.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
2663
|
+
let P = navigator.userAgentData;
|
|
2664
|
+
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
2665
|
+
}
|
|
2666
|
+
_onPlay() {
|
|
2667
|
+
this._scanRegion = this._calculateScanRegion(this.$video), this._updateOverlay(), this.$overlay && (this.$overlay.style.display = ""), this._scanFrame();
|
|
2668
|
+
}
|
|
2669
|
+
_onLoadedMetaData() {
|
|
2670
|
+
this._scanRegion = this._calculateScanRegion(this.$video), this._updateOverlay();
|
|
2671
|
+
}
|
|
2672
|
+
_onVisibilityChange() {
|
|
2673
|
+
document.hidden ? this.pause() : this._active && this.start();
|
|
2674
|
+
}
|
|
2675
|
+
_calculateScanRegion(a) {
|
|
2676
|
+
let N = Math.round(2 / 3 * Math.min(a.videoWidth, a.videoHeight));
|
|
2677
|
+
return {
|
|
2678
|
+
x: Math.round((a.videoWidth - N) / 2),
|
|
2679
|
+
y: Math.round((a.videoHeight - N) / 2),
|
|
2680
|
+
width: N,
|
|
2681
|
+
height: N,
|
|
2682
|
+
downScaledWidth: this._legacyCanvasSize,
|
|
2683
|
+
downScaledHeight: this._legacyCanvasSize
|
|
2684
|
+
};
|
|
2685
|
+
}
|
|
2686
|
+
_updateOverlay() {
|
|
2687
|
+
requestAnimationFrame(() => {
|
|
2688
|
+
if (this.$overlay) {
|
|
2689
|
+
var a = this.$video, N = a.videoWidth, P = a.videoHeight, F = a.offsetWidth, I = a.offsetHeight, L = a.offsetLeft, R = a.offsetTop, z = window.getComputedStyle(a), B = z.objectFit, V = N / P, H = F / I;
|
|
2690
|
+
switch (B) {
|
|
2691
|
+
case "none":
|
|
2692
|
+
var U = N, W = P;
|
|
2693
|
+
break;
|
|
2694
|
+
case "fill":
|
|
2695
|
+
U = F, W = I;
|
|
2696
|
+
break;
|
|
2697
|
+
default: (B === "cover" ? V > H : V < H) ? (W = I, U = W * V) : (U = F, W = U / V), B === "scale-down" && (U = Math.min(U, N), W = Math.min(W, P));
|
|
2698
|
+
}
|
|
2699
|
+
var [G, K] = z.objectPosition.split(" ").map((a, N) => {
|
|
2700
|
+
let P = parseFloat(a);
|
|
2701
|
+
return a.endsWith("%") ? (N ? I - W : F - U) * P / 100 : P;
|
|
2702
|
+
});
|
|
2703
|
+
z = this._scanRegion.width || N, H = this._scanRegion.height || P, B = this._scanRegion.x || 0;
|
|
2704
|
+
var q = this._scanRegion.y || 0;
|
|
2705
|
+
V = this.$overlay.style, V.width = `${z / N * U}px`, V.height = `${H / P * W}px`, V.top = `${R + K + q / P * W}px`, P = /scaleX\(-1\)/.test(a.style.transform), V.left = `${L + (P ? F - G - U : G) + (P ? N - B - z : B) / N * U}px`, V.transform = a.style.transform;
|
|
2706
|
+
}
|
|
2707
|
+
});
|
|
2708
|
+
}
|
|
2709
|
+
static _convertPoints(a, N) {
|
|
2710
|
+
if (!N) return a;
|
|
2711
|
+
let P = N.x || 0, F = N.y || 0, I = N.width && N.downScaledWidth ? N.width / N.downScaledWidth : 1;
|
|
2712
|
+
N = N.height && N.downScaledHeight ? N.height / N.downScaledHeight : 1;
|
|
2713
|
+
for (let L of a) L.x = L.x * I + P, L.y = L.y * N + F;
|
|
2714
|
+
return a;
|
|
2715
|
+
}
|
|
2716
|
+
_scanFrame() {
|
|
2717
|
+
!this._active || this.$video.paused || this.$video.ended || ("requestVideoFrameCallback" in this.$video ? this.$video.requestVideoFrameCallback.bind(this.$video) : requestAnimationFrame)(async () => {
|
|
2718
|
+
if (!(1 >= this.$video.readyState)) {
|
|
2719
|
+
var N = Date.now() - this._lastScanTimestamp, P = 1e3 / this._maxScansPerSecond;
|
|
2720
|
+
N < P && await new Promise((a) => setTimeout(a, P - N)), this._lastScanTimestamp = Date.now();
|
|
2721
|
+
try {
|
|
2722
|
+
var F = await a.scanImage(this.$video, {
|
|
2723
|
+
scanRegion: this._scanRegion,
|
|
2724
|
+
qrEngine: this._qrEnginePromise,
|
|
2725
|
+
canvas: this.$canvas
|
|
2726
|
+
});
|
|
2727
|
+
} catch (a) {
|
|
2728
|
+
if (!this._active) return;
|
|
2729
|
+
this._onDecodeError(a);
|
|
2730
|
+
}
|
|
2731
|
+
!a._disableBarcodeDetector || await this._qrEnginePromise instanceof Worker || (this._qrEnginePromise = a.createQrEngine()), F ? (this._onDecode ? this._onDecode(F) : this._legacyOnDecode && this._legacyOnDecode(F.data), this.$codeOutlineHighlight && (clearTimeout(this._codeOutlineHighlightRemovalTimeout), this._codeOutlineHighlightRemovalTimeout = void 0, this.$codeOutlineHighlight.setAttribute("viewBox", `${this._scanRegion.x || 0} ${this._scanRegion.y || 0} ${this._scanRegion.width || this.$video.videoWidth} ${this._scanRegion.height || this.$video.videoHeight}`), this.$codeOutlineHighlight.firstElementChild.setAttribute("points", F.cornerPoints.map(({ x: a, y: N }) => `${a},${N}`).join(" ")), this.$codeOutlineHighlight.style.display = "")) : this.$codeOutlineHighlight && !this._codeOutlineHighlightRemovalTimeout && (this._codeOutlineHighlightRemovalTimeout = setTimeout(() => this.$codeOutlineHighlight.style.display = "none", 100));
|
|
2732
|
+
}
|
|
2733
|
+
this._scanFrame();
|
|
2734
|
+
});
|
|
2735
|
+
}
|
|
2736
|
+
_onDecodeError(N) {
|
|
2737
|
+
N !== a.NO_QR_CODE_FOUND && console.log(N);
|
|
2738
|
+
}
|
|
2739
|
+
async _getCameraStream() {
|
|
2740
|
+
if (!navigator.mediaDevices) throw "Camera not found.";
|
|
2741
|
+
let a = /^(environment|user)$/.test(this._preferredCamera) ? "facingMode" : "deviceId", N = [
|
|
2742
|
+
{ width: { min: 1024 } },
|
|
2743
|
+
{ width: { min: 768 } },
|
|
2744
|
+
{}
|
|
2745
|
+
], P = N.map((N) => Object.assign({}, N, { [a]: { exact: this._preferredCamera } }));
|
|
2746
|
+
for (let a of [...P, ...N]) try {
|
|
2747
|
+
let N = await navigator.mediaDevices.getUserMedia({
|
|
2748
|
+
video: a,
|
|
2749
|
+
audio: !1
|
|
2750
|
+
});
|
|
2751
|
+
return {
|
|
2752
|
+
stream: N,
|
|
2753
|
+
facingMode: this._getFacingMode(N) || (a.facingMode ? this._preferredCamera : this._preferredCamera === "environment" ? "user" : "environment")
|
|
2754
|
+
};
|
|
2755
|
+
} catch {}
|
|
2756
|
+
throw "Camera not found.";
|
|
2757
|
+
}
|
|
2758
|
+
async _restartVideoStream() {
|
|
2759
|
+
let a = this._paused;
|
|
2760
|
+
await this.pause(!0) && !a && this._active && await this.start();
|
|
2761
|
+
}
|
|
2762
|
+
static _stopVideoStream(a) {
|
|
2763
|
+
for (let N of a.getTracks()) N.stop(), a.removeTrack(N);
|
|
2764
|
+
}
|
|
2765
|
+
_setVideoMirror(a) {
|
|
2766
|
+
this.$video.style.transform = "scaleX(" + (a === "user" ? -1 : 1) + ")";
|
|
2767
|
+
}
|
|
2768
|
+
_getFacingMode(a) {
|
|
2769
|
+
return (a = a.getVideoTracks()[0]) ? /rear|back|environment/i.test(a.label) ? "environment" : /front|user|face/i.test(a.label) ? "user" : null : null;
|
|
2770
|
+
}
|
|
2771
|
+
static _drawToCanvas(a, N, P, F = !1) {
|
|
2772
|
+
P ||= document.createElement("canvas");
|
|
2773
|
+
let I = N && N.x ? N.x : 0, L = N && N.y ? N.y : 0, R = N && N.width ? N.width : a.videoWidth || a.width, z = N && N.height ? N.height : a.videoHeight || a.height;
|
|
2774
|
+
return F || (F = N && N.downScaledWidth ? N.downScaledWidth : R, N = N && N.downScaledHeight ? N.downScaledHeight : z, P.width !== F && (P.width = F), P.height !== N && (P.height = N)), N = P.getContext("2d", { alpha: !1 }), N.imageSmoothingEnabled = !1, N.drawImage(a, I, L, R, z, 0, 0, P.width, P.height), [P, N];
|
|
2775
|
+
}
|
|
2776
|
+
static async _loadImage(N) {
|
|
2777
|
+
if (N instanceof Image) return await a._awaitImageLoad(N), N;
|
|
2778
|
+
if (N instanceof HTMLVideoElement || N instanceof HTMLCanvasElement || N instanceof SVGImageElement || "OffscreenCanvas" in window && N instanceof OffscreenCanvas || "ImageBitmap" in window && N instanceof ImageBitmap) return N;
|
|
2779
|
+
if (N instanceof File || N instanceof Blob || N instanceof URL || typeof N == "string") {
|
|
2780
|
+
let P = new Image();
|
|
2781
|
+
P.src = N instanceof File || N instanceof Blob ? URL.createObjectURL(N) : N.toString();
|
|
2782
|
+
try {
|
|
2783
|
+
return await a._awaitImageLoad(P), P;
|
|
2784
|
+
} finally {
|
|
2785
|
+
(N instanceof File || N instanceof Blob) && URL.revokeObjectURL(P.src);
|
|
2786
|
+
}
|
|
2787
|
+
} else throw "Unsupported image type.";
|
|
2788
|
+
}
|
|
2789
|
+
static async _awaitImageLoad(a) {
|
|
2790
|
+
a.complete && a.naturalWidth !== 0 || await new Promise((N, P) => {
|
|
2791
|
+
let F = (I) => {
|
|
2792
|
+
a.removeEventListener("load", F), a.removeEventListener("error", F), I instanceof ErrorEvent ? P("Image load error") : N();
|
|
2793
|
+
};
|
|
2794
|
+
a.addEventListener("load", F), a.addEventListener("error", F);
|
|
2795
|
+
});
|
|
2796
|
+
}
|
|
2797
|
+
static async _postWorkerMessage(N, P, F, I) {
|
|
2798
|
+
return a._postWorkerMessageSync(await N, P, F, I);
|
|
2799
|
+
}
|
|
2800
|
+
static _postWorkerMessageSync(N, P, F, I) {
|
|
2801
|
+
if (!(N instanceof Worker)) return -1;
|
|
2802
|
+
let L = a._workerMessageId++;
|
|
2803
|
+
return N.postMessage({
|
|
2804
|
+
id: L,
|
|
2805
|
+
type: P,
|
|
2806
|
+
data: F
|
|
2807
|
+
}, I), L;
|
|
2808
|
+
}
|
|
2809
|
+
};
|
|
2810
|
+
e$9.DEFAULT_CANVAS_SIZE = 400, e$9.NO_QR_CODE_FOUND = "No QR code found", e$9._disableBarcodeDetector = !1, e$9._workerMessageId = 0;
|
|
2811
|
+
var __defProp$22 = Object.defineProperty, __defNormalProp$13 = (a, N, P) => N in a ? __defProp$22(a, N, {
|
|
2812
|
+
enumerable: !0,
|
|
2813
|
+
configurable: !0,
|
|
2814
|
+
writable: !0,
|
|
2815
|
+
value: P
|
|
2816
|
+
}) : a[N] = P, __publicField$13 = (a, N, P) => (__defNormalProp$13(a, typeof N == "symbol" ? N : N + "", P), P), SharedCameras$1$4 = new class extends import_events$9.default {
|
|
2817
|
+
constructor() {
|
|
2818
|
+
super(...arguments), __publicField$13(this, "_list", []);
|
|
2819
|
+
}
|
|
2820
|
+
_add(a, N) {
|
|
2821
|
+
let P = {
|
|
2822
|
+
camera: a,
|
|
2823
|
+
container: N
|
|
2824
|
+
};
|
|
2825
|
+
this._list.push(P), this.emit("added", P);
|
|
2826
|
+
}
|
|
2827
|
+
_remove(a) {
|
|
2828
|
+
this._list = this._list.filter(({ camera: N }) => N !== a), this.emit("removed", { camera: a });
|
|
2829
|
+
}
|
|
2830
|
+
get list() {
|
|
2831
|
+
return this._list;
|
|
2832
|
+
}
|
|
2833
|
+
getCameraByContainer(a) {
|
|
2834
|
+
return this._list.find((N) => N.container === a)?.camera || null;
|
|
2835
|
+
}
|
|
2836
|
+
}();
|
|
2837
|
+
function convertFov$3(a, N) {
|
|
2838
|
+
return 2 * Math.atan(Math.tan(a / 180 * Math.PI / 2) * N) * 180 / Math.PI;
|
|
2839
|
+
}
|
|
2840
|
+
function calcDisplayedFov$3(a, N, P) {
|
|
2841
|
+
let F = N.videoWidth, I = N.videoHeight;
|
|
2842
|
+
if (!F || !I) return null;
|
|
2843
|
+
let L = a.offsetWidth, R = a.offsetHeight, z = F / I, B = L / R, V = P, H = convertFov$3(V, z);
|
|
2844
|
+
return B < z ? H = convertFov$3(V, B) : V = convertFov$3(H, 1 / B), {
|
|
2845
|
+
vertical: V,
|
|
2846
|
+
horizontal: H
|
|
2847
|
+
};
|
|
2848
|
+
}
|
|
2849
|
+
var _Camera$4 = class a extends import_events$9.default {
|
|
2850
|
+
constructor(N, P = {}) {
|
|
2851
|
+
super(), __publicField$13(this, "_userMediaConstraints"), __publicField$13(this, "videoStream", null), __publicField$13(this, "videoContainer"), __publicField$13(this, "videoElement"), __publicField$13(this, "fov", null), __publicField$13(this, "_state", "stopped"), __publicField$13(this, "_hardwareVerticalFov", a.GENERIC_HARDWARE_VERTICAL_FOV), __publicField$13(this, "_resizeOnWindowChange"), __publicField$13(this, "notifyContainerSizeChanged", () => {
|
|
2852
|
+
this._resizeElement(), this._computeFov();
|
|
2853
|
+
}), __publicField$13(this, "_resizeElement", () => {
|
|
2854
|
+
if (!this.videoElement) throw Error("No video element found");
|
|
2855
|
+
let a = this.videoElement.videoWidth, N = this.videoElement.videoHeight, P = this.videoContainer.offsetWidth, F = this.videoContainer.offsetHeight, I = a / N;
|
|
2856
|
+
if (P / F < I) {
|
|
2857
|
+
let a = I * F;
|
|
2858
|
+
this.videoElement.style.width = a + "px", this.videoElement.style.marginLeft = -(a - P) / 2 + "px", this.videoElement.style.height = F + "px", this.videoElement.style.marginTop = "0px";
|
|
2859
|
+
} else {
|
|
2860
|
+
let a = 1 / (I / P);
|
|
2861
|
+
this.videoElement.style.height = a + "px", this.videoElement.style.marginTop = -(a - F) / 2 + "px", this.videoElement.style.width = P + "px", this.videoElement.style.marginLeft = "0px";
|
|
2862
|
+
}
|
|
2863
|
+
}), __publicField$13(this, "_computeFov", () => {
|
|
2864
|
+
["stopping", "stopped"].includes(this.state) || (this.fov = calcDisplayedFov$3(this.videoContainer, this.videoElement, this._hardwareVerticalFov), this.emit("fov.changed", this.fov));
|
|
2865
|
+
}), P = Object.assign({}, a.DEFAULT_OPTIONS, P), SharedCameras$1$4._add(this, N), this.videoContainer = N, this._resizeOnWindowChange = P.resizeOnWindowChange, this._userMediaConstraints = {
|
|
2866
|
+
audio: !1,
|
|
2867
|
+
video: {
|
|
2868
|
+
facingMode: "environment",
|
|
2869
|
+
width: { ideal: P.width },
|
|
2870
|
+
height: { ideal: P.height },
|
|
2871
|
+
resizeMode: "none"
|
|
2872
|
+
}
|
|
2873
|
+
}, this.videoContainer.style.overflow = "hidden", this.videoElement = document.createElement("video"), this.videoElement.setAttribute("id", "wemap-camera"), this.videoElement.setAttribute("preload", "none"), this.videoElement.setAttribute("muted", ""), this.videoElement.setAttribute("playsinline", ""), this.videoContainer.appendChild(this.videoElement);
|
|
2874
|
+
}
|
|
2875
|
+
async start(N) {
|
|
2876
|
+
if (this._state === "started" || this._state === "starting") throw Error("Camera is already started");
|
|
2877
|
+
this._state === "stopping" && await new Promise((a) => this.once("stopped", a)), this._state = "starting", this.emit("starting"), await a.checkAvailability(), typeof N == "object" && Object.assign(this._userMediaConstraints.video, this._userMediaConstraints.video, N);
|
|
2878
|
+
let P = await navigator.mediaDevices.getUserMedia(this._userMediaConstraints);
|
|
2879
|
+
this.videoElement.oncanplaythrough = () => this.videoElement.play();
|
|
2880
|
+
let F = new Promise((a) => this.videoElement.onloadedmetadata = a);
|
|
2881
|
+
this.videoElement.srcObject = this.videoStream = P, await F, this._resizeElement(), this._computeFov(), this._resizeOnWindowChange && window.addEventListener("resize", this.notifyContainerSizeChanged), this._state = "started";
|
|
2882
|
+
let I = {
|
|
2883
|
+
videoElement: this.videoElement,
|
|
2884
|
+
stream: P
|
|
2885
|
+
};
|
|
2886
|
+
return this.emit("started", I), I;
|
|
2887
|
+
}
|
|
2888
|
+
async stop() {
|
|
2889
|
+
if (this._state === "stopped") throw Error("Camera is already stopped");
|
|
2890
|
+
this._state === "starting" && await new Promise((a) => this.once("started", a)), this._state = "stopping", this.emit("stopping"), this.videoStream && this.videoStream.getVideoTracks().forEach((a) => a.stop()), this.videoStream = null, this.videoElement.srcObject = null, this._resizeOnWindowChange && window.removeEventListener("resize", this.notifyContainerSizeChanged), this._state = "stopped", this.emit("stopped");
|
|
2891
|
+
}
|
|
2892
|
+
release() {
|
|
2893
|
+
this.videoContainer.removeChild(this.videoElement), SharedCameras$1$4._remove(this);
|
|
2894
|
+
}
|
|
2895
|
+
static async checkAvailability(a = !1) {
|
|
2896
|
+
if (!navigator.mediaDevices) throw Error("navigator.mediaDevices not present in your browser");
|
|
2897
|
+
if (!navigator.mediaDevices.enumerateDevices) throw Error("navigator.mediaDevices.enumerateDevices not present in your browser");
|
|
2898
|
+
if (!navigator.mediaDevices.getUserMedia) throw Error("navigator.mediaDevices.getUserMedia not present in your browser");
|
|
2899
|
+
if (!(await navigator.mediaDevices.enumerateDevices()).find((a) => a.kind === "videoinput")) throw Error("No camera found");
|
|
2900
|
+
a && (await navigator.mediaDevices.getUserMedia({
|
|
2901
|
+
audio: !1,
|
|
2902
|
+
video: { facingMode: "environment" }
|
|
2903
|
+
})).getVideoTracks().forEach((a) => a.stop());
|
|
2904
|
+
}
|
|
2905
|
+
get state() {
|
|
2906
|
+
return this._state;
|
|
2907
|
+
}
|
|
2908
|
+
get hardwareVerticalFov() {
|
|
2909
|
+
return this._hardwareVerticalFov;
|
|
2910
|
+
}
|
|
2911
|
+
set hardwareVerticalFov(a) {
|
|
2912
|
+
this._hardwareVerticalFov = a, this._computeFov();
|
|
2913
|
+
}
|
|
2914
|
+
get currentImage() {
|
|
2915
|
+
if (this._state !== "started") return Logger$4.warn("Trying to access image but video is not started"), Promise.resolve(null);
|
|
2916
|
+
let { videoWidth: a, videoHeight: N } = this.videoElement, P = document.createElement("canvas"), F = P.getContext("2d");
|
|
2917
|
+
return P.width = a, P.height = N, F?.drawImage(this.videoElement, 0, 0, a, N), Promise.resolve(P);
|
|
2918
|
+
}
|
|
2919
|
+
};
|
|
2920
|
+
__publicField$13(_Camera$4, "DEFAULT_OPTIONS", {
|
|
2921
|
+
width: 1024,
|
|
2922
|
+
height: 768,
|
|
2923
|
+
resizeOnWindowChange: !1
|
|
2924
|
+
}), __publicField$13(_Camera$4, "GENERIC_HARDWARE_VERTICAL_FOV", 60);
|
|
2925
|
+
var __create$8 = Object.create, __defProp$21 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __getOwnPropNames$8 = Object.getOwnPropertyNames, __getProtoOf$8 = Object.getPrototypeOf, __hasOwnProp$8 = Object.prototype.hasOwnProperty, __commonJSMin$8 = (a, N) => () => (N || a((N = { exports: {} }).exports, N), N.exports), __copyProps$8 = (a, N, P, F) => {
|
|
2926
|
+
if (N && typeof N == "object" || typeof N == "function") for (var I = __getOwnPropNames$8(N), L = 0, R = I.length, z; L < R; L++) z = I[L], !__hasOwnProp$8.call(a, z) && z !== P && __defProp$21(a, z, {
|
|
2927
|
+
get: ((a) => N[a]).bind(null, z),
|
|
2928
|
+
enumerable: !(F = __getOwnPropDesc$8(N, z)) || F.enumerable
|
|
2929
|
+
});
|
|
2930
|
+
return a;
|
|
2931
|
+
}, import_events$5 = /* @__PURE__ */ ((a, N, P) => (P = a == null ? {} : __create$8(__getProtoOf$8(a)), __copyProps$8(N || !a || !a.__esModule ? __defProp$21(P, "default", {
|
|
2932
|
+
value: a,
|
|
2933
|
+
enumerable: !0
|
|
2934
|
+
}) : P, a)))((/* @__PURE__ */ __commonJSMin$8(((a, N) => {
|
|
11
2935
|
var P = typeof Reflect == "object" ? Reflect : null, F = P && typeof P.apply == "function" ? P.apply : function(a, N, P) {
|
|
12
2936
|
return Function.prototype.apply.call(a, N, P);
|
|
13
2937
|
}, I = P && typeof P.ownKeys == "function" ? P.ownKeys : Object.getOwnPropertySymbols ? function(a) {
|
|
@@ -255,12 +3179,12 @@ var _Logger$8 = class a {
|
|
|
255
3179
|
}
|
|
256
3180
|
}
|
|
257
3181
|
static _log(N, P, F) {
|
|
258
|
-
let I = "color: auto;", L = "color: #6A6A6A;", R = typeof window < "u", z, B = null, V = null, H = null, U = null,
|
|
259
|
-
if (B = N, U = Error(P), R && (V = a._getColorByType(N)), H = a._getOriginByType(U, F), B === "deprecated" && (B = "warn",
|
|
3182
|
+
let I = "color: auto;", L = "color: #6A6A6A;", R = typeof window < "u", z, B = null, V = null, H = null, U = null, W = "", G = !1;
|
|
3183
|
+
if (B = N, U = Error(P), R && (V = a._getColorByType(N)), H = a._getOriginByType(U, F), B === "deprecated" && (B = "warn", G = "deprecated"), R && (H = a._COLOR_TOKEN + H), z = (R ? a._COLOR_TOKEN : "") + " " + U.message, W = R ? a._COLOR_TOKEN : "", W += a._TYPE_PREFIX, W += G || N, W += a._TYPE_SUFFIX, typeof window < "u" && isWindowWithWemap$8(window)) {
|
|
260
3184
|
let a = performance && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime();
|
|
261
|
-
|
|
3185
|
+
W += "[" + Math.round(a - window.wemap.startTime) + "ms]";
|
|
262
3186
|
}
|
|
263
|
-
return z =
|
|
3187
|
+
return z = W + z, a.SHOW_ORIGIN && (z += H), a.HISTORY.push(z), !this._canUseLog(N) || arguments.length < 2 || !a.ENABLED ? !1 : (R ? console && N !== "ok" && N !== "flux" && N !== "deprecated" && console[N] && LEVELS_ORDER$8.indexOf(N) <= LEVELS_ORDER$8.indexOf("info") ? console[N](z, V, I, L) : console.log(z, V, I, L) : console.log(z), !0);
|
|
264
3188
|
}
|
|
265
3189
|
static external(a) {
|
|
266
3190
|
return console.log("LIVEMAP :: " + a);
|
|
@@ -466,7 +3390,7 @@ var Logger$2 = _Logger$8, e$8 = class a {
|
|
|
466
3390
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
467
3391
|
}
|
|
468
3392
|
static async createQrEngine(N) {
|
|
469
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
3393
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-BRbiAMv9-nmIQ9hck-C6vs_IbV-DSY4QR6D.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
470
3394
|
let P = navigator.userAgentData;
|
|
471
3395
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
472
3396
|
}
|
|
@@ -729,7 +3653,7 @@ __publicField$11(_Camera$3, "DEFAULT_OPTIONS", {
|
|
|
729
3653
|
height: 768,
|
|
730
3654
|
resizeOnWindowChange: !1
|
|
731
3655
|
}), __publicField$11(_Camera$3, "GENERIC_HARDWARE_VERTICAL_FOV", 60);
|
|
732
|
-
var
|
|
3656
|
+
var __create$7 = Object.create, __defProp$18 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __getOwnPropNames$7 = Object.getOwnPropertyNames, __getProtoOf$7 = Object.getPrototypeOf, __hasOwnProp$7 = Object.prototype.hasOwnProperty, __commonJSMin$7 = (a, N) => () => (N || a((N = { exports: {} }).exports, N), N.exports), __copyProps$7 = (a, N, P, F) => {
|
|
733
3657
|
if (N && typeof N == "object" || typeof N == "function") for (var I = __getOwnPropNames$7(N), L = 0, R = I.length, z; L < R; L++) z = I[L], !__hasOwnProp$7.call(a, z) && z !== P && __defProp$18(a, z, {
|
|
734
3658
|
get: ((a) => N[a]).bind(null, z),
|
|
735
3659
|
enumerable: !(F = __getOwnPropDesc$7(N, z)) || F.enumerable
|
|
@@ -1197,7 +4121,7 @@ var Logger$1 = _Logger$7, e$7 = class a {
|
|
|
1197
4121
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
1198
4122
|
}
|
|
1199
4123
|
static async createQrEngine(N) {
|
|
1200
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-CBTRGYa
|
|
4124
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-CBTRGYa--CBfOUkyb-qo3X-B_9-BkjDc6vN-ypRw_IJJ.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
1201
4125
|
let P = navigator.userAgentData;
|
|
1202
4126
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
1203
4127
|
}
|
|
@@ -1460,7 +4384,7 @@ __publicField$9(_Camera$2, "DEFAULT_OPTIONS", {
|
|
|
1460
4384
|
height: 768,
|
|
1461
4385
|
resizeOnWindowChange: !1
|
|
1462
4386
|
}), __publicField$9(_Camera$2, "GENERIC_HARDWARE_VERTICAL_FOV", 60);
|
|
1463
|
-
var
|
|
4387
|
+
var __create$6 = Object.create, __defProp$15 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __getOwnPropNames$6 = Object.getOwnPropertyNames, __getProtoOf$6 = Object.getPrototypeOf, __hasOwnProp$6 = Object.prototype.hasOwnProperty, __commonJSMin$6 = (a, N) => () => (N || a((N = { exports: {} }).exports, N), N.exports), __copyProps$6 = (a, N, P, F) => {
|
|
1464
4388
|
if (N && typeof N == "object" || typeof N == "function") for (var I = __getOwnPropNames$6(N), L = 0, R = I.length, z; L < R; L++) z = I[L], !__hasOwnProp$6.call(a, z) && z !== P && __defProp$15(a, z, {
|
|
1465
4389
|
get: ((a) => N[a]).bind(null, z),
|
|
1466
4390
|
enumerable: !(F = __getOwnPropDesc$6(N, z)) || F.enumerable
|
|
@@ -1928,7 +4852,7 @@ var Logger$3 = _Logger$6, e$6 = class a {
|
|
|
1928
4852
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
1929
4853
|
}
|
|
1930
4854
|
static async createQrEngine(N) {
|
|
1931
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-B5PB_bz0-DA0kiTSy.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
4855
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-B5PB_bz0-DA0kiTSy-NorQ2854-BMBKUWY9-BoVZZTXJ-CkGuQIJj.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
1932
4856
|
let P = navigator.userAgentData;
|
|
1933
4857
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
1934
4858
|
}
|
|
@@ -2677,7 +5601,7 @@ var e$5 = class a {
|
|
|
2677
5601
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
2678
5602
|
}
|
|
2679
5603
|
static async createQrEngine(N) {
|
|
2680
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-zOsA9GqL-spdHzETc-CdfYQy09.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
5604
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-zOsA9GqL-spdHzETc-CdfYQy09-yymxaPor-DcsJbmYs-CbrIyAqr-Cmnj38L_.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
2681
5605
|
let P = navigator.userAgentData;
|
|
2682
5606
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
2683
5607
|
}
|
|
@@ -3316,7 +6240,7 @@ var e$4 = class a {
|
|
|
3316
6240
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
3317
6241
|
}
|
|
3318
6242
|
static async createQrEngine(N) {
|
|
3319
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-DAbG1qpa-DsmIQ1ZR-D0bKFp24-Bgg9_K2D.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
6243
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-DAbG1qpa-DsmIQ1ZR-D0bKFp24-Bgg9_K2D-CzQjeLnK-Crw_pXOi-CxBZ0nTY-79jwfh5Z.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
3320
6244
|
let P = navigator.userAgentData;
|
|
3321
6245
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
3322
6246
|
}
|
|
@@ -3955,7 +6879,7 @@ var e$3 = class a {
|
|
|
3955
6879
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
3956
6880
|
}
|
|
3957
6881
|
static async createQrEngine(N) {
|
|
3958
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-BasYyBmn-Sg4PHYpX-k03AL3XJ-Cgjn176v-CDYp3S06.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
6882
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-BasYyBmn-Sg4PHYpX-k03AL3XJ-Cgjn176v-CDYp3S06-DEPW_gy0-CqeOxb0L-BxEDkksK-Cp-a8RPF.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
3959
6883
|
let P = navigator.userAgentData;
|
|
3960
6884
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
3961
6885
|
}
|
|
@@ -4590,7 +7514,7 @@ var e$2 = class a {
|
|
|
4590
7514
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
4591
7515
|
}
|
|
4592
7516
|
static async createQrEngine(N) {
|
|
4593
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-BQGmnbPC-DnOUafgV-DWpsR0Js-ZZGQKBrC-DOG-01---DWmsTSae.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
7517
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-BQGmnbPC-DnOUafgV-DWpsR0Js-ZZGQKBrC-DOG-01---DWmsTSae-B_rE_zzG-BqVqc5W7-Hoirdoyc-Dogb-sTf.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
4594
7518
|
let P = navigator.userAgentData;
|
|
4595
7519
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
4596
7520
|
}
|
|
@@ -5225,7 +8149,7 @@ var e$1 = class a {
|
|
|
5225
8149
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
5226
8150
|
}
|
|
5227
8151
|
static async createQrEngine(N) {
|
|
5228
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-Bej9J3jZ-LIy5T9qw-B5AD_dxc-vFmEZ9Jc-C18UJXmQ-ByBto5KP-DEO_S4_W.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
8152
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-Bej9J3jZ-LIy5T9qw-B5AD_dxc-vFmEZ9Jc-C18UJXmQ-ByBto5KP-DEO_S4_W-BWRiSO9N-BBjAeT1B-DH0W8Rxm-D2jL_VRE.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
5229
8153
|
let P = navigator.userAgentData;
|
|
5230
8154
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
5231
8155
|
}
|
|
@@ -5842,7 +8766,7 @@ var Logger = _Logger, e = class a {
|
|
|
5842
8766
|
a._postWorkerMessage(this._qrEnginePromise, "inversionMode", N);
|
|
5843
8767
|
}
|
|
5844
8768
|
static async createQrEngine(N) {
|
|
5845
|
-
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-j4KIyzGW-CtZ2H-uq-BsxRIRJ2-B58mXfMr-CY7U-8le-BqjFedsp-DkEzaBUL-DmYDsfTA.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
8769
|
+
if (N && console.warn("Specifying a worker path is not required and not supported anymore."), N = () => import("./qr-scanner-worker.min-CdBZO1_x-j4KIyzGW-CtZ2H-uq-BsxRIRJ2-B58mXfMr-CY7U-8le-BqjFedsp-DkEzaBUL-DmYDsfTA-OFT0YV77-CQI-j0E8-8Zc4Heoq-Bn1EU35u.js").then((a) => a.createWorker()), !(!a._disableBarcodeDetector && "BarcodeDetector" in window && BarcodeDetector.getSupportedFormats && (await BarcodeDetector.getSupportedFormats()).includes("qr_code"))) return N();
|
|
5846
8770
|
let P = navigator.userAgentData;
|
|
5847
8771
|
return P && P.brands.some(({ brand: a }) => /Chromium/i.test(a)) && /mac ?OS/i.test(P.platform) && await P.getHighEntropyValues(["architecture", "platformVersion"]).then(({ architecture: a, platformVersion: N }) => /arm/i.test(a || "arm") && 13 <= parseInt(N || "13")).catch(() => !0) ? N() : new BarcodeDetector({ formats: ["qr_code"] });
|
|
5848
8772
|
}
|