@burdenoff/microfe-healthybowl 2026.829.3 → 2026.829.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/components/assistant/AssistantHeader.js +40 -38
  2. package/dist/components/assistant/AssistantHeader.js.map +1 -1
  3. package/dist/components/assistant/AssistantSpeechProvider.js +165 -139
  4. package/dist/components/assistant/AssistantSpeechProvider.js.map +1 -1
  5. package/dist/components/assistant/composer/AssistantLanguageSelector.js +1 -1
  6. package/dist/components/assistant/composer/AssistantLanguageSelector.js.map +1 -1
  7. package/dist/components/assistant/composer/AssistantVoiceSelector.js +39 -0
  8. package/dist/components/assistant/composer/AssistantVoiceSelector.js.map +1 -0
  9. package/dist/config/assistantLanguages.js +29 -18
  10. package/dist/config/assistantLanguages.js.map +1 -1
  11. package/dist/services/speech/createSpeechEngine.js +32 -0
  12. package/dist/services/speech/createSpeechEngine.js.map +1 -0
  13. package/dist/services/speech/hostedTtsProtocol.js +41 -0
  14. package/dist/services/speech/hostedTtsProtocol.js.map +1 -0
  15. package/dist/services/speech/hostedTtsSpeechEngine.js +119 -0
  16. package/dist/services/speech/hostedTtsSpeechEngine.js.map +1 -0
  17. package/dist/services/speech/hostedVoiceCatalogue.js +52 -0
  18. package/dist/services/speech/hostedVoiceCatalogue.js.map +1 -0
  19. package/dist/services/speech/index.js +5 -0
  20. package/dist/services/speech/routingSpeechEngine.js +28 -0
  21. package/dist/services/speech/routingSpeechEngine.js.map +1 -0
  22. package/dist/store/assistantStore.js +10 -3
  23. package/dist/store/assistantStore.js.map +1 -1
  24. package/dist/utils/speakableText.js +7 -5
  25. package/dist/utils/speakableText.js.map +1 -1
  26. package/dist/utils/speechVoices.js +25 -12
  27. package/dist/utils/speechVoices.js.map +1 -1
  28. 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 { History as r, PanelBottom as i, PanelRight as a, Plus as o, Sparkles as s, X as c } from "lucide-react";
5
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
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 d = ({ contextLabel: d, onNewConversation: f, onOpenHistory: p, historyOpen: m, onClose: h, docked: g, onToggleDock: _ }) => {
8
- let v = e();
9
- return /* @__PURE__ */ u("div", {
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__ */ u("div", {
12
+ children: [/* @__PURE__ */ d("div", {
12
13
  className: "flex min-w-0 flex-1 items-center gap-2",
13
- children: [/* @__PURE__ */ l("span", {
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__ */ l(s, { className: "size-4" })
16
- }), /* @__PURE__ */ u("span", {
16
+ children: /* @__PURE__ */ u(c, { className: "size-4" })
17
+ }), /* @__PURE__ */ d("span", {
17
18
  className: "min-w-0 flex-1",
18
- children: [/* @__PURE__ */ l("span", {
19
+ children: [/* @__PURE__ */ u("span", {
19
20
  className: "block truncate text-[14px] font-semibold leading-tight text-text-primary",
20
- children: v("healthybowl.assistant.header.title", "HealthyBowl AI")
21
- }), /* @__PURE__ */ u("span", {
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
- v("healthybowl.assistant.header.ready", "Ready"),
25
- /* @__PURE__ */ l("span", {
25
+ y("healthybowl.assistant.header.ready", "Ready"),
26
+ /* @__PURE__ */ u("span", {
26
27
  "aria-hidden": "true",
27
28
  children: " · "
28
29
  }),
29
- v("healthybowl.assistant.header.context", "Context: {{page}}", { page: d })
30
+ y("healthybowl.assistant.header.context", "Context: {{page}}", { page: f })
30
31
  ]
31
32
  })]
32
33
  })]
33
- }), /* @__PURE__ */ u("div", {
34
+ }), /* @__PURE__ */ d("div", {
34
35
  className: "flex flex-shrink-0 items-center gap-0.5",
35
36
  children: [
36
- /* @__PURE__ */ l("button", {
37
+ /* @__PURE__ */ u("button", {
37
38
  type: "button",
38
- onClick: f,
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": v("healthybowl.assistant.header.newConversation", "New conversation"),
41
+ "aria-label": y("healthybowl.assistant.header.newConversation", "New conversation"),
41
42
  "data-testid": "assistant-new-conversation",
42
- children: /* @__PURE__ */ l(o, { className: "size-4" })
43
+ children: /* @__PURE__ */ u(s, { className: "size-4" })
43
44
  }),
44
- /* @__PURE__ */ l("button", {
45
+ /* @__PURE__ */ u("button", {
45
46
  type: "button",
46
- onClick: p,
47
- className: `rounded-lg p-1.5 transition-colors ${m ? "bg-action-primary-bg/15 text-action-primary-bg" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
48
- "aria-label": v("healthybowl.assistant.header.history", "Conversation history"),
49
- "aria-pressed": m,
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__ */ l(r, { className: "size-4" })
52
+ children: /* @__PURE__ */ u(i, { className: "size-4" })
52
53
  }),
53
- /* @__PURE__ */ l(n, {}),
54
- /* @__PURE__ */ l(t, {}),
55
- _ && /* @__PURE__ */ l("button", {
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": g ? v("healthybowl.assistant.header.float", "Float chat window") : v("healthybowl.assistant.header.dock", "Dock to side panel"),
60
- "aria-pressed": g,
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: l(g ? i : a, { className: "size-4" })
64
+ children: u(_ ? a : o, { className: "size-4" })
63
65
  }),
64
- /* @__PURE__ */ l("button", {
66
+ /* @__PURE__ */ u("button", {
65
67
  type: "button",
66
- onClick: h,
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": v("healthybowl.assistant.header.close", "Close assistant"),
70
+ "aria-label": y("healthybowl.assistant.header.close", "Close assistant"),
69
71
  "data-testid": "assistant-close",
70
- children: /* @__PURE__ */ l(c, { className: "size-4" })
72
+ children: /* @__PURE__ */ u(l, { className: "size-4" })
71
73
  })
72
74
  ]
73
75
  })]
74
76
  });
75
77
  };
76
78
  //#endregion
77
- export { d as AssistantHeader };
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":";;;;;;AA4BA,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;IAC3B,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"}
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"}
@@ -1,30 +1,37 @@
1
1
  import { useAssistantStore as e } from "../../store/assistantStore.js";
2
2
  import { useTr as t } from "../../shared/hooks/useTr.js";
3
- import { browserSpeechEngine as n } from "../../services/speech/browserSpeechEngine.js";
3
+ import { getSpeechEngine as n } from "../../services/speech/createSpeechEngine.js";
4
+ import "../../services/speech/index.js";
4
5
  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 c, speechLangForLocale as l, voiceAvailability as u } from "../../utils/speechVoices.js";
6
+ 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
7
  import { resolveSpeechLocale as d } from "../../utils/replyLanguage.js";
7
- import { findAssistantLanguage as f, resolveAssistantLanguage as p } from "../../config/assistantLanguages.js";
8
- import { IDLE_PLAYBACK as ee, isSpeakingMessage as m, speechPlaybackReducer as te } from "../../utils/speechPlayback.js";
9
- import { isTurnInFlight as ne } from "../../utils/assistantTurnState.js";
10
- import { parseToolActivity as re } from "./AssistantToolActivity.js";
11
- import { createContext as h, useCallback as g, useContext as _, useEffect as v, useMemo as y, useReducer as ie, useRef as b, useState as x } from "react";
12
- import { useI18n as ae } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
13
- import { jsx as oe } from "react/jsx-runtime";
8
+ import { findAssistantLanguage as f, resolveAssistantLanguage as te } from "../../config/assistantLanguages.js";
9
+ import { IDLE_PLAYBACK as ne, isSpeakingMessage as p, speechPlaybackReducer as re } from "../../utils/speechPlayback.js";
10
+ import { isTurnInFlight as ie } from "../../utils/assistantTurnState.js";
11
+ import { parseToolActivity as ae } from "./AssistantToolActivity.js";
12
+ 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";
13
+ import { useI18n as se } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
14
+ import { jsx as ce } from "react/jsx-runtime";
14
15
  //#region src/components/assistant/AssistantSpeechProvider.tsx
15
- var se = {
16
+ var le = {
16
17
  codeBlock: "",
17
18
  image: "",
18
19
  link: "",
19
20
  largeTable: "",
20
21
  truncated: "",
22
+ emailAt: "at",
23
+ emailDot: "dot",
21
24
  nestedItem: ""
22
- }, S = h({
25
+ }, x = m({
23
26
  isSupported: !1,
24
27
  availability: "unsupported",
25
28
  isBlocked: !0,
26
29
  disabledReason: null,
27
30
  blockedFor: () => null,
31
+ voiceChoices: [],
32
+ activeVoiceName: null,
33
+ preferredVoiceName: null,
34
+ setVoice: () => {},
28
35
  speakingMessageId: null,
29
36
  isSpeaking: () => !1,
30
37
  toggle: () => {},
@@ -32,196 +39,215 @@ var se = {
32
39
  autoSpeakEnabled: !1,
33
40
  setAutoSpeak: () => {}
34
41
  });
35
- function C() {
36
- return _(S);
42
+ function S() {
43
+ return g(x);
37
44
  }
38
- var w = ({ children: h, visible: _ = !0, engine: C = n }) => {
39
- let w = t(), { locale: T } = ae(), [E, D] = ie(te, ee), [O, k] = x(() => C.listVoices()), [A, j] = x(!1), [M, N] = x(() => /* @__PURE__ */ new Map()), P = b(0), F = b(null), I = b(() => {}), L = g(() => {
40
- F.current?.(), F.current = null;
41
- }, []), R = e((e) => e.autoSpeakEnabled), z = e((e) => e.setAutoSpeak), ce = e((e) => e.activeConversationId), B = y(() => C.isSupported(), [C]);
42
- v(() => {
43
- if (!B) return;
45
+ var C = ({ children: m, visible: g = !0, engine: S = n() }) => {
46
+ 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(() => {
47
+ P.current?.(), P.current = null;
48
+ }, []), L = e((e) => e.autoSpeakEnabled), R = e((e) => e.setAutoSpeak), ue = e((e) => e.activeConversationId), z = v(() => S.isSupported(), [S]);
49
+ _(() => {
50
+ if (!z) return;
44
51
  let e = () => {
45
- k(C.listVoices()), N((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
52
+ O(S.listVoices()), M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
46
53
  };
47
- return e(), C.subscribeVoices(e);
48
- }, [C, B]);
49
- let V = e((e) => e.assistantLanguage), H = y(() => p(V, T), [V, T]), U = H.code, W = g((e) => f(e)?.tag ?? l(e), []), G = y(() => u(B, O, H.tag, A), [
50
- B,
51
- O,
52
- H,
53
- A
54
- ]), K = y(() => ({
55
- codeBlock: w("healthybowl.assistant.speech.codeBlock", "Code block"),
56
- image: w("healthybowl.assistant.speech.image", "image"),
57
- link: w("healthybowl.assistant.speech.link", "link"),
58
- largeTable: w("healthybowl.assistant.speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
59
- truncated: w("healthybowl.assistant.speech.truncated", "The rest of this message is not read aloud"),
60
- nestedItem: w("healthybowl.assistant.speech.nestedItem", "Sub-item {{ordinal}}")
61
- }), [w]), q = g(() => {
62
- L(), C.cancel(), D({ type: "stop" });
63
- }, [L, C]), J = g((e) => M.get(e) ?? null, [M]), Y = g((e, t, n) => {
64
- L();
54
+ return e(), S.subscribeVoices(e);
55
+ }, [S, z]);
56
+ 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), [
57
+ z,
58
+ D,
59
+ U,
60
+ k
61
+ ]), J = v(() => ({
62
+ codeBlock: C("healthybowl.assistant.speech.codeBlock", "Code block"),
63
+ image: C("healthybowl.assistant.speech.image", "image"),
64
+ link: C("healthybowl.assistant.speech.link", "link"),
65
+ largeTable: C("healthybowl.assistant.speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
66
+ truncated: C("healthybowl.assistant.speech.truncated", "The rest of this message is not read aloud"),
67
+ nestedItem: C("healthybowl.assistant.speech.nestedItem", "Sub-item {{ordinal}}"),
68
+ emailAt: C("healthybowl.assistant.speech.emailAt", "at"),
69
+ emailDot: C("healthybowl.assistant.speech.emailDot", "dot")
70
+ }), [C]), Y = h(() => {
71
+ I(), S.cancel(), E({ type: "stop" });
72
+ }, [I, S]), X = h((e) => j.get(e) ?? null, [j]), Z = h((e, t, n) => {
73
+ I();
65
74
  let r = !1, i = () => {}, o = (a) => {
66
75
  if (!r) {
67
- if (r = !0, F.current = null, clearTimeout(s), i(), a.length === 0) {
68
- j(!0);
76
+ if (r = !0, P.current = null, clearTimeout(s), i(), a.length === 0) {
77
+ A(!0);
69
78
  return;
70
79
  }
71
- k(a), I.current(e, t, a, n);
80
+ O(a), F.current(e, t, a, n);
72
81
  }
73
- }, s = setTimeout(() => o(C.listVoices()), a);
74
- i = C.subscribeVoices(() => o(C.listVoices())), F.current = () => {
75
- r || (r = !0, clearTimeout(s), i(), F.current = null);
82
+ }, s = setTimeout(() => o(S.listVoices()), a);
83
+ i = S.subscribeVoices(() => o(S.listVoices())), P.current = () => {
84
+ r || (r = !0, clearTimeout(s), i(), P.current = null);
76
85
  };
77
- }, [L, C]), X = g((e, t, n, i) => {
86
+ }, [I, S]), Q = h((e, t, n, i) => {
78
87
  let a = n;
79
88
  if (a.length === 0) {
80
- let e = C.listVoices();
81
- e.length > 0 && (a = e, k(e));
89
+ let e = S.listVoices();
90
+ e.length > 0 && (a = e, O(e));
82
91
  }
83
- let l = W(i), d = c(u(!0, a, i, A));
84
- if (d === "block") {
85
- let t = w("healthybowl.assistant.speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: o(l, T) });
86
- N((n) => new Map(n).set(e, t));
92
+ let c = G(i), u = ee(l(!0, a, i, k));
93
+ if (u === "block") {
94
+ 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) });
95
+ M((n) => new Map(n).set(e, t));
87
96
  return;
88
97
  }
89
- if (d === "wait-for-voices") {
90
- Y(e, t, i);
98
+ if (u === "wait-for-voices") {
99
+ Z(e, t, i);
91
100
  return;
92
101
  }
93
- N((t) => {
102
+ M((t) => {
94
103
  if (!t.has(e)) return t;
95
104
  let n = new Map(t);
96
105
  return n.delete(e), n;
97
106
  });
98
- let f = P.current + 1;
99
- P.current = f, D({
107
+ let d = N.current + 1;
108
+ N.current = d, E({
100
109
  type: "start",
101
110
  messageId: e,
102
- requestId: f
103
- }), C.speak(r(t), {
104
- voice: s(a, l),
105
- lang: l
111
+ requestId: d
112
+ }), S.speak(r(t), {
113
+ voice: s(a, c, V[i]),
114
+ lang: c,
115
+ rate: K(i)
106
116
  }, {
107
- onEnd: () => D({
117
+ onEnd: () => E({
108
118
  type: "finished",
109
- requestId: f
119
+ requestId: d
110
120
  }),
111
- onError: () => D({
121
+ onError: () => E({
112
122
  type: "failed",
113
- requestId: f
123
+ requestId: d
114
124
  })
115
125
  });
116
126
  }, [
117
- C,
118
- T,
119
- W,
127
+ S,
120
128
  w,
121
- A,
122
- Y
129
+ V,
130
+ K,
131
+ G,
132
+ C,
133
+ k,
134
+ Z
123
135
  ]);
124
- v(() => {
125
- I.current = X;
126
- }, [X]);
127
- let Z = g((e, t, n) => {
128
- if (!B) return;
129
- let r = i(t, { labels: K });
130
- r && X(e, r, O, d(i(t, { labels: se }), n ?? U));
136
+ _(() => {
137
+ F.current = Q;
138
+ }, [Q]);
139
+ let $ = h((e, t, n) => {
140
+ if (!z) return;
141
+ let r = i(t, { labels: J });
142
+ r && Q(e, r, D, d(i(t, { labels: le }), n ?? W));
131
143
  }, [
132
- B,
133
- K,
134
- U,
135
- X,
136
- O
137
- ]), Q = g((e, t, n) => {
138
- if (m(E, e)) {
139
- q();
144
+ z,
145
+ J,
146
+ W,
147
+ Q,
148
+ D
149
+ ]), de = h((e, t, n) => {
150
+ if (p(T, e)) {
151
+ Y();
140
152
  return;
141
153
  }
142
- Z(e, t, n);
154
+ $(e, t, n);
143
155
  }, [
144
- E,
145
- Z,
146
- q
156
+ T,
157
+ $,
158
+ Y
147
159
  ]);
148
- v(() => {
149
- _ || q();
150
- }, [_, q]), v(() => {
151
- q(), N(/* @__PURE__ */ new Map());
152
- }, [ce, q]), v(() => {
153
- N((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), q();
154
- }, [U, q]), v(() => () => {
155
- F.current?.(), F.current = null, C.cancel();
156
- }, [C]), v(() => {
160
+ _(() => {
161
+ g || Y();
162
+ }, [g, Y]), _(() => {
163
+ Y(), M(/* @__PURE__ */ new Map());
164
+ }, [ue, Y]), _(() => {
165
+ M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), Y();
166
+ }, [W, Y]), _(() => () => {
167
+ P.current?.(), P.current = null, S.cancel();
168
+ }, [S]), _(() => {
157
169
  if (typeof window > "u") return;
158
- let e = () => C.cancel();
170
+ let e = () => S.cancel();
159
171
  return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
160
- }, [C]), v(() => {
161
- if (typeof document > "u" || !B) return;
172
+ }, [S]), _(() => {
173
+ if (typeof document > "u" || !z) return;
162
174
  let e = () => {
163
175
  if (document.visibilityState !== "visible") return;
164
- let e = C.listVoices();
165
- e.length > 0 && L(), k(e), j(!1), N((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
176
+ let e = S.listVoices();
177
+ e.length > 0 && I(), O(e), A(!1), M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
166
178
  };
167
179
  return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
168
180
  document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
169
181
  };
170
182
  }, [
171
- L,
172
- C,
173
- B
183
+ I,
184
+ S,
185
+ z
174
186
  ]);
175
- let $ = b(Z);
176
- v(() => {
177
- $.current = Z;
178
- }, [Z]), v(() => {
179
- if (!(!R || !_ || !B)) return e.subscribe((e, t) => {
187
+ let fe = y($);
188
+ _(() => {
189
+ fe.current = $;
190
+ }, [$]), _(() => {
191
+ if (!(!L || !g || !z)) return e.subscribe((e, t) => {
180
192
  let n = e.activeConversationId;
181
193
  if (!n || n !== t.activeConversationId) return;
182
194
  let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
183
- if (r?.status !== "complete" || !ne(i?.status)) return;
195
+ if (r?.status !== "complete" || !ie(i?.status)) return;
184
196
  let a = r.messageId ?? i?.messageId ?? null;
185
197
  if (!a) return;
186
198
  let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
187
199
  if (!o || o.role !== "assistant") return;
188
- let { text: s } = re(o.content);
189
- s.trim() && $.current(a, s, o.metadata?.lang);
200
+ let { text: s } = ae(o.content);
201
+ s.trim() && fe.current(a, s, o.metadata?.lang);
190
202
  });
191
203
  }, [
192
- R,
193
- B,
194
- _
204
+ L,
205
+ z,
206
+ g
195
207
  ]);
196
- let le = y(() => ({
197
- isSupported: B,
198
- availability: G,
199
- isBlocked: G === "no-voices",
200
- disabledReason: G === "no-voices" ? w("healthybowl.assistant.speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
201
- blockedFor: J,
202
- speakingMessageId: E.status === "speaking" ? E.messageId : null,
203
- isSpeaking: (e) => m(E, e),
204
- toggle: Q,
205
- stop: q,
206
- autoSpeakEnabled: R,
207
- setAutoSpeak: z
208
+ let pe = v(() => u(D, U.tag), [D, U]), me = v(() => s(D, U.tag, V[W]), [
209
+ D,
210
+ U,
211
+ V,
212
+ W
213
+ ]), he = v(() => ({
214
+ isSupported: z,
215
+ availability: q,
216
+ isBlocked: q === "no-voices",
217
+ 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,
218
+ blockedFor: X,
219
+ voiceChoices: pe,
220
+ activeVoiceName: me?.name ?? null,
221
+ preferredVoiceName: V[W] ?? null,
222
+ setVoice: (e) => H(W, e),
223
+ speakingMessageId: T.status === "speaking" ? T.messageId : null,
224
+ isSpeaking: (e) => p(T, e),
225
+ toggle: de,
226
+ stop: Y,
227
+ autoSpeakEnabled: L,
228
+ setAutoSpeak: R
208
229
  }), [
209
- B,
210
- G,
211
- J,
212
- E,
213
- Q,
230
+ z,
214
231
  q,
232
+ X,
233
+ pe,
234
+ me,
235
+ V,
236
+ H,
237
+ W,
238
+ T,
239
+ de,
240
+ Y,
241
+ L,
215
242
  R,
216
- z,
217
- w
243
+ C
218
244
  ]);
219
- return /* @__PURE__ */ oe(S.Provider, {
220
- value: le,
221
- children: h
245
+ return /* @__PURE__ */ ce(x.Provider, {
246
+ value: he,
247
+ children: m
222
248
  });
223
249
  };
224
250
  //#endregion
225
- export { w as AssistantSpeechProvider, C as useAssistantSpeech };
251
+ export { C as AssistantSpeechProvider, S as useAssistantSpeech };
226
252
 
227
253
  //# sourceMappingURL=AssistantSpeechProvider.js.map