@webority/chat-elements 0.0.0-stage → 0.133.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 (78) hide show
  1. package/LICENSE.txt +9 -0
  2. package/dist/chat-elements.js +1 -0
  3. package/dist/chat.css +1 -0
  4. package/dist/chat.global.js +44 -0
  5. package/dist/types/WuiChat.d.ts +263 -0
  6. package/dist/types/agent.d.ts +7 -0
  7. package/dist/types/composer.d.ts +7 -0
  8. package/dist/types/dom.d.ts +31 -0
  9. package/dist/types/footer.d.ts +4 -0
  10. package/dist/types/global.d.ts +1 -0
  11. package/dist/types/header.d.ts +4 -0
  12. package/dist/types/history.d.ts +7 -0
  13. package/dist/types/http.d.ts +12 -0
  14. package/dist/types/index.d.ts +3 -0
  15. package/dist/types/loaders/index.d.ts +5 -0
  16. package/dist/types/loaders/orb.d.ts +4 -0
  17. package/dist/types/loaders/phrases.d.ts +4 -0
  18. package/dist/types/loaders/skeleton.d.ts +4 -0
  19. package/dist/types/loaders/steps.d.ts +4 -0
  20. package/dist/types/loaders/typing.d.ts +9 -0
  21. package/dist/types/nudge.d.ts +8 -0
  22. package/dist/types/past-chats.d.ts +18 -0
  23. package/dist/types/recaptcha.d.ts +2 -0
  24. package/dist/types/renderers/action-part.d.ts +17 -0
  25. package/dist/types/renderers/audio-type.d.ts +1 -0
  26. package/dist/types/renderers/cell-format.d.ts +6 -0
  27. package/dist/types/renderers/chart-engine.d.ts +1 -0
  28. package/dist/types/renderers/chart-engine.global.d.ts +1 -0
  29. package/dist/types/renderers/chart-part.d.ts +11 -0
  30. package/dist/types/renderers/figure-runs.d.ts +4 -0
  31. package/dist/types/renderers/figures-part.d.ts +1 -0
  32. package/dist/types/renderers/file-part.d.ts +4 -0
  33. package/dist/types/renderers/handoff-part.d.ts +6 -0
  34. package/dist/types/renderers/image-part.d.ts +1 -0
  35. package/dist/types/renderers/index.d.ts +32 -0
  36. package/dist/types/renderers/input-request-part.d.ts +12 -0
  37. package/dist/types/renderers/notice-part.d.ts +4 -0
  38. package/dist/types/renderers/part-base.d.ts +20 -0
  39. package/dist/types/renderers/quick-replies-part.d.ts +1 -0
  40. package/dist/types/renderers/record-card-part.d.ts +1 -0
  41. package/dist/types/renderers/sources-part.d.ts +1 -0
  42. package/dist/types/renderers/table-part.d.ts +1 -0
  43. package/dist/types/renderers/text-part.d.ts +2 -0
  44. package/dist/types/renderers/ticket-part.d.ts +1 -0
  45. package/dist/types/renderers/voice-clip-part.d.ts +6 -0
  46. package/dist/types/share-actions.d.ts +23 -0
  47. package/dist/types/shell-docked.d.ts +11 -0
  48. package/dist/types/shell-embed.d.ts +10 -0
  49. package/dist/types/shell-launcher.d.ts +10 -0
  50. package/dist/types/shell-page.d.ts +10 -0
  51. package/dist/types/starters.d.ts +6 -0
  52. package/dist/types/thread.d.ts +6 -0
  53. package/dist/types/voice/composer-voice.d.ts +12 -0
  54. package/dist/types/voice/controller.d.ts +24 -0
  55. package/dist/types/voice/icons.d.ts +1 -0
  56. package/dist/types/voice/read-aloud-button.d.ts +5 -0
  57. package/dist/types/web/autoopen.d.ts +3 -0
  58. package/dist/types/web/avoid.d.ts +3 -0
  59. package/dist/types/web/behaviour.d.ts +6 -0
  60. package/dist/types/web/explain.d.ts +27 -0
  61. package/dist/types/web/focus.d.ts +2 -0
  62. package/dist/types/web/haptics.d.ts +1 -0
  63. package/dist/types/web/index.d.ts +17 -0
  64. package/dist/types/web/moment.d.ts +15 -0
  65. package/dist/types/web/motion.d.ts +5 -0
  66. package/dist/types/web/print.d.ts +19 -0
  67. package/dist/types/web/scrolllock.d.ts +1 -0
  68. package/dist/types/web/share.d.ts +10 -0
  69. package/dist/types/web/sound.d.ts +6 -0
  70. package/dist/types/web/speech-azure.d.ts +29 -0
  71. package/dist/types/web/speech-sdk-absent.d.ts +1 -0
  72. package/dist/types/web/speech.d.ts +9 -0
  73. package/dist/types/web/switch.d.ts +13 -0
  74. package/dist/types/web/viewport.d.ts +3 -0
  75. package/dist/web-DeRQru_E.js +1 -0
  76. package/dist/web.js +1 -0
  77. package/package.json +67 -3
  78. package/README.md +0 -3
package/LICENSE.txt ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) Webority Technologies. All rights reserved.
2
+
3
+ This software and its NuGet packages are the proprietary and confidential property
4
+ of Webority Technologies. They are published publicly only for the convenience of
5
+ Webority's own projects and internal consumption.
6
+
7
+ No license or right to use, copy, modify, merge, publish, distribute, sublicense,
8
+ or create derivative works is granted to any third party. Unauthorized use,
9
+ reproduction, or distribution is prohibited.
@@ -0,0 +1 @@
1
+ import{A as e,C as t,D as n,E as r,M as i,O as a,S as o,T as s,a as c,b as l,c as u,f as d,g as f,h as p,j as m,k as h,l as g,m as _,n as v,o as y,p as b,s as x,u as S,v as C,x as w,y as T}from"./web-DeRQru_E.js";import{buildTranscript as E,createChatClient as D,createChatSession as O,createConversationList as ee,createTurnApi as te,formatChatDate as k,formatChatValue as ne,formatClipTime as A,formatFigure as re,formatFileSize as ie,isHandoffTarget as ae,loaderView as oe,mergeLabels as se,mergeLook as ce,messagePlainText as j,resolveNudge as le,showsCaptchaNote as ue,toFigureRuns as M,toFigureText as de,transcriptToText as fe,voiceClipBars as pe}from"@webority/chat-core";import{linkTarget as me,parseInline as he}from"@webority/markdown-core";import{COPY_FEEDBACK_MS as ge,EMPTY_VALUE as _e,copyTextToClipboard as ve,formatDate as ye,formatDateTime as be,formatNumber as xe,glyphSvg as Se}from"@webority/ui-elements/helpers";import"@webority/ui-elements/elements/lightbox";import"@webority/ui-elements/elements/markdown";import"@webority/ui-elements/elements/code-block";var Ce=typeof HTMLElement>`u`?class{}:HTMLElement,N=class extends Ce{#e=null;#t=null;#n=null;#r=!1;get part(){return this.#e}set part(e){this.#e=e,this.#i()}get message(){return this.#t}set message(e){this.#t=e,this.#i()}get turn(){return this.#n}set turn(e){this.#n=e,this.#i()}connectedCallback(){this.#r=!0,this.#i()}disconnectedCallback(){this.#r=!1,queueMicrotask(()=>{this.isConnected||this.disposePart()})}#i(){this.#r&&this.#e&&this.#t&&this.#n&&this.renderPart(this.#e,this.#t,this.#n)}renderPart(){throw Error(`${this.localName} must override renderPart`)}disposePart(){}};function P(e,t){typeof customElements>`u`||customElements.get(e)||customElements.define(e,t)}function F(e,t,n=null,r=null){let i=e.createElement(t);return n&&(i.className=n),r!==null&&(i.textContent=r),i}function we(e,t,n){let r=Se(t,{size:n});if(!r)return null;let i=new DOMParser().parseFromString(r,`text/html`);return e.importNode(i.body.firstElementChild,!0)}var Te={Confirmed:`actionConfirmed`,Rejected:`actionRejected`,Expired:`actionExpired`,Failed:`actionFailed`},Ee=/^https?:\/\//i,De={strong:`strong`,em:`em`,strike:`s`};function I(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r}function Oe(e,t){return{id:e,label:t,action:`Send`,target:null,navigateAfterMs:null,icon:null,variant:null}}function ke(e,t){for(let n of t)if(n.type===`text`||n.type===`citation`)e.append(document.createTextNode(n.text));else if(n.type===`link`){if(Ee.test(n.href)){let t=I(`a`);t.href=n.href,t.target=`_blank`,t.rel=`noopener noreferrer`,ke(t,n.children),e.append(t)}else ke(e,n.children)}else if(n.type in De){let t=I(De[n.type]);ke(t,n.children),e.append(t)}else n.type===`code`&&e.append(I(`code`,null,n.text))}function Ae(e){let t=I(`p`,`wui-chat-action-consent`);return ke(t,he(e)),t}function je(e){let t=I(`ul`,`wui-chat-action-lines`);for(let n of e)t.append(I(`li`,null,n));return t}function Me(e){let t=I(`dl`,`wui-chat-action-lines`);for(let n of e){let e=I(`div`,`wui-chat-action-line`),r=n.indexOf(`: `);r===-1?e.append(I(`dt`,null,n)):e.append(I(`dt`,null,n.slice(0,r)),I(`dd`,null,n.slice(r+2))),t.append(e)}return t}P(`wui-chat-part-action`,class extends N{constructor(){super(),this._part=null,this._turn=null,this._working=null,this._error=null,this._menuOpen=!1}renderPart(e,t,n){this._part?.actionId!==e.actionId&&(this._working=null,this._error=null,this._menuOpen=!1),this._part=e,this._turn=n,this._paint()}_paint(e=null){this.replaceChildren(this._view()),e===`first`?this.querySelector(`[role="menuitem"]`)?.focus():e===`edit`&&this.querySelector(`.wui-chat-action-edit`)?.focus()}async _run(e){let t=this._part.actionId;this._working=e,this._error=null,this._paint();try{e===`confirm`?await this._turn.confirmAction(t):await this._turn.rejectAction(t),this._working=null}catch(e){if(this._part.actionId!==t)return;this._working=null,this._error=e?.message||this._turn.labels.actionFailed,this._paint()}}_view(){let{part:e,turn:t}=this,n=t.labels,r=e.state===`Pending`,i=t.features.LeadRecap&&e.actionKind===`ChatLeadCapture`,a=i&&e.editFields?.length>0,o=I(`div`,`wui-chat-action wui-chat-action--${e.state.toLowerCase()}`);if(o.append(I(`strong`,`wui-chat-action-title`,e.title)),e.lines.length>0&&o.append(i?Me(e.lines):je(e.lines)),i&&e.consentText&&o.append(Ae(e.consentText)),e.note&&o.append(I(`p`,`wui-chat-action-note`,e.note)),r||o.append(this._status(e,n)),(r||a)&&o.append(this._buttons(e,n,i,r,a)),a&&this._menuOpen&&o.append(this._menu(e.editFields,n)),this._error){let e=I(`p`,`wui-chat-action-error`,this._error);e.setAttribute(`role`,`alert`),o.append(e)}return o}_status(e,t){let n=I(`p`,`wui-chat-action-status wui-chat-action-status--${e.state.toLowerCase()}`);if(e.state===`Repeat`)n.textContent=e.decidedDateTimeUtc?t.actionRepeat(k(e.decidedDateTimeUtc)):t.actionDone;else if(e.state===`Done`){if(n.append(t.actionDone),e.decidedDateTimeUtc){let t=I(`time`,null,k(e.decidedDateTimeUtc));t.dateTime=e.decidedDateTimeUtc,n.append(` `,t)}}else n.textContent=t[Te[e.state]]??``;return n}_buttons(e,t,n,r,i){let a=I(`div`,`wui-chat-action-buttons`),o=this._working;if(r){let r=n&&e.confirmLabel||t.actionConfirm,i=n&&e.rejectLabel||t.actionDismiss,s=I(`button`,`btn btn-primary btn-sm`,o===`confirm`?t.actionWorking:r);s.type=`button`,s.disabled=o!==null,s.addEventListener(`click`,()=>this._run(`confirm`));let c=I(`button`,`btn btn-soft-primary btn-sm`,i);c.type=`button`,c.disabled=o!==null,c.addEventListener(`click`,()=>this._run(`dismiss`)),a.append(s,c)}if(i){let e=I(`button`,`btn btn-soft-primary btn-sm wui-chat-action-edit`,t.editSomething);e.type=`button`,e.setAttribute(`aria-haspopup`,`menu`),e.setAttribute(`aria-expanded`,String(this._menuOpen)),e.disabled=!r||o!==null,e.addEventListener(`click`,()=>{this._menuOpen=!this._menuOpen,this._paint(this._menuOpen?`first`:`edit`)}),a.append(e)}return a}_menu(e,t){let n=I(`ul`,`list-group wui-chat-action-menu`);n.setAttribute(`role`,`menu`),n.setAttribute(`aria-label`,t.editSomething),n.addEventListener(`keydown`,e=>this._onMenuKey(e));for(let t of e){let e=I(`li`);e.setAttribute(`role`,`none`);let r=I(`button`,`list-group-item list-group-item-action wui-chat-action-menu-item`,t.label);r.type=`button`,r.setAttribute(`role`,`menuitem`),r.addEventListener(`click`,()=>{this._menuOpen=!1,this._turn.chooseQuickReply(Oe(`lead.edit:${t.id}`,t.label)),this._paint()}),e.append(r),n.append(e)}return n}_onMenuKey(e){if(e.key===`Escape`){e.preventDefault(),this._menuOpen=!1,this._paint(`edit`);return}let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)],n=t.indexOf(document.activeElement),r=t.length-1,i={ArrowDown:n<r?n+1:0,ArrowUp:n>0?n-1:r,Home:0,End:r};e.key in i&&(e.preventDefault(),t[i[e.key]].focus())}});var Ne=null;async function Pe(){await import(`@webority/ui-elements/chart`),await customElements.whenDefined(`wui-chart`)}async function Fe(){return Ne??=Pe().catch(e=>{throw Ne=null,e}),Ne}var Ie={sub:`wui-chat-sub`,sup:`wui-chat-sup`};function L(e,t){let n=e.ownerDocument;for(let r of t){if(Ie[r.kind]===void 0){e.append(n.createTextNode(r.text));continue}let t=n.createElement(r.kind);t.className=Ie[r.kind],t.textContent=r.text,e.append(t)}}function R(e,t){e.replaceChildren(),L(e,M(String(t??``)))}function z(e){return de(String(e??``))}function Le(e){return re(e)}var Re=8,ze={Bar:`column`,Line:`line`,Donut:`donut`};function Be(e,t){return e===`Bar`&&t>4?300:240}function Ve(e,t){let n=e.chartType===`Donut`,r=n?e.series.slice(0,1):e.series.slice(0,Re),i=r.map((e,n)=>({key:`s${n}`,label:z(e.name)||t.chart})),a=Object.fromEntries(i.map(e=>[e.key,null])),o=/* @__PURE__ */ new Map;r.forEach((e,t)=>{for(let n of e.points){let e=String(n.label);o.has(e)||o.set(e,{label:z(e),...a}),o.get(e)[`s${t}`]=n.value}});let s=[...o.values()],c={type:ze[e.chartType],title:z(e.title)||t.chart,x:{key:`label`,kind:`category`},series:i,data:s,height:Be(e.chartType,s.length)};return!n&&e.unit&&(c.y={label:z(e.unit)}),s.length===0&&(c.state=`empty`,c.emptyText=t.chartEmpty),c}P(`wui-chat-part-chart`,class extends N{#e=null;#t=0;#n=!1;#r=null;#i=null;#a=null;#o=null;#s=null;renderPart(e,t,n){let r=JSON.stringify(e);if(r===this.#e)return;this.#e=r,this.#t+=1;let i=this.#t,a=this.ownerDocument;this.#r||(this.#r=F(a,`figure`,`wui-chat-chart`),this.#a=F(a,`div`,`wui-chat-chart-body`),this.#o=a.createElement(`wui-chart`),this.#a.append(this.#o),this.#r.append(this.#a),this.replaceChildren(this.#r)),this.#i?.remove(),this.#i=null,e.title&&(this.#i=F(a,`figcaption`,`wui-chat-chart-title`),R(this.#i,e.title),this.#r.prepend(this.#i));let o=Ve(e,n.labels);this.#c(o.state!==`empty`,n.labels),this.#n?this.#o.spec=o:Fe().then(()=>{i===this.#t&&this.isConnected&&(this.#n=!0,this.#a.replaceChildren(this.#o),this.#o.spec=o)},()=>{i===this.#t&&this.isConnected&&this.#u(n.labels)})}disposePart(){this.#t+=1,this.#e=null}#c(e,t){if(!e){this.#s?.remove(),this.#s=null;return}this.#s||(this.#s=F(this.ownerDocument,`button`,`btn btn-link btn-sm wui-chat-chart-toggle`),this.#s.type=`button`,this.#s.addEventListener(`click`,()=>this.#l()),this.#r.append(this.#s));let n=this.#o.getAttribute(`view`)===`table`;this.#s.setAttribute(`aria-pressed`,String(n)),this.#s.textContent=n?t.chartShowChart:t.chartShowTable}#l(){let e=this.#o.getAttribute(`view`)!==`table`;this.#o.setAttribute(`view`,e?`table`:`chart`),this.#c(!0,this.turn.labels)}#u(e){let t=F(this.ownerDocument,`p`,`wui-chat-chart-error`,e.chartLoadFailed);t.setAttribute(`role`,`status`),this.#a.replaceChildren(t),this.#s?.remove(),this.#s=null}});var He={Positive:`wui-metric-tone-success`,Caution:`wui-metric-tone-warning`,Negative:`wui-metric-tone-danger`},Ue=/* @__PURE__ */ new Set([`Positive`,`Caution`,`Negative`]),We=.001;function Ge(e,t,n){let r=He[t.status],i=F(e,`div`,r?`wui-metric ${r}`:`wui-metric`);i.dataset.status=t.status;let a=F(e,`div`,`wui-metric-label`);R(a,t.label);let o=F(e,`div`,`wui-metric-value`);if(L(o,t.value!==0&&Math.abs(t.value)<We?Le(t.value):[{kind:`text`,text:xe(t.value)}]),t.unit){let n=F(e,`span`,`wui-chat-figure-unit`);R(n,t.unit),n.prepend(` `),o.append(n)}return Ue.has(t.status)&&o.append(F(e,`span`,`visually-hidden`,n.figureStatus(t.status))),i.append(a,o),i}P(`wui-chat-part-figures`,class extends N{#e=null;renderPart(e,t,n){let r=JSON.stringify(e);if(r===this.#e)return;if(this.#e=r,!e.figures||e.figures.length===0){this.replaceChildren();return}let i=this.ownerDocument,a=F(i,`div`,`wui-chat-figures`),o=F(i,`div`,`wui-metric-strip wui-metric-strip-sm`);o.setAttribute(`role`,`group`),o.setAttribute(`aria-label`,n.labels.figures);for(let t of e.figures)o.append(Ge(i,t,n.labels));a.append(o),this.replaceChildren(a)}}),P(`wui-chat-part-file`,class extends N{renderPart(e,t,n){let r=typeof n.openAttachment==`function`,i=document.createElement(r?`button`:`span`);i.className=`wui-chat-file-chip`,r&&(i.type=`button`,i.setAttribute(`aria-label`,n.labels.fileOpen(e.fileName)),i.addEventListener(`click`,()=>n.openAttachment(e)));let a=we(document,`document-text`,16),o=document.createElement(`span`);o.className=`wui-chat-file-name`,o.textContent=e.fileName;let s=document.createElement(`span`);s.className=`wui-chat-file-size`,s.textContent=ie(e.length),i.append(...[a,o,s].filter(Boolean));let c=document.createElement(`div`);c.className=`wui-chat-file`,c.append(i),this.replaceChildren(c)}});var Ke={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`neutral`,Cancelled:`neutral`},qe=/^\/[/\\]/,Je=/^https?:\/\//i,Ye=/[\t\r\n]/g;function Xe(e){return typeof e==`string`&&e.trim()!==``}function Ze(e){return e.replace(Ye,``)}function Qe(e){if(typeof e!=`string`)return!1;let t=Ze(e);return t.startsWith(`/`)?!qe.test(t):Je.test(t)}function $e(e){if(typeof e!=`string`)return`?`;let t=e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>[...e][0].toUpperCase()).join(``);return t===``?`?`:t}function et(e,t){let n=$e(Xe(e?.displayName)?e.displayName:t),r=a(`span`,`wui-chat-avatar`,{"aria-hidden":`true`}),i=typeof e?.avatarUrl==`string`?Ze(e.avatarUrl):null;if(Qe(i)){let e=a(`img`,null,{alt:``,src:i,loading:`lazy`});e.addEventListener(`error`,()=>{r.textContent=n}),r.append(e)}else r.textContent=n;return r}function tt(e,t){let n=a(`div`,`wui-chat-agent-head`),r=a(`span`,`wui-chat-agent-name`);r.textContent=Xe(e?.displayName)?e.displayName:t.agent;let i=a(`span`,`wui-chat-agent-role`);return i.textContent=t.agent,n.append(et(e,t.agent),r,i),n}function nt(e,t){let n=e.displayName,r=a(`li`,`wui-chat-message wui-chat-message--agent wui-chat-message--typing`),i=a(`span`,`wui-chat-typing`);for(let e=0;e<3;e+=1)i.append(a(`span`,`wui-chat-typing-dot`,{"aria-hidden":`true`}));let o=a(`span`,`visually-hidden`);return o.textContent=t.agentTyping(Xe(n)?n:t.agent),r.append(tt({kind:`Agent`,displayName:n,avatarUrl:null},t),i,o),r}function rt(e){return Object.hasOwn(Ke,e)?Ke[e]:null}function it(e,t){return rt(e)===null?``:t.ticketStatus(e)}var at=/* @__PURE__ */ new Set([`Requested`,`Waiting`]),ot=/* @__PURE__ */ new Set([`Requested`,`Waiting`,`Joined`]);function st(e,t){let n=e?.displayName;return typeof n==`string`&&n.trim()!==``?n:t.handoffAgentFallback}function ct(){let e=a(`div`,`wui-chat-handoff-pulses`);for(let t=0;t<3;t+=1)e.append(a(`span`,`wui-chat-handoff-pulse`,{"aria-hidden":`true`}));return e}function B(e,t,n){let r=a(e,t);return r.textContent=n,r}function V(e,t){let n=a(`div`,`wui-chat-handoff-body`);return n.append(B(`strong`,`wui-chat-handoff-title`,e),B(`p`,`wui-chat-handoff-text`,t)),n}function lt(e,t){if(typeof e.queuePosition!=`number`)return[ct(),B(`p`,`wui-chat-handoff-text`,t.handoffWaiting)];let n=a(`span`,`wui-chat-handoff-position`,{"aria-hidden":`true`});return n.textContent=String(e.queuePosition),[n,V(t.handoffQueued(e.queuePosition),t.handoffQueuedText)]}function ut(e,t){let n=st(e.agent,t),r=a(`span`,`wui-chat-handoff-agent`);return r.append(et(e.agent,t.handoffAgentFallback),a(`span`,`wui-chat-handoff-online`,{"aria-hidden":`true`})),[r,V(t.handoffJoined(n),t.handoffJoinedText(n))]}function dt(e,t){switch(e.state){case`Requested`:return[ct(),B(`p`,`wui-chat-handoff-text`,t.handoffRequested)];case`Waiting`:return lt(e,t);case`Joined`:return ut(e,t);case`Left`:return[V(t.handoffLeft(st(e.agent,t)),t.handoffLeftText)];case`Ended`:return[V(t.handoffEnded,t.handoffEndedText)];default:return null}}P(`wui-chat-part-handoff`,class extends N{constructor(){super(),this._signature=null}renderPart(e,t,n){let r=n.isLast,i=JSON.stringify([e.state,e.queuePosition,e.agent,r,n.features.HumanHandoff,n.busy]);if(i===this._signature)return;this._signature=i;let o=dt(e,n.labels);if(o===null){this.replaceChildren();return}let s=a(`div`,`wui-chat-handoff wui-chat-handoff--${e.state.toLowerCase()}`);r&&at.has(e.state)&&s.classList.add(`wui-chat-handoff--live`),r&&ot.has(e.state)&&s.setAttribute(`role`,`status`),s.append(...o),this.replaceChildren(s)}}),P(`wui-chat-part-image`,class extends N{#e=null;#t=0;#n=null;renderPart(e,t,n){if(e.attachmentId===this.#e)return;this.#e=e.attachmentId;let r=this.ownerDocument,i=F(r,`figure`,`wui-chat-image`);this.#n=F(r,`div`,`wui-chat-image-frame`),Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0&&(this.#n.style.aspectRatio=`${e.width} / ${e.height}`),i.append(this.#n),this.replaceChildren(i),this.#r(e,n)}disposePart(){this.#t+=1,this.#e=null}#r(e,t){this.#t+=1;let n=this.#t,r=this.ownerDocument,i=F(r,`div`,`wui-chat-image-skeleton`);i.setAttribute(`aria-hidden`,`true`);let a=F(r,`span`,`visually-hidden`,t.labels.imageLoading);a.setAttribute(`role`,`status`),this.#n.replaceChildren(i,a),typeof t.loadAttachmentUrl==`function`?t.loadAttachmentUrl(e.attachmentId).then(r=>{n===this.#t&&this.isConnected&&this.#i(r,e,t)},()=>{n===this.#t&&this.isConnected&&this.#a(e,t)}):this.#a(e,t)}#i(e,t,n){let r=this.ownerDocument,i=z(t.alt),a=r.createElement(`wui-lightbox`);a.setAttribute(`label`,n.labels.imageViewer);let o=F(r,`a`,`wui-lightbox-item`);o.setAttribute(`href`,e),o.dataset.caption=i,o.dataset.name=i;let s=r.createElement(`img`);s.src=e,s.alt=i,s.decoding=`async`,o.append(s),a.append(o),this.#n.replaceChildren(a)}#a(e,t){let n=this.ownerDocument,r=F(n,`p`,`wui-chat-image-error`,t.labels.imageFailed);r.setAttribute(`role`,`status`);let i=F(n,`button`,`btn btn-soft-primary btn-sm`,t.labels.retry);i.type=`button`,i.addEventListener(`click`,()=>this.#r(e,t)),this.#n.replaceChildren(r,i)}});var ft=/* @__PURE__ */ new Set([`ActionLimitReached`,`AssistantUnavailable`]);P(`wui-chat-part-notice`,class extends N{renderPart(e){let t=this.ownerDocument,n=F(t,`div`,`wui-chat-notice wui-chat-notice--${ft.has(e.code)?`warning`:`info`}`);n.setAttribute(`role`,`status`);let r=F(t,`span`,`wui-chat-notice-icon`);r.setAttribute(`aria-hidden`,`true`);let i=we(t,`info`,16);i&&r.append(i),n.append(r,F(t,`span`,`wui-chat-notice-text`,e.text)),this.replaceChildren(n)}});var pt=/* @__PURE__ */ new Set([`Email`,`Phone`,`Name`,`Company`,`Text`,`LongText`,`Choice`,`MultiChoice`,`TimeSlot`,`File`,`Consent`]),mt={Email:{type:`email`,autocomplete:`email`},Phone:{type:`tel`,autocomplete:`tel`},Name:{type:`text`,autocomplete:`name`},Company:{type:`text`,autocomplete:`organization`},Text:{type:`text`,autocomplete:null},LongText:{type:`text`,autocomplete:null}},ht=[`Open`,`Answered`,`Skipped`,`Expired`],gt=0;function H(e){return gt+=1,`${e}-${gt}`}function U(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r}function W(){let e=U(`p`,`wui-chat-field-error`);return e.id=H(`wui-chat-field-error`),e.setAttribute(`role`,`alert`),e.hidden=!0,e}function G(e,t){return e.required?[]:[U(`span`,`wui-chat-field-hint`,t.inputOptional)]}function _t(e,t){let n=H(`wui-chat-field`),r=mt[e.type],i=e.type===`LongText`&&!e.secret,a=U(i?`textarea`:`input`,`form-control`);i?a.rows=3:(a.type=e.secret?`password`:r.type,e.secret?a.autocomplete=`off`:r.autocomplete&&(a.autocomplete=r.autocomplete)),a.id=n,a.name=e.key,e.placeholder!=null&&(a.placeholder=e.placeholder),e.maxLength!=null&&(a.maxLength=e.maxLength),e.required&&a.setAttribute(`aria-required`,`true`);let o=U(`label`,`form-label`,e.label);o.htmlFor=n;let s=W();a.setAttribute(`aria-describedby`,s.id);let c=U(`div`,`wui-chat-field`);return c.dataset.key=e.key,c.append(o,...G(e,t),a,s),{field:e,element:c,controls:[a],focus:a,invalid:a,error:s,read:()=>e.secret?a.value:a.value.trim()}}function vt(e,t){let n=H(`wui-chat-field-label`),r=U(`span`,`form-label`,e.label);r.id=n;let i=U(`div`);i.setAttribute(`role`,`radiogroup`),i.setAttribute(`aria-labelledby`,n);let a=W();i.setAttribute(`aria-describedby`,a.id);let o=[];for(let t of e.options??[]){let n=U(`div`,`form-check`),r=U(`input`,`form-check-input`);r.type=`radio`,r.name=e.key,r.value=t.id,r.id=H(`wui-chat-option`);let a=U(`label`,`form-check-label`,t.label);a.htmlFor=r.id,n.append(r,a),i.append(n),o.push(r)}o.length===0&&(i.tabIndex=-1);let s=U(`div`,`wui-chat-field`);return s.dataset.key=e.key,s.append(r,...G(e,t),i,a),{field:e,element:s,controls:o,focus:o[0]??i,invalid:i,error:a,read:()=>o.find(e=>e.checked)?.value??``}}function yt(e,t){let n=H(`wui-chat-field-label`),r=U(`span`,`form-label`,e.label);r.id=n;let i=U(`div`,`wui-chat-input-choices`);i.setAttribute(`role`,`group`),i.setAttribute(`aria-labelledby`,n);let a=W();i.setAttribute(`aria-describedby`,a.id);let o=[];for(let t of e.options??[]){let n=U(`div`,`form-check`),r=U(`input`,`form-check-input`);r.type=`checkbox`,r.name=e.key,r.value=t.id,r.id=H(`wui-chat-option`);let a=U(`label`,`form-check-label`,t.label);a.htmlFor=r.id,n.append(r,a),i.append(n),o.push(r)}o.length===0&&(i.tabIndex=-1);let s=U(`div`,`wui-chat-field`);return s.dataset.key=e.key,s.append(r,...G(e,t),i,a),{field:e,element:s,controls:o,focus:o[0]??i,invalid:i,error:a,read:()=>JSON.stringify(o.filter(e=>e.checked).map(e=>e.value))}}function bt(e,t){let n=H(`wui-chat-field-label`),r=U(`span`,`form-label`,e.label);r.id=n;let i=U(`div`,`wui-chat-input-slots`);i.setAttribute(`role`,`radiogroup`),i.setAttribute(`aria-labelledby`,n);let a=W();i.setAttribute(`aria-describedby`,a.id);let o=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`}),s=[];for(let t of e.slots??[]){let n=U(`input`,`wui-chat-input-slot-radio`);n.type=`radio`,n.name=e.key,n.value=t.id,n.id=H(`wui-chat-slot`);let r=U(`label`,`btn btn-soft-primary wui-chat-input-slot`,o.format(new Date(t.startDateTimeUtc)));r.htmlFor=n.id,i.append(n,r),s.push(n)}s.length===0&&(i.tabIndex=-1);let c=U(`div`,`wui-chat-field`);return c.dataset.key=e.key,c.append(r,...G(e,t),i,a),{field:e,element:c,controls:s,focus:s[0]??i,invalid:i,error:a,read:()=>s.find(e=>e.checked)?.value??``}}function xt(e,t,n){let r=H(`wui-chat-field-label`),i=U(`span`,`form-label`,e.label);i.id=r;let a=W(),o=U(`input`);o.type=`file`,o.name=e.key,o.id=H(`wui-chat-field`),o.hidden=!0,e.accept?.length&&(o.accept=e.accept.join(`,`));let s=U(`button`,`btn btn-soft-primary`,t.inputChooseFile);s.type=`button`,s.dataset.wui=`AppButton`,s.setAttribute(`aria-describedby`,a.id),s.addEventListener(`click`,()=>o.click());let c=U(`span`,`wui-chat-input-file-status`);c.setAttribute(`aria-live`,`polite`);let l=U(`button`,`btn btn-link`);l.type=`button`,l.hidden=!0;let u=U(`div`,`wui-chat-input-file`);u.setAttribute(`role`,`group`),u.setAttribute(`aria-labelledby`,r),u.append(s,c,l,o);let d=`empty`,f=``,p=``,m=0,h=()=>{c.textContent=d===`uploading`?`${t.attachmentUploading} ${f}`:f,l.hidden=f===``,l.textContent=f===``?``:t.inputRemoveFile(f);let e=d===`failed`;a.textContent=e?t.attachmentFailed:``,a.hidden=!e,e?u.setAttribute(`aria-invalid`,`true`):u.removeAttribute(`aria-invalid`)},g=async e=>{m+=1;let t=m;d=`uploading`,f=e.name,p=``,h();try{let r=await n.uploadInputFile(e);if(t!==m)return;p=r,d=`ready`}catch{if(t!==m)return;d=`failed`}h()};o.addEventListener(`change`,()=>{let e=o.files?.[0];e&&g(e)}),l.addEventListener(`click`,()=>{m+=1,d=`empty`,f=``,p=``,o.value=``,h()}),h();let _=U(`div`,`wui-chat-field`);return _.dataset.key=e.key,_.append(i,...G(e,t),u,a),{field:e,element:_,controls:[s,l,o],focus:s,invalid:u,error:a,read:()=>d===`ready`?p:``,uploadProblem:()=>d===`uploading`?t.attachmentUploading:d===`failed`?t.attachmentFailed:null}}function St(e){let t=U(`input`,`form-check-input`);t.type=`checkbox`,t.name=e.key,t.id=H(`wui-chat-field`);let n=U(`label`,`form-check-label`,e.consentText||e.label);n.htmlFor=t.id;let r=W();t.setAttribute(`aria-describedby`,r.id);let i=U(`div`,`form-check`);i.append(t,n);let a=U(`div`,`wui-chat-field`);return a.dataset.key=e.key,a.append(i,r),{field:e,element:a,controls:[t],focus:t,invalid:t,error:r,read:()=>t.checked?`true`:`false`}}function Ct(e,t,n){return e.type===`Choice`?vt(e,t):e.type===`MultiChoice`?yt(e,t):e.type===`TimeSlot`?bt(e,t):e.type===`File`?xt(e,t,n):e.type===`Consent`?St(e):_t(e,t)}function wt(e,t,n){let r=e.uploadProblem?.();if(r)return r;let{field:i}=e;return i.required?i.type===`Consent`?t===`true`?null:n.inputConsentRequired:i.type===`MultiChoice`?t===`[]`?n.inputRequired:null:t===``?n.inputRequired:null:null}function Tt(e,t){return e.state===`Answered`?U(`p`,`wui-chat-input-summary`,e.answeredSummary||t.inputAnswered):U(`p`,`wui-chat-input-summary`,e.state===`Skipped`?t.inputSkipped:t.inputExpired)}function Et(e){return{kind:`Notice`,code:`NeedsNewerApp`,text:e.needsNewerApp}}P(`wui-chat-part-input-request`,class extends N{constructor(){super(),this._signature=null,this._turn=null,this._notice=null,this._generation=0}renderPart(e,t,n){this._turn=n;for(let t of ht)this.classList.toggle(`wui-chat-input-request--${t.toLowerCase()}`,e.state===t);let r=JSON.stringify([e.requestId,e.state,e.answeredSummary,e.fields]);r===this._signature?this._notice&&(this._notice.message=t,this._notice.turn=n,this._notice.part=Et(n.labels)):(this._signature=r,this._generation+=1,this._notice=null,this.replaceChildren(this._content(e,t,n)))}_content(e,t,n){if(e.state!==`Open`)return Tt(e,n.labels);if(e.fields.some(e=>!pt.has(e.type))){let e=document.createElement(`wui-chat-part-notice`);return e.message=t,e.turn=n,e.part=Et(n.labels),this._notice=e,e}return this._form(e,this._generation)}_form(e,t){let n=this._turn.labels,r=this._turn.features,i=U(`form`,`wui-chat-input-form`);i.noValidate=!0,i.setAttribute(`aria-label`,e.title||e.submitLabel),e.title&&i.append(U(`h3`,`wui-chat-input-title`,e.title));let a=e.fields.map(e=>Ct(e,n,this._turn));for(let e of a)i.append(e.element);let o=U(`p`,`wui-chat-input-error`);o.setAttribute(`role`,`alert`),o.hidden=!0,i.append(o);let s=U(`button`,`btn btn-primary`,e.submitLabel);s.type=`submit`,s.dataset.wui=`AppButton`;let c=U(`div`,`d-flex flex-wrap gap-2`);c.append(s);let l=[s];if(r.LeadShortcuts&&e.fields.length===1&&!e.fields[0].required){let t=U(`button`,`btn btn-soft-primary`,n.skip);t.type=`button`,t.dataset.wui=`AppButton`,t.addEventListener(`click`,()=>this._turn.skipInput(e.requestId)),c.append(t),l.push(t)}if(r.LeadShortcuts&&e.cancellable){let e=U(`button`,`btn btn-link`,n.cancel);e.type=`button`,e.addEventListener(`click`,()=>this._turn.cancelLead()),c.append(e),l.push(e)}i.append(c),e.allowTyped&&i.append(U(`p`,`wui-chat-input-typed`,n.typeAnswer));let u=!1,d=t=>{for(let e of a)for(let n of e.controls)n.disabled=t;for(let e of l)e.disabled=t;s.textContent=t?n.inputSubmitting:e.submitLabel},f=()=>{for(let e of a)e.error.hidden=!0,e.error.textContent=``,e.invalid.removeAttribute(`aria-invalid`);o.hidden=!0,o.textContent=``},p=(e,t)=>{e.error.textContent=t,e.error.hidden=!1,e.invalid.setAttribute(`aria-invalid`,`true`)};return i.addEventListener(`submit`,async r=>{if(r.preventDefault(),u)return;f();let i={},c=[];for(let e of a){let t=e.read();i[e.field.key]=t;let r=wt(e,t,n);r&&c.push([e,r])}if(c.length>0){for(let[e,t]of c)p(e,t);c[0][0].focus.focus();return}u=!0,d(!0);let l;try{l=await this._turn.answerInput(e.requestId,i)}catch{l={ok:!1,errors:{},message:n.errorGeneric}}if(t!==this._generation||l.ok)return;u=!1;let m=null;for(let e of a){let t=l.errors?.[e.field.key];t&&(p(e,t),m??=e)}l.message!=null&&(o.textContent=l.message,o.hidden=!1),d(!1),m?m.focus.focus():a[0]?a[0].focus.focus():s.focus()}),i}});var Dt={Primary:`wui-chat-quick-reply--primary`,Cta:`wui-chat-quick-reply--cta`};P(`wui-chat-part-quick-replies`,class extends N{#e=null;renderPart(e,t,n){let r=n.features.SuggestedReplies===!0&&n.isLast===!0&&n.busy===!1&&e.replies.length>0,i=typeof n.openTarget==`function`,a=typeof n.beginHandoff==`function`,o=n.handoffPause===!0,s=JSON.stringify([r,e.replies,e.placement,n.labels.quickReplies,n.labels.handoffMoment,i,a,o,n.handoffHosts??null,n.features.LinkHandoff===!0]);if(s===this.#e||(this.#e=s,this.replaceChildren(),!r))return;let c=this.ownerDocument,l=F(c,`div`,e.placement===`Composer`?`wui-chat-quick-replies wui-chat-quick-replies--composer`:`wui-chat-quick-replies`);l.setAttribute(`role`,`group`),l.setAttribute(`aria-label`,n.labels.quickReplies);let u=0;for(let t of e.replies)if(t.action!==`Open`||t.target&&i){if(t.action===`Navigate`){if(n.features.LinkHandoff!==!0)continue;if(!ae(t.target,n.handoffHosts)){l.append(F(c,`span`,null,t.label));continue}if(!a)continue}l.append(this.#t(c,t,u,n)),u+=1}l.childElementCount>0&&this.append(l)}#t(e,t,n,r){let i=e.createElement(`button`);i.type=`button`,i.className=[`wui-chat-quick-reply`,Dt[t.variant]??``].filter(Boolean).join(` `),i.style.setProperty(`--wui-chat-i`,String(n));let a=t.action===`Navigate`,o=a&&r.handoffPause===!0;if(i.disabled=o,t.icon){let n=we(e,t.icon,16);if(n){let t=F(e,`span`,`wui-chat-quick-reply-icon`);t.setAttribute(`aria-hidden`,`true`),t.append(n),i.append(t)}}return i.append(F(e,`span`,`wui-chat-quick-reply-label`,o?r.labels.handoffMoment:t.label)),i.addEventListener(`click`,()=>{t.action===`Open`?this.turn.openTarget(t.target):a?this.turn.beginHandoff(t,()=>this.#n(t.target)):this.turn.chooseQuickReply(t)}),i}#n(e){typeof this.turn.openTarget==`function`?this.turn.openTarget(e):globalThis.location.assign(e)}});var Ot=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]);function K(e){return Ot.has(e)}function kt(e,t,n){if(t==null||t===``)return[{kind:`text`,text:_e}];if(e===`Date`)return[{kind:`text`,text:ye(t,{pattern:`day`})}];if(e===`DateTimeUtc`)return[{kind:`text`,text:be(t)}];if(K(e)){let r=Number(t);return M(Number.isFinite(r)?ne(r,e,n):String(t))}return M(String(t))}P(`wui-chat-part-record-card`,class extends N{#e=null;renderPart(e,t,n){let r=!!e.target&&typeof n.openRecord==`function`,i=JSON.stringify([e,r]);if(i===this.#e)return;this.#e=i;let a=this.ownerDocument,o=F(a,`article`,`wui-chat-record`),s=F(a,`div`,`wui-chat-record-head`),c=F(a,`strong`,`wui-chat-record-title`);if(R(c,e.title),s.append(c),e.subtitle){let t=F(a,`span`,`wui-chat-record-subtitle`);R(t,e.subtitle),s.append(t)}if(o.append(s),e.fields?.length>0){let t=F(a,`dl`,`wui-chat-record-fields`);for(let n of e.fields){let e=F(a,`div`),r=F(a,`dt`);R(r,n.label);let i=F(a,`dd`);K(n.type)&&(i.className=`wui-chat-num`),L(i,kt(n.type,n.value,null)),e.append(r,i),t.append(e)}o.append(t)}if(r){let t=F(a,`button`,`btn btn-soft-primary btn-sm wui-chat-record-open`,n.labels.recordOpen);t.type=`button`,t.setAttribute(`aria-label`,n.labels.recordOpenFor(z(e.title))),t.addEventListener(`click`,()=>this.turn.openRecord(e)),o.append(t)}this.replaceChildren(o)}});var At=/^https?:\/\//i;P(`wui-chat-part-sources`,class extends N{renderPart(e,t,n){if(this.replaceChildren(),!n.features.Sources||e.sources.length===0)return;let r=this.ownerDocument,i=F(r,`div`,`wui-chat-sources`);i.append(F(r,`p`,`wui-chat-sources-label`,n.labels.sources));let a=F(r,`ul`,`wui-chat-sources-list`);a.setAttribute(`aria-label`,n.labels.sources);for(let t of e.sources){let e=r.createElement(`li`);e.append(this.#e(r,t,n)),a.append(e)}i.append(a),this.append(i)}#e(e,t,n){let r;return typeof t.url==`string`&&At.test(t.url)?(r=F(e,`a`,`wui-chat-source`),r.setAttribute(`href`,t.url),r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`),r.setAttribute(`aria-label`,n.labels.openSource(t.title))):(r=F(e,`span`,`wui-chat-source`),r.tabIndex=-1),r.dataset.marker=String(t.marker),r.append(F(e,`span`,`wui-chat-source-marker`,String(t.marker)),F(e,`span`,`wui-chat-source-title`,t.title)),r}});var jt=25,Mt=0;function Nt(e,t){let n=e.createElement(`tr`);for(let r of t.columns){let t=e.createElement(`th`);t.setAttribute(`scope`,`col`),K(r.type)&&(t.className=`wui-chat-num`),R(t,r.label),n.append(t)}return n}function Pt(e,t,n){let r=e.createElement(`tr`);return t.columns.forEach((i,a)=>{let o=a===0&&i.type===`Text`,s=e.createElement(o?`th`:`td`);o&&s.setAttribute(`scope`,`row`),K(i.type)&&(s.className=`wui-chat-num`),L(s,kt(i.type,n[a],t.currency)),r.append(s)}),r}function Ft(e,t,n,r){let i=e.ownerDocument;for(let a=n;a<r;a+=1)e.append(Pt(i,t,t.rows[a]))}P(`wui-chat-part-table`,class extends N{#e=null;renderPart(e,t,n){let r=JSON.stringify(e);if(r===this.#e)return;if(this.#e=r,!e.columns||e.columns.length===0){this.replaceChildren();return}let i=this.ownerDocument,a=F(i,`figure`,`wui-chat-table`),o=null;if(e.title){Mt+=1,o=`wui-chat-table-${Mt}`;let t=F(i,`figcaption`,`wui-chat-table-title`);t.id=o,R(t,e.title),a.append(t)}let s=F(i,`div`,`table-wrap wui-chat-table-wrap`);s.tabIndex=0,s.setAttribute(`role`,`region`),o?s.setAttribute(`aria-labelledby`,o):s.setAttribute(`aria-label`,n.labels.table);let c=F(i,`table`,`table table-sm wui-chat-table-grid`),l=i.createElement(`thead`);l.append(Nt(i,e));let u=i.createElement(`tbody`);if(Ft(u,e,0,Math.min(e.rows.length,jt)),c.append(l,u),s.append(c),a.append(s),e.rows.length>jt){let t=F(i,`button`,`btn btn-soft-primary btn-sm wui-chat-table-more`,n.labels.tableShowAll(e.rows.length));t.type=`button`,t.addEventListener(`click`,()=>{Ft(u,e,jt,e.rows.length),t.remove()}),a.append(t)}this.replaceChildren(a)}});var It=/* @__PURE__ */ new Set([`Visitor`,`Customer`]),Lt=/^\d+$/,Rt=`pre, code, .wui-markdown-source`;function zt(e,t){return typeof e?.isCitation==`function`?e.isCitation(t):Lt.test(t)}function Bt(e,t){if(ae(e,t?.handoffHosts))return e;let n=t?.resolveLink?.(e);return typeof n==`string`&&n!==``?n:null}function Vt(e,t){let n=globalThis.location?.origin;for(let r of e.querySelectorAll(`a[href]`)){let e=r.dataset.linkSource??r.getAttribute(`href`);r.dataset.linkSource=e;let i=Bt(e,t);i===null?r.replaceWith(r.ownerDocument.createTextNode(r.textContent)):(i!==r.getAttribute(`href`)&&r.setAttribute(`href`,i),me(i,`web`,void 0,n)?.kind===`web`?(r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`)):(r.removeAttribute(`target`),r.removeAttribute(`rel`)))}}function Ht(e){let t=e.ownerDocument,n=t.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=[];for(let e=n.nextNode();e;e=n.nextNode())e.parentElement?.closest(Rt)||r.push(e);for(let e of r){let n=M(e.nodeValue);if(n.length===1&&n[0].kind===`text`)continue;let r=t.createDocumentFragment();L(r,n),e.replaceWith(r)}}function Ut(e){let t=e.turn;Vt(e,t),t?.features?.FigureText===!0&&Ht(e)}P(`wui-chat-part-text`,class extends N{#e=null;#t=null;#n=null;#r=null;#i=!1;#a=null;constructor(){super(),this.addEventListener(`wui-markdown-citation`,e=>{let t=this.turn;typeof t?.openCitation==`function`&&t.openCitation(Number(e.detail.citation))}),this.addEventListener(`click`,e=>this.#s(e))}renderPart(e,t){let n=It.has(t.author.kind)?`plain`:`markdown`;if(n!==this.#e&&(this.#e=n,this.#r=null,this.#t=n===`plain`?this.#c():this.#l(e.text),this.#n=n===`plain`?null:this.#t.firstElementChild,this.replaceChildren(this.#t)),n===`plain`){let t=this.turn?.features?.FigureText===!0,n=JSON.stringify([e.text,t]);n!==this.#r&&(this.#r=n,this.#t.replaceChildren(),t?L(this.#t,M(e.text)):this.#t.append(this.ownerDocument.createTextNode(e.text)))}else this.#n.textContent!==e.text&&(this.#n.textContent=e.text);this.toggleAttribute(`data-streaming`,t.streaming===!0),this.#i||(this.#i=!0,this.closest(`[data-restored]`)||this.classList.add(`wui-chat-part-enter`)),this.#o()}disposePart(){this.#a?.disconnect(),this.#a=null}#o(){this.#a||(this.#a=new MutationObserver(()=>Ut(this)),this.#a.observe(this,{childList:!0,subtree:!0,characterData:!0}),Ut(this))}#s(e){let t=e.target instanceof Element?e.target.closest(`a[href]`):null,n=this.turn;if(!t||!this.contains(t))return;let r=t.getAttribute(`href`);r.startsWith(`#`)||(r.startsWith(`/`)&&typeof n?.onNavigate==`function`?(e.preventDefault(),n.onNavigate(r)):typeof n?.openTarget==`function`&&(e.preventDefault(),n.openTarget(r)))}#c(){return F(this.ownerDocument,`div`,`wui-chat-bubble`)}#l(e){let t=this.ownerDocument,n=F(t,`wui-markdown`,`wui-markdown wui-chat-text`);n.setAttribute(`links`,`web`),n.setAttribute(`headings`,`text`),n.isCitation=e=>zt(this.turn,e);let r=F(t,`pre`,`wui-markdown-source`,e);return n.append(r),n}}),P(`wui-chat-part-ticket`,class extends N{renderPart(e,t,n){let{labels:r}=n,i=a(`article`,`wui-chat-ticket`,{"aria-label":r.ticketAria(e.number)}),o=a(`div`,`wui-chat-ticket-head`),s=a(`span`,`wui-chat-ticket-number`);s.textContent=r.ticketAria(e.number),o.append(s);let c=rt(e.status);if(c!==null){let t=a(`span`,`wui-chat-ticket-badge wui-chat-ticket-badge--${c}`);t.textContent=it(e.status,r),o.append(t)}let l=a(`strong`,`wui-chat-ticket-title`);if(l.textContent=e.subject,i.append(o,l),typeof n.openTicket==`function`){let t=a(`div`,`wui-chat-ticket-foot`),o=a(`button`,`wui-chat-ticket-link`,{type:`button`});o.textContent=r.ticketView,o.addEventListener(`click`,()=>n.openTicket({ticketId:e.ticketId,number:e.number})),t.append(o),i.append(t)}this.replaceChildren(i)}});var Wt=`http://www.w3.org/2000/svg`,Gt={mic:`M12 15a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.92V21h2v-2.08A7 7 0 0 0 19 12z`,stop:`M6 6h12v12H6z`,play:`M8 5v14l11-7z`,pause:`M6 5h4v14H6zm8 0h4v14h-4z`,speaker:`M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4zM14 3.2v2.1a7 7 0 0 1 0 13.4v2.1a9 9 0 0 0 0-17.6z`};function Kt(e,t=18){if(!Object.hasOwn(Gt,e))throw Error(`Unknown voice icon "${e}".`);let n=document.createElementNS(Wt,`svg`);n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`),n.setAttribute(`fill`,`currentColor`);let r=document.createElementNS(Wt,`path`);return r.setAttribute(`d`,Gt[e]),n.append(r),n}function qt(e){let t=new Uint8Array(e),n=(e,n)=>String.fromCharCode(...t.slice(e,n));return n(0,4)===`OggS`?`audio/ogg`:t[0]===26&&t[1]===69&&t[2]===223&&t[3]===163?`audio/webm`:n(4,8)===`ftyp`?`audio/mp4`:n(0,4)===`RIFF`?`audio/wav`:n(0,3)===`ID3`||t[0]===255&&(t[1]&224)==224?`audio/mpeg`:`application/octet-stream`}var Jt=40,q=null,Yt=class extends N{#e=null;#t=null;#n=null;#r=null;#i=null;#a=null;#o=null;#s=null;#c=!1;#l=null;#u=0;#d=0;#f=!1;#p=null;#m=null;#h=null;#g=0;renderPart(e,t,n){this.#e=n,n.features.VoiceClips?(this.#t===null&&this.#v(),e.attachmentId!==this.#l&&(this.disposePart(),this.#l=e.attachmentId,this.#d=0,this.#n.replaceChildren(...pe(e.attachmentId,Jt).map(Xt))),this.#u=e.durationMs,this.#y(e)):this.#_(e.transcript)}disposePart(){this.#g+=1,this.#p?.pause(),this.#h!==null&&URL.revokeObjectURL(this.#h),q===this&&(q=null),this.#p=null,this.#m=null,this.#h=null,this.#f=!1}#_(e){if(this.disposePart(),this.#t=null,this.#l=null,this.#o=null,this.#s=null,typeof e==`string`&&e!==``){let t=F(document,`p`,`wui-chat-clip-transcript`);t.textContent=e,this.replaceChildren(t)}else this.replaceChildren()}#v(){this.#t=F(document,`div`,`wui-chat-clip`),this.#t.setAttribute(`role`,`group`);let e=F(document,`div`,`wui-chat-clip-row`);this.#r=F(document,`button`,`wui-chat-clip-play`),this.#r.type=`button`,this.#r.addEventListener(`click`,()=>this.#k()),this.#n=F(document,`div`,`wui-chat-clip-wave`),this.#n.setAttribute(`aria-hidden`,`true`),this.#i=F(document,`span`,`wui-chat-clip-time`),e.append(this.#r,this.#n,this.#i),this.#a=F(document,`p`,`wui-chat-clip-error`),this.#a.setAttribute(`role`,`status`),this.#a.hidden=!0,this.#t.append(e,this.#a),this.replaceChildren(this.#t)}#y(e){let t=this.#e.labels;this.#t.setAttribute(`aria-label`,t.voiceClip),this.#r.disabled=typeof this.#e.readAttachment!=`function`,this.#b(),this.#x(),this.#S(e.transcript)}#b(){let e=this.#e.labels,t=this.#f?e.voiceClipPause:e.voiceClipPlay;this.#r.setAttribute(`aria-pressed`,String(this.#f)),this.#r.setAttribute(`aria-label`,t),this.#r.title=t,this.#r.replaceChildren(Kt(this.#f?`pause`:`play`,18))}#x(){let e=this.#u/1e3,t=e>0?Math.min(1,this.#d/e):0,n=Math.floor(t*Jt);[...this.#n.children].forEach((e,t)=>{e.classList.toggle(`wui-chat-clip-bar--played`,t<n)});let r=A(Math.max(1,Math.round(e)));this.#i.textContent=this.#e.labels.voiceClipTime(A(this.#d),r)}#S(e){typeof e!=`string`||e===``?(this.#o?.remove(),this.#s?.remove(),this.#o=null,this.#s=null):(this.#o===null&&(this.#o=F(document,`button`,`wui-chat-clip-toggle`),this.#o.type=`button`,this.#o.addEventListener(`click`,()=>{this.#c=!this.#c,this.#s.hidden=!this.#c,this.#C()}),this.#s=F(document,`p`,`wui-chat-clip-transcript`),this.#s.hidden=!this.#c,this.#t.append(this.#o,this.#s)),this.#s.textContent=e,this.#C())}#C(){let e=this.#e.labels;this.#o.setAttribute(`aria-expanded`,String(this.#c)),this.#o.textContent=this.#c?e.voiceClipHideTranscript:e.voiceClipShowTranscript}#w(){return this.#m??=this.#T().catch(e=>{throw this.#m=null,e}),this.#m}async#T(){let e=this.#g,t=await this.#e.readAttachment(this.#l),n=URL.createObjectURL(new Blob([t],{type:qt(t)}));if(e!==this.#g)return URL.revokeObjectURL(n),null;this.#h!==null&&URL.revokeObjectURL(this.#h),this.#h=n;let r=new Audio(this.#h);return r.addEventListener(`timeupdate`,()=>{this.#d=r.currentTime,this.#x()}),r.addEventListener(`ended`,()=>{this.#d=0,this.#E(),this.#x()}),r.addEventListener(`error`,()=>{this.#E(),this.#m=null,this.#O()}),this.#p=r,r}#E(){this.#p?.pause(),this.#D(!1)}#D(e){this.#f=e,e?(q&&q!==this&&q.#E(),q=this):q===this&&(q=null),this.#t!==null&&this.#b()}#O(){this.#a.textContent=this.#e.labels.voiceClipFailed,this.#a.hidden=!1}async#k(){if(this.#f)this.#E();else{this.#a.hidden=!0;try{let e=await this.#w();if(e===null)return;this.#D(!0),await e.play()}catch{this.#E(),this.#m=null,this.#O()}}}};function Xt(e){let t=F(document,`span`,`wui-chat-clip-bar`);return t.style.setProperty(`--wui-chat-bar-height`,`${Math.round(e*100)}%`),t}P(`wui-chat-part-voice-clip`,Yt);var Zt={Text:`wui-chat-part-text`,Sources:`wui-chat-part-sources`,QuickReplies:`wui-chat-part-quick-replies`,InputRequest:`wui-chat-part-input-request`,Action:`wui-chat-part-action`,Notice:`wui-chat-part-notice`,Table:`wui-chat-part-table`,Chart:`wui-chat-part-chart`,Figures:`wui-chat-part-figures`,RecordCard:`wui-chat-part-record-card`,Image:`wui-chat-part-image`,File:`wui-chat-part-file`,Ticket:`wui-chat-part-ticket`,Handoff:`wui-chat-part-handoff`,VoiceClip:`wui-chat-part-voice-clip`},Qt=8e3,$t=6e3,en=/* @__PURE__ */ new Set([`Blocked`,`NoMicrophone`]);function tn(e){let t=e instanceof o?e.code:`Failed`;return{code:t,source:`Dictation`,sticky:en.has(t)}}function nn(e){let t=j(e.filter(e=>e.kind===`Text`)).replace(/ ?\[\d+\]/g,``).replace(/\s+/g,` `).trim();if(t.length<=6e3)return t;let n=t.slice(0,$t),r=n.lastIndexOf(`. `);return r===-1?n.trim():n.slice(0,r+1)}function rn(e,t){switch(e.code){case`Blocked`:return t.dictationBlocked;case`NoMicrophone`:return t.dictationNoMicrophone;case`NoSpeech`:return t.dictationNotHeard;case`Unavailable`:return t.dictationUnavailable;case`Failed`:return t.dictationFailed;case`SpeakFailed`:return t.readAloudFailed;default:throw Error(`Unknown voice note code "${e.code}".`)}}function an(e){let n=e.getState,r=e.speech??t({getToken:e.getToken}),i=`Idle`,a=null,o=null,s=null,c=null,l=0,u=null,d=/* @__PURE__ */ new Set,f=()=>({mode:i,messageId:a,startedAtMs:o,note:s});function p(){let e=f();for(let t of[...d])t(e)}function m(e){i=e.mode,a=e.messageId??null,o=e.startedAtMs??null,p()}function h(){clearTimeout(u),u=null}function g(e){h(),s=e,e&&!e.sticky&&(u=setTimeout(()=>{u=null,s=null,p()},Qt)),p()}function _(){s!==null&&(h(),s=null,p())}function v(){return l+=1,c={id:l,controller:new AbortController,stopped:!1},c}function y(e){c===e&&(c=null,m({mode:`Idle`}))}function b(){let e=c;c=null,e&&(e.stopped=!0,e.controller.abort()),i!==`Idle`&&m({mode:`Idle`})}function x(){let e=n();return!!(e.features.Dictation&&e.profile?.speechAvailable&&r.dictation)}function S(){let e=n();return!!(e.features.ReadAloud&&e.profile?.speechAvailable&&r.readAloud)}async function C(e){if(i===`Dictating`){b();return}if(b(),g(null),!x())return;let t=e.getText(),n=t!==``&&!/\s$/.test(t)?`${t} `:t,a=v();m({mode:`Dictating`});try{await r.startDictation({signal:a.controller.signal,onText:t=>{c===a&&e.setText(n+t)},onEnd:()=>y(a)})}catch(e){if(a.stopped)return;y(a),g(tn(e))}}async function w(e,t){if(i===`Speaking`&&a===e){b();return}b(),g(null);let n=nn(t);if(n===``)return;let o=v();m({mode:`Speaking`,messageId:e});try{await r.speak(n,{signal:o.controller.signal}),y(o)}catch{if(o.stopped)return;y(o),g({code:`SpeakFailed`,source:`ReadAloud`,sticky:!1})}}function T(e){return d.add(e),()=>{d.delete(e)}}function E(){b(),h(),s=null,d.clear()}return{canDictate:x,canSpeak:S,getStatus:f,subscribe:T,toggleDictation:C,toggleSpeak:w,stop:b,dismissNote:_,destroy:E}}var on=/* @__PURE__ */ new Set([`Shift`,`Control`,`Alt`,`Meta`,`Escape`]);function sn(e,t){e.isTrusted&&!on.has(e.key)&&t.getStatus().mode===`Dictating`&&t.stop()}function cn({voice:e,getLabels:t,textarea:n,onTextChanged:r}){let i=null,o=a(`button`,`wui-chat-tool wui-chat-mic`,{type:`button`});o.append(Kt(`mic`,20)),o.hidden=!0,o.addEventListener(`click`,()=>{e.toggleDictation({getText:()=>n.value,setText:e=>{n.value=n.maxLength>0?e.slice(0,n.maxLength):e,r(),n.setSelectionRange(n.value.length,n.value.length)}})});let s=a(`p`,`wui-chat-voice-note`,{role:`status`});s.hidden=!0;function c(e){let n=t(),r=e.mode===`Dictating`,i=r?n.dictateStop:n.dictate;o.setAttribute(`aria-pressed`,String(r)),o.setAttribute(`aria-label`,i),o.title=i;let a=e.note?.code===`Blocked`||e.note?.code===`NoMicrophone`;e.note===null?(s.hidden=!0,s.textContent=``):(s.hidden=!1,s.textContent=rn(e.note,n),s.setAttribute(`role`,e.note.sticky?`alert`:`status`)),s.classList.toggle(`wui-chat-voice-note--blocked`,a)}function l(t){let{state:n}=t;o.hidden=!e.canDictate();let r=e.getStatus().mode===`Speaking`,i=n.messagesLeftToday===0;o.disabled=i||r}function u(e){c(e),i!==null&&l(i)}let d=e.subscribe(u);function f(t){i=t,l(t),c(e.getStatus())}function p(){d()}return{buttons:[o],note:s,paint:f,destroy:p}}var ln=10,un=.9,dn=0;function fn(e){for(let t of e.toReversed())for(let e of t.parts.toReversed())if(e.kind===`InputRequest`&&e.state===`Open`)return e.fields[0]?.label??e.title??null;return null}function pn(t){dn+=1;let n=`wui-chat-composer-hint-${dn}`,r=a(`p`,`wui-chat-allowance`,{role:`status`});r.hidden=!0;let i=a(`span`),o=a(`button`,`btn btn-ghost-primary btn-sm wui-chat-action-btn`,{type:`button`});o.addEventListener(`click`,()=>t.onCancelEdit());let s=a(`div`,`wui-chat-editing`);s.hidden=!0,s.append(i,o);let c=a(`div`,`wui-chat-attachments`);c.hidden=!0;let l=a(`button`,`wui-chat-tool`,{type:`button`});l.append(e(`paperclip`,16)),l.hidden=!0;let u=a(`input`,null,{type:`file`,multiple:``,tabindex:`-1`});u.hidden=!0,u.addEventListener(`change`,()=>{let e=[...u.files];u.value=``,e.length>0&&t.onAttach(e)}),l.addEventListener(`click`,()=>u.click());let d=a(`textarea`,`wui-chat-input`,{rows:`1`,"aria-describedby":n}),f=a(`span`,`visually-hidden`,{id:n}),p=a(`span`,`wui-chat-counter`);p.hidden=!0;let m=a(`button`,`wui-chat-send`,{type:`submit`});m.append(e(`send`,16));let h=a(`button`,`wui-chat-send wui-chat-send--stop`,{type:`button`});h.append(e(`stop`,16)),h.hidden=!0,h.addEventListener(`click`,()=>t.onStop());let g=a(`form`,`wui-chat-composer`);g.append(l,u,d,p,f,h,m);let _=null,v=null,y=null,b=0,x=null;function S(){d.style.height=`auto`,d.style.height=`${d.scrollHeight}px`}function C(){return x?.attachments.some(e=>e.status===`Uploading`)??!1}function w(){return x?.attachments.some(e=>e.status===`Ready`)??!1}function T(){let e=d.value.length,t=b>0&&e>b*un;p.hidden=!t,t&&y&&(p.textContent=y.counter(e,b))}function E(){let e=x?.messagesLeftToday??null,t=d.value.trim()===``&&!w();m.disabled=!!x?.streaming||e===0||C()||t}function D(){if(m.disabled)return;let e=d.value.trim();d.value=``,S(),T(),E(),t.voice?.stop(),t.voice?.dismissNote(),t.onSubmit(e)}d.addEventListener(`input`,()=>{S(),T(),E(),d.value!==``&&t.onTyping?.()}),d.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),D())}),g.addEventListener(`submit`,e=>{e.preventDefault(),D()});let O=t.voice?cn({voice:t.voice,getLabels:()=>y,textarea:d,onTextChanged:()=>{S(),T(),E()}}):null;O&&(g.insertBefore(O.buttons[0],m),d.addEventListener(`keydown`,e=>sn(e,t.voice)));function ee(n){let r=n.map(n=>{let r=a(`span`,`wui-chat-chip`),i=a(`span`,null,n.status===`Failed`?{title:n.error??``}:null);i.textContent=n.fileName;let o=a(`button`,`wui-chat-chip-remove`,{type:`button`,"aria-label":y.removeAttachment(n.fileName)});return o.append(e(`x`,14)),o.addEventListener(`click`,()=>t.onRemove(n.key)),r.append(i,o),r});c.replaceChildren(...r),c.hidden=r.length===0}function te(e){x=e.state,y=e.labels,b=e.maxLength;let n=x.messagesLeftToday;g.setAttribute(`aria-label`,y.composer),f.textContent=y.composerHint,d.setAttribute(`aria-label`,y.composer),d.maxLength=b,d.placeholder=fn(x.messages)??y.placeholder,d.disabled=n===0,r.hidden=!(n!==null&&n<=ln),r.hidden||(r.textContent=y.allowance(n));let a=x.editing?.messageId??null;if(a!==_){let e=_!==null;_=a,x.editing?(d.value=x.editing.text,S()):e&&(d.value=``,S())}s.hidden=!x.editing,i.textContent=y.editing,o.textContent=y.cancel;let c=e.draft??null;typeof c==`string`&&c!==``&&c!==v&&(v=c,d.value=c,d.dispatchEvent(new Event(`input`)),d.focus(),t.onDraftApplied?.()),ee(x.attachments);let p=x.features.Attachments&&(x.profile?.limits.maxAttachments??0)>0;l.hidden=!p,l.setAttribute(`aria-label`,y.attach),l.title=y.attach,u.accept=e.accept??``;let C=x.streaming&&x.features.Stop;h.hidden=!C,h.setAttribute(`aria-label`,y.stop),m.hidden=C,m.setAttribute(`aria-label`,y.send),T(),E(),O?.paint({state:x})}function k(){d.focus()}function ne(){O?.destroy();for(let e of A)e.remove()}let A=[r,s,c,...O?[O.note]:[],g];return{nodes:A,paint:te,focus:k,destroy:ne,getDraft:()=>d.value}}var mn=`https://policies.google.com/privacy`,hn=`https://policies.google.com/terms`;function gn(e,t){let n=a(`a`,`wui-chat-footer-link`,{href:t,target:`_blank`,rel:`noopener noreferrer`});return n.textContent=e,n}function _n(){let e=a(`p`,`wui-chat-footer`);e.hidden=!0;function t(t){let{labels:n,profile:r}=t,i=[];if(r){let e=a(`span`,`wui-chat-footer-text`);if(e.textContent=r.footer.disclaimer||n.disclaimer,i.push(e),r.footer.privacyUrl){let e=a(`a`,`wui-chat-footer-link`,{href:r.footer.privacyUrl});e.textContent=n.footerPrivacy,i.push(e)}if(r.footer.assuranceText){let e=a(`span`);e.textContent=r.footer.assuranceText,i.push(e)}if(ue(r)){let e=a(`span`,`wui-chat-footer-captcha`);e.append(document.createTextNode(`${n.captchaNote} `),gn(n.captchaPrivacy,mn),document.createTextNode(` `),gn(n.captchaTerms,hn)),i.push(e)}}e.replaceChildren(...i),e.hidden=i.length===0}return{el:e,paint:t}}function J(t,n,r){t.setAttribute(`aria-label`,n),t.title=n,t.dataset.icon!==r&&(t.dataset.icon=r,t.replaceChildren(e(r,20)))}function vn(e){let t=a(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),n=a(`strong`,`wui-chat-title`),r=a(`span`,`wui-chat-tagline`),i=a(`span`,`wui-chat-status`),o=a(`div`,`wui-chat-header-text`);o.append(n,r,i);let s=h(``,`history`,()=>e.onHistory()),c=h(``,`chat`,()=>e.onMute());c.setAttribute(`aria-pressed`,`false`);let l=h(``,`plus`,()=>e.onNew()),u=h(``,`maximize-4`,()=>e.onSwitch());u.classList.add(`wui-chat-switch-btn`,`wui-chat-switch-btn--full`);let d=h(``,`panel-left-open`,()=>e.onSwitch());d.classList.add(`wui-chat-switch-btn`,`wui-chat-switch-btn--side`);let f=h(``,`x`,()=>e.onClose()),p=a(`div`,`wui-chat-header-actions`);p.append(s,c,l,u,d,f);let m=a(`header`,`wui-chat-header`);m.append(t,o,p);function g(e){let{labels:t}=e;n.textContent=e.title??``,r.textContent=e.tagline??``,r.hidden=!e.tagline,i.textContent=e.status??``,s.hidden=!e.showHistory,e.viewingHistory?J(s,t.backToChat,`arrow-left`):J(s,t.history,`history`),c.hidden=!e.showMute,c.setAttribute(`aria-pressed`,String(!!e.muted)),J(c,e.muted?t.unmuteSounds:t.muteSounds,`chat`),l.hidden=!!e.viewingHistory||e.showNew===!1,l.disabled=!e.canNew,J(l,t.newChat,`plus`),u.hidden=e.switchTo!==`full-page`,u.disabled=!e.canSwitch,J(u,t.openFullScreen,`maximize-4`),d.hidden=e.switchTo!==`docked`,d.disabled=!e.canSwitch,J(d,t.openSidePanel,`panel-left-open`),f.hidden=!e.showClose,J(f,t.close,`x`)}return{el:m,paint:g}}var yn=120;function Y(e,t,n=`outline`){let i=a(`button`,`${r(n,`sm`)} wui-chat-action-btn`,{type:`button`});return i.textContent=e,i.addEventListener(`click`,t),i}function bn(e){let t=a(`div`,`wui-chat-history`);t.hidden=!0;let n=null,r=null,i=null,o=null,s=!1;function c(){return n||(n=ee({client:e.getClient()}),r=n.subscribe(()=>v()),n)}function l(e){i={id:e.publicId,kind:`rename`,draft:e.title??``,saving:!1},o=null,s=!0,v()}function u(e){i={id:e.publicId,kind:`delete`,saving:!1},o=null,v()}function d(){i=null,o=null,v()}async function f(){let t=i,n=t?.draft.trim()??``;if(t?.kind===`rename`&&!t.saving&&n){t.saving=!0,v();try{await c().rename(t.id,n),i===t&&(i=null),o=null}catch{if(i!==t)return;t.saving=!1,o=e.getLabels().renameFailed}v()}}async function p(){let t=i;if(!(t?.kind!==`delete`||t.saving)){t.saving=!0,v();try{await c().remove(t.id),i===t&&(i=null),o=null,e.onDeleted(t.id)}catch{if(i!==t)return;t.saving=!1,o=e.getLabels().deleteFailed}v()}}function m(e){let t=a(`li`,`wui-chat-history-row wui-chat-history-row--editing`),n=a(`input`,`wui-chat-history-input`,{type:`text`,"aria-label":e.conversationTitle,maxlength:String(yn)});n.value=i.draft,n.addEventListener(`input`,()=>{i.draft=n.value,r.disabled=i.saving||!i.draft.trim()}),n.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),d())});let r=Y(e.renameSave,()=>f(),`primary`);return r.disabled=i.saving||!i.draft.trim(),t.append(n,r,Y(e.cancel,()=>d(),`ghost`)),s&&(s=!1,queueMicrotask(()=>n.focus())),t}function g(e){let t=a(`li`,`wui-chat-history-row wui-chat-history-row--confirm`),n=a(`p`);n.textContent=e.deleteConfirmTitle;let r=Y(e.deleteConfirm,()=>p(),`danger`);return r.disabled=i.saving,t.append(n,r,Y(e.cancel,()=>d(),`ghost`)),t}function _(t,n,r){if(i?.id===t.publicId&&i.kind===`rename`)return m(n);if(i?.id===t.publicId&&i.kind===`delete`)return g(n);let o=a(`li`,`wui-chat-history-row`),s=a(`button`,`wui-chat-history-open`,{type:`button`}),c=a(`span`,`wui-chat-history-title`);c.textContent=t.title||n.untitled;let d=a(`span`,`wui-chat-history-time`);return d.textContent=k(t.lastActivityDateTimeUtc),s.append(c,d),s.addEventListener(`click`,()=>e.onOpen(t.publicId)),o.append(s),r.Rename&&o.append(h(n.rename,`pencil`,()=>l(t))),r.Delete&&o.append(h(n.deleteChat,`trash`,()=>u(t))),o}function v(){let r=e.getLabels(),i=e.getFeatures(),s=n?n.getState():{items:[],loading:!1,error:null,hasMore:!1},l=[];if(s.error||o){let e=a(`p`,`wui-chat-history-error`,{role:`alert`});s.error?(e.append(document.createTextNode(r.loadFailed),document.createTextNode(` `)),e.append(Y(r.retry,()=>c().load(),`outline`))):e.textContent=o,l.push(e)}if(s.items.length===0&&!s.loading&&!s.error){let e=a(`p`,`wui-chat-history-empty`),t=a(`span`);t.textContent=r.historyEmptyTitle;let n=a(`span`);n.textContent=r.historyEmptyText,e.append(t,n),l.push(e)}if(s.items.length>0){let e=a(`ul`,`wui-chat-history-list`,{"aria-label":r.history});e.append(...s.items.map(e=>_(e,r,i))),l.push(e)}s.hasMore&&!s.loading&&l.push(Y(r.loadMore,()=>c().loadMore(),`outline`)),t.replaceChildren(...l)}function y(){t.hidden=!1,c().load().catch(()=>{}),v()}function b(){t.hidden=!0}function x(){r?.(),r=null,n?.dispose(),n=null}return{el:t,show:y,hide:b,paint:v,dispose:x}}var xn=/* @__PURE__ */ new Set([`GET`,`HEAD`]);function Sn(){let e=document.querySelector(`meta[name="wui-csrf"]`),t=e?.getAttribute(`content`);return t?{token:t,header:e.getAttribute(`data-header`)||`RequestVerificationToken`}:null}async function Cn(e){let t=await e.text();if(t){if((e.headers.get(`content-type`)||``).includes(`json`))try{return JSON.parse(t)}catch{return t}return t}}async function wn(e,t){let n=new TextDecoder,r=e.body.getReader(),i=``;for(;;){let{done:a,value:o}=await r.read();if(a)break;i+=n.decode(o,{stream:!0}),t({event:{target:{responseText:i,status:e.status}}})}return i+=n.decode(),i}function Tn({fetch:e=(...e)=>globalThis.fetch(...e)}={}){async function t(t,n,r,i={}){let a={...i.headers},o;if(typeof FormData<`u`&&r instanceof FormData){for(let e of Object.keys(a))e.toLowerCase()===`content-type`&&delete a[e];o=r}else r!==void 0&&(a[`Content-Type`]=`application/json`,o=JSON.stringify(r));if(!xn.has(t)){let e=Sn();e&&(a[e.header]=e.token)}let s=i.signal,c=s,l,u,d=()=>l.abort(s.reason);i.timeout>0&&(l=new AbortController,c=l.signal,s?.aborted?l.abort(s.reason):s?.addEventListener(`abort`,d,{once:!0}),u=setTimeout(()=>l.abort(new DOMException(`The request timed out.`,`TimeoutError`)),i.timeout));try{let r=await e(n,{method:t,headers:a,body:o,signal:c,credentials:`same-origin`});if(!r.ok){let e=/* @__PURE__ */ Error(`Request failed with status ${r.status}`);throw e.response={status:r.status,data:await Cn(r)},e}let s=i.responseType===`arraybuffer`,l=!s&&typeof i.onDownloadProgress==`function`&&r.body,u;return u=s?await r.arrayBuffer():l?await wn(r,i.onDownloadProgress):await Cn(r),{data:u,status:r.status}}finally{clearTimeout(u),s?.removeEventListener(`abort`,d)}}return{get:(e,n)=>t(`GET`,e,void 0,n),post:(e,n,r)=>t(`POST`,e,n,r),put:(e,n,r)=>t(`PUT`,e,n,r),delete:(e,n)=>t(`DELETE`,e,void 0,n)}}function En(t){let n=null,r=!1,i=!1,o=a(`div`,`wui-chat-nudge`,{role:`status`});o.hidden=!0;let s=a(`button`,`wui-chat-nudge-text`,{type:`button`}),c=a(`button`,`wui-chat-nudge-close`,{type:`button`});c.append(e(`x`,14)),o.append(s,c);function l(){clearTimeout(n),n=null}function u(){l(),i=!0,o.hidden=!0}s.addEventListener(`click`,()=>{o.hidden=!0,t.onActivate()}),c.addEventListener(`click`,()=>{u(),t.onDismiss()});function d(e){l(),i||r||(n=setTimeout(()=>{n=null,s.textContent=e.text,c.setAttribute(`aria-label`,e.label),o.hidden=!1,r=!0},e.delaySeconds*1e3))}function f(){l(),o.remove()}return{el:o,schedule:d,cancel:l,dismiss:u,isShown:()=>r,destroy:f}}function Dn(e){let{list:t,getLabels:n,getFeatures:r,onOpen:i}=e,o=e.now??(()=>Date.now()),s=a(`div`,`wui-chat-empty-rows wui-chat-empty-rows--past`);s.hidden=!0;let c=!1;function u(e,t){let n=a(`button`,`wui-chat-empty-row`,{type:`button`}),r=a(`span`,`wui-chat-empty-row-title`);r.textContent=e.title||t.earlierChat;let s=a(`span`,`wui-chat-empty-row-time`,{title:l(e.lastActivityDateTimeUtc)});return s.textContent=w(e.lastActivityDateTimeUtc,o()),n.append(r,s),n.addEventListener(`click`,()=>i(e.publicId)),n}function d(){if(c)return;let e=t.getState().items;if(r().History!==!0||e.length===0){s.replaceChildren(),s.hidden=!0;return}let i=n();s.replaceChildren(...e.slice(0,20).map(e=>u(e,i))),s.hidden=!1}let f=t.subscribe(d);return{el:s,refresh(){t.load().catch(()=>{})},paint:d,dispose(){c=!0,f()}}}var On=`https://www.google.com/recaptcha/api.js?render=`,kn=/* @__PURE__ */ new Map;function An(e){let t=kn.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=On+encodeURIComponent(e),r.async=!0,r.addEventListener(`load`,()=>t(globalThis.grecaptcha)),r.addEventListener(`error`,()=>{kn.delete(e),n(/* @__PURE__ */ Error(`The reCAPTCHA script did not load.`))}),document.head.append(r)});return kn.set(e,n),n}async function jn(e,t){let n=await An(e);return await new Promise(e=>n.ready(e)),n.execute(e,{action:t})}var Mn=`data-wui-chat-docked`,Nn=`--wui-chat-docked-width`,Pn=420,Fn=/* @__PURE__ */ new Set;function In(e,t){let n=document.documentElement;n.setAttribute(Mn,e),n.style.setProperty(Nn,t)}function Ln(){let e=document.documentElement;e.removeAttribute(Mn),e.style.removeProperty(Nn)}function Rn(e){let t=n({...e,layout:`docked`,role:`dialog`,launcher:!0}),r={},i=e.position,a=!1,o=null,s=()=>`${Math.round(t.panel.getBoundingClientRect().width)||Pn}px`;function c(){Fn.add(r),In(i,s()),typeof ResizeObserver==`function`&&(o=new ResizeObserver(()=>document.documentElement.style.setProperty(Nn,s())),o.observe(t.panel))}function l(){o?.disconnect(),o=null,Fn.delete(r),Fn.size===0&&Ln()}function u(e){t.setOpen(e),e&&!a?(a=!0,c()):!e&&a&&(a=!1,l())}function d(e){t.setAppearance(e),e.position!==void 0&&(i=e.position,a&&document.documentElement.setAttribute(Mn,i))}function f(){u(!1)}return{...t,setOpen:u,setAppearance:d,destroy:f}}function zn(e){return n({...e,layout:`embedded`,role:`region`,launcher:!1})}var Bn=`wchat:peeked`,Vn=576,Hn=200;function Un(e){let t=n({...e,layout:`launcher`,role:`dialog`,launcher:!0}),{root:r,panel:i,nudgeHost:a,launcherButton:o}=t,s={peek:!1,peekSeconds:3,hideWhileOpen:!1},c=!1,l=!1,u=null,d=null;function f(){!s.peek||c||l||a.dataset.launcher!==`idle`||globalThis.innerWidth<Vn||globalThis.sessionStorage.getItem(Bn)!==null||(globalThis.sessionStorage.setItem(Bn,`1`),a.dataset.launcher=`peeking`,u=setTimeout(()=>{u=null,a.dataset.launcher===`peeking`&&(a.dataset.launcher=`idle`)},s.peekSeconds*1e3))}a.addEventListener(`animationend`,e=>{e.target===a&&a.dataset.launcher===`idle`&&f()});function p(e){if(e!==l){if(l=e,clearTimeout(u),u=null,e)clearTimeout(d),d=null,s.hideWhileOpen?(a.dataset.launcher=`hidden`,a.toggleAttribute(`inert`,!0)):a.dataset.launcher===`peeking`&&(a.dataset.launcher=`idle`);else if(s.hideWhileOpen){let e=i.contains(document.activeElement);d=setTimeout(()=>{d=null,a.toggleAttribute(`inert`,!1),a.dataset.launcher=`idle`,e&&o.focus()},Hn)}}t.setOpen(e)}function m(e){e.reduced!==void 0&&(c=!!e.reduced),e.peek!==void 0&&(s.peek=e.peek),e.peekSeconds!==void 0&&(s.peekSeconds=e.peekSeconds),e.hideWhileOpen!==void 0&&(s.hideWhileOpen=e.hideWhileOpen),e.phoneMode!==void 0&&r.classList.toggle(`wui-chat--sheet`,e.phoneMode===`Sheet`),e.sheetHeightDvh!==void 0&&r.style.setProperty(`--wui-chat-sheet-height`,`${e.sheetHeightDvh}dvh`),e.sheetMaxHeightPx!==void 0&&r.style.setProperty(`--wui-chat-sheet-max-height`,`${e.sheetMaxHeightPx}px`),t.setAppearance(e),!s.hideWhileOpen&&a.dataset.launcher===`hidden`&&!l&&(a.dataset.launcher=`idle`),a.dataset.launcher===`idle`&&f()}return{...t,setOpen:p,setAppearance:m}}function Wn(e){return n({...e,layout:`full-page`,role:`region`,launcher:!1})}var Gn=3;function Kn(t){let n=a(`h2`,`wui-chat-greeting`),r=a(`div`,`wui-chat-empty-hero`);r.append(a(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),n);let i=a(`div`,`wui-chat-empty-extra`);i.hidden=!0;let o=a(`div`,`wui-chat-starters`,{role:`group`}),s=a(`div`,`wui-chat-empty-rows`),c=a(`div`,`wui-chat-empty-past`),l=a(`div`,`wui-chat-empty`);l.append(r,i,o,s,c);function u(n){let r=a(`button`,`wui-chat-starter`,{type:`button`});return n.icon&&r.append(e(n.icon,16)),r.append(document.createTextNode(n.label)),r.addEventListener(`click`,()=>t.onStarter(n)),r}function d(e,n){let r=a(`button`,`wui-chat-empty-row`,{type:`button`}),i=a(`span`,`wui-chat-empty-row-label`);i.textContent=n.resumeLast;let o=a(`span`,`wui-chat-empty-row-title`,{title:e.title||n.untitled});o.textContent=e.title||n.untitled;let s=a(`span`,`wui-chat-empty-row-time`);return s.textContent=k(e.lastActivityDateTimeUtc),r.append(i,o,s),r.addEventListener(`click`,()=>t.onResume()),r}function f(e,n,r){let i=r?a(`button`,`wui-chat-empty-row`,{type:`button`}):a(`span`,`wui-chat-empty-row`),o=a(`span`,`wui-chat-empty-row-label`);o.textContent=n.openTicketRow;let s=a(`span`,`wui-chat-empty-row-title`);s.textContent=`${e.number}: ${e.subject}`;let c=a(`span`,`wui-chat-empty-row-status`);return c.textContent=it(e.status,n),i.append(o,s,c),r&&i.addEventListener(`click`,()=>t.onTicket(e)),i}function p(e,t){if(e.features?.OpenTickets!==!0||!e.openTickets?.length)return null;let n=a(`div`,`wui-chat-open-tickets`,{role:`group`,"aria-label":t.openTickets});return n.append(...e.openTickets.slice(0,Gn).map(n=>f(n,t,e.ticketsClickable===!0))),n}function m(e){let{labels:t}=e;n.textContent=e.greeting??``;let r=e.starters??[];o.setAttribute(`aria-label`,t.starters),o.hidden=!e.showStarters||r.length===0,o.replaceChildren(...r.map(u));let i=e.resume??null,a=p(e,t);s.hidden=i===null&&a===null,s.replaceChildren(...[a,i===null?null:d(i,t)].filter(Boolean))}return{el:l,paint:m,extraHost:i,pastHost:c}}function qn(){let e=document.createElement(`div`);e.className=`wui-chat-loader-orb`;let t=document.createElement(`span`);t.className=`wui-chat-loader-orb-mark`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);n.className=`wui-chat-loader-orb-glow`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`span`);r.className=`wui-chat-loader-orb-disc`,r.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=document.createElement(`span`);return i.className=`wui-chat-loader-orb-label`,e.append(t,i),{el:e,render(e){i.textContent!==e.label&&(i.textContent=e.label)}}}var Jn=180;function Yn(){let e=document.createElement(`div`);e.className=`wui-chat-loader-phrases`;let t=document.createElement(`span`);t.className=`wui-chat-loader-phrases-orb`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);n.className=`wui-chat-loader-phrases-stage`,e.append(t,n);let r=null,i=null;function a(){return e.closest(`.wui-chat-loader`)?.classList.contains(`wui-chat-loader--reduced`)===!0}function o(e){if(e.label===r)return;r=e.label;let t=i,o=document.createElement(`span`);o.className=`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--in`,o.textContent=e.label,n.append(o),i=o,t&&(t.classList.remove(`wui-chat-loader-phrases-text--in`),t.classList.add(`wui-chat-loader-phrases-text--out`),a()?t.remove():setTimeout(()=>t.remove(),Jn))}return{el:e,render:o}}var Xn=[`95%`,`80%`,`60%`];function Zn(){let e=document.createElement(`div`);e.className=`wui-chat-loader-skeleton`;let t=document.createElement(`div`);t.className=`wui-chat-loader-skeleton-label`;let n=document.createElement(`div`);n.className=`wui-chat-loader-skeleton-body`;let r=document.createElement(`span`);r.className=`wui-chat-loader-skeleton-avatar`,r.setAttribute(`aria-hidden`,`true`),n.append(r);for(let e of Xn){let t=document.createElement(`span`);t.className=`wui-chat-loader-skeleton-line`,t.setAttribute(`aria-hidden`,`true`),t.style.width=e,n.append(t)}return e.append(t,n),{el:e,render(e){t.textContent!==e.label&&(t.textContent=e.label)}}}var Qn=`http://www.w3.org/2000/svg`;function $n(e){if(e===`done`){let e=document.createElementNS(Qn,`svg`);e.setAttribute(`viewBox`,`0 0 16 16`),e.setAttribute(`class`,`wui-chat-loader-steps-check`);let t=document.createElementNS(Qn,`path`);return t.setAttribute(`d`,`M3 8.5 6.5 12 13 4.5`),t.setAttribute(`pathLength`,`1`),e.append(t),e}let t=document.createElement(`span`);return t.className=e===`active`?`wui-chat-loader-steps-ring`:`wui-chat-loader-steps-dot`,t}function er(){let e=document.createElement(`div`);e.className=`wui-chat-loader-steps`;let t=document.createElement(`span`);t.className=`wui-chat-loader-steps-pill`;let n=document.createElement(`ol`);n.className=`wui-chat-loader-steps-list`,e.append(t,n);let r=[];function i(){let e=document.createElement(`li`);e.className=`wui-chat-loader-steps-item`;let t=document.createElement(`span`);t.className=`wui-chat-loader-steps-icon`,t.setAttribute(`aria-hidden`,`true`);let i=document.createElement(`span`);i.className=`wui-chat-loader-steps-text`,e.append(t,i);let a={li:e,icon:t,text:i,state:null};return r.push(a),n.append(e),a}function a(e){let a=e.steps.length===0;for(t.hidden=!a,n.hidden=a,a&&t.textContent!==e.label&&(t.textContent=e.label),e.steps.forEach((t,n)=>{let a=r[n]??i();a.text.textContent!==t&&(a.text.textContent=t);let o=n<e.activeIndex?`done`:n===e.activeIndex?`active`:`pending`;a.state!==o&&(a.state=o,a.li.dataset.state=o,a.icon.replaceChildren($n(o)))});r.length>e.steps.length;)r.pop().li.remove()}return{el:e,render:a}}var tr={Steps:er,Phrases:Yn,Orb:qn,Skeleton:Zn},nr=500;function rr(){let e=document.createElement(`div`);e.className=`wui-chat-loader`,e.setAttribute(`role`,`status`),e.hidden=!0;let t=document.createElement(`div`);t.className=`wui-chat-loader-body`;let n=document.createElement(`span`);n.className=`visually-hidden`,e.append(t,n);let r=null,i=null,a=0,o=null,s=0,c=null,l=!1;function u(){o!==null&&clearInterval(o),o=null}function d(){e.isConnected?(a+=1,f()):u()}function f(){if(!i||!r)return;let t=oe(r.style,r.steps,r.phrases,a);i.render(t),e.setAttribute(`aria-label`,t.label)}function p(){c!==null&&clearTimeout(c),c=null,l=!1,n.textContent=``}function m(e){!l&&c===null&&e&&(c=setTimeout(()=>{c=null,l=!0,n.textContent=e},nr))}function h(n){if(!n.active)r=null,e.hidden=!0,e.removeAttribute(`data-loading`),u(),p();else{if(!Object.hasOwn(tr,n.style))throw Error(`Unknown loader style. Use Steps, Phrases, Orb or Skeleton.`);if(!(n.intervalMs>0))throw Error(`Loader intervalMs must be a positive number.`);if(r={...n,steps:n.steps??[],phrases:n.phrases??[]},e.hidden=!1,e.setAttribute(`data-loading`,`true`),e.classList.toggle(`wui-chat-loader--reduced`,n.reduced===!0),!i||i.style!==n.style){let e=tr[n.style]();t.replaceChildren(e.el),i={style:n.style,render:e.render},a=0}m(n.announce),(o===null||s!==n.intervalMs)&&(u(),s=n.intervalMs,o=setInterval(d,s)),f()}}function g(){u(),p(),i=null,r=null,e.remove()}return{el:e,update:h,destroy:g}}var ir=/* @__PURE__ */ new Set([`Assistant`,`Agent`,`Script`]),ar=/* @__PURE__ */ new WeakMap;function or(e,t,n){let{labels:r,features:a,title:o}=n;if(j(t.parts)!==``){if(a.Share&&p()){let n=i(`ghost`,r.share,`share`,async()=>{let e=ur([t],a,r,o,!1);e!==``&&await f({title:o,text:e})===`failed`&&pr(n,r.shareFailed)});e.append(n)}if(a.Print){let t=i(`ghost`,r.print,`printer`,()=>{T(t.closest(`.wui-chat`),t.closest(`li.wui-chat-message`),{title:o,printedOn:fr(r)})});e.append(t)}}}function sr(e,t,n){if(t.streaming||t.thinking||t.loading||t.conversationId===null||t.messages.filter(e=>e.stored&&ir.has(e.author.kind)&&j(e.parts)!==``).length===0){e.hidden=!0;return}let{labels:r,features:i}=n,a=!!i.Share&&p(),o=!!i.Print;if(!a&&!o){e.hidden=!0;return}let s=[a,o,t.messages.length,r.shareConversation,r.printConversation].join(`|`);e.dataset.sig!==s&&(e.dataset.sig=s,e.replaceChildren(),a&&e.append(cr(r,i,n)),o&&e.append(lr(e,r,n))),e.hidden=!1}function cr(e,t,n){let r=i(`ghost`,e.shareConversation,`share`,async()=>{let i=n.getState(),a=dr(i,n),o=ur(i.messages.filter(e=>e.stored),t,e,a,!0);await f({title:a,text:o})===`failed`&&pr(r,e.shareFailed)});return r}function lr(e,t,n){return i(`ghost`,t.printConversation,`printer`,()=>{C(e.closest(`.wui-chat`),{title:dr(n.getState(),n),printedOn:fr(t)})})}function ur(e,t,n,r,i){let a=E(e,{labels:n,title:r,figureText:t.FigureText});return fe(a,{heading:i,speakers:i})}function dr(e,t){return typeof e.title==`string`&&e.title!==``?e.title:t.title}function fr(e){return e.printedOn(k((/* @__PURE__ */ new Date()).toISOString()))}function pr(e,t){let n=e.lastChild,r=ar.get(n);r?clearTimeout(r.timer):r={original:n.data},n.data=t,r.timer=setTimeout(()=>{n.data=r.original,ar.delete(n)},ge),ar.set(n,r)}function mr({voice:e,getLabels:t,message:n}){if(n.streaming||!e.canSpeak()||nn(n.parts)===``)return null;let r=e.getStatus(),i=r.mode===`Speaking`&&r.messageId===n.id,o=t(),s=i?o.readAloudStop:o.readAloud,c=a(`button`,`wui-chat-action-btn wui-chat-speak`,{type:`button`,"aria-pressed":String(i),"aria-label":s,title:s});return c.append(Kt(i?`stop`:`speaker`,16)),c.addEventListener(`click`,()=>{e.toggleSpeak(n.id,n.parts)}),c}var hr=/* @__PURE__ */ new Set([`Assistant`,`Agent`]),gr=/* @__PURE__ */ new Set([`Assistant`,`Agent`,`Script`]);function _r(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 X(t,n,i){let o=a(`button`,`${r(`ghost`,`sm`)} wui-chat-action-btn`,{type:`button`}),s=a(`span`);return s.textContent=t,o.append(e(n,14),s),o.addEventListener(`click`,i),{node:o,text:s}}function vr(e,t){return e.profile?.assistant.name??t.panelTitle}function yr(e,t){return e.author.displayName==null?e.author.kind===`Visitor`||e.author.kind===`Customer`?t.you:e.author.kind===`Agent`?t.agent:t.assistant:e.author.displayName}function br(t){let n=a(`ol`,`wui-chat-thread`,{"aria-live":`polite`}),i=rr(),o=a(`li`,`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`),s=a(`div`,`wui-chat-loader-slot`);s.append(i.el),o.append(s);let c=a(`li`,`wui-chat-conversation-actions`);c.hidden=!0;let u=/* @__PURE__ */ new Map,d=``,f=null;function p(e,t,n){return n[e.kind]?{kind:e.kind,part:e,tag:n[e.kind]}:{kind:`Notice`,part:{kind:`Notice`,code:`NeedsNewerApp`,text:t.needsNewerApp},tag:n.Notice}}function m(e,n,r){let i=document.createElement(e);return i.message=r,i.turn=t.makeTurnApi(r.id),i.part=n,i}function h(e){return a(`div`,`wui-chat-part wui-chat-part--${e.toLowerCase()}`)}function g(e,t,n,r,i){e.parts=[];let o=[],s=e=>{let i=p(e,n,r),a=h(i.kind);return a.append(m(i.tag,i.part,t)),a};for(let e of i(t))if(Array.isArray(e)){let t=a(`div`,`wui-chat-part-group`);t.append(...e.map(s)),o.push(t)}else o.push(s(e));e.body.replaceChildren(...o)}function _(e,n,r,i){let a=[];n.parts.forEach((o,s)=>{let c=p(o,r,i),l=e.parts[s];if(l&&l.kind===c.kind&&l.tag===c.tag){l.part!==c.part&&(l.element.message=n,l.element.turn=t.makeTurnApi(n.id),l.element.part=c.part,l.part=c.part),a.push(l);return}let u=h(c.kind),d=m(c.tag,c.part,n);u.append(d),a.push({kind:c.kind,tag:c.tag,part:c.part,element:d,wrapper:u})}),e.parts=a,e.body.replaceChildren(...a.map(e=>e.wrapper))}function v(t,n,i){let o=a(`div`,`wui-chat-rating`,{role:`group`,"aria-label":`${i.rateUp}/${i.rateDown}`});for(let[s,c,l]of[[`Up`,i.rateUp,`check`],[`Down`,i.rateDown,`x`]]){let u=n.rating===s,d=a(`button`,`${r(u?`neutral`:`ghost`,`sm`)} wui-chat-action-btn`,{type:`button`,"aria-pressed":String(u)}),f=a(`span`);f.textContent=c,d.append(e(l,14),f),d.addEventListener(`click`,()=>y(t,n,s,i)),o.append(d)}if(t.ratingNote){let e=a(`span`,null,{role:`status`});e.textContent=t.ratingNote,o.append(e)}return o}async function y(e,n,r,i){try{await t.onRate(n.id,r),e.ratingNote=i.rated}catch{e.ratingNote=i.ratingFailed}f&&D(f.state,f.context)}function b(e,n,r,i,o){let{labels:s}=i,c=r.features,l=n.author.kind,u=j(n.parts),d=[];if(c.Copy&&gr.has(l)&&u){let t=X(s.copy,`copy`,async()=>{await ve(u)&&(t.text.textContent=s.copied,clearTimeout(e.copyTimer),e.copyTimer=setTimeout(()=>{t.text.textContent=s.copy},ge))});d.push(t.node)}let f=t.getVoice?.();if(f&&gr.has(l)){let e=mr({voice:f,getLabels:()=>s,message:n});e&&d.push(e)}if(gr.has(l)){let e=a(`div`);or(e,n,{labels:s,features:c,title:vr(r,s)}),d.push(...e.childNodes)}let p=r.messages.some(e=>e.author.kind===`Visitor`&&e.stored);o&&l===`Assistant`&&!r.streaming&&c.Regenerate&&p&&d.push(X(s.regenerate,`refresh`,()=>t.onRegenerate()).node);let m=r.messages.findLast(e=>e.author.kind===`Visitor`&&e.stored);c.Edit&&m?.id===n.id&&!r.streaming&&!r.thinking&&d.push(X(s.edit,`pencil`,()=>t.getSession().startEdit(n.id)).node),c.Rating&&n.stored&&hr.has(l)&&d.push(v(e,n,s)),e.actions.hidden=d.length===0,e.actions.replaceChildren(...d)}function x(e){let t=u.get(e.id);if(t)return t;let n=a(`li`,`wui-chat-message`),r=a(`span`,`wui-chat-author visually-hidden`),i=a(`div`,`wui-chat-message-body`),o=a(`div`,`wui-chat-message-actions`);n.append(r,i,o);let s={li:n,author:r,body:i,actions:o,head:null,parts:[],copyTimer:null,ratingNote:null};return u.set(e.id,s),s}function S(e,t,n,r){let i=n?.author.kind===`Agent`&&t.author.kind===`Agent`&&(n.author.displayName??``)===(t.author.displayName??``);e.head?.remove(),e.head=t.author.kind===`Agent`&&!i?tt(t.author,r):null,e.head&&e.li.insertBefore(e.head,e.body)}function C(e,n,r,i,a,o){let{labels:s}=i;e.li.className=`wui-chat-message wui-chat-message--${n.author.kind.toLowerCase()}`,e.li.toggleAttribute(`data-restored`,n.restored===!0),n.streaming?e.li.setAttribute(`aria-busy`,`true`):e.li.removeAttribute(`aria-busy`),e.author.textContent=`${yr(n,s)}: `,S(e,n,o,s);let c=t.getRenderers(),l=t.getLayoutParts();typeof l==`function`?g(e,n,s,c,l):_(e,n,s,c),n.streaming?(e.actions.hidden=!0,e.actions.replaceChildren()):b(e,n,r,i,a)}function w(e,t){let n=a(`li`,`wui-chat-message wui-chat-message--system wui-chat-message--notice`),r=a(`div`,`wui-chat-notice wui-chat-notice--info`,{role:`status`}),i=e.resetsAtUtc?` ${t.dailyLimitRefresh(l(e.resetsAtUtc))}`:``;return r.textContent=`${e.message}${i}`,n.append(r),n}function T(e,n){let{labels:r}=n;if(e.turnError?.code===`daily_limit`)return w(e.turnError,r);let i=a(`li`,`wui-chat-message wui-chat-message--system wui-chat-message--error`),o=a(`p`,`wui-chat-error`,{role:`alert`});if(o.textContent=e.turnError?.message||r.stopped,i.append(o),e.features.Retry){let e=a(`div`,`wui-chat-message-actions`);e.append(X(r.retry,`rotate-ccw`,()=>t.onRetry()).node),i.append(e)}return i}function E(e){let t=e.messages.at(-1),r=t?`${t.id}|${j(t.parts).length}`:``;if(r===d)return;d=r;let i=_r(n);i&&(i.scrollTop=i.scrollHeight)}function D(e,r){f={state:e,context:r};let{labels:a}=r;n.setAttribute(`aria-label`,a.thread);let s=[],l=/* @__PURE__ */ new Set,d=e.messages.filter(e=>!(e.streaming&&e.parts.length===0));d.forEach((t,n)=>{let i=x(t);l.add(t.id),C(i,t,e,r,n===d.length-1,d[n-1]??null),s.push(i.li)});for(let e of[...u.keys()])l.has(e)||u.delete(e);e.agentTyping&&s.push(nt(e.agentTyping,a)),e.thinking?(i.update({active:!0,style:r.loaderStyle,steps:e.steps,phrases:r.phrases,intervalMs:r.intervalMs,reduced:r.reduced,announce:r.assistantName?a.preparingAnswer(r.assistantName):void 0}),s.push(o)):i.update({active:!1}),!e.streaming&&(e.turnError||e.stopped)&&s.push(T(e,r)),sr(c,e,{labels:a,features:e.features,title:vr(e,a),getState:()=>t.getSession().getState()}),s.push(c),n.replaceChildren(...s),E(e)}function O(e){return u.get(e)?.li??null}function ee(){i.destroy(),u.clear(),f=null,n.remove()}return{el:n,paint:D,find:O,destroy:ee}}var xr=typeof HTMLElement>`u`?class{}:HTMLElement;function Sr(e,t){if(e.conversationState===`WaitingForAgent`)return t.statusWaitingForAgent;if(e.conversationState===`WithAgent`){let n=e.agent?.displayName;return t.statusWithAgent(typeof n==`string`&&n.trim()!==``?n:t.handoffAgentFallback)}return t.headerStatus}function Cr(e,t,n){return t.PanelSwitch!==!0||typeof n!=`function`?null:e===`docked`?`full-page`:e===`full-page`?`docked`:null}var wr=[`launcher`,`docked`,`full-page`,`embedded`],Tr=[`end`,`start`],Er={steps:`Steps`,phrases:`Phrases`,orb:`Orb`,skeleton:`Skeleton`},Dr={on:`On`,reduced:`Reduced`},Or=[`auto`,`light`,`dark`],kr=`wchat:muted`,Ar=6e4,jr=400,Mr=[`labels`,`pageContext`,`compact`,`open`,`layoutParts`,`getCaptchaToken`,`openAttachment`,`openCitation`,`openTarget`,`openTicket`,`onNavigate`,`resolveLink`,`emptyContent`,`onPanelSwitch`,`preloadPanelSwitch`],Nr={...Zt};function Pr(e,t){if(!s.includes(e))throw Error(`Unknown part kind "${e}". Use one of ${s.join(`, `)}.`);if(typeof t!=`string`||!t.includes(`-`))throw Error(`Renderer tag "${t}" must be a custom element name containing a hyphen.`)}function Z(e,t){return n=>{let r=n.toLowerCase();if(!Object.hasOwn(t,r))throw Error(`<wui-chat ${e}> must be one of ${Object.keys(t).join(`, `)}, got "${n}".`);return t[r]}}function Q(e){return t=>{let n=Number(t);if(!Number.isInteger(n)||n<0)throw Error(`<wui-chat ${e}> must be a whole number of pixels, got "${t}".`);return n}}function Fr(e){return t=>{if(t===``||t===`true`)return!0;if(t===`false`)return!1;throw Error(`<wui-chat ${e}> must be true or false, got "${t}".`)}}var $=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),Ir=[[`launcher-style`,`launcher`,`style`,Z(`launcher-style`,{round:`Round`,pill:`Pill`})],[`entrance`,`launcher`,`entrance`,Z(`entrance`,{"slide-up":`SlideUp`,"bounce-in":`BounceIn`,"fade-in-pulse":`FadeInPulse`,"spin-scale":`SpinScale`,"wiggle-in":`WiggleIn`,"elastic-in":`ElasticIn`,rise:`Rise`,none:`None`})],[`idle`,`launcher`,`idle`,Z(`idle`,{"float-and-pulse":`FloatAndPulse`,ring:`Ring`,none:`None`})],[`label-reveal`,`launcher`,`labelReveal`,Z(`label-reveal`,{bubble:`Bubble`,expand:`Expand`})],[`compact`,`launcher`,`compact`,Fr(`compact`)],[`panel-motion`,`panel`,`motion`,Z(`panel-motion`,{spring:`Spring`,none:`None`})],[`panel-width`,`panel`,`widthPx`,Q(`panel-width`)],[`panel-max-height`,`panel`,`maxHeightPx`,Q(`panel-max-height`)],[`panel-bottom-gap`,`panel`,`bottomGapPx`,Q(`panel-bottom-gap`)],[`phone-max-width`,`phone`,`maxWidthPx`,Q(`phone-max-width`)],[`phone-mode`,`phone`,`mode`,Z(`phone-mode`,{"full-screen":`FullScreen`,sheet:`Sheet`})],[`sheet-height-dvh`,`phone`,`sheetHeightDvh`,Q(`sheet-height-dvh`)],[`sheet-max-height`,`phone`,`sheetMaxHeightPx`,Q(`sheet-max-height`)],[`input-ring`,`input`,`ring`,Fr(`input-ring`)],[`send-reveal`,`input`,`sendReveal`,Z(`send-reveal`,{"on-text":`OnText`,always:`Always`})],[`lift-selectors`,`avoid`,`liftSelectors`,$],[`menu-selectors`,`avoid`,`menuSelectors`,$],[`dark-selectors`,`avoid`,`darkSelectors`,$],[`autoopen-busy-selectors`,`avoid`,`autoOpenBusySelectors`,$],[`autoopen-optout-selector`,`avoid`,`autoOpenOptOutSelector`,e=>e]],Lr={layout:`launcher`,position:`end`,"offset-x":`24`,"offset-y":`24`,loader:`steps`,motion:`on`,icon:`chat`},Rr=[`base`,`layout`,`position`,`offset-x`,`offset-y`,`loader`,`screen`,`motion`,`theme`,`icon`,`narrow`,...Ir.map(([e])=>e).filter(e=>e!==`compact`)],zr=e=>e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase());function Br(e){let t={launcher:{},panel:{},phone:{},input:{},avoid:{}};for(let[n,r,i,a]of Ir){let o=e.getAttribute(n);o!=null&&(t[r][i]=a(o))}let n=e.getAttribute(`motion`);return ce({...t,motion:n==null?void 0:Z(`motion`,Dr)(n)})}function Vr(e){let t=e.getAttribute(`loader`)??`steps`;if(!Object.hasOwn(Er,t))throw Error(`<wui-chat loader> must be one of ${Object.keys(Er).join(`, `)}, got "${t}".`);return Er[t]}function Hr(e){let t=e.getAttribute(`narrow`);if(t!=null&&t!==``)return Object.fromEntries($(t).map(e=>[e,!1]))}function Ur(e){return e===kr?globalThis.localStorage:globalThis.sessionStorage}var Wr={get:e=>Ur(e).getItem(e),set:(e,t)=>Ur(e).setItem(e,t)};function Gr(e){return globalThis.innerWidth<=e.phone.maxWidthPx}function Kr(e){let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}var qr=0,Jr=class extends xr{static get observedAttributes(){return[...Rr,`compact`,`open`,`labels`,`page-context`,`narrow`].filter((e,t,n)=>n.indexOf(e)===t)}constructor(){super(),qr+=1,this._uid=`wui-chat-${qr}`,this._built=!1,this._session=null,this._unsubscribe=null,this._voice=null,this._voiceConversationId=void 0,this._shell=null,this._labelsProp=void 0,this._pageContextProp=void 0,this._layoutParts=null,this._renderers={...Nr},this._rendererApi={define:(e,t)=>{Pr(e,t),this._renderers[e]=t,this._render()},map:this._renderers},this._captchaToken=null,this._openAttachmentProp=null,this._openCitationProp=null,this._openTargetProp=null,this._resolveLinkProp=null,this._openTicketProp=void 0,this._emptyContentProp=null,this._onPanelSwitchProp=null,this._preloadPanelSwitchProp=null,this._preloaded=!1,this._pastList=null,this._past=null,this._pastRefreshed=!1,this._historyShown=!1,this._openedConversation=null,this._lastOpen=!1,this._openTrigger=`manual`,this._focusTimer=null,this._nudgeArmed=!1,this._seeded=!1,this._wasLoading=!1,this._seen=/* @__PURE__ */ new Set,this._sound=null,this._behaviour=null,this._autoOpen=null,this._avoid=null,this._motion=null,this._phone=null,this._onKeyDown=e=>{e.key===`Escape`&&this._session?.getState().open&&(e.stopPropagation(),this._session.close(`escape`))}}get session(){return this._session??null}get conversationId(){return this._session?.getState().conversationId??null}get labels(){return se({...m(this,`labels`),...this._labelsProp})}set labels(e){this._labelsProp=e??void 0,this._render()}get pageContext(){return this._pageContextProp===void 0?m(this,`page-context`):this._pageContextProp}set pageContext(e){this._pageContextProp=e===null?void 0:e}get compact(){return this.hasAttribute(`compact`)}set compact(e){this.toggleAttribute(`compact`,e===!0||e===``||e===`true`)}get open(){return this.hasAttribute(`open`)}set open(e){this.toggleAttribute(`open`,e===!0||e===``||e===`true`)}get renderers(){return this._rendererApi}get layoutParts(){return this._layoutParts}set layoutParts(e){this._layoutParts=typeof e==`function`?e:null,this._render()}get getCaptchaToken(){return this._captchaToken}set getCaptchaToken(e){this._captchaToken=typeof e==`function`?e:null}get openAttachment(){return this._openAttachmentProp??(e=>this._defaultOpenAttachment(e))}set openAttachment(e){this._openAttachmentProp=typeof e==`function`?e:null}get openCitation(){return this._openCitationProp??((e,t)=>this._defaultOpenCitation(e,t))}set openCitation(e){this._openCitationProp=typeof e==`function`?e:null}get openTarget(){return this._openTargetProp??(e=>this._defaultOpenTarget(e))}set openTarget(e){this._openTargetProp=typeof e==`function`?e:null}get openTicket(){return this._openTicketProp}set openTicket(e){this._openTicketProp=typeof e==`function`?e:void 0}get onNavigate(){return this._onNavigateProp}set onNavigate(e){this._onNavigateProp=typeof e==`function`?e:void 0}get resolveLink(){return this._resolveLinkProp}set resolveLink(e){this._resolveLinkProp=typeof e==`function`?e:null}get emptyContent(){return this._emptyContentProp}set emptyContent(e){if(e!==null&&!(e instanceof Node))throw TypeError(`emptyContent must be a Node or null`);this._emptyContentProp=e,this._applyEmptyContent()}get onPanelSwitch(){return this._onPanelSwitchProp}set onPanelSwitch(e){this._onPanelSwitchProp=typeof e==`function`?e:null}get preloadPanelSwitch(){return this._preloadPanelSwitchProp}set preloadPanelSwitch(e){this._preloadPanelSwitchProp=typeof e==`function`?e:null}connectedCallback(){if(this._adoptEarlyProperties(),this._assertLayout(),this._assertPosition(),this.base.trim()===``)throw TypeError(`<wui-chat> needs a base path, e.g. base="/api/assistant".`);this._built||this._build(),this._shell||this._buildShell(),this._session||this._createSession(),this._past||this._createPast(),this._unsubscribe||=this._session.subscribe(()=>this._render()),this._render()}_adoptEarlyProperties(){for(let e of Mr){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}disconnectedCallback(){this._voice?.stop(),this._session?.stop(),this._unsubscribe?.(),this._unsubscribe=null,this._disposePast(),this._shell?.destroy?.(),document.removeEventListener(`keydown`,this._onKeyDown),this._avoid?.destroy(),this._avoid=null,this._autoOpen?.cancel(),this._autoOpen=null,this._motion?.destroy(),this._motion=null}attributeChangedCallback(e,t,n){if(this._built&&t!==n){if(e===`layout`)this._assertLayout(),this._buildShell();else if(e===`position`)this._assertPosition();else if(e===`base`||e===`screen`||e===`narrow`)this._resetSession();else if(e===`motion`)this._motion?.destroy(),this._motion=null;else if(e===`open`&&this._session){let e=this._session.getState().open;this.open!==e&&this._setOpen(this.open,`manual`)}this._render()}}toggle(){this._session&&(this._session.getState().open?this._session.close(`button`):this._setOpen(!0,`manual`))}close(){this._voice?.stop(),this._session?.close(`button`)}newConversation(){this._voice?.stop(),this._session?.newConversation(),this._past?.refresh()}reset(){this._voice?.stop(),this._session?.reset()}_setOpen(e,t){this._session&&(e?(this._openTrigger=t,this._session.open({trigger:t})):this._session.close(`button`))}_assertLayout(){let e=this.layout;if(!wr.includes(e))throw Error(`<wui-chat layout> must be one of ${wr.join(`, `)}, got "${e}".`)}_assertPosition(){let e=this.position;if(!Tr.includes(e))throw Error(`<wui-chat position> must be one of ${Tr.join(`, `)}, got "${e}".`)}_isLauncherLike(){return this.layout===`launcher`||this.layout===`docked`}_build(){this._built=!0,this._header=vn({onNew:()=>this.newConversation(),onHistory:()=>this._toggleHistory(),onClose:()=>this.close(),onMute:()=>this._session?.setMuted(!this._session.getState().muted),onSwitch:()=>this._switchPanel()}),this._starters=Kn({onStarter:e=>this._session.submit(e.message),onResume:()=>this._session.resumeLast(),onTicket:e=>{typeof this.openTicket==`function`&&this.openTicket({ticketId:e.ticketId,number:e.number})}}),this._applyEmptyContent(),this._voice=an({getState:()=>this._session.getState(),getLabels:()=>this.labels,getToken:()=>this._session.client.getSpeechToken()}),this._voice.subscribe(()=>this._render()),this._thread=br({getRenderers:()=>this._renderers,getLayoutParts:()=>this._layoutParts,makeTurnApi:e=>this._makeTurnApi(e),onRetry:()=>this._session.retry(),onRegenerate:()=>this._session.regenerate(),onRate:(e,t)=>this._session.rate(e,t),getSession:()=>this._session,getVoice:()=>this._voice}),this._composer=pn({voice:this._voice,onSubmit:e=>this._session.submit(e),onStop:()=>this._session.stop(),onAttach:e=>this._session.attach(e),onRemove:e=>this._session.removeAttachment(e),onCancelEdit:()=>this._session.cancelEdit(),onTyping:()=>this._session.notifyTyping(),onDraftApplied:()=>this._session.consumeDraft()}),this._footer=_n(),this._history=bn({getClient:()=>this._session.client,getLabels:()=>this.labels,getFeatures:()=>this._session.getState().features,onOpen:e=>{this._session.openConversation(e).catch(()=>{}),this._toggleHistory(!1)},onDeleted:e=>{e===this.conversationId&&this._session.newConversation()}}),this._nudge=En({onActivate:()=>this._setOpen(!0,`manual`),onDismiss:()=>{}}),this._status=a(`p`,null,{role:`status`}),this._status.hidden=!0,this._errorEl=a(`p`,`wui-chat-profile-error`,{role:`alert`}),this._errorEl.hidden=!0,this._body=a(`div`,`wui-chat-body`),this._body.append(this._starters.el,this._thread.el,this._history.el,this._status,this._errorEl),this._foot=a(`div`,`wui-chat-foot`),this._foot.append(...this._composer.nodes,this._footer.el)}_buildShell(){let e={launcher:Un,docked:Rn,"full-page":Wn,embedded:zn};this._shell?.destroy?.(),this._avoid?.destroy(),this._avoid=null,this._autoOpen?.cancel(),this._autoOpen=null,this._lastOpen=!1,this._launcherPlayed=!1;let t=e[this.layout]({id:`${this._uid}-panel`,position:this.position,onToggle:()=>this.toggle()});t.panel.append(this._header.el,this._body,this._foot),t.panel.addEventListener(`keydown`,e=>{e.key===`Tab`&&S(t.panel,e)}),t.nudgeHost&&t.nudgeHost.prepend(this._nudge.el),this._shell=t,this.replaceChildren(t.root)}_createSession(){let e=D(Tn(),{base:this.base}),t=Hr(this);this._session=O(e,{screen:this.screen||void 0,narrow:t,pageContext:()=>this.pageContext,behaviour:()=>this._behaviour?.()??null,prefs:Wr,reducedMotion:()=>this._motion?.reduced??!1,schedule:Kr,getCaptchaToken:e=>{if(this._captchaToken)return this._captchaToken(e);let t=this._session?.getState().profile?.captcha?.siteKey;return t?jn(t,e):Promise.resolve(null)},onEvent:(e,t)=>{this.dispatchEvent(new CustomEvent(`wui-chat-event`,{bubbles:!0,detail:{name:e,data:t}}))},onError:()=>{},labels:this.labels}),this._unsubscribe=null,this._lastOpen=!1,this._openApplied=!1,this._seeded=!1,this._wasLoading=!1,this._seen=/* @__PURE__ */ new Set,this._pastRefreshed=!1}_createPast(){this._pastList=ee({client:this._session.client,pageSize:20}),this._past=Dn({list:this._pastList,getLabels:()=>this.labels,getFeatures:()=>this._session.getState().features,onOpen:e=>{this._session.openConversation(e).catch(()=>{})}}),this._starters.pastHost.append(this._past.el)}_disposePast(){this._past&&(this._past.el.remove(),this._past.dispose(),this._pastList.dispose(),this._past=null,this._pastList=null)}_applyEmptyContent(){if(!this._starters)return;let e=this._starters.extraHost;e.replaceChildren(...this._emptyContentProp?[this._emptyContentProp]:[]),e.hidden=!this._emptyContentProp}_switchPanel(){let e=this._session.getState(),t=Cr(this.layout,e.features,this._onPanelSwitchProp);t!==null&&this._onPanelSwitchProp({from:this.layout,to:t,conversationId:e.conversationId,draft:this._composer.getDraft()})}_resetSession(){this._voice?.stop(),this._unsubscribe?.(),this._unsubscribe=null,this._session?.dispose(),this._session=null,this._disposePast(),this._history.dispose(),this.isConnected&&(this._createSession(),this._createPast(),this._unsubscribe=this._session.subscribe(()=>this._render()))}_toggleHistory(e=!this._historyShown){this._historyShown=e,e?this._history.show():this._history.hide(),this._render()}_makeTurnApi(e){let t=te(this._session,{messageId:e,labels:this.labels,openAttachment:e=>this.openAttachment(e),openCitation:t=>this.openCitation(e,t),openTarget:e=>this.openTarget(e),openTicket:this.openTicket,onNavigate:this.onNavigate});return t.resolveLink=this.resolveLink,t}_defaultOpenAttachment(e){this._session.client.getAttachment(e.attachmentId).then(t=>{let n=URL.createObjectURL(new Blob([t],{type:e.contentType}));window.open(n,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(n),Ar)}).catch(e=>globalThis.reportError?.(e))}_defaultOpenCitation(e,t){let n=this._thread.find(e);if(n){for(let e of n.querySelectorAll(`[data-marker]`))if(e.dataset.marker===String(t)){e.focus();return}}}_defaultOpenTarget(e){/^https?:\/\//i.test(e)?window.open(e,`_blank`,`noopener`):window.location.assign(e)}_render(){this._built&&this._session&&this._paint(this._session.getState())}_paint(e){e.conversationId!==this._voiceConversationId&&(this._voiceConversationId=e.conversationId,this._voice.stop());let t=this.labels,n=e.profile,r=this._isLauncherLike();if(!n){this.hidden=r,this._header.el.hidden=!0,this._starters.el.hidden=!0,this._thread.el.hidden=!0,this._history.el.hidden=!0,this._foot.hidden=!0,this._errorEl.hidden=e.profileError==null,e.profileError&&(this._errorEl.textContent=e.profileError.message),this._status.hidden=e.profileError!=null,this._status.textContent=t.loadingConversation,this._shell.panel.setAttribute(`aria-busy`,String(e.profileError==null));return}if(this._shell.panel.removeAttribute(`aria-busy`),!e.features.VisitorChat){this.hidden=!0,this._status.hidden=!0;return}this.hidden=!1;let i=e.features,a=Br(this);this._ensureRuntime(e,n,a,t);let o=e.loading,s=e.loadError,c=e.messages.length===0&&!o,l=this._historyShown,u=e.messages.some(e=>e.author.kind===`Visitor`),d=Cr(this.layout,i,this._onPanelSwitchProp),f=e.streaming||e.thinking;this._header.paint({labels:t,title:n.assistant.name,tagline:n.assistant.tagline,status:Sr(e,t),canNew:!f,showNew:this.layout===`full-page`||u,showHistory:i.History,showClose:r||this.layout===`full-page`&&d!==null,switchTo:d,canSwitch:!f,viewingHistory:l,showMute:i.Sounds&&n.experience.sound.muteControl,muted:e.muted}),this._starters.el.hidden=!c||l,c&&this._starters.paint({labels:t,greeting:e.greeting,starters:e.starters,showStarters:i.Starters&&!e.streaming,resume:!i.History&&i.ResumeLast?e.lastConversation:null,openTickets:e.openTickets,features:e.features,ticketsClickable:typeof this.openTicket==`function`}),i.History&&!this._pastRefreshed&&(this._pastRefreshed=!0,this._past?.refresh()),this._past?.paint();let p=!c&&!o&&!s&&!l;this._thread.el.hidden=!p,p&&this._thread.paint(e,{labels:t,loaderStyle:Vr(this),reduced:this._motion?.reduced??!1,phrases:n.experience.pacing.thinkingPhrases,intervalMs:n.experience.pacing.phraseIntervalMs,assistantName:n.assistant.name}),this._status.hidden=!o||l,this._status.textContent=t.loadingConversation,this._errorEl.hidden=!s||l,s&&(this._errorEl.textContent=s.message),this._foot.hidden=l,this._composer.paint({state:e,labels:t,maxLength:n.limits.maxMessageLength,accept:n.limits.contentTypes.join(`,`),draft:e.draft??null}),this._footer.paint({labels:t,profile:n}),this._history.el.hidden=!l,this._syncOpen(e,n,i,t,r),this._syncConversation(e),this._playSounds(e)}_ensureRuntime(e,t,n,r){let i=e.features;this._motion||(this._motion=x(n,t.experience),this._motion.subscribe(()=>this._render())),i.Sounds&&!this._sound&&(this._sound=c(t.experience.sound,Wr)),!i.Sounds&&this._sound&&(this._sound=null),i.BehaviourStarters&&!this._behaviour&&(this._behaviour=d(t.start.behaviour?.servicePathPrefixes??[]));let a=this._isLauncherLike();a&&!this._avoid&&this.layout===`launcher`&&(this._avoid=b(n.avoid,t.experience.launcher,this._shell.nudgeHost)),this.layout===`launcher`&&i.AutoOpen&&!this._autoOpen&&(this._autoOpen=_(t.experience.autoOpen,n,{open:()=>this._setOpen(!0,`auto`),isOpen:()=>this._session.getState().open,panelRect:()=>this._shell.panel.getBoundingClientRect()}));let o=Gr(n);this._shell.setLabels(r),this._shell.setAppearance({position:this.position,offsetX:this.hasAttribute(`offset-x`)?Q(`offset-x`)(this.getAttribute(`offset-x`)):void 0,offsetY:this.hasAttribute(`offset-y`)?Q(`offset-y`)(this.getAttribute(`offset-y`)):void 0,width:`${n.panel.widthPx}px`,maxHeight:n.panel.maxHeightPx,bottomGap:n.panel.bottomGapPx,reduced:this._motion.reduced,theme:Or.includes(this.getAttribute(`theme`))?this.getAttribute(`theme`):`auto`,icon:this.icon,launcherStyle:n.launcher.style,compact:n.launcher.compact,labelReveal:n.launcher.labelReveal,entrance:n.launcher.entrance,idle:n.launcher.idle,phone:o,hoverLabel:t.experience.launcher.hoverLabel,peek:t.experience.launcher.peek,peekSeconds:t.experience.launcher.peekSeconds,hideWhileOpen:t.experience.launcher.hideWhileOpen,phoneMode:n.phone.mode,sheetHeightDvh:n.phone.sheetHeightDvh,sheetMaxHeightPx:n.phone.sheetMaxHeightPx,launcherState:this._launcherPlayed?void 0:`entering`}),this._launcherPlayed=!0,this._shell.root.classList.toggle(`wui-chat--phone`,a&&Gr(n))}_syncOpen(e,t,n,r,i){if(i){if(!this._openApplied&&(this._openApplied=!0,this.hasAttribute(`open`)&&!e.open))this._setOpen(!0,`manual`);else if(this._shell.setOpen(e.open),this.toggleAttribute(`open`,e.open),e.open!==this._lastOpen&&(this._lastOpen=e.open,this._onOpenChange(e.open)),e.open)this._nudge.cancel(),this._nudgeArmed=!1,this._autoOpen?.cancel();else if(n.Nudges&&this.layout===`launcher`&&!this._nudgeArmed){let e=le(t,n);e&&(this._nudge.schedule({text:e.text,delaySeconds:e.delaySeconds,label:r.nudgeDismiss}),this._nudgeArmed=!0)}}}_onOpenChange(e){let t=Gr(Br(this));if(e){if(document.addEventListener(`keydown`,this._onKeyDown),this._sound?.play(`open`),this._past?.refresh(),this.layout===`docked`&&!this._preloaded&&typeof this._preloadPanelSwitchProp==`function`){this._preloaded=!0;try{this._preloadPanelSwitchProp()?.catch?.(()=>{})}catch{}}if(t){let e=Br(this);this._phone={fit:v(this._shell.panel,e),unlock:y(this._thread.el)}}else this._openTrigger===`manual`&&(this._focusTimer=setTimeout(()=>{this._focusTimer=null,this._composer.focus()},jr))}else document.removeEventListener(`keydown`,this._onKeyDown),clearTimeout(this._focusTimer),this._focusTimer=null,this._phone?.fit.destroy(),this._phone?.unlock(),this._phone=null,this._historyShown&&(this._historyShown=!1,this._history.hide(),this._render()),g(this._shell.launcherButton)}_syncConversation(e){let t=this.getAttribute(`conversation-id`);t&&t!==this._openedConversation&&!e.loading&&(this._openedConversation=t,e.conversationId!==t&&this._session.openConversation(t).catch(()=>{}))}_playSounds(e){if(e.loading){this._wasLoading=!0;for(let t of e.messages)this._seen.add(t.id)}else if(this._wasLoading||!this._seeded){this._wasLoading=!1,this._seeded=!0;for(let t of e.messages)this._seen.add(t.id)}else for(let t of e.messages)this._seen.has(t.id)||(this._seen.add(t.id),this._announce(t))}_announce(e){if(!this._sound||e.restored||e.parts.some(e=>e.kind===`Notice`))return;let t=e.author.kind;if(t===`Visitor`)this._sound.play(`sent`);else if(t===`Assistant`||t===`Script`||t===`Agent`){this._sound.play(`reply`);let e=this._session.getState().profile;e?.experience.sound.vibrate&&u(e.experience.sound.vibrateMs,this._sound.isMuted())}}};Object.defineProperty(Jr.prototype,"layout",{get(){return this.getAttribute(`layout`)??Lr.layout},set(e){this.setAttribute(`layout`,String(e))}});for(let e of Rr)e!==`layout`&&Object.defineProperty(Jr.prototype,zr(e),{configurable:!0,get(){return this.getAttribute(e)??Lr[e]??``},set(t){t==null?this.removeAttribute(e):this.setAttribute(e,String(t))}});typeof customElements<`u`&&!customElements.get(`wui-chat`)&&customElements.define(`wui-chat`,Jr);export{Jr as WuiChat,Zt as defaultRenderers};
package/dist/chat.css ADDED
@@ -0,0 +1 @@
1
+ wui-chat{display:contents}.wui-chat{--wui-chat-accent: var(--wui-primary);--wui-chat-accent-contrast: var(--wui-primary-text);--wui-chat-accent-soft: var(--wui-primary-5);--wui-chat-surface: var(--color-surface);--wui-chat-border: var(--color-border);--wui-chat-text: var(--color-text-body);--wui-chat-text-muted: var(--color-text-muted);--wui-chat-question-bg: var(--color-bg-muted);--wui-chat-radius: 14px;--wui-chat-radius-sm: 8px;--wui-chat-shadow: var(--wui-shadow-popover);--wui-chat-gradient: conic-gradient(from 200deg, var(--wui-primary), var(--wui-info), var(--wui-success), var(--wui-primary));--wui-chat-font: var(--wui-font-ui, inherit);--wui-chat-ease: cubic-bezier(0.2, 0.8, 0.2, 1);--wui-chat-lift: 0px;--wui-chat-launcher-block: 0px;font-family:var(--wui-chat-font);color:var(--wui-chat-text)}[data-theme=dark] .wui-chat{--wui-chat-accent-soft: color-mix(in srgb, var(--wui-primary) 18%, transparent)}.wui-chat [hidden],wui-chat[hidden]{display:none !important}.wui-chat button:focus-visible,.wui-chat a:focus-visible,.wui-chat textarea:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}.wui-chat-input:focus-visible{outline:none}.wui-chat-composer:has(.wui-chat-input:focus-visible){outline:2px solid var(--color-focus-ring);outline-offset:2px}.wui-chat-panel{display:flex;flex-direction:column;min-height:0;overflow:hidden;background:var(--wui-chat-surface);border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);box-shadow:var(--wui-chat-shadow);transform-origin:50% 100%}.wui-chat--launcher .wui-chat-panel{position:fixed;z-index:var(--wui-z-shell-drawer);width:min(var(--wui-chat-width, 420px),100vw - 32px);height:min(var(--wui-chat-panel-max-height, 650px),100dvh - 110px);bottom:calc(var(--wui-chat-offset-y, 20px) + var(--wui-chat-bottom-gap, 80px) + var(--wui-consent-banner-block, 0px) + var(--wui-chat-lift));inset-inline-end:var(--wui-chat-offset-x, 20px)}.wui-chat--launcher.wui-chat--start .wui-chat-panel{inset-inline-end:auto;inset-inline-start:var(--wui-chat-offset-x, 20px)}.wui-chat--docked .wui-chat-panel{position:fixed;top:0;bottom:0;inset-inline-end:0;width:min(var(--wui-chat-width, 420px),100vw);border-radius:0;border:0;border-inline-start:1px solid var(--wui-chat-border)}.wui-chat--docked.wui-chat--start .wui-chat-panel{inset-inline-end:auto;inset-inline-start:0;border-inline-start:0;border-inline-end:1px solid var(--wui-chat-border)}.wui-chat--phone:not(.wui-chat--sheet) .wui-chat-panel{inset:0;z-index:10000;width:100%;height:100%;border-radius:0}.wui-chat--launcher.wui-chat--phone.wui-chat--sheet .wui-chat-panel{inset-inline:0;bottom:0;width:100%;height:min(var(--wui-chat-sheet-height),var(--wui-chat-sheet-max-height));border-radius:var(--wui-chat-radius) var(--wui-chat-radius) 0 0}.wui-chat--launcher.wui-chat--phone.wui-chat--sheet[data-state=opening] .wui-chat-panel{animation:wui-chat-sheet-in 400ms cubic-bezier(0.2, 0.9, 0.25, 1) both}.wui-chat--launcher.wui-chat--phone.wui-chat--sheet[data-state=closing] .wui-chat-panel{animation:wui-chat-sheet-out 300ms cubic-bezier(0.4, 0, 0.7, 0.2) forwards}@media(max-height: 500px){.wui-chat--launcher.wui-chat--phone .wui-chat-panel{height:calc(100dvh - 48px)}.wui-chat--phone .wui-chat-quick-replies{max-height:72px;overflow-y:auto}}.wui-chat--full-page .wui-chat-panel,.wui-chat--embedded .wui-chat-panel{position:relative;width:100%;height:100%;min-height:0}.wui-chat--full-page .wui-chat-panel{min-height:100dvh;border:0;border-radius:0;box-shadow:none}.wui-chat[data-state=closed] .wui-chat-panel{display:none}.wui-chat--launcher[data-state=opening] .wui-chat-panel{animation:wui-chat-panel-open 620ms cubic-bezier(0.2, 0.9, 0.25, 1) both;animation-timing-function:cubic-bezier(0.2, 0.9, 0.25, 1);animation-timing-function:linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001 85.9%, 1)}.wui-chat--launcher[data-state=closing] .wui-chat-panel{animation:wui-chat-panel-close 300ms cubic-bezier(0.4, 0, 0.7, 0.2) forwards;pointer-events:none}.wui-chat--launcher[data-state=opening] .wui-chat-header,.wui-chat--launcher[data-state=opening] .wui-chat-body,.wui-chat--launcher[data-state=opening] .wui-chat-foot{animation:wui-chat-band 550ms cubic-bezier(0.2, 0.9, 0.25, 1) both;animation-delay:var(--wui-chat-band, 0ms)}.wui-chat--launcher[data-state=closing] .wui-chat-header,.wui-chat--launcher[data-state=closing] .wui-chat-body,.wui-chat--launcher[data-state=closing] .wui-chat-foot{animation:wui-chat-band-out 140ms ease-in both}.wui-chat-header{--wui-chat-band: 110ms}.wui-chat-body{--wui-chat-band: 160ms}.wui-chat-foot{--wui-chat-band: 240ms}.wui-chat-header-actions .wui-chat-icon-btn{--wui-chat-band: 260ms}.wui-chat-footer{--wui-chat-band: 280ms}@keyframes wui-chat-panel-open{0%{opacity:0;transform:scale(0.15, 0.09);filter:blur(8px)}22%{opacity:1}45%{filter:blur(0)}100%{opacity:1;transform:none;filter:blur(0)}}@keyframes wui-chat-panel-close{65%{opacity:1}100%{opacity:0;transform:scale(0.15, 0.09);filter:blur(6px)}}@keyframes wui-chat-band{from{opacity:0;transform:translateY(10px);filter:blur(4px)}to{opacity:1;transform:none;filter:blur(0)}}@keyframes wui-chat-band-out{to{opacity:0;filter:blur(3px)}}@keyframes wui-chat-sheet-in{from{transform:translateY(100%)}to{transform:none}}@keyframes wui-chat-sheet-out{from{transform:none}to{transform:translateY(100%)}}.wui-chat-header{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--wui-chat-border)}.wui-chat-orb{width:28px;height:28px;flex:none;border-radius:50%;background:var(--wui-chat-gradient)}.wui-chat-header-text{display:flex;flex:1 1 auto;flex-direction:column;min-width:0}.wui-chat-title{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wui-chat-tagline{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;color:var(--wui-chat-text-muted)}.wui-chat-status{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--wui-chat-text-muted)}.wui-chat-status:empty{display:none}.wui-chat-status::before{content:"";width:6px;height:6px;flex:none;border-radius:50%;background:var(--wui-success);animation:wui-chat-status-pulse 2s ease-in-out infinite}@keyframes wui-chat-status-pulse{0%,100%{opacity:1}50%{opacity:.5}}.wui-chat-header-actions{display:flex;align-items:center;gap:4px}.wui-chat-icon-btn{display:inline-grid;place-items:center;width:36px;height:36px;padding:0;border:0;border-radius:var(--wui-chat-radius-sm);background:rgba(0,0,0,0);color:var(--wui-chat-text-muted);cursor:pointer}.wui-chat-icon-btn:hover{background:var(--wui-chat-accent-soft)}.wui-chat-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:20px}.wui-chat-empty{display:flex;flex-direction:column;gap:20px;padding-block:24px}.wui-chat-empty-hero{display:flex;flex-direction:column;align-items:center;gap:12px;text-align:center}.wui-chat-empty-hero .wui-chat-orb{width:40px;height:40px}.wui-chat-greeting{margin:0;font-size:22px;font-weight:600}.wui-chat-starters{display:grid;gap:8px}.wui-chat-starter,.wui-chat-empty-row{display:grid;width:100%;gap:4px;padding:12px 14px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:rgba(0,0,0,0);color:inherit;font:inherit;text-align:start;cursor:pointer}.wui-chat-starter:hover,.wui-chat-empty-row:hover{border-color:var(--wui-chat-accent);background:var(--wui-chat-accent-soft)}.wui-chat-empty-rows{display:grid;gap:8px}.wui-chat-empty-row{grid-template-columns:1fr}.wui-chat-empty-row .wui-chat-empty-row-label,.wui-chat-empty-row .wui-chat-empty-row-time{font-size:12px;color:var(--wui-chat-text-muted)}.wui-chat-empty-row .wui-chat-empty-row-title{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wui-chat-profile-error{margin:0;color:var(--color-danger)}.wui-chat-thread{display:flex;flex-direction:column;gap:20px;margin:0;padding:0;list-style:none;--wui-chat-band: 160ms}.wui-chat-message{animation:wui-chat-message-in 260ms var(--wui-chat-ease) both}.wui-chat-message[data-restored]{animation:none}.wui-chat-message--visitor,.wui-chat-message--customer{align-self:flex-end;max-width:85%}.wui-chat-message-body{display:flex;flex-direction:column;gap:10px}.wui-chat-part-group{display:flex;flex-wrap:wrap;gap:8px}.wui-chat-message-actions{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.wui-chat-action-btn{font-size:13px}.wui-chat-rating{display:inline-flex;align-items:center;gap:4px}.wui-chat-message--error .wui-chat-error{margin:0;font-size:14px;color:var(--color-danger)}.wui-chat-loader-slot{display:block}@keyframes wui-chat-message-in{from{opacity:0;transform:translateY(8px) scale(0.98)}to{opacity:1;transform:none}}.wui-chat-foot{display:flex;flex:none;flex-direction:column;gap:8px;padding:12px 16px 16px;border-top:1px solid var(--wui-chat-border)}.wui-chat-allowance,.wui-chat-footer{margin:0;font-size:12px;color:var(--wui-chat-text-muted)}.wui-chat-editing{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-radius:var(--wui-chat-radius-sm);background:var(--wui-chat-question-bg);font-size:14px;color:var(--wui-chat-text-muted)}.wui-chat-attachments{display:flex;flex-wrap:wrap;gap:8px}.wui-chat-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;border:1px solid var(--wui-chat-border);border-radius:999px;font-size:13px}.wui-chat-chip-remove{padding:0;border:0;background:rgba(0,0,0,0);color:inherit;cursor:pointer}.wui-chat-composer{--wui-chat-row-height: 41px;display:flex;align-items:flex-end;gap:8px;margin:0;padding:8px 8px 8px 12px;border:1px solid var(--wui-chat-border);border-radius:16px;background:var(--wui-chat-surface)}.wui-chat-composer:focus-within{border-color:var(--wui-chat-accent)}.wui-chat-input{flex:1 1 auto;min-height:var(--wui-chat-row-height);max-height:9rem;padding-block:calc((var(--wui-chat-row-height) - 1lh - 2px)/2);border:0;outline:0;resize:none;background:rgba(0,0,0,0);color:inherit;font:inherit}.wui-chat-tool{display:inline-grid;place-items:center;width:36px;height:36px;padding:0;border:0;background:rgba(0,0,0,0);color:var(--wui-chat-text-muted);cursor:pointer}.wui-chat-send{display:inline-grid;place-items:center;flex:none;width:var(--wui-chat-row-height);height:var(--wui-chat-row-height);padding:0;border:0;border-radius:50%;background:var(--wui-chat-accent);color:var(--wui-chat-accent-contrast);cursor:pointer}.wui-chat-send:disabled{opacity:.45;cursor:default}.wui-chat-composer>.wui-chat-send>svg{margin:0 !important}.wui-chat-send--stop{background:var(--color-text)}.wui-chat-counter{align-self:end;font-size:12px;color:var(--wui-chat-text-muted)}.wui-chat-footer-link{color:inherit}.wui-chat-footer-link:hover{text-decoration:underline}.wui-chat-history{flex:1 1 auto;overflow:auto;padding:16px}.wui-chat-history-list{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;list-style:none}.wui-chat-history-row{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.wui-chat-history-open{display:flex;flex:1 1 auto;flex-direction:column;min-width:0;padding:6px 8px;border:0;background:rgba(0,0,0,0);color:inherit;font:inherit;text-align:start;cursor:pointer}.wui-chat-history-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wui-chat-history-time{font-size:12px;color:var(--wui-chat-text-muted)}.wui-chat-history-input{flex:1 1 100%;padding:8px 10px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius-sm);background:var(--wui-chat-surface);color:inherit;font:inherit}.wui-chat-history-empty{margin:0;color:var(--wui-chat-text-muted)}.wui-chat-history-error{margin:0 0 8px;color:var(--color-danger)}.wui-chat--reduced,.wui-chat--reduced *,.wui-chat--reduced *::before,.wui-chat--reduced *::after{transition:none !important;animation:none !important}@media(prefers-reduced-motion: reduce){.wui-chat,.wui-chat *,.wui-chat *::before,.wui-chat *::after{transition:none !important;animation:none !important}}.wui-chat-print-heading{display:none}@media print{[data-wui-print-hide]{display:none !important}html[data-wui-printing] [data-wui-print-path]{position:static !important;overflow:visible !important;height:auto !important;min-height:0 !important;max-height:none !important;transform:none !important;inset:auto !important;width:auto !important;max-width:none !important;margin:0 !important;padding:0 !important}html[data-wui-printing] .wui-chat-panel{border:0 !important;border-radius:0 !important;box-shadow:none !important;background:Canvas !important;color:CanvasText !important;display:block !important}html[data-wui-printing] .wui-chat-body{overflow:visible !important;padding:0 !important}html[data-wui-printing] .wui-chat-header,html[data-wui-printing] .wui-chat-foot,html[data-wui-printing] .wui-chat-launcher-wrap,html[data-wui-printing] .wui-chat-nudge,html[data-wui-printing] .wui-chat-message-actions,html[data-wui-printing] .wui-chat-conversation-actions,html[data-wui-printing] .wui-chat-history,html[data-wui-printing] .wui-chat-empty,html[data-wui-printing] .wui-chat-message--loading,html[data-wui-printing] .wui-chat-message--error,html[data-wui-printing] .wui-chat-part--quickreplies,html[data-wui-printing] .wui-chat-part--inputrequest,html[data-wui-printing] .wui-chat-part--action,html[data-wui-printing] [data-wui-print-skip]{display:none !important}html[data-wui-printing] .wui-chat-print-heading{display:block;margin-block-end:16px;padding-block-end:8px;border-block-end:1px solid CanvasText}html[data-wui-printing] .wui-chat-print-heading h1{margin:0;font-size:1.25rem}html[data-wui-printing] .wui-chat-print-heading p{margin:4px 0 0;font-size:.8125rem}html[data-wui-printing] .wui-chat .wui-chat-author.visually-hidden{position:static !important;width:auto !important;height:auto !important;clip:auto !important;clip-path:none !important;overflow:visible !important;margin:0 0 2px !important;white-space:normal !important;display:block;font-weight:600}html[data-wui-printing] .wui-chat-message{break-inside:auto}html[data-wui-printing] .wui-chat-part--table,html[data-wui-printing] .wui-chat-part--chart,html[data-wui-printing] .wui-chat-part--figures,html[data-wui-printing] .wui-chat-part--recordcard,html[data-wui-printing] .wui-chat-part--image{break-inside:avoid}html[data-wui-printing] .wui-chat-bubble{background:rgba(0,0,0,0) !important;border:1px solid CanvasText;color:CanvasText !important}}@property --wui-chat-ring-angle{syntax:"<angle>";inherits:false;initial-value:0deg}.wui-chat-launcher-wrap{position:fixed;z-index:1070;display:inline-flex;bottom:calc(var(--wui-chat-offset-y, 24px) + var(--wui-chat-lift, 0px) + var(--wui-consent-banner-block, 0px));inset-inline-end:var(--wui-chat-offset-x, 24px);transition:transform .5s cubic-bezier(0.34, 1.56, 0.64, 1) .2s,opacity .25s ease .2s,visibility 0s}.wui-chat--start .wui-chat-launcher-wrap{inset-inline-start:var(--wui-chat-offset-x, 24px);inset-inline-end:auto}.wui-chat-launcher-wrap[data-launcher=hidden]{transform:scale(0.4);opacity:0;visibility:hidden;transition:transform .16s ease,opacity .16s ease,visibility 0s linear .16s}.wui-chat-launcher{position:relative;display:grid;place-items:center;border:0;padding:0;cursor:pointer;color:var(--wui-text-heading);background:color-mix(in srgb, var(--wui-primary-text) 10%, transparent);box-shadow:var(--wui-shadow-popover);backdrop-filter:blur(20px) saturate(180%);transition:transform .2s var(--wui-ease-elastic),box-shadow .2s ease}.wui-chat-launcher:focus-visible{outline:2px solid var(--wui-primary);outline-offset:2px}.wui-chat-launcher:hover{transform:scale(1.05);box-shadow:var(--wui-shadow-modal)}.wui-chat-launcher:active{transform:scale(0.95)}.wui-chat-launcher--round{width:64px;height:64px;border-radius:50%;color:var(--wui-primary-text);background:linear-gradient(179deg, var(--wui-primary), var(--wui-primary-pressed));backdrop-filter:none}.wui-chat-launcher--pill{height:54px;padding-inline:18px;border-radius:var(--wui-radius-pill);grid-auto-flow:column;gap:10px}.wui-chat-launcher--pill.wui-chat-launcher--compact{height:48px}.wui-chat-launcher-icon,.wui-chat-launcher-close{grid-area:1/1;display:grid;place-items:center;width:24px;height:24px;transition:opacity .3s ease,transform .3s ease}.wui-chat-launcher-close{opacity:0;transform:rotate(-90deg) scale(0.4)}.wui-chat-launcher[aria-expanded=true] .wui-chat-launcher-icon{opacity:0;transform:rotate(90deg) scale(0.4)}.wui-chat-launcher[aria-expanded=true] .wui-chat-launcher-close{opacity:1;transform:none}.wui-chat-launcher:hover .wui-chat-launcher-icon svg{transform:scale(1.1)}.wui-chat-launcher-icon svg,.wui-chat-launcher-close svg{width:100%;height:100%;transition:transform .3s ease}.wui-chat-launcher-label{display:inline-block;max-width:0;overflow:hidden;white-space:nowrap;opacity:0;filter:blur(6px);transition:max-width .3s cubic-bezier(0.34, 1.4, 0.64, 1),opacity .3s ease,filter .3s ease}.wui-chat-launcher--reveal-expand:hover .wui-chat-launcher-label,.wui-chat-launcher--reveal-expand:focus-visible .wui-chat-launcher-label,.wui-chat-launcher-wrap[data-launcher=peeking] .wui-chat-launcher--reveal-expand .wui-chat-launcher-label{max-width:16rem;opacity:1;filter:none}.wui-chat-launcher--reveal-expand:hover .wui-chat-launcher-icon,.wui-chat-launcher--reveal-expand:focus-visible .wui-chat-launcher-icon,.wui-chat-launcher-wrap[data-launcher=peeking] .wui-chat-launcher--reveal-expand .wui-chat-launcher-icon{transform:rotate(-12deg) scale(1.08) translateY(-2px)}.wui-chat-launcher--reveal-expand:active{transform:scale(0.95)}.wui-chat-launcher-bubble{position:absolute;top:50%;inset-inline-end:calc(100% + 12px);z-index:1;padding:var(--wui-space-xs) var(--wui-space-sm);border-radius:var(--wui-radius-md);color:var(--wui-bg-elevated);background:var(--wui-text-heading);box-shadow:var(--wui-shadow-popover);white-space:nowrap;pointer-events:none;opacity:0;transform:translateY(-50%);transition:opacity .3s ease}.wui-chat-launcher-bubble::after{content:"";position:absolute;top:50%;inset-inline-start:100%;margin-top:-6px;border-block:6px solid rgba(0,0,0,0);border-inline-start:6px solid var(--wui-text-heading)}.wui-chat--start .wui-chat-launcher-bubble{inset-inline-end:auto;inset-inline-start:calc(100% + 12px)}.wui-chat--start .wui-chat-launcher-bubble::after{inset-inline-start:auto;inset-inline-end:100%;border-inline-start:0;border-inline-end:6px solid var(--wui-text-heading)}@media(hover: hover)and (pointer: fine){.wui-chat-launcher-wrap:hover>.wui-chat-launcher--reveal-bubble~.wui-chat-launcher-bubble{opacity:1}}.wui-chat-launcher--reveal-bubble:focus-visible~.wui-chat-launcher-bubble,.wui-chat-launcher-wrap[data-launcher=peeking]>.wui-chat-launcher--reveal-bubble~.wui-chat-launcher-bubble{opacity:1}.wui-chat-launcher-wrap.wui-chat-launcher--entrance-slide-up[data-launcher=entering]{animation:wui-chat-slide-up .8s cubic-bezier(0.34, 1.56, 0.64, 1) 1s both}.wui-chat-launcher-wrap.wui-chat-launcher--entrance-bounce-in[data-launcher=entering]{animation:wui-chat-bounce-in .8s cubic-bezier(0.34, 1.56, 0.64, 1) 1s both}.wui-chat-launcher-wrap.wui-chat-launcher--entrance-fade-in-pulse[data-launcher=entering]{animation:wui-chat-fade-in-pulse .8s cubic-bezier(0.34, 1.56, 0.64, 1) 1s both}.wui-chat-launcher-wrap.wui-chat-launcher--entrance-spin-scale[data-launcher=entering]{animation:wui-chat-spin-scale .8s cubic-bezier(0.34, 1.56, 0.64, 1) 1s both}.wui-chat-launcher-wrap.wui-chat-launcher--entrance-wiggle-in[data-launcher=entering]{animation:wui-chat-wiggle-in .8s cubic-bezier(0.34, 1.56, 0.64, 1) 1s both}.wui-chat-launcher-wrap.wui-chat-launcher--entrance-elastic-in[data-launcher=entering]{animation:wui-chat-elastic-in .8s cubic-bezier(0.34, 1.56, 0.64, 1) 1s both}.wui-chat-launcher-wrap.wui-chat-launcher--entrance-rise[data-launcher=entering]{animation:wui-chat-rise .9s cubic-bezier(0.34, 1.4, 0.64, 1) .4s both}.wui-chat-launcher-wrap.wui-chat-launcher--idle-float-and-pulse[data-launcher=idle]{animation:wui-chat-float 3s ease-in-out .1s infinite}.wui-chat-launcher-wrap.wui-chat-launcher--idle-float-and-pulse[data-launcher=idle]>.wui-chat-launcher{animation:wui-chat-pulse 2s ease-out .1s infinite}.wui-chat-launcher-wrap.wui-chat-launcher--idle-float-and-pulse[data-launcher=idle]:hover,.wui-chat-launcher-wrap.wui-chat-launcher--idle-float-and-pulse[data-launcher=idle]:hover>.wui-chat-launcher{animation-play-state:paused}.wui-chat-launcher-wrap.wui-chat-launcher--idle-ring[data-launcher=idle]>.wui-chat-launcher--pill::before{content:"";position:absolute;inset:-2px;border-radius:inherit;padding:2px;background:conic-gradient(from var(--wui-chat-ring-angle), var(--wui-info), var(--wui-primary), var(--wui-info));-webkit-mask:linear-gradient(currentColor, currentColor) content-box,linear-gradient(currentColor, currentColor);-webkit-mask-composite:xor;mask-composite:exclude;animation:wui-chat-ring-turn 4s linear infinite;pointer-events:none}.wui-chat-launcher-wrap.wui-chat-launcher--idle-ring[data-launcher=idle]:has(>.wui-chat-launcher--compact:not(:hover):not(:focus-visible))>.wui-chat-launcher--pill::before{animation-play-state:paused}.wui-chat-launcher-wrap.wui-chat-launcher--idle-ring[data-launcher=idle]:hover>.wui-chat-launcher--pill::before{animation-play-state:paused}.wui-chat-launcher-wrap[data-launcher]>.wui-chat-launcher.wui-chat-launcher--opening{animation:wui-chat-click-pulse .4s ease-out both}.wui-chat-launcher-wrap[data-launcher]>.wui-chat-launcher.wui-chat-launcher--closing{animation:wui-chat-click-shrink .3s ease-out both}.wui-chat-launcher-wrap[data-on-dark] .wui-chat-launcher{color:var(--wui-primary-text)}.wui-chat-launcher-wrap[data-on-dark] .wui-chat-launcher--pill{background:color-mix(in srgb, var(--wui-primary-text) 14%, transparent)}.wui-chat-nudge{position:absolute;inset-block-end:0;inset-inline-end:calc(100% + 12px);display:flex;gap:var(--wui-space-xs);width:248px;padding:var(--wui-space-sm) var(--wui-space-sm) var(--wui-space-sm) var(--wui-space-md);border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:var(--wui-chat-surface);box-shadow:var(--wui-chat-shadow);color:var(--wui-chat-text)}.wui-chat--start .wui-chat-nudge{inset-inline-end:auto;inset-inline-start:calc(100% + 12px)}.wui-chat-nudge-text{flex:1;border:0;padding:0;background:rgba(0,0,0,0);color:inherit;text-align:start;cursor:pointer}.wui-chat-nudge-close{flex:none;width:26px;height:26px;border:0;padding:0;background:rgba(0,0,0,0);color:var(--wui-chat-text-muted);cursor:pointer}.wui-chat--phone .wui-chat-launcher-wrap{bottom:calc(16px + env(safe-area-inset-bottom) + var(--wui-chat-lift, 0px) + var(--wui-consent-banner-block, 0px))}.wui-chat--phone.wui-chat--end .wui-chat-launcher-wrap{inset-inline-end:16px}.wui-chat--phone .wui-chat-launcher--reveal-expand .wui-chat-launcher-label{position:absolute;width:1px;height:1px;max-width:none;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;opacity:1;filter:none}@keyframes wui-chat-slide-up{from{opacity:0;transform:translateY(100px) scale(0.8)}to{opacity:1;transform:none}}@keyframes wui-chat-bounce-in{0%{transform:scale(0.3)}50%{transform:scale(1.05)}70%{transform:scale(0.9)}100%{transform:scale(1)}}@keyframes wui-chat-fade-in-pulse{0%{opacity:0;transform:scale(1)}50%{opacity:1;transform:scale(1.1)}100%{opacity:1;transform:scale(1)}}@keyframes wui-chat-spin-scale{from{transform:rotate(-180deg) scale(0)}to{transform:none}}@keyframes wui-chat-wiggle-in{0%{transform:translateY(100px) rotate(-10deg)}40%{transform:rotate(5deg)}60%{transform:rotate(-3deg)}80%{transform:rotate(1deg)}100%{transform:none}}@keyframes wui-chat-elastic-in{0%{transform:scale(0)}55%{transform:scale(1.1)}75%{transform:scale(0.95)}100%{transform:scale(1)}}@keyframes wui-chat-rise{0%{translate:0 calc(100% + 60px);opacity:0}40%{opacity:1}100%{translate:0 0;opacity:1}}@keyframes wui-chat-float{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}@keyframes wui-chat-pulse{0%{box-shadow:0 0 0 0 color-mix(in srgb, var(--wui-primary) 40%, transparent)}100%{box-shadow:0 0 0 10px rgba(0,0,0,0)}}@keyframes wui-chat-click-pulse{0%{transform:scale(1)}50%{transform:scale(1.1) rotate(5deg);box-shadow:0 0 0 10px color-mix(in srgb, var(--wui-primary) 30%, transparent)}100%{transform:scale(1.05)}}@keyframes wui-chat-click-shrink{0%{transform:scale(1.05)}50%{transform:scale(0.95) rotate(-3deg)}100%{transform:scale(1)}}@keyframes wui-chat-ring-turn{to{--wui-chat-ring-angle: 360deg}}.wui-chat--reduced .wui-chat-launcher-wrap,.wui-chat--reduced .wui-chat-launcher-wrap *,.wui-chat--reduced .wui-chat-launcher-wrap *::before,.wui-chat--reduced .wui-chat-launcher-wrap *::after{animation:none !important;transition:none !important}.wui-chat--reduced .wui-chat-launcher-wrap>.wui-chat-launcher--pill::before{display:none}@keyframes wui-chat-message-in{from{opacity:0;transform:translateY(8px) scale(0.98)}to{opacity:1;transform:none}}@keyframes wui-chat-chip-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}@keyframes wui-chat-ripple{from{width:0;height:0;opacity:.6}to{width:300px;height:300px;opacity:0}}.wui-chat-part-enter{animation:wui-chat-message-in .26s var(--wui-ease-in-out) both}.wui-chat-quick-reply{animation:wui-chat-chip-in .25s var(--wui-ease-out) both;animation-delay:calc(var(--wui-chat-i, 0)*45ms);transition:background-color .15s var(--wui-ease-in-out),border-color .15s var(--wui-ease-in-out),transform .15s var(--wui-ease-in-out)}.wui-chat-starter{position:relative;overflow:hidden;transition:background-color .15s var(--wui-ease-in-out),transform .2s var(--wui-ease-out),box-shadow .2s var(--wui-ease-out)}.wui-chat-starter::before{content:"";position:absolute;inset-inline-start:50%;inset-block-start:50%;width:0;height:0;border-radius:50%;background:var(--wui-chat-accent-soft);transform:translate(-50%, -50%);pointer-events:none}.wui-chat-starter:hover{transform:translateY(-3px) scale(1.05);box-shadow:var(--wui-shadow-popover)}.wui-chat-starter:hover::before{animation:wui-chat-ripple .6s var(--wui-ease-out) both}.wui-chat--reduced,.wui-chat--reduced *{animation:none !important;transition:none !important}@media(prefers-reduced-motion: reduce){.wui-chat-part-enter,.wui-chat-quick-reply,.wui-chat-starter,.wui-chat-starter::before,.wui-chat-starter:hover::before{animation:none;transition:none}}@keyframes wui-chat-loader-spin{to{transform:rotate(360deg)}}@keyframes wui-chat-loader-breathe{from{transform:scale(0.92)}to{transform:scale(1.04)}}@keyframes wui-chat-loader-glow{from{opacity:.35}to{opacity:.8}}@keyframes wui-chat-loader-morph{0%,100%{border-radius:50%}50%{border-radius:42% 58% 55% 45%/47% 52% 48% 53%}}@keyframes wui-chat-loader-shimmer{from{background-position:100% 0}to{background-position:0 0}}@keyframes wui-chat-loader-draw{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}@keyframes wui-chat-loader-sweep{from{transform:translateX(-100%)}to{transform:translateX(100%)}}@keyframes wui-chat-loader-rise{from{transform:translateY(60%);opacity:0}to{transform:none;opacity:1}}@keyframes wui-chat-loader-fall{from{transform:none;opacity:1}to{transform:translateY(-60%);opacity:0}}@keyframes wui-chat-loader-row-in{from{transform:translateY(6px);opacity:0}to{transform:none;opacity:1}}@keyframes wui-chat-loader-bounce{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(-4px)}}.wui-chat-loader{padding-block:8px;color:var(--wui-chat-text-muted);font-size:14px;line-height:1.4}.wui-chat-loader[hidden]{display:none}.wui-chat-loader-body{display:grid}.wui-chat-loader-body>*{grid-area:1/1;min-width:0}.wui-chat-loader-orb{display:flex;align-items:center;justify-content:center;gap:10px}.wui-chat-loader-orb-mark{position:relative;display:block;width:28px;height:28px;animation:wui-chat-loader-breathe 1.6s ease-in-out infinite alternate}.wui-chat-loader-orb-glow{position:absolute;inset:-8px;display:block;border-radius:50%;background:var(--wui-chat-gradient);filter:blur(8px);opacity:.55;animation:wui-chat-loader-glow 1.6s ease-in-out infinite alternate}.wui-chat-loader-orb-disc{position:absolute;inset:0;display:block;border-radius:50%;background:var(--wui-chat-gradient);animation:wui-chat-loader-spin 3s linear infinite,wui-chat-loader-morph 3.2s ease-in-out infinite}.wui-chat-loader-orb-label{background-image:linear-gradient(90deg, var(--wui-chat-text-muted) 0%, var(--wui-chat-text-muted) 40%, var(--wui-chat-accent) 50%, var(--wui-chat-text-muted) 60%, var(--wui-chat-text-muted) 100%);background-size:300% 100%;background-clip:text;color:rgba(0,0,0,0);animation:wui-chat-loader-shimmer 1.9s linear infinite}.wui-chat-loader-phrases{display:flex;align-items:center;gap:8px;min-width:0}.wui-chat-loader-phrases-orb{flex:none;display:block;width:12px;height:12px;border-radius:50%;background:var(--wui-chat-gradient);animation:wui-chat-loader-spin 6s linear infinite}.wui-chat-loader-phrases-stage{display:grid;overflow:hidden;min-width:0}.wui-chat-loader-phrases-text{grid-area:1/1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;background-image:linear-gradient(90deg, var(--wui-chat-text-muted) 0%, var(--wui-chat-text-muted) 40%, var(--wui-chat-accent) 50%, var(--wui-chat-text-muted) 60%, var(--wui-chat-text-muted) 100%);background-size:300% 100%;background-clip:text;color:rgba(0,0,0,0);animation:wui-chat-loader-shimmer 1.8s linear infinite}.wui-chat-loader-phrases-text--in{animation:wui-chat-loader-shimmer 1.8s linear infinite,wui-chat-loader-rise 180ms var(--wui-chat-ease)}.wui-chat-loader-phrases-text--out{animation:wui-chat-loader-shimmer 1.8s linear infinite,wui-chat-loader-fall 180ms var(--wui-chat-ease) forwards}.wui-chat-loader-steps{display:grid;min-width:0}.wui-chat-loader-steps-pill{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;background-image:linear-gradient(90deg, var(--wui-chat-text-muted) 0%, var(--wui-chat-text-muted) 40%, var(--wui-chat-accent) 50%, var(--wui-chat-text-muted) 60%, var(--wui-chat-text-muted) 100%);background-size:300% 100%;background-clip:text;color:rgba(0,0,0,0);animation:wui-chat-loader-shimmer 1.8s linear infinite}.wui-chat-loader-steps-pill[hidden]{display:none}.wui-chat-loader-steps-list{display:grid;gap:8px;list-style:none;margin:0;padding:0}.wui-chat-loader-steps-list[hidden]{display:none}.wui-chat-loader-steps-item{display:flex;align-items:center;gap:10px;animation:wui-chat-loader-row-in 280ms var(--wui-chat-ease) backwards}.wui-chat-loader-steps-item[data-state=done]{color:var(--wui-chat-text-muted)}.wui-chat-loader-steps-item[data-state=active]{color:var(--wui-chat-text);font-weight:600}.wui-chat-loader-steps-item[data-state=pending]{opacity:.4}.wui-chat-loader-steps-icon{flex:none;display:grid;place-items:center;width:16px;height:16px}.wui-chat-loader-steps-text{min-width:0}.wui-chat-loader-steps-ring{box-sizing:border-box;width:14px;height:14px;border:2px solid var(--wui-chat-accent-soft);border-top-color:var(--wui-chat-accent);border-radius:50%;animation:wui-chat-loader-spin .9s linear infinite}.wui-chat-loader-steps-dot{width:6px;height:6px;border-radius:50%;background:var(--wui-chat-text-muted)}.wui-chat-loader-steps-check{width:16px;height:16px;overflow:visible;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1;animation:wui-chat-loader-draw 300ms var(--wui-chat-ease) forwards}.wui-chat-loader-skeleton{display:grid;gap:10px}.wui-chat-loader-skeleton-label{color:var(--wui-chat-text-muted);font-size:13px}.wui-chat-loader-skeleton-body{position:relative;display:grid;gap:8px;overflow:hidden}.wui-chat-loader-skeleton-body::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg, transparent, color-mix(in srgb, var(--wui-chat-accent) 14%, transparent), transparent);animation:wui-chat-loader-sweep 1.5s linear infinite;pointer-events:none}.wui-chat-loader-skeleton-avatar{display:block;justify-self:start;width:32px;height:32px;border-radius:50%;background:color-mix(in srgb, var(--wui-chat-text-muted) 18%, transparent)}.wui-chat-loader-skeleton-line{display:block;justify-self:start;height:10px;border-radius:999px;background:color-mix(in srgb, var(--wui-chat-text-muted) 18%, transparent)}.wui-chat-loader-typing{display:inline-flex;align-items:center;gap:8px;color:var(--wui-chat-text-muted)}.wui-chat-loader-typing[hidden]{display:none}.wui-chat-loader-typing-orb{flex:none;display:block;width:12px;height:12px;border-radius:50%;background:var(--wui-chat-gradient);animation:wui-chat-loader-spin 6s linear infinite}.wui-chat-loader-typing-orb[hidden]{display:none}.wui-chat-loader-typing-dots{display:inline-flex;align-items:center;gap:4px}.wui-chat-loader-typing-dot{display:block;width:6px;height:6px;border-radius:50%;background:var(--wui-chat-text-muted);animation:wui-chat-loader-bounce 1.2s ease-in-out infinite}.wui-chat-loader-typing-dot:nth-child(2){animation-delay:.14s}.wui-chat-loader-typing-dot:nth-child(3){animation-delay:.28s}.wui-chat-loader--reduced .wui-chat-loader-orb-mark,.wui-chat-loader--reduced .wui-chat-loader-orb-glow,.wui-chat-loader--reduced .wui-chat-loader-orb-disc,.wui-chat-loader--reduced .wui-chat-loader-orb-label,.wui-chat-loader--reduced .wui-chat-loader-phrases-orb,.wui-chat-loader--reduced .wui-chat-loader-phrases-text,.wui-chat-loader--reduced .wui-chat-loader-steps-pill,.wui-chat-loader--reduced .wui-chat-loader-steps-item,.wui-chat-loader--reduced .wui-chat-loader-steps-ring,.wui-chat-loader--reduced .wui-chat-loader-steps-check,.wui-chat-loader--reduced .wui-chat-loader-skeleton-body::after,.wui-chat-loader--reduced .wui-chat-loader-typing-orb,.wui-chat-loader--reduced .wui-chat-loader-typing-dot{animation:none}.wui-chat-loader--reduced .wui-chat-loader-steps-check{stroke-dashoffset:0}.wui-chat-loader--reduced .wui-chat-loader-skeleton-body::after{display:none}.wui-chat-loader--reduced .wui-chat-loader-orb-label,.wui-chat-loader--reduced .wui-chat-loader-phrases-text,.wui-chat-loader--reduced .wui-chat-loader-steps-pill{background-image:none;color:var(--wui-chat-text-muted);-webkit-text-fill-color:currentColor}@media(prefers-reduced-motion: reduce){.wui-chat-loader .wui-chat-loader-orb-mark,.wui-chat-loader .wui-chat-loader-orb-glow,.wui-chat-loader .wui-chat-loader-orb-disc,.wui-chat-loader .wui-chat-loader-orb-label,.wui-chat-loader .wui-chat-loader-phrases-orb,.wui-chat-loader .wui-chat-loader-phrases-text,.wui-chat-loader .wui-chat-loader-steps-pill,.wui-chat-loader .wui-chat-loader-steps-item,.wui-chat-loader .wui-chat-loader-steps-ring,.wui-chat-loader .wui-chat-loader-steps-check,.wui-chat-loader .wui-chat-loader-skeleton-body::after,.wui-chat-loader .wui-chat-loader-typing-orb,.wui-chat-loader .wui-chat-loader-typing-dot,.wui-chat-loader-typing .wui-chat-loader-orb-mark,.wui-chat-loader-typing .wui-chat-loader-orb-glow,.wui-chat-loader-typing .wui-chat-loader-orb-disc,.wui-chat-loader-typing .wui-chat-loader-orb-label,.wui-chat-loader-typing .wui-chat-loader-phrases-orb,.wui-chat-loader-typing .wui-chat-loader-phrases-text,.wui-chat-loader-typing .wui-chat-loader-steps-pill,.wui-chat-loader-typing .wui-chat-loader-steps-item,.wui-chat-loader-typing .wui-chat-loader-steps-ring,.wui-chat-loader-typing .wui-chat-loader-steps-check,.wui-chat-loader-typing .wui-chat-loader-skeleton-body::after,.wui-chat-loader-typing .wui-chat-loader-typing-orb,.wui-chat-loader-typing .wui-chat-loader-typing-dot{animation:none}.wui-chat-loader .wui-chat-loader-steps-check,.wui-chat-loader-typing .wui-chat-loader-steps-check{stroke-dashoffset:0}.wui-chat-loader .wui-chat-loader-skeleton-body::after,.wui-chat-loader-typing .wui-chat-loader-skeleton-body::after{display:none}.wui-chat-loader .wui-chat-loader-orb-label,.wui-chat-loader .wui-chat-loader-phrases-text,.wui-chat-loader .wui-chat-loader-steps-pill,.wui-chat-loader-typing .wui-chat-loader-orb-label,.wui-chat-loader-typing .wui-chat-loader-phrases-text,.wui-chat-loader-typing .wui-chat-loader-steps-pill{background-image:none;color:var(--wui-chat-text-muted);-webkit-text-fill-color:currentColor}}.wui-chat-bubble{padding:10px 14px;background:var(--wui-chat-question-bg);border-radius:var(--wui-chat-radius) var(--wui-chat-radius) var(--wui-chat-radius-sm) var(--wui-chat-radius);white-space:pre-wrap;overflow-wrap:anywhere}.wui-chat-text{margin:0;font-size:15px;line-height:1.55;overflow-wrap:anywhere}.wui-chat-text p{margin:0 0 .6em}.wui-chat-text>:last-child{margin-block-end:0}.wui-chat-text ul,.wui-chat-text ol{padding-inline-start:1.25em}.wui-chat-text code{background:var(--wui-chat-question-bg);border-radius:4px}.wui-chat-text blockquote{margin-inline:0;padding-inline-start:12px;border-inline-start:3px solid var(--wui-chat-border);color:var(--color-text-muted)}.wui-chat-text table{display:block;overflow-x:auto}.wui-chat-sources-label{margin:0 0 6px;font-size:12px;color:var(--color-text-muted)}.wui-chat-sources-list{display:flex;flex-wrap:wrap;gap:6px;list-style:none;margin:0;padding:0}.wui-chat-source{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-radius-pill);font-size:13px;color:inherit;text-decoration:none}.wui-chat-source:hover,.wui-chat-source:focus-visible{border-color:var(--wui-chat-accent);background:var(--wui-chat-accent-soft)}.wui-chat-source-marker{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;background:var(--wui-chat-accent-soft);color:var(--wui-chat-accent);font-size:11px;font-weight:600}.wui-chat-source-title{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wui-chat-quick-replies{display:flex;flex-wrap:wrap;gap:8px}.wui-chat-quick-replies--composer{position:sticky;inset-block-end:0;padding-block:8px;background:var(--wui-chat-surface)}.wui-chat-quick-reply,.wui-chat-starter{display:inline-flex;align-items:center;gap:6px;padding:8px 14px;border:1px solid var(--wui-chat-accent);border-radius:var(--wui-radius-pill);background:rgba(0,0,0,0);color:var(--wui-chat-accent);cursor:pointer}.wui-chat-quick-reply:hover,.wui-chat-starter:hover{background:var(--wui-chat-accent-soft)}.wui-chat-quick-reply:active,.wui-chat-starter:active{transform:scale(0.97)}.wui-chat-quick-reply:focus-visible,.wui-chat-starter:focus-visible{outline:2px solid var(--wui-chat-accent);outline-offset:2px}.wui-chat-quick-reply--primary,.wui-chat-starter--primary{background:var(--wui-chat-accent);color:var(--color-on-primary);font-weight:700}.wui-chat-quick-reply--primary:hover,.wui-chat-starter--primary:hover{background:var(--wui-chat-accent)}.wui-chat-quick-reply--cta,.wui-chat-starter--cta{box-shadow:var(--wui-shadow-popover)}.wui-chat-quick-reply-icon{display:inline-flex}.wui-chat-notice{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:var(--wui-chat-radius-sm);font-size:14px}.wui-chat-notice--info{background:var(--wui-chat-accent-soft)}.wui-chat-notice--warning{background:color-mix(in srgb, var(--color-warning) 16%, transparent)}.wui-chat-notice-icon{display:inline-flex;flex-shrink:0}.wui-chat-input-form{display:grid;gap:12px;max-width:100%;padding:14px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:var(--wui-chat-surface)}.wui-chat-input-title{margin:0;font-size:15px;font-weight:600}.wui-chat-field{display:grid;gap:4px}.wui-chat-field .form-control{width:100%}.wui-chat-field textarea.form-control{resize:vertical}.wui-chat-field-hint{margin-inline-start:6px;font-size:12px;color:var(--color-text-muted)}.wui-chat-field-error,.wui-chat-input-error{margin:0;font-size:13px;color:var(--color-danger)}.wui-chat-input-form [aria-invalid=true]{border-color:var(--color-danger)}.wui-chat-input-typed{margin:0;font-size:13px;color:var(--color-text-muted)}.wui-chat-input-choices{display:grid;gap:4px}.wui-chat-input-slots{position:relative;display:flex;flex-wrap:wrap;gap:8px}.wui-chat-input-slot-radio{position:absolute;width:1px;height:1px;margin:0;opacity:0;pointer-events:none}.wui-chat-input-slot{cursor:pointer}.wui-chat-input-slot-radio:checked+.wui-chat-input-slot{background:var(--wui-chat-accent-soft)}.wui-chat-input-slot-radio:focus-visible+.wui-chat-input-slot{outline:2px solid var(--wui-chat-accent);outline-offset:2px}.wui-chat-input-file{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.wui-chat-input-file-status{min-width:0;overflow:hidden;font-size:14px;text-overflow:ellipsis;white-space:nowrap}.wui-chat-input-request--answered .wui-chat-input-summary,.wui-chat-input-request--skipped .wui-chat-input-summary,.wui-chat-input-request--expired .wui-chat-input-summary{margin:0;padding:8px 12px;border-radius:var(--wui-chat-radius-sm);background:var(--wui-chat-question-bg);color:var(--color-text-muted);font-size:14px}.wui-chat-action{display:grid;gap:8px;padding:12px 14px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:var(--wui-chat-surface)}.wui-chat-action-lines{margin:0 14px;padding-inline-start:1.25em}.wui-chat-action-line{margin:0}.wui-chat-action-menu{margin:0;max-width:100%}.wui-chat-action-menu-item{font-size:13px}.wui-chat-action-buttons{display:flex;flex-wrap:wrap;gap:8px}.wui-chat-action-status{margin:0;font-size:14px}.wui-chat-action-status--done,.wui-chat-action-status--confirmed,.wui-chat-action-status--repeat{color:var(--color-success)}.wui-chat-action-status--failed,.wui-chat-action-status--rejected,.wui-chat-action-status--expired{color:var(--color-text-muted)}.wui-chat-action-note,.wui-chat-action-consent,.wui-chat-action-error{margin:0;font-size:13px}.wui-chat-action-error{color:var(--color-danger)}.wui-chat-file-chip{display:inline-flex;gap:8px;align-items:center;max-width:100%;padding:6px 12px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-radius-pill);background:rgba(0,0,0,0);color:inherit;font-size:13px}.wui-chat-file-chip:is(button){cursor:pointer}.wui-chat-file-chip:is(button):hover{background:var(--wui-chat-accent-soft)}.wui-chat-file-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wui-chat-file-size{color:var(--color-text-muted);white-space:nowrap}.wui-chat-sub,.wui-chat-sup{font-size:.75em;line-height:0;position:relative;vertical-align:baseline}.wui-chat-sub{bottom:-0.25em}.wui-chat-sup{top:-0.5em}.wui-chat-num{text-align:end;font-variant-numeric:tabular-nums;white-space:nowrap}.wui-chat-table{margin:0}.wui-chat-table-title,.wui-chat-chart-title{font-size:14px;font-weight:600;margin-block-end:6px}.wui-chat-table-wrap{max-width:100%;overflow-x:auto;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius-sm)}.wui-chat-table-wrap:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}.wui-chat-table-grid{margin:0;font-size:13px}.wui-chat-table-grid th{font-weight:600;white-space:nowrap;background:var(--wui-chat-question-bg)}.wui-chat-table-more{margin-block-start:6px}.wui-chat-chart{margin:0}.wui-chat-chart-body{min-height:240px;max-width:100%}.wui-chat-chart-error{margin:0;font-size:14px;color:var(--color-text-muted)}.wui-chat-figures .wui-metric-strip[class]{grid-template-columns:repeat(auto-fit, minmax(110px, 1fr));padding:10px 12px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:var(--wui-chat-surface)}.wui-chat-figure-unit{font-size:.8em;color:var(--color-text-muted)}.wui-chat-record{display:grid;gap:8px;padding:12px 14px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:var(--wui-chat-surface)}.wui-chat-record-title{font-size:15px;font-weight:600}.wui-chat-record-subtitle{display:block;font-size:13px;color:var(--color-text-muted)}.wui-chat-record-fields{display:grid;gap:6px;margin:0}.wui-chat-record-fields>div{display:grid;grid-template-columns:minmax(0, 40%) minmax(0, 1fr);gap:8px}.wui-chat-record-fields dt{font-size:13px;font-weight:400;color:var(--color-text-muted)}.wui-chat-record-fields dd{margin:0;font-size:14px;overflow-wrap:anywhere}.wui-chat-record-open{justify-self:start}.wui-chat-image{margin:0}.wui-chat-image-frame{max-width:100%;max-height:320px;overflow:hidden;border-radius:var(--wui-chat-radius-sm);background:var(--wui-chat-question-bg)}.wui-chat-image-frame img{display:block;max-width:100%;max-height:320px;object-fit:contain;cursor:zoom-in}.wui-chat-image-skeleton{width:100%;height:100%;min-height:120px}.wui-chat-image-error{margin:0;font-size:14px;color:var(--color-text-muted)}.wui-chat-handoff{display:grid;gap:10px;min-width:0;padding:14px 16px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:var(--wui-chat-surface);color:var(--wui-chat-text)}.wui-chat-handoff-title{margin:0;font-size:15px;font-weight:600}.wui-chat-handoff-text{margin:0;font-size:14px;color:var(--wui-chat-text-muted)}.wui-chat-handoff--requested,.wui-chat-handoff--waiting,.wui-chat-handoff--joined{grid-template-columns:auto 1fr;align-items:center}.wui-chat-handoff-body{display:grid;gap:4px;min-width:0}.wui-chat-handoff-pulses{display:flex;gap:6px}.wui-chat-handoff-pulse{width:14px;height:14px;border-radius:50%;background:var(--wui-chat-accent-soft)}.wui-chat-handoff--live .wui-chat-handoff-pulse{animation:wui-chat-handoff-pulse 1.2s ease-in-out infinite}.wui-chat-handoff--live .wui-chat-handoff-pulse:nth-child(2){animation-delay:160ms}.wui-chat-handoff--live .wui-chat-handoff-pulse:nth-child(3){animation-delay:320ms}.wui-chat--reduced .wui-chat-handoff-pulse{animation:none}@keyframes wui-chat-handoff-pulse{0%,100%{transform:scale(0.8);opacity:.5}50%{transform:scale(1.1);opacity:1}}.wui-chat-handoff-position{display:inline-grid;place-items:center;width:44px;height:44px;border:3px solid var(--wui-chat-accent);border-radius:50%;color:var(--wui-chat-accent);font-size:18px;font-weight:700;font-variant-numeric:tabular-nums}.wui-chat-handoff-agent{position:relative;display:inline-flex}.wui-chat-handoff-agent .wui-chat-avatar{width:44px;height:44px;font-size:16px}.wui-chat-handoff-online{position:absolute;inset-block-end:0;inset-inline-end:0;width:12px;height:12px;border:2px solid var(--wui-chat-surface);border-radius:50%;background:var(--color-success)}.wui-chat-avatar{display:inline-grid;place-items:center;width:28px;height:28px;border-radius:50%;overflow:hidden;flex:none;background:var(--wui-chat-accent);color:var(--wui-chat-accent-contrast);font-size:12px;font-weight:600}.wui-chat-avatar img{width:100%;height:100%;object-fit:cover}.wui-chat-agent-head{display:flex;align-items:center;gap:8px;margin-block-end:4px}.wui-chat-agent-name{font-size:13px;font-weight:600;color:var(--wui-chat-text)}.wui-chat-agent-role{font-size:12px;color:var(--wui-chat-text-muted)}.wui-chat-typing{display:inline-flex;gap:4px;padding-block:6px}.wui-chat-typing-dot{width:6px;height:6px;border-radius:50%;background:var(--wui-chat-text-muted);opacity:.6}.wui-chat-ticket{display:grid;gap:8px;min-width:0;padding:14px 16px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:var(--wui-chat-surface)}.wui-chat-ticket-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.wui-chat-ticket-number{font-size:13px;color:var(--wui-chat-text-muted);font-variant-numeric:tabular-nums}.wui-chat-ticket-title{font-size:15px;font-weight:600;overflow-wrap:anywhere}.wui-chat-ticket-badge{padding:2px 10px;border-radius:999px;font-size:12px;font-weight:600;white-space:nowrap}.wui-chat-ticket-badge--info{background:var(--color-info-soft);color:var(--color-info-text)}.wui-chat-ticket-badge--warning{background:var(--color-warning-soft);color:var(--color-warning-text)}.wui-chat-ticket-badge--success{background:var(--color-success-soft);color:var(--color-success-text)}.wui-chat-ticket-badge--neutral{background:var(--wui-chat-question-bg);color:var(--wui-chat-text-muted)}.wui-chat-ticket-foot{display:flex;justify-content:flex-end}.wui-chat-ticket-link{border:0;padding:0;background:rgba(0,0,0,0);color:var(--wui-chat-accent);font-size:13px;font-weight:600;cursor:pointer}.wui-chat-ticket-link:hover{text-decoration:underline}.wui-chat-ticket-link:focus-visible{outline:2px solid var(--wui-chat-accent);outline-offset:2px}.wui-chat-open-tickets{display:grid;gap:6px}.wui-chat-empty-row-status{font-size:12px;color:var(--wui-chat-text-muted);white-space:nowrap}.wui-chat-mic{width:36px;height:36px;border:0;background:rgba(0,0,0,0);color:var(--wui-chat-text-muted)}.wui-chat-mic[aria-pressed=true]{color:var(--wui-chat-accent);background:var(--wui-chat-accent-soft);animation:wui-chat-pulse 1.4s ease-out infinite}.wui-chat-mic[disabled]{opacity:.45}.wui-chat-voice-note{margin:0;font-size:13px;color:var(--wui-chat-text-muted)}.wui-chat-voice-note--blocked{color:var(--color-danger)}.wui-chat-speak[aria-pressed=true]{color:var(--wui-chat-accent)}.wui-chat-clip{display:flex;flex-direction:column;gap:6px;max-width:320px;padding:8px 12px;border:1px solid var(--wui-chat-border);border-radius:var(--wui-chat-radius);background:var(--wui-chat-surface)}.wui-chat-clip-row{display:flex;align-items:center;gap:10px}.wui-chat-clip-play{flex:none;width:32px;height:32px;border:0;border-radius:50%;background:var(--wui-chat-accent);color:var(--wui-chat-accent-contrast);cursor:pointer}.wui-chat-clip-play[disabled]{opacity:.45;cursor:default}.wui-chat-clip-wave{display:flex;flex:1;align-items:center;gap:2px;height:28px}.wui-chat-clip-bar{width:3px;height:var(--wui-chat-bar-height);border-radius:2px;background:var(--wui-chat-border)}.wui-chat-clip-bar--played{background:var(--wui-chat-accent)}.wui-chat-clip-time{font-size:12px;color:var(--wui-chat-text-muted);font-variant-numeric:tabular-nums;white-space:nowrap}.wui-chat-clip-error{margin:0;font-size:13px;color:var(--color-danger)}.wui-chat-clip-toggle{align-self:start;padding:0;border:0;background:rgba(0,0,0,0);color:var(--wui-chat-accent);font-size:13px}.wui-chat-clip-transcript{margin:0;font-size:14px;color:var(--wui-chat-text-muted);white-space:pre-wrap}@keyframes wui-chat-pulse{from{box-shadow:0 0 0 0 color-mix(in srgb, var(--wui-chat-accent) 35%, transparent)}to{box-shadow:0 0 0 10px rgba(0,0,0,0)}}.wui-chat-explain{inset:auto;margin:0;padding:0;border:1px solid var(--color-border);color:var(--color-text-body);background:var(--color-surface);border-radius:14px;box-shadow:var(--wui-shadow-popover);overflow:auto;width:min(360px,100vw - 32px);max-height:calc(100dvh - 32px);z-index:var(--wui-z-popover, 1085);font-family:var(--wui-font-ui, inherit);font-size:14px}.wui-chat-explain-head{display:flex;justify-content:space-between;align-items:center;padding:12px 12px 8px 16px}.wui-chat-explain-title{font-weight:600}.wui-chat-explain-body{display:flex;flex-direction:column;gap:8px;padding:0 16px 8px}.wui-chat-explain-foot{display:flex;flex-direction:column;gap:8px;padding:8px 16px 14px;border-top:1px solid var(--color-border)}.wui-chat-explain-note{margin:0;font-size:12px;color:var(--color-text-muted)}.wui-chat-explain-pill{display:inline-flex;align-items:center;gap:8px;padding:6px 12px;border-radius:999px;background:var(--wui-primary-5)}.wui-chat-explain-pill .wui-chat-orb{width:16px;height:16px;animation:wui-chat-explain-pulse 1.2s ease-in-out infinite alternate}@keyframes wui-chat-explain-pulse{from{opacity:.5}to{opacity:1}}.wui-chat-explain-alert{display:flex;flex-direction:column;gap:8px;padding:8px 12px;border-radius:8px}.wui-chat-explain-alert p{margin:0}.wui-chat-explain-alert--error{background:color-mix(in srgb, var(--color-danger) 12%, transparent)}.wui-chat-explain-alert--warning{background:color-mix(in srgb, var(--color-warning) 16%, transparent)}.wui-chat-explain[data-beside]{position:fixed;inset-block-start:50%;transform:translateY(-50%)}.wui-chat-explain[data-beside=end]{inset-inline-end:calc(var(--wui-chat-docked-width, 420px) + 16px);inset-inline-start:auto}.wui-chat-explain[data-beside=start]{inset-inline-start:calc(var(--wui-chat-docked-width, 420px) + 16px);inset-inline-end:auto}@media(prefers-reduced-motion: reduce){.wui-chat-explain-pill .wui-chat-orb{animation:none}}html[data-wui-chat-switching] .wui-chat--docked .wui-chat-panel,html[data-wui-chat-switching] .wui-chat--full-page .wui-chat-panel{view-transition-name:wui-chat;animation:none;transition:none}@media(prefers-reduced-motion: no-preference){::view-transition-group(wui-chat){animation-duration:280ms;animation-timing-function:cubic-bezier(0.2, 0.8, 0.2, 1)}::view-transition-old(root),::view-transition-new(root){animation-duration:200ms}}.wui-chat-switch-btn--side svg{transform:scaleX(-1)}.wui-chat-switch-btn--side:dir(rtl) svg{transform:none}.wui-chat-empty-extra,.wui-chat-empty-past{display:flex;flex-direction:column;gap:8px}.wui-chat-empty-rows--past .wui-chat-empty-row{display:flex;align-items:center;gap:8px}.wui-chat-empty-rows--past .wui-chat-empty-row-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wui-chat-empty-rows--past .wui-chat-empty-row-time{flex:none;margin-inline-start:auto}