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