@webority/chat-elements 0.133.0 → 0.135.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 +8 -0
- package/dist/types/global.d.ts +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/renderers/cell-format.d.ts +1 -1
- package/dist/types/voice/composer-voice.d.ts +1 -0
- package/dist/types/voice/read-aloud-button.d.ts +5 -0
- package/dist/types/web/index.d.ts +1 -1
- package/dist/types/web/motion.d.ts +1 -0
- package/dist/web-Dkz2jgyc.js +1 -0
- package/dist/web.js +1 -1
- package/package.json +8 -8
- package/dist/types/renderers/audio-type.d.ts +0 -1
- package/dist/web-DeRQru_E.js +0 -1
package/dist/types/WuiChat.d.ts
CHANGED
|
@@ -121,6 +121,7 @@ export declare class WuiChat extends Base {
|
|
|
121
121
|
};
|
|
122
122
|
unlock: () => void;
|
|
123
123
|
} | null;
|
|
124
|
+
_requesting: boolean;
|
|
124
125
|
_onKeyDown: (event: any) => void;
|
|
125
126
|
_onNavigateProp: any;
|
|
126
127
|
_header: {
|
|
@@ -167,6 +168,11 @@ export declare class WuiChat extends Base {
|
|
|
167
168
|
} | undefined;
|
|
168
169
|
_status: any;
|
|
169
170
|
_errorEl: any;
|
|
171
|
+
_liveStatus: any;
|
|
172
|
+
_talk: any;
|
|
173
|
+
_liveRetry: any;
|
|
174
|
+
_liveError: any;
|
|
175
|
+
_live: any;
|
|
170
176
|
_body: any;
|
|
171
177
|
_foot: any;
|
|
172
178
|
_launcherPlayed: boolean | undefined;
|
|
@@ -245,6 +251,8 @@ export declare class WuiChat extends Base {
|
|
|
245
251
|
_disposePast(): void;
|
|
246
252
|
_applyEmptyContent(): void;
|
|
247
253
|
_switchPanel(): void;
|
|
254
|
+
_requestHandoff(): Promise<void>;
|
|
255
|
+
_paintLive(state: any, labels: any, viewingHistory: any): void;
|
|
248
256
|
_resetSession(): void;
|
|
249
257
|
_toggleHistory(show?: boolean): void;
|
|
250
258
|
_makeTurnApi(messageId: any): import("@webority/chat-core").ChatTurnApi;
|
package/dist/types/global.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function isNumericType(type: any): boolean;
|
|
2
|
-
export declare function formatCell(type: any, value: any, currency: any): {
|
|
2
|
+
export declare function formatCell(type: any, value: any, currency: any, figureText?: boolean): {
|
|
3
3
|
kind: string;
|
|
4
4
|
text: any;
|
|
5
5
|
}[];
|
|
@@ -6,7 +6,7 @@ export { createExplainPopover } from "./explain.js";
|
|
|
6
6
|
export { returnFocus, trapTab } from "./focus.js";
|
|
7
7
|
export { vibrate } from "./haptics.js";
|
|
8
8
|
export { fullMoment, relativeMoment } from "./moment.js";
|
|
9
|
-
export { watchReducedMotion } from "./motion.js";
|
|
9
|
+
export { growFromButton, watchReducedMotion } from "./motion.js";
|
|
10
10
|
export { endPrint, printConversation, printReply } from "./print.js";
|
|
11
11
|
export { lockPageScroll } from "./scrolllock.js";
|
|
12
12
|
export { canShareText, shareText } from "./share.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ChatSpeechError as e,ChatSpeechError as t,createExplain as n,mergeLabels as r}from"@webority/chat-core";import{glyphSvg as i}from"@webority/ui-elements/helpers";var a=`(prefers-reduced-motion: reduce)`;function o(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 s(e,t){let n=typeof window.matchMedia==`function`?window.matchMedia(a):null,r=/* @__PURE__ */ new Set,i=()=>e.motion===`Reduced`||t?.motion===!1||n?.matches===!0,o=i();function s(){let e=i();if(e!==o){o=e;for(let e of r)e(o)}}return n?.addEventListener(`change`,s),{get reduced(){return o},subscribe(e){return r.add(e),()=>{r.delete(e)}},destroy(){n?.removeEventListener(`change`,s),r.clear()}}}var c=`AppButton`,l={primary:`btn-primary`,secondary:`btn-soft-primary`,ghost:`btn-ghost-primary`,outline:`btn-outline-primary`,neutral:`btn-soft-neutral`,danger:`btn-danger`};function u(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 d(e,t=16){let n=i(e,{size:t});if(!n)return u(`span`,`d-inline-flex`);let r=document.createElement(`template`);return r.innerHTML=n,r.content.firstElementChild??u(`span`,`d-inline-flex`)}function f(e=`primary`,t=`md`){if(!Object.hasOwn(l,e))throw Error(`Unknown button variant "${e}". Use one of ${Object.keys(l).join(`, `)}.`);return`btn ${l[e]}${t===`sm`?` btn-sm`:``}`}function p(e,t,n,r){let i=u(`button`,`${f(e,`sm`)} wui-chat-action-btn`,{type:`button`});return i.dataset.wui=c,n&&i.append(d(n,14)),i.append(document.createTextNode(t)),i.addEventListener(`click`,r),i}function m(e,t,n){let r=u(`button`,`wui-chat-icon-btn`,{type:`button`,"aria-label":e,title:e});return r.append(d(t,20)),r.addEventListener(`click`,n),r}function h(e,t){let n=e.getAttribute(t);if(n!=null&&n!==``)try{return JSON.parse(n)}catch{throw Error(`<wui-chat ${t}> must be valid JSON.`)}}function g(e){let t=null;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 _(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.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.removeProperty(`--wui-chat-avatar`)),t.replyAvatars!==void 0&&e.classList.toggle(`wui-chat--reply-avatars-off`,t.replyAvatars===!1)}var v=[`Text`,`Sources`,`QuickReplies`,`InputRequest`,`Action`,`Notice`,`Table`,`Chart`,`Figures`,`RecordCard`,`Image`,`File`,`Ticket`,`Handoff`,`VoiceClip`],y={launcher:`wui-chat--launcher`,docked:`wui-chat--docked`,"full-page":`wui-chat--full-page`,embedded:`wui-chat--embedded`};function b(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function x({id:e,layout:t,position:n,role:r,launcher:i,onToggle:a}){let s=u(`div`,`wui-chat ${y[t]} wui-chat--${n}`),c=u(`section`,`wui-chat-panel`,{id:e,role:r}),l=i?g(s):null;s.dataset.state=i?`closed`:`open`;let f=null,p=null,m=null,h=null,v=null,x=null,S=null,C=`round`,w=!1,T=`bubble`,E=null,D=null,O=!1,k=`icon`,A=!1;function j(){let e=f.dataset.launcher,t=[`wui-chat-launcher-wrap`];e===`entering`&&E&&t.push(`wui-chat-launcher--entrance-${E}`),e===`idle`&&D&&D!==`none`&&(D!==`ring`||C===`pill`)&&t.push(`wui-chat-launcher--idle-${D}`),f.className=t.join(` `)}function M(){let e=[...p.classList].filter(e=>e.endsWith(`--opening`)||e.endsWith(`--closing`)),t=[`wui-chat-launcher`,`wui-chat-launcher--${C}`];C===`pill`&&w&&t.push(`wui-chat-launcher--compact`),k===`avatar`&&t.push(`wui-chat-launcher--mark-avatar`),t.push(`wui-chat-launcher--reveal-${T}`,...e),p.className=t.join(` `)}function N(){v&&x&&(v.textContent=S||x.launcher)}function P(){if(!p||!x)return;let e=A?x.launcherClose:S||x.launcher;p.setAttribute(`aria-label`,e),h.textContent=e}if(i){f=u(`div`,`wui-chat-launcher-wrap`),f.dataset.launcher=`idle`,p=u(`button`,`wui-chat-launcher`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":e}),m=u(`span`,`wui-chat-launcher-icon`,{"aria-hidden":`true`}),m.append(d(`chat`,24));let t=u(`span`,`wui-chat-launcher-close`,{"aria-hidden":`true`});t.append(d(`x`,24)),h=u(`span`,`wui-chat-launcher-label`),p.append(m,t,h),p.addEventListener(`click`,()=>a()),p.addEventListener(`animationend`,e=>{e.target===p&&p.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`)}),v=u(`span`,`wui-chat-launcher-bubble`,{"aria-hidden":`true`}),f.append(p,v),f.addEventListener(`animationend`,e=>{e.target===f&&f.dataset.launcher===`entering`&&(f.dataset.launcher=`idle`,j())}),M(),j(),s.append(f,c)}else s.append(c);function F(e){if(!l)return;let t=e&&!A&&p!==null,n=t?p.getBoundingClientRect():null;e!==A&&p&&(p.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`),p.classList.add(e?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`)),A=e,l(e),t&&o(c,n),p&&(p.setAttribute(`aria-expanded`,String(e)),P())}function I(e){x=e,p&&(P(),N())}function L(e){if(_(s,e),e.theme!==void 0&&(e.theme===`light`||e.theme===`dark`?s.dataset.theme=e.theme:delete s.dataset.theme),!p)return;e.launcherStyle!==void 0&&(C=e.launcherStyle===`Pill`?`pill`:`round`),e.compact!==void 0&&(w=e.compact),e.labelReveal!==void 0&&(T=e.labelReveal===`Expand`?`expand`:`bubble`),e.entrance!==void 0&&(E=e.entrance===`None`?null:b(e.entrance)),e.idle!==void 0&&(D=e.idle===`None`?`none`:b(e.idle)),e.phone!==void 0&&(O=e.phone),e.hoverLabel!==void 0&&(S=e.hoverLabel||null),e.launcherMark!==void 0&&(k=e.launcherMark===`Avatar`?`avatar`:`icon`),e.icon!==void 0&&e.icon!==m.dataset.icon&&(m.dataset.icon=e.icon,m.replaceChildren(d(e.icon,24)));let t=e.launcherState??f.dataset.launcher;O&&t===`entering`&&(t=`idle`),t===`entering`&&!E&&(t=`idle`),f.dataset.launcher=t,M(),j(),N(),P()}return{root:s,panel:c,setOpen:F,setLabels:I,setAppearance:L,nudgeHost:f,launcherButton:p,role:r}}var S=1e4,C=2e3,w=3e5,T=/* @__PURE__ */ new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),E=/* @__PURE__ */ new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function D(e){return T.has(e?.name)?new t(`Blocked`,e.message):E.has(e?.name)?new t(`NoMicrophone`,e.message):O(e)}function O(e){return e instanceof t?e:new t(`Failed`,e?.message??String(e))}var k=null;function A(){return globalThis.SpeechSDK?globalThis.SpeechSDK:(k===null&&(k=import(`microsoft-cognitiveservices-speech-sdk`).then(e=>e.SpeechConfig?e:e.default).catch(e=>{throw k=null,e})),k)}function j(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function M(e){let n=e.getToken,r=e.loadSdk??A,i=e.getLanguage??j,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,O(e)})),u)}function p(){return d===null&&(d=Promise.resolve().then(()=>r()).then(e=>{if(!e?.SpeechConfig)throw new t(`Unavailable`,`Speech is not available in this browser.`);return e}).catch(e=>{throw d=null,O(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=null,y=null,b=null,x=()=>{clearTimeout(v),clearTimeout(y),clearTimeout(b)},T=e=>{if(!u){u=!0,x(),n?.removeEventListener(`abort`,E);try{m?.close()}finally{try{a?.()}finally{e?c(e):o()}}}};async function E(){if(!(u||d)){if(d=!0,x(),m!==null)try{await new Promise(e=>m.stopContinuousRecognitionAsync(e,e))}catch{}T(null)}}let k=()=>[..._,g].filter(e=>e!==``).join(` `).trim(),A=(e,t)=>{h||(h=!0,clearTimeout(v)),clearTimeout(y),y=setTimeout(E,C),r?.(k(),t)};async function j(){if(n?.addEventListener(`abort`,E),!s){T(new t(`Unavailable`,`Dictation is not available in this browser.`));return}let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){T(D(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);if(a.speechRecognitionLanguage=e.language||i(),a.setProperty(n.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,String(S)),m=new n.SpeechRecognizer(a,n.AudioConfig.fromDefaultMicrophoneInput()),m.recognizing=(e,t)=>{if(u)return;let n=t.result?.text;n&&(g=n,A(n,!1))},m.recognized=(e,r)=>{if(u)return;let{reason:i,text:a}=r.result;i===n.ResultReason.RecognizedSpeech&&a?(_.push(a),g=``,A(a,!0)):i===n.ResultReason.NoMatch&&n.NoMatchDetails.fromResult(r.result).reason===n.NoMatchReason.InitialSilenceTimeout&&T(new t(`NoSpeech`,`No speech was heard.`))},m.canceled=(e,r)=>{u||(r.reason===n.CancellationReason.Error?T(new t(`Failed`,r.errorDetails)):T(null))},m.sessionStopped=()=>T(null),await new Promise((e,t)=>m.startContinuousRecognitionAsync(e,t)),u)return;e.onStarted?.(),v=setTimeout(()=>{h||T(new t(`NoSpeech`,`No speech was heard.`))},S),b=setTimeout(E,w)}catch(e){T(O(e))}}return j(),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(O(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`,`The reply could not be synthesised.`))},e=>d(e))}catch(e){d(e)}})}catch(e){throw O(e)}}return{dictation:s,readAloud:c,streamsText:!0,startDictation:m,speak:h}}var N=6e4,P=60*N,F=48*P;function I(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function L(e,t=Date.now(),n=void 0){let r=I(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<N)return s.format(0,`second`);if(a<P){let e=Math.floor(a/N);return s.format(o?-e:e,`minute`)}if(a<F){let e=Math.floor(a/P);return s.format(o?-e:e,`hour`)}return new Intl.DateTimeFormat(n,{day:`numeric`,month:`short`,year:`numeric`}).format(new Date(r))}function R(e,t=void 0){let n=I(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}var z=`data-wui-printing`,B=`data-wui-print-hide`,V=`data-wui-print-path`,H=`data-wui-print-target`,U=/* @__PURE__ */ new Set([`script`,`style`,`link`,`template`]),W=null;function G(){if(W!==null){for(let e of W.marked)e.removeAttribute(B),e.removeAttribute(V),e.removeAttribute(H);W.heading.remove(),document.documentElement.removeAttribute(z),window.removeEventListener(`afterprint`,W.onAfterPrint),W=null}}function K(e,t,n,r,i){G();let a=e.querySelector(`.wui-chat-panel`);if(a===null)throw Error(`print needs the wui-chat root`);let o=[];for(let e=a;e!==document.documentElement;e=e.parentElement){e.setAttribute(V,``),o.push(e);for(let t of e.parentElement.children)t===e||U.has(t.localName)||(t.setAttribute(B,``),o.push(t))}for(let e of n)e.setAttribute(B,``),o.push(e);r!==null&&(r.setAttribute(H,``),o.push(r));let s=document.createElement(`div`);s.className=`wui-chat-print-heading`;let c=document.createElement(`h1`);c.textContent=i.title;let l=document.createElement(`p`);l.textContent=i.printedOn,s.append(c,l),a.prepend(s),document.documentElement.setAttribute(z,t);let u=()=>G();window.addEventListener(`afterprint`,u,{once:!0}),W={marked:o,heading:s,onAfterPrint:u};try{window.print()}catch(e){throw G(),e}}function q(e,t){K(e,`conversation`,[],null,t)}function ee(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);K(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function J(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function te({title:e,text:t}){if(!J())return`failed`;try{return await navigator.share({title:e,text:t}),`shared`}catch(e){return e?.name===`AbortError`?`cancelled`:`failed`}}var ne=`wchat:auto-opened`,re=`wchat:dismissed`,ie=`button, a[href], input, select, textarea`,ae=`input, textarea`;function Y(e){return!e.closest(`.wui-chat`)}function oe(e){return e instanceof Element&&e.matches(ae)&&Y(e)}function se(){return[...document.querySelectorAll(ae)].some(e=>Y(e)&&e.value!==e.defaultValue)}function ce(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function le(e){return e?[...document.querySelectorAll(ie)].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 ue(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(ne)||e.rememberDismissal&&sessionStorage.getItem(re)||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&&se()||n.isOpen()?!0:e.skipWhenCoversControl&&le(n.panelRect())}function de(e){return oe(document.activeElement)||ce(e.avoid.menuSelectors)||ce(e.avoid.autoOpenBusySelectors)}function fe(e,t,n){let r=0;function i(){r=0,ue(e,t,n)||(de(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(ne,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=0}}}var pe=.4,me=20;function X(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function he(e){let t=e.match(/[\d.]+/g);if(!t||t.length<3)return null;let[n,r,i]=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 ge({r:e,g:t,b:n}){return .2126*X(e)+.7152*X(t)+.0722*X(n)}function _e(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=he(getComputedStyle(t).backgroundColor);if(n&&n.alpha>0)return ge(n)<pe}return!1}function ve(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function ye(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+me:0}function be(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 xe(e,t,n){let r=n.ownerDocument.documentElement,i=0,a=!1,o=null;function s(){i=0;let s=t.liftAboveFooter?ve(e.liftSelectors):[];if(o)for(let e of s)o.observe(e);n.style.setProperty(`--wui-chat-lift`,`${ye(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&&be(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&&_e(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`,Se=`wchat:pages`,Ce=`wchat:services`;function we(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function Te(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function Ee(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function De(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=we(Se);i.includes(r)||(i.push(r),Te(Se,i));let a=Ee(r,e),o=we(Ce);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),Te(Ce,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,Oe=`(min-width: 992px)`,ke=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,Ae=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],je=0;function Me(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Ne(e){let{trigger:t,request:i,isEmpty:a,renderAnswer:o,renderFooter:s,session:c,timings:l,onStateChange:d,returnFocusTo:f}=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.`);je+=1;let h=e.title??``,g=e.showNotCounted??!0,_=`wui-chat-explain-${je}`,v=()=>r(e.labels??{}),y=()=>({labels:v(),close:W}),b=n({request:i,isEmpty:a,...l}),x=Object.fromEntries(Ae.map(e=>[e,t.getAttribute(e)])),S=t.hidden,C;t.setAttribute(`aria-haspopup`,`dialog`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,_);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&&Me(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=u(`span`,`wui-chat-explain-pill`),n=u(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),r=u(`span`);r.textContent=e.state===`slow`?v().explainSlow:v().thinking,t.append(n,r);let i=u(`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=u(`div`,`wui-chat-explain-answer`);E&&t.append(E),T.append(t)}else if(e.state===`empty`){let e=u(`p`,`wui-chat-explain-text`);e.textContent=v().explainEmpty,T.append(e)}else if(e.state===`capacity`){let t=u(`div`,`wui-chat-explain-alert wui-chat-explain-alert--warning`,{role:`status`}),n=u(`p`);n.textContent=e.resetsDateTimeUtc?v().explainCapacity(R(e.resetsDateTimeUtc)):v().explainCapacityNoDate,t.append(n),T.append(t)}else if(e.state===`error`){let e=u(`div`,`wui-chat-explain-alert wui-chat-explain-alert--error`,{role:`alert`}),t=u(`p`);t.textContent=v().explainError,e.append(t,p(`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),g){let t=u(`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(),d?.(e)}function I(){if(!w)return;if(!t.isConnected){W({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wui-chat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Oe)?.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-wui-chat-docked`)||(e.stopPropagation(),W()))}function z(e){let n=e.target;w.contains(n)||t.contains(n)||n instanceof Element&&n.closest(`.wui-chat-panel`)||W({restoreFocus:!1})}function B(e){e.target instanceof Node&&w.contains(e.target)||I()}function V(){b.getSnapshot().offline||G()}function H(){for(let[e,t,n,r]of k)e.removeEventListener(t,n,r);k=[];for(let e of A)e.disconnect();A=[]}function U(){if(w||j()||b.getSnapshot().offline)return;w=u(`div`,`wui-chat-explain`,{role:`dialog`,"aria-label":h,popover:`manual`,id:_});let e=u(`header`,`wui-chat-explain-head`),n=u(`strong`,`wui-chat-explain-title`);n.textContent=h,O=m(v().close,`x`,()=>W()),O.classList.add(`wui-chat-explain-close`),e.append(n,O),T=u(`div`,`wui-chat-explain-body`,{"aria-live":`polite`}),w.append(e,T,u(`div`,`wui-chat-explain-foot`)),w.dataset.state=b.getSnapshot().state,document.body.append(w);try{w.showPopover?.()}catch{}t.setAttribute(`aria-expanded`,`true`),b.ask(),I(),(w.querySelector(ke)??O).focus({preventScroll:!0}),k=[[document,`keydown`,L,!0],[document,`pointerdown`,z,!0],[window,`resize`,I,!1],[document,`scroll`,B,!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-wui-chat-docked`]}),A.push(r)}function W(e={restoreFocus:!0}){w&&(b.reset(),H(),w.remove(),w=null,T=null,E=null,D=void 0,O=null,t.setAttribute(`aria-expanded`,`false`),M(),e?.restoreFocus!==!1&&(f?.()??t).focus({preventScroll:!0}))}function G(){w?W():U()}let K=b.subscribe(()=>{M(),b.getSnapshot().offline&&w?W():F()}),q=c?.subscribe(()=>{M(),j()&&w&&W({restoreFocus:!1})});return t.addEventListener(`click`,V),M(),{open:U,close:W,toggle:G,isOpen:()=>w!==null,destroy(){W({restoreFocus:!1}),K(),q?.(),b.dispose(),t.removeEventListener(`click`,V);for(let e of Ae)Me(t,e,x[e]);t.hidden=S}}}var Pe=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Fe(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(Pe)].filter(e=>e.tabIndex>=0&&!e.hidden);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1],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 Ie(e){e?.isConnected&&e.focus()}function Le(e,t){t||typeof navigator>`u`||typeof navigator.vibrate!=`function`||navigator.vibrate(e)}var Re=`wui-chat-lock`,ze=`wui-chat-scroll-lock`;function Be(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(Re);e.setAttribute(`data-lenis-prevent`,``),e.style.overscrollBehavior=`contain`,window.dispatchEvent(new CustomEvent(ze,{detail:{locked:!0}}));let i=!0;return function(){if(i){i=!1;for(let e of n)e.classList.remove(Re);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(ze,{detail:{locked:!1}}))}}}var Ve={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}},He=[`pointerdown`,`keydown`,`touchstart`],Ue=`wchat:muted`,We=1e-4;function Ge(e,t){let n=t.get(Ue)===`1`,r=null;function i(){for(let e of He)document.removeEventListener(e,a)}function a(){let e=globalThis.AudioContext||globalThis.webkitAudioContext;!r&&e&&(r=new e),r?.state===`suspended`&&r.resume(),i()}for(let e of He)document.addEventListener(e,a);return{play(t){let i=Ve[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(We,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(Ue,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close(),r=null}}}function Ke(e,t={}){return M({getToken:()=>e.getSpeechToken(),getLanguage:t.language?()=>t.language:void 0})}var qe=2e3,Je=500,Ye=32,$=16,Xe=`data-wui-chat-switching`;function Ze(e){return new Promise(t=>setTimeout(t,e))}function Qe(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 $e(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(Xe,``);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 Qe(t.routeReady,qe),await Qe(r,Je),await Ze(Ye)});i.ready.catch(()=>{});try{await i.updateCallbackDone}finally{await i.finished.catch(()=>{})}}finally{r.removeAttribute(Xe)}}var et=100,tt=12,nt=220,rt=640;function it(e,t){let n=t.phone.mode===`Sheet`,r=window.visualViewport,i=0;function a(){e.style.removeProperty(`bottom`),e.style.removeProperty(`max-height`)}function o(){if(i=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-tt;n&&(s=Math.min(rt,Math.max(nt,s))),e.style.bottom=`${o}px`,e.style.maxHeight=`${s}px`}function s(){clearTimeout(i),i=setTimeout(o,et)}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{h as A,D as C,u as D,x as E,o as M,s as N,m as O,M as S,f as T,q as _,Ge as a,L as b,Ie as c,De as d,xe as f,G as g,te as h,Ke as i,p as j,d as k,Fe as l,J as m,it as n,Be as o,fe as p,$e as r,Le as s,e as t,Ne as u,ee as v,v as w,t as x,R as y};
|
package/dist/web.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as ChatSpeechError,
|
|
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,M 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,l as trapTab,s as vibrate,p as watchAutoOpen,N as watchReducedMotion}from"./web-Dkz2jgyc.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/chat-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.135.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",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"./src/renderers/*.js"
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@webority/chat-core": "0.
|
|
41
|
-
"@webority/markdown-core": "^0.
|
|
42
|
-
"@webority/theme": "^0.
|
|
43
|
-
"@webority/ui-elements": "^0.
|
|
40
|
+
"@webority/chat-core": "0.135.0",
|
|
41
|
+
"@webority/markdown-core": "^0.131.0",
|
|
42
|
+
"@webority/theme": "^0.131.0",
|
|
43
|
+
"@webority/ui-elements": "^0.131.0",
|
|
44
44
|
"microsoft-cognitiveservices-speech-sdk": "^1.53.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@webority/chat-core": "0.
|
|
53
|
-
"@webority/theme": "0.
|
|
54
|
-
"@webority/ui-elements": "0.
|
|
52
|
+
"@webority/chat-core": "0.135.0",
|
|
53
|
+
"@webority/theme": "0.131.0",
|
|
54
|
+
"@webority/ui-elements": "0.131.0",
|
|
55
55
|
"@vitest/coverage-v8": "5.0.1",
|
|
56
56
|
"bootstrap": "5.3.3",
|
|
57
57
|
"jsdom": "30.1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function sniffAudioType(buffer: any): "application/octet-stream" | "audio/mp4" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm";
|
package/dist/web-DeRQru_E.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ChatSpeechError as e,ChatSpeechError as t,createExplain as n,mergeLabels as r}from"@webority/chat-core";import{glyphSvg as i}from"@webority/ui-elements/helpers";var a=`AppButton`,o={primary:`btn-primary`,secondary:`btn-soft-primary`,ghost:`btn-ghost-primary`,outline:`btn-outline-primary`,neutral:`btn-soft-neutral`,danger:`btn-danger`};function s(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 c(e,t=16){let n=i(e,{size:t});return n?document.importNode(new DOMParser().parseFromString(n,`image/svg+xml`).documentElement,!0):s(`span`,`d-inline-flex`)}function l(e=`primary`,t=`md`){if(!Object.hasOwn(o,e))throw Error(`Unknown button variant "${e}". Use one of ${Object.keys(o).join(`, `)}.`);return`btn ${o[e]}${t===`sm`?` btn-sm`:``}`}function u(e,t,n,r){let i=s(`button`,`${l(e,`sm`)} wui-chat-action-btn`,{type:`button`});return i.dataset.wui=a,n&&i.append(c(n,14)),i.append(document.createTextNode(t)),i.addEventListener(`click`,r),i}function d(e,t,n){let r=s(`button`,`wui-chat-icon-btn`,{type:`button`,"aria-label":e,title:e});return r.append(c(t,20)),r.addEventListener(`click`,n),r}function f(e,t){let n=e.getAttribute(t);if(n!=null&&n!==``)try{return JSON.parse(n)}catch{throw Error(`<wui-chat ${t}> must be valid JSON.`)}}function p(e){let t=null;return n=>{let r=e.dataset.state;(!n||r!==`open`&&r!==`opening`)&&(n||r!==`closed`&&r!==`closing`)&&(clearTimeout(t),n?(e.dataset.state=`opening`,t=setTimeout(()=>{e.dataset.state=`open`},620)):(e.dataset.state=`closing`,t=setTimeout(()=>{e.dataset.state=`closed`},300)))}}function m(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.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`)}var h=[`Text`,`Sources`,`QuickReplies`,`InputRequest`,`Action`,`Notice`,`Table`,`Chart`,`Figures`,`RecordCard`,`Image`,`File`,`Ticket`,`Handoff`,`VoiceClip`],g={launcher:`wui-chat--launcher`,docked:`wui-chat--docked`,"full-page":`wui-chat--full-page`,embedded:`wui-chat--embedded`};function _(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function v({id:e,layout:t,position:n,role:r,launcher:i,onToggle:a}){let o=s(`div`,`wui-chat ${g[t]} wui-chat--${n}`),l=s(`section`,`wui-chat-panel`,{id:e,role:r}),u=i?p(o):null;o.dataset.state=i?`closed`:`open`;let d=null,f=null,h=null,v=null,y=null,b=null,x=null,S=`round`,C=!1,w=`bubble`,T=null,E=null,D=!1,O=!1;function k(){let e=d.dataset.launcher,t=[`wui-chat-launcher-wrap`];e===`entering`&&T&&t.push(`wui-chat-launcher--entrance-${T}`),e===`idle`&&E&&E!==`none`&&(E!==`ring`||S===`pill`)&&t.push(`wui-chat-launcher--idle-${E}`),d.className=t.join(` `)}function A(){let e=[...f.classList].filter(e=>e.endsWith(`--opening`)||e.endsWith(`--closing`)),t=[`wui-chat-launcher`,`wui-chat-launcher--${S}`];S===`pill`&&C&&t.push(`wui-chat-launcher--compact`),t.push(`wui-chat-launcher--reveal-${w}`,...e),f.className=t.join(` `)}function j(){y&&b&&(y.textContent=x||b.launcher)}if(i){d=s(`div`,`wui-chat-launcher-wrap`),d.dataset.launcher=`idle`,f=s(`button`,`wui-chat-launcher`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":e}),h=s(`span`,`wui-chat-launcher-icon`,{"aria-hidden":`true`}),h.append(c(`chat`,24));let t=s(`span`,`wui-chat-launcher-close`,{"aria-hidden":`true`});t.append(c(`x`,24)),v=s(`span`,`wui-chat-launcher-label`),f.append(h,t,v),f.addEventListener(`click`,()=>a()),f.addEventListener(`animationend`,e=>{e.target===f&&f.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`)}),y=s(`span`,`wui-chat-launcher-bubble`,{"aria-hidden":`true`}),d.append(f,y),d.addEventListener(`animationend`,e=>{e.target===d&&d.dataset.launcher===`entering`&&(d.dataset.launcher=`idle`,k())}),A(),k(),o.append(d,l)}else o.append(l);function M(e){if(u){if(e&&!O&&f){let e=f.getBoundingClientRect(),t=l.getBoundingClientRect();l.style.transformOrigin=`${e.left+e.width/2-t.left}px ${e.top+e.height/2-t.top}px`}e!==O&&f&&(f.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`),f.classList.add(e?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`)),O=e,u(e),f&&(f.setAttribute(`aria-expanded`,String(e)),b&&f.setAttribute(`aria-label`,e?b.launcherClose:b.launcher))}}function N(e){b=e,f&&(f.setAttribute(`aria-label`,O?e.launcherClose:e.launcher),v.textContent=e.launcher,j())}function P(e){if(m(o,e),e.theme!==void 0&&(e.theme===`light`||e.theme===`dark`?o.dataset.theme=e.theme:delete o.dataset.theme),!f)return;e.launcherStyle!==void 0&&(S=e.launcherStyle===`Pill`?`pill`:`round`),e.compact!==void 0&&(C=e.compact),e.labelReveal!==void 0&&(w=e.labelReveal===`Expand`?`expand`:`bubble`),e.entrance!==void 0&&(T=e.entrance===`None`?null:_(e.entrance)),e.idle!==void 0&&(E=e.idle===`None`?`none`:_(e.idle)),e.phone!==void 0&&(D=e.phone),e.hoverLabel!==void 0&&(x=e.hoverLabel||null),e.icon!==void 0&&e.icon!==h.dataset.icon&&(h.dataset.icon=e.icon,h.replaceChildren(c(e.icon,24)));let t=e.launcherState??d.dataset.launcher;D&&t===`entering`&&(t=`idle`),t===`entering`&&!T&&(t=`idle`),d.dataset.launcher=t,A(),k(),j()}return{root:o,panel:l,setOpen:M,setLabels:N,setAppearance:P,nudgeHost:d,launcherButton:f,role:r}}var y=1e4,b=2e3,x=3e5,S=/* @__PURE__ */ new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),C=/* @__PURE__ */ new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function w(e){return S.has(e?.name)?new t(`Blocked`,e.message):C.has(e?.name)?new t(`NoMicrophone`,e.message):T(e)}function T(e){return e instanceof t?e:new t(`Failed`,e?.message??String(e))}var E=null;function D(){return globalThis.SpeechSDK?globalThis.SpeechSDK:(E===null&&(E=import(`microsoft-cognitiveservices-speech-sdk`).then(e=>e.SpeechConfig?e:e.default).catch(e=>{throw E=null,e})),E)}function O(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function k(e){let n=e.getToken,r=e.loadSdk??D,i=e.getLanguage??O,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,T(e)})),u)}function p(){return d===null&&(d=Promise.resolve().then(()=>r()).then(e=>{if(!e?.SpeechConfig)throw new t(`Unavailable`,`Speech is not available in this browser.`);return e}).catch(e=>{throw d=null,T(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=null,S=null,C=null,E=()=>{clearTimeout(v),clearTimeout(S),clearTimeout(C)},D=e=>{if(!u){u=!0,E(),n?.removeEventListener(`abort`,O);try{m?.close()}finally{try{a?.()}finally{e?c(e):o()}}}};async function O(){if(!(u||d)){if(d=!0,E(),m!==null)try{await new Promise(e=>m.stopContinuousRecognitionAsync(e,e))}catch{}D(null)}}let k=()=>[..._,g].filter(e=>e!==``).join(` `).trim(),A=(e,t)=>{h||(h=!0,clearTimeout(v)),clearTimeout(S),S=setTimeout(O,b),r?.(k(),t)};async function j(){if(n?.addEventListener(`abort`,O),!s){D(new t(`Unavailable`,`Dictation is not available in this browser.`));return}let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){D(w(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);if(a.speechRecognitionLanguage=e.language||i(),a.setProperty(n.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,String(y)),m=new n.SpeechRecognizer(a,n.AudioConfig.fromDefaultMicrophoneInput()),m.recognizing=(e,t)=>{if(u)return;let n=t.result?.text;n&&(g=n,A(n,!1))},m.recognized=(e,r)=>{if(u)return;let{reason:i,text:a}=r.result;i===n.ResultReason.RecognizedSpeech&&a?(_.push(a),g=``,A(a,!0)):i===n.ResultReason.NoMatch&&n.NoMatchDetails.fromResult(r.result).reason===n.NoMatchReason.InitialSilenceTimeout&&D(new t(`NoSpeech`,`No speech was heard.`))},m.canceled=(e,r)=>{u||(r.reason===n.CancellationReason.Error?D(new t(`Failed`,r.errorDetails)):D(null))},m.sessionStopped=()=>D(null),await new Promise((e,t)=>m.startContinuousRecognitionAsync(e,t)),u)return;e.onStarted?.(),v=setTimeout(()=>{h||D(new t(`NoSpeech`,`No speech was heard.`))},y),C=setTimeout(O,x)}catch(e){D(T(e))}}return j(),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(T(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`,`The reply could not be synthesised.`))},e=>d(e))}catch(e){d(e)}})}catch(e){throw T(e)}}return{dictation:s,readAloud:c,streamsText:!0,startDictation:m,speak:h}}var A=6e4,j=60*A,M=48*j;function N(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function P(e,t=Date.now(),n=void 0){let r=N(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<A)return s.format(0,`second`);if(a<j){let e=Math.floor(a/A);return s.format(o?-e:e,`minute`)}if(a<M){let e=Math.floor(a/j);return s.format(o?-e:e,`hour`)}return new Intl.DateTimeFormat(n,{day:`numeric`,month:`short`,year:`numeric`}).format(new Date(r))}function F(e,t=void 0){let n=N(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}var I=`data-wui-printing`,L=`data-wui-print-hide`,R=`data-wui-print-path`,z=`data-wui-print-target`,B=/* @__PURE__ */ new Set([`script`,`style`,`link`,`template`]),V=null;function H(){if(V!==null){for(let e of V.marked)e.removeAttribute(L),e.removeAttribute(R),e.removeAttribute(z);V.heading.remove(),document.documentElement.removeAttribute(I),window.removeEventListener(`afterprint`,V.onAfterPrint),V=null}}function U(e,t,n,r,i){H();let a=e.querySelector(`.wui-chat-panel`);if(a===null)throw Error(`print needs the wui-chat root`);let o=[];for(let e=a;e!==document.documentElement;e=e.parentElement){e.setAttribute(R,``),o.push(e);for(let t of e.parentElement.children)t===e||B.has(t.localName)||(t.setAttribute(L,``),o.push(t))}for(let e of n)e.setAttribute(L,``),o.push(e);r!==null&&(r.setAttribute(z,``),o.push(r));let s=document.createElement(`div`);s.className=`wui-chat-print-heading`;let c=document.createElement(`h1`);c.textContent=i.title;let l=document.createElement(`p`);l.textContent=i.printedOn,s.append(c,l),a.prepend(s),document.documentElement.setAttribute(I,t);let u=()=>H();window.addEventListener(`afterprint`,u,{once:!0}),V={marked:o,heading:s,onAfterPrint:u};try{window.print()}catch(e){throw H(),e}}function W(e,t){U(e,`conversation`,[],null,t)}function G(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);U(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function K(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function ee({title:e,text:t}){if(!K())return`failed`;try{return await navigator.share({title:e,text:t}),`shared`}catch(e){return e?.name===`AbortError`?`cancelled`:`failed`}}var te=`wchat:auto-opened`,ne=`wchat:dismissed`,re=`button, a[href], input, select, textarea`,ie=`input, textarea`;function q(e){return!e.closest(`.wui-chat`)}function ae(e){return e instanceof Element&&e.matches(ie)&&q(e)}function oe(){return[...document.querySelectorAll(ie)].some(e=>q(e)&&e.value!==e.defaultValue)}function J(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function se(e){return e?[...document.querySelectorAll(re)].some(t=>{if(!q(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 ce(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(te)||e.rememberDismissal&&sessionStorage.getItem(ne)||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&&oe()||n.isOpen()?!0:e.skipWhenCoversControl&&se(n.panelRect())}function le(e){return ae(document.activeElement)||J(e.avoid.menuSelectors)||J(e.avoid.autoOpenBusySelectors)}function ue(e,t,n){let r=0;function i(){r=0,ce(e,t,n)||(le(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(te,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=0}}}var de=.4,fe=20;function Y(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function pe(e){let t=e.match(/[\d.]+/g);if(!t||t.length<3)return null;let[n,r,i]=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 me({r:e,g:t,b:n}){return .2126*Y(e)+.7152*Y(t)+.0722*Y(n)}function he(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=pe(getComputedStyle(t).backgroundColor);if(n&&n.alpha>0)return me(n)<de}return!1}function ge(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function _e(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+fe:0}function ve(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 ye(e,t,n){let r=n.ownerDocument.documentElement,i=0,a=!1,o=null;function s(){i=0;let s=t.liftAboveFooter?ge(e.liftSelectors):[];if(o)for(let e of s)o.observe(e);n.style.setProperty(`--wui-chat-lift`,`${_e(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&&ve(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&&he(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 X=`wchat:session-start`,be=`wchat:pages`,xe=`wchat:services`;function Se(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function Ce(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function we(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function Te(e){sessionStorage.getItem(X)||sessionStorage.setItem(X,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=Se(be);i.includes(r)||(i.push(r),Ce(be,i));let a=we(r,e),o=Se(xe);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),Ce(xe,o)),{timeOnSiteSeconds:Math.floor((Date.now()-Number(sessionStorage.getItem(X)))/1e3),scrollPercent:Math.min(100,Math.floor(t)),pagesViewed:i.length,viewedServices:o}}}var Z=8,Ee=`(min-width: 992px)`,De=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,Oe=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],ke=0;function Ae(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function je(e){let{trigger:t,request:i,isEmpty:a,renderAnswer:o,renderFooter:c,session:l,timings:f,onStateChange:p,returnFocusTo:m}=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.`);ke+=1;let h=e.title??``,g=e.showNotCounted??!0,_=`wui-chat-explain-${ke}`,v=()=>r(e.labels??{}),y=()=>({labels:v(),close:W}),b=n({request:i,isEmpty:a,...f}),x=Object.fromEntries(Oe.map(e=>[e,t.getAttribute(e)])),S=t.hidden,C;t.setAttribute(`aria-haspopup`,`dialog`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,_);let w=null,T=null,E=null,D,O=null,k=[],A=[],j=()=>l?.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&&Ae(t,`title`,C),C=void 0,t.removeAttribute(`aria-disabled`),t.removeAttribute(`data-offline`)),l&&(t.hidden=j())}function N(e){if(T.replaceChildren(),e.pillVisible){let t=s(`span`,`wui-chat-explain-pill`),n=s(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),r=s(`span`);r.textContent=e.state===`slow`?v().explainSlow:v().thinking,t.append(n,r);let i=s(`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=s(`div`,`wui-chat-explain-answer`);E&&t.append(E),T.append(t)}else if(e.state===`empty`){let e=s(`p`,`wui-chat-explain-text`);e.textContent=v().explainEmpty,T.append(e)}else if(e.state===`capacity`){let t=s(`div`,`wui-chat-explain-alert wui-chat-explain-alert--warning`,{role:`status`}),n=s(`p`);n.textContent=e.resetsAtUtc?v().explainCapacity(F(e.resetsAtUtc)):v().explainCapacityNoDate,t.append(n),T.append(t)}else if(e.state===`error`){let e=s(`div`,`wui-chat-explain-alert wui-chat-explain-alert--error`,{role:`alert`}),t=s(`p`);t.textContent=v().explainError,e.append(t,u(`ghost`,v().retry,`rotate-ccw`,()=>b.ask())),T.append(e)}}function P(){let e=w.querySelector(`.wui-chat-explain-foot`);e.replaceChildren();let t=c?.(y());if(t&&e.append(t),g){let t=s(`p`,`wui-chat-explain-note`);t.textContent=v().explainNotCounted,e.append(t)}}function I(){if(!w)return;let e=b.getSnapshot();w.dataset.state=e.state,N(e),P(),p?.(e)}function L(){if(!w)return;if(!t.isConnected){W({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wui-chat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Ee)?.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-Z,o=a<i&&n.top>a,s=o?n.top-Z:a,c=o?Math.max(Z,n.top-i-Z):n.bottom+Z,l=Math.max(Z,Math.min(n.left,globalThis.innerWidth-r-Z));w.style.top=`${c}px`,w.style.left=`${l}px`,w.style.maxHeight=s<i?`${Math.max(0,s)}px`:``}function R(e){e.key===`Escape`&&(document.documentElement.hasAttribute(`data-wui-chat-docked`)||(e.stopPropagation(),W()))}function z(e){let n=e.target;w.contains(n)||t.contains(n)||n instanceof Element&&n.closest(`.wui-chat-panel`)||W({restoreFocus:!1})}function B(e){e.target instanceof Node&&w.contains(e.target)||L()}function V(){b.getSnapshot().offline||G()}function H(){for(let[e,t,n,r]of k)e.removeEventListener(t,n,r);k=[];for(let e of A)e.disconnect();A=[]}function U(){if(w||j()||b.getSnapshot().offline)return;w=s(`div`,`wui-chat-explain`,{role:`dialog`,"aria-label":h,popover:`manual`,id:_});let e=s(`header`,`wui-chat-explain-head`),n=s(`strong`,`wui-chat-explain-title`);n.textContent=h,O=d(v().close,`x`,()=>W()),O.classList.add(`wui-chat-explain-close`),e.append(n,O),T=s(`div`,`wui-chat-explain-body`,{"aria-live":`polite`}),w.append(e,T,s(`div`,`wui-chat-explain-foot`)),w.dataset.state=b.getSnapshot().state,document.body.append(w);try{w.showPopover?.()}catch{}t.setAttribute(`aria-expanded`,`true`),b.ask(),L(),(w.querySelector(De)??O).focus({preventScroll:!0}),k=[[document,`keydown`,R,!0],[document,`pointerdown`,z,!0],[window,`resize`,L,!1],[document,`scroll`,B,!0]];for(let[e,t,n,r]of k)e.addEventListener(t,n,r);if(typeof ResizeObserver==`function`){let e=new ResizeObserver(()=>L());e.observe(w),A.push(e)}let r=new MutationObserver(()=>L());r.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-wui-chat-docked`]}),A.push(r)}function W(e={restoreFocus:!0}){w&&(b.reset(),H(),w.remove(),w=null,T=null,E=null,D=void 0,O=null,t.setAttribute(`aria-expanded`,`false`),M(),e?.restoreFocus!==!1&&(m?.()??t).focus({preventScroll:!0}))}function G(){w?W():U()}let K=b.subscribe(()=>{M(),b.getSnapshot().offline&&w?W():I()}),ee=l?.subscribe(()=>{M(),j()&&w&&W({restoreFocus:!1})});return t.addEventListener(`click`,V),M(),{open:U,close:W,toggle:G,isOpen:()=>w!==null,destroy(){W({restoreFocus:!1}),K(),ee?.(),b.dispose(),t.removeEventListener(`click`,V);for(let e of Oe)Ae(t,e,x[e]);t.hidden=S}}}var Me=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Ne(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(Me)].filter(e=>e.tabIndex>=0&&!e.hidden);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1],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 Pe(e){e?.isConnected&&e.focus()}function Fe(e,t){t||typeof navigator>`u`||typeof navigator.vibrate!=`function`||navigator.vibrate(e)}var Ie=`(prefers-reduced-motion: reduce)`;function Le(e,t){let n=typeof window.matchMedia==`function`?window.matchMedia(Ie):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 Re=`wui-chat-lock`,ze=`wui-chat-scroll-lock`;function Be(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(Re);e.setAttribute(`data-lenis-prevent`,``),e.style.overscrollBehavior=`contain`,window.dispatchEvent(new CustomEvent(ze,{detail:{locked:!0}}));let i=!0;return function(){if(i){i=!1;for(let e of n)e.classList.remove(Re);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(ze,{detail:{locked:!1}}))}}}var Ve={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}},He=[`pointerdown`,`keydown`,`touchstart`],Ue=`wchat:muted`,We=1e-4;function Ge(e,t){let n=t.get(Ue)===`1`,r=null;function i(){for(let e of He)document.removeEventListener(e,a)}function a(){let e=globalThis.AudioContext||globalThis.webkitAudioContext;!r&&e&&(r=new e),r?.state===`suspended`&&r.resume(),i()}for(let e of He)document.addEventListener(e,a);return{play(t){let i=Ve[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(We,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(Ue,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close(),r=null}}}function Ke(e,t={}){return k({getToken:()=>e.getSpeechToken(),getLanguage:t.language?()=>t.language:void 0})}var qe=2e3,Je=500,Ye=32,Q=16,Xe=`data-wui-chat-switching`;function Ze(e){return new Promise(t=>setTimeout(t,e))}function $(e,t){return typeof e!=`function`||e()?Promise.resolve():new Promise(n=>{let r=0,i=()=>{e()||r>=t?n():(r+=Q,setTimeout(i,Q))};setTimeout(i,Q)})}async function Qe(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(Xe,``);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 $(t.routeReady,qe),await $(r,Je),await Ze(Ye)});try{await i.updateCallbackDone}finally{await i.finished.catch(()=>{})}}finally{r.removeAttribute(Xe)}}var $e=100,et=12,tt=220,nt=640;function rt(e,t){let n=t.phone.mode===`Sheet`,r=window.visualViewport,i=0;function a(){e.style.removeProperty(`bottom`),e.style.removeProperty(`max-height`)}function o(){if(i=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-et;n&&(s=Math.min(nt,Math.max(tt,s))),e.style.bottom=`${o}px`,e.style.maxHeight=`${s}px`}function s(){clearTimeout(i),i=setTimeout(o,$e)}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{c as A,k as C,v as D,l as E,u as M,s as O,t as S,h as T,H as _,Ge as a,F as b,Fe as c,je as d,Te as f,ee as g,K as h,Ke as i,f as j,d as k,Pe as l,ue as m,rt as n,Be as o,ye as p,Qe as r,Le as s,e as t,Ne as u,W as v,w,P as x,G as y};
|