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