sm-click-library-ui 0.0.390 → 0.0.393

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.
@@ -0,0 +1,732 @@
1
+ import { r as le, C as ge, W as me } from "./index-pIuAt61H.js";
2
+ const F = {
3
+ RECORDING: "RECORDING",
4
+ PAUSED: "PAUSED",
5
+ NONE: "NONE"
6
+ };
7
+ function we(n) {
8
+ n.CapacitorUtils.Synapse = new Proxy(
9
+ {},
10
+ {
11
+ get(i, a) {
12
+ return new Proxy({}, {
13
+ get(p, d) {
14
+ return (l, c, f) => {
15
+ const s = n.Capacitor.Plugins[a];
16
+ if (s === void 0) {
17
+ f(new Error(`Capacitor plugin ${a} not found`));
18
+ return;
19
+ }
20
+ if (typeof s[d] != "function") {
21
+ f(new Error(`Method ${d} not found in Capacitor plugin ${a}`));
22
+ return;
23
+ }
24
+ (async () => {
25
+ try {
26
+ const v = await s[d](l);
27
+ c(v);
28
+ } catch (v) {
29
+ f(v);
30
+ }
31
+ })();
32
+ };
33
+ }
34
+ });
35
+ }
36
+ }
37
+ );
38
+ }
39
+ function Re(n) {
40
+ n.CapacitorUtils.Synapse = new Proxy(
41
+ {},
42
+ {
43
+ get(i, a) {
44
+ return n.cordova.plugins[a];
45
+ }
46
+ }
47
+ );
48
+ }
49
+ function ye(n = !1) {
50
+ typeof window > "u" || (window.CapacitorUtils = window.CapacitorUtils || {}, window.Capacitor !== void 0 && !n ? we(window) : window.cordova !== void 0 && Re(window));
51
+ }
52
+ var re;
53
+ (function(n) {
54
+ n.Documents = "DOCUMENTS", n.Data = "DATA", n.Library = "LIBRARY", n.Cache = "CACHE", n.External = "EXTERNAL", n.ExternalStorage = "EXTERNAL_STORAGE", n.ExternalCache = "EXTERNAL_CACHE", n.LibraryNoCloud = "LIBRARY_NO_CLOUD", n.Temporary = "TEMPORARY";
55
+ })(re || (re = {}));
56
+ var te;
57
+ (function(n) {
58
+ n.UTF8 = "utf8", n.ASCII = "ascii", n.UTF16 = "utf16";
59
+ })(te || (te = {}));
60
+ const k = le("Filesystem", {
61
+ web: () => import("./web-s6lFS2jx.js").then((n) => new n.FilesystemWeb())
62
+ });
63
+ ye();
64
+ const Ee = le("BlobWriter");
65
+ function _e(n) {
66
+ return window.btoa(
67
+ Array.from(new Uint8Array(n)).map(function(i) {
68
+ return String.fromCharCode(i);
69
+ }).join("")
70
+ );
71
+ }
72
+ function be({
73
+ path: n,
74
+ directory: i,
75
+ blob: a,
76
+ recursive: p
77
+ }) {
78
+ return k.writeFile({
79
+ directory: i,
80
+ path: n,
81
+ recursive: p,
82
+ data: ""
83
+ }).then(function() {
84
+ return new Promise(function(d, l) {
85
+ function c(s) {
86
+ l(s.target.error);
87
+ }
88
+ const f = window.indexedDB.open("Disc");
89
+ f.onerror = c, f.onsuccess = function() {
90
+ const v = f.result.transaction("FileStorage", "readwrite");
91
+ v.onerror = c;
92
+ const g = v.objectStore("FileStorage"), m = `/${i}/${n.replace(/^\//, "")}`, _ = g.get(m);
93
+ _.onsuccess = function() {
94
+ _.result.size = a.size, _.result.content = a;
95
+ const P = g.put(_.result);
96
+ P.onsuccess = function() {
97
+ d(void 0);
98
+ };
99
+ };
100
+ };
101
+ });
102
+ });
103
+ }
104
+ function ne({
105
+ path: n,
106
+ directory: i,
107
+ blob: a,
108
+ recursive: p
109
+ }) {
110
+ return k.writeFile({
111
+ directory: i,
112
+ path: n,
113
+ recursive: p,
114
+ data: ""
115
+ }).then(function d() {
116
+ if (a.size === 0)
117
+ return Promise.resolve();
118
+ const l = 3 * 128 * 1024, c = a.slice(0, l);
119
+ return a = a.slice(l), new Response(
120
+ c
121
+ ).arrayBuffer().then(function(s) {
122
+ return k.appendFile({
123
+ directory: i,
124
+ path: n,
125
+ data: _e(s)
126
+ });
127
+ }).then(
128
+ d
129
+ );
130
+ });
131
+ }
132
+ function Se(n) {
133
+ const {
134
+ path: i,
135
+ directory: a,
136
+ blob: p,
137
+ fast_mode: d = !1,
138
+ recursive: l,
139
+ on_fallback: c
140
+ } = n;
141
+ return !p || !Number.isSafeInteger(p.size) || typeof p.type != "string" ? Promise.reject(new Error("Not a Blob.")) : ge.getPlatform() === "web" ? d ? be(n) : ne(n) : Promise.all([
142
+ Ee.get_config(),
143
+ k.getUri({ path: i, directory: a })
144
+ ]).then(function([f, s]) {
145
+ const v = s.uri.replace("file://", "");
146
+ return (window.CapacitorWebFetch || window.fetch)(
147
+ f.base_url + v + (l ? "?recursive=true" : ""),
148
+ {
149
+ headers: { authorization: f.auth_token },
150
+ method: "put",
151
+ body: p
152
+ }
153
+ ).then(function(m) {
154
+ if (m.status !== 204)
155
+ throw new Error("Bad HTTP status: " + m.status);
156
+ return s.uri;
157
+ });
158
+ }).catch(function(s) {
159
+ return c !== void 0 && c(s), ne(n);
160
+ });
161
+ }
162
+ const Pe = Object.freeze(Se);
163
+ function Oe(n) {
164
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
165
+ }
166
+ var fe = {};
167
+ function Te(n) {
168
+ return n && n.__esModule ? n : {
169
+ default: n
170
+ };
171
+ }
172
+ var Ne = Te, W = { exports: {} }, oe;
173
+ function Ce() {
174
+ return oe || (oe = 1, function(n) {
175
+ var i = function(a) {
176
+ var p = Object.prototype, d = p.hasOwnProperty, l = Object.defineProperty || function(r, e, t) {
177
+ r[e] = t.value;
178
+ }, c, f = typeof Symbol == "function" ? Symbol : {}, s = f.iterator || "@@iterator", v = f.asyncIterator || "@@asyncIterator", g = f.toStringTag || "@@toStringTag";
179
+ function m(r, e, t) {
180
+ return Object.defineProperty(r, e, {
181
+ value: t,
182
+ enumerable: !0,
183
+ configurable: !0,
184
+ writable: !0
185
+ }), r[e];
186
+ }
187
+ try {
188
+ m({}, "");
189
+ } catch {
190
+ m = function(e, t, u) {
191
+ return e[t] = u;
192
+ };
193
+ }
194
+ function _(r, e, t, u) {
195
+ var o = e && e.prototype instanceof U ? e : U, h = Object.create(o.prototype), w = new $(u || []);
196
+ return l(h, "_invoke", { value: pe(r, t, w) }), h;
197
+ }
198
+ a.wrap = _;
199
+ function P(r, e, t) {
200
+ try {
201
+ return { type: "normal", arg: r.call(e, t) };
202
+ } catch (u) {
203
+ return { type: "throw", arg: u };
204
+ }
205
+ }
206
+ var x = "suspendedStart", he = "suspendedYield", J = "executing", A = "completed", b = {};
207
+ function U() {
208
+ }
209
+ function I() {
210
+ }
211
+ function T() {
212
+ }
213
+ var j = {};
214
+ m(j, s, function() {
215
+ return this;
216
+ });
217
+ var B = Object.getPrototypeOf, G = B && B(B(Y([])));
218
+ G && G !== p && d.call(G, s) && (j = G);
219
+ var C = T.prototype = U.prototype = Object.create(j);
220
+ I.prototype = T, l(C, "constructor", { value: T, configurable: !0 }), l(
221
+ T,
222
+ "constructor",
223
+ { value: I, configurable: !0 }
224
+ ), I.displayName = m(
225
+ T,
226
+ g,
227
+ "GeneratorFunction"
228
+ );
229
+ function K(r) {
230
+ ["next", "throw", "return"].forEach(function(e) {
231
+ m(r, e, function(t) {
232
+ return this._invoke(e, t);
233
+ });
234
+ });
235
+ }
236
+ a.isGeneratorFunction = function(r) {
237
+ var e = typeof r == "function" && r.constructor;
238
+ return e ? e === I || // For the native GeneratorFunction constructor, the best we can
239
+ // do is to check its .name property.
240
+ (e.displayName || e.name) === "GeneratorFunction" : !1;
241
+ }, a.mark = function(r) {
242
+ return Object.setPrototypeOf ? Object.setPrototypeOf(r, T) : (r.__proto__ = T, m(r, g, "GeneratorFunction")), r.prototype = Object.create(C), r;
243
+ }, a.awrap = function(r) {
244
+ return { __await: r };
245
+ };
246
+ function M(r, e) {
247
+ function t(h, w, R, E) {
248
+ var y = P(r[h], r, w);
249
+ if (y.type === "throw")
250
+ E(y.arg);
251
+ else {
252
+ var z = y.arg, D = z.value;
253
+ return D && typeof D == "object" && d.call(D, "__await") ? e.resolve(D.__await).then(function(N) {
254
+ t("next", N, R, E);
255
+ }, function(N) {
256
+ t("throw", N, R, E);
257
+ }) : e.resolve(D).then(function(N) {
258
+ z.value = N, R(z);
259
+ }, function(N) {
260
+ return t("throw", N, R, E);
261
+ });
262
+ }
263
+ }
264
+ var u;
265
+ function o(h, w) {
266
+ function R() {
267
+ return new e(function(E, y) {
268
+ t(h, w, E, y);
269
+ });
270
+ }
271
+ return u = // If enqueue has been called before, then we want to wait until
272
+ // all previous Promises have been resolved before calling invoke,
273
+ // so that results are always delivered in the correct order. If
274
+ // enqueue has not been called before, then it is important to
275
+ // call invoke immediately, without waiting on a callback to fire,
276
+ // so that the async generator function has the opportunity to do
277
+ // any necessary setup in a predictable way. This predictability
278
+ // is why the Promise constructor synchronously invokes its
279
+ // executor callback, and why async functions synchronously
280
+ // execute code before the first await. Since we implement simple
281
+ // async functions in terms of async generators, it is especially
282
+ // important to get this right, even though it requires care.
283
+ u ? u.then(
284
+ R,
285
+ // Avoid propagating failures to Promises returned by later
286
+ // invocations of the iterator.
287
+ R
288
+ ) : R();
289
+ }
290
+ l(this, "_invoke", { value: o });
291
+ }
292
+ K(M.prototype), m(M.prototype, v, function() {
293
+ return this;
294
+ }), a.AsyncIterator = M, a.async = function(r, e, t, u, o) {
295
+ o === void 0 && (o = Promise);
296
+ var h = new M(
297
+ _(r, e, t, u),
298
+ o
299
+ );
300
+ return a.isGeneratorFunction(e) ? h : h.next().then(function(w) {
301
+ return w.done ? w.value : h.next();
302
+ });
303
+ };
304
+ function pe(r, e, t) {
305
+ var u = x;
306
+ return function(h, w) {
307
+ if (u === J)
308
+ throw new Error("Generator is already running");
309
+ if (u === A) {
310
+ if (h === "throw")
311
+ throw w;
312
+ return ee();
313
+ }
314
+ for (t.method = h, t.arg = w; ; ) {
315
+ var R = t.delegate;
316
+ if (R) {
317
+ var E = Z(R, t);
318
+ if (E) {
319
+ if (E === b) continue;
320
+ return E;
321
+ }
322
+ }
323
+ if (t.method === "next")
324
+ t.sent = t._sent = t.arg;
325
+ else if (t.method === "throw") {
326
+ if (u === x)
327
+ throw u = A, t.arg;
328
+ t.dispatchException(t.arg);
329
+ } else t.method === "return" && t.abrupt("return", t.arg);
330
+ u = J;
331
+ var y = P(r, e, t);
332
+ if (y.type === "normal") {
333
+ if (u = t.done ? A : he, y.arg === b)
334
+ continue;
335
+ return {
336
+ value: y.arg,
337
+ done: t.done
338
+ };
339
+ } else y.type === "throw" && (u = A, t.method = "throw", t.arg = y.arg);
340
+ }
341
+ };
342
+ }
343
+ function Z(r, e) {
344
+ var t = e.method, u = r.iterator[t];
345
+ if (u === c)
346
+ return e.delegate = null, t === "throw" && r.iterator.return && (e.method = "return", e.arg = c, Z(r, e), e.method === "throw") || t !== "return" && (e.method = "throw", e.arg = new TypeError(
347
+ "The iterator does not provide a '" + t + "' method"
348
+ )), b;
349
+ var o = P(u, r.iterator, e.arg);
350
+ if (o.type === "throw")
351
+ return e.method = "throw", e.arg = o.arg, e.delegate = null, b;
352
+ var h = o.arg;
353
+ if (!h)
354
+ return e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, b;
355
+ if (h.done)
356
+ e[r.resultName] = h.value, e.next = r.nextLoc, e.method !== "return" && (e.method = "next", e.arg = c);
357
+ else
358
+ return h;
359
+ return e.delegate = null, b;
360
+ }
361
+ K(C), m(C, g, "Generator"), m(C, s, function() {
362
+ return this;
363
+ }), m(C, "toString", function() {
364
+ return "[object Generator]";
365
+ });
366
+ function ve(r) {
367
+ var e = { tryLoc: r[0] };
368
+ 1 in r && (e.catchLoc = r[1]), 2 in r && (e.finallyLoc = r[2], e.afterLoc = r[3]), this.tryEntries.push(e);
369
+ }
370
+ function q(r) {
371
+ var e = r.completion || {};
372
+ e.type = "normal", delete e.arg, r.completion = e;
373
+ }
374
+ function $(r) {
375
+ this.tryEntries = [{ tryLoc: "root" }], r.forEach(ve, this), this.reset(!0);
376
+ }
377
+ a.keys = function(r) {
378
+ var e = Object(r), t = [];
379
+ for (var u in e)
380
+ t.push(u);
381
+ return t.reverse(), function o() {
382
+ for (; t.length; ) {
383
+ var h = t.pop();
384
+ if (h in e)
385
+ return o.value = h, o.done = !1, o;
386
+ }
387
+ return o.done = !0, o;
388
+ };
389
+ };
390
+ function Y(r) {
391
+ if (r) {
392
+ var e = r[s];
393
+ if (e)
394
+ return e.call(r);
395
+ if (typeof r.next == "function")
396
+ return r;
397
+ if (!isNaN(r.length)) {
398
+ var t = -1, u = function o() {
399
+ for (; ++t < r.length; )
400
+ if (d.call(r, t))
401
+ return o.value = r[t], o.done = !1, o;
402
+ return o.value = c, o.done = !0, o;
403
+ };
404
+ return u.next = u;
405
+ }
406
+ }
407
+ return { next: ee };
408
+ }
409
+ a.values = Y;
410
+ function ee() {
411
+ return { value: c, done: !0 };
412
+ }
413
+ return $.prototype = {
414
+ constructor: $,
415
+ reset: function(r) {
416
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = c, this.done = !1, this.delegate = null, this.method = "next", this.arg = c, this.tryEntries.forEach(q), !r)
417
+ for (var e in this)
418
+ e.charAt(0) === "t" && d.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = c);
419
+ },
420
+ stop: function() {
421
+ this.done = !0;
422
+ var r = this.tryEntries[0], e = r.completion;
423
+ if (e.type === "throw")
424
+ throw e.arg;
425
+ return this.rval;
426
+ },
427
+ dispatchException: function(r) {
428
+ if (this.done)
429
+ throw r;
430
+ var e = this;
431
+ function t(E, y) {
432
+ return h.type = "throw", h.arg = r, e.next = E, y && (e.method = "next", e.arg = c), !!y;
433
+ }
434
+ for (var u = this.tryEntries.length - 1; u >= 0; --u) {
435
+ var o = this.tryEntries[u], h = o.completion;
436
+ if (o.tryLoc === "root")
437
+ return t("end");
438
+ if (o.tryLoc <= this.prev) {
439
+ var w = d.call(o, "catchLoc"), R = d.call(o, "finallyLoc");
440
+ if (w && R) {
441
+ if (this.prev < o.catchLoc)
442
+ return t(o.catchLoc, !0);
443
+ if (this.prev < o.finallyLoc)
444
+ return t(o.finallyLoc);
445
+ } else if (w) {
446
+ if (this.prev < o.catchLoc)
447
+ return t(o.catchLoc, !0);
448
+ } else if (R) {
449
+ if (this.prev < o.finallyLoc)
450
+ return t(o.finallyLoc);
451
+ } else
452
+ throw new Error("try statement without catch or finally");
453
+ }
454
+ }
455
+ },
456
+ abrupt: function(r, e) {
457
+ for (var t = this.tryEntries.length - 1; t >= 0; --t) {
458
+ var u = this.tryEntries[t];
459
+ if (u.tryLoc <= this.prev && d.call(u, "finallyLoc") && this.prev < u.finallyLoc) {
460
+ var o = u;
461
+ break;
462
+ }
463
+ }
464
+ o && (r === "break" || r === "continue") && o.tryLoc <= e && e <= o.finallyLoc && (o = null);
465
+ var h = o ? o.completion : {};
466
+ return h.type = r, h.arg = e, o ? (this.method = "next", this.next = o.finallyLoc, b) : this.complete(h);
467
+ },
468
+ complete: function(r, e) {
469
+ if (r.type === "throw")
470
+ throw r.arg;
471
+ return r.type === "break" || r.type === "continue" ? this.next = r.arg : r.type === "return" ? (this.rval = this.arg = r.arg, this.method = "return", this.next = "end") : r.type === "normal" && e && (this.next = e), b;
472
+ },
473
+ finish: function(r) {
474
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
475
+ var t = this.tryEntries[e];
476
+ if (t.finallyLoc === r)
477
+ return this.complete(t.completion, t.afterLoc), q(t), b;
478
+ }
479
+ },
480
+ catch: function(r) {
481
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
482
+ var t = this.tryEntries[e];
483
+ if (t.tryLoc === r) {
484
+ var u = t.completion;
485
+ if (u.type === "throw") {
486
+ var o = u.arg;
487
+ q(t);
488
+ }
489
+ return o;
490
+ }
491
+ }
492
+ throw new Error("illegal catch attempt");
493
+ },
494
+ delegateYield: function(r, e, t) {
495
+ return this.delegate = {
496
+ iterator: Y(r),
497
+ resultName: e,
498
+ nextLoc: t
499
+ }, this.method === "next" && (this.arg = c), b;
500
+ }
501
+ }, a;
502
+ }(
503
+ // If this script is executing as a CommonJS module, use module.exports
504
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
505
+ // object. Either way, the resulting object will be used to initialize
506
+ // the regeneratorRuntime variable at the top of this file.
507
+ n.exports
508
+ );
509
+ try {
510
+ regeneratorRuntime = i;
511
+ } catch {
512
+ typeof globalThis == "object" ? globalThis.regeneratorRuntime = i : Function("r", "regeneratorRuntime = r")(i);
513
+ }
514
+ }(W)), W.exports;
515
+ }
516
+ var H, ie;
517
+ function De() {
518
+ return ie || (ie = 1, H = Ce()), H;
519
+ }
520
+ var V, ae;
521
+ function Le() {
522
+ if (ae) return V;
523
+ ae = 1;
524
+ function n(a, p, d, l, c, f, s) {
525
+ try {
526
+ var v = a[f](s), g = v.value;
527
+ } catch (m) {
528
+ d(m);
529
+ return;
530
+ }
531
+ v.done ? p(g) : Promise.resolve(g).then(l, c);
532
+ }
533
+ function i(a) {
534
+ return function() {
535
+ var p = this, d = arguments;
536
+ return new Promise(function(l, c) {
537
+ var f = a.apply(p, d);
538
+ function s(g) {
539
+ n(f, l, c, s, v, "next", g);
540
+ }
541
+ function v(g) {
542
+ n(f, l, c, s, v, "throw", g);
543
+ }
544
+ s(void 0);
545
+ });
546
+ };
547
+ }
548
+ return V = i, V;
549
+ }
550
+ (function(n) {
551
+ var i = Ne;
552
+ Object.defineProperty(n, "__esModule", { value: !0 }), n.default = d;
553
+ var a = i(De()), p = i(Le());
554
+ function d(c) {
555
+ return l.apply(this, arguments);
556
+ }
557
+ function l() {
558
+ return (l = (0, p.default)(a.default.mark(function c(f) {
559
+ var s, v;
560
+ return a.default.wrap(function(g) {
561
+ for (; ; ) switch (g.prev = g.next) {
562
+ case 0:
563
+ return s = document.createElement("video"), v = new Promise(function(m, _) {
564
+ s.addEventListener("loadedmetadata", function() {
565
+ s.duration === 1 / 0 ? (s.currentTime = Number.MAX_SAFE_INTEGER, s.ontimeupdate = function() {
566
+ s.ontimeupdate = null, m(s.duration), s.currentTime = 0;
567
+ }) : m(s.duration);
568
+ }), s.onerror = function(P) {
569
+ return _(P.target.error);
570
+ };
571
+ }), s.src = typeof f == "string" || f instanceof String ? f : window.URL.createObjectURL(f), g.abrupt("return", v);
572
+ case 4:
573
+ case "end":
574
+ return g.stop();
575
+ }
576
+ }, c);
577
+ }))).apply(this, arguments);
578
+ }
579
+ })(fe);
580
+ const Ae = /* @__PURE__ */ Oe(fe), O = () => ({ value: !0 }), L = () => ({ value: !1 }), Ie = () => new Error("MISSING_PERMISSION"), Ge = () => new Error("ALREADY_RECORDING"), Me = () => new Error("DEVICE_CANNOT_VOICE_RECORD"), se = () => new Error("FAILED_TO_RECORD"), Fe = () => new Error("EMPTY_RECORDING"), X = () => new Error("RECORDING_HAS_NOT_STARTED"), ue = () => new Error("FAILED_TO_FETCH_RECORDING"), Q = () => new Error("COULD_NOT_QUERY_PERMISSION_STATUS"), ce = {
581
+ "audio/aac": ".aac",
582
+ "audio/mp4": ".mp3",
583
+ "audio/webm;codecs=opus": ".ogg",
584
+ "audio/webm": ".ogg",
585
+ "audio/ogg;codecs=opus": ".ogg"
586
+ }, de = () => new Promise(() => {
587
+ });
588
+ class S {
589
+ constructor() {
590
+ this.mediaRecorder = null, this.chunks = [], this.pendingResult = de();
591
+ }
592
+ static async canDeviceVoiceRecord() {
593
+ var i;
594
+ return ((i = navigator == null ? void 0 : navigator.mediaDevices) === null || i === void 0 ? void 0 : i.getUserMedia) == null || S.getSupportedMimeType() == null ? L() : O();
595
+ }
596
+ async startRecording(i) {
597
+ if (this.mediaRecorder != null)
598
+ throw Ge();
599
+ if (!(await S.canDeviceVoiceRecord()).value)
600
+ throw Me();
601
+ if (!(await S.hasAudioRecordingPermission().catch(() => O())).value)
602
+ throw Ie();
603
+ return navigator.mediaDevices.getUserMedia({ audio: !0 }).then((d) => this.onSuccessfullyStartedRecording(d, i)).catch(this.onFailedToStartRecording.bind(this));
604
+ }
605
+ async stopRecording() {
606
+ if (this.mediaRecorder == null)
607
+ throw X();
608
+ try {
609
+ return this.mediaRecorder.stop(), this.mediaRecorder.stream.getTracks().forEach((i) => i.stop()), this.pendingResult;
610
+ } catch {
611
+ throw ue();
612
+ } finally {
613
+ this.prepareInstanceForNextOperation();
614
+ }
615
+ }
616
+ static async hasAudioRecordingPermission() {
617
+ return navigator.permissions.query == null ? navigator.mediaDevices == null ? Promise.reject(Q()) : navigator.mediaDevices.getUserMedia({ audio: !0 }).then(() => O()).catch(() => {
618
+ throw Q();
619
+ }) : navigator.permissions.query({ name: "microphone" }).then((i) => ({ value: i.state === "granted" })).catch(() => {
620
+ throw Q();
621
+ });
622
+ }
623
+ static async requestAudioRecordingPermission() {
624
+ return (await S.hasAudioRecordingPermission().catch(() => L())).value ? O() : navigator.mediaDevices.getUserMedia({ audio: !0 }).then(() => O()).catch(() => L());
625
+ }
626
+ pauseRecording() {
627
+ if (this.mediaRecorder == null)
628
+ throw X();
629
+ return this.mediaRecorder.state === "recording" ? (this.mediaRecorder.pause(), Promise.resolve(O())) : Promise.resolve(L());
630
+ }
631
+ resumeRecording() {
632
+ if (this.mediaRecorder == null)
633
+ throw X();
634
+ return this.mediaRecorder.state === "paused" ? (this.mediaRecorder.resume(), Promise.resolve(O())) : Promise.resolve(L());
635
+ }
636
+ getCurrentStatus() {
637
+ return this.mediaRecorder == null ? Promise.resolve({ status: F.NONE }) : this.mediaRecorder.state === "recording" ? Promise.resolve({ status: F.RECORDING }) : this.mediaRecorder.state === "paused" ? Promise.resolve({ status: F.PAUSED }) : Promise.resolve({ status: F.NONE });
638
+ }
639
+ static getSupportedMimeType() {
640
+ if ((MediaRecorder == null ? void 0 : MediaRecorder.isTypeSupported) == null)
641
+ return null;
642
+ const i = Object.keys(ce).find((a) => MediaRecorder.isTypeSupported(a));
643
+ return i ?? null;
644
+ }
645
+ onSuccessfullyStartedRecording(i, a) {
646
+ return this.pendingResult = new Promise((p, d) => {
647
+ this.mediaRecorder = new MediaRecorder(i), this.mediaRecorder.onerror = () => {
648
+ this.prepareInstanceForNextOperation(), d(se());
649
+ }, this.mediaRecorder.onstop = async () => {
650
+ var l, c, f;
651
+ const s = S.getSupportedMimeType();
652
+ if (s == null) {
653
+ this.prepareInstanceForNextOperation(), d(ue());
654
+ return;
655
+ }
656
+ const v = new Blob(this.chunks, { type: s });
657
+ if (v.size <= 0) {
658
+ this.prepareInstanceForNextOperation(), d(Fe());
659
+ return;
660
+ }
661
+ let g, m;
662
+ a != null ? (g = `${(f = (c = (l = a.subDirectory) === null || l === void 0 ? void 0 : l.match(/^\/?(.+[^/])\/?$/)) === null || c === void 0 ? void 0 : c[1]) !== null && f !== void 0 ? f : ""}/recording-${(/* @__PURE__ */ new Date()).getTime()}${ce[s]}`, await Pe({
663
+ blob: v,
664
+ directory: a.directory,
665
+ fast_mode: !0,
666
+ path: g,
667
+ recursive: !0
668
+ })) : m = await S.blobToBase64(v);
669
+ const _ = await Ae(v);
670
+ this.prepareInstanceForNextOperation(), p({ value: { recordDataBase64: m, mimeType: s, msDuration: _ * 1e3, path: g } });
671
+ }, this.mediaRecorder.ondataavailable = (l) => this.chunks.push(l.data), this.mediaRecorder.start();
672
+ }), O();
673
+ }
674
+ onFailedToStartRecording() {
675
+ throw this.prepareInstanceForNextOperation(), se();
676
+ }
677
+ static blobToBase64(i) {
678
+ return new Promise((a) => {
679
+ const p = new FileReader();
680
+ p.onloadend = () => {
681
+ const d = String(p.result), l = d.split("base64,"), c = l.length > 1 ? l[1] : d;
682
+ a(c.trim());
683
+ }, p.readAsDataURL(i);
684
+ });
685
+ }
686
+ prepareInstanceForNextOperation() {
687
+ if (this.mediaRecorder != null && this.mediaRecorder.state === "recording")
688
+ try {
689
+ this.mediaRecorder.stop();
690
+ } catch (i) {
691
+ console.warn("While trying to stop a media recorder, an error was thrown", i);
692
+ }
693
+ this.pendingResult = de(), this.mediaRecorder = null, this.chunks = [];
694
+ }
695
+ }
696
+ class ke extends me {
697
+ constructor() {
698
+ super(...arguments), this.voiceRecorderInstance = new S();
699
+ }
700
+ canDeviceVoiceRecord() {
701
+ return S.canDeviceVoiceRecord();
702
+ }
703
+ hasAudioRecordingPermission() {
704
+ return S.hasAudioRecordingPermission();
705
+ }
706
+ requestAudioRecordingPermission() {
707
+ return S.requestAudioRecordingPermission();
708
+ }
709
+ startRecording(i) {
710
+ return this.voiceRecorderInstance.startRecording(i);
711
+ }
712
+ stopRecording() {
713
+ return this.voiceRecorderInstance.stopRecording();
714
+ }
715
+ pauseRecording() {
716
+ return this.voiceRecorderInstance.pauseRecording();
717
+ }
718
+ resumeRecording() {
719
+ return this.voiceRecorderInstance.resumeRecording();
720
+ }
721
+ getCurrentStatus() {
722
+ return this.voiceRecorderInstance.getCurrentStatus();
723
+ }
724
+ }
725
+ const je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
726
+ __proto__: null,
727
+ VoiceRecorderWeb: ke
728
+ }, Symbol.toStringTag, { value: "Module" }));
729
+ export {
730
+ te as E,
731
+ je as w
732
+ };