interview-widget 0.1.4 → 0.1.6
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.
package/dist/widget.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var ve = Object.defineProperty;
|
|
2
|
-
var je = (
|
|
3
|
-
var D = (
|
|
4
|
-
import
|
|
2
|
+
var je = (r, i, e) => i in r ? ve(r, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[i] = e;
|
|
3
|
+
var D = (r, i, e) => je(r, typeof i != "symbol" ? i + "" : i, e);
|
|
4
|
+
import le, { createContext as Ne, useContext as Te, useRef as S, useState as k, useEffect as P, useCallback as A, useMemo as J } from "react";
|
|
5
5
|
import { createPortal as ke } from "react-dom";
|
|
6
|
-
var
|
|
6
|
+
var we = { exports: {} }, X = {};
|
|
7
7
|
/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react-jsx-runtime.production.js
|
|
@@ -14,27 +14,27 @@ var le = { exports: {} }, X = {};
|
|
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
|
15
15
|
*/
|
|
16
16
|
var Ie = Symbol.for("react.transitional.element"), Ee = Symbol.for("react.fragment");
|
|
17
|
-
function
|
|
18
|
-
var
|
|
19
|
-
if (e !== void 0 && (
|
|
17
|
+
function ue(r, i, e) {
|
|
18
|
+
var a = null;
|
|
19
|
+
if (e !== void 0 && (a = "" + e), i.key !== void 0 && (a = "" + i.key), "key" in i) {
|
|
20
20
|
e = {};
|
|
21
|
-
for (var s in
|
|
22
|
-
s !== "key" && (e[s] =
|
|
23
|
-
} else e =
|
|
24
|
-
return
|
|
21
|
+
for (var s in i)
|
|
22
|
+
s !== "key" && (e[s] = i[s]);
|
|
23
|
+
} else e = i;
|
|
24
|
+
return i = e.ref, {
|
|
25
25
|
$$typeof: Ie,
|
|
26
|
-
type:
|
|
27
|
-
key:
|
|
28
|
-
ref:
|
|
26
|
+
type: r,
|
|
27
|
+
key: a,
|
|
28
|
+
ref: i !== void 0 ? i : null,
|
|
29
29
|
props: e
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
X.Fragment = Ee;
|
|
33
|
-
X.jsx =
|
|
34
|
-
X.jsxs =
|
|
35
|
-
|
|
36
|
-
var t =
|
|
37
|
-
const
|
|
33
|
+
X.jsx = ue;
|
|
34
|
+
X.jsxs = ue;
|
|
35
|
+
we.exports = X;
|
|
36
|
+
var t = we.exports;
|
|
37
|
+
const L = {
|
|
38
38
|
api: {
|
|
39
39
|
baseUrl: "/api",
|
|
40
40
|
retryConfig: {
|
|
@@ -62,66 +62,66 @@ const O = {
|
|
|
62
62
|
provider: "piper"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
},
|
|
65
|
+
}, he = Ne(
|
|
66
66
|
null
|
|
67
67
|
);
|
|
68
68
|
function Re({
|
|
69
|
-
config:
|
|
70
|
-
children:
|
|
69
|
+
config: r = {},
|
|
70
|
+
children: i
|
|
71
71
|
}) {
|
|
72
|
-
var
|
|
72
|
+
var a, s, c, o;
|
|
73
73
|
const e = {
|
|
74
74
|
api: {
|
|
75
|
-
...
|
|
76
|
-
...
|
|
75
|
+
...L.api,
|
|
76
|
+
...r.api,
|
|
77
77
|
retryConfig: {
|
|
78
|
-
...
|
|
79
|
-
...(
|
|
78
|
+
...L.api.retryConfig,
|
|
79
|
+
...(a = r.api) == null ? void 0 : a.retryConfig
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
ui: {
|
|
83
|
-
...
|
|
84
|
-
...
|
|
83
|
+
...L.ui,
|
|
84
|
+
...r.ui
|
|
85
85
|
},
|
|
86
86
|
interview: {
|
|
87
|
-
...
|
|
88
|
-
...
|
|
87
|
+
...L.interview,
|
|
88
|
+
...r.interview,
|
|
89
89
|
timers: {
|
|
90
|
-
...
|
|
91
|
-
...(s =
|
|
90
|
+
...L.interview.timers,
|
|
91
|
+
...(s = r.interview) == null ? void 0 : s.timers
|
|
92
92
|
},
|
|
93
93
|
stt: {
|
|
94
|
-
...
|
|
95
|
-
...(c =
|
|
94
|
+
...L.interview.stt,
|
|
95
|
+
...(c = r.interview) == null ? void 0 : c.stt
|
|
96
96
|
},
|
|
97
97
|
tts: {
|
|
98
|
-
...
|
|
99
|
-
...(
|
|
98
|
+
...L.interview.tts,
|
|
99
|
+
...(o = r.interview) == null ? void 0 : o.tts
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
return /* @__PURE__ */ t.jsx(
|
|
103
|
+
return /* @__PURE__ */ t.jsx(he.Provider, { value: e, children: i });
|
|
104
104
|
}
|
|
105
105
|
function Z() {
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
106
|
+
const r = Te(he);
|
|
107
|
+
if (!r)
|
|
108
108
|
throw new Error(
|
|
109
109
|
"useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>"
|
|
110
110
|
);
|
|
111
|
-
return
|
|
111
|
+
return r;
|
|
112
112
|
}
|
|
113
113
|
function Se() {
|
|
114
|
-
return Z().api ||
|
|
114
|
+
return Z().api || L.api;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
return Z().ui ||
|
|
116
|
+
function Y() {
|
|
117
|
+
return Z().ui || L.ui;
|
|
118
118
|
}
|
|
119
119
|
function Ce() {
|
|
120
|
-
return Z().interview ||
|
|
120
|
+
return Z().interview || L.interview;
|
|
121
121
|
}
|
|
122
|
-
const
|
|
123
|
-
className:
|
|
124
|
-
...
|
|
122
|
+
const me = ({
|
|
123
|
+
className: r,
|
|
124
|
+
...i
|
|
125
125
|
}) => /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsxs(
|
|
126
126
|
"svg",
|
|
127
127
|
{
|
|
@@ -134,8 +134,8 @@ const ue = ({
|
|
|
134
134
|
strokeWidth: "2",
|
|
135
135
|
strokeLinecap: "round",
|
|
136
136
|
strokeLinejoin: "round",
|
|
137
|
-
className: `iw-animate-spin ${
|
|
138
|
-
...
|
|
137
|
+
className: `iw-animate-spin ${r}`,
|
|
138
|
+
...i,
|
|
139
139
|
children: [
|
|
140
140
|
/* @__PURE__ */ t.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
141
141
|
/* @__PURE__ */ t.jsx("path", { d: "M12 6l0 -3" }),
|
|
@@ -148,73 +148,73 @@ const ue = ({
|
|
|
148
148
|
/* @__PURE__ */ t.jsx("path", { d: "M7.75 7.75l-2.15 -2.15" })
|
|
149
149
|
]
|
|
150
150
|
}
|
|
151
|
-
) }),
|
|
152
|
-
children:
|
|
153
|
-
variant:
|
|
151
|
+
) }), ne = ({
|
|
152
|
+
children: r,
|
|
153
|
+
variant: i = "primary",
|
|
154
154
|
size: e = "md",
|
|
155
|
-
fullWidth:
|
|
155
|
+
fullWidth: a = !1,
|
|
156
156
|
isLoading: s = !1,
|
|
157
157
|
disabled: c,
|
|
158
|
-
className:
|
|
159
|
-
...
|
|
158
|
+
className: o = "",
|
|
159
|
+
...n
|
|
160
160
|
}) => {
|
|
161
|
-
const
|
|
161
|
+
const l = "iw-inline-flex iw-items-center iw-justify-center iw-rounded-md iw-font-medium iw-transition-colors iw-focus:outline-none iw-focus:ring-2 iw-focus:ring-primary-500 iw-focus:ring-offset-2", m = {
|
|
162
162
|
primary: "iw-bg-primary-600 iw-text-white iw-hover:bg-primary-700 iw-border iw-border-transparent",
|
|
163
163
|
secondary: "iw-bg-primary-100 iw-text-primary-700 iw-hover:bg-primary-200 iw-border iw-border-transparent",
|
|
164
164
|
outline: "iw-bg-transparent iw-text-primary-700 iw-border iw-border-primary-500 iw-hover:bg-primary-50",
|
|
165
165
|
text: "iw-bg-transparent iw-text-primary-600 iw-hover:bg-primary-50 iw-border iw-border-transparent",
|
|
166
166
|
gradient: "iw-text-white iw-border iw-border-transparent iw-bg-gradient-to-r iw-from-purple-500 iw-to-indigo-500 hover:iw-from-purple-600 hover:iw-to-indigo-600"
|
|
167
|
-
},
|
|
167
|
+
}, w = {
|
|
168
168
|
sm: "iw-px-3 iw-py-1.5 iw-text-sm",
|
|
169
169
|
md: "iw-px-4 iw-py-2.5 iw-text-sm",
|
|
170
170
|
lg: "iw-px-5 iw-py-3 iw-text-base"
|
|
171
|
-
}, h = "iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none", u =
|
|
171
|
+
}, h = "iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none", u = a ? "iw-w-full" : "";
|
|
172
172
|
return /* @__PURE__ */ t.jsxs(
|
|
173
173
|
"button",
|
|
174
174
|
{
|
|
175
|
-
className: `${
|
|
175
|
+
className: `${l} ${m[i]} ${w[e]} ${u} ${h} ${o}`,
|
|
176
176
|
disabled: c || s,
|
|
177
|
-
...
|
|
177
|
+
...n,
|
|
178
178
|
children: [
|
|
179
|
-
s && /* @__PURE__ */ t.jsx(
|
|
180
|
-
|
|
179
|
+
s && /* @__PURE__ */ t.jsx(me, { height: 16, width: 16, style: { marginRight: "3px" } }),
|
|
180
|
+
r
|
|
181
181
|
]
|
|
182
182
|
}
|
|
183
183
|
);
|
|
184
184
|
};
|
|
185
|
-
function Me(
|
|
186
|
-
const
|
|
187
|
-
return
|
|
188
|
-
r: parseInt(
|
|
189
|
-
g: parseInt(
|
|
190
|
-
b: parseInt(
|
|
185
|
+
function Me(r) {
|
|
186
|
+
const i = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);
|
|
187
|
+
return i ? {
|
|
188
|
+
r: parseInt(i[1], 16),
|
|
189
|
+
g: parseInt(i[2], 16),
|
|
190
|
+
b: parseInt(i[3], 16)
|
|
191
191
|
} : null;
|
|
192
192
|
}
|
|
193
|
-
function Ae(
|
|
194
|
-
return "#" + [
|
|
195
|
-
const s = Math.round(
|
|
193
|
+
function Ae(r, i, e) {
|
|
194
|
+
return "#" + [r, i, e].map((a) => {
|
|
195
|
+
const s = Math.round(a).toString(16);
|
|
196
196
|
return s.length === 1 ? "0" + s : s;
|
|
197
197
|
}).join("");
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
const e = Me(
|
|
201
|
-
if (!e) return
|
|
202
|
-
const
|
|
203
|
-
return Ae(
|
|
199
|
+
function ge(r, i) {
|
|
200
|
+
const e = Me(r);
|
|
201
|
+
if (!e) return r;
|
|
202
|
+
const a = e.r + (255 - e.r) * i, s = e.g + (255 - e.g) * i, c = e.b + (255 - e.b) * i;
|
|
203
|
+
return Ae(a, s, c);
|
|
204
204
|
}
|
|
205
|
-
function De(
|
|
205
|
+
function De(r, i = 0.8) {
|
|
206
206
|
return {
|
|
207
|
-
background: `linear-gradient(to bottom, ${
|
|
207
|
+
background: `linear-gradient(to bottom, ${ge(r, i)}, #ffffff)`,
|
|
208
208
|
color: "#1f2937"
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
function Pe(
|
|
212
|
-
return new Promise((
|
|
211
|
+
function Pe(r) {
|
|
212
|
+
return new Promise((i) => setTimeout(i, r));
|
|
213
213
|
}
|
|
214
|
-
function
|
|
215
|
-
return `linear-gradient(to left, ${
|
|
214
|
+
function fe(r) {
|
|
215
|
+
return `linear-gradient(to left, ${ge(r, 0.4)}, ${r})`;
|
|
216
216
|
}
|
|
217
|
-
const $e = (
|
|
217
|
+
const $e = (r) => /* @__PURE__ */ t.jsxs(
|
|
218
218
|
"svg",
|
|
219
219
|
{
|
|
220
220
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -226,7 +226,7 @@ const $e = (i) => /* @__PURE__ */ t.jsxs(
|
|
|
226
226
|
strokeWidth: "2",
|
|
227
227
|
strokeLinecap: "round",
|
|
228
228
|
strokeLinejoin: "round",
|
|
229
|
-
...
|
|
229
|
+
...r,
|
|
230
230
|
children: [
|
|
231
231
|
/* @__PURE__ */ t.jsx("path", { d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" }),
|
|
232
232
|
/* @__PURE__ */ t.jsx("path", { d: "m9 12 2 2 4-4" })
|
|
@@ -240,40 +240,40 @@ const $e = (i) => /* @__PURE__ */ t.jsxs(
|
|
|
240
240
|
"Do not disable or interfere with audio/video monitoring",
|
|
241
241
|
"All activities are being recorded, and any violations may result in penalties, including disqualification"
|
|
242
242
|
], Le = ({
|
|
243
|
-
isOpen:
|
|
244
|
-
onStart:
|
|
243
|
+
isOpen: r,
|
|
244
|
+
onStart: i,
|
|
245
245
|
onClose: e
|
|
246
246
|
}) => {
|
|
247
|
-
var
|
|
248
|
-
const
|
|
249
|
-
s.current && (s.current.getTracks().forEach((
|
|
250
|
-
},
|
|
251
|
-
u(!0),
|
|
247
|
+
var I;
|
|
248
|
+
const a = S(null), s = S(null), { baseColor: c, borderRadius: o } = Y(), [n, l] = k(!1), [m, w] = k(null), [h, u] = k(!1), g = () => {
|
|
249
|
+
s.current && (s.current.getTracks().forEach((d) => d.stop()), s.current = null);
|
|
250
|
+
}, j = async () => {
|
|
251
|
+
u(!0), w(null);
|
|
252
252
|
try {
|
|
253
|
-
const
|
|
253
|
+
const d = await navigator.mediaDevices.getUserMedia({
|
|
254
254
|
video: { width: { ideal: 1280 }, height: { ideal: 720 } },
|
|
255
255
|
audio: !0
|
|
256
256
|
});
|
|
257
|
-
s.current =
|
|
258
|
-
} catch (
|
|
259
|
-
console.error("Media permission error:",
|
|
260
|
-
let
|
|
261
|
-
(
|
|
257
|
+
s.current = d, a.current && (a.current.srcObject = d), l(!0);
|
|
258
|
+
} catch (d) {
|
|
259
|
+
console.error("Media permission error:", d);
|
|
260
|
+
let x = "Unable to access camera or microphone.";
|
|
261
|
+
(d == null ? void 0 : d.name) === "NotAllowedError" ? x = "Permissions denied. Please allow access to camera and microphone." : (d == null ? void 0 : d.name) === "NotFoundError" ? x = "No camera/microphone found. Please connect a device and retry." : d != null && d.message && (x = d.message), l(!1), w(x);
|
|
262
262
|
} finally {
|
|
263
263
|
u(!1);
|
|
264
264
|
}
|
|
265
265
|
};
|
|
266
|
-
if (
|
|
267
|
-
if (!
|
|
268
|
-
|
|
266
|
+
if (P(() => {
|
|
267
|
+
if (!r) {
|
|
268
|
+
g();
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
return
|
|
272
|
-
|
|
271
|
+
return j(), () => {
|
|
272
|
+
g();
|
|
273
273
|
};
|
|
274
|
-
}, [
|
|
275
|
-
const
|
|
276
|
-
|
|
274
|
+
}, [r]), !r) return null;
|
|
275
|
+
const y = () => {
|
|
276
|
+
i(), g();
|
|
277
277
|
};
|
|
278
278
|
return /* @__PURE__ */ t.jsx("div", { className: "iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-black/50 iw-backdrop-blur-sm", children: /* @__PURE__ */ t.jsxs("div", { className: "iw-bg-white iw-rounded-xl iw-shadow-2xl iw-w-full iw-max-w-[800px] iw-mx-4", children: [
|
|
279
279
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-px-5 iw-py-4 iw-border-b iw-border-gray-200 iw-flex iw-items-center iw-justify-between", children: [
|
|
@@ -284,7 +284,7 @@ const $e = (i) => /* @__PURE__ */ t.jsxs(
|
|
|
284
284
|
"aria-label": "Close",
|
|
285
285
|
className: "iw-text-gray-500 hover:iw-text-gray-700",
|
|
286
286
|
onClick: () => {
|
|
287
|
-
|
|
287
|
+
g(), e == null || e();
|
|
288
288
|
},
|
|
289
289
|
children: "✕"
|
|
290
290
|
}
|
|
@@ -295,7 +295,7 @@ const $e = (i) => /* @__PURE__ */ t.jsxs(
|
|
|
295
295
|
/* @__PURE__ */ t.jsx("div", { className: "iw-border iw-border-gray-200 iw-rounded-lg iw-overflow-hidden iw-bg-gray-900", children: /* @__PURE__ */ t.jsx(
|
|
296
296
|
"video",
|
|
297
297
|
{
|
|
298
|
-
ref:
|
|
298
|
+
ref: a,
|
|
299
299
|
autoPlay: !0,
|
|
300
300
|
playsInline: !0,
|
|
301
301
|
muted: !0,
|
|
@@ -307,29 +307,29 @@ const $e = (i) => /* @__PURE__ */ t.jsxs(
|
|
|
307
307
|
) }),
|
|
308
308
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-grid iw-grid-cols-2 iw-gap-2 iw-mt-3", children: [
|
|
309
309
|
/* @__PURE__ */ t.jsx(
|
|
310
|
-
|
|
310
|
+
ne,
|
|
311
311
|
{
|
|
312
|
-
onClick:
|
|
312
|
+
onClick: j,
|
|
313
313
|
disabled: h,
|
|
314
314
|
variant: "outline",
|
|
315
315
|
size: "sm",
|
|
316
316
|
style: {
|
|
317
317
|
borderColor: c,
|
|
318
|
-
borderRadius:
|
|
318
|
+
borderRadius: o,
|
|
319
319
|
color: c
|
|
320
320
|
},
|
|
321
|
-
children:
|
|
321
|
+
children: n ? "Recheck Permissions" : "Enable Camera & Mic"
|
|
322
322
|
}
|
|
323
323
|
),
|
|
324
324
|
/* @__PURE__ */ t.jsx(
|
|
325
|
-
|
|
325
|
+
ne,
|
|
326
326
|
{
|
|
327
|
-
onClick:
|
|
328
|
-
disabled: !
|
|
327
|
+
onClick: y,
|
|
328
|
+
disabled: !n,
|
|
329
329
|
size: "sm",
|
|
330
330
|
style: {
|
|
331
|
-
background:
|
|
332
|
-
borderRadius:
|
|
331
|
+
background: fe(c),
|
|
332
|
+
borderRadius: o
|
|
333
333
|
},
|
|
334
334
|
children: "Start Interview"
|
|
335
335
|
}
|
|
@@ -341,14 +341,14 @@ const $e = (i) => /* @__PURE__ */ t.jsxs(
|
|
|
341
341
|
/* @__PURE__ */ t.jsx($e, {}),
|
|
342
342
|
/* @__PURE__ */ t.jsx("h3", { children: "Interview Guidelines" })
|
|
343
343
|
] }),
|
|
344
|
-
!((
|
|
345
|
-
|
|
346
|
-
/* @__PURE__ */ t.jsx("ul", { className: "iw-mt-1 iw-text-sm iw-text-gray-500 iw-list-disc iw-pl-4 iw-space-y-1.5", children: _e.map((
|
|
344
|
+
!((I = navigator.mediaDevices) != null && I.getUserMedia) && /* @__PURE__ */ t.jsx("div", { className: "iw-text-xs iw-text-red-600", children: "Your browser does not support media devices. Please use a modern browser like Chrome, Edge, or Firefox." }),
|
|
345
|
+
m && /* @__PURE__ */ t.jsx("div", { className: "iw-text-xs iw-text-red-600", children: m }),
|
|
346
|
+
/* @__PURE__ */ t.jsx("ul", { className: "iw-mt-1 iw-text-sm iw-text-gray-500 iw-list-disc iw-pl-4 iw-space-y-1.5", children: _e.map((d, x) => /* @__PURE__ */ t.jsx("li", { children: d }, x)) })
|
|
347
347
|
] })
|
|
348
348
|
] })
|
|
349
349
|
] }) });
|
|
350
350
|
};
|
|
351
|
-
var
|
|
351
|
+
var R = /* @__PURE__ */ ((r) => (r.IDLE = "idle", r.FETCHING_QUESTION = "fetching_question", r.READING_QUESTION = "reading_question", r.THINKING = "thinking", r.ANSWERING = "answering", r.TRANSCRIBING = "transcribing", r.EDITING = "editing", r.SUBMITTING = "submitting", r.COMPLETED = "completed", r))(R || {});
|
|
352
352
|
const Oe = {
|
|
353
353
|
thinkingDuration: 30,
|
|
354
354
|
answeringDuration: 120,
|
|
@@ -383,13 +383,13 @@ const Oe = {
|
|
|
383
383
|
}
|
|
384
384
|
};
|
|
385
385
|
class Ue {
|
|
386
|
-
constructor(
|
|
386
|
+
constructor(i = {}, e = {}) {
|
|
387
387
|
D(this, "config");
|
|
388
388
|
D(this, "state");
|
|
389
389
|
D(this, "phaseIntervalId", null);
|
|
390
390
|
D(this, "globalIntervalId", null);
|
|
391
391
|
D(this, "callbacks");
|
|
392
|
-
this.config = { ...Oe, ...
|
|
392
|
+
this.config = { ...Oe, ...i }, this.callbacks = e, this.state = {
|
|
393
393
|
phase: "idle",
|
|
394
394
|
currentPhaseTimeRemaining: 0,
|
|
395
395
|
totalTimeElapsed: 0,
|
|
@@ -412,18 +412,18 @@ class Ue {
|
|
|
412
412
|
* Move to next phase
|
|
413
413
|
*/
|
|
414
414
|
nextPhase() {
|
|
415
|
-
const
|
|
415
|
+
const i = this.state.phase, e = Fe[i];
|
|
416
416
|
if (!e) return;
|
|
417
417
|
this.stopPhaseTimer(), this.state.phase = e.next;
|
|
418
|
-
const
|
|
419
|
-
|
|
418
|
+
const a = this.getDurationForPhase(e.next);
|
|
419
|
+
a > 0 ? (this.state.currentPhaseTimeRemaining = a, this.startPhaseTimer()) : this.state.currentPhaseTimeRemaining = 0, this.notifyChange();
|
|
420
420
|
}
|
|
421
421
|
/**
|
|
422
422
|
* Manually complete the interview
|
|
423
423
|
*/
|
|
424
424
|
completeInterview() {
|
|
425
|
-
var
|
|
426
|
-
this.stopGlobalTimer(), this.stopPhaseTimer(), this.state.phase = "completed", (e = (
|
|
425
|
+
var i, e;
|
|
426
|
+
this.stopGlobalTimer(), this.stopPhaseTimer(), this.state.phase = "completed", (e = (i = this.callbacks).onInterviewEnd) == null || e.call(i), this.notifyChange();
|
|
427
427
|
}
|
|
428
428
|
/**
|
|
429
429
|
* Cleanup
|
|
@@ -434,8 +434,8 @@ class Ue {
|
|
|
434
434
|
/**
|
|
435
435
|
* Get duration for a phase
|
|
436
436
|
*/
|
|
437
|
-
getDurationForPhase(
|
|
438
|
-
switch (
|
|
437
|
+
getDurationForPhase(i) {
|
|
438
|
+
switch (i) {
|
|
439
439
|
case "thinking":
|
|
440
440
|
return this.config.thinkingDuration;
|
|
441
441
|
case "answering":
|
|
@@ -451,8 +451,8 @@ class Ue {
|
|
|
451
451
|
*/
|
|
452
452
|
startGlobalTimer() {
|
|
453
453
|
this.globalIntervalId = setInterval(() => {
|
|
454
|
-
var
|
|
455
|
-
this.state.totalTimeElapsed++, (e = (
|
|
454
|
+
var i, e;
|
|
455
|
+
this.state.totalTimeElapsed++, (e = (i = this.callbacks).onTick) == null || e.call(i, this.getState());
|
|
456
456
|
}, 1e3);
|
|
457
457
|
}
|
|
458
458
|
/**
|
|
@@ -479,91 +479,91 @@ class Ue {
|
|
|
479
479
|
* Notify phase change
|
|
480
480
|
*/
|
|
481
481
|
notifyChange() {
|
|
482
|
-
var
|
|
483
|
-
(e = (
|
|
482
|
+
var i, e;
|
|
483
|
+
(e = (i = this.callbacks).onPhaseChange) == null || e.call(i, this.state.phase, this.getState());
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
function Ge(
|
|
487
|
-
const { config:
|
|
488
|
-
|
|
489
|
-
const s =
|
|
490
|
-
|
|
486
|
+
function Ge(r = {}) {
|
|
487
|
+
const { config: i = {}, callbacks: e = {} } = r, a = S(null);
|
|
488
|
+
a.current || (a.current = new Ue(i, {}));
|
|
489
|
+
const s = a.current, [c, o] = k(s.getState()), n = A(() => {
|
|
490
|
+
o(s.getState());
|
|
491
491
|
}, [s]);
|
|
492
|
-
|
|
492
|
+
P(() => {
|
|
493
493
|
const h = {
|
|
494
|
-
onPhaseChange: (u,
|
|
495
|
-
var
|
|
496
|
-
|
|
494
|
+
onPhaseChange: (u, g) => {
|
|
495
|
+
var j;
|
|
496
|
+
n(), (j = e.onPhaseChange) == null || j.call(e, u, g);
|
|
497
497
|
},
|
|
498
498
|
onTick: (u) => {
|
|
499
|
-
var
|
|
500
|
-
|
|
499
|
+
var g;
|
|
500
|
+
n(), (g = e.onTick) == null || g.call(e, u);
|
|
501
501
|
},
|
|
502
502
|
onInterviewEnd: () => {
|
|
503
503
|
var u;
|
|
504
|
-
|
|
504
|
+
n(), (u = e.onInterviewEnd) == null || u.call(e);
|
|
505
505
|
}
|
|
506
506
|
};
|
|
507
507
|
s.callbacks = h;
|
|
508
|
-
}, [s, e,
|
|
508
|
+
}, [s, e, n]), P(() => () => {
|
|
509
509
|
s.destroy();
|
|
510
510
|
}, [s]);
|
|
511
|
-
const
|
|
512
|
-
s.startQuestion(),
|
|
513
|
-
}, [s,
|
|
514
|
-
s.nextPhase(),
|
|
515
|
-
}, [s,
|
|
516
|
-
s.completeInterview(),
|
|
517
|
-
}, [s,
|
|
511
|
+
const l = A(() => {
|
|
512
|
+
s.startQuestion(), n();
|
|
513
|
+
}, [s, n]), m = A(() => {
|
|
514
|
+
s.nextPhase(), n();
|
|
515
|
+
}, [s, n]), w = A(() => {
|
|
516
|
+
s.completeInterview(), n();
|
|
517
|
+
}, [s, n]);
|
|
518
518
|
return {
|
|
519
519
|
state: c,
|
|
520
|
-
startQuestion:
|
|
521
|
-
nextPhase:
|
|
522
|
-
completeInterview:
|
|
520
|
+
startQuestion: l,
|
|
521
|
+
nextPhase: m,
|
|
522
|
+
completeInterview: w,
|
|
523
523
|
timerService: s
|
|
524
524
|
};
|
|
525
525
|
}
|
|
526
|
-
function qe(
|
|
527
|
-
const [e,
|
|
526
|
+
function qe(r, i = {}) {
|
|
527
|
+
const [e, a] = k({
|
|
528
528
|
data: null,
|
|
529
529
|
loading: !1,
|
|
530
530
|
error: null
|
|
531
531
|
}), s = A(
|
|
532
532
|
async (...c) => {
|
|
533
|
-
var
|
|
534
|
-
|
|
533
|
+
var o, n, l, m;
|
|
534
|
+
a((w) => ({ ...w, loading: !0, error: null }));
|
|
535
535
|
try {
|
|
536
|
-
const
|
|
537
|
-
|
|
536
|
+
const w = await r(...c);
|
|
537
|
+
a((h) => ({
|
|
538
538
|
...h,
|
|
539
|
-
data:
|
|
539
|
+
data: w,
|
|
540
540
|
loading: !1,
|
|
541
541
|
error: null
|
|
542
|
-
})), (
|
|
543
|
-
} catch (
|
|
544
|
-
const h =
|
|
542
|
+
})), (o = i.onSuccess) == null || o.call(i, w), (n = i.onSettled) == null || n.call(i, w, null);
|
|
543
|
+
} catch (w) {
|
|
544
|
+
const h = w.type ? w : {
|
|
545
545
|
type: "unknown",
|
|
546
|
-
message:
|
|
546
|
+
message: w.message || "Unknown error",
|
|
547
547
|
retryable: !0,
|
|
548
548
|
userMessage: "Something went wrong. Please try again.",
|
|
549
|
-
originalError:
|
|
549
|
+
originalError: w
|
|
550
550
|
};
|
|
551
|
-
|
|
551
|
+
a((u) => ({
|
|
552
552
|
...u,
|
|
553
553
|
loading: !1,
|
|
554
554
|
error: h
|
|
555
|
-
})), (
|
|
555
|
+
})), (l = i.onError) == null || l.call(i, h), (m = i.onSettled) == null || m.call(i, null, h);
|
|
556
556
|
}
|
|
557
557
|
},
|
|
558
|
-
[
|
|
558
|
+
[r, i]
|
|
559
559
|
);
|
|
560
560
|
return {
|
|
561
561
|
...e,
|
|
562
562
|
execute: s
|
|
563
563
|
};
|
|
564
564
|
}
|
|
565
|
-
function Be(
|
|
566
|
-
var
|
|
565
|
+
function Be(r) {
|
|
566
|
+
var i;
|
|
567
567
|
if (!navigator.onLine)
|
|
568
568
|
return {
|
|
569
569
|
type: "network",
|
|
@@ -571,15 +571,15 @@ function Be(i) {
|
|
|
571
571
|
retryable: !0,
|
|
572
572
|
userMessage: "Please check your internet connection and try again."
|
|
573
573
|
};
|
|
574
|
-
if (
|
|
574
|
+
if (r.name === "AbortError" || (i = r.message) != null && i.includes("timeout"))
|
|
575
575
|
return {
|
|
576
576
|
type: "timeout",
|
|
577
577
|
message: "Request timed out",
|
|
578
578
|
retryable: !0,
|
|
579
579
|
userMessage: "The request is taking longer than expected. Please try again."
|
|
580
580
|
};
|
|
581
|
-
if (
|
|
582
|
-
const { status: e } =
|
|
581
|
+
if (r.status) {
|
|
582
|
+
const { status: e } = r;
|
|
583
583
|
if (e === 401 || e === 403)
|
|
584
584
|
return {
|
|
585
585
|
type: "auth",
|
|
@@ -615,123 +615,123 @@ function Be(i) {
|
|
|
615
615
|
}
|
|
616
616
|
return {
|
|
617
617
|
type: "unknown",
|
|
618
|
-
message:
|
|
618
|
+
message: r.message || "Unknown error occurred",
|
|
619
619
|
retryable: !0,
|
|
620
620
|
userMessage: "Something unexpected happened. Please try again.",
|
|
621
|
-
originalError:
|
|
621
|
+
originalError: r
|
|
622
622
|
};
|
|
623
623
|
}
|
|
624
|
-
async function
|
|
624
|
+
async function ae(r, i = {}, e = {
|
|
625
625
|
attempts: 3,
|
|
626
626
|
backoff: "exponential",
|
|
627
627
|
baseDelay: 1e3,
|
|
628
628
|
maxDelay: 1e4,
|
|
629
629
|
jitter: !0
|
|
630
630
|
}) {
|
|
631
|
-
let
|
|
631
|
+
let a;
|
|
632
632
|
for (let s = 1; s <= e.attempts; s++)
|
|
633
633
|
try {
|
|
634
|
-
const c = new AbortController(),
|
|
635
|
-
...
|
|
634
|
+
const c = new AbortController(), o = setTimeout(() => c.abort(), 6e4), n = await fetch(r, {
|
|
635
|
+
...i,
|
|
636
636
|
signal: c.signal
|
|
637
637
|
});
|
|
638
|
-
if (clearTimeout(
|
|
639
|
-
return
|
|
640
|
-
if (!
|
|
641
|
-
throw new Error(`HTTP ${
|
|
642
|
-
return
|
|
638
|
+
if (clearTimeout(o), n.status >= 400 && n.status < 500 && n.status !== 429)
|
|
639
|
+
return n;
|
|
640
|
+
if (!n.ok)
|
|
641
|
+
throw new Error(`HTTP ${n.status}: ${n.statusText}`);
|
|
642
|
+
return n;
|
|
643
643
|
} catch (c) {
|
|
644
|
-
|
|
645
|
-
const
|
|
646
|
-
if (!
|
|
647
|
-
throw
|
|
648
|
-
const
|
|
644
|
+
a = c;
|
|
645
|
+
const o = Be(c);
|
|
646
|
+
if (!o.retryable || s === e.attempts)
|
|
647
|
+
throw o;
|
|
648
|
+
const n = ze(s, e);
|
|
649
649
|
console.warn(
|
|
650
|
-
`API request failed (attempt ${s}/${e.attempts}), retrying in ${
|
|
651
|
-
|
|
652
|
-
), await new Promise((
|
|
650
|
+
`API request failed (attempt ${s}/${e.attempts}), retrying in ${n}ms:`,
|
|
651
|
+
o.message
|
|
652
|
+
), await new Promise((l) => setTimeout(l, n));
|
|
653
653
|
}
|
|
654
|
-
throw
|
|
654
|
+
throw a;
|
|
655
655
|
}
|
|
656
|
-
function ze(
|
|
656
|
+
function ze(r, i) {
|
|
657
657
|
let e;
|
|
658
|
-
return
|
|
658
|
+
return i.backoff === "exponential" ? e = i.baseDelay * Math.pow(2, r - 1) : e = i.baseDelay, e = Math.min(e, i.maxDelay), i.jitter && (e = e * (0.5 + Math.random() * 0.5)), Math.round(e);
|
|
659
659
|
}
|
|
660
660
|
class Qe {
|
|
661
|
-
constructor(
|
|
661
|
+
constructor(i = {}) {
|
|
662
662
|
D(this, "config");
|
|
663
|
-
this.config =
|
|
663
|
+
this.config = i;
|
|
664
664
|
}
|
|
665
665
|
/**
|
|
666
666
|
* Update configuration
|
|
667
667
|
*/
|
|
668
|
-
updateConfig(
|
|
669
|
-
this.config = { ...this.config, ...
|
|
668
|
+
updateConfig(i) {
|
|
669
|
+
this.config = { ...this.config, ...i };
|
|
670
670
|
}
|
|
671
671
|
/**
|
|
672
672
|
* Get default headers for API requests
|
|
673
673
|
*/
|
|
674
674
|
getHeaders() {
|
|
675
675
|
var e;
|
|
676
|
-
const
|
|
676
|
+
const i = {
|
|
677
677
|
"Content-Type": "application/json",
|
|
678
678
|
"X-Auth-Token": "appkey"
|
|
679
679
|
};
|
|
680
|
-
return (e = this.config) != null && e.authToken && (
|
|
680
|
+
return (e = this.config) != null && e.authToken && (i.Authorization = `Bearer ${this.config.authToken}`), i;
|
|
681
681
|
}
|
|
682
682
|
/**
|
|
683
683
|
* Get base URL from config with fallback
|
|
684
684
|
*/
|
|
685
685
|
getBaseUrl() {
|
|
686
|
-
var
|
|
687
|
-
return ((
|
|
686
|
+
var i;
|
|
687
|
+
return ((i = this.config) == null ? void 0 : i.baseUrl) || "/api";
|
|
688
688
|
}
|
|
689
689
|
/**
|
|
690
690
|
* Get questions for an interview
|
|
691
691
|
*/
|
|
692
692
|
async generateQuestion({
|
|
693
|
-
interviewId:
|
|
693
|
+
interviewId: i,
|
|
694
694
|
isInterviewDone: e = !1,
|
|
695
|
-
qnaId:
|
|
695
|
+
qnaId: a,
|
|
696
696
|
question: s,
|
|
697
697
|
answer: c,
|
|
698
|
-
answerDuration:
|
|
698
|
+
answerDuration: o
|
|
699
699
|
}) {
|
|
700
|
-
const
|
|
700
|
+
const n = await ae(
|
|
701
701
|
`${this.getBaseUrl()}/questions/next`,
|
|
702
702
|
{
|
|
703
703
|
method: "POST",
|
|
704
704
|
headers: this.getHeaders(),
|
|
705
705
|
body: JSON.stringify({
|
|
706
|
-
interview_id:
|
|
706
|
+
interview_id: i,
|
|
707
707
|
is_interview_done: e,
|
|
708
|
-
qna_id:
|
|
708
|
+
qna_id: a,
|
|
709
709
|
question: s,
|
|
710
710
|
answer: c,
|
|
711
711
|
// TODO: Hardcoded for now, will be dynamic later
|
|
712
|
-
answer_duration:
|
|
712
|
+
answer_duration: o ?? "00:00:30"
|
|
713
713
|
})
|
|
714
714
|
}
|
|
715
715
|
);
|
|
716
|
-
if (!
|
|
717
|
-
throw new Error(`Failed to get questions: ${
|
|
718
|
-
return await
|
|
716
|
+
if (!n.ok)
|
|
717
|
+
throw new Error(`Failed to get questions: ${n.status}`);
|
|
718
|
+
return await n.json();
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
721
|
function We() {
|
|
722
|
-
const
|
|
722
|
+
const r = Z();
|
|
723
723
|
return J(() => {
|
|
724
|
-
const e =
|
|
724
|
+
const e = r.api || {};
|
|
725
725
|
return new Qe(e);
|
|
726
|
-
}, [
|
|
726
|
+
}, [r.api]);
|
|
727
727
|
}
|
|
728
|
-
class
|
|
729
|
-
constructor(
|
|
730
|
-
super(
|
|
728
|
+
class v extends Error {
|
|
729
|
+
constructor(i, e, a = !1) {
|
|
730
|
+
super(i), this.code = e, this.recoverable = a, this.name = "STTError";
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
class He {
|
|
734
|
-
constructor(
|
|
734
|
+
constructor(i = {}) {
|
|
735
735
|
D(this, "config");
|
|
736
736
|
D(this, "mediaRecorder", null);
|
|
737
737
|
D(this, "audioChunks", []);
|
|
@@ -744,14 +744,14 @@ class He {
|
|
|
744
744
|
language: "en",
|
|
745
745
|
includeTimestamps: !1,
|
|
746
746
|
temperature: 0,
|
|
747
|
-
...
|
|
747
|
+
...i
|
|
748
748
|
};
|
|
749
749
|
}
|
|
750
750
|
/**
|
|
751
751
|
* Update STT configuration
|
|
752
752
|
*/
|
|
753
|
-
updateConfig(
|
|
754
|
-
this.config = { ...this.config, ...
|
|
753
|
+
updateConfig(i) {
|
|
754
|
+
this.config = { ...this.config, ...i };
|
|
755
755
|
}
|
|
756
756
|
/**
|
|
757
757
|
* Check if browser supports audio recording
|
|
@@ -762,16 +762,16 @@ class He {
|
|
|
762
762
|
/**
|
|
763
763
|
* Start recording audio from user's microphone
|
|
764
764
|
*/
|
|
765
|
-
async startRecording(
|
|
766
|
-
var
|
|
765
|
+
async startRecording(i, e) {
|
|
766
|
+
var a;
|
|
767
767
|
if (!this.isRecordingSupported())
|
|
768
|
-
throw new
|
|
768
|
+
throw new v(
|
|
769
769
|
"Audio recording is not supported in this browser",
|
|
770
770
|
"RECORDING_NOT_SUPPORTED",
|
|
771
771
|
!1
|
|
772
772
|
);
|
|
773
773
|
if (this.isRecording())
|
|
774
|
-
throw new
|
|
774
|
+
throw new v(
|
|
775
775
|
"Recording is already in progress",
|
|
776
776
|
"ALREADY_RECORDING",
|
|
777
777
|
!0
|
|
@@ -788,34 +788,34 @@ class He {
|
|
|
788
788
|
this.mediaRecorder = new MediaRecorder(this.recordingStream, {
|
|
789
789
|
mimeType: s
|
|
790
790
|
}), this.mediaRecorder.ondataavailable = (c) => {
|
|
791
|
-
var
|
|
792
|
-
c.data.size > 0 && (this.audioChunks.push(c.data), (
|
|
791
|
+
var o;
|
|
792
|
+
c.data.size > 0 && (this.audioChunks.push(c.data), (o = e == null ? void 0 : e.onDataAvailable) == null || o.call(e, c.data));
|
|
793
793
|
}, this.mediaRecorder.onstop = () => {
|
|
794
794
|
var c;
|
|
795
795
|
(c = e == null ? void 0 : e.onStop) == null || c.call(e);
|
|
796
796
|
}, this.mediaRecorder.onerror = (c) => {
|
|
797
|
-
var
|
|
798
|
-
const
|
|
797
|
+
var n;
|
|
798
|
+
const o = new v(
|
|
799
799
|
`Recording failed: ${c.error}`,
|
|
800
800
|
"RECORDING_ERROR",
|
|
801
801
|
!0
|
|
802
802
|
);
|
|
803
|
-
(
|
|
804
|
-
}, this.mediaRecorder.start(100), (
|
|
803
|
+
(n = e == null ? void 0 : e.onError) == null || n.call(e, o), this.cleanup();
|
|
804
|
+
}, this.mediaRecorder.start(100), (a = e == null ? void 0 : e.onStart) == null || a.call(e), i && i > 0 && (this.autoStopTimeoutId = setTimeout(() => {
|
|
805
805
|
this.isRecording() && this.stopRecording();
|
|
806
|
-
},
|
|
806
|
+
}, i * 1e3));
|
|
807
807
|
} catch (s) {
|
|
808
808
|
if (this.cleanup(), s instanceof Error) {
|
|
809
809
|
if (s.name === "NotAllowedError" || s.name === "PermissionDeniedError")
|
|
810
|
-
throw new
|
|
810
|
+
throw new v(
|
|
811
811
|
"Microphone permission was denied",
|
|
812
812
|
"PERMISSION_DENIED",
|
|
813
813
|
!1
|
|
814
814
|
);
|
|
815
815
|
if (s.name === "NotFoundError")
|
|
816
|
-
throw new
|
|
816
|
+
throw new v("No microphone found", "NO_MICROPHONE", !1);
|
|
817
817
|
}
|
|
818
|
-
throw new
|
|
818
|
+
throw new v(
|
|
819
819
|
`Failed to start recording: ${s instanceof Error ? s.message : String(s)}`,
|
|
820
820
|
"START_RECORDING_FAILED",
|
|
821
821
|
!0
|
|
@@ -827,25 +827,25 @@ class He {
|
|
|
827
827
|
*/
|
|
828
828
|
async stopRecording() {
|
|
829
829
|
if (this.autoStopTimeoutId && (clearTimeout(this.autoStopTimeoutId), this.autoStopTimeoutId = null), !this.mediaRecorder || !this.isRecording())
|
|
830
|
-
throw new
|
|
830
|
+
throw new v(
|
|
831
831
|
"No active recording to stop",
|
|
832
832
|
"NO_ACTIVE_RECORDING",
|
|
833
833
|
!1
|
|
834
834
|
);
|
|
835
|
-
return new Promise((
|
|
835
|
+
return new Promise((i, e) => {
|
|
836
836
|
if (!this.mediaRecorder) {
|
|
837
837
|
e(
|
|
838
|
-
new
|
|
838
|
+
new v("MediaRecorder is null", "MEDIARECORDER_NULL", !1)
|
|
839
839
|
);
|
|
840
840
|
return;
|
|
841
841
|
}
|
|
842
|
-
const
|
|
842
|
+
const a = this.mediaRecorder, s = () => {
|
|
843
843
|
try {
|
|
844
|
-
const c =
|
|
845
|
-
this.cleanup(),
|
|
844
|
+
const c = a.mimeType || "audio/webm", o = new Blob(this.audioChunks, { type: c });
|
|
845
|
+
this.cleanup(), i(o);
|
|
846
846
|
} catch (c) {
|
|
847
847
|
e(
|
|
848
|
-
new
|
|
848
|
+
new v(
|
|
849
849
|
`Failed to create audio blob: ${c instanceof Error ? c.message : String(c)}`,
|
|
850
850
|
"BLOB_CREATION_FAILED",
|
|
851
851
|
!1
|
|
@@ -853,40 +853,43 @@ class He {
|
|
|
853
853
|
);
|
|
854
854
|
}
|
|
855
855
|
};
|
|
856
|
-
|
|
856
|
+
a.addEventListener("stop", s, { once: !0 }), a.stop();
|
|
857
857
|
});
|
|
858
858
|
}
|
|
859
859
|
/**
|
|
860
860
|
* Transcribe audio blob using the STT API
|
|
861
861
|
*/
|
|
862
|
-
async transcribe(
|
|
862
|
+
async transcribe(i) {
|
|
863
863
|
const {
|
|
864
864
|
audioBlob: e,
|
|
865
|
-
model:
|
|
865
|
+
model: a = this.config.model,
|
|
866
866
|
language: s = this.config.language,
|
|
867
867
|
includeTimestamps: c = this.config.includeTimestamps,
|
|
868
|
-
temperature:
|
|
869
|
-
} =
|
|
868
|
+
temperature: o = this.config.temperature
|
|
869
|
+
} = i;
|
|
870
870
|
if (!e || e.size === 0)
|
|
871
|
-
throw new
|
|
871
|
+
throw new v(
|
|
872
872
|
"Audio blob is empty or invalid",
|
|
873
873
|
"INVALID_AUDIO",
|
|
874
874
|
!1
|
|
875
875
|
);
|
|
876
876
|
try {
|
|
877
|
-
const
|
|
877
|
+
const n = new FormData(), l = new File([e], "recording.wav", {
|
|
878
878
|
type: e.type || "audio/wav"
|
|
879
879
|
});
|
|
880
|
-
|
|
881
|
-
const
|
|
880
|
+
n.append("file", l), n.append("model", a || "whisper-large-v3-turbo"), n.append("language", s || "en"), n.append("include_timestamps", String(c || !1)), n.append("temperature", String(o || 0));
|
|
881
|
+
const m = await ae(
|
|
882
882
|
`${this.config.baseUrl}/speech/transcribe`,
|
|
883
883
|
{
|
|
884
884
|
method: "POST",
|
|
885
885
|
headers: {
|
|
886
886
|
accept: "application/json",
|
|
887
|
-
"X-STT-Provider": this.config.provider || "groq"
|
|
887
|
+
"X-STT-Provider": this.config.provider || "groq",
|
|
888
|
+
...this.config.authToken && {
|
|
889
|
+
Authorization: `Bearer ${this.config.authToken}`
|
|
890
|
+
}
|
|
888
891
|
},
|
|
889
|
-
body:
|
|
892
|
+
body: n
|
|
890
893
|
},
|
|
891
894
|
{
|
|
892
895
|
attempts: 1,
|
|
@@ -896,27 +899,27 @@ class He {
|
|
|
896
899
|
jitter: !0
|
|
897
900
|
}
|
|
898
901
|
);
|
|
899
|
-
if (!
|
|
900
|
-
const h = await
|
|
901
|
-
let u = `STT request failed: ${
|
|
902
|
+
if (!m.ok) {
|
|
903
|
+
const h = await m.text();
|
|
904
|
+
let u = `STT request failed: ${m.status} ${m.statusText}`;
|
|
902
905
|
try {
|
|
903
|
-
const
|
|
904
|
-
u =
|
|
906
|
+
const g = JSON.parse(h);
|
|
907
|
+
u = g.message || g.error || u;
|
|
905
908
|
} catch {
|
|
906
909
|
u = h || u;
|
|
907
910
|
}
|
|
908
|
-
throw new
|
|
911
|
+
throw new v(
|
|
909
912
|
u,
|
|
910
|
-
`HTTP_${
|
|
911
|
-
|
|
913
|
+
`HTTP_${m.status}`,
|
|
914
|
+
m.status >= 500
|
|
912
915
|
);
|
|
913
916
|
}
|
|
914
917
|
return {
|
|
915
|
-
transcript: (await
|
|
918
|
+
transcript: (await m.json()).data.text ?? ""
|
|
916
919
|
};
|
|
917
|
-
} catch (
|
|
918
|
-
throw
|
|
919
|
-
`Transcription failed: ${
|
|
920
|
+
} catch (n) {
|
|
921
|
+
throw n instanceof v ? n : new v(
|
|
922
|
+
`Transcription failed: ${n instanceof Error ? n.message : String(n)}`,
|
|
920
923
|
"TRANSCRIPTION_FAILED",
|
|
921
924
|
!0
|
|
922
925
|
);
|
|
@@ -938,14 +941,14 @@ class He {
|
|
|
938
941
|
* Get supported MIME type for recording
|
|
939
942
|
*/
|
|
940
943
|
getSupportedMimeType() {
|
|
941
|
-
const
|
|
944
|
+
const i = [
|
|
942
945
|
"audio/webm",
|
|
943
946
|
"audio/webm;codecs=opus",
|
|
944
947
|
"audio/ogg;codecs=opus",
|
|
945
948
|
"audio/mp4",
|
|
946
949
|
"audio/wav"
|
|
947
950
|
];
|
|
948
|
-
for (const e of
|
|
951
|
+
for (const e of i)
|
|
949
952
|
if (MediaRecorder.isTypeSupported(e))
|
|
950
953
|
return e;
|
|
951
954
|
return "audio/webm";
|
|
@@ -954,88 +957,88 @@ class He {
|
|
|
954
957
|
* Clean up recording resources
|
|
955
958
|
*/
|
|
956
959
|
cleanup() {
|
|
957
|
-
this.recordingStream && (this.recordingStream.getTracks().forEach((
|
|
960
|
+
this.recordingStream && (this.recordingStream.getTracks().forEach((i) => i.stop()), this.recordingStream = null), this.mediaRecorder = null, this.audioChunks = [], this.autoStopTimeoutId && (clearTimeout(this.autoStopTimeoutId), this.autoStopTimeoutId = null);
|
|
958
961
|
}
|
|
959
962
|
}
|
|
960
|
-
const
|
|
961
|
-
const [
|
|
962
|
-
|
|
963
|
-
const h = A(async (
|
|
964
|
-
var
|
|
963
|
+
const H = new He(), Ye = (r = {}) => {
|
|
964
|
+
const [i, e] = k(!1), [a, s] = k(!1), [c, o] = k(null), [n, l] = k(null), [m, w] = k(null);
|
|
965
|
+
r.config && H.updateConfig(r.config);
|
|
966
|
+
const h = A(async (y) => {
|
|
967
|
+
var I;
|
|
965
968
|
try {
|
|
966
|
-
|
|
969
|
+
l(null), o(null), w(null), await H.startRecording(y, {
|
|
967
970
|
onStart: () => {
|
|
968
|
-
var
|
|
969
|
-
e(!0), (
|
|
971
|
+
var d;
|
|
972
|
+
e(!0), (d = r.onStart) == null || d.call(r);
|
|
970
973
|
},
|
|
971
974
|
onStop: () => {
|
|
972
|
-
var
|
|
973
|
-
e(!1), (
|
|
975
|
+
var d;
|
|
976
|
+
e(!1), (d = r.onStop) == null || d.call(r);
|
|
974
977
|
},
|
|
975
|
-
onError: (
|
|
978
|
+
onError: (d) => {
|
|
976
979
|
var M;
|
|
977
|
-
const
|
|
978
|
-
|
|
980
|
+
const x = d instanceof v ? d : new v(d.message, "RECORDING_ERROR", !0);
|
|
981
|
+
l(x), e(!1), (M = r.onError) == null || M.call(r, x);
|
|
979
982
|
}
|
|
980
983
|
});
|
|
981
|
-
} catch (
|
|
982
|
-
const
|
|
983
|
-
|
|
984
|
+
} catch (d) {
|
|
985
|
+
const x = d instanceof v ? d : new v(
|
|
986
|
+
d instanceof Error ? d.message : String(d),
|
|
984
987
|
"START_FAILED",
|
|
985
988
|
!1
|
|
986
989
|
);
|
|
987
|
-
throw
|
|
990
|
+
throw l(x), e(!1), (I = r.onError) == null || I.call(r, x), x;
|
|
988
991
|
}
|
|
989
992
|
}, []), u = A(async () => {
|
|
990
|
-
var
|
|
993
|
+
var y, I;
|
|
991
994
|
try {
|
|
992
|
-
const
|
|
993
|
-
return d
|
|
994
|
-
} catch (
|
|
995
|
-
const
|
|
996
|
-
|
|
995
|
+
const d = await H.stopRecording();
|
|
996
|
+
return w(d), e(!1), (y = r.onStop) == null || y.call(r), d;
|
|
997
|
+
} catch (d) {
|
|
998
|
+
const x = d instanceof v ? d : new v(
|
|
999
|
+
d instanceof Error ? d.message : String(d),
|
|
997
1000
|
"STOP_FAILED",
|
|
998
1001
|
!1
|
|
999
1002
|
);
|
|
1000
|
-
throw
|
|
1003
|
+
throw l(x), e(!1), (I = r.onError) == null || I.call(r, x), x;
|
|
1001
1004
|
}
|
|
1002
|
-
}, []),
|
|
1003
|
-
async (
|
|
1004
|
-
var
|
|
1005
|
+
}, []), g = A(
|
|
1006
|
+
async (y, I = {}) => {
|
|
1007
|
+
var d, x;
|
|
1005
1008
|
try {
|
|
1006
|
-
|
|
1009
|
+
l(null), s(!0);
|
|
1007
1010
|
const M = {
|
|
1008
|
-
audioBlob:
|
|
1009
|
-
...
|
|
1010
|
-
},
|
|
1011
|
-
return
|
|
1011
|
+
audioBlob: y,
|
|
1012
|
+
...I
|
|
1013
|
+
}, p = await H.transcribe(M);
|
|
1014
|
+
return o(p.transcript), s(!1), (d = r.onTranscriptionComplete) == null || d.call(r, p), p;
|
|
1012
1015
|
} catch (M) {
|
|
1013
|
-
const
|
|
1016
|
+
const p = M instanceof v ? M : new v(
|
|
1014
1017
|
M instanceof Error ? M.message : String(M),
|
|
1015
1018
|
"TRANSCRIPTION_FAILED",
|
|
1016
1019
|
!0
|
|
1017
1020
|
);
|
|
1018
|
-
throw
|
|
1021
|
+
throw l(p), s(!1), (x = r.onError) == null || x.call(r, p), p;
|
|
1019
1022
|
}
|
|
1020
1023
|
},
|
|
1021
1024
|
[]
|
|
1022
|
-
),
|
|
1023
|
-
|
|
1025
|
+
), j = A(() => {
|
|
1026
|
+
H.cancelRecording(), e(!1), w(null);
|
|
1024
1027
|
}, []);
|
|
1025
1028
|
return {
|
|
1026
1029
|
startRecording: h,
|
|
1027
1030
|
stopRecording: u,
|
|
1028
|
-
transcribe:
|
|
1029
|
-
cancelRecording:
|
|
1030
|
-
isRecording:
|
|
1031
|
-
isTranscribing:
|
|
1031
|
+
transcribe: g,
|
|
1032
|
+
cancelRecording: j,
|
|
1033
|
+
isRecording: i,
|
|
1034
|
+
isTranscribing: a,
|
|
1032
1035
|
transcript: c,
|
|
1033
|
-
error:
|
|
1034
|
-
audioBlob:
|
|
1036
|
+
error: n,
|
|
1037
|
+
audioBlob: m
|
|
1035
1038
|
};
|
|
1036
1039
|
};
|
|
1037
1040
|
class Ve {
|
|
1038
|
-
constructor(
|
|
1041
|
+
constructor(i = {}) {
|
|
1039
1042
|
D(this, "config");
|
|
1040
1043
|
D(this, "currentAudio", null);
|
|
1041
1044
|
this.config = {
|
|
@@ -1043,33 +1046,36 @@ class Ve {
|
|
|
1043
1046
|
provider: "piper",
|
|
1044
1047
|
voice: "string",
|
|
1045
1048
|
speed: 1,
|
|
1046
|
-
...
|
|
1049
|
+
...i
|
|
1047
1050
|
};
|
|
1048
1051
|
}
|
|
1049
1052
|
/**
|
|
1050
1053
|
* Update TTS configuration
|
|
1051
1054
|
*/
|
|
1052
|
-
updateConfig(
|
|
1053
|
-
this.config = { ...this.config, ...
|
|
1055
|
+
updateConfig(i) {
|
|
1056
|
+
this.config = { ...this.config, ...i };
|
|
1054
1057
|
}
|
|
1055
1058
|
/**
|
|
1056
1059
|
* Get TTS audio from the API and return as blob
|
|
1057
1060
|
*/
|
|
1058
|
-
async synthesizeSpeech(
|
|
1061
|
+
async synthesizeSpeech(i) {
|
|
1059
1062
|
const {
|
|
1060
1063
|
text: e,
|
|
1061
|
-
voice:
|
|
1064
|
+
voice: a = this.config.voice,
|
|
1062
1065
|
speed: s = this.config.speed
|
|
1063
|
-
} =
|
|
1064
|
-
c.append("text", e), c.append("voice",
|
|
1065
|
-
const
|
|
1066
|
+
} = i, c = new URLSearchParams();
|
|
1067
|
+
c.append("text", e), c.append("voice", a || "string"), c.append("speed", (s == null ? void 0 : s.toString()) || "1");
|
|
1068
|
+
const o = await ae(
|
|
1066
1069
|
`${this.config.baseUrl}/speech/synthesize`,
|
|
1067
1070
|
{
|
|
1068
1071
|
method: "POST",
|
|
1069
1072
|
headers: {
|
|
1070
1073
|
accept: "application/json",
|
|
1071
1074
|
"X-TTS-Provider": this.config.provider || "piper",
|
|
1072
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
1075
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
1076
|
+
...this.config.authToken && {
|
|
1077
|
+
Authorization: `Bearer ${this.config.authToken}`
|
|
1078
|
+
}
|
|
1073
1079
|
},
|
|
1074
1080
|
body: c
|
|
1075
1081
|
},
|
|
@@ -1081,16 +1087,16 @@ class Ve {
|
|
|
1081
1087
|
jitter: !1
|
|
1082
1088
|
}
|
|
1083
1089
|
);
|
|
1084
|
-
if (!
|
|
1090
|
+
if (!o.ok)
|
|
1085
1091
|
throw new Error(
|
|
1086
|
-
`TTS request failed: ${
|
|
1092
|
+
`TTS request failed: ${o.status} ${o.statusText}`
|
|
1087
1093
|
);
|
|
1088
|
-
const
|
|
1089
|
-
if (
|
|
1090
|
-
return
|
|
1094
|
+
const n = o.headers.get("content-type");
|
|
1095
|
+
if (n && n.includes("audio/"))
|
|
1096
|
+
return o.blob();
|
|
1091
1097
|
try {
|
|
1092
|
-
const
|
|
1093
|
-
throw new Error(`TTS Error: ${JSON.stringify(
|
|
1098
|
+
const l = await o.json();
|
|
1099
|
+
throw new Error(`TTS Error: ${JSON.stringify(l)}`);
|
|
1094
1100
|
} catch {
|
|
1095
1101
|
throw new Error("TTS request failed with unknown error");
|
|
1096
1102
|
}
|
|
@@ -1098,35 +1104,35 @@ class Ve {
|
|
|
1098
1104
|
/**
|
|
1099
1105
|
* Speak text and return a promise that resolves when playback completes
|
|
1100
1106
|
*/
|
|
1101
|
-
async speak(
|
|
1102
|
-
var
|
|
1107
|
+
async speak(i, e) {
|
|
1108
|
+
var a, s;
|
|
1103
1109
|
try {
|
|
1104
|
-
this.stop(), (
|
|
1105
|
-
const c = await this.synthesizeSpeech(
|
|
1106
|
-
return this.currentAudio = new Audio(
|
|
1110
|
+
this.stop(), (a = e == null ? void 0 : e.onStart) == null || a.call(e);
|
|
1111
|
+
const c = await this.synthesizeSpeech(i), o = URL.createObjectURL(c);
|
|
1112
|
+
return this.currentAudio = new Audio(o), new Promise((n, l) => {
|
|
1107
1113
|
if (!this.currentAudio) {
|
|
1108
|
-
|
|
1114
|
+
l(new Error("Audio element not created"));
|
|
1109
1115
|
return;
|
|
1110
1116
|
}
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
var
|
|
1114
|
-
URL.revokeObjectURL(
|
|
1115
|
-
},
|
|
1117
|
+
const m = this.currentAudio;
|
|
1118
|
+
m.onended = () => {
|
|
1119
|
+
var w;
|
|
1120
|
+
URL.revokeObjectURL(o), this.currentAudio = null, (w = e == null ? void 0 : e.onEnd) == null || w.call(e), n();
|
|
1121
|
+
}, m.onerror = (w) => {
|
|
1116
1122
|
var u;
|
|
1117
|
-
URL.revokeObjectURL(
|
|
1118
|
-
const h = new Error(`Audio playback failed: ${
|
|
1119
|
-
(u = e == null ? void 0 : e.onError) == null || u.call(e, h),
|
|
1120
|
-
},
|
|
1123
|
+
URL.revokeObjectURL(o), this.currentAudio = null;
|
|
1124
|
+
const h = new Error(`Audio playback failed: ${w}`);
|
|
1125
|
+
(u = e == null ? void 0 : e.onError) == null || u.call(e, h), l(h);
|
|
1126
|
+
}, m.play().catch((w) => {
|
|
1121
1127
|
var u;
|
|
1122
|
-
URL.revokeObjectURL(
|
|
1123
|
-
const h = new Error(`Failed to play audio: ${
|
|
1124
|
-
(u = e == null ? void 0 : e.onError) == null || u.call(e, h),
|
|
1128
|
+
URL.revokeObjectURL(o), this.currentAudio = null;
|
|
1129
|
+
const h = new Error(`Failed to play audio: ${w.message}`);
|
|
1130
|
+
(u = e == null ? void 0 : e.onError) == null || u.call(e, h), l(h);
|
|
1125
1131
|
});
|
|
1126
1132
|
});
|
|
1127
1133
|
} catch (c) {
|
|
1128
|
-
const
|
|
1129
|
-
throw (s = e == null ? void 0 : e.onError) == null || s.call(e,
|
|
1134
|
+
const o = c instanceof Error ? c : new Error(`TTS Error: ${String(c)}`);
|
|
1135
|
+
throw (s = e == null ? void 0 : e.onError) == null || s.call(e, o), o;
|
|
1130
1136
|
}
|
|
1131
1137
|
}
|
|
1132
1138
|
/**
|
|
@@ -1142,91 +1148,91 @@ class Ve {
|
|
|
1142
1148
|
return this.currentAudio !== null && !this.currentAudio.paused;
|
|
1143
1149
|
}
|
|
1144
1150
|
}
|
|
1145
|
-
const
|
|
1146
|
-
const [
|
|
1147
|
-
|
|
1148
|
-
const
|
|
1149
|
-
async (
|
|
1151
|
+
const se = new Ve(), Je = (r = {}) => {
|
|
1152
|
+
const [i, e] = k(!1), [a, s] = k(!1), [c, o] = k(null);
|
|
1153
|
+
r.config && se.updateConfig(r.config);
|
|
1154
|
+
const n = A(
|
|
1155
|
+
async (m, w = {}) => {
|
|
1150
1156
|
var h;
|
|
1151
1157
|
try {
|
|
1152
|
-
|
|
1158
|
+
o(null), s(!0);
|
|
1153
1159
|
const u = {
|
|
1154
|
-
text:
|
|
1155
|
-
...
|
|
1160
|
+
text: m,
|
|
1161
|
+
...w
|
|
1156
1162
|
};
|
|
1157
|
-
await
|
|
1163
|
+
await se.speak(u, {
|
|
1158
1164
|
onStart: () => {
|
|
1159
|
-
var
|
|
1160
|
-
s(!1), e(!0), (
|
|
1165
|
+
var g;
|
|
1166
|
+
s(!1), e(!0), (g = r.onStart) == null || g.call(r);
|
|
1161
1167
|
},
|
|
1162
1168
|
onEnd: () => {
|
|
1163
|
-
var
|
|
1164
|
-
e(!1), (
|
|
1169
|
+
var g;
|
|
1170
|
+
e(!1), (g = r.onEnd) == null || g.call(r);
|
|
1165
1171
|
},
|
|
1166
|
-
onError: (
|
|
1167
|
-
var
|
|
1168
|
-
e(!1), s(!1),
|
|
1172
|
+
onError: (g) => {
|
|
1173
|
+
var j;
|
|
1174
|
+
e(!1), s(!1), o(g), (j = r.onError) == null || j.call(r, g);
|
|
1169
1175
|
}
|
|
1170
1176
|
});
|
|
1171
1177
|
} catch (u) {
|
|
1172
|
-
const
|
|
1173
|
-
throw
|
|
1178
|
+
const g = u instanceof Error ? u : new Error(String(u));
|
|
1179
|
+
throw o(g), e(!1), s(!1), (h = r.onError) == null || h.call(r, g), g;
|
|
1174
1180
|
}
|
|
1175
1181
|
},
|
|
1176
|
-
[
|
|
1177
|
-
),
|
|
1178
|
-
|
|
1182
|
+
[r]
|
|
1183
|
+
), l = A(() => {
|
|
1184
|
+
se.stop(), e(!1), s(!1);
|
|
1179
1185
|
}, []);
|
|
1180
1186
|
return {
|
|
1181
|
-
speak:
|
|
1182
|
-
stop:
|
|
1183
|
-
isPlaying:
|
|
1184
|
-
isLoading:
|
|
1187
|
+
speak: n,
|
|
1188
|
+
stop: l,
|
|
1189
|
+
isPlaying: i,
|
|
1190
|
+
isLoading: a,
|
|
1185
1191
|
error: c
|
|
1186
1192
|
};
|
|
1187
|
-
}, Xe = ({ className:
|
|
1188
|
-
const
|
|
1189
|
-
return
|
|
1193
|
+
}, Xe = ({ className: r = "" }) => {
|
|
1194
|
+
const i = S(null);
|
|
1195
|
+
return P(() => {
|
|
1190
1196
|
let e = null;
|
|
1191
1197
|
return (async () => {
|
|
1192
1198
|
try {
|
|
1193
1199
|
e = await navigator.mediaDevices.getUserMedia({
|
|
1194
1200
|
video: !0,
|
|
1195
1201
|
audio: !1
|
|
1196
|
-
}),
|
|
1202
|
+
}), i.current && (i.current.srcObject = e);
|
|
1197
1203
|
} catch (s) {
|
|
1198
1204
|
console.error("Error accessing camera:", s);
|
|
1199
1205
|
}
|
|
1200
1206
|
})(), () => {
|
|
1201
1207
|
e && e.getTracks().forEach((s) => s.stop());
|
|
1202
1208
|
};
|
|
1203
|
-
}, []), /* @__PURE__ */ t.jsx("div", { className: `iw-relative ${
|
|
1209
|
+
}, []), /* @__PURE__ */ t.jsx("div", { className: `iw-relative ${r}`, children: /* @__PURE__ */ t.jsx(
|
|
1204
1210
|
"video",
|
|
1205
1211
|
{
|
|
1206
|
-
ref:
|
|
1212
|
+
ref: i,
|
|
1207
1213
|
autoPlay: !0,
|
|
1214
|
+
playsInline: !0,
|
|
1208
1215
|
muted: !0,
|
|
1209
|
-
hidden: !0,
|
|
1210
1216
|
className: "iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-md iw-min-h-[400px] iw-max-h-[600px] iw-aspect-video",
|
|
1211
1217
|
style: {
|
|
1212
1218
|
transform: "scaleX(-1)"
|
|
1213
1219
|
}
|
|
1214
1220
|
}
|
|
1215
1221
|
) });
|
|
1216
|
-
},
|
|
1217
|
-
const { baseColor:
|
|
1222
|
+
}, K = (r) => {
|
|
1223
|
+
const { baseColor: i, borderRadius: e } = Y(), { loading: a, children: s, ...c } = r;
|
|
1218
1224
|
return /* @__PURE__ */ t.jsx(
|
|
1219
|
-
|
|
1225
|
+
ne,
|
|
1220
1226
|
{
|
|
1221
1227
|
style: {
|
|
1222
|
-
background:
|
|
1228
|
+
background: fe(i),
|
|
1223
1229
|
borderRadius: e
|
|
1224
1230
|
},
|
|
1225
1231
|
...c,
|
|
1226
|
-
children:
|
|
1232
|
+
children: a ? /* @__PURE__ */ t.jsx(me, {}) : s
|
|
1227
1233
|
}
|
|
1228
1234
|
);
|
|
1229
|
-
},
|
|
1235
|
+
}, oe = (r) => /* @__PURE__ */ t.jsxs(
|
|
1230
1236
|
"svg",
|
|
1231
1237
|
{
|
|
1232
1238
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1238,7 +1244,7 @@ const re = new Ve(), Je = (i = {}) => {
|
|
|
1238
1244
|
strokeWidth: "2",
|
|
1239
1245
|
strokeLinecap: "round",
|
|
1240
1246
|
strokeLinejoin: "round",
|
|
1241
|
-
...
|
|
1247
|
+
...r,
|
|
1242
1248
|
children: [
|
|
1243
1249
|
/* @__PURE__ */ t.jsx("path", { d: "M12 2a10 10 0 0 1 7.38 16.75" }),
|
|
1244
1250
|
/* @__PURE__ */ t.jsx("path", { d: "M12 6v6l4 2" }),
|
|
@@ -1248,27 +1254,27 @@ const re = new Ve(), Je = (i = {}) => {
|
|
|
1248
1254
|
/* @__PURE__ */ t.jsx("path", { d: "M8.644 21.42a10 10 0 0 0 7.631-.38" })
|
|
1249
1255
|
]
|
|
1250
1256
|
}
|
|
1251
|
-
), Ze = (
|
|
1252
|
-
const
|
|
1253
|
-
return `${e}:${
|
|
1254
|
-
},
|
|
1255
|
-
total:
|
|
1256
|
-
remaining:
|
|
1257
|
+
), Ze = (r, i, e) => Math.max(i, Math.min(e, r)), de = (r) => {
|
|
1258
|
+
const i = Math.max(0, Math.floor(r)), e = Math.floor(i / 60).toString().padStart(2, "0"), a = (i % 60).toString().padStart(2, "0");
|
|
1259
|
+
return `${e}:${a}`;
|
|
1260
|
+
}, ce = ({
|
|
1261
|
+
total: r,
|
|
1262
|
+
remaining: i,
|
|
1257
1263
|
size: e = 64,
|
|
1258
|
-
strokeWidth:
|
|
1264
|
+
strokeWidth: a = 6,
|
|
1259
1265
|
className: s = "",
|
|
1260
1266
|
showLabel: c = !0
|
|
1261
1267
|
}) => {
|
|
1262
|
-
const
|
|
1263
|
-
const
|
|
1264
|
-
return { radius:
|
|
1265
|
-
}, [e,
|
|
1268
|
+
const o = Math.max(1, r || 1), n = Ze(i / o, 0, 1), { radius: l, circumference: m, dashOffset: w, center: h } = J(() => {
|
|
1269
|
+
const j = (e - a) / 2, y = 2 * Math.PI * j, I = y * (1 - n), d = Math.round(a) % 2 === 1, x = e / 2 + (d ? 0.5 : 0);
|
|
1270
|
+
return { radius: j, circumference: y, dashOffset: I, center: x };
|
|
1271
|
+
}, [e, a, n]), u = J(() => n <= 0.25 ? "iw-stroke-red-500" : n <= 0.5 ? "iw-stroke-yellow-500" : "iw-stroke-green-500", [n]), g = n <= 0.25 ? "iw-animate-pulse" : "";
|
|
1266
1272
|
return /* @__PURE__ */ t.jsxs(
|
|
1267
1273
|
"div",
|
|
1268
1274
|
{
|
|
1269
1275
|
className: `iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${s}`,
|
|
1270
1276
|
style: { width: e, height: e },
|
|
1271
|
-
"aria-label": `Time remaining ${
|
|
1277
|
+
"aria-label": `Time remaining ${de(i)}`,
|
|
1272
1278
|
role: "timer",
|
|
1273
1279
|
"aria-live": "polite",
|
|
1274
1280
|
children: [
|
|
@@ -1285,9 +1291,9 @@ const re = new Ve(), Je = (i = {}) => {
|
|
|
1285
1291
|
{
|
|
1286
1292
|
cx: h,
|
|
1287
1293
|
cy: h,
|
|
1288
|
-
r:
|
|
1294
|
+
r: l,
|
|
1289
1295
|
className: "iw-stroke-gray-200",
|
|
1290
|
-
strokeWidth:
|
|
1296
|
+
strokeWidth: a,
|
|
1291
1297
|
fill: "none",
|
|
1292
1298
|
shapeRendering: "geometricPrecision",
|
|
1293
1299
|
vectorEffect: "non-scaling-stroke"
|
|
@@ -1298,13 +1304,13 @@ const re = new Ve(), Je = (i = {}) => {
|
|
|
1298
1304
|
{
|
|
1299
1305
|
cx: h,
|
|
1300
1306
|
cy: h,
|
|
1301
|
-
r:
|
|
1302
|
-
className: `${u} ${
|
|
1303
|
-
strokeWidth:
|
|
1307
|
+
r: l,
|
|
1308
|
+
className: `${u} ${g}`,
|
|
1309
|
+
strokeWidth: a,
|
|
1304
1310
|
strokeLinecap: "round",
|
|
1305
1311
|
fill: "none",
|
|
1306
|
-
strokeDasharray:
|
|
1307
|
-
strokeDashoffset:
|
|
1312
|
+
strokeDasharray: m,
|
|
1313
|
+
strokeDashoffset: w,
|
|
1308
1314
|
shapeRendering: "geometricPrecision",
|
|
1309
1315
|
vectorEffect: "non-scaling-stroke",
|
|
1310
1316
|
style: {
|
|
@@ -1318,69 +1324,69 @@ const re = new Ve(), Je = (i = {}) => {
|
|
|
1318
1324
|
c && /* @__PURE__ */ t.jsx("div", { className: "iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0", children: /* @__PURE__ */ t.jsx(
|
|
1319
1325
|
"span",
|
|
1320
1326
|
{
|
|
1321
|
-
className: `iw-text-[11px] iw-font-semibold iw-tabular-nums ${
|
|
1322
|
-
children:
|
|
1327
|
+
className: `iw-text-[11px] iw-font-semibold iw-tabular-nums ${n <= 0.25 ? "iw-text-red-600" : n <= 0.5 ? "iw-text-yellow-600" : "iw-text-green-600"}`,
|
|
1328
|
+
children: de(i)
|
|
1323
1329
|
}
|
|
1324
1330
|
) })
|
|
1325
1331
|
]
|
|
1326
1332
|
}
|
|
1327
1333
|
);
|
|
1328
1334
|
}, Ke = ({
|
|
1329
|
-
label:
|
|
1330
|
-
error:
|
|
1335
|
+
label: r,
|
|
1336
|
+
error: i,
|
|
1331
1337
|
fullWidth: e = !1,
|
|
1332
|
-
className:
|
|
1338
|
+
className: a = "",
|
|
1333
1339
|
id: s,
|
|
1334
1340
|
...c
|
|
1335
1341
|
}) => {
|
|
1336
|
-
const
|
|
1342
|
+
const o = s || `textarea-${Math.random().toString(36).substring(2, 9)}`, n = "iw-block iw-rounded-md iw-border iw-border-gray-300 iw-shadow-sm iw-px-4 iw-py-2 iw-text-sm iw-transition-all", l = i ? "iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500" : "", m = e ? "iw-w-full" : "", w = a.includes("iw-h-full") || e ? "iw-h-full" : "";
|
|
1337
1343
|
return /* @__PURE__ */ t.jsxs(
|
|
1338
1344
|
"div",
|
|
1339
1345
|
{
|
|
1340
1346
|
className: `iw-h-full iw-flex iw-flex-col ${e ? "iw-w-full" : ""}`,
|
|
1341
1347
|
children: [
|
|
1342
|
-
|
|
1348
|
+
r && /* @__PURE__ */ t.jsx(
|
|
1343
1349
|
"label",
|
|
1344
1350
|
{
|
|
1345
|
-
htmlFor:
|
|
1351
|
+
htmlFor: o,
|
|
1346
1352
|
className: "iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",
|
|
1347
|
-
children:
|
|
1353
|
+
children: r
|
|
1348
1354
|
}
|
|
1349
1355
|
),
|
|
1350
1356
|
/* @__PURE__ */ t.jsx(
|
|
1351
1357
|
"textarea",
|
|
1352
1358
|
{
|
|
1353
|
-
id:
|
|
1354
|
-
className: `${
|
|
1355
|
-
"aria-invalid":
|
|
1359
|
+
id: o,
|
|
1360
|
+
className: `${n} ${l} ${m} ${w} ${a}`,
|
|
1361
|
+
"aria-invalid": i ? "true" : "false",
|
|
1356
1362
|
...c
|
|
1357
1363
|
}
|
|
1358
1364
|
),
|
|
1359
|
-
|
|
1365
|
+
i && /* @__PURE__ */ t.jsx("p", { className: "iw-mt-1 iw-text-sm iw-text-red-600", children: i })
|
|
1360
1366
|
]
|
|
1361
1367
|
}
|
|
1362
1368
|
);
|
|
1363
1369
|
}, et = ({
|
|
1364
|
-
value:
|
|
1365
|
-
onChange:
|
|
1370
|
+
value: r,
|
|
1371
|
+
onChange: i,
|
|
1366
1372
|
onSubmit: e,
|
|
1367
|
-
isSubmitDisabled:
|
|
1373
|
+
isSubmitDisabled: a,
|
|
1368
1374
|
state: s,
|
|
1369
1375
|
editingTime: c
|
|
1370
1376
|
}) => {
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1377
|
+
const o = (n) => {
|
|
1378
|
+
n.key === "Enter" && (n.ctrlKey || n.metaKey) && !a && (n.preventDefault(), e());
|
|
1373
1379
|
};
|
|
1374
1380
|
return /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-h-full ", children: [
|
|
1375
1381
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between", children: [
|
|
1376
1382
|
/* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "Your Answer" }),
|
|
1377
1383
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
|
|
1378
1384
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
|
|
1379
|
-
/* @__PURE__ */ t.jsx(
|
|
1385
|
+
/* @__PURE__ */ t.jsx(oe, { className: "iw-size-4 iw-text-orange-600" }),
|
|
1380
1386
|
/* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to edit: " })
|
|
1381
1387
|
] }),
|
|
1382
1388
|
/* @__PURE__ */ t.jsx(
|
|
1383
|
-
|
|
1389
|
+
ce,
|
|
1384
1390
|
{
|
|
1385
1391
|
total: c,
|
|
1386
1392
|
remaining: s.currentPhaseTimeRemaining,
|
|
@@ -1394,141 +1400,141 @@ const re = new Ve(), Je = (i = {}) => {
|
|
|
1394
1400
|
/* @__PURE__ */ t.jsx(
|
|
1395
1401
|
Ke,
|
|
1396
1402
|
{
|
|
1397
|
-
value:
|
|
1398
|
-
onChange:
|
|
1399
|
-
onKeyDown:
|
|
1403
|
+
value: r,
|
|
1404
|
+
onChange: i,
|
|
1405
|
+
onKeyDown: o,
|
|
1400
1406
|
placeholder: "Type your answer here...",
|
|
1401
1407
|
className: " iw-w-full iw-h-full iw-flex-1 iw-resize-none !iw-p-4 iw-bg-transparent iw-min-h-full focus-visible:iw-outline-0",
|
|
1402
|
-
onPaste: (
|
|
1403
|
-
onCopy: (
|
|
1404
|
-
onCut: (
|
|
1405
|
-
onDrop: (
|
|
1406
|
-
onDragOver: (
|
|
1408
|
+
onPaste: (n) => n.preventDefault(),
|
|
1409
|
+
onCopy: (n) => n.preventDefault(),
|
|
1410
|
+
onCut: (n) => n.preventDefault(),
|
|
1411
|
+
onDrop: (n) => n.preventDefault(),
|
|
1412
|
+
onDragOver: (n) => n.preventDefault()
|
|
1407
1413
|
}
|
|
1408
1414
|
),
|
|
1409
|
-
/* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1 iw-mt-4", children: /* @__PURE__ */ t.jsx(
|
|
1415
|
+
/* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1 iw-mt-4", children: /* @__PURE__ */ t.jsx(K, { onClick: e, disabled: a, children: "Submit Answer" }) })
|
|
1410
1416
|
] })
|
|
1411
1417
|
] });
|
|
1412
1418
|
}, tt = ({
|
|
1413
|
-
className:
|
|
1414
|
-
width:
|
|
1419
|
+
className: r = "",
|
|
1420
|
+
width: i,
|
|
1415
1421
|
height: e = 56,
|
|
1416
|
-
barWidth:
|
|
1422
|
+
barWidth: a = 3,
|
|
1417
1423
|
gap: s = 2,
|
|
1418
1424
|
fftSize: c = 1024,
|
|
1419
|
-
smoothingTimeConstant:
|
|
1420
|
-
mediaStream:
|
|
1421
|
-
startOnMount:
|
|
1425
|
+
smoothingTimeConstant: o = 0.8,
|
|
1426
|
+
mediaStream: n,
|
|
1427
|
+
startOnMount: l = !0
|
|
1422
1428
|
}) => {
|
|
1423
|
-
const { baseColor:
|
|
1424
|
-
|
|
1425
|
-
if (
|
|
1426
|
-
const
|
|
1427
|
-
const
|
|
1428
|
-
if (!
|
|
1429
|
-
const
|
|
1430
|
-
|
|
1431
|
-
},
|
|
1432
|
-
return
|
|
1433
|
-
}, [
|
|
1434
|
-
if (!
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1429
|
+
const { baseColor: m } = Y(), w = S(null), h = S(null), u = S(null), g = S(null), j = S(null), y = S(null), I = S(!1), [d, x] = k(null);
|
|
1430
|
+
P(() => {
|
|
1431
|
+
if (i || !h.current) return;
|
|
1432
|
+
const p = h.current, $ = () => {
|
|
1433
|
+
const N = w.current;
|
|
1434
|
+
if (!N) return;
|
|
1435
|
+
const T = p.clientWidth, C = e;
|
|
1436
|
+
N.width = Math.max(1, Math.floor(T * window.devicePixelRatio || 1)), N.height = Math.max(1, Math.floor(C * window.devicePixelRatio || 1));
|
|
1437
|
+
}, b = new ResizeObserver($);
|
|
1438
|
+
return b.observe(p), $(), () => b.disconnect();
|
|
1439
|
+
}, [i, e]), P(() => {
|
|
1440
|
+
if (!i) return;
|
|
1441
|
+
const p = w.current;
|
|
1442
|
+
p && (p.width = Math.max(
|
|
1437
1443
|
1,
|
|
1438
|
-
Math.floor(
|
|
1439
|
-
),
|
|
1444
|
+
Math.floor(i * (window.devicePixelRatio || 1))
|
|
1445
|
+
), p.height = Math.max(
|
|
1440
1446
|
1,
|
|
1441
1447
|
Math.floor(e * (window.devicePixelRatio || 1))
|
|
1442
1448
|
));
|
|
1443
|
-
}, [
|
|
1444
|
-
let
|
|
1449
|
+
}, [i, e]), P(() => {
|
|
1450
|
+
let p = !1;
|
|
1445
1451
|
return (async () => {
|
|
1446
1452
|
try {
|
|
1447
|
-
const
|
|
1448
|
-
u.current =
|
|
1449
|
-
let
|
|
1450
|
-
if (!
|
|
1451
|
-
if (!
|
|
1452
|
-
|
|
1453
|
+
const b = new (window.AudioContext || window.webkitAudioContext)();
|
|
1454
|
+
u.current = b;
|
|
1455
|
+
let N = n;
|
|
1456
|
+
if (!N) {
|
|
1457
|
+
if (!l) return;
|
|
1458
|
+
N = await navigator.mediaDevices.getUserMedia({
|
|
1453
1459
|
audio: !0,
|
|
1454
1460
|
video: !1
|
|
1455
|
-
}),
|
|
1461
|
+
}), I.current = !0;
|
|
1456
1462
|
}
|
|
1457
|
-
if (
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
const C =
|
|
1461
|
-
|
|
1462
|
-
} catch (
|
|
1463
|
-
|
|
1463
|
+
if (p) return;
|
|
1464
|
+
const T = b.createAnalyser();
|
|
1465
|
+
T.fftSize = c, T.smoothingTimeConstant = o, g.current = T;
|
|
1466
|
+
const C = b.createMediaStreamSource(N);
|
|
1467
|
+
j.current = C, C.connect(T), M();
|
|
1468
|
+
} catch (b) {
|
|
1469
|
+
x((b == null ? void 0 : b.message) || "Failed to initialize microphone");
|
|
1464
1470
|
}
|
|
1465
1471
|
})(), () => {
|
|
1466
|
-
var
|
|
1467
|
-
|
|
1472
|
+
var b, N, T, C;
|
|
1473
|
+
p = !0, y.current && cancelAnimationFrame(y.current);
|
|
1468
1474
|
try {
|
|
1469
|
-
(
|
|
1475
|
+
(b = j.current) == null || b.disconnect();
|
|
1470
1476
|
} catch {
|
|
1471
1477
|
}
|
|
1472
1478
|
try {
|
|
1473
|
-
(
|
|
1479
|
+
(N = g.current) == null || N.disconnect();
|
|
1474
1480
|
} catch {
|
|
1475
1481
|
}
|
|
1476
|
-
|
|
1482
|
+
I.current && ((C = ((T = j.current) == null ? void 0 : T.mediaStream) || void 0) == null || C.getTracks().forEach((q) => q.stop())), u.current && u.current.state !== "closed" && u.current.close();
|
|
1477
1483
|
};
|
|
1478
|
-
}, [
|
|
1484
|
+
}, [n, c, o, l]);
|
|
1479
1485
|
const M = () => {
|
|
1480
|
-
const
|
|
1481
|
-
if (!
|
|
1482
|
-
const
|
|
1483
|
-
if (!
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1486
|
-
const
|
|
1487
|
-
for (let
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1490
|
-
const ye = Math.min(
|
|
1491
|
-
rt(
|
|
1486
|
+
const p = w.current, $ = g.current;
|
|
1487
|
+
if (!p || !$) return;
|
|
1488
|
+
const b = p.getContext("2d");
|
|
1489
|
+
if (!b) return;
|
|
1490
|
+
const N = window.devicePixelRatio || 1, T = p.width, C = p.height, q = $.frequencyBinCount, F = new Uint8Array(q), Q = () => {
|
|
1491
|
+
y.current = requestAnimationFrame(Q), $.getByteTimeDomainData(F), b.clearRect(0, 0, T, C), b.fillStyle = "rgba(0,0,0,0)", b.fillRect(0, 0, T, C);
|
|
1492
|
+
const _ = Math.max(1, Math.floor(a * N)), U = Math.max(1, Math.floor(s * N)), E = _ + U, B = Math.max(8, Math.floor((T + U) / E)), ee = Math.floor(F.length / B);
|
|
1493
|
+
for (let z = 0; z < B; z++) {
|
|
1494
|
+
const te = Math.min(F.length - 1, z * ee), re = F[te] / 128 - 1, G = Math.abs(re), ie = Math.pow(G, 0.6), W = Math.max(C * 0.06, ie * (C * 0.9)), f = z * E, O = (C - W) / 2, V = 140 - Math.min(140, 140 * G), pe = 85, be = 48 + Math.floor(12 * (1 - G));
|
|
1495
|
+
b.fillStyle = `${m}`, b.shadowColor = `hsla(${V}, ${pe}%, ${be}%, ${0.25 * G})`, b.shadowBlur = 8 * G;
|
|
1496
|
+
const ye = Math.min(_ / 2, W / 2);
|
|
1497
|
+
rt(b, f, O, _, W, ye), b.fill();
|
|
1492
1498
|
}
|
|
1493
1499
|
};
|
|
1494
|
-
|
|
1500
|
+
Q();
|
|
1495
1501
|
};
|
|
1496
1502
|
return /* @__PURE__ */ t.jsxs(
|
|
1497
1503
|
"div",
|
|
1498
1504
|
{
|
|
1499
1505
|
ref: h,
|
|
1500
|
-
className: `iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${
|
|
1506
|
+
className: `iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${r}`,
|
|
1501
1507
|
style: { height: e },
|
|
1502
1508
|
children: [
|
|
1503
|
-
/* @__PURE__ */ t.jsx("canvas", { ref:
|
|
1504
|
-
|
|
1509
|
+
/* @__PURE__ */ t.jsx("canvas", { ref: w, className: "iw-w-full iw-h-full" }),
|
|
1510
|
+
d && /* @__PURE__ */ t.jsx("div", { className: "iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center", children: /* @__PURE__ */ t.jsx("span", { className: "iw-text-xs iw-text-red-600 iw-bg-red-50 iw-border iw-border-red-200 iw-px-2 iw-py-1 iw-rounded", children: d }) })
|
|
1505
1511
|
]
|
|
1506
1512
|
}
|
|
1507
1513
|
);
|
|
1508
1514
|
};
|
|
1509
|
-
function rt(
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1515
|
+
function rt(r, i, e, a, s, c) {
|
|
1516
|
+
const o = Math.min(c, a / 2, s / 2);
|
|
1517
|
+
r.beginPath(), r.moveTo(i + o, e), r.lineTo(i + a - o, e), r.quadraticCurveTo(i + a, e, i + a, e + o), r.lineTo(i + a, e + s - o), r.quadraticCurveTo(i + a, e + s, i + a - o, e + s), r.lineTo(i + o, e + s), r.quadraticCurveTo(i, e + s, i, e + s - o), r.lineTo(i, e + o), r.quadraticCurveTo(i, e, i + o, e), r.closePath();
|
|
1512
1518
|
}
|
|
1513
1519
|
const it = ({
|
|
1514
|
-
state:
|
|
1515
|
-
answeringTime:
|
|
1520
|
+
state: r,
|
|
1521
|
+
answeringTime: i,
|
|
1516
1522
|
nextPhase: e,
|
|
1517
|
-
sttError:
|
|
1523
|
+
sttError: a
|
|
1518
1524
|
}) => /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-justify-between iw-h-full ", children: [
|
|
1519
1525
|
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
1520
1526
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between", children: [
|
|
1521
1527
|
/* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "You may start speaking now. We're listening...." }),
|
|
1522
1528
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
|
|
1523
1529
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
|
|
1524
|
-
/* @__PURE__ */ t.jsx(
|
|
1530
|
+
/* @__PURE__ */ t.jsx(oe, { className: "iw-size-4 iw-text-orange-600" }),
|
|
1525
1531
|
/* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to talk: " })
|
|
1526
1532
|
] }),
|
|
1527
1533
|
/* @__PURE__ */ t.jsx(
|
|
1528
|
-
|
|
1534
|
+
ce,
|
|
1529
1535
|
{
|
|
1530
|
-
total:
|
|
1531
|
-
remaining:
|
|
1536
|
+
total: i,
|
|
1537
|
+
remaining: r.currentPhaseTimeRemaining,
|
|
1532
1538
|
size: 50,
|
|
1533
1539
|
strokeWidth: 4
|
|
1534
1540
|
}
|
|
@@ -1539,13 +1545,13 @@ const it = ({
|
|
|
1539
1545
|
] }),
|
|
1540
1546
|
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
1541
1547
|
/* @__PURE__ */ t.jsx(tt, {}),
|
|
1542
|
-
|
|
1548
|
+
a && /* @__PURE__ */ t.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
|
|
1543
1549
|
"Recording error: ",
|
|
1544
|
-
|
|
1550
|
+
a.message
|
|
1545
1551
|
] })
|
|
1546
1552
|
] }),
|
|
1547
1553
|
/* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1", children: /* @__PURE__ */ t.jsx(
|
|
1548
|
-
|
|
1554
|
+
K,
|
|
1549
1555
|
{
|
|
1550
1556
|
onClick: () => {
|
|
1551
1557
|
e();
|
|
@@ -1555,18 +1561,18 @@ const it = ({
|
|
|
1555
1561
|
) })
|
|
1556
1562
|
] });
|
|
1557
1563
|
function st() {
|
|
1558
|
-
const [
|
|
1559
|
-
() => [0, 1, 2].map((
|
|
1564
|
+
const [r, i] = k(!0), e = J(
|
|
1565
|
+
() => [0, 1, 2].map((a) => ({ id: a })),
|
|
1560
1566
|
[]
|
|
1561
1567
|
);
|
|
1562
|
-
return
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1568
|
+
return P(() => {
|
|
1569
|
+
const a = setInterval(() => {
|
|
1570
|
+
i((s) => !s);
|
|
1565
1571
|
}, 1500);
|
|
1566
|
-
return () => clearInterval(
|
|
1572
|
+
return () => clearInterval(a);
|
|
1567
1573
|
}, []), /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full", children: [
|
|
1568
|
-
/* @__PURE__ */ t.jsx("div", { className: "iw-relative iw-w-80 iw-h-48 ", "aria-hidden": !0, children: e.map((
|
|
1569
|
-
const c = s * 50,
|
|
1574
|
+
/* @__PURE__ */ t.jsx("div", { className: "iw-relative iw-w-80 iw-h-48 ", "aria-hidden": !0, children: e.map((a, s) => {
|
|
1575
|
+
const c = s * 50, o = r ? c : c + 12, n = r ? 1 : 0.08, l = s * 140;
|
|
1570
1576
|
return /* @__PURE__ */ t.jsx(
|
|
1571
1577
|
"div",
|
|
1572
1578
|
{
|
|
@@ -1574,9 +1580,9 @@ function st() {
|
|
|
1574
1580
|
className: "iw-absolute iw-w-full iw-rounded-lg iw-p-4 iw-shadow-md iw-bg-gradient-to-b iw-from-gray-50 iw-to-gray-100 iw-overflow-hidden",
|
|
1575
1581
|
style: {
|
|
1576
1582
|
top: 0,
|
|
1577
|
-
transform: `translateY(${
|
|
1578
|
-
opacity:
|
|
1579
|
-
transition: `transform 600ms cubic-bezier(.2,.9,.3,1) ${
|
|
1583
|
+
transform: `translateY(${o}px)`,
|
|
1584
|
+
opacity: n,
|
|
1585
|
+
transition: `transform 600ms cubic-bezier(.2,.9,.3,1) ${l}ms, opacity 400ms ease ${l}ms`
|
|
1580
1586
|
},
|
|
1581
1587
|
children: /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-gap-3 iw-items-center", children: [
|
|
1582
1588
|
/* @__PURE__ */ t.jsx("div", { className: "iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0" }),
|
|
@@ -1586,62 +1592,62 @@ function st() {
|
|
|
1586
1592
|
] })
|
|
1587
1593
|
] })
|
|
1588
1594
|
},
|
|
1589
|
-
|
|
1595
|
+
a.id
|
|
1590
1596
|
);
|
|
1591
1597
|
}) }),
|
|
1592
1598
|
/* @__PURE__ */ t.jsx("div", { className: "iw-text-center", children: /* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-500 iw-font-medium", children: "Preparing your question..." }) })
|
|
1593
1599
|
] });
|
|
1594
1600
|
}
|
|
1595
|
-
const
|
|
1596
|
-
isOpen:
|
|
1597
|
-
onClose:
|
|
1601
|
+
const xe = ({
|
|
1602
|
+
isOpen: r,
|
|
1603
|
+
onClose: i,
|
|
1598
1604
|
children: e,
|
|
1599
|
-
title:
|
|
1605
|
+
title: a,
|
|
1600
1606
|
showCloseButton: s = !0,
|
|
1601
1607
|
closeOnOverlayClick: c = !0,
|
|
1602
|
-
closeOnEscape:
|
|
1603
|
-
className:
|
|
1608
|
+
closeOnEscape: o = !0,
|
|
1609
|
+
className: n = ""
|
|
1604
1610
|
}) => {
|
|
1605
|
-
if (
|
|
1606
|
-
if (!
|
|
1607
|
-
const
|
|
1608
|
-
h.key === "Escape" &&
|
|
1611
|
+
if (P(() => {
|
|
1612
|
+
if (!r || !o) return;
|
|
1613
|
+
const w = (h) => {
|
|
1614
|
+
h.key === "Escape" && i();
|
|
1609
1615
|
};
|
|
1610
|
-
return document.addEventListener("keydown",
|
|
1611
|
-
}, [
|
|
1616
|
+
return document.addEventListener("keydown", w), () => document.removeEventListener("keydown", w);
|
|
1617
|
+
}, [r, o, i]), P(() => (r ? (document.body.style.overflow = "hidden", document.body.classList.add("interview-widget-container")) : (document.body.style.overflow = "unset", document.body.classList.remove("interview-widget-container")), () => {
|
|
1612
1618
|
document.body.style.overflow = "unset", document.body.classList.remove("interview-widget-container");
|
|
1613
|
-
}), [
|
|
1614
|
-
const
|
|
1615
|
-
c &&
|
|
1616
|
-
},
|
|
1619
|
+
}), [r]), !r) return null;
|
|
1620
|
+
const l = (w) => {
|
|
1621
|
+
c && w.target === w.currentTarget && i();
|
|
1622
|
+
}, m = /* @__PURE__ */ t.jsxs("div", { className: "iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center", children: [
|
|
1617
1623
|
/* @__PURE__ */ t.jsx(
|
|
1618
1624
|
"div",
|
|
1619
1625
|
{
|
|
1620
1626
|
className: "iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",
|
|
1621
|
-
onClick:
|
|
1627
|
+
onClick: l
|
|
1622
1628
|
}
|
|
1623
1629
|
),
|
|
1624
1630
|
/* @__PURE__ */ t.jsxs(
|
|
1625
1631
|
"div",
|
|
1626
1632
|
{
|
|
1627
|
-
className: `iw-relative iw-bg-white iw-rounded-lg iw-shadow-xl iw-max-w-md iw-w-full iw-mx-4 iw-max-h-[90vh] iw-overflow-hidden ${
|
|
1633
|
+
className: `iw-relative iw-bg-white iw-rounded-lg iw-shadow-xl iw-max-w-md iw-w-full iw-mx-4 iw-max-h-[90vh] iw-overflow-hidden ${n}`,
|
|
1628
1634
|
role: "dialog",
|
|
1629
1635
|
"aria-modal": "true",
|
|
1630
|
-
"aria-labelledby":
|
|
1636
|
+
"aria-labelledby": a ? "dialog-title" : void 0,
|
|
1631
1637
|
children: [
|
|
1632
|
-
(
|
|
1633
|
-
|
|
1638
|
+
(a || s) && /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200", children: [
|
|
1639
|
+
a && /* @__PURE__ */ t.jsx(
|
|
1634
1640
|
"h2",
|
|
1635
1641
|
{
|
|
1636
1642
|
id: "dialog-title",
|
|
1637
1643
|
className: "iw-text-lg iw-font-semibold iw-text-gray-900",
|
|
1638
|
-
children:
|
|
1644
|
+
children: a
|
|
1639
1645
|
}
|
|
1640
1646
|
),
|
|
1641
1647
|
s && /* @__PURE__ */ t.jsx(
|
|
1642
1648
|
"button",
|
|
1643
1649
|
{
|
|
1644
|
-
onClick:
|
|
1650
|
+
onClick: i,
|
|
1645
1651
|
className: "iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100",
|
|
1646
1652
|
"aria-label": "Close dialog",
|
|
1647
1653
|
children: /* @__PURE__ */ t.jsx(
|
|
@@ -1670,15 +1676,15 @@ const ge = ({
|
|
|
1670
1676
|
}
|
|
1671
1677
|
)
|
|
1672
1678
|
] });
|
|
1673
|
-
return ke(
|
|
1674
|
-
},
|
|
1675
|
-
open:
|
|
1676
|
-
onClose:
|
|
1679
|
+
return ke(m, document.body);
|
|
1680
|
+
}, nt = ({
|
|
1681
|
+
open: r,
|
|
1682
|
+
onClose: i
|
|
1677
1683
|
}) => /* @__PURE__ */ t.jsx(
|
|
1678
|
-
|
|
1684
|
+
xe,
|
|
1679
1685
|
{
|
|
1680
|
-
isOpen:
|
|
1681
|
-
onClose:
|
|
1686
|
+
isOpen: r,
|
|
1687
|
+
onClose: i || (() => {
|
|
1682
1688
|
}),
|
|
1683
1689
|
title: "Interview Complete!",
|
|
1684
1690
|
className: "",
|
|
@@ -1701,22 +1707,14 @@ const ge = ({
|
|
|
1701
1707
|
)
|
|
1702
1708
|
}
|
|
1703
1709
|
),
|
|
1704
|
-
/* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-600 iw-mb-6", children: "Thank you for your time. Your answers have been recorded and submitted for review." })
|
|
1705
|
-
/* @__PURE__ */ t.jsx(
|
|
1706
|
-
W,
|
|
1707
|
-
{
|
|
1708
|
-
className: "iw-mt-2 iw-px-6 iw-py-2 iw-bg-primary-500 iw-text-white iw-font-semibold iw-rounded-lg iw-shadow iw-transition hover:iw-bg-primary-600 focus:iw-outline-none",
|
|
1709
|
-
onClick: r,
|
|
1710
|
-
children: "Close"
|
|
1711
|
-
}
|
|
1712
|
-
)
|
|
1710
|
+
/* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-600 iw-mb-6", children: "Thank you for your time. Your answers have been recorded and submitted for review." })
|
|
1713
1711
|
] })
|
|
1714
1712
|
}
|
|
1715
|
-
),
|
|
1716
|
-
size:
|
|
1717
|
-
className:
|
|
1713
|
+
), at = ({
|
|
1714
|
+
size: r = "192px",
|
|
1715
|
+
className: i,
|
|
1718
1716
|
colors: e,
|
|
1719
|
-
animationDuration:
|
|
1717
|
+
animationDuration: a = 20
|
|
1720
1718
|
}) => {
|
|
1721
1719
|
const c = { ...{
|
|
1722
1720
|
bg: "oklch(95% 0.02 264.695)",
|
|
@@ -1726,23 +1724,23 @@ const ge = ({
|
|
|
1726
1724
|
// Pastel blue
|
|
1727
1725
|
c3: "oklch(78% 0.14 280)"
|
|
1728
1726
|
// Pastel purple/lavender
|
|
1729
|
-
}, ...e },
|
|
1727
|
+
}, ...e }, o = parseInt(r.replace("px", ""), 10), n = o < 50 ? Math.max(o * 8e-3, 1) : Math.max(o * 0.015, 4), l = o < 50 ? Math.max(o * 4e-3, 1.2) : Math.max(o * 8e-3, 1.5), m = o < 50 ? Math.max(o * 4e-3, 0.05) : Math.max(o * 8e-3, 0.1), w = o < 50 ? Math.max(o * 4e-3, 0.5) : Math.max(o * 8e-3, 2), h = o < 30 ? "0%" : o < 50 ? "5%" : o < 100 ? "15%" : "25%", u = o < 30 ? 1.1 : o < 50 ? Math.max(l * 1.2, 1.3) : l;
|
|
1730
1728
|
return /* @__PURE__ */ t.jsx(
|
|
1731
1729
|
"div",
|
|
1732
1730
|
{
|
|
1733
|
-
className: `siri-orb ${
|
|
1731
|
+
className: `siri-orb ${i}`,
|
|
1734
1732
|
style: {
|
|
1735
|
-
width:
|
|
1736
|
-
height:
|
|
1733
|
+
width: r,
|
|
1734
|
+
height: r,
|
|
1737
1735
|
"--bg": c.bg,
|
|
1738
1736
|
"--c1": c.c1,
|
|
1739
1737
|
"--c2": c.c2,
|
|
1740
1738
|
"--c3": c.c3,
|
|
1741
|
-
"--animation-duration": `${
|
|
1742
|
-
"--blur-amount": `${
|
|
1739
|
+
"--animation-duration": `${a}s`,
|
|
1740
|
+
"--blur-amount": `${n}px`,
|
|
1743
1741
|
"--contrast-amount": u,
|
|
1744
|
-
"--dot-size": `${
|
|
1745
|
-
"--shadow-spread": `${
|
|
1742
|
+
"--dot-size": `${m}px`,
|
|
1743
|
+
"--shadow-spread": `${w}px`,
|
|
1746
1744
|
"--mask-radius": h
|
|
1747
1745
|
},
|
|
1748
1746
|
children: /* @__PURE__ */ t.jsx("style", { children: `
|
|
@@ -1854,38 +1852,38 @@ const ge = ({
|
|
|
1854
1852
|
}
|
|
1855
1853
|
);
|
|
1856
1854
|
};
|
|
1857
|
-
function ot({ ttsError:
|
|
1855
|
+
function ot({ ttsError: r }) {
|
|
1858
1856
|
return /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full", children: [
|
|
1859
|
-
/* @__PURE__ */ t.jsx(
|
|
1860
|
-
|
|
1857
|
+
/* @__PURE__ */ t.jsx(at, { size: "80px" }),
|
|
1858
|
+
r && /* @__PURE__ */ t.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
|
|
1861
1859
|
"Audio playback failed: ",
|
|
1862
|
-
|
|
1860
|
+
r.message
|
|
1863
1861
|
] }),
|
|
1864
1862
|
/* @__PURE__ */ t.jsx("p", { className: "iw-text- iw-text-gray-700", children: "Your AI interviewer is speaking..." })
|
|
1865
1863
|
] });
|
|
1866
1864
|
}
|
|
1867
|
-
const ct = ({ state:
|
|
1865
|
+
const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ", children: [
|
|
1868
1866
|
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
1869
1867
|
/* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "Get Ready to Answer" }),
|
|
1870
1868
|
/* @__PURE__ */ t.jsx("p", { className: "iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]", children: "After 30-seconds thinking time, recording will start automatically, or you can begin recording early by clicking the button below." })
|
|
1871
1869
|
] }),
|
|
1872
1870
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
|
|
1873
1871
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
|
|
1874
|
-
/* @__PURE__ */ t.jsx(
|
|
1872
|
+
/* @__PURE__ */ t.jsx(oe, { className: "iw-size-4 iw-text-orange-600" }),
|
|
1875
1873
|
/* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to think: " })
|
|
1876
1874
|
] }),
|
|
1877
1875
|
/* @__PURE__ */ t.jsx(
|
|
1878
|
-
|
|
1876
|
+
ce,
|
|
1879
1877
|
{
|
|
1880
|
-
total:
|
|
1881
|
-
remaining:
|
|
1878
|
+
total: i,
|
|
1879
|
+
remaining: r.currentPhaseTimeRemaining,
|
|
1882
1880
|
size: 50,
|
|
1883
1881
|
strokeWidth: 4
|
|
1884
1882
|
}
|
|
1885
1883
|
)
|
|
1886
1884
|
] }),
|
|
1887
1885
|
/* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1", children: /* @__PURE__ */ t.jsx(
|
|
1888
|
-
|
|
1886
|
+
K,
|
|
1889
1887
|
{
|
|
1890
1888
|
onClick: () => {
|
|
1891
1889
|
e();
|
|
@@ -1893,7 +1891,7 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
1893
1891
|
children: "Start Answering"
|
|
1894
1892
|
}
|
|
1895
1893
|
) })
|
|
1896
|
-
] }), lt = ({ sttError:
|
|
1894
|
+
] }), lt = ({ sttError: r }) => /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full", children: [
|
|
1897
1895
|
/* @__PURE__ */ t.jsxs("svg", { width: "48", height: "48", viewBox: "0 0 60 60", fill: "none", children: [
|
|
1898
1896
|
/* @__PURE__ */ t.jsx(
|
|
1899
1897
|
"rect",
|
|
@@ -1929,12 +1927,12 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
1929
1927
|
] }),
|
|
1930
1928
|
/* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1 iw-mt-3", children: "Just a moment... We're analyzing your response" }),
|
|
1931
1929
|
/* @__PURE__ */ t.jsx("p", { className: "iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]", children: "After transcription, you'll have 45 sec to review your answer." }),
|
|
1932
|
-
|
|
1930
|
+
r && /* @__PURE__ */ t.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
|
|
1933
1931
|
"Transcription error: ",
|
|
1934
|
-
|
|
1935
|
-
|
|
1932
|
+
r.message,
|
|
1933
|
+
r.recoverable && " (attempting to continue)"
|
|
1936
1934
|
] })
|
|
1937
|
-
] }), dt = (
|
|
1935
|
+
] }), dt = (r) => /* @__PURE__ */ t.jsxs(
|
|
1938
1936
|
"svg",
|
|
1939
1937
|
{
|
|
1940
1938
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1946,7 +1944,7 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
1946
1944
|
strokeWidth: "2",
|
|
1947
1945
|
strokeLinecap: "round",
|
|
1948
1946
|
strokeLinejoin: "round",
|
|
1949
|
-
...
|
|
1947
|
+
...r,
|
|
1950
1948
|
children: [
|
|
1951
1949
|
/* @__PURE__ */ t.jsx("path", { d: "M12 8V4H8" }),
|
|
1952
1950
|
/* @__PURE__ */ t.jsx("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }),
|
|
@@ -1957,10 +1955,10 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
1957
1955
|
]
|
|
1958
1956
|
}
|
|
1959
1957
|
), wt = ({
|
|
1960
|
-
question:
|
|
1961
|
-
isLoading:
|
|
1958
|
+
question: r,
|
|
1959
|
+
isLoading: i = !1
|
|
1962
1960
|
}) => {
|
|
1963
|
-
const { baseColor: e } =
|
|
1961
|
+
const { baseColor: e } = Y();
|
|
1964
1962
|
return /* @__PURE__ */ t.jsx(
|
|
1965
1963
|
"div",
|
|
1966
1964
|
{
|
|
@@ -1977,18 +1975,18 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
1977
1975
|
) }),
|
|
1978
1976
|
/* @__PURE__ */ t.jsx("div", { className: "iw-absolute iw-bottom-2 iw-translate-x-1/2 iw-flex iw-mt-2", children: /* @__PURE__ */ t.jsx("div", { className: "iw-text-sm", children: "Novara" }) })
|
|
1979
1977
|
] }),
|
|
1980
|
-
|
|
1978
|
+
i ? /* @__PURE__ */ t.jsxs("div", { className: "iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10", children: [
|
|
1981
1979
|
/* @__PURE__ */ t.jsx("div", { className: "iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full" }),
|
|
1982
1980
|
/* @__PURE__ */ t.jsx("div", { className: "iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4" })
|
|
1983
|
-
] }) : /* @__PURE__ */ t.jsx("p", { className: "iw-text-lg iw-leading-8", children:
|
|
1981
|
+
] }) : /* @__PURE__ */ t.jsx("p", { className: "iw-text-lg iw-leading-8", children: r == null ? void 0 : r.question })
|
|
1984
1982
|
] })
|
|
1985
1983
|
}
|
|
1986
1984
|
);
|
|
1987
1985
|
}, ut = ({
|
|
1988
|
-
confirmExitInterview:
|
|
1989
|
-
isOpen:
|
|
1986
|
+
confirmExitInterview: r,
|
|
1987
|
+
isOpen: i,
|
|
1990
1988
|
onClose: e
|
|
1991
|
-
}) => /* @__PURE__ */ t.jsx(
|
|
1989
|
+
}) => /* @__PURE__ */ t.jsx(xe, { isOpen: i, onClose: e, title: "Exit Interview", children: /* @__PURE__ */ t.jsxs("div", { className: "iw-space-y-4", children: [
|
|
1992
1990
|
/* @__PURE__ */ t.jsx("p", { className: "iw-text-base iw-text-gray-700", children: "Are you sure you want to exit the interview? All progress will be lost and you will not be able to resume." }),
|
|
1993
1991
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-justify-end iw-space-x-2", children: [
|
|
1994
1992
|
/* @__PURE__ */ t.jsx(
|
|
@@ -2003,13 +2001,13 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
2003
2001
|
"button",
|
|
2004
2002
|
{
|
|
2005
2003
|
className: "iw-px-4 iw-py-2 iw-bg-red-600 iw-text-white iw-rounded iw-font-medium",
|
|
2006
|
-
onClick:
|
|
2004
|
+
onClick: r,
|
|
2007
2005
|
children: "Confirm Exit"
|
|
2008
2006
|
}
|
|
2009
2007
|
)
|
|
2010
2008
|
] })
|
|
2011
|
-
] }) }), ht = ({ title:
|
|
2012
|
-
const { baseColor: e } =
|
|
2009
|
+
] }) }), ht = ({ title: r, onExit: i }) => {
|
|
2010
|
+
const { baseColor: e } = Y(), [a, s] = k(!1);
|
|
2013
2011
|
return /* @__PURE__ */ t.jsxs("header", { className: "iw-w-full iw-text-gray-900", children: [
|
|
2014
2012
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-py-3", children: [
|
|
2015
2013
|
/* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
|
|
@@ -2023,7 +2021,7 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
2023
2021
|
),
|
|
2024
2022
|
/* @__PURE__ */ t.jsx("p", { className: "iw-text-sm iw-font-medium", children: "Novara" })
|
|
2025
2023
|
] }),
|
|
2026
|
-
/* @__PURE__ */ t.jsx("h1", { className: "iw-text-base iw-font-bold", children:
|
|
2024
|
+
/* @__PURE__ */ t.jsx("h1", { className: "iw-text-base iw-font-bold", children: r }),
|
|
2027
2025
|
/* @__PURE__ */ t.jsx(
|
|
2028
2026
|
"button",
|
|
2029
2027
|
{
|
|
@@ -2037,192 +2035,195 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
2037
2035
|
/* @__PURE__ */ t.jsx(
|
|
2038
2036
|
ut,
|
|
2039
2037
|
{
|
|
2040
|
-
isOpen:
|
|
2038
|
+
isOpen: a,
|
|
2041
2039
|
confirmExitInterview: () => {
|
|
2042
|
-
|
|
2040
|
+
i(), s(!1);
|
|
2043
2041
|
},
|
|
2044
2042
|
onClose: () => s(!1)
|
|
2045
2043
|
}
|
|
2046
2044
|
)
|
|
2047
2045
|
] });
|
|
2048
2046
|
}, mt = ({
|
|
2047
|
+
interviewTitle: r,
|
|
2049
2048
|
interviewId: i,
|
|
2050
|
-
onComplete:
|
|
2051
|
-
className:
|
|
2049
|
+
onComplete: e,
|
|
2050
|
+
className: a = ""
|
|
2052
2051
|
}) => {
|
|
2053
|
-
const
|
|
2054
|
-
thinkingTime: (
|
|
2055
|
-
answeringTime: (
|
|
2056
|
-
editingTime: (
|
|
2057
|
-
}, { thinkingTime:
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
}, [
|
|
2061
|
-
const
|
|
2052
|
+
const s = We(), { baseUrl: c, authToken: o } = Se(), { timers: n, stt: l, tts: m } = Ce(), [w, h] = k(null), [u, g] = k(""), j = S(""), y = S(null), I = {
|
|
2053
|
+
thinkingTime: (n == null ? void 0 : n.thinkingDuration) || 30,
|
|
2054
|
+
answeringTime: (n == null ? void 0 : n.answeringDuration) || 120,
|
|
2055
|
+
editingTime: (n == null ? void 0 : n.editingDuration) || 30
|
|
2056
|
+
}, { thinkingTime: d, answeringTime: x, editingTime: M } = I;
|
|
2057
|
+
P(() => {
|
|
2058
|
+
j.current = u;
|
|
2059
|
+
}, [u]);
|
|
2060
|
+
const p = S(!1), { speak: $, error: b } = Je({
|
|
2062
2061
|
config: {
|
|
2063
|
-
baseUrl:
|
|
2064
|
-
provider:
|
|
2062
|
+
baseUrl: c,
|
|
2063
|
+
provider: m == null ? void 0 : m.provider,
|
|
2064
|
+
authToken: o
|
|
2065
2065
|
},
|
|
2066
2066
|
onEnd: () => {
|
|
2067
|
-
|
|
2067
|
+
p.current = !1, E();
|
|
2068
2068
|
},
|
|
2069
2069
|
onError: () => {
|
|
2070
|
-
|
|
2070
|
+
p.current || (p.current = !0, E());
|
|
2071
2071
|
}
|
|
2072
|
-
}),
|
|
2073
|
-
startRecording:
|
|
2074
|
-
stopRecording:
|
|
2075
|
-
transcribe:
|
|
2076
|
-
error:
|
|
2072
|
+
}), N = S(!1), T = S(!1), {
|
|
2073
|
+
startRecording: C,
|
|
2074
|
+
stopRecording: q,
|
|
2075
|
+
transcribe: F,
|
|
2076
|
+
error: Q
|
|
2077
2077
|
} = Ye({
|
|
2078
2078
|
config: {
|
|
2079
|
-
baseUrl:
|
|
2080
|
-
provider:
|
|
2081
|
-
model:
|
|
2082
|
-
language:
|
|
2079
|
+
baseUrl: c,
|
|
2080
|
+
provider: l == null ? void 0 : l.provider,
|
|
2081
|
+
model: l == null ? void 0 : l.model,
|
|
2082
|
+
language: l == null ? void 0 : l.language,
|
|
2083
|
+
authToken: o
|
|
2083
2084
|
},
|
|
2084
2085
|
onStart: () => {
|
|
2085
|
-
|
|
2086
|
+
N.current = !1, T.current = !1;
|
|
2086
2087
|
},
|
|
2087
2088
|
onStop: () => {
|
|
2088
2089
|
},
|
|
2089
|
-
onTranscriptionComplete: (
|
|
2090
|
-
|
|
2090
|
+
onTranscriptionComplete: (f) => {
|
|
2091
|
+
g(f.transcript), T.current || (T.current = !0, E());
|
|
2091
2092
|
},
|
|
2092
|
-
onError: (
|
|
2093
|
-
console.error("STT Error:",
|
|
2093
|
+
onError: (f) => {
|
|
2094
|
+
console.error("STT Error:", f), N.current || (N.current = !0, E());
|
|
2094
2095
|
}
|
|
2095
|
-
}), { state: _, startQuestion:
|
|
2096
|
+
}), { state: _, startQuestion: U, nextPhase: E, completeInterview: B } = Ge({
|
|
2096
2097
|
config: {
|
|
2097
|
-
thinkingDuration:
|
|
2098
|
-
answeringDuration:
|
|
2099
|
-
editingDuration:
|
|
2098
|
+
thinkingDuration: d,
|
|
2099
|
+
answeringDuration: x,
|
|
2100
|
+
editingDuration: M
|
|
2100
2101
|
},
|
|
2101
2102
|
callbacks: {
|
|
2102
|
-
onPhaseChange: (
|
|
2103
|
-
switch (
|
|
2104
|
-
case
|
|
2105
|
-
|
|
2103
|
+
onPhaseChange: (f) => {
|
|
2104
|
+
switch (f) {
|
|
2105
|
+
case R.FETCHING_QUESTION:
|
|
2106
|
+
ee();
|
|
2106
2107
|
break;
|
|
2107
|
-
case
|
|
2108
|
-
|
|
2108
|
+
case R.READING_QUESTION:
|
|
2109
|
+
re();
|
|
2109
2110
|
break;
|
|
2110
|
-
case
|
|
2111
|
-
|
|
2111
|
+
case R.ANSWERING:
|
|
2112
|
+
G();
|
|
2112
2113
|
break;
|
|
2113
|
-
case
|
|
2114
|
-
|
|
2114
|
+
case R.TRANSCRIBING:
|
|
2115
|
+
ie();
|
|
2115
2116
|
break;
|
|
2116
|
-
case
|
|
2117
|
-
|
|
2117
|
+
case R.SUBMITTING:
|
|
2118
|
+
te();
|
|
2118
2119
|
break;
|
|
2119
2120
|
}
|
|
2120
2121
|
},
|
|
2121
2122
|
onInterviewEnd: () => {
|
|
2122
|
-
|
|
2123
|
+
e == null || e();
|
|
2123
2124
|
}
|
|
2124
2125
|
}
|
|
2125
2126
|
});
|
|
2126
|
-
|
|
2127
|
-
|
|
2127
|
+
P(() => {
|
|
2128
|
+
U();
|
|
2128
2129
|
}, []);
|
|
2129
|
-
const { execute:
|
|
2130
|
+
const { execute: ee, loading: z } = qe(
|
|
2130
2131
|
async () => {
|
|
2131
|
-
var
|
|
2132
|
-
const
|
|
2132
|
+
var O, V;
|
|
2133
|
+
const f = await s.generateQuestion({
|
|
2133
2134
|
interviewId: i,
|
|
2134
|
-
question: ((
|
|
2135
|
-
qnaId: ((V =
|
|
2136
|
-
answer:
|
|
2135
|
+
question: ((O = y.current) == null ? void 0 : O.question) || "",
|
|
2136
|
+
qnaId: ((V = y.current) == null ? void 0 : V.qna_id) || "",
|
|
2137
|
+
answer: j.current
|
|
2137
2138
|
});
|
|
2138
|
-
return
|
|
2139
|
+
return y.current = f.data, f;
|
|
2139
2140
|
},
|
|
2140
2141
|
{
|
|
2141
|
-
onSuccess: async (
|
|
2142
|
-
|
|
2142
|
+
onSuccess: async (f) => {
|
|
2143
|
+
f && f.data && (g(""), h(f.data), E());
|
|
2143
2144
|
},
|
|
2144
|
-
onError: (
|
|
2145
|
-
console.error("Failed to fetch questions:",
|
|
2145
|
+
onError: (f) => {
|
|
2146
|
+
console.error("Failed to fetch questions:", f);
|
|
2146
2147
|
}
|
|
2147
2148
|
}
|
|
2148
|
-
),
|
|
2149
|
-
|
|
2150
|
-
}, [
|
|
2151
|
-
var
|
|
2152
|
-
if ((
|
|
2149
|
+
), te = A(async () => {
|
|
2150
|
+
U();
|
|
2151
|
+
}, [U]), re = A(async () => {
|
|
2152
|
+
var f;
|
|
2153
|
+
if ((f = y.current) != null && f.question)
|
|
2153
2154
|
try {
|
|
2154
|
-
|
|
2155
|
-
} catch (
|
|
2156
|
-
console.error("Failed to speak question:",
|
|
2155
|
+
p.current = !1, await $(y.current.question), y.current.is_interview_done && (await Pe(2e3), B());
|
|
2156
|
+
} catch (O) {
|
|
2157
|
+
console.error("Failed to speak question:", O);
|
|
2157
2158
|
}
|
|
2158
2159
|
else
|
|
2159
|
-
|
|
2160
|
-
}, [
|
|
2160
|
+
E();
|
|
2161
|
+
}, [$, E, B]), G = A(async () => {
|
|
2161
2162
|
try {
|
|
2162
|
-
await
|
|
2163
|
-
} catch (
|
|
2164
|
-
console.error("Failed to start recording:",
|
|
2163
|
+
await C(x);
|
|
2164
|
+
} catch (f) {
|
|
2165
|
+
console.error("Failed to start recording:", f), E();
|
|
2165
2166
|
}
|
|
2166
|
-
}, [
|
|
2167
|
+
}, [C, E]), ie = A(async () => {
|
|
2167
2168
|
try {
|
|
2168
|
-
const
|
|
2169
|
-
await
|
|
2170
|
-
} catch (
|
|
2171
|
-
console.error("STT processing failed:",
|
|
2169
|
+
const f = await q();
|
|
2170
|
+
await F(f);
|
|
2171
|
+
} catch (f) {
|
|
2172
|
+
console.error("STT processing failed:", f), !N.current && !T.current && (N.current = !0, E());
|
|
2172
2173
|
}
|
|
2173
|
-
}, [
|
|
2174
|
-
const { phase:
|
|
2175
|
-
switch (
|
|
2176
|
-
case
|
|
2174
|
+
}, [q, F, E]), W = () => {
|
|
2175
|
+
const { phase: f } = _;
|
|
2176
|
+
switch (f) {
|
|
2177
|
+
case R.IDLE:
|
|
2177
2178
|
return /* @__PURE__ */ t.jsxs("div", { className: "iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full", children: [
|
|
2178
2179
|
/* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "Ready to start the Interview?" }),
|
|
2179
2180
|
/* @__PURE__ */ t.jsx("p", { className: "iw-max-w-xl iw-text-gray-500 iw-text-xs iw-leading-[21px]", children: `You will be asked a series of behavioral and technical questions. For each one you'll get a short thinking period, then a timed recording window. We'll transcribe your response so you can review and edit it before submitting. Click "Start Interview" when you're ready.` }),
|
|
2180
|
-
/* @__PURE__ */ t.jsx(
|
|
2181
|
+
/* @__PURE__ */ t.jsx(K, { onClick: U, className: "iw-mt-2 iw-w-40", children: "Start Interview" })
|
|
2181
2182
|
] });
|
|
2182
|
-
case
|
|
2183
|
+
case R.FETCHING_QUESTION:
|
|
2183
2184
|
return /* @__PURE__ */ t.jsx(st, {});
|
|
2184
|
-
case
|
|
2185
|
+
case R.READING_QUESTION:
|
|
2185
2186
|
return /* @__PURE__ */ t.jsx(ot, { ttsError: b });
|
|
2186
|
-
case
|
|
2187
|
+
case R.THINKING:
|
|
2187
2188
|
return /* @__PURE__ */ t.jsx(
|
|
2188
2189
|
ct,
|
|
2189
2190
|
{
|
|
2190
2191
|
state: _,
|
|
2191
|
-
thinkingTime:
|
|
2192
|
-
nextPhase:
|
|
2192
|
+
thinkingTime: d,
|
|
2193
|
+
nextPhase: E
|
|
2193
2194
|
}
|
|
2194
2195
|
);
|
|
2195
|
-
case
|
|
2196
|
+
case R.ANSWERING:
|
|
2196
2197
|
return /* @__PURE__ */ t.jsx(
|
|
2197
2198
|
it,
|
|
2198
2199
|
{
|
|
2199
2200
|
state: _,
|
|
2200
|
-
answeringTime:
|
|
2201
|
-
nextPhase:
|
|
2202
|
-
sttError:
|
|
2201
|
+
answeringTime: x,
|
|
2202
|
+
nextPhase: E,
|
|
2203
|
+
sttError: Q
|
|
2203
2204
|
}
|
|
2204
2205
|
);
|
|
2205
|
-
case
|
|
2206
|
-
return /* @__PURE__ */ t.jsx(lt, { sttError:
|
|
2207
|
-
case
|
|
2208
|
-
case
|
|
2206
|
+
case R.TRANSCRIBING:
|
|
2207
|
+
return /* @__PURE__ */ t.jsx(lt, { sttError: Q });
|
|
2208
|
+
case R.EDITING:
|
|
2209
|
+
case R.SUBMITTING:
|
|
2209
2210
|
return /* @__PURE__ */ t.jsx("div", { className: "iw-space-y-4 iw-h-full", children: /* @__PURE__ */ t.jsx(
|
|
2210
2211
|
et,
|
|
2211
2212
|
{
|
|
2212
|
-
value:
|
|
2213
|
-
onChange: (
|
|
2214
|
-
onSubmit: () =>
|
|
2215
|
-
isSubmitDisabled: !
|
|
2213
|
+
value: u,
|
|
2214
|
+
onChange: (O) => g(O.target.value),
|
|
2215
|
+
onSubmit: () => E(),
|
|
2216
|
+
isSubmitDisabled: !u.trim() || z,
|
|
2216
2217
|
state: _,
|
|
2217
|
-
editingTime:
|
|
2218
|
+
editingTime: M
|
|
2218
2219
|
}
|
|
2219
2220
|
) });
|
|
2220
|
-
case
|
|
2221
|
+
case R.COMPLETED:
|
|
2221
2222
|
return /* @__PURE__ */ t.jsx("div", { className: "iw-fixed iw-inset-0 iw-bg-white", children: /* @__PURE__ */ t.jsx(
|
|
2222
|
-
|
|
2223
|
+
nt,
|
|
2223
2224
|
{
|
|
2224
2225
|
open: !0,
|
|
2225
|
-
onClose:
|
|
2226
|
+
onClose: e || (() => {
|
|
2226
2227
|
})
|
|
2227
2228
|
}
|
|
2228
2229
|
) });
|
|
@@ -2234,47 +2235,54 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
2234
2235
|
/* @__PURE__ */ t.jsx(
|
|
2235
2236
|
ht,
|
|
2236
2237
|
{
|
|
2237
|
-
title:
|
|
2238
|
-
onExit:
|
|
2238
|
+
title: r,
|
|
2239
|
+
onExit: async () => {
|
|
2240
|
+
(await s.generateQuestion({
|
|
2241
|
+
interviewId: i,
|
|
2242
|
+
isInterviewDone: !0
|
|
2243
|
+
})).success && B();
|
|
2244
|
+
}
|
|
2239
2245
|
}
|
|
2240
2246
|
),
|
|
2241
2247
|
/* @__PURE__ */ t.jsxs(
|
|
2242
2248
|
"div",
|
|
2243
2249
|
{
|
|
2244
|
-
className: `iw-p-4 iw-space-y-4 iw-pb-6 ${
|
|
2250
|
+
className: `iw-p-4 iw-space-y-4 iw-pb-6 ${a} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,
|
|
2245
2251
|
children: [
|
|
2246
2252
|
/* @__PURE__ */ t.jsx("div", { className: "iw-flex iw-items-start iw-justify-between iw-gap-3", children: /* @__PURE__ */ t.jsx("div", { className: "iw-flex-1", children: /* @__PURE__ */ t.jsx(
|
|
2247
2253
|
wt,
|
|
2248
2254
|
{
|
|
2249
2255
|
question: w,
|
|
2250
|
-
isLoading: _.phase ===
|
|
2256
|
+
isLoading: _.phase === R.FETCHING_QUESTION || _.phase === R.IDLE
|
|
2251
2257
|
}
|
|
2252
2258
|
) }) }),
|
|
2253
2259
|
/* @__PURE__ */ t.jsxs("div", { className: "iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-xl iw-p-4", children: [
|
|
2254
2260
|
/* @__PURE__ */ t.jsx("div", { className: "iw-min-h-[400px] iw-max-h-[600px]", children: /* @__PURE__ */ t.jsx(Xe, {}) }),
|
|
2255
|
-
/* @__PURE__ */ t.jsx("div", { className: "iw-bg-white iw-rounded-lg iw-shadow iw-p-6", children:
|
|
2261
|
+
/* @__PURE__ */ t.jsx("div", { className: "iw-bg-white iw-rounded-lg iw-shadow iw-p-6", children: W() })
|
|
2256
2262
|
] })
|
|
2257
2263
|
]
|
|
2258
2264
|
}
|
|
2259
2265
|
)
|
|
2260
2266
|
] });
|
|
2261
2267
|
}, gt = ({
|
|
2268
|
+
title: r,
|
|
2262
2269
|
interviewId: i,
|
|
2263
|
-
onInterviewEnd:
|
|
2264
|
-
className:
|
|
2270
|
+
onInterviewEnd: e,
|
|
2271
|
+
className: a = ""
|
|
2265
2272
|
}) => {
|
|
2266
|
-
const [
|
|
2267
|
-
return
|
|
2273
|
+
const [s, c] = le.useState(!1), [o, n] = le.useState(!0), l = S(null);
|
|
2274
|
+
return s ? /* @__PURE__ */ t.jsx("div", { className: "interview-widget-container", children: /* @__PURE__ */ t.jsx(
|
|
2268
2275
|
"div",
|
|
2269
2276
|
{
|
|
2270
|
-
ref:
|
|
2271
|
-
className: `iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${
|
|
2277
|
+
ref: l,
|
|
2278
|
+
className: `iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${a}`,
|
|
2272
2279
|
children: /* @__PURE__ */ t.jsx("div", { className: " iw-h-full iw-flex iw-flex-col", children: /* @__PURE__ */ t.jsx(
|
|
2273
2280
|
mt,
|
|
2274
2281
|
{
|
|
2282
|
+
interviewTitle: r ?? "Interview",
|
|
2275
2283
|
interviewId: i,
|
|
2276
|
-
className:
|
|
2277
|
-
onComplete:
|
|
2284
|
+
className: a,
|
|
2285
|
+
onComplete: e || (() => {
|
|
2278
2286
|
})
|
|
2279
2287
|
}
|
|
2280
2288
|
) })
|
|
@@ -2282,9 +2290,9 @@ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ t.js
|
|
|
2282
2290
|
) }) : /* @__PURE__ */ t.jsx("div", { className: "interview-widget-container", children: /* @__PURE__ */ t.jsx(
|
|
2283
2291
|
Le,
|
|
2284
2292
|
{
|
|
2285
|
-
isOpen:
|
|
2293
|
+
isOpen: o,
|
|
2286
2294
|
onStart: () => {
|
|
2287
|
-
console.log("Permissions granted, starting interview"),
|
|
2295
|
+
console.log("Permissions granted, starting interview"), c(!0), n(!1);
|
|
2288
2296
|
}
|
|
2289
2297
|
}
|
|
2290
2298
|
) });
|