@aiden-voice/widget 0.6.0 → 0.7.1
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 +45 -27
- package/dist/theme.d.ts +7 -1
- package/dist/types.d.ts +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +392 -373
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,6 +102,7 @@ throws synchronously, at call time, if you pass both or neither.
|
|
|
102
102
|
| `inkColor` | Body text color (chat title and replies). Darkened automatically if needed to stay readable. Overrides the color configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'#111111'` |
|
|
103
103
|
| `accentColor` | Link color in replies. Darkened automatically if needed to stay readable. Overrides the color configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'#0000ee'` |
|
|
104
104
|
| `name` | Agent name for the panel header and the dialog's screen-reader label ("Chat with {name}"). Overrides the name configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'Aiden'` |
|
|
105
|
+
| `title` | Full panel title, used for the header heading and the dialog's screen-reader label. Replaces the whole "Chat with {name}" string (e.g. `'Ask our concierge'`), with surrounding whitespace trimmed; the agent's messages are still labelled with its name. A blank value is ignored. | `'Chat with {name}'` |
|
|
105
106
|
| `greeting` | Welcome text shown in the panel before the first message. | none |
|
|
106
107
|
| `launcherIconUrl` | Image shown on the launcher bubble instead of the default chat icon. `https:` or `data:image/` only. Until it loads, and permanently if it fails, the default icon shows. Alias of `theme.launcher.iconUrl`. | none (default icon) |
|
|
107
108
|
| `theme` | Colors, font and launcher icons. See [Theming](#theming). | defaults |
|
|
@@ -213,9 +214,13 @@ const theme = resolveTheme({ color: '#3b82f6', inkColor: '#1f2937', accentColor:
|
|
|
213
214
|
const dark = resolveTheme({ overrides: { panel: '#0f172a', ink: '#f8fafc' } })
|
|
214
215
|
// dark.roles: every color the widget renders, by role (all 16 of them).
|
|
215
216
|
// dark.overridden: which roles came from `overrides`.
|
|
216
|
-
// dark.contrastWarnings:
|
|
217
|
-
//
|
|
218
|
-
//
|
|
217
|
+
// dark.contrastWarnings: every role whose contrast against the surface it is
|
|
218
|
+
// drawn on is below 4.5:1 (text) or 3:1 (icons, borders, focus ring), when the
|
|
219
|
+
// role or the surface was overridden. Each is { role, against, value, ratio,
|
|
220
|
+
// required, overridden }; `overridden: false` means only the surface was, so
|
|
221
|
+
// the role's default or calculated color needs an override too. Here, for
|
|
222
|
+
// example, the header controls (`primaryText`) and the focus ring
|
|
223
|
+
// (`focusRing`) are flagged against the dark panel.
|
|
219
224
|
```
|
|
220
225
|
|
|
221
226
|
An override is never adjusted (an opaque one is only normalized to `#rrggbb`). In particular a *translucent* override (`rgba(…, 0.5)`, `#rrggbbaa`) is kept as given, not flattened to its look over white the way `color` is, so a translucent `primary` or `panel` is see-through over the host page, and the host owns the result. `resolveTheme` never logs; read `contrastWarnings` instead.
|
|
@@ -250,26 +255,34 @@ version it needs exists — don't pre-embed `/v1/` in anticipation of a `1.0.0`
|
|
|
250
255
|
|
|
251
256
|
## Releasing
|
|
252
257
|
|
|
253
|
-
Releases
|
|
254
|
-
workflow), running in the `release` GitHub environment. It has
|
|
255
|
-
`cdn` (build, archive upload,
|
|
256
|
-
`publish` (npm), with `publish`
|
|
258
|
+
Releases start from the version bump itself, via `.github/workflows/release.yml`
|
|
259
|
+
(the `Release` workflow), running in the `release` GitHub environment. It has
|
|
260
|
+
three jobs: `tag` (creates the version tag), `cdn` (build, archive upload,
|
|
261
|
+
alias rewrite, Static Web App deploy) and `publish` (npm), with `publish`
|
|
262
|
+
gated on `cdn` succeeding first.
|
|
257
263
|
|
|
258
264
|
1. Bump `version` in **both** `package.json` and `src/version.ts`'s
|
|
259
|
-
`WIDGET_VERSION`
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
265
|
+
`WIDGET_VERSION` in a normal PR. `tests/version.test.ts` fails the PR's
|
|
266
|
+
required `quality` check unless the two agree, so a mismatched bump can't
|
|
267
|
+
be merged.
|
|
268
|
+
2. Merge it to `main`. That is the whole release step: merging is the
|
|
269
|
+
approval, and there is no tag to push.
|
|
270
|
+
|
|
271
|
+
When a push to `main` changes `package.json` or `src/version.ts`, the
|
|
272
|
+
workflow runs and `tag` looks for `v<version>`. If the tag doesn't exist yet,
|
|
273
|
+
`tag` creates it on the pushed commit (a lightweight tag, via the API) and
|
|
274
|
+
`cdn` then `publish` run in that same run. If it does exist, the change
|
|
275
|
+
wasn't a version bump (e.g. a dependency edit in `package.json`), so
|
|
276
|
+
`cdn`/`publish` are skipped. A version that isn't plain SemVer is refused
|
|
277
|
+
before any tag is created. Stable releases and prereleases alike are named
|
|
278
|
+
from the version: `1.3.0` → `v1.3.0`, `1.3.0-rc.1` → `v1.3.0-rc.1`
|
|
279
|
+
(prereleases use a `-rc.N` suffix).
|
|
280
|
+
|
|
281
|
+
Pushing a `v*` tag by hand still starts the workflow too (it skips `tag`),
|
|
282
|
+
and then the tag must match `package.json`'s `version` exactly or the
|
|
283
|
+
workflow refuses.
|
|
284
|
+
|
|
285
|
+
The `cdn` job:
|
|
273
286
|
|
|
274
287
|
- Builds and re-runs the full quality gate (lint, typecheck, unit tests,
|
|
275
288
|
build) against the tagged commit.
|
|
@@ -348,11 +361,14 @@ for a failed `cdn` job.
|
|
|
348
361
|
|
|
349
362
|
### Recovering a failed release
|
|
350
363
|
|
|
351
|
-
If the `cdn` job fails
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
364
|
+
If the `cdn` job fails before it uploads anything (a flaky test, an Azure
|
|
365
|
+
login), use **Re-run failed jobs** on that run: `tag` already succeeded and
|
|
366
|
+
is not repeated. If it fails partway through — after the version folder was
|
|
367
|
+
already uploaded to the archive — re-running will not work:
|
|
368
|
+
`scripts/release-plan.mjs plan` refuses a version that already exists in the
|
|
369
|
+
archive, since versions are immutable by design. To recover, delete that
|
|
370
|
+
version's folder from the archive first, then re-run the failed `cdn` job (or,
|
|
371
|
+
if you deleted the tag too, re-push it as below).
|
|
356
372
|
Run this as an operator, not the workflow's identity — the release
|
|
357
373
|
identity is the only principal with a data-plane role on the container, so
|
|
358
374
|
an operator's own `az storage blob` command needs `--auth-mode key`
|
|
@@ -362,7 +378,9 @@ key for that):
|
|
|
362
378
|
```sh
|
|
363
379
|
az storage blob delete-batch --account-name <acct> --source widget-releases \
|
|
364
380
|
--pattern "vX.Y.Z/*" --auth-mode key
|
|
365
|
-
|
|
381
|
+
# Only if you'd rather start a fresh run than re-run the failed job: delete the remote
|
|
382
|
+
# tag and push it again by hand (a manual tag push skips the `tag` job).
|
|
383
|
+
git push origin :refs/tags/vX.Y.Z
|
|
366
384
|
git tag -d vX.Y.Z && git tag vX.Y.Z && git push origin vX.Y.Z
|
|
367
385
|
```
|
|
368
386
|
|
package/dist/theme.d.ts
CHANGED
|
@@ -14,10 +14,16 @@ export interface ContrastWarning {
|
|
|
14
14
|
role: ThemeColorRole;
|
|
15
15
|
/** The role whose color this one is drawn on. */
|
|
16
16
|
against: ThemeColorRole;
|
|
17
|
-
/** The
|
|
17
|
+
/** The role's rendered value. */
|
|
18
18
|
value: string;
|
|
19
19
|
ratio: number;
|
|
20
20
|
required: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether `role` itself was overridden. False when only `against` was: the
|
|
23
|
+
* widget's own default or calculated color is unreadable on the host's
|
|
24
|
+
* surface, so the host should override `role` too.
|
|
25
|
+
*/
|
|
26
|
+
overridden: boolean;
|
|
21
27
|
}
|
|
22
28
|
export interface ResolvedTheme {
|
|
23
29
|
/** Launcher, visitor bubbles, Send and Submit button fill. */
|
package/dist/types.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export interface WidgetConfig {
|
|
|
89
89
|
*/
|
|
90
90
|
accentColor?: string;
|
|
91
91
|
name?: string;
|
|
92
|
+
title?: string;
|
|
92
93
|
greeting?: string;
|
|
93
94
|
/** Image shown on the launcher bubble instead of the default chat icon. Alias of `theme.launcher.iconUrl`, which wins if both are set. */
|
|
94
95
|
launcherIconUrl?: string;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const WIDGET_VERSION = "0.
|
|
1
|
+
export declare const WIDGET_VERSION = "0.7.1";
|
package/dist/widget.iife.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var whooAidenWidget=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){if(e!=null&&e!==``){if(typeof e==`string`)try{let t=new URL(e);if(t.protocol===`https:`||t.protocol===`data:`&&t.pathname.toLowerCase().startsWith(`image/`))return e}catch{}console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`)}}var n=[`primary`,`onPrimary`,`primaryText`,`ink`,`link`,`text`,`panel`,`border`,`headerHover`,`assistantBubble`,`muted`,`typingDots`,`errorBackground`,`errorText`,`inputBorder`,`focusRing`],r={primary:`#4f46e5`,onPrimary:`#ffffff`,primaryText:`#4f46e5`,ink:`#111111`,link:`#0000ee`,text:`#111111`,panel:`#ffffff`,border:`#e5e5e5`,headerHover:`#f3f4f6`,assistantBubble:`#f0f0f0`,muted:`#4b5563`,typingDots:`#6b7280`,errorBackground:`#fee2e2`,errorText:`#991b1b`,inputBorder:`#6b7280`,focusRing:`#111827`},i={primary:`--whoo-widget-color`,onPrimary:`--whoo-widget-text-on-color`,primaryText:`--whoo-widget-color-text`,ink:`--whoo-widget-ink`,link:`--whoo-widget-link-color`,text:`--whoo-widget-text`,panel:`--whoo-widget-panel`,border:`--whoo-widget-border`,headerHover:`--whoo-widget-header-hover`,assistantBubble:`--whoo-widget-assistant-bubble`,muted:`--whoo-widget-muted`,typingDots:`--whoo-widget-typing-dots`,errorBackground:`--whoo-widget-error-bg`,errorText:`--whoo-widget-error-text`,inputBorder:`--whoo-widget-input-border`,focusRing:`--whoo-widget-focus-ring`},a=2147483e3,o=2147483647;function s(e){return e===void 0?a:Number.isInteger(e)&&Math.abs(e)<=o?e:(console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${o} and ${o}); using ${a}.`),a)}var c=`Aiden`;function l(e){return typeof e==`string`?e.trim():``}function u(e){if((typeof e.publishableKey==`string`&&e.publishableKey.length>0)==(typeof e.sessionToken==`string`&&e.sessionToken.length>0))throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.")}function d(e){console.warn(`whoo-aiden-widget: ${e}`)}var f=20;function p(e){let t=new WeakSet,n=new Set;return r=>{if(typeof r==`object`&&r||typeof r==`function`){if(t.has(r))return;t.add(r)}else{if(n.has(r))return;n.size>=f&&n.delete(n.values().next().value),n.add(r)}d(e)}}var m=p("ignoring `theme` -- expected an object."),h=p("ignoring `layout` -- expected an object.");function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var _=e=>e==null||e===``;function v(e,t,n){let r=e[t];return r==null?null:g(r)?r:(d(`ignoring \`${n}\` -- expected an object.`),null)}function y(e,t,n){for(let r of Object.keys(e))t.includes(r)||d(`ignoring unknown option \`${n}.${r}\`.`)}function b(e,t,n){if(!_(e)){if(typeof e==`string`&&t.includes(e))return e;d(`ignoring \`${n}\` -- expected one of ${t.join(`, `)}.`)}}var x=200,S=/url\(|[@;{}\\]/i;function C(e){if(!_(e)){if(typeof e==`string`){let t=e.trim();if(t&&t.length<=x&&!S.test(t))return t}d(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${x} characters, without url(), @, ;, {, } or \\.`)}}var ee=[`chat`,`message`,`sparkle`],w=[`chevron-down`,`close`],T=new WeakMap;function E(e){let r={colors:{},fontFamily:void 0,launcher:{}};if(e==null)return r;if(!g(e))return m(e),r;let i=T.get(e);if(i)return i;y(e,[`colors`,`fonts`,`launcher`],`theme`);let a=v(e,`colors`,`theme.colors`);if(a){y(a,n,`theme.colors`);for(let e of n){let t=a[e];_(t)||(typeof t==`string`?r.colors[e]=t:d(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`))}}let o=v(e,`fonts`,`theme.fonts`);o&&(y(o,[`family`],`theme.fonts`),r.fontFamily=C(o.family));let s=v(e,`launcher`,`theme.launcher`);if(s){y(s,[`icon`,`iconUrl`,`openIcon`,`openIconUrl`],`theme.launcher`);let e=b(s.icon,ee,`theme.launcher.icon`),n=t(s.iconUrl,`theme.launcher.iconUrl`),i=b(s.openIcon,w,`theme.launcher.openIcon`),a=t(s.openIconUrl,`theme.launcher.openIconUrl`);e&&(r.launcher.icon=e),n&&(r.launcher.iconUrl=n),i&&(r.launcher.openIcon=i),a&&(r.launcher.openIconUrl=a)}return T.set(e,r),r}var D={offsetX:20,offsetY:20,launcherSize:56,panelWidth:360,panelHeight:480};function O(e,t,n){return e==null?n:typeof e==`number`&&Number.isFinite(e)&&e>=0?e:(d(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`),n)}function k(e,t,n,r){let i=Math.min(r,Math.max(n,e));return i!==e&&d(`\`${t}\` ${e} is out of range (${r===1/0?`at least ${n}`:`${n}-${r}`}); using ${i}.`),i}var te=new WeakMap;function ne(e){let t={...D};if(e==null)return t;if(!g(e))return h(e),t;let n=te.get(e);if(n)return n;y(e,[`offset`,`launcherSize`,`panel`],`layout`);let r=v(e,`offset`,`layout.offset`);r&&(y(r,[`x`,`y`],`layout.offset`),t.offsetX=O(r.x,`layout.offset.x`,D.offsetX),t.offsetY=O(r.y,`layout.offset.y`,D.offsetY)),t.launcherSize=k(O(e.launcherSize,`layout.launcherSize`,D.launcherSize),`layout.launcherSize`,24,120);let i=v(e,`panel`,`layout.panel`);return i&&(y(i,[`width`,`height`],`layout.panel`),t.panelWidth=k(O(i.width,`layout.panel.width`,D.panelWidth),`layout.panel.width`,280,1/0),t.panelHeight=k(O(i.height,`layout.panel.height`,D.panelHeight),`layout.panel.height`,320,1/0)),te.set(e,t),t}var A,re,j,ie,M,ae,oe,N,se,ce,le,ue,de={},fe=[],pe=/^m(i|n|o|s|text|space)$/,me=Array.isArray,he=fe.slice,P=Object.assign;function ge(e){e&&e.parentNode&&e.remove()}function _e(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i||++re,__i:-1,__u:0};return!i&&A.vnode&&A.vnode(a),a}function F(e){return e.children}function ve(e,t){this.props=e,this.context=t,this.__g=0}function I(e,t){if(t==null)return e.__?I(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:I(e)}function ye(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),ye(e)}function be(e){(8&e.__g||!(e.__g|=8)||!j.push(e)||M++)&&ie==A.debounceRendering||((ie=A.debounceRendering)||queueMicrotask)(xe)}function xe(){var e,t,n,r,i,a,o,s,c;try{for(t=1;j.length;)j.length>t&&j.sort(ae),e=j.shift(),t=j.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=P({constructor:void 0},i)).__v=i.__v+1,A.vnode&&A.vnode(r),Oe(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||I(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,Ae(o,r,s),i.__=i.__e=null,r.__e!=a&&ye(r)))}finally{j.length=M=0}}function Se(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||fe,v=t.length;for(c=Ce(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||de,p.__i=d,g=Oe(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&(f.ref!=p.ref||8&f.__u)&&(f.ref!=p.ref&&f.ref&&Me(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h||=m,4&p.__u?(c=we(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function Ce(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m,h=n.length,g=h,_=0,v=!1,y=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=y[a]=_e(null,o):me(o)?o=y[a]=_e(F,{children:o}):o.constructor===void 0&&o.__b?o=y[a]=_e(o.type,o.props,o.key,o.ref,o.__v):y[a]=o,c=a+_,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=Te(o,n,c,g))&&(g--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=2,l==c-1?_--:l==c+1?_++:l!=c&&(l>c?_--:_++,v=!0)):(~l||(i>h?_--:i<h&&_++),typeof o.type!=`function`&&(o.__u|=4))):y[a]=null;if(v){for(u=[],d=[],a=0;a<i;a++)if((o=y[a])&&2&o.__u){for(f=0,p=u.length;f<p;)u[m=f+p>>1]<o.__i?f=m+1:p=m;u[f]=o.__i,d[a]=f+1}for(_=u.length;a--;)d[a]&&(d[a]==_?_--:y[a].__u|=4)}if(g)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=I(s)),Ne(s,s));return r}function we(e,t,n,r){var i,a;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=we(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=I(e))&&!t.parentNode&&(t=null),e.__e!=t&&(!r&&n.moveBefore&&e.__e.parentNode?n.moveBefore(e.__e,t):n.insertBefore(e.__e,t||null)),t=e.__e;(t&&=t.nextSibling)&&t.nodeType==8;);return t}function Te(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function Ee(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function L(e,t,n,r,i){var a;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||Ee(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||Ee(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(se,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),(e.__e||={})[t+a]=n,n?r?n[N]=r[N]:(n[N]=ce,e.addEventListener(t,a?ue:le,a)):e.removeEventListener(t,a?ue:le,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function De(e){return function(t){if(this.__e){var n=this.__e[t.type+e];if(t[oe]==null)t[oe]=ce++;else if(t[oe]<n[N])return;return n(A.event?A.event(t):t)}}}function Oe(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,ee,w,T,E,D,O,k=t.type;if(t.constructor!==void 0)return null;if(128&n.__u&&(c=32&n.__u,u=n.__c.__z)){if(t.__u|=c,d=a=[],u.nodeType==8)for(f=1,p=u.nextSibling;p;p=p.nextSibling){if(p.nodeType==8){if(p.data.startsWith(`$s`))f++;else if(p.data.startsWith(`/$s`)&&!--f)break}a.push(p)}else a.push(u);s=a[0]}(u=A.__b)&&u(t);n:if(typeof k==`function`){m=o.length;try{if(y=t.props,b=(u=k.prototype)&&u.render,x=(u=k.contextType)&&r[u.__c],S=u?x?x.props.value:u.__:r,n.__c?2&(h=t.__c=n.__c).__g&&(h.__g|=1):(b?t.__c=h=new k(y,S):(t.__c=h=new ve(y,S),h.constructor=k,h.render=Pe),x&&x.sub(h),h.state||(h.state={}),h.__n=r,h.__g|=8,h.__h=[],h.__k=[]),b&&(h.__s||(h.__s=h.state),k.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=P({},h.__s)),P(h.__s,k.getDerivedStateFromProps(y,h.__s)))),g=h.props,_=h.state,h.__v=t,n.__c){if(b&&!k.getDerivedStateFromProps&&y!==g&&h.componentWillReceiveProps&&h.componentWillReceiveProps(y,S),t.__v==n.__v&&!(8&h.__g)||!(4&h.__g)&&h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(y,h.__s,S)){t.__v!=n.__v&&(h.props=y,h.state=h.__s,h.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),fe.push.apply(h.__h,h.__k),h.__k=[],h.__h.length&&o.push(h),s=I(n);break n}h.componentWillUpdate&&h.componentWillUpdate(y,h.__s,S),b&&h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(g,_,v)})}else b&&!k.getDerivedStateFromProps&&h.componentWillMount&&h.componentWillMount(),b&&h.componentDidMount&&h.__h.push(h.componentDidMount);if(h.context=S,h.props=y,h.__P=e,h.__g&=-5,C=A.__r,ee=0,b)h.state=h.__s,h.__g&=-9,C&&C(t),u=h.render(h.props,h.state,h.context),fe.push.apply(h.__h,h.__k),h.__k=[];else do h.__g&=-9,C&&C(t),u=h.render(h.props,h.state,h.context),h.state=h.__s;while(8&h.__g&&++ee<25);h.state=h.__s,h.getChildContext&&(r=P({},r,h.getChildContext())),b&&n.__c&&h.getSnapshotBeforeUpdate&&(v=h.getSnapshotBeforeUpdate(g,_)),w=u&&u.type===F&&u.key==null?u.props.children:u,y.__P&&(u=s,i=(e=y.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&Ne(e,e)}),n.__k=null),s=n.__k?I(n,0):null),s=Se(e,me(w)?w:[w],t,n,r,i,a,o,s,c,l),y.__P&&(t.__e=null,s=u),t.__u&=-161,128&n.__u&&(h.__z=null),d&&d.some(ge),h.__h.length&&o.push(h),1&h.__g&&(h.__g&=-4)}catch(e){if(o.length=m,t.__v=null,c||a){if(e.then){if(T=0,t.__u|=c?160:128,a){for(D=0;D<a.length;D++)if(O=a[D]){if(O.nodeType==8){if(a[D]=null,O.data.startsWith(`$s`))T++||(E=O);else if(O.data.startsWith(`/$s`)&&!--T){s=O;break}}else T&&(a[D]=null)}}if(!E){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a&&(a[a.indexOf(s)]=null),E=s}t.__c.__z||(t.__c.__z=E),t.__e=s}else a&&a.some(ge)}else t.__e=n.__e;t.__k||=n.__k||[],e.then||ke(t),A.__e(e,t,n)}}else s=t.__e=je(n.__e,t,n,r,i,a,o,c,l,e);return(u=A.diffed)&&u(t),128&t.__u?void 0:s}function ke(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(ke))}function Ae(e,t,n){for(var r=0;r<n.length;)Me(n[r++],n[r++],n[r++]);A.__c&&A.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){A.__e(e,t.__v)}})}function je(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y=n.props||de,b=t.props,x=t.type;if(x==`svg`?i=`http://www.w3.org/2000/svg`:x==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a){for(u=0;u<a.length;u++)if((m=a[u])&&(x?m.localName==x:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!x)return _.createTextNode(b);e=_.createElementNS(i,x,b.is&&b),s&&=(A.__m&&A.__m(t,a),!1),a=null}if(x){if(l=x==`template`?e.content:e,a=x==`textarea`&&b.defaultValue!=null?null:a&&he.call(l.childNodes),!s&&a)for(y={},u=0;u<e.attributes.length;u++)y[(m=e.attributes[u]).name]=m.value;for(u in y)m=y[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in b||u==`value`&&`defaultValue`in b||u==`checked`&&`defaultChecked`in b||L(e,u,null,m,i);for(u in v=1&n.__u,b)m=b[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||!(y[u]!==m||v&&m!=null)||L(e,u,m,y[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(x==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&pe.test(x))&&(i=`http://www.w3.org/1999/xhtml`),Se(l,me(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&I(n,0),s,c),a&&a.some(ge)),s&&x!=`textarea`||(u=`value`,x==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(x!=`progress`||h)||L(e,u,h,y[u],i),u=`checked`,g!=null&&g!=e[u]&&L(e,u,g,y[u],i))}else y===b||s&&e.data==b||(e.data=b);return e}function Me(e,t,n){try{typeof e==`function`?(typeof e.__u==`function`&&e.__u(),(typeof e.__u!=`function`||t)&&(e.__u=e(t))):e.current=t}catch(e){A.__e(e,n)}}function Ne(e,t,n){var r,i;if(A.unmount&&A.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||Me(r,null,t),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){A.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ne(r[i],t,typeof e.type!=`function`||n&&!e.props.__P);(r=e.__e)&&(n||ge(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function Pe(e,t,n){return this.constructor(e,n)}function Fe(e,t){var n,r,i,a;A.__&&A.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=_e(F,{children:[e]}),i=[],a=[],Oe(t,t.__k,r||de,de,t.namespaceURI,r?null:t.firstChild?he.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),Ae(i,t.__k,a),t.__k.props.children=null}A={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t,o=0}}throw M=0,e}},re=0,ve.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=P({},this.state)),typeof e==`function`&&(e=e(P({},n),this.props)),e&&(P(n,e),this.__v&&(t&&this.__k.push(t),be(this)))},ve.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),be(this))},ve.prototype.render=F,j=[],M=0,ae=function(e,t){return e.__v.__b-t.__v.__b},oe=Symbol(),N=Symbol(),se=/(PointerCapture)$|Capture$/i,ce=0,le=De(!1),ue=De(!0);var R,z,Ie,Le,Re=Object.is,B=0,ze=[],Be=[],V=A,Ve=V.__b,He=V.__r,Ue=V.diffed,We=V.__c,Ge=V.unmount,Ke=V.__;function qe(e,t){V.__h&&V.__h(z,e,B||t),B=0;var n=z.__H||(z.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function H(e){return B=1,Je(nt,e)}function Je(e,t,n){var r=qe(R++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):nt(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);Re(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=z,!z.__f)){z.__f=!0;var i=z.shouldComponentUpdate;z.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,Re(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function U(e,t){var n=qe(R++,3);!V.__s&&tt(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,z.__H.__h.push(n))}function W(e){return B=5,Ye(function(){return{current:e}},[])}function Ye(e,t){var n=qe(R++,7);return tt(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Xe(){var e;do{for(;e=Be.shift();)try{G(e)}catch(t){V.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=ze.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(G),t.__h.some(et),t.__h=[]}catch(n){t.__h=[],V.__e(n,e.__v)}}}while(Be.length)}V.__b=function(e){z=null,Ve&&Ve(e)},V.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ke&&Ke(e,t)},V.__r=function(e){He&&He(e),R=0;var t=(z=e.__c).__H;t&&(Ie==z?z.__h=[]:(t.__h.some(G),t.__h.some(et),R=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Ie=z},V.diffed=function(e){Ue&&Ue(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&$e(ze.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Ie=z=null},V.__c=function(e,t){t.some(function(e){try{e.__h.some(G),e.__h=e.__h.filter(function(e){return!e.__||et(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],V.__e(n,e.__v)}}),We&&We(e,t)},V.unmount=function(e){Ge&&Ge(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,$e(Be.push(r))}else G(r)}catch(e){t=e}}),r.__H=void 0,t&&V.__e(t,r.__v))};var Ze=typeof requestAnimationFrame==`function`;function Qe(e){var t,n=function(){clearTimeout(r),Ze&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ze&&(t=requestAnimationFrame(n))}function $e(e){e!=1&&Le==V.requestAnimationFrame||((Le=V.requestAnimationFrame)||Qe)(Xe)}function G(e){var t=z,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),z=t}function et(e){var t=z;e.__c=e.__(),z=t}function tt(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Re(t,e[n])})}function nt(e,t){return typeof t==`function`?t(e):t}var rt=0;Array.isArray;function K(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--rt,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),A.vnode&&A.vnode(l),l}function q({name:e,size:t,children:n}){return K(`svg`,{"data-icon":e,"aria-hidden":`true`,focusable:`false`,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,children:n})}function it({size:e=26}){return K(q,{name:`chat`,size:e,children:[K(`path`,{d:`M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z`}),K(`path`,{d:`M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01`,"stroke-width":`2.5`})]})}function at({size:e=26}){return K(q,{name:`message`,size:e,children:K(`path`,{d:`M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z`})})}function ot({size:e=26}){return K(q,{name:`sparkle`,size:e,children:[K(`path`,{d:`M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z`}),K(`path`,{d:`M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z`})]})}function st({size:e=26}){return K(q,{name:`chevron-down`,size:e,children:K(`path`,{d:`M6 9l6 6 6-6`})})}function ct({size:e=18}){return K(q,{name:`close`,size:e,children:K(`path`,{d:`M6 6l12 12M18 6L6 18`})})}var lt=`M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7`;function ut({size:e=16}){return K(q,{name:`thumb-up`,size:e,children:K(`path`,{d:lt})})}function dt({size:e=16}){return K(q,{name:`thumb-down`,size:e,children:K(`path`,{d:lt,transform:`matrix(1 0 0 -1 0 24)`})})}var ft={chat:it,message:at,sparkle:ot},pt={"chevron-down":st,close:ct};function mt({isOpen:e,onClick:t,iconUrl:n,icon:r=`chat`,openIconUrl:i,openIcon:a=`chevron-down`,buttonRef:o}){let[s,c]=H(`loading`),[l,u]=H(`loading`),d=n!==void 0&&s!==`failed`,f=i!==void 0&&l!==`failed`,p=d&&!e&&s===`loaded`,m=f&&e&&l===`loaded`,h=ft[r]??it,g=pt[a]??st;return K(`button`,{type:`button`,class:`whoo-widget-launcher`,onClick:t,"aria-label":e?`Close chat`:`Open chat`,ref:o,children:[e?m?null:K(g,{}):p?null:K(h,{}),d?K(`img`,{class:`whoo-widget-launcher-icon-image`,src:n,alt:``,referrerpolicy:`no-referrer`,hidden:!p,onLoad:()=>c(`loaded`),onError:()=>c(`failed`)}):null,f?K(`img`,{class:`whoo-widget-launcher-icon-image`,src:i,alt:``,referrerpolicy:`no-referrer`,hidden:!m,onLoad:()=>u(`loaded`),onError:()=>u(`failed`)}):null]})}function ht({value:e,onChange:t,onSend:n,disabled:r,inputRef:i}){return K(`div`,{class:`whoo-widget-composer`,children:[K(`label`,{class:`whoo-widget-sr-only`,for:`whoo-widget-composer-input`,children:`Message`}),K(`input`,{id:`whoo-widget-composer-input`,class:`whoo-widget-composer-input`,value:e,readOnly:r,"aria-disabled":r,ref:i,onInput:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n()}}),K(`button`,{type:`button`,class:`whoo-widget-composer-send`,"aria-disabled":r,onClick:()=>{r||n()},children:`Send`})]})}function gt({message:e}){return K(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var _t=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,vt=/\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y,yt=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,bt=/\*([^*\s](?:[^*]*[^*\s])?)\*/y,xt=/[ \t]*[*+-][ \t]+/y,St=/https?:\/\/\S+/y,Ct=/[.,;:!?)\]}>]+$/;function wt(e){let t=[],n=0,r=0,i=n=>{n>r&&t.push({type:`text`,value:e.slice(r,n),start:r,end:n})};for(;n<e.length;){if((n===0||e[n-1]===`
|
|
2
|
-
`)&&(
|
|
1
|
+
var whooAidenWidget=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){if(e!=null&&e!==``){if(typeof e==`string`)try{let t=new URL(e);if(t.protocol===`https:`||t.protocol===`data:`&&t.pathname.toLowerCase().startsWith(`image/`))return e}catch{}console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`)}}var n=[`primary`,`onPrimary`,`primaryText`,`ink`,`link`,`text`,`panel`,`border`,`headerHover`,`assistantBubble`,`muted`,`typingDots`,`errorBackground`,`errorText`,`inputBorder`,`focusRing`],r={primary:`#4f46e5`,onPrimary:`#ffffff`,primaryText:`#4f46e5`,ink:`#111111`,link:`#0000ee`,text:`#111111`,panel:`#ffffff`,border:`#e5e5e5`,headerHover:`#f3f4f6`,assistantBubble:`#f0f0f0`,muted:`#4b5563`,typingDots:`#6b7280`,errorBackground:`#fee2e2`,errorText:`#991b1b`,inputBorder:`#6b7280`,focusRing:`#111827`},i={primary:`--whoo-widget-color`,onPrimary:`--whoo-widget-text-on-color`,primaryText:`--whoo-widget-color-text`,ink:`--whoo-widget-ink`,link:`--whoo-widget-link-color`,text:`--whoo-widget-text`,panel:`--whoo-widget-panel`,border:`--whoo-widget-border`,headerHover:`--whoo-widget-header-hover`,assistantBubble:`--whoo-widget-assistant-bubble`,muted:`--whoo-widget-muted`,typingDots:`--whoo-widget-typing-dots`,errorBackground:`--whoo-widget-error-bg`,errorText:`--whoo-widget-error-text`,inputBorder:`--whoo-widget-input-border`,focusRing:`--whoo-widget-focus-ring`},a=2147483e3,o=2147483647;function s(e){return e===void 0?a:Number.isInteger(e)&&Math.abs(e)<=o?e:(console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${o} and ${o}); using ${a}.`),a)}var c=`Aiden`;function l(e){return typeof e==`string`?e.trim():``}function u(e){if((typeof e.publishableKey==`string`&&e.publishableKey.length>0)==(typeof e.sessionToken==`string`&&e.sessionToken.length>0))throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.")}function d(e){console.warn(`whoo-aiden-widget: ${e}`)}var f=20;function p(e){let t=new WeakSet,n=new Set;return r=>{if(typeof r==`object`&&r||typeof r==`function`){if(t.has(r))return;t.add(r)}else{if(n.has(r))return;n.size>=f&&n.delete(n.values().next().value),n.add(r)}d(e)}}var m=p("ignoring `theme` -- expected an object."),h=p("ignoring `layout` -- expected an object.");function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var _=e=>e==null||e===``;function v(e,t,n){let r=e[t];return r==null?null:g(r)?r:(d(`ignoring \`${n}\` -- expected an object.`),null)}function y(e,t,n){for(let r of Object.keys(e))t.includes(r)||d(`ignoring unknown option \`${n}.${r}\`.`)}function b(e,t,n){if(!_(e)){if(typeof e==`string`&&t.includes(e))return e;d(`ignoring \`${n}\` -- expected one of ${t.join(`, `)}.`)}}var x=200,S=/url\(|[@;{}\\]/i;function C(e){if(!_(e)){if(typeof e==`string`){let t=e.trim();if(t&&t.length<=x&&!S.test(t))return t}d(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${x} characters, without url(), @, ;, {, } or \\.`)}}var ee=[`chat`,`message`,`sparkle`],w=[`chevron-down`,`close`],T=new WeakMap;function E(e){let r={colors:{},fontFamily:void 0,launcher:{}};if(e==null)return r;if(!g(e))return m(e),r;let i=T.get(e);if(i)return i;y(e,[`colors`,`fonts`,`launcher`],`theme`);let a=v(e,`colors`,`theme.colors`);if(a){y(a,n,`theme.colors`);for(let e of n){let t=a[e];_(t)||(typeof t==`string`?r.colors[e]=t:d(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`))}}let o=v(e,`fonts`,`theme.fonts`);o&&(y(o,[`family`],`theme.fonts`),r.fontFamily=C(o.family));let s=v(e,`launcher`,`theme.launcher`);if(s){y(s,[`icon`,`iconUrl`,`openIcon`,`openIconUrl`],`theme.launcher`);let e=b(s.icon,ee,`theme.launcher.icon`),n=t(s.iconUrl,`theme.launcher.iconUrl`),i=b(s.openIcon,w,`theme.launcher.openIcon`),a=t(s.openIconUrl,`theme.launcher.openIconUrl`);e&&(r.launcher.icon=e),n&&(r.launcher.iconUrl=n),i&&(r.launcher.openIcon=i),a&&(r.launcher.openIconUrl=a)}return T.set(e,r),r}var D={offsetX:20,offsetY:20,launcherSize:56,panelWidth:360,panelHeight:480};function O(e,t,n){return e==null?n:typeof e==`number`&&Number.isFinite(e)&&e>=0?e:(d(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`),n)}function k(e,t,n,r){let i=Math.min(r,Math.max(n,e));return i!==e&&d(`\`${t}\` ${e} is out of range (${r===1/0?`at least ${n}`:`${n}-${r}`}); using ${i}.`),i}var te=new WeakMap;function ne(e){let t={...D};if(e==null)return t;if(!g(e))return h(e),t;let n=te.get(e);if(n)return n;y(e,[`offset`,`launcherSize`,`panel`],`layout`);let r=v(e,`offset`,`layout.offset`);r&&(y(r,[`x`,`y`],`layout.offset`),t.offsetX=O(r.x,`layout.offset.x`,D.offsetX),t.offsetY=O(r.y,`layout.offset.y`,D.offsetY)),t.launcherSize=k(O(e.launcherSize,`layout.launcherSize`,D.launcherSize),`layout.launcherSize`,24,120);let i=v(e,`panel`,`layout.panel`);return i&&(y(i,[`width`,`height`],`layout.panel`),t.panelWidth=k(O(i.width,`layout.panel.width`,D.panelWidth),`layout.panel.width`,280,1/0),t.panelHeight=k(O(i.height,`layout.panel.height`,D.panelHeight),`layout.panel.height`,320,1/0)),te.set(e,t),t}var A,re,j,ie,ae,oe,se,M,ce,le,ue,de,fe={},pe=[],me=/^m(i|n|o|s|text|space)$/,he=Array.isArray,ge=pe.slice,N=Object.assign;function _e(e){e&&e.parentNode&&e.remove()}function ve(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i||++re,__i:-1,__u:0};return!i&&A.vnode&&A.vnode(a),a}function P(e){return e.children}function F(e,t){this.props=e,this.context=t,this.__g=0}function I(e,t){if(t==null)return e.__?I(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:I(e)}function ye(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),ye(e)}function be(e){(8&e.__g||!(e.__g|=8)||!j.push(e)||ae++)&&ie==A.debounceRendering||((ie=A.debounceRendering)||queueMicrotask)(xe)}function xe(){var e,t,n,r,i,a,o,s,c;try{for(t=1;j.length;)j.length>t&&j.sort(oe),e=j.shift(),t=j.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=N({constructor:void 0},i)).__v=i.__v+1,A.vnode&&A.vnode(r),Oe(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||I(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,Ae(o,r,s),i.__=i.__e=null,r.__e!=a&&ye(r)))}finally{j.length=ae=0}}function Se(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||pe,v=t.length;for(c=Ce(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||fe,p.__i=d,g=Oe(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&(f.ref!=p.ref||8&f.__u)&&(f.ref!=p.ref&&f.ref&&Me(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h||=m,4&p.__u?(c=we(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function Ce(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m,h=n.length,g=h,_=0,v=!1,y=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=y[a]=ve(null,o):he(o)?o=y[a]=ve(P,{children:o}):o.constructor===void 0&&o.__b?o=y[a]=ve(o.type,o.props,o.key,o.ref,o.__v):y[a]=o,c=a+_,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=Te(o,n,c,g))&&(g--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=2,l==c-1?_--:l==c+1?_++:l!=c&&(l>c?_--:_++,v=!0)):(~l||(i>h?_--:i<h&&_++),typeof o.type!=`function`&&(o.__u|=4))):y[a]=null;if(v){for(u=[],d=[],a=0;a<i;a++)if((o=y[a])&&2&o.__u){for(f=0,p=u.length;f<p;)u[m=f+p>>1]<o.__i?f=m+1:p=m;u[f]=o.__i,d[a]=f+1}for(_=u.length;a--;)d[a]&&(d[a]==_?_--:y[a].__u|=4)}if(g)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=I(s)),Ne(s,s));return r}function we(e,t,n,r){var i,a;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=we(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=I(e))&&!t.parentNode&&(t=null),e.__e!=t&&(!r&&n.moveBefore&&e.__e.parentNode?n.moveBefore(e.__e,t):n.insertBefore(e.__e,t||null)),t=e.__e;(t&&=t.nextSibling)&&t.nodeType==8;);return t}function Te(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function Ee(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function L(e,t,n,r,i){var a;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||Ee(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||Ee(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(ce,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),(e.__e||={})[t+a]=n,n?r?n[M]=r[M]:(n[M]=le,e.addEventListener(t,a?de:ue,a)):e.removeEventListener(t,a?de:ue,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function De(e){return function(t){if(this.__e){var n=this.__e[t.type+e];if(t[se]==null)t[se]=le++;else if(t[se]<n[M])return;return n(A.event?A.event(t):t)}}}function Oe(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,ee,w,T,E,D,O,k=t.type;if(t.constructor!==void 0)return null;if(128&n.__u&&(c=32&n.__u,u=n.__c.__z)){if(t.__u|=c,d=a=[],u.nodeType==8)for(f=1,p=u.nextSibling;p;p=p.nextSibling){if(p.nodeType==8){if(p.data.startsWith(`$s`))f++;else if(p.data.startsWith(`/$s`)&&!--f)break}a.push(p)}else a.push(u);s=a[0]}(u=A.__b)&&u(t);n:if(typeof k==`function`){m=o.length;try{if(y=t.props,b=(u=k.prototype)&&u.render,x=(u=k.contextType)&&r[u.__c],S=u?x?x.props.value:u.__:r,n.__c?2&(h=t.__c=n.__c).__g&&(h.__g|=1):(b?t.__c=h=new k(y,S):(t.__c=h=new F(y,S),h.constructor=k,h.render=Pe),x&&x.sub(h),h.state||(h.state={}),h.__n=r,h.__g|=8,h.__h=[],h.__k=[]),b&&(h.__s||(h.__s=h.state),k.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=N({},h.__s)),N(h.__s,k.getDerivedStateFromProps(y,h.__s)))),g=h.props,_=h.state,h.__v=t,n.__c){if(b&&!k.getDerivedStateFromProps&&y!==g&&h.componentWillReceiveProps&&h.componentWillReceiveProps(y,S),t.__v==n.__v&&!(8&h.__g)||!(4&h.__g)&&h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(y,h.__s,S)){t.__v!=n.__v&&(h.props=y,h.state=h.__s,h.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),pe.push.apply(h.__h,h.__k),h.__k=[],h.__h.length&&o.push(h),s=I(n);break n}h.componentWillUpdate&&h.componentWillUpdate(y,h.__s,S),b&&h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(g,_,v)})}else b&&!k.getDerivedStateFromProps&&h.componentWillMount&&h.componentWillMount(),b&&h.componentDidMount&&h.__h.push(h.componentDidMount);if(h.context=S,h.props=y,h.__P=e,h.__g&=-5,C=A.__r,ee=0,b)h.state=h.__s,h.__g&=-9,C&&C(t),u=h.render(h.props,h.state,h.context),pe.push.apply(h.__h,h.__k),h.__k=[];else do h.__g&=-9,C&&C(t),u=h.render(h.props,h.state,h.context),h.state=h.__s;while(8&h.__g&&++ee<25);h.state=h.__s,h.getChildContext&&(r=N({},r,h.getChildContext())),b&&n.__c&&h.getSnapshotBeforeUpdate&&(v=h.getSnapshotBeforeUpdate(g,_)),w=u&&u.type===P&&u.key==null?u.props.children:u,y.__P&&(u=s,i=(e=y.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&Ne(e,e)}),n.__k=null),s=n.__k?I(n,0):null),s=Se(e,he(w)?w:[w],t,n,r,i,a,o,s,c,l),y.__P&&(t.__e=null,s=u),t.__u&=-161,128&n.__u&&(h.__z=null),d&&d.some(_e),h.__h.length&&o.push(h),1&h.__g&&(h.__g&=-4)}catch(e){if(o.length=m,t.__v=null,c||a){if(e.then){if(T=0,t.__u|=c?160:128,a){for(D=0;D<a.length;D++)if(O=a[D]){if(O.nodeType==8){if(a[D]=null,O.data.startsWith(`$s`))T++||(E=O);else if(O.data.startsWith(`/$s`)&&!--T){s=O;break}}else T&&(a[D]=null)}}if(!E){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a&&(a[a.indexOf(s)]=null),E=s}t.__c.__z||(t.__c.__z=E),t.__e=s}else a&&a.some(_e)}else t.__e=n.__e;t.__k||=n.__k||[],e.then||ke(t),A.__e(e,t,n)}}else s=t.__e=je(n.__e,t,n,r,i,a,o,c,l,e);return(u=A.diffed)&&u(t),128&t.__u?void 0:s}function ke(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(ke))}function Ae(e,t,n){for(var r=0;r<n.length;)Me(n[r++],n[r++],n[r++]);A.__c&&A.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){A.__e(e,t.__v)}})}function je(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y=n.props||fe,b=t.props,x=t.type;if(x==`svg`?i=`http://www.w3.org/2000/svg`:x==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a){for(u=0;u<a.length;u++)if((m=a[u])&&(x?m.localName==x:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!x)return _.createTextNode(b);e=_.createElementNS(i,x,b.is&&b),s&&=(A.__m&&A.__m(t,a),!1),a=null}if(x){if(l=x==`template`?e.content:e,a=x==`textarea`&&b.defaultValue!=null?null:a&&ge.call(l.childNodes),!s&&a)for(y={},u=0;u<e.attributes.length;u++)y[(m=e.attributes[u]).name]=m.value;for(u in y)m=y[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in b||u==`value`&&`defaultValue`in b||u==`checked`&&`defaultChecked`in b||L(e,u,null,m,i);for(u in v=1&n.__u,b)m=b[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||!(y[u]!==m||v&&m!=null)||L(e,u,m,y[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(x==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&me.test(x))&&(i=`http://www.w3.org/1999/xhtml`),Se(l,he(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&I(n,0),s,c),a&&a.some(_e)),s&&x!=`textarea`||(u=`value`,x==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(x!=`progress`||h)||L(e,u,h,y[u],i),u=`checked`,g!=null&&g!=e[u]&&L(e,u,g,y[u],i))}else y===b||s&&e.data==b||(e.data=b);return e}function Me(e,t,n){try{typeof e==`function`?(typeof e.__u==`function`&&e.__u(),(typeof e.__u!=`function`||t)&&(e.__u=e(t))):e.current=t}catch(e){A.__e(e,n)}}function Ne(e,t,n){var r,i;if(A.unmount&&A.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||Me(r,null,t),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){A.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ne(r[i],t,typeof e.type!=`function`||n&&!e.props.__P);(r=e.__e)&&(n||_e(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function Pe(e,t,n){return this.constructor(e,n)}function Fe(e,t){var n,r,i,a;A.__&&A.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=ve(P,{children:[e]}),i=[],a=[],Oe(t,t.__k,r||fe,fe,t.namespaceURI,r?null:t.firstChild?ge.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),Ae(i,t.__k,a),t.__k.props.children=null}A={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t,o=0}}throw ae=0,e}},re=0,F.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=N({},this.state)),typeof e==`function`&&(e=e(N({},n),this.props)),e&&(N(n,e),this.__v&&(t&&this.__k.push(t),be(this)))},F.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),be(this))},F.prototype.render=P,j=[],ae=0,oe=function(e,t){return e.__v.__b-t.__v.__b},se=Symbol(),M=Symbol(),ce=/(PointerCapture)$|Capture$/i,le=0,ue=De(!1),de=De(!0);var R,z,Ie,Le,Re=Object.is,B=0,ze=[],Be=[],V=A,Ve=V.__b,He=V.__r,Ue=V.diffed,We=V.__c,Ge=V.unmount,Ke=V.__;function qe(e,t){V.__h&&V.__h(z,e,B||t),B=0;var n=z.__H||(z.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Je(e){return B=1,Ye(rt,e)}function Ye(e,t,n){var r=qe(R++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):rt(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);Re(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=z,!z.__f)){z.__f=!0;var i=z.shouldComponentUpdate;z.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,Re(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function H(e,t){var n=qe(R++,3);!V.__s&&nt(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,z.__H.__h.push(n))}function U(e){return B=5,Xe(function(){return{current:e}},[])}function Xe(e,t){var n=qe(R++,7);return nt(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Ze(){var e;do{for(;e=Be.shift();)try{W(e)}catch(t){V.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=ze.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(W),t.__h.some(tt),t.__h=[]}catch(n){t.__h=[],V.__e(n,e.__v)}}}while(Be.length)}V.__b=function(e){z=null,Ve&&Ve(e)},V.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ke&&Ke(e,t)},V.__r=function(e){He&&He(e),R=0;var t=(z=e.__c).__H;t&&(Ie==z?z.__h=[]:(t.__h.some(W),t.__h.some(tt),R=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Ie=z},V.diffed=function(e){Ue&&Ue(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&et(ze.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Ie=z=null},V.__c=function(e,t){t.some(function(e){try{e.__h.some(W),e.__h=e.__h.filter(function(e){return!e.__||tt(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],V.__e(n,e.__v)}}),We&&We(e,t)},V.unmount=function(e){Ge&&Ge(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,et(Be.push(r))}else W(r)}catch(e){t=e}}),r.__H=void 0,t&&V.__e(t,r.__v))};var Qe=typeof requestAnimationFrame==`function`;function $e(e){var t,n=function(){clearTimeout(r),Qe&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Qe&&(t=requestAnimationFrame(n))}function et(e){e!=1&&Le==V.requestAnimationFrame||((Le=V.requestAnimationFrame)||$e)(Ze)}function W(e){var t=z,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),z=t}function tt(e){var t=z;e.__c=e.__(),z=t}function nt(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Re(t,e[n])})}function rt(e,t){return typeof t==`function`?t(e):t}var it=0;Array.isArray;function G(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--it,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),A.vnode&&A.vnode(l),l}function K({name:e,size:t,children:n}){return G(`svg`,{"data-icon":e,"aria-hidden":`true`,focusable:`false`,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,children:n})}function at({size:e=26}){return G(K,{name:`chat`,size:e,children:[G(`path`,{d:`M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z`}),G(`path`,{d:`M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01`,"stroke-width":`2.5`})]})}function ot({size:e=26}){return G(K,{name:`message`,size:e,children:G(`path`,{d:`M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z`})})}function st({size:e=26}){return G(K,{name:`sparkle`,size:e,children:[G(`path`,{d:`M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z`}),G(`path`,{d:`M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z`})]})}function ct({size:e=26}){return G(K,{name:`chevron-down`,size:e,children:G(`path`,{d:`M6 9l6 6 6-6`})})}function lt({size:e=18}){return G(K,{name:`close`,size:e,children:G(`path`,{d:`M6 6l12 12M18 6L6 18`})})}var ut=`M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7`;function dt({size:e=16}){return G(K,{name:`thumb-up`,size:e,children:G(`path`,{d:ut})})}function ft({size:e=16}){return G(K,{name:`thumb-down`,size:e,children:G(`path`,{d:ut,transform:`matrix(1 0 0 -1 0 24)`})})}var pt={chat:at,message:ot,sparkle:st},mt={"chevron-down":ct,close:lt};function ht({isOpen:e,onClick:t,iconUrl:n,icon:r=`chat`,openIconUrl:i,openIcon:a=`chevron-down`,buttonRef:o}){let[s,c]=Je(`loading`),[l,u]=Je(`loading`),d=n!==void 0&&s!==`failed`,f=i!==void 0&&l!==`failed`,p=d&&!e&&s===`loaded`,m=f&&e&&l===`loaded`,h=pt[r]??at,g=mt[a]??ct;return G(`button`,{type:`button`,class:`whoo-widget-launcher`,onClick:t,"aria-label":e?`Close chat`:`Open chat`,ref:o,children:[e?m?null:G(g,{}):p?null:G(h,{}),d?G(`img`,{class:`whoo-widget-launcher-icon-image`,src:n,alt:``,referrerpolicy:`no-referrer`,hidden:!p,onLoad:()=>c(`loaded`),onError:()=>c(`failed`)}):null,f?G(`img`,{class:`whoo-widget-launcher-icon-image`,src:i,alt:``,referrerpolicy:`no-referrer`,hidden:!m,onLoad:()=>u(`loaded`),onError:()=>u(`failed`)}):null]})}function gt({value:e,onChange:t,onSend:n,disabled:r,inputRef:i}){return G(`div`,{class:`whoo-widget-composer`,children:[G(`label`,{class:`whoo-widget-sr-only`,for:`whoo-widget-composer-input`,children:`Message`}),G(`input`,{id:`whoo-widget-composer-input`,class:`whoo-widget-composer-input`,value:e,readOnly:r,"aria-disabled":r,ref:i,onInput:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n()}}),G(`button`,{type:`button`,class:`whoo-widget-composer-send`,"aria-disabled":r,onClick:()=>{r||n()},children:`Send`})]})}function _t({message:e}){return G(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var vt=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,yt=/\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y,bt=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,xt=/\*([^*\s](?:[^*]*[^*\s])?)\*/y,St=/[ \t]*[*+-][ \t]+/y,Ct=/https?:\/\/\S+/y,wt=/[.,;:!?)\]}>]+$/;function Tt(e){let t=[],n=0,r=0,i=n=>{n>r&&t.push({type:`text`,value:e.slice(r,n),start:r,end:n})};for(;n<e.length;){if((n===0||e[n-1]===`
|
|
2
|
+
`)&&(St.lastIndex=n,St.exec(e))){i(n),t.push({type:`text`,value:`• `,start:n,end:St.lastIndex}),n=St.lastIndex,r=n;continue}if(e[n]===`!`&&n+1<e.length&&e[n+1]===`[`){let t=/!\[([^\]]*)\]\(([^)]*)\)/y;t.lastIndex=n;let r=t.exec(e);if(r){n+=r[0].length;continue}}if(e[n-1]!==`!`){vt.lastIndex=n;let a=vt.exec(e);if(a){i(n),t.push({type:`link`,text:a[1],url:a[2],start:n,end:vt.lastIndex}),n=vt.lastIndex,r=n;continue}}yt.lastIndex=n;let a=yt.exec(e);if(a){i(n),t.push({type:`bold`,value:a[1],start:n,end:yt.lastIndex}),n=yt.lastIndex,r=n;continue}bt.lastIndex=n;let o=bt.exec(e);if(o){i(n),t.push({type:`italic`,value:o[1],start:n,end:bt.lastIndex}),n=bt.lastIndex,r=n;continue}xt.lastIndex=n;let s=xt.exec(e);if(s){i(n),t.push({type:`italic`,value:s[1],start:n,end:xt.lastIndex}),n=xt.lastIndex,r=n;continue}Ct.lastIndex=n;let c=Ct.exec(e);if(c){let e=c[0].match(wt),a=e?c[0].slice(0,c[0].length-e[0].length):c[0];if(a.length>0){i(n),t.push({type:`link`,text:a,url:a,start:n,end:n+a.length}),n+=a.length,r=n;continue}}n+=1}return i(e.length),t}var Et=/^[ \t]*[*+-][ \t]+(.*)$/;function Dt(e){let t=[],n=[],r=[],i=()=>{n.length>0&&t.push({type:`text`,text:n.join(`
|
|
3
3
|
`)}),n=[]},a=()=>{r.length>0&&t.push({type:`list`,items:r}),r=[]};for(let t of e.split(`
|
|
4
|
-
`)){let e=t.match(
|
|
5
|
-
`),n=
|
|
4
|
+
`)){let e=t.match(Et);e?(i(),r.push(e[1])):(a(),n.push(t))}return i(),a(),t.some(e=>e.type===`list`)?t.flatMap((e,n)=>{if(e.type===`list`)return[e];let{text:r}=e;return t[n-1]?.type===`list`&&(r=r.replace(/^(?:[ \t]*\n)+/,``)),t[n+1]?.type===`list`&&(r=r.replace(/(?:\n[ \t]*)+$/,``)),r.trim()===``?[]:[{type:`text`,text:r}]}):null}function q(e){return Tt(e).map((e,t)=>{switch(e.type){case`bold`:return G(`strong`,{children:q(e.value)},t);case`italic`:return G(`em`,{children:q(e.value)},t);case`link`:return G(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[e.text,G(`span`,{class:`whoo-widget-sr-only`,children:` (opens in new tab)`})]},t);default:return e.value}})}function Ot(e){let t=e.replace(/\r\n?/g,`
|
|
5
|
+
`),n=Dt(t);return n?n.map((e,t)=>e.type===`list`?G(`ul`,{class:`whoo-widget-list`,children:e.items.map((e,t)=>G(`li`,{children:q(e)},t))},t):G(`span`,{children:q(e.text)},t)):q(t)}var kt=[{value:``,label:`Select a reason (optional)`},{value:`factual`,label:`Factual error`},{value:`incomplete`,label:`Incomplete`},{value:`tone`,label:`Off tone`},{value:`other`,label:`Other`}];function At({state:e,containerRef:t,onThumbsUp:n,onThumbsDown:r,onDraftChange:i,onSubmitDetailed:a,onCancel:o}){let s=e.correction??``,c=e.category??``,l=U(e.status),u=U(null),d=U(null);if(H(()=>{let n=l.current;if(l.current=e.status,n===e.status)return;if(e.status===`expanded`){u.current?.focus();return}if(n===`expanded`&&e.status===`idle`){d.current?.focus();return}let r=t?.current;if(!r)return;let i=r.getRootNode();r.contains(i.activeElement)||r.focus()},[e.status,t]),e.status===`expanded`)return G(`div`,{class:`whoo-widget-feedback-form`,children:[G(`label`,{children:[G(`span`,{class:`whoo-widget-sr-only`,children:`Additional feedback`}),G(`textarea`,{ref:u,class:`whoo-widget-feedback-textarea`,value:s,onInput:e=>i(e.target.value,c),placeholder:`What was wrong? (optional)`})]}),G(`select`,{class:`whoo-widget-feedback-select`,"aria-label":`Feedback category`,value:c,onChange:e=>i(s,e.target.value),children:kt.map(e=>G(`option`,{value:e.value,children:e.label},e.value))}),G(`div`,{class:`whoo-widget-feedback-form-buttons`,children:[G(`button`,{type:`button`,class:`whoo-widget-feedback-submit`,onClick:()=>a(s,c),children:`Submit`}),G(`button`,{type:`button`,class:`whoo-widget-feedback-cancel`,onClick:o,children:`Cancel`})]})]});let f=e.status===`submitting`,p=e.status===`submitted`;return G(`div`,{class:`whoo-widget-feedback`,children:[p?null:G(`div`,{class:`whoo-widget-feedback-buttons`,children:[G(`button`,{type:`button`,"aria-label":`Good response`,disabled:f,onClick:n,children:G(dt,{})}),G(`button`,{ref:d,type:`button`,"aria-label":`Bad response`,disabled:f,onClick:r,children:G(ft,{})})]}),G(`div`,{role:`status`,class:p?`whoo-widget-feedback-submitted`:e.status===`error`?`whoo-widget-feedback-error`:void 0,children:p?`Thanks for the feedback`:e.status===`error`?`Couldn't send feedback`:null})]})}function jt({isSlowResponse:e}){return G(`div`,{class:`whoo-widget-pending`,role:`status`,children:[G(`span`,{class:`whoo-widget-typing`,"aria-hidden":`true`,children:[G(`span`,{}),G(`span`,{}),G(`span`,{})]}),e?G(`span`,{class:`whoo-widget-pending-text`,children:`Looking that up for you…`}):null]})}function Mt({url:e,alt:t}){let[n,r]=Je(!1);return n?null:G(`img`,{class:`whoo-widget-empty-state-image`,src:e,alt:t,referrerpolicy:`no-referrer`,onError:()=>r(!0)})}function Nt({message:e,speaker:t,feedbackState:n,showFeedback:r,pending:i,isSlowResponse:a,onThumbsUp:o,onThumbsDown:s,onDraftChange:c,onSubmitDetailed:l,onCancelFeedback:u}){let d=U(null),f=e.id;return G(`div`,{ref:d,tabIndex:-1,class:`whoo-widget-message whoo-widget-message--${e.role}`,children:[G(`span`,{class:`whoo-widget-sr-only`,children:[t,`: `]}),i?G(jt,{isSlowResponse:a}):Ot(e.content),r&&e.role===`assistant`&&f?G(At,{state:n,containerRef:d,onThumbsUp:()=>o(f),onThumbsDown:()=>s(f),onDraftChange:(e,t)=>c(f,e,t),onSubmitDetailed:(e,t)=>l(f,e,t),onCancel:()=>u(f)}):null]})}function Pt({messages:e,messageFeedback:t,announcement:n,emptyStateImage:r,agentName:i=c,showFeedback:a=!1,isStreaming:o=!1,isSlowResponse:s=!1,onThumbsUp:l,onThumbsDown:u,onDraftChange:d=()=>{},onSubmitDetailed:f,onCancelFeedback:p}){let m=U(null);return H(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[e,s]),G(P,{children:[G(`section`,{class:`whoo-widget-message-list`,ref:m,"aria-label":`Conversation`,tabIndex:0,children:[r?G(Mt,{...r}):null,e.map((n,r)=>G(Nt,{message:n,speaker:n.role===`user`?`You`:i,showFeedback:a,feedbackState:n.id?t[n.id]??{status:`idle`}:{status:`idle`},pending:o&&r===e.length-1&&n.role===`assistant`&&n.content===``,isSlowResponse:s,onThumbsUp:l,onThumbsDown:u,onDraftChange:d,onSubmitDetailed:f,onCancelFeedback:p},n.id??r))]}),G(`div`,{class:`whoo-widget-sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:n??``})]})}var Ft=`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`;function It(e){return Array.from(e.querySelectorAll(Ft)).filter(e=>{let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}function Lt({state:e,controller:t,greeting:n}){let r=U(null),i=U(null);H(()=>{i.current?.focus()},[]);let a=e=>{if(e.key===`Escape`){t.close();return}if(e.key!==`Tab`)return;let n=r.current;if(!n)return;let i=It(n);if(i.length===0)return;let a=i[0],o=i[i.length-1],s=n.getRootNode().activeElement;if(!n.contains(s)){e.preventDefault(),a.focus();return}e.shiftKey&&s===a?(e.preventDefault(),o.focus()):!e.shiftKey&&s===o&&(e.preventDefault(),a.focus())},o=()=>{let n=e.draft.trim();n&&!e.isStreaming&&(t.setDraft(``),t.sendMessage(n))},s=l(t.config.name)||e.agentName||`Aiden`,c=l(t.config.title)||`Chat with ${s}`,u=e.messages.length===0&&n?[{role:`assistant`,content:n,id:null}]:e.messages,d=t.emptyStateImageUrl,f=e.messages.length===0&&d?{url:d,alt:t.emptyStateImageAlt}:void 0;return G(`div`,{class:`whoo-widget-panel`,role:`dialog`,"aria-modal":`true`,"aria-label":c,ref:r,onKeyDown:a,children:[G(`div`,{class:`whoo-widget-header`,children:[G(`h2`,{class:`whoo-widget-header-title`,children:c}),G(`div`,{class:`whoo-widget-header-actions`,children:[e.messages.length>0&&G(`button`,{type:`button`,class:`whoo-widget-header-reset`,onClick:()=>{t.resetConversation(),i.current?.focus()},children:`New conversation`}),G(`button`,{type:`button`,class:`whoo-widget-header-close`,"aria-label":`Close chat`,onClick:()=>t.close(),children:G(lt,{})})]})]}),G(Pt,{messages:u,messageFeedback:e.messageFeedback,announcement:e.announcement,emptyStateImage:f,agentName:s,showFeedback:t.showFeedback,isStreaming:e.isStreaming,isSlowResponse:e.isSlowResponse,onThumbsUp:e=>t.submitFeedback(e,`up`),onThumbsDown:e=>t.expandFeedback(e),onDraftChange:(e,n,r)=>t.setFeedbackDraft(e,n,r),onSubmitDetailed:(e,n,r)=>t.submitFeedback(e,`down`,n||void 0,r||void 0),onCancelFeedback:e=>t.cancelFeedback(e)}),e.runtimeError&&G(_t,{message:e.runtimeError}),G(gt,{value:e.draft,onChange:e=>t.setDraft(e),onSend:o,disabled:e.isStreaming,inputRef:i})]})}function Rt({controller:e}){let[t,n]=Je(e.getState()),r=U(null),i=U(t.isOpen);return H(()=>(n(e.getState()),e.subscribe(n)),[e]),H(()=>{i.current&&!t.isOpen&&r.current?.focus(),i.current=t.isOpen},[t.isOpen]),t.initError||t.isInitializing?null:G(P,{children:[G(ht,{isOpen:t.isOpen,onClick:()=>t.isOpen?e.close():e.open(),iconUrl:e.launcher.iconUrl,icon:e.launcher.icon,openIconUrl:e.launcher.openIconUrl,openIcon:e.launcher.openIcon,buttonRef:r}),t.isOpen&&G(Lt,{state:t,controller:e,greeting:e.config.greeting})]})}var zt=class extends Error{status;constructor(e,t){super(e),this.name=`WidgetApiError`,this.status=t}};function Bt(e){if(typeof e!=`string`)return null;let t=e.trim();return t===``?null:t}async function Vt(e,t){let n=await fetch(`${e}/api/v1/widget/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({publishable_key:t})});if(!n.ok)throw new zt(`Failed to create widget session (${n.status})`,n.status);let r=await n.json();return{token:r.token,...Ht(r)}}function Ht(e){return{primaryColor:Bt(e.primary_color),name:Bt(e.name),accentColor:Bt(e.accent_color),inkColor:Bt(e.ink_color)}}async function Ut(e,t){let n=await fetch(`${e}/api/v1/widget/branding`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw new zt(`Failed to load widget branding (${n.status})`,n.status);return Ht(await n.json())}async function Wt(e,t,n){let r=await fetch(`${e}/api/v1/widget/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({message_id:n.messageId,rating:n.rating,correction:n.correction??null,category:n.category??null})});if(!r.ok)throw new zt(`Feedback submission failed (${r.status})`,r.status)}async function*Gt(e,t,n,r,i){let a=await fetch(`${e}/api/v1/widget/chat`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({conversation_id:n,message:r}),signal:i});if(!a.ok||!a.body)throw new zt(`Chat request failed (${a.status})`,a.status);let o=a.body.getReader(),s=new TextDecoder,c=``;for(;;){let{done:e,value:t}=await o.read();if(e)break;c+=s.decode(t,{stream:!0});let n=c.indexOf(`
|
|
6
6
|
|
|
7
7
|
`);for(;n!==-1;){let e=c.slice(0,n);c=c.slice(n+2);let t=e.split(`
|
|
8
|
-
`).find(e=>e.startsWith(`data: `));t&&(yield
|
|
8
|
+
`).find(e=>e.startsWith(`data: `));t&&(yield Kt(JSON.parse(t.slice(6)))),n=c.indexOf(`
|
|
9
9
|
|
|
10
|
-
`)}}}function
|
|
11
|
-
`)).map(e=>{switch(e.type){case`bold`:case`italic`:return Kt(e.value);case`link`:return e.text;default:return e.value}}).join(``)}var qt=40,Jt=120;function Yt(e){let t=[];for(let n of wt(e))if(n.type===`text`){let e=n.value.split(/(\s+)/),r=n.start;for(let n of e)r+=n.length,n.trim().length>0&&t.push(r)}else t.push(n.end);return t}function Xt(e){let t=null;return e?.addEventListener(`abort`,()=>{t?.()},{once:!0}),function(e){return new Promise(n=>{let r=setTimeout(()=>{t=null,n()},e);t=()=>{clearTimeout(r),t=null,n()}})}}async function Zt(e,t,n){let r=n?.wordIntervalMs??qt,i=n?.tokenIntervalMs??Jt,a=n?.signal,o=wt(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=Xt(a),l=``;for(let n of Yt(e))if(a?.aborted||(l=e.slice(0,n),t(l),await c(s.has(n)?i:r),a?.aborted))return;l!==e&&t(e)}function Qt(e,t=Date.now()){let n=e.split(`.`);if(n.length!==3||n.some(e=>e===``))return!1;let r=n[1];try{let e=r.replace(/-/g,`+`).replace(/_/g,`/`),n=JSON.parse(atob(e.padEnd(Math.ceil(e.length/4)*4,`=`)))?.exp;return typeof n==`number`&&Number.isFinite(n)&&n*1e3<=t}catch{return!1}}function $t(e){return`whoo-aiden-widget:conversation:${e}`}function en(e){try{return window.sessionStorage.getItem($t(e))}catch{return null}}function tn(e,t){try{window.sessionStorage.setItem($t(e),t)}catch{}}function nn(e){try{window.sessionStorage.removeItem($t(e))}catch{}}var rn=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function an(e){if(rn.test(e.trim()))return null;let t=document.createElement(`div`);if(t.style.color=e,t.style.color===``)return null;let n=document.createElement(`div`);n.attachShadow({mode:`open`}).appendChild(t),document.body.appendChild(n);let r=getComputedStyle(t).color;n.remove();let i=r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);if(!i)return null;let a=i[4]===void 0?1:Number(i[4]);return{rgb:[Number(i[1]),Number(i[2]),Number(i[3])].map(e=>Math.round(e*a+255*(1-a))),translucent:a<1}}function Y(e){return an(e)?.rgb??null}function X([e,t,n]){let r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function on(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function sn(e){let t=Y(e);if(!t)return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`),`#ffffff`;let n=X(t);return on(n,X([0,0,0]))>=on(n,X([255,255,255]))?`#000000`:`#ffffff`}function cn(e,t){let n=Y(e),r=Y(t);return!n||!r?NaN:on(X(n),X(r))}var ln=r.primary,un=r.panel,dn=r.assistantBubble,fn=r.headerHover,pn=4.5;function Z([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function mn(e,t=un){let n=Y(e),r=Y(t);if(!n||!r)return ln;let i=X(r),a=e=>on(X(e),i)>=pn;if(a(n))return Z(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return Z(t)}return`#000000`}var hn=r.ink,gn=r.link;function Q(e){if(typeof e!=`string`||!e)return null;let t=an(e);return t?Z(t.rgb):null}function _n(e){if(typeof e!=`string`||!e)return null;let t=an(e);return t?t.translucent?e.trim():Z(t.rgb):null}var vn=[{role:`onPrimary`,against:[`primary`],required:4.5},{role:`primaryText`,against:[`panel`,`headerHover`],required:4.5},{role:`ink`,against:[`assistantBubble`,`panel`],required:4.5},{role:`link`,against:[`assistantBubble`],required:4.5},{role:`muted`,against:[`assistantBubble`],required:4.5},{role:`text`,against:[`panel`,`assistantBubble`],required:4.5},{role:`errorText`,against:[`errorBackground`],required:4.5},{role:`typingDots`,against:[`assistantBubble`],required:3},{role:`inputBorder`,against:[`panel`],required:3},{role:`focusRing`,against:[`panel`],required:3}];function yn({color:e,inkColor:t,accentColor:i,overrides:a}){let o=typeof a==`object`&&a&&!Array.isArray(a)?a:{},s=e=>_n(o[e]),c=Q(e),l=s(`primary`),u=l??c??ln,d=s(`primaryText`),f=d??mn(u,fn),p=s(`onPrimary`)??sn(u),m=Q(t),h=s(`ink`)??(m?mn(m,dn):hn),g=Q(i),_=s(`link`)??(g?mn(g,dn):gn),v=e=>s(e)??r[e],y={primary:u,onPrimary:p,primaryText:f,ink:h,link:_,text:v(`text`),panel:v(`panel`),border:v(`border`),headerHover:v(`headerHover`),assistantBubble:v(`assistantBubble`),muted:v(`muted`),typingDots:v(`typingDots`),errorBackground:v(`errorBackground`),errorText:v(`errorText`),inputBorder:v(`inputBorder`),focusRing:v(`focusRing`)},b=Object.fromEntries(n.map(e=>[e,s(e)!==null])),x=[];for(let{role:e,against:t,required:n}of vn)if(b[e])for(let r of t){let t=cn(y[e],y[r]);Number.isFinite(t)&&t<n&&x.push({role:e,against:r,value:y[e],ratio:t,required:n})}return{primary:u,textOnPrimary:p,primaryAsText:f,ink:h,link:_,adjusted:{primary:l===null&&d===null&&c!==null&&f!==u,ink:!b.ink&&m!==null&&h!==m,link:!b.link&&g!==null&&_!==g},roles:y,overridden:b,contrastWarnings:x}}function bn(e){return typeof e==`string`?`"${e}"`:`a ${typeof e} value`}function xn(e,t,n=ln){let r=t;Q(t)===null&&(console.warn(`[whoo-aiden-widget] Could not use ${bn(t)} as the theme color; falling back to ${bn(n)}.`),r=n);let i=yn({color:r});e.style.setProperty(`--whoo-widget-color`,i.primary),e.style.setProperty(`--whoo-widget-text-on-color`,i.textOnPrimary),e.style.setProperty(`--whoo-widget-color-text`,i.primaryAsText)}function Sn(e,{inkColor:t,accentColor:n}){let r=yn({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function Cn(e,t){let r=yn({overrides:t});for(let t of n){let n=r.overridden.primary&&(t===`onPrimary`||t===`primaryText`);(r.overridden[t]||n)&&e.style.setProperty(i[t],r.roles[t])}}function wn(e,t){e&&Q(e)===null&&console.warn(`[whoo-aiden-widget] Could not use ${bn(e)} as the ${t}; using the default.`)}function Tn(e,t){for(let e of n){let n=t[e];n&&Q(n)===null&&console.warn(`[whoo-aiden-widget] Could not use ${bn(n)} as theme.colors.${e}; using the calculated color.`)}let{contrastWarnings:r}=yn({color:e.color,inkColor:e.inkColor,accentColor:e.accentColor,overrides:t});for(let{role:e,against:t,value:n,ratio:i,required:a}of r)console.warn(`[whoo-aiden-widget] theme.colors.${e} (${n}) has ${i.toFixed(2)}:1 contrast against the ${t} color; ${a}:1 is recommended. Using it as given.`)}function En(e,t){xn(e,t.color??ln),wn(t.inkColor,`ink color`),wn(t.accentColor,`accent color`),Sn(e,{inkColor:t.inkColor,accentColor:t.accentColor});let n=E(t.theme);Tn(t,n.colors),Cn(e,n.colors),n.fontFamily&&(e.style.setProperty(`--whoo-widget-font`,n.fontFamily),e.setAttribute(`data-whoo-custom-font`,``))}var Dn=8e3,On=3e3;function kn(e,t){return new Promise(n=>{let r=setTimeout(n,t);e.then(()=>{clearTimeout(r),n()})})}var An=class{config;state;listeners=new Set;sessionToken=null;conversationId=null;storageIdentifier;activeRequestController=null;slowResponseTimer=null;prefersReducedMotion;launcher;launcherIconUrl;emptyStateImageUrl;emptyStateImageAlt;showFeedback;constructor(e){this.config=e;let n=E(e.theme).launcher,r=n.iconUrl??t(e.launcherIconUrl,`launcherIconUrl`);this.launcher={...n,...r?{iconUrl:r}:{}},this.launcherIconUrl=r,this.emptyStateImageUrl=t(e.emptyStateImageUrl,`emptyStateImageUrl`),this.emptyStateImageAlt=typeof e.emptyStateImageAlt==`string`?e.emptyStateImageAlt.trim():``,this.showFeedback=e.showFeedback===!0,this.storageIdentifier=e.publishableKey??`session-token-mode`,this.prefersReducedMotion=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.state={isOpen:!1,messages:[],isStreaming:!1,initError:null,isInitializing:!1,runtimeError:null,messageFeedback:{},primaryColor:null,agentName:null,accentColor:null,inkColor:null,announcement:null,isSlowResponse:!1,draft:``}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clearSlowResponse(){this.slowResponseTimer!==null&&(clearTimeout(this.slowResponseTimer),this.slowResponseTimer=null),this.state.isSlowResponse&&this.setState({isSlowResponse:!1})}setState(e){this.state={...this.state,...e};for(let e of this.listeners)e(this.state)}async init(){this.setState({isInitializing:!0});try{await this.start()}finally{this.setState({isInitializing:!1})}}async start(){let e=this.config.apiBaseUrl??`https://api.aidenvoice.com`;try{if(this.config.sessionToken){if(Qt(this.config.sessionToken))throw Error(`The sessionToken has expired.`);this.sessionToken=this.config.sessionToken}else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await Bt(e,this.config.publishableKey);this.sessionToken=t,this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}else throw Error(`WidgetConfig must include exactly one of publishableKey or sessionToken`)}catch(e){console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)});return}this.conversationId=en(this.storageIdentifier),this.config.sessionToken&&await kn(this.loadBranding(e,this.config.sessionToken),On)}async loadBranding(e,t){try{let n=this.config;if(Q(n.color)&&Q(n.inkColor)&&Q(n.accentColor)&&l(n.name))return;let{primaryColor:r,name:i,accentColor:a,inkColor:o}=await Ht(e,t);this.setState({primaryColor:r,agentName:i,accentColor:a,inkColor:o})}catch(e){let t=e?.status;(t===401||t===403)&&(console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)}))}}open(){this.setState({isOpen:!0})}resetConversation(){this.activeRequestController?.abort(),this.activeRequestController=null,this.clearSlowResponse(),this.conversationId=null,nn(this.storageIdentifier),this.setState({messages:[],messageFeedback:{},runtimeError:null,isStreaming:!1,announcement:`Conversation cleared`})}setDraft(e){this.setState({draft:e})}close(){this.activeRequestController?.abort(),this.activeRequestController=null,this.clearSlowResponse(),this.setState({isOpen:!1})}async sendMessage(e){if(!this.sessionToken)return;let t=this.config.apiBaseUrl??`https://api.aidenvoice.com`,n={role:`user`,content:e,id:null},r={role:`assistant`,content:``,id:null};this.setState({messages:[...this.state.messages,n,r],isStreaming:!0,runtimeError:null,announcement:null});let i=e=>{let t=[...this.state.messages];t[t.length-1]={...t[t.length-1],content:e},this.setState({messages:t})};this.activeRequestController=new AbortController;let{signal:a}=this.activeRequestController;this.slowResponseTimer=setTimeout(()=>{this.slowResponseTimer=null,this.setState({isSlowResponse:!0})},Dn);let o=()=>{this.setState({runtimeError:`Something went wrong, please try again.`,...this.state.draft===``?{draft:e}:{}})},s=``;try{for await(let n of Wt(t,this.sessionToken,this.conversationId,e,a))if(n.type===`conversation_id`)this.conversationId=n.conversationId,tn(this.storageIdentifier,n.conversationId);else if(n.type===`delta`)this.clearSlowResponse(),n.verbatim&&!this.prefersReducedMotion?(await Zt(n.delta,e=>i(e),{signal:a}),s=n.delta):n.verbatim?(s=n.delta,i(s)):(s+=n.delta,i(s));else if(n.type===`done`){if(n.conversationId&&(this.conversationId=n.conversationId,tn(this.storageIdentifier,n.conversationId)),n.messageId){let e=[...this.state.messages];e[e.length-1]={...e[e.length-1],id:n.messageId},this.setState({messages:e})}this.setState({announcement:Kt(s)})}else if(n.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,n.error),o(),this.activeRequestController?.abort();break}}catch(e){e?.name===`AbortError`||(console.error(`[whoo-aiden-widget] chat request failed:`,e),o())}finally{this.activeRequestController=null,this.clearSlowResponse(),this.setState({isStreaming:!1})}}expandFeedback(e){let{correction:t,category:n}=this.state.messageFeedback[e]??{};this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`expanded`,correction:t,category:n}}})}setFeedbackDraft(e,t,n){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{...this.state.messageFeedback[e],correction:t,category:n}}})}cancelFeedback(e){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`idle`}}})}async submitFeedback(e,t,n,r){if(!this.sessionToken)return;let i=this.config.apiBaseUrl??`https://api.aidenvoice.com`;this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitting`,rating:t}}});try{await Ut(i,this.sessionToken,{messageId:e,rating:t,correction:n,category:r}),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitted`,rating:t}}})}catch(i){console.error(`[whoo-aiden-widget] feedback submission failed:`,i),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`error`,rating:t,correction:n,category:r}}})}}},$=20,jn=12,Mn=300,Nn=352;function Pn(e,t){let{offsetX:n,offsetY:r,launcherSize:i,panelWidth:a,panelHeight:o}=ne(t.layout),s=e=>typeof t.layout?.offset?.[e]==`number`;if(typeof window<`u`&&window.innerWidth>0&&window.innerHeight>0){let e=Math.max($,window.innerWidth-Mn),t=Math.max($,window.innerHeight-i-Nn);s(`x`)&&(n>e||n>window.innerWidth-i)&&console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`),s(`y`)&&(r>t||r>window.innerHeight-i)&&console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`)}let c=`min(${n}px, max(${$}px, calc(100vw - ${Mn}px)), calc(100vw - ${i}px))`,l=`min(${r}px, max(${$}px, calc(100vh - ${i+Nn}px)), calc(100vh - ${i}px))`,u=`calc(${l} + ${i}px + ${jn}px)`,d=t.position===`bottom-left`,f=(t,n)=>e.style.setProperty(t,n);f(`--whoo-widget-inset-left`,d?c:`auto`),f(`--whoo-widget-inset-right`,d?`auto`:c),f(`--whoo-widget-inset-bottom`,l),f(`--whoo-widget-launcher-size`,`${i}px`),f(`--whoo-widget-panel-bottom`,u),f(`--whoo-widget-panel-width`,`${a}px`),f(`--whoo-widget-panel-height`,`${o}px`),f(`--whoo-widget-panel-max-width`,`calc(100vw - ${c} - ${$}px)`),f(`--whoo-widget-panel-max-height`,`calc(100vh - ${u} - ${$}px)`)}var Fn=`:host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);border-radius:12px;flex-direction:column;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding:8px 8px 8px 16px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-left:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-left:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}[data-whoo-custom-font] button,[data-whoo-custom-font] input,[data-whoo-custom-font] textarea,[data-whoo-custom-font] select{font-family:inherit}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}`;function In(e){let t=document.createElement(`div`);t.id=`whoo-aiden-widget-host`,t.style.position=`relative`,t.style.zIndex=String(s(e.zIndex));let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);r.textContent=Fn,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i),En(i,e),Pn(i,e);let a=new An(e),o=Q(e.color)!==null,c=null,l=``,u=E(e.theme).colors;return a.subscribe(t=>{let n=!1;!o&&t.primaryColor&&t.primaryColor!==c&&(c=t.primaryColor,xn(i,t.primaryColor,e.color),n=!0);let r=`${t.inkColor}|${t.accentColor}`;(t.inkColor||t.accentColor)&&r!==l&&(l=r,Sn(i,{inkColor:Q(e.inkColor)?e.inkColor:t.inkColor,accentColor:Q(e.accentColor)?e.accentColor:t.accentColor}),n=!0),n&&Cn(i,u)}),a.init(),Fe(K(Lt,{controller:a}),i),document.body.appendChild(t),{unmount(){Fe(null,i),t.remove()}}}function Ln(e){return u(e),In(e)}return e.init=Ln,e})({});
|
|
10
|
+
`)}}}function Kt(e){return typeof e.error==`string`?{type:`error`,error:e.error,conversationId:e.conversation_id}:e.done===!0?{type:`done`,conversationId:e.conversation_id,messageId:e.message_id??null}:typeof e.delta==`string`?e.verbatim===!0?{type:`delta`,delta:e.delta,verbatim:!0}:{type:`delta`,delta:e.delta}:{type:`conversation_id`,conversationId:e.conversation_id}}function qt(e){return Tt(e.replace(/\r\n?/g,`
|
|
11
|
+
`)).map(e=>{switch(e.type){case`bold`:case`italic`:return qt(e.value);case`link`:return e.text;default:return e.value}}).join(``)}var Jt=40,Yt=120;function Xt(e){let t=[];for(let n of Tt(e))if(n.type===`text`){let e=n.value.split(/(\s+)/),r=n.start;for(let n of e)r+=n.length,n.trim().length>0&&t.push(r)}else t.push(n.end);return t}function Zt(e){let t=null;return e?.addEventListener(`abort`,()=>{t?.()},{once:!0}),function(e){return new Promise(n=>{let r=setTimeout(()=>{t=null,n()},e);t=()=>{clearTimeout(r),t=null,n()}})}}async function Qt(e,t,n){let r=n?.wordIntervalMs??Jt,i=n?.tokenIntervalMs??Yt,a=n?.signal,o=Tt(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=Zt(a),l=``;for(let n of Xt(e))if(a?.aborted||(l=e.slice(0,n),t(l),await c(s.has(n)?i:r),a?.aborted))return;l!==e&&t(e)}function $t(e,t=Date.now()){let n=e.split(`.`);if(n.length!==3||n.some(e=>e===``))return!1;let r=n[1];try{let e=r.replace(/-/g,`+`).replace(/_/g,`/`),n=JSON.parse(atob(e.padEnd(Math.ceil(e.length/4)*4,`=`)))?.exp;return typeof n==`number`&&Number.isFinite(n)&&n*1e3<=t}catch{return!1}}function en(e){return`whoo-aiden-widget:conversation:${e}`}function tn(e){try{return window.sessionStorage.getItem(en(e))}catch{return null}}function nn(e,t){try{window.sessionStorage.setItem(en(e),t)}catch{}}function rn(e){try{window.sessionStorage.removeItem(en(e))}catch{}}var an=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function on(e){if(an.test(e.trim()))return null;let t=document.createElement(`div`);if(t.style.color=e,t.style.color===``)return null;let n=document.createElement(`div`);n.attachShadow({mode:`open`}).appendChild(t),document.body.appendChild(n);let r=getComputedStyle(t).color;n.remove();let i=r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);if(!i)return null;let a=i[4]===void 0?1:Number(i[4]);return{rgb:[Number(i[1]),Number(i[2]),Number(i[3])].map(e=>Math.round(e*a+255*(1-a))),translucent:a<1}}function J(e){return on(e)?.rgb??null}function Y([e,t,n]){let r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function sn(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function cn(e){let t=J(e);if(!t)return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`),`#ffffff`;let n=Y(t);return sn(n,Y([0,0,0]))>=sn(n,Y([255,255,255]))?`#000000`:`#ffffff`}function ln(e,t){let n=J(e),r=J(t);return!n||!r?NaN:sn(Y(n),Y(r))}var un=r.primary,dn=r.panel,fn=r.assistantBubble,pn=r.headerHover,mn=4.5;function X([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function hn(e,t=dn){let n=J(e),r=J(t);if(!n||!r)return un;let i=Y(r),a=e=>sn(Y(e),i)>=mn;if(a(n))return X(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return X(t)}return`#000000`}var gn=r.ink,_n=r.link;function Z(e){if(typeof e!=`string`||!e)return null;let t=on(e);return t?X(t.rgb):null}function vn(e){if(typeof e!=`string`||!e)return null;let t=on(e);return t?t.translucent?e.trim():X(t.rgb):null}var yn=[{role:`onPrimary`,against:[`primary`],required:4.5},{role:`primaryText`,against:[`panel`,`headerHover`],required:4.5},{role:`ink`,against:[`assistantBubble`,`panel`],required:4.5},{role:`link`,against:[`assistantBubble`],required:4.5},{role:`muted`,against:[`assistantBubble`],required:4.5},{role:`text`,against:[`panel`,`assistantBubble`],required:4.5},{role:`errorText`,against:[`errorBackground`],required:4.5},{role:`typingDots`,against:[`assistantBubble`],required:3},{role:`inputBorder`,against:[`panel`],required:3},{role:`focusRing`,against:[`panel`],required:3}];function bn({color:e,inkColor:t,accentColor:i,overrides:a}){let o=typeof a==`object`&&a&&!Array.isArray(a)?a:{},s=e=>vn(o[e]),c=Z(e),l=s(`primary`),u=l??c??un,d=s(`primaryText`),f=d??hn(u,pn),p=s(`onPrimary`)??cn(u),m=Z(t),h=s(`ink`)??(m?hn(m,fn):gn),g=Z(i),_=s(`link`)??(g?hn(g,fn):_n),v=e=>s(e)??r[e],y={primary:u,onPrimary:p,primaryText:f,ink:h,link:_,text:v(`text`),panel:v(`panel`),border:v(`border`),headerHover:v(`headerHover`),assistantBubble:v(`assistantBubble`),muted:v(`muted`),typingDots:v(`typingDots`),errorBackground:v(`errorBackground`),errorText:v(`errorText`),inputBorder:v(`inputBorder`),focusRing:v(`focusRing`)},b=Object.fromEntries(n.map(e=>[e,s(e)!==null])),x=[];for(let{role:e,against:t,required:n}of yn)for(let r of t){if(!b[e]&&!b[r])continue;let t=ln(y[e],y[r]);Number.isFinite(t)&&t<n&&x.push({role:e,against:r,value:y[e],ratio:t,required:n,overridden:b[e]})}return{primary:u,textOnPrimary:p,primaryAsText:f,ink:h,link:_,adjusted:{primary:l===null&&d===null&&c!==null&&f!==u,ink:!b.ink&&m!==null&&h!==m,link:!b.link&&g!==null&&_!==g},roles:y,overridden:b,contrastWarnings:x}}function Q(e){return typeof e==`string`?`"${e}"`:`a ${typeof e} value`}function xn(e,t,n=un){let r=t;Z(t)===null&&(console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`),r=n);let i=bn({color:r});e.style.setProperty(`--whoo-widget-color`,i.primary),e.style.setProperty(`--whoo-widget-text-on-color`,i.textOnPrimary),e.style.setProperty(`--whoo-widget-color-text`,i.primaryAsText)}function Sn(e,{inkColor:t,accentColor:n}){let r=bn({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function Cn(e,t){let r=bn({overrides:t});for(let t of n){let n=r.overridden.primary&&(t===`onPrimary`||t===`primaryText`);(r.overridden[t]||n)&&e.style.setProperty(i[t],r.roles[t])}}function wn(e,t){e&&Z(e)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`)}function Tn(e,t){for(let e of n){let n=t[e];n&&Z(n)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Q(n)} as theme.colors.${e}; using the calculated color.`)}let r=t.primary;typeof r==`string`&&on(r)?.translucent&&console.warn(`[whoo-aiden-widget] theme.colors.primary ${Q(r)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`);let{contrastWarnings:i}=bn({color:e.color,inkColor:e.inkColor,accentColor:e.accentColor,overrides:t});for(let{role:e,against:t,value:n,ratio:r,required:a,overridden:o}of i)console.warn(o?`[whoo-aiden-widget] theme.colors.${e} (${n}) has ${r.toFixed(2)}:1 contrast against the ${t} color; ${a}:1 is recommended. Using it as given.`:`[whoo-aiden-widget] the ${e} color (${n}) has ${r.toFixed(2)}:1 contrast against your theme.colors.${t}; ${a}:1 is recommended. Override theme.colors.${e} too.`)}function En(e,t){xn(e,t.color??un),wn(t.inkColor,`ink color`),wn(t.accentColor,`accent color`),Sn(e,{inkColor:t.inkColor,accentColor:t.accentColor});let n=E(t.theme);Tn(t,n.colors),Cn(e,n.colors),n.fontFamily&&(e.style.setProperty(`--whoo-widget-font`,n.fontFamily),e.setAttribute(`data-whoo-custom-font`,``))}var Dn=8e3,On=3e3;function kn(e,t){return new Promise(n=>{let r=setTimeout(n,t);e.then(()=>{clearTimeout(r),n()})})}var An=class{config;state;listeners=new Set;sessionToken=null;conversationId=null;storageIdentifier;activeRequestController=null;slowResponseTimer=null;prefersReducedMotion;launcher;launcherIconUrl;emptyStateImageUrl;emptyStateImageAlt;showFeedback;constructor(e){this.config=e;let n=E(e.theme).launcher,r=n.iconUrl??t(e.launcherIconUrl,`launcherIconUrl`);this.launcher={...n,...r?{iconUrl:r}:{}},this.launcherIconUrl=r,this.emptyStateImageUrl=t(e.emptyStateImageUrl,`emptyStateImageUrl`),this.emptyStateImageAlt=typeof e.emptyStateImageAlt==`string`?e.emptyStateImageAlt.trim():``,this.showFeedback=e.showFeedback===!0,this.storageIdentifier=e.publishableKey??`session-token-mode`,this.prefersReducedMotion=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.state={isOpen:!1,messages:[],isStreaming:!1,initError:null,isInitializing:!1,runtimeError:null,messageFeedback:{},primaryColor:null,agentName:null,accentColor:null,inkColor:null,announcement:null,isSlowResponse:!1,draft:``}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clearSlowResponse(){this.slowResponseTimer!==null&&(clearTimeout(this.slowResponseTimer),this.slowResponseTimer=null),this.state.isSlowResponse&&this.setState({isSlowResponse:!1})}setState(e){this.state={...this.state,...e};for(let e of this.listeners)e(this.state)}async init(){this.setState({isInitializing:!0});try{await this.start()}finally{this.setState({isInitializing:!1})}}async start(){let e=this.config.apiBaseUrl??`https://api.aidenvoice.com`;try{if(this.config.sessionToken){if($t(this.config.sessionToken))throw Error(`The sessionToken has expired.`);this.sessionToken=this.config.sessionToken}else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await Vt(e,this.config.publishableKey);this.sessionToken=t,this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}else throw Error(`WidgetConfig must include exactly one of publishableKey or sessionToken`)}catch(e){console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)});return}this.conversationId=tn(this.storageIdentifier),this.config.sessionToken&&await kn(this.loadBranding(e,this.config.sessionToken),On)}async loadBranding(e,t){try{let n=this.config;if(Z(n.color)&&Z(n.inkColor)&&Z(n.accentColor)&&l(n.name))return;let{primaryColor:r,name:i,accentColor:a,inkColor:o}=await Ut(e,t);this.setState({primaryColor:r,agentName:i,accentColor:a,inkColor:o})}catch(e){let t=e?.status;(t===401||t===403)&&(console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)}))}}open(){this.setState({isOpen:!0})}resetConversation(){this.activeRequestController?.abort(),this.activeRequestController=null,this.clearSlowResponse(),this.conversationId=null,rn(this.storageIdentifier),this.setState({messages:[],messageFeedback:{},runtimeError:null,isStreaming:!1,announcement:`Conversation cleared`})}setDraft(e){this.setState({draft:e})}close(){this.activeRequestController?.abort(),this.activeRequestController=null,this.clearSlowResponse(),this.setState({isOpen:!1})}async sendMessage(e){if(!this.sessionToken)return;let t=this.config.apiBaseUrl??`https://api.aidenvoice.com`,n={role:`user`,content:e,id:null},r={role:`assistant`,content:``,id:null};this.setState({messages:[...this.state.messages,n,r],isStreaming:!0,runtimeError:null,announcement:null});let i=e=>{let t=[...this.state.messages];t[t.length-1]={...t[t.length-1],content:e},this.setState({messages:t})};this.activeRequestController=new AbortController;let{signal:a}=this.activeRequestController;this.slowResponseTimer=setTimeout(()=>{this.slowResponseTimer=null,this.setState({isSlowResponse:!0})},Dn);let o=()=>{this.setState({runtimeError:`Something went wrong, please try again.`,...this.state.draft===``?{draft:e}:{}})},s=``;try{for await(let n of Gt(t,this.sessionToken,this.conversationId,e,a))if(n.type===`conversation_id`)this.conversationId=n.conversationId,nn(this.storageIdentifier,n.conversationId);else if(n.type===`delta`)this.clearSlowResponse(),n.verbatim&&!this.prefersReducedMotion?(await Qt(n.delta,e=>i(e),{signal:a}),s=n.delta):n.verbatim?(s=n.delta,i(s)):(s+=n.delta,i(s));else if(n.type===`done`){if(n.conversationId&&(this.conversationId=n.conversationId,nn(this.storageIdentifier,n.conversationId)),n.messageId){let e=[...this.state.messages];e[e.length-1]={...e[e.length-1],id:n.messageId},this.setState({messages:e})}this.setState({announcement:qt(s)})}else if(n.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,n.error),o(),this.activeRequestController?.abort();break}}catch(e){e?.name===`AbortError`||(console.error(`[whoo-aiden-widget] chat request failed:`,e),o())}finally{this.activeRequestController=null,this.clearSlowResponse();let e=this.state.messages.filter(e=>e!==r);this.setState({isStreaming:!1,...e.length===this.state.messages.length?{}:{messages:e}})}}expandFeedback(e){let{correction:t,category:n}=this.state.messageFeedback[e]??{};this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`expanded`,correction:t,category:n}}})}setFeedbackDraft(e,t,n){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{...this.state.messageFeedback[e],correction:t,category:n}}})}cancelFeedback(e){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`idle`}}})}async submitFeedback(e,t,n,r){if(!this.sessionToken)return;let i=this.config.apiBaseUrl??`https://api.aidenvoice.com`;this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitting`,rating:t}}});try{await Wt(i,this.sessionToken,{messageId:e,rating:t,correction:n,category:r}),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitted`,rating:t}}})}catch(i){console.error(`[whoo-aiden-widget] feedback submission failed:`,i),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`error`,rating:t,correction:n,category:r}}})}}},$=20,jn=12,Mn=300,Nn=352;function Pn(e,t){let{offsetX:n,offsetY:r,launcherSize:i,panelWidth:a,panelHeight:o}=ne(t.layout),s=e=>typeof t.layout?.offset?.[e]==`number`;if(typeof window<`u`&&window.innerWidth>0&&window.innerHeight>0){let e=Math.max($,window.innerWidth-Mn),t=Math.max($,window.innerHeight-i-Nn);s(`x`)&&(n>e||n>window.innerWidth-i)&&console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`),s(`y`)&&(r>t||r>window.innerHeight-i)&&console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`)}let c=`min(${n}px, max(${$}px, calc(100vw - ${Mn}px)), calc(100vw - ${i}px))`,l=`min(${r}px, max(${$}px, calc(100vh - ${i+Nn}px)), calc(100vh - ${i}px))`,u=`calc(${l} + ${i}px + ${jn}px)`,d=t.position===`bottom-left`,f=(t,n)=>e.style.setProperty(t,n);f(`--whoo-widget-inset-left`,d?c:`auto`),f(`--whoo-widget-inset-right`,d?`auto`:c),f(`--whoo-widget-inset-bottom`,l),f(`--whoo-widget-launcher-size`,`${i}px`),f(`--whoo-widget-panel-bottom`,u),f(`--whoo-widget-panel-width`,`${a}px`),f(`--whoo-widget-panel-height`,`${o}px`),f(`--whoo-widget-panel-max-width`,`calc(100vw - ${c} - ${$}px)`),f(`--whoo-widget-panel-max-height`,`calc(100vh - ${u} - ${$}px)`)}var Fn=`:host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);border-radius:12px;flex-direction:column;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding:8px 8px 8px 16px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-left:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-left:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}[data-whoo-custom-font] button,[data-whoo-custom-font] input,[data-whoo-custom-font] textarea,[data-whoo-custom-font] select{font-family:inherit}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}`;function In(e){let t=document.createElement(`div`);t.id=`whoo-aiden-widget-host`,t.style.position=`relative`,t.style.zIndex=String(s(e.zIndex));let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);r.textContent=Fn,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i),En(i,e),Pn(i,e);let a=new An(e),o=Z(e.color)!==null,c=null,l=``,u=E(e.theme).colors;return a.subscribe(t=>{let n=!1;!o&&t.primaryColor&&t.primaryColor!==c&&(c=t.primaryColor,xn(i,t.primaryColor,e.color),n=!0);let r=`${t.inkColor}|${t.accentColor}`;(t.inkColor||t.accentColor)&&r!==l&&(l=r,Sn(i,{inkColor:Z(e.inkColor)?e.inkColor:t.inkColor,accentColor:Z(e.accentColor)?e.accentColor:t.accentColor}),n=!0),n&&Cn(i,u)}),a.init(),Fe(G(Rt,{controller:a}),i),document.body.appendChild(t),{unmount(){Fe(null,i),t.remove()}}}function Ln(e){return u(e),In(e)}return e.init=Ln,e})({});
|