@alxxsck/ai-assistant 2.26.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/{Avatar-Cr3PsHzw.js → Avatar-Bsv7Y3ZQ.js} +19082 -18842
  2. package/dist/{ChatWidgetContent-DJ2Y9kKV.js → ChatWidgetContent-Cq2Y5IHt.js} +2837 -2578
  3. package/dist/api/audio.api.d.ts +1 -1
  4. package/dist/avatar/AnimationManager.d.ts +7 -3
  5. package/dist/avatar/Avatar.d.ts +20 -3
  6. package/dist/avatar/avatarMeshes.d.ts +8 -0
  7. package/dist/avatar/loaders.d.ts +16 -0
  8. package/dist/bridge-ai-chat-widget.es.js +1 -1
  9. package/dist/constants.d.ts +1 -0
  10. package/dist/context/ChatWidgetContext.d.ts +0 -2
  11. package/dist/domain/message/message.store.d.ts +3 -0
  12. package/dist/domain/speech/SpeechPlayer.d.ts +2 -0
  13. package/dist/domain/ui/widget-geometry.d.ts +7 -5
  14. package/dist/domain/voice/media/ReliableVoiceUplink.d.ts +4 -0
  15. package/dist/domain/voice/voice-audio-meter.d.ts +12 -0
  16. package/dist/domain/voice/voice.store.d.ts +5 -1
  17. package/dist/i18n/messages.d.ts +5 -2
  18. package/dist/index-DY_Y_QHI.js +2825 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/inter-cyrillic-wght-italic.woff2 +0 -0
  21. package/dist/inter-cyrillic-wght-normal.woff2 +0 -0
  22. package/dist/inter-latin-ext-wght-italic.woff2 +0 -0
  23. package/dist/inter-latin-ext-wght-normal.woff2 +0 -0
  24. package/dist/inter-latin-wght-italic.woff2 +0 -0
  25. package/dist/inter-latin-wght-normal.woff2 +0 -0
  26. package/dist/{mount-DCjHLj_e.js → mount-RA3wsImP.js} +6415 -5939
  27. package/dist/roboto-cyrillic-400-normal.woff2 +0 -0
  28. package/dist/roboto-cyrillic-700-normal.woff2 +0 -0
  29. package/dist/roboto-latin-400-normal.woff2 +0 -0
  30. package/dist/roboto-latin-700-normal.woff2 +0 -0
  31. package/dist/roboto-latin-ext-400-normal.woff2 +0 -0
  32. package/dist/roboto-latin-ext-700-normal.woff2 +0 -0
  33. package/dist/ui/components/ChatListItem.d.ts +4 -1
  34. package/dist/ui/components/ChatSurfaceFrameContext.d.ts +6 -0
  35. package/dist/ui/components/ChatTopControls.d.ts +5 -5
  36. package/dist/ui/components/ChatVoiceMode.d.ts +5 -1
  37. package/dist/ui/components/ChatWidgetFrame.d.ts +3 -3
  38. package/dist/ui/components/VoiceComposer.d.ts +18 -0
  39. package/dist/ui/components/voice-waveform.d.ts +15 -0
  40. package/dist/ui/responder-visual-state.d.ts +7 -0
  41. package/dist/widget-fonts-CFulYNmT.js +16 -0
  42. package/dist/widget-fonts.d.ts +1 -0
  43. package/package.json +6 -2
  44. package/dist/avatar/consolidateMaterialGroups.d.ts +0 -2
  45. package/dist/index-D01wjcEK.js +0 -2809
  46. package/dist/ui/chat-composer-layout.d.ts +0 -1
  47. package/dist/ui/components/overlays/ChatBlurOverlayTop.d.ts +0 -1
  48. package/dist/ui/components/overlays/ChatDarkOverlay.d.ts +0 -1
@@ -1,2809 +0,0 @@
1
- const kt = '@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-blue-500:oklch(62.3% .214 259.815);--color-violet-200:oklch(89.4% .057 293.283);--color-rose-200:oklch(89.2% .058 10.001);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--ease-in:cubic-bezier(.4,0,1,1);--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-xs:4px;--blur-md:12px;--blur-xl:24px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components{.btn-preview{border-style:var(--tw-border-style);border-width:5px;border-color:var(--color-blue-500);border-radius:3.40282e38px}.message{background:var(--chat-surface-agent);max-width:100%;color:var(--chat-text-primary);border:0;border-radius:17px;padding:7px 11px;font-size:14px;font-weight:400;line-height:20px;box-shadow:0 6px 18px #00000029}.chat-message-row[data-author=customer]>.message,.message[data-author=customer]{background:var(--chat-surface-customer)}.bridge-ai-chat-widget [class~=text-start]{text-align:left;text-align:start}.bridge-ai-chat-widget[dir=rtl] [class~=text-start]{text-align:right;text-align:start}.chat-message-row[data-author=agent]>.message,.message[data-author=agent],.chat-message-skeleton-bubble.self-start{border-bottom-left-radius:5px}.chat-message-row[data-author=customer]>.message,.message[data-author=customer],.chat-message-skeleton-bubble.self-end{border-bottom-right-radius:5px}.bridge-ai-chat-widget[dir=rtl] .chat-message-row[data-author=agent]>.message,.bridge-ai-chat-widget[dir=rtl] .message[data-author=agent],.bridge-ai-chat-widget[dir=rtl] .chat-message-skeleton-bubble.self-start{border-bottom-right-radius:5px;border-bottom-left-radius:17px}.bridge-ai-chat-widget[dir=rtl] .chat-message-row[data-author=customer]>.message,.bridge-ai-chat-widget[dir=rtl] .message[data-author=customer],.bridge-ai-chat-widget[dir=rtl] .chat-message-skeleton-bubble.self-end{border-bottom-right-radius:17px;border-bottom-left-radius:5px}.message[data-author=agent]{margin-left:8px}.message[data-author=customer]{margin-right:8px}.bridge-ai-chat-widget[dir=rtl] .message[data-author=agent]{margin-left:0;margin-right:8px}.bridge-ai-chat-widget[dir=rtl] .message[data-author=customer]{margin-left:8px;margin-right:0}.chat-message-row[data-author=agent]+.chat-message-row[data-author=agent],.chat-message-row[data-author=customer]+.chat-message-row[data-author=customer]{margin-top:-4px}.chat-message-content p+p{margin-top:8px}.chat-message-author{color:#ffffffb8;letter-spacing:.01em;align-items:center;gap:6px;padding-inline:4px;font-size:11px;font-weight:600;display:inline-flex}.chat-message-author img{object-fit:cover;background:#0e131bcc;border:1px solid #68d8ff5c;border-radius:9999px;width:18px;height:18px}.chat-message-author[data-author-kind=operator] img{border-color:#d7ff6480}.chat-attachments{flex-direction:column;gap:6px;max-width:100%;display:flex}.chat-message-row[data-author=customer] .chat-attachments{justify-content:flex-end;align-self:flex-end}.chat-attachment-card,.chat-attachment-placeholder{width:min(250px,100%);max-width:100%;color:var(--chat-text-primary);background:linear-gradient(135deg,#68d8ff0e,#0000 58%),#050a1094;border:1px solid #ffffff1f;border-radius:13px;align-items:center;gap:8px;padding:7px;text-decoration:none;display:flex;box-shadow:inset 0 1px #ffffff09}.chat-attachment-card__icon,.chat-attachment-card__thumbnail{color:#87e2ffe0;background:#68d8ff14;border:1px solid #68d8ff2e;border-radius:9px;flex:none;width:34px;height:34px}.chat-attachment-card__icon{justify-content:center;align-items:center;display:flex}.chat-attachment-card__thumbnail{object-fit:cover}.chat-attachment-card__action{color:#ffffff94;border-radius:9px;justify-content:center;align-items:center;width:36px;height:36px;transition:color .14s,background-color .14s,transform .14s;display:inline-flex}.chat-attachment-card__action:hover{color:#a0eaff;background:#68d8ff1c}.chat-attachment-card__action:active{transform:scale(.94)}.chat-attachment-card__action:focus-visible{outline-offset:1px;outline:2px solid #68d8ffb8}.chat-message-receipt{color:#68d8ffc7;align-self:flex-end;padding-inline:4px;font-size:10px;line-height:1.2}.chat-composer-attachments{flex-direction:column;gap:6px;max-height:148px;padding:4px 4px 6px;display:flex;overflow-y:auto}.chat-composer-attachment{color:#ffffffd6;background:linear-gradient(90deg,#68d8ff0e,#0000 62%),#05090f80;border:1px solid #ffffff1a;border-radius:12px;align-items:center;gap:8px;width:100%;max-width:100%;padding:6px;font-size:11px;animation:.18s ease-out both chat-attachment-ready-in;display:flex;position:relative;overflow:visible;box-shadow:inset 0 1px #ffffff09}.chat-composer-attachment__preview{color:#87e2ffcc;background:#68d8ff12;border:1px solid #68d8ff2b;border-radius:9px;flex:none;justify-content:center;align-items:center;width:36px;height:36px;display:flex;overflow:hidden}.chat-composer-attachment__preview img{object-fit:cover;width:100%;height:100%}.chat-composer-attachment__progress{background:#ffffff14;border-radius:99px;height:2px;margin-top:5px;overflow:hidden}.chat-composer-attachment__progress span{border-radius:inherit;background:linear-gradient(90deg,#36bfe9,#8be7ff);height:100%;transition:width .16s;display:block;box-shadow:0 0 8px #68d8ff80}.chat-composer-attachment__progress span.is-scanning{background:linear-gradient(90deg,#f6c65b,#fff0af);width:36%;animation:1.2s ease-in-out infinite chat-attachment-scan;box-shadow:0 0 8px #f6c65b59}.chat-composer-attachment__action{border-radius:9px;flex:none;justify-content:center;align-items:center;width:36px;height:36px;transition:color .14s,background-color .14s,transform .14s;display:flex}.chat-composer-attachment__action:hover{color:#fff;background:#ffffff14}.chat-composer-attachment__action:disabled{cursor:wait;opacity:.62}.chat-composer-attachment__action:disabled:hover{background:0 0}.chat-composer-attachment__action:active{transform:scale(.94)}.chat-composer-attachment__action:focus-visible,.chat-attach-button:focus-visible{outline-offset:1px;outline:2px solid #68d8ffb8}.chat-attachment-dropzone{z-index:50;color:#b3edff;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);background:#060d15db;border:1px dashed #68d8ffad;border-radius:18px;justify-content:center;align-items:center;animation:.15s ease-out both chat-attachment-drop-in;display:flex;position:absolute;inset:6px 8px 52px;box-shadow:inset 0 0 42px #68d8ff14,0 16px 38px #0000005c}.chat-attachment-dropzone__content{text-align:center;flex-direction:column;align-items:center;gap:7px;font-size:13px;font-weight:650;display:flex}.chat-attachment-dropzone__content small{color:#ffffff80;font-size:10px;font-weight:450}@keyframes chat-attachment-ready-in{0%{opacity:0;transform:translateY(4px)scale(.99)}}@keyframes chat-attachment-scan{0%{transform:translate(-110%)}50%{transform:translate(90%)}to{transform:translate(290%)}}@keyframes chat-attachment-drop-in{0%{opacity:0;transform:scale(.985)}}@media(pointer:coarse){.chat-attachment-card__action,.chat-composer-attachment__action,.chat-attach-button{width:40px;height:40px}}.chat-message-content strong{font-weight:650}.chat-message-content h1,.chat-message-content h2,.chat-message-content h3,.chat-message-content h4,.chat-message-content h5,.chat-message-content h6{margin:8px 0 4px;font-weight:650;line-height:1.3}.chat-message-content h1,.chat-message-content h2{font-size:1.12em}.chat-message-content ul,.chat-message-content ol{padding-left:20px;margin:6px 0;padding-inline-start:20px}.bridge-ai-chat-widget[dir=rtl] .chat-message-content ul,.bridge-ai-chat-widget[dir=rtl] .chat-message-content ol{padding-left:0;padding-right:20px}.chat-message-content ul{list-style:outside}.chat-message-content ol{list-style:decimal}.chat-message-content blockquote{color:#f3f0f4c2;border-left:2px solid #68d8ff7a;padding-left:9px;border-inline-start:2px solid #68d8ff7a;margin:6px 0;padding-inline-start:9px}.bridge-ai-chat-widget[dir=rtl] .chat-message-content blockquote{border-left:0;border-right:2px solid #68d8ff7a;padding-left:0;padding-right:9px}.chat-message-content code{background:#ffffff17;border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.88em}.chat-message-content pre{background:#0003;border:1px solid #ffffff14;border-radius:8px;max-width:100%;margin:7px 0;padding:8px;overflow-x:auto}.chat-message-content pre code{background:0 0;padding:0}.chat-message-link{color:var(--chat-accent-cyan);text-underline-offset:2px;-webkit-text-decoration:underline #68d8ff61;text-decoration:underline #68d8ff61}.chat-message-link:hover{text-decoration-color:currentColor}.chat-message-link:focus-visible{outline:2px solid var(--chat-accent-cyan);outline-offset:2px;border-radius:2px}.chat-citation{vertical-align:super;margin-left:1px;margin-inline-start:1px;font-size:.72em;line-height:0}.bridge-ai-chat-widget[dir=rtl] .chat-citation{margin-left:0;margin-right:1px}.chat-citation .chat-message-link{text-decoration:none}.chat-icon-button{color:#ffffffd6;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);background:#0c0f157a;border:1px solid #ffffff1a;border-radius:9999px;justify-content:center;align-items:center;width:36px;height:36px;transition:color .16s,border-color .16s,background-color .16s,transform .16s;display:flex;box-shadow:inset 0 1px #ffffff0a}.chat-icon-button:hover{color:var(--chat-accent-cyan);background:#141921c7;border-color:#68d8ff57}.chat-icon-button:active{transform:scale(.96)}.chat-icon-button:focus-visible,.chat-launcher:focus-visible,.chat-composer-button:focus-visible,.chat-send-button:focus-visible,.chat-microphone-button:focus-visible{outline:2px solid var(--chat-accent-cyan);outline-offset:2px}[data-lola-widget-shell]{backface-visibility:hidden;visibility:hidden;opacity:0;pointer-events:none;transform-origin:50% 100%;transition:visibility 0s linear .2s,opacity .13s ease-in,transform .2s cubic-bezier(.4,0,.7,.2);transform:translateY(10px)scale(.985);box-shadow:0 24px 64px #00000052,0 8px 24px #0003}[data-lola-widget-shell][data-state=open]{visibility:visible;opacity:1;pointer-events:auto;transition:visibility,opacity .15s ease-out,transform .28s cubic-bezier(.16,1,.3,1);transition-timing-function:linear,ease-out,var(--chat-route-enter-easing);transform:translate(0)scale(1)}[data-lola-widget-shell][data-layout=fullscreen]{width:100vw;height:100vh}@supports (width:100dvw) and (height:100dvh){[data-lola-widget-shell][data-layout=fullscreen]{width:100dvw;height:100dvh}}[data-lola-widget-shell][data-layout=fullscreen] .chat-widget-panel{padding-top:env(safe-area-inset-top,0px);padding-right:env(safe-area-inset-right,0px);padding-bottom:env(safe-area-inset-bottom,0px);padding-left:env(safe-area-inset-left,0px)}.chat-widget-panel{transform:translateZ(0)}.compact-preview-anchor{width:min(320px,calc(100vw - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px) - 24px));contain:layout style}.compact-preview-anchor[data-suspended=true]{opacity:0;pointer-events:none}.compact-preview-anchor[data-suspended=true] :is(.compact-scenario-preview,.compact-scenario-preview *),.compact-preview-anchor[data-suspended=true] .compact-scenario-preview__action:after{animation-play-state:paused!important}.chat-launcher-menu{overscroll-behavior:contain;background:#121417f5;border:1px solid #ffffff24;border-radius:14px;width:max-content;min-width:168px;display:grid;overflow:hidden auto;box-shadow:0 12px 32px #00000052}.chat-launcher-menu>button{min-height:44px;color:var(--chat-text-primary);font:inherit;text-align:start;background:0 0;border:0;padding:10px 14px}.chat-launcher-menu>button:hover,.chat-launcher-menu>button:focus-visible{background:#ffffff1a}.chat-launcher-menu>button:focus-visible{outline:2px solid var(--chat-accent-cyan);outline-offset:-3px}.bridge-ai-chat-widget.is-interacting .chat-launcher{transition:none}.bridge-ai-chat-widget[data-preview-active=true] .chat-launcher__portrait,.bridge-ai-chat-widget[data-preview-active=true] .chat-launcher__aura,.bridge-ai-chat-widget.is-interacting .chat-launcher__portrait,.bridge-ai-chat-widget.is-interacting .chat-launcher__aura{animation-play-state:paused}.chat-launcher{visibility:visible;opacity:1;transition:visibility,opacity .14s ease-out,transform .18s ease-out;transform:translateZ(0)scale(1)}.chat-launcher[aria-expanded=true]{visibility:hidden;opacity:0;pointer-events:none;transition:visibility 0s linear .16s,opacity .12s ease-in,transform .16s ease-in;transform:translateZ(0)scale(.88)}.chat-launcher{color:#fff;cursor:grab;isolation:isolate;touch-action:none;background:#090f16e0;border:0;border-radius:9999px;place-items:center;padding:3px;display:grid}.chat-launcher:active{cursor:grabbing}.chat-launcher__portrait{z-index:2;border:3px solid var(--chat-accent-cyan);background:radial-gradient(circle at 50% 35%,#3d4c5d,#0c1219 72%);border-radius:9999px;width:46px;height:46px;animation:2.8s ease-in-out infinite lola-launcher-breathe;display:block;position:relative;overflow:hidden;box-shadow:inset 0 0 0 1px #ffffff3d,0 0 13px #68d8ffa3,0 0 30px #45bdff42}.chat-launcher__portrait img{width:100%;max-height:inherit;object-fit:cover;object-position:50% 20%;-webkit-user-select:none;user-select:none;height:100%;transform:scale(1.22)translateY(6%)}.chat-launcher__aura{z-index:1;filter:blur(7px);opacity:.7;background:conic-gradient(from 45deg,#68d8ff47,#775cff14,#68d8ff5c,#775cff14,#68d8ff47);border:1px solid #68d8ff61;border-radius:9999px;animation:3.6s ease-in-out infinite lola-launcher-aura;position:absolute;inset:-7px}.chat-widget-resize-corner:after{content:"";border-top:2px solid #68d8ffc2;border-left:2px solid #68d8ffc2;border-radius:3px 0 0;width:8px;height:8px;position:absolute;top:5px;left:5px}.bridge-ai-chat-widget[data-mobile=true] .chat-icon-button{width:48px;height:48px}@keyframes lola-launcher-breathe{0%,to{transform:scale(1)}50%{transform:scale(1.045)}}@keyframes lola-launcher-aura{0%,to{opacity:.48;transform:scale(.94)rotate(0)}50%{opacity:.82;transform:scale(1.08)rotate(18deg)}}.chat-composer{background:linear-gradient(145deg,#1d142af0,#0a0f16f5);border:0;border-radius:22px;min-height:42px;box-shadow:0 12px 34px #0000004d,0 0 0 1px #b564ff29,inset 0 1px #ffffff12}.chat-composer:focus-within{box-shadow:0 12px 34px #0000004d,0 0 0 1px #68d8ff57,0 0 24px #68d8ff14,inset 0 1px #ffffff14}.chat-composer-button{background:var(--chat-surface-customer);border-radius:15px;box-shadow:0 4px 14px #00000024}.chat-composer-button:hover{background:#684b6c}.chat-talk-button{width:var(--chat-talk-expanded-width);flex:none;transition:width .22s cubic-bezier(.16,1,.3,1);transform:translateZ(0)}.chat-talk-button[data-compact=true]{width:32px}.chat-unread-indicator{right:-2px}.bridge-ai-chat-widget[dir=rtl] .chat-unread-indicator{left:-2px;right:auto}.chat-talk-button__content{z-index:1;pointer-events:none;align-items:center;gap:8px;padding:0 12px;display:flex;position:absolute;inset:0}.chat-talk-button__label{opacity:1;flex:none;line-height:16px;transition:opacity 90ms ease-out,transform .18s cubic-bezier(.16,1,.3,1);transform:translateZ(0)}.chat-talk-button[data-compact=true] .chat-talk-button__content{justify-content:center;gap:0;padding:0}.chat-talk-button[data-compact=true] .chat-talk-button__label{opacity:0;position:absolute;inset-inline-start:38px;transform:translate(-6px)}.bridge-ai-chat-widget[dir=rtl] .chat-talk-button[data-compact=true] .chat-talk-button__label{left:auto;right:38px;transform:translate(6px)}.chat-send-button{background:var(--chat-accent-lime);color:#081207;border-radius:9999px;flex:0 0 32px;justify-content:center;align-items:center;width:32px;height:32px;transition:filter .16s,transform .16s,opacity .16s;display:flex;box-shadow:0 6px 18px #d7ff6438}.chat-send-button:hover:not(:disabled){filter:brightness(1.08)}.chat-send-button:active:not(:disabled){transform:scale(.95)}.chat-send-button:disabled{box-shadow:none;color:#ffffff3d;background:#ffffff13}.chat-cta-primary,.chat-cta-secondary{isolation:isolate;border-radius:9999px;justify-content:center;align-items:center;min-width:44px;min-height:44px;padding:10px 16px;font-size:14px;font-weight:600;line-height:16px;transition:background-color .16s,border-color .16s,transform .16s;display:inline-flex;position:relative}.chat-cta-primary{background:var(--chat-accent-lime);color:#081207;border:0;box-shadow:0 6px 18px #d7ff642e}.chat-cta-primary:hover{filter:brightness(1.07)}.chat-cta-action{background:linear-gradient(135deg,var(--chat-accent-lime),#a6ef36);color:#081207;box-shadow:0 8px 24px #8fff373d,inset 0 1px #ffffff47}.chat-cta-action:hover{filter:brightness(1.12)}.chat-cta-secondary{color:#ffffffb8;background:#fff1;border:1px solid #ffffff1f}.chat-cta-secondary:hover{background:#68d8ff14;border-color:#68d8ff47}.chat-choice-option{isolation:isolate;color:#ffffffe6;text-align:center;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);background:#00000047;border:1px solid #ffffff29;border-radius:22px;justify-content:center;align-items:center;min-width:44px;min-height:30px;padding:4px 12px;font-size:12px;font-weight:600;line-height:20px;transition:color .14s,background-color .14s,border-color .14s,opacity .14s,transform .12s;display:inline-flex;position:relative}.chat-choice-option:before{content:"";pointer-events:auto;background:0 0;position:absolute;inset-block:-5px;inset-inline:0}.chat-choice-option[data-presentation=PRIMARY]{background:var(--chat-accent-lime);color:#081207;border-color:#0000}.chat-choice-option[data-presentation=TERTIARY]{color:#ffffffc2;background:#ffffff13;border-color:#ffffff1f}.chat-choice-option--selected,.chat-choice-option:focus-visible,.chat-cta-primary:focus-visible,.chat-cta-secondary:focus-visible{outline:2px solid var(--chat-accent-cyan);outline-offset:2px}.chat-choice-option:active:not(:disabled),.chat-cta-primary:active:not(:disabled),.chat-cta-secondary:active:not(:disabled){transform:scale(.97)}.chat-attention-nudge-once:after{z-index:-1;border-radius:inherit;content:"";opacity:0;pointer-events:none;background:#d7ff647a;animation:3s ease-out 3s infinite both compact-scenario-preview-nudge-glow;position:absolute;inset:-4px;transform:scale(.97)}.chat-attention-nudge-once{animation:3s ease-out 3s infinite both compact-scenario-preview-nudge}.chat-attention-nudge-once:active:not(:disabled){animation:none;transform:scale(.97)}.chat-attention-nudge-once:active:not(:disabled):after{opacity:0;animation:none}.chat-voice-card{-webkit-backdrop-filter:blur(22px)saturate(135%);backdrop-filter:blur(22px)saturate(135%);background:#0d1016c7;border:1px solid #ffffff1c;border-radius:20px;box-shadow:0 12px 36px #0000003d}.chat-microphone-button{color:#fff;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);background:#0d1016a6;border:1px solid #ffffff21;border-radius:9999px;justify-content:center;align-items:center;width:68px;height:68px;transition:transform .16s,border-color .16s,background-color .16s;display:flex;position:relative;box-shadow:0 12px 32px #0000003d,inset 0 1px #ffffff0f}.chat-microphone-button:hover{border-color:#68d8ff6b;transform:translateY(-1px)}.chat-microphone-button_active{background:#68d8ff2e;border-color:#68d8ff75;box-shadow:0 12px 32px #0000003d,0 0 0 6px #68d8ff0f}.chat-list-surface{background:radial-gradient(circle at 92% 0,#68d8ff1a,#0000 26%),radial-gradient(circle at 8% 0,#ef6b7f1a,#0000 28%),#0d1016;box-shadow:inset 0 1px #ffffff0d}.chat-list-item_selected{background:linear-gradient(100deg,#70265757,#14475e47);box-shadow:inset 0 1px #ffffff0d}.chat-list-entry{content-visibility:auto;contain-intrinsic-block-size:64px}.chat-route-stage{border-radius:inherit;isolation:isolate;overflow:hidden}.chat-route-page{border-radius:inherit;height:100%;position:absolute;inset:0;overflow:hidden}.chat-route-page_background{z-index:1}.chat-route-pane{z-index:2;backface-visibility:hidden;contain:layout paint;will-change:transform,opacity}.chat-route-pane_exit{pointer-events:none}.chat-route-pane .chat-list-entry{content-visibility:visible}.chat-route-pane_enter.chat-route-pane_forward{animation:.3s cubic-bezier(.16,1,.3,1) both chat-route-forward-enter;animation-timing-function:var(--chat-route-enter-easing)}.chat-route-pane_exit.chat-route-pane_backward{animation:.24s cubic-bezier(.4,0,.7,.2) both chat-route-backward-exit}@keyframes chat-route-forward-enter{0%{opacity:.88;transform:translate3d(var(--chat-route-offset-x),0,0)}to{opacity:1;transform:translate(0)}}@keyframes chat-route-backward-exit{0%{opacity:1;transform:translate(0)}to{opacity:.94;transform:translate3d(var(--chat-route-offset-x),0,0)}}.chat-message-skeleton{justify-content:flex-end;min-height:min(420px,62vh)}.chat-message-skeleton-bubble{animation:1.2s ease-in-out infinite alternate chat-message-skeleton-pulse;animation-delay:var(--chat-skeleton-delay);will-change:opacity;position:relative;overflow:hidden}.chat-message-skeleton-bubble:after{content:"";pointer-events:none;animation:1.45s cubic-bezier(.4,0,.2,1) infinite chat-message-skeleton-shimmer;animation-delay:var(--chat-skeleton-delay);will-change:transform;background:linear-gradient(105deg,#0000 24%,#ffffff16,#0000 72%);position:absolute;inset:-1px;transform:translate(-125%)}.chat-avatar-ring{background:linear-gradient(145deg,var(--chat-accent-cherry),var(--chat-accent-cyan));border-radius:9999px;padding:1px;display:inline-flex;box-shadow:0 4px 14px #0003}.chat-scrollbar{overscroll-behavior:contain;scrollbar-color:transparent transparent;scrollbar-width:thin;touch-action:pan-y}.chat-scrollbar:hover{scrollbar-color:#ffffff38 transparent}.chat-scrollbar::-webkit-scrollbar{width:4px;height:4px}.chat-scrollbar::-webkit-scrollbar-track{background:0 0}.chat-scrollbar::-webkit-scrollbar-thumb{background:0 0;border-radius:9999px}.chat-scrollbar:hover::-webkit-scrollbar-thumb{background:#ffffff38}.no-scrollbar{scrollbar-width:none;-ms-overflow-style:none}.no-scrollbar::-webkit-scrollbar{display:none}.chat-pending-assistant-message{transform-origin:0 100%;animation:.22s cubic-bezier(.22,1,.36,1) both chat-pending-assistant-message-in}.bridge-ai-chat-widget[dir=rtl] .chat-pending-assistant-message{transform-origin:100% 100%}.chat-typing-indicator{align-items:center;gap:5px;display:flex}.chat-typing-indicator__dot{background-color:var(--chat-accent-cyan);opacity:.38;border-radius:50%;width:7px;height:7px;animation:1.2s cubic-bezier(.45,0,.55,1) infinite both chat-typing-dot;transform:translateY(0)scale(.82)}.chat-typing-indicator__dot_left{animation-delay:0s}.chat-typing-indicator__dot_center{animation-delay:.14s}.chat-typing-indicator__dot_right{animation-delay:.28s}.chat-stream-fragment{animation:.12s cubic-bezier(.22,1,.36,1) both chat-stream-fragment-in}.chat-support-message-enter{transform-origin:0 100%;animation:.18s cubic-bezier(.22,1,.36,1) chat-support-message-in}.bridge-ai-chat-widget[dir=rtl] .chat-support-message-enter{transform-origin:100% 100%}@keyframes chat-support-message-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}@keyframes chat-stream-fragment-in{0%{opacity:.15}to{opacity:1}}@keyframes chat-message-skeleton-pulse{0%{opacity:.58}to{opacity:1}}@keyframes chat-message-skeleton-shimmer{to{transform:translate(125%)}}@media(prefers-reduced-motion:reduce){[data-lola-widget-shell],.chat-widget-panel,.chat-launcher,.chat-talk-button,.chat-talk-button__icon,.chat-talk-button__label{transition:none}.chat-launcher__portrait,.chat-launcher__aura,.chat-pending-assistant-message,.chat-typing-indicator__dot,.chat-composer-attachment,.chat-composer-attachment__progress span.is-scanning,.chat-attachment-dropzone{animation:none}.chat-route-pane{animation-duration:1ms!important}.chat-typing-indicator__dot{opacity:.72;transform:none}.chat-stream-fragment{animation:none}.chat-support-message-enter{animation:none;transform:none}.chat-message-skeleton-bubble{opacity:.82;will-change:auto;animation:none}.chat-message-skeleton-bubble:after{will-change:auto;animation:none;display:none}}@keyframes chat-pending-assistant-message-in{0%{opacity:0;transform:translateY(4px)scale(.96)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes chat-typing-dot{0%,60%,to{opacity:.38;transform:translateY(0)scale(.82)}30%{opacity:1;transform:translateY(-3px)scale(1.05)}}.compact-scenario-preview{isolation:isolate;box-sizing:border-box;max-height:inherit;width:100%;max-width:calc(100vw - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px) - 24px);border:1px solid var(--lola-compact-preview-border,#ffffff1a);background:var(--lola-compact-preview-surface,#121214fe);color:var(--lola-compact-preview-text,var(--chat-text-primary));transform-origin:100% 100%;border-radius:26px 26px 8px;flex-direction:column;padding:18px 54px 18px 18px;display:flex;position:relative;overflow:visible;box-shadow:0 14px 38px #0000004d}.compact-scenario-preview:before{z-index:-1;border-right:1px solid var(--lola-compact-preview-border,#ffffff1a);border-bottom:1px solid var(--lola-compact-preview-border,#ffffff1a);background:var(--lola-compact-preview-surface,#121214fe);content:"";width:16px;height:16px;position:absolute;bottom:-7px;right:18px;transform:rotate(45deg)}.compact-preview-anchor[data-side=left] .compact-scenario-preview{transform-origin:0 100%;border-radius:26px 26px 26px 8px}.compact-preview-anchor[data-side=left] .compact-scenario-preview:before{left:18px;right:auto}.compact-preview-anchor[data-side=right] .compact-scenario-preview{transform-origin:100% 100%;border-radius:26px 26px 8px}.compact-preview-anchor[data-placement=below][data-side=right] .compact-scenario-preview{transform-origin:100% 0;border-radius:26px 8px 26px 26px}.compact-preview-anchor[data-placement=below][data-side=left] .compact-scenario-preview{transform-origin:0 0;border-radius:8px 26px 26px}.compact-preview-anchor[data-placement=below] .compact-scenario-preview:before{border-top:1px solid var(--lola-compact-preview-border,#ffffff1a);border-bottom:0;border-right:0;border-left:1px solid var(--lola-compact-preview-border,#ffffff1a);top:-7px;bottom:auto}.compact-scenario-preview[data-kind=CHOICE]{padding-right:18px}.compact-scenario-preview[data-phase=ENTERING]{animation:.22s cubic-bezier(.16,1,.3,1) both compact-scenario-preview-in}.compact-scenario-preview[data-phase=EXITING]{pointer-events:none;animation:.16s cubic-bezier(.4,0,.7,.2) both compact-scenario-preview-out}.compact-scenario-preview__copy{overflow-wrap:anywhere;overscroll-behavior:contain;scrollbar-width:thin;min-width:0;min-height:0;font-size:15px;font-weight:500;line-height:1.45;overflow-y:auto}.compact-scenario-preview__copy :where(p,ul,ol,blockquote,pre){margin:0}.compact-scenario-preview__copy :where(p,ul,ol,blockquote,pre)+:where(p,ul,ol,blockquote,pre){margin-top:8px}.compact-scenario-preview__copy :where(ul,ol){padding-inline-start:20px}.compact-scenario-preview__copy :where(code,pre){font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}.compact-scenario-preview__link-text{color:var(--lola-compact-preview-link,var(--chat-accent-cyan));text-underline-offset:2px;text-decoration:underline;text-decoration-thickness:1px}.compact-scenario-preview__coalesced{width:max-content;max-width:100%;color:var(--lola-compact-preview-muted,#ffffffb3);background:#ffffff14;border-radius:9999px;margin:10px 0 0;padding:4px 9px;font-size:12px;font-weight:600;line-height:16px}.compact-scenario-preview__phrase{display:inline}.compact-scenario-preview[data-phase=ENTERING] .compact-scenario-preview__phrase{opacity:0;animation:.28s cubic-bezier(.22,1,.36,1) both compact-scenario-preview-phrase-in;animation-delay:var(--compact-preview-phrase-delay,90ms)}.compact-scenario-preview__dismiss{width:44px;min-width:44px;height:44px;min-height:44px;color:var(--lola-compact-preview-dismiss,#ffffffa8);background:0 0;border:0;border-radius:9999px;place-items:center;font-size:30px;font-weight:300;line-height:1;transition:color .14s,background-color .14s,transform .12s;display:grid;position:absolute;top:4px;right:4px}.compact-scenario-preview__actions{grid-template-columns:minmax(0,1fr);gap:8px;margin-top:16px;display:grid}.compact-scenario-preview[data-kind=CHOICE] .compact-scenario-preview__actions{overscroll-behavior:contain;scrollbar-width:thin;min-height:0;margin:10px -2px -2px;padding:5px 2px;overflow-y:auto}.compact-scenario-preview[data-phase=ENTERING] .compact-scenario-preview__actions{opacity:0;animation:.17s cubic-bezier(.22,1,.36,1) both compact-scenario-preview-actions-in;animation-delay:var(--compact-preview-actions-delay,.42s);transform:translateY(5px)}.compact-scenario-preview[data-kind=CTA] .compact-scenario-preview__copy.compact-scenario-preview__sr-only~.compact-scenario-preview__actions{margin-top:0}.compact-scenario-preview__choice-group{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;display:grid}.compact-scenario-preview__action{isolation:isolate;overflow-wrap:anywhere;text-align:center;border:1px solid #0000;border-radius:9999px;justify-content:center;align-items:center;min-width:44px;min-height:44px;padding:10px 16px;font-size:14px;font-weight:650;line-height:20px;transition:color .14s,background-color .14s,border-color .14s,opacity .14s,transform .12s;display:inline-flex;position:relative}.compact-scenario-preview[data-kind=CHOICE] .compact-scenario-preview__action{border-radius:22px;min-height:30px;padding:4px 12px;font-size:12px;line-height:20px}.compact-scenario-preview[data-kind=CHOICE] .compact-scenario-preview__action:before{content:"";pointer-events:auto;background:0 0;position:absolute;inset-block:-5px;inset-inline:0}.compact-scenario-preview__action[data-presentation=PRIMARY]{border-color:var(--lola-compact-preview-primary-border,transparent);background:var(--lola-compact-preview-primary-background,var(--chat-accent-lime));color:var(--lola-compact-preview-primary-foreground,#081207)}.compact-scenario-preview__action[data-presentation=TERTIARY]{border-color:var(--lola-compact-preview-tertiary-border,#fff6);background:var(--lola-compact-preview-tertiary-background,#ffffff1f);color:var(--lola-compact-preview-tertiary-foreground,#ffffffb8)}.compact-scenario-preview__action[data-presentation=PRIMARY]:after{z-index:-1;border-radius:inherit;background:var(--lola-compact-preview-primary-attention,#d7ff647a);content:"";opacity:0;pointer-events:none;position:absolute;inset:-4px;transform:scale(.92)}.compact-scenario-preview__action[data-presentation=PRIMARY][data-attention=NUDGE_ONCE]:after{animation:3s ease-out 3s infinite both compact-scenario-preview-nudge-glow}.compact-scenario-preview__action[data-presentation=PRIMARY][data-attention=NUDGE_ONCE]{animation:3s ease-out 3s infinite both compact-scenario-preview-nudge}.compact-scenario-preview__action[data-presentation=PRIMARY][data-attention=NUDGE_ONCE]:active:not(:disabled){animation:none;transform:scale(.97)}.compact-scenario-preview__action[data-presentation=PRIMARY][data-attention=NUDGE_ONCE]:active:not(:disabled):after{opacity:0;animation:none}.compact-scenario-preview__feedback{color:var(--lola-compact-preview-error,#fecaca);margin:10px 0 0;font-size:12px;line-height:1.4}.compact-scenario-preview__dismiss:focus-visible,.compact-scenario-preview__action:focus-visible{outline:2px solid var(--lola-compact-preview-focus,var(--chat-accent-cyan));outline-offset:2px}.compact-scenario-preview__dismiss:active:not(:disabled),.compact-scenario-preview__action:active:not(:disabled){transform:scale(.97)}.compact-scenario-preview__dismiss:disabled,.compact-scenario-preview__action:disabled{opacity:.48}.compact-scenario-preview__sr-only{clip:rect(0,0,0,0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media(hover:hover){.compact-scenario-preview__dismiss:hover:not(:disabled){background:var(--lola-compact-preview-dismiss-hover-background,#ffffff14);color:var(--lola-compact-preview-dismiss-hover,white)}.compact-scenario-preview__action[data-presentation=PRIMARY]:hover:not(:disabled){background:var(--lola-compact-preview-primary-hover-background,#e0ff88)}.compact-scenario-preview__action[data-presentation=TERTIARY]:hover:not(:disabled){border-color:var(--lola-compact-preview-tertiary-hover-border,#68d8ff4d);background:var(--lola-compact-preview-tertiary-hover-background,#68d8ff17)}}@keyframes compact-scenario-preview-in{0%{opacity:0;transform:translateY(9px)scale(.975)}to{opacity:1;transform:translate(0)scale(1)}}@keyframes compact-scenario-preview-out{0%{opacity:1;transform:translate(0)scale(1)}to{opacity:0;transform:translateY(5px)scale(.985)}}@keyframes compact-scenario-preview-phrase-in{0%{opacity:0}to{opacity:1}}@keyframes compact-scenario-preview-actions-in{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translate(0)}}@keyframes compact-scenario-preview-nudge-glow{0%,12%,to{opacity:0;transform:scale(.97)}6%{opacity:.24;transform:scale(1.04)}}@keyframes compact-scenario-preview-nudge{0%,12%,to{transform:translate(0)scale(1)}3%{transform:translate(-1px)scale(1.006)}6%{transform:translate(1px)scale(1.012)}9%{transform:translate(-.5px)scale(1.006)}}@media(prefers-reduced-motion:reduce){.compact-scenario-preview,.compact-scenario-preview__phrase,.compact-scenario-preview__actions,.compact-scenario-preview__action,.compact-scenario-preview__action:after,.chat-attention-nudge-once,.chat-attention-nudge-once:after{transition:none!important;animation:none!important}.compact-scenario-preview,.compact-scenario-preview__phrase,.compact-scenario-preview__actions,.compact-scenario-preview__action,.compact-scenario-preview__action:after{transform:none}.compact-scenario-preview,.compact-scenario-preview__phrase,.compact-scenario-preview__actions{opacity:1}.compact-scenario-preview__action:after{opacity:0}}@media(forced-colors:active){.compact-scenario-preview,.compact-scenario-preview__action,.compact-scenario-preview__dismiss{color:canvastext;background:canvas;border:1px solid canvastext}.compact-scenario-preview__action:after{display:none}}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.-end-0\\.5{inset-inline-end:calc(var(--spacing)*-.5)}.-top-0\\.5{top:calc(var(--spacing)*-.5)}.top-0{top:calc(var(--spacing)*0)}.top-1\\/2{top:50%}.top-5{top:calc(var(--spacing)*5)}.right-0{right:calc(var(--spacing)*0)}.right-5{right:calc(var(--spacing)*5)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-5{bottom:calc(var(--spacing)*5)}.left-0{left:calc(var(--spacing)*0)}.left-1\\/2{left:50%}.left-5{left:calc(var(--spacing)*5)}.z-0{z-index:0}.z-1{z-index:1}.z-5{z-index:5}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-51{z-index:51}.z-\\[70\\]{z-index:70}.z-\\[9999999\\]{z-index:9999999}.\\!container{width:100%!important}@media(min-width:40rem){.\\!container{max-width:40rem!important}}@media(min-width:48rem){.\\!container{max-width:48rem!important}}@media(min-width:64rem){.\\!container{max-width:64rem!important}}@media(min-width:80rem){.\\!container{max-width:80rem!important}}@media(min-width:96rem){.\\!container{max-width:96rem!important}}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.my-2{margin-block:calc(var(--spacing)*2)}.ms-2{margin-inline-start:calc(var(--spacing)*2)}.me-2{margin-inline-end:calc(var(--spacing)*2)}.mt-0\\.5{margin-top:calc(var(--spacing)*.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-auto{margin-top:auto}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.box-content{box-sizing:content-box}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.h-0{height:calc(var(--spacing)*0)}.h-1{height:calc(var(--spacing)*1)}.h-1\\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-3{height:calc(var(--spacing)*3)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-4\\.5{height:calc(var(--spacing)*4.5)}.h-5{height:calc(var(--spacing)*5)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-\\[50\\%\\]{height:50%}.h-\\[52\\%\\]{height:52%}.h-\\[66vh\\]{height:66vh}.h-\\[650px\\]{height:650px}.h-\\[calc\\(100\\%-64px\\)\\]{height:calc(100% - 64px)}.h-\\[calc\\(100\\%-96px\\)\\]{height:calc(100% - 96px)}.h-fit{height:fit-content}.h-full{height:100%}.h-px{height:1px}.max-h-\\[66vh\\]{max-height:66vh}.max-h-\\[min\\(82vh\\,760px\\)\\]{max-height:min(82vh,760px)}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-8{min-height:calc(var(--spacing)*8)}.min-h-9{min-height:calc(var(--spacing)*9)}.min-h-14{min-height:calc(var(--spacing)*14)}.min-h-16{min-height:calc(var(--spacing)*16)}.min-h-64{min-height:calc(var(--spacing)*64)}.min-h-96{min-height:calc(var(--spacing)*96)}.min-h-full{min-height:100%}.w-1{width:calc(var(--spacing)*1)}.w-1\\.5{width:calc(var(--spacing)*1.5)}.w-2{width:calc(var(--spacing)*2)}.w-3{width:calc(var(--spacing)*3)}.w-3\\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-14{width:calc(var(--spacing)*14)}.w-\\[42\\%\\]{width:42%}.w-\\[48\\%\\]{width:48%}.w-\\[50\\%\\]{width:50%}.w-\\[52\\%\\]{width:52%}.w-\\[56\\%\\]{width:56%}.w-\\[58\\%\\]{width:58%}.w-\\[62\\%\\]{width:62%}.w-\\[64\\%\\]{width:64%}.w-\\[66\\%\\]{width:66%}.w-\\[68\\%\\]{width:68%}.w-\\[70\\%\\]{width:70%}.w-\\[72\\%\\]{width:72%}.w-\\[74\\%\\]{width:74%}.w-\\[76\\%\\]{width:76%}.w-\\[78\\%\\]{width:78%}.w-\\[86\\%\\]{width:86%}.w-\\[390px\\]{width:390px}.w-\\[min\\(92vw\\,920px\\)\\]{width:min(92vw,920px)}.w-\\[min\\(232px\\,calc\\(100\\%-2rem\\)\\)\\]{width:min(232px,100% - 2rem)}.w-\\[min\\(232px\\,calc\\(100\\%-208px\\)\\)\\]{width:min(232px,100% - 208px)}.w-fit{width:fit-content}.w-full{width:100%}.max-w-8{max-width:calc(var(--spacing)*8)}.max-w-70{max-width:calc(var(--spacing)*70)}.max-w-72{max-width:calc(var(--spacing)*72)}.max-w-\\[86\\%\\]{max-width:86%}.max-w-\\[232px\\]{max-width:232px}.max-w-\\[calc\\(100vw-32px\\)\\]{max-width:calc(100vw - 32px)}.max-w-full{max-width:100%}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing)*0)}.flex-1{flex:1}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.-translate-x-1\\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1{--tw-translate-y:calc(var(--spacing)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-0{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-1\\.5{--tw-translate-y:calc(var(--spacing)*1.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-2{--tw-translate-y:calc(var(--spacing)*2);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-3{--tw-translate-y:calc(var(--spacing)*3);translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x)var(--tw-scale-y)}.-scale-x-100{--tw-scale-x: -100% ;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\\[0\\.98\\]{scale:.98}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-grab{cursor:grab}.cursor-n-resize{cursor:n-resize}.cursor-nwse-resize{cursor:nwse-resize}.cursor-w-resize{cursor:w-resize}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.appearance-none{appearance:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-\\[3px\\]{gap:3px}.gap-\\[10px\\]{gap:10px}.self-center{align-self:center}.self-end{align-self:flex-end}.self-start{align-self:flex-start}.justify-self-end{justify-self:flex-end}.justify-self-start{justify-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-2xl{border-radius:calc(var(--radius) + 8px)}.rounded-\\[17px\\]{border-radius:17px}.rounded-\\[24px\\]{border-radius:24px}.rounded-\\[28px\\]{border-radius:28px}.rounded-\\[32px\\]{border-radius:32px}.rounded-\\[inherit\\]{border-radius:inherit}.rounded-full{border-radius:3.40282e38px}.rounded-none{border-radius:0}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.rounded-ee-\\[5px\\]{border-end-end-radius:5px}.rounded-es-\\[5px\\]{border-end-start-radius:5px}.rounded-br-\\[5px\\]{border-bottom-right-radius:5px}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.border-\\[\\#68d8ff\\]\\/10{border-color:#68d8ff1a}.border-\\[\\#68d8ff\\]\\/24{border-color:#68d8ff3d}.border-\\[\\#68d8ff\\]\\/35{border-color:#68d8ff59}.border-red-200\\/10{border-color:#ffcaca1a}@supports (color:color-mix(in lab,red,red)){.border-red-200\\/10{border-color:color-mix(in oklab,var(--color-red-200)10%,transparent)}}.border-white\\/8{border-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.border-white\\/8{border-color:color-mix(in oklab,var(--color-white)8%,transparent)}}.border-white\\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\\/12{border-color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.border-white\\/12{border-color:color-mix(in oklab,var(--color-white)12%,transparent)}}.border-white\\/14{border-color:#ffffff24}@supports (color:color-mix(in lab,red,red)){.border-white\\/14{border-color:color-mix(in oklab,var(--color-white)14%,transparent)}}.border-white\\/\\[0\\.05\\]{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\\/\\[0\\.05\\]{border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.border-white\\/\\[0\\.06\\]{border-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.border-white\\/\\[0\\.06\\]{border-color:color-mix(in oklab,var(--color-white)6%,transparent)}}.border-white\\/\\[0\\.045\\]{border-color:#ffffff0b}@supports (color:color-mix(in lab,red,red)){.border-white\\/\\[0\\.045\\]{border-color:color-mix(in oklab,var(--color-white)4.5%,transparent)}}.bg-\\[\\#0c1119\\]\\/96{background-color:#0c1119f5}.bg-\\[\\#5b405f\\]{background-color:#5b405f}.bg-\\[\\#5b405f\\]\\/70{background-color:#5b405fb3}.bg-\\[\\#68d8ff\\]{background-color:#68d8ff}.bg-\\[\\#68d8ff\\]\\/10,.bg-\\[\\#68d8ff\\]\\/\\[0\\.1\\]{background-color:#68d8ff1a}.bg-\\[\\#68d8ff\\]\\/\\[0\\.13\\]{background-color:#68d8ff21}.bg-\\[\\#090b10\\]\\/58{background-color:#090b1094}.bg-\\[\\#05080d\\]\\/82{background-color:#05080dd1}.bg-\\[\\#17131b\\]{background-color:#17131b}.bg-\\[\\#111319\\]{background-color:#111319}.bg-\\[\\#111923\\]{background-color:#111923}.bg-\\[\\#ef6b7f\\]{background-color:#ef6b7f}.bg-\\[radial-gradient\\(circle_at_50\\%_20\\%\\,rgba\\(104\\,216\\,255\\,\\.08\\)\\,transparent_46\\%\\)\\,\\#080c12\\]{background-color:radial-gradient(circle at 50% 20%,#68d8ff14,transparent 46%),#080c12}.bg-\\[var\\(--chat-surface-agent\\)\\]{background-color:var(--chat-surface-agent)}.bg-black{background-color:var(--color-black)}.bg-black\\/8{background-color:#00000014}@supports (color:color-mix(in lab,red,red)){.bg-black\\/8{background-color:color-mix(in oklab,var(--color-black)8%,transparent)}}.bg-black\\/20{background-color:#0003}@supports (color:color-mix(in lab,red,red)){.bg-black\\/20{background-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.bg-black\\/32{background-color:#00000052}@supports (color:color-mix(in lab,red,red)){.bg-black\\/32{background-color:color-mix(in oklab,var(--color-black)32%,transparent)}}.bg-black\\/35{background-color:#00000059}@supports (color:color-mix(in lab,red,red)){.bg-black\\/35{background-color:color-mix(in oklab,var(--color-black)35%,transparent)}}.bg-black\\/45{background-color:#00000073}@supports (color:color-mix(in lab,red,red)){.bg-black\\/45{background-color:color-mix(in oklab,var(--color-black)45%,transparent)}}.bg-current{background-color:currentColor}.bg-red-300\\/8{background-color:#ffa3a314}@supports (color:color-mix(in lab,red,red)){.bg-red-300\\/8{background-color:color-mix(in oklab,var(--color-red-300)8%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-white\\/5{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\\/5{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.bg-white\\/\\[0\\.04\\]{background-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.bg-white\\/\\[0\\.04\\]{background-color:color-mix(in oklab,var(--color-white)4%,transparent)}}.bg-white\\/\\[0\\.06\\]{background-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.bg-white\\/\\[0\\.06\\]{background-color:color-mix(in oklab,var(--color-white)6%,transparent)}}.bg-white\\/\\[0\\.07\\]{background-color:#ffffff12}@supports (color:color-mix(in lab,red,red)){.bg-white\\/\\[0\\.07\\]{background-color:color-mix(in oklab,var(--color-white)7%,transparent)}}.bg-white\\/\\[0\\.09\\]{background-color:#ffffff17}@supports (color:color-mix(in lab,red,red)){.bg-white\\/\\[0\\.09\\]{background-color:color-mix(in oklab,var(--color-white)9%,transparent)}}.bg-white\\/\\[0\\.11\\]{background-color:#ffffff1c}@supports (color:color-mix(in lab,red,red)){.bg-white\\/\\[0\\.11\\]{background-color:color-mix(in oklab,var(--color-white)11%,transparent)}}.bg-white\\/\\[0\\.035\\]{background-color:#ffffff09}@supports (color:color-mix(in lab,red,red)){.bg-white\\/\\[0\\.035\\]{background-color:color-mix(in oklab,var(--color-white)3.5%,transparent)}}.bg-\\[linear-gradient\\(145deg\\,\\#684d6d_0\\%\\,\\#3f3348_100\\%\\)\\]{background-image:linear-gradient(145deg,#684d6d,#3f3348)}.bg-\\[linear-gradient\\(180deg\\,rgba\\(25\\,22\\,28\\,0\\.97\\)\\,rgba\\(14\\,13\\,16\\,0\\.98\\)\\)\\]{background-image:linear-gradient(#19161cf7,#0e0d10fa)}.bg-\\[linear-gradient\\(to_bottom\\,rgba\\(0\\,0\\,0\\,0\\.7\\)_0\\%\\,rgba\\(0\\,0\\,0\\,0\\.7\\)_20\\%\\,rgba\\(0\\,0\\,0\\,0\\.2\\)_60\\%\\,rgba\\(0\\,0\\,0\\,0\\)_100\\%\\)\\]{background-image:linear-gradient(#000000b3 0% 20%,#0003 60%,#0000)}.bg-\\[linear-gradient\\(to_top\\,rgba\\(8\\,10\\,15\\,0\\.78\\)_0\\%\\,rgba\\(8\\,10\\,15\\,0\\.42\\)_42\\%\\,rgba\\(8\\,10\\,15\\,0\\)_100\\%\\)\\]{background-image:linear-gradient(#080a0f00,#080a0f6b 58%,#080a0fc7)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-\\[50\\%_20\\%\\]{object-position:50% 20%}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-\\[11px\\]{padding-inline:11px}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-6{padding-block:calc(var(--spacing)*6)}.py-\\[7px\\]{padding-block:7px}.ps-0\\.5{padding-inline-start:calc(var(--spacing)*.5)}.ps-1{padding-inline-start:calc(var(--spacing)*1)}.pe-3{padding-inline-end:calc(var(--spacing)*3)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-6{padding-top:calc(var(--spacing)*6)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-5{padding-bottom:calc(var(--spacing)*5)}.text-center{text-align:center}.text-start{text-align:start}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[10\\.5px\\]{font-size:10.5px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.text-\\[13px\\]{font-size:13px}.text-\\[14px\\]{font-size:14px}.text-\\[15px\\]{font-size:15px}.text-\\[16px\\]{font-size:16px}.leading-3\\.5{--tw-leading:calc(var(--spacing)*3.5);line-height:calc(var(--spacing)*3.5)}.leading-4{--tw-leading:calc(var(--spacing)*4);line-height:calc(var(--spacing)*4)}.leading-5{--tw-leading:calc(var(--spacing)*5);line-height:calc(var(--spacing)*5)}.leading-\\[18px\\]{--tw-leading:18px;line-height:18px}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\\[-0\\.01em\\]{--tw-tracking:-.01em;letter-spacing:-.01em}.tracking-\\[-0\\.02em\\]{--tw-tracking:-.02em;letter-spacing:-.02em}.tracking-\\[-0\\.005em\\]{--tw-tracking:-.005em;letter-spacing:-.005em}.tracking-\\[0\\.01em\\]{--tw-tracking:.01em;letter-spacing:.01em}.tracking-\\[0\\.08em\\]{--tw-tracking:.08em;letter-spacing:.08em}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\\[\\#8df0c8\\]{color:#8df0c8}.text-\\[\\#68d8ff\\]{color:#68d8ff}.text-\\[\\#a6ebce\\]{color:#a6ebce}.text-\\[\\#a9eaff\\]{color:#a9eaff}.text-\\[\\#bcecff\\]{color:#bcecff}.text-\\[\\#f3f0f4\\]{color:#f3f0f4}.text-amber-100\\/74{color:#fef3c6bd}@supports (color:color-mix(in lab,red,red)){.text-amber-100\\/74{color:color-mix(in oklab,var(--color-amber-100)74%,transparent)}}.text-amber-100\\/86{color:#fef3c6db}@supports (color:color-mix(in lab,red,red)){.text-amber-100\\/86{color:color-mix(in oklab,var(--color-amber-100)86%,transparent)}}.text-amber-200{color:var(--color-amber-200)}.text-red-100\\/80{color:#ffe2e2cc}@supports (color:color-mix(in lab,red,red)){.text-red-100\\/80{color:color-mix(in oklab,var(--color-red-100)80%,transparent)}}.text-red-100\\/88{color:#ffe2e2e0}@supports (color:color-mix(in lab,red,red)){.text-red-100\\/88{color:color-mix(in oklab,var(--color-red-100)88%,transparent)}}.text-red-200{color:var(--color-red-200)}.text-rose-200\\/82{color:#ffccd3d1}@supports (color:color-mix(in lab,red,red)){.text-rose-200\\/82{color:color-mix(in oklab,var(--color-rose-200)82%,transparent)}}.text-violet-200{color:var(--color-violet-200)}.text-white{color:var(--color-white)}.text-white\\/35{color:#ffffff59}@supports (color:color-mix(in lab,red,red)){.text-white\\/35{color:color-mix(in oklab,var(--color-white)35%,transparent)}}.text-white\\/38{color:#ffffff61}@supports (color:color-mix(in lab,red,red)){.text-white\\/38{color:color-mix(in oklab,var(--color-white)38%,transparent)}}.text-white\\/42{color:#ffffff6b}@supports (color:color-mix(in lab,red,red)){.text-white\\/42{color:color-mix(in oklab,var(--color-white)42%,transparent)}}.text-white\\/44{color:#ffffff70}@supports (color:color-mix(in lab,red,red)){.text-white\\/44{color:color-mix(in oklab,var(--color-white)44%,transparent)}}.text-white\\/48{color:#ffffff7a}@supports (color:color-mix(in lab,red,red)){.text-white\\/48{color:color-mix(in oklab,var(--color-white)48%,transparent)}}.text-white\\/50{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.text-white\\/50{color:color-mix(in oklab,var(--color-white)50%,transparent)}}.text-white\\/52{color:#ffffff85}@supports (color:color-mix(in lab,red,red)){.text-white\\/52{color:color-mix(in oklab,var(--color-white)52%,transparent)}}.text-white\\/55{color:#ffffff8c}@supports (color:color-mix(in lab,red,red)){.text-white\\/55{color:color-mix(in oklab,var(--color-white)55%,transparent)}}.text-white\\/58{color:#ffffff94}@supports (color:color-mix(in lab,red,red)){.text-white\\/58{color:color-mix(in oklab,var(--color-white)58%,transparent)}}.text-white\\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\\/62{color:#ffffff9e}@supports (color:color-mix(in lab,red,red)){.text-white\\/62{color:color-mix(in oklab,var(--color-white)62%,transparent)}}.text-white\\/64{color:#ffffffa3}@supports (color:color-mix(in lab,red,red)){.text-white\\/64{color:color-mix(in oklab,var(--color-white)64%,transparent)}}.text-white\\/65{color:#ffffffa6}@supports (color:color-mix(in lab,red,red)){.text-white\\/65{color:color-mix(in oklab,var(--color-white)65%,transparent)}}.text-white\\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\\/72{color:#ffffffb8}@supports (color:color-mix(in lab,red,red)){.text-white\\/72{color:color-mix(in oklab,var(--color-white)72%,transparent)}}.text-white\\/75{color:#ffffffbf}@supports (color:color-mix(in lab,red,red)){.text-white\\/75{color:color-mix(in oklab,var(--color-white)75%,transparent)}}.text-white\\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\\/82{color:#ffffffd1}@supports (color:color-mix(in lab,red,red)){.text-white\\/82{color:color-mix(in oklab,var(--color-white)82%,transparent)}}.text-white\\/86{color:#ffffffdb}@supports (color:color-mix(in lab,red,red)){.text-white\\/86{color:color-mix(in oklab,var(--color-white)86%,transparent)}}.text-white\\/88{color:#ffffffe0}@supports (color:color-mix(in lab,red,red)){.text-white\\/88{color:color-mix(in oklab,var(--color-white)88%,transparent)}}.text-white\\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-white\\/92{color:#ffffffeb}@supports (color:color-mix(in lab,red,red)){.text-white\\/92{color:color-mix(in oklab,var(--color-white)92%,transparent)}}.text-white\\/95{color:#fffffff2}@supports (color:color-mix(in lab,red,red)){.text-white\\/95{color:color-mix(in oklab,var(--color-white)95%,transparent)}}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[0_6px_18px_rgba\\(0\\,0\\,0\\,0\\.16\\)\\]{--tw-shadow:0 6px 18px var(--tw-shadow-color,#00000029);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[0_28px_80px_rgba\\(0\\,0\\,0\\,0\\.48\\)\\]{--tw-shadow:0 28px 80px var(--tw-shadow-color,#0000007a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[0_30px_90px_rgba\\(0\\,0\\,0\\,\\.58\\)\\,0_0_0_1px_rgba\\(104\\,216\\,255\\,\\.05\\)\\]{--tw-shadow:0 30px 90px var(--tw-shadow-color,#00000094),0 0 0 1px var(--tw-shadow-color,#68d8ff0d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[inset_0_0_0_1px_rgba\\(0\\,0\\,0\\,0\\.1\\)\\]{--tw-shadow:inset 0 0 0 1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[inset_0_0_0_1px_rgba\\(239\\,107\\,127\\,0\\.22\\)\\,0_5px_18px_rgba\\(0\\,0\\,0\\,0\\.14\\)\\]{--tw-shadow:inset 0 0 0 1px var(--tw-shadow-color,#ef6b7f38),0 5px 18px var(--tw-shadow-color,#00000024);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[inset_0_0_0_1px_rgba\\(255\\,255\\,255\\,0\\.09\\)\\,0_5px_18px_rgba\\(0\\,0\\,0\\,0\\.14\\)\\]{--tw-shadow:inset 0 0 0 1px var(--tw-shadow-color,#ffffff17),0 5px 18px var(--tw-shadow-color,#00000024);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[inset_0_0_0_1px_rgba\\(255\\,255\\,255\\,0\\.11\\)\\]{--tw-shadow:inset 0 0 0 1px var(--tw-shadow-color,#ffffff1c);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.outline-2{outline-style:var(--tw-outline-style);outline-width:2px}.outline-\\[\\#111319\\]{outline-color:#111319}.outline-black\\/9{outline-color:#00000017}@supports (color:color-mix(in lab,red,red)){.outline-black\\/9{outline-color:color-mix(in oklab,var(--color-black)9%,transparent)}}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.grayscale{--tw-grayscale:grayscale(100%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-md{--tw-backdrop-blur:blur(var(--blur-md));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-blur-xl{--tw-backdrop-blur:blur(var(--blur-xl));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-blur-xs{--tw-backdrop-blur:blur(var(--blur-xs));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-filter{-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.\\!transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events!important;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))!important;transition-duration:var(--tw-duration,var(--default-transition-duration))!important}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[background-color\\,transform\\]{transition-property:background-color,transform;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[height\\]{transition-property:height;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[opacity\\,transform\\]{transition-property:opacity,transform;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.delay-75{transition-delay:75ms}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-\\[180ms\\]{--tw-duration:.18s;transition-duration:.18s}.duration-\\[220ms\\]{--tw-duration:.22s;transition-duration:.22s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.delay-75{--tw-animation-delay:75ms;animation-delay:75ms}.outline-none{--tw-outline-style:none;outline-style:none}.outline-solid{--tw-outline-style:solid;outline-style:solid}.select-none{-webkit-user-select:none;user-select:none}.\\!paused{animation-play-state:paused!important}.\\[overflow-anchor\\:none\\]{overflow-anchor:none}.paused{animation-play-state:paused}.running{animation-play-state:running}@media(hover:hover){.group-hover\\:block:is(:where(.group):hover *){display:block}.group-hover\\:hidden:is(:where(.group):hover *){display:none}.group-hover\\:opacity-70:is(:where(.group):hover *){opacity:.7}}.group-aria-\\[current\\=page\\]\\:opacity-100:is(:where(.group)[aria-current=page] *){opacity:1}.placeholder\\:text-white\\/38::placeholder{color:#ffffff61}@supports (color:color-mix(in lab,red,red)){.placeholder\\:text-white\\/38::placeholder{color:color-mix(in oklab,var(--color-white)38%,transparent)}}@media(hover:hover){.hover\\:border-\\[\\#68d8ff\\]\\/30:hover{border-color:#68d8ff4d}.hover\\:bg-white\\/6:hover{background-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-white\\/6:hover{background-color:color-mix(in oklab,var(--color-white)6%,transparent)}}.hover\\:bg-white\\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-white\\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\\:text-\\[\\#68d8ff\\]:hover{color:#68d8ff}.hover\\:text-white\\/90:hover{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.hover\\:text-white\\/90:hover{color:color-mix(in oklab,var(--color-white)90%,transparent)}}}.active\\:scale-\\[0\\.992\\]:active{scale:.992}.active\\:cursor-grabbing:active{cursor:grabbing}.active\\:bg-white\\/8:active{background-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.active\\:bg-white\\/8:active{background-color:color-mix(in oklab,var(--color-white)8%,transparent)}}.disabled\\:opacity-40:disabled{opacity:.4}.data-disabled\\:opacity-50[data-disabled]{opacity:.5}.data-focus\\:ring-2[data-focus]{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-focus\\:ring-\\[\\#68d8ff\\]\\/65[data-focus]{--tw-ring-color:oklab(83.1484% -.0833826 -.0797253/.65)}.data-hover\\:border-\\[\\#68d8ff\\]\\/42[data-hover]{border-color:#68d8ff6b}.data-hover\\:bg-\\[\\#68d8ff\\]\\/10[data-hover]{background-color:#68d8ff1a}.data-hover\\:bg-\\[\\#68d8ff\\]\\/16[data-hover]{background-color:#68d8ff29}.data-hover\\:bg-white\\/8[data-hover]{background-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.data-hover\\:bg-white\\/8[data-hover]{background-color:color-mix(in oklab,var(--color-white)8%,transparent)}}.data-hover\\:text-white[data-hover]{color:var(--color-white)}@media(prefers-reduced-motion:reduce){.motion-reduce\\:translate-y-0{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.motion-reduce\\:transition-none{transition-property:none}.motion-reduce\\:delay-0{--tw-animation-delay:0s;transition-delay:0s;animation-delay:0s}}@media(min-width:40rem){.sm\\:inline{display:inline}.sm\\:p-5{padding:calc(var(--spacing)*5)}.sm\\:p-6{padding:calc(var(--spacing)*6)}}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:none}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}.bridge-ai-chat-widget{--lola-safe-area-inset-top:env(safe-area-inset-top,0px);--lola-safe-area-inset-right:env(safe-area-inset-right,0px);--lola-safe-area-inset-bottom:env(safe-area-inset-bottom,0px);--lola-safe-area-inset-left:env(safe-area-inset-left,0px);--radius:.625rem;--chat-accent-cherry:#ef6b7f;--chat-accent-cyan:#68d8ff;--chat-accent-lime:#d7ff64;--chat-surface-agent:#1a191bd1;--chat-surface-customer:#5b405f;--chat-text-primary:#f3f0f4;--chat-talk-expanded-width:80px;--chat-route-offset-x:100%;--chat-route-enter-easing:linear(0,.062 5%,.192 10%,.338 15%,.477 20%,.596 25%,.694 30%,.771 35%,.831 40%,.877 45%,.911 50%,.937 55%,.955 60%,.969 65%,.979 70%,.986 75%,.991 80%,.994 85%,.997 90%,.999 95%,1);color-scheme:dark;font-synthesis:none;letter-spacing:-.006em;-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:InterVariable,Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.bridge-ai-chat-widget[dir=rtl]{--chat-route-offset-x:-100%}.bridge-ai-chat-widget button,.bridge-ai-chat-widget textarea{font-family:inherit}.bridge-ai-chat-widget :where(button:not(:disabled),[role=button]:not([aria-disabled=true]),a[href]){cursor:pointer}.bridge-ai-chat-widget button:disabled{cursor:not-allowed}.bridge-ai-chat-widget .chat-launcher,.bridge-ai-chat-widget [data-lola-drag-handle]{cursor:grab}.bridge-ai-chat-widget .chat-launcher:active,.bridge-ai-chat-widget [data-lola-drag-handle]:active{cursor:grabbing}.bridge-ai-chat-widget [data-lola-resize=top]{cursor:n-resize}.bridge-ai-chat-widget [data-lola-resize=left]{cursor:w-resize}.bridge-ai-chat-widget [data-lola-resize=corner]{cursor:nwse-resize}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}';
2
- var Et = typeof global == "object" && global && global.Object === Object && global, St = typeof self == "object" && self && self.Object === Object && self, dt = Et || St || Function("return this")(), O = dt.Symbol, ht = Object.prototype, _t = ht.hasOwnProperty, It = ht.toString, T = O ? O.toStringTag : void 0;
3
- function Tt(a) {
4
- var t = _t.call(a, T), e = a[T];
5
- try {
6
- a[T] = void 0;
7
- var i = !0;
8
- } catch {
9
- }
10
- var r = It.call(a);
11
- return i && (t ? a[T] = e : delete a[T]), r;
12
- }
13
- var At = Object.prototype, Rt = At.toString;
14
- function Ct(a) {
15
- return Rt.call(a);
16
- }
17
- var Ot = "[object Null]", Nt = "[object Undefined]", z = O ? O.toStringTag : void 0;
18
- function Pt(a) {
19
- return a == null ? a === void 0 ? Nt : Ot : z && z in Object(a) ? Tt(a) : Ct(a);
20
- }
21
- function Dt(a) {
22
- return a != null && typeof a == "object";
23
- }
24
- var Lt = "[object Symbol]";
25
- function Ut(a) {
26
- return typeof a == "symbol" || Dt(a) && Pt(a) == Lt;
27
- }
28
- var Ht = /\s/;
29
- function Mt(a) {
30
- for (var t = a.length; t-- && Ht.test(a.charAt(t)); )
31
- ;
32
- return t;
33
- }
34
- var jt = /^\s+/;
35
- function qt(a) {
36
- return a && a.slice(0, Mt(a) + 1).replace(jt, "");
37
- }
38
- function U(a) {
39
- var t = typeof a;
40
- return a != null && (t == "object" || t == "function");
41
- }
42
- var V = NaN, zt = /^[-+]0x[0-9a-f]+$/i, Vt = /^0b[01]+$/i, Gt = /^0o[0-7]+$/i, Ft = parseInt;
43
- function G(a) {
44
- if (typeof a == "number")
45
- return a;
46
- if (Ut(a))
47
- return V;
48
- if (U(a)) {
49
- var t = typeof a.valueOf == "function" ? a.valueOf() : a;
50
- a = U(t) ? t + "" : t;
51
- }
52
- if (typeof a != "string")
53
- return a === 0 ? a : +a;
54
- a = qt(a);
55
- var e = Vt.test(a);
56
- return e || Gt.test(a) ? Ft(a.slice(2), e ? 2 : 8) : zt.test(a) ? V : +a;
57
- }
58
- var D = function() {
59
- return dt.Date.now();
60
- }, Wt = "Expected a function", Bt = Math.max, Kt = Math.min;
61
- function $t(a, t, e) {
62
- var i, r, n, o, s, c, l = 0, d = !1, u = !1, p = !0;
63
- if (typeof a != "function")
64
- throw new TypeError(Wt);
65
- t = G(t) || 0, U(e) && (d = !0, u = "maxWait" in e, n = u ? Bt(G(e.maxWait) || 0, t) : n, p = "trailing" in e ? !!e.trailing : p);
66
- function m(b) {
67
- var S = i, I = r;
68
- return i = r = void 0, l = b, o = a.apply(I, S), o;
69
- }
70
- function w(b) {
71
- return l = b, s = setTimeout(x, t), d ? m(b) : o;
72
- }
73
- function f(b) {
74
- var S = b - c, I = b - l, q = t - S;
75
- return u ? Kt(q, n - I) : q;
76
- }
77
- function E(b) {
78
- var S = b - c, I = b - l;
79
- return c === void 0 || S >= t || S < 0 || u && I >= n;
80
- }
81
- function x() {
82
- var b = D();
83
- if (E(b))
84
- return y(b);
85
- s = setTimeout(x, f(b));
86
- }
87
- function y(b) {
88
- return s = void 0, p && i ? m(b) : (i = r = void 0, o);
89
- }
90
- function A() {
91
- s !== void 0 && clearTimeout(s), l = 0, i = c = r = s = void 0;
92
- }
93
- function N() {
94
- return s === void 0 ? o : y(D());
95
- }
96
- function P() {
97
- var b = D(), S = E(b);
98
- if (i = arguments, r = this, c = b, S) {
99
- if (s === void 0)
100
- return w(c);
101
- if (u)
102
- return clearTimeout(s), s = setTimeout(x, t), m(c);
103
- }
104
- return s === void 0 && (s = setTimeout(x, t)), o;
105
- }
106
- return P.cancel = A, P.flush = N, P;
107
- }
108
- const F = {
109
- debug: 0,
110
- info: 1,
111
- warn: 2,
112
- error: 3
113
- };
114
- class Yt {
115
- level;
116
- prefix;
117
- debugOwnerCount = 0;
118
- constructor(t = "Widget", e = "info") {
119
- this.prefix = `[${t}]`, this.level = F[e];
120
- }
121
- enableDebug() {
122
- this.debugOwnerCount += 1;
123
- let t = !0;
124
- return () => {
125
- t && (t = !1, this.debugOwnerCount -= 1);
126
- };
127
- }
128
- isEnabled(t) {
129
- return this.debugOwnerCount > 0 || this.level <= F[t];
130
- }
131
- debug(...t) {
132
- this.isEnabled("debug") && console.debug(this.prefix, ...t);
133
- }
134
- info(...t) {
135
- this.isEnabled("info") && console.info(this.prefix, ...t);
136
- }
137
- warn(...t) {
138
- this.isEnabled("warn") && console.warn(this.prefix, ...t);
139
- }
140
- error(...t) {
141
- this.isEnabled("error") && console.error(this.prefix, ...t);
142
- }
143
- }
144
- const Xt = "warn", g = new Yt("Lola-Widget", Xt), Ci = "audio/wav", W = "audio/pcm";
145
- class h extends Error {
146
- constructor(t, e = "failed", i) {
147
- super(t, i), this.code = t, this.status = e;
148
- }
149
- }
150
- const Zt = /^[a-zA-Z0-9_.:-]{1,200}$/, Jt = /* @__PURE__ */ new Set([
151
- "button",
152
- "element",
153
- "modal",
154
- "page"
155
- ]);
156
- class Qt {
157
- targets = /* @__PURE__ */ new Map();
158
- handlers = {};
159
- constructor(t = {}, e = {}) {
160
- for (const [i, r] of Object.entries(t))
161
- this.registerTarget(i, r);
162
- Object.assign(this.handlers, e);
163
- }
164
- registerTarget(t, e) {
165
- return this.assertTargetCode(t), this.assertLegacyTarget(e), this.targets.set(t, e), () => {
166
- this.targets.get(t) === e && this.targets.delete(t);
167
- };
168
- }
169
- getTarget(t) {
170
- return this.targets.get(t);
171
- }
172
- getHandler(t) {
173
- return this.handlers[t];
174
- }
175
- registerHandler(t, e) {
176
- return this.handlers[t] = e, () => {
177
- this.handlers[t] === e && delete this.handlers[t];
178
- };
179
- }
180
- resolveAction(t, e, i) {
181
- return i !== void 0 ? this.resolveCanonicalAction(t, i) : this.resolveLegacyAction(t, e);
182
- }
183
- async execute(t, e, i, r) {
184
- const n = this.resolveAction(t, i, r);
185
- await this.executeAction(n, e, i);
186
- }
187
- async executeAction(t, e, i) {
188
- if (t.kind === "page") {
189
- const n = this.handlers.openPage;
190
- if (n) {
191
- await n({
192
- commandId: e,
193
- pageCode: t.code,
194
- route: t.route,
195
- payload: i
196
- });
197
- return;
198
- }
199
- this.applyUrlFallback(t.route);
200
- return;
201
- }
202
- const r = this.handlers.openModal;
203
- if (r && t.modalName) {
204
- await r({
205
- commandId: e,
206
- modalCode: t.code,
207
- modalName: t.modalName,
208
- payload: i
209
- });
210
- return;
211
- }
212
- if (t.selector) {
213
- const n = document.querySelector(t.selector);
214
- if (n instanceof HTMLDialogElement) {
215
- n.showModal();
216
- return;
217
- }
218
- if (!t.url) throw new h("TARGET_NOT_FOUND");
219
- }
220
- if (t.url) {
221
- this.applyUrlFallback(t.url);
222
- return;
223
- }
224
- throw new h("HANDLER_UNSUPPORTED", "unsupported");
225
- }
226
- canExecute(t) {
227
- return t.kind === "page" ? !!(this.handlers.openPage || this.isSameOriginUrl(t.route)) : !!(this.handlers.openModal && t.modalName || t.selector || t.url);
228
- }
229
- resolveCanonicalAction(t, e) {
230
- if (!e || typeof e != "object")
231
- throw new h("TARGET_INVALID");
232
- const i = this.requireNonEmptyString(e.id), r = this.requireNonEmptyString(e.code);
233
- if (this.assertTargetCode(r), t === "open_page") {
234
- if (e.kind !== "page")
235
- throw new h("TARGET_INVALID");
236
- const o = this.requireNonEmptyString(e.route);
237
- return Object.freeze({
238
- kind: "page",
239
- code: r,
240
- route: o,
241
- target: Object.freeze({
242
- ...e,
243
- id: i,
244
- code: r,
245
- route: o
246
- })
247
- });
248
- }
249
- if (e.kind !== "modal")
250
- throw new h("TARGET_INVALID");
251
- const n = this.requireNonEmptyString(e.modalName);
252
- return Object.freeze({
253
- kind: "modal",
254
- code: r,
255
- modalName: n,
256
- target: Object.freeze({
257
- ...e,
258
- id: i,
259
- code: r,
260
- modalName: n
261
- })
262
- });
263
- }
264
- resolveLegacyAction(t, e) {
265
- const i = t === "open_page" ? e.pageId ?? e.pageCode : e.modalId ?? e.modalCode, r = this.requireNonEmptyString(i);
266
- this.assertTargetCode(r);
267
- const n = this.targets.get(r), o = t === "open_page" ? "page" : "modal";
268
- if (n && n.kind !== o)
269
- throw new h("TARGET_INVALID");
270
- if (t === "open_page") {
271
- const l = this.targetUrl(n);
272
- if (!l) throw new h("TARGET_INVALID");
273
- return Object.freeze({ kind: "page", code: r, route: l });
274
- }
275
- if (!n) throw new h("TARGET_INVALID");
276
- const s = this.targetUrl(n), c = n.modalName ?? (this.handlers.openModal ? r : void 0);
277
- if (!c && !n.selector && !s)
278
- throw new h("TARGET_INVALID");
279
- return Object.freeze({
280
- kind: "modal",
281
- code: r,
282
- modalName: c,
283
- url: s,
284
- selector: n.selector
285
- });
286
- }
287
- assertLegacyTarget(t) {
288
- if (!t || typeof t != "object" || !Jt.has(t.kind))
289
- throw new h("TARGET_INVALID");
290
- for (const e of [
291
- t.selector,
292
- t.route,
293
- t.modalName,
294
- t.url
295
- ])
296
- if (e !== void 0 && !this.requireNonEmptyString(e))
297
- throw new h("TARGET_INVALID");
298
- if (t.query !== void 0 && (!t.query || typeof t.query != "object" || Array.isArray(t.query) || Object.values(t.query).some(
299
- (e) => e !== null && typeof e != "string"
300
- )))
301
- throw new h("TARGET_INVALID");
302
- }
303
- targetUrl(t) {
304
- if (!t) return;
305
- const e = t.url ?? t.route;
306
- if (!e && !t.query) return;
307
- let i;
308
- try {
309
- i = new URL(e ?? window.location.href, window.location.href);
310
- } catch {
311
- throw new h("TARGET_INVALID");
312
- }
313
- for (const [r, n] of Object.entries(t.query ?? {}))
314
- n === null ? i.searchParams.delete(r) : i.searchParams.set(r, n);
315
- if (i.origin !== window.location.origin)
316
- throw new h("TARGET_INVALID");
317
- return `${i.pathname}${i.search}${i.hash}`;
318
- }
319
- applyUrlFallback(t) {
320
- let e;
321
- try {
322
- e = new URL(t, window.location.href);
323
- } catch {
324
- throw new h("TARGET_INVALID");
325
- }
326
- if (!this.isSameOriginUrl(e))
327
- throw new h("TARGET_INVALID");
328
- window.history.pushState(null, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: null }));
329
- }
330
- isSameOriginUrl(t) {
331
- try {
332
- return (t instanceof URL ? t : new URL(t, window.location.href)).origin === window.location.origin;
333
- } catch {
334
- return !1;
335
- }
336
- }
337
- requireNonEmptyString(t) {
338
- if (typeof t != "string" || !t.trim())
339
- throw new h("TARGET_INVALID");
340
- return t.trim();
341
- }
342
- assertTargetCode(t) {
343
- if (!Zt.test(t))
344
- throw new h("TARGET_INVALID");
345
- }
346
- }
347
- const te = [
348
- "show_assistant",
349
- "hide_assistant",
350
- "open_chat",
351
- "close_chat",
352
- "play_animation",
353
- "highlight_element",
354
- "remove_highlight",
355
- "show_cta",
356
- "connect_telegram",
357
- "speak_text",
358
- "start_voice_conversation",
359
- "open_page",
360
- "open_modal"
361
- ], B = /* @__PURE__ */ new Set([
362
- "succeeded",
363
- "failed",
364
- "expired",
365
- "unsupported"
366
- ]), ee = 600 * 1e3, ie = 256, re = /^[a-zA-Z0-9_.:-]{1,200}$/, ae = "rgba(167, 139, 250, 0.82)", ne = "rgba(196, 181, 253, 1)", oe = "0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 0 4px rgba(139, 92, 246, 0.12), 0 0 18px 2px rgba(124, 58, 237, 0.28), inset 0 0 12px rgba(139, 92, 246, 0.06)", se = "0 0 0 1px rgba(255, 255, 255, 0.28), 0 0 0 5px rgba(139, 92, 246, 0.2), 0 0 26px 4px rgba(124, 58, 237, 0.5), inset 0 0 14px rgba(139, 92, 246, 0.12)";
367
- class ce {
368
- constructor(t = {}, e = {}, i, r) {
369
- this.onStatus = i, this.scenarioInteractions = r, this.uiCommands = new Qt(t, e), this.internalHandlersReady = new Promise((n) => {
370
- this.resolveInternalHandlers = n;
371
- });
372
- }
373
- uiCommands;
374
- internalHandlers = {};
375
- internalHandlersReady;
376
- resolveInternalHandlers;
377
- completed = /* @__PURE__ */ new Map();
378
- inFlight = /* @__PURE__ */ new Map();
379
- completedCtaActions = /* @__PURE__ */ new Set();
380
- terminalCtaActions = /* @__PURE__ */ new Map();
381
- ctaActionRetentionOrder = /* @__PURE__ */ new Set();
382
- inFlightCtaActions = /* @__PURE__ */ new Map();
383
- highlights = /* @__PURE__ */ new Map();
384
- targetObservationCleanups = /* @__PURE__ */ new Map();
385
- targetActivationOwners = /* @__PURE__ */ new Map();
386
- activeCustomHighlights = /* @__PURE__ */ new Map();
387
- targetHighlightOperations = /* @__PURE__ */ new Map();
388
- principalSessionId = null;
389
- principalGeneration = 0;
390
- destroyed = !1;
391
- registerTarget(t, e) {
392
- return this.uiCommands.registerTarget(t, e);
393
- }
394
- registerHostHandler(t, e) {
395
- return this.uiCommands.registerHandler(t, e);
396
- }
397
- setInternalHandlers(t) {
398
- return Object.assign(this.internalHandlers, t), this.resolveInternalHandlers(), () => {
399
- for (const [e, i] of Object.entries(t))
400
- this.internalHandlers[e] === i && delete this.internalHandlers[e];
401
- };
402
- }
403
- async execute(t, e, i) {
404
- const r = t?.data?.commandId;
405
- if (typeof r != "string" || !r) {
406
- g.warn("Ignored command without commandId", t);
407
- return;
408
- }
409
- if (this.destroyed) return;
410
- const n = this.ensurePrincipal(e, !1);
411
- if (n === null) {
412
- const l = {
413
- commandId: r,
414
- status: "failed",
415
- errorCode: "SESSION_MISMATCH"
416
- };
417
- this.onStatus?.({ ...l, commandType: t.data.commandType }), await i(l);
418
- return;
419
- }
420
- this.loadCompleted(e);
421
- const o = this.completed.get(r);
422
- if (o) {
423
- await i(this.toAck(o));
424
- return;
425
- }
426
- const s = this.inFlight.get(r);
427
- if (s) {
428
- await i({ commandId: r, status: "received" });
429
- try {
430
- await s;
431
- } catch (d) {
432
- if (!this.completed.has(r)) throw d;
433
- }
434
- const l = this.completed.get(r);
435
- l && await i(this.toAck(l));
436
- return;
437
- }
438
- const c = this.executeOnce(t, e, i, n);
439
- this.inFlight.set(r, c);
440
- try {
441
- await c;
442
- } finally {
443
- this.inFlight.get(r) === c && this.inFlight.delete(r);
444
- }
445
- }
446
- updateSession(t) {
447
- this.destroyed || this.ensurePrincipal(t, !0);
448
- }
449
- async executeCtaAction(t) {
450
- if (this.completedCtaActions.has(t.commandId)) return "COMPLETED";
451
- const e = this.terminalCtaActions.get(t.commandId);
452
- if (e) return e;
453
- const i = this.inFlightCtaActions.get(t.commandId);
454
- if (i) return i;
455
- const r = this.principalGeneration;
456
- let n;
457
- const o = new Promise((s) => {
458
- n = s;
459
- });
460
- return this.inFlightCtaActions.set(t.commandId, o), this.executeCtaActionOnce(t).then(
461
- (s) => {
462
- this.inFlightCtaActions.get(t.commandId) === o && (this.inFlightCtaActions.delete(t.commandId), this.isCurrentPrincipal(r) && (s === "COMPLETED" ? (this.completedCtaActions.add(t.commandId), this.retainCtaAction(t.commandId)) : s === "TERMINAL_FAILURE" && (this.terminalCtaActions.set(t.commandId, o), this.retainCtaAction(t.commandId)))), n(s);
463
- },
464
- (s) => {
465
- this.inFlightCtaActions.get(t.commandId) === o && (this.inFlightCtaActions.delete(t.commandId), this.isCurrentPrincipal(r) && (this.terminalCtaActions.set(t.commandId, o), this.retainCtaAction(t.commandId))), g.error("CTA action failed", s), n("TERMINAL_FAILURE");
466
- }
467
- ), o;
468
- }
469
- async executeCtaActionOnce(t) {
470
- if (t.expiresAt && Number.isFinite(Date.parse(t.expiresAt)) && Date.parse(t.expiresAt) <= Date.now())
471
- throw new Error("CTA expired before activation");
472
- if (t.action === "none") return "COMPLETED";
473
- if (t.action === "connect_telegram") {
474
- const i = this.requireInternal("connectTelegram");
475
- try {
476
- return await i(t);
477
- } catch (r) {
478
- return g.error("Retryable CTA action failed", r), "RETRYABLE_FAILURE";
479
- }
480
- }
481
- const e = t.uiAction ?? this.uiCommands.resolveAction(t.action, t.payload);
482
- return await this.uiCommands.executeAction(
483
- e,
484
- t.commandId,
485
- t.payload
486
- ), "COMPLETED";
487
- }
488
- retainCtaAction(t) {
489
- for (this.ctaActionRetentionOrder.delete(t), this.ctaActionRetentionOrder.add(t); this.ctaActionRetentionOrder.size > ie; ) {
490
- const e = this.ctaActionRetentionOrder.values().next().value;
491
- if (e === void 0) break;
492
- this.ctaActionRetentionOrder.delete(e), this.completedCtaActions.delete(e), this.terminalCtaActions.delete(e);
493
- }
494
- }
495
- destroy() {
496
- this.destroyed || (this.destroyed = !0, this.resetPrincipalState(), this.principalSessionId = null);
497
- }
498
- async executeOnce(t, e, i, r) {
499
- const { commandId: n, commandType: o, interactionSessionId: s, expiresAt: c } = t.data, l = e.interactionSessionId;
500
- if (s !== l) {
501
- await this.finish(
502
- { commandId: n, status: "failed", errorCode: "SESSION_MISMATCH" },
503
- e,
504
- i,
505
- o,
506
- r
507
- );
508
- return;
509
- }
510
- if (c && Date.parse(c) <= Date.now()) {
511
- await this.finish(
512
- { commandId: n, status: "expired", errorCode: "COMMAND_EXPIRED" },
513
- e,
514
- i,
515
- o,
516
- r
517
- );
518
- return;
519
- }
520
- if (await i({ commandId: n, status: "received" }), this.onStatus?.({ commandId: n, status: "received", commandType: o }), !this.isCurrentPrincipal(r)) return;
521
- const d = t.data.contractVersion;
522
- if (d !== void 0 && d !== 1 || t.data.target !== void 0 && d !== 1) {
523
- await this.finish(
524
- {
525
- commandId: n,
526
- status: "unsupported",
527
- errorCode: "CONTRACT_VERSION_UNSUPPORTED"
528
- },
529
- e,
530
- i,
531
- o,
532
- r
533
- );
534
- return;
535
- }
536
- if (!te.includes(o)) {
537
- await this.finish(
538
- { commandId: n, status: "unsupported", errorCode: "COMMAND_UNSUPPORTED" },
539
- e,
540
- i,
541
- o,
542
- r
543
- );
544
- return;
545
- }
546
- if (!t.data.payload || typeof t.data.payload != "object" || Array.isArray(t.data.payload)) {
547
- await this.finish(
548
- { commandId: n, status: "failed", errorCode: "PAYLOAD_INVALID" },
549
- e,
550
- i,
551
- o,
552
- r
553
- );
554
- return;
555
- }
556
- let u;
557
- try {
558
- await this.dispatch(
559
- o,
560
- t.data.payload,
561
- n,
562
- t.data.target,
563
- c,
564
- t.data.scenarioRunId,
565
- r
566
- ), u = { commandId: n, status: "succeeded" };
567
- } catch (p) {
568
- const m = p instanceof h ? p : new h("HANDLER_FAILED");
569
- g.warn(`Command ${n} failed`, p);
570
- const w = p instanceof h && p.cause instanceof Error ? p.cause : p instanceof Error && !(p instanceof h) ? p : null;
571
- u = {
572
- commandId: n,
573
- status: m.status,
574
- errorCode: m.code,
575
- details: w ? { message: w.message } : void 0
576
- };
577
- }
578
- await this.finish(u, e, i, o, r);
579
- }
580
- async dispatch(t, e, i, r, n, o = "", s = this.principalGeneration) {
581
- if ([
582
- "show_assistant",
583
- "hide_assistant",
584
- "open_chat",
585
- "close_chat",
586
- "play_animation",
587
- "show_cta",
588
- "connect_telegram",
589
- "speak_text",
590
- "start_voice_conversation"
591
- ].includes(t) && await this.internalHandlersReady, !!this.isCurrentPrincipal(s))
592
- switch (t) {
593
- case "show_assistant":
594
- return this.requireInternal("setAssistantVisible")(!0, i);
595
- case "hide_assistant":
596
- return this.requireInternal("setAssistantVisible")(!1, i);
597
- case "open_chat":
598
- return this.requireInternal("setChatOpen")(!0, i);
599
- case "close_chat":
600
- return this.requireInternal("setChatOpen")(!1, i);
601
- case "play_animation": {
602
- const c = this.requireString(
603
- e.animation,
604
- "ANIMATION_INVALID"
605
- );
606
- return this.requireInternal("playAnimation")(c, n);
607
- }
608
- case "highlight_element":
609
- case "remove_highlight": {
610
- const c = r !== void 0 ? this.requireEnvelopeTarget(r, ["button", "element"]) : this.requireTarget(
611
- this.firstDefined(e.target, e.interfaceElementId),
612
- ["button", "element"]
613
- );
614
- return this.executeHighlight(
615
- c,
616
- t === "highlight_element",
617
- e,
618
- i,
619
- t,
620
- s
621
- );
622
- }
623
- case "show_cta":
624
- return this.executeShowCta(
625
- e,
626
- i,
627
- o,
628
- n ?? null,
629
- r
630
- );
631
- case "connect_telegram":
632
- return this.executeConnectTelegram(
633
- e,
634
- i,
635
- o,
636
- n ?? null
637
- );
638
- case "speak_text": {
639
- const c = this.requireString(
640
- e.audioPath,
641
- "SPEECH_AUDIO_INVALID"
642
- );
643
- if (c !== `/scenario-commands/${i}/audio` || e.method !== "POST" || e.mimeType !== W || e.format !== "pcm16" || e.sampleRate !== 24e3 || e.channels !== 1)
644
- throw new h("SPEECH_AUDIO_INVALID");
645
- const l = this.readLipSyncDescriptor(e.lipSync, i);
646
- try {
647
- return await this.requireInternal("speakText")({
648
- commandId: i,
649
- commandType: t,
650
- audioPath: c,
651
- method: "POST",
652
- mimeType: W,
653
- format: "pcm16",
654
- sampleRate: 24e3,
655
- channels: 1,
656
- ...l ? { lipSync: l } : {}
657
- });
658
- } catch (d) {
659
- throw new h("AUDIO_PLAYBACK_FAILED", "failed", {
660
- cause: d
661
- });
662
- }
663
- }
664
- case "start_voice_conversation": {
665
- const c = this.requireString(
666
- e.voiceSessionId,
667
- "VOICE_INVITATION_INVALID"
668
- ), l = this.requireString(
669
- e.introAudioPath,
670
- "VOICE_INVITATION_INVALID"
671
- ), d = `/voice/sessions/${c}`;
672
- if (e.requiresUserGesture !== !0 || l !== `${d}/intro-audio`)
673
- throw new h("VOICE_INVITATION_INVALID");
674
- return this.requireInternal("startVoiceConversation")({
675
- commandId: i,
676
- commandType: t,
677
- voiceSessionId: c,
678
- conversationId: this.requireString(
679
- e.conversationId,
680
- "VOICE_INVITATION_INVALID"
681
- ),
682
- messageId: this.requireString(
683
- e.messageId,
684
- "VOICE_INVITATION_INVALID"
685
- ),
686
- text: this.requireString(e.text, "VOICE_INVITATION_INVALID"),
687
- voice: this.requireString(e.voice, "VOICE_INVITATION_INVALID"),
688
- requiresUserGesture: !0,
689
- introAudioPath: l
690
- });
691
- }
692
- case "open_page":
693
- return this.uiCommands.execute(
694
- t,
695
- i,
696
- e,
697
- r
698
- );
699
- case "open_modal":
700
- return this.uiCommands.execute(
701
- t,
702
- i,
703
- e,
704
- r
705
- );
706
- }
707
- }
708
- async executeHighlight(t, e, i, r, n, o) {
709
- const c = (this.targetHighlightOperations.get(t) ?? Promise.resolve()).catch(() => {
710
- }).then(
711
- () => this.executeHighlightSerial(
712
- t,
713
- e,
714
- i,
715
- r,
716
- n,
717
- o
718
- )
719
- );
720
- this.targetHighlightOperations.set(t, c);
721
- try {
722
- await c;
723
- } finally {
724
- this.targetHighlightOperations.get(t) === c && this.targetHighlightOperations.delete(t);
725
- }
726
- }
727
- async executeHighlightSerial(t, e, i, r, n, o) {
728
- if (!this.isCurrentPrincipal(o)) return;
729
- const s = this.uiCommands.getTarget(t), c = this.findTargetElement(t, s), l = this.uiCommands.getHandler("highlight");
730
- if (l) {
731
- const d = {
732
- handler: l,
733
- commandId: r,
734
- target: t,
735
- payload: i,
736
- ...c ? { element: c } : {}
737
- };
738
- if (this.activeCustomHighlights.has(t)) {
739
- if (!e) {
740
- await this.removeCustomHighlightForCommand(
741
- t,
742
- d
743
- );
744
- return;
745
- }
746
- if (await this.deactivateCustomHighlight(t), !this.isCurrentPrincipal(o)) return;
747
- }
748
- this.removeTargetTracking(t);
749
- const u = e ? this.createTargetActivationReporter(t, r) : () => {
750
- };
751
- try {
752
- await this.invokeCustomHighlight(
753
- d,
754
- e,
755
- n,
756
- u
757
- );
758
- } catch (p) {
759
- if (this.targetActivationOwners.get(t) === r && this.removeTargetTracking(t), e)
760
- try {
761
- await this.invokeCustomHighlight(
762
- d,
763
- !1,
764
- "remove_highlight",
765
- () => {
766
- }
767
- );
768
- } catch (m) {
769
- g.warn("Custom highlight rollback failed", m);
770
- }
771
- throw p;
772
- }
773
- if (!this.isCurrentPrincipal(o)) {
774
- if (this.removeTargetTracking(t), e)
775
- try {
776
- await this.invokeCustomHighlight(
777
- d,
778
- !1,
779
- "remove_highlight",
780
- () => {
781
- }
782
- );
783
- } catch (p) {
784
- g.warn("Custom highlight cleanup failed", p);
785
- }
786
- return;
787
- }
788
- e && this.targetActivationOwners.get(t) === r && (this.activeCustomHighlights.set(t, d), c && this.observeTarget(t, c, r));
789
- return;
790
- }
791
- if (!e && this.highlights.has(t)) {
792
- this.removeDefaultHighlight(t);
793
- return;
794
- }
795
- if (!c) throw new h("TARGET_NOT_FOUND");
796
- e ? (this.applyDefaultHighlight(t, c, i), this.observeTarget(t, c, r)) : this.removeDefaultHighlight(t);
797
- }
798
- async executeShowCta(t, e, i, r, n) {
799
- const o = this.requireString(t.label, "CTA_INVALID"), s = t.action;
800
- if (s !== "none" && s !== "open_modal" && s !== "open_page" && s !== "connect_telegram")
801
- throw new h("CTA_INVALID");
802
- const c = s === "none" || s === "connect_telegram" ? void 0 : this.uiCommands.resolveAction(s, t, n);
803
- if (c && !this.uiCommands.canExecute(c))
804
- throw new h("HANDLER_UNSUPPORTED", "unsupported");
805
- const l = c?.code, d = t.text === void 0 ? void 0 : this.requireString(t.text, "CTA_INVALID", 1e3), u = t.conversationId === void 0 ? void 0 : this.requireString(t.conversationId, "CTA_INVALID", 200), p = {
806
- commandId: e,
807
- commandType: "show_cta",
808
- label: o,
809
- ...d ? { text: d } : {},
810
- action: s,
811
- ...u ? { conversationId: u } : {},
812
- scenarioRunId: i,
813
- expiresAt: r,
814
- presentation: "PRIMARY",
815
- attention: t.attention === "NUDGE_ONCE" ? "NUDGE_ONCE" : "NONE",
816
- target: l,
817
- uiAction: c,
818
- payload: t
819
- }, m = this.internalHandlers.showCta;
820
- if (!m)
821
- throw new h("HANDLER_UNSUPPORTED", "unsupported");
822
- await m(p);
823
- }
824
- async executeConnectTelegram(t, e, i, r) {
825
- const n = this.requireString(t.label, "CTA_INVALID"), o = t.text === void 0 ? void 0 : this.requireString(t.text, "CTA_INVALID", 1e3), s = t.conversationId === void 0 ? void 0 : this.requireString(t.conversationId, "CTA_INVALID", 200), c = {
826
- commandId: e,
827
- commandType: "connect_telegram",
828
- label: n,
829
- ...o ? { text: o } : {},
830
- action: "connect_telegram",
831
- ...s ? { conversationId: s } : {},
832
- scenarioRunId: i,
833
- expiresAt: r,
834
- presentation: "PRIMARY",
835
- attention: t.attention === "NUDGE_ONCE" ? "NUDGE_ONCE" : "NONE",
836
- payload: t
837
- }, l = this.internalHandlers.showCta;
838
- if (!l)
839
- throw new h("HANDLER_UNSUPPORTED", "unsupported");
840
- await l(c);
841
- }
842
- requireTarget(t, e) {
843
- const i = t && typeof t == "object" ? t.code ?? t.id : t, r = this.requireString(i, "TARGET_INVALID");
844
- if (!re.test(r))
845
- throw new h("TARGET_INVALID");
846
- const n = this.uiCommands.getTarget(r);
847
- if (n && !e.includes(n.kind))
848
- throw new h("TARGET_INVALID");
849
- return r;
850
- }
851
- readLipSyncDescriptor(t, e) {
852
- if (t === void 0) return;
853
- if (!t || typeof t != "object" || Array.isArray(t))
854
- throw new h("SPEECH_AUDIO_INVALID");
855
- const i = t, r = i.audio, n = i.transport;
856
- if (i.contractVersion !== 1 || i.playbackId !== e || i.cueTimebase !== "milliseconds" || !r || r.encoding !== "pcm_s16le" || r.sampleRate !== 24e3 || r.channels !== 1 || !n || n.socketIoEvent !== "lip_sync.cues" || n.cableField !== "lipSyncCues")
857
- throw new h("SPEECH_AUDIO_INVALID");
858
- return t;
859
- }
860
- requireEnvelopeTarget(t, e) {
861
- if (!t || typeof t != "object")
862
- throw new h("TARGET_INVALID");
863
- if (this.requireString(t.id, "TARGET_INVALID"), !e.includes(t.kind))
864
- throw new h("TARGET_INVALID");
865
- return this.requireTarget(t.code, e);
866
- }
867
- findTargetElement(t, e) {
868
- if (e?.selector) return document.querySelector(e.selector);
869
- const i = typeof CSS < "u" && CSS.escape ? CSS.escape(t) : t;
870
- return document.querySelector(
871
- `[data-lola="${i}"], [data-lola-action="${i}"]`
872
- );
873
- }
874
- applyDefaultHighlight(t, e, i) {
875
- this.removeDefaultHighlight(t), e.scrollIntoView({ behavior: "smooth", block: "center" }), e.setAttribute("data-lola-highlighted", "true");
876
- const r = this.applyHighlightEffect(e), n = typeof i.durationMs == "number" && Number.isFinite(i.durationMs) ? Math.max(0, i.durationMs) : 0, o = n ? window.setTimeout(() => this.removeDefaultHighlight(t), n) : void 0;
877
- this.highlights.set(t, {
878
- element: e,
879
- timer: o,
880
- cleanupEffect: r
881
- });
882
- }
883
- applyHighlightEffect(t) {
884
- const e = window.getComputedStyle(t).boxShadow, i = (d, u) => [
885
- `inset 0 0 0 2px ${d}`,
886
- u,
887
- ...e && e !== "none" ? [e] : []
888
- ].join(", "), r = i(
889
- ae,
890
- oe
891
- ), n = i(
892
- ne,
893
- se
894
- );
895
- if (!(typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches) && typeof t.animate == "function") {
896
- const d = t.animate(
897
- [
898
- { boxShadow: r },
899
- { boxShadow: n },
900
- { boxShadow: r }
901
- ],
902
- {
903
- duration: 1800,
904
- easing: "ease-in-out",
905
- iterations: 1 / 0
906
- }
907
- );
908
- return () => d.cancel();
909
- }
910
- const s = t instanceof HTMLElement || typeof SVGElement < "u" && t instanceof SVGElement ? t.style : void 0;
911
- if (!s) return () => {
912
- };
913
- const c = s.getPropertyValue("box-shadow"), l = s.getPropertyPriority("box-shadow");
914
- return s.setProperty("box-shadow", r, "important"), () => {
915
- c ? s.setProperty("box-shadow", c, l) : s.removeProperty("box-shadow");
916
- };
917
- }
918
- removeDefaultHighlight(t) {
919
- const e = this.highlights.get(t);
920
- e?.timer && window.clearTimeout(e.timer), e?.cleanupEffect(), e?.element.removeAttribute("data-lola-highlighted"), this.highlights.delete(t), this.removeTargetTracking(t);
921
- }
922
- observeTarget(t, e, i) {
923
- this.removeTargetObservation(t);
924
- const r = this.scenarioInteractions?.observeHighlightedTarget({
925
- element: e,
926
- commandId: i
927
- });
928
- r && this.targetObservationCleanups.set(t, r);
929
- }
930
- createTargetActivationReporter(t, e) {
931
- this.targetActivationOwners.set(t, e);
932
- const i = this.scenarioInteractions?.getSurfaceEpisodeId() ?? null;
933
- let r = !1;
934
- return () => {
935
- r || this.targetActivationOwners.get(t) !== e || (r = !0, this.scenarioInteractions?.recordTargetActivation(
936
- e,
937
- i
938
- ));
939
- };
940
- }
941
- removeTargetObservation(t) {
942
- this.targetObservationCleanups.get(t)?.(), this.targetObservationCleanups.delete(t);
943
- }
944
- removeTargetTracking(t) {
945
- this.removeTargetObservation(t), this.targetActivationOwners.delete(t);
946
- }
947
- async deactivateCustomHighlight(t) {
948
- const e = this.activeCustomHighlights.get(t);
949
- e && (this.removeTargetTracking(t), await this.invokeCustomHighlight(
950
- e,
951
- !1,
952
- "remove_highlight",
953
- () => {
954
- }
955
- ), this.activeCustomHighlights.get(t) === e && this.activeCustomHighlights.delete(t));
956
- }
957
- async removeCustomHighlightForCommand(t, e) {
958
- const i = this.activeCustomHighlights.get(t);
959
- i && (this.removeTargetTracking(t), await this.invokeCustomHighlight(
960
- e,
961
- !1,
962
- "remove_highlight",
963
- () => {
964
- }
965
- ), this.activeCustomHighlights.get(t) === i && this.activeCustomHighlights.delete(t));
966
- }
967
- invokeCustomHighlight(t, e, i, r) {
968
- return t.handler({
969
- commandId: t.commandId,
970
- commandType: i,
971
- target: t.target,
972
- payload: t.payload,
973
- active: e,
974
- ...t.element ? { element: t.element } : {},
975
- reportActivation: r
976
- });
977
- }
978
- queueCustomHighlightCleanup(t, e) {
979
- const r = (this.targetHighlightOperations.get(t) ?? Promise.resolve()).catch(() => {
980
- }).then(async () => {
981
- try {
982
- await this.invokeCustomHighlight(
983
- e,
984
- !1,
985
- "remove_highlight",
986
- () => {
987
- }
988
- );
989
- } catch (n) {
990
- g.warn("Custom highlight cleanup failed", n);
991
- }
992
- });
993
- this.targetHighlightOperations.set(t, r), r.finally(() => {
994
- this.targetHighlightOperations.get(t) === r && this.targetHighlightOperations.delete(t);
995
- });
996
- }
997
- clearCustomHighlights() {
998
- for (const [t, e] of this.activeCustomHighlights)
999
- this.activeCustomHighlights.delete(t), this.removeTargetTracking(t), this.queueCustomHighlightCleanup(t, e);
1000
- }
1001
- requireInternal(t) {
1002
- const e = this.internalHandlers[t];
1003
- if (!e)
1004
- throw new h("HANDLER_UNSUPPORTED", "unsupported");
1005
- return e;
1006
- }
1007
- requireString(t, e, i) {
1008
- const r = typeof t == "string" ? t.trim() : "";
1009
- if (typeof t != "string" || !r || i !== void 0 && [...r].length > i)
1010
- throw new h(e);
1011
- return r;
1012
- }
1013
- firstDefined(...t) {
1014
- return t.find((e) => e != null);
1015
- }
1016
- async finish(t, e, i, r, n = this.principalGeneration) {
1017
- this.isCurrentPrincipal(n) && (B.has(t.status) && (this.completed.set(t.commandId, {
1018
- ...t,
1019
- storedUntil: Date.now() + ee
1020
- }), this.saveCompleted(e)), this.onStatus?.({ ...t, commandType: r }), await i(t));
1021
- }
1022
- ensurePrincipal(t, e) {
1023
- if (this.principalSessionId === null)
1024
- return this.principalSessionId = t.interactionSessionId, this.principalGeneration;
1025
- if (this.principalSessionId !== t.interactionSessionId) {
1026
- if (!e) return null;
1027
- this.resetPrincipalState(), this.principalSessionId = t.interactionSessionId;
1028
- }
1029
- return this.principalGeneration;
1030
- }
1031
- resetPrincipalState() {
1032
- this.principalGeneration += 1, this.clearCustomHighlights();
1033
- for (const t of [...this.highlights.keys()])
1034
- this.removeDefaultHighlight(t);
1035
- for (const t of this.targetObservationCleanups.values()) t();
1036
- this.targetObservationCleanups.clear(), this.targetActivationOwners.clear(), this.completed.clear(), this.inFlight.clear(), this.completedCtaActions.clear(), this.terminalCtaActions.clear(), this.ctaActionRetentionOrder.clear(), this.inFlightCtaActions.clear();
1037
- }
1038
- isCurrentPrincipal(t) {
1039
- return t === this.principalGeneration;
1040
- }
1041
- storageKey(t) {
1042
- return `bridge-lola-command-dedup:${t.interactionSessionId}`;
1043
- }
1044
- loadCompleted(t) {
1045
- try {
1046
- const e = window.sessionStorage.getItem(this.storageKey(t)), i = e ? JSON.parse(e) : [];
1047
- for (const r of i)
1048
- r.storedUntil > Date.now() && B.has(r.status) && this.completed.set(r.commandId, r);
1049
- } catch {
1050
- }
1051
- }
1052
- saveCompleted(t) {
1053
- const e = [...this.completed.values()].filter(
1054
- (i) => i.storedUntil > Date.now()
1055
- );
1056
- try {
1057
- window.sessionStorage.setItem(
1058
- this.storageKey(t),
1059
- JSON.stringify(e)
1060
- );
1061
- } catch {
1062
- }
1063
- }
1064
- toAck(t) {
1065
- return {
1066
- commandId: t.commandId,
1067
- status: t.status,
1068
- errorCode: t.errorCode,
1069
- details: t.details
1070
- };
1071
- }
1072
- }
1073
- const pt = (a) => a.replace(/\/$/, ""), j = pt(
1074
- "https://api.retenive.com/api/v1"
1075
- ), le = "wss://api.retenive.com/cable", de = pt(
1076
- "https://metamediastatic.com"
1077
- ), Oi = (a) => {
1078
- const t = new URL(le);
1079
- return t.searchParams.set("access_token", a), t.toString();
1080
- }, ut = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu, ft = () => {
1081
- try {
1082
- if (typeof globalThis.crypto?.randomUUID == "function")
1083
- return globalThis.crypto.randomUUID();
1084
- } catch {
1085
- }
1086
- if (typeof globalThis.crypto?.getRandomValues != "function")
1087
- throw new Error("Secure UUID generation is unavailable");
1088
- const a = globalThis.crypto.getRandomValues(new Uint8Array(16));
1089
- a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128;
1090
- const t = [...a].map((e) => e.toString(16).padStart(2, "0")).join("");
1091
- return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
1092
- };
1093
- class he {
1094
- constructor(t, e, i) {
1095
- this.getSession = t, this.onSessionExpired = e, this.clientEnvironment = i;
1096
- }
1097
- destroyed = !1;
1098
- async track(t) {
1099
- try {
1100
- if (this.destroyed) return;
1101
- if (!t || typeof t.event != "string" || !t.event.trim())
1102
- throw new TypeError("Event tracking requires a non-empty event name");
1103
- const { event: e, params: i = {} } = t;
1104
- if (typeof i != "object" || i === null || Array.isArray(i))
1105
- throw new TypeError("Event tracking params must be a record");
1106
- const r = this.getSession();
1107
- if (Date.parse(r.expiresAt) <= Date.now()) {
1108
- this.onSessionExpired();
1109
- return;
1110
- }
1111
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = window.location.pathname, s = JSON.parse(
1112
- JSON.stringify({
1113
- eventCode: e,
1114
- occurredAt: n,
1115
- payload: i,
1116
- context: { route: o }
1117
- })
1118
- );
1119
- let c = null;
1120
- try {
1121
- c = await this.clientEnvironment.ensureForEvent(
1122
- r.interactionSessionId
1123
- );
1124
- } catch (w) {
1125
- g.debug("Client Environment attribution failed", w);
1126
- }
1127
- if (this.destroyed) return;
1128
- const l = this.getSession(), d = l.interactionSessionId === r.interactionSessionId ? l : r;
1129
- if (Date.parse(d.expiresAt) <= Date.now()) {
1130
- l.interactionSessionId === r.interactionSessionId && this.onSessionExpired();
1131
- return;
1132
- }
1133
- const u = l.interactionSessionId === r.interactionSessionId ? c : null, p = await fetch(`${j}/events/client`, {
1134
- method: "POST",
1135
- headers: {
1136
- Authorization: `Bearer ${d.accessToken}`,
1137
- "Content-Type": "application/json",
1138
- "Idempotency-Key": ft()
1139
- },
1140
- body: JSON.stringify({
1141
- ...s,
1142
- ...u ? {
1143
- clientEnvironmentObservationRef: u
1144
- } : {}
1145
- })
1146
- }), m = this.getSession();
1147
- if (p.status === 401 && m.accessToken === d.accessToken && m.interactionSessionId === d.interactionSessionId && this.onSessionExpired(), !p.ok) {
1148
- const w = await p.json().catch(() => null), f = w?.error?.code || `LOLA_HTTP_${p.status}`, E = w?.error?.message || p.statusText || "Lola event request failed";
1149
- throw new Error(`${f}: ${E}`);
1150
- }
1151
- } catch (e) {
1152
- g.warn("Event tracking failed", e);
1153
- }
1154
- }
1155
- destroy() {
1156
- this.destroyed = !0;
1157
- }
1158
- }
1159
- const H = 300 * 1e3;
1160
- function Ni(a, t = Date.now()) {
1161
- const e = Date.parse(a.expiresAt);
1162
- return !Number.isFinite(e) || e <= t + H;
1163
- }
1164
- const gt = 1, pe = [
1165
- "SURFACE_STATE_CHANGED",
1166
- "EXPERIENCE_PRESENTED",
1167
- "EXPERIENCE_ENGAGED"
1168
- ], ue = [
1169
- "CHAT_OPENED",
1170
- "CHAT_CLOSED",
1171
- "MESSAGE_PRESENTED",
1172
- "CHOICE_PRESENTED",
1173
- "CTA_PRESENTED",
1174
- "CTA_CLICKED",
1175
- "CTA_DISMISSED",
1176
- "TARGET_PRESENTED",
1177
- "TARGET_ACTIVATED"
1178
- ], fe = [
1179
- "USER",
1180
- "SCENARIO",
1181
- "HOST"
1182
- ], ge = [
1183
- "SURFACE",
1184
- "MESSAGE",
1185
- "CHOICE",
1186
- "CTA",
1187
- "TARGET"
1188
- ], me = ["SUCCEEDED", "FAILED"], we = [
1189
- "USER_LAUNCHER",
1190
- "USER_CLOSE_BUTTON",
1191
- "HOST_SET_OPEN",
1192
- "SCENARIO_COMMAND",
1193
- "UNKNOWN"
1194
- ], be = ["CHAT", "COMPACT_PREVIEW"], ve = "/scenario-interactions/capabilities", xe = "/scenario-interactions/batch", ye = 160, ke = 16, Ee = 1500, Se = 1e4, _e = 60 * 1024, Ie = 2147483647, K = 60 * 6e4, Te = 100, R = [1e3, 2e3, 5e3, 1e4, 3e4], Ae = 3e4, Re = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, mt = new Set(pe), wt = new Set(ue), bt = new Set(fe), Ce = new Set(ge), Oe = new Set(me), Ne = new Set(we), Pe = new Set(be), De = /* @__PURE__ */ new Set([
1195
- "ACCEPTED",
1196
- "DUPLICATE",
1197
- "IGNORED_NO_INTEREST",
1198
- "REJECTED"
1199
- ]), Le = (a) => {
1200
- if (a) return a;
1201
- const t = globalThis.fetch;
1202
- if (typeof t != "function")
1203
- throw new Error(
1204
- "Scenario interaction collection requires a global or injected fetch"
1205
- );
1206
- return t.bind(globalThis);
1207
- }, Ue = (a) => new TextEncoder().encode(a).length, $ = (a) => a === 408 || a === 425 || a === 429 || a >= 500, He = (a) => {
1208
- if (!a || typeof a != "object" || Array.isArray(a)) return null;
1209
- const t = a;
1210
- return t.version !== gt || !Number.isSafeInteger(t.maxBatchItems) || t.maxBatchItems < 1 || !Number.isSafeInteger(t.maxRequestBytes) || t.maxRequestBytes < 1 || !Number.isSafeInteger(t.sessionHourlyLimit) || t.sessionHourlyLimit < 1 || !Number.isSafeInteger(t.retentionDays) || t.retentionDays < 1 || !Array.isArray(t.kinds) || !t.kinds.every((e) => typeof e == "string") || !Array.isArray(t.types) || !t.types.every((e) => typeof e == "string") || !Array.isArray(t.actors) || !t.actors.every((e) => typeof e == "string") || typeof t.attributionHandleSupported != "boolean" ? null : {
1211
- version: t.version,
1212
- maxBatchItems: t.maxBatchItems,
1213
- maxRequestBytes: t.maxRequestBytes,
1214
- sessionHourlyLimit: t.sessionHourlyLimit,
1215
- retentionDays: t.retentionDays,
1216
- kinds: t.kinds.filter((e) => mt.has(e)),
1217
- types: t.types.filter((e) => wt.has(e)),
1218
- actors: t.actors.filter((e) => bt.has(e)),
1219
- attributionHandleSupported: t.attributionHandleSupported
1220
- };
1221
- }, Me = (a) => {
1222
- if (!a || typeof a != "object" || Array.isArray(a)) return null;
1223
- const t = a.receipts;
1224
- if (!Array.isArray(t)) return null;
1225
- for (const e of t)
1226
- if (!e || typeof e != "object" || typeof e.clientObservationId != "string" || !e.clientObservationId.length || e.clientObservationId.length > 128 || !De.has(e.status))
1227
- return null;
1228
- return t;
1229
- };
1230
- class je {
1231
- constructor(t, e, i = {}) {
1232
- this.getSession = t, this.onSessionExpired = e, this.baseUrl = i.baseUrl ?? j, this.queueLimit = i.queueLimit ?? ye, this.batchLimit = i.batchLimit ?? ke, this.flushIntervalMs = i.flushIntervalMs ?? Ee, this.requestTimeoutMs = Math.max(
1233
- 1,
1234
- i.requestTimeoutMs ?? Se
1235
- ), this.fetchImpl = Le(i.fetch), this.createId = i.createId ?? (() => crypto.randomUUID()), this.now = i.now ?? Date.now, this.random = i.random ?? Math.random;
1236
- const r = t();
1237
- this.principalSessionId = r.interactionSessionId, this.principalAccessToken = r.accessToken, this.principalExpiresAt = r.expiresAt, this.admissionWindowStartedAt = this.now();
1238
- }
1239
- queue = [];
1240
- baseUrl;
1241
- queueLimit;
1242
- batchLimit;
1243
- flushIntervalMs;
1244
- requestTimeoutMs;
1245
- fetchImpl;
1246
- createId;
1247
- now;
1248
- random;
1249
- sequence = 0;
1250
- capabilities;
1251
- capabilityRequest = null;
1252
- flushRequest = null;
1253
- capabilityRequestControl = null;
1254
- batchRequestControl = null;
1255
- batchRequestUsesKeepalive = !1;
1256
- flushTimer;
1257
- retryTimer;
1258
- capabilityRetryTimer;
1259
- retryAttempt = 0;
1260
- capabilityRetryAttempt = 0;
1261
- batchRetriesSuspended = !1;
1262
- capabilityRetriesSuspended = !1;
1263
- nextUserRecoveryProbeAt = 0;
1264
- awaitingRenewalToken = null;
1265
- sessionGeneration = 0;
1266
- quotaBlockedUntil = 0;
1267
- admissionWindowStartedAt;
1268
- admissionCount = 0;
1269
- started = !1;
1270
- destroyed = !1;
1271
- principalSessionId;
1272
- principalAccessToken;
1273
- principalExpiresAt;
1274
- start() {
1275
- this.started || this.destroyed || (this.started = !0, window.addEventListener("online", this.onOnlineOrFocus), window.addEventListener("focus", this.onOnlineOrFocus), window.addEventListener("pagehide", this.onPageHide), document.addEventListener("visibilitychange", this.onVisibilityChange), this.ensureCapabilities());
1276
- }
1277
- destroy() {
1278
- this.destroyed = !0, this.started = !1, this.abortPendingRequests(), this.clearTimers(), window.removeEventListener("online", this.onOnlineOrFocus), window.removeEventListener("focus", this.onOnlineOrFocus), window.removeEventListener("pagehide", this.onPageHide), document.removeEventListener("visibilitychange", this.onVisibilityChange), this.queue.length = 0;
1279
- }
1280
- updateSession(t) {
1281
- if (t.interactionSessionId !== this.principalSessionId)
1282
- return this.principalSessionId = t.interactionSessionId, this.principalAccessToken = t.accessToken, this.principalExpiresAt = t.expiresAt, this.queue.length = 0, this.sequence = 0, this.capabilities = void 0, this.sessionGeneration += 1, this.abortPendingRequests(), this.awaitingRenewalToken = null, this.resetRecoveryState(), this.quotaBlockedUntil = 0, this.admissionWindowStartedAt = this.now(), this.admissionCount = 0, this.clearFlushTimer(), this.started && this.ensureCapabilities(), !0;
1283
- if (t.accessToken !== this.principalAccessToken) {
1284
- const o = this.capabilities;
1285
- return this.principalAccessToken = t.accessToken, this.principalExpiresAt = t.expiresAt, this.sessionGeneration += 1, this.abortPendingRequests(), this.awaitingRenewalToken = null, this.resetRecoveryState(), this.clearFlushTimer(), o ? (this.capabilities = o, this.started && this.scheduleFlush(0)) : (this.capabilities = void 0, this.started && this.ensureCapabilities()), !1;
1286
- }
1287
- const i = Date.parse(this.principalExpiresAt), r = Date.parse(t.expiresAt), n = r > i;
1288
- return this.principalExpiresAt = t.expiresAt, this.awaitingRenewalToken && (t.accessToken !== this.awaitingRenewalToken || r > this.now()) && (this.awaitingRenewalToken = null, this.retryAttempt = 0, this.capabilities ? this.scheduleFlush(0) : this.ensureCapabilities()), this.started && n && r > this.now() && (this.capabilityRetryTimer !== void 0 || this.retryTimer !== void 0 || this.capabilityRetriesSuspended || this.batchRetriesSuspended) && this.resumeAfterStrongSignal(), !1;
1289
- }
1290
- enqueue(t) {
1291
- if (this.destroyed || this.capabilities === null || typeof t.kind != "string" || !mt.has(t.kind) || typeof t.type != "string" || !wt.has(t.type) || typeof t.actor != "string" || !bt.has(t.actor))
1292
- return null;
1293
- const e = this.nextSequence();
1294
- if (e === null)
1295
- return g.warn(
1296
- "Scenario interaction sequence is exhausted; observation dropped"
1297
- ), null;
1298
- const i = this.buildObservation(t, e);
1299
- if (this.capabilities && !this.isSupported(i, this.capabilities))
1300
- return null;
1301
- this.capabilities && !this.capabilities.attributionHandleSupported && delete i.attributionHandle;
1302
- const r = i.kind !== "SURFACE_STATE_CHANGED" || i.type === "CHAT_CLOSED" && !!i.attributionHandle;
1303
- let n = -1;
1304
- if (this.queue.length >= this.queueLimit) {
1305
- if (!r) return null;
1306
- if (n = this.queue.findIndex(
1307
- (o) => !o.protectedFromRoutineEviction
1308
- ), n < 0)
1309
- return g.warn("Scenario interaction queue is full; observation dropped"), null;
1310
- }
1311
- return this.capabilities && !this.admitWithinSessionQuota(this.capabilities) ? null : (n >= 0 && this.queue.splice(n, 1), this.queue.push({ observation: i, protectedFromRoutineEviction: r }), this.probeAfterUserObservation(i), this.capabilities ? this.scheduleFlush() : this.started && !this.capabilityRetriesSuspended && this.ensureCapabilities(), i.clientObservationId);
1312
- }
1313
- getQueueSnapshot() {
1314
- return this.queue.map(({ observation: t }) => t);
1315
- }
1316
- isSendingEnabled() {
1317
- return !!this.capabilities;
1318
- }
1319
- getPrincipalSessionId() {
1320
- return this.principalSessionId;
1321
- }
1322
- async flush(t = {}) {
1323
- if (this.destroyed || this.batchRetriesSuspended) return;
1324
- this.clearRetryTimer();
1325
- const e = !!t.keepalive;
1326
- if (this.flushRequest) {
1327
- if (!e || this.batchRequestUsesKeepalive)
1328
- return this.flushRequest;
1329
- this.batchRequestControl?.controller.abort(), this.flushRequest = null;
1330
- }
1331
- const i = this.sessionGeneration, r = this.createRequestControl();
1332
- this.batchRequestControl = r, this.batchRequestUsesKeepalive = e;
1333
- const n = this.flushOnce(e, i, r).finally(
1334
- () => {
1335
- this.finishRequestControl(r), this.flushRequest === n && (this.flushRequest = null), this.batchRequestControl === r && (this.batchRequestControl = null, this.batchRequestUsesKeepalive = !1);
1336
- }
1337
- );
1338
- return this.flushRequest = n, n;
1339
- }
1340
- onOnlineOrFocus = () => {
1341
- this.resumeAfterStrongSignal();
1342
- };
1343
- resumeAfterStrongSignal() {
1344
- this.destroyed || (this.resetRecoveryState(), this.capabilities === void 0 ? this.ensureCapabilities() : this.capabilities && this.scheduleFlush(0));
1345
- }
1346
- probeAfterUserObservation(t) {
1347
- if (!this.started || t.actor !== "USER" || !this.capabilityRetriesSuspended && !this.batchRetriesSuspended)
1348
- return;
1349
- const e = this.now();
1350
- if (!(e < this.nextUserRecoveryProbeAt)) {
1351
- if (this.nextUserRecoveryProbeAt = e + Ae, this.capabilityRetriesSuspended && this.capabilities === void 0) {
1352
- this.capabilityRetriesSuspended = !1, this.ensureCapabilities();
1353
- return;
1354
- }
1355
- this.batchRetriesSuspended && this.capabilities && (this.batchRetriesSuspended = !1, this.scheduleFlush(0));
1356
- }
1357
- }
1358
- onVisibilityChange = () => {
1359
- document.visibilityState === "hidden" ? this.flush({ keepalive: !0 }) : document.visibilityState === "visible" && this.resumeAfterStrongSignal();
1360
- };
1361
- onPageHide = () => {
1362
- this.flush({ keepalive: !0 });
1363
- };
1364
- buildObservation(t, e) {
1365
- const i = t.attributionHandle && Re.test(t.attributionHandle) ? t.attributionHandle : void 0;
1366
- return {
1367
- clientObservationId: this.createId().slice(0, 128),
1368
- version: gt,
1369
- kind: t.kind,
1370
- type: t.type,
1371
- actor: t.actor,
1372
- occurredAt: new Date(this.now()).toISOString(),
1373
- sequence: e,
1374
- ...typeof t.surfaceEpisodeId == "string" && t.surfaceEpisodeId ? { surfaceEpisodeId: t.surfaceEpisodeId.slice(0, 128) } : {},
1375
- ...typeof t.subjectKind == "string" && Ce.has(t.subjectKind) && typeof t.subjectId == "string" && t.subjectId ? {
1376
- subjectKind: t.subjectKind,
1377
- subjectId: t.subjectId.slice(0, 255)
1378
- } : {},
1379
- ...typeof t.result == "string" && Oe.has(t.result) ? { result: t.result } : {},
1380
- ...typeof t.reason == "string" && Ne.has(t.reason) ? { reason: t.reason } : {},
1381
- ...i ? { attributionHandle: i } : {},
1382
- ...this.buildDetails(t)
1383
- };
1384
- }
1385
- buildDetails(t) {
1386
- if (!t.details) return {};
1387
- const e = {};
1388
- return typeof t.details.surface == "string" && Pe.has(t.details.surface) && (e.surface = t.details.surface), Number.isSafeInteger(t.details.presentationOrdinal) && t.details.presentationOrdinal >= 0 && t.details.presentationOrdinal <= 1e4 && (e.presentationOrdinal = t.details.presentationOrdinal), Object.keys(e).length ? { details: e } : {};
1389
- }
1390
- async ensureCapabilities() {
1391
- if (this.destroyed || this.capabilityRetriesSuspended || this.capabilityRetryTimer !== void 0 || this.capabilities !== void 0 || this.capabilityRequest)
1392
- return this.capabilityRequest ?? Promise.resolve();
1393
- this.clearCapabilityRetryTimer();
1394
- const t = this.sessionGeneration, e = this.createRequestControl();
1395
- this.capabilityRequestControl = e;
1396
- const i = this.loadCapabilities(t, e).finally(() => {
1397
- this.finishRequestControl(e), this.capabilityRequest === i && (this.capabilityRequest = null), this.capabilityRequestControl === e && (this.capabilityRequestControl = null), !this.destroyed && t !== this.sessionGeneration && this.capabilities === void 0 && this.ensureCapabilities();
1398
- });
1399
- return this.capabilityRequest = i, i;
1400
- }
1401
- async loadCapabilities(t, e) {
1402
- const { signal: i } = e.controller, r = this.getSession();
1403
- if (!this.sessionNeedsRenewal(r))
1404
- try {
1405
- const n = await this.fetchImpl(
1406
- `${this.baseUrl}${ve}`,
1407
- {
1408
- // A conditional 304 has no JSON body and cannot negotiate the
1409
- // collector contract. Always request a complete representation.
1410
- cache: "no-store",
1411
- headers: { Authorization: `Bearer ${r.accessToken}` },
1412
- signal: i
1413
- }
1414
- );
1415
- if (!this.isCurrentGeneration(t) || i.aborted) return;
1416
- if (n.status === 401) {
1417
- this.handleUnauthorized(r);
1418
- return;
1419
- }
1420
- if (!n.ok) {
1421
- n.status === 304 || $(n.status) ? (this.capabilities = void 0, this.scheduleCapabilityRetry()) : this.disableSending(
1422
- `Scenario interaction capability request was rejected with ${n.status}`
1423
- );
1424
- return;
1425
- }
1426
- const o = He(await n.json());
1427
- if (!this.isCurrentGeneration(t) || i.aborted) return;
1428
- if (!o) {
1429
- this.disableSending("Scenario interaction capabilities are invalid");
1430
- return;
1431
- }
1432
- this.capabilities = o, this.resetCapabilityRecoveryState(), this.nextUserRecoveryProbeAt = 0, this.dropUnsupportedObservations(o), this.admissionCount = Math.max(this.admissionCount, this.queue.length), this.queue.length && this.scheduleFlush(0);
1433
- } catch (n) {
1434
- if (!this.isCurrentGeneration(t) || i.aborted && !e.timedOut)
1435
- return;
1436
- this.capabilities = void 0, this.scheduleCapabilityRetry(), g.debug("Scenario interaction capability request failed", n);
1437
- }
1438
- }
1439
- async flushOnce(t, e, i) {
1440
- const { signal: r } = i.controller;
1441
- this.clearFlushTimer();
1442
- const n = this.capabilities;
1443
- if (this.isQuotaBlocked()) {
1444
- this.scheduleFlush(this.quotaBlockedUntil - this.now());
1445
- return;
1446
- }
1447
- if (this.destroyed || !n || !this.queue.length || this.awaitingRenewalToken || typeof navigator < "u" && !navigator.onLine)
1448
- return;
1449
- const o = this.getSession();
1450
- if (o.interactionSessionId !== this.principalSessionId) {
1451
- this.updateSession(o);
1452
- return;
1453
- }
1454
- if (this.sessionNeedsRenewal(o)) return;
1455
- const s = this.selectBatch(n, t);
1456
- if (!s.length) return;
1457
- const c = JSON.stringify({
1458
- items: s.map(({ observation: l }) => l)
1459
- });
1460
- try {
1461
- const l = await this.fetchImpl(`${this.baseUrl}${xe}`, {
1462
- method: "POST",
1463
- headers: {
1464
- Authorization: `Bearer ${o.accessToken}`,
1465
- "Content-Type": "application/json"
1466
- },
1467
- body: c,
1468
- signal: r,
1469
- ...t ? { keepalive: !0 } : {}
1470
- });
1471
- if (!this.isCurrentGeneration(e) || r.aborted) return;
1472
- if (l.status === 401) {
1473
- this.handleUnauthorized(o);
1474
- return;
1475
- }
1476
- if (!l.ok) {
1477
- $(l.status) ? this.scheduleRetry() : this.disableSending(
1478
- `Scenario interaction batch was rejected with ${l.status}`
1479
- );
1480
- return;
1481
- }
1482
- const d = Me(await l.json());
1483
- if (!this.isCurrentGeneration(e) || r.aborted) return;
1484
- if (!d) {
1485
- this.scheduleRetry();
1486
- return;
1487
- }
1488
- const u = new Set(
1489
- s.map(({ observation: f }) => f.clientObservationId)
1490
- ), p = new Set(
1491
- d.filter((f) => u.has(f.clientObservationId)).map((f) => f.clientObservationId)
1492
- ), m = d.some(
1493
- (f) => u.has(f.clientObservationId) && f.status === "REJECTED" && f.code === "SESSION_HOURLY_QUOTA_EXCEEDED"
1494
- );
1495
- if (p.size)
1496
- for (let f = this.queue.length - 1; f >= 0; f -= 1)
1497
- p.has(
1498
- this.queue[f].observation.clientObservationId
1499
- ) && this.queue.splice(f, 1);
1500
- this.resetBatchRecoveryState(), this.nextUserRecoveryProbeAt = 0, m && (this.quotaBlockedUntil = this.now() + K), s.some(
1501
- ({ observation: f }) => !p.has(f.clientObservationId)
1502
- ) ? this.scheduleRetry() : this.queue.length && this.scheduleFlush(Te);
1503
- } catch (l) {
1504
- if (!this.isCurrentGeneration(e) || r.aborted && !i.timedOut)
1505
- return;
1506
- this.scheduleRetry(), g.debug("Scenario interaction batch request failed", l);
1507
- }
1508
- }
1509
- selectBatch(t, e) {
1510
- const i = Math.max(
1511
- 1,
1512
- Math.min(this.batchLimit, t.maxBatchItems)
1513
- ), r = Math.min(
1514
- t.maxRequestBytes,
1515
- e ? _e : t.maxRequestBytes
1516
- );
1517
- for (; this.queue.length; ) {
1518
- const n = this.queue.slice(0, i);
1519
- for (; n.length && Ue(
1520
- JSON.stringify({
1521
- items: n.map(({ observation: o }) => o)
1522
- })
1523
- ) > r; )
1524
- n.pop();
1525
- if (n.length) return n;
1526
- this.queue.shift(), g.warn(
1527
- "Scenario interaction observation exceeds the server request limit; observation dropped"
1528
- );
1529
- }
1530
- return [];
1531
- }
1532
- dropUnsupportedObservations(t) {
1533
- for (let e = this.queue.length - 1; e >= 0; e -= 1) {
1534
- const i = this.queue[e].observation;
1535
- this.isSupported(i, t) ? t.attributionHandleSupported || delete i.attributionHandle : this.queue.splice(e, 1);
1536
- }
1537
- }
1538
- isSupported(t, e) {
1539
- return e.kinds.includes(t.kind) && e.types.includes(t.type) && e.actors.includes(t.actor);
1540
- }
1541
- sessionNeedsRenewal(t) {
1542
- return Date.parse(t.expiresAt) > this.now() ? !1 : (this.awaitingRenewalToken = t.accessToken, this.onSessionExpired(), !0);
1543
- }
1544
- isCurrentGeneration(t) {
1545
- return !this.destroyed && t === this.sessionGeneration;
1546
- }
1547
- nextSequence() {
1548
- if (this.sequence > Ie) return null;
1549
- const t = this.sequence;
1550
- return this.sequence += 1, t;
1551
- }
1552
- abortPendingRequests() {
1553
- this.capabilityRequestControl?.controller.abort(), this.batchRequestControl?.controller.abort(), this.finishRequestControl(this.capabilityRequestControl), this.finishRequestControl(this.batchRequestControl), this.capabilityRequestControl = null, this.batchRequestControl = null, this.batchRequestUsesKeepalive = !1, this.capabilityRequest = null, this.flushRequest = null;
1554
- }
1555
- createRequestControl() {
1556
- const t = {
1557
- controller: new AbortController(),
1558
- timedOut: !1,
1559
- timeoutId: 0
1560
- };
1561
- return t.timeoutId = window.setTimeout(() => {
1562
- t.timedOut = !0, t.controller.abort();
1563
- }, this.requestTimeoutMs), t;
1564
- }
1565
- finishRequestControl(t) {
1566
- t && window.clearTimeout(t.timeoutId);
1567
- }
1568
- handleUnauthorized(t) {
1569
- const e = this.getSession();
1570
- if (e.interactionSessionId === t.interactionSessionId && e.accessToken === t.accessToken) {
1571
- this.awaitingRenewalToken = t.accessToken, this.onSessionExpired();
1572
- return;
1573
- }
1574
- this.scheduleRetry();
1575
- }
1576
- scheduleFlush(t = this.flushIntervalMs) {
1577
- if (this.destroyed || this.flushTimer !== void 0 || this.retryTimer !== void 0 || this.batchRetriesSuspended || this.awaitingRenewalToken)
1578
- return;
1579
- const e = this.isQuotaBlocked() ? Math.max(t, this.quotaBlockedUntil - this.now()) : t;
1580
- this.flushTimer = window.setTimeout(() => {
1581
- this.flushTimer = void 0, this.flush();
1582
- }, e);
1583
- }
1584
- scheduleRetry() {
1585
- if (this.destroyed || this.retryTimer !== void 0)
1586
- return;
1587
- if (this.retryAttempt >= R.length) {
1588
- this.batchRetriesSuspended = !0;
1589
- return;
1590
- }
1591
- const t = this.retryDelay(this.retryAttempt);
1592
- this.retryAttempt += 1, this.retryTimer = window.setTimeout(() => {
1593
- this.retryTimer = void 0, this.flush();
1594
- }, t);
1595
- }
1596
- scheduleCapabilityRetry() {
1597
- if (this.destroyed || this.capabilityRetryTimer !== void 0)
1598
- return;
1599
- if (this.capabilityRetryAttempt >= R.length) {
1600
- this.capabilityRetriesSuspended = !0;
1601
- return;
1602
- }
1603
- const t = this.retryDelay(this.capabilityRetryAttempt);
1604
- this.capabilityRetryAttempt += 1, this.capabilityRetryTimer = window.setTimeout(() => {
1605
- this.capabilityRetryTimer = void 0, this.capabilities = void 0, this.ensureCapabilities();
1606
- }, t);
1607
- }
1608
- clearFlushTimer() {
1609
- this.flushTimer !== void 0 && (window.clearTimeout(this.flushTimer), this.flushTimer = void 0);
1610
- }
1611
- clearTimers() {
1612
- this.clearFlushTimer(), this.clearRetryTimer(), this.clearCapabilityRetryTimer();
1613
- }
1614
- resetRecoveryState() {
1615
- this.resetBatchRecoveryState(), this.resetCapabilityRecoveryState(), this.nextUserRecoveryProbeAt = 0;
1616
- }
1617
- resetBatchRecoveryState() {
1618
- this.clearRetryTimer(), this.retryAttempt = 0, this.batchRetriesSuspended = !1;
1619
- }
1620
- resetCapabilityRecoveryState() {
1621
- this.clearCapabilityRetryTimer(), this.capabilityRetryAttempt = 0, this.capabilityRetriesSuspended = !1;
1622
- }
1623
- clearRetryTimer() {
1624
- this.retryTimer !== void 0 && window.clearTimeout(this.retryTimer), this.retryTimer = void 0;
1625
- }
1626
- clearCapabilityRetryTimer() {
1627
- this.capabilityRetryTimer !== void 0 && window.clearTimeout(this.capabilityRetryTimer), this.capabilityRetryTimer = void 0;
1628
- }
1629
- retryDelay(t) {
1630
- const e = R[Math.min(t, R.length - 1)], i = 0.75 + Math.min(1, Math.max(0, this.random())) * 0.5;
1631
- return Math.max(1, Math.round(e * i));
1632
- }
1633
- disableSending(t) {
1634
- this.capabilities = null, this.queue.length = 0, this.nextUserRecoveryProbeAt = 0, this.clearTimers(), g.debug(t);
1635
- }
1636
- admitWithinSessionQuota(t) {
1637
- if (this.isQuotaBlocked()) return !1;
1638
- const e = this.now();
1639
- return e - this.admissionWindowStartedAt >= K && (this.admissionWindowStartedAt = e, this.admissionCount = 0), this.admissionCount >= t.sessionHourlyLimit ? !1 : (this.admissionCount += 1, !0);
1640
- }
1641
- isQuotaBlocked() {
1642
- return this.quotaBlockedUntil <= this.now() ? (this.quotaBlockedUntil = 0, !1) : !0;
1643
- }
1644
- }
1645
- const qe = (a) => {
1646
- switch (a.reason) {
1647
- case "USER_LAUNCHER":
1648
- case "USER_CLOSE_BUTTON":
1649
- case "HOST_SET_OPEN":
1650
- case "SCENARIO_COMMAND":
1651
- return a.reason;
1652
- default:
1653
- return "UNKNOWN";
1654
- }
1655
- };
1656
- class ze {
1657
- constructor(t, e = () => crypto.randomUUID()) {
1658
- this.observe = t, this.createId = e;
1659
- }
1660
- state = "CLOSED";
1661
- episode = null;
1662
- transition(t, e) {
1663
- const i = this.state;
1664
- if (i === t)
1665
- return {
1666
- changed: !1,
1667
- from: i,
1668
- to: t,
1669
- episodeId: this.episode?.id ?? null,
1670
- context: e
1671
- };
1672
- t === "OPEN" && (this.episode = { id: this.createId(), openedBy: e });
1673
- const r = this.episode;
1674
- if (this.state = t, e.actor !== "SYSTEM") {
1675
- const n = e.sourceCommandId ?? r?.latestScenarioHandle ?? r?.openedBy.sourceCommandId;
1676
- this.observe({
1677
- kind: "SURFACE_STATE_CHANGED",
1678
- type: t === "OPEN" ? "CHAT_OPENED" : "CHAT_CLOSED",
1679
- actor: e.actor,
1680
- reason: qe(e),
1681
- ...r ? { surfaceEpisodeId: r.id } : {},
1682
- ...n ? { attributionHandle: n } : {},
1683
- subjectKind: "SURFACE",
1684
- subjectId: "assistant_chat"
1685
- });
1686
- }
1687
- return t === "CLOSED" && (this.episode = null), {
1688
- changed: !0,
1689
- from: i,
1690
- to: t,
1691
- episodeId: t === "OPEN" ? r?.id ?? null : null,
1692
- context: e
1693
- };
1694
- }
1695
- getState() {
1696
- return this.state;
1697
- }
1698
- getEpisodeId() {
1699
- return this.episode?.id ?? null;
1700
- }
1701
- markScenarioContext(t) {
1702
- !this.episode || this.state !== "OPEN" || (this.episode.latestScenarioHandle = t);
1703
- }
1704
- replacePrincipal() {
1705
- if (this.state === "OPEN") {
1706
- this.episode = {
1707
- id: this.createId(),
1708
- openedBy: { actor: "SYSTEM", reason: "SYSTEM_RESTORE" }
1709
- };
1710
- return;
1711
- }
1712
- this.episode = null;
1713
- }
1714
- }
1715
- const Ve = 0.5, Ge = 500, Fe = ({
1716
- element: a,
1717
- isActive: t,
1718
- isPresentable: e = () => !0,
1719
- onPresented: i,
1720
- intersectionRatio: r = Ve,
1721
- dwellMs: n = Ge
1722
- }) => {
1723
- if (typeof IntersectionObserver != "function") {
1724
- const y = (() => {
1725
- });
1726
- return y.pause = () => {
1727
- }, y.resume = () => {
1728
- }, y.refresh = () => {
1729
- }, y;
1730
- }
1731
- let o = 0, s = !1, c = !1, l, d = 0, u = n;
1732
- const p = (y = !1) => {
1733
- l !== void 0 && (window.clearTimeout(l), l = void 0, y ? u = Math.max(
1734
- 0,
1735
- u - (Date.now() - d)
1736
- ) : u = n);
1737
- }, m = () => !s && !c && document.visibilityState === "visible" && t() && e() && o >= r, w = () => {
1738
- if (!m()) {
1739
- p();
1740
- return;
1741
- }
1742
- l === void 0 && (d = Date.now(), l = window.setTimeout(() => {
1743
- l = void 0, m() && (s = !0, f.disconnect(), E.disconnect(), document.removeEventListener("visibilitychange", w), i());
1744
- }, u));
1745
- }, f = new IntersectionObserver(
1746
- (y) => {
1747
- const A = y.find(({ target: N }) => N === a);
1748
- o = A?.isIntersecting ? A.intersectionRatio : 0, w();
1749
- },
1750
- { threshold: [0, r, 1] }
1751
- );
1752
- f.observe(a);
1753
- const E = new MutationObserver(w);
1754
- E.observe(a, {
1755
- childList: !0,
1756
- characterData: !0,
1757
- subtree: !0
1758
- }), document.addEventListener("visibilitychange", w);
1759
- const x = (() => {
1760
- s = !0, p(), f.disconnect(), E.disconnect(), document.removeEventListener("visibilitychange", w);
1761
- });
1762
- return x.pause = () => {
1763
- c || s || (c = !0, p(!0));
1764
- }, x.resume = () => {
1765
- !c || s || (c = !1, w());
1766
- }, x.refresh = w, x;
1767
- };
1768
- class We {
1769
- collector;
1770
- surfaceController;
1771
- compactSurfaceEpisode = null;
1772
- presented = /* @__PURE__ */ new Set();
1773
- engaged = /* @__PURE__ */ new Set();
1774
- constructor(t, e, i) {
1775
- this.collector = new je(
1776
- t,
1777
- e,
1778
- i
1779
- ), this.surfaceController = new ze((r) => {
1780
- this.collector.enqueue(r);
1781
- });
1782
- }
1783
- start() {
1784
- this.collector.start();
1785
- }
1786
- destroy() {
1787
- this.collector.destroy(), this.compactSurfaceEpisode = null, this.presented.clear(), this.engaged.clear();
1788
- }
1789
- updateSession(t) {
1790
- this.collector.updateSession(t) && (this.compactSurfaceEpisode = null, this.presented.clear(), this.engaged.clear(), this.surfaceController.replacePrincipal());
1791
- }
1792
- transitionSurface(t, e) {
1793
- const i = this.getSurfaceEpisodeId(), r = this.surfaceController.transition(t, e);
1794
- return r.changed && i !== this.getSurfaceEpisodeId() && (this.presented.clear(), this.engaged.clear()), r;
1795
- }
1796
- getSurfaceState() {
1797
- return this.surfaceController.getState();
1798
- }
1799
- getSurfaceEpisodeId() {
1800
- return this.surfaceController.getEpisodeId();
1801
- }
1802
- openCompactSurfaceEpisode(t) {
1803
- return (!this.compactSurfaceEpisode || t && this.compactSurfaceEpisode.id !== t) && (this.compactSurfaceEpisode = {
1804
- id: t ?? crypto.randomUUID(),
1805
- presented: /* @__PURE__ */ new Set(),
1806
- engaged: /* @__PURE__ */ new Set()
1807
- }), this.compactSurfaceEpisode.id;
1808
- }
1809
- closeCompactSurfaceEpisode(t = this.compactSurfaceEpisode?.id) {
1810
- return !t || t !== this.compactSurfaceEpisode?.id ? !1 : (this.compactSurfaceEpisode = null, !0);
1811
- }
1812
- getCompactSurfaceEpisodeId() {
1813
- return this.compactSurfaceEpisode?.id ?? null;
1814
- }
1815
- recordCompactPresented(t, e = this.compactSurfaceEpisode?.id) {
1816
- const i = this.compactSurfaceEpisode;
1817
- if (!i || !e || e !== i.id)
1818
- return !1;
1819
- const r = [
1820
- e,
1821
- t.subjectKind,
1822
- t.subjectId
1823
- ].join(":");
1824
- if (i.presented.has(r)) return !1;
1825
- const n = `${t.subjectKind}_PRESENTED`;
1826
- return this.collector.enqueue({
1827
- kind: "EXPERIENCE_PRESENTED",
1828
- type: n,
1829
- actor: t.actor ?? "SCENARIO",
1830
- surfaceEpisodeId: e,
1831
- subjectKind: t.subjectKind,
1832
- subjectId: t.subjectId,
1833
- ...t.attributionHandle ? { attributionHandle: t.attributionHandle } : {},
1834
- details: {
1835
- surface: "COMPACT_PREVIEW",
1836
- ...t.presentationOrdinal !== void 0 ? { presentationOrdinal: t.presentationOrdinal } : {}
1837
- }
1838
- }) ? (i.presented.add(r), !0) : !1;
1839
- }
1840
- recordCompactEngagement(t, e = this.compactSurfaceEpisode?.id) {
1841
- const i = this.compactSurfaceEpisode;
1842
- if (!i || !e || e !== i.id)
1843
- return !1;
1844
- const r = [
1845
- e,
1846
- t.type,
1847
- t.subjectKind,
1848
- t.subjectId
1849
- ].join(":");
1850
- return i.engaged.has(r) || !this.collector.enqueue({
1851
- kind: "EXPERIENCE_ENGAGED",
1852
- type: t.type,
1853
- actor: "USER",
1854
- surfaceEpisodeId: e,
1855
- subjectKind: t.subjectKind,
1856
- subjectId: t.subjectId,
1857
- ...t.attributionHandle ? { attributionHandle: t.attributionHandle } : {},
1858
- ...t.result ? { result: t.result } : {},
1859
- details: { surface: "COMPACT_PREVIEW" }
1860
- }) ? !1 : (i.engaged.add(r), !0);
1861
- }
1862
- getPrincipalSessionId() {
1863
- return this.collector.getPrincipalSessionId();
1864
- }
1865
- recordPresented(t, e = this.getSurfaceEpisodeId()) {
1866
- if (!e || e !== this.getSurfaceEpisodeId() || this.getSurfaceState() !== "OPEN")
1867
- return !1;
1868
- const i = [
1869
- e,
1870
- t.subjectKind,
1871
- t.subjectId
1872
- ].join(":");
1873
- if (this.presented.has(i)) return !1;
1874
- const r = `${t.subjectKind}_PRESENTED`;
1875
- return this.collector.enqueue({
1876
- kind: "EXPERIENCE_PRESENTED",
1877
- type: r,
1878
- actor: t.actor ?? "SCENARIO",
1879
- surfaceEpisodeId: e,
1880
- subjectKind: t.subjectKind,
1881
- subjectId: t.subjectId,
1882
- ...t.attributionHandle ? { attributionHandle: t.attributionHandle } : {},
1883
- ...t.presentationOrdinal !== void 0 ? { details: { presentationOrdinal: t.presentationOrdinal } } : {}
1884
- }) ? (this.presented.add(i), t.attributionHandle && this.surfaceController.markScenarioContext(t.attributionHandle), !0) : !1;
1885
- }
1886
- recordEngagement(t) {
1887
- const e = this.getSurfaceEpisodeId();
1888
- if (!e || this.getSurfaceState() !== "OPEN") return !1;
1889
- const i = [
1890
- e,
1891
- t.type,
1892
- t.subjectKind,
1893
- t.subjectId
1894
- ].join(":");
1895
- return this.engaged.has(i) || !this.collector.enqueue({
1896
- kind: "EXPERIENCE_ENGAGED",
1897
- type: t.type,
1898
- actor: "USER",
1899
- surfaceEpisodeId: e,
1900
- subjectKind: t.subjectKind,
1901
- subjectId: t.subjectId,
1902
- ...t.attributionHandle ? { attributionHandle: t.attributionHandle } : {},
1903
- ...t.result ? { result: t.result } : {}
1904
- }) ? !1 : (this.engaged.add(i), t.attributionHandle && this.surfaceController.markScenarioContext(t.attributionHandle), !0);
1905
- }
1906
- recordTargetPresented(t, e = this.getSurfaceEpisodeId()) {
1907
- return this.collector.enqueue({
1908
- kind: "EXPERIENCE_PRESENTED",
1909
- type: "TARGET_PRESENTED",
1910
- actor: "SCENARIO",
1911
- ...e ? { surfaceEpisodeId: e } : {},
1912
- subjectKind: "TARGET",
1913
- subjectId: t,
1914
- attributionHandle: t
1915
- }) ? (this.markCurrentTargetContext(t, e), !0) : !1;
1916
- }
1917
- recordTargetActivation(t, e = this.getSurfaceEpisodeId()) {
1918
- return this.collector.enqueue({
1919
- kind: "EXPERIENCE_ENGAGED",
1920
- type: "TARGET_ACTIVATED",
1921
- actor: "USER",
1922
- ...e ? { surfaceEpisodeId: e } : {},
1923
- subjectKind: "TARGET",
1924
- subjectId: t,
1925
- attributionHandle: t
1926
- }) ? (this.markCurrentTargetContext(t, e), !0) : !1;
1927
- }
1928
- observeHighlightedTarget(t) {
1929
- const e = this.getSurfaceEpisodeId(), i = this.getPrincipalSessionId();
1930
- let r = !0;
1931
- const n = Fe({
1932
- element: t.element,
1933
- isActive: () => r && this.getPrincipalSessionId() === i,
1934
- onPresented: () => this.recordTargetPresented(t.commandId, e)
1935
- });
1936
- return () => {
1937
- r = !1, n();
1938
- };
1939
- }
1940
- markCurrentTargetContext(t, e) {
1941
- e && this.getSurfaceState() === "OPEN" && this.getSurfaceEpisodeId() === e && this.surfaceController.markScenarioContext(t);
1942
- }
1943
- }
1944
- const Be = "2.26.0", Ke = 1, $e = 1, vt = 35, Ye = 10, Xe = 64, Ze = 64, _ = 32768, Je = 32, Y = 840, X = 0.1, Z = 16, L = 64, J = 32, Qe = 0.25, xt = 0.1, Q = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, tt = "lola-ai-assistant:client-environment:browser-instance:v1", v = (a) => {
1945
- try {
1946
- return a();
1947
- } catch {
1948
- return null;
1949
- }
1950
- }, C = (a, t) => typeof a != "string" || a.length === 0 ? null : Array.from(a).slice(0, t).join(""), k = (a, t, e, i = !1) => {
1951
- if (typeof a != "number" || !Number.isFinite(a)) return null;
1952
- const r = i ? Math.round(a) : a;
1953
- return !Number.isInteger(r) || r < t || r > e ? null : Object.is(r, -0) ? 0 : r;
1954
- }, et = (a, t, e) => typeof a != "number" || !Number.isFinite(a) || a < t || a > e ? null : Object.is(a, -0) ? 0 : a, it = (a) => typeof a == "boolean" ? a : null, ti = (a) => {
1955
- if (!Array.isArray(a)) return [];
1956
- const t = [], e = /* @__PURE__ */ new Set();
1957
- for (const i of a) {
1958
- const r = C(i, vt);
1959
- if (!(r === null || e.has(r)) && (t.push(r), e.add(r), t.length === Ye))
1960
- break;
1961
- }
1962
- return t;
1963
- }, ei = (a) => a instanceof Date && Number.isFinite(a.getTime()) ? a.toISOString() : (/* @__PURE__ */ new Date(0)).toISOString(), ii = (a, t, e) => {
1964
- if (typeof a == "string") {
1965
- const i = a.toLowerCase();
1966
- if (i.startsWith("portrait")) return "portrait";
1967
- if (i.startsWith("landscape")) return "landscape";
1968
- }
1969
- return t === null || e === null || t === e ? "unknown" : t > e ? "landscape" : "portrait";
1970
- }, yt = {
1971
- now: () => /* @__PURE__ */ new Date(),
1972
- language: () => typeof navigator > "u" ? null : navigator.language,
1973
- languages: () => typeof navigator > "u" ? null : navigator.languages,
1974
- timeZone: () => typeof Intl > "u" ? null : Intl.DateTimeFormat().resolvedOptions().timeZone,
1975
- timeZoneOffsetMinutes: () => (/* @__PURE__ */ new Date()).getTimezoneOffset(),
1976
- screenWidth: () => typeof window > "u" ? null : window.screen.width,
1977
- screenHeight: () => typeof window > "u" ? null : window.screen.height,
1978
- screenAvailableWidth: () => typeof window > "u" ? null : window.screen.availWidth,
1979
- screenAvailableHeight: () => typeof window > "u" ? null : window.screen.availHeight,
1980
- devicePixelRatio: () => typeof window > "u" ? null : window.devicePixelRatio,
1981
- screenOrientationType: () => typeof window > "u" ? null : window.screen.orientation?.type,
1982
- viewportWidth: () => typeof window > "u" ? null : window.innerWidth,
1983
- viewportHeight: () => typeof window > "u" ? null : window.innerHeight,
1984
- visualViewportWidth: () => typeof window > "u" ? null : window.visualViewport?.width,
1985
- visualViewportHeight: () => typeof window > "u" ? null : window.visualViewport?.height,
1986
- visualViewportScale: () => typeof window > "u" ? null : window.visualViewport?.scale,
1987
- maxTouchPoints: () => typeof navigator > "u" ? null : navigator.maxTouchPoints,
1988
- coarsePointer: () => typeof window > "u" || typeof window.matchMedia != "function" ? null : window.matchMedia("(pointer: coarse)").matches,
1989
- hoverSupported: () => typeof window > "u" || typeof window.matchMedia != "function" ? null : window.matchMedia("(hover: hover)").matches,
1990
- storage: () => typeof window > "u" ? null : window.localStorage,
1991
- randomUuid: () => typeof globalThis.crypto?.randomUUID != "function" ? null : globalThis.crypto.randomUUID()
1992
- }, ri = (a = yt) => {
1993
- try {
1994
- const t = a.storage();
1995
- if (!t) return null;
1996
- const e = t.getItem(
1997
- tt
1998
- );
1999
- if (e !== null && Q.test(e)) return e;
2000
- const i = a.randomUuid();
2001
- return typeof i != "string" || !Q.test(i) ? null : (t.setItem(tt, i), i);
2002
- } catch {
2003
- return null;
2004
- }
2005
- }, ai = (a, t = yt) => {
2006
- const e = k(
2007
- v(t.screenWidth),
2008
- 0,
2009
- _,
2010
- !0
2011
- ), i = k(
2012
- v(t.screenHeight),
2013
- 0,
2014
- _,
2015
- !0
2016
- ), r = k(
2017
- v(t.timeZoneOffsetMinutes),
2018
- -Y,
2019
- Y
2020
- );
2021
- return {
2022
- schemaVersion: Ke,
2023
- clientObservationId: a.clientObservationId,
2024
- clientRuntimeId: a.clientRuntimeId,
2025
- clientSequence: a.clientSequence,
2026
- browserInstanceId: ri(t),
2027
- collectedAt: ei(v(t.now)),
2028
- sdk: {
2029
- name: "lola-ai-assistant",
2030
- version: C(a.sdkVersion, Ze) ?? "unknown"
2031
- },
2032
- locale: {
2033
- language: C(v(t.language), vt),
2034
- languages: ti(v(t.languages)),
2035
- timeZone: C(v(t.timeZone), Xe),
2036
- localUtcOffsetMinutes: r === null ? null : Object.is(-r, -0) ? 0 : -r
2037
- },
2038
- screen: {
2039
- widthCssPx: e,
2040
- heightCssPx: i,
2041
- availableWidthCssPx: k(
2042
- v(t.screenAvailableWidth),
2043
- 0,
2044
- _,
2045
- !0
2046
- ),
2047
- availableHeightCssPx: k(
2048
- v(t.screenAvailableHeight),
2049
- 0,
2050
- _,
2051
- !0
2052
- ),
2053
- devicePixelRatio: et(
2054
- v(t.devicePixelRatio),
2055
- X,
2056
- Z
2057
- ),
2058
- orientation: ii(
2059
- v(t.screenOrientationType),
2060
- e,
2061
- i
2062
- )
2063
- },
2064
- viewport: {
2065
- widthCssPx: k(
2066
- v(t.viewportWidth),
2067
- 0,
2068
- _,
2069
- !0
2070
- ),
2071
- heightCssPx: k(
2072
- v(t.viewportHeight),
2073
- 0,
2074
- _,
2075
- !0
2076
- ),
2077
- visualWidthCssPx: k(
2078
- v(t.visualViewportWidth),
2079
- 0,
2080
- _,
2081
- !0
2082
- ),
2083
- visualHeightCssPx: k(
2084
- v(t.visualViewportHeight),
2085
- 0,
2086
- _,
2087
- !0
2088
- ),
2089
- visualScale: et(
2090
- v(t.visualViewportScale),
2091
- X,
2092
- Z
2093
- )
2094
- },
2095
- interaction: {
2096
- maxTouchPoints: k(
2097
- v(t.maxTouchPoints),
2098
- 0,
2099
- Je
2100
- ),
2101
- coarsePointer: it(v(t.coarsePointer)),
2102
- hoverSupported: it(v(t.hoverSupported))
2103
- }
2104
- };
2105
- }, rt = (a, t) => {
2106
- if (a === null) return null;
2107
- const e = t === xt ? 1 : 2;
2108
- return Number((Math.round(a / t) * t).toFixed(e));
2109
- }, ni = (a, t) => {
2110
- if (a === null) return null;
2111
- const e = Math.floor(a / L) * L;
2112
- if (t === null) return e;
2113
- const i = Math.max(
2114
- 0,
2115
- t - J
2116
- ), r = t + L + J;
2117
- return a >= i && a < r ? t : e;
2118
- }, oi = (a, t = null) => ({
2119
- projectionVersion: $e,
2120
- browserInstanceId: a.browserInstanceId,
2121
- language: a.locale.language,
2122
- languages: a.locale.languages,
2123
- timeZone: a.locale.timeZone,
2124
- localUtcOffsetMinutes: a.locale.localUtcOffsetMinutes,
2125
- screenWidthCssPx: a.screen.widthCssPx,
2126
- screenHeightCssPx: a.screen.heightCssPx,
2127
- screenAvailableWidthCssPx: a.screen.availableWidthCssPx,
2128
- screenAvailableHeightCssPx: a.screen.availableHeightCssPx,
2129
- devicePixelRatio: rt(
2130
- a.screen.devicePixelRatio,
2131
- Qe
2132
- ),
2133
- orientation: a.screen.orientation,
2134
- viewportWidthBucketCssPx: ni(
2135
- a.viewport.widthCssPx,
2136
- t?.viewportWidthBucketCssPx ?? null
2137
- ),
2138
- visualScale: rt(a.viewport.visualScale, xt),
2139
- maxTouchPoints: a.interaction.maxTouchPoints,
2140
- coarsePointer: a.interaction.coarsePointer,
2141
- hoverSupported: a.interaction.hoverSupported
2142
- }), si = "/client-environment/observations", ci = 250, li = 1e3, di = 1e4, at = [250, 1e3, 3e3], hi = 0.2, pi = 3e4, ui = 2147483647, fi = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,9})?(?:Z|[+-](\d{2}):(\d{2}))$/u, gi = "00000000-0000-4000-8000-000000000000", nt = () => {
2143
- let a;
2144
- const t = new Promise((i) => {
2145
- a = i;
2146
- });
2147
- let e = !1;
2148
- return {
2149
- promise: t,
2150
- resolve: (i) => {
2151
- e || (e = !0, a(i));
2152
- }
2153
- };
2154
- }, mi = (a) => a || ((t, e) => globalThis.fetch(t, e)), ot = (a) => JSON.stringify(a), wi = (a) => a === 408 || a === 429 || a >= 500, bi = (a) => {
2155
- const t = fi.exec(a);
2156
- if (!t) return !1;
2157
- const [
2158
- ,
2159
- e,
2160
- i,
2161
- r,
2162
- n,
2163
- o,
2164
- s
2165
- ] = t, c = Number(e), l = Number(i), d = Number(r), u = Number(n), p = Number(o), m = Number(s), w = Number(t[7] ?? 0), f = Number(t[8] ?? 0), x = [
2166
- 31,
2167
- c % 4 === 0 && (c % 100 !== 0 || c % 400 === 0) ? 29 : 28,
2168
- 31,
2169
- 30,
2170
- 31,
2171
- 30,
2172
- 31,
2173
- 31,
2174
- 30,
2175
- 31,
2176
- 30,
2177
- 31
2178
- ];
2179
- return l >= 1 && l <= 12 && d >= 1 && d <= x[l - 1] && u <= 23 && p <= 59 && m <= 59 && w <= 23 && f <= 59 && Number.isFinite(Date.parse(a));
2180
- }, vi = async (a, t) => {
2181
- let e;
2182
- try {
2183
- e = await a.json();
2184
- } catch (i) {
2185
- if (i instanceof SyntaxError || i instanceof Error && i.name === "SyntaxError")
2186
- return null;
2187
- throw i;
2188
- }
2189
- return !e || e.schemaVersion !== 1 || e.clientObservationId !== t.clientObservationId || typeof e.observationRef != "string" || !ut.test(e.observationRef) || typeof e.receivedAt != "string" || !bi(e.receivedAt) || typeof e.duplicate != "boolean" || a.status === 201 && e.duplicate !== !1 || a.status === 200 && e.duplicate !== !0 ? null : { observationRef: e.observationRef };
2190
- };
2191
- class xi {
2192
- constructor(t, e, i = {}) {
2193
- this.getSession = t, this.onSessionExpired = e;
2194
- const r = t();
2195
- this.sessionId = r.interactionSessionId, this.accessToken = r.accessToken, this.baseUrl = i.baseUrl ?? j, this.fetchImpl = mi(i.fetch), this.collect = i.collect ?? ai, this.project = i.project ?? oi, this.createId = i.createId ?? ft, this.runtimeId = this.safeCreateId(), this.now = i.now ?? Date.now, this.random = i.random ?? Math.random, this.sdkVersion = i.sdkVersion ?? Be;
2196
- }
2197
- baseUrl;
2198
- fetchImpl;
2199
- collect;
2200
- project;
2201
- createId;
2202
- now;
2203
- random;
2204
- sdkVersion;
2205
- sessionId;
2206
- accessToken;
2207
- generation = 1;
2208
- runtimeId;
2209
- nextSequence = 1;
2210
- latestFenceRevision = 0;
2211
- lastStartedAt = Number.NEGATIVE_INFINITY;
2212
- cooldownUntil = 0;
2213
- lastCollectedProjection = null;
2214
- acknowledged = null;
2215
- active = null;
2216
- pending = null;
2217
- recovery = null;
2218
- awaitingRenewalToken = null;
2219
- currentProjectionUncertain = !1;
2220
- suppressedProjectionKey = null;
2221
- pumpTimer;
2222
- eventWaiters = /* @__PURE__ */ new Set();
2223
- started = !1;
2224
- destroyed = !1;
2225
- start() {
2226
- this.started || this.destroyed || (this.started = !0, this.requestCurrentObservation());
2227
- }
2228
- async ensureForEvent(t) {
2229
- if (!this.started && !this.destroyed && this.start(), this.destroyed || !this.started || t !== this.sessionId || this.getSession().interactionSessionId !== t)
2230
- return null;
2231
- const e = this.generation, i = this.requestCurrentObservation();
2232
- return this.withEventDeadline(i, e, t);
2233
- }
2234
- updateSession(t) {
2235
- if (this.destroyed) return;
2236
- if (t.interactionSessionId !== this.sessionId) {
2237
- this.resetGeneration(t), this.started && this.requestCurrentObservation();
2238
- return;
2239
- }
2240
- const e = t.accessToken !== this.accessToken;
2241
- this.accessToken = t.accessToken;
2242
- const i = e && this.awaitingRenewalToken !== null && t.accessToken !== this.awaitingRenewalToken;
2243
- if (i && (this.awaitingRenewalToken = null), i && this.recovery?.reason === "authentication" && this.recovery.projectionKey === ot(this.lastCollectedProjection ?? this.recovery.projection)) {
2244
- const r = this.recovery;
2245
- this.recovery = null, this.startRecovery(r);
2246
- } else i && this.started && (this.recovery = null, this.requestCurrentObservation());
2247
- }
2248
- destroy() {
2249
- this.destroyed || (this.destroyed = !0, this.started = !1, this.cancelGeneration(), this.acknowledged = null, this.recovery = null, this.awaitingRenewalToken = null, this.currentProjectionUncertain = !1, this.lastCollectedProjection = null);
2250
- }
2251
- requestCurrentObservation() {
2252
- if (this.destroyed || !this.started) return Promise.resolve(null);
2253
- const t = this.getSession();
2254
- if (t.interactionSessionId !== this.sessionId && this.resetGeneration(t), this.nextSequence > ui || (this.runtimeId || (this.runtimeId = this.safeCreateId()), !this.runtimeId)) return Promise.resolve(null);
2255
- const e = this.runtimeId;
2256
- let i, r;
2257
- try {
2258
- i = this.collect({
2259
- clientObservationId: gi,
2260
- clientRuntimeId: e,
2261
- clientSequence: this.nextSequence,
2262
- sdkVersion: this.sdkVersion
2263
- }), r = this.project(i, this.lastCollectedProjection);
2264
- } catch (d) {
2265
- return g.debug("Client Environment collection failed", d), Promise.resolve(null);
2266
- }
2267
- this.lastCollectedProjection = r;
2268
- const n = ot(r);
2269
- if (this.awaitingRenewalToken !== null && t.accessToken === this.awaitingRenewalToken)
2270
- return this.recovery?.projectionKey !== n && (this.recovery = null), Promise.resolve(null);
2271
- if (this.recovery)
2272
- if (this.recovery.projectionKey !== n)
2273
- this.recovery.reason === "transient" && (this.currentProjectionUncertain = !0), this.recovery = null;
2274
- else {
2275
- if (this.recovery.reason === "authentication")
2276
- return Promise.resolve(null);
2277
- if (this.now() < this.cooldownUntil)
2278
- return Promise.resolve(null);
2279
- {
2280
- const d = this.recovery;
2281
- return this.recovery = null, this.startRecovery(d);
2282
- }
2283
- }
2284
- if (this.now() < this.cooldownUntil)
2285
- return this.currentProjectionUncertain = !0, !this.active && !this.pending && this.acknowledged?.projectionKey === n ? Promise.resolve(this.acknowledged.observationRef) : Promise.resolve(null);
2286
- const o = this.currentProjectionUncertain;
2287
- let s = !1;
2288
- if (this.pending) {
2289
- if (this.pending.projectionKey === n)
2290
- return this.pending.deferred.promise;
2291
- this.pending.deferred.resolve(null), this.pending = null, s = !0;
2292
- }
2293
- if (this.active?.projectionKey === n)
2294
- return s && (this.active.fenceRevision = ++this.latestFenceRevision), this.active.deferred.promise;
2295
- if (!o && !this.active && this.acknowledged?.projectionKey === n)
2296
- return this.suppressedProjectionKey = null, Promise.resolve(this.acknowledged.observationRef);
2297
- if (this.suppressedProjectionKey === n) return Promise.resolve(null);
2298
- this.suppressedProjectionKey = null;
2299
- const c = this.safeCreateId();
2300
- if (!c) return Promise.resolve(null);
2301
- i = {
2302
- ...i,
2303
- clientObservationId: c
2304
- }, this.nextSequence += 1;
2305
- const l = {
2306
- generation: this.generation,
2307
- observation: i,
2308
- projection: r,
2309
- projectionKey: n,
2310
- fenceRevision: ++this.latestFenceRevision,
2311
- deferred: nt(),
2312
- controller: null
2313
- };
2314
- return this.currentProjectionUncertain = !1, this.pending = l, this.pump(), l.deferred.promise;
2315
- }
2316
- startRecovery(t) {
2317
- if (this.destroyed || t.generation !== this.generation)
2318
- return Promise.resolve(null);
2319
- const e = {
2320
- ...t,
2321
- fenceRevision: ++this.latestFenceRevision,
2322
- deferred: nt(),
2323
- controller: null
2324
- };
2325
- return this.active = e, this.upload(e), e.deferred.promise;
2326
- }
2327
- pump() {
2328
- if (this.destroyed || this.active || !this.pending) return;
2329
- const t = Math.max(
2330
- 0,
2331
- this.lastStartedAt + li - this.now()
2332
- );
2333
- if (t > 0) {
2334
- if (this.pumpTimer !== void 0) return;
2335
- this.pumpTimer = window.setTimeout(() => {
2336
- this.pumpTimer = void 0, this.pump();
2337
- }, t);
2338
- return;
2339
- }
2340
- const e = this.pending;
2341
- this.pending = null, this.active = e, this.lastStartedAt = this.now(), this.upload(e);
2342
- }
2343
- async upload(t) {
2344
- const e = new AbortController();
2345
- t.controller = e;
2346
- const i = await this.runAttempts(t, e.signal);
2347
- if (this.destroyed || t.generation !== this.generation || this.active !== t) {
2348
- t.deferred.resolve(null);
2349
- return;
2350
- }
2351
- if (this.active = null, t.controller = null, i.kind === "acknowledged") {
2352
- const r = t.observation.clientSequence;
2353
- (!this.acknowledged || r > this.acknowledged.clientSequence) && (this.acknowledged = {
2354
- ...t,
2355
- clientSequence: r,
2356
- observationRef: i.receipt.observationRef
2357
- });
2358
- const n = t.fenceRevision === this.latestFenceRevision && !this.pending;
2359
- t.deferred.resolve(
2360
- n ? i.receipt.observationRef : null
2361
- ), this.cooldownUntil = 0, this.recovery = null, this.awaitingRenewalToken = null, this.currentProjectionUncertain = !1;
2362
- } else if (i.kind === "transient-exhausted") {
2363
- const r = this.pending ?? t;
2364
- this.pending?.deferred.resolve(null), this.pending = null, this.recovery = {
2365
- generation: r.generation,
2366
- observation: r.observation,
2367
- projection: r.projection,
2368
- projectionKey: r.projectionKey,
2369
- reason: "transient"
2370
- }, this.cooldownUntil = this.now() + pi, this.currentProjectionUncertain = !1, t.deferred.resolve(null);
2371
- } else if (i.kind === "authentication") {
2372
- const r = this.pending ?? t;
2373
- this.pending?.deferred.resolve(null), this.pending = null;
2374
- const n = {
2375
- generation: r.generation,
2376
- observation: r.observation,
2377
- projection: r.projection,
2378
- projectionKey: r.projectionKey,
2379
- reason: "authentication"
2380
- };
2381
- t.deferred.resolve(null), this.getSession().accessToken !== i.rejectedAccessToken ? (this.awaitingRenewalToken = null, this.recovery = null, this.startRecovery(n)) : (this.recovery = n, this.awaitingRenewalToken = i.rejectedAccessToken);
2382
- } else i.kind === "permanent" && (this.suppressedProjectionKey = t.projectionKey, this.currentProjectionUncertain = !1), t.deferred.resolve(null);
2383
- this.pending && this.pump();
2384
- }
2385
- async runAttempts(t, e) {
2386
- const i = JSON.stringify(t.observation);
2387
- let r = 0, n = 0;
2388
- for (; !e.aborted; ) {
2389
- const o = await this.sendOnce(t, i, e);
2390
- if (o.kind === "acknowledged" || o.kind === "cancelled" || o.kind === "authentication" || o.kind === "permanent") return o;
2391
- if (o.kind === "authentication-refreshed") {
2392
- if (n += 1, n > 1)
2393
- return {
2394
- kind: "authentication",
2395
- rejectedAccessToken: o.rejectedAccessToken
2396
- };
2397
- continue;
2398
- }
2399
- if (r >= at.length)
2400
- return { kind: "transient-exhausted" };
2401
- const s = at[r];
2402
- r += 1;
2403
- const c = Math.floor(
2404
- s * hi * Math.min(1, Math.max(0, this.random()))
2405
- );
2406
- if (!await this.delay(s + c, e))
2407
- return { kind: "cancelled" };
2408
- }
2409
- return { kind: "cancelled" };
2410
- }
2411
- async sendOnce(t, e, i) {
2412
- if (i.aborted || t.generation !== this.generation || this.destroyed)
2413
- return { kind: "cancelled" };
2414
- const r = this.getSession();
2415
- if (r.interactionSessionId !== this.sessionId)
2416
- return { kind: "cancelled" };
2417
- if (Date.parse(r.expiresAt) <= this.now())
2418
- return this.onSessionExpired(), {
2419
- kind: "authentication",
2420
- rejectedAccessToken: r.accessToken
2421
- };
2422
- const n = new AbortController(), o = () => n.abort();
2423
- i.addEventListener("abort", o, { once: !0 });
2424
- const s = window.setTimeout(() => {
2425
- n.abort();
2426
- }, di);
2427
- try {
2428
- const c = await this.fetchImpl(
2429
- `${this.baseUrl}${si}`,
2430
- {
2431
- method: "POST",
2432
- headers: {
2433
- Authorization: `Bearer ${r.accessToken}`,
2434
- "Content-Type": "application/json"
2435
- },
2436
- body: e,
2437
- signal: n.signal
2438
- }
2439
- );
2440
- if (i.aborted || t.generation !== this.generation || this.destroyed)
2441
- return { kind: "cancelled" };
2442
- if (c.status === 200 || c.status === 201) {
2443
- const l = await vi(c, t.observation);
2444
- return l ? { kind: "acknowledged", receipt: l } : { kind: "permanent" };
2445
- }
2446
- if (c.status === 401) {
2447
- const l = this.getSession();
2448
- return l.interactionSessionId === this.sessionId && l.accessToken !== r.accessToken ? {
2449
- kind: "authentication-refreshed",
2450
- rejectedAccessToken: r.accessToken
2451
- } : (l.interactionSessionId === this.sessionId && l.accessToken === r.accessToken && this.onSessionExpired(), {
2452
- kind: "authentication",
2453
- rejectedAccessToken: r.accessToken
2454
- });
2455
- }
2456
- return wi(c.status) ? { kind: "retryable" } : { kind: "permanent" };
2457
- } catch (c) {
2458
- return i.aborted ? { kind: "cancelled" } : (g.debug("Client Environment observation request failed", c), { kind: "retryable" });
2459
- } finally {
2460
- window.clearTimeout(s), i.removeEventListener("abort", o);
2461
- }
2462
- }
2463
- withEventDeadline(t, e, i) {
2464
- return new Promise((r) => {
2465
- let n = !1;
2466
- const o = (l) => {
2467
- if (n) return;
2468
- n = !0, window.clearTimeout(c), this.eventWaiters.delete(s);
2469
- const d = this.getSession();
2470
- r(
2471
- !this.destroyed && e === this.generation && i === this.sessionId && d.interactionSessionId === i ? l : null
2472
- );
2473
- }, s = () => o(null), c = window.setTimeout(s, ci);
2474
- this.eventWaiters.add(s), t.then(o, s);
2475
- });
2476
- }
2477
- delay(t, e) {
2478
- return new Promise((i) => {
2479
- if (e.aborted) {
2480
- i(!1);
2481
- return;
2482
- }
2483
- const r = () => n(!1), n = (s) => {
2484
- window.clearTimeout(o), e.removeEventListener("abort", r), i(s);
2485
- }, o = window.setTimeout(() => n(!0), t);
2486
- e.addEventListener("abort", r, { once: !0 });
2487
- });
2488
- }
2489
- resetGeneration(t) {
2490
- this.cancelGeneration(), this.generation += 1, this.sessionId = t.interactionSessionId, this.accessToken = t.accessToken, this.runtimeId = this.safeCreateId(), this.nextSequence = 1, this.latestFenceRevision = 0, this.lastStartedAt = Number.NEGATIVE_INFINITY, this.cooldownUntil = 0, this.lastCollectedProjection = null, this.acknowledged = null, this.recovery = null, this.awaitingRenewalToken = null, this.currentProjectionUncertain = !1, this.suppressedProjectionKey = null;
2491
- }
2492
- safeCreateId() {
2493
- try {
2494
- const t = this.createId();
2495
- if (ut.test(t)) return t;
2496
- g.debug("Client Environment UUID generation returned an invalid ID");
2497
- } catch (t) {
2498
- g.debug("Client Environment UUID generation failed", t);
2499
- }
2500
- return null;
2501
- }
2502
- cancelGeneration() {
2503
- this.pumpTimer !== void 0 && (window.clearTimeout(this.pumpTimer), this.pumpTimer = void 0), this.active?.controller?.abort(), this.active?.deferred.resolve(null), this.pending?.deferred.resolve(null), this.active = null, this.pending = null;
2504
- for (const t of [...this.eventWaiters]) t(null);
2505
- this.eventWaiters.clear();
2506
- }
2507
- }
2508
- const yi = [
2509
- "deposit",
2510
- "excited",
2511
- "fix_hair",
2512
- "kiss",
2513
- "spin",
2514
- "win_small"
2515
- ];
2516
- function Pi(a) {
2517
- return yi.includes(a);
2518
- }
2519
- const ki = [
2520
- "ru",
2521
- "uz",
2522
- "en",
2523
- "it",
2524
- "es",
2525
- "de",
2526
- "fr",
2527
- "pl",
2528
- "pt",
2529
- "bn",
2530
- "sw",
2531
- "so",
2532
- "ar"
2533
- ], Ei = new Set(ki), Si = /^(?:(?:[a-z]{2,3}(?:-[a-z]{3}){0,3}|[a-z]{4}|[a-z]{5,8})(?:-[a-z]{4})?(?:-(?:[a-z]{2}|[0-9]{3}))?(?:-(?:[a-z0-9]{5,8}|[0-9][a-z0-9]{3}))*(?:-[0-9a-wy-z](?:-[a-z0-9]{2,8})+)*(?:-x(?:-[a-z0-9]{1,8})+)?|x(?:-[a-z0-9]{1,8})+)$/i;
2534
- function Di(a) {
2535
- const t = a?.trim().replace(/_/g, "-");
2536
- if (!t || !Si.test(t)) return "en";
2537
- const e = t.split("-", 1)[0].toLowerCase();
2538
- return Ei.has(e) ? e : "en";
2539
- }
2540
- const M = (a) => !!a && typeof a == "object" && !Array.isArray(a), _i = (a) => typeof a == "string" && a.trim() ? a : void 0, Ii = (a) => {
2541
- if (!M(a)) return null;
2542
- const t = _i(a.conversationId), e = a.actor;
2543
- return !t || e !== "ASSISTANT" && e !== "ADMIN" || typeof a.active != "boolean" ? null : {
2544
- conversationId: t,
2545
- actor: e,
2546
- active: a.active
2547
- };
2548
- }, Li = (a) => {
2549
- const t = M(a) && M(a.event) ? a.event : {};
2550
- return {
2551
- typing: Ii(t.messageTyping)
2552
- };
2553
- }, Ti = (a) => a.startsWith("image/") ? "image" : "document", Ai = (a) => {
2554
- try {
2555
- return URL.createObjectURL(a);
2556
- } catch {
2557
- return `mock://attachment/${encodeURIComponent(a.name)}`;
2558
- }
2559
- }, Ui = () => ({
2560
- async upload({ file: a, signal: t, onProgress: e, onStage: i }) {
2561
- if (t?.aborted) throw new DOMException("Upload aborted", "AbortError");
2562
- if (i?.("preparing"), e?.(0), await Promise.resolve(), t?.aborted) throw new DOMException("Upload aborted", "AbortError");
2563
- i?.("uploading"), e?.(1), i?.("scanning");
2564
- const r = Ai(a);
2565
- return {
2566
- id: crypto.randomUUID(),
2567
- fileName: a.name,
2568
- mediaType: a.type || "application/octet-stream",
2569
- size: a.size,
2570
- kind: Ti(a.type || "application/octet-stream"),
2571
- downloadUrl: r,
2572
- ...a.type.startsWith("image/") ? { previewUrl: r } : {}
2573
- };
2574
- }
2575
- }), st = de, ct = 3e4, Ri = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/, lt = (a) => {
2576
- g.error("Session renewal callback failed", a);
2577
- };
2578
- class Hi extends EventTarget {
2579
- root = null;
2580
- hostElement;
2581
- shadowRoot;
2582
- config;
2583
- setOpenImpl = null;
2584
- pendingOpenState = null;
2585
- playAnimationImpl = null;
2586
- avatarLoadError = null;
2587
- avatarLoadGeneration = 0;
2588
- pendingAvatarAnimations = /* @__PURE__ */ new Set();
2589
- destroyed = !1;
2590
- disableDebugLogging = null;
2591
- resolveAssetPath;
2592
- setSessionImpl = null;
2593
- setLocaleImpl = null;
2594
- commandRuntime;
2595
- clientEnvironmentRuntime;
2596
- eventTracker;
2597
- scenarioInteractionRuntime;
2598
- onSessionExpired = $t(
2599
- () => {
2600
- this.destroyed || this.runRenewSessionCallback();
2601
- },
2602
- H,
2603
- { leading: !0, maxWait: H }
2604
- );
2605
- runRenewSessionCallback() {
2606
- try {
2607
- Promise.resolve(this.config.onRenewSession?.()).catch(
2608
- lt
2609
- );
2610
- } catch (t) {
2611
- lt(t);
2612
- }
2613
- }
2614
- addEventListener(t, e, i) {
2615
- super.addEventListener(t, e, i);
2616
- }
2617
- constructor(t) {
2618
- if (super(), this.validateCustomerInteractionSession(t.customerInteractionSession), this.config = t, this.clientEnvironmentRuntime = new xi(
2619
- () => this.config.customerInteractionSession,
2620
- this.onSessionExpired
2621
- ), this.eventTracker = new he(
2622
- () => this.config.customerInteractionSession,
2623
- this.onSessionExpired,
2624
- this.clientEnvironmentRuntime
2625
- ), this.scenarioInteractionRuntime = new We(
2626
- () => this.config.customerInteractionSession,
2627
- this.onSessionExpired
2628
- ), this.commandRuntime = new ce(
2629
- {},
2630
- t.handlers,
2631
- this.onCommandStatus,
2632
- this.scenarioInteractionRuntime
2633
- ), !document.body)
2634
- throw new Error("ChatWidget: document.body is not available");
2635
- this.hostElement = document.createElement("div"), this.hostElement.dataset.lolaWidgetHost = "", document.body.appendChild(this.hostElement), this.shadowRoot = this.hostElement.attachShadow({ mode: "open" }), this.injectStyles(this.shadowRoot);
2636
- const e = document.createElement("div");
2637
- this.shadowRoot.appendChild(e), this.disableDebugLogging = t.debug ? g.enableDebug() : null;
2638
- const i = this.init(e, t);
2639
- Promise.resolve().then(() => {
2640
- this.destroyed || this.clientEnvironmentRuntime.start();
2641
- }).catch((r) => {
2642
- g.debug("Client Environment startup failed", r);
2643
- }), i.catch((r) => {
2644
- this.destroyed || g.error("Initialization failed", r);
2645
- });
2646
- }
2647
- async init(t, e) {
2648
- const [i, { mountWidget: r }] = await Promise.all([
2649
- fetch(`${st}/manifest.json`),
2650
- import("./mount-DCjHLj_e.js").then((s) => s._)
2651
- ]);
2652
- if (!i.ok)
2653
- throw new Error(
2654
- `Asset manifest request failed: ${i.status} ${i.statusText}`
2655
- );
2656
- const n = await i.json();
2657
- this.resolveAssetPath = (s) => `${st}/${n[s]}`, this.config = e, this.scenarioInteractionRuntime.start();
2658
- const o = {
2659
- onAvatarLoadStarted: this.onAvatarLoadStarted,
2660
- onAvatarReady: this.onAvatarReady,
2661
- onAvatarLoadFailed: this.onAvatarLoadFailed,
2662
- playAvatarAnimation: this.playAvatarAnimation,
2663
- onSessionExpired: this.onSessionExpired,
2664
- registerSetOpen: (s) => {
2665
- this.setOpenImpl = s, s && this.pendingOpenState !== null && (s(this.pendingOpenState), this.pendingOpenState = null);
2666
- },
2667
- resolveAssetPath: this.resolveAssetPath,
2668
- registerSetSession: (s) => {
2669
- this.setSessionImpl = s;
2670
- },
2671
- registerSetLocale: (s) => {
2672
- this.setLocaleImpl = s;
2673
- },
2674
- commandRuntime: this.commandRuntime,
2675
- scenarioInteractionRuntime: this.scenarioInteractionRuntime
2676
- };
2677
- this.destroyed || (this.root = r(t, this.config, o));
2678
- }
2679
- onAvatarReady = (t) => {
2680
- if (!this.destroyed) {
2681
- this.avatarLoadError = null, this.playAnimationImpl = t;
2682
- for (const e of this.pendingAvatarAnimations) {
2683
- if (window.clearTimeout(e.timeoutId), e.expiresAtMs !== void 0 && e.expiresAtMs <= Date.now()) {
2684
- e.reject(new h("COMMAND_EXPIRED", "expired"));
2685
- continue;
2686
- }
2687
- try {
2688
- Promise.resolve(t(e.name)).then(
2689
- e.resolve,
2690
- e.reject
2691
- );
2692
- } catch (i) {
2693
- e.reject(
2694
- i instanceof Error ? i : new Error("Animation playback failed")
2695
- );
2696
- }
2697
- }
2698
- this.pendingAvatarAnimations.clear();
2699
- }
2700
- };
2701
- onAvatarLoadStarted = () => {
2702
- const t = ++this.avatarLoadGeneration;
2703
- return this.playAnimationImpl = null, this.avatarLoadError = null, {
2704
- onAvatarReady: (e) => {
2705
- t === this.avatarLoadGeneration && this.onAvatarReady(e);
2706
- },
2707
- onAvatarLoadFailed: (e) => {
2708
- t === this.avatarLoadGeneration && this.onAvatarLoadFailed(e);
2709
- }
2710
- };
2711
- };
2712
- onAvatarLoadFailed = (t) => {
2713
- if (this.destroyed) return;
2714
- const e = t instanceof Error ? t : new Error("Avatar loading failed");
2715
- this.playAnimationImpl = null, this.avatarLoadError = e;
2716
- for (const i of this.pendingAvatarAnimations)
2717
- window.clearTimeout(i.timeoutId), i.reject(e);
2718
- this.pendingAvatarAnimations.clear(), g.error("Avatar loading failed", e);
2719
- };
2720
- playAvatarAnimation = (t, e) => {
2721
- if (this.destroyed)
2722
- return Promise.reject(new Error("Widget was destroyed"));
2723
- const i = e ? Date.parse(e) : NaN, r = Number.isFinite(i) ? i : void 0;
2724
- if (r !== void 0 && r <= Date.now())
2725
- return Promise.reject(
2726
- new h("COMMAND_EXPIRED", "expired")
2727
- );
2728
- if (this.avatarLoadError) return Promise.reject(this.avatarLoadError);
2729
- if (this.playAnimationImpl)
2730
- try {
2731
- return Promise.resolve(this.playAnimationImpl(t));
2732
- } catch (n) {
2733
- return Promise.reject(
2734
- n instanceof Error ? n : new Error("Animation playback failed")
2735
- );
2736
- }
2737
- return new Promise((n, o) => {
2738
- const s = r !== void 0 ? r - Date.now() : void 0, c = s !== void 0 ? Math.max(0, Math.min(ct, s)) : ct, l = {
2739
- name: t,
2740
- resolve: n,
2741
- reject: o,
2742
- timeoutId: 0,
2743
- expiresAtMs: r
2744
- };
2745
- l.timeoutId = window.setTimeout(() => {
2746
- this.pendingAvatarAnimations.delete(l), o(
2747
- r !== void 0 && r <= Date.now() ? new h("COMMAND_EXPIRED", "expired") : new Error("Avatar readiness timed out")
2748
- );
2749
- }, c), this.pendingAvatarAnimations.add(l);
2750
- });
2751
- };
2752
- onCommandStatus = (t) => {
2753
- this.dispatchEvent(new CustomEvent(`command_${t.status}`, { detail: t }));
2754
- };
2755
- injectStyles(t) {
2756
- const e = document.createElement("style");
2757
- e.textContent = kt, t.appendChild(e);
2758
- }
2759
- validateCustomerInteractionSession(t) {
2760
- if (!t?.accessToken?.trim())
2761
- throw new Error(
2762
- "ChatWidget: customerInteractionSession.accessToken is invalid"
2763
- );
2764
- if (!t.interactionSessionId?.trim())
2765
- throw new Error(
2766
- "ChatWidget: customerInteractionSession.interactionSessionId is invalid"
2767
- );
2768
- if (!Ri.test(t.expiresAt) || !Number.isFinite(Date.parse(t.expiresAt)))
2769
- throw new Error(
2770
- "ChatWidget: customerInteractionSession.expiresAt is invalid"
2771
- );
2772
- }
2773
- //widget api for external use
2774
- setOpen(t) {
2775
- this.setOpenImpl ? this.setOpenImpl(t) : (this.pendingOpenState = t, g.debug(`setOpen(${t}) queued until the widget is initialized`));
2776
- }
2777
- setCustomerInteractionSession(t) {
2778
- this.validateCustomerInteractionSession(t), this.onSessionExpired.cancel(), this.config.customerInteractionSession = t, this.clientEnvironmentRuntime.updateSession(t), this.scenarioInteractionRuntime.updateSession(t), this.commandRuntime.updateSession(t), this.setSessionImpl?.(t);
2779
- }
2780
- setLocale(t) {
2781
- this.config.locale = t, this.setLocaleImpl?.(t);
2782
- }
2783
- track(t) {
2784
- return this.destroyed ? Promise.resolve() : this.eventTracker.track(t);
2785
- }
2786
- destroy() {
2787
- this.destroyed = !0;
2788
- const t = new Error("Widget was destroyed");
2789
- for (const e of this.pendingAvatarAnimations)
2790
- window.clearTimeout(e.timeoutId), e.reject(t);
2791
- this.pendingAvatarAnimations.clear(), this.onSessionExpired.cancel(), this.setOpenImpl = null, this.pendingOpenState = null, this.playAnimationImpl = null, this.setSessionImpl = null, this.setLocaleImpl = null, this.commandRuntime.destroy(), this.eventTracker.destroy(), this.clientEnvironmentRuntime.destroy(), this.scenarioInteractionRuntime.destroy(), this.disableDebugLogging?.(), this.disableDebugLogging = null, this.root?.unmount?.(), this.shadowRoot.innerHTML = "", this.hostElement.remove();
2792
- }
2793
- }
2794
- export {
2795
- Hi as C,
2796
- yi as E,
2797
- j as L,
2798
- Ci as P,
2799
- ki as S,
2800
- Ti as a,
2801
- Di as b,
2802
- Pi as c,
2803
- Ui as d,
2804
- Oi as g,
2805
- Ni as i,
2806
- g as l,
2807
- Li as n,
2808
- Fe as o
2809
- };