@memberjunction/realtime-widget 0.0.0 → 5.45.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 (86) hide show
  1. package/README.md +107 -43
  2. package/dist/embed.d.ts +18 -0
  3. package/dist/embed.d.ts.map +1 -0
  4. package/dist/embed.js +33 -0
  5. package/dist/embed.js.map +1 -0
  6. package/dist/index.d.ts +23 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +37 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/loader.d.ts +32 -0
  11. package/dist/loader.d.ts.map +1 -0
  12. package/dist/loader.js +163 -0
  13. package/dist/loader.js.map +1 -0
  14. package/dist/session/visitor-key-cookie.d.ts +20 -0
  15. package/dist/session/visitor-key-cookie.d.ts.map +1 -0
  16. package/dist/session/visitor-key-cookie.js +60 -0
  17. package/dist/session/visitor-key-cookie.js.map +1 -0
  18. package/dist/session/widget-session-client.d.ts +74 -0
  19. package/dist/session/widget-session-client.d.ts.map +1 -0
  20. package/dist/session/widget-session-client.js +147 -0
  21. package/dist/session/widget-session-client.js.map +1 -0
  22. package/dist/transport/mock-widget-transport.d.ts +26 -0
  23. package/dist/transport/mock-widget-transport.d.ts.map +1 -0
  24. package/dist/transport/mock-widget-transport.js +42 -0
  25. package/dist/transport/mock-widget-transport.js.map +1 -0
  26. package/dist/transport/runtime-widget-transport.d.ts +54 -0
  27. package/dist/transport/runtime-widget-transport.d.ts.map +1 -0
  28. package/dist/transport/runtime-widget-transport.js +203 -0
  29. package/dist/transport/runtime-widget-transport.js.map +1 -0
  30. package/dist/transport/widget-transport.d.ts +41 -0
  31. package/dist/transport/widget-transport.d.ts.map +1 -0
  32. package/dist/transport/widget-transport.js +13 -0
  33. package/dist/transport/widget-transport.js.map +1 -0
  34. package/dist/types.d.ts +104 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/types.js +6 -0
  37. package/dist/types.js.map +1 -0
  38. package/dist/ui/browser-capabilities.d.ts +36 -0
  39. package/dist/ui/browser-capabilities.d.ts.map +1 -0
  40. package/dist/ui/browser-capabilities.js +30 -0
  41. package/dist/ui/browser-capabilities.js.map +1 -0
  42. package/dist/ui/support-widget-element.d.ts +149 -0
  43. package/dist/ui/support-widget-element.d.ts.map +1 -0
  44. package/dist/ui/support-widget-element.js +540 -0
  45. package/dist/ui/support-widget-element.js.map +1 -0
  46. package/dist/ui/tokens.d.ts +16 -0
  47. package/dist/ui/tokens.d.ts.map +1 -0
  48. package/dist/ui/tokens.js +135 -0
  49. package/dist/ui/tokens.js.map +1 -0
  50. package/dist/voice/channels/base-widget-channel.d.ts +63 -0
  51. package/dist/voice/channels/base-widget-channel.d.ts.map +1 -0
  52. package/dist/voice/channels/base-widget-channel.js +36 -0
  53. package/dist/voice/channels/base-widget-channel.js.map +1 -0
  54. package/dist/voice/channels/whiteboard-channel.d.ts +38 -0
  55. package/dist/voice/channels/whiteboard-channel.d.ts.map +1 -0
  56. package/dist/voice/channels/whiteboard-channel.js +214 -0
  57. package/dist/voice/channels/whiteboard-channel.js.map +1 -0
  58. package/dist/voice/channels/widget-channel-host.d.ts +68 -0
  59. package/dist/voice/channels/widget-channel-host.d.ts.map +1 -0
  60. package/dist/voice/channels/widget-channel-host.js +111 -0
  61. package/dist/voice/channels/widget-channel-host.js.map +1 -0
  62. package/dist/voice/guest-tool-relay.d.ts +14 -0
  63. package/dist/voice/guest-tool-relay.d.ts.map +1 -0
  64. package/dist/voice/guest-tool-relay.js +28 -0
  65. package/dist/voice/guest-tool-relay.js.map +1 -0
  66. package/dist/voice/guest-voice-mint.d.ts +23 -0
  67. package/dist/voice/guest-voice-mint.d.ts.map +1 -0
  68. package/dist/voice/guest-voice-mint.js +61 -0
  69. package/dist/voice/guest-voice-mint.js.map +1 -0
  70. package/dist/voice/mock-voice-controller.d.ts +22 -0
  71. package/dist/voice/mock-voice-controller.d.ts.map +1 -0
  72. package/dist/voice/mock-voice-controller.js +42 -0
  73. package/dist/voice/mock-voice-controller.js.map +1 -0
  74. package/dist/voice/realtime-voice-controller.d.ts +75 -0
  75. package/dist/voice/realtime-voice-controller.d.ts.map +1 -0
  76. package/dist/voice/realtime-voice-controller.js +182 -0
  77. package/dist/voice/realtime-voice-controller.js.map +1 -0
  78. package/dist/voice/voice-abuse-guard.d.ts +39 -0
  79. package/dist/voice/voice-abuse-guard.d.ts.map +1 -0
  80. package/dist/voice/voice-abuse-guard.js +57 -0
  81. package/dist/voice/voice-abuse-guard.js.map +1 -0
  82. package/dist/voice/voice-controller.d.ts +39 -0
  83. package/dist/voice/voice-controller.d.ts.map +1 -0
  84. package/dist/voice/voice-controller.js +10 -0
  85. package/dist/voice/voice-controller.js.map +1 -0
  86. package/package.json +36 -7
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @fileoverview The transport seam between the widget UI and the agent pathway.
3
+ *
4
+ * The UI element depends only on this interface, so it is unit-testable with a mock
5
+ * and decoupled from the heavy ConversationsRuntime + GraphQL wiring. The real
6
+ * implementation (`RuntimeWidgetTransport`) reuses `ConversationsRuntime` +
7
+ * `@memberjunction/graphql-dataprovider` against MJAPI with the guest token — it does
8
+ * NOT reimplement chat or agent dispatch (anti-drift checklist).
9
+ *
10
+ * @module @memberjunction/realtime-widget
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=widget-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-transport.js","sourceRoot":"","sources":["../../src/transport/widget-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * @fileoverview Shared types for the public web widget bundle.
3
+ * @module @memberjunction/realtime-widget
4
+ */
5
+ /** Modalities a widget instance may expose (mirrors the WidgetInstance.Modality column). */
6
+ export type WidgetModality = 'Text' | 'Voice' | 'Both';
7
+ /**
8
+ * The successful response shape from `POST /widget/session` (see
9
+ * `WidgetSessionService.MintGuestSession` in MJServer). Mirrors `MintGuestSessionResult`.
10
+ */
11
+ export interface WidgetSessionResponse {
12
+ success: boolean;
13
+ token?: string;
14
+ expiresAt?: string;
15
+ widgetId?: string;
16
+ applicationId?: string;
17
+ /** The pinned support agent the widget passes as explicitAgentId for every turn (D5). */
18
+ pinnedAgentId?: string;
19
+ modality?: WidgetModality;
20
+ /** Opaque per-session id; stamped onto Conversation.ExternalID so the Widget Guest RLS filters isolate this guest. */
21
+ sessionId?: string;
22
+ /** Optional hard ceiling (minutes) on a voice session for this widget (server default applies when absent). */
23
+ voiceMaxSessionMinutes?: number;
24
+ /**
25
+ * Returning-visitor memory toggle for this widget (RememberReturningVisitors). When false (default),
26
+ * the widget sets no durable visitor cookie and does no cross-session linking — fully off.
27
+ */
28
+ rememberReturningVisitors?: boolean;
29
+ /**
30
+ * The durable, opaque visitor anchor (RV3). Present only when rememberReturningVisitors is true:
31
+ * either echoed back from the cookie the client presented, or freshly minted on a first visit.
32
+ * The client persists it as a long-lived first-party cookie and stamps it on Conversation.VisitorKey.
33
+ */
34
+ visitorKey?: string;
35
+ /**
36
+ * The visitor's most-recent prior conversation for this VisitorKey within the widget's application
37
+ * (RV2 chain). Present only on a returning visit; the client stamps it on Conversation.LastConversationID.
38
+ */
39
+ lastConversationId?: string;
40
+ /**
41
+ * Resolved polymorphic identity (RV4), present only when a host-identity widget asserted a
42
+ * resolvable identity at mint. The client stamps `(linkedEntityId, linkedRecordId)` on the new
43
+ * conversation so memory injection keys off the resolved record rather than the cookie chain.
44
+ */
45
+ linkedEntityId?: string;
46
+ /** Resolved polymorphic identity record id (RV4); paired with linkedEntityId. */
47
+ linkedRecordId?: string;
48
+ /**
49
+ * MJ interactive channels (by name, e.g. `["Whiteboard"]`) this widget may attach when voice is
50
+ * active (mirrors WidgetInstance.EnabledChannels). Empty/absent (the default) = no channels.
51
+ */
52
+ enabledChannels?: string[];
53
+ error?: string;
54
+ errorCode?: string;
55
+ }
56
+ /** Resolved, validated session a widget instance holds in memory after minting. */
57
+ export interface WidgetSession {
58
+ token: string;
59
+ expiresAtMs: number;
60
+ widgetId: string;
61
+ applicationId: string;
62
+ pinnedAgentId: string;
63
+ modality: WidgetModality;
64
+ /** Opaque per-session id; stamped onto Conversation.ExternalID for per-guest RLS isolation. */
65
+ sessionId: string;
66
+ /** Optional hard ceiling (minutes) on a voice session — the authoritative limit for the voice-abuse guard. */
67
+ voiceMaxSessionMinutes?: number;
68
+ /** Returning-visitor memory enabled for this widget (gates cookie-set + cross-session linking). */
69
+ rememberReturningVisitors: boolean;
70
+ /** Durable visitor anchor when remembering is on (persisted as a cookie, stamped on Conversation.VisitorKey). */
71
+ visitorKey?: string;
72
+ /** The prior conversation this visit chains from (stamped on Conversation.LastConversationID). */
73
+ lastConversationId?: string;
74
+ /** Resolved polymorphic identity entity id (RV4), stamped on Conversation.LinkedEntityID when set. */
75
+ linkedEntityId?: string;
76
+ /** Resolved polymorphic identity record id (RV4), stamped on Conversation.LinkedRecordID when set. */
77
+ linkedRecordId?: string;
78
+ /**
79
+ * MJ interactive channels this widget may attach during a voice session (by name, e.g. `['Whiteboard']`).
80
+ * Resolved to framework-free channel clients via `MJGlobal.ClassFactory`; empty = no channels (default).
81
+ */
82
+ enabledChannels: string[];
83
+ }
84
+ /** Options the host page supplies (via data-attributes or the programmatic API). */
85
+ export interface WidgetMountOptions {
86
+ /** The public widget key (pk_live_…). */
87
+ widgetKey: string;
88
+ /** Base URL of MJAPI (e.g. https://api.yourco.com). */
89
+ apiUrl: string;
90
+ /** Element (or selector) to mount into. When omitted, a floating launcher is appended to <body>. */
91
+ mountTarget?: HTMLElement | string;
92
+ /** Optional UI title shown in the widget header. */
93
+ title?: string;
94
+ /** Optional greeting shown in the empty state. */
95
+ greeting?: string;
96
+ }
97
+ /** A single chat message rendered in the widget transcript. */
98
+ export interface WidgetChatMessage {
99
+ role: 'user' | 'agent' | 'system';
100
+ text: string;
101
+ /** Epoch ms; used for ordering + display. */
102
+ timestampMs: number;
103
+ }
104
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
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8GAA8G;IAC9G,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mGAAmG;IACnG,yBAAyB,EAAE,OAAO,CAAC;IACnC,iHAAiH;IACjH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kGAAkG;IAClG,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sGAAsG;IACtG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sGAAsG;IACtG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IAC/B,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,oGAAoG;IACpG,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IACnC,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;CACvB"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Shared types for the public web widget bundle.
3
+ * @module @memberjunction/realtime-widget
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @fileoverview Browser capability detection for graceful degradation (W6).
3
+ *
4
+ * Voice on a public widget needs microphone capture, which the browser exposes ONLY
5
+ * through `navigator.mediaDevices.getUserMedia` AND ONLY in a secure context
6
+ * (`https:` or `localhost`). On an insecure origin, an old browser, or a context that
7
+ * has stripped `mediaDevices`, the mic affordance must be hidden so the visitor
8
+ * silently falls back to text rather than clicking a button that throws.
9
+ *
10
+ * The probe takes the relevant globals as a minimal structural surface so it stays a
11
+ * pure function — unit-testable without a real browser and without leaking the DOM's
12
+ * own ambient types into the call sites.
13
+ *
14
+ * @module @memberjunction/realtime-widget
15
+ */
16
+ /** The minimal slice of `navigator` the voice capability probe inspects. */
17
+ export interface VoiceCapabilityNavigator {
18
+ /** Present (with `getUserMedia`) only when the browser supports media capture. */
19
+ mediaDevices?: {
20
+ getUserMedia?: unknown;
21
+ };
22
+ }
23
+ /** The minimal slice of `window` the probe inspects (secure-context flag). */
24
+ export interface VoiceCapabilityWindow {
25
+ /** `true` on https / localhost; `false` (or absent) on insecure origins. */
26
+ isSecureContext?: boolean;
27
+ }
28
+ /**
29
+ * Returns `true` when the current browser context can capture microphone audio:
30
+ * a secure context AND a callable `navigator.mediaDevices.getUserMedia`.
31
+ *
32
+ * @param nav The navigator-like object to probe (defaults to the ambient `navigator`).
33
+ * @param win The window-like object to probe (defaults to the ambient `window`).
34
+ */
35
+ export declare function VoiceIsSupported(nav?: VoiceCapabilityNavigator | undefined, win?: VoiceCapabilityWindow | undefined): boolean;
36
+ //# sourceMappingURL=browser-capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-capabilities.d.ts","sourceRoot":"","sources":["../../src/ui/browser-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,wBAAwB;IACrC,kFAAkF;IAClF,YAAY,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7C;AAED,8EAA8E;AAC9E,MAAM,WAAW,qBAAqB;IAClC,4EAA4E;IAC5E,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC5B,GAAG,GAAE,wBAAwB,GAAG,SAAoE,EACpG,GAAG,GAAE,qBAAqB,GAAG,SAA8D,GAC5F,OAAO,CAIT"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Browser capability detection for graceful degradation (W6).
3
+ *
4
+ * Voice on a public widget needs microphone capture, which the browser exposes ONLY
5
+ * through `navigator.mediaDevices.getUserMedia` AND ONLY in a secure context
6
+ * (`https:` or `localhost`). On an insecure origin, an old browser, or a context that
7
+ * has stripped `mediaDevices`, the mic affordance must be hidden so the visitor
8
+ * silently falls back to text rather than clicking a button that throws.
9
+ *
10
+ * The probe takes the relevant globals as a minimal structural surface so it stays a
11
+ * pure function — unit-testable without a real browser and without leaking the DOM's
12
+ * own ambient types into the call sites.
13
+ *
14
+ * @module @memberjunction/realtime-widget
15
+ */
16
+ /**
17
+ * Returns `true` when the current browser context can capture microphone audio:
18
+ * a secure context AND a callable `navigator.mediaDevices.getUserMedia`.
19
+ *
20
+ * @param nav The navigator-like object to probe (defaults to the ambient `navigator`).
21
+ * @param win The window-like object to probe (defaults to the ambient `window`).
22
+ */
23
+ export function VoiceIsSupported(nav = typeof navigator !== 'undefined' ? navigator : undefined, win = typeof window !== 'undefined' ? window : undefined) {
24
+ if (!nav || !win)
25
+ return false;
26
+ if (win.isSecureContext !== true)
27
+ return false;
28
+ return typeof nav.mediaDevices?.getUserMedia === 'function';
29
+ }
30
+ //# sourceMappingURL=browser-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-capabilities.js","sourceRoot":"","sources":["../../src/ui/browser-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAA4C,OAAO,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EACpG,MAAyC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;IAE3F,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IAC/B,IAAI,GAAG,CAAC,eAAe,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC/C,OAAO,OAAO,GAAG,CAAC,YAAY,EAAE,YAAY,KAAK,UAAU,CAAC;AAChE,CAAC"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * @fileoverview `<mj-support-widget>` — a self-contained shadow-DOM custom element
3
+ * rendering the text support surface. Host CSS cannot bleed in or out (closed style
4
+ * scope + `all: initial` on :host). It owns NO chat logic — it delegates turns to an
5
+ * injected `IWidgetTransport` (which reuses ConversationsRuntime). Voice is layered on
6
+ * in W4 via the same element.
7
+ *
8
+ * @module @memberjunction/realtime-widget
9
+ */
10
+ import type { WidgetSession } from '../types.js';
11
+ import type { IWidgetTransport } from '../transport/widget-transport.js';
12
+ import type { IVoiceController } from '../voice/voice-controller.js';
13
+ /** The registered custom-element tag name. */
14
+ export declare const WIDGET_TAG_NAME = "mj-support-widget";
15
+ /** A pending retry action surfaced by the connection-lost banner. */
16
+ type RetryAction = () => void;
17
+ /** The droppable support widget element. */
18
+ export declare class SupportWidgetElement extends HTMLElement {
19
+ private readonly root;
20
+ private transport;
21
+ private voiceController;
22
+ private session;
23
+ private readonly messages;
24
+ private sending;
25
+ private voiceActive;
26
+ private headerTitle;
27
+ private greeting;
28
+ /** The pending retry the connection-lost banner invokes; null when no banner is shown. */
29
+ private pendingRetry;
30
+ private forgetHandler;
31
+ private forgetting;
32
+ /** Capability probe for the voice/mic affordance (overridable for tests). */
33
+ private voiceSupportedProbe;
34
+ /** Bound key handler for the open panel's focus trap (added/removed on open/close). */
35
+ private readonly trapHandler;
36
+ constructor();
37
+ connectedCallback(): void;
38
+ /** Sets the UI title + greeting (called by the loader before mount). */
39
+ Configure(options: {
40
+ title?: string;
41
+ greeting?: string;
42
+ }): void;
43
+ /** Injects the minted session (drives modality/agent pinning). */
44
+ SetSession(session: WidgetSession): void;
45
+ /** Injects the transport the element sends turns through. */
46
+ SetTransport(transport: IWidgetTransport): void;
47
+ /**
48
+ * Wires the RV5 "forget me" action. The loader supplies a handler that archives the visitor's
49
+ * server-side memory and clears the durable cookie. When set (and the widget remembers returning
50
+ * visitors), a privacy notice + "Forget me" control render below the composer.
51
+ */
52
+ SetForgetHandler(handler: () => Promise<void>): void;
53
+ /** Injects the voice controller (enables the mic button when modality allows voice). */
54
+ SetVoiceController(controller: IVoiceController): void;
55
+ /** Overrides the voice capability probe (used by tests to simulate unsupported browsers). */
56
+ SetVoiceSupportedProbe(probe: () => boolean): void;
57
+ /** Opens the chat panel, traps focus inside it, and focuses the composer. */
58
+ Open(): void;
59
+ /** Closes the chat panel, releases the focus trap, and returns focus to the launcher. */
60
+ Close(): void;
61
+ private render;
62
+ private buildLauncher;
63
+ private buildPanel;
64
+ /**
65
+ * RV5 visitor-facing privacy notice + "Forget me" control. Rendered only when this widget remembers
66
+ * returning visitors AND a forget handler is wired — otherwise returns null (no notice, no control),
67
+ * keeping the default (memory-off) widget unchanged.
68
+ */
69
+ private buildMemoryNotice;
70
+ /** Invokes the wired forget handler, then surfaces a confirmation as a system line. */
71
+ private onForgetClicked;
72
+ /** The connection-lost banner (hidden until a send / token refresh fails). */
73
+ private buildBanner;
74
+ private buildHeader;
75
+ private buildTranscriptContainer;
76
+ /**
77
+ * The interactive-channel demonstration surface (Phase 2): a titled stage an MJ channel (e.g. the
78
+ * Whiteboard) renders into while voice is active. Hidden until a channel's first tool call reveals it
79
+ * via {@link RevealChannelSurface}; a widget with no enabled channels never shows it.
80
+ */
81
+ private buildDemonstrationSurface;
82
+ /**
83
+ * Reveals the demonstration surface for an interactive channel and returns the inner host element the
84
+ * channel renders into. Called (via the voice callbacks) the first time the agent engages a channel.
85
+ */
86
+ RevealChannelSurface(_channelName: string, title: string): HTMLElement;
87
+ /** Hides + clears the demonstration surface (on voice end). */
88
+ private hideChannelSurface;
89
+ private buildProgress;
90
+ private buildComposer;
91
+ private renderTranscript;
92
+ private onComposerKeydown;
93
+ /** Keeps Tab focus cycling within the open panel; Esc still closes. */
94
+ private onPanelKeydown;
95
+ /** The focusable controls inside the panel, in DOM order, excluding hidden subtrees. */
96
+ private focusableElements;
97
+ /** True when the element (or an ancestor up to the panel) carries the `hidden` attribute. */
98
+ private isInHiddenSubtree;
99
+ /** The currently-focused element, resolved through the shadow root. */
100
+ private activeWithinPanel;
101
+ /** Reads the composer, appends the user turn, dispatches it, renders the reply. */
102
+ private sendCurrent;
103
+ /** Sends one turn through the transport and renders progress + the reply. */
104
+ private dispatchTurn;
105
+ private appendMessage;
106
+ private showProgress;
107
+ private hideProgress;
108
+ private setSending;
109
+ /**
110
+ * Voice is offered only when a controller is wired, the instance enables Voice/Both,
111
+ * AND the browser can actually capture the mic (secure context + getUserMedia). On an
112
+ * insecure origin or an unsupported browser the mic affordance is hidden and the
113
+ * visitor falls back to text (graceful degradation, W6).
114
+ */
115
+ private voiceEnabled;
116
+ private buildVoiceButton;
117
+ /** Starts or stops a voice session via the injected controller. */
118
+ private toggleVoice;
119
+ private onVoiceState;
120
+ private onVoiceEnded;
121
+ private refreshVoiceButton;
122
+ /** Surfaces a system/notification line in the transcript (used by the notification adapter). */
123
+ ShowSystemMessage(text: string): void;
124
+ /**
125
+ * Shows the connection-lost banner with a retry affordance. Used when a send fails or
126
+ * a token refresh fails (graceful degradation, W6). Invoking the banner's Retry button
127
+ * (or {@link RetryConnection}) runs the supplied action and clears the banner on success.
128
+ *
129
+ * @param message The user-facing reason shown in the banner.
130
+ * @param retry The action to run when the visitor clicks Retry.
131
+ */
132
+ ShowConnectionError(message: string, retry: RetryAction): void;
133
+ /** Programmatically triggers the pending retry (same effect as clicking Retry). */
134
+ RetryConnection(): void;
135
+ /** Hides the connection-lost banner and drops the pending retry. */
136
+ private clearConnectionError;
137
+ /** Runs the pending retry (if any) and hides the banner; the retry re-shows it on a repeat failure. */
138
+ private onRetryClicked;
139
+ /** Exposes the shadow root for tests + integration code. */
140
+ get ShadowRootRef(): ShadowRoot;
141
+ private query;
142
+ private panel;
143
+ private launcher;
144
+ private input;
145
+ }
146
+ /** Registers the custom element once (idempotent). */
147
+ export declare function defineSupportWidgetElement(): void;
148
+ export {};
149
+ //# sourceMappingURL=support-widget-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"support-widget-element.d.ts","sourceRoot":"","sources":["../../src/ui/support-widget-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAqB,aAAa,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,8BAA8B,CAAC;AAIvF,8CAA8C;AAC9C,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAEnD,qEAAqE;AACrE,KAAK,WAAW,GAAG,MAAM,IAAI,CAAC;AAE9B,4CAA4C;AAC5C,qBAAa,oBAAqB,SAAQ,WAAW;IACjD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,eAAe,CAAiC;IACxD,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;IACpD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAoC;IACpD,0FAA0F;IAC1F,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,aAAa,CAAsC;IAC3D,OAAO,CAAC,UAAU,CAAS;IAC3B,6EAA6E;IAC7E,OAAO,CAAC,mBAAmB,CAA2C;IACtE,uFAAuF;IACvF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsD;;IAO3E,iBAAiB,IAAI,IAAI;IAIhC,wEAAwE;IACjE,SAAS,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