@webority/chat-elements 0.160.0 → 0.162.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.
@@ -1,5 +1,6 @@
1
1
  import type { ChatAttribution, ChatFeature, ChatLabels, ChatLiveMessage, ChatLook, ChatPart, ChatPartKind, ChatProfileView, ChatSession, ChatSessionState, ChatTurnApi, ConversationList } from "@webority/chat-core";
2
2
  import { createComposer } from "./composer.js";
3
+ import { type MarkMaker } from "./dom.js";
3
4
  import { ElementBase } from "./elementBase.js";
4
5
  import { createFooter } from "./footer.js";
5
6
  import { createHeader } from "./header.js";
@@ -44,7 +45,7 @@ export type WuiChatAttributes = {
44
45
  position?: Position;
45
46
  "offset-x"?: `${number}`;
46
47
  "offset-y"?: `${number}`;
47
- loader?: "steps" | "phrases" | "orb" | "skeleton";
48
+ loader?: "steps" | "phrases" | "orb" | "skeleton" | "pulse-and-dots";
48
49
  screen?: string;
49
50
  motion?: "on" | "reduced";
50
51
  theme?: "auto" | "light" | "dark";
@@ -57,14 +58,15 @@ export type WuiChatAttributes = {
57
58
  labels?: string;
58
59
  "page-context"?: string;
59
60
  "conversation-id"?: string;
60
- "launcher-style"?: "round" | "pill";
61
+ "launcher-style"?: "round" | "pill" | "expanding";
61
62
  entrance?: "slide-up" | "bounce-in" | "fade-in-pulse" | "spin-scale" | "wiggle-in" | "elastic-in" | "rise" | "none";
62
63
  idle?: "float-and-pulse" | "ring" | "none";
63
64
  "label-reveal"?: "bubble" | "expand";
64
65
  "launcher-mark"?: "icon" | "avatar" | "orb";
65
66
  "panel-height"?: "fixed" | "content";
66
67
  "panel-placement"?: "floating" | "side";
67
- "reply-avatars"?: BooleanAttribute;
68
+ "reply-avatars"?: "none" | "first" | "every";
69
+ "avatar-motion"?: "still" | "drift";
68
70
  "greeting-loader-ms"?: `${number}`;
69
71
  "panel-motion"?: "spring" | "gentle" | "none";
70
72
  "panel-width"?: `${number}`;
@@ -79,6 +81,13 @@ export type WuiChatAttributes = {
79
81
  "send-reveal"?: "on-text" | "always";
80
82
  "send-icon"?: string;
81
83
  "input-mark"?: "none" | "avatar";
84
+ "input-edge"?: "none" | "gradient";
85
+ "input-busy-edge"?: "off" | "sweep";
86
+ "input-placeholder"?: "plain" | "gradient";
87
+ "footer-layout"?: "stacked" | "inline";
88
+ "starters-style"?: "chips" | "rows";
89
+ "recent-rows"?: `${number}`;
90
+ "footer-disclaimer"?: "show" | "hide";
82
91
  "lift-selectors"?: string;
83
92
  "menu-selectors"?: string;
84
93
  "dark-selectors"?: string;
@@ -108,6 +117,7 @@ export declare class WuiChat extends ElementBase {
108
117
  _voice: ReturnType<typeof createVoiceController> | null;
109
118
  _voiceConversationId: string | null | undefined;
110
119
  _shell: Shell;
120
+ _markMaker: MarkMaker;
111
121
  _labelsProp: Partial<ChatLabels> | undefined;
112
122
  _pageContextProp: unknown;
113
123
  _layoutParts: LayoutParts | null;
@@ -1,4 +1,5 @@
1
- import type { ChatFeature, ChatLabels, ChatSessionState, ComposerAttachment } from "@webority/chat-core";
1
+ import type { ChatFeature, ChatInputMark, ChatLabels, ChatSessionState, ComposerAttachment } from "@webority/chat-core";
2
+ import { type MarkMaker } from "./dom.js";
2
3
  import type { createVoiceController } from "./voice/controller.js";
3
4
  type ComposerState = Pick<ChatSessionState, "streaming" | "messagesLeftToday" | "editing" | "messages" | "handoffPause"> & {
4
5
  attachments: Pick<ComposerAttachment, "key" | "fileName" | "status" | "progress" | "error">[];
@@ -16,6 +17,8 @@ type ComposerView = {
16
17
  accept?: string;
17
18
  draft?: string | null;
18
19
  sendIcon?: string;
20
+ inputMark?: ChatInputMark;
21
+ busy?: boolean;
19
22
  };
20
23
  export declare function createComposer(handlers: {
21
24
  voice?: ReturnType<typeof createVoiceController>;
@@ -26,6 +29,7 @@ export declare function createComposer(handlers: {
26
29
  onCancelEdit(): void;
27
30
  onTyping?(): void;
28
31
  onDraftApplied?(): void;
32
+ mark?: MarkMaker;
29
33
  }): {
30
34
  nodes: HTMLElement[];
31
35
  paint: (view: ComposerView) => void;
@@ -1,4 +1,4 @@
1
- import type { ChatEntrance, ChatIdleMotion, ChatInputMark, ChatLabelReveal, ChatLabels, ChatLauncherMark, ChatLauncherStyle, ChatPanelHeight, ChatPanelMotion, ChatPanelPlacement, ChatPhoneMode, ChatSendReveal } from "@webority/chat-core";
1
+ import type { ChatAvatarMotion, ChatEntrance, ChatFooterLayout, ChatIdleMotion, ChatInputBusyEdge, ChatInputEdge, ChatInputMark, ChatInputPlaceholder, ChatLabelReveal, ChatLabels, ChatLauncherMark, ChatLauncherStyle, ChatPanelHeight, ChatPanelMotion, ChatPanelPlacement, ChatPhoneMode, ChatReplyAvatars, ChatSendReveal, ChatStartersStyle } 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;
@@ -18,6 +18,11 @@ export declare function textButton(variant: keyof typeof BUTTON_VARIANTS, label:
18
18
  export declare function iconButton(label: string, icon: string, onClick: (event: MouseEvent) => void): HTMLButtonElement;
19
19
  export declare function parseJsonAttribute(element: Element, name: string): unknown;
20
20
  export declare function clear<T extends ParentNode>(node: T): T;
21
+ export type MarkPlace = "launcher" | "header" | "greeting" | "reply" | "loader" | "input";
22
+ export type MarkState = "rest" | "busy";
23
+ export type MarkMaker = (place: MarkPlace, state: MarkState) => HTMLSpanElement | null;
24
+ export declare function captureMark(host: Element): Element | null;
25
+ export declare function createMarkMaker(template: Element | null): MarkMaker;
21
26
  export declare function createOpenState(root: HTMLElement): (open: boolean) => void;
22
27
  export declare function applyAppearance(root: HTMLElement, options: {
23
28
  position?: "start" | "end";
@@ -34,9 +39,15 @@ export declare function applyAppearance(root: HTMLElement, options: {
34
39
  panelHeight?: ChatPanelHeight;
35
40
  panelPlacement?: ChatPanelPlacement;
36
41
  inputMark?: ChatInputMark;
42
+ inputEdge?: ChatInputEdge;
43
+ inputBusyEdge?: ChatInputBusyEdge;
44
+ inputPlaceholder?: ChatInputPlaceholder;
37
45
  phoneHideLauncher?: boolean;
38
46
  avatar?: string | null;
39
- replyAvatars?: boolean;
47
+ avatarMotion?: ChatAvatarMotion;
48
+ replyAvatars?: ChatReplyAvatars;
49
+ footerLayout?: ChatFooterLayout;
50
+ startersStyle?: ChatStartersStyle;
40
51
  }): void;
41
52
  export declare const PART_KINDS: string[];
42
53
  declare const LAYOUT_CLASS: {
@@ -46,13 +57,14 @@ declare const LAYOUT_CLASS: {
46
57
  readonly embedded: "wui-chat--embedded";
47
58
  };
48
59
  export declare function kebab(name: string): string;
49
- export declare function createShellBase({ id, layout, position, role, launcher, onToggle, }: {
60
+ export declare function createShellBase({ id, layout, position, role, launcher, onToggle, mark: markMaker, }: {
50
61
  id: string;
51
62
  layout: keyof typeof LAYOUT_CLASS;
52
63
  position: "start" | "end";
53
64
  role: string;
54
65
  launcher: boolean;
55
66
  onToggle: () => void;
67
+ mark?: MarkMaker;
56
68
  }): {
57
69
  root: HTMLDivElement;
58
70
  panel: HTMLElement;
@@ -4,5 +4,6 @@ export declare function createFooter(): {
4
4
  paint: (view: {
5
5
  labels: ChatLabels;
6
6
  profile: ChatProfileView | null;
7
+ hideDisclaimer: boolean;
7
8
  }) => void;
8
9
  };
@@ -1,6 +1,8 @@
1
1
  import type { ChatLabels } from "@webority/chat-core";
2
+ import { type MarkMaker } from "./dom.js";
2
3
  export declare function createHeader(handlers: {
3
4
  titleId?: string;
5
+ mark?: MarkMaker;
4
6
  onHistory(): void;
5
7
  onMute(): void;
6
8
  onNew(): void;
@@ -9,6 +9,7 @@ type LoaderUpdate = {
9
9
  intervalMs: number;
10
10
  reduced?: boolean | undefined;
11
11
  announce?: string | undefined;
12
+ mark?: Element | null | undefined;
12
13
  };
13
14
  export declare function createLoader(): {
14
15
  el: HTMLDivElement;
@@ -1,5 +1,5 @@
1
1
  import type { ChatLoaderView } from "@webority/chat-core";
2
2
  export declare function createOrb(): {
3
3
  el: HTMLDivElement;
4
- render(view: ChatLoaderView): void;
4
+ render(view: ChatLoaderView, copy?: Element | null): void;
5
5
  };
@@ -0,0 +1,5 @@
1
+ import type { ChatLoaderView } from "@webority/chat-core";
2
+ export declare function createPulseAndDots(): {
3
+ el: HTMLDivElement;
4
+ render(view: ChatLoaderView, copy?: Element | null): void;
5
+ };
@@ -1,5 +1,5 @@
1
1
  import type { ChatLoaderView } from "@webority/chat-core";
2
2
  export declare function createSteps(): {
3
3
  el: HTMLDivElement;
4
- render: (view: ChatLoaderView) => void;
4
+ render: (view: ChatLoaderView, mark?: Element | null) => void;
5
5
  };
@@ -1,5 +1,6 @@
1
1
  import type { ChatSession } from "@webority/chat-core";
2
2
  import type { defineDefaultRenderer, WuiChat } from "./WuiChat.js";
3
+ import type { createExplainPopover } from "./web/explain.js";
3
4
  /** Reads the live session of a `<wui-chat>` element, or null before it connects. */
4
5
  export type WeborityChatSession = (element: WuiChat) => ChatSession | null;
5
6
  /** Registers a default renderer for one part kind on every chat element created after the call. */
@@ -10,6 +11,8 @@ export type WeborityChatRenderers = {
10
11
  export type WeborityChatGlobal = {
11
12
  session: WeborityChatSession;
12
13
  renderers: WeborityChatRenderers;
14
+ /** Binds a Why? trigger to the explain card; the same function the `@webority/chat-elements/web` entry exports. */
15
+ createExplainPopover: typeof createExplainPopover;
13
16
  };
14
17
  declare global {
15
18
  interface HTMLElementTagNameMap {
@@ -1,7 +1,9 @@
1
+ import { type MarkMaker } from "./dom.js";
1
2
  export declare function createDockedShell(options: {
2
3
  id: string;
3
4
  position: "start" | "end";
4
5
  onToggle: () => void;
6
+ mark?: MarkMaker;
5
7
  }): {
6
8
  root: HTMLDivElement;
7
9
  panel: HTMLElement;
@@ -1,7 +1,9 @@
1
+ import { type MarkMaker } from "./dom.js";
1
2
  export declare function createEmbedShell(options: {
2
3
  id: string;
3
4
  position: "start" | "end";
4
5
  onToggle: () => void;
6
+ mark?: MarkMaker;
5
7
  }): {
6
8
  root: HTMLDivElement;
7
9
  panel: HTMLElement;
@@ -1,8 +1,9 @@
1
- import { createShellBase } from "./dom.js";
1
+ import { createShellBase, type MarkMaker } from "./dom.js";
2
2
  export declare function createLauncherShell(options: {
3
3
  id: string;
4
4
  position: "start" | "end";
5
5
  onToggle: () => void;
6
+ mark?: MarkMaker;
6
7
  }): {
7
8
  root: HTMLDivElement;
8
9
  panel: HTMLElement;
@@ -1,7 +1,9 @@
1
+ import { type MarkMaker } from "./dom.js";
1
2
  export declare function createPageShell(options: {
2
3
  id: string;
3
4
  position: "start" | "end";
4
5
  onToggle: () => void;
6
+ mark?: MarkMaker;
5
7
  }): {
6
8
  root: HTMLDivElement;
7
9
  panel: HTMLElement;
@@ -1,4 +1,5 @@
1
1
  import { type ChatConversationSummary, type ChatFeature, type ChatLabels, type ChatOpenTicket, type ChatStarter } from "@webority/chat-core";
2
+ import { type MarkMaker } from "./dom.js";
2
3
  type StarterView = {
3
4
  labels: ChatLabels;
4
5
  greeting: string | null;
@@ -6,6 +7,7 @@ type StarterView = {
6
7
  starters: ChatStarter[];
7
8
  showStarters: boolean;
8
9
  resume: ChatConversationSummary | null;
10
+ recent: ChatConversationSummary[];
9
11
  openTickets: ChatOpenTicket[];
10
12
  features: Readonly<Record<ChatFeature, boolean>>;
11
13
  ticketsClickable: boolean;
@@ -14,6 +16,8 @@ export declare function createStarters(handlers: {
14
16
  onStarter: (starter: ChatStarter) => void;
15
17
  onResume: () => void;
16
18
  onTicket: (ticket: ChatOpenTicket) => void;
19
+ onOpenConversation: (id: string) => void;
20
+ mark?: MarkMaker;
17
21
  }): {
18
22
  el: HTMLDivElement;
19
23
  paint: (view: StarterView) => void;
@@ -1,4 +1,5 @@
1
- import type { ChatFeature, ChatLabels, ChatLiveMessage, ChatLoaderStyle, ChatPart, ChatPartKind, ChatRating, ChatTurnApi, ChatTurnError } from "@webority/chat-core";
1
+ import type { ChatFeature, ChatLabels, ChatLiveMessage, ChatLoaderStyle, ChatPart, ChatPartKind, ChatRating, ChatReplyAvatars, ChatTurnApi, ChatTurnError } from "@webority/chat-core";
2
+ import { type MarkMaker } from "./dom.js";
2
3
  import { createReadAloudButton } from "./voice/read-aloud-button.js";
3
4
  type ThreadState = {
4
5
  conversationId: string | null;
@@ -26,6 +27,7 @@ type ThreadContext = {
26
27
  phrases: readonly string[];
27
28
  intervalMs: number;
28
29
  assistantName?: string | undefined;
30
+ replyAvatars?: ChatReplyAvatars;
29
31
  };
30
32
  type Renderers = Readonly<Record<ChatPartKind, string>>;
31
33
  export declare function createThread(options: {
@@ -39,6 +41,7 @@ export declare function createThread(options: {
39
41
  startEdit(messageId: string): void;
40
42
  };
41
43
  getVoice?: () => Parameters<typeof createReadAloudButton>[0]["voice"] | null;
44
+ mark?: MarkMaker;
42
45
  }): {
43
46
  el: HTMLDivElement;
44
47
  paint: (state: ThreadState, context: ThreadContext) => 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})}}var y=0;function b(e){return e.querySelector(`:scope > [slot="mark"]`)}function x(e,t){for(let t of e.querySelectorAll(`script`))t.remove();let n=[e,...e.querySelectorAll(`*`)],r=[];for(let e of n){for(let t of e.getAttributeNames())t.startsWith(`on`)&&e.removeAttribute(t);let n=e.getAttribute(`id`);if(n){let i=`${n}-${t}`;r.push([n,i]),e.setAttribute(`id`,i)}}let i=e=>r.reduce((e,[t,n])=>e.split(`url(#${t})`).join(`url(#${n})`),e);for(let e of n){for(let t of e.getAttributeNames()){let n=e.getAttribute(t);n?.includes(`url(#`)&&e.setAttribute(t,i(n))}let t=e.localName===`style`?e.textContent:null;t?.includes(`url(#`)&&(e.textContent=i(t))}}function S(e){return(t,n)=>{if(e===null)return null;let r=e.cloneNode(!0);if(!(r instanceof Element))return null;r.removeAttribute(`slot`),y+=1,x(r,`mark${y}`);let i=p(`span`,`wui-chat-mark`,{"aria-hidden":`true`,"data-place":t,"data-state":n});return i.append(r),i}}function C(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 w(e,t){if(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.avatarMotion!==void 0){let n=e.style.getPropertyValue(`--wui-chat-avatar`)!==``;e.classList.toggle(`wui-chat--avatar-drift`,t.avatarMotion===`Drift`&&!n)}t.replyAvatars!==void 0&&(e.classList.toggle(`wui-chat--reply-avatars-off`,t.replyAvatars===`None`),e.classList.toggle(`wui-chat--reply-avatars-every`,t.replyAvatars===`Every`)),t.footerLayout!==void 0&&e.classList.toggle(`wui-chat--footer-inline`,t.footerLayout===`Inline`),t.inputEdge!==void 0&&e.classList.toggle(`wui-chat--input-edge-gradient`,t.inputEdge===`Gradient`),t.inputBusyEdge!==void 0&&e.classList.toggle(`wui-chat--input-busy-edge-sweep`,t.inputBusyEdge===`Sweep`),t.inputPlaceholder!==void 0&&e.classList.toggle(`wui-chat--placeholder-gradient`,t.inputPlaceholder===`Gradient`),t.startersStyle!==void 0&&e.classList.toggle(`wui-chat--starters-rows`,t.startersStyle===`Rows`)}var T=[`Text`,`Sources`,`QuickReplies`,`InputRequest`,`Action`,`Notice`,`Table`,`Chart`,`Figures`,`RecordCard`,`Image`,`File`,`Ticket`,`Handoff`,`VoiceClip`],E={launcher:`wui-chat--launcher`,docked:`wui-chat--docked`,"full-page":`wui-chat--full-page`,embedded:`wui-chat--embedded`};function D(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function O({id:e,layout:t,position:n,role:r,launcher:i,onToggle:a,mark:s}){let l=p(`div`,`wui-chat ${E[t]} wui-chat--${n}`),u=p(`section`,`wui-chat-panel`,{id:e,role:r}),d=i?C(l):null;l.dataset.state=i?`closed`:`open`;let f=null,h=null,g=null,_=null,v=null,y=null,b=null,x=null,S=`round`,T=!1,O=`bubble`,k=null,A=null,j=!1,M=`icon`,N=!1;function P(){if(!f)return;let e=f.dataset.launcher,t=[`wui-chat-launcher-wrap`];e===`entering`&&k&&t.push(`wui-chat-launcher--entrance-${k}`),e===`idle`&&A&&A!==`none`&&t.push(`wui-chat-launcher--idle-${A}`),f.className=t.join(` `)}function F(){if(!h)return;let e=[...h.classList].filter(e=>e.endsWith(`--opening`)||e.endsWith(`--closing`)),t=[`wui-chat-launcher`,`wui-chat-launcher--${S}`];S===`expanding`&&t.push(`wui-chat-launcher--pill`),S===`pill`&&T&&t.push(`wui-chat-launcher--compact`),M!==`icon`&&t.push(`wui-chat-launcher--mark-${M}`),t.push(`wui-chat-launcher--reveal-${O}`,...e),h.className=t.join(` `)}function I(){y&&b&&(y.textContent=x||b.launcher)}function L(){if(!h||!v||!b)return;let e=x||b.launcher;h.setAttribute(`aria-label`,N?b.launcherClose:e),v.textContent=e}if(i){let t=p(`div`,`wui-chat-launcher-wrap`);f=t,t.dataset.launcher=`idle`;let n=p(`button`,`wui-chat-launcher`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":e});h=n;let r=p(`span`,`wui-chat-launcher-icon`,{"aria-hidden":`true`});g=r,_=s?.(`launcher`,`rest`)??null,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`);v=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 d=p(`span`,`wui-chat-launcher-bubble`,{"aria-hidden":`true`});y=d,t.append(n,d),o(l,n),t.addEventListener(`animationend`,e=>{e.target===t&&t.dataset.launcher===`entering`&&(t.dataset.launcher=`idle`,P())}),F(),P(),l.append(t,u)}else l.append(u);function R(e){if(!d)return;let t=e&&!N&&h!==null&&h?h.getBoundingClientRect():null;e!==N&&h&&(h.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`),h.classList.add(e?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`)),N=e,d(e),t&&c(u,t),h&&(h.setAttribute(`aria-expanded`,String(e)),L())}function z(e){b=e,h&&(L(),I())}function B(e){if(w(l,e),e.theme!==void 0&&(e.theme===`light`||e.theme===`dark`?l.dataset.theme=e.theme:delete l.dataset.theme),!h||!f||!g)return;e.launcherStyle!==void 0&&(S=D(e.launcherStyle)),e.compact!==void 0&&(T=e.compact),e.labelReveal!==void 0&&(O=e.labelReveal===`Expand`?`expand`:`bubble`),e.entrance!==void 0&&(k=e.entrance===`None`?null:D(e.entrance)),e.idle!==void 0&&(A=e.idle===`None`?`none`:D(e.idle)),e.phone!==void 0&&(j=e.phone),e.hoverLabel!==void 0&&(x=e.hoverLabel||null),e.launcherMark!==void 0&&(M=D(e.launcherMark)),_===null&&e.icon!==void 0&&e.icon!==g.dataset.icon&&(g.dataset.icon=e.icon,g.replaceChildren(m(e.icon,24)));let t=e.launcherState??f.dataset.launcher;j&&t===`entering`&&(t=`idle`),t===`entering`&&!k&&(t=`idle`),f.dataset.launcher=t,F(),P(),I(),L()}return{root:l,panel:u,setOpen:R,setLabels:z,setAppearance:B,nudgeHost:f,launcherButton:h,role:r}}var k=1e4,A=2e3,j=3e5,M=/* @__PURE__ */ new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),N=/* @__PURE__ */ new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function P(e){return M.has(I(e,`name`))?new t(`Blocked`,{message:L(e)}):N.has(I(e,`name`))?new t(`NoMicrophone`,{message:L(e)}):F(e)}function F(e){return e instanceof t?e:new t(`Failed`,{message:L(e)??String(e)})}function I(e,t){return typeof e==`object`&&e||typeof e==`function`?Reflect.get(e,t):void 0}function L(e){let t=I(e,`message`);return t==null?void 0:String(t)}function R(e){return typeof e==`object`&&!!e}function z(e){let t=I(e,`SpeechConfig`),n=I(e,`AudioConfig`),r=I(e,`NoMatchDetails`);return typeof I(t,`fromAuthorizationToken`)==`function`&&typeof I(n,`fromDefaultMicrophoneInput`)==`function`&&typeof I(n,`fromSpeakerOutput`)==`function`&&typeof I(r,`fromResult`)==`function`&&typeof I(e,`SpeechRecognizer`)==`function`&&typeof I(e,`SpeakerAudioDestination`)==`function`&&typeof I(e,`SpeechSynthesizer`)==`function`&&R(I(e,`PropertyId`))&&R(I(e,`ResultReason`))&&R(I(e,`NoMatchReason`))&&R(I(e,`CancellationReason`))}function B(e){if(!z(e))throw new t(`Unavailable`,{message:`Speech is not available in this browser.`});return e}var V=null;function H(){let e=globalThis,t=`SpeechSDK`in e?e.SpeechSDK:void 0;return t?Promise.resolve(B(t)):(V===null&&(V=import(`microsoft-cognitiveservices-speech-sdk`).then(e=>B(I(e,`SpeechConfig`)?e:I(e,`default`))).catch(e=>{throw V=null,e})),V)}function U(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function W(e){let n=e.getToken,r=e.loadSdk??H,i=e.getLanguage??U,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,F(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,F(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(),T=(e,t)=>{h||(h=!0,clearTimeout(v)),clearTimeout(y),y=setTimeout(C,A),r?.(w(),t)};async function E(){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(P(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(k));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,T(n,!1))},o.recognized=(e,r)=>{if(u)return;let{reason:i,text:a}=r.result;i===n.ResultReason.RecognizedSpeech&&a?(_.push(a),g=``,T(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.`}))},k),b=setTimeout(C,j)}catch(e){S(F(e))}}return E(),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(F(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 F(e)}}return{dictation:s,readAloud:c,streamsText:!0,startDictation:m,speak:h}}var G=6e4,K=60*G,ee=48*K;function te(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function ne(e,t=Date.now(),n){let r=te(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<G)return s.format(0,`second`);if(a<K){let e=Math.floor(a/G);return s.format(o?-e:e,`minute`)}if(a<ee){let e=Math.floor(a/K);return s.format(o?-e:e,`hour`)}return new Intl.DateTimeFormat(n,{day:`numeric`,month:`short`,year:`numeric`}).format(new Date(r))}function re(e,t){let n=te(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}var ie=`data-wchat-printing`,q=`data-wchat-print-hide`,ae=`data-wchat-print-path`,oe=`data-wchat-print-target`,se=/* @__PURE__ */ new Set([`script`,`style`,`link`,`template`]),J=null;function Y(){if(J!==null){for(let e of J.marked)e.removeAttribute(q),e.removeAttribute(ae),e.removeAttribute(oe);J.heading.remove(),document.documentElement.removeAttribute(ie),window.removeEventListener(`afterprint`,J.onAfterPrint),J=null}}function ce(e,t,n,r,i){Y();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(ae,``),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||se.has(t.localName)||(t.setAttribute(q,``),o.push(t));s=e}for(let e of n)e.setAttribute(q,``),o.push(e);r!==null&&(r.setAttribute(oe,``),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(ie,t);let d=()=>Y();window.addEventListener(`afterprint`,d,{once:!0}),J={marked:o,heading:c,onAfterPrint:d};try{window.print()}catch(e){throw Y(),e}}function le(e,t){ce(e,`conversation`,[],null,t)}function ue(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);ce(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function de(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function fe({title:e,text:t}){if(!de())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 pe=`wchat:auto-opened`,me=`wchat:dismissed`,he=`button, a[href], input, select, textarea`,ge=`input, textarea`;function X(e){return!e.closest(`.wui-chat`)}function _e(e){return e instanceof Element&&e.matches(ge)&&X(e)}function ve(){return[...document.querySelectorAll(ge)].some(e=>X(e)&&e.value!==e.defaultValue)}function ye(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function be(e){return e?[...document.querySelectorAll(he)].some(t=>{if(!X(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 xe(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(pe)||e.rememberDismissal&&sessionStorage.getItem(me)||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&&ve()||n.isOpen()?!0:e.skipWhenCoversControl&&be(n.panelRect())}function Se(e){return _e(document.activeElement)||ye(e.avoid.menuSelectors)||ye(e.avoid.autoOpenBusySelectors)}function Ce(e,t,n){let r;function i(){r=void 0,xe(e,t,n)||(Se(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(pe,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=void 0}}}var we=.4,Te=.5,Ee=`rgba(0, 0, 0, 0)`,De=20;function Z(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Oe(e){let t=e.createElement(`canvas`);t.width=1,t.height=1;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)throw Error(`A 2D canvas context is needed to read the colour under the launcher.`);return e=>{n.clearRect(0,0,1,1),n.fillStyle=Ee,n.fillStyle=e,n.fillRect(0,0,1,1);let[t=0,r=0,i=0,a=0]=n.getImageData(0,0,1,1).data;return{r:t,g:r,b:i,alpha:a/255}}}function ke({r:e,g:t,b:n}){return .2126*Z(e)+.7152*Z(t)+.0722*Z(n)}function Ae(e,t,n){let r=e.getBoundingClientRect(),i=document.elementsFromPoint?.(r.left+r.width/2,r.top+r.height/2)??[],a=t.length?t.join(`,`):null;for(let t of i){if(e.contains(t))continue;if(a&&t.closest(a))return!0;let r=n(getComputedStyle(t).backgroundColor);if(!(r.alpha<Te))return ke(r)<we}return!1}function je(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function Me(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+De:0}function Ne(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 Pe(e,t,n){let r=n.ownerDocument.documentElement,i=t.switchOnDark?Oe(n.ownerDocument):null,a=0,o=!1,s=null;function c(){a=0;let c=t.liftAboveFooter?je(e.liftSelectors):[];if(s)for(let e of c)s.observe(e);n.style.setProperty(`--wui-chat-lift`,`${Me(c)}px`);let l=n.getBoundingClientRect(),u=l.height===0?0:Math.round(window.innerHeight-l.top);r.style.setProperty(`--wui-chat-launcher-block`,`${u}px`);let d=t.stepAsideForMenus&&Ne(e.menuSelectors);d&&!o?(n.dataset.launcher=`hidden`,n.inert=!0,o=!0):!d&&o&&(n.dataset.launcher=`idle`,n.inert=!1,o=!1);let f=i!==null&&Ae(n,e.darkSelectors,i);f&&n.dataset.onDark===void 0&&(n.dataset.onDark=``),!f&&n.dataset.onDark!==void 0&&delete n.dataset.onDark}function l(){a||=requestAnimationFrame(c)}typeof ResizeObserver==`function`&&(s=new ResizeObserver(l));let u=new MutationObserver(l);return u.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`open`,`data-menu-open`]}),document.addEventListener(`scroll`,l,{capture:!0,passive:!0}),window.addEventListener(`resize`,l),window.addEventListener(`load`,l),n.addEventListener(`animationend`,l),l(),{destroy(){a&&cancelAnimationFrame(a),a=0,s?.disconnect(),u.disconnect(),document.removeEventListener(`scroll`,l,{capture:!0}),window.removeEventListener(`resize`,l),window.removeEventListener(`load`,l),n.removeEventListener(`animationend`,l),o&&=(n.inert=!1,!1),delete n.dataset.onDark,n.style.removeProperty(`--wui-chat-lift`),r.style.removeProperty(`--wui-chat-launcher-block`)}}}var Q=`wchat:session-start`,Fe=`wchat:pages`,Ie=`wchat:services`;function Le(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function Re(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function ze(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function Be(e){sessionStorage.getItem(Q)||sessionStorage.setItem(Q,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=Le(Fe);i.includes(r)||(i.push(r),Re(Fe,i));let a=ze(r,e),o=Le(Ie);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),Re(Ie,o)),{timeOnSiteSeconds:Math.floor((Date.now()-Number(sessionStorage.getItem(Q)))/1e3),scrollPercent:Math.min(100,Math.floor(t)),pagesViewed:i.length,viewedServices:o}}}var $=8,Ve=`(min-width: 992px)`,He=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,Ue=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],We=0;function Ge(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Ke(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.`);We+=1;let f=e.title??``,m=e.showNotCounted??!0,h=`wui-chat-explain-${We}`,v=()=>r(e.labels??{}),y=()=>({labels:v(),close:U}),b=n({request:i,...a===void 0?{}:{isEmpty:a},...l}),x=Object.fromEntries(Ue.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&&Ge(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(re(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){U({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wchat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Ve)?.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-$,o=a<i&&n.top>a,s=o?n.top-$:a,c=o?Math.max($,n.top-i-$):n.bottom+$,l=Math.max($,Math.min(n.left,globalThis.innerWidth-r-$));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(),U()))}function R(e){let n=e.target;n instanceof Node&&(w?.contains(n)||t.contains(n))||n instanceof Element&&n.closest(`.wui-chat-panel`)||U({restoreFocus:!1})}function z(e){e.target instanceof Node&&w?.contains(e.target)||I()}function B(){b.getSnapshot().offline||W()}function V(){for(let[e,t,n,r]of k)e.removeEventListener(t,n,r);k=[];for(let e of A)e.disconnect();A=[]}function H(){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`,()=>U()),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(He)??O).focus({preventScroll:!0}),k=[[document,`keydown`,L,!0],[document,`pointerdown`,R,!0],[window,`resize`,I,!1],[document,`scroll`,z,!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 U(e={restoreFocus:!0}){w&&(b.reset(),V(),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 W(){w?U():H()}let G=b.subscribe(()=>{M(),b.getSnapshot().offline&&w?U():F()}),K=c?.subscribe(()=>{M(),j()&&w&&U({restoreFocus:!1})});return t.addEventListener(`click`,B),M(),{open:H,close:U,toggle:W,isOpen:()=>w!==null,destroy(){U({restoreFocus:!1}),G(),K?.(),b.dispose(),t.removeEventListener(`click`,B);for(let e of Ue)Ge(t,e,x[e]);t.hidden=S}}}var qe=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Je(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(qe)].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 Ye(e){e?.isConnected&&e.focus()}function Xe(e,t){if(t||typeof navigator>`u`)return;let n=navigator;typeof n.vibrate==`function`&&n.vibrate(e)}var Ze=`wui-chat-lock`,Qe=`wui-chat-scroll-lock`;function $e(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(Ze);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(Ze);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(Qe,{detail:{locked:!1}}))}}}var et={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}},tt=[`pointerdown`,`keydown`,`touchstart`],nt=`wchat:muted`,rt=1e-4;function it(e,t){let n=t.get(nt)===`1`,r=null;function i(){for(let e of tt)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 tt)document.addEventListener(e,a);return{play(t){let i=et[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(rt,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(nt,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close().catch(e=>globalThis.reportError?.(e)),r=null}}}function at(e,t={}){let n=t.language;return W({getToken:()=>e.getSpeechToken(),getLanguage:n?()=>n:void 0})}var ot=2e3,st=500,ct=32,lt=16,ut=`data-wchat-switching`;function dt(e){return new Promise(t=>setTimeout(t,e))}function ft(e,t){return typeof e!=`function`||e()?Promise.resolve():new Promise(n=>{let r=0,i=()=>{e()||r>=t?n():(r+=lt,setTimeout(i,lt))};setTimeout(i,lt)})}async function pt(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(ut,``);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 ft(t.routeReady,ot),await ft(r,st),await dt(ct)});Promise.allSettled([i.ready]);try{await i.updateCallbackDone}finally{await Promise.allSettled([i.finished])}}finally{r.removeAttribute(ut)}}var mt=100,ht=12,gt=220;function _t(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=window.innerHeight-r.height>ht,c=r.height-(n||s?ht:0);n&&(c=Math.min(t.phone.sheetMaxHeightPx,Math.max(gt,c))),e.style.bottom=`${o}px`,e.style.maxHeight=`${c}px`}function s(){clearTimeout(i),i=setTimeout(o,mt)}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{f as A,P as C,S as D,b as E,c as F,l as I,o as L,m as M,v as N,O,g as P,W as S,h as T,le as _,it as a,ne as b,Ye as c,Be as d,Pe as f,Y as g,fe as h,at as i,_ as j,p as k,Je as l,de as m,_t as n,$e as o,Ce as p,pt as r,Xe as s,e as t,Ke as u,ue as v,T as w,t as x,re 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-5VRSPxuS.js";
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,F 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 trackLauncherBlock,l as trapTab,s as vibrate,p as watchAutoOpen,I as watchReducedMotion}from"./web-4zEeUVrr.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/chat-elements",
3
- "version": "0.160.0",
3
+ "version": "0.162.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.160.0",
47
- "@webority/markdown-core": "^0.190.1",
48
- "@webority/theme": "^0.190.1",
49
- "@webority/ui-elements": "^0.190.1",
46
+ "@webority/chat-core": "0.162.0",
47
+ "@webority/markdown-core": "^0.191.3",
48
+ "@webority/theme": "^0.191.3",
49
+ "@webority/ui-elements": "^0.191.3",
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.160.0",
59
- "@webority/theme": "0.190.1",
60
- "@webority/ui-elements": "0.190.1",
58
+ "@webority/chat-core": "0.162.0",
59
+ "@webority/theme": "0.191.3",
60
+ "@webority/ui-elements": "0.191.3",
61
61
  "@vitest/coverage-v8": "5.1.0",
62
62
  "bootstrap": "5.3.9",
63
63
  "jsdom": "30.1.1",
@@ -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.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};