@oxvo/ai-live-assist 7.4.50 → 7.5.0

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 (163) hide show
  1. package/cjs/AiLiveAssist.d.ts +76 -11
  2. package/cjs/AiLiveAssist.js +1771 -298
  3. package/cjs/client.d.ts +19 -0
  4. package/cjs/client.js +51 -0
  5. package/cjs/context.d.ts +23 -1
  6. package/cjs/context.js +713 -126
  7. package/cjs/control.d.ts +2 -0
  8. package/cjs/control.js +42 -3
  9. package/cjs/ctaOffer.d.ts +11 -0
  10. package/cjs/ctaOffer.js +185 -0
  11. package/cjs/dialogFocusScope.js +1 -1
  12. package/cjs/guideAdmission.d.ts +46 -0
  13. package/cjs/guideAdmission.js +397 -0
  14. package/cjs/guideHost.d.ts +47 -0
  15. package/cjs/guideHost.js +48 -0
  16. package/cjs/guideInstallation.d.ts +12 -0
  17. package/cjs/guideInstallation.js +60 -0
  18. package/cjs/guideInstaller.d.ts +4 -0
  19. package/cjs/guideInstaller.js +116 -0
  20. package/cjs/guideMount.d.ts +22 -0
  21. package/cjs/guideMount.js +84 -0
  22. package/cjs/guideRecording.d.ts +64 -0
  23. package/cjs/guideRecording.js +176 -0
  24. package/cjs/guideRecordingSession.d.ts +35 -0
  25. package/cjs/guideRecordingSession.js +167 -0
  26. package/cjs/guideSubjectStore.d.ts +32 -0
  27. package/cjs/guideSubjectStore.js +105 -0
  28. package/cjs/guideTypes.d.ts +117 -0
  29. package/cjs/guideTypes.js +15 -0
  30. package/cjs/index.d.ts +6 -0
  31. package/cjs/index.js +25 -11
  32. package/cjs/liveAudioProcessor.d.ts +92 -0
  33. package/cjs/liveAudioProcessor.js +269 -0
  34. package/cjs/liveAudioQueue.d.ts +40 -0
  35. package/cjs/liveAudioQueue.js +130 -0
  36. package/cjs/liveAudioWorklet.d.ts +1 -0
  37. package/cjs/liveAudioWorklet.js +63 -0
  38. package/cjs/liveBrowserDetector.d.ts +16 -0
  39. package/cjs/liveBrowserDetector.js +75 -0
  40. package/cjs/liveBrowserDetectorWorker.d.ts +1 -0
  41. package/cjs/liveBrowserDetectorWorker.js +72 -0
  42. package/cjs/liveControlChannel.d.ts +176 -0
  43. package/cjs/liveControlChannel.js +829 -0
  44. package/cjs/liveDuplexMedia.d.ts +204 -0
  45. package/cjs/liveDuplexMedia.js +740 -0
  46. package/cjs/liveGuideAdmission.d.ts +21 -0
  47. package/cjs/liveGuideAdmission.js +94 -0
  48. package/cjs/liveGuideWidget.d.ts +68 -0
  49. package/cjs/liveGuideWidget.js +451 -0
  50. package/cjs/liveSpeechAssets.d.ts +36 -0
  51. package/cjs/liveSpeechAssets.js +39 -0
  52. package/cjs/liveSpeechCaptureBridge.d.ts +32 -0
  53. package/cjs/liveSpeechCaptureBridge.js +140 -0
  54. package/cjs/liveSpeechDetector.d.ts +62 -0
  55. package/cjs/liveSpeechDetector.js +206 -0
  56. package/cjs/liveSpeechModel.d.ts +46 -0
  57. package/cjs/liveSpeechModel.js +105 -0
  58. package/cjs/liveSpeechResampler.d.ts +22 -0
  59. package/cjs/liveSpeechResampler.js +93 -0
  60. package/cjs/liveSpeechWorker.d.ts +56 -0
  61. package/cjs/liveSpeechWorker.js +143 -0
  62. package/cjs/locales/resources.js +568 -8
  63. package/cjs/media.d.ts +11 -0
  64. package/cjs/media.js +78 -9
  65. package/cjs/messages.js +22 -8
  66. package/cjs/pageAssistancePreference.d.ts +15 -3
  67. package/cjs/pageAssistancePreference.js +46 -7
  68. package/cjs/preview.d.ts +4 -1
  69. package/cjs/preview.js +42 -1
  70. package/cjs/recording.d.ts +12 -0
  71. package/cjs/recording.js +150 -0
  72. package/cjs/standalone.d.ts +6 -0
  73. package/cjs/standalone.js +12 -0
  74. package/cjs/types.d.ts +31 -5
  75. package/cjs/types.js +14 -0
  76. package/cjs/ui.d.ts +128 -4
  77. package/cjs/ui.js +1918 -276
  78. package/cjs/version.d.ts +1 -1
  79. package/cjs/version.js +1 -1
  80. package/cjs/voicePresenceUi.d.ts +52 -4
  81. package/cjs/voicePresenceUi.js +659 -57
  82. package/lib/AiLiveAssist.d.ts +76 -11
  83. package/lib/AiLiveAssist.js +1772 -299
  84. package/lib/client.d.ts +19 -0
  85. package/lib/client.js +51 -0
  86. package/lib/context.d.ts +23 -1
  87. package/lib/context.js +713 -126
  88. package/lib/control.d.ts +2 -0
  89. package/lib/control.js +42 -3
  90. package/lib/ctaOffer.d.ts +11 -0
  91. package/lib/ctaOffer.js +179 -0
  92. package/lib/dialogFocusScope.js +1 -1
  93. package/lib/guideAdmission.d.ts +46 -0
  94. package/lib/guideAdmission.js +392 -0
  95. package/lib/guideHost.d.ts +47 -0
  96. package/lib/guideHost.js +42 -0
  97. package/lib/guideInstallation.d.ts +12 -0
  98. package/lib/guideInstallation.js +56 -0
  99. package/lib/guideInstaller.d.ts +4 -0
  100. package/lib/guideInstaller.js +113 -0
  101. package/lib/guideMount.d.ts +22 -0
  102. package/lib/guideMount.js +77 -0
  103. package/lib/guideRecording.d.ts +64 -0
  104. package/lib/guideRecording.js +172 -0
  105. package/lib/guideRecordingSession.d.ts +35 -0
  106. package/lib/guideRecordingSession.js +163 -0
  107. package/lib/guideSubjectStore.d.ts +32 -0
  108. package/lib/guideSubjectStore.js +101 -0
  109. package/lib/guideTypes.d.ts +117 -0
  110. package/lib/guideTypes.js +11 -0
  111. package/lib/index.d.ts +6 -0
  112. package/lib/index.js +21 -10
  113. package/lib/liveAudioProcessor.d.ts +92 -0
  114. package/lib/liveAudioProcessor.js +265 -0
  115. package/lib/liveAudioQueue.d.ts +40 -0
  116. package/lib/liveAudioQueue.js +126 -0
  117. package/lib/liveAudioWorklet.d.ts +1 -0
  118. package/lib/liveAudioWorklet.js +61 -0
  119. package/lib/liveBrowserDetector.d.ts +16 -0
  120. package/lib/liveBrowserDetector.js +71 -0
  121. package/lib/liveBrowserDetectorWorker.d.ts +1 -0
  122. package/lib/liveBrowserDetectorWorker.js +70 -0
  123. package/lib/liveControlChannel.d.ts +176 -0
  124. package/lib/liveControlChannel.js +825 -0
  125. package/lib/liveDuplexMedia.d.ts +204 -0
  126. package/lib/liveDuplexMedia.js +736 -0
  127. package/lib/liveGuideAdmission.d.ts +21 -0
  128. package/lib/liveGuideAdmission.js +90 -0
  129. package/lib/liveGuideWidget.d.ts +68 -0
  130. package/lib/liveGuideWidget.js +447 -0
  131. package/lib/liveSpeechAssets.d.ts +36 -0
  132. package/lib/liveSpeechAssets.js +35 -0
  133. package/lib/liveSpeechCaptureBridge.d.ts +32 -0
  134. package/lib/liveSpeechCaptureBridge.js +136 -0
  135. package/lib/liveSpeechDetector.d.ts +62 -0
  136. package/lib/liveSpeechDetector.js +202 -0
  137. package/lib/liveSpeechModel.d.ts +46 -0
  138. package/lib/liveSpeechModel.js +101 -0
  139. package/lib/liveSpeechResampler.d.ts +22 -0
  140. package/lib/liveSpeechResampler.js +89 -0
  141. package/lib/liveSpeechWorker.d.ts +56 -0
  142. package/lib/liveSpeechWorker.js +137 -0
  143. package/lib/locales/resources.js +568 -8
  144. package/lib/media.d.ts +11 -0
  145. package/lib/media.js +77 -8
  146. package/lib/messages.js +22 -8
  147. package/lib/pageAssistancePreference.d.ts +15 -3
  148. package/lib/pageAssistancePreference.js +46 -7
  149. package/lib/preview.d.ts +4 -1
  150. package/lib/preview.js +42 -1
  151. package/lib/recording.d.ts +12 -0
  152. package/lib/recording.js +146 -0
  153. package/lib/standalone.d.ts +6 -0
  154. package/lib/standalone.js +6 -0
  155. package/lib/types.d.ts +31 -5
  156. package/lib/types.js +14 -0
  157. package/lib/ui.d.ts +128 -4
  158. package/lib/ui.js +1919 -277
  159. package/lib/version.d.ts +1 -1
  160. package/lib/version.js +1 -1
  161. package/lib/voicePresenceUi.d.ts +52 -4
  162. package/lib/voicePresenceUi.js +659 -57
  163. package/package.json +16 -1
package/lib/ui.js CHANGED
@@ -1,6 +1,7 @@
1
- import { AudioLines, Captions, CaptionsOff, CircleStop, Eye, EyeOff, Grid2X2Plus, Hand, Maximize2, MessageSquareText, Mic, MicOff, Minus, Minimize2, Pause, Play, RotateCcw, Send, ShieldOff, UserRound, X, createElement as createLucideElement, } from "lucide";
1
+ import { AudioLines, Captions, CaptionsOff, CircleStop, Eye, EyeOff, Grid2X2Plus, Hand, Maximize2, MessageSquareText, Mic, MicOff, Minus, Minimize2, Pause, Play, RotateCcw, Send, ShieldCheck, ShieldOff, UserRound, X, createElement as createLucideElement, } from "lucide";
2
2
  import { normalizeAvatarUrl } from "./avatarUrl.js";
3
3
  import { DialogFocusScope } from "./dialogFocusScope.js";
4
+ import { CtaOfferCard, CTA_OFFER_STYLES, parseCtaOffer } from "./ctaOffer.js";
4
5
  import { resolveWidgetMessages, widgetLocaleAttributes, } from "./locales/index.js";
5
6
  const PANEL_POSITION_KEY = "__oxvo_ai_live_assist_compact_voice_position_v2";
6
7
  const LEGACY_PANEL_POSITION_KEY = "__oxvo_ai_live_assist_panel_position_v1";
@@ -10,7 +11,21 @@ const SESSION_START_KEY = "__oxvo_ai_live_assist_session_start_v1";
10
11
  const COMPACT_CAPTION_LIFETIME_MS = 8000;
11
12
  const COMPACT_CAPTION_EXIT_MS = 350;
12
13
  const CAPTION_HEIGHT_GLIDE_MS = 250;
14
+ const CAPTION_BOTTOM_PIN_THRESHOLD_PX = 16;
13
15
  const ASSISTANT_READY_VISUAL_GRACE_MS = 1200;
16
+ const REMOTE_PLAYBACK_START_TIMEOUT_MS = 2000;
17
+ const REMOTE_AUDIO_EVIDENCE_SAMPLE_MS = 50;
18
+ const REMOTE_AUDIO_EVIDENCE_RECHECK_MS = 250;
19
+ const REMOTE_AUDIO_EVIDENCE_IDLE_RECHECK_MS = 1000;
20
+ const REMOTE_AUDIO_EVIDENCE_ATTACK_WINDOW = 3;
21
+ const REMOTE_AUDIO_EVIDENCE_ATTACK_HITS = 2;
22
+ const REMOTE_AUDIO_EVIDENCE_ATTACK_RMS = 0.006;
23
+ const REMOTE_AUDIO_EVIDENCE_ATTACK_PEAK = 0.025;
24
+ const REMOTE_AUDIO_EVIDENCE_SUSTAIN_RMS = 0.0025;
25
+ const REMOTE_AUDIO_EVIDENCE_SUSTAIN_PEAK = 0.012;
26
+ const REMOTE_AUDIO_EVIDENCE_RELEASE_MS = 650;
27
+ const REMOTE_AUDIO_EVIDENCE_READY_TAIL_MS = 5000;
28
+ const REMOTE_AUDIO_EVIDENCE_EXPECTATION_MS = 15000;
14
29
  const FEEDBACK_EXIT_FADE_MS = 180;
15
30
  const AMBIENT_IDLE_GRACE_MS = 700;
16
31
  const VOICE_CARD_EFFECT_SETTLE_MS = 720;
@@ -105,6 +120,7 @@ const style = `
105
120
  --brand-mark-border: rgba(255, 255, 255, .8);
106
121
  --surface-material-plane: 0;
107
122
  --surface-content-plane: 10;
123
+ --intro-action-width: 76px;
108
124
  --skel: rgba(255, 255, 255, .55);
109
125
  --shimmer: rgba(255, 255, 255, .75);
110
126
  }
@@ -964,6 +980,11 @@ const style = `
964
980
  .identity strong { color: var(--assist-text); font-size: 14px; font-weight: 600; line-height: 19px; }
965
981
  .identity span { margin-top: 2px; color: var(--assist-muted); font-size: 11px; line-height: 15px; }
966
982
  .header-actions { display: flex; align-items: center; gap: 6px; }
983
+ .header-push[aria-pressed="true"] {
984
+ color: #d9a1f5;
985
+ background: color-mix(in srgb, var(--accent) 16%, var(--glass-control-background));
986
+ border-color: color-mix(in srgb, var(--accent) 34%, var(--glass-control-border));
987
+ }
967
988
  .panel.open:not(.compact) .header {
968
989
  min-height: 58px;
969
990
  padding: 0 2px 12px;
@@ -1058,6 +1079,12 @@ const style = `
1058
1079
  box-shadow: none;
1059
1080
  animation: none;
1060
1081
  }
1082
+ .panel.active-session.compact:is(.voice-session, .starting-voice) .header {
1083
+ box-shadow:
1084
+ -2px 1px 6px rgba(207, 48, 170, .18),
1085
+ 2px 1px 6px rgba(64, 47, 181, .2),
1086
+ 0 3px 5px rgba(15, 8, 31, .14);
1087
+ }
1061
1088
  .panel.active-session.compact:is(.voice-session, .starting-voice) .header::before,
1062
1089
  .panel.active-session.compact:is(.voice-session, .starting-voice) .header::after {
1063
1090
  content: none;
@@ -1117,9 +1144,11 @@ const style = `
1117
1144
  line-height: 1.25;
1118
1145
  }
1119
1146
  .panel.active-session.compact:is(.voice-session, .starting-voice) .identity span {
1120
- display: flex;
1121
- align-items: center;
1122
- gap: 5px;
1147
+ position: relative;
1148
+ display: block;
1149
+ box-sizing: border-box;
1150
+ min-width: 0;
1151
+ padding-inline-start: 10px;
1123
1152
  margin: 0;
1124
1153
  color: #cdb8e6;
1125
1154
  font-family: Poppins, system-ui, "Segoe UI", sans-serif;
@@ -1128,6 +1157,9 @@ const style = `
1128
1157
  }
1129
1158
  .panel.active-session.compact:is(.voice-session, .starting-voice) .identity span::before {
1130
1159
  content: "";
1160
+ position: absolute;
1161
+ inset-inline-start: 0;
1162
+ top: calc(50% - 2.5px);
1131
1163
  width: 5px;
1132
1164
  height: 5px;
1133
1165
  flex: none;
@@ -1144,7 +1176,7 @@ const style = `
1144
1176
  .panel.active-session.compact:is(.voice-session, .starting-voice) .header-actions { gap: 5px; }
1145
1177
  .panel.active-session.compact:is(.voice-session, .starting-voice):focus-within { outline: 1px solid rgba(160, 153, 216, .55); outline-offset: 3px; }
1146
1178
  :host([data-input-glow="false"]) .panel.active-session.compact:is(.voice-session, .starting-voice) > .voice-card-fx { display: none !important; }
1147
- :host([data-input-glow="false"]) .panel.active-session.compact:is(.voice-session, .starting-voice) .header { background: #010201; border: 1px solid #302a3c; }
1179
+ :host([data-input-glow="false"]) .panel.active-session.compact:is(.voice-session, .starting-voice) .header { background: #010201; border: 1px solid #302a3c; box-shadow: none; }
1148
1180
  .panel.active-session.compact:is(.voice-session, .starting-voice) .compact-captions {
1149
1181
  inset-inline-start: 0;
1150
1182
  inset-inline-end: auto;
@@ -1273,7 +1305,7 @@ const style = `
1273
1305
  border: 0;
1274
1306
  border-radius: 999px;
1275
1307
  box-shadow: none;
1276
- pointer-events: none;
1308
+ pointer-events: auto;
1277
1309
  }
1278
1310
  .panel.open.compact.ending-state > :not(.compact-error-notice) {
1279
1311
  display: none !important;
@@ -1305,6 +1337,26 @@ const style = `
1305
1337
  overflow-wrap: anywhere;
1306
1338
  animation: terminal-progress-in .2s ease-out both;
1307
1339
  }
1340
+ .compact-ending-dismiss {
1341
+ display: none;
1342
+ }
1343
+ .panel.open.compact.ending-state .compact-ending-dismiss {
1344
+ display: inline-grid;
1345
+ width: 28px;
1346
+ min-width: 28px;
1347
+ min-height: 28px;
1348
+ flex: 0 0 28px;
1349
+ place-items: center;
1350
+ padding: 0;
1351
+ color: var(--assist-text);
1352
+ background: color-mix(in srgb, var(--assist-surface) 82%, transparent);
1353
+ border: 1px solid color-mix(in srgb, var(--assist-text) 16%, transparent);
1354
+ border-radius: 50%;
1355
+ pointer-events: auto;
1356
+ }
1357
+ .panel.open.compact.ending-state .compact-ending-dismiss:hover {
1358
+ background: var(--assist-surface-muted);
1359
+ }
1308
1360
  .panel.open.compact.ending-state .compact-error-notice-icon {
1309
1361
  width: 18px;
1310
1362
  height: 18px;
@@ -1340,7 +1392,7 @@ const style = `
1340
1392
  line-height: 1;
1341
1393
  font-variant-numeric: tabular-nums;
1342
1394
  }
1343
- .end, .restart, .view-toggle, .compact-mute, .close {
1395
+ .end, .restart, .view-toggle, .header-push, .compact-mute, .close {
1344
1396
  display: inline-grid;
1345
1397
  width: 34px;
1346
1398
  min-width: 34px;
@@ -1402,12 +1454,12 @@ const style = `
1402
1454
  opacity: 1;
1403
1455
  visibility: visible;
1404
1456
  }
1405
- .restart, .view-toggle, .compact-mute, .close {
1457
+ .restart, .view-toggle, .header-push, .compact-mute, .close {
1406
1458
  color: var(--assist-text);
1407
1459
  background: var(--assist-surface);
1408
1460
  border: 1px solid var(--assist-border);
1409
1461
  }
1410
- .restart:hover, .view-toggle:hover, .compact-mute:hover, .close:hover { background: var(--assist-surface-muted); }
1462
+ .restart:hover, .view-toggle:hover, .header-push:hover, .compact-mute:hover, .close:hover { background: var(--assist-surface-muted); }
1411
1463
  .button-icon, .menu-icon, .turn-icon {
1412
1464
  display: inline-grid;
1413
1465
  flex: 0 0 auto;
@@ -1731,6 +1783,10 @@ const style = `
1731
1783
  opacity: .4;
1732
1784
  }
1733
1785
  .intro-effect-glow {
1786
+ -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, rgba(0, 0, 0, .92) 42%, transparent 78%);
1787
+ mask-image: radial-gradient(ellipse at center, #000 0%, rgba(0, 0, 0, .92) 42%, transparent 78%);
1788
+ -webkit-mask-repeat: no-repeat;
1789
+ mask-repeat: no-repeat;
1734
1790
  opacity: .1;
1735
1791
  }
1736
1792
  .intro-effect-glow::before,
@@ -1738,6 +1794,21 @@ const style = `
1738
1794
  --effect-rest-angle: 60deg;
1739
1795
  width: 999px;
1740
1796
  height: 999px;
1797
+ filter: none;
1798
+ transform: translate(-50%, -50%) rotate(60deg);
1799
+ animation: none;
1800
+ }
1801
+ .intro-effect-glow::before {
1802
+ background-image: conic-gradient(
1803
+ transparent,
1804
+ #402fb5 5%,
1805
+ transparent 38%,
1806
+ transparent 50%,
1807
+ #cf30aa 60%,
1808
+ transparent 87%
1809
+ );
1810
+ }
1811
+ .composer-effect-glow::before {
1741
1812
  background-image: conic-gradient(
1742
1813
  #000,
1743
1814
  #402fb5 5%,
@@ -1746,12 +1817,21 @@ const style = `
1746
1817
  #cf30aa 60%,
1747
1818
  #000 87%
1748
1819
  );
1749
- filter: none;
1750
- transform: translate(-50%, -50%) rotate(60deg);
1751
- animation: none;
1752
1820
  }
1753
1821
  .intro-effect-glow::after,
1754
1822
  .composer-effect-glow::after { content: none; }
1823
+ .intro:not([data-primary-motion]) .intro-composer-frame:not(.omago-transition-source) > .intro-effect-glow,
1824
+ .panel:not(.mode-surface-transition-clone):not(.panel-transition-compact-clone):not(.primary-surface-transition-clone) > .compact-chat-card:not(.mode-surface-transition-clone) > .intro-effect-glow,
1825
+ .panel.active-session.compact:not(.panel-transition-compact-clone):is(.voice-session, .starting-voice) > .voice-card-fx.intro-effect-glow {
1826
+ display: none !important;
1827
+ }
1828
+ .intro:not([data-primary-motion]) .intro-composer-frame:not(.omago-transition-source),
1829
+ .panel:not(.mode-surface-transition-clone):not(.panel-transition-compact-clone):not(.primary-surface-transition-clone) > .compact-chat-card:not(.mode-surface-transition-clone) {
1830
+ box-shadow:
1831
+ -2px 1px 6px rgba(207, 48, 170, .18),
1832
+ 2px 1px 6px rgba(64, 47, 181, .2),
1833
+ 0 3px 5px rgba(15, 8, 31, .14);
1834
+ }
1755
1835
  .intro-effect-dark,
1756
1836
  .composer-effect-dark {
1757
1837
  width: calc(100% + 11px);
@@ -2174,6 +2254,10 @@ const style = `
2174
2254
  outline-offset: -1px;
2175
2255
  box-shadow: none;
2176
2256
  }
2257
+ :host([data-input-glow="false"]) .intro:not([data-primary-motion]) .intro-composer-frame:not(.omago-transition-source),
2258
+ :host([data-input-glow="false"]) .panel:not(.mode-surface-transition-clone):not(.panel-transition-compact-clone):not(.primary-surface-transition-clone) > .compact-chat-card:not(.mode-surface-transition-clone) {
2259
+ box-shadow: none;
2260
+ }
2177
2261
  :host([data-input-glow="false"]) .intro-composer-frame[data-minimized="true"] {
2178
2262
  border: 0;
2179
2263
  outline: 1px solid #302a3c;
@@ -2184,7 +2268,7 @@ const style = `
2184
2268
  z-index: var(--surface-content-plane);
2185
2269
  grid-area: 1 / 1;
2186
2270
  display: grid;
2187
- grid-template-columns: minmax(0, 1fr) auto 0px;
2271
+ grid-template-columns: minmax(0, 1fr) var(--intro-action-width) 0px;
2188
2272
  width: calc(100% - 3px);
2189
2273
  min-width: 0;
2190
2274
  height: 44px;
@@ -2200,12 +2284,15 @@ const style = `
2200
2284
  border-radius: 10px;
2201
2285
  box-shadow: none;
2202
2286
  overflow: visible;
2287
+ }
2288
+ .intro-composer-frame > .intro-composer {
2203
2289
  transition:
2204
2290
  grid-template-columns .28s cubic-bezier(.2, .8, .2, 1),
2205
2291
  opacity .18s ease;
2206
2292
  }
2207
2293
  .intro-entry[data-has-draft="true"] .intro-composer {
2208
- grid-template-columns: minmax(0, 1fr) auto 44px;
2294
+ grid-template-columns:
2295
+ minmax(0, 1fr) var(--intro-action-width) var(--intro-action-width);
2209
2296
  }
2210
2297
  .intro-entry[data-text-enabled="false"] .intro-composer {
2211
2298
  grid-template-columns: auto;
@@ -2277,7 +2364,7 @@ const style = `
2277
2364
  outline: 0;
2278
2365
  caret-color: #fff;
2279
2366
  text-overflow: ellipsis;
2280
- font-size: 16px;
2367
+ font-size: 12px;
2281
2368
  font-weight: 400;
2282
2369
  line-height: 22px;
2283
2370
  }
@@ -2316,7 +2403,8 @@ const style = `
2316
2403
  .intro-voice {
2317
2404
  grid-column: 2;
2318
2405
  gap: 6px;
2319
- min-width: 76px;
2406
+ width: var(--intro-action-width);
2407
+ min-width: var(--intro-action-width);
2320
2408
  padding: 0 10px;
2321
2409
  border-radius: 8px;
2322
2410
  font-size: 12px;
@@ -2334,7 +2422,8 @@ const style = `
2334
2422
  }
2335
2423
  .intro-send {
2336
2424
  grid-column: 3;
2337
- width: 0;
2425
+ /* The animated grid track owns the width, including interrupted exits. */
2426
+ width: 100%;
2338
2427
  min-width: 0;
2339
2428
  padding: 0;
2340
2429
  background: linear-gradient(135deg, var(--oxvo-iris-violet), var(--oxvo-iris-magenta));
@@ -2343,21 +2432,16 @@ const style = `
2343
2432
  opacity: 0;
2344
2433
  overflow: hidden;
2345
2434
  pointer-events: none;
2346
- transform: translateX(5px) scale(.82);
2435
+ transition: opacity .22s ease, border-color .22s ease, background-color .22s ease;
2347
2436
  }
2348
- :host([dir="rtl"]) .intro-send { transform: translateX(-5px) scale(.82); }
2349
2437
  .intro-send.is-visible {
2350
- width: 44px;
2351
- min-width: 44px;
2352
2438
  opacity: 1;
2353
2439
  overflow: visible;
2354
2440
  pointer-events: auto;
2355
- transform: translateX(0) scale(1);
2356
2441
  }
2357
2442
  .intro-send.is-visible:hover,
2358
2443
  .intro-send.is-visible:focus-visible {
2359
2444
  filter: brightness(1.12);
2360
- transform: translateX(0) scale(1.04);
2361
2445
  }
2362
2446
  .intro-entry[aria-busy="true"] { opacity: .58; }
2363
2447
  .intro-entry input:disabled, .intro-entry button:disabled { cursor: not-allowed; }
@@ -2385,7 +2469,7 @@ const style = `
2385
2469
  .legal-overlay {
2386
2470
  position: absolute;
2387
2471
  inset: 0;
2388
- z-index: 4;
2472
+ z-index: calc(var(--surface-content-plane) + 2);
2389
2473
  display: grid;
2390
2474
  place-items: center;
2391
2475
  padding: 14px;
@@ -2407,119 +2491,178 @@ const style = `
2407
2491
  .legal-close { display: inline-grid; width: 44px; min-width: 44px; min-height: 44px; place-items: center; padding: 0; color: #4b5563; background: white; border: 1px solid var(--assist-border); }
2408
2492
  .legal-dialog p { margin: 10px 0; color: #4b5563; font-size: 11px; line-height: 17px; }
2409
2493
  .legal-dialog ul { display: grid; gap: 6px; margin: 10px 0; padding-inline-start: 18px; color: #374151; font-size: 11px; line-height: 16px; }
2494
+ .recording-consent { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; font-size: 11px; line-height: 16px; text-align: start; }
2495
+ .recording-consent[hidden] { display: none; }
2496
+ .recording-consent input { flex: 0 0 auto; margin-top: 3px; accent-color: var(--accent); }
2497
+ .recording-consent strong, .recording-consent small { display: block; font-size: inherit; }
2410
2498
  .legal-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
2411
2499
  .legal-links a { color: #185ea8; font-size: 11px; font-weight: 600; }
2500
+ .legal-revoke {
2501
+ display: inline-flex;
2502
+ align-items: center;
2503
+ gap: 8px;
2504
+ width: 100%;
2505
+ min-height: 38px;
2506
+ margin-top: 14px;
2507
+ justify-content: center;
2508
+ }
2412
2509
  .page-assistance-overlay {
2413
- position: relative;
2414
- grid-area: 2 / 1;
2415
- z-index: 6;
2510
+ position: absolute;
2511
+ inset: 8px;
2512
+ z-index: 12;
2416
2513
  display: grid;
2417
- width: 100%;
2418
- height: 100%;
2514
+ width: auto;
2515
+ height: auto;
2419
2516
  min-width: 0;
2420
2517
  min-height: 0;
2421
- place-items: end center;
2422
- padding: 12px 8px 8px;
2423
- background:
2424
- radial-gradient(80% 52% at 50% 100%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 72%),
2425
- color-mix(in srgb, var(--assist-surface) 48%, transparent);
2518
+ place-items: center;
2519
+ padding: 8px;
2520
+ background: color-mix(in srgb, var(--assist-surface) 48%, transparent);
2426
2521
  border-radius: 18px;
2427
2522
  overflow: hidden;
2428
2523
  overscroll-behavior: contain;
2429
- -webkit-backdrop-filter: blur(10px) saturate(1.08);
2430
- backdrop-filter: blur(10px) saturate(1.08);
2431
- animation: page-assistance-backdrop-in .24s ease-out both;
2524
+ -webkit-backdrop-filter: blur(6px);
2525
+ backdrop-filter: blur(6px);
2526
+ animation: page-assistance-backdrop-in .18s ease-out both;
2432
2527
  }
2433
2528
  .page-assistance-dialog {
2434
- width: min(100%, 430px);
2435
- max-height: calc(100% - 8px);
2529
+ display: flex;
2530
+ flex-direction: column;
2531
+ width: min(100%, 400px);
2532
+ max-height: 100%;
2436
2533
  min-width: 0;
2437
- overflow: auto;
2534
+ min-height: 0;
2535
+ overflow: hidden;
2438
2536
  overscroll-behavior: contain;
2439
- padding: 16px;
2537
+ padding: 0;
2440
2538
  color: var(--assist-text);
2441
- background:
2442
- linear-gradient(
2443
- 145deg,
2444
- color-mix(in srgb, var(--assist-surface) 86%, transparent),
2445
- color-mix(in srgb, var(--assist-surface-muted) 74%, transparent)
2446
- );
2447
- border: 1px solid var(--dialog-surface-border);
2448
- border-radius: 20px;
2449
- box-shadow:
2450
- 0 20px 48px color-mix(in srgb, var(--accent) 16%, transparent),
2451
- 0 4px 16px rgba(15, 23, 42, .14),
2452
- inset 0 1px 0 var(--glass-highlight-strong);
2453
- -webkit-backdrop-filter: blur(18px) saturate(1.1);
2454
- backdrop-filter: blur(18px) saturate(1.1);
2455
- animation: page-assistance-dialog-in .32s cubic-bezier(.2, .8, .3, 1) both;
2539
+ background-color: var(--assist-surface);
2540
+ background-image: var(--dialog-surface-background);
2541
+ border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--assist-border));
2542
+ border-radius: 18px;
2543
+ box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 12%, transparent);
2544
+ animation: page-assistance-dialog-in .18s ease-out both;
2456
2545
  }
2457
2546
  .page-assistance-header {
2458
2547
  display: grid;
2459
- grid-template-columns: minmax(0, 1fr) auto;
2460
- gap: 12px;
2461
- align-items: start;
2548
+ grid-template-columns: minmax(0, 1fr) 44px;
2549
+ flex: 0 0 auto;
2550
+ gap: 8px;
2551
+ align-items: center;
2552
+ padding-block: 8px 4px;
2553
+ padding-inline: 16px 8px;
2462
2554
  }
2463
2555
  .page-assistance-header-copy { min-width: 0; }
2464
2556
  .page-assistance-header h3 {
2465
2557
  margin: 0;
2466
- font-size: 16px;
2467
- line-height: 22px;
2468
- font-weight: 720;
2558
+ color: var(--assist-text);
2559
+ font-size: 15px;
2560
+ line-height: 1.4;
2561
+ font-weight: 600;
2562
+ overflow-wrap: anywhere;
2563
+ }
2564
+ .page-assistance-close {
2565
+ display: inline-grid;
2566
+ width: 44px;
2567
+ min-width: 44px;
2568
+ height: 44px;
2569
+ min-height: 44px;
2570
+ place-items: center;
2571
+ padding: 0;
2572
+ color: var(--assist-muted);
2573
+ background: transparent;
2574
+ border: 0;
2575
+ border-radius: 10px;
2576
+ box-shadow: none;
2577
+ }
2578
+ .page-assistance-close .button-icon {
2579
+ display: inline-grid;
2580
+ width: 28px;
2581
+ height: 28px;
2582
+ place-items: center;
2583
+ border-radius: 8px;
2584
+ transition: background-color .18s ease, color .18s ease;
2585
+ }
2586
+ .page-assistance-close:hover .button-icon,
2587
+ .page-assistance-close:focus-visible .button-icon {
2588
+ color: var(--assist-text);
2589
+ background: color-mix(in srgb, var(--accent) 8%, var(--assist-surface));
2590
+ }
2591
+ .page-assistance-content {
2592
+ min-width: 0;
2593
+ min-height: 0;
2594
+ overflow: auto;
2595
+ overscroll-behavior: contain;
2596
+ padding: 0 16px 12px;
2597
+ scroll-padding-block: 8px;
2598
+ overflow-wrap: anywhere;
2469
2599
  }
2470
2600
  .page-assistance-action-copy {
2471
- margin: 5px 0 0;
2601
+ margin: 0;
2472
2602
  min-width: 0;
2473
- color: color-mix(in srgb, var(--assist-text) 72%, var(--accent));
2603
+ color: var(--assist-text);
2474
2604
  overflow-wrap: anywhere;
2475
2605
  font-size: 13px;
2476
- line-height: 19px;
2606
+ line-height: 1.5;
2477
2607
  }
2478
- .page-assistance-action-copy > span { min-width: 0; }
2608
+ .page-assistance-action-copy > span { display: block; min-width: 0; }
2479
2609
  .page-assistance-target {
2480
- margin-inline-start: 4px;
2610
+ margin-top: 6px;
2481
2611
  color: var(--assist-muted);
2612
+ font-size: 12px;
2482
2613
  }
2483
2614
  .page-assistance-footer {
2484
2615
  display: grid;
2485
- gap: 6px;
2486
- margin-top: 13px;
2487
- padding: 11px 0 0;
2616
+ gap: 4px;
2617
+ margin-top: 12px;
2618
+ padding-top: 8px;
2488
2619
  background: transparent;
2489
- border: 0;
2490
- border-top: 1px solid var(--soft-surface-border);
2491
- border-radius: 0;
2620
+ border-top: 1px solid var(--assist-border);
2492
2621
  }
2493
2622
  .page-assistance-always {
2494
2623
  display: grid;
2495
2624
  grid-template-columns: 18px minmax(0, 1fr);
2496
- gap: 9px;
2497
- align-items: center;
2625
+ gap: 10px;
2626
+ align-items: start;
2498
2627
  margin: 0;
2499
- color: #29333d;
2628
+ padding-block: 12px;
2629
+ color: var(--assist-text);
2500
2630
  font-size: 12px;
2501
2631
  line-height: 18px;
2502
2632
  cursor: pointer;
2503
- min-height: 32px;
2633
+ min-height: 44px;
2504
2634
  }
2505
2635
  .page-assistance-always input {
2506
- width: 17px;
2507
- height: 17px;
2636
+ width: 18px;
2637
+ height: 18px;
2508
2638
  margin: 0;
2509
2639
  accent-color: var(--accent);
2510
2640
  }
2511
2641
  .page-assistance-agreement {
2512
2642
  margin: 0;
2513
- color: color-mix(in srgb, var(--assist-text) 62%, var(--accent));
2514
- font-size: 11px;
2515
- line-height: 17px;
2643
+ color: var(--assist-muted);
2644
+ font-size: 12px;
2645
+ line-height: 1.6;
2646
+ }
2647
+ .page-assistance-agreement > [data-role="page-assistance-agreement-prefix"] {
2648
+ display: block;
2516
2649
  }
2517
2650
  .page-assistance-agreement a {
2518
- color: color-mix(in srgb, var(--accent) 82%, #5d2b70);
2519
- font-weight: 650;
2520
- text-underline-offset: 2px;
2651
+ display: inline-flex;
2652
+ min-height: 44px;
2653
+ align-items: center;
2654
+ color: var(--accent);
2655
+ font-weight: 500;
2656
+ text-decoration: underline;
2657
+ text-decoration-thickness: 1px;
2658
+ text-underline-offset: 3px;
2659
+ border-radius: 2px;
2660
+ }
2661
+ .page-assistance-agreement a:hover {
2662
+ text-decoration-thickness: 2px;
2521
2663
  }
2522
2664
  .panel.active-session.compact:is(.voice-session, .starting-voice) .end,
2665
+ .panel.active-session.compact:is(.voice-session, .starting-voice) .header-push,
2523
2666
  .panel.active-session.compact:is(.voice-session, .starting-voice) .compact-mute,
2524
2667
  .panel.active-session.compact:is(.voice-session, .starting-voice) .view-toggle {
2525
2668
  width: 30px;
@@ -2544,6 +2687,7 @@ const style = `
2544
2687
  border-color: rgba(215, 151, 169, .22);
2545
2688
  }
2546
2689
  .panel.active-session.compact:is(.voice-session, .starting-voice) .end:not(:disabled):hover,
2690
+ .panel.active-session.compact:is(.voice-session, .starting-voice) .header-push:not(:disabled):hover,
2547
2691
  .panel.active-session.compact:is(.voice-session, .starting-voice) .compact-mute:not(:disabled):hover,
2548
2692
  .panel.active-session.compact:is(.voice-session, .starting-voice) .view-toggle:not(:disabled):hover {
2549
2693
  color: #fff;
@@ -2609,10 +2753,20 @@ const style = `
2609
2753
  box-shadow: none;
2610
2754
  }
2611
2755
  .page-assistance-actions {
2612
- display: flex;
2613
- justify-content: flex-end;
2756
+ display: grid;
2757
+ grid-template-columns: repeat(2, minmax(0, 1fr));
2758
+ flex: 0 0 auto;
2614
2759
  gap: 8px;
2615
- margin-top: 12px;
2760
+ padding: 12px 16px 14px;
2761
+ border-top: 1px solid var(--assist-border);
2762
+ }
2763
+ .page-assistance-actions button {
2764
+ min-width: 0;
2765
+ min-height: 44px;
2766
+ padding: 10px 12px;
2767
+ line-height: 1.4;
2768
+ overflow-wrap: anywhere;
2769
+ border-radius: 10px;
2616
2770
  }
2617
2771
  .primary, .secondary {
2618
2772
  padding: 0 12px;
@@ -2738,6 +2892,7 @@ const style = `
2738
2892
  overscroll-behavior: contain;
2739
2893
  scrollbar-width: none;
2740
2894
  scroll-behavior: auto;
2895
+ touch-action: pan-y;
2741
2896
  }
2742
2897
  .panel.active-session:not(.compact) .captions {
2743
2898
  height: 100%;
@@ -3346,6 +3501,7 @@ const style = `
3346
3501
  display: grid;
3347
3502
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
3348
3503
  gap: 7px;
3504
+ margin-block-start: 10px;
3349
3505
  }
3350
3506
  .turn-action {
3351
3507
  display: inline-flex;
@@ -3428,7 +3584,7 @@ const style = `
3428
3584
  }
3429
3585
  @keyframes page-assistance-backdrop-in { from { opacity: 0; } }
3430
3586
  @keyframes page-assistance-dialog-in {
3431
- from { opacity: 0; transform: translateY(10px) scale(.98); }
3587
+ from { opacity: 0; transform: translateY(4px); }
3432
3588
  }
3433
3589
  @keyframes pop { from { opacity: 0; transform: translateY(8px); } }
3434
3590
  @keyframes attribution-in { from { opacity: 0; transform: translateY(3px); } }
@@ -3566,11 +3722,6 @@ const style = `
3566
3722
  font-size: 16px;
3567
3723
  line-height: 22px;
3568
3724
  }
3569
- .panel.open:not(.compact) .page-assistance-header h3 {
3570
- color: color-mix(in srgb, var(--assist-text) 88%, var(--accent));
3571
- font-size: 16px;
3572
- line-height: 22px;
3573
- }
3574
3725
  .panel.open:not(.compact) .legal-close {
3575
3726
  color: var(--assist-text);
3576
3727
  background: var(--soft-surface-strong-background);
@@ -3578,9 +3729,7 @@ const style = `
3578
3729
  border-radius: 50%;
3579
3730
  }
3580
3731
  .panel.open:not(.compact) .legal-dialog p,
3581
- .panel.open:not(.compact) .legal-dialog ul,
3582
- .panel.open:not(.compact) .page-assistance-target,
3583
- .panel.open:not(.compact) .page-assistance-always {
3732
+ .panel.open:not(.compact) .legal-dialog ul {
3584
3733
  color: color-mix(in srgb, var(--assist-text) 66%, var(--accent));
3585
3734
  }
3586
3735
  .panel.open:not(.compact) .boundary {
@@ -3606,6 +3755,20 @@ const style = `
3606
3755
  background: var(--soft-surface-strong-background);
3607
3756
  border-color: var(--soft-surface-border);
3608
3757
  }
3758
+ .panel.open .page-assistance-actions .secondary {
3759
+ color: var(--assist-text);
3760
+ background: var(--assist-surface);
3761
+ border-color: var(--assist-border);
3762
+ }
3763
+ .panel.open .page-assistance-actions .primary {
3764
+ box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 14%, transparent);
3765
+ }
3766
+ .panel.open .page-assistance-actions .secondary:hover {
3767
+ background: color-mix(in srgb, var(--accent) 5%, var(--assist-surface));
3768
+ }
3769
+ .panel.open .page-assistance-actions .primary:hover {
3770
+ filter: brightness(.96);
3771
+ }
3609
3772
  .panel.open:not(.compact) .confirmation,
3610
3773
  .panel.open:not(.compact) .visual-request,
3611
3774
  .panel.open:not(.compact) .feedback.visible {
@@ -3760,7 +3923,7 @@ const style = `
3760
3923
  border-radius: 5px;
3761
3924
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
3762
3925
  transition: inset .12s ease, width .12s ease, height .12s ease;
3763
- z-index: 3;
3926
+ z-index: 1;
3764
3927
  }
3765
3928
  .highlight.visible { display: block; }
3766
3929
  .highlight.success { border-color: #0f8a80; }
@@ -3861,6 +4024,8 @@ const style = `
3861
4024
  .intro-composer::before { display: none; }
3862
4025
  .intro-composer-frame:focus-within,
3863
4026
  .compact-chat-card:focus-within { box-shadow: none; }
4027
+ .intro:not([data-primary-motion]) .intro-composer-frame:not(.omago-transition-source),
4028
+ .panel:not(.mode-surface-transition-clone):not(.panel-transition-compact-clone):not(.primary-surface-transition-clone) > .compact-chat-card:not(.mode-surface-transition-clone) { box-shadow: none; }
3864
4029
  .panel.open.compact.ending-state .compact-error-notice.visible {
3865
4030
  background: var(--assist-surface);
3866
4031
  border-color: var(--assist-border);
@@ -3903,7 +4068,8 @@ const style = `
3903
4068
  backdrop-filter: none;
3904
4069
  forced-color-adjust: auto;
3905
4070
  }
3906
- .panel.active-session.compact:is(.voice-session, .starting-voice) .header {
4071
+ .panel.active-session.compact:is(.voice-session, .starting-voice) .header,
4072
+ :host([data-input-glow="false"]) .panel.active-session.compact:is(.voice-session, .starting-voice) .header {
3907
4073
  background: Canvas;
3908
4074
  border: 2px solid CanvasText;
3909
4075
  box-shadow: none;
@@ -3938,14 +4104,18 @@ const style = `
3938
4104
  .mode-option[aria-pressed="true"] { outline: 2px solid Highlight; }
3939
4105
  .primary, .intro-voice, .intro-send { border: 2px solid ButtonText; }
3940
4106
  .intro-minimize, .compact-chat-action { color: ButtonText; background: Canvas; border: 2px solid ButtonText; box-shadow: none; }
3941
- .intro-composer-frame { padding: 0; overflow: visible; background: Canvas; border: 2px solid ButtonText; box-shadow: none; }
4107
+ .intro-composer-frame,
4108
+ :host([data-input-glow="false"]) .intro-composer-frame { padding: 0; overflow: visible; background: Canvas; border: 2px solid ButtonText; outline: 0; box-shadow: none; }
3942
4109
  .intro-composer-frame::before,
3943
4110
  .compact-chat-card::before,
3944
4111
  .composer::before,
3945
4112
  .panel.active-session.compact:is(.voice-session, .starting-voice)::before {
3946
4113
  background: Canvas;
3947
4114
  }
3948
- .compact-chat-card { overflow: visible; background: Canvas; border: 0; outline: 2px solid ButtonText; outline-offset: -2px; box-shadow: none; }
4115
+ .compact-chat-card,
4116
+ :host([data-input-glow="false"]) .compact-chat-card { overflow: visible; background: Canvas; border: 0; outline: 2px solid ButtonText; outline-offset: -2px; box-shadow: none; }
4117
+ .intro:not([data-primary-motion]) .intro-composer-frame:not(.omago-transition-source),
4118
+ .panel:not(.mode-surface-transition-clone):not(.panel-transition-compact-clone):not(.primary-surface-transition-clone) > .compact-chat-card:not(.mode-surface-transition-clone) { box-shadow: none; }
3949
4119
  .intro-effect,
3950
4120
  .composer-effect,
3951
4121
  .intro-effect-pink,
@@ -3967,6 +4137,7 @@ const style = `
3967
4137
  .highlight { border: 3px solid Highlight; box-shadow: none; }
3968
4138
  }
3969
4139
  @media (max-width: 520px) {
4140
+ :host { --intro-action-width: 72px; }
3970
4141
  .panel {
3971
4142
  inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px !important;
3972
4143
  width: auto;
@@ -3976,11 +4147,10 @@ const style = `
3976
4147
  .header-actions { gap: 4px; }
3977
4148
  .duration { min-width: 48px; padding-inline: 6px; }
3978
4149
  .feedback-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
3979
- .page-assistance-overlay { place-items: end center; padding: 8px 6px 6px; }
3980
- .page-assistance-dialog { width: 100%; max-height: calc(100% - 4px); }
3981
- .page-assistance-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
4150
+ .page-assistance-overlay { padding: 8px 4px; }
4151
+ .page-assistance-dialog { width: 100%; }
3982
4152
  .page-assistance-actions button { width: 100%; }
3983
- .intro-voice { min-width: 72px; padding-inline: 8px; }
4153
+ .intro-voice { padding-inline: 8px; }
3984
4154
  .intro,
3985
4155
  .intro[data-minimized="true"] {
3986
4156
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--intro-visual-bottom-offset, 0px)) !important;
@@ -4055,17 +4225,17 @@ const style = `
4055
4225
  margin-inline: auto;
4056
4226
  }
4057
4227
  .panel.active-session.compact:is(.voice-session, .starting-voice) {
4058
- inset: auto max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) auto !important;
4059
- width: calc(100vw - 16px) !important;
4228
+ inset: auto max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) auto !important;
4229
+ width: min(340px, calc(100vw - 40px)) !important;
4060
4230
  min-width: 0 !important;
4061
4231
  height: 54px !important;
4062
4232
  max-height: 54px !important;
4063
4233
  }
4064
4234
  .panel.active-session.compact:is(.voice-session, .starting-voice)[data-anchor="left"] {
4065
- inset: auto auto max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)) !important;
4235
+ inset: auto auto max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)) !important;
4066
4236
  }
4067
4237
  .panel.active-session.compact:is(.voice-session, .starting-voice)[data-anchor="center"] {
4068
- inset: auto auto max(8px, env(safe-area-inset-bottom)) 50% !important;
4238
+ inset: auto auto max(20px, env(safe-area-inset-bottom)) 50% !important;
4069
4239
  translate: -50% 0;
4070
4240
  }
4071
4241
  .panel.active-session.compact:is(.voice-session, .starting-voice) .compact-captions {
@@ -4145,15 +4315,44 @@ const style = `
4145
4315
  export class WidgetView {
4146
4316
  constructor(config, overrides, callbacks, options = {}) {
4147
4317
  this.callbacks = callbacks;
4318
+ this.ctaCard = null;
4319
+ this.ctaSlot = null;
4148
4320
  this.ambient = null;
4149
4321
  this.widgetCornerGlow = null;
4150
4322
  this.playbackBlocked = false;
4151
4323
  this.playbackResumePending = false;
4324
+ this.playbackResumeTimer = null;
4325
+ this.playbackResumeFinish = null;
4152
4326
  this.playbackGeneration = 0;
4327
+ this.playbackAttempt = 0;
4328
+ this.destroyed = false;
4329
+ this.recordingConsent = false;
4330
+ this.mediaPlaybackActive = false;
4331
+ this.remoteAudioContext = null;
4332
+ this.remoteAudioContextStateListener = null;
4333
+ this.remoteAudioAnalyser = null;
4334
+ this.remoteAudioSilentSink = null;
4335
+ this.remoteAudioSources = [];
4336
+ this.remoteAudioAnalysisStreams = [];
4337
+ this.remoteAudioAnalysedTracks = new Set();
4338
+ this.remoteAudioFloatBuffer = null;
4339
+ this.remoteAudioByteBuffer = null;
4340
+ this.remoteAudioEvidenceTimer = null;
4341
+ this.remoteAudioEvidenceGeneration = 0;
4342
+ this.remoteAudioEvidenceAttackWindow = 0;
4343
+ this.remoteAudioEvidenceQuietSince = null;
4344
+ this.remoteAudioEvidenceAudible = false;
4345
+ this.remoteAudioEvidenceCandidateUntil = 0;
4346
+ this.boundRemoteAudioStreams = new WeakSet();
4347
+ this.boundRemoteAudioTracks = new WeakSet();
4348
+ this.playbackStateBindings = [];
4349
+ this.remotePlaybackState = "idle";
4153
4350
  this.muted = false;
4351
+ this.playbackInterrupted = false;
4154
4352
  this.statusBeforeMute = null;
4155
4353
  this.manualTurn = false;
4156
4354
  this.pushActive = false;
4355
+ this.pushPending = false;
4157
4356
  this.voiceActive = false;
4158
4357
  this.modeTransitionPending = null;
4159
4358
  this.startingVoicePresentation = false;
@@ -4165,6 +4364,7 @@ export class WidgetView {
4165
4364
  this.visualPaused = false;
4166
4365
  this.active = false;
4167
4366
  this.endRequested = false;
4367
+ this.endingPresentationDismissed = false;
4168
4368
  this.launcherSuppressed = false;
4169
4369
  this.introMinimized = false;
4170
4370
  this.introTransitionTarget = null;
@@ -4184,6 +4384,12 @@ export class WidgetView {
4184
4384
  this.introComposing = false;
4185
4385
  this.legalOpenedPanel = false;
4186
4386
  this.highlightedElement = null;
4387
+ this.highlightFrame = null;
4388
+ this.highlightIntersectionKnown = false;
4389
+ this.highlightIntersectionObserver = null;
4390
+ this.highlightIntersectionRect = null;
4391
+ this.highlightResizeObserver = null;
4392
+ this.highlightScrollTargets = [];
4187
4393
  this.dragState = null;
4188
4394
  this.suggestionDragState = null;
4189
4395
  this.suppressSuggestionClick = false;
@@ -4202,6 +4408,7 @@ export class WidgetView {
4202
4408
  this.durationInterval = null;
4203
4409
  this.compactCaptionTimers = new Map();
4204
4410
  this.compactCaptionContentTimers = new Map();
4411
+ this.captionsPinnedToBottom = true;
4205
4412
  this.captionHeightGlides = new Map();
4206
4413
  this.captionResizeObserver = null;
4207
4414
  this.introTransitionTimers = new Set();
@@ -4229,18 +4436,32 @@ export class WidgetView {
4229
4436
  this.assistantState = "ready";
4230
4437
  this.assistantCaptionPhase = "none";
4231
4438
  this.actionStateRunning = false;
4439
+ this.actionPendingAssistantCaption = null;
4440
+ this.actionPendingCompactAssistantCaption = null;
4232
4441
  this.supportCompanion = false;
4233
4442
  this.onPlaybackActivation = () => {
4234
- if (!this.active ||
4235
- !this.voiceActive ||
4236
- !this.playbackBlocked ||
4237
- !this.audio.srcObject) {
4443
+ if (!this.active || !this.voiceActive || !this.audio.srcObject) {
4238
4444
  return;
4239
4445
  }
4240
- void this.playRemoteAudio();
4446
+ this.resumeRemoteAudioContext();
4447
+ if (this.playbackBlocked) {
4448
+ void this.playRemoteAudio();
4449
+ return;
4450
+ }
4451
+ this.startRemoteAudioEvidenceSampling();
4241
4452
  };
4242
4453
  this.onEffectVisibilityChange = () => {
4243
4454
  this.syncEffectMotion();
4455
+ if (document.hidden) {
4456
+ this.resetRemoteAudioEvidence(true);
4457
+ return;
4458
+ }
4459
+ if (this.assistantState === "thinking" ||
4460
+ this.assistantState === "speaking") {
4461
+ this.remoteAudioEvidenceCandidateUntil = Math.max(this.remoteAudioEvidenceCandidateUntil, this.remoteAudioEvidenceNow() + REMOTE_AUDIO_EVIDENCE_EXPECTATION_MS);
4462
+ }
4463
+ this.resumeRemoteAudioContext();
4464
+ this.startRemoteAudioEvidenceSampling();
4244
4465
  };
4245
4466
  this.onReducedMotionChange = () => {
4246
4467
  this.syncEffectMotion();
@@ -4249,6 +4470,45 @@ export class WidgetView {
4249
4470
  this.settlePanelTransitionForStaticMotion();
4250
4471
  }
4251
4472
  };
4473
+ this.livePlaybackObservation = null;
4474
+ this.liveDrainObservation = null;
4475
+ this.onCaptionsScroll = () => {
4476
+ // Hidden and morphing layouts can clamp scrollTop without visitor input.
4477
+ // Do not mistake that clamp for a visitor choosing to read older messages.
4478
+ if (this.compact || this.panelViewTransition || this.captions.clientHeight === 0)
4479
+ return;
4480
+ this.updateCaptionsPinnedState();
4481
+ };
4482
+ this.onPanelWheel = (event) => {
4483
+ if (event.ctrlKey ||
4484
+ !this.active ||
4485
+ this.compact ||
4486
+ !this.panel.classList.contains("open") ||
4487
+ !this.require('[data-role="legal-overlay"]').hidden ||
4488
+ !this.require('[data-role="page-assistance-overlay"]')
4489
+ .hidden ||
4490
+ this.currentConfirmation !== null ||
4491
+ this.currentVisualRequest !== null ||
4492
+ this.currentHandoffContextRequest !== null ||
4493
+ this.currentPageAssistanceRequest !== null ||
4494
+ this.panel.classList.contains("feedback-state") ||
4495
+ Math.abs(event.deltaY) < Math.abs(event.deltaX)) {
4496
+ return;
4497
+ }
4498
+ const maximum = Math.max(0, this.captions.scrollHeight - this.captions.clientHeight);
4499
+ if (maximum <= 0 || !Number.isFinite(event.deltaY) || event.deltaY === 0) {
4500
+ return;
4501
+ }
4502
+ const scale = event.deltaMode === 1
4503
+ ? 16
4504
+ : event.deltaMode === 2
4505
+ ? Math.max(1, this.captions.clientHeight)
4506
+ : 1;
4507
+ event.preventDefault();
4508
+ event.stopPropagation();
4509
+ this.captions.scrollTop = Math.min(maximum, Math.max(0, this.captions.scrollTop + event.deltaY * scale));
4510
+ this.updateCaptionsPinnedState();
4511
+ };
4252
4512
  this.onIntroInputPointerDown = (event) => {
4253
4513
  this.consumeProactiveEngagement();
4254
4514
  if (event.pointerType !== "touch")
@@ -4432,6 +4692,72 @@ export class WidgetView {
4432
4692
  return;
4433
4693
  this.closeControlsMenu();
4434
4694
  };
4695
+ this.onHighlightIntersection = (entries) => {
4696
+ const target = this.highlightedElement;
4697
+ const entry = target
4698
+ ? entries.find((candidate) => candidate.target === target)
4699
+ : null;
4700
+ if (!entry)
4701
+ return;
4702
+ const currentRect = target.getBoundingClientRect();
4703
+ const observedRect = entry.boundingClientRect;
4704
+ const geometryEpsilon = 0.5;
4705
+ if (Math.abs(currentRect.left - observedRect.left) > geometryEpsilon ||
4706
+ Math.abs(currentRect.top - observedRect.top) > geometryEpsilon ||
4707
+ Math.abs(currentRect.right - observedRect.right) > geometryEpsilon ||
4708
+ Math.abs(currentRect.bottom - observedRect.bottom) > geometryEpsilon) {
4709
+ this.rearmHighlightIntersection();
4710
+ return;
4711
+ }
4712
+ this.highlightIntersectionKnown = true;
4713
+ if (!entry.isIntersecting ||
4714
+ entry.intersectionRect.right <= entry.intersectionRect.left ||
4715
+ entry.intersectionRect.bottom <= entry.intersectionRect.top) {
4716
+ this.highlightIntersectionRect = null;
4717
+ }
4718
+ else {
4719
+ const clippedEdges = {};
4720
+ if (entry.intersectionRect.left > observedRect.left + geometryEpsilon) {
4721
+ clippedEdges.left = entry.intersectionRect.left;
4722
+ }
4723
+ if (entry.intersectionRect.top > observedRect.top + geometryEpsilon) {
4724
+ clippedEdges.top = entry.intersectionRect.top;
4725
+ }
4726
+ if (entry.intersectionRect.right < observedRect.right - geometryEpsilon) {
4727
+ clippedEdges.right = entry.intersectionRect.right;
4728
+ }
4729
+ if (entry.intersectionRect.bottom <
4730
+ observedRect.bottom - geometryEpsilon) {
4731
+ clippedEdges.bottom = entry.intersectionRect.bottom;
4732
+ }
4733
+ this.highlightIntersectionRect = clippedEdges;
4734
+ }
4735
+ this.scheduleHighlightRefresh();
4736
+ };
4737
+ this.scheduleHighlightGeometryRefresh = () => {
4738
+ if (!this.highlightedElement)
4739
+ return;
4740
+ this.rearmHighlightIntersection();
4741
+ this.scheduleHighlightRefresh();
4742
+ };
4743
+ this.onHighlightViewportGeometryChange = () => {
4744
+ if (!this.highlightedElement)
4745
+ return;
4746
+ if (this.highlightIntersectionObserver) {
4747
+ this.scheduleHighlightGeometryRefresh();
4748
+ }
4749
+ else {
4750
+ this.refreshHighlight();
4751
+ }
4752
+ };
4753
+ this.scheduleHighlightRefresh = () => {
4754
+ if (!this.highlightedElement || this.highlightFrame !== null)
4755
+ return;
4756
+ this.highlightFrame = requestAnimationFrame(() => {
4757
+ this.highlightFrame = null;
4758
+ this.refreshHighlight();
4759
+ });
4760
+ };
4435
4761
  this.refreshHighlight = () => {
4436
4762
  this.hideTooltip();
4437
4763
  if (this.highlightedElement) {
@@ -4447,7 +4773,7 @@ export class WidgetView {
4447
4773
  this.hideTooltip();
4448
4774
  this.syncPanelDragState();
4449
4775
  this.clampPanelPosition();
4450
- this.refreshHighlight();
4776
+ this.onHighlightViewportGeometryChange();
4451
4777
  this.scheduleProactiveOverflowSync();
4452
4778
  };
4453
4779
  this.onDragStart = (event) => {
@@ -4502,7 +4828,10 @@ export class WidgetView {
4502
4828
  this.messageOverrides = { ...overrides };
4503
4829
  this.messages = resolveWidgetMessages(this.messageOverrides, config.messages);
4504
4830
  this.persistentState = options.persistentState !== false;
4831
+ this.storageNamespace = options.storageNamespace ?? null;
4505
4832
  this.initialPanelView = options.initialPanelView ?? null;
4833
+ this.preserveRawText = options.preserveRawText === true;
4834
+ this.manualTurnsSupported = options.manualTurnsSupported === true;
4506
4835
  this.semanticStatus = this.messages.ready;
4507
4836
  this.host = document.createElement("div");
4508
4837
  this.host.dataset.oxvoAiLiveAssistRoot = "true";
@@ -4510,7 +4839,7 @@ export class WidgetView {
4510
4839
  this.host.setAttribute("aria-live", "off");
4511
4840
  this.shadow = this.host.attachShadow({ mode: "closed" });
4512
4841
  const sheet = document.createElement("style");
4513
- sheet.textContent = style;
4842
+ sheet.textContent = style + CTA_OFFER_STYLES;
4514
4843
  this.shadow.append(sheet);
4515
4844
  this.shadow.append(this.build());
4516
4845
  document.documentElement.append(this.host);
@@ -4524,10 +4853,11 @@ export class WidgetView {
4524
4853
  this.compactCaptions = this.require(".compact-captions");
4525
4854
  if (typeof ResizeObserver === "function") {
4526
4855
  this.captionResizeObserver = new ResizeObserver((entries) => {
4527
- if (entries.some((entry) => entry.target.parentElement === this.captions)) {
4856
+ if (entries.some((entry) => entry.target === this.captions || entry.target.parentElement === this.captions)) {
4528
4857
  this.scrollCaptionsToBottom();
4529
4858
  }
4530
4859
  });
4860
+ this.captionResizeObserver.observe(this.captions);
4531
4861
  }
4532
4862
  this.controls = this.require(".controls");
4533
4863
  this.confirmation = this.require(".confirmation");
@@ -4537,6 +4867,8 @@ export class WidgetView {
4537
4867
  this.highlight = this.require(".highlight");
4538
4868
  this.tooltip = this.require(".tooltip");
4539
4869
  this.audio = this.require("audio");
4870
+ this.audio.setAttribute("playsinline", "");
4871
+ this.audio.setAttribute("aria-hidden", "true");
4540
4872
  this.dialogFocus = new DialogFocusScope(this.shadow, this.host);
4541
4873
  this.reducedMotionQuery =
4542
4874
  window.matchMedia?.("(prefers-reduced-motion: reduce)") ?? null;
@@ -4550,11 +4882,93 @@ export class WidgetView {
4550
4882
  this.syncSurfaceEffectOwner();
4551
4883
  }
4552
4884
  setRemoteStream(stream) {
4553
- if (this.audio.srcObject !== stream)
4885
+ const streamChanged = this.audio.srcObject !== stream;
4886
+ if (streamChanged)
4554
4887
  this.invalidateRemotePlayback();
4555
4888
  this.audio.srcObject = stream;
4889
+ if (streamChanged) {
4890
+ this.boundRemoteAudioStreams = new WeakSet();
4891
+ this.boundRemoteAudioTracks = new WeakSet();
4892
+ this.bindPlaybackState();
4893
+ this.bindRemoteAudioTrackState(stream);
4894
+ }
4556
4895
  void this.playRemoteAudio();
4557
4896
  }
4897
+ bindRemoteAudioTrackState(stream) {
4898
+ if (typeof stream.getAudioTracks !== "function")
4899
+ return;
4900
+ const isCurrent = (track) => this.audio.srcObject === stream &&
4901
+ this.playbackEventIsCurrent() &&
4902
+ (!track ||
4903
+ stream.getAudioTracks().some((candidate) => candidate === track));
4904
+ if (!this.boundRemoteAudioStreams.has(stream) &&
4905
+ typeof stream.addEventListener === "function") {
4906
+ this.boundRemoteAudioStreams.add(stream);
4907
+ const refreshTrackSet = () => {
4908
+ if (!isCurrent())
4909
+ return;
4910
+ this.resetRemoteAudioEvidence(true);
4911
+ this.rebuildRemoteAudioAnalyser(stream);
4912
+ this.bindRemoteAudioTrackState(stream);
4913
+ this.startRemoteAudioEvidenceSampling();
4914
+ };
4915
+ stream.addEventListener("addtrack", refreshTrackSet);
4916
+ stream.addEventListener("removetrack", refreshTrackSet);
4917
+ }
4918
+ for (const track of stream.getAudioTracks()) {
4919
+ if (this.boundRemoteAudioTracks.has(track) ||
4920
+ typeof track.addEventListener !== "function") {
4921
+ continue;
4922
+ }
4923
+ this.boundRemoteAudioTracks.add(track);
4924
+ track.addEventListener("mute", () => {
4925
+ if (!isCurrent(track))
4926
+ return;
4927
+ this.resetRemoteAudioEvidence(true);
4928
+ this.startRemoteAudioEvidenceSampling();
4929
+ });
4930
+ track.addEventListener("unmute", () => {
4931
+ if (!isCurrent(track))
4932
+ return;
4933
+ this.resetRemoteAudioEvidence(false);
4934
+ this.resumeRemoteAudioContext();
4935
+ this.startRemoteAudioEvidenceSampling();
4936
+ });
4937
+ track.addEventListener("ended", () => {
4938
+ if (!isCurrent(track))
4939
+ return;
4940
+ this.resetRemoteAudioEvidence(true);
4941
+ this.rebuildRemoteAudioAnalyser(stream);
4942
+ if (stream
4943
+ .getAudioTracks()
4944
+ .some((candidate) => candidate.readyState === "live")) {
4945
+ this.startRemoteAudioEvidenceSampling();
4946
+ return;
4947
+ }
4948
+ this.mediaPlaybackActive = false;
4949
+ this.applyRemotePlaybackState("ended");
4950
+ });
4951
+ }
4952
+ }
4953
+ remoteAudioIsAudible() {
4954
+ return Boolean(this.remoteAudioEvidenceAudible &&
4955
+ this.mediaPlaybackActive &&
4956
+ this.remoteAudioTrackIsPlayable());
4957
+ }
4958
+ authorizeVoicePlayback(value) {
4959
+ this.audio.autoplay = value && !this.playbackInterrupted;
4960
+ if (!value || this.playbackInterrupted)
4961
+ return;
4962
+ this.audio.setAttribute("playsinline", "");
4963
+ this.audio.setAttribute("aria-hidden", "true");
4964
+ // Create/resume inside the voice-button gesture when possible. Safari can
4965
+ // otherwise leave an AudioContext created after the RTC stream arrives in
4966
+ // the suspended state even though media playback itself was authorized.
4967
+ this.ensureRemoteAudioContext();
4968
+ this.resumeRemoteAudioContext();
4969
+ if (this.audio.srcObject)
4970
+ void this.playRemoteAudio();
4971
+ }
4558
4972
  playRemoteAudio() {
4559
4973
  // Text sessions keep a receive-only audio section for the realtime
4560
4974
  // transport, so an attached stream alone never authorizes playback.
@@ -4563,78 +4977,546 @@ export class WidgetView {
4563
4977
  remoteStream
4564
4978
  .getAudioTracks()
4565
4979
  .some((track) => track.readyState === "live");
4566
- if (!this.active || !this.voiceActive || !hasLiveAudioTrack) {
4980
+ if (!this.active ||
4981
+ !this.voiceActive ||
4982
+ !hasLiveAudioTrack ||
4983
+ this.playbackInterrupted) {
4567
4984
  return Promise.resolve();
4568
4985
  }
4569
4986
  if (this.playbackResumePending)
4570
4987
  return Promise.resolve();
4988
+ this.bindPlaybackState();
4989
+ this.ensureRemoteAudioContext();
4990
+ this.rebuildRemoteAudioAnalyser(remoteStream);
4991
+ this.resumeRemoteAudioContext();
4571
4992
  const generation = this.playbackGeneration;
4993
+ const attempt = ++this.playbackAttempt;
4572
4994
  this.playbackResumePending = true;
4573
- return this.audio
4574
- .play()
4575
- .then(() => {
4576
- if (generation !== this.playbackGeneration)
4577
- return;
4578
- this.playbackBlocked = false;
4579
- })
4580
- .catch(() => {
4581
- if (generation !== this.playbackGeneration)
4582
- return;
4583
- this.playbackBlocked = true;
4584
- this.setStatus(this.muted && this.voiceActive
4585
- ? this.messages.muted
4586
- : this.messages.audioPaused);
4587
- this.emitPlaybackState("blocked");
4588
- })
4589
- .finally(() => {
4590
- if (generation === this.playbackGeneration) {
4995
+ this.remotePlaybackState = "waiting";
4996
+ this.refreshAssistantPlaybackPresentation();
4997
+ let playback;
4998
+ try {
4999
+ playback = this.audio.play();
5000
+ }
5001
+ catch (error) {
5002
+ playback = Promise.reject(error);
5003
+ }
5004
+ return new Promise((resolve) => {
5005
+ let settled = false;
5006
+ const finish = () => {
5007
+ if (settled)
5008
+ return;
5009
+ settled = true;
5010
+ if (this.playbackResumeFinish === finish) {
5011
+ this.playbackResumeFinish = null;
5012
+ }
5013
+ resolve();
5014
+ };
5015
+ this.playbackResumeFinish = finish;
5016
+ const timeout = setTimeout(() => {
5017
+ if (generation !== this.playbackGeneration ||
5018
+ attempt !== this.playbackAttempt) {
5019
+ finish();
5020
+ return;
5021
+ }
5022
+ this.playbackAttempt += 1;
4591
5023
  this.playbackResumePending = false;
4592
- }
5024
+ this.playbackResumeTimer = null;
5025
+ this.markPlaybackBlocked();
5026
+ finish();
5027
+ }, REMOTE_PLAYBACK_START_TIMEOUT_MS);
5028
+ this.playbackResumeTimer = timeout;
5029
+ void playback
5030
+ .then(() => {
5031
+ if (generation !== this.playbackGeneration ||
5032
+ attempt !== this.playbackAttempt) {
5033
+ return;
5034
+ }
5035
+ this.playbackBlocked = false;
5036
+ })
5037
+ .catch(() => {
5038
+ if (generation !== this.playbackGeneration ||
5039
+ attempt !== this.playbackAttempt) {
5040
+ return;
5041
+ }
5042
+ this.markPlaybackBlocked();
5043
+ })
5044
+ .finally(() => {
5045
+ if (this.playbackResumeTimer === timeout &&
5046
+ generation === this.playbackGeneration &&
5047
+ attempt === this.playbackAttempt) {
5048
+ clearTimeout(timeout);
5049
+ this.playbackResumeTimer = null;
5050
+ this.playbackResumePending = false;
5051
+ }
5052
+ finish();
5053
+ });
4593
5054
  });
4594
5055
  }
5056
+ markPlaybackBlocked() {
5057
+ this.mediaPlaybackActive = false;
5058
+ this.resetRemoteAudioEvidence(false);
5059
+ this.playbackBlocked = true;
5060
+ this.remotePlaybackState = "blocked";
5061
+ this.refreshAssistantPlaybackPresentation();
5062
+ this.emitPlaybackState("blocked");
5063
+ }
4595
5064
  invalidateRemotePlayback() {
5065
+ if (this.playbackResumeTimer !== null) {
5066
+ clearTimeout(this.playbackResumeTimer);
5067
+ this.playbackResumeTimer = null;
5068
+ }
4596
5069
  this.playbackGeneration += 1;
5070
+ this.playbackAttempt += 1;
5071
+ this.playbackResumeFinish?.();
4597
5072
  this.playbackBlocked = false;
4598
5073
  this.playbackResumePending = false;
5074
+ this.mediaPlaybackActive = false;
5075
+ this.remoteAudioEvidenceCandidateUntil = 0;
5076
+ this.stopRemoteAudioEvidenceSampling();
5077
+ this.resetRemoteAudioEvidenceState();
5078
+ this.disconnectRemoteAudioAnalyser();
5079
+ this.remotePlaybackState = "idle";
5080
+ this.refreshAssistantPlaybackPresentation();
5081
+ }
5082
+ pauseRemotePlayback(emit = false) {
5083
+ this.invalidateRemotePlayback();
5084
+ this.remotePlaybackState = "paused";
5085
+ this.audio.pause();
5086
+ if (emit)
5087
+ this.emitPlaybackState("paused");
5088
+ }
5089
+ resetRemotePlayback() {
5090
+ this.playbackInterrupted = false;
5091
+ this.pauseRemotePlayback();
5092
+ this.audio.srcObject = null;
5093
+ this.audio.autoplay = false;
5094
+ }
5095
+ playbackEventIsCurrent() {
5096
+ return Boolean(!this.destroyed &&
5097
+ this.active &&
5098
+ this.voiceActive &&
5099
+ this.audio.srcObject &&
5100
+ !this.panel.classList.contains("error-state") &&
5101
+ !this.panel.classList.contains("ending-state"));
5102
+ }
5103
+ bindPlaybackState() {
5104
+ this.unbindPlaybackState();
5105
+ const generation = this.playbackGeneration;
5106
+ const stream = this.audio.srcObject;
5107
+ const current = () => generation === this.playbackGeneration &&
5108
+ this.audio.srcObject === stream &&
5109
+ this.playbackEventIsCurrent();
5110
+ const bind = (type, handler) => {
5111
+ const listener = () => {
5112
+ if (!current())
5113
+ return;
5114
+ handler();
5115
+ };
5116
+ this.playbackStateBindings.push({ type, listener });
5117
+ this.audio.addEventListener(type, listener);
5118
+ };
5119
+ bind("playing", () => {
5120
+ if (this.playbackInterrupted) {
5121
+ this.audio.pause();
5122
+ return;
5123
+ }
5124
+ if (this.playbackResumeTimer !== null) {
5125
+ clearTimeout(this.playbackResumeTimer);
5126
+ this.playbackResumeTimer = null;
5127
+ }
5128
+ this.playbackResumeFinish?.();
5129
+ this.playbackAttempt += 1;
5130
+ this.playbackResumePending = false;
5131
+ this.playbackBlocked = false;
5132
+ this.mediaPlaybackActive = true;
5133
+ this.remoteAudioEvidenceCandidateUntil = Math.max(this.remoteAudioEvidenceCandidateUntil, this.remoteAudioEvidenceNow() + REMOTE_AUDIO_EVIDENCE_READY_TAIL_MS);
5134
+ this.remotePlaybackState = "waiting";
5135
+ this.refreshAssistantPlaybackPresentation();
5136
+ this.emitPlaybackState("waiting");
5137
+ if (stream)
5138
+ this.rebuildRemoteAudioAnalyser(stream);
5139
+ this.resumeRemoteAudioContext();
5140
+ this.startRemoteAudioEvidenceSampling();
5141
+ });
5142
+ bind("waiting", () => {
5143
+ this.mediaPlaybackActive = false;
5144
+ this.resetRemoteAudioEvidence(false);
5145
+ this.applyRemotePlaybackState("waiting", true);
5146
+ });
5147
+ bind("pause", () => {
5148
+ this.mediaPlaybackActive = false;
5149
+ this.resetRemoteAudioEvidence(false);
5150
+ this.applyRemotePlaybackState("paused", true);
5151
+ });
5152
+ bind("ended", () => {
5153
+ this.mediaPlaybackActive = false;
5154
+ this.resetRemoteAudioEvidence(false);
5155
+ this.applyRemotePlaybackState("ended", true);
5156
+ });
5157
+ bind("volumechange", () => {
5158
+ if (this.audio.muted || this.audio.volume <= 0) {
5159
+ this.resetRemoteAudioEvidence(true);
5160
+ return;
5161
+ }
5162
+ this.resetRemoteAudioEvidenceAttack();
5163
+ this.resumeRemoteAudioContext();
5164
+ this.startRemoteAudioEvidenceSampling();
5165
+ });
5166
+ }
5167
+ unbindPlaybackState() {
5168
+ for (const binding of this.playbackStateBindings) {
5169
+ this.audio.removeEventListener(binding.type, binding.listener);
5170
+ }
5171
+ this.playbackStateBindings = [];
5172
+ }
5173
+ ensureRemoteAudioContext() {
5174
+ if (this.remoteAudioContext) {
5175
+ this.resumeRemoteAudioContext();
5176
+ return;
5177
+ }
5178
+ const AudioContextConstructor = window.AudioContext ||
5179
+ window
5180
+ .webkitAudioContext;
5181
+ if (!AudioContextConstructor)
5182
+ return;
5183
+ try {
5184
+ this.remoteAudioContext = new AudioContextConstructor({
5185
+ latencyHint: "interactive",
5186
+ });
5187
+ const context = this.remoteAudioContext;
5188
+ this.remoteAudioContextStateListener = () => {
5189
+ if (this.destroyed || this.remoteAudioContext !== context)
5190
+ return;
5191
+ if (context.state === "running") {
5192
+ this.startRemoteAudioEvidenceSampling();
5193
+ return;
5194
+ }
5195
+ this.resetRemoteAudioEvidence(true);
5196
+ };
5197
+ context.addEventListener?.("statechange", this.remoteAudioContextStateListener);
5198
+ this.resumeRemoteAudioContext();
5199
+ }
5200
+ catch {
5201
+ this.remoteAudioContext = null;
5202
+ this.remoteAudioContextStateListener = null;
5203
+ }
5204
+ }
5205
+ resumeRemoteAudioContext() {
5206
+ const context = this.remoteAudioContext;
5207
+ if (!context || context.state === "closed" || this.destroyed)
5208
+ return;
5209
+ if (context.state === "running") {
5210
+ this.startRemoteAudioEvidenceSampling();
5211
+ return;
5212
+ }
5213
+ const generation = this.playbackGeneration;
5214
+ const stream = this.audio.srcObject;
5215
+ void context
5216
+ .resume()
5217
+ .then(() => {
5218
+ if (this.remoteAudioContext === context &&
5219
+ generation === this.playbackGeneration &&
5220
+ this.audio.srcObject === stream &&
5221
+ this.playbackEventIsCurrent()) {
5222
+ this.startRemoteAudioEvidenceSampling();
5223
+ }
5224
+ })
5225
+ .catch(() => undefined);
5226
+ }
5227
+ rebuildRemoteAudioAnalyser(stream) {
5228
+ this.ensureRemoteAudioContext();
5229
+ const context = this.remoteAudioContext;
5230
+ if (!context || this.audio.srcObject !== stream)
5231
+ return;
5232
+ this.disconnectRemoteAudioAnalyser();
5233
+ try {
5234
+ const analyser = context.createAnalyser();
5235
+ analyser.fftSize = 512;
5236
+ analyser.smoothingTimeConstant = 0.78;
5237
+ const sink = context.createGain();
5238
+ sink.gain.value = 0;
5239
+ analyser.connect(sink);
5240
+ sink.connect(context.destination);
5241
+ this.remoteAudioAnalyser = analyser;
5242
+ this.remoteAudioSilentSink = sink;
5243
+ this.remoteAudioFloatBuffer = new Float32Array(analyser.fftSize);
5244
+ this.remoteAudioByteBuffer = new Uint8Array(analyser.fftSize);
5245
+ const tracks = stream
5246
+ .getAudioTracks()
5247
+ .filter((track) => track.readyState === "live");
5248
+ const contextWithTrackSource = context;
5249
+ for (const track of tracks) {
5250
+ let source;
5251
+ if (typeof contextWithTrackSource.createMediaStreamTrackSource ===
5252
+ "function") {
5253
+ source = contextWithTrackSource.createMediaStreamTrackSource(track);
5254
+ }
5255
+ else if (tracks.length === 1) {
5256
+ source = context.createMediaStreamSource(stream);
5257
+ }
5258
+ else if (typeof MediaStream === "function") {
5259
+ const isolatedStream = new MediaStream([track]);
5260
+ this.remoteAudioAnalysisStreams.push(isolatedStream);
5261
+ source = context.createMediaStreamSource(isolatedStream);
5262
+ }
5263
+ else {
5264
+ throw new Error("Multiple remote audio tracks cannot be analysed.");
5265
+ }
5266
+ source.connect(analyser);
5267
+ this.remoteAudioSources.push(source);
5268
+ this.remoteAudioAnalysedTracks.add(track);
5269
+ }
5270
+ if (this.remoteAudioSources.length === 0) {
5271
+ this.disconnectRemoteAudioAnalyser();
5272
+ }
5273
+ }
5274
+ catch {
5275
+ this.disconnectRemoteAudioAnalyser();
5276
+ }
5277
+ }
5278
+ disconnectRemoteAudioAnalyser() {
5279
+ for (const source of this.remoteAudioSources)
5280
+ source.disconnect();
5281
+ this.remoteAudioSources = [];
5282
+ this.remoteAudioAnalysisStreams = [];
5283
+ this.remoteAudioAnalysedTracks.clear();
5284
+ this.remoteAudioAnalyser?.disconnect();
5285
+ this.remoteAudioAnalyser = null;
5286
+ this.remoteAudioSilentSink?.disconnect();
5287
+ this.remoteAudioSilentSink = null;
5288
+ this.remoteAudioFloatBuffer = null;
5289
+ this.remoteAudioByteBuffer = null;
5290
+ }
5291
+ remoteAudioEvidenceNow() {
5292
+ const value = globalThis.performance?.now?.();
5293
+ return typeof value === "number" && Number.isFinite(value)
5294
+ ? value
5295
+ : Date.now();
5296
+ }
5297
+ remoteAudioEvidenceVisualStateIsEligible() {
5298
+ return Boolean(!this.destroyed &&
5299
+ this.active &&
5300
+ this.voiceActive &&
5301
+ this.mediaPlaybackActive &&
5302
+ this.audio.srcObject &&
5303
+ !this.panel.classList.contains("error-state") &&
5304
+ !this.panel.classList.contains("ending-state") &&
5305
+ (this.remotePlaybackState === "waiting" ||
5306
+ this.remotePlaybackState === "playing"));
5307
+ }
5308
+ remoteAudioEvidenceCandidateIsCurrent(now) {
5309
+ return Boolean(this.remoteAudioEvidenceVisualStateIsEligible() &&
5310
+ (this.remoteAudioEvidenceAudible ||
5311
+ this.assistantState === "thinking" ||
5312
+ this.assistantState === "speaking" ||
5313
+ (this.remoteAudioEvidenceCandidateUntil > 0 &&
5314
+ now < this.remoteAudioEvidenceCandidateUntil)));
5315
+ }
5316
+ updateRemoteAudioEvidenceExpectation(previous, next) {
5317
+ const now = this.remoteAudioEvidenceNow();
5318
+ if (next === "thinking" || next === "speaking") {
5319
+ this.remoteAudioEvidenceCandidateUntil = Math.max(this.remoteAudioEvidenceCandidateUntil, now + REMOTE_AUDIO_EVIDENCE_EXPECTATION_MS);
5320
+ this.startRemoteAudioEvidenceSampling();
5321
+ return;
5322
+ }
5323
+ if (next === "ready" &&
5324
+ (previous === "thinking" ||
5325
+ previous === "speaking" ||
5326
+ this.remoteAudioEvidenceAudible)) {
5327
+ this.remoteAudioEvidenceCandidateUntil = Math.max(this.remoteAudioEvidenceCandidateUntil, now + REMOTE_AUDIO_EVIDENCE_READY_TAIL_MS);
5328
+ this.startRemoteAudioEvidenceSampling();
5329
+ return;
5330
+ }
5331
+ this.remoteAudioEvidenceCandidateUntil = 0;
5332
+ this.resetRemoteAudioEvidence(true);
5333
+ }
5334
+ remoteAudioTrackIsPlayable() {
5335
+ const stream = this.audio.srcObject;
5336
+ const currentTracks = typeof stream?.getAudioTracks === "function"
5337
+ ? stream.getAudioTracks()
5338
+ : [];
5339
+ return Boolean(stream &&
5340
+ !this.audio.paused &&
5341
+ !this.audio.muted &&
5342
+ this.audio.volume > 0 &&
5343
+ this.remoteAudioAnalysedTracks.size > 0 &&
5344
+ [...this.remoteAudioAnalysedTracks].some((track) => currentTracks.some((candidate) => candidate === track) &&
5345
+ track.readyState === "live" &&
5346
+ track.enabled !== false &&
5347
+ track.muted !== true));
5348
+ }
5349
+ startRemoteAudioEvidenceSampling() {
5350
+ if (this.remoteAudioEvidenceTimer !== null ||
5351
+ !this.remoteAudioAnalyser ||
5352
+ (!this.remoteAudioFloatBuffer && !this.remoteAudioByteBuffer) ||
5353
+ this.remoteAudioContext?.state !== "running" ||
5354
+ !this.remoteAudioEvidenceCandidateIsCurrent(this.remoteAudioEvidenceNow())) {
5355
+ return;
5356
+ }
5357
+ const generation = this.remoteAudioEvidenceGeneration;
5358
+ const now = this.remoteAudioEvidenceNow();
5359
+ const inBurstWindow = this.remoteAudioEvidenceAudible ||
5360
+ (this.remoteAudioEvidenceCandidateUntil > 0 &&
5361
+ now < this.remoteAudioEvidenceCandidateUntil);
5362
+ const delay = inBurstWindow
5363
+ ? this.remoteAudioTrackIsPlayable()
5364
+ ? REMOTE_AUDIO_EVIDENCE_SAMPLE_MS
5365
+ : REMOTE_AUDIO_EVIDENCE_RECHECK_MS
5366
+ : REMOTE_AUDIO_EVIDENCE_IDLE_RECHECK_MS;
5367
+ this.remoteAudioEvidenceTimer = setTimeout(() => {
5368
+ this.remoteAudioEvidenceTimer = null;
5369
+ if (generation !== this.remoteAudioEvidenceGeneration)
5370
+ return;
5371
+ this.sampleRemoteAudioEvidence(generation);
5372
+ }, delay);
5373
+ }
5374
+ sampleRemoteAudioEvidence(generation) {
5375
+ if (generation !== this.remoteAudioEvidenceGeneration ||
5376
+ !this.remoteAudioEvidenceVisualStateIsEligible()) {
5377
+ return;
5378
+ }
5379
+ const now = this.remoteAudioEvidenceNow();
5380
+ if (!this.remoteAudioEvidenceCandidateIsCurrent(now)) {
5381
+ this.resetRemoteAudioEvidence(true);
5382
+ return;
5383
+ }
5384
+ if (!this.remoteAudioTrackIsPlayable()) {
5385
+ this.resetRemoteAudioEvidence(true);
5386
+ this.startRemoteAudioEvidenceSampling();
5387
+ return;
5388
+ }
5389
+ const sample = this.readRemoteAudioEvidence();
5390
+ if (!sample) {
5391
+ this.resetRemoteAudioEvidence(true);
5392
+ this.startRemoteAudioEvidenceSampling();
5393
+ return;
5394
+ }
5395
+ const attack = sample.rms >= REMOTE_AUDIO_EVIDENCE_ATTACK_RMS ||
5396
+ sample.peak >= REMOTE_AUDIO_EVIDENCE_ATTACK_PEAK;
5397
+ const sustain = sample.rms >= REMOTE_AUDIO_EVIDENCE_SUSTAIN_RMS ||
5398
+ sample.peak >= REMOTE_AUDIO_EVIDENCE_SUSTAIN_PEAK;
5399
+ if (!this.remoteAudioEvidenceAudible) {
5400
+ const mask = (1 << REMOTE_AUDIO_EVIDENCE_ATTACK_WINDOW) - 1;
5401
+ this.remoteAudioEvidenceAttackWindow =
5402
+ ((this.remoteAudioEvidenceAttackWindow << 1) | Number(attack)) & mask;
5403
+ let hits = 0;
5404
+ for (let candidates = this.remoteAudioEvidenceAttackWindow; candidates > 0; candidates >>= 1) {
5405
+ hits += candidates & 1;
5406
+ }
5407
+ if (hits >= REMOTE_AUDIO_EVIDENCE_ATTACK_HITS) {
5408
+ this.remoteAudioEvidenceAudible = true;
5409
+ this.remoteAudioEvidenceQuietSince = null;
5410
+ this.remoteAudioEvidenceAttackWindow = 0;
5411
+ this.remoteAudioEvidenceCandidateUntil = Math.max(this.remoteAudioEvidenceCandidateUntil, now + REMOTE_AUDIO_EVIDENCE_READY_TAIL_MS);
5412
+ this.applyRemotePlaybackState("playing");
5413
+ }
5414
+ }
5415
+ else if (sustain) {
5416
+ this.remoteAudioEvidenceQuietSince = null;
5417
+ this.remoteAudioEvidenceCandidateUntil = Math.max(this.remoteAudioEvidenceCandidateUntil, now + REMOTE_AUDIO_EVIDENCE_READY_TAIL_MS);
5418
+ }
5419
+ else if (this.remoteAudioEvidenceQuietSince === null) {
5420
+ this.remoteAudioEvidenceQuietSince = now;
5421
+ }
5422
+ else if (now - this.remoteAudioEvidenceQuietSince >=
5423
+ REMOTE_AUDIO_EVIDENCE_RELEASE_MS) {
5424
+ this.remoteAudioEvidenceAudible = false;
5425
+ this.resetRemoteAudioEvidenceAttack();
5426
+ this.applyRemotePlaybackState("waiting");
5427
+ }
5428
+ this.startRemoteAudioEvidenceSampling();
5429
+ }
5430
+ readRemoteAudioEvidence() {
5431
+ const analyser = this.remoteAudioAnalyser;
5432
+ const context = this.remoteAudioContext;
5433
+ if (!analyser || !context || context.state !== "running")
5434
+ return null;
5435
+ let length = 0;
5436
+ let valueAt = null;
5437
+ let floatRead = false;
5438
+ if (this.remoteAudioFloatBuffer &&
5439
+ typeof analyser.getFloatTimeDomainData === "function") {
5440
+ try {
5441
+ analyser.getFloatTimeDomainData(this.remoteAudioFloatBuffer);
5442
+ length = this.remoteAudioFloatBuffer.length;
5443
+ valueAt = (index) => this.remoteAudioFloatBuffer?.[index] ?? 0;
5444
+ floatRead = true;
5445
+ }
5446
+ catch {
5447
+ floatRead = false;
5448
+ }
5449
+ }
5450
+ if (!floatRead) {
5451
+ if (!this.remoteAudioByteBuffer)
5452
+ return null;
5453
+ try {
5454
+ analyser.getByteTimeDomainData(this.remoteAudioByteBuffer);
5455
+ length = this.remoteAudioByteBuffer.length;
5456
+ valueAt = (index) => ((this.remoteAudioByteBuffer?.[index] ?? 128) - 128) / 128;
5457
+ }
5458
+ catch {
5459
+ return null;
5460
+ }
5461
+ }
5462
+ if (length === 0 || !valueAt)
5463
+ return null;
5464
+ let mean = 0;
5465
+ for (let index = 0; index < length; index += 1) {
5466
+ const value = valueAt(index);
5467
+ if (!Number.isFinite(value))
5468
+ return null;
5469
+ mean += value;
5470
+ }
5471
+ mean /= length;
5472
+ let sum = 0;
5473
+ let peak = 0;
5474
+ for (let index = 0; index < length; index += 1) {
5475
+ const centered = valueAt(index) - mean;
5476
+ if (!Number.isFinite(centered))
5477
+ return null;
5478
+ sum += centered * centered;
5479
+ peak = Math.max(peak, Math.abs(centered));
5480
+ }
5481
+ const volume = Math.min(1, Math.max(0, this.audio.volume));
5482
+ const rms = Math.sqrt(sum / length) * volume;
5483
+ peak *= volume;
5484
+ return Number.isFinite(rms) && Number.isFinite(peak) ? { rms, peak } : null;
4599
5485
  }
4600
- pauseRemotePlayback() {
4601
- this.invalidateRemotePlayback();
4602
- this.audio.pause();
5486
+ stopRemoteAudioEvidenceSampling() {
5487
+ if (this.remoteAudioEvidenceTimer !== null) {
5488
+ clearTimeout(this.remoteAudioEvidenceTimer);
5489
+ this.remoteAudioEvidenceTimer = null;
5490
+ }
5491
+ this.remoteAudioEvidenceGeneration += 1;
4603
5492
  }
4604
- resetRemotePlayback() {
4605
- this.pauseRemotePlayback();
4606
- this.audio.srcObject = null;
5493
+ resetRemoteAudioEvidenceAttack() {
5494
+ this.remoteAudioEvidenceAttackWindow = 0;
5495
+ this.remoteAudioEvidenceQuietSince = null;
4607
5496
  }
4608
- playbackEventIsCurrent() {
4609
- return Boolean(this.active && this.voiceActive && this.audio.srcObject);
5497
+ resetRemoteAudioEvidenceState() {
5498
+ this.remoteAudioEvidenceAudible = false;
5499
+ this.resetRemoteAudioEvidenceAttack();
4610
5500
  }
4611
- bindPlaybackState() {
4612
- this.audio.addEventListener("playing", () => {
4613
- if (!this.playbackEventIsCurrent())
4614
- return;
4615
- this.playbackBlocked = false;
4616
- this.emitPlaybackState("playing");
4617
- });
4618
- this.audio.addEventListener("waiting", () => {
4619
- if (!this.playbackEventIsCurrent())
4620
- return;
4621
- this.emitPlaybackState("waiting");
4622
- });
4623
- this.audio.addEventListener("pause", () => {
4624
- if (!this.playbackEventIsCurrent())
4625
- return;
4626
- this.emitPlaybackState("paused");
4627
- });
4628
- this.audio.addEventListener("ended", () => {
4629
- if (!this.playbackEventIsCurrent())
4630
- return;
4631
- this.emitPlaybackState("ended");
4632
- });
5501
+ resetRemoteAudioEvidence(emitWaiting) {
5502
+ const wasAudible = this.remoteAudioEvidenceAudible || this.remotePlaybackState === "playing";
5503
+ this.stopRemoteAudioEvidenceSampling();
5504
+ this.resetRemoteAudioEvidenceState();
5505
+ if (emitWaiting && wasAudible) {
5506
+ this.applyRemotePlaybackState("waiting", true);
5507
+ }
5508
+ }
5509
+ applyRemotePlaybackState(state, force = false) {
5510
+ if (!force && this.remotePlaybackState === state)
5511
+ return;
5512
+ this.remotePlaybackState = state;
5513
+ this.refreshAssistantPlaybackPresentation();
5514
+ this.emitPlaybackState(state);
4633
5515
  }
4634
5516
  emitPlaybackState(state) {
4635
5517
  this.callbacks.onPlaybackState({
4636
5518
  state,
4637
- audible: state === "playing" && !this.audio.muted && this.audio.volume > 0,
5519
+ audible: state === "playing" && this.remoteAudioIsAudible(),
4638
5520
  utteranceId: null,
4639
5521
  sampledAt: new Date().toISOString(),
4640
5522
  });
@@ -4646,6 +5528,7 @@ export class WidgetView {
4646
5528
  applyStatus(value) {
4647
5529
  this.status.textContent = value;
4648
5530
  this.status.setAttribute("aria-label", value);
5531
+ this.status.title = value;
4649
5532
  this.syncSessionModeUi();
4650
5533
  if (this.active)
4651
5534
  this.syncLauncherState();
@@ -4877,6 +5760,57 @@ export class WidgetView {
4877
5760
  rootElement() {
4878
5761
  return this.host;
4879
5762
  }
5763
+ /** Live owns this same playback element; never create a second audible sink. */
5764
+ livePlaybackElement() { return this.audio; }
5765
+ /** Current remote PCM activity, independent of the element's continuous
5766
+ * playing state. Null is unavailable evidence, never proof of silence.
5767
+ * Reuses the existing analyser and never starts or authorizes playback. */
5768
+ livePlaybackActivity() {
5769
+ const stream = this.audio.srcObject;
5770
+ if (!stream || this.audio.paused || this.audio.ended) {
5771
+ this.livePlaybackObservation = null;
5772
+ return false;
5773
+ }
5774
+ const now = performance.now();
5775
+ if (!Number.isFinite(now) || now < 0)
5776
+ return null;
5777
+ if (!this.livePlaybackObservation || this.livePlaybackObservation.source !== stream) {
5778
+ this.livePlaybackObservation = { source: stream, quietSince: null, lastAt: now };
5779
+ this.rebuildRemoteAudioAnalyser(stream);
5780
+ }
5781
+ const observation = this.livePlaybackObservation;
5782
+ if (now < observation.lastAt) {
5783
+ observation.quietSince = null;
5784
+ observation.lastAt = now;
5785
+ return null;
5786
+ }
5787
+ observation.lastAt = now;
5788
+ const sample = this.readRemoteAudioEvidence();
5789
+ if (!sample) {
5790
+ observation.quietSince = null;
5791
+ return null;
5792
+ }
5793
+ if (sample.rms >= REMOTE_AUDIO_EVIDENCE_SUSTAIN_RMS || sample.peak >= REMOTE_AUDIO_EVIDENCE_SUSTAIN_PEAK) {
5794
+ observation.quietSince = null;
5795
+ return true;
5796
+ }
5797
+ observation.quietSince ?? (observation.quietSince = now);
5798
+ return now - observation.quietSince < REMOTE_AUDIO_EVIDENCE_RELEASE_MS;
5799
+ }
5800
+ /** Observe a stopped render sink across several audio quanta. This proves
5801
+ * local playback drain only, never provider closure or acoustic echo quality. */
5802
+ livePlaybackDrained() {
5803
+ if (!this.audio.paused && !this.audio.ended) {
5804
+ this.liveDrainObservation = null;
5805
+ return false;
5806
+ }
5807
+ const now = performance.now();
5808
+ if (!this.liveDrainObservation || this.liveDrainObservation.source !== this.audio.srcObject || now < this.liveDrainObservation.since) {
5809
+ this.liveDrainObservation = { source: this.audio.srcObject, since: now };
5810
+ return false;
5811
+ }
5812
+ return now - this.liveDrainObservation.since >= 80;
5813
+ }
4880
5814
  get hasFocus() {
4881
5815
  return document.activeElement === this.host;
4882
5816
  }
@@ -4915,17 +5849,66 @@ export class WidgetView {
4915
5849
  this.clearAssistantReadyVisualTimer();
4916
5850
  this.applyAssistantState(state);
4917
5851
  }
5852
+ assistantPresentationState() {
5853
+ if (this.voiceActive &&
5854
+ this.manualTurn &&
5855
+ !this.pushActive &&
5856
+ this.assistantState === "listening") {
5857
+ return "ready";
5858
+ }
5859
+ if (this.voiceActive &&
5860
+ this.assistantState === "speaking" &&
5861
+ this.remotePlaybackState !== "playing") {
5862
+ return "thinking";
5863
+ }
5864
+ if (this.assistantState === "listening" ||
5865
+ this.assistantState === "thinking" ||
5866
+ this.assistantState === "speaking") {
5867
+ return this.assistantState;
5868
+ }
5869
+ return "ready";
5870
+ }
5871
+ assistantPresentationMessage() {
5872
+ if (this.voiceActive && this.remotePlaybackState === "blocked") {
5873
+ return this.messages.audioPaused;
5874
+ }
5875
+ const state = this.assistantPresentationState();
5876
+ if (this.voiceActive &&
5877
+ this.manualTurn &&
5878
+ !this.pushActive &&
5879
+ state === "ready") {
5880
+ return this.messages.usePushToTalk;
5881
+ }
5882
+ return this.messages[state];
5883
+ }
5884
+ refreshAssistantPlaybackPresentation() {
5885
+ if (this.assistantState !== "speaking" &&
5886
+ !(this.voiceActive && this.remotePlaybackState === "blocked"))
5887
+ return;
5888
+ this.setActivity(this.assistantPresentationState());
5889
+ const message = this.assistantPresentationMessage();
5890
+ if (this.muted && this.voiceActive) {
5891
+ this.statusBeforeMute = message;
5892
+ this.setStatus(this.messages.muted);
5893
+ return;
5894
+ }
5895
+ this.setStatus(message);
5896
+ }
4918
5897
  applyAssistantState(state) {
5898
+ const previousState = this.assistantState;
4919
5899
  this.assistantState = state;
4920
- this.setActivity(state);
5900
+ this.updateRemoteAudioEvidenceExpectation(previousState, state);
5901
+ const presentationState = this.assistantPresentationState();
5902
+ const presentationMessage = this.assistantPresentationMessage();
5903
+ this.setActivity(presentationState);
4921
5904
  if (this.muted && this.voiceActive) {
4922
- this.statusBeforeMute = this.messages[state];
5905
+ this.statusBeforeMute = presentationMessage;
4923
5906
  this.setStatus(this.messages.muted);
4924
5907
  }
4925
5908
  else {
4926
- this.setStatus(this.messages[state]);
5909
+ this.setStatus(presentationMessage);
4927
5910
  }
4928
- if (state === "listening") {
5911
+ if (state === "listening" && presentationState === "listening") {
4929
5912
  this.assistantCaptionPhase = "none";
4930
5913
  this.clearPendingCaptions("assistant");
4931
5914
  this.ensurePendingCaption("user", this.messages.listening);
@@ -4936,13 +5919,15 @@ export class WidgetView {
4936
5919
  this.assistantCaptionPhase = "none";
4937
5920
  }
4938
5921
  if (this.assistantCaptionPhase === "none") {
4939
- this.ensurePendingCaption("assistant", this.messages[state]);
5922
+ this.ensurePendingCaption("assistant", this.messages[presentationState]);
4940
5923
  }
4941
5924
  }
4942
5925
  else {
4943
5926
  this.clearPendingCaptions(undefined, this.assistantCaptionPhase === "final");
4944
5927
  }
4945
- if (state === "speaking" && this.audio.paused) {
5928
+ if (state === "speaking" &&
5929
+ this.audio.paused &&
5930
+ this.remotePlaybackState !== "playing") {
4946
5931
  void this.playRemoteAudio();
4947
5932
  }
4948
5933
  this.setAmbientActive(state !== "ready");
@@ -4999,6 +5984,7 @@ export class WidgetView {
4999
5984
  this.assistantState = "connecting";
5000
5985
  this.setActivity("connecting");
5001
5986
  this.voiceActive = mode === "voice";
5987
+ this.authorizeVoicePlayback(this.voiceActive);
5002
5988
  this.modeTransitionPending = null;
5003
5989
  this.panel.classList.toggle("voice-session", this.voiceActive);
5004
5990
  this.panel.classList.remove("feedback-state");
@@ -5062,7 +6048,7 @@ export class WidgetView {
5062
6048
  this.conversation.classList.add("visible");
5063
6049
  this.controls.classList.add("visible");
5064
6050
  this.setComposerEnabled(true);
5065
- this.setStatus(this.messages.ready);
6051
+ this.setStatus(this.assistantPresentationMessage());
5066
6052
  this.clearPendingCaptions();
5067
6053
  this.setAmbientActive(false);
5068
6054
  if (this.sessionStartedAt === null)
@@ -5115,6 +6101,7 @@ export class WidgetView {
5115
6101
  actions.hidden = actions.childElementCount === 0;
5116
6102
  group.hidden = false;
5117
6103
  this.captions.scrollTop = 0;
6104
+ this.captionsPinnedToBottom = true;
5118
6105
  }
5119
6106
  defaultWelcomeMessage() {
5120
6107
  return this.messages.messagePlaceholder;
@@ -5135,6 +6122,7 @@ export class WidgetView {
5135
6122
  group.hidden = false;
5136
6123
  this.pendingWelcomeBubble = bubble;
5137
6124
  this.captions.scrollTop = 0;
6125
+ this.captionsPinnedToBottom = true;
5138
6126
  }
5139
6127
  clearPendingWelcomeSkeleton() {
5140
6128
  const bubble = this.pendingWelcomeBubble;
@@ -5155,14 +6143,32 @@ export class WidgetView {
5155
6143
  this.captions.prepend(empty);
5156
6144
  }
5157
6145
  }
5158
- scrollCaptionsToBottom() {
6146
+ scrollCaptionsToBottom(force = false) {
6147
+ if (!force && !this.captionsPinnedToBottom)
6148
+ return;
5159
6149
  this.captions.scrollTop = this.captions.scrollHeight;
6150
+ this.captionsPinnedToBottom = true;
6151
+ }
6152
+ updateCaptionsPinnedState() {
6153
+ const remaining = this.captions.scrollHeight -
6154
+ this.captions.clientHeight -
6155
+ this.captions.scrollTop;
6156
+ this.captionsPinnedToBottom = remaining <= CAPTION_BOTTOM_PIN_THRESHOLD_PX;
5160
6157
  }
5161
6158
  addCaption(role, text, final, options = {}) {
5162
6159
  if (!this.captionsEnabled)
5163
6160
  return;
5164
6161
  const restored = options.restored === true;
5165
- if (!final && role === "user" && this.assistantState !== "listening") {
6162
+ const partialKey = options.liveFragmentGroup
6163
+ ? `${role}-live-fragment`
6164
+ : `${role}-partial`;
6165
+ if (final &&
6166
+ role === "assistant" &&
6167
+ options.sourceTurnId &&
6168
+ Array.from(this.captions.querySelectorAll("p[data-source-turn-id]")).some((line) => line.dataset.sourceTurnId === options.sourceTurnId))
6169
+ return;
6170
+ if (!final && role === "user" && this.assistantState !== "listening" &&
6171
+ !options.liveFragmentGroup) {
5166
6172
  return;
5167
6173
  }
5168
6174
  this.captions.querySelector('[data-role="empty"]')?.remove();
@@ -5175,10 +6181,15 @@ export class WidgetView {
5175
6181
  this.ensurePendingCaption(role, role === "user" ? this.messages.listening : this.messages.thinking);
5176
6182
  return;
5177
6183
  }
5178
- let partial = this.captions.querySelector(`[data-caption="${role}-partial"]`);
6184
+ let partial = this.captions.querySelector(`[data-caption="${partialKey}"]`);
5179
6185
  if (!partial) {
6186
+ if (options.liveFragmentGroup) {
6187
+ this.captions
6188
+ .querySelector(`[data-caption="${role}-partial"].pending`)
6189
+ ?.remove();
6190
+ }
5180
6191
  partial = document.createElement("p");
5181
- partial.dataset.caption = `${role}-partial`;
6192
+ partial.dataset.caption = partialKey;
5182
6193
  this.captions.append(partial);
5183
6194
  }
5184
6195
  partial.classList.remove(role === "assistant" ? "user" : "assistant", "pending", "typing", "settled");
@@ -5188,7 +6199,7 @@ export class WidgetView {
5188
6199
  partial.removeAttribute("aria-label");
5189
6200
  this.renderLiveCaption(partial, safe);
5190
6201
  this.scrollCaptionsToBottom();
5191
- this.addCompactCaption(role, safe, false, role === "user" ? this.messages.listening : this.messages.thinking, true);
6202
+ this.addCompactCaption(role, safe, false, role === "user" ? this.messages.listening : this.messages.thinking, true, options.liveFragmentGroup);
5192
6203
  return;
5193
6204
  }
5194
6205
  if (!safe) {
@@ -5197,7 +6208,7 @@ export class WidgetView {
5197
6208
  this.clearPendingCaptions(role);
5198
6209
  return;
5199
6210
  }
5200
- let line = this.captions.querySelector(`[data-caption="${role}-partial"]`);
6211
+ let line = this.captions.querySelector(`[data-caption="${partialKey}"]`);
5201
6212
  if (!line) {
5202
6213
  line = document.createElement("p");
5203
6214
  this.captions.append(line);
@@ -5209,13 +6220,64 @@ export class WidgetView {
5209
6220
  line.removeAttribute("aria-label");
5210
6221
  this.renderLiveCaption(line, safe, this.captionRenderedHeight(line), !restored);
5211
6222
  line.dataset.caption = `${role}-${crypto.randomUUID()}`;
6223
+ if (role === "assistant" && options.sourceTurnId) {
6224
+ line.dataset.sourceTurnId = options.sourceTurnId;
6225
+ }
6226
+ if (role === "user" && options.localQuestionId) {
6227
+ line.dataset.localQuestionId = options.localQuestionId;
6228
+ }
6229
+ else {
6230
+ delete line.dataset.localQuestionId;
6231
+ }
5212
6232
  const messages = this.captions.querySelectorAll(":scope > p[data-caption]");
5213
6233
  for (let index = 0; index < messages.length - 20; index += 1) {
5214
6234
  messages[index]?.remove();
5215
6235
  }
5216
- this.scrollCaptionsToBottom();
5217
- if (!restored)
5218
- this.addCompactCaption(role, safe, true);
6236
+ this.scrollCaptionsToBottom(role === "user" && !restored);
6237
+ if (!restored) {
6238
+ this.addCompactCaption(role, safe, true, undefined, false, options.liveFragmentGroup);
6239
+ }
6240
+ this.placeCtaOffer();
6241
+ }
6242
+ showCtaOffer(value, options = {}) {
6243
+ const offer = parseCtaOffer(value);
6244
+ if (!offer || this.ctaCard?.offer.offerId === offer.offerId)
6245
+ return;
6246
+ this.clearCtaOffer();
6247
+ this.ctaCard = new CtaOfferCard(offer, this.messages, (result) => this.callbacks.onCtaResult?.(result) ?? false, () => this.require(".end").focus({ preventScroll: true }), options.announce !== false);
6248
+ this.placeCtaOffer();
6249
+ }
6250
+ clearCtaOffer() {
6251
+ this.ctaCard?.destroy();
6252
+ this.ctaCard = null;
6253
+ this.ctaSlot?.remove();
6254
+ this.ctaSlot = null;
6255
+ }
6256
+ placeCtaOffer() {
6257
+ const card = this.ctaCard;
6258
+ if (!card)
6259
+ return;
6260
+ const source = Array.from(this.captions.querySelectorAll("p[data-source-turn-id]")).find((line) => line.dataset.sourceTurnId === card.offer.sourceTurnId);
6261
+ if (!this.compact && this.captionsEnabled && source) {
6262
+ const pinned = this.captions.scrollHeight -
6263
+ this.captions.scrollTop -
6264
+ this.captions.clientHeight <=
6265
+ CAPTION_BOTTOM_PIN_THRESHOLD_PX;
6266
+ if (source.nextElementSibling !== card.element)
6267
+ source.after(card.element);
6268
+ if (pinned)
6269
+ this.scrollCaptionsToBottom();
6270
+ return;
6271
+ }
6272
+ if (!this.ctaSlot) {
6273
+ this.ctaSlot = document.createElement("div");
6274
+ this.ctaSlot.className = "cta-action-slot";
6275
+ }
6276
+ const slotParent = this.compact ? this.panel : this.conversation;
6277
+ if (this.ctaSlot.parentElement !== slotParent)
6278
+ slotParent.prepend(this.ctaSlot);
6279
+ if (card.element.parentElement !== this.ctaSlot)
6280
+ this.ctaSlot.append(card.element);
5219
6281
  }
5220
6282
  ensurePendingCaption(role, label) {
5221
6283
  if (!this.captionsEnabled)
@@ -5455,8 +6517,13 @@ export class WidgetView {
5455
6517
  }
5456
6518
  addCompactCaption(role, text, final, pendingLabel = role === "user"
5457
6519
  ? this.messages.listening
5458
- : this.messages.thinking, live = false) {
5459
- const partialKey = `${role}-partial`;
6520
+ : this.messages.thinking, live = false, fragmentGroup = false) {
6521
+ const partialKey = fragmentGroup ? `${role}-live-fragment` : `${role}-partial`;
6522
+ if (fragmentGroup) {
6523
+ const placeholder = this.compactCaptions.querySelector(`[data-compact-caption="${role}-partial"].pending`);
6524
+ if (placeholder)
6525
+ this.removeCompactCaption(placeholder);
6526
+ }
5460
6527
  const partialLines = [
5461
6528
  ...this.compactCaptions.querySelectorAll(`[data-compact-caption="${partialKey}"]`),
5462
6529
  ];
@@ -5475,7 +6542,7 @@ export class WidgetView {
5475
6542
  line.classList.remove("leaving");
5476
6543
  line.removeAttribute("aria-hidden");
5477
6544
  }
5478
- if (!line && final) {
6545
+ if (!line && final && !fragmentGroup) {
5479
6546
  line =
5480
6547
  [...this.compactCaptions.children]
5481
6548
  .reverse()
@@ -5498,7 +6565,7 @@ export class WidgetView {
5498
6565
  if (!line) {
5499
6566
  line = document.createElement("div");
5500
6567
  line.dataset.compactCaption = partialKey;
5501
- const activeAssistant = final && role === "user"
6568
+ const activeAssistant = final && role === "user" && !fragmentGroup
5502
6569
  ? this.compactCaptions.querySelector('[data-compact-caption="assistant-partial"]')
5503
6570
  : null;
5504
6571
  if (activeAssistant) {
@@ -5691,6 +6758,7 @@ export class WidgetView {
5691
6758
  this.resolveVisualContext(false);
5692
6759
  if (this.currentConfirmation)
5693
6760
  this.resolveConfirmation(false);
6761
+ this.releaseActivePushToTalk();
5694
6762
  this.currentConfirmation = value;
5695
6763
  this.setCompact(false, false);
5696
6764
  this.openPanel();
@@ -5718,11 +6786,24 @@ export class WidgetView {
5718
6786
  });
5719
6787
  }
5720
6788
  showActionState(status) {
6789
+ const actionWasRunning = this.actionStateRunning;
5721
6790
  this.setActionStateRunning(status === "running");
5722
6791
  if (this.actionStateRunning) {
5723
6792
  this.clearAssistantReadyVisualTimer();
5724
6793
  this.assistantState = "thinking";
5725
- this.ensurePendingCaption("assistant", this.messages.thinking);
6794
+ const assistantCaption = this.captions.querySelector('[data-caption="assistant-partial"]');
6795
+ if (!assistantCaption || assistantCaption.classList.contains("pending")) {
6796
+ this.ensurePendingCaption("assistant", this.messages.thinking);
6797
+ }
6798
+ this.actionPendingAssistantCaption =
6799
+ this.captions.querySelector('[data-caption="assistant-partial"].pending');
6800
+ this.actionPendingCompactAssistantCaption =
6801
+ this.compactCaptions.querySelector('[data-compact-caption="assistant-partial"].pending');
6802
+ }
6803
+ else if (actionWasRunning ||
6804
+ this.actionPendingAssistantCaption ||
6805
+ this.actionPendingCompactAssistantCaption) {
6806
+ this.retireActionPendingCaption();
5726
6807
  }
5727
6808
  this.confirmation.classList.remove("visible");
5728
6809
  this.currentConfirmation = null;
@@ -5749,12 +6830,41 @@ export class WidgetView {
5749
6830
  this.restoreVoicePresenceAfterPrompt();
5750
6831
  this.syncHeaderActions();
5751
6832
  }
6833
+ retireActionPendingCaption() {
6834
+ const caption = this.actionPendingAssistantCaption;
6835
+ const compactCaption = this.actionPendingCompactAssistantCaption;
6836
+ this.actionPendingAssistantCaption = null;
6837
+ this.actionPendingCompactAssistantCaption = null;
6838
+ if (caption?.isConnected &&
6839
+ caption.classList.contains("pending") &&
6840
+ caption.querySelector(".typing-dots")) {
6841
+ this.cancelCaptionHeightGlide(caption);
6842
+ caption.remove();
6843
+ }
6844
+ if (compactCaption?.isConnected &&
6845
+ compactCaption.classList.contains("pending") &&
6846
+ compactCaption.querySelector(".typing-dots")) {
6847
+ this.removeCompactCaption(compactCaption);
6848
+ }
6849
+ const providerCaption = this.captions.querySelector('[data-caption="assistant-partial"]:not(.pending)');
6850
+ if (this.assistantState === "thinking" && !providerCaption) {
6851
+ const previousState = this.assistantState;
6852
+ this.assistantState = "ready";
6853
+ this.updateRemoteAudioEvidenceExpectation(previousState, "ready");
6854
+ }
6855
+ }
5752
6856
  dismissActionState() {
6857
+ const actionWasRunning = this.actionStateRunning;
5753
6858
  this.setActionStateRunning(false);
6859
+ if (actionWasRunning ||
6860
+ this.actionPendingAssistantCaption ||
6861
+ this.actionPendingCompactAssistantCaption) {
6862
+ this.retireActionPendingCaption();
6863
+ }
5754
6864
  this.confirmation.classList.remove("visible");
5755
6865
  this.currentConfirmation = null;
5756
6866
  this.dialogFocus.dismiss(this.confirmation);
5757
- this.setStatus(this.messages.ready);
6867
+ this.setStatus(this.assistantPresentationMessage());
5758
6868
  this.setActivity("ready");
5759
6869
  this.setAmbientActive(false);
5760
6870
  this.restoreVoicePresenceAfterPrompt();
@@ -5772,6 +6882,7 @@ export class WidgetView {
5772
6882
  this.resolveVisualContext(false);
5773
6883
  if (this.currentConfirmation)
5774
6884
  this.resolveConfirmation(false);
6885
+ this.releaseActivePushToTalk();
5775
6886
  this.currentVisualRequest = value;
5776
6887
  this.setCompact(false, false);
5777
6888
  this.openPanel();
@@ -5801,6 +6912,7 @@ export class WidgetView {
5801
6912
  if (this.currentHandoffContextRequest || this.handoffRequestPreparing) {
5802
6913
  return;
5803
6914
  }
6915
+ this.releaseActivePushToTalk();
5804
6916
  this.handoffRequestPreparing = true;
5805
6917
  this.setCompact(false, false);
5806
6918
  this.openPanel();
@@ -5851,6 +6963,7 @@ export class WidgetView {
5851
6963
  }
5852
6964
  if (this.currentConfirmation)
5853
6965
  this.resolveConfirmation(false);
6966
+ this.releaseActivePushToTalk();
5854
6967
  this.currentHandoffContextRequest = value;
5855
6968
  }
5856
6969
  this.setCompact(false, false);
@@ -5904,6 +7017,7 @@ export class WidgetView {
5904
7017
  if (this.currentPageAssistanceRequest) {
5905
7018
  this.resolvePageAssistance("decline", false);
5906
7019
  }
7020
+ this.releaseActivePushToTalk();
5907
7021
  this.currentPageAssistanceRequest = value;
5908
7022
  this.setCompact(false, false);
5909
7023
  this.openPanel();
@@ -5994,6 +7108,19 @@ export class WidgetView {
5994
7108
  }
5995
7109
  setPageAssistancePersistentAllowed(value) {
5996
7110
  this.require('[data-role="page-assistance-revoke"]').hidden = !value;
7111
+ this.syncLegalDetailsAvailability();
7112
+ this.syncStartAvailability();
7113
+ }
7114
+ syncLegalDetailsAvailability() {
7115
+ const available = Boolean(this.config.consent?.disclosure ||
7116
+ this.require('[data-role="legal-scopes"]').childElementCount > 0 ||
7117
+ !this.require('[data-role="legal-links"]').hidden ||
7118
+ !this.require('[data-role="page-assistance-revoke"]')
7119
+ .hidden);
7120
+ this.require('[data-role="legal-open"]').hidden =
7121
+ !available;
7122
+ this.require('[data-role="session-legal-open"]').hidden =
7123
+ !available;
5997
7124
  }
5998
7125
  setSupportCompanion(linked) {
5999
7126
  this.supportCompanion = linked;
@@ -6030,19 +7157,24 @@ export class WidgetView {
6030
7157
  }
6031
7158
  }
6032
7159
  setPaused(value) {
7160
+ if (value && this.pushActive)
7161
+ this.setPushActive(false);
6033
7162
  this.paused = value;
6034
7163
  this.assistantState = value ? "paused" : "ready";
6035
7164
  this.setControlLabel("pause", value ? this.messages.resumeActions : this.messages.pauseActions);
6036
7165
  this.setControlIcon("pause", value ? Play : Pause);
6037
7166
  this.require('[data-role="pause"]').setAttribute("aria-pressed", String(value));
6038
- this.setStatus(value ? this.messages.paused : this.messages.ready);
7167
+ this.setStatus(value ? this.messages.paused : this.assistantPresentationMessage());
6039
7168
  this.setActivity("ready");
6040
7169
  if (value)
6041
7170
  this.setAmbientActive(false, true);
7171
+ this.syncHeaderActions();
6042
7172
  }
6043
7173
  setMuted(value) {
6044
7174
  if (value === this.muted)
6045
7175
  return;
7176
+ if (value && this.pushActive)
7177
+ this.setPushActive(false);
6046
7178
  if (value) {
6047
7179
  this.statusBeforeMute = this.status.textContent ?? this.messages.ready;
6048
7180
  }
@@ -6059,6 +7191,8 @@ export class WidgetView {
6059
7191
  this.setTooltip(compactMute, label);
6060
7192
  this.setControlIcon("compact-mute", icon);
6061
7193
  this.require('[data-role="push"]').disabled = value;
7194
+ this.require('[data-role="header-push"]').disabled =
7195
+ value;
6062
7196
  if (this.voiceActive) {
6063
7197
  this.setStatus(value
6064
7198
  ? this.messages.muted
@@ -6069,6 +7203,7 @@ export class WidgetView {
6069
7203
  }
6070
7204
  if (!value)
6071
7205
  this.statusBeforeMute = null;
7206
+ this.syncHeaderActions();
6072
7207
  }
6073
7208
  configureVoiceControls(voiceActive, manualTurn, automaticTurnsAvailable) {
6074
7209
  if (!voiceActive && this.startingVoicePresentation) {
@@ -6098,8 +7233,10 @@ export class WidgetView {
6098
7233
  this.voiceActive = voiceActive;
6099
7234
  if (wasVoiceActive && !voiceActive) {
6100
7235
  this.resetRemotePlayback();
7236
+ this.authorizeVoicePlayback(false);
6101
7237
  }
6102
7238
  else if (!wasVoiceActive && voiceActive) {
7239
+ this.authorizeVoicePlayback(true);
6103
7240
  void this.playRemoteAudio();
6104
7241
  }
6105
7242
  this.modeTransitionPending = null;
@@ -6174,6 +7311,8 @@ export class WidgetView {
6174
7311
  this.syncHeaderActions();
6175
7312
  }
6176
7313
  setModeTransitionPending(mode) {
7314
+ if (mode !== null)
7315
+ this.releaseActivePushToTalk();
6177
7316
  const previousMode = this.modeTransitionPending;
6178
7317
  this.modeTransitionPending = mode;
6179
7318
  if (mode === "voice" && this.active && !this.voiceActive) {
@@ -6289,6 +7428,7 @@ export class WidgetView {
6289
7428
  !this.callbacks.onModeChange) {
6290
7429
  return;
6291
7430
  }
7431
+ this.authorizeVoicePlayback(true);
6292
7432
  this.setModeTransitionPending("voice");
6293
7433
  this.callbacks.onModeChange("voice");
6294
7434
  return;
@@ -6331,22 +7471,29 @@ export class WidgetView {
6331
7471
  !this.callbacks.onModeChange;
6332
7472
  compactVoice.setAttribute("aria-busy", String(compactErrorEndPending || this.modeTransitionPending === "voice"));
6333
7473
  hud.hidden = !this.active || !this.voiceActive || this.compact;
7474
+ const presentationState = this.assistantPresentationState();
6334
7475
  const stateLabel = this.muted
6335
7476
  ? this.messages.muted
6336
- : this.assistantState === "speaking"
6337
- ? this.messages.speaking
6338
- : this.assistantState === "thinking"
6339
- ? this.messages.thinking
6340
- : this.messages.listening;
7477
+ : this.remotePlaybackState === "blocked"
7478
+ ? this.messages.audioPaused
7479
+ : this.manualTurn && !this.pushActive && presentationState === "ready"
7480
+ ? this.messages.usePushToTalk
7481
+ : presentationState === "speaking"
7482
+ ? this.messages.speaking
7483
+ : presentationState === "thinking"
7484
+ ? this.messages.thinking
7485
+ : this.messages.listening;
6341
7486
  state.textContent = stateLabel;
6342
7487
  this.panel.dataset.assistantState = this.muted
6343
7488
  ? "muted"
6344
- : this.assistantState;
7489
+ : presentationState;
7490
+ this.syncPushToTalkControls();
6345
7491
  }
6346
7492
  setManualTurn(value) {
7493
+ value = value && this.manualTurnsSupported;
6347
7494
  this.manualTurn = value;
6348
7495
  const mode = this.require('[data-role="turn-mode"]');
6349
- mode.hidden = !this.voiceActive || value;
7496
+ mode.hidden = !this.voiceActive || value || !this.manualTurnsSupported;
6350
7497
  this.setControlLabel("turn-mode", value ? this.messages.useAutomaticTurns : this.messages.usePushToTalk);
6351
7498
  this.setControlIcon("turn-mode", value ? AudioLines : Hand);
6352
7499
  mode.setAttribute("aria-pressed", String(value));
@@ -6362,28 +7509,119 @@ export class WidgetView {
6362
7509
  this.setControlIcon("automatic-turns", AudioLines);
6363
7510
  if (!value)
6364
7511
  this.setPushActive(false);
7512
+ this.syncPushToTalkControls();
7513
+ if (value &&
7514
+ this.active &&
7515
+ this.voiceActive &&
7516
+ this.assistantPresentationState() === "ready" &&
7517
+ !this.muted) {
7518
+ this.setActivity("ready");
7519
+ this.setStatus(this.messages.usePushToTalk);
7520
+ }
7521
+ this.syncHeaderActions();
6365
7522
  }
6366
7523
  setPushActive(value) {
7524
+ const wasPending = this.pushPending;
7525
+ this.pushPending = false;
7526
+ if (value && !this.pushToTalkAvailable()) {
7527
+ this.pushActive = false;
7528
+ this.syncSessionModeUi();
7529
+ return false;
7530
+ }
6367
7531
  this.pushActive = value;
6368
- const button = this.require('[data-role="push"]');
6369
- this.setControlLabel("push", value ? this.messages.sendVoiceTurn : this.messages.startSpeaking);
6370
- this.setControlIcon("push", value ? Send : Mic);
6371
- button.setAttribute("aria-pressed", String(value));
6372
- if (value) {
7532
+ this.syncPushToTalkControls();
7533
+ if (value && !this.muted) {
6373
7534
  this.assistantState = "listening";
6374
7535
  this.setActivity("listening");
6375
7536
  this.setStatus(this.messages.listening);
6376
7537
  }
7538
+ else if (this.manualTurn &&
7539
+ this.voiceActive &&
7540
+ (this.assistantState === "listening" || wasPending) &&
7541
+ !this.muted) {
7542
+ this.clearPendingCaptions("user");
7543
+ this.setActivity("ready");
7544
+ this.setStatus(this.messages.usePushToTalk);
7545
+ }
7546
+ this.syncSessionModeUi();
7547
+ return true;
6377
7548
  }
6378
- interruptPlayback() {
6379
- this.audio.pause();
6380
- this.setPushActive(false);
6381
- this.assistantState = "ready";
6382
- this.setActivity("ready");
7549
+ setPushPending(value) {
7550
+ if (value && !this.pushToTalkAvailable())
7551
+ return false;
7552
+ this.pushPending = value;
7553
+ this.syncPushToTalkControls();
7554
+ if (value)
7555
+ this.setStatus(this.messages.preparingMicrophone);
7556
+ return true;
7557
+ }
7558
+ pushToTalkAvailable() {
7559
+ return Boolean(this.active &&
7560
+ this.voiceActive &&
7561
+ this.manualTurn &&
7562
+ !this.muted &&
7563
+ !this.paused &&
7564
+ !this.endRequested &&
7565
+ this.stagedLaunchMode === null &&
7566
+ this.modeTransitionPending === null &&
7567
+ this.panelViewTransition === null &&
7568
+ this.currentConfirmation === null &&
7569
+ this.currentVisualRequest === null &&
7570
+ this.currentHandoffContextRequest === null &&
7571
+ this.currentPageAssistanceRequest === null &&
7572
+ !this.handoffRequestPreparing &&
7573
+ this.require('[data-role="legal-overlay"]').hidden &&
7574
+ !this.panel.classList.contains("error-state") &&
7575
+ !this.panel.classList.contains("ending-state"));
7576
+ }
7577
+ releaseActivePushToTalk() {
7578
+ if (!this.pushActive && !this.pushPending)
7579
+ return;
7580
+ this.callbacks.onPushToTalk(false);
7581
+ if (this.pushActive || this.pushPending)
7582
+ this.setPushActive(false);
7583
+ }
7584
+ syncPushToTalkControls() {
7585
+ const label = this.pushPending ? this.messages.cancelVoiceStart : this.pushActive
7586
+ ? this.messages.sendVoiceTurn
7587
+ : this.messages.startSpeaking;
7588
+ const icon = this.pushActive ? Send : Mic;
7589
+ for (const role of ["push", "header-push"]) {
7590
+ const button = this.require(`[data-role="${role}"]`);
7591
+ this.setControlLabel(role, label);
7592
+ this.setControlIcon(role, icon);
7593
+ button.setAttribute("aria-pressed", String(this.pushActive));
7594
+ button.setAttribute("aria-busy", String(this.pushPending));
7595
+ button.disabled = !this.pushToTalkAvailable();
7596
+ }
7597
+ }
7598
+ interruptPlayback(preserveManualInput = false) {
7599
+ if (!this.playbackInterrupted) {
7600
+ this.playbackInterrupted = true;
7601
+ this.audio.autoplay = false;
7602
+ this.pauseRemotePlayback(true);
7603
+ }
7604
+ if (!preserveManualInput)
7605
+ this.setPushActive(false);
7606
+ const listening = preserveManualInput && this.pushActive;
7607
+ this.assistantState = listening ? "listening" : "ready";
7608
+ this.setActivity(listening ? "listening" : "ready");
6383
7609
  this.clearPendingCaptions("assistant");
6384
- this.setStatus(this.messages.ready);
7610
+ this.setStatus(preserveManualInput && this.pushPending
7611
+ ? this.messages.preparingMicrophone
7612
+ : listening ? this.messages.listening : this.assistantPresentationMessage());
6385
7613
  this.setAmbientActive(false);
6386
7614
  }
7615
+ // The controller calls this only for a new admitted visitor turn followed by
7616
+ // fresh response readiness. A generic thinking/speaking update after Stop is
7617
+ // not permission to replay the interrupted answer.
7618
+ resumeInterruptedPlayback() {
7619
+ if (!this.playbackInterrupted || !this.playbackEventIsCurrent())
7620
+ return;
7621
+ this.playbackInterrupted = false;
7622
+ this.audio.autoplay = true;
7623
+ void this.playRemoteAudio();
7624
+ }
6387
7625
  clearErrorPresentation(restoreView) {
6388
7626
  if (!this.panel.classList.contains("error-state"))
6389
7627
  return;
@@ -6402,6 +7640,7 @@ export class WidgetView {
6402
7640
  if (!this.panel.classList.contains("ending-state"))
6403
7641
  return;
6404
7642
  this.panel.classList.remove("ending-state");
7643
+ this.endingPresentationDismissed = false;
6405
7644
  this.panel.removeAttribute("aria-busy");
6406
7645
  const notice = this.require('[data-role="notice"]');
6407
7646
  notice.classList.remove("visible");
@@ -6409,9 +7648,17 @@ export class WidgetView {
6409
7648
  notice.setAttribute("role", "alert");
6410
7649
  notice.setAttribute("aria-live", "assertive");
6411
7650
  this.require('[data-role="notice-icon"]').textContent = "!";
7651
+ this.require('[data-role="ending-dismiss"]').hidden =
7652
+ true;
6412
7653
  }
6413
7654
  showError(message, retryable = false, sessionActive = this.active) {
6414
7655
  this.setActionStateRunning(false);
7656
+ if (this.voiceActive || this.audio.srcObject) {
7657
+ this.pauseRemotePlayback(true);
7658
+ }
7659
+ else {
7660
+ this.resetRemoteAudioEvidence(false);
7661
+ }
6415
7662
  this.clearPendingWelcomeSkeleton();
6416
7663
  this.clearEndingPresentation();
6417
7664
  this.stagedLaunchMode = null;
@@ -6461,6 +7708,10 @@ export class WidgetView {
6461
7708
  ]);
6462
7709
  }
6463
7710
  showEndingDetached(message) {
7711
+ const continuingEndingPresentation = this.panel.classList.contains("ending-state");
7712
+ if (!continuingEndingPresentation) {
7713
+ this.endingPresentationDismissed = false;
7714
+ }
6464
7715
  this.setActionStateRunning(false);
6465
7716
  this.clearPendingWelcomeSkeleton();
6466
7717
  this.resetRemotePlayback();
@@ -6483,7 +7734,9 @@ export class WidgetView {
6483
7734
  this.panel.classList.add("ending-state");
6484
7735
  this.panel.setAttribute("aria-busy", "true");
6485
7736
  this.commitCompact(true, false);
6486
- this.openPanel(false);
7737
+ if (!this.endingPresentationDismissed) {
7738
+ this.openPanel(false);
7739
+ }
6487
7740
  this.conversation.classList.remove("visible");
6488
7741
  this.controls.classList.remove("visible", "error");
6489
7742
  this.confirmation.classList.remove("visible");
@@ -6497,6 +7750,8 @@ export class WidgetView {
6497
7750
  notice.setAttribute("aria-busy", "true");
6498
7751
  this.require('[data-role="notice-icon"]').textContent = "";
6499
7752
  this.require('[data-role="notice-message"]').textContent = progressMessage;
7753
+ this.require('[data-role="ending-dismiss"]').hidden =
7754
+ false;
6500
7755
  this.setComposerEnabled(false);
6501
7756
  this.stopDuration(false);
6502
7757
  this.hideAttribution();
@@ -6508,12 +7763,13 @@ export class WidgetView {
6508
7763
  this.setAmbientActive(false, true);
6509
7764
  }
6510
7765
  showEndRetry(message) {
7766
+ this.endingPresentationDismissed = false;
6511
7767
  this.active = true;
6512
7768
  this.endRequested = false;
6513
7769
  this.showError(message || this.messages.endRetry, false, true);
6514
7770
  this.syncEndControls();
6515
7771
  }
6516
- showResumeStopped() {
7772
+ showResumeStopped(notifyOpenChange = true) {
6517
7773
  this.setActionStateRunning(false);
6518
7774
  this.clearPendingWelcomeSkeleton();
6519
7775
  this.resetRemotePlayback();
@@ -6548,14 +7804,58 @@ export class WidgetView {
6548
7804
  this.stopDuration(true);
6549
7805
  this.hideAttribution();
6550
7806
  this.setActivity("idle");
6551
- this.setStatus(this.messages.ready);
7807
+ this.setStatus(this.assistantPresentationMessage());
6552
7808
  this.intro.hidden = false;
6553
7809
  this.syncLauncherState();
6554
7810
  this.syncHeaderActions();
6555
- if (wasOpen)
7811
+ if (wasOpen && notifyOpenChange)
6556
7812
  this.callbacks.onOpenChange?.(false);
6557
7813
  }
7814
+ showStartRetry(question, message, localQuestionId) {
7815
+ this.initialQuestionStaged = false;
7816
+ this.removeLocalQuestionEcho(localQuestionId);
7817
+ // The controller already rolls back the exact admitted question before
7818
+ // requesting this presentation. Avoid routing this internal close through
7819
+ // the generic user-close callback, which would clear unrelated controller
7820
+ // intent a second time.
7821
+ this.showResumeStopped(false);
7822
+ this.clearIntroTransition();
7823
+ this.introMinimized = false;
7824
+ this.syncIntroMinimizedState();
7825
+ const input = this.require('[data-role="intro-text-input"]');
7826
+ input.value = question.slice(0, INITIAL_QUESTION_MAX_LENGTH);
7827
+ input.setAttribute("aria-invalid", "false");
7828
+ this.syncIntroSendState();
7829
+ this.setStatus(message);
7830
+ if (!input.disabled && !input.hidden)
7831
+ input.focus({ preventScroll: true });
7832
+ }
7833
+ removeLocalQuestionEcho(localQuestionId) {
7834
+ this.captions
7835
+ .querySelectorAll("[data-local-question-id]")
7836
+ .forEach((line) => {
7837
+ if (line.dataset.localQuestionId !== localQuestionId)
7838
+ return;
7839
+ this.cancelCaptionHeightGlide(line);
7840
+ line.remove();
7841
+ });
7842
+ const welcomeGroup = this.require('[data-role="welcome-group"]');
7843
+ if (!this.captions.querySelector('[data-role="empty"]') &&
7844
+ [...this.captions.children].every((child) => child === welcomeGroup)) {
7845
+ const empty = document.createElement("div");
7846
+ empty.className = "empty";
7847
+ empty.dataset.role = "empty";
7848
+ empty.textContent = this.messages.emptyConversation;
7849
+ this.captions.prepend(empty);
7850
+ }
7851
+ }
6558
7852
  showEnded(message) {
7853
+ this.clearCtaOffer();
7854
+ if (this.endingPresentationDismissed) {
7855
+ this.endingPresentationDismissed = false;
7856
+ this.showResumeStopped(false);
7857
+ return;
7858
+ }
6559
7859
  this.setActionStateRunning(false);
6560
7860
  this.clearPendingWelcomeSkeleton();
6561
7861
  this.resetRemotePlayback();
@@ -6628,6 +7928,7 @@ export class WidgetView {
6628
7928
  showLaunchUnavailable(message) {
6629
7929
  this.setActionStateRunning(false);
6630
7930
  this.clearPendingWelcomeSkeleton();
7931
+ const wasOpen = this.panel.classList.contains("open");
6631
7932
  const previousFocus = this.shadow.activeElement;
6632
7933
  const wasStartingVoice = this.startingVoicePresentation;
6633
7934
  this.discardStartingVoicePresentation();
@@ -6639,7 +7940,7 @@ export class WidgetView {
6639
7940
  this.assistantState = "unavailable";
6640
7941
  this.setActivity("error");
6641
7942
  this.modeTransitionPending = null;
6642
- this.panel.classList.remove("feedback-state");
7943
+ this.panel.classList.remove("feedback-state", "open");
6643
7944
  this.clearEndingPresentation();
6644
7945
  this.clearErrorPresentation(false);
6645
7946
  this.setCompact(false, false);
@@ -6663,19 +7964,216 @@ export class WidgetView {
6663
7964
  this.focusFallbackIfUnavailable(previousFocus, [
6664
7965
  '[data-role="availability"]',
6665
7966
  ]);
7967
+ if (wasOpen)
7968
+ this.callbacks.onOpenChange?.(false);
6666
7969
  }
6667
7970
  updateHighlight(element, status) {
7971
+ const targetChanged = element !== this.highlightedElement;
7972
+ if (targetChanged && this.highlightFrame !== null) {
7973
+ cancelAnimationFrame(this.highlightFrame);
7974
+ this.highlightFrame = null;
7975
+ }
6668
7976
  this.highlightedElement = element;
6669
7977
  this.highlight.className = `highlight ${status}`;
6670
- if (!element || !element.isConnected)
7978
+ if (!element || !element.isConnected) {
7979
+ this.clearHighlightTracking();
6671
7980
  return;
7981
+ }
7982
+ this.syncHighlightScrollTargets(element, targetChanged);
6672
7983
  const rect = element.getBoundingClientRect();
6673
- this.highlight.style.left = `${Math.max(0, rect.left - 4)}px`;
6674
- this.highlight.style.top = `${Math.max(0, rect.top - 4)}px`;
6675
- this.highlight.style.width = `${Math.max(8, rect.width + 8)}px`;
6676
- this.highlight.style.height = `${Math.max(8, rect.height + 8)}px`;
7984
+ const visual = window.visualViewport;
7985
+ let viewportLeft = visual?.offsetLeft ?? 0;
7986
+ let viewportTop = visual?.offsetTop ?? 0;
7987
+ let viewportRight = viewportLeft + (visual?.width ?? window.innerWidth);
7988
+ let viewportBottom = viewportTop + (visual?.height ?? window.innerHeight);
7989
+ if (this.highlightIntersectionObserver) {
7990
+ if (!this.highlightIntersectionKnown || !this.highlightIntersectionRect)
7991
+ return;
7992
+ if (this.highlightIntersectionRect.left !== undefined) {
7993
+ viewportLeft = Math.max(viewportLeft, this.highlightIntersectionRect.left);
7994
+ }
7995
+ if (this.highlightIntersectionRect.top !== undefined) {
7996
+ viewportTop = Math.max(viewportTop, this.highlightIntersectionRect.top);
7997
+ }
7998
+ if (this.highlightIntersectionRect.right !== undefined) {
7999
+ viewportRight = Math.min(viewportRight, this.highlightIntersectionRect.right);
8000
+ }
8001
+ if (this.highlightIntersectionRect.bottom !== undefined) {
8002
+ viewportBottom = Math.min(viewportBottom, this.highlightIntersectionRect.bottom);
8003
+ }
8004
+ }
8005
+ else {
8006
+ for (const ancestor of this.highlightScrollTargets) {
8007
+ const style = getComputedStyle(ancestor);
8008
+ const overflowX = style.overflowX || style.overflow;
8009
+ const overflowY = style.overflowY || style.overflow;
8010
+ if (!this.clipsHighlightOverflow(overflowX) &&
8011
+ !this.clipsHighlightOverflow(overflowY)) {
8012
+ continue;
8013
+ }
8014
+ const ancestorRect = this.highlightScrollportRect(ancestor);
8015
+ if (this.clipsHighlightOverflow(overflowX)) {
8016
+ viewportLeft = Math.max(viewportLeft, ancestorRect.left);
8017
+ viewportRight = Math.min(viewportRight, ancestorRect.right);
8018
+ }
8019
+ if (this.clipsHighlightOverflow(overflowY)) {
8020
+ viewportTop = Math.max(viewportTop, ancestorRect.top);
8021
+ viewportBottom = Math.min(viewportBottom, ancestorRect.bottom);
8022
+ }
8023
+ }
8024
+ }
8025
+ if (viewportRight <= viewportLeft || viewportBottom <= viewportTop)
8026
+ return;
8027
+ if (rect.right <= viewportLeft ||
8028
+ rect.bottom <= viewportTop ||
8029
+ rect.left >= viewportRight ||
8030
+ rect.top >= viewportBottom) {
8031
+ return;
8032
+ }
8033
+ const left = Math.max(viewportLeft, rect.left - 4);
8034
+ const top = Math.max(viewportTop, rect.top - 4);
8035
+ const right = Math.min(viewportRight, rect.right + 4);
8036
+ const bottom = Math.min(viewportBottom, rect.bottom + 4);
8037
+ if (right <= left || bottom <= top)
8038
+ return;
8039
+ this.highlight.style.left = `${left}px`;
8040
+ this.highlight.style.top = `${top}px`;
8041
+ this.highlight.style.width = `${right - left}px`;
8042
+ this.highlight.style.height = `${bottom - top}px`;
6677
8043
  this.highlight.classList.add("visible");
6678
8044
  }
8045
+ clipsHighlightOverflow(value) {
8046
+ return /^(?:auto|clip|hidden|overlay|scroll)$/.test(value);
8047
+ }
8048
+ highlightScrollportRect(element) {
8049
+ const rect = element.getBoundingClientRect();
8050
+ if (!(element instanceof HTMLElement))
8051
+ return rect;
8052
+ const scaleX = element.offsetWidth > 0 ? rect.width / element.offsetWidth : 1;
8053
+ const scaleY = element.offsetHeight > 0 ? rect.height / element.offsetHeight : 1;
8054
+ const left = rect.left + element.clientLeft * scaleX;
8055
+ const top = rect.top + element.clientTop * scaleY;
8056
+ return {
8057
+ left,
8058
+ top,
8059
+ right: left + element.clientWidth * scaleX,
8060
+ bottom: top + element.clientHeight * scaleY,
8061
+ };
8062
+ }
8063
+ composedHighlightParent(element) {
8064
+ const assignedSlot = element.assignedSlot;
8065
+ if (assignedSlot)
8066
+ return assignedSlot;
8067
+ if (element.parentElement)
8068
+ return element.parentElement;
8069
+ const root = element.getRootNode();
8070
+ return root instanceof ShadowRoot ? root.host : null;
8071
+ }
8072
+ establishesFixedContainingBlock(element) {
8073
+ const style = getComputedStyle(element);
8074
+ const individualTransform = (property) => {
8075
+ if (!(element instanceof HTMLElement))
8076
+ return style.getPropertyValue(property);
8077
+ const inlineStyle = element.style;
8078
+ return (style.getPropertyValue(property) ||
8079
+ inlineStyle.getPropertyValue(property) ||
8080
+ inlineStyle[property] ||
8081
+ "");
8082
+ };
8083
+ const activeProperty = (value) => Boolean(value) && value !== "none";
8084
+ if (activeProperty(style.transform) ||
8085
+ activeProperty(style.perspective) ||
8086
+ activeProperty(style.filter) ||
8087
+ activeProperty(style.getPropertyValue("backdrop-filter")) ||
8088
+ activeProperty(individualTransform("rotate")) ||
8089
+ activeProperty(individualTransform("scale")) ||
8090
+ activeProperty(individualTransform("translate"))) {
8091
+ return true;
8092
+ }
8093
+ if (/(?:^|\s)(?:content|layout|paint|strict)(?:\s|$)/.test(style.contain) ||
8094
+ style.getPropertyValue("content-visibility") === "auto") {
8095
+ return true;
8096
+ }
8097
+ return style.willChange
8098
+ .split(",")
8099
+ .some((property) => /^(?:backdrop-filter|filter|perspective|transform)$/.test(property.trim()));
8100
+ }
8101
+ highlightPositionEscape(element) {
8102
+ const position = getComputedStyle(element).position || "static";
8103
+ if (position === "fixed")
8104
+ return "fixed";
8105
+ if (position === "absolute")
8106
+ return "absolute";
8107
+ return null;
8108
+ }
8109
+ establishesHighlightContainingBlock(element, escape) {
8110
+ return (this.establishesFixedContainingBlock(element) ||
8111
+ (escape === "absolute" &&
8112
+ (getComputedStyle(element).position || "static") !== "static"));
8113
+ }
8114
+ collectHighlightScrollTargets(target) {
8115
+ const targets = [];
8116
+ let ancestor = target;
8117
+ let escape = this.highlightPositionEscape(target);
8118
+ while (true) {
8119
+ ancestor = this.composedHighlightParent(ancestor);
8120
+ if (!ancestor)
8121
+ break;
8122
+ if (!escape ||
8123
+ this.establishesHighlightContainingBlock(ancestor, escape)) {
8124
+ targets.push(ancestor);
8125
+ escape = null;
8126
+ }
8127
+ escape = this.highlightPositionEscape(ancestor) ?? escape;
8128
+ }
8129
+ return targets;
8130
+ }
8131
+ syncHighlightScrollTargets(target, targetChanged) {
8132
+ const targets = this.collectHighlightScrollTargets(target);
8133
+ if (!targetChanged &&
8134
+ targets.length === this.highlightScrollTargets.length &&
8135
+ targets.every((candidate, index) => candidate === this.highlightScrollTargets[index])) {
8136
+ return;
8137
+ }
8138
+ this.unbindHighlightScrollTargets();
8139
+ for (const ancestor of targets) {
8140
+ ancestor.addEventListener("scroll", this.scheduleHighlightGeometryRefresh, {
8141
+ passive: true,
8142
+ });
8143
+ }
8144
+ this.highlightScrollTargets = targets;
8145
+ if (targetChanged && typeof IntersectionObserver === "function") {
8146
+ this.highlightIntersectionObserver ?? (this.highlightIntersectionObserver = new IntersectionObserver(this.onHighlightIntersection, { threshold: [0, 0.01, 0.25, 0.5, 0.75, 0.99, 1] }));
8147
+ this.highlightIntersectionObserver.disconnect();
8148
+ this.highlightIntersectionKnown = false;
8149
+ this.highlightIntersectionRect = null;
8150
+ this.highlightIntersectionObserver.observe(target);
8151
+ }
8152
+ if (typeof ResizeObserver === "function") {
8153
+ this.highlightResizeObserver ?? (this.highlightResizeObserver = new ResizeObserver(this.scheduleHighlightGeometryRefresh));
8154
+ this.highlightResizeObserver.observe(target);
8155
+ for (const ancestor of targets) {
8156
+ this.highlightResizeObserver.observe(ancestor);
8157
+ }
8158
+ }
8159
+ }
8160
+ unbindHighlightScrollTargets() {
8161
+ for (const target of this.highlightScrollTargets) {
8162
+ target.removeEventListener("scroll", this.scheduleHighlightGeometryRefresh);
8163
+ }
8164
+ this.highlightScrollTargets = [];
8165
+ this.highlightResizeObserver?.disconnect();
8166
+ }
8167
+ clearHighlightTracking() {
8168
+ if (this.highlightFrame !== null)
8169
+ cancelAnimationFrame(this.highlightFrame);
8170
+ this.highlightFrame = null;
8171
+ this.highlightedElement = null;
8172
+ this.unbindHighlightScrollTargets();
8173
+ this.highlightIntersectionObserver?.disconnect();
8174
+ this.highlightIntersectionKnown = false;
8175
+ this.highlightIntersectionRect = null;
8176
+ }
6679
8177
  safetySurfaceVisible() {
6680
8178
  if (!this.panel.classList.contains("open") ||
6681
8179
  document.visibilityState === "hidden") {
@@ -6722,12 +8220,18 @@ export class WidgetView {
6722
8220
  });
6723
8221
  }
6724
8222
  destroy() {
8223
+ this.clearCtaOffer();
8224
+ if (this.destroyed)
8225
+ return;
8226
+ this.destroyed = true;
6725
8227
  window.removeEventListener("resize", this.onResize);
6726
- window.removeEventListener("scroll", this.refreshHighlight);
8228
+ window.removeEventListener("scroll", this.onHighlightViewportGeometryChange);
6727
8229
  window.removeEventListener("scroll", this.onIntroFocusHostScroll);
6728
8230
  window.removeEventListener("touchmove", this.onIntroFocusTouchMove);
6729
8231
  window.visualViewport?.removeEventListener("resize", this.onIntroVisualViewportChange);
8232
+ window.visualViewport?.removeEventListener("resize", this.onHighlightViewportGeometryChange);
6730
8233
  window.visualViewport?.removeEventListener("scroll", this.onIntroVisualViewportChange);
8234
+ window.visualViewport?.removeEventListener("scroll", this.onHighlightViewportGeometryChange);
6731
8235
  document.removeEventListener("pointerdown", this.onDocumentPointerDown, true);
6732
8236
  document.removeEventListener("visibilitychange", this.onEffectVisibilityChange);
6733
8237
  this.reducedMotionQuery?.removeEventListener?.("change", this.onReducedMotionChange);
@@ -6737,6 +8241,15 @@ export class WidgetView {
6737
8241
  this.clearFeedbackExitFade();
6738
8242
  this.cancelPanelDrag();
6739
8243
  this.resetRemotePlayback();
8244
+ this.unbindPlaybackState();
8245
+ if (this.remoteAudioContext && this.remoteAudioContextStateListener) {
8246
+ this.remoteAudioContext.removeEventListener?.("statechange", this.remoteAudioContextStateListener);
8247
+ }
8248
+ this.remoteAudioContextStateListener = null;
8249
+ if (this.remoteAudioContext) {
8250
+ void this.remoteAudioContext.close().catch(() => undefined);
8251
+ }
8252
+ this.remoteAudioContext = null;
6740
8253
  this.stopDuration(false);
6741
8254
  this.clearCompactCaptions();
6742
8255
  this.clearIntroTransition();
@@ -6761,12 +8274,14 @@ export class WidgetView {
6761
8274
  this.panel.removeEventListener("pointerdown", this.onPlaybackActivation, true);
6762
8275
  this.currentPageAssistanceRequest = null;
6763
8276
  this.pageAssistancePresentationSnapshot = null;
8277
+ this.clearHighlightTracking();
8278
+ this.highlightIntersectionObserver = null;
8279
+ this.highlightResizeObserver = null;
6764
8280
  this.dialogFocus.destroy();
6765
8281
  this.host.remove();
6766
8282
  this.currentConfirmation = null;
6767
8283
  this.currentVisualRequest = null;
6768
8284
  this.currentHandoffContextRequest = null;
6769
- this.highlightedElement = null;
6770
8285
  }
6771
8286
  build() {
6772
8287
  const fragment = document.createDocumentFragment();
@@ -6780,6 +8295,7 @@ export class WidgetView {
6780
8295
  <div class="status-card" data-role="availability" role="status" tabindex="-1"></div>
6781
8296
  <div class="status-card" data-role="elsewhere" role="status" tabindex="-1"></div>
6782
8297
  <div class="intro-entry" data-role="intro-entry" data-has-draft="false" aria-busy="false" hidden>
8298
+ <label class="recording-consent" data-role="recording-consent" hidden><input type="checkbox" data-role="recording-consent-input"><span><strong data-role="recording-consent-label"></strong><small data-role="recording-consent-description"></small></span></label>
6783
8299
  <div class="proactive-engagement" data-role="proactive-engagement" hidden>
6784
8300
  <div class="proactive-rail" data-role="proactive-prompts" role="group"></div>
6785
8301
  </div>
@@ -6836,6 +8352,7 @@ export class WidgetView {
6836
8352
  <div class="status-card compact-error-notice" data-role="notice" role="alert" aria-live="assertive">
6837
8353
  <span class="compact-error-notice-icon" data-role="notice-icon" aria-hidden="true">!</span>
6838
8354
  <span class="compact-error-notice-message" data-role="notice-message"></span>
8355
+ <button type="button" class="compact-ending-dismiss" data-role="ending-dismiss" hidden><span class="button-icon" data-icon aria-hidden="true"></span></button>
6839
8356
  </div>
6840
8357
  <span class="voice-card-fx intro-effect intro-effect-glow" aria-hidden="true"></span>
6841
8358
  <span class="voice-card-fx intro-effect intro-effect-dark intro-effect-dark-a" aria-hidden="true"></span>
@@ -6852,6 +8369,7 @@ export class WidgetView {
6852
8369
  <div class="header-actions">
6853
8370
  <span class="duration" data-role="duration" hidden>00:00</span>
6854
8371
  <button type="button" class="end icon-button" data-role="end" data-tooltip hidden><span class="button-icon" data-icon aria-hidden="true"></span></button>
8372
+ <button type="button" class="header-push icon-button" data-role="header-push" data-tooltip aria-pressed="false" hidden><span class="button-icon" data-icon aria-hidden="true"></span></button>
6855
8373
  <button type="button" class="compact-mute icon-button" data-role="compact-mute" data-tooltip hidden><span class="button-icon" data-icon aria-hidden="true"></span></button>
6856
8374
  <button type="button" class="view-toggle icon-button" data-role="view-toggle" data-tooltip aria-controls="oxvo-ai-live-assist-content" hidden><span class="button-icon" data-icon aria-hidden="true"></span></button>
6857
8375
  <button type="button" class="restart icon-button" data-role="restart" data-tooltip hidden><span class="button-icon" data-icon aria-hidden="true"></span></button>
@@ -6864,7 +8382,9 @@ export class WidgetView {
6864
8382
  <p data-role="legal-disclosure"></p>
6865
8383
  <div class="boundary" data-role="boundary"></div>
6866
8384
  <ul data-role="legal-scopes"></ul>
8385
+ <label class="recording-consent" data-role="recording-consent" hidden><input type="checkbox" data-role="recording-consent-input"><span><strong data-role="recording-consent-label"></strong><small data-role="recording-consent-description"></small></span></label>
6867
8386
  <div class="legal-links" data-role="legal-links"><a data-role="legal-privacy" target="_blank" rel="noopener noreferrer"></a><a data-role="legal-terms" target="_blank" rel="noopener noreferrer"></a></div>
8387
+ <button type="button" class="secondary legal-revoke" data-role="page-assistance-revoke" hidden><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
6868
8388
  </section>
6869
8389
  </div>
6870
8390
  <div class="body" id="oxvo-ai-live-assist-content">
@@ -6906,16 +8426,19 @@ export class WidgetView {
6906
8426
  <div class="page-assistance-header">
6907
8427
  <div class="page-assistance-header-copy">
6908
8428
  <h3 id="oxvo-ai-page-assistance-title" data-role="page-assistance-title"></h3>
6909
- <p id="oxvo-ai-page-assistance-action" class="page-assistance-action-copy"><span data-role="page-assistance-action"></span><span class="page-assistance-target" data-role="page-assistance-target"></span></p>
6910
8429
  </div>
6911
- <button type="button" class="legal-close icon-button" data-role="page-assistance-close"><span class="button-icon" data-icon aria-hidden="true"></span></button>
8430
+ <button type="button" class="page-assistance-close icon-button" data-role="page-assistance-close"><span class="button-icon" data-icon aria-hidden="true"></span></button>
6912
8431
  </div>
6913
- <div class="page-assistance-footer" hidden>
6914
- <label class="page-assistance-always" data-role="page-assistance-always-control" hidden>
6915
- <input type="checkbox" data-role="page-assistance-always">
6916
- <span data-role="page-assistance-always-label"></span>
6917
- </label>
6918
- <p id="oxvo-ai-page-assistance-agreement" class="page-assistance-agreement" data-role="page-assistance-agreement"><span data-role="page-assistance-agreement-prefix"></span><a data-role="privacy" target="_blank" rel="noopener noreferrer"></a><span data-role="page-assistance-agreement-connector"></span><a data-role="terms" target="_blank" rel="noopener noreferrer"></a><span data-role="page-assistance-agreement-terminator"></span></p>
8432
+ <div class="page-assistance-content">
8433
+ <p id="oxvo-ai-page-assistance-action" class="page-assistance-action-copy"><span data-role="page-assistance-action"></span>
8434
+ <span class="page-assistance-target" data-role="page-assistance-target"></span></p>
8435
+ <div class="page-assistance-footer" hidden>
8436
+ <label class="page-assistance-always" data-role="page-assistance-always-control" hidden>
8437
+ <input type="checkbox" data-role="page-assistance-always">
8438
+ <span data-role="page-assistance-always-label"></span>
8439
+ </label>
8440
+ <p id="oxvo-ai-page-assistance-agreement" class="page-assistance-agreement" data-role="page-assistance-agreement"><span data-role="page-assistance-agreement-prefix"></span><a data-role="privacy" target="_blank" rel="noopener noreferrer"></a><span data-role="page-assistance-agreement-connector"></span><a data-role="terms" target="_blank" rel="noopener noreferrer"></a><span data-role="page-assistance-agreement-terminator"></span></p>
8441
+ </div>
6919
8442
  </div>
6920
8443
  <div class="page-assistance-actions">
6921
8444
  <button type="button" class="secondary" data-role="page-assistance-decline"></button>
@@ -6951,7 +8474,7 @@ export class WidgetView {
6951
8474
  <button type="button" class="menu-control" data-role="captions" data-tooltip><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
6952
8475
  <button type="button" class="menu-control" data-role="text-only" data-tooltip><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
6953
8476
  <button type="button" class="menu-control" data-role="visual-pause" data-tooltip hidden><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
6954
- <button type="button" class="menu-control" data-role="page-assistance-revoke" data-tooltip hidden><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
8477
+ <button type="button" class="menu-control" data-role="session-legal-open" data-tooltip hidden><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
6955
8478
  <button type="button" class="menu-control" data-role="human" data-tooltip><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
6956
8479
  </div></details>
6957
8480
  <button type="submit" class="send btn-submit off" data-role="send" data-tooltip disabled><i aria-hidden="true"><svg viewBox="0 0 512 512" aria-hidden="true" focusable="false"><path fill="currentColor" d="M473 39.05a24 24 0 0 0-25.5-5.46L47.47 185h-.08a24 24 0 0 0 1 45.16l.41.13l137.3 58.63a16 16 0 0 0 15.54-3.59L422 80a7.07 7.07 0 0 1 10 10L226.66 310.26a16 16 0 0 0-3.59 15.54l58.65 137.38c.06.2.12.38.19.57c3.2 9.27 11.3 15.81 21.09 16.25h1a24.63 24.63 0 0 0 23-15.46L478.39 64.62A24 24 0 0 0 473 39.05"/></svg></i></button>
@@ -6964,13 +8487,17 @@ export class WidgetView {
6964
8487
  </div>
6965
8488
  </div>
6966
8489
  </footer>
6967
- <audio></audio>
8490
+ <audio playsinline aria-hidden="true"></audio>
6968
8491
  `;
6969
8492
  fragment.append(intro, highlight, panel, tooltip);
6970
8493
  return fragment;
6971
8494
  }
6972
8495
  bind() {
6973
8496
  this.panel.addEventListener("pointerdown", this.onPlaybackActivation, true);
8497
+ this.panel.addEventListener("wheel", this.onPanelWheel, { passive: false });
8498
+ this.captions.addEventListener("scroll", this.onCaptionsScroll, {
8499
+ passive: true,
8500
+ });
6974
8501
  this.require('[data-role="end"]').addEventListener("click", () => {
6975
8502
  this.requestEnd();
6976
8503
  });
@@ -6990,6 +8517,7 @@ export class WidgetView {
6990
8517
  }
6991
8518
  this.closePanel();
6992
8519
  });
8520
+ this.require('[data-role="ending-dismiss"]').addEventListener("click", () => this.closePanel());
6993
8521
  this.require('[data-role="view-toggle"]').addEventListener("click", () => {
6994
8522
  if (!this.active ||
6995
8523
  this.currentConfirmation ||
@@ -7034,6 +8562,7 @@ export class WidgetView {
7034
8562
  this.require('[data-role="mode-chat"]').addEventListener("click", () => this.requestSessionMode("text"));
7035
8563
  this.require('[data-role="mode-voice"]').addEventListener("click", () => this.requestSessionMode("voice"));
7036
8564
  this.require('[data-role="legal-open"]').addEventListener("click", () => this.openLegalDetails());
8565
+ this.require('[data-role="session-legal-open"]').addEventListener("click", () => this.openLegalDetails());
7037
8566
  this.require('[data-role="legal-close"]').addEventListener("click", () => this.closeLegalDetails());
7038
8567
  this.require('[data-role="legal-overlay"]').addEventListener("click", (event) => {
7039
8568
  if (event.target === event.currentTarget)
@@ -7057,8 +8586,14 @@ export class WidgetView {
7057
8586
  dragHandle.addEventListener("pointermove", this.onDragMove);
7058
8587
  dragHandle.addEventListener("pointerup", this.onDragEnd);
7059
8588
  dragHandle.addEventListener("pointercancel", this.onDragEnd);
7060
- this.require('[data-role="intro-voice"]').addEventListener("click", () => this.start("voice"));
7061
- this.require('[data-role="intro-compact-voice"]').addEventListener("click", () => this.start("voice"));
8589
+ this.require('[data-role="intro-voice"]').addEventListener("click", () => {
8590
+ this.authorizeVoicePlayback(true);
8591
+ this.start("voice");
8592
+ });
8593
+ this.require('[data-role="intro-compact-voice"]').addEventListener("click", () => {
8594
+ this.authorizeVoicePlayback(true);
8595
+ this.start("voice");
8596
+ });
7062
8597
  this.require('[data-role="intro-minimize"]').addEventListener("click", () => this.setIntroMinimized(true, true));
7063
8598
  this.require('[data-role="intro-expand"]').addEventListener("click", () => this.start("text"));
7064
8599
  const introInput = this.require('[data-role="intro-text-input"]');
@@ -7100,18 +8635,26 @@ export class WidgetView {
7100
8635
  this.submitIntroQuestion();
7101
8636
  });
7102
8637
  this.require('[data-role="mute"]').addEventListener("click", () => {
7103
- this.setMuted(!this.muted);
7104
- this.callbacks.onMute(this.muted);
8638
+ const muted = !this.muted;
8639
+ if (muted)
8640
+ this.releaseActivePushToTalk();
8641
+ this.setMuted(muted);
8642
+ this.callbacks.onMute(muted);
7105
8643
  });
7106
8644
  this.require('[data-role="compact-mute"]').addEventListener("click", () => {
7107
- this.setMuted(!this.muted);
7108
- this.callbacks.onMute(this.muted);
8645
+ const muted = !this.muted;
8646
+ if (muted)
8647
+ this.releaseActivePushToTalk();
8648
+ this.setMuted(muted);
8649
+ this.callbacks.onMute(muted);
7109
8650
  });
7110
8651
  this.require('[data-role="interrupt"]').addEventListener("click", () => {
7111
8652
  this.interruptPlayback();
7112
8653
  this.callbacks.onInterrupt();
7113
8654
  });
7114
8655
  this.require('[data-role="turn-mode"]').addEventListener("click", () => {
8656
+ if (!this.manualTurnsSupported)
8657
+ return;
7115
8658
  const manual = !this.manualTurn;
7116
8659
  if (!manual && !this.automaticTurnsAvailable)
7117
8660
  return;
@@ -7125,11 +8668,25 @@ export class WidgetView {
7125
8668
  this.require('[data-role="push"]').addEventListener("click", () => {
7126
8669
  if (!this.manualTurn)
7127
8670
  return;
7128
- this.callbacks.onPushToTalk(!this.pushActive);
8671
+ const active = !this.pushActive && !this.pushPending;
8672
+ if (active && !this.pushToTalkAvailable())
8673
+ return;
8674
+ this.callbacks.onPushToTalk(active);
8675
+ });
8676
+ this.require('[data-role="header-push"]').addEventListener("click", () => {
8677
+ if (!this.manualTurn)
8678
+ return;
8679
+ const active = !this.pushActive && !this.pushPending;
8680
+ if (active && !this.pushToTalkAvailable())
8681
+ return;
8682
+ this.callbacks.onPushToTalk(active);
7129
8683
  });
7130
8684
  this.require('[data-role="pause"]').addEventListener("click", () => {
7131
- this.setPaused(!this.paused);
7132
- this.callbacks.onPause(this.paused);
8685
+ const paused = !this.paused;
8686
+ if (paused)
8687
+ this.releaseActivePushToTalk();
8688
+ this.setPaused(paused);
8689
+ this.callbacks.onPause(paused);
7133
8690
  });
7134
8691
  this.require('[data-role="captions"]').addEventListener("click", () => {
7135
8692
  this.captionsEnabled = !this.captionsEnabled;
@@ -7140,6 +8697,7 @@ export class WidgetView {
7140
8697
  this.require('[data-role="captions"]').setAttribute("aria-pressed", String(!this.captionsEnabled));
7141
8698
  this.captions.hidden = !this.captionsEnabled;
7142
8699
  this.compactCaptions.hidden = !this.captionsEnabled;
8700
+ this.placeCtaOffer();
7143
8701
  if (!this.captionsEnabled) {
7144
8702
  this.clearPendingCaptions();
7145
8703
  this.clearCompactCaptions();
@@ -7185,8 +8743,8 @@ export class WidgetView {
7185
8743
  this.panel.getAttribute("aria-hidden") === "true") {
7186
8744
  return;
7187
8745
  }
7188
- const value = textInput.value.trim();
7189
- if (!value)
8746
+ const value = this.preserveRawText ? textInput.value : textInput.value.trim();
8747
+ if (!value.trim() || (this.preserveRawText && value.length > 4000))
7190
8748
  return;
7191
8749
  if (!this.callbacks.onText(value)) {
7192
8750
  textInput.focus({ preventScroll: true });
@@ -7288,7 +8846,9 @@ export class WidgetView {
7288
8846
  document.addEventListener("pointerdown", this.onDocumentPointerDown, true);
7289
8847
  document.addEventListener("visibilitychange", this.onEffectVisibilityChange);
7290
8848
  window.addEventListener("resize", this.onResize, { passive: true });
7291
- window.addEventListener("scroll", this.refreshHighlight, { passive: true });
8849
+ window.addEventListener("scroll", this.onHighlightViewportGeometryChange, {
8850
+ passive: true,
8851
+ });
7292
8852
  window.addEventListener("scroll", this.onIntroFocusHostScroll, {
7293
8853
  passive: true,
7294
8854
  });
@@ -7296,7 +8856,9 @@ export class WidgetView {
7296
8856
  passive: true,
7297
8857
  });
7298
8858
  window.visualViewport?.addEventListener("resize", this.onIntroVisualViewportChange, { passive: true });
8859
+ window.visualViewport?.addEventListener("resize", this.onHighlightViewportGeometryChange, { passive: true });
7299
8860
  window.visualViewport?.addEventListener("scroll", this.onIntroVisualViewportChange, { passive: true });
8861
+ window.visualViewport?.addEventListener("scroll", this.onHighlightViewportGeometryChange, { passive: true });
7300
8862
  }
7301
8863
  applyConfig() {
7302
8864
  const appearance = this.config.appearance;
@@ -7331,6 +8893,8 @@ export class WidgetView {
7331
8893
  this.setControlIcon("brand-mark", AudioLines);
7332
8894
  this.applyBrandAvatar();
7333
8895
  this.status.textContent = this.messages.ready;
8896
+ this.status.setAttribute("aria-label", this.messages.ready);
8897
+ this.status.title = this.messages.ready;
7334
8898
  this.duration.setAttribute("aria-label", this.messages.sessionDuration);
7335
8899
  this.require(".more-menu").setAttribute("aria-label", this.messages.sessionControls);
7336
8900
  this.panel.setAttribute("aria-label", entryTitle);
@@ -7386,6 +8950,10 @@ export class WidgetView {
7386
8950
  close.setAttribute("aria-label", this.messages.close);
7387
8951
  this.setTooltip(close, this.messages.close);
7388
8952
  this.setControlIcon("close", X);
8953
+ const endingDismiss = this.require('[data-role="ending-dismiss"]');
8954
+ endingDismiss.setAttribute("aria-label", this.messages.close);
8955
+ this.setTooltip(endingDismiss, this.messages.close);
8956
+ this.setControlIcon("ending-dismiss", X);
7389
8957
  const viewToggle = this.require('[data-role="view-toggle"]');
7390
8958
  viewToggle.setAttribute("aria-label", this.messages.minimize);
7391
8959
  this.setTooltip(viewToggle, this.messages.minimize);
@@ -7476,6 +9044,8 @@ export class WidgetView {
7476
9044
  this.setControlIcon("turn-mode", Hand);
7477
9045
  this.setControlLabel("push", this.messages.startSpeaking);
7478
9046
  this.setControlIcon("push", Mic);
9047
+ this.setControlLabel("header-push", this.messages.startSpeaking);
9048
+ this.setControlIcon("header-push", Mic);
7479
9049
  this.configureVoiceControls(false, false, false);
7480
9050
  this.setControlLabel("pause", this.messages.pauseActions);
7481
9051
  this.setControlIcon("pause", Pause);
@@ -7487,6 +9057,8 @@ export class WidgetView {
7487
9057
  this.setControlIcon("visual-pause", EyeOff);
7488
9058
  this.setControlLabel("page-assistance-revoke", this.messages.pageAssistanceRevoke);
7489
9059
  this.setControlIcon("page-assistance-revoke", ShieldOff);
9060
+ this.setControlLabel("session-legal-open", this.messages.legalDetails);
9061
+ this.setControlIcon("session-legal-open", ShieldCheck);
7490
9062
  this.setControlLabel("human", this.messages.requestHuman);
7491
9063
  this.setControlIcon("human", UserRound);
7492
9064
  this.require('[data-role="support-reply-message"]').textContent =
@@ -7522,6 +9094,7 @@ export class WidgetView {
7522
9094
  this.require('[data-outcome="not_resolved"]').textContent =
7523
9095
  this.messages.notResolved;
7524
9096
  this.renderLegalScopes();
9097
+ this.renderRecordingConsent();
7525
9098
  const privacy = this.require('[data-role="privacy"]');
7526
9099
  if (this.config.consent?.policyUrl)
7527
9100
  privacy.href = this.config.consent.policyUrl;
@@ -7547,10 +9120,7 @@ export class WidgetView {
7547
9120
  this.require('[data-role="page-assistance-agreement"]').hidden = privacy.hidden && terms.hidden;
7548
9121
  this.require('[data-role="page-assistance-agreement-connector"]').hidden = privacy.hidden || terms.hidden;
7549
9122
  this.syncPageAssistanceFooter();
7550
- this.require('[data-role="legal-open"]').hidden =
7551
- !this.config.consent?.disclosure &&
7552
- this.require('[data-role="legal-scopes"]').childElementCount === 0 &&
7553
- legalLinks.hidden;
9123
+ this.syncLegalDetailsAvailability();
7554
9124
  if (this.hasActiveSessionMarker())
7555
9125
  this.clearPanelInlinePosition();
7556
9126
  else
@@ -7588,6 +9158,29 @@ export class WidgetView {
7588
9158
  mark.classList.add("has-avatar");
7589
9159
  mark.append(avatar);
7590
9160
  }
9161
+ recordingConsentOffered() {
9162
+ return this.config.schemaVersion === 3 && this.config.replayRecordingEnabled === true &&
9163
+ this.config.consent?.optionalScopes.includes("session_recording") === true;
9164
+ }
9165
+ setRecordingConsent(allowed) {
9166
+ this.recordingConsent = allowed && this.recordingConsentOffered();
9167
+ for (const input of this.shadow.querySelectorAll('[data-role="recording-consent-input"]')) {
9168
+ input.checked = this.recordingConsent;
9169
+ }
9170
+ }
9171
+ renderRecordingConsent() {
9172
+ for (const row of this.shadow.querySelectorAll('[data-role="recording-consent"]')) {
9173
+ row.hidden = !this.recordingConsentOffered();
9174
+ row.querySelector('[data-role="recording-consent-label"]').textContent = this.messages.recordingConsent;
9175
+ row.querySelector('[data-role="recording-consent-description"]').textContent = this.messages.recordingConsentDescription;
9176
+ const input = row.querySelector('[data-role="recording-consent-input"]');
9177
+ input.checked = this.recordingConsent;
9178
+ input.onchange = () => {
9179
+ this.setRecordingConsent(input.checked);
9180
+ this.callbacks.onRecordingConsent?.(this.recordingConsent);
9181
+ };
9182
+ }
9183
+ }
7591
9184
  renderLegalScopes() {
7592
9185
  const container = this.require('[data-role="legal-scopes"]');
7593
9186
  container.replaceChildren();
@@ -7633,6 +9226,8 @@ export class WidgetView {
7633
9226
  ...(this.config.consent?.optionalScopes ?? []),
7634
9227
  ]);
7635
9228
  const scopes = ["ai_disclosure", "text"];
9229
+ if (this.recordingConsentOffered() && this.recordingConsent)
9230
+ scopes.push("session_recording");
7636
9231
  if (required.has("page_context") &&
7637
9232
  this.config.capabilities?.pageContext === true) {
7638
9233
  scopes.push("page_context");
@@ -7643,6 +9238,7 @@ export class WidgetView {
7643
9238
  return false;
7644
9239
  }
7645
9240
  scopes.push("microphone");
9241
+ this.authorizeVoicePlayback(true);
7646
9242
  }
7647
9243
  this.stagedLaunchMode = mode;
7648
9244
  this.initialQuestionStaged = mode === "text" && Boolean(initialQuestion);
@@ -7653,6 +9249,8 @@ export class WidgetView {
7653
9249
  ? this.callbacks.onStart(mode, scopes, initialQuestion)
7654
9250
  : this.callbacks.onStart(mode, scopes);
7655
9251
  if (!admitted) {
9252
+ if (mode === "voice")
9253
+ this.authorizeVoicePlayback(false);
7656
9254
  this.stagedLaunchMode = null;
7657
9255
  this.initialQuestionStaged = false;
7658
9256
  this.clearPendingWelcomeSkeleton();
@@ -7669,8 +9267,8 @@ export class WidgetView {
7669
9267
  const input = this.require('[data-role="intro-text-input"]');
7670
9268
  if (input.disabled || input.hidden || this.introComposing)
7671
9269
  return false;
7672
- const value = input.value.trim();
7673
- if (!value) {
9270
+ const value = this.preserveRawText ? input.value : input.value.trim();
9271
+ if (!value.trim()) {
7674
9272
  input.setAttribute("aria-invalid", "false");
7675
9273
  this.syncIntroSendState();
7676
9274
  return false;
@@ -7813,7 +9411,7 @@ export class WidgetView {
7813
9411
  !input.disabled &&
7814
9412
  !send.hidden &&
7815
9413
  input.value.trim().length > 0 &&
7816
- input.value.trim().length <= INITIAL_QUESTION_MAX_LENGTH;
9414
+ (this.preserveRawText ? input.value.length : input.value.trim().length) <= INITIAL_QUESTION_MAX_LENGTH;
7817
9415
  entry.dataset.hasDraft = String(canSubmit);
7818
9416
  send.disabled = !canSubmit;
7819
9417
  send.tabIndex = canSubmit ? 0 : -1;
@@ -7952,6 +9550,7 @@ export class WidgetView {
7952
9550
  requestEnd() {
7953
9551
  if (!this.active || this.endRequested)
7954
9552
  return;
9553
+ this.releaseActivePushToTalk();
7955
9554
  this.endRequested = true;
7956
9555
  this.setStatus(this.messages.ending);
7957
9556
  this.setActivity("ending");
@@ -7961,11 +9560,8 @@ export class WidgetView {
7961
9560
  this.require('[data-role="notice-message"]').textContent =
7962
9561
  this.messages.ending;
7963
9562
  notice.setAttribute("aria-busy", "true");
7964
- this.syncHeaderActions();
7965
- }
7966
- else {
7967
- this.syncEndControls();
7968
9563
  }
9564
+ this.syncHeaderActions();
7969
9565
  this.syncPanelDragState();
7970
9566
  this.callbacks.onEnd();
7971
9567
  }
@@ -8546,8 +10142,15 @@ export class WidgetView {
8546
10142
  closePanel() {
8547
10143
  if (!this.panel.classList.contains("open"))
8548
10144
  return;
8549
- if (this.panel.classList.contains("ending-state"))
10145
+ if (this.panel.classList.contains("ending-state")) {
10146
+ this.endingPresentationDismissed = true;
10147
+ this.panel.classList.remove("open");
10148
+ this.removeStoredPanelVisibility();
10149
+ this.syncLauncherState();
10150
+ this.syncHeaderActions();
10151
+ this.callbacks.onOpenChange?.(false);
8550
10152
  return;
10153
+ }
8551
10154
  if (this.active) {
8552
10155
  if (!this.currentConfirmation &&
8553
10156
  !this.currentVisualRequest &&
@@ -8677,26 +10280,33 @@ export class WidgetView {
8677
10280
  this.settleCompactCaptionMotion();
8678
10281
  this.settleExpandedBubbleMotion();
8679
10282
  }
8680
- if (!value && this.compact)
10283
+ if (!value && this.compact) {
8681
10284
  this.settleExpandedBubbleMotion();
10285
+ this.captionsPinnedToBottom = true;
10286
+ }
8682
10287
  this.compact = value;
8683
10288
  if (!value)
8684
10289
  this.panel.classList.remove("compact-text-arrived");
8685
10290
  this.panel.classList.toggle("compact", this.compact);
8686
- if (!value)
8687
- this.scrollCaptionsToBottom();
10291
+ this.placeCtaOffer();
8688
10292
  this.syncSurfaceEffectOwner();
8689
10293
  if (persist && this.active && this.persistentState) {
8690
10294
  this.panelViewInitialized = true;
8691
10295
  try {
8692
- sessionStorage.setItem(PANEL_VIEW_KEY, this.compact ? "compact" : "expanded");
10296
+ sessionStorage.setItem(this.storageKey(PANEL_VIEW_KEY), this.compact ? "compact" : "expanded");
8693
10297
  }
8694
10298
  catch {
8695
10299
  // The current view still works when session storage is unavailable.
8696
10300
  }
8697
10301
  }
8698
10302
  this.syncHeaderActions();
8699
- requestAnimationFrame(() => this.clampPanelPosition());
10303
+ if (!value)
10304
+ this.scrollCaptionsToBottom();
10305
+ requestAnimationFrame(() => {
10306
+ if (!this.compact)
10307
+ this.scrollCaptionsToBottom();
10308
+ this.clampPanelPosition();
10309
+ });
8700
10310
  }
8701
10311
  settleExpandedBubbleMotion() {
8702
10312
  this.captions
@@ -8731,6 +10341,7 @@ export class WidgetView {
8731
10341
  }
8732
10342
  const sourceRect = transitionSnapshot?.rect ?? this.panel.getBoundingClientRect();
8733
10343
  const voicePresentation = this.voiceActive || this.startingVoicePresentation;
10344
+ this.syncPushToTalkControls();
8734
10345
  let targetRect;
8735
10346
  let innerTarget = null;
8736
10347
  let outerClone;
@@ -8964,6 +10575,9 @@ export class WidgetView {
8964
10575
  return clone;
8965
10576
  }
8966
10577
  prepareSessionTransitionClone(clone) {
10578
+ clone
10579
+ .querySelectorAll(".cta-offer, .cta-action-slot")
10580
+ .forEach((node) => node.remove());
8967
10581
  clone.classList.remove("primary-surface-content-fade");
8968
10582
  clone
8969
10583
  .querySelectorAll("details.more-controls")
@@ -9135,11 +10749,14 @@ export class WidgetView {
9135
10749
  }
9136
10750
  });
9137
10751
  }
10752
+ storageKey(key) {
10753
+ return this.storageNamespace ? `${key}_${this.storageNamespace}` : key;
10754
+ }
9138
10755
  readPanelView() {
9139
10756
  if (!this.persistentState)
9140
10757
  return this.initialPanelView;
9141
10758
  try {
9142
- const stored = sessionStorage.getItem(PANEL_VIEW_KEY);
10759
+ const stored = sessionStorage.getItem(this.storageKey(PANEL_VIEW_KEY));
9143
10760
  return stored === "compact" || stored === "expanded" ? stored : null;
9144
10761
  }
9145
10762
  catch {
@@ -9150,7 +10767,7 @@ export class WidgetView {
9150
10767
  if (!this.persistentState)
9151
10768
  return null;
9152
10769
  try {
9153
- const stored = sessionStorage.getItem(PANEL_VISIBILITY_KEY);
10770
+ const stored = sessionStorage.getItem(this.storageKey(PANEL_VISIBILITY_KEY));
9154
10771
  return stored === "open" || stored === "hidden" ? stored : null;
9155
10772
  }
9156
10773
  catch {
@@ -9161,7 +10778,7 @@ export class WidgetView {
9161
10778
  if (!this.persistentState)
9162
10779
  return;
9163
10780
  try {
9164
- sessionStorage.setItem(PANEL_VISIBILITY_KEY, value);
10781
+ sessionStorage.setItem(this.storageKey(PANEL_VISIBILITY_KEY), value);
9165
10782
  }
9166
10783
  catch {
9167
10784
  // Panel visibility remains usable when session storage is unavailable.
@@ -9171,7 +10788,7 @@ export class WidgetView {
9171
10788
  if (!this.persistentState)
9172
10789
  return;
9173
10790
  try {
9174
- sessionStorage.removeItem(PANEL_VISIBILITY_KEY);
10791
+ sessionStorage.removeItem(this.storageKey(PANEL_VISIBILITY_KEY));
9175
10792
  }
9176
10793
  catch {
9177
10794
  // Ignore unavailable session storage.
@@ -9182,8 +10799,8 @@ export class WidgetView {
9182
10799
  if (!this.persistentState)
9183
10800
  return;
9184
10801
  try {
9185
- sessionStorage.removeItem(PANEL_VIEW_KEY);
9186
- sessionStorage.removeItem(PANEL_VISIBILITY_KEY);
10802
+ sessionStorage.removeItem(this.storageKey(PANEL_VIEW_KEY));
10803
+ sessionStorage.removeItem(this.storageKey(PANEL_VISIBILITY_KEY));
9187
10804
  }
9188
10805
  catch {
9189
10806
  // Ignore unavailable session storage.
@@ -9193,6 +10810,7 @@ export class WidgetView {
9193
10810
  this.intro.hidden =
9194
10811
  this.active ||
9195
10812
  this.launcherSuppressed ||
10813
+ this.panel.classList.contains("ending-state") ||
9196
10814
  this.panel.classList.contains("open");
9197
10815
  this.syncProactiveEngagementVisibility();
9198
10816
  this.syncSurfaceEffectOwner();
@@ -9274,7 +10892,7 @@ export class WidgetView {
9274
10892
  let startedAt = Date.now();
9275
10893
  if (resume && this.persistentState) {
9276
10894
  try {
9277
- const stored = Number(sessionStorage.getItem(SESSION_START_KEY));
10895
+ const stored = Number(sessionStorage.getItem(this.storageKey(SESSION_START_KEY)));
9278
10896
  if (Number.isFinite(stored) && stored > 0 && stored <= startedAt) {
9279
10897
  startedAt = stored;
9280
10898
  }
@@ -9290,7 +10908,7 @@ export class WidgetView {
9290
10908
  this.stagedLaunchMode === null);
9291
10909
  if (this.persistentState) {
9292
10910
  try {
9293
- sessionStorage.setItem(SESSION_START_KEY, String(startedAt));
10911
+ sessionStorage.setItem(this.storageKey(SESSION_START_KEY), String(startedAt));
9294
10912
  }
9295
10913
  catch {
9296
10914
  // A timer still works when session storage is unavailable.
@@ -9317,7 +10935,7 @@ export class WidgetView {
9317
10935
  if (!clearStoredStart || !this.persistentState)
9318
10936
  return;
9319
10937
  try {
9320
- sessionStorage.removeItem(SESSION_START_KEY);
10938
+ sessionStorage.removeItem(this.storageKey(SESSION_START_KEY));
9321
10939
  }
9322
10940
  catch {
9323
10941
  // Ignore unavailable session storage.
@@ -9425,6 +11043,7 @@ export class WidgetView {
9425
11043
  this.welcomePresented = false;
9426
11044
  this.pendingWelcomeBubble = null;
9427
11045
  this.captions.replaceChildren();
11046
+ this.captionsPinnedToBottom = true;
9428
11047
  const empty = document.createElement("div");
9429
11048
  empty.className = "empty";
9430
11049
  empty.dataset.role = "empty";
@@ -9454,6 +11073,7 @@ export class WidgetView {
9454
11073
  this.attribution.hidden = true;
9455
11074
  }
9456
11075
  openLegalDetails() {
11076
+ this.releaseActivePushToTalk();
9457
11077
  if (!this.panel.classList.contains("open")) {
9458
11078
  this.legalOpenedPanel = true;
9459
11079
  this.openPanel();
@@ -9466,6 +11086,7 @@ export class WidgetView {
9466
11086
  fallbackFocus: () => this.dialogFallbackFocus(),
9467
11087
  onEscape: () => this.closeLegalDetails(),
9468
11088
  });
11089
+ this.syncHeaderActions();
9469
11090
  }
9470
11091
  closeLegalDetails() {
9471
11092
  const overlay = this.require('[data-role="legal-overlay"]');
@@ -9478,6 +11099,7 @@ export class WidgetView {
9478
11099
  this.closePanel();
9479
11100
  return;
9480
11101
  }
11102
+ this.syncHeaderActions();
9481
11103
  }
9482
11104
  syncAdvancedSessionControlsVisibility() {
9483
11105
  const controls = [
@@ -9527,7 +11149,7 @@ export class WidgetView {
9527
11149
  const text = button.querySelector(".control-label");
9528
11150
  if (text)
9529
11151
  text.textContent = label;
9530
- else
11152
+ else if (!button.querySelector("[data-icon]"))
9531
11153
  button.textContent = label;
9532
11154
  button.setAttribute("aria-label", label);
9533
11155
  button.removeAttribute("title");
@@ -9616,6 +11238,18 @@ export class WidgetView {
9616
11238
  trigger.focus();
9617
11239
  return false;
9618
11240
  }
11241
+ rearmHighlightIntersection() {
11242
+ const observer = this.highlightIntersectionObserver;
11243
+ const target = this.highlightedElement;
11244
+ if (!observer || !target)
11245
+ return;
11246
+ observer.takeRecords();
11247
+ observer.unobserve(target);
11248
+ this.highlightIntersectionKnown = false;
11249
+ this.highlightIntersectionRect = null;
11250
+ this.highlight.classList.remove("visible");
11251
+ observer.observe(target);
11252
+ }
9619
11253
  setPanelPosition(left, top) {
9620
11254
  this.panel.style.insetInlineStart = "auto";
9621
11255
  this.panel.style.insetInlineEnd = "auto";
@@ -9629,7 +11263,7 @@ export class WidgetView {
9629
11263
  if (!this.canDragPanel() || !this.persistentState)
9630
11264
  return;
9631
11265
  try {
9632
- sessionStorage.setItem(PANEL_POSITION_KEY, JSON.stringify({ left: Math.round(left), top: Math.round(top) }));
11266
+ sessionStorage.setItem(this.storageKey(PANEL_POSITION_KEY), JSON.stringify({ left: Math.round(left), top: Math.round(top) }));
9633
11267
  }
9634
11268
  catch {
9635
11269
  // The panel remains draggable when storage is unavailable.
@@ -9639,7 +11273,7 @@ export class WidgetView {
9639
11273
  if (!this.persistentState)
9640
11274
  return false;
9641
11275
  try {
9642
- const startedAt = Number(sessionStorage.getItem(SESSION_START_KEY));
11276
+ const startedAt = Number(sessionStorage.getItem(this.storageKey(SESSION_START_KEY)));
9643
11277
  return (Number.isFinite(startedAt) && startedAt > 0 && startedAt <= Date.now());
9644
11278
  }
9645
11279
  catch {
@@ -9652,8 +11286,8 @@ export class WidgetView {
9652
11286
  if (!this.persistentState)
9653
11287
  return;
9654
11288
  try {
9655
- sessionStorage.removeItem(PANEL_POSITION_KEY);
9656
- sessionStorage.removeItem(LEGACY_PANEL_POSITION_KEY);
11289
+ sessionStorage.removeItem(this.storageKey(PANEL_POSITION_KEY));
11290
+ sessionStorage.removeItem(this.storageKey(LEGACY_PANEL_POSITION_KEY));
9657
11291
  }
9658
11292
  catch {
9659
11293
  // The default anchored position still applies without session storage.
@@ -9676,7 +11310,7 @@ export class WidgetView {
9676
11310
  if (!this.canDragPanel() || !this.persistentState)
9677
11311
  return;
9678
11312
  try {
9679
- const parsed = JSON.parse(sessionStorage.getItem(PANEL_POSITION_KEY) || "null");
11313
+ const parsed = JSON.parse(sessionStorage.getItem(this.storageKey(PANEL_POSITION_KEY)) || "null");
9680
11314
  if (parsed &&
9681
11315
  typeof parsed.left === "number" &&
9682
11316
  Number.isFinite(parsed.left) &&
@@ -9764,6 +11398,14 @@ export class WidgetView {
9764
11398
  !sessionReady ||
9765
11399
  !this.voiceActive ||
9766
11400
  !this.compact;
11401
+ const headerPush = this.require('[data-role="header-push"]');
11402
+ headerPush.hidden =
11403
+ endingState ||
11404
+ errorState ||
11405
+ !sessionReady ||
11406
+ !this.voiceActive ||
11407
+ !this.manualTurn;
11408
+ headerPush.disabled = !this.pushToTalkAvailable();
9767
11409
  const viewToggle = this.require('[data-role="view-toggle"]');
9768
11410
  viewToggle.hidden =
9769
11411
  endingState ||
@@ -9864,7 +11506,7 @@ export class WidgetView {
9864
11506
  this.require('[data-role="restart"]').hidden =
9865
11507
  this.active || this.assistantState !== "ended";
9866
11508
  const close = this.require('[data-role="close"]');
9867
- close.hidden = this.active || errorState || endingState;
11509
+ close.hidden = this.active || errorState;
9868
11510
  close.setAttribute("aria-label", this.messages.close);
9869
11511
  this.setTooltip(close, this.messages.close);
9870
11512
  this.syncPanelDragState();