@burdenoff/microfe-healthybowl 2026.902.15 → 2026.902.17
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/AssistantMoreMenu.js +58 -48
- package/dist/components/assistant/AssistantMoreMenu.js.map +1 -1
- package/dist/components/assistant/AssistantSpeechProvider.js +176 -161
- package/dist/components/assistant/AssistantSpeechProvider.js.map +1 -1
- package/dist/healthybowl/hooks/useHealthyBowlData.js +0 -15
- package/dist/healthybowl/hooks/useHealthyBowlData.js.map +1 -1
- package/dist/healthybowl/offline/graphql.js.map +1 -1
- package/dist/healthybowl/offline/syncEngine.js +1 -2
- package/dist/healthybowl/offline/syncEngine.js.map +1 -1
- package/dist/healthybowl/offline/types.js.map +1 -1
- package/dist/healthybowl/pages/government-schemes/ApplicationTrackingPage.js +188 -228
- package/dist/healthybowl/pages/government-schemes/ApplicationTrackingPage.js.map +1 -1
- package/dist/healthybowl/pages/government-schemes/SchemeDetailsPage.js +191 -261
- package/dist/healthybowl/pages/government-schemes/SchemeDetailsPage.js.map +1 -1
- package/dist/healthybowl/pages/network/ExpertsPage.js +419 -520
- package/dist/healthybowl/pages/network/ExpertsPage.js.map +1 -1
- package/dist/utils/voicePreview.js +28 -0
- package/dist/utils/voicePreview.js.map +1 -0
- package/package.json +1 -1
- package/dist/healthybowl/hooks/useConsultationPayments.js +0 -59
- package/dist/healthybowl/hooks/useConsultationPayments.js.map +0 -1
- package/dist/healthybowl/pages/government-schemes/schemeApplicationTransitions.js +0 -49
- package/dist/healthybowl/pages/government-schemes/schemeApplicationTransitions.js.map +0 -1
- package/dist/healthybowl/pages/government-schemes/schemeDocumentSlots.js +0 -48
- package/dist/healthybowl/pages/government-schemes/schemeDocumentSlots.js.map +0 -1
- package/dist/healthybowl/pages/government-schemes/useSchemeApplicationTransition.js +0 -54
- package/dist/healthybowl/pages/government-schemes/useSchemeApplicationTransition.js.map +0 -1
|
@@ -4,101 +4,111 @@ import { downloadFile as n, exportConversation as r } from "../../services/assis
|
|
|
4
4
|
import { useAssistantSpeech as i } from "./AssistantSpeechProvider.js";
|
|
5
5
|
import { AssistantVoiceSelector as a } from "./composer/AssistantVoiceSelector.js";
|
|
6
6
|
import { useEffect as o, useRef as s, useState as c } from "react";
|
|
7
|
-
import { Check as l, FileJson as u, FileText as d, MoreHorizontal as f,
|
|
8
|
-
import { Fragment as
|
|
7
|
+
import { Check as l, FileJson as u, FileText as d, MoreHorizontal as f, Play as p, Volume2 as m } from "lucide-react";
|
|
8
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/assistant/AssistantMoreMenu.tsx
|
|
10
|
-
var
|
|
11
|
-
let
|
|
10
|
+
var v = () => {
|
|
11
|
+
let v = t(), [y, b] = c(!1), x = s(null), S = s(null), { conversations: C, activeConversationId: w } = e(), T = C.find((e) => e.id === w), E = !!(T && T.messages.length > 0), { isSupported: D, isBlocked: O, disabledReason: k, autoSpeakEnabled: A, setAutoSpeak: j, stop: M, previewVoice: N, activeVoiceName: P } = i(), F = O && !A;
|
|
12
12
|
o(() => {
|
|
13
|
-
if (!
|
|
13
|
+
if (!y) return;
|
|
14
14
|
let e = (e) => {
|
|
15
|
-
e.key === "Escape" && (
|
|
15
|
+
e.key === "Escape" && (b(!1), S.current?.focus());
|
|
16
16
|
}, t = (e) => {
|
|
17
17
|
let t = e.target;
|
|
18
|
-
|
|
18
|
+
x.current?.contains(t) || S.current?.contains(t) || b(!1);
|
|
19
19
|
};
|
|
20
20
|
return window.addEventListener("keydown", e), document.addEventListener("mousedown", t), () => {
|
|
21
21
|
window.removeEventListener("keydown", e), document.removeEventListener("mousedown", t);
|
|
22
22
|
};
|
|
23
|
-
}, [
|
|
24
|
-
let
|
|
25
|
-
if (!
|
|
26
|
-
let { content: t, filename: i, mimeType: a } = r(
|
|
27
|
-
n(t, i, a),
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
return /* @__PURE__ */
|
|
23
|
+
}, [y]);
|
|
24
|
+
let I = (e) => {
|
|
25
|
+
if (!T) return;
|
|
26
|
+
let { content: t, filename: i, mimeType: a } = r(T, e);
|
|
27
|
+
n(t, i, a), b(!1);
|
|
28
|
+
}, L = () => {
|
|
29
|
+
A && M(), j(!A);
|
|
30
|
+
}, R = v("healthybowl.assistant.header.more", "More options");
|
|
31
|
+
return /* @__PURE__ */ _("div", {
|
|
32
32
|
className: "relative",
|
|
33
|
-
children: [/* @__PURE__ */
|
|
34
|
-
ref:
|
|
33
|
+
children: [/* @__PURE__ */ g("button", {
|
|
34
|
+
ref: S,
|
|
35
35
|
type: "button",
|
|
36
|
-
onClick: () =>
|
|
36
|
+
onClick: () => b((e) => !e),
|
|
37
37
|
className: "rounded p-1 transition-colors hover:bg-bg-elevated",
|
|
38
|
-
"aria-label":
|
|
38
|
+
"aria-label": R,
|
|
39
39
|
"aria-haspopup": "menu",
|
|
40
|
-
"aria-expanded":
|
|
40
|
+
"aria-expanded": y,
|
|
41
41
|
"data-testid": "assistant-more",
|
|
42
|
-
children: /* @__PURE__ */
|
|
43
|
-
}),
|
|
44
|
-
ref:
|
|
42
|
+
children: /* @__PURE__ */ g(f, { className: "size-4 text-text-secondary" })
|
|
43
|
+
}), y ? /* @__PURE__ */ _("div", {
|
|
44
|
+
ref: x,
|
|
45
45
|
role: "menu",
|
|
46
|
-
"aria-label":
|
|
46
|
+
"aria-label": R,
|
|
47
47
|
className: "absolute right-0 top-full z-50 mt-1 min-w-56 overflow-hidden rounded-xl border border-border-default bg-bg-surface py-1 shadow-lg",
|
|
48
48
|
"data-testid": "assistant-more-menu",
|
|
49
49
|
children: [
|
|
50
|
-
|
|
50
|
+
D ? /* @__PURE__ */ _("button", {
|
|
51
51
|
type: "button",
|
|
52
52
|
role: "menuitemcheckbox",
|
|
53
|
-
"aria-checked":
|
|
54
|
-
onClick:
|
|
55
|
-
disabled:
|
|
56
|
-
title:
|
|
53
|
+
"aria-checked": A,
|
|
54
|
+
onClick: L,
|
|
55
|
+
disabled: F,
|
|
56
|
+
title: F ? k ?? void 0 : void 0,
|
|
57
57
|
className: "flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated disabled:cursor-not-allowed disabled:text-text-muted disabled:hover:bg-transparent",
|
|
58
58
|
"data-testid": "assistant-auto-speak",
|
|
59
59
|
children: [
|
|
60
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ g(m, {
|
|
61
61
|
className: "size-3.5 flex-shrink-0 text-text-secondary",
|
|
62
62
|
"aria-hidden": "true"
|
|
63
63
|
}),
|
|
64
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ g("span", {
|
|
65
65
|
className: "flex-1",
|
|
66
|
-
children:
|
|
66
|
+
children: v("healthybowl.assistant.header.autoRead", "Auto-read replies")
|
|
67
67
|
}),
|
|
68
|
-
|
|
68
|
+
A ? /* @__PURE__ */ g(l, { className: "size-3.5 flex-shrink-0 text-action-primary-bg" }) : null
|
|
69
69
|
]
|
|
70
70
|
}) : null,
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
className: "px-3 py-1.5",
|
|
71
|
+
/* @__PURE__ */ _("div", {
|
|
72
|
+
className: "flex items-center gap-1 px-3 py-1.5",
|
|
73
73
|
"data-testid": "assistant-more-voice",
|
|
74
|
-
children: /* @__PURE__ */
|
|
74
|
+
children: [/* @__PURE__ */ g(a, {}), P ? /* @__PURE__ */ _("button", {
|
|
75
|
+
type: "button",
|
|
76
|
+
onClick: () => N(P),
|
|
77
|
+
className: "flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-text-muted transition-colors hover:bg-bg-elevated hover:text-text-secondary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong",
|
|
78
|
+
"aria-label": v("healthybowl.assistant.voice.preview", "Hear this voice"),
|
|
79
|
+
"data-testid": "assistant-voice-preview",
|
|
80
|
+
children: [/* @__PURE__ */ g(p, {
|
|
81
|
+
className: "size-3",
|
|
82
|
+
"aria-hidden": "true"
|
|
83
|
+
}), v("healthybowl.assistant.voice.previewShort", "Preview")]
|
|
84
|
+
}) : null]
|
|
75
85
|
}),
|
|
76
|
-
|
|
77
|
-
/* @__PURE__ */
|
|
86
|
+
E ? /* @__PURE__ */ _(h, { children: [
|
|
87
|
+
/* @__PURE__ */ g("div", {
|
|
78
88
|
className: "my-1 border-t border-border-subtle",
|
|
79
89
|
role: "separator"
|
|
80
90
|
}),
|
|
81
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ _("button", {
|
|
82
92
|
type: "button",
|
|
83
93
|
role: "menuitem",
|
|
84
|
-
onClick: () =>
|
|
94
|
+
onClick: () => I("json"),
|
|
85
95
|
className: "flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated",
|
|
86
96
|
"data-testid": "export-json",
|
|
87
|
-
children: [/* @__PURE__ */
|
|
97
|
+
children: [/* @__PURE__ */ g(u, {
|
|
88
98
|
className: "size-3.5 flex-shrink-0 text-text-secondary",
|
|
89
99
|
"aria-hidden": "true"
|
|
90
|
-
}),
|
|
100
|
+
}), v("healthybowl.assistant.export.json", "Export as JSON")]
|
|
91
101
|
}),
|
|
92
|
-
/* @__PURE__ */
|
|
102
|
+
/* @__PURE__ */ _("button", {
|
|
93
103
|
type: "button",
|
|
94
104
|
role: "menuitem",
|
|
95
|
-
onClick: () =>
|
|
105
|
+
onClick: () => I("markdown"),
|
|
96
106
|
className: "flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated",
|
|
97
107
|
"data-testid": "export-markdown",
|
|
98
|
-
children: [/* @__PURE__ */
|
|
108
|
+
children: [/* @__PURE__ */ g(d, {
|
|
99
109
|
className: "size-3.5 flex-shrink-0 text-text-secondary",
|
|
100
110
|
"aria-hidden": "true"
|
|
101
|
-
}),
|
|
111
|
+
}), v("healthybowl.assistant.export.markdown", "Export as Markdown")]
|
|
102
112
|
})
|
|
103
113
|
] }) : null
|
|
104
114
|
]
|
|
@@ -106,6 +116,6 @@ var _ = () => {
|
|
|
106
116
|
});
|
|
107
117
|
};
|
|
108
118
|
//#endregion
|
|
109
|
-
export {
|
|
119
|
+
export { v as AssistantMoreMenu };
|
|
110
120
|
|
|
111
121
|
//# sourceMappingURL=AssistantMoreMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantMoreMenu.js","names":[],"sources":["../../../src/components/assistant/AssistantMoreMenu.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type FC } from 'react';\nimport { Check, FileJson, FileText, MoreHorizontal, Volume2 } from 'lucide-react';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { exportConversation, downloadFile } from '@/services/assistantExportService';\nimport { useAssistantSpeech } from './AssistantSpeechProvider';\nimport { AssistantVoiceSelector } from './composer/AssistantVoiceSelector';\nimport { useTr } from '../../shared/hooks/useTr';\n\n/**\n * The header's secondary surface — everything that CONFIGURES the assistant.\n *\n * ★ `+` supplies content, `⋯` configures. Keeping those two meanings apart is\n * the point: the header carried seven controls, and three of them\n * (auto-read, the voice picker, export) render null under conditions the user\n * cannot see — no speech support, fewer than two voices, an empty conversation —\n * so the row silently changed width between devices and between the first and\n * second message of the same session.\n *\n * Now four primary controls, always present, and one menu that absorbs the\n * conditional ones. A menu ROW may still hide itself; a menu that keeps its\n * position while its contents vary is a much smaller surprise than a toolbar\n * that reflows.\n *\n * ★ Export is FLATTENED into this menu rather than nested inside it. It was\n * itself a dropdown, and a dropdown inside a dropdown is two Escape presses and\n * two outside-click regions for two menu items.\n *\n * ★ The voice picker keeps its native `<select>`. It is deliberate — see that\n * component — and a custom listbox would look tidier in a screenshot while being\n * worse on the phones this product is used on. Because the select lives inside\n * the menu's own subtree, the outside-click handler ignores clicks on it.\n *\n * Not included, deliberately: Live captions and Assistant settings have nothing\n * behind them yet, and a Transcript entry needs a product decision first (the\n * voice transcript is session-scoped, while the chat thread is always visible —\n * one menu label cannot honestly mean both).\n */\nexport const AssistantMoreMenu: FC = () => {\n const tr = useTr();\n const [open, setOpen] = useState(false);\n const menuRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const { conversations, activeConversationId } = useAssistantStore();\n const activeConversation = conversations.find((conversation) => conversation.id === activeConversationId);\n const canExport = Boolean(activeConversation && activeConversation.messages.length > 0);\n\n const { isSupported, isBlocked, disabledReason, autoSpeakEnabled, setAutoSpeak, stop } = useAssistantSpeech();\n // Blocked and already off means turning it on would do nothing audible.\n const autoReadDisabled = isBlocked && !autoSpeakEnabled;\n\n useEffect(() => {\n if (!open) return;\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n setOpen(false);\n buttonRef.current?.focus();\n }\n };\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (menuRef.current?.contains(target) || buttonRef.current?.contains(target)) return;\n setOpen(false);\n };\n window.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onPointerDown);\n return () => {\n window.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onPointerDown);\n };\n }, [open]);\n\n const handleExport = (format: 'json' | 'markdown') => {\n if (!activeConversation) return;\n const { content, filename, mimeType } = exportConversation(activeConversation, format);\n downloadFile(content, filename, mimeType);\n setOpen(false);\n };\n\n const toggleAutoRead = () => {\n // Turning it OFF stops whatever is speaking now: leaving audio running\n // after the user switched the feature off reads as the control not working.\n if (autoSpeakEnabled) stop();\n setAutoSpeak(!autoSpeakEnabled);\n };\n\n const label = tr('healthybowl.assistant.header.more', 'More options');\n\n return (\n <div className=\"relative\">\n <button\n ref={buttonRef}\n type=\"button\"\n onClick={() => setOpen((wasOpen) => !wasOpen)}\n className=\"rounded p-1 transition-colors hover:bg-bg-elevated\"\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n data-testid=\"assistant-more\"\n >\n <MoreHorizontal className=\"size-4 text-text-secondary\" />\n </button>\n\n {open ? (\n <div\n ref={menuRef}\n role=\"menu\"\n aria-label={label}\n className=\"absolute right-0 top-full z-50 mt-1 min-w-56 overflow-hidden rounded-xl border border-border-default bg-bg-surface py-1 shadow-lg\"\n data-testid=\"assistant-more-menu\"\n >\n {isSupported ? (\n <button\n type=\"button\"\n role=\"menuitemcheckbox\"\n aria-checked={autoSpeakEnabled}\n onClick={toggleAutoRead}\n disabled={autoReadDisabled}\n title={autoReadDisabled ? (disabledReason ?? undefined) : undefined}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated disabled:cursor-not-allowed disabled:text-text-muted disabled:hover:bg-transparent\"\n data-testid=\"assistant-auto-speak\"\n >\n <Volume2 className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"flex-1\">{tr('healthybowl.assistant.header.autoRead', 'Auto-read replies')}</span>\n {/* State as a tick rather than the word \"On\": the row is already a\n checkbox to assistive technology via aria-checked. */}\n {autoSpeakEnabled ? <Check className=\"size-3.5 flex-shrink-0 text-action-primary-bg\" /> : null}\n </button>\n ) : null}\n\n {/* Renders nothing when the device offers fewer than two voices, which\n is most of them until a hosted TTS endpoint is configured. */}\n <div className=\"px-3 py-1.5\" data-testid=\"assistant-more-voice\">\n <AssistantVoiceSelector />\n </div>\n\n {canExport ? (\n <>\n <div className=\"my-1 border-t border-border-subtle\" role=\"separator\" />\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => handleExport('json')}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated\"\n data-testid=\"export-json\"\n >\n <FileJson className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n {tr('healthybowl.assistant.export.json', 'Export as JSON')}\n </button>\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => handleExport('markdown')}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated\"\n data-testid=\"export-markdown\"\n >\n <FileText className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n {tr('healthybowl.assistant.export.markdown', 'Export as Markdown')}\n </button>\n </>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AAqCA,IAAa,UAA8B;CACzC,IAAM,IAAK,EAAM,GACX,CAAC,GAAM,KAAW,EAAS,EAAK,GAChC,IAAU,EAAuB,IAAI,GACrC,IAAY,EAA0B,IAAI,GAE1C,EAAE,kBAAe,4BAAyB,EAAkB,GAC5D,IAAqB,EAAc,MAAM,MAAiB,EAAa,OAAO,CAAoB,GAClG,IAAY,GAAQ,KAAsB,EAAmB,SAAS,SAAS,IAE/E,EAAE,gBAAa,cAAW,mBAAgB,qBAAkB,iBAAc,YAAS,EAAmB,GAEtG,IAAmB,KAAa,CAAC;CAEvC,QAAgB;EACd,IAAI,CAAC,GAAM;EACX,IAAM,KAAa,MAAyB;GAC1C,AAAI,EAAM,QAAQ,aAChB,EAAQ,EAAK,GACb,EAAU,SAAS,MAAM;EAE7B,GACM,KAAiB,MAAsB;GAC3C,IAAM,IAAS,EAAM;GACjB,EAAQ,SAAS,SAAS,CAAM,KAAK,EAAU,SAAS,SAAS,CAAM,KAC3E,EAAQ,EAAK;EACf;EAGA,OAFA,OAAO,iBAAiB,WAAW,CAAS,GAC5C,SAAS,iBAAiB,aAAa,CAAa,SACvC;GAEX,AADA,OAAO,oBAAoB,WAAW,CAAS,GAC/C,SAAS,oBAAoB,aAAa,CAAa;EACzD;CACF,GAAG,CAAC,CAAI,CAAC;CAET,IAAM,KAAgB,MAAgC;EACpD,IAAI,CAAC,GAAoB;EACzB,IAAM,EAAE,YAAS,aAAU,gBAAa,EAAmB,GAAoB,CAAM;EAErF,AADA,EAAa,GAAS,GAAU,CAAQ,GACxC,EAAQ,EAAK;CACf,GAEM,UAAuB;EAI3B,AADI,KA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;OAAU,WAAU;OAA6C,eAAY;MAAQ,CAAA,GACpF,EAAG,yCAAyC,oBAAoB,CAC3D;;IACR,EAAA,CAAA,IACA;GACD;OACH,IACD;;AAET"}
|
|
1
|
+
{"version":3,"file":"AssistantMoreMenu.js","names":[],"sources":["../../../src/components/assistant/AssistantMoreMenu.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type FC } from 'react';\nimport { Check, FileJson, FileText, MoreHorizontal, Play, Volume2 } from 'lucide-react';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { exportConversation, downloadFile } from '@/services/assistantExportService';\nimport { useAssistantSpeech } from './AssistantSpeechProvider';\nimport { AssistantVoiceSelector } from './composer/AssistantVoiceSelector';\nimport { useTr } from '../../shared/hooks/useTr';\n\n/**\n * The header's secondary surface — everything that CONFIGURES the assistant.\n *\n * ★ `+` supplies content, `⋯` configures. Keeping those two meanings apart is\n * the point: the header carried seven controls, and three of them\n * (auto-read, the voice picker, export) render null under conditions the user\n * cannot see — no speech support, fewer than two voices, an empty conversation —\n * so the row silently changed width between devices and between the first and\n * second message of the same session.\n *\n * Now four primary controls, always present, and one menu that absorbs the\n * conditional ones. A menu ROW may still hide itself; a menu that keeps its\n * position while its contents vary is a much smaller surprise than a toolbar\n * that reflows.\n *\n * ★ Export is FLATTENED into this menu rather than nested inside it. It was\n * itself a dropdown, and a dropdown inside a dropdown is two Escape presses and\n * two outside-click regions for two menu items.\n *\n * ★ The voice picker keeps its native `<select>`. It is deliberate — see that\n * component — and a custom listbox would look tidier in a screenshot while being\n * worse on the phones this product is used on. Because the select lives inside\n * the menu's own subtree, the outside-click handler ignores clicks on it.\n *\n * Not included, deliberately: Live captions and Assistant settings have nothing\n * behind them yet, and a Transcript entry needs a product decision first (the\n * voice transcript is session-scoped, while the chat thread is always visible —\n * one menu label cannot honestly mean both).\n */\nexport const AssistantMoreMenu: FC = () => {\n const tr = useTr();\n const [open, setOpen] = useState(false);\n const menuRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const { conversations, activeConversationId } = useAssistantStore();\n const activeConversation = conversations.find((conversation) => conversation.id === activeConversationId);\n const canExport = Boolean(activeConversation && activeConversation.messages.length > 0);\n\n const {\n isSupported,\n isBlocked,\n disabledReason,\n autoSpeakEnabled,\n setAutoSpeak,\n stop,\n previewVoice,\n activeVoiceName,\n } = useAssistantSpeech();\n // Blocked and already off means turning it on would do nothing audible.\n const autoReadDisabled = isBlocked && !autoSpeakEnabled;\n\n useEffect(() => {\n if (!open) return;\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n setOpen(false);\n buttonRef.current?.focus();\n }\n };\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (menuRef.current?.contains(target) || buttonRef.current?.contains(target)) return;\n setOpen(false);\n };\n window.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onPointerDown);\n return () => {\n window.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onPointerDown);\n };\n }, [open]);\n\n const handleExport = (format: 'json' | 'markdown') => {\n if (!activeConversation) return;\n const { content, filename, mimeType } = exportConversation(activeConversation, format);\n downloadFile(content, filename, mimeType);\n setOpen(false);\n };\n\n const toggleAutoRead = () => {\n // Turning it OFF stops whatever is speaking now: leaving audio running\n // after the user switched the feature off reads as the control not working.\n if (autoSpeakEnabled) stop();\n setAutoSpeak(!autoSpeakEnabled);\n };\n\n const label = tr('healthybowl.assistant.header.more', 'More options');\n\n return (\n <div className=\"relative\">\n <button\n ref={buttonRef}\n type=\"button\"\n onClick={() => setOpen((wasOpen) => !wasOpen)}\n className=\"rounded p-1 transition-colors hover:bg-bg-elevated\"\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n data-testid=\"assistant-more\"\n >\n <MoreHorizontal className=\"size-4 text-text-secondary\" />\n </button>\n\n {open ? (\n <div\n ref={menuRef}\n role=\"menu\"\n aria-label={label}\n className=\"absolute right-0 top-full z-50 mt-1 min-w-56 overflow-hidden rounded-xl border border-border-default bg-bg-surface py-1 shadow-lg\"\n data-testid=\"assistant-more-menu\"\n >\n {isSupported ? (\n <button\n type=\"button\"\n role=\"menuitemcheckbox\"\n aria-checked={autoSpeakEnabled}\n onClick={toggleAutoRead}\n disabled={autoReadDisabled}\n title={autoReadDisabled ? (disabledReason ?? undefined) : undefined}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated disabled:cursor-not-allowed disabled:text-text-muted disabled:hover:bg-transparent\"\n data-testid=\"assistant-auto-speak\"\n >\n <Volume2 className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"flex-1\">{tr('healthybowl.assistant.header.autoRead', 'Auto-read replies')}</span>\n {/* State as a tick rather than the word \"On\": the row is already a\n checkbox to assistive technology via aria-checked. */}\n {autoSpeakEnabled ? <Check className=\"size-3.5 flex-shrink-0 text-action-primary-bg\" /> : null}\n </button>\n ) : null}\n\n {/* Renders nothing when the device offers fewer than two voices, which\n is most of them until a hosted TTS endpoint is configured. */}\n <div className=\"flex items-center gap-1 px-3 py-1.5\" data-testid=\"assistant-more-voice\">\n <AssistantVoiceSelector />\n {/* ★ Auditioning a voice used to cost a round trip: you picked one,\n nothing happened, and you first heard it after asking a real\n question. This speaks a short sample straight through the engine —\n no model call, no message in the thread, no tokens. Shown only\n once a voice has resolved, so it can never be a dead control. */}\n {activeVoiceName ? (\n <button\n type=\"button\"\n onClick={() => previewVoice(activeVoiceName)}\n className=\"flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-text-muted transition-colors hover:bg-bg-elevated hover:text-text-secondary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong\"\n aria-label={tr('healthybowl.assistant.voice.preview', 'Hear this voice')}\n data-testid=\"assistant-voice-preview\"\n >\n <Play className=\"size-3\" aria-hidden=\"true\" />\n {tr('healthybowl.assistant.voice.previewShort', 'Preview')}\n </button>\n ) : null}\n </div>\n\n {canExport ? (\n <>\n <div className=\"my-1 border-t border-border-subtle\" role=\"separator\" />\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => handleExport('json')}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated\"\n data-testid=\"export-json\"\n >\n <FileJson className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n {tr('healthybowl.assistant.export.json', 'Export as JSON')}\n </button>\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => handleExport('markdown')}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated\"\n data-testid=\"export-markdown\"\n >\n <FileText className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n {tr('healthybowl.assistant.export.markdown', 'Export as Markdown')}\n </button>\n </>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AAqCA,IAAa,UAA8B;CACzC,IAAM,IAAK,EAAM,GACX,CAAC,GAAM,KAAW,EAAS,EAAK,GAChC,IAAU,EAAuB,IAAI,GACrC,IAAY,EAA0B,IAAI,GAE1C,EAAE,kBAAe,4BAAyB,EAAkB,GAC5D,IAAqB,EAAc,MAAM,MAAiB,EAAa,OAAO,CAAoB,GAClG,IAAY,GAAQ,KAAsB,EAAmB,SAAS,SAAS,IAE/E,EACJ,gBACA,cACA,mBACA,qBACA,iBACA,SACA,iBACA,uBACE,EAAmB,GAEjB,IAAmB,KAAa,CAAC;CAEvC,QAAgB;EACd,IAAI,CAAC,GAAM;EACX,IAAM,KAAa,MAAyB;GAC1C,AAAI,EAAM,QAAQ,aAChB,EAAQ,EAAK,GACb,EAAU,SAAS,MAAM;EAE7B,GACM,KAAiB,MAAsB;GAC3C,IAAM,IAAS,EAAM;GACjB,EAAQ,SAAS,SAAS,CAAM,KAAK,EAAU,SAAS,SAAS,CAAM,KAC3E,EAAQ,EAAK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