@burdenoff/microfe-healthybowl 2026.902.7 → 2026.902.9
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/composer/AssistantComposer.js +4 -3
- package/dist/components/assistant/composer/AssistantComposer.js.map +1 -1
- package/dist/components/assistant/composer/AssistantVoiceButton.js +10 -9
- package/dist/components/assistant/composer/AssistantVoiceButton.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/hooks/useVoiceInput.js +14 -10
- package/dist/hooks/useVoiceInput.js.map +1 -1
- 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
|
@@ -28,7 +28,7 @@ var _ = 200, v = ({ onSend: v, disabled: y = !1, placeholder: b, mode: oe, avail
|
|
|
28
28
|
e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, _)}px`);
|
|
29
29
|
}, [E]);
|
|
30
30
|
let Z = s(() => {
|
|
31
|
-
X && (G.
|
|
31
|
+
X && (G.isActive && G.stop(), v(E.trim(), J), D(""), R());
|
|
32
32
|
}, [
|
|
33
33
|
X,
|
|
34
34
|
v,
|
|
@@ -108,14 +108,15 @@ var _ = 200, v = ({ onSend: v, disabled: y = !1, placeholder: b, mode: oe, avail
|
|
|
108
108
|
current: W,
|
|
109
109
|
selected: H,
|
|
110
110
|
onChange: U,
|
|
111
|
-
disabled: y || G.
|
|
111
|
+
disabled: y || G.isActive
|
|
112
112
|
}),
|
|
113
113
|
G.isSupported && /* @__PURE__ */ h(ne, {
|
|
114
114
|
isListening: G.isListening,
|
|
115
|
+
isStarting: G.isStarting,
|
|
115
116
|
onToggle: G.toggle,
|
|
116
117
|
disabled: y
|
|
117
118
|
}),
|
|
118
|
-
S && q.length === 0 && j.length === 0 && !G.
|
|
119
|
+
S && q.length === 0 && j.length === 0 && !G.isActive ? /* @__PURE__ */ h(ie, {
|
|
119
120
|
onStart: S,
|
|
120
121
|
disabled: y
|
|
121
122
|
}) : /* @__PURE__ */ h("button", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantComposer.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantComposer.tsx"],"sourcesContent":["import {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ClipboardEvent,\n type DragEvent,\n type FC,\n type KeyboardEvent,\n} from 'react';\nimport { ArrowUp, Loader2 } from 'lucide-react';\nimport type { AssistantMode, AssistantModeConfig } from '@/types/assistant';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { languageDisplayName } from '@/utils/speechVoices';\nimport { resolveAssistantLanguage } from '@/config/assistantLanguages';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { useVoiceInput } from '@/hooks/useVoiceInput';\nimport { useAssistantAttachments } from '@/hooks/useAssistantAttachments';\nimport {\n MAX_ATTACHMENTS,\n getSendableAttachments,\n type AssistantAttachment,\n type AttachmentRejection,\n} from '@/utils/assistantAttachments';\nimport { AssistantAttachmentButton } from './AssistantAttachmentButton';\nimport { AssistantAttachmentChips } from './AssistantAttachmentChips';\nimport { AssistantVoiceButton } from './AssistantVoiceButton';\nimport { AssistantLanguageSelector } from './AssistantLanguageSelector';\nimport { AssistantVoiceSessionButton } from '../voice/AssistantVoiceSessionButton';\nimport { AssistantModeSelector } from './AssistantModeSelector';\n\ninterface Props {\n /**\n * Send the message. `attachments` are already uploaded and ready; the chat\n * area folds them into the prompt and onto the user bubble.\n */\n onSend: (message: string, attachments: AssistantAttachment[]) => void;\n /** True while a turn is in-flight (assistant busy) — disables send + shows the spinner. */\n disabled?: boolean;\n placeholder?: string;\n mode: AssistantMode;\n /** Role-filtered list of modes the user may pick. */\n availableModes: AssistantModeConfig[];\n onModeChange: (mode: AssistantMode) => void;\n /**\n * Opens the hands-free voice conversation. Omitted where a voice session\n * cannot work at all (no speech input, or nothing able to speak the reply),\n * which is what hides the control rather than offering a dead button.\n */\n onStartVoiceSession?: () => void;\n}\n\nconst MAX_TEXTAREA_HEIGHT = 200;\n\n/**\n * AssistantComposer — the v2 input surface (per the ai-assistant-v2 mockups).\n *\n * A rounded card with, on the input row: a leading circular \"+\" attach control,\n * an auto-growing textarea, a microphone, and a prominent filled forest-green\n * circular send button. BELOW the input sit the mode pills (\"Ask\" active-green /\n * \"Take action\" outline); ABOVE it, chips for any pending attachments.\n *\n * Multimodal input (Workstreams 2–3) arrives through three converging paths —\n * the attach button, drag-and-drop onto the card, and paste (a screenshot from\n * the clipboard is the single most common way a user shares one) — plus voice\n * dictation, which appends recognised speech to the draft so it can still be\n * edited before sending.\n *\n * Fully controlled (React state for the text) with auto-grow via a layout\n * effect. Enter sends, Shift+Enter inserts a newline.\n */\nexport const AssistantComposer: FC<Props> = ({\n onSend,\n disabled = false,\n placeholder,\n mode,\n availableModes,\n onModeChange,\n onStartVoiceSession,\n}) => {\n const tr = useTr();\n const { locale } = useI18n();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const [text, setText] = useState('');\n const [isDraggingOver, setIsDraggingOver] = useState(false);\n // Nested drag-enter/leave pairs fire for every child element; count them so\n // the highlight survives dragging across the textarea and buttons.\n const dragDepthRef = useRef(0);\n\n const {\n attachments,\n isBusy: attachmentsBusy,\n sendBlocker,\n rejection,\n addFiles,\n remove,\n retry,\n clear,\n clearRejection,\n canAddMore,\n } = useAssistantAttachments();\n\n const appendTranscript = useCallback((phrase: string) => {\n setText((current) => (current ? `${current.replace(/\\s+$/, '')} ${phrase}` : phrase));\n }, []);\n\n // One selection drives the recogniser, the reply language and the voice —\n // see `assistantLanguages`. `null` follows the interface language, which is\n // what this did unconditionally before.\n const assistantLanguage = useAssistantStore((state) => state.assistantLanguage);\n const setAssistantLanguage = useAssistantStore((state) => state.setAssistantLanguage);\n const spokenLanguage = useMemo(\n () => resolveAssistantLanguage(assistantLanguage, locale),\n [assistantLanguage, locale]\n );\n\n const voice = useVoiceInput({ onFinalize: appendTranscript, language: spokenLanguage.tag });\n\n const resolvedPlaceholder =\n placeholder ?? tr('healthybowl.assistant.composer.placeholder', 'Ask HealthyBowl anything…');\n const trimmed = text.trim();\n // Exactly what the model will be given — see `getSendableAttachments`.\n const sendableAttachments = getSendableAttachments(attachments);\n const failedAttachments = attachments.filter((attachment) => attachment.status === 'error');\n // A message may be attachments-only (\"what's wrong with this leaf?\" is often\n // just the photo), but never sends while an upload is in flight OR has failed:\n // `sendBlocker` covers both. Gating on the blocker rather than on\n // `attachmentsBusy` is what stops a turn going out that quietly omits a file\n // the user can still see attached — the chips are cleared by `clear()` below,\n // so the evidence would disappear at the same instant.\n const canSend = (trimmed.length > 0 || sendableAttachments.length > 0) && !disabled && sendBlocker === null;\n\n // Auto-grow the textarea to fit its content (capped), re-measured after every\n // value change so the card breathes as the user types.\n useLayoutEffect(() => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n textarea.style.height = 'auto';\n textarea.style.height = `${Math.min(textarea.scrollHeight, MAX_TEXTAREA_HEIGHT)}px`;\n }, [text]);\n\n const handleSend = useCallback(() => {\n if (!canSend) return;\n // Dictation left running into a send would keep appending to a cleared\n // draft; stop it so the mic state matches what the user sees.\n if (voice.isListening) voice.stop();\n onSend(text.trim(), sendableAttachments);\n setText('');\n clear();\n }, [canSend, onSend, text, sendableAttachments, clear, voice]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n handleSend();\n }\n },\n [handleSend]\n );\n\n const handlePaste = useCallback(\n (event: ClipboardEvent<HTMLTextAreaElement>) => {\n const files = Array.from(event.clipboardData?.files ?? []);\n if (files.length === 0) return;\n // Only claim the paste when it carried files; a normal text paste (which\n // also exposes an empty `files`) must still land in the textarea.\n event.preventDefault();\n addFiles(files);\n },\n [addFiles]\n );\n\n const handleDragEnter = useCallback((event: DragEvent<HTMLDivElement>) => {\n if (!Array.from(event.dataTransfer?.types ?? []).includes('Files')) return;\n dragDepthRef.current += 1;\n setIsDraggingOver(true);\n }, []);\n\n const handleDragLeave = useCallback(() => {\n dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);\n if (dragDepthRef.current === 0) setIsDraggingOver(false);\n }, []);\n\n const handleDragOver = useCallback((event: DragEvent<HTMLDivElement>) => {\n if (!Array.from(event.dataTransfer?.types ?? []).includes('Files')) return;\n // Required for a drop to fire at all, and stops the browser from navigating\n // away to the dropped file.\n event.preventDefault();\n }, []);\n\n const handleDrop = useCallback(\n (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n dragDepthRef.current = 0;\n setIsDraggingOver(false);\n addFiles(event.dataTransfer?.files ?? null);\n },\n [addFiles]\n );\n\n const rejectionMessage = (reason: AttachmentRejection): string => {\n switch (reason) {\n case 'too-many':\n return tr('healthybowl.assistant.attachments.tooMany', 'You can attach up to {{max}} files per message.', {\n max: MAX_ATTACHMENTS,\n });\n case 'too-large':\n return tr('healthybowl.assistant.attachments.tooLarge', 'That file is larger than 10 MB.');\n case 'empty':\n return tr('healthybowl.assistant.attachments.empty', 'That file is empty.');\n case 'unreadable':\n return tr('healthybowl.assistant.attachments.unreadable', 'That file could not be read.');\n case 'unsupported-image':\n return tr(\n 'healthybowl.assistant.attachments.unsupportedImage',\n \"This device can't read that image format, so it can't be resized to send. Save it as JPEG and try again.\"\n );\n }\n };\n\n const voiceErrorMessage = (): string | null => {\n switch (voice.error) {\n case 'not-allowed':\n return tr(\n 'healthybowl.assistant.voice.denied',\n 'Microphone access is blocked. Allow it in your browser settings to dictate.'\n );\n case 'audio-capture':\n return tr('healthybowl.assistant.voice.noMic', 'No microphone was found.');\n case 'network':\n return tr('healthybowl.assistant.voice.network', 'Speech recognition is offline right now.');\n case 'language-not-supported':\n // The recogniser's language list is the browser vendor's, not ours, so\n // name the language and point at the browser rather than implying the\n // assistant is broken.\n return tr(\n 'healthybowl.assistant.voice.languageNotSupported',\n 'This browser cannot recognise spoken {{language}}. Try a different browser, or type instead.',\n { language: languageDisplayName(voice.language, locale) }\n );\n case 'unknown':\n return tr('healthybowl.assistant.voice.failed', 'Dictation stopped unexpectedly.');\n default:\n return null;\n }\n };\n\n const voiceError = voiceErrorMessage();\n\n return (\n <div className=\"flex-shrink-0 px-3 pb-3 pt-1.5\">\n <div\n onDragEnter={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n className={`rounded-2xl border p-2 shadow-sm transition-colors focus-within:border-action-primary-bg focus-within:ring-2 focus-within:ring-action-primary-bg/15 ${\n isDraggingOver\n ? 'border-action-primary-bg border-dashed bg-action-primary-bg/5'\n : 'border-border-default bg-bg-sunken'\n }`}\n data-testid=\"assistant-composer\"\n >\n <AssistantAttachmentChips attachments={attachments} onRemove={remove} onRetry={retry} disabled={disabled} />\n\n {/* Input row: attach · textarea · mic · send */}\n <div className=\"flex items-end gap-2\">\n <AssistantAttachmentButton onFiles={addFiles} canAddMore={canAddMore} disabled={disabled} />\n\n <textarea\n ref={textareaRef}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n disabled={disabled}\n placeholder={\n isDraggingOver\n ? tr('healthybowl.assistant.composer.dropHere', 'Drop files to attach')\n : resolvedPlaceholder\n }\n rows={1}\n className=\"min-h-[36px] flex-1 resize-none self-center bg-transparent px-1 py-2 text-[15px] leading-relaxed text-text-primary placeholder:text-text-muted focus:outline-none disabled:opacity-50\"\n aria-label={tr('healthybowl.assistant.chatInput.ariaLabel', 'Message input')}\n data-testid=\"assistant-input\"\n />\n\n {/* Outside the dictation guard on purpose: this preference also\n decides what language the assistant REPLIES in, which works\n perfectly well on a browser with no speech recognition at all.\n Hiding it there left Firefox users unable to choose a reply\n language, which is most of what it is for. */}\n <AssistantLanguageSelector\n current={spokenLanguage}\n selected={assistantLanguage}\n onChange={setAssistantLanguage}\n disabled={disabled || voice.isListening}\n />\n\n {voice.isSupported && (\n <AssistantVoiceButton isListening={voice.isListening} onToggle={voice.toggle} disabled={disabled} />\n )}\n\n {/* The voice button takes the send slot while there is nothing to\n send — see AssistantVoiceSessionButton for why swapping rather\n than adding is the only option that fits. */}\n {/* Genuinely empty, NOT merely unsendable: `canSend` is also false\n while an attachment uploads or a turn is in flight, so keying off\n it would replace send even with a draft typed and ready. */}\n {onStartVoiceSession && trimmed.length === 0 && attachments.length === 0 && !voice.isListening ? (\n <AssistantVoiceSessionButton onStart={onStartVoiceSession} disabled={disabled} />\n ) : (\n <button\n type=\"button\"\n onClick={handleSend}\n disabled={!canSend}\n className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong ${\n canSend\n ? 'bg-action-primary-bg text-action-primary-text hover:scale-105 hover:bg-action-primary-bg-hover'\n : 'bg-bg-elevated text-text-muted'\n }`}\n aria-label={tr('healthybowl.assistant.chatInput.send', 'Send message')}\n data-testid=\"assistant-send\"\n >\n {disabled || attachmentsBusy ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <ArrowUp className=\"size-4\" />\n )}\n </button>\n )}\n </div>\n\n {/* Mode pills */}\n {availableModes.length > 1 && (\n <div className=\"mt-2 px-0.5\">\n <AssistantModeSelector\n mode={mode}\n availableModes={availableModes}\n onModeChange={onModeChange}\n disabled={disabled}\n />\n </div>\n )}\n </div>\n\n {/* One status line under the card: live dictation > voice error >\n attachment rejection > failed upload > the keyboard hint. Announced\n politely so a screen-reader user hears dictation land without losing\n their place.\n\n The failed-upload line ranks below `rejection` (which is transient and\n describes the file the user just picked) but above the hint, because a\n disabled send button with no stated reason is the thing this whole\n change exists to avoid. */}\n <div className=\"mt-1.5 px-1 text-center text-[11px]\" aria-live=\"polite\">\n {/* ★ Three states, not two. `isListening` now waits for the recogniser's\n own `onstart`, which is the honest signal — but it left this line\n showing the idle hint after the user had already tapped the\n microphone, for the whole permission-prompt window. */}\n {voice.isStarting && !voice.isListening ? (\n <p className=\"text-text-muted\" data-testid=\"assistant-voice-starting\">\n {tr('healthybowl.assistant.voice.starting', 'Starting the microphone…')}\n </p>\n ) : voice.isListening ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-voice-status\">\n <span className=\"mr-1 inline-block size-1.5 rounded-full bg-status-error-text align-middle motion-safe:animate-pulse\" />\n {voice.interim ||\n tr('healthybowl.assistant.voice.listening', 'Listening… speak now, tap the square to stop')}\n </p>\n ) : voiceError ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-voice-error\">\n {voiceError}\n </p>\n ) : rejection ? (\n <button\n type=\"button\"\n onClick={clearRejection}\n className=\"text-status-error-text underline-offset-2 hover:underline\"\n data-testid=\"assistant-attachment-rejection\"\n >\n {rejectionMessage(rejection)}\n </button>\n ) : sendBlocker === 'failed' ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-attachment-blocked\">\n {failedAttachments.length === 1\n ? tr(\n 'healthybowl.assistant.attachments.blockedOne',\n \"{{name}} didn't upload. Retry or remove it before sending.\",\n { name: failedAttachments[0].filename }\n )\n : tr(\n 'healthybowl.assistant.attachments.blockedMany',\n \"{{count}} attachments didn't upload. Retry or remove them before sending.\",\n { count: failedAttachments.length }\n )}\n </p>\n ) : (\n <p className=\"text-text-muted\">\n {tr(\n 'healthybowl.assistant.composer.hint',\n 'Enter to send · Shift+Enter for newline · drag or paste files to attach'\n )}\n </p>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsDA,IAAM,IAAsB,KAmBf,KAAgC,EAC3C,WACA,cAAW,IACX,gBACA,UACA,mBACA,kBACA,6BACI;CACJ,IAAM,IAAK,EAAM,GACX,EAAE,cAAW,EAAQ,GACrB,IAAc,EAA4B,IAAI,GAC9C,CAAC,GAAM,KAAW,EAAS,EAAE,GAC7B,CAAC,GAAgB,KAAqB,EAAS,EAAK,GAGpD,IAAe,EAAO,CAAC,GAEvB,EACJ,gBACA,QAAQ,GACR,gBACA,cACA,aACA,WACA,UACA,UACA,mBACA,kBACE,EAAwB,GAEtB,IAAmB,GAAa,MAAmB;EACvD,GAAS,MAAa,IAAU,GAAG,EAAQ,QAAQ,QAAQ,EAAE,EAAE,GAAG,MAAW,CAAO;CACtF,GAAG,CAAC,CAAC,GAKC,IAAoB,GAAmB,MAAU,EAAM,iBAAiB,GACxE,IAAuB,GAAmB,MAAU,EAAM,oBAAoB,GAC9E,IAAiB,QACf,EAAyB,GAAmB,CAAM,GACxD,CAAC,GAAmB,CAAM,CAC5B,GAEM,IAAQ,EAAc;EAAE,YAAY;EAAkB,UAAU,EAAe;CAAI,CAAC,GAEpF,IACJ,KAAe,EAAG,8CAA8C,2BAA2B,GACvF,IAAU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AU;IACV,eAAY;cAEX,GAAiB,CAAS;GACrB,CAAA,IACN,MAAgB,WAClB,kBAAC,KAAD;IAAG,WAAU;IAAyB,eAAY;cAC/C,EAAkB,WAAW,IAC1B,EACE,gDACA,8DACA,EAAE,MAAM,EAAkB,GAAG,SAAS,CACxC,IACA,EACE,iDACA,6EACA,EAAE,OAAO,EAAkB,OAAO,CACpC;GACH,CAAA,IAEH,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,uCACA,yEACF;GACC,CAAA;EAEF,CAAA,CACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"AssistantComposer.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantComposer.tsx"],"sourcesContent":["import {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ClipboardEvent,\n type DragEvent,\n type FC,\n type KeyboardEvent,\n} from 'react';\nimport { ArrowUp, Loader2 } from 'lucide-react';\nimport type { AssistantMode, AssistantModeConfig } from '@/types/assistant';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { languageDisplayName } from '@/utils/speechVoices';\nimport { resolveAssistantLanguage } from '@/config/assistantLanguages';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { useVoiceInput } from '@/hooks/useVoiceInput';\nimport { useAssistantAttachments } from '@/hooks/useAssistantAttachments';\nimport {\n MAX_ATTACHMENTS,\n getSendableAttachments,\n type AssistantAttachment,\n type AttachmentRejection,\n} from '@/utils/assistantAttachments';\nimport { AssistantAttachmentButton } from './AssistantAttachmentButton';\nimport { AssistantAttachmentChips } from './AssistantAttachmentChips';\nimport { AssistantVoiceButton } from './AssistantVoiceButton';\nimport { AssistantLanguageSelector } from './AssistantLanguageSelector';\nimport { AssistantVoiceSessionButton } from '../voice/AssistantVoiceSessionButton';\nimport { AssistantModeSelector } from './AssistantModeSelector';\n\ninterface Props {\n /**\n * Send the message. `attachments` are already uploaded and ready; the chat\n * area folds them into the prompt and onto the user bubble.\n */\n onSend: (message: string, attachments: AssistantAttachment[]) => void;\n /** True while a turn is in-flight (assistant busy) — disables send + shows the spinner. */\n disabled?: boolean;\n placeholder?: string;\n mode: AssistantMode;\n /** Role-filtered list of modes the user may pick. */\n availableModes: AssistantModeConfig[];\n onModeChange: (mode: AssistantMode) => void;\n /**\n * Opens the hands-free voice conversation. Omitted where a voice session\n * cannot work at all (no speech input, or nothing able to speak the reply),\n * which is what hides the control rather than offering a dead button.\n */\n onStartVoiceSession?: () => void;\n}\n\nconst MAX_TEXTAREA_HEIGHT = 200;\n\n/**\n * AssistantComposer — the v2 input surface (per the ai-assistant-v2 mockups).\n *\n * A rounded card with, on the input row: a leading circular \"+\" attach control,\n * an auto-growing textarea, a microphone, and a prominent filled forest-green\n * circular send button. BELOW the input sit the mode pills (\"Ask\" active-green /\n * \"Take action\" outline); ABOVE it, chips for any pending attachments.\n *\n * Multimodal input (Workstreams 2–3) arrives through three converging paths —\n * the attach button, drag-and-drop onto the card, and paste (a screenshot from\n * the clipboard is the single most common way a user shares one) — plus voice\n * dictation, which appends recognised speech to the draft so it can still be\n * edited before sending.\n *\n * Fully controlled (React state for the text) with auto-grow via a layout\n * effect. Enter sends, Shift+Enter inserts a newline.\n */\nexport const AssistantComposer: FC<Props> = ({\n onSend,\n disabled = false,\n placeholder,\n mode,\n availableModes,\n onModeChange,\n onStartVoiceSession,\n}) => {\n const tr = useTr();\n const { locale } = useI18n();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const [text, setText] = useState('');\n const [isDraggingOver, setIsDraggingOver] = useState(false);\n // Nested drag-enter/leave pairs fire for every child element; count them so\n // the highlight survives dragging across the textarea and buttons.\n const dragDepthRef = useRef(0);\n\n const {\n attachments,\n isBusy: attachmentsBusy,\n sendBlocker,\n rejection,\n addFiles,\n remove,\n retry,\n clear,\n clearRejection,\n canAddMore,\n } = useAssistantAttachments();\n\n const appendTranscript = useCallback((phrase: string) => {\n setText((current) => (current ? `${current.replace(/\\s+$/, '')} ${phrase}` : phrase));\n }, []);\n\n // One selection drives the recogniser, the reply language and the voice —\n // see `assistantLanguages`. `null` follows the interface language, which is\n // what this did unconditionally before.\n const assistantLanguage = useAssistantStore((state) => state.assistantLanguage);\n const setAssistantLanguage = useAssistantStore((state) => state.setAssistantLanguage);\n const spokenLanguage = useMemo(\n () => resolveAssistantLanguage(assistantLanguage, locale),\n [assistantLanguage, locale]\n );\n\n const voice = useVoiceInput({ onFinalize: appendTranscript, language: spokenLanguage.tag });\n\n const resolvedPlaceholder =\n placeholder ?? tr('healthybowl.assistant.composer.placeholder', 'Ask HealthyBowl anything…');\n const trimmed = text.trim();\n // Exactly what the model will be given — see `getSendableAttachments`.\n const sendableAttachments = getSendableAttachments(attachments);\n const failedAttachments = attachments.filter((attachment) => attachment.status === 'error');\n // A message may be attachments-only (\"what's wrong with this leaf?\" is often\n // just the photo), but never sends while an upload is in flight OR has failed:\n // `sendBlocker` covers both. Gating on the blocker rather than on\n // `attachmentsBusy` is what stops a turn going out that quietly omits a file\n // the user can still see attached — the chips are cleared by `clear()` below,\n // so the evidence would disappear at the same instant.\n const canSend = (trimmed.length > 0 || sendableAttachments.length > 0) && !disabled && sendBlocker === null;\n\n // Auto-grow the textarea to fit its content (capped), re-measured after every\n // value change so the card breathes as the user types.\n useLayoutEffect(() => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n textarea.style.height = 'auto';\n textarea.style.height = `${Math.min(textarea.scrollHeight, MAX_TEXTAREA_HEIGHT)}px`;\n }, [text]);\n\n const handleSend = useCallback(() => {\n if (!canSend) return;\n // Dictation left running into a send would keep appending to a cleared\n // draft; stop it so the mic state matches what the user sees.\n // ★ `isActive`, not `isListening`. Sending during the permission window left\n // the recogniser running, and its trailing phrase landed in the draft this\n // line had just cleared — precisely what the comment above says it prevents.\n if (voice.isActive) voice.stop();\n onSend(text.trim(), sendableAttachments);\n setText('');\n clear();\n }, [canSend, onSend, text, sendableAttachments, clear, voice]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n handleSend();\n }\n },\n [handleSend]\n );\n\n const handlePaste = useCallback(\n (event: ClipboardEvent<HTMLTextAreaElement>) => {\n const files = Array.from(event.clipboardData?.files ?? []);\n if (files.length === 0) return;\n // Only claim the paste when it carried files; a normal text paste (which\n // also exposes an empty `files`) must still land in the textarea.\n event.preventDefault();\n addFiles(files);\n },\n [addFiles]\n );\n\n const handleDragEnter = useCallback((event: DragEvent<HTMLDivElement>) => {\n if (!Array.from(event.dataTransfer?.types ?? []).includes('Files')) return;\n dragDepthRef.current += 1;\n setIsDraggingOver(true);\n }, []);\n\n const handleDragLeave = useCallback(() => {\n dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);\n if (dragDepthRef.current === 0) setIsDraggingOver(false);\n }, []);\n\n const handleDragOver = useCallback((event: DragEvent<HTMLDivElement>) => {\n if (!Array.from(event.dataTransfer?.types ?? []).includes('Files')) return;\n // Required for a drop to fire at all, and stops the browser from navigating\n // away to the dropped file.\n event.preventDefault();\n }, []);\n\n const handleDrop = useCallback(\n (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n dragDepthRef.current = 0;\n setIsDraggingOver(false);\n addFiles(event.dataTransfer?.files ?? null);\n },\n [addFiles]\n );\n\n const rejectionMessage = (reason: AttachmentRejection): string => {\n switch (reason) {\n case 'too-many':\n return tr('healthybowl.assistant.attachments.tooMany', 'You can attach up to {{max}} files per message.', {\n max: MAX_ATTACHMENTS,\n });\n case 'too-large':\n return tr('healthybowl.assistant.attachments.tooLarge', 'That file is larger than 10 MB.');\n case 'empty':\n return tr('healthybowl.assistant.attachments.empty', 'That file is empty.');\n case 'unreadable':\n return tr('healthybowl.assistant.attachments.unreadable', 'That file could not be read.');\n case 'unsupported-image':\n return tr(\n 'healthybowl.assistant.attachments.unsupportedImage',\n \"This device can't read that image format, so it can't be resized to send. Save it as JPEG and try again.\"\n );\n }\n };\n\n const voiceErrorMessage = (): string | null => {\n switch (voice.error) {\n case 'not-allowed':\n return tr(\n 'healthybowl.assistant.voice.denied',\n 'Microphone access is blocked. Allow it in your browser settings to dictate.'\n );\n case 'audio-capture':\n return tr('healthybowl.assistant.voice.noMic', 'No microphone was found.');\n case 'network':\n return tr('healthybowl.assistant.voice.network', 'Speech recognition is offline right now.');\n case 'language-not-supported':\n // The recogniser's language list is the browser vendor's, not ours, so\n // name the language and point at the browser rather than implying the\n // assistant is broken.\n return tr(\n 'healthybowl.assistant.voice.languageNotSupported',\n 'This browser cannot recognise spoken {{language}}. Try a different browser, or type instead.',\n { language: languageDisplayName(voice.language, locale) }\n );\n case 'unknown':\n return tr('healthybowl.assistant.voice.failed', 'Dictation stopped unexpectedly.');\n default:\n return null;\n }\n };\n\n const voiceError = voiceErrorMessage();\n\n return (\n <div className=\"flex-shrink-0 px-3 pb-3 pt-1.5\">\n <div\n onDragEnter={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n className={`rounded-2xl border p-2 shadow-sm transition-colors focus-within:border-action-primary-bg focus-within:ring-2 focus-within:ring-action-primary-bg/15 ${\n isDraggingOver\n ? 'border-action-primary-bg border-dashed bg-action-primary-bg/5'\n : 'border-border-default bg-bg-sunken'\n }`}\n data-testid=\"assistant-composer\"\n >\n <AssistantAttachmentChips attachments={attachments} onRemove={remove} onRetry={retry} disabled={disabled} />\n\n {/* Input row: attach · textarea · mic · send */}\n <div className=\"flex items-end gap-2\">\n <AssistantAttachmentButton onFiles={addFiles} canAddMore={canAddMore} disabled={disabled} />\n\n <textarea\n ref={textareaRef}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n disabled={disabled}\n placeholder={\n isDraggingOver\n ? tr('healthybowl.assistant.composer.dropHere', 'Drop files to attach')\n : resolvedPlaceholder\n }\n rows={1}\n className=\"min-h-[36px] flex-1 resize-none self-center bg-transparent px-1 py-2 text-[15px] leading-relaxed text-text-primary placeholder:text-text-muted focus:outline-none disabled:opacity-50\"\n aria-label={tr('healthybowl.assistant.chatInput.ariaLabel', 'Message input')}\n data-testid=\"assistant-input\"\n />\n\n {/* Outside the dictation guard on purpose: this preference also\n decides what language the assistant REPLIES in, which works\n perfectly well on a browser with no speech recognition at all.\n Hiding it there left Firefox users unable to choose a reply\n language, which is most of what it is for. */}\n <AssistantLanguageSelector\n current={spokenLanguage}\n selected={assistantLanguage}\n onChange={setAssistantLanguage}\n disabled={disabled || voice.isActive}\n />\n\n {voice.isSupported && (\n <AssistantVoiceButton\n isListening={voice.isListening}\n isStarting={voice.isStarting}\n onToggle={voice.toggle}\n disabled={disabled}\n />\n )}\n\n {/* The voice button takes the send slot while there is nothing to\n send — see AssistantVoiceSessionButton for why swapping rather\n than adding is the only option that fits. */}\n {/* Genuinely empty, NOT merely unsendable: `canSend` is also false\n while an attachment uploads or a turn is in flight, so keying off\n it would replace send even with a draft typed and ready. */}\n {onStartVoiceSession && trimmed.length === 0 && attachments.length === 0 && !voice.isActive ? (\n <AssistantVoiceSessionButton onStart={onStartVoiceSession} disabled={disabled} />\n ) : (\n <button\n type=\"button\"\n onClick={handleSend}\n disabled={!canSend}\n className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong ${\n canSend\n ? 'bg-action-primary-bg text-action-primary-text hover:scale-105 hover:bg-action-primary-bg-hover'\n : 'bg-bg-elevated text-text-muted'\n }`}\n aria-label={tr('healthybowl.assistant.chatInput.send', 'Send message')}\n data-testid=\"assistant-send\"\n >\n {disabled || attachmentsBusy ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <ArrowUp className=\"size-4\" />\n )}\n </button>\n )}\n </div>\n\n {/* Mode pills */}\n {availableModes.length > 1 && (\n <div className=\"mt-2 px-0.5\">\n <AssistantModeSelector\n mode={mode}\n availableModes={availableModes}\n onModeChange={onModeChange}\n disabled={disabled}\n />\n </div>\n )}\n </div>\n\n {/* One status line under the card: live dictation > voice error >\n attachment rejection > failed upload > the keyboard hint. Announced\n politely so a screen-reader user hears dictation land without losing\n their place.\n\n The failed-upload line ranks below `rejection` (which is transient and\n describes the file the user just picked) but above the hint, because a\n disabled send button with no stated reason is the thing this whole\n change exists to avoid. */}\n <div className=\"mt-1.5 px-1 text-center text-[11px]\" aria-live=\"polite\">\n {/* ★ Three states, not two. `isListening` now waits for the recogniser's\n own `onstart`, which is the honest signal — but it left this line\n showing the idle hint after the user had already tapped the\n microphone, for the whole permission-prompt window. */}\n {voice.isStarting && !voice.isListening ? (\n <p className=\"text-text-muted\" data-testid=\"assistant-voice-starting\">\n {tr('healthybowl.assistant.voice.starting', 'Starting the microphone…')}\n </p>\n ) : voice.isListening ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-voice-status\">\n <span className=\"mr-1 inline-block size-1.5 rounded-full bg-status-error-text align-middle motion-safe:animate-pulse\" />\n {voice.interim ||\n tr('healthybowl.assistant.voice.listening', 'Listening… speak now, tap the square to stop')}\n </p>\n ) : voiceError ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-voice-error\">\n {voiceError}\n </p>\n ) : rejection ? (\n <button\n type=\"button\"\n onClick={clearRejection}\n className=\"text-status-error-text underline-offset-2 hover:underline\"\n data-testid=\"assistant-attachment-rejection\"\n >\n {rejectionMessage(rejection)}\n </button>\n ) : sendBlocker === 'failed' ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-attachment-blocked\">\n {failedAttachments.length === 1\n ? tr(\n 'healthybowl.assistant.attachments.blockedOne',\n \"{{name}} didn't upload. Retry or remove it before sending.\",\n { name: failedAttachments[0].filename }\n )\n : tr(\n 'healthybowl.assistant.attachments.blockedMany',\n \"{{count}} attachments didn't upload. Retry or remove them before sending.\",\n { count: failedAttachments.length }\n )}\n </p>\n ) : (\n <p className=\"text-text-muted\">\n {tr(\n 'healthybowl.assistant.composer.hint',\n 'Enter to send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hooks/useTr.js";
|
|
|
2
2
|
import { Mic as t, Square as n } from "lucide-react";
|
|
3
3
|
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/assistant/composer/AssistantVoiceButton.tsx
|
|
5
|
-
var a = ({ isListening: a,
|
|
6
|
-
let
|
|
5
|
+
var a = ({ isListening: a, isStarting: o = !1, onToggle: s, disabled: c = !1 }) => {
|
|
6
|
+
let l = e(), u = a ? l("healthybowl.assistant.composer.voiceStop", "Stop dictation") : o ? l("healthybowl.assistant.composer.voiceStarting", "Starting the microphone — tap to cancel") : l("healthybowl.assistant.composer.voiceStart", "Dictate a message");
|
|
7
7
|
return /* @__PURE__ */ r("button", {
|
|
8
8
|
type: "button",
|
|
9
|
-
onClick:
|
|
10
|
-
disabled:
|
|
11
|
-
title:
|
|
12
|
-
"aria-label":
|
|
13
|
-
"aria-pressed": a,
|
|
14
|
-
className: `flex size-9 flex-shrink-0 items-center justify-center rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 ${a ? "border-status-error-text/40 bg-status-error-bg/10 text-status-error-text" : "border-border-subtle bg-bg-elevated text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
|
|
9
|
+
onClick: s,
|
|
10
|
+
disabled: c,
|
|
11
|
+
title: u,
|
|
12
|
+
"aria-label": u,
|
|
13
|
+
"aria-pressed": a || o,
|
|
14
|
+
className: `flex size-9 flex-shrink-0 items-center justify-center rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 ${a ? "border-status-error-text/40 bg-status-error-bg/10 text-status-error-text" : o ? "border-border-strong bg-bg-elevated text-text-secondary" : "border-border-subtle bg-bg-elevated text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
|
|
15
15
|
"data-testid": "assistant-voice",
|
|
16
|
-
|
|
16
|
+
"data-state": a ? "listening" : o ? "starting" : "idle",
|
|
17
|
+
children: o && !a ? /* @__PURE__ */ r(t, { className: "size-4 motion-safe:animate-pulse opacity-70" }) : a ? /* @__PURE__ */ i("span", {
|
|
17
18
|
className: "relative flex items-center justify-center",
|
|
18
19
|
children: [/* @__PURE__ */ r("span", { className: "absolute inline-flex size-7 rounded-full bg-status-error-bg/20 motion-safe:animate-ping" }), /* @__PURE__ */ r(n, { className: "relative size-3 fill-current" })]
|
|
19
20
|
}) : /* @__PURE__ */ r(t, { className: "size-4" })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantVoiceButton.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantVoiceButton.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Mic, Square } from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\n\ninterface Props {\n isListening: boolean;\n onToggle: () => void;\n disabled?: boolean;\n}\n\n/**\n * Microphone control in the composer — real speech-to-text (Workstream 2),\n * driven by `useVoiceInput`. While listening it becomes a stop button with a\n * live ring, so the control that starts dictation is also the one that ends it\n * (no hunting for a second affordance mid-sentence).\n *\n * The composer renders this only when the browser supports SpeechRecognition;\n * an unsupported engine gets no dead control at all.\n */\nexport const AssistantVoiceButton: FC<Props> = ({ isListening, onToggle, disabled = false }) => {\n const tr = useTr();\n const label = isListening\n ? tr('healthybowl.assistant.composer.voiceStop', 'Stop dictation')\n : tr('healthybowl.assistant.composer.voiceStart', 'Dictate a message');\n\n return (\n <button\n type=\"button\"\n onClick={onToggle}\n disabled={disabled}\n title={label}\n aria-label={label}\n aria-pressed={isListening}\n className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 ${\n isListening\n ? 'border-status-error-text/40 bg-status-error-bg/10 text-status-error-text'\n : 'border-border-subtle bg-bg-elevated text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n data-testid=\"assistant-voice\"\n >\n {isListening ? (\n <span className=\"relative flex items-center justify-center\">\n {/* Pulsing ring reads as \"live\" at a glance; motion-safe so a\n reduced-motion user gets the colour change without the throb. */}\n <span className=\"absolute inline-flex size-7 rounded-full bg-status-error-bg/20 motion-safe:animate-ping\" />\n <Square className=\"relative size-3 fill-current\" />\n </span>\n ) : (\n <Mic className=\"size-4\" />\n )}\n </button>\n );\n};\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"AssistantVoiceButton.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantVoiceButton.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Mic, Square } from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\n\ninterface Props {\n isListening: boolean;\n /** Requested, not yet capturing — the permission prompt / start-up window. */\n isStarting?: boolean;\n onToggle: () => void;\n disabled?: boolean;\n}\n\n/**\n * Microphone control in the composer — real speech-to-text (Workstream 2),\n * driven by `useVoiceInput`. While listening it becomes a stop button with a\n * live ring, so the control that starts dictation is also the one that ends it\n * (no hunting for a second affordance mid-sentence).\n *\n * The composer renders this only when the browser supports SpeechRecognition;\n * an unsupported engine gets no dead control at all.\n */\nexport const AssistantVoiceButton: FC<Props> = ({ isListening, isStarting = false, onToggle, disabled = false }) => {\n const tr = useTr();\n // ★ Three states. Rendering the idle microphone while the browser is still\n // asking for permission told the user nothing had happened, so they pressed it\n // again — and the press was a no-op until `toggle` learned to cancel a pending\n // start. The icon now says which of the three it is.\n const label = isListening\n ? tr('healthybowl.assistant.composer.voiceStop', 'Stop dictation')\n : isStarting\n ? tr('healthybowl.assistant.composer.voiceStarting', 'Starting the microphone — tap to cancel')\n : tr('healthybowl.assistant.composer.voiceStart', 'Dictate a message');\n\n return (\n <button\n type=\"button\"\n onClick={onToggle}\n disabled={disabled}\n title={label}\n aria-label={label}\n aria-pressed={isListening || isStarting}\n className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 ${\n isListening\n ? 'border-status-error-text/40 bg-status-error-bg/10 text-status-error-text'\n : isStarting\n ? 'border-border-strong bg-bg-elevated text-text-secondary'\n : 'border-border-subtle bg-bg-elevated text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n data-testid=\"assistant-voice\"\n data-state={isListening ? 'listening' : isStarting ? 'starting' : 'idle'}\n >\n {isStarting && !isListening ? (\n // Deliberately NOT disabled: this is the one moment the user most wants\n // a way out, and `toggle` now cancels the pending start.\n <Mic className=\"size-4 motion-safe:animate-pulse opacity-70\" />\n ) : isListening ? (\n <span className=\"relative flex items-center justify-center\">\n {/* Pulsing ring reads as \"live\" at a glance; motion-safe so a\n reduced-motion user gets the colour change without the throb. */}\n <span className=\"absolute inline-flex size-7 rounded-full bg-status-error-bg/20 motion-safe:animate-ping\" />\n <Square className=\"relative size-3 fill-current\" />\n </span>\n ) : (\n <Mic className=\"size-4\" />\n )}\n </button>\n );\n};\n"],"mappings":";;;;AAqBA,IAAa,KAAmC,EAAE,gBAAa,gBAAa,IAAO,aAAU,cAAW,SAAY;CAClH,IAAM,IAAK,EAAM,GAKX,IAAQ,IACV,EAAG,4CAA4C,gBAAgB,IAC/D,IACE,EAAG,gDAAgD,yCAAyC,IAC5F,EAAG,6CAA6C,mBAAmB;CAEzE,OACE,kBAAC,UAAD;EACE,MAAK;EACL,SAAS;EACC;EACV,OAAO;EACP,cAAY;EACZ,gBAAc,KAAe;EAC7B,WAAW,wNACT,IACI,6EACA,IACE,4DACA;EAER,eAAY;EACZ,cAAY,IAAc,cAAc,IAAa,aAAa;YAEjE,KAAc,CAAC,IAGd,kBAAC,GAAD,EAAK,WAAU,8CAA+C,CAAA,IAC5D,IACF,kBAAC,QAAD;GAAM,WAAU;aAAhB,CAGE,kBAAC,QAAD,EAAM,WAAU,0FAA2F,CAAA,GAC3G,kBAAC,GAAD,EAAQ,WAAU,+BAAgC,CAAA,CAC9C;OAEN,kBAAC,GAAD,EAAK,WAAU,SAAU,CAAA;CAErB,CAAA;AAEZ"}
|
|
@@ -289,11 +289,6 @@ var Dt = a`
|
|
|
289
289
|
notes
|
|
290
290
|
fee
|
|
291
291
|
status
|
|
292
|
-
paymentStatus
|
|
293
|
-
paymentProvider
|
|
294
|
-
paymentReference
|
|
295
|
-
paidAmount
|
|
296
|
-
paidAt
|
|
297
292
|
createdAt
|
|
298
293
|
}
|
|
299
294
|
}
|
|
@@ -310,11 +305,6 @@ var Dt = a`
|
|
|
310
305
|
notes
|
|
311
306
|
fee
|
|
312
307
|
status
|
|
313
|
-
paymentStatus
|
|
314
|
-
paymentProvider
|
|
315
|
-
paymentReference
|
|
316
|
-
paidAmount
|
|
317
|
-
paidAt
|
|
318
308
|
createdAt
|
|
319
309
|
}
|
|
320
310
|
}
|
|
@@ -331,11 +321,6 @@ var Dt = a`
|
|
|
331
321
|
notes
|
|
332
322
|
fee
|
|
333
323
|
status
|
|
334
|
-
paymentStatus
|
|
335
|
-
paymentProvider
|
|
336
|
-
paymentReference
|
|
337
|
-
paidAmount
|
|
338
|
-
paidAt
|
|
339
324
|
createdAt
|
|
340
325
|
}
|
|
341
326
|
}
|