@trillet-ai/web-sdk 1.9.1 → 1.10.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.
- package/README.md +2 -0
- package/dist/{chunk-3MH6DJZ6.js → chunk-CVTVHUNZ.js} +12 -5
- package/dist/chunk-CVTVHUNZ.js.map +1 -0
- package/dist/{chunk-FSJ42TKR.js → chunk-IASKK2IK.js} +155 -23
- package/dist/chunk-IASKK2IK.js.map +1 -0
- package/dist/index.d.ts +34 -1
- package/dist/index.js +2 -2
- package/dist/server.d.ts +5 -1
- package/dist/server.js +1 -1
- package/dist/widget/index.d.ts +194 -37
- package/dist/widget/index.js +1526 -644
- package/dist/widget/index.js.map +1 -1
- package/dist/widget.umd.js +492 -361
- package/dist/widget.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3MH6DJZ6.js.map +0 -1
- package/dist/chunk-FSJ42TKR.js.map +0 -1
package/dist/widget/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/widget/config.ts","../../src/widget/styles.ts","../../src/widget/recaptcha.ts","../../src/widget/TrilletWidgetElement.ts","../../src/widget/register.ts","../../src/widget/react.tsx","../../src/widget/index.ts"],"sourcesContent":["// Widget configuration: the attribute/prop surface (ElevenLabs-modeled) and the\n// parsing helpers that turn HTML attributes into a typed config object. This file\n// is framework-free and shared by the custom element and the React wrapper.\n\n// OUT OF SCOPE (TRI-399): default branding is BLANK / unbranded (spec §6.4).\n// Trillet's own brand values are recorded here for a FUTURE partner \"show Trillet\n// branding\" toggle only — they MUST NOT render by default:\n// logo https://www.trillet.ai/trillet-icon.png · color #1060ff · name \"Trillet\"\n\n// Internal, resolved variant. Kept as the historical two-value vocabulary; the\n// convai `tiny|compact|full` inputs are mapped down onto it (see resolveVariant).\nexport type WidgetVariant = 'compact' | 'expanded';\n// Accepted variant *inputs* — both our original vocabulary and convai's.\nexport type WidgetVariantInput = WidgetVariant | 'tiny' | 'full';\n// `both` = one widget offering BOTH modalities (convai multimodal); the end user\n// switches voice <-> text mid-session. `voice`/`text` stay single-modality.\nexport type WidgetMode = 'voice' | 'text' | 'both';\nexport type WidgetPlacement =\n | 'top-left'\n | 'top'\n | 'top-right'\n | 'bottom-left'\n | 'bottom'\n | 'bottom-right';\n\n// convai-compatible orb gradient defaults.\nexport const DEFAULT_ORB_COLOR_1 = '#2792dc';\nexport const DEFAULT_ORB_COLOR_2 = '#9ce6e6';\n\nexport interface WidgetBrand {\n logo?: string;\n primaryColor?: string;\n name?: string;\n}\n\n/**\n * Resolved, typed widget configuration. The custom element builds this from HTML\n * attributes; the React wrapper builds it from props.\n */\nexport interface WidgetConfig {\n // Required\n agentId: string;\n\n // Attribute-derived credentials only (overall priority:\n // signedUrlEndpoint/getRoomDetails > roomDetails > workspaceId). The function and\n // object forms can't come from HTML attributes, so getRoomDetails/roomDetails live\n // as properties on the element instance, not in this config.\n signedUrlEndpoint?: string;\n workspaceId?: string;\n\n // Header identity overrides. Each takes precedence over the corresponding\n // backend-provided `display.*` value (which arrives on `connected`). Being static\n // config, they let the header title render immediately (pre-call).\n agentName?: string;\n callFlowName?: string;\n workspaceName?: string;\n\n // Appearance\n avatar?: string;\n /** Legacy single accent/orb color; alias of orbColor1. */\n orbColor?: string;\n /** Gradient orb color 1 (convai `avatar-orb-color-1`). */\n orbColor1?: string;\n /** Gradient orb color 2 (convai `avatar-orb-color-2`). */\n orbColor2?: string;\n variant: WidgetVariant;\n placement: WidgetPlacement;\n dismissible: boolean;\n\n // Copy / text overrides\n actionText?: string;\n startCallText: string;\n endCallText: string;\n messageText: string;\n switchToTextText: string;\n switchToVoiceText: string;\n listeningText: string;\n speakingText: string;\n expandText: string;\n collapseText: string;\n recaptchaText: string;\n\n // Behavior\n mode: WidgetMode;\n variables?: Record<string, unknown>;\n maxCallDuration?: number; // seconds\n /**\n * Optional Google reCAPTCHA v2 site key. When set, the widget renders a checkbox the\n * visitor solves once per session before the first conversation starts.\n *\n * BYO and client-only: the solved token is never sent to Trillet and never verified,\n * so this is UI friction, not bot protection. See ./recaptcha.ts. For a real gate,\n * use the core SDK's `onBeforeCall` hook and verify on your own backend.\n */\n recaptchaSiteKey?: string;\n /** convai `disable-banner` — accepted no-op (we're blank by default). */\n disableBanner: boolean;\n\n // Customer branding (default BLANK)\n brand: WidgetBrand;\n}\n\nexport const DEFAULT_COPY = {\n startCallText: 'Start a call',\n endCallText: 'End call',\n messageText: 'Message',\n switchToTextText: 'Switch to text mode',\n switchToVoiceText: 'Switch to voice mode',\n listeningText: 'Listening…',\n speakingText: 'Speaking…',\n expandText: 'Expand',\n collapseText: 'Collapse',\n recaptchaText: 'Verify you are human to start',\n} as const;\n\n/** The full list of observed HTML attributes (kebab-case). */\nexport const OBSERVED_ATTRIBUTES = [\n 'agent-id',\n 'signed-url-endpoint',\n 'workspace-id',\n 'agent-name',\n 'call-flow-name',\n 'workspace-name',\n 'avatar',\n 'avatar-image-url', // convai alias -> avatar\n 'orb-color',\n 'avatar-orb-color-1',\n 'avatar-orb-color-2',\n 'variant',\n 'placement',\n 'dismissible',\n 'action-text',\n 'start-call-text',\n 'end-call-text',\n 'message-text',\n 'switch-to-text-text',\n 'switch-to-voice-text',\n 'listening-text',\n 'speaking-text',\n 'expand-text',\n 'collapse-text',\n 'recaptcha-text',\n 'mode',\n 'variables',\n 'dynamic-variables', // convai alias -> variables\n 'max-call-duration',\n 'recaptcha-site-key',\n 'disable-banner', // convai no-op\n 'brand-logo',\n 'brand-color',\n 'brand-name',\n] as const;\n\nconst PLACEMENTS: readonly WidgetPlacement[] = [\n 'top-left',\n 'top',\n 'top-right',\n 'bottom-left',\n 'bottom',\n 'bottom-right',\n];\n\nfunction parseBoolAttr(value: string | null): boolean {\n // Presence-style boolean: dismissible | dismissible=\"\" | dismissible=\"true\" => true;\n // dismissible=\"false\" => false; absent => false.\n if (value === null) return false;\n return value !== 'false';\n}\n\nfunction parseJsonAttr(value: string | null): Record<string, unknown> | undefined {\n if (!value) return undefined;\n try {\n const parsed = JSON.parse(value);\n return parsed && typeof parsed === 'object' ? (parsed as Record<string, unknown>) : undefined;\n } catch {\n console.warn('[trillet-widget] Failed to parse JSON attribute:', value);\n return undefined;\n }\n}\n\nfunction parseNumberAttr(value: string | null): number | undefined {\n if (!value) return undefined;\n const n = Number(value);\n return Number.isFinite(n) ? n : undefined;\n}\n\n/** Map any accepted variant vocabulary (convai `tiny|compact|full` + ours) onto the\n * internal two-value variant. `tiny`->compact (launcher-focused), `full`->expanded. */\nexport function resolveVariant(raw: string | null): WidgetVariant {\n switch (raw) {\n case 'expanded':\n case 'full':\n return 'expanded';\n case 'tiny':\n case 'compact':\n return 'compact';\n default:\n return 'compact';\n }\n}\n\n/**\n * Build a {@link WidgetConfig} from a custom element's attributes. Pure function of\n * the element's attribute map — no side effects.\n */\nexport function configFromElement(el: HTMLElement): WidgetConfig {\n const get = (name: string): string | null => el.getAttribute(name);\n\n const variant = resolveVariant(get('variant'));\n\n const modeRaw = get('mode');\n const mode: WidgetMode = modeRaw === 'text' ? 'text' : modeRaw === 'both' ? 'both' : 'voice';\n\n const placementRaw = get('placement');\n const placement: WidgetPlacement = PLACEMENTS.includes(placementRaw as WidgetPlacement)\n ? (placementRaw as WidgetPlacement)\n : 'bottom-right';\n\n // Start/end labels are mode-aware: a text session is a chat, not a \"call\". These are\n // still overridable via the start-call-text / end-call-text attributes.\n const isText = mode === 'text';\n const startDefault = isText ? 'Start chat' : DEFAULT_COPY.startCallText;\n const endDefault = isText ? 'End chat' : DEFAULT_COPY.endCallText;\n\n const brand: WidgetBrand = {};\n const brandLogo = get('brand-logo');\n const brandColor = get('brand-color');\n const brandName = get('brand-name');\n if (brandLogo) brand.logo = brandLogo;\n if (brandColor) brand.primaryColor = brandColor;\n if (brandName) brand.name = brandName;\n\n const orbColor = get('orb-color') || undefined;\n const orbColor1 = get('avatar-orb-color-1') || orbColor || undefined;\n const orbColor2 = get('avatar-orb-color-2') || undefined;\n\n return {\n agentId: get('agent-id') || '',\n signedUrlEndpoint: get('signed-url-endpoint') || undefined,\n workspaceId: get('workspace-id') || undefined,\n // Header identity overrides — empty string/absent => treated as \"not set\".\n agentName: get('agent-name') || undefined,\n callFlowName: get('call-flow-name') || undefined,\n workspaceName: get('workspace-name') || undefined,\n // convai `avatar-image-url` is an alias of our `avatar`.\n avatar: get('avatar') || get('avatar-image-url') || undefined,\n orbColor,\n orbColor1,\n orbColor2,\n variant,\n placement,\n dismissible: parseBoolAttr(get('dismissible')),\n actionText: get('action-text') || undefined,\n startCallText: get('start-call-text') || startDefault,\n endCallText: get('end-call-text') || endDefault,\n messageText: get('message-text') || DEFAULT_COPY.messageText,\n switchToTextText: get('switch-to-text-text') || DEFAULT_COPY.switchToTextText,\n switchToVoiceText: get('switch-to-voice-text') || DEFAULT_COPY.switchToVoiceText,\n listeningText: get('listening-text') || DEFAULT_COPY.listeningText,\n speakingText: get('speaking-text') || DEFAULT_COPY.speakingText,\n expandText: get('expand-text') || DEFAULT_COPY.expandText,\n collapseText: get('collapse-text') || DEFAULT_COPY.collapseText,\n recaptchaText: get('recaptcha-text') || DEFAULT_COPY.recaptchaText,\n mode,\n // convai `dynamic-variables` is an alias of our `variables`.\n variables: parseJsonAttr(get('variables') || get('dynamic-variables')),\n maxCallDuration: parseNumberAttr(get('max-call-duration')),\n recaptchaSiteKey: get('recaptcha-site-key') || undefined,\n disableBanner: parseBoolAttr(get('disable-banner')),\n brand,\n };\n}\n","// Shadow-DOM stylesheet for the widget. Kept as a single string injected into the\n// shadow root so styles are fully isolated from (and cannot bleed into) the host\n// page. All visual tokens are driven by CSS custom properties so attributes like\n// `orb-color` / `brand-color` can override them at runtime.\n\nexport const WIDGET_STYLES = /* css */ `\n:host {\n /* Positioning: default bottom-right. The host can override by setting\n position-related CSS on the trillet-widget element directly, or via the\n placement attribute (see :host([placement=...]) rules below). */\n position: fixed;\n right: 24px;\n bottom: 24px;\n z-index: 2147483000;\n\n /* Theming tokens (overridden at runtime via setProperty). */\n --trillet-accent: #2792dc;\n --trillet-orb-1: #2792dc;\n --trillet-orb-2: #9ce6e6;\n --trillet-surface: #ffffff;\n --trillet-on-surface: #0b0b0f;\n --trillet-muted: #6b7280;\n --trillet-border: rgba(0, 0, 0, 0.08);\n --trillet-shadow: 0 12px 48px rgba(0, 0, 0, 0.20);\n\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n font-size: 14px;\n line-height: 1.4;\n color: var(--trillet-on-surface);\n}\n\n:host([hidden]) { display: none; }\n\n/* ---- placement attribute (fixed positioning on the host element) ----\n Kept in the shadow stylesheet (low specificity) so raw CSS on the\n trillet-widget element still overrides it. */\n:host([placement=\"bottom-right\"]) { top: auto; bottom: 24px; left: auto; right: 24px; }\n:host([placement=\"bottom-left\"]) { top: auto; bottom: 24px; right: auto; left: 24px; }\n:host([placement=\"bottom\"]) { top: auto; bottom: 24px; left: 50%; right: auto; transform: translateX(-50%); }\n:host([placement=\"top-right\"]) { bottom: auto; top: 24px; left: auto; right: 24px; }\n:host([placement=\"top-left\"]) { bottom: auto; top: 24px; right: auto; left: 24px; }\n:host([placement=\"top\"]) { bottom: auto; top: 24px; left: 50%; right: auto; transform: translateX(-50%); }\n\n* { box-sizing: border-box; }\n\n.tw-root {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 12px;\n}\n/* Left/center placements align the launcher + card accordingly. */\n:host([placement=\"bottom-left\"]) .tw-root,\n:host([placement=\"top-left\"]) .tw-root { align-items: flex-start; }\n:host([placement=\"bottom\"]) .tw-root,\n:host([placement=\"top\"]) .tw-root { align-items: center; }\n\n/* ---- Floating launcher ---- */\n.tw-launcher {\n display: inline-flex;\n align-items: center;\n gap: 10px;\n padding: 12px 18px;\n border: none;\n border-radius: 999px;\n background: var(--trillet-accent);\n color: #fff;\n font-size: 14px;\n font-weight: 600;\n cursor: pointer;\n box-shadow: var(--trillet-shadow);\n transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;\n}\n.tw-launcher:hover { transform: translateY(-1px); box-shadow: 0 16px 52px rgba(0, 0, 0, 0.26); }\n.tw-launcher:active { transform: translateY(0); }\n.tw-launcher .tw-launcher-orb {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background:\n conic-gradient(from 0deg, var(--trillet-orb-1), var(--trillet-orb-2), var(--trillet-orb-1));\n box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.6);\n animation: tw-orb-rotate 8s linear infinite;\n}\n.tw-launcher .tw-launcher-orb-avatar {\n background: none;\n background-size: cover;\n background-position: center;\n animation: none;\n}\n\n/* ---- Panel ---- */\n.tw-panel {\n width: 320px;\n max-width: calc(100vw - 32px);\n background: var(--trillet-surface);\n border: 1px solid var(--trillet-border);\n border-radius: 16px;\n box-shadow: var(--trillet-shadow);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n}\n.tw-panel.tw-expanded { width: 380px; }\n\n.tw-header {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 14px 16px;\n border-bottom: 1px solid var(--trillet-border);\n}\n/* Brand slot: customer logo + optional small brand label, stacked. Subordinate to\n the identity title. */\n.tw-brand {\n display: flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n flex-shrink: 0;\n}\n.tw-brand-logo {\n width: 28px;\n height: 28px;\n border-radius: 8px;\n object-fit: cover;\n}\n/* Small customer brand label (brand.name). Visually subordinate to the identity\n title — lighter weight, muted color, smaller. Never used as the header title. */\n.tw-brand-name {\n font-weight: 500;\n font-size: 12px;\n color: var(--trillet-muted);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 120px;\n}\n/* Header title identifying who the user is talking to (agent / call flow /\n workspace name). The primary header identity; truncates long names cleanly. */\n.tw-header-title {\n flex: 1;\n min-width: 0;\n font-weight: 600;\n font-size: 14px;\n color: var(--trillet-on-surface);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.tw-icon-btn {\n border: none;\n background: transparent;\n color: var(--trillet-muted);\n cursor: pointer;\n width: 28px;\n height: 28px;\n border-radius: 8px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n line-height: 1;\n}\n.tw-icon-btn:hover { background: rgba(0, 0, 0, 0.05); }\n\n.tw-body {\n padding: 20px 16px;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 14px;\n}\n\n/* ---- Animated 2-color gradient orb / avatar ---- */\n.tw-orb-wrap {\n position: relative;\n width: 96px;\n height: 96px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n/* Soft aura behind the orb (breathes gently; stronger while speaking). */\n.tw-orb-wrap::before {\n content: '';\n position: absolute;\n width: 78px;\n height: 78px;\n border-radius: 50%;\n background: radial-gradient(circle, var(--trillet-orb-2), transparent 70%);\n opacity: 0.5;\n filter: blur(10px);\n animation: tw-aura 3.2s ease-in-out infinite;\n}\n.tw-orb {\n position: relative;\n width: 72px;\n height: 72px;\n border-radius: 50%;\n background:\n radial-gradient(circle at 30% 28%, var(--trillet-orb-2), transparent 58%),\n conic-gradient(from 0deg, var(--trillet-orb-1), var(--trillet-orb-2), var(--trillet-orb-1));\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);\n animation: tw-orb-rotate 9s linear infinite;\n}\n/* Glossy highlight so the orb reads as a 3D sphere, not a flat disc. */\n.tw-orb::after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: 50%;\n background: radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.55), transparent 46%);\n}\n/* When an avatar image is provided, show it instead of the gradient. */\n.tw-orb.tw-orb-avatar {\n background: none;\n background-size: cover;\n background-position: center;\n animation: none;\n}\n.tw-orb.tw-orb-avatar::after { display: none; }\n\n@keyframes tw-orb-rotate { to { transform: rotate(360deg); } }\n@keyframes tw-aura {\n 0%, 100% { transform: scale(1); opacity: 0.4; }\n 50% { transform: scale(1.16); opacity: 0.66; }\n}\n\n/* Connecting: a pulsing ring around the orb. */\n.tw-orb-wrap.tw-connecting::after {\n content: '';\n position: absolute;\n width: 72px;\n height: 72px;\n border-radius: 50%;\n border: 2px solid var(--trillet-orb-1);\n animation: tw-pulse 1.4s ease-out infinite;\n}\n@keyframes tw-pulse {\n 0% { transform: scale(0.85); opacity: 0.7; }\n 100% { transform: scale(1.3); opacity: 0; }\n}\n\n/* Listening (live, not speaking): a slow calm breathe. */\n.tw-orb-wrap.tw-listening .tw-orb {\n animation: tw-orb-rotate 9s linear infinite, tw-breathe 3.6s ease-in-out infinite;\n}\n@keyframes tw-breathe {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.03); }\n}\n\n/* Speaking: faster rotation + stronger bob, and a livelier aura. */\n.tw-orb-wrap.tw-speaking .tw-orb {\n animation: tw-orb-rotate 4.5s linear infinite, tw-bob 0.7s ease-in-out infinite alternate;\n}\n.tw-orb-wrap.tw-speaking::before { animation: tw-aura 1.2s ease-in-out infinite; }\n@keyframes tw-bob {\n from { transform: scale(1); }\n to { transform: scale(1.08); }\n}\n\n.tw-status {\n font-size: 13px;\n color: var(--trillet-muted);\n min-height: 18px;\n text-align: center;\n}\n.tw-timer {\n font-size: 12px;\n color: var(--trillet-muted);\n font-variant-numeric: tabular-nums;\n}\n\n/* ---- BYO reCAPTCHA gate ---- */\n/* The checkbox is a light-DOM node projected in via <slot name=\"recaptcha\"> — it can't\n render directly in the shadow root (reCAPTCHA v2 hangs there). ::slotted targets that\n projected node. The checkbox iframe is a fixed 304x78; scale it down on narrow panels\n so it doesn't overflow. */\n.tw-recaptcha-slot {\n display: flex;\n justify-content: center;\n width: 100%;\n}\n::slotted(.tw-recaptcha-mount) {\n display: flex;\n justify-content: center;\n}\n@media (max-width: 340px) {\n ::slotted(.tw-recaptcha-mount) {\n transform: scale(0.85);\n transform-origin: center top;\n }\n}\n\n/* ---- Controls ---- */\n.tw-controls {\n display: flex;\n align-items: center;\n gap: 10px;\n width: 100%;\n justify-content: center;\n}\n.tw-controls.tw-controls-stack {\n flex-direction: column;\n gap: 8px;\n}\n.tw-controls-stack .tw-primary-btn { width: 100%; }\n.tw-primary-btn {\n border: none;\n border-radius: 999px;\n padding: 11px 20px;\n font-size: 14px;\n font-weight: 600;\n cursor: pointer;\n background: var(--trillet-accent);\n color: #fff;\n transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;\n}\n.tw-primary-btn:hover { opacity: 0.92; }\n.tw-primary-btn.tw-danger { background: #e5484d; }\n.tw-primary-btn.tw-secondary {\n background: transparent;\n color: var(--trillet-accent);\n border: 1px solid var(--trillet-border);\n}\n.tw-primary-btn.tw-secondary:hover { background: rgba(0, 0, 0, 0.03); opacity: 1; }\n.tw-primary-btn:disabled { opacity: 0.6; cursor: default; }\n/* Subtle modality switch affordance (mode=\"both\"). */\n.tw-switch-btn {\n border: none;\n background: none;\n color: var(--trillet-muted);\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n padding: 2px 6px;\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.tw-switch-btn:hover { color: var(--trillet-accent); }\n.tw-mic-btn {\n border: 1px solid var(--trillet-border);\n background: var(--trillet-surface);\n color: var(--trillet-on-surface);\n border-radius: 50%;\n width: 42px;\n height: 42px;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n}\n.tw-mic-btn.tw-muted { color: #e5484d; border-color: #e5484d; }\n\n/* ---- Text mode ---- */\n.tw-text-input-row {\n display: flex;\n gap: 8px;\n width: 100%;\n}\n.tw-text-input {\n flex: 1;\n border: 1px solid var(--trillet-border);\n border-radius: 10px;\n padding: 9px 12px;\n font-size: 14px;\n font-family: inherit;\n color: var(--trillet-on-surface);\n background: var(--trillet-surface);\n outline: none;\n}\n.tw-text-input:focus { border-color: var(--trillet-accent); }\n.tw-send-btn {\n border: none;\n border-radius: 10px;\n padding: 0 14px;\n background: var(--trillet-accent);\n color: #fff;\n font-weight: 600;\n cursor: pointer;\n}\n\n/* ---- Transcript ---- */\n.tw-transcript {\n width: 100%;\n max-height: 200px;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding-top: 4px;\n border-top: 1px solid var(--trillet-border);\n margin-top: 4px;\n}\n\n/* ---- Chat window (text mode) ----\n A fixed-height, internally scrolling thread so the panel does NOT grow as\n messages arrive. Height is a sensible fixed value, capped to the viewport on\n short screens. Rendered (empty) as soon as the chat opens. */\n.tw-chat {\n height: min(380px, 60vh);\n max-height: none;\n overflow-y: auto;\n padding: 10px;\n border: 1px solid var(--trillet-border);\n border-top: 1px solid var(--trillet-border);\n border-radius: 12px;\n margin-top: 0;\n background: rgba(0, 0, 0, 0.015);\n scroll-behavior: smooth;\n}\n/* Faint empty state so the open (message-less) chat doesn't read as broken. */\n.tw-chat-empty {\n margin: auto;\n color: var(--trillet-muted);\n opacity: 0.45;\n font-size: 20px;\n letter-spacing: 2px;\n}\n.tw-msg {\n padding: 8px 12px;\n border-radius: 12px;\n max-width: 85%;\n font-size: 13px;\n white-space: pre-wrap;\n word-break: break-word;\n}\n.tw-msg.tw-user {\n align-self: flex-end;\n background: var(--trillet-accent);\n color: #fff;\n border-bottom-right-radius: 4px;\n}\n.tw-msg.tw-assistant {\n align-self: flex-start;\n background: rgba(0, 0, 0, 0.05);\n color: var(--trillet-on-surface);\n border-bottom-left-radius: 4px;\n}\n\n.tw-hidden { display: none !important; }\n`;\n","// Optional BYO reCAPTCHA v2 checkbox for <trillet-widget> (TRI-400).\n//\n// THIS IS NOT A SECURITY CONTROL. The solved token is never sent to Trillet and is\n// never verified — no `siteverify`, no `createAssessment`, by design. A reCAPTCHA\n// token that nobody validates proves nothing, so this provides exactly zero bot\n// protection by construction. It is UI friction: it deters a casual script pointed at\n// a customer's embedded widget, and nothing more.\n//\n// What actually protects the customer's wallet is server-side: the per-workspace\n// domain allowlist and the rate limits on /web-call/public. If you are reaching for\n// this to stop abuse, you want `onBeforeCall` instead — that hook lets you run your\n// own challenge and verify it on your own backend before the call starts.\n\nconst RECAPTCHA_SCRIPT_SRC = 'https://www.google.com/recaptcha/api.js?render=explicit';\n\ninterface GrecaptchaRenderParams {\n sitekey: string;\n callback: (token: string) => void;\n 'expired-callback': () => void;\n 'error-callback': () => void;\n}\n\ninterface Grecaptcha {\n render: (container: HTMLElement, params: GrecaptchaRenderParams) => number;\n ready: (cb: () => void) => void;\n}\n\nfunction getGrecaptcha(): Grecaptcha | undefined {\n return (window as unknown as { grecaptcha?: Grecaptcha }).grecaptcha;\n}\n\n// One script tag per page, shared by every widget instance on it.\nlet scriptPromise: Promise<void> | null = null;\n\nfunction injectScript(): Promise<void> {\n if (scriptPromise) return scriptPromise;\n\n scriptPromise = new Promise<void>((resolve, reject) => {\n const existing = document.querySelector<HTMLScriptElement>(\n `script[src=\"${RECAPTCHA_SCRIPT_SRC}\"]`\n );\n if (existing) {\n resolve();\n return;\n }\n\n const script = document.createElement('script');\n script.src = RECAPTCHA_SCRIPT_SRC;\n script.async = true;\n script.defer = true;\n script.onload = (): void => resolve();\n script.onerror = (): void => {\n // Let a later attempt retry rather than caching the failure forever.\n scriptPromise = null;\n reject(new Error('Failed to load Google reCAPTCHA'));\n };\n document.head.appendChild(script);\n });\n\n return scriptPromise;\n}\n\n/** Load api.js and wait until `grecaptcha.render` is actually callable. */\nexport async function loadRecaptcha(): Promise<Grecaptcha> {\n await injectScript();\n\n const grecaptcha = getGrecaptcha();\n if (!grecaptcha) throw new Error('reCAPTCHA loaded but grecaptcha is undefined');\n\n // onload fires before the library finishes initializing; `ready` is the documented\n // way to wait for `render` to exist.\n await new Promise<void>((resolve) => grecaptcha.ready(resolve));\n return grecaptcha;\n}\n\nexport interface RenderCheckboxOptions {\n container: HTMLElement;\n siteKey: string;\n /** Fired once the visitor solves the challenge. The token is deliberately ignored. */\n onSolved: () => void;\n /** Fired when a solved challenge times out, or the challenge itself errors. */\n onExpired: () => void;\n}\n\n/**\n * Render the v2 checkbox into `container` and resolve with its widget id.\n *\n * `container` lives inside the widget's shadow root. The checkbox iframe renders in\n * place; the challenge dialog (when Google decides to show one) is appended to\n * document.body, outside the shadow tree, which is why it is not affected by the\n * widget's encapsulated styles.\n */\nexport async function renderRecaptchaCheckbox(options: RenderCheckboxOptions): Promise<number> {\n const grecaptcha = await loadRecaptcha();\n\n return grecaptcha.render(options.container, {\n sitekey: options.siteKey,\n // The token is received and dropped on the floor — see the header note.\n callback: () => options.onSolved(),\n 'expired-callback': () => options.onExpired(),\n 'error-callback': () => options.onExpired(),\n });\n}\n","// <trillet-widget> custom element — the self-mounting, shadow-DOM drop-in widget.\n//\n// This is a THIN UI layer over the existing secure core. All call lifecycle is\n// delegated to an internal `TrilletAgent` instance; no call logic is reimplemented\n// here. The element parses config from HTML attributes, renders an isolated UI into\n// a shadow root, and maps `TrilletAgent` events -> UI state + DOM CustomEvents.\n\nimport { TrilletAgent } from '../index.js';\nimport type { TrilletRoomDetails } from '../createCall.js';\nimport type { Transcript } from '../TranscriptManager.js';\nimport {\n WidgetConfig,\n configFromElement,\n OBSERVED_ATTRIBUTES,\n DEFAULT_ORB_COLOR_1,\n DEFAULT_ORB_COLOR_2,\n} from './config.js';\nimport { WIDGET_STYLES } from './styles.js';\nimport { renderRecaptchaCheckbox } from './recaptcha.js';\n\ntype WidgetState = 'idle' | 'connecting' | 'live' | 'ended';\n// The modality actually running in the live session. In `mode=\"both\"` this is chosen\n// by the user (entry point / switch control); in single-modality modes it mirrors the\n// configured mode. `null` = no modality picked yet (pre-call `both` panel).\ntype ActiveMode = 'voice' | 'text';\n\nexport class TrilletWidgetElement extends HTMLElement {\n static get observedAttributes(): readonly string[] {\n return OBSERVED_ATTRIBUTES;\n }\n\n private root: ShadowRoot;\n private config!: WidgetConfig;\n private agent: TrilletAgent | null = null;\n private state: WidgetState = 'idle';\n private open = false; // panel open vs. launcher only\n private micEnabled = true;\n private speaking = false;\n private transcripts: Transcript[] = [];\n // Human-facing identity of who the user is talking to, delivered on the\n // `connected` event. Drives the header title. Null until a session connects.\n private display: TrilletRoomDetails['display'] | null = null;\n\n // Chosen modality for the current/next session. Only meaningful for mode=\"both\";\n // in voice/text modes resolvedMode() ignores it.\n private activeMode: ActiveMode | null = null;\n // True while tearing down one modality and reconnecting in the other, so lifecycle\n // events (call-start/conversationStarted) aren't re-emitted for an internal switch.\n private switching = false;\n\n // JS-only credential path (cannot be set via HTML attribute). Set by the React\n // wrapper or imperative consumers via properties.\n public getRoomDetails?: () => Promise<TrilletRoomDetails> | TrilletRoomDetails;\n public roomDetails?: TrilletRoomDetails;\n\n // maxCallDuration countdown (UX only — see startConversation()).\n private durationTimer: ReturnType<typeof setInterval> | null = null;\n private remainingSeconds: number | null = null;\n private elapsedSeconds = 0;\n\n // BYO reCAPTCHA gate (opt-in via recaptcha-site-key). A ONE-TIME gate per session:\n // once solved, it stays solved for the life of this element, so the visitor can\n // start, end and restart conversations without being re-challenged. Never reset on\n // call end — re-challenging per call is friction that buys nothing, since the token\n // is never verified. See ./recaptcha.ts.\n //\n // The checkbox is rendered into a LIGHT-DOM node projected into the panel via a\n // <slot>, not directly in the shadow root. reCAPTCHA v2's anchor iframe hangs on its\n // loading spinner inside a shadow root — its init handshake can't complete across the\n // shadow boundary (verified). Slotting keeps the checkbox in the light DOM (where it\n // works) while displaying it inside the panel. See ensureRecaptchaSlot().\n private recaptchaSolved = false;\n private recaptchaSlot: HTMLDivElement | null = null;\n private recaptchaWidgetId: number | null = null;\n\n private styleEl: HTMLStyleElement;\n private container: HTMLDivElement;\n\n constructor() {\n super();\n this.root = this.attachShadow({ mode: 'open' });\n this.styleEl = document.createElement('style');\n this.styleEl.textContent = WIDGET_STYLES;\n this.container = document.createElement('div');\n this.container.className = 'tw-root';\n this.root.appendChild(this.styleEl);\n this.root.appendChild(this.container);\n }\n\n connectedCallback(): void {\n this.config = configFromElement(this);\n this.syncActiveMode();\n this.applyTheme();\n this.render();\n }\n\n disconnectedCallback(): void {\n this.clearDurationTimer();\n this.teardownAgent();\n this.removeRecaptchaSlot();\n }\n\n attributeChangedCallback(): void {\n if (!this.isConnected) return;\n // Re-derive config on any attribute change (reactivity), preserving JS-only props.\n this.config = configFromElement(this);\n this.syncActiveMode();\n this.applyTheme();\n this.render();\n }\n\n // ---- Public element API ----------------------------------------------------\n\n /**\n * Imperatively start a conversation. Primary headless API (convai-aligned).\n * @param modality - optional; only used in `mode=\"both\"` to pick voice vs text.\n */\n public async startConversation(modality?: ActiveMode): Promise<void> {\n if (this.state === 'connecting' || this.state === 'live') return;\n this.open = true;\n\n // An unsolved reCAPTCHA gate blocks the imperative API too, not just the button —\n // otherwise the gate is one `document.querySelector(...).startConversation()` away\n // from irrelevant. Open the panel so the visitor can see what is being asked.\n if (this.needsRecaptcha()) {\n this.render();\n return;\n }\n\n await this.beginCall(modality);\n }\n\n /** Imperatively end the active conversation. Primary headless API. */\n public endConversation(): void {\n this.agent?.endCall();\n }\n\n /** @deprecated Use {@link startConversation}. Kept as a thin alias for back-compat. */\n public startCall(): Promise<void> {\n return this.startConversation();\n }\n\n /** @deprecated Use {@link endConversation}. Kept as a thin alias for back-compat. */\n public endCall(): void {\n this.endConversation();\n }\n\n // ---- Modality helpers ------------------------------------------------------\n\n /** The concrete modality to run for the current session (`both` -> activeMode). */\n private resolvedMode(): ActiveMode {\n if (this.config.mode === 'both') return this.activeMode ?? 'voice';\n return this.config.mode as ActiveMode; // 'voice' | 'text'\n }\n\n /** Keep activeMode consistent with the configured mode. */\n private syncActiveMode(): void {\n if (this.config.mode === 'voice' || this.config.mode === 'text') {\n this.activeMode = this.config.mode;\n }\n // mode=\"both\": leave activeMode as-is (null pre-call, chosen at entry / switch).\n }\n\n /** Tear down the current agent cleanly: detach listeners, end the call, drop the ref. */\n private teardownAgent(): void {\n if (!this.agent) return;\n try {\n this.agent.removeAllListeners();\n } catch {\n /* noop */\n }\n try {\n this.agent.endCall();\n } catch {\n /* noop */\n }\n this.agent = null;\n }\n\n /**\n * Switch modality mid-session (mode=\"both\"). Because the core binds `mode` at\n * construction, this ends the current `TrilletAgent` and constructs a fresh one in\n * the other modality, rejoining via the same credential path. Transcripts and the\n * duration timer are preserved across the switch; no lifecycle events fire (it's one\n * conversation from the consumer's perspective).\n */\n private async switchModality(): Promise<void> {\n if (this.config.mode !== 'both' || this.state !== 'live') return;\n const target: ActiveMode = this.resolvedMode() === 'voice' ? 'text' : 'voice';\n\n this.switching = true;\n this.clearDurationTimer();\n this.speaking = false;\n // Detach + end the current agent so its 'disconnected' never reaches endLocalCall.\n this.teardownAgent();\n // transcripts are intentionally kept (this.transcripts) so the thread carries over.\n await this.beginCall(target);\n }\n\n // ---- Credential resolution + call lifecycle --------------------------------\n\n private async beginCall(modality?: ActiveMode): Promise<void> {\n if (modality) this.activeMode = modality;\n const mode = this.resolvedMode();\n // Fresh start: clear any stale identity so the header title doesn't carry over\n // from a previous session. A modality switch (this.switching) keeps it.\n if (!this.switching) this.display = null;\n this.setState('connecting');\n\n try {\n // Construct inside the try: the TrilletAgent constructor throws synchronously\n // on a non-secure context or missing agentId, and that must surface through\n // handleError (not escape as an unhandled rejection that strands 'connecting').\n const agent = new TrilletAgent({\n agentId: this.config.agentId,\n workspaceId: this.config.workspaceId,\n mode,\n variables: this.config.variables,\n });\n this.agent = agent;\n this.wireAgentEvents(agent);\n\n // Credential path resolution (priority order, spec §5).\n if (this.config.signedUrlEndpoint || this.getRoomDetails) {\n // Secure DEFAULT — minted at call-start, not at mount, to avoid token expiry.\n let details: TrilletRoomDetails;\n if (this.getRoomDetails) {\n details = await this.getRoomDetails();\n } else {\n const res = await fetch(this.config.signedUrlEndpoint as string, {\n method: 'GET',\n headers: { Accept: 'application/json' },\n });\n if (!res.ok) {\n throw new Error(`signed-url-endpoint returned ${res.status}`);\n }\n details = (await res.json()) as TrilletRoomDetails;\n }\n await agent.joinRoom(details);\n } else if (this.roomDetails) {\n // Secure static — token may expire between mount and click.\n await agent.joinRoom(this.roomDetails);\n } else if (this.config.workspaceId) {\n // Public fallback (legacy).\n await agent.startPublicCall();\n } else {\n throw new Error(\n 'No credential path configured: set signed-url-endpoint, roomDetails/getRoomDetails, or workspace-id'\n );\n }\n } catch (error) {\n // Agent already emits 'error' for its own failures; the catch here covers\n // credential-resolution failures too. wireAgentEvents handles UI + DOM event.\n this.handleError(error);\n }\n }\n\n private wireAgentEvents(agent: TrilletAgent): void {\n agent.on('connected', (details?: { display?: TrilletRoomDetails['display'] }) => {\n // Capture who the user is talking to so the header title can render it.\n this.display = details?.display ?? null;\n const wasSwitching = this.switching;\n this.setState('live'); // reads this.switching to suppress start events on a switch\n this.startDurationTimer(!wasSwitching); // keep the running timer across a switch\n this.switching = false;\n });\n\n agent.on('disconnected', () => {\n this.endLocalCall();\n });\n\n agent.on('error', (error: unknown) => {\n this.handleError(error);\n });\n\n agent.on('assistantStartedSpeaking', () => {\n this.speaking = true;\n this.render();\n });\n\n agent.on('assistantStoppedSpeaking', () => {\n this.speaking = false;\n this.render();\n });\n\n agent.on('transcriptUpdate', (transcripts: Transcript[]) => {\n this.transcripts = transcripts;\n this.dispatch('transcript', transcripts);\n this.render();\n });\n }\n\n private endLocalCall(): void {\n if (this.state === 'ended' || this.state === 'idle') return;\n this.clearDurationTimer();\n this.dispatch('call-end', this.elapsedSeconds);\n this.dispatch('conversationEnded', this.elapsedSeconds);\n this.setState('ended');\n this.agent = null;\n // In `both` mode, drop the chosen modality so the pre-call dual entry returns.\n if (this.config.mode === 'both') this.activeMode = null;\n }\n\n private handleError(error: unknown): void {\n const err = error instanceof Error ? error : new Error(String(error));\n this.clearDurationTimer();\n this.switching = false;\n this.dispatch('error', err);\n this.agent = null;\n if (this.config.mode === 'both') this.activeMode = null;\n this.setState('idle');\n }\n\n // ---- maxCallDuration (UX-ONLY countdown) -----------------------------------\n // NOTE: This is a client-side timer for UX feedback only. Real call-duration\n // enforcement happens server-side (backend web-call route); this timer is\n // trivially bypassable and must not be relied on as a hard cap.\n private startDurationTimer(reset = true): void {\n this.clearDurationTimer();\n if (reset) {\n this.elapsedSeconds = 0;\n this.remainingSeconds =\n typeof this.config.maxCallDuration === 'number' ? this.config.maxCallDuration : null;\n }\n this.durationTimer = setInterval(() => {\n this.elapsedSeconds += 1;\n if (this.remainingSeconds !== null) {\n this.remainingSeconds -= 1;\n if (this.remainingSeconds <= 0) {\n this.agent?.endCall();\n return;\n }\n }\n this.renderStatus();\n }, 1000);\n }\n\n private clearDurationTimer(): void {\n if (this.durationTimer) {\n clearInterval(this.durationTimer);\n this.durationTimer = null;\n }\n }\n\n // ---- State + DOM events ----------------------------------------------------\n\n private setState(state: WidgetState): void {\n const prev = this.state;\n this.state = state;\n if (state === 'live' && prev !== 'live' && !this.switching) {\n this.dispatch('call-start', undefined);\n this.dispatch('conversationStarted', undefined);\n }\n this.render();\n }\n\n private dispatch(type: string, detail: unknown): void {\n this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));\n }\n\n // ---- Theming ----------------------------------------------------------------\n\n private applyTheme(): void {\n const orb1 = this.config.orbColor1 || DEFAULT_ORB_COLOR_1;\n const orb2 = this.config.orbColor2 || DEFAULT_ORB_COLOR_2;\n this.style.setProperty('--trillet-orb-1', orb1);\n this.style.setProperty('--trillet-orb-2', orb2);\n\n // Accent (buttons/launcher): customer brand color first, else orb color 1.\n const accent = this.config.brand.primaryColor || this.config.orbColor1;\n if (accent) {\n this.style.setProperty('--trillet-accent', accent);\n } else {\n this.style.removeProperty('--trillet-accent');\n }\n }\n\n // ---- Rendering --------------------------------------------------------------\n\n private formatTime(total: number): string {\n const m = Math.floor(total / 60);\n const s = total % 60;\n return `${m}:${s.toString().padStart(2, '0')}`;\n }\n\n private statusText(): string {\n switch (this.state) {\n case 'connecting':\n return 'Connecting…';\n case 'live':\n return this.speaking ? this.config.speakingText : this.config.listeningText;\n case 'ended':\n return 'Call ended';\n default:\n return this.config.actionText || '';\n }\n }\n\n private renderStatus(): void {\n const statusEl = this.root.querySelector('.tw-status');\n if (statusEl) statusEl.textContent = this.statusText();\n const timerEl = this.root.querySelector('.tw-timer');\n if (timerEl) timerEl.textContent = this.timerText();\n }\n\n private timerText(): string {\n if (this.state !== 'live') return '';\n if (this.remainingSeconds !== null) {\n return this.formatTime(Math.max(0, this.remainingSeconds));\n }\n return this.formatTime(this.elapsedSeconds);\n }\n\n private render(): void {\n this.container.replaceChildren();\n\n if (!this.open) {\n this.container.appendChild(this.renderLauncher());\n return;\n }\n this.container.appendChild(this.renderPanel());\n }\n\n private renderLauncher(): HTMLElement {\n const btn = document.createElement('button');\n btn.className = 'tw-launcher';\n btn.type = 'button';\n\n const orb = document.createElement('span');\n orb.className = 'tw-launcher-orb';\n if (this.config.avatar) {\n orb.classList.add('tw-launcher-orb-avatar');\n orb.style.backgroundImage = `url(\"${this.config.avatar}\")`;\n }\n btn.appendChild(orb);\n\n const label = document.createElement('span');\n label.textContent = this.config.actionText || this.config.startCallText;\n btn.appendChild(label);\n\n btn.addEventListener('click', () => {\n this.open = true;\n this.render();\n });\n return btn;\n }\n\n private renderPanel(): HTMLElement {\n const panel = document.createElement('div');\n panel.className = `tw-panel${this.config.variant === 'expanded' ? ' tw-expanded' : ''}`;\n\n panel.appendChild(this.renderHeader());\n panel.appendChild(this.renderBody());\n\n // Voice sessions show ONLY the orb + status + timer + controls (like competitors):\n // no transcript / chat thread in any variant, including a mode=\"both\" session\n // running its voice modality. The chat thread lives exclusively in text mode\n // (rendered inside renderTextBody). So nothing extra is appended here.\n return panel;\n }\n\n /**\n * The header title identifying who the user is talking to. Each identity value is\n * code-overridable per value: a static `agent-name`/`call-flow-name`/`workspace-name`\n * config value takes precedence over the corresponding backend `display.*` value\n * (which only arrives on `connected`), falling back to it when unset. Resolution:\n * effectiveAgent = config.agentName ?? display.agent_name\n * effectiveCallFlow = config.callFlowName ?? display.call_flow_name\n * effectiveWorkspace = config.workspaceName ?? display.workspace_name\n * title = effectiveAgent || effectiveCallFlow || effectiveWorkspace || ''\n * Because the overrides are static config, the title can render pre-call. Note:\n * `brand.name` is intentionally NOT part of this chain — it renders in the brand\n * slot only.\n */\n private headerTitle(): string {\n // configFromElement already maps empty-string attributes to undefined, so `??`\n // correctly falls through to the display fallback when an override is unset.\n const effectiveAgent = this.config.agentName ?? this.display?.agent_name;\n const effectiveCallFlow = this.config.callFlowName ?? this.display?.call_flow_name;\n const effectiveWorkspace = this.config.workspaceName ?? this.display?.workspace_name;\n return effectiveAgent || effectiveCallFlow || effectiveWorkspace || '';\n }\n\n private renderHeader(): HTMLElement {\n const header = document.createElement('div');\n header.className = 'tw-header';\n\n // Brand slot: customer logo + optional small brand label. This is where\n // `brand.name` renders — subordinate to and visually distinct from the identity\n // title below. `brand.name` is NEVER used as the header title.\n if (this.config.brand.logo || this.config.brand.name) {\n const brand = document.createElement('div');\n brand.className = 'tw-brand';\n if (this.config.brand.logo) {\n const logo = document.createElement('img');\n logo.className = 'tw-brand-logo';\n logo.src = this.config.brand.logo;\n logo.alt = this.config.brand.name || '';\n brand.appendChild(logo);\n }\n if (this.config.brand.name) {\n const brandLabel = document.createElement('span');\n brandLabel.className = 'tw-brand-name';\n brandLabel.textContent = this.config.brand.name;\n brandLabel.title = this.config.brand.name;\n brand.appendChild(brandLabel);\n }\n header.appendChild(brand);\n }\n\n // Identity title: who the user is talking to (agent / call flow / workspace),\n // per-value overridable in code with the backend `display.*` as fallback.\n const name = document.createElement('div');\n name.className = 'tw-header-title';\n const title = this.headerTitle();\n name.textContent = title;\n if (title) name.title = title; // native tooltip for truncated long names\n header.appendChild(name);\n\n if (this.config.variant === 'compact') {\n const expandBtn = document.createElement('button');\n expandBtn.className = 'tw-icon-btn';\n expandBtn.type = 'button';\n expandBtn.title = this.config.expandText;\n expandBtn.textContent = '⤢';\n expandBtn.addEventListener('click', () => {\n this.config = { ...this.config, variant: 'expanded' };\n this.render();\n });\n header.appendChild(expandBtn);\n } else {\n const collapseBtn = document.createElement('button');\n collapseBtn.className = 'tw-icon-btn';\n collapseBtn.type = 'button';\n collapseBtn.title = this.config.collapseText;\n collapseBtn.textContent = '⤡';\n collapseBtn.addEventListener('click', () => {\n this.config = { ...this.config, variant: 'compact' };\n this.render();\n });\n header.appendChild(collapseBtn);\n }\n\n if (this.config.dismissible) {\n const closeBtn = document.createElement('button');\n closeBtn.className = 'tw-icon-btn';\n closeBtn.type = 'button';\n closeBtn.title = 'Close';\n closeBtn.textContent = '✕';\n closeBtn.addEventListener('click', () => {\n if (this.state === 'live' || this.state === 'connecting') {\n this.endConversation();\n }\n this.open = false;\n this.render();\n });\n header.appendChild(closeBtn);\n }\n\n return header;\n }\n\n /** True when a `both` widget is idle/ended with no modality chosen yet. */\n private isBothPreCall(): boolean {\n return (\n this.config.mode === 'both' &&\n this.activeMode === null &&\n (this.state === 'idle' || this.state === 'ended')\n );\n }\n\n // ---- BYO reCAPTCHA gate ----------------------------------------------------\n\n /** True when a site key is configured and this session has not solved it yet. */\n private needsRecaptcha(): boolean {\n return Boolean(this.config.recaptchaSiteKey) && !this.recaptchaSolved;\n }\n\n /**\n * The pre-call gate shown in the panel: orb, prompt, the reCAPTCHA checkbox, and a\n * disabled start button. The button enables once the checkbox is solved.\n *\n * The checkbox itself is projected in via a <slot>: reCAPTCHA v2 hangs inside a\n * shadow root (its anchor iframe never finishes initializing), so the actual widget\n * is rendered into a LIGHT-DOM node — a child of the host element — that is assigned\n * to this slot. It therefore *displays* here inside the panel while its DOM home\n * stays in the light tree, where reCAPTCHA works. Verified via examples/recaptcha-\n * isolate.local.html (case C).\n */\n private renderRecaptchaGate(body: HTMLElement): void {\n body.appendChild(this.buildOrb());\n\n const status = document.createElement('div');\n status.className = 'tw-status';\n status.textContent = this.config.recaptchaText;\n body.appendChild(status);\n\n // The checkbox renders into the slotted light-DOM node (see ensureRecaptchaSlot).\n const slot = document.createElement('slot');\n slot.setAttribute('name', 'recaptcha');\n slot.className = 'tw-recaptcha-slot';\n body.appendChild(slot);\n\n const controls = document.createElement('div');\n controls.className = 'tw-controls';\n const startBtn = document.createElement('button');\n startBtn.className = 'tw-primary-btn';\n startBtn.type = 'button';\n startBtn.textContent = this.config.startCallText;\n startBtn.disabled = true;\n controls.appendChild(startBtn);\n body.appendChild(controls);\n\n this.ensureRecaptchaSlot();\n }\n\n /**\n * Create the light-DOM node that hosts the reCAPTCHA checkbox and render the checkbox\n * into it. The node is a child of the host element with `slot=\"recaptcha\"`, so it is\n * projected into the gate's <slot>. Idempotent: every widget re-render recreates the\n * <slot> element, but this node (and its iframe) persists in the light DOM untouched,\n * so the checkbox is rendered exactly once and re-projects automatically.\n */\n private ensureRecaptchaSlot(): void {\n const siteKey = this.config.recaptchaSiteKey;\n if (!siteKey || this.recaptchaSolved || this.recaptchaSlot) return;\n\n const slotted = document.createElement('div');\n slotted.setAttribute('slot', 'recaptcha');\n slotted.className = 'tw-recaptcha-mount';\n // Light DOM: a child of the host element, NOT of the shadow-root container that\n // render() rebuilds. That's what keeps the iframe alive across re-renders.\n this.appendChild(slotted);\n this.recaptchaSlot = slotted;\n\n this.recaptchaWidgetId = -1; // claim the slot before awaiting (guards double-render)\n void renderRecaptchaCheckbox({\n container: slotted,\n siteKey,\n onSolved: () => {\n this.recaptchaSolved = true;\n this.removeRecaptchaSlot();\n this.render(); // panel now shows the enabled start button\n },\n // A solved checkbox expires after ~2 minutes. Google resets its own widget UI in\n // place, and the slot is still showing, so the visitor can just re-tick it.\n onExpired: () => {\n this.recaptchaSolved = false;\n },\n })\n .then((id) => {\n this.recaptchaWidgetId = id;\n })\n .catch((error) => {\n // Google unreachable (blocked, offline, CSP). Failing closed would strand the\n // visitor behind a checkbox that can never appear, on a gate that provides no\n // security anyway — so let the call through and say why.\n console.warn('[trillet-widget] reCAPTCHA failed to load; starting without it', error);\n this.recaptchaSolved = true;\n this.removeRecaptchaSlot();\n this.render();\n });\n }\n\n /** Remove the slotted light-DOM checkbox node. Safe to call when none exists. */\n private removeRecaptchaSlot(): void {\n this.recaptchaSlot?.remove();\n this.recaptchaSlot = null;\n if (!this.recaptchaSolved) this.recaptchaWidgetId = null;\n }\n\n private renderBody(): HTMLElement {\n const body = document.createElement('div');\n body.className = 'tw-body';\n\n // Gate everything pre-call behind the checkbox when one is configured.\n if (this.needsRecaptcha() && (this.state === 'idle' || this.state === 'ended')) {\n this.renderRecaptchaGate(body);\n return body;\n }\n\n // mode=\"both\", pre-call: present BOTH entry points (call + message), convai-style.\n if (this.isBothPreCall()) {\n this.renderBothEntry(body);\n return body;\n }\n\n // Voice and text are mutually exclusive experiences — a session is either a voice\n // call or a text chat, never both simultaneously. Each mode renders only its own\n // controls; mode=\"both\" adds a switch affordance to move between them.\n if (this.resolvedMode() === 'text') {\n this.renderTextBody(body);\n } else {\n this.renderVoiceBody(body);\n }\n return body;\n }\n\n /** Build the animated gradient orb (or avatar image) reflecting the current state. */\n private buildOrb(): HTMLElement {\n const orbWrap = document.createElement('div');\n orbWrap.className = 'tw-orb-wrap';\n if (this.state === 'connecting') orbWrap.classList.add('tw-connecting');\n if (this.state === 'live') orbWrap.classList.add('tw-listening');\n if (this.state === 'live' && this.speaking) orbWrap.classList.add('tw-speaking');\n\n const orb = document.createElement('div');\n orb.className = 'tw-orb';\n if (this.config.avatar) {\n orb.classList.add('tw-orb-avatar');\n orb.style.backgroundImage = `url(\"${this.config.avatar}\")`;\n }\n orbWrap.appendChild(orb);\n return orbWrap;\n }\n\n /** Pre-call panel for mode=\"both\": orb + \"Start a call\" (voice) and \"Message\" (text). */\n private renderBothEntry(body: HTMLElement): void {\n body.appendChild(this.buildOrb());\n\n const controls = document.createElement('div');\n controls.className = 'tw-controls tw-controls-stack';\n\n const callBtn = document.createElement('button');\n callBtn.className = 'tw-primary-btn';\n callBtn.type = 'button';\n callBtn.textContent = this.config.startCallText;\n callBtn.addEventListener('click', () => {\n void this.beginCall('voice');\n });\n controls.appendChild(callBtn);\n\n const msgBtn = document.createElement('button');\n msgBtn.className = 'tw-primary-btn tw-secondary';\n msgBtn.type = 'button';\n msgBtn.textContent = this.config.messageText;\n msgBtn.addEventListener('click', () => {\n void this.beginCall('text');\n });\n controls.appendChild(msgBtn);\n\n body.appendChild(controls);\n }\n\n /** Voice UI: orb + spoken status + timer + mic/end controls. Never a text input. */\n private renderVoiceBody(body: HTMLElement): void {\n body.appendChild(this.buildOrb());\n\n const status = document.createElement('div');\n status.className = 'tw-status';\n status.textContent = this.statusText();\n body.appendChild(status);\n\n const timer = document.createElement('div');\n timer.className = 'tw-timer';\n timer.textContent = this.timerText();\n body.appendChild(timer);\n\n body.appendChild(this.renderControls());\n\n const switchBtn = this.renderSwitchButton();\n if (switchBtn) body.appendChild(switchBtn);\n }\n\n /** Text/chat UI: conversation thread + message input. Never an orb or \"listening\" state. */\n private renderTextBody(body: HTMLElement): void {\n if (this.state === 'idle' || this.state === 'ended') {\n if (this.state === 'ended') {\n const status = document.createElement('div');\n status.className = 'tw-status';\n status.textContent = 'Chat ended';\n body.appendChild(status);\n }\n body.appendChild(this.renderControls()); // Start button\n return;\n }\n\n // connecting | live — the conversation thread is the primary surface here.\n if (this.state === 'connecting') {\n const status = document.createElement('div');\n status.className = 'tw-status';\n status.textContent = 'Connecting…';\n body.appendChild(status);\n }\n\n body.appendChild(this.renderTranscript());\n\n if (this.state === 'live') {\n body.appendChild(this.renderTextInput());\n }\n\n const endBtn = document.createElement('button');\n endBtn.className = 'tw-primary-btn tw-danger';\n endBtn.type = 'button';\n endBtn.textContent = this.config.endCallText;\n endBtn.disabled = this.state === 'connecting';\n endBtn.addEventListener('click', () => this.endConversation());\n body.appendChild(endBtn);\n\n const switchBtn = this.renderSwitchButton();\n if (switchBtn) body.appendChild(switchBtn);\n }\n\n /** In mode=\"both\" during a live session, a control to switch to the other modality. */\n private renderSwitchButton(): HTMLButtonElement | null {\n if (this.config.mode !== 'both' || this.state !== 'live') return null;\n const toText = this.resolvedMode() === 'voice';\n const btn = document.createElement('button');\n btn.className = 'tw-switch-btn';\n btn.type = 'button';\n btn.textContent = toText ? this.config.switchToTextText : this.config.switchToVoiceText;\n btn.addEventListener('click', () => {\n void this.switchModality();\n });\n return btn;\n }\n\n private renderControls(): HTMLElement {\n const controls = document.createElement('div');\n controls.className = 'tw-controls';\n\n if (this.state === 'idle' || this.state === 'ended') {\n const startBtn = document.createElement('button');\n startBtn.className = 'tw-primary-btn';\n startBtn.type = 'button';\n startBtn.textContent = this.config.startCallText;\n startBtn.addEventListener('click', () => {\n void this.beginCall();\n });\n controls.appendChild(startBtn);\n return controls;\n }\n\n // connecting | live\n if (this.resolvedMode() === 'voice' && this.state === 'live') {\n const micBtn = document.createElement('button');\n micBtn.className = `tw-mic-btn${this.micEnabled ? '' : ' tw-muted'}`;\n micBtn.type = 'button';\n micBtn.title = this.micEnabled ? 'Mute microphone' : 'Unmute microphone';\n micBtn.textContent = this.micEnabled ? '🎙' : '🔇';\n micBtn.addEventListener('click', () => {\n this.micEnabled = !this.micEnabled;\n this.agent?.toggleMicrophone(this.micEnabled);\n this.render();\n });\n controls.appendChild(micBtn);\n }\n\n const endBtn = document.createElement('button');\n endBtn.className = 'tw-primary-btn tw-danger';\n endBtn.type = 'button';\n endBtn.textContent = this.config.endCallText;\n endBtn.disabled = this.state === 'connecting';\n endBtn.addEventListener('click', () => this.endConversation());\n controls.appendChild(endBtn);\n\n return controls;\n }\n\n private renderTextInput(): HTMLElement {\n const row = document.createElement('div');\n row.className = 'tw-text-input-row';\n\n const input = document.createElement('input');\n input.className = 'tw-text-input';\n input.type = 'text';\n input.placeholder = 'Type a message…';\n\n const send = (): void => {\n const text = input.value.trim();\n if (!text) return;\n void this.agent?.sendTextMessage(text);\n input.value = '';\n };\n\n input.addEventListener('keydown', (e) => {\n if (e.key === 'Enter') send();\n });\n\n const sendBtn = document.createElement('button');\n sendBtn.className = 'tw-send-btn';\n sendBtn.type = 'button';\n sendBtn.textContent = 'Send';\n sendBtn.addEventListener('click', send);\n\n row.appendChild(input);\n row.appendChild(sendBtn);\n return row;\n }\n\n /**\n * The chat thread for text mode. This is a fixed-height, internally scrolling\n * window (like a normal website chatbot): the container is rendered at its full\n * height as soon as the chat opens — empty until messages arrive — and messages\n * accumulate + scroll inside it, so the panel's overall height stays stable.\n * Auto-scrolls to the newest message after each render.\n */\n private renderTranscript(): HTMLElement {\n const wrap = document.createElement('div');\n wrap.className = 'tw-transcript tw-chat';\n\n if (this.transcripts.length === 0) {\n const empty = document.createElement('div');\n empty.className = 'tw-chat-empty';\n empty.textContent = this.state === 'connecting' ? '' : '…';\n wrap.appendChild(empty);\n } else {\n for (const t of this.transcripts) {\n const msg = document.createElement('div');\n msg.className = `tw-msg ${t.role === 'user' ? 'tw-user' : 'tw-assistant'}`;\n msg.textContent = t.text;\n wrap.appendChild(msg);\n }\n }\n\n // Auto-scroll to the newest message. render() reattaches this element to the\n // shadow root synchronously, so by the time this rAF fires it's laid out.\n requestAnimationFrame(() => {\n wrap.scrollTop = wrap.scrollHeight;\n });\n return wrap;\n }\n}\n","// Custom-element registration. Idempotent and SSR-safe: does nothing when there is\n// no `customElements` registry (e.g. Node SSR), and never double-registers.\n\nimport { TrilletWidgetElement } from './TrilletWidgetElement.js';\n\nexport const TRILLET_WIDGET_TAG = 'trillet-widget';\n\nexport function registerTrilletWidget(tag: string = TRILLET_WIDGET_TAG): void {\n if (typeof customElements === 'undefined') return;\n if (customElements.get(tag)) return;\n customElements.define(tag, TrilletWidgetElement);\n}\n","// React wrapper (SECONDARY entry) — a thin <TrilletWidget> over the framework-free\n// <trillet-widget> custom element. React stays a peerDependency and is NOT bundled\n// into the npm ESM build. This component only sets attributes/properties on the\n// underlying element and forwards its DOM CustomEvents to React callbacks.\n\nimport * as React from 'react';\nimport { registerTrilletWidget, TRILLET_WIDGET_TAG } from './register.js';\nimport type { TrilletWidgetElement } from './TrilletWidgetElement.js';\nimport type {\n WidgetBrand,\n WidgetMode,\n WidgetVariantInput,\n WidgetPlacement,\n} from './config.js';\nimport type { TrilletRoomDetails } from '../createCall.js';\nimport type { Transcript } from '../TranscriptManager.js';\n\nexport interface TrilletWidgetProps {\n // Required\n agentId: string;\n\n // Credential paths\n signedUrlEndpoint?: string;\n /** JS-only: invoked at call-start to mint room details (cannot be an HTML attribute). */\n getRoomDetails?: () => Promise<TrilletRoomDetails> | TrilletRoomDetails;\n /** JS-only: static pre-minted room details. */\n roomDetails?: TrilletRoomDetails;\n workspaceId?: string;\n\n // Header identity overrides. Each overrides the corresponding backend-provided\n // `display.*` name (which remains the fallback). Being static config, setting any\n // of them renders the header title immediately (pre-call).\n agentName?: string;\n callFlowName?: string;\n workspaceName?: string;\n\n // Appearance\n avatar?: string;\n /** convai alias of `avatar`. */\n avatarImageUrl?: string;\n /** Legacy single accent/orb color; alias of orbColor1. */\n orbColor?: string;\n /** Gradient orb color 1 (convai `avatar-orb-color-1`). */\n orbColor1?: string;\n /** Gradient orb color 2 (convai `avatar-orb-color-2`). */\n orbColor2?: string;\n /** Accepts both our `compact|expanded` and convai's `tiny|compact|full`. */\n variant?: WidgetVariantInput;\n placement?: WidgetPlacement;\n dismissible?: boolean;\n\n // Copy / text overrides\n actionText?: string;\n startCallText?: string;\n endCallText?: string;\n /** Label for the text/chat entry point in mode=\"both\" (default \"Message\"). */\n messageText?: string;\n switchToTextText?: string;\n switchToVoiceText?: string;\n listeningText?: string;\n speakingText?: string;\n expandText?: string;\n collapseText?: string;\n /** Copy shown above the reCAPTCHA checkbox, when `recaptchaSiteKey` is set. */\n recaptchaText?: string;\n\n // Behavior\n /** \"voice\" | \"text\" | \"both\" (multimodal, user-switchable). */\n mode?: WidgetMode;\n variables?: Record<string, unknown>;\n /** convai alias of `variables`. */\n dynamicVariables?: Record<string, unknown>;\n maxCallDuration?: number;\n /**\n * Google reCAPTCHA v2 site key. Renders a checkbox the visitor solves once per\n * session before the first conversation. BYO and client-only — the token is never\n * sent to Trillet nor verified, so it is UI friction, not bot protection.\n */\n recaptchaSiteKey?: string;\n /** convai `disable-banner` — accepted no-op (blank by default). */\n disableBanner?: boolean;\n\n // Customer branding (default blank)\n brand?: WidgetBrand;\n\n // Callbacks — primary (convai-aligned) + back-compat aliases.\n /** Primary. Fires alongside onCallStart. */\n onConversationStart?: () => void;\n /** Primary. Fires alongside onCallEnd. */\n onConversationEnd?: (durationSeconds: number) => void;\n /** @deprecated Use onConversationStart. Still fired for back-compat. */\n onCallStart?: () => void;\n /** @deprecated Use onConversationEnd. Still fired for back-compat. */\n onCallEnd?: (durationSeconds: number) => void;\n onError?: (error: Error) => void;\n onTranscript?: (transcripts: Transcript[]) => void;\n\n // Escape hatch for positioning / sizing via inline style or className.\n className?: string;\n style?: React.CSSProperties;\n}\n\n/** Maps a camelCase prop name to its kebab-case HTML attribute. */\nfunction setAttr(el: HTMLElement, name: string, value: string | number | boolean | undefined): void {\n if (value === undefined || value === false || value === null) {\n el.removeAttribute(name);\n return;\n }\n if (value === true) {\n el.setAttribute(name, '');\n return;\n }\n el.setAttribute(name, String(value));\n}\n\nexport const TrilletWidget: React.FC<TrilletWidgetProps> = (props) => {\n const ref = React.useRef<TrilletWidgetElement | null>(null);\n\n // Register the element once on the client.\n React.useEffect(() => {\n registerTrilletWidget();\n }, []);\n\n // Reflect attribute-style props onto the element.\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n setAttr(el, 'agent-id', props.agentId);\n setAttr(el, 'signed-url-endpoint', props.signedUrlEndpoint);\n setAttr(el, 'workspace-id', props.workspaceId);\n setAttr(el, 'agent-name', props.agentName);\n setAttr(el, 'call-flow-name', props.callFlowName);\n setAttr(el, 'workspace-name', props.workspaceName);\n setAttr(el, 'avatar', props.avatar ?? props.avatarImageUrl);\n setAttr(el, 'orb-color', props.orbColor);\n setAttr(el, 'avatar-orb-color-1', props.orbColor1);\n setAttr(el, 'avatar-orb-color-2', props.orbColor2);\n setAttr(el, 'variant', props.variant);\n setAttr(el, 'placement', props.placement);\n setAttr(el, 'dismissible', props.dismissible);\n setAttr(el, 'action-text', props.actionText);\n setAttr(el, 'start-call-text', props.startCallText);\n setAttr(el, 'end-call-text', props.endCallText);\n setAttr(el, 'message-text', props.messageText);\n setAttr(el, 'switch-to-text-text', props.switchToTextText);\n setAttr(el, 'switch-to-voice-text', props.switchToVoiceText);\n setAttr(el, 'listening-text', props.listeningText);\n setAttr(el, 'speaking-text', props.speakingText);\n setAttr(el, 'expand-text', props.expandText);\n setAttr(el, 'collapse-text', props.collapseText);\n setAttr(el, 'mode', props.mode);\n const vars = props.variables ?? props.dynamicVariables;\n setAttr(el, 'variables', vars ? JSON.stringify(vars) : undefined);\n setAttr(el, 'max-call-duration', props.maxCallDuration);\n setAttr(el, 'recaptcha-site-key', props.recaptchaSiteKey);\n setAttr(el, 'recaptcha-text', props.recaptchaText);\n setAttr(el, 'disable-banner', props.disableBanner);\n setAttr(el, 'brand-logo', props.brand?.logo);\n setAttr(el, 'brand-color', props.brand?.primaryColor);\n setAttr(el, 'brand-name', props.brand?.name);\n });\n\n // Reflect JS-only credential props (functions/objects can't be attributes).\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n el.getRoomDetails = props.getRoomDetails;\n el.roomDetails = props.roomDetails;\n }, [props.getRoomDetails, props.roomDetails]);\n\n // Wire DOM CustomEvents -> React callbacks.\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n // Primary (convai-aligned) lifecycle events.\n const onConvStart = (): void => props.onConversationStart?.();\n const onConvEnd = (e: Event): void =>\n props.onConversationEnd?.((e as CustomEvent<number>).detail);\n // Back-compat aliases (both fire from the element; wire both so either prop works).\n const onStart = (): void => props.onCallStart?.();\n const onEnd = (e: Event): void => props.onCallEnd?.((e as CustomEvent<number>).detail);\n const onErr = (e: Event): void => props.onError?.((e as CustomEvent<Error>).detail);\n const onTr = (e: Event): void => props.onTranscript?.((e as CustomEvent<Transcript[]>).detail);\n\n el.addEventListener('conversationStarted', onConvStart);\n el.addEventListener('conversationEnded', onConvEnd);\n el.addEventListener('call-start', onStart);\n el.addEventListener('call-end', onEnd);\n el.addEventListener('error', onErr);\n el.addEventListener('transcript', onTr);\n return () => {\n el.removeEventListener('conversationStarted', onConvStart);\n el.removeEventListener('conversationEnded', onConvEnd);\n el.removeEventListener('call-start', onStart);\n el.removeEventListener('call-end', onEnd);\n el.removeEventListener('error', onErr);\n el.removeEventListener('transcript', onTr);\n };\n }, [\n props.onConversationStart,\n props.onConversationEnd,\n props.onCallStart,\n props.onCallEnd,\n props.onError,\n props.onTranscript,\n ]);\n\n return React.createElement(TRILLET_WIDGET_TAG, {\n ref: ref as unknown as React.Ref<HTMLElement>,\n class: props.className,\n style: props.style,\n });\n};\n","// `@trillet-ai/web-sdk/widget` entry (ESM, secondary). Exports the React wrapper,\n// the custom element class, the registration helper, and the widget config types.\n// Importing this module registers the <trillet-widget> custom element as a side\n// effect (idempotent + SSR-safe), so consumers can use either the React component\n// or the bare custom element.\n\nimport { registerTrilletWidget } from './register.js';\n\n// Side-effect: define <trillet-widget> on import (no-op when no customElements).\nregisterTrilletWidget();\n\nexport { TrilletWidget } from './react.js';\nexport type { TrilletWidgetProps } from './react.js';\nexport { TrilletWidgetElement } from './TrilletWidgetElement.js';\nexport { registerTrilletWidget, TRILLET_WIDGET_TAG } from './register.js';\nexport type {\n WidgetConfig,\n WidgetBrand,\n WidgetVariant,\n WidgetVariantInput,\n WidgetMode,\n WidgetPlacement,\n} from './config.js';\n"],"mappings":";;;;;;AA0BO,IAAM,sBAAsB;AAC5B,IAAM,sBAAsB;AA2E5B,IAAM,eAAe;AAAA,EAC1B,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,eAAe;AACjB;AAGO,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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;AAC5B,UAAM,QAAQ,CAAC,MAAgB;AArLnC;AAqLsC,yBAAM,cAAN,+BAAmB,EAA0B;AAAA;AAC/E,UAAM,QAAQ,CAAC,MAAgB;AAtLnC;AAsLsC,yBAAM,YAAN,+BAAiB,EAAyB;AAAA;AAC5E,UAAM,OAAO,CAAC,MAAgB;AAvLlC;AAuLqC,yBAAM,iBAAN,+BAAsB,EAAgC;AAAA;AAEvF,OAAG,iBAAiB,uBAAuB,WAAW;AACtD,OAAG,iBAAiB,qBAAqB,SAAS;AAClD,OAAG,iBAAiB,cAAc,OAAO;AACzC,OAAG,iBAAiB,YAAY,KAAK;AACrC,OAAG,iBAAiB,SAAS,KAAK;AAClC,OAAG,iBAAiB,cAAc,IAAI;AACtC,WAAO,MAAM;AACX,SAAG,oBAAoB,uBAAuB,WAAW;AACzD,SAAG,oBAAoB,qBAAqB,SAAS;AACrD,SAAG,oBAAoB,cAAc,OAAO;AAC5C,SAAG,oBAAoB,YAAY,KAAK;AACxC,SAAG,oBAAoB,SAAS,KAAK;AACrC,SAAG,oBAAoB,cAAc,IAAI;AAAA,IAC3C;AAAA,EACF,GAAG;AAAA,IACD,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR,CAAC;AAED,SAAa,oBAAc,oBAAoB;AAAA,IAC7C;AAAA,IACA,OAAO,MAAM;AAAA,IACb,OAAO,MAAM;AAAA,EACf,CAAC;AACH;;;AC5MA,sBAAsB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/widget/config.ts","../../src/widget/styles.ts","../../src/widget/recaptcha.ts","../../src/widget/markdown.ts","../../src/widget/TrilletWidgetElement.ts","../../src/widget/register.ts","../../src/widget/react.tsx","../../src/widget/index.ts"],"sourcesContent":["// Widget configuration: the attribute/prop surface (ElevenLabs-modeled) and the\n// parsing helpers that turn HTML attributes into a typed config object. This file\n// is framework-free and shared by the custom element and the React wrapper.\n\n// OUT OF SCOPE (TRI-399): default branding is BLANK / unbranded (spec §6.4).\n// Trillet's own brand values are recorded here for a FUTURE partner \"show Trillet\n// branding\" toggle only — they MUST NOT render by default:\n// logo https://www.trillet.ai/trillet-icon.png · color #1060ff · name \"Trillet\"\n\n// Internal, resolved variant. Kept as the historical two-value vocabulary; the\n// convai `tiny|compact|full` inputs are mapped down onto it (see resolveVariant).\nexport type WidgetVariant = 'compact' | 'expanded';\n// Accepted variant *inputs* — both our original vocabulary and convai's.\nexport type WidgetVariantInput = WidgetVariant | 'tiny' | 'full';\n// `both` = one widget offering BOTH modalities (convai multimodal); the end user\n// switches voice <-> text mid-session. `voice`/`text` stay single-modality.\nexport type WidgetMode = 'voice' | 'text' | 'both';\nexport type WidgetPlacement =\n | 'top-left'\n | 'top'\n | 'top-right'\n | 'bottom-left'\n | 'bottom'\n | 'bottom-right';\n\n// convai-compatible orb gradient defaults.\nexport const DEFAULT_ORB_COLOR_1 = '#2792dc';\nexport const DEFAULT_ORB_COLOR_2 = '#9ce6e6';\n\nexport type WidgetTheme = 'light' | 'dark';\n\n/**\n * The design saved in the Trillet dashboard (Widget designer), served by\n * GET /v1/api/web-call/public/widget-config. Every key is optional; HTML attributes\n * on the element always win over these, so an existing embed keeps rendering exactly\n * as written.\n */\nexport type AvatarStyle = 'orb' | 'image' | 'initials';\n\nexport interface RemoteWidgetConfig {\n avatarStyle?: AvatarStyle | null;\n orbColor1?: string | null;\n orbColor2?: string | null;\n backgroundColor?: string | null;\n textColor?: string | null;\n buttonTextColor?: string | null;\n termsText?: string | null;\n feedback?: 'none' | 'end' | null;\n mode?: WidgetMode;\n placement?: WidgetPlacement;\n variant?: WidgetVariant;\n theme?: WidgetTheme;\n brandColor?: string | null;\n brandName?: string | null;\n brandLogo?: string | null;\n avatar?: string | null;\n title?: string | null;\n launcherText?: string | null;\n greeting?: string | null;\n inputPlaceholder?: string | null;\n startCallText?: string | null;\n messageText?: string | null;\n suggestedPrompts?: string[];\n}\n\nexport interface WidgetBrand {\n logo?: string;\n primaryColor?: string;\n name?: string;\n}\n\n/**\n * Resolved, typed widget configuration. The custom element builds this from HTML\n * attributes; the React wrapper builds it from props.\n */\nexport interface WidgetConfig {\n // Required\n agentId: string;\n\n // Attribute-derived credentials only (overall priority:\n // signedUrlEndpoint/getRoomDetails > roomDetails > workspaceId). The function and\n // object forms can't come from HTML attributes, so getRoomDetails/roomDetails live\n // as properties on the element instance, not in this config.\n signedUrlEndpoint?: string;\n workspaceId?: string;\n /** API host override (whitelabel API domain, or a local backend in development). */\n apiBase?: string;\n /** Load the dashboard design on mount (default true; `remote-config=\"false\"` opts out). */\n remoteConfig: boolean;\n\n // Header identity overrides. Each takes precedence over the corresponding\n // backend-provided `display.*` value (which arrives on `connected`). Being static\n // config, they let the header title render immediately (pre-call).\n agentName?: string;\n callFlowName?: string;\n workspaceName?: string;\n\n // Appearance\n /** 'orb' (animated gradient, default), 'image' (avatar URL) or 'initials'. */\n avatarStyle?: AvatarStyle;\n avatar?: string;\n /** Legacy single accent/orb color; alias of orbColor1. */\n orbColor?: string;\n /** Gradient orb color 1 (convai `avatar-orb-color-1`). */\n orbColor1?: string;\n /** Gradient orb color 2 (convai `avatar-orb-color-2`). */\n orbColor2?: string;\n variant: WidgetVariant;\n placement: WidgetPlacement;\n dismissible: boolean;\n\n // Copy / text overrides\n actionText?: string;\n startCallText: string;\n endCallText: string;\n messageText: string;\n /** Mode \"both\" launcher: the two halves of the Call | Chat button. */\n callLabel: string;\n chatLabel: string;\n switchToTextText: string;\n switchToVoiceText: string;\n listeningText: string;\n speakingText: string;\n expandText: string;\n collapseText: string;\n recaptchaText: string;\n /** Short line shown next to the closed launcher, and under the chat header. */\n greeting?: string;\n inputPlaceholder: string;\n /** Tap-to-send starter questions, shown until the visitor sends a message. */\n suggestedPrompts: string[];\n theme: WidgetTheme;\n /** Colour overrides on top of the theme. Button colour is brand.primaryColor. */\n backgroundColor?: string;\n textColor?: string;\n buttonTextColor?: string;\n /** Markdown the visitor must accept before their first conversation. */\n termsText?: string;\n /** 'end': ask for a thumbs up/down when a conversation ends. */\n feedback: 'none' | 'end';\n\n // Behavior\n mode: WidgetMode;\n variables?: Record<string, unknown>;\n maxCallDuration?: number; // seconds\n /**\n * Optional Google reCAPTCHA v2 site key. When set, the widget renders a checkbox the\n * visitor solves once per session before the first conversation starts.\n *\n * BYO and client-only: the solved token is never sent to Trillet and never verified,\n * so this is UI friction, not bot protection. See ./recaptcha.ts. For a real gate,\n * use the core SDK's `onBeforeCall` hook and verify on your own backend.\n */\n recaptchaSiteKey?: string;\n /** convai `disable-banner` — accepted no-op (we're blank by default). */\n disableBanner: boolean;\n\n // Customer branding (default BLANK)\n brand: WidgetBrand;\n}\n\nexport const DEFAULT_COPY = {\n startCallText: 'Start a call',\n endCallText: 'End call',\n messageText: 'Message',\n switchToTextText: 'Switch to text mode',\n switchToVoiceText: 'Switch to voice mode',\n listeningText: 'Listening…',\n speakingText: 'Speaking…',\n expandText: 'Expand',\n collapseText: 'Collapse',\n recaptchaText: 'Verify you are human to start',\n inputPlaceholder: 'Type a message…',\n} as const;\n\n/** The full list of observed HTML attributes (kebab-case). */\nexport const OBSERVED_ATTRIBUTES = [\n 'agent-id',\n 'signed-url-endpoint',\n 'workspace-id',\n 'api-base',\n 'remote-config',\n 'greeting',\n 'input-placeholder',\n 'suggested-prompts',\n 'theme',\n 'bg-color',\n 'text-color',\n 'btn-text-color',\n 'terms',\n 'feedback',\n 'agent-name',\n 'call-flow-name',\n 'workspace-name',\n 'avatar',\n 'avatar-style',\n 'avatar-image-url', // convai alias -> avatar\n 'orb-color',\n 'avatar-orb-color-1',\n 'avatar-orb-color-2',\n 'variant',\n 'placement',\n 'dismissible',\n 'action-text',\n 'start-call-text',\n 'end-call-text',\n 'message-text',\n 'call-label',\n 'chat-label',\n 'switch-to-text-text',\n 'switch-to-voice-text',\n 'listening-text',\n 'speaking-text',\n 'expand-text',\n 'collapse-text',\n 'recaptcha-text',\n 'mode',\n 'variables',\n 'dynamic-variables', // convai alias -> variables\n 'max-call-duration',\n 'recaptcha-site-key',\n 'disable-banner', // convai no-op\n 'brand-logo',\n 'brand-color',\n 'brand-name',\n] as const;\n\nconst PLACEMENTS: readonly WidgetPlacement[] = [\n 'top-left',\n 'top',\n 'top-right',\n 'bottom-left',\n 'bottom',\n 'bottom-right',\n];\n\nfunction parseBoolAttr(value: string | null): boolean {\n // Presence-style boolean: dismissible | dismissible=\"\" | dismissible=\"true\" => true;\n // dismissible=\"false\" => false; absent => false.\n if (value === null) return false;\n return value !== 'false';\n}\n\nfunction parseJsonAttr(value: string | null): Record<string, unknown> | undefined {\n if (!value) return undefined;\n try {\n const parsed = JSON.parse(value);\n return parsed && typeof parsed === 'object' ? (parsed as Record<string, unknown>) : undefined;\n } catch {\n console.warn('[trillet-widget] Failed to parse JSON attribute:', value);\n return undefined;\n }\n}\n\nfunction parseNumberAttr(value: string | null): number | undefined {\n if (!value) return undefined;\n const n = Number(value);\n return Number.isFinite(n) ? n : undefined;\n}\n\nconst HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;\nfunction hexOrUndefined(value: string | null): string | undefined {\n return value && HEX.test(value.trim()) ? value.trim() : undefined;\n}\n\n/** `suggested-prompts` accepts a JSON array, or `|`-separated text for hand-written HTML. */\nfunction parsePromptsAttr(value: string | null): string[] | undefined {\n if (value === null) return undefined;\n const trimmed = value.trim();\n if (!trimmed) return [];\n if (trimmed.startsWith('[')) {\n try {\n const parsed = JSON.parse(trimmed);\n if (Array.isArray(parsed)) return parsed.map(String).map((p) => p.trim()).filter(Boolean);\n } catch {\n console.warn('[trillet-widget] Failed to parse suggested-prompts:', value);\n }\n return [];\n }\n return trimmed.split('|').map((p) => p.trim()).filter(Boolean);\n}\n\n/** Map any accepted variant vocabulary (convai `tiny|compact|full` + ours) onto the\n * internal two-value variant. `tiny`->compact (launcher-focused), `full`->expanded. */\nexport function resolveVariant(raw: string | null): WidgetVariant {\n switch (raw) {\n case 'expanded':\n case 'full':\n return 'expanded';\n case 'tiny':\n case 'compact':\n return 'compact';\n default:\n return 'compact';\n }\n}\n\n/**\n * Build a {@link WidgetConfig} from a custom element's attributes. Pure function of\n * the element's attribute map — no side effects.\n */\nexport function configFromElement(el: HTMLElement, remote?: RemoteWidgetConfig | null): WidgetConfig {\n const r: RemoteWidgetConfig = remote || {};\n // Attribute first, then the saved dashboard design, then nothing.\n const get = (name: string, fallback?: string | null): string | null =>\n el.getAttribute(name) ?? (fallback || null);\n\n const variant = resolveVariant(get('variant', r.variant));\n\n const modeRaw = get('mode', r.mode);\n const mode: WidgetMode = modeRaw === 'text' ? 'text' : modeRaw === 'both' ? 'both' : 'voice';\n\n const placementRaw = get('placement', r.placement);\n const placement: WidgetPlacement = PLACEMENTS.includes(placementRaw as WidgetPlacement)\n ? (placementRaw as WidgetPlacement)\n : 'bottom-right';\n\n // Start/end labels are mode-aware: a text session is a chat, not a \"call\". These are\n // still overridable via the start-call-text / end-call-text attributes.\n const isText = mode === 'text';\n const startDefault = r.startCallText || (isText ? 'Start chat' : DEFAULT_COPY.startCallText);\n const endDefault = isText ? 'End chat' : DEFAULT_COPY.endCallText;\n\n const brand: WidgetBrand = {};\n const brandLogo = get('brand-logo', r.brandLogo);\n const brandColor = get('brand-color', r.brandColor);\n const brandName = get('brand-name', r.brandName);\n if (brandLogo) brand.logo = brandLogo;\n if (brandColor) brand.primaryColor = brandColor;\n if (brandName) brand.name = brandName;\n\n const orbColor = get('orb-color') || undefined;\n const orbColor1 = get('avatar-orb-color-1', r.orbColor1) || orbColor || undefined;\n const orbColor2 = get('avatar-orb-color-2', r.orbColor2) || undefined;\n const styleRaw = get('avatar-style', r.avatarStyle);\n const avatarStyle: AvatarStyle | undefined =\n styleRaw === 'orb' || styleRaw === 'image' || styleRaw === 'initials' ? styleRaw : undefined;\n\n return {\n agentId: get('agent-id') || '',\n signedUrlEndpoint: get('signed-url-endpoint') || undefined,\n workspaceId: get('workspace-id') || undefined,\n apiBase: get('api-base') || undefined,\n remoteConfig: get('remote-config') !== 'false',\n // Header identity overrides — empty string/absent => treated as \"not set\".\n agentName: get('agent-name', r.title) || undefined,\n callFlowName: get('call-flow-name') || undefined,\n workspaceName: get('workspace-name') || undefined,\n // convai `avatar-image-url` is an alias of our `avatar`.\n avatarStyle,\n avatar: get('avatar') || get('avatar-image-url') || r.avatar || undefined,\n orbColor,\n orbColor1,\n orbColor2,\n variant,\n placement,\n dismissible: parseBoolAttr(get('dismissible')),\n actionText: get('action-text', r.launcherText) || undefined,\n startCallText: get('start-call-text') || startDefault,\n endCallText: get('end-call-text') || endDefault,\n messageText: get('message-text', r.messageText) || DEFAULT_COPY.messageText,\n callLabel: get('call-label') || 'Call',\n chatLabel: get('chat-label') || 'Chat',\n switchToTextText: get('switch-to-text-text') || DEFAULT_COPY.switchToTextText,\n switchToVoiceText: get('switch-to-voice-text') || DEFAULT_COPY.switchToVoiceText,\n listeningText: get('listening-text') || DEFAULT_COPY.listeningText,\n speakingText: get('speaking-text') || DEFAULT_COPY.speakingText,\n expandText: get('expand-text') || DEFAULT_COPY.expandText,\n collapseText: get('collapse-text') || DEFAULT_COPY.collapseText,\n recaptchaText: get('recaptcha-text') || DEFAULT_COPY.recaptchaText,\n greeting: get('greeting', r.greeting) || undefined,\n inputPlaceholder: get('input-placeholder', r.inputPlaceholder) || DEFAULT_COPY.inputPlaceholder,\n suggestedPrompts: parsePromptsAttr(el.getAttribute('suggested-prompts')) ?? r.suggestedPrompts ?? [],\n theme: get('theme', r.theme) === 'dark' ? 'dark' : 'light',\n backgroundColor: hexOrUndefined(get('bg-color', r.backgroundColor)),\n textColor: hexOrUndefined(get('text-color', r.textColor)),\n buttonTextColor: hexOrUndefined(get('btn-text-color', r.buttonTextColor)),\n termsText: get('terms', r.termsText) || undefined,\n feedback: get('feedback', r.feedback) === 'end' ? 'end' : 'none',\n mode,\n // convai `dynamic-variables` is an alias of our `variables`.\n variables: parseJsonAttr(get('variables') || get('dynamic-variables')),\n maxCallDuration: parseNumberAttr(get('max-call-duration')),\n recaptchaSiteKey: get('recaptcha-site-key') || undefined,\n disableBanner: parseBoolAttr(get('disable-banner')),\n brand,\n };\n}\n","// Shadow-DOM stylesheet for the widget. Injected into the shadow root, so nothing\n// leaks into (or in from) the host page except, on purpose:\n// - the host page's font (`font-family: inherit`), so the widget reads as part of\n// the customer's site;\n// - the customer's colours (--tw-accent and the optional overrides), set from\n// attributes / the dashboard design.\n//\n// Visual language follows trillet.ai: slate ink on white, hairline borders, soft\n// panels, 8px controls, restrained shadows, Trillet blue as the default accent. The\n// one expressive element is the orb, whose ring follows the agent's live voice\n// (--tw-level, written by the element from real audio).\n\nexport const WIDGET_STYLES = /* css */ `\n:host {\n position: fixed;\n right: 20px;\n bottom: 20px;\n z-index: 2147483000;\n\n --tw-accent: #0062e9;\n --tw-on-accent: #ffffff;\n --tw-surface: #ffffff;\n --tw-raised: #f7f9fc;\n --tw-ink: #1e293b;\n --tw-muted: #64748b;\n --tw-line: #e2e8f0;\n --tw-danger: #dc2626;\n --tw-online: #16a34a;\n --tw-orb-1: #0062e9;\n --tw-orb-2: #27a3fd;\n --tw-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 12px 32px -6px rgba(15, 23, 42, 0.14);\n --tw-level: 0;\n\n font-family: inherit;\n font-size: 15px;\n line-height: 1.5;\n color: var(--tw-ink);\n -webkit-font-smoothing: antialiased;\n}\n\n:host([data-theme=\"dark\"]) {\n --tw-surface: #0f1b2d;\n --tw-raised: #172437;\n --tw-ink: #e8edf4;\n --tw-muted: #94a3b8;\n --tw-line: #23324a;\n --tw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -8px rgba(0, 0, 0, 0.55);\n}\n\n:host([hidden]) { display: none; }\n\n/* ---- Placement (fixed on the host; raw CSS on the element still wins) ---- */\n:host([data-placement=\"bottom-right\"]) { top: auto; bottom: 20px; left: auto; right: 20px; }\n:host([data-placement=\"bottom-left\"]) { top: auto; bottom: 20px; right: auto; left: 20px; }\n:host([data-placement=\"bottom\"]) { top: auto; bottom: 20px; left: 50%; right: auto; transform: translateX(-50%); }\n:host([data-placement=\"top-right\"]) { bottom: auto; top: 20px; left: auto; right: 20px; }\n:host([data-placement=\"top-left\"]) { bottom: auto; top: 20px; right: auto; left: 20px; }\n:host([data-placement=\"top\"]) { bottom: auto; top: 20px; left: 50%; right: auto; transform: translateX(-50%); }\n\n* { box-sizing: border-box; }\nbutton { font: inherit; color: inherit; }\nbutton:focus-visible, textarea:focus-visible, a:focus-visible {\n outline: 2px solid var(--tw-accent);\n outline-offset: 2px;\n}\nsvg { display: block; flex-shrink: 0; }\n\n.tw-root { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }\n:host([data-placement$=\"left\"]) .tw-root { align-items: flex-start; }\n:host([data-placement=\"bottom\"]) .tw-root, :host([data-placement=\"top\"]) .tw-root { align-items: center; }\n\n/* ---- Buttons ---- */\n.tw-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n height: 40px;\n padding: 0 16px;\n border-radius: 8px;\n border: 1px solid transparent;\n font-size: 15px;\n font-weight: 600;\n white-space: nowrap;\n cursor: pointer;\n transition: background 0.15s ease, filter 0.15s ease, border-color 0.15s ease;\n}\n.tw-btn svg { width: 17px; height: 17px; }\n.tw-btn:disabled { opacity: 0.55; cursor: default; }\n.tw-btn-primary { background: var(--tw-accent); color: var(--tw-on-accent); }\n.tw-btn-primary:hover:not(:disabled) { filter: brightness(1.07); }\n.tw-btn-secondary { background: var(--tw-surface); color: var(--tw-ink); border-color: var(--tw-line); }\n.tw-btn-secondary:hover:not(:disabled) { background: var(--tw-raised); }\n.tw-btn-danger { background: var(--tw-danger); color: #fff; }\n.tw-btn-danger:hover:not(:disabled) { filter: brightness(1.07); }\n\n.tw-icon-btn {\n width: 32px;\n height: 32px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: var(--tw-muted);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n}\n.tw-icon-btn svg { width: 18px; height: 18px; }\n.tw-icon-btn:hover:not(:disabled) { background: var(--tw-raised); color: var(--tw-ink); }\n.tw-icon-btn:disabled { opacity: 0.45; cursor: default; }\n.tw-icon-btn.tw-btn-icon {\n width: 40px;\n height: 40px;\n border: 1px solid var(--tw-line);\n color: var(--tw-ink);\n}\n.tw-icon-btn.tw-muted { color: var(--tw-danger); border-color: var(--tw-danger); }\n\n/* Full-width buttons on the panel's centred screens. */\n.tw-primary-btn, .tw-secondary-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n height: 42px;\n padding: 0 18px;\n border-radius: 8px;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n}\n.tw-primary-btn svg, .tw-secondary-btn svg { width: 17px; height: 17px; }\n.tw-primary-btn { border: none; background: var(--tw-accent); color: var(--tw-on-accent); }\n.tw-primary-btn:hover:not(:disabled) { filter: brightness(1.07); }\n.tw-primary-btn:disabled { opacity: 0.5; cursor: default; }\n.tw-secondary-btn { border: 1px solid var(--tw-line); background: var(--tw-surface); color: var(--tw-ink); }\n.tw-secondary-btn:hover:not(:disabled) { background: var(--tw-raised); }\n.tw-secondary-btn.tw-small { height: 34px; padding: 0 12px; font-size: 14px; }\n\n.tw-round-btn {\n width: 48px;\n height: 48px;\n border-radius: 50%;\n border: 1px solid var(--tw-line);\n color: var(--tw-ink);\n}\n.tw-round-btn svg { width: 20px; height: 20px; }\n.tw-round-btn.tw-small-round { width: 36px; height: 36px; }\n.tw-round-btn.tw-small-round svg { width: 17px; height: 17px; }\n.tw-round-btn.tw-end-btn { background: var(--tw-danger); border-color: var(--tw-danger); color: #fff; }\n\n.tw-link-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n border: none;\n background: transparent;\n color: var(--tw-muted);\n font-size: 13px;\n padding: 4px 2px;\n cursor: pointer;\n}\n.tw-link-btn:hover:not(:disabled) { color: var(--tw-ink); }\n.tw-link-btn:disabled { opacity: 0.5; cursor: default; }\n\n/* ---- Ask bar: the resting widget (input-first) ---- */\n.tw-bar-stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }\n:host([data-placement$=\"left\"]) .tw-bar-stack { align-items: flex-start; }\n.tw-ask, .tw-callbar {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 320px;\n max-width: calc(100vw - 24px);\n padding: 6px 6px 6px 10px;\n background: var(--tw-surface);\n border: 1px solid var(--tw-line);\n border-radius: 12px;\n box-shadow: var(--tw-shadow);\n transition: border-color 0.15s ease, box-shadow 0.15s ease;\n}\n.tw-ask:focus-within { border-color: var(--tw-accent); }\n.tw-ask-form { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; margin: 0; }\n.tw-ask-input {\n flex: 1;\n min-width: 0;\n border: none;\n outline: none;\n background: transparent;\n color: var(--tw-ink);\n font: inherit;\n font-size: 15px;\n padding: 6px 4px;\n}\n.tw-ask-input::placeholder { color: var(--tw-muted); }\n.tw-ask-input:focus-visible { outline: none; }\n.tw-ask-label {\n flex: 1;\n min-width: 0;\n border: none;\n background: transparent;\n text-align: left;\n font-size: 15px;\n padding: 6px 4px;\n color: var(--tw-ink);\n cursor: pointer;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.tw-ask-suggestions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 320px; }\n:host([data-placement$=\"left\"]) .tw-ask-suggestions { justify-content: flex-start; }\n.tw-ask-suggestions .tw-suggestion { box-shadow: var(--tw-shadow); }\n.tw-bar-note {\n max-width: 320px;\n padding: 7px 12px;\n font-size: 13px;\n background: var(--tw-surface);\n border: 1px solid var(--tw-line);\n border-radius: 10px;\n box-shadow: var(--tw-shadow);\n}\n\n/* Square icon actions. accent = send / call, quiet = mic etc., danger = hang up. */\n.tw-icon-btn.tw-sq { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; }\n.tw-icon-btn.tw-sq svg { width: 17px; height: 17px; }\n.tw-icon-btn.tw-sq-accent, .tw-icon-btn.tw-sq-accent:hover:not(:disabled) { background: var(--tw-accent); color: var(--tw-on-accent); }\n.tw-icon-btn.tw-sq-accent:hover:not(:disabled) { filter: brightness(1.08); }\n.tw-icon-btn.tw-sq-accent:disabled { opacity: 0.35; }\n.tw-icon-btn.tw-sq-quiet { color: var(--tw-ink); }\n.tw-icon-btn.tw-sq-danger, .tw-icon-btn.tw-sq-danger:hover:not(:disabled) { background: var(--tw-danger); color: #fff; }\n.tw-icon-btn.tw-sq-danger:hover:not(:disabled) { filter: brightness(1.08); }\n.tw-icon-btn.tw-sq.tw-muted { color: var(--tw-danger); }\n\n/* ---- Call bar ---- */\n.tw-callbar { gap: 10px; padding-left: 12px; }\n.tw-callbar-inline { width: auto; margin: 0 12px; box-shadow: none; animation: none; }\n.tw-callbar-text { flex: 1; min-width: 0; }\n.tw-callbar-activity { font-size: 14px; font-weight: 600; line-height: 1.25; }\n.tw-callbar-meta {\n font-size: 12px;\n color: var(--tw-muted);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n/* The waveform: five bars whose height follows the agent's live voice level. */\n.tw-wave { display: inline-flex; align-items: center; gap: 3px; height: 24px; flex-shrink: 0; }\n.tw-wave i {\n display: block;\n width: 3px;\n border-radius: 2px;\n background: var(--tw-accent);\n height: calc(5px + var(--tw-level) * 19px);\n transition: height 0.08s linear;\n}\n.tw-wave i:nth-child(1), .tw-wave i:nth-child(5) { height: calc(4px + var(--tw-level) * 9px); }\n.tw-wave i:nth-child(2), .tw-wave i:nth-child(4) { height: calc(5px + var(--tw-level) * 15px); }\n.tw-wave:not(.tw-wave-speaking) i { opacity: 0.55; }\n\n/* ---- Mark: who the visitor talks to ---- */\n.tw-mark {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n border-radius: 7px;\n background: var(--tw-accent);\n color: var(--tw-on-accent);\n font-weight: 600;\n background-size: cover;\n background-position: center;\n}\n.tw-mark-sm { width: 24px; height: 24px; font-size: 11px; border-radius: 6px; }\n.tw-mark-md { width: 26px; height: 26px; font-size: 12px; }\n.tw-mark-lg { width: 56px; height: 56px; font-size: 20px; border-radius: 14px; }\n.tw-mark-orb { background: linear-gradient(135deg, var(--tw-orb-1), var(--tw-orb-2)); }\n\n/* Terms dialog keeps a small card. */\n.tw-card {\n display: flex;\n flex-direction: column;\n gap: 14px;\n max-width: calc(100vw - 24px);\n padding: 16px;\n background: var(--tw-surface);\n border: 1px solid var(--tw-line);\n border-radius: 12px;\n box-shadow: var(--tw-shadow);\n}\n.tw-card-title { font-size: 15px; font-weight: 600; }\n.tw-card-actions { display: flex; gap: 8px; }\n.tw-inline-hint { font-size: 13px; color: var(--tw-muted); }\n\n/* ---- Panel ---- */\n.tw-panel {\n width: 380px;\n height: min(600px, calc(100vh - 40px));\n max-width: calc(100vw - 24px);\n display: flex;\n flex-direction: column;\n background: var(--tw-surface);\n border: 1px solid var(--tw-line);\n border-radius: 14px;\n box-shadow: var(--tw-shadow);\n overflow: hidden;\n}\n.tw-panel.tw-expanded { width: 420px; height: min(680px, calc(100vh - 40px)); }\n\n.tw-header {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px 10px 12px 14px;\n border-bottom: 1px solid var(--tw-line);\n}\n.tw-who { flex: 1; min-width: 0; }\n.tw-header-title {\n font-size: 15px;\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.tw-status {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n color: var(--tw-muted);\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n}\n.tw-status.tw-online::before {\n content: '';\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--tw-online);\n}\n.tw-brand-logo { height: 22px; max-width: 72px; object-fit: contain; }\n.tw-header-actions { display: flex; gap: 2px; }\n\n.tw-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }\n.tw-center-body {\n align-items: center;\n justify-content: center;\n gap: 12px;\n padding: 24px;\n text-align: center;\n}\n.tw-prompt { margin: 4px 0 0; font-size: 16px; font-weight: 600; max-width: 260px; }\n.tw-timer { font-size: 13px; color: var(--tw-muted); font-variant-numeric: tabular-nums; }\n.tw-error-text { color: var(--tw-danger); }\n.tw-choices, .tw-controls { display: flex; gap: 8px; width: 100%; justify-content: center; }\n.tw-choices { flex-direction: column; max-width: 240px; margin-top: 4px; }\n\n/* ---- Chat ---- */\n.tw-chat {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 16px 14px 8px;\n scroll-behavior: smooth;\n}\n.tw-msg {\n max-width: 84%;\n padding: 8px 12px;\n border-radius: 10px;\n font-size: 15px;\n line-height: 1.5;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n.tw-msg.tw-run { margin-top: -2px; }\n.tw-msg.tw-assistant {\n align-self: flex-start;\n background: var(--tw-raised);\n border: 1px solid var(--tw-line);\n color: var(--tw-ink);\n}\n.tw-msg-label { font-size: 11px; color: var(--tw-muted); margin-bottom: 1px; }\n.tw-msg.tw-user {\n align-self: flex-end;\n background: var(--tw-accent);\n color: var(--tw-on-accent);\n}\n.tw-msg.tw-typing { display: inline-flex; gap: 4px; padding: 12px 13px; }\n.tw-msg.tw-typing span {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--tw-muted);\n animation: tw-typing 1.2s infinite ease-in-out;\n}\n.tw-msg.tw-typing span:nth-child(2) { animation-delay: 0.15s; }\n.tw-msg.tw-typing span:nth-child(3) { animation-delay: 0.3s; }\n\n.tw-suggestions {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: 6px;\n padding: 2px 14px 10px;\n}\n.tw-suggestion {\n border: 1px solid var(--tw-line);\n background: var(--tw-surface);\n color: var(--tw-ink);\n border-radius: 8px;\n padding: 6px 11px;\n font-size: 14px;\n text-align: left;\n cursor: pointer;\n}\n.tw-suggestion:hover { border-color: var(--tw-accent); color: var(--tw-accent); }\n\n.tw-composer {\n display: flex;\n align-items: flex-end;\n gap: 6px;\n margin: 0 12px;\n padding: 5px 5px 5px 12px;\n border: 1px solid var(--tw-line);\n border-radius: 10px;\n background: var(--tw-surface);\n transition: border-color 0.15s ease;\n}\n.tw-composer:focus-within { border-color: var(--tw-accent); }\n.tw-text-input {\n flex: 1;\n min-width: 0;\n border: none;\n outline: none;\n resize: none;\n background: transparent;\n color: var(--tw-ink);\n font: inherit;\n font-size: 15px;\n line-height: 1.4;\n padding: 7px 0;\n max-height: 112px;\n}\n.tw-text-input:focus-visible { outline: none; }\n.tw-text-input::placeholder { color: var(--tw-muted); }\n.tw-send-btn {\n width: 34px;\n height: 34px;\n flex-shrink: 0;\n border: none;\n border-radius: 8px;\n background: var(--tw-accent);\n color: var(--tw-on-accent);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n}\n.tw-send-btn svg { width: 17px; height: 17px; }\n.tw-send-btn:disabled { opacity: 0.35; cursor: default; }\n.tw-composer .tw-composer-mic { width: 34px; height: 34px; }\n\n.tw-voice-bar {\n display: flex;\n align-items: center;\n gap: 10px;\n margin: 0 12px;\n padding: 8px 8px 8px 10px;\n border: 1px solid var(--tw-line);\n border-radius: 10px;\n background: var(--tw-raised);\n}\n.tw-voice-bar-text { flex: 1; min-width: 0; }\n.tw-voice-bar-activity { font-size: 14px; font-weight: 600; }\n.tw-voice-bar .tw-timer { font-size: 12px; }\n\n.tw-notice {\n margin: 0 12px 8px;\n padding: 8px 12px;\n border-radius: 8px;\n border: 1px solid color-mix(in srgb, var(--tw-danger) 35%, var(--tw-line));\n background: color-mix(in srgb, var(--tw-danger) 6%, var(--tw-surface));\n font-size: 13px;\n}\n\n.tw-chat-footer {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n min-height: 30px;\n padding: 2px 14px 6px;\n}\n.tw-chat-ended {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n margin: 4px 12px 12px;\n padding: 10px 12px;\n border-radius: 10px;\n border: 1px solid var(--tw-line);\n background: var(--tw-raised);\n font-size: 14px;\n color: var(--tw-muted);\n}\n\n.tw-recaptcha-slot { display: flex; justify-content: center; }\n\n/* ---- Markdown in agent messages / terms ---- */\n.tw-md { white-space: normal; }\n.tw-md p { margin: 0; }\n.tw-md p + p, .tw-md p + ul, .tw-md p + ol, .tw-md ul + p, .tw-md ol + p { margin-top: 8px; }\n.tw-md ul, .tw-md ol { margin: 0; padding-left: 20px; }\n.tw-md li + li { margin-top: 2px; }\n.tw-md a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }\n.tw-md code {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-size: 0.88em;\n padding: 1px 4px;\n border-radius: 4px;\n background: color-mix(in srgb, var(--tw-ink) 7%, transparent);\n}\n\n/* ---- Terms gate ---- */\n.tw-terms { width: 320px; }\n.tw-terms-body {\n max-height: 220px;\n overflow-y: auto;\n font-size: 14px;\n color: var(--tw-muted);\n}\n.tw-terms .tw-pill {\n flex: 1;\n height: 40px;\n border: none;\n border-radius: 8px;\n background: var(--tw-accent);\n color: var(--tw-on-accent);\n font-weight: 600;\n cursor: pointer;\n}\n.tw-terms .tw-secondary-btn { height: 40px; }\n\n/* ---- Feedback ---- */\n.tw-feedback {\n display: flex;\n align-items: center;\n gap: 2px;\n font-size: 13px;\n color: var(--tw-muted);\n}\n.tw-feedback span { margin-right: 6px; }\n.tw-body .tw-feedback { padding: 0 14px 12px; }\n\n/* ---- Motion ---- */\n@keyframes tw-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }\n@keyframes tw-breathe { 0%, 100% { transform: scale(1.04); } 50% { transform: scale(1.16); } }\n@keyframes tw-typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }\n@keyframes tw-spin { to { transform: rotate(360deg); } }\n.tw-spin { transform-origin: 12px 12px; animation: tw-spin 0.9s linear infinite; }\n\n@media (prefers-reduced-motion: reduce) {\n .tw-enter, .tw-msg.tw-typing span, .tw-spin { animation: none; }\n .tw-wave i { transition: none; }\n}\n\n/* Phones: the open panel takes the screen width. */\n@media (max-width: 480px) {\n :host { right: 12px; bottom: 12px; }\n .tw-panel, .tw-panel.tw-expanded { width: calc(100vw - 24px); height: calc(100vh - 24px); }\n}\n\n.tw-enter { animation: tw-rise 0.2s ease-out both; }\n\n.tw-hidden { display: none !important; }\n`;\n","// Optional BYO reCAPTCHA v2 checkbox for <trillet-widget> (TRI-400).\n//\n// THIS IS NOT A SECURITY CONTROL. The solved token is never sent to Trillet and is\n// never verified — no `siteverify`, no `createAssessment`, by design. A reCAPTCHA\n// token that nobody validates proves nothing, so this provides exactly zero bot\n// protection by construction. It is UI friction: it deters a casual script pointed at\n// a customer's embedded widget, and nothing more.\n//\n// What actually protects the customer's wallet is server-side: the per-workspace\n// domain allowlist and the rate limits on /web-call/public. If you are reaching for\n// this to stop abuse, you want `onBeforeCall` instead — that hook lets you run your\n// own challenge and verify it on your own backend before the call starts.\n\nconst RECAPTCHA_SCRIPT_SRC = 'https://www.google.com/recaptcha/api.js?render=explicit';\n\ninterface GrecaptchaRenderParams {\n sitekey: string;\n callback: (token: string) => void;\n 'expired-callback': () => void;\n 'error-callback': () => void;\n}\n\ninterface Grecaptcha {\n render: (container: HTMLElement, params: GrecaptchaRenderParams) => number;\n ready: (cb: () => void) => void;\n}\n\nfunction getGrecaptcha(): Grecaptcha | undefined {\n return (window as unknown as { grecaptcha?: Grecaptcha }).grecaptcha;\n}\n\n// One script tag per page, shared by every widget instance on it.\nlet scriptPromise: Promise<void> | null = null;\n\nfunction injectScript(): Promise<void> {\n if (scriptPromise) return scriptPromise;\n\n scriptPromise = new Promise<void>((resolve, reject) => {\n const existing = document.querySelector<HTMLScriptElement>(\n `script[src=\"${RECAPTCHA_SCRIPT_SRC}\"]`\n );\n if (existing) {\n resolve();\n return;\n }\n\n const script = document.createElement('script');\n script.src = RECAPTCHA_SCRIPT_SRC;\n script.async = true;\n script.defer = true;\n script.onload = (): void => resolve();\n script.onerror = (): void => {\n // Let a later attempt retry rather than caching the failure forever.\n scriptPromise = null;\n reject(new Error('Failed to load Google reCAPTCHA'));\n };\n document.head.appendChild(script);\n });\n\n return scriptPromise;\n}\n\n/** Load api.js and wait until `grecaptcha.render` is actually callable. */\nexport async function loadRecaptcha(): Promise<Grecaptcha> {\n await injectScript();\n\n const grecaptcha = getGrecaptcha();\n if (!grecaptcha) throw new Error('reCAPTCHA loaded but grecaptcha is undefined');\n\n // onload fires before the library finishes initializing; `ready` is the documented\n // way to wait for `render` to exist.\n await new Promise<void>((resolve) => grecaptcha.ready(resolve));\n return grecaptcha;\n}\n\nexport interface RenderCheckboxOptions {\n container: HTMLElement;\n siteKey: string;\n /** Fired once the visitor solves the challenge. The token is deliberately ignored. */\n onSolved: () => void;\n /** Fired when a solved challenge times out, or the challenge itself errors. */\n onExpired: () => void;\n}\n\n/**\n * Render the v2 checkbox into `container` and resolve with its widget id.\n *\n * `container` lives inside the widget's shadow root. The checkbox iframe renders in\n * place; the challenge dialog (when Google decides to show one) is appended to\n * document.body, outside the shadow tree, which is why it is not affected by the\n * widget's encapsulated styles.\n */\nexport async function renderRecaptchaCheckbox(options: RenderCheckboxOptions): Promise<number> {\n const grecaptcha = await loadRecaptcha();\n\n return grecaptcha.render(options.container, {\n sitekey: options.siteKey,\n // The token is received and dropped on the floor — see the header note.\n callback: () => options.onSolved(),\n 'expired-callback': () => options.onExpired(),\n 'error-callback': () => options.onExpired(),\n });\n}\n","// Minimal, safe markdown for agent chat messages (and the terms text).\n//\n// Builds DOM nodes directly, never innerHTML, so model output cannot inject markup.\n// Supported: paragraphs, line breaks, - / * / 1. lists, **bold**, *italic*, `code`,\n// [label](https://…) and bare https:// links. Links open in a new tab and only http(s)\n// is ever linked; anything else renders as plain text. Partial input (a reply still\n// streaming in) renders fine: an unclosed ** simply shows as text until it closes.\n\nconst INLINE = /(\\*\\*[^*\\n]+\\*\\*|\\*[^*\\n]+\\*|`[^`\\n]+`|\\[[^\\]\\n]+\\]\\((?:https?:\\/\\/)[^)\\s]+\\)|https?:\\/\\/[^\\s<]+[^\\s<.,;:!?)\\]])/g;\n\nfunction safeHref(raw: string): string | null {\n try {\n const url = new URL(raw);\n return url.protocol === 'https:' || url.protocol === 'http:' ? url.toString() : null;\n } catch {\n return null;\n }\n}\n\nfunction link(text: string, href: string): HTMLElement | Text {\n const safe = safeHref(href);\n if (!safe) return document.createTextNode(text);\n const a = document.createElement('a');\n a.href = safe;\n a.target = '_blank';\n a.rel = 'noopener noreferrer nofollow';\n a.textContent = text;\n return a;\n}\n\nfunction appendInline(parent: HTMLElement, text: string): void {\n let last = 0;\n for (const match of text.matchAll(INLINE)) {\n const token = match[0];\n const index = match.index ?? 0;\n if (index > last) parent.appendChild(document.createTextNode(text.slice(last, index)));\n if (token.startsWith('**')) {\n const strong = document.createElement('strong');\n strong.textContent = token.slice(2, -2);\n parent.appendChild(strong);\n } else if (token.startsWith('`')) {\n const code = document.createElement('code');\n code.textContent = token.slice(1, -1);\n parent.appendChild(code);\n } else if (token.startsWith('[')) {\n const label = token.slice(1, token.indexOf(']('));\n const href = token.slice(token.indexOf('](') + 2, -1);\n parent.appendChild(link(label, href));\n } else if (token.startsWith('*')) {\n const em = document.createElement('em');\n em.textContent = token.slice(1, -1);\n parent.appendChild(em);\n } else {\n parent.appendChild(link(token, token));\n }\n last = index + token.length;\n }\n if (last < text.length) parent.appendChild(document.createTextNode(text.slice(last)));\n}\n\n/** Render `source` as safe markdown into a fragment. */\nexport function renderMarkdown(source: string): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const blocks = source.replace(/\\r\\n/g, '\\n').split(/\\n{2,}/);\n\n for (const block of blocks) {\n const lines = block.split('\\n').filter((l) => l.trim() !== '');\n if (!lines.length) continue;\n\n const bullet = /^\\s*[-*•]\\s+/;\n const numbered = /^\\s*\\d+[.)]\\s+/;\n if (lines.every((l) => bullet.test(l)) || lines.every((l) => numbered.test(l))) {\n const ordered = numbered.test(lines[0]);\n const list = document.createElement(ordered ? 'ol' : 'ul');\n for (const line of lines) {\n const li = document.createElement('li');\n appendInline(li, line.replace(ordered ? numbered : bullet, ''));\n list.appendChild(li);\n }\n fragment.appendChild(list);\n continue;\n }\n\n const p = document.createElement('p');\n lines.forEach((line, i) => {\n if (i > 0) p.appendChild(document.createElement('br'));\n appendInline(p, line);\n });\n fragment.appendChild(p);\n }\n return fragment;\n}\n","// <trillet-widget> custom element — the self-mounting, shadow-DOM drop-in widget.\n//\n// This is a THIN UI layer over the existing secure core. All call lifecycle is\n// delegated to an internal `TrilletAgent` instance; no call logic is reimplemented\n// here. The element parses config from HTML attributes, renders an isolated UI into\n// a shadow root, and maps `TrilletAgent` events -> UI state + DOM CustomEvents.\n//\n// Voice mode (the default embed) never opens a panel. The floating control starts\n// the call and, while the call is live, becomes the hang-up control. Text and\n// multimodal modes still use the conversation panel, because those sessions need\n// a message surface.\n\nimport { TrilletAgent } from '../index.js';\nimport type { TrilletRoomDetails } from '../createCall.js';\nimport type { Transcript } from '../TranscriptManager.js';\nimport { apiUrl } from '../createCall.js';\nimport {\n WidgetConfig,\n RemoteWidgetConfig,\n configFromElement,\n OBSERVED_ATTRIBUTES,\n} from './config.js';\nimport { WIDGET_STYLES } from './styles.js';\nimport { renderRecaptchaCheckbox } from './recaptcha.js';\nimport { renderMarkdown } from './markdown.js';\n\ntype WidgetState = 'idle' | 'connecting' | 'live' | 'ended';\n// The modality actually running in the live session. In `mode=\"both\"` this is chosen\n// by the user (entry point / switch control); in single-modality modes it mirrors the\n// configured mode. `null` = no modality picked yet (pre-call `both` panel).\ntype ActiveMode = 'voice' | 'text';\n// What the backend/agent runs: mode=\"both\" is ONE multimodal session the visitor can\n// type or talk in, switching any time without losing the conversation.\ntype SessionMode = 'voice' | 'text' | 'multimodal';\n\nexport class TrilletWidgetElement extends HTMLElement {\n static get observedAttributes(): readonly string[] {\n return OBSERVED_ATTRIBUTES;\n }\n\n private root: ShadowRoot;\n private config!: WidgetConfig;\n private agent: TrilletAgent | null = null;\n private state: WidgetState = 'idle';\n private open = false; // panel open vs. launcher only\n private micEnabled = true;\n private speaking = false;\n private transcripts: Transcript[] = [];\n // Human-facing identity of who the user is talking to, delivered on the\n // `connected` event. Drives the header title. Null until a session connects.\n private display: TrilletRoomDetails['display'] | null = null;\n\n // Chosen modality for the current/next session. Only meaningful for mode=\"both\";\n // in voice/text modes resolvedMode() ignores it.\n private activeMode: ActiveMode | null = null;\n // True while tearing down one modality and reconnecting in the other, so lifecycle\n // events (call-start/conversationStarted) aren't re-emitted for an internal switch.\n private switching = false;\n\n // Dashboard design (Widget designer), fetched on mount unless remote-config=\"false\".\n // Attributes always win over it; see configFromElement.\n private remote: RemoteWidgetConfig | null = null;\n private remoteDisplay: TrilletRoomDetails['display'] | null = null;\n private remoteLoadedFor: string | null = null;\n // A suggested prompt clicked before the chat finished connecting; sent on connect.\n private pendingMessage: string | null = null;\n\n // JS-only credential path (cannot be set via HTML attribute). Set by the React\n // wrapper or imperative consumers via properties. Receives the modality being\n // started, so a minting endpoint can create a voice or a text session.\n public getRoomDetails?: (context: {\n /** The side the conversation starts on. */\n mode: ActiveMode;\n /** Session type to mint: `multimodal` for mode=\"both\" (type or talk). */\n session: SessionMode;\n }) => Promise<TrilletRoomDetails> | TrilletRoomDetails;\n public roomDetails?: TrilletRoomDetails;\n\n // maxCallDuration countdown (UX only — see startConversation()).\n private durationTimer: ReturnType<typeof setInterval> | null = null;\n private remainingSeconds: number | null = null;\n private elapsedSeconds = 0;\n\n // BYO reCAPTCHA gate (opt-in via recaptcha-site-key). A ONE-TIME gate per session:\n // once solved, it stays solved for the life of this element, so the visitor can\n // start, end and restart conversations without being re-challenged. Never reset on\n // call end — re-challenging per call is friction that buys nothing, since the token\n // is never verified. See ./recaptcha.ts.\n //\n // The checkbox is rendered into a LIGHT-DOM node projected into the panel via a\n // <slot>, not directly in the shadow root. reCAPTCHA v2's anchor iframe hangs on its\n // loading spinner inside a shadow root — its init handshake can't complete across the\n // shadow boundary (verified). Slotting keeps the checkbox in the light DOM (where it\n // works) while displaying it inside the panel. See ensureRecaptchaSlot().\n private recaptchaSolved = false;\n private recaptchaSlot: HTMLDivElement | null = null;\n private recaptchaWidgetId: number | null = null;\n\n private styleEl: HTMLStyleElement;\n private container: HTMLDivElement;\n\n constructor() {\n super();\n this.root = this.attachShadow({ mode: 'open' });\n this.styleEl = document.createElement('style');\n this.styleEl.textContent = WIDGET_STYLES;\n this.container = document.createElement('div');\n this.container.className = 'tw-root';\n this.root.appendChild(this.styleEl);\n this.root.appendChild(this.container);\n }\n\n connectedCallback(): void {\n this.refreshConfig();\n void this.loadRemoteConfig();\n }\n\n private refreshConfig(): void {\n this.config = configFromElement(this, this.remote);\n this.syncActiveMode();\n this.applyTheme();\n this.render();\n }\n\n /**\n * Fetch the design saved in the dashboard. Best-effort: on any failure the widget\n * keeps rendering from its attributes, exactly as before this existed.\n */\n private async loadRemoteConfig(): Promise<void> {\n const { agentId, remoteConfig, apiBase } = this.config;\n if (!remoteConfig || !agentId || this.remoteLoadedFor === agentId) return;\n this.remoteLoadedFor = agentId;\n try {\n const url = `${apiUrl('/v1/api/web-call/public/widget-config', apiBase)}?agent_id=${encodeURIComponent(agentId)}`;\n const res = await fetch(url, { headers: { Accept: 'application/json' } });\n if (!res.ok) return;\n const data = (await res.json()) as {\n widget?: RemoteWidgetConfig;\n display?: TrilletRoomDetails['display'];\n };\n if (this.config.agentId !== agentId) return; // agent changed while loading\n this.remote = data.widget ?? null;\n this.remoteDisplay = data.display ?? null;\n // Don't yank the UI out from under a live session; it applies on the next one.\n if (this.state === 'idle') this.refreshConfig();\n } catch (error) {\n console.warn('[trillet-widget] Could not load widget design; using attributes only', error);\n }\n }\n\n disconnectedCallback(): void {\n this.clearDurationTimer();\n this.teardownAgent();\n this.removeRecaptchaSlot();\n }\n\n attributeChangedCallback(): void {\n if (!this.isConnected) return;\n // Re-derive config on any attribute change (reactivity), preserving JS-only props.\n this.refreshConfig();\n void this.loadRemoteConfig();\n }\n\n /**\n * Send a chat message as the visitor (text sessions). Opens and starts the chat\n * first when needed; the message is delivered as soon as the session connects.\n */\n public async sendMessage(text: string): Promise<void> {\n const message = text.trim();\n if (!message) return;\n if (this.state === 'live' && (this.resolvedMode() === 'text' || this.config.mode === 'both')) {\n await this.agent?.sendTextMessage(message);\n return;\n }\n if (this.config.mode === 'voice') return;\n if (this.state === 'idle' || this.state === 'ended') this.transcripts = [];\n this.pendingMessage = message;\n if (this.state !== 'connecting') await this.startConversation('text');\n }\n\n // ---- Public element API ----------------------------------------------------\n\n /**\n * Imperatively start a conversation. Primary headless API (convai-aligned).\n * @param modality - optional; only used in `mode=\"both\"` to pick voice vs text.\n */\n public async startConversation(modality?: ActiveMode): Promise<void> {\n if (this.state === 'connecting' || this.state === 'live') return;\n\n // Text and multimodal sessions still reveal their conversation surface so a\n // visitor can see the reCAPTCHA gate or the chat. Voice stays on the floating\n // control — opening that surface is the modal this embed used to show.\n const chat = this.config.mode === 'text' || (this.config.mode === 'both' && modality !== 'voice');\n if (chat) {\n this.open = true;\n }\n\n // An unsolved reCAPTCHA gate blocks the imperative API too, not just the button —\n // otherwise the gate is one `document.querySelector(...).startConversation()` away\n // from irrelevant.\n if (this.needsRecaptcha()) {\n this.render();\n return;\n }\n\n await this.beginCall(modality);\n }\n\n /** Imperatively end the active conversation. Primary headless API. */\n public endConversation(): void {\n this.agent?.endCall();\n }\n\n /** @deprecated Use {@link startConversation}. Kept as a thin alias for back-compat. */\n public startCall(): Promise<void> {\n return this.startConversation();\n }\n\n /** @deprecated Use {@link endConversation}. Kept as a thin alias for back-compat. */\n public endCall(): void {\n this.endConversation();\n }\n\n // ---- Modality helpers ------------------------------------------------------\n\n\n /** The concrete modality to run for the current session (`both` -> activeMode). */\n private resolvedMode(): ActiveMode {\n if (this.config.mode === 'both') return this.activeMode ?? 'voice';\n return this.config.mode as ActiveMode; // 'voice' | 'text'\n }\n\n /** Keep activeMode consistent with the configured mode. */\n private syncActiveMode(): void {\n if (this.config.mode === 'voice' || this.config.mode === 'text') {\n this.activeMode = this.config.mode;\n }\n // mode=\"both\": leave activeMode as-is (null pre-call, chosen at entry / switch).\n }\n\n /** Tear down the current agent cleanly: detach listeners, end the call, drop the ref. */\n private teardownAgent(): void {\n if (!this.agent) return;\n try {\n this.agent.removeAllListeners();\n } catch {\n /* noop */\n }\n try {\n this.agent.endCall();\n } catch {\n /* noop */\n }\n this.agent = null;\n }\n\n /**\n * Switch between typing and talking (mode=\"both\"). Same session, same conversation:\n * the SDK turns the mic on/off and asks the agent to turn its speech on/off. If the\n * mic is refused, the conversation simply stays in text and says why.\n */\n private async switchModality(): Promise<void> {\n if (this.config.mode !== 'both' || this.state !== 'live' || !this.agent) return;\n const toVoice = this.resolvedMode() === 'text';\n this.notice = null;\n this.switchingSide = true;\n this.render();\n try {\n await this.agent.setVoiceEnabled(toVoice);\n } catch (error) {\n console.warn('[trillet-widget] Could not switch modality', error);\n this.notice = toVoice\n ? 'Could not turn on your microphone. Check the browser permission and try again.'\n : 'Could not switch back to typing. Please try again.';\n } finally {\n this.switchingSide = false;\n this.render();\n }\n }\n\n private pendingTimer: ReturnType<typeof setTimeout> | null = null;\n\n /**\n * Listening <-> Speaking flips several times a second at turn edges. Patch the few\n * nodes that show it instead of re-rendering, which would rebuild (and flash) the UI.\n */\n private setSpeaking(speaking: boolean): void {\n if (this.speaking === speaking) return;\n this.speaking = speaking;\n const activity = speaking ? this.config.speakingText : this.config.listeningText;\n this.root.querySelectorAll('.tw-callbar-activity').forEach((el) => {\n el.textContent = activity;\n });\n this.root.querySelectorAll('.tw-wave').forEach((el) => el.classList.toggle('tw-wave-speaking', speaking));\n this.root.querySelectorAll('.tw-mark').forEach((el) => el.classList.toggle('tw-speaking', speaking));\n const status = this.root.querySelector('.tw-header .tw-status');\n if (status) status.textContent = this.statusText();\n }\n\n // Which top-level view is on screen; the entrance animation only plays on a change.\n private lastView: string | null = null;\n\n /** Send the message typed before the chat started (once). */\n private flushPending(): void {\n if (this.pendingTimer) clearTimeout(this.pendingTimer);\n this.pendingTimer = null;\n const queued = this.pendingMessage;\n this.pendingMessage = null;\n if (queued && this.agent && this.state === 'live') void this.agent.sendTextMessage(queued);\n }\n\n // Inline notice in the chat (e.g. microphone refused). Cleared on the next switch.\n private notice: string | null = null;\n private switchingSide = false;\n\n // ---- Credential resolution + call lifecycle --------------------------------\n\n private async beginCall(modality?: ActiveMode): Promise<void> {\n // Terms gate: the first conversation waits for the visitor to accept.\n if (this.config.termsText && !this.termsAccepted()) {\n this.pendingStart = modality ?? this.resolvedMode();\n this.showTerms = true;\n this.render();\n return;\n }\n this.feedbackState = 'hidden';\n if (modality) this.activeMode = modality;\n const mode = this.resolvedMode();\n const session: SessionMode = this.config.mode === 'both' ? 'multimodal' : mode;\n this.notice = null;\n // Fresh start: clear any stale identity so the header title doesn't carry over\n // from a previous session. A modality switch (this.switching) keeps it.\n if (!this.switching) this.display = null;\n this.setState('connecting');\n\n try {\n // Construct inside the try: the TrilletAgent constructor throws synchronously\n // on a non-secure context or missing agentId, and that must surface through\n // handleError (not escape as an unhandled rejection that strands 'connecting').\n const agent = new TrilletAgent({\n agentId: this.config.agentId,\n workspaceId: this.config.workspaceId,\n apiBaseUrl: this.config.apiBase,\n mode: session,\n startWithVoice: session === 'multimodal' && mode === 'voice',\n variables: this.config.variables,\n });\n this.agent = agent;\n this.wireAgentEvents(agent);\n\n // Credential path resolution (priority order, spec §5).\n if (this.config.signedUrlEndpoint || this.getRoomDetails) {\n // Secure DEFAULT — minted at call-start, not at mount, to avoid token expiry.\n let details: TrilletRoomDetails;\n if (this.getRoomDetails) {\n details = await this.getRoomDetails({ mode, session });\n } else {\n const res = await fetch(this.config.signedUrlEndpoint as string, {\n method: 'GET',\n headers: { Accept: 'application/json' },\n });\n if (!res.ok) {\n throw new Error(`signed-url-endpoint returned ${res.status}`);\n }\n details = (await res.json()) as TrilletRoomDetails;\n }\n await agent.joinRoom(details);\n } else if (this.roomDetails) {\n // Secure static — token may expire between mount and click.\n await agent.joinRoom(this.roomDetails);\n } else if (this.config.workspaceId) {\n // Public fallback (legacy).\n await agent.startPublicCall();\n } else {\n throw new Error(\n 'No credential path configured: set signed-url-endpoint, roomDetails/getRoomDetails, or workspace-id'\n );\n }\n } catch (error) {\n // Agent already emits 'error' for its own failures; the catch here covers\n // credential-resolution failures too. wireAgentEvents handles UI + DOM event.\n this.handleError(error);\n }\n }\n\n private wireAgentEvents(agent: TrilletAgent): void {\n agent.on('connected', (details?: { display?: TrilletRoomDetails['display']; callId?: string }) => {\n // Capture who the user is talking to so the header title can render it.\n this.display = details?.display ?? null;\n this.callId = details?.callId ?? null;\n const wasSwitching = this.switching;\n this.setState('live'); // reads this.switching to suppress start events on a switch\n this.startDurationTimer(!wasSwitching); // keep the running timer across a switch\n this.switching = false;\n // A message typed before the chat existed goes out after the agent's welcome,\n // so the thread reads in order. Fallback for flows that open with silence.\n if (this.pendingMessage) {\n this.pendingTimer = setTimeout(() => this.flushPending(), 25000);\n }\n });\n\n agent.on('disconnected', () => {\n this.endLocalCall();\n });\n\n agent.on('error', (error: unknown) => {\n this.handleError(error);\n });\n\n // Type-or-talk: the visitor switched sides within the same conversation.\n agent.on('modalityChanged', (side: ActiveMode) => {\n this.activeMode = side;\n this.speaking = false;\n this.dispatch('modality', side);\n this.render();\n });\n\n // Live agent audio level drives the presence ring (voice only).\n agent.on('audioData', (samples: Float32Array) => this.setLevel(samples));\n\n agent.on('assistantStartedSpeaking', () => this.setSpeaking(true));\n agent.on('assistantStoppedSpeaking', () => this.setSpeaking(false));\n\n agent.on('transcriptUpdate', (transcripts: Transcript[]) => {\n // Fresh array per update: the core reuses one array, and consumers of the DOM\n // event (React state) need a new reference to notice the change.\n this.transcripts = [...transcripts];\n if (this.pendingMessage && transcripts.some((t) => t.role === 'assistant' && !t.toolUsed)) {\n this.flushPending();\n }\n this.dispatch('transcript', this.transcripts);\n // Text chat patches only the thread, so the message box keeps focus and any\n // half-typed reply while the agent's answer streams in.\n if (!this.updateThread()) this.render();\n });\n }\n\n private endLocalCall(): void {\n if (this.state === 'ended' || this.state === 'idle') return;\n // Ask how it went, once, for a conversation that actually happened.\n if (this.config.feedback === 'end' && this.callId && this.elapsedSeconds >= 5) {\n this.feedbackState = 'ask';\n }\n this.clearDurationTimer();\n this.speaking = false;\n this.dispatch('call-end', this.elapsedSeconds);\n this.dispatch('conversationEnded', this.elapsedSeconds);\n this.setState('ended');\n this.agent = null;\n this.pendingMessage = null;\n if (this.pendingTimer) clearTimeout(this.pendingTimer);\n this.pendingTimer = null;\n // In `both` mode, drop the chosen modality so the pre-call dual entry returns.\n if (this.config.mode === 'both') this.activeMode = null;\n }\n\n private handleError(error: unknown): void {\n const err = error instanceof Error ? error : new Error(String(error));\n this.errorText = friendlyError(err);\n this.clearDurationTimer();\n this.speaking = false;\n this.switching = false;\n this.dispatch('error', err);\n this.agent = null;\n if (this.config.mode === 'both') this.activeMode = null;\n this.setState('idle');\n }\n\n // ---- maxCallDuration (UX-ONLY countdown) -----------------------------------\n // NOTE: This is a client-side timer for UX feedback only. Real call-duration\n // enforcement happens server-side (backend web-call route); this timer is\n // trivially bypassable and must not be relied on as a hard cap.\n private startDurationTimer(reset = true): void {\n this.clearDurationTimer();\n if (reset) {\n this.elapsedSeconds = 0;\n this.remainingSeconds =\n typeof this.config.maxCallDuration === 'number' ? this.config.maxCallDuration : null;\n }\n this.durationTimer = setInterval(() => {\n this.elapsedSeconds += 1;\n if (this.remainingSeconds !== null) {\n this.remainingSeconds -= 1;\n if (this.remainingSeconds <= 0) {\n this.agent?.endCall();\n return;\n }\n }\n this.renderStatus();\n }, 1000);\n }\n\n private clearDurationTimer(): void {\n if (this.durationTimer) {\n clearInterval(this.durationTimer);\n this.durationTimer = null;\n }\n }\n\n // ---- State + DOM events ----------------------------------------------------\n\n private setState(state: WidgetState): void {\n const prev = this.state;\n if (state === 'connecting') this.errorText = null;\n this.state = state;\n if (state === 'live' && prev !== 'live' && !this.switching) {\n this.dispatch('call-start', undefined);\n this.dispatch('conversationStarted', undefined);\n }\n this.render();\n }\n\n private dispatch(type: string, detail: unknown): void {\n this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));\n }\n\n // ---- Theming ----------------------------------------------------------------\n\n private applyTheme(): void {\n // Accent: the customer's brand colour, else the legacy orb colour, else default.\n const accent = this.config.brand.primaryColor || this.config.orbColor1 || DEFAULT_ACCENT;\n this.style.setProperty('--tw-accent', accent);\n // Text that sits ON the accent picks whichever of white/ink reads better, so a\n // pale brand colour (yellow, mint) still has legible buttons.\n this.style.setProperty('--tw-on-accent', readableOn(accent));\n // Colour overrides on top of the theme. The quieter tones (bubbles, borders,\n // secondary text) are mixed from background + text so they always belong together.\n const custom = this.config.backgroundColor || this.config.textColor;\n const setOrClear = (name: string, value?: string) =>\n value ? this.style.setProperty(name, value) : this.style.removeProperty(name);\n setOrClear('--tw-surface', this.config.backgroundColor);\n setOrClear('--tw-ink', this.config.textColor);\n setOrClear('--tw-raised', custom ? 'color-mix(in srgb, var(--tw-ink) 7%, var(--tw-surface))' : undefined);\n setOrClear('--tw-line', custom ? 'color-mix(in srgb, var(--tw-ink) 14%, var(--tw-surface))' : undefined);\n setOrClear('--tw-muted', custom ? 'color-mix(in srgb, var(--tw-ink) 62%, var(--tw-surface))' : undefined);\n if (this.config.buttonTextColor) this.style.setProperty('--tw-on-accent', this.config.buttonTextColor);\n\n // Orb gradient: its own two colours, else derived from the accent.\n this.style.setProperty('--tw-orb-1', this.config.orbColor1 || accent);\n this.style.setProperty('--tw-orb-2', this.config.orbColor2 || '#27a3fd');\n\n // Placement and theme can come from the dashboard design as well as attributes,\n // so the stylesheet keys off these resolved data attributes.\n this.dataset.placement = this.config.placement;\n this.dataset.theme = this.config.theme;\n }\n\n // ---- Rendering --------------------------------------------------------------\n\n private formatTime(total: number): string {\n const m = Math.floor(total / 60);\n const s = total % 60;\n return `${m}:${s.toString().padStart(2, '0')}`;\n }\n\n /** The line under the agent's name in the header. */\n private statusText(): string {\n if (this.state === 'connecting') return 'Connecting…';\n if (this.state === 'live' && this.resolvedMode() === 'voice') {\n const activity = this.speaking ? this.config.speakingText : this.config.listeningText;\n return `${activity} ${this.timerText()}`.trim();\n }\n if (this.state === 'live') return 'Online';\n return this.config.brand.name || 'Online';\n }\n\n private renderStatus(): void {\n const statusEl = this.root.querySelector('.tw-status');\n if (statusEl) statusEl.textContent = this.statusText();\n this.root.querySelectorAll('.tw-timer').forEach((el) => {\n // The call bar's line is \"Name · 0:42\"; everywhere else it's just the time.\n el.textContent = el.classList.contains('tw-callbar-meta')\n ? [this.speakerName(), this.timerText()].filter(Boolean).join(' · ')\n : this.timerText();\n });\n }\n\n private timerText(): string {\n if (this.state !== 'live') return '';\n if (this.remainingSeconds !== null) {\n return this.formatTime(Math.max(0, this.remainingSeconds));\n }\n return this.formatTime(this.elapsedSeconds);\n }\n\n /**\n * Agent voice level (0..1) from the live audio. Written straight to a CSS variable\n * on the host, so the presence ring moves with the real voice without re-rendering.\n */\n private setLevel(samples: Float32Array): void {\n let sum = 0;\n for (let i = 0; i < samples.length; i += 1) sum += samples[i] * samples[i];\n const rms = Math.sqrt(sum / (samples.length || 1));\n const level = Math.min(1, rms * 6);\n this.smoothedLevel = this.smoothedLevel * 0.7 + level * 0.3;\n this.style.setProperty('--tw-level', this.smoothedLevel.toFixed(3));\n }\n\n private smoothedLevel = 0;\n\n private render(): void {\n this.container.replaceChildren();\n let view: string;\n let el: HTMLElement;\n if (this.showTerms) {\n view = 'terms';\n el = this.renderTerms();\n } else if (this.open) {\n view = 'panel';\n el = this.renderPanel();\n } else {\n el = this.renderCard();\n view = el.querySelector('.tw-callbar') ? 'callbar' : 'bar';\n }\n if (view !== this.lastView) el.classList.add('tw-enter');\n this.lastView = view;\n this.container.appendChild(el);\n }\n\n // ---- Shared building blocks ---------------------------------------------------\n\n /** Avatar style: an explicit choice, else the image when one is set, else the orb. */\n private avatarStyle(): 'orb' | 'image' | 'initials' {\n const chosen = this.config.avatarStyle;\n if (chosen === 'image' && !this.config.avatar) return 'orb';\n if (chosen) return chosen;\n return this.config.avatar ? 'image' : 'orb';\n }\n\n /**\n * The mark: who the visitor is talking to, as a small rounded tile. A gradient in\n * the brand colours (default), the business's image, or initials. While the agent\n * speaks on a call, the tile breathes with the voice level (--tw-level).\n */\n private buildAvatar(size: 'sm' | 'md' | 'lg'): HTMLElement {\n const mark = document.createElement('span');\n const style = this.avatarStyle();\n mark.className = `tw-mark tw-mark-${size} tw-mark-${style}`;\n mark.setAttribute('aria-hidden', 'true');\n if (this.state === 'live' && this.resolvedMode() === 'voice') mark.classList.add('tw-voice-live');\n if (style === 'image') mark.style.backgroundImage = `url(\"${this.config.avatar}\")`;\n else if (style === 'initials') mark.textContent = initials(this.speakerName());\n return mark;\n }\n\n /** The name shown to visitors: business name, else the agent/flow name. */\n private speakerName(): string {\n return this.config.brand.name || this.headerTitle() || '';\n }\n\n /** Live voice level as five bars (heights follow --tw-level). */\n private buildWave(): HTMLElement {\n const wave = document.createElement('span');\n wave.className = `tw-wave${this.speaking ? ' tw-wave-speaking' : ''}`;\n wave.setAttribute('aria-hidden', 'true');\n for (let n = 0; n < 5; n += 1) wave.appendChild(document.createElement('i'));\n return wave;\n }\n\n private iconButton(icon: string, label: string, onClick: () => void, extraClass = ''): HTMLButtonElement {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = `tw-icon-btn ${extraClass}`.trim();\n btn.title = label;\n btn.setAttribute('aria-label', label);\n btn.innerHTML = icon;\n btn.addEventListener('click', onClick);\n return btn;\n }\n\n // ---- Terms gate + feedback --------------------------------------------------\n\n private showTerms = false;\n private pendingStart: ActiveMode | null = null;\n private callId: string | null = null;\n private feedbackState: 'hidden' | 'ask' | 'sent' = 'hidden';\n\n /** Acceptance is remembered per agent and per version of the text. */\n private termsKey(): string {\n let hash = 0;\n for (const ch of this.config.termsText || '') hash = (hash * 31 + ch.charCodeAt(0)) | 0;\n return `trillet-terms:${this.config.agentId}:${hash}`;\n }\n\n private termsAccepted(): boolean {\n if (this.termsAcceptedThisPage) return true;\n try {\n return window.localStorage.getItem(this.termsKey()) === '1';\n } catch {\n return false;\n }\n }\n\n // Fallback when storage is blocked: accepted for the life of this page.\n private termsAcceptedThisPage = false;\n\n private renderTerms(): HTMLElement {\n const card = document.createElement('div');\n card.className = 'tw-card tw-terms';\n card.setAttribute('role', 'dialog');\n card.setAttribute('aria-label', 'Terms');\n const title = document.createElement('div');\n title.className = 'tw-card-title';\n title.textContent = 'Before we start';\n card.appendChild(title);\n const body = document.createElement('div');\n body.className = 'tw-terms-body tw-md';\n body.appendChild(renderMarkdown(this.config.termsText || ''));\n card.appendChild(body);\n\n const row = document.createElement('div');\n row.className = 'tw-card-actions';\n const accept = document.createElement('button');\n accept.type = 'button';\n accept.className = 'tw-pill';\n accept.textContent = 'Agree and continue';\n accept.addEventListener('click', () => {\n try {\n window.localStorage.setItem(this.termsKey(), '1');\n } catch {\n /* storage blocked: falls back to this page only */\n }\n this.termsAcceptedThisPage = true;\n this.showTerms = false;\n const start = this.pendingStart;\n this.pendingStart = null;\n if (start === 'text') this.open = true;\n void this.beginCall(start ?? undefined);\n });\n const decline = document.createElement('button');\n decline.type = 'button';\n decline.className = 'tw-secondary-btn';\n decline.textContent = 'Not now';\n decline.addEventListener('click', () => {\n this.showTerms = false;\n this.pendingStart = null;\n this.open = false;\n this.render();\n });\n row.appendChild(accept);\n row.appendChild(decline);\n card.appendChild(row);\n return card;\n }\n\n /** \"How was this conversation?\" thumbs, once, after a conversation ends. */\n private renderFeedback(): HTMLElement | null {\n if (this.feedbackState === 'hidden') return null;\n const row = document.createElement('div');\n row.className = 'tw-feedback';\n if (this.feedbackState === 'sent') {\n row.textContent = 'Thanks for the feedback.';\n return row;\n }\n const label = document.createElement('span');\n label.textContent = 'How was this conversation?';\n row.appendChild(label);\n const send = (rating: 'up' | 'down') => {\n this.feedbackState = 'sent';\n this.render();\n fetch(apiUrl('/v1/api/web-call/public/feedback', this.config.apiBase), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ call_id: this.callId, rating }),\n }).catch(() => undefined);\n this.dispatch('feedback', rating);\n };\n row.appendChild(this.iconButton(ICONS.thumbUp, 'Good', () => send('up')));\n row.appendChild(this.iconButton(ICONS.thumbDown, 'Not good', () => send('down')));\n return row;\n }\n\n /**\n * The ask bar: the widget's resting state.\n *\n * [mark] Ask Firelink anything… (mic) (send)\n *\n * Input-first: typing + Enter opens the chat with that message already sent; the\n * mic starts a call and the bar becomes the call bar. Voice-only shows \"Talk to …\"\n * with a call button; chat-only drops the mic.\n */\n private renderCard(): HTMLElement {\n const idle = this.state === 'idle' || this.state === 'ended';\n const live = this.state === 'live';\n const voiceLive = live && this.resolvedMode() === 'voice';\n const voiceStarting = this.state === 'connecting' && this.resolvedMode() === 'voice';\n const gated = this.needsRecaptcha() && idle;\n const stack = document.createElement('div');\n stack.className = 'tw-bar-stack';\n\n if (voiceLive || voiceStarting) {\n stack.appendChild(this.renderVoiceBar(false));\n return stack;\n }\n\n if (this.errorText && idle) {\n const err = document.createElement('div');\n err.className = 'tw-bar-note tw-error-text';\n err.textContent = this.errorText;\n stack.appendChild(err);\n }\n\n const bar = document.createElement('div');\n bar.className = 'tw-ask';\n bar.appendChild(this.buildAvatar('md'));\n const name = this.speakerName();\n const canChat = this.config.mode !== 'voice';\n const canTalk = this.config.mode !== 'text';\n\n // A chat still running behind the minimized panel: one tap back to it.\n if (live || this.state === 'connecting') {\n const back = document.createElement('button');\n back.type = 'button';\n back.className = 'tw-ask-label';\n back.textContent = name ? `Chat with ${name}` : 'Back to chat';\n back.addEventListener('click', () => this.openPanel());\n bar.appendChild(back);\n bar.appendChild(this.iconButton(ICONS.chat, 'Open the chat', () => this.openPanel(), 'tw-sq tw-sq-accent'));\n stack.appendChild(bar);\n return stack;\n }\n\n if (!canChat) {\n // Voice only: the whole bar is the call button.\n const label = document.createElement('button');\n label.type = 'button';\n label.className = 'tw-ask-label';\n label.textContent = this.config.greeting || (name ? `Talk to ${name}` : this.config.startCallText);\n label.disabled = gated;\n label.addEventListener('click', () => {\n if (!this.needsRecaptcha()) void this.beginCall('voice');\n });\n bar.appendChild(label);\n const call = this.iconButton(ICONS.phone, this.config.actionText || this.config.startCallText, () => {\n if (!this.needsRecaptcha()) void this.beginCall('voice');\n }, 'tw-sq tw-sq-accent');\n call.disabled = gated;\n bar.appendChild(call);\n } else {\n const form = document.createElement('form');\n form.className = 'tw-ask-form';\n const input = document.createElement('input');\n input.className = 'tw-ask-input';\n input.type = 'text';\n input.placeholder = this.config.greeting || (name ? `Ask ${name} anything…` : 'Ask anything…');\n input.setAttribute('aria-label', input.placeholder);\n input.value = this.draft;\n input.disabled = gated;\n const send = this.iconButton(ICONS.send, 'Send', () => undefined, 'tw-sq tw-sq-accent');\n send.type = 'submit';\n const sync = () => {\n send.disabled = gated || !input.value.trim();\n };\n input.addEventListener('input', () => {\n this.draft = input.value;\n sync();\n });\n input.addEventListener('focus', () => {\n this.askFocused = true;\n this.renderAskSuggestions(stack, bar);\n });\n input.addEventListener('blur', () => {\n this.askFocused = false;\n // Let a click on a suggestion land before the row goes away.\n setTimeout(() => {\n if (!this.askFocused) stack.querySelector('.tw-ask-suggestions')?.remove();\n }, 150);\n });\n form.addEventListener('submit', (e) => {\n e.preventDefault();\n const text = input.value.trim();\n if (!text || this.needsRecaptcha()) return;\n this.draft = '';\n void this.sendMessage(text);\n });\n form.appendChild(input);\n if (canTalk) {\n const call = this.iconButton(ICONS.phone, this.config.actionText || this.config.startCallText, () => {\n if (!this.needsRecaptcha()) void this.beginCall('voice');\n }, 'tw-sq tw-sq-quiet');\n call.disabled = gated;\n form.appendChild(call);\n }\n form.appendChild(send);\n sync();\n bar.appendChild(form);\n }\n stack.appendChild(bar);\n\n if (gated) {\n const slot = document.createElement('slot');\n slot.setAttribute('name', 'recaptcha');\n slot.className = 'tw-recaptcha-slot';\n stack.insertBefore(slot, bar);\n this.ensureRecaptchaSlot();\n }\n\n const feedback = idle ? this.renderFeedback() : null;\n if (feedback) {\n feedback.classList.add('tw-bar-note');\n stack.insertBefore(feedback, bar);\n }\n return stack;\n }\n\n private askFocused = false;\n\n /** Suggested questions just above the ask bar while it has focus. */\n private renderAskSuggestions(stack: HTMLElement, bar: HTMLElement): void {\n if (!this.config.suggestedPrompts.length || stack.querySelector('.tw-ask-suggestions')) return;\n const row = document.createElement('div');\n row.className = 'tw-ask-suggestions';\n for (const prompt of this.config.suggestedPrompts) {\n const chip = document.createElement('button');\n chip.type = 'button';\n chip.className = 'tw-suggestion';\n chip.textContent = prompt;\n // mousedown, not click: fires before the input's blur removes the row.\n chip.addEventListener('mousedown', (e) => {\n e.preventDefault();\n this.askFocused = false;\n void this.sendMessage(prompt);\n });\n row.appendChild(chip);\n }\n stack.insertBefore(row, bar);\n }\n\n /**\n * Open the panel. A text-only widget starts the chat straight away, so the agent's\n * welcome is already there when the panel opens, like any website chat. `both`\n * waits for the visitor to pick call or message.\n */\n private openPanel(): void {\n this.open = true;\n const idle = this.state === 'idle' || this.state === 'ended';\n if (this.config.mode === 'text' && idle && !this.needsRecaptcha()) {\n this.transcripts = [];\n void this.beginCall('text');\n return;\n }\n this.render();\n }\n\n private renderPanel(): HTMLElement {\n const panel = document.createElement('div');\n panel.className = `tw-panel${this.config.variant === 'expanded' ? ' tw-expanded' : ''}`;\n panel.setAttribute('role', 'dialog');\n panel.setAttribute('aria-label', this.headerTitle() || 'Chat');\n panel.appendChild(this.renderHeader());\n panel.appendChild(this.renderBody());\n return panel;\n }\n\n /**\n * The header title identifying who the user is talking to. Each identity value is\n * code-overridable per value: a static `agent-name`/`call-flow-name`/`workspace-name`\n * config value takes precedence over the corresponding backend `display.*` value\n * (which only arrives on `connected`), falling back to it when unset. `brand.name`\n * is intentionally NOT part of this chain; it renders as the status line pre-call.\n */\n private headerTitle(): string {\n const display = this.display ?? this.remoteDisplay;\n const effectiveAgent = this.config.agentName ?? display?.agent_name;\n const effectiveCallFlow = this.config.callFlowName ?? display?.call_flow_name;\n const effectiveWorkspace = this.config.workspaceName ?? display?.workspace_name;\n return effectiveAgent || effectiveCallFlow || effectiveWorkspace || '';\n }\n\n private renderHeader(): HTMLElement {\n const header = document.createElement('div');\n header.className = 'tw-header';\n\n // Screens that already show the large avatar in the body skip the small one.\n if (!this.bodyShowsLargeAvatar()) header.appendChild(this.buildAvatar('sm'));\n\n const who = document.createElement('div');\n who.className = 'tw-who';\n const name = document.createElement('div');\n name.className = 'tw-header-title';\n // An explicit window title wins; otherwise the same name the messages carry.\n const title = this.config.agentName || this.speakerName();\n name.textContent = title;\n if (title) name.title = title;\n const status = document.createElement('div');\n status.className = 'tw-status';\n if (this.state === 'live') status.classList.add('tw-online');\n status.textContent = this.statusText();\n who.appendChild(name);\n who.appendChild(status);\n header.appendChild(who);\n\n // Customer logo, when set: theirs, so it sits on the right like a site mark.\n if (this.config.brand.logo) {\n const logo = document.createElement('img');\n logo.className = 'tw-brand-logo';\n logo.src = this.config.brand.logo;\n logo.alt = this.config.brand.name || '';\n header.appendChild(logo);\n }\n\n const actions = document.createElement('div');\n actions.className = 'tw-header-actions';\n // Minimize keeps the conversation running; close (dismissible) ends it.\n actions.appendChild(\n this.iconButton(ICONS.minimize, 'Minimize', () => {\n this.open = false;\n this.render();\n })\n );\n if (this.config.dismissible) {\n actions.appendChild(\n this.iconButton(ICONS.close, 'Close', () => {\n if (this.state === 'live' || this.state === 'connecting') this.endConversation();\n this.open = false;\n this.render();\n })\n );\n }\n header.appendChild(actions);\n return header;\n }\n\n /** Start, call and gate screens centre a large avatar in the body. */\n private bodyShowsLargeAvatar(): boolean {\n const idle = this.state === 'idle' || this.state === 'ended';\n if (this.needsRecaptcha() && idle) return true;\n if (this.isBothPreCall()) return true;\n if (this.config.mode !== 'both' && this.resolvedMode() === 'voice') return true;\n return this.state === 'idle' && this.transcripts.length === 0;\n }\n\n /** True when a `both` widget is idle/ended with no modality chosen yet. */\n private isBothPreCall(): boolean {\n return (\n this.config.mode === 'both' &&\n this.activeMode === null &&\n (this.state === 'idle' || this.state === 'ended')\n );\n }\n\n // ---- BYO reCAPTCHA gate ----------------------------------------------------\n\n /** True when a site key is configured and this session has not solved it yet. */\n private needsRecaptcha(): boolean {\n return Boolean(this.config.recaptchaSiteKey) && !this.recaptchaSolved;\n }\n\n /**\n * The pre-call gate shown in the panel: prompt, the reCAPTCHA checkbox, and a\n * disabled start button. The button enables once the checkbox is solved.\n *\n * The checkbox itself is projected in via a <slot>: reCAPTCHA v2 hangs inside a\n * shadow root (its anchor iframe never finishes initializing), so the actual widget\n * is rendered into a LIGHT-DOM node — a child of the host element — that is assigned\n * to this slot. It therefore *displays* here inside the panel while its DOM home\n * stays in the light tree, where reCAPTCHA works.\n */\n private renderRecaptchaGate(body: HTMLElement): void {\n body.classList.add('tw-center-body');\n body.appendChild(this.buildAvatar('lg'));\n\n const prompt = document.createElement('p');\n prompt.className = 'tw-prompt';\n prompt.textContent = this.config.recaptchaText;\n body.appendChild(prompt);\n\n const slot = document.createElement('slot');\n slot.setAttribute('name', 'recaptcha');\n slot.className = 'tw-recaptcha-slot';\n body.appendChild(slot);\n\n const startBtn = document.createElement('button');\n startBtn.className = 'tw-primary-btn';\n startBtn.type = 'button';\n startBtn.textContent = this.config.startCallText;\n startBtn.disabled = true;\n body.appendChild(startBtn);\n\n this.ensureRecaptchaSlot();\n }\n\n /**\n * Create the light-DOM node that hosts the reCAPTCHA checkbox and render the checkbox\n * into it. Idempotent: every re-render recreates the <slot>, but this node (and its\n * iframe) persists in the light DOM untouched, so the checkbox renders exactly once.\n */\n private ensureRecaptchaSlot(): void {\n const siteKey = this.config.recaptchaSiteKey;\n if (!siteKey || this.recaptchaSolved || this.recaptchaSlot) return;\n\n const slotted = document.createElement('div');\n slotted.setAttribute('slot', 'recaptcha');\n slotted.className = 'tw-recaptcha-mount';\n this.appendChild(slotted);\n this.recaptchaSlot = slotted;\n\n this.recaptchaWidgetId = -1; // claim the slot before awaiting (guards double-render)\n void renderRecaptchaCheckbox({\n container: slotted,\n siteKey,\n onSolved: () => {\n this.recaptchaSolved = true;\n this.removeRecaptchaSlot();\n this.render();\n },\n onExpired: () => {\n this.recaptchaSolved = false;\n },\n })\n .then((id) => {\n this.recaptchaWidgetId = id;\n })\n .catch((error) => {\n // Google unreachable (blocked, offline, CSP). Failing closed would strand the\n // visitor behind a checkbox that can never appear, on a gate that provides no\n // security anyway, so let the call through and say why.\n console.warn('[trillet-widget] reCAPTCHA failed to load; starting without it', error);\n this.recaptchaSolved = true;\n this.removeRecaptchaSlot();\n this.render();\n });\n }\n\n /** Remove the slotted light-DOM checkbox node. Safe to call when none exists. */\n private removeRecaptchaSlot(): void {\n this.recaptchaSlot?.remove();\n this.recaptchaSlot = null;\n if (!this.recaptchaSolved) this.recaptchaWidgetId = null;\n }\n\n private renderBody(): HTMLElement {\n const body = document.createElement('div');\n body.className = 'tw-body';\n\n if (this.needsRecaptcha() && (this.state === 'idle' || this.state === 'ended')) {\n this.renderRecaptchaGate(body);\n return body;\n }\n\n if (this.isBothPreCall()) {\n this.renderBothEntry(body);\n return body;\n }\n\n // mode=\"both\" always shows the conversation thread, on either side.\n if (this.resolvedMode() === 'text' || this.config.mode === 'both') {\n this.renderTextBody(body);\n } else {\n this.renderVoiceBody(body);\n }\n return body;\n }\n\n /** Pre-call panel for mode=\"both\": the visitor picks how to talk. */\n private renderBothEntry(body: HTMLElement): void {\n body.classList.add('tw-center-body');\n body.appendChild(this.buildAvatar('lg'));\n\n const prompt = document.createElement('p');\n prompt.className = 'tw-prompt';\n prompt.textContent = this.config.greeting || 'How would you like to talk?';\n body.appendChild(prompt);\n\n const choices = document.createElement('div');\n choices.className = 'tw-choices';\n const choice = (icon: string, text: string, modality: ActiveMode, primary: boolean) => {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = primary ? 'tw-primary-btn' : 'tw-secondary-btn';\n btn.innerHTML = icon;\n const span = document.createElement('span');\n span.textContent = text;\n btn.appendChild(span);\n btn.addEventListener('click', () => {\n if (modality === 'text') this.transcripts = [];\n void this.beginCall(modality);\n });\n return btn;\n };\n choices.appendChild(choice(ICONS.phone, this.config.startCallText, 'voice', true));\n choices.appendChild(choice(ICONS.chat, this.config.messageText, 'text', false));\n body.appendChild(choices);\n }\n\n /** Voice call: the agent's presence (ring follows their voice), status, controls. */\n private renderVoiceBody(body: HTMLElement): void {\n body.classList.add('tw-center-body', 'tw-voice-body');\n body.appendChild(this.buildAvatar('lg'));\n\n const status = document.createElement('p');\n status.className = 'tw-prompt';\n if (this.state === 'connecting') status.textContent = 'Connecting…';\n else if (this.state === 'live') status.textContent = this.speaking ? this.config.speakingText : this.config.listeningText;\n else if (this.state === 'ended') status.textContent = this.errorText ?? 'Call ended';\n else status.textContent = this.config.actionText || 'Talk to us now';\n if (this.errorText && this.state !== 'live') status.classList.add('tw-error-text');\n body.appendChild(status);\n\n const timer = document.createElement('div');\n timer.className = 'tw-timer';\n timer.textContent = this.timerText();\n body.appendChild(timer);\n\n body.appendChild(this.renderControls());\n }\n\n /** Text/chat UI: conversation thread + message input. */\n private renderTextBody(body: HTMLElement): void {\n body.classList.add('tw-chat-body');\n\n if (this.state === 'idle' && this.transcripts.length === 0) {\n body.classList.add('tw-center-body');\n body.appendChild(this.buildAvatar('lg'));\n if (this.errorText) {\n const err = document.createElement('p');\n err.className = 'tw-prompt tw-error-text';\n err.textContent = this.errorText;\n body.appendChild(err);\n }\n body.appendChild(this.renderControls());\n return;\n }\n\n body.appendChild(this.renderTranscript());\n\n const suggestions = this.renderSuggestions();\n if (suggestions) body.appendChild(suggestions);\n\n if (this.state === 'ended' || this.state === 'idle') {\n const footer = document.createElement('div');\n footer.className = 'tw-chat-ended';\n const status = document.createElement('span');\n status.textContent = this.errorText ?? 'This chat has ended.';\n if (this.errorText) status.classList.add('tw-error-text');\n footer.appendChild(status);\n const restart = document.createElement('button');\n restart.type = 'button';\n restart.className = 'tw-secondary-btn tw-small';\n restart.textContent = 'Start a new chat';\n restart.addEventListener('click', () => {\n this.transcripts = [];\n void this.beginCall('text');\n });\n footer.appendChild(restart);\n body.appendChild(footer);\n const feedback = this.renderFeedback();\n if (feedback) body.appendChild(feedback);\n return;\n }\n\n if (this.notice) {\n const notice = document.createElement('p');\n notice.className = 'tw-notice';\n notice.setAttribute('role', 'status');\n notice.textContent = this.notice;\n body.appendChild(notice);\n }\n\n const talking = this.config.mode === 'both' && this.resolvedMode() === 'voice';\n body.appendChild(talking ? this.renderVoiceBar(true) : this.renderTextInput());\n\n const footer = document.createElement('div');\n footer.className = 'tw-chat-footer';\n const endBtn = document.createElement('button');\n endBtn.className = 'tw-link-btn tw-end-chat';\n endBtn.type = 'button';\n // end-call-text is the call label in \"both\"; the thread view ends the whole\n // conversation, whichever side it is on.\n endBtn.textContent = this.config.mode === 'text' ? this.config.endCallText : 'End conversation';\n endBtn.disabled = this.state === 'connecting';\n endBtn.addEventListener('click', () => this.endConversation());\n footer.appendChild(endBtn);\n body.appendChild(footer);\n }\n\n /** Starter questions, shown until the visitor has said something. */\n private renderSuggestions(): HTMLElement | null {\n const prompts = this.config.suggestedPrompts;\n const visitorHasSpoken = this.transcripts.some((t) => t.role === 'user');\n if (!prompts.length || visitorHasSpoken || this.state === 'ended') return null;\n const row = document.createElement('div');\n row.className = 'tw-suggestions';\n for (const prompt of prompts) {\n const chip = document.createElement('button');\n chip.type = 'button';\n chip.className = 'tw-suggestion';\n chip.textContent = prompt;\n chip.addEventListener('click', () => void this.sendMessage(prompt));\n row.appendChild(chip);\n }\n return row;\n }\n\n private renderControls(): HTMLElement {\n const controls = document.createElement('div');\n controls.className = 'tw-controls';\n\n if (this.state === 'idle' || this.state === 'ended') {\n const startBtn = document.createElement('button');\n startBtn.className = 'tw-primary-btn';\n startBtn.type = 'button';\n const isText = this.resolvedMode() === 'text';\n startBtn.innerHTML = isText ? ICONS.chat : ICONS.phone;\n const span = document.createElement('span');\n span.textContent = isText ? 'Start chat' : this.config.startCallText;\n startBtn.appendChild(span);\n startBtn.addEventListener('click', () => {\n void this.beginCall();\n });\n controls.appendChild(startBtn);\n return controls;\n }\n\n // connecting | live (voice)\n if (this.resolvedMode() === 'voice') {\n const micBtn = this.iconButton(\n this.micEnabled ? ICONS.mic : ICONS.micOff,\n this.micEnabled ? 'Mute microphone' : 'Unmute microphone',\n () => {\n this.micEnabled = !this.micEnabled;\n this.agent?.toggleMicrophone(this.micEnabled);\n this.render();\n },\n `tw-round-btn${this.micEnabled ? '' : ' tw-muted'}`\n );\n micBtn.disabled = this.state !== 'live';\n controls.appendChild(micBtn);\n\n const endBtn = this.iconButton(ICONS.hangup, this.config.endCallText, () => this.endConversation(), 'tw-round-btn tw-end-btn');\n endBtn.disabled = this.state === 'connecting';\n controls.appendChild(endBtn);\n }\n return controls;\n }\n\n /**\n * The call bar. Resting (floating) it replaces the ask bar during a call; inside the\n * chat panel it replaces the composer on the voice side of a type-or-talk chat.\n *\n * ||||| Speaking (mic) (💬 / ⌨) (end)\n * Firelink · 0:42\n */\n private renderVoiceBar(inPanel: boolean): HTMLElement {\n const bar = document.createElement('div');\n bar.className = inPanel ? 'tw-callbar tw-callbar-inline' : 'tw-callbar';\n const connecting = this.state === 'connecting';\n\n bar.appendChild(this.buildWave());\n const text = document.createElement('div');\n text.className = 'tw-callbar-text';\n const activity = document.createElement('div');\n activity.className = 'tw-callbar-activity';\n activity.textContent = connecting\n ? 'Connecting…'\n : this.speaking\n ? this.config.speakingText\n : this.config.listeningText;\n const meta = document.createElement('div');\n meta.className = 'tw-callbar-meta tw-timer';\n const name = this.speakerName();\n meta.textContent = [name, this.timerText()].filter(Boolean).join(' · ');\n text.appendChild(activity);\n text.appendChild(meta);\n bar.appendChild(text);\n\n const mute = this.iconButton(\n this.micEnabled ? ICONS.mic : ICONS.micOff,\n this.micEnabled ? 'Mute microphone' : 'Unmute microphone',\n () => {\n this.micEnabled = !this.micEnabled;\n this.agent?.toggleMicrophone(this.micEnabled);\n this.render();\n },\n `tw-sq tw-sq-quiet${this.micEnabled ? '' : ' tw-muted'}`\n );\n mute.disabled = connecting;\n bar.appendChild(mute);\n\n if (inPanel) {\n const back = this.iconButton(ICONS.keyboard, 'Type instead', () => void this.switchModality(), 'tw-sq tw-sq-quiet');\n back.disabled = this.switchingSide || connecting;\n bar.appendChild(back);\n } else if (this.config.mode === 'both') {\n bar.appendChild(\n this.iconButton(ICONS.chat, 'Show the conversation', () => {\n this.open = true;\n this.render();\n }, 'tw-sq tw-sq-quiet')\n );\n }\n\n const end = this.iconButton(ICONS.hangup, this.config.endCallText, () => this.endConversation(), 'tw-sq tw-sq-danger');\n bar.appendChild(end);\n return bar;\n }\n\n // Last start/connection failure, shown instead of the \"ended\" line.\n private errorText: string | null = null;\n\n // Half-typed message, kept across full re-renders (connecting -> live, etc.).\n private draft = '';\n\n private renderTextInput(): HTMLElement {\n const row = document.createElement('form');\n row.className = 'tw-composer';\n\n const input = document.createElement('textarea');\n input.className = 'tw-text-input';\n input.rows = 1;\n input.placeholder = this.config.inputPlaceholder;\n input.value = this.draft;\n input.setAttribute('aria-label', this.config.inputPlaceholder);\n\n const sendBtn = document.createElement('button');\n sendBtn.className = 'tw-send-btn';\n sendBtn.type = 'submit';\n sendBtn.setAttribute('aria-label', 'Send');\n sendBtn.innerHTML = ICONS.send;\n\n const syncState = (): void => {\n sendBtn.disabled = this.state !== 'live' || !input.value.trim();\n // Grow with the text up to a few lines, then scroll.\n input.style.height = 'auto';\n input.style.height = `${Math.min(input.scrollHeight, 112)}px`;\n };\n\n const send = (): void => {\n const text = input.value.trim();\n if (!text || this.state !== 'live') return;\n this.draft = '';\n input.value = '';\n syncState();\n void this.agent?.sendTextMessage(text);\n };\n\n input.addEventListener('input', () => {\n this.draft = input.value;\n syncState();\n });\n input.addEventListener('keydown', (e) => {\n // Enter sends, Shift+Enter is a newline. Ignore Enter while an IME is composing.\n if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) {\n e.preventDefault();\n send();\n }\n });\n row.addEventListener('submit', (e) => {\n e.preventDefault();\n send();\n });\n\n row.appendChild(input);\n // Type-or-talk: the mic sits beside send and moves this conversation to voice.\n if (this.config.mode === 'both') {\n const mic = this.iconButton(ICONS.phone, 'Talk instead', () => void this.switchModality(), 'tw-composer-mic');\n mic.disabled = this.state !== 'live' || this.switchingSide;\n row.appendChild(mic);\n }\n row.appendChild(sendBtn);\n requestAnimationFrame(syncState);\n if (this.state === 'live') requestAnimationFrame(() => input.focus({ preventScroll: true }));\n return row;\n }\n\n /** The agent's reply as it streams in (not yet final), if any. */\n private streamingReply(): string {\n const partials = this.agent?.getCurrentTranscript() ?? {};\n return Object.entries(partials)\n .filter(([identity]) => identity.startsWith('agent'))\n .map(([, text]) => text)\n .join(' ')\n .trim();\n }\n\n /** Fill a chat thread element with the current messages. */\n private fillThread(wrap: HTMLElement): void {\n wrap.replaceChildren();\n let previousRole: string | null = null;\n for (const t of this.transcripts) {\n // Tool activity rows are for developer consoles, not the visitor's chat.\n if (t.toolUsed) continue;\n const msg = document.createElement('div');\n msg.className = `tw-msg ${t.role === 'user' ? 'tw-user' : 'tw-assistant'}`;\n // Consecutive messages from the same side sit closer together.\n if (previousRole === t.role) msg.classList.add('tw-run');\n previousRole = t.role;\n if (t.role === 'user') {\n msg.textContent = t.text;\n } else {\n // First reply in a run carries a small name label, like the trillet.ai demo.\n if (!msg.classList.contains('tw-run') && this.speakerName()) {\n const who = document.createElement('div');\n who.className = 'tw-msg-label';\n who.textContent = this.speakerName();\n msg.appendChild(who);\n }\n const body = document.createElement('div');\n body.className = 'tw-md';\n body.appendChild(renderMarkdown(t.text));\n msg.appendChild(body);\n }\n wrap.appendChild(msg);\n }\n\n const streaming = this.streamingReply();\n if (streaming) {\n const msg = document.createElement('div');\n msg.className = 'tw-msg tw-assistant tw-streaming';\n if (previousRole === 'assistant') msg.classList.add('tw-run');\n else if (this.speakerName()) {\n const who = document.createElement('div');\n who.className = 'tw-msg-label';\n who.textContent = this.speakerName();\n msg.appendChild(who);\n }\n const body = document.createElement('div');\n body.className = 'tw-md';\n body.appendChild(renderMarkdown(streaming));\n msg.appendChild(body);\n wrap.appendChild(msg);\n } else if (this.isAwaitingReply()) {\n const typing = document.createElement('div');\n typing.className = 'tw-msg tw-assistant tw-typing';\n typing.setAttribute('aria-label', 'Typing');\n typing.innerHTML = '<span></span><span></span><span></span>';\n wrap.appendChild(typing);\n }\n\n requestAnimationFrame(() => {\n wrap.scrollTop = wrap.scrollHeight;\n });\n }\n\n /** Connecting, or the visitor spoke last and the agent hasn't started answering. */\n private isAwaitingReply(): boolean {\n if (this.state === 'connecting' || this.pendingMessage) return true;\n if (this.state !== 'live') return false;\n const last = [...this.transcripts].reverse().find((t) => !t.toolUsed);\n return last?.role === 'user';\n }\n\n /**\n * Patch just the chat thread (and starter questions) in place. Returns false when\n * there is no text thread on screen, in which case the caller does a full render.\n */\n private updateThread(): boolean {\n if (!this.open) return false;\n const thread = this.root.querySelector<HTMLElement>('.tw-chat');\n if (!thread) return false;\n this.fillThread(thread);\n const existing = this.root.querySelector('.tw-suggestions');\n const next = this.renderSuggestions();\n if (existing && !next) existing.remove();\n const status = this.root.querySelector('.tw-status');\n if (status) status.textContent = this.statusText();\n return true;\n }\n\n /** The chat thread: a fixed-height window that scrolls internally. */\n private renderTranscript(): HTMLElement {\n const wrap = document.createElement('div');\n wrap.className = 'tw-chat';\n wrap.setAttribute('role', 'log');\n wrap.setAttribute('aria-live', 'polite');\n this.fillThread(wrap);\n return wrap;\n }\n}\n\n/** Turn backend/SDK errors into one line a website visitor can act on. */\nfunction friendlyError(err: Error): string {\n const msg = err.message || '';\n if (/Origin not allowed/i.test(msg)) return 'Chat is not enabled on this website.';\n if (/Public access/i.test(msg)) return 'Chat is not available right now.';\n if (/Too many/i.test(msg)) return 'Too many chats right now. Please try again shortly.';\n if (/Insufficient funds/i.test(msg)) return 'Chat is not available right now.';\n return 'Could not connect. Please try again.';\n}\n\n// Default accent when neither a brand colour nor a legacy orb colour is set.\nconst DEFAULT_ACCENT = '#0062e9';\n\n/** White or ink, whichever has more contrast on `hex` (WCAG relative luminance). */\nfunction readableOn(hex: string): string {\n const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());\n if (!m) return '#ffffff';\n const full = m[1].length === 3 ? m[1].split('').map((c) => c + c).join('') : m[1];\n const channel = (i: number): number => {\n const v = parseInt(full.slice(i, i + 2), 16) / 255;\n return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;\n };\n const lum = 0.2126 * channel(0) + 0.7152 * channel(2) + 0.0722 * channel(4);\n const contrastWhite = 1.05 / (lum + 0.05);\n const contrastInk = (lum + 0.05) / 0.06;\n return contrastWhite >= contrastInk ? '#ffffff' : '#16181d';\n}\n\n/** Up to two initials from a display name (\"Front Desk\" -> \"FD\"). */\nfunction initials(name: string): string {\n const words = name.trim().split(/\\s+/).filter((w) => /[a-z0-9]/i.test(w));\n if (!words.length) return '';\n const letters = words.length === 1 ? words[0].slice(0, 1) : words[0][0] + words[1][0];\n return letters.toUpperCase();\n}\n\n// 20px stroke icons (currentColor), inlined so the bundle needs no icon font.\nconst svg = (body: string): string =>\n `<svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.9\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">${body}</svg>`;\n\nconst ICONS = {\n chat: svg('<path d=\"M20 12.5a7.5 7.5 0 0 1-11.2 6.5L4 20l1.1-4.3A7.5 7.5 0 1 1 20 12.5Z\"/>'),\n phone: svg('<path d=\"M5 4h3l1.6 4-2 1.3a11 11 0 0 0 5.1 5.1l1.3-2 4 1.6v3a2 2 0 0 1-2.2 2A16 16 0 0 1 3 6.2 2 2 0 0 1 5 4Z\"/>'),\n hangup: svg('<path d=\"M3.5 13.5c4.7-4 12.3-4 17 0l-1.6 2.6-3.4-1.2v-2.5a10 10 0 0 0-7 0v2.5l-3.4 1.2Z\"/>'),\n mic: svg('<rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21\"/>'),\n micOff: svg('<path d=\"M15 10V6a3 3 0 0 0-5.7-1.3M9 9v2a3 3 0 0 0 4.6 2.5M5.5 11a6.5 6.5 0 0 0 10.4 5.2M18.5 11a6.4 6.4 0 0 1-.6 2.6M12 17.5V21M4 4l16 16\"/>'),\n send: svg('<path d=\"M12 19V5M5.5 11.5 12 5l6.5 6.5\"/>'),\n minimize: svg('<path d=\"m6 9 6 6 6-6\"/>'),\n thumbUp: svg('<path d=\"M7 11v9H4v-9h3Zm0 0 4-7a2 2 0 0 1 2 2v3h5a2 2 0 0 1 2 2.3l-1.2 6A2 2 0 0 1 16.8 19H7\"/>'),\n thumbDown: svg('<path d=\"M17 13V4h3v9h-3Zm0 0-4 7a2 2 0 0 1-2-2v-3H6a2 2 0 0 1-2-2.3l1.2-6A2 2 0 0 1 7.2 5H17\"/>'),\n keyboard: svg('<rect x=\"3\" y=\"6\" width=\"18\" height=\"12\" rx=\"2\"/><path d=\"M7 10h.01M11 10h.01M15 10h.01M7 14h10\"/>'),\n close: svg('<path d=\"M6 6l12 12M18 6 6 18\"/>'),\n spinner: svg('<path d=\"M12 3a9 9 0 1 0 9 9\" class=\"tw-spin\"/>'),\n};\n","// Custom-element registration. Idempotent and SSR-safe: does nothing when there is\n// no `customElements` registry (e.g. Node SSR), and never double-registers.\n\nimport { TrilletWidgetElement } from './TrilletWidgetElement.js';\n\nexport const TRILLET_WIDGET_TAG = 'trillet-widget';\n\nexport function registerTrilletWidget(tag: string = TRILLET_WIDGET_TAG): void {\n if (typeof customElements === 'undefined') return;\n if (customElements.get(tag)) return;\n customElements.define(tag, TrilletWidgetElement);\n}\n","// React wrapper (SECONDARY entry) — a thin <TrilletWidget> over the framework-free\n// <trillet-widget> custom element. React stays a peerDependency and is NOT bundled\n// into the npm ESM build. This component only sets attributes/properties on the\n// underlying element and forwards its DOM CustomEvents to React callbacks.\n\nimport * as React from 'react';\nimport { registerTrilletWidget, TRILLET_WIDGET_TAG } from './register.js';\nimport type { TrilletWidgetElement } from './TrilletWidgetElement.js';\nimport type {\n WidgetBrand,\n WidgetMode,\n WidgetVariantInput,\n WidgetPlacement,\n WidgetTheme,\n} from './config.js';\nimport type { TrilletRoomDetails } from '../createCall.js';\nimport type { Transcript } from '../TranscriptManager.js';\n\nexport interface TrilletWidgetProps {\n // Required\n agentId: string;\n\n // Credential paths\n signedUrlEndpoint?: string;\n /**\n * JS-only: invoked at call-start to mint room details (cannot be an HTML attribute).\n * Receives the modality being started, so you can mint a voice or a text session.\n */\n getRoomDetails?: (context: { mode: 'voice' | 'text' }) => Promise<TrilletRoomDetails> | TrilletRoomDetails;\n /** API host override (whitelabel API domain, or a local backend in development). */\n apiBase?: string;\n /** Load the design saved in the Trillet dashboard (default true). */\n remoteConfig?: boolean;\n /** JS-only: static pre-minted room details. */\n roomDetails?: TrilletRoomDetails;\n workspaceId?: string;\n\n // Header identity overrides. Each overrides the corresponding backend-provided\n // `display.*` name (which remains the fallback). Being static config, setting any\n // of them renders the header title immediately (pre-call).\n agentName?: string;\n callFlowName?: string;\n workspaceName?: string;\n\n // Appearance\n avatar?: string;\n /** convai alias of `avatar`. */\n avatarImageUrl?: string;\n /** Legacy single accent/orb color; alias of orbColor1. */\n orbColor?: string;\n /** Gradient orb color 1 (convai `avatar-orb-color-1`). */\n orbColor1?: string;\n /** Gradient orb color 2 (convai `avatar-orb-color-2`). */\n orbColor2?: string;\n /** Accepts both our `compact|expanded` and convai's `tiny|compact|full`. */\n variant?: WidgetVariantInput;\n placement?: WidgetPlacement;\n dismissible?: boolean;\n\n // Copy / text overrides\n actionText?: string;\n startCallText?: string;\n endCallText?: string;\n /** Label for the text/chat entry point in mode=\"both\" (default \"Message\"). */\n messageText?: string;\n switchToTextText?: string;\n switchToVoiceText?: string;\n listeningText?: string;\n speakingText?: string;\n expandText?: string;\n collapseText?: string;\n /** Copy shown above the reCAPTCHA checkbox, when `recaptchaSiteKey` is set. */\n recaptchaText?: string;\n\n /** Short line shown beside the closed launcher. */\n greeting?: string;\n /** Placeholder in the chat message box. */\n inputPlaceholder?: string;\n /** Tap-to-send starter questions for text chats. */\n suggestedPrompts?: string[];\n theme?: WidgetTheme;\n\n // Behavior\n /** \"voice\" | \"text\" | \"both\" (multimodal, user-switchable). */\n mode?: WidgetMode;\n variables?: Record<string, unknown>;\n /** convai alias of `variables`. */\n dynamicVariables?: Record<string, unknown>;\n maxCallDuration?: number;\n /**\n * Google reCAPTCHA v2 site key. Renders a checkbox the visitor solves once per\n * session before the first conversation. BYO and client-only — the token is never\n * sent to Trillet nor verified, so it is UI friction, not bot protection.\n */\n recaptchaSiteKey?: string;\n /** convai `disable-banner` — accepted no-op (blank by default). */\n disableBanner?: boolean;\n\n // Customer branding (default blank)\n brand?: WidgetBrand;\n\n // Callbacks — primary (convai-aligned) + back-compat aliases.\n /** Primary. Fires alongside onCallStart. */\n onConversationStart?: () => void;\n /** Primary. Fires alongside onCallEnd. */\n onConversationEnd?: (durationSeconds: number) => void;\n /** @deprecated Use onConversationStart. Still fired for back-compat. */\n onCallStart?: () => void;\n /** @deprecated Use onConversationEnd. Still fired for back-compat. */\n onCallEnd?: (durationSeconds: number) => void;\n onError?: (error: Error) => void;\n onTranscript?: (transcripts: Transcript[]) => void;\n\n // Escape hatch for positioning / sizing via inline style or className.\n className?: string;\n style?: React.CSSProperties;\n}\n\n/** Maps a camelCase prop name to its kebab-case HTML attribute. */\nfunction setAttr(el: HTMLElement, name: string, value: string | number | boolean | undefined): void {\n if (value === undefined || value === false || value === null) {\n el.removeAttribute(name);\n return;\n }\n if (value === true) {\n el.setAttribute(name, '');\n return;\n }\n el.setAttribute(name, String(value));\n}\n\nexport const TrilletWidget: React.FC<TrilletWidgetProps> = (props) => {\n const ref = React.useRef<TrilletWidgetElement | null>(null);\n\n // Register the element once on the client.\n React.useEffect(() => {\n registerTrilletWidget();\n }, []);\n\n // Reflect attribute-style props onto the element.\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n setAttr(el, 'agent-id', props.agentId);\n setAttr(el, 'signed-url-endpoint', props.signedUrlEndpoint);\n setAttr(el, 'workspace-id', props.workspaceId);\n setAttr(el, 'agent-name', props.agentName);\n setAttr(el, 'call-flow-name', props.callFlowName);\n setAttr(el, 'workspace-name', props.workspaceName);\n setAttr(el, 'avatar', props.avatar ?? props.avatarImageUrl);\n setAttr(el, 'orb-color', props.orbColor);\n setAttr(el, 'avatar-orb-color-1', props.orbColor1);\n setAttr(el, 'avatar-orb-color-2', props.orbColor2);\n setAttr(el, 'variant', props.variant);\n setAttr(el, 'placement', props.placement);\n setAttr(el, 'dismissible', props.dismissible);\n setAttr(el, 'action-text', props.actionText);\n setAttr(el, 'start-call-text', props.startCallText);\n setAttr(el, 'end-call-text', props.endCallText);\n setAttr(el, 'message-text', props.messageText);\n setAttr(el, 'switch-to-text-text', props.switchToTextText);\n setAttr(el, 'switch-to-voice-text', props.switchToVoiceText);\n setAttr(el, 'listening-text', props.listeningText);\n setAttr(el, 'speaking-text', props.speakingText);\n setAttr(el, 'expand-text', props.expandText);\n setAttr(el, 'collapse-text', props.collapseText);\n setAttr(el, 'mode', props.mode);\n setAttr(el, 'api-base', props.apiBase);\n setAttr(el, 'remote-config', props.remoteConfig === false ? 'false' : undefined);\n setAttr(el, 'greeting', props.greeting);\n setAttr(el, 'input-placeholder', props.inputPlaceholder);\n setAttr(\n el,\n 'suggested-prompts',\n props.suggestedPrompts ? JSON.stringify(props.suggestedPrompts) : undefined,\n );\n setAttr(el, 'theme', props.theme);\n const vars = props.variables ?? props.dynamicVariables;\n setAttr(el, 'variables', vars ? JSON.stringify(vars) : undefined);\n setAttr(el, 'max-call-duration', props.maxCallDuration);\n setAttr(el, 'recaptcha-site-key', props.recaptchaSiteKey);\n setAttr(el, 'recaptcha-text', props.recaptchaText);\n setAttr(el, 'disable-banner', props.disableBanner);\n setAttr(el, 'brand-logo', props.brand?.logo);\n setAttr(el, 'brand-color', props.brand?.primaryColor);\n setAttr(el, 'brand-name', props.brand?.name);\n });\n\n // Reflect JS-only credential props (functions/objects can't be attributes).\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n el.getRoomDetails = props.getRoomDetails;\n el.roomDetails = props.roomDetails;\n }, [props.getRoomDetails, props.roomDetails]);\n\n // Wire DOM CustomEvents -> React callbacks.\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n // Primary (convai-aligned) lifecycle events.\n const onConvStart = (): void => props.onConversationStart?.();\n const onConvEnd = (e: Event): void =>\n props.onConversationEnd?.((e as CustomEvent<number>).detail);\n // Back-compat aliases (both fire from the element; wire both so either prop works).\n const onStart = (): void => props.onCallStart?.();\n const onEnd = (e: Event): void => props.onCallEnd?.((e as CustomEvent<number>).detail);\n const onErr = (e: Event): void => props.onError?.((e as CustomEvent<Error>).detail);\n const onTr = (e: Event): void => props.onTranscript?.((e as CustomEvent<Transcript[]>).detail);\n\n el.addEventListener('conversationStarted', onConvStart);\n el.addEventListener('conversationEnded', onConvEnd);\n el.addEventListener('call-start', onStart);\n el.addEventListener('call-end', onEnd);\n el.addEventListener('error', onErr);\n el.addEventListener('transcript', onTr);\n return () => {\n el.removeEventListener('conversationStarted', onConvStart);\n el.removeEventListener('conversationEnded', onConvEnd);\n el.removeEventListener('call-start', onStart);\n el.removeEventListener('call-end', onEnd);\n el.removeEventListener('error', onErr);\n el.removeEventListener('transcript', onTr);\n };\n }, [\n props.onConversationStart,\n props.onConversationEnd,\n props.onCallStart,\n props.onCallEnd,\n props.onError,\n props.onTranscript,\n ]);\n\n return React.createElement(TRILLET_WIDGET_TAG, {\n ref: ref as unknown as React.Ref<HTMLElement>,\n class: props.className,\n style: props.style,\n });\n};\n","// `@trillet-ai/web-sdk/widget` entry (ESM, secondary). Exports the React wrapper,\n// the custom element class, the registration helper, and the widget config types.\n// Importing this module registers the <trillet-widget> custom element as a side\n// effect (idempotent + SSR-safe), so consumers can use either the React component\n// or the bare custom element.\n\nimport { registerTrilletWidget } from './register.js';\n\n// Side-effect: define <trillet-widget> on import (no-op when no customElements).\nregisterTrilletWidget();\n\nexport { TrilletWidget } from './react.js';\nexport type { TrilletWidgetProps } from './react.js';\nexport { TrilletWidgetElement } from './TrilletWidgetElement.js';\nexport { registerTrilletWidget, TRILLET_WIDGET_TAG } from './register.js';\nexport type {\n WidgetConfig,\n WidgetBrand,\n WidgetVariant,\n WidgetVariantInput,\n WidgetMode,\n WidgetPlacement,\n WidgetTheme,\n RemoteWidgetConfig,\n} from './config.js';\n"],"mappings":";;;;;;;;AAiKO,IAAM,eAAe;AAAA,EAC1B,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,eAAe;AAAA,EACf,kBAAkB;AACpB;AAGO,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,aAAyC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,cAAc,OAA+B;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