@cliniq360/eigi-chat 1.8.0 → 1.8.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/dist/eigi-chat.js +1 -1
- package/package.json +1 -1
package/dist/eigi-chat.js
CHANGED
|
@@ -33,7 +33,7 @@ var Ct={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
|
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/function Rt({agentName:e,avatarUrl:t,tncEnabled:n,tncContent:r,onTalk:i,onChat:a,onClose:o,className:s}){const[l,c]=x.useState(!n||!r),[u,d]=x.useState(n&&r),f=x.useRef(null),p=x.useCallback(e=>{const t=e.target;t.scrollHeight-t.scrollTop<=t.clientHeight+20&&(c(!0),d(!1))},[]),h=x.useCallback(e=>{e&&(f.current=e,setTimeout(()=>{e.scrollHeight>e.clientHeight||(c(!0),d(!1))},100))},[]);return b.jsxs("div",{className:vt("flex flex-col h-full w-full animate-fade-in relative min-h-0",s),style:{backgroundColor:"var(--widget-background, #FFFFFF)",fontFamily:"var(--widget-font-family, system-ui)"},children:[b.jsx("button",{onClick:o,className:"absolute top-4 right-4 p-2 rounded-full hover:opacity-80 transition-opacity z-10",style:{color:"var(--widget-icon-secondary, #6B7280)"},"aria-label":"Close",children:b.jsx(Ft,{className:"h-6 w-6"})}),b.jsx("div",{ref:h,onScroll:p,className:"flex-1 min-h-0 overflow-y-auto",children:b.jsxs("div",{className:"flex flex-col items-center px-6 py-8 pt-14",children:[b.jsx(St,{src:t,alt:e,size:"2xl",className:"mb-6 shadow-lg"}),b.jsx("h1",{className:"text-2xl font-semibold mb-2 text-center",style:{color:"var(--widget-text-primary, #111827)"},children:"Welcome!"}),b.jsxs("p",{className:"text-lg mb-6 text-center",style:{color:"var(--widget-text-secondary, #6B7280)"},children:["I'm ",b.jsx("span",{className:"font-medium",children:e})]}),n&&r&&b.jsx("div",{className:"w-full max-w-md mb-6 p-4 rounded-lg",style:{backgroundColor:"var(--widget-background-secondary, #F9FAFB)",border:"1px solid var(--widget-border, #E5E7EB)"},children:b.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",style:{color:"var(--widget-text-secondary, #6B7280)"},children:r})}),n&&b.jsx("p",{className:"text-xs mb-8 text-center max-w-sm",style:{color:"var(--widget-text-muted, #9CA3AF)"},children:"By continuing, you agree to the terms above."})]})}),u&&b.jsxs("div",{className:"flex flex-col items-center py-2 pointer-events-none",style:{background:"linear-gradient(transparent, var(--widget-background, #FFFFFF) 30%)"},children:[b.jsx(Pt,{className:"h-5 w-5 animate-bounce",style:{color:"var(--widget-primary-color, #3B82F6)"}}),b.jsx("span",{className:"text-xs",style:{color:"var(--widget-primary-color, #3B82F6)"},children:"Scroll to continue"})]}),b.jsx("div",{className:"p-6 pb-safe shrink-0",style:{borderTop:"1px solid var(--widget-border, #E5E7EB)",paddingBottom:"max(1.5rem, env(safe-area-inset-bottom, 0px))"},children:b.jsxs("div",{className:"flex gap-4 max-w-md mx-auto",children:[b.jsxs(kt,{onClick:i,variant:"default",size:"xl",className:"flex-1",disabled:!l,children:[b.jsx(Lt,{className:"h-5 w-5"}),"Talk"]}),b.jsxs(kt,{onClick:a,variant:"secondary",size:"xl",className:"flex-1",disabled:!l,children:[b.jsx(Ot,{className:"h-5 w-5"}),"Chat"]})]})})]})}function Dt(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Bt(...e){return t=>{let n=!1;const r=e.map(e=>{const r=Dt(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():Dt(e[t],null)}}}}function zt(...e){return x.useCallback(Bt(...e),e)}function Ut(e){const t=Vt(e),n=x.forwardRef((e,n)=>{const r=e,{children:i}=r,a=u(r,["children"]),o=x.Children.toArray(i),s=o.find(Wt);if(s){const e=s.props.children,r=o.map(t=>t===s?x.Children.count(e)>1?x.Children.only(null):x.isValidElement(e)?e.props.children:null:t);return b.jsx(t,c(l({},a),{ref:n,children:x.isValidElement(e)?x.cloneElement(e,void 0,r):null}))}return b.jsx(t,c(l({},a),{ref:n,children:i}))});return n.displayName=`${e}.Slot`,n}function Vt(e){const t=x.forwardRef((e,t)=>{const n=e,{children:r}=n,i=u(n,["children"]);if(x.isValidElement(r)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,i=r&&"isReactWarning"in r&&r.isReactWarning;if(i)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,i=r&&"isReactWarning"in r&&r.isReactWarning,i)return e.props.ref;return e.props.ref||e.ref}(r),n=function(e,t){const n=l({},t);for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{const t=a(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]=l(l({},i),a):"className"===r&&(n[r]=[i,a].filter(Boolean).join(" "))}return l(l({},e),n)}(i,r.props);return r.type!==x.Fragment&&(n.ref=t?Bt(t,e):e),x.cloneElement(r,n)}return x.Children.count(r)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}z();var $t=Symbol("radix.slottable");function Wt(e){return x.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===$t}var qt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=Ut(`Primitive.${t}`),r=x.forwardRef((e,r)=>{const i=e,{asChild:a}=i,o=u(i,["asChild"]),s=a?n:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b.jsx(s,c(l({},o),{ref:r}))});return r.displayName=`Primitive.${t}`,c(l({},e),{[t]:r})},{}),Ht=(null==globalThis?void 0:globalThis.document)?x.useLayoutEffect:()=>{};var Jt=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=x.useState(),r=x.useRef(null),i=x.useRef(e),a=x.useRef("none"),o=e?"mounted":"unmounted",[s,l]=function(e,t){return x.useReducer((e,n)=>{const r=t[e][n];return null!=r?r:e},e)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const e=Qt(r.current);a.current="mounted"===s?e:"none"},[s]),Ht(()=>{const t=r.current,n=i.current;if(n!==e){const r=a.current,o=Qt(t);if(e)l("MOUNT");else if("none"===o||"none"===(null==t?void 0:t.display))l("UNMOUNT");else{l(n&&r!==o?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,l]),Ht(()=>{var e;if(t){let n;const o=null!=(e=t.ownerDocument.defaultView)?e:window,s=e=>{const a=Qt(r.current).includes(CSS.escape(e.animationName));if(e.target===t&&a&&(l("ANIMATION_END"),!i.current)){const e=t.style.animationFillMode;t.style.animationFillMode="forwards",n=o.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=e)})}},c=e=>{e.target===t&&(a.current=Qt(r.current))};return t.addEventListener("animationstart",c),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{o.clearTimeout(n),t.removeEventListener("animationstart",c),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:x.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):x.Children.only(n),a=zt(r.ref,function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,i=r&&"isReactWarning"in r&&r.isReactWarning;if(i)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,i=r&&"isReactWarning"in r&&r.isReactWarning,i)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||r.isPresent?x.cloneElement(i,{ref:a}):null};function Qt(e){return(null==e?void 0:e.animationName)||"none"}function Gt(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>{const i=n(e)[`__scope${r}`];return l(l({},t),i)},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function Yt(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e}),x.useMemo(()=>(...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)},[])}Jt.displayName="Presence";var Kt=x.createContext(void 0);function Xt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(null==e||e(r),!1===n||!r.defaultPrevented)return null==t?void 0:t(r)}}var Zt="ScrollArea",[en]=function(e,t=[]){let n=[];const r=()=>{const t=n.map(e=>x.createContext(e));return function(n){const r=(null==n?void 0:n[e])||t;return x.useMemo(()=>({[`__scope${e}`]:c(l({},n),{[e]:r})}),[n,r])}};return r.scopeName=e,[function(t,r){const i=x.createContext(r),a=n.length;n=[...n,r];const o=t=>{var n;const r=t,{scope:o,children:s}=r,l=u(r,["scope","children"]),c=(null==(n=null==o?void 0:o[e])?void 0:n[a])||i,d=x.useMemo(()=>l,Object.values(l));return b.jsx(c.Provider,{value:d,children:s})};return o.displayName=t+"Provider",[o,function(n,o){var s;const l=(null==(s=null==o?void 0:o[e])?void 0:s[a])||i,c=x.useContext(l);if(c)return c;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},Gt(r,...t)]}(Zt),[tn,nn]=en(Zt),rn=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r,type:i="hover",dir:a,scrollHideDelay:o=600}=n,s=u(n,["__scopeScrollArea","type","dir","scrollHideDelay"]),[d,f]=x.useState(null),[p,h]=x.useState(null),[m,g]=x.useState(null),[v,y]=x.useState(null),[w,k]=x.useState(null),[S,_]=x.useState(0),[C,E]=x.useState(0),[T,M]=x.useState(!1),[P,A]=x.useState(!1),O=zt(t,e=>f(e)),N=function(e){const t=x.useContext(Kt);return e||t||"ltr"}(a);return b.jsx(tn,{scope:r,type:i,dir:N,scrollHideDelay:o,scrollArea:d,viewport:p,onViewportChange:h,content:m,onContentChange:g,scrollbarX:v,onScrollbarXChange:y,scrollbarXEnabled:T,onScrollbarXEnabledChange:M,scrollbarY:w,onScrollbarYChange:k,scrollbarYEnabled:P,onScrollbarYEnabledChange:A,onCornerWidthChange:_,onCornerHeightChange:E,children:b.jsx(qt.div,c(l({dir:N},s),{ref:O,style:l({position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":C+"px"},e.style)}))})});rn.displayName=Zt;var an="ScrollAreaViewport",on=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r,children:i,nonce:a}=n,o=u(n,["__scopeScrollArea","children","nonce"]),s=nn(an,r),d=zt(t,x.useRef(null),s.onViewportChange);return b.jsxs(b.Fragment,{children:[b.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),b.jsx(qt.div,c(l({"data-radix-scroll-area-viewport":""},o),{ref:d,style:l({overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden"},e.style),children:b.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:i})}))]})});on.displayName=an;var sn="ScrollAreaScrollbar",ln=x.forwardRef((e,t)=>{const n=e,{forceMount:r}=n,i=u(n,["forceMount"]),a=nn(sn,e.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:s}=a,d="horizontal"===e.orientation;return x.useEffect(()=>(d?o(!0):s(!0),()=>{d?o(!1):s(!1)}),[d,o,s]),"hover"===a.type?b.jsx(cn,c(l({},i),{ref:t,forceMount:r})):"scroll"===a.type?b.jsx(un,c(l({},i),{ref:t,forceMount:r})):"auto"===a.type?b.jsx(dn,c(l({},i),{ref:t,forceMount:r})):"always"===a.type?b.jsx(fn,c(l({},i),{ref:t})):null});ln.displayName=sn;var cn=x.forwardRef((e,t)=>{const n=e,{forceMount:r}=n,i=u(n,["forceMount"]),a=nn(sn,e.__scopeScrollArea),[o,s]=x.useState(!1);return x.useEffect(()=>{const e=a.scrollArea;let t=0;if(e){const n=()=>{window.clearTimeout(t),s(!0)},r=()=>{t=window.setTimeout(()=>s(!1),a.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",r),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",r)}}},[a.scrollArea,a.scrollHideDelay]),b.jsx(Jt,{present:r||o,children:b.jsx(dn,c(l({"data-state":o?"visible":"hidden"},i),{ref:t}))})}),un=x.forwardRef((e,t)=>{const n=e,{forceMount:r}=n,i=u(n,["forceMount"]),a=nn(sn,e.__scopeScrollArea),o="horizontal"===e.orientation,s=On(()=>f("SCROLL_END"),100),[d,f]=(p="hidden",h={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},x.useReducer((e,t)=>{const n=h[e][t];return null!=n?n:e},p));var p,h;return x.useEffect(()=>{if("idle"===d){const e=window.setTimeout(()=>f("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[d,a.scrollHideDelay,f]),x.useEffect(()=>{const e=a.viewport,t=o?"scrollLeft":"scrollTop";if(e){let n=e[t];const r=()=>{const r=e[t];n!==r&&(f("SCROLL"),s()),n=r};return e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[a.viewport,o,f,s]),b.jsx(Jt,{present:r||"hidden"!==d,children:b.jsx(fn,c(l({"data-state":"hidden"===d?"hidden":"visible"},i),{ref:t,onPointerEnter:Xt(e.onPointerEnter,()=>f("POINTER_ENTER")),onPointerLeave:Xt(e.onPointerLeave,()=>f("POINTER_LEAVE"))}))})}),dn=x.forwardRef((e,t)=>{const n=nn(sn,e.__scopeScrollArea),r=e,{forceMount:i}=r,a=u(r,["forceMount"]),[o,s]=x.useState(!1),d="horizontal"===e.orientation,f=On(()=>{if(n.viewport){const e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;s(d?e:t)}},10);return Nn(n.viewport,f),Nn(n.content,f),b.jsx(Jt,{present:i||o,children:b.jsx(fn,c(l({"data-state":o?"visible":"hidden"},a),{ref:t}))})}),fn=x.forwardRef((e,t)=>{const n=e,{orientation:r="vertical"}=n,i=u(n,["orientation"]),a=nn(sn,e.__scopeScrollArea),o=x.useRef(null),s=x.useRef(0),[d,f]=x.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),p=Cn(d.viewport,d.content),h=c(l({},i),{sizes:d,onSizesChange:f,hasThumb:Boolean(p>0&&p<1),onThumbChange:e=>o.current=e,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:e=>s.current=e});function m(e,t){return function(e,t,n,r="ltr"){const i=En(n),a=i/2,o=t||a,s=i-o,l=n.scrollbar.paddingStart+o,c=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d="ltr"===r?[0,u]:[-1*u,0];return Mn([l,c],d)(e)}(e,s.current,d,t)}return"horizontal"===r?b.jsx(pn,c(l({},h),{ref:t,onThumbPositionChange:()=>{if(a.viewport&&o.current){const e=Tn(a.viewport.scrollLeft,d,a.dir);o.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{a.viewport&&(a.viewport.scrollLeft=e)},onDragScroll:e=>{a.viewport&&(a.viewport.scrollLeft=m(e,a.dir))}})):"vertical"===r?b.jsx(hn,c(l({},h),{ref:t,onThumbPositionChange:()=>{if(a.viewport&&o.current){const e=Tn(a.viewport.scrollTop,d);o.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{a.viewport&&(a.viewport.scrollTop=e)},onDragScroll:e=>{a.viewport&&(a.viewport.scrollTop=m(e))}})):null}),pn=x.forwardRef((e,t)=>{const n=e,{sizes:r,onSizesChange:i}=n,a=u(n,["sizes","onSizesChange"]),o=nn(sn,e.__scopeScrollArea),[s,d]=x.useState(),f=x.useRef(null),p=zt(t,f,o.onScrollbarXChange);return x.useEffect(()=>{f.current&&d(getComputedStyle(f.current))},[f]),b.jsx(vn,c(l({"data-orientation":"horizontal"},a),{ref:p,sizes:r,style:l({bottom:0,left:"rtl"===o.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===o.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":En(r)+"px"},e.style),onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(o.viewport){const r=o.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Pn(r,n)&&t.preventDefault()}},onResize:()=>{f.current&&o.viewport&&s&&i({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:f.current.clientWidth,paddingStart:xn(s.paddingLeft),paddingEnd:xn(s.paddingRight)}})}}))}),hn=x.forwardRef((e,t)=>{const n=e,{sizes:r,onSizesChange:i}=n,a=u(n,["sizes","onSizesChange"]),o=nn(sn,e.__scopeScrollArea),[s,d]=x.useState(),f=x.useRef(null),p=zt(t,f,o.onScrollbarYChange);return x.useEffect(()=>{f.current&&d(getComputedStyle(f.current))},[f]),b.jsx(vn,c(l({"data-orientation":"vertical"},a),{ref:p,sizes:r,style:l({top:0,right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":En(r)+"px"},e.style),onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(o.viewport){const r=o.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Pn(r,n)&&t.preventDefault()}},onResize:()=>{f.current&&o.viewport&&s&&i({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:f.current.clientHeight,paddingStart:xn(s.paddingTop),paddingEnd:xn(s.paddingBottom)}})}}))}),[mn,gn]=en(sn),vn=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r,sizes:i,hasThumb:a,onThumbChange:o,onThumbPointerUp:s,onThumbPointerDown:d,onThumbPositionChange:f,onDragScroll:p,onWheelScroll:h,onResize:m}=n,g=u(n,["__scopeScrollArea","sizes","hasThumb","onThumbChange","onThumbPointerUp","onThumbPointerDown","onThumbPositionChange","onDragScroll","onWheelScroll","onResize"]),v=nn(sn,r),[y,w]=x.useState(null),k=zt(t,e=>w(e)),S=x.useRef(null),_=x.useRef(""),C=v.viewport,E=i.content-i.viewport,T=Yt(h),M=Yt(f),P=On(m,10);function A(e){if(S.current){const t=e.clientX-S.current.left,n=e.clientY-S.current.top;p({x:t,y:n})}}return x.useEffect(()=>{const e=e=>{const t=e.target;(null==y?void 0:y.contains(t))&&T(e,E)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[C,y,E,T]),x.useEffect(M,[i,M]),Nn(y,P),Nn(v.content,P),b.jsx(mn,{scope:r,scrollbar:y,hasThumb:a,onThumbChange:Yt(o),onThumbPointerUp:Yt(s),onThumbPositionChange:M,onThumbPointerDown:Yt(d),children:b.jsx(qt.div,c(l({},g),{ref:k,style:l({position:"absolute"},g.style),onPointerDown:Xt(e.onPointerDown,e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),S.current=y.getBoundingClientRect(),_.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),A(e)}}),onPointerMove:Xt(e.onPointerMove,A),onPointerUp:Xt(e.onPointerUp,e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=_.current,v.viewport&&(v.viewport.style.scrollBehavior=""),S.current=null})}))})}),yn="ScrollAreaThumb",bn=x.forwardRef((e,t)=>{const n=e,{forceMount:r}=n,i=u(n,["forceMount"]),a=gn(yn,e.__scopeScrollArea);return b.jsx(Jt,{present:r||a.hasThumb,children:b.jsx(wn,l({ref:t},i))})}),wn=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r,style:i}=n,a=u(n,["__scopeScrollArea","style"]),o=nn(yn,r),s=gn(yn,r),{onThumbPositionChange:d}=s,f=zt(t,e=>s.onThumbChange(e)),p=x.useRef(void 0),h=On(()=>{p.current&&(p.current(),p.current=void 0)},100);return x.useEffect(()=>{const e=o.viewport;if(e){const t=()=>{if(h(),!p.current){const t=An(e,d);p.current=t,d()}};return d(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[o.viewport,h,d]),b.jsx(qt.div,c(l({"data-state":s.hasThumb?"visible":"hidden"},a),{ref:f,style:l({width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)"},i),onPointerDownCapture:Xt(e.onPointerDownCapture,e=>{const t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;s.onThumbPointerDown({x:n,y:r})}),onPointerUp:Xt(e.onPointerUp,s.onThumbPointerUp)}))});bn.displayName=yn;var kn="ScrollAreaCorner",Sn=x.forwardRef((e,t)=>{const n=nn(kn,e.__scopeScrollArea),r=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&r?b.jsx(_n,c(l({},e),{ref:t})):null});Sn.displayName=kn;var _n=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r}=n,i=u(n,["__scopeScrollArea"]),a=nn(kn,r),[o,s]=x.useState(0),[d,f]=x.useState(0),p=Boolean(o&&d);return Nn(a.scrollbarX,()=>{var e;const t=(null==(e=a.scrollbarX)?void 0:e.offsetHeight)||0;a.onCornerHeightChange(t),f(t)}),Nn(a.scrollbarY,()=>{var e;const t=(null==(e=a.scrollbarY)?void 0:e.offsetWidth)||0;a.onCornerWidthChange(t),s(t)}),p?b.jsx(qt.div,c(l({},i),{ref:t,style:l({width:o,height:d,position:"absolute",right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:0},e.style)})):null});function xn(e){return e?parseInt(e,10):0}function Cn(e,t){const n=e/t;return isNaN(n)?0:n}function En(e){const t=Cn(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Tn(e,t,n="ltr"){const r=En(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,l=function(e,[t,n]){return Math.min(n,Math.max(t,e))}(e,"ltr"===n?[0,o]:[-1*o,0]);return Mn([0,o],[0,s])(l)}function Mn(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Pn(e,t){return e>0&&e<t}var An=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function i(){const a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(r)};function On(e,t){const n=Yt(e),r=x.useRef(0);return x.useEffect(()=>()=>window.clearTimeout(r.current),[]),x.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Nn(e,t){const n=Yt(t);Ht(()=>{let t=0;if(e){const r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var Ln=rn,jn=on,In=Sn;const Fn=x.forwardRef((e,t)=>{var n=e,{className:r,children:i}=n,a=u(n,["className","children"]);return b.jsxs(Ln,c(l({ref:t,className:vt("relative overflow-hidden",r)},a),{children:[b.jsx(jn,{className:"h-full w-full rounded-[inherit]",children:i}),b.jsx(Rn,{}),b.jsx(In,{})]}))});Fn.displayName=Ln.displayName;const Rn=x.forwardRef((e,t)=>{var n=e,{className:r,orientation:i="vertical"}=n,a=u(n,["className","orientation"]);return b.jsx(ln,c(l({ref:t,orientation:i,className:vt("flex touch-none select-none transition-colors","vertical"===i&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===i&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",r)},a),{children:b.jsx(bn,{className:"relative flex-1 rounded-full",style:{backgroundColor:"var(--widget-border, #E5E7EB)"}})}))});function Dn({messages:e,streamingContent:t,isStreaming:n,className:r}){const i=x.useRef(null);return x.useEffect(()=>{var e;null==(e=i.current)||e.scrollIntoView({behavior:"smooth"})},[e,t]),b.jsx(Fn,{className:vt("flex-1 px-4",r),children:b.jsxs("div",{className:"py-4 space-y-4",children:[e.map(e=>b.jsx(Bn,{message:e},e.id)),n&&t&&b.jsx(Bn,{message:{type:"assistant",text:t,isStreaming:!0}}),b.jsx("div",{ref:i})]})})}function Bn({message:e}){const t="user"===e.type;e.type;const n="system"===e.type;return"separator"===e.type?b.jsx("div",{className:"flex items-center justify-center py-2",children:b.jsx("div",{className:"px-3 py-1 rounded-full text-xs",style:{backgroundColor:"var(--widget-system-message-bg, #F3F4F6)",color:"var(--widget-system-message-text, #6B7280)"},children:e.text})}):n?b.jsx("div",{className:"flex justify-center",children:b.jsx("div",{className:"max-w-[85%] px-4 py-2 rounded-lg text-sm",style:{backgroundColor:"var(--widget-system-message-bg, #FEF3C7)",color:"var(--widget-system-message-text, #92400E)"},children:e.text})}):b.jsx("div",{className:vt("flex",t?"justify-end":"justify-start"),children:b.jsxs("div",{className:vt("max-w-[85%] px-4 py-3 rounded-2xl text-sm leading-relaxed",t?"rounded-br-md":"rounded-bl-md",e.isTranscript&&"italic opacity-80"),style:{backgroundColor:t?"var(--widget-user-message-bg, #3B82F6)":"var(--widget-bot-message-bg, #F3F4F6)",color:t?"var(--widget-user-message-text, #FFFFFF)":"var(--widget-bot-message-text, #111827)"},children:[e.text,e.isStreaming&&b.jsx("span",{className:"inline-block w-2 h-4 ml-1 animate-pulse bg-current opacity-50"})]})})}function zn({onSend:e,disabled:t,placeholder:n="Type a message...",className:r}){const[i,a]=x.useState(""),o=x.useRef(null),s=n=>{var r;n.preventDefault(),i.trim()&&!t&&(e(i.trim()),a(""),null==(r=o.current)||r.focus())};return b.jsxs("form",{onSubmit:s,className:vt("flex items-center gap-2 p-4 pb-safe shrink-0",r),style:{borderTop:"1px solid var(--widget-border, #E5E7EB)",backgroundColor:"var(--widget-background, #FFFFFF)",paddingBottom:"max(1rem, env(safe-area-inset-bottom, 0px))"},children:[b.jsx("input",{ref:o,type:"text",value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),s(e))},placeholder:n,disabled:t,className:"flex-1 h-11 px-4 rounded-full outline-none transition-all",style:{backgroundColor:"var(--widget-input-bg, #F9FAFB)",color:"var(--widget-input-text, #111827)",border:"1px solid var(--widget-input-border, #E5E7EB)",fontFamily:"var(--widget-font-family, inherit)",fontSize:"var(--widget-font-size-base, 14px)"}}),b.jsx(kt,{type:"submit",variant:"default",size:"icon",disabled:!i.trim()||t,className:"shrink-0 rounded-full h-11 w-11",children:b.jsx(It,{className:"h-5 w-5"})})]})}function Un(e,t,n={}){const{chatSession:r,messages:i,isChatInitialized:a,isStreaming:o,streamingContent:s,setChatSession:u,addMessage:f,setStreaming:p}=H(),h=x.useRef(null),m=x.useRef(null),g=x.useRef(!1),v=x.useCallback(()=>d(null,null,function*(){if(!g.current&&!a&&e&&t){g.current=!0;try{const r=yield function(e,t){return d(this,arguments,function*(e,t,n={}){const r=`${Q}/v1/widgets/chat/sessions`,i=yield fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-Prompt-Token":t},body:JSON.stringify({agent_id:e,conversation_metadata:n})});if(!i.ok){const e=yield i.json().catch(()=>({}));throw new Error(e.detail||e.message||`HTTP ${i.status}`)}const a=yield i.json();return a.session_id,a})}(e,t,n);u(r),m.current=r.session_id,r.first_message&&f({type:"assistant",text:r.first_message,isTranscript:!1})}catch(r){f({type:"system",text:`Error: ${r.message}`})}}}),[e,t,n,a,u,f]),y=x.useCallback(i=>d(null,null,function*(){if(i.trim()&&!o){f({type:"user",text:i,isTranscript:!1});try{h.current=new AbortController,p(!0,""),m.current,i.substring(0,50);const a=yield function(e,t,n,r,i){return d(this,null,function*(){const a=`${Q}/v1/widgets/chat/messages`;n.substring(0,50);const o=yield fetch(a,{method:"POST",headers:{"Content-Type":"application/json","X-Prompt-Token":i},body:JSON.stringify({agent_id:e,session_id:t,message:n,metadata:r})});if(!o.ok){const e=yield o.text();throw new Error(`Server error (${o.status}): ${e||"Unknown error"}`)}return{response:o,sessionId:o.headers.get("X-Session-ID")}})}(e,m.current||(null==r?void 0:r.session_id),i,c(l({},n),{agent_id:e}),t);a.sessionId&&(m.current=a.sessionId);const o=a.response.body.getReader(),s=new TextDecoder;let u="";try{for(;;){const{done:e,value:t}=yield o.read();if(e)break;u+=s.decode(t,{stream:!0}),p(!0,u)}}finally{o.releaseLock()}u.trim()&&f({type:"assistant",text:u,isTranscript:!1}),p(!1,"")}catch(a){"AbortError"!==a.name&&f({type:"system",text:`Error: ${a.message}`}),p(!1,"")}}}),[e,t,r,n,o,f,p]),b=x.useCallback(()=>{h.current&&(h.current.abort(),p(!1,""))},[p]);return{messages:i,isStreaming:o,streamingContent:s,isInitialized:a,initializeChat:v,sendMessage:y,cancelStream:b}}function Vn({agentId:e,agentName:t,promptToken:n,metadata:r,onClose:i,onSwitchToTalk:a,className:o}){const{messages:s,isStreaming:l,streamingContent:c,isInitialized:u,initializeChat:d,sendMessage:f}=Un(e,n,r);return x.useEffect(()=>{!u&&n&&d()},[u,n,d]),b.jsxs("div",{className:vt("flex flex-col h-full w-full animate-fade-in",o),style:{backgroundColor:"var(--widget-background, #FFFFFF)",fontFamily:"var(--widget-font-family, system-ui)"},children:[b.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{backgroundColor:"var(--widget-header-bg, #F9FAFB)",borderBottom:"1px solid var(--widget-header-border, #E5E7EB)"},children:[b.jsx("button",{onClick:i,className:"p-2 rounded-full hover:opacity-80 transition-opacity",style:{color:"var(--widget-icon-secondary, #6B7280)"},"aria-label":"Close",children:b.jsx(Ft,{className:"h-5 w-5"})}),b.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--widget-header-text, #111827)"},children:t}),b.jsx(kt,{onClick:a,variant:"ghost",size:"icon-sm",className:"rounded-full",title:"Switch to voice",children:b.jsx(Lt,{className:"h-5 w-5",style:{color:"var(--widget-icon-active, #3B82F6)"}})})]}),b.jsx(Dn,{messages:s,streamingContent:c,isStreaming:l,className:"flex-1"}),b.jsx(zn,{onSend:f,disabled:l,placeholder:"Type a message..."})]})}Rn.displayName=ln.displayName;const $n={sm:48,md:80,lg:120,xl:160,"2xl":200},Wn=x.forwardRef((e,t)=>{var n=e,{children:r,loading:i=!0,size:a="lg",strokeWidth:o=4,gap:s=8,trackColor:d,spinnerColor:f,duration:p=1.5,className:h}=n,m=u(n,["children","loading","size","strokeWidth","gap","trackColor","spinnerColor","duration","className"]);const g="string"==typeof a?$n[a]||120:a,v=(g-o)/2,y=2*Math.PI*v,w=g/2,k=g-2*s-2*o,S=x.useId(),_=`\n @keyframes loader-spin-${S.replace(/:/g,"")} {\n 0% {\n transform: rotate(-90deg);\n }\n 100% {\n transform: rotate(270deg);\n }\n }\n \n @keyframes loader-dash-${S.replace(/:/g,"")} {\n 0% {\n stroke-dashoffset: ${y};\n }\n 50% {\n stroke-dashoffset: ${.25*y};\n }\n 100% {\n stroke-dashoffset: ${y};\n }\n }\n `;return b.jsxs("div",c(l({ref:t,className:vt("relative inline-flex items-center justify-center",h),style:{width:g,height:g}},m),{children:[i&&b.jsx("style",{children:_}),i&&b.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${g} ${g}`,"aria-hidden":"true",children:[b.jsx("circle",{cx:w,cy:w,r:v,fill:"none",stroke:d||"var(--widget-border, #E5E7EB)",strokeWidth:o}),b.jsx("circle",{cx:w,cy:w,r:v,fill:"none",stroke:f||"var(--widget-primary-color, #3B82F6)",strokeWidth:o,strokeLinecap:"round",strokeDasharray:y,strokeDashoffset:.25*y,style:{transformOrigin:"center",animation:`loader-spin-${S.replace(/:/g,"")} ${p}s linear infinite, loader-dash-${S.replace(/:/g,"")} ${1.33*p}s ease-in-out infinite`}})]}),b.jsx("div",{className:"relative z-10 flex items-center justify-center overflow-hidden rounded-full",style:{width:k,height:k},children:r})]}))});Wn.displayName="Loader";x.forwardRef((e,t)=>{var n=e,{size:r="md",strokeWidth:i=3,color:a,trackColor:o,duration:s=1,className:d}=n,f=u(n,["size","strokeWidth","color","trackColor","duration","className"]);const p="string"==typeof r?{xs:16,sm:20,md:24,lg:32,xl:40}[r]||24:r,h=(p-i)/2,m=2*Math.PI*h,g=p/2,v=x.useId(),y=`\n @keyframes simple-spin-${v.replace(/:/g,"")} {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n `;return b.jsxs("span",c(l({ref:t,className:vt("inline-flex items-center justify-center",d),role:"status","aria-label":"Loading"},f),{children:[b.jsx("style",{children:y}),b.jsxs("svg",{width:p,height:p,viewBox:`0 0 ${p} ${p}`,fill:"none",style:{animation:`simple-spin-${v.replace(/:/g,"")} ${s}s linear infinite`},children:[o&&b.jsx("circle",{cx:g,cy:g,r:h,stroke:o,strokeWidth:i,fill:"none",opacity:.25}),b.jsx("circle",{cx:g,cy:g,r:h,stroke:a||"var(--widget-primary-color, #3B82F6)",strokeWidth:i,strokeLinecap:"round",fill:"none",strokeDasharray:m,strokeDashoffset:.75*m})]}),b.jsx("span",{className:"sr-only",children:"Loading..."})]}))}).displayName="SpinnerLoader";function qn(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Hn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Jn(e){return(Jn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Qn(e){var t=function(e){if("object"!=Jn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Jn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Jn(t)?t:t+""}function Gn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Qn(r.key),r)}}function Yn(e,t,n){return t&&Gn(e.prototype,t),n&&Gn(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Kn(e,t){if(t&&("object"==Jn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Xn(e){return(Xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Zn(e,t){return(Zn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function er(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Zn(e,t)}function tr(e,t,n){return(t=Qn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nr(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(c){return void n(c)}s.done?t(l):Promise.resolve(l).then(r,i)}function rr(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){nr(a,r,i,o,s,"next",e)}function s(e){nr(a,r,i,o,s,"throw",e)}o(void 0)})}}function ir(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ar(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ir(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ir(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}x.forwardRef((e,t)=>{var n=e,{dotSize:r=8,gap:i=6,color:a,duration:o=1.4,className:s}=n,d=u(n,["dotSize","gap","color","duration","className"]);const f=x.useId(),p=`\n @keyframes dots-bounce-${f.replace(/:/g,"")} {\n 0%, 80%, 100% {\n transform: scale(0.6);\n opacity: 0.5;\n }\n 40% {\n transform: scale(1);\n opacity: 1;\n }\n }\n `;return b.jsxs("span",c(l({ref:t,className:vt("inline-flex items-center",s),style:{gap:i},role:"status","aria-label":"Loading"},d),{children:[b.jsx("style",{children:p}),[0,1,2].map(e=>b.jsx("span",{style:{width:r,height:r,borderRadius:"50%",backgroundColor:a||"var(--widget-primary-color, #3B82F6)",animation:`dots-bounce-${f.replace(/:/g,"")} ${o}s ease-in-out infinite`,animationDelay:e*(o/3)+"s"}},e)),b.jsx("span",{className:"sr-only",children:"Loading..."})]}))}).displayName="DotsLoader";var or,sr,lr={exports:{}},cr=function(){if(or)return lr.exports;or=1;var e,t="object"==typeof Reflect?Reflect:null,n=t&&"function"==typeof t.apply?t.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}lr.exports=i,lr.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}var o,s;h(e,t,a,{once:!0}),"error"!==t&&(s=i,"function"==typeof(o=e).on&&h(o,"error",s,{once:!0}))})},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function o(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function s(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var i,a,l,c;if(o(n),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),l=a[t]),void 0===l)l=a[t]=n,++e._eventsCount;else if("function"==typeof l?l=a[t]=r?[n,l]:[l,n]:r?l.unshift(n):l.push(n),(i=s(e))>0&&l.length>i&&!l.warned){l.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=l.length,c=u,console&&console.warn&&console.warn(c)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=c.bind(r);return i.listener=n,r.wrapFn=i,i}function d(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):p(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function h(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)})}}return Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return s(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var l=a[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var c=l.length,u=p(l,c);for(r=0;r<c;++r)n(u[r],this,t)}return!0},i.prototype.addListener=function(e,t){return l(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return l(this,e,t,!0)},i.prototype.once=function(e,t){return o(t),this.on(e,u(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return o(t),this.prependListener(e,u(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,r,i,a,s;if(o(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){s=n[a].listener,i=a;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,a=Object.keys(n);for(r=0;r<a.length;++r)"removeListener"!==(i=a[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},i.prototype.listeners=function(e){return d(this,e,!0)},i.prototype.rawListeners=function(e){return d(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},lr.exports}(),ur=(sr=cr)&&sr.__esModule&&Object.prototype.hasOwnProperty.call(sr,"default")?sr.default:sr,dr=Object.prototype.hasOwnProperty;function fr(e,t,n){for(n of e.keys())if(pr(n,t))return n}function pr(e,t){var n,r,i;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&pr(e[r],t[r]););return-1===r}if(n===Set){if(e.size!==t.size)return!1;for(r of e){if((i=r)&&"object"==typeof i&&!(i=fr(t,i)))return!1;if(!t.has(i))return!1}return!0}if(n===Map){if(e.size!==t.size)return!1;for(r of e){if((i=r[0])&&"object"==typeof i&&!(i=fr(t,i)))return!1;if(!pr(r[1],t.get(i)))return!1}return!0}if(n===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(n===DataView){if((r=e.byteLength)===t.byteLength)for(;r--&&e.getInt8(r)===t.getInt8(r););return-1===r}if(ArrayBuffer.isView(e)){if((r=e.byteLength)===t.byteLength)for(;r--&&e[r]===t[r];);return-1===r}if(!n||"object"==typeof e){for(n in r=0,e){if(dr.call(e,n)&&++r&&!dr.call(t,n))return!1;if(!(n in t)||!pr(e[n],t[n]))return!1}return Object.keys(t).length===r}}return e!=e&&t!=t}const hr={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},mr={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},gr={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},vr={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},yr={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class br{static getFirstMatch(e,t){const n=t.match(e);return n&&n.length>0&&n[1]||""}static getSecondMatch(e,t){const n=t.match(e);return n&&n.length>1&&n[2]||""}static matchAndReturnConst(e,t,n){if(e.test(t))return n}static getWindowsVersionName(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}static getMacOSVersionName(e){const t=e.split(".").splice(0,2).map(e=>parseInt(e,10)||0);if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}}static getAndroidVersionName(e){const t=e.split(".").splice(0,2).map(e=>parseInt(e,10)||0);if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0}static getVersionPrecision(e){return e.split(".").length}static compareVersions(e,t,n=!1){const r=br.getVersionPrecision(e),i=br.getVersionPrecision(t);let a=Math.max(r,i),o=0;const s=br.map([e,t],e=>{const t=a-br.getVersionPrecision(e),n=e+new Array(t+1).join(".0");return br.map(n.split("."),e=>new Array(20-e.length).join("0")+e).reverse()});for(n&&(o=a-Math.min(r,i)),a-=1;a>=o;){if(s[0][a]>s[1][a])return 1;if(s[0][a]===s[1][a]){if(a===o)return 0;a-=1}else if(s[0][a]<s[1][a])return-1}}static map(e,t){const n=[];let r;if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n}static find(e,t){let n,r;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(n=0,r=e.length;n<r;n+=1){const r=e[n];if(t(r,n))return r}}static assign(e,...t){const n=e;let r,i;if(Object.assign)return Object.assign(e,...t);for(r=0,i=t.length;r<i;r+=1){const e=t[r];"object"==typeof e&&null!==e&&Object.keys(e).forEach(t=>{n[t]=e[t]})}return e}static getBrowserAlias(e){return hr[e]}static getBrowserTypeByAlias(e){return mr[e]||""}}const wr=/version\/(\d+(\.?_?\d+)+)/i,kr=[{test:[/googlebot/i],describe(e){const t={name:"Googlebot"},n=br.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/opera/i],describe(e){const t={name:"Opera"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe(e){const t={name:"Opera"},n=br.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe(e){const t={name:"Samsung Internet for Android"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe(e){const t={name:"NAVER Whale Browser"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe(e){const t={name:"MZ Browser"},n=br.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/focus/i],describe(e){const t={name:"Focus"},n=br.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/swing/i],describe(e){const t={name:"Swing"},n=br.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/coast/i],describe(e){const t={name:"Opera Coast"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(e){const t={name:"Opera Touch"},n=br.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe(e){const t={name:"Yandex Browser"},n=br.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe(e){const t={name:"UC Browser"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe(e){const t={name:"Maxthon"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe(e){const t={name:"Epiphany"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe(e){const t={name:"Puffin"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe(e){const t={name:"Sleipnir"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe(e){const t={name:"K-Meleon"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe(e){const t={name:"WeChat"},n=br.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/qqbrowser/i],describe(e){const t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},n=br.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe(e){const t={name:"Internet Explorer"},n=br.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe(e){const t={name:"Microsoft Edge"},n=br.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe(e){const t={name:"Microsoft Edge"},n=br.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe(e){const t={name:"Vivaldi"},n=br.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe(e){const t={name:"SeaMonkey"},n=br.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe(e){const t={name:"Sailfish"},n=br.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe(e){const t={name:"Amazon Silk"},n=br.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe(e){const t={name:"PhantomJS"},n=br.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe(e){const t={name:"SlimerJS"},n=br.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t={name:"BlackBerry"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe(e){const t={name:"WebOS Browser"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe(e){const t={name:"Bada"},n=br.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe(e){const t={name:"Tizen"},n=br.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe(e){const t={name:"QupZilla"},n=br.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe(e){const t={name:"Firefox"},n=br.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe(e){const t={name:"Electron"},n=br.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MiuiBrowser/i],describe(e){const t={name:"Miui"},n=br.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe(e){const t={name:"Chromium"},n=br.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe(e){const t={name:"Chrome"},n=br.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/GSA/i],describe(e){const t={name:"Google Search"},n=br.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test(e){const t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe(e){const t={name:"Android Browser"},n=br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe(e){const t={name:"PlayStation 4"},n=br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe(e){const t={name:"Safari"},n=br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/.*/i],describe(e){const t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:br.getFirstMatch(t,e),version:br.getSecondMatch(t,e)}}}];var Sr=[{test:[/Roku\/DVP/],describe(e){const t=br.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:vr.Roku,version:t}}},{test:[/windows phone/i],describe(e){const t=br.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:vr.WindowsPhone,version:t}}},{test:[/windows /i],describe(e){const t=br.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=br.getWindowsVersionName(t);return{name:vr.Windows,version:t,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(e){const t={name:vr.iOS},n=br.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe(e){const t=br.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=br.getMacOSVersionName(t),r={name:vr.MacOS,version:t};return n&&(r.versionName=n),r}},{test:[/(ipod|iphone|ipad)/i],describe(e){const t=br.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:vr.iOS,version:t}}},{test(e){const t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe(e){const t=br.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),n=br.getAndroidVersionName(t),r={name:vr.Android,version:t};return n&&(r.versionName=n),r}},{test:[/(web|hpw)[o0]s/i],describe(e){const t=br.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:vr.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t=br.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||br.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||br.getFirstMatch(/\bbb(\d+)/i,e);return{name:vr.BlackBerry,version:t}}},{test:[/bada/i],describe(e){const t=br.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:vr.Bada,version:t}}},{test:[/tizen/i],describe(e){const t=br.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:vr.Tizen,version:t}}},{test:[/linux/i],describe:()=>({name:vr.Linux})},{test:[/CrOS/],describe:()=>({name:vr.ChromeOS})},{test:[/PlayStation 4/],describe(e){const t=br.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:vr.PlayStation4,version:t}}}],_r=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(e){const t=br.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:gr.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:gr.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:gr.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:gr.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:gr.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:gr.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:gr.tablet})},{test(e){const t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe(e){const t=br.getFirstMatch(/(ipod|iphone)/i,e);return{type:gr.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:gr.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:gr.mobile})},{test:e=>"blackberry"===e.getBrowserName(!0),describe:()=>({type:gr.mobile,vendor:"BlackBerry"})},{test:e=>"bada"===e.getBrowserName(!0),describe:()=>({type:gr.mobile})},{test:e=>"windows phone"===e.getBrowserName(),describe:()=>({type:gr.mobile,vendor:"Microsoft"})},{test(e){const t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:()=>({type:gr.tablet})},{test:e=>"android"===e.getOSName(!0),describe:()=>({type:gr.mobile})},{test:e=>"macos"===e.getOSName(!0),describe:()=>({type:gr.desktop,vendor:"Apple"})},{test:e=>"windows"===e.getOSName(!0),describe:()=>({type:gr.desktop})},{test:e=>"linux"===e.getOSName(!0),describe:()=>({type:gr.desktop})},{test:e=>"playstation 4"===e.getOSName(!0),describe:()=>({type:gr.tv})},{test:e=>"roku"===e.getOSName(!0),describe:()=>({type:gr.tv})}],xr=[{test:e=>"microsoft edge"===e.getBrowserName(!0),describe(e){if(/\sedg\//i.test(e))return{name:yr.Blink};const t=br.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:yr.EdgeHTML,version:t}}},{test:[/trident/i],describe(e){const t={name:yr.Trident},n=br.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:e=>e.test(/presto/i),describe(e){const t={name:yr.Presto},n=br.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test(e){const t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe(e){const t={name:yr.Gecko},n=br.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:yr.Blink})},{test:[/(apple)?webkit/i],describe(e){const t={name:yr.WebKit},n=br.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];class Cr{constructor(e,t=!1){if(null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}getUA(){return this._ua}test(e){return e.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const e=br.find(kr,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const e=br.find(Sr,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os}getOSName(e){const{name:t}=this.getOS();return e?String(t).toLowerCase()||"":t||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(e=!1){const{type:t}=this.getPlatform();return e?String(t).toLowerCase()||"":t||""}parsePlatform(){this.parsedResult.platform={};const e=br.find(_r,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const e=br.find(xr,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return br.assign({},this.parsedResult)}satisfies(e){const t={};let n=0;const r={};let i=0;if(Object.keys(e).forEach(a=>{const o=e[a];"string"==typeof o?(r[a]=o,i+=1):"object"==typeof o&&(t[a]=o,n+=1)}),n>0){const e=Object.keys(t),n=br.find(e,e=>this.isOS(e));if(n){const e=this.satisfies(t[n]);if(void 0!==e)return e}const r=br.find(e,e=>this.isPlatform(e));if(r){const e=this.satisfies(t[r]);if(void 0!==e)return e}}if(i>0){const e=Object.keys(r),t=br.find(e,e=>this.isBrowser(e,!0));if(void 0!==t)return this.compareVersion(r[t])}}isBrowser(e,t=!1){const n=this.getBrowserName().toLowerCase();let r=e.toLowerCase();const i=br.getBrowserTypeByAlias(r);return t&&i&&(r=i.toLowerCase()),r===n}compareVersion(e){let t=[0],n=e,r=!1;const i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(r=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(r=!0,n=e.substr(1)),t.indexOf(br.compareVersions(i,n,r))>-1}isOS(e){return this.getOSName(!0)===String(e).toLowerCase()}isPlatform(e){return this.getPlatformType(!0)===String(e).toLowerCase()}isEngine(e){return this.getEngineName(!0)===String(e).toLowerCase()}is(e,t=!1){return this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)}some(e=[]){return e.some(e=>this.is(e))}}
|
|
36
|
+
*/function Rt({agentName:e,avatarUrl:t,tncEnabled:n,tncContent:r,onTalk:i,onChat:a,onClose:o,className:s}){const[l,c]=x.useState(!n||!r),[u,d]=x.useState(n&&r),f=x.useRef(null),p=x.useCallback(e=>{const t=e.target;t.scrollHeight-t.scrollTop<=t.clientHeight+20&&(c(!0),d(!1))},[]),h=x.useCallback(e=>{e&&(f.current=e,setTimeout(()=>{e.scrollHeight>e.clientHeight||(c(!0),d(!1))},100))},[]);return b.jsxs("div",{className:vt("flex flex-col h-full w-full animate-fade-in relative min-h-0",s),style:{backgroundColor:"var(--widget-background, #FFFFFF)",fontFamily:"var(--widget-font-family, system-ui)"},children:[b.jsx("button",{onClick:o,className:"absolute top-4 right-4 p-2 rounded-full hover:opacity-80 transition-opacity z-10",style:{color:"var(--widget-icon-secondary, #6B7280)"},"aria-label":"Close",children:b.jsx(Ft,{className:"h-6 w-6"})}),b.jsx("div",{ref:h,onScroll:p,className:"flex-1 min-h-0 overflow-y-auto",children:b.jsxs("div",{className:"flex flex-col items-center px-6 py-8 pt-14",children:[b.jsx(St,{src:t,alt:e,size:"2xl",className:"mb-6 shadow-lg"}),b.jsx("h1",{className:"text-2xl font-semibold mb-2 text-center",style:{color:"var(--widget-text-primary, #111827)"},children:"Welcome!"}),b.jsxs("p",{className:"text-lg mb-6 text-center",style:{color:"var(--widget-text-secondary, #6B7280)"},children:["I'm ",b.jsx("span",{className:"font-medium",children:e})]}),n&&r&&b.jsx("div",{className:"w-full max-w-md mb-6 p-4 rounded-lg",style:{backgroundColor:"var(--widget-background-secondary, #F9FAFB)",border:"1px solid var(--widget-border, #E5E7EB)"},children:b.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",style:{color:"var(--widget-text-secondary, #6B7280)"},children:r})}),n&&b.jsx("p",{className:"text-xs mb-8 text-center max-w-sm",style:{color:"var(--widget-text-muted, #9CA3AF)"},children:"By continuing, you agree to the terms above."})]})}),u&&b.jsxs("div",{className:"flex flex-col items-center py-2 pointer-events-none",style:{background:"linear-gradient(transparent, var(--widget-background, #FFFFFF) 30%)"},children:[b.jsx(Pt,{className:"h-5 w-5 animate-bounce",style:{color:"var(--widget-primary-color, #3B82F6)"}}),b.jsx("span",{className:"text-xs",style:{color:"var(--widget-primary-color, #3B82F6)"},children:"Scroll to continue"})]}),b.jsx("div",{className:"p-6 pb-safe shrink-0",style:{borderTop:"1px solid var(--widget-border, #E5E7EB)",paddingBottom:"max(1.5rem, env(safe-area-inset-bottom, 0px))"},children:b.jsxs("div",{className:"flex gap-4 max-w-md mx-auto",children:[b.jsxs(kt,{onClick:i,variant:"default",size:"xl",className:"flex-1",disabled:!l,children:[b.jsx(Lt,{className:"h-5 w-5"}),"Talk"]}),b.jsxs(kt,{onClick:a,variant:"secondary",size:"xl",className:"flex-1",disabled:!l,children:[b.jsx(Ot,{className:"h-5 w-5"}),"Chat"]})]})})]})}function Dt(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Bt(...e){return t=>{let n=!1;const r=e.map(e=>{const r=Dt(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():Dt(e[t],null)}}}}function zt(...e){return x.useCallback(Bt(...e),e)}function Ut(e){const t=Vt(e),n=x.forwardRef((e,n)=>{const r=e,{children:i}=r,a=u(r,["children"]),o=x.Children.toArray(i),s=o.find(Wt);if(s){const e=s.props.children,r=o.map(t=>t===s?x.Children.count(e)>1?x.Children.only(null):x.isValidElement(e)?e.props.children:null:t);return b.jsx(t,c(l({},a),{ref:n,children:x.isValidElement(e)?x.cloneElement(e,void 0,r):null}))}return b.jsx(t,c(l({},a),{ref:n,children:i}))});return n.displayName=`${e}.Slot`,n}function Vt(e){const t=x.forwardRef((e,t)=>{const n=e,{children:r}=n,i=u(n,["children"]);if(x.isValidElement(r)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,i=r&&"isReactWarning"in r&&r.isReactWarning;if(i)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,i=r&&"isReactWarning"in r&&r.isReactWarning,i)return e.props.ref;return e.props.ref||e.ref}(r),n=function(e,t){const n=l({},t);for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{const t=a(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]=l(l({},i),a):"className"===r&&(n[r]=[i,a].filter(Boolean).join(" "))}return l(l({},e),n)}(i,r.props);return r.type!==x.Fragment&&(n.ref=t?Bt(t,e):e),x.cloneElement(r,n)}return x.Children.count(r)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}z();var $t=Symbol("radix.slottable");function Wt(e){return x.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===$t}var qt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=Ut(`Primitive.${t}`),r=x.forwardRef((e,r)=>{const i=e,{asChild:a}=i,o=u(i,["asChild"]),s=a?n:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b.jsx(s,c(l({},o),{ref:r}))});return r.displayName=`Primitive.${t}`,c(l({},e),{[t]:r})},{}),Ht=(null==globalThis?void 0:globalThis.document)?x.useLayoutEffect:()=>{};var Jt=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=x.useState(),r=x.useRef(null),i=x.useRef(e),a=x.useRef("none"),o=e?"mounted":"unmounted",[s,l]=function(e,t){return x.useReducer((e,n)=>{const r=t[e][n];return null!=r?r:e},e)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const e=Qt(r.current);a.current="mounted"===s?e:"none"},[s]),Ht(()=>{const t=r.current,n=i.current;if(n!==e){const r=a.current,o=Qt(t);if(e)l("MOUNT");else if("none"===o||"none"===(null==t?void 0:t.display))l("UNMOUNT");else{l(n&&r!==o?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,l]),Ht(()=>{var e;if(t){let n;const o=null!=(e=t.ownerDocument.defaultView)?e:window,s=e=>{const a=Qt(r.current).includes(CSS.escape(e.animationName));if(e.target===t&&a&&(l("ANIMATION_END"),!i.current)){const e=t.style.animationFillMode;t.style.animationFillMode="forwards",n=o.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=e)})}},c=e=>{e.target===t&&(a.current=Qt(r.current))};return t.addEventListener("animationstart",c),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{o.clearTimeout(n),t.removeEventListener("animationstart",c),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:x.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):x.Children.only(n),a=zt(r.ref,function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,i=r&&"isReactWarning"in r&&r.isReactWarning;if(i)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,i=r&&"isReactWarning"in r&&r.isReactWarning,i)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||r.isPresent?x.cloneElement(i,{ref:a}):null};function Qt(e){return(null==e?void 0:e.animationName)||"none"}function Gt(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>{const i=n(e)[`__scope${r}`];return l(l({},t),i)},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function Yt(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e}),x.useMemo(()=>(...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)},[])}Jt.displayName="Presence";var Kt=x.createContext(void 0);function Xt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(null==e||e(r),!1===n||!r.defaultPrevented)return null==t?void 0:t(r)}}var Zt="ScrollArea",[en]=function(e,t=[]){let n=[];const r=()=>{const t=n.map(e=>x.createContext(e));return function(n){const r=(null==n?void 0:n[e])||t;return x.useMemo(()=>({[`__scope${e}`]:c(l({},n),{[e]:r})}),[n,r])}};return r.scopeName=e,[function(t,r){const i=x.createContext(r),a=n.length;n=[...n,r];const o=t=>{var n;const r=t,{scope:o,children:s}=r,l=u(r,["scope","children"]),c=(null==(n=null==o?void 0:o[e])?void 0:n[a])||i,d=x.useMemo(()=>l,Object.values(l));return b.jsx(c.Provider,{value:d,children:s})};return o.displayName=t+"Provider",[o,function(n,o){var s;const l=(null==(s=null==o?void 0:o[e])?void 0:s[a])||i,c=x.useContext(l);if(c)return c;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},Gt(r,...t)]}(Zt),[tn,nn]=en(Zt),rn=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r,type:i="hover",dir:a,scrollHideDelay:o=600}=n,s=u(n,["__scopeScrollArea","type","dir","scrollHideDelay"]),[d,f]=x.useState(null),[p,h]=x.useState(null),[m,g]=x.useState(null),[v,y]=x.useState(null),[w,k]=x.useState(null),[S,_]=x.useState(0),[C,E]=x.useState(0),[T,M]=x.useState(!1),[P,A]=x.useState(!1),O=zt(t,e=>f(e)),N=function(e){const t=x.useContext(Kt);return e||t||"ltr"}(a);return b.jsx(tn,{scope:r,type:i,dir:N,scrollHideDelay:o,scrollArea:d,viewport:p,onViewportChange:h,content:m,onContentChange:g,scrollbarX:v,onScrollbarXChange:y,scrollbarXEnabled:T,onScrollbarXEnabledChange:M,scrollbarY:w,onScrollbarYChange:k,scrollbarYEnabled:P,onScrollbarYEnabledChange:A,onCornerWidthChange:_,onCornerHeightChange:E,children:b.jsx(qt.div,c(l({dir:N},s),{ref:O,style:l({position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":C+"px"},e.style)}))})});rn.displayName=Zt;var an="ScrollAreaViewport",on=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r,children:i,nonce:a}=n,o=u(n,["__scopeScrollArea","children","nonce"]),s=nn(an,r),d=zt(t,x.useRef(null),s.onViewportChange);return b.jsxs(b.Fragment,{children:[b.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),b.jsx(qt.div,c(l({"data-radix-scroll-area-viewport":""},o),{ref:d,style:l({overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden"},e.style),children:b.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:i})}))]})});on.displayName=an;var sn="ScrollAreaScrollbar",ln=x.forwardRef((e,t)=>{const n=e,{forceMount:r}=n,i=u(n,["forceMount"]),a=nn(sn,e.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:s}=a,d="horizontal"===e.orientation;return x.useEffect(()=>(d?o(!0):s(!0),()=>{d?o(!1):s(!1)}),[d,o,s]),"hover"===a.type?b.jsx(cn,c(l({},i),{ref:t,forceMount:r})):"scroll"===a.type?b.jsx(un,c(l({},i),{ref:t,forceMount:r})):"auto"===a.type?b.jsx(dn,c(l({},i),{ref:t,forceMount:r})):"always"===a.type?b.jsx(fn,c(l({},i),{ref:t})):null});ln.displayName=sn;var cn=x.forwardRef((e,t)=>{const n=e,{forceMount:r}=n,i=u(n,["forceMount"]),a=nn(sn,e.__scopeScrollArea),[o,s]=x.useState(!1);return x.useEffect(()=>{const e=a.scrollArea;let t=0;if(e){const n=()=>{window.clearTimeout(t),s(!0)},r=()=>{t=window.setTimeout(()=>s(!1),a.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",r),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",r)}}},[a.scrollArea,a.scrollHideDelay]),b.jsx(Jt,{present:r||o,children:b.jsx(dn,c(l({"data-state":o?"visible":"hidden"},i),{ref:t}))})}),un=x.forwardRef((e,t)=>{const n=e,{forceMount:r}=n,i=u(n,["forceMount"]),a=nn(sn,e.__scopeScrollArea),o="horizontal"===e.orientation,s=On(()=>f("SCROLL_END"),100),[d,f]=(p="hidden",h={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},x.useReducer((e,t)=>{const n=h[e][t];return null!=n?n:e},p));var p,h;return x.useEffect(()=>{if("idle"===d){const e=window.setTimeout(()=>f("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[d,a.scrollHideDelay,f]),x.useEffect(()=>{const e=a.viewport,t=o?"scrollLeft":"scrollTop";if(e){let n=e[t];const r=()=>{const r=e[t];n!==r&&(f("SCROLL"),s()),n=r};return e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[a.viewport,o,f,s]),b.jsx(Jt,{present:r||"hidden"!==d,children:b.jsx(fn,c(l({"data-state":"hidden"===d?"hidden":"visible"},i),{ref:t,onPointerEnter:Xt(e.onPointerEnter,()=>f("POINTER_ENTER")),onPointerLeave:Xt(e.onPointerLeave,()=>f("POINTER_LEAVE"))}))})}),dn=x.forwardRef((e,t)=>{const n=nn(sn,e.__scopeScrollArea),r=e,{forceMount:i}=r,a=u(r,["forceMount"]),[o,s]=x.useState(!1),d="horizontal"===e.orientation,f=On(()=>{if(n.viewport){const e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;s(d?e:t)}},10);return Nn(n.viewport,f),Nn(n.content,f),b.jsx(Jt,{present:i||o,children:b.jsx(fn,c(l({"data-state":o?"visible":"hidden"},a),{ref:t}))})}),fn=x.forwardRef((e,t)=>{const n=e,{orientation:r="vertical"}=n,i=u(n,["orientation"]),a=nn(sn,e.__scopeScrollArea),o=x.useRef(null),s=x.useRef(0),[d,f]=x.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),p=Cn(d.viewport,d.content),h=c(l({},i),{sizes:d,onSizesChange:f,hasThumb:Boolean(p>0&&p<1),onThumbChange:e=>o.current=e,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:e=>s.current=e});function m(e,t){return function(e,t,n,r="ltr"){const i=En(n),a=i/2,o=t||a,s=i-o,l=n.scrollbar.paddingStart+o,c=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d="ltr"===r?[0,u]:[-1*u,0];return Mn([l,c],d)(e)}(e,s.current,d,t)}return"horizontal"===r?b.jsx(pn,c(l({},h),{ref:t,onThumbPositionChange:()=>{if(a.viewport&&o.current){const e=Tn(a.viewport.scrollLeft,d,a.dir);o.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{a.viewport&&(a.viewport.scrollLeft=e)},onDragScroll:e=>{a.viewport&&(a.viewport.scrollLeft=m(e,a.dir))}})):"vertical"===r?b.jsx(hn,c(l({},h),{ref:t,onThumbPositionChange:()=>{if(a.viewport&&o.current){const e=Tn(a.viewport.scrollTop,d);o.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{a.viewport&&(a.viewport.scrollTop=e)},onDragScroll:e=>{a.viewport&&(a.viewport.scrollTop=m(e))}})):null}),pn=x.forwardRef((e,t)=>{const n=e,{sizes:r,onSizesChange:i}=n,a=u(n,["sizes","onSizesChange"]),o=nn(sn,e.__scopeScrollArea),[s,d]=x.useState(),f=x.useRef(null),p=zt(t,f,o.onScrollbarXChange);return x.useEffect(()=>{f.current&&d(getComputedStyle(f.current))},[f]),b.jsx(vn,c(l({"data-orientation":"horizontal"},a),{ref:p,sizes:r,style:l({bottom:0,left:"rtl"===o.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===o.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":En(r)+"px"},e.style),onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(o.viewport){const r=o.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Pn(r,n)&&t.preventDefault()}},onResize:()=>{f.current&&o.viewport&&s&&i({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:f.current.clientWidth,paddingStart:xn(s.paddingLeft),paddingEnd:xn(s.paddingRight)}})}}))}),hn=x.forwardRef((e,t)=>{const n=e,{sizes:r,onSizesChange:i}=n,a=u(n,["sizes","onSizesChange"]),o=nn(sn,e.__scopeScrollArea),[s,d]=x.useState(),f=x.useRef(null),p=zt(t,f,o.onScrollbarYChange);return x.useEffect(()=>{f.current&&d(getComputedStyle(f.current))},[f]),b.jsx(vn,c(l({"data-orientation":"vertical"},a),{ref:p,sizes:r,style:l({top:0,right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":En(r)+"px"},e.style),onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(o.viewport){const r=o.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Pn(r,n)&&t.preventDefault()}},onResize:()=>{f.current&&o.viewport&&s&&i({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:f.current.clientHeight,paddingStart:xn(s.paddingTop),paddingEnd:xn(s.paddingBottom)}})}}))}),[mn,gn]=en(sn),vn=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r,sizes:i,hasThumb:a,onThumbChange:o,onThumbPointerUp:s,onThumbPointerDown:d,onThumbPositionChange:f,onDragScroll:p,onWheelScroll:h,onResize:m}=n,g=u(n,["__scopeScrollArea","sizes","hasThumb","onThumbChange","onThumbPointerUp","onThumbPointerDown","onThumbPositionChange","onDragScroll","onWheelScroll","onResize"]),v=nn(sn,r),[y,w]=x.useState(null),k=zt(t,e=>w(e)),S=x.useRef(null),_=x.useRef(""),C=v.viewport,E=i.content-i.viewport,T=Yt(h),M=Yt(f),P=On(m,10);function A(e){if(S.current){const t=e.clientX-S.current.left,n=e.clientY-S.current.top;p({x:t,y:n})}}return x.useEffect(()=>{const e=e=>{const t=e.target;(null==y?void 0:y.contains(t))&&T(e,E)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[C,y,E,T]),x.useEffect(M,[i,M]),Nn(y,P),Nn(v.content,P),b.jsx(mn,{scope:r,scrollbar:y,hasThumb:a,onThumbChange:Yt(o),onThumbPointerUp:Yt(s),onThumbPositionChange:M,onThumbPointerDown:Yt(d),children:b.jsx(qt.div,c(l({},g),{ref:k,style:l({position:"absolute"},g.style),onPointerDown:Xt(e.onPointerDown,e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),S.current=y.getBoundingClientRect(),_.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),A(e)}}),onPointerMove:Xt(e.onPointerMove,A),onPointerUp:Xt(e.onPointerUp,e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=_.current,v.viewport&&(v.viewport.style.scrollBehavior=""),S.current=null})}))})}),yn="ScrollAreaThumb",bn=x.forwardRef((e,t)=>{const n=e,{forceMount:r}=n,i=u(n,["forceMount"]),a=gn(yn,e.__scopeScrollArea);return b.jsx(Jt,{present:r||a.hasThumb,children:b.jsx(wn,l({ref:t},i))})}),wn=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r,style:i}=n,a=u(n,["__scopeScrollArea","style"]),o=nn(yn,r),s=gn(yn,r),{onThumbPositionChange:d}=s,f=zt(t,e=>s.onThumbChange(e)),p=x.useRef(void 0),h=On(()=>{p.current&&(p.current(),p.current=void 0)},100);return x.useEffect(()=>{const e=o.viewport;if(e){const t=()=>{if(h(),!p.current){const t=An(e,d);p.current=t,d()}};return d(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[o.viewport,h,d]),b.jsx(qt.div,c(l({"data-state":s.hasThumb?"visible":"hidden"},a),{ref:f,style:l({width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)"},i),onPointerDownCapture:Xt(e.onPointerDownCapture,e=>{const t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;s.onThumbPointerDown({x:n,y:r})}),onPointerUp:Xt(e.onPointerUp,s.onThumbPointerUp)}))});bn.displayName=yn;var kn="ScrollAreaCorner",Sn=x.forwardRef((e,t)=>{const n=nn(kn,e.__scopeScrollArea),r=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&r?b.jsx(_n,c(l({},e),{ref:t})):null});Sn.displayName=kn;var _n=x.forwardRef((e,t)=>{const n=e,{__scopeScrollArea:r}=n,i=u(n,["__scopeScrollArea"]),a=nn(kn,r),[o,s]=x.useState(0),[d,f]=x.useState(0),p=Boolean(o&&d);return Nn(a.scrollbarX,()=>{var e;const t=(null==(e=a.scrollbarX)?void 0:e.offsetHeight)||0;a.onCornerHeightChange(t),f(t)}),Nn(a.scrollbarY,()=>{var e;const t=(null==(e=a.scrollbarY)?void 0:e.offsetWidth)||0;a.onCornerWidthChange(t),s(t)}),p?b.jsx(qt.div,c(l({},i),{ref:t,style:l({width:o,height:d,position:"absolute",right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:0},e.style)})):null});function xn(e){return e?parseInt(e,10):0}function Cn(e,t){const n=e/t;return isNaN(n)?0:n}function En(e){const t=Cn(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Tn(e,t,n="ltr"){const r=En(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,l=function(e,[t,n]){return Math.min(n,Math.max(t,e))}(e,"ltr"===n?[0,o]:[-1*o,0]);return Mn([0,o],[0,s])(l)}function Mn(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Pn(e,t){return e>0&&e<t}var An=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function i(){const a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(r)};function On(e,t){const n=Yt(e),r=x.useRef(0);return x.useEffect(()=>()=>window.clearTimeout(r.current),[]),x.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Nn(e,t){const n=Yt(t);Ht(()=>{let t=0;if(e){const r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var Ln=rn,jn=on,In=Sn;const Fn=x.forwardRef((e,t)=>{var n=e,{className:r,children:i}=n,a=u(n,["className","children"]);return b.jsxs(Ln,c(l({ref:t,className:vt("relative overflow-hidden",r)},a),{children:[b.jsx(jn,{className:"h-full w-full rounded-[inherit]",children:i}),b.jsx(Rn,{}),b.jsx(In,{})]}))});Fn.displayName=Ln.displayName;const Rn=x.forwardRef((e,t)=>{var n=e,{className:r,orientation:i="vertical"}=n,a=u(n,["className","orientation"]);return b.jsx(ln,c(l({ref:t,orientation:i,className:vt("flex touch-none select-none transition-colors","vertical"===i&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===i&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",r)},a),{children:b.jsx(bn,{className:"relative flex-1 rounded-full",style:{backgroundColor:"var(--widget-border, #E5E7EB)"}})}))});function Dn({messages:e,streamingContent:t,isStreaming:n,className:r}){const i=x.useRef(null);return x.useEffect(()=>{var e;null==(e=i.current)||e.scrollIntoView({behavior:"smooth"})},[e,t]),b.jsx(Fn,{className:vt("flex-1 px-4",r),children:b.jsxs("div",{className:"py-4 space-y-4",children:[e.map(e=>b.jsx(Bn,{message:e},e.id)),n&&t&&b.jsx(Bn,{message:{type:"assistant",text:t,isStreaming:!0}}),b.jsx("div",{ref:i})]})})}function Bn({message:e}){const t="user"===e.type;e.type;const n="system"===e.type;return"separator"===e.type?b.jsx("div",{className:"flex items-center justify-center py-2",children:b.jsx("div",{className:"px-3 py-1 rounded-full text-xs",style:{backgroundColor:"var(--widget-system-message-bg, #F3F4F6)",color:"var(--widget-system-message-text, #6B7280)"},children:e.text})}):n?b.jsx("div",{className:"flex justify-center",children:b.jsx("div",{className:"max-w-[85%] px-4 py-2 rounded-lg text-sm",style:{backgroundColor:"var(--widget-system-message-bg, #FEF3C7)",color:"var(--widget-system-message-text, #92400E)"},children:e.text})}):b.jsx("div",{className:vt("flex",t?"justify-end":"justify-start"),children:b.jsxs("div",{className:vt("max-w-[85%] px-4 py-3 rounded-2xl text-sm leading-relaxed",t?"rounded-br-md":"rounded-bl-md",e.isTranscript&&"italic opacity-80"),style:{backgroundColor:t?"var(--widget-user-message-bg, #3B82F6)":"var(--widget-bot-message-bg, #F3F4F6)",color:t?"var(--widget-user-message-text, #FFFFFF)":"var(--widget-bot-message-text, #111827)"},children:[e.text,e.isStreaming&&b.jsx("span",{className:"inline-block w-2 h-4 ml-1 animate-pulse bg-current opacity-50"})]})})}function zn({onSend:e,disabled:t,placeholder:n="Type a message...",className:r}){const[i,a]=x.useState(""),o=x.useRef(null),s=n=>{var r;n.preventDefault(),i.trim()&&!t&&(e(i.trim()),a(""),null==(r=o.current)||r.focus())};return b.jsxs("form",{onSubmit:s,className:vt("flex items-center gap-2 p-4 pb-safe shrink-0",r),style:{borderTop:"1px solid var(--widget-border, #E5E7EB)",backgroundColor:"var(--widget-background, #FFFFFF)",paddingBottom:"max(1rem, env(safe-area-inset-bottom, 0px))"},children:[b.jsx("input",{ref:o,type:"text",value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),s(e))},placeholder:n,disabled:t,className:"flex-1 h-11 px-4 rounded-full outline-none transition-all",style:{backgroundColor:"var(--widget-input-bg, #F9FAFB)",color:"var(--widget-input-text, #111827)",border:"1px solid var(--widget-input-border, #E5E7EB)",fontFamily:"var(--widget-font-family, inherit)",fontSize:"var(--widget-font-size-base, 14px)"}}),b.jsx(kt,{type:"submit",variant:"default",size:"icon",disabled:!i.trim()||t,className:"shrink-0 rounded-full h-11 w-11",children:b.jsx(It,{className:"h-5 w-5"})})]})}function Un(e,t,n={}){const{chatSession:r,messages:i,isChatInitialized:a,isStreaming:o,streamingContent:s,setChatSession:u,addMessage:f,setStreaming:p}=H(),h=x.useRef(null),m=x.useRef(null),g=x.useRef(!1),v=x.useCallback(()=>d(null,null,function*(){if(!g.current&&!a&&e&&t){g.current=!0;try{const r=yield function(e,t){return d(this,arguments,function*(e,t,n={}){const r=`${Q}/v1/widgets/chat/sessions?agent_id=${e}`,i=yield fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-Prompt-Token":t},body:JSON.stringify({agent_id:e,conversation_metadata:n})});if(!i.ok){const e=yield i.json().catch(()=>({}));throw new Error(e.detail||e.message||`HTTP ${i.status}`)}const a=yield i.json();return a.session_id,a})}(e,t,n);u(r),m.current=r.session_id,r.first_message&&f({type:"assistant",text:r.first_message,isTranscript:!1})}catch(r){f({type:"system",text:`Error: ${r.message}`})}}}),[e,t,n,a,u,f]),y=x.useCallback(i=>d(null,null,function*(){if(i.trim()&&!o){f({type:"user",text:i,isTranscript:!1});try{h.current=new AbortController,p(!0,""),m.current,i.substring(0,50);const a=yield function(e,t,n,r,i){return d(this,null,function*(){const a=`${Q}/v1/widgets/chat/messages`;n.substring(0,50);const o=yield fetch(a,{method:"POST",headers:{"Content-Type":"application/json","X-Prompt-Token":i},body:JSON.stringify({agent_id:e,session_id:t,message:n,metadata:r})});if(!o.ok){const e=yield o.text();throw new Error(`Server error (${o.status}): ${e||"Unknown error"}`)}return{response:o,sessionId:o.headers.get("X-Session-ID")}})}(e,m.current||(null==r?void 0:r.session_id),i,c(l({},n),{agent_id:e}),t);a.sessionId&&(m.current=a.sessionId);const o=a.response.body.getReader(),s=new TextDecoder;let u="";try{for(;;){const{done:e,value:t}=yield o.read();if(e)break;u+=s.decode(t,{stream:!0}),p(!0,u)}}finally{o.releaseLock()}u.trim()&&f({type:"assistant",text:u,isTranscript:!1}),p(!1,"")}catch(a){"AbortError"!==a.name&&f({type:"system",text:`Error: ${a.message}`}),p(!1,"")}}}),[e,t,r,n,o,f,p]),b=x.useCallback(()=>{h.current&&(h.current.abort(),p(!1,""))},[p]);return{messages:i,isStreaming:o,streamingContent:s,isInitialized:a,initializeChat:v,sendMessage:y,cancelStream:b}}function Vn({agentId:e,agentName:t,promptToken:n,metadata:r,onClose:i,onSwitchToTalk:a,className:o}){const{messages:s,isStreaming:l,streamingContent:c,isInitialized:u,initializeChat:d,sendMessage:f}=Un(e,n,r);return x.useEffect(()=>{!u&&n&&d()},[u,n,d]),b.jsxs("div",{className:vt("flex flex-col h-full w-full animate-fade-in",o),style:{backgroundColor:"var(--widget-background, #FFFFFF)",fontFamily:"var(--widget-font-family, system-ui)"},children:[b.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{backgroundColor:"var(--widget-header-bg, #F9FAFB)",borderBottom:"1px solid var(--widget-header-border, #E5E7EB)"},children:[b.jsx("button",{onClick:i,className:"p-2 rounded-full hover:opacity-80 transition-opacity",style:{color:"var(--widget-icon-secondary, #6B7280)"},"aria-label":"Close",children:b.jsx(Ft,{className:"h-5 w-5"})}),b.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--widget-header-text, #111827)"},children:t}),b.jsx(kt,{onClick:a,variant:"ghost",size:"icon-sm",className:"rounded-full",title:"Switch to voice",children:b.jsx(Lt,{className:"h-5 w-5",style:{color:"var(--widget-icon-active, #3B82F6)"}})})]}),b.jsx(Dn,{messages:s,streamingContent:c,isStreaming:l,className:"flex-1"}),b.jsx(zn,{onSend:f,disabled:l,placeholder:"Type a message..."})]})}Rn.displayName=ln.displayName;const $n={sm:48,md:80,lg:120,xl:160,"2xl":200},Wn=x.forwardRef((e,t)=>{var n=e,{children:r,loading:i=!0,size:a="lg",strokeWidth:o=4,gap:s=8,trackColor:d,spinnerColor:f,duration:p=1.5,className:h}=n,m=u(n,["children","loading","size","strokeWidth","gap","trackColor","spinnerColor","duration","className"]);const g="string"==typeof a?$n[a]||120:a,v=(g-o)/2,y=2*Math.PI*v,w=g/2,k=g-2*s-2*o,S=x.useId(),_=`\n @keyframes loader-spin-${S.replace(/:/g,"")} {\n 0% {\n transform: rotate(-90deg);\n }\n 100% {\n transform: rotate(270deg);\n }\n }\n \n @keyframes loader-dash-${S.replace(/:/g,"")} {\n 0% {\n stroke-dashoffset: ${y};\n }\n 50% {\n stroke-dashoffset: ${.25*y};\n }\n 100% {\n stroke-dashoffset: ${y};\n }\n }\n `;return b.jsxs("div",c(l({ref:t,className:vt("relative inline-flex items-center justify-center",h),style:{width:g,height:g}},m),{children:[i&&b.jsx("style",{children:_}),i&&b.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${g} ${g}`,"aria-hidden":"true",children:[b.jsx("circle",{cx:w,cy:w,r:v,fill:"none",stroke:d||"var(--widget-border, #E5E7EB)",strokeWidth:o}),b.jsx("circle",{cx:w,cy:w,r:v,fill:"none",stroke:f||"var(--widget-primary-color, #3B82F6)",strokeWidth:o,strokeLinecap:"round",strokeDasharray:y,strokeDashoffset:.25*y,style:{transformOrigin:"center",animation:`loader-spin-${S.replace(/:/g,"")} ${p}s linear infinite, loader-dash-${S.replace(/:/g,"")} ${1.33*p}s ease-in-out infinite`}})]}),b.jsx("div",{className:"relative z-10 flex items-center justify-center overflow-hidden rounded-full",style:{width:k,height:k},children:r})]}))});Wn.displayName="Loader";x.forwardRef((e,t)=>{var n=e,{size:r="md",strokeWidth:i=3,color:a,trackColor:o,duration:s=1,className:d}=n,f=u(n,["size","strokeWidth","color","trackColor","duration","className"]);const p="string"==typeof r?{xs:16,sm:20,md:24,lg:32,xl:40}[r]||24:r,h=(p-i)/2,m=2*Math.PI*h,g=p/2,v=x.useId(),y=`\n @keyframes simple-spin-${v.replace(/:/g,"")} {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n `;return b.jsxs("span",c(l({ref:t,className:vt("inline-flex items-center justify-center",d),role:"status","aria-label":"Loading"},f),{children:[b.jsx("style",{children:y}),b.jsxs("svg",{width:p,height:p,viewBox:`0 0 ${p} ${p}`,fill:"none",style:{animation:`simple-spin-${v.replace(/:/g,"")} ${s}s linear infinite`},children:[o&&b.jsx("circle",{cx:g,cy:g,r:h,stroke:o,strokeWidth:i,fill:"none",opacity:.25}),b.jsx("circle",{cx:g,cy:g,r:h,stroke:a||"var(--widget-primary-color, #3B82F6)",strokeWidth:i,strokeLinecap:"round",fill:"none",strokeDasharray:m,strokeDashoffset:.75*m})]}),b.jsx("span",{className:"sr-only",children:"Loading..."})]}))}).displayName="SpinnerLoader";function qn(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Hn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Jn(e){return(Jn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Qn(e){var t=function(e){if("object"!=Jn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Jn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Jn(t)?t:t+""}function Gn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Qn(r.key),r)}}function Yn(e,t,n){return t&&Gn(e.prototype,t),n&&Gn(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Kn(e,t){if(t&&("object"==Jn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Xn(e){return(Xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Zn(e,t){return(Zn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function er(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Zn(e,t)}function tr(e,t,n){return(t=Qn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nr(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(c){return void n(c)}s.done?t(l):Promise.resolve(l).then(r,i)}function rr(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){nr(a,r,i,o,s,"next",e)}function s(e){nr(a,r,i,o,s,"throw",e)}o(void 0)})}}function ir(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ar(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ir(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ir(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}x.forwardRef((e,t)=>{var n=e,{dotSize:r=8,gap:i=6,color:a,duration:o=1.4,className:s}=n,d=u(n,["dotSize","gap","color","duration","className"]);const f=x.useId(),p=`\n @keyframes dots-bounce-${f.replace(/:/g,"")} {\n 0%, 80%, 100% {\n transform: scale(0.6);\n opacity: 0.5;\n }\n 40% {\n transform: scale(1);\n opacity: 1;\n }\n }\n `;return b.jsxs("span",c(l({ref:t,className:vt("inline-flex items-center",s),style:{gap:i},role:"status","aria-label":"Loading"},d),{children:[b.jsx("style",{children:p}),[0,1,2].map(e=>b.jsx("span",{style:{width:r,height:r,borderRadius:"50%",backgroundColor:a||"var(--widget-primary-color, #3B82F6)",animation:`dots-bounce-${f.replace(/:/g,"")} ${o}s ease-in-out infinite`,animationDelay:e*(o/3)+"s"}},e)),b.jsx("span",{className:"sr-only",children:"Loading..."})]}))}).displayName="DotsLoader";var or,sr,lr={exports:{}},cr=function(){if(or)return lr.exports;or=1;var e,t="object"==typeof Reflect?Reflect:null,n=t&&"function"==typeof t.apply?t.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}lr.exports=i,lr.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}var o,s;h(e,t,a,{once:!0}),"error"!==t&&(s=i,"function"==typeof(o=e).on&&h(o,"error",s,{once:!0}))})},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function o(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function s(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var i,a,l,c;if(o(n),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),l=a[t]),void 0===l)l=a[t]=n,++e._eventsCount;else if("function"==typeof l?l=a[t]=r?[n,l]:[l,n]:r?l.unshift(n):l.push(n),(i=s(e))>0&&l.length>i&&!l.warned){l.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=l.length,c=u,console&&console.warn&&console.warn(c)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=c.bind(r);return i.listener=n,r.wrapFn=i,i}function d(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):p(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function h(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)})}}return Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return s(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var l=a[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var c=l.length,u=p(l,c);for(r=0;r<c;++r)n(u[r],this,t)}return!0},i.prototype.addListener=function(e,t){return l(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return l(this,e,t,!0)},i.prototype.once=function(e,t){return o(t),this.on(e,u(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return o(t),this.prependListener(e,u(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,r,i,a,s;if(o(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){s=n[a].listener,i=a;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,a=Object.keys(n);for(r=0;r<a.length;++r)"removeListener"!==(i=a[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},i.prototype.listeners=function(e){return d(this,e,!0)},i.prototype.rawListeners=function(e){return d(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},lr.exports}(),ur=(sr=cr)&&sr.__esModule&&Object.prototype.hasOwnProperty.call(sr,"default")?sr.default:sr,dr=Object.prototype.hasOwnProperty;function fr(e,t,n){for(n of e.keys())if(pr(n,t))return n}function pr(e,t){var n,r,i;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&pr(e[r],t[r]););return-1===r}if(n===Set){if(e.size!==t.size)return!1;for(r of e){if((i=r)&&"object"==typeof i&&!(i=fr(t,i)))return!1;if(!t.has(i))return!1}return!0}if(n===Map){if(e.size!==t.size)return!1;for(r of e){if((i=r[0])&&"object"==typeof i&&!(i=fr(t,i)))return!1;if(!pr(r[1],t.get(i)))return!1}return!0}if(n===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(n===DataView){if((r=e.byteLength)===t.byteLength)for(;r--&&e.getInt8(r)===t.getInt8(r););return-1===r}if(ArrayBuffer.isView(e)){if((r=e.byteLength)===t.byteLength)for(;r--&&e[r]===t[r];);return-1===r}if(!n||"object"==typeof e){for(n in r=0,e){if(dr.call(e,n)&&++r&&!dr.call(t,n))return!1;if(!(n in t)||!pr(e[n],t[n]))return!1}return Object.keys(t).length===r}}return e!=e&&t!=t}const hr={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},mr={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},gr={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},vr={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},yr={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class br{static getFirstMatch(e,t){const n=t.match(e);return n&&n.length>0&&n[1]||""}static getSecondMatch(e,t){const n=t.match(e);return n&&n.length>1&&n[2]||""}static matchAndReturnConst(e,t,n){if(e.test(t))return n}static getWindowsVersionName(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}static getMacOSVersionName(e){const t=e.split(".").splice(0,2).map(e=>parseInt(e,10)||0);if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}}static getAndroidVersionName(e){const t=e.split(".").splice(0,2).map(e=>parseInt(e,10)||0);if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0}static getVersionPrecision(e){return e.split(".").length}static compareVersions(e,t,n=!1){const r=br.getVersionPrecision(e),i=br.getVersionPrecision(t);let a=Math.max(r,i),o=0;const s=br.map([e,t],e=>{const t=a-br.getVersionPrecision(e),n=e+new Array(t+1).join(".0");return br.map(n.split("."),e=>new Array(20-e.length).join("0")+e).reverse()});for(n&&(o=a-Math.min(r,i)),a-=1;a>=o;){if(s[0][a]>s[1][a])return 1;if(s[0][a]===s[1][a]){if(a===o)return 0;a-=1}else if(s[0][a]<s[1][a])return-1}}static map(e,t){const n=[];let r;if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n}static find(e,t){let n,r;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(n=0,r=e.length;n<r;n+=1){const r=e[n];if(t(r,n))return r}}static assign(e,...t){const n=e;let r,i;if(Object.assign)return Object.assign(e,...t);for(r=0,i=t.length;r<i;r+=1){const e=t[r];"object"==typeof e&&null!==e&&Object.keys(e).forEach(t=>{n[t]=e[t]})}return e}static getBrowserAlias(e){return hr[e]}static getBrowserTypeByAlias(e){return mr[e]||""}}const wr=/version\/(\d+(\.?_?\d+)+)/i,kr=[{test:[/googlebot/i],describe(e){const t={name:"Googlebot"},n=br.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/opera/i],describe(e){const t={name:"Opera"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe(e){const t={name:"Opera"},n=br.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe(e){const t={name:"Samsung Internet for Android"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe(e){const t={name:"NAVER Whale Browser"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe(e){const t={name:"MZ Browser"},n=br.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/focus/i],describe(e){const t={name:"Focus"},n=br.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/swing/i],describe(e){const t={name:"Swing"},n=br.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/coast/i],describe(e){const t={name:"Opera Coast"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(e){const t={name:"Opera Touch"},n=br.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe(e){const t={name:"Yandex Browser"},n=br.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe(e){const t={name:"UC Browser"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe(e){const t={name:"Maxthon"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe(e){const t={name:"Epiphany"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe(e){const t={name:"Puffin"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe(e){const t={name:"Sleipnir"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe(e){const t={name:"K-Meleon"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe(e){const t={name:"WeChat"},n=br.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/qqbrowser/i],describe(e){const t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},n=br.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe(e){const t={name:"Internet Explorer"},n=br.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe(e){const t={name:"Microsoft Edge"},n=br.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe(e){const t={name:"Microsoft Edge"},n=br.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe(e){const t={name:"Vivaldi"},n=br.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe(e){const t={name:"SeaMonkey"},n=br.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe(e){const t={name:"Sailfish"},n=br.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe(e){const t={name:"Amazon Silk"},n=br.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe(e){const t={name:"PhantomJS"},n=br.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe(e){const t={name:"SlimerJS"},n=br.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t={name:"BlackBerry"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe(e){const t={name:"WebOS Browser"},n=br.getFirstMatch(wr,e)||br.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe(e){const t={name:"Bada"},n=br.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe(e){const t={name:"Tizen"},n=br.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe(e){const t={name:"QupZilla"},n=br.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe(e){const t={name:"Firefox"},n=br.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe(e){const t={name:"Electron"},n=br.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MiuiBrowser/i],describe(e){const t={name:"Miui"},n=br.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe(e){const t={name:"Chromium"},n=br.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe(e){const t={name:"Chrome"},n=br.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/GSA/i],describe(e){const t={name:"Google Search"},n=br.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test(e){const t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe(e){const t={name:"Android Browser"},n=br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe(e){const t={name:"PlayStation 4"},n=br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe(e){const t={name:"Safari"},n=br.getFirstMatch(wr,e);return n&&(t.version=n),t}},{test:[/.*/i],describe(e){const t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:br.getFirstMatch(t,e),version:br.getSecondMatch(t,e)}}}];var Sr=[{test:[/Roku\/DVP/],describe(e){const t=br.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:vr.Roku,version:t}}},{test:[/windows phone/i],describe(e){const t=br.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:vr.WindowsPhone,version:t}}},{test:[/windows /i],describe(e){const t=br.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=br.getWindowsVersionName(t);return{name:vr.Windows,version:t,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(e){const t={name:vr.iOS},n=br.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe(e){const t=br.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=br.getMacOSVersionName(t),r={name:vr.MacOS,version:t};return n&&(r.versionName=n),r}},{test:[/(ipod|iphone|ipad)/i],describe(e){const t=br.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:vr.iOS,version:t}}},{test(e){const t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe(e){const t=br.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),n=br.getAndroidVersionName(t),r={name:vr.Android,version:t};return n&&(r.versionName=n),r}},{test:[/(web|hpw)[o0]s/i],describe(e){const t=br.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:vr.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t=br.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||br.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||br.getFirstMatch(/\bbb(\d+)/i,e);return{name:vr.BlackBerry,version:t}}},{test:[/bada/i],describe(e){const t=br.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:vr.Bada,version:t}}},{test:[/tizen/i],describe(e){const t=br.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:vr.Tizen,version:t}}},{test:[/linux/i],describe:()=>({name:vr.Linux})},{test:[/CrOS/],describe:()=>({name:vr.ChromeOS})},{test:[/PlayStation 4/],describe(e){const t=br.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:vr.PlayStation4,version:t}}}],_r=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(e){const t=br.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:gr.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:gr.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:gr.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:gr.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:gr.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:gr.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:gr.tablet})},{test(e){const t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe(e){const t=br.getFirstMatch(/(ipod|iphone)/i,e);return{type:gr.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:gr.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:gr.mobile})},{test:e=>"blackberry"===e.getBrowserName(!0),describe:()=>({type:gr.mobile,vendor:"BlackBerry"})},{test:e=>"bada"===e.getBrowserName(!0),describe:()=>({type:gr.mobile})},{test:e=>"windows phone"===e.getBrowserName(),describe:()=>({type:gr.mobile,vendor:"Microsoft"})},{test(e){const t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:()=>({type:gr.tablet})},{test:e=>"android"===e.getOSName(!0),describe:()=>({type:gr.mobile})},{test:e=>"macos"===e.getOSName(!0),describe:()=>({type:gr.desktop,vendor:"Apple"})},{test:e=>"windows"===e.getOSName(!0),describe:()=>({type:gr.desktop})},{test:e=>"linux"===e.getOSName(!0),describe:()=>({type:gr.desktop})},{test:e=>"playstation 4"===e.getOSName(!0),describe:()=>({type:gr.tv})},{test:e=>"roku"===e.getOSName(!0),describe:()=>({type:gr.tv})}],xr=[{test:e=>"microsoft edge"===e.getBrowserName(!0),describe(e){if(/\sedg\//i.test(e))return{name:yr.Blink};const t=br.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:yr.EdgeHTML,version:t}}},{test:[/trident/i],describe(e){const t={name:yr.Trident},n=br.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:e=>e.test(/presto/i),describe(e){const t={name:yr.Presto},n=br.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test(e){const t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe(e){const t={name:yr.Gecko},n=br.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:yr.Blink})},{test:[/(apple)?webkit/i],describe(e){const t={name:yr.WebKit},n=br.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];class Cr{constructor(e,t=!1){if(null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}getUA(){return this._ua}test(e){return e.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const e=br.find(kr,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const e=br.find(Sr,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os}getOSName(e){const{name:t}=this.getOS();return e?String(t).toLowerCase()||"":t||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(e=!1){const{type:t}=this.getPlatform();return e?String(t).toLowerCase()||"":t||""}parsePlatform(){this.parsedResult.platform={};const e=br.find(_r,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const e=br.find(xr,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return br.assign({},this.parsedResult)}satisfies(e){const t={};let n=0;const r={};let i=0;if(Object.keys(e).forEach(a=>{const o=e[a];"string"==typeof o?(r[a]=o,i+=1):"object"==typeof o&&(t[a]=o,n+=1)}),n>0){const e=Object.keys(t),n=br.find(e,e=>this.isOS(e));if(n){const e=this.satisfies(t[n]);if(void 0!==e)return e}const r=br.find(e,e=>this.isPlatform(e));if(r){const e=this.satisfies(t[r]);if(void 0!==e)return e}}if(i>0){const e=Object.keys(r),t=br.find(e,e=>this.isBrowser(e,!0));if(void 0!==t)return this.compareVersion(r[t])}}isBrowser(e,t=!1){const n=this.getBrowserName().toLowerCase();let r=e.toLowerCase();const i=br.getBrowserTypeByAlias(r);return t&&i&&(r=i.toLowerCase()),r===n}compareVersion(e){let t=[0],n=e,r=!1;const i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(r=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(r=!0,n=e.substr(1)),t.indexOf(br.compareVersions(i,n,r))>-1}isOS(e){return this.getOSName(!0)===String(e).toLowerCase()}isPlatform(e){return this.getPlatformType(!0)===String(e).toLowerCase()}isEngine(e){return this.getEngineName(!0)===String(e).toLowerCase()}is(e,t=!1){return this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)}some(e=[]){return e.some(e=>this.is(e))}}
|
|
37
37
|
/*!
|
|
38
38
|
* Bowser - a browser detector
|
|
39
39
|
* https://github.com/lancedikson/bowser
|