@burdenoff/fe-libs 2026.1029.6 → 2026.1029.7

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 (34) hide show
  1. package/dist/shared/assistant/index.d.ts +5 -0
  2. package/dist/shared/assistant/liveDeltas.d.ts +3 -0
  3. package/dist/shared/assistant/liveDeltas.js +17 -1
  4. package/dist/shared/assistant/liveOverlay.d.ts +4 -0
  5. package/dist/shared/assistant/liveOverlay.js +10 -1
  6. package/dist/shared/assistant/speech/appendSpeechQueue.d.ts +13 -0
  7. package/dist/shared/assistant/speech/appendSpeechQueue.js +75 -0
  8. package/dist/shared/assistant/speech/browserSpeechEngine.js +93 -46
  9. package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +173 -109
  10. package/dist/shared/assistant/speech/index.d.ts +1 -1
  11. package/dist/shared/assistant/speech/notifyCancellationSpeechEngine.js +53 -0
  12. package/dist/shared/assistant/speech/routingSpeechEngine.js +107 -23
  13. package/dist/shared/assistant/speech/speechFeed.d.ts +17 -2
  14. package/dist/shared/assistant/speech/speechFeed.js +35 -12
  15. package/dist/shared/assistant/speech/types.d.ts +20 -1
  16. package/dist/shared/assistant/turnTimeline.d.ts +3 -0
  17. package/dist/shared/assistant/turnTimeline.js +4 -1
  18. package/dist/shared/assistant/ui/AssistantChatArea.js +1410 -1393
  19. package/dist/shared/assistant/ui/AssistantSpeechProvider.js +351 -291
  20. package/dist/shared/assistant/ui/useVoiceSession.js +323 -288
  21. package/dist/shared/assistant/voice/livePhraseSpeech.d.ts +14 -0
  22. package/dist/shared/assistant/voice/livePhraseSpeech.js +72 -0
  23. package/dist/shared/assistant/voice/phraseGate.d.ts +11 -0
  24. package/dist/shared/assistant/voice/phraseGate.js +74 -0
  25. package/dist/shared/assistant/voice/phrasePlayback.d.ts +9 -0
  26. package/dist/shared/assistant/voice/phrasePlayback.js +78 -0
  27. package/dist/shared/assistant/voice/phraseSpeechConfig.d.ts +5 -0
  28. package/dist/shared/assistant/voice/phraseSpeechConfig.js +10 -0
  29. package/dist/shared/assistant/voice/speakableText.d.ts +1 -0
  30. package/dist/shared/assistant/voice/speakableText.js +1 -1
  31. package/dist/shared/assistant/voice/voiceSession.d.ts +5 -0
  32. package/dist/shared/assistant/voice/voiceSession.js +17 -1
  33. package/dist/shared-assistant.js +293 -288
  34. package/package.json +1 -1
@@ -15,41 +15,42 @@ import { AUTO_READ_MODE as p, autoSuggestions as ee, classifyAssistantIntent as
15
15
  import { getHistoryStamp as ie, setHistoryBusyProbe as ae } from "../history/stampRegistry.js";
16
16
  import { beginApprovalInFlight as oe, endApprovalInFlight as h, getApprovalInFlight as se, markLiveTurn as ce, newestModelReplyId as g, resolveApprovablePendingWrite as le, resolveRetryableMessageId as ue, subscribeApprovalInFlight as _ } from "../liveTurns.js";
17
17
  import { isWriteModeAcknowledged as de, writeModeSendRefusalReason as fe } from "../writeModeConsent.js";
18
- import { resolveActiveModeSandbox as pe, useAssistantStore as v } from "../store.js";
19
- import { abortAssistantTurn as me, approvePendingWrite as he, createAssistantSandbox as ge, createAssistantSession as y, extendAssistantSandboxTTL as _e, findExistingSandboxWithStatus as ve, getAssistantArtifacts as ye, getAssistantMessages as be, getAssistantSession as xe, mintAssistantTurnStream as Se, modeRequiresConfirmWrites as Ce, postClientToolResult as we, promptGatewayRequestBytes as Te, releaseSupersededAssistantSandboxes as Ee, sendAssistantPromptAsync as De, waitForAssistantServiceReady as Oe, waitForSandboxRunning as ke, writeApprovalModeOf as b } from "../api.js";
20
- import { UiOfferSession as Ae, sandboxServesUiOffers as je, uiOfferHintKind as Me, uiOfferInTime as Ne } from "../uiActions/uiOffers.js";
21
- import { AssistantSendRefusal as Pe, classifyTurnFailure as Fe, turnConfirmsNoAction as Ie, turnOutcomeCopy as Le } from "../turnOutcome.js";
22
- import { assistantUsageLedger as Re, hasPendingUsageReports as ze, reportUsageWithRetry as Be, retryPendingUsageReports as Ve, usageSendRefusal as He } from "../usageReporting.js";
23
- import { withIncompleteTurnNotice as Ue } from "../streamBudget.js";
24
- import { chatTurns as x, isVoiceTurn as We, voiceMarker as Ge, voiceSessionIdOf as Ke } from "../voice/turnVisibility.js";
25
- import { speechFeed as qe } from "../speech/speechFeed.js";
26
- import { requestReplyOnAvatar as Je } from "../speech/replySpeechRequests.js";
27
- import { toVoiceReply as Ye } from "../voice/voiceReply.js";
28
- import { isTurnSuperseded as Xe, markTurnSuperseded as Ze } from "../voice/supersededTurns.js";
29
- import { buildContinuedFromVoiceNote as Qe, buildVoiceTranscriptMarkdown as $e, voiceTranscriptFilename as et } from "../voice/voiceTranscript.js";
30
- import { pollDelayMs as tt } from "../voice/assistantPollSchedule.js";
31
- import { toCaptionText as nt } from "../voice/captionText.js";
32
- import { resolveAssistantLanguage as rt } from "../voice/languages.js";
33
- import { resolveLanguagePair as it } from "../voice/languagePair.js";
34
- import { INITIAL_TRANSCRIPT_AUTO_OPEN as at, isAwaitingOwnConversation as ot, maySendSpokenTurn as st, planTranscriptAutoOpen as ct, planVoiceSessionBinding as S, planVoiceSessionStart as lt, planVoiceSpokenEntry as ut, voiceBindingAtStart as dt, voiceBindingConversationId as ft } from "../voice/voiceReopen.js";
35
- import { countInlineImageCandidates as pt, countInlinedImageParts as mt, largestInlineCharsPerFile as ht, resolveAssistantInlineLimits as gt, toMessageAttachment as _t } from "../attachments.js";
36
- import { useAvatarCopy as vt } from "../avatar/useAvatarCopy.js";
37
- import { WRITE_PROPOSAL_VOICE_COPY as yt, isVoiceProposalBound as bt, voiceProposalChip as xt, voiceProposalChipText as St, voiceReadbacksDue as Ct, voiceWaitingProposals as wt, writeProposalVoiceLine as Tt, writeProposalVoiceReadback as Et } from "../writeProposalVoice.js";
38
- import { createAdminModeAccessGate as Dt, resolveAssistantSendModeAfterAccess as Ot } from "../adminModeSendGate.js";
39
- import { buildBoundedAttachmentTurn as kt } from "../attachmentTurn.js";
40
- import { attachmentUrlIsStale as At, refreshStaleAttachmentUrls as jt } from "../attachmentCommit.js";
41
- import { VOICE_COMMIT_BUDGET_MS as Mt, settleAndCommitSpokenTurn as Nt } from "../voiceCommit.js";
42
- import { getOrganizationId as Pt, getWorkspaceId as C } from "../context.js";
43
- import { useAttachmentUrlResolver as Ft } from "../useAttachmentCommitter.js";
44
- import { isTurnInFlight as It, planAbandonedTurn as Lt, planTurnAbort as Rt } from "../turnState.js";
45
- import { backDoneCopy as zt, chooseDestinationCopy as Bt, chooseLinkedCopy as Vt, entityNounText as Ht, linkNotOpenableCopy as Ut, navigationCommandCopy as Wt, navigationOutcomeCopy as Gt, offerExpiredCopy as Kt, offerKeptForUnsavedCopy as qt, offerNotAvailableCopy as Jt, pickFromListCopy as Yt, recordChoiceCopy as Xt, recordKindsCopy as Zt, themeCommandCopy as Qt } from "../localUiCommandCopy.js";
46
- import { appControlCopy as $t } from "../appControls/copy.js";
47
- import { LANGUAGE_REPLY_DEADLINE_MS as en, languageConfirmationCopy as tn, languageReplyStep as nn } from "../appControls/languageReply.js";
48
- import { getAssistantDisplayContent as rn } from "../displayContent.js";
49
- import { NO_FIRST_TEXT as an, buildAssistantProgress as on, readAheadFor as sn, snapshotReplyFloor as cn, startSessionReadAhead as ln, trackFirstText as un } from "../turnProgress.js";
50
- import { parseToolActivity as dn } from "./AssistantToolActivity.js";
51
- import { countSpokenTurns as fn, spokenMessagesSinceContinueNote as pn, spokenTurnText as mn } from "../spokenTurns.js";
52
- import { beginTurn as hn, describeTurn as w, detectTurnDevice as gn, markTurn as T, restartAttempt as _n, turnClockMs as vn } from "../turnTimeline.js";
18
+ import { resolveActiveModeSandbox as v, useAssistantStore as y } from "../store.js";
19
+ import { abortAssistantTurn as pe, approvePendingWrite as me, createAssistantSandbox as he, createAssistantSession as b, extendAssistantSandboxTTL as ge, findExistingSandboxWithStatus as _e, getAssistantArtifacts as ve, getAssistantMessages as ye, getAssistantSession as be, mintAssistantTurnStream as xe, modeRequiresConfirmWrites as Se, postClientToolResult as Ce, promptGatewayRequestBytes as we, releaseSupersededAssistantSandboxes as Te, sendAssistantPromptAsync as Ee, waitForAssistantServiceReady as De, waitForSandboxRunning as Oe, writeApprovalModeOf as x } from "../api.js";
20
+ import { UiOfferSession as ke, sandboxServesUiOffers as Ae, uiOfferHintKind as je, uiOfferInTime as Me } from "../uiActions/uiOffers.js";
21
+ import { AssistantSendRefusal as Ne, classifyTurnFailure as Pe, turnConfirmsNoAction as Fe, turnOutcomeCopy as Ie } from "../turnOutcome.js";
22
+ import { assistantUsageLedger as Le, hasPendingUsageReports as Re, reportUsageWithRetry as ze, retryPendingUsageReports as Be, usageSendRefusal as Ve } from "../usageReporting.js";
23
+ import { withIncompleteTurnNotice as He } from "../streamBudget.js";
24
+ import { chatTurns as S, isVoiceTurn as Ue, voiceMarker as We, voiceSessionIdOf as Ge } from "../voice/turnVisibility.js";
25
+ import { speechFeed as Ke } from "../speech/speechFeed.js";
26
+ import { requestReplyOnAvatar as qe } from "../speech/replySpeechRequests.js";
27
+ import { toVoiceReply as Je } from "../voice/voiceReply.js";
28
+ import { isTurnSuperseded as Ye, markTurnSuperseded as Xe } from "../voice/supersededTurns.js";
29
+ import { buildContinuedFromVoiceNote as Ze, buildVoiceTranscriptMarkdown as Qe, voiceTranscriptFilename as $e } from "../voice/voiceTranscript.js";
30
+ import { pollDelayMs as et } from "../voice/assistantPollSchedule.js";
31
+ import { toCaptionText as tt } from "../voice/captionText.js";
32
+ import { resolveAssistantLanguage as nt } from "../voice/languages.js";
33
+ import { resolveLanguagePair as rt } from "../voice/languagePair.js";
34
+ import { INITIAL_TRANSCRIPT_AUTO_OPEN as it, isAwaitingOwnConversation as at, maySendSpokenTurn as ot, planTranscriptAutoOpen as st, planVoiceSessionBinding as C, planVoiceSessionStart as ct, planVoiceSpokenEntry as lt, voiceBindingAtStart as ut, voiceBindingConversationId as dt } from "../voice/voiceReopen.js";
35
+ import { countInlineImageCandidates as ft, countInlinedImageParts as pt, largestInlineCharsPerFile as mt, resolveAssistantInlineLimits as ht, toMessageAttachment as gt } from "../attachments.js";
36
+ import { useAvatarCopy as _t } from "../avatar/useAvatarCopy.js";
37
+ import { WRITE_PROPOSAL_VOICE_COPY as vt, isVoiceProposalBound as yt, voiceProposalChip as bt, voiceProposalChipText as xt, voiceReadbacksDue as St, voiceWaitingProposals as Ct, writeProposalVoiceLine as wt, writeProposalVoiceReadback as Tt } from "../writeProposalVoice.js";
38
+ import { createAdminModeAccessGate as Et, resolveAssistantSendModeAfterAccess as Dt } from "../adminModeSendGate.js";
39
+ import { buildBoundedAttachmentTurn as Ot } from "../attachmentTurn.js";
40
+ import { attachmentUrlIsStale as kt, refreshStaleAttachmentUrls as At } from "../attachmentCommit.js";
41
+ import { VOICE_COMMIT_BUDGET_MS as jt, settleAndCommitSpokenTurn as Mt } from "../voiceCommit.js";
42
+ import { getOrganizationId as Nt, getWorkspaceId as w } from "../context.js";
43
+ import { useAttachmentUrlResolver as Pt } from "../useAttachmentCommitter.js";
44
+ import { isTurnInFlight as Ft, planAbandonedTurn as It, planTurnAbort as Lt } from "../turnState.js";
45
+ import { backDoneCopy as Rt, chooseDestinationCopy as zt, chooseLinkedCopy as Bt, entityNounText as Vt, linkNotOpenableCopy as Ht, navigationCommandCopy as Ut, navigationOutcomeCopy as Wt, offerExpiredCopy as Gt, offerKeptForUnsavedCopy as Kt, offerNotAvailableCopy as qt, pickFromListCopy as Jt, recordChoiceCopy as Yt, recordKindsCopy as Xt, themeCommandCopy as Zt } from "../localUiCommandCopy.js";
46
+ import { appControlCopy as Qt } from "../appControls/copy.js";
47
+ import { LANGUAGE_REPLY_DEADLINE_MS as $t, languageConfirmationCopy as en, languageReplyStep as tn } from "../appControls/languageReply.js";
48
+ import { getAssistantDisplayContent as nn } from "../displayContent.js";
49
+ import { NO_FIRST_TEXT as rn, buildAssistantProgress as an, readAheadFor as on, snapshotReplyFloor as sn, startSessionReadAhead as cn, trackFirstText as ln } from "../turnProgress.js";
50
+ import { parseToolActivity as un } from "./AssistantToolActivity.js";
51
+ import { countSpokenTurns as dn, spokenMessagesSinceContinueNote as fn, spokenTurnText as pn } from "../spokenTurns.js";
52
+ import { phraseSpeechEnabled as mn } from "../voice/phraseSpeechConfig.js";
53
+ import { beginTurn as hn, describeTurn as T, detectTurnDevice as gn, markTurn as E, restartAttempt as _n, turnClockMs as vn } from "../turnTimeline.js";
53
54
  import { sendAssistantTurnTimings as yn, startTurnTimingReporting as bn } from "../turnTimingReporter.js";
54
55
  import { useAssistantSpeech as xn } from "./AssistantSpeechProvider.js";
55
56
  import { useLiveAvatarTab as Sn, useLiveAvatarTabSeam as Cn } from "./assistantLiveAvatarSeam.js";
@@ -121,164 +122,165 @@ import { isProdRuntime as Si } from "../env.js";
121
122
  import { AssistantApiCallsConsentDialog as Ci } from "./AssistantApiCallsConsentDialog.js";
122
123
  import { createDraftCommandCheck as wi } from "./draftCommandCheck.js";
123
124
  import { createClientToolRunner as Ti, offerClientTools as Ei } from "../../agent-tools/adapters/assistant.js";
124
- import { useVisibleNavItems as Di } from "../../../chrome/mobileTabBar/useVisibleNavItems.js";
125
- import { useCallback as E, useEffect as D, useLayoutEffect as Oi, useMemo as O, useRef as k, useState as A, useSyncExternalStore as ki } from "react";
126
- import { jsx as j, jsxs as Ai } from "react/jsx-runtime";
125
+ import { createLivePhraseSpeech as Di } from "../voice/livePhraseSpeech.js";
126
+ import { useVisibleNavItems as Oi } from "../../../chrome/mobileTabBar/useVisibleNavItems.js";
127
+ import { useCallback as D, useEffect as O, useLayoutEffect as ki, useMemo as k, useRef as A, useState as j, useSyncExternalStore as Ai } from "react";
128
+ import { jsx as M, jsxs as ji } from "react/jsx-runtime";
127
129
  //#region src/shared/assistant/ui/AssistantChatArea.tsx
128
- var ji = 2500, Mi = 600, Ni = 2e4, Pi = 1e4, Fi = 1e4, Ii = !1, Li = {
130
+ var Mi = 2500, Ni = 600, Pi = 2e4, Fi = 1e4, Ii = 1e4, Li = !1, Ri = {
129
131
  committing: !1,
130
132
  dictating: !1
131
- }, Ri = 6e3;
132
- function M() {
133
+ }, zi = 6e3;
134
+ function N() {
133
135
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
134
136
  }
135
- var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess: Hi = "unknown", presentation: Ui = "classic" }) => {
136
- let N = s(), Wi = Ui === "compact", { product: P, modes: F, gatherPageContext: Gi, buildPrompt: Ki, reportTurnTimings: qi, reportTokenUsage: Ji, localUiCommands: Yi } = o(), I = b(o().writeApproval), Xi = E((e, t) => {
137
- let n = v.getState(), r = t ?? n.sandboxesByMode[e]?.sandboxId ?? null;
138
- return bt({
137
+ var Bi = () => () => {}, Vi = () => "off", Hi = ({ visible: Hi = !0, writeAccess: Ui = "unknown", presentation: Wi = "classic" }) => {
138
+ let P = s(), Gi = Wi === "compact", { product: F, modes: I, gatherPageContext: Ki, buildPrompt: qi, reportTurnTimings: Ji, reportTokenUsage: Yi, localUiCommands: Xi } = o(), L = x(o().writeApproval), Zi = D((e, t) => {
139
+ let n = y.getState(), r = t ?? n.sandboxesByMode[e]?.sandboxId ?? null;
140
+ return yt({
139
141
  mode: e,
140
- productWriteApproval: I,
142
+ productWriteApproval: L,
141
143
  capabilities: r ? n.sandboxWriteCapabilities[r] : null
142
144
  });
143
- }, [I]), { getAccessToken: Zi, getWorkspaceToken: Qi, userId: L } = r(), { locale: R, isLocaleLoading: $i } = e(), ea = v((e) => e.voiceGraceMs), ta = v((e) => e.handsFreeInterrupt), na = v((e) => e.handsFreeStreamNoticeAccepted), ra = v((e) => e.acceptHandsFreeStreamNotice), ia = v((e) => e.assistantLanguage), aa = v((e) => e.replyLanguage), oa = O(() => it(ia, aa, R), [
145
+ }, [L]), { getAccessToken: R, getWorkspaceToken: Qi, userId: z } = r(), { locale: B, isLocaleLoading: $i } = e(), ea = y((e) => e.voiceGraceMs), ta = y((e) => e.handsFreeInterrupt), na = y((e) => e.handsFreeStreamNoticeAccepted), ra = y((e) => e.acceptHandsFreeStreamNotice), ia = y((e) => e.assistantLanguage), aa = y((e) => e.replyLanguage), oa = k(() => rt(ia, aa, B), [
144
146
  ia,
145
147
  aa,
146
- R
147
- ]), sa = oa.reply.english, ca = oa.replyIsExplicit, la = oa.reply.code, { conversations: ua, activeConversationId: z, mode: B, processingByConversationId: da, setMode: fa, setConversationMode: pa, setActiveConversation: ma, createConversation: ha, addMessage: V, updateMessage: ga, patchMessage: _a, mergeMessageMetadata: va, setConversationProcessing: ya, clearConversationProcessing: ba, setBackendSessionId: xa, clearBackendSessionId: Sa, setSandbox: Ca, clearSandbox: wa, acknowledgedWriteModes: Ta, acknowledgeWriteMode: Ea, autoRouting: Da, setAutoRouting: Oa, routeConversation: ka } = v(), H = ua.find((e) => e.id === z), Aa = kr(H), ja = Aa.all, U = z ? da[z] : void 0, W = It(U?.status), Ma = W ? U?.messageId ?? null : null, Na = U?.status === "error" ? U.messageId : null, Pa = v((e) => e.sandboxWriteCapabilities), { panel: G, entries: Fa, retiredSandboxes: Ia } = Un({
148
- tr: N,
149
- productWriteApproval: I
150
- }), La = Ln({
151
- approve: (e, t) => G.approve(e, t),
152
- decline: (e, t, n) => G.decline(e, t, n),
153
- presented: (e, t) => G.presented(e, t)
154
- }), Ra = La.dismiss, za = k(null);
155
- D(() => {
156
- Ra();
157
- let e = za.current;
158
- za.current = z, e && e !== z && G.withdraw(e, "conversation_closed"), z && G.openConversation(z);
148
+ B
149
+ ]), sa = oa.reply.english, ca = oa.replyIsExplicit, la = oa.reply.code, { conversations: ua, activeConversationId: V, mode: H, processingByConversationId: da, setMode: fa, setConversationMode: pa, setActiveConversation: ma, createConversation: ha, addMessage: U, updateMessage: ga, patchMessage: _a, mergeMessageMetadata: va, setConversationProcessing: ya, clearConversationProcessing: ba, setBackendSessionId: xa, clearBackendSessionId: Sa, setSandbox: Ca, clearSandbox: wa, acknowledgedWriteModes: Ta, acknowledgeWriteMode: Ea, autoRouting: Da, setAutoRouting: Oa, routeConversation: ka } = y(), W = ua.find((e) => e.id === V), Aa = kr(W), ja = Aa.all, G = V ? da[V] : void 0, Ma = Ft(G?.status), Na = Ma ? G?.messageId ?? null : null, Pa = G?.status === "error" ? G.messageId : null, Fa = y((e) => e.sandboxWriteCapabilities), { panel: K, entries: Ia, retiredSandboxes: La } = Un({
150
+ tr: P,
151
+ productWriteApproval: L
152
+ }), Ra = Ln({
153
+ approve: (e, t) => K.approve(e, t),
154
+ decline: (e, t, n) => K.decline(e, t, n),
155
+ presented: (e, t) => K.presented(e, t)
156
+ }), za = Ra.dismiss, Ba = A(null);
157
+ O(() => {
158
+ za();
159
+ let e = Ba.current;
160
+ Ba.current = V, e && e !== V && K.withdraw(e, "conversation_closed"), V && K.openConversation(V);
159
161
  }, [
160
- z,
161
- G,
162
- Ra
162
+ V,
163
+ K,
164
+ za
163
165
  ]);
164
- let Ba = nr(H), Va = hr(H)?.archivedAt != null, Ha = ir((e) => z !== null && z in e.loadingIds), Ua = ir((e) => z !== null && z in e.loadErrorIds), Wa = ir((e) => e.remoteDelete), [Ga, Ka] = A(() => ir.getState().remoteDelete?.at ?? null), qa = Wa?.wasActive === !0 && Wa.at !== Ga ? Wa.at : null;
165
- D(() => {
166
- if (qa === null) return;
167
- let e = window.setTimeout(() => Ka(qa), Fi);
166
+ let Va = nr(W), Ha = hr(W)?.archivedAt != null, Ua = ir((e) => V !== null && V in e.loadingIds), Wa = ir((e) => V !== null && V in e.loadErrorIds), Ga = ir((e) => e.remoteDelete), [Ka, qa] = j(() => ir.getState().remoteDelete?.at ?? null), Ja = Ga?.wasActive === !0 && Ga.at !== Ka ? Ga.at : null;
167
+ O(() => {
168
+ if (Ja === null) return;
169
+ let e = window.setTimeout(() => qa(Ja), Ii);
168
170
  return () => window.clearTimeout(e);
169
- }, [qa]);
170
- let { canUseApiCalls: Ja, loading: Ya } = Or(C(), L), Xa = k(Dt({
171
- loading: Ya,
172
- canUseAdminModes: Ja
173
- })).current, Za = k(F);
174
- D(() => {
175
- Za.current = F;
176
- }, [F]);
177
- let Qa = () => {
178
- let e = v.getState().activeConversationId;
179
- e && ar.openConversation(e, { modes: Za.current });
180
- }, $a = () => {
181
- let e = v.getState().activeConversationId;
171
+ }, [Ja]);
172
+ let { canUseApiCalls: Ya, loading: Xa } = Or(w(), z), Za = A(Et({
173
+ loading: Xa,
174
+ canUseAdminModes: Ya
175
+ })).current, Qa = A(I);
176
+ O(() => {
177
+ Qa.current = I;
178
+ }, [I]);
179
+ let $a = () => {
180
+ let e = y.getState().activeConversationId;
181
+ e && ar.openConversation(e, { modes: Qa.current });
182
+ }, eo = () => {
183
+ let e = y.getState().activeConversationId;
182
184
  e && ar.loadEarlier(e);
183
- }, eo = k(Zi);
184
- D(() => {
185
- eo.current = Zi;
186
- }, [Zi]);
187
- let to = !!P && qi !== !1;
188
- D(() => {
189
- if (to) return bn({ send: (e) => yn(e, {
190
- workspaceId: C(),
185
+ }, to = A(R);
186
+ O(() => {
187
+ to.current = R;
188
+ }, [R]);
189
+ let no = !!F && Ji !== !1;
190
+ O(() => {
191
+ if (no) return bn({ send: (e) => yn(e, {
192
+ workspaceId: w(),
191
193
  authContext: {
192
- accessToken: eo.current(),
193
- organizationId: Pt()
194
+ accessToken: to.current(),
195
+ organizationId: Nt()
194
196
  }
195
197
  }) });
196
- }, [to]), D(() => {
197
- Xa.update({
198
- loading: Ya,
199
- canUseAdminModes: Ja
198
+ }, [no]), O(() => {
199
+ Za.update({
200
+ loading: Xa,
201
+ canUseAdminModes: Ya
200
202
  });
201
203
  }, [
204
+ Za,
202
205
  Xa,
203
- Ya,
204
- Ja
205
- ]), D(() => () => {
206
- Xa.abandon();
207
- }, [Xa]);
208
- let no = O(() => F.filter((e) => !e.requiresAdmin || Ja), [F, Ja]), ro = ne(no), io = Da && ro, ao = k(ro);
209
- D(() => {
210
- ao.current = ro;
211
- }, [ro]);
212
- let oo = k(null), so = k(!1), [co, lo] = A(!1), uo = ht(F), [fo, po] = A(null), [mo, ho] = A(null), go = mo !== null && mo === z, K = Sn(), _o = Cn(), q = K.open && _o !== null, vo = K.close, yo = k(q);
213
- Oi(() => {
214
- yo.current = q;
206
+ Ya
207
+ ]), O(() => () => {
208
+ Za.abandon();
209
+ }, [Za]);
210
+ let ro = k(() => I.filter((e) => !e.requiresAdmin || Ya), [I, Ya]), io = ne(ro), ao = Da && io, oo = A(io);
211
+ O(() => {
212
+ oo.current = io;
213
+ }, [io]);
214
+ let so = A(null), co = A(!1), [lo, uo] = j(!1), fo = mt(I), [po, mo] = j(null), [ho, go] = j(null), _o = ho !== null && ho === V, vo = Sn(), yo = Cn(), q = vo.open && yo !== null, bo = vo.close, xo = A(q);
215
+ ki(() => {
216
+ xo.current = q;
215
217
  }, [q]);
216
- let bo = E((e) => {
217
- e && yo.current || ho(e ? v.getState().activeConversationId : null);
218
+ let So = D((e) => {
219
+ e && xo.current || go(e ? y.getState().activeConversationId : null);
218
220
  }, []);
219
- D(() => {
220
- ho((e) => e !== null && e !== z ? null : e);
221
- }, [z]);
222
- let xo = k(void 0), [So, Co] = A(!1), wo = E((e) => {
223
- xo.current = e, Co(ot(e));
224
- }, []), To = E(() => {
225
- let e = v.getState(), t = e.activeConversationId, n = t ? e.conversations.find((e) => e.id === t) : void 0;
221
+ O(() => {
222
+ go((e) => e !== null && e !== V ? null : e);
223
+ }, [V]);
224
+ let Co = A(void 0), [wo, To] = j(!1), Eo = D((e) => {
225
+ Co.current = e, To(at(e));
226
+ }, []), Do = D(() => {
227
+ let e = y.getState(), t = e.activeConversationId, n = t ? e.conversations.find((e) => e.id === t) : void 0;
226
228
  return !t || !n ? null : {
227
229
  id: t,
228
230
  reusableDraft: rr(n, ie()),
229
- liveProposals: G.liveFor(t).count,
230
- turnInFlight: It(e.processingByConversationId[t]?.status)
231
+ liveProposals: K.liveFor(t).count,
232
+ turnInFlight: Ft(e.processingByConversationId[t]?.status)
231
233
  };
232
- }, [G]), Eo = k({}), J = k(Dn()), Do = k(new Nr()), Oo = k(/* @__PURE__ */ new Set()), ko = O(() => F.find((e) => e.id === B), [F, B]), Ao = v((e) => {
233
- let t = e.sandboxesByMode[B]?.sandboxId;
234
+ }, [K]), Oo = A({}), ko = A(Dn()), Ao = A(new Nr()), jo = A(/* @__PURE__ */ new Set()), Mo = k(() => I.find((e) => e.id === H), [I, H]), No = y((e) => {
235
+ let t = e.sandboxesByMode[H]?.sandboxId;
234
236
  return t ? e.sandboxWriteCapabilities[t] : void 0;
235
- }), jo = ko !== void 0 && bt({
236
- mode: B,
237
- productWriteApproval: I,
238
- capabilities: Ao
239
- }), Mo = B === "assistant" || ko !== void 0 && !ko.writeCapable && !Ce(B) || jo;
240
- D(() => {
241
- if (B !== "assistant" && ko?.writeCapable && !de(Ta, B)) {
237
+ }), Po = Mo !== void 0 && yt({
238
+ mode: H,
239
+ productWriteApproval: L,
240
+ capabilities: No
241
+ }), Fo = H === "assistant" || Mo !== void 0 && !Mo.writeCapable && !Se(H) || Po;
242
+ O(() => {
243
+ if (H !== "assistant" && Mo?.writeCapable && !de(Ta, H)) {
242
244
  fa("assistant");
243
245
  return;
244
246
  }
245
- Ya || (!ko || ko.requiresAdmin && !Ja) && B !== "assistant" && fa("assistant");
247
+ Xa || (!Mo || Mo.requiresAdmin && !Ya) && H !== "assistant" && fa("assistant");
246
248
  }, [
247
- B,
248
- ko,
249
- Ja,
249
+ H,
250
+ Mo,
250
251
  Ya,
252
+ Xa,
251
253
  fa,
252
254
  Ta
253
255
  ]);
254
- let No = E((e, t, n, r) => {
256
+ let Io = D((e, t, n, r) => {
255
257
  ya(e, n, t, null, r);
256
- }, [ya]), Po = E(async (e, t, n, r, i, a = null) => {
258
+ }, [ya]), Lo = D(async (e, t, n, r, i, a = null) => {
257
259
  let o = (e, t) => {
258
- r && No(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
260
+ r && Io(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
259
261
  }, s = (e) => {
260
- r && T(r.assistantMessageId, e);
262
+ r && E(r.assistantMessageId, e);
261
263
  }, c = () => {
262
264
  s("bootAdopted"), a?.beginBoot();
263
- }, l = () => a !== null && (a.signal.aborted || C() !== t), u = () => {
265
+ }, l = () => a !== null && (a.signal.aborted || w() !== t), u = () => {
264
266
  if (l()) throw new Pr("cancelled");
265
- }, d = v.getState().sandboxesByMode[e]?.sandboxId ?? null, p = !1, ee = !1, m = !1, te = !1, ne = !1, re = async (r) => {
266
- if (i && !Do.current.has(r) && J.current.isFresh(r)) return p = !0, !0;
267
+ }, d = y.getState().sandboxesByMode[e]?.sandboxId ?? null, p = !1, ee = !1, m = !1, te = !1, ne = !1, re = async (r) => {
268
+ if (i && !Ao.current.has(r) && ko.current.isFresh(r)) return p = !0, !0;
267
269
  m = !0;
268
270
  let o = !1;
269
271
  try {
270
- await ke(r, t, n, 3e5), await Oe(r, t, e, n, 9e4, () => {
272
+ await Oe(r, t, n, 3e5), await De(r, t, e, n, 9e4, () => {
271
273
  o = !0, c();
272
274
  });
273
275
  } catch {
274
276
  if (l()) throw new Pr("cancelled");
275
- return J.current.invalidate(r), Do.current.add(r), a?.dead.push(r), ne = !0, !1;
277
+ return ko.current.invalidate(r), Ao.current.add(r), a?.dead.push(r), ne = !0, !1;
276
278
  }
277
- return u(), J.current.markVerified(r), o && (te = !0), !0;
279
+ return u(), ko.current.markVerified(r), o && (te = !0), !0;
278
280
  };
279
281
  if (d && (Ca(e, d, "provisioning"), o("provisioning", "reusingEnvironment"), await re(d) || (Ca(e, null, "provisioning"), d = null)), !d) {
280
282
  o("provisioning", "lookingForEnvironment");
281
- let r = await ve(t, P, e, Si(), n, Do.current, I);
283
+ let r = await _e(t, F, e, Si(), n, Ao.current, L);
282
284
  u();
283
285
  let i = r?.id ?? null;
284
286
  if (i) {
@@ -289,23 +291,23 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
289
291
  }
290
292
  if (!d) {
291
293
  if (a && !a.mayCreate) throw new Pr("no-create");
292
- if (s("provisionStarted"), e === "api-calls" && !Zi()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
294
+ if (s("provisionStarted"), e === "api-calls" && !R()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
293
295
  o("provisioning", "startingEnvironment"), Ca(e, null, "provisioning");
294
- let r = a ? [] : await Ee(t, P, e, Si(), n, Do.current, I);
296
+ let r = a ? [] : await Te(t, F, e, Si(), n, Ao.current, L);
295
297
  if (r.length > 0) {
296
298
  let e = new Set(r);
297
- for (let e of r) J.current.invalidate(e), Do.current.add(e);
298
- let t = v.getState().sandboxesByMode;
299
+ for (let e of r) ko.current.invalidate(e), Ao.current.add(e);
300
+ let t = y.getState().sandboxesByMode;
299
301
  for (let [n, r] of Object.entries(t)) f(n) && r?.sandboxId && e.has(r.sandboxId) && wa(n);
300
302
  }
301
303
  s("createRequested");
302
304
  let i = a?.beginCreate();
303
305
  try {
304
- d = await ge(P, e, t, Si(), Mi, n, { writeApproval: I });
306
+ d = await he(F, e, t, Si(), Ni, n, { writeApproval: L });
305
307
  } finally {
306
308
  i?.();
307
309
  }
308
- ee = !0, u(), Ca(e, d, "provisioning"), await ke(d, t, n, 3e5), u(), s("sandboxRunning"), await Oe(d, t, e, n, 9e4), u(), s("serviceReady"), J.current.markVerified(d);
310
+ ee = !0, u(), Ca(e, d, "provisioning"), await Oe(d, t, n, 3e5), u(), s("sandboxRunning"), await De(d, t, e, n, 9e4), u(), s("serviceReady"), ko.current.markVerified(d);
309
311
  }
310
312
  return Ca(e, d, "running"), {
311
313
  sandboxId: d,
@@ -317,25 +319,25 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
317
319
  };
318
320
  }, [
319
321
  wa,
320
- Zi,
321
- P,
322
- I,
322
+ R,
323
+ F,
324
+ L,
323
325
  Ca,
324
- No
325
- ]), Fo = E(async function e(t, n, r, i, a, o = {}) {
326
- let s = await Br(i, r, (e) => No(t, n, "provisioning", e), () => T(n, "prewarmJoined"));
327
- for (let e of s.dead) J.current.invalidate(e), Do.current.add(e);
328
- s.verified && !Do.current.has(s.verified) && J.current.markVerified(s.verified), s.joined && w(n, { prewarm: s.joined });
329
- let { sandboxId: c, sandboxIsNew: l, sandboxProbed: u, sandboxAdopted: d, deadSandboxProbe: f, trustedFromCache: p } = await Po(r, i, a, {
326
+ Io
327
+ ]), Ro = D(async function e(t, n, r, i, a, o = {}) {
328
+ let s = await Br(i, r, (e) => Io(t, n, "provisioning", e), () => E(n, "prewarmJoined"));
329
+ for (let e of s.dead) ko.current.invalidate(e), Ao.current.add(e);
330
+ s.verified && !Ao.current.has(s.verified) && ko.current.markVerified(s.verified), s.joined && T(n, { prewarm: s.joined });
331
+ let { sandboxId: c, sandboxIsNew: l, sandboxProbed: u, sandboxAdopted: d, deadSandboxProbe: f, trustedFromCache: p } = await Lo(r, i, a, {
330
332
  conversationId: t,
331
333
  assistantMessageId: n
332
334
  }, o.trustCache !== !1), ee = Ir(i, r, c);
333
- !s.waited && ee && w(n, { prewarm: "hit" });
334
- let m = v.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, te = !1, ne = null;
335
+ !s.waited && ee && T(n, { prewarm: "hit" });
336
+ let m = y.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, te = !1, ne = null;
335
337
  if (m) {
336
- let e = ln(c, m, (e, t) => be(e, i, t, r, a, { limit: 50 }));
338
+ let e = cn(c, m, (e, t) => ye(e, i, t, r, a, { limit: 50 }));
337
339
  try {
338
- let t = await xe(c, i, m, r, a);
340
+ let t = await be(c, i, m, r, a);
339
341
  if (t.mode !== r) throw Error(`Session mode mismatch: expected ${r}, received ${t.mode}`);
340
342
  ne = e;
341
343
  } catch {
@@ -348,32 +350,32 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
348
350
  workspaceId: i,
349
351
  mode: r,
350
352
  sandboxId: c,
351
- userId: L
353
+ userId: z
352
354
  }), Date.now());
353
355
  if (e) {
354
- "pending" in e && No(t, n, "connecting", "preparingSession");
356
+ "pending" in e && Io(t, n, "connecting", "preparingSession");
355
357
  let o = "sessionId" in e ? e.sessionId : await e.pending;
356
- if (o && !Do.current.has(c)) try {
357
- (await xe(c, i, o, r, a)).mode === r && (m = o, re = !0, xa(t, m), te = !0);
358
+ if (o && !Ao.current.has(c)) try {
359
+ (await be(c, i, o, r, a)).mode === r && (m = o, re = !0, xa(t, m), te = !0);
358
360
  } catch {}
359
361
  }
360
362
  }
361
363
  if (!m) {
362
- No(t, n, "connecting", "preparingSession");
364
+ Io(t, n, "connecting", "preparingSession");
363
365
  let s;
364
366
  try {
365
- s = await y(c, i, r, a);
367
+ s = await b(c, i, r, a);
366
368
  } catch (s) {
367
369
  if (p) {
368
- J.current.invalidate(c);
370
+ ko.current.invalidate(c);
369
371
  let l = kn(s, o.isAbandoned?.() ?? !1), p = l === "check-network";
370
- if (l === "check-network" && (l = await On(() => ve(i, P, r, Si(), a, Do.current, I))), l !== "rethrow" && o.isAbandoned?.() && (l = "rethrow"), l !== "rethrow") {
371
- p || w(n, { cacheProofFailed: !0 }), l === "replace" && (Do.current.add(c), Sa(t), wa(r), G.retireSandbox(c));
372
+ if (l === "check-network" && (l = await On(() => _e(i, F, r, Si(), a, Ao.current, L))), l !== "rethrow" && o.isAbandoned?.() && (l = "rethrow"), l !== "rethrow") {
373
+ p || T(n, { cacheProofFailed: !0 }), l === "replace" && (Ao.current.add(c), Sa(t), wa(r), K.retireSandbox(c));
372
374
  let s = await e(t, n, r, i, a, {
373
375
  ...o,
374
376
  trustCache: !1
375
377
  });
376
- return p && (s.deadSandboxProbe || s.sandboxId !== c) && w(n, { cacheProofFailed: !0 }), {
378
+ return p && (s.deadSandboxProbe || s.sandboxId !== c) && T(n, { cacheProofFailed: !0 }), {
377
379
  ...s,
378
380
  sandboxProbed: s.sandboxProbed || u,
379
381
  sandboxAdopted: s.sandboxAdopted || d,
@@ -397,49 +399,49 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
397
399
  sessionPreopened: re
398
400
  };
399
401
  }, [
400
- Po,
402
+ Lo,
401
403
  Sa,
402
404
  wa,
403
- P,
404
- I,
405
- xa,
406
- No,
405
+ F,
407
406
  L,
408
- G
409
- ]), Io = E((e, t = !1) => {
410
- let n = C();
407
+ xa,
408
+ Io,
409
+ z,
410
+ K
411
+ ]), zo = D((e, t = !1) => {
412
+ let n = w();
411
413
  if (!n) return;
412
- let r = v.getState(), i = Date.now(), a = zr({
414
+ let r = y.getState(), i = Date.now(), a = zr({
413
415
  autoRouting: r.autoRouting,
414
- autoOffered: ao.current,
416
+ autoOffered: oo.current,
415
417
  active: !t && r.activeConversationId ? r.conversations.find((e) => e.id === r.activeConversationId) : void 0,
416
418
  selectedMode: r.mode,
417
419
  autoReadMode: p,
418
- modes: Za.current,
420
+ modes: Qa.current,
419
421
  acknowledgedWriteModes: r.acknowledgedWriteModes,
420
- adminAccess: Xa.read(),
422
+ adminAccess: Za.read(),
421
423
  dictated: e,
422
- voiceProposalBound: (e) => Xi(e),
423
- turnInFlight: Object.values(r.processingByConversationId).some((e) => It(e?.status)),
424
+ voiceProposalBound: (e) => Zi(e),
425
+ turnInFlight: Object.values(r.processingByConversationId).some((e) => Ft(e?.status)),
424
426
  ...Ur(n),
425
427
  now: i
426
428
  });
427
429
  if (!a) return;
428
430
  let o = Hr(n, a, i), s = {
429
- accessToken: Zi(),
431
+ accessToken: R(),
430
432
  workspaceToken: Qi(),
431
- userId: L,
432
- organizationId: Pt()
433
+ userId: z,
434
+ organizationId: Nt()
433
435
  };
434
- Po(a.mode, n, s, null, !0, o).then((e) => {
436
+ Lo(a.mode, n, s, null, !0, o).then((e) => {
435
437
  if (o.finish({
436
438
  ok: !0,
437
439
  sandboxId: e.sandboxId,
438
440
  didWork: !e.trustedFromCache && (e.sandboxIsNew || e.sandboxProbed || e.sandboxAdopted),
439
441
  booted: e.sandboxIsNew || e.sandboxAdopted,
440
442
  dead: o.dead
441
- }), o.signal.aborted || C() !== n || Do.current.has(e.sandboxId)) return;
442
- let r = v.getState(), i = !t && r.activeConversationId ? r.conversations.find((e) => e.id === r.activeConversationId) : void 0, c = ie();
443
+ }), o.signal.aborted || w() !== n || Ao.current.has(e.sandboxId)) return;
444
+ let r = y.getState(), i = !t && r.activeConversationId ? r.conversations.find((e) => e.id === r.activeConversationId) : void 0, c = ie();
443
445
  Rr({
444
446
  active: i ? {
445
447
  mode: i.mode,
@@ -452,12 +454,12 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
452
454
  workspaceId: n,
453
455
  mode: a.mode,
454
456
  sandboxId: e.sandboxId,
455
- userId: L
456
- }), () => y(e.sandboxId, n, a.mode, s).then((e) => e.sessionId), Date.now());
457
+ userId: z
458
+ }), () => b(e.sandboxId, n, a.mode, s).then((e) => e.sessionId), Date.now());
457
459
  }, (e) => {
458
- if (!(e instanceof Pr) && !o.signal.aborted && C() === n) {
459
- let e = v.getState().sandboxesByMode[a.mode]?.sandboxId ?? null;
460
- e && (J.current.invalidate(e), Do.current.add(e), o.dead.push(e), wa(a.mode));
460
+ if (!(e instanceof Pr) && !o.signal.aborted && w() === n) {
461
+ let e = y.getState().sandboxesByMode[a.mode]?.sandboxId ?? null;
462
+ e && (ko.current.invalidate(e), Ao.current.add(e), o.dead.push(e), wa(a.mode));
461
463
  }
462
464
  o.finish({
463
465
  ok: !1,
@@ -467,52 +469,52 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
467
469
  });
468
470
  });
469
471
  }, [
470
- Po,
471
- Xa,
472
+ Lo,
473
+ Za,
472
474
  wa,
473
- Zi,
475
+ R,
474
476
  Qi,
475
- L,
476
- Xi
477
- ]), Lo = k(!1), Ro = k(null), zo = O(() => wi(), []);
478
- D(() => () => zo.cancel(), [zo]);
479
- let Bo = ki(_, se, se)?.reference ?? null, [Vo, Ho] = A(0), Uo = k(/* @__PURE__ */ new Set()), Wo = k(null), Go = E(() => {
480
- let e = v.getState(), t = e.activeConversationId;
477
+ z,
478
+ Zi
479
+ ]), Bo = A(!1), Vo = A(null), Ho = k(() => wi(), []);
480
+ O(() => () => Ho.cancel(), [Ho]);
481
+ let Uo = Ai(_, se, se)?.reference ?? null, [Wo, Go] = j(0), Ko = A(/* @__PURE__ */ new Set()), qo = A(null), Jo = D(() => {
482
+ let e = y.getState(), t = e.activeConversationId;
481
483
  if (!t) return null;
482
- let n = e.processingByConversationId[t], r = It(n?.status) ? n?.messageId ?? null : null;
483
- if (!Rt({
484
+ let n = e.processingByConversationId[t], r = Ft(n?.status) ? n?.messageId ?? null : null;
485
+ if (!Lt({
484
486
  interruptedTurnId: r,
485
487
  activeTurnId: r,
486
- alreadyRequested: r ? Uo.current.has(r) : !1
488
+ alreadyRequested: r ? Ko.current.has(r) : !1
487
489
  }).send || !r) return null;
488
- Uo.current.add(r);
489
- let i = pe(e), a = C(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
490
- return !i || !a || !o || me(i.sandboxId, a, o, i.mode, {
491
- accessToken: Zi(),
490
+ Ko.current.add(r);
491
+ let i = v(e), a = w(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
492
+ return !i || !a || !o || pe(i.sandboxId, a, o, i.mode, {
493
+ accessToken: R(),
492
494
  workspaceToken: Qi(),
493
- userId: L,
494
- organizationId: Pt()
495
+ userId: z,
496
+ organizationId: Nt()
495
497
  }), r;
496
498
  }, [
497
- L,
498
- Zi,
499
+ z,
500
+ R,
499
501
  Qi
500
- ]), Ko = E(() => {
501
- let e = Go();
502
- return e && (Ze(e), qe.abort(e)), e;
503
- }, [Go]), qo = E(() => {
504
- let e = v.getState().activeConversationId;
505
- Ko(), e && G.declineForReply(e, "corrected", "spoken");
506
- }, [Ko, G]), Jo = E(async (e) => {
507
- let t = v.getState(), n = pe(t), r = C(), i = t.activeConversationId;
502
+ ]), Yo = D(() => {
503
+ let e = Jo();
504
+ return e && (Xe(e), Ke.abort(e)), e;
505
+ }, [Jo]), Xo = D(() => {
506
+ let e = y.getState().activeConversationId;
507
+ Yo(), e && K.declineForReply(e, "corrected", "spoken");
508
+ }, [Yo, K]), Zo = D(async (e) => {
509
+ let t = y.getState(), n = v(t), r = w(), i = t.activeConversationId;
508
510
  if (!n || !r || !i || Bn(t.sandboxWriteCapabilities[n.sandboxId])) return;
509
- let a = t.conversations.find((e) => e.id === i), o = a ? le(x(a.messages), {
511
+ let a = t.conversations.find((e) => e.id === i), o = a ? le(S(a.messages), {
510
512
  sessionId: a.backendSessionId,
511
513
  sandboxId: n.sandboxId,
512
514
  nowMs: Date.now()
513
515
  }) : null;
514
516
  if (o?.reference !== e) {
515
- Ho((e) => e + 1);
517
+ Go((e) => e + 1);
516
518
  return;
517
519
  }
518
520
  let s = {
@@ -521,15 +523,15 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
521
523
  };
522
524
  if (!oe(s)) return;
523
525
  try {
524
- await he(n.sandboxId, r, e, n.mode, {
525
- accessToken: Zi(),
526
+ await me(n.sandboxId, r, e, n.mode, {
527
+ accessToken: R(),
526
528
  workspaceToken: Qi(),
527
- userId: L,
528
- organizationId: Pt()
529
+ userId: z,
530
+ organizationId: Nt()
529
531
  });
530
532
  } catch (e) {
531
- h(s), V(i, {
532
- id: M(),
533
+ h(s), U(i, {
534
+ id: N(),
533
535
  role: "system",
534
536
  content: e instanceof Error ? e.message : "The change could not be approved.",
535
537
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
@@ -537,69 +539,69 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
537
539
  return;
538
540
  }
539
541
  h(s), va(i, o.messageId, { pendingWriteApprovedAt: (/* @__PURE__ */ new Date()).toISOString() });
540
- let c = v.getState(), l = c.conversations.find((e) => e.id === i);
541
- c.activeConversationId !== i || !l || c.mode !== n.mode || l.backendSessionId !== a?.backendSessionId || pe(c)?.sandboxId !== n.sandboxId || It(c.processingByConversationId[i]?.status) || g(x(l.messages)) !== o.messageId || $s.current(N("pendingWrite.approvedPrompt", "I approved that change — go ahead."), [], {
542
+ let c = y.getState(), l = c.conversations.find((e) => e.id === i);
543
+ c.activeConversationId !== i || !l || c.mode !== n.mode || l.backendSessionId !== a?.backendSessionId || v(c)?.sandboxId !== n.sandboxId || Ft(c.processingByConversationId[i]?.status) || g(S(l.messages)) !== o.messageId || nc.current(P("pendingWrite.approvedPrompt", "I approved that change — go ahead."), [], {
542
544
  approvalFollowUp: { approvedReplyId: o.messageId },
543
545
  targetConversationId: i
544
546
  });
545
547
  }, [
546
- L,
547
- V,
548
+ z,
549
+ U,
548
550
  va,
549
- N
550
- ]), Yo = n(), { speakFinishedReply: Xo, speakingMessageId: Zo, stop: Qo } = xn(), $o = k(null), es = E((e, t) => {
551
- let n = $o.current;
551
+ P
552
+ ]), Qo = n(), { speakFinishedReply: $o, speakingMessageId: es, stop: ts } = xn(), ns = A(null), rs = D((e, t) => {
553
+ let n = ns.current;
552
554
  n?.token === e && n.exchange === null && (n.exchange = t);
553
- }, []), ts = E((e) => {
554
- let t = $o.current;
555
+ }, []), is = D((e) => {
556
+ let t = ns.current;
555
557
  e !== void 0 && t?.token === e && (t.handled = !0);
556
- }, []), ns = E((e, t) => {
557
- es(e, t), yo.current && Je(t);
558
- }, [es]), rs = c(), { items: is, permissionsSettled: as, simulating: os } = Di(), Y = k({
559
- theme: Yo,
560
- navigate: rs,
561
- navItems: is,
562
- options: Yi ?? {},
563
- navPermissionsSettled: as,
564
- navSimulating: os
558
+ }, []), as = D((e, t) => {
559
+ rs(e, t), xo.current && qe(t);
560
+ }, [rs]), os = c(), { items: ss, permissionsSettled: cs, simulating: ls } = Oi(), J = A({
561
+ theme: Qo,
562
+ navigate: os,
563
+ navItems: ss,
564
+ options: Xi ?? {},
565
+ navPermissionsSettled: cs,
566
+ navSimulating: ls
565
567
  });
566
- D(() => {
567
- Y.current = {
568
- theme: Yo,
569
- navigate: rs,
570
- navItems: is,
571
- options: Yi ?? {},
572
- navPermissionsSettled: as,
573
- navSimulating: os
568
+ O(() => {
569
+ J.current = {
570
+ theme: Qo,
571
+ navigate: os,
572
+ navItems: ss,
573
+ options: Xi ?? {},
574
+ navPermissionsSettled: cs,
575
+ navSimulating: ls
574
576
  };
575
577
  }, [
576
- Yo,
577
- rs,
578
- is,
579
- Yi,
580
- as,
581
- os
578
+ Qo,
579
+ os,
580
+ ss,
581
+ Xi,
582
+ cs,
583
+ ls
582
584
  ]);
583
- let X = k(!0);
584
- D(() => (X.current = !0, () => {
585
- X.current = !1;
585
+ let Y = A(!0);
586
+ O(() => (Y.current = !0, () => {
587
+ Y.current = !1;
586
588
  }), []);
587
- let ss = k({
588
- tr: N,
589
- locale: R
590
- }), cs = k(null), [ls, us] = A(null), ds = k(null), fs = E((e) => {
591
- ds.current !== null && (window.clearTimeout(ds.current), ds.current = null);
592
- let t = cs.current;
593
- t && (cs.current = null, window.clearTimeout(t.deadline), X.current && us(null), !(!e || !X.current) && (ds.current = window.setTimeout(() => {
594
- if (ds.current = null, !X.current) return;
595
- let e = v.getState();
589
+ let us = A({
590
+ tr: P,
591
+ locale: B
592
+ }), ds = A(null), [fs, ps] = j(null), ms = A(null), hs = D((e) => {
593
+ ms.current !== null && (window.clearTimeout(ms.current), ms.current = null);
594
+ let t = ds.current;
595
+ t && (ds.current = null, window.clearTimeout(t.deadline), Y.current && ps(null), !(!e || !Y.current) && (ms.current = window.setTimeout(() => {
596
+ if (ms.current = null, !Y.current) return;
597
+ let e = y.getState();
596
598
  if (e.activeConversationId !== t.conversationId) return;
597
599
  let n = e.conversations.find((e) => e.id === t.conversationId)?.messages.find((e) => e.id === t.messageId);
598
600
  if (!n) return;
599
- let r = ss.current, i = rn(n, null, r.tr);
601
+ let r = us.current, i = nn(n, null, r.tr);
600
602
  if (i.kind !== "output") return;
601
- let a = tn(n, r.tr);
602
- qe.publish(n.id, {
603
+ let a = en(n, r.tr);
604
+ Ke.publish(n.id, {
603
605
  conversationId: t.conversationId,
604
606
  channel: n.metadata?.voice === !0 ? "voice" : "chat",
605
607
  voiceSessionId: n.metadata?.voiceSessionId,
@@ -608,48 +610,48 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
608
610
  final: !0
609
611
  });
610
612
  }, 0)));
611
- }, []), ps = E(() => fs(!0), [fs]);
612
- D(() => {
613
- ss.current = {
614
- tr: N,
615
- locale: R
613
+ }, []), gs = D(() => hs(!0), [hs]);
614
+ O(() => {
615
+ us.current = {
616
+ tr: P,
617
+ locale: B
616
618
  };
617
- let e = cs.current;
619
+ let e = ds.current;
618
620
  if (!e) return;
619
- let t = nn({
621
+ let t = tn({
620
622
  wanted: e.wanted,
621
- locale: R,
623
+ locale: B,
622
624
  isLoading: $i(e.wanted),
623
- translatedNow: $t(N, e.reply).translated
625
+ translatedNow: Qt(P, e.reply).translated
624
626
  });
625
627
  if (t === "write") {
626
- ps();
628
+ gs();
627
629
  return;
628
630
  }
629
631
  if (t === "grace") {
630
- let e = window.setTimeout(ps, 400);
632
+ let e = window.setTimeout(gs, 400);
631
633
  return () => window.clearTimeout(e);
632
634
  }
633
635
  }, [
634
- N,
635
- R,
636
+ P,
637
+ B,
636
638
  $i,
637
- ls,
638
- ps
639
- ]), D(() => () => fs(!1), [fs]);
640
- let ms = k(null), [hs, gs] = A(!1), [_s, vs] = A(null), [Z] = A(() => new Ae()), [ys, bs] = A(0), xs = E(() => bs((e) => e + 1), []), Ss = E(() => {
641
- let e = Y.current;
639
+ fs,
640
+ gs
641
+ ]), O(() => () => hs(!1), [hs]);
642
+ let _s = A(null), [vs, ys] = j(!1), [bs, xs] = j(null), [X] = j(() => new ke()), [Ss, Cs] = j(0), ws = D(() => Cs((e) => e + 1), []), Ts = D(() => {
643
+ let e = J.current;
642
644
  return {
643
645
  destinations: Xr(e.navItems),
644
646
  permissionsSettled: e.navPermissionsSettled,
645
647
  simulating: e.navSimulating
646
648
  };
647
- }, []), Cs = k(L);
648
- D(() => {
649
- Cs.current = L;
650
- }, [L]);
651
- let ws = E((e, t) => {
652
- let n = Z.replyIdOf(e), r = n ? Z.turnFor(n) : void 0, i = Z.offer(e), a = {
649
+ }, []), Es = A(z);
650
+ O(() => {
651
+ Es.current = z;
652
+ }, [z]);
653
+ let Ds = D((e, t) => {
654
+ let n = X.replyIdOf(e), r = n ? X.turnFor(n) : void 0, i = X.offer(e), a = {
653
655
  ok: !1,
654
656
  reason: "gone",
655
657
  copy: null,
@@ -657,59 +659,59 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
657
659
  voiceSessionId: void 0
658
660
  };
659
661
  if (!n || !r || !i || i.used) return a;
660
- let o = r.conversationId, s = v.getState().conversations.find((e) => e.id === o);
662
+ let o = r.conversationId, s = y.getState().conversations.find((e) => e.id === o);
661
663
  if (!s) return a;
662
- let c = s.messages.find((e) => e.id === n), l = c?.metadata?.voice === !0 ? c.metadata.voiceSessionId : void 0, u = Z.liveOffersFor(n, {
663
- registry: Ss(),
664
- actorId: Cs.current,
664
+ let c = s.messages.find((e) => e.id === n), l = c?.metadata?.voice === !0 ? c.metadata.voiceSessionId : void 0, u = X.liveOffersFor(n, {
665
+ registry: Ts(),
666
+ actorId: Es.current,
665
667
  conversationId: o,
666
668
  perfNow: performance.now()
667
669
  }).find((t) => t.offer.offerId === e);
668
670
  if (!u) {
669
- let e = Ne(i, performance.now());
671
+ let e = Me(i, performance.now());
670
672
  return {
671
673
  ok: !1,
672
674
  reason: e ? "unavailable" : "expired",
673
- copy: e ? Jt(N, t || null) : Kt(N),
675
+ copy: e ? qt(P, t || null) : Gt(P),
674
676
  conversationId: o,
675
677
  voiceSessionId: l
676
678
  };
677
679
  }
678
- return Z.markUsed(e) ? (xs(), {
680
+ return X.markUsed(e) ? (ws(), {
679
681
  ok: !0,
680
682
  target: u.target,
681
683
  conversationId: o,
682
684
  voiceSessionId: l
683
685
  }) : a;
684
686
  }, [
685
- Z,
686
- Ss,
687
- N,
688
- xs
689
- ]), Ts = E((e, t, n, r, i) => {
690
- let a = M();
691
- V(e, {
687
+ X,
688
+ Ts,
689
+ P,
690
+ ws
691
+ ]), Os = D((e, t, n, r, i) => {
692
+ let a = N();
693
+ U(e, {
692
694
  id: a,
693
695
  role: "system",
694
696
  content: n.text,
695
697
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
696
698
  metadata: {
697
- lang: n.translated ? R : "en",
699
+ lang: n.translated ? B : "en",
698
700
  ...i ? { localAction: i } : {},
699
- ...Ge(t)
701
+ ...We(t)
700
702
  }
701
703
  }), i && ar.recordCommittedEntries(e, [a], "NOTE", r);
702
- }, [V, R]), Es = E((e, t) => (t.status === "kept" || t.status === "refused" && t.reason === "unsaved-changes") && Z.release(e), [Z]), Ds = k(null);
703
- D(() => () => {
704
- Ds.current?.(), Ds.current = null;
704
+ }, [U, B]), ks = D((e, t) => (t.status === "kept" || t.status === "refused" && t.reason === "unsaved-changes") && X.release(e), [X]), As = A(null);
705
+ O(() => () => {
706
+ As.current?.(), As.current = null;
705
707
  }, []);
706
- let Os = E((e) => {
707
- Ds.current?.(), Ds.current = X.current ? fr(document, e) : null;
708
- }, []), ks = E((e, t, n, r = !1) => {
709
- if (ms.current !== null) return;
710
- let i = ws(e, n), a = C(), o = (e, t, n, r) => Ts(e, t, n, a, r);
708
+ let js = D((e) => {
709
+ As.current?.(), As.current = Y.current ? fr(document, e) : null;
710
+ }, []), Ms = D((e, t, n, r = !1) => {
711
+ if (_s.current !== null) return;
712
+ let i = Ds(e, n), a = w(), o = (e, t, n, r) => Os(e, t, n, a, r);
711
713
  if (!i.ok) {
712
- i.copy && i.conversationId && o(i.conversationId, i.voiceSessionId, i.copy), xs();
714
+ i.copy && i.conversationId && o(i.conversationId, i.voiceSessionId, i.copy), ws();
713
715
  return;
714
716
  }
715
717
  let { target: s, conversationId: c, voiceSessionId: l } = i, u = {
@@ -717,7 +719,7 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
717
719
  offerId: e
718
720
  };
719
721
  if (r) {
720
- o(c, l, Wt(N, s.label, !0), ii({
722
+ o(c, l, Ut(P, s.label, !0), ii({
721
723
  destinationId: s.id,
722
724
  path: s.path,
723
725
  alreadyHere: !0,
@@ -726,15 +728,15 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
726
728
  }));
727
729
  return;
728
730
  }
729
- let d = M();
730
- ms.current = d, gs(!0);
731
+ let d = N();
732
+ _s.current = d, ys(!0);
731
733
  let f = (t) => {
732
734
  try {
733
- if (Es(e, t) && (xs(), t.status === "kept" && Os(e)), t.status === "kept" || !v.getState().conversations.some((e) => e.id === c)) return;
735
+ if (ks(e, t) && (ws(), t.status === "kept" && js(e)), t.status === "kept" || !y.getState().conversations.some((e) => e.id === c)) return;
734
736
  let n = t.status === "arrived" || t.status === "redirected" ? t.landedPath : null;
735
- o(c, l, Gt(N, t, {
737
+ o(c, l, Wt(P, t, {
736
738
  page: s.label,
737
- landed: n === null ? null : oi(Xr(Y.current.navItems), n),
739
+ landed: n === null ? null : oi(Xr(J.current.navItems), n),
738
740
  path: s.path
739
741
  }), ii({
740
742
  destinationId: s.id,
@@ -745,89 +747,89 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
745
747
  offer: u
746
748
  }));
747
749
  } finally {
748
- ms.current === d && (ms.current = null, X.current && gs(!1));
750
+ _s.current === d && (_s.current = null, Y.current && ys(!1));
749
751
  }
750
752
  };
751
- ei(Y.current.navigate, s.path, {
753
+ ei(J.current.navigate, s.path, {
752
754
  readPath: () => window.location.pathname + window.location.search,
753
755
  now: () => Date.now(),
754
756
  schedule: (e, t) => {
755
757
  window.setTimeout(e, t);
756
758
  },
757
- isShellLess: () => !X.current,
759
+ isShellLess: () => !Y.current,
758
760
  initiator: t === "tap" ? "person" : "assistant",
759
761
  surface: "offer"
760
762
  }).then(f, () => f({ status: "unconfirmed" }));
761
763
  }, [
764
+ Ds,
765
+ Os,
766
+ P,
762
767
  ws,
763
- Ts,
764
- N,
765
- xs,
766
- Es,
767
- Os
768
- ]), As = E((e, t) => ks(e, "tap", t || null), [ks]), js = E((e) => {
769
- let { replyId: t, conversationId: n } = e, r = Z.turnFor(t);
768
+ ks,
769
+ js
770
+ ]), Ns = D((e, t) => Ms(e, "tap", t || null), [Ms]), Ps = D((e) => {
771
+ let { replyId: t, conversationId: n } = e, r = X.turnFor(t);
770
772
  if (!r) return;
771
- let i = window.location.pathname + window.location.search, a = Xr(Y.current.navItems), o = _i({
773
+ let i = window.location.pathname + window.location.search, a = Xr(J.current.navItems), o = _i({
772
774
  intent: e.intent,
773
- live: Z.liveOffersFor(t, {
774
- registry: Ss(),
775
- actorId: Cs.current,
775
+ live: X.liveOffersFor(t, {
776
+ registry: Ts(),
777
+ actorId: Es.current,
776
778
  conversationId: n,
777
779
  perfNow: performance.now()
778
780
  }),
779
- unusedCount: Z.offersFor(t).filter((e) => !e.used).length,
780
- pendingProposals: G.liveFor(n).count,
781
+ unusedCount: X.offersFor(t).filter((e) => !e.used).length,
782
+ pendingProposals: K.liveFor(n).count,
781
783
  turnWriteCapable: r.writeCapable,
782
784
  atSend: e.atSend,
783
785
  now: {
784
786
  location: i,
785
- conversationId: v.getState().activeConversationId,
786
- workspaceId: C(),
787
- actorId: Cs.current ?? null
787
+ conversationId: y.getState().activeConversationId,
788
+ workspaceId: w(),
789
+ actorId: Es.current ?? null
788
790
  },
789
- mounted: X.current,
791
+ mounted: Y.current,
790
792
  visible: document.visibilityState === "visible",
791
- unsavedChanges: vi(Y.current.options),
793
+ unsavedChanges: vi(J.current.options),
792
794
  alreadyThere: ({ target: e }) => {
793
795
  let t = a.find((t) => t.id === e.id);
794
796
  return t ? qr(t, i, a) : !1;
795
797
  }
796
798
  });
797
799
  if (o.act === "navigate" || o.act === "already-here") {
798
- ks(o.offer.offer.offerId, "resolve", o.offer.target.label, o.act === "already-here");
800
+ Ms(o.offer.offer.offerId, "resolve", o.offer.target.label, o.act === "already-here");
799
801
  return;
800
802
  }
801
- let [s] = o.unsaved ?? [], [c] = Z.liveOffersFor(t, {
802
- registry: Ss(),
803
- actorId: Cs.current,
803
+ let [s] = o.unsaved ?? [], [c] = X.liveOffersFor(t, {
804
+ registry: Ts(),
805
+ actorId: Es.current,
804
806
  conversationId: n,
805
807
  perfNow: performance.now()
806
808
  });
807
- o.hold === "R5-unsaved" && s && c && Ts(n, e.voiceSessionId, qt(N, s.label, c.target.label), C());
809
+ o.hold === "R5-unsaved" && s && c && Os(n, e.voiceSessionId, Kt(P, s.label, c.target.label), w());
808
810
  }, [
809
- Z,
810
- Ss,
811
- G,
812
- ks,
811
+ X,
813
812
  Ts,
814
- N
815
- ]), Ms = E((e) => {
816
- let t = v.getState(), n = t.conversations.find((e) => e.id === t.activeConversationId);
813
+ K,
814
+ Ms,
815
+ Os,
816
+ P
817
+ ]), Fs = D((e) => {
818
+ let t = y.getState(), n = t.conversations.find((e) => e.id === t.activeConversationId);
817
819
  return n ? ni(ti, window.location.pathname, si(n.messages, e)) : !1;
818
- }, []), Ns = lr(), Ps = ur(), Fs = Ns?.request ?? null, Is = E((e, t, n = !1, r = !1) => {
819
- let { navItems: i, options: a, theme: o, navigate: s } = Y.current, c = Xr(i), l = null, u = {
820
+ }, []), Is = lr(), Ls = ur(), Rs = Is?.request ?? null, zs = D((e, t, n = !1, r = !1) => {
821
+ let { navItems: i, options: a, theme: o, navigate: s } = J.current, c = Xr(i), l = null, u = {
820
822
  ...a,
821
- locale: t === void 0 ? R : oa.input.code,
822
- uiLocale: R,
823
+ locale: t === void 0 ? B : oa.input.code,
824
+ uiLocale: B,
823
825
  inputLocale: oa.input.code
824
826
  };
825
827
  if (r || Yr(e, u)) {
826
- let e = v.getState(), n = e.conversations.find((t) => t.id === e.activeConversationId), r = n ? li(n.messages, t, { lookThroughRefusedOffers: { ownsOffer: (e, t) => Z.offersFor(e.id).some((e) => e.offerId === t) } }) : null, o = n ? e.processingByConversationId[n.id] ?? null : null, s = o !== null && o.messageId === r?.id && It(o.status);
828
+ let e = y.getState(), n = e.conversations.find((t) => t.id === e.activeConversationId), r = n ? li(n.messages, t, { lookThroughRefusedOffers: { ownsOffer: (e, t) => X.offersFor(e.id).some((e) => e.offerId === t) } }) : null, o = n ? e.processingByConversationId[n.id] ?? null : null, s = o !== null && o.messageId === r?.id && Ft(o.status);
827
829
  if (n && r && !s) {
828
- let e = Z.liveOffersFor(r.id, {
829
- registry: Ss(),
830
- actorId: Cs.current,
830
+ let e = X.liveOffersFor(r.id, {
831
+ registry: Ts(),
832
+ actorId: Es.current,
831
833
  conversationId: n.id,
832
834
  perfNow: performance.now()
833
835
  }).flatMap(({ offer: e, target: t }) => {
@@ -839,12 +841,12 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
839
841
  });
840
842
  l = ci({
841
843
  reply: r,
842
- text: mn(r, o, N),
844
+ text: pn(r, o, P),
843
845
  resolve: {
844
846
  destinations: c,
845
847
  entityRoutes: a.entityRoutes,
846
848
  visibleNavIds: Wr(i),
847
- nounLabel: (e) => Ht(N, e)
849
+ nounLabel: (e) => Vt(P, e)
848
850
  },
849
851
  offers: e
850
852
  });
@@ -854,18 +856,18 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
854
856
  destinations: c,
855
857
  sentenceOptions: u,
856
858
  context: {
857
- backRunnable: Ms(t),
859
+ backRunnable: Fs(t),
858
860
  navigation: l,
859
861
  skipRecords: n,
860
862
  controls: $r(),
861
863
  executors: {
862
864
  theme: o !== null,
863
865
  navigation: s !== null,
864
- conversationDelete: Fs !== null,
866
+ conversationDelete: Rs !== null,
865
867
  appControl: (e) => {
866
868
  try {
867
- let n = yi(e, { voiceLive: t !== void 0 || zc.current });
868
- return n !== null && (n.kind !== "confirm" || Ps !== null);
869
+ let n = yi(e, { voiceLive: t !== void 0 || Hc.current });
870
+ return n !== null && (n.kind !== "confirm" || Ls !== null);
869
871
  } catch {
870
872
  return !1;
871
873
  }
@@ -874,38 +876,38 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
874
876
  }
875
877
  };
876
878
  }, [
877
- Ms,
878
- oa,
879
- R,
880
- N,
881
- Z,
882
- Ss,
883
879
  Fs,
884
- Ps
885
- ]), Ls = E((e, t, n = !1) => {
886
- let { destinations: r, sentenceOptions: i, context: a } = Is(e, t, n);
880
+ oa,
881
+ B,
882
+ P,
883
+ X,
884
+ Ts,
885
+ Rs,
886
+ Ls
887
+ ]), Bs = D((e, t, n = !1) => {
888
+ let { destinations: r, sentenceOptions: i, context: a } = zs(e, t, n);
887
889
  return Jr(e, r, i, a);
888
- }, [Is]), Rs = E((e) => {
889
- if (Ro.current = e, zo.cancel(), !e.text.trim() && !e.hasAttachments) {
890
- Lo.current = !1;
890
+ }, [zs]), Vs = D((e) => {
891
+ if (Vo.current = e, Ho.cancel(), !e.text.trim() && !e.hasAttachments) {
892
+ Bo.current = !1;
891
893
  return;
892
894
  }
893
- if (Lo.current) return;
895
+ if (Bo.current) return;
894
896
  let n = () => {
895
- Lo.current = !0, Io(!1);
897
+ Bo.current = !0, zo(!1);
896
898
  };
897
899
  if (e.hasAttachments || e.dictated) {
898
900
  n();
899
901
  return;
900
902
  }
901
- zo.schedule(() => {
902
- if (!Lo.current) {
903
+ Ho.schedule(() => {
904
+ if (!Bo.current) {
903
905
  try {
904
- let { destinations: t, sentenceOptions: n, context: r } = Is(e.text, void 0, !1, !0);
906
+ let { destinations: t, sentenceOptions: n, context: r } = zs(e.text, void 0, !1, !0);
905
907
  if (Kr(e.text, t, n, r)) return;
906
908
  } catch {
907
- if (!Ii) {
908
- Ii = !0;
909
+ if (!Li) {
910
+ Li = !0;
909
911
  try {
910
912
  t.getLogger("assistant").warn("Draft command classification failed; using standard warm-up.");
911
913
  } catch {}
@@ -915,37 +917,37 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
915
917
  }
916
918
  });
917
919
  }, [
920
+ Ho,
918
921
  zo,
919
- Io,
920
- Is
922
+ zs
921
923
  ]);
922
- D(() => {
924
+ O(() => {
923
925
  let e = () => {
924
- Ro.current && Rs(Ro.current);
926
+ Vo.current && Vs(Vo.current);
925
927
  }, t = i(e), n = ri(window, e), r = ti.subscribe(e);
926
928
  return () => {
927
- t(), n(), r(), zo.cancel();
929
+ t(), n(), r(), Ho.cancel();
928
930
  };
929
- }, [zo, Rs]), D(() => {
930
- Ro.current && Rs(Ro.current);
931
+ }, [Ho, Vs]), O(() => {
932
+ Vo.current && Vs(Vo.current);
931
933
  }, [
932
- Rs,
933
- is,
934
- Yi,
935
- as,
934
+ Vs,
935
+ ss,
936
+ Xi,
937
+ cs,
938
+ ls,
939
+ Qo,
936
940
  os,
937
- Yo,
938
- rs,
939
- B,
940
- ys,
941
- z,
942
- H?.messages,
943
- U
941
+ H,
942
+ Ss,
943
+ V,
944
+ W?.messages,
945
+ G
944
946
  ]);
945
- let zs = E((e, t) => {
946
- let n = Ls(e, t);
947
+ let Hs = D((e, t) => {
948
+ let n = Bs(e, t);
947
949
  if (!n) return !1;
948
- let { theme: r, navigate: i } = Y.current;
950
+ let { theme: r, navigate: i } = J.current;
949
951
  switch (n.kind) {
950
952
  case "theme": return r !== null;
951
953
  case "navigate":
@@ -955,40 +957,40 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
955
957
  case "link-not-openable":
956
958
  case "back": return i !== null;
957
959
  case "conversation-delete": return !1;
958
- case "app-control": return yi(n.request, { voiceLive: t !== void 0 || zc.current }) !== null;
960
+ case "app-control": return yi(n.request, { voiceLive: t !== void 0 || Hc.current }) !== null;
959
961
  case "open-record": return !1;
960
962
  }
961
- }, [Ls]), Bs = k(zs);
962
- D(() => {
963
- Bs.current = zs;
964
- }, [zs]);
965
- let Vs = E((e, t) => {
963
+ }, [Bs]), Us = A(Hs);
964
+ O(() => {
965
+ Us.current = Hs;
966
+ }, [Hs]);
967
+ let Ws = D((e, t) => {
966
968
  let n = {
967
969
  state: "none",
968
970
  accept: null
969
- }, { navigate: r, options: i, navItems: a } = Y.current;
971
+ }, { navigate: r, options: i, navItems: a } = J.current;
970
972
  if (!e || r === null || i.uiOffers !== !0) return n;
971
- let o = v.getState(), s = o.conversations.find((t) => t.id === e);
973
+ let o = y.getState(), s = o.conversations.find((t) => t.id === e);
972
974
  if (!s) return n;
973
975
  let c = o.processingByConversationId[s.id] ?? null, l = {
974
- registry: Ss(),
975
- actorId: Cs.current,
976
+ registry: Ts(),
977
+ actorId: Es.current,
976
978
  conversationId: s.id,
977
979
  perfNow: performance.now()
978
- }, { state: u, reply: d } = hi(Z, {
980
+ }, { state: u, reply: d } = hi(X, {
979
981
  ...l,
980
982
  messages: s.messages,
981
983
  voiceSessionId: t,
982
984
  processing: c,
983
- displayedText: (e) => mn(e, c, N),
984
- productWriteApproval: I,
985
- capabilitiesOf: (e) => v.getState().sandboxWriteCapabilities[e]
985
+ displayedText: (e) => pn(e, c, P),
986
+ productWriteApproval: L,
987
+ capabilitiesOf: (e) => y.getState().sandboxWriteCapabilities[e]
986
988
  });
987
989
  if (u !== "acceptable" || !d) return {
988
990
  state: u,
989
991
  accept: null
990
992
  };
991
- let [f] = Z.liveOffersFor(d.id, l), p = f ? Xr(a).find((e) => e.id === f.target.id) : void 0;
993
+ let [f] = X.liveOffersFor(d.id, l), p = f ? Xr(a).find((e) => e.id === f.target.id) : void 0;
992
994
  return !f || !p ? n : {
993
995
  state: u,
994
996
  accept: {
@@ -997,134 +999,134 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
997
999
  }
998
1000
  };
999
1001
  }, [
1000
- Z,
1001
- Ss,
1002
- I,
1003
- N
1004
- ]), Hs = E((e, t, n, r, i, a) => {
1005
- let o = N(n.key, n.fallback, r), s = n.fallback.replace(/\{\{\s*count\s*\}\}/g, String(r.count)), c = {
1002
+ X,
1003
+ Ts,
1004
+ L,
1005
+ P
1006
+ ]), Gs = D((e, t, n, r, i, a) => {
1007
+ let o = P(n.key, n.fallback, r), s = n.fallback.replace(/\{\{\s*count\s*\}\}/g, String(r.count)), c = {
1006
1008
  kind: "write-reply",
1007
1009
  line: n.key
1008
- }, l = (/* @__PURE__ */ new Date()).toISOString(), u = M();
1009
- V(e, {
1010
+ }, l = (/* @__PURE__ */ new Date()).toISOString(), u = N();
1011
+ U(e, {
1010
1012
  id: u,
1011
1013
  role: "user",
1012
1014
  content: t,
1013
1015
  timestamp: l,
1014
1016
  metadata: {
1015
1017
  localAction: c,
1016
- ...Ge(i)
1018
+ ...We(i)
1017
1019
  }
1018
1020
  });
1019
- let d = M();
1020
- V(e, {
1021
+ let d = N();
1022
+ U(e, {
1021
1023
  id: d,
1022
1024
  role: "assistant",
1023
1025
  content: o,
1024
1026
  timestamp: l,
1025
1027
  metadata: {
1026
- lang: o === s ? "en" : R,
1028
+ lang: o === s ? "en" : B,
1027
1029
  localAction: c,
1028
- ...Ge(i)
1030
+ ...We(i)
1029
1031
  }
1030
- }), ar.recordCommittedEntries(e, [u, d], "LOCAL_COMMAND", C()), a !== void 0 && ns(a, {
1032
+ }), ar.recordCommittedEntries(e, [u, d], "LOCAL_COMMAND", w()), a !== void 0 && as(a, {
1031
1033
  conversationId: e,
1032
1034
  questionId: u,
1033
1035
  replyId: d
1034
- }), Xo(e, d);
1036
+ }), $o(e, d);
1035
1037
  }, [
1036
- V,
1037
- R,
1038
- ns,
1039
- Xo,
1040
- N
1041
- ]), Us = k(() => void 0), [Ws, Gs] = A(null);
1042
- D(() => {
1043
- if (Ws === null) return;
1044
- let e = window.setTimeout(() => Gs(null), Ri);
1038
+ U,
1039
+ B,
1040
+ as,
1041
+ $o,
1042
+ P
1043
+ ]), Ks = A(() => void 0), [qs, Js] = j(null);
1044
+ O(() => {
1045
+ if (qs === null) return;
1046
+ let e = window.setTimeout(() => Js(null), zi);
1045
1047
  return () => window.clearTimeout(e);
1046
- }, [Ws]);
1047
- let Ks = E(() => {
1048
- let e = v.getState();
1049
- return ha(void 0, e.autoRouting && ao.current ? p : e.mode, e.autoRouting ? { routedBy: "auto" } : void 0);
1050
- }, [ha]), qs = E((e) => {
1051
- if (!Fs) return !1;
1052
- let t = e !== void 0, n = v.getState(), r = pr({
1048
+ }, [qs]);
1049
+ let Ys = D(() => {
1050
+ let e = y.getState();
1051
+ return ha(void 0, e.autoRouting && oo.current ? p : e.mode, e.autoRouting ? { routedBy: "auto" } : void 0);
1052
+ }, [ha]), Xs = D((e) => {
1053
+ if (!Rs) return !1;
1054
+ let t = e !== void 0, n = y.getState(), r = pr({
1053
1055
  spoken: t,
1054
- bound: xo.current,
1056
+ bound: Co.current,
1055
1057
  activeConversationId: n.activeConversationId,
1056
1058
  conversations: n.conversations,
1057
1059
  historyOn: cr()
1058
1060
  });
1059
- if (r && Fs(r), t) {
1060
- let e = r ? "Opened the delete confirmation. Choose Delete or Cancel on screen." : "There is no conversation to delete.", t = r ? N("deleteConversation.opened", "Opened the delete confirmation. Choose Delete or Cancel on screen.") : N("deleteConversation.nothing", "There is no conversation to delete.");
1061
- Us.current({
1062
- id: `conversation-delete:${M()}`,
1061
+ if (r && Rs(r), t) {
1062
+ let e = r ? "Opened the delete confirmation. Choose Delete or Cancel on screen." : "There is no conversation to delete.", t = r ? P("deleteConversation.opened", "Opened the delete confirmation. Choose Delete or Cancel on screen.") : P("deleteConversation.nothing", "There is no conversation to delete.");
1063
+ Ks.current({
1064
+ id: `conversation-delete:${N()}`,
1063
1065
  text: t,
1064
- lang: t === e ? "en" : R
1066
+ lang: t === e ? "en" : B
1065
1067
  });
1066
- } else r || Gs(Date.now());
1068
+ } else r || Js(Date.now());
1067
1069
  return !0;
1068
1070
  }, [
1069
- Fs,
1070
- R,
1071
- N
1072
- ]), Js = E((e, t, n, r = !1, i) => {
1073
- if (e.kind === "conversation-delete") return qs(n);
1074
- let { theme: a, navigate: o } = Y.current, s = null, c = () => {
1075
- let e = (r ? null : s ?? v.getState().activeConversationId) ?? Ks();
1076
- return r && wo(e), e;
1071
+ Rs,
1072
+ B,
1073
+ P
1074
+ ]), Zs = D((e, t, n, r = !1, i) => {
1075
+ if (e.kind === "conversation-delete") return Xs(n);
1076
+ let { theme: a, navigate: o } = J.current, s = null, c = () => {
1077
+ let e = (r ? null : s ?? y.getState().activeConversationId) ?? Ys();
1078
+ return r && Eo(e), e;
1077
1079
  }, l = (e, r) => {
1078
- let i = M();
1079
- return V(e, {
1080
+ let i = N();
1081
+ return U(e, {
1080
1082
  id: i,
1081
1083
  role: "user",
1082
1084
  content: t,
1083
1085
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1084
1086
  metadata: {
1085
1087
  localAction: r,
1086
- ...Ge(n)
1088
+ ...We(n)
1087
1089
  }
1088
1090
  }), i;
1089
1091
  }, u = (e, t, r, a, o, s, c) => {
1090
- let l = c ?? M();
1091
- return V(e, {
1092
+ let l = c ?? N();
1093
+ return U(e, {
1092
1094
  id: l,
1093
1095
  role: "assistant",
1094
1096
  content: r.text,
1095
1097
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1096
1098
  metadata: {
1097
- lang: r.translated ? R : "en",
1099
+ lang: r.translated ? B : "en",
1098
1100
  localAction: a,
1099
- ...Ge(n)
1101
+ ...We(n)
1100
1102
  }
1101
- }), ar.recordCommittedEntries(e, [t, l], "LOCAL_COMMAND", o), i !== void 0 && ns(i, {
1103
+ }), ar.recordCommittedEntries(e, [t, l], "LOCAL_COMMAND", o), i !== void 0 && as(i, {
1102
1104
  conversationId: e,
1103
1105
  questionId: t,
1104
1106
  replyId: l
1105
- }), s && Xo(e, l), l;
1107
+ }), s && $o(e, l), l;
1106
1108
  }, d = (e, t, n) => {
1107
- let r = c(), i = u(r, l(r, t), e, t, C(), !0);
1109
+ let r = c(), i = u(r, l(r, t), e, t, w(), !0);
1108
1110
  return n?.(i), !0;
1109
1111
  }, f = (e) => {
1110
- let t = c(), n = C(), r = window.location.pathname, a = l(t, ii({
1112
+ let t = c(), n = w(), r = window.location.pathname, a = l(t, ii({
1111
1113
  destinationId: e.destinationId,
1112
1114
  path: e.registryPath,
1113
1115
  alreadyHere: !1,
1114
1116
  via: e.via,
1115
1117
  offer: e.offer
1116
- })), s = i === void 0 ? void 0 : M();
1117
- i !== void 0 && s !== void 0 && (es(i, {
1118
+ })), s = i === void 0 ? void 0 : N();
1119
+ i !== void 0 && s !== void 0 && (rs(i, {
1118
1120
  conversationId: t,
1119
1121
  questionId: a,
1120
1122
  replyId: s
1121
- }), vs(s));
1122
- let d = M();
1123
- ms.current = d, gs(!0);
1123
+ }), xs(s));
1124
+ let d = N();
1125
+ _s.current = d, ys(!0);
1124
1126
  let f = (i) => {
1125
1127
  try {
1126
- if (e.offer && Es(e.offer.offerId, i) && xs(), i.status === "kept" || !v.getState().conversations.some((e) => e.id === t)) return;
1127
- let o = Xr(Y.current.navItems), c = i.status === "arrived" || i.status === "redirected" ? i.landedPath : null, l = ii({
1128
+ if (e.offer && ks(e.offer.offerId, i) && ws(), i.status === "kept" || !y.getState().conversations.some((e) => e.id === t)) return;
1129
+ let o = Xr(J.current.navItems), c = i.status === "arrived" || i.status === "redirected" ? i.landedPath : null, l = ii({
1128
1130
  destinationId: e.destinationId,
1129
1131
  path: e.registryPath,
1130
1132
  alreadyHere: !1,
@@ -1133,18 +1135,18 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1133
1135
  offer: e.offer
1134
1136
  });
1135
1137
  va(t, a, { localAction: l });
1136
- let d = u(t, a, e.via === "back" && i.status === "arrived" ? zt(N, e.pageLabel()) : Gt(N, i, {
1138
+ let d = u(t, a, e.via === "back" && i.status === "arrived" ? Rt(P, e.pageLabel()) : Wt(P, i, {
1137
1139
  page: e.pageLabel(),
1138
1140
  landed: c === null ? null : oi(o, c),
1139
1141
  path: e.target
1140
- }), l, n, X.current, s);
1142
+ }), l, n, Y.current, s);
1141
1143
  i.status === "arrived" && e.onArrived?.({
1142
1144
  replyId: d,
1143
1145
  fromPath: r,
1144
1146
  landedPath: i.landedPath
1145
1147
  });
1146
1148
  } finally {
1147
- ms.current === d && (ms.current = null, X.current && gs(!1)), s !== void 0 && X.current && vs((e) => e === s ? null : e);
1149
+ _s.current === d && (_s.current = null, Y.current && ys(!1)), s !== void 0 && Y.current && xs((e) => e === s ? null : e);
1148
1150
  }
1149
1151
  };
1150
1152
  return ei(o, e.target, {
@@ -1153,7 +1155,7 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1153
1155
  schedule: (e, t) => {
1154
1156
  window.setTimeout(e, t);
1155
1157
  },
1156
- isShellLess: () => !X.current
1158
+ isShellLess: () => !Y.current
1157
1159
  }).then(f, () => f({ status: "unconfirmed" })), !0;
1158
1160
  }, p = ({ replyId: e, fromPath: t, landedPath: n }) => ti.push({
1159
1161
  fromPath: t,
@@ -1170,14 +1172,14 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1170
1172
  if (!t.alreadyApplied) try {
1171
1173
  a.setMode(t.mode);
1172
1174
  } catch {}
1173
- return d(Qt(N, t, e.request.kind === "family"), {
1175
+ return d(Zt(P, t, e.request.kind === "family"), {
1174
1176
  kind: "theme",
1175
1177
  mode: t.mode,
1176
1178
  alreadyApplied: t.alreadyApplied
1177
1179
  });
1178
1180
  }
1179
1181
  if (e.kind === "app-control") {
1180
- let t = yi(e.request, { voiceLive: n !== void 0 || zc.current });
1182
+ let t = yi(e.request, { voiceLive: n !== void 0 || Hc.current });
1181
1183
  if (!t) return !1;
1182
1184
  let r = (e) => ({
1183
1185
  kind: "app-control",
@@ -1185,60 +1187,60 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1185
1187
  outcome: e.outcome,
1186
1188
  ...e.reply.code === "language" ? { languageLabel: e.reply.label } : {}
1187
1189
  }), i = (t) => {
1188
- if (e.request.control === "language" && fs(!1), e.request.control === "language" && t.reply.code === "language" && !t.reply.already && t.outcome === "done") {
1189
- let n = c(), i = r(t), a = u(n, l(n, i), $t((e, t) => t, t.reply), i, C(), !1);
1190
- return cs.current = {
1190
+ if (e.request.control === "language" && hs(!1), e.request.control === "language" && t.reply.code === "language" && !t.reply.already && t.outcome === "done") {
1191
+ let n = c(), i = r(t), a = u(n, l(n, i), Qt((e, t) => t, t.reply), i, w(), !1);
1192
+ return ds.current = {
1191
1193
  wanted: e.request.code,
1192
1194
  reply: t.reply,
1193
1195
  conversationId: n,
1194
1196
  messageId: a,
1195
- deadline: window.setTimeout(ps, en)
1196
- }, us(a), !0;
1197
+ deadline: window.setTimeout(gs, $t)
1198
+ }, ps(a), !0;
1197
1199
  }
1198
- return d($t(N, t.reply), r(t));
1200
+ return d(Qt(P, t.reply), r(t));
1199
1201
  };
1200
1202
  if (t.kind === "reply") return i(t.run);
1201
1203
  if (t.kind === "run") {
1202
1204
  let e = t.run();
1203
1205
  return t.silent && (e.outcome === "done" || e.outcome === "already") ? !0 : i(e);
1204
1206
  }
1205
- let a = Ps;
1207
+ let a = Ls;
1206
1208
  if (!a) return !1;
1207
1209
  let o = null;
1208
- return d($t(N, t.ask.reply), r(t.ask), (e) => {
1209
- o = v.getState().conversations.find((t) => t.messages.some((t) => t.id === e))?.id ?? null;
1210
+ return d(Qt(P, t.ask.reply), r(t.ask), (e) => {
1211
+ o = y.getState().conversations.find((t) => t.messages.some((t) => t.id === e))?.id ?? null;
1210
1212
  }), a.request({
1211
1213
  prompt: t.prompt,
1212
1214
  onConfirm: () => {
1213
- let e = t.confirmed(), i = o, a = i !== null && v.getState().conversations.some((e) => e.id === i);
1215
+ let e = t.confirmed(), i = o, a = i !== null && y.getState().conversations.some((e) => e.id === i);
1214
1216
  if (!i || !a) return;
1215
- let s = $t(N, e.reply);
1216
- V(i, {
1217
- id: M(),
1217
+ let s = Qt(P, e.reply);
1218
+ U(i, {
1219
+ id: N(),
1218
1220
  role: "assistant",
1219
1221
  content: s.text,
1220
1222
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1221
1223
  metadata: {
1222
- lang: s.translated ? R : "en",
1224
+ lang: s.translated ? B : "en",
1223
1225
  localAction: r(e),
1224
- ...Ge(n)
1226
+ ...We(n)
1225
1227
  }
1226
1228
  });
1227
1229
  }
1228
1230
  }), !0;
1229
1231
  }
1230
1232
  if (!o) return !1;
1231
- if (e.kind === "choose-destination") return d(Bt(N, e.candidates[0]?.label ?? e.query, e.candidates), {
1233
+ if (e.kind === "choose-destination") return d(zt(P, e.candidates[0]?.label ?? e.query, e.candidates), {
1232
1234
  kind: "choose-destination",
1233
1235
  candidateIds: e.candidates.map((e) => e.id)
1234
1236
  }, (t) => ui(t, e.candidates));
1235
- if (e.kind === "choose-linked") return d(Vt(N, e.candidates), {
1237
+ if (e.kind === "choose-linked") return d(Bt(P, e.candidates), {
1236
1238
  kind: "choose-destination",
1237
1239
  candidateIds: e.candidates.map((e) => e.id)
1238
1240
  }, (t) => ui(t, e.candidates));
1239
1241
  if (e.kind === "pick-from-list") {
1240
1242
  let t = e.candidates !== null && e.candidates.every((e) => e !== null) ? e.candidates : null;
1241
- return d(Yt(N), t ? {
1243
+ return d(Jt(P), t ? {
1242
1244
  kind: "choose-destination",
1243
1245
  candidateIds: t.map((e) => e.id)
1244
1246
  } : e.candidateIds.length > 0 ? {
@@ -1255,7 +1257,7 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1255
1257
  }
1256
1258
  }), t ? (e) => ui(e, t) : void 0);
1257
1259
  }
1258
- if (e.kind === "link-not-openable") return d(Ut(N), ii({
1260
+ if (e.kind === "link-not-openable") return d(Ht(P), ii({
1259
1261
  destinationId: "",
1260
1262
  path: "",
1261
1263
  alreadyHere: !1,
@@ -1268,7 +1270,7 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1268
1270
  if (e.kind === "open-record") {
1269
1271
  let r;
1270
1272
  try {
1271
- let { options: t, navItems: n } = Y.current, i = t.entityRoutes ?? [], a = Wr(n);
1273
+ let { options: t, navItems: n } = J.current, i = t.entityRoutes ?? [], a = Wr(n);
1272
1274
  r = (t.records ?? []).flatMap((t) => {
1273
1275
  let n = i.find((e) => e.id === t.entityRouteId), r = e.request.adapterIds.length === 0 || e.request.adapterIds.includes(t.id);
1274
1276
  return n && r && (n.visibleWith === void 0 || a.has(n.visibleWith)) ? [{
@@ -1280,10 +1282,10 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1280
1282
  return !1;
1281
1283
  }
1282
1284
  if (r.length === 0) return !1;
1283
- let i = v.getState().activeConversationId, a = M();
1284
- ms.current = a, gs(!0);
1285
+ let i = y.getState().activeConversationId, a = N();
1286
+ _s.current = a, ys(!0);
1285
1287
  let o = () => {
1286
- ms.current === a && (ms.current = null, X.current && gs(!1));
1288
+ _s.current === a && (_s.current = null, Y.current && ys(!1));
1287
1289
  };
1288
1290
  return (async () => {
1289
1291
  let a = { kind: "none" }, c = !0;
@@ -1291,17 +1293,17 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1291
1293
  a = await Gr({
1292
1294
  name: e.request.name,
1293
1295
  usable: r,
1294
- nounOf: (e) => Ht(N, e.noun),
1295
- timeoutMs: ji
1296
- }), c = v.getState().conversations.some((e) => e.id === i);
1296
+ nounOf: (e) => Vt(P, e.noun),
1297
+ timeoutMs: Mi
1298
+ }), c = y.getState().conversations.some((e) => e.id === i);
1297
1299
  } catch {
1298
1300
  a = { kind: "none" };
1299
1301
  } finally {
1300
1302
  o();
1301
1303
  }
1302
- if (!X.current) return;
1304
+ if (!Y.current) return;
1303
1305
  if (a.kind === "none") {
1304
- $s.current(t, [], {
1306
+ nc.current(t, [], {
1305
1307
  fromPerson: !0,
1306
1308
  ...n === void 0 ? {} : { voiceSessionId: n },
1307
1309
  localRecordsChecked: !0
@@ -1322,7 +1324,7 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1322
1324
  return;
1323
1325
  }
1324
1326
  let l = a.candidates[0];
1325
- d(a.why === "kinds" ? Zt(N, a.nouns, a.candidates) : Xt(N, a.nouns[0] ?? "", l?.label ?? e.request.name, a.candidates), {
1327
+ d(a.why === "kinds" ? Xt(P, a.nouns, a.candidates) : Yt(P, a.nouns[0] ?? "", l?.label ?? e.request.name, a.candidates), {
1326
1328
  kind: "choose-destination",
1327
1329
  candidateIds: a.candidates.map((e) => e.id)
1328
1330
  }, (e) => ui(e, a.candidates));
@@ -1331,7 +1333,7 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1331
1333
  if (e.kind === "back") {
1332
1334
  let e = ti.top();
1333
1335
  if (!e) return !1;
1334
- let t = ai(Xr(Y.current.navItems), e.fromPath);
1336
+ let t = ai(Xr(J.current.navItems), e.fromPath);
1335
1337
  return f({
1336
1338
  target: e.fromPath,
1337
1339
  destinationId: t?.id ?? "",
@@ -1345,21 +1347,21 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1345
1347
  }
1346
1348
  let ee, m = e.destination;
1347
1349
  if (e.via === "offer") {
1348
- let t = ws(e.offerId, e.destination.label);
1349
- if (!t.ok) return d(t.copy ?? Kt(N), {
1350
+ let t = Ds(e.offerId, e.destination.label);
1351
+ if (!t.ok) return d(t.copy ?? Gt(P), {
1350
1352
  kind: "write-reply",
1351
1353
  line: t.reason === "unavailable" ? "offer.notAvailable" : "offer.expired"
1352
1354
  });
1353
1355
  ee = {
1354
1356
  trigger: e.trigger,
1355
1357
  offerId: e.offerId
1356
- }, m = Xr(Y.current.navItems).find((e) => e.id === t.target.id) ?? {
1358
+ }, m = Xr(J.current.navItems).find((e) => e.id === t.target.id) ?? {
1357
1359
  id: t.target.id,
1358
1360
  label: t.target.label,
1359
1361
  path: t.target.path
1360
1362
  };
1361
1363
  }
1362
- return qr(m, window.location.pathname + window.location.search, Xr(Y.current.navItems)) ? d(Wt(N, m.label, !0), ii({
1364
+ return qr(m, window.location.pathname + window.location.search, Xr(J.current.navItems)) ? d(Ut(P, m.label, !0), ii({
1363
1365
  destinationId: m.id,
1364
1366
  path: m.path,
1365
1367
  alreadyHere: !0,
@@ -1375,55 +1377,55 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1375
1377
  onArrived: p
1376
1378
  });
1377
1379
  }, [
1378
- V,
1379
- wo,
1380
- Ps,
1381
- Ks,
1382
- ps,
1383
- R,
1380
+ U,
1381
+ Eo,
1382
+ Ls,
1383
+ Ys,
1384
+ gs,
1385
+ B,
1384
1386
  va,
1385
- es,
1386
- qs,
1387
- ns,
1388
- fs,
1389
- Xo,
1390
- N,
1391
- ws,
1392
- Es,
1393
- xs
1394
- ]), Ys = E(async (e) => {
1395
- so.current = !0, lo(!0);
1387
+ rs,
1388
+ Xs,
1389
+ as,
1390
+ hs,
1391
+ $o,
1392
+ P,
1393
+ Ds,
1394
+ ks,
1395
+ ws
1396
+ ]), Qs = D(async (e) => {
1397
+ co.current = !0, uo(!0);
1396
1398
  try {
1397
- await G.declineForReply(e.conversationId, e.reason, e.origin);
1399
+ await K.declineForReply(e.conversationId, e.reason, e.origin);
1398
1400
  } finally {
1399
- so.current = !1, X.current && lo(!1);
1401
+ co.current = !1, Y.current && uo(!1);
1400
1402
  }
1401
1403
  if (e.commandText !== null) {
1402
- let t = Ls(e.commandText, e.options.voiceSessionId);
1403
- if (t && Js(t, e.content, e.options.voiceSessionId)) return;
1404
+ let t = Bs(e.commandText, e.options.voiceSessionId);
1405
+ if (t && Zs(t, e.content, e.options.voiceSessionId)) return;
1404
1406
  }
1405
- await $s.current(e.content, e.attachments, e.options);
1407
+ await nc.current(e.content, e.attachments, e.options);
1406
1408
  }, [
1407
- Ls,
1408
- Js,
1409
- G
1410
- ]), Q = E(async (e, t = [], n = {}) => {
1411
- let r = n.voiceSessionId !== void 0, i = v.getState(), a = !1, o = xo.current;
1412
- if (r && ot(o)) {
1413
- let e = ut(o, i.activeConversationId, To());
1409
+ Bs,
1410
+ Zs,
1411
+ K
1412
+ ]), Z = D(async (e, t = [], n = {}) => {
1413
+ let r = n.voiceSessionId !== void 0, i = y.getState(), a = !1, o = Co.current;
1414
+ if (r && at(o)) {
1415
+ let e = lt(o, i.activeConversationId, Do());
1414
1416
  if (e.kind === "gone") return;
1415
1417
  let t = n.voiceEntry ?? e;
1416
- t.kind === "adopt" && wo(t.conversationId), a = t.kind === "own", n = {
1418
+ t.kind === "adopt" && Eo(t.conversationId), a = t.kind === "own", n = {
1417
1419
  ...n,
1418
1420
  voiceEntry: t
1419
1421
  };
1420
1422
  }
1421
- let s = a ? null : i.activeConversationId, c = a ? null : i.activeConversationId ?? z;
1423
+ let s = a ? null : i.activeConversationId, c = a ? null : i.activeConversationId ?? V;
1422
1424
  if (c) {
1423
- if (It(i.processingByConversationId[c]?.status)) {
1425
+ if (Ft(i.processingByConversationId[c]?.status)) {
1424
1426
  if (n.avatarTabAsk !== void 0) return;
1425
1427
  let r = i.processingByConversationId[c]?.messageId ?? null;
1426
- r && n.correctsInFlightTurn === !0 && !Uo.current.has(r) && Ko(), r && Uo.current.has(r) && (Wo.current = {
1428
+ r && n.correctsInFlightTurn === !0 && !Ko.current.has(r) && Yo(), r && Ko.current.has(r) && (qo.current = {
1427
1429
  conversationId: c,
1428
1430
  content: e,
1429
1431
  attachments: t,
@@ -1431,9 +1433,9 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1431
1433
  });
1432
1434
  return;
1433
1435
  }
1434
- if (Oo.current.has(c)) return;
1436
+ if (jo.current.has(c)) return;
1435
1437
  }
1436
- if (oo.current || se() !== null || so.current || ms.current !== null) return;
1438
+ if (so.current || se() !== null || co.current || _s.current !== null) return;
1437
1439
  let f = n.targetConversationId, p = ie(), ee = (e) => nr(e) || tr(e, p);
1438
1440
  if (f !== void 0) {
1439
1441
  let e = i.conversations.find((e) => e.id === f);
@@ -1442,44 +1444,44 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1442
1444
  if (n.avatarTabAsk !== void 0) {
1443
1445
  let e = s ? i.conversations.find((e) => e.id === s) : void 0, t = e && !ee(e) ? e : void 0;
1444
1446
  if (wr({
1445
- auto: i.autoRouting && ao.current && f === void 0,
1447
+ auto: i.autoRouting && oo.current && f === void 0,
1446
1448
  selectedMode: i.mode,
1447
1449
  conversation: t ? {
1448
1450
  mode: t.mode,
1449
1451
  routedBy: t.routedBy,
1450
1452
  hasHistory: er(t)
1451
1453
  } : null,
1452
- modeWrites: (e) => Za.current.find((t) => t.id === e)?.writeCapable === !0 || Ce(e)
1454
+ modeWrites: (e) => Qa.current.find((t) => t.id === e)?.writeCapable === !0 || Se(e)
1453
1455
  }) !== null) return;
1454
1456
  }
1455
1457
  if (n.fromPerson && n.writeReplyBound === void 0) {
1456
- let r = f ?? s ?? null, i = n.voiceSessionId === void 0 ? "typed" : "spoken", o = Vs(r, n.voiceSessionId), c = Vn({
1458
+ let r = f ?? s ?? null, i = n.voiceSessionId === void 0 ? "typed" : "spoken", o = Ws(r, n.voiceSessionId), c = Vn({
1457
1459
  text: e,
1458
- locale: i === "spoken" ? oa.input.code : R,
1460
+ locale: i === "spoken" ? oa.input.code : B,
1459
1461
  origin: i,
1460
1462
  hasAttachments: t.length > 0,
1461
- live: G.liveFor(r),
1462
- matchesLocalCommand: (e) => Ls(e, n.voiceSessionId) !== null,
1463
+ live: K.liveFor(r),
1464
+ matchesLocalCommand: (e) => Bs(e, n.voiceSessionId) !== null,
1463
1465
  offer: o.state,
1464
1466
  offerAssent: o.state !== "none" && Qr({
1465
1467
  text: e,
1466
- uiLocale: R,
1468
+ uiLocale: B,
1467
1469
  inputLocale: oa.input.code,
1468
- commandLocales: Y.current.options.commandLocales,
1469
- manifest: Y.current.options.commandManifest,
1470
- leaveGuard: Y.current.options.leaveGuard
1470
+ commandLocales: J.current.options.commandLocales,
1471
+ manifest: J.current.options.commandManifest,
1472
+ leaveGuard: J.current.options.leaveGuard
1471
1473
  })
1472
1474
  });
1473
1475
  if (c.kind === "accept_offer") {
1474
1476
  let t = o.accept;
1475
- if (t && Js({
1477
+ if (t && Zs({
1476
1478
  kind: "navigate",
1477
1479
  destination: t.destination,
1478
1480
  via: "offer",
1479
1481
  offerId: t.offerId,
1480
1482
  trigger: "yes"
1481
1483
  }, e, n.voiceSessionId, a, n.avatarTabAsk)) {
1482
- ts(n.avatarTabAsk);
1484
+ is(n.avatarTabAsk);
1483
1485
  return;
1484
1486
  }
1485
1487
  c = {
@@ -1496,11 +1498,11 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1496
1498
  };
1497
1499
  }
1498
1500
  if (c.kind === "local_reply") {
1499
- r && Hs(r, e, c.line, c.values, n.voiceSessionId, n.avatarTabAsk);
1501
+ r && Gs(r, e, c.line, c.values, n.voiceSessionId, n.avatarTabAsk);
1500
1502
  return;
1501
1503
  }
1502
1504
  let l = c.kind === "local" ? c.fallback : c.bound, u = c.declineAll;
1503
- if (u !== null && r) return n.avatarTabAsk === void 0 ? Ys({
1505
+ if (u !== null && r) return n.avatarTabAsk === void 0 ? Qs({
1504
1506
  conversationId: r,
1505
1507
  reason: u,
1506
1508
  origin: i,
@@ -1519,280 +1521,295 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1519
1521
  }
1520
1522
  let ne = n.writeReplyBound?.promptText ?? e;
1521
1523
  if (n.fromPerson && t.length === 0 && n.writeReplyBound?.localCommands !== !1) {
1522
- let t = Ls(e, n.voiceSessionId, n.localRecordsChecked === !0);
1523
- if (t && Js(t, e, n.voiceSessionId, a, n.avatarTabAsk)) {
1524
- ts(n.avatarTabAsk);
1524
+ let t = Bs(e, n.voiceSessionId, n.localRecordsChecked === !0);
1525
+ if (t && Zs(t, e, n.voiceSessionId, a, n.avatarTabAsk)) {
1526
+ is(n.avatarTabAsk);
1525
1527
  return;
1526
1528
  }
1527
1529
  }
1528
- let ae = s ? i.conversations.find((e) => e.id === s) : void 0, oe = ee(ae) ? void 0 : ae, h = i.autoRouting && ao.current && f === void 0 ? re({
1530
+ let ae = s ? i.conversations.find((e) => e.id === s) : void 0, oe = ee(ae) ? void 0 : ae, h = i.autoRouting && oo.current && f === void 0 ? re({
1529
1531
  intent: n.avatarTabAsk === void 0 ? n.autoIntent ?? m(e) : "read",
1530
1532
  dictated: r,
1531
- voiceProposalBound: r && Xi("api-calls") && de(i.acknowledgedWriteModes, "api-calls"),
1533
+ voiceProposalBound: r && Zi("api-calls") && de(i.acknowledgedWriteModes, "api-calls"),
1532
1534
  conversation: oe ? {
1533
1535
  mode: oe.mode,
1534
1536
  routedBy: oe.routedBy,
1535
1537
  hasHistory: er(oe)
1536
1538
  } : null
1537
1539
  }) : null;
1538
- if (h && Za.current.find((e) => e.id === h.mode)?.writeCapable && !de(i.acknowledgedWriteModes, h.mode)) {
1539
- oo.current = {
1540
+ if (h && Qa.current.find((e) => e.id === h.mode)?.writeCapable && !de(i.acknowledgedWriteModes, h.mode)) {
1541
+ so.current = {
1540
1542
  content: e,
1541
1543
  attachments: t,
1542
1544
  options: n
1543
- }, po(h.mode);
1545
+ }, mo(h.mode);
1544
1546
  return;
1545
1547
  }
1546
- let g = h ? h.mode : i.mode, le, ue, _ = f ?? (a ? null : z), pe = _ ? v.getState().conversations.find((e) => e.id === _) : void 0, he = h?.action === "escalate" && oe ? {
1548
+ let g = h ? h.mode : i.mode, le, ue, _ = f ?? (a ? null : V), v = _ ? y.getState().conversations.find((e) => e.id === _) : void 0, me = h?.action === "escalate" && oe ? {
1547
1549
  mode: oe.mode,
1548
1550
  backendSessionId: oe.backendSessionId ?? null
1549
1551
  } : null;
1550
1552
  if (h) h.action === "new" || !oe ? _ = ha(void 0, g, { routedBy: "auto" }) : (_ = oe.id, ka(_, g));
1551
1553
  else {
1552
1554
  let e = i.autoRouting ? { routedBy: "auto" } : void 0;
1553
- !_ || ee(pe) || pe && pe.mode !== g && er(pe) ? _ = ha(void 0, g, e) : pe && pe.mode !== g && (e ? ka(_, g) : pa(_, g));
1555
+ !_ || ee(v) || v && v.mode !== g && er(v) ? _ = ha(void 0, g, e) : v && v.mode !== g && (e ? ka(_, g) : pa(_, g));
1554
1556
  }
1555
1557
  if (!_) return;
1556
- r && xo.current !== void 0 && _ !== i.activeConversationId && wo(_), n.approvalFollowUp || (Eo.current[_] = t);
1557
- let ge = () => v.getState().conversations.some((e) => e.id === _), y = C(), ve = {
1558
- accessToken: Zi(),
1558
+ r && Co.current !== void 0 && _ !== i.activeConversationId && Eo(_), n.approvalFollowUp || (Oo.current[_] = t);
1559
+ let he = () => y.getState().conversations.some((e) => e.id === _), b = w(), _e = {
1560
+ accessToken: R(),
1559
1561
  workspaceToken: Qi(),
1560
- userId: L,
1561
- organizationId: Pt()
1562
- }, xe = (e, t) => {
1563
- ge() || !y || me(e, y, t, g, {
1564
- accessToken: Zi(),
1562
+ userId: z,
1563
+ organizationId: Nt()
1564
+ }, be = (e, t) => {
1565
+ he() || !b || pe(e, b, t, g, {
1566
+ accessToken: R(),
1565
1567
  workspaceToken: Qi(),
1566
- userId: L,
1567
- organizationId: Pt()
1568
+ userId: z,
1569
+ organizationId: Nt()
1568
1570
  });
1569
- }, Ee = {
1570
- id: M(),
1571
+ }, Te = {
1572
+ id: N(),
1571
1573
  role: "user",
1572
1574
  content: e,
1573
1575
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1574
1576
  metadata: {
1575
- ...t.length ? { attachments: t.map(_t) } : {},
1577
+ ...t.length ? { attachments: t.map(gt) } : {},
1576
1578
  ...n.approvalFollowUp ? {
1577
1579
  approvalFollowUp: !0,
1578
1580
  approvedReplyId: n.approvalFollowUp.approvedReplyId
1579
1581
  } : {},
1580
- ...Ge(n.voiceSessionId)
1582
+ ...We(n.voiceSessionId)
1581
1583
  }
1582
1584
  };
1583
- V(_, Ee);
1584
- let Oe = n.fromPerson === !0 && t.length === 0 && n.approvalFollowUp === void 0 && ne === e ? gi(e, r ? oa.input.code : R) : null, ke = {
1585
+ U(_, Te);
1586
+ let De = n.fromPerson === !0 && t.length === 0 && n.approvalFollowUp === void 0 && ne === e ? gi(e, r ? oa.input.code : B) : null, Oe = {
1585
1587
  location: window.location.pathname + window.location.search,
1586
- conversationId: v.getState().activeConversationId,
1587
- workspaceId: C(),
1588
- actorId: L ?? null
1589
- }, b = M();
1590
- V(_, {
1591
- id: b,
1588
+ conversationId: y.getState().activeConversationId,
1589
+ workspaceId: w(),
1590
+ actorId: z ?? null
1591
+ }, x = N();
1592
+ U(_, {
1593
+ id: x,
1592
1594
  role: "assistant",
1593
1595
  content: "",
1594
1596
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1595
1597
  metadata: {
1596
1598
  lang: la,
1597
- ...Ge(n.voiceSessionId)
1599
+ ...We(n.voiceSessionId)
1598
1600
  }
1599
- }), hn(b, {
1601
+ }), hn(x, {
1600
1602
  channel: r ? "voice" : "chat",
1601
1603
  mode: g,
1602
- product: P,
1604
+ product: F,
1603
1605
  language: la,
1604
1606
  device: gn(),
1605
1607
  routedByAuto: !!h
1606
- }, n.voiceTiming), T(b, "accepted"), ya(_, "provisioning", b, null), ce(b), n.avatarTabAsk !== void 0 && ns(n.avatarTabAsk, {
1608
+ }, n.voiceTiming), E(x, "accepted"), ya(_, "provisioning", x, null), ce(x), n.avatarTabAsk !== void 0 && as(n.avatarTabAsk, {
1607
1609
  conversationId: _,
1608
- questionId: Ee.id,
1609
- replyId: b
1610
+ questionId: Te.id,
1611
+ replyId: x
1610
1612
  });
1611
- let Ae = () => {
1612
- let e = Lt({
1613
- turnId: b,
1614
- abortRequested: Uo.current.has(b),
1615
- activeTurnId: v.getState().processingByConversationId[_]?.messageId ?? null,
1616
- conversationExists: ge()
1613
+ let ke = () => {
1614
+ let e = It({
1615
+ turnId: x,
1616
+ abortRequested: Ko.current.has(x),
1617
+ activeTurnId: y.getState().processingByConversationId[_]?.messageId ?? null,
1618
+ conversationExists: he()
1617
1619
  });
1618
- return e.abandon && We(), e;
1619
- }, Me = (e, t, r, i, a = !1, o = la) => {
1620
- _a(_, b, { content: l(e) }), va(_, b, {
1620
+ return e.abandon && Ue(), e;
1621
+ }, je = (e, t, r, i, a = !1, o = la) => {
1622
+ _a(_, x, { content: l(e) }), va(_, x, {
1621
1623
  lang: o,
1622
1624
  ...t?.length ? { artifacts: t } : {},
1623
1625
  ...t?.length || r || i ? { mode: g } : {},
1624
1626
  ...r ? { sessionId: r } : {},
1625
1627
  ...i ? { sandboxId: i } : {},
1626
1628
  ...a ? { incomplete: !0 } : {},
1627
- ...Ge(n.voiceSessionId)
1629
+ ...We(n.voiceSessionId)
1628
1630
  });
1629
- }, Ne = { session: null }, x = {
1631
+ }, Me = { session: null }, S = {
1632
+ speech: null,
1630
1633
  stream: null,
1631
1634
  render: null
1632
- }, We = () => {
1633
- x.render?.end();
1634
- }, Ke = () => {
1635
- We(), x.stream?.close(), x.stream = null, x.render = null;
1636
- }, Je = !1, Ye = () => {
1637
- Je && (Je = !1, qe.abort(b));
1638
- }, Xe = new u(), Qe = () => {}, $e = async (i = 1) => {
1639
- T(b, "attemptStarted");
1635
+ }, Ue = () => {
1636
+ S.speech?.close(), S.speech = null, S.render?.end();
1637
+ }, Ge = () => {
1638
+ Ue(), S.stream?.close(), S.stream = null, S.render = null;
1639
+ }, qe = !1, Je = () => {
1640
+ qe && (qe = !1, Ke.abort(x));
1641
+ }, Ye = new u(), Ze = () => {}, Qe = async (i = 1) => {
1642
+ E(x, "attemptStarted");
1640
1643
  let a = null, o = null, s = !1;
1641
1644
  try {
1642
- let { sandboxId: i, sessionId: c, sessionIsNew: u, readAhead: f, sandboxIsNew: p, sandboxProbed: ee, sandboxAdopted: m, deadSandboxProbe: te, sessionPreopened: re } = await Fo(_, b, g, y, ve, { isAbandoned: () => Lt({
1643
- turnId: b,
1644
- abortRequested: Uo.current.has(b),
1645
- activeTurnId: v.getState().processingByConversationId[_]?.messageId ?? null,
1646
- conversationExists: ge()
1645
+ let { sandboxId: i, sessionId: c, sessionIsNew: u, readAhead: f, sandboxIsNew: p, sandboxProbed: ee, sandboxAdopted: m, deadSandboxProbe: te, sessionPreopened: re } = await Ro(_, x, g, b, _e, { isAbandoned: () => It({
1646
+ turnId: x,
1647
+ abortRequested: Ko.current.has(x),
1648
+ activeTurnId: y.getState().processingByConversationId[_]?.messageId ?? null,
1649
+ conversationExists: he()
1647
1650
  }).abandon });
1648
- if (a = i, Qe(), Qe = d(i, () => {
1649
- Uo.current.add(b), Ze(b), qe.abort(b);
1650
- }), T(b, "runtimeReady"), w(b, {
1651
+ if (a = i, Ze(), Ze = d(i, () => {
1652
+ Ko.current.add(x), Xe(x), Ke.abort(x);
1653
+ }), E(x, "runtimeReady"), T(x, {
1651
1654
  runtime: p ? "cold" : m ? "adopted" : ee ? "probed" : re ? "preopened" : u ? "new-session" : "warm",
1652
1655
  deadSandboxProbe: te
1653
- }), w(b, { session: re ? "preopened" : u ? "created" : "reused" }), o = c, Ne.session = {
1656
+ }), T(x, { session: re ? "preopened" : u ? "created" : "reused" }), o = c, Me.session = {
1654
1657
  sandboxId: i,
1655
1658
  sessionId: c
1656
- }, fe(g, le, v.getState().acknowledgedWriteModes, {
1659
+ }, fe(g, le, y.getState().acknowledgedWriteModes, {
1657
1660
  dictated: r,
1658
- confirmsWrites: Ce(g),
1659
- proposalBound: Xi(g, i)
1660
- }) === "voice-in-write-mode") throw new Pe("voice-in-write-mode", "Voice in a write mode");
1661
+ confirmsWrites: Se(g),
1662
+ proposalBound: Zi(g, i)
1663
+ }) === "voice-in-write-mode") throw new Ne("voice-in-write-mode", "Voice in a write mode");
1661
1664
  let ie = mr({
1662
- conversation: v.getState().conversations.find((e) => e.id === _),
1665
+ conversation: y.getState().conversations.find((e) => e.id === _),
1663
1666
  content: e,
1664
1667
  sessionIsNew: u,
1665
1668
  sendingMode: g,
1666
1669
  sendingModeConfig: le,
1667
- modes: Za.current,
1668
- answerText: (e) => dn(e).text
1670
+ modes: Qa.current,
1671
+ answerText: (e) => un(e).text
1669
1672
  });
1670
- if (Ke(), jr()) {
1673
+ if (Ge(), jr()) {
1671
1674
  let e = Ar({
1672
- mint: () => Se(i, y, c, g, ve),
1673
- mark: (e) => T(b, e)
1675
+ mint: () => xe(i, b, c, g, _e),
1676
+ mark: (e) => E(x, e)
1674
1677
  });
1675
- x.stream = e, x.render = _r({
1678
+ S.stream = e, mn() && n.voiceSessionId !== void 0 && !ue.accumulatesNarration && (S.speech = Di({
1679
+ append: (e, t) => {
1680
+ ke().abandon || (E(x, "speechQueued"), qe = !0, Ke.append(x, {
1681
+ conversationId: _,
1682
+ channel: "voice",
1683
+ voiceSessionId: n.voiceSessionId,
1684
+ text: t,
1685
+ lang: la,
1686
+ final: !1
1687
+ }, e));
1688
+ },
1689
+ retract: () => Ke.retract(x)
1690
+ })), S.render = _r({
1691
+ onLiveState: (e, t) => S.speech?.invalidate(e, t),
1692
+ onRendered: (e, t, n) => S.speech?.update(e, t, n),
1676
1693
  stream: e,
1677
1694
  conversationId: _,
1678
- messageId: b,
1679
- build: (e, t) => l(on(e, t, { accumulateNarration: ue.accumulatesNarration }).content),
1680
- onFirstDelta: () => T(b, "firstDelta"),
1681
- onFirstVisible: () => T(b, "firstOutput")
1695
+ messageId: x,
1696
+ build: (e, t) => l(an(e, t, { accumulateNarration: ue.accumulatesNarration }).content),
1697
+ onFirstDelta: () => E(x, "firstDelta"),
1698
+ onFirstVisible: () => E(x, "firstOutput")
1682
1699
  });
1683
1700
  }
1684
- let ae = await cn(() => be(i, y, c, g, ve, { limit: 50 }), u, sn(f, i, c));
1685
- No(_, b, "streaming", "thinking");
1686
- let oe = Gi?.(), h = Hn(v.getState().sandboxWriteCapabilities[i]), se = Y.current, ce = mi(i, c), de = se.options.uiCatalogue ? di(Xr(se.navItems), {
1701
+ let ae = await sn(() => ye(i, b, c, g, _e, { limit: 50 }), u, on(f, i, c));
1702
+ Io(_, x, "streaming", "thinking");
1703
+ let oe = Ki?.(), h = Hn(y.getState().sandboxWriteCapabilities[i]), se = J.current, ce = mi(i, c), de = se.options.uiCatalogue ? di(Xr(se.navItems), {
1687
1704
  permissionsSettled: se.navPermissionsSettled,
1688
1705
  simulating: se.navSimulating,
1689
1706
  sentBefore: pi(ce)
1690
- }) : null, pe = v.getState().sandboxWriteCapabilities[i]?.clientTools === !0 ? Ei({ writeCapable: le?.writeCapable === !0 || g === "api-calls" }) : null, me = pe?.manifest ?? [], he = {
1707
+ }) : null, v = y.getState().sandboxWriteCapabilities[i]?.clientTools === !0 ? Ei({ writeCapable: le?.writeCapable === !0 || g === "api-calls" }) : null, pe = v?.manifest ?? [], me = {
1691
1708
  conversationId: _,
1692
1709
  writeReply: h === "proposal-v1" ? n.writeReplyBound?.writeReply ?? null : null,
1693
1710
  ...de ? { uiCatalogue: de } : {},
1694
- ...me.length > 0 ? { clientTools: me } : {}
1695
- }, { prompt: Fe, parts: Ie } = kt({
1711
+ ...pe.length > 0 ? { clientTools: pe } : {}
1712
+ }, { prompt: Pe, parts: Fe } = Ot({
1696
1713
  content: ie ? `${ie}${ne}` : ne,
1697
1714
  attachments: t,
1698
- limits: gt(le),
1699
- wrapPrompt: (e) => Ki?.(g, e, sa, ca, r, { writeApproval: h }) ?? e,
1700
- requestBytes: (e, t) => Te({
1715
+ limits: ht(le),
1716
+ wrapPrompt: (e) => qi?.(g, e, sa, ca, r, { writeApproval: h }) ?? e,
1717
+ requestBytes: (e, t) => we({
1701
1718
  sandboxId: i,
1702
- workspaceId: y,
1719
+ workspaceId: b,
1703
1720
  sessionId: c,
1704
1721
  mode: g,
1705
1722
  prompt: e,
1706
1723
  parts: t,
1707
1724
  pageContext: oe,
1708
- authContext: ve,
1709
- ...he
1725
+ authContext: _e,
1726
+ ...me
1710
1727
  })
1711
- }), Le = mt(Ie), ze = Le > 0;
1712
- s = pt(t) > Le;
1713
- let Ve = Ae();
1714
- if (Ve.abandon) {
1715
- Ve.clearProcessing && ba(_);
1728
+ }), Ie = pt(Fe), Re = Ie > 0;
1729
+ s = ft(t) > Ie;
1730
+ let Be = ke();
1731
+ if (Be.abandon) {
1732
+ Be.clearProcessing && ba(_);
1716
1733
  return;
1717
1734
  }
1718
- let He = (e) => Xe.dispatch({
1719
- prompt: Fe,
1720
- isAbandoned: () => Ae().abandon,
1721
- readMessages: (e) => be(i, y, c, g, ve, { sinceMs: e }),
1722
- send: () => De(i, y, c, Fe, g, oe, ve, e?.length ? {
1735
+ let Ve = (e) => Ye.dispatch({
1736
+ prompt: Pe,
1737
+ isAbandoned: () => ke().abandon,
1738
+ readMessages: (e) => ye(i, b, c, g, _e, { sinceMs: e }),
1739
+ send: () => Ee(i, b, c, Pe, g, oe, _e, e?.length ? {
1723
1740
  parts: e,
1724
- ...he
1725
- } : he)
1741
+ ...me
1742
+ } : me)
1726
1743
  });
1727
1744
  try {
1728
- await He(Ie);
1745
+ await Ve(Fe);
1729
1746
  } catch (e) {
1730
- if (!Xe.canFailover() || !Ie || !Tn(e)) throw e;
1731
- await He(void 0), s ||= ze;
1747
+ if (!Ye.canFailover() || !Fe || !Tn(e)) throw e;
1748
+ await Ve(void 0), s ||= Re;
1732
1749
  }
1733
1750
  de && fi(ce);
1734
- let Ge = v.getState().sandboxWriteCapabilities[i], Ye = se.options.uiOffers === !0 && je(Ge) ? L : null, $e = !!Ye;
1735
- Ye && Z.recordTurn({
1736
- replyId: b,
1751
+ let We = y.getState().sandboxWriteCapabilities[i], Je = se.options.uiOffers === !0 && Ae(We) ? z : null, Qe = !!Je;
1752
+ Je && X.recordTurn({
1753
+ replyId: x,
1737
1754
  conversationId: _,
1738
1755
  sandboxId: i,
1739
1756
  sessionId: c,
1740
1757
  mode: g,
1741
1758
  writeCapable: le?.writeCapable === !0,
1742
- actorId: Ye,
1759
+ actorId: Je,
1743
1760
  floorMs: ae
1744
1761
  });
1745
- let et = pe && me.length > 0 ? Ti({
1746
- tools: pe.tools,
1747
- post: (e, t) => we(i, y, c, e, t, g, ve)
1748
- }) : null, nt = et ? (e) => et.receive(e) : void 0, rt = $e ? (e, t) => {
1749
- Z.receive(b, e, t, performance.now()) && xs();
1750
- } : void 0, it = (e) => _a(_, b, { content: e }), at = (e) => s ? `${e}\n\n${N("attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}` : e;
1751
- T(b, "promptSent");
1752
- let ot = null, st = !1, ct = an, S = on([], ae);
1753
- x.render?.arm(ae);
1754
- let lt = Date.now() + ue.streamBudgetMs, ut = Date.now(), dt = Date.now(), ft = Mr(() => be(i, y, c, g, ve, {
1762
+ let $e = v && pe.length > 0 ? Ti({
1763
+ tools: v.tools,
1764
+ post: (e, t) => Ce(i, b, c, e, t, g, _e)
1765
+ }) : null, tt = $e ? (e) => $e.receive(e) : void 0, nt = Qe ? (e, t) => {
1766
+ X.receive(x, e, t, performance.now()) && ws();
1767
+ } : void 0, rt = (e) => _a(_, x, { content: e }), it = (e) => s ? `${e}\n\n${P("attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}` : e;
1768
+ E(x, "promptSent");
1769
+ let at = null, ot = !1, st = rn, C = an([], ae);
1770
+ S.render?.arm(ae);
1771
+ let ct = Date.now() + ue.streamBudgetMs, lt = Date.now(), ut = Date.now(), dt = Mr(() => ye(i, b, c, g, _e, {
1755
1772
  limit: 50,
1756
1773
  sinceMs: ae,
1757
1774
  surfaceTurnTerminal: !0,
1758
- surfaceUiOffers: rt,
1759
- surfaceClientToolRequests: nt
1760
- })), ht = x.stream?.onIdle(() => ft.startExtra());
1775
+ surfaceUiOffers: nt,
1776
+ surfaceClientToolRequests: tt
1777
+ })), mt = S.stream?.onIdle(() => dt.startExtra());
1761
1778
  try {
1762
- for (; Date.now() < lt;) {
1763
- xe(i, c);
1764
- let e = Ae();
1779
+ for (; Date.now() < ct;) {
1780
+ be(i, c);
1781
+ let e = ke();
1765
1782
  if (e.abandon) {
1766
1783
  e.clearProcessing && ba(_);
1767
1784
  return;
1768
1785
  }
1769
- let t = await ft.next();
1770
- if ($e && Z.observeMessages(b, t) && xs(), S = on(t, ae, { accumulateNarration: ue.accumulatesNarration }), _a(_, b, { content: l(S.content) }), S.hasRenderableOutput ? st || (st = !0, ot !== null && T(b, "lastQuietPoll", ot), T(b, "firstOutput")) : ot = vn(), ue.accumulatesNarration) S.hasText && T(b, "firstText");
1786
+ let t = await dt.next();
1787
+ if (Qe && X.observeMessages(x, t) && ws(), C = an(t, ae, { accumulateNarration: ue.accumulatesNarration }), _a(_, x, { content: l(C.content) }), C.hasRenderableOutput ? ot || (ot = !0, at !== null && E(x, "lastQuietPoll", at), E(x, "firstOutput")) : at = vn(), ue.accumulatesNarration) C.hasText && E(x, "firstText");
1771
1788
  else {
1772
- let e = un(ct, S, vn());
1773
- ct = e.tracker, e.confirmedAt !== null && T(b, "firstText", e.confirmedAt);
1789
+ let e = ln(st, C, vn());
1790
+ st = e.tracker, e.confirmedAt !== null && E(x, "firstText", e.confirmedAt);
1774
1791
  }
1775
- if (S.pendingWrite && !Bn(v.getState().sandboxWriteCapabilities[i]) && va(_, b, { pendingWrite: S.pendingWrite }), S.done && (x.stream ? w(b, {
1776
- transport: x.stream.reachedOpen ? "sse" : "poll",
1777
- live: gr(x.stream.live)
1778
- }) : w(b, {
1792
+ if (C.pendingWrite && !Bn(y.getState().sandboxWriteCapabilities[i]) && va(_, x, { pendingWrite: C.pendingWrite }), C.done && (S.stream ? T(x, {
1793
+ transport: S.stream.reachedOpen ? "sse" : "poll",
1794
+ live: gr(S.stream.live)
1795
+ }) : T(x, {
1779
1796
  transport: "poll",
1780
1797
  live: "none"
1781
- }), We()), S.done) {
1782
- T(b, "answerDone"), J.current.markVerified(i);
1798
+ }), Ue()), C.done) {
1799
+ E(x, "answerDone"), ko.current.markVerified(i);
1783
1800
  break;
1784
1801
  }
1785
- if (x.render?.refresh(t), Date.now() - ut > 3e4 && (await _e(i, y, 600, ve).catch(() => void 0), ut = Date.now()), !ft.hasPending()) {
1786
- let e = tt(Date.now() - dt);
1787
- x.stream ? await x.stream.waitWake(e) : await new Promise((t) => setTimeout(t, e));
1802
+ if (S.render?.refresh(t), Date.now() - lt > 3e4 && (await ge(i, b, 600, _e).catch(() => void 0), lt = Date.now()), !dt.hasPending()) {
1803
+ let e = et(Date.now() - ut);
1804
+ S.stream ? await S.stream.waitWake(e) : await new Promise((t) => setTimeout(t, e));
1788
1805
  }
1789
1806
  }
1790
1807
  } finally {
1791
- et?.dispose();
1808
+ $e?.dispose();
1792
1809
  }
1793
- if (ht?.(), Ke(), S.done && n.voiceSessionId !== void 0 && !Ae().abandon) {
1794
- let e = l(at(S.content));
1795
- e.trim() && (s && it(e), T(b, "speechQueued"), Je = !0, qe.publish(b, {
1810
+ if (mt?.(), Ge(), (C.done || qe) && n.voiceSessionId !== void 0 && !ke().abandon) {
1811
+ let e = l(it(C.content));
1812
+ (e.trim() || qe) && (s && rt(e), E(x, "speechQueued"), qe = !0, Ke.publish(x, {
1796
1813
  conversationId: _,
1797
1814
  channel: "voice",
1798
1815
  voiceSessionId: n.voiceSessionId,
@@ -1801,323 +1818,323 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
1801
1818
  final: !0
1802
1819
  }));
1803
1820
  }
1804
- let _t = ue.producesArtifacts ? await ye(i, y, c, g, ve).then((e) => e).catch(() => []) : void 0;
1805
- S.usedTools !== void 0 && w(b, { usedTools: S.usedTools }), S.done || (w(b, { outcome: "timedOut" }), S = {
1806
- ...S,
1807
- content: Ue(S.content, g, N, le)
1808
- }), s && (S = {
1809
- ...S,
1810
- content: at(S.content)
1821
+ let gt = ue.producesArtifacts ? await ve(i, b, c, g, _e).then((e) => e).catch(() => []) : void 0;
1822
+ C.usedTools !== void 0 && T(x, { usedTools: C.usedTools }), C.done || (T(x, { outcome: "timedOut" }), C = {
1823
+ ...C,
1824
+ content: He(C.content, g, P, le)
1825
+ }), s && (C = {
1826
+ ...C,
1827
+ content: it(C.content)
1811
1828
  });
1812
- let vt = !S.done;
1813
- Me(S.content, _t, c, i, vt), S.tokens && (_a(_, b, { tokens: S.tokens }), (Ji ? await Be({
1814
- workspaceId: y,
1829
+ let _t = !C.done;
1830
+ je(C.content, gt, c, i, _t), C.tokens && (_a(_, x, { tokens: C.tokens }), (Yi ? await ze({
1831
+ workspaceId: b,
1815
1832
  sessionId: c,
1816
- messageId: S.messageId,
1817
- model: S.model,
1818
- tokens: S.tokens
1819
- }, Ji, { ledger: Re("panel", P) }) : { ok: !0 }).ok && Pn(P)), S.done || xe(i, c);
1820
- let yt = Ae();
1821
- if (yt.abandon) {
1822
- yt.clearProcessing && ba(_);
1833
+ messageId: C.messageId,
1834
+ model: C.model,
1835
+ tokens: C.tokens
1836
+ }, Yi, { ledger: Le("panel", F) }) : { ok: !0 }).ok && Pn(F)), C.done || be(i, c);
1837
+ let vt = ke();
1838
+ if (vt.abandon) {
1839
+ vt.clearProcessing && ba(_);
1823
1840
  return;
1824
1841
  }
1825
- T(b, "complete"), w(b, { outcome: "answered" }), ya(_, "complete", b, null), ar.recordCommittedEntries(_, [Ee.id, b], "TURN", y), Je = !1, $e && Oe && S.done && js({
1826
- replyId: b,
1842
+ E(x, "complete"), T(x, { outcome: "answered" }), ya(_, "complete", x, null), ar.recordCommittedEntries(_, [Te.id, x], "TURN", b), qe = !1, Qe && De && C.done && Ps({
1843
+ replyId: x,
1827
1844
  conversationId: _,
1828
1845
  voiceSessionId: n.voiceSessionId,
1829
- intent: Oe,
1830
- atSend: ke
1846
+ intent: De,
1847
+ atSend: Oe
1831
1848
  });
1832
1849
  } catch (e) {
1833
- J.current.invalidate(a ?? v.getState().sandboxesByMode[g]?.sandboxId ?? null);
1834
- let t = Lt({
1835
- turnId: b,
1836
- abortRequested: Uo.current.has(b),
1837
- activeTurnId: v.getState().processingByConversationId[_]?.messageId ?? null,
1838
- conversationExists: ge()
1850
+ ko.current.invalidate(a ?? y.getState().sandboxesByMode[g]?.sandboxId ?? null);
1851
+ let t = It({
1852
+ turnId: x,
1853
+ abortRequested: Ko.current.has(x),
1854
+ activeTurnId: y.getState().processingByConversationId[_]?.messageId ?? null,
1855
+ conversationExists: he()
1839
1856
  });
1840
- if (We(), a && o && xe(a, o), t.abandon) {
1857
+ if (Ue(), a && o && be(a, o), t.abandon) {
1841
1858
  t.clearProcessing && ba(_);
1842
1859
  return;
1843
1860
  }
1844
- if (i === 1 && Xe.canFailover() && En(e)) {
1845
- Qe();
1846
- let e = a ?? v.getState().sandboxesByMode[g]?.sandboxId ?? null;
1847
- return e && (Do.current.add(e), J.current.invalidate(e)), Sa(_), wa(g), ga(_, b, ""), va(_, b, { pendingWrite: void 0 }), e && G.retireSandbox(e), Ke(), Ye(), _n(b), $e(2);
1861
+ if (i === 1 && Ye.canFailover() && En(e)) {
1862
+ Ze();
1863
+ let e = a ?? y.getState().sandboxesByMode[g]?.sandboxId ?? null;
1864
+ return e && (Ao.current.add(e), ko.current.invalidate(e)), Sa(_), wa(g), ga(_, x, ""), va(_, x, { pendingWrite: void 0 }), e && K.retireSandbox(e), Ge(), Je(), _n(x), Qe(2);
1848
1865
  }
1849
1866
  throw e;
1850
1867
  }
1851
- }, et = _;
1852
- Oo.current.add(et);
1868
+ }, $e = _;
1869
+ jo.current.add($e);
1853
1870
  try {
1854
- if (!y) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
1871
+ if (!b) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
1855
1872
  code: "UNAUTHENTICATED",
1856
1873
  authFailure: "WORKSPACE_CONTEXT_MISSING"
1857
1874
  } });
1858
- let e = await Ot(g, () => Za.current.find((e) => e.id === g), Xa);
1875
+ let e = await Dt(g, () => Qa.current.find((e) => e.id === g), Za);
1859
1876
  le = e.config, ue = e.capabilities;
1860
- let t = le, n = Ae();
1877
+ let t = le, n = ke();
1861
1878
  if (n.abandon) {
1862
1879
  n.clearProcessing && ba(_);
1863
1880
  return;
1864
1881
  }
1865
- let i = fe(g, t, v.getState().acknowledgedWriteModes, {
1882
+ let i = fe(g, t, y.getState().acknowledgedWriteModes, {
1866
1883
  dictated: r,
1867
- confirmsWrites: Ce(g),
1868
- proposalBound: Xi(g)
1884
+ confirmsWrites: Se(g),
1885
+ proposalBound: Zi(g)
1869
1886
  });
1870
- if (i) throw new Pe(i, i === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
1871
- let a = Re("panel", P);
1872
- if (Ji && ze(a, y)) {
1873
- let e = await Ve(a, y, Ji);
1874
- if (!e.ok) throw He(e.kind);
1875
- let t = Ae();
1887
+ if (i) throw new Ne(i, i === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
1888
+ let a = Le("panel", F);
1889
+ if (Yi && Re(a, b)) {
1890
+ let e = await Be(a, b, Yi);
1891
+ if (!e.ok) throw Ve(e.kind);
1892
+ let t = ke();
1876
1893
  if (t.abandon) {
1877
1894
  t.clearProcessing && ba(_);
1878
1895
  return;
1879
1896
  }
1880
1897
  }
1881
- T(b, "cleared"), await $e();
1898
+ E(x, "cleared"), await Qe();
1882
1899
  } catch (e) {
1883
- if (J.current.invalidate(v.getState().sandboxesByMode[g]?.sandboxId ?? null), !ge()) {
1900
+ if (ko.current.invalidate(y.getState().sandboxesByMode[g]?.sandboxId ?? null), !he()) {
1884
1901
  ba(_);
1885
1902
  return;
1886
1903
  }
1887
- let t = Ne.session?.sandboxId ?? null, r = Fe(e, { confirmsNoAction: Ie({
1904
+ let t = Me.session?.sandboxId ?? null, r = Pe(e, { confirmsNoAction: Fe({
1888
1905
  mode: g,
1889
- capabilities: t ? v.getState().sandboxWriteCapabilities[t] : null
1906
+ capabilities: t ? y.getState().sandboxWriteCapabilities[t] : null
1890
1907
  }) });
1891
- w(b, { outcome: r.kind === "temporary" ? "failed" : "refused" }), r.offersUpgrade && Nn(P, "sandbox");
1892
- let i = Le(r, N, { locale: R });
1893
- ya(_, "error", b, i.headline), _a(_, b, { content: i.text }), va(_, b, {
1894
- lang: i.translated ? R : "en",
1895
- ...Ge(n.voiceSessionId)
1908
+ T(x, { outcome: r.kind === "temporary" ? "failed" : "refused" }), r.offersUpgrade && Nn(F, "sandbox");
1909
+ let i = Ie(r, P, { locale: B });
1910
+ ya(_, "error", x, i.headline), _a(_, x, { content: i.text }), va(_, x, {
1911
+ lang: i.translated ? B : "en",
1912
+ ...We(n.voiceSessionId)
1896
1913
  });
1897
1914
  } finally {
1898
- Qe(), Oo.current.delete(et), w(b, { outcome: "stopped" }), T(b, "complete"), Ye(), Ke();
1899
- let e = v.getState(), t = te(he, g, e.conversations.find((e) => e.id === et), (t) => !!e.sandboxesByMode[t]?.sandboxId);
1900
- t && (ka(et, t.mode), t.backendSessionId && xa(et, t.backendSessionId)), Ne.session && ge() && G.afterTurn({
1901
- ...Ne.session,
1902
- conversationId: et
1903
- }, b);
1904
- let n = Wo.current;
1905
- Wo.current = null, n && n.conversationId === et && ge() && $s.current(n.content, n.attachments, n.options);
1915
+ Ze(), jo.current.delete($e), T(x, { outcome: "stopped" }), E(x, "complete"), Je(), Ge();
1916
+ let e = y.getState(), t = te(me, g, e.conversations.find((e) => e.id === $e), (t) => !!e.sandboxesByMode[t]?.sandboxId);
1917
+ t && (ka($e, t.mode), t.backendSessionId && xa($e, t.backendSessionId)), Me.session && he() && K.afterTurn({
1918
+ ...Me.session,
1919
+ conversationId: $e
1920
+ }, x);
1921
+ let n = qo.current;
1922
+ qo.current = null, n && n.conversationId === $e && he() && nc.current(n.content, n.attachments, n.options);
1906
1923
  }
1907
1924
  }, [
1908
- z,
1909
1925
  V,
1910
- Ki,
1926
+ U,
1927
+ qi,
1911
1928
  Sa,
1912
1929
  wa,
1913
1930
  ua,
1914
1931
  ha,
1915
- Fo,
1916
- G,
1917
- Ko,
1918
- Hs,
1919
- Ys,
1920
- R,
1932
+ Ro,
1933
+ K,
1934
+ Yo,
1935
+ Gs,
1936
+ Qs,
1937
+ B,
1921
1938
  oa,
1922
- Xi,
1923
- Gi,
1924
1939
  Zi,
1940
+ Ki,
1941
+ R,
1925
1942
  Qi,
1926
1943
  _a,
1927
- P,
1928
- Xa,
1929
- Ji,
1944
+ F,
1945
+ Za,
1946
+ Yi,
1930
1947
  ca,
1931
- R,
1948
+ B,
1932
1949
  la,
1933
1950
  sa,
1934
1951
  ka,
1935
- Js,
1936
- Ls,
1937
- wo,
1938
- To,
1952
+ Zs,
1953
+ Bs,
1954
+ Eo,
1955
+ Do,
1939
1956
  xa,
1940
1957
  pa,
1941
1958
  ya,
1942
1959
  ba,
1943
- N,
1944
- No,
1960
+ P,
1961
+ Io,
1945
1962
  ga,
1946
- L,
1947
- Z,
1948
- xs,
1949
- Vs,
1950
- js,
1951
- ns,
1952
- ts
1953
- ]), Xs = E((e, t) => {
1954
- Q(e, [], t ? { autoIntent: t } : {});
1955
- }, [Q]), Zs = Ft(), Qs = E(() => {
1963
+ z,
1964
+ X,
1965
+ ws,
1966
+ Ws,
1967
+ Ps,
1968
+ as,
1969
+ is
1970
+ ]), $s = D((e, t) => {
1971
+ Z(e, [], t ? { autoIntent: t } : {});
1972
+ }, [Z]), ec = Pt(), tc = D(() => {
1956
1973
  let e = [...Aa.chat].reverse().find((e) => e.role === "user" && !e.metadata?.localAction);
1957
1974
  if (!e || e.metadata?.approvalFollowUp) return;
1958
- let t = z ? Eo.current[z] ?? [] : [];
1959
- if (t.some((e) => At(e, Date.now()))) {
1960
- let n = z ?? void 0;
1961
- jt(t, Zs).then((t) => {
1962
- Q(e.content, t, n === void 0 ? void 0 : { targetConversationId: n });
1975
+ let t = V ? Oo.current[V] ?? [] : [];
1976
+ if (t.some((e) => kt(e, Date.now()))) {
1977
+ let n = V ?? void 0;
1978
+ At(t, ec).then((t) => {
1979
+ Z(e.content, t, n === void 0 ? void 0 : { targetConversationId: n });
1963
1980
  });
1964
1981
  return;
1965
1982
  }
1966
- Q(e.content, t);
1983
+ Z(e.content, t);
1967
1984
  }, [
1968
1985
  ja,
1969
- Q,
1970
- z,
1971
- Zs
1972
- ]), $s = k(Q);
1973
- D(() => {
1974
- $s.current = Q;
1975
- }, [Q]);
1976
- let ec = O(() => {
1977
- if (W) return null;
1986
+ Z,
1987
+ V,
1988
+ ec
1989
+ ]), nc = A(Z);
1990
+ O(() => {
1991
+ nc.current = Z;
1992
+ }, [Z]);
1993
+ let rc = k(() => {
1994
+ if (Ma) return null;
1978
1995
  for (let e = ja.length - 1; e >= 0; --e) {
1979
1996
  let t = ja[e];
1980
1997
  if (t?.role !== "assistant") continue;
1981
- if (t.id === ls) return null;
1982
- if (!We(t) || Uo.current.has(t.id) || Xe(t.id)) continue;
1983
- let n = rn(t, U, N);
1998
+ if (t.id === fs) return null;
1999
+ if (!Ue(t) || Ko.current.has(t.id) || Ye(t.id)) continue;
2000
+ let n = nn(t, G, P);
1984
2001
  if (n.kind !== "output") return null;
1985
- let r = dn(n.text).text.trim();
1986
- return r ? Ye(t, r, U) : null;
2002
+ let r = un(n.text).text.trim();
2003
+ return r ? Je(t, r, G) : null;
1987
2004
  }
1988
2005
  return null;
1989
2006
  }, [
1990
2007
  ja,
1991
- W,
1992
- U,
1993
- ls,
1994
- N
1995
- ]), tc = O(() => ec ? nt(ec.text) : null, [ec]), nc = O(() => Aa.chat.filter((e) => e.id !== ls), [Aa.chat, ls]), rc = v((e) => pe(e)?.sandboxId ?? null), ic = le(nc, {
1996
- sessionId: H?.backendSessionId,
1997
- sandboxId: rc,
2008
+ Ma,
2009
+ G,
2010
+ fs,
2011
+ P
2012
+ ]), ic = k(() => rc ? tt(rc.text) : null, [rc]), ac = k(() => Aa.chat.filter((e) => e.id !== fs), [Aa.chat, fs]), oc = y((e) => v(e)?.sandboxId ?? null), sc = le(ac, {
2013
+ sessionId: W?.backendSessionId,
2014
+ sandboxId: oc,
1998
2015
  nowMs: Date.now()
1999
- }), ac = ue(nc), oc = (e) => {
2016
+ }), cc = ue(ac), lc = (e) => {
2000
2017
  if (zn(e.metadata).length > 0) return !0;
2001
2018
  let t = e.metadata?.sandboxId;
2002
- return Bn(t ? Pa[t] : null);
2003
- }, sc = (e) => {
2019
+ return Bn(t ? Fa[t] : null);
2020
+ }, uc = (e) => {
2004
2021
  let t = zn(e.metadata);
2005
- return t.length === 0 || !z ? null : /* @__PURE__ */ j(Rn, {
2022
+ return t.length === 0 || !V ? null : /* @__PURE__ */ M(Rn, {
2006
2023
  refs: t,
2007
- conversationId: z,
2008
- panel: G,
2009
- entries: Fa,
2010
- capabilitiesOf: (e) => Pa[e],
2011
- turnInFlight: W,
2012
- tr: N,
2013
- onReview: La.review,
2014
- retiredSandboxes: Ia
2024
+ conversationId: V,
2025
+ panel: K,
2026
+ entries: Ia,
2027
+ capabilitiesOf: (e) => Fa[e],
2028
+ turnInFlight: Ma,
2029
+ tr: P,
2030
+ onReview: Ra.review,
2031
+ retiredSandboxes: La
2015
2032
  });
2016
- }, cc = (e) => {
2017
- if (!z) return null;
2018
- let t = Z.liveOffersFor(e, {
2033
+ }, dc = (e) => {
2034
+ if (!V) return null;
2035
+ let t = X.liveOffersFor(e, {
2019
2036
  registry: {
2020
- destinations: Xr(is),
2021
- permissionsSettled: as,
2022
- simulating: os
2037
+ destinations: Xr(ss),
2038
+ permissionsSettled: cs,
2039
+ simulating: ls
2023
2040
  },
2024
- actorId: L,
2025
- conversationId: z,
2041
+ actorId: z,
2042
+ conversationId: V,
2026
2043
  perfNow: performance.now()
2027
2044
  }), n = t[0];
2028
- return n ? /* @__PURE__ */ j(yr, {
2045
+ return n ? /* @__PURE__ */ M(yr, {
2029
2046
  offers: t.map(({ offer: e, target: t }) => ({
2030
2047
  offerId: e.offerId,
2031
2048
  label: t.label,
2032
2049
  path: t.path
2033
2050
  })),
2034
- hint: t.length === 1 && I === "proposal-v1" ? Me(n.offer, Z.turnFor(e)) : "link",
2035
- onOpen: As
2051
+ hint: t.length === 1 && L === "proposal-v1" ? je(n.offer, X.turnFor(e)) : "link",
2052
+ onOpen: Ns
2036
2053
  }, n.offer.offerId) : null;
2037
- }, lc = (e) => e.role === "assistant" ? cc(e.id) : null;
2038
- D(() => {
2039
- let e = Z.nextExpiryInMs(performance.now());
2054
+ }, fc = (e) => e.role === "assistant" ? dc(e.id) : null;
2055
+ O(() => {
2056
+ let e = X.nextExpiryInMs(performance.now());
2040
2057
  if (e === null) return;
2041
- let t = window.setTimeout(xs, e + 1);
2058
+ let t = window.setTimeout(ws, e + 1);
2042
2059
  return () => window.clearTimeout(t);
2043
2060
  }, [
2044
- Z,
2045
- ys,
2046
- xs
2061
+ X,
2062
+ Ss,
2063
+ ws
2047
2064
  ]);
2048
- let uc = La.dialog.view ? Fa[La.dialog.view.proposalId] : void 0, dc = ic?.expiresAtMs ?? null;
2049
- D(() => {
2050
- if (dc === null) return;
2051
- let e = window.setTimeout(() => Ho((e) => e + 1), Math.max(0, dc - Date.now()));
2065
+ let pc = Ra.dialog.view ? Ia[Ra.dialog.view.proposalId] : void 0, mc = sc?.expiresAtMs ?? null;
2066
+ O(() => {
2067
+ if (mc === null) return;
2068
+ let e = window.setTimeout(() => Go((e) => e + 1), Math.max(0, mc - Date.now()));
2052
2069
  return () => window.clearTimeout(e);
2053
- }, [dc, Vo]);
2054
- let fc = O(() => Aa.voice.filter((e) => e.id !== ls && (e.role === "user" || e.role === "assistant")).map((e) => ({
2070
+ }, [mc, Wo]);
2071
+ let hc = k(() => Aa.voice.filter((e) => e.id !== fs && (e.role === "user" || e.role === "assistant")).map((e) => ({
2055
2072
  id: e.id,
2056
2073
  role: e.role,
2057
- text: mn(e, U, N),
2058
- sessionId: Ke(e),
2074
+ text: pn(e, G, P),
2075
+ sessionId: Ge(e),
2059
2076
  timestamp: e.timestamp
2060
2077
  })).filter((e) => e.text.length > 0), [
2061
2078
  Aa.voice,
2062
- U,
2063
- ls,
2064
- N
2065
- ]), pc = E(() => {
2066
- if (fc.length === 0) return;
2079
+ G,
2080
+ fs,
2081
+ P
2082
+ ]), gc = D(() => {
2083
+ if (hc.length === 0) return;
2067
2084
  let e = /* @__PURE__ */ new Date();
2068
- $n($e(fc, {
2069
- title: N("voiceSession.transcript", "Voice conversation"),
2070
- savedAt: N("voiceSession.savedAt", "Saved"),
2071
- session: N("voiceSession.sessionLabel", "Session"),
2072
- earlier: N("voiceSession.earlierLabel", "Earlier"),
2073
- you: N("voiceSession.speakerYou", "You"),
2074
- assistant: N("voiceSession.speakerAssistant", "Assistant")
2075
- }, e), et(P, e), "text/markdown");
2085
+ $n(Qe(hc, {
2086
+ title: P("voiceSession.transcript", "Voice conversation"),
2087
+ savedAt: P("voiceSession.savedAt", "Saved"),
2088
+ session: P("voiceSession.sessionLabel", "Session"),
2089
+ earlier: P("voiceSession.earlierLabel", "Earlier"),
2090
+ you: P("voiceSession.speakerYou", "You"),
2091
+ assistant: P("voiceSession.speakerAssistant", "Assistant")
2092
+ }, e), $e(F, e), "text/markdown");
2076
2093
  }, [
2077
- P,
2078
- fc,
2079
- N
2080
- ]), mc = bi({ perFileChars: uo }), hc = k(mc);
2081
- hc.current = mc;
2082
- let [gc, _c] = A(null), vc = gc === null ? null : N("attachments.voiceDropped", "{{count}} attachment(s) couldn't be saved and weren't sent.", { count: gc });
2083
- D(() => {
2084
- if (gc === null) return;
2085
- let e = window.setTimeout(() => _c(null), Pi);
2094
+ F,
2095
+ hc,
2096
+ P
2097
+ ]), _c = bi({ perFileChars: fo }), vc = A(_c);
2098
+ vc.current = _c;
2099
+ let [yc, bc] = j(null), xc = yc === null ? null : P("attachments.voiceDropped", "{{count}} attachment(s) couldn't be saved and weren't sent.", { count: yc });
2100
+ O(() => {
2101
+ if (yc === null) return;
2102
+ let e = window.setTimeout(() => bc(null), Fi);
2086
2103
  return () => window.clearTimeout(e);
2087
- }, [gc]);
2088
- let yc = k(/* @__PURE__ */ new Set()), bc = k(() => !1), $ = wn({
2089
- onSubmit: E((e, t, n, r) => {
2090
- let i = xo.current, a = ft(i), o = () => {
2091
- let e = v.getState();
2092
- return st({
2093
- sessionLive: bc.current(t),
2104
+ }, [yc]);
2105
+ let Sc = A(/* @__PURE__ */ new Set()), Cc = A(() => !1), Q = wn({
2106
+ onSubmit: D((e, t, n, r) => {
2107
+ let i = Co.current, a = dt(i), o = () => {
2108
+ let e = y.getState();
2109
+ return ot({
2110
+ sessionLive: Cc.current(t),
2094
2111
  boundAtSubmit: i,
2095
2112
  activeConversationId: e.activeConversationId,
2096
2113
  boundConversationExists: e.conversations.some((e) => e.id === a)
2097
2114
  });
2098
2115
  }, s = () => {
2099
- let i = hc.current;
2100
- Nt({
2116
+ let i = vc.current;
2117
+ Mt({
2101
2118
  draft: i,
2102
2119
  maySend: o,
2103
- budgetMs: Mt,
2120
+ budgetMs: jt,
2104
2121
  sendTurn: (i) => {
2105
2122
  let a = {
2106
2123
  ...n,
2107
2124
  handedOver: vn()
2108
2125
  };
2109
- $s.current(e, i, {
2126
+ nc.current(e, i, {
2110
2127
  fromPerson: !0,
2111
2128
  voiceSessionId: t,
2112
2129
  voiceTiming: a,
2113
2130
  ...r.correction ? { correctsInFlightTurn: !0 } : {}
2114
2131
  });
2115
2132
  },
2116
- announceDropped: (e) => _c(e)
2133
+ announceDropped: (e) => bc(e)
2117
2134
  });
2118
2135
  };
2119
- if (o() && Bs.current(e, t)) {
2120
- $s.current(e, [], {
2136
+ if (o() && Us.current(e, t)) {
2137
+ nc.current(e, [], {
2121
2138
  fromPerson: !0,
2122
2139
  voiceSessionId: t,
2123
2140
  voiceTiming: {
@@ -2127,383 +2144,383 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
2127
2144
  });
2128
2145
  return;
2129
2146
  }
2130
- if (!hc.current.isBusy) {
2147
+ if (!vc.current.isBusy) {
2131
2148
  s();
2132
2149
  return;
2133
2150
  }
2134
- let c = Date.now(), l = yc.current, u = window.setInterval(() => {
2135
- let e = hc.current.isBusy;
2136
- hc.current.isCommitting || e && Date.now() - c < Ni || (window.clearInterval(u), l.delete(u), s());
2151
+ let c = Date.now(), l = Sc.current, u = window.setInterval(() => {
2152
+ let e = vc.current.isBusy;
2153
+ vc.current.isCommitting || e && Date.now() - c < Pi || (window.clearInterval(u), l.delete(u), s());
2137
2154
  }, 200);
2138
2155
  l.add(u);
2139
2156
  }, []),
2140
- latestReply: ec,
2141
- language: rt(ia, R).tag,
2157
+ latestReply: rc,
2158
+ language: nt(ia, B).tag,
2142
2159
  graceMs: ea,
2143
- onSupersede: qo,
2160
+ onSupersede: Xo,
2144
2161
  handsFreeStreamNoticeAccepted: na,
2145
2162
  onAcceptHandsFreeStreamNotice: ra,
2146
2163
  handsFreeInterrupt: ta,
2147
- onBargeIn: Ko
2164
+ onBargeIn: Yo
2148
2165
  });
2149
- bc.current = $.isCurrentSession;
2150
- let xc = So ? fc.filter((e) => e.sessionId !== void 0 && $.isCurrentSession(e.sessionId)) : fc, Sc = $.answerLocally;
2151
- D(() => {
2152
- Us.current = Sc;
2153
- }, [Sc]);
2154
- let Cc = $.active, wc = O(() => wt(Object.values(Fa), z, Ia), [
2155
- Fa,
2156
- z,
2157
- Ia
2158
- ]), [Tc, Ec] = A(null);
2159
- D(() => {
2160
- Cc || Ec(null);
2161
- }, [Cc]);
2162
- let Dc = La.review, Oc = E(() => {
2163
- let e = wc[wc.length - 1];
2166
+ Cc.current = Q.isCurrentSession;
2167
+ let wc = wo ? hc.filter((e) => e.sessionId !== void 0 && Q.isCurrentSession(e.sessionId)) : hc, Tc = Q.answerLocally;
2168
+ O(() => {
2169
+ Ks.current = Tc;
2170
+ }, [Tc]);
2171
+ let Ec = Q.active, Dc = k(() => Ct(Object.values(Ia), V, La), [
2172
+ Ia,
2173
+ V,
2174
+ La
2175
+ ]), [Oc, kc] = j(null);
2176
+ O(() => {
2177
+ Ec || kc(null);
2178
+ }, [Ec]);
2179
+ let Ac = Ra.review, jc = D(() => {
2180
+ let e = Dc[Dc.length - 1];
2164
2181
  if (!e) return;
2165
2182
  let { view: t } = e;
2166
- if (Mn(t) && jn(t, Pa[e.session.sandboxId]).offerConfirm) {
2167
- Dc(t);
2183
+ if (Mn(t) && jn(t, Fa[e.session.sandboxId]).offerConfirm) {
2184
+ Ac(t);
2168
2185
  return;
2169
2186
  }
2170
- Ec(t.proposalId);
2187
+ kc(t.proposalId);
2171
2188
  }, [
2172
- wc,
2173
- Pa,
2174
- Dc
2175
- ]), kc = Cc ? xt(wc) : null, Ac = Tc ? Fa[Tc] : void 0, jc = Cc && Ac && Ac.session.conversationId === z ? {
2176
- content: /* @__PURE__ */ j(Rn, {
2189
+ Dc,
2190
+ Fa,
2191
+ Ac
2192
+ ]), Mc = Ec ? bt(Dc) : null, Nc = Oc ? Ia[Oc] : void 0, Pc = Ec && Nc && Nc.session.conversationId === V ? {
2193
+ content: /* @__PURE__ */ M(Rn, {
2177
2194
  refs: [{
2178
- proposalId: Ac.view.proposalId,
2179
- sandboxId: Ac.session.sandboxId,
2180
- sessionId: Ac.session.sessionId
2195
+ proposalId: Nc.view.proposalId,
2196
+ sandboxId: Nc.session.sandboxId,
2197
+ sessionId: Nc.session.sessionId
2181
2198
  }],
2182
- conversationId: Ac.session.conversationId,
2183
- panel: G,
2184
- entries: Fa,
2185
- capabilitiesOf: (e) => Pa[e],
2186
- turnInFlight: W,
2187
- tr: N,
2188
- onReview: Dc,
2189
- retiredSandboxes: Ia
2199
+ conversationId: Nc.session.conversationId,
2200
+ panel: K,
2201
+ entries: Ia,
2202
+ capabilitiesOf: (e) => Fa[e],
2203
+ turnInFlight: Ma,
2204
+ tr: P,
2205
+ onReview: Ac,
2206
+ retiredSandboxes: La
2190
2207
  }),
2191
- closeLabel: Tt(N, yt.trayClose),
2192
- onClose: () => Ec(null)
2193
- } : null, Mc = La.asking, Nc = Ns?.asking === !0, Pc = Ps?.asking === !0, Fc = dr(), Ic = $.holdListening;
2194
- a("assistant.transcript", O(() => Cc || q ? null : { run: () => go ? { status: "already" } : (bo(!0), { status: "done" }) }, [
2195
- Cc,
2208
+ closeLabel: wt(P, vt.trayClose),
2209
+ onClose: () => kc(null)
2210
+ } : null, Fc = Ra.asking, Ic = Is?.asking === !0, Lc = Ls?.asking === !0, Rc = dr(), zc = Q.holdListening;
2211
+ a("assistant.transcript", k(() => Ec || q ? null : { run: () => _o ? { status: "already" } : (So(!0), { status: "done" }) }, [
2212
+ Ec,
2196
2213
  q,
2197
- go,
2198
- bo
2199
- ])), a("assistant.conversation.new", O(() => Cc ? null : { run: () => {
2200
- let e = v.getState(), t = e.conversations.find((t) => t.id === e.activeConversationId);
2214
+ _o,
2215
+ So
2216
+ ])), a("assistant.conversation.new", k(() => Ec ? null : { run: () => {
2217
+ let e = y.getState(), t = e.conversations.find((t) => t.id === e.activeConversationId);
2201
2218
  return t && t.messages.length === 0 ? { status: "already" } : (e.createConversation(), { status: "done" });
2202
- } }, [Cc])), D(() => {
2203
- Ic(Cc && (Mc || Nc || Pc || Fc));
2219
+ } }, [Ec])), O(() => {
2220
+ zc(Ec && (Fc || Ic || Lc || Rc));
2204
2221
  }, [
2205
- Cc,
2206
- Mc,
2207
- Nc,
2208
- Pc,
2222
+ Ec,
2209
2223
  Fc,
2210
- Ic
2224
+ Ic,
2225
+ Lc,
2226
+ Rc,
2227
+ zc
2211
2228
  ]);
2212
- let Lc = k(null), Rc = $.announce;
2213
- D(() => {
2214
- if (!Cc) {
2215
- Lc.current = null;
2229
+ let Bc = A(null), Vc = Q.announce;
2230
+ O(() => {
2231
+ if (!Ec) {
2232
+ Bc.current = null;
2216
2233
  return;
2217
2234
  }
2218
- let e = Lc.current;
2235
+ let e = Bc.current;
2219
2236
  if (e === null) {
2220
- Lc.current = new Set(Object.keys(Fa));
2237
+ Bc.current = new Set(Object.keys(Ia));
2221
2238
  return;
2222
2239
  }
2223
- for (let { view: t, session: n } of Ct(wc, e)) {
2240
+ for (let { view: t, session: n } of St(Dc, e)) {
2224
2241
  e.add(t.proposalId);
2225
- let r = Pa[n.sandboxId];
2226
- if (!bt({
2242
+ let r = Fa[n.sandboxId];
2243
+ if (!yt({
2227
2244
  mode: "api-calls",
2228
- productWriteApproval: I,
2245
+ productWriteApproval: L,
2229
2246
  capabilities: r
2230
2247
  })) continue;
2231
- let i = Et(t, jn(t, r).offerConfirm, N), a = t.proposalId;
2232
- Rc({
2248
+ let i = Tt(t, jn(t, r).offerConfirm, P), a = t.proposalId;
2249
+ Vc({
2233
2250
  id: `write-readback:${a}`,
2234
2251
  text: i.text,
2235
- lang: i.translated ? R : "en",
2236
- stillWanted: () => G.entry(a)?.view.status === "pending"
2252
+ lang: i.translated ? B : "en",
2253
+ stillWanted: () => K.entry(a)?.view.status === "pending"
2237
2254
  });
2238
2255
  }
2239
2256
  }, [
2240
- Cc,
2241
- wc,
2257
+ Ec,
2258
+ Dc,
2259
+ Ia,
2242
2260
  Fa,
2243
- Pa,
2244
- I,
2245
- N,
2246
- R,
2247
- Rc,
2248
- G
2261
+ L,
2262
+ P,
2263
+ B,
2264
+ Vc,
2265
+ K
2249
2266
  ]);
2250
- let zc = k(!1);
2251
- D(() => {
2252
- zc.current = $.active;
2253
- }, [$.active]), D(() => ae((e) => {
2254
- if (!zc.current) return !1;
2255
- let t = xo.current;
2256
- return typeof t == "string" ? t === e : v.getState().activeConversationId === e;
2267
+ let Hc = A(!1);
2268
+ O(() => {
2269
+ Hc.current = Q.active;
2270
+ }, [Q.active]), O(() => ae((e) => {
2271
+ if (!Hc.current) return !1;
2272
+ let t = Co.current;
2273
+ return typeof t == "string" ? t === e : y.getState().activeConversationId === e;
2257
2274
  }), []);
2258
- let Bc = $.start, Vc = E(() => {
2259
- let e = v.getState().activeConversationId, t = lt(To());
2260
- wo(dt(t, e)), Io(!0, t.kind === "own"), Bc();
2275
+ let Uc = Q.start, Wc = D(() => {
2276
+ let e = y.getState().activeConversationId, t = ct(Do());
2277
+ Eo(ut(t, e)), zo(!0, t.kind === "own"), Uc();
2261
2278
  }, [
2262
- wo,
2263
- Io,
2264
- To,
2265
- Bc
2266
- ]), Hc = O(() => pn(H?.messages ?? []), [H?.messages]), Uc = fn(Aa.voice, U, N), Wc = fn(Hc, U, N) > 0, Gc = E(() => {
2267
- let e = v.getState().activeConversationId;
2268
- if (!e || fc.length === 0) return;
2269
- let t = new Set(Hc.map((e) => e.id)), n = M();
2270
- V(e, {
2279
+ Eo,
2280
+ zo,
2281
+ Do,
2282
+ Uc
2283
+ ]), Gc = k(() => fn(W?.messages ?? []), [W?.messages]), Kc = dn(Aa.voice, G, P), qc = dn(Gc, G, P) > 0, Jc = D(() => {
2284
+ let e = y.getState().activeConversationId;
2285
+ if (!e || hc.length === 0) return;
2286
+ let t = new Set(Gc.map((e) => e.id)), n = N();
2287
+ U(e, {
2271
2288
  id: n,
2272
2289
  role: "system",
2273
- content: Qe(fc.filter((e) => t.has(e.id)), {
2274
- intro: N("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
2275
- nothing: N("voiceSession.continuedNothing", "Continued from a voice conversation."),
2276
- more: (e) => N("voiceSession.continuedMore", "…and {{count}} more", { count: e })
2290
+ content: Ze(hc.filter((e) => t.has(e.id)), {
2291
+ intro: P("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
2292
+ nothing: P("voiceSession.continuedNothing", "Continued from a voice conversation."),
2293
+ more: (e) => P("voiceSession.continuedMore", "…and {{count}} more", { count: e })
2277
2294
  }),
2278
2295
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2279
- metadata: { continuedVoiceTurns: Uc }
2280
- }), ar.recordCommittedEntries(e, [n], "NOTE", C()), bo(!1), $.end(), vo();
2296
+ metadata: { continuedVoiceTurns: Kc }
2297
+ }), ar.recordCommittedEntries(e, [n], "NOTE", w()), So(!1), Q.end(), bo();
2281
2298
  }, [
2282
- fc,
2283
- Uc,
2284
- Hc,
2285
- V,
2286
- N,
2287
- $,
2288
- bo,
2289
- vo
2290
- ]), Kc = k({
2299
+ hc,
2300
+ Kc,
2301
+ Gc,
2302
+ U,
2303
+ P,
2304
+ Q,
2305
+ So,
2306
+ bo
2307
+ ]), Yc = A({
2291
2308
  conversationId: null,
2292
2309
  count: 0
2293
2310
  });
2294
- D(() => {
2295
- $.active && (Kc.current = {
2296
- conversationId: z,
2297
- count: Uc
2311
+ O(() => {
2312
+ Q.active && (Yc.current = {
2313
+ conversationId: V,
2314
+ count: Kc
2298
2315
  });
2299
- }, [$.active]);
2300
- let qc = E(() => {
2301
- let e = Kc.current, t = Uc > (e.conversationId === z ? e.count : 0);
2302
- $.end(), t && bo(!0);
2316
+ }, [Q.active]);
2317
+ let Xc = D(() => {
2318
+ let e = Yc.current, t = Kc > (e.conversationId === V ? e.count : 0);
2319
+ Q.end(), t && So(!0);
2303
2320
  }, [
2304
- z,
2305
- Uc,
2306
- $,
2307
- bo
2321
+ V,
2322
+ Kc,
2323
+ Q,
2324
+ So
2308
2325
  ]);
2309
- D(() => {
2310
- (!Vi || !Mo) && $.active && $.end();
2326
+ O(() => {
2327
+ (!Hi || !Fo) && Q.active && Q.end();
2311
2328
  }, [
2312
- Vi,
2313
- Mo,
2314
- $
2329
+ Hi,
2330
+ Fo,
2331
+ Q
2315
2332
  ]);
2316
- let [Jc, Yc] = A(Li), Xc = xr({
2317
- available: $.available,
2318
- allowedInMode: Mo,
2319
- readOnly: Ba,
2320
- busy: W || Bo !== null || Ha || hs,
2321
- committing: Jc.committing,
2322
- dictating: Jc.dictating
2323
- }), Zc = vt(), [Qc, $c] = A(null);
2324
- D(() => {
2325
- Qc !== null && (!q || Qc.conversationId !== z) && $c(null);
2333
+ let [Zc, Qc] = j(Ri), $c = xr({
2334
+ available: Q.available,
2335
+ allowedInMode: Fo,
2336
+ readOnly: Va,
2337
+ busy: Ma || Uo !== null || Ua || vs,
2338
+ committing: Zc.committing,
2339
+ dictating: Zc.dictating
2340
+ }), el = _t(), [tl, nl] = j(null);
2341
+ O(() => {
2342
+ tl !== null && (!q || tl.conversationId !== V) && nl(null);
2326
2343
  }, [
2327
2344
  q,
2328
- z,
2329
- Qc
2345
+ V,
2346
+ tl
2330
2347
  ]);
2331
- let el = Qc !== null && Zo === Qc.replyId, tl = k(!1), nl = E(() => {
2332
- tl.current = !0, el && Qo(), Vc();
2348
+ let rl = tl !== null && es === tl.replyId, il = A(!1), al = D(() => {
2349
+ il.current = !0, rl && ts(), Wc();
2333
2350
  }, [
2334
- Vc,
2335
- el,
2336
- Qo
2351
+ Wc,
2352
+ rl,
2353
+ ts
2337
2354
  ]);
2338
- D(() => {
2339
- $.active || (tl.current = !1);
2340
- }, [$.active]), D(() => {
2341
- q || !tl.current || (tl.current = !1, $.active && qc());
2355
+ O(() => {
2356
+ Q.active || (il.current = !1);
2357
+ }, [Q.active]), O(() => {
2358
+ q || !il.current || (il.current = !1, Q.active && Xc());
2342
2359
  }, [
2343
2360
  q,
2344
- $.active,
2345
- qc
2346
- ]), D(() => {
2347
- q && bo(!1);
2348
- }, [q, bo]);
2349
- let rl = O(() => ({
2350
- live: $.active,
2351
- blocked: Xc === null ? null : Zc.voiceStartBlocked(Xc),
2352
- impossible: Sr(Xc),
2353
- start: nl
2361
+ Q.active,
2362
+ Xc
2363
+ ]), O(() => {
2364
+ q && So(!1);
2365
+ }, [q, So]);
2366
+ let ol = k(() => ({
2367
+ live: Q.active,
2368
+ blocked: $c === null ? null : el.voiceStartBlocked($c),
2369
+ impossible: Sr($c),
2370
+ start: al
2354
2371
  }), [
2355
- $.active,
2356
- Xc,
2357
- Zc,
2358
- nl
2359
- ]), [il, al] = A("mini"), ol = Vi && K.covered !== !0 && !($.active && il !== "mini") && !(go && !$.active) && !(Mc || Nc || Pc || Fc), sl = _o?.ask, cl = ki(sl?.subscribe ?? zi, sl?.getSnapshot ?? Bi, sl?.getSnapshot ?? Bi), ll = Cr({
2360
- voiceLive: $.active,
2361
- readOnly: Ba,
2372
+ Q.active,
2373
+ $c,
2374
+ el,
2375
+ al
2376
+ ]), [sl, cl] = j("mini"), ll = Hi && vo.covered !== !0 && !(Q.active && sl !== "mini") && !(_o && !Q.active) && !(Fc || Ic || Lc || Rc), ul = yo?.ask, dl = Ai(ul?.subscribe ?? Bi, ul?.getSnapshot ?? Vi, ul?.getSnapshot ?? Vi), fl = Cr({
2377
+ voiceLive: Q.active,
2378
+ readOnly: Va,
2362
2379
  writes: wr({
2363
- auto: io,
2364
- selectedMode: B,
2365
- conversation: H && !Ba ? {
2366
- mode: H.mode,
2367
- routedBy: H.routedBy,
2368
- hasHistory: er(H)
2380
+ auto: ao,
2381
+ selectedMode: H,
2382
+ conversation: W && !Va ? {
2383
+ mode: W.mode,
2384
+ routedBy: W.routedBy,
2385
+ hasHistory: er(W)
2369
2386
  } : null,
2370
- modeWrites: (e) => F.find((t) => t.id === e)?.writeCapable === !0 || Ce(e)
2387
+ modeWrites: (e) => I.find((t) => t.id === e)?.writeCapable === !0 || Se(e)
2371
2388
  }),
2372
- avatar: cl,
2373
- busy: W || Bo !== null || Ha || hs || fo !== null || co,
2374
- committing: Jc.committing
2375
- }), ul = k(ll);
2376
- Oi(() => {
2377
- ul.current = ll;
2378
- }, [ll]);
2379
- let dl = E((e) => {
2389
+ avatar: dl,
2390
+ busy: Ma || Uo !== null || Ua || vs || po !== null || lo,
2391
+ committing: Zc.committing
2392
+ }), pl = A(fl);
2393
+ ki(() => {
2394
+ pl.current = fl;
2395
+ }, [fl]);
2396
+ let ml = D((e) => {
2380
2397
  let t = e.trim();
2381
- if (t === "" || ul.current !== null) return { accepted: !1 };
2382
- el && Qo();
2398
+ if (t === "" || pl.current !== null) return { accepted: !1 };
2399
+ rl && ts();
2383
2400
  let n = {
2384
- token: M(),
2401
+ token: N(),
2385
2402
  exchange: null,
2386
2403
  handled: !1
2387
2404
  };
2388
- $o.current = n;
2405
+ ns.current = n;
2389
2406
  try {
2390
- Q(t, [], {
2407
+ Z(t, [], {
2391
2408
  fromPerson: !0,
2392
2409
  avatarTabAsk: n.token,
2393
2410
  localRecordsChecked: !0,
2394
- ...io ? { autoIntent: "read" } : {}
2411
+ ...ao ? { autoIntent: "read" } : {}
2395
2412
  });
2396
2413
  } finally {
2397
- $o.current = null;
2414
+ ns.current = null;
2398
2415
  }
2399
2416
  let r = n.exchange;
2400
2417
  return r === null ? n.handled ? {
2401
2418
  accepted: !0,
2402
2419
  recorded: !1
2403
- } : { accepted: !1 } : ($c(r), {
2420
+ } : { accepted: !1 } : (nl(r), {
2404
2421
  accepted: !0,
2405
2422
  recorded: !0,
2406
2423
  ...r
2407
2424
  });
2408
2425
  }, [
2409
- io,
2410
- Q,
2411
- Qo,
2412
- el
2413
- ]), [fl] = A(() => Er()), pl = O(() => ({
2414
- blocker: ll,
2415
- line: Tr(ll, Xc),
2416
- send: dl,
2417
- last: Qc,
2418
- navigatingReplyId: _s,
2419
- draft: fl
2426
+ ao,
2427
+ Z,
2428
+ ts,
2429
+ rl
2430
+ ]), [hl] = j(() => Er()), gl = k(() => ({
2431
+ blocker: fl,
2432
+ line: Tr(fl, $c),
2433
+ send: ml,
2434
+ last: tl,
2435
+ navigatingReplyId: bs,
2436
+ draft: hl
2420
2437
  }), [
2421
- ll,
2422
- Xc,
2423
- dl,
2424
- Qc,
2425
- _s,
2426
- fl
2427
- ]), ml = K.setReplyEscape, hl = q && ol && el;
2428
- D(() => {
2429
- if (!(!ml || !hl)) return ml(Qo), () => ml(null);
2430
- }, [
2438
+ fl,
2439
+ $c,
2431
2440
  ml,
2432
- hl,
2433
- Qo
2434
- ]), D(() => {
2435
- let e = xo.current, t = ft(e), n = v.getState(), r = S({
2436
- sessionLive: $.active,
2441
+ tl,
2442
+ bs,
2443
+ hl
2444
+ ]), _l = vo.setReplyEscape, vl = q && ll && rl;
2445
+ O(() => {
2446
+ if (!(!_l || !vl)) return _l(ts), () => _l(null);
2447
+ }, [
2448
+ _l,
2449
+ vl,
2450
+ ts
2451
+ ]), O(() => {
2452
+ let e = Co.current, t = dt(e), n = y.getState(), r = C({
2453
+ sessionLive: Q.active,
2437
2454
  bound: e,
2438
2455
  activeConversationId: n.activeConversationId,
2439
2456
  boundConversationExists: n.conversations.some((e) => e.id === t)
2440
2457
  });
2441
- wo(r.bound), r.end && $.end();
2458
+ Eo(r.bound), r.end && Q.end();
2442
2459
  }, [
2443
- $,
2444
- z,
2460
+ Q,
2461
+ V,
2445
2462
  ua,
2446
- wo
2463
+ Eo
2447
2464
  ]);
2448
- let gl = k(at);
2449
- D(() => {
2450
- let e = ct(gl.current, {
2451
- activeConversationId: z,
2452
- chatTurnCount: nc.length,
2453
- voiceTurnCount: fc.length,
2454
- sessionLive: $.active,
2455
- sessionBoundTo: xo.current,
2456
- turnInFlight: W
2465
+ let yl = A(it);
2466
+ O(() => {
2467
+ let e = st(yl.current, {
2468
+ activeConversationId: V,
2469
+ chatTurnCount: ac.length,
2470
+ voiceTurnCount: hc.length,
2471
+ sessionLive: Q.active,
2472
+ sessionBoundTo: Co.current,
2473
+ turnInFlight: Ma
2457
2474
  });
2458
- gl.current = e.state, e.open && bo(!0);
2475
+ yl.current = e.state, e.open && So(!0);
2459
2476
  }, [
2460
- z,
2461
- nc.length,
2462
- fc.length,
2463
- $.active,
2464
- W,
2465
- bo
2466
- ]), D(() => {
2467
- if (!$.active) {
2468
- hc.current.clear(), _c(null), Wo.current = null;
2469
- for (let e of yc.current) window.clearInterval(e);
2470
- yc.current.clear();
2477
+ V,
2478
+ ac.length,
2479
+ hc.length,
2480
+ Q.active,
2481
+ Ma,
2482
+ So
2483
+ ]), O(() => {
2484
+ if (!Q.active) {
2485
+ vc.current.clear(), bc(null), qo.current = null;
2486
+ for (let e of Sc.current) window.clearInterval(e);
2487
+ Sc.current.clear();
2471
2488
  }
2472
- }, [$.active]), D(() => {
2473
- let e = yc.current;
2489
+ }, [Q.active]), O(() => {
2490
+ let e = Sc.current;
2474
2491
  return () => {
2475
2492
  for (let t of e) window.clearInterval(t);
2476
2493
  e.clear();
2477
2494
  };
2478
- }, []), D(() => {
2479
- let e = v.getState().consumePendingPrompt();
2480
- return e && $s.current(e), v.subscribe((e, t) => {
2495
+ }, []), O(() => {
2496
+ let e = y.getState().consumePendingPrompt();
2497
+ return e && nc.current(e), y.subscribe((e, t) => {
2481
2498
  if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
2482
- let e = v.getState().consumePendingPrompt();
2483
- e && $s.current(e);
2499
+ let e = y.getState().consumePendingPrompt();
2500
+ e && nc.current(e);
2484
2501
  }
2485
2502
  });
2486
2503
  }, []);
2487
- let _l = E((e) => {
2488
- let t = z ? v.getState().conversations.find((e) => e.id === z) : void 0;
2489
- if (t && t.mode !== e && G.withdraw(t.id, "mode_switched"), t && er(t)) {
2504
+ let bl = D((e) => {
2505
+ let t = V ? y.getState().conversations.find((e) => e.id === V) : void 0;
2506
+ if (t && t.mode !== e && K.withdraw(t.id, "mode_switched"), t && er(t)) {
2490
2507
  if (t.mode !== e) {
2491
- let t = ie(), n = v.getState().conversations.find((n) => n.mode === e && rr(n, t) && !v.getState().processingByConversationId[n.id]);
2508
+ let t = ie(), n = y.getState().conversations.find((n) => n.mode === e && rr(n, t) && !y.getState().processingByConversationId[n.id]);
2492
2509
  n ? ma(n.id) : ha(void 0, e);
2493
2510
  }
2494
- } else z && pa(z, e);
2495
- let n = v.getState().activeConversationId;
2511
+ } else V && pa(V, e);
2512
+ let n = y.getState().activeConversationId;
2496
2513
  n ? pa(n, e) : Oa(!1), fa(e);
2497
2514
  }, [
2498
- z,
2515
+ V,
2499
2516
  ha,
2500
2517
  ma,
2501
2518
  Oa,
2502
2519
  pa,
2503
2520
  fa,
2504
- G
2505
- ]), vl = E(() => {
2506
- let e = v.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
2521
+ K
2522
+ ]), xl = D(() => {
2523
+ let e = y.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
2507
2524
  if (!t) {
2508
2525
  Oa(!0), fa(p);
2509
2526
  return;
@@ -2516,7 +2533,7 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
2516
2533
  ka(t.id, p);
2517
2534
  return;
2518
2535
  }
2519
- G.withdraw(t.id, "mode_switched");
2536
+ K.withdraw(t.id, "mode_switched");
2520
2537
  let n = ie(), r = e.conversations.find((t) => t.routedBy === "auto" && rr(t, n) && !e.processingByConversationId[t.id]);
2521
2538
  r ? (ma(r.id), ka(r.id, p)) : ha(void 0, p, { routedBy: "auto" });
2522
2539
  }, [
@@ -2525,36 +2542,36 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
2525
2542
  ma,
2526
2543
  Oa,
2527
2544
  fa,
2528
- G
2529
- ]), yl = E((e) => {
2530
- if (F.find((t) => t.id === e)?.writeCapable && !de(v.getState().acknowledgedWriteModes, e)) {
2531
- po(e);
2545
+ K
2546
+ ]), Sl = D((e) => {
2547
+ if (I.find((t) => t.id === e)?.writeCapable && !de(y.getState().acknowledgedWriteModes, e)) {
2548
+ mo(e);
2532
2549
  return;
2533
2550
  }
2534
- _l(e);
2535
- }, [_l, F]), bl = E(() => {
2536
- let e = fo;
2537
- if (po(null), !e) return;
2538
- let t = oo.current;
2539
- if (oo.current = null, t) {
2540
- Ea(e), Q(t.content, t.attachments, t.options);
2551
+ bl(e);
2552
+ }, [bl, I]), Cl = D(() => {
2553
+ let e = po;
2554
+ if (mo(null), !e) return;
2555
+ let t = so.current;
2556
+ if (so.current = null, t) {
2557
+ Ea(e), Z(t.content, t.attachments, t.options);
2541
2558
  return;
2542
2559
  }
2543
- Ea(e), _l(e);
2560
+ Ea(e), bl(e);
2544
2561
  }, [
2545
- fo,
2562
+ po,
2546
2563
  Ea,
2547
- _l,
2548
- Q
2549
- ]), xl = fo === null ? void 0 : F.find((e) => e.id === fo) ?? { id: fo }, Sl = E(() => {
2550
- po(null);
2551
- let e = oo.current;
2552
- oo.current = null, e && Q(e.content, e.attachments, {
2564
+ bl,
2565
+ Z
2566
+ ]), wl = po === null ? void 0 : I.find((e) => e.id === po) ?? { id: po }, Tl = D(() => {
2567
+ mo(null);
2568
+ let e = so.current;
2569
+ so.current = null, e && Z(e.content, e.attachments, {
2553
2570
  ...e.options,
2554
2571
  autoIntent: "read"
2555
2572
  });
2556
- }, [Q]), Cl = E(() => Ko(), [Ko]), [wl, Tl] = A(null), El = E(() => {
2557
- let e = v.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0, n = Ro.current;
2573
+ }, [Z]), El = D(() => Yo(), [Yo]), [$, Dl] = j(null), Ol = D(() => {
2574
+ let e = y.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0, n = Vo.current;
2558
2575
  return {
2559
2576
  state: e,
2560
2577
  conversation: t ? {
@@ -2562,12 +2579,12 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
2562
2579
  hasHistory: er(t),
2563
2580
  routedByAuto: t.routedBy === "auto"
2564
2581
  } : null,
2565
- waitingCount: t ? G.liveFor(t.id).count : 0,
2582
+ waitingCount: t ? K.liveFor(t.id).count : 0,
2566
2583
  hasDraft: n !== null && (n.text.trim() !== "" || n.hasAttachments)
2567
2584
  };
2568
- }, [G]), Dl = io ? N("modeSelector.auto", "Auto") : void 0, Ol = E((e) => {
2569
- if (fo !== null) return;
2570
- let { state: t, conversation: n, waitingCount: r, hasDraft: i } = El(), a = F.find((t) => t.id === e), o = Kn({
2585
+ }, [K]), kl = ao ? P("modeSelector.auto", "Auto") : void 0, Al = D((e) => {
2586
+ if (po !== null) return;
2587
+ let { state: t, conversation: n, waitingCount: r, hasDraft: i } = Ol(), a = I.find((t) => t.id === e), o = Kn({
2571
2588
  target: {
2572
2589
  kind: "mode",
2573
2590
  mode: e,
@@ -2578,255 +2595,255 @@ var zi = () => () => {}, Bi = () => "off", Vi = ({ visible: Vi = !0, writeAccess
2578
2595
  hasDraft: i
2579
2596
  });
2580
2597
  if (!o.needsDialog) {
2581
- _l(e);
2598
+ bl(e);
2582
2599
  return;
2583
2600
  }
2584
- Tl({
2601
+ Dl({
2585
2602
  open: !0,
2586
2603
  target: {
2587
2604
  kind: "mode",
2588
2605
  mode: e
2589
2606
  },
2590
2607
  plan: o,
2591
- targetName: Gn(N, a ?? { id: e }),
2592
- currentName: Dl
2608
+ targetName: Gn(P, a ?? { id: e }),
2609
+ currentName: kl
2593
2610
  });
2594
2611
  }, [
2595
- Dl,
2596
- El,
2597
- fo,
2598
- _l,
2599
- F,
2600
- N
2601
- ]), kl = E(() => {
2602
- if (fo !== null) return;
2603
- let { conversation: e, waitingCount: t, hasDraft: n } = El(), r = Kn({
2612
+ kl,
2613
+ Ol,
2614
+ po,
2615
+ bl,
2616
+ I,
2617
+ P
2618
+ ]), jl = D(() => {
2619
+ if (po !== null) return;
2620
+ let { conversation: e, waitingCount: t, hasDraft: n } = Ol(), r = Kn({
2604
2621
  target: { kind: "auto" },
2605
2622
  conversation: e,
2606
2623
  waitingCount: t,
2607
2624
  hasDraft: n
2608
2625
  });
2609
2626
  if (!r.needsDialog) {
2610
- vl();
2627
+ xl();
2611
2628
  return;
2612
2629
  }
2613
- Tl({
2630
+ Dl({
2614
2631
  open: !0,
2615
2632
  target: { kind: "auto" },
2616
2633
  plan: r,
2617
- targetName: N("modeSelector.auto", "Auto")
2634
+ targetName: P("modeSelector.auto", "Auto")
2618
2635
  });
2619
2636
  }, [
2620
- vl,
2621
- El,
2622
- fo,
2623
- N
2624
- ]), Al = E(() => {
2625
- let e = wl;
2637
+ xl,
2638
+ Ol,
2639
+ po,
2640
+ P
2641
+ ]), Ml = D(() => {
2642
+ let e = $;
2626
2643
  if (e?.open) {
2627
- if (Tl({
2644
+ if (Dl({
2628
2645
  ...e,
2629
2646
  open: !1
2630
2647
  }), e.target.kind === "auto") {
2631
- vl();
2648
+ xl();
2632
2649
  return;
2633
2650
  }
2634
- e.plan.consent && Ea(e.target.mode), _l(e.target.mode);
2651
+ e.plan.consent && Ea(e.target.mode), bl(e.target.mode);
2635
2652
  }
2636
2653
  }, [
2637
2654
  Ea,
2638
- vl,
2639
- wl,
2640
- _l
2641
- ]), jl = E(() => {
2642
- Tl((e) => e && {
2655
+ xl,
2656
+ $,
2657
+ bl
2658
+ ]), Nl = D(() => {
2659
+ Dl((e) => e && {
2643
2660
  ...e,
2644
2661
  open: !1
2645
2662
  });
2646
- }, []), Ml = wl ? {
2647
- consent: wl.plan.consent,
2648
- withdrawnCount: wl.plan.withdrawnCount,
2649
- movesToNewConversation: wl.plan.movesToNewConversation,
2650
- draftKept: wl.plan.draftKept,
2651
- targetName: wl.targetName,
2652
- ...wl.currentName === void 0 ? {} : { currentName: wl.currentName }
2653
- } : void 0, Nl = wl?.target.kind === "mode" ? wl.target.mode : null, Pl = Nl === null ? void 0 : F.find((e) => e.id === Nl) ?? { id: Nl };
2654
- return /* @__PURE__ */ Ai("div", {
2663
+ }, []), Pl = $ ? {
2664
+ consent: $.plan.consent,
2665
+ withdrawnCount: $.plan.withdrawnCount,
2666
+ movesToNewConversation: $.plan.movesToNewConversation,
2667
+ draftKept: $.plan.draftKept,
2668
+ targetName: $.targetName,
2669
+ ...$.currentName === void 0 ? {} : { currentName: $.currentName }
2670
+ } : void 0, Fl = $?.target.kind === "mode" ? $.target.mode : null, Il = Fl === null ? void 0 : I.find((e) => e.id === Fl) ?? { id: Fl };
2671
+ return /* @__PURE__ */ ji("div", {
2655
2672
  className: "relative flex flex-1 flex-col overflow-hidden",
2656
2673
  children: [
2657
- /* @__PURE__ */ Ai("div", {
2674
+ /* @__PURE__ */ ji("div", {
2658
2675
  className: "contents",
2659
- inert: $.active || q || void 0,
2660
- ...K.ids ? {
2676
+ inert: Q.active || q || void 0,
2677
+ ...vo.ids ? {
2661
2678
  role: "tabpanel",
2662
- id: K.ids.chatPanel,
2663
- "aria-labelledby": K.ids.chatTab
2679
+ id: vo.ids.chatPanel,
2680
+ "aria-labelledby": vo.ids.chatTab
2664
2681
  } : {},
2665
2682
  children: [
2666
- qa === null ? null : /* @__PURE__ */ j(Jn, { onDismiss: () => Ka(qa) }),
2667
- fc.length > 0 && !$.active ? /* @__PURE__ */ j(Wn, {
2668
- count: fc.length,
2669
- onOpenTranscript: () => bo(!0)
2683
+ Ja === null ? null : /* @__PURE__ */ M(Jn, { onDismiss: () => qa(Ja) }),
2684
+ hc.length > 0 && !Q.active ? /* @__PURE__ */ M(Wn, {
2685
+ count: hc.length,
2686
+ onOpenTranscript: () => So(!0)
2670
2687
  }) : null,
2671
- nc.length === 0 && (Ha || Ua) ? /* @__PURE__ */ j(Yn, {
2672
- state: Ha ? "loading" : "failed",
2673
- onRetry: Qa
2674
- }) : nc.length === 0 && H?.sync?.hasOlder ? /* @__PURE__ */ j("div", {
2688
+ ac.length === 0 && (Ua || Wa) ? /* @__PURE__ */ M(Yn, {
2689
+ state: Ua ? "loading" : "failed",
2690
+ onRetry: $a
2691
+ }) : ac.length === 0 && W?.sync?.hasOlder ? /* @__PURE__ */ M("div", {
2675
2692
  className: "flex min-h-0 flex-1 flex-col",
2676
- children: /* @__PURE__ */ j(Zn, {
2677
- onShowEarlier: $a,
2678
- disabled: Ha
2693
+ children: /* @__PURE__ */ M(Zn, {
2694
+ onShowEarlier: eo,
2695
+ disabled: Ua
2679
2696
  })
2680
- }) : nc.length === 0 ? /* @__PURE__ */ j(or, {
2681
- mode: B,
2682
- onSuggestionClick: Xs,
2683
- explainsAuto: io,
2684
- suggestions: io && B === "assistant" ? ee(F.find((e) => e.id === "assistant")?.suggestions ?? [], F.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
2685
- }) : /* @__PURE__ */ Ai("div", {
2697
+ }) : ac.length === 0 ? /* @__PURE__ */ M(or, {
2698
+ mode: H,
2699
+ onSuggestionClick: $s,
2700
+ explainsAuto: ao,
2701
+ suggestions: ao && H === "assistant" ? ee(I.find((e) => e.id === "assistant")?.suggestions ?? [], I.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
2702
+ }) : /* @__PURE__ */ ji("div", {
2686
2703
  className: "flex min-h-0 flex-1 flex-col",
2687
- children: [H?.sync?.hasOlder ? /* @__PURE__ */ j(Zn, {
2688
- onShowEarlier: $a,
2689
- disabled: Ha
2690
- }) : null, /* @__PURE__ */ j(vr, {
2691
- onApprovePendingWrite: Jo,
2692
- approvingWriteRef: Bo,
2693
- approvableMessageId: ic?.messageId ?? null,
2694
- retryableMessageId: ac,
2695
- messages: nc,
2696
- processing: U ?? null,
2697
- streamingMessageId: Ma,
2698
- failedMessageId: Na,
2699
- onRetry: Bo === null ? Qs : void 0,
2700
- renderWriteProposals: sc,
2701
- hidesLegacyWriteCard: oc,
2702
- renderUiOffers: lc
2704
+ children: [W?.sync?.hasOlder ? /* @__PURE__ */ M(Zn, {
2705
+ onShowEarlier: eo,
2706
+ disabled: Ua
2707
+ }) : null, /* @__PURE__ */ M(vr, {
2708
+ onApprovePendingWrite: Zo,
2709
+ approvingWriteRef: Uo,
2710
+ approvableMessageId: sc?.messageId ?? null,
2711
+ retryableMessageId: cc,
2712
+ messages: ac,
2713
+ processing: G ?? null,
2714
+ streamingMessageId: Na,
2715
+ failedMessageId: Pa,
2716
+ onRetry: Uo === null ? tc : void 0,
2717
+ renderWriteProposals: uc,
2718
+ hidesLegacyWriteCard: lc,
2719
+ renderUiOffers: fc
2703
2720
  })]
2704
2721
  }),
2705
- Ba ? /* @__PURE__ */ j(Xn, { onStartNew: () => ha() }) : null,
2706
- Va && z ? /* @__PURE__ */ j(qn, { onUnarchive: () => ar.updateConversation(z, { archived: !1 }) }) : null,
2707
- Ws === null ? null : /* @__PURE__ */ j(sr, {
2708
- tr: N,
2709
- onDismiss: () => Gs(null)
2722
+ Va ? /* @__PURE__ */ M(Xn, { onStartNew: () => ha() }) : null,
2723
+ Ha && V ? /* @__PURE__ */ M(qn, { onUnarchive: () => ar.updateConversation(V, { archived: !1 }) }) : null,
2724
+ qs === null ? null : /* @__PURE__ */ M(sr, {
2725
+ tr: P,
2726
+ onDismiss: () => Js(null)
2710
2727
  }),
2711
- nc.length > 0 && (Ha || Ua) ? /* @__PURE__ */ j(Yn, {
2712
- state: Ha ? "loading" : "failed",
2713
- onRetry: Qa,
2728
+ ac.length > 0 && (Ua || Wa) ? /* @__PURE__ */ M(Yn, {
2729
+ state: Ua ? "loading" : "failed",
2730
+ onRetry: $a,
2714
2731
  compact: !0
2715
2732
  }) : null,
2716
- /* @__PURE__ */ j(xi, {
2717
- onStartVoiceSession: $.available && Mo ? Vc : void 0,
2718
- onSend: (e, t) => void Q(e, t, { fromPerson: !0 }),
2719
- onDraftChange: Rs,
2720
- disabled: W || Bo !== null || Ha || hs,
2721
- readOnly: Ba,
2722
- placeholder: B === "api-calls" ? N("chatArea.placeholderActions", "What would you like me to do?") : N("chatArea.placeholderGeneral", "Ask me anything…"),
2723
- mode: B,
2724
- writeAccessDenied: Hi === "denied" && !!ko?.writeCapable,
2725
- availableModes: no,
2726
- attachmentCharsPerFile: uo,
2727
- onModeChange: Wi ? Ol : yl,
2728
- auto: ro ? {
2729
- active: io,
2730
- onSelect: Wi ? kl : vl
2733
+ /* @__PURE__ */ M(xi, {
2734
+ onStartVoiceSession: Q.available && Fo ? Wc : void 0,
2735
+ onSend: (e, t) => void Z(e, t, { fromPerson: !0 }),
2736
+ onDraftChange: Vs,
2737
+ disabled: Ma || Uo !== null || Ua || vs,
2738
+ readOnly: Va,
2739
+ placeholder: H === "api-calls" ? P("chatArea.placeholderActions", "What would you like me to do?") : P("chatArea.placeholderGeneral", "Ask me anything…"),
2740
+ mode: H,
2741
+ writeAccessDenied: Ui === "denied" && !!Mo?.writeCapable,
2742
+ availableModes: ro,
2743
+ attachmentCharsPerFile: fo,
2744
+ onModeChange: Gi ? Al : Sl,
2745
+ auto: io ? {
2746
+ active: ao,
2747
+ onSelect: Gi ? jl : xl
2731
2748
  } : void 0,
2732
2749
  suspendDictation: q,
2733
- onVoiceStateChange: K.ids ? Yc : void 0,
2734
- presentation: Ui,
2735
- turnInFlight: W,
2736
- onStop: Wi ? Cl : void 0,
2737
- modeDisabledReason: W ? "replying" : "busy"
2750
+ onVoiceStateChange: vo.ids ? Qc : void 0,
2751
+ presentation: Wi,
2752
+ turnInFlight: Ma,
2753
+ onStop: Gi ? El : void 0,
2754
+ modeDisabledReason: Ma ? "replying" : "busy"
2738
2755
  }),
2739
- /* @__PURE__ */ j(Fn, {
2740
- productKey: P,
2741
- enabled: !!Ji,
2756
+ /* @__PURE__ */ M(Fn, {
2757
+ productKey: F,
2758
+ enabled: !!Yi,
2742
2759
  className: "px-3 pt-1 text-center",
2743
2760
  testId: "assistant-ai-credit-balance"
2744
2761
  }),
2745
- /* @__PURE__ */ j(An, { className: "px-3 pb-2 pt-1" })
2762
+ /* @__PURE__ */ M(An, { className: "px-3 pb-2 pt-1" })
2746
2763
  ]
2747
2764
  }),
2748
- go && !$.active ? /* @__PURE__ */ j(Qn, {
2749
- turns: fc,
2750
- onClose: () => bo(!1),
2751
- onSave: pc,
2752
- onContinueInChat: Wc ? Gc : void 0,
2765
+ _o && !Q.active ? /* @__PURE__ */ M(Qn, {
2766
+ turns: hc,
2767
+ onClose: () => So(!1),
2768
+ onSave: gc,
2769
+ onContinueInChat: qc ? Jc : void 0,
2753
2770
  closeOnEscape: !0,
2754
- onShowEarlier: H?.sync?.hasOlder ? $a : void 0,
2755
- showEarlierDisabled: Ha,
2756
- renderAfterTurn: cc
2771
+ onShowEarlier: W?.sync?.hasOlder ? eo : void 0,
2772
+ showEarlierDisabled: Ua,
2773
+ renderAfterTurn: dc
2757
2774
  }) : null,
2758
- q && _o && K.ids ? /* @__PURE__ */ j(Dr, {
2759
- tab: _o,
2760
- id: K.ids.avatarPanel,
2761
- labelledBy: K.ids.avatarTab,
2762
- leaveHintId: K.ids.leaveHint,
2763
- shown: ol,
2764
- voice: rl,
2765
- ...sl ? { ask: pl } : {}
2775
+ q && yo && vo.ids ? /* @__PURE__ */ M(Dr, {
2776
+ tab: yo,
2777
+ id: vo.ids.avatarPanel,
2778
+ labelledBy: vo.ids.avatarTab,
2779
+ leaveHintId: vo.ids.leaveHint,
2780
+ shown: ll,
2781
+ voice: ol,
2782
+ ...ul ? { ask: gl } : {}
2766
2783
  }) : null,
2767
- $.active && /* @__PURE__ */ j(br, {
2768
- session: $.session,
2769
- notice: $.notice,
2770
- privacyNotice: $.handsFree.privacyNotice,
2771
- capturing: $.capturing,
2772
- interrupting: $.interrupting,
2773
- awaitingEndpoint: $.awaitingEndpoint,
2774
- holding: $.holding,
2775
- correcting: $.correcting,
2776
- onLetMeFinish: $.letMeFinish,
2777
- onImDone: $.imDone,
2778
- turns: xc,
2779
- spokenChunks: $.spokenChunks,
2780
- attachments: mc.attachments,
2781
- onAttachFiles: mc.addFiles,
2782
- onRemoveAttachment: mc.remove,
2783
- onRetryAttachment: mc.retry,
2784
- canAttachMore: mc.canAddMore,
2785
- preparingAttachments: mc.preparingCount,
2786
- attachmentsLocked: mc.isCommitting,
2787
- attachmentNotice: vc,
2788
- onSaveTranscript: pc,
2789
- onContinueInChat: Gc,
2784
+ Q.active && /* @__PURE__ */ M(br, {
2785
+ session: Q.session,
2786
+ notice: Q.notice,
2787
+ privacyNotice: Q.handsFree.privacyNotice,
2788
+ capturing: Q.capturing,
2789
+ interrupting: Q.interrupting,
2790
+ awaitingEndpoint: Q.awaitingEndpoint,
2791
+ holding: Q.holding,
2792
+ correcting: Q.correcting,
2793
+ onLetMeFinish: Q.letMeFinish,
2794
+ onImDone: Q.imDone,
2795
+ turns: wc,
2796
+ spokenChunks: Q.spokenChunks,
2797
+ attachments: _c.attachments,
2798
+ onAttachFiles: _c.addFiles,
2799
+ onRemoveAttachment: _c.remove,
2800
+ onRetryAttachment: _c.retry,
2801
+ canAttachMore: _c.canAddMore,
2802
+ preparingAttachments: _c.preparingCount,
2803
+ attachmentsLocked: _c.isCommitting,
2804
+ attachmentNotice: xc,
2805
+ onSaveTranscript: gc,
2806
+ onContinueInChat: Jc,
2790
2807
  onInterrupt: () => {
2791
- $.interrupt(), Ko();
2808
+ Q.interrupt(), Yo();
2792
2809
  },
2793
- spoken: tc,
2794
- onToggleMute: $.toggleMute,
2795
- onEnd: qc,
2796
- proposalChip: kc ? {
2797
- label: St(kc, N),
2798
- onOpen: Oc
2810
+ spoken: ic,
2811
+ onToggleMute: Q.toggleMute,
2812
+ onEnd: Xc,
2813
+ proposalChip: Mc ? {
2814
+ label: xt(Mc, P),
2815
+ onOpen: jc
2799
2816
  } : null,
2800
- proposalTray: jc,
2801
- renderAfterTurn: cc,
2802
- onViewChange: K.ids ? al : void 0
2817
+ proposalTray: Pc,
2818
+ renderAfterTurn: dc,
2819
+ onViewChange: vo.ids ? cl : void 0
2803
2820
  }),
2804
- /* @__PURE__ */ j(Ci, {
2805
- open: fo !== null,
2806
- mode: xl,
2807
- currentMode: ko ?? { id: B },
2808
- onConfirm: bl,
2809
- onCancel: Sl
2821
+ /* @__PURE__ */ M(Ci, {
2822
+ open: po !== null,
2823
+ mode: wl,
2824
+ currentMode: Mo ?? { id: H },
2825
+ onConfirm: Cl,
2826
+ onCancel: Tl
2810
2827
  }),
2811
- Wi ? /* @__PURE__ */ j(Ci, {
2812
- open: wl?.open === !0,
2813
- mode: Pl,
2814
- currentMode: ko ?? { id: B },
2815
- switchPlan: Ml,
2816
- onConfirm: Al,
2817
- onCancel: jl
2828
+ Gi ? /* @__PURE__ */ M(Ci, {
2829
+ open: $?.open === !0,
2830
+ mode: Il,
2831
+ currentMode: Mo ?? { id: H },
2832
+ switchPlan: Pl,
2833
+ onConfirm: Ml,
2834
+ onCancel: Nl
2818
2835
  }) : null,
2819
- /* @__PURE__ */ j(In, {
2820
- ...La.dialog,
2821
- view: uc?.view ?? La.dialog.view,
2822
- serverNow: uc?.serverNow ?? NaN,
2823
- arrivedAt: uc?.arrivedAt ?? NaN,
2824
- capabilities: uc ? Pa[uc.session.sandboxId] : null,
2825
- turnInFlight: W,
2826
- tr: N
2836
+ /* @__PURE__ */ M(In, {
2837
+ ...Ra.dialog,
2838
+ view: pc?.view ?? Ra.dialog.view,
2839
+ serverNow: pc?.serverNow ?? NaN,
2840
+ arrivedAt: pc?.arrivedAt ?? NaN,
2841
+ capabilities: pc ? Fa[pc.session.sandboxId] : null,
2842
+ turnInFlight: Ma,
2843
+ tr: P
2827
2844
  })
2828
2845
  ]
2829
2846
  });
2830
2847
  };
2831
2848
  //#endregion
2832
- export { Vi as AssistantChatArea };
2849
+ export { Hi as AssistantChatArea };