@webority/chat-elements 0.159.6 → 0.160.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-elements.js +1 -1
- package/dist/chat.css +1 -1
- package/dist/chat.global.js +27 -27
- package/dist/types/WuiChat.d.ts +3 -0
- package/dist/types/dom.d.ts +4 -1
- package/dist/types/renderers/notice-part.d.ts +1 -1
- package/dist/web-5VRSPxuS.js +1 -0
- package/dist/web.js +1 -1
- package/package.json +8 -8
- package/dist/web-CG-QtQ0L.js +0 -1
package/dist/types/WuiChat.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ export type WuiChatAttributes = {
|
|
|
63
63
|
"label-reveal"?: "bubble" | "expand";
|
|
64
64
|
"launcher-mark"?: "icon" | "avatar" | "orb";
|
|
65
65
|
"panel-height"?: "fixed" | "content";
|
|
66
|
+
"panel-placement"?: "floating" | "side";
|
|
66
67
|
"reply-avatars"?: BooleanAttribute;
|
|
67
68
|
"greeting-loader-ms"?: `${number}`;
|
|
68
69
|
"panel-motion"?: "spring" | "gentle" | "none";
|
|
@@ -71,11 +72,13 @@ export type WuiChatAttributes = {
|
|
|
71
72
|
"panel-bottom-gap"?: `${number}`;
|
|
72
73
|
"phone-max-width"?: `${number}`;
|
|
73
74
|
"phone-mode"?: "full-screen" | "sheet";
|
|
75
|
+
"phone-hide-launcher"?: BooleanAttribute;
|
|
74
76
|
"sheet-height-dvh"?: `${number}`;
|
|
75
77
|
"sheet-max-height"?: `${number}`;
|
|
76
78
|
"input-ring"?: BooleanAttribute;
|
|
77
79
|
"send-reveal"?: "on-text" | "always";
|
|
78
80
|
"send-icon"?: string;
|
|
81
|
+
"input-mark"?: "none" | "avatar";
|
|
79
82
|
"lift-selectors"?: string;
|
|
80
83
|
"menu-selectors"?: string;
|
|
81
84
|
"dark-selectors"?: string;
|
package/dist/types/dom.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatEntrance, ChatIdleMotion, ChatLabelReveal, ChatLabels, ChatLauncherMark, ChatLauncherStyle, ChatPanelHeight, ChatPanelMotion, ChatPhoneMode, ChatSendReveal } from "@webority/chat-core";
|
|
1
|
+
import type { ChatEntrance, ChatIdleMotion, ChatInputMark, ChatLabelReveal, ChatLabels, ChatLauncherMark, ChatLauncherStyle, ChatPanelHeight, ChatPanelMotion, ChatPanelPlacement, ChatPhoneMode, ChatSendReveal } from "@webority/chat-core";
|
|
2
2
|
export declare const APP_BUTTON_MARKER = "AppButton";
|
|
3
3
|
export declare const OPEN_MS = 620;
|
|
4
4
|
export declare const CLOSE_MS = 300;
|
|
@@ -32,6 +32,9 @@ export declare function applyAppearance(root: HTMLElement, options: {
|
|
|
32
32
|
maxHeight?: number;
|
|
33
33
|
bottomGap?: number;
|
|
34
34
|
panelHeight?: ChatPanelHeight;
|
|
35
|
+
panelPlacement?: ChatPanelPlacement;
|
|
36
|
+
inputMark?: ChatInputMark;
|
|
37
|
+
phoneHideLauncher?: boolean;
|
|
35
38
|
avatar?: string | null;
|
|
36
39
|
replyAvatars?: boolean;
|
|
37
40
|
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ChatSpeechError as e,ChatSpeechError as t,createExplain as n,mergeLabels as r}from"@webority/chat-core";import{glyphNode as i}from"@webority/ui-elements/helpers";var a=`--wui-chat-launcher-block`;function o(e,t){let n=()=>{let n=t.offsetHeight;n>0&&e.style.setProperty(a,`${n}px`)};if(n(),typeof ResizeObserver>`u`)return()=>void 0;let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()}var s=`(prefers-reduced-motion: reduce)`;function c(e,t){let n=e.style.animation;e.style.animation=`none`;let r=e.getBoundingClientRect();e.style.animation=n,e.style.transformOrigin=`${t.left+t.width/2-r.left}px ${t.top+t.height/2-r.top}px`}function l(e,t){let n=typeof window.matchMedia==`function`?window.matchMedia(s):null,r=/* @__PURE__ */ new Set,i=()=>e.motion===`Reduced`||t?.motion===!1||n?.matches===!0,a=i();function o(){let e=i();if(e!==a){a=e;for(let e of r)e(a)}}return n?.addEventListener(`change`,o),{get reduced(){return a},subscribe(e){return r.add(e),()=>{r.delete(e)}},destroy(){n?.removeEventListener(`change`,o),r.clear()}}}var u=`AppButton`,d={primary:`btn-primary`,secondary:`btn-soft-primary`,ghost:`btn-ghost-primary`,outline:`btn-outline-primary`,neutral:`btn-soft-neutral`,danger:`btn-danger`};function f(e,t){return Object.getOwnPropertyDescriptor(e,t)!==void 0}function p(e,t,n){let r=document.createElement(e);if(t&&(r.className=t),n)for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return r}function m(e,t=16){return i(e,{size:t})??p(`span`,`d-inline-flex`)}function h(e=`primary`,t=`md`){if(!f(d,e))throw Error(`Unknown button variant "${e}". Use one of ${Object.keys(d).join(`, `)}.`);return`btn ${d[e]}${t===`sm`?` btn-sm`:``}`}function g(e,t,n,r){let i=p(`button`,`${h(e,`sm`)} wui-chat-action-btn`,{type:`button`});return i.dataset.wui=u,n&&i.append(m(n,14)),i.append(document.createTextNode(t)),i.addEventListener(`click`,r),i}function _(e,t,n){let r=p(`button`,`wui-chat-icon-btn`,{type:`button`,"aria-label":e,title:e});return r.append(m(t,20)),r.addEventListener(`click`,n),r}function v(e,t){let n=e.getAttribute(t);if(n!=null&&n!==``)try{return JSON.parse(n)}catch(e){throw Error(`<wui-chat ${t}> must be valid JSON.`,{cause:e})}}function y(e){let t;return n=>{let r=e.dataset.state;if((!n||r!==`open`&&r!==`opening`)&&(n||r!==`closed`&&r!==`closing`)){if(clearTimeout(t),n)e.dataset.state=`opening`,t=setTimeout(()=>{e.dataset.state=`open`},620);else{e.dataset.state=`closing`;let n=e.classList.contains(`wui-chat--panel-motion-none`)?0:300;t=setTimeout(()=>{e.dataset.state=`closed`},n)}}}}function b(e,t){t.position!==void 0&&(e.classList.toggle(`wui-chat--end`,t.position===`end`),e.classList.toggle(`wui-chat--start`,t.position===`start`)),t.reduced!==void 0&&e.classList.toggle(`wui-chat--reduced`,!!t.reduced),t.expressive!==void 0&&e.classList.toggle(`wui-chat--expressive`,t.expressive===!0),t.sendReveal!==void 0&&e.classList.toggle(`wui-chat--send-always`,t.sendReveal===`Always`),t.inputRing!==void 0&&e.classList.toggle(`wui-chat--input-ring-off`,t.inputRing===!1),t.panelMotion!==void 0&&(e.classList.toggle(`wui-chat--panel-motion-gentle`,t.panelMotion===`Gentle`),e.classList.toggle(`wui-chat--panel-motion-none`,t.panelMotion===`None`)),t.offsetX!==void 0&&e.style.setProperty(`--wui-chat-offset-x`,`${t.offsetX}px`),t.offsetY!==void 0&&e.style.setProperty(`--wui-chat-offset-y`,`${t.offsetY}px`),t.width!==void 0&&e.style.setProperty(`--wui-chat-width`,t.width),t.maxHeight!==void 0&&e.style.setProperty(`--wui-chat-panel-max-height`,`${t.maxHeight}px`),t.bottomGap!==void 0&&e.style.setProperty(`--wui-chat-bottom-gap`,`${t.bottomGap}px`),t.panelHeight!==void 0&&e.classList.toggle(`wui-chat--panel-height-content`,t.panelHeight===`Content`),t.panelPlacement!==void 0&&e.classList.toggle(`wui-chat--placement-side`,t.panelPlacement===`Side`),t.inputMark!==void 0&&e.classList.toggle(`wui-chat--input-mark-avatar`,t.inputMark===`Avatar`),t.phoneHideLauncher!==void 0&&e.classList.toggle(`wui-chat--phone-hide-launcher`,t.phoneHideLauncher),t.avatar!==void 0&&(t.avatar?(e.style.setProperty(`--wui-chat-avatar`,`url(${JSON.stringify(t.avatar)})`),e.style.setProperty(`--wui-chat-typing-mark`,`url(${JSON.stringify(t.avatar)})`)):(e.style.removeProperty(`--wui-chat-avatar`),e.style.removeProperty(`--wui-chat-typing-mark`))),t.replyAvatars!==void 0&&e.classList.toggle(`wui-chat--reply-avatars-off`,t.replyAvatars===!1)}var x=[`Text`,`Sources`,`QuickReplies`,`InputRequest`,`Action`,`Notice`,`Table`,`Chart`,`Figures`,`RecordCard`,`Image`,`File`,`Ticket`,`Handoff`,`VoiceClip`],S={launcher:`wui-chat--launcher`,docked:`wui-chat--docked`,"full-page":`wui-chat--full-page`,embedded:`wui-chat--embedded`};function C(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function w({id:e,layout:t,position:n,role:r,launcher:i,onToggle:a}){let s=p(`div`,`wui-chat ${S[t]} wui-chat--${n}`),l=p(`section`,`wui-chat-panel`,{id:e,role:r}),u=i?y(s):null;s.dataset.state=i?`closed`:`open`;let d=null,f=null,h=null,g=null,_=null,v=null,x=null,w=`round`,T=!1,E=`bubble`,D=null,O=null,k=!1,A=`icon`,j=!1;function M(){if(!d)return;let e=d.dataset.launcher,t=[`wui-chat-launcher-wrap`];e===`entering`&&D&&t.push(`wui-chat-launcher--entrance-${D}`),e===`idle`&&O&&O!==`none`&&t.push(`wui-chat-launcher--idle-${O}`),d.className=t.join(` `)}function N(){if(!f)return;let e=[...f.classList].filter(e=>e.endsWith(`--opening`)||e.endsWith(`--closing`)),t=[`wui-chat-launcher`,`wui-chat-launcher--${w}`];w===`pill`&&T&&t.push(`wui-chat-launcher--compact`),A!==`icon`&&t.push(`wui-chat-launcher--mark-${A}`),t.push(`wui-chat-launcher--reveal-${E}`,...e),f.className=t.join(` `)}function P(){_&&v&&(_.textContent=x||v.launcher)}function F(){if(!f||!g||!v)return;let e=j?v.launcherClose:x||v.launcher;f.setAttribute(`aria-label`,e),g.textContent=e}if(i){let t=p(`div`,`wui-chat-launcher-wrap`);d=t,t.dataset.launcher=`idle`;let n=p(`button`,`wui-chat-launcher`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":e});f=n;let r=p(`span`,`wui-chat-launcher-icon`,{"aria-hidden":`true`});h=r,r.append(m(`chat`,24));let i=p(`span`,`wui-chat-launcher-close`,{"aria-hidden":`true`});i.append(m(`x`,24));let c=p(`span`,`wui-chat-launcher-label`);g=c,n.append(r,i,c),n.addEventListener(`click`,()=>a()),n.addEventListener(`animationend`,e=>{e.target===n&&n.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`)});let u=p(`span`,`wui-chat-launcher-bubble`,{"aria-hidden":`true`});_=u,t.append(n,u),o(s,n),t.addEventListener(`animationend`,e=>{e.target===t&&t.dataset.launcher===`entering`&&(t.dataset.launcher=`idle`,M())}),N(),M(),s.append(t,l)}else s.append(l);function I(e){if(!u)return;let t=e&&!j&&f!==null&&f?f.getBoundingClientRect():null;e!==j&&f&&(f.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`),f.classList.add(e?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`)),j=e,u(e),t&&c(l,t),f&&(f.setAttribute(`aria-expanded`,String(e)),F())}function L(e){v=e,f&&(F(),P())}function R(e){if(b(s,e),e.theme!==void 0&&(e.theme===`light`||e.theme===`dark`?s.dataset.theme=e.theme:delete s.dataset.theme),!f||!d||!h)return;e.launcherStyle!==void 0&&(w=e.launcherStyle===`Pill`?`pill`:`round`),e.compact!==void 0&&(T=e.compact),e.labelReveal!==void 0&&(E=e.labelReveal===`Expand`?`expand`:`bubble`),e.entrance!==void 0&&(D=e.entrance===`None`?null:C(e.entrance)),e.idle!==void 0&&(O=e.idle===`None`?`none`:C(e.idle)),e.phone!==void 0&&(k=e.phone),e.hoverLabel!==void 0&&(x=e.hoverLabel||null),e.launcherMark!==void 0&&(A=C(e.launcherMark)),e.icon!==void 0&&e.icon!==h.dataset.icon&&(h.dataset.icon=e.icon,h.replaceChildren(m(e.icon,24)));let t=e.launcherState??d.dataset.launcher;k&&t===`entering`&&(t=`idle`),t===`entering`&&!D&&(t=`idle`),d.dataset.launcher=t,N(),M(),P(),F()}return{root:s,panel:l,setOpen:I,setLabels:L,setAppearance:R,nudgeHost:d,launcherButton:f,role:r}}var T=1e4,E=2e3,D=3e5,O=/* @__PURE__ */ new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),k=/* @__PURE__ */ new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function A(e){return O.has(M(e,`name`))?new t(`Blocked`,{message:N(e)}):k.has(M(e,`name`))?new t(`NoMicrophone`,{message:N(e)}):j(e)}function j(e){return e instanceof t?e:new t(`Failed`,{message:N(e)??String(e)})}function M(e,t){return typeof e==`object`&&e||typeof e==`function`?Reflect.get(e,t):void 0}function N(e){let t=M(e,`message`);return t==null?void 0:String(t)}function P(e){return typeof e==`object`&&!!e}function F(e){let t=M(e,`SpeechConfig`),n=M(e,`AudioConfig`),r=M(e,`NoMatchDetails`);return typeof M(t,`fromAuthorizationToken`)==`function`&&typeof M(n,`fromDefaultMicrophoneInput`)==`function`&&typeof M(n,`fromSpeakerOutput`)==`function`&&typeof M(r,`fromResult`)==`function`&&typeof M(e,`SpeechRecognizer`)==`function`&&typeof M(e,`SpeakerAudioDestination`)==`function`&&typeof M(e,`SpeechSynthesizer`)==`function`&&P(M(e,`PropertyId`))&&P(M(e,`ResultReason`))&&P(M(e,`NoMatchReason`))&&P(M(e,`CancellationReason`))}function I(e){if(!F(e))throw new t(`Unavailable`,{message:`Speech is not available in this browser.`});return e}var L=null;function R(){let e=globalThis,t=`SpeechSDK`in e?e.SpeechSDK:void 0;return t?Promise.resolve(I(t)):(L===null&&(L=import(`microsoft-cognitiveservices-speech-sdk`).then(e=>I(M(e,`SpeechConfig`)?e:M(e,`default`))).catch(e=>{throw L=null,e})),L)}function ee(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function z(e){let n=e.getToken,r=e.loadSdk??R,i=e.getLanguage??ee,a=typeof navigator<`u`&&typeof navigator.mediaDevices?.getUserMedia==`function`,o=typeof window<`u`&&window.isSecureContext===!0,s=a&&o,c=typeof window<`u`,l=null,u=null,d=null;function f(){return l!==null&&Date.parse(l.expiresDateTimeUtc)-Date.now()>6e4?Promise.resolve(l):(u===null&&(u=Promise.resolve().then(()=>n()).then(e=>(l=e,u=null,e),e=>{throw u=null,j(e)})),u)}function p(){return d===null&&(d=Promise.resolve().then(()=>r()).then(e=>{if(!e?.SpeechConfig)throw new t(`Unavailable`,{message:`Speech is not available in this browser.`});return e}).catch(e=>{throw d=null,j(e)})),d}function m(e={}){let{signal:n,onText:r,onEnd:a}=e;if(n?.aborted)return a?.(),Promise.resolve();let o=()=>{},c=()=>{},l=new Promise((e,t)=>{o=e,c=t}),u=!1,d=!1,m=null,h=!1,g=``,_=[],v,y,b,x=()=>{clearTimeout(v),clearTimeout(y),clearTimeout(b)},S=e=>{if(!u){u=!0,x(),n?.removeEventListener(`abort`,C);try{m?.close()}finally{try{a?.()}finally{e?c(e):o()}}}};async function C(){if(!(u||d)){d=!0,x();try{let e=m;e!==null&&await new Promise(t=>e.stopContinuousRecognitionAsync(()=>t(),()=>t()))}finally{S(null)}}}let w=()=>[..._,g].filter(e=>e!==``).join(` `).trim(),O=(e,t)=>{h||(h=!0,clearTimeout(v)),clearTimeout(y),y=setTimeout(C,E),r?.(w(),t)};async function k(){if(n?.addEventListener(`abort`,C),!s){S(new t(`Unavailable`,{message:`Dictation is not available in this browser.`}));return}let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){S(A(e));return}for(let e of r.getTracks())e.stop();if(!u)try{let n=await p(),r=await f();if(u)return;let a=n.SpeechConfig.fromAuthorizationToken(r.token,r.region);a.speechRecognitionLanguage=e.language||i(),a.setProperty(n.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,String(T));let o=new n.SpeechRecognizer(a,n.AudioConfig.fromDefaultMicrophoneInput());if(m=o,o.recognizing=(e,t)=>{if(u)return;let n=t.result?.text;n&&(g=n,O(n,!1))},o.recognized=(e,r)=>{if(u)return;let{reason:i,text:a}=r.result;i===n.ResultReason.RecognizedSpeech&&a?(_.push(a),g=``,O(a,!0)):i===n.ResultReason.NoMatch&&n.NoMatchDetails.fromResult(r.result).reason===n.NoMatchReason.InitialSilenceTimeout&&S(new t(`NoSpeech`,{message:`No speech was heard.`}))},o.canceled=(e,r)=>{u||(r.reason===n.CancellationReason.Error?S(new t(`Failed`,{message:r.errorDetails})):S(null))},o.sessionStopped=()=>S(null),await new Promise((e,t)=>o.startContinuousRecognitionAsync(()=>e(),t)),u)return;e.onStarted?.(),v=setTimeout(()=>{h||S(new t(`NoSpeech`,{message:`No speech was heard.`}))},T),b=setTimeout(C,D)}catch(e){S(j(e))}}return k(),l}async function h(e,n={}){let{signal:r}=n;if(!r?.aborted)try{let a=await p(),o=await f();if(r?.aborted)return;let s=a.SpeechConfig.fromAuthorizationToken(o.token,o.region);s.speechSynthesisLanguage=n.language||i();let c=new a.SpeakerAudioDestination,l=new a.SpeechSynthesizer(s,a.AudioConfig.fromSpeakerOutput(c));await new Promise((n,i)=>{let o=!1,s=()=>{r?.removeEventListener(`abort`,f),l.close(),c.close()},u=()=>{o||(o=!0,s(),n())},d=e=>{o||(o=!0,s(),i(j(e)))};function f(){c.pause(),u()}r?.addEventListener(`abort`,f),c.onAudioEnd=u;try{l.speakTextAsync(e,e=>{e.reason!==a.ResultReason.SynthesizingAudioCompleted&&d(new t(`Failed`,{message:`The reply could not be synthesised.`}))},e=>d(e))}catch(e){d(e)}})}catch(e){throw j(e)}}return{dictation:s,readAloud:c,streamsText:!0,startDictation:m,speak:h}}var B=6e4,V=60*B,H=48*V;function U(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function W(e,t=Date.now(),n){let r=U(e);if(r===null)return``;let i=t-r,a=Math.abs(i),o=i>=0,s=new Intl.RelativeTimeFormat(n,{numeric:`auto`});if(a<B)return s.format(0,`second`);if(a<V){let e=Math.floor(a/B);return s.format(o?-e:e,`minute`)}if(a<H){let e=Math.floor(a/V);return s.format(o?-e:e,`hour`)}return new Intl.DateTimeFormat(n,{day:`numeric`,month:`short`,year:`numeric`}).format(new Date(r))}function te(e,t){let n=U(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}var G=`data-wchat-printing`,K=`data-wchat-print-hide`,ne=`data-wchat-print-path`,re=`data-wchat-print-target`,ie=/* @__PURE__ */ new Set([`script`,`style`,`link`,`template`]),q=null;function J(){if(q!==null){for(let e of q.marked)e.removeAttribute(K),e.removeAttribute(ne),e.removeAttribute(re);q.heading.remove(),document.documentElement.removeAttribute(G),window.removeEventListener(`afterprint`,q.onAfterPrint),q=null}}function ae(e,t,n,r,i){J();let a=e.querySelector(`.wui-chat-panel`);if(a===null)throw Error(`print needs the wui-chat root`);let o=[],s=a;for(;s!==null&&s!==document.documentElement;){s.setAttribute(ne,``),o.push(s);let e=s.parentElement;if(e===null)throw Error(`print walk left the chat root`);for(let t of e.children)t===s||ie.has(t.localName)||(t.setAttribute(K,``),o.push(t));s=e}for(let e of n)e.setAttribute(K,``),o.push(e);r!==null&&(r.setAttribute(re,``),o.push(r));let c=document.createElement(`div`);c.className=`wui-chat-print-heading`;let l=document.createElement(`h1`);l.textContent=i.title;let u=document.createElement(`p`);u.textContent=i.printedOn,c.append(l,u),a.prepend(c),document.documentElement.setAttribute(G,t);let d=()=>J();window.addEventListener(`afterprint`,d,{once:!0}),q={marked:o,heading:c,onAfterPrint:d};try{window.print()}catch(e){throw J(),e}}function oe(e,t){ae(e,`conversation`,[],null,t)}function se(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);ae(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function ce(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function le({title:e,text:t}){if(!ce())return`failed`;try{return await navigator.share({title:e,text:t}),`shared`}catch(e){return typeof e==`object`&&e&&`name`in e&&e.name===`AbortError`?`cancelled`:`failed`}}var ue=`wchat:auto-opened`,de=`wchat:dismissed`,fe=`button, a[href], input, select, textarea`,pe=`input, textarea`;function Y(e){return!e.closest(`.wui-chat`)}function me(e){return e instanceof Element&&e.matches(pe)&&Y(e)}function he(){return[...document.querySelectorAll(pe)].some(e=>Y(e)&&e.value!==e.defaultValue)}function ge(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function _e(e){return e?[...document.querySelectorAll(fe)].some(t=>{if(!Y(t))return!1;let n=t.getBoundingClientRect();return n.width===0||n.height===0?!1:n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top}):!1}function ve(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(ue)||e.rememberDismissal&&sessionStorage.getItem(de)||window.innerWidth<e.skipBelowWidthPx)return!0;let r=window.location.pathname;if(e.skipPathPrefixes.some(e=>r.startsWith(e)))return!0;let i=t.avoid.autoOpenOptOutSelector;return i&&document.querySelector(i)||e.skipWhenFormTouched&&he()||n.isOpen()?!0:e.skipWhenCoversControl&&_e(n.panelRect())}function ye(e){return me(document.activeElement)||ge(e.avoid.menuSelectors)||ge(e.avoid.autoOpenBusySelectors)}function be(e,t,n){let r;function i(){r=void 0,ve(e,t,n)||(ye(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(ue,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=void 0}}}var xe=.4,Se=20;function X(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Ce(e){let t=e.match(/[\d.]+/g);if(!t||t.length<3)return null;let[n=0,r=0,i=0]=t.slice(0,3).map(Number);return{r:n,g:r,b:i,alpha:t.length>3?Number(t[3])/(e.includes(`%`)?100:1):1}}function we({r:e,g:t,b:n}){return .2126*X(e)+.7152*X(t)+.0722*X(n)}function Te(e,t){let n=e.getBoundingClientRect(),r=document.elementsFromPoint?.(n.left+n.width/2,n.top+n.height/2)??[],i=t.length?t.join(`,`):null;for(let t of r){if(e.contains(t))continue;if(i&&t.closest(i))return!0;let n=Ce(getComputedStyle(t).backgroundColor);if(n&&n.alpha>0)return we(n)<xe}return!1}function Ee(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function De(e){let t=0;for(let n of e){let e=n.getBoundingClientRect();e.height!==0&&(t=Math.max(t,window.innerHeight-e.top))}return t>0?t+Se:0}function Oe(e){if(e.length===0)return!1;for(let t of document.querySelectorAll(e.join(`,`))){let e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return!0}return!1}function ke(e,t,n){let r=n.ownerDocument.documentElement,i=0,a=!1,o=null;function s(){i=0;let s=t.liftAboveFooter?Ee(e.liftSelectors):[];if(o)for(let e of s)o.observe(e);n.style.setProperty(`--wui-chat-lift`,`${De(s)}px`);let c=n.getBoundingClientRect(),l=c.height===0?0:Math.round(window.innerHeight-c.top);r.style.setProperty(`--wui-chat-launcher-block`,`${l}px`);let u=t.stepAsideForMenus&&Oe(e.menuSelectors);u&&!a?(n.dataset.launcher=`hidden`,n.inert=!0,a=!0):!u&&a&&(n.dataset.launcher=`idle`,n.inert=!1,a=!1);let d=t.switchOnDark&&Te(n,e.darkSelectors);d&&n.dataset.onDark===void 0&&(n.dataset.onDark=``),!d&&n.dataset.onDark!==void 0&&delete n.dataset.onDark}function c(){i||=requestAnimationFrame(s)}typeof ResizeObserver==`function`&&(o=new ResizeObserver(c));let l=new MutationObserver(c);return l.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`open`,`data-menu-open`]}),document.addEventListener(`scroll`,c,{capture:!0,passive:!0}),window.addEventListener(`resize`,c),window.addEventListener(`load`,c),n.addEventListener(`animationend`,c),c(),{destroy(){i&&cancelAnimationFrame(i),i=0,o?.disconnect(),l.disconnect(),document.removeEventListener(`scroll`,c,{capture:!0}),window.removeEventListener(`resize`,c),window.removeEventListener(`load`,c),n.removeEventListener(`animationend`,c),a&&=(n.inert=!1,!1),delete n.dataset.onDark,n.style.removeProperty(`--wui-chat-lift`),r.style.removeProperty(`--wui-chat-launcher-block`)}}}var Z=`wchat:session-start`,Ae=`wchat:pages`,je=`wchat:services`;function Me(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function Ne(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function Pe(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function Fe(e){sessionStorage.getItem(Z)||sessionStorage.setItem(Z,String(Date.now()));let t=0;function n(){let e=document.documentElement.scrollHeight;if(e<=0)return;let n=(window.scrollY+window.innerHeight)/e*100;n>t&&(t=n)}return window.addEventListener(`scroll`,n,{passive:!0}),function(){n();let r=window.location.pathname,i=Me(Ae);i.includes(r)||(i.push(r),Ne(Ae,i));let a=Pe(r,e),o=Me(je);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),Ne(je,o)),{timeOnSiteSeconds:Math.floor((Date.now()-Number(sessionStorage.getItem(Z)))/1e3),scrollPercent:Math.min(100,Math.floor(t)),pagesViewed:i.length,viewedServices:o}}}var Q=8,Ie=`(min-width: 992px)`,Le=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,Re=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],ze=0;function Be(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Ve(e){let{trigger:t,request:i,isEmpty:a,renderAnswer:o,renderFooter:s,session:c,timings:l,onStateChange:u,returnFocusTo:d}=e??{};if(!(t instanceof HTMLElement))throw TypeError(`createExplainPopover needs a "trigger" element.`);if(typeof i!=`function`)throw TypeError(`createExplainPopover needs a "request" function.`);if(typeof o!=`function`)throw TypeError(`createExplainPopover needs a "renderAnswer" function.`);ze+=1;let f=e.title??``,m=e.showNotCounted??!0,h=`wui-chat-explain-${ze}`,v=()=>r(e.labels??{}),y=()=>({labels:v(),close:H}),b=n({request:i,...a===void 0?{}:{isEmpty:a},...l}),x=Object.fromEntries(Re.map(e=>[e,t.getAttribute(e)])),S=t.hidden,C;t.setAttribute(`aria-haspopup`,`dialog`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,h);let w=null,T=null,E=null,D,O=null,k=[],A=[],j=()=>c?.getState().features.Explain===!1;function M(){b.getSnapshot().offline?(C===void 0&&(C=t.getAttribute(`title`)),t.setAttribute(`title`,v().explainOffline),t.setAttribute(`aria-disabled`,`true`),t.setAttribute(`data-offline`,``)):(C!==void 0&&Be(t,`title`,C),C=void 0,t.removeAttribute(`aria-disabled`),t.removeAttribute(`data-offline`)),c&&(t.hidden=j())}function N(e){if(T?.replaceChildren(),e.pillVisible){let t=p(`span`,`wui-chat-explain-pill`),n=p(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),r=p(`span`);r.textContent=e.state===`slow`?v().explainSlow:v().thinking,t.append(n,r);let i=p(`div`,`wui-chat-explain-thinking`,{role:`status`});i.append(t),T?.append(i)}else if(e.state===`answered`){e.answer!==D&&(E=o(e.answer,y())??null,D=e.answer);let t=p(`div`,`wui-chat-explain-answer`);E&&t.append(E),T?.append(t)}else if(e.state===`empty`){let e=p(`p`,`wui-chat-explain-text`);e.textContent=v().explainEmpty,T?.append(e)}else if(e.state===`capacity`){let t=p(`div`,`wui-chat-explain-alert wui-chat-explain-alert--warning`,{role:`status`}),n=p(`p`);n.textContent=e.resetsDateTimeUtc?v().explainCapacity(te(e.resetsDateTimeUtc)):v().explainCapacityNoDate,t.append(n),T?.append(t)}else if(e.state===`error`){let e=p(`div`,`wui-chat-explain-alert wui-chat-explain-alert--error`,{role:`alert`}),t=p(`p`);t.textContent=v().explainError,e.append(t,g(`ghost`,v().retry,`rotate-ccw`,()=>b.ask())),T?.append(e)}}function P(){let e=w?.querySelector(`.wui-chat-explain-foot`);e?.replaceChildren();let t=s?.(y());if(t&&e?.append(t),m){let t=p(`p`,`wui-chat-explain-note`);t.textContent=v().explainNotCounted,e?.append(t)}}function F(){if(!w)return;let e=b.getSnapshot();w.dataset.state=e.state,N(e),P(),u?.(e)}function I(){if(!w)return;if(!t.isConnected){H({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wchat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Ie)?.matches===!0){w.dataset.beside=e,w.style.left=``,w.style.top=``,w.style.maxHeight=``;return}delete w.dataset.beside,w.style.position=`fixed`;let n=t.getBoundingClientRect(),r=w.offsetWidth,i=w.offsetHeight,a=globalThis.innerHeight-n.bottom-Q,o=a<i&&n.top>a,s=o?n.top-Q:a,c=o?Math.max(Q,n.top-i-Q):n.bottom+Q,l=Math.max(Q,Math.min(n.left,globalThis.innerWidth-r-Q));w.style.top=`${c}px`,w.style.left=`${l}px`,w.style.maxHeight=s<i?`${Math.max(0,s)}px`:``}function L(e){e.key===`Escape`&&(document.documentElement.hasAttribute(`data-wchat-docked`)||(e.stopPropagation(),H()))}function R(e){let n=e.target;n instanceof Node&&(w?.contains(n)||t.contains(n))||n instanceof Element&&n.closest(`.wui-chat-panel`)||H({restoreFocus:!1})}function ee(e){e.target instanceof Node&&w?.contains(e.target)||I()}function z(){b.getSnapshot().offline||U()}function B(){for(let[e,t,n,r]of k)e.removeEventListener(t,n,r);k=[];for(let e of A)e.disconnect();A=[]}function V(){if(w||j()||b.getSnapshot().offline)return;w=p(`div`,`wui-chat-explain`,{role:`dialog`,"aria-label":f,popover:`manual`,id:h});let e=p(`header`,`wui-chat-explain-head`),n=p(`strong`,`wui-chat-explain-title`);n.textContent=f,O=_(v().close,`x`,()=>H()),O.classList.add(`wui-chat-explain-close`),e.append(n,O),T=p(`div`,`wui-chat-explain-body`,{"aria-live":`polite`}),w.append(e,T,p(`div`,`wui-chat-explain-foot`)),w.dataset.state=b.getSnapshot().state,document.body.append(w),w.showPopover?.(),t.setAttribute(`aria-expanded`,`true`),b.ask(),I(),(w.querySelector(Le)??O).focus({preventScroll:!0}),k=[[document,`keydown`,L,!0],[document,`pointerdown`,R,!0],[window,`resize`,I,!1],[document,`scroll`,ee,!0]];for(let[e,t,n,r]of k)e.addEventListener(t,n,r);if(typeof ResizeObserver==`function`){let e=new ResizeObserver(()=>I());e.observe(w),A.push(e)}let r=new MutationObserver(()=>I());r.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-wchat-docked`]}),A.push(r)}function H(e={restoreFocus:!0}){w&&(b.reset(),B(),w.remove(),w=null,T=null,E=null,D=void 0,O=null,t.setAttribute(`aria-expanded`,`false`),M(),e?.restoreFocus!==!1&&(d?.()??t).focus({preventScroll:!0}))}function U(){w?H():V()}let W=b.subscribe(()=>{M(),b.getSnapshot().offline&&w?H():F()}),G=c?.subscribe(()=>{M(),j()&&w&&H({restoreFocus:!1})});return t.addEventListener(`click`,z),M(),{open:V,close:H,toggle:U,isOpen:()=>w!==null,destroy(){H({restoreFocus:!1}),W(),G?.(),b.dispose(),t.removeEventListener(`click`,z);for(let e of Re)Be(t,e,x[e]);t.hidden=S}}}var He=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Ue(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(He)].filter(e=>e.tabIndex>=0&&!e.hidden),r=n[0],i=n[n.length-1];if(!r||!i){t.preventDefault();return}let a=e.ownerDocument.activeElement,o=e.contains(a);t.shiftKey?o&&a!==r||(t.preventDefault(),i.focus()):o&&a!==i||(t.preventDefault(),r.focus())}function We(e){e?.isConnected&&e.focus()}function Ge(e,t){if(t||typeof navigator>`u`)return;let n=navigator;typeof n.vibrate==`function`&&n.vibrate(e)}var Ke=`wui-chat-lock`,qe=`wui-chat-scroll-lock`;function Je(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(Ke);e.setAttribute(`data-lenis-prevent`,``),e.style.overscrollBehavior=`contain`,window.dispatchEvent(new CustomEvent(qe,{detail:{locked:!0}}));let i=!0;return function(){if(i){i=!1;for(let e of n)e.classList.remove(Ke);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(qe,{detail:{locked:!1}}))}}}var Ye={open:{from:420,to:920,seconds:.16,peak:.16},reply:{from:680,to:540,seconds:.11,peak:.06},sent:{from:540,to:760,seconds:.09,peak:.05}},Xe=[`pointerdown`,`keydown`,`touchstart`],Ze=`wchat:muted`,Qe=1e-4;function $e(e,t){let n=t.get(Ze)===`1`,r=null;function i(){for(let e of Xe)document.removeEventListener(e,a)}function a(){let e=globalThis.AudioContext||globalThis.webkitAudioContext;!r&&e&&(r=new e),r?.state===`suspended`&&r.resume().catch(e=>globalThis.reportError?.(e)),i()}for(let e of Xe)document.addEventListener(e,a);return{play(t){let i=Ye[t];if(!i||n||!r||!e[t]||!(e.volume>0))return;let a=r.currentTime,o=r.createOscillator(),s=r.createGain();o.type=`sine`,o.frequency.setValueAtTime(i.from,a),o.frequency.linearRampToValueAtTime(i.to,a+i.seconds),s.gain.setValueAtTime(i.peak*e.volume,a),s.gain.exponentialRampToValueAtTime(Qe,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(Ze,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close().catch(e=>globalThis.reportError?.(e)),r=null}}}function et(e,t={}){let n=t.language;return z({getToken:()=>e.getSpeechToken(),getLanguage:n?()=>n:void 0})}var tt=2e3,nt=500,rt=32,$=16,it=`data-wchat-switching`;function at(e){return new Promise(t=>setTimeout(t,e))}function ot(e,t){return typeof e!=`function`||e()?Promise.resolve():new Promise(n=>{let r=0,i=()=>{e()||r>=t?n():(r+=$,setTimeout(i,$))};setTimeout(i,$)})}async function st(e,t={}){let n=t.reduced??globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;if(typeof document.startViewTransition!=`function`||n){await e();return}let r=document.documentElement;r.setAttribute(it,``);try{let n=()=>!t.target||document.querySelector(`.wui-chat--${t.target}`)!==null,r=()=>(typeof t.pageReady!=`function`||t.pageReady())&&n(),i=document.startViewTransition(async()=>{await e(),await ot(t.routeReady,tt),await ot(r,nt),await at(rt)});Promise.allSettled([i.ready]);try{await i.updateCallbackDone}finally{await Promise.allSettled([i.finished])}}finally{r.removeAttribute(it)}}var ct=100,lt=12,ut=220;function dt(e,t){let n=t.phone.mode===`Sheet`,r=window.visualViewport,i;function a(){e.style.removeProperty(`bottom`),e.style.removeProperty(`max-height`)}function o(){if(i=void 0,window.innerWidth>t.phone.maxWidthPx){a();return}if(!r)return;let o=Math.max(0,window.innerHeight-r.height-r.offsetTop),s=r.height-lt;n&&(s=Math.min(t.phone.sheetMaxHeightPx,Math.max(ut,s))),e.style.bottom=`${o}px`,e.style.maxHeight=`${s}px`}function s(){clearTimeout(i),i=setTimeout(o,ct)}return r?.addEventListener(`resize`,s),r?.addEventListener(`scroll`,s),window.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),o(),{destroy(){clearTimeout(i),r?.removeEventListener(`resize`,s),r?.removeEventListener(`scroll`,s),window.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s),a()}}}export{m as A,A as C,p as D,w as E,o as F,g as M,c as N,f as O,l as P,z as S,h as T,oe as _,$e as a,W as b,We as c,Fe as d,ke as f,J as g,le as h,et as i,v as j,_ as k,Ue as l,ce as m,dt as n,Je as o,be as p,st as r,Ge as s,e as t,Ve as u,se as v,x as w,t as x,te as y};
|
package/dist/web.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as ChatSpeechError,m as canShareText,f as createAvoidance,S as createAzureSpeech,d as createBehaviourCollector,u as createExplainPopover,a as createSound,i as createWebSpeech,g as endPrint,n as fitToViewport,y as fullMoment,N as growFromButton,o as lockPageScroll,C as microphoneError,_ as printConversation,v as printReply,b as relativeMoment,c as returnFocus,h as shareText,r as switchPanel,F as trackLauncherBlock,l as trapTab,s as vibrate,p as watchAutoOpen,P as watchReducedMotion}from"./web-
|
|
1
|
+
export{t as ChatSpeechError,m as canShareText,f as createAvoidance,S as createAzureSpeech,d as createBehaviourCollector,u as createExplainPopover,a as createSound,i as createWebSpeech,g as endPrint,n as fitToViewport,y as fullMoment,N as growFromButton,o as lockPageScroll,C as microphoneError,_ as printConversation,v as printReply,b as relativeMoment,c as returnFocus,h as shareText,r as switchPanel,F as trackLauncherBlock,l as trapTab,s as vibrate,p as watchAutoOpen,P as watchReducedMotion}from"./web-5VRSPxuS.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/chat-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.160.0",
|
|
4
4
|
"description": "The Webority Chat web elements: the <wui-chat> custom element and one custom element per message part kind, the chat styles on @webority/theme tokens, and the global bundle that Razor pages load.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"type": "module",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"./src/renderers/*.ts"
|
|
44
44
|
],
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@webority/chat-core": "0.
|
|
47
|
-
"@webority/markdown-core": "^0.
|
|
48
|
-
"@webority/theme": "^0.
|
|
49
|
-
"@webority/ui-elements": "^0.
|
|
46
|
+
"@webority/chat-core": "0.160.0",
|
|
47
|
+
"@webority/markdown-core": "^0.190.1",
|
|
48
|
+
"@webority/theme": "^0.190.1",
|
|
49
|
+
"@webority/ui-elements": "^0.190.1",
|
|
50
50
|
"microsoft-cognitiveservices-speech-sdk": "^1.53.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@webority/chat-core": "0.
|
|
59
|
-
"@webority/theme": "0.
|
|
60
|
-
"@webority/ui-elements": "0.
|
|
58
|
+
"@webority/chat-core": "0.160.0",
|
|
59
|
+
"@webority/theme": "0.190.1",
|
|
60
|
+
"@webority/ui-elements": "0.190.1",
|
|
61
61
|
"@vitest/coverage-v8": "5.1.0",
|
|
62
62
|
"bootstrap": "5.3.9",
|
|
63
63
|
"jsdom": "30.1.1",
|
package/dist/web-CG-QtQ0L.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ChatSpeechError as e,ChatSpeechError as t,createExplain as n,mergeLabels as r}from"@webority/chat-core";import{glyphNode as i}from"@webority/ui-elements/helpers";var a=`--wui-chat-launcher-block`;function o(e,t){let n=()=>{let n=t.offsetHeight;n>0&&e.style.setProperty(a,`${n}px`)};if(n(),typeof ResizeObserver>`u`)return()=>void 0;let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()}var s=`(prefers-reduced-motion: reduce)`;function c(e,t){let n=e.style.animation;e.style.animation=`none`;let r=e.getBoundingClientRect();e.style.animation=n,e.style.transformOrigin=`${t.left+t.width/2-r.left}px ${t.top+t.height/2-r.top}px`}function l(e,t){let n=typeof window.matchMedia==`function`?window.matchMedia(s):null,r=/* @__PURE__ */ new Set,i=()=>e.motion===`Reduced`||t?.motion===!1||n?.matches===!0,a=i();function o(){let e=i();if(e!==a){a=e;for(let e of r)e(a)}}return n?.addEventListener(`change`,o),{get reduced(){return a},subscribe(e){return r.add(e),()=>{r.delete(e)}},destroy(){n?.removeEventListener(`change`,o),r.clear()}}}var u=`AppButton`,d={primary:`btn-primary`,secondary:`btn-soft-primary`,ghost:`btn-ghost-primary`,outline:`btn-outline-primary`,neutral:`btn-soft-neutral`,danger:`btn-danger`};function f(e,t){return Object.getOwnPropertyDescriptor(e,t)!==void 0}function p(e,t,n){let r=document.createElement(e);if(t&&(r.className=t),n)for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return r}function m(e,t=16){return i(e,{size:t})??p(`span`,`d-inline-flex`)}function h(e=`primary`,t=`md`){if(!f(d,e))throw Error(`Unknown button variant "${e}". Use one of ${Object.keys(d).join(`, `)}.`);return`btn ${d[e]}${t===`sm`?` btn-sm`:``}`}function g(e,t,n,r){let i=p(`button`,`${h(e,`sm`)} wui-chat-action-btn`,{type:`button`});return i.dataset.wui=u,n&&i.append(m(n,14)),i.append(document.createTextNode(t)),i.addEventListener(`click`,r),i}function _(e,t,n){let r=p(`button`,`wui-chat-icon-btn`,{type:`button`,"aria-label":e,title:e});return r.append(m(t,20)),r.addEventListener(`click`,n),r}function v(e,t){let n=e.getAttribute(t);if(n!=null&&n!==``)try{return JSON.parse(n)}catch(e){throw Error(`<wui-chat ${t}> must be valid JSON.`,{cause:e})}}function y(e){let t;return n=>{let r=e.dataset.state;if((!n||r!==`open`&&r!==`opening`)&&(n||r!==`closed`&&r!==`closing`)){if(clearTimeout(t),n)e.dataset.state=`opening`,t=setTimeout(()=>{e.dataset.state=`open`},620);else{e.dataset.state=`closing`;let n=e.classList.contains(`wui-chat--panel-motion-none`)?0:300;t=setTimeout(()=>{e.dataset.state=`closed`},n)}}}}function b(e,t){t.position!==void 0&&(e.classList.toggle(`wui-chat--end`,t.position===`end`),e.classList.toggle(`wui-chat--start`,t.position===`start`)),t.reduced!==void 0&&e.classList.toggle(`wui-chat--reduced`,!!t.reduced),t.expressive!==void 0&&e.classList.toggle(`wui-chat--expressive`,t.expressive===!0),t.sendReveal!==void 0&&e.classList.toggle(`wui-chat--send-always`,t.sendReveal===`Always`),t.inputRing!==void 0&&e.classList.toggle(`wui-chat--input-ring-off`,t.inputRing===!1),t.panelMotion!==void 0&&(e.classList.toggle(`wui-chat--panel-motion-gentle`,t.panelMotion===`Gentle`),e.classList.toggle(`wui-chat--panel-motion-none`,t.panelMotion===`None`)),t.offsetX!==void 0&&e.style.setProperty(`--wui-chat-offset-x`,`${t.offsetX}px`),t.offsetY!==void 0&&e.style.setProperty(`--wui-chat-offset-y`,`${t.offsetY}px`),t.width!==void 0&&e.style.setProperty(`--wui-chat-width`,t.width),t.maxHeight!==void 0&&e.style.setProperty(`--wui-chat-panel-max-height`,`${t.maxHeight}px`),t.bottomGap!==void 0&&e.style.setProperty(`--wui-chat-bottom-gap`,`${t.bottomGap}px`),t.panelHeight!==void 0&&e.classList.toggle(`wui-chat--panel-height-content`,t.panelHeight===`Content`),t.avatar!==void 0&&(t.avatar?(e.style.setProperty(`--wui-chat-avatar`,`url(${JSON.stringify(t.avatar)})`),e.style.setProperty(`--wui-chat-typing-mark`,`url(${JSON.stringify(t.avatar)})`)):(e.style.removeProperty(`--wui-chat-avatar`),e.style.removeProperty(`--wui-chat-typing-mark`))),t.replyAvatars!==void 0&&e.classList.toggle(`wui-chat--reply-avatars-off`,t.replyAvatars===!1)}var x=[`Text`,`Sources`,`QuickReplies`,`InputRequest`,`Action`,`Notice`,`Table`,`Chart`,`Figures`,`RecordCard`,`Image`,`File`,`Ticket`,`Handoff`,`VoiceClip`],S={launcher:`wui-chat--launcher`,docked:`wui-chat--docked`,"full-page":`wui-chat--full-page`,embedded:`wui-chat--embedded`};function C(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function w({id:e,layout:t,position:n,role:r,launcher:i,onToggle:a}){let s=p(`div`,`wui-chat ${S[t]} wui-chat--${n}`),l=p(`section`,`wui-chat-panel`,{id:e,role:r}),u=i?y(s):null;s.dataset.state=i?`closed`:`open`;let d=null,f=null,h=null,g=null,_=null,v=null,x=null,w=`round`,T=!1,E=`bubble`,D=null,O=null,k=!1,A=`icon`,j=!1;function M(){if(!d)return;let e=d.dataset.launcher,t=[`wui-chat-launcher-wrap`];e===`entering`&&D&&t.push(`wui-chat-launcher--entrance-${D}`),e===`idle`&&O&&O!==`none`&&(O!==`ring`||w===`pill`)&&t.push(`wui-chat-launcher--idle-${O}`),d.className=t.join(` `)}function N(){if(!f)return;let e=[...f.classList].filter(e=>e.endsWith(`--opening`)||e.endsWith(`--closing`)),t=[`wui-chat-launcher`,`wui-chat-launcher--${w}`];w===`pill`&&T&&t.push(`wui-chat-launcher--compact`),A!==`icon`&&t.push(`wui-chat-launcher--mark-${A}`),t.push(`wui-chat-launcher--reveal-${E}`,...e),f.className=t.join(` `)}function P(){_&&v&&(_.textContent=x||v.launcher)}function F(){if(!f||!g||!v)return;let e=j?v.launcherClose:x||v.launcher;f.setAttribute(`aria-label`,e),g.textContent=e}if(i){let t=p(`div`,`wui-chat-launcher-wrap`);d=t,t.dataset.launcher=`idle`;let n=p(`button`,`wui-chat-launcher`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":e});f=n;let r=p(`span`,`wui-chat-launcher-icon`,{"aria-hidden":`true`});h=r,r.append(m(`chat`,24));let i=p(`span`,`wui-chat-launcher-close`,{"aria-hidden":`true`});i.append(m(`x`,24));let c=p(`span`,`wui-chat-launcher-label`);g=c,n.append(r,i,c),n.addEventListener(`click`,()=>a()),n.addEventListener(`animationend`,e=>{e.target===n&&n.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`)});let u=p(`span`,`wui-chat-launcher-bubble`,{"aria-hidden":`true`});_=u,t.append(n,u),o(s,n),t.addEventListener(`animationend`,e=>{e.target===t&&t.dataset.launcher===`entering`&&(t.dataset.launcher=`idle`,M())}),N(),M(),s.append(t,l)}else s.append(l);function I(e){if(!u)return;let t=e&&!j&&f!==null&&f?f.getBoundingClientRect():null;e!==j&&f&&(f.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`),f.classList.add(e?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`)),j=e,u(e),t&&c(l,t),f&&(f.setAttribute(`aria-expanded`,String(e)),F())}function L(e){v=e,f&&(F(),P())}function R(e){if(b(s,e),e.theme!==void 0&&(e.theme===`light`||e.theme===`dark`?s.dataset.theme=e.theme:delete s.dataset.theme),!f||!d||!h)return;e.launcherStyle!==void 0&&(w=e.launcherStyle===`Pill`?`pill`:`round`),e.compact!==void 0&&(T=e.compact),e.labelReveal!==void 0&&(E=e.labelReveal===`Expand`?`expand`:`bubble`),e.entrance!==void 0&&(D=e.entrance===`None`?null:C(e.entrance)),e.idle!==void 0&&(O=e.idle===`None`?`none`:C(e.idle)),e.phone!==void 0&&(k=e.phone),e.hoverLabel!==void 0&&(x=e.hoverLabel||null),e.launcherMark!==void 0&&(A=C(e.launcherMark)),e.icon!==void 0&&e.icon!==h.dataset.icon&&(h.dataset.icon=e.icon,h.replaceChildren(m(e.icon,24)));let t=e.launcherState??d.dataset.launcher;k&&t===`entering`&&(t=`idle`),t===`entering`&&!D&&(t=`idle`),d.dataset.launcher=t,N(),M(),P(),F()}return{root:s,panel:l,setOpen:I,setLabels:L,setAppearance:R,nudgeHost:d,launcherButton:f,role:r}}var T=1e4,E=2e3,D=3e5,O=/* @__PURE__ */ new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),k=/* @__PURE__ */ new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function A(e){return O.has(M(e,`name`))?new t(`Blocked`,{message:N(e)}):k.has(M(e,`name`))?new t(`NoMicrophone`,{message:N(e)}):j(e)}function j(e){return e instanceof t?e:new t(`Failed`,{message:N(e)??String(e)})}function M(e,t){return typeof e==`object`&&e||typeof e==`function`?Reflect.get(e,t):void 0}function N(e){let t=M(e,`message`);return t==null?void 0:String(t)}function P(e){return typeof e==`object`&&!!e}function F(e){let t=M(e,`SpeechConfig`),n=M(e,`AudioConfig`),r=M(e,`NoMatchDetails`);return typeof M(t,`fromAuthorizationToken`)==`function`&&typeof M(n,`fromDefaultMicrophoneInput`)==`function`&&typeof M(n,`fromSpeakerOutput`)==`function`&&typeof M(r,`fromResult`)==`function`&&typeof M(e,`SpeechRecognizer`)==`function`&&typeof M(e,`SpeakerAudioDestination`)==`function`&&typeof M(e,`SpeechSynthesizer`)==`function`&&P(M(e,`PropertyId`))&&P(M(e,`ResultReason`))&&P(M(e,`NoMatchReason`))&&P(M(e,`CancellationReason`))}function I(e){if(!F(e))throw new t(`Unavailable`,{message:`Speech is not available in this browser.`});return e}var L=null;function R(){let e=globalThis,t=`SpeechSDK`in e?e.SpeechSDK:void 0;return t?Promise.resolve(I(t)):(L===null&&(L=import(`microsoft-cognitiveservices-speech-sdk`).then(e=>I(M(e,`SpeechConfig`)?e:M(e,`default`))).catch(e=>{throw L=null,e})),L)}function ee(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function z(e){let n=e.getToken,r=e.loadSdk??R,i=e.getLanguage??ee,a=typeof navigator<`u`&&typeof navigator.mediaDevices?.getUserMedia==`function`,o=typeof window<`u`&&window.isSecureContext===!0,s=a&&o,c=typeof window<`u`,l=null,u=null,d=null;function f(){return l!==null&&Date.parse(l.expiresDateTimeUtc)-Date.now()>6e4?Promise.resolve(l):(u===null&&(u=Promise.resolve().then(()=>n()).then(e=>(l=e,u=null,e),e=>{throw u=null,j(e)})),u)}function p(){return d===null&&(d=Promise.resolve().then(()=>r()).then(e=>{if(!e?.SpeechConfig)throw new t(`Unavailable`,{message:`Speech is not available in this browser.`});return e}).catch(e=>{throw d=null,j(e)})),d}function m(e={}){let{signal:n,onText:r,onEnd:a}=e;if(n?.aborted)return a?.(),Promise.resolve();let o=()=>{},c=()=>{},l=new Promise((e,t)=>{o=e,c=t}),u=!1,d=!1,m=null,h=!1,g=``,_=[],v,y,b,x=()=>{clearTimeout(v),clearTimeout(y),clearTimeout(b)},S=e=>{if(!u){u=!0,x(),n?.removeEventListener(`abort`,C);try{m?.close()}finally{try{a?.()}finally{e?c(e):o()}}}};async function C(){if(!(u||d)){d=!0,x();try{let e=m;e!==null&&await new Promise(t=>e.stopContinuousRecognitionAsync(()=>t(),()=>t()))}finally{S(null)}}}let w=()=>[..._,g].filter(e=>e!==``).join(` `).trim(),O=(e,t)=>{h||(h=!0,clearTimeout(v)),clearTimeout(y),y=setTimeout(C,E),r?.(w(),t)};async function k(){if(n?.addEventListener(`abort`,C),!s){S(new t(`Unavailable`,{message:`Dictation is not available in this browser.`}));return}let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){S(A(e));return}for(let e of r.getTracks())e.stop();if(!u)try{let n=await p(),r=await f();if(u)return;let a=n.SpeechConfig.fromAuthorizationToken(r.token,r.region);a.speechRecognitionLanguage=e.language||i(),a.setProperty(n.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,String(T));let o=new n.SpeechRecognizer(a,n.AudioConfig.fromDefaultMicrophoneInput());if(m=o,o.recognizing=(e,t)=>{if(u)return;let n=t.result?.text;n&&(g=n,O(n,!1))},o.recognized=(e,r)=>{if(u)return;let{reason:i,text:a}=r.result;i===n.ResultReason.RecognizedSpeech&&a?(_.push(a),g=``,O(a,!0)):i===n.ResultReason.NoMatch&&n.NoMatchDetails.fromResult(r.result).reason===n.NoMatchReason.InitialSilenceTimeout&&S(new t(`NoSpeech`,{message:`No speech was heard.`}))},o.canceled=(e,r)=>{u||(r.reason===n.CancellationReason.Error?S(new t(`Failed`,{message:r.errorDetails})):S(null))},o.sessionStopped=()=>S(null),await new Promise((e,t)=>o.startContinuousRecognitionAsync(()=>e(),t)),u)return;e.onStarted?.(),v=setTimeout(()=>{h||S(new t(`NoSpeech`,{message:`No speech was heard.`}))},T),b=setTimeout(C,D)}catch(e){S(j(e))}}return k(),l}async function h(e,n={}){let{signal:r}=n;if(!r?.aborted)try{let a=await p(),o=await f();if(r?.aborted)return;let s=a.SpeechConfig.fromAuthorizationToken(o.token,o.region);s.speechSynthesisLanguage=n.language||i();let c=new a.SpeakerAudioDestination,l=new a.SpeechSynthesizer(s,a.AudioConfig.fromSpeakerOutput(c));await new Promise((n,i)=>{let o=!1,s=()=>{r?.removeEventListener(`abort`,f),l.close(),c.close()},u=()=>{o||(o=!0,s(),n())},d=e=>{o||(o=!0,s(),i(j(e)))};function f(){c.pause(),u()}r?.addEventListener(`abort`,f),c.onAudioEnd=u;try{l.speakTextAsync(e,e=>{e.reason!==a.ResultReason.SynthesizingAudioCompleted&&d(new t(`Failed`,{message:`The reply could not be synthesised.`}))},e=>d(e))}catch(e){d(e)}})}catch(e){throw j(e)}}return{dictation:s,readAloud:c,streamsText:!0,startDictation:m,speak:h}}var B=6e4,V=60*B,H=48*V;function U(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function W(e,t=Date.now(),n){let r=U(e);if(r===null)return``;let i=t-r,a=Math.abs(i),o=i>=0,s=new Intl.RelativeTimeFormat(n,{numeric:`auto`});if(a<B)return s.format(0,`second`);if(a<V){let e=Math.floor(a/B);return s.format(o?-e:e,`minute`)}if(a<H){let e=Math.floor(a/V);return s.format(o?-e:e,`hour`)}return new Intl.DateTimeFormat(n,{day:`numeric`,month:`short`,year:`numeric`}).format(new Date(r))}function te(e,t){let n=U(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}var G=`data-wchat-printing`,K=`data-wchat-print-hide`,ne=`data-wchat-print-path`,re=`data-wchat-print-target`,ie=/* @__PURE__ */ new Set([`script`,`style`,`link`,`template`]),q=null;function J(){if(q!==null){for(let e of q.marked)e.removeAttribute(K),e.removeAttribute(ne),e.removeAttribute(re);q.heading.remove(),document.documentElement.removeAttribute(G),window.removeEventListener(`afterprint`,q.onAfterPrint),q=null}}function ae(e,t,n,r,i){J();let a=e.querySelector(`.wui-chat-panel`);if(a===null)throw Error(`print needs the wui-chat root`);let o=[],s=a;for(;s!==null&&s!==document.documentElement;){s.setAttribute(ne,``),o.push(s);let e=s.parentElement;if(e===null)throw Error(`print walk left the chat root`);for(let t of e.children)t===s||ie.has(t.localName)||(t.setAttribute(K,``),o.push(t));s=e}for(let e of n)e.setAttribute(K,``),o.push(e);r!==null&&(r.setAttribute(re,``),o.push(r));let c=document.createElement(`div`);c.className=`wui-chat-print-heading`;let l=document.createElement(`h1`);l.textContent=i.title;let u=document.createElement(`p`);u.textContent=i.printedOn,c.append(l,u),a.prepend(c),document.documentElement.setAttribute(G,t);let d=()=>J();window.addEventListener(`afterprint`,d,{once:!0}),q={marked:o,heading:c,onAfterPrint:d};try{window.print()}catch(e){throw J(),e}}function oe(e,t){ae(e,`conversation`,[],null,t)}function se(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);ae(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function ce(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function le({title:e,text:t}){if(!ce())return`failed`;try{return await navigator.share({title:e,text:t}),`shared`}catch(e){return typeof e==`object`&&e&&`name`in e&&e.name===`AbortError`?`cancelled`:`failed`}}var ue=`wchat:auto-opened`,de=`wchat:dismissed`,fe=`button, a[href], input, select, textarea`,pe=`input, textarea`;function Y(e){return!e.closest(`.wui-chat`)}function me(e){return e instanceof Element&&e.matches(pe)&&Y(e)}function he(){return[...document.querySelectorAll(pe)].some(e=>Y(e)&&e.value!==e.defaultValue)}function ge(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function _e(e){return e?[...document.querySelectorAll(fe)].some(t=>{if(!Y(t))return!1;let n=t.getBoundingClientRect();return n.width===0||n.height===0?!1:n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top}):!1}function ve(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(ue)||e.rememberDismissal&&sessionStorage.getItem(de)||window.innerWidth<e.skipBelowWidthPx)return!0;let r=window.location.pathname;if(e.skipPathPrefixes.some(e=>r.startsWith(e)))return!0;let i=t.avoid.autoOpenOptOutSelector;return i&&document.querySelector(i)||e.skipWhenFormTouched&&he()||n.isOpen()?!0:e.skipWhenCoversControl&&_e(n.panelRect())}function ye(e){return me(document.activeElement)||ge(e.avoid.menuSelectors)||ge(e.avoid.autoOpenBusySelectors)}function be(e,t,n){let r;function i(){r=void 0,ve(e,t,n)||(ye(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(ue,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=void 0}}}var xe=.4,Se=20;function X(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Ce(e){let t=e.match(/[\d.]+/g);if(!t||t.length<3)return null;let[n=0,r=0,i=0]=t.slice(0,3).map(Number);return{r:n,g:r,b:i,alpha:t.length>3?Number(t[3])/(e.includes(`%`)?100:1):1}}function we({r:e,g:t,b:n}){return .2126*X(e)+.7152*X(t)+.0722*X(n)}function Te(e,t){let n=e.getBoundingClientRect(),r=document.elementsFromPoint?.(n.left+n.width/2,n.top+n.height/2)??[],i=t.length?t.join(`,`):null;for(let t of r){if(e.contains(t))continue;if(i&&t.closest(i))return!0;let n=Ce(getComputedStyle(t).backgroundColor);if(n&&n.alpha>0)return we(n)<xe}return!1}function Ee(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function De(e){let t=0;for(let n of e){let e=n.getBoundingClientRect();e.height!==0&&(t=Math.max(t,window.innerHeight-e.top))}return t>0?t+Se:0}function Oe(e){if(e.length===0)return!1;for(let t of document.querySelectorAll(e.join(`,`))){let e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return!0}return!1}function ke(e,t,n){let r=n.ownerDocument.documentElement,i=0,a=!1,o=null;function s(){i=0;let s=t.liftAboveFooter?Ee(e.liftSelectors):[];if(o)for(let e of s)o.observe(e);n.style.setProperty(`--wui-chat-lift`,`${De(s)}px`);let c=n.getBoundingClientRect(),l=c.height===0?0:Math.round(window.innerHeight-c.top);r.style.setProperty(`--wui-chat-launcher-block`,`${l}px`);let u=t.stepAsideForMenus&&Oe(e.menuSelectors);u&&!a?(n.dataset.launcher=`hidden`,n.inert=!0,a=!0):!u&&a&&(n.dataset.launcher=`idle`,n.inert=!1,a=!1);let d=t.switchOnDark&&Te(n,e.darkSelectors);d&&n.dataset.onDark===void 0&&(n.dataset.onDark=``),!d&&n.dataset.onDark!==void 0&&delete n.dataset.onDark}function c(){i||=requestAnimationFrame(s)}typeof ResizeObserver==`function`&&(o=new ResizeObserver(c));let l=new MutationObserver(c);return l.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`open`,`data-menu-open`]}),document.addEventListener(`scroll`,c,{capture:!0,passive:!0}),window.addEventListener(`resize`,c),window.addEventListener(`load`,c),n.addEventListener(`animationend`,c),c(),{destroy(){i&&cancelAnimationFrame(i),i=0,o?.disconnect(),l.disconnect(),document.removeEventListener(`scroll`,c,{capture:!0}),window.removeEventListener(`resize`,c),window.removeEventListener(`load`,c),n.removeEventListener(`animationend`,c),a&&=(n.inert=!1,!1),delete n.dataset.onDark,n.style.removeProperty(`--wui-chat-lift`),r.style.removeProperty(`--wui-chat-launcher-block`)}}}var Z=`wchat:session-start`,Ae=`wchat:pages`,je=`wchat:services`;function Me(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function Ne(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function Pe(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function Fe(e){sessionStorage.getItem(Z)||sessionStorage.setItem(Z,String(Date.now()));let t=0;function n(){let e=document.documentElement.scrollHeight;if(e<=0)return;let n=(window.scrollY+window.innerHeight)/e*100;n>t&&(t=n)}return window.addEventListener(`scroll`,n,{passive:!0}),function(){n();let r=window.location.pathname,i=Me(Ae);i.includes(r)||(i.push(r),Ne(Ae,i));let a=Pe(r,e),o=Me(je);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),Ne(je,o)),{timeOnSiteSeconds:Math.floor((Date.now()-Number(sessionStorage.getItem(Z)))/1e3),scrollPercent:Math.min(100,Math.floor(t)),pagesViewed:i.length,viewedServices:o}}}var Q=8,Ie=`(min-width: 992px)`,Le=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,Re=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],ze=0;function Be(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Ve(e){let{trigger:t,request:i,isEmpty:a,renderAnswer:o,renderFooter:s,session:c,timings:l,onStateChange:u,returnFocusTo:d}=e??{};if(!(t instanceof HTMLElement))throw TypeError(`createExplainPopover needs a "trigger" element.`);if(typeof i!=`function`)throw TypeError(`createExplainPopover needs a "request" function.`);if(typeof o!=`function`)throw TypeError(`createExplainPopover needs a "renderAnswer" function.`);ze+=1;let f=e.title??``,m=e.showNotCounted??!0,h=`wui-chat-explain-${ze}`,v=()=>r(e.labels??{}),y=()=>({labels:v(),close:H}),b=n({request:i,...a===void 0?{}:{isEmpty:a},...l}),x=Object.fromEntries(Re.map(e=>[e,t.getAttribute(e)])),S=t.hidden,C;t.setAttribute(`aria-haspopup`,`dialog`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,h);let w=null,T=null,E=null,D,O=null,k=[],A=[],j=()=>c?.getState().features.Explain===!1;function M(){b.getSnapshot().offline?(C===void 0&&(C=t.getAttribute(`title`)),t.setAttribute(`title`,v().explainOffline),t.setAttribute(`aria-disabled`,`true`),t.setAttribute(`data-offline`,``)):(C!==void 0&&Be(t,`title`,C),C=void 0,t.removeAttribute(`aria-disabled`),t.removeAttribute(`data-offline`)),c&&(t.hidden=j())}function N(e){if(T?.replaceChildren(),e.pillVisible){let t=p(`span`,`wui-chat-explain-pill`),n=p(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),r=p(`span`);r.textContent=e.state===`slow`?v().explainSlow:v().thinking,t.append(n,r);let i=p(`div`,`wui-chat-explain-thinking`,{role:`status`});i.append(t),T?.append(i)}else if(e.state===`answered`){e.answer!==D&&(E=o(e.answer,y())??null,D=e.answer);let t=p(`div`,`wui-chat-explain-answer`);E&&t.append(E),T?.append(t)}else if(e.state===`empty`){let e=p(`p`,`wui-chat-explain-text`);e.textContent=v().explainEmpty,T?.append(e)}else if(e.state===`capacity`){let t=p(`div`,`wui-chat-explain-alert wui-chat-explain-alert--warning`,{role:`status`}),n=p(`p`);n.textContent=e.resetsDateTimeUtc?v().explainCapacity(te(e.resetsDateTimeUtc)):v().explainCapacityNoDate,t.append(n),T?.append(t)}else if(e.state===`error`){let e=p(`div`,`wui-chat-explain-alert wui-chat-explain-alert--error`,{role:`alert`}),t=p(`p`);t.textContent=v().explainError,e.append(t,g(`ghost`,v().retry,`rotate-ccw`,()=>b.ask())),T?.append(e)}}function P(){let e=w?.querySelector(`.wui-chat-explain-foot`);e?.replaceChildren();let t=s?.(y());if(t&&e?.append(t),m){let t=p(`p`,`wui-chat-explain-note`);t.textContent=v().explainNotCounted,e?.append(t)}}function F(){if(!w)return;let e=b.getSnapshot();w.dataset.state=e.state,N(e),P(),u?.(e)}function I(){if(!w)return;if(!t.isConnected){H({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wchat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Ie)?.matches===!0){w.dataset.beside=e,w.style.left=``,w.style.top=``,w.style.maxHeight=``;return}delete w.dataset.beside,w.style.position=`fixed`;let n=t.getBoundingClientRect(),r=w.offsetWidth,i=w.offsetHeight,a=globalThis.innerHeight-n.bottom-Q,o=a<i&&n.top>a,s=o?n.top-Q:a,c=o?Math.max(Q,n.top-i-Q):n.bottom+Q,l=Math.max(Q,Math.min(n.left,globalThis.innerWidth-r-Q));w.style.top=`${c}px`,w.style.left=`${l}px`,w.style.maxHeight=s<i?`${Math.max(0,s)}px`:``}function L(e){e.key===`Escape`&&(document.documentElement.hasAttribute(`data-wchat-docked`)||(e.stopPropagation(),H()))}function R(e){let n=e.target;n instanceof Node&&(w?.contains(n)||t.contains(n))||n instanceof Element&&n.closest(`.wui-chat-panel`)||H({restoreFocus:!1})}function ee(e){e.target instanceof Node&&w?.contains(e.target)||I()}function z(){b.getSnapshot().offline||U()}function B(){for(let[e,t,n,r]of k)e.removeEventListener(t,n,r);k=[];for(let e of A)e.disconnect();A=[]}function V(){if(w||j()||b.getSnapshot().offline)return;w=p(`div`,`wui-chat-explain`,{role:`dialog`,"aria-label":f,popover:`manual`,id:h});let e=p(`header`,`wui-chat-explain-head`),n=p(`strong`,`wui-chat-explain-title`);n.textContent=f,O=_(v().close,`x`,()=>H()),O.classList.add(`wui-chat-explain-close`),e.append(n,O),T=p(`div`,`wui-chat-explain-body`,{"aria-live":`polite`}),w.append(e,T,p(`div`,`wui-chat-explain-foot`)),w.dataset.state=b.getSnapshot().state,document.body.append(w),w.showPopover?.(),t.setAttribute(`aria-expanded`,`true`),b.ask(),I(),(w.querySelector(Le)??O).focus({preventScroll:!0}),k=[[document,`keydown`,L,!0],[document,`pointerdown`,R,!0],[window,`resize`,I,!1],[document,`scroll`,ee,!0]];for(let[e,t,n,r]of k)e.addEventListener(t,n,r);if(typeof ResizeObserver==`function`){let e=new ResizeObserver(()=>I());e.observe(w),A.push(e)}let r=new MutationObserver(()=>I());r.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-wchat-docked`]}),A.push(r)}function H(e={restoreFocus:!0}){w&&(b.reset(),B(),w.remove(),w=null,T=null,E=null,D=void 0,O=null,t.setAttribute(`aria-expanded`,`false`),M(),e?.restoreFocus!==!1&&(d?.()??t).focus({preventScroll:!0}))}function U(){w?H():V()}let W=b.subscribe(()=>{M(),b.getSnapshot().offline&&w?H():F()}),G=c?.subscribe(()=>{M(),j()&&w&&H({restoreFocus:!1})});return t.addEventListener(`click`,z),M(),{open:V,close:H,toggle:U,isOpen:()=>w!==null,destroy(){H({restoreFocus:!1}),W(),G?.(),b.dispose(),t.removeEventListener(`click`,z);for(let e of Re)Be(t,e,x[e]);t.hidden=S}}}var He=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Ue(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(He)].filter(e=>e.tabIndex>=0&&!e.hidden),r=n[0],i=n[n.length-1];if(!r||!i){t.preventDefault();return}let a=e.ownerDocument.activeElement,o=e.contains(a);t.shiftKey?o&&a!==r||(t.preventDefault(),i.focus()):o&&a!==i||(t.preventDefault(),r.focus())}function We(e){e?.isConnected&&e.focus()}function Ge(e,t){if(t||typeof navigator>`u`)return;let n=navigator;typeof n.vibrate==`function`&&n.vibrate(e)}var Ke=`wui-chat-lock`,qe=`wui-chat-scroll-lock`;function Je(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(Ke);e.setAttribute(`data-lenis-prevent`,``),e.style.overscrollBehavior=`contain`,window.dispatchEvent(new CustomEvent(qe,{detail:{locked:!0}}));let i=!0;return function(){if(i){i=!1;for(let e of n)e.classList.remove(Ke);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(qe,{detail:{locked:!1}}))}}}var Ye={open:{from:420,to:920,seconds:.16,peak:.16},reply:{from:680,to:540,seconds:.11,peak:.06},sent:{from:540,to:760,seconds:.09,peak:.05}},Xe=[`pointerdown`,`keydown`,`touchstart`],Ze=`wchat:muted`,Qe=1e-4;function $e(e,t){let n=t.get(Ze)===`1`,r=null;function i(){for(let e of Xe)document.removeEventListener(e,a)}function a(){let e=globalThis.AudioContext||globalThis.webkitAudioContext;!r&&e&&(r=new e),r?.state===`suspended`&&r.resume().catch(e=>globalThis.reportError?.(e)),i()}for(let e of Xe)document.addEventListener(e,a);return{play(t){let i=Ye[t];if(!i||n||!r||!e[t]||!(e.volume>0))return;let a=r.currentTime,o=r.createOscillator(),s=r.createGain();o.type=`sine`,o.frequency.setValueAtTime(i.from,a),o.frequency.linearRampToValueAtTime(i.to,a+i.seconds),s.gain.setValueAtTime(i.peak*e.volume,a),s.gain.exponentialRampToValueAtTime(Qe,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(Ze,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close().catch(e=>globalThis.reportError?.(e)),r=null}}}function et(e,t={}){let n=t.language;return z({getToken:()=>e.getSpeechToken(),getLanguage:n?()=>n:void 0})}var tt=2e3,nt=500,rt=32,$=16,it=`data-wchat-switching`;function at(e){return new Promise(t=>setTimeout(t,e))}function ot(e,t){return typeof e!=`function`||e()?Promise.resolve():new Promise(n=>{let r=0,i=()=>{e()||r>=t?n():(r+=$,setTimeout(i,$))};setTimeout(i,$)})}async function st(e,t={}){let n=t.reduced??globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;if(typeof document.startViewTransition!=`function`||n){await e();return}let r=document.documentElement;r.setAttribute(it,``);try{let n=()=>!t.target||document.querySelector(`.wui-chat--${t.target}`)!==null,r=()=>(typeof t.pageReady!=`function`||t.pageReady())&&n(),i=document.startViewTransition(async()=>{await e(),await ot(t.routeReady,tt),await ot(r,nt),await at(rt)});Promise.allSettled([i.ready]);try{await i.updateCallbackDone}finally{await Promise.allSettled([i.finished])}}finally{r.removeAttribute(it)}}var ct=100,lt=12,ut=220,dt=640;function ft(e,t){let n=t.phone.mode===`Sheet`,r=window.visualViewport,i;function a(){e.style.removeProperty(`bottom`),e.style.removeProperty(`max-height`)}function o(){if(i=void 0,window.innerWidth>t.phone.maxWidthPx){a();return}if(!r)return;let o=Math.max(0,window.innerHeight-r.height-r.offsetTop),s=r.height-lt;n&&(s=Math.min(dt,Math.max(ut,s))),e.style.bottom=`${o}px`,e.style.maxHeight=`${s}px`}function s(){clearTimeout(i),i=setTimeout(o,ct)}return r?.addEventListener(`resize`,s),r?.addEventListener(`scroll`,s),window.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),o(),{destroy(){clearTimeout(i),r?.removeEventListener(`resize`,s),r?.removeEventListener(`scroll`,s),window.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s),a()}}}export{m as A,A as C,p as D,w as E,o as F,g as M,c as N,f as O,l as P,z as S,h as T,oe as _,$e as a,W as b,We as c,Fe as d,ke as f,J as g,le as h,et as i,v as j,_ as k,Ue as l,ce as m,ft as n,Je as o,be as p,st as r,Ge as s,e as t,Ve as u,se as v,x as w,t as x,te as y};
|