@usereq/widget 1.0.0-experimental.0 → 1.0.0-experimental.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 CHANGED
@@ -24,11 +24,11 @@ Importing the module instead gives `render(snapshot, host, { apiUrl?, theme?, si
24
24
  | Look | `appearance.ts` | accent, alpha → fill, readable text colour, radius, glass skin, position - the preview's arithmetic, pure; `isMessenger` when a bubble carries `preset: "facebook-messenger"`, and `surfaces/chat-messenger.tsx` draws it from `@workspace/contracts/embed/presets` instead (the accent, alpha and radius go unused; placement, the content and the parts still apply) |
25
25
  | Rules | `rules.ts`, `surface.tsx` | the payload's ENABLED rules in priority order; the first whose conditions fit the page (path, utm, device, referrer) arms its trigger (`page_load`, `time_on_page`, `scroll_depth`, `element_click`, `element_visible`, `exit_intent`); when it fires the surface **shows** - the dashboard's sentence is "When …, show <surface>", so a firing is the show, `autoStart` puts the visitor in the composer, `pinned` takes the close away. `once` is remembered per visit in `sessionStorage`. No rules: the surface rests - a bubble's launcher alone, a banner or a testimonial straight away, a popup on exit intent |
26
26
  | Groups | `group.ts`, `mount.tsx` | the group's rules say when it plays; `split` picks a member by weight and remembers the bucket (`localStorage`), `sequence` walks the lineup on each member's `advanceOn` and remembers the step |
27
- | Chat | `chat/use-conversation.ts`, `stream.ts`, `api.ts` | `POST /api/embed/sessions` on the first send, then `POST /api/embed/chat` - the AI SDK UI-message stream read by hand (`stream.ts`), one bubble per paragraph on the preview's reveal clock (`@workspace/contracts/embed/reveal`); Stop aborts, Retry regenerates; a refused session (401/409) is minted anew on the next send |
27
+ | Chat | `chat/use-conversation.ts`, `chat/session-store.ts`, `stream.ts`, `api.ts` | `POST /api/embed/sessions` on the first send, then `POST /api/embed/chat` - the AI SDK UI-message stream read by hand (`stream.ts`), one bubble per paragraph on the preview's reveal clock (`@workspace/contracts/embed/reveal`); Stop aborts, Retry regenerates. The session is kept per surface in `localStorage` (the token is bound to the origin that minted it, and `localStorage` is per origin - so a kept token is only ever presented from the site it belongs to) and a surface that mounts with one reads the thread back (`GET /api/embed/sessions/current`), so a reload or the next page of the site carries the conversation on; a refused session (401/409, expired) is forgotten and minted anew on the next send. The visitor ends it with the `MessageCircleX` control (the panel header, or beside the send where there is no header): the agent asks "Stop the conversation?" in the thread, "Stop conversation" ends it on the server (`POST /api/embed/sessions/current/end` - the dashboard shows it ended) and clears the page for a fresh start; "Keep chatting" takes the card away. Chat only - the other surfaces have no agent |
28
28
  | Events | `events.ts` | `embed.loaded`, `surface.opened/closed`, `rule.fired`, `cta.clicked`, … batched to `POST /api/embed/events` with client-minted uuidv7 ids (the server's dedupe key) and a per-browser visitor key |
29
29
  | Styling hooks | `base.css.ts`, `appearance.ts` | a static base sheet in the shadow root, then the customer's: `appearance.parts` adds their class beside the runtime's `uq-<part>` on each named part, `appearance.customCss` is appended as-is, a block's `css` is scoped to that block's element |
30
30
 
31
- Storage keys, all optional conveniences that degrade to "forgotten" (`storage.ts` never throws): `usereq:visitor` (localStorage), `usereq:once:<ruleId>` (sessionStorage), `usereq:split:<groupId>`, `usereq:seq:<groupId>`.
31
+ Storage keys, all optional conveniences that degrade to "forgotten" (`storage.ts` never throws): `usereq:visitor` (localStorage), `usereq:session:<widgetId>` (localStorage - the chat session, for the token's 24 h), `usereq:once:<ruleId>` (sessionStorage), `usereq:split:<groupId>`, `usereq:seq:<groupId>`.
32
32
 
33
33
  On a phone (`max-width: 639px`, live through `matchMedia`, `drawer.tsx`): the bubble's panel is a bottom sheet at half the screen instead of a card beside the launcher. The grab bar drags it to full height or, past the bottom, away; a flick decides on its own; the header gains a close button; the launcher hides while the sheet is up. A pinned surface never closes - the drag down settles at half. Heights are percentages of the viewport as it is (under a collapsing address bar or a keyboard), not `vh`. The chatbar is already a bottom strip and the stream keeps floating; the exit popup's card scrolls inside itself on a short screen.
34
34
 
@@ -43,7 +43,7 @@ bun run size # the gzip gate - fails the build over 25 kB
43
43
 
44
44
  The dev host page takes `?id=…&kind=widget|group&bg=light|dark|photo&api=http://localhost:4000`, plus `variant=bubble|chatbar|box|stream` and `preset=default|facebook-messenger` to render a chat surface as another variant or under a preset (the real snapshot with `config.variant` / `config.preset` swapped, through `render`) - every look from one published surface. The origin gate is open for an org with no verified domain; with one, run `apps/api` with `DASHBOARD_ORIGIN=http://localhost:5173` or add `localhost` to the list.
45
45
 
46
- `USEREQ_EMBED_API_URL` at build time bakes the default API origin (`https://api.usereq.com` otherwise); `api-url` on the element overrides it per mount.
46
+ `USEREQ_EMBED_API_URL` at build time bakes the default API origin (the contracts' `EMBED_API_URL`, `https://api.usereq.com`, otherwise); `api-url` on the element overrides it per mount. The dashboard writes that attribute into the snippet only when its own `NEXT_PUBLIC_API_URL` is not the production API - a dev or staging deployment - so a production snippet stays two lines with nothing to override.
47
47
 
48
48
  ## Publishing
49
49
 
package/dist/embed.js CHANGED
@@ -1,5 +1,5 @@
1
- var UserEQ=(function(ke){Object.defineProperty(ke,Symbol.toStringTag,{value:"Module"});async function Kt(e){const t=e.getReader(),n=new TextDecoder;let r="",o="";const i=[],s=new Map,u=d=>{if(!d.startsWith("data:"))return;const c=d.slice(5).trim();if(!c||c==="[DONE]")return;let f;try{f=JSON.parse(c)}catch{return}switch(f.type){case"start":"messageId"in f&&f.messageId&&(o=f.messageId);break;case"text-start":"id"in f&&(i.push(f.id),s.set(f.id,""));break;case"text-delta":if("id"in f&&"delta"in f){var p;s.set(f.id,((p=s.get(f.id))!==null&&p!==void 0?p:"")+f.delta)}break;case"error":throw new Error("errorText"in f?f.errorText:"The reply failed.");case"abort":throw new Error("The reply was cut short.")}};for(;;){const{done:d,value:c}=await t.read();if(d)break;r+=n.decode(c,{stream:!0});let f;for(;(f=r.indexOf(`
2
- `))!==-1;)u(r.slice(0,f).replace(/\r$/,"")),r=r.slice(f+1)}return r&&u(r),{id:o||`reply-${Date.now()}`,parts:i.map(d=>{var c;return(c=s.get(d))!==null&&c!==void 0?c:""})}}function V(e){"@babel/helpers - typeof";return V=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},V(e)}function Xt(e,t){if(V(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(V(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Jt(e){var t=Xt(e,"string");return V(t)=="symbol"?t:t+""}function Se(e,t,n){return(t=Jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var te=class extends Error{constructor(e,t,n){super(n),Se(this,"status",void 0),Se(this,"code",void 0),this.status=e,this.code=t}};async function $e(e){let t="request_failed",n=`The request failed (${e.status}).`;try{var r,o;const i=await e.json();!((r=i.error)===null||r===void 0)&&r.code&&(t=i.error.code),!((o=i.error)===null||o===void 0)&&o.message&&(n=i.error.message)}catch{}throw new te(e.status,t,n)}var Ce=(e,t={})=>({method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(e)});async function Qt(e,t,n){const r=await fetch(`${e.base}/api/embed/${t}/${n}`);return r.ok?r.json():$e(r)}async function Zt(e,t){const n=await fetch(`${e.base}/api/embed/sessions`,Ce(t));return n.ok?n.json():$e(n)}async function en(e,t,n,r,o){const i=await fetch(`${e.base}/api/embed/chat`,{...Ce({message:{id:n.id,role:"user",parts:[{type:"text",text:n.text}]},trigger:r},{Authorization:`Bearer ${t}`}),signal:o});return!i.ok||!i.body?$e(i):Kt(i.body)}async function tn(e,t){try{const n=await fetch(`${e.base}/api/embed/events`,{...Ce(t),keepalive:!0});return n.ok?await n.json():null}catch{return null}}var N=e=>typeof e=="object"&&e!==null;function Ve(e){return N(e)&&typeof e.id=="string"&&N(e.config)&&typeof e.config.type=="string"&&N(e.config.appearance)&&Array.isArray(e.rules)}function nn(e){return N(e)&&typeof e.id=="string"&&typeof e.mode=="string"&&N(e.config)&&Array.isArray(e.members)&&e.members.every(t=>N(t)&&Ve(t.widget))&&Array.isArray(e.rules)}function rn(e,t){return!N(e)||e.kind!==t?null:t==="widget"&&Ve(e.payload)||t==="group"&&nn(e.payload)?e:null}var ne,$,Ke,on,D,Xe,Je,Qe,qe,re,K,Ze,Ie,Me,Te,an,ie={},oe=[],sn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ae=Array.isArray;function B(e,t){for(var n in t)e[n]=t[n];return e}function Ae(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ln(e,t,n){var r,o,i,s={};for(i in t)i=="key"?r=t[i]:i=="ref"?o=t[i]:s[i]=t[i];if(arguments.length>2&&(s.children=arguments.length>3?ne.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)s[i]===void 0&&(s[i]=e.defaultProps[i]);return se(e,s,r,o,null)}function se(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o==null?++Ke:o,__i:-1,__u:0};return o==null&&$.vnode!=null&&$.vnode(i),i}function L(e){return e.children}function le(e,t){this.props=e,this.context=t}function O(e,t){if(t==null)return e.__?O(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?O(e):null}function cn(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],o=[],i=B({},t);i.__v=t.__v+1,$.vnode&&$.vnode(i),Ee(e.__P,i,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n==null?O(t):n,!!(32&t.__u),o),i.__v=t.__v,i.__.__k[i.__i]=i,st(r,i,o),t.__e=t.__=null,i.__e!=n&&et(i)}}function et(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),et(e)}function tt(e){(!e.__d&&(e.__d=!0)&&D.push(e)&&!ce.__r++||Xe!=$.debounceRendering)&&((Xe=$.debounceRendering)||Je)(ce)}function ce(){try{for(var e,t=1;D.length;)D.length>t&&D.sort(Qe),e=D.shift(),t=D.length,cn(e)}finally{D.length=ce.__r=0}}function nt(e,t,n,r,o,i,s,u,d,c,f){var p,l,h,m,y,w,_=r&&r.__k||oe,g=t.length;for(d=un(n,t,_,d,g),p=0;p<g;p++)(h=n.__k[p])!=null&&(l=h.__i!=-1&&_[h.__i]||ie,h.__i=p,w=Ee(e,h,l,o,i,s,u,d,c,f),m=h.__e,h.ref&&l.ref!=h.ref&&(l.ref&&ze(l.ref,null,h),f.push(h.ref,h.__c||m,h)),y==null&&m!=null&&(y=m),4&h.__u?(d=rt(h,d,e),l.__e&&(l.__e=null)):typeof h.type=="function"&&w!==void 0?d=w:m&&(d=m.nextSibling),h.__u&=-7);return n.__e=y,d}function un(e,t,n,r,o){var i,s,u,d,c,f=n.length,p=f,l=0;for(e.__k=new Array(o),i=0;i<o;i++)(s=t[i])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=e.__k[i]=se(null,s,null,null,null):ae(s)?s=e.__k[i]=se(L,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[i]=se(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[i]=s,d=i+l,s.__=e,s.__b=e.__b+1,u=null,(c=s.__i=dn(s,n,d,p))!=-1&&(p--,(u=n[c])&&(u.__u|=2)),u==null||u.__v==null?(c==-1&&(o>f?l--:o<f&&l++),typeof s.type!="function"&&(s.__u|=4)):c!=d&&(c==d-1?l--:c==d+1?l++:(c>d?l--:l++,s.__u|=4))):e.__k[i]=null;if(p)for(i=0;i<f;i++)(u=n[i])!=null&&(2&u.__u)==0&&(u.__e==r&&(r=O(u)),ct(u,u));return r}function rt(e,t,n){var r,o;if(typeof e.type=="function"){for(r=e.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=e,t=rt(r[o],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=O(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function dn(e,t,n,r){var o,i,s,u=e.key,d=e.type,c=t[n],f=c!=null&&(2&c.__u)==0;if(c===null&&u==null||f&&u==c.key&&d==c.type)return n;if(r>(f?1:0)){for(o=n-1,i=n+1;o>=0||i<t.length;)if((c=t[s=o>=0?o--:i++])!=null&&(2&c.__u)==0&&u==c.key&&d==c.type)return s}return-1}function it(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":typeof n!="number"||sn.test(t)?n:n+"px"}function ue(e,t,n,r,o){var i,s;e: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||it(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||it(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")i=t!=(t=t.replace(Ze,"$1")),s=t.toLowerCase(),t=s in e||t=="onFocusOut"||t=="onFocusIn"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r?n[K]=r[K]:(n[K]=Ie,e.addEventListener(t,i?Te:Me,i)):e.removeEventListener(t,i?Te:Me,i);else{if(o=="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==null?"":n;break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function ot(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[re]==null)t[re]=Ie++;else if(t[re]<n[K])return;return n($.event?$.event(t):t)}}}function Ee(e,t,n,r,o,i,s,u,d,c){var f,p,l,h,m,y,w,_,g,v,k,x,q,C,z,H,E=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),i=[u=t.__e=n.__e]),(f=$.__b)&&f(t);e:if(typeof E=="function"){p=s.length;try{if(g=t.props,v=E.prototype&&E.prototype.render,k=(f=E.contextType)&&r[f.__c],x=f?k?k.props.value:f.__:r,n.__c?_=(l=t.__c=n.__c).__=l.__E:(v?t.__c=l=new E(g,x):(t.__c=l=new le(g,x),l.constructor=E,l.render=hn),k&&k.sub(l),l.state||(l.state={}),l.__n=r,h=l.__d=!0,l.__h=[],l._sb=[]),v&&l.__s==null&&(l.__s=l.state),v&&E.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=B({},l.__s)),B(l.__s,E.getDerivedStateFromProps(g,l.__s))),m=l.props,y=l.state,l.__v=t,h)v&&E.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),v&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(v&&E.getDerivedStateFromProps==null&&g!==m&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(g,x),t.__v==n.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(g,l.__s,x)===!1){t.__v!=n.__v&&(l.props=g,l.state=l.__s,l.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(R){R&&(R.__=t)}),oe.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&s.push(l),u=O(n);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(g,l.__s,x),v&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(m,y,w)})}if(l.context=x,l.props=g,l.__P=e,l.__e=!1,q=$.__r,C=0,v)l.state=l.__s,l.__d=!1,q&&q(t),f=l.render(l.props,l.state,l.context),oe.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,q&&q(t),f=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++C<25);l.state=l.__s,l.getChildContext!=null&&(r=B(B({},r),l.getChildContext())),v&&!h&&l.getSnapshotBeforeUpdate!=null&&(w=l.getSnapshotBeforeUpdate(m,y)),z=f!=null&&f.type===L&&f.key==null?lt(f.props.children):f,u=nt(e,ae(z)?z:[z],t,n,r,o,i,s,u,d,c),l.base=t.__e,t.__u&=-161,l.__h.length&&s.push(l),_&&(l.__E=l.__=null)}catch(R){if(s.length=p,t.__v=null,d||i!=null){if(R.then){for(t.__u|=d?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;i!=null&&(i[i.indexOf(u)]=null),t.__e=u}else if(i!=null)for(H=i.length;H--;)Ae(i[H])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),R.then||at(t),$.__e(R,t,n)}}else i==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):u=t.__e=fn(n.__e,t,n,r,o,i,s,d,c);return(f=$.diffed)&&f(t),128&t.__u?void 0:u}function at(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(at))}function st(e,t,n){for(var r=0;r<n.length;r++)ze(n[r],n[++r],n[++r]);$.__c&&$.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(i){i.call(o)})}catch(i){$.__e(i,o.__v)}})}function lt(e){return typeof e!="object"||e==null||e.__b>0?e:ae(e)?e.map(lt):e.constructor!==void 0?null:B({},e)}function fn(e,t,n,r,o,i,s,u,d){var c,f,p,l,h,m,y,w=n.props||ie,_=t.props,g=t.type;if(g=="svg"?o="http://www.w3.org/2000/svg":g=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),i!=null){for(c=0;c<i.length;c++)if((h=i[c])&&"setAttribute"in h==!!g&&(g?h.localName==g:h.nodeType==3)){e=h,i[c]=null;break}}if(e==null){if(g==null)return document.createTextNode(_);e=document.createElementNS(o,g,_.is&&_),u&&($.__m&&$.__m(t,i),u=!1),i=null}if(g==null)w===_||u&&e.data==_||(e.data=_);else{if(i=g=="textarea"&&_.defaultValue!=null?null:i&&ne.call(e.childNodes),!u&&i!=null)for(w={},c=0;c<e.attributes.length;c++)w[(h=e.attributes[c]).name]=h.value;for(c in w)h=w[c],c=="dangerouslySetInnerHTML"?p=h:c=="children"||c in _||c=="value"&&"defaultValue"in _||c=="checked"&&"defaultChecked"in _||ue(e,c,null,h,o);for(c in _)h=_[c],c=="children"?l=h:c=="dangerouslySetInnerHTML"?f=h:c=="value"?m=h:c=="checked"?y=h:u&&typeof h!="function"||w[c]===h||ue(e,c,h,w[c],o);if(f)u||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=""),nt(t.type=="template"?e.content:e,ae(l)?l:[l],t,n,r,g=="foreignObject"?"http://www.w3.org/1999/xhtml":o,i,s,i?i[0]:n.__k&&O(n,0),u,d),i!=null)for(c=i.length;c--;)Ae(i[c]);u&&g!="textarea"||(c="value",g=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[c]||g=="progress"&&!m||g=="option"&&m!=w[c])&&ue(e,c,m,w[c],o),c="checked",y!=null&&y!=e[c]&&ue(e,c,y,w[c],o))}return e}function ze(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(o){$.__e(o,n)}}function ct(e,t,n){var r,o;if($.unmount&&$.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||ze(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(i){$.__e(i,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&ct(r[o],t,n||typeof e.type!="function");n||Ae(e.__e),e.__c=e.__=e.__e=void 0}function hn(e,t,n){return this.constructor(e,n)}function ut(e,t,n){var r,o,i,s;t==document&&(t=document.documentElement),$.__&&$.__(e,t),o=(r=typeof n=="function")?null:n&&n.__k||t.__k,i=[],s=[],Ee(t,e=(!r&&n||t).__k=ln(L,null,[e]),o||ie,ie,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?ne.call(t.childNodes):null,i,!r&&n?n:o?o.__e:t.firstChild,r,s),st(i,e,s),e.props.children=null}ne=oe.slice,$={__e:function(e,t,n,r){for(var o,i,s;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(e)),s=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,r||{}),s=o.__d),s)return o.__E=o}catch(u){e=u}throw e}},Ke=0,on=function(e){return e!=null&&e.constructor===void 0},le.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=B({},this.state);typeof e=="function"&&(e=e(B({},n),this.props)),e&&B(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),tt(this))},le.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),tt(this))},le.prototype.render=L,D=[],Je=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Qe=function(e,t){return e.__v.__b-t.__v.__b},ce.__r=0,qe=Math.random().toString(8),re="__d"+qe,K="__a"+qe,Ze=/(PointerCapture)$|Capture$/i,Ie=0,Me=ot(!1),Te=ot(!0),an=0;var X,I,He,dt,J=0,ft=[],T=$,ht=T.__b,pt=T.__r,_t=T.diffed,gt=T.__c,mt=T.unmount,bt=T.__;function Re(e,t){T.__h&&T.__h(I,e,J||t),J=0;var n=I.__H||(I.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function A(e){return J=1,pn(xt,e)}function pn(e,t,n){var r=Re(X++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):xt(void 0,t),function(u){var d=r.__N?r.__N[0]:r.__[0],c=r.t(d,u);d!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=I,!I.__f)){var o=function(u,d,c){if(!r.__c.__H)return!0;var f=!1,p=r.__c.props!==u;if(r.__c.__H.__.some(function(h){if(h.__N){f=!0;var m=h.__[0];h.__=h.__N,h.__N=void 0,m!==h.__[0]&&(p=!0)}}),i){var l=i.call(this,u,d,c);return f?l||p:l}return!f||p};I.__f=!0;var i=I.shouldComponentUpdate,s=I.componentWillUpdate;I.componentWillUpdate=function(u,d,c){if(this.__e){var f=i;i=void 0,o(u,d,c),i=f}s&&s.call(this,u,d,c)},I.shouldComponentUpdate=o}return r.__N||r.__}function P(e,t){var n=Re(X++,3);!T.__s&&yt(n.__H,t)&&(n.__=e,n.u=t,I.__H.__h.push(n))}function F(e){return J=5,de(function(){return{current:e}},[])}function de(e,t){var n=Re(X++,7);return yt(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Q(e,t){return J=8,de(function(){return e},t)}function _n(){for(var e;e=ft.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(fe),t.__h.some(Pe),t.__h=[]}catch(n){t.__h=[],T.__e(n,e.__v)}}}T.__b=function(e){I=null,ht&&ht(e)},T.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),bt&&bt(e,t)},T.__r=function(e){pt&&pt(e),X=0;var t=(I=e.__c).__H;t&&(He===I?(t.__h=[],I.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(fe),t.__h.some(Pe),t.__h=[],X=0)),He=I},T.diffed=function(e){_t&&_t(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ft.push(t)!==1&&dt===T.requestAnimationFrame||((dt=T.requestAnimationFrame)||gn)(_n)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),He=I=null},T.__c=function(e,t){t.some(function(n){try{n.__h.some(fe),n.__h=n.__h.filter(function(r){return!r.__||Pe(r)})}catch(r){t.some(function(o){o.__h&&(o.__h=[])}),t=[],T.__e(r,n.__v)}}),gt&&gt(e,t)},T.unmount=function(e){mt&&mt(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{fe(r)}catch(o){t=o}}),n.__H=void 0,t&&T.__e(t,n.__v))};var vt=typeof requestAnimationFrame=="function";function gn(e){var t,n=function(){clearTimeout(r),vt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);vt&&(t=requestAnimationFrame(n))}function fe(e){var t=I,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),I=t}function Pe(e){var t=I;e.__c=e.__(),I=t}function yt(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function xt(e,t){return typeof t=="function"?t(e):t}var mn=`
1
+ var UserEQ=(function(qe){Object.defineProperty(qe,Symbol.toStringTag,{value:"Module"});async function nn(e){const t=e.getReader(),n=new TextDecoder;let r="",o="";const i=[],a=new Map,u=d=>{if(!d.startsWith("data:"))return;const c=d.slice(5).trim();if(!c||c==="[DONE]")return;let f;try{f=JSON.parse(c)}catch{return}switch(f.type){case"start":"messageId"in f&&f.messageId&&(o=f.messageId);break;case"text-start":"id"in f&&(i.push(f.id),a.set(f.id,""));break;case"text-delta":if("id"in f&&"delta"in f){var h;a.set(f.id,((h=a.get(f.id))!==null&&h!==void 0?h:"")+f.delta)}break;case"error":throw new Error("errorText"in f?f.errorText:"The reply failed.");case"abort":throw new Error("The reply was cut short.")}};for(;;){const{done:d,value:c}=await t.read();if(d)break;r+=n.decode(c,{stream:!0});let f;for(;(f=r.indexOf(`
2
+ `))!==-1;)u(r.slice(0,f).replace(/\r$/,"")),r=r.slice(f+1)}return r&&u(r),{id:o||`reply-${Date.now()}`,parts:i.map(d=>{var c;return(c=a.get(d))!==null&&c!==void 0?c:""})}}function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(e)}function rn(e,t){if(Z(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Z(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function on(e){var t=rn(e,"string");return Z(t)=="symbol"?t:t+""}function Ie(e,t,n){return(t=on(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var G=class extends Error{constructor(e,t,n){super(n),Ie(this,"status",void 0),Ie(this,"code",void 0),this.status=e,this.code=t}};async function ee(e){let t="request_failed",n=`The request failed (${e.status}).`;try{var r,o;const i=await e.json();!((r=i.error)===null||r===void 0)&&r.code&&(t=i.error.code),!((o=i.error)===null||o===void 0)&&o.message&&(n=i.error.message)}catch{}throw new G(e.status,t,n)}var Te=(e,t={})=>({method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(e)});async function sn(e,t,n){const r=await fetch(`${e.base}/api/embed/${t}/${n}`);return r.ok?r.json():ee(r)}async function an(e,t){const n=await fetch(`${e.base}/api/embed/sessions`,Te(t));return n.ok?n.json():ee(n)}var Me=e=>({Authorization:`Bearer ${e}`});async function ln(e,t){const n=await fetch(`${e.base}/api/embed/sessions/current`,{headers:Me(t)});return n.ok?n.json():ee(n)}async function cn(e,t){const n=await fetch(`${e.base}/api/embed/sessions/current/end`,{method:"POST",headers:Me(t)});return n.ok?n.json():ee(n)}async function un(e,t,n,r,o){const i=await fetch(`${e.base}/api/embed/chat`,{...Te({message:{id:n.id,role:"user",parts:[{type:"text",text:n.text}]},trigger:r},Me(t)),signal:o});return!i.ok||!i.body?ee(i):nn(i.body)}async function dn(e,t){try{const n=await fetch(`${e.base}/api/embed/events`,{...Te(t),keepalive:!0});return n.ok?await n.json():null}catch{return null}}var K=e=>typeof e=="object"&&e!==null;function et(e){return K(e)&&typeof e.id=="string"&&K(e.config)&&typeof e.config.type=="string"&&K(e.config.appearance)&&Array.isArray(e.rules)}function fn(e){return K(e)&&typeof e.id=="string"&&typeof e.mode=="string"&&K(e.config)&&Array.isArray(e.members)&&e.members.every(t=>K(t)&&et(t.widget))&&Array.isArray(e.rules)}function pn(e,t){return!K(e)||e.kind!==t?null:t==="widget"&&et(e.payload)||t==="group"&&fn(e.payload)?e:null}var ce,C,tt,hn,O,nt,rt,it,Ae,ue,te,ot,ze,Re,Ee,_n,de={},fe=[],gn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pe=Array.isArray;function W(e,t){for(var n in t)e[n]=t[n];return e}function He(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function mn(e,t,n){var r,o,i,a={};for(i in t)i=="key"?r=t[i]:i=="ref"?o=t[i]:a[i]=t[i];if(arguments.length>2&&(a.children=arguments.length>3?ce.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)a[i]===void 0&&(a[i]=e.defaultProps[i]);return he(e,a,r,o,null)}function he(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o==null?++tt:o,__i:-1,__u:0};return o==null&&C.vnode!=null&&C.vnode(i),i}function N(e){return e.children}function _e(e,t){this.props=e,this.context=t}function V(e,t){if(t==null)return e.__?V(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?V(e):null}function bn(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],o=[],i=W({},t);i.__v=t.__v+1,C.vnode&&C.vnode(i),Pe(e.__P,i,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n==null?V(t):n,!!(32&t.__u),o),i.__v=t.__v,i.__.__k[i.__i]=i,pt(r,i,o),t.__e=t.__=null,i.__e!=n&&st(i)}}function st(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),st(e)}function at(e){(!e.__d&&(e.__d=!0)&&O.push(e)&&!ge.__r++||nt!=C.debounceRendering)&&((nt=C.debounceRendering)||rt)(ge)}function ge(){try{for(var e,t=1;O.length;)O.length>t&&O.sort(it),e=O.shift(),t=O.length,bn(e)}finally{O.length=ge.__r=0}}function lt(e,t,n,r,o,i,a,u,d,c,f){var h,l,p,m,x,v,_=r&&r.__k||fe,g=t.length;for(d=vn(n,t,_,d,g),h=0;h<g;h++)(p=n.__k[h])!=null&&(l=p.__i!=-1&&_[p.__i]||de,p.__i=h,v=Pe(e,p,l,o,i,a,u,d,c,f),m=p.__e,p.ref&&l.ref!=p.ref&&(l.ref&&je(l.ref,null,p),f.push(p.ref,p.__c||m,p)),x==null&&m!=null&&(x=m),4&p.__u?(d=ct(p,d,e),l.__e&&(l.__e=null)):typeof p.type=="function"&&v!==void 0?d=v:m&&(d=m.nextSibling),p.__u&=-7);return n.__e=x,d}function vn(e,t,n,r,o){var i,a,u,d,c,f=n.length,h=f,l=0;for(e.__k=new Array(o),i=0;i<o;i++)(a=t[i])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[i]=he(null,a,null,null,null):pe(a)?a=e.__k[i]=he(N,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[i]=he(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[i]=a,d=i+l,a.__=e,a.__b=e.__b+1,u=null,(c=a.__i=yn(a,n,d,h))!=-1&&(h--,(u=n[c])&&(u.__u|=2)),u==null||u.__v==null?(c==-1&&(o>f?l--:o<f&&l++),typeof a.type!="function"&&(a.__u|=4)):c!=d&&(c==d-1?l--:c==d+1?l++:(c>d?l--:l++,a.__u|=4))):e.__k[i]=null;if(h)for(i=0;i<f;i++)(u=n[i])!=null&&(2&u.__u)==0&&(u.__e==r&&(r=V(u)),_t(u,u));return r}function ct(e,t,n){var r,o;if(typeof e.type=="function"){for(r=e.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=e,t=ct(r[o],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=V(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function yn(e,t,n,r){var o,i,a,u=e.key,d=e.type,c=t[n],f=c!=null&&(2&c.__u)==0;if(c===null&&u==null||f&&u==c.key&&d==c.type)return n;if(r>(f?1:0)){for(o=n-1,i=n+1;o>=0||i<t.length;)if((c=t[a=o>=0?o--:i++])!=null&&(2&c.__u)==0&&u==c.key&&d==c.type)return a}return-1}function ut(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":typeof n!="number"||gn.test(t)?n:n+"px"}function me(e,t,n,r,o){var i,a;e: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||ut(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||ut(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")i=t!=(t=t.replace(ot,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r?n[te]=r[te]:(n[te]=ze,e.addEventListener(t,i?Ee:Re,i)):e.removeEventListener(t,i?Ee:Re,i);else{if(o=="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==null?"":n;break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function dt(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[ue]==null)t[ue]=ze++;else if(t[ue]<n[te])return;return n(C.event?C.event(t):t)}}}function Pe(e,t,n,r,o,i,a,u,d,c){var f,h,l,p,m,x,v,_,g,y,$,q,A,w,I,S,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),i=[u=t.__e=n.__e]),(f=C.__b)&&f(t);e:if(typeof T=="function"){h=a.length;try{if(g=t.props,y=T.prototype&&T.prototype.render,$=(f=T.contextType)&&r[f.__c],q=f?$?$.props.value:f.__:r,n.__c?_=(l=t.__c=n.__c).__=l.__E:(y?t.__c=l=new T(g,q):(t.__c=l=new _e(g,q),l.constructor=T,l.render=wn),$&&$.sub(l),l.state||(l.state={}),l.__n=r,p=l.__d=!0,l.__h=[],l._sb=[]),y&&l.__s==null&&(l.__s=l.state),y&&T.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=W({},l.__s)),W(l.__s,T.getDerivedStateFromProps(g,l.__s))),m=l.props,x=l.state,l.__v=t,p)y&&T.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),y&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(y&&T.getDerivedStateFromProps==null&&g!==m&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(g,q),t.__v==n.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(g,l.__s,q)===!1){t.__v!=n.__v&&(l.props=g,l.state=l.__s,l.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(M){M&&(M.__=t)}),fe.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&a.push(l),u=V(n);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(g,l.__s,q),y&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(m,x,v)})}if(l.context=q,l.props=g,l.__P=e,l.__e=!1,A=C.__r,w=0,y)l.state=l.__s,l.__d=!1,A&&A(t),f=l.render(l.props,l.state,l.context),fe.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,A&&A(t),f=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++w<25);l.state=l.__s,l.getChildContext!=null&&(r=W(W({},r),l.getChildContext())),y&&!p&&l.getSnapshotBeforeUpdate!=null&&(v=l.getSnapshotBeforeUpdate(m,x)),I=f!=null&&f.type===N&&f.key==null?ht(f.props.children):f,u=lt(e,pe(I)?I:[I],t,n,r,o,i,a,u,d,c),l.base=t.__e,t.__u&=-161,l.__h.length&&a.push(l),_&&(l.__E=l.__=null)}catch(M){if(a.length=h,t.__v=null,d||i!=null){if(M.then){for(t.__u|=d?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;i!=null&&(i[i.indexOf(u)]=null),t.__e=u}else if(i!=null)for(S=i.length;S--;)He(i[S])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),M.then||ft(t),C.__e(M,t,n)}}else i==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):u=t.__e=xn(n.__e,t,n,r,o,i,a,d,c);return(f=C.diffed)&&f(t),128&t.__u?void 0:u}function ft(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ft))}function pt(e,t,n){for(var r=0;r<n.length;r++)je(n[r],n[++r],n[++r]);C.__c&&C.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(i){i.call(o)})}catch(i){C.__e(i,o.__v)}})}function ht(e){return typeof e!="object"||e==null||e.__b>0?e:pe(e)?e.map(ht):e.constructor!==void 0?null:W({},e)}function xn(e,t,n,r,o,i,a,u,d){var c,f,h,l,p,m,x,v=n.props||de,_=t.props,g=t.type;if(g=="svg"?o="http://www.w3.org/2000/svg":g=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),i!=null){for(c=0;c<i.length;c++)if((p=i[c])&&"setAttribute"in p==!!g&&(g?p.localName==g:p.nodeType==3)){e=p,i[c]=null;break}}if(e==null){if(g==null)return document.createTextNode(_);e=document.createElementNS(o,g,_.is&&_),u&&(C.__m&&C.__m(t,i),u=!1),i=null}if(g==null)v===_||u&&e.data==_||(e.data=_);else{if(i=g=="textarea"&&_.defaultValue!=null?null:i&&ce.call(e.childNodes),!u&&i!=null)for(v={},c=0;c<e.attributes.length;c++)v[(p=e.attributes[c]).name]=p.value;for(c in v)p=v[c],c=="dangerouslySetInnerHTML"?h=p:c=="children"||c in _||c=="value"&&"defaultValue"in _||c=="checked"&&"defaultChecked"in _||me(e,c,null,p,o);for(c in _)p=_[c],c=="children"?l=p:c=="dangerouslySetInnerHTML"?f=p:c=="value"?m=p:c=="checked"?x=p:u&&typeof p!="function"||v[c]===p||me(e,c,p,v[c],o);if(f)u||h&&(f.__html==h.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(h&&(e.innerHTML=""),lt(t.type=="template"?e.content:e,pe(l)?l:[l],t,n,r,g=="foreignObject"?"http://www.w3.org/1999/xhtml":o,i,a,i?i[0]:n.__k&&V(n,0),u,d),i!=null)for(c=i.length;c--;)He(i[c]);u&&g!="textarea"||(c="value",g=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[c]||g=="progress"&&!m||g=="option"&&m!=v[c])&&me(e,c,m,v[c],o),c="checked",x!=null&&x!=e[c]&&me(e,c,x,v[c],o))}return e}function je(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(o){C.__e(o,n)}}function _t(e,t,n){var r,o;if(C.unmount&&C.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||je(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(i){C.__e(i,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&_t(r[o],t,n||typeof e.type!="function");n||He(e.__e),e.__c=e.__=e.__e=void 0}function wn(e,t,n){return this.constructor(e,n)}function gt(e,t,n){var r,o,i,a;t==document&&(t=document.documentElement),C.__&&C.__(e,t),o=(r=typeof n=="function")?null:n&&n.__k||t.__k,i=[],a=[],Pe(t,e=(!r&&n||t).__k=mn(N,null,[e]),o||de,de,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?ce.call(t.childNodes):null,i,!r&&n?n:o?o.__e:t.firstChild,r,a),pt(i,e,a),e.props.children=null}ce=fe.slice,C={__e:function(e,t,n,r){for(var o,i,a;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(e)),a=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,r||{}),a=o.__d),a)return o.__E=o}catch(u){e=u}throw e}},tt=0,hn=function(e){return e!=null&&e.constructor===void 0},_e.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=W({},this.state);typeof e=="function"&&(e=e(W({},n),this.props)),e&&W(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),at(this))},_e.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),at(this))},_e.prototype.render=N,O=[],rt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,it=function(e,t){return e.__v.__b-t.__v.__b},ge.__r=0,Ae=Math.random().toString(8),ue="__d"+Ae,te="__a"+Ae,ot=/(PointerCapture)$|Capture$/i,ze=0,Re=dt(!1),Ee=dt(!0),_n=0;var ne,z,Fe,mt,re=0,bt=[],E=C,vt=E.__b,yt=E.__r,xt=E.diffed,wt=E.__c,St=E.unmount,kt=E.__;function Be(e,t){E.__h&&E.__h(z,e,re||t),re=0;var n=z.__H||(z.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function H(e){return re=1,Sn(qt,e)}function Sn(e,t,n){var r=Be(ne++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):qt(void 0,t),function(u){var d=r.__N?r.__N[0]:r.__[0],c=r.t(d,u);d!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=z,!z.__f)){var o=function(u,d,c){if(!r.__c.__H)return!0;var f=!1,h=r.__c.props!==u;if(r.__c.__H.__.some(function(p){if(p.__N){f=!0;var m=p.__[0];p.__=p.__N,p.__N=void 0,m!==p.__[0]&&(h=!0)}}),i){var l=i.call(this,u,d,c);return f?l||h:l}return!f||h};z.__f=!0;var i=z.shouldComponentUpdate,a=z.componentWillUpdate;z.componentWillUpdate=function(u,d,c){if(this.__e){var f=i;i=void 0,o(u,d,c),i=f}a&&a.call(this,u,d,c)},z.shouldComponentUpdate=o}return r.__N||r.__}function P(e,t){var n=Be(ne++,3);!E.__s&&Ct(n.__H,t)&&(n.__=e,n.u=t,z.__H.__h.push(n))}function B(e){return re=5,be(function(){return{current:e}},[])}function be(e,t){var n=Be(ne++,7);return Ct(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function U(e,t){return re=8,be(function(){return e},t)}function kn(){for(var e;e=bt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ve),t.__h.some(De),t.__h=[]}catch(n){t.__h=[],E.__e(n,e.__v)}}}E.__b=function(e){z=null,vt&&vt(e)},E.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),kt&&kt(e,t)},E.__r=function(e){yt&&yt(e),ne=0;var t=(z=e.__c).__H;t&&(Fe===z?(t.__h=[],z.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(ve),t.__h.some(De),t.__h=[],ne=0)),Fe=z},E.diffed=function(e){xt&&xt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(bt.push(t)!==1&&mt===E.requestAnimationFrame||((mt=E.requestAnimationFrame)||$n)(kn)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Fe=z=null},E.__c=function(e,t){t.some(function(n){try{n.__h.some(ve),n.__h=n.__h.filter(function(r){return!r.__||De(r)})}catch(r){t.some(function(o){o.__h&&(o.__h=[])}),t=[],E.__e(r,n.__v)}}),wt&&wt(e,t)},E.unmount=function(e){St&&St(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{ve(r)}catch(o){t=o}}),n.__H=void 0,t&&E.__e(t,n.__v))};var $t=typeof requestAnimationFrame=="function";function $n(e){var t,n=function(){clearTimeout(r),$t&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);$t&&(t=requestAnimationFrame(n))}function ve(e){var t=z,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),z=t}function De(e){var t=z;e.__c=e.__(),z=t}function Ct(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function qt(e,t){return typeof t=="function"?t(e):t}var Cn=`
3
3
  :host{all:initial;display:contents;font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:14px;line-height:1.4;-webkit-font-smoothing:antialiased;color:#15171e}
4
4
  :host([hidden]){display:none}
5
5
  *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
@@ -31,8 +31,8 @@ img,video{display:block;max-width:100%}
31
31
  .uq-slide{animation:uq-slide .3s cubic-bezier(.32,.72,0,1) both}
32
32
  @keyframes uq-slide{from{transform:translateY(100%)}to{transform:none}}
33
33
  @media (prefers-reduced-motion:reduce){.uq-rise,.uq-fade,.uq-slide,.uq-dots span{animation:none}.uq-drawer{transition:none}}
34
- `;function he(e,t){try{return window[e].getItem(t)}catch{return null}}function pe(e,t,n){try{window[e].setItem(t,n)}catch{}}var bn=2e3,vn=20,yn=100;function Fe(e=Date.now()){const t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/1099511627776&255,t[1]=e/4294967296&255,t[2]=e/16777216&255,t[3]=e/65536&255,t[4]=e/256&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}var wt="usereq:visitor";function kt(){const e=he("localStorage",wt);if(e)return e;const t=Fe();return pe("localStorage",wt,t),t}function xn(e,t){const n=[];let r=null;const o=kt(),i=()=>{for(r!==null&&(window.clearTimeout(r),r=null);n.length>0;){const u=n.splice(0,yn);tn(e,{events:u})}},s=(u,d={})=>{n.push({id:Fe(),type:u,embedKind:t.kind,embedId:t.id,widgetId:d.widgetId,sessionId:d.sessionId,clientKey:o,url:window.location.href.slice(0,2e3),occurredAt:new Date().toISOString(),payload:d.payload}),n.length>=vn?i():r===null&&(r=window.setTimeout(i,bn))};return window.addEventListener("pagehide",i),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&i()}),{report:s,flush:i}}var St=e=>`usereq:once:${e}`;function je(e,t,n){switch(e){case"is":return t===n;case"starts_with":return t.startsWith(n);case"contains":return t.includes(n);case"matches":try{return new RegExp(n).test(t)}catch{return!1}}}function wn(e,t){switch(e.kind){case"path":return e.value==="*"||je(e.op,t.path,e.value);case"utm":var n;return je(e.op,(n=t.utm[e.param])!==null&&n!==void 0?n:"",e.value);case"device":return t.device===e.value;case"referrer":return je(e.op,t.referrer,e.value)}}function kn(e,t){for(const n of e)if(!(n.once&&he("sessionStorage",St(n.id)))&&n.conditions.every(r=>wn(r,t)))return n;return null}function $t(e,t,n){let r=!1,o=()=>{};const i=()=>{r||(r=!0,o(),n())};switch(e){case"page_load":{const d=window.setTimeout(i,0);o=()=>window.clearTimeout(d);break}case"time_on_page":{const d=Number(t.seconds)||0,c=window.setTimeout(i,d*1e3);o=()=>window.clearTimeout(c);break}case"scroll_depth":{const d=Number(t.percent)||0,c=()=>{const f=document.documentElement.scrollHeight-window.innerHeight;(f<=0?100:window.scrollY/f*100)>=d&&i()};window.addEventListener("scroll",c,{passive:!0}),o=()=>window.removeEventListener("scroll",c),c();break}case"element_click":{var s;const d=String((s=t.selector)!==null&&s!==void 0?s:""),c=f=>{const p=f.target;if(!(!(p instanceof Element)||!d))try{p.closest(d)&&i()}catch{}};document.addEventListener("click",c,!0),o=()=>document.removeEventListener("click",c,!0);break}case"element_visible":{var u;const d=String((u=t.selector)!==null&&u!==void 0?u:"");let c=null;const f=()=>{let p=null;try{p=d?document.querySelector(d):null}catch{p=null}return p?(c=new IntersectionObserver(l=>{l.some(h=>h.isIntersecting)&&i()}),c.observe(p),!0):!1};!f()&&document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",()=>void f(),{once:!0}),o=()=>c==null?void 0:c.disconnect();break}case"exit_intent":{const d=c=>{c.relatedTarget===null&&c.clientY<=0&&i()};document.addEventListener("mouseout",d),o=()=>document.removeEventListener("mouseout",d);break}}return()=>{r=!0,o()}}function Ct(e,t,n){const r=kn(e,t);return r?$t(r.trigger,r.triggerParams,()=>{r.once&&pe("sessionStorage",St(r.id),"1"),n(r)}):()=>{}}var qt=e=>`usereq:split:${e}`,It=e=>`usereq:seq:${e}`;function Sn(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function _e(e){return[...e].sort((t,n)=>t.position-n.position)}function $n(e){const t=_e(e.members);if(t.length===0)return null;const n=he("localStorage",qt(e.id)),r=n?t.find(u=>u.widget.id===n):void 0;if(r)return r;const o=t.reduce((u,d)=>u+d.weight,0);let i=Sn(`${kt()}:${e.config.salt}`)%o,s=t[t.length-1];for(const u of t){if(i<u.weight){s=u;break}i-=u.weight}return pe("localStorage",qt(e.id),s.widget.id),s}function Mt(e){var t,n;const r=_e(e.members);if(r.length===0)return null;const o=Number((t=he("sessionStorage",It(e.id)))!==null&&t!==void 0?t:0);return(n=r[Number.isFinite(o)?Math.min(o,r.length-1):0])!==null&&n!==void 0?n:null}function Cn(e,t,n){if(!t.advanceOn)return()=>{};const r=_e(e.members),o=r.findIndex(i=>i.widget.id===t.widget.id);return $t(t.advanceOn.kind,t.advanceOn.params,()=>{var i;const s=o+1<r.length?o+1:null;if(s===null){n(null);return}pe("sessionStorage",It(e.id),String(s)),n((i=r[s])!==null&&i!==void 0?i:null)})}function qn(e){switch(e.mode){case"split":{const t=$n(e);return t?[t.widget]:[]}case"sequence":{const t=Mt(e);return t?[t.widget]:[]}case"parallel":return _e(e.members).map(t=>t.widget)}}function In(e){var t,n,r,o;if(e)return e==="dark";const i=(t=Tt(getComputedStyle(document.body).backgroundColor))!==null&&t!==void 0?t:Tt(getComputedStyle(document.documentElement).backgroundColor);return i!==null?i<.5:(n=(r=(o=window).matchMedia)===null||r===void 0?void 0:r.call(o,"(prefers-color-scheme: dark)").matches)!==null&&n!==void 0?n:!1}function Tt(e){const t=/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)(?:[,\s/]+([\d.]+))?/.exec(e);if(!t||(t[4]===void 0?1:Number(t[4]))<.5)return null;const[n,r,o]=[Number(t[1]),Number(t[2]),Number(t[3])];return(.299*n+.587*r+.114*o)/255}function Mn(e=window.innerWidth){return e<640?"mobile":e<1024?"tablet":"desktop"}function Tn(){const e=new URL(window.location.href),t={};for(const n of["source","medium","campaign","term","content"]){const r=e.searchParams.get(`utm_${n}`);r&&(t[n]=r)}return{href:e.href.slice(0,2e3),path:e.pathname,referrer:document.referrer.slice(0,2e3),utm:t,device:Mn()}}function At(e){const t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function An(e){const{r:t,g:n,b:r}=At(e);return(.299*t+.587*n+.114*r)/255>.62?"#15171e":"#ffffff"}var ge=e=>e?"245,245,241":"21,23,30";function En(e,t){const n=e.appearance,r=n.accent;return{accent:r,accentFill:(()=>{if(n.alpha>=100)return r;const{r:o,g:i,b:s}=At(r);return`rgba(${o},${i},${s},${n.alpha/100})`})(),accentText:An(r),rad:n.radius,isGlass:e.type==="chat"&&e.variant==="stream"&&n.skin==="glass",isMessenger:e.type==="chat"&&e.variant==="bubble"&&e.preset==="facebook-messenger",hostDark:t,ink:ge(t),surfaceBg:t?"#181b22":"#ffffff",side:n.position==="bottom-right"?{right:n.offsetX}:{left:n.offsetX},offsetY:n.offsetY}}function S(e,t,n){const r=e.appearance.parts[t],o=[`uq-${t}`];return n&&o.push(n),r&&o.push(r.trim()),o.join(" ")}var zn=0,pr=Array.isArray;function a(e,t,n,r,o,i){t||(t={});var s,u,d=t;if("ref"in d)for(u in d={},t)u=="ref"?s=t[u]:d[u]=t[u];var c={type:e,props:d,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--zn,__i:-1,__u:0,__source:o,__self:i};if(typeof e=="function"&&(s=e.defaultProps))for(u in s)d[u]===void 0&&(d[u]=s[u]);return $.vnode&&$.vnode(c),c}function j({size:e,children:t}){return a("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:t})}var Et=({size:e})=>a(j,{size:e,children:[a("path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}),a("path",{d:"M20 2v4"}),a("path",{d:"M22 4h-4"}),a("circle",{cx:"4",cy:"20",r:"2"})]}),zt=({size:e})=>a(j,{size:e,children:[a("path",{d:"M5 12h14"}),a("path",{d:"m12 5 7 7-7 7"})]}),me=({size:e})=>a(j,{size:e,children:[a("path",{d:"M18 6 6 18"}),a("path",{d:"m6 6 12 12"})]}),Hn=({size:e})=>a(j,{size:e,children:a("path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"})}),Rn=({size:e})=>a(j,{size:e,children:[a("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),a("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]}),Pn=({size:e})=>a(j,{size:e,children:[a("circle",{cx:"12",cy:"12",r:"10"}),a("path",{d:"M12 16v-4"}),a("path",{d:"M12 8h.01"})]}),Ht=({size:e})=>a(j,{size:e,children:a("path",{d:"m6 9 6 6 6-6"})}),Fn=({size:e})=>a(j,{size:e,children:a("path",{d:"M5 12h14"})}),jn=({size:e})=>a(j,{size:e,children:[a("path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}),a("path",{d:"m21.854 2.147-10.94 10.939"})]}),Bn=({size:e})=>a(j,{size:e,children:[a("path",{d:"M15 3h6v6"}),a("path",{d:"M10 14 21 3"}),a("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]}),Dn=({size:e,d:t})=>a("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a("path",{d:t})});function Ln({payload:e,look:t,reporter:n,open:r,setOpen:o,pinned:i}){var s;const u=e.config,{accentFill:d,accentText:c,rad:f}=t;if(!r)return null;const p=!((s=u.cta)===null||s===void 0)&&s.label.trim()?u.cta:null,l=(p==null?void 0:p.href.trim())||"",h=u.position==="bottom"?{bottom:0}:{top:0};return a("div",{class:S(u,"strip","uq-fixed uq-fade"),role:"region","aria-label":"Announcement",style:{left:0,right:0,...h,display:"flex",alignItems:"center",justifyContent:"center",gap:14,padding:"11px 14px",background:d,color:c},children:[a("span",{class:S(u,"text"),style:{fontSize:12.5,fontWeight:500},children:u.text}),p&&a("a",{class:S(u,"cta"),href:l||"#",target:l?"_blank":void 0,rel:l?"noopener noreferrer":void 0,onClick:()=>n.report("cta.clicked",{widgetId:e.id,payload:{href:l}}),style:{fontSize:11.5,padding:"5px 10px",borderRadius:f,border:`1px solid ${c}`,whiteSpace:"nowrap"},children:p.label}),!i&&a("button",{type:"button",class:S(u,"close"),onClick:()=>o(!1),"aria-label":"Close",style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",opacity:.7},children:a(me,{size:14})})]})}var Be={holdMs:1260,gapMs:1520,jitterMs:100};function Wn(e,t=Math.random){const n=[];let r=0;for(let o=0;o<e;o++){if(o===0)r+=Be.holdMs;else{const i=Math.round((t()*2-1)*Be.jitterMs);r+=Math.max(0,Be.gapMs+i)}n.push(r)}return n}function Nn(e,t,n,r){const[o,i]=A([]),[s,u]=A(!1),[d,c]=A(null),[f,p]=A(null),l=F(null),h=F(null),m=F([]),y=F(null),w=()=>{for(const v of m.current)window.clearTimeout(v);m.current=[]};P(()=>()=>w(),[]);const _=Q(async()=>{if(l.current)return l.current;const v=await Zt(e,{kind:n.kind,id:n.id,widgetId:n.kind==="group"?t.id:void 0,landingUrl:r.href,referrer:r.referrer||void 0,utm:Object.keys(r.utm).length?r.utm:void 0});return l.current={token:v.token,conversationId:v.conversationId},p(v.conversationId),l.current},[e,n.kind,n.id,t.id,r]),g=Q(async(v,k)=>{var x;(x=h.current)===null||x===void 0||x.abort();const q=new AbortController;h.current=q,w(),u(!0),c(null);try{const{token:C}=await _(),z=await en(e,C,v,k,q.signal);if(q.signal.aborted)return;const H=z.parts.filter(E=>E.trim());if(H.length===0)throw new Error("The agent did not answer. Try again.");i(E=>[...E,{id:z.id,role:"assistant",parts:H,shown:0}]),m.current=Wn(H.length).map((E,R)=>window.setTimeout(()=>{i(W=>W.map(Y=>Y.id===z.id?{...Y,shown:R+1}:Y)),R===H.length-1&&u(!1)},E))}catch(C){if(q.signal.aborted)return;C instanceof te&&(C.status===401||C.status===409)&&(l.current=null),u(!1),c(C instanceof te?C.message:C instanceof TypeError?"Could not reach the agent. Try again.":C instanceof Error&&C.message?C.message:"Something went wrong. Try again.")}},[e,_]);return{turns:o,busy:s,error:d,sessionId:f,send:Q(v=>{const k=v.trim().slice(0,4e3);if(!k||s)return;const x={id:Fe(),text:k};y.current=x,i(q=>[...q,{id:x.id,role:"user",parts:[k],shown:1}]),g(x,"submit-message")},[s,g]),retry:Q(()=>{!y.current||s||g(y.current,"regenerate-message")},[s,g]),stop:Q(()=>{var v;(v=h.current)===null||v===void 0||v.abort(),h.current=null,w(),i(k=>k.map(x=>x.role==="assistant"&&x.shown<x.parts.length?{...x,shown:x.parts.length}:x)),u(!1)},[])}}function On(){const e="(max-width: 639px)",[t,n]=A(()=>{var r,o,i;return(r=(o=(i=window).matchMedia)===null||o===void 0?void 0:o.call(i,e).matches)!==null&&r!==void 0?r:!1});return P(()=>{var r,o;const i=(r=(o=window).matchMedia)===null||r===void 0?void 0:r.call(o,e);if(!i)return;const s=()=>n(i.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),t}var Un=.5,Rt=120,De=()=>document.documentElement.clientHeight;function Pt({look:e,pinned:t,onClose:n,children:r}){const[o,i]=A("half"),[s,u]=A(null),d=F(null),c=F(null),f=_=>{const g=d.current;g&&(_.currentTarget.setPointerCapture(_.pointerId),c.current={startY:_.clientY,startHeight:g.getBoundingClientRect().height,lastY:_.clientY,lastAt:_.timeStamp,velocity:0},u(c.current.startHeight))},p=_=>{const g=c.current;if(!g)return;const v=_.timeStamp-g.lastAt;v>0&&(g.velocity=(_.clientY-g.lastY)/v),g.lastY=_.clientY,g.lastAt=_.timeStamp;const k=g.startHeight+(g.startY-_.clientY);u(Math.max(Rt,Math.min(De(),k)))},l=()=>{const _=c.current;if(!_)return;c.current=null;const g=Math.max(Rt,Math.min(De(),_.startHeight+(_.startY-_.lastY))),v=De();let k;if(_.velocity<-.5?k="full":_.velocity>Un?k=o==="full"?"half":"closed":g>v*.75?k="full":g<v*.3?k="closed":k="half",u(null),k==="closed"){t?i("half"):n();return}i(k)},{ink:h,surfaceBg:m,rad:y}=e,w=o==="full"&&s===null;return a("div",{ref:d,class:["uq-fixed uq-drawer uq-slide",w?"uq-drawer-full":"uq-drawer-half",s!==null&&"uq-drawer-held"].filter(Boolean).join(" "),role:"dialog","aria-modal":"false",style:{height:s!==null?s:void 0,borderRadius:w?0:`${y}px ${y}px 0 0`,borderTop:`1px solid rgba(${h},.12)`,background:m,boxShadow:"0 -12px 40px rgba(0,0,0,.18)"},children:[a("div",{class:"uq-grab",onPointerDown:f,onPointerMove:p,onPointerUp:l,onPointerCancel:l,"aria-label":w?"Drag down to shrink or close":"Drag up to expand",style:{background:m},children:a("span",{style:{background:`rgba(${h},.25)`}})}),r]})}var b={accent:"#7B5BFF",gradient:"linear-gradient(135deg,#00B2FF 0%,#006AFF 38%,#8E5BFF 100%)",blue:"#0084FF",surface:{light:"#ffffff",dark:"#242526"},bubble:{light:"#f5f5f5",dark:"#404040"},muted:{light:"#8e8e8e",dark:"#a8a8a8"},border:{light:"rgba(0,0,0,.1)",dark:"rgba(255,255,255,.12)"},panelWidth:372,panelHeight:520,panelRadius:24,panelGap:14,panelShadow:"0 8px 32px rgba(0,0,0,.16)",launcherSize:60,launcherShadow:"0 6px 20px rgba(123,91,255,.4)",badgeSize:20,logo:"M12 2C6.48 2 2 6.18 2 11.32c0 2.93 1.45 5.55 3.7 7.27v3.4l3.39-1.86a10.5 10.5 0 0 0 2.91.41c5.52 0 10-4.18 10-9.22S17.52 2 12 2Zm1.06 12.42-2.55-2.72-4.97 2.72 5.46-5.8 2.61 2.72 4.91-2.72-5.46 5.8Z",headerAvatar:40,headerButton:28,headerIcon:18,nameFont:15,avatarSize:28,bubbleRadius:18,bubbleFont:14,bubblePadding:"6px 12px",bubbleMaxWidth:"78%",ctaShadow:"0 4px 12px rgba(123,91,255,.32)",composerPlaceholder:"Aa",composerRadius:24,composerHeight:36,sendSize:36,sendIcon:20},Yn=3600,Le=e=>e.welcome||"Hi! Ask me anything before you buy.";function Ft(e,t="Type your message…"){const n=e.spotlights.filter(s=>s.trim()),[r,o]=A(0);P(()=>{if(n.length<2)return;const s=window.setInterval(()=>o(u=>u+1),Yn);return()=>window.clearInterval(s)},[n.length]);const i=e.placeholder||t;return n.length?n[r%n.length]:i}function be(e){const t=F(null);return P(()=>{const n=t.current;n&&(n.scrollTop=n.scrollHeight)},e),t}function jt(e){const t=e?"dark":"light";return{surface:b.surface[t],bubble:b.bubble[t],muted:b.muted[t],border:b.border[t]}}var U=(e,t={})=>({width:e,height:e,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,...t});function We({payload:e,size:t,font:n,palette:r,fallback:o}){var i,s,u,d;const c=(i=(s=e.agent)===null||s===void 0?void 0:s.name)!==null&&i!==void 0?i:null,f=(u=(d=e.agent)===null||d===void 0?void 0:d.avatarUrl)!==null&&u!==void 0?u:null;return f?a("img",{src:f,alt:"",width:t,height:t,style:U(t,{objectFit:"cover"})}):a("span",{style:U(t,{background:r.bubble,color:r.muted,fontSize:n,fontWeight:600,...o}),children:c?c.trim().charAt(0).toUpperCase():"A"})}function Bt({text:e,mine:t,runStart:n,look:r,config:o,payload:i,palette:s,children:u}){return a("div",{class:"uq-rise",style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:t?"flex-end":"flex-start",marginTop:n?6:2},children:[!t&&(n?a(We,{payload:i,size:b.avatarSize,font:12,palette:s}):a("span",{style:{width:b.avatarSize,flexShrink:0}})),a("div",{class:S(o,t?"userMessage":"botMessage"),style:{maxWidth:b.bubbleMaxWidth,padding:u?"8px 12px":b.bubblePadding,borderRadius:b.bubbleRadius,background:t?b.gradient:s.bubble,color:t?"#fff":`rgb(${r.ink})`,fontSize:b.bubbleFont,lineHeight:1.375,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:u!=null?u:e})]})}function Dt({payload:e,config:t,look:n,chat:r,focus:o,onCta:i,mobile:s,fill:u=!1,onMinimize:d,onClose:c}){var f,p,l,h;const m=jt(n.hostDark),{surface:y,bubble:w,muted:_,border:g}=m,v=Ft(t,b.composerPlaceholder),k=(f=(p=e.agent)===null||p===void 0?void 0:p.name)!==null&&f!==void 0?f:null,x=!!(!((l=e.agent)===null||l===void 0)&&l.live),q=be([r.turns,r.busy,r.error]),[C,z]=A(""),H=F(null);P(()=>{var M;o>0&&((M=H.current)===null||M===void 0||M.focus())},[o]);const E=M=>{M.preventDefault(),x&&(r.send(C),z(""))},R=!((h=t.cta)===null||h===void 0||(h=h.href)===null||h===void 0)&&h.trim()?t.cta:null,W=[{key:"welcome",text:Le(t),mine:!1}];for(const M of r.turns)if(M.role==="user"){var Y;W.push({key:M.id,text:(Y=M.parts[0])!==null&&Y!==void 0?Y:"",mine:!0})}else M.parts.slice(0,M.shown).forEach((G,Ye)=>{W.push({key:`${M.id}:${Ye}`,text:G,mine:!1})});const hr=W[W.length-1],Z=(M,G,Ye,Ge,Vt)=>a("button",{type:"button",class:Vt?S(t,Vt):void 0,onClick:Ge,disabled:!Ge,"aria-label":G,style:U(s?36:b.headerButton,{color:Ye,opacity:Ge?1:.6}),children:M}),ee=b.headerIcon;return a("div",{class:S(t,"panel"),style:{display:"flex",flexDirection:"column",borderRadius:u?0:b.panelRadius,overflow:"hidden",border:u?void 0:`1px solid ${g}`,boxShadow:u?void 0:b.panelShadow,background:y,color:`rgb(${n.ink})`,...u?{flex:1,minHeight:0}:{height:b.panelHeight,maxHeight:`calc(100vh - ${n.offsetY+b.launcherSize+b.panelGap+12}px)`}},children:[a("div",{class:S(t,"header"),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderBottom:`1px solid ${g}`},children:[a(We,{payload:e,size:b.headerAvatar,font:14,palette:m}),a("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:2},children:[a("span",{style:{fontSize:b.nameFont,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k?k.split("—")[0].trim():"Chat"}),a("span",{style:{color:_,opacity:.7,display:"flex"},children:a(Ht,{size:16})})]}),Z(a(Hn,{size:ee}),"Call (unavailable)",b.blue),Z(a(Rn,{size:ee}),"Video call (unavailable)",b.blue),Z(a(Pn,{size:ee}),"Details (unavailable)",_),d&&Z(a(Fn,{size:ee}),"Minimize chat",_,d),c&&Z(a(me,{size:ee}),"Close chat",_,c,"close")]}),a("div",{ref:q,style:{flex:1,minHeight:0,padding:"6px 12px 12px",display:"flex",flexDirection:"column",overflowY:"auto",overscrollBehavior:"contain"},children:[W.map((M,G)=>a(Bt,{text:M.text,mine:M.mine,runStart:G===0||W[G-1].mine!==M.mine,look:n,config:t,payload:e,palette:m},M.key)),r.busy&&a(Bt,{mine:!1,runStart:hr.mine,look:n,config:t,payload:e,palette:m,children:a("span",{class:"uq-dots","aria-label":"Typing",style:{gap:4},children:[a("span",{style:{width:6,height:6}}),a("span",{style:{width:6,height:6}}),a("span",{style:{width:6,height:6}})]})}),r.error&&a("div",{class:"uq-error uq-fade",style:{display:"flex",gap:8,marginTop:6,paddingLeft:b.avatarSize+6,fontSize:12,color:_},children:[a("span",{children:r.error}),a("button",{type:"button",onClick:r.retry,style:{color:b.blue,fontWeight:500,textDecoration:"underline"},children:"Retry"})]})]}),R&&a("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 12px"},children:a("a",{class:"uq-cta",href:R.href,target:"_blank",rel:"noopener noreferrer",onClick:i,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"8px 16px",borderRadius:999,background:b.gradient,color:"#fff",fontSize:14,fontWeight:600,boxShadow:b.ctaShadow},children:[R.label||"Learn more",a(Bn,{size:16})]})}),a("form",{class:S(t,"composer"),onSubmit:E,style:{display:"flex",alignItems:"center",gap:4,padding:8,borderTop:`1px solid ${g}`},children:[a("input",{ref:H,type:"text",value:C,onInput:M=>z(M.target.value),placeholder:v,disabled:!x,maxLength:4e3,"aria-label":"Message",autoComplete:"off",style:{flex:1,minHeight:b.composerHeight,padding:"0 12px",borderRadius:b.composerRadius,background:w,color:`rgb(${n.ink})`,fontSize:s?16:14,"--uq-placeholder":_}}),r.busy?a("button",{type:"button",class:S(t,"sendButton"),onClick:r.stop,"aria-label":"Stop",style:U(b.sendSize,{color:b.blue}),children:a("span",{style:{width:10,height:10,background:"currentColor",borderRadius:2}})}):a("button",{type:"submit",class:S(t,"sendButton"),disabled:!x||!C.trim(),"aria-label":"Send",style:U(b.sendSize,{color:b.blue,opacity:x&&C.trim()?1:.5}),children:a(jn,{size:b.sendIcon})})]})]})}function Gn({payload:e,config:t,look:n,chat:r,mobile:o,focus:i,open:s,setOpen:u,pinned:d,onCta:c}){const f=jt(n.hostDark),{side:p,offsetY:l}=n,h=d?void 0:()=>u(!1);if(s&&o){const m={...n,surfaceBg:f.surface,rad:b.panelRadius};return a(Pt,{look:m,pinned:d,onClose:()=>u(!1),children:a(Dt,{payload:e,config:t,look:n,chat:r,focus:i,onCta:c,mobile:!0,fill:!0,onClose:h})})}return a(L,{children:[s&&a("div",{class:"uq-fixed uq-rise",style:{bottom:l+b.launcherSize+b.panelGap,width:b.panelWidth,...p},children:a(Dt,{payload:e,config:t,look:n,chat:r,focus:i,onCta:c,mobile:!1,onMinimize:h,onClose:h})}),a("button",{type:"button",class:S(t,"launcher","uq-fixed"),"aria-label":s?"Close chat":"Open chat","aria-expanded":s,onClick:()=>{s&&d||u(!s)},style:{bottom:l,...U(b.launcherSize,{boxShadow:b.launcherShadow}),...p},children:[a(We,{payload:e,size:b.launcherSize,font:16,palette:f,fallback:{background:b.gradient,color:"#fff"}}),s?a("span",{style:{position:"absolute",inset:0,borderRadius:"50%",background:"rgba(0,0,0,.45)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff"},children:a(Ht,{size:28})}):a("span",{style:{position:"absolute",right:-4,bottom:-4,...U(b.badgeSize,{background:b.accent,color:"#fff",boxShadow:`0 0 0 2px ${f.surface}`})},children:a(Dn,{size:12,d:b.logo})})]})]})}function ve({text:e,mine:t,onDark:n,look:r,config:o,children:i}){const s=ge(n),{isGlass:u,accentFill:d,accentText:c,rad:f}=r;return a("div",{class:S(o,t?"userMessage":"botMessage","uq-rise"),style:{alignSelf:t?"flex-end":"flex-start",maxWidth:t?"78%":"84%",padding:"8px 10px",borderRadius:f,background:t?d:u?"rgba(10,12,18,.42)":`rgba(${s},${n?.1:.06})`,color:t?c:u?"#fff":`rgb(${s})`,backdropFilter:!t&&u?"blur(6px)":void 0,fontSize:12,lineHeight:1.45,textShadow:!t&&u?"0 1px 2px rgba(0,0,0,.5)":void 0,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:i!=null?i:e})}var Vn=e=>a(ve,{mine:!1,...e,children:a("span",{class:"uq-dots","aria-label":"Typing",children:[a("span",{}),a("span",{}),a("span",{})]})});function Lt({config:e,look:t,onClick:n}){var r;const o=!((r=e.cta)===null||r===void 0||(r=r.href)===null||r===void 0)&&r.trim()?e.cta:null;return o?a("a",{class:"uq-cta",href:o.href,target:"_blank",rel:"noopener noreferrer",onClick:n,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"9px 12px",borderRadius:t.rad,background:t.accentFill,color:t.accentText,fontSize:12,fontWeight:500},children:o.label||"Learn more"}):null}function Wt({config:e,look:t,onDark:n,hint:r,chat:o,disabled:i,focus:s}){const u=ge(n),{isGlass:d,accentFill:c,accentText:f,rad:p}=t,[l,h]=A(""),m=F(null);P(()=>{var _;s>0&&((_=m.current)===null||_===void 0||_.focus())},[s]);const y=_=>{_.preventDefault(),!i&&(o.send(l),h(""))},w=d?"rgba(255,255,255,.75)":`rgba(${u},${n?.6:.45})`;return a("form",{class:S(e,"composer"),onSubmit:y,style:{display:"flex",alignItems:"center",gap:8,padding:"7px 8px 7px 11px",borderRadius:p,border:d?"1px solid rgba(255,255,255,.35)":`1px solid rgba(${u},${n?.28:.12})`,background:d?"rgba(10,12,18,.3)":`rgba(${u},${n?.08:.02})`,backdropFilter:d||n?"blur(6px)":void 0},children:[a("input",{ref:m,type:"text",value:l,onInput:_=>h(_.target.value),placeholder:r||"Message…",disabled:i,maxLength:4e3,"aria-label":"Message",autoComplete:"off",style:{flex:1,fontSize:11.5,color:d?"#fff":`rgb(${u})`,"--uq-placeholder":w}}),o.busy?a("button",{type:"button",class:S(e,"sendButton"),onClick:o.stop,"aria-label":"Stop",style:{width:24,height:24,borderRadius:p,background:c,color:f,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:a("span",{style:{width:8,height:8,background:"currentColor",borderRadius:1}})}):a("button",{type:"submit",class:S(e,"sendButton"),disabled:i,"aria-label":"Send",style:{width:24,height:24,borderRadius:p,background:c,color:f,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,opacity:i?.5:1},children:a(zt,{size:13})})]})}function Ne({welcome:e,chat:t,onDark:n,look:r,config:o}){const i=ge(n);return a(L,{children:[a(ve,{text:e,mine:!1,onDark:n,look:r,config:o}),t.turns.map(s=>s.role==="user"?a(ve,{text:s.parts[0],mine:!0,onDark:n,look:r,config:o},s.id):s.parts.slice(0,s.shown).map((u,d)=>a(ve,{text:u,mine:!1,onDark:n,look:r,config:o},`${s.id}:${d}`))),t.busy&&a(Vn,{onDark:n,look:r,config:o}),t.error&&a("div",{class:"uq-error uq-fade",style:{alignSelf:"flex-start",display:"flex",gap:8,fontSize:11.5,color:r.isGlass?"rgba(255,255,255,.8)":`rgba(${i},.6)`,textShadow:r.isGlass?"0 1px 2px rgba(0,0,0,.5)":void 0},children:[a("span",{children:t.error}),a("button",{type:"button",onClick:t.retry,style:{color:r.isGlass?"#fff":r.accent,fontWeight:500,textDecoration:"underline"},children:"Retry"})]})]})}function Oe({payload:e,config:t,look:n,chat:r,shadow:o,hint:i,focus:s,onCta:u,fill:d=!1,onClose:c}){var f,p,l;const{ink:h,surfaceBg:m,hostDark:y,accentFill:w,accentText:_,rad:g}=n,v=(f=(p=e.agent)===null||p===void 0?void 0:p.name)!==null&&f!==void 0?f:null,k=v?v.trim().charAt(0).toUpperCase():"A",x=Le(t),q=be([r.turns,r.busy,r.error]),C=!!(!((l=e.agent)===null||l===void 0)&&l.live);return a("div",{class:S(t,"panel"),style:{width:"100%",borderRadius:d?0:g,overflow:"hidden",border:d?void 0:`1px solid rgba(${h},.12)`,boxShadow:o?"0 18px 44px rgba(0,0,0,.16)":void 0,background:m,...d?{flex:1,minHeight:0,display:"flex",flexDirection:"column"}:{}},children:[a("div",{class:S(t,"header"),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:w,color:_},children:[a("span",{style:{width:20,height:20,borderRadius:"50%",background:"rgba(255,255,255,.25)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,color:_},children:k}),a("span",{style:{fontSize:12,fontWeight:500},children:v?v.split("—")[0].trim():"Chat"}),a("span",{style:{marginLeft:"auto",fontSize:10,opacity:.8},children:C?"online":"offline"}),c&&a("button",{type:"button",class:S(t,"close"),onClick:c,"aria-label":"Close chat",style:{width:28,height:28,marginRight:-6,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:_,flexShrink:0},children:a(me,{size:16})})]}),a("div",{ref:q,style:{display:"flex",flexDirection:"column",gap:7,padding:12,background:m,maxHeight:d?void 0:"min(58vh, 380px)",flex:d?1:void 0,minHeight:d?0:void 0,overflowY:"auto",overscrollBehavior:"contain"},children:a(Ne,{welcome:x,chat:r,onDark:y,look:n,config:t})}),a("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"0 12px 12px",background:m},children:[a(Lt,{config:t,look:n,onClick:u}),a(Wt,{config:t,look:n,onDark:y,hint:i,chat:r,disabled:!C,focus:s})]})]})}function Kn({payload:e,look:t,api:n,embed:r,page:o,reporter:i,open:s,setOpen:u,pinned:d,focus:c}){var f;const p=e.config,l=Nn(n,e,r,o),h=Ft(p),{accentFill:m,accentText:y,rad:w,side:_,offsetY:g}=t,v=On(),k=!!(!((f=e.agent)===null||f===void 0)&&f.live),x=Le(p),q=()=>{var z,H;return i.report("cta.clicked",{widgetId:e.id,sessionId:(z=l.sessionId)!==null&&z!==void 0?z:void 0,payload:{href:(H=p.cta)===null||H===void 0?void 0:H.href}})};if(t.isMessenger)return a(Gn,{payload:e,config:p,look:t,chat:l,mobile:v,focus:c,open:s,setOpen:u,pinned:d,onCta:q});if(p.variant==="bubble")return s&&v?a(Pt,{look:t,pinned:d,onClose:()=>u(!1),children:a(Oe,{payload:e,config:p,look:t,chat:l,shadow:!1,hint:h,focus:c,onCta:q,fill:!0,onClose:d?void 0:()=>u(!1)})}):a(L,{children:[s&&a("div",{class:"uq-fixed uq-rise",style:{bottom:g+54,width:296,..._},children:a(Oe,{payload:e,config:p,look:t,chat:l,shadow:!0,hint:h,focus:c,onCta:q})}),a("button",{type:"button",class:S(p,"launcher","uq-fixed"),"aria-label":s?"Close chat":"Open chat","aria-expanded":s,onClick:()=>{s&&d||u(!s)},style:{bottom:g,width:44,height:44,borderRadius:Math.min(22,w*2),background:m,color:y,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 10px 26px rgba(0,0,0,.24)",..._},children:a(Et,{size:20})})]});if(p.variant==="box")return a("div",{class:"uq-inline",children:a(Oe,{payload:e,config:p,look:t,chat:l,shadow:!1,hint:h,focus:c,onCta:q})});const C={payload:e,config:p,look:t,chat:l,hint:h,mobile:v,focus:c,live:k,welcome:x,onCta:q};return p.variant==="chatbar"?a(Xn,{...C}):a(Jn,{...C})}function Xn({config:e,look:t,chat:n,hint:r,mobile:o,focus:i,live:s,welcome:u}){const{ink:d,hostDark:c,accentFill:f,accentText:p,rad:l}=t,h=be([n.turns,n.busy,n.error]),m=n.turns.length>0;return a("div",{class:S(e,"panel","uq-fixed"),style:{left:0,right:0,bottom:0,padding:"10px 12px",background:c?"rgba(24,27,34,.97)":"rgba(255,255,255,.97)",borderTop:`1px solid rgba(${d},.12)`,display:"flex",flexDirection:"column",gap:10,boxShadow:"0 -10px 30px rgba(0,0,0,.12)"},children:[m&&a("div",{ref:h,style:{display:"flex",flexDirection:"column",gap:7,maxHeight:"min(50vh, 320px)",overflowY:"auto"},children:a(Ne,{welcome:u,chat:n,onDark:c,look:t,config:e})}),a("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a("span",{class:S(e,"launcher"),style:{width:26,height:26,borderRadius:l,background:f,color:p,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:a(Et,{size:14})}),a("span",{class:S(e,"botMessage"),style:{flex:1,minWidth:0,fontSize:12,color:`rgb(${d})`,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:u}),a("form",{class:S(e,"composer"),onSubmit:y=>{y.preventDefault();const w=y.currentTarget.elements.namedItem("message");!w||!s||(n.send(w.value),w.value="")},style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,padding:"6px 8px 6px 11px",borderRadius:l,border:`1px solid rgba(${d},.14)`,minWidth:o?0:220},children:[a("input",{name:"message",type:"text",placeholder:r,disabled:!s,maxLength:4e3,"aria-label":"Message",autoComplete:"off",ref:y=>{y&&i>0&&y.focus()},style:{flex:1,fontSize:11.5,color:`rgb(${d})`,"--uq-placeholder":`rgba(${d},.45)`}}),a("button",{type:n.busy?"button":"submit",class:S(e,"sendButton"),onClick:n.busy?n.stop:void 0,disabled:!s,"aria-label":n.busy?"Stop":"Send",style:{width:22,height:22,borderRadius:l,background:f,color:p,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n.busy?a("span",{style:{width:7,height:7,background:"currentColor",borderRadius:1}}):a(zt,{size:12})})]})]})]})}function Jn({config:e,look:t,chat:n,hint:r,mobile:o,focus:i,live:s,welcome:u,onCta:d}){const{hostDark:c,side:f,offsetY:p}=t,l=c,h=be([n.turns,n.busy,n.error]);return a("div",{class:S(e,"panel","uq-fixed"),style:{bottom:p,width:o?`calc(100% - ${e.appearance.offsetX*2}px)`:320,display:"flex",flexDirection:"column",gap:7,...f},children:[a("div",{ref:h,style:{display:"flex",flexDirection:"column",gap:7,maxHeight:"min(60vh, 420px)",overflowY:"auto"},children:a(Ne,{welcome:u,chat:n,onDark:l,look:t,config:e})}),a(Lt,{config:e,look:t,onClick:d}),a(Wt,{config:e,look:t,onDark:l,hint:r,chat:n,disabled:!s,focus:i})]})}var Qn=e=>/^https?:\/\//i.test(e);function Zn({config:e,block:t,index:n,look:r,onCta:o}){const{ink:i,accent:s,accentFill:u,accentText:d,rad:c}=r,f=["uq-block",`uq-block-${t.kind}`,t.cssClass.trim()].filter(Boolean).join(" "),p="align"in t?t.align:"center",l={class:f,"data-uq-block":n};switch(t.kind){case"headline":return a("div",{...l,style:{fontFamily:"var(--font-display, inherit)",fontSize:t.size==="lg"?21:t.size==="sm"?15:18,fontWeight:600,letterSpacing:"-0.02em",textAlign:p,color:t.color||`rgb(${i})`},children:t.text});case"text":return a("div",{...l,style:{fontSize:12.5,lineHeight:1.5,textAlign:p,color:t.color||`rgba(${i},.65)`,whiteSpace:"pre-wrap"},children:t.text});case"media":return!t.src||!Qn(t.src)?null:t.mediaType==="video"?a("video",{...l,src:t.src,muted:!0,loop:!0,autoPlay:!0,playsInline:!0,style:{width:"100%",maxHeight:200,objectFit:"cover",borderRadius:c,background:"#000"}}):a("img",{...l,src:t.src,alt:t.alt||"",style:{width:"100%",maxHeight:200,objectFit:"cover",borderRadius:c}});case"quote":return a("div",{...l,style:{textAlign:"center"},children:[a("div",{style:{fontSize:13,fontStyle:"italic",color:`rgb(${i})`},children:["“",t.text,"”"]}),a("div",{style:{fontSize:11,color:`rgba(${i},.55)`,marginTop:4},children:t.author})]});case"cta":return a("a",{...l,class:`${S(e,"cta")} ${f}`,href:t.href||"#",target:t.newTab?"_blank":void 0,rel:t.newTab?"noopener noreferrer":void 0,onClick:()=>o(t.href),style:{display:"block",marginTop:4,padding:"10px 14px",borderRadius:c,background:t.style==="outline"?"transparent":u,border:t.style==="outline"?`1px solid ${s}`:void 0,color:t.style==="outline"?s:d,fontSize:13,fontWeight:500,textAlign:"center"},children:t.label})}}function er({payload:e,look:t,reporter:n,open:r,setOpen:o,pinned:i}){const s=e.config,{ink:u,surfaceBg:d,rad:c}=t;if(!r)return null;const f=()=>{i||o(!1)},p=l=>n.report("cta.clicked",{widgetId:e.id,payload:{href:l}});return a("div",{class:S(s,"scrim","uq-fixed uq-fade"),onClick:f,style:{inset:0,background:"rgba(8,10,16,.5)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:a("div",{class:S(s,"card","uq-rise"),role:"dialog","aria-modal":"true",onClick:l=>l.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:340,maxHeight:"calc(100vh - 48px)",overflowY:"auto",background:d,borderRadius:c,padding:"22px 20px",boxShadow:"0 24px 60px rgba(0,0,0,.3)",display:"flex",flexDirection:"column",gap:10,textAlign:"center",color:`rgb(${u})`},children:[!i&&a("button",{type:"button",class:S(s,"close"),onClick:f,"aria-label":"Close",style:{position:"absolute",top:8,right:8,width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:`rgba(${u},.55)`},children:a(me,{size:14})}),s.blocks.map((l,h)=>a(Zn,{config:s,block:l,index:h,look:t,onCta:p},h))]})})}var tr=3600;function nr({payload:e,look:t,open:n}){const r=e.config,{ink:o,accent:i,surfaceBg:s,rad:u}=t,d=r.quotes,[c,f]=A(0);if(P(()=>{if(d.length<2)return;const h=window.setInterval(()=>f(m=>m+1),tr);return()=>window.clearInterval(h)},[d.length]),!n||d.length===0)return null;const p=c%d.length,l=d[p];return a("div",{class:"uq-fixed uq-fade",style:{left:0,right:0,bottom:0,display:"flex",justifyContent:"center",padding:24,pointerEvents:"none"},children:a("figure",{class:S(r,"frame"),style:{width:"100%",maxWidth:440,background:s,border:`1px solid rgba(${o},.12)`,borderLeft:`3px solid ${i}`,borderRadius:u,padding:"16px 18px",display:"flex",flexDirection:"column",gap:9,boxShadow:"0 14px 34px rgba(0,0,0,.12)",pointerEvents:"auto"},children:[a("blockquote",{class:S(r,"quote","uq-fade"),style:{fontSize:13.5,lineHeight:1.55,color:`rgb(${o})`},children:["“",l.text||"…","”"]},p),a("figcaption",{style:{display:"flex",alignItems:"center",gap:10},children:[a("span",{class:S(r,"author"),style:{fontFamily:"monospace",fontSize:11,color:`rgba(${o},.55)`},children:l.author||"—"}),a("span",{class:S(r,"dots"),style:{marginLeft:"auto",display:"flex",gap:4},children:d.map((h,m)=>a("span",{style:{width:5,height:5,borderRadius:"50%",background:m===p?i:`rgba(${o},.18)`}},m))})]})]})})}function rr(e){switch(e.config.type){case"chat":case"exit-popup":return!1;case"banner":case"testimonial":return!0}}function ir(e){return e.rules.length>0||e.config.type!=="exit-popup"?e.rules:[{id:`default:${e.id}`,trigger:"exit_intent",triggerParams:{},conditions:[],once:!0,actionConfig:{open:!1,autoStart:!1,pinned:!1}}]}function Nt({payload:e,api:t,embed:n,page:r,reporter:o,hostDark:i,kick:s=null}){const u=de(()=>En(e.config,i),[e,i]),d=de(()=>ir(e),[e]),[c,f]=A(d.length===0),[p,l]=A(()=>d.length===0&&rr(e)),[h,m]=A(!1),[y,w]=A(0),_=F(p),g=x=>{l(x),x!==_.current&&(_.current=x,o.report(x?"surface.opened":"surface.closed",{widgetId:e.id}))},v=({autoStart:x,pinned:q})=>{f(!0),m(q),g(!0),x&&w(C=>C+1)};if(P(()=>Ct(d,r,x=>{o.report("rule.fired",{widgetId:e.id,payload:{ruleId:x.id,trigger:x.trigger}}),v(x.actionConfig)}),[e.id]),P(()=>{s&&v(s.action)},[s]),!c)return null;const k={payload:e,look:u,api:t,embed:n,page:r,reporter:o,open:p,setOpen:g,pinned:h,focus:y};switch(e.config.type){case"chat":return a(Kn,{...k});case"exit-popup":return a(er,{...k});case"banner":return a(Ln,{...k});case"testimonial":return a(nr,{...k})}}function or(e){const t=[],n=e.config.appearance.customCss.trim();return n&&t.push(n),e.config.type==="exit-popup"&&e.config.blocks.forEach((r,o)=>{const i=r.css.trim();i&&t.push(`[data-uq-widget="${e.id}"] [data-uq-block="${o}"]{${i}}`)}),t.join(`
35
- `)}function ar(e){return e.kind==="widget"?[e.payload]:e.payload.members.map(t=>t.widget)}var sr={report:()=>{},flush:()=>{}};function lr({group:e,...t}){const[n,r]=A(e.rules.length===0),[o,i]=A(null),[s,u]=A(()=>qn(e));return P(()=>Ct(e.rules,t.page,d=>{t.reporter.report("rule.fired",{payload:{ruleId:d.id,trigger:d.trigger}}),r(!0),i(c=>{var f;return{action:d.actionConfig,n:((f=c==null?void 0:c.n)!==null&&f!==void 0?f:0)+1}})}),[e.id]),P(()=>{if(e.mode!=="sequence"||!n)return;const d=Mt(e);if(d)return Cn(e,d,c=>u(c?[c.widget]:[]))},[e.id,e.mode,n,s]),n?a(L,{children:s.map(d=>a("div",{"data-uq-widget":d.id,style:"display:contents",children:a(Nt,{payload:d,kick:o,...t})},d.id))}):null}function cr({snapshot:e,...t}){const n={kind:e.kind,id:e.payload.id};return e.kind==="group"?a(lr,{group:e.payload,embed:n,...t}):a("div",{"data-uq-widget":e.payload.id,style:"display:contents",children:a(Nt,{payload:e.payload,embed:n,...t})})}function Ot(e,t,n={}){var r,o,i;const s=(r=t.shadowRoot)!==null&&r!==void 0?r:t.attachShadow({mode:"open"}),u={base:((o=n.apiUrl)!==null&&o!==void 0?o:"https://api.usereq.com").replace(/\/+$/,"")},d={kind:e.kind,id:e.payload.id},c=n.silent?sr:xn(u,d),f=In((i=n.theme)!==null&&i!==void 0?i:null),p=Tn(),l=document.createElement("style");s.appendChild(l);const h=document.createElement("div");h.setAttribute("data-uq-root",""),h.style.display="contents",s.appendChild(h);const m=y=>{l.textContent=[mn,...ar(y).map(or)].join(`
36
- `),ut(a(cr,{snapshot:y,api:u,page:p,reporter:c,hostDark:f}),h)};return m(e),c.report("embed.loaded",{payload:{version:e.payload.version}}),{update:m,unmount:()=>{ut(null,h),c.flush(),l.remove(),h.remove()}}}function Ut(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ur(e,t){Ut(e,t),t.add(e)}function Yt(e,t,n){Ut(e,t),t.set(e,n)}function ye(e,t,n){if(typeof e=="function"?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function xe(e,t){return e.get(ye(e,t))}function we(e,t,n){return e.set(ye(e,t),n),n}var dr={widget:{element:"usereq-widget",attribute:"widget-id"},group:{element:"usereq-group",attribute:"group-id"}};function Ue(e){console.warn(`[usereq] ${e}`)}function Gt(e){const{element:t,attribute:n}=dr[e];if(customElements.get(t))return;var r=new WeakMap,o=new WeakMap,i=new WeakSet;class s extends HTMLElement{constructor(...c){super(...c),ur(this,i),Yt(this,r,null),Yt(this,o,0)}connectedCallback(){ye(i,this,u).call(this)}disconnectedCallback(){var c;(c=xe(r,this))===null||c===void 0||c.unmount(),we(r,this,null)}attributeChangedCallback(c,f,p){f!==p&&this.isConnected&&ye(i,this,u).call(this)}}async function u(){var d,c,f,p;const l=(d=this.getAttribute(n))===null||d===void 0?void 0:d.trim();if(!l)return;const h=we(o,this,(c=xe(o,this),++c));(f=xe(r,this))===null||f===void 0||f.unmount(),we(r,this,null);const m=((p=this.getAttribute("api-url"))!==null&&p!==void 0?p:"https://api.usereq.com").replace(/\/+$/,""),y=this.getAttribute("theme"),w=y==="light"||y==="dark"?y:null;let _;try{const g=await Qt({base:m},e,l);_=rn(g,e)}catch(g){g instanceof te?Ue(`${t} ${l}: ${g.message} (${g.code})`):Ue(`${t} ${l}: could not reach ${m}.`);return}if(!(h!==xe(o,this)||!this.isConnected)){if(!_){Ue(`${t} ${l}: the response was not a ${e} snapshot.`);return}we(r,this,Ot(_,this,{apiUrl:m,theme:w}))}}Se(s,"observedAttributes",[n,"api-url","theme"]),customElements.define(t,s)}function fr(){Gt("widget"),Gt("group")}return fr(),ke.render=Ot,ke})({});
34
+ `;function ie(e,t){try{return window[e].getItem(t)}catch{return null}}function oe(e,t,n){try{window[e].setItem(t,n)}catch{}}function It(e,t){try{window[e].removeItem(t)}catch{}}var qn=2e3,In=20,Tn=100;function We(e=Date.now()){const t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/1099511627776&255,t[1]=e/4294967296&255,t[2]=e/16777216&255,t[3]=e/65536&255,t[4]=e/256&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}var Tt="usereq:visitor";function Mt(){const e=ie("localStorage",Tt);if(e)return e;const t=We();return oe("localStorage",Tt,t),t}function Mn(e,t){const n=[];let r=null;const o=Mt(),i=()=>{for(r!==null&&(window.clearTimeout(r),r=null);n.length>0;){const u=n.splice(0,Tn);dn(e,{events:u})}},a=(u,d={})=>{n.push({id:We(),type:u,embedKind:t.kind,embedId:t.id,widgetId:d.widgetId,sessionId:d.sessionId,clientKey:o,url:window.location.href.slice(0,2e3),occurredAt:new Date().toISOString(),payload:d.payload}),n.length>=In?i():r===null&&(r=window.setTimeout(i,qn))};return window.addEventListener("pagehide",i),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&i()}),{report:a,flush:i}}var At=e=>`usereq:once:${e}`;function Le(e,t,n){switch(e){case"is":return t===n;case"starts_with":return t.startsWith(n);case"contains":return t.includes(n);case"matches":try{return new RegExp(n).test(t)}catch{return!1}}}function An(e,t){switch(e.kind){case"path":return e.value==="*"||Le(e.op,t.path,e.value);case"utm":var n;return Le(e.op,(n=t.utm[e.param])!==null&&n!==void 0?n:"",e.value);case"device":return t.device===e.value;case"referrer":return Le(e.op,t.referrer,e.value)}}function zn(e,t){for(const n of e)if(!(n.once&&ie("sessionStorage",At(n.id)))&&n.conditions.every(r=>An(r,t)))return n;return null}function zt(e,t,n){let r=!1,o=()=>{};const i=()=>{r||(r=!0,o(),n())};switch(e){case"page_load":{const d=window.setTimeout(i,0);o=()=>window.clearTimeout(d);break}case"time_on_page":{const d=Number(t.seconds)||0,c=window.setTimeout(i,d*1e3);o=()=>window.clearTimeout(c);break}case"scroll_depth":{const d=Number(t.percent)||0,c=()=>{const f=document.documentElement.scrollHeight-window.innerHeight;(f<=0?100:window.scrollY/f*100)>=d&&i()};window.addEventListener("scroll",c,{passive:!0}),o=()=>window.removeEventListener("scroll",c),c();break}case"element_click":{var a;const d=String((a=t.selector)!==null&&a!==void 0?a:""),c=f=>{const h=f.target;if(!(!(h instanceof Element)||!d))try{h.closest(d)&&i()}catch{}};document.addEventListener("click",c,!0),o=()=>document.removeEventListener("click",c,!0);break}case"element_visible":{var u;const d=String((u=t.selector)!==null&&u!==void 0?u:"");let c=null;const f=()=>{let h=null;try{h=d?document.querySelector(d):null}catch{h=null}return h?(c=new IntersectionObserver(l=>{l.some(p=>p.isIntersecting)&&i()}),c.observe(h),!0):!1};!f()&&document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",()=>void f(),{once:!0}),o=()=>c==null?void 0:c.disconnect();break}case"exit_intent":{const d=c=>{c.relatedTarget===null&&c.clientY<=0&&i()};document.addEventListener("mouseout",d),o=()=>document.removeEventListener("mouseout",d);break}}return()=>{r=!0,o()}}function Rt(e,t,n){const r=zn(e,t);return r?zt(r.trigger,r.triggerParams,()=>{r.once&&oe("sessionStorage",At(r.id),"1"),n(r)}):()=>{}}var Et=e=>`usereq:split:${e}`,Ht=e=>`usereq:seq:${e}`;function Rn(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function ye(e){return[...e].sort((t,n)=>t.position-n.position)}function En(e){const t=ye(e.members);if(t.length===0)return null;const n=ie("localStorage",Et(e.id)),r=n?t.find(u=>u.widget.id===n):void 0;if(r)return r;const o=t.reduce((u,d)=>u+d.weight,0);let i=Rn(`${Mt()}:${e.config.salt}`)%o,a=t[t.length-1];for(const u of t){if(i<u.weight){a=u;break}i-=u.weight}return oe("localStorage",Et(e.id),a.widget.id),a}function Pt(e){var t,n;const r=ye(e.members);if(r.length===0)return null;const o=Number((t=ie("sessionStorage",Ht(e.id)))!==null&&t!==void 0?t:0);return(n=r[Number.isFinite(o)?Math.min(o,r.length-1):0])!==null&&n!==void 0?n:null}function Hn(e,t,n){if(!t.advanceOn)return()=>{};const r=ye(e.members),o=r.findIndex(i=>i.widget.id===t.widget.id);return zt(t.advanceOn.kind,t.advanceOn.params,()=>{var i;const a=o+1<r.length?o+1:null;if(a===null){n(null);return}oe("sessionStorage",Ht(e.id),String(a)),n((i=r[a])!==null&&i!==void 0?i:null)})}function Pn(e){switch(e.mode){case"split":{const t=En(e);return t?[t.widget]:[]}case"sequence":{const t=Pt(e);return t?[t.widget]:[]}case"parallel":return ye(e.members).map(t=>t.widget)}}function jn(e){var t,n,r,o;if(e)return e==="dark";const i=(t=jt(getComputedStyle(document.body).backgroundColor))!==null&&t!==void 0?t:jt(getComputedStyle(document.documentElement).backgroundColor);return i!==null?i<.5:(n=(r=(o=window).matchMedia)===null||r===void 0?void 0:r.call(o,"(prefers-color-scheme: dark)").matches)!==null&&n!==void 0?n:!1}function jt(e){const t=/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)(?:[,\s/]+([\d.]+))?/.exec(e);if(!t||(t[4]===void 0?1:Number(t[4]))<.5)return null;const[n,r,o]=[Number(t[1]),Number(t[2]),Number(t[3])];return(.299*n+.587*r+.114*o)/255}function Fn(e=window.innerWidth){return e<640?"mobile":e<1024?"tablet":"desktop"}function Bn(){const e=new URL(window.location.href),t={};for(const n of["source","medium","campaign","term","content"]){const r=e.searchParams.get(`utm_${n}`);r&&(t[n]=r)}return{href:e.href.slice(0,2e3),path:e.pathname,referrer:document.referrer.slice(0,2e3),utm:t,device:Fn()}}function Ft(e){const t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function Dn(e){const{r:t,g:n,b:r}=Ft(e);return(.299*t+.587*n+.114*r)/255>.62?"#15171e":"#ffffff"}var se=e=>e?"245,245,241":"21,23,30";function Wn(e,t){const n=e.appearance,r=n.accent;return{accent:r,accentFill:(()=>{if(n.alpha>=100)return r;const{r:o,g:i,b:a}=Ft(r);return`rgba(${o},${i},${a},${n.alpha/100})`})(),accentText:Dn(r),rad:n.radius,isGlass:e.type==="chat"&&e.variant==="stream"&&n.skin==="glass",isMessenger:e.type==="chat"&&e.variant==="bubble"&&e.preset==="facebook-messenger",hostDark:t,ink:se(t),surfaceBg:t?"#181b22":"#ffffff",side:n.position==="bottom-right"?{right:n.offsetX}:{left:n.offsetX},offsetY:n.offsetY}}function k(e,t,n){const r=e.appearance.parts[t],o=[`uq-${t}`];return n&&o.push(n),r&&o.push(r.trim()),o.join(" ")}var Ln=0,Ir=Array.isArray;function s(e,t,n,r,o,i){t||(t={});var a,u,d=t;if("ref"in d)for(u in d={},t)u=="ref"?a=t[u]:d[u]=t[u];var c={type:e,props:d,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ln,__i:-1,__u:0,__source:o,__self:i};if(typeof e=="function"&&(a=e.defaultProps))for(u in a)d[u]===void 0&&(d[u]=a[u]);return C.vnode&&C.vnode(c),c}function j({size:e,children:t}){return s("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:t})}var Bt=({size:e})=>s(j,{size:e,children:[s("path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}),s("path",{d:"M20 2v4"}),s("path",{d:"M22 4h-4"}),s("circle",{cx:"4",cy:"20",r:"2"})]}),Dt=({size:e})=>s(j,{size:e,children:[s("path",{d:"M5 12h14"}),s("path",{d:"m12 5 7 7-7 7"})]}),xe=({size:e})=>s(j,{size:e,children:[s("path",{d:"M18 6 6 18"}),s("path",{d:"m6 6 12 12"})]}),Oe=({size:e})=>s(j,{size:e,children:[s("path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}),s("path",{d:"m15 9-6 6"}),s("path",{d:"m9 9 6 6"})]}),On=({size:e})=>s(j,{size:e,children:s("path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"})}),Nn=({size:e})=>s(j,{size:e,children:[s("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),s("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]}),Un=({size:e})=>s(j,{size:e,children:[s("circle",{cx:"12",cy:"12",r:"10"}),s("path",{d:"M12 16v-4"}),s("path",{d:"M12 8h.01"})]}),Wt=({size:e})=>s(j,{size:e,children:s("path",{d:"m6 9 6 6 6-6"})}),Yn=({size:e})=>s(j,{size:e,children:s("path",{d:"M5 12h14"})}),Gn=({size:e})=>s(j,{size:e,children:[s("path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}),s("path",{d:"m21.854 2.147-10.94 10.939"})]}),Kn=({size:e})=>s(j,{size:e,children:[s("path",{d:"M15 3h6v6"}),s("path",{d:"M10 14 21 3"}),s("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]}),Vn=({size:e,d:t})=>s("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s("path",{d:t})});function Xn({payload:e,look:t,reporter:n,open:r,setOpen:o,pinned:i}){var a;const u=e.config,{accentFill:d,accentText:c,rad:f}=t;if(!r)return null;const h=!((a=u.cta)===null||a===void 0)&&a.label.trim()?u.cta:null,l=(h==null?void 0:h.href.trim())||"",p=u.position==="bottom"?{bottom:0}:{top:0};return s("div",{class:k(u,"strip","uq-fixed uq-fade"),role:"region","aria-label":"Announcement",style:{left:0,right:0,...p,display:"flex",alignItems:"center",justifyContent:"center",gap:14,padding:"11px 14px",background:d,color:c},children:[s("span",{class:k(u,"text"),style:{fontSize:12.5,fontWeight:500},children:u.text}),h&&s("a",{class:k(u,"cta"),href:l||"#",target:l?"_blank":void 0,rel:l?"noopener noreferrer":void 0,onClick:()=>n.report("cta.clicked",{widgetId:e.id,payload:{href:l}}),style:{fontSize:11.5,padding:"5px 10px",borderRadius:f,border:`1px solid ${c}`,whiteSpace:"nowrap"},children:h.label}),!i&&s("button",{type:"button",class:k(u,"close"),onClick:()=>o(!1),"aria-label":"Close",style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",opacity:.7},children:s(xe,{size:14})})]})}var Ne={holdMs:1260,gapMs:1520,jitterMs:100};function Jn(e,t=Math.random){const n=[];let r=0;for(let o=0;o<e;o++){if(o===0)r+=Ne.holdMs;else{const i=Math.round((t()*2-1)*Ne.jitterMs);r+=Math.max(0,Ne.gapMs+i)}n.push(r)}return n}var we=e=>`usereq:session:${e}`;function Qn(e,t=Date.now()){const n=ie("localStorage",we(e));if(!n)return null;try{const r=JSON.parse(n);if(typeof r!="object"||r===null||!("token"in r)||typeof r.token!="string"||!("conversationId"in r)||typeof r.conversationId!="string"||!("expiresAt"in r)||typeof r.expiresAt!="string")return null;const o=Date.parse(r.expiresAt);return!Number.isFinite(o)||o<=t?(It("localStorage",we(e)),null):{token:r.token,conversationId:r.conversationId,expiresAt:r.expiresAt}}catch{return null}}function Zn(e,t){oe("localStorage",we(e),JSON.stringify(t))}function er(e){It("localStorage",we(e))}function tr(e){const t=e.parts.map(n=>n.text).filter(n=>n.trim());return t.length===0?null:{id:e.id,role:e.role,parts:t,shown:t.length}}function nr(e,t,n,r){const[o,i]=H([]),[a,u]=H(!1),[d,c]=H(null),[f,h]=H(null),[l,p]=H(null),m=B(null),x=B(null),v=B([]),_=B(null),g=()=>{for(const w of v.current)window.clearTimeout(w);v.current=[]};P(()=>()=>g(),[]);const y=t.id,$=U(()=>{m.current=null,h(null),er(y)},[y]);P(()=>{const w=Qn(y);if(!w)return;let I=!1;return m.current={token:w.token,conversationId:w.conversationId},h(w.conversationId),ln(e,w.token).then(S=>{if(!I){if(S.ended){$();return}i(S.messages.flatMap(T=>{const M=tr(T);return M?[M]:[]}))}}).catch(S=>{I||S instanceof G&&S.status<500&&$()}),()=>{I=!0}},[e,y,$]);const q=U(async()=>{if(m.current)return m.current;const w=await an(e,{kind:n.kind,id:n.id,widgetId:n.kind==="group"?t.id:void 0,landingUrl:r.href,referrer:r.referrer||void 0,utm:Object.keys(r.utm).length?r.utm:void 0});return m.current={token:w.token,conversationId:w.conversationId},Zn(y,{token:w.token,conversationId:w.conversationId,expiresAt:w.expiresAt}),h(w.conversationId),m.current},[e,n.kind,n.id,t.id,r,y]),A=U(async(w,I)=>{var S;(S=x.current)===null||S===void 0||S.abort();const T=new AbortController;x.current=T,g(),u(!0),c(null);try{const{token:M}=await q(),J=await un(e,M,w,I,T.signal);if(T.signal.aborted)return;const F=J.parts.filter(L=>L.trim());if(F.length===0)throw new Error("The agent did not answer. Try again.");i(L=>[...L,{id:J.id,role:"assistant",parts:F,shown:0}]),v.current=Jn(F.length).map((L,le)=>window.setTimeout(()=>{i(Y=>Y.map(D=>D.id===J.id?{...D,shown:le+1}:D)),le===F.length-1&&u(!1)},L))}catch(M){if(T.signal.aborted)return;M instanceof G&&(M.status===401||M.status===409)&&$(),u(!1),c(M instanceof G?M.message:M instanceof TypeError?"Could not reach the agent. Try again.":M instanceof Error&&M.message?M.message:"Something went wrong. Try again.")}},[e,q,$]);return{turns:o,busy:a,error:d,sessionId:f,stopping:l,send:U(w=>{const I=w.trim().slice(0,4e3);if(!I||a||l)return;const S={id:We(),text:I};_.current=S,i(T=>[...T,{id:S.id,role:"user",parts:[I],shown:1}]),A(S,"submit-message")},[a,l,A]),retry:U(()=>{!_.current||a||l||A(_.current,"regenerate-message")},[a,l,A]),stop:U(()=>{var w;(w=x.current)===null||w===void 0||w.abort(),x.current=null,g(),i(I=>I.map(S=>S.role==="assistant"&&S.shown<S.parts.length?{...S,shown:S.parts.length}:S)),u(!1)},[]),askToStop:U(()=>{!m.current||a||p({busy:!1,error:null})},[a]),answerStop:U(async w=>{const I=m.current;if(!w||!I){p(null);return}p({busy:!0,error:null});try{await cn(e,I.token)}catch(S){if(!(S instanceof G&&(S.status===401||S.status===409))){p({busy:!1,error:S instanceof G?S.message:"Could not stop the conversation. Try again."});return}}$(),_.current=null,i([]),c(null),p(null)},[e,$])}}function rr(){const e="(max-width: 639px)",[t,n]=H(()=>{var r,o,i;return(r=(o=(i=window).matchMedia)===null||o===void 0?void 0:o.call(i,e).matches)!==null&&r!==void 0?r:!1});return P(()=>{var r,o;const i=(r=(o=window).matchMedia)===null||r===void 0?void 0:r.call(o,e);if(!i)return;const a=()=>n(i.matches);return i.addEventListener("change",a),()=>i.removeEventListener("change",a)},[]),t}var ir=.5,Lt=120,Ue=()=>document.documentElement.clientHeight;function Ot({look:e,pinned:t,onClose:n,children:r}){const[o,i]=H("half"),[a,u]=H(null),d=B(null),c=B(null),f=_=>{const g=d.current;g&&(_.currentTarget.setPointerCapture(_.pointerId),c.current={startY:_.clientY,startHeight:g.getBoundingClientRect().height,lastY:_.clientY,lastAt:_.timeStamp,velocity:0},u(c.current.startHeight))},h=_=>{const g=c.current;if(!g)return;const y=_.timeStamp-g.lastAt;y>0&&(g.velocity=(_.clientY-g.lastY)/y),g.lastY=_.clientY,g.lastAt=_.timeStamp;const $=g.startHeight+(g.startY-_.clientY);u(Math.max(Lt,Math.min(Ue(),$)))},l=()=>{const _=c.current;if(!_)return;c.current=null;const g=Math.max(Lt,Math.min(Ue(),_.startHeight+(_.startY-_.lastY))),y=Ue();let $;if(_.velocity<-.5?$="full":_.velocity>ir?$=o==="full"?"half":"closed":g>y*.75?$="full":g<y*.3?$="closed":$="half",u(null),$==="closed"){t?i("half"):n();return}i($)},{ink:p,surfaceBg:m,rad:x}=e,v=o==="full"&&a===null;return s("div",{ref:d,class:["uq-fixed uq-drawer uq-slide",v?"uq-drawer-full":"uq-drawer-half",a!==null&&"uq-drawer-held"].filter(Boolean).join(" "),role:"dialog","aria-modal":"false",style:{height:a!==null?a:void 0,borderRadius:v?0:`${x}px ${x}px 0 0`,borderTop:`1px solid rgba(${p},.12)`,background:m,boxShadow:"0 -12px 40px rgba(0,0,0,.18)"},children:[s("div",{class:"uq-grab",onPointerDown:f,onPointerMove:h,onPointerUp:l,onPointerCancel:l,"aria-label":v?"Drag down to shrink or close":"Drag up to expand",style:{background:m},children:s("span",{style:{background:`rgba(${p},.25)`}})}),r]})}var b={accent:"#7B5BFF",gradient:"linear-gradient(135deg,#00B2FF 0%,#006AFF 38%,#8E5BFF 100%)",blue:"#0084FF",surface:{light:"#ffffff",dark:"#242526"},bubble:{light:"#f5f5f5",dark:"#404040"},muted:{light:"#8e8e8e",dark:"#a8a8a8"},border:{light:"rgba(0,0,0,.1)",dark:"rgba(255,255,255,.12)"},panelWidth:372,panelHeight:520,panelRadius:24,panelGap:14,panelShadow:"0 8px 32px rgba(0,0,0,.16)",launcherSize:60,launcherShadow:"0 6px 20px rgba(123,91,255,.4)",badgeSize:20,logo:"M12 2C6.48 2 2 6.18 2 11.32c0 2.93 1.45 5.55 3.7 7.27v3.4l3.39-1.86a10.5 10.5 0 0 0 2.91.41c5.52 0 10-4.18 10-9.22S17.52 2 12 2Zm1.06 12.42-2.55-2.72-4.97 2.72 5.46-5.8 2.61 2.72 4.91-2.72-5.46 5.8Z",headerAvatar:40,headerButton:28,headerIcon:18,nameFont:15,avatarSize:28,bubbleRadius:18,bubbleFont:14,bubblePadding:"6px 12px",bubbleMaxWidth:"78%",ctaShadow:"0 4px 12px rgba(123,91,255,.32)",composerPlaceholder:"Aa",composerRadius:24,composerHeight:36,sendSize:36,sendIcon:20},or=3600,Ye=e=>e.welcome||"Hi! Ask me anything before you buy.";function Nt(e,t="Type your message…"){const n=e.spotlights.filter(a=>a.trim()),[r,o]=H(0);P(()=>{if(n.length<2)return;const a=window.setInterval(()=>o(u=>u+1),or);return()=>window.clearInterval(a)},[n.length]);const i=e.placeholder||t;return n.length?n[r%n.length]:i}function Se(e){const t=B(null);return P(()=>{const n=t.current;n&&(n.scrollTop=n.scrollHeight)},e),t}function Ut(e){const t=e?"dark":"light";return{surface:b.surface[t],bubble:b.bubble[t],muted:b.muted[t],border:b.border[t]}}var X=(e,t={})=>({width:e,height:e,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,...t});function Ge({payload:e,size:t,font:n,palette:r,fallback:o}){var i,a,u,d;const c=(i=(a=e.agent)===null||a===void 0?void 0:a.name)!==null&&i!==void 0?i:null,f=(u=(d=e.agent)===null||d===void 0?void 0:d.avatarUrl)!==null&&u!==void 0?u:null;return f?s("img",{src:f,alt:"",width:t,height:t,style:X(t,{objectFit:"cover"})}):s("span",{style:X(t,{background:r.bubble,color:r.muted,fontSize:n,fontWeight:600,...o}),children:c?c.trim().charAt(0).toUpperCase():"A"})}function Ke({text:e,mine:t,runStart:n,look:r,config:o,payload:i,palette:a,children:u}){return s("div",{class:"uq-rise",style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:t?"flex-end":"flex-start",marginTop:n?6:2},children:[!t&&(n?s(Ge,{payload:i,size:b.avatarSize,font:12,palette:a}):s("span",{style:{width:b.avatarSize,flexShrink:0}})),s("div",{class:k(o,t?"userMessage":"botMessage"),style:{maxWidth:b.bubbleMaxWidth,padding:u?"8px 12px":b.bubblePadding,borderRadius:b.bubbleRadius,background:t?b.gradient:a.bubble,color:t?"#fff":`rgb(${r.ink})`,fontSize:b.bubbleFont,lineHeight:1.375,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:u!=null?u:e})]})}function sr({chat:e,stopping:t}){const n={padding:"6px 12px",borderRadius:999,fontSize:13,fontWeight:600,lineHeight:1.3,opacity:t.busy?.6:1};return s("div",{class:"uq-stop",style:{display:"flex",flexDirection:"column",gap:8},children:[s("span",{style:{fontWeight:600},children:"Stop the conversation?"}),s("span",{children:"Do you want to stop this conversation?"}),s("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[s("button",{type:"button",onClick:()=>e.answerStop(!1),disabled:t.busy,style:{...n,border:`1px solid ${b.blue}`,color:b.blue},children:"Keep chatting"}),s("button",{type:"button",onClick:()=>e.answerStop(!0),disabled:t.busy,style:{...n,background:b.gradient,color:"#fff"},children:t.busy?"Stopping…":"Stop conversation"})]}),t.error&&s("span",{class:"uq-fade",style:{opacity:.7},children:t.error})]})}function Yt({payload:e,config:t,look:n,chat:r,focus:o,onCta:i,mobile:a,fill:u=!1,onMinimize:d,onClose:c}){var f,h,l,p;const m=Ut(n.hostDark),{surface:x,bubble:v,muted:_,border:g}=m,y=Nt(t,b.composerPlaceholder),$=(f=(h=e.agent)===null||h===void 0?void 0:h.name)!==null&&f!==void 0?f:null,q=!!(!((l=e.agent)===null||l===void 0)&&l.live),A=Se([r.turns,r.busy,r.error,r.stopping]),[w,I]=H(""),S=B(null);P(()=>{var R;o>0&&((R=S.current)===null||R===void 0||R.focus())},[o]);const T=q&&!r.stopping,M=R=>{R.preventDefault(),T&&(r.send(w),I(""))},J=!((p=t.cta)===null||p===void 0||(p=p.href)===null||p===void 0)&&p.trim()?t.cta:null,F=[{key:"welcome",text:Ye(t),mine:!1}];for(const R of r.turns)if(R.role==="user"){var L;F.push({key:R.id,text:(L=R.parts[0])!==null&&L!==void 0?L:"",mine:!0})}else R.parts.slice(0,R.shown).forEach((Q,Qe)=>{F.push({key:`${R.id}:${Qe}`,text:Q,mine:!1})});const le=F[F.length-1],Y=(R,Q,Qe,Ze,tn)=>s("button",{type:"button",class:tn?k(t,tn):void 0,onClick:Ze,disabled:!Ze,"aria-label":Q,style:X(a?36:b.headerButton,{color:Qe,opacity:Ze?1:.6}),children:R}),D=b.headerIcon;return s("div",{class:k(t,"panel"),style:{display:"flex",flexDirection:"column",borderRadius:u?0:b.panelRadius,overflow:"hidden",border:u?void 0:`1px solid ${g}`,boxShadow:u?void 0:b.panelShadow,background:x,color:`rgb(${n.ink})`,...u?{flex:1,minHeight:0}:{height:b.panelHeight,maxHeight:`calc(100vh - ${n.offsetY+b.launcherSize+b.panelGap+12}px)`}},children:[s("div",{class:k(t,"header"),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderBottom:`1px solid ${g}`},children:[s(Ge,{payload:e,size:b.headerAvatar,font:14,palette:m}),s("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:2},children:[s("span",{style:{fontSize:b.nameFont,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$?$.split("—")[0].trim():"Chat"}),s("span",{style:{color:_,opacity:.7,display:"flex"},children:s(Wt,{size:16})})]}),Y(s(On,{size:D}),"Call (unavailable)",b.blue),Y(s(Nn,{size:D}),"Video call (unavailable)",b.blue),Y(s(Un,{size:D}),"Details (unavailable)",_),r.sessionId&&Y(s(Oe,{size:D}),"Stop conversation",_,r.busy||r.stopping?void 0:r.askToStop,"stopButton"),d&&Y(s(Yn,{size:D}),"Minimize chat",_,d),c&&Y(s(xe,{size:D}),"Close chat",_,c,"close")]}),s("div",{ref:A,style:{flex:1,minHeight:0,padding:"6px 12px 12px",display:"flex",flexDirection:"column",overflowY:"auto",overscrollBehavior:"contain"},children:[F.map((R,Q)=>s(Ke,{text:R.text,mine:R.mine,runStart:Q===0||F[Q-1].mine!==R.mine,look:n,config:t,payload:e,palette:m},R.key)),r.stopping&&s(Ke,{mine:!1,runStart:le.mine,look:n,config:t,payload:e,palette:m,children:s(sr,{chat:r,stopping:r.stopping})}),r.busy&&s(Ke,{mine:!1,runStart:le.mine,look:n,config:t,payload:e,palette:m,children:s("span",{class:"uq-dots","aria-label":"Typing",style:{gap:4},children:[s("span",{style:{width:6,height:6}}),s("span",{style:{width:6,height:6}}),s("span",{style:{width:6,height:6}})]})}),r.error&&s("div",{class:"uq-error uq-fade",style:{display:"flex",gap:8,marginTop:6,paddingLeft:b.avatarSize+6,fontSize:12,color:_},children:[s("span",{children:r.error}),s("button",{type:"button",onClick:r.retry,style:{color:b.blue,fontWeight:500,textDecoration:"underline"},children:"Retry"})]})]}),J&&s("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 12px"},children:s("a",{class:"uq-cta",href:J.href,target:"_blank",rel:"noopener noreferrer",onClick:i,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"8px 16px",borderRadius:999,background:b.gradient,color:"#fff",fontSize:14,fontWeight:600,boxShadow:b.ctaShadow},children:[J.label||"Learn more",s(Kn,{size:16})]})}),s("form",{class:k(t,"composer"),onSubmit:M,style:{display:"flex",alignItems:"center",gap:4,padding:8,borderTop:`1px solid ${g}`},children:[s("input",{ref:S,type:"text",value:w,onInput:R=>I(R.target.value),placeholder:y,disabled:!T,maxLength:4e3,"aria-label":"Message",autoComplete:"off",style:{flex:1,minHeight:b.composerHeight,padding:"0 12px",borderRadius:b.composerRadius,background:v,color:`rgb(${n.ink})`,fontSize:a?16:14,"--uq-placeholder":_}}),r.busy?s("button",{type:"button",class:k(t,"sendButton"),onClick:r.stop,"aria-label":"Stop",style:X(b.sendSize,{color:b.blue}),children:s("span",{style:{width:10,height:10,background:"currentColor",borderRadius:2}})}):s("button",{type:"submit",class:k(t,"sendButton"),disabled:!T||!w.trim(),"aria-label":"Send",style:X(b.sendSize,{color:b.blue,opacity:T&&w.trim()?1:.5}),children:s(Gn,{size:b.sendIcon})})]})]})}function ar({payload:e,config:t,look:n,chat:r,mobile:o,focus:i,open:a,setOpen:u,pinned:d,onCta:c}){const f=Ut(n.hostDark),{side:h,offsetY:l}=n,p=d?void 0:()=>u(!1);if(a&&o){const m={...n,surfaceBg:f.surface,rad:b.panelRadius};return s(Ot,{look:m,pinned:d,onClose:()=>u(!1),children:s(Yt,{payload:e,config:t,look:n,chat:r,focus:i,onCta:c,mobile:!0,fill:!0,onClose:p})})}return s(N,{children:[a&&s("div",{class:"uq-fixed uq-rise",style:{bottom:l+b.launcherSize+b.panelGap,width:b.panelWidth,...h},children:s(Yt,{payload:e,config:t,look:n,chat:r,focus:i,onCta:c,mobile:!1,onMinimize:p,onClose:p})}),s("button",{type:"button",class:k(t,"launcher","uq-fixed"),"aria-label":a?"Close chat":"Open chat","aria-expanded":a,onClick:()=>{a&&d||u(!a)},style:{bottom:l,...X(b.launcherSize,{boxShadow:b.launcherShadow}),...h},children:[s(Ge,{payload:e,size:b.launcherSize,font:16,palette:f,fallback:{background:b.gradient,color:"#fff"}}),a?s("span",{style:{position:"absolute",inset:0,borderRadius:"50%",background:"rgba(0,0,0,.45)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff"},children:s(Wt,{size:28})}):s("span",{style:{position:"absolute",right:-4,bottom:-4,...X(b.badgeSize,{background:b.accent,color:"#fff",boxShadow:`0 0 0 2px ${f.surface}`})},children:s(Vn,{size:12,d:b.logo})})]})]})}function ae({text:e,mine:t,onDark:n,look:r,config:o,children:i}){const a=se(n),{isGlass:u,accentFill:d,accentText:c,rad:f}=r;return s("div",{class:k(o,t?"userMessage":"botMessage","uq-rise"),style:{alignSelf:t?"flex-end":"flex-start",maxWidth:t?"78%":"84%",padding:"8px 10px",borderRadius:f,background:t?d:u?"rgba(10,12,18,.42)":`rgba(${a},${n?.1:.06})`,color:t?c:u?"#fff":`rgb(${a})`,backdropFilter:!t&&u?"blur(6px)":void 0,fontSize:12,lineHeight:1.45,textShadow:!t&&u?"0 1px 2px rgba(0,0,0,.5)":void 0,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:i!=null?i:e})}var lr=e=>s(ae,{mine:!1,...e,children:s("span",{class:"uq-dots","aria-label":"Typing",children:[s("span",{}),s("span",{}),s("span",{})]})});function cr({chat:e,onDark:t,look:n,config:r}){const o=e.stopping;if(!o)return null;const{isGlass:i,accent:a,accentFill:u,accentText:d,rad:c}=n,f=i?"#fff":a,h={padding:"5px 10px",borderRadius:c,fontSize:11.5,fontWeight:500,lineHeight:1.3,opacity:o.busy?.6:1};return s(ae,{mine:!1,onDark:t,look:n,config:r,children:s("div",{class:"uq-stop",style:{display:"flex",flexDirection:"column",gap:8},children:[s("span",{style:{fontWeight:600},children:"Stop the conversation?"}),s("span",{children:"Do you want to stop this conversation?"}),s("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[s("button",{type:"button",onClick:()=>e.answerStop(!1),disabled:o.busy,style:{...h,border:`1px solid ${f}`,color:f},children:"Keep chatting"}),s("button",{type:"button",onClick:()=>e.answerStop(!0),disabled:o.busy,style:{...h,background:u,color:d},children:o.busy?"Stopping…":"Stop conversation"})]}),o.error&&s("span",{class:"uq-fade",style:{opacity:.7},children:o.error})]})})}function Gt({config:e,look:t,onDark:n,chat:r,size:o}){if(!r.sessionId)return null;const i=se(n),a=!r.busy&&!r.stopping;return s("button",{type:"button",class:k(e,"stopButton"),onClick:r.askToStop,disabled:!a,"aria-label":"Stop conversation",style:{width:o,height:o,borderRadius:t.rad,color:t.isGlass?"#fff":`rgb(${i})`,opacity:a?.55:.3,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s(Oe,{size:o-9})})}function Kt({config:e,look:t,onClick:n}){var r;const o=!((r=e.cta)===null||r===void 0||(r=r.href)===null||r===void 0)&&r.trim()?e.cta:null;return o?s("a",{class:"uq-cta",href:o.href,target:"_blank",rel:"noopener noreferrer",onClick:n,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"9px 12px",borderRadius:t.rad,background:t.accentFill,color:t.accentText,fontSize:12,fontWeight:500},children:o.label||"Learn more"}):null}function Vt({config:e,look:t,onDark:n,hint:r,chat:o,disabled:i,focus:a,withStop:u=!1}){const d=se(n),{isGlass:c,accentFill:f,accentText:h,rad:l}=t,[p,m]=H(""),x=B(null);P(()=>{var y;a>0&&((y=x.current)===null||y===void 0||y.focus())},[a]);const v=i||!!o.stopping,_=y=>{y.preventDefault(),!v&&(o.send(p),m(""))},g=c?"rgba(255,255,255,.75)":`rgba(${d},${n?.6:.45})`;return s("form",{class:k(e,"composer"),onSubmit:_,style:{display:"flex",alignItems:"center",gap:8,padding:"7px 8px 7px 11px",borderRadius:l,border:c?"1px solid rgba(255,255,255,.35)":`1px solid rgba(${d},${n?.28:.12})`,background:c?"rgba(10,12,18,.3)":`rgba(${d},${n?.08:.02})`,backdropFilter:c||n?"blur(6px)":void 0},children:[s("input",{ref:x,type:"text",value:p,onInput:y=>m(y.target.value),placeholder:r||"Message…",disabled:v,maxLength:4e3,"aria-label":"Message",autoComplete:"off",style:{flex:1,fontSize:11.5,color:c?"#fff":`rgb(${d})`,"--uq-placeholder":g}}),u&&s(Gt,{config:e,look:t,onDark:n,chat:o,size:24}),o.busy?s("button",{type:"button",class:k(e,"sendButton"),onClick:o.stop,"aria-label":"Stop",style:{width:24,height:24,borderRadius:l,background:f,color:h,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s("span",{style:{width:8,height:8,background:"currentColor",borderRadius:1}})}):s("button",{type:"submit",class:k(e,"sendButton"),disabled:v,"aria-label":"Send",style:{width:24,height:24,borderRadius:l,background:f,color:h,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,opacity:v?.5:1},children:s(Dt,{size:13})})]})}function Ve({welcome:e,chat:t,onDark:n,look:r,config:o}){const i=se(n);return s(N,{children:[s(ae,{text:e,mine:!1,onDark:n,look:r,config:o}),t.turns.map(a=>a.role==="user"?s(ae,{text:a.parts[0],mine:!0,onDark:n,look:r,config:o},a.id):a.parts.slice(0,a.shown).map((u,d)=>s(ae,{text:u,mine:!1,onDark:n,look:r,config:o},`${a.id}:${d}`))),s(cr,{chat:t,onDark:n,look:r,config:o}),t.busy&&s(lr,{onDark:n,look:r,config:o}),t.error&&s("div",{class:"uq-error uq-fade",style:{alignSelf:"flex-start",display:"flex",gap:8,fontSize:11.5,color:r.isGlass?"rgba(255,255,255,.8)":`rgba(${i},.6)`,textShadow:r.isGlass?"0 1px 2px rgba(0,0,0,.5)":void 0},children:[s("span",{children:t.error}),s("button",{type:"button",onClick:t.retry,style:{color:r.isGlass?"#fff":r.accent,fontWeight:500,textDecoration:"underline"},children:"Retry"})]})]})}function Xe({payload:e,config:t,look:n,chat:r,shadow:o,hint:i,focus:a,onCta:u,fill:d=!1,onClose:c}){var f,h,l;const{ink:p,surfaceBg:m,hostDark:x,accentFill:v,accentText:_,rad:g}=n,y=(f=(h=e.agent)===null||h===void 0?void 0:h.name)!==null&&f!==void 0?f:null,$=y?y.trim().charAt(0).toUpperCase():"A",q=Ye(t),A=Se([r.turns,r.busy,r.error,r.stopping]),w=!!(!((l=e.agent)===null||l===void 0)&&l.live);return s("div",{class:k(t,"panel"),style:{width:"100%",borderRadius:d?0:g,overflow:"hidden",border:d?void 0:`1px solid rgba(${p},.12)`,boxShadow:o?"0 18px 44px rgba(0,0,0,.16)":void 0,background:m,...d?{flex:1,minHeight:0,display:"flex",flexDirection:"column"}:{}},children:[s("div",{class:k(t,"header"),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:v,color:_},children:[s("span",{style:{width:20,height:20,borderRadius:"50%",background:"rgba(255,255,255,.25)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,color:_},children:$}),s("span",{style:{fontSize:12,fontWeight:500},children:y?y.split("—")[0].trim():"Chat"}),s("span",{style:{marginLeft:"auto",fontSize:10,opacity:.8},children:w?"online":"offline"}),r.sessionId&&s("button",{type:"button",class:k(t,"stopButton"),onClick:r.askToStop,disabled:r.busy||!!r.stopping,"aria-label":"Stop conversation",style:{width:28,height:28,marginRight:c?0:-6,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:_,opacity:r.busy||r.stopping?.5:.9,flexShrink:0},children:s(Oe,{size:15})}),c&&s("button",{type:"button",class:k(t,"close"),onClick:c,"aria-label":"Close chat",style:{width:28,height:28,marginRight:-6,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:_,flexShrink:0},children:s(xe,{size:16})})]}),s("div",{ref:A,style:{display:"flex",flexDirection:"column",gap:7,padding:12,background:m,maxHeight:d?void 0:"min(58vh, 380px)",flex:d?1:void 0,minHeight:d?0:void 0,overflowY:"auto",overscrollBehavior:"contain"},children:s(Ve,{welcome:q,chat:r,onDark:x,look:n,config:t})}),s("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"0 12px 12px",background:m},children:[s(Kt,{config:t,look:n,onClick:u}),s(Vt,{config:t,look:n,onDark:x,hint:i,chat:r,disabled:!w,focus:a})]})]})}function ur({payload:e,look:t,api:n,embed:r,page:o,reporter:i,open:a,setOpen:u,pinned:d,focus:c}){var f;const h=e.config,l=nr(n,e,r,o),p=Nt(h),{accentFill:m,accentText:x,rad:v,side:_,offsetY:g}=t,y=rr(),$=!!(!((f=e.agent)===null||f===void 0)&&f.live),q=Ye(h),A=()=>{var I,S;return i.report("cta.clicked",{widgetId:e.id,sessionId:(I=l.sessionId)!==null&&I!==void 0?I:void 0,payload:{href:(S=h.cta)===null||S===void 0?void 0:S.href}})};if(t.isMessenger)return s(ar,{payload:e,config:h,look:t,chat:l,mobile:y,focus:c,open:a,setOpen:u,pinned:d,onCta:A});if(h.variant==="bubble")return a&&y?s(Ot,{look:t,pinned:d,onClose:()=>u(!1),children:s(Xe,{payload:e,config:h,look:t,chat:l,shadow:!1,hint:p,focus:c,onCta:A,fill:!0,onClose:d?void 0:()=>u(!1)})}):s(N,{children:[a&&s("div",{class:"uq-fixed uq-rise",style:{bottom:g+54,width:296,..._},children:s(Xe,{payload:e,config:h,look:t,chat:l,shadow:!0,hint:p,focus:c,onCta:A})}),s("button",{type:"button",class:k(h,"launcher","uq-fixed"),"aria-label":a?"Close chat":"Open chat","aria-expanded":a,onClick:()=>{a&&d||u(!a)},style:{bottom:g,width:44,height:44,borderRadius:Math.min(22,v*2),background:m,color:x,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 10px 26px rgba(0,0,0,.24)",..._},children:s(Bt,{size:20})})]});if(h.variant==="box")return s("div",{class:"uq-inline",children:s(Xe,{payload:e,config:h,look:t,chat:l,shadow:!1,hint:p,focus:c,onCta:A})});const w={payload:e,config:h,look:t,chat:l,hint:p,mobile:y,focus:c,live:$,welcome:q,onCta:A};return h.variant==="chatbar"?s(dr,{...w}):s(fr,{...w})}function dr({config:e,look:t,chat:n,hint:r,mobile:o,focus:i,live:a,welcome:u}){const{ink:d,hostDark:c,accentFill:f,accentText:h,rad:l}=t,p=Se([n.turns,n.busy,n.error,n.stopping]),m=n.turns.length>0||n.stopping!==null,x=!a||n.stopping!==null;return s("div",{class:k(e,"panel","uq-fixed"),style:{left:0,right:0,bottom:0,padding:"10px 12px",background:c?"rgba(24,27,34,.97)":"rgba(255,255,255,.97)",borderTop:`1px solid rgba(${d},.12)`,display:"flex",flexDirection:"column",gap:10,boxShadow:"0 -10px 30px rgba(0,0,0,.12)"},children:[m&&s("div",{ref:p,style:{display:"flex",flexDirection:"column",gap:7,maxHeight:"min(50vh, 320px)",overflowY:"auto"},children:s(Ve,{welcome:u,chat:n,onDark:c,look:t,config:e})}),s("div",{style:{display:"flex",alignItems:"center",gap:10},children:[s("span",{class:k(e,"launcher"),style:{width:26,height:26,borderRadius:l,background:f,color:h,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s(Bt,{size:14})}),s("span",{class:k(e,"botMessage"),style:{flex:1,minWidth:0,fontSize:12,color:`rgb(${d})`,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:u}),s("form",{class:k(e,"composer"),onSubmit:v=>{v.preventDefault();const _=v.currentTarget.elements.namedItem("message");!_||x||(n.send(_.value),_.value="")},style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,padding:"6px 8px 6px 11px",borderRadius:l,border:`1px solid rgba(${d},.14)`,minWidth:o?0:220},children:[s("input",{name:"message",type:"text",placeholder:r,disabled:x,maxLength:4e3,"aria-label":"Message",autoComplete:"off",ref:v=>{v&&i>0&&v.focus()},style:{flex:1,fontSize:11.5,color:`rgb(${d})`,"--uq-placeholder":`rgba(${d},.45)`}}),s(Gt,{config:e,look:t,onDark:c,chat:n,size:22}),s("button",{type:n.busy?"button":"submit",class:k(e,"sendButton"),onClick:n.busy?n.stop:void 0,disabled:x,"aria-label":n.busy?"Stop":"Send",style:{width:22,height:22,borderRadius:l,background:f,color:h,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n.busy?s("span",{style:{width:7,height:7,background:"currentColor",borderRadius:1}}):s(Dt,{size:12})})]})]})]})}function fr({config:e,look:t,chat:n,hint:r,mobile:o,focus:i,live:a,welcome:u,onCta:d}){const{hostDark:c,side:f,offsetY:h}=t,l=c,p=Se([n.turns,n.busy,n.error,n.stopping]);return s("div",{class:k(e,"panel","uq-fixed"),style:{bottom:h,width:o?`calc(100% - ${e.appearance.offsetX*2}px)`:320,display:"flex",flexDirection:"column",gap:7,...f},children:[s("div",{ref:p,style:{display:"flex",flexDirection:"column",gap:7,maxHeight:"min(60vh, 420px)",overflowY:"auto"},children:s(Ve,{welcome:u,chat:n,onDark:l,look:t,config:e})}),s(Kt,{config:e,look:t,onClick:d}),s(Vt,{config:e,look:t,onDark:l,hint:r,chat:n,disabled:!a,focus:i,withStop:!0})]})}var pr=e=>/^https?:\/\//i.test(e);function hr({config:e,block:t,index:n,look:r,onCta:o}){const{ink:i,accent:a,accentFill:u,accentText:d,rad:c}=r,f=["uq-block",`uq-block-${t.kind}`,t.cssClass.trim()].filter(Boolean).join(" "),h="align"in t?t.align:"center",l={class:f,"data-uq-block":n};switch(t.kind){case"headline":return s("div",{...l,style:{fontFamily:"var(--font-display, inherit)",fontSize:t.size==="lg"?21:t.size==="sm"?15:18,fontWeight:600,letterSpacing:"-0.02em",textAlign:h,color:t.color||`rgb(${i})`},children:t.text});case"text":return s("div",{...l,style:{fontSize:12.5,lineHeight:1.5,textAlign:h,color:t.color||`rgba(${i},.65)`,whiteSpace:"pre-wrap"},children:t.text});case"media":return!t.src||!pr(t.src)?null:t.mediaType==="video"?s("video",{...l,src:t.src,muted:!0,loop:!0,autoPlay:!0,playsInline:!0,style:{width:"100%",maxHeight:200,objectFit:"cover",borderRadius:c,background:"#000"}}):s("img",{...l,src:t.src,alt:t.alt||"",style:{width:"100%",maxHeight:200,objectFit:"cover",borderRadius:c}});case"quote":return s("div",{...l,style:{textAlign:"center"},children:[s("div",{style:{fontSize:13,fontStyle:"italic",color:`rgb(${i})`},children:["“",t.text,"”"]}),s("div",{style:{fontSize:11,color:`rgba(${i},.55)`,marginTop:4},children:t.author})]});case"cta":return s("a",{...l,class:`${k(e,"cta")} ${f}`,href:t.href||"#",target:t.newTab?"_blank":void 0,rel:t.newTab?"noopener noreferrer":void 0,onClick:()=>o(t.href),style:{display:"block",marginTop:4,padding:"10px 14px",borderRadius:c,background:t.style==="outline"?"transparent":u,border:t.style==="outline"?`1px solid ${a}`:void 0,color:t.style==="outline"?a:d,fontSize:13,fontWeight:500,textAlign:"center"},children:t.label})}}function _r({payload:e,look:t,reporter:n,open:r,setOpen:o,pinned:i}){const a=e.config,{ink:u,surfaceBg:d,rad:c}=t;if(!r)return null;const f=()=>{i||o(!1)},h=l=>n.report("cta.clicked",{widgetId:e.id,payload:{href:l}});return s("div",{class:k(a,"scrim","uq-fixed uq-fade"),onClick:f,style:{inset:0,background:"rgba(8,10,16,.5)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:s("div",{class:k(a,"card","uq-rise"),role:"dialog","aria-modal":"true",onClick:l=>l.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:340,maxHeight:"calc(100vh - 48px)",overflowY:"auto",background:d,borderRadius:c,padding:"22px 20px",boxShadow:"0 24px 60px rgba(0,0,0,.3)",display:"flex",flexDirection:"column",gap:10,textAlign:"center",color:`rgb(${u})`},children:[!i&&s("button",{type:"button",class:k(a,"close"),onClick:f,"aria-label":"Close",style:{position:"absolute",top:8,right:8,width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:`rgba(${u},.55)`},children:s(xe,{size:14})}),a.blocks.map((l,p)=>s(hr,{config:a,block:l,index:p,look:t,onCta:h},p))]})})}var gr=3600;function mr({payload:e,look:t,open:n}){const r=e.config,{ink:o,accent:i,surfaceBg:a,rad:u}=t,d=r.quotes,[c,f]=H(0);if(P(()=>{if(d.length<2)return;const p=window.setInterval(()=>f(m=>m+1),gr);return()=>window.clearInterval(p)},[d.length]),!n||d.length===0)return null;const h=c%d.length,l=d[h];return s("div",{class:"uq-fixed uq-fade",style:{left:0,right:0,bottom:0,display:"flex",justifyContent:"center",padding:24,pointerEvents:"none"},children:s("figure",{class:k(r,"frame"),style:{width:"100%",maxWidth:440,background:a,border:`1px solid rgba(${o},.12)`,borderLeft:`3px solid ${i}`,borderRadius:u,padding:"16px 18px",display:"flex",flexDirection:"column",gap:9,boxShadow:"0 14px 34px rgba(0,0,0,.12)",pointerEvents:"auto"},children:[s("blockquote",{class:k(r,"quote","uq-fade"),style:{fontSize:13.5,lineHeight:1.55,color:`rgb(${o})`},children:["“",l.text||"…","”"]},h),s("figcaption",{style:{display:"flex",alignItems:"center",gap:10},children:[s("span",{class:k(r,"author"),style:{fontFamily:"monospace",fontSize:11,color:`rgba(${o},.55)`},children:l.author||"—"}),s("span",{class:k(r,"dots"),style:{marginLeft:"auto",display:"flex",gap:4},children:d.map((p,m)=>s("span",{style:{width:5,height:5,borderRadius:"50%",background:m===h?i:`rgba(${o},.18)`}},m))})]})]})})}function br(e){switch(e.config.type){case"chat":case"exit-popup":return!1;case"banner":case"testimonial":return!0}}function vr(e){return e.rules.length>0||e.config.type!=="exit-popup"?e.rules:[{id:`default:${e.id}`,trigger:"exit_intent",triggerParams:{},conditions:[],once:!0,actionConfig:{open:!1,autoStart:!1,pinned:!1}}]}function Xt({payload:e,api:t,embed:n,page:r,reporter:o,hostDark:i,kick:a=null}){const u=be(()=>Wn(e.config,i),[e,i]),d=be(()=>vr(e),[e]),[c,f]=H(d.length===0),[h,l]=H(()=>d.length===0&&br(e)),[p,m]=H(!1),[x,v]=H(0),_=B(h),g=q=>{l(q),q!==_.current&&(_.current=q,o.report(q?"surface.opened":"surface.closed",{widgetId:e.id}))},y=({autoStart:q,pinned:A})=>{f(!0),m(A),g(!0),q&&v(w=>w+1)};if(P(()=>Rt(d,r,q=>{o.report("rule.fired",{widgetId:e.id,payload:{ruleId:q.id,trigger:q.trigger}}),y(q.actionConfig)}),[e.id]),P(()=>{a&&y(a.action)},[a]),!c)return null;const $={payload:e,look:u,api:t,embed:n,page:r,reporter:o,open:h,setOpen:g,pinned:p,focus:x};switch(e.config.type){case"chat":return s(ur,{...$});case"exit-popup":return s(_r,{...$});case"banner":return s(Xn,{...$});case"testimonial":return s(mr,{...$})}}function yr(e){const t=[],n=e.config.appearance.customCss.trim();return n&&t.push(n),e.config.type==="exit-popup"&&e.config.blocks.forEach((r,o)=>{const i=r.css.trim();i&&t.push(`[data-uq-widget="${e.id}"] [data-uq-block="${o}"]{${i}}`)}),t.join(`
35
+ `)}function xr(e){return e.kind==="widget"?[e.payload]:e.payload.members.map(t=>t.widget)}var wr={report:()=>{},flush:()=>{}};function Sr({group:e,...t}){const[n,r]=H(e.rules.length===0),[o,i]=H(null),[a,u]=H(()=>Pn(e));return P(()=>Rt(e.rules,t.page,d=>{t.reporter.report("rule.fired",{payload:{ruleId:d.id,trigger:d.trigger}}),r(!0),i(c=>{var f;return{action:d.actionConfig,n:((f=c==null?void 0:c.n)!==null&&f!==void 0?f:0)+1}})}),[e.id]),P(()=>{if(e.mode!=="sequence"||!n)return;const d=Pt(e);if(d)return Hn(e,d,c=>u(c?[c.widget]:[]))},[e.id,e.mode,n,a]),n?s(N,{children:a.map(d=>s("div",{"data-uq-widget":d.id,style:"display:contents",children:s(Xt,{payload:d,kick:o,...t})},d.id))}):null}function kr({snapshot:e,...t}){const n={kind:e.kind,id:e.payload.id};return e.kind==="group"?s(Sr,{group:e.payload,embed:n,...t}):s("div",{"data-uq-widget":e.payload.id,style:"display:contents",children:s(Xt,{payload:e.payload,embed:n,...t})})}function Jt(e,t,n={}){var r,o,i;const a=(r=t.shadowRoot)!==null&&r!==void 0?r:t.attachShadow({mode:"open"}),u={base:((o=n.apiUrl)!==null&&o!==void 0?o:"https://api.usereq.com").replace(/\/+$/,"")},d={kind:e.kind,id:e.payload.id},c=n.silent?wr:Mn(u,d),f=jn((i=n.theme)!==null&&i!==void 0?i:null),h=Bn(),l=document.createElement("style");a.appendChild(l);const p=document.createElement("div");p.setAttribute("data-uq-root",""),p.style.display="contents",a.appendChild(p);const m=x=>{l.textContent=[Cn,...xr(x).map(yr)].join(`
36
+ `),gt(s(kr,{snapshot:x,api:u,page:h,reporter:c,hostDark:f}),p)};return m(e),c.report("embed.loaded",{payload:{version:e.payload.version}}),{update:m,unmount:()=>{gt(null,p),c.flush(),l.remove(),p.remove()}}}function Qt(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function $r(e,t){Qt(e,t),t.add(e)}function Zt(e,t,n){Qt(e,t),t.set(e,n)}function ke(e,t,n){if(typeof e=="function"?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function $e(e,t){return e.get(ke(e,t))}function Ce(e,t,n){return e.set(ke(e,t),n),n}var Cr={widget:{element:"usereq-widget",attribute:"widget-id"},group:{element:"usereq-group",attribute:"group-id"}};function Je(e){console.warn(`[usereq] ${e}`)}function en(e){const{element:t,attribute:n}=Cr[e];if(customElements.get(t))return;var r=new WeakMap,o=new WeakMap,i=new WeakSet;class a extends HTMLElement{constructor(...c){super(...c),$r(this,i),Zt(this,r,null),Zt(this,o,0)}connectedCallback(){ke(i,this,u).call(this)}disconnectedCallback(){var c;(c=$e(r,this))===null||c===void 0||c.unmount(),Ce(r,this,null)}attributeChangedCallback(c,f,h){f!==h&&this.isConnected&&ke(i,this,u).call(this)}}async function u(){var d,c,f,h;const l=(d=this.getAttribute(n))===null||d===void 0?void 0:d.trim();if(!l)return;const p=Ce(o,this,(c=$e(o,this),++c));(f=$e(r,this))===null||f===void 0||f.unmount(),Ce(r,this,null);const m=((h=this.getAttribute("api-url"))!==null&&h!==void 0?h:"https://api.usereq.com").replace(/\/+$/,""),x=this.getAttribute("theme"),v=x==="light"||x==="dark"?x:null;let _;try{const g=await sn({base:m},e,l);_=pn(g,e)}catch(g){g instanceof G?Je(`${t} ${l}: ${g.message} (${g.code})`):Je(`${t} ${l}: could not reach ${m}.`);return}if(!(p!==$e(o,this)||!this.isConnected)){if(!_){Je(`${t} ${l}: the response was not a ${e} snapshot.`);return}Ce(r,this,Jt(_,this,{apiUrl:m,theme:v}))}}Ie(a,"observedAttributes",[n,"api-url","theme"]),customElements.define(t,a)}function qr(){en("widget"),en("group")}return qr(),qe.render=Jt,qe})({});
37
37
 
38
38
  //# sourceMappingURL=embed.js.map