@untemps/react-vocal 2.0.0-beta.1 → 2.0.0-beta.10

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +54 -20
  3. package/dist/index.es.js +330 -1914
  4. package/dist/index.js +2 -4
  5. package/package.json +14 -7
  6. package/.github/workflows/publish.yml +0 -32
  7. package/.husky/commit-msg +0 -1
  8. package/.husky/pre-commit +0 -1
  9. package/.prettierignore +0 -3
  10. package/.prettierrc +0 -29
  11. package/CLAUDE.md +0 -59
  12. package/assets/icon-idle.png +0 -0
  13. package/assets/icon-listening.png +0 -0
  14. package/assets/microphone.png +0 -0
  15. package/assets/react-vocal.png +0 -0
  16. package/commitlint.config.js +0 -7
  17. package/dev/index.html +0 -24
  18. package/dev/package.json +0 -18
  19. package/dev/public/index.html +0 -24
  20. package/dev/src/index.jsx +0 -45
  21. package/dev/vite.config.js +0 -10
  22. package/dev/yarn.lock +0 -201
  23. package/dist/index.es.js.map +0 -1
  24. package/dist/index.js.map +0 -1
  25. package/dist/index.umd.js +0 -9
  26. package/dist/index.umd.js.map +0 -1
  27. package/src/components/Icon.jsx +0 -24
  28. package/src/components/Vocal.jsx +0 -168
  29. package/src/components/__tests__/Icon.test.jsx +0 -38
  30. package/src/components/__tests__/Vocal.test.jsx +0 -270
  31. package/src/components/__tests__/VocalWithMockedUseVocal.test.jsx +0 -38
  32. package/src/components/__tests__/__snapshots__/Icon.test.jsx.snap +0 -21
  33. package/src/components/__tests__/__snapshots__/Vocal.test.jsx.snap +0 -28
  34. package/src/hooks/__tests__/useCommands.test.js +0 -64
  35. package/src/hooks/__tests__/useTimeout.test.js +0 -69
  36. package/src/hooks/__tests__/useVocal.test.js +0 -197
  37. package/src/hooks/useCommands.js +0 -21
  38. package/src/hooks/useTimeout.js +0 -21
  39. package/src/hooks/useVocal.js +0 -56
  40. package/src/index.js +0 -7
  41. package/vite.config.js +0 -35
  42. package/vitest.setup.js +0 -71
package/dist/index.es.js CHANGED
@@ -1,663 +1,21 @@
1
- import { cloneElement as e, isValidElement as t, useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
1
+ import { cloneElement as e, isValidElement as t, useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
2
2
  //#region \0rolldown/runtime.js
3
- var o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
3
+ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), c = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
4
4
  if (typeof require < "u") return require.apply(this, arguments);
5
5
  throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
6
- }), c = function(e, t, n) {
7
- return e(n = {
8
- path: t,
9
- exports: {},
10
- require: function(e, t) {
11
- return function() {
12
- throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
13
- }(t == null && n.path);
14
- }
15
- }, n.exports), n.exports;
16
- }((function(e) {
17
- var t = function(e) {
18
- var t = Object.prototype, n = t.hasOwnProperty, r = typeof Symbol == "function" ? Symbol : {}, i = r.iterator || "@@iterator", a = r.asyncIterator || "@@asyncIterator", o = r.toStringTag || "@@toStringTag";
19
- function s(e, t, n) {
20
- return Object.defineProperty(e, t, {
21
- value: n,
22
- enumerable: !0,
23
- configurable: !0,
24
- writable: !0
25
- }), e[t];
26
- }
27
- try {
28
- s({}, "");
29
- } catch {
30
- s = function(e, t, n) {
31
- return e[t] = n;
32
- };
33
- }
34
- function c(e, t, n, r) {
35
- var i = t && t.prototype instanceof d ? t : d, a = Object.create(i.prototype);
36
- return a._invoke = function(e, t, n) {
37
- var r = "suspendedStart";
38
- return function(i, a) {
39
- if (r === "executing") throw Error("Generator is already running");
40
- if (r === "completed") {
41
- if (i === "throw") throw a;
42
- return T();
43
- }
44
- for (n.method = i, n.arg = a;;) {
45
- var o = n.delegate;
46
- if (o) {
47
- var s = b(o, n);
48
- if (s) {
49
- if (s === u) continue;
50
- return s;
51
- }
52
- }
53
- if (n.method === "next") n.sent = n._sent = n.arg;
54
- else if (n.method === "throw") {
55
- if (r === "suspendedStart") throw r = "completed", n.arg;
56
- n.dispatchException(n.arg);
57
- } else n.method === "return" && n.abrupt("return", n.arg);
58
- r = "executing";
59
- var c = l(e, t, n);
60
- if (c.type === "normal") {
61
- if (r = n.done ? "completed" : "suspendedYield", c.arg === u) continue;
62
- return {
63
- value: c.arg,
64
- done: n.done
65
- };
66
- }
67
- c.type === "throw" && (r = "completed", n.method = "throw", n.arg = c.arg);
68
- }
69
- };
70
- }(e, n, new C(r || [])), a;
71
- }
72
- function l(e, t, n) {
73
- try {
74
- return {
75
- type: "normal",
76
- arg: e.call(t, n)
77
- };
78
- } catch (e) {
79
- return {
80
- type: "throw",
81
- arg: e
82
- };
83
- }
84
- }
85
- e.wrap = c;
86
- var u = {};
87
- function d() {}
88
- function f() {}
89
- function p() {}
90
- var m = {};
91
- m[i] = function() {
92
- return this;
93
- };
94
- var h = Object.getPrototypeOf, g = h && h(h(w([])));
95
- g && g !== t && n.call(g, i) && (m = g);
96
- var _ = p.prototype = d.prototype = Object.create(m);
97
- function v(e) {
98
- [
99
- "next",
100
- "throw",
101
- "return"
102
- ].forEach((function(t) {
103
- s(e, t, (function(e) {
104
- return this._invoke(t, e);
105
- }));
106
- }));
107
- }
108
- function y(e, t) {
109
- var r;
110
- this._invoke = function(i, a) {
111
- function o() {
112
- return new t((function(r, o) {
113
- (function r(i, a, o, s) {
114
- var c = l(e[i], e, a);
115
- if (c.type !== "throw") {
116
- var u = c.arg, d = u.value;
117
- return d && typeof d == "object" && n.call(d, "__await") ? t.resolve(d.__await).then((function(e) {
118
- r("next", e, o, s);
119
- }), (function(e) {
120
- r("throw", e, o, s);
121
- })) : t.resolve(d).then((function(e) {
122
- u.value = e, o(u);
123
- }), (function(e) {
124
- return r("throw", e, o, s);
125
- }));
126
- }
127
- s(c.arg);
128
- })(i, a, r, o);
129
- }));
130
- }
131
- return r = r ? r.then(o, o) : o();
132
- };
133
- }
134
- function b(e, t) {
135
- var n = e.iterator[t.method];
136
- if (n === void 0) {
137
- if (t.delegate = null, t.method === "throw") {
138
- if (e.iterator.return && (t.method = "return", t.arg = void 0, b(e, t), t.method === "throw")) return u;
139
- t.method = "throw", t.arg = /* @__PURE__ */ TypeError("The iterator does not provide a 'throw' method");
140
- }
141
- return u;
142
- }
143
- var r = l(n, e.iterator, t.arg);
144
- if (r.type === "throw") return t.method = "throw", t.arg = r.arg, t.delegate = null, u;
145
- var i = r.arg;
146
- return i ? i.done ? (t[e.resultName] = i.value, t.next = e.nextLoc, t.method !== "return" && (t.method = "next", t.arg = void 0), t.delegate = null, u) : i : (t.method = "throw", t.arg = /* @__PURE__ */ TypeError("iterator result is not an object"), t.delegate = null, u);
147
- }
148
- function x(e) {
149
- var t = { tryLoc: e[0] };
150
- 1 in e && (t.catchLoc = e[1]), 2 in e && (t.finallyLoc = e[2], t.afterLoc = e[3]), this.tryEntries.push(t);
151
- }
152
- function S(e) {
153
- var t = e.completion || {};
154
- t.type = "normal", delete t.arg, e.completion = t;
155
- }
156
- function C(e) {
157
- this.tryEntries = [{ tryLoc: "root" }], e.forEach(x, this), this.reset(!0);
158
- }
159
- function w(e) {
160
- if (e) {
161
- var t = e[i];
162
- if (t) return t.call(e);
163
- if (typeof e.next == "function") return e;
164
- if (!isNaN(e.length)) {
165
- var r = -1, a = function t() {
166
- for (; ++r < e.length;) if (n.call(e, r)) return t.value = e[r], t.done = !1, t;
167
- return t.value = void 0, t.done = !0, t;
168
- };
169
- return a.next = a;
170
- }
171
- }
172
- return { next: T };
173
- }
174
- function T() {
175
- return {
176
- value: void 0,
177
- done: !0
178
- };
179
- }
180
- return f.prototype = _.constructor = p, p.constructor = f, f.displayName = s(p, o, "GeneratorFunction"), e.isGeneratorFunction = function(e) {
181
- var t = typeof e == "function" && e.constructor;
182
- return !!t && (t === f || (t.displayName || t.name) === "GeneratorFunction");
183
- }, e.mark = function(e) {
184
- return Object.setPrototypeOf ? Object.setPrototypeOf(e, p) : (e.__proto__ = p, s(e, o, "GeneratorFunction")), e.prototype = Object.create(_), e;
185
- }, e.awrap = function(e) {
186
- return { __await: e };
187
- }, v(y.prototype), y.prototype[a] = function() {
188
- return this;
189
- }, e.AsyncIterator = y, e.async = function(t, n, r, i, a) {
190
- a === void 0 && (a = Promise);
191
- var o = new y(c(t, n, r, i), a);
192
- return e.isGeneratorFunction(n) ? o : o.next().then((function(e) {
193
- return e.done ? e.value : o.next();
194
- }));
195
- }, v(_), s(_, o, "Generator"), _[i] = function() {
196
- return this;
197
- }, _.toString = function() {
198
- return "[object Generator]";
199
- }, e.keys = function(e) {
200
- var t = [];
201
- for (var n in e) t.push(n);
202
- return t.reverse(), function n() {
203
- for (; t.length;) {
204
- var r = t.pop();
205
- if (r in e) return n.value = r, n.done = !1, n;
206
- }
207
- return n.done = !0, n;
208
- };
209
- }, e.values = w, C.prototype = {
210
- constructor: C,
211
- reset: function(e) {
212
- if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(S), !e) for (var t in this) t.charAt(0) === "t" && n.call(this, t) && !isNaN(+t.slice(1)) && (this[t] = void 0);
213
- },
214
- stop: function() {
215
- this.done = !0;
216
- var e = this.tryEntries[0].completion;
217
- if (e.type === "throw") throw e.arg;
218
- return this.rval;
219
- },
220
- dispatchException: function(e) {
221
- if (this.done) throw e;
222
- var t = this;
223
- function r(n, r) {
224
- return o.type = "throw", o.arg = e, t.next = n, r && (t.method = "next", t.arg = void 0), !!r;
225
- }
226
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
227
- var a = this.tryEntries[i], o = a.completion;
228
- if (a.tryLoc === "root") return r("end");
229
- if (a.tryLoc <= this.prev) {
230
- var s = n.call(a, "catchLoc"), c = n.call(a, "finallyLoc");
231
- if (s && c) {
232
- if (this.prev < a.catchLoc) return r(a.catchLoc, !0);
233
- if (this.prev < a.finallyLoc) return r(a.finallyLoc);
234
- } else if (s) {
235
- if (this.prev < a.catchLoc) return r(a.catchLoc, !0);
236
- } else {
237
- if (!c) throw Error("try statement without catch or finally");
238
- if (this.prev < a.finallyLoc) return r(a.finallyLoc);
239
- }
240
- }
241
- }
242
- },
243
- abrupt: function(e, t) {
244
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
245
- var i = this.tryEntries[r];
246
- if (i.tryLoc <= this.prev && n.call(i, "finallyLoc") && this.prev < i.finallyLoc) {
247
- var a = i;
248
- break;
249
- }
250
- }
251
- a && (e === "break" || e === "continue") && a.tryLoc <= t && t <= a.finallyLoc && (a = null);
252
- var o = a ? a.completion : {};
253
- return o.type = e, o.arg = t, a ? (this.method = "next", this.next = a.finallyLoc, u) : this.complete(o);
254
- },
255
- complete: function(e, t) {
256
- if (e.type === "throw") throw e.arg;
257
- return e.type === "break" || e.type === "continue" ? this.next = e.arg : e.type === "return" ? (this.rval = this.arg = e.arg, this.method = "return", this.next = "end") : e.type === "normal" && t && (this.next = t), u;
258
- },
259
- finish: function(e) {
260
- for (var t = this.tryEntries.length - 1; t >= 0; --t) {
261
- var n = this.tryEntries[t];
262
- if (n.finallyLoc === e) return this.complete(n.completion, n.afterLoc), S(n), u;
263
- }
264
- },
265
- catch: function(e) {
266
- for (var t = this.tryEntries.length - 1; t >= 0; --t) {
267
- var n = this.tryEntries[t];
268
- if (n.tryLoc === e) {
269
- var r = n.completion;
270
- if (r.type === "throw") {
271
- var i = r.arg;
272
- S(n);
273
- }
274
- return i;
275
- }
276
- }
277
- throw Error("illegal catch attempt");
278
- },
279
- delegateYield: function(e, t, n) {
280
- return this.delegate = {
281
- iterator: w(e),
282
- resultName: t,
283
- nextLoc: n
284
- }, this.method === "next" && (this.arg = void 0), u;
285
- }
286
- }, e;
287
- }(e.exports);
288
- try {
289
- regeneratorRuntime = t;
290
- } catch {
291
- Function("r", "regeneratorRuntime = r")(t);
292
- }
293
- }));
294
- function l(e, t, n, r, i, a, o) {
295
- try {
296
- var s = e[a](o), c = s.value;
297
- } catch (e) {
298
- n(e);
299
- return;
300
- }
301
- s.done ? t(c) : Promise.resolve(c).then(r, i);
302
- }
303
- var u = function(e) {
304
- return function() {
305
- var t = this, n = arguments;
306
- return new Promise((function(r, i) {
307
- var a = e.apply(t, n);
308
- function o(e) {
309
- l(a, r, i, o, s, "next", e);
310
- }
311
- function s(e) {
312
- l(a, r, i, o, s, "throw", e);
313
- }
314
- o(void 0);
315
- }));
316
- };
317
- }, d = function(e) {
318
- if (Array.isArray(e)) return e;
319
- }, f = function(e, t) {
320
- if (typeof Symbol < "u" && Symbol.iterator in Object(e)) {
321
- var n = [], r = !0, i = !1, a = void 0;
322
- try {
323
- for (var o, s = e[Symbol.iterator](); !(r = (o = s.next()).done) && (n.push(o.value), !t || n.length !== t); r = !0);
324
- } catch (e) {
325
- i = !0, a = e;
326
- } finally {
327
- try {
328
- r || s.return == null || s.return();
329
- } finally {
330
- if (i) throw a;
331
- }
332
- }
333
- return n;
334
- }
335
- }, p = function(e, t) {
336
- (t == null || t > e.length) && (t = e.length);
337
- for (var n = 0, r = Array(t); n < t; n++) r[n] = e[n];
338
- return r;
339
- }, m = function(e, t) {
340
- if (e) {
341
- if (typeof e == "string") return p(e, t);
342
- var n = Object.prototype.toString.call(e).slice(8, -1);
343
- return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? p(e, t) : void 0;
344
- }
345
- }, h = function() {
346
- throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
347
- }, g = function(e, t) {
348
- return d(e) || f(e, t) || m(e, t) || h();
349
- }, _ = function(e, t) {
350
- if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
351
- };
352
- function v(e, t) {
353
- for (var n = 0; n < t.length; n++) {
354
- var r = t[n];
355
- r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
356
- }
357
- }
358
- var y = function(e, t, n) {
359
- return t && v(e.prototype, t), n && v(e, n), e;
360
- }, b = function(e, t, n) {
361
- return t in e ? Object.defineProperty(e, t, {
362
- value: n,
363
- enumerable: !0,
364
- configurable: !0,
365
- writable: !0
366
- }) : e[t] = n, e;
367
- }, x = function() {
368
- return !!navigator.permissions;
369
- }, S = function() {
370
- return !!navigator.mediaDevices;
371
- };
372
- function C(e, t, n, r, i, a, o) {
373
- try {
374
- var s = e[a](o), c = s.value;
375
- } catch (e) {
376
- n(e);
377
- return;
378
- }
379
- s.done ? t(c) : Promise.resolve(c).then(r, i);
380
- }
381
- function w(e) {
382
- return function() {
383
- var t = this, n = arguments;
384
- return new Promise((function(r, i) {
385
- var a = e.apply(t, n);
386
- function o(e) {
387
- C(a, r, i, o, s, "next", e);
388
- }
389
- function s(e) {
390
- C(a, r, i, o, s, "throw", e);
391
- }
392
- o(void 0);
393
- }));
394
- };
395
- }
396
- function T(e, t) {
397
- return function(e) {
398
- if (Array.isArray(e)) return e;
399
- }(e) || function(e, t) {
400
- if (typeof Symbol < "u" && Symbol.iterator in Object(e)) {
401
- var n = [], r = !0, i = !1, a = void 0;
402
- try {
403
- for (var o, s = e[Symbol.iterator](); !(r = (o = s.next()).done) && (n.push(o.value), !t || n.length !== t); r = !0);
404
- } catch (e) {
405
- i = !0, a = e;
406
- } finally {
407
- try {
408
- r || s.return == null || s.return();
409
- } finally {
410
- if (i) throw a;
411
- }
412
- }
413
- return n;
414
- }
415
- }(e, t) || function(e, t) {
416
- if (e) {
417
- if (typeof e == "string") return E(e, t);
418
- var n = Object.prototype.toString.call(e).slice(8, -1);
419
- return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? E(e, t) : void 0;
420
- }
421
- }(e, t) || function() {
422
- throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
423
- }();
424
- }
425
- function E(e, t) {
426
- (t == null || t > e.length) && (t = e.length);
427
- for (var n = 0, r = Array(t); n < t; n++) r[n] = e[n];
428
- return r;
429
- }
430
- var D = function() {
431
- var e = w(regeneratorRuntime.mark((function e(t) {
432
- return regeneratorRuntime.wrap((function(e) {
433
- for (;;) switch (e.prev = e.next) {
434
- case 0: return e.abrupt("return", new Promise(function() {
435
- var e = w(regeneratorRuntime.mark((function e(n, r) {
436
- var i, a;
437
- return regeneratorRuntime.wrap((function(e) {
438
- for (;;) switch (e.prev = e.next) {
439
- case 0: return x() || r(new DOMException("Navigator API: permissions not supported", "NOT_SUPPORTED_ERR")), e.prev = 1, e.next = 4, navigator.permissions.query({ name: t });
440
- case 4:
441
- i = e.sent, a = function e(t) {
442
- i.removeEventListener("change", e), O(t.target.state, n, r);
443
- }, i.addEventListener("change", a), O(i.state, n, r), e.next = 13;
444
- break;
445
- case 10: e.prev = 10, e.t0 = e.catch(1), r(e.t0);
446
- case 13:
447
- case "end": return e.stop();
448
- }
449
- }), e, null, [[1, 10]]);
450
- })));
451
- return function(t, n) {
452
- return e.apply(this, arguments);
453
- };
454
- }()));
455
- case 1:
456
- case "end": return e.stop();
457
- }
458
- }), e);
459
- })));
460
- return function(t) {
461
- return e.apply(this, arguments);
462
- };
463
- }(), O = function(e, t, n) {
464
- switch (e) {
465
- case "denied":
466
- n(new DOMException("Permission denied", "NOT_ALLOWED_ERR"));
467
- break;
468
- default: t(e);
469
- }
470
- }, k = function() {
471
- var e = w(regeneratorRuntime.mark((function e(t, n) {
472
- return regeneratorRuntime.wrap((function(e) {
473
- for (;;) switch (e.prev = e.next) {
474
- case 0: return e.abrupt("return", new Promise(function() {
475
- var e = w(regeneratorRuntime.mark((function e(r, i) {
476
- var a, o, s;
477
- return regeneratorRuntime.wrap((function(e) {
478
- for (;;) switch (e.prev = e.next) {
479
- case 0: return x() && S() || i(new DOMException("Navigator API: permissions or Navigator API: mediaDevices not supported", "NOT_SUPPORTED_ERR")), e.prev = 1, e.t0 = Promise, e.next = 5, D(t);
480
- case 5: return e.t1 = e.sent, e.next = 8, navigator.mediaDevices.getUserMedia(n);
481
- case 8: return e.t2 = e.sent, e.t3 = [e.t1, e.t2], e.next = 12, e.t0.all.call(e.t0, e.t3);
482
- case 12:
483
- a = e.sent, o = T(a, 2), s = o[1], r(s), e.next = 21;
484
- break;
485
- case 18: e.prev = 18, e.t4 = e.catch(1), i(e.t4);
486
- case 21:
487
- case "end": return e.stop();
488
- }
489
- }), e, null, [[1, 18]]);
490
- })));
491
- return function(t, n) {
492
- return e.apply(this, arguments);
493
- };
494
- }()));
495
- case 1:
496
- case "end": return e.stop();
497
- }
498
- }), e);
499
- })));
500
- return function(t, n) {
501
- return e.apply(this, arguments);
502
- };
503
- }();
504
- function A(e, t) {
505
- var n = Object.keys(e);
506
- if (Object.getOwnPropertySymbols) {
507
- var r = Object.getOwnPropertySymbols(e);
508
- t && (r = r.filter((function(t) {
509
- return Object.getOwnPropertyDescriptor(e, t).enumerable;
510
- }))), n.push.apply(n, r);
511
- }
512
- return n;
513
- }
514
- function j(e) {
515
- for (var t = 1; t < arguments.length; t++) {
516
- var n = arguments[t] == null ? {} : arguments[t];
517
- t % 2 ? A(Object(n), !0).forEach((function(t) {
518
- b(e, t, n[t]);
519
- })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : A(Object(n)).forEach((function(t) {
520
- Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
521
- }));
522
- }
523
- return e;
524
- }
525
- var M = function() {
526
- function e(t) {
527
- var n = this;
528
- _(this, e), b(this, "_instance", null), b(this, "_listeners", null);
529
- var r = e._resolveSpeechRecognition();
530
- if (!r) throw new DOMException("SpeechRecognition not supported", "NOT_SUPPORTED_ERR");
531
- this._instance = new r(), this._listeners = {}, Object.entries(j(j({}, e.defaultOptions), t || {})).forEach((function(t) {
532
- var r = g(t, 2), i = r[0], a = r[1];
533
- if (i === "grammars" && !a) {
534
- var o = e._resolveSpeechGrammarList();
535
- o && (a = new o());
536
- }
537
- n._instance[i] = a;
538
- }));
539
- }
540
- var t;
541
- return y(e, null, [{
542
- key: "isSupported",
543
- get: function() {
544
- return !!e._resolveSpeechRecognition() && !!x() && !!S();
545
- },
546
- set: function(e) {
547
- throw Error("You cannot set isSupported directly.");
548
- }
549
- }]), y(e, [
550
- {
551
- key: "start",
552
- value: (t = u(c.mark((function e() {
553
- var t;
554
- return c.wrap((function(e) {
555
- for (;;) switch (e.prev = e.next) {
556
- case 0:
557
- if (!this._instance) {
558
- e.next = 14;
559
- break;
560
- }
561
- return e.prev = 1, e.next = 4, k("microphone", { audio: !0 });
562
- case 4:
563
- if (e.sent) {
564
- e.next = 7;
565
- break;
566
- }
567
- throw Error("Unable to retrieve the stream from media device");
568
- case 7:
569
- this._instance.start(), e.next = 14;
570
- break;
571
- case 10: e.prev = 10, e.t0 = e.catch(1), (t = this._listeners.error) && t(e.t0);
572
- case 14: return e.abrupt("return", this);
573
- case 15:
574
- case "end": return e.stop();
575
- }
576
- }), e, this, [[1, 10]]);
577
- }))), function() {
578
- return t.apply(this, arguments);
579
- })
580
- },
581
- {
582
- key: "stop",
583
- value: function() {
584
- return this._instance && this._instance.stop(), this;
585
- }
586
- },
587
- {
588
- key: "abort",
589
- value: function() {
590
- return this._instance && this._instance.abort(), this;
591
- }
592
- },
593
- {
594
- key: "addEventListener",
595
- value: function(t, n) {
596
- var r = this;
597
- if (this._instance && this._includesEventType(t)) {
598
- this._listeners[t] && this.removeEventListener(t);
599
- var i = function(i) {
600
- var a = [];
601
- t === e.eventTypes.RESULT && i.results && i.results.length > 0 && a.push(i.results[0][0].transcript), n && n.apply(r, [i].concat(a));
602
- };
603
- this._instance.addEventListener(t, i), this._listeners[t] = i;
604
- }
605
- return this;
606
- }
607
- },
608
- {
609
- key: "removeEventListener",
610
- value: function(e) {
611
- var t = this._listeners[e];
612
- return this._instance.removeEventListener(e, t), delete this._listeners[e], this;
613
- }
614
- },
615
- {
616
- key: "cleanup",
617
- value: function() {
618
- var e = this;
619
- return this.stop(), Object.keys(this._listeners).forEach((function(t) {
620
- return e.removeEventListener(t);
621
- })), this._instance = null, this;
622
- }
623
- },
624
- {
625
- key: "_includesEventType",
626
- value: function(t) {
627
- return !!Object.values(e.eventTypes).find((function(e) {
628
- return e === t;
629
- }));
630
- }
631
- },
632
- {
633
- key: "instance",
634
- get: function() {
635
- return this._instance;
636
- },
637
- set: function(e) {
638
- throw Error("You cannot set instance directly.");
639
- }
640
- }
641
- ], [{
642
- key: "_resolveSpeechRecognition",
643
- value: function() {
644
- return window.SpeechRecognition || window.webkitSpeechRecognition || window.mozSpeechRecognition || window.msSpeechRecognition;
645
- }
646
- }, {
647
- key: "_resolveSpeechGrammarList",
648
- value: function() {
649
- return window.SpeechGrammarList || window.webkitSpeechGrammarList || window.mozSpeechGrammarList || window.msSpeechGrammarList;
650
- }
651
- }]), e;
652
- }();
653
- b(M, "defaultOptions", {
654
- grammars: null,
655
- lang: "en-US",
656
- continuous: !1,
657
- interimResults: !1,
658
- maxAlternatives: 1,
659
- serviceURI: null
660
- }), b(M, "eventTypes", {
6
+ }), l = () => !!navigator.permissions, u = () => !!navigator.mediaDevices, d = async (e, t, { signal: n } = {}) => {
7
+ if (!l() || !u()) throw new DOMException("Navigator API: permissions or Navigator API: mediaDevices not supported", "NOT_SUPPORTED_ERR");
8
+ if (n?.throwIfAborted(), (await navigator.permissions.query({ name: e })).state === "denied") throw new DOMException("Permission denied", "NOT_ALLOWED_ERR");
9
+ n?.throwIfAborted();
10
+ let r = navigator.mediaDevices.getUserMedia(t);
11
+ if (!n) return r;
12
+ let i, a = new Promise((e, t) => {
13
+ i = () => t(n.reason), n.addEventListener("abort", i, { once: !0 });
14
+ });
15
+ return Promise.race([r, a]).finally(() => {
16
+ n.removeEventListener("abort", i);
17
+ });
18
+ }, f = {
661
19
  AUDIO_END: "audioend",
662
20
  AUDIO_START: "audiostart",
663
21
  END: "end",
@@ -669,1227 +27,236 @@ b(M, "defaultOptions", {
669
27
  SPEECH_END: "speechend",
670
28
  SPEECH_START: "speechstart",
671
29
  START: "start"
672
- });
673
- //#endregion
674
- //#region node_modules/@untemps/utils/dist/function/isFunction.js
675
- var N = (e) => typeof e == "function", P = (e = "en-US", t = null, a = null) => {
676
- let o = i(null);
677
- return r(() => {
678
- if (M.isSupported) return o.current = a || new M({
679
- lang: e,
680
- grammars: t
681
- }), () => {
682
- o.current.abort(), o.current.cleanup();
30
+ }, p = 1e3, m = new Set([
31
+ "not-allowed",
32
+ "service-not-allowed",
33
+ "audio-capture"
34
+ ]), h = {
35
+ grammars: null,
36
+ lang: "en-US",
37
+ continuous: !1,
38
+ interimResults: !1,
39
+ maxAlternatives: 1
40
+ }, g = () => {
41
+ if (!(typeof window > "u")) return window.SpeechRecognition ?? window.webkitSpeechRecognition ?? window.mozSpeechRecognition ?? window.msSpeechRecognition;
42
+ }, _ = () => window.SpeechGrammarList ?? window.webkitSpeechGrammarList ?? window.mozSpeechGrammarList ?? window.msSpeechGrammarList, v = (e) => e.reduce((e, t) => (t.confidence ?? 0) > (e.confidence ?? 0) ? t : e), y = (e) => {
43
+ let t = e.slice();
44
+ return Object.defineProperty(t, "isFinal", { value: !0 }), Object.defineProperty(t, "item", { value: (e) => t[e] }), t;
45
+ }, b = (e) => {
46
+ let t = e.slice();
47
+ return Object.defineProperty(t, "item", { value: (e) => t[e] }), t;
48
+ }, x = (e) => Object.values(f).includes(e), S = (e) => `Unknown event type "${e}". Valid types are: ${Object.values(f).join(", ")}.`, C = () => !!g() && !!l() && !!u(), w = (e) => {
49
+ let t = g();
50
+ if (!t) throw new DOMException("SpeechRecognition not supported", "NOT_SUPPORTED_ERR");
51
+ let n = new t(), r = {}, i = !1, a = !1, o = 0, s = null, c = !1, l = [], u = {
52
+ ...h,
53
+ ...e ?? {}
54
+ };
55
+ if (n.lang = u.lang, n.continuous = u.continuous, n.interimResults = u.interimResults, n.maxAlternatives = u.maxAlternatives, u.grammars) n.grammars = u.grammars;
56
+ else {
57
+ let e = _();
58
+ n.grammars = e ? new e() : null;
59
+ }
60
+ let C = () => {
61
+ s !== null && (clearTimeout(s), s = null), c = !1;
62
+ }, w = () => !!n && !a && n.continuous, T = () => {
63
+ s = null;
64
+ try {
65
+ n.start(), o = Date.now();
66
+ } catch {
67
+ c = !1, i = !1;
68
+ }
69
+ }, E = () => {
70
+ let e = l;
71
+ if (l = [], e.length === 0 || !r[f.RESULT]?.length) return;
72
+ let t = e.map((e) => v(Array.from(e)).transcript).join(" ").trim(), n = Object.assign(new Event(f.RESULT), {
73
+ resultIndex: 0,
74
+ results: b(e)
75
+ });
76
+ [...r[f.RESULT]].forEach(({ callback: e }) => {
77
+ e(n, t, [t]);
78
+ });
79
+ }, D = [
80
+ [f.END, (e) => {
81
+ if (w()) {
82
+ let t = Math.max(0, p - (Date.now() - o));
83
+ c = !0, s = setTimeout(T, t), e.stopImmediatePropagation();
84
+ return;
85
+ }
86
+ E(), i = !1;
87
+ }],
88
+ [f.START, (e) => {
89
+ c && (e.stopImmediatePropagation(), queueMicrotask(() => {
90
+ c = !1;
91
+ }));
92
+ }],
93
+ [f.ERROR, (e) => {
94
+ m.has(e.error) && (a = !0, C(), i = !1);
95
+ }],
96
+ [f.RESULT, (e) => {
97
+ if (!u.continuous) return;
98
+ let t = e, n = t.results?.[t.resultIndex];
99
+ n?.isFinal && l.push(y(Array.from(n)));
100
+ }]
101
+ ];
102
+ D.forEach(([e, t]) => n.addEventListener(e, t));
103
+ let O = async ({ signal: e } = {}) => {
104
+ if (n) try {
105
+ let t = await d("microphone", { audio: !0 }, { signal: e });
106
+ if (e?.aborted || !n) return;
107
+ if (!t) throw Error("Unable to retrieve the stream from media device");
108
+ a = !1, l = [], n.start(), i = !0, o = Date.now();
109
+ } catch (e) {
110
+ if (e instanceof Error && e.name === "AbortError") return;
111
+ throw e;
112
+ }
113
+ }, k = () => {
114
+ n && (a = !0, C(), n.stop(), i = !1);
115
+ }, A = () => {
116
+ n && (a = !0, C(), l = [], n.abort(), i = !1);
117
+ }, j = (e, t) => {
118
+ if (!x(e)) throw Error(S(e));
119
+ if (!n) return;
120
+ let i = (n) => {
121
+ if (c && (e === f.END || e === f.START)) return;
122
+ if (e !== f.RESULT) {
123
+ t(n);
124
+ return;
125
+ }
126
+ let r = n;
127
+ if (!(r.results?.length > 0) || r.resultIndex >= r.results.length) {
128
+ t(n);
129
+ return;
130
+ }
131
+ let i = r.results[r.resultIndex];
132
+ if (u.continuous && i.isFinal) return;
133
+ let a = Array.from(i);
134
+ t(n, v(a).transcript, a.map((e) => e.transcript));
683
135
  };
136
+ n.addEventListener(e, i), r[e] || (r[e] = []), r[e].push({
137
+ callback: t,
138
+ handler: i
139
+ });
140
+ }, M = (e, t) => {
141
+ if (!x(e)) throw Error(S(e));
142
+ if (!(!n || !r[e])) if (t !== void 0) {
143
+ let i = r[e].findIndex((e) => e.callback === t);
144
+ i !== -1 && (n.removeEventListener(e, r[e][i].handler), r[e].splice(i, 1), r[e].length === 0 && delete r[e]);
145
+ } else r[e].forEach(({ handler: t }) => n.removeEventListener(e, t)), delete r[e];
146
+ };
147
+ return {
148
+ get isRecording() {
149
+ return i;
150
+ },
151
+ start: O,
152
+ stop: k,
153
+ abort: A,
154
+ on: j,
155
+ off: M,
156
+ cleanup: () => {
157
+ k(), Object.keys(r).forEach((e) => M(e)), D.forEach(([e, t]) => n?.removeEventListener(e, t)), n = null;
158
+ }
159
+ };
160
+ }, T = (e) => typeof e == "function", E = (e = "en-US", t = null, s = 1, c = !1, l = null) => {
161
+ let u = a(null), [d, f] = o(!1), p = i(() => C(), []);
162
+ return r(() => {
163
+ if (p) {
164
+ let n = l || w({
165
+ lang: e,
166
+ grammars: t,
167
+ maxAlternatives: s,
168
+ continuous: c
169
+ });
170
+ u.current = n;
171
+ let r = () => f(!0), i = () => f(!1);
172
+ return n.on("start", r), n.on("end", i), n.on("error", i), () => {
173
+ n.off("start", r), n.off("end", i), n.off("error", i), n.abort(), n.cleanup(), f(!1);
174
+ };
175
+ }
684
176
  }, [
685
177
  e,
686
178
  t,
687
- a
688
- ]), [o, {
689
- start: n(() => {
690
- o.current && o.current.start();
179
+ s,
180
+ c,
181
+ l,
182
+ p
183
+ ]), [u, {
184
+ start: n((e) => {
185
+ if (u.current) return f(!0), u.current.start(e);
691
186
  }, []),
692
187
  stop: n(() => {
693
- o.current && o.current.stop();
188
+ u.current && u.current.stop();
694
189
  }, []),
695
190
  abort: n(() => {
696
- o.current && o.current.abort();
191
+ u.current && u.current.abort();
697
192
  }, []),
698
193
  subscribe: n((e, t) => {
699
- o.current && o.current.addEventListener(e, t);
194
+ u.current && u.current.on(e, t);
700
195
  }, []),
701
196
  unsubscribe: n((e, t) => {
702
- o.current && o.current.removeEventListener(e, t);
197
+ u.current && u.current.off(e, t);
703
198
  }, []),
704
199
  clean: n(() => {
705
- o.current && o.current.cleanup();
706
- }, [])
200
+ u.current && u.current.cleanup();
201
+ }, []),
202
+ isRecording: d
707
203
  }];
708
- }, ee = (e, t = 0) => {
709
- let a = i(-1), o = n(() => {
710
- clearTimeout(a.current), a.current = -1;
204
+ }, D = (e, t = 0) => {
205
+ let i = a(-1), o = n(() => {
206
+ clearTimeout(i.current), i.current = -1;
711
207
  }, []), s = n(() => {
712
- o(), a.current = setTimeout(e, t);
208
+ o(), i.current = setTimeout(e, t);
713
209
  }, [
714
210
  e,
715
211
  t,
716
212
  o
717
213
  ]);
718
214
  return r(() => o, [o]), [s, o];
719
- };
720
- //#endregion
721
- //#region node_modules/fuse.js/dist/fuse.mjs
722
- function F(e) {
723
- return Array.isArray ? Array.isArray(e) : re(e) === "[object Array]";
724
- }
725
- function I(e) {
726
- if (typeof e == "string") return e;
727
- if (typeof e == "bigint") return e.toString();
728
- let t = e + "";
729
- return t == "0" && 1 / e == -Infinity ? "-0" : t;
730
- }
731
- function L(e) {
732
- return e == null ? "" : I(e);
733
- }
734
- function R(e) {
735
- return typeof e == "string";
736
- }
737
- function z(e) {
738
- return typeof e == "number";
739
- }
740
- function te(e) {
741
- return e === !0 || e === !1 || ne(e) && re(e) == "[object Boolean]";
742
- }
743
- function B(e) {
744
- return typeof e == "object";
745
- }
746
- function ne(e) {
747
- return B(e) && e !== null;
748
- }
749
- function V(e) {
750
- return e != null;
751
- }
752
- function H(e) {
753
- return !e.trim().length;
754
- }
755
- function re(e) {
756
- return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
757
- }
758
- var ie = "Incorrect 'index' type", ae = (e) => `Invalid value for key ${e}`, oe = (e) => `Pattern length exceeds max of ${e}.`, se = (e) => `Missing ${e} property in key`, ce = (e) => `Property 'weight' in key '${e}' must be a positive integer`, le = Object.prototype.hasOwnProperty, ue = class {
759
- constructor(e) {
760
- this._keys = [], this._keyMap = {};
761
- let t = 0;
762
- e.forEach((e) => {
763
- let n = de(e);
764
- this._keys.push(n), this._keyMap[n.id] = n, t += n.weight;
765
- }), this._keys.forEach((e) => {
766
- e.weight /= t;
767
- });
768
- }
769
- get(e) {
770
- return this._keyMap[e];
771
- }
772
- keys() {
773
- return this._keys;
774
- }
775
- toJSON() {
776
- return JSON.stringify(this._keys);
777
- }
778
- };
779
- function de(e) {
780
- let t = null, n = null, r = null, i = 1, a = null;
781
- if (R(e) || F(e)) r = e, t = fe(e), n = U(e);
782
- else {
783
- if (!le.call(e, "name")) throw Error(se("name"));
784
- let o = e.name;
785
- if (r = o, le.call(e, "weight") && (i = e.weight, i <= 0)) throw Error(ce(o));
786
- t = fe(o), n = U(o), a = e.getFn;
787
- }
788
- return {
789
- path: t,
790
- id: n,
791
- weight: i,
792
- src: r,
793
- getFn: a
794
- };
795
- }
796
- function fe(e) {
797
- return F(e) ? e : e.split(".");
798
- }
799
- function U(e) {
800
- return F(e) ? e.join(".") : e;
801
- }
802
- function pe(e, t) {
803
- let n = [], r = !1, i = (e, t, a, o) => {
804
- if (V(e)) if (!t[a]) n.push(o === void 0 ? e : {
805
- v: e,
806
- i: o
807
- });
808
- else {
809
- let s = e[t[a]];
810
- if (!V(s)) return;
811
- if (a === t.length - 1 && (R(s) || z(s) || te(s) || typeof s == "bigint")) n.push(o === void 0 ? L(s) : {
812
- v: L(s),
813
- i: o
814
- });
815
- else if (F(s)) {
816
- r = !0;
817
- for (let e = 0, n = s.length; e < n; e += 1) i(s[e], t, a + 1, e);
818
- } else t.length && i(s, t, a + 1, o);
819
- }
820
- };
821
- return i(e, R(t) ? t.split(".") : t, 0), r ? n : n[0];
822
- }
823
- var me = {
824
- includeMatches: !1,
825
- findAllMatches: !1,
826
- minMatchCharLength: 1
827
- }, he = {
828
- isCaseSensitive: !1,
829
- ignoreDiacritics: !1,
830
- includeScore: !1,
831
- keys: [],
832
- shouldSort: !0,
833
- sortFn: (e, t) => e.score === t.score ? e.idx < t.idx ? -1 : 1 : e.score < t.score ? -1 : 1
834
- }, ge = {
835
- location: 0,
836
- threshold: .6,
837
- distance: 100
838
- }, _e = {
839
- useExtendedSearch: !1,
840
- useTokenSearch: !1,
841
- getFn: pe,
842
- ignoreLocation: !1,
843
- ignoreFieldNorm: !1,
844
- fieldNormWeight: 1
845
- }, W = Object.freeze({
846
- ...he,
847
- ...me,
848
- ...ge,
849
- ..._e
850
- }), ve = /[^ ]+/g;
851
- function ye(e = 1, t = 3) {
852
- let n = /* @__PURE__ */ new Map(), r = 10 ** t;
853
- return {
854
- get(t) {
855
- let i = t.match(ve).length;
856
- if (n.has(i)) return n.get(i);
857
- let a = 1 / i ** (.5 * e), o = parseFloat(Math.round(a * r) / r);
858
- return n.set(i, o), o;
859
- },
860
- clear() {
861
- n.clear();
862
- }
863
- };
864
- }
865
- var G = class {
866
- constructor({ getFn: e = W.getFn, fieldNormWeight: t = W.fieldNormWeight } = {}) {
867
- this.norm = ye(t, 3), this.getFn = e, this.isCreated = !1, this.docs = [], this.keys = [], this._keysMap = {}, this.setIndexRecords();
868
- }
869
- setSources(e = []) {
870
- this.docs = e;
871
- }
872
- setIndexRecords(e = []) {
873
- this.records = e;
874
- }
875
- setKeys(e = []) {
876
- this.keys = e, this._keysMap = {}, e.forEach((e, t) => {
877
- this._keysMap[e.id] = t;
878
- });
879
- }
880
- create() {
881
- this.isCreated || !this.docs.length || (this.isCreated = !0, R(this.docs[0]) ? this.docs.forEach((e, t) => {
882
- this._addString(e, t);
883
- }) : this.docs.forEach((e, t) => {
884
- this._addObject(e, t);
885
- }), this.norm.clear());
886
- }
887
- add(e) {
888
- let t = this.size();
889
- R(e) ? this._addString(e, t) : this._addObject(e, t);
890
- }
891
- removeAt(e) {
892
- this.records.splice(e, 1);
893
- for (let t = e, n = this.size(); t < n; t += 1) --this.records[t].i;
894
- }
895
- removeAll(e) {
896
- for (let t = e.length - 1; t >= 0; --t) this.records.splice(e[t], 1);
897
- for (let e = 0, t = this.records.length; e < t; e += 1) this.records[e].i = e;
898
- }
899
- getValueForItemAtKeyId(e, t) {
900
- return e[this._keysMap[t]];
901
- }
902
- size() {
903
- return this.records.length;
904
- }
905
- _addString(e, t) {
906
- if (!V(e) || H(e)) return;
907
- let n = {
908
- v: e,
909
- i: t,
910
- n: this.norm.get(e)
911
- };
912
- this.records.push(n);
913
- }
914
- _addObject(e, t) {
915
- let n = {
916
- i: t,
917
- $: {}
918
- };
919
- this.keys.forEach((t, r) => {
920
- let i = t.getFn ? t.getFn(e) : this.getFn(e, t.path);
921
- if (V(i)) {
922
- if (F(i)) {
923
- let e = [];
924
- for (let t = 0, n = i.length; t < n; t += 1) {
925
- let n = i[t];
926
- if (V(n)) {
927
- if (R(n)) {
928
- if (!H(n)) {
929
- let r = {
930
- v: n,
931
- i: t,
932
- n: this.norm.get(n)
933
- };
934
- e.push(r);
935
- }
936
- } else if (V(n.v)) {
937
- let t = R(n.v) ? n.v : L(n.v);
938
- if (!H(t)) {
939
- let r = {
940
- v: t,
941
- i: n.i,
942
- n: this.norm.get(t)
943
- };
944
- e.push(r);
945
- }
946
- }
947
- }
948
- }
949
- n.$[r] = e;
950
- } else if (R(i) && !H(i)) {
951
- let e = {
952
- v: i,
953
- n: this.norm.get(i)
954
- };
955
- n.$[r] = e;
956
- }
957
- }
958
- }), this.records.push(n);
959
- }
960
- toJSON() {
961
- return {
962
- keys: this.keys.map(({ getFn: e, ...t }) => t),
963
- records: this.records
215
+ }, O = (e, t = .4) => {
216
+ let n = i(() => e ? Object.entries(e).reduce((e, [t, n]) => ({
217
+ ...e,
218
+ [t.toLowerCase()]: n
219
+ }), {}) : {}, [e]), o = i(() => Object.keys(n), [n]), s = i(() => o.some((e) => e.includes(" ")), [o]), c = a(null);
220
+ return r(() => {
221
+ if (!s) {
222
+ c.current = null;
223
+ return;
224
+ }
225
+ let e = !1;
226
+ return import("fuse.js").then((t) => {
227
+ e || (c.current = new (t.default ?? t)(o, {
228
+ includeScore: !0,
229
+ ignoreLocation: !0
230
+ }));
231
+ }).catch(() => {
232
+ e || process.env.NODE_ENV !== "production" && console.warn("[react-vocal] fuse.js is not installed. Phrase command keys will fall back to exact matching. Install fuse.js to enable fuzzy matching: npm install fuse.js");
233
+ }), () => {
234
+ e = !0;
964
235
  };
965
- }
966
- };
967
- function be(e, t, { getFn: n = W.getFn, fieldNormWeight: r = W.fieldNormWeight } = {}) {
968
- let i = new G({
969
- getFn: n,
970
- fieldNormWeight: r
971
- });
972
- return i.setKeys(e.map(de)), i.setSources(t), i.create(), i;
973
- }
974
- function xe(e, { getFn: t = W.getFn, fieldNormWeight: n = W.fieldNormWeight } = {}) {
975
- let { keys: r, records: i } = e, a = new G({
976
- getFn: t,
977
- fieldNormWeight: n
978
- });
979
- return a.setKeys(r), a.setIndexRecords(i), a;
980
- }
981
- function Se(e = [], t = W.minMatchCharLength) {
982
- let n = [], r = -1, i = -1, a = 0;
983
- for (let o = e.length; a < o; a += 1) {
984
- let o = e[a];
985
- o && r === -1 ? r = a : !o && r !== -1 && (i = a - 1, i - r + 1 >= t && n.push([r, i]), r = -1);
986
- }
987
- return e[a - 1] && a - r >= t && n.push([r, a - 1]), n;
988
- }
989
- var K = 32;
990
- function Ce(e, t, n, { location: r = W.location, distance: i = W.distance, threshold: a = W.threshold, findAllMatches: o = W.findAllMatches, minMatchCharLength: s = W.minMatchCharLength, includeMatches: c = W.includeMatches, ignoreLocation: l = W.ignoreLocation } = {}) {
991
- if (t.length > K) throw Error(oe(K));
992
- let u = t.length, d = e.length, f = Math.max(0, Math.min(r, d)), p = a, m = f, h = (e, t) => {
993
- let n = e / u;
994
- if (l) return n;
995
- let r = Math.abs(f - t);
996
- return i ? n + r / i : r ? 1 : n;
997
- }, g = s > 1 || c, _ = g ? Array(d) : [], v;
998
- for (; (v = e.indexOf(t, m)) > -1;) {
999
- let e = h(0, v);
1000
- if (p = Math.min(e, p), m = v + u, g) {
1001
- let e = 0;
1002
- for (; e < u;) _[v + e] = 1, e += 1;
1003
- }
1004
- }
1005
- m = -1;
1006
- let y = [], b = 1, x = u + d, S = 1 << u - 1;
1007
- for (let t = 0; t < u; t += 1) {
1008
- let r = 0, i = x;
1009
- for (; r < i;) h(t, f + i) <= p ? r = i : x = i, i = Math.floor((x - r) / 2 + r);
1010
- x = i;
1011
- let a = Math.max(1, f - i + 1), s = o ? d : Math.min(f + i, d) + u, c = Array(s + 2);
1012
- c[s + 1] = (1 << t) - 1;
1013
- for (let r = s; r >= a; --r) {
1014
- let i = r - 1, o = n[e[i]];
1015
- if (g && (_[i] = +!!o), c[r] = (c[r + 1] << 1 | 1) & o, t && (c[r] |= (y[r + 1] | y[r]) << 1 | 1 | y[r + 1]), c[r] & S && (b = h(t, i), b <= p)) {
1016
- if (p = b, m = i, m <= f) break;
1017
- a = Math.max(1, 2 * f - m);
236
+ }, [s, o]), (e) => {
237
+ if (!o.length) return null;
238
+ if (!s) {
239
+ let t = e.trim().split(/\s+/), r = t.length > 1 ? t : [e.trim()];
240
+ for (let e of r) {
241
+ let t = e.toLowerCase();
242
+ if (t in n) return n[t]?.(e, t);
1018
243
  }
244
+ return null;
1019
245
  }
1020
- if (h(t + 1, f) > p) break;
1021
- y = c;
1022
- }
1023
- let C = {
1024
- isMatch: m >= 0,
1025
- score: Math.max(.001, b)
1026
- };
1027
- if (g) {
1028
- let e = Se(_, s);
1029
- e.length ? c && (C.indices = e) : C.isMatch = !1;
1030
- }
1031
- return C;
1032
- }
1033
- function we(e) {
1034
- let t = {};
1035
- for (let n = 0, r = e.length; n < r; n += 1) {
1036
- let i = e.charAt(n);
1037
- t[i] = (t[i] || 0) | 1 << r - n - 1;
1038
- }
1039
- return t;
1040
- }
1041
- function Te(e) {
1042
- if (e.length <= 1) return e;
1043
- e.sort((e, t) => e[0] - t[0] || e[1] - t[1]);
1044
- let t = [e[0]];
1045
- for (let n = 1, r = e.length; n < r; n += 1) {
1046
- let r = t[t.length - 1], i = e[n];
1047
- i[0] <= r[1] + 1 ? r[1] = Math.max(r[1], i[1]) : t.push(i);
1048
- }
1049
- return t;
1050
- }
1051
- var Ee = {
1052
- ł: "l",
1053
- Ł: "L",
1054
- đ: "d",
1055
- Đ: "D",
1056
- ø: "o",
1057
- Ø: "O",
1058
- ħ: "h",
1059
- Ħ: "H",
1060
- ŧ: "t",
1061
- Ŧ: "T",
1062
- ı: "i",
1063
- ß: "ss"
1064
- }, De = RegExp("[" + Object.keys(Ee).join("") + "]", "g"), q = String.prototype.normalize ? (e) => e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, "").replace(De, (e) => Ee[e]) : (e) => e, Oe = class {
1065
- constructor(e, { location: t = W.location, threshold: n = W.threshold, distance: r = W.distance, includeMatches: i = W.includeMatches, findAllMatches: a = W.findAllMatches, minMatchCharLength: o = W.minMatchCharLength, isCaseSensitive: s = W.isCaseSensitive, ignoreDiacritics: c = W.ignoreDiacritics, ignoreLocation: l = W.ignoreLocation } = {}) {
1066
- if (this.options = {
1067
- location: t,
1068
- threshold: n,
1069
- distance: r,
1070
- includeMatches: i,
1071
- findAllMatches: a,
1072
- minMatchCharLength: o,
1073
- isCaseSensitive: s,
1074
- ignoreDiacritics: c,
1075
- ignoreLocation: l
1076
- }, e = s ? e : e.toLowerCase(), e = c ? q(e) : e, this.pattern = e, this.chunks = [], !this.pattern.length) return;
1077
- let u = (e, t) => {
1078
- this.chunks.push({
1079
- pattern: e,
1080
- alphabet: we(e),
1081
- startIndex: t
1082
- });
1083
- }, d = this.pattern.length;
1084
- if (d > K) {
1085
- let e = 0, t = d % K, n = d - t;
1086
- for (; e < n;) u(this.pattern.substr(e, K), e), e += K;
1087
- if (t) {
1088
- let e = d - K;
1089
- u(this.pattern.substr(e), e);
1090
- }
1091
- } else u(this.pattern, 0);
1092
- }
1093
- searchIn(e) {
1094
- let { isCaseSensitive: t, ignoreDiacritics: n, includeMatches: r } = this.options;
1095
- if (e = t ? e : e.toLowerCase(), e = n ? q(e) : e, this.pattern === e) {
1096
- let t = {
1097
- isMatch: !0,
1098
- score: 0
1099
- };
1100
- return r && (t.indices = [[0, e.length - 1]]), t;
1101
- }
1102
- let { location: i, distance: a, threshold: o, findAllMatches: s, minMatchCharLength: c, ignoreLocation: l } = this.options, u = [], d = 0, f = !1;
1103
- this.chunks.forEach(({ pattern: t, alphabet: n, startIndex: p }) => {
1104
- let { isMatch: m, score: h, indices: g } = Ce(e, t, n, {
1105
- location: i + p,
1106
- distance: a,
1107
- threshold: o,
1108
- findAllMatches: s,
1109
- minMatchCharLength: c,
1110
- includeMatches: r,
1111
- ignoreLocation: l
1112
- });
1113
- m && (f = !0), d += h, m && g && u.push(...g);
1114
- });
1115
- let p = {
1116
- isMatch: f,
1117
- score: f ? d / this.chunks.length : 1
1118
- };
1119
- return f && r && (p.indices = Te(u)), p;
1120
- }
1121
- }, J = class {
1122
- constructor(e) {
1123
- this.pattern = e;
1124
- }
1125
- static isMultiMatch(e) {
1126
- return ke(e, this.multiRegex);
1127
- }
1128
- static isSingleMatch(e) {
1129
- return ke(e, this.singleRegex);
1130
- }
1131
- search(e) {
1132
- return {
1133
- isMatch: !1,
1134
- score: 1
1135
- };
1136
- }
1137
- };
1138
- function ke(e, t) {
1139
- let n = e.match(t);
1140
- return n ? n[1] : null;
1141
- }
1142
- var Ae = class extends J {
1143
- constructor(e) {
1144
- super(e);
1145
- }
1146
- static get type() {
1147
- return "exact";
1148
- }
1149
- static get multiRegex() {
1150
- return /^="(.*)"$/;
1151
- }
1152
- static get singleRegex() {
1153
- return /^=(.*)$/;
1154
- }
1155
- search(e) {
1156
- let t = e === this.pattern;
1157
- return {
1158
- isMatch: t,
1159
- score: +!t,
1160
- indices: [0, this.pattern.length - 1]
1161
- };
1162
- }
1163
- }, je = class extends J {
1164
- constructor(e) {
1165
- super(e);
1166
- }
1167
- static get type() {
1168
- return "inverse-exact";
1169
- }
1170
- static get multiRegex() {
1171
- return /^!"(.*)"$/;
1172
- }
1173
- static get singleRegex() {
1174
- return /^!(.*)$/;
1175
- }
1176
- search(e) {
1177
- let t = e.indexOf(this.pattern) === -1;
1178
- return {
1179
- isMatch: t,
1180
- score: +!t,
1181
- indices: [0, e.length - 1]
1182
- };
1183
- }
1184
- }, Me = class extends J {
1185
- constructor(e) {
1186
- super(e);
1187
- }
1188
- static get type() {
1189
- return "prefix-exact";
1190
- }
1191
- static get multiRegex() {
1192
- return /^\^"(.*)"$/;
1193
- }
1194
- static get singleRegex() {
1195
- return /^\^(.*)$/;
1196
- }
1197
- search(e) {
1198
- let t = e.startsWith(this.pattern);
1199
- return {
1200
- isMatch: t,
1201
- score: +!t,
1202
- indices: [0, this.pattern.length - 1]
1203
- };
1204
- }
1205
- }, Ne = class extends J {
1206
- constructor(e) {
1207
- super(e);
1208
- }
1209
- static get type() {
1210
- return "inverse-prefix-exact";
1211
- }
1212
- static get multiRegex() {
1213
- return /^!\^"(.*)"$/;
1214
- }
1215
- static get singleRegex() {
1216
- return /^!\^(.*)$/;
1217
- }
1218
- search(e) {
1219
- let t = !e.startsWith(this.pattern);
1220
- return {
1221
- isMatch: t,
1222
- score: +!t,
1223
- indices: [0, e.length - 1]
1224
- };
1225
- }
1226
- }, Pe = class extends J {
1227
- constructor(e) {
1228
- super(e);
1229
- }
1230
- static get type() {
1231
- return "suffix-exact";
1232
- }
1233
- static get multiRegex() {
1234
- return /^"(.*)"\$$/;
1235
- }
1236
- static get singleRegex() {
1237
- return /^(.*)\$$/;
1238
- }
1239
- search(e) {
1240
- let t = e.endsWith(this.pattern);
1241
- return {
1242
- isMatch: t,
1243
- score: +!t,
1244
- indices: [e.length - this.pattern.length, e.length - 1]
1245
- };
1246
- }
1247
- }, Fe = class extends J {
1248
- constructor(e) {
1249
- super(e);
1250
- }
1251
- static get type() {
1252
- return "inverse-suffix-exact";
1253
- }
1254
- static get multiRegex() {
1255
- return /^!"(.*)"\$$/;
1256
- }
1257
- static get singleRegex() {
1258
- return /^!(.*)\$$/;
1259
- }
1260
- search(e) {
1261
- let t = !e.endsWith(this.pattern);
1262
- return {
1263
- isMatch: t,
1264
- score: +!t,
1265
- indices: [0, e.length - 1]
1266
- };
1267
- }
1268
- }, Ie = class extends J {
1269
- constructor(e, { location: t = W.location, threshold: n = W.threshold, distance: r = W.distance, includeMatches: i = W.includeMatches, findAllMatches: a = W.findAllMatches, minMatchCharLength: o = W.minMatchCharLength, isCaseSensitive: s = W.isCaseSensitive, ignoreDiacritics: c = W.ignoreDiacritics, ignoreLocation: l = W.ignoreLocation } = {}) {
1270
- super(e), this._bitapSearch = new Oe(e, {
1271
- location: t,
1272
- threshold: n,
1273
- distance: r,
1274
- includeMatches: i,
1275
- findAllMatches: a,
1276
- minMatchCharLength: o,
1277
- isCaseSensitive: s,
1278
- ignoreDiacritics: c,
1279
- ignoreLocation: l
1280
- });
1281
- }
1282
- static get type() {
1283
- return "fuzzy";
1284
- }
1285
- static get multiRegex() {
1286
- return /^"(.*)"$/;
1287
- }
1288
- static get singleRegex() {
1289
- return /^(.*)$/;
1290
- }
1291
- search(e) {
1292
- return this._bitapSearch.searchIn(e);
1293
- }
1294
- }, Le = class extends J {
1295
- constructor(e) {
1296
- super(e);
1297
- }
1298
- static get type() {
1299
- return "include";
1300
- }
1301
- static get multiRegex() {
1302
- return /^'"(.*)"$/;
1303
- }
1304
- static get singleRegex() {
1305
- return /^'(.*)$/;
1306
- }
1307
- search(e) {
1308
- let t = 0, n, r = [], i = this.pattern.length;
1309
- for (; (n = e.indexOf(this.pattern, t)) > -1;) t = n + i, r.push([n, t - 1]);
1310
- let a = !!r.length;
1311
- return {
1312
- isMatch: a,
1313
- score: +!a,
1314
- indices: r
1315
- };
1316
- }
1317
- }, Re = [
1318
- Ae,
1319
- Le,
1320
- Me,
1321
- Ne,
1322
- Fe,
1323
- Pe,
1324
- je,
1325
- Ie
1326
- ], ze = Re.length, Be = "\0", Ve = "|";
1327
- function He(e) {
1328
- let t = [], n = e.length, r = 0;
1329
- for (; r < n;) {
1330
- for (; r < n && e[r] === " ";) r++;
1331
- if (r >= n) break;
1332
- let i = r;
1333
- for (; i < n && e[i] !== " " && e[i] !== "\"";) i++;
1334
- if (i < n && e[i] === "\"") {
1335
- for (i++; i < n;) {
1336
- if (e[i] === "\"") {
1337
- let t = i + 1;
1338
- if (t >= n || e[t] === " ") {
1339
- i++;
1340
- break;
1341
- }
1342
- if (e[t] === "$" && (t + 1 >= n || e[t + 1] === " ")) {
1343
- i += 2;
1344
- break;
1345
- }
1346
- }
1347
- i++;
246
+ let r = c.current;
247
+ if (r) {
248
+ let i = r.search(e).filter((e) => e.score < t);
249
+ if (i?.length) {
250
+ let t = i[0].item.toLowerCase();
251
+ return n[t]?.(e, t);
1348
252
  }
1349
- t.push(e.substring(r, i)), r = i;
1350
253
  } else {
1351
- for (; i < n && e[i] !== " ";) i++;
1352
- t.push(e.substring(r, i)), r = i;
1353
- }
1354
- }
1355
- return t;
1356
- }
1357
- function Ue(e, t = {}) {
1358
- return e.replace(/\\\|/g, Be).split(Ve).map((e) => {
1359
- let n = He(e.replace(/\u0000/g, "|").trim()).filter((e) => e && !!e.trim()), r = [];
1360
- for (let e = 0, i = n.length; e < i; e += 1) {
1361
- let i = n[e], a = !1, o = -1;
1362
- for (; !a && ++o < ze;) {
1363
- let e = Re[o], n = e.isMultiMatch(i);
1364
- n && (r.push(new e(n, t)), a = !0);
1365
- }
1366
- if (!a) for (o = -1; ++o < ze;) {
1367
- let e = Re[o], n = e.isSingleMatch(i);
1368
- if (n) {
1369
- r.push(new e(n, t));
1370
- break;
1371
- }
1372
- }
1373
- }
1374
- return r;
1375
- });
1376
- }
1377
- var We = new Set([Ie.type, Le.type]), Ge = class {
1378
- constructor(e, { isCaseSensitive: t = W.isCaseSensitive, ignoreDiacritics: n = W.ignoreDiacritics, includeMatches: r = W.includeMatches, minMatchCharLength: i = W.minMatchCharLength, ignoreLocation: a = W.ignoreLocation, findAllMatches: o = W.findAllMatches, location: s = W.location, threshold: c = W.threshold, distance: l = W.distance } = {}) {
1379
- this.query = null, this.options = {
1380
- isCaseSensitive: t,
1381
- ignoreDiacritics: n,
1382
- includeMatches: r,
1383
- minMatchCharLength: i,
1384
- findAllMatches: o,
1385
- ignoreLocation: a,
1386
- location: s,
1387
- threshold: c,
1388
- distance: l
1389
- }, e = t ? e : e.toLowerCase(), e = n ? q(e) : e, this.pattern = e, this.query = Ue(this.pattern, this.options);
1390
- }
1391
- static condition(e, t) {
1392
- return t.useExtendedSearch;
1393
- }
1394
- searchIn(e) {
1395
- let t = this.query;
1396
- if (!t) return {
1397
- isMatch: !1,
1398
- score: 1
1399
- };
1400
- let { includeMatches: n, isCaseSensitive: r, ignoreDiacritics: i } = this.options;
1401
- e = r ? e : e.toLowerCase(), e = i ? q(e) : e;
1402
- let a = 0, o = [], s = 0, c = !1;
1403
- for (let r = 0, i = t.length; r < i; r += 1) {
1404
- let i = t[r];
1405
- o.length = 0, a = 0, c = !1;
1406
- for (let t = 0, r = i.length; t < r; t += 1) {
1407
- let r = i[t], { isMatch: l, indices: u, score: d } = r.search(e);
1408
- if (l) {
1409
- a += 1, s += d;
1410
- let e = r.constructor.type;
1411
- e.startsWith("inverse") && (c = !0), n && (We.has(e) ? o.push(...u) : o.push(u));
1412
- } else {
1413
- s = 0, a = 0, o.length = 0, c = !1;
1414
- break;
1415
- }
1416
- }
1417
- if (a) {
1418
- let e = {
1419
- isMatch: !0,
1420
- score: s / a
1421
- };
1422
- return c && (e.hasInverse = !0), n && (e.indices = Te(o)), e;
1423
- }
1424
- }
1425
- return {
1426
- isMatch: !1,
1427
- score: 1
1428
- };
1429
- }
1430
- }, Ke = [];
1431
- function qe(...e) {
1432
- Ke.push(...e);
1433
- }
1434
- function Y(e, t) {
1435
- for (let n = 0, r = Ke.length; n < r; n += 1) {
1436
- let r = Ke[n];
1437
- if (r.condition(e, t)) return new r(e, t);
1438
- }
1439
- return new Oe(e, t);
1440
- }
1441
- var X = {
1442
- AND: "$and",
1443
- OR: "$or"
1444
- }, Je = {
1445
- PATH: "$path",
1446
- PATTERN: "$val"
1447
- }, Ye = (e) => !!(e[X.AND] || e[X.OR]), Xe = (e) => !!e[Je.PATH], Ze = (e) => !F(e) && B(e) && !Ye(e), Qe = (e) => ({ [X.AND]: Object.keys(e).map((t) => ({ [t]: e[t] })) });
1448
- function $e(e, t, { auto: n = !0 } = {}) {
1449
- let r = (e) => {
1450
- if (R(e)) {
1451
- let r = {
1452
- keyId: null,
1453
- pattern: e
1454
- };
1455
- return n && (r.searcher = Y(e, t)), r;
1456
- }
1457
- let i = Object.keys(e), a = Xe(e);
1458
- if (!a && i.length > 1 && !Ye(e)) return r(Qe(e));
1459
- if (Ze(e)) {
1460
- let r = a ? e[Je.PATH] : i[0], o = a ? e[Je.PATTERN] : e[r];
1461
- if (!R(o)) throw Error(ae(r));
1462
- let s = {
1463
- keyId: U(r),
1464
- pattern: o
1465
- };
1466
- return n && (s.searcher = Y(o, t)), s;
1467
- }
1468
- let o = {
1469
- children: [],
1470
- operator: i[0]
1471
- };
1472
- return i.forEach((t) => {
1473
- let n = e[t];
1474
- F(n) && n.forEach((e) => {
1475
- o.children.push(r(e));
1476
- });
1477
- }), o;
1478
- };
1479
- return Ye(e) || (e = Qe(e)), r(e);
1480
- }
1481
- function Z(e, { ignoreFieldNorm: t = W.ignoreFieldNorm }) {
1482
- let n = 1;
1483
- return e.forEach(({ key: e, norm: r, score: i }) => {
1484
- let a = e ? e.weight : null;
1485
- n *= (i === 0 && a ? 2 ** -52 : i) ** +((a || 1) * (t ? 1 : r));
1486
- }), n;
1487
- }
1488
- function et(e, { ignoreFieldNorm: t = W.ignoreFieldNorm }) {
1489
- e.forEach((e) => {
1490
- e.score = Z(e.matches, { ignoreFieldNorm: t });
1491
- });
1492
- }
1493
- var tt = class {
1494
- constructor(e) {
1495
- this.limit = e, this.heap = [];
1496
- }
1497
- get size() {
1498
- return this.heap.length;
1499
- }
1500
- shouldInsert(e) {
1501
- return this.size < this.limit || e < this.heap[0].score;
1502
- }
1503
- insert(e) {
1504
- this.size < this.limit ? (this.heap.push(e), this._bubbleUp(this.size - 1)) : e.score < this.heap[0].score && (this.heap[0] = e, this._sinkDown(0));
1505
- }
1506
- extractSorted(e) {
1507
- return this.heap.sort(e);
1508
- }
1509
- _bubbleUp(e) {
1510
- let t = this.heap;
1511
- for (; e > 0;) {
1512
- let n = e - 1 >> 1;
1513
- if (t[e].score <= t[n].score) break;
1514
- let r = t[e];
1515
- t[e] = t[n], t[n] = r, e = n;
254
+ let t = e.toLowerCase(), r = o.find((e) => t.includes(e) || e.includes(t));
255
+ if (r) return n[r]?.(e, r);
1516
256
  }
1517
- }
1518
- _sinkDown(e) {
1519
- let t = this.heap, n = t.length, r = e;
1520
- do {
1521
- e = r;
1522
- let i = 2 * e + 1, a = 2 * e + 2;
1523
- if (i < n && t[i].score > t[r].score && (r = i), a < n && t[a].score > t[r].score && (r = a), r !== e) {
1524
- let n = t[e];
1525
- t[e] = t[r], t[r] = n;
1526
- }
1527
- } while (r !== e);
1528
- }
1529
- };
1530
- function nt(e, t) {
1531
- let n = e.matches;
1532
- t.matches = [], V(n) && n.forEach((e) => {
1533
- if (!V(e.indices) || !e.indices.length) return;
1534
- let { indices: n, value: r } = e, i = {
1535
- indices: n,
1536
- value: r
1537
- };
1538
- e.key && (i.key = e.key.src), e.idx > -1 && (i.refIndex = e.idx), t.matches.push(i);
1539
- });
1540
- }
1541
- function rt(e, t) {
1542
- t.score = e.score;
1543
- }
1544
- function it(e, t, { includeMatches: n = W.includeMatches, includeScore: r = W.includeScore } = {}) {
1545
- let i = [];
1546
- return n && i.push(nt), r && i.push(rt), e.map((e) => {
1547
- let { idx: n } = e, r = {
1548
- item: t[n],
1549
- refIndex: n
1550
- };
1551
- return i.length && i.forEach((t) => {
1552
- t(e, r);
1553
- }), r;
1554
- });
1555
- }
1556
- var at = /\b\w+\b/g;
1557
- function ot({ isCaseSensitive: e = !1, ignoreDiacritics: t = !1 } = {}) {
1558
- return { tokenize(n) {
1559
- return e || (n = n.toLowerCase()), t && (n = q(n)), n.match(at) || [];
1560
- } };
1561
- }
1562
- function st(e, t, n) {
1563
- let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0;
1564
- function o(e, t, o, s) {
1565
- let c = n.tokenize(e);
1566
- if (!c.length) return;
1567
- a++;
1568
- let l = /* @__PURE__ */ new Map();
1569
- for (let e of c) l.set(e, (l.get(e) || 0) + 1);
1570
- for (let [e, n] of l) {
1571
- let a = {
1572
- docIdx: t,
1573
- keyIdx: o,
1574
- subIdx: s,
1575
- tf: n
1576
- }, c = r.get(e);
1577
- c || (c = [], r.set(e, c)), c.push(a), i.set(e, (i.get(e) || 0) + 1);
1578
- }
1579
- }
1580
- for (let n of e) {
1581
- let { i: e, v: r, $: i } = n;
1582
- if (r !== void 0) {
1583
- o(r, e, -1, -1);
1584
- continue;
1585
- }
1586
- if (i) for (let n = 0; n < t; n++) {
1587
- let t = i[n];
1588
- if (t) if (Array.isArray(t)) for (let r of t) o(r.v, e, n, r.i ?? -1);
1589
- else o(t.v, e, n, -1);
1590
- }
1591
- }
1592
- return {
1593
- terms: r,
1594
- fieldCount: a,
1595
- df: i
257
+ return null;
1596
258
  };
1597
- }
1598
- function ct(e, t, n, r) {
1599
- let { i, v: a, $: o } = t;
1600
- function s(t, n, a) {
1601
- let o = r.tokenize(t);
1602
- if (!o.length) return;
1603
- e.fieldCount++;
1604
- let s = /* @__PURE__ */ new Map();
1605
- for (let e of o) s.set(e, (s.get(e) || 0) + 1);
1606
- for (let [t, r] of s) {
1607
- let o = {
1608
- docIdx: i,
1609
- keyIdx: n,
1610
- subIdx: a,
1611
- tf: r
1612
- }, s = e.terms.get(t);
1613
- s || (s = [], e.terms.set(t, s)), s.push(o), e.df.set(t, (e.df.get(t) || 0) + 1);
1614
- }
1615
- }
1616
- if (a !== void 0) {
1617
- s(a, -1, -1);
1618
- return;
1619
- }
1620
- if (o) for (let e = 0; e < n; e++) {
1621
- let t = o[e];
1622
- if (t) if (Array.isArray(t)) for (let n of t) s(n.v, e, n.i ?? -1);
1623
- else s(t.v, e, -1);
1624
- }
1625
- }
1626
- function lt(e, t) {
1627
- for (let [n, r] of e.terms) {
1628
- let i = r.filter((e) => e.docIdx !== t), a = r.length - i.length;
1629
- a > 0 && (e.fieldCount -= a, e.df.set(n, (e.df.get(n) || 0) - a), i.length === 0 ? (e.terms.delete(n), e.df.delete(n)) : e.terms.set(n, i));
1630
- }
1631
- }
1632
- var Q = class {
1633
- constructor(e, t, n) {
1634
- this.options = {
1635
- ...W,
1636
- ...t
1637
- }, this.options.useExtendedSearch, this.options.useTokenSearch, this._keyStore = new ue(this.options.keys), this._docs = e, this._myIndex = null, this._invertedIndex = null, this.setCollection(e, n), this._lastQuery = null, this._lastSearcher = null;
1638
- }
1639
- _getSearcher(e) {
1640
- if (this._lastQuery === e) return this._lastSearcher;
1641
- let t = Y(e, this._invertedIndex ? {
1642
- ...this.options,
1643
- _invertedIndex: this._invertedIndex
1644
- } : this.options);
1645
- return this._lastQuery = e, this._lastSearcher = t, t;
1646
- }
1647
- setCollection(e, t) {
1648
- if (this._docs = e, t && !(t instanceof G)) throw Error(ie);
1649
- if (this._myIndex = t || be(this.options.keys, this._docs, {
1650
- getFn: this.options.getFn,
1651
- fieldNormWeight: this.options.fieldNormWeight
1652
- }), this.options.useTokenSearch) {
1653
- let e = ot({
1654
- isCaseSensitive: this.options.isCaseSensitive,
1655
- ignoreDiacritics: this.options.ignoreDiacritics
1656
- });
1657
- this._invertedIndex = st(this._myIndex.records, this._myIndex.keys.length, e);
1658
- }
1659
- }
1660
- add(e) {
1661
- if (V(e) && (this._docs.push(e), this._myIndex.add(e), this._invertedIndex)) {
1662
- let e = this._myIndex.records[this._myIndex.records.length - 1], t = ot({
1663
- isCaseSensitive: this.options.isCaseSensitive,
1664
- ignoreDiacritics: this.options.ignoreDiacritics
1665
- });
1666
- ct(this._invertedIndex, e, this._myIndex.keys.length, t);
1667
- }
1668
- }
1669
- remove(e = () => !1) {
1670
- let t = [], n = [];
1671
- for (let r = 0, i = this._docs.length; r < i; r += 1) e(this._docs[r], r) && (t.push(this._docs[r]), n.push(r));
1672
- if (n.length) {
1673
- if (this._invertedIndex) for (let e of n) lt(this._invertedIndex, e);
1674
- for (let e = n.length - 1; e >= 0; --e) this._docs.splice(n[e], 1);
1675
- this._myIndex.removeAll(n);
1676
- }
1677
- return t;
1678
- }
1679
- removeAt(e) {
1680
- this._invertedIndex && lt(this._invertedIndex, e);
1681
- let t = this._docs.splice(e, 1)[0];
1682
- return this._myIndex.removeAt(e), t;
1683
- }
1684
- getIndex() {
1685
- return this._myIndex;
1686
- }
1687
- search(e, t) {
1688
- let { limit: n = -1 } = t || {}, { includeMatches: r, includeScore: i, shouldSort: a, sortFn: o, ignoreFieldNorm: s } = this.options;
1689
- if (R(e) && !e.trim()) {
1690
- let e = this._docs.map((e, t) => ({
1691
- item: e,
1692
- refIndex: t
1693
- }));
1694
- return z(n) && n > -1 && (e = e.slice(0, n)), e;
1695
- }
1696
- let c = z(n) && n > 0 && R(e), l;
1697
- if (c) {
1698
- let t = new tt(n);
1699
- R(this._docs[0]) ? this._searchStringList(e, {
1700
- heap: t,
1701
- ignoreFieldNorm: s
1702
- }) : this._searchObjectList(e, {
1703
- heap: t,
1704
- ignoreFieldNorm: s
1705
- }), l = t.extractSorted(o);
1706
- } else l = R(e) ? R(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e), et(l, { ignoreFieldNorm: s }), a && l.sort(o), z(n) && n > -1 && (l = l.slice(0, n));
1707
- return it(l, this._docs, {
1708
- includeMatches: r,
1709
- includeScore: i
1710
- });
1711
- }
1712
- _searchStringList(e, { heap: t, ignoreFieldNorm: n } = {}) {
1713
- let r = this._getSearcher(e), { records: i } = this._myIndex, a = t ? null : [];
1714
- return i.forEach(({ v: e, i, n: o }) => {
1715
- if (!V(e)) return;
1716
- let { isMatch: s, score: c, indices: l } = r.searchIn(e);
1717
- if (s) {
1718
- let r = {
1719
- item: e,
1720
- idx: i,
1721
- matches: [{
1722
- score: c,
1723
- value: e,
1724
- norm: o,
1725
- indices: l
1726
- }]
1727
- };
1728
- t ? (r.score = Z(r.matches, { ignoreFieldNorm: n }), t.shouldInsert(r.score) && t.insert(r)) : a.push(r);
1729
- }
1730
- }), a;
1731
- }
1732
- _searchLogical(e) {
1733
- let t = $e(e, this.options), n = (e, t, r) => {
1734
- if (!("children" in e)) {
1735
- let { keyId: n, searcher: i } = e, a;
1736
- return n === null ? (a = [], this._myIndex.keys.forEach((e, n) => {
1737
- a.push(...this._findMatches({
1738
- key: e,
1739
- value: t[n],
1740
- searcher: i
1741
- }));
1742
- })) : a = this._findMatches({
1743
- key: this._keyStore.get(n),
1744
- value: this._myIndex.getValueForItemAtKeyId(t, n),
1745
- searcher: i
1746
- }), a && a.length ? [{
1747
- idx: r,
1748
- item: t,
1749
- matches: a
1750
- }] : [];
1751
- }
1752
- let { children: i, operator: a } = e, o = [];
1753
- for (let e = 0, s = i.length; e < s; e += 1) {
1754
- let s = i[e], c = n(s, t, r);
1755
- if (c.length) o.push(...c);
1756
- else if (a === X.AND) return [];
1757
- }
1758
- return o;
1759
- }, r = this._myIndex.records, i = /* @__PURE__ */ new Map(), a = [];
1760
- return r.forEach(({ $: e, i: r }) => {
1761
- if (V(e)) {
1762
- let o = n(t, e, r);
1763
- o.length && (i.has(r) || (i.set(r, {
1764
- idx: r,
1765
- item: e,
1766
- matches: []
1767
- }), a.push(i.get(r))), o.forEach(({ matches: e }) => {
1768
- i.get(r).matches.push(...e);
1769
- }));
1770
- }
1771
- }), a;
1772
- }
1773
- _searchObjectList(e, { heap: t, ignoreFieldNorm: n } = {}) {
1774
- let r = this._getSearcher(e), { keys: i, records: a } = this._myIndex, o = t ? null : [];
1775
- return a.forEach(({ $: e, i: a }) => {
1776
- if (!V(e)) return;
1777
- let s = [], c = !1, l = !1;
1778
- if (i.forEach((t, n) => {
1779
- let i = this._findMatches({
1780
- key: t,
1781
- value: e[n],
1782
- searcher: r
1783
- });
1784
- i.length ? (s.push(...i), i[0].hasInverse && (l = !0)) : c = !0;
1785
- }), !(l && c) && s.length) {
1786
- let r = {
1787
- idx: a,
1788
- item: e,
1789
- matches: s
1790
- };
1791
- t ? (r.score = Z(r.matches, { ignoreFieldNorm: n }), t.shouldInsert(r.score) && t.insert(r)) : o.push(r);
1792
- }
1793
- }), o;
1794
- }
1795
- _findMatches({ key: e, value: t, searcher: n }) {
1796
- if (!V(t)) return [];
1797
- let r = [];
1798
- if (F(t)) t.forEach(({ v: t, i, n: a }) => {
1799
- if (!V(t)) return;
1800
- let { isMatch: o, score: s, indices: c, hasInverse: l } = n.searchIn(t);
1801
- o && r.push({
1802
- score: s,
1803
- key: e,
1804
- value: t,
1805
- idx: i,
1806
- norm: a,
1807
- indices: c,
1808
- hasInverse: l
1809
- });
1810
- });
1811
- else {
1812
- let { v: i, n: a } = t, { isMatch: o, score: s, indices: c, hasInverse: l } = n.searchIn(i);
1813
- o && r.push({
1814
- score: s,
1815
- key: e,
1816
- value: i,
1817
- norm: a,
1818
- indices: c,
1819
- hasInverse: l
1820
- });
1821
- }
1822
- return r;
1823
- }
1824
- }, ut = class {
1825
- static condition(e, t) {
1826
- return t.useTokenSearch;
1827
- }
1828
- constructor(e, t) {
1829
- this.options = t, this.analyzer = ot({
1830
- isCaseSensitive: t.isCaseSensitive,
1831
- ignoreDiacritics: t.ignoreDiacritics
1832
- });
1833
- let n = this.analyzer.tokenize(e), { df: r, fieldCount: i } = t._invertedIndex;
1834
- this.termSearchers = [], this.idfWeights = [];
1835
- for (let e of n) {
1836
- this.termSearchers.push(new Oe(e, {
1837
- location: t.location,
1838
- threshold: t.threshold,
1839
- distance: t.distance,
1840
- includeMatches: t.includeMatches,
1841
- findAllMatches: t.findAllMatches,
1842
- minMatchCharLength: t.minMatchCharLength,
1843
- isCaseSensitive: t.isCaseSensitive,
1844
- ignoreDiacritics: t.ignoreDiacritics,
1845
- ignoreLocation: !0
1846
- }));
1847
- let n = r.get(e) || 0, a = Math.log(1 + (i - n + .5) / (n + .5));
1848
- this.idfWeights.push(a);
1849
- }
1850
- }
1851
- searchIn(e) {
1852
- if (!this.termSearchers.length) return {
1853
- isMatch: !1,
1854
- score: 1
1855
- };
1856
- let t = [], n = 0, r = 0, i = 0;
1857
- for (let a = 0; a < this.termSearchers.length; a++) {
1858
- let o = this.termSearchers[a].searchIn(e), s = this.idfWeights[a];
1859
- r += s, o.isMatch && (i++, n += s * (1 - o.score), o.indices && t.push(...o.indices));
1860
- }
1861
- if (i === 0) return {
1862
- isMatch: !1,
1863
- score: 1
1864
- };
1865
- let a = r > 0 ? 1 - n / r : 0, o = {
1866
- isMatch: !0,
1867
- score: Math.max(.001, a)
1868
- };
1869
- return this.options.includeMatches && t.length && (o.indices = Te(t)), o;
1870
- }
1871
- };
1872
- Q.version = "7.3.0", Q.createIndex = be, Q.parseIndex = xe, Q.config = W, Q.match = function(e, t, n) {
1873
- return Y(e, {
1874
- ...W,
1875
- ...n
1876
- }).searchIn(t);
1877
- }, Q.parseQuery = $e, qe(Ge), qe(ut), Q.use = function(...e) {
1878
- e.forEach((e) => qe(e));
1879
- };
1880
- //#endregion
1881
- //#region src/hooks/useCommands.js
1882
- var dt = (e, t = .4) => (e = e ? Object.entries(e)?.reduce((e, [t, n]) => ({ [t.toLowerCase()]: n }), {}) : {}, (n) => {
1883
- let r = new Q(Object.keys(e), {
1884
- includeScore: !0,
1885
- ignoreLocation: !0
1886
- }).search(n).filter((e) => e.score < t);
1887
- if (r?.length) {
1888
- let t = r[0].item.toLowerCase();
1889
- return e[t]?.(n);
1890
- }
1891
- return null;
1892
- }), ft = /* @__PURE__ */ o(((e) => {
259
+ }, k = /* @__PURE__ */ s(((e) => {
1893
260
  var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
1894
261
  function r(e, n, r) {
1895
262
  var i = null;
@@ -1904,7 +271,7 @@ var dt = (e, t = .4) => (e = e ? Object.entries(e)?.reduce((e, [t, n]) => ({ [t.
1904
271
  };
1905
272
  }
1906
273
  e.Fragment = n, e.jsx = r, e.jsxs = r;
1907
- })), pt = /* @__PURE__ */ o(((e) => {
274
+ })), A = /* @__PURE__ */ s(((e) => {
1908
275
  process.env.NODE_ENV !== "production" && (function() {
1909
276
  function t(e) {
1910
277
  if (e == null) return null;
@@ -1967,7 +334,7 @@ var dt = (e, t = .4) => (e = e ? Object.entries(e)?.reduce((e, [t, n]) => ({ [t.
1967
334
  function o() {
1968
335
  return Error("react-stack-top-frame");
1969
336
  }
1970
- function c(e) {
337
+ function s(e) {
1971
338
  if (j.call(e, "key")) {
1972
339
  var t = Object.getOwnPropertyDescriptor(e, "key").get;
1973
340
  if (t && t.isReactWarning) return !1;
@@ -1985,7 +352,7 @@ var dt = (e, t = .4) => (e = e ? Object.entries(e)?.reduce((e, [t, n]) => ({ [t.
1985
352
  }
1986
353
  function u() {
1987
354
  var e = t(this.type);
1988
- return ee[e] || (ee[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
355
+ return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
1989
356
  }
1990
357
  function d(e, t, n, r, i, a) {
1991
358
  var o = n.ref;
@@ -2023,7 +390,7 @@ var dt = (e, t = .4) => (e = e ? Object.entries(e)?.reduce((e, [t, n]) => ({ [t.
2023
390
  value: a
2024
391
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
2025
392
  }
2026
- function f(e, n, i, o, s, u) {
393
+ function f(e, n, i, o, c, u) {
2027
394
  var f = n.children;
2028
395
  if (f !== void 0) if (o) if (M(f)) {
2029
396
  for (o = 0; o < f.length; o++) p(f[o]);
@@ -2035,11 +402,11 @@ var dt = (e, t = .4) => (e = e ? Object.entries(e)?.reduce((e, [t, n]) => ({ [t.
2035
402
  var m = Object.keys(n).filter(function(e) {
2036
403
  return e !== "key";
2037
404
  });
2038
- o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", L[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), L[f + o] = !0);
405
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), R[f + o] = !0);
2039
406
  }
2040
- if (f = null, i !== void 0 && (r(i), f = "" + i), c(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
407
+ if (f = null, i !== void 0 && (r(i), f = "" + i), s(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
2041
408
  else i = n;
2042
- return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, a(), s, u);
409
+ return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, a(), c, u);
2043
410
  }
2044
411
  function p(e) {
2045
412
  m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
@@ -2047,105 +414,154 @@ var dt = (e, t = .4) => (e = e ? Object.entries(e)?.reduce((e, [t, n]) => ({ [t.
2047
414
  function m(e) {
2048
415
  return typeof e == "object" && !!e && e.$$typeof === g;
2049
416
  }
2050
- var h = s("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
417
+ var h = c("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
2051
418
  return null;
2052
419
  };
2053
420
  h = { react_stack_bottom_frame: function(e) {
2054
421
  return e();
2055
422
  } };
2056
- var P, ee = {}, F = h.react_stack_bottom_frame.bind(h, o)(), I = N(i(o)), L = {};
423
+ var P, F = {}, I = h.react_stack_bottom_frame.bind(h, o)(), L = N(i(o)), R = {};
2057
424
  e.Fragment = v, e.jsx = function(e, t, n) {
2058
425
  var r = 1e4 > A.recentlyCreatedOwnerStacks++;
2059
- return f(e, t, n, !1, r ? Error("react-stack-top-frame") : F, r ? N(i(e)) : I);
426
+ return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
2060
427
  }, e.jsxs = function(e, t, n) {
2061
428
  var r = 1e4 > A.recentlyCreatedOwnerStacks++;
2062
- return f(e, t, n, !0, r ? Error("react-stack-top-frame") : F, r ? N(i(e)) : I);
429
+ return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
2063
430
  };
2064
431
  })();
2065
- })), $ = (/* @__PURE__ */ o(((e, t) => {
2066
- process.env.NODE_ENV === "production" ? t.exports = ft() : t.exports = pt();
2067
- })))(), mt = ({ color: e = "black", activeColor: t = "red", isActive: n = !1 }) => /* @__PURE__ */ (0, $.jsx)("svg", {
432
+ })), j = (/* @__PURE__ */ s(((e, t) => {
433
+ process.env.NODE_ENV === "production" ? t.exports = k() : t.exports = A();
434
+ })))(), M = ({ color: e = "black", activeColor: t = "red", isActive: n = !1 }) => /* @__PURE__ */ (0, j.jsx)("svg", {
2068
435
  "data-testid": "__icon-root__",
2069
436
  xmlns: "http://www.w3.org/2000/svg",
2070
437
  width: "100%",
2071
438
  height: "100%",
2072
439
  viewBox: "0 0 24 24",
2073
- children: /* @__PURE__ */ (0, $.jsxs)("g", { children: [/* @__PURE__ */ (0, $.jsx)("path", {
440
+ "aria-hidden": "true",
441
+ children: /* @__PURE__ */ (0, j.jsxs)("g", { children: [/* @__PURE__ */ (0, j.jsx)("path", {
2074
442
  "data-testid": "__icon-path__",
2075
443
  fill: e,
2076
444
  d: "M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"
2077
- }), n && /* @__PURE__ */ (0, $.jsx)("circle", {
445
+ }), n && /* @__PURE__ */ (0, j.jsx)("circle", {
2078
446
  "data-testid": "__icon-active__",
2079
447
  fill: t,
2080
448
  cx: "16",
2081
449
  cy: "4",
2082
450
  r: "4"
2083
451
  })] })
2084
- }), ht = ({ children: n, commands: r = null, lang: o = "en-US", grammars: s = null, timeout: c = 3e3, ariaLabel: l = "start recognition", style: u = null, className: d = null, outlineStyle: f = "2px solid", onStart: p = null, onEnd: m = null, onSpeechStart: h = null, onSpeechEnd: g = null, onResult: _ = null, onError: v = null, onNoMatch: y = null, __rsInstance: b }) => {
2085
- let x = i(null), [S, C] = a(!1), [, { start: w, stop: T, subscribe: E, unsubscribe: D }] = P(o, s, b), O = dt(r), k = (e) => {
2086
- j(), I(), ie(), m?.(e);
2087
- }, [A, j] = ee(k, c), F = () => {
452
+ }), N = (e, t) => {
453
+ for (let n of e) for (let e of n) if (t(e.transcript ?? "") !== null) return;
454
+ }, P = ({ children: r, commands: o = null, lang: s = "en-US", grammars: c = null, timeout: l = 3e3, silenceTimeout: u = null, precision: d = .4, maxAlternatives: f = 1, continuous: p = !1, ariaLabel: m = "start recognition", style: h = null, className: g = null, outlineStyle: _ = "2px solid", onStart: v = null, onEnd: y = null, onSpeechStart: b = null, onSpeechEnd: x = null, onResult: S = null, onError: w = null, onNoMatch: k = null, signal: A = null, __rsInstance: P }) => {
455
+ let F = a(null), I = i(() => C(), []), [, { start: L, stop: R, subscribe: ee, unsubscribe: te, isRecording: z }] = E(s, c, f, p, P), B = O(o, d), V = a({});
456
+ V.current = {
457
+ onStart: v,
458
+ onEnd: y,
459
+ onSpeechStart: b,
460
+ onSpeechEnd: x,
461
+ onResult: S,
462
+ onError: w,
463
+ onNoMatch: k
464
+ };
465
+ let H = a(p);
466
+ H.current = p;
467
+ let U = a(B);
468
+ U.current = B;
469
+ let W = a(null), ne = a(null), G = a(!1), re = a(u);
470
+ re.current = u;
471
+ let ie = n(() => ne.current?.(), []), [K, q] = D(ie, l), [ae, J] = D(ie, u ?? 0), Y = n(() => {
2088
472
  try {
2089
- C(!0), re(), w();
473
+ R();
2090
474
  } catch (e) {
2091
- V(e);
475
+ V.current.onError?.(e), W.current?.();
476
+ }
477
+ }, [R]), oe = n((e) => {
478
+ K(), V.current.onStart?.(e);
479
+ }, [K]), se = n((e) => {
480
+ q(), V.current.onSpeechStart?.(e);
481
+ }, [q]), ce = n((e) => {
482
+ K(), H.current && re.current > 0 && ae(), V.current.onSpeechEnd?.(e);
483
+ }, [K, ae]), le = n((e, t) => {
484
+ q(), H.current || (N(e?.results ?? [], U.current), Y()), V.current.onResult?.(t, e);
485
+ }, [q, Y]), X = n((e) => {
486
+ Y(), V.current.onError?.(e);
487
+ }, [Y]), ue = n((e) => {
488
+ q(), Y(), V.current.onNoMatch?.(e);
489
+ }, [q, Y]), Z = n((e) => {
490
+ if (!G.current) {
491
+ G.current = !0, q(), J();
492
+ try {
493
+ Y(), W.current?.();
494
+ } finally {
495
+ G.current = !1, V.current.onEnd?.(e);
496
+ }
2092
497
  }
2093
- }, I = () => {
498
+ }, [
499
+ q,
500
+ J,
501
+ Y
502
+ ]);
503
+ ne.current = Z;
504
+ let Q = i(() => ({
505
+ start: oe,
506
+ end: Z,
507
+ speechstart: se,
508
+ speechend: ce,
509
+ result: le,
510
+ error: X,
511
+ nomatch: ue
512
+ }), [
513
+ oe,
514
+ Z,
515
+ se,
516
+ ce,
517
+ le,
518
+ X,
519
+ ue
520
+ ]);
521
+ W.current = () => Object.entries(Q).forEach(([e, t]) => te?.(e, t));
522
+ let $ = n(() => {
2094
523
  try {
2095
- C(!1), T();
524
+ J(), Object.entries(Q).forEach(([e, t]) => ee(e, t)), L({ signal: A })?.catch?.(X);
2096
525
  } catch (e) {
2097
- v?.(e);
2098
- }
2099
- }, L = () => {
2100
- !d && f && (x.current.style.outline = f);
2101
- }, R = () => {
2102
- !d && f && (x.current.style.outline = "none");
2103
- }, z = (e) => {
2104
- A(), p?.(e);
2105
- }, te = (e) => {
2106
- j(), h?.(e);
2107
- }, B = (e) => {
2108
- A(), g?.(e);
2109
- }, ne = (e, t) => {
2110
- j(), I(), O(t), _?.(t, e);
2111
- }, V = (e) => {
2112
- I(), v?.(e);
2113
- }, H = {
2114
- start: z,
2115
- end: k,
2116
- speechstart: te,
2117
- speechend: B,
2118
- result: ne,
2119
- error: V,
2120
- nomatch: (e) => {
2121
- j(), I(), y?.(e);
526
+ X(e);
2122
527
  }
2123
- }, re = () => Object.entries(H).forEach(([e, t]) => E(e, t)), ie = () => Object.entries(H).forEach(([e, t]) => D(e, t));
2124
- return M.isSupported ? N(n) ? n(F, I, S) : t(n) ? e(n, { ...!S && { onClick: F } }) : /* @__PURE__ */ (0, $.jsx)("button", {
528
+ }, [
529
+ Q,
530
+ ee,
531
+ L,
532
+ J,
533
+ X,
534
+ A
535
+ ]), de = () => {
536
+ !g && _ && (F.current.style.outline = _);
537
+ }, fe = () => {
538
+ !g && _ && (F.current.style.outline = "none");
539
+ };
540
+ return I ? T(r) ? r($, Y, z) : t(r) ? e(r, { ...!z && { onClick: $ } }) : /* @__PURE__ */ (0, j.jsx)("button", {
2125
541
  "data-testid": "__vocal-root__",
2126
- ref: x,
2127
- role: "button",
2128
- "aria-label": l,
2129
- style: d ? null : {
542
+ ref: F,
543
+ "aria-label": m,
544
+ "aria-pressed": z,
545
+ style: g ? null : {
2130
546
  width: 24,
2131
547
  height: 24,
2132
548
  backgroundColor: "transparent",
2133
549
  border: "none",
2134
550
  padding: 0,
2135
- cursor: S ? "default" : "pointer",
2136
- ...u
551
+ cursor: !p && z ? "default" : "pointer",
552
+ ...h
2137
553
  },
2138
- className: d,
2139
- onFocus: L,
2140
- onBlur: R,
2141
- onClick: F,
2142
- children: /* @__PURE__ */ (0, $.jsx)(mt, {
2143
- isActive: S,
554
+ className: g,
555
+ onFocus: de,
556
+ onBlur: fe,
557
+ onClick: z ? Y : $,
558
+ children: /* @__PURE__ */ (0, j.jsx)(M, {
559
+ isActive: z,
2144
560
  color: "#aaa"
2145
561
  })
2146
562
  }) : null;
2147
- }, gt = M.isSupported, _t = ht;
563
+ };
2148
564
  //#endregion
2149
- export { _t as default, gt as isSupported, P as useVocal };
565
+ export { P as default, C as isSupported, E as useVocal };
2150
566
 
2151
567
  //# sourceMappingURL=index.es.js.map