ablok-components 0.3.85 → 0.3.86
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.
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { defineComponent as at, ref as u, computed as h, watch as Ie, onMounted as it, nextTick as nt, onBeforeUnmount as ot, openBlock as y, createElementBlock as b, normalizeClass as
|
|
2
|
-
import { debounce as
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as at, ref as u, computed as h, watch as Ie, onMounted as it, nextTick as nt, onBeforeUnmount as ot, openBlock as y, createElementBlock as b, normalizeClass as ve, createElementVNode as w, createVNode as ae, withCtx as lt, createCommentVNode as z, withDirectives as xe, normalizeStyle as he, vShow as Re, toDisplayString as me, withModifiers as rt } from "vue";
|
|
2
|
+
import { debounce as st } from "lodash";
|
|
3
|
+
import ut from "../../atoms/loading-spinner/loading-spinner.vue.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import
|
|
5
|
+
import ct from "../../atoms/svg-icon/svg-icon.vue.js";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import
|
|
7
|
+
import dt from "../input-dropdown/input-dropdown.vue.js";
|
|
8
8
|
/* empty css */
|
|
9
|
-
import { dataURItoBlob as
|
|
10
|
-
import { useCameraFilter as
|
|
11
|
-
import
|
|
9
|
+
import { dataURItoBlob as vt } from "../../../utilities/helpers.js";
|
|
10
|
+
import { useCameraFilter as ht } from "../../../composables/useCameraFilter.js";
|
|
11
|
+
import mt from "../../atoms/zoom-slider/zoom-slider.vue.js";
|
|
12
12
|
/* empty css */
|
|
13
|
-
import
|
|
14
|
-
const
|
|
13
|
+
import ft from "../../../assets/img/guide.png.js";
|
|
14
|
+
const gt = { class: "camera__preview" }, wt = {
|
|
15
15
|
key: 0,
|
|
16
16
|
class: "camera__bg-notification"
|
|
17
|
-
},
|
|
17
|
+
}, pt = ["innerHTML"], yt = ["width", "height"], bt = {
|
|
18
18
|
key: 1,
|
|
19
19
|
class: "camera__countdown-overlay"
|
|
20
|
-
},
|
|
20
|
+
}, _t = ["innerHTML", "data-countdown"], Et = ["src"], Ct = {
|
|
21
21
|
key: 3,
|
|
22
22
|
class: "camera__zoom-slider"
|
|
23
|
-
},
|
|
23
|
+
}, St = { class: "camera__controls" }, kt = { class: "container" }, Dt = { class: "row" }, Mt = { class: "col" }, It = { class: "btn-group" }, xt = { key: 0 }, Rt = { key: 1 }, Ot = {
|
|
24
24
|
key: 0,
|
|
25
25
|
class: "camera__select-device"
|
|
26
|
-
},
|
|
26
|
+
}, Lt = { class: "col" }, Tt = { class: "" }, At = {
|
|
27
27
|
name: "BaseCamera",
|
|
28
28
|
inheritAttrs: !1
|
|
29
29
|
}, Oe = {
|
|
@@ -36,8 +36,8 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
36
36
|
"5x4": { width: 1200, height: 960 },
|
|
37
37
|
"16x9": { width: 1280, height: 720 },
|
|
38
38
|
"9x16": { width: 720, height: 1280 }
|
|
39
|
-
},
|
|
40
|
-
...
|
|
39
|
+
}, Kt = /* @__PURE__ */ at({
|
|
40
|
+
...At,
|
|
41
41
|
props: {
|
|
42
42
|
modelValue: {
|
|
43
43
|
type: null
|
|
@@ -60,7 +60,7 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
60
60
|
},
|
|
61
61
|
guideSrc: {
|
|
62
62
|
type: String,
|
|
63
|
-
default: () =>
|
|
63
|
+
default: () => ft
|
|
64
64
|
},
|
|
65
65
|
countdown: {
|
|
66
66
|
type: Number,
|
|
@@ -73,7 +73,7 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
73
73
|
filter: {
|
|
74
74
|
type: String,
|
|
75
75
|
default: "none",
|
|
76
|
-
validator: (
|
|
76
|
+
validator: (p) => ["none", "grayscale", "sepia"].includes(p)
|
|
77
77
|
},
|
|
78
78
|
tintColor: {
|
|
79
79
|
type: String,
|
|
@@ -113,34 +113,34 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
emits: ["update:modelValue"],
|
|
116
|
-
setup(
|
|
117
|
-
const r =
|
|
116
|
+
setup(p, { expose: Le, emit: Te }) {
|
|
117
|
+
const r = p, Ae = Te, n = u(), o = u(), fe = u(!1), W = u([]), c = u(), R = u(), j = u(), O = u(!1), K = u(!1), X = u(0), J = u(0), k = u(), d = u(r.zoom || 1), ge = u(!1), V = u(!1), ie = u(null), ne = u(!1);
|
|
118
118
|
let $, D;
|
|
119
|
-
const ze = typeof window < "u" && "DeviceMotionEvent" in window && (window.matchMedia?.("(pointer: coarse)")?.matches || "ontouchstart" in window), we = h(() => r.correctOrientation && ze),
|
|
120
|
-
function
|
|
119
|
+
const ze = typeof window < "u" && "DeviceMotionEvent" in window && (window.matchMedia?.("(pointer: coarse)")?.matches || "ontouchstart" in window), we = h(() => r.correctOrientation && ze), oe = h(() => fe.value && (!we.value || ne.value));
|
|
120
|
+
function le() {
|
|
121
121
|
D && (window.removeEventListener("pointerdown", D, !0), window.removeEventListener("touchend", D, !0), D = void 0);
|
|
122
122
|
}
|
|
123
123
|
function Q() {
|
|
124
|
-
|
|
124
|
+
ne.value = !0, $ && (clearTimeout($), $ = void 0), le();
|
|
125
125
|
}
|
|
126
126
|
function Ve() {
|
|
127
127
|
D || (D = () => {
|
|
128
|
-
|
|
128
|
+
re();
|
|
129
129
|
}, window.addEventListener("pointerdown", D, !0), window.addEventListener("touchend", D, !0));
|
|
130
130
|
}
|
|
131
131
|
function pe(e) {
|
|
132
132
|
const t = e.accelerationIncludingGravity;
|
|
133
133
|
if (!t || t.x == null || t.y == null) return;
|
|
134
134
|
const a = Math.round(Math.atan2(t.x, t.y) * 180 / Math.PI);
|
|
135
|
-
if (
|
|
135
|
+
if (ie.value = a, !(typeof screen < "u" && screen.orientation && screen.orientation.type || "portrait-primary").startsWith("portrait"))
|
|
136
136
|
V.value = !1;
|
|
137
137
|
else {
|
|
138
|
-
const
|
|
139
|
-
!V.value &&
|
|
138
|
+
const f = Math.abs(Math.abs(a) - 90);
|
|
139
|
+
!V.value && f < 40 ? V.value = !0 : V.value && f > 50 && (V.value = !1);
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
ne.value || Q();
|
|
142
142
|
}
|
|
143
|
-
async function
|
|
143
|
+
async function re() {
|
|
144
144
|
if (!(!r.correctOrientation || ge.value))
|
|
145
145
|
try {
|
|
146
146
|
const e = window.DeviceOrientationEvent, t = window.DeviceMotionEvent;
|
|
@@ -149,25 +149,25 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
t && typeof t.requestPermission == "function" && await t.requestPermission().catch(() => {
|
|
152
|
-
}), window.addEventListener("devicemotion", pe, !0), ge.value = !0,
|
|
152
|
+
}), window.addEventListener("devicemotion", pe, !0), ge.value = !0, le();
|
|
153
153
|
} catch (e) {
|
|
154
154
|
console.error(e, "enableMotion: failed"), Q();
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
const G = h(() => ({ ...Oe, ...r.resolutions })), $e = h(() => Object.values(G.value)[0]);
|
|
158
|
-
function
|
|
158
|
+
function He(e) {
|
|
159
159
|
return String(e || "").trim().toLowerCase().replace(/\s+/g, "").replace(/[:/]/g, "x");
|
|
160
160
|
}
|
|
161
161
|
const M = h(() => {
|
|
162
162
|
if (G.value[r.ratio])
|
|
163
163
|
return r.ratio;
|
|
164
|
-
const e =
|
|
164
|
+
const e = He(r.ratio);
|
|
165
165
|
if (G.value[e])
|
|
166
166
|
return e;
|
|
167
|
-
}),
|
|
167
|
+
}), L = h(() => M.value ? G.value[M.value] : $e.value), Be = h(() => {
|
|
168
168
|
const e = M.value ? G.value[M.value] : void 0;
|
|
169
169
|
return e ? `${e.width} / ${e.height}` : void 0;
|
|
170
|
-
}), I = h(() => W.value.filter((e) => e.kind === "videoinput")), ye = h(() => W.value.filter((e) => e.kind === "audioinput")), N = u([]),
|
|
170
|
+
}), I = h(() => W.value.filter((e) => e.kind === "videoinput")), ye = h(() => W.value.filter((e) => e.kind === "audioinput")), N = u([]), se = h(() => I.value.filter((e) => !N.value.includes(e.deviceId)));
|
|
171
171
|
function Ue(e) {
|
|
172
172
|
e && !N.value.includes(e) && (N.value = [...N.value, e]);
|
|
173
173
|
}
|
|
@@ -176,12 +176,12 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
176
176
|
if (!t.length) return;
|
|
177
177
|
const a = t.findIndex((l) => l.deviceId === e);
|
|
178
178
|
for (let l = 1; l <= t.length; l++) {
|
|
179
|
-
const
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
179
|
+
const m = t[(Math.max(a, 0) + l) % t.length];
|
|
180
|
+
if (m && !N.value.includes(m.deviceId))
|
|
181
|
+
return m;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
const We = h(() =>
|
|
184
|
+
const We = h(() => se.value.map((e, t) => ({
|
|
185
185
|
text: e.label.slice(0, e.label.indexOf("(")) || `Camera ${t + 1}`,
|
|
186
186
|
value: e.deviceId
|
|
187
187
|
}))), _e = h({
|
|
@@ -194,46 +194,46 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
194
194
|
});
|
|
195
195
|
h({
|
|
196
196
|
get() {
|
|
197
|
-
return
|
|
197
|
+
return R.value && R.value.deviceId;
|
|
198
198
|
},
|
|
199
199
|
set(e) {
|
|
200
|
-
|
|
200
|
+
R.value = ye.value.find((t) => t.deviceId === e);
|
|
201
201
|
}
|
|
202
202
|
});
|
|
203
|
-
const
|
|
203
|
+
const H = h(() => {
|
|
204
204
|
const e = c.value && I.value.findIndex((t) => t.deviceId === c.value?.deviceId);
|
|
205
205
|
return r.enableMirrorCamera && e === 0 ? "mirror-cam" : "";
|
|
206
206
|
}), je = h(() => {
|
|
207
207
|
const e = c.value && W.value.findIndex((t) => t.deviceId === c.value?.deviceId);
|
|
208
|
-
return
|
|
209
|
-
}), { tintRgb:
|
|
208
|
+
return H.value ? `${H.value} mirror-device-${e}` : "";
|
|
209
|
+
}), { tintRgb: zt, applyFilterToCanvas: Ee } = ht(r);
|
|
210
210
|
function Ce() {
|
|
211
|
-
if (M.value &&
|
|
212
|
-
X.value =
|
|
211
|
+
if (M.value && L.value) {
|
|
212
|
+
X.value = L.value.width, J.value = L.value.height;
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
X.value = n.value.parentElement && n.value.parentElement.clientWidth, J.value = n.value.parentElement && n.value.parentElement.clientHeight;
|
|
216
216
|
}
|
|
217
|
-
const Se =
|
|
217
|
+
const Se = st(() => {
|
|
218
218
|
Ce();
|
|
219
219
|
}, 300, { trailing: !0, leading: !1 });
|
|
220
|
-
function
|
|
220
|
+
function ue(e) {
|
|
221
221
|
return new Promise((t) => setTimeout(t, e));
|
|
222
222
|
}
|
|
223
223
|
async function Ge() {
|
|
224
|
-
const e =
|
|
225
|
-
...
|
|
224
|
+
const e = L.value ? { width: L.value.width, height: L.value.height } : void 0, t = e ? Math.max(e.width, e.height) : void 0, a = e ? Math.min(e.width, e.height) : void 0, l = r.enableAudio && {
|
|
225
|
+
...R.value ? { deviceId: R.value.deviceId } : {}
|
|
226
226
|
// deviceId: activeAudioDevice.value ? { exact: activeAudioDevice.value } : undefined
|
|
227
|
-
},
|
|
228
|
-
|
|
227
|
+
}, m = c.value && c.value.deviceId, f = j.value, i = [];
|
|
228
|
+
m ? (t && a && i.push({ deviceId: { exact: m }, width: { ideal: t }, height: { ideal: a } }), i.push({ deviceId: { exact: m } })) : f ? (t && a && i.push({ facingMode: { exact: f }, width: { ideal: t }, height: { ideal: a } }), i.push({ facingMode: { exact: f } }), t && a && i.push({ width: { ideal: t }, height: { ideal: a } }), i.push({})) : (t && a && i.push({ width: { ideal: t }, height: { ideal: a } }), i.push({}));
|
|
229
229
|
for (const s of i)
|
|
230
230
|
for (let v = 0; v < 5; v++)
|
|
231
231
|
try {
|
|
232
232
|
return await navigator.mediaDevices.getUserMedia({ audio: l, video: s });
|
|
233
|
-
} catch (
|
|
234
|
-
const C =
|
|
233
|
+
} catch (A) {
|
|
234
|
+
const C = A && A.name;
|
|
235
235
|
if (C === "NotReadableError" || C === "AbortError") {
|
|
236
|
-
await
|
|
236
|
+
await ue(500);
|
|
237
237
|
continue;
|
|
238
238
|
}
|
|
239
239
|
break;
|
|
@@ -244,10 +244,10 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
244
244
|
t.stop();
|
|
245
245
|
}), n.value.srcObject = null);
|
|
246
246
|
}
|
|
247
|
-
let
|
|
247
|
+
let T = 0;
|
|
248
248
|
const Ne = 350, Pe = 8e3;
|
|
249
249
|
let P, ee;
|
|
250
|
-
function
|
|
250
|
+
function B() {
|
|
251
251
|
P && (clearTimeout(P), P = void 0), ee && (ee(), ee = void 0);
|
|
252
252
|
}
|
|
253
253
|
function Fe(e) {
|
|
@@ -256,54 +256,54 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
256
256
|
t && t.deviceId !== e && (c.value = t);
|
|
257
257
|
}
|
|
258
258
|
function qe(e) {
|
|
259
|
-
|
|
259
|
+
B();
|
|
260
260
|
const t = c.value && c.value.deviceId, a = n.value;
|
|
261
261
|
if (!t || !a) return;
|
|
262
262
|
const l = a.srcObject && a.srcObject.getVideoTracks?.()[0];
|
|
263
263
|
if (!l || !(typeof l.addEventListener == "function") || a.videoWidth > 0) return;
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
264
|
+
const f = () => {
|
|
265
|
+
if (B(), e !== T || !n.value) return;
|
|
266
266
|
const v = be(t);
|
|
267
267
|
v && v.deviceId !== t && (Y(), Fe(t));
|
|
268
268
|
}, i = () => {
|
|
269
|
-
e ===
|
|
269
|
+
e === T && n.value && n.value.videoWidth > 0 && B();
|
|
270
270
|
}, s = () => {
|
|
271
|
-
|
|
271
|
+
f();
|
|
272
272
|
};
|
|
273
273
|
l.addEventListener("unmute", i), l.addEventListener("ended", s), ee = () => {
|
|
274
274
|
l.removeEventListener("unmute", i), l.removeEventListener("ended", s);
|
|
275
275
|
}, P = setTimeout(() => {
|
|
276
|
-
P = void 0, !(e !==
|
|
276
|
+
P = void 0, !(e !== T || !n.value) && (n.value.videoWidth === 0 ? f() : B());
|
|
277
277
|
}, Pe);
|
|
278
278
|
}
|
|
279
279
|
const Ze = 2;
|
|
280
|
-
let
|
|
280
|
+
let ce = 0;
|
|
281
281
|
async function U() {
|
|
282
|
-
const e = ++
|
|
283
|
-
|
|
282
|
+
const e = ++T;
|
|
283
|
+
B();
|
|
284
284
|
const t = !!(n.value && n.value.srcObject);
|
|
285
|
-
if (Y(), t && (await
|
|
285
|
+
if (Y(), t && (await ue(Ne), e !== T))
|
|
286
286
|
return;
|
|
287
287
|
const a = await Ge();
|
|
288
|
-
if (e !==
|
|
288
|
+
if (e !== T) {
|
|
289
289
|
a?.getTracks?.().forEach((l) => l.stop());
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
292
|
if (a && n.value) {
|
|
293
|
-
|
|
293
|
+
ce = 0, n.value.srcObject = a, n.value.muted = !0;
|
|
294
294
|
try {
|
|
295
295
|
await n.value.play?.();
|
|
296
296
|
} catch {
|
|
297
297
|
}
|
|
298
298
|
qe(e);
|
|
299
299
|
} else if (!a && c.value) {
|
|
300
|
-
|
|
300
|
+
ce < Ze && (ce++, await ue(600), e === T && await U());
|
|
301
301
|
return;
|
|
302
302
|
}
|
|
303
303
|
return W.value = await navigator.mediaDevices.enumerateDevices(), { stream: n.value && n.value.srcObject, devices: W.value };
|
|
304
304
|
}
|
|
305
305
|
function Ke() {
|
|
306
|
-
|
|
306
|
+
O.value ? (O.value = !1, K.value = !1, Y()) : (O.value = !0, U());
|
|
307
307
|
}
|
|
308
308
|
function Xe() {
|
|
309
309
|
c.value = void 0, j.value = j.value === "user" ? "environment" : "user", U();
|
|
@@ -311,25 +311,25 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
311
311
|
async function ke(e, t) {
|
|
312
312
|
e && (!t || e.deviceId !== t.deviceId) && await U();
|
|
313
313
|
}
|
|
314
|
-
Ie(() => c.value, ke), Ie(() =>
|
|
315
|
-
function
|
|
316
|
-
r.countdown ? (k.value = k.value ? k.value - 1 : r.countdown, k.value ? setTimeout(
|
|
314
|
+
Ie(() => c.value, ke), Ie(() => R.value, ke);
|
|
315
|
+
function de() {
|
|
316
|
+
r.countdown ? (k.value = k.value ? k.value - 1 : r.countdown, k.value ? setTimeout(de, 1e3) : De()) : De();
|
|
317
317
|
}
|
|
318
|
-
Le({ onCapture:
|
|
318
|
+
Le({ onCapture: de, enableMotion: re, camera: n.value, zoom: d });
|
|
319
319
|
function Je() {
|
|
320
|
-
if (!r.correctOrientation ||
|
|
321
|
-
const e = ((
|
|
320
|
+
if (!r.correctOrientation || ie.value == null) return 0;
|
|
321
|
+
const e = ((ie.value - 180) % 360 + 360) % 360;
|
|
322
322
|
return (-1 * (Math.round(e / 90) * 90 % 360) % 360 + 360) % 360;
|
|
323
323
|
}
|
|
324
|
-
function Qe(e, t, a, l,
|
|
325
|
-
const
|
|
326
|
-
e.translate(
|
|
327
|
-
const s = i, v =
|
|
324
|
+
function Qe(e, t, a, l, m) {
|
|
325
|
+
const f = o.value.width, i = o.value.height;
|
|
326
|
+
e.translate(f / 2, i / 2), H.value && e.scale(-1, 1), e.rotate(a * Math.PI / 180);
|
|
327
|
+
const s = i, v = f, C = Math.max(s / l, v / m) * (d.value && d.value > 0 ? d.value : 1), F = l * C, S = m * C;
|
|
328
328
|
e.drawImage(t, -F / 2, -S / 2, F, S);
|
|
329
329
|
}
|
|
330
330
|
function De() {
|
|
331
331
|
K.value = !0;
|
|
332
|
-
const e = o.value.getContext("2d"), t = n.value, a = t && t.srcObject && t.srcObject.getTracks(), { aspectRatio: l, width:
|
|
332
|
+
const e = o.value.getContext("2d"), t = n.value, a = t && t.srcObject && t.srcObject.getTracks(), { aspectRatio: l, width: m, height: f } = a.length && a[0].getSettings(), i = t?.videoWidth || m || X.value, s = t?.videoHeight || f || J.value, v = i && s ? i / s : l, A = L.value || { width: i, height: s }, C = A?.width || i, F = M.value ? A?.height || s : Math.round(C / v), S = C / F;
|
|
333
333
|
if (o.value.width = C, o.value.height = F, !i || !s || !v)
|
|
334
334
|
return;
|
|
335
335
|
const te = Je();
|
|
@@ -337,17 +337,17 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
337
337
|
Qe(e, t, te, i, s), e.restore(), Ee(e, o.value.width, o.value.height), Me(o.value.toDataURL("image/png"));
|
|
338
338
|
return;
|
|
339
339
|
}
|
|
340
|
-
if (te === 180 && (e.translate(o.value.width, o.value.height), e.scale(-1, -1)),
|
|
341
|
-
let _ = 0, x = 0,
|
|
342
|
-
if (v > S ? (
|
|
343
|
-
const q =
|
|
344
|
-
_ += (
|
|
340
|
+
if (te === 180 && (e.translate(o.value.width, o.value.height), e.scale(-1, -1)), H.value && (e.translate(o.value.width, 0), e.scale(-1, 1)), r.enableCropImage) {
|
|
341
|
+
let _ = 0, x = 0, g = i, E = s;
|
|
342
|
+
if (v > S ? (g = s * S, _ = (i - g) / 2) : v < S && (E = i / S, x = (s - E) / 2), d.value && d.value !== 1) {
|
|
343
|
+
const q = g / d.value, Z = E / d.value;
|
|
344
|
+
_ += (g - q) / 2, x += (E - Z) / 2, g = q, E = Z;
|
|
345
345
|
}
|
|
346
346
|
e.drawImage(
|
|
347
347
|
t,
|
|
348
348
|
_,
|
|
349
349
|
x,
|
|
350
|
-
|
|
350
|
+
g,
|
|
351
351
|
E,
|
|
352
352
|
0,
|
|
353
353
|
0,
|
|
@@ -355,28 +355,28 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
355
355
|
o.value.height
|
|
356
356
|
);
|
|
357
357
|
} else {
|
|
358
|
-
let _ = o.value.width, x = o.value.height,
|
|
359
|
-
if (v > S ? (x = o.value.width / v, E = (o.value.height - x) / 2) : v < S && (_ = o.value.height * v,
|
|
358
|
+
let _ = o.value.width, x = o.value.height, g = 0, E = 0;
|
|
359
|
+
if (v > S ? (x = o.value.width / v, E = (o.value.height - x) / 2) : v < S && (_ = o.value.height * v, g = (o.value.width - _) / 2), d.value && d.value !== 1) {
|
|
360
360
|
const q = i / d.value, Z = s / d.value, et = (i - q) / 2, tt = (s - Z) / 2;
|
|
361
|
-
|
|
361
|
+
H.value && (g = o.value.width - g - _), e.drawImage(
|
|
362
362
|
t,
|
|
363
363
|
et,
|
|
364
364
|
tt,
|
|
365
365
|
q,
|
|
366
366
|
Z,
|
|
367
|
-
|
|
367
|
+
g,
|
|
368
368
|
E,
|
|
369
369
|
_,
|
|
370
370
|
x
|
|
371
371
|
);
|
|
372
372
|
} else
|
|
373
|
-
|
|
373
|
+
H.value && (g = o.value.width - g - _), e.drawImage(
|
|
374
374
|
t,
|
|
375
375
|
0,
|
|
376
376
|
0,
|
|
377
377
|
i,
|
|
378
378
|
s,
|
|
379
|
-
|
|
379
|
+
g,
|
|
380
380
|
E,
|
|
381
381
|
_,
|
|
382
382
|
x
|
|
@@ -387,7 +387,7 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
387
387
|
Me(Ye);
|
|
388
388
|
}
|
|
389
389
|
function Me(e) {
|
|
390
|
-
const t =
|
|
390
|
+
const t = vt(e);
|
|
391
391
|
Ae("update:modelValue", {
|
|
392
392
|
name: `cam-pic-${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
393
393
|
id: `cam-pic-${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
@@ -396,135 +396,134 @@ const wt = { class: "camera__preview" }, pt = {
|
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
return it(async () => {
|
|
399
|
-
await U(),
|
|
399
|
+
await U(), O.value = !0, j.value = r.defaultRearCamera ? "environment" : "user";
|
|
400
400
|
const e = r.defaultRearCamera && I.value.length > 1 ? I.value[I.value.length - 1] : I.value[0];
|
|
401
|
-
if (c.value = e, r.enableAudio && (
|
|
401
|
+
if (c.value = e, r.enableAudio && (R.value = ye.value[0]), navigator.mediaDevices.addEventListener("devicechange", async (t) => {
|
|
402
402
|
await U();
|
|
403
403
|
}), window.addEventListener("resize", Se), Ce(), we.value) {
|
|
404
404
|
$ = setTimeout(Q, 3e3);
|
|
405
405
|
const t = window.DeviceOrientationEvent;
|
|
406
|
-
t && typeof t.requestPermission == "function" ? Ve() :
|
|
406
|
+
t && typeof t.requestPermission == "function" ? Ve() : re();
|
|
407
407
|
}
|
|
408
408
|
await nt(), fe.value = !0;
|
|
409
409
|
}), ot(() => {
|
|
410
|
-
|
|
410
|
+
O.value = !1, K.value = !1, B(), Y(), window.removeEventListener("resize", Se), window.removeEventListener("devicemotion", pe, !0), $ && clearTimeout($), le();
|
|
411
411
|
}), (e, t) => (y(), b("div", {
|
|
412
|
-
class:
|
|
412
|
+
class: ve(["camera", je.value])
|
|
413
413
|
}, [
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
w("div", gt, [
|
|
415
|
+
oe.value ? z("", !0) : (y(), b("div", wt, [
|
|
416
|
+
ae(ut, { color: "#000" }, {
|
|
417
417
|
default: lt(() => [
|
|
418
|
-
|
|
419
|
-
class:
|
|
418
|
+
w("span", {
|
|
419
|
+
class: ve("d-block text-center"),
|
|
420
420
|
innerHTML: e.$t("camera.waitForCameraNotification")
|
|
421
|
-
}, null, 8,
|
|
421
|
+
}, null, 8, pt)
|
|
422
422
|
]),
|
|
423
423
|
_: 1
|
|
424
424
|
})
|
|
425
425
|
])),
|
|
426
|
-
xe(
|
|
427
|
-
class:
|
|
428
|
-
style: he({ aspectRatio:
|
|
426
|
+
xe(w("div", {
|
|
427
|
+
class: ve(["camera__video-wrapper", M.value ? `aspect-ratio--${M.value}` : ""]),
|
|
428
|
+
style: he({ aspectRatio: Be.value || void 0, transform: d.value !== 1 ? `scale(${d.value})` : void 0 })
|
|
429
429
|
}, [
|
|
430
|
-
|
|
430
|
+
w("video", {
|
|
431
431
|
ref_key: "camera",
|
|
432
432
|
ref: n,
|
|
433
433
|
class: "camera__video",
|
|
434
434
|
style: he({
|
|
435
435
|
filter: r.filter === "grayscale" ? "grayscale(100%)" : r.filter === "sepia" ? "sepia(100%)" : "none",
|
|
436
|
-
transform:
|
|
436
|
+
transform: p.correctOrientation && V.value ? "rotate(180deg)" : void 0
|
|
437
437
|
}),
|
|
438
438
|
autoplay: "",
|
|
439
439
|
muted: "",
|
|
440
440
|
playsinline: ""
|
|
441
441
|
}, null, 4),
|
|
442
|
-
|
|
442
|
+
p.tintColor ? (y(), b("div", {
|
|
443
443
|
key: 0,
|
|
444
444
|
class: "camera__tint-overlay",
|
|
445
445
|
style: he({
|
|
446
|
-
backgroundColor:
|
|
447
|
-
opacity:
|
|
446
|
+
backgroundColor: p.tintColor,
|
|
447
|
+
opacity: p.tintIntensity,
|
|
448
448
|
mixBlendMode: "multiply"
|
|
449
449
|
})
|
|
450
|
-
}, null, 4)) :
|
|
450
|
+
}, null, 4)) : z("", !0)
|
|
451
451
|
], 6), [
|
|
452
|
-
[Re,
|
|
452
|
+
[Re, oe.value]
|
|
453
453
|
]),
|
|
454
|
-
xe(
|
|
454
|
+
xe(w("canvas", {
|
|
455
455
|
ref_key: "canvas",
|
|
456
456
|
ref: o,
|
|
457
457
|
class: "camera__canvas",
|
|
458
458
|
width: X.value,
|
|
459
459
|
height: J.value
|
|
460
|
-
}, null, 8,
|
|
460
|
+
}, null, 8, yt), [
|
|
461
461
|
[Re, K.value]
|
|
462
462
|
]),
|
|
463
|
-
k.value ? (y(), b("div",
|
|
463
|
+
k.value ? (y(), b("div", bt, [
|
|
464
464
|
(y(), b("p", {
|
|
465
465
|
class: "countdown",
|
|
466
466
|
key: k.value,
|
|
467
467
|
innerHTML: k.value,
|
|
468
468
|
"data-countdown": k.value
|
|
469
|
-
}, null, 8,
|
|
470
|
-
])) :
|
|
471
|
-
|
|
469
|
+
}, null, 8, _t))
|
|
470
|
+
])) : z("", !0),
|
|
471
|
+
p.enableGuide && O.value && oe.value ? (y(), b("img", {
|
|
472
472
|
key: 2,
|
|
473
473
|
class: "camera__guide",
|
|
474
|
-
src:
|
|
475
|
-
}, null, 8,
|
|
476
|
-
|
|
477
|
-
|
|
474
|
+
src: p.guideSrc
|
|
475
|
+
}, null, 8, Et)) : z("", !0),
|
|
476
|
+
p.enableZoomSlider ? (y(), b("div", Ct, [
|
|
477
|
+
ae(mt, {
|
|
478
478
|
modelValue: d.value,
|
|
479
479
|
"onUpdate:modelValue": t[0] || (t[0] = (a) => d.value = a)
|
|
480
480
|
}, null, 8, ["modelValue"])
|
|
481
|
-
])) :
|
|
481
|
+
])) : z("", !0)
|
|
482
482
|
]),
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
483
|
+
w("div", St, [
|
|
484
|
+
w("div", kt, [
|
|
485
|
+
w("div", Dt, [
|
|
486
|
+
w("div", Mt, [
|
|
487
|
+
w("div", It, [
|
|
488
|
+
w("button", {
|
|
489
489
|
type: "button",
|
|
490
490
|
class: "camera__toggle btn btn-primary",
|
|
491
491
|
onClick: Ke
|
|
492
492
|
}, [
|
|
493
|
-
|
|
493
|
+
O.value ? (y(), b("span", Rt, me(e.$t("common.pause")), 1)) : (y(), b("span", xt, me(e.$t("common.play")), 1))
|
|
494
494
|
]),
|
|
495
|
-
|
|
495
|
+
w("button", {
|
|
496
496
|
type: "button",
|
|
497
497
|
class: "camera__capture btn btn-primary",
|
|
498
|
-
onClick:
|
|
498
|
+
onClick: de
|
|
499
499
|
}, me(e.$t("camera.capture")), 1)
|
|
500
500
|
])
|
|
501
501
|
])
|
|
502
502
|
])
|
|
503
503
|
])
|
|
504
504
|
]),
|
|
505
|
-
(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
key: 0,
|
|
505
|
+
(p.enableSwitchCamera || p.enableSelectDevice) && se.value && se.value.length > 1 ? (y(), b("div", Ot, [
|
|
506
|
+
w("div", Lt, [
|
|
507
|
+
ae(dt, {
|
|
509
508
|
modelValue: _e.value,
|
|
510
509
|
"onUpdate:modelValue": t[1] || (t[1] = (a) => _e.value = a),
|
|
511
510
|
options: We.value,
|
|
512
511
|
class: "w-100"
|
|
513
|
-
}, null, 8, ["modelValue", "options"])
|
|
512
|
+
}, null, 8, ["modelValue", "options"])
|
|
514
513
|
]),
|
|
515
|
-
|
|
516
|
-
|
|
514
|
+
w("div", Tt, [
|
|
515
|
+
p.enableSwitchCamera ? (y(), b("button", {
|
|
517
516
|
key: 0,
|
|
518
517
|
class: "btn",
|
|
519
|
-
onClick:
|
|
518
|
+
onClick: rt(Xe, ["prevent"])
|
|
520
519
|
}, [
|
|
521
|
-
|
|
522
|
-
])) :
|
|
520
|
+
ae(ct, { symbol: "switch-camera" })
|
|
521
|
+
])) : z("", !0)
|
|
523
522
|
])
|
|
524
|
-
])) :
|
|
523
|
+
])) : z("", !0)
|
|
525
524
|
], 2));
|
|
526
525
|
}
|
|
527
526
|
});
|
|
528
527
|
export {
|
|
529
|
-
|
|
528
|
+
Kt as default
|
|
530
529
|
};
|