@webority/ui-elements 0.54.0 → 0.56.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/WuiAutocomplete-CE7wT-Vc.js +13 -0
- package/dist/{WuiCommandPalette-B5OB6lsf.js → WuiCommandPalette-CcmFOWNc.js} +1 -1
- package/dist/{WuiCountrySelect-GJrl6sUP.js → WuiCountrySelect-D92rrSvW.js} +1 -1
- package/dist/{WuiDatePicker-CI7wLkmd.js → WuiDatePicker-_BzQ2m1e.js} +1 -1
- package/dist/{WuiDateRange-B5sO9usZ.js → WuiDateRange-CrVodISl.js} +1 -1
- package/dist/WuiMultiSelect-WUNCdkzW.js +25 -0
- package/dist/{WuiPhone-CSUVhYSb.js → WuiPhone-DtuXp6o2.js} +7 -7
- package/dist/{WuiSelect-DcbtqI9s.js → WuiSelect-CT8tgsxL.js} +1 -1
- package/dist/WuiTour-DW3kPaR9.js +488 -0
- package/dist/elements/autocomplete.js +1 -1
- package/dist/elements/command-palette.js +1 -1
- package/dist/elements/country-select.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/multiselect.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/helpers.js +1 -1
- package/dist/{optionLabel-DOZb8ERB.js → optionLabel-BBaur8Bs.js} +1 -1
- package/dist/types/chatClient.d.ts +4 -4
- package/dist/ui-chat-core.js +1 -1
- package/dist/ui-chat.global.js +1 -1
- package/dist/ui-chat.js +1 -1
- package/dist/ui-elements.global.js +401 -82
- package/dist/ui-elements.js +1 -1
- package/dist/ui-tour.global.js +1 -1
- package/package.json +1 -1
- package/dist/WuiAutocomplete-DvXHihD6.js +0 -13
- package/dist/WuiMultiSelect-BCZE2VHM.js +0 -25
- package/dist/WuiTour-CUWrh5MD.js +0 -169
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n}from"./anchorOverlay-WcDeH46q.js";import{t as r}from"./tourOpenMark-nPeAJFSo.js";var i=`data-advance`,a=`wui-tour-hint`,o=`Click {actionName} to continue.`,s=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,c=(e,t)=>e?.advanceOn===`click`&&!!t,l=e=>(e??``).replace(/\s+/g,` `).trim();function u(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e.tagName===`INPUT`&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(e.labels??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=l(e);if(t)return t}return``}function d(e){for(let t of[e,...e.querySelectorAll(s)])if(t.tabIndex>=0&&!t.disabled)return t;return null}function f(e,t,n){let r=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(e=>e&&e!==t);n&&r.push(t),r.length>0?e.setAttribute(`aria-describedby`,r.join(` `)):e.removeAttribute(`aria-describedby`)}function p(e,t){let n=e.querySelector(`.${a}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t){n?.remove(),i&&f(e,i,!1);return}n||(n=e.ownerDocument.createElement(`p`),n.className=a,i&&(n.id=i),e.querySelector(`.wui-tour-actions`).before(n)),n.textContent=t,i&&f(e,i,!0)}var m=e=>getComputedStyle(e).animationName;function h(e,{layer:t,spot:n,card:r},a,s){let d=c(a,s);t.toggleAttribute(i,d&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(i)&&(n.removeAttribute(i),d&&m(n)),d&&n.setAttribute(i,``);let f=r.querySelector(`.wui-tour-next`);f.classList.toggle(`btn-primary`,!d),f.classList.toggle(`btn-link`,d);let h=d?l(a.actionLabel)||u(s):``,g=e.getAttribute(`advance-label`)||o,_=h?g.replace(/\{actionName\}/g,()=>h):``;return p(r,_),_}function g(e,t,n){if(!c(e,t))return()=>{};let r=null,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function _(e,t,n,r){return e.contains(r)||c(t,n)&&n.contains(r)}function ee(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=c(r,i)?d(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i.contains(n));e.preventDefault(),a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length].focus()}var te=2/3,ne=1e3,v=new Set([`top`,`left`,`width`,`height`]),y=new WeakMap,b=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],x=e=>e.transitionProperty===`opacity`,re=e=>v.has(e.transitionProperty),S=e=>typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function C(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,ne);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function ie(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?b(t,re):[]){let t=e.effect?.getComputedTiming?.();if(typeof t?.duration!=`number`)continue;let r=typeof e.currentTime==`number`?e.currentTime:0;n=Math.max(n,(t.delay??0)+t.duration*te-r)}return n}function w(e){let t=ie(e);t>0?e.style.setProperty(`--wui-tour-card-delay`,`${Math.round(t)}ms`):e.style.removeProperty(`--wui-tour-card-delay`),e.dataset.state=`entering`;let n={};y.set(e,n);let r=()=>{y.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=b(e,S);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function T(e){return e.dataset.state=`leaving`,C(b(e,x))}function ae(e){let t=e.classList.contains(`wui-tour-layer`)?e:e.shadowRoot?.querySelector(`.wui-tour-layer`);t&&(t.dataset.state=`leaving`);let n=t?C(b(t,x)):null;if(!n){e.remove();return}e.setAttribute(`inert`,``),n.then(()=>e.remove())}var E=2,D=12,O=8,k=4,A=20,oe=`(max-width: 575.98px)`,se=[`bottom`,`top`,`right`,`left`],j=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],M,N=(e,t,n)=>Math.max(t,Math.min(e,n)),P=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function ce(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=z(e),r=e.offsetHeight+D;if(t.getBoundingClientRect().height+E*2+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+E}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function F(e,t,n){let r=e.style,i=t.style,a=B(t);if(!n){r.top=`50%`,r.left=`50%`,r.width=`0px`,r.height=`0px`,r.boxShadow=`0 0 0 100vmax var(--color-scrim-strong)`;for(let e of j)r.removeProperty(`border-${e}-radius`),r.removeProperty(`corner-${e}-shape`);t.dataset.placement=`center`,a.hidden=!0,i.position=`fixed`,i.top=`50%`,i.left=`50%`,i.transform=`translate(-50%, -50%)`,i.maxHeight=`calc(100vh - 16px)`;return}r.boxShadow=``,i.transform=``,i.position=`fixed`;let o=n.getBoundingClientRect();r.top=`${o.top}px`,r.left=`${o.left}px`,r.width=`${o.width}px`,r.height=`${o.height}px`,le(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=z(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-D,top:o.top-D-l.top,right:l.right-o.right-D,left:o.left-D-l.left},f=window.matchMedia(oe).matches,p=se.find(e=>e===`top`||e===`bottom`?c.height<=d[e]+1:!f&&c.width<=d[e]+1&&c.height<=u+1),m=Math.min(o.bottom,l.bottom+O)-Math.max(o.top,l.top-O);p?I(t,a,p,o,l,c):m>=Math.min(c.height,u)+k*2?L(t,a,o,l,c):R(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function le(e,t){M??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of j)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),M&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function I(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=P(r.left,r.right,i.left,i.right);s=N(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+D:r.top-D-a.height,l=N(e-s,A,a.width-A)}else{let e=P(r.top,r.bottom,i.top,i.bottom);c=N(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+D:r.left-D-a.width,l=N(e-c,A,a.height-A)}e.dataset.placement=n,e.style.top=`${c}px`,e.style.left=`${s}px`,t.hidden=!1,t.style.left=o?`${l-e.clientLeft-t.offsetWidth/2}px`:``,t.style.top=o?``:`${l-e.clientTop-t.offsetHeight/2}px`}function L(e,t,n,r,i){let a=r.bottom-r.top;e.dataset.placement=`overlap`,t.hidden=!0,e.style.maxHeight=i.height>a?`${Math.max(a,0)}px`:``;let o=Math.min(n.bottom,r.bottom)-k;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${N(n.left+k,r.left,r.right-i.width)}px`}function R(e,t,n,r,i,a,o){let s=Math.max(o[n],0),c=Math.min(a.height,s);e.dataset.placement=n,t.hidden=!0,e.style.maxHeight=a.height>s?`${s}px`:``,e.style.top=`${n===`bottom`?r.bottom+D:r.top-D-c}px`;let l=P(r.left,r.right,i.left,i.right);e.style.left=`${N(l-a.width/2,i.left,i.right-a.width)}px`}function z(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e])||0;return{top:r(`paddingTop`)+O,bottom:window.innerHeight-r(`paddingBottom`)-O,left:r(`paddingLeft`)+O,right:window.innerWidth-r(`paddingRight`)-O}}function B(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);return t||(t=document.createElement(`span`),t.className=`wui-tour-arrow`,t.setAttribute(`aria-hidden`,`true`),t.hidden=!0,e.append(t)),t}var V=0;function H(e,t,n){let r=`wui-tour-end-${++V}`,i=e.createElement(`div`);return i.className=`wui-tour-card wui-tour-end`,i.dataset.layout=`center`,i.setAttribute(`role`,`dialog`),n&&i.setAttribute(`aria-modal`,`true`),i.tabIndex=-1,i.setAttribute(`aria-labelledby`,`${r}-title`),i.setAttribute(`aria-describedby`,`${r}-message`),i.innerHTML=`
|
|
2
|
+
<div class="wui-tour-end-mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></div>
|
|
3
|
+
<h2 class="wui-tour-title wui-tour-end-title" id="${r}-title"></h2>
|
|
4
|
+
<p class="wui-tour-text wui-tour-end-message" id="${r}-message"></p>
|
|
5
|
+
<div class="wui-tour-actions"><button type="button" class="btn btn-sm btn-primary wui-tour-end-button"></button></div>`,i.querySelector(`.wui-tour-end-title`).textContent=t.title,i.querySelector(`.wui-tour-end-message`).textContent=t.message,i.querySelector(`.wui-tour-end-button`).textContent=t.button,i}function U(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=e.querySelector(`.wui-tour-card:not(.wui-tour-end)`),o=e.querySelector(`.wui-tour-spot`),s=e.querySelector(`[role=status]`),c=H(r,t,i),l=c.querySelector(`.wui-tour-end-button`),u=new AbortController;return new Promise(d=>{let f=()=>{u.abort(),d()};if(n?.aborted){f();return}let p={signal:u.signal};n?.addEventListener(`abort`,f,p),l.addEventListener(`click`,f,p),r.addEventListener(`keydown`,e=>{e.altKey||e.ctrlKey||e.metaKey||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),f()):e.key===`Tab`&&i&&(e.preventDefault(),l.focus()))},{capture:!0,signal:u.signal}),i&&r.addEventListener(`focusin`,e=>{c.contains(e.target)||l.focus()},p);let m=()=>{u.signal.aborted||(a.hidden=!0,F(o,a,null),e.append(c),w(c),s.textContent=[t.title,t.message].filter(Boolean).join(`. `),l.focus())},h=T(a);h?h.then(m):m()})}var W=`
|
|
6
|
+
:host {
|
|
7
|
+
all: initial;
|
|
8
|
+
${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay":`0 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out-quart":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-motion-duration":`200ms`,"--wui-tour-motion-ease":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-spot-duration":`240ms`,"--wui-tour-spot-ease":`cubic-bezier(0.32, 0.72, 0, 1)`,"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-ink":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-primary-text":`#FFFFFF`,"--color-success-soft":`#E8FAEE`,"--color-success-text":`#0e7531`,"--color-on-scrim":`#FFFFFF`,"--color-scrim-strong":`color-mix(in srgb, #071437 62%, transparent)`,"--color-surface":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-bg-muted":`#F5F6FA`}).map(([e,t])=>` ${e}: ${t};`).join(`
|
|
9
|
+
`)}
|
|
10
|
+
}
|
|
11
|
+
*, *::before, *::after {
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
}
|
|
14
|
+
[hidden] {
|
|
15
|
+
display: none !important;
|
|
16
|
+
}
|
|
17
|
+
.visually-hidden {
|
|
18
|
+
position: absolute !important;
|
|
19
|
+
width: 1px !important;
|
|
20
|
+
height: 1px !important;
|
|
21
|
+
padding: 0 !important;
|
|
22
|
+
margin: -1px !important;
|
|
23
|
+
overflow: hidden !important;
|
|
24
|
+
clip: rect(0, 0, 0, 0) !important;
|
|
25
|
+
white-space: nowrap !important;
|
|
26
|
+
border: 0 !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.btn {
|
|
30
|
+
display: inline-block;
|
|
31
|
+
margin: 0;
|
|
32
|
+
padding: 0.25rem 0.5rem;
|
|
33
|
+
border: 1px solid transparent;
|
|
34
|
+
border-radius: 0.375rem;
|
|
35
|
+
background: transparent;
|
|
36
|
+
font: inherit;
|
|
37
|
+
font-size: 0.875rem;
|
|
38
|
+
font-weight: 500;
|
|
39
|
+
line-height: 1.5;
|
|
40
|
+
text-align: center;
|
|
41
|
+
text-decoration: none;
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
.btn:focus-visible {
|
|
46
|
+
outline: 2px solid var(--color-primary);
|
|
47
|
+
outline-offset: 2px;
|
|
48
|
+
}
|
|
49
|
+
.btn-primary {
|
|
50
|
+
background: var(--color-primary);
|
|
51
|
+
border-color: var(--color-primary);
|
|
52
|
+
color: var(--color-primary-text);
|
|
53
|
+
}
|
|
54
|
+
.btn-primary:hover {
|
|
55
|
+
background: var(--color-primary-hover);
|
|
56
|
+
border-color: var(--color-primary-hover);
|
|
57
|
+
}
|
|
58
|
+
.btn-outline-secondary {
|
|
59
|
+
border-color: var(--color-text-muted);
|
|
60
|
+
color: var(--color-text-muted);
|
|
61
|
+
}
|
|
62
|
+
.btn-outline-secondary:hover {
|
|
63
|
+
background: var(--color-bg-muted);
|
|
64
|
+
color: var(--color-text);
|
|
65
|
+
}
|
|
66
|
+
.btn-link {
|
|
67
|
+
font-weight: 400;
|
|
68
|
+
color: var(--color-primary-ink);
|
|
69
|
+
text-decoration: underline;
|
|
70
|
+
}
|
|
71
|
+
.btn-link:hover {
|
|
72
|
+
color: var(--color-primary-hover);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.wui-tour-layer {
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
font-family: "Webority Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
78
|
+
font-size: 16px;
|
|
79
|
+
font-weight: 400;
|
|
80
|
+
line-height: 1.5;
|
|
81
|
+
color: var(--color-text);
|
|
82
|
+
text-align: start;
|
|
83
|
+
}
|
|
84
|
+
.wui-tour-card {
|
|
85
|
+
pointer-events: auto;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.wui-tour-layer {
|
|
89
|
+
position: fixed;
|
|
90
|
+
inset: 0;
|
|
91
|
+
z-index: var(--wui-z-tour);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.wui-tour-spot {
|
|
95
|
+
position: fixed;
|
|
96
|
+
box-shadow: 0 0 0 2px var(--color-primary), 0 0 0 100vmax var(--color-scrim-strong);
|
|
97
|
+
pointer-events: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.wui-tour-card {
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
gap: 8px;
|
|
104
|
+
width: min(360px, 100vw - 16px);
|
|
105
|
+
padding: 16px;
|
|
106
|
+
overflow-y: auto;
|
|
107
|
+
background: var(--color-surface);
|
|
108
|
+
color: var(--color-text);
|
|
109
|
+
border: 1px solid var(--color-border);
|
|
110
|
+
border-radius: var(--wui-radius-lg);
|
|
111
|
+
corner-shape: squircle;
|
|
112
|
+
box-shadow: var(--wui-shadow-overlay);
|
|
113
|
+
}
|
|
114
|
+
.wui-tour-card:focus {
|
|
115
|
+
outline: none;
|
|
116
|
+
}
|
|
117
|
+
.wui-tour-card:focus-visible {
|
|
118
|
+
outline: var(--wui-focus-ring-width) solid var(--color-focus-ring);
|
|
119
|
+
outline-offset: var(--wui-focus-ring-offset);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.wui-tour-title {
|
|
123
|
+
margin: 0;
|
|
124
|
+
font-size: 16px;
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.wui-tour-text {
|
|
129
|
+
margin: 0;
|
|
130
|
+
font-size: 14px;
|
|
131
|
+
color: var(--color-text-muted);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.wui-tour-actions {
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
justify-content: space-between;
|
|
138
|
+
gap: 8px;
|
|
139
|
+
margin-top: 4px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.wui-tour-nav {
|
|
143
|
+
display: flex;
|
|
144
|
+
gap: 8px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.wui-tour-skip {
|
|
148
|
+
color: var(--color-text-muted);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.wui-tour-back,
|
|
152
|
+
.wui-tour-next {
|
|
153
|
+
min-width: 64px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@keyframes wui-tour-fade-in {
|
|
157
|
+
from {
|
|
158
|
+
opacity: 0;
|
|
159
|
+
}
|
|
160
|
+
to {
|
|
161
|
+
opacity: 1;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
@keyframes wui-tour-card-enter {
|
|
165
|
+
from {
|
|
166
|
+
opacity: 0;
|
|
167
|
+
scale: 0.96;
|
|
168
|
+
translate: var(--wui-tour-card-lift, 0 6px);
|
|
169
|
+
}
|
|
170
|
+
to {
|
|
171
|
+
opacity: 1;
|
|
172
|
+
scale: 1;
|
|
173
|
+
translate: 0 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
.wui-tour-layer[data-state=leaving],
|
|
177
|
+
.wui-tour-card[data-state=leaving] {
|
|
178
|
+
opacity: 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.wui-tour-layer[data-state=leaving],
|
|
182
|
+
.wui-tour-layer[data-state=leaving] * {
|
|
183
|
+
pointer-events: none;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
187
|
+
.wui-tour-layer {
|
|
188
|
+
animation: wui-tour-fade-in var(--wui-tour-motion-duration) var(--wui-tour-motion-ease);
|
|
189
|
+
}
|
|
190
|
+
.wui-tour-layer[data-state=leaving] {
|
|
191
|
+
transition: opacity var(--wui-tour-motion-duration) var(--wui-tour-motion-ease);
|
|
192
|
+
}
|
|
193
|
+
.wui-tour-spot {
|
|
194
|
+
transition: top var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), left var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), width var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), height var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), border-radius var(--wui-tour-spot-duration) var(--wui-tour-spot-ease);
|
|
195
|
+
}
|
|
196
|
+
.wui-tour-spot[data-tracking] {
|
|
197
|
+
transition: none;
|
|
198
|
+
}
|
|
199
|
+
.wui-tour-card {
|
|
200
|
+
--wui-tour-card-lift: 0 6px;
|
|
201
|
+
transform-origin: top center;
|
|
202
|
+
}
|
|
203
|
+
.wui-tour-card[data-placement=top] {
|
|
204
|
+
--wui-tour-card-lift: 0 -6px;
|
|
205
|
+
transform-origin: bottom center;
|
|
206
|
+
}
|
|
207
|
+
.wui-tour-card[data-placement=bottom] {
|
|
208
|
+
--wui-tour-card-lift: 0 6px;
|
|
209
|
+
transform-origin: top center;
|
|
210
|
+
}
|
|
211
|
+
.wui-tour-card[data-placement=left] {
|
|
212
|
+
--wui-tour-card-lift: -6px 0;
|
|
213
|
+
transform-origin: right center;
|
|
214
|
+
}
|
|
215
|
+
.wui-tour-card[data-placement=right] {
|
|
216
|
+
--wui-tour-card-lift: 6px 0;
|
|
217
|
+
transform-origin: left center;
|
|
218
|
+
}
|
|
219
|
+
.wui-tour-card[data-placement=overlap],
|
|
220
|
+
.wui-tour-card[data-placement=center] {
|
|
221
|
+
--wui-tour-card-lift: 0 0;
|
|
222
|
+
transform-origin: center;
|
|
223
|
+
}
|
|
224
|
+
.wui-tour-card[data-state=entering] {
|
|
225
|
+
animation: wui-tour-card-enter var(--wui-tour-motion-duration) var(--wui-tour-motion-ease) var(--wui-tour-card-delay, 0ms) both;
|
|
226
|
+
}
|
|
227
|
+
.wui-tour-card[data-state=leaving] {
|
|
228
|
+
transition: opacity calc(var(--wui-tour-motion-duration) / 2) var(--wui-tour-motion-ease);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
@media (prefers-reduced-motion: reduce) {
|
|
232
|
+
.wui-tour-layer {
|
|
233
|
+
animation: wui-tour-fade-in 120ms linear;
|
|
234
|
+
}
|
|
235
|
+
.wui-tour-layer[data-state=leaving] {
|
|
236
|
+
transition: opacity 120ms linear;
|
|
237
|
+
}
|
|
238
|
+
.wui-tour-card[data-state=entering] {
|
|
239
|
+
animation: wui-tour-fade-in 120ms linear both;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
.wui-tour-progress-bar {
|
|
243
|
+
display: flex;
|
|
244
|
+
gap: 4px;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.wui-tour-progress-segment {
|
|
248
|
+
flex: 1 1 0;
|
|
249
|
+
height: 4px;
|
|
250
|
+
border-radius: 999px;
|
|
251
|
+
background: var(--color-border);
|
|
252
|
+
}
|
|
253
|
+
.wui-tour-progress-segment[data-filled] {
|
|
254
|
+
background: var(--color-primary);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.wui-tour-position {
|
|
258
|
+
margin: 0;
|
|
259
|
+
font-size: 12px;
|
|
260
|
+
color: var(--color-text-muted);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.wui-tour-layer {
|
|
264
|
+
padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.wui-tour-card:has(.wui-tour-arrow:not([hidden])) {
|
|
268
|
+
overflow: visible;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.wui-tour-arrow {
|
|
272
|
+
position: absolute;
|
|
273
|
+
width: 8px;
|
|
274
|
+
height: 8px;
|
|
275
|
+
background: var(--color-surface);
|
|
276
|
+
border: 1px solid var(--color-border);
|
|
277
|
+
rotate: 45deg;
|
|
278
|
+
pointer-events: none;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.wui-tour-card[data-placement=bottom] .wui-tour-arrow {
|
|
282
|
+
top: -5px;
|
|
283
|
+
border-right-color: rgba(0, 0, 0, 0);
|
|
284
|
+
border-bottom-color: rgba(0, 0, 0, 0);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.wui-tour-card[data-placement=top] .wui-tour-arrow {
|
|
288
|
+
bottom: -5px;
|
|
289
|
+
border-top-color: rgba(0, 0, 0, 0);
|
|
290
|
+
border-left-color: rgba(0, 0, 0, 0);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.wui-tour-card[data-placement=right] .wui-tour-arrow {
|
|
294
|
+
left: -5px;
|
|
295
|
+
border-top-color: rgba(0, 0, 0, 0);
|
|
296
|
+
border-right-color: rgba(0, 0, 0, 0);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.wui-tour-card[data-placement=left] .wui-tour-arrow {
|
|
300
|
+
right: -5px;
|
|
301
|
+
border-bottom-color: rgba(0, 0, 0, 0);
|
|
302
|
+
border-left-color: rgba(0, 0, 0, 0);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@media (max-width: 575.98px) {
|
|
306
|
+
.wui-tour-card {
|
|
307
|
+
width: calc(100vw - 16px);
|
|
308
|
+
}
|
|
309
|
+
.wui-tour-actions .btn {
|
|
310
|
+
display: inline-flex;
|
|
311
|
+
align-items: center;
|
|
312
|
+
justify-content: center;
|
|
313
|
+
min-height: 44px;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
.wui-tour-media {
|
|
317
|
+
position: relative;
|
|
318
|
+
order: -1;
|
|
319
|
+
flex: none;
|
|
320
|
+
aspect-ratio: 16/9;
|
|
321
|
+
margin: -16px -16px 4px;
|
|
322
|
+
overflow: hidden;
|
|
323
|
+
background: var(--color-border);
|
|
324
|
+
}
|
|
325
|
+
.wui-tour-media>img,
|
|
326
|
+
.wui-tour-media>video {
|
|
327
|
+
display: block;
|
|
328
|
+
width: 100%;
|
|
329
|
+
height: 100%;
|
|
330
|
+
object-fit: cover;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.wui-tour-card[data-media=welcome] {
|
|
334
|
+
width: min(420px, 100vw - 16px);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.wui-tour-media-toggle {
|
|
338
|
+
position: absolute;
|
|
339
|
+
inset-block-end: 8px;
|
|
340
|
+
inset-inline-end: 8px;
|
|
341
|
+
display: inline-flex;
|
|
342
|
+
align-items: center;
|
|
343
|
+
justify-content: center;
|
|
344
|
+
width: 44px;
|
|
345
|
+
height: 44px;
|
|
346
|
+
padding: 0;
|
|
347
|
+
border: 0;
|
|
348
|
+
border-radius: 50%;
|
|
349
|
+
background: var(--color-scrim-strong);
|
|
350
|
+
color: var(--color-on-scrim);
|
|
351
|
+
cursor: pointer;
|
|
352
|
+
}
|
|
353
|
+
.wui-tour-media-toggle>svg {
|
|
354
|
+
width: 20px;
|
|
355
|
+
height: 20px;
|
|
356
|
+
fill: currentColor;
|
|
357
|
+
}
|
|
358
|
+
.wui-tour-media-toggle:focus-visible {
|
|
359
|
+
outline: 2px solid var(--color-on-scrim);
|
|
360
|
+
outline-offset: 2px;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.wui-tour-layer[data-advance] {
|
|
364
|
+
pointer-events: none;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-card {
|
|
368
|
+
pointer-events: auto;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-spot::before {
|
|
372
|
+
content: "";
|
|
373
|
+
position: absolute;
|
|
374
|
+
inset: -100vmax;
|
|
375
|
+
pointer-events: auto;
|
|
376
|
+
clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 100vmax 100vmax, calc(100% - 100vmax) 100vmax, calc(100% - 100vmax) calc(100% - 100vmax), 100vmax calc(100% - 100vmax), 100vmax 100vmax);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.wui-tour-hint {
|
|
380
|
+
margin: 0;
|
|
381
|
+
font-size: 14px;
|
|
382
|
+
font-weight: 600;
|
|
383
|
+
color: var(--color-text);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
@keyframes wui-tour-pulse {
|
|
387
|
+
from {
|
|
388
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 85%, transparent);
|
|
389
|
+
}
|
|
390
|
+
to {
|
|
391
|
+
box-shadow: 0 0 0 14px color-mix(in srgb, var(--color-primary) 0%, transparent);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
395
|
+
.wui-tour-spot[data-advance]::after {
|
|
396
|
+
content: "";
|
|
397
|
+
position: absolute;
|
|
398
|
+
inset: 0;
|
|
399
|
+
border-radius: inherit;
|
|
400
|
+
corner-shape: inherit;
|
|
401
|
+
pointer-events: none;
|
|
402
|
+
animation: wui-tour-pulse 600ms var(--wui-ease-out-quart) var(--wui-tour-spot-duration);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
@keyframes wui-tour-check {
|
|
406
|
+
from {
|
|
407
|
+
stroke-dashoffset: 24;
|
|
408
|
+
}
|
|
409
|
+
to {
|
|
410
|
+
stroke-dashoffset: 0;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
.wui-tour-end[data-layout=center] {
|
|
414
|
+
--wui-tour-card-lift: 0 0;
|
|
415
|
+
position: fixed;
|
|
416
|
+
top: 50%;
|
|
417
|
+
left: 50%;
|
|
418
|
+
transform: translate(-50%, -50%);
|
|
419
|
+
transform-origin: center;
|
|
420
|
+
align-items: center;
|
|
421
|
+
gap: 8px;
|
|
422
|
+
width: min(420px, 100vw - 16px);
|
|
423
|
+
max-height: calc(100vh - 16px);
|
|
424
|
+
padding: 24px;
|
|
425
|
+
text-align: center;
|
|
426
|
+
}
|
|
427
|
+
.wui-tour-end[data-layout=center] .wui-tour-actions {
|
|
428
|
+
justify-content: center;
|
|
429
|
+
margin-top: 8px;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.wui-tour-end-mark {
|
|
433
|
+
display: inline-flex;
|
|
434
|
+
flex: none;
|
|
435
|
+
align-items: center;
|
|
436
|
+
justify-content: center;
|
|
437
|
+
width: 48px;
|
|
438
|
+
height: 48px;
|
|
439
|
+
border-radius: 50%;
|
|
440
|
+
background: var(--color-success-soft);
|
|
441
|
+
color: var(--color-success-text);
|
|
442
|
+
}
|
|
443
|
+
.wui-tour-end-mark>svg {
|
|
444
|
+
width: 26px;
|
|
445
|
+
height: 26px;
|
|
446
|
+
}
|
|
447
|
+
.wui-tour-end-mark path {
|
|
448
|
+
fill: none;
|
|
449
|
+
stroke: currentColor;
|
|
450
|
+
stroke-width: 2.5;
|
|
451
|
+
stroke-linecap: round;
|
|
452
|
+
stroke-linejoin: round;
|
|
453
|
+
stroke-dasharray: 24;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.wui-tour-end-title {
|
|
457
|
+
font-size: 18px;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.wui-tour-end-message {
|
|
461
|
+
text-wrap: balance;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.wui-tour-end-button {
|
|
465
|
+
min-width: 120px;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
469
|
+
.wui-tour-end-mark path {
|
|
470
|
+
animation: wui-tour-check 300ms var(--wui-ease-out-quart) calc(var(--wui-tour-card-delay, 0ms) + 120ms) both;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
`,G=`wui-tour-media`,ue=`wui-tour-media-toggle`,K=`http://www.w3.org/2000/svg`,de=`M6 5h4v14H6zM14 5h4v14h-4z`,fe=`M8 5v14l11-7z`,pe={pause:`Pause animation`,play:`Play animation`},me=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function he(e){let t=document.createElementNS(K,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(K,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function ge(e){let t=document.createElement(`img`);return t.setAttribute(`alt`,e.mediaAlt??``),t.setAttribute(`width`,`1280`),t.setAttribute(`height`,`720`),t.setAttribute(`loading`,`lazy`),t.setAttribute(`decoding`,`async`),t.setAttribute(`src`,e.media),t}function _e(e,t){let n=document.createElement(`video`);return n.muted=!0,n.setAttribute(`muted`,``),n.loop=!0,n.setAttribute(`playsinline`,``),t&&n.setAttribute(`autoplay`,``),n.setAttribute(`preload`,t?`auto`:`metadata`),e.mediaAlt&&n.setAttribute(`aria-label`,e.mediaAlt),e.mediaPoster&&n.setAttribute(`poster`,e.mediaPoster),n.setAttribute(`src`,e.media),n}function ve(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=ue;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(he(r?de:fe))};return e.addEventListener(`play`,()=>r()),e.addEventListener(`pause`,()=>r()),n.addEventListener(`click`,()=>{e.paused?e.play()?.catch(()=>r()):e.pause()}),r(e.hasAttribute(`autoplay`)),n}function ye(e){let t=e.querySelector(`:scope > .${G}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function be(e,t,n=pe){if(ye(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=G,t.mediaType===`video`){let e=_e(t,!me());r.append(e,ve(e,n))}else r.appendChild(ge(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var xe=`Step {current} of {total}`;function Se(e){let t=new Set;return{drop:e=>{t.add(e)},position:e=>{t.delete(e);let n=0;for(let r of t)r<e&&n++;return e+1-n},total:()=>e-t.size}}function Ce(e,t,n){return(e.getAttribute(`progress-label`)||xe).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function we(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);i.textContent=t;let a=e.querySelector(`.wui-tour-progress-bar`);if(!a){let t=e.ownerDocument,n=t.createElement(`div`);n.className=`wui-tour-progress`,n.setAttribute(`aria-hidden`,`true`),a=t.createElement(`div`),a.className=`wui-tour-progress-bar`,n.append(a),i.before(n)}let o=a.children;for(;o.length<r;){let t=e.ownerDocument.createElement(`span`);t.className=`wui-tour-progress-segment`,a.append(t)}for(;o.length>r;)a.lastElementChild.remove();for(let e=0;e<o.length;e++)o[e].toggleAttribute(`data-filled`,e<n)}var Te=`wui-tour-step`,Ee=`wui-tour-host`,De=`wui-tour-seen:`,q=`data-tracking`,Oe={back:`Back`,next:`Next`,skip:`Skip`,done:`Done`,mediaPause:`Pause animation`,mediaPlay:`Play animation`,endTitle:`You're all set`,endMessage:`You know your way around now. Enjoy exploring.`,endButton:`Done`},ke={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`,mediaPause:`media-pause-label`,mediaPlay:`media-play-label`,endTitle:`end-title`,endMessage:`end-message`,endButton:`end-button`},Ae=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],J={index:null,position:null,total:null},je=0;function Y(e=De,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var X=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Z=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),Q=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function Me(e){if(`adoptedStyleSheets`in e&&typeof CSSStyleSheet==`function`&&`replaceSync`in CSSStyleSheet.prototype){$||($=new CSSStyleSheet,$.replaceSync(W)),e.adoptedStyleSheets=[$];return}let t=document.createElement(`style`);t.textContent=W,e.appendChild(t)}var Ne=class extends e{static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=null,this._outer=null,this._shadow=null,this._unbindAdvance=null,this._ending=null,this._seenMark=null}connectedCallback(){this.hasAttribute(`open`)&&this.start()}disconnectedCallback(){this.stop()}attributeChangedCallback(e,t,n){e!==`open`||!this.isConnected||(n===null?this.stop():this.start())}get tourId(){return this.getAttribute(`tour-id`)||``}set tourId(e){e==null||e===``?this.removeAttribute(`tour-id`):this.setAttribute(`tour-id`,String(e))}get isolated(){return this.hasAttribute(`isolated`)}set isolated(e){this.toggleAttribute(`isolated`,e===!0||e===``||e===`true`)}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${Te}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:e.textContent.trim()};for(let[n,r]of Ae)e.hasAttribute(r)&&(t[n]=e.getAttribute(r));return t})}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?Y():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(ke[e])||Oe[e]}_endDialogText(){return this.getAttribute(`end-dialog`)===`false`?null:{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`)}}_markSeen(e){let t=this._store();return t?t.markSeen(this.tourId,e):null}async start(){if(this._running)return;this._running=!0;let e=++this._run;this.hasAttribute(`open`)||this.setAttribute(`open`,``);try{await this._start(e)}catch(t){throw e===this._run&&(this._running=!1),t}}async _start(e){this._steps=this._stepList(),this._progress=Se(this._steps.length);let t=this._store();if(t&&!this.tourId)throw Error(`<wui-tour> needs a tour-id to use a seen store.`);if(t&&await t.isSeen(this.tourId)){e===this._run&&this._finish(`alreadySeen`);return}for(let[e,t]of this._steps.entries())t.target&&!X(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);if(e===this._run){if(!n){this._finish(`noTargets`);return}this._firstIndex=n.index,this.dispatchEvent(new CustomEvent(`wui-tour:start`,{bubbles:!0,detail:{total:this._progress.total()}})),e===this._run&&(this._build(),this._show(n))}}next(){return this._move(1)}back(){return!this._current||this._current.index<=this._firstIndex?Promise.resolve():this._move(-1)}async goTo(e){if(this._current){if(!Number.isInteger(e)||e<0||e>=this._steps.length)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);await this._go(e,1)}}stop(){this._running&&(this._run++,this._teardown(),this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`))}async _locate(e,t,n){let r=this._steps;for(let i=e;i>=0&&i<r.length;i+=t){let e=r[i];if(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target);if(X(t))return this._progress.position(i),{index:i,target:t};this._progress.drop(i)}return null}async _beforeStep(e,t){let n=[];this.dispatchEvent(new CustomEvent(`wui-tour:beforestep`,{bubbles:!0,detail:{step:e,index:t,wait:e=>n.push(e)}})),await Promise.all(n),typeof this.onBeforeStep==`function`&&await this.onBeforeStep(e,t)}_build(){let e=`wui-tour-${++je}`,n=document.createElement(`div`);n.className=`wui-tour-layer`,n.innerHTML=`
|
|
475
|
+
<div class="wui-tour-spot" aria-hidden="true"></div>
|
|
476
|
+
<div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${e}-title" aria-describedby="${e}-text">
|
|
477
|
+
<p class="wui-tour-position"></p>
|
|
478
|
+
<h2 class="wui-tour-title" id="${e}-title"></h2>
|
|
479
|
+
<p class="wui-tour-text" id="${e}-text"></p>
|
|
480
|
+
<div class="wui-tour-actions">
|
|
481
|
+
<button type="button" class="btn btn-sm btn-link wui-tour-skip"></button>
|
|
482
|
+
<div class="wui-tour-nav">
|
|
483
|
+
<button type="button" class="btn btn-sm btn-outline-secondary wui-tour-back"></button>
|
|
484
|
+
<button type="button" class="btn btn-sm btn-primary wui-tour-next"></button>
|
|
485
|
+
</div>
|
|
486
|
+
</div>
|
|
487
|
+
</div>
|
|
488
|
+
<div class="visually-hidden" role="status" aria-live="polite"></div>`;let i=n;this._shadow=null,this.isolated&&(i=document.createElement(Ee),this._shadow=i.attachShadow({mode:`open`}),Me(this._shadow),this._shadow.appendChild(n)),document.body.appendChild(i),document.documentElement.setAttribute(r,``),this._outer=i,this._layer=n,this._spot=n.querySelector(`.wui-tour-spot`),this._card=n.querySelector(`.wui-tour-card`),this._live=n.querySelector(`[role=status]`),this._card.querySelector(`.wui-tour-skip`).addEventListener(`click`,()=>this._close(`skipped`,`button`)),this._card.querySelector(`.wui-tour-back`).addEventListener(`click`,()=>this._move(-1)),this._card.querySelector(`.wui-tour-next`).addEventListener(`click`,()=>this._move(1)),this._shadow&&this._card.removeAttribute(`aria-modal`),this._onKey=e=>this._key(e),this._onFocusIn=e=>{if(!this._layer||this._ending)return;let t=this._current,n=t?this._steps[t.index]:null;_(this._layer,n,t?.target??null,e.target)||this._card.focus()},document.addEventListener(`keydown`,this._onKey,!0),this._shadow||document.addEventListener(`focusin`,this._onFocusIn),t(i,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_show(e){this._current=e;let{index:t,target:n}=e,r=this._steps[t],i=this._card,a=this._progress.position(t),o=this._progress.total(),s=a===o&&!this._endDialogText(),c=Ce(this,a,o);we(i,{text:c,position:a,total:o}),be(i,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)});let l=h(this,{layer:this._layer,spot:this._spot,card:i},r,n),u=i.querySelector(`.wui-tour-title`);u.textContent=r.title||``,u.hidden=!r.title,i.querySelector(`.wui-tour-text`).textContent=r.description||``,i.querySelector(`.wui-tour-skip`).textContent=this._label(`skip`),i.querySelector(`.wui-tour-back`).textContent=this._label(`back`),i.querySelector(`.wui-tour-back`).hidden=t<=this._firstIndex,i.querySelector(`.wui-tour-next`).textContent=this._label(s?`done`:`next`);let d=[c,r.title,r.description].filter(Boolean).join(`. `);this._live.textContent=l?[d,l].join(/[.!?]$/.test(d)?` `:`. `):d,ce(i,n),this._spot.removeAttribute(q),this._place(),w(i),this._unbindAdvance?.(),this._unbindAdvance=g(r,n,()=>this._move(1));let f=this._active();(i.contains(f)?!f.hidden:this._shadow!==null&&Z(Q()))||i.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:a,total:o}}))}_place(){!this._current||!this._layer||F(this._spot,this._card,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot.style.cssText;this._place(),this._spot.style.cssText!==e&&this._spot.setAttribute(q,``)}async _move(e){this._current&&await this._go(this._current.index+e,e)}async _go(e,t){if(!this._current||this._moving)return;this._moving=!0;let n=this._run;try{let r=await this._locate(e,t,n);if(n!==this._run)return;if(r){let e=T(this._card);if(e&&await e,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText();if(e&&await this._showEnd(e),n!==this._run)return;await this._close(`finished`)}}finally{this._moving=!1}}_showEnd(e){return this._unbindAdvance?.(),this._unbindAdvance=null,h(this,{layer:this._layer,spot:this._spot,card:this._card},null,null),this._spot.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),U(this._layer,e,this._ending.signal)}_key(e){if(!(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(e.key===`ArrowRight`||e.key===`ArrowLeft`){if(Z(e.composedPath?.()[0]??e.target))return;e.preventDefault(),e.key===`ArrowRight`?this._move(1):this._current.index>this._firstIndex&&this._move(-1)}else if(e.key===`Tab`&&!this._shadow){let{index:t,target:n}=this._current;ee(e,{card:this._card,active:this._active(),step:this._steps[t],target:n})}}}_teardown(){if(!this._layer)return;document.removeEventListener(`keydown`,this._onKey,!0),document.removeEventListener(`focusin`,this._onFocusIn);let e=!this._shadow||this._shadow.activeElement!==null||!document.activeElement||document.activeElement===document.body;this._unbindAdvance?.(),this._unbindAdvance=null,this._ending?.abort(),this._ending=null,this._seenMark=null,n(this._outer),ae(this._outer),document.documentElement.removeAttribute(r),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let t=this._returnFocus;this._returnFocus=null,e&&t?.isConnected&&t.focus?.()}async _close(e,t=null){let n=this._run,r=this._current,i=r?{index:r.index,position:this._progress.position(r.index),total:this._progress.total()}:J,a=this._seenMark;this._teardown();try{n===this._run&&await(a??this._markSeen(e))}finally{this._finish(e,i,t)}}_finish(e,t=J,n=null){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e,...t,via:n}}))}};export{Y as n,Ne as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiAutocomplete-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiAutocomplete-CE7wT-Vc.js";e(`wui-autocomplete`,t);export{t as WuiAutocomplete};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiCommandPalette-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiCommandPalette-CcmFOWNc.js";e(`wui-command-palette`,t);export{t as WuiCommandPalette};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiCountrySelect-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiCountrySelect-D92rrSvW.js";e(`wui-country-select`,t);export{t as WuiCountrySelect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiDateRange-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiDateRange-CrVodISl.js";e(`wui-date-range`,t);export{t as WuiDateRange};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiDatePicker-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiDatePicker-_BzQ2m1e.js";e(`wui-datepicker`,t);export{t as WuiDatePicker};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiMultiSelect-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiMultiSelect-WUNCdkzW.js";e(`wui-multiselect`,t);export{t as WuiMultiSelect};
|
package/dist/elements/phone.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiPhone-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiPhone-DtuXp6o2.js";e(`wui-phone`,t);export{t as WuiPhone};
|
package/dist/elements/select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiSelect-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiSelect-CT8tgsxL.js";e(`wui-select`,t);export{t as WuiSelect};
|
package/dist/elements/tour.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-BlsR4tqa.js";import{n as t,t as n}from"../WuiTour-
|
|
1
|
+
import{n as e}from"../elementBase-BlsR4tqa.js";import{n as t,t as n}from"../WuiTour-DW3kPaR9.js";e(`wui-tour`,n);export{n as WuiTour,t as createLocalSeenStore};
|
package/dist/helpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./formatters-BAE__8ye.js";import{t as h}from"./iconGlyphs.g-CUm_mfze.js";import{
|
|
1
|
+
import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./formatters-BAE__8ye.js";import{t as h}from"./iconGlyphs.g-CUm_mfze.js";import{o as g}from"./optionLabel-BBaur8Bs.js";import{n as _,t as v}from"./copyText-DM5HhXjf.js";import{t as y}from"./textMatch-wdY7XLIc.js";import{a as b,c as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./notificationDays-pYmoU0g6.js";import{a as O,c as k,d as A,f as j,i as M,l as N,m as P,n as F,o as I,p as L,r as R,s as z,t as B,u as V}from"./shortcutKeys-BQiDpsTJ.js";import{$ as H,A as U,B as W,C as G,D as K,E as q,F as J,G as Y,H as X,I as Z,J as Q,K as $,L as ee,M as te,N as ne,O as re,P as ie,Q as ae,R as oe,S as se,T as ce,U as le,V as ue,W as de,X as fe,Y as pe,Z as me,_ as he,a as ge,b as _e,c as ve,d as ye,f as be,g as xe,h as Se,i as Ce,j as we,k as Te,l as Ee,m as De,n as Oe,o as ke,p as Ae,q as je,s as Me,t as Ne,u as Pe,v as Fe,w as Ie,x as Le,y as Re,z as ze}from"./themeTransition-C61cbmZ4.js";export{Y as AVATAR_ACCEPT,$ as AVATAR_MAX_SIZE_MB,je as AVATAR_OUTPUT_SIZE,Q as AVATAR_OUTPUT_TYPE,pe as AVATAR_PREVIEW_SIZES,fe as AVATAR_TEXT,v as COPY_FEEDBACK_MS,p as CURRENCIES,c as DATE_PATTERNS,ee as DEFAULT_IMAGE_ACCEPT,oe as DEFAULT_MAX_SIZE_MB,se as DEFAULT_PASSWORD_RULES,G as DEFAULT_REQUIREMENTS_TITLE,Ne as DEFAULT_THEME_EFFECT,Oe as DEFAULT_THEME_STORAGE_KEY,d as DURATION_UNITS,a as EMPTY_VALUE,e as FORMAT_STYLES,l as IST_TIME_ZONE,B as LIST_KEYS,K as MASK_INPUT_TYPES,re as MASK_NAMES,f as MONEY_UNITS,D as NOTIFICATION_COUNT_CAP,C as NOTIFICATION_TEXT,Re as SCROLL_EDGE_SELECTOR,F as SELECT_KEY,R as SHORTCUTS_OFF_ATTRIBUTE,M as SHORTCUT_EVENT,O as SHORTCUT_SCOPE_ATTRIBUTE,I as SHORTCUT_TEXT,Ce as THEME_CHANGE_EVENT,ge as THEME_EFFECTS,ke as THEME_EFFECT_DURATION,Me as THEME_LIVE_NAME,ve as THEME_MODES,Ee as THEME_SWITCHING_CLASS,ze as acceptLabel,Pe as applyTheme,z as ariaKeyShortcuts,Te as attachInputMask,_e as attachScrollEdges,me as avatarCropOptions,ae as avatarUnreadableMessage,Ie as buildPasswordRules,_ as copyTextToClipboard,ce as evaluatePassword,t as formatCompact,o as formatCurrency,m as formatDate,n as formatDuration,U as formatMasked,r as formatNumber,u as formatPercent,s as formatValue,h as glyphSvg,T as groupNotificationsByDay,k as inShortcutScope,we as initInputMasks,Le as initScrollEdges,H as isHeicFile,W as isImageFile,ue as isImageOnlyAccept,te as isMaskPattern,X as isPdfFile,N as isTypingTarget,ne as maskedPostValue,y as matchSegments,le as matchesAccept,V as moveFocus,ye as nextTheme,S as notificationCountText,b as notificationDayHeading,w as notificationTime,E as notificationTriggerLabel,x as notificationUnreadAnnouncement,q as passwordSatisfies,ie as postedMasked,J as rawMasked,be as readStoredTheme,Z as resolveMask,Ae as resolveTheme,A as runShortcut,j as shortcutKey,L as shortcutName,P as shortcutsOff,De as storeTheme,Se as themeBootScript,xe as themeKeyframes,i as toInstant,he as transitionTheme,de as validateFile,Fe as watchSystemTheme,g as withTrustedLabel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./iconGlyphs.g-CUm_mfze.js";var t=Symbol(`wui.trustedHtml`),n=e=>({...e,[t]:!0}),r=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),i=t=>{if(!t)return``;let n=String(t).toLowerCase().replace(/[^a-z0-9-]/g,``);return n?e(n):``},a=e=>`wui-flag wui-flag-${e}`,o=e=>{let t=String(e??``).toLowerCase();return/^[a-z]{2}$/.test(t)?`<span class="${a(t)}" aria-hidden="true"></span>`:``},s=e=>{if(e==null)return``;let n=e[t]?String(e.label??``):r(e.label),a=o(e.flag)+i(e.icon);return a?`<span class="wui-opt-label">${a}${n}</span>`:n};export{
|
|
1
|
+
import{t as e}from"./iconGlyphs.g-CUm_mfze.js";var t=Symbol(`wui.trustedHtml`),n=e=>({...e,[t]:!0}),r=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),i=t=>{if(!t)return``;let n=String(t).toLowerCase().replace(/[^a-z0-9-]/g,``);return n?e(n):``},a=e=>`wui-flag wui-flag-${e}`,o=e=>{let t=String(e??``).toLowerCase();return/^[a-z]{2}$/.test(t)?`<span class="${a(t)}" aria-hidden="true"></span>`:``},s=e=>{if(e==null)return``;let n=e[t]?String(e.label??``):r(e.label),a=o(e.flag)+i(e.icon);return a?`<span class="wui-opt-label">${a}${n}</span>`:n},c=e=>String(e??``).replace(/<[^>]*>/g,``),l=new WeakMap,u=e=>{if(e==null)return``;if(!e[t])return c(e.label);let n=l.get(e);if(n&&n.label===e.label)return n.text;let r=document.createElement(`template`);r.innerHTML=String(e.label??``);let i=r.content.textContent;return l.set(e,{label:e.label,text:i}),i};export{c as a,u as i,r as n,n as o,s as r,t};
|
|
@@ -64,9 +64,9 @@ export type ChatStreamOptions = {
|
|
|
64
64
|
/**
|
|
65
65
|
* Called for each event
|
|
66
66
|
* before the end of the turn: `delta { text }` to append, `reset {}` to discard what was shown,
|
|
67
|
-
* `actions { actions }` for support cards.
|
|
67
|
+
* `tool { toolName }` when the assistant starts a tool (the name only), `actions { actions }` for support cards.
|
|
68
68
|
*/
|
|
69
|
-
onEvent?: (name: "delta" | "reset" | "actions", data: any) => void;
|
|
69
|
+
onEvent?: (name: "delta" | "reset" | "tool" | "actions", data: any) => void;
|
|
70
70
|
};
|
|
71
71
|
export type ChatTurnResult = {
|
|
72
72
|
conversationId: string;
|
|
@@ -151,9 +151,9 @@ export type ChatClient = {
|
|
|
151
151
|
/**
|
|
152
152
|
* @typedef {object} ChatStreamOptions
|
|
153
153
|
* @property {AbortSignal} [signal] Cancels the request.
|
|
154
|
-
* @property {(name: "delta"|"reset"|"actions", data: any) => void} [onEvent] Called for each event
|
|
154
|
+
* @property {(name: "delta"|"reset"|"tool"|"actions", data: any) => void} [onEvent] Called for each event
|
|
155
155
|
* before the end of the turn: `delta { text }` to append, `reset {}` to discard what was shown,
|
|
156
|
-
* `actions { actions }` for support cards.
|
|
156
|
+
* `tool { toolName }` when the assistant starts a tool (the name only), `actions { actions }` for support cards.
|
|
157
157
|
*/
|
|
158
158
|
/**
|
|
159
159
|
* @typedef {object} ChatTurnResult The `done` event: the turn's outcome of record.
|
package/dist/ui-chat-core.js
CHANGED
|
@@ -4,7 +4,7 @@ function e(e){let t=``;function n(t){let n=`message`,r=[];for(let e of t.split(`
|
|
|
4
4
|
`).replace(/\r(?!$)/g,`
|
|
5
5
|
`);let r=t.split(`
|
|
6
6
|
|
|
7
|
-
`);t=r.pop();for(let e of r)n(e)},end(){let e=t.replace(/\r$/,``);t=``,e.trim()&&n(e)}}}var t=`Something went wrong. Please try again.`,n=class extends Error{constructor(e,t,n,r=null){super(t),this.name=`ChatApiError`,this.code=e,this.status=n,this.resetsAtUtc=r}};function r(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}function i(e,t){return t?.aborted||e?.code===`ERR_CANCELED`||e?.name===`CanceledError`||e?.name===`AbortError`}function a(e,a){if(e instanceof n)return e;if(i(e,a))return new n(`aborted`,`The request was cancelled.`);let o=e?.response;if(!o)return new n(`network`,t);let s=r(o.data),c=typeof s?.code==`string`&&s.code?s.code:`unknown`,l=typeof s?.message==`string`&&s.message?s.message:t,u=typeof s?.resetsAtUtc==`string`?s.resetsAtUtc:null;return new n(c,l,o.status,u)}async function o(e){try{return(await e()).data}catch(e){throw a(e)}}function s(e){let t=e?.event?.target;if(!(!t||typeof t.responseText!=`string`)&&!(typeof t.status==`number`&&(t.status<200||t.status>=300)))return t.responseText}function c(r,{base:i}){if(typeof i!=`string`||i.trim()===``)throw TypeError(`createChatClient needs a base path, e.g. { base: "/api/assistant" }.`);let c=i.replace(/\/+$/,``),l=e=>`${c}/conversations/${encodeURIComponent(e)}`;async function u({message:i,conversationId:o,pageContext:l},{signal:u,onEvent:d}={}){let f=null,p=null,m=e(({name:e,data:t})=>{f||p||(e===`done`?f=t:e===`error`?p=t:(e===`delta`||e===`reset`||e===`actions`)&&d?.(e,t))}),h=0,g=e=>{typeof e!=`string`||e.length<=h||(m.push(e.slice(h)),h=e.length)},_={message:i};o&&(_.conversationId=o),l!=null&&(_.pageContext=l);let v;try{v=await r.post(`${c}/chat`,_,{responseType:`text`,headers:{Accept:`text/event-stream`},signal:u,onDownloadProgress:e=>g(s(e))})}catch(e){throw a(e,u)}if(g(v.data),m.end(),p)throw new n(p.code||`unknown`,p.message||t);if(!f)throw new n(`invalid-response`,t,v.status);return f}return{sendMessage:u,getAllowance:()=>o(()=>r.get(`${c}/allowance`)),listConversations:({skip:e,take:t}={})=>{let n=new URLSearchParams;e!=null&&n.append(`skip`,String(e)),t!=null&&n.append(`take`,String(t));let i=n.toString();return o(()=>r.get(`${c}/conversations${i?`?${i}`:``}`))},getConversation:e=>o(()=>r.get(l(e))),deleteConversation:async e=>{await o(()=>r.delete(l(e)))},rateMessage:async(e,t,{rating:n,note:i})=>{let a=typeof i==`string`?i.trim():``;await o(()=>r.put(`${l(e)}/messages/${encodeURIComponent(t)}/rating`,{rating:n,note:a||null}))}}}var l=Object.freeze({launcher:`Ask the assistant`,panelTitle:`Assistant`,newChat:`New chat`,close:`Close`,thread:`Conversation`,you:`You`,assistant:`Assistant`,thinking:`Thinking`,emptyTitle:`How can I help?`,emptyText:`Ask a question about what you see on this page.`,composer:`Your question`,placeholder:`Ask a question`,send:`Send`,composerHint:`Press Enter to send, Shift and Enter for a new line.`,allowance:e=>e===0?`You have no questions left today.`:e===1?`You have 1 question left today.`:`You have ${e} questions left today.`,disclaimer:`Answers are written by AI and can be wrong. Check anything important.`,loadingConversation:`Loading the conversation`,rateUp:`Helpful`,rateDown:`Not helpful`,rated:`Thanks for the feedback.`,ratingNote:`What was wrong with this answer?`,ratingNoteHint:`Optional.`,ratingNoteSend:`Send`,ratingNoteSkip:`Skip`,ratingFailed:`Your rating did not save. Please try again.`,actionRaiseTicket:`New support ticket`,actionReply:e=>`Reply on ${e}`,actionReopen:e=>`Reopen ${e}`,actionNote:`Nothing is sent until you confirm.`,actionConfirm:`Confirm`,actionDismiss:`Not now`,actionDismissed:`Not sent.`,actionExpired:`This request expired and was not sent. Ask again if you still need it.`,actionFailed:`We could not send this. Please try again.`,actionDoneRaiseTicket:e=>`Ticket ${e} raised.`,actionDoneReply:e=>`Your reply was added to ${e}.`,actionDoneReopen:e=>`${e} is open again.`,viewTicket:`View ticket`,conversations:`Past chats`,conversationsEmptyTitle:`No past chats`,conversationsEmptyText:`Your conversations with the assistant show here.`,untitled:`Untitled chat`,deleteConversation:`Delete chat`,deleteConfirmTitle:`Delete this chat?`,deleteConfirmMessage:`The conversation is removed for good.`,deleteConfirm:`Delete`,deleteFailed:`We could not delete this chat. Please try again.`,cancel:`Cancel`,loadMore:`Show more`,loadFailed:`We could not load your chats. Please try again.`,retry:`Try again`});function u(e){return e?{...l,...e}:l}var d=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,f=/^\s*```/,p=/^\s*[-*+]\s+(.*)$/,m=/^\s*(\d{1,9})[.)]\s+(.*)$/,h=/^\s{0,3}#{1,6}\s+(.*?)\s*#*\s*$/,g=/^\s*([-*_])(\s*\1){2,}\s*$/,_=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,v=e=>e.includes(`|`);function y(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function b(e,t){return v(e[t])&&t+1<e.length&&_.test(e[t+1])}function x(e,t){let n=e[t];return f.test(n)||p.test(n)||m.test(n)||h.test(n)||g.test(n)||b(e,t)}function S(e){let t=String(e??``).replace(/\r\n?/g,`
|
|
7
|
+
`);t=r.pop();for(let e of r)n(e)},end(){let e=t.replace(/\r$/,``);t=``,e.trim()&&n(e)}}}var t=`Something went wrong. Please try again.`,n=class extends Error{constructor(e,t,n,r=null){super(t),this.name=`ChatApiError`,this.code=e,this.status=n,this.resetsAtUtc=r}};function r(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}function i(e,t){return t?.aborted||e?.code===`ERR_CANCELED`||e?.name===`CanceledError`||e?.name===`AbortError`}function a(e,a){if(e instanceof n)return e;if(i(e,a))return new n(`aborted`,`The request was cancelled.`);let o=e?.response;if(!o)return new n(`network`,t);let s=r(o.data),c=typeof s?.code==`string`&&s.code?s.code:`unknown`,l=typeof s?.message==`string`&&s.message?s.message:t,u=typeof s?.resetsAtUtc==`string`?s.resetsAtUtc:null;return new n(c,l,o.status,u)}async function o(e){try{return(await e()).data}catch(e){throw a(e)}}function s(e){let t=e?.event?.target;if(!(!t||typeof t.responseText!=`string`)&&!(typeof t.status==`number`&&(t.status<200||t.status>=300)))return t.responseText}function c(r,{base:i}){if(typeof i!=`string`||i.trim()===``)throw TypeError(`createChatClient needs a base path, e.g. { base: "/api/assistant" }.`);let c=i.replace(/\/+$/,``),l=e=>`${c}/conversations/${encodeURIComponent(e)}`;async function u({message:i,conversationId:o,pageContext:l},{signal:u,onEvent:d}={}){let f=null,p=null,m=e(({name:e,data:t})=>{f||p||(e===`done`?f=t:e===`error`?p=t:(e===`delta`||e===`reset`||e===`tool`||e===`actions`)&&d?.(e,t))}),h=0,g=e=>{typeof e!=`string`||e.length<=h||(m.push(e.slice(h)),h=e.length)},_={message:i};o&&(_.conversationId=o),l!=null&&(_.pageContext=l);let v;try{v=await r.post(`${c}/chat`,_,{responseType:`text`,headers:{Accept:`text/event-stream`},signal:u,onDownloadProgress:e=>g(s(e))})}catch(e){throw a(e,u)}if(g(v.data),m.end(),p)throw new n(p.code||`unknown`,p.message||t);if(!f)throw new n(`invalid-response`,t,v.status);return f}return{sendMessage:u,getAllowance:()=>o(()=>r.get(`${c}/allowance`)),listConversations:({skip:e,take:t}={})=>{let n=new URLSearchParams;e!=null&&n.append(`skip`,String(e)),t!=null&&n.append(`take`,String(t));let i=n.toString();return o(()=>r.get(`${c}/conversations${i?`?${i}`:``}`))},getConversation:e=>o(()=>r.get(l(e))),deleteConversation:async e=>{await o(()=>r.delete(l(e)))},rateMessage:async(e,t,{rating:n,note:i})=>{let a=typeof i==`string`?i.trim():``;await o(()=>r.put(`${l(e)}/messages/${encodeURIComponent(t)}/rating`,{rating:n,note:a||null}))}}}var l=Object.freeze({launcher:`Ask the assistant`,panelTitle:`Assistant`,newChat:`New chat`,close:`Close`,thread:`Conversation`,you:`You`,assistant:`Assistant`,thinking:`Thinking`,emptyTitle:`How can I help?`,emptyText:`Ask a question about what you see on this page.`,composer:`Your question`,placeholder:`Ask a question`,send:`Send`,composerHint:`Press Enter to send, Shift and Enter for a new line.`,allowance:e=>e===0?`You have no questions left today.`:e===1?`You have 1 question left today.`:`You have ${e} questions left today.`,disclaimer:`Answers are written by AI and can be wrong. Check anything important.`,loadingConversation:`Loading the conversation`,rateUp:`Helpful`,rateDown:`Not helpful`,rated:`Thanks for the feedback.`,ratingNote:`What was wrong with this answer?`,ratingNoteHint:`Optional.`,ratingNoteSend:`Send`,ratingNoteSkip:`Skip`,ratingFailed:`Your rating did not save. Please try again.`,actionRaiseTicket:`New support ticket`,actionReply:e=>`Reply on ${e}`,actionReopen:e=>`Reopen ${e}`,actionNote:`Nothing is sent until you confirm.`,actionConfirm:`Confirm`,actionDismiss:`Not now`,actionDismissed:`Not sent.`,actionExpired:`This request expired and was not sent. Ask again if you still need it.`,actionFailed:`We could not send this. Please try again.`,actionDoneRaiseTicket:e=>`Ticket ${e} raised.`,actionDoneReply:e=>`Your reply was added to ${e}.`,actionDoneReopen:e=>`${e} is open again.`,viewTicket:`View ticket`,conversations:`Past chats`,conversationsEmptyTitle:`No past chats`,conversationsEmptyText:`Your conversations with the assistant show here.`,untitled:`Untitled chat`,deleteConversation:`Delete chat`,deleteConfirmTitle:`Delete this chat?`,deleteConfirmMessage:`The conversation is removed for good.`,deleteConfirm:`Delete`,deleteFailed:`We could not delete this chat. Please try again.`,cancel:`Cancel`,loadMore:`Show more`,loadFailed:`We could not load your chats. Please try again.`,retry:`Try again`});function u(e){return e?{...l,...e}:l}var d=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,f=/^\s*```/,p=/^\s*[-*+]\s+(.*)$/,m=/^\s*(\d{1,9})[.)]\s+(.*)$/,h=/^\s{0,3}#{1,6}\s+(.*?)\s*#*\s*$/,g=/^\s*([-*_])(\s*\1){2,}\s*$/,_=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,v=e=>e.includes(`|`);function y(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function b(e,t){return v(e[t])&&t+1<e.length&&_.test(e[t+1])}function x(e,t){let n=e[t];return f.test(n)||p.test(n)||m.test(n)||h.test(n)||g.test(n)||b(e,t)}function S(e){let t=String(e??``).replace(/\r\n?/g,`
|
|
8
8
|
`).split(`
|
|
9
9
|
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r+=1;continue}if(f.test(e)){let e=[];for(r+=1;r<t.length&&!f.test(t[r]);)e.push(t[r]),r+=1;r+=1,n.push({type:`code`,text:e.join(`
|
|
10
10
|
`)});continue}if(b(t,r)){let i=y(e),a=[];for(r+=2;r<t.length&&t[r].trim()&&v(t[r]);)a.push(y(t[r])),r+=1;n.push({type:`table`,header:i,rows:a});continue}if(g.test(e)){n.push({type:`rule`}),r+=1;continue}let i=h.exec(e);if(i){n.push({type:`heading`,text:i[1]}),r+=1;continue}let a=m.exec(e);if(a||p.test(e)){let e=!!a,i=e?m:p,o=[];for(;r<t.length&&t[r].trim();){let n=i.exec(t[r]);if(n)o.push(e?n[2]:n[1]);else if(x(t,r))break;else o[o.length-1]+=` ${t[r].trim()}`;r+=1}n.push({type:`list`,ordered:e,start:e?Number(a[1]):1,items:o});continue}let o=[e];for(r+=1;r<t.length&&t[r].trim()&&!x(t,r);)o.push(t[r]),r+=1;n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var C=e=>!!e&&/[\p{L}\p{N}]/u.test(e);function w(e,t,n){let r=e.indexOf(n,t);for(;r!==-1;){let i=e.slice(t,r),a=n.length===1&&(e[r+1]===n||e[r-1]===n),o=n[0]===`_`&&C(e[r+n.length]);if(i.trim()&&!/^\s/.test(i)&&!/\s$/.test(i)&&!a&&!o)return r;r=e.indexOf(n,r+1)}return-1}function T(e){let t=[],n=``,r=()=>{n&&t.push({type:`text`,text:n}),n=``},i=0;for(;i<e.length;){let a=e[i];if(a==="`"){let n=e.indexOf("`",i+1);if(n>i+1){r(),t.push({type:`code`,text:e.slice(i+1,n)}),i=n+1;continue}}if((a===`*`||a===`_`)&&e[i+1]===a){let o=a+a,s=w(e,i+2,o);if(s!==-1&&!(a===`_`&&C(e[i-1]))){r(),t.push({type:`strong`,children:T(e.slice(i+2,s))}),i=s+2;continue}n+=o,i+=2;continue}if(a===`*`||a===`_`){let n=w(e,i+1,a);if(n!==-1&&!(a===`_`&&C(e[i-1]))){r(),t.push({type:`em`,children:T(e.slice(i+1,n))}),i=n+1;continue}}if(a===`[`){let n=/^\[([^\]\n]+)\]\(([^)\s]+)\)/.exec(e.slice(i));if(n){r(),t.push({type:`link`,href:n[2],children:T(n[1])}),i+=n[0].length;continue}}n+=a,i+=1}return r(),t.map((e,t)=>({...e,key:t}))}function E(e,t){if(!t||!d.test(e))return null;let n=t(e);return typeof n==`string`&&n.startsWith(`/`)&&!n.startsWith(`//`)?n:null}export{n as ChatApiError,l as DEFAULT_CHAT_LABELS,c as createChatClient,e as createSseParser,E as linkRoute,u as mergeLabels,S as parseBlocks,T as parseInline};
|