@burdenoff/microfe-healthybowl 2026.829.3 → 2026.829.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.
- package/dist/components/assistant/AssistantHeader.js +40 -38
- package/dist/components/assistant/AssistantHeader.js.map +1 -1
- package/dist/components/assistant/AssistantSpeechProvider.js +163 -138
- package/dist/components/assistant/AssistantSpeechProvider.js.map +1 -1
- package/dist/components/assistant/composer/AssistantLanguageSelector.js +1 -1
- package/dist/components/assistant/composer/AssistantLanguageSelector.js.map +1 -1
- package/dist/components/assistant/composer/AssistantVoiceSelector.js +39 -0
- package/dist/components/assistant/composer/AssistantVoiceSelector.js.map +1 -0
- package/dist/config/assistantLanguages.js +29 -18
- package/dist/config/assistantLanguages.js.map +1 -1
- package/dist/store/assistantStore.js +10 -3
- package/dist/store/assistantStore.js.map +1 -1
- package/dist/utils/speakableText.js +7 -5
- package/dist/utils/speakableText.js.map +1 -1
- package/dist/utils/speechVoices.js +25 -12
- package/dist/utils/speechVoices.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,79 +1,81 @@
|
|
|
1
1
|
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
2
|
import { AssistantExportMenu as t } from "./AssistantExportMenu.js";
|
|
3
3
|
import { AssistantAutoSpeakToggle as n } from "./AssistantAutoSpeakToggle.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { AssistantVoiceSelector as r } from "./composer/AssistantVoiceSelector.js";
|
|
5
|
+
import { History as i, PanelBottom as a, PanelRight as o, Plus as s, Sparkles as c, X as l } from "lucide-react";
|
|
6
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
7
|
//#region src/components/assistant/AssistantHeader.tsx
|
|
7
|
-
var
|
|
8
|
-
let
|
|
9
|
-
return /* @__PURE__ */
|
|
8
|
+
var f = ({ contextLabel: f, onNewConversation: p, onOpenHistory: m, historyOpen: h, onClose: g, docked: _, onToggleDock: v }) => {
|
|
9
|
+
let y = e();
|
|
10
|
+
return /* @__PURE__ */ d("div", {
|
|
10
11
|
className: "flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5",
|
|
11
|
-
children: [/* @__PURE__ */
|
|
12
|
+
children: [/* @__PURE__ */ d("div", {
|
|
12
13
|
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
13
|
-
children: [/* @__PURE__ */
|
|
14
|
+
children: [/* @__PURE__ */ u("span", {
|
|
14
15
|
className: "flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg",
|
|
15
|
-
children: /* @__PURE__ */
|
|
16
|
-
}), /* @__PURE__ */
|
|
16
|
+
children: /* @__PURE__ */ u(c, { className: "size-4" })
|
|
17
|
+
}), /* @__PURE__ */ d("span", {
|
|
17
18
|
className: "min-w-0 flex-1",
|
|
18
|
-
children: [/* @__PURE__ */
|
|
19
|
+
children: [/* @__PURE__ */ u("span", {
|
|
19
20
|
className: "block truncate text-[14px] font-semibold leading-tight text-text-primary",
|
|
20
|
-
children:
|
|
21
|
-
}), /* @__PURE__ */
|
|
21
|
+
children: y("healthybowl.assistant.header.title", "HealthyBowl AI")
|
|
22
|
+
}), /* @__PURE__ */ d("span", {
|
|
22
23
|
className: "block truncate text-[11px] leading-tight text-text-muted",
|
|
23
24
|
children: [
|
|
24
|
-
|
|
25
|
-
/* @__PURE__ */
|
|
25
|
+
y("healthybowl.assistant.header.ready", "Ready"),
|
|
26
|
+
/* @__PURE__ */ u("span", {
|
|
26
27
|
"aria-hidden": "true",
|
|
27
28
|
children: " · "
|
|
28
29
|
}),
|
|
29
|
-
|
|
30
|
+
y("healthybowl.assistant.header.context", "Context: {{page}}", { page: f })
|
|
30
31
|
]
|
|
31
32
|
})]
|
|
32
33
|
})]
|
|
33
|
-
}), /* @__PURE__ */
|
|
34
|
+
}), /* @__PURE__ */ d("div", {
|
|
34
35
|
className: "flex flex-shrink-0 items-center gap-0.5",
|
|
35
36
|
children: [
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
+
/* @__PURE__ */ u("button", {
|
|
37
38
|
type: "button",
|
|
38
|
-
onClick:
|
|
39
|
+
onClick: p,
|
|
39
40
|
className: "rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
|
|
40
|
-
"aria-label":
|
|
41
|
+
"aria-label": y("healthybowl.assistant.header.newConversation", "New conversation"),
|
|
41
42
|
"data-testid": "assistant-new-conversation",
|
|
42
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ u(s, { className: "size-4" })
|
|
43
44
|
}),
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
+
/* @__PURE__ */ u("button", {
|
|
45
46
|
type: "button",
|
|
46
|
-
onClick:
|
|
47
|
-
className: `rounded-lg p-1.5 transition-colors ${
|
|
48
|
-
"aria-label":
|
|
49
|
-
"aria-pressed":
|
|
47
|
+
onClick: m,
|
|
48
|
+
className: `rounded-lg p-1.5 transition-colors ${h ? "bg-action-primary-bg/15 text-action-primary-bg" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
|
|
49
|
+
"aria-label": y("healthybowl.assistant.header.history", "Conversation history"),
|
|
50
|
+
"aria-pressed": h,
|
|
50
51
|
"data-testid": "assistant-open-history",
|
|
51
|
-
children: /* @__PURE__ */
|
|
52
|
+
children: /* @__PURE__ */ u(i, { className: "size-4" })
|
|
52
53
|
}),
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
|
|
54
|
+
/* @__PURE__ */ u(n, {}),
|
|
55
|
+
/* @__PURE__ */ u(r, {}),
|
|
56
|
+
/* @__PURE__ */ u(t, {}),
|
|
57
|
+
v && /* @__PURE__ */ u("button", {
|
|
56
58
|
type: "button",
|
|
57
|
-
onClick:
|
|
59
|
+
onClick: v,
|
|
58
60
|
className: "hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary md:inline-flex",
|
|
59
|
-
"aria-label":
|
|
60
|
-
"aria-pressed":
|
|
61
|
+
"aria-label": _ ? y("healthybowl.assistant.header.float", "Float chat window") : y("healthybowl.assistant.header.dock", "Dock to side panel"),
|
|
62
|
+
"aria-pressed": _,
|
|
61
63
|
"data-testid": "assistant-toggle-dock",
|
|
62
|
-
children:
|
|
64
|
+
children: u(_ ? a : o, { className: "size-4" })
|
|
63
65
|
}),
|
|
64
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ u("button", {
|
|
65
67
|
type: "button",
|
|
66
|
-
onClick:
|
|
68
|
+
onClick: g,
|
|
67
69
|
className: "rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
|
|
68
|
-
"aria-label":
|
|
70
|
+
"aria-label": y("healthybowl.assistant.header.close", "Close assistant"),
|
|
69
71
|
"data-testid": "assistant-close",
|
|
70
|
-
children: /* @__PURE__ */ l
|
|
72
|
+
children: /* @__PURE__ */ u(l, { className: "size-4" })
|
|
71
73
|
})
|
|
72
74
|
]
|
|
73
75
|
})]
|
|
74
76
|
});
|
|
75
77
|
};
|
|
76
78
|
//#endregion
|
|
77
|
-
export {
|
|
79
|
+
export { f as AssistantHeader };
|
|
78
80
|
|
|
79
81
|
//# sourceMappingURL=AssistantHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantHeader.js","names":[],"sources":["../../../src/components/assistant/AssistantHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Sparkles, Plus, History, PanelRight, PanelBottom, X } from 'lucide-react';\nimport { AssistantExportMenu } from './AssistantExportMenu';\nimport { AssistantAutoSpeakToggle } from './AssistantAutoSpeakToggle';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n /** Friendly label for the page the user is on (e.g. \"Inventory\"). */\n contextLabel: string;\n onNewConversation: () => void;\n onOpenHistory: () => void;\n /** True when the history drawer is currently open (drives the toggle state). */\n historyOpen: boolean;\n onClose: () => void;\n docked?: boolean;\n onToggleDock?: () => void;\n}\n\n/**\n * AssistantHeader — the v2 identity bar (per the ai-assistant-v2 mockups):\n * a ✦ brand mark + \"HealthyBowl AI\", a small availability/context subtitle\n * (\"Ready · Context: <page>\"), and a row of icon actions: New conversation,\n * History (opens the conversation list as an overlay drawer — NOT an accordion),\n * Export, Dock toggle, Close.\n *\n * Replaces the old \"Conversation History\" accordion header. HB semantic tokens\n * only; copy via useTr.\n */\nexport const AssistantHeader: FC<Props> = ({\n contextLabel,\n onNewConversation,\n onOpenHistory,\n historyOpen,\n onClose,\n docked,\n onToggleDock,\n}) => {\n const tr = useTr();\n\n return (\n <div className=\"flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5\">\n {/* Brand + context subtitle */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg\">\n <Sparkles className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[14px] font-semibold leading-tight text-text-primary\">\n {tr('healthybowl.assistant.header.title', 'HealthyBowl AI')}\n </span>\n <span className=\"block truncate text-[11px] leading-tight text-text-muted\">\n {tr('healthybowl.assistant.header.ready', 'Ready')}\n <span aria-hidden=\"true\"> · </span>\n {tr('healthybowl.assistant.header.context', 'Context: {{page}}', { page: contextLabel })}\n </span>\n </span>\n </div>\n\n {/* Actions */}\n <div className=\"flex flex-shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={onNewConversation}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.newConversation', 'New conversation')}\n data-testid=\"assistant-new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={onOpenHistory}\n className={`rounded-lg p-1.5 transition-colors ${\n historyOpen\n ? 'bg-action-primary-bg/15 text-action-primary-bg'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n aria-label={tr('healthybowl.assistant.header.history', 'Conversation history')}\n aria-pressed={historyOpen}\n data-testid=\"assistant-open-history\"\n >\n <History className=\"size-4\" />\n </button>\n {/* Renders nothing where the browser has no speech output. */}\n <AssistantAutoSpeakToggle />\n <AssistantExportMenu />\n {onToggleDock && (\n <button\n type=\"button\"\n onClick={onToggleDock}\n className=\"hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary md:inline-flex\"\n aria-label={\n docked\n ? tr('healthybowl.assistant.header.float', 'Float chat window')\n : tr('healthybowl.assistant.header.dock', 'Dock to side panel')\n }\n aria-pressed={docked}\n data-testid=\"assistant-toggle-dock\"\n >\n {docked ? <PanelBottom className=\"size-4\" /> : <PanelRight className=\"size-4\" />}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.close', 'Close assistant')}\n data-testid=\"assistant-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n </div>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AssistantHeader.js","names":[],"sources":["../../../src/components/assistant/AssistantHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Sparkles, Plus, History, PanelRight, PanelBottom, X } from 'lucide-react';\nimport { AssistantExportMenu } from './AssistantExportMenu';\nimport { AssistantAutoSpeakToggle } from './AssistantAutoSpeakToggle';\nimport { AssistantVoiceSelector } from './composer/AssistantVoiceSelector';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n /** Friendly label for the page the user is on (e.g. \"Inventory\"). */\n contextLabel: string;\n onNewConversation: () => void;\n onOpenHistory: () => void;\n /** True when the history drawer is currently open (drives the toggle state). */\n historyOpen: boolean;\n onClose: () => void;\n docked?: boolean;\n onToggleDock?: () => void;\n}\n\n/**\n * AssistantHeader — the v2 identity bar (per the ai-assistant-v2 mockups):\n * a ✦ brand mark + \"HealthyBowl AI\", a small availability/context subtitle\n * (\"Ready · Context: <page>\"), and a row of icon actions: New conversation,\n * History (opens the conversation list as an overlay drawer — NOT an accordion),\n * Export, Dock toggle, Close.\n *\n * Replaces the old \"Conversation History\" accordion header. HB semantic tokens\n * only; copy via useTr.\n */\nexport const AssistantHeader: FC<Props> = ({\n contextLabel,\n onNewConversation,\n onOpenHistory,\n historyOpen,\n onClose,\n docked,\n onToggleDock,\n}) => {\n const tr = useTr();\n\n return (\n <div className=\"flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5\">\n {/* Brand + context subtitle */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg\">\n <Sparkles className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[14px] font-semibold leading-tight text-text-primary\">\n {tr('healthybowl.assistant.header.title', 'HealthyBowl AI')}\n </span>\n <span className=\"block truncate text-[11px] leading-tight text-text-muted\">\n {tr('healthybowl.assistant.header.ready', 'Ready')}\n <span aria-hidden=\"true\"> · </span>\n {tr('healthybowl.assistant.header.context', 'Context: {{page}}', { page: contextLabel })}\n </span>\n </span>\n </div>\n\n {/* Actions */}\n <div className=\"flex flex-shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={onNewConversation}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.newConversation', 'New conversation')}\n data-testid=\"assistant-new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={onOpenHistory}\n className={`rounded-lg p-1.5 transition-colors ${\n historyOpen\n ? 'bg-action-primary-bg/15 text-action-primary-bg'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n aria-label={tr('healthybowl.assistant.header.history', 'Conversation history')}\n aria-pressed={historyOpen}\n data-testid=\"assistant-open-history\"\n >\n <History className=\"size-4\" />\n </button>\n {/* Renders nothing where the browser has no speech output. */}\n <AssistantAutoSpeakToggle />\n {/* Beside the auto-speak toggle rather than in the composer: it is a\n playback setting, and the composer row is already exactly full at\n 390px — a fourth chip there would push send off the edge. Renders\n nothing when the device offers fewer than two voices. */}\n <AssistantVoiceSelector />\n <AssistantExportMenu />\n {onToggleDock && (\n <button\n type=\"button\"\n onClick={onToggleDock}\n className=\"hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary md:inline-flex\"\n aria-label={\n docked\n ? tr('healthybowl.assistant.header.float', 'Float chat window')\n : tr('healthybowl.assistant.header.dock', 'Dock to side panel')\n }\n aria-pressed={docked}\n data-testid=\"assistant-toggle-dock\"\n >\n {docked ? <PanelBottom className=\"size-4\" /> : <PanelRight className=\"size-4\" />}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.close', 'Close assistant')}\n data-testid=\"assistant-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;AA6BA,IAAa,KAA8B,EACzC,iBACA,sBACA,kBACA,gBACA,YACA,WACA,sBACI;CACJ,IAAM,IAAK,EAAM;CAEjB,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CAEE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,QAAD;IAAM,WAAU;cACd,kBAAC,GAAD,EAAU,WAAU,SAAU,CAAA;GAC1B,CAAA,GACN,kBAAC,QAAD;IAAM,WAAU;cAAhB,CACE,kBAAC,QAAD;KAAM,WAAU;eACb,EAAG,sCAAsC,gBAAgB;IACtD,CAAA,GACN,kBAAC,QAAD;KAAM,WAAU;eAAhB;MACG,EAAG,sCAAsC,OAAO;MACjD,kBAAC,QAAD;OAAM,eAAY;iBAAO;MAAS,CAAA;MACjC,EAAG,wCAAwC,qBAAqB,EAAE,MAAM,EAAa,CAAC;KACnF;MACF;KACH;MAGL,kBAAC,OAAD;GAAK,WAAU;aAAf;IACE,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cAAY,EAAG,gDAAgD,kBAAkB;KACjF,eAAY;eAEZ,kBAAC,GAAD,EAAM,WAAU,SAAU,CAAA;IACpB,CAAA;IACR,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAW,sCACT,IACI,mDACA;KAEN,cAAY,EAAG,wCAAwC,sBAAsB;KAC7E,gBAAc;KACd,eAAY;eAEZ,kBAAC,GAAD,EAAS,WAAU,SAAU,CAAA;IACvB,CAAA;IAER,kBAAC,GAAD,CAA2B,CAAA;IAK3B,kBAAC,GAAD,CAAyB,CAAA;IACzB,kBAAC,GAAD,CAAsB,CAAA;IACrB,KACC,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cACE,IACI,EAAG,sCAAsC,mBAAmB,IAC5D,EAAG,qCAAqC,oBAAoB;KAElE,gBAAc;KACd,eAAY;eAEF,EAAT,IAAU,IAAqC,GAAtC,EAAa,WAAU,SAAU,CAAoC;IACzE,CAAA;IAEV,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cAAY,EAAG,sCAAsC,iBAAiB;KACtE,eAAY;eAEZ,kBAAC,GAAD,EAAG,WAAU,SAAU,CAAA;IACjB,CAAA;GACL;IACF;;AAET"}
|
|
@@ -2,29 +2,35 @@ import { useAssistantStore as e } from "../../store/assistantStore.js";
|
|
|
2
2
|
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
3
|
import { browserSpeechEngine as n } from "../../services/speech/browserSpeechEngine.js";
|
|
4
4
|
import { chunkForSpeech as r, toSpeakableText as i } from "../../utils/speakableText.js";
|
|
5
|
-
import { VOICE_LIST_TIMEOUT_MS as a, languageDisplayName as o, selectVoiceForLocale as s, speechGate as
|
|
5
|
+
import { VOICE_LIST_TIMEOUT_MS as a, languageDisplayName as o, selectVoiceForLocale as s, speechGate as ee, speechLangForLocale as c, voiceAvailability as l, voicesForLocale as u } from "../../utils/speechVoices.js";
|
|
6
6
|
import { resolveSpeechLocale as d } from "../../utils/replyLanguage.js";
|
|
7
|
-
import { findAssistantLanguage as f, resolveAssistantLanguage as
|
|
8
|
-
import { IDLE_PLAYBACK as
|
|
9
|
-
import { isTurnInFlight as
|
|
10
|
-
import { parseToolActivity as
|
|
11
|
-
import { createContext as
|
|
12
|
-
import { useI18n as
|
|
13
|
-
import { jsx as
|
|
7
|
+
import { findAssistantLanguage as f, resolveAssistantLanguage as te } from "../../config/assistantLanguages.js";
|
|
8
|
+
import { IDLE_PLAYBACK as ne, isSpeakingMessage as p, speechPlaybackReducer as re } from "../../utils/speechPlayback.js";
|
|
9
|
+
import { isTurnInFlight as ie } from "../../utils/assistantTurnState.js";
|
|
10
|
+
import { parseToolActivity as ae } from "./AssistantToolActivity.js";
|
|
11
|
+
import { createContext as m, useCallback as h, useContext as g, useEffect as _, useMemo as v, useReducer as oe, useRef as y, useState as b } from "react";
|
|
12
|
+
import { useI18n as se } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
13
|
+
import { jsx as ce } from "react/jsx-runtime";
|
|
14
14
|
//#region src/components/assistant/AssistantSpeechProvider.tsx
|
|
15
|
-
var
|
|
15
|
+
var le = {
|
|
16
16
|
codeBlock: "",
|
|
17
17
|
image: "",
|
|
18
18
|
link: "",
|
|
19
19
|
largeTable: "",
|
|
20
20
|
truncated: "",
|
|
21
|
+
emailAt: "at",
|
|
22
|
+
emailDot: "dot",
|
|
21
23
|
nestedItem: ""
|
|
22
|
-
},
|
|
24
|
+
}, x = m({
|
|
23
25
|
isSupported: !1,
|
|
24
26
|
availability: "unsupported",
|
|
25
27
|
isBlocked: !0,
|
|
26
28
|
disabledReason: null,
|
|
27
29
|
blockedFor: () => null,
|
|
30
|
+
voiceChoices: [],
|
|
31
|
+
activeVoiceName: null,
|
|
32
|
+
preferredVoiceName: null,
|
|
33
|
+
setVoice: () => {},
|
|
28
34
|
speakingMessageId: null,
|
|
29
35
|
isSpeaking: () => !1,
|
|
30
36
|
toggle: () => {},
|
|
@@ -32,196 +38,215 @@ var se = {
|
|
|
32
38
|
autoSpeakEnabled: !1,
|
|
33
39
|
setAutoSpeak: () => {}
|
|
34
40
|
});
|
|
35
|
-
function
|
|
36
|
-
return
|
|
41
|
+
function S() {
|
|
42
|
+
return g(x);
|
|
37
43
|
}
|
|
38
|
-
var
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
}, []),
|
|
42
|
-
|
|
43
|
-
if (!
|
|
44
|
+
var C = ({ children: m, visible: g = !0, engine: S = n }) => {
|
|
45
|
+
let C = t(), { locale: w } = se(), [T, E] = oe(re, ne), [D, O] = b(() => S.listVoices()), [k, A] = b(!1), [j, M] = b(() => /* @__PURE__ */ new Map()), N = y(0), P = y(null), F = y(() => {}), I = h(() => {
|
|
46
|
+
P.current?.(), P.current = null;
|
|
47
|
+
}, []), L = e((e) => e.autoSpeakEnabled), R = e((e) => e.setAutoSpeak), ue = e((e) => e.activeConversationId), z = v(() => S.isSupported(), [S]);
|
|
48
|
+
_(() => {
|
|
49
|
+
if (!z) return;
|
|
44
50
|
let e = () => {
|
|
45
|
-
|
|
51
|
+
O(S.listVoices()), M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
46
52
|
};
|
|
47
|
-
return e(),
|
|
48
|
-
}, [
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]),
|
|
55
|
-
codeBlock:
|
|
56
|
-
image:
|
|
57
|
-
link:
|
|
58
|
-
largeTable:
|
|
59
|
-
truncated:
|
|
60
|
-
nestedItem:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, [
|
|
64
|
-
|
|
53
|
+
return e(), S.subscribeVoices(e);
|
|
54
|
+
}, [S, z]);
|
|
55
|
+
let B = e((e) => e.assistantLanguage), V = e((e) => e.preferredVoices), H = e((e) => e.setPreferredVoice), U = v(() => te(B, w), [B, w]), W = U.code, G = h((e) => f(e)?.tag ?? c(e), []), K = h((e) => f(e)?.rate ?? .9, []), q = v(() => l(z, D, U.tag, k), [
|
|
56
|
+
z,
|
|
57
|
+
D,
|
|
58
|
+
U,
|
|
59
|
+
k
|
|
60
|
+
]), J = v(() => ({
|
|
61
|
+
codeBlock: C("healthybowl.assistant.speech.codeBlock", "Code block"),
|
|
62
|
+
image: C("healthybowl.assistant.speech.image", "image"),
|
|
63
|
+
link: C("healthybowl.assistant.speech.link", "link"),
|
|
64
|
+
largeTable: C("healthybowl.assistant.speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
|
|
65
|
+
truncated: C("healthybowl.assistant.speech.truncated", "The rest of this message is not read aloud"),
|
|
66
|
+
nestedItem: C("healthybowl.assistant.speech.nestedItem", "Sub-item {{ordinal}}"),
|
|
67
|
+
emailAt: C("healthybowl.assistant.speech.emailAt", "at"),
|
|
68
|
+
emailDot: C("healthybowl.assistant.speech.emailDot", "dot")
|
|
69
|
+
}), [C]), Y = h(() => {
|
|
70
|
+
I(), S.cancel(), E({ type: "stop" });
|
|
71
|
+
}, [I, S]), X = h((e) => j.get(e) ?? null, [j]), Z = h((e, t, n) => {
|
|
72
|
+
I();
|
|
65
73
|
let r = !1, i = () => {}, o = (a) => {
|
|
66
74
|
if (!r) {
|
|
67
|
-
if (r = !0,
|
|
68
|
-
|
|
75
|
+
if (r = !0, P.current = null, clearTimeout(s), i(), a.length === 0) {
|
|
76
|
+
A(!0);
|
|
69
77
|
return;
|
|
70
78
|
}
|
|
71
|
-
|
|
79
|
+
O(a), F.current(e, t, a, n);
|
|
72
80
|
}
|
|
73
|
-
}, s = setTimeout(() => o(
|
|
74
|
-
i =
|
|
75
|
-
r || (r = !0, clearTimeout(s), i(),
|
|
81
|
+
}, s = setTimeout(() => o(S.listVoices()), a);
|
|
82
|
+
i = S.subscribeVoices(() => o(S.listVoices())), P.current = () => {
|
|
83
|
+
r || (r = !0, clearTimeout(s), i(), P.current = null);
|
|
76
84
|
};
|
|
77
|
-
}, [
|
|
85
|
+
}, [I, S]), Q = h((e, t, n, i) => {
|
|
78
86
|
let a = n;
|
|
79
87
|
if (a.length === 0) {
|
|
80
|
-
let e =
|
|
81
|
-
e.length > 0 && (a = e,
|
|
88
|
+
let e = S.listVoices();
|
|
89
|
+
e.length > 0 && (a = e, O(e));
|
|
82
90
|
}
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
let t =
|
|
86
|
-
|
|
91
|
+
let c = G(i), u = ee(l(!0, a, i, k));
|
|
92
|
+
if (u === "block") {
|
|
93
|
+
let t = C("healthybowl.assistant.speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: o(c, w) });
|
|
94
|
+
M((n) => new Map(n).set(e, t));
|
|
87
95
|
return;
|
|
88
96
|
}
|
|
89
|
-
if (
|
|
90
|
-
|
|
97
|
+
if (u === "wait-for-voices") {
|
|
98
|
+
Z(e, t, i);
|
|
91
99
|
return;
|
|
92
100
|
}
|
|
93
|
-
|
|
101
|
+
M((t) => {
|
|
94
102
|
if (!t.has(e)) return t;
|
|
95
103
|
let n = new Map(t);
|
|
96
104
|
return n.delete(e), n;
|
|
97
105
|
});
|
|
98
|
-
let
|
|
99
|
-
|
|
106
|
+
let d = N.current + 1;
|
|
107
|
+
N.current = d, E({
|
|
100
108
|
type: "start",
|
|
101
109
|
messageId: e,
|
|
102
|
-
requestId:
|
|
103
|
-
}),
|
|
104
|
-
voice: s(a,
|
|
105
|
-
lang:
|
|
110
|
+
requestId: d
|
|
111
|
+
}), S.speak(r(t), {
|
|
112
|
+
voice: s(a, c, V[i]),
|
|
113
|
+
lang: c,
|
|
114
|
+
rate: K(i)
|
|
106
115
|
}, {
|
|
107
|
-
onEnd: () =>
|
|
116
|
+
onEnd: () => E({
|
|
108
117
|
type: "finished",
|
|
109
|
-
requestId:
|
|
118
|
+
requestId: d
|
|
110
119
|
}),
|
|
111
|
-
onError: () =>
|
|
120
|
+
onError: () => E({
|
|
112
121
|
type: "failed",
|
|
113
|
-
requestId:
|
|
122
|
+
requestId: d
|
|
114
123
|
})
|
|
115
124
|
});
|
|
116
125
|
}, [
|
|
117
|
-
|
|
118
|
-
T,
|
|
119
|
-
W,
|
|
126
|
+
S,
|
|
120
127
|
w,
|
|
121
|
-
|
|
122
|
-
|
|
128
|
+
V,
|
|
129
|
+
K,
|
|
130
|
+
G,
|
|
131
|
+
C,
|
|
132
|
+
k,
|
|
133
|
+
Z
|
|
123
134
|
]);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}, [
|
|
127
|
-
let
|
|
128
|
-
if (!
|
|
129
|
-
let r = i(t, { labels:
|
|
130
|
-
r &&
|
|
135
|
+
_(() => {
|
|
136
|
+
F.current = Q;
|
|
137
|
+
}, [Q]);
|
|
138
|
+
let $ = h((e, t, n) => {
|
|
139
|
+
if (!z) return;
|
|
140
|
+
let r = i(t, { labels: J });
|
|
141
|
+
r && Q(e, r, D, d(i(t, { labels: le }), n ?? W));
|
|
131
142
|
}, [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
]),
|
|
138
|
-
if (
|
|
139
|
-
|
|
143
|
+
z,
|
|
144
|
+
J,
|
|
145
|
+
W,
|
|
146
|
+
Q,
|
|
147
|
+
D
|
|
148
|
+
]), de = h((e, t, n) => {
|
|
149
|
+
if (p(T, e)) {
|
|
150
|
+
Y();
|
|
140
151
|
return;
|
|
141
152
|
}
|
|
142
|
-
|
|
153
|
+
$(e, t, n);
|
|
143
154
|
}, [
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
T,
|
|
156
|
+
$,
|
|
157
|
+
Y
|
|
147
158
|
]);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}, [
|
|
151
|
-
|
|
152
|
-
}, [
|
|
153
|
-
|
|
154
|
-
}, [
|
|
155
|
-
|
|
156
|
-
}, [
|
|
159
|
+
_(() => {
|
|
160
|
+
g || Y();
|
|
161
|
+
}, [g, Y]), _(() => {
|
|
162
|
+
Y(), M(/* @__PURE__ */ new Map());
|
|
163
|
+
}, [ue, Y]), _(() => {
|
|
164
|
+
M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), Y();
|
|
165
|
+
}, [W, Y]), _(() => () => {
|
|
166
|
+
P.current?.(), P.current = null, S.cancel();
|
|
167
|
+
}, [S]), _(() => {
|
|
157
168
|
if (typeof window > "u") return;
|
|
158
|
-
let e = () =>
|
|
169
|
+
let e = () => S.cancel();
|
|
159
170
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
160
|
-
}, [
|
|
161
|
-
if (typeof document > "u" || !
|
|
171
|
+
}, [S]), _(() => {
|
|
172
|
+
if (typeof document > "u" || !z) return;
|
|
162
173
|
let e = () => {
|
|
163
174
|
if (document.visibilityState !== "visible") return;
|
|
164
|
-
let e =
|
|
165
|
-
e.length > 0 &&
|
|
175
|
+
let e = S.listVoices();
|
|
176
|
+
e.length > 0 && I(), O(e), A(!1), M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
166
177
|
};
|
|
167
178
|
return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
|
|
168
179
|
document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
|
|
169
180
|
};
|
|
170
181
|
}, [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
182
|
+
I,
|
|
183
|
+
S,
|
|
184
|
+
z
|
|
174
185
|
]);
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}, [
|
|
179
|
-
if (!(!
|
|
186
|
+
let fe = y($);
|
|
187
|
+
_(() => {
|
|
188
|
+
fe.current = $;
|
|
189
|
+
}, [$]), _(() => {
|
|
190
|
+
if (!(!L || !g || !z)) return e.subscribe((e, t) => {
|
|
180
191
|
let n = e.activeConversationId;
|
|
181
192
|
if (!n || n !== t.activeConversationId) return;
|
|
182
193
|
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
183
|
-
if (r?.status !== "complete" || !
|
|
194
|
+
if (r?.status !== "complete" || !ie(i?.status)) return;
|
|
184
195
|
let a = r.messageId ?? i?.messageId ?? null;
|
|
185
196
|
if (!a) return;
|
|
186
197
|
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
187
198
|
if (!o || o.role !== "assistant") return;
|
|
188
|
-
let { text: s } =
|
|
189
|
-
s.trim() &&
|
|
199
|
+
let { text: s } = ae(o.content);
|
|
200
|
+
s.trim() && fe.current(a, s, o.metadata?.lang);
|
|
190
201
|
});
|
|
191
202
|
}, [
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
203
|
+
L,
|
|
204
|
+
z,
|
|
205
|
+
g
|
|
195
206
|
]);
|
|
196
|
-
let
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
let pe = v(() => u(D, U.tag), [D, U]), me = v(() => s(D, U.tag, V[W]), [
|
|
208
|
+
D,
|
|
209
|
+
U,
|
|
210
|
+
V,
|
|
211
|
+
W
|
|
212
|
+
]), he = v(() => ({
|
|
213
|
+
isSupported: z,
|
|
214
|
+
availability: q,
|
|
215
|
+
isBlocked: q === "no-voices",
|
|
216
|
+
disabledReason: q === "no-voices" ? C("healthybowl.assistant.speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
|
|
217
|
+
blockedFor: X,
|
|
218
|
+
voiceChoices: pe,
|
|
219
|
+
activeVoiceName: me?.name ?? null,
|
|
220
|
+
preferredVoiceName: V[W] ?? null,
|
|
221
|
+
setVoice: (e) => H(W, e),
|
|
222
|
+
speakingMessageId: T.status === "speaking" ? T.messageId : null,
|
|
223
|
+
isSpeaking: (e) => p(T, e),
|
|
224
|
+
toggle: de,
|
|
225
|
+
stop: Y,
|
|
226
|
+
autoSpeakEnabled: L,
|
|
227
|
+
setAutoSpeak: R
|
|
208
228
|
}), [
|
|
209
|
-
|
|
210
|
-
G,
|
|
211
|
-
J,
|
|
212
|
-
E,
|
|
213
|
-
Q,
|
|
229
|
+
z,
|
|
214
230
|
q,
|
|
231
|
+
X,
|
|
232
|
+
pe,
|
|
233
|
+
me,
|
|
234
|
+
V,
|
|
235
|
+
H,
|
|
236
|
+
W,
|
|
237
|
+
T,
|
|
238
|
+
de,
|
|
239
|
+
Y,
|
|
240
|
+
L,
|
|
215
241
|
R,
|
|
216
|
-
|
|
217
|
-
w
|
|
242
|
+
C
|
|
218
243
|
]);
|
|
219
|
-
return /* @__PURE__ */
|
|
220
|
-
value:
|
|
221
|
-
children:
|
|
244
|
+
return /* @__PURE__ */ ce(x.Provider, {
|
|
245
|
+
value: he,
|
|
246
|
+
children: m
|
|
222
247
|
});
|
|
223
248
|
};
|
|
224
249
|
//#endregion
|
|
225
|
-
export {
|
|
250
|
+
export { C as AssistantSpeechProvider, S as useAssistantSpeech };
|
|
226
251
|
|
|
227
252
|
//# sourceMappingURL=AssistantSpeechProvider.js.map
|