luzia-widget 0.1.2 → 0.1.4
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/README.md +1 -1
- package/dist/element.d.ts +30 -2
- package/dist/element.js +213 -119
- package/dist/element.js.map +1 -1
- package/dist/links.d.ts +9 -0
- package/dist/links.js +85 -0
- package/dist/links.js.map +1 -0
- package/dist/luzia-widget.js +455 -150
- package/dist/styles.d.ts +4 -4
- package/dist/styles.js +428 -141
- package/dist/styles.js.map +1 -1
- package/package.json +1 -1
package/dist/luzia-widget.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var q="conversation_limit_reached",N="message_too_long";function z(n){return n.code===q?"limit":n.code===N?"too-long":"unavailable"}var $={limit:"You've reached the message limit for this conversation.","too-long":"That message is too long. Please shorten it and try again.",unavailable:"luzIA is unavailable right now. Please try again later."};function L(n,e,t){if(n.hidden=e===null,n.replaceChildren(),e===null)return;n.append($[e]);let i=t.trim();e==="too-long"||!i||n.append(" You can get in touch directly: ",P(i),".")}function P(n){let e=/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(n)?`mailto:${n}`:/^https?:\/\/\S+$/i.test(n)?n:null;if(!e)return document.createTextNode(n);let t=document.createElement("a");return t.href=e,t.textContent=n,e.startsWith("mailto:")||(t.target="_blank",t.rel="noopener noreferrer"),t}var d=class extends Error{code;status;constructor(e,t,i){super(t),this.name="LuziaRequestError",this.code=e,this.status=i}};async function*E(n,e,t){let i;try{i=await fetch(n,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({messages:e}),signal:t})}catch(r){if(t?.aborted)return;throw new d("network_error",A(r))}if(!i.ok)throw await V(i);if(!i.body)throw new d("network_error","The reply had no body.",i.status);let a=i.body.pipeThrough(new TextDecoderStream).getReader();try{for(;;){let{done:r,value:s}=await a.read();if(r)return;s&&(yield s)}}catch(r){if(t?.aborted)return;throw new d("network_error",A(r),i.status)}finally{a.releaseLock()}}async function V(n){let t=(await n.json().catch(()=>{}))?.error;return new d(typeof t?.code=="string"?t.code:"http_error",typeof t?.message=="string"?t.message:`The server answered ${n.status}.`,n.status)}function A(n){return n instanceof Error?n.message:String(n)}var h=class{#e;#a=new Set;#l;#n=null;constructor(e){this.#l=e,this.#e={messages:e.messages??[],status:"idle",error:null,unsent:null}}get state(){return this.#e}subscribe(e){return this.#a.add(e),()=>this.#a.delete(e)}send(e){let t=e.trim();return!t||this.#e.status==="streaming"?!1:(this.#d([...this.#e.messages,{role:"user",content:t}]),!0)}abort(){this.#n?.abort()}reset(e=[]){let t=this.#n;this.#n=null,t?.abort(),this.#i({messages:e,status:"idle",error:null,unsent:null})}async#d(e){let t=new AbortController;this.#n=t;let i="";this.#i({messages:[...e,{role:"assistant",content:i}],status:"streaming",error:null,unsent:null});try{for await(let a of E(this.#l.endpoint(),e,t.signal)){if(this.#n!==t)return;i+=a,this.#i({...this.#e,messages:[...e,{role:"assistant",content:i}]})}if(this.#n!==t)return;this.#i({messages:T(e,i),status:"idle",error:null,unsent:null})}catch(a){if(this.#n!==t)return;let r=a instanceof d?a:new d("network_error",String(a));i?this.#i({messages:T(e,i),status:"error",error:r,unsent:null}):this.#i({messages:e.slice(0,-1),status:"error",error:r,unsent:e.at(-1)?.content??null})}finally{this.#n===t&&(this.#n=null)}}#i(e){this.#e=e;for(let t of this.#a)t(e)}};function T(n,e){return e?[...n,{role:"assistant",content:e}]:n}var B=String.raw`\[([^\]\n]+)\]\(\s*((?:https?:\/\/|mailto:|www\.)[^\s)]+)\s*\)`,G=String.raw`(?:https?:\/\/|www\.)[^\s<>"'\x60]+`,j=String.raw`[\w.+-]+@[\w-]+(?:\.[\w-]+)*\.[a-z]{2,}`,K=new RegExp(`${B}|(${G})|(${j})`,"gi"),D=/[.,;:!?'"»”’]+$/;function F(n){let e=n;for(;;){let t=e;e=e.replace(D,"");for(let[i,a]of[["(",")"],["[","]"]])e.endsWith(a)&&S(e,a)>S(e,i)&&(e=e.slice(0,-1));if(e===t)return e}}function S(n,e){return n.split(e).length-1}function C(n){let e=/^www\./i.test(n)?`https://${n}`:n;try{let t=new URL(e);return["http:","https:","mailto:"].includes(t.protocol)?t.href:null}catch{return null}}function f(n,e){let t=document.createElement("a");return t.href=e,t.textContent=n,e.startsWith("mailto:")||(t.target="_blank",t.rel="noopener noreferrer"),t}function M(n,e){let t=[],i=0;for(let a of e.matchAll(K)){let[r,s,l,o,p]=a,b=a.index,g=r,u=null;if(s!==void 0&&l!==void 0){let c=C(l);c&&(u=f(s,c))}else if(o!==void 0){g=F(o);let c=C(g);c&&(u=f(g,c))}else p!==void 0&&(u=f(p,`mailto:${p}`));u&&(b>i&&t.push(document.createTextNode(e.slice(i,b))),t.push(u),i=b+g.length)}i<e.length&&t.push(document.createTextNode(e.slice(i))),n.replaceChildren(...t)}function R(n){let e=n;try{e=new URL(n,document.baseURI).href}catch{}return`luzia:conversation:${e}`}function O(n,e){let t=J();if(!t)return()=>{};let i=Y(t,e);i&&n.state.messages.length===0&&n.reset(i);let a=W(I(n.state));return n.subscribe(r=>{let s=I(r),l=W(s);if(l!==a){a=l;try{s.length===0?t.removeItem(e):t.setItem(e,l)}catch{}}})}function I(n){return n.status==="streaming"?n.messages.slice(0,-1):n.messages}function W(n){let e={v:1,messages:[...n]};return JSON.stringify(e)}function Y(n,e){try{let t=n.getItem(e);if(t===null)return null;let i=JSON.parse(t);return U(i)?i.messages.map(({role:a,content:r})=>({role:a,content:r})):null}catch{return null}}function U(n){if(typeof n!="object"||n===null)return!1;let{v:e,messages:t}=n;return e===1&&Array.isArray(t)&&t.every(Q)}function Q(n){if(typeof n!="object"||n===null)return!1;let{role:e,content:t}=n;return(e==="user"||e==="assistant")&&typeof t=="string"}function J(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}var _=`
|
|
2
2
|
:host {
|
|
3
3
|
--luzia-accent: #4f46e5;
|
|
4
4
|
--luzia-accent-contrast: #ffffff;
|
|
@@ -8,6 +8,9 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
8
8
|
--luzia-font: system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
9
9
|
--luzia-border: #d4d4d8;
|
|
10
10
|
--luzia-inline-height: 38rem;
|
|
11
|
+
--luzia-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
|
12
|
+
/* How strongly the accent lights the top of the chat, behind luzIA. */
|
|
13
|
+
--luzia-glow-strength: 22%;
|
|
11
14
|
position: fixed;
|
|
12
15
|
right: 1.25rem;
|
|
13
16
|
bottom: 1.25rem;
|
|
@@ -16,6 +19,7 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
16
19
|
color: var(--luzia-text);
|
|
17
20
|
}
|
|
18
21
|
:host([theme='dark']) {
|
|
22
|
+
--luzia-glow-strength: 30%;
|
|
19
23
|
--luzia-surface: #18181b;
|
|
20
24
|
--luzia-text: #f4f4f5;
|
|
21
25
|
--luzia-muted: #27272a;
|
|
@@ -23,6 +27,7 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
23
27
|
}
|
|
24
28
|
@media (prefers-color-scheme: dark) {
|
|
25
29
|
:host([theme='auto']) {
|
|
30
|
+
--luzia-glow-strength: 30%;
|
|
26
31
|
--luzia-surface: #18181b;
|
|
27
32
|
--luzia-text: #f4f4f5;
|
|
28
33
|
--luzia-muted: #27272a;
|
|
@@ -36,8 +41,10 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
36
41
|
outline: 2px solid var(--luzia-accent);
|
|
37
42
|
outline-offset: 2px;
|
|
38
43
|
}
|
|
39
|
-
/* The
|
|
40
|
-
.
|
|
44
|
+
/* The message box shows focus on its whole field (see .composer:focus-within). */
|
|
45
|
+
.composer textarea:focus-visible { outline: none; }
|
|
46
|
+
::selection { background: color-mix(in srgb, var(--luzia-accent) 28%, transparent); }
|
|
47
|
+
.message[data-role='user']::selection { background: color-mix(in srgb, var(--luzia-accent-contrast) 35%, transparent); }
|
|
41
48
|
/* Read by screen readers only: each finished reply (see the element's View). */
|
|
42
49
|
.announcer {
|
|
43
50
|
position: absolute;
|
|
@@ -50,19 +57,102 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
50
57
|
white-space: nowrap;
|
|
51
58
|
border: 0;
|
|
52
59
|
}
|
|
60
|
+
/*
|
|
61
|
+
* The launcher: a pill with luzIA's icon and an invitation to ask. With the
|
|
62
|
+
* chat open it folds into just the icon: the text fades and blurs out first,
|
|
63
|
+
* then the pill narrows (unfolding, the pill widens first, then the text comes in).
|
|
64
|
+
*/
|
|
53
65
|
.bubble {
|
|
54
|
-
display:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
height: 3.5rem;
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
height: 3.25rem;
|
|
58
69
|
margin-left: auto;
|
|
70
|
+
padding: 0 0.45rem;
|
|
59
71
|
border: none;
|
|
60
|
-
border-radius:
|
|
72
|
+
border-radius: 999px;
|
|
61
73
|
background: var(--luzia-accent);
|
|
62
74
|
color: var(--luzia-accent-contrast);
|
|
63
|
-
font: 600 0.
|
|
75
|
+
font: 600 0.95rem var(--luzia-font);
|
|
64
76
|
box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
|
|
65
77
|
cursor: pointer;
|
|
78
|
+
transition: transform 160ms ease-out, box-shadow 160ms ease-out;
|
|
79
|
+
position: relative;
|
|
80
|
+
}
|
|
81
|
+
/*
|
|
82
|
+
* With the Owner's hello animation, luzIA peeks out of the closed launcher
|
|
83
|
+
* now and then, above its text: she rises from its top edge (clipped there,
|
|
84
|
+
* as if from behind it), says hello, and ducks back down.
|
|
85
|
+
*/
|
|
86
|
+
.peek {
|
|
87
|
+
position: absolute;
|
|
88
|
+
left: calc(50% + 1.15rem);
|
|
89
|
+
bottom: calc(100% - 1px);
|
|
90
|
+
width: 10.5rem;
|
|
91
|
+
height: var(--luzia-peek-size, 8.5rem);
|
|
92
|
+
transform: translateX(-50%);
|
|
93
|
+
clip-path: inset(-3rem -3rem 0 -3rem);
|
|
94
|
+
pointer-events: none;
|
|
95
|
+
}
|
|
96
|
+
.peek-image {
|
|
97
|
+
display: block;
|
|
98
|
+
height: 100%;
|
|
99
|
+
width: 100%;
|
|
100
|
+
object-fit: contain;
|
|
101
|
+
object-position: 50% 100%;
|
|
102
|
+
transform: translateY(105%);
|
|
103
|
+
transform-origin: 50% 100%;
|
|
104
|
+
filter: drop-shadow(0 4px 10px rgb(0 0 0 / 0.18));
|
|
105
|
+
}
|
|
106
|
+
/* The animation says hello; she only rises and ducks: half a second up, gently settling;
|
|
107
|
+
half a second down, easing in and out (no sudden drop). */
|
|
108
|
+
.bubble[data-peeking] .peek-image { animation: luzia-peek-rise 4s both; }
|
|
109
|
+
@keyframes luzia-peek-rise {
|
|
110
|
+
0% { transform: translateY(105%); animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1); }
|
|
111
|
+
12.5%, 87.5% { transform: translateY(0); animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
|
|
112
|
+
100% { transform: translateY(105%); }
|
|
113
|
+
}
|
|
114
|
+
@media (hover: hover) and (pointer: fine) {
|
|
115
|
+
.bubble:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); }
|
|
116
|
+
}
|
|
117
|
+
.bubble:active { transform: scale(0.97); }
|
|
118
|
+
.bubble-icon { display: block; width: 2.35rem; height: 2.35rem; flex: none; }
|
|
119
|
+
.bubble-icon svg { display: block; }
|
|
120
|
+
/* The star turns a little as the pill folds and unfolds. */
|
|
121
|
+
.bubble-icon path {
|
|
122
|
+
transform-box: fill-box;
|
|
123
|
+
transform-origin: center;
|
|
124
|
+
transition: transform 400ms var(--luzia-ease-out);
|
|
125
|
+
}
|
|
126
|
+
.bubble[aria-expanded='true'] .bubble-icon path { transform: rotate(90deg); }
|
|
127
|
+
.bubble-label {
|
|
128
|
+
display: block;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
max-width: 14rem;
|
|
131
|
+
transition: max-width 320ms var(--luzia-ease-out);
|
|
132
|
+
}
|
|
133
|
+
.bubble-text {
|
|
134
|
+
display: block;
|
|
135
|
+
padding: 0 0.95rem 0 0.6rem;
|
|
136
|
+
white-space: nowrap;
|
|
137
|
+
transition: opacity 200ms ease 90ms, filter 200ms ease 90ms, transform 200ms ease-out 90ms;
|
|
138
|
+
}
|
|
139
|
+
.bubble[aria-expanded='true'] .bubble-label {
|
|
140
|
+
max-width: 0;
|
|
141
|
+
transition-delay: 60ms;
|
|
142
|
+
}
|
|
143
|
+
.bubble[aria-expanded='true'] .bubble-text {
|
|
144
|
+
opacity: 0;
|
|
145
|
+
filter: blur(3px);
|
|
146
|
+
transform: translateX(-0.4rem);
|
|
147
|
+
transition-duration: 140ms;
|
|
148
|
+
transition-delay: 0ms;
|
|
149
|
+
}
|
|
150
|
+
/* Less motion: the text still fades, but nothing moves or turns (and luzIA doesn't peek). */
|
|
151
|
+
@media (prefers-reduced-motion: reduce) {
|
|
152
|
+
.peek { display: none; }
|
|
153
|
+
.bubble, .bubble-label, .bubble-icon path { transition: none; }
|
|
154
|
+
.bubble:hover, .bubble:active, .bubble-text, .bubble[aria-expanded='true'] .bubble-text { transform: none; }
|
|
155
|
+
.bubble-text, .bubble[aria-expanded='true'] .bubble-text { filter: none; transition: opacity 150ms ease; }
|
|
66
156
|
}
|
|
67
157
|
.panel {
|
|
68
158
|
display: flex;
|
|
@@ -71,10 +161,28 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
71
161
|
height: min(40rem, calc(100vh - 7rem));
|
|
72
162
|
margin-bottom: 0.75rem;
|
|
73
163
|
background: var(--luzia-surface);
|
|
74
|
-
|
|
75
|
-
|
|
164
|
+
/* luzIA's light (.stage::before) sits behind the header and stage, above this background. */
|
|
165
|
+
isolation: isolate;
|
|
166
|
+
border: 1px solid color-mix(in srgb, var(--luzia-border) 70%, transparent);
|
|
167
|
+
border-radius: 1.25rem;
|
|
168
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 24px 48px -12px rgb(0 0 0 / 0.3);
|
|
76
169
|
overflow: hidden;
|
|
77
170
|
}
|
|
171
|
+
/* Opening grows the chat out of the launcher below it; closing is instant. */
|
|
172
|
+
:host(:not([mode='inline'])) .panel {
|
|
173
|
+
transform-origin: bottom right;
|
|
174
|
+
transition: opacity 200ms ease-out, transform 240ms var(--luzia-ease-out);
|
|
175
|
+
@starting-style {
|
|
176
|
+
opacity: 0;
|
|
177
|
+
transform: translateY(8px) scale(0.97);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
@media (prefers-reduced-motion: reduce) {
|
|
181
|
+
:host(:not([mode='inline'])) .panel {
|
|
182
|
+
transition: opacity 150ms ease;
|
|
183
|
+
@starting-style { transform: none; }
|
|
184
|
+
}
|
|
185
|
+
}
|
|
78
186
|
:host([mode='inline']) {
|
|
79
187
|
position: static;
|
|
80
188
|
display: block;
|
|
@@ -85,31 +193,56 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
85
193
|
width: 100%;
|
|
86
194
|
height: var(--luzia-inline-height);
|
|
87
195
|
margin: 0;
|
|
88
|
-
|
|
89
|
-
box-shadow: none;
|
|
196
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
|
|
90
197
|
}
|
|
198
|
+
/* Quiet: luzIA's mark and name, then two icon buttons. The light below carries the colour. */
|
|
91
199
|
.header {
|
|
92
200
|
display: flex;
|
|
93
201
|
align-items: center;
|
|
94
|
-
|
|
95
|
-
padding: 0.
|
|
96
|
-
|
|
97
|
-
color: var(--luzia-accent-contrast);
|
|
202
|
+
gap: 0.5rem;
|
|
203
|
+
padding: 0.375rem 0.375rem 0 0.875rem;
|
|
204
|
+
color: var(--luzia-text);
|
|
98
205
|
}
|
|
99
|
-
|
|
206
|
+
.header-icon { display: block; width: 1.5rem; height: 1.5rem; flex: none; }
|
|
207
|
+
.header-icon svg { display: block; }
|
|
208
|
+
.header-icon circle { fill: var(--luzia-accent); }
|
|
209
|
+
.header-icon path { fill: var(--luzia-accent-contrast); }
|
|
210
|
+
/* Like a video call: luzIA's whole picture at the top, her state beside it like a name tag. */
|
|
100
211
|
.stage {
|
|
212
|
+
--luzia-avatar-height: var(--luzia-avatar-size, clamp(6rem, 26vh, 11rem));
|
|
213
|
+
position: relative;
|
|
101
214
|
flex: none;
|
|
102
215
|
display: flex;
|
|
103
|
-
justify-content:
|
|
104
|
-
|
|
105
|
-
padding: 0.
|
|
106
|
-
border-bottom: 1px solid var(--luzia-border);
|
|
216
|
+
justify-content: center;
|
|
217
|
+
align-items: flex-end;
|
|
218
|
+
padding: 0.25rem 1rem 0;
|
|
219
|
+
border-bottom: 1px solid color-mix(in srgb, var(--luzia-border) 75%, transparent);
|
|
220
|
+
}
|
|
221
|
+
/* She stands in a soft light of the accent colour. */
|
|
222
|
+
.stage::before {
|
|
223
|
+
content: '';
|
|
224
|
+
position: absolute;
|
|
225
|
+
z-index: -1;
|
|
226
|
+
left: 50%;
|
|
227
|
+
bottom: -3rem;
|
|
228
|
+
width: 22rem;
|
|
229
|
+
height: 15rem;
|
|
230
|
+
transform: translateX(-50%);
|
|
231
|
+
background: radial-gradient(closest-side, color-mix(in srgb, var(--luzia-accent) var(--luzia-glow-strength), transparent), transparent);
|
|
232
|
+
pointer-events: none;
|
|
107
233
|
}
|
|
108
234
|
/* The picture is shown whole, in its own shape (a cut-out stands on the divider line). */
|
|
109
235
|
.avatar {
|
|
110
|
-
display:
|
|
111
|
-
|
|
236
|
+
display: grid;
|
|
237
|
+
grid-template-rows: 100%;
|
|
238
|
+
flex: none;
|
|
239
|
+
height: var(--luzia-avatar-height);
|
|
112
240
|
}
|
|
241
|
+
/* The still picture and its talking version share one place; only one shows at a time. */
|
|
242
|
+
.avatar > * { grid-area: 1 / 1; }
|
|
243
|
+
.avatar .speaking { opacity: 0; }
|
|
244
|
+
.stage[data-talking] .avatar .speaking { opacity: 1; }
|
|
245
|
+
.stage[data-talking] .avatar:has(.speaking) .still { opacity: 0; }
|
|
113
246
|
.avatar img,
|
|
114
247
|
.avatar svg {
|
|
115
248
|
display: block;
|
|
@@ -117,116 +250,217 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
117
250
|
width: auto;
|
|
118
251
|
max-width: 100%;
|
|
119
252
|
object-fit: contain;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
padding: 0.55rem 0.75rem;
|
|
131
|
-
border: 1px solid var(--luzia-border);
|
|
132
|
-
border-radius: 0.9rem;
|
|
133
|
-
background: var(--luzia-surface);
|
|
134
|
-
color: var(--luzia-text);
|
|
135
|
-
box-shadow: 0 6px 18px rgb(0 0 0 / 0.18);
|
|
136
|
-
font-size: 0.875rem;
|
|
137
|
-
line-height: 1.4;
|
|
138
|
-
opacity: 1;
|
|
139
|
-
transition: opacity 0.4s ease;
|
|
140
|
-
}
|
|
141
|
-
.speech-text {
|
|
142
|
-
display: block;
|
|
143
|
-
max-height: calc(var(--luzia-avatar-size, clamp(7rem, 30vh, 13rem)) - 2.75rem);
|
|
144
|
-
/* Long replies scroll inside the bubble, so their beginning can be read. */
|
|
145
|
-
overflow-y: auto;
|
|
146
|
-
overscroll-behavior: contain;
|
|
147
|
-
scrollbar-width: thin;
|
|
148
|
-
padding-inline-end: 0.25rem;
|
|
149
|
-
white-space: pre-wrap;
|
|
150
|
-
overflow-wrap: anywhere;
|
|
151
|
-
}
|
|
152
|
-
/* The tail points back at luzIA's mouth (tune its height with --luzia-speech-tail-top). */
|
|
153
|
-
.speech::before,
|
|
154
|
-
.speech::after {
|
|
155
|
-
content: '';
|
|
156
|
-
position: absolute;
|
|
157
|
-
border-block-style: solid;
|
|
158
|
-
border-block-color: transparent;
|
|
159
|
-
border-inline-end-style: solid;
|
|
160
|
-
}
|
|
161
|
-
.speech::before {
|
|
162
|
-
top: var(--luzia-speech-tail-top, 1.6rem);
|
|
163
|
-
left: -0.6rem;
|
|
164
|
-
border-block-width: 0.45rem;
|
|
165
|
-
border-inline-end-width: 0.6rem;
|
|
166
|
-
border-inline-end-color: var(--luzia-border);
|
|
167
|
-
}
|
|
168
|
-
.speech::after {
|
|
169
|
-
top: calc(var(--luzia-speech-tail-top, 1.6rem) + 1px);
|
|
170
|
-
left: calc(-0.6rem + 1.5px);
|
|
171
|
-
border-block-width: calc(0.45rem - 1px);
|
|
172
|
-
border-inline-end-width: 0.6rem;
|
|
173
|
-
border-inline-end-color: var(--luzia-surface);
|
|
174
|
-
}
|
|
175
|
-
.speech.leaving { opacity: 0; }
|
|
176
|
-
@media (prefers-reduced-motion: reduce) {
|
|
177
|
-
.speech { transition: none; }
|
|
178
|
-
}
|
|
179
|
-
/* While a reply streams in, a soft glow follows the picture's outline. */
|
|
253
|
+
transform-origin: 50% 100%;
|
|
254
|
+
transition: filter 0.2s ease, transform 360ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
255
|
+
}
|
|
256
|
+
.avatar svg { aspect-ratio: 1; margin-bottom: 0.5rem; height: calc(100% - 0.5rem); }
|
|
257
|
+
/* luzIA's own icon: the star on a disc lit by the accent, not a flat white circle. */
|
|
258
|
+
.avatar svg circle { fill: color-mix(in srgb, var(--luzia-accent) 12%, var(--luzia-surface)); }
|
|
259
|
+
/* While the Visitor types, she leans in a little, as someone listening does. */
|
|
260
|
+
.stage[data-presence='listening'] .avatar img,
|
|
261
|
+
.stage[data-presence='listening'] .avatar svg { transform: scale(1.025) rotate(-1deg); }
|
|
262
|
+
/* Speaking (the greeting, or a reply as it streams in): a soft glow breathes along her outline. */
|
|
180
263
|
.stage[data-speaking] .avatar img,
|
|
181
|
-
.stage[data-speaking] .avatar svg
|
|
264
|
+
.stage[data-speaking] .avatar svg,
|
|
265
|
+
.stage[data-greeting] .avatar img,
|
|
266
|
+
.stage[data-greeting] .avatar svg {
|
|
182
267
|
filter: drop-shadow(0 0 6px var(--luzia-accent));
|
|
183
268
|
animation: luzia-speaking 1.4s ease-in-out infinite;
|
|
184
269
|
}
|
|
185
270
|
@keyframes luzia-speaking {
|
|
186
271
|
50% { filter: drop-shadow(0 0 14px var(--luzia-accent)); }
|
|
187
272
|
}
|
|
273
|
+
/* Her state, like the name tag in a video call: a dot that is lit while she is busy. */
|
|
274
|
+
/* Centred under her, on the divider line, like the name tag in a video call. */
|
|
275
|
+
.presence {
|
|
276
|
+
position: absolute;
|
|
277
|
+
z-index: 1;
|
|
278
|
+
left: 50%;
|
|
279
|
+
bottom: 0;
|
|
280
|
+
transform: translate(-50%, 50%);
|
|
281
|
+
display: flex;
|
|
282
|
+
align-items: center;
|
|
283
|
+
gap: 0.45rem;
|
|
284
|
+
max-width: calc(100% - 2rem);
|
|
285
|
+
padding: 0.3rem 0.7rem 0.3rem 0.55rem;
|
|
286
|
+
border-radius: 999px;
|
|
287
|
+
background: var(--luzia-surface);
|
|
288
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 0 0 1px color-mix(in srgb, var(--luzia-border) 60%, transparent);
|
|
289
|
+
color: color-mix(in srgb, var(--luzia-text) 72%, transparent);
|
|
290
|
+
font-size: 0.8125rem;
|
|
291
|
+
font-weight: 500;
|
|
292
|
+
line-height: 1.2;
|
|
293
|
+
white-space: nowrap;
|
|
294
|
+
}
|
|
295
|
+
.presence-dot {
|
|
296
|
+
flex: none;
|
|
297
|
+
width: 0.5rem;
|
|
298
|
+
height: 0.5rem;
|
|
299
|
+
border-radius: 50%;
|
|
300
|
+
background: #16a34a;
|
|
301
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, #16a34a 18%, transparent);
|
|
302
|
+
transition: background-color 200ms ease, box-shadow 200ms ease;
|
|
303
|
+
}
|
|
304
|
+
.stage:not([data-presence='idle']) .presence-dot {
|
|
305
|
+
background: var(--luzia-accent);
|
|
306
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--luzia-accent) 22%, transparent);
|
|
307
|
+
animation: luzia-pulse 1.2s ease-in-out infinite;
|
|
308
|
+
}
|
|
309
|
+
.stage:not([data-presence='idle']) .presence-text { color: var(--luzia-text); }
|
|
310
|
+
@keyframes luzia-pulse {
|
|
311
|
+
50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--luzia-accent) 8%, transparent); }
|
|
312
|
+
}
|
|
188
313
|
@media (prefers-reduced-motion: reduce) {
|
|
314
|
+
.avatar img, .avatar svg { transition: filter 0.2s ease; transform: none !important; }
|
|
189
315
|
.stage[data-speaking] .avatar img,
|
|
190
|
-
.stage[data-speaking] .avatar svg
|
|
316
|
+
.stage[data-speaking] .avatar svg,
|
|
317
|
+
.stage[data-greeting] .avatar img,
|
|
318
|
+
.stage[data-greeting] .avatar svg,
|
|
319
|
+
.stage:not([data-presence='idle']) .presence-dot { animation: none; }
|
|
320
|
+
/* A moving mouth is motion too: the still picture stays. */
|
|
321
|
+
.stage[data-talking] .avatar .speaking { opacity: 0; }
|
|
322
|
+
.stage[data-talking] .avatar:has(.speaking) .still { opacity: 1; }
|
|
323
|
+
}
|
|
324
|
+
.title { margin: 0; font-size: 0.95rem; font-weight: 650; letter-spacing: -0.01em; }
|
|
325
|
+
.new-conversation,
|
|
326
|
+
.close {
|
|
327
|
+
color: color-mix(in srgb, var(--luzia-text) 65%, transparent);
|
|
191
328
|
}
|
|
192
|
-
|
|
329
|
+
/* Restart: a circular arrow, named by a tooltip on hover or keyboard focus. */
|
|
193
330
|
.new-conversation {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
331
|
+
position: relative;
|
|
332
|
+
display: grid;
|
|
333
|
+
place-items: center;
|
|
334
|
+
margin-inline: auto 0.25rem;
|
|
335
|
+
padding: 0;
|
|
336
|
+
border: none;
|
|
337
|
+
border-radius: 0.75rem;
|
|
198
338
|
background: transparent;
|
|
199
|
-
color: inherit;
|
|
200
|
-
font: inherit;
|
|
201
|
-
font-size: 0.8rem;
|
|
202
339
|
cursor: pointer;
|
|
340
|
+
transition: background-color 150ms ease, color 150ms ease, transform 160ms ease-out;
|
|
341
|
+
}
|
|
342
|
+
.new-conversation svg { display: block; transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1); }
|
|
343
|
+
.new-conversation:active { transform: scale(0.94); }
|
|
344
|
+
.tooltip {
|
|
345
|
+
position: absolute;
|
|
346
|
+
top: calc(100% + 0.4rem);
|
|
347
|
+
right: 0;
|
|
348
|
+
z-index: 1;
|
|
349
|
+
padding: 0.35rem 0.6rem;
|
|
350
|
+
border-radius: 0.375rem;
|
|
351
|
+
background: var(--luzia-text);
|
|
352
|
+
color: var(--luzia-surface);
|
|
353
|
+
font: 500 0.75rem var(--luzia-font);
|
|
354
|
+
white-space: nowrap;
|
|
355
|
+
box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
|
|
356
|
+
pointer-events: none;
|
|
357
|
+
opacity: 0;
|
|
358
|
+
transform: translateY(-2px) scale(0.97);
|
|
359
|
+
transform-origin: top right;
|
|
360
|
+
/* Leaving: quick, with no wait. */
|
|
361
|
+
transition: opacity 100ms ease-out, transform 100ms ease-out;
|
|
362
|
+
}
|
|
363
|
+
/* Appearing: after a short pause, so passing over the button does not flash it. */
|
|
364
|
+
.new-conversation:focus-visible .tooltip {
|
|
365
|
+
opacity: 1;
|
|
366
|
+
transform: none;
|
|
367
|
+
transition: opacity 125ms ease-out, transform 125ms ease-out;
|
|
368
|
+
}
|
|
369
|
+
@media (hover: hover) and (pointer: fine) {
|
|
370
|
+
.new-conversation:hover,
|
|
371
|
+
.close:hover { background-color: color-mix(in srgb, var(--luzia-text) 8%, transparent); color: var(--luzia-text); }
|
|
372
|
+
/* The arrow winds back a little, hinting at what it does. */
|
|
373
|
+
.new-conversation:hover svg { transform: rotate(-45deg); }
|
|
374
|
+
.new-conversation:hover .tooltip {
|
|
375
|
+
opacity: 1;
|
|
376
|
+
transform: none;
|
|
377
|
+
transition: opacity 125ms ease-out 350ms, transform 125ms ease-out 350ms;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
@media (prefers-reduced-motion: reduce) {
|
|
381
|
+
.tooltip, .new-conversation:active, .new-conversation svg { transform: none !important; }
|
|
203
382
|
}
|
|
204
383
|
.close {
|
|
384
|
+
display: grid;
|
|
385
|
+
place-items: center;
|
|
386
|
+
padding: 0;
|
|
205
387
|
border: none;
|
|
388
|
+
border-radius: 0.75rem;
|
|
206
389
|
background: transparent;
|
|
207
|
-
color: inherit;
|
|
208
|
-
font-size: 1.4rem;
|
|
209
|
-
line-height: 1;
|
|
210
390
|
cursor: pointer;
|
|
391
|
+
transition: background-color 150ms ease, color 150ms ease, transform 160ms ease-out;
|
|
392
|
+
}
|
|
393
|
+
.close svg { display: block; }
|
|
394
|
+
.close:active { transform: scale(0.94); }
|
|
395
|
+
@media (prefers-reduced-motion: reduce) {
|
|
396
|
+
.close:active { transform: none; }
|
|
211
397
|
}
|
|
212
398
|
.body {
|
|
213
399
|
flex: 1;
|
|
214
400
|
display: flex;
|
|
215
401
|
flex-direction: column;
|
|
216
|
-
gap: 0.
|
|
217
|
-
|
|
402
|
+
gap: 0.375rem;
|
|
403
|
+
/* Room at the top for luzIA's name tag, which sits on the divider line. */
|
|
404
|
+
padding: 1.5rem 1rem 0.75rem;
|
|
218
405
|
overflow-y: auto;
|
|
219
406
|
}
|
|
220
|
-
.
|
|
221
|
-
|
|
407
|
+
.body {
|
|
408
|
+
scrollbar-width: thin;
|
|
409
|
+
scrollbar-color: color-mix(in srgb, var(--luzia-text) 22%, transparent) transparent;
|
|
410
|
+
}
|
|
411
|
+
/* Messages: soft, with the corner nearest the speaker drawn in, like a tail. */
|
|
412
|
+
.greeting,
|
|
413
|
+
.message {
|
|
222
414
|
max-width: 85%;
|
|
223
415
|
margin: 0;
|
|
224
|
-
padding: 0.
|
|
225
|
-
border-radius:
|
|
226
|
-
|
|
416
|
+
padding: 0.55rem 0.875rem;
|
|
417
|
+
border-radius: 1.125rem;
|
|
418
|
+
font-size: 0.9375rem;
|
|
419
|
+
line-height: 1.45;
|
|
227
420
|
white-space: pre-wrap;
|
|
228
421
|
overflow-wrap: anywhere;
|
|
229
|
-
|
|
422
|
+
}
|
|
423
|
+
.greeting,
|
|
424
|
+
.message[data-role='assistant'] {
|
|
425
|
+
align-self: flex-start;
|
|
426
|
+
border-bottom-left-radius: 0.375rem;
|
|
427
|
+
background: var(--luzia-muted);
|
|
428
|
+
transform-origin: bottom left;
|
|
429
|
+
}
|
|
430
|
+
/* Before her reply starts, luzIA thinks in her own message: three dots that rise in turn. */
|
|
431
|
+
.message[data-thinking] {
|
|
432
|
+
display: flex;
|
|
433
|
+
gap: 0.3rem;
|
|
434
|
+
padding-block: 0.85rem;
|
|
435
|
+
}
|
|
436
|
+
.message[data-thinking] .dot {
|
|
437
|
+
width: 0.4rem;
|
|
438
|
+
height: 0.4rem;
|
|
439
|
+
border-radius: 50%;
|
|
440
|
+
background: color-mix(in srgb, var(--luzia-text) 45%, transparent);
|
|
441
|
+
animation: luzia-think 1.1s ease-in-out infinite;
|
|
442
|
+
}
|
|
443
|
+
.message[data-thinking] .dot:nth-child(2) { animation-delay: 160ms; }
|
|
444
|
+
.message[data-thinking] .dot:nth-child(3) { animation-delay: 320ms; }
|
|
445
|
+
@keyframes luzia-think {
|
|
446
|
+
0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
|
|
447
|
+
30% { transform: translateY(-3px); opacity: 1; }
|
|
448
|
+
}
|
|
449
|
+
@media (prefers-reduced-motion: reduce) {
|
|
450
|
+
.message[data-thinking] .dot { animation: luzia-fade 1.1s ease-in-out infinite alternate; }
|
|
451
|
+
}
|
|
452
|
+
/* Links in luzIA's replies: underlined in the text's own colour, so they read as links on any theme. */
|
|
453
|
+
.message a {
|
|
454
|
+
color: inherit;
|
|
455
|
+
text-decoration: underline;
|
|
456
|
+
text-decoration-thickness: 1px;
|
|
457
|
+
text-underline-offset: 0.15em;
|
|
458
|
+
border-radius: 0.125rem;
|
|
459
|
+
}
|
|
460
|
+
.message a:hover { text-decoration-thickness: 2px; }
|
|
461
|
+
.message a:focus-visible {
|
|
462
|
+
outline: 2px solid var(--luzia-accent);
|
|
463
|
+
outline-offset: 1px;
|
|
230
464
|
}
|
|
231
465
|
.messages {
|
|
232
466
|
margin: 0;
|
|
@@ -234,24 +468,27 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
234
468
|
list-style: none;
|
|
235
469
|
display: flex;
|
|
236
470
|
flex-direction: column;
|
|
237
|
-
gap: 0.
|
|
238
|
-
}
|
|
239
|
-
.message {
|
|
240
|
-
max-width: 85%;
|
|
241
|
-
padding: 0.5rem 0.75rem;
|
|
242
|
-
border-radius: 0.75rem;
|
|
243
|
-
white-space: pre-wrap;
|
|
244
|
-
overflow-wrap: anywhere;
|
|
245
|
-
line-height: 1.4;
|
|
471
|
+
gap: 0.375rem;
|
|
246
472
|
}
|
|
247
473
|
.message[data-role='user'] {
|
|
248
474
|
align-self: flex-end;
|
|
475
|
+
border-bottom-right-radius: 0.375rem;
|
|
249
476
|
background: var(--luzia-accent);
|
|
250
477
|
color: var(--luzia-accent-contrast);
|
|
478
|
+
box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--luzia-accent) 80%, transparent);
|
|
479
|
+
transform-origin: bottom right;
|
|
251
480
|
}
|
|
252
|
-
.
|
|
253
|
-
|
|
254
|
-
|
|
481
|
+
/* A little more room where the speaker changes. */
|
|
482
|
+
.message[data-role='assistant'] + .message[data-role='user'],
|
|
483
|
+
.message[data-role='user'] + .message[data-role='assistant'] { margin-top: 0.375rem; }
|
|
484
|
+
.greeting:not([hidden]) + .messages:not(:empty) { margin-top: 0.375rem; }
|
|
485
|
+
/* Each new message rises into place once. */
|
|
486
|
+
.greeting, .message { animation: luzia-rise 260ms var(--luzia-ease-out); }
|
|
487
|
+
@keyframes luzia-rise {
|
|
488
|
+
from { opacity: 0; transform: translateY(6px) scale(0.98); }
|
|
489
|
+
}
|
|
490
|
+
@keyframes luzia-fade {
|
|
491
|
+
from { opacity: 0; }
|
|
255
492
|
}
|
|
256
493
|
.suggestions {
|
|
257
494
|
display: flex;
|
|
@@ -262,17 +499,33 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
262
499
|
padding: 0;
|
|
263
500
|
list-style: none;
|
|
264
501
|
}
|
|
502
|
+
/* Questions the Visitor could ask, tinted with the accent; they arrive one after another. */
|
|
503
|
+
.suggestions li { animation: luzia-rise 320ms var(--luzia-ease-out) both; transform-origin: bottom right; }
|
|
504
|
+
.suggestions li:nth-child(2) { animation-delay: 50ms; }
|
|
505
|
+
.suggestions li:nth-child(3) { animation-delay: 100ms; }
|
|
506
|
+
.suggestions li:nth-child(n + 4) { animation-delay: 150ms; }
|
|
265
507
|
.suggestion {
|
|
266
|
-
padding: 0.
|
|
267
|
-
border: 1px solid var(--luzia-accent);
|
|
508
|
+
padding: 0.5rem 0.9rem;
|
|
509
|
+
border: 1px solid color-mix(in srgb, var(--luzia-accent) 24%, transparent);
|
|
268
510
|
border-radius: 999px;
|
|
269
|
-
background: var(--luzia-surface);
|
|
270
|
-
color: var(--luzia-text);
|
|
271
|
-
font: 0.875rem var(--luzia-font);
|
|
511
|
+
background: color-mix(in srgb, var(--luzia-accent) 7%, var(--luzia-surface));
|
|
512
|
+
color: color-mix(in srgb, var(--luzia-accent) 60%, var(--luzia-text));
|
|
513
|
+
font: 500 0.875rem/1.3 var(--luzia-font);
|
|
272
514
|
text-align: left;
|
|
273
515
|
cursor: pointer;
|
|
516
|
+
transition: background-color 150ms ease, border-color 150ms ease, transform 160ms ease-out;
|
|
517
|
+
}
|
|
518
|
+
@media (hover: hover) and (pointer: fine) {
|
|
519
|
+
.suggestion:hover {
|
|
520
|
+
border-color: color-mix(in srgb, var(--luzia-accent) 45%, transparent);
|
|
521
|
+
background: color-mix(in srgb, var(--luzia-accent) 13%, var(--luzia-surface));
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
.suggestion:active { transform: scale(0.97); }
|
|
525
|
+
@media (prefers-reduced-motion: reduce) {
|
|
526
|
+
.greeting, .message, .suggestions li { animation-name: luzia-fade; }
|
|
527
|
+
.suggestion:active { transform: none; }
|
|
274
528
|
}
|
|
275
|
-
.suggestion:hover { background: var(--luzia-muted); }
|
|
276
529
|
.alert {
|
|
277
530
|
margin: 0 1rem 0.5rem;
|
|
278
531
|
font-size: 0.875rem;
|
|
@@ -281,32 +534,65 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
281
534
|
.alert a {
|
|
282
535
|
color: inherit;
|
|
283
536
|
}
|
|
537
|
+
/* One rounded field: the message box with a round Send button inside it. */
|
|
284
538
|
.composer {
|
|
285
539
|
display: flex;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
540
|
+
align-items: flex-end;
|
|
541
|
+
gap: 0.375rem;
|
|
542
|
+
margin: 0 0.75rem 0.75rem;
|
|
543
|
+
padding: 0.25rem 0.25rem 0.25rem 1rem;
|
|
544
|
+
border: 1px solid var(--luzia-border);
|
|
545
|
+
border-radius: 1.5rem;
|
|
546
|
+
background: var(--luzia-surface);
|
|
547
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
|
|
548
|
+
transition: border-color 150ms ease, box-shadow 150ms ease;
|
|
549
|
+
}
|
|
550
|
+
.composer:focus-within {
|
|
551
|
+
border-color: color-mix(in srgb, var(--luzia-accent) 60%, var(--luzia-border));
|
|
552
|
+
box-shadow: 0 0 0 4px color-mix(in srgb, var(--luzia-accent) 16%, transparent);
|
|
289
553
|
}
|
|
290
554
|
.composer textarea {
|
|
291
555
|
flex: 1;
|
|
556
|
+
box-sizing: border-box;
|
|
557
|
+
min-height: 2.75rem;
|
|
558
|
+
max-height: 8rem;
|
|
292
559
|
resize: none;
|
|
293
|
-
padding: 0.
|
|
294
|
-
border:
|
|
295
|
-
|
|
296
|
-
background: var(--luzia-surface);
|
|
560
|
+
padding: 0.7rem 0;
|
|
561
|
+
border: none;
|
|
562
|
+
background: transparent;
|
|
297
563
|
color: var(--luzia-text);
|
|
564
|
+
caret-color: var(--luzia-accent);
|
|
298
565
|
font: inherit;
|
|
566
|
+
font-size: 0.9375rem;
|
|
567
|
+
line-height: 1.4;
|
|
568
|
+
/* Grows with what is typed, where supported. */
|
|
569
|
+
field-sizing: content;
|
|
299
570
|
}
|
|
300
|
-
.composer
|
|
301
|
-
|
|
571
|
+
.composer textarea::placeholder { color: color-mix(in srgb, var(--luzia-text) 55%, transparent); }
|
|
572
|
+
.composer textarea:disabled { cursor: not-allowed; }
|
|
573
|
+
.send {
|
|
574
|
+
display: grid;
|
|
575
|
+
place-items: center;
|
|
576
|
+
flex: none;
|
|
577
|
+
width: 44px;
|
|
578
|
+
height: 44px;
|
|
579
|
+
padding: 0;
|
|
302
580
|
border: none;
|
|
303
|
-
border-radius:
|
|
581
|
+
border-radius: 50%;
|
|
304
582
|
background: var(--luzia-accent);
|
|
305
583
|
color: var(--luzia-accent-contrast);
|
|
306
|
-
font: 600 0.875rem var(--luzia-font);
|
|
307
584
|
cursor: pointer;
|
|
585
|
+
transition: background-color 150ms ease, opacity 150ms ease, transform 160ms ease-out;
|
|
586
|
+
}
|
|
587
|
+
.send svg { display: block; }
|
|
588
|
+
@media (hover: hover) and (pointer: fine) {
|
|
589
|
+
.send:not(:disabled):hover { background: color-mix(in srgb, var(--luzia-accent) 86%, #000); }
|
|
590
|
+
}
|
|
591
|
+
.send:not(:disabled):active { transform: scale(0.94); }
|
|
592
|
+
.send:disabled { opacity: 0.35; cursor: default; }
|
|
593
|
+
@media (prefers-reduced-motion: reduce) {
|
|
594
|
+
.send:not(:disabled):active { transform: none; }
|
|
308
595
|
}
|
|
309
|
-
.composer button:disabled { opacity: 0.5; cursor: default; }
|
|
310
596
|
@media (max-width: 480px) {
|
|
311
597
|
/* The whole visible screen: above the on-screen keyboard when it is open (set by the element from visualViewport). */
|
|
312
598
|
.panel {
|
|
@@ -316,33 +602,45 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
316
602
|
width: 100vw;
|
|
317
603
|
height: var(--luzia-viewport-height, 100vh);
|
|
318
604
|
margin: 0;
|
|
605
|
+
border: none;
|
|
319
606
|
border-radius: 0;
|
|
320
607
|
}
|
|
321
608
|
@supports (height: 100dvh) {
|
|
322
609
|
.panel { height: var(--luzia-viewport-height, 100dvh); }
|
|
323
610
|
}
|
|
324
|
-
/* With the keyboard open there is little room: a smaller picture keeps the
|
|
325
|
-
:host([data-keyboard]) .
|
|
326
|
-
:host([data-keyboard]) .speech-text { max-height: 4.5rem; }
|
|
611
|
+
/* With the keyboard open there is little room: a smaller picture keeps the last messages in view. */
|
|
612
|
+
:host([data-keyboard]) .stage { --luzia-avatar-height: 4.5rem; }
|
|
327
613
|
/* Inline, the chat stays in the page but never taller than the screen. */
|
|
328
614
|
:host([mode='inline']) .panel { height: min(var(--luzia-inline-height), 85vh); }
|
|
329
|
-
.composer {
|
|
615
|
+
.composer { margin-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
|
|
616
|
+
:host(:not([mode='inline'])) .panel { transform-origin: bottom center; }
|
|
330
617
|
/* Below 16px, mobile browsers zoom the page when the text box gets focus. */
|
|
331
618
|
.composer textarea { font-size: 16px; }
|
|
332
619
|
}
|
|
333
|
-
`;var
|
|
620
|
+
`;var k="luzia-widget",X=typeof HTMLElement>"u"?class{}:HTMLElement;function v(n=null){return(document.documentElement.lang||navigator.language||"en").toLowerCase().startsWith("es")?`\xA1Hola! Soy luzIA, una IA que responde preguntas sobre ${n??"la persona de este portfolio"}: su experiencia, sus proyectos y lo que busca. \xBFQu\xE9 te gustar\xEDa saber?`:`Hi! I\u2019m luzIA, an AI agent that answers questions about ${n??"the person behind this portfolio"}: their experience, their projects and what they\u2019re looking for. What would you like to know?`}var Z=1500;function ee(n){return fetch(n,{headers:{accept:"application/json"}}).then(async e=>{if(!e.ok)return null;let t=await e.json();return typeof t.owner?.name=="string"&&t.owner.name.trim()?t.owner.name.trim():null}).catch(()=>null)}var te=4e3,ne=25e3,ie='<span class="dot" aria-hidden="true"></span>'.repeat(3),ae=1400;function re(n){let e=(document.documentElement.lang||navigator.language||"en").toLowerCase().startsWith("es");return{idle:["En l\xEDnea","Online"],listening:["Escuchando\u2026","Listening\u2026"],thinking:["Pensando\u2026","Thinking\u2026"],replying:["Respondiendo\u2026","Replying\u2026"]}[n][e?0:1]}var w="Ask luzIA about me",y=`<svg viewBox="0 0 32 32" width="100%" height="100%" focusable="false">
|
|
334
621
|
<circle cx="16" cy="16" r="16" fill="var(--luzia-accent-contrast)" />
|
|
335
622
|
<path d="M16 6l2.6 6.4L25 15l-6.4 2.6L16 24l-2.6-6.4L7 15l6.4-2.6z" fill="var(--luzia-accent)" />
|
|
336
|
-
</svg>`,
|
|
623
|
+
</svg>`,se=`
|
|
337
624
|
<section class="panel" role="dialog" aria-label="luzIA" hidden>
|
|
338
625
|
<header class="header">
|
|
626
|
+
<span class="header-icon" aria-hidden="true">${y}</span>
|
|
339
627
|
<h2 class="title">luzIA</h2>
|
|
340
|
-
<button type="button" class="new-conversation"
|
|
341
|
-
|
|
628
|
+
<button type="button" class="new-conversation" aria-label="Restart conversation">
|
|
629
|
+
<svg viewBox="0 0 24 24" width="20" height="20" focusable="false" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
630
|
+
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
|
|
631
|
+
<path d="M3 3v5h5" />
|
|
632
|
+
</svg>
|
|
633
|
+
<span class="tooltip" aria-hidden="true">Restart conversation</span>
|
|
634
|
+
</button>
|
|
635
|
+
<button type="button" class="close" aria-label="Close luzIA chat">
|
|
636
|
+
<svg viewBox="0 0 24 24" width="20" height="20" focusable="false" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
637
|
+
<path d="M18 6 6 18M6 6l12 12" />
|
|
638
|
+
</svg>
|
|
639
|
+
</button>
|
|
342
640
|
</header>
|
|
343
|
-
<div class="stage">
|
|
344
|
-
<span class="avatar"
|
|
345
|
-
<
|
|
641
|
+
<div class="stage" aria-hidden="true">
|
|
642
|
+
<span class="avatar"></span>
|
|
643
|
+
<span class="presence"><span class="presence-dot"></span><span class="presence-text"></span></span>
|
|
346
644
|
</div>
|
|
347
645
|
<div class="body">
|
|
348
646
|
<p class="greeting" hidden></p>
|
|
@@ -353,10 +651,17 @@ var k="conversation_limit_reached",E="message_too_long";function p(i){return i.c
|
|
|
353
651
|
<p class="alert" role="alert" hidden></p>
|
|
354
652
|
<form class="composer">
|
|
355
653
|
<textarea name="message" rows="2" aria-label="Message luzIA" placeholder="Ask a question\u2026"></textarea>
|
|
356
|
-
<button type="submit"
|
|
654
|
+
<button type="submit" class="send" aria-label="Send">
|
|
655
|
+
<svg viewBox="0 0 24 24" width="18" height="18" focusable="false" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round">
|
|
656
|
+
<path d="M12 19V5M5 12l7-7 7 7" />
|
|
657
|
+
</svg>
|
|
658
|
+
</button>
|
|
357
659
|
</form>
|
|
358
660
|
</section>
|
|
359
|
-
<button type="button" class="bubble" aria-label="
|
|
360
|
-
<span aria-hidden="true"
|
|
661
|
+
<button type="button" class="bubble" aria-label="${w}" aria-expanded="false">
|
|
662
|
+
<span class="peek" aria-hidden="true"></span>
|
|
663
|
+
<span class="bubble-icon" aria-hidden="true">${y}</span>
|
|
664
|
+
<span class="bubble-label" aria-hidden="true"><span class="bubble-text">${w}</span></span>
|
|
361
665
|
</button>
|
|
362
|
-
`,
|
|
666
|
+
`,m=class extends X{conversation=new h({endpoint:()=>this.endpoint});#e=null;get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get contact(){return this.getAttribute("contact")??""}set contact(e){this.setAttribute("contact",e)}get greeting(){return this.getAttribute("greeting")??v()}set greeting(e){this.setAttribute("greeting",e)}get suggestedQuestions(){return oe(this.getAttribute("suggested-questions"))}set suggestedQuestions(e){this.setAttribute("suggested-questions",JSON.stringify(e))}get mode(){return this.getAttribute("mode")==="inline"?"inline":"bubble"}set mode(e){this.setAttribute("mode",e)}get theme(){let e=this.getAttribute("theme");return e==="dark"||e==="auto"?e:"light"}set theme(e){this.setAttribute("theme",e)}get avatar(){return this.getAttribute("avatar")??""}set avatar(e){this.setAttribute("avatar",e)}get avatarSpeaking(){return this.getAttribute("avatar-speaking")??""}set avatarSpeaking(e){this.setAttribute("avatar-speaking",e)}get avatarWaving(){return this.getAttribute("avatar-waving")??""}set avatarWaving(e){this.setAttribute("avatar-waving",e)}get bubbleLabel(){return this.getAttribute("bubble-label")?.trim()||w}set bubbleLabel(e){this.setAttribute("bubble-label",e)}static get observedAttributes(){return["greeting","suggested-questions","mode","avatar","avatar-speaking","avatar-waving","bubble-label"]}connectedCallback(){if(this.#e)return;let e=this.attachShadow({mode:"open"});e.innerHTML=`<style>${_}</style>${se}`,O(this.conversation,R(this.endpoint));let t=null,i=()=>this.hasAttribute("greeting")||!this.endpoint?null:(t??=ee(this.endpoint),t);this.#e=new x(e,this.conversation,()=>this.contact,i),this.#e.configure(this),i()}attributeChangedCallback(){this.#e?.configure(this)}};function oe(n){if(!n)return[];let e;try{e=JSON.parse(n)}catch{return[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(Boolean):[]}var x=class{#e;#a;#l;#n;#d;#i;#r;#v;#h;#m;#q=0;#u="";#w=!1;#y;#s;#T=null;#x=!1;#c;#k;#p;#S;#b;#t;#C;#o;#M;#g="bubble";#I=new WeakMap;#W=!1;#z;#L=null;constructor(e,t,i,a=()=>null){this.#z=a,this.#o=t,this.#s=e.host,this.#M=i,this.#e=e.querySelector(".bubble"),this.#a=e.querySelector(".panel"),this.#l=e.querySelector(".close"),this.#n=e.querySelector(".body"),this.#d=e.querySelector(".greeting"),this.#i=e.querySelector(".avatar"),this.#r=e.querySelector(".stage"),this.#v=e.querySelector(".presence-text"),this.#h=e.querySelector(".peek"),this.#c=e.querySelector(".messages"),this.#k=e.querySelector(".announcer"),this.#p=e.querySelector(".suggestions"),this.#S=e.querySelector(".alert"),this.#b=e.querySelector(".composer"),this.#t=this.#b.querySelector("textarea"),this.#C=this.#b.querySelector("button"),this.#e.addEventListener("click",()=>this.#A(this.#e.getAttribute("aria-expanded")!=="true")),this.#l.addEventListener("click",()=>this.#A(!1)),this.#a.addEventListener("keydown",s=>{s.key==="Escape"&&this.#g==="bubble"&&!s.isComposing&&(s.preventDefault(),this.#A(!1))}),e.querySelector(".new-conversation").addEventListener("click",()=>{t.reset(),this.#x=!1,this.#w=!1,this.#_(),this.#t.focus()}),this.#b.addEventListener("submit",s=>{s.preventDefault(),this.#H()}),this.#t.addEventListener("input",()=>this.#E(this.#o.state)),this.#t.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&!s.isComposing&&(s.preventDefault(),this.#H())});let r=setInterval(()=>{this.#s.isConnected?this.#$():clearInterval(r)},ne);t.subscribe(s=>this.#f(s)),this.#f(t.state)}configure(e){this.#V(e.avatar.trim(),e.avatarSpeaking.trim()),this.#B(e.avatarWaving.trim()),this.#e.setAttribute("aria-label",e.bubbleLabel),this.#e.querySelector(".bubble-text").textContent=e.bubbleLabel,this.#u=this.#L&&this.#z()?v(this.#L):e.greeting.trim(),this.#d.textContent=this.#u,this.#p.replaceChildren(...e.suggestedQuestions.map(t=>{let i=document.createElement("button");i.type="button",i.className="suggestion",i.textContent=t,i.addEventListener("click",()=>{this.#o.send(t)&&this.#t.focus()});let a=document.createElement("li");return a.append(i),a})),this.#f(this.#o.state),e.mode!==this.#g&&this.#N(e.mode)}#N(e){this.#g=e;let t=e==="inline";this.#a.setAttribute("role",t?"region":"dialog"),this.#e.hidden=t,this.#l.hidden=t,this.#R(t)}#A(e){this.#R(e),(e?this.#t:this.#e).focus()}#$(){let e=!this.#a.hidden,t=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,i=this.#h.firstElementChild,a=i?.dataset.waves;this.#g!=="bubble"||e||document.hidden||t||!i||!a||i.hasAttribute("data-broken")||(i.src=`${a.split("#")[0]}#peek-${++this.#q}`,this.#e.toggleAttribute("data-peeking",!0),clearTimeout(this.#m),this.#m=setTimeout(()=>this.#e.removeAttribute("data-peeking"),te))}#R(e){e&&(clearTimeout(this.#m),this.#e.removeAttribute("data-peeking")),this.#a.hidden=!e,this.#e.setAttribute("aria-expanded",String(e)),e&&this.#_(),this.#T?.(),this.#T=e?this.#P():null}#P(){let e=window.visualViewport;if(!e)return null;let t=()=>{if(!(this.#g==="bubble"&&window.matchMedia("(max-width: 480px)").matches))return this.#O();this.#s.style.setProperty("--luzia-viewport-height",`${e.height}px`),this.#s.style.setProperty("--luzia-viewport-top",`${e.offsetTop}px`),this.#s.toggleAttribute("data-keyboard",e.height<window.innerHeight*.75)};return t(),e.addEventListener("resize",t),e.addEventListener("scroll",t),()=>{e.removeEventListener("resize",t),e.removeEventListener("scroll",t),this.#O()}}#O(){this.#s.style.removeProperty("--luzia-viewport-height"),this.#s.style.removeProperty("--luzia-viewport-top"),this.#s.removeAttribute("data-keyboard")}#_(){if(this.#x||this.#a.hidden)return;this.#x=!0;let e=()=>{!this.#u||this.#a.hidden||this.#o.state.messages.length>0||(this.#w=!0,clearTimeout(this.#y),this.#r.toggleAttribute("data-greeting",!0),this.#y=setTimeout(()=>{this.#r.removeAttribute("data-greeting"),this.#E(this.#o.state)},ae),this.#f(this.#o.state))},t=this.#z();if(!t)return e();let i=new Promise(a=>setTimeout(()=>a(null),Z));Promise.race([t,i]).then(a=>{a&&(this.#L=a,this.#u=v(a),this.#d.textContent=this.#u),e()})}#V(e,t){let i=`${e}
|
|
667
|
+
${e?t:""}`;if(this.#i.dataset.shown===i)return;if(this.#i.dataset.shown=i,!e){this.#i.innerHTML=y;return}let a=(r,s)=>{let l=document.createElement("img");return l.src=r,l.alt="",l.className=s,l};this.#i.replaceChildren(a(e,"still"),...t?[a(t,"speaking")]:[])}#B(e){if((this.#h.firstElementChild?.dataset.waves??"")===e)return;if(clearTimeout(this.#m),this.#e.removeAttribute("data-peeking"),!e){this.#h.replaceChildren();return}let i=document.createElement("img");i.alt="",i.className="peek-image",i.dataset.waves=e,i.addEventListener("error",()=>{i.dataset.broken="",this.#e.removeAttribute("data-peeking")}),i.src=e,this.#h.replaceChildren(i)}#H(){let e=this.#t.value;this.#o.send(e)&&(this.#t.value="",this.#t.focus())}#G(e,t){let i=this.#W&&!t;if(this.#W=t,(t||e.messages.length===0)&&(this.#k.textContent=""),!i)return;let a=e.messages.at(-1);this.#k.textContent=e.status==="idle"&&a?.role==="assistant"?a.content:""}#E(e){let t=e.messages.at(-1),i="idle";e.status==="streaming"?i=t?.role==="assistant"&&t.content?"replying":"thinking":this.#t.value.trim()&&!this.#t.disabled&&(i="listening"),this.#r.dataset.presence=i,this.#r.toggleAttribute("data-talking",i==="replying"||this.#r.hasAttribute("data-greeting"));let a=re(i);this.#v.textContent!==a&&(this.#v.textContent=a)}#f(e){for(e.messages.forEach((r,s)=>{let l=this.#c.children[s],o=l;(!o||o.dataset.role!==r.role)&&(o=document.createElement("li"),o.className="message",o.dataset.role=r.role,l?l.replaceWith(o):this.#c.append(o)),o.toggleAttribute("data-thinking",r.role==="assistant"&&r.content===""),this.#I.get(o)!==r.content&&(this.#I.set(o,r.content),r.role==="assistant"&&r.content===""?o.innerHTML=ie:r.role==="assistant"?M(o,r.content):o.textContent=r.content)});this.#c.children.length>e.messages.length;)this.#c.lastElementChild?.remove();this.#p.hidden=e.messages.length>0||this.#p.children.length===0;let t=e.status==="streaming";this.#d.hidden=!this.#u||e.messages.length===0&&!this.#w,e.messages.length>0&&this.#r.hasAttribute("data-greeting")&&(clearTimeout(this.#y),this.#r.removeAttribute("data-greeting")),this.#n.scrollTop=this.#n.scrollHeight,this.#r.toggleAttribute("data-speaking",t),this.#c.setAttribute("aria-busy",String(t)),this.#G(e,t);let i=e.status==="error"&&e.error?z(e.error):null;L(this.#S,i,this.#M());let a=i==="limit";this.#t.disabled=a,this.#C.disabled=t||a,e.unsent!==null&&!a&&!this.#t.value&&(this.#t.value=e.unsent),this.#E(e)}};function H(){customElements.get(k)||customElements.define(k,m)}H();export{h as Conversation,k as LUZIA_WIDGET_TAG,d as LuziaRequestError,m as LuziaWidgetElement,H as defineLuziaWidget};
|