@webority/chat-react 0.141.0 → 0.142.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 (64) hide show
  1. package/dist/chat-react.js +2 -2
  2. package/dist/types/ChatAgentTyping.d.ts +6 -4
  3. package/dist/types/ChatAuthorBadge.d.ts +6 -4
  4. package/dist/types/ChatComposer.d.ts +12 -7
  5. package/dist/types/ChatConversationActions.d.ts +9 -4
  6. package/dist/types/ChatEmbed.d.ts +6 -1
  7. package/dist/types/ChatExplain.d.ts +27 -12
  8. package/dist/types/ChatFooter.d.ts +6 -4
  9. package/dist/types/ChatFrame.d.ts +48 -23
  10. package/dist/types/ChatHistory.d.ts +7 -5
  11. package/dist/types/ChatLauncher.d.ts +3 -1
  12. package/dist/types/ChatLiveStatus.d.ts +9 -4
  13. package/dist/types/ChatMessageActions.d.ts +10 -7
  14. package/dist/types/ChatNudge.d.ts +11 -6
  15. package/dist/types/ChatOpenTickets.d.ts +10 -5
  16. package/dist/types/ChatPage.d.ts +40 -43
  17. package/dist/types/ChatPanel.d.ts +8 -5
  18. package/dist/types/ChatPastChats.d.ts +10 -5
  19. package/dist/types/ChatReadAloudButton.d.ts +8 -5
  20. package/dist/types/ChatShell.d.ts +42 -28
  21. package/dist/types/ChatStarters.d.ts +12 -5
  22. package/dist/types/ChatThread.d.ts +24 -12
  23. package/dist/types/chatLive.d.ts +19 -5
  24. package/dist/types/chatPrint.d.ts +7 -1
  25. package/dist/types/chatShared.d.ts +11 -8
  26. package/dist/types/dictationText.d.ts +4 -9
  27. package/dist/types/index.d.ts +21 -1
  28. package/dist/types/loaders/ChatLoader.d.ts +15 -16
  29. package/dist/types/loaders/OrbLoader.d.ts +6 -8
  30. package/dist/types/loaders/PhrasesLoader.d.ts +8 -10
  31. package/dist/types/loaders/SkeletonLoader.d.ts +6 -8
  32. package/dist/types/loaders/StepsLoader.d.ts +6 -8
  33. package/dist/types/loaders/TypingPill.d.ts +7 -8
  34. package/dist/types/recaptcha.d.ts +11 -1
  35. package/dist/types/renderers/ActionPart.d.ts +8 -4
  36. package/dist/types/renderers/ChartPart.d.ts +8 -4
  37. package/dist/types/renderers/ChatLinkContext.d.ts +5 -4
  38. package/dist/types/renderers/FigureText.d.ts +7 -5
  39. package/dist/types/renderers/FiguresPart.d.ts +8 -4
  40. package/dist/types/renderers/FilePart.d.ts +8 -4
  41. package/dist/types/renderers/HandoffPart.d.ts +8 -4
  42. package/dist/types/renderers/ImagePart.d.ts +8 -4
  43. package/dist/types/renderers/InputRequestPart.d.ts +12 -5
  44. package/dist/types/renderers/NoticePart.d.ts +8 -3
  45. package/dist/types/renderers/QuickRepliesPart.d.ts +11 -4
  46. package/dist/types/renderers/RecordCardPart.d.ts +8 -4
  47. package/dist/types/renderers/SourcesPart.d.ts +8 -4
  48. package/dist/types/renderers/TablePart.d.ts +8 -4
  49. package/dist/types/renderers/TextPart.d.ts +9 -5
  50. package/dist/types/renderers/TicketPart.d.ts +8 -4
  51. package/dist/types/renderers/VoiceClipPart.d.ts +8 -4
  52. package/dist/types/renderers/index.d.ts +35 -30
  53. package/dist/types/useAutoOpen.d.ts +10 -8
  54. package/dist/types/useChat.d.ts +43 -25
  55. package/dist/types/useChatDictation.d.ts +18 -19
  56. package/dist/types/useChatExplain.d.ts +14 -41
  57. package/dist/types/useChatHandoff.d.ts +2 -4
  58. package/dist/types/useChatReadAloud.d.ts +10 -11
  59. package/dist/types/useChatSound.d.ts +2 -1
  60. package/dist/types/useChatSpeech.d.ts +5 -3
  61. package/dist/types/useLauncherAvoid.d.ts +3 -1
  62. package/dist/types/useReducedMotion.d.ts +2 -1
  63. package/dist/types/useTranscriptActions.d.ts +11 -9
  64. package/package.json +22 -19
@@ -1,4 +1,4 @@
1
- import{AppBadge as e,AppButton as t,AppChart as n,AppDataTable as r,AppDescriptions as i,AppIcon as a,AppLightbox as o,AppMarkdown as s,AppMetricStrip as c,AppPopover as l,AppSkeleton as u,AppTooltip as d}from"@webority/ui-react";import{Fragment as f,cloneElement as p,createContext as m,useCallback as h,useContext as g,useEffect as _,useId as v,useLayoutEffect as y,useMemo as b,useRef as x,useState as S,useSyncExternalStore as C}from"react";import{CHAT_HANDOFF_REQUEST_ID as w,LOADER_STYLES as T,buildTranscript as E,createChatSession as D,createConversationList as O,createDictation as k,createExplain as A,createTurnApi as j,emptyFeatures as M,formatChatDate as N,formatChatDay as P,formatChatValue as F,formatClipTime as I,formatFigure as L,formatFileSize as ee,isHandoffTarget as te,loaderView as R,mergeLabels as ne,mergeLook as re,messagePlainText as z,resolveNudge as ie,showsCaptchaNote as ae,toFigureRuns as oe,toFigureText as B,transcriptToText as V,voiceClipBars as H}from"@webority/chat-core";import{createAvoidance as U,createBehaviourCollector as se,createSound as ce,createWebSpeech as le,fitToViewport as ue,growFromButton as de,lockPageScroll as fe,returnFocus as pe,switchPanel as me,trapTab as he,vibrate as ge,watchAutoOpen as _e,watchReducedMotion as ve}from"@webority/chat-elements/web";import{Fragment as W,jsx as G,jsxs as K}from"react/jsx-runtime";import{parseInline as ye}from"@webority/markdown-core";import{EMPTY_VALUE as be,formatDate as q,formatDateTime as xe,formatNumber as Se}from"@webority/ui-elements/helpers";function Ce({value:e,span:t,selectionStart:n,selectionEnd:r,text:i,maxLength:a}){let o=t?t.start:n,s=t?t.end:r,c=!t&&o>0&&e.charAt(o-1).trim()!==``?` `:``,l=a-(e.length-(s-o))-c.length,u=i.slice(0,Math.max(0,l)),d=o+c.length,f=d+u.length;return{value:e.slice(0,o)+c+u+e.slice(s),span:{start:d,end:f},caret:f}}var we=8e3,Te=Object.freeze({status:`Idle`}),Ee=()=>()=>void 0,De=()=>Te,Oe=/* @__PURE__ */ new Set([`Blocked`,`NotHeard`,`Failed`,`NoMicrophone`,`Unavailable`]),ke=/* @__PURE__ */ new Set([`Blocked`,`NoMicrophone`]),Ae={Blocked:`dictationBlocked`,NotHeard:`dictationNotHeard`,Failed:`dictationFailed`,NoMicrophone:`dictationNoMicrophone`,Unavailable:`dictationUnavailable`};function J({speech:e,enabled:t,labels:n,onText:r}){let i=x(null),a=x(r);a.current=r;let[o,s]=S(null);_(()=>{if(!e){s(null);return}let t=k({adapter:e,onText:(e,t)=>a.current(e,t),onLevel:e=>i.current?.style.setProperty(`--wui-chat-mic-level`,String(e))});return s({speech:e,instance:t}),()=>t.dispose()},[e]);let c=o!==null&&o.speech===e?o.instance:null,l=C(c?c.subscribe:Ee,c?c.getState:De).status,u=l===`Listening`,[d,f]=S(!1);_(()=>{if(!Oe.has(l)){f(!1);return}if(f(!0),ke.has(l))return;let e=setTimeout(()=>f(!1),we);return()=>clearTimeout(e)},[l]),_(()=>{u||i.current?.style.removeProperty(`--wui-chat-mic-level`)},[u]);let p=h(()=>c?.toggle(),[c]),m=h(()=>c?.stop(),[c]),g=Oe.has(l)&&d?l:null,v=g?n[Ae[g]]:null;return{available:!!(t&&e?.dictation),listening:u,note:v,noteKind:g,toggle:p,stop:m,buttonRef:i}}var je=/* @__PURE__ */ new WeakMap;function Me(e){if(!e.profile?.speechAvailable||!e.features.Dictation&&!e.features.ReadAloud)return null;let t=je.get(e.client);return t||(t=le(e.client),je.set(e.client,t)),t}var Y=10,Ne=.9,X=/* @__PURE__ */ new Set([`Shift`,`Control`,`Alt`,`Meta`,`Escape`]);function Pe(e){e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`}function Fe({chat:e,labels:n,maxLength:r,inputRef:i,sendIcon:o=`arrow-up`}){let{features:s}=e,c=v(),l=x(null),u=x(null),d=x(null),f=x(null),[p,m]=S(``),[h,g]=S(null);e.editing&&e.editing.messageId!==h&&(g(e.editing.messageId),m(e.editing.text)),!e.editing&&h!==null&&g(null),_(()=>{let t=e.draft;t&&!e.editing&&(d.current=null,l.current?.value!==t&&(f.current=t.length),m(t),l.current?.focus(),e.session.consumeDraft())},[e.draft,e.editing,e.session]);let b=J({speech:Me(e),enabled:e.features.Dictation,labels:n,onText:C});function C(e){let t=l.current;if(!t)return;let n=Ce({value:t.value,span:d.current,selectionStart:t.selectionStart,selectionEnd:t.selectionEnd,text:e,maxLength:r});d.current=n.span,n.value===t.value?t.setSelectionRange(n.caret,n.caret):(f.current=n.caret,m(n.value))}y(()=>{let e=l.current;f.current!==null&&e&&e.value===p&&(Pe(e),e.setSelectionRange(f.current,f.current),f.current=null)},[p]),_(()=>{e.editing&&b.stop()},[e.editing,b.stop]),_(()=>{e.handoffPause&&b.stop()},[e.handoffPause,b.stop]),_(()=>{b.listening||(d.current=null)},[b.listening]);let w=e.messages.flatMap(e=>e.parts).filter(e=>e.kind===`InputRequest`&&e.state===`Open`).at(-1),T=w?.fields[0],E=e.messagesLeftToday,D=e.profile?.limits,O=e.attachments.some(e=>e.status===`Uploading`),k=e.attachments.some(e=>e.status===`Ready`),A=s.Attachments&&(D?.maxAttachments??0)>0&&!e.handoffPause,j=e.streaming&&s.Stop,M=e.streaming&&!s.Stop||E===0||O||p.trim()===``&&!k||e.handoffPause,N=p.length>r*Ne,P=E!==null&&E<=Y;function F(e){l.current=e,typeof i==`function`?i(e):i&&(i.current=e)}function I(){let t=p.trim();M||t===``&&!k||(b.stop(),d.current=null,e.submit(t),m(``),l.current&&(l.current.style.height=`auto`))}function L(t){let n=Array.from(t.target.files??[]);t.target.value=``,n.length>0&&e.attach(n)}return/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`p`,{className:`wui-chat-allowance`,role:`status`,hidden:!P,children:P?n.allowance(E):``}),/* @__PURE__ */ G(`div`,{className:`wui-chat-editing`,hidden:!e.editing,children:e.editing&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`span`,{children:n.editing}),/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.cancelEdit(),children:n.cancel})]})}),/* @__PURE__ */ G(`div`,{className:`wui-chat-attachments`,hidden:e.attachments.length===0,children:e.attachments.map(t=>/* @__PURE__ */ K(`span`,{className:`wui-chat-chip`,title:t.status===`Failed`?t.error??``:void 0,children:[/* @__PURE__ */ G(`span`,{children:t.fileName}),t.status===`Uploading`&&/* @__PURE__ */ G(`span`,{className:`wui-chat-chip-status`,"aria-live":`polite`,children:n.attachmentUploading}),t.status===`Failed`&&/* @__PURE__ */ G(`span`,{className:`wui-chat-chip-error`,role:`status`,children:t.error||n.attachmentFailed}),/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-chip-remove`,"aria-label":n.removeAttachment(t.fileName),onClick:()=>e.removeAttachment(t.key),children:/* @__PURE__ */ G(a,{name:`x`,size:14,"aria-hidden":`true`})})]},t.key))}),/* @__PURE__ */ K(`form`,{className:p.trim()!==``||k?`wui-chat-composer wui-chat-composer--has-text`:`wui-chat-composer`,"aria-label":n.composer,onSubmit:e=>{e.preventDefault(),I()},children:[A&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-tool`,"aria-label":n.attach,title:n.attachHint,onClick:()=>u.current?.click(),children:/* @__PURE__ */ G(a,{name:`paperclip`,size:18,"aria-hidden":`true`})}),/* @__PURE__ */ G(`input`,{ref:u,type:`file`,multiple:!0,hidden:!0,accept:D.contentTypes.join(`,`),onChange:L})]}),/* @__PURE__ */ G(`textarea`,{ref:F,className:`wui-chat-input`,"aria-label":n.composer,"aria-describedby":c,placeholder:T?.label??w?.title??n.placeholder,rows:1,maxLength:r,value:p,disabled:E===0||e.handoffPause,onChange:t=>{d.current=null,m(t.target.value),Pe(t.target),t.target.value!==``&&e.notifyTyping()},onKeyDown:e=>{b.listening&&e.nativeEvent.isTrusted&&!X.has(e.key)&&b.stop(),e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),I())}}),/* @__PURE__ */ G(`span`,{id:c,className:`visually-hidden`,children:n.composerHint}),/* @__PURE__ */ G(`span`,{className:`wui-chat-counter`,hidden:!N,children:N?n.counter(p.length,r):``}),b.available&&/* @__PURE__ */ K(`button`,{type:`button`,className:b.listening?`wui-chat-tool wui-chat-mic wui-chat-mic--listening`:`wui-chat-tool wui-chat-mic`,ref:b.buttonRef,"aria-pressed":b.listening,"aria-label":b.listening?n.dictateStop:n.dictate,title:b.listening?n.dictateStop:n.dictate,disabled:E===0||e.handoffPause,onClick:b.toggle,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-ring`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-ring wui-chat-mic-ring--late`,"aria-hidden":`true`}),/* @__PURE__ */ G(a,{name:`microphone`,size:18,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-mic-level`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`})]})]}),/* @__PURE__ */ G(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:b.listening?n.dictateListening:``}),j?/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-send wui-chat-send--stop`,"aria-label":n.stop,onClick:()=>e.stop(),children:/* @__PURE__ */ G(a,{name:`stop`,size:18,"aria-hidden":`true`})}):/* @__PURE__ */ G(`button`,{type:`submit`,className:`wui-chat-send`,"aria-label":n.send,disabled:M,children:/* @__PURE__ */ G(a,{name:o,size:18,"aria-hidden":`true`})})]}),b.note!==null&&/* @__PURE__ */ G(`p`,{className:`wui-chat-dictate-note`,role:b.noteKind===`Blocked`||b.noteKind===`NoMicrophone`?`alert`:`status`,children:b.note})]})}var Ie=6e4,Le=`
1
+ import{AppActionIcon as e,AppBadge as t,AppButton as n,AppChart as r,AppCheckbox as i,AppDataTable as a,AppDescriptions as o,AppIcon as s,AppInput as c,AppLightbox as l,AppMarkdown as u,AppMetricStrip as d,AppPopover as f,AppRadio as p,AppSkeleton as m,AppTextarea as h,AppTooltip as g}from"@webority/ui-react";import{Fragment as _,cloneElement as v,createContext as y,createElement as b,useCallback as x,useContext as S,useEffect as C,useId as w,useLayoutEffect as T,useMemo as E,useRef as D,useState as O,useSyncExternalStore as k}from"react";import{CHAT_FEATURES as A,CHAT_HANDOFF_REQUEST_ID as j,IDLE_CHAT_SESSION as M,LOADER_STYLES as N,buildTranscript as P,createChatSession as F,createConversationList as I,createDictation as L,createExplain as ee,createTurnApi as te,formatChatDate as R,formatChatDay as z,formatChatValue as ne,formatClipTime as re,formatFigure as ie,formatFileSize as B,isHandoffTarget as V,loaderView as H,mergeLabels as ae,mergeLook as oe,messagePlainText as U,resolveNudge as se,showsCaptchaNote as ce,toFigureRuns as le,toFigureText as ue,transcriptToText as de,voiceClipBars as fe}from"@webority/chat-core";import{createAvoidance as pe,createBehaviourCollector as me,createSound as he,createWebSpeech as ge,fitToViewport as _e,growFromButton as ve,lockPageScroll as ye,returnFocus as be,switchPanel as xe,trapTab as Se,vibrate as Ce,watchAutoOpen as we,watchReducedMotion as Te}from"@webority/chat-elements/web";import{Fragment as W,jsx as G,jsxs as K}from"react/jsx-runtime";import{parseInline as Ee}from"@webority/markdown-core";import{EMPTY_VALUE as De,formatDate as Oe,formatDateTime as ke,formatNumber as Ae}from"@webority/ui-elements/helpers";function je({value:e,span:t,selectionStart:n,selectionEnd:r,text:i,maxLength:a}){let o=t?t.start:n,s=t?t.end:r,c=!t&&o>0&&e.charAt(o-1).trim()!==``?` `:``,l=a-(e.length-(s-o))-c.length,u=i.slice(0,Math.max(0,l)),d=o+c.length,f=d+u.length;return{value:e.slice(0,o)+c+u+e.slice(s),span:{start:d,end:f},caret:f}}var q=8e3,Me=Object.freeze({status:`Idle`}),Ne=()=>()=>void 0,J=()=>Me,Pe=/* @__PURE__ */ new Set([`Blocked`,`NotHeard`,`Failed`,`NoMicrophone`,`Unavailable`]),Fe=/* @__PURE__ */ new Set([`Blocked`,`NoMicrophone`]),Ie={Blocked:`dictationBlocked`,NotHeard:`dictationNotHeard`,Failed:`dictationFailed`,NoMicrophone:`dictationNoMicrophone`,Unavailable:`dictationUnavailable`};function Le(e){return Pe.has(e)}function Re({speech:e,enabled:t,labels:n,onText:r}){let i=D(null),a=D(r);a.current=r;let[o,s]=O(null);C(()=>{if(!e){s(null);return}let t=L({adapter:e,onText:(e,t)=>a.current(e,t),onLevel:e=>i.current?.style.setProperty(`--wui-chat-mic-level`,String(e))});return s({speech:e,instance:t}),()=>t.dispose()},[e]);let c=o!==null&&o.speech===e?o.instance:null,l=k(c?c.subscribe:Ne,c?c.getState:J).status,u=l===`Listening`,[d,f]=O(!1);C(()=>{if(!Pe.has(l)){f(!1);return}if(f(!0),Fe.has(l))return;let e=setTimeout(()=>f(!1),q);return()=>clearTimeout(e)},[l]),C(()=>{u||i.current?.style.removeProperty(`--wui-chat-mic-level`)},[u]);let p=x(()=>c?.toggle(),[c]),m=x(()=>c?.stop(),[c]),h=Le(l)&&d?l:null,g=h?n[Ie[h]]:null;return{available:!!(t&&e?.dictation),listening:u,note:g,noteKind:h,toggle:p,stop:m,buttonRef:i}}var ze=/* @__PURE__ */ new WeakMap;function Be(e){if(!e.profile?.speechAvailable||!e.features.Dictation&&!e.features.ReadAloud)return null;let t=ze.get(e.client);return t||(t=ge(e.client),ze.set(e.client,t)),t}var Ve=10,He=.9,Ue=/* @__PURE__ */ new Set([`Shift`,`Control`,`Alt`,`Meta`,`Escape`]);function We(e){e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`}function Ge({chat:e,labels:t,maxLength:r,inputRef:i,sendIcon:a=`arrow-up`}){let{features:o}=e,c=w(),l=D(null),u=D(null),d=D(null),f=D(null),[p,m]=O(``),[h,g]=O(null);e.editing&&e.editing.messageId!==h&&(g(e.editing.messageId),m(e.editing.text)),!e.editing&&h!==null&&g(null),C(()=>{let t=e.draft;t&&!e.editing&&(d.current=null,l.current?.value!==t&&(f.current=t.length),m(t),l.current?.focus(),e.session.consumeDraft())},[e.draft,e.editing,e.session]);let _=Re({speech:Be(e),enabled:e.features.Dictation,labels:t,onText:v});function v(e){let t=l.current;if(!t)return;let n=je({value:t.value,span:d.current,selectionStart:t.selectionStart,selectionEnd:t.selectionEnd,text:e,maxLength:r});d.current=n.span,n.value===t.value?t.setSelectionRange(n.caret,n.caret):(f.current=n.caret,m(n.value))}T(()=>{let e=l.current;f.current!==null&&e&&e.value===p&&(We(e),e.setSelectionRange(f.current,f.current),f.current=null)},[p]),C(()=>{e.editing&&_.stop()},[e.editing,_.stop]),C(()=>{e.handoffPause&&_.stop()},[e.handoffPause,_.stop]),C(()=>{_.listening||(d.current=null)},[_.listening]);let y=e.messages.flatMap(e=>e.parts).filter(e=>e.kind===`InputRequest`&&e.state===`Open`).at(-1),b=y?.fields[0],x=e.messagesLeftToday,S=e.profile?.limits,E=e.attachments.some(e=>e.status===`Uploading`),k=e.attachments.some(e=>e.status===`Ready`),A=o.Attachments&&(S?.maxAttachments??0)>0&&!e.handoffPause,j=e.streaming&&o.Stop,M=e.streaming&&!o.Stop||x===0||E||p.trim()===``&&!k||e.handoffPause,N=p.length>r*He,P=x!==null&&x<=Ve;function F(e){l.current=e,typeof i==`function`?i(e):i&&(i.current=e)}function I(){let t=p.trim();M||t===``&&!k||(_.stop(),d.current=null,e.submit(t).catch(e=>globalThis.reportError?.(e)),m(``),l.current&&(l.current.style.height=`auto`))}function L(t){let n=Array.from(t.target.files??[]);t.target.value=``,n.length>0&&e.attach(n).catch(e=>globalThis.reportError?.(e))}return/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`p`,{className:`wui-chat-allowance`,role:`status`,hidden:!P,children:P?t.allowance(x):``}),/* @__PURE__ */ G(`div`,{className:`wui-chat-editing`,hidden:!e.editing,children:e.editing&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`span`,{children:t.editing}),/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.cancelEdit(),children:t.cancel})]})}),/* @__PURE__ */ G(`div`,{className:`wui-chat-attachments`,hidden:e.attachments.length===0,children:e.attachments.map(n=>/* @__PURE__ */ K(`span`,{className:`wui-chat-chip`,title:n.status===`Failed`?n.error??``:void 0,children:[/* @__PURE__ */ G(`span`,{children:n.fileName}),n.status===`Uploading`&&/* @__PURE__ */ G(`span`,{className:`wui-chat-chip-status`,"aria-live":`polite`,children:t.attachmentUploading}),n.status===`Failed`&&/* @__PURE__ */ G(`span`,{className:`wui-chat-chip-error`,role:`status`,children:n.error||t.attachmentFailed}),/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-chip-remove`,"aria-label":t.removeAttachment(n.fileName),onClick:()=>e.removeAttachment(n.key).catch(e=>globalThis.reportError?.(e)),children:/* @__PURE__ */ G(s,{name:`x`,size:14,"aria-hidden":`true`})})]},n.key))}),/* @__PURE__ */ K(`form`,{className:p.trim()!==``||k?`wui-chat-composer wui-chat-composer--has-text`:`wui-chat-composer`,"aria-label":t.composer,onSubmit:e=>{e.preventDefault(),I()},children:[A&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-tool`,"aria-label":t.attach,title:t.attachHint,onClick:()=>u.current?.click(),children:/* @__PURE__ */ G(s,{name:`paperclip`,size:18,"aria-hidden":`true`})}),/* @__PURE__ */ G(`input`,{ref:u,type:`file`,multiple:!0,hidden:!0,accept:S?.contentTypes.join(`,`),onChange:L})]}),/* @__PURE__ */ G(`textarea`,{ref:F,className:`wui-chat-input`,"aria-label":t.composer,"aria-describedby":c,placeholder:b?.label??y?.title??t.placeholder,rows:1,maxLength:r,value:p,disabled:x===0||e.handoffPause,onChange:t=>{d.current=null,m(t.target.value),We(t.target),t.target.value!==``&&e.notifyTyping()},onKeyDown:e=>{_.listening&&e.nativeEvent.isTrusted&&!Ue.has(e.key)&&_.stop(),e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),I())}}),/* @__PURE__ */ G(`span`,{id:c,className:`visually-hidden`,children:t.composerHint}),/* @__PURE__ */ G(`span`,{className:`wui-chat-counter`,hidden:!N,children:N?t.counter(p.length,r):``}),_.available&&/* @__PURE__ */ K(`button`,{type:`button`,className:_.listening?`wui-chat-tool wui-chat-mic wui-chat-mic--listening`:`wui-chat-tool wui-chat-mic`,ref:_.buttonRef,"aria-pressed":_.listening,"aria-label":_.listening?t.dictateStop:t.dictate,title:_.listening?t.dictateStop:t.dictate,disabled:x===0||e.handoffPause,onClick:_.toggle,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-ring`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-ring wui-chat-mic-ring--late`,"aria-hidden":`true`}),/* @__PURE__ */ G(s,{name:`microphone`,size:18,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-mic-level`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-mic-bar`})]})]}),/* @__PURE__ */ G(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:_.listening?t.dictateListening:``}),j?/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-send wui-chat-send--stop`,"aria-label":t.stop,onClick:()=>e.stop(),children:/* @__PURE__ */ G(s,{name:`stop`,size:18,"aria-hidden":`true`})}):/* @__PURE__ */ G(`button`,{type:`submit`,className:`wui-chat-send`,"aria-label":t.send,disabled:M,children:/* @__PURE__ */ G(s,{name:a,size:18,"aria-hidden":`true`})})]}),_.note!==null&&/* @__PURE__ */ G(`p`,{className:`wui-chat-dictate-note`,role:_.noteKind===`Blocked`||_.noteKind===`NoMicrophone`?`alert`:`status`,children:_.note})]})}var Ke=6e4,qe=`
2
2
  @page { margin: 16mm }
3
3
  body { font-family: system-ui, sans-serif; font-size: 11pt; line-height: 1.5; color: CanvasText; background: Canvas }
4
4
  h1 { font-size: 18pt; margin: 0 0 4pt }
@@ -11,4 +11,4 @@ table { border-collapse: collapse; margin: 0 0 6pt; max-width: 100% }
11
11
  caption { text-align: left; font-weight: 600 }
12
12
  th, td { border: 1px solid currentColor; padding: 2pt 6pt; text-align: left; vertical-align: top }
13
13
  thead { display: table-header-group }
14
- `;function Z(e,t,n){let r=e.createElement(t);return n!==void 0&&(r.textContent=n),r}function Re(e,t){if(t.kind===`paragraph`)return Z(e,`p`,t.text);if(t.kind===`list`){let n=Z(e,t.ordered?`ol`:`ul`);for(let r of t.items)n.append(Z(e,`li`,r));return n}let n=Z(e,`table`);if(t.title!==null&&n.append(Z(e,`caption`,t.title)),t.head.length>0){let r=Z(e,`thead`),i=Z(e,`tr`);for(let n of t.head)i.append(Z(e,`th`,n));r.append(i),n.append(r)}let r=Z(e,`tbody`);for(let n of t.rows){let t=Z(e,`tr`);for(let r of n)t.append(Z(e,`td`,r));r.append(t)}return n.append(r),n}function ze(e,t){if(typeof e.CSSStyleSheet==`function`&&`adoptedStyleSheets`in t){let n=new e.CSSStyleSheet;n.replaceSync(Le),t.adoptedStyleSheets=[n];return}let n=Z(t,`style`,Le);t.head.append(n)}function Be(e,t={}){let n=t.lang||document.documentElement.lang||`en`,r=document.createElement(`iframe`);r.title=`Print`,r.setAttribute(`aria-hidden`,`true`),r.tabIndex=-1;let i=r.style;i.position=`fixed`,i.right=`0`,i.bottom=`0`,i.width=`0`,i.height=`0`,i.border=`0`,document.body.append(r);let a=r.contentWindow,o=r.contentDocument;if(!a||!o)return r.remove(),!1;o.open(),o.write(`<!doctype html><title></title>`),o.close(),o.title=e.title,o.documentElement.lang=n,ze(a,o),o.body.append(Z(o,`h1`,e.title));let s=t.printedOn??e.dateText;if(s!=null){let e=Z(o,`p`,s);e.className=`date`,o.body.append(e)}for(let t of e.entries){let e=Z(o,`section`);e.append(Z(o,`h2`,t.speaker));for(let n of t.blocks)e.append(Re(o,n));o.body.append(e)}let c=()=>{r.isConnected&&r.remove(),clearTimeout(l)};a.addEventListener(`afterprint`,c);let l=setTimeout(c,Ie);return a.focus(),a.print(),!0}var Ve=3e3;function He(e,t){let[n,r]=S(null),i=x(null),a=x(!1);_(()=>(a.current=!0,()=>{a.current=!1,clearTimeout(i.current)}),[]);function o(e){a.current&&(clearTimeout(i.current),r(e),i.current=setTimeout(()=>r(null),Ve))}let s={labels:t,title:e.title,figureText:e.features.FigureText,assistantName:e.profile?.assistant.name},c=e.features.Share&&typeof navigator<`u`&&typeof navigator.share==`function`,l=e.features.Print&&typeof document<`u`;async function u(e,n){let r=E(e,s);if(r.entries.length===0)return;let i={title:r.title,text:V(r,{heading:n,speakers:n})};if(typeof navigator.canShare==`function`&&!navigator.canShare(i))o(t.shareFailed);else try{await navigator.share(i)}catch(e){e?.name!==`AbortError`&&o(t.shareFailed)}}function d(e){let n=E(e,s);n.entries.length!==0&&(Be(n,{printedOn:t.printedOn(N((/* @__PURE__ */ new Date()).toISOString()))})||o(t.printFailed))}return{canShare:c,canPrint:l,notice:n,shareReply:e=>u([e],!1),printReply:e=>d([e]),shareConversation:()=>u(e.messages,!0),printConversation:()=>d(e.messages)}}function Ue({chat:e,labels:t}){let n=He(e,t),r=e.streaming||e.thinking,i=e.messages.some(e=>e.stored&&(e.author.kind===`Assistant`||e.author.kind===`Agent`||e.author.kind===`Script`)&&z(e.parts)!==``);return r||e.loading||e.conversationId===null||!i||!n.canShare&&!n.canPrint?null:/* @__PURE__ */ K(W,{children:[n.canShare&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.shareConversation,title:t.shareConversation,onClick:()=>n.shareConversation(),children:/* @__PURE__ */ G(a,{name:`share`,size:18,"aria-hidden":`true`})}),n.canPrint&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.printConversation,title:t.printConversation,onClick:()=>n.printConversation(),children:/* @__PURE__ */ G(a,{name:`printer`,size:18,"aria-hidden":`true`})}),n.notice!==null&&/* @__PURE__ */ G(`span`,{className:`wui-chat-action-notice`,role:`status`,children:n.notice})]})}function We({chat:e,labels:t}){let n=e.profile;if(!n)return null;let r=n.footer.disclaimer||t.disclaimer,i=n.footer.privacyText,a=n.footer.privacyUrl,o=n.footer.assuranceText,s=ae(n);return!r&&!i&&!a&&!o&&!s?null:/* @__PURE__ */ K(`p`,{className:`wui-chat-footer`,children:[r&&/* @__PURE__ */ G(`span`,{className:`wui-chat-footer-text`,children:r}),(i||a)&&/* @__PURE__ */ K(`span`,{className:`wui-chat-footer-privacy`,children:[i,i&&a&&` `,a&&/* @__PURE__ */ G(`a`,{className:`wui-chat-footer-link`,href:a,children:t.footerPrivacy})]}),o&&/* @__PURE__ */ G(`span`,{className:`wui-chat-footer-text`,children:o}),s&&/* @__PURE__ */ K(`span`,{className:`wui-chat-footer-captcha`,children:[t.captchaNote,` `,/* @__PURE__ */ G(`a`,{className:`wui-chat-footer-link`,href:`https://policies.google.com/privacy`,target:`_blank`,rel:`noopener noreferrer`,children:t.captchaPrivacy}),` `,/* @__PURE__ */ G(`a`,{className:`wui-chat-footer-link`,href:`https://policies.google.com/terms`,target:`_blank`,rel:`noopener noreferrer`,children:t.captchaTerms})]})]})}var Ge=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),Ke=()=>()=>{};function qe({chat:e,labels:n,onOpen:r}){let[i,o]=S(null),s=i!==null&&i.client===e.client?i.list:null,c=h(e=>s?s.subscribe(e):Ke(),[s]),l=h(()=>s?s.getState():Ge,[s]),u=C(c,l),[d,f]=S(null),[p,m]=S(``),[g,v]=S(!1),[y,b]=S(null),[w,T]=S(!1),E=x(null),D=x(!1),[k,A]=S(!1);_(()=>{let t=O({client:e.client});return o({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client]),_(()=>{d!==null&&E.current?.focus()},[d]);function j(e){f(e.publicId),m(e.title||``),v(!1)}async function M(e){if(!(D.current||p.trim()===``)){D.current=!0,A(!0);try{await s.rename(e,p),f(null)}catch{v(!0)}finally{D.current=!1,A(!1)}}}async function P(t){if(!D.current){D.current=!0,A(!0);try{await s.remove(t),b(null),T(!1),t===e.conversationId&&e.newConversation()}catch{T(!0)}finally{D.current=!1,A(!1)}}}let F=!u.loading&&u.error===null&&u.totalCount!==null&&u.items.length===0;return/* @__PURE__ */ K(`div`,{className:`wui-chat-history`,children:[u.error&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-error`,role:`alert`,children:[n.loadFailed,` `,/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>s.load(),children:n.retry})]}),u.loading&&u.items.length===0&&/* @__PURE__ */ G(`p`,{className:`wui-chat-history-empty`,role:`status`,children:n.loadingConversation}),F&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-empty`,children:[/* @__PURE__ */ G(`span`,{children:n.historyEmptyTitle}),` `,/* @__PURE__ */ G(`span`,{children:n.historyEmptyText})]}),u.items.length>0&&/* @__PURE__ */ G(`ul`,{className:`wui-chat-history-list`,"aria-label":n.history,children:u.items.map(i=>d===i.publicId?/* @__PURE__ */ K(`li`,{className:`wui-chat-history-row wui-chat-history-row--editing`,children:[/* @__PURE__ */ G(`input`,{ref:E,className:`wui-chat-history-input`,"aria-label":n.conversationTitle,maxLength:120,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&M(i.publicId),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f(null))}}),/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,disabled:k||p.trim()===``,onClick:()=>M(i.publicId),children:n.renameSave}),/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>f(null),children:n.cancel}),g&&/* @__PURE__ */ G(`p`,{className:`wui-chat-history-error`,role:`alert`,children:n.renameFailed})]},i.publicId):y===i.publicId?/* @__PURE__ */ K(`li`,{className:`wui-chat-history-row wui-chat-history-row--confirm`,children:[/* @__PURE__ */ G(`p`,{children:n.deleteConfirmTitle}),/* @__PURE__ */ G(`p`,{children:n.deleteConfirmMessage}),/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,tone:`danger`,disabled:k,onClick:()=>P(i.publicId),children:n.deleteConfirm}),/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>b(null),children:n.cancel}),w&&/* @__PURE__ */ G(`p`,{className:`wui-chat-history-error`,role:`alert`,children:n.deleteFailed})]},i.publicId):/* @__PURE__ */ K(`li`,{className:`wui-chat-history-row`,children:[/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-history-open`,onClick:()=>{e.openConversation(i.publicId),r()},children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-history-title`,children:i.title||n.untitled}),/* @__PURE__ */ G(`span`,{className:`wui-chat-history-time`,children:N(i.lastActivityDateTimeUtc)})]}),e.features.Rename&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":n.rename,title:n.rename,onClick:()=>j(i),children:/* @__PURE__ */ G(a,{name:`pencil`,size:18,"aria-hidden":`true`})}),e.features.Delete&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":n.deleteChat,title:n.deleteChat,onClick:()=>{T(!1),b(i.publicId)},children:/* @__PURE__ */ G(a,{name:`trash`,size:18,"aria-hidden":`true`})})]},i.publicId))}),!u.loading&&u.hasMore&&/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`soft`,onClick:()=>s.loadMore(),children:n.loadMore})]})}var Je=/* @__PURE__ */ new Map([[`Open`,`info`],[`InProgress`,`info`],[`WaitingOnCustomer`,`warning`],[`Resolved`,`success`]]);function Ye(e){let t=(e??``).trim().split(/\s+/).filter(Boolean);if(t.length===0)return`?`;let n=Array.from(t[0])[0];return t.length===1?n.toUpperCase():`${n}${Array.from(t.at(-1))[0]}`.toUpperCase()}function Xe(e){return Je.get(e)??`neutral`}function Ze(e){for(let t=e.length-1;t>=0;--t){let{author:n}=e[t];if(n.kind===`Agent`&&typeof n.displayName==`string`&&n.displayName.trim()!==``)return n.displayName}return null}function Qe(e,t){return e.conversationState===`WaitingForAgent`?t.statusWaitingForAgent:e.conversationState===`WithAgent`?t.statusWithAgent(Ze(e.messages)??t.handoffAgentFallback):null}function $e(e){return e.features.HumanHandoff===!0&&e.conversationState===`Open`&&e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`)&&!e.streaming&&!e.thinking}function et({chat:e,labels:n}){let[r,i]=S(!1),[a,o]=S(null),s=e.live===`Lost`,c=$e(e);if(!c&&!s)return null;async function l(){i(!0),o(null);try{await e.requestHandoff()}catch(e){o(e?.message||n.errorGeneric)}finally{i(!1)}}return/* @__PURE__ */ K(W,{children:[s&&/* @__PURE__ */ K(`p`,{className:`wui-chat-live-status`,role:`status`,children:[n.liveLost,` `,/* @__PURE__ */ G(t,{variant:`ghost`,size:`sm`,onClick:()=>e.session.resumeLive(),children:n.retry})]}),c&&/* @__PURE__ */ K(`div`,{className:`wui-chat-live-actions`,children:[/* @__PURE__ */ G(t,{variant:`outline`,size:`sm`,leftIcon:`user`,className:`wui-chat-handoff-request`,disabled:r,onClick:l,children:n.talkToPerson}),a&&/* @__PURE__ */ G(`p`,{className:`wui-chat-live-error`,role:`alert`,children:a})]})]})}var tt=Object.freeze({state:`idle`,answer:null,pillVisible:!1,resetsDateTimeUtc:null,offline:!1}),nt=()=>void 0,rt=()=>tt;function it({request:e,enabled:t=!0}){let n=x(e);n.current=e;let[r,i]=S(null);_(()=>{let e=A({request:e=>n.current(e)});return i(e),()=>e.dispose()},[]);let a=h(e=>r?r.subscribe(e):nt,[r]),o=C(a,r?r.getSnapshot:rt),s=h(()=>{t&&r?.ask()},[t,r]),c=h(()=>r?.reset(),[r]),l=t?o:tt;return{state:l.state,answer:l.answer,pillVisible:l.pillVisible,resetsDateTimeUtc:l.resetsDateTimeUtc,offline:l.offline,ask:s,reset:c}}function at(e){if(typeof e!=`string`||e===``)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}var ot=20,st=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),ct=()=>void 0,lt=()=>st;function ut(e,t){let n=Date.parse(e);if(Number.isNaN(n))return``;let r=(Date.now()-n)/1e3;if(r<60)return t.justNow;let i=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`});return r<3600?i.format(-Math.floor(r/60),`minute`):r<86400?i.format(-Math.floor(r/3600),`hour`):r<604800?i.format(-Math.floor(r/86400),`day`):at(e)}function dt({chat:e,labels:t,open:n}){let r=e.features.History===!0,i=e.client,[a,o]=S(null);_(()=>{if(!r)return;let e=O({client:i,pageSize:ot});return o(e),()=>e.dispose()},[i,r]);let s=h(e=>a?a.subscribe(e):ct,[a]),c=C(s,a?a.getState:lt);_(()=>{n&&a&&a.load()},[n,a]);let l=e.features.ResumeLast?e.lastConversation?.publicId:void 0,u=c.items.filter(e=>e.publicId!==l).slice(0,ot);return!r||c.error||u.length===0?null:/* @__PURE__ */ G(`div`,{className:`wui-chat-empty-rows wui-chat-past`,role:`group`,"aria-label":t.history,children:u.map(n=>/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-empty-row`,onClick:()=>e.openConversation(n.publicId),children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-title`,children:n.title||t.earlierChat}),/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-time`,title:at(n.lastActivityDateTimeUtc)||void 0,children:ut(n.lastActivityDateTimeUtc,t)})]},n.publicId))})}var ft=3;function pt({chat:t,labels:n,onOpenTicket:r}){return!t.features.OpenTickets||t.openTickets.length===0?null:/* @__PURE__ */ G(`div`,{className:`wui-chat-open-tickets`,role:`group`,"aria-label":n.openTickets,children:t.openTickets.slice(0,ft).map(t=>{let i=/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-label`,children:n.ticketAria(t.number)}),/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-title`,children:t.subject}),/* @__PURE__ */ G(e,{className:`wui-chat-empty-row-status`,tone:Xe(t.status),children:n.ticketStatus(t.status)||t.status})]});return r?/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-empty-row`,onClick:()=>r({ticketId:t.ticketId,number:t.number}),children:i},t.ticketId):/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row`,children:i},t.ticketId)})})}var mt={Primary:`wui-chat-starter--primary`,Cta:`wui-chat-starter--cta`};function ht({chat:e,labels:t,onOpenTicket:n}){let r=e.profile;if(!r)return null;let i=r.assistant.intro,o=e.features.Starters&&!e.streaming&&e.starters.length>0,s=e.features.ResumeLast&&!e.features.History?e.lastConversation:null;return/* @__PURE__ */ K(`div`,{className:`wui-chat-empty`,role:`group`,"aria-label":t.emptyTitle,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-empty-hero`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-orb`,"aria-hidden":`true`}),e.greeting?/* @__PURE__ */ G(`h2`,{className:`wui-chat-greeting`,children:e.greeting}):null,i?/* @__PURE__ */ G(`p`,{className:`wui-chat-empty-intro`,children:i}):null]}),o&&/* @__PURE__ */ G(`div`,{className:`wui-chat-starters`,role:`group`,"aria-label":t.starters,children:e.starters.map((t,n)=>/* @__PURE__ */ K(`button`,{type:`button`,className:[`wui-chat-starter`,mt[t.variant]].filter(Boolean).join(` `),style:{"--wui-chat-i":n},onClick:()=>e.submit(t.message),children:[t.icon?/* @__PURE__ */ G(`span`,{className:`wui-chat-starter-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(a,{name:t.icon,size:16})}):null,t.label]},t.id))}),s&&/* @__PURE__ */ G(`div`,{className:`wui-chat-empty-rows`,children:/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-empty-row`,onClick:()=>e.resumeLast(),children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-label`,children:t.resumeLast}),/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-title`,children:s.title||t.untitled}),/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-time`,children:N(s.lastActivityDateTimeUtc)})]})}),/* @__PURE__ */ G(pt,{chat:e,labels:t,onOpenTicket:n})]})}function gt({chat:e,labels:t}){let n=e.agentTyping;if(!n)return null;let r=typeof n==`object`&&n.displayName||Ze(e.messages)||t.agent;return/* @__PURE__ */ G(`li`,{className:`wui-chat-message wui-chat-message--agent wui-chat-message--typing`,children:/* @__PURE__ */ K(`div`,{className:`wui-chat-typing`,role:`status`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-typing-dots`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-typing-dot`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-typing-dot`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-typing-dot`})]}),/* @__PURE__ */ G(`span`,{className:`visually-hidden`,children:t.agentTyping(r)})]})})}function _t({author:e,labels:t}){if(e.kind!==`Agent`)return null;let n=typeof e.avatarUrl==`string`&&e.avatarUrl!==``?e.avatarUrl:null;return/* @__PURE__ */ K(`div`,{className:`wui-chat-agent-head`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-avatar`,"aria-hidden":`true`,children:n?/* @__PURE__ */ G(`img`,{src:n,alt:``}):Ye(e.displayName)}),/* @__PURE__ */ G(`span`,{className:`wui-chat-agent-name`,children:e.displayName||t.agent}),/* @__PURE__ */ G(`span`,{className:`wui-chat-agent-role wui-chat-agent-tag`,children:t.agent})]})}var vt=null;function yt({speech:e,enabled:t}){let n=!!(t&&e?.readAloud),[r,i]=S(!1),[a,o]=S(!1),s=x(null),c=x(null),l=x(!1);return _(()=>(l.current=!0,()=>{l.current=!1,s.current?.abort(),s.current=null,vt===c.current&&(vt=null),c.current=null}),[]),{available:n,speaking:r,failed:a,toggle:h(t=>{if(s.current){s.current.abort();return}if(!e||t.trim()===``)return;vt?.();let n=new AbortController;s.current=n;let r=()=>n.abort();vt=r,c.current=r,i(!0),o(!1),e.speak(t,{signal:n.signal}).catch(()=>{!n.signal.aborted&&l.current&&o(!0)}).finally(()=>{s.current===n&&(s.current=null),vt===r&&(vt=null),l.current&&i(!1)})},[e])}}var bt=/* @__PURE__ */ new Set([`Assistant`,`Agent`,`Script`]),xt=6e3;function St(e){let t=z(e).replace(/ ?\[\d+\]/g,``).replace(/\s+/g,` `).trim();if(t.length<=xt)return t;let n=t.slice(0,xt),r=n.lastIndexOf(`. `);return r===-1?n.trim():n.slice(0,r+1)}function Ct({chat:e,labels:n,message:r}){let i=yt({speech:Me(e),enabled:e.features.ReadAloud});if(!i.available||r.streaming||!bt.has(r.author.kind))return null;let a=r.parts.filter(e=>e.kind===`Text`),o=St(e.features.FigureText?a.map(e=>({...e,text:B(e.text)})):a);if(o.trim()===``)return null;let s=i.speaking?n.readAloudStop:n.readAloud;return/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`volume-high`,tone:i.speaking?`neutral`:void 0,"aria-pressed":i.speaking,"aria-label":s,title:s,onClick:()=>i.toggle(o)}),i.failed&&/* @__PURE__ */ G(`span`,{className:`wui-chat-action-notice`,role:`status`,children:n.readAloudFailed})]})}function wt(e){return e===`wchat:muted`?globalThis.localStorage:globalThis.sessionStorage}var Tt={get(e){try{return wt(e)?.getItem(e)??null}catch{return null}},set(e,t){try{wt(e)?.setItem(e,t)}catch{}}};async function Et(e){if(!navigator.clipboard?.writeText)return Dt(e);try{return await navigator.clipboard.writeText(e),!0}catch{return Dt(e)}}function Dt(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}async function Ot(e,t){try{let n=await e.getAttachment(t.attachmentId),r=URL.createObjectURL(new Blob([n],{type:t.contentType}));return window.open(r,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(r),6e4),!0}catch(e){return globalThis.reportError?.(e),!1}}function kt(e){/^https?:\/\//i.test(e)?window.open(e,`_blank`,`noopener`):window.location.assign(e)}function At(e){for(let t=e?.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return null}function jt(e){let t=0;for(let n of e.parts)n.kind===`Text`&&(t+=n.text.length);return`${e.id}:${e.parts.length}:${t}`}function Mt(e){return e===`Reduced`?`wui-chat--reduced`:``}var Nt={Up:`check`,Down:`x`};function Pt({chat:e,message:n,labels:r,isLast:i,isLastVisitor:a}){let{features:o}=e,[s,c]=S(!1),[l,u]=S(!1),[d,f]=S(!1),p=He(e,r),m=e.streaming||e.thinking;if(_(()=>{if(!s)return;let e=setTimeout(()=>c(!1),2e3);return()=>clearTimeout(e)},[s]),n.streaming)return null;let h=n.author.kind===`Assistant`||n.author.kind===`Agent`||n.author.kind===`Script`,g=h?z(n.parts):``,v=h&&g!==``&&o.Copy,y=h&&g!==``&&o.ReadAloud,b=h&&g!==``&&o.Share&&p.canShare,x=h&&g!==``&&o.Print&&p.canPrint,C=i&&n.author.kind===`Assistant`&&!e.streaming&&!e.thinking&&o.Regenerate&&e.messages.some(e=>e.author.kind===`Visitor`&&e.stored),w=a&&o.Edit&&!m,T=o.Rating&&n.stored&&(n.author.kind===`Assistant`||n.author.kind===`Agent`);if(!v&&!y&&!b&&!x&&!C&&!w&&!T)return null;async function E(t){u(!1);try{await e.rate(n.id,t),f(!0)}catch{u(!0)}}return/* @__PURE__ */ K(W,{children:[v&&/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`copy`,onClick:async()=>{let e=await Et(g);c(e)},children:s?r.copied:r.copy}),y&&/* @__PURE__ */ G(Ct,{chat:e,labels:r,message:n}),b&&/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`share`,disabled:m,onClick:()=>p.shareReply(n),children:r.share}),x&&/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`printer`,disabled:m,onClick:()=>p.printReply(n),children:r.print}),C&&/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`refresh`,onClick:()=>e.regenerate(),children:r.regenerate}),w&&/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`pencil`,onClick:()=>e.startEdit(n.id),children:r.edit}),T&&/* @__PURE__ */ K(`div`,{className:`wui-chat-rating`,role:`group`,"aria-label":`${r.rateUp} / ${r.rateDown}`,children:[[`Up`,`Down`].map(e=>/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:Nt[e],tone:n.rating===e?`neutral`:void 0,"aria-pressed":n.rating===e,"aria-label":e===`Up`?r.rateUp:r.rateDown,onClick:()=>E(e)},e)),l&&/* @__PURE__ */ G(`span`,{role:`status`,children:r.ratingFailed}),d&&!l&&/* @__PURE__ */ G(`span`,{role:`status`,children:r.rated})]}),p.notice!==null&&/* @__PURE__ */ G(`span`,{className:`wui-chat-action-notice`,role:`status`,children:p.notice})]})}function Ft({view:e}){return/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-orb`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-orb-mark`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-orb-glow`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-orb-disc`,"aria-hidden":`true`})]}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-orb-label`,children:e.label})]})}var It=150;function Lt({view:e,motion:t}){let n=t===`Reduced`,[r,i]=S(()=>({id:0,label:e.label,previous:null}));e.label!==r.label&&i({id:r.id+1,label:e.label,previous:{id:r.id,label:r.label}}),_(()=>{if(!r.previous)return;let e=setTimeout(()=>i(e=>({...e,previous:null})),It);return()=>clearTimeout(e)},[r.previous]);let a=n?null:r.previous;return/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-phrases`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-phrases-orb`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-phrases-stage`,children:[a&&/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--out`,children:a.label},`out-${a.id}`),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--in`,children:r.label},`in-${r.id}`)]})]})}var Rt=[`92%`,`78%`,`85%`,`40%`];function zt({view:e}){return/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-skeleton`,children:[/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-skeleton-label`,children:e.label}),/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-skeleton-body`,children:[Rt.map(e=>/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-skeleton-line`,"aria-hidden":`true`,style:{width:e}},e)),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-skeleton-table`,"aria-hidden":`true`})]})]})}function Bt(e,t){return e<t?`done`:e===t?`active`:`pending`}function Vt(e){let t=/* @__PURE__ */ new Map;return e.map(e=>{let n=(t.get(e)??0)+1;return t.set(e,n),{key:`${e}\u0000${n}`,text:e}})}function Ht({state:e}){return e===`done`?/* @__PURE__ */ G(`svg`,{viewBox:`0 0 16 16`,className:`wui-chat-loader-steps-check`,"aria-hidden":`true`,children:/* @__PURE__ */ G(`path`,{d:`M3 8.5 6.5 12 13 4.5`,pathLength:1})}):e===`active`?/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-steps-ring`,"aria-hidden":`true`}):/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-steps-dot`,"aria-hidden":`true`})}function Ut({view:e}){return/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-steps`,children:/* @__PURE__ */ G(`ol`,{className:`wui-chat-loader-steps-list`,children:Vt(e.steps).map(({key:t,text:n},r)=>{let i=Bt(r,e.activeIndex);return/* @__PURE__ */ K(`li`,{className:`wui-chat-loader-steps-item`,"data-state":i,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(Ht,{state:i})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-steps-text`,children:n})]},t)})})})}var Wt=500;function Gt({style:e,view:t,motion:n}){return e===`Phrases`?/* @__PURE__ */ G(Lt,{view:t,motion:n}):G(e===`Orb`?Ft:e===`Skeleton`?zt:Ut,{view:t})}function Kt({style:e=`Steps`,steps:t=[],phrases:n,intervalMs:r,announce:i,motion:a=`On`}){let o=a===`Reduced`,[s,c]=S({style:e,count:0}),[l,u]=S(!1);if(_(()=>{if(o)return;let t=setInterval(()=>c(t=>({style:e,count:t.count+1})),r);return()=>clearInterval(t)},[e,r,o]),_(()=>{let e=setTimeout(()=>u(!0),Wt);return()=>clearTimeout(e)},[]),!T.includes(e))throw Error(`ChatLoader style must be one of ${T.join(`, `)}, got "${e}".`);if(!(r>0))throw Error(`ChatLoader needs intervalMs, a positive number of milliseconds.`);s.style!==e&&c({style:e,count:0});let d=o?0:s.count,f=R(e,t,n,d);return/* @__PURE__ */ K(`div`,{className:o?`wui-chat-loader wui-chat-loader--reduced`:`wui-chat-loader`,role:`status`,"aria-label":f.label,children:[/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-body`,children:/* @__PURE__ */ G(Gt,{style:e,view:f,motion:a})}),/* @__PURE__ */ G(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:l?i:``})]})}function qt({motion:e,mark:t}){return/* @__PURE__ */ K(`div`,{className:e===`Reduced`?`wui-chat-loader-typing wui-chat-loader--reduced`:`wui-chat-loader-typing`,"aria-hidden":`true`,children:[t===`None`?null:/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-typing-orb`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-dots`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`})]})]})}var Jt=`ChatLeadCapture`,Yt=/^https?:\/\//i,Xt={strong:`strong`,em:`em`,strike:`s`};function Zt(e,t={next:0}){return e.map(e=>{let n=t.next++;if(e.type===`text`||e.type===`citation`)return e.text;if(e.type===`link`){let r=Zt(e.children,t);return Yt.test(e.href)?/* @__PURE__ */ G(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:r},n):/* @__PURE__ */ G(f,{children:r},n)}if(e.type in Xt){let r=Xt[e.type];return/* @__PURE__ */ G(r,{children:Zt(e.children,t)},n)}return e.type===`code`?/* @__PURE__ */ G(`code`,{children:e.text},n):null})}function Qt(e,t){return e.state===`Repeat`?e.decidedDateTimeUtc?t.actionRepeat(N(e.decidedDateTimeUtc)):t.actionDone:{Confirmed:t.actionConfirmed,Done:t.actionDone,Rejected:t.actionRejected,Expired:t.actionExpired,Failed:t.actionFailed}[e.state]}function $t(e){let t=e.indexOf(`: `);return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}}function en(e,t){return{id:e,label:t,action:`Send`,target:null,navigateAfterMs:null,icon:null,variant:null}}function tn({part:e,turn:t}){let{labels:n,features:r}=t,i=r.LeadRecap&&e.actionKind===Jt,a=e.state===`Pending`,o=e.editFields??[],s=i&&o.length>0,c=i&&e.confirmLabel||n.actionConfirm,l=i&&e.rejectLabel||n.actionDismiss,[u,d]=S(null),[f,p]=S(null),[m,h]=S(!1),g=v(),y=x(null),b=x(null),C=u!==null;_(()=>{m&&b.current?.querySelector(`[role="menuitem"]`)?.focus()},[m]);async function w(e,t){p(null),d(e);try{await t()}catch(e){p(e?.message||n.actionFailed),d(null)}}function T(e){h(!1),y.current?.focus(),t.chooseQuickReply(en(`lead.edit:${e.id}`,e.label))}function E(e){let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)],n=t.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),h(!1),y.current?.focus()):e.key===`ArrowDown`?(e.preventDefault(),t[(n+1)%t.length]?.focus()):e.key===`ArrowUp`?(e.preventDefault(),t[n<=0?t.length-1:n-1]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`?(e.preventDefault(),t[t.length-1]?.focus()):e.key===`Tab`&&h(!1)}return/* @__PURE__ */ K(`div`,{className:`wui-chat-action wui-chat-action--${e.state.toLowerCase()}`,children:[/* @__PURE__ */ G(`strong`,{className:`wui-chat-action-title`,children:e.title}),e.lines.length>0&&(i?/* @__PURE__ */ G(`dl`,{className:`wui-chat-action-lines`,children:e.lines.map(e=>{let{term:t,detail:n}=$t(e);return/* @__PURE__ */ K(`div`,{className:`wui-chat-action-line`,children:[/* @__PURE__ */ G(`dt`,{children:t}),n!==null&&/* @__PURE__ */ G(`dd`,{children:n})]},e)})}):/* @__PURE__ */ G(`ul`,{className:`wui-chat-action-lines`,children:e.lines.map(e=>/* @__PURE__ */ G(`li`,{children:e},e))})),i&&e.consentText&&/* @__PURE__ */ G(`p`,{className:`wui-chat-action-consent`,children:Zt(ye(e.consentText))}),e.note&&/* @__PURE__ */ G(`p`,{className:`wui-chat-action-note`,children:e.note}),!a&&/* @__PURE__ */ K(`p`,{className:`wui-chat-action-status wui-chat-action-status--${e.state.toLowerCase()}`,children:[Qt(e,n),e.state===`Done`&&e.decidedDateTimeUtc&&/* @__PURE__ */ K(W,{children:[` `,/* @__PURE__ */ G(`time`,{dateTime:e.decidedDateTimeUtc,children:N(e.decidedDateTimeUtc)})]})]}),(a||s)&&/* @__PURE__ */ K(`div`,{className:`wui-chat-action-buttons`,children:[a&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`button`,{className:`btn btn-primary btn-sm`,type:`button`,disabled:C,onClick:()=>w(`confirm`,()=>t.confirmAction(e.actionId)),children:u===`confirm`?n.actionWorking:c}),/* @__PURE__ */ G(`button`,{className:`btn btn-soft-primary btn-sm`,type:`button`,disabled:C,onClick:()=>w(`reject`,()=>t.rejectAction(e.actionId)),children:l})]}),s&&/* @__PURE__ */ G(`button`,{ref:y,className:`btn btn-soft-primary btn-sm wui-chat-action-edit`,type:`button`,"aria-haspopup":`menu`,"aria-expanded":m,"aria-controls":m?g:void 0,disabled:!a||C,onClick:()=>h(e=>!e),children:n.editSomething})]}),s&&m&&/* @__PURE__ */ G(`ul`,{id:g,ref:b,className:`list-group wui-chat-action-menu`,role:`menu`,"aria-label":n.editSomething,onKeyDown:E,children:o.map(e=>/* @__PURE__ */ G(`li`,{role:`none`,children:/* @__PURE__ */ G(`button`,{className:`list-group-item list-group-item-action wui-chat-action-menu-item`,type:`button`,role:`menuitem`,tabIndex:-1,onClick:()=>T(e),children:e.label})},e.id))}),f&&/* @__PURE__ */ G(`p`,{className:`wui-chat-action-error`,role:`alert`,children:f})]})}function Q({text:e,enabled:t}){if(!t||typeof e!=`string`)return e;let n=0;return/* @__PURE__ */ G(W,{children:oe(e).map(e=>{let t=`${n}-${e.kind}`;return n+=e.text.length,e.kind===`sub`?/* @__PURE__ */ G(`sub`,{children:e.text},t):e.kind===`sup`?/* @__PURE__ */ G(`sup`,{children:e.text},t):/* @__PURE__ */ G(f,{children:e.text},t)})})}function nn(e,t){return t&&typeof e==`string`?B(e):e}var rn={Bar:`column`,Line:`line`,Donut:`donut`},an=8,on=4;function sn({part:e,turn:r}){let[i,a]=S(`chart`),o=r.features.FigureText,s=e.chartType===`Donut`?e.series.slice(0,1):e.series.slice(0,an),c=s.map(e=>new Map(e.points.map(e=>[e.label,e.value]))),l=[...new Set(s.flatMap(e=>e.points.map(e=>e.label)))].map(e=>{let t={label:nn(e,o)};return c.forEach((n,r)=>{t[`s${r}`]=n.get(e)??null}),t}),u=e.unit?nn(e.unit,o):null,d=s.map((e,t)=>{let n=nn(e.name,o);return{key:`s${t}`,label:n,format:{style:`number`}}}),f=e.chartType!==`Donut`&&u?{label:u}:void 0,p=Math.max(0,...s.map(e=>e.points.length)),m=e.chartType===`Bar`&&p>on?300:240;return/* @__PURE__ */ K(`figure`,{className:`wui-chat-chart`,children:[e.title?/* @__PURE__ */ G(`figcaption`,{className:`wui-chat-rich-title`,children:/* @__PURE__ */ G(Q,{text:e.title,enabled:o})}):null,/* @__PURE__ */ G(n,{type:rn[e.chartType],title:(e.title?nn(e.title,o):``)||r.labels.chart,data:l,x:{key:`label`},series:d,y:f,height:m,view:i,errorText:r.labels.chartLoadFailed}),l.length>0&&/* @__PURE__ */ G(t,{variant:`link`,size:`sm`,className:`wui-chat-chart-toggle`,"aria-pressed":i===`table`,onClick:()=>a(i===`table`?`chart`:`table`),children:i===`table`?r.labels.chartShowChart:r.labels.chartShowTable})]})}var cn={Neutral:`neutral`,Positive:`success`,Caution:`warning`,Negative:`danger`},ln=/* @__PURE__ */ new Set([`Positive`,`Caution`,`Negative`]),un=3,dn=5,fn=.001;function pn(e){let t=0;return e.map(e=>{let n=`${t}-${e.kind}`;return t+=e.text.length,e.kind===`sub`?/* @__PURE__ */ G(`sub`,{children:e.text},n):e.kind===`sup`?/* @__PURE__ */ G(`sup`,{children:e.text},n):/* @__PURE__ */ G(`span`,{children:e.text},n)})}function mn(e,t){let n=e.value!==0&&Math.abs(e.value)<fn?pn(L(e.value)):Se(e.value),r=ln.has(e.status)?/* @__PURE__ */ G(`span`,{className:`visually-hidden`,children:t.figureStatus(e.status)}):null;return e.unit?/* @__PURE__ */ K(W,{children:[n,` `,/* @__PURE__ */ G(`span`,{className:`wui-chat-figure-unit`,children:pn(oe(e.unit))}),r]}):/* @__PURE__ */ K(W,{children:[n,r]})}function hn({part:e,turn:t}){if(e.figures.length===0)return null;let n=Math.min(dn,Math.max(un,e.figures.length)),r=e.figures.map(e=>({label:/* @__PURE__ */ G(Q,{text:e.label,enabled:!0}),value:mn(e,t.labels),tone:cn[e.status]}));return/* @__PURE__ */ G(`div`,{className:`wui-chat-figures`,role:`group`,"aria-label":t.labels.figures,children:/* @__PURE__ */ G(c,{className:`wui-chat-figures-strip`,size:`sm`,columns:n,items:r})})}function gn({part:e,turn:t}){let n=/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`span`,{children:/* @__PURE__ */ G(a,{name:`document-text`,size:16})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-file-name`,children:e.fileName}),/* @__PURE__ */ G(`span`,{className:`wui-chat-file-size`,children:ee(e.length)})]});return/* @__PURE__ */ G(`div`,{className:`wui-chat-file`,children:t.openAttachment?/* @__PURE__ */ G(`button`,{className:`wui-chat-file-chip`,type:`button`,"aria-label":t.labels.fileOpen(e.fileName),onClick:()=>t.openAttachment(e),children:n}):/* @__PURE__ */ G(`span`,{className:`wui-chat-file-chip`,children:n})})}var _n=/* @__PURE__ */ new Set([`Requested`,`Waiting`,`Joined`,`Left`,`Ended`]),vn=/* @__PURE__ */ new Set([`Requested`,`Waiting`,`Joined`]);function yn({part:e,turn:t}){if(!_n.has(e.state)||t.handoffSettled===!0&&(e.state===`Requested`||e.state===`Waiting`))return null;let{labels:n}=t,r=e.agent?.displayName||null,i=e.agent?.avatarUrl||null,a=e.state.toLowerCase(),o=t.isLast&&(e.state===`Requested`||e.state===`Waiting`);return/* @__PURE__ */ K(`div`,{className:`wui-chat-handoff wui-chat-handoff--${a}${o?` wui-chat-handoff--live`:``}`,role:t.isLast&&vn.has(e.state)?`status`:void 0,children:[e.state===`Requested`&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulses`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`})]}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffRequested})]}),e.state===`Waiting`&&/* @__PURE__ */ K(W,{children:[typeof e.queuePosition!=`number`&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulses`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`})]}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffWaiting})]}),typeof e.queuePosition==`number`&&/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-queue`,children:n.handoffQueued(e.queuePosition)}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-note`,children:n.handoffQueuedText})]}),e.state===`Joined`&&/* @__PURE__ */ K(W,{children:[i?/* @__PURE__ */ G(`img`,{className:`wui-chat-handoff-avatar`,src:i,alt:``,"aria-hidden":`true`,width:32,height:32}):/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-avatar`,"aria-hidden":`true`,children:Ye(r)}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-online`,"aria-hidden":`true`}),/* @__PURE__ */ G(`strong`,{className:`wui-chat-handoff-title`,children:n.handoffJoined(r??n.handoffAgentFallback)}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffJoinedText(r??n.handoffAgentFallback)})]}),e.state===`Left`&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`strong`,{className:`wui-chat-handoff-title`,children:n.handoffLeft(r??n.handoffAgentFallback)}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffLeftText})]}),e.state===`Ended`&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffEnded}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffEndedText})]})]})}function bn({part:e,loadAttachmentUrl:n,turn:r}){let[i,a]=S({status:`loading`,url:null}),s=x(0),c=h(e=>{let t=++s.current;a({status:`loading`,url:null}),n(e).then(e=>{s.current===t&&a({status:`ready`,url:e})},()=>{s.current===t&&a({status:`failed`,url:null})})},[n]);return _(()=>(c(e.attachmentId),()=>{s.current++}),[c,e.attachmentId]),i.status===`loading`?/* @__PURE__ */ K(`div`,{className:`wui-chat-image-loading`,role:`status`,children:[/* @__PURE__ */ G(`span`,{className:`visually-hidden`,children:r.labels.imageLoading}),/* @__PURE__ */ G(u,{height:160,radius:8})]}):i.status===`failed`?/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`p`,{className:`wui-chat-image-error`,role:`status`,children:r.labels.imageFailed}),/* @__PURE__ */ G(t,{variant:`soft`,tone:`primary`,size:`sm`,onClick:()=>c(e.attachmentId),children:r.labels.retry})]}):/* @__PURE__ */ G(o,{className:`wui-chat-image-view`,label:r.labels.imageViewer,items:[{key:e.attachmentId,src:i.url,alt:e.alt,name:e.alt}],download:!1,layout:`single`})}function xn({part:e,turn:t}){let n=e.width&&e.height?{aspectRatio:`${e.width} / ${e.height}`}:void 0;return typeof t.loadAttachmentUrl==`function`?/* @__PURE__ */ G(`figure`,{className:`wui-chat-image`,style:n,children:/* @__PURE__ */ G(bn,{part:e,loadAttachmentUrl:t.loadAttachmentUrl,turn:t},e.attachmentId)}):/* @__PURE__ */ G(`figure`,{className:`wui-chat-image`,style:n,children:/* @__PURE__ */ G(`span`,{className:`wui-chat-image-alt`,children:e.alt})})}var Sn=/* @__PURE__ */ new Set([`ActionLimitReached`,`ConversationTooLong`]),Cn={AssistantUnavailable:`danger`},wn={info:`info`,warning:`alert-triangle`,danger:`alert-circle`};function Tn({part:e}){let t=Cn[e.code]??(Sn.has(e.code)?`warning`:`info`);return/* @__PURE__ */ K(`div`,{className:`wui-chat-notice wui-chat-notice--${t}`,role:t===`danger`?`alert`:`status`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-notice-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(a,{name:wn[t],size:16})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-notice-text`,children:e.text})]})}var En=[`Email`,`Phone`,`Name`,`Company`,`Text`,`LongText`,`Choice`,`MultiChoice`,`TimeSlot`,`File`,`Consent`],Dn={Email:{type:`email`,autoComplete:`email`},Phone:{type:`tel`,autoComplete:`tel`},Name:{type:`text`,autoComplete:`name`},Company:{type:`text`,autoComplete:`organization`},Text:{type:`text`,autoComplete:void 0}},On=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`});function kn(e,t){return e.state===`Answered`?e.answeredSummary||t.inputAnswered:e.state===`Skipped`?t.inputSkipped:t.inputExpired}function An(e){return e.type===`Consent`?!1:e.type===`MultiChoice`?[]:``}function jn(e){return Object.fromEntries(e.map(e=>[e.key,An(e)]))}function Mn(e,t){return e.secret?t:t.trim()}function Nn(e,t,n){return e.required?e.type===`Consent`?t?null:n.inputConsentRequired:e.type===`MultiChoice`?t.length>0?null:n.inputRequired:Mn(e,t)?null:n.inputRequired:null}function Pn(e,t){return e.type===`Consent`?t?`true`:`false`:e.type===`MultiChoice`?JSON.stringify((e.options??[]).map(e=>e.id).filter(e=>t.includes(e))):e.type===`Choice`||e.type===`TimeSlot`?t:Mn(e,t)}function Fn({field:e,value:t,error:n,file:r,disabled:i,id:a,labels:o,onChange:s,onFile:c,onRemove:l,controlRef:u}){let d=`${a}-error`,f=d,p=n?`true`:void 0,m=e.required||void 0,h=/* @__PURE__ */ G(`p`,{className:`wui-chat-field-error`,id:d,role:`alert`,hidden:!n,children:n}),g=e.required?null:/* @__PURE__ */ G(`span`,{className:`wui-chat-field-hint`,children:o.inputOptional});if(e.type===`Choice`){let n=`${a}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`span`,{className:`form-label`,id:n,children:e.label}),g,/* @__PURE__ */ G(`div`,{role:`radiogroup`,"aria-labelledby":n,"aria-invalid":p,"aria-describedby":f,children:(e.options??[]).map((n,r)=>{let o=`${a}-${n.id}`;return/* @__PURE__ */ K(`div`,{className:`form-check`,children:[/* @__PURE__ */ G(`input`,{className:`form-check-input`,type:`radio`,id:o,name:e.key,value:n.id,checked:t===n.id,disabled:i,onChange:()=>s(n.id),ref:r===0?u:void 0}),/* @__PURE__ */ G(`label`,{className:`form-check-label`,htmlFor:o,children:n.label})]},n.id)})}),h]})}if(e.type===`MultiChoice`){let n=`${a}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`span`,{className:`form-label`,id:n,children:e.label}),g,/* @__PURE__ */ G(`div`,{className:`wui-chat-input-choices`,role:`group`,"aria-labelledby":n,"aria-invalid":p,"aria-describedby":f,children:(e.options??[]).map((n,r)=>{let o=`${a}-${n.id}`;return/* @__PURE__ */ K(`div`,{className:`form-check`,children:[/* @__PURE__ */ G(`input`,{className:`form-check-input`,type:`checkbox`,id:o,name:e.key,value:n.id,checked:t.includes(n.id),disabled:i,onChange:e=>s(e.target.checked?[...t,n.id]:t.filter(e=>e!==n.id)),ref:r===0?u:void 0}),/* @__PURE__ */ G(`label`,{className:`form-check-label`,htmlFor:o,children:n.label})]},n.id)})}),h]})}if(e.type===`TimeSlot`){let n=`${a}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`span`,{className:`form-label`,id:n,children:e.label}),g,/* @__PURE__ */ G(`div`,{className:`wui-chat-input-slots d-flex flex-wrap gap-2`,role:`radiogroup`,"aria-labelledby":n,"aria-invalid":p,"aria-describedby":f,children:(e.slots??[]).map((n,r)=>{let o=`${a}-${n.id}`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-input-slot`,children:[/* @__PURE__ */ G(`input`,{className:`btn-check`,type:`radio`,id:o,name:e.key,value:n.id,checked:t===n.id,disabled:i,onChange:()=>s(n.id),ref:r===0?u:void 0}),/* @__PURE__ */ G(`label`,{className:`btn btn-soft-primary wui-chat-input-slot`,htmlFor:o,children:On.format(new Date(n.startDateTimeUtc))})]},n.id)})}),h]})}if(e.type===`File`){let t=r?.status===`uploading`,n=`${a}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`label`,{className:`form-label`,id:n,htmlFor:a,children:e.label}),g,/* @__PURE__ */ G(`span`,{className:t?`wui-chat-input-file-status`:`visually-hidden`,"aria-live":`polite`,children:t?o.attachmentUploading:``}),/* @__PURE__ */ G(`div`,{role:`group`,"aria-labelledby":n,children:r?/* @__PURE__ */ K(`div`,{className:`wui-chat-input-file`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-input-file-name`,children:r.name}),/* @__PURE__ */ G(`button`,{className:`btn btn-link`,type:`button`,disabled:i,onClick:l,ref:u,children:o.inputRemoveFile(r.name)})]}):/* @__PURE__ */ G(`input`,{className:`form-control wui-chat-input-control`,type:`file`,id:a,name:e.key,accept:e.accept?.join(`,`),disabled:i,"aria-label":o.inputChooseFile,"aria-required":m,"aria-invalid":p,"aria-describedby":f,onChange:e=>{let t=e.target.files?.[0];t&&c(t)},ref:u})}),h]})}if(e.type===`Consent`)return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`div`,{className:`form-check`,children:[/* @__PURE__ */ G(`input`,{className:`form-check-input`,type:`checkbox`,id:a,name:e.key,checked:t,disabled:i,"aria-invalid":p,"aria-describedby":f,onChange:e=>s(e.target.checked),ref:u}),/* @__PURE__ */ G(`label`,{className:`form-check-label`,htmlFor:a,children:e.consentText||e.label})]}),h]});let _=Dn[e.type],v=e.type===`LongText`&&!e.secret?/* @__PURE__ */ G(`textarea`,{className:`form-control wui-chat-input-control`,id:a,name:e.key,rows:3,value:t,placeholder:e.placeholder??void 0,maxLength:e.maxLength??void 0,disabled:i,"aria-required":m,"aria-invalid":p,"aria-describedby":f,onChange:e=>s(e.target.value),ref:u}):/* @__PURE__ */ G(`input`,{className:`form-control wui-chat-input-control`,id:a,name:e.key,type:e.secret?`password`:_.type,autoComplete:e.secret?`off`:_.autoComplete,value:t,placeholder:e.placeholder??void 0,maxLength:e.maxLength??void 0,disabled:i,"aria-required":m,"aria-invalid":p,"aria-describedby":f,onChange:e=>s(e.target.value),ref:u});return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`label`,{className:`form-label`,htmlFor:a,children:e.label}),g,v,h]})}function In({part:e,turn:t}){let{labels:n,features:r}=t,i=v(),[a,o]=S(()=>jn(e.fields)),[s,c]=S({}),[l,u]=S(null),[d,f]=S(!1),[p,m]=S(null),[h,g]=S({}),y=x({}),b=x({});_(()=>{p&&y.current[p.key]?.focus()},[p]);let C=e.fields.length===1?e.fields[0]:null,w=r.LeadShortcuts&&C!==null&&!C.required,T=r.LeadShortcuts&&e.cancellable,E=Object.values(h).some(e=>e.status===`uploading`);function D(t){return e.fields.find(e=>t[e.key])?.key??e.fields[0]?.key}function O(e,t){o(n=>({...n,[e]:t}))}async function k(e,r){let i={};b.current[e]=i,g(t=>({...t,[e]:{status:`uploading`,name:r.name}})),O(e,``),c(t=>({...t,[e]:void 0}));let a;try{a=await t.uploadInputFile(r)}catch{if(b.current[e]!==i)return;g(t=>({...t,[e]:{status:`failed`,name:r.name}})),c(t=>({...t,[e]:n.attachmentFailed}));return}b.current[e]===i&&(O(e,a),g(t=>({...t,[e]:{status:`ready`,name:r.name}})),c(t=>({...t,[e]:void 0})))}function A(e){b.current[e]=null,O(e,``),g(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),c(t=>({...t,[e]:void 0}))}async function j(r){if(r.preventDefault(),E){let e=Object.keys(h).find(e=>h[e]?.status===`uploading`);c(t=>({...t,[e]:n.attachmentUploading})),m({key:e});return}let i={};for(let t of e.fields){let e=t.type===`File`&&h[t.key]?.status===`failed`?n.attachmentFailed:Nn(t,a[t.key],n);e&&(i[t.key]=e)}if(u(null),c(i),Object.keys(i).length>0){m({key:D(i)});return}f(!0);let o=Object.fromEntries(e.fields.map(e=>[e.key,Pn(e,a[e.key])])),s;try{s=await t.answerInput(e.requestId,o)}catch{s={ok:!1,errors:{},message:n.errorGeneric}}if(s.ok)return;let l=Object.entries(s.errors).filter(([t])=>!e.fields.some(e=>e.key===t)).map(([,e])=>e),d=[s.message,...l].filter(Boolean);c(s.errors),u(d.length>0?d.join(` `):null),f(!1),m({key:D(s.errors)})}return/* @__PURE__ */ K(`form`,{className:`wui-chat-input-form`,noValidate:!0,"aria-label":e.title||e.submitLabel,onSubmit:j,children:[e.title&&/* @__PURE__ */ G(`h3`,{className:`wui-chat-input-title`,children:e.title}),e.fields.map(e=>/* @__PURE__ */ G(Fn,{field:e,value:a[e.key],error:s[e.key],file:h[e.key],disabled:d,id:`${i}-${e.key}`,labels:n,onChange:t=>O(e.key,t),onFile:t=>k(e.key,t),onRemove:()=>A(e.key),controlRef:t=>{y.current[e.key]=t}},e.key)),/* @__PURE__ */ G(`p`,{className:`wui-chat-input-error`,role:`status`,hidden:!l,children:l}),/* @__PURE__ */ K(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ G(`button`,{className:`btn btn-primary`,type:`submit`,"data-wui":`AppButton`,disabled:d,children:d?n.inputSubmitting:e.submitLabel}),w&&/* @__PURE__ */ G(`button`,{className:`btn btn-soft-primary`,type:`button`,"data-wui":`AppButton`,disabled:d,onClick:()=>t.skipInput(e.requestId),children:n.skip}),T&&/* @__PURE__ */ G(`button`,{className:`btn btn-link`,type:`button`,disabled:d,onClick:()=>t.cancelLead(),children:n.cancel})]}),e.allowTyped&&/* @__PURE__ */ G(`p`,{className:`wui-chat-input-typed`,children:n.typeAnswer})]})}function Ln({part:e,message:t,turn:n}){if(e.fields.some(e=>!En.includes(e.type)))return/* @__PURE__ */ G(Tn,{part:{kind:`Notice`,code:`NeedsNewerApp`,text:n.labels.needsNewerApp},message:t,turn:n});let r=`wui-chat-input-request wui-chat-input-request--${e.state.toLowerCase()}`;return/* @__PURE__ */ G(`div`,{className:r,children:e.state===`Open`?/* @__PURE__ */ G(In,{part:e,turn:n},e.requestId):/* @__PURE__ */ G(`p`,{className:`wui-chat-input-summary`,children:kn(e,n.labels)})})}var Rn=m({resolveLink:null,linkComponent:null});function zn(){return g(Rn)}var Bn={Primary:`wui-chat-quick-reply--primary`,Cta:`wui-chat-quick-reply--cta`};function Vn(e,t){return e.action===`Navigate`?!!t.features.LinkHandoff:e.action!==`Open`||!!e.target&&!!t.openTarget}function Hn(e,t){return[`wui-chat-quick-reply`,Bn[e.variant],t].filter(Boolean).join(` `)}function Un(e,t,n){return te(e.target,t.handoffHosts)?n?n(e.target):e.target:null}function Wn(e){return e.icon?/* @__PURE__ */ G(`span`,{className:`wui-chat-quick-reply-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(a,{name:e.icon,size:16})}):null}function Gn(e,t,n,r){return/* @__PURE__ */ K(`button`,{type:`button`,className:r,style:n,onClick:n=>{e.action===`Open`?t.openTarget(e.target):(t.chooseQuickReply(e),n.currentTarget.closest(`.wui-chat`)?.querySelector(`.wui-chat-input`)?.focus())},children:[Wn(e),/* @__PURE__ */ G(`span`,{className:`wui-chat-quick-reply-label`,children:e.label})]},e.id)}function Kn(e,t,n){if(!t.features.SuggestedReplies||!t.isLast||t.busy||e.replies.length===0)return null;let r=e.placement===`Composer`?`wui-chat-quick-replies wui-chat-quick-replies--composer`:`wui-chat-quick-replies`,i=e.replies.filter(e=>Vn(e,t));if(i.length===0)return null;let a=t.openTarget??(e=>globalThis.location.assign(e)),o=e.placement===`Composer`?void 0:i.find(e=>e.id===w&&e.action===`Send`);return/* @__PURE__ */ K(`div`,{className:o?`${r} wui-chat-quick-replies--offer`:r,role:`group`,"aria-label":t.labels.quickReplies,children:[o&&/* @__PURE__ */ K(`div`,{className:`wui-chat-offer`,children:[/* @__PURE__ */ G(`div`,{className:`wui-chat-offer-title`,children:o.label}),Gn(o,t,{"--wui-chat-i":0},Hn({...o,variant:`Primary`},`wui-chat-offer-action`))]}),i.map((e,r)=>{if(e===o)return null;let i={"--wui-chat-i":r};if(e.action===`Navigate`){let r=Un(e,t,n);return r===null?/* @__PURE__ */ G(`span`,{className:`wui-chat-quick-reply-label`,style:i,children:e.label},e.id):typeof t.beginHandoff==`function`?/* @__PURE__ */ K(`button`,{type:`button`,disabled:t.handoffPause,className:Hn(e,t.handoffPause?`wui-chat-quick-reply--quiet`:void 0),style:i,onClick:()=>t.beginHandoff(e,()=>a(r)),children:[Wn(e),/* @__PURE__ */ G(`span`,{className:`wui-chat-quick-reply-label`,children:t.handoffPause?t.labels.handoffMoment:e.label})]},e.id):null}return Gn(e,t,i,Hn(e,o?`wui-chat-quick-reply--quiet`:void 0))})]})}function qn({part:e,turn:t}){let{resolveLink:n}=zn(),r=Kn(e,t,n),i=x(null),[a,o]=S(null),s=x(null);return y(()=>{r?i.current=r:i.current&&=(o(i.current),null)}),_(()=>{if(!a)return;let e=s.current,t=e?.ownerDocument.defaultView,n=Number.parseFloat(t?t.getComputedStyle(e).animationDuration:``)*1e3;if(!(n>0)){o(null);return}let r=t.setTimeout(()=>o(null),n);return()=>t.clearTimeout(r)},[a]),r||(a?p(a,{ref:s,className:`${a.props.className} wui-chat-quick-replies--leaving`,"aria-hidden":`true`}):null)}var Jn=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]);function Yn(e){return e.value===null||e.value===void 0||e.value===``?be:e.type===`Date`?q(e.value,{pattern:`day`}):e.type===`DateTimeUtc`?xe(e.value):F(e.value,e.type,null)}function Xn({part:e,turn:n}){let r=v(),a=n.features.FigureText,o=e.fields.map(e=>({label:/* @__PURE__ */ G(Q,{text:e.label,enabled:a}),value:/* @__PURE__ */ G(`span`,{className:Jn.has(e.type)?`wui-chat-num`:void 0,children:/* @__PURE__ */ G(Q,{text:Yn(e),enabled:a})})})),s=!!e.target&&typeof n.openRecord==`function`;return/* @__PURE__ */ K(`article`,{className:`wui-chat-record`,"aria-labelledby":r,children:[/* @__PURE__ */ K(`header`,{className:`wui-chat-record-head`,children:[/* @__PURE__ */ G(`h3`,{className:`wui-chat-record-title`,id:r,children:/* @__PURE__ */ G(Q,{text:e.title,enabled:a})}),e.subtitle?/* @__PURE__ */ G(`span`,{className:`wui-chat-record-subtitle`,children:/* @__PURE__ */ G(Q,{text:e.subtitle,enabled:a})}):null]}),e.fields.length>0?/* @__PURE__ */ G(i,{className:`wui-chat-record-fields`,columns:1,size:`sm`,layout:`summary`,items:o}):null,s?/* @__PURE__ */ G(`div`,{className:`wui-chat-record-actions`,children:/* @__PURE__ */ G(t,{className:`wui-chat-record-open`,size:`sm`,type:`button`,"aria-label":n.labels.recordOpenFor(B(e.title)),onClick:()=>n.openRecord(e),children:n.labels.recordOpen})}):null]})}var Zn=/^https?:\/\//i;function Qn({source:e}){return/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-source-marker`,children:e.marker}),/* @__PURE__ */ G(`span`,{className:`wui-chat-source-title`,children:e.title})]})}function $n({part:e,turn:t}){return!t.features.Sources||e.sources.length===0?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-sources`,children:[/* @__PURE__ */ G(`p`,{className:`wui-chat-sources-label`,children:t.labels.sources}),/* @__PURE__ */ G(`ul`,{className:`wui-chat-sources-list`,"aria-label":t.labels.sources,children:e.sources.map(e=>/* @__PURE__ */ G(`li`,{children:Zn.test(e.url??``)?/* @__PURE__ */ G(`a`,{className:`wui-chat-source`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":t.labels.openSource(e.title),"data-marker":e.marker,children:/* @__PURE__ */ G(Qn,{source:e})}):/* @__PURE__ */ G(`span`,{className:`wui-chat-source`,tabIndex:-1,"data-marker":e.marker,children:/* @__PURE__ */ G(Qn,{source:e})})},e.marker))})]})}var er=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]),tr=50,nr=25;function rr(e){return e.id}function ir(e,t,n,r){return e==null?null:t.type===`Text`&&e!==``?/* @__PURE__ */ G(Q,{text:e,enabled:r}):F(e,t.type,n)}function ar({part:e,turn:n}){let[i,a]=S(!1),o=n.features.FigureText,s=e.columns.map((e,t)=>({key:`c${t}`,label:/* @__PURE__ */ G(Q,{text:e.label,enabled:o}),...er.has(e.type)?{align:`num`}:{},...t===0&&e.type===`Text`?{rowHeader:!0}:{}})),c=e.rows.map((t,n)=>{let r={id:n};return e.columns.forEach((n,i)=>{r[`c${i}`]=ir(t[i],n,e.currency,o)}),r}),l=i?c:c.slice(0,nr),u=l.length>tr,d=e.title?nn(e.title,o):n.labels.table;return/* @__PURE__ */ K(`figure`,{className:`wui-chat-table`,children:[e.title?/* @__PURE__ */ G(`figcaption`,{className:`wui-chat-table-title`,children:/* @__PURE__ */ G(Q,{text:e.title,enabled:o})}):null,/* @__PURE__ */ G(`div`,{className:`table-wrap wui-chat-table-wrap`,role:`region`,tabIndex:0,"aria-label":d,children:/* @__PURE__ */ G(r,{density:`cozy`,columns:s,rows:l,rowKey:rr,empty:n.labels.tableEmpty,maxHeight:u?360:void 0,virtual:u})}),!i&&c.length>nr&&/* @__PURE__ */ G(t,{variant:`soft`,tone:`primary`,size:`sm`,className:`wui-chat-table-more`,onClick:()=>a(!0),children:n.labels.tableShowAll(c.length)})]})}var or=/* @__PURE__ */ new Set([`Visitor`,`Customer`]),sr=/^\d+$/;function cr({part:e,message:t,turn:n}){let{resolveLink:r,linkComponent:i}=zn(),a=n.features.FigureText,o=n.features.Sources===!0;if(or.has(t.author.kind))return/* @__PURE__ */ G(`div`,{className:t.restored?`wui-chat-bubble`:`wui-chat-bubble wui-chat-part-enter`,children:/* @__PURE__ */ G(Q,{text:e.text,enabled:a})});let c=n.handoffHosts,l=e=>te(e,c)?e:r?r(e):null,u=o&&n.openCitation?e=>n.openCitation(Number(e)):void 0,d=o?n.isCitation??(e=>sr.test(e)):()=>!1;return/* @__PURE__ */ G(s,{value:e.text,links:`app`,headings:`text`,className:t.restored?`wui-chat-text`:`wui-chat-text wui-chat-part-enter`,resolveLink:l,linkComponent:i||void 0,isCitation:d,figureText:a?oe:void 0,onOpenCitation:u})}function lr({part:n,turn:r}){let{labels:i}=r,o=i.ticketStatus(n.status);return/* @__PURE__ */ K(`article`,{className:`wui-chat-ticket`,"aria-label":i.ticketAria(n.number),children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-ticket-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(a,{name:`tag`,size:20})}),/* @__PURE__ */ K(`div`,{className:`wui-chat-ticket-body`,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-ticket-head`,children:[/* @__PURE__ */ G(`b`,{className:`wui-chat-ticket-number`,children:i.ticketAria(n.number)}),o&&/* @__PURE__ */ G(e,{className:`wui-chat-ticket-status`,tone:Xe(n.status),children:o})]}),/* @__PURE__ */ G(`strong`,{className:`wui-chat-ticket-title`,children:n.subject})]}),r.openTicket&&/* @__PURE__ */ G(t,{variant:`outline`,size:`sm`,className:`wui-chat-ticket-open`,onClick:()=>r.openTicket(n),children:i.ticketView})]})}var ur=40,$=null;function dr({part:e,turn:t}){let[n,r]=S(!1),[i,o]=S(!1),[s,c]=S(!1),[l,u]=S(!1),[d,f]=S(0),p=x(null),m=x(null),g=x(!1),v=b(()=>H(`${e.attachmentId}|${e.durationMs}`,ur).map((e,t)=>({id:`bar-${t}`,position:t,height:e})),[e.attachmentId,e.durationMs]),y=h(()=>{p.current?.pause(),$===y&&($=null),o(!1)},[]);if(_(()=>(g.current=!0,()=>{g.current=!1,p.current?.pause(),m.current&&URL.revokeObjectURL(m.current),$===y&&($=null)}),[y]),!t.features.VoiceClips)return e.transcript?/* @__PURE__ */ G(`p`,{className:`wui-chat-clip-transcript`,children:e.transcript}):null;async function C(){if(i)y();else{r(!0),c(!1);try{if(!p.current){let n=await t.readAttachment(e.attachmentId);if(!g.current)return;m.current=URL.createObjectURL(new Blob([n]));let r=new Audio(m.current);r.addEventListener(`timeupdate`,()=>f(r.currentTime)),r.addEventListener(`ended`,()=>{o(!1),f(0),r.currentTime=0,$===y&&($=null)}),r.addEventListener(`error`,()=>{c(!0),o(!1)}),p.current=r}$?.(),await p.current.play(),$=y,o(!0)}catch{c(!0)}finally{g.current&&r(!1)}}}let w=e.durationMs/1e3,T=Math.floor((w>0?Math.min(1,d/w):0)*ur);return/* @__PURE__ */ K(`div`,{className:`wui-chat-clip`,role:`group`,"aria-label":t.labels.voiceClip,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-clip-row`,children:[/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-clip-play`,"aria-label":i?t.labels.voiceClipPause:t.labels.voiceClipPlay,"aria-busy":n,disabled:n,onClick:C,children:/* @__PURE__ */ G(a,{name:i?`pause`:`play`,size:16,"aria-hidden":`true`})}),/* @__PURE__ */ G(`div`,{className:`wui-chat-clip-wave`,"aria-hidden":`true`,children:v.map(({id:e,position:t,height:n})=>/* @__PURE__ */ G(`span`,{className:t<T?`wui-chat-clip-bar wui-chat-clip-bar--played`:`wui-chat-clip-bar`,style:{"--wui-chat-bar-height":`${Math.round(n*100)}%`}},e))}),/* @__PURE__ */ G(`span`,{className:`wui-chat-clip-time`,children:t.labels.voiceClipTime(I(d),I(Math.max(1,Math.round(w))))})]}),s&&/* @__PURE__ */ G(`p`,{className:`wui-chat-clip-error`,role:`status`,children:t.labels.voiceClipFailed}),e.transcript?/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-clip-toggle`,"aria-expanded":l,onClick:()=>u(!l),children:l?t.labels.voiceClipHideTranscript:t.labels.voiceClipShowTranscript}),l&&/* @__PURE__ */ G(`p`,{className:`wui-chat-clip-transcript`,children:e.transcript})]}):null]})}var fr={Text:cr,Sources:$n,QuickReplies:qn,InputRequest:Ln,Action:tn,Notice:Tn,Table:ar,Chart:sn,Figures:hn,RecordCard:Xn,Image:xn,File:gn,Ticket:lr,Handoff:yn,VoiceClip:dr},pr=48,mr={Visitor:`you`,Customer:`you`,Agent:`agent`,Assistant:`assistant`,Script:`assistant`,System:`assistant`},hr={kind:`Notice`,code:`NeedsNewerApp`};function gr(e,t){let n=e.author.kind;return e.author.displayName&&n!==`Visitor`&&n!==`Customer`?e.author.displayName:t[mr[n]??`assistant`]}function _r(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function vr(e,t){let n=/* @__PURE__ */ new Map,r=[];for(let i of e){let e=t(i),a=n.get(e)??0;n.set(e,a+1),r.push({key:`${e}#${a}`,item:i})}return r}function yr({chat:e,labels:n,renderers:r,layoutParts:i,loader:a,motion:o,onOpenAttachment:s,onOpenTarget:c,onOpenTicket:l,onNavigate:u}){let d=x(null),p=x(!0),m=x(/* @__PURE__ */ new Map),h={...fr,...r},g=u??e.onNavigate,v=e.pending?.authorKind,y=v===`Agent`||v===`Customer`?`None`:a===`Orb`?`Orb`:`Assistant`,b=e.messages.at(-1),S=e.messages.find(e=>!(e.streaming&&e.parts.length===0)),C=e.greeting&&S&&(S.author.kind===`Visitor`||S.author.kind===`Customer`)?{id:`greeting`,createdDateTimeUtc:S.createdDateTimeUtc,author:{kind:`Assistant`,displayName:null},parts:[{kind:`Text`,text:e.greeting}],stored:!1,streaming:!1,restored:!1}:null,w=C?[C,...e.messages]:e.messages,T=w.filter(e=>!(e.streaming&&e.parts.length===0)),E=!e.streaming&&(e.turnError!==null||e.stopped),D=e.turnError?.code===`daily_limit`,O=typeof e.turnError?.code==`string`&&e.turnError.code.endsWith(`feature_off`),k=e.pending?.typing===!0,A=`${b?jt(b):``}|${e.thinking}|${k}|${E}`,M=_r(e.messages,e=>e.author.kind===`Visitor`&&e.stored),N=e.profile?.experience.pacing,F=e.profile?.assistant.name??``;_(()=>{if(!A)return;let e=At(d.current);e&&(e.scrollTop=e.scrollHeight,p.current=!0)},[A]),_(()=>{let e=d.current;if(!e||typeof ResizeObserver!=`function`)return;let t=null,n=()=>{p.current=t.scrollHeight-t.scrollTop-t.clientHeight<=pr},r=new ResizeObserver(()=>{let r=At(e);r!==t&&(t?.removeEventListener(`scroll`,n),t=r,t?.addEventListener(`scroll`,n,{passive:!0})),t&&p.current&&(t.scrollTop=t.scrollHeight)});return r.observe(e),()=>{t?.removeEventListener(`scroll`,n),r.disconnect()}},[]);function I(e,t){m.current.get(e)?.querySelector(`[data-marker="${t}"]`)?.focus()}function L(e,t,r,i){let a=Object.hasOwn(h,r.kind),o=a?r:{...hr,text:n.needsNewerApp},s=o.kind.toLowerCase(),c=a?h[r.kind]:h.Notice;return/* @__PURE__ */ G(`div`,{className:`wui-chat-part wui-chat-part--${s}`,children:/* @__PURE__ */ G(c,{part:o,message:e,turn:t})},i)}return/* @__PURE__ */ G(`div`,{role:`log`,"aria-live":`polite`,"aria-label":n.thread,children:/* @__PURE__ */ K(`ol`,{ref:d,className:`wui-chat-thread`,children:[w.map((t,r)=>{if(t.streaming&&t.parts.length===0)return null;let a=j(e.session,{messageId:t.id,labels:n,openAttachment:s??(t=>Ot(e.client,t)),openTarget:c??kt,...l?{openTicket:l}:{},openCitation:e=>I(t.id,e),onNavigate:g}),o=t===C,u=C?r-1:r,d=T[T.indexOf(t)-1],p=t.author.kind===`Agent`&&d?.author.kind===`Agent`&&(d.author.displayName??``)===(t.author.displayName??``),h=i?i(t):null,_=P(t.createdDateTimeUtc,n),v=d===void 0||P(d.createdDateTimeUtc,n)!==_;return/* @__PURE__ */ K(f,{children:[v?/* @__PURE__ */ G(`li`,{className:`wui-chat-day`,role:`presentation`,children:/* @__PURE__ */ G(`span`,{children:_})}):null,/* @__PURE__ */ K(`li`,{ref:e=>{e?m.current.set(t.id,e):m.current.delete(t.id)},className:`wui-chat-message wui-chat-message--${t.author.kind.toLowerCase()}`,"aria-busy":t.streaming?`true`:void 0,"data-restored":t.restored?``:void 0,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-author visually-hidden`,children:`${gr(t,n)}: `}),p?null:/* @__PURE__ */ G(_t,{author:t.author,labels:n}),/* @__PURE__ */ G(`div`,{className:`wui-chat-message-body`,children:h?vr(h,e=>Array.isArray(e)?`group`:`part`).map(({key:e,item:n})=>/* @__PURE__ */ G(`div`,{className:`wui-chat-part-group`,children:vr(Array.isArray(n)?n:[n],e=>e.kind).map(({key:e,item:n})=>L(t,a,n,e))},e)):vr(t.parts,e=>e.kind).map(({key:e,item:n})=>L(t,a,n,e))}),o?null:/* @__PURE__ */ G(`div`,{className:`wui-chat-message-actions`,children:/* @__PURE__ */ G(Pt,{chat:e,message:t,labels:n,isLast:t===b,isLastVisitor:!o&&u===M})})]})]},t.id)}),/* @__PURE__ */ G(gt,{chat:e,labels:n}),k&&/* @__PURE__ */ G(`li`,{className:`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`,children:/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-slot`,children:/* @__PURE__ */ G(qt,{motion:o,mark:y})})}),e.thinking&&/* @__PURE__ */ G(`li`,{className:`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`,children:/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-slot`,children:/* @__PURE__ */ G(Kt,{style:a,steps:e.steps,phrases:N?.thinkingPhrases??[],intervalMs:N?.phraseIntervalMs??2500,announce:n.preparingAnswer(F),motion:o})})}),E&&/* @__PURE__ */ K(`li`,{className:`wui-chat-message wui-chat-message--system wui-chat-message--error`,children:[D?/* @__PURE__ */ K(`p`,{className:`wui-chat-error wui-chat-error--info`,role:`status`,children:[e.turnError.message,e.turnError.resetsDateTimeUtc?` ${n.dailyLimitRefresh(at(e.turnError.resetsDateTimeUtc))}`:``]}):/* @__PURE__ */ G(`p`,{className:`wui-chat-error`,role:`alert`,children:e.turnError?.message??n.stopped}),e.features.Retry&&!D&&!O&&/* @__PURE__ */ G(`div`,{className:`wui-chat-message-actions`,children:/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.retry(),children:n.retry})})]})]})})}var br=e=>e===`Assistant`||e===`Script`||e===`Agent`;function xr(e,t,n){if(t){e.wasLoading=!0;for(let t of n)e.seen.add(t.id);return[]}if(e.wasLoading||!e.seeded){e.wasLoading=!1,e.seeded=!0;for(let t of n)e.seen.add(t.id);return[]}let r=[];for(let t of n)e.seen.has(t.id)||(e.seen.add(t.id),r.push(t));return r}function Sr(e){let t=e.features.Sounds?e.profile?.experience.sound??null:null,n=x(null),r=x(e);r.current=e;let i=x(e.open),a=x({seen:/* @__PURE__ */ new Set,seeded:!1,wasLoading:!1}),o=t!==null&&(t.open||t.sent||t.reply||t.vibrate);_(()=>{if(!o)return;let e=ce(t,Tt);return n.current=e,e.setMuted(r.current.muted),()=>{e.destroy(),n.current=null}},[o,t]);let{open:s,loading:c,messages:l,muted:u}=e;_(()=>{n.current?.setMuted(u)},[u]),_(()=>{let e=n.current,o=i.current;i.current=s;let u=xr(a.current,c,l);if(e){s&&!o&&e.play(`open`);for(let n of u){if(n.restored||n.parts.some(e=>e.kind===`Notice`))continue;let i=n.author.kind;i===`Visitor`?n.stored||e.play(`sent`):br(i)&&(e.play(`reply`),t.vibrate&&ge(t.vibrateMs,r.current.muted))}}},[s,c,l,t])}function Cr({chat:e,labels:t,layout:n,onClose:r,panelId:i,inputRef:o,ariaLabelOverride:s,renderers:c,layoutParts:l,loader:u,motion:d,onOpenAttachment:f,onOpenTarget:p,onOpenTicket:m,onNavigate:h,resolveLink:g=null,linkComponent:_=null,onSwitch:v,open:y=!0,renderEmpty:x,sendIcon:C=`arrow-up`}){let[w,T]=S(`chat`),E=b(()=>({resolveLink:g,linkComponent:_}),[g,_]);Sr(e);let{features:D}=e,O=e.profile,k=w===`history`&&D.History===!0,A=e.messages.length>0,j=n===`launcher`||n===`docked`,M=O?.experience.sound,N=!!(D.Sounds&&M?.muteControl),P=j?`dialog`:`region`,F=s??O?.assistant.name??t.panelTitle,I=D.PanelSwitch===!0,L=e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`),ee=n===`full-page`||L,te=I&&typeof v==`function`&&(n===`docked`||n===`full-page`),R=n===`full-page`&&I&&typeof r==`function`;function ne(){T(`chat`),r?.()}function re(){if(e.profileError)return/* @__PURE__ */ G(`p`,{className:`wui-chat-profile-error`,role:`alert`,children:e.profileError.message});if(!O&&(n===`full-page`||n===`embedded`)||e.loading)return/* @__PURE__ */ G(`p`,{role:`status`,"aria-busy":`true`,children:t.loadingConversation});if(e.loadError)return/* @__PURE__ */ G(`p`,{className:`wui-chat-profile-error`,role:`alert`,children:e.loadError.message});if(!A){let n=/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(ht,{chat:e,labels:t,onOpenTicket:m}),D.History&&/* @__PURE__ */ G(dt,{chat:e,labels:t,open:y})]});return x?x({chat:e,labels:t,open:y,defaultEmpty:n}):n}return/* @__PURE__ */ G(Rn.Provider,{value:E,children:/* @__PURE__ */ G(yr,{chat:e,labels:t,renderers:c,layoutParts:l,loader:u,motion:d,onOpenAttachment:f,onOpenTarget:p,onOpenTicket:m,onNavigate:h})})}return/* @__PURE__ */ K(`section`,{id:i,className:`wui-chat-panel`,role:P,"aria-label":F,children:[/* @__PURE__ */ K(`header`,{className:`wui-chat-header`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-orb`,"aria-hidden":`true`}),/* @__PURE__ */ K(`div`,{className:`wui-chat-header-text`,children:[/* @__PURE__ */ G(`strong`,{className:`wui-chat-title`,children:O?.assistant.name??``}),/* @__PURE__ */ G(`span`,{className:`wui-chat-status`,children:Qe(e,t)??t.headerStatus})]}),/* @__PURE__ */ K(`div`,{className:`wui-chat-header-actions`,children:[!k&&/* @__PURE__ */ G(Ue,{chat:e,labels:t}),D.History&&(k?/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.backToChat,title:t.backToChat,onClick:()=>T(`chat`),children:/* @__PURE__ */ G(a,{name:`arrow-left`,size:18,"aria-hidden":`true`})}):/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.history,title:t.history,onClick:()=>T(`history`),children:/* @__PURE__ */ G(a,{name:`history`,size:18,"aria-hidden":`true`})})),N&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":e.muted?t.unmuteSounds:t.muteSounds,title:e.muted?t.unmuteSounds:t.muteSounds,onClick:()=>e.session.setMuted(!e.muted),children:/* @__PURE__ */ G(a,{name:e.muted?`volume-mute`:`volume-high`,size:18,"aria-hidden":`true`})}),!k&&ee&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.newChat,title:t.newChat,disabled:e.streaming||e.thinking,onClick:()=>e.newConversation(),children:/* @__PURE__ */ G(a,{name:`plus`,size:18,"aria-hidden":`true`})}),te&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn wui-chat-icon-btn--switch`,"aria-label":n===`docked`?t.openFullScreen:t.openSidePanel,title:n===`docked`?t.openFullScreen:t.openSidePanel,disabled:e.streaming||e.thinking,onClick:()=>v(),children:/* @__PURE__ */ G(a,{name:n===`docked`?`maximize-4`:`panel-left-open`,size:18,"aria-hidden":`true`})}),(j||R)&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn wui-chat-close-btn`,"aria-label":t.close,title:t.close,onClick:ne,children:/* @__PURE__ */ G(a,{name:`x`,size:18,"aria-hidden":`true`})})]})]}),/* @__PURE__ */ G(`div`,{className:`wui-chat-body`,children:k?/* @__PURE__ */ G(qe,{chat:e,labels:t,onOpen:()=>T(`chat`)}):re()}),!k&&/* @__PURE__ */ K(`div`,{className:`wui-chat-foot`,children:[/* @__PURE__ */ G(et,{chat:e,labels:t}),/* @__PURE__ */ G(Fe,{chat:e,labels:t,maxLength:O?.limits.maxMessageLength??4e3,inputRef:o,sendIcon:C}),/* @__PURE__ */ G(We,{chat:e,labels:t})]})]})}function wr(e,t){let n=x(!1);_(()=>{n.current||(n.current=!0,typeof t?.conversationId==`string`&&t.conversationId!==``&&e.openConversation(t.conversationId),typeof t?.draft==`string`&&t.draft!==``&&e.session.open({draft:t.draft}))},[e,t])}function Tr(e,t){let[n,r]=S(!1);return _(()=>{let n=ve(e,t??null);r(n.reduced);let i=n.subscribe(()=>r(n.reduced));return()=>{i(),n.destroy()}},[e,t]),n}function Er({chat:e,labels:t,renderers:n,layoutParts:r,loader:i,motion:a=`On`,onOpenAttachment:o,onOpenTarget:s,onNavigate:c,resolveLink:l,linkComponent:u,className:d,style:f,theme:p,look:m,onOpenSidePanel:h,onClose:g,renderEmpty:_,handoff:v}){let y=x(null);wr(e,v??null);let b=e.features.PanelSwitch===!0&&typeof h==`function`?()=>{let t={conversationId:e.conversationId,draft:y.current?.value??``,from:`full-page`,to:`docked`};me(()=>h(t),{target:`docked`}).catch(e=>globalThis.reportError?.(e))}:void 0;return/* @__PURE__ */ G(Dr,{layout:`full-page`,chat:e,labelOverrides:t,renderers:n,layoutParts:r,loader:i,motion:a,onOpenAttachment:o,onOpenTarget:s,onNavigate:c,resolveLink:l,linkComponent:u,className:d,style:f,theme:p,look:m,inputRef:y,onSwitch:b,onClose:g,renderEmpty:_})}function Dr({layout:e,chat:t,labelOverrides:n,renderers:r,layoutParts:i,loader:a,motion:o,onOpenAttachment:s,onOpenTarget:c,onNavigate:l,resolveLink:u=null,linkComponent:d=null,className:f,style:p,theme:m,look:h,inputRef:g,onSwitch:_,onClose:v,renderEmpty:y}){let x=b(()=>ne(n),[n]),S=b(()=>re(h),[h]),C=Tr(S,t.profile?.experience??null),w=o===`Reduced`||C?`Reduced`:`On`;if(t.profile!==null&&!t.features.VisitorChat)return null;let T=[`wui-chat`,`wui-chat--${e}`,Mt(w),S.input.sendReveal===`Always`?`wui-chat--send-always`:null,S.input.ring===!1?`wui-chat--input-ring-off`:null,S.panel.replyAvatars===!1?`wui-chat--reply-avatars-off`:null,S.expressive?`wui-chat--expressive`:null,f].filter(Boolean).join(` `),E=S.avatar?{"--wui-chat-avatar":`url(${JSON.stringify(S.avatar)})`,"--wui-chat-typing-mark":`url(${JSON.stringify(S.avatar)})`,...p}:p;return/* @__PURE__ */ G(`div`,{className:T,style:E,"data-state":`open`,"data-theme":m===`auto`?void 0:m,children:/* @__PURE__ */ G(Cr,{chat:t,labels:x,layout:e,sendIcon:S.input.sendIcon,panelId:void 0,renderers:r,layoutParts:i,loader:a,motion:w,onOpenAttachment:s,onOpenTarget:c,onNavigate:l,resolveLink:u,linkComponent:d,inputRef:g,onSwitch:_,onClose:v,renderEmpty:y})})}function Or(e){return/* @__PURE__ */ G(Dr,{...e,layout:`embedded`})}var kr=`a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Ar(e){let t=x(null);return _(()=>{let n=document.activeElement;return t.current?.querySelector(kr)?.focus({preventScroll:!0}),()=>(e.current??n)?.focus?.({preventScroll:!0})},[e]),_(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=0,r=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>window.dispatchEvent(new Event(`scroll`)))});return r.observe(e),()=>{cancelAnimationFrame(n),r.disconnect()}},[]),t}function jr({x:e,labels:n,renderAnswer:r,renderFoot:i,askDraft:a,chat:o,close:s,triggerRef:c}){let l=Ar(c),{state:u,answer:d,pillVisible:f,resetsDateTimeUtc:p}=e,m=null;if((u===`thinking`||u===`slow`)&&f)m=/* @__PURE__ */ K(`div`,{className:`wui-chat-explain-pill`,role:`status`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-explain-pill-dot`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{children:u===`slow`?n.explainSlow:n.thinking})]});else if(u===`answered`)m=/* @__PURE__ */ G(`div`,{className:`wui-chat-explain-answer`,children:r({answer:d,labels:n,close:s})});else if(u===`empty`)m=/* @__PURE__ */ G(`p`,{className:`wui-chat-explain-note`,children:n.explainEmpty});else if(u===`capacity`){let e=at(p);m=/* @__PURE__ */ G(`p`,{className:`wui-chat-explain-notice wui-chat-explain-notice--info`,role:`status`,children:e?n.explainCapacity(e):n.explainCapacityNoDate})}else u===`error`&&(m=/* @__PURE__ */ K(`div`,{className:`wui-chat-explain-notice wui-chat-explain-notice--error`,role:`alert`,children:[/* @__PURE__ */ G(`p`,{children:n.explainError}),/* @__PURE__ */ G(t,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.ask(),children:n.explainRetry})]}));let h=typeof a==`string`&&a!==``&&typeof o.session?.open==`function`;return/* @__PURE__ */ K(`div`,{ref:l,className:`wui-chat-explain`,children:[m,/* @__PURE__ */ K(`div`,{className:`wui-chat-explain-foot`,children:[i?.({close:s}),h&&/* @__PURE__ */ G(t,{className:`wui-chat-explain-more`,size:`sm`,variant:`ghost`,onClick:()=>{s(),o.session.open({draft:a})},children:n.explainAskMore}),/* @__PURE__ */ G(`p`,{className:`wui-chat-explain-note`,children:n.explainNotCounted})]})]})}function Mr({chat:e,request:t,renderAnswer:n,label:r,renderFoot:i,askDraft:o,labels:s,placement:c=`auto`,className:u,triggerContent:f}){let p=b(()=>ne(s),[s]),[m,h]=S(!1),g=it({request:t,enabled:e.features.Explain===!0}),v=x(null),y=x(!1);if(_(()=>{if(!m)return;let e=e=>{y.current=!!e.target?.closest?.(`.wui-chat-panel`)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[m]),!e.features.Explain)return null;function C(e){!e&&(y.current||document.querySelector(`.wui-chat--docked[data-open=true]`))?y.current=!1:(h(e),e?g.ask():g.reset())}function w(){h(!1),g.reset()}let T=/* @__PURE__ */ K(`button`,{type:`button`,className:[`wui-chat-explain-trigger`,m?`wui-chat-explain-trigger--open`:null].filter(Boolean).join(` `),"aria-haspopup":`dialog`,"aria-label":p.explainTriggerLabel(r),disabled:g.offline,onClick:e=>{v.current=e.currentTarget},children:[/* @__PURE__ */ G(a,{name:`magic-star`,size:14,"aria-hidden":`true`}),f??p.explainTrigger]});return g.offline?/* @__PURE__ */ G(d,{content:p.explainOffline,children:/* @__PURE__ */ G(`span`,{className:`wui-chat-explain-offline`,children:T})}):/* @__PURE__ */ G(l,{trigger:T,title:r,placement:c,open:m,onOpenChange:C,role:`dialog`,className:[`wui-chat-explain-pop`,u].filter(Boolean).join(` `),children:/* @__PURE__ */ G(jr,{x:g,labels:p,renderAnswer:n,renderFoot:i,askDraft:o,chat:e,close:w,triggerRef:v})})}function Nr({chat:e,labels:t,enabled:n,onActivate:r}){let i=e.profile?ie(e.profile,e.features):null,[o,s]=S(!1),[c,l]=S(!1),[u,d]=S(!1),f=(i?.delaySeconds??0)*1e3;return _(()=>{if(!n||!i||c){s(!1);return}if(u)return;let e=setTimeout(()=>{s(!0),d(!0)},f);return()=>clearTimeout(e)},[n,i,f,c,u]),!o||!i||c?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-nudge`,role:`status`,children:[/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-nudge-text`,onClick:r,children:i.text}),/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-nudge-close`,"aria-label":t.nudgeDismiss,onClick:()=>l(!0),children:/* @__PURE__ */ G(a,{name:`x`,size:14,"aria-hidden":`true`})})]})}function Pr(e,t,n,r){_(()=>{let i=e.current;if(!r||!i||!n)return;let a=U(t,n,i);return()=>a.destroy()},[e,t,n,r])}var Fr=620,Ir=300,Lr=`wchat:peeked`,Rr=576,zr=200;function Br(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function Vr(e){return e?.querySelector(`:scope > .wui-chat-panel`)??null}function Hr(e){let[t,n]=S(()=>globalThis.innerWidth<=e);return _(()=>{let t=()=>n(globalThis.innerWidth<=e);return t(),globalThis.addEventListener(`resize`,t),()=>globalThis.removeEventListener(`resize`,t)},[e]),t}function Ur({chat:e,layout:t,labels:n,renderers:r,layoutParts:i,loader:o,motion:s=`On`,onOpenAttachment:c,onOpenTarget:l,onNavigate:u,resolveLink:d=null,linkComponent:f=null,className:p,style:m,theme:g,icon:C=`chat`,look:w,open:T,defaultOpen:E=!1,onOpenChange:D,position:O=`end`,offsetX:k=24,offsetY:A=24,panelId:j,switchConfig:M=null,renderEmpty:N}){let P=v(),F=j??P,I=b(()=>ne(n),[n]),L=b(()=>re(w),[w]),ee=e.profile,te=e.features,R=T!==void 0,z=R?T:e.open,ie=Tr(L,ee?.experience??null),ae=s===`Reduced`||ie?`Reduced`:`On`,oe=L.panel.motion===`None`?0:Ir,B=ee!==null&&te.VisitorChat,V=t===`launcher`||t===`docked`,H=Hr(L.phone.maxWidthPx),U=ee?.experience.launcher??null,se=L.launcher.style===`Pill`?`pill`:`round`,ce=L.launcher.labelReveal===`Expand`?`expand`:`bubble`,le=L.launcher.idle===`None`?`none`:Br(L.launcher.idle),ge=L.launcher.entrance===`None`?null:Br(L.launcher.entrance),_e=U?.hideWhileOpen===!0||L.expressive===!0,ve=U?.peek===!0,W=U?.peekSeconds??3,ye=e.messages.length>0,be=x(null),q=x(null),xe=x(null),Se=x(null),Ce=x(!1),we=x(z),Te=x(z),Ee=x(!1),De=x(D);De.current=D;let[Oe,ke]=S(z?`open`:`closed`),[Ae,J]=S(null),[je,Me]=S(null),Y=Ae??(ge&&!H?`entering`:`idle`);Pr(be,L.avoid,U,t===`launcher`&&B);let Ne=h(e=>{we.current!==e&&(we.current=e,De.current?.(e))},[]),X=h((t,n)=>{Ce.current=t,Ne(t),R||(t?e.session.open({trigger:`manual`}):e.session.close(n))},[R,e.session,Ne]);_(()=>{R&&(T&&!e.open&&e.session.open({trigger:`manual`}),!T&&e.open&&e.session.close(`button`))},[R,T,e.open,e.session]),_(()=>{!R&&E&&e.session.open({trigger:`manual`})},[R,E,e.session]),_(()=>{Ne(e.open)},[e.open,Ne]),_(()=>{if(z){ke(e=>e===`open`?e:`opening`);let e=setTimeout(()=>ke(`open`),Fr);return()=>clearTimeout(e)}ke(e=>e===`closed`?e:`closing`);let e=setTimeout(()=>ke(`closed`),oe);return()=>clearTimeout(e)},[z,oe]),_(()=>{Te.current!==z&&(Te.current=z,Me(z?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`))},[z]),y(()=>{if(Oe!==`opening`)return;let e=Vr(q.current),t=xe.current;e&&t&&de(e,t.getBoundingClientRect())},[Oe]),_(()=>{if(!_e){J(e=>e===`hidden`?`idle`:e);return}if(z){J(`hidden`);return}if(Ae!==`hidden`)return;let e=Vr(q.current)?.contains(document.activeElement)??!1,t=setTimeout(()=>{Ee.current=e,J(`idle`)},zr);return()=>clearTimeout(t)},[z,_e,Ae]),_(()=>{Y===`idle`&&Ee.current&&(Ee.current=!1,pe(xe.current))},[Y]);let Pe=x(!1);_(()=>{let e=Pe.current;Pe.current=z,z||!e||_e||pe(xe.current)},[z,_e]),_(()=>{z&&J(e=>e===`peeking`?`idle`:e)},[z]),_(()=>{B&&Y===`idle`&&ve&&!ie&&!z&&(globalThis.innerWidth<Rr||globalThis.sessionStorage.getItem(Lr)!==null||(globalThis.sessionStorage.setItem(Lr,`1`),J(`peeking`)))},[B,Y,ve,ie,z]),_(()=>{if(Y!==`peeking`)return;let e=setTimeout(()=>J(e=>e===`peeking`?`idle`:e),W*1e3);return()=>clearTimeout(e)},[Y,W]);let Fe=x(X);Fe.current=X,_(()=>{if(!z||!V)return;let e=e=>{e.key===`Escape`&&Fe.current(!1,`escape`)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z,V]),_(()=>{let e=Vr(q.current);if(!B||!V||!e)return;let t=t=>he(e,t);return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[B,V]),_(()=>{if(!z||H||!Ce.current)return;let e=setTimeout(()=>Se.current?.focus(),400);return()=>clearTimeout(e)},[z,H]),_(()=>{let e=Vr(q.current);if(!B||!z||!H||!V||!e)return;let t=ue(e,L);return()=>t.destroy()},[B,z,H,V,L]),_(()=>{let e=q.current?.querySelector(`.wui-chat-thread`);if(B&&z&&H&&V&&ye&&e)return fe(e)},[B,z,H,V,ye]),_(()=>{if(t!==`docked`||!z||typeof document>`u`)return;let e=document.documentElement,n=document.getElementById(F);e.dataset.wchatDocked=``;let r=null;if(n){let t=()=>e.style.setProperty(`--wchat-docked-width`,`${n.getBoundingClientRect().width}px`);t(),typeof ResizeObserver<`u`&&(r=new ResizeObserver(t),r.observe(n))}return()=>{r?.disconnect(),e.removeAttribute(`data-wchat-docked`),e.style.removeProperty(`--wchat-docked-width`)}},[t,z,F]);let Ie=M?.preload,Le=x(!1);if(_(()=>{if(z&&!Le.current){Le.current=!0;try{Promise.resolve(Ie?.()).catch(()=>void 0)}catch{}}},[z,Ie]),!B)return null;let Z=M?()=>{let n={conversationId:e.conversationId,draft:Se.current?.value??``,from:t,to:M.target};me(()=>(X(!1,`button`),M.onSwitch(n)),{target:M.target}).catch(e=>globalThis.reportError?.(e))}:void 0,Re=[`wui-chat`,`wui-chat--${t}`,`wui-chat--${O}`,Mt(ae),V&&H?`wui-chat--phone`:null,L.phone.mode===`Sheet`?`wui-chat--sheet`:null,L.input.sendReveal===`Always`?`wui-chat--send-always`:null,L.input.ring===!1?`wui-chat--input-ring-off`:null,L.panel.motion===`Gentle`?`wui-chat--panel-motion-gentle`:null,L.panel.motion===`None`?`wui-chat--panel-motion-none`:null,L.panel.height===`Content`?`wui-chat--panel-height-content`:null,L.panel.replyAvatars===!1?`wui-chat--reply-avatars-off`:null,L.expressive?`wui-chat--expressive`:null,p].filter(Boolean).join(` `),ze={...L.avatar?{"--wui-chat-avatar":`url(${JSON.stringify(L.avatar)})`,"--wui-chat-typing-mark":`url(${JSON.stringify(L.avatar)})`}:null,"--wui-chat-offset-x":`${k}px`,"--wui-chat-offset-y":`${A}px`,"--wui-chat-width":`${L.panel.widthPx}px`,"--wui-chat-panel-max-height":`${L.panel.maxHeightPx}px`,"--wui-chat-bottom-gap":`${L.panel.bottomGapPx}px`,"--wui-chat-sheet-height":`${L.phone.sheetHeightDvh}dvh`,"--wui-chat-sheet-max-height":`${L.phone.sheetMaxHeightPx}px`,...m},Be=[`wui-chat-launcher-wrap`,Y===`entering`&&ge?`wui-chat-launcher--entrance-${ge}`:null,Y===`idle`&&le!==`none`&&(le!==`ring`||se===`pill`)?`wui-chat-launcher--idle-${le}`:null].filter(Boolean).join(` `),Ve=[`wui-chat-launcher`,`wui-chat-launcher--${se}`,se===`pill`&&L.launcher.compact?`wui-chat-launcher--compact`:null,L.launcher.mark===`Icon`?null:`wui-chat-launcher--mark-${Br(L.launcher.mark)}`,`wui-chat-launcher--reveal-${ce}`,je].filter(Boolean).join(` `),He=t===`launcher`&&!z&&te.Nudges,Ue=z?I.launcherClose:U?.hoverLabel||I.launcher;return/* @__PURE__ */ K(`div`,{ref:q,className:Re,style:ze,"data-state":Oe,"data-open":z?`true`:`false`,"data-theme":g===`auto`?void 0:g,children:[/* @__PURE__ */ K(`div`,{ref:be,className:Be,"data-launcher":Y,inert:Y===`hidden`,onAnimationEnd:e=>{e.target===e.currentTarget&&Y===`entering`&&J(`idle`)},children:[/* @__PURE__ */ G(Nr,{chat:e,labels:I,enabled:He,onActivate:()=>X(!0,`manual`)}),/* @__PURE__ */ K(`button`,{ref:xe,type:`button`,className:Ve,"aria-haspopup":`dialog`,"aria-expanded":z,"aria-controls":F,"aria-label":Ue,onClick:()=>X(!z,`launcher`),onAnimationEnd:e=>{e.target===e.currentTarget&&Me(null)},children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-launcher-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(a,{name:C,size:24,"aria-hidden":`true`})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-launcher-close`,"aria-hidden":`true`,children:/* @__PURE__ */ G(a,{name:`x`,size:20,"aria-hidden":`true`})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-launcher-label`,children:Ue})]}),/* @__PURE__ */ G(`span`,{className:`wui-chat-launcher-bubble`,"aria-hidden":`true`,children:U?.hoverLabel||I.launcher})]}),/* @__PURE__ */ G(Cr,{chat:e,labels:I,layout:t,sendIcon:L.input.sendIcon,panelId:F,inputRef:Se,onClose:()=>X(!1,`button`),onSwitch:Z,open:z,renderEmpty:N,renderers:r,layoutParts:i,loader:o,motion:ae,onOpenAttachment:c,onOpenTarget:l,onNavigate:u,resolveLink:d,linkComponent:f})]})}function Wr({enabled:e,settings:t,look:n,session:r,isOpen:i,panelId:a}){let o=x(i);o.current=i,_(()=>{if(!e||!t)return;let i=_e(t,n,{open:()=>r.open({trigger:`auto`}),isOpen:()=>o.current,panelRect:()=>document.getElementById(a)?.getBoundingClientRect()??null});return()=>i.cancel()},[e,t,n,r,a])}function Gr(e){let{chat:t,look:n}=e,r=v(),i=b(()=>re(n),[n]);return Wr({enabled:t.features.AutoOpen&&t.profile!==null,settings:t.profile?.experience.autoOpen??null,look:i,session:t.session,isOpen:t.open,panelId:r}),/* @__PURE__ */ G(Ur,{...e,layout:`launcher`,panelId:r})}function Kr({onOpenFullScreen:e,preloadFullPage:t,...n}){let r=n.chat.features.PanelSwitch===!0&&typeof e==`function`?{onSwitch:e,target:`full-page`,preload:t}:null;return/* @__PURE__ */ G(Ur,{...n,layout:`docked`,switchConfig:r})}var qr=`https://www.google.com/recaptcha/api.js?render=`,Jr=/* @__PURE__ */ new Map;function Yr(e){let t=Jr.get(e);if(t)return t;let n=new Promise((t,n)=>{if(globalThis.grecaptcha?.execute){t(globalThis.grecaptcha);return}let r=document.createElement(`script`);r.src=qr+encodeURIComponent(e),r.async=!0,r.addEventListener(`load`,()=>t(globalThis.grecaptcha)),r.addEventListener(`error`,()=>{Jr.delete(e),n(/* @__PURE__ */ Error(`The reCAPTCHA script did not load.`))}),document.head.append(r)});return Jr.set(e,n),n}async function Xr(e,t){let n=await Yr(e);await new Promise(e=>n.ready(e));let r=await n.execute(e,{action:t});if(!r)throw Object.assign(/* @__PURE__ */ Error(`reCAPTCHA returned no token.`),{code:`captcha_unavailable`});return r}var Zr=e=>{if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(()=>e());return()=>cancelAnimationFrame(t)}let t=setTimeout(e,16);return()=>clearTimeout(t)},Qr=re(),$r=()=>()=>void 0,ei=Object.freeze({profile:null,profileError:null,features:Object.freeze(M()),conversationId:null,conversationState:`Open`,title:null,continuesConversationId:null,messages:[],thinking:!1,steps:[],streaming:!1,loading:!1,loadError:null,turnError:null,stopped:!1,messagesLeftToday:null,editing:null,attachments:[],lastConversation:null,open:!1,muted:!1,greeting:null,starters:[],pending:null,agent:null,agentTyping:null,live:`Off`,handoffPending:!1,handoffPause:!1,openTickets:[],draft:null}),ti=new Proxy({},{get:(e,t)=>{if(!(typeof t==`symbol`||t===`client`||t===`toJSON`||t.startsWith(`$$`))){if(t===`getState`)return()=>ei;if(t===`subscribe`)return $r;if(t!==`then`)return()=>Promise.resolve()}}});function ni(e){let{client:t,screen:n,layout:r,narrow:i,conversationId:a,behaviour:o,attribution:s,prefs:c,pageContext:l,getCaptchaToken:u,onEvent:d,onError:f,onNavigate:p}=e,m=x(l);m.current=l;let g=x(u);g.current=u;let v=x(d);v.current=d;let y=x(f);y.current=f;let w=x(a);w.current=a;let T=x(o);T.current=o;let E=x(s);E.current=s;let O=x(c);O.current=c;let k=JSON.stringify(i??{}),A=x(null),j=x(!1),M=x(null),[N,P]=S(null);_(()=>{M.current=null;let e=D(t,{screen:n,layout:r,narrow:JSON.parse(k),conversationId:w.current??null,pageContext:()=>m.current,behaviour:()=>{let e=A.current;return e?.getState().features.BehaviourStarters?T.current?T.current():(M.current||=se(e.getState().profile?.start.behaviour?.servicePathPrefixes??[]),M.current()):null},attribution:()=>E.current?.()??null,prefs:O.current??Tt,schedule:Zr,reducedMotion:()=>j.current,getCaptchaToken:async e=>{if(g.current)return g.current(e);let t=A.current?.getState().profile?.captcha;return t?.siteKey?Xr(t.siteKey,e):null},onEvent:(e,t)=>v.current?.(e,t),onError:e=>y.current?.(e)});return A.current=e,P({client:t,screen:n,layout:r,narrowKey:k,session:e}),()=>{A.current=null,e.dispose()}},[t,n,r,k]);let F=N!==null&&N.client===t&&N.screen===n&&N.layout===r&&N.narrowKey===k?N.session:ti,I=C(F.subscribe,F.getState);j.current=Tr(Qr,I.profile?.experience??null);let L=b(()=>({load:()=>F.load(),submit:e=>F.submit(e),chooseQuickReply:e=>F.chooseQuickReply(e),answerInput:(e,t)=>F.answerInput(e,t),confirmAction:e=>F.confirmAction(e),rejectAction:(e,t)=>F.rejectAction(e,t),stop:()=>F.stop(),retry:()=>F.retry(),regenerate:()=>F.regenerate(),notifyTyping:()=>F.notifyTyping(),requestHandoff:e=>F.requestHandoff(e),startEdit:e=>F.startEdit(e),cancelEdit:()=>F.cancelEdit(),attach:e=>F.attach(e),removeAttachment:e=>F.removeAttachment(e),openConversation:e=>F.openConversation(e),resumeLast:()=>F.resumeLast(),newConversation:()=>F.newConversation(),rate:(e,t,n)=>F.rate(e,t,n),reset:()=>F.reset()}),[F]),ee=h((e,t)=>v.current?.(e,t),[]);return{...I,...L,session:F,client:t,emit:ee,onNavigate:p}}export{Fe as ChatComposer,Ue as ChatConversationActions,Or as ChatEmbed,Mr as ChatExplain,We as ChatFooter,Gr as ChatLauncher,Kt as ChatLoader,pt as ChatOpenTickets,Er as ChatPage,Kr as ChatPanel,dt as ChatPastChats,Ct as ChatReadAloudButton,yr as ChatThread,fr as defaultRenderers,at as formatResetTime,ni as useChat,J as useChatDictation,it as useChatExplain,wr as useChatHandoff,yt as useChatReadAloud,He as useTranscriptActions};
14
+ `;function Y(e,t,n){let r=e.createElement(t);return n!==void 0&&(r.textContent=n),r}function Je(e,t){if(t.kind===`paragraph`)return Y(e,`p`,t.text);if(t.kind===`list`){let n=Y(e,t.ordered?`ol`:`ul`);for(let r of t.items)n.append(Y(e,`li`,r));return n}let n=Y(e,`table`);if(t.title!==null&&n.append(Y(e,`caption`,t.title)),t.head.length>0){let r=Y(e,`thead`),i=Y(e,`tr`);for(let n of t.head)i.append(Y(e,`th`,n));r.append(i),n.append(r)}let r=Y(e,`tbody`);for(let n of t.rows){let t=Y(e,`tr`);for(let r of n)t.append(Y(e,`td`,r));r.append(t)}return n.append(r),n}function Ye(e){return`CSSStyleSheet`in e&&typeof e.CSSStyleSheet==`function`}function Xe(e,t){if(Ye(e)&&`adoptedStyleSheets`in t){let n=new e.CSSStyleSheet;n.replaceSync(qe),t.adoptedStyleSheets=[n];return}let n=Y(t,`style`,qe);t.head.append(n)}function Ze(e,t={}){let n=t.lang||document.documentElement.lang||`en`,r=document.createElement(`iframe`);r.title=`Print`,r.setAttribute(`aria-hidden`,`true`),r.tabIndex=-1;let i=r.style;i.position=`fixed`,i.right=`0`,i.bottom=`0`,i.width=`0`,i.height=`0`,i.border=`0`,document.body.append(r);let a=r.contentWindow,o=r.contentDocument;if(!a||!o)return r.remove(),!1;o.open(),o.write(`<!doctype html><title></title>`),o.close(),o.title=e.title,o.documentElement.lang=n,Xe(a,o),o.body.append(Y(o,`h1`,e.title));let s=t.printedOn??e.dateText;if(s!=null){let e=Y(o,`p`,s);e.className=`date`,o.body.append(e)}for(let t of e.entries){let e=Y(o,`section`);e.append(Y(o,`h2`,t.speaker));for(let n of t.blocks)e.append(Je(o,n));o.body.append(e)}let c=()=>{r.isConnected&&r.remove(),clearTimeout(l)};a.addEventListener(`afterprint`,c);let l=setTimeout(c,Ke);return a.focus(),a.print(),!0}var Qe=3e3;function $e(e,t){let[n,r]=O(null),i=D(void 0),a=D(!1);C(()=>(a.current=!0,()=>{a.current=!1,clearTimeout(i.current)}),[]);function o(e){a.current&&(clearTimeout(i.current),r(e),i.current=setTimeout(()=>r(null),Qe))}let s={labels:t,title:e.title,figureText:e.features.FigureText,...e.profile?{assistantName:e.profile.assistant.name}:{}},c=e.features.Share&&typeof navigator<`u`&&typeof navigator.share==`function`,l=e.features.Print&&typeof document<`u`;async function u(e,n){let r=P(e,s);if(r.entries.length===0)return;let i={title:r.title,text:de(r,{heading:n,speakers:n})};if(typeof navigator.canShare==`function`&&!navigator.canShare(i))o(t.shareFailed);else try{await navigator.share(i)}catch(e){(typeof e==`object`&&e&&`name`in e?e.name:void 0)!==`AbortError`&&o(t.shareFailed)}}function d(e){let n=P(e,s);n.entries.length!==0&&(Ze(n,{printedOn:t.printedOn(R((/* @__PURE__ */ new Date()).toISOString()))})||o(t.printFailed))}return{canShare:c,canPrint:l,notice:n,shareReply:e=>u([e],!1),printReply:e=>d([e]),shareConversation:()=>u(e.messages,!0),printConversation:()=>d(e.messages)}}function et({chat:e,labels:t}){let n=$e(e,t),r=e.streaming||e.thinking,i=e.messages.some(e=>e.stored&&(e.author.kind===`Assistant`||e.author.kind===`Agent`||e.author.kind===`Script`)&&U(e.parts)!==``);return r||e.loading||e.conversationId===null||!i||!n.canShare&&!n.canPrint?null:/* @__PURE__ */ K(W,{children:[n.canShare&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.shareConversation,title:t.shareConversation,onClick:()=>n.shareConversation(),children:/* @__PURE__ */ G(s,{name:`share`,size:18,"aria-hidden":`true`})}),n.canPrint&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.printConversation,title:t.printConversation,onClick:()=>n.printConversation(),children:/* @__PURE__ */ G(s,{name:`printer`,size:18,"aria-hidden":`true`})}),n.notice!==null&&/* @__PURE__ */ G(`span`,{className:`wui-chat-action-notice`,role:`status`,children:n.notice})]})}function tt({chat:e,labels:t}){let n=e.profile;if(!n)return null;let r=n.footer.disclaimer||t.disclaimer,i=n.footer.privacyText,a=n.footer.privacyUrl,o=n.footer.assuranceText,s=ce(n);return!r&&!i&&!a&&!o&&!s?null:/* @__PURE__ */ K(`p`,{className:`wui-chat-footer`,children:[r&&/* @__PURE__ */ G(`span`,{className:`wui-chat-footer-text`,children:r}),(i||a)&&/* @__PURE__ */ K(`span`,{className:`wui-chat-footer-privacy`,children:[i,i&&a&&` `,a&&/* @__PURE__ */ G(`a`,{className:`wui-chat-footer-link`,href:a,children:t.footerPrivacy})]}),o&&/* @__PURE__ */ G(`span`,{className:`wui-chat-footer-text`,children:o}),s&&/* @__PURE__ */ K(`span`,{className:`wui-chat-footer-captcha`,children:[t.captchaNote,` `,/* @__PURE__ */ G(`a`,{className:`wui-chat-footer-link`,href:`https://policies.google.com/privacy`,target:`_blank`,rel:`noopener noreferrer`,children:t.captchaPrivacy}),` `,/* @__PURE__ */ G(`a`,{className:`wui-chat-footer-link`,href:`https://policies.google.com/terms`,target:`_blank`,rel:`noopener noreferrer`,children:t.captchaTerms})]})]})}var nt=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),rt=()=>()=>{};function it({chat:e,labels:t,onOpen:r}){let[i,a]=O(null),o=i!==null&&i.client===e.client?i.list:null,c=x(e=>o?o.subscribe(e):rt(),[o]),l=x(()=>o?o.getState():nt,[o]),u=k(c,l),[d,f]=O(null),[p,m]=O(``),[h,g]=O(!1),[_,v]=O(null),[y,b]=O(!1),S=D(null),w=D(!1),[T,E]=O(!1);C(()=>{let t=I({client:e.client});return a({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client]),C(()=>{d!==null&&S.current?.focus()},[d]);function A(e){f(e.publicId),m(e.title||``),g(!1)}async function j(e){if(!(w.current||p.trim()===``)){if(o===null)throw Error(`The conversation list is not loaded, so no row can be renamed.`);w.current=!0,E(!0);try{await o.rename(e,p),f(null)}catch{g(!0)}finally{w.current=!1,E(!1)}}}async function M(t){if(!w.current){if(o===null)throw Error(`The conversation list is not loaded, so no row can be deleted.`);w.current=!0,E(!0);try{await o.remove(t),v(null),b(!1),t===e.conversationId&&e.newConversation()}catch{b(!0)}finally{w.current=!1,E(!1)}}}let N=!u.loading&&u.error===null&&u.totalCount!==null&&u.items.length===0;return/* @__PURE__ */ K(`div`,{className:`wui-chat-history`,children:[u.error&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-error`,role:`alert`,children:[t.loadFailed,` `,/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>o?.load(),children:t.retry})]}),u.loading&&u.items.length===0&&/* @__PURE__ */ G(`p`,{className:`wui-chat-history-empty`,role:`status`,children:t.loadingConversation}),N&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-empty`,children:[/* @__PURE__ */ G(`span`,{children:t.historyEmptyTitle}),` `,/* @__PURE__ */ G(`span`,{children:t.historyEmptyText})]}),u.items.length>0&&/* @__PURE__ */ G(`ul`,{className:`wui-chat-history-list`,"aria-label":t.history,children:u.items.map(i=>d===i.publicId?/* @__PURE__ */ K(`li`,{className:`wui-chat-history-row wui-chat-history-row--editing`,children:[/* @__PURE__ */ G(`input`,{ref:S,className:`wui-chat-history-input`,"aria-label":t.conversationTitle,maxLength:120,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j(i.publicId).catch(e=>globalThis.reportError?.(e)),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f(null))}}),/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,disabled:T||p.trim()===``,onClick:()=>j(i.publicId).catch(e=>globalThis.reportError?.(e)),children:t.renameSave}),/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>f(null),children:t.cancel}),h&&/* @__PURE__ */ G(`p`,{className:`wui-chat-history-error`,role:`alert`,children:t.renameFailed})]},i.publicId):_===i.publicId?/* @__PURE__ */ K(`li`,{className:`wui-chat-history-row wui-chat-history-row--confirm`,children:[/* @__PURE__ */ G(`p`,{children:t.deleteConfirmTitle}),/* @__PURE__ */ G(`p`,{children:t.deleteConfirmMessage}),/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,tone:`danger`,disabled:T,onClick:()=>M(i.publicId).catch(e=>globalThis.reportError?.(e)),children:t.deleteConfirm}),/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>v(null),children:t.cancel}),y&&/* @__PURE__ */ G(`p`,{className:`wui-chat-history-error`,role:`alert`,children:t.deleteFailed})]},i.publicId):/* @__PURE__ */ K(`li`,{className:`wui-chat-history-row`,children:[/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-history-open`,onClick:()=>{e.openConversation(i.publicId).catch(e=>globalThis.reportError?.(e)),r()},children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-history-title`,children:i.title||t.untitled}),/* @__PURE__ */ G(`span`,{className:`wui-chat-history-time`,children:R(i.lastActivityDateTimeUtc)})]}),e.features.Rename&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.rename,title:t.rename,onClick:()=>A(i),children:/* @__PURE__ */ G(s,{name:`pencil`,size:18,"aria-hidden":`true`})}),e.features.Delete&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.deleteChat,title:t.deleteChat,onClick:()=>{b(!1),v(i.publicId)},children:/* @__PURE__ */ G(s,{name:`trash`,size:18,"aria-hidden":`true`})})]},i.publicId))}),!u.loading&&u.hasMore&&/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`soft`,onClick:()=>o?.loadMore(),children:t.loadMore})]})}var at=/* @__PURE__ */ new Map([[`Open`,`info`],[`InProgress`,`info`],[`WaitingOnCustomer`,`warning`],[`Resolved`,`success`]]);function ot(e){let t=(e??``).trim().split(/\s+/).filter(Boolean);if(t.length===0)return`?`;let n=Array.from(t[0]??``)[0]??``;return t.length===1?n.toUpperCase():`${n}${Array.from(t[t.length-1]??``)[0]??``}`.toUpperCase()}function st(e){return at.get(e)??`neutral`}function ct(e){for(let t=e.length-1;t>=0;--t){let n=e[t]?.author;if(n&&n.kind===`Agent`&&typeof n.displayName==`string`&&n.displayName.trim()!==``)return n.displayName}return null}function lt(e,t){return e.conversationState===`WaitingForAgent`?t.statusWaitingForAgent:e.conversationState===`WithAgent`?t.statusWithAgent(ct(e.messages)??t.handoffAgentFallback):null}function ut(e){return e.features.HumanHandoff===!0&&e.conversationState===`Open`&&e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`)&&!e.streaming&&!e.thinking}function dt(e){if(typeof e==`object`&&e&&`message`in e)return typeof e.message==`string`?e.message:void 0}function ft({chat:e,labels:t}){let[r,i]=O(!1),[a,o]=O(null),s=e.live===`Lost`,c=ut(e);if(!c&&!s)return null;async function l(){i(!0),o(null);try{await e.requestHandoff()}catch(e){o(dt(e)||t.errorGeneric)}finally{i(!1)}}return/* @__PURE__ */ K(W,{children:[s&&/* @__PURE__ */ K(`p`,{className:`wui-chat-live-status`,role:`status`,children:[t.liveLost,` `,/* @__PURE__ */ G(n,{variant:`ghost`,size:`sm`,onClick:()=>e.session.resumeLive(),children:t.retry})]}),c&&/* @__PURE__ */ K(`div`,{className:`wui-chat-live-actions`,children:[/* @__PURE__ */ G(n,{variant:`outline`,size:`sm`,leftIcon:`user`,className:`wui-chat-handoff-request`,disabled:r,onClick:l,children:t.talkToPerson}),a&&/* @__PURE__ */ G(`p`,{className:`wui-chat-live-error`,role:`alert`,children:a})]})]})}var pt=Object.freeze({state:`idle`,answer:null,pillVisible:!1,resetsDateTimeUtc:null,offline:!1}),mt=()=>void 0,ht=()=>pt;function gt({request:e,enabled:t=!0}){let n=D(e);n.current=e;let[r,i]=O(null);C(()=>{let e=ee({request:e=>{if(!(e instanceof AbortSignal))throw Error(`The explain engine did not pass an AbortSignal.`);return n.current(e)}});return i(e),()=>e.dispose()},[]);let a=x(e=>r?r.subscribe(e):mt,[r]),o=k(a,r?r.getSnapshot:ht),s=x(()=>{t&&r?.ask()},[t,r]),c=x(()=>r?.reset(),[r]),l=t?o:pt;return{state:l.state,answer:l.answer,pillVisible:l.pillVisible,resetsDateTimeUtc:l.resetsDateTimeUtc,offline:l.offline,ask:s,reset:c}}function _t(e){if(typeof e!=`string`||e===``)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}var vt=20,yt=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),bt=()=>void 0,xt=()=>yt;function St(e,t){let n=Date.parse(e);if(Number.isNaN(n))return``;let r=(Date.now()-n)/1e3;if(r<60)return t.justNow;let i=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`});return r<3600?i.format(-Math.floor(r/60),`minute`):r<86400?i.format(-Math.floor(r/3600),`hour`):r<604800?i.format(-Math.floor(r/86400),`day`):_t(e)}function Ct({chat:e,labels:t,open:n}){let r=e.features.History===!0,i=e.client,[a,o]=O(null);C(()=>{if(!r)return;let e=I({client:i,pageSize:vt});return o(e),()=>e.dispose()},[i,r]);let s=x(e=>a?a.subscribe(e):bt,[a]),c=k(s,a?a.getState:xt);C(()=>{n&&a&&a.load().catch(e=>globalThis.reportError?.(e))},[n,a]);let l=e.features.ResumeLast?e.lastConversation?.publicId:void 0,u=c.items.filter(e=>e.publicId!==l).slice(0,vt);return!r||c.error||u.length===0?null:/* @__PURE__ */ G(`div`,{className:`wui-chat-empty-rows wui-chat-past`,role:`group`,"aria-label":t.history,children:u.map(n=>/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-empty-row`,onClick:()=>e.openConversation(n.publicId).catch(e=>globalThis.reportError?.(e)),children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-title`,children:n.title||t.earlierChat}),/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-time`,title:_t(n.lastActivityDateTimeUtc)||void 0,children:St(n.lastActivityDateTimeUtc,t)})]},n.publicId))})}var wt=3;function Tt({chat:e,labels:n,onOpenTicket:r}){return!e.features.OpenTickets||e.openTickets.length===0?null:/* @__PURE__ */ G(`div`,{className:`wui-chat-open-tickets`,role:`group`,"aria-label":n.openTickets,children:e.openTickets.slice(0,wt).map(e=>{let i=/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-label`,children:n.ticketAria(e.number)}),/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-title`,children:e.subject}),/* @__PURE__ */ G(t,{className:`wui-chat-empty-row-status`,tone:st(e.status),children:n.ticketStatus(e.status)||e.status})]});return r?/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-empty-row`,onClick:()=>r({ticketId:e.ticketId,number:e.number}),children:i},e.ticketId):/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row`,children:i},e.ticketId)})})}var Et={Primary:`wui-chat-starter--primary`,Cta:`wui-chat-starter--cta`},Dt=e=>({"--wui-chat-i":e});function Ot({chat:e,labels:t,onOpenTicket:n}){let r=e.profile;if(!r)return null;let i=r.assistant.intro,a=e.features.Starters&&!e.streaming&&e.starters.length>0,o=e.features.ResumeLast&&!e.features.History?e.lastConversation:null;return/* @__PURE__ */ K(`div`,{className:`wui-chat-empty`,role:`group`,"aria-label":t.emptyTitle,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-empty-hero`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-orb`,"aria-hidden":`true`}),e.greeting?/* @__PURE__ */ G(`h2`,{className:`wui-chat-greeting`,children:e.greeting}):null,i?/* @__PURE__ */ G(`p`,{className:`wui-chat-empty-intro`,children:i}):null]}),a&&/* @__PURE__ */ G(`div`,{className:`wui-chat-starters`,role:`group`,"aria-label":t.starters,children:e.starters.map((t,n)=>/* @__PURE__ */ K(`button`,{type:`button`,className:[`wui-chat-starter`,t.variant===null?void 0:Et[t.variant]].filter(Boolean).join(` `),style:Dt(n),onClick:()=>e.submit(t.message).catch(e=>globalThis.reportError?.(e)),children:[t.icon?/* @__PURE__ */ G(`span`,{className:`wui-chat-starter-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(s,{name:t.icon,size:16})}):null,t.label]},t.id))}),o&&/* @__PURE__ */ G(`div`,{className:`wui-chat-empty-rows`,children:/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-empty-row`,onClick:()=>e.resumeLast().catch(e=>globalThis.reportError?.(e)),children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-label`,children:t.resumeLast}),/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-title`,children:o.title||t.untitled}),/* @__PURE__ */ G(`span`,{className:`wui-chat-empty-row-time`,children:R(o.lastActivityDateTimeUtc)})]})}),/* @__PURE__ */ G(Tt,{chat:e,labels:t,onOpenTicket:n})]})}function kt({chat:e,labels:t}){let n=e.agentTyping;if(!n)return null;let r=typeof n==`object`&&n.displayName||ct(e.messages)||t.agent;return/* @__PURE__ */ G(`li`,{className:`wui-chat-message wui-chat-message--agent wui-chat-message--typing`,children:/* @__PURE__ */ K(`div`,{className:`wui-chat-typing`,role:`status`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-typing-dots`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-typing-dot`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-typing-dot`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-typing-dot`})]}),/* @__PURE__ */ G(`span`,{className:`visually-hidden`,children:t.agentTyping(r)})]})})}function At({author:e,labels:t}){if(e.kind!==`Agent`)return null;let n=typeof e.avatarUrl==`string`&&e.avatarUrl!==``?e.avatarUrl:null;return/* @__PURE__ */ K(`div`,{className:`wui-chat-agent-head`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-avatar`,"aria-hidden":`true`,children:n?/* @__PURE__ */ G(`img`,{src:n,alt:``}):ot(e.displayName)}),/* @__PURE__ */ G(`span`,{className:`wui-chat-agent-name`,children:e.displayName||t.agent}),/* @__PURE__ */ G(`span`,{className:`wui-chat-agent-role wui-chat-agent-tag`,children:t.agent})]})}var jt=null;function Mt({speech:e,enabled:t}){let n=!!(t&&e?.readAloud),[r,i]=O(!1),[a,o]=O(!1),s=D(null),c=D(null),l=D(!1);return C(()=>(l.current=!0,()=>{l.current=!1,s.current?.abort(),s.current=null,jt===c.current&&(jt=null),c.current=null}),[]),{available:n,speaking:r,failed:a,toggle:x(t=>{if(s.current){s.current.abort();return}if(!e||t.trim()===``)return;jt?.();let n=new AbortController;s.current=n;let r=()=>n.abort();jt=r,c.current=r,i(!0),o(!1),e.speak(t,{signal:n.signal}).catch(()=>{!n.signal.aborted&&l.current&&o(!0)}).finally(()=>{s.current===n&&(s.current=null),jt===r&&(jt=null),l.current&&i(!1)})},[e])}}var Nt=/* @__PURE__ */ new Set([`Assistant`,`Agent`,`Script`]),Pt=6e3,Ft={tone:`neutral`};function It(e){let t=U(e).replace(/ ?\[\d+\]/g,``).replace(/\s+/g,` `).trim();if(t.length<=Pt)return t;let n=t.slice(0,Pt),r=n.lastIndexOf(`. `);return r===-1?n.trim():n.slice(0,r+1)}function Lt({chat:t,labels:n,message:r}){let i=Mt({speech:Be(t),enabled:t.features.ReadAloud});if(!i.available||r.streaming||!Nt.has(r.author.kind))return null;let a=r.parts.filter(e=>e.kind===`Text`),o=It(t.features.FigureText?a.map(e=>({...e,text:ue(e.text)})):a);if(o.trim()===``)return null;let s=i.speaking?n.readAloudStop:n.readAloud;return/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(e,{icon:`volume-high`,label:s,size:16,...i.speaking?Ft:{},"aria-pressed":i.speaking,onClick:()=>i.toggle(o)}),i.failed&&/* @__PURE__ */ G(`span`,{className:`wui-chat-action-notice`,role:`status`,children:n.readAloudFailed})]})}function Rt(e){return e===`wchat:muted`?globalThis.localStorage:globalThis.sessionStorage}var zt={get(e){try{return Rt(e)?.getItem(e)??null}catch{return null}},set(e,t){try{Rt(e)?.setItem(e,t)}catch{}}};async function Bt(e){if(!navigator.clipboard?.writeText)return Vt(e);try{return await navigator.clipboard.writeText(e),!0}catch{return Vt(e)}}function Vt(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}async function Ht(e,t){try{let n=await e.getAttachment(t.attachmentId),r=URL.createObjectURL(new Blob([n],{type:t.contentType}));return window.open(r,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(r),6e4),!0}catch(e){return globalThis.reportError?.(e),!1}}function Ut(e){/^https?:\/\//i.test(e)?window.open(e,`_blank`,`noopener`):window.location.assign(e)}function Wt(e){for(let t=e?.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return null}function Gt(e){let t=0;for(let n of e.parts)n.kind===`Text`&&(t+=n.text.length);return`${e.id}:${e.parts.length}:${t}`}function Kt(e){return e===`Reduced`?`wui-chat--reduced`:``}var qt=[`Up`,`Down`],Jt={Up:`check`,Down:`x`},Yt={tone:`neutral`};function Xt({chat:t,message:r,labels:i,isLast:a,isLastVisitor:o}){let{features:s}=t,[c,l]=O(!1),[u,d]=O(!1),[f,p]=O(!1),m=$e(t,i),h=t.streaming||t.thinking;if(C(()=>{if(!c)return;let e=setTimeout(()=>l(!1),2e3);return()=>clearTimeout(e)},[c]),r.streaming)return null;let g=r.author.kind===`Assistant`||r.author.kind===`Agent`||r.author.kind===`Script`,_=g?U(r.parts):``,v=g&&_!==``&&s.Copy,y=g&&_!==``&&s.ReadAloud,b=g&&_!==``&&s.Share&&m.canShare,x=g&&_!==``&&s.Print&&m.canPrint,S=a&&r.author.kind===`Assistant`&&!t.streaming&&!t.thinking&&s.Regenerate&&t.messages.some(e=>e.author.kind===`Visitor`&&e.stored),w=o&&s.Edit&&!h,T=s.Rating&&r.stored&&(r.author.kind===`Assistant`||r.author.kind===`Agent`);if(!v&&!y&&!b&&!x&&!S&&!w&&!T)return null;async function E(e){d(!1);try{await t.rate(r.id,e),p(!0)}catch{d(!0)}}return/* @__PURE__ */ K(W,{children:[v&&/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`copy`,onClick:async()=>{let e=await Bt(_);l(e)},children:c?i.copied:i.copy}),y&&/* @__PURE__ */ G(Lt,{chat:t,labels:i,message:r}),b&&/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`share`,disabled:h,onClick:()=>m.shareReply(r).catch(e=>globalThis.reportError?.(e)),children:i.share}),x&&/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`printer`,disabled:h,onClick:()=>m.printReply(r),children:i.print}),S&&/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`refresh`,onClick:()=>t.regenerate().catch(e=>globalThis.reportError?.(e)),children:i.regenerate}),w&&/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`pencil`,onClick:()=>t.startEdit(r.id),children:i.edit}),T&&/* @__PURE__ */ K(`div`,{className:`wui-chat-rating`,role:`group`,"aria-label":`${i.rateUp} / ${i.rateDown}`,children:[qt.map(t=>/* @__PURE__ */ G(e,{icon:Jt[t],label:t===`Up`?i.rateUp:i.rateDown,size:16,...r.rating===t?Yt:{},"aria-pressed":r.rating===t,onClick:()=>E(t)},t)),u&&/* @__PURE__ */ G(`span`,{role:`status`,children:i.ratingFailed}),f&&!u&&/* @__PURE__ */ G(`span`,{role:`status`,children:i.rated})]}),m.notice!==null&&/* @__PURE__ */ G(`span`,{className:`wui-chat-action-notice`,role:`status`,children:m.notice})]})}function Zt({view:e}){return/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-orb`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-orb-mark`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-orb-glow`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-orb-disc`,"aria-hidden":`true`})]}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-orb-label`,children:e.label})]})}var Qt=150;function $t({view:e,motion:t}){let n=t===`Reduced`,[r,i]=O(()=>({id:0,label:e.label,previous:null}));e.label!==r.label&&i({id:r.id+1,label:e.label,previous:{id:r.id,label:r.label}}),C(()=>{if(!r.previous)return;let e=setTimeout(()=>i(e=>({...e,previous:null})),Qt);return()=>clearTimeout(e)},[r.previous]);let a=n?null:r.previous;return/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-phrases`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-phrases-orb`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-phrases-stage`,children:[a&&/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--out`,children:a.label},`out-${a.id}`),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--in`,children:r.label},`in-${r.id}`)]})]})}var en=[`92%`,`78%`,`85%`,`40%`];function tn({view:e}){return/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-skeleton`,children:[/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-skeleton-label`,children:e.label}),/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-skeleton-body`,children:[en.map(e=>/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-skeleton-line`,"aria-hidden":`true`,style:{width:e}},e)),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-skeleton-table`,"aria-hidden":`true`})]})]})}function nn(e,t){return e<t?`done`:e===t?`active`:`pending`}function rn(e){let t=/* @__PURE__ */ new Map;return e.map(e=>{let n=(t.get(e)??0)+1;return t.set(e,n),{key:`${e}\u0000${n}`,text:e}})}function an({state:e}){return e===`done`?/* @__PURE__ */ G(`svg`,{viewBox:`0 0 16 16`,className:`wui-chat-loader-steps-check`,"aria-hidden":`true`,children:/* @__PURE__ */ G(`path`,{d:`M3 8.5 6.5 12 13 4.5`,pathLength:1})}):e===`active`?/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-steps-ring`,"aria-hidden":`true`}):/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-steps-dot`,"aria-hidden":`true`})}function on({view:e}){return/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-steps`,children:/* @__PURE__ */ G(`ol`,{className:`wui-chat-loader-steps-list`,children:rn(e.steps).map(({key:t,text:n},r)=>{let i=nn(r,e.activeIndex);return/* @__PURE__ */ K(`li`,{className:`wui-chat-loader-steps-item`,"data-state":i,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(an,{state:i})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-steps-text`,children:n})]},t)})})})}var sn=500;function cn(e){if(!N.some(t=>t===e))throw Error(`ChatLoader style must be one of ${N.join(`, `)}, got "${e}".`)}function ln({style:e,view:t,motion:n}){return e===`Phrases`?/* @__PURE__ */ G($t,{view:t,motion:n}):G(e===`Orb`?Zt:e===`Skeleton`?tn:on,{view:t})}function un({style:e=`Steps`,steps:t=[],phrases:n,intervalMs:r,announce:i,motion:a=`On`}){let o=a===`Reduced`,[s,c]=O({style:e,count:0}),[l,u]=O(!1);if(C(()=>{if(o)return;let t=setInterval(()=>c(t=>({style:e,count:t.count+1})),r);return()=>clearInterval(t)},[e,r,o]),C(()=>{let e=setTimeout(()=>u(!0),sn);return()=>clearTimeout(e)},[]),cn(e),!(r>0))throw Error(`ChatLoader needs intervalMs, a positive number of milliseconds.`);s.style!==e&&c({style:e,count:0});let d=o?0:s.count,f=H(e,t,n,d);return/* @__PURE__ */ K(`div`,{className:o?`wui-chat-loader wui-chat-loader--reduced`:`wui-chat-loader`,role:`status`,"aria-label":f.label,children:[/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-body`,children:/* @__PURE__ */ G(ln,{style:e,view:f,motion:a})}),/* @__PURE__ */ G(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:l?i:``})]})}function dn({motion:e,mark:t}){return/* @__PURE__ */ K(`div`,{className:e===`Reduced`?`wui-chat-loader-typing wui-chat-loader--reduced`:`wui-chat-loader-typing`,"aria-hidden":`true`,children:[t===`None`?null:/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-typing-orb`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-dots`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`})]})]})}var fn=`ChatLeadCapture`,pn=/^https?:\/\//i,mn={strong:`strong`,em:`em`,strike:`s`};function hn(e){return e in mn}function gn(e,t={next:0}){return e.map(e=>{let n=t.next++;if(e.type===`text`||e.type===`citation`)return e.text;if(e.type===`link`){let r=gn(e.children,t);return pn.test(e.href)?/* @__PURE__ */ G(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:r},n):/* @__PURE__ */ G(_,{children:r},n)}if(e.type===`code`)return/* @__PURE__ */ G(`code`,{children:e.text},n);if(hn(e.type)){let r=mn[e.type];return/* @__PURE__ */ G(r,{children:gn(e.children,t)},n)}return null})}function _n(e,t){return e.state===`Repeat`?e.decidedDateTimeUtc?t.actionRepeat(R(e.decidedDateTimeUtc)):t.actionDone:{Confirmed:t.actionConfirmed,Done:t.actionDone,Rejected:t.actionRejected,Expired:t.actionExpired,Failed:t.actionFailed}[e.state]}function vn(e){let t=e.indexOf(`: `);return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}}function yn(e,t){return{id:e,label:t,action:`Send`,target:null,navigateAfterMs:null,icon:null,variant:null}}function bn(e){if(typeof e==`object`&&e&&`message`in e)return e.message?String(e.message):void 0}function xn({part:e,turn:t}){let{labels:r,features:i}=t,a=i.LeadRecap&&e.actionKind===fn,o=e.state===`Pending`,s=e.editFields??[],c=a&&s.length>0,l=a&&e.confirmLabel||r.actionConfirm,u=a&&e.rejectLabel||r.actionDismiss,[d,f]=O(null),[p,m]=O(null),[h,g]=O(!1),_=w(),v=D(null),y=D(null),b=d!==null;C(()=>{h&&y.current?.querySelector(`[role="menuitem"]`)?.focus()},[h]);async function x(e,t){m(null),f(e);try{await t()}catch(e){m(bn(e)||r.actionFailed),f(null)}}function S(e){g(!1),v.current?.focus(),t.chooseQuickReply(yn(`lead.edit:${e.id}`,e.label))}function T(e){let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)],n=e.target,r=n instanceof HTMLElement?t.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),g(!1),v.current?.focus()):e.key===`ArrowDown`?(e.preventDefault(),t[(r+1)%t.length]?.focus()):e.key===`ArrowUp`?(e.preventDefault(),t[r<=0?t.length-1:r-1]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`?(e.preventDefault(),t[t.length-1]?.focus()):e.key===`Tab`&&g(!1)}return/* @__PURE__ */ K(`div`,{className:`wui-chat-action wui-chat-action--${e.state.toLowerCase()}`,children:[/* @__PURE__ */ G(`strong`,{className:`wui-chat-action-title`,children:e.title}),e.lines.length>0&&(a?/* @__PURE__ */ G(`dl`,{className:`wui-chat-action-lines`,children:e.lines.map(e=>{let{term:t,detail:n}=vn(e);return/* @__PURE__ */ K(`div`,{className:`wui-chat-action-line`,children:[/* @__PURE__ */ G(`dt`,{children:t}),n!==null&&/* @__PURE__ */ G(`dd`,{children:n})]},e)})}):/* @__PURE__ */ G(`ul`,{className:`wui-chat-action-lines`,children:e.lines.map(e=>/* @__PURE__ */ G(`li`,{children:e},e))})),a&&e.consentText&&/* @__PURE__ */ G(`p`,{className:`wui-chat-action-consent`,children:gn(Ee(e.consentText))}),e.note&&/* @__PURE__ */ G(`p`,{className:`wui-chat-action-note`,children:e.note}),!o&&/* @__PURE__ */ K(`p`,{className:`wui-chat-action-status wui-chat-action-status--${e.state.toLowerCase()}`,children:[_n(e,r),e.state===`Done`&&e.decidedDateTimeUtc&&/* @__PURE__ */ K(W,{children:[` `,/* @__PURE__ */ G(`time`,{dateTime:e.decidedDateTimeUtc,children:R(e.decidedDateTimeUtc)})]})]}),(o||c)&&/* @__PURE__ */ K(`div`,{className:`wui-chat-action-buttons`,children:[o&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(n,{size:`sm`,disabled:b,onClick:()=>x(`confirm`,()=>t.confirmAction(e.actionId)),children:d===`confirm`?r.actionWorking:l}),/* @__PURE__ */ G(n,{variant:`soft`,size:`sm`,disabled:b,onClick:()=>x(`reject`,()=>t.rejectAction(e.actionId)),children:u})]}),c&&/* @__PURE__ */ G(n,{ref:v,variant:`soft`,size:`sm`,className:`wui-chat-action-edit`,"aria-haspopup":`menu`,"aria-expanded":h,"aria-controls":h?_:void 0,disabled:!o||b,onClick:()=>g(e=>!e),children:r.editSomething})]}),c&&h&&/* @__PURE__ */ G(`ul`,{id:_,ref:y,className:`list-group wui-chat-action-menu`,role:`menu`,"aria-label":r.editSomething,onKeyDown:T,children:s.map(e=>/* @__PURE__ */ G(`li`,{role:`none`,children:/* @__PURE__ */ G(`button`,{className:`list-group-item list-group-item-action wui-chat-action-menu-item`,type:`button`,role:`menuitem`,tabIndex:-1,onClick:()=>S(e),children:e.label})},e.id))}),p&&/* @__PURE__ */ G(`p`,{className:`wui-chat-action-error`,role:`alert`,children:p})]})}function X({text:e,enabled:t}){if(!t||typeof e!=`string`)return e;let n=0;return/* @__PURE__ */ G(W,{children:le(e).map(e=>{let t=`${n}-${e.kind}`;return n+=e.text.length,e.kind===`sub`?/* @__PURE__ */ G(`sub`,{children:e.text},t):e.kind===`sup`?/* @__PURE__ */ G(`sup`,{children:e.text},t):/* @__PURE__ */ G(_,{children:e.text},t)})})}function Sn(e,t){return t&&typeof e==`string`?ue(e):e}var Cn={Bar:`column`,Line:`line`,Donut:`donut`},wn=8,Tn=4;function En({part:e,turn:t}){let[i,a]=O(`chart`),o=t.features.FigureText,s=e.chartType===`Donut`?e.series.slice(0,1):e.series.slice(0,wn),c=s.map(e=>new Map(e.points.map(e=>[e.label,e.value]))),l=[...new Set(s.flatMap(e=>e.points.map(e=>e.label)))].map(e=>{let t={label:Sn(e,o)};return c.forEach((n,r)=>{t[`s${r}`]=n.get(e)??null}),t}),u=e.unit?Sn(e.unit,o):null,d=s.map((e,t)=>{let n=Sn(e.name,o);return{key:`s${t}`,label:n,format:{style:`number`}}}),f=e.chartType!==`Donut`&&u?{label:u}:void 0,p=Math.max(0,...s.map(e=>e.points.length)),m=e.chartType===`Bar`&&p>Tn?300:240;return/* @__PURE__ */ K(`figure`,{className:`wui-chat-chart`,children:[e.title?/* @__PURE__ */ G(`figcaption`,{className:`wui-chat-rich-title`,children:/* @__PURE__ */ G(X,{text:e.title,enabled:o})}):null,/* @__PURE__ */ G(r,{type:Cn[e.chartType],title:(e.title?Sn(e.title,o):``)||t.labels.chart,data:l,x:{key:`label`},series:d,...f===void 0?{}:{y:f},height:m,view:i,errorText:t.labels.chartLoadFailed}),l.length>0&&/* @__PURE__ */ G(n,{variant:`link`,size:`sm`,className:`wui-chat-chart-toggle`,"aria-pressed":i===`table`,onClick:()=>a(i===`table`?`chart`:`table`),children:i===`table`?t.labels.chartShowChart:t.labels.chartShowTable})]})}var Dn={Neutral:`neutral`,Positive:`success`,Caution:`warning`,Negative:`danger`},On=/* @__PURE__ */ new Set([`Positive`,`Caution`,`Negative`]),kn=.001;function An(e){return e<=3?3:e===4?4:5}function jn(e){let t=0;return e.map(e=>{let n=`${t}-${e.kind}`;return t+=e.text.length,e.kind===`sub`?/* @__PURE__ */ G(`sub`,{children:e.text},n):e.kind===`sup`?/* @__PURE__ */ G(`sup`,{children:e.text},n):/* @__PURE__ */ G(`span`,{children:e.text},n)})}function Mn(e,t){let n=e.value!==0&&Math.abs(e.value)<kn?jn(ie(e.value)):Ae(e.value),r=On.has(e.status)?/* @__PURE__ */ G(`span`,{className:`visually-hidden`,children:t.figureStatus(e.status)}):null;return e.unit?/* @__PURE__ */ K(W,{children:[n,` `,/* @__PURE__ */ G(`span`,{className:`wui-chat-figure-unit`,children:jn(le(e.unit))}),r]}):/* @__PURE__ */ K(W,{children:[n,r]})}function Nn({part:e,turn:t}){if(e.figures.length===0)return null;let n=An(e.figures.length),r=e.figures.map(e=>({label:/* @__PURE__ */ G(X,{text:e.label,enabled:!0}),value:Mn(e,t.labels),tone:Dn[e.status]}));return/* @__PURE__ */ G(`div`,{className:`wui-chat-figures`,role:`group`,"aria-label":t.labels.figures,children:/* @__PURE__ */ G(d,{className:`wui-chat-figures-strip`,size:`sm`,columns:n,items:r})})}function Pn({part:e,turn:t}){let n=/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`span`,{children:/* @__PURE__ */ G(s,{name:`document-text`,size:16})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-file-name`,children:e.fileName}),/* @__PURE__ */ G(`span`,{className:`wui-chat-file-size`,children:B(e.length)})]});return/* @__PURE__ */ G(`div`,{className:`wui-chat-file`,children:t.openAttachment?/* @__PURE__ */ G(`button`,{className:`wui-chat-file-chip`,type:`button`,"aria-label":t.labels.fileOpen(e.fileName),onClick:()=>t.openAttachment?.(e),children:n}):/* @__PURE__ */ G(`span`,{className:`wui-chat-file-chip`,children:n})})}var Fn=/* @__PURE__ */ new Set([`Requested`,`Waiting`,`Joined`]);function In({part:e,turn:t}){if(t.handoffSettled===!0&&(e.state===`Requested`||e.state===`Waiting`))return null;let{labels:n}=t,r=e.agent?.displayName||null,i=e.agent?.avatarUrl||null,a=e.state.toLowerCase(),o=t.isLast&&(e.state===`Requested`||e.state===`Waiting`);return/* @__PURE__ */ K(`div`,{className:`wui-chat-handoff wui-chat-handoff--${a}${o?` wui-chat-handoff--live`:``}`,role:t.isLast&&Fn.has(e.state)?`status`:void 0,children:[e.state===`Requested`&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulses`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`})]}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffRequested})]}),e.state===`Waiting`&&/* @__PURE__ */ K(W,{children:[typeof e.queuePosition!=`number`&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulses`,"aria-hidden":`true`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-pulse`})]}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffWaiting})]}),typeof e.queuePosition==`number`&&/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-queue`,children:n.handoffQueued(e.queuePosition)}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-note`,children:n.handoffQueuedText})]}),e.state===`Joined`&&/* @__PURE__ */ K(W,{children:[i?/* @__PURE__ */ G(`img`,{className:`wui-chat-handoff-avatar`,src:i,alt:``,"aria-hidden":`true`,width:32,height:32}):/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-avatar`,"aria-hidden":`true`,children:ot(r)}),/* @__PURE__ */ G(`span`,{className:`wui-chat-handoff-online`,"aria-hidden":`true`}),/* @__PURE__ */ G(`strong`,{className:`wui-chat-handoff-title`,children:n.handoffJoined(r??n.handoffAgentFallback)}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffJoinedText(r??n.handoffAgentFallback)})]}),e.state===`Left`&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`strong`,{className:`wui-chat-handoff-title`,children:n.handoffLeft(r??n.handoffAgentFallback)}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffLeftText})]}),e.state===`Ended`&&/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffEnded}),/* @__PURE__ */ G(`p`,{className:`wui-chat-handoff-text`,children:n.handoffEndedText})]})]})}function Ln({part:e,loadAttachmentUrl:t,turn:r}){let[i,a]=O({status:`loading`,url:null}),o=D(0),s=x(e=>{let n=++o.current;a({status:`loading`,url:null}),t(e).then(e=>{o.current===n&&a({status:`ready`,url:e})},()=>{o.current===n&&a({status:`failed`,url:null})})},[t]);return C(()=>(s(e.attachmentId),()=>{o.current++}),[s,e.attachmentId]),i.status===`loading`?/* @__PURE__ */ K(`div`,{className:`wui-chat-image-loading`,role:`status`,children:[/* @__PURE__ */ G(`span`,{className:`visually-hidden`,children:r.labels.imageLoading}),/* @__PURE__ */ G(m,{height:160,radius:8})]}):i.status===`failed`?/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`p`,{className:`wui-chat-image-error`,role:`status`,children:r.labels.imageFailed}),/* @__PURE__ */ G(n,{variant:`soft`,tone:`primary`,size:`sm`,onClick:()=>s(e.attachmentId),children:r.labels.retry})]}):/* @__PURE__ */ G(l,{className:`wui-chat-image-view`,label:r.labels.imageViewer,items:[{key:e.attachmentId,src:i.url,alt:e.alt,name:e.alt}],download:!1,layout:`single`})}function Rn({part:e,turn:t}){let n=e.width&&e.height?{aspectRatio:`${e.width} / ${e.height}`}:void 0;return typeof t.loadAttachmentUrl==`function`?/* @__PURE__ */ G(`figure`,{className:`wui-chat-image`,style:n,children:/* @__PURE__ */ G(Ln,{part:e,loadAttachmentUrl:t.loadAttachmentUrl,turn:t},e.attachmentId)}):/* @__PURE__ */ G(`figure`,{className:`wui-chat-image`,style:n,children:/* @__PURE__ */ G(`span`,{className:`wui-chat-image-alt`,children:e.alt})})}var zn={Email:{type:`email`,autoComplete:`email`},Phone:{type:`tel`,autoComplete:`tel`},Name:{type:`text`,autoComplete:`name`},Company:{type:`text`,autoComplete:`organization`},Text:{type:`text`,autoComplete:void 0}},Bn=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`});function Vn(e,t){return e.state===`Answered`?e.answeredSummary||t.inputAnswered:e.state===`Skipped`?t.inputSkipped:t.inputExpired}function Hn(e){return e.type===`Consent`?!1:e.type===`MultiChoice`?[]:``}function Un(e){return Object.fromEntries(e.map(e=>[e.key,Hn(e)]))}function Wn(e){return typeof e==`string`?e:``}function Gn(e){return typeof e==`object`?e:[]}function Kn(e,t){let n=Wn(t);return e.secret?n:n.trim()}function qn(e,t,n){return e.required?e.type===`Consent`?t?null:n.inputConsentRequired:e.type===`MultiChoice`?Gn(t).length>0?null:n.inputRequired:Kn(e,t)?null:n.inputRequired:null}function Jn(e,t){if(e.type===`Consent`)return t?`true`:`false`;if(e.type===`MultiChoice`){let n=Gn(t);return JSON.stringify((e.options??[]).map(e=>e.id).filter(e=>n.includes(e)))}return e.type===`Choice`||e.type===`TimeSlot`?Wn(t):Kn(e,t)}function Yn({field:e,value:t,error:r,file:a,disabled:o,id:s,labels:l,onChange:u,onFile:d,onRemove:f,controlRef:m}){let g=`${s}-error`,_=g,v=r?`true`:void 0,y=e.required||void 0,b=/* @__PURE__ */ G(`p`,{className:`wui-chat-field-error`,id:g,role:`alert`,hidden:!r,children:r}),x=e.required?null:/* @__PURE__ */ G(`span`,{className:`wui-chat-field-hint`,children:l.inputOptional});if(e.type===`Choice`){let n=`${s}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`span`,{className:`form-label`,id:n,children:e.label}),x,/* @__PURE__ */ G(`div`,{role:`radiogroup`,"aria-labelledby":n,"aria-invalid":v,"aria-describedby":_,children:(e.options??[]).map((n,r)=>{let i=`${s}-${n.id}`;return/* @__PURE__ */ G(p,{id:i,name:e.key,value:n.id,label:n.label,checked:t===n.id,disabled:o,onChange:()=>u(n.id),ref:r===0?m:void 0},n.id)})}),b]})}if(e.type===`MultiChoice`){let n=`${s}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`span`,{className:`form-label`,id:n,children:e.label}),x,/* @__PURE__ */ G(`div`,{className:`wui-chat-input-choices`,role:`group`,"aria-labelledby":n,"aria-invalid":v,"aria-describedby":_,children:(e.options??[]).map((n,r)=>{let a=`${s}-${n.id}`;return/* @__PURE__ */ G(i,{id:a,name:e.key,value:n.id,label:n.label,checked:Gn(t).includes(n.id),disabled:o,onChange:e=>u(e.target.checked?[...Gn(t),n.id]:Gn(t).filter(e=>e!==n.id)),ref:r===0?m:void 0},n.id)})}),b]})}if(e.type===`TimeSlot`){let r=`${s}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`span`,{className:`form-label`,id:r,children:e.label}),x,/* @__PURE__ */ G(`div`,{className:`wui-chat-input-slots d-flex flex-wrap gap-2`,role:`radiogroup`,"aria-labelledby":r,"aria-invalid":v,"aria-describedby":_,children:(e.slots??[]).map((r,i)=>{let a=`${s}-${r.id}`,c=`${a}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-input-slot`,children:[/* @__PURE__ */ G(`input`,{className:`btn-check`,type:`radio`,id:a,name:e.key,value:r.id,checked:t===r.id,disabled:o,"aria-labelledby":c,onChange:()=>u(r.id),ref:i===0?m:void 0}),/* @__PURE__ */ G(n,{as:`label`,id:c,variant:`soft`,className:`wui-chat-input-slot`,disabled:o,onClick:()=>u(r.id),children:Bn.format(new Date(r.startDateTimeUtc))})]},r.id)})}),b]})}if(e.type===`File`){let t=a?.status===`uploading`,r=`${s}-label`;return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`label`,{className:`form-label`,id:r,htmlFor:s,children:e.label}),x,/* @__PURE__ */ G(`span`,{className:t?`wui-chat-input-file-status`:`visually-hidden`,"aria-live":`polite`,children:t?l.attachmentUploading:``}),/* @__PURE__ */ G(`div`,{role:`group`,"aria-labelledby":r,children:a?/* @__PURE__ */ K(`div`,{className:`wui-chat-input-file`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-input-file-name`,children:a.name}),/* @__PURE__ */ G(n,{variant:`link`,type:`button`,disabled:o,onClick:f,ref:m,children:l.inputRemoveFile(a.name)})]}):/* @__PURE__ */ G(c,{controlOnly:!0,className:`wui-chat-input-control`,type:`file`,id:s,name:e.key,accept:e.accept?.join(`,`),disabled:o,"aria-label":l.inputChooseFile,"aria-required":y,"aria-invalid":v,"aria-describedby":_,onChange:e=>{let t=e.target.files?.[0];t&&d(t)},ref:m})}),b]})}if(e.type===`Consent`)return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(i,{id:s,name:e.key,label:e.consentText||e.label,checked:t===!0,disabled:o,"aria-invalid":v,"aria-describedby":_,onChange:e=>u(e.target.checked),ref:m}),b]});let S=zn[e.type],C=e.type===`LongText`&&!e.secret?/* @__PURE__ */ G(h,{controlOnly:!0,className:`wui-chat-input-control`,id:s,name:e.key,rows:3,value:Wn(t),placeholder:e.placeholder??void 0,maxLength:e.maxLength??void 0,disabled:o,"aria-required":y,"aria-invalid":v,"aria-describedby":_,onChange:e=>u(e.target.value),ref:m}):/* @__PURE__ */ G(c,{controlOnly:!0,className:`wui-chat-input-control`,id:s,name:e.key,type:e.secret?`password`:S?.type,autoComplete:e.secret?`off`:S?.autoComplete,value:Wn(t),placeholder:e.placeholder??void 0,maxLength:e.maxLength??void 0,disabled:o,"aria-required":y,"aria-invalid":v,"aria-describedby":_,onChange:e=>u(e.target.value),ref:m});return/* @__PURE__ */ K(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ G(`label`,{className:`form-label`,htmlFor:s,children:e.label}),x,C,b]})}function Xn({part:e,turn:t}){let{labels:r,features:i}=t,a=w(),[o,s]=O(()=>Un(e.fields)),[c,l]=O({}),[u,d]=O(null),[f,p]=O(!1),[m,h]=O(null),[g,_]=O({}),v=D({}),y=D({});C(()=>{m?.key!==void 0&&v.current[m.key]?.focus()},[m]);let b=e.fields.length===1?e.fields[0]:void 0,x=i.LeadShortcuts&&b!==void 0&&!b.required,S=i.LeadShortcuts&&e.cancellable,T=Object.keys(g).find(e=>g[e]?.status===`uploading`);function E(t){return e.fields.find(e=>t[e.key])?.key??e.fields[0]?.key}function k(e,t){s(n=>({...n,[e]:t}))}function A(e){let t=o[e];if(t===void 0)throw Error(`The input form has no value for field "${e}".`);return t}async function j(e,n){let i={};y.current[e]=i,_(t=>({...t,[e]:{status:`uploading`,name:n.name}})),k(e,``),l(t=>({...t,[e]:void 0}));let a;try{a=await t.uploadInputFile(n)}catch{if(y.current[e]!==i)return;_(t=>({...t,[e]:{status:`failed`,name:n.name}})),l(t=>({...t,[e]:r.attachmentFailed}));return}y.current[e]===i&&(k(e,a),_(t=>({...t,[e]:{status:`ready`,name:n.name}})),l(t=>({...t,[e]:void 0})))}function M(e){y.current[e]=null,k(e,``),_(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),l(t=>({...t,[e]:void 0}))}async function N(n){if(n.preventDefault(),T!==void 0){l(e=>({...e,[T]:r.attachmentUploading})),h({key:T});return}let i={};for(let t of e.fields){let e=t.type===`File`&&g[t.key]?.status===`failed`?r.attachmentFailed:qn(t,A(t.key),r);e&&(i[t.key]=e)}if(d(null),l(i),Object.keys(i).length>0){h({key:E(i)});return}p(!0);let a=Object.fromEntries(e.fields.map(e=>[e.key,Jn(e,A(e.key))])),o;try{o=await t.answerInput(e.requestId,a)}catch{o={ok:!1,errors:{},message:r.errorGeneric}}if(o.ok)return;let s=Object.entries(o.errors).filter(([t])=>!e.fields.some(e=>e.key===t)).map(([,e])=>e),c=[o.message,...s].filter(Boolean);l(o.errors),d(c.length>0?c.join(` `):null),p(!1),h({key:E(o.errors)})}return/* @__PURE__ */ K(`form`,{className:`wui-chat-input-form`,noValidate:!0,"aria-label":e.title||e.submitLabel,onSubmit:N,children:[e.title&&/* @__PURE__ */ G(`h3`,{className:`wui-chat-input-title`,children:e.title}),e.fields.map(e=>/* @__PURE__ */ G(Yn,{field:e,value:A(e.key),error:c[e.key],file:g[e.key],disabled:f,id:`${a}-${e.key}`,labels:r,onChange:t=>k(e.key,t),onFile:t=>j(e.key,t),onRemove:()=>M(e.key),controlRef:t=>{v.current[e.key]=t}},e.key)),/* @__PURE__ */ G(`p`,{className:`wui-chat-input-error`,role:`status`,hidden:!u,children:u}),/* @__PURE__ */ K(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ G(n,{type:`submit`,disabled:f,children:f?r.inputSubmitting:e.submitLabel}),x&&/* @__PURE__ */ G(n,{variant:`soft`,disabled:f,onClick:()=>t.skipInput(e.requestId),children:r.skip}),S&&/* @__PURE__ */ G(n,{variant:`link`,type:`button`,disabled:f,onClick:()=>t.cancelLead(),children:r.cancel})]}),e.allowTyped&&/* @__PURE__ */ G(`p`,{className:`wui-chat-input-typed`,children:r.typeAnswer})]})}function Zn({part:e,turn:t}){let n=`wui-chat-input-request wui-chat-input-request--${e.state.toLowerCase()}`;return/* @__PURE__ */ G(`div`,{className:n,children:e.state===`Open`?/* @__PURE__ */ G(Xn,{part:e,turn:t},e.requestId):/* @__PURE__ */ G(`p`,{className:`wui-chat-input-summary`,children:Vn(e,t.labels)})})}var Qn=/* @__PURE__ */ new Set([`ActionLimitReached`,`ConversationTooLong`]),$n={AssistantUnavailable:`danger`},er={info:`info`,warning:`alert-triangle`,danger:`alert-circle`};function tr({part:e,turn:t}){let n=$n[e.code]??(Qn.has(e.code)?`warning`:`info`),r=e.code===`NeedsNewerApp`?t.labels.needsNewerApp:e.text;return/* @__PURE__ */ K(`div`,{className:`wui-chat-notice wui-chat-notice--${n}`,role:n===`danger`?`alert`:`status`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-notice-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(s,{name:er[n],size:16})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-notice-text`,children:r})]})}var nr=y({resolveLink:null,linkComponent:void 0});function rr(){return S(nr)}var ir={Primary:`wui-chat-quick-reply--primary`,Cta:`wui-chat-quick-reply--cta`};function ar(e){return e===null?void 0:ir[e]}function or(e,t){return e.action===`Navigate`?!!t.features.LinkHandoff:e.action!==`Open`||!!e.target&&!!t.openTarget}function sr(e,t){return[`wui-chat-quick-reply`,ar(e.variant),t].filter(Boolean).join(` `)}function cr(e,t,n){return e.target===null||!V(e.target,t.handoffHosts)?null:n?n(e.target)??null:e.target}function lr(e){return e.icon?/* @__PURE__ */ G(`span`,{className:`wui-chat-quick-reply-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(s,{name:e.icon,size:16})}):null}function ur(e,t,n,r){return/* @__PURE__ */ K(`button`,{type:`button`,className:r,style:n,onClick:n=>{if(e.action===`Open`){if(!t.openTarget)throw Error(`An Open quick reply needs turn.openTarget, and the turn has none.`);e.target&&t.openTarget(e.target)}else t.chooseQuickReply(e),n.currentTarget.closest(`.wui-chat`)?.querySelector(`.wui-chat-input`)?.focus()},children:[lr(e),/* @__PURE__ */ G(`span`,{className:`wui-chat-quick-reply-label`,children:e.label})]},e.id)}function dr(e,t,n){if(!t.features.SuggestedReplies||!t.isLast||t.busy||e.replies.length===0)return null;let r=e.placement===`Composer`?`wui-chat-quick-replies wui-chat-quick-replies--composer`:`wui-chat-quick-replies`,i=e.replies.filter(e=>or(e,t));if(i.length===0)return null;let a=t.openTarget??(e=>globalThis.location.assign(e)),o=e.placement===`Composer`?void 0:i.find(e=>e.id===j&&e.action===`Send`);return/* @__PURE__ */ K(`div`,{className:o?`${r} wui-chat-quick-replies--offer`:r,role:`group`,"aria-label":t.labels.quickReplies,children:[o&&/* @__PURE__ */ K(`div`,{className:`wui-chat-offer`,children:[/* @__PURE__ */ G(`div`,{className:`wui-chat-offer-title`,children:o.label}),ur(o,t,{"--wui-chat-i":0},sr({...o,variant:`Primary`},`wui-chat-offer-action`))]}),i.map((e,r)=>{if(e===o)return null;let i={"--wui-chat-i":r};if(e.action===`Navigate`){let r=cr(e,t,n);if(r===null)return/* @__PURE__ */ G(`span`,{className:`wui-chat-quick-reply-label`,style:i,children:e.label},e.id);if(typeof t.beginHandoff!=`function`)return null;let o=()=>a(r);return/* @__PURE__ */ K(`button`,{type:`button`,disabled:t.handoffPause,className:sr(e,t.handoffPause?`wui-chat-quick-reply--quiet`:void 0),style:i,onClick:()=>t.beginHandoff(e,o),children:[lr(e),/* @__PURE__ */ G(`span`,{className:`wui-chat-quick-reply-label`,children:t.handoffPause?t.labels.handoffMoment:e.label})]},e.id)}return ur(e,t,i,sr(e,o?`wui-chat-quick-reply--quiet`:void 0))})]})}function fr({part:e,turn:t}){let{resolveLink:n}=rr(),r=dr(e,t,n),i=D(null),[a,o]=O(null),s=D(null);return T(()=>{r?i.current=r:i.current&&=(o(i.current),null)}),C(()=>{if(!a)return;let e=s.current,t=e?.ownerDocument.defaultView;if(!t||!e){o(null);return}let n=Number.parseFloat(t.getComputedStyle(e).animationDuration)*1e3;if(!(n>0)){o(null);return}let r=t.setTimeout(()=>o(null),n);return()=>t.clearTimeout(r)},[a]),r||(a?v(a,{ref:s,className:`${a.props.className} wui-chat-quick-replies--leaving`,"aria-hidden":`true`}):null)}var pr=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]);function mr(e){return e.value===null||e.value===void 0||e.value===``?De:e.type===`Date`?Oe(e.value,{pattern:`day`}):e.type===`DateTimeUtc`?ke(e.value):ne(e.value,e.type,null)}function hr({part:e,turn:t}){let r=w(),i=t.features.FigureText,a=e.fields.map((e,t)=>({key:String(t),label:/* @__PURE__ */ G(X,{text:e.label,enabled:i}),value:/* @__PURE__ */ G(`span`,{className:pr.has(e.type)?`wui-chat-num`:void 0,children:/* @__PURE__ */ G(X,{text:mr(e),enabled:i})})})),s=!!e.target&&typeof t.openRecord==`function`;return/* @__PURE__ */ K(`article`,{className:`wui-chat-record`,"aria-labelledby":r,children:[/* @__PURE__ */ K(`header`,{className:`wui-chat-record-head`,children:[/* @__PURE__ */ G(`h3`,{className:`wui-chat-record-title`,id:r,children:/* @__PURE__ */ G(X,{text:e.title,enabled:i})}),e.subtitle?/* @__PURE__ */ G(`span`,{className:`wui-chat-record-subtitle`,children:/* @__PURE__ */ G(X,{text:e.subtitle,enabled:i})}):null]}),e.fields.length>0?/* @__PURE__ */ G(o,{className:`wui-chat-record-fields`,columns:1,size:`sm`,layout:`summary`,items:a}):null,s?/* @__PURE__ */ G(`div`,{className:`wui-chat-record-actions`,children:/* @__PURE__ */ G(n,{className:`wui-chat-record-open`,size:`sm`,type:`button`,"aria-label":t.labels.recordOpenFor(ue(e.title)),onClick:()=>t.openRecord?.(e),children:t.labels.recordOpen})}):null]})}var gr=/^https?:\/\//i;function _r({source:e}){return/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-source-marker`,children:e.marker}),/* @__PURE__ */ G(`span`,{className:`wui-chat-source-title`,children:e.title})]})}function vr({part:e,turn:t}){return!t.features.Sources||e.sources.length===0?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-sources`,children:[/* @__PURE__ */ G(`p`,{className:`wui-chat-sources-label`,children:t.labels.sources}),/* @__PURE__ */ G(`ul`,{className:`wui-chat-sources-list`,"aria-label":t.labels.sources,children:e.sources.map(e=>/* @__PURE__ */ G(`li`,{children:gr.test(e.url??``)?/* @__PURE__ */ G(`a`,{className:`wui-chat-source`,href:e.url??void 0,target:`_blank`,rel:`noopener noreferrer`,"aria-label":t.labels.openSource(e.title),"data-marker":e.marker,children:/* @__PURE__ */ G(_r,{source:e})}):/* @__PURE__ */ G(`span`,{className:`wui-chat-source`,tabIndex:-1,"data-marker":e.marker,children:/* @__PURE__ */ G(_r,{source:e})})},e.marker))})]})}var yr=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]),br=50,xr=25,Sr={align:`num`},Cr={rowHeader:!0};function wr(e,t,n,r){return e==null?null:t.type===`Text`&&e!==``?/* @__PURE__ */ G(X,{text:e,enabled:r}):ne(e,t.type,n)}function Tr({part:e,turn:t}){let[r,i]=O(!1),o=t.features.FigureText,s=e.columns.map((e,t)=>({key:`c${t}`,label:/* @__PURE__ */ G(X,{text:e.label,enabled:o}),...yr.has(e.type)?Sr:{},...t===0&&e.type===`Text`?Cr:{}})),c=e.rows.map((t,n)=>{let r={id:n};return e.columns.forEach((n,i)=>{r[`c${i}`]=wr(t[i],n,e.currency,o)}),r}),l=r?c:c.slice(0,xr),u=l.length>br,d=e.title?Sn(e.title,o):t.labels.table;return/* @__PURE__ */ K(`figure`,{className:`wui-chat-table`,children:[e.title?/* @__PURE__ */ G(`figcaption`,{className:`wui-chat-table-title`,children:/* @__PURE__ */ G(X,{text:e.title,enabled:o})}):null,/* @__PURE__ */ G(`div`,{className:`table-wrap wui-chat-table-wrap`,role:`region`,tabIndex:0,"aria-label":d,children:/* @__PURE__ */ G(a,{density:`cozy`,columns:s,rows:l,rowKey:(e,t)=>t,empty:t.labels.tableEmpty,...u?{maxHeight:360}:{},virtual:u})}),!r&&c.length>xr&&/* @__PURE__ */ G(n,{variant:`soft`,tone:`primary`,size:`sm`,className:`wui-chat-table-more`,onClick:()=>i(!0),children:t.labels.tableShowAll(c.length)})]})}var Er=/* @__PURE__ */ new Set([`Visitor`,`Customer`]),Dr=/^\d+$/;function Or({part:e,message:t,turn:n}){let{resolveLink:r,linkComponent:i}=rr(),a=n.features.FigureText,o=n.features.Sources===!0;if(Er.has(t.author.kind))return/* @__PURE__ */ G(`div`,{className:t.restored?`wui-chat-bubble`:`wui-chat-bubble wui-chat-part-enter`,children:/* @__PURE__ */ G(X,{text:e.text,enabled:a})});let s=n.handoffHosts,c=e=>V(e,s)?e:r?r(e):null,l=o&&n.openCitation?e=>n.openCitation?.(Number(e)):void 0,d=o?n.isCitation??(e=>Dr.test(e)):()=>!1;return/* @__PURE__ */ G(u,{value:e.text,links:`app`,headings:`text`,className:t.restored?`wui-chat-text`:`wui-chat-text wui-chat-part-enter`,resolveLink:c,linkComponent:i,isCitation:d,...a?{figureText:le}:{},...l?{onOpenCitation:l}:{}})}function kr({part:e,turn:r}){let{labels:i}=r,a=i.ticketStatus(e.status);return/* @__PURE__ */ K(`article`,{className:`wui-chat-ticket`,"aria-label":i.ticketAria(e.number),children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-ticket-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(s,{name:`tag`,size:20})}),/* @__PURE__ */ K(`div`,{className:`wui-chat-ticket-body`,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-ticket-head`,children:[/* @__PURE__ */ G(`b`,{className:`wui-chat-ticket-number`,children:i.ticketAria(e.number)}),a&&/* @__PURE__ */ G(t,{className:`wui-chat-ticket-status`,tone:st(e.status),children:a})]}),/* @__PURE__ */ G(`strong`,{className:`wui-chat-ticket-title`,children:e.subject})]}),r.openTicket&&/* @__PURE__ */ G(n,{variant:`outline`,size:`sm`,className:`wui-chat-ticket-open`,onClick:()=>r.openTicket?.(e),children:i.ticketView})]})}var Ar=40,Z=null;function jr({part:e,turn:t}){let[n,r]=O(!1),[i,a]=O(!1),[o,c]=O(!1),[l,u]=O(!1),[d,f]=O(0),p=D(null),m=D(null),h=D(!1),g=E(()=>fe(`${e.attachmentId}|${e.durationMs}`,Ar).map((e,t)=>({id:`bar-${t}`,position:t,height:e})),[e.attachmentId,e.durationMs]),_=x(()=>{p.current?.pause(),Z===_&&(Z=null),a(!1)},[]);if(C(()=>(h.current=!0,()=>{h.current=!1,p.current?.pause(),m.current&&URL.revokeObjectURL(m.current),Z===_&&(Z=null)}),[_]),!t.features.VoiceClips)return e.transcript?/* @__PURE__ */ G(`p`,{className:`wui-chat-clip-transcript`,children:e.transcript}):null;async function v(){if(i)_();else{r(!0),c(!1);try{if(!p.current){let n=await t.readAttachment(e.attachmentId);if(!h.current)return;m.current=URL.createObjectURL(new Blob([n]));let r=new Audio(m.current);r.addEventListener(`timeupdate`,()=>f(r.currentTime)),r.addEventListener(`ended`,()=>{a(!1),f(0),r.currentTime=0,Z===_&&(Z=null)}),r.addEventListener(`error`,()=>{c(!0),a(!1)}),p.current=r}Z?.(),await p.current.play(),Z=_,a(!0)}catch{c(!0)}finally{h.current&&r(!1)}}}let y=e.durationMs/1e3,b=Math.floor((y>0?Math.min(1,d/y):0)*Ar);return/* @__PURE__ */ K(`div`,{className:`wui-chat-clip`,role:`group`,"aria-label":t.labels.voiceClip,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-clip-row`,children:[/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-clip-play`,"aria-label":i?t.labels.voiceClipPause:t.labels.voiceClipPlay,"aria-busy":n,disabled:n,onClick:v,children:/* @__PURE__ */ G(s,{name:i?`pause`:`play`,size:16,"aria-hidden":`true`})}),/* @__PURE__ */ G(`div`,{className:`wui-chat-clip-wave`,"aria-hidden":`true`,children:g.map(({id:e,position:t,height:n})=>{let r={"--wui-chat-bar-height":`${Math.round(n*100)}%`};return/* @__PURE__ */ G(`span`,{className:t<b?`wui-chat-clip-bar wui-chat-clip-bar--played`:`wui-chat-clip-bar`,style:r},e)})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-clip-time`,children:t.labels.voiceClipTime(re(d),re(Math.max(1,Math.round(y))))})]}),o&&/* @__PURE__ */ G(`p`,{className:`wui-chat-clip-error`,role:`status`,children:t.labels.voiceClipFailed}),e.transcript?/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-clip-toggle`,"aria-expanded":l,onClick:()=>u(!l),children:l?t.labels.voiceClipHideTranscript:t.labels.voiceClipShowTranscript}),l&&/* @__PURE__ */ G(`p`,{className:`wui-chat-clip-transcript`,children:e.transcript})]}):null]})}function Mr(e,t){return e.kind===t}function Q(e,t){function n(n){if(!Mr(n.part,e))throw Error(`renderer for ${e} received a ${n.part.kind} part`);return b(t,{part:n.part,message:n.message,turn:n.turn})}return n}var Nr=/* @__PURE__ */ new WeakMap;function Pr(e,t){let n=Nr.get(t)??/* @__PURE__ */ new Map,r=n.get(e);if(r)return r;function i(n){if(!Mr(n.part,e))throw Error(`renderer for ${e} received a ${n.part.kind} part`);return b(t,{part:n.part,message:n.message,turn:n.turn})}return n.set(e,i),Nr.set(t,n),i}var Fr={Text:Q(`Text`,Or),Sources:Q(`Sources`,vr),QuickReplies:Q(`QuickReplies`,fr),InputRequest:Q(`InputRequest`,Zn),Action:Q(`Action`,xn),Notice:Q(`Notice`,tr),Table:Q(`Table`,Tr),Chart:Q(`Chart`,En),Figures:Q(`Figures`,Nn),RecordCard:Q(`RecordCard`,hr),Image:Q(`Image`,Rn),File:Q(`File`,Pn),Ticket:Q(`Ticket`,kr),Handoff:Q(`Handoff`,In),VoiceClip:Q(`VoiceClip`,jr)};function $(e,t){let n=t?.[e];return n?Pr(e,n):Fr[e]}function Ir(e){return{Text:$(`Text`,e),Sources:$(`Sources`,e),QuickReplies:$(`QuickReplies`,e),InputRequest:$(`InputRequest`,e),Action:$(`Action`,e),Notice:$(`Notice`,e),Table:$(`Table`,e),Chart:$(`Chart`,e),Figures:$(`Figures`,e),RecordCard:$(`RecordCard`,e),Image:$(`Image`,e),File:$(`File`,e),Ticket:$(`Ticket`,e),Handoff:$(`Handoff`,e),VoiceClip:$(`VoiceClip`,e)}}var Lr=48,Rr={Visitor:`you`,Customer:`you`,Agent:`agent`,Assistant:`assistant`,Script:`assistant`,System:`assistant`};function zr(e,t){let n=e.author.kind;return e.author.displayName&&n!==`Visitor`&&n!==`Customer`?e.author.displayName:t[Rr[n]??`assistant`]}function Br(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r!==void 0&&t(r))return n}return-1}function Vr(e,t){let n=/* @__PURE__ */ new Map,r=[];for(let i of e){let e=t(i),a=n.get(e)??0;n.set(e,a+1),r.push({key:`${e}#${a}`,item:i})}return r}function Hr({chat:e,labels:t,renderers:r,layoutParts:i,loader:a,motion:o,onOpenAttachment:s,onOpenTarget:c,onOpenTicket:l,onNavigate:u}){let d=D(null),f=D(!0),p=D(/* @__PURE__ */ new Map),m=E(()=>Ir(r),[r]),h=u??e.onNavigate,g=e.pending?.authorKind,v=g===`Agent`||g===`Customer`?`None`:a===`Orb`?`Orb`:`Assistant`,y=e.messages.at(-1),b=e.messages.find(e=>!(e.streaming&&e.parts.length===0)),x=e.greeting&&b&&(b.author.kind===`Visitor`||b.author.kind===`Customer`)?{id:`greeting`,createdDateTimeUtc:b.createdDateTimeUtc,author:{kind:`Assistant`,displayName:null,avatarUrl:null},parts:[{kind:`Text`,text:e.greeting}],sequence:null,rating:null,ratingNote:null,stored:!1,streaming:!1,restored:!1}:null,S=x?[x,...e.messages]:e.messages,w=S.filter(e=>!(e.streaming&&e.parts.length===0)),T=!e.streaming&&(e.turnError!==null||e.stopped),O=e.turnError?.code===`daily_limit`,k=typeof e.turnError?.code==`string`&&e.turnError.code.endsWith(`feature_off`),A=e.pending?.typing===!0,j=`${y?Gt(y):``}|${e.thinking}|${A}|${T}`,M=Br(e.messages,e=>e.author.kind===`Visitor`&&e.stored),N=e.profile?.experience.pacing,P=e.profile?.assistant.name??``;C(()=>{if(!j)return;let e=Wt(d.current);e&&(e.scrollTop=e.scrollHeight,f.current=!0)},[j]),C(()=>{let e=d.current;if(!e||typeof ResizeObserver!=`function`)return;let t=null,n=()=>{t&&(f.current=t.scrollHeight-t.scrollTop-t.clientHeight<=Lr)},r=new ResizeObserver(()=>{let r=Wt(e);r!==t&&(t?.removeEventListener(`scroll`,n),t=r,t?.addEventListener(`scroll`,n,{passive:!0})),t&&f.current&&(t.scrollTop=t.scrollHeight)});return r.observe(e),()=>{t?.removeEventListener(`scroll`,n),r.disconnect()}},[]);function F(e,t){p.current.get(e)?.querySelector(`[data-marker="${t}"]`)?.focus()}function I(e,t,n,r){let i=m[n.kind];return/* @__PURE__ */ G(`div`,{className:`wui-chat-part wui-chat-part--${n.kind.toLowerCase()}`,children:/* @__PURE__ */ G(i,{part:n,message:e,turn:t})},r)}return/* @__PURE__ */ G(`div`,{role:`log`,"aria-live":`polite`,"aria-label":t.thread,children:/* @__PURE__ */ K(`ol`,{ref:d,className:`wui-chat-thread`,children:[S.map((n,r)=>{if(n.streaming&&n.parts.length===0)return null;let a=te(e.session,{messageId:n.id,labels:t,openAttachment:s??(t=>Ht(e.client,t)),openTarget:c??Ut,...l?{openTicket:l}:{},openCitation:e=>F(n.id,e),onNavigate:h}),o=n===x,u=x?r-1:r,d=w[w.indexOf(n)-1],f=n.author.kind===`Agent`&&d?.author.kind===`Agent`&&(d.author.displayName??``)===(n.author.displayName??``),m=i?i(n):null,g=z(n.createdDateTimeUtc,t),v=d===void 0||z(d.createdDateTimeUtc,t)!==g;return/* @__PURE__ */ K(_,{children:[v?/* @__PURE__ */ G(`li`,{className:`wui-chat-day`,role:`presentation`,children:/* @__PURE__ */ G(`span`,{children:g})}):null,/* @__PURE__ */ K(`li`,{ref:e=>{e?p.current.set(n.id,e):p.current.delete(n.id)},className:`wui-chat-message wui-chat-message--${n.author.kind.toLowerCase()}`,"aria-busy":n.streaming?`true`:void 0,"data-restored":n.restored?``:void 0,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-author visually-hidden`,children:`${zr(n,t)}: `}),f?null:/* @__PURE__ */ G(At,{author:n.author,labels:t}),/* @__PURE__ */ G(`div`,{className:`wui-chat-message-body`,children:m?Vr(m,e=>Array.isArray(e)?`group`:`part`).map(({key:e,item:t})=>/* @__PURE__ */ G(`div`,{className:`wui-chat-part-group`,children:Vr(Array.isArray(t)?t:[t],e=>e.kind).map(({key:e,item:t})=>I(n,a,t,e))},e)):Vr(n.parts,e=>e.kind).map(({key:e,item:t})=>I(n,a,t,e))}),o?null:/* @__PURE__ */ G(`div`,{className:`wui-chat-message-actions`,children:/* @__PURE__ */ G(Xt,{chat:e,message:n,labels:t,isLast:n===y,isLastVisitor:!o&&u===M})})]})]},n.id)}),/* @__PURE__ */ G(kt,{chat:e,labels:t}),A&&/* @__PURE__ */ G(`li`,{className:`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`,children:/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-slot`,children:/* @__PURE__ */ G(dn,{motion:o??`On`,mark:v})})}),e.thinking&&/* @__PURE__ */ G(`li`,{className:`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`,children:/* @__PURE__ */ G(`div`,{className:`wui-chat-loader-slot`,children:/* @__PURE__ */ G(un,{style:a??`Steps`,steps:e.steps,phrases:N?.thinkingPhrases??[],intervalMs:N?.phraseIntervalMs??2500,announce:t.preparingAnswer(P),motion:o??`On`})})}),T&&/* @__PURE__ */ K(`li`,{className:`wui-chat-message wui-chat-message--system wui-chat-message--error`,children:[O?/* @__PURE__ */ K(`p`,{className:`wui-chat-error wui-chat-error--info`,role:`status`,children:[e.turnError?.message,e.turnError?.resetsDateTimeUtc?` ${t.dailyLimitRefresh(_t(e.turnError.resetsDateTimeUtc))}`:``]}):/* @__PURE__ */ G(`p`,{className:`wui-chat-error`,role:`alert`,children:e.turnError?.message??t.stopped}),e.features.Retry&&!O&&!k&&/* @__PURE__ */ G(`div`,{className:`wui-chat-message-actions`,children:/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.retry().catch(e=>globalThis.reportError?.(e)),children:t.retry})})]})]})})}var Ur=e=>e===`Assistant`||e===`Script`||e===`Agent`;function Wr(e,t,n){if(t){e.wasLoading=!0;for(let t of n)e.seen.add(t.id);return[]}if(e.wasLoading||!e.seeded){e.wasLoading=!1,e.seeded=!0;for(let t of n)e.seen.add(t.id);return[]}let r=[];for(let t of n)e.seen.has(t.id)||(e.seen.add(t.id),r.push(t));return r}function Gr(e){let t=e.features.Sounds?e.profile?.experience.sound??null:null,n=D(null),r=D(e);r.current=e;let i=D(e.open),a=D({seen:/* @__PURE__ */ new Set,seeded:!1,wasLoading:!1}),o=t!==null&&(t.open||t.sent||t.reply||t.vibrate);C(()=>{if(!o)return;let e=he(t,zt);return n.current=e,e.setMuted(r.current.muted),()=>{e.destroy(),n.current=null}},[o,t]);let{open:s,loading:c,messages:l,muted:u}=e;C(()=>{n.current?.setMuted(u)},[u]),C(()=>{let e=n.current,o=i.current;i.current=s;let u=Wr(a.current,c,l);if(e){s&&!o&&e.play(`open`);for(let n of u){if(n.restored||n.parts.some(e=>e.kind===`Notice`))continue;let i=n.author.kind;i===`Visitor`?n.stored||e.play(`sent`):Ur(i)&&(e.play(`reply`),t?.vibrate&&Ce(t.vibrateMs,r.current.muted))}}},[s,c,l,t])}function Kr({chat:e,labels:t,layout:n,onClose:r,panelId:i,inputRef:a,ariaLabelOverride:o,renderers:c,layoutParts:l,loader:u,motion:d,onOpenAttachment:f,onOpenTarget:p,onOpenTicket:m,onNavigate:h,resolveLink:g=null,linkComponent:_,onSwitch:v,open:y=!0,renderEmpty:b,sendIcon:x=`arrow-up`}){let[S,C]=O(`chat`),w=E(()=>({resolveLink:g,linkComponent:_}),[g,_]);Gr(e);let{features:T}=e,D=e.profile,k=S===`history`&&T.History===!0,A=e.messages.length>0,j=n===`launcher`||n===`docked`,M=D?.experience.sound,N=!!(T.Sounds&&M?.muteControl),P=j?`dialog`:`region`,F=o??D?.assistant.name??t.panelTitle,I=T.PanelSwitch===!0,L=e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`),ee=n===`full-page`||L,te=I&&typeof v==`function`&&(n===`docked`||n===`full-page`),R=n===`full-page`&&I&&typeof r==`function`;function z(){C(`chat`),r?.()}function ne(){if(e.profileError)return/* @__PURE__ */ G(`p`,{className:`wui-chat-profile-error`,role:`alert`,children:e.profileError.message});if(!D&&(n===`full-page`||n===`embedded`)||e.loading)return/* @__PURE__ */ G(`p`,{role:`status`,"aria-busy":`true`,children:t.loadingConversation});if(e.loadError)return/* @__PURE__ */ G(`p`,{className:`wui-chat-profile-error`,role:`alert`,children:e.loadError.message});if(!A){let n=/* @__PURE__ */ K(W,{children:[/* @__PURE__ */ G(Ot,{chat:e,labels:t,onOpenTicket:m}),T.History&&/* @__PURE__ */ G(Ct,{chat:e,labels:t,open:y})]});return b?b({chat:e,labels:t,open:y,defaultEmpty:n}):n}return/* @__PURE__ */ G(nr.Provider,{value:w,children:/* @__PURE__ */ G(Hr,{chat:e,labels:t,renderers:c,layoutParts:l,loader:u,motion:d,onOpenAttachment:f,onOpenTarget:p,onOpenTicket:m,onNavigate:h})})}return/* @__PURE__ */ K(`section`,{id:i,className:`wui-chat-panel`,role:P,"aria-label":F,children:[/* @__PURE__ */ K(`header`,{className:`wui-chat-header`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-orb`,"aria-hidden":`true`}),/* @__PURE__ */ K(`div`,{className:`wui-chat-header-text`,children:[/* @__PURE__ */ G(`strong`,{className:`wui-chat-title`,children:D?.assistant.name??``}),/* @__PURE__ */ G(`span`,{className:`wui-chat-status`,children:lt(e,t)??t.headerStatus})]}),/* @__PURE__ */ K(`div`,{className:`wui-chat-header-actions`,children:[!k&&/* @__PURE__ */ G(et,{chat:e,labels:t}),T.History&&(k?/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.backToChat,title:t.backToChat,onClick:()=>C(`chat`),children:/* @__PURE__ */ G(s,{name:`arrow-left`,size:18,"aria-hidden":`true`})}):/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.history,title:t.history,onClick:()=>C(`history`),children:/* @__PURE__ */ G(s,{name:`history`,size:18,"aria-hidden":`true`})})),N&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":e.muted?t.unmuteSounds:t.muteSounds,title:e.muted?t.unmuteSounds:t.muteSounds,onClick:()=>e.session.setMuted(!e.muted),children:/* @__PURE__ */ G(s,{name:e.muted?`volume-mute`:`volume-high`,size:18,"aria-hidden":`true`})}),!k&&ee&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.newChat,title:t.newChat,disabled:e.streaming||e.thinking,onClick:()=>e.newConversation(),children:/* @__PURE__ */ G(s,{name:`plus`,size:18,"aria-hidden":`true`})}),te&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn wui-chat-icon-btn--switch`,"aria-label":n===`docked`?t.openFullScreen:t.openSidePanel,title:n===`docked`?t.openFullScreen:t.openSidePanel,disabled:e.streaming||e.thinking,onClick:()=>v(),children:/* @__PURE__ */ G(s,{name:n===`docked`?`maximize-4`:`panel-left-open`,size:18,"aria-hidden":`true`})}),(j||R)&&/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-icon-btn wui-chat-close-btn`,"aria-label":t.close,title:t.close,onClick:z,children:/* @__PURE__ */ G(s,{name:`x`,size:18,"aria-hidden":`true`})})]})]}),/* @__PURE__ */ G(`div`,{className:`wui-chat-body`,children:k?/* @__PURE__ */ G(it,{chat:e,labels:t,onOpen:()=>C(`chat`)}):ne()}),!k&&/* @__PURE__ */ K(`div`,{className:`wui-chat-foot`,children:[/* @__PURE__ */ G(ft,{chat:e,labels:t}),/* @__PURE__ */ G(Ge,{chat:e,labels:t,maxLength:D?.limits.maxMessageLength??4e3,inputRef:a,sendIcon:x}),/* @__PURE__ */ G(tt,{chat:e,labels:t})]})]})}function qr(e,t){let n=D(!1);C(()=>{n.current||(n.current=!0,typeof t?.conversationId==`string`&&t.conversationId!==``&&e.openConversation(t.conversationId).catch(e=>globalThis.reportError?.(e)),typeof t?.draft==`string`&&t.draft!==``&&e.session.open({draft:t.draft}))},[e,t])}function Jr(e,t){let[n,r]=O(!1);return C(()=>{let n=Te(e,t??null);r(n.reduced);let i=n.subscribe(()=>r(n.reduced));return()=>{i(),n.destroy()}},[e,t]),n}function Yr({chat:e,labels:t,renderers:n,layoutParts:r,loader:i,motion:a=`On`,onOpenAttachment:o,onOpenTarget:s,onNavigate:c,resolveLink:l,linkComponent:u,className:d,style:f,theme:p,look:m,onOpenSidePanel:h,onClose:g,renderEmpty:_,handoff:v}){let y=D(null);qr(e,v??null);let b=e.features.PanelSwitch===!0&&typeof h==`function`?()=>{let t={conversationId:e.conversationId,draft:y.current?.value??``,from:`full-page`,to:`docked`};xe(()=>h(t),{target:`docked`}).catch(e=>globalThis.reportError?.(e))}:void 0;return/* @__PURE__ */ G(Xr,{layout:`full-page`,chat:e,labelOverrides:t,renderers:n,layoutParts:r,loader:i,motion:a,onOpenAttachment:o,onOpenTarget:s,onNavigate:c,resolveLink:l,linkComponent:u,className:d,style:f,theme:p,look:m,inputRef:y,onSwitch:b,onClose:g,renderEmpty:_})}function Xr({layout:e,chat:t,labelOverrides:n,renderers:r,layoutParts:i,loader:a,motion:o,onOpenAttachment:s,onOpenTarget:c,onNavigate:l,resolveLink:u=null,linkComponent:d,className:f,style:p,theme:m,look:h,inputRef:g,onSwitch:_,onClose:v,renderEmpty:y}){let b=E(()=>ae(n),[n]),x=E(()=>oe(h),[h]),S=Jr(x,t.profile?.experience??null),C=o===`Reduced`||S?`Reduced`:`On`;if(t.profile!==null&&!t.features.VisitorChat)return null;let w=[`wui-chat`,`wui-chat--${e}`,Kt(C),x.input.sendReveal===`Always`?`wui-chat--send-always`:null,x.input.ring===!1?`wui-chat--input-ring-off`:null,x.panel.replyAvatars===!1?`wui-chat--reply-avatars-off`:null,x.expressive?`wui-chat--expressive`:null,f].filter(Boolean).join(` `),T=x.avatar?{"--wui-chat-avatar":`url(${JSON.stringify(x.avatar)})`,"--wui-chat-typing-mark":`url(${JSON.stringify(x.avatar)})`,...p}:p;return/* @__PURE__ */ G(`div`,{className:w,style:T,"data-state":`open`,"data-theme":m===`auto`?void 0:m,children:/* @__PURE__ */ G(Kr,{chat:t,labels:b,layout:e,sendIcon:x.input.sendIcon,panelId:void 0,renderers:r,layoutParts:i,loader:a,motion:C,onOpenAttachment:s,onOpenTarget:c,onNavigate:l,resolveLink:u,linkComponent:d,inputRef:g,onSwitch:_,onClose:v,renderEmpty:y})})}function Zr({labels:e,...t}){return/* @__PURE__ */ G(Xr,{...t,labelOverrides:e,layout:`embedded`})}var Qr=`a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`;function $r(e){return e!=null&&`focus`in e}function ei(e){let t=D(null);return C(()=>{let n=document.activeElement,r=t.current?.querySelector(Qr);return $r(r)&&r.focus({preventScroll:!0}),()=>{let t=e.current??n;$r(t)&&t.focus({preventScroll:!0})}},[e]),C(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=0,r=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>window.dispatchEvent(new Event(`scroll`)))});return r.observe(e),()=>{cancelAnimationFrame(n),r.disconnect()}},[]),t}function ti({x:e,labels:t,renderAnswer:r,renderFoot:i,askDraft:a,chat:o,close:s,triggerRef:c}){let l=ei(c),{state:u,answer:d,pillVisible:f,resetsDateTimeUtc:p}=e,m=null;if((u===`thinking`||u===`slow`)&&f)m=/* @__PURE__ */ K(`div`,{className:`wui-chat-explain-pill`,role:`status`,children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-explain-pill-dot`,"aria-hidden":`true`}),/* @__PURE__ */ G(`span`,{children:u===`slow`?t.explainSlow:t.thinking})]});else if(u===`answered`)m=/* @__PURE__ */ G(`div`,{className:`wui-chat-explain-answer`,children:r({answer:d,labels:t,close:s})});else if(u===`empty`)m=/* @__PURE__ */ G(`p`,{className:`wui-chat-explain-note`,children:t.explainEmpty});else if(u===`capacity`){let e=_t(p);m=/* @__PURE__ */ G(`p`,{className:`wui-chat-explain-notice wui-chat-explain-notice--info`,role:`status`,children:e?t.explainCapacity(e):t.explainCapacityNoDate})}else u===`error`&&(m=/* @__PURE__ */ K(`div`,{className:`wui-chat-explain-notice wui-chat-explain-notice--error`,role:`alert`,children:[/* @__PURE__ */ G(`p`,{children:t.explainError}),/* @__PURE__ */ G(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.ask(),children:t.explainRetry})]}));let h=typeof a==`string`&&a!==``&&typeof o.session?.open==`function`?a:null;return/* @__PURE__ */ K(`div`,{ref:l,className:`wui-chat-explain`,children:[m,/* @__PURE__ */ K(`div`,{className:`wui-chat-explain-foot`,children:[i?.({close:s}),h!==null&&/* @__PURE__ */ G(n,{className:`wui-chat-explain-more`,size:`sm`,variant:`ghost`,onClick:()=>{s(),o.session.open({draft:h})},children:t.explainAskMore}),/* @__PURE__ */ G(`p`,{className:`wui-chat-explain-note`,children:t.explainNotCounted})]})]})}function ni({chat:e,request:t,renderAnswer:n,label:r,renderFoot:i,askDraft:a,labels:o,placement:c=`auto`,className:l,triggerContent:u}){let d=E(()=>ae(o),[o]),[p,m]=O(!1),h=gt({request:t,enabled:e.features.Explain===!0}),_=D(null),v=D(!1);if(C(()=>{if(!p)return;let e=e=>{let t=e.target;v.current=t instanceof Element&&t.closest(`.wui-chat-panel`)!==null};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[p]),!e.features.Explain)return null;function y(e){!e&&(v.current||document.querySelector(`.wui-chat--docked[data-open=true]`))?v.current=!1:(m(e),e?h.ask():h.reset())}function b(){m(!1),h.reset()}let x=/* @__PURE__ */ K(`button`,{type:`button`,className:[`wui-chat-explain-trigger`,p?`wui-chat-explain-trigger--open`:null].filter(Boolean).join(` `),"aria-haspopup":`dialog`,"aria-label":d.explainTriggerLabel(r),disabled:h.offline,onClick:e=>{_.current=e.currentTarget},children:[/* @__PURE__ */ G(s,{name:`magic-star`,size:14,"aria-hidden":`true`}),u??d.explainTrigger]});return h.offline?/* @__PURE__ */ G(g,{content:d.explainOffline,children:/* @__PURE__ */ G(`span`,{className:`wui-chat-explain-offline`,children:x})}):/* @__PURE__ */ G(f,{trigger:x,title:r,placement:c,open:p,onOpenChange:y,role:`dialog`,className:[`wui-chat-explain-pop`,l].filter(Boolean).join(` `),children:/* @__PURE__ */ G(ti,{x:h,labels:d,renderAnswer:n,renderFoot:i,askDraft:a,chat:e,close:b,triggerRef:_})})}function ri({chat:e,labels:t,enabled:n,onActivate:r}){let i=e.profile?se(e.profile,e.features):null,[a,o]=O(!1),[c,l]=O(!1),[u,d]=O(!1),f=(i?.delaySeconds??0)*1e3;return C(()=>{if(!n||!i||c){o(!1);return}if(u)return;let e=setTimeout(()=>{o(!0),d(!0)},f);return()=>clearTimeout(e)},[n,i,f,c,u]),!a||!i||c?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-nudge`,role:`status`,children:[/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-nudge-text`,onClick:r,children:i.text}),/* @__PURE__ */ G(`button`,{type:`button`,className:`wui-chat-nudge-close`,"aria-label":t.nudgeDismiss,onClick:()=>l(!0),children:/* @__PURE__ */ G(s,{name:`x`,size:14,"aria-hidden":`true`})})]})}function ii(e,t,n,r){C(()=>{let i=e.current;if(!r||!i||!n)return;let a=pe(t,n,i);return()=>a.destroy()},[e,t,n,r])}var ai=620,oi=300,si=`wchat:peeked`,ci=576,li=200;function ui(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function di(e){return e?.querySelector(`:scope > .wui-chat-panel`)??null}function fi(e){let[t,n]=O(()=>globalThis.innerWidth<=e);return C(()=>{let t=()=>n(globalThis.innerWidth<=e);return t(),globalThis.addEventListener(`resize`,t),()=>globalThis.removeEventListener(`resize`,t)},[e]),t}function pi({chat:e,layout:t,labels:n,renderers:r,layoutParts:i,loader:a,motion:o=`On`,onOpenAttachment:c,onOpenTarget:l,onNavigate:u,resolveLink:d=null,linkComponent:f,className:p,style:m,theme:h,icon:g=`chat`,look:_,open:v,defaultOpen:y=!1,onOpenChange:b,position:S=`end`,offsetX:k=24,offsetY:A=24,panelId:j,switchConfig:M=null,renderEmpty:N}){let P=w(),F=j??P,I=E(()=>ae(n),[n]),L=E(()=>oe(_),[_]),ee=e.profile,te=e.features,R=v!==void 0,z=R?v:e.open,ne=Jr(L,ee?.experience??null),re=o===`Reduced`||ne?`Reduced`:`On`,ie=L.panel.motion===`None`?0:oi,B=ee!==null&&te.VisitorChat,V=t===`launcher`||t===`docked`,H=fi(L.phone.maxWidthPx),U=ee?.experience.launcher??null,se=L.launcher.style===`Pill`?`pill`:`round`,ce=L.launcher.labelReveal===`Expand`?`expand`:`bubble`,le=L.launcher.idle===`None`?`none`:ui(L.launcher.idle),ue=L.launcher.entrance===`None`?null:ui(L.launcher.entrance),de=U?.hideWhileOpen===!0||L.expressive===!0,fe=U?.peek===!0,pe=U?.peekSeconds??3,me=e.messages.length>0,he=D(null),ge=D(null),Ce=D(null),we=D(null),Te=D(!1),W=D(z),Ee=D(z),De=D(!1),Oe=D(b);Oe.current=b;let[ke,Ae]=O(z?`open`:`closed`),[je,q]=O(null),[Me,Ne]=O(null),J=je??(ue&&!H?`entering`:`idle`);ii(he,L.avoid,U,t===`launcher`&&B);let Pe=x(e=>{W.current!==e&&(W.current=e,Oe.current?.(e))},[]),Fe=x((t,n)=>{Te.current=t,Pe(t),R||(t?e.session.open({trigger:`manual`}):e.session.close(n))},[R,e.session,Pe]);C(()=>{R&&(v&&!e.open&&e.session.open({trigger:`manual`}),!v&&e.open&&e.session.close(`button`))},[R,v,e.open,e.session]),C(()=>{!R&&y&&e.session.open({trigger:`manual`})},[R,y,e.session]),C(()=>{Pe(e.open)},[e.open,Pe]),C(()=>{if(z){Ae(e=>e===`open`?e:`opening`);let e=setTimeout(()=>Ae(`open`),ai);return()=>clearTimeout(e)}Ae(e=>e===`closed`?e:`closing`);let e=setTimeout(()=>Ae(`closed`),ie);return()=>clearTimeout(e)},[z,ie]),C(()=>{Ee.current!==z&&(Ee.current=z,Ne(z?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`))},[z]),T(()=>{if(ke!==`opening`)return;let e=di(ge.current),t=Ce.current;e&&t&&ve(e,t.getBoundingClientRect())},[ke]),C(()=>{if(!de){q(e=>e===`hidden`?`idle`:e);return}if(z){q(`hidden`);return}if(je!==`hidden`)return;let e=di(ge.current)?.contains(document.activeElement)??!1,t=setTimeout(()=>{De.current=e,q(`idle`)},li);return()=>clearTimeout(t)},[z,de,je]),C(()=>{J===`idle`&&De.current&&(De.current=!1,be(Ce.current))},[J]);let Ie=D(!1);C(()=>{let e=Ie.current;Ie.current=z,z||!e||de||be(Ce.current)},[z,de]),C(()=>{z&&q(e=>e===`peeking`?`idle`:e)},[z]),C(()=>{B&&J===`idle`&&fe&&!ne&&!z&&(globalThis.innerWidth<ci||globalThis.sessionStorage.getItem(si)!==null||(globalThis.sessionStorage.setItem(si,`1`),q(`peeking`)))},[B,J,fe,ne,z]),C(()=>{if(J!==`peeking`)return;let e=setTimeout(()=>q(e=>e===`peeking`?`idle`:e),pe*1e3);return()=>clearTimeout(e)},[J,pe]);let Le=D(Fe);Le.current=Fe,C(()=>{if(!z||!V)return;let e=e=>{e.key===`Escape`&&Le.current(!1,`escape`)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z,V]),C(()=>{let e=di(ge.current);if(!B||!V||!e)return;let t=t=>Se(e,t);return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[B,V]),C(()=>{if(!z||H||!Te.current)return;let e=setTimeout(()=>we.current?.focus(),400);return()=>clearTimeout(e)},[z,H]),C(()=>{let e=di(ge.current);if(!B||!z||!H||!V||!e)return;let t=_e(e,L);return()=>t.destroy()},[B,z,H,V,L]),C(()=>{let e=ge.current?.querySelector(`.wui-chat-thread`);if(B&&z&&H&&V&&me&&e)return ye(e)},[B,z,H,V,me]),C(()=>{if(t!==`docked`||!z||typeof document>`u`)return;let e=document.documentElement,n=document.getElementById(F);e.dataset.wchatDocked=``;let r=null;if(n){let t=()=>e.style.setProperty(`--wchat-docked-width`,`${n.getBoundingClientRect().width}px`);t(),typeof ResizeObserver<`u`&&(r=new ResizeObserver(t),r.observe(n))}return()=>{r?.disconnect(),e.removeAttribute(`data-wchat-docked`),e.style.removeProperty(`--wchat-docked-width`)}},[t,z,F]);let Re=M?.preload,ze=D(!1);if(C(()=>{if(z&&!ze.current){ze.current=!0;try{Promise.allSettled([Promise.resolve(Re?.())])}catch{}}},[z,Re]),!B)return null;let Be=M?()=>{let n={conversationId:e.conversationId,draft:we.current?.value??``,from:t,to:M.target};xe(()=>(Fe(!1,`button`),M.onSwitch(n)),{target:M.target}).catch(e=>globalThis.reportError?.(e))}:void 0,Ve=[`wui-chat`,`wui-chat--${t}`,`wui-chat--${S}`,Kt(re),V&&H?`wui-chat--phone`:null,L.phone.mode===`Sheet`?`wui-chat--sheet`:null,L.input.sendReveal===`Always`?`wui-chat--send-always`:null,L.input.ring===!1?`wui-chat--input-ring-off`:null,L.panel.motion===`Gentle`?`wui-chat--panel-motion-gentle`:null,L.panel.motion===`None`?`wui-chat--panel-motion-none`:null,L.panel.height===`Content`?`wui-chat--panel-height-content`:null,L.panel.replyAvatars===!1?`wui-chat--reply-avatars-off`:null,L.expressive?`wui-chat--expressive`:null,p].filter(Boolean).join(` `),He={...L.avatar?{"--wui-chat-avatar":`url(${JSON.stringify(L.avatar)})`,"--wui-chat-typing-mark":`url(${JSON.stringify(L.avatar)})`}:null,"--wui-chat-offset-x":`${k}px`,"--wui-chat-offset-y":`${A}px`,"--wui-chat-width":`${L.panel.widthPx}px`,"--wui-chat-panel-max-height":`${L.panel.maxHeightPx}px`,"--wui-chat-bottom-gap":`${L.panel.bottomGapPx}px`,"--wui-chat-sheet-height":`${L.phone.sheetHeightDvh}dvh`,"--wui-chat-sheet-max-height":`${L.phone.sheetMaxHeightPx}px`,...m},Ue=[`wui-chat-launcher-wrap`,J===`entering`&&ue?`wui-chat-launcher--entrance-${ue}`:null,J===`idle`&&le!==`none`&&(le!==`ring`||se===`pill`)?`wui-chat-launcher--idle-${le}`:null].filter(Boolean).join(` `),We=[`wui-chat-launcher`,`wui-chat-launcher--${se}`,se===`pill`&&L.launcher.compact?`wui-chat-launcher--compact`:null,L.launcher.mark===`Icon`?null:`wui-chat-launcher--mark-${ui(L.launcher.mark)}`,`wui-chat-launcher--reveal-${ce}`,Me].filter(Boolean).join(` `),Ge=t===`launcher`&&!z&&te.Nudges,Ke=z?I.launcherClose:U?.hoverLabel||I.launcher;return/* @__PURE__ */ K(`div`,{ref:ge,className:Ve,style:He,"data-state":ke,"data-open":z?`true`:`false`,"data-theme":h===`auto`?void 0:h,children:[/* @__PURE__ */ K(`div`,{ref:he,className:Ue,"data-launcher":J,inert:J===`hidden`,onAnimationEnd:e=>{e.target===e.currentTarget&&J===`entering`&&q(`idle`)},children:[/* @__PURE__ */ G(ri,{chat:e,labels:I,enabled:Ge,onActivate:()=>Fe(!0,`launcher`)}),/* @__PURE__ */ K(`button`,{ref:Ce,type:`button`,className:We,"aria-haspopup":`dialog`,"aria-expanded":z,"aria-controls":F,"aria-label":Ke,onClick:()=>Fe(!z,`launcher`),onAnimationEnd:e=>{e.target===e.currentTarget&&Ne(null)},children:[/* @__PURE__ */ G(`span`,{className:`wui-chat-launcher-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ G(s,{name:g,size:24,"aria-hidden":`true`})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-launcher-close`,"aria-hidden":`true`,children:/* @__PURE__ */ G(s,{name:`x`,size:20,"aria-hidden":`true`})}),/* @__PURE__ */ G(`span`,{className:`wui-chat-launcher-label`,children:Ke})]}),/* @__PURE__ */ G(`span`,{className:`wui-chat-launcher-bubble`,"aria-hidden":`true`,children:U?.hoverLabel||I.launcher})]}),/* @__PURE__ */ G(Kr,{chat:e,labels:I,layout:t,sendIcon:L.input.sendIcon,panelId:F,inputRef:we,onClose:()=>Fe(!1,`button`),onSwitch:Be,open:z,renderEmpty:N,renderers:r,layoutParts:i,loader:a,motion:re,onOpenAttachment:c,onOpenTarget:l,onNavigate:u,resolveLink:d,linkComponent:f})]})}function mi({enabled:e,settings:t,look:n,session:r,isOpen:i,panelId:a}){let o=D(i);o.current=i,C(()=>{if(!e||!t)return;let i=we(t,n,{open:()=>r.open({trigger:`auto`}),isOpen:()=>o.current,panelRect:()=>document.getElementById(a)?.getBoundingClientRect()??null});return()=>i.cancel()},[e,t,n,r,a])}function hi(e){let{chat:t,look:n}=e,r=w(),i=E(()=>oe(n),[n]);return mi({enabled:t.features.AutoOpen&&t.profile!==null,settings:t.profile?.experience.autoOpen??null,look:i,session:t.session,isOpen:t.open,panelId:r}),/* @__PURE__ */ G(pi,{...e,layout:`launcher`,panelId:r})}function gi({onOpenFullScreen:e,preloadFullPage:t,...n}){let r=n.chat.features.PanelSwitch===!0&&typeof e==`function`?{onSwitch:e,target:`full-page`,preload:t}:null;return/* @__PURE__ */ G(pi,{...n,layout:`docked`,switchConfig:r})}var _i=`https://www.google.com/recaptcha/api.js?render=`,vi=/* @__PURE__ */ new Map;function yi(e){let t=vi.get(e);if(t)return t;let n=new Promise((t,n)=>{let r=globalThis.grecaptcha;if(r!==void 0&&typeof r.execute==`function`){t(r);return}let i=document.createElement(`script`);i.src=_i+encodeURIComponent(e),i.async=!0,i.addEventListener(`load`,()=>{let r=globalThis.grecaptcha;r!==void 0&&typeof r.execute==`function`?t(r):(vi.delete(e),n(Object.assign(/* @__PURE__ */ Error(`The reCAPTCHA script loaded without grecaptcha.`),{code:`captcha_unavailable`})))}),i.addEventListener(`error`,()=>{vi.delete(e),n(/* @__PURE__ */ Error(`The reCAPTCHA script did not load.`))}),document.head.append(i)});return vi.set(e,n),n}async function bi(e,t){let n=await yi(e);await new Promise(e=>n.ready(e));let r=await n.execute(e,{action:t});if(!r)throw Object.assign(/* @__PURE__ */ Error(`reCAPTCHA returned no token.`),{code:`captcha_unavailable`});return r}var xi=e=>{if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(()=>e());return()=>cancelAnimationFrame(t)}let t=setTimeout(e,16);return()=>clearTimeout(t)},Si=oe();function Ci(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`The chat narrowing must be an object of feature switches.`);let n={};for(let e of A){let r=Reflect.get(t,e);if(r!==void 0){if(typeof r==`boolean`)n[e]=r;else throw TypeError(`The chat narrowing for "${e}" must be true or false.`)}}let r=new Set(A);for(let e of Object.keys(t))if(!r.has(e))throw TypeError(`"${e}" is not a chat feature.`);return n}function wi(e){let{client:t,screen:n,layout:r,narrow:i,conversationId:a,behaviour:o,attribution:s,prefs:c,pageContext:l,getCaptchaToken:u,onEvent:d,onError:f,onNavigate:p}=e,m=D(l);m.current=l;let h=D(u);h.current=u;let g=D(d);g.current=d;let _=D(f);_.current=f;let v=D(a);v.current=a;let y=D(o);y.current=o;let b=D(s);b.current=s;let S=D(c);S.current=c;let w=JSON.stringify(i??{}),T=D(null),A=D(!1),j=D(null),[N,P]=O(null);C(()=>{j.current=null;let e=F(t,{...n===void 0?{}:{screen:n},...r===void 0?{}:{layout:r},narrow:Ci(w),...v.current?{conversationId:v.current}:{},pageContext:()=>m.current,behaviour:()=>{let e=T.current;return e?.getState().features.BehaviourStarters?y.current?y.current():(j.current||=me(e.getState().profile?.start.behaviour?.servicePathPrefixes??[]),j.current()):null},attribution:()=>b.current?.()??null,prefs:S.current??zt,schedule:xi,reducedMotion:()=>A.current,getCaptchaToken:async e=>{if(h.current)return h.current(e);let t=T.current?.getState().profile?.captcha;return t?.siteKey?bi(t.siteKey,e):null},onEvent:(e,t)=>g.current?.(e,t),onError:e=>_.current?.(e)});return T.current=e,P({client:t,screen:n,layout:r,narrowKey:w,session:e}),()=>{T.current=null,e.dispose()}},[t,n,r,w]);let I=N!==null&&N.client===t&&N.screen===n&&N.layout===r&&N.narrowKey===w?N.session:M,L=k(I.subscribe,I.getState);A.current=Jr(Si,L.profile?.experience??null);let ee=E(()=>({load:()=>I.load(),submit:e=>I.submit(e),chooseQuickReply:e=>I.chooseQuickReply(e),answerInput:(e,t)=>I.answerInput(e,t),confirmAction:e=>I.confirmAction(e),rejectAction:(e,t)=>I.rejectAction(e,t),stop:()=>I.stop(),retry:()=>I.retry(),regenerate:()=>I.regenerate(),notifyTyping:()=>I.notifyTyping(),requestHandoff:e=>I.requestHandoff(e),startEdit:e=>I.startEdit(e),cancelEdit:()=>I.cancelEdit(),attach:e=>I.attach(e),removeAttachment:e=>I.removeAttachment(e),openConversation:e=>I.openConversation(e),resumeLast:()=>I.resumeLast(),newConversation:()=>I.newConversation(),rate:(e,t,n)=>I.rate(e,t,n),reset:()=>I.reset()}),[I]),te=x((e,t)=>g.current?.(e,t),[]);return{...L,...ee,session:I,client:t,emit:te,onNavigate:p}}export{Ge as ChatComposer,et as ChatConversationActions,Zr as ChatEmbed,ni as ChatExplain,tt as ChatFooter,hi as ChatLauncher,un as ChatLoader,Tt as ChatOpenTickets,Yr as ChatPage,gi as ChatPanel,Ct as ChatPastChats,Lt as ChatReadAloudButton,Hr as ChatThread,cn as assertChatLoaderStyle,Fr as defaultRenderers,_t as formatResetTime,wi as useChat,Re as useChatDictation,gt as useChatExplain,qr as useChatHandoff,Mt as useChatReadAloud,$e as useTranscriptActions};
@@ -1,4 +1,6 @@
1
- export default function ChatAgentTyping({ chat, labels }: {
2
- chat: any;
3
- labels: any;
4
- }): import("react").JSX.Element | null;
1
+ import type { ChatLabels, ChatSessionState } from "@webority/chat-core";
2
+ export type ChatAgentTypingProps = {
3
+ chat: Pick<ChatSessionState, "agentTyping" | "messages">;
4
+ labels: ChatLabels;
5
+ };
6
+ export default function ChatAgentTyping({ chat, labels }: ChatAgentTypingProps): import("react").JSX.Element | null;
@@ -1,4 +1,6 @@
1
- export default function ChatAuthorBadge({ author, labels }: {
2
- author: any;
3
- labels: any;
4
- }): import("react").JSX.Element | null;
1
+ import type { ChatAuthor, ChatLabels } from "@webority/chat-core";
2
+ export type ChatAuthorBadgeProps = {
3
+ author: ChatAuthor;
4
+ labels: ChatLabels;
5
+ };
6
+ export default function ChatAuthorBadge({ author, labels }: ChatAuthorBadgeProps): import("react").JSX.Element | null;
@@ -1,11 +1,16 @@
1
+ import type { ChatLabels, ChatSession, ChatSessionState } from "@webority/chat-core";
2
+ import { type Ref } from "react";
3
+ export type ChatComposerProps = {
4
+ chat: Pick<ChatSessionState, "attachments" | "draft" | "editing" | "features" | "handoffPause" | "messages" | "messagesLeftToday" | "profile" | "streaming"> & Pick<ChatSession, "attach" | "cancelEdit" | "client" | "notifyTyping" | "removeAttachment" | "stop" | "submit"> & {
5
+ session: Pick<ChatSession, "consumeDraft">;
6
+ };
7
+ labels: ChatLabels;
8
+ maxLength: number;
9
+ inputRef?: Ref<HTMLTextAreaElement> | undefined;
10
+ sendIcon?: string | undefined;
11
+ };
1
12
  /**
2
13
  * The foot nodes of the chat: the allowance line, the edit banner, the attachment chips and the
3
14
  * composer form, in that order, as CONTRACT-WEBDOM draws them.
4
15
  */
5
- export default function ChatComposer({ chat, labels, maxLength, inputRef, sendIcon }: {
6
- chat: any;
7
- inputRef: any;
8
- labels: any;
9
- maxLength: any;
10
- sendIcon?: string | undefined;
11
- }): import("react").JSX.Element;
16
+ export default function ChatComposer({ chat, labels, maxLength, inputRef, sendIcon }: ChatComposerProps): import("react").JSX.Element;
@@ -1,7 +1,12 @@
1
+ import { type ChatLabels } from "@webority/chat-core";
2
+ import type useChat from "./useChat.js";
3
+ type ChatHook = ReturnType<typeof useChat>;
4
+ export type ChatConversationActionsProps = {
5
+ chat: ChatHook;
6
+ labels: ChatLabels;
7
+ };
1
8
  /**
2
9
  * Header buttons that share or print the whole conversation.
3
10
  */
4
- export default function ChatConversationActions({ chat, labels }: {
5
- chat: any;
6
- labels: any;
7
- }): import("react").JSX.Element | null;
11
+ export default function ChatConversationActions({ chat, labels }: ChatConversationActionsProps): import("react").JSX.Element | null;
12
+ export {};