@genai-fi/base 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +1,41 @@
1
- import { jsx as s, jsxs as F, Fragment as q } from "react/jsx-runtime";
2
- import * as G from "react";
3
- import { useState as M, useRef as O, useEffect as y, useCallback as E } from "react";
4
- import { useTranslation as J } from "react-i18next";
5
- import { IconButton as V } from "@mui/material";
6
- import { c as Q } from "../../createSvgIcon-DmrVEdN7.js";
7
- import { WebcamClass as Y } from "./webcamClass.js";
8
- import { g as Z, u as z, s as P, c as W, a as ee, m as te } from "../../DefaultPropsProvider-D2IJ8Qbs.js";
9
- import { g as ae, b as ne, P as a } from "../../createTheme-a85zdZWm.js";
10
- import { css as A, keyframes as H } from "@emotion/react";
11
- import '../../assets/Webcam.css';function re(e) {
12
- return String(e).match(/[\d.\-+]*\s*(.*)/)[1] || "";
1
+ import { jsx as c, jsxs as j, Fragment as D } from "react/jsx-runtime";
2
+ import * as X from "react";
3
+ import { useState as T, useRef as b, useEffect as C, useCallback as B } from "react";
4
+ import { useTranslation as H } from "react-i18next";
5
+ import { IconButton as P } from "@mui/material";
6
+ import { c as K } from "../../createSvgIcon-DQhMxTx4.js";
7
+ import { WebcamClass as L } from "./webcamClass.js";
8
+ import { g as G, u as J, s as Q, c as Y, a as Z, m as W } from "../../DefaultPropsProvider-BurgXZzw.js";
9
+ import { g as tt, P as n } from "../../createTheme-DV959X3d.js";
10
+ import { css as z, keyframes as q } from "@emotion/react";
11
+ import '../../assets/Webcam.css';function et(t) {
12
+ return String(t).match(/[\d.\-+]*\s*(.*)/)[1] || "";
13
13
  }
14
- function ie(e) {
15
- return parseFloat(e);
14
+ function nt(t) {
15
+ return parseFloat(t);
16
16
  }
17
- const oe = "_container_u6uf5_1", se = "_wrapContainer_u6uf5_5", ce = "_flipButton_u6uf5_10", N = {
18
- container: oe,
19
- wrapContainer: se,
20
- flipButton: ce
17
+ const rt = "_container_u6uf5_1", at = "_wrapContainer_u6uf5_5", ot = "_flipButton_u6uf5_10", F = {
18
+ container: rt,
19
+ wrapContainer: at,
20
+ flipButton: ot
21
21
  };
22
- function le(e) {
23
- return ae("MuiSkeleton", e);
22
+ function it(t) {
23
+ return tt("MuiSkeleton", t);
24
24
  }
25
- Z("MuiSkeleton", ["root", "text", "rectangular", "rounded", "circular", "pulse", "wave", "withChildren", "fitContent", "heightAuto"]);
26
- const ue = (e) => {
25
+ G("MuiSkeleton", ["root", "text", "rectangular", "rounded", "circular", "pulse", "wave", "withChildren", "fitContent", "heightAuto"]);
26
+ const st = (t) => {
27
27
  const {
28
- classes: i,
29
- variant: r,
30
- animation: o,
31
- hasChildren: u,
32
- width: v,
33
- height: f
34
- } = e;
35
- return ee({
36
- root: ["root", r, o, u && "withChildren", u && !v && "fitContent", u && !f && "heightAuto"]
37
- }, le, i);
38
- }, $ = H`
28
+ classes: o,
29
+ variant: a,
30
+ animation: i,
31
+ hasChildren: p,
32
+ width: y,
33
+ height: m
34
+ } = t;
35
+ return Z({
36
+ root: ["root", a, i, p && "withChildren", p && !y && "fitContent", p && !m && "heightAuto"]
37
+ }, it, o);
38
+ }, M = q`
39
39
  0% {
40
40
  opacity: 1;
41
41
  }
@@ -47,7 +47,7 @@ const ue = (e) => {
47
47
  100% {
48
48
  opacity: 1;
49
49
  }
50
- `, j = H`
50
+ `, _ = q`
51
51
  0% {
52
52
  transform: translateX(-100%);
53
53
  }
@@ -60,29 +60,29 @@ const ue = (e) => {
60
60
  100% {
61
61
  transform: translateX(100%);
62
62
  }
63
- `, fe = typeof $ != "string" ? A`
64
- animation: ${$} 2s ease-in-out 0.5s infinite;
65
- ` : null, pe = typeof j != "string" ? A`
63
+ `, ct = typeof M != "string" ? z`
64
+ animation: ${M} 2s ease-in-out 0.5s infinite;
65
+ ` : null, lt = typeof _ != "string" ? z`
66
66
  &::after {
67
- animation: ${j} 2s linear 0.5s infinite;
67
+ animation: ${_} 2s linear 0.5s infinite;
68
68
  }
69
- ` : null, de = P("span", {
69
+ ` : null, ut = Q("span", {
70
70
  name: "MuiSkeleton",
71
71
  slot: "Root",
72
- overridesResolver: (e, i) => {
72
+ overridesResolver: (t, o) => {
73
73
  const {
74
- ownerState: r
75
- } = e;
76
- return [i.root, i[r.variant], r.animation !== !1 && i[r.animation], r.hasChildren && i.withChildren, r.hasChildren && !r.width && i.fitContent, r.hasChildren && !r.height && i.heightAuto];
74
+ ownerState: a
75
+ } = t;
76
+ return [o.root, o[a.variant], a.animation !== !1 && o[a.animation], a.hasChildren && o.withChildren, a.hasChildren && !a.width && o.fitContent, a.hasChildren && !a.height && o.heightAuto];
77
77
  }
78
- })(te(({
79
- theme: e
78
+ })(W(({
79
+ theme: t
80
80
  }) => {
81
- const i = re(e.shape.borderRadius) || "px", r = ie(e.shape.borderRadius);
81
+ const o = et(t.shape.borderRadius) || "px", a = nt(t.shape.borderRadius);
82
82
  return {
83
83
  display: "block",
84
84
  // Create a "on paper" color with sufficient contrast retaining the color
85
- backgroundColor: e.vars ? e.vars.palette.Skeleton.bg : ne(e.palette.text.primary, e.palette.mode === "light" ? 0.11 : 0.13),
85
+ backgroundColor: t.vars ? t.vars.palette.Skeleton.bg : t.alpha(t.palette.text.primary, t.palette.mode === "light" ? 0.11 : 0.13),
86
86
  height: "1.2em",
87
87
  variants: [{
88
88
  props: {
@@ -94,7 +94,7 @@ const ue = (e) => {
94
94
  height: "auto",
95
95
  transformOrigin: "0 55%",
96
96
  transform: "scale(1, 0.60)",
97
- borderRadius: `${r}${i}/${Math.round(r / 0.6 * 10) / 10}${i}`,
97
+ borderRadius: `${a}${o}/${Math.round(a / 0.6 * 10) / 10}${o}`,
98
98
  "&:empty:before": {
99
99
  content: '"\\00a0"'
100
100
  }
@@ -111,12 +111,12 @@ const ue = (e) => {
111
111
  variant: "rounded"
112
112
  },
113
113
  style: {
114
- borderRadius: (e.vars || e).shape.borderRadius
114
+ borderRadius: (t.vars || t).shape.borderRadius
115
115
  }
116
116
  }, {
117
117
  props: ({
118
- ownerState: o
119
- }) => o.hasChildren,
118
+ ownerState: i
119
+ }) => i.hasChildren,
120
120
  style: {
121
121
  "& > *": {
122
122
  visibility: "hidden"
@@ -124,15 +124,15 @@ const ue = (e) => {
124
124
  }
125
125
  }, {
126
126
  props: ({
127
- ownerState: o
128
- }) => o.hasChildren && !o.width,
127
+ ownerState: i
128
+ }) => i.hasChildren && !i.width,
129
129
  style: {
130
130
  maxWidth: "fit-content"
131
131
  }
132
132
  }, {
133
133
  props: ({
134
- ownerState: o
135
- }) => o.hasChildren && !o.height,
134
+ ownerState: i
135
+ }) => i.hasChildren && !i.height,
136
136
  style: {
137
137
  height: "auto"
138
138
  }
@@ -140,8 +140,8 @@ const ue = (e) => {
140
140
  props: {
141
141
  animation: "pulse"
142
142
  },
143
- style: fe || {
144
- animation: `${$} 2s ease-in-out 0.5s infinite`
143
+ style: ct || {
144
+ animation: `${M} 2s ease-in-out 0.5s infinite`
145
145
  }
146
146
  }, {
147
147
  props: {
@@ -156,7 +156,7 @@ const ue = (e) => {
156
156
  background: `linear-gradient(
157
157
  90deg,
158
158
  transparent,
159
- ${(e.vars || e).palette.action.hover},
159
+ ${(t.vars || t).palette.action.hover},
160
160
  transparent
161
161
  )`,
162
162
  content: '""',
@@ -172,47 +172,47 @@ const ue = (e) => {
172
172
  props: {
173
173
  animation: "wave"
174
174
  },
175
- style: pe || {
175
+ style: lt || {
176
176
  "&::after": {
177
- animation: `${j} 2s linear 0.5s infinite`
177
+ animation: `${_} 2s linear 0.5s infinite`
178
178
  }
179
179
  }
180
180
  }]
181
181
  };
182
- })), K = /* @__PURE__ */ G.forwardRef(function(i, r) {
183
- const o = z({
184
- props: i,
182
+ })), E = /* @__PURE__ */ X.forwardRef(function(o, a) {
183
+ const i = J({
184
+ props: o,
185
185
  name: "MuiSkeleton"
186
186
  }), {
187
- animation: u = "pulse",
188
- className: v,
189
- component: f = "span",
190
- height: m,
191
- style: p,
192
- variant: w = "text",
193
- width: l,
194
- ...h
195
- } = o, t = {
196
- ...o,
197
- animation: u,
198
- component: f,
199
- variant: w,
200
- hasChildren: !!h.children
201
- }, T = ue(t);
202
- return /* @__PURE__ */ s(de, {
203
- as: f,
204
- ref: r,
205
- className: W(T.root, v),
206
- ownerState: t,
207
- ...h,
187
+ animation: p = "pulse",
188
+ className: y,
189
+ component: m = "span",
190
+ height: h,
191
+ style: e,
192
+ variant: A = "text",
193
+ width: v,
194
+ ...f
195
+ } = i, g = {
196
+ ...i,
197
+ animation: p,
198
+ component: m,
199
+ variant: A,
200
+ hasChildren: !!f.children
201
+ }, u = st(g);
202
+ return /* @__PURE__ */ c(ut, {
203
+ as: m,
204
+ ref: a,
205
+ className: Y(u.root, y),
206
+ ownerState: g,
207
+ ...f,
208
208
  style: {
209
- width: l,
210
- height: m,
211
- ...p
209
+ width: v,
210
+ height: h,
211
+ ...e
212
212
  }
213
213
  });
214
214
  });
215
- process.env.NODE_ENV !== "production" && (K.propTypes = {
215
+ process.env.NODE_ENV !== "production" && (E.propTypes = {
216
216
  // ┌────────────────────────────── Warning ──────────────────────────────┐
217
217
  // │ These PropTypes are generated from the TypeScript type definitions. │
218
218
  // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
@@ -222,169 +222,159 @@ process.env.NODE_ENV !== "production" && (K.propTypes = {
222
222
  * If `false` the animation effect is disabled.
223
223
  * @default 'pulse'
224
224
  */
225
- animation: a.oneOf(["pulse", "wave", !1]),
225
+ animation: n.oneOf(["pulse", "wave", !1]),
226
226
  /**
227
227
  * Optional children to infer width and height from.
228
228
  */
229
- children: a.node,
229
+ children: n.node,
230
230
  /**
231
231
  * Override or extend the styles applied to the component.
232
232
  */
233
- classes: a.object,
233
+ classes: n.object,
234
234
  /**
235
235
  * @ignore
236
236
  */
237
- className: a.string,
237
+ className: n.string,
238
238
  /**
239
239
  * The component used for the root node.
240
240
  * Either a string to use a HTML element or a component.
241
241
  */
242
- component: a.elementType,
242
+ component: n.elementType,
243
243
  /**
244
244
  * Height of the skeleton.
245
245
  * Useful when you don't want to adapt the skeleton to a text element but for instance a card.
246
246
  */
247
- height: a.oneOfType([a.number, a.string]),
247
+ height: n.oneOfType([n.number, n.string]),
248
248
  /**
249
249
  * @ignore
250
250
  */
251
- style: a.object,
251
+ style: n.object,
252
252
  /**
253
253
  * The system prop that allows defining system overrides as well as additional CSS styles.
254
254
  */
255
- sx: a.oneOfType([a.arrayOf(a.oneOfType([a.func, a.object, a.bool])), a.func, a.object]),
255
+ sx: n.oneOfType([n.arrayOf(n.oneOfType([n.func, n.object, n.bool])), n.func, n.object]),
256
256
  /**
257
257
  * The type of content that will be rendered.
258
258
  * @default 'text'
259
259
  */
260
- variant: a.oneOfType([a.oneOf(["circular", "rectangular", "rounded", "text"]), a.string]),
260
+ variant: n.oneOfType([n.oneOf(["circular", "rectangular", "rounded", "text"]), n.string]),
261
261
  /**
262
262
  * Width of the skeleton.
263
263
  * Useful when the skeleton is inside an inline element with no width of its own.
264
264
  */
265
- width: a.oneOfType([a.number, a.string])
265
+ width: n.oneOfType([n.number, n.string])
266
266
  });
267
- const X = Q([/* @__PURE__ */ s("path", {
267
+ const U = K([/* @__PURE__ */ c("path", {
268
268
  d: "M16 7h-1l-1-1h-4L9 7H8c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2m-4 7c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2"
269
- }, "0"), /* @__PURE__ */ s("path", {
269
+ }, "0"), /* @__PURE__ */ c("path", {
270
270
  d: "m8.57.51 4.48 4.48V2.04c4.72.47 8.48 4.23 8.95 8.95h2C23.34 3.02 15.49-1.59 8.57.51m2.38 21.45c-4.72-.47-8.48-4.23-8.95-8.95H0c.66 7.97 8.51 12.58 15.43 10.48l-4.48-4.48z"
271
271
  }, "1")], "Cameraswitch");
272
- function Re({
273
- interval: e,
274
- capture: i,
275
- onCapture: r,
276
- disable: o,
277
- direct: u,
278
- hidden: v,
279
- onPreprocess: f,
280
- onPostprocess: m,
281
- onActivated: p,
282
- onFatal: w,
283
- size: l
284
- }) {
285
- const { t: h } = J(), [t, T] = M(null), b = O(null), C = O(-1), _ = O(0), d = O(), [k, L] = M(!1), [R, D] = M(!1);
286
- y(() => {
287
- d.current = async (n) => {
288
- var c;
289
- if (o) {
290
- d.current && (C.current = window.requestAnimationFrame(d.current));
272
+ function bt({ interval: t, capture: o, disable: a, direct: i, hidden: p, size: y, ...m }) {
273
+ const { t: h } = H(), [e, A] = T(null), v = b(null), f = b(-1), g = b(0), u = b(), s = b({}), [k, V] = T(!1), [R, I] = T(!1);
274
+ s.current = m;
275
+ const d = Math.floor(y);
276
+ C(() => {
277
+ u.current = async (r) => {
278
+ var l;
279
+ if (a) {
280
+ u.current && (f.current = window.requestAnimationFrame(u.current));
291
281
  return;
292
282
  }
293
- if (t && t.canvas) {
294
- t.update();
295
- const x = e !== void 0 ? e : 1e3;
296
- if (f && await f(t.canvas), i && r && n - _.current >= x) {
297
- if (u && t.canvas)
298
- await r(t.canvas);
283
+ if (e && e.canvas) {
284
+ e.update();
285
+ const S = t !== void 0 ? t : 1e3;
286
+ if (s.current.onPreprocess && await s.current.onPreprocess(e.canvas), o && s.current.onCapture && r - g.current >= S) {
287
+ if (i && e.canvas)
288
+ await s.current.onCapture(e.canvas);
299
289
  else {
300
- const g = document.createElement("canvas");
301
- g.width = t.canvas.width, g.height = t.canvas.height;
302
- const S = g.getContext("2d");
303
- S || console.error("Failed to get context"), S == null || S.drawImage(t.canvas, 0, 0), await r(g);
290
+ const w = document.createElement("canvas");
291
+ w.width = e.canvas.width, w.height = e.canvas.height;
292
+ const x = w.getContext("2d");
293
+ x || console.error("Failed to get context"), x == null || x.drawImage(e.canvas, 0, 0), await s.current.onCapture(w);
304
294
  }
305
- _.current = n;
295
+ g.current = r;
306
296
  }
307
- const I = (c = b.current) == null ? void 0 : c.getContext("2d");
308
- I && (I.drawImage(t.canvas, 0, 0), m && b.current && await m(b.current));
297
+ const O = (l = v.current) == null ? void 0 : l.getContext("2d");
298
+ O && (O.drawImage(e.canvas, 0, 0), s.current.onPostprocess && v.current && await s.current.onPostprocess(v.current));
309
299
  }
310
- d.current && (C.current = window.requestAnimationFrame(d.current));
311
- }, C.current === -1 && (C.current = window.requestAnimationFrame(d.current));
312
- }, [t, e, i, r, u, o, m, f]);
313
- const B = E(
314
- async (n) => {
315
- var c;
316
- if (await n.setup({ facingMode: R ? "user" : "environment" }), n.webcam && (n.webcam.playsInline = !0, n.webcam.muted = !0, n.webcam.onsuspend = () => n.play(), T(n)), (c = navigator.mediaDevices) != null && c.enumerateDevices)
300
+ u.current && (f.current = window.requestAnimationFrame(u.current));
301
+ }, f.current === -1 && (f.current = window.requestAnimationFrame(u.current));
302
+ }, [e, t, o, i, a]);
303
+ const N = B(
304
+ async (r) => {
305
+ var l;
306
+ if (await r.setup({ facingMode: R ? "user" : "environment" }), r.webcam && (r.webcam.playsInline = !0, r.webcam.muted = !0, r.webcam.onsuspend = () => r.play(), A(r)), (l = navigator.mediaDevices) != null && l.enumerateDevices)
317
307
  try {
318
- (await navigator.mediaDevices.enumerateDevices()).filter((g) => g.kind === "videoinput").length > 1 && (k || L(!0), n.flip = R);
319
- } catch (x) {
320
- console.error(x);
308
+ (await navigator.mediaDevices.enumerateDevices()).filter((w) => w.kind === "videoinput").length > 1 && (k || V(!0), r.flip = R);
309
+ } catch (S) {
310
+ console.error(S);
321
311
  }
322
- return p && p(!0), n;
312
+ return s.current.onActivated && s.current.onActivated(!0), r;
323
313
  },
324
- [p, R, k]
314
+ [R, k]
325
315
  );
326
- y(() => {
327
- i && (_.current = 0);
328
- }, [i]), y(() => {
329
- const n = new Y(l, l, !0);
330
- return B(n).catch((c) => {
331
- p && p(!1), console.error("No webcam", c), w && w();
316
+ C(() => {
317
+ o && (g.current = 0);
318
+ }, [o]), C(() => {
319
+ const r = new L(d, d, !0);
320
+ return N(r).catch((l) => {
321
+ s.current.onActivated && s.current.onActivated(!1), console.error("No webcam", l), s.current.onFatal && s.current.onFatal();
332
322
  }), () => {
333
- var c;
334
- (c = n.webcam) != null && c.srcObject && n.stop();
323
+ var l;
324
+ (l = r.webcam) != null && l.srcObject && r.stop();
335
325
  };
336
- }, [R, p, B, w, l]), y(() => () => {
337
- var n;
338
- d.current = void 0, (n = t == null ? void 0 : t.webcam) != null && n.srcObject && t.stop();
339
- }, [t]), y(() => {
340
- t && (o ? t.pause() : t.play());
341
- }, [t, o]);
342
- const U = E(() => {
343
- D((n) => !n);
344
- }, [D]);
345
- return v ? /* @__PURE__ */ s(q, { children: k && /* @__PURE__ */ s(
346
- V,
326
+ }, [R, N, d]), C(() => () => {
327
+ var r;
328
+ u.current = void 0, (r = e == null ? void 0 : e.webcam) != null && r.srcObject && e.stop();
329
+ }, [e]), C(() => {
330
+ e && (a ? e.pause() : e.play());
331
+ }, [e, a]);
332
+ const $ = B(() => {
333
+ I((r) => !r);
334
+ }, [I]);
335
+ return p ? /* @__PURE__ */ c(D, { children: k && /* @__PURE__ */ c(
336
+ P,
347
337
  {
348
338
  size: "large",
349
339
  color: "inherit",
350
- onClick: U,
340
+ onClick: $,
351
341
  "aria-label": h("webcam.aria.flip"),
352
- children: /* @__PURE__ */ s(X, { fontSize: "large" })
342
+ children: /* @__PURE__ */ c(U, { fontSize: "large" })
353
343
  }
354
- ) }) : /* @__PURE__ */ F(q, { children: [
355
- !t && /* @__PURE__ */ s(
356
- K,
344
+ ) }) : /* @__PURE__ */ j(D, { children: [
345
+ !e && /* @__PURE__ */ c(
346
+ E,
357
347
  {
358
348
  variant: "rounded",
359
- width: l,
360
- height: l
349
+ width: d,
350
+ height: d
361
351
  }
362
352
  ),
363
- t && /* @__PURE__ */ F("div", { className: N.wrapContainer, children: [
364
- k && /* @__PURE__ */ s(
365
- V,
353
+ e && /* @__PURE__ */ j("div", { className: F.wrapContainer, children: [
354
+ k && /* @__PURE__ */ c(
355
+ P,
366
356
  {
367
- className: N.flipButton,
357
+ className: F.flipButton,
368
358
  size: "large",
369
359
  color: "inherit",
370
- onClick: U,
360
+ onClick: $,
371
361
  "aria-label": h("webcam.aria.flip"),
372
- children: /* @__PURE__ */ s(X, { fontSize: "large" })
362
+ children: /* @__PURE__ */ c(U, { fontSize: "large" })
373
363
  }
374
364
  ),
375
- /* @__PURE__ */ s(
365
+ /* @__PURE__ */ c(
376
366
  "div",
377
367
  {
378
368
  "data-testid": "webcam",
379
- className: N.container,
369
+ className: F.container,
380
370
  role: "img",
381
371
  "aria-label": h("webcam.aria.video"),
382
- children: /* @__PURE__ */ s(
372
+ children: /* @__PURE__ */ c(
383
373
  "canvas",
384
374
  {
385
- width: l,
386
- height: l,
387
- ref: b
375
+ width: d,
376
+ height: d,
377
+ ref: v
388
378
  }
389
379
  )
390
380
  }
@@ -393,5 +383,5 @@ function Re({
393
383
  ] });
394
384
  }
395
385
  export {
396
- Re as default
386
+ bt as default
397
387
  };