@gram-ai/elements 1.16.2 → 1.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.typedoc.md +26 -0
- package/dist/elements.cjs +2 -2
- package/dist/elements.css +1 -1
- package/dist/elements.js +81 -79
- package/dist/index.d.ts +1 -1
- package/dist/types/index.d.ts +50 -27
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @gram-ai/elements
|
|
2
|
+
|
|
3
|
+
## First time setup
|
|
4
|
+
|
|
5
|
+
Please follow the [Setup Instructions](./README.md#setup) in the main README to get started.
|
|
6
|
+
|
|
7
|
+
## Elements Configuration
|
|
8
|
+
|
|
9
|
+
The minimal configuration required to get Elements setup is demonstrated below:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import type { ElementsConfig } from '@gram-ai/elements'
|
|
13
|
+
|
|
14
|
+
const config: ElementsConfig = {
|
|
15
|
+
mcp: 'https://app.getgram.ai/mcp/your-mcp-slug',
|
|
16
|
+
projectSlug: 'your-project-slug',
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The `mcp` and `projectSlug` values can be retrieved from the MCP and project pages respectively.
|
|
21
|
+
|
|
22
|
+
## API Documentation
|
|
23
|
+
|
|
24
|
+
`ElementsConfig` is the top level configuration object for the Elements library. Please refer the [ElementsConfig](./docs/interfaces/ElementsConfig.md) interface documentation for more details on how to configure Elements.
|
|
25
|
+
|
|
26
|
+
For an overview of all the available types and functions, please refer to the [Globals](./docs/globals.md) documentation.
|
package/dist/elements.cjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Utilities:
|
|
8
8
|
${r.map(o=>`- ${o.language}: ${o.prompt}`).join(`
|
|
9
|
-
`)}`}const Ql=({children:t,config:r})=>{const[o,i]=N.useState(r.model?.defaultModel??s.MODELS[0]),[e,n]=N.useState(r.modal?.defaultExpanded??!1),[a,l]=N.useState(r.modal?.defaultOpen),d=r.plugins??$.recommended,u=sl({sendAutomaticallyWhen:s.lastAssistantMessageIsCompleteWithToolCalls,transport:new Gt({api:r.chatEndpoint??ql,prepareSendMessagesRequest:({id:f,messages:g})=>{const h=u.thread.getModelContext(),v=Gl(Jl(h?.tools??{}));return{body:{messages:g,system:Yl(r.systemPrompt,d),id:f,tools:v,config:{mcp:r.mcp,environment:r.environment,projectSlug:r.projectSlug,model:o}}}}})});return c.jsx(j.AssistantRuntimeProvider,{runtime:u,children:c.jsxs($.ElementsContext.Provider,{value:{config:r,setModel:i,model:o,isExpanded:e,setIsExpanded:n,isOpen:a??!1,setIsOpen:l,plugins:d},children:[t,c.jsx(Hl,{tools:r.tools?.frontendTools??{}})]})})};function Hn(t,r){if(typeof t=="function")return t(r);t!=null&&(t.current=r)}function on(...t){return r=>{let o=!1;const i=t.map(e=>{const n=Hn(e,r);return!o&&typeof n=="function"&&(o=!0),n});if(o)return()=>{for(let e=0;e<i.length;e++){const n=i[e];typeof n=="function"?n():Hn(t[e],null)}}}}function G(...t){return m.useCallback(on(...t),t)}var ec=Symbol.for("react.lazy"),dt=m[" use ".trim().toString()];function tc(t){return typeof t=="object"&&t!==null&&"then"in t}function Er(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===ec&&"_payload"in t&&tc(t._payload)}function Dr(t){const r=rc(t),o=m.forwardRef((i,e)=>{let{children:n,...a}=i;Er(n)&&typeof dt=="function"&&(n=dt(n._payload));const l=m.Children.toArray(n),d=l.find(ac);if(d){const u=d.props.children,f=l.map(g=>g===d?m.Children.count(u)>1?m.Children.only(null):m.isValidElement(u)?u.props.children:null:g);return c.jsx(r,{...a,ref:e,children:m.isValidElement(u)?m.cloneElement(u,void 0,f):null})}return c.jsx(r,{...a,ref:e,children:n})});return o.displayName=`${t}.Slot`,o}var nc=Dr("Slot");function rc(t){const r=m.forwardRef((o,i)=>{let{children:e,...n}=o;if(Er(e)&&typeof dt=="function"&&(e=dt(e._payload)),m.isValidElement(e)){const a=lc(e),l=sc(n,e.props);return e.type!==m.Fragment&&(l.ref=i?on(i,a):a),m.cloneElement(e,l)}return m.Children.count(e)>1?m.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var Ur=Symbol("radix.slottable");function ic(t){const r=({children:o})=>c.jsx(c.Fragment,{children:o});return r.displayName=`${t}.Slottable`,r.__radixId=Ur,r}var oc=ic("Slottable");function ac(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Ur}function sc(t,r){const o={...r};for(const i in r){const e=t[i],n=r[i];/^on[A-Z]/.test(i)?e&&n?o[i]=(...l)=>{const d=n(...l);return e(...l),d}:e&&(o[i]=e):i==="style"?o[i]={...e,...n}:i==="className"&&(o[i]=[e,n].filter(Boolean).join(" "))}return{...t,...o}}function lc(t){let r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?t.ref:(r=Object.getOwnPropertyDescriptor(t,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?t.props.ref:t.props.ref||t.ref)}const qn=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Xn=$.clsx,cc=(t,r)=>o=>{var i;if(r?.variants==null)return Xn(t,o?.class,o?.className);const{variants:e,defaultVariants:n}=r,a=Object.keys(e).map(u=>{const f=o?.[u],g=n?.[u];if(f===null)return null;const h=qn(f)||qn(g);return e[u][h]}),l=o&&Object.entries(o).reduce((u,f)=>{let[g,h]=f;return h===void 0||(u[g]=h),u},{}),d=r==null||(i=r.compoundVariants)===null||i===void 0?void 0:i.reduce((u,f)=>{let{class:g,className:h,...v}=f;return Object.entries(v).every(y=>{let[p,b]=y;return Array.isArray(b)?b.includes({...n,...l}[p]):{...n,...l}[p]===b})?[...u,g,h]:u},[]);return Xn(t,a,d,o?.class,o?.className)},uc=cc("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),ce=m.forwardRef(({className:t,variant:r,size:o,asChild:i=!1,...e},n)=>{const a=i?nc:"button";return c.jsx(a,{"data-slot":"button",className:$.cn(uc({variant:r,size:o,className:t})),ref:n,...e})});ce.displayName="Button";function R(t,r,{checkForDefaultPrevented:o=!0}={}){return function(e){if(t?.(e),o===!1||!e.defaultPrevented)return r?.(e)}}function dc(t,r){const o=m.createContext(r),i=n=>{const{children:a,...l}=n,d=m.useMemo(()=>l,Object.values(l));return c.jsx(o.Provider,{value:d,children:a})};i.displayName=t+"Provider";function e(n){const a=m.useContext(o);if(a)return a;if(r!==void 0)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}return[i,e]}function Je(t,r=[]){let o=[];function i(n,a){const l=m.createContext(a),d=o.length;o=[...o,a];const u=g=>{const{scope:h,children:v,...y}=g,p=h?.[t]?.[d]||l,b=m.useMemo(()=>y,Object.values(y));return c.jsx(p.Provider,{value:b,children:v})};u.displayName=n+"Provider";function f(g,h){const v=h?.[t]?.[d]||l,y=m.useContext(v);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${g}\` must be used within \`${n}\``)}return[u,f]}const e=()=>{const n=o.map(a=>m.createContext(a));return function(l){const d=l?.[t]||n;return m.useMemo(()=>({[`__scope${t}`]:{...l,[t]:d}}),[l,d])}};return e.scopeName=t,[i,fc(e,...r)]}function fc(...t){const r=t[0];if(t.length===1)return r;const o=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(n){const a=i.reduce((l,{useScope:d,scopeName:u})=>{const g=d(n)[`__scope${u}`];return{...l,...g}},{});return m.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return o.scopeName=r.scopeName,o}function an(t){const r=mc(t),o=m.forwardRef((i,e)=>{const{children:n,...a}=i,l=m.Children.toArray(n),d=l.find(pc);if(d){const u=d.props.children,f=l.map(g=>g===d?m.Children.count(u)>1?m.Children.only(null):m.isValidElement(u)?u.props.children:null:g);return c.jsx(r,{...a,ref:e,children:m.isValidElement(u)?m.cloneElement(u,void 0,f):null})}return c.jsx(r,{...a,ref:e,children:n})});return o.displayName=`${t}.Slot`,o}function mc(t){const r=m.forwardRef((o,i)=>{const{children:e,...n}=o;if(m.isValidElement(e)){const a=hc(e),l=vc(n,e.props);return e.type!==m.Fragment&&(l.ref=i?on(i,a):a),m.cloneElement(e,l)}return m.Children.count(e)>1?m.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var Tr=Symbol("radix.slottable");function gc(t){const r=({children:o})=>c.jsx(c.Fragment,{children:o});return r.displayName=`${t}.Slottable`,r.__radixId=Tr,r}function pc(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Tr}function vc(t,r){const o={...r};for(const i in r){const e=t[i],n=r[i];/^on[A-Z]/.test(i)?e&&n?o[i]=(...l)=>{const d=n(...l);return e(...l),d}:e&&(o[i]=e):i==="style"?o[i]={...e,...n}:i==="className"&&(o[i]=[e,n].filter(Boolean).join(" "))}return{...t,...o}}function hc(t){let r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?t.ref:(r=Object.getOwnPropertyDescriptor(t,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?t.props.ref:t.props.ref||t.ref)}var yc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Z=yc.reduce((t,r)=>{const o=an(`Primitive.${r}`),i=m.forwardRef((e,n)=>{const{asChild:a,...l}=e,d=a?o:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...l,ref:n})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});function bc(t,r){t&&wr.flushSync(()=>t.dispatchEvent(r))}function xe(t){const r=m.useRef(t);return m.useEffect(()=>{r.current=t}),m.useMemo(()=>(...o)=>r.current?.(...o),[])}function $c(t,r=globalThis?.document){const o=xe(t);m.useEffect(()=>{const i=e=>{e.key==="Escape"&&o(e)};return r.addEventListener("keydown",i,{capture:!0}),()=>r.removeEventListener("keydown",i,{capture:!0})},[o,r])}var xc="DismissableLayer",Jt="dismissableLayer.update",_c="dismissableLayer.pointerDownOutside",wc="dismissableLayer.focusOutside",Yn,Ar=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ht=m.forwardRef((t,r)=>{const{disableOutsidePointerEvents:o=!1,onEscapeKeyDown:i,onPointerDownOutside:e,onFocusOutside:n,onInteractOutside:a,onDismiss:l,...d}=t,u=m.useContext(Ar),[f,g]=m.useState(null),h=f?.ownerDocument??globalThis?.document,[,v]=m.useState({}),y=G(r,O=>g(O)),p=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=p.indexOf(b),_=f?p.indexOf(f):-1,w=u.layersWithOutsidePointerEventsDisabled.size>0,k=_>=x,I=jc(O=>{const E=O.target,A=[...u.branches].some(U=>U.contains(E));!k||A||(e?.(O),a?.(O),O.defaultPrevented||l?.())},h),P=Ic(O=>{const E=O.target;[...u.branches].some(U=>U.contains(E))||(n?.(O),a?.(O),O.defaultPrevented||l?.())},h);return $c(O=>{_===u.layers.size-1&&(i?.(O),!O.defaultPrevented&&l&&(O.preventDefault(),l()))},h),m.useEffect(()=>{if(f)return o&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Yn=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Qn(),()=>{o&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Yn)}},[f,h,o,u]),m.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Qn())},[f,u]),m.useEffect(()=>{const O=()=>v({});return document.addEventListener(Jt,O),()=>document.removeEventListener(Jt,O)},[]),c.jsx(Z.div,{...d,ref:y,style:{pointerEvents:w?k?"auto":"none":void 0,...t.style},onFocusCapture:R(t.onFocusCapture,P.onFocusCapture),onBlurCapture:R(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:R(t.onPointerDownCapture,I.onPointerDownCapture)})});ht.displayName=xc;var Sc="DismissableLayerBranch",kc=m.forwardRef((t,r)=>{const o=m.useContext(Ar),i=m.useRef(null),e=G(r,i);return m.useEffect(()=>{const n=i.current;if(n)return o.branches.add(n),()=>{o.branches.delete(n)}},[o.branches]),c.jsx(Z.div,{...t,ref:e})});kc.displayName=Sc;function jc(t,r=globalThis?.document){const o=xe(t),i=m.useRef(!1),e=m.useRef(()=>{});return m.useEffect(()=>{const n=l=>{if(l.target&&!i.current){let d=function(){Rr(_c,o,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(r.removeEventListener("click",e.current),e.current=d,r.addEventListener("click",e.current,{once:!0})):d()}else r.removeEventListener("click",e.current);i.current=!1},a=window.setTimeout(()=>{r.addEventListener("pointerdown",n)},0);return()=>{window.clearTimeout(a),r.removeEventListener("pointerdown",n),r.removeEventListener("click",e.current)}},[r,o]),{onPointerDownCapture:()=>i.current=!0}}function Ic(t,r=globalThis?.document){const o=xe(t),i=m.useRef(!1);return m.useEffect(()=>{const e=n=>{n.target&&!i.current&&Rr(wc,o,{originalEvent:n},{discrete:!1})};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,o]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function Qn(){const t=new CustomEvent(Jt);document.dispatchEvent(t)}function Rr(t,r,o,{discrete:i}){const e=o.originalEvent.target,n=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:o});r&&e.addEventListener(t,r,{once:!0}),i?bc(e,n):e.dispatchEvent(n)}var Y=globalThis?.document?m.useLayoutEffect:()=>{},Nc=m[" useId ".trim().toString()]||(()=>{}),Oc=0;function Oe(t){const[r,o]=m.useState(Nc());return Y(()=>{o(i=>i??String(Oc++))},[t]),r?`radix-${r}`:""}const Pc=["top","right","bottom","left"],ye=Math.min,K=Math.max,ft=Math.round,Qe=Math.floor,le=t=>({x:t,y:t}),Cc={left:"right",right:"left",bottom:"top",top:"bottom"},Ec={start:"end",end:"start"};function Kt(t,r,o){return K(t,ye(r,o))}function me(t,r){return typeof t=="function"?t(r):t}function ge(t){return t.split("-")[0]}function Te(t){return t.split("-")[1]}function sn(t){return t==="x"?"y":"x"}function ln(t){return t==="y"?"height":"width"}const Dc=new Set(["top","bottom"]);function se(t){return Dc.has(ge(t))?"y":"x"}function cn(t){return sn(se(t))}function Uc(t,r,o){o===void 0&&(o=!1);const i=Te(t),e=cn(t),n=ln(e);let a=e==="x"?i===(o?"end":"start")?"right":"left":i==="start"?"bottom":"top";return r.reference[n]>r.floating[n]&&(a=mt(a)),[a,mt(a)]}function Tc(t){const r=mt(t);return[Ht(t),r,Ht(r)]}function Ht(t){return t.replace(/start|end/g,r=>Ec[r])}const er=["left","right"],tr=["right","left"],Ac=["top","bottom"],Rc=["bottom","top"];function zc(t,r,o){switch(t){case"top":case"bottom":return o?r?tr:er:r?er:tr;case"left":case"right":return r?Ac:Rc;default:return[]}}function Lc(t,r,o,i){const e=Te(t);let n=zc(ge(t),o==="start",i);return e&&(n=n.map(a=>a+"-"+e),r&&(n=n.concat(n.map(Ht)))),n}function mt(t){return t.replace(/left|right|bottom|top/g,r=>Cc[r])}function Mc(t){return{top:0,right:0,bottom:0,left:0,...t}}function zr(t){return typeof t!="number"?Mc(t):{top:t,right:t,bottom:t,left:t}}function gt(t){const{x:r,y:o,width:i,height:e}=t;return{width:i,height:e,top:o,left:r,right:r+i,bottom:o+e,x:r,y:o}}function nr(t,r,o){let{reference:i,floating:e}=t;const n=se(r),a=cn(r),l=ln(a),d=ge(r),u=n==="y",f=i.x+i.width/2-e.width/2,g=i.y+i.height/2-e.height/2,h=i[l]/2-e[l]/2;let v;switch(d){case"top":v={x:f,y:i.y-e.height};break;case"bottom":v={x:f,y:i.y+i.height};break;case"right":v={x:i.x+i.width,y:g};break;case"left":v={x:i.x-e.width,y:g};break;default:v={x:i.x,y:i.y}}switch(Te(r)){case"start":v[a]-=h*(o&&u?-1:1);break;case"end":v[a]+=h*(o&&u?-1:1);break}return v}const Zc=async(t,r,o)=>{const{placement:i="bottom",strategy:e="absolute",middleware:n=[],platform:a}=o,l=n.filter(Boolean),d=await(a.isRTL==null?void 0:a.isRTL(r));let u=await a.getElementRects({reference:t,floating:r,strategy:e}),{x:f,y:g}=nr(u,i,d),h=i,v={},y=0;for(let p=0;p<l.length;p++){const{name:b,fn:x}=l[p],{x:_,y:w,data:k,reset:I}=await x({x:f,y:g,initialPlacement:i,placement:h,strategy:e,middlewareData:v,rects:u,platform:a,elements:{reference:t,floating:r}});f=_??f,g=w??g,v={...v,[b]:{...v[b],...k}},I&&y<=50&&(y++,typeof I=="object"&&(I.placement&&(h=I.placement),I.rects&&(u=I.rects===!0?await a.getElementRects({reference:t,floating:r,strategy:e}):I.rects),{x:f,y:g}=nr(u,h,d)),p=-1)}return{x:f,y:g,placement:h,strategy:e,middlewareData:v}};async function Ve(t,r){var o;r===void 0&&(r={});const{x:i,y:e,platform:n,rects:a,elements:l,strategy:d}=t,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:g="floating",altBoundary:h=!1,padding:v=0}=me(r,t),y=zr(v),b=l[h?g==="floating"?"reference":"floating":g],x=gt(await n.getClippingRect({element:(o=await(n.isElement==null?void 0:n.isElement(b)))==null||o?b:b.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(l.floating)),boundary:u,rootBoundary:f,strategy:d})),_=g==="floating"?{x:i,y:e,width:a.floating.width,height:a.floating.height}:a.reference,w=await(n.getOffsetParent==null?void 0:n.getOffsetParent(l.floating)),k=await(n.isElement==null?void 0:n.isElement(w))?await(n.getScale==null?void 0:n.getScale(w))||{x:1,y:1}:{x:1,y:1},I=gt(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:_,offsetParent:w,strategy:d}):_);return{top:(x.top-I.top+y.top)/k.y,bottom:(I.bottom-x.bottom+y.bottom)/k.y,left:(x.left-I.left+y.left)/k.x,right:(I.right-x.right+y.right)/k.x}}const Fc=t=>({name:"arrow",options:t,async fn(r){const{x:o,y:i,placement:e,rects:n,platform:a,elements:l,middlewareData:d}=r,{element:u,padding:f=0}=me(t,r)||{};if(u==null)return{};const g=zr(f),h={x:o,y:i},v=cn(e),y=ln(v),p=await a.getDimensions(u),b=v==="y",x=b?"top":"left",_=b?"bottom":"right",w=b?"clientHeight":"clientWidth",k=n.reference[y]+n.reference[v]-h[v]-n.floating[y],I=h[v]-n.reference[v],P=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let O=P?P[w]:0;(!O||!await(a.isElement==null?void 0:a.isElement(P)))&&(O=l.floating[w]||n.floating[y]);const E=k/2-I/2,A=O/2-p[y]/2-1,U=ye(g[x],A),W=ye(g[_],A),B=U,z=O-p[y]-W,T=O/2-p[y]/2+E,J=Kt(B,T,z),L=!d.arrow&&Te(e)!=null&&T!==J&&n.reference[y]/2-(T<B?U:W)-p[y]/2<0,M=L?T<B?T-B:T-z:0;return{[v]:h[v]+M,data:{[v]:J,centerOffset:T-J-M,...L&&{alignmentOffset:M}},reset:L}}}),Vc=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(r){var o,i;const{placement:e,middlewareData:n,rects:a,initialPlacement:l,platform:d,elements:u}=r,{mainAxis:f=!0,crossAxis:g=!0,fallbackPlacements:h,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:p=!0,...b}=me(t,r);if((o=n.arrow)!=null&&o.alignmentOffset)return{};const x=ge(e),_=se(l),w=ge(l)===l,k=await(d.isRTL==null?void 0:d.isRTL(u.floating)),I=h||(w||!p?[mt(l)]:Tc(l)),P=y!=="none";!h&&P&&I.push(...Lc(l,p,y,k));const O=[l,...I],E=await Ve(r,b),A=[];let U=((i=n.flip)==null?void 0:i.overflows)||[];if(f&&A.push(E[x]),g){const T=Uc(e,a,k);A.push(E[T[0]],E[T[1]])}if(U=[...U,{placement:e,overflows:A}],!A.every(T=>T<=0)){var W,B;const T=(((W=n.flip)==null?void 0:W.index)||0)+1,J=O[T];if(J&&(!(g==="alignment"?_!==se(J):!1)||U.every(C=>se(C.placement)===_?C.overflows[0]>0:!0)))return{data:{index:T,overflows:U},reset:{placement:J}};let L=(B=U.filter(M=>M.overflows[0]<=0).sort((M,C)=>M.overflows[1]-C.overflows[1])[0])==null?void 0:B.placement;if(!L)switch(v){case"bestFit":{var z;const M=(z=U.filter(C=>{if(P){const F=se(C.placement);return F===_||F==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(F=>F>0).reduce((F,re)=>F+re,0)]).sort((C,F)=>C[1]-F[1])[0])==null?void 0:z[0];M&&(L=M);break}case"initialPlacement":L=l;break}if(e!==L)return{reset:{placement:L}}}return{}}}};function rr(t,r){return{top:t.top-r.height,right:t.right-r.width,bottom:t.bottom-r.height,left:t.left-r.width}}function ir(t){return Pc.some(r=>t[r]>=0)}const Wc=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(r){const{rects:o}=r,{strategy:i="referenceHidden",...e}=me(t,r);switch(i){case"referenceHidden":{const n=await Ve(r,{...e,elementContext:"reference"}),a=rr(n,o.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:ir(a)}}}case"escaped":{const n=await Ve(r,{...e,altBoundary:!0}),a=rr(n,o.floating);return{data:{escapedOffsets:a,escaped:ir(a)}}}default:return{}}}}},Lr=new Set(["left","top"]);async function Bc(t,r){const{placement:o,platform:i,elements:e}=t,n=await(i.isRTL==null?void 0:i.isRTL(e.floating)),a=ge(o),l=Te(o),d=se(o)==="y",u=Lr.has(a)?-1:1,f=n&&d?-1:1,g=me(r,t);let{mainAxis:h,crossAxis:v,alignmentAxis:y}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return l&&typeof y=="number"&&(v=l==="end"?y*-1:y),d?{x:v*f,y:h*u}:{x:h*u,y:v*f}}const Gc=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(r){var o,i;const{x:e,y:n,placement:a,middlewareData:l}=r,d=await Bc(r,t);return a===((o=l.offset)==null?void 0:o.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:e+d.x,y:n+d.y,data:{...d,placement:a}}}}},Jc=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(r){const{x:o,y:i,placement:e}=r,{mainAxis:n=!0,crossAxis:a=!1,limiter:l={fn:b=>{let{x,y:_}=b;return{x,y:_}}},...d}=me(t,r),u={x:o,y:i},f=await Ve(r,d),g=se(ge(e)),h=sn(g);let v=u[h],y=u[g];if(n){const b=h==="y"?"top":"left",x=h==="y"?"bottom":"right",_=v+f[b],w=v-f[x];v=Kt(_,v,w)}if(a){const b=g==="y"?"top":"left",x=g==="y"?"bottom":"right",_=y+f[b],w=y-f[x];y=Kt(_,y,w)}const p=l.fn({...r,[h]:v,[g]:y});return{...p,data:{x:p.x-o,y:p.y-i,enabled:{[h]:n,[g]:a}}}}}},Kc=function(t){return t===void 0&&(t={}),{options:t,fn(r){const{x:o,y:i,placement:e,rects:n,middlewareData:a}=r,{offset:l=0,mainAxis:d=!0,crossAxis:u=!0}=me(t,r),f={x:o,y:i},g=se(e),h=sn(g);let v=f[h],y=f[g];const p=me(l,r),b=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(d){const w=h==="y"?"height":"width",k=n.reference[h]-n.floating[w]+b.mainAxis,I=n.reference[h]+n.reference[w]-b.mainAxis;v<k?v=k:v>I&&(v=I)}if(u){var x,_;const w=h==="y"?"width":"height",k=Lr.has(ge(e)),I=n.reference[g]-n.floating[w]+(k&&((x=a.offset)==null?void 0:x[g])||0)+(k?0:b.crossAxis),P=n.reference[g]+n.reference[w]+(k?0:((_=a.offset)==null?void 0:_[g])||0)-(k?b.crossAxis:0);y<I?y=I:y>P&&(y=P)}return{[h]:v,[g]:y}}}},Hc=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(r){var o,i;const{placement:e,rects:n,platform:a,elements:l}=r,{apply:d=()=>{},...u}=me(t,r),f=await Ve(r,u),g=ge(e),h=Te(e),v=se(e)==="y",{width:y,height:p}=n.floating;let b,x;g==="top"||g==="bottom"?(b=g,x=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(x=g,b=h==="end"?"top":"bottom");const _=p-f.top-f.bottom,w=y-f.left-f.right,k=ye(p-f[b],_),I=ye(y-f[x],w),P=!r.middlewareData.shift;let O=k,E=I;if((o=r.middlewareData.shift)!=null&&o.enabled.x&&(E=w),(i=r.middlewareData.shift)!=null&&i.enabled.y&&(O=_),P&&!h){const U=K(f.left,0),W=K(f.right,0),B=K(f.top,0),z=K(f.bottom,0);v?E=y-2*(U!==0||W!==0?U+W:K(f.left,f.right)):O=p-2*(B!==0||z!==0?B+z:K(f.top,f.bottom))}await d({...r,availableWidth:E,availableHeight:O});const A=await a.getDimensions(l.floating);return y!==A.width||p!==A.height?{reset:{rects:!0}}:{}}}};function yt(){return typeof window<"u"}function Ae(t){return Mr(t)?(t.nodeName||"").toLowerCase():"#document"}function H(t){var r;return(t==null||(r=t.ownerDocument)==null?void 0:r.defaultView)||window}function de(t){var r;return(r=(Mr(t)?t.ownerDocument:t.document)||window.document)==null?void 0:r.documentElement}function Mr(t){return yt()?t instanceof Node||t instanceof H(t).Node:!1}function ee(t){return yt()?t instanceof Element||t instanceof H(t).Element:!1}function ue(t){return yt()?t instanceof HTMLElement||t instanceof H(t).HTMLElement:!1}function or(t){return!yt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof H(t).ShadowRoot}const qc=new Set(["inline","contents"]);function Ke(t){const{overflow:r,overflowX:o,overflowY:i,display:e}=te(t);return/auto|scroll|overlay|hidden|clip/.test(r+i+o)&&!qc.has(e)}const Xc=new Set(["table","td","th"]);function Yc(t){return Xc.has(Ae(t))}const Qc=[":popover-open",":modal"];function bt(t){return Qc.some(r=>{try{return t.matches(r)}catch{return!1}})}const eu=["transform","translate","scale","rotate","perspective"],tu=["transform","translate","scale","rotate","perspective","filter"],nu=["paint","layout","strict","content"];function un(t){const r=dn(),o=ee(t)?te(t):t;return eu.some(i=>o[i]?o[i]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!r&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!r&&(o.filter?o.filter!=="none":!1)||tu.some(i=>(o.willChange||"").includes(i))||nu.some(i=>(o.contain||"").includes(i))}function ru(t){let r=be(t);for(;ue(r)&&!Ee(r);){if(un(r))return r;if(bt(r))return null;r=be(r)}return null}function dn(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const iu=new Set(["html","body","#document"]);function Ee(t){return iu.has(Ae(t))}function te(t){return H(t).getComputedStyle(t)}function $t(t){return ee(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function be(t){if(Ae(t)==="html")return t;const r=t.assignedSlot||t.parentNode||or(t)&&t.host||de(t);return or(r)?r.host:r}function Zr(t){const r=be(t);return Ee(r)?t.ownerDocument?t.ownerDocument.body:t.body:ue(r)&&Ke(r)?r:Zr(r)}function We(t,r,o){var i;r===void 0&&(r=[]),o===void 0&&(o=!0);const e=Zr(t),n=e===((i=t.ownerDocument)==null?void 0:i.body),a=H(e);if(n){const l=qt(a);return r.concat(a,a.visualViewport||[],Ke(e)?e:[],l&&o?We(l):[])}return r.concat(e,We(e,[],o))}function qt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Fr(t){const r=te(t);let o=parseFloat(r.width)||0,i=parseFloat(r.height)||0;const e=ue(t),n=e?t.offsetWidth:o,a=e?t.offsetHeight:i,l=ft(o)!==n||ft(i)!==a;return l&&(o=n,i=a),{width:o,height:i,$:l}}function fn(t){return ee(t)?t:t.contextElement}function Pe(t){const r=fn(t);if(!ue(r))return le(1);const o=r.getBoundingClientRect(),{width:i,height:e,$:n}=Fr(r);let a=(n?ft(o.width):o.width)/i,l=(n?ft(o.height):o.height)/e;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const ou=le(0);function Vr(t){const r=H(t);return!dn()||!r.visualViewport?ou:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function au(t,r,o){return r===void 0&&(r=!1),!o||r&&o!==H(t)?!1:r}function _e(t,r,o,i){r===void 0&&(r=!1),o===void 0&&(o=!1);const e=t.getBoundingClientRect(),n=fn(t);let a=le(1);r&&(i?ee(i)&&(a=Pe(i)):a=Pe(t));const l=au(n,o,i)?Vr(n):le(0);let d=(e.left+l.x)/a.x,u=(e.top+l.y)/a.y,f=e.width/a.x,g=e.height/a.y;if(n){const h=H(n),v=i&&ee(i)?H(i):i;let y=h,p=qt(y);for(;p&&i&&v!==y;){const b=Pe(p),x=p.getBoundingClientRect(),_=te(p),w=x.left+(p.clientLeft+parseFloat(_.paddingLeft))*b.x,k=x.top+(p.clientTop+parseFloat(_.paddingTop))*b.y;d*=b.x,u*=b.y,f*=b.x,g*=b.y,d+=w,u+=k,y=H(p),p=qt(y)}}return gt({width:f,height:g,x:d,y:u})}function mn(t,r){const o=$t(t).scrollLeft;return r?r.left+o:_e(de(t)).left+o}function Wr(t,r,o){o===void 0&&(o=!1);const i=t.getBoundingClientRect(),e=i.left+r.scrollLeft-(o?0:mn(t,i)),n=i.top+r.scrollTop;return{x:e,y:n}}function su(t){let{elements:r,rect:o,offsetParent:i,strategy:e}=t;const n=e==="fixed",a=de(i),l=r?bt(r.floating):!1;if(i===a||l&&n)return o;let d={scrollLeft:0,scrollTop:0},u=le(1);const f=le(0),g=ue(i);if((g||!g&&!n)&&((Ae(i)!=="body"||Ke(a))&&(d=$t(i)),ue(i))){const v=_e(i);u=Pe(i),f.x=v.x+i.clientLeft,f.y=v.y+i.clientTop}const h=a&&!g&&!n?Wr(a,d,!0):le(0);return{width:o.width*u.x,height:o.height*u.y,x:o.x*u.x-d.scrollLeft*u.x+f.x+h.x,y:o.y*u.y-d.scrollTop*u.y+f.y+h.y}}function lu(t){return Array.from(t.getClientRects())}function cu(t){const r=de(t),o=$t(t),i=t.ownerDocument.body,e=K(r.scrollWidth,r.clientWidth,i.scrollWidth,i.clientWidth),n=K(r.scrollHeight,r.clientHeight,i.scrollHeight,i.clientHeight);let a=-o.scrollLeft+mn(t);const l=-o.scrollTop;return te(i).direction==="rtl"&&(a+=K(r.clientWidth,i.clientWidth)-e),{width:e,height:n,x:a,y:l}}function uu(t,r){const o=H(t),i=de(t),e=o.visualViewport;let n=i.clientWidth,a=i.clientHeight,l=0,d=0;if(e){n=e.width,a=e.height;const u=dn();(!u||u&&r==="fixed")&&(l=e.offsetLeft,d=e.offsetTop)}return{width:n,height:a,x:l,y:d}}const du=new Set(["absolute","fixed"]);function fu(t,r){const o=_e(t,!0,r==="fixed"),i=o.top+t.clientTop,e=o.left+t.clientLeft,n=ue(t)?Pe(t):le(1),a=t.clientWidth*n.x,l=t.clientHeight*n.y,d=e*n.x,u=i*n.y;return{width:a,height:l,x:d,y:u}}function ar(t,r,o){let i;if(r==="viewport")i=uu(t,o);else if(r==="document")i=cu(de(t));else if(ee(r))i=fu(r,o);else{const e=Vr(t);i={x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}return gt(i)}function Br(t,r){const o=be(t);return o===r||!ee(o)||Ee(o)?!1:te(o).position==="fixed"||Br(o,r)}function mu(t,r){const o=r.get(t);if(o)return o;let i=We(t,[],!1).filter(l=>ee(l)&&Ae(l)!=="body"),e=null;const n=te(t).position==="fixed";let a=n?be(t):t;for(;ee(a)&&!Ee(a);){const l=te(a),d=un(a);!d&&l.position==="fixed"&&(e=null),(n?!d&&!e:!d&&l.position==="static"&&!!e&&du.has(e.position)||Ke(a)&&!d&&Br(t,a))?i=i.filter(f=>f!==a):e=l,a=be(a)}return r.set(t,i),i}function gu(t){let{element:r,boundary:o,rootBoundary:i,strategy:e}=t;const a=[...o==="clippingAncestors"?bt(r)?[]:mu(r,this._c):[].concat(o),i],l=a[0],d=a.reduce((u,f)=>{const g=ar(r,f,e);return u.top=K(g.top,u.top),u.right=ye(g.right,u.right),u.bottom=ye(g.bottom,u.bottom),u.left=K(g.left,u.left),u},ar(r,l,e));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function pu(t){const{width:r,height:o}=Fr(t);return{width:r,height:o}}function vu(t,r,o){const i=ue(r),e=de(r),n=o==="fixed",a=_e(t,!0,n,r);let l={scrollLeft:0,scrollTop:0};const d=le(0);function u(){d.x=mn(e)}if(i||!i&&!n)if((Ae(r)!=="body"||Ke(e))&&(l=$t(r)),i){const v=_e(r,!0,n,r);d.x=v.x+r.clientLeft,d.y=v.y+r.clientTop}else e&&u();n&&!i&&e&&u();const f=e&&!i&&!n?Wr(e,l):le(0),g=a.left+l.scrollLeft-d.x-f.x,h=a.top+l.scrollTop-d.y-f.y;return{x:g,y:h,width:a.width,height:a.height}}function Ut(t){return te(t).position==="static"}function sr(t,r){if(!ue(t)||te(t).position==="fixed")return null;if(r)return r(t);let o=t.offsetParent;return de(t)===o&&(o=o.ownerDocument.body),o}function Gr(t,r){const o=H(t);if(bt(t))return o;if(!ue(t)){let e=be(t);for(;e&&!Ee(e);){if(ee(e)&&!Ut(e))return e;e=be(e)}return o}let i=sr(t,r);for(;i&&Yc(i)&&Ut(i);)i=sr(i,r);return i&&Ee(i)&&Ut(i)&&!un(i)?o:i||ru(t)||o}const hu=async function(t){const r=this.getOffsetParent||Gr,o=this.getDimensions,i=await o(t.floating);return{reference:vu(t.reference,await r(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function yu(t){return te(t).direction==="rtl"}const bu={convertOffsetParentRelativeRectToViewportRelativeRect:su,getDocumentElement:de,getClippingRect:gu,getOffsetParent:Gr,getElementRects:hu,getClientRects:lu,getDimensions:pu,getScale:Pe,isElement:ee,isRTL:yu};function Jr(t,r){return t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height}function $u(t,r){let o=null,i;const e=de(t);function n(){var l;clearTimeout(i),(l=o)==null||l.disconnect(),o=null}function a(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),n();const u=t.getBoundingClientRect(),{left:f,top:g,width:h,height:v}=u;if(l||r(),!h||!v)return;const y=Qe(g),p=Qe(e.clientWidth-(f+h)),b=Qe(e.clientHeight-(g+v)),x=Qe(f),w={rootMargin:-y+"px "+-p+"px "+-b+"px "+-x+"px",threshold:K(0,ye(1,d))||1};let k=!0;function I(P){const O=P[0].intersectionRatio;if(O!==d){if(!k)return a();O?a(!1,O):i=setTimeout(()=>{a(!1,1e-7)},1e3)}O===1&&!Jr(u,t.getBoundingClientRect())&&a(),k=!1}try{o=new IntersectionObserver(I,{...w,root:e.ownerDocument})}catch{o=new IntersectionObserver(I,w)}o.observe(t)}return a(!0),n}function xu(t,r,o,i){i===void 0&&(i={});const{ancestorScroll:e=!0,ancestorResize:n=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=i,u=fn(t),f=e||n?[...u?We(u):[],...We(r)]:[];f.forEach(x=>{e&&x.addEventListener("scroll",o,{passive:!0}),n&&x.addEventListener("resize",o)});const g=u&&l?$u(u,o):null;let h=-1,v=null;a&&(v=new ResizeObserver(x=>{let[_]=x;_&&_.target===u&&v&&(v.unobserve(r),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=v)==null||w.observe(r)})),o()}),u&&!d&&v.observe(u),v.observe(r));let y,p=d?_e(t):null;d&&b();function b(){const x=_e(t);p&&!Jr(p,x)&&o(),p=x,y=requestAnimationFrame(b)}return o(),()=>{var x;f.forEach(_=>{e&&_.removeEventListener("scroll",o),n&&_.removeEventListener("resize",o)}),g?.(),(x=v)==null||x.disconnect(),v=null,d&&cancelAnimationFrame(y)}}const _u=Gc,wu=Jc,Su=Vc,ku=Hc,ju=Wc,lr=Fc,Iu=Kc,Nu=(t,r,o)=>{const i=new Map,e={platform:bu,...o},n={...e.platform,_c:i};return Zc(t,r,{...e,platform:n})};var Ou=typeof document<"u",Pu=function(){},st=Ou?N.useLayoutEffect:Pu;function pt(t,r){if(t===r)return!0;if(typeof t!=typeof r)return!1;if(typeof t=="function"&&t.toString()===r.toString())return!0;let o,i,e;if(t&&r&&typeof t=="object"){if(Array.isArray(t)){if(o=t.length,o!==r.length)return!1;for(i=o;i--!==0;)if(!pt(t[i],r[i]))return!1;return!0}if(e=Object.keys(t),o=e.length,o!==Object.keys(r).length)return!1;for(i=o;i--!==0;)if(!{}.hasOwnProperty.call(r,e[i]))return!1;for(i=o;i--!==0;){const n=e[i];if(!(n==="_owner"&&t.$$typeof)&&!pt(t[n],r[n]))return!1}return!0}return t!==t&&r!==r}function Kr(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function cr(t,r){const o=Kr(t);return Math.round(r*o)/o}function Tt(t){const r=m.useRef(t);return st(()=>{r.current=t}),r}function Cu(t){t===void 0&&(t={});const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:e,elements:{reference:n,floating:a}={},transform:l=!0,whileElementsMounted:d,open:u}=t,[f,g]=m.useState({x:0,y:0,strategy:o,placement:r,middlewareData:{},isPositioned:!1}),[h,v]=m.useState(i);pt(h,i)||v(i);const[y,p]=m.useState(null),[b,x]=m.useState(null),_=m.useCallback(C=>{C!==P.current&&(P.current=C,p(C))},[]),w=m.useCallback(C=>{C!==O.current&&(O.current=C,x(C))},[]),k=n||y,I=a||b,P=m.useRef(null),O=m.useRef(null),E=m.useRef(f),A=d!=null,U=Tt(d),W=Tt(e),B=Tt(u),z=m.useCallback(()=>{if(!P.current||!O.current)return;const C={placement:r,strategy:o,middleware:h};W.current&&(C.platform=W.current),Nu(P.current,O.current,C).then(F=>{const re={...F,isPositioned:B.current!==!1};T.current&&!pt(E.current,re)&&(E.current=re,wr.flushSync(()=>{g(re)}))})},[h,r,o,W,B]);st(()=>{u===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,g(C=>({...C,isPositioned:!1})))},[u]);const T=m.useRef(!1);st(()=>(T.current=!0,()=>{T.current=!1}),[]),st(()=>{if(k&&(P.current=k),I&&(O.current=I),k&&I){if(U.current)return U.current(k,I,z);z()}},[k,I,z,U,A]);const J=m.useMemo(()=>({reference:P,floating:O,setReference:_,setFloating:w}),[_,w]),L=m.useMemo(()=>({reference:k,floating:I}),[k,I]),M=m.useMemo(()=>{const C={position:o,left:0,top:0};if(!L.floating)return C;const F=cr(L.floating,f.x),re=cr(L.floating,f.y);return l?{...C,transform:"translate("+F+"px, "+re+"px)",...Kr(L.floating)>=1.5&&{willChange:"transform"}}:{position:o,left:F,top:re}},[o,l,L.floating,f.x,f.y]);return m.useMemo(()=>({...f,update:z,refs:J,elements:L,floatingStyles:M}),[f,z,J,L,M])}const Eu=t=>{function r(o){return{}.hasOwnProperty.call(o,"current")}return{name:"arrow",options:t,fn(o){const{element:i,padding:e}=typeof t=="function"?t(o):t;return i&&r(i)?i.current!=null?lr({element:i.current,padding:e}).fn(o):{}:i?lr({element:i,padding:e}).fn(o):{}}}},Du=(t,r)=>({..._u(t),options:[t,r]}),Uu=(t,r)=>({...wu(t),options:[t,r]}),Tu=(t,r)=>({...Iu(t),options:[t,r]}),Au=(t,r)=>({...Su(t),options:[t,r]}),Ru=(t,r)=>({...ku(t),options:[t,r]}),zu=(t,r)=>({...ju(t),options:[t,r]}),Lu=(t,r)=>({...Eu(t),options:[t,r]});var Mu="Arrow",Hr=m.forwardRef((t,r)=>{const{children:o,width:i=10,height:e=5,...n}=t;return c.jsx(Z.svg,{...n,ref:r,width:i,height:e,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?o:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Hr.displayName=Mu;var Zu=Hr;function Fu(t){const[r,o]=m.useState(void 0);return Y(()=>{if(t){o({width:t.offsetWidth,height:t.offsetHeight});const i=new ResizeObserver(e=>{if(!Array.isArray(e)||!e.length)return;const n=e[0];let a,l;if("borderBoxSize"in n){const d=n.borderBoxSize,u=Array.isArray(d)?d[0]:d;a=u.inlineSize,l=u.blockSize}else a=t.offsetWidth,l=t.offsetHeight;o({width:a,height:l})});return i.observe(t,{box:"border-box"}),()=>i.unobserve(t)}else o(void 0)},[t]),r}var gn="Popper",[qr,xt]=Je(gn),[Vu,Xr]=qr(gn),Yr=t=>{const{__scopePopper:r,children:o}=t,[i,e]=m.useState(null);return c.jsx(Vu,{scope:r,anchor:i,onAnchorChange:e,children:o})};Yr.displayName=gn;var Qr="PopperAnchor",ei=m.forwardRef((t,r)=>{const{__scopePopper:o,virtualRef:i,...e}=t,n=Xr(Qr,o),a=m.useRef(null),l=G(r,a),d=m.useRef(null);return m.useEffect(()=>{const u=d.current;d.current=i?.current||a.current,u!==d.current&&n.onAnchorChange(d.current)}),i?null:c.jsx(Z.div,{...e,ref:l})});ei.displayName=Qr;var pn="PopperContent",[Wu,Bu]=qr(pn),ti=m.forwardRef((t,r)=>{const{__scopePopper:o,side:i="bottom",sideOffset:e=0,align:n="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:g="partial",hideWhenDetached:h=!1,updatePositionStrategy:v="optimized",onPlaced:y,...p}=t,b=Xr(pn,o),[x,_]=m.useState(null),w=G(r,Re=>_(Re)),[k,I]=m.useState(null),P=Fu(k),O=P?.width??0,E=P?.height??0,A=i+(n!=="center"?"-"+n:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},W=Array.isArray(u)?u:[u],B=W.length>0,z={padding:U,boundary:W.filter(Ju),altBoundary:B},{refs:T,floatingStyles:J,placement:L,isPositioned:M,middlewareData:C}=Cu({strategy:"fixed",placement:A,whileElementsMounted:(...Re)=>xu(...Re,{animationFrame:v==="always"}),elements:{reference:b.anchor},middleware:[Du({mainAxis:e+E,alignmentAxis:a}),d&&Uu({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?Tu():void 0,...z}),d&&Au({...z}),Ru({...z,apply:({elements:Re,rects:An,availableWidth:Oo,availableHeight:Po})=>{const{width:Co,height:Eo}=An.reference,Xe=Re.floating.style;Xe.setProperty("--radix-popper-available-width",`${Oo}px`),Xe.setProperty("--radix-popper-available-height",`${Po}px`),Xe.setProperty("--radix-popper-anchor-width",`${Co}px`),Xe.setProperty("--radix-popper-anchor-height",`${Eo}px`)}}),k&&Lu({element:k,padding:l}),Ku({arrowWidth:O,arrowHeight:E}),h&&zu({strategy:"referenceHidden",...z})]}),[F,re]=ii(L),Tn=xe(y);Y(()=>{M&&Tn?.()},[M,Tn]);const So=C.arrow?.x,ko=C.arrow?.y,jo=C.arrow?.centerOffset!==0,[Io,No]=m.useState();return Y(()=>{x&&No(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:M?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Io,"--radix-popper-transform-origin":[C.transformOrigin?.x,C.transformOrigin?.y].join(" "),...C.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:c.jsx(Wu,{scope:o,placedSide:F,onArrowChange:I,arrowX:So,arrowY:ko,shouldHideArrow:jo,children:c.jsx(Z.div,{"data-side":F,"data-align":re,...p,ref:w,style:{...p.style,animation:M?void 0:"none"}})})})});ti.displayName=pn;var ni="PopperArrow",Gu={top:"bottom",right:"left",bottom:"top",left:"right"},ri=m.forwardRef(function(r,o){const{__scopePopper:i,...e}=r,n=Bu(ni,i),a=Gu[n.placedSide];return c.jsx("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:c.jsx(Zu,{...e,ref:o,style:{...e.style,display:"block"}})})});ri.displayName=ni;function Ju(t){return t!==null}var Ku=t=>({name:"transformOrigin",options:t,fn(r){const{placement:o,rects:i,middlewareData:e}=r,a=e.arrow?.centerOffset!==0,l=a?0:t.arrowWidth,d=a?0:t.arrowHeight,[u,f]=ii(o),g={start:"0%",center:"50%",end:"100%"}[f],h=(e.arrow?.x??0)+l/2,v=(e.arrow?.y??0)+d/2;let y="",p="";return u==="bottom"?(y=a?g:`${h}px`,p=`${-d}px`):u==="top"?(y=a?g:`${h}px`,p=`${i.floating.height+d}px`):u==="right"?(y=`${-d}px`,p=a?g:`${v}px`):u==="left"&&(y=`${i.floating.width+d}px`,p=a?g:`${v}px`),{data:{x:y,y:p}}}});function ii(t){const[r,o="center"]=t.split("-");return[r,o]}var oi=Yr,vn=ei,ai=ti,si=ri,Hu="Portal",_t=m.forwardRef((t,r)=>{const{container:o,...i}=t,[e,n]=m.useState(!1);Y(()=>n(!0),[]);const a=o||e&&globalThis?.document?.body;return a?_r.createPortal(c.jsx(Z.div,{...i,ref:r}),a):null});_t.displayName=Hu;function qu(t,r){return m.useReducer((o,i)=>r[o][i]??o,t)}var pe=t=>{const{present:r,children:o}=t,i=Xu(r),e=typeof o=="function"?o({present:i.isPresent}):m.Children.only(o),n=G(i.ref,Yu(e));return typeof o=="function"||i.isPresent?m.cloneElement(e,{ref:n}):null};pe.displayName="Presence";function Xu(t){const[r,o]=m.useState(),i=m.useRef(null),e=m.useRef(t),n=m.useRef("none"),a=t?"mounted":"unmounted",[l,d]=qu(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=et(i.current);n.current=l==="mounted"?u:"none"},[l]),Y(()=>{const u=i.current,f=e.current;if(f!==t){const h=n.current,v=et(u);t?d("MOUNT"):v==="none"||u?.display==="none"?d("UNMOUNT"):d(f&&h!==v?"ANIMATION_OUT":"UNMOUNT"),e.current=t}},[t,d]),Y(()=>{if(r){let u;const f=r.ownerDocument.defaultView??window,g=v=>{const p=et(i.current).includes(CSS.escape(v.animationName));if(v.target===r&&p&&(d("ANIMATION_END"),!e.current)){const b=r.style.animationFillMode;r.style.animationFillMode="forwards",u=f.setTimeout(()=>{r.style.animationFillMode==="forwards"&&(r.style.animationFillMode=b)})}},h=v=>{v.target===r&&(n.current=et(i.current))};return r.addEventListener("animationstart",h),r.addEventListener("animationcancel",g),r.addEventListener("animationend",g),()=>{f.clearTimeout(u),r.removeEventListener("animationstart",h),r.removeEventListener("animationcancel",g),r.removeEventListener("animationend",g)}}else d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:m.useCallback(u=>{i.current=u?getComputedStyle(u):null,o(u)},[])}}function et(t){return t?.animationName||"none"}function Yu(t){let r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?t.ref:(r=Object.getOwnPropertyDescriptor(t,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?t.props.ref:t.props.ref||t.ref)}var Qu=m[" useInsertionEffect ".trim().toString()]||Y;function wt({prop:t,defaultProp:r,onChange:o=()=>{},caller:i}){const[e,n,a]=ed({defaultProp:r,onChange:o}),l=t!==void 0,d=l?t:e;{const f=m.useRef(t!==void 0);m.useEffect(()=>{const g=f.current;g!==l&&console.warn(`${i} is changing from ${g?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,i])}const u=m.useCallback(f=>{if(l){const g=td(f)?f(t):f;g!==t&&a.current?.(g)}else n(f)},[l,t,n,a]);return[d,u]}function ed({defaultProp:t,onChange:r}){const[o,i]=m.useState(t),e=m.useRef(o),n=m.useRef(r);return Qu(()=>{n.current=r},[r]),m.useEffect(()=>{e.current!==o&&(n.current?.(o),e.current=o)},[o,e]),[o,i,n]}function td(t){return typeof t=="function"}var nd=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),rd="VisuallyHidden",li=m.forwardRef((t,r)=>c.jsx(Z.span,{...t,ref:r,style:{...nd,...t.style}}));li.displayName=rd;var id=li,[St]=Je("Tooltip",[xt]),kt=xt(),ci="TooltipProvider",od=700,Xt="tooltip.open",[ad,hn]=St(ci),ui=t=>{const{__scopeTooltip:r,delayDuration:o=od,skipDelayDuration:i=300,disableHoverableContent:e=!1,children:n}=t,a=m.useRef(!0),l=m.useRef(!1),d=m.useRef(0);return m.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),c.jsx(ad,{scope:r,isOpenDelayedRef:a,delayDuration:o,onOpen:m.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(u=>{l.current=u},[]),disableHoverableContent:e,children:n})};ui.displayName=ci;var Be="Tooltip",[sd,He]=St(Be),di=t=>{const{__scopeTooltip:r,children:o,open:i,defaultOpen:e,onOpenChange:n,disableHoverableContent:a,delayDuration:l}=t,d=hn(Be,t.__scopeTooltip),u=kt(r),[f,g]=m.useState(null),h=Oe(),v=m.useRef(0),y=a??d.disableHoverableContent,p=l??d.delayDuration,b=m.useRef(!1),[x,_]=wt({prop:i,defaultProp:e??!1,onChange:O=>{O?(d.onOpen(),document.dispatchEvent(new CustomEvent(Xt))):d.onClose(),n?.(O)},caller:Be}),w=m.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),k=m.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,_(!0)},[_]),I=m.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_(!1)},[_]),P=m.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,_(!0),v.current=0},p)},[p,_]);return m.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),c.jsx(oi,{...u,children:c.jsx(sd,{scope:r,contentId:h,open:x,stateAttribute:w,trigger:f,onTriggerChange:g,onTriggerEnter:m.useCallback(()=>{d.isOpenDelayedRef.current?P():k()},[d.isOpenDelayedRef,P,k]),onTriggerLeave:m.useCallback(()=>{y?I():(window.clearTimeout(v.current),v.current=0)},[I,y]),onOpen:k,onClose:I,disableHoverableContent:y,children:o})})};di.displayName=Be;var Yt="TooltipTrigger",fi=m.forwardRef((t,r)=>{const{__scopeTooltip:o,...i}=t,e=He(Yt,o),n=hn(Yt,o),a=kt(o),l=m.useRef(null),d=G(r,l,e.onTriggerChange),u=m.useRef(!1),f=m.useRef(!1),g=m.useCallback(()=>u.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),c.jsx(vn,{asChild:!0,...a,children:c.jsx(Z.button,{"aria-describedby":e.open?e.contentId:void 0,"data-state":e.stateAttribute,...i,ref:d,onPointerMove:R(t.onPointerMove,h=>{h.pointerType!=="touch"&&!f.current&&!n.isPointerInTransitRef.current&&(e.onTriggerEnter(),f.current=!0)}),onPointerLeave:R(t.onPointerLeave,()=>{e.onTriggerLeave(),f.current=!1}),onPointerDown:R(t.onPointerDown,()=>{e.open&&e.onClose(),u.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:R(t.onFocus,()=>{u.current||e.onOpen()}),onBlur:R(t.onBlur,e.onClose),onClick:R(t.onClick,e.onClose)})})});fi.displayName=Yt;var yn="TooltipPortal",[ld,cd]=St(yn,{forceMount:void 0}),mi=t=>{const{__scopeTooltip:r,forceMount:o,children:i,container:e}=t,n=He(yn,r);return c.jsx(ld,{scope:r,forceMount:o,children:c.jsx(pe,{present:o||n.open,children:c.jsx(_t,{asChild:!0,container:e,children:i})})})};mi.displayName=yn;var De="TooltipContent",gi=m.forwardRef((t,r)=>{const o=cd(De,t.__scopeTooltip),{forceMount:i=o.forceMount,side:e="top",...n}=t,a=He(De,t.__scopeTooltip);return c.jsx(pe,{present:i||a.open,children:a.disableHoverableContent?c.jsx(pi,{side:e,...n,ref:r}):c.jsx(ud,{side:e,...n,ref:r})})}),ud=m.forwardRef((t,r)=>{const o=He(De,t.__scopeTooltip),i=hn(De,t.__scopeTooltip),e=m.useRef(null),n=G(r,e),[a,l]=m.useState(null),{trigger:d,onClose:u}=o,f=e.current,{onPointerInTransitChange:g}=i,h=m.useCallback(()=>{l(null),g(!1)},[g]),v=m.useCallback((y,p)=>{const b=y.currentTarget,x={x:y.clientX,y:y.clientY},_=gd(x,b.getBoundingClientRect()),w=pd(x,_),k=vd(p.getBoundingClientRect()),I=yd([...w,...k]);l(I),g(!0)},[g]);return m.useEffect(()=>()=>h(),[h]),m.useEffect(()=>{if(d&&f){const y=b=>v(b,f),p=b=>v(b,d);return d.addEventListener("pointerleave",y),f.addEventListener("pointerleave",p),()=>{d.removeEventListener("pointerleave",y),f.removeEventListener("pointerleave",p)}}},[d,f,v,h]),m.useEffect(()=>{if(a){const y=p=>{const b=p.target,x={x:p.clientX,y:p.clientY},_=d?.contains(b)||f?.contains(b),w=!hd(x,a);_?h():w&&(h(),u())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[d,f,a,u,h]),c.jsx(pi,{...t,ref:n})}),[dd,fd]=St(Be,{isInside:!1}),md=gc("TooltipContent"),pi=m.forwardRef((t,r)=>{const{__scopeTooltip:o,children:i,"aria-label":e,onEscapeKeyDown:n,onPointerDownOutside:a,...l}=t,d=He(De,o),u=kt(o),{onClose:f}=d;return m.useEffect(()=>(document.addEventListener(Xt,f),()=>document.removeEventListener(Xt,f)),[f]),m.useEffect(()=>{if(d.trigger){const g=h=>{h.target?.contains(d.trigger)&&f()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,f]),c.jsx(ht,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:c.jsxs(ai,{"data-state":d.stateAttribute,...u,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[c.jsx(md,{children:i}),c.jsx(dd,{scope:o,isInside:!0,children:c.jsx(id,{id:d.contentId,role:"tooltip",children:e||i})})]})})});gi.displayName=De;var vi="TooltipArrow",hi=m.forwardRef((t,r)=>{const{__scopeTooltip:o,...i}=t,e=kt(o);return fd(vi,o).isInside?null:c.jsx(si,{...e,...i,ref:r})});hi.displayName=vi;function gd(t,r){const o=Math.abs(r.top-t.y),i=Math.abs(r.bottom-t.y),e=Math.abs(r.right-t.x),n=Math.abs(r.left-t.x);switch(Math.min(o,i,e,n)){case n:return"left";case e:return"right";case o:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function pd(t,r,o=5){const i=[];switch(r){case"top":i.push({x:t.x-o,y:t.y+o},{x:t.x+o,y:t.y+o});break;case"bottom":i.push({x:t.x-o,y:t.y-o},{x:t.x+o,y:t.y-o});break;case"left":i.push({x:t.x+o,y:t.y-o},{x:t.x+o,y:t.y+o});break;case"right":i.push({x:t.x-o,y:t.y-o},{x:t.x-o,y:t.y+o});break}return i}function vd(t){const{top:r,right:o,bottom:i,left:e}=t;return[{x:e,y:r},{x:o,y:r},{x:o,y:i},{x:e,y:i}]}function hd(t,r){const{x:o,y:i}=t;let e=!1;for(let n=0,a=r.length-1;n<r.length;a=n++){const l=r[n],d=r[a],u=l.x,f=l.y,g=d.x,h=d.y;f>i!=h>i&&o<(g-u)*(i-f)/(h-f)+u&&(e=!e)}return e}function yd(t){const r=t.slice();return r.sort((o,i)=>o.x<i.x?-1:o.x>i.x?1:o.y<i.y?-1:o.y>i.y?1:0),bd(r)}function bd(t){if(t.length<=1)return t.slice();const r=[];for(let i=0;i<t.length;i++){const e=t[i];for(;r.length>=2;){const n=r[r.length-1],a=r[r.length-2];if((n.x-a.x)*(e.y-a.y)>=(n.y-a.y)*(e.x-a.x))r.pop();else break}r.push(e)}r.pop();const o=[];for(let i=t.length-1;i>=0;i--){const e=t[i];for(;o.length>=2;){const n=o[o.length-1],a=o[o.length-2];if((n.x-a.x)*(e.y-a.y)>=(n.y-a.y)*(e.x-a.x))o.pop();else break}o.push(e)}return o.pop(),r.length===1&&o.length===1&&r[0].x===o[0].x&&r[0].y===o[0].y?r:r.concat(o)}var $d=ui,xd=di,_d=fi,wd=mi,Sd=gi,kd=hi;function yi({delayDuration:t=0,...r}){return c.jsx($d,{"data-slot":"tooltip-provider",delayDuration:t,...r})}function bn({...t}){return c.jsx(yi,{children:c.jsx(xd,{"data-slot":"tooltip",...t})})}function $n({...t}){return c.jsx(_d,{"data-slot":"tooltip-trigger",...t})}function xn({className:t,sideOffset:r=0,children:o,...i}){return c.jsx(wd,{children:c.jsxs(Sd,{"data-slot":"tooltip-content",sideOffset:r,className:$.cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...i,children:[o,c.jsx(kd,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}const Q=N.forwardRef(({children:t,tooltip:r,side:o="bottom",align:i="center",className:e,...n},a)=>c.jsxs(bn,{children:[c.jsx($n,{asChild:!0,children:c.jsxs(ce,{variant:"ghost",size:"icon",...n,className:$.cn("aui-button-icon size-6 p-1",e),ref:a,children:[c.jsx(oc,{children:t}),c.jsx("span",{className:"aui-sr-only sr-only",children:r})]})}),c.jsx(xn,{side:o,align:i,children:r})]}));Q.displayName="TooltipIconButton";function jd(t){return N.useMemo(()=>t.reduce((r,o)=>(r?.[o.language]&&!o.overrideExisting||(r={...r,[o.language]:{CodeHeader:o.Header??(()=>null),SyntaxHighlighter:o.Component??void 0}}),r),{}),[t])}const Id=()=>{const{plugins:t}=$.useElements(),r=jd(t);return c.jsx(Vt.MarkdownTextPrimitive,{remarkPlugins:[Uo],className:"aui-md",components:Pd,componentsByLanguage:r})},bi=N.memo(Id),Nd=({language:t,code:r})=>{const i=j.useAssistantState(({message:l})=>l).status?.type==="complete",{isCopied:e,copyToClipboard:n}=Od(),a=()=>{!r||e||n(r)};return i?c.jsxs("div",{className:"aui-code-header-root bg-muted-foreground/15 text-foreground dark:bg-muted-foreground/20 mt-4 flex items-center justify-between gap-4 rounded-t-lg px-4 py-2 text-sm font-semibold",children:[c.jsx("span",{className:"aui-code-header-language lowercase [&>span]:text-xs",children:t}),c.jsxs(Q,{tooltip:"Copy",onClick:a,children:[!e&&c.jsx(Cr,{}),e&&c.jsx(Ge,{})]})]}):null},Od=({copiedDuration:t=3e3}={})=>{const[r,o]=N.useState(!1);return{isCopied:r,copyToClipboard:e=>{e&&navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),t)})}}},Pd=Vt.unstable_memoizeMarkdownComponents({h1:({className:t,...r})=>c.jsx("h1",{className:$.cn("aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",t),...r}),h2:({className:t,...r})=>c.jsx("h2",{className:$.cn("aui-md-h2 mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",t),...r}),h3:({className:t,...r})=>c.jsx("h3",{className:$.cn("aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",t),...r}),h4:({className:t,...r})=>c.jsx("h4",{className:$.cn("aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",t),...r}),h5:({className:t,...r})=>c.jsx("h5",{className:$.cn("aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0",t),...r}),h6:({className:t,...r})=>c.jsx("h6",{className:$.cn("aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",t),...r}),p:({className:t,...r})=>c.jsx("p",{className:$.cn("aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",t),...r}),a:({className:t,...r})=>c.jsx("a",{className:$.cn("aui-md-a text-primary font-medium underline underline-offset-4",t),...r}),blockquote:({className:t,...r})=>c.jsx("blockquote",{className:$.cn("aui-md-blockquote border-l-2 pl-6 italic",t),...r}),ul:({className:t,...r})=>c.jsx("ul",{className:$.cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2",t),...r}),ol:({className:t,...r})=>c.jsx("ol",{className:$.cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2",t),...r}),hr:({className:t,...r})=>c.jsx("hr",{className:$.cn("aui-md-hr my-5 border-b",t),...r}),table:({className:t,...r})=>c.jsx("table",{className:$.cn("aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",t),...r}),th:({className:t,...r})=>c.jsx("th",{className:$.cn("aui-md-th bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [[align=center]]:text-center [[align=right]]:text-right",t),...r}),td:({className:t,...r})=>c.jsx("td",{className:$.cn("aui-md-td border-b border-l px-4 py-2 text-left last:border-r [[align=center]]:text-center [[align=right]]:text-right",t),...r}),tr:({className:t,...r})=>c.jsx("tr",{className:$.cn("aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",t),...r}),sup:({className:t,...r})=>c.jsx("sup",{className:$.cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline",t),...r}),pre:({className:t,...r})=>c.jsx("pre",{className:$.cn("aui-md-pre text-foreground bg-muted overflow-x-auto rounded-t-none! rounded-b-lg border border-t-0 p-4",t),...r}),code:function({className:r,...o}){const i=Vt.useIsMarkdownCodeBlock();return c.jsx("code",{className:$.cn(!i&&"aui-md-inline-code bg-muted rounded border font-semibold",r),...o})},CodeHeader:Nd}),Cd=s.union([s.object({type:s.literal("text"),text:s.string()}),s.object({type:s.literal("image"),data:s.string()})]).and(s.object({_meta:s.object({"getgram.ai/mime-type":s.string()}).optional()})),Ed=s.object({content:s.array(Cd)}).or(s._undefined$1());function $i(t){return t.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ")}const Dd=({toolName:t,status:r,result:o,args:i})=>{const n=j.useAssistantState(({message:h})=>h).parts.filter(h=>h.type==="tool-call"),a=n.findIndex(h=>h.toolName===t),l=N.useMemo(()=>r.type==="complete"?c.jsx(Ge,{className:"size-4 text-emerald-500"}):r.type==="incomplete"?c.jsx($.CircleAlert,{className:"size-4 text-rose-500"}):c.jsx(nn,{className:"text-muted-foreground size-4 animate-spin"}),[r]),d=$.useDensity(),[u,f]=N.useState(!1),g=h=>{h.stopPropagation(),f(!u)};return c.jsxs("div",{className:$.cn("aui-tool-fallback-root flex w-full flex-col",a!==-1&&"border-b",a===n.length-1&&"border-b-0"),children:[c.jsxs("button",{className:$.cn("aui-tool-fallback-header flex h-full w-full cursor-pointer items-center",d("py-xs"),d("px-md"),d("gap-md")),onClick:g,children:[c.jsx("div",{children:l}),c.jsx("div",{className:"select-none",children:$i(t)}),c.jsx("div",{className:"ml-auto",children:c.jsx(ce,{variant:"ghost",size:"icon",className:"cursor-pointer hover:bg-transparent",onClick:g,children:u?c.jsx(Pr,{className:"size-4"}):c.jsx(tn,{className:"size-4"})})})]}),c.jsx("div",{className:"bg-muted flex overflow-hidden transition-all duration-300 ease-out",style:{maxHeight:u?"1000px":"0"},children:u&&c.jsx(Ud,{result:o,args:i})})]})};function Ud({result:t,args:r}){const[o,i]=N.useState("result"),e=(n,a)=>{n.stopPropagation(),i(a)};return c.jsxs("div",{className:"flex w-full flex-col border-t",children:[c.jsx(Td,{tabs:[{id:"result",label:"Output"},{id:"args",label:"Arguments"}],activeTab:o,onTabClick:e}),c.jsxs("div",{className:"bg-background relative flex w-full flex-col items-start gap-4 border-t",children:[c.jsx("div",{className:$.cn("w-full transition-opacity",o==="args"?"opacity-100":"pointer-events-none absolute opacity-0"),children:c.jsx(xi,{text:JSON.stringify(r,null,2),language:"json"})}),c.jsx("div",{className:$.cn("w-full transition-opacity",o==="result"?"opacity-100":"pointer-events-none absolute opacity-0"),children:c.jsx(Ad,{result:t})})]})]})}function Td({tabs:t,activeTab:r,onTabClick:o}){return c.jsx("div",{className:"bg-muted flex h-full items-center px-3 py-2",children:t.map(i=>c.jsx("button",{onClick:e=>o(e,i.id),className:$.cn("cursor-pointer rounded-md px-3 py-1 text-sm font-medium transition-all",r===i.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:i.label},i.id))})}function Ad({result:t,className:r}){const o=Ed.parse(t);return c.jsx("div",{className:$.cn("w-full",r),children:o?.content.map((i,e)=>{switch(i.type){case"text":{const n=Rd(i._meta?.["getgram.ai/mime-type"]??"text/plain"),a=zd(i.text,n);return c.jsx(xi,{text:a,language:n},i.text)}case"image":{const n=`data:image/png;base64,${i.data}`;return c.jsx("div",{className:"flex items-center justify-center rounded-lg p-5",style:{backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
9
|
+
`)}`}const Ql=({children:t,config:r})=>{const[o,i]=N.useState(r.model?.defaultModel??s.MODELS[0]),[e,n]=N.useState(r.modal?.defaultExpanded??!1),[a,l]=N.useState(r.modal?.defaultOpen),d=r.plugins??$.recommended,u=sl({sendAutomaticallyWhen:s.lastAssistantMessageIsCompleteWithToolCalls,transport:new Gt({api:r.chatEndpoint??ql,prepareSendMessagesRequest:({id:f,messages:g})=>{const h=u.thread.getModelContext(),v=Gl(Jl(h?.tools??{}));return{body:{messages:g,system:Yl(r.systemPrompt,d),id:f,tools:v,config:{mcp:r.mcp,environment:r.environment,projectSlug:r.projectSlug,model:o}}}}})});return c.jsx(j.AssistantRuntimeProvider,{runtime:u,children:c.jsxs($.ElementsContext.Provider,{value:{config:r,setModel:i,model:o,isExpanded:e,setIsExpanded:n,isOpen:a??!1,setIsOpen:l,plugins:d},children:[t,c.jsx(Hl,{tools:r.tools?.frontendTools??{}})]})})};function Hn(t,r){if(typeof t=="function")return t(r);t!=null&&(t.current=r)}function on(...t){return r=>{let o=!1;const i=t.map(e=>{const n=Hn(e,r);return!o&&typeof n=="function"&&(o=!0),n});if(o)return()=>{for(let e=0;e<i.length;e++){const n=i[e];typeof n=="function"?n():Hn(t[e],null)}}}}function G(...t){return m.useCallback(on(...t),t)}var ec=Symbol.for("react.lazy"),dt=m[" use ".trim().toString()];function tc(t){return typeof t=="object"&&t!==null&&"then"in t}function Er(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===ec&&"_payload"in t&&tc(t._payload)}function Dr(t){const r=rc(t),o=m.forwardRef((i,e)=>{let{children:n,...a}=i;Er(n)&&typeof dt=="function"&&(n=dt(n._payload));const l=m.Children.toArray(n),d=l.find(ac);if(d){const u=d.props.children,f=l.map(g=>g===d?m.Children.count(u)>1?m.Children.only(null):m.isValidElement(u)?u.props.children:null:g);return c.jsx(r,{...a,ref:e,children:m.isValidElement(u)?m.cloneElement(u,void 0,f):null})}return c.jsx(r,{...a,ref:e,children:n})});return o.displayName=`${t}.Slot`,o}var nc=Dr("Slot");function rc(t){const r=m.forwardRef((o,i)=>{let{children:e,...n}=o;if(Er(e)&&typeof dt=="function"&&(e=dt(e._payload)),m.isValidElement(e)){const a=lc(e),l=sc(n,e.props);return e.type!==m.Fragment&&(l.ref=i?on(i,a):a),m.cloneElement(e,l)}return m.Children.count(e)>1?m.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var Ur=Symbol("radix.slottable");function ic(t){const r=({children:o})=>c.jsx(c.Fragment,{children:o});return r.displayName=`${t}.Slottable`,r.__radixId=Ur,r}var oc=ic("Slottable");function ac(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Ur}function sc(t,r){const o={...r};for(const i in r){const e=t[i],n=r[i];/^on[A-Z]/.test(i)?e&&n?o[i]=(...l)=>{const d=n(...l);return e(...l),d}:e&&(o[i]=e):i==="style"?o[i]={...e,...n}:i==="className"&&(o[i]=[e,n].filter(Boolean).join(" "))}return{...t,...o}}function lc(t){let r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?t.ref:(r=Object.getOwnPropertyDescriptor(t,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?t.props.ref:t.props.ref||t.ref)}const qn=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Xn=$.clsx,cc=(t,r)=>o=>{var i;if(r?.variants==null)return Xn(t,o?.class,o?.className);const{variants:e,defaultVariants:n}=r,a=Object.keys(e).map(u=>{const f=o?.[u],g=n?.[u];if(f===null)return null;const h=qn(f)||qn(g);return e[u][h]}),l=o&&Object.entries(o).reduce((u,f)=>{let[g,h]=f;return h===void 0||(u[g]=h),u},{}),d=r==null||(i=r.compoundVariants)===null||i===void 0?void 0:i.reduce((u,f)=>{let{class:g,className:h,...v}=f;return Object.entries(v).every(y=>{let[p,b]=y;return Array.isArray(b)?b.includes({...n,...l}[p]):{...n,...l}[p]===b})?[...u,g,h]:u},[]);return Xn(t,a,d,o?.class,o?.className)},uc=cc("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),ce=m.forwardRef(({className:t,variant:r,size:o,asChild:i=!1,...e},n)=>{const a=i?nc:"button";return c.jsx(a,{"data-slot":"button",className:$.cn(uc({variant:r,size:o,className:t})),ref:n,...e})});ce.displayName="Button";function R(t,r,{checkForDefaultPrevented:o=!0}={}){return function(e){if(t?.(e),o===!1||!e.defaultPrevented)return r?.(e)}}function dc(t,r){const o=m.createContext(r),i=n=>{const{children:a,...l}=n,d=m.useMemo(()=>l,Object.values(l));return c.jsx(o.Provider,{value:d,children:a})};i.displayName=t+"Provider";function e(n){const a=m.useContext(o);if(a)return a;if(r!==void 0)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}return[i,e]}function Je(t,r=[]){let o=[];function i(n,a){const l=m.createContext(a),d=o.length;o=[...o,a];const u=g=>{const{scope:h,children:v,...y}=g,p=h?.[t]?.[d]||l,b=m.useMemo(()=>y,Object.values(y));return c.jsx(p.Provider,{value:b,children:v})};u.displayName=n+"Provider";function f(g,h){const v=h?.[t]?.[d]||l,y=m.useContext(v);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${g}\` must be used within \`${n}\``)}return[u,f]}const e=()=>{const n=o.map(a=>m.createContext(a));return function(l){const d=l?.[t]||n;return m.useMemo(()=>({[`__scope${t}`]:{...l,[t]:d}}),[l,d])}};return e.scopeName=t,[i,fc(e,...r)]}function fc(...t){const r=t[0];if(t.length===1)return r;const o=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(n){const a=i.reduce((l,{useScope:d,scopeName:u})=>{const g=d(n)[`__scope${u}`];return{...l,...g}},{});return m.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return o.scopeName=r.scopeName,o}function an(t){const r=mc(t),o=m.forwardRef((i,e)=>{const{children:n,...a}=i,l=m.Children.toArray(n),d=l.find(pc);if(d){const u=d.props.children,f=l.map(g=>g===d?m.Children.count(u)>1?m.Children.only(null):m.isValidElement(u)?u.props.children:null:g);return c.jsx(r,{...a,ref:e,children:m.isValidElement(u)?m.cloneElement(u,void 0,f):null})}return c.jsx(r,{...a,ref:e,children:n})});return o.displayName=`${t}.Slot`,o}function mc(t){const r=m.forwardRef((o,i)=>{const{children:e,...n}=o;if(m.isValidElement(e)){const a=hc(e),l=vc(n,e.props);return e.type!==m.Fragment&&(l.ref=i?on(i,a):a),m.cloneElement(e,l)}return m.Children.count(e)>1?m.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var Tr=Symbol("radix.slottable");function gc(t){const r=({children:o})=>c.jsx(c.Fragment,{children:o});return r.displayName=`${t}.Slottable`,r.__radixId=Tr,r}function pc(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Tr}function vc(t,r){const o={...r};for(const i in r){const e=t[i],n=r[i];/^on[A-Z]/.test(i)?e&&n?o[i]=(...l)=>{const d=n(...l);return e(...l),d}:e&&(o[i]=e):i==="style"?o[i]={...e,...n}:i==="className"&&(o[i]=[e,n].filter(Boolean).join(" "))}return{...t,...o}}function hc(t){let r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?t.ref:(r=Object.getOwnPropertyDescriptor(t,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?t.props.ref:t.props.ref||t.ref)}var yc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Z=yc.reduce((t,r)=>{const o=an(`Primitive.${r}`),i=m.forwardRef((e,n)=>{const{asChild:a,...l}=e,d=a?o:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...l,ref:n})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});function bc(t,r){t&&wr.flushSync(()=>t.dispatchEvent(r))}function xe(t){const r=m.useRef(t);return m.useEffect(()=>{r.current=t}),m.useMemo(()=>(...o)=>r.current?.(...o),[])}function $c(t,r=globalThis?.document){const o=xe(t);m.useEffect(()=>{const i=e=>{e.key==="Escape"&&o(e)};return r.addEventListener("keydown",i,{capture:!0}),()=>r.removeEventListener("keydown",i,{capture:!0})},[o,r])}var xc="DismissableLayer",Jt="dismissableLayer.update",_c="dismissableLayer.pointerDownOutside",wc="dismissableLayer.focusOutside",Yn,Ar=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ht=m.forwardRef((t,r)=>{const{disableOutsidePointerEvents:o=!1,onEscapeKeyDown:i,onPointerDownOutside:e,onFocusOutside:n,onInteractOutside:a,onDismiss:l,...d}=t,u=m.useContext(Ar),[f,g]=m.useState(null),h=f?.ownerDocument??globalThis?.document,[,v]=m.useState({}),y=G(r,O=>g(O)),p=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=p.indexOf(b),_=f?p.indexOf(f):-1,w=u.layersWithOutsidePointerEventsDisabled.size>0,k=_>=x,I=jc(O=>{const E=O.target,A=[...u.branches].some(U=>U.contains(E));!k||A||(e?.(O),a?.(O),O.defaultPrevented||l?.())},h),P=Ic(O=>{const E=O.target;[...u.branches].some(U=>U.contains(E))||(n?.(O),a?.(O),O.defaultPrevented||l?.())},h);return $c(O=>{_===u.layers.size-1&&(i?.(O),!O.defaultPrevented&&l&&(O.preventDefault(),l()))},h),m.useEffect(()=>{if(f)return o&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Yn=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Qn(),()=>{o&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Yn)}},[f,h,o,u]),m.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Qn())},[f,u]),m.useEffect(()=>{const O=()=>v({});return document.addEventListener(Jt,O),()=>document.removeEventListener(Jt,O)},[]),c.jsx(Z.div,{...d,ref:y,style:{pointerEvents:w?k?"auto":"none":void 0,...t.style},onFocusCapture:R(t.onFocusCapture,P.onFocusCapture),onBlurCapture:R(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:R(t.onPointerDownCapture,I.onPointerDownCapture)})});ht.displayName=xc;var Sc="DismissableLayerBranch",kc=m.forwardRef((t,r)=>{const o=m.useContext(Ar),i=m.useRef(null),e=G(r,i);return m.useEffect(()=>{const n=i.current;if(n)return o.branches.add(n),()=>{o.branches.delete(n)}},[o.branches]),c.jsx(Z.div,{...t,ref:e})});kc.displayName=Sc;function jc(t,r=globalThis?.document){const o=xe(t),i=m.useRef(!1),e=m.useRef(()=>{});return m.useEffect(()=>{const n=l=>{if(l.target&&!i.current){let d=function(){Rr(_c,o,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(r.removeEventListener("click",e.current),e.current=d,r.addEventListener("click",e.current,{once:!0})):d()}else r.removeEventListener("click",e.current);i.current=!1},a=window.setTimeout(()=>{r.addEventListener("pointerdown",n)},0);return()=>{window.clearTimeout(a),r.removeEventListener("pointerdown",n),r.removeEventListener("click",e.current)}},[r,o]),{onPointerDownCapture:()=>i.current=!0}}function Ic(t,r=globalThis?.document){const o=xe(t),i=m.useRef(!1);return m.useEffect(()=>{const e=n=>{n.target&&!i.current&&Rr(wc,o,{originalEvent:n},{discrete:!1})};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,o]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function Qn(){const t=new CustomEvent(Jt);document.dispatchEvent(t)}function Rr(t,r,o,{discrete:i}){const e=o.originalEvent.target,n=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:o});r&&e.addEventListener(t,r,{once:!0}),i?bc(e,n):e.dispatchEvent(n)}var Y=globalThis?.document?m.useLayoutEffect:()=>{},Nc=m[" useId ".trim().toString()]||(()=>{}),Oc=0;function Oe(t){const[r,o]=m.useState(Nc());return Y(()=>{o(i=>i??String(Oc++))},[t]),r?`radix-${r}`:""}const Pc=["top","right","bottom","left"],ye=Math.min,K=Math.max,ft=Math.round,Qe=Math.floor,le=t=>({x:t,y:t}),Cc={left:"right",right:"left",bottom:"top",top:"bottom"},Ec={start:"end",end:"start"};function Kt(t,r,o){return K(t,ye(r,o))}function me(t,r){return typeof t=="function"?t(r):t}function ge(t){return t.split("-")[0]}function Te(t){return t.split("-")[1]}function sn(t){return t==="x"?"y":"x"}function ln(t){return t==="y"?"height":"width"}const Dc=new Set(["top","bottom"]);function se(t){return Dc.has(ge(t))?"y":"x"}function cn(t){return sn(se(t))}function Uc(t,r,o){o===void 0&&(o=!1);const i=Te(t),e=cn(t),n=ln(e);let a=e==="x"?i===(o?"end":"start")?"right":"left":i==="start"?"bottom":"top";return r.reference[n]>r.floating[n]&&(a=mt(a)),[a,mt(a)]}function Tc(t){const r=mt(t);return[Ht(t),r,Ht(r)]}function Ht(t){return t.replace(/start|end/g,r=>Ec[r])}const er=["left","right"],tr=["right","left"],Ac=["top","bottom"],Rc=["bottom","top"];function zc(t,r,o){switch(t){case"top":case"bottom":return o?r?tr:er:r?er:tr;case"left":case"right":return r?Ac:Rc;default:return[]}}function Lc(t,r,o,i){const e=Te(t);let n=zc(ge(t),o==="start",i);return e&&(n=n.map(a=>a+"-"+e),r&&(n=n.concat(n.map(Ht)))),n}function mt(t){return t.replace(/left|right|bottom|top/g,r=>Cc[r])}function Mc(t){return{top:0,right:0,bottom:0,left:0,...t}}function zr(t){return typeof t!="number"?Mc(t):{top:t,right:t,bottom:t,left:t}}function gt(t){const{x:r,y:o,width:i,height:e}=t;return{width:i,height:e,top:o,left:r,right:r+i,bottom:o+e,x:r,y:o}}function nr(t,r,o){let{reference:i,floating:e}=t;const n=se(r),a=cn(r),l=ln(a),d=ge(r),u=n==="y",f=i.x+i.width/2-e.width/2,g=i.y+i.height/2-e.height/2,h=i[l]/2-e[l]/2;let v;switch(d){case"top":v={x:f,y:i.y-e.height};break;case"bottom":v={x:f,y:i.y+i.height};break;case"right":v={x:i.x+i.width,y:g};break;case"left":v={x:i.x-e.width,y:g};break;default:v={x:i.x,y:i.y}}switch(Te(r)){case"start":v[a]-=h*(o&&u?-1:1);break;case"end":v[a]+=h*(o&&u?-1:1);break}return v}const Zc=async(t,r,o)=>{const{placement:i="bottom",strategy:e="absolute",middleware:n=[],platform:a}=o,l=n.filter(Boolean),d=await(a.isRTL==null?void 0:a.isRTL(r));let u=await a.getElementRects({reference:t,floating:r,strategy:e}),{x:f,y:g}=nr(u,i,d),h=i,v={},y=0;for(let p=0;p<l.length;p++){const{name:b,fn:x}=l[p],{x:_,y:w,data:k,reset:I}=await x({x:f,y:g,initialPlacement:i,placement:h,strategy:e,middlewareData:v,rects:u,platform:a,elements:{reference:t,floating:r}});f=_??f,g=w??g,v={...v,[b]:{...v[b],...k}},I&&y<=50&&(y++,typeof I=="object"&&(I.placement&&(h=I.placement),I.rects&&(u=I.rects===!0?await a.getElementRects({reference:t,floating:r,strategy:e}):I.rects),{x:f,y:g}=nr(u,h,d)),p=-1)}return{x:f,y:g,placement:h,strategy:e,middlewareData:v}};async function Ve(t,r){var o;r===void 0&&(r={});const{x:i,y:e,platform:n,rects:a,elements:l,strategy:d}=t,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:g="floating",altBoundary:h=!1,padding:v=0}=me(r,t),y=zr(v),b=l[h?g==="floating"?"reference":"floating":g],x=gt(await n.getClippingRect({element:(o=await(n.isElement==null?void 0:n.isElement(b)))==null||o?b:b.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(l.floating)),boundary:u,rootBoundary:f,strategy:d})),_=g==="floating"?{x:i,y:e,width:a.floating.width,height:a.floating.height}:a.reference,w=await(n.getOffsetParent==null?void 0:n.getOffsetParent(l.floating)),k=await(n.isElement==null?void 0:n.isElement(w))?await(n.getScale==null?void 0:n.getScale(w))||{x:1,y:1}:{x:1,y:1},I=gt(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:_,offsetParent:w,strategy:d}):_);return{top:(x.top-I.top+y.top)/k.y,bottom:(I.bottom-x.bottom+y.bottom)/k.y,left:(x.left-I.left+y.left)/k.x,right:(I.right-x.right+y.right)/k.x}}const Fc=t=>({name:"arrow",options:t,async fn(r){const{x:o,y:i,placement:e,rects:n,platform:a,elements:l,middlewareData:d}=r,{element:u,padding:f=0}=me(t,r)||{};if(u==null)return{};const g=zr(f),h={x:o,y:i},v=cn(e),y=ln(v),p=await a.getDimensions(u),b=v==="y",x=b?"top":"left",_=b?"bottom":"right",w=b?"clientHeight":"clientWidth",k=n.reference[y]+n.reference[v]-h[v]-n.floating[y],I=h[v]-n.reference[v],P=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let O=P?P[w]:0;(!O||!await(a.isElement==null?void 0:a.isElement(P)))&&(O=l.floating[w]||n.floating[y]);const E=k/2-I/2,A=O/2-p[y]/2-1,U=ye(g[x],A),W=ye(g[_],A),B=U,z=O-p[y]-W,T=O/2-p[y]/2+E,J=Kt(B,T,z),L=!d.arrow&&Te(e)!=null&&T!==J&&n.reference[y]/2-(T<B?U:W)-p[y]/2<0,M=L?T<B?T-B:T-z:0;return{[v]:h[v]+M,data:{[v]:J,centerOffset:T-J-M,...L&&{alignmentOffset:M}},reset:L}}}),Vc=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(r){var o,i;const{placement:e,middlewareData:n,rects:a,initialPlacement:l,platform:d,elements:u}=r,{mainAxis:f=!0,crossAxis:g=!0,fallbackPlacements:h,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:p=!0,...b}=me(t,r);if((o=n.arrow)!=null&&o.alignmentOffset)return{};const x=ge(e),_=se(l),w=ge(l)===l,k=await(d.isRTL==null?void 0:d.isRTL(u.floating)),I=h||(w||!p?[mt(l)]:Tc(l)),P=y!=="none";!h&&P&&I.push(...Lc(l,p,y,k));const O=[l,...I],E=await Ve(r,b),A=[];let U=((i=n.flip)==null?void 0:i.overflows)||[];if(f&&A.push(E[x]),g){const T=Uc(e,a,k);A.push(E[T[0]],E[T[1]])}if(U=[...U,{placement:e,overflows:A}],!A.every(T=>T<=0)){var W,B;const T=(((W=n.flip)==null?void 0:W.index)||0)+1,J=O[T];if(J&&(!(g==="alignment"?_!==se(J):!1)||U.every(C=>se(C.placement)===_?C.overflows[0]>0:!0)))return{data:{index:T,overflows:U},reset:{placement:J}};let L=(B=U.filter(M=>M.overflows[0]<=0).sort((M,C)=>M.overflows[1]-C.overflows[1])[0])==null?void 0:B.placement;if(!L)switch(v){case"bestFit":{var z;const M=(z=U.filter(C=>{if(P){const F=se(C.placement);return F===_||F==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(F=>F>0).reduce((F,re)=>F+re,0)]).sort((C,F)=>C[1]-F[1])[0])==null?void 0:z[0];M&&(L=M);break}case"initialPlacement":L=l;break}if(e!==L)return{reset:{placement:L}}}return{}}}};function rr(t,r){return{top:t.top-r.height,right:t.right-r.width,bottom:t.bottom-r.height,left:t.left-r.width}}function ir(t){return Pc.some(r=>t[r]>=0)}const Wc=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(r){const{rects:o}=r,{strategy:i="referenceHidden",...e}=me(t,r);switch(i){case"referenceHidden":{const n=await Ve(r,{...e,elementContext:"reference"}),a=rr(n,o.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:ir(a)}}}case"escaped":{const n=await Ve(r,{...e,altBoundary:!0}),a=rr(n,o.floating);return{data:{escapedOffsets:a,escaped:ir(a)}}}default:return{}}}}},Lr=new Set(["left","top"]);async function Bc(t,r){const{placement:o,platform:i,elements:e}=t,n=await(i.isRTL==null?void 0:i.isRTL(e.floating)),a=ge(o),l=Te(o),d=se(o)==="y",u=Lr.has(a)?-1:1,f=n&&d?-1:1,g=me(r,t);let{mainAxis:h,crossAxis:v,alignmentAxis:y}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return l&&typeof y=="number"&&(v=l==="end"?y*-1:y),d?{x:v*f,y:h*u}:{x:h*u,y:v*f}}const Gc=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(r){var o,i;const{x:e,y:n,placement:a,middlewareData:l}=r,d=await Bc(r,t);return a===((o=l.offset)==null?void 0:o.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:e+d.x,y:n+d.y,data:{...d,placement:a}}}}},Jc=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(r){const{x:o,y:i,placement:e}=r,{mainAxis:n=!0,crossAxis:a=!1,limiter:l={fn:b=>{let{x,y:_}=b;return{x,y:_}}},...d}=me(t,r),u={x:o,y:i},f=await Ve(r,d),g=se(ge(e)),h=sn(g);let v=u[h],y=u[g];if(n){const b=h==="y"?"top":"left",x=h==="y"?"bottom":"right",_=v+f[b],w=v-f[x];v=Kt(_,v,w)}if(a){const b=g==="y"?"top":"left",x=g==="y"?"bottom":"right",_=y+f[b],w=y-f[x];y=Kt(_,y,w)}const p=l.fn({...r,[h]:v,[g]:y});return{...p,data:{x:p.x-o,y:p.y-i,enabled:{[h]:n,[g]:a}}}}}},Kc=function(t){return t===void 0&&(t={}),{options:t,fn(r){const{x:o,y:i,placement:e,rects:n,middlewareData:a}=r,{offset:l=0,mainAxis:d=!0,crossAxis:u=!0}=me(t,r),f={x:o,y:i},g=se(e),h=sn(g);let v=f[h],y=f[g];const p=me(l,r),b=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(d){const w=h==="y"?"height":"width",k=n.reference[h]-n.floating[w]+b.mainAxis,I=n.reference[h]+n.reference[w]-b.mainAxis;v<k?v=k:v>I&&(v=I)}if(u){var x,_;const w=h==="y"?"width":"height",k=Lr.has(ge(e)),I=n.reference[g]-n.floating[w]+(k&&((x=a.offset)==null?void 0:x[g])||0)+(k?0:b.crossAxis),P=n.reference[g]+n.reference[w]+(k?0:((_=a.offset)==null?void 0:_[g])||0)-(k?b.crossAxis:0);y<I?y=I:y>P&&(y=P)}return{[h]:v,[g]:y}}}},Hc=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(r){var o,i;const{placement:e,rects:n,platform:a,elements:l}=r,{apply:d=()=>{},...u}=me(t,r),f=await Ve(r,u),g=ge(e),h=Te(e),v=se(e)==="y",{width:y,height:p}=n.floating;let b,x;g==="top"||g==="bottom"?(b=g,x=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(x=g,b=h==="end"?"top":"bottom");const _=p-f.top-f.bottom,w=y-f.left-f.right,k=ye(p-f[b],_),I=ye(y-f[x],w),P=!r.middlewareData.shift;let O=k,E=I;if((o=r.middlewareData.shift)!=null&&o.enabled.x&&(E=w),(i=r.middlewareData.shift)!=null&&i.enabled.y&&(O=_),P&&!h){const U=K(f.left,0),W=K(f.right,0),B=K(f.top,0),z=K(f.bottom,0);v?E=y-2*(U!==0||W!==0?U+W:K(f.left,f.right)):O=p-2*(B!==0||z!==0?B+z:K(f.top,f.bottom))}await d({...r,availableWidth:E,availableHeight:O});const A=await a.getDimensions(l.floating);return y!==A.width||p!==A.height?{reset:{rects:!0}}:{}}}};function yt(){return typeof window<"u"}function Ae(t){return Mr(t)?(t.nodeName||"").toLowerCase():"#document"}function H(t){var r;return(t==null||(r=t.ownerDocument)==null?void 0:r.defaultView)||window}function de(t){var r;return(r=(Mr(t)?t.ownerDocument:t.document)||window.document)==null?void 0:r.documentElement}function Mr(t){return yt()?t instanceof Node||t instanceof H(t).Node:!1}function ee(t){return yt()?t instanceof Element||t instanceof H(t).Element:!1}function ue(t){return yt()?t instanceof HTMLElement||t instanceof H(t).HTMLElement:!1}function or(t){return!yt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof H(t).ShadowRoot}const qc=new Set(["inline","contents"]);function Ke(t){const{overflow:r,overflowX:o,overflowY:i,display:e}=te(t);return/auto|scroll|overlay|hidden|clip/.test(r+i+o)&&!qc.has(e)}const Xc=new Set(["table","td","th"]);function Yc(t){return Xc.has(Ae(t))}const Qc=[":popover-open",":modal"];function bt(t){return Qc.some(r=>{try{return t.matches(r)}catch{return!1}})}const eu=["transform","translate","scale","rotate","perspective"],tu=["transform","translate","scale","rotate","perspective","filter"],nu=["paint","layout","strict","content"];function un(t){const r=dn(),o=ee(t)?te(t):t;return eu.some(i=>o[i]?o[i]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!r&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!r&&(o.filter?o.filter!=="none":!1)||tu.some(i=>(o.willChange||"").includes(i))||nu.some(i=>(o.contain||"").includes(i))}function ru(t){let r=be(t);for(;ue(r)&&!Ee(r);){if(un(r))return r;if(bt(r))return null;r=be(r)}return null}function dn(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const iu=new Set(["html","body","#document"]);function Ee(t){return iu.has(Ae(t))}function te(t){return H(t).getComputedStyle(t)}function $t(t){return ee(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function be(t){if(Ae(t)==="html")return t;const r=t.assignedSlot||t.parentNode||or(t)&&t.host||de(t);return or(r)?r.host:r}function Zr(t){const r=be(t);return Ee(r)?t.ownerDocument?t.ownerDocument.body:t.body:ue(r)&&Ke(r)?r:Zr(r)}function We(t,r,o){var i;r===void 0&&(r=[]),o===void 0&&(o=!0);const e=Zr(t),n=e===((i=t.ownerDocument)==null?void 0:i.body),a=H(e);if(n){const l=qt(a);return r.concat(a,a.visualViewport||[],Ke(e)?e:[],l&&o?We(l):[])}return r.concat(e,We(e,[],o))}function qt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Fr(t){const r=te(t);let o=parseFloat(r.width)||0,i=parseFloat(r.height)||0;const e=ue(t),n=e?t.offsetWidth:o,a=e?t.offsetHeight:i,l=ft(o)!==n||ft(i)!==a;return l&&(o=n,i=a),{width:o,height:i,$:l}}function fn(t){return ee(t)?t:t.contextElement}function Pe(t){const r=fn(t);if(!ue(r))return le(1);const o=r.getBoundingClientRect(),{width:i,height:e,$:n}=Fr(r);let a=(n?ft(o.width):o.width)/i,l=(n?ft(o.height):o.height)/e;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const ou=le(0);function Vr(t){const r=H(t);return!dn()||!r.visualViewport?ou:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function au(t,r,o){return r===void 0&&(r=!1),!o||r&&o!==H(t)?!1:r}function _e(t,r,o,i){r===void 0&&(r=!1),o===void 0&&(o=!1);const e=t.getBoundingClientRect(),n=fn(t);let a=le(1);r&&(i?ee(i)&&(a=Pe(i)):a=Pe(t));const l=au(n,o,i)?Vr(n):le(0);let d=(e.left+l.x)/a.x,u=(e.top+l.y)/a.y,f=e.width/a.x,g=e.height/a.y;if(n){const h=H(n),v=i&&ee(i)?H(i):i;let y=h,p=qt(y);for(;p&&i&&v!==y;){const b=Pe(p),x=p.getBoundingClientRect(),_=te(p),w=x.left+(p.clientLeft+parseFloat(_.paddingLeft))*b.x,k=x.top+(p.clientTop+parseFloat(_.paddingTop))*b.y;d*=b.x,u*=b.y,f*=b.x,g*=b.y,d+=w,u+=k,y=H(p),p=qt(y)}}return gt({width:f,height:g,x:d,y:u})}function mn(t,r){const o=$t(t).scrollLeft;return r?r.left+o:_e(de(t)).left+o}function Wr(t,r,o){o===void 0&&(o=!1);const i=t.getBoundingClientRect(),e=i.left+r.scrollLeft-(o?0:mn(t,i)),n=i.top+r.scrollTop;return{x:e,y:n}}function su(t){let{elements:r,rect:o,offsetParent:i,strategy:e}=t;const n=e==="fixed",a=de(i),l=r?bt(r.floating):!1;if(i===a||l&&n)return o;let d={scrollLeft:0,scrollTop:0},u=le(1);const f=le(0),g=ue(i);if((g||!g&&!n)&&((Ae(i)!=="body"||Ke(a))&&(d=$t(i)),ue(i))){const v=_e(i);u=Pe(i),f.x=v.x+i.clientLeft,f.y=v.y+i.clientTop}const h=a&&!g&&!n?Wr(a,d,!0):le(0);return{width:o.width*u.x,height:o.height*u.y,x:o.x*u.x-d.scrollLeft*u.x+f.x+h.x,y:o.y*u.y-d.scrollTop*u.y+f.y+h.y}}function lu(t){return Array.from(t.getClientRects())}function cu(t){const r=de(t),o=$t(t),i=t.ownerDocument.body,e=K(r.scrollWidth,r.clientWidth,i.scrollWidth,i.clientWidth),n=K(r.scrollHeight,r.clientHeight,i.scrollHeight,i.clientHeight);let a=-o.scrollLeft+mn(t);const l=-o.scrollTop;return te(i).direction==="rtl"&&(a+=K(r.clientWidth,i.clientWidth)-e),{width:e,height:n,x:a,y:l}}function uu(t,r){const o=H(t),i=de(t),e=o.visualViewport;let n=i.clientWidth,a=i.clientHeight,l=0,d=0;if(e){n=e.width,a=e.height;const u=dn();(!u||u&&r==="fixed")&&(l=e.offsetLeft,d=e.offsetTop)}return{width:n,height:a,x:l,y:d}}const du=new Set(["absolute","fixed"]);function fu(t,r){const o=_e(t,!0,r==="fixed"),i=o.top+t.clientTop,e=o.left+t.clientLeft,n=ue(t)?Pe(t):le(1),a=t.clientWidth*n.x,l=t.clientHeight*n.y,d=e*n.x,u=i*n.y;return{width:a,height:l,x:d,y:u}}function ar(t,r,o){let i;if(r==="viewport")i=uu(t,o);else if(r==="document")i=cu(de(t));else if(ee(r))i=fu(r,o);else{const e=Vr(t);i={x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}return gt(i)}function Br(t,r){const o=be(t);return o===r||!ee(o)||Ee(o)?!1:te(o).position==="fixed"||Br(o,r)}function mu(t,r){const o=r.get(t);if(o)return o;let i=We(t,[],!1).filter(l=>ee(l)&&Ae(l)!=="body"),e=null;const n=te(t).position==="fixed";let a=n?be(t):t;for(;ee(a)&&!Ee(a);){const l=te(a),d=un(a);!d&&l.position==="fixed"&&(e=null),(n?!d&&!e:!d&&l.position==="static"&&!!e&&du.has(e.position)||Ke(a)&&!d&&Br(t,a))?i=i.filter(f=>f!==a):e=l,a=be(a)}return r.set(t,i),i}function gu(t){let{element:r,boundary:o,rootBoundary:i,strategy:e}=t;const a=[...o==="clippingAncestors"?bt(r)?[]:mu(r,this._c):[].concat(o),i],l=a[0],d=a.reduce((u,f)=>{const g=ar(r,f,e);return u.top=K(g.top,u.top),u.right=ye(g.right,u.right),u.bottom=ye(g.bottom,u.bottom),u.left=K(g.left,u.left),u},ar(r,l,e));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function pu(t){const{width:r,height:o}=Fr(t);return{width:r,height:o}}function vu(t,r,o){const i=ue(r),e=de(r),n=o==="fixed",a=_e(t,!0,n,r);let l={scrollLeft:0,scrollTop:0};const d=le(0);function u(){d.x=mn(e)}if(i||!i&&!n)if((Ae(r)!=="body"||Ke(e))&&(l=$t(r)),i){const v=_e(r,!0,n,r);d.x=v.x+r.clientLeft,d.y=v.y+r.clientTop}else e&&u();n&&!i&&e&&u();const f=e&&!i&&!n?Wr(e,l):le(0),g=a.left+l.scrollLeft-d.x-f.x,h=a.top+l.scrollTop-d.y-f.y;return{x:g,y:h,width:a.width,height:a.height}}function Ut(t){return te(t).position==="static"}function sr(t,r){if(!ue(t)||te(t).position==="fixed")return null;if(r)return r(t);let o=t.offsetParent;return de(t)===o&&(o=o.ownerDocument.body),o}function Gr(t,r){const o=H(t);if(bt(t))return o;if(!ue(t)){let e=be(t);for(;e&&!Ee(e);){if(ee(e)&&!Ut(e))return e;e=be(e)}return o}let i=sr(t,r);for(;i&&Yc(i)&&Ut(i);)i=sr(i,r);return i&&Ee(i)&&Ut(i)&&!un(i)?o:i||ru(t)||o}const hu=async function(t){const r=this.getOffsetParent||Gr,o=this.getDimensions,i=await o(t.floating);return{reference:vu(t.reference,await r(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function yu(t){return te(t).direction==="rtl"}const bu={convertOffsetParentRelativeRectToViewportRelativeRect:su,getDocumentElement:de,getClippingRect:gu,getOffsetParent:Gr,getElementRects:hu,getClientRects:lu,getDimensions:pu,getScale:Pe,isElement:ee,isRTL:yu};function Jr(t,r){return t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height}function $u(t,r){let o=null,i;const e=de(t);function n(){var l;clearTimeout(i),(l=o)==null||l.disconnect(),o=null}function a(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),n();const u=t.getBoundingClientRect(),{left:f,top:g,width:h,height:v}=u;if(l||r(),!h||!v)return;const y=Qe(g),p=Qe(e.clientWidth-(f+h)),b=Qe(e.clientHeight-(g+v)),x=Qe(f),w={rootMargin:-y+"px "+-p+"px "+-b+"px "+-x+"px",threshold:K(0,ye(1,d))||1};let k=!0;function I(P){const O=P[0].intersectionRatio;if(O!==d){if(!k)return a();O?a(!1,O):i=setTimeout(()=>{a(!1,1e-7)},1e3)}O===1&&!Jr(u,t.getBoundingClientRect())&&a(),k=!1}try{o=new IntersectionObserver(I,{...w,root:e.ownerDocument})}catch{o=new IntersectionObserver(I,w)}o.observe(t)}return a(!0),n}function xu(t,r,o,i){i===void 0&&(i={});const{ancestorScroll:e=!0,ancestorResize:n=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=i,u=fn(t),f=e||n?[...u?We(u):[],...We(r)]:[];f.forEach(x=>{e&&x.addEventListener("scroll",o,{passive:!0}),n&&x.addEventListener("resize",o)});const g=u&&l?$u(u,o):null;let h=-1,v=null;a&&(v=new ResizeObserver(x=>{let[_]=x;_&&_.target===u&&v&&(v.unobserve(r),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=v)==null||w.observe(r)})),o()}),u&&!d&&v.observe(u),v.observe(r));let y,p=d?_e(t):null;d&&b();function b(){const x=_e(t);p&&!Jr(p,x)&&o(),p=x,y=requestAnimationFrame(b)}return o(),()=>{var x;f.forEach(_=>{e&&_.removeEventListener("scroll",o),n&&_.removeEventListener("resize",o)}),g?.(),(x=v)==null||x.disconnect(),v=null,d&&cancelAnimationFrame(y)}}const _u=Gc,wu=Jc,Su=Vc,ku=Hc,ju=Wc,lr=Fc,Iu=Kc,Nu=(t,r,o)=>{const i=new Map,e={platform:bu,...o},n={...e.platform,_c:i};return Zc(t,r,{...e,platform:n})};var Ou=typeof document<"u",Pu=function(){},st=Ou?N.useLayoutEffect:Pu;function pt(t,r){if(t===r)return!0;if(typeof t!=typeof r)return!1;if(typeof t=="function"&&t.toString()===r.toString())return!0;let o,i,e;if(t&&r&&typeof t=="object"){if(Array.isArray(t)){if(o=t.length,o!==r.length)return!1;for(i=o;i--!==0;)if(!pt(t[i],r[i]))return!1;return!0}if(e=Object.keys(t),o=e.length,o!==Object.keys(r).length)return!1;for(i=o;i--!==0;)if(!{}.hasOwnProperty.call(r,e[i]))return!1;for(i=o;i--!==0;){const n=e[i];if(!(n==="_owner"&&t.$$typeof)&&!pt(t[n],r[n]))return!1}return!0}return t!==t&&r!==r}function Kr(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function cr(t,r){const o=Kr(t);return Math.round(r*o)/o}function Tt(t){const r=m.useRef(t);return st(()=>{r.current=t}),r}function Cu(t){t===void 0&&(t={});const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:e,elements:{reference:n,floating:a}={},transform:l=!0,whileElementsMounted:d,open:u}=t,[f,g]=m.useState({x:0,y:0,strategy:o,placement:r,middlewareData:{},isPositioned:!1}),[h,v]=m.useState(i);pt(h,i)||v(i);const[y,p]=m.useState(null),[b,x]=m.useState(null),_=m.useCallback(C=>{C!==P.current&&(P.current=C,p(C))},[]),w=m.useCallback(C=>{C!==O.current&&(O.current=C,x(C))},[]),k=n||y,I=a||b,P=m.useRef(null),O=m.useRef(null),E=m.useRef(f),A=d!=null,U=Tt(d),W=Tt(e),B=Tt(u),z=m.useCallback(()=>{if(!P.current||!O.current)return;const C={placement:r,strategy:o,middleware:h};W.current&&(C.platform=W.current),Nu(P.current,O.current,C).then(F=>{const re={...F,isPositioned:B.current!==!1};T.current&&!pt(E.current,re)&&(E.current=re,wr.flushSync(()=>{g(re)}))})},[h,r,o,W,B]);st(()=>{u===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,g(C=>({...C,isPositioned:!1})))},[u]);const T=m.useRef(!1);st(()=>(T.current=!0,()=>{T.current=!1}),[]),st(()=>{if(k&&(P.current=k),I&&(O.current=I),k&&I){if(U.current)return U.current(k,I,z);z()}},[k,I,z,U,A]);const J=m.useMemo(()=>({reference:P,floating:O,setReference:_,setFloating:w}),[_,w]),L=m.useMemo(()=>({reference:k,floating:I}),[k,I]),M=m.useMemo(()=>{const C={position:o,left:0,top:0};if(!L.floating)return C;const F=cr(L.floating,f.x),re=cr(L.floating,f.y);return l?{...C,transform:"translate("+F+"px, "+re+"px)",...Kr(L.floating)>=1.5&&{willChange:"transform"}}:{position:o,left:F,top:re}},[o,l,L.floating,f.x,f.y]);return m.useMemo(()=>({...f,update:z,refs:J,elements:L,floatingStyles:M}),[f,z,J,L,M])}const Eu=t=>{function r(o){return{}.hasOwnProperty.call(o,"current")}return{name:"arrow",options:t,fn(o){const{element:i,padding:e}=typeof t=="function"?t(o):t;return i&&r(i)?i.current!=null?lr({element:i.current,padding:e}).fn(o):{}:i?lr({element:i,padding:e}).fn(o):{}}}},Du=(t,r)=>({..._u(t),options:[t,r]}),Uu=(t,r)=>({...wu(t),options:[t,r]}),Tu=(t,r)=>({...Iu(t),options:[t,r]}),Au=(t,r)=>({...Su(t),options:[t,r]}),Ru=(t,r)=>({...ku(t),options:[t,r]}),zu=(t,r)=>({...ju(t),options:[t,r]}),Lu=(t,r)=>({...Eu(t),options:[t,r]});var Mu="Arrow",Hr=m.forwardRef((t,r)=>{const{children:o,width:i=10,height:e=5,...n}=t;return c.jsx(Z.svg,{...n,ref:r,width:i,height:e,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?o:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Hr.displayName=Mu;var Zu=Hr;function Fu(t){const[r,o]=m.useState(void 0);return Y(()=>{if(t){o({width:t.offsetWidth,height:t.offsetHeight});const i=new ResizeObserver(e=>{if(!Array.isArray(e)||!e.length)return;const n=e[0];let a,l;if("borderBoxSize"in n){const d=n.borderBoxSize,u=Array.isArray(d)?d[0]:d;a=u.inlineSize,l=u.blockSize}else a=t.offsetWidth,l=t.offsetHeight;o({width:a,height:l})});return i.observe(t,{box:"border-box"}),()=>i.unobserve(t)}else o(void 0)},[t]),r}var gn="Popper",[qr,xt]=Je(gn),[Vu,Xr]=qr(gn),Yr=t=>{const{__scopePopper:r,children:o}=t,[i,e]=m.useState(null);return c.jsx(Vu,{scope:r,anchor:i,onAnchorChange:e,children:o})};Yr.displayName=gn;var Qr="PopperAnchor",ei=m.forwardRef((t,r)=>{const{__scopePopper:o,virtualRef:i,...e}=t,n=Xr(Qr,o),a=m.useRef(null),l=G(r,a),d=m.useRef(null);return m.useEffect(()=>{const u=d.current;d.current=i?.current||a.current,u!==d.current&&n.onAnchorChange(d.current)}),i?null:c.jsx(Z.div,{...e,ref:l})});ei.displayName=Qr;var pn="PopperContent",[Wu,Bu]=qr(pn),ti=m.forwardRef((t,r)=>{const{__scopePopper:o,side:i="bottom",sideOffset:e=0,align:n="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:g="partial",hideWhenDetached:h=!1,updatePositionStrategy:v="optimized",onPlaced:y,...p}=t,b=Xr(pn,o),[x,_]=m.useState(null),w=G(r,Re=>_(Re)),[k,I]=m.useState(null),P=Fu(k),O=P?.width??0,E=P?.height??0,A=i+(n!=="center"?"-"+n:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},W=Array.isArray(u)?u:[u],B=W.length>0,z={padding:U,boundary:W.filter(Ju),altBoundary:B},{refs:T,floatingStyles:J,placement:L,isPositioned:M,middlewareData:C}=Cu({strategy:"fixed",placement:A,whileElementsMounted:(...Re)=>xu(...Re,{animationFrame:v==="always"}),elements:{reference:b.anchor},middleware:[Du({mainAxis:e+E,alignmentAxis:a}),d&&Uu({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?Tu():void 0,...z}),d&&Au({...z}),Ru({...z,apply:({elements:Re,rects:An,availableWidth:Oo,availableHeight:Po})=>{const{width:Co,height:Eo}=An.reference,Xe=Re.floating.style;Xe.setProperty("--radix-popper-available-width",`${Oo}px`),Xe.setProperty("--radix-popper-available-height",`${Po}px`),Xe.setProperty("--radix-popper-anchor-width",`${Co}px`),Xe.setProperty("--radix-popper-anchor-height",`${Eo}px`)}}),k&&Lu({element:k,padding:l}),Ku({arrowWidth:O,arrowHeight:E}),h&&zu({strategy:"referenceHidden",...z})]}),[F,re]=ii(L),Tn=xe(y);Y(()=>{M&&Tn?.()},[M,Tn]);const So=C.arrow?.x,ko=C.arrow?.y,jo=C.arrow?.centerOffset!==0,[Io,No]=m.useState();return Y(()=>{x&&No(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:M?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Io,"--radix-popper-transform-origin":[C.transformOrigin?.x,C.transformOrigin?.y].join(" "),...C.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:c.jsx(Wu,{scope:o,placedSide:F,onArrowChange:I,arrowX:So,arrowY:ko,shouldHideArrow:jo,children:c.jsx(Z.div,{"data-side":F,"data-align":re,...p,ref:w,style:{...p.style,animation:M?void 0:"none"}})})})});ti.displayName=pn;var ni="PopperArrow",Gu={top:"bottom",right:"left",bottom:"top",left:"right"},ri=m.forwardRef(function(r,o){const{__scopePopper:i,...e}=r,n=Bu(ni,i),a=Gu[n.placedSide];return c.jsx("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:c.jsx(Zu,{...e,ref:o,style:{...e.style,display:"block"}})})});ri.displayName=ni;function Ju(t){return t!==null}var Ku=t=>({name:"transformOrigin",options:t,fn(r){const{placement:o,rects:i,middlewareData:e}=r,a=e.arrow?.centerOffset!==0,l=a?0:t.arrowWidth,d=a?0:t.arrowHeight,[u,f]=ii(o),g={start:"0%",center:"50%",end:"100%"}[f],h=(e.arrow?.x??0)+l/2,v=(e.arrow?.y??0)+d/2;let y="",p="";return u==="bottom"?(y=a?g:`${h}px`,p=`${-d}px`):u==="top"?(y=a?g:`${h}px`,p=`${i.floating.height+d}px`):u==="right"?(y=`${-d}px`,p=a?g:`${v}px`):u==="left"&&(y=`${i.floating.width+d}px`,p=a?g:`${v}px`),{data:{x:y,y:p}}}});function ii(t){const[r,o="center"]=t.split("-");return[r,o]}var oi=Yr,vn=ei,ai=ti,si=ri,Hu="Portal",_t=m.forwardRef((t,r)=>{const{container:o,...i}=t,[e,n]=m.useState(!1);Y(()=>n(!0),[]);const a=o||e&&globalThis?.document?.body;return a?_r.createPortal(c.jsx(Z.div,{...i,ref:r}),a):null});_t.displayName=Hu;function qu(t,r){return m.useReducer((o,i)=>r[o][i]??o,t)}var pe=t=>{const{present:r,children:o}=t,i=Xu(r),e=typeof o=="function"?o({present:i.isPresent}):m.Children.only(o),n=G(i.ref,Yu(e));return typeof o=="function"||i.isPresent?m.cloneElement(e,{ref:n}):null};pe.displayName="Presence";function Xu(t){const[r,o]=m.useState(),i=m.useRef(null),e=m.useRef(t),n=m.useRef("none"),a=t?"mounted":"unmounted",[l,d]=qu(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=et(i.current);n.current=l==="mounted"?u:"none"},[l]),Y(()=>{const u=i.current,f=e.current;if(f!==t){const h=n.current,v=et(u);t?d("MOUNT"):v==="none"||u?.display==="none"?d("UNMOUNT"):d(f&&h!==v?"ANIMATION_OUT":"UNMOUNT"),e.current=t}},[t,d]),Y(()=>{if(r){let u;const f=r.ownerDocument.defaultView??window,g=v=>{const p=et(i.current).includes(CSS.escape(v.animationName));if(v.target===r&&p&&(d("ANIMATION_END"),!e.current)){const b=r.style.animationFillMode;r.style.animationFillMode="forwards",u=f.setTimeout(()=>{r.style.animationFillMode==="forwards"&&(r.style.animationFillMode=b)})}},h=v=>{v.target===r&&(n.current=et(i.current))};return r.addEventListener("animationstart",h),r.addEventListener("animationcancel",g),r.addEventListener("animationend",g),()=>{f.clearTimeout(u),r.removeEventListener("animationstart",h),r.removeEventListener("animationcancel",g),r.removeEventListener("animationend",g)}}else d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:m.useCallback(u=>{i.current=u?getComputedStyle(u):null,o(u)},[])}}function et(t){return t?.animationName||"none"}function Yu(t){let r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?t.ref:(r=Object.getOwnPropertyDescriptor(t,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?t.props.ref:t.props.ref||t.ref)}var Qu=m[" useInsertionEffect ".trim().toString()]||Y;function wt({prop:t,defaultProp:r,onChange:o=()=>{},caller:i}){const[e,n,a]=ed({defaultProp:r,onChange:o}),l=t!==void 0,d=l?t:e;{const f=m.useRef(t!==void 0);m.useEffect(()=>{const g=f.current;g!==l&&console.warn(`${i} is changing from ${g?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,i])}const u=m.useCallback(f=>{if(l){const g=td(f)?f(t):f;g!==t&&a.current?.(g)}else n(f)},[l,t,n,a]);return[d,u]}function ed({defaultProp:t,onChange:r}){const[o,i]=m.useState(t),e=m.useRef(o),n=m.useRef(r);return Qu(()=>{n.current=r},[r]),m.useEffect(()=>{e.current!==o&&(n.current?.(o),e.current=o)},[o,e]),[o,i,n]}function td(t){return typeof t=="function"}var nd=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),rd="VisuallyHidden",li=m.forwardRef((t,r)=>c.jsx(Z.span,{...t,ref:r,style:{...nd,...t.style}}));li.displayName=rd;var id=li,[St]=Je("Tooltip",[xt]),kt=xt(),ci="TooltipProvider",od=700,Xt="tooltip.open",[ad,hn]=St(ci),ui=t=>{const{__scopeTooltip:r,delayDuration:o=od,skipDelayDuration:i=300,disableHoverableContent:e=!1,children:n}=t,a=m.useRef(!0),l=m.useRef(!1),d=m.useRef(0);return m.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),c.jsx(ad,{scope:r,isOpenDelayedRef:a,delayDuration:o,onOpen:m.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(u=>{l.current=u},[]),disableHoverableContent:e,children:n})};ui.displayName=ci;var Be="Tooltip",[sd,He]=St(Be),di=t=>{const{__scopeTooltip:r,children:o,open:i,defaultOpen:e,onOpenChange:n,disableHoverableContent:a,delayDuration:l}=t,d=hn(Be,t.__scopeTooltip),u=kt(r),[f,g]=m.useState(null),h=Oe(),v=m.useRef(0),y=a??d.disableHoverableContent,p=l??d.delayDuration,b=m.useRef(!1),[x,_]=wt({prop:i,defaultProp:e??!1,onChange:O=>{O?(d.onOpen(),document.dispatchEvent(new CustomEvent(Xt))):d.onClose(),n?.(O)},caller:Be}),w=m.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),k=m.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,_(!0)},[_]),I=m.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_(!1)},[_]),P=m.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,_(!0),v.current=0},p)},[p,_]);return m.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),c.jsx(oi,{...u,children:c.jsx(sd,{scope:r,contentId:h,open:x,stateAttribute:w,trigger:f,onTriggerChange:g,onTriggerEnter:m.useCallback(()=>{d.isOpenDelayedRef.current?P():k()},[d.isOpenDelayedRef,P,k]),onTriggerLeave:m.useCallback(()=>{y?I():(window.clearTimeout(v.current),v.current=0)},[I,y]),onOpen:k,onClose:I,disableHoverableContent:y,children:o})})};di.displayName=Be;var Yt="TooltipTrigger",fi=m.forwardRef((t,r)=>{const{__scopeTooltip:o,...i}=t,e=He(Yt,o),n=hn(Yt,o),a=kt(o),l=m.useRef(null),d=G(r,l,e.onTriggerChange),u=m.useRef(!1),f=m.useRef(!1),g=m.useCallback(()=>u.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),c.jsx(vn,{asChild:!0,...a,children:c.jsx(Z.button,{"aria-describedby":e.open?e.contentId:void 0,"data-state":e.stateAttribute,...i,ref:d,onPointerMove:R(t.onPointerMove,h=>{h.pointerType!=="touch"&&!f.current&&!n.isPointerInTransitRef.current&&(e.onTriggerEnter(),f.current=!0)}),onPointerLeave:R(t.onPointerLeave,()=>{e.onTriggerLeave(),f.current=!1}),onPointerDown:R(t.onPointerDown,()=>{e.open&&e.onClose(),u.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:R(t.onFocus,()=>{u.current||e.onOpen()}),onBlur:R(t.onBlur,e.onClose),onClick:R(t.onClick,e.onClose)})})});fi.displayName=Yt;var yn="TooltipPortal",[ld,cd]=St(yn,{forceMount:void 0}),mi=t=>{const{__scopeTooltip:r,forceMount:o,children:i,container:e}=t,n=He(yn,r);return c.jsx(ld,{scope:r,forceMount:o,children:c.jsx(pe,{present:o||n.open,children:c.jsx(_t,{asChild:!0,container:e,children:i})})})};mi.displayName=yn;var De="TooltipContent",gi=m.forwardRef((t,r)=>{const o=cd(De,t.__scopeTooltip),{forceMount:i=o.forceMount,side:e="top",...n}=t,a=He(De,t.__scopeTooltip);return c.jsx(pe,{present:i||a.open,children:a.disableHoverableContent?c.jsx(pi,{side:e,...n,ref:r}):c.jsx(ud,{side:e,...n,ref:r})})}),ud=m.forwardRef((t,r)=>{const o=He(De,t.__scopeTooltip),i=hn(De,t.__scopeTooltip),e=m.useRef(null),n=G(r,e),[a,l]=m.useState(null),{trigger:d,onClose:u}=o,f=e.current,{onPointerInTransitChange:g}=i,h=m.useCallback(()=>{l(null),g(!1)},[g]),v=m.useCallback((y,p)=>{const b=y.currentTarget,x={x:y.clientX,y:y.clientY},_=gd(x,b.getBoundingClientRect()),w=pd(x,_),k=vd(p.getBoundingClientRect()),I=yd([...w,...k]);l(I),g(!0)},[g]);return m.useEffect(()=>()=>h(),[h]),m.useEffect(()=>{if(d&&f){const y=b=>v(b,f),p=b=>v(b,d);return d.addEventListener("pointerleave",y),f.addEventListener("pointerleave",p),()=>{d.removeEventListener("pointerleave",y),f.removeEventListener("pointerleave",p)}}},[d,f,v,h]),m.useEffect(()=>{if(a){const y=p=>{const b=p.target,x={x:p.clientX,y:p.clientY},_=d?.contains(b)||f?.contains(b),w=!hd(x,a);_?h():w&&(h(),u())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[d,f,a,u,h]),c.jsx(pi,{...t,ref:n})}),[dd,fd]=St(Be,{isInside:!1}),md=gc("TooltipContent"),pi=m.forwardRef((t,r)=>{const{__scopeTooltip:o,children:i,"aria-label":e,onEscapeKeyDown:n,onPointerDownOutside:a,...l}=t,d=He(De,o),u=kt(o),{onClose:f}=d;return m.useEffect(()=>(document.addEventListener(Xt,f),()=>document.removeEventListener(Xt,f)),[f]),m.useEffect(()=>{if(d.trigger){const g=h=>{h.target?.contains(d.trigger)&&f()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,f]),c.jsx(ht,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:c.jsxs(ai,{"data-state":d.stateAttribute,...u,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[c.jsx(md,{children:i}),c.jsx(dd,{scope:o,isInside:!0,children:c.jsx(id,{id:d.contentId,role:"tooltip",children:e||i})})]})})});gi.displayName=De;var vi="TooltipArrow",hi=m.forwardRef((t,r)=>{const{__scopeTooltip:o,...i}=t,e=kt(o);return fd(vi,o).isInside?null:c.jsx(si,{...e,...i,ref:r})});hi.displayName=vi;function gd(t,r){const o=Math.abs(r.top-t.y),i=Math.abs(r.bottom-t.y),e=Math.abs(r.right-t.x),n=Math.abs(r.left-t.x);switch(Math.min(o,i,e,n)){case n:return"left";case e:return"right";case o:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function pd(t,r,o=5){const i=[];switch(r){case"top":i.push({x:t.x-o,y:t.y+o},{x:t.x+o,y:t.y+o});break;case"bottom":i.push({x:t.x-o,y:t.y-o},{x:t.x+o,y:t.y-o});break;case"left":i.push({x:t.x+o,y:t.y-o},{x:t.x+o,y:t.y+o});break;case"right":i.push({x:t.x-o,y:t.y-o},{x:t.x-o,y:t.y+o});break}return i}function vd(t){const{top:r,right:o,bottom:i,left:e}=t;return[{x:e,y:r},{x:o,y:r},{x:o,y:i},{x:e,y:i}]}function hd(t,r){const{x:o,y:i}=t;let e=!1;for(let n=0,a=r.length-1;n<r.length;a=n++){const l=r[n],d=r[a],u=l.x,f=l.y,g=d.x,h=d.y;f>i!=h>i&&o<(g-u)*(i-f)/(h-f)+u&&(e=!e)}return e}function yd(t){const r=t.slice();return r.sort((o,i)=>o.x<i.x?-1:o.x>i.x?1:o.y<i.y?-1:o.y>i.y?1:0),bd(r)}function bd(t){if(t.length<=1)return t.slice();const r=[];for(let i=0;i<t.length;i++){const e=t[i];for(;r.length>=2;){const n=r[r.length-1],a=r[r.length-2];if((n.x-a.x)*(e.y-a.y)>=(n.y-a.y)*(e.x-a.x))r.pop();else break}r.push(e)}r.pop();const o=[];for(let i=t.length-1;i>=0;i--){const e=t[i];for(;o.length>=2;){const n=o[o.length-1],a=o[o.length-2];if((n.x-a.x)*(e.y-a.y)>=(n.y-a.y)*(e.x-a.x))o.pop();else break}o.push(e)}return o.pop(),r.length===1&&o.length===1&&r[0].x===o[0].x&&r[0].y===o[0].y?r:r.concat(o)}var $d=ui,xd=di,_d=fi,wd=mi,Sd=gi,kd=hi;function yi({delayDuration:t=0,...r}){return c.jsx($d,{"data-slot":"tooltip-provider",delayDuration:t,...r})}function bn({...t}){return c.jsx(yi,{children:c.jsx(xd,{"data-slot":"tooltip",...t})})}function $n({...t}){return c.jsx(_d,{"data-slot":"tooltip-trigger",...t})}function xn({className:t,sideOffset:r=0,children:o,...i}){return c.jsx(wd,{children:c.jsxs(Sd,{"data-slot":"tooltip-content",sideOffset:r,className:$.cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...i,children:[o,c.jsx(kd,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}const Q=N.forwardRef(({children:t,tooltip:r,side:o="bottom",align:i="center",className:e,...n},a)=>c.jsxs(bn,{children:[c.jsx($n,{asChild:!0,children:c.jsxs(ce,{variant:"ghost",size:"icon",...n,className:$.cn("aui-button-icon size-6 p-1",e),ref:a,children:[c.jsx(oc,{children:t}),c.jsx("span",{className:"aui-sr-only sr-only",children:r})]})}),c.jsx(xn,{side:o,align:i,children:r})]}));Q.displayName="TooltipIconButton";function jd(t){return N.useMemo(()=>t.reduce((r,o)=>(r?.[o.language]&&!o.overrideExisting||(r={...r,[o.language]:{CodeHeader:o.Header??(()=>null),SyntaxHighlighter:o.Component??void 0}}),r),{}),[t])}const Id=()=>{const{plugins:t}=$.useElements(),r=jd(t);return c.jsx(Vt.MarkdownTextPrimitive,{remarkPlugins:[Uo],className:"aui-md",components:Pd,componentsByLanguage:r})},bi=N.memo(Id),Nd=({language:t,code:r})=>{const i=j.useAssistantState(({message:l})=>l).status?.type==="complete",{isCopied:e,copyToClipboard:n}=Od(),a=()=>{!r||e||n(r)};return i?c.jsxs("div",{className:"aui-code-header-root bg-muted-foreground/15 text-foreground dark:bg-muted-foreground/20 mt-4 flex items-center justify-between gap-4 rounded-t-lg px-4 py-2 text-sm font-semibold",children:[c.jsx("span",{className:"aui-code-header-language lowercase [&>span]:text-xs",children:t}),c.jsxs(Q,{tooltip:"Copy",onClick:a,children:[!e&&c.jsx(Cr,{}),e&&c.jsx(Ge,{})]})]}):null},Od=({copiedDuration:t=3e3}={})=>{const[r,o]=N.useState(!1);return{isCopied:r,copyToClipboard:e=>{e&&navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),t)})}}},Pd=Vt.unstable_memoizeMarkdownComponents({h1:({className:t,...r})=>c.jsx("h1",{className:$.cn("aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",t),...r}),h2:({className:t,...r})=>c.jsx("h2",{className:$.cn("aui-md-h2 mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",t),...r}),h3:({className:t,...r})=>c.jsx("h3",{className:$.cn("aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",t),...r}),h4:({className:t,...r})=>c.jsx("h4",{className:$.cn("aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",t),...r}),h5:({className:t,...r})=>c.jsx("h5",{className:$.cn("aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0",t),...r}),h6:({className:t,...r})=>c.jsx("h6",{className:$.cn("aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",t),...r}),p:({className:t,...r})=>c.jsx("p",{className:$.cn("aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",t),...r}),a:({className:t,...r})=>c.jsx("a",{className:$.cn("aui-md-a text-primary font-medium underline underline-offset-4",t),...r}),blockquote:({className:t,...r})=>c.jsx("blockquote",{className:$.cn("aui-md-blockquote border-l-2 pl-6 italic",t),...r}),ul:({className:t,...r})=>c.jsx("ul",{className:$.cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2",t),...r}),ol:({className:t,...r})=>c.jsx("ol",{className:$.cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2",t),...r}),hr:({className:t,...r})=>c.jsx("hr",{className:$.cn("aui-md-hr my-5 border-b",t),...r}),table:({className:t,...r})=>c.jsx("table",{className:$.cn("aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",t),...r}),th:({className:t,...r})=>c.jsx("th",{className:$.cn("aui-md-th bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [[align=center]]:text-center [[align=right]]:text-right",t),...r}),td:({className:t,...r})=>c.jsx("td",{className:$.cn("aui-md-td border-b border-l px-4 py-2 text-left last:border-r [[align=center]]:text-center [[align=right]]:text-right",t),...r}),tr:({className:t,...r})=>c.jsx("tr",{className:$.cn("aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",t),...r}),sup:({className:t,...r})=>c.jsx("sup",{className:$.cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline",t),...r}),pre:({className:t,...r})=>c.jsx("pre",{className:$.cn("aui-md-pre text-foreground bg-muted overflow-x-auto rounded-t-none! rounded-b-lg border border-t-0 p-4",t),...r}),code:function({className:r,...o}){const i=Vt.useIsMarkdownCodeBlock();return c.jsx("code",{className:$.cn(!i&&"aui-md-inline-code bg-muted rounded border font-semibold",r),...o})},CodeHeader:Nd}),Cd=s.union([s.object({type:s.literal("text"),text:s.string()}),s.object({type:s.literal("image"),data:s.string()})]).and(s.object({_meta:s.object({"getgram.ai/mime-type":s.string()}).optional()})),Ed=s.object({content:s.array(Cd)}).or(s._undefined$1());function $i(t){return t.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ")}const Dd=({toolName:t,status:r,result:o,args:i})=>{const n=j.useAssistantState(({message:h})=>h).parts.filter(h=>h.type==="tool-call"),a=n.findIndex(h=>h.toolName===t),l=N.useMemo(()=>r.type==="complete"?c.jsx(Ge,{className:"size-4 text-emerald-500"}):r.type==="incomplete"?c.jsx($.CircleAlert,{className:"size-4 text-rose-500"}):c.jsx(nn,{className:"text-muted-foreground size-4 animate-spin"}),[r]),d=$.useDensity(),[u,f]=N.useState(!1),g=h=>{h.stopPropagation(),f(!u)};return c.jsxs("div",{className:$.cn("aui-tool-fallback-root flex w-full flex-col",a!==-1&&"border-b",a===n.length-1&&"border-b-0"),children:[c.jsxs("button",{className:$.cn("aui-tool-fallback-header flex h-full w-full cursor-pointer items-center",d("py-xs"),d("px-md"),d("gap-md")),onClick:g,children:[c.jsx("div",{children:l}),c.jsx("div",{className:"select-none",children:$i(t)}),c.jsx("div",{className:"ml-auto",children:c.jsx(ce,{variant:"ghost",size:"icon",className:"cursor-pointer hover:bg-transparent",onClick:g,children:u?c.jsx(Pr,{className:"size-4"}):c.jsx(tn,{className:"size-4"})})})]}),c.jsx("div",{className:"bg-muted flex overflow-hidden transition-all duration-300 ease-out",style:{maxHeight:u?"1000px":"0"},children:u&&c.jsx(Ud,{result:o,args:i})})]})};function Ud({result:t,args:r}){const[o,i]=N.useState("result"),e=(n,a)=>{n.stopPropagation(),i(a)};return c.jsxs("div",{className:"flex w-full flex-col border-t",children:[c.jsx(Td,{tabs:[{id:"result",label:"Output"},{id:"args",label:"Arguments"}],activeTab:o,onTabClick:e}),c.jsxs("div",{className:"bg-background relative flex w-full flex-col items-start gap-4 border-t",children:[c.jsx("div",{className:$.cn("w-full transition-opacity",o==="args"?"opacity-100":"pointer-events-none absolute opacity-0"),children:c.jsx(xi,{text:JSON.stringify(r,null,2),language:"json"})}),c.jsx("div",{className:$.cn("w-full transition-opacity",o==="result"?"opacity-100":"pointer-events-none absolute opacity-0"),children:c.jsx(Ad,{result:t})})]})]})}function Td({tabs:t,activeTab:r,onTabClick:o}){return c.jsx("div",{className:"bg-muted flex h-full items-center px-3 py-2",children:t.map(i=>c.jsx("button",{onClick:e=>o(e,i.id),className:$.cn("cursor-pointer rounded-md px-3 py-1 text-sm font-medium transition-all",r===i.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:i.label},i.id))})}function Ad({result:t,className:r}){const o=Ed.parse(t);return c.jsx("div",{className:$.cn("w-full",r),children:o?.content.map((i,e)=>{switch(i.type){case"text":{const n=Rd(i._meta?.["getgram.ai/mime-type"]??"text/plain"),a=zd(i.text,n);return c.jsx(xi,{text:a,language:n},i.text)}case"image":{const n=`data:image/png;base64,${i.data}`;return c.jsx("div",{className:"flex items-center justify-center rounded-lg p-5",style:{backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
10
10
|
linear-gradient(135deg, #ccc 25%, transparent 25%),
|
|
11
11
|
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
|
12
12
|
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:c.jsx("img",{src:n,className:"max-h-[300px] max-w-full object-contain"})},e)}default:return c.jsx("pre",{className:"aui-tool-fallback-result-content whitespace-pre-wrap",children:JSON.stringify(i,null,2)},e)}})})}function Rd(t){let r;switch(t){case"text/markdown":r="markdown";break;case"text/html":r="html";break;case"text/css":r="css";break;case"application/json":r="json";break;case"text/javascript":r="javascript";break;case"text/typescript":r="typescript";break;case"text/python":r="python";break;default:return}return r}function xi({text:t,language:r,className:o}){const[i,e]=N.useState(null);return N.useEffect(()=>{r&&To.codeToHtml(t,{lang:r,theme:"github-dark-default",rootStyle:"background-color: transparent;",transformers:[{pre(n){n.properties.class="w-full py-3 px-5 max-h-[300px] overflow-y-auto whitespace-pre-wrap text-left"}}]}).then(e)},[t]),i?c.jsx("div",{className:$.cn("aui-tool-fallback-result-content w-full bg-slate-800/90",o),dangerouslySetInnerHTML:{__html:i}}):c.jsx("pre",{className:$.cn("aui-tool-fallback-result-content text-background flex w-full items-start bg-slate-800/90 px-5 py-3 whitespace-normal",o),children:t})}function zd(t,r){if(!r)return t;switch(r){case"json":return JSON.stringify(JSON.parse(t),null,2);default:return t}}var jt="Collapsible",[Ld]=Je(jt),[Md,_n]=Ld(jt),_i=m.forwardRef((t,r)=>{const{__scopeCollapsible:o,open:i,defaultOpen:e,disabled:n,onOpenChange:a,...l}=t,[d,u]=wt({prop:i,defaultProp:e??!1,onChange:a,caller:jt});return c.jsx(Md,{scope:o,disabled:n,contentId:Oe(),open:d,onOpenToggle:m.useCallback(()=>u(f=>!f),[u]),children:c.jsx(Z.div,{"data-state":Sn(d),"data-disabled":n?"":void 0,...l,ref:r})})});_i.displayName=jt;var wi="CollapsibleTrigger",Si=m.forwardRef((t,r)=>{const{__scopeCollapsible:o,...i}=t,e=_n(wi,o);return c.jsx(Z.button,{type:"button","aria-controls":e.contentId,"aria-expanded":e.open||!1,"data-state":Sn(e.open),"data-disabled":e.disabled?"":void 0,disabled:e.disabled,...i,ref:r,onClick:R(t.onClick,e.onOpenToggle)})});Si.displayName=wi;var wn="CollapsibleContent",ki=m.forwardRef((t,r)=>{const{forceMount:o,...i}=t,e=_n(wn,t.__scopeCollapsible);return c.jsx(pe,{present:o||e.open,children:({present:n})=>c.jsx(Zd,{...i,ref:r,present:n})})});ki.displayName=wn;var Zd=m.forwardRef((t,r)=>{const{__scopeCollapsible:o,present:i,children:e,...n}=t,a=_n(wn,o),[l,d]=m.useState(i),u=m.useRef(null),f=G(r,u),g=m.useRef(0),h=g.current,v=m.useRef(0),y=v.current,p=a.open||l,b=m.useRef(p),x=m.useRef(void 0);return m.useEffect(()=>{const _=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(_)},[]),Y(()=>{const _=u.current;if(_){x.current=x.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";const w=_.getBoundingClientRect();g.current=w.height,v.current=w.width,b.current||(_.style.transitionDuration=x.current.transitionDuration,_.style.animationName=x.current.animationName),d(i)}},[a.open,i]),c.jsx(Z.div,{"data-state":Sn(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!p,...n,ref:f,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...t.style},children:p&&e})});function Sn(t){return t?"open":"closed"}var Fd=_i;function Vd({...t}){return c.jsx(Fd,{"data-slot":"collapsible",...t})}function Wd({...t}){return c.jsx(Si,{"data-slot":"collapsible-trigger",...t})}function Bd({...t}){return c.jsx(ki,{"data-slot":"collapsible-content",...t})}const ur=200,ji=({className:t,children:r})=>{const o=N.useRef(null),[i,e]=N.useState(!1),n=j.useScrollLock(o,ur),a=N.useCallback(l=>{l||n(),e(l)},[n]);return c.jsx(Vd,{ref:o,open:i,onOpenChange:a,className:$.cn("aui-reasoning-root mb-4 w-full",t),style:{"--animation-duration":`${ur}ms`},children:r})};ji.displayName="ReasoningRoot";const Gd=({className:t})=>c.jsx("div",{className:$.cn("aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-16","bg-[linear-gradient(to_top,var(--color-background),transparent)]","fade-in-0 animate-in","group-data-[state=open]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:delay-[calc(var(--animation-duration)*0.75)]","group-data-[state=open]/collapsible-content:fill-mode-forwards","duration-(--animation-duration)","group-data-[state=open]/collapsible-content:duration-(--animation-duration)",t)}),Jd=({active:t,className:r})=>c.jsxs(Wd,{className:$.cn("aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground -mb-2 flex max-w-[75%] items-center gap-2 py-2 text-sm transition-colors",r,t&&"shimmer"),children:[c.jsx(ml,{className:"aui-reasoning-trigger-icon size-4 shrink-0"}),c.jsxs("span",{className:"aui-reasoning-trigger-label-wrapper relative inline-block leading-none",children:[c.jsx("span",{children:"Reasoning"}),t?c.jsx("span",{"aria-hidden":!0,className:"aui-reasoning-trigger-shimmer shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",children:"Reasoning"}):null]}),c.jsx(tn,{className:$.cn("aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0","transition-transform duration-(--animation-duration) ease-out","group-data-[state=closed]/trigger:-rotate-90","group-data-[state=open]/trigger:rotate-0")})]}),Ii=({className:t,children:r,"aria-busy":o})=>c.jsxs(Bd,{className:$.cn("aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none","group/collapsible-content ease-out","data-[state=closed]:animate-collapsible-up","data-[state=open]:animate-collapsible-down","data-[state=closed]:fill-mode-forwards","data-[state=closed]:pointer-events-none","data-[state=open]:duration-(--animation-duration)","data-[state=closed]:duration-(--animation-duration)",t),"aria-busy":o,children:[r,c.jsx(Gd,{})]});Ii.displayName="ReasoningContent";const Ni=({className:t,children:r})=>c.jsx("div",{className:$.cn("aui-reasoning-text relative z-0 space-y-4 pt-4 pl-6 leading-relaxed","transform-gpu transition-[transform,opacity]","group-data-[state=open]/collapsible-content:animate-in","group-data-[state=closed]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-in-0","group-data-[state=closed]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:slide-in-from-top-4","group-data-[state=closed]/collapsible-content:slide-out-to-top-4","group-data-[state=open]/collapsible-content:duration-(--animation-duration)","group-data-[state=closed]/collapsible-content:duration-(--animation-duration)","[&_p]:-mb-2",t),children:r});Ni.displayName="ReasoningText";const Kd=()=>c.jsx(bi,{}),Hd=({children:t,startIndex:r,endIndex:o})=>{const i=j.useAssistantState(({message:e})=>{if(e.status?.type!=="running")return!1;const n=e.parts.length-1;return n<0||e.parts[n]?.type!=="reasoning"?!1:n>=r&&n<=o});return c.jsxs(ji,{children:[c.jsx(Jd,{active:i}),c.jsx(Ii,{"aria-busy":i,children:c.jsx(Ni,{children:t})})]})},Oi=N.memo(Kd);Oi.displayName="Reasoning";const Pi=N.memo(Hd);Pi.displayName="ReasoningGroup";var At="focusScope.autoFocusOnMount",Rt="focusScope.autoFocusOnUnmount",dr={bubbles:!1,cancelable:!0},qd="FocusScope",kn=m.forwardRef((t,r)=>{const{loop:o=!1,trapped:i=!1,onMountAutoFocus:e,onUnmountAutoFocus:n,...a}=t,[l,d]=m.useState(null),u=xe(e),f=xe(n),g=m.useRef(null),h=G(r,p=>d(p)),v=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(i){let p=function(w){if(v.paused||!l)return;const k=w.target;l.contains(k)?g.current=k:he(g.current,{select:!0})},b=function(w){if(v.paused||!l)return;const k=w.relatedTarget;k!==null&&(l.contains(k)||he(g.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const I of w)I.removedNodes.length>0&&he(l)};document.addEventListener("focusin",p),document.addEventListener("focusout",b);const _=new MutationObserver(x);return l&&_.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",b),_.disconnect()}}},[i,l,v.paused]),m.useEffect(()=>{if(l){mr.add(v);const p=document.activeElement;if(!l.contains(p)){const x=new CustomEvent(At,dr);l.addEventListener(At,u),l.dispatchEvent(x),x.defaultPrevented||(Xd(nf(Ci(l)),{select:!0}),document.activeElement===p&&he(l))}return()=>{l.removeEventListener(At,u),setTimeout(()=>{const x=new CustomEvent(Rt,dr);l.addEventListener(Rt,f),l.dispatchEvent(x),x.defaultPrevented||he(p??document.body,{select:!0}),l.removeEventListener(Rt,f),mr.remove(v)},0)}}},[l,u,f,v]);const y=m.useCallback(p=>{if(!o&&!i||v.paused)return;const b=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,x=document.activeElement;if(b&&x){const _=p.currentTarget,[w,k]=Yd(_);w&&k?!p.shiftKey&&x===k?(p.preventDefault(),o&&he(w,{select:!0})):p.shiftKey&&x===w&&(p.preventDefault(),o&&he(k,{select:!0})):x===_&&p.preventDefault()}},[o,i,v.paused]);return c.jsx(Z.div,{tabIndex:-1,...a,ref:h,onKeyDown:y})});kn.displayName=qd;function Xd(t,{select:r=!1}={}){const o=document.activeElement;for(const i of t)if(he(i,{select:r}),document.activeElement!==o)return}function Yd(t){const r=Ci(t),o=fr(r,t),i=fr(r.reverse(),t);return[o,i]}function Ci(t){const r=[],o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const e=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||e?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;o.nextNode();)r.push(o.currentNode);return r}function fr(t,r){for(const o of t)if(!Qd(o,{upTo:r}))return o}function Qd(t,{upTo:r}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(r!==void 0&&t===r)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function ef(t){return t instanceof HTMLInputElement&&"select"in t}function he(t,{select:r=!1}={}){if(t&&t.focus){const o=document.activeElement;t.focus({preventScroll:!0}),t!==o&&ef(t)&&r&&t.select()}}var mr=tf();function tf(){let t=[];return{add(r){const o=t[0];r!==o&&o?.pause(),t=gr(t,r),t.unshift(r)},remove(r){t=gr(t,r),t[0]?.resume()}}}function gr(t,r){const o=[...t],i=o.indexOf(r);return i!==-1&&o.splice(i,1),o}function nf(t){return t.filter(r=>r.tagName!=="A")}var zt=0;function Ei(){m.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??pr()),document.body.insertAdjacentElement("beforeend",t[1]??pr()),zt++,()=>{zt===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),zt--}},[])}function pr(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var ae=function(){return ae=Object.assign||function(r){for(var o,i=1,e=arguments.length;i<e;i++){o=arguments[i];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r},ae.apply(this,arguments)};function Di(t,r){var o={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&r.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var e=0,i=Object.getOwnPropertySymbols(t);e<i.length;e++)r.indexOf(i[e])<0&&Object.prototype.propertyIsEnumerable.call(t,i[e])&&(o[i[e]]=t[i[e]]);return o}function rf(t,r,o){if(o||arguments.length===2)for(var i=0,e=r.length,n;i<e;i++)(n||!(i in r))&&(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return t.concat(n||Array.prototype.slice.call(r))}var lt="right-scroll-bar-position",ct="width-before-scroll-bar",of="with-scroll-bars-hidden",af="--removed-body-scroll-bar-size";function Lt(t,r){return typeof t=="function"?t(r):t&&(t.current=r),t}function sf(t,r){var o=N.useState(function(){return{value:t,callback:r,facade:{get current(){return o.value},set current(i){var e=o.value;e!==i&&(o.value=i,o.callback(i,e))}}}})[0];return o.callback=r,o.facade}var lf=typeof window<"u"?m.useLayoutEffect:m.useEffect,vr=new WeakMap;function cf(t,r){var o=sf(null,function(i){return t.forEach(function(e){return Lt(e,i)})});return lf(function(){var i=vr.get(o);if(i){var e=new Set(i),n=new Set(t),a=o.current;e.forEach(function(l){n.has(l)||Lt(l,null)}),n.forEach(function(l){e.has(l)||Lt(l,a)})}vr.set(o,t)},[t]),o}function uf(t){return t}function df(t,r){r===void 0&&(r=uf);var o=[],i=!1,e={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return o.length?o[o.length-1]:t},useMedium:function(n){var a=r(n,i);return o.push(a),function(){o=o.filter(function(l){return l!==a})}},assignSyncMedium:function(n){for(i=!0;o.length;){var a=o;o=[],a.forEach(n)}o={push:function(l){return n(l)},filter:function(){return o}}},assignMedium:function(n){i=!0;var a=[];if(o.length){var l=o;o=[],l.forEach(n),a=o}var d=function(){var f=a;a=[],f.forEach(n)},u=function(){return Promise.resolve().then(d)};u(),o={push:function(f){a.push(f),u()},filter:function(f){return a=a.filter(f),o}}}};return e}function ff(t){t===void 0&&(t={});var r=df(null);return r.options=ae({async:!0,ssr:!1},t),r}var Ui=function(t){var r=t.sideCar,o=Di(t,["sideCar"]);if(!r)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=r.read();if(!i)throw new Error("Sidecar medium not found");return m.createElement(i,ae({},o))};Ui.isSideCarExport=!0;function mf(t,r){return t.useMedium(r),Ui}var Ti=ff(),Mt=function(){},It=m.forwardRef(function(t,r){var o=m.useRef(null),i=m.useState({onScrollCapture:Mt,onWheelCapture:Mt,onTouchMoveCapture:Mt}),e=i[0],n=i[1],a=t.forwardProps,l=t.children,d=t.className,u=t.removeScrollBar,f=t.enabled,g=t.shards,h=t.sideCar,v=t.noRelative,y=t.noIsolation,p=t.inert,b=t.allowPinchZoom,x=t.as,_=x===void 0?"div":x,w=t.gapMode,k=Di(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),I=h,P=cf([o,r]),O=ae(ae({},k),e);return m.createElement(m.Fragment,null,f&&m.createElement(I,{sideCar:Ti,removeScrollBar:u,shards:g,noRelative:v,noIsolation:y,inert:p,setCallbacks:n,allowPinchZoom:!!b,lockRef:o,gapMode:w}),a?m.cloneElement(m.Children.only(l),ae(ae({},O),{ref:P})):m.createElement(_,ae({},O,{className:d,ref:P}),l))});It.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};It.classNames={fullWidth:ct,zeroRight:lt};var gf=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pf(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var r=gf();return r&&t.setAttribute("nonce",r),t}function vf(t,r){t.styleSheet?t.styleSheet.cssText=r:t.appendChild(document.createTextNode(r))}function hf(t){var r=document.head||document.getElementsByTagName("head")[0];r.appendChild(t)}var yf=function(){var t=0,r=null;return{add:function(o){t==0&&(r=pf())&&(vf(r,o),hf(r)),t++},remove:function(){t--,!t&&r&&(r.parentNode&&r.parentNode.removeChild(r),r=null)}}},bf=function(){var t=yf();return function(r,o){m.useEffect(function(){return t.add(r),function(){t.remove()}},[r&&o])}},Ai=function(){var t=bf(),r=function(o){var i=o.styles,e=o.dynamic;return t(i,e),null};return r},$f={left:0,top:0,right:0,gap:0},Zt=function(t){return parseInt(t||"",10)||0},xf=function(t){var r=window.getComputedStyle(document.body),o=r[t==="padding"?"paddingLeft":"marginLeft"],i=r[t==="padding"?"paddingTop":"marginTop"],e=r[t==="padding"?"paddingRight":"marginRight"];return[Zt(o),Zt(i),Zt(e)]},_f=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return $f;var r=xf(t),o=document.documentElement.clientWidth,i=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,i-o+r[2]-r[0])}},wf=Ai(),Ce="data-scroll-locked",Sf=function(t,r,o,i){var e=t.left,n=t.top,a=t.right,l=t.gap;return o===void 0&&(o="margin"),`
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
|
|
54
54
|
If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
55
55
|
|
|
56
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return m.useEffect(()=>{t&&(document.getElementById(t)||console.error(o))},[o,t]),null},Xf="DialogDescriptionWarning",Yf=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${no(Xf).contentName}}.`;return m.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");r&&e&&(document.getElementById(r)||console.warn(i))},[i,t,r]),null},Qf=Vi,em=Bi,tm=Ji,nm=Ki,rm=Hi,im=Xi,om=eo;function am({...t}){return c.jsx(Qf,{"data-slot":"dialog",...t})}function sm({...t}){return c.jsx(em,{"data-slot":"dialog-trigger",...t})}function lm({...t}){return c.jsx(tm,{"data-slot":"dialog-portal",...t})}function cm({className:t,...r}){return c.jsx(nm,{"data-slot":"dialog-overlay",className:$.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...r})}function um({className:t,children:r,showCloseButton:o=!0,...i}){return c.jsxs(lm,{"data-slot":"dialog-portal",children:[c.jsx(cm,{}),c.jsxs(rm,{"data-slot":"dialog-content",className:$.cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...i,children:[r,o&&c.jsxs(om,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[c.jsx(rn,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function dm({className:t,...r}){return c.jsx(im,{"data-slot":"dialog-title",className:$.cn("text-lg leading-none font-semibold",t),...r})}function fm(t,r=[]){let o=[];function i(n,a){const l=m.createContext(a);l.displayName=n+"Context";const d=o.length;o=[...o,a];const u=g=>{const{scope:h,children:v,...y}=g,p=h?.[t]?.[d]||l,b=m.useMemo(()=>y,Object.values(y));return c.jsx(p.Provider,{value:b,children:v})};u.displayName=n+"Provider";function f(g,h){const v=h?.[t]?.[d]||l,y=m.useContext(v);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${g}\` must be used within \`${n}\``)}return[u,f]}const e=()=>{const n=o.map(a=>m.createContext(a));return function(l){const d=l?.[t]||n;return m.useMemo(()=>({[`__scope${t}`]:{...l,[t]:d}}),[l,d])}};return e.scopeName=t,[i,mm(e,...r)]}function mm(...t){const r=t[0];if(t.length===1)return r;const o=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(n){const a=i.reduce((l,{useScope:d,scopeName:u})=>{const g=d(n)[`__scope${u}`];return{...l,...g}},{});return m.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return o.scopeName=r.scopeName,o}var gm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Pn=gm.reduce((t,r)=>{const o=Dr(`Primitive.${r}`),i=m.forwardRef((e,n)=>{const{asChild:a,...l}=e,d=a?o:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...l,ref:n})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});function pm(){return Qs.useSyncExternalStore(vm,()=>!0,()=>!1)}function vm(){return()=>{}}var Cn="Avatar",[hm]=fm(Cn),[ym,ro]=hm(Cn),io=m.forwardRef((t,r)=>{const{__scopeAvatar:o,...i}=t,[e,n]=m.useState("idle");return c.jsx(ym,{scope:o,imageLoadingStatus:e,onImageLoadingStatusChange:n,children:c.jsx(Pn.span,{...i,ref:r})})});io.displayName=Cn;var oo="AvatarImage",ao=m.forwardRef((t,r)=>{const{__scopeAvatar:o,src:i,onLoadingStatusChange:e=()=>{},...n}=t,a=ro(oo,o),l=bm(i,n),d=xe(u=>{e(u),a.onImageLoadingStatusChange(u)});return Y(()=>{l!=="idle"&&d(l)},[l,d]),l==="loaded"?c.jsx(Pn.img,{...n,ref:r,src:i}):null});ao.displayName=oo;var so="AvatarFallback",lo=m.forwardRef((t,r)=>{const{__scopeAvatar:o,delayMs:i,...e}=t,n=ro(so,o),[a,l]=m.useState(i===void 0);return m.useEffect(()=>{if(i!==void 0){const d=window.setTimeout(()=>l(!0),i);return()=>window.clearTimeout(d)}},[i]),a&&n.imageLoadingStatus!=="loaded"?c.jsx(Pn.span,{...e,ref:r}):null});lo.displayName=so;function xr(t,r){return t?r?(t.src!==r&&(t.src=r),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function bm(t,{referrerPolicy:r,crossOrigin:o}){const i=pm(),e=m.useRef(null),n=i?(e.current||(e.current=new window.Image),e.current):null,[a,l]=m.useState(()=>xr(n,t));return Y(()=>{l(xr(n,t))},[n,t]),Y(()=>{const d=g=>()=>{l(g)};if(!n)return;const u=d("loaded"),f=d("error");return n.addEventListener("load",u),n.addEventListener("error",f),r&&(n.referrerPolicy=r),typeof o=="string"&&(n.crossOrigin=o),()=>{n.removeEventListener("load",u),n.removeEventListener("error",f)}},[n,o,r]),a}var $m=io,xm=ao,_m=lo;function wm({className:t,...r}){return c.jsx($m,{"data-slot":"avatar",className:$.cn("relative flex size-8 shrink-0 overflow-hidden rounded-full",t),...r})}function Sm({className:t,...r}){return c.jsx(xm,{"data-slot":"avatar-image",className:$.cn("aspect-square size-full",t),...r})}function km({className:t,...r}){return c.jsx(_m,{"data-slot":"avatar-fallback",className:$.cn("bg-muted flex size-full items-center justify-center rounded-full",t),...r})}const jm=t=>{const[r,o]=N.useState(void 0);return N.useEffect(()=>{if(!t){o(void 0);return}const i=URL.createObjectURL(t);return o(i),()=>{URL.revokeObjectURL(i)}},[t]),r},co=()=>{const{file:t,src:r}=j.useAssistantState(Ao.useShallow(({attachment:o})=>{if(o.type!=="image")return{};if(o.file)return{file:o.file};const i=o.content?.filter(e=>e.type==="image")[0]?.image;return i?{src:i}:{}}));return jm(t)??r},Im=({src:t})=>{const[r,o]=N.useState(!1);return c.jsx("img",{src:t,alt:"Image Preview",className:r?"aui-attachment-preview-image-loaded block h-auto max-h-[80vh] w-auto max-w-full object-contain":"aui-attachment-preview-image-loading hidden",onLoad:()=>o(!0)})},Nm=({children:t})=>{const r=co();return r?c.jsxs(am,{children:[c.jsx(sm,{className:"aui-attachment-preview-trigger hover:bg-accent/50 cursor-pointer transition-colors",asChild:!0,children:t}),c.jsxs(um,{className:"aui-attachment-preview-dialog-content [&_svg]:text-background [&>button]:bg-foreground/60 [&>button]:hover:[&_svg]:text-destructive p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:!ring-0",children:[c.jsx(dm,{className:"aui-sr-only sr-only",children:"Image Attachment Preview"}),c.jsx("div",{className:"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:c.jsx(Im,{src:r})})]})]}):t},Om=()=>{const t=j.useAssistantState(({attachment:o})=>o.type==="image"),r=co();return c.jsxs(wm,{className:"aui-attachment-tile-avatar h-full w-full rounded-none",children:[c.jsx(Sm,{src:r,alt:"Attachment preview",className:"aui-attachment-tile-image object-cover"}),c.jsx(km,{delayMs:t?200:0,children:c.jsx(wl,{className:"aui-attachment-tile-fallback-icon text-muted-foreground size-8"})})]})},uo=()=>{const r=j.useAssistantApi().attachment.source==="composer",o=j.useAssistantState(({attachment:e})=>e.type==="image"),i=j.useAssistantState(({attachment:e})=>{const n=e.type;switch(n){case"image":return"Image";case"document":return"Document";case"file":return"File";default:{const a=n;throw new Error(`Unknown attachment type: ${a}`)}}});return c.jsxs(bn,{children:[c.jsxs(j.AttachmentPrimitive.Root,{className:$.cn("aui-attachment-root relative",o&&"aui-attachment-root-composer only:[&>#attachment-tile]:size-24"),children:[c.jsx(Nm,{children:c.jsx($n,{asChild:!0,children:c.jsx("div",{className:$.cn("aui-attachment-tile bg-muted size-14 cursor-pointer overflow-hidden rounded-[14px] border transition-opacity hover:opacity-75",r&&"aui-attachment-tile-composer border-foreground/20"),role:"button",id:"attachment-tile","aria-label":`${i} attachment`,children:c.jsx(Om,{})})})}),r&&c.jsx(Pm,{})]}),c.jsx(xn,{side:"top",children:c.jsx(j.AttachmentPrimitive.Name,{})})]})},Pm=()=>c.jsx(j.AttachmentPrimitive.Remove,{asChild:!0,children:c.jsx(Q,{tooltip:"Remove file",className:"aui-attachment-tile-remove text-muted-foreground hover:[&_svg]:text-destructive absolute top-1.5 right-1.5 size-3.5 rounded-full bg-white opacity-100 shadow-sm hover:!bg-white [&_svg]:text-black",side:"top",children:c.jsx(rn,{className:"aui-attachment-remove-icon size-3 dark:stroke-[2.5px]"})})}),Cm=()=>c.jsx("div",{className:"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2",children:c.jsx(j.MessagePrimitive.Attachments,{components:{Attachment:uo}})}),Em=()=>c.jsx("div",{className:"aui-composer-attachments mb-2 flex w-full flex-row items-center gap-2 overflow-x-auto px-1.5 pt-0.5 pb-1 empty:hidden",children:c.jsx(j.ComposerPrimitive.Attachments,{components:{Attachment:uo}})}),Dm=()=>c.jsx(j.ComposerPrimitive.AddAttachment,{asChild:!0,children:c.jsx(Q,{tooltip:"Add Attachment",side:"bottom",variant:"ghost",size:"icon",align:"start",className:"aui-composer-add-attachment hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-[34px] rounded-full p-1 text-xs font-semibold","aria-label":"Add Attachment",children:c.jsx(zl,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})}),En=()=>{const{config:t}=$.useElements(),r=t.theme??{};return N.useMemo(()=>{const{colorScheme:o="light"}=r;return{className:o==="dark"||o==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[r])};var Ot="Popover",[fo]=Je(Ot,[xt]),qe=xt(),[Um,$e]=fo(Ot),mo=t=>{const{__scopePopover:r,children:o,open:i,defaultOpen:e,onOpenChange:n,modal:a=!1}=t,l=qe(r),d=m.useRef(null),[u,f]=m.useState(!1),[g,h]=wt({prop:i,defaultProp:e??!1,onChange:n,caller:Ot});return c.jsx(oi,{...l,children:c.jsx(Um,{scope:r,contentId:Oe(),triggerRef:d,open:g,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(v=>!v),[h]),hasCustomAnchor:u,onCustomAnchorAdd:m.useCallback(()=>f(!0),[]),onCustomAnchorRemove:m.useCallback(()=>f(!1),[]),modal:a,children:o})})};mo.displayName=Ot;var go="PopoverAnchor",Tm=m.forwardRef((t,r)=>{const{__scopePopover:o,...i}=t,e=$e(go,o),n=qe(o),{onCustomAnchorAdd:a,onCustomAnchorRemove:l}=e;return m.useEffect(()=>(a(),()=>l()),[a,l]),c.jsx(vn,{...n,...i,ref:r})});Tm.displayName=go;var po="PopoverTrigger",vo=m.forwardRef((t,r)=>{const{__scopePopover:o,...i}=t,e=$e(po,o),n=qe(o),a=G(r,e.triggerRef),l=c.jsx(Z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":e.open,"aria-controls":e.contentId,"data-state":xo(e.open),...i,ref:a,onClick:R(t.onClick,e.onOpenToggle)});return e.hasCustomAnchor?l:c.jsx(vn,{asChild:!0,...n,children:l})});vo.displayName=po;var Dn="PopoverPortal",[Am,Rm]=fo(Dn,{forceMount:void 0}),ho=t=>{const{__scopePopover:r,forceMount:o,children:i,container:e}=t,n=$e(Dn,r);return c.jsx(Am,{scope:r,forceMount:o,children:c.jsx(pe,{present:o||n.open,children:c.jsx(_t,{asChild:!0,container:e,children:i})})})};ho.displayName=Dn;var Ue="PopoverContent",yo=m.forwardRef((t,r)=>{const o=Rm(Ue,t.__scopePopover),{forceMount:i=o.forceMount,...e}=t,n=$e(Ue,t.__scopePopover);return c.jsx(pe,{present:i||n.open,children:n.modal?c.jsx(Lm,{...e,ref:r}):c.jsx(Mm,{...e,ref:r})})});yo.displayName=Ue;var zm=an("PopoverContent.RemoveScroll"),Lm=m.forwardRef((t,r)=>{const o=$e(Ue,t.__scopePopover),i=m.useRef(null),e=G(r,i),n=m.useRef(!1);return m.useEffect(()=>{const a=i.current;if(a)return Zi(a)},[]),c.jsx(jn,{as:zm,allowPinchZoom:!0,children:c.jsx(bo,{...t,ref:e,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:R(t.onCloseAutoFocus,a=>{a.preventDefault(),n.current||o.triggerRef.current?.focus()}),onPointerDownOutside:R(t.onPointerDownOutside,a=>{const l=a.detail.originalEvent,d=l.button===0&&l.ctrlKey===!0,u=l.button===2||d;n.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:R(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),Mm=m.forwardRef((t,r)=>{const o=$e(Ue,t.__scopePopover),i=m.useRef(!1),e=m.useRef(!1);return c.jsx(bo,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{t.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||o.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,e.current=!1},onInteractOutside:n=>{t.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(e.current=!0));const a=n.target;o.triggerRef.current?.contains(a)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&e.current&&n.preventDefault()}})}),bo=m.forwardRef((t,r)=>{const{__scopePopover:o,trapFocus:i,onOpenAutoFocus:e,onCloseAutoFocus:n,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,...g}=t,h=$e(Ue,o),v=qe(o);return Ei(),c.jsx(kn,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:e,onUnmountAutoFocus:n,children:c.jsx(ht,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>h.onOpenChange(!1),children:c.jsx(ai,{"data-state":xo(h.open),role:"dialog",id:h.contentId,...v,...g,ref:r,style:{...g.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),$o="PopoverClose",Zm=m.forwardRef((t,r)=>{const{__scopePopover:o,...i}=t,e=$e($o,o);return c.jsx(Z.button,{type:"button",...i,ref:r,onClick:R(t.onClick,()=>e.onOpenChange(!1))})});Zm.displayName=$o;var Fm="PopoverArrow",Vm=m.forwardRef((t,r)=>{const{__scopePopover:o,...i}=t,e=qe(o);return c.jsx(si,{...e,...i,ref:r})});Vm.displayName=Fm;function xo(t){return t?"open":"closed"}var Wm=mo,Bm=vo,Gm=ho,Jm=yo;function Km({...t}){return c.jsx(Wm,{"data-slot":"popover",...t})}function Hm({...t}){return c.jsx(Bm,{"data-slot":"popover-trigger",...t})}function qm({className:t,align:r="center",sideOffset:o=4,...i}){return c.jsx(Gm,{children:c.jsx(Jm,{"data-slot":"popover-content",align:r,sideOffset:o,className:$.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...i})})}const fe=[.23,1,.32,1],Xm=({children:t})=>{const r=$.useRadius(),o=j.useAssistantState(({message:g})=>g).parts,i=o.filter(g=>g.type==="tool-call"),e=i.some(g=>g.status?.type==="running"),n=N.useMemo(()=>e?c.jsx(nn,{className:"text-muted-foreground size-4 animate-spin"}):c.jsx(Ge,{className:"size-4 text-green-500"}),[e]),{config:a}=$.useElements(),[l,d]=N.useState(a.tools?.expandToolGroupsByDefault??!1),u=$.useDensity(),f=N.useMemo(()=>{const g=o.filter(h=>h.type==="tool-call");return g.length===0?"No tools called":g.length===1?`Calling ${$i(g[0].toolName)}...`:e?`Calling ${g.length} tools...`:`Executed ${g.length} tools`},[o,e]);return a.tools?.components?.[i[0].toolName]?t:c.jsx(X.LazyMotion,{features:X.domAnimation,children:i.length>1?c.jsxs("button",{className:$.cn("group my-4 w-full max-w-xl cursor-pointer border",r("sm")),onClick:()=>d(!l),children:[c.jsxs("div",{className:$.cn("bg-muted/40 flex items-center rounded-b-none!",r("sm"),u("py-xs"),u("gap-md"),u("px-md"),l&&"border-b"),children:[c.jsx("span",{children:n}),c.jsx("span",{className:$.cn("font-semibold",e&&"shimmer"),children:f}),c.jsx("div",{className:"ml-auto",children:c.jsx(ce,{variant:"ghost",size:"icon",className:"cursor-pointer hover:bg-transparent",onClick:()=>d(!l),children:l?c.jsx(Pr,{className:"size-4"}):c.jsx(tn,{className:"size-4"})})})]}),c.jsx(X.AnimatePresence,{children:l&&c.jsx(oe.div,{initial:{height:0,opacity:0,y:-10},animate:{height:"auto",opacity:1,y:0},exit:{height:0,opacity:0,y:-10},transition:{duration:.3,ease:fe},style:{overflow:"hidden"},children:t})})]}):c.jsx("div",{className:$.cn("bg-muted/40 my-4 flex w-full max-w-xl cursor-pointer items-center rounded-b-none! border"),children:t})})},Un=()=>{const t=En(),r=$.useDensity(),{config:o}=$.useElements(),i=o.components??{};return c.jsx(X.LazyMotion,{features:X.domAnimation,children:c.jsx(X.MotionConfig,{reducedMotion:"user",children:c.jsx(j.ThreadPrimitive.Root,{className:$.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",t.className),children:c.jsxs(j.ThreadPrimitive.Viewport,{className:$.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",r("p-lg")),children:[c.jsx(j.ThreadPrimitive.If,{empty:!0,children:i.ThreadWelcome?c.jsx(i.ThreadWelcome,{}):c.jsx(Qm,{})}),c.jsx(j.ThreadPrimitive.Messages,{components:{UserMessage:i.UserMessage??lg,EditComposer:i.EditComposer??ug,AssistantMessage:i.AssistantMessage??og}}),c.jsx(j.ThreadPrimitive.If,{empty:!1,children:c.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),c.jsx(tg,{})]})})})})},Ym=()=>c.jsx(j.ThreadPrimitive.ScrollToBottom,{asChild:!0,children:c.jsx(Q,{tooltip:"Scroll to bottom",variant:"outline",className:"aui-thread-scroll-to-bottom dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible",children:c.jsx(cl,{})})}),Qm=()=>{const{config:t}=$.useElements(),r=$.useDensity(),{title:o,subtitle:i}=t.welcome??{},e=t.variant==="standalone";return c.jsxs("div",{className:$.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",e?"items-center justify-center":"",r("gap-lg")),children:[c.jsx("div",{className:$.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:c.jsxs("div",{className:$.cn("aui-thread-welcome-message flex flex-col",e?"items-center text-center":"size-full justify-start",r("gap-sm"),!e&&r("py-md")),children:[c.jsx(oe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:fe},className:$.cn("aui-thread-welcome-message-motion-1 font-semibold",r("text-title")),children:o}),c.jsx(oe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:fe},className:$.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",r("text-subtitle")),children:i})]})}),c.jsx(eg,{})]})},eg=()=>{const{config:t}=$.useElements(),r=$.useRadius(),o=$.useDensity(),i=t.welcome?.suggestions??[],e=t.variant==="standalone";return i.length===0?null:c.jsx("div",{className:$.cn("aui-thread-welcome-suggestions w-full",o("gap-md"),o("py-lg"),e?"flex flex-wrap items-center justify-center":i.length===1?"flex":"grid @md:grid-cols-2"),children:i.map((n,a)=>c.jsx(oe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:fe},className:$.cn("aui-thread-welcome-suggestion-display",!e&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:c.jsx(j.ThreadPrimitive.Suggestion,{prompt:n.action,send:!0,asChild:!0,children:c.jsxs(ce,{variant:"ghost",className:$.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",o("text-base"),e?`flex-row items-center ${o("gap-sm")} ${o("px-md")} ${o("py-sm")} ${r("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${o("gap-sm")} ${o("px-lg")} ${o("py-md")} ${r("xl")}`),"aria-label":n.action,children:[c.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-sm font-medium",children:n.title}),c.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:n.label})]})})},`suggested-action-${n.title}-${a}`))})},tg=()=>{const{config:t}=$.useElements(),r=$.useRadius(),o=$.useDensity(),i=t.composer??{placeholder:"Send a message...",attachments:!0},e=t.components??{};return e.Composer?c.jsx(e.Composer,{}):c.jsxs("div",{className:$.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",o("gap-md"),o("py-md"),r("xl")),children:[c.jsx(Ym,{}),c.jsxs(j.ComposerPrimitive.Root,{className:$.cn("aui-composer-root group/input-group border-input bg-background has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/5 dark:bg-background relative flex w-full flex-col border px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:ring-1",r("xl")),children:[i.attachments&&c.jsx(Em,{}),c.jsx(j.ComposerPrimitive.Input,{placeholder:i.placeholder,className:$.cn("aui-composer-input placeholder:text-muted-foreground mb-1 max-h-32 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 outline-none focus-visible:ring-0",o("h-input"),o("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),c.jsx(rg,{})]})]})},ng=()=>{const{model:t,setModel:r}=$.useElements(),[o,i]=N.useState(!1),[e,n]=N.useState(!1),a=N.useRef(null),l=N.useRef(0),d=N.useRef(!1);N.useEffect(()=>{o&&!d.current&&requestAnimationFrame(()=>{const f=a.current;f&&f.scrollHeight>0&&(f.scrollTop=l.current)}),d.current=o},[o]);const u=f=>{l.current=f.currentTarget.scrollTop};return c.jsx(yi,{children:c.jsxs(bn,{open:e,onOpenChange:n,children:[c.jsxs(Km,{open:o,onOpenChange:i,children:[c.jsx($n,{asChild:!0,children:c.jsx(Hm,{asChild:!0,children:c.jsx(ce,{variant:"ghost",size:"icon","data-state":o?"open":"closed",className:"aui-composer-model-picker data-[state=open]:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 flex w-fit items-center gap-2 rounded-full px-2.5 py-1 text-xs font-semibold","aria-label":"Model Settings",onPointerUp:f=>f.stopPropagation(),children:c.jsx(Fl,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),c.jsx(qm,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:c.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:u,children:s.MODELS.map(f=>c.jsxs(ce,{onClick:()=>{r(f)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[f===t?c.jsx("div",{children:c.jsx(Ge,{className:"size-4 text-emerald-500"})}):c.jsx("div",{className:"size-4",children:" "}),f]},f))})})]}),c.jsx(xn,{side:"bottom",align:"start",children:"Model Settings"})]})})},rg=()=>{const{config:t}=$.useElements(),r=$.useRadius(),o=t.composer??{attachments:!0};return c.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[c.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[o.attachments?c.jsx(Dm,{}):c.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),t.model?.showModelPicker&&c.jsx(ng,{})]}),c.jsx(j.ThreadPrimitive.If,{running:!1,children:c.jsx(j.ComposerPrimitive.Send,{asChild:!0,children:c.jsx(Q,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:$.cn("aui-composer-send size-[34px] p-1",r("full")),"aria-label":"Send message",children:c.jsx(dl,{className:"aui-composer-send-icon size-5"})})})}),c.jsx(j.ThreadPrimitive.If,{running:!0,children:c.jsx(j.ComposerPrimitive.Cancel,{asChild:!0,children:c.jsx(ce,{type:"button",variant:"default",size:"icon",className:$.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",r("full")),"aria-label":"Stop generating",children:c.jsx(Wl,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},ig=()=>c.jsx(j.MessagePrimitive.Error,{children:c.jsx(j.ErrorPrimitive.Root,{className:"aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200",children:c.jsx(j.ErrorPrimitive.Message,{className:"aui-message-error-message line-clamp-2"})})}),og=()=>{const{config:t}=$.useElements(),r=t.tools??{},o=t.components??{};return c.jsx(j.MessagePrimitive.Root,{asChild:!0,children:c.jsxs("div",{className:"aui-assistant-message-root animate-in fade-in slide-in-from-bottom-1 relative mx-auto w-full py-4 duration-150 ease-out last:mb-24","data-role":"assistant",children:[c.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[c.jsx(j.MessagePrimitive.Parts,{components:{Text:o.Text??bi,Image:o.Image??ag,tools:{by_name:r.components,Fallback:o.ToolFallback??Dd},Reasoning:o.Reasoning??Oi,ReasoningGroup:o.ReasoningGroup??Pi,ToolGroup:o.ToolGroup??Xm}}),c.jsx(ig,{})]}),c.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[c.jsx(_o,{}),c.jsx(sg,{})]})]})})},ag=t=>c.jsx("img",{src:t.image}),sg=()=>c.jsxs(j.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",autohideFloat:"single-branch",className:"aui-assistant-action-bar-root text-muted-foreground data-floating:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-floating:absolute data-floating:rounded-md data-floating:border data-floating:p-1 data-floating:shadow-sm",children:[c.jsx(j.ActionBarPrimitive.Copy,{asChild:!0,children:c.jsxs(Q,{tooltip:"Copy",children:[c.jsx(j.MessagePrimitive.If,{copied:!0,children:c.jsx(Ge,{})}),c.jsx(j.MessagePrimitive.If,{copied:!1,children:c.jsx(Cr,{})})]})}),c.jsx(j.ActionBarPrimitive.Reload,{asChild:!0,children:c.jsx(Q,{tooltip:"Refresh",children:c.jsx(Ml,{})})})]}),lg=()=>{const t=$.useRadius();return c.jsx(j.MessagePrimitive.Root,{asChild:!0,children:c.jsxs("div",{className:"aui-user-message-root animate-in fade-in slide-in-from-bottom-1 mx-auto grid w-full auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out first:mt-3 last:mb-5 [&:where(>*)]:col-start-2","data-role":"user",children:[c.jsx(Cm,{}),c.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[c.jsx("div",{className:$.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",t("xl")),children:c.jsx(j.MessagePrimitive.Parts,{})}),c.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:c.jsx(cg,{})})]}),c.jsx(_o,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},cg=()=>c.jsx(j.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:c.jsx(j.ActionBarPrimitive.Edit,{asChild:!0,children:c.jsx(Q,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:c.jsx(Al,{})})})}),ug=()=>c.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:c.jsxs(j.ComposerPrimitive.Root,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[c.jsx(j.ComposerPrimitive.Input,{className:"aui-edit-composer-input text-foreground flex min-h-[60px] w-full resize-none bg-transparent p-4 outline-none",autoFocus:!0}),c.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[c.jsx(j.ComposerPrimitive.Cancel,{asChild:!0,children:c.jsx(ce,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),c.jsx(j.ComposerPrimitive.Send,{asChild:!0,children:c.jsx(ce,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),_o=({className:t,...r})=>c.jsxs(j.BranchPickerPrimitive.Root,{hideWhenSingleBranch:!0,className:$.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",t),...r,children:[c.jsx(j.BranchPickerPrimitive.Previous,{asChild:!0,children:c.jsx(Q,{tooltip:"Previous",children:c.jsx(hl,{})})}),c.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[c.jsx(j.BranchPickerPrimitive.Number,{})," / ",c.jsx(j.BranchPickerPrimitive.Count,{})]}),c.jsx(j.BranchPickerPrimitive.Next,{asChild:!0,children:c.jsx(Q,{tooltip:"Next",children:c.jsx(bl,{})})})]}),wo=()=>{const{config:t,isExpanded:r,setIsExpanded:o}=$.useElements(),i=t.modal?.defaultExpanded??!1;return{expandable:t.modal?.expandable??!1,isExpanded:r,setIsExpanded:o,defaultExpanded:i}},dg={layout:{duration:.25,ease:fe}},fg=()=>{const{config:t}=$.useElements(),r=En(),o=$.useRadius(),i=$.useDensity(),[e,n]=N.useState(t.modal?.defaultOpen??!1),{expandable:a,isExpanded:l,setIsExpanded:d}=wo(),u=t.modal?.title,f=t.modal?.icon,g=t.modal?.position??"bottom-right",h=mg(g),v=N.useMemo(()=>t.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[t.modal?.dimensions?.default]),y=N.useMemo(()=>t.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[t.modal?.dimensions?.expanded]),b=j.useAssistantState(({thread:k})=>k).messages.some(k=>k.status?.type==="running"),x=l?y.width:v.width,_=l?y.height:v.height,w=v.maxHeight;return c.jsx(X.LazyMotion,{features:X.domMax,children:c.jsx(X.MotionConfig,{reducedMotion:"user",transition:dg,children:c.jsx("div",{className:$.cn("aui-root aui-modal-anchor fixed z-[9999]",h,r.className,o("lg"),e&&"shadow-xl"),children:c.jsx(X.AnimatePresence,{mode:"wait",children:e?c.jsxs(oe.div,{layout:!0,layoutId:"chat-container",className:$.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",o("lg")),initial:!1,style:{originX:g.includes("left")?0:1,originY:g.includes("top")?0:1,width:x,height:_,maxHeight:w},children:[c.jsxs(oe.div,{className:$.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",i("h-header"),i("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:fe},children:[c.jsx("div",{className:$.cn("flex min-w-0 items-center"),children:c.jsxs("span",{className:$.cn("text-md flex items-center gap-2 truncate font-medium",b&&"shimmer"),children:[c.jsx("span",{className:"truncate",children:u}),b&&c.jsx(nn,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),c.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?c.jsx("button",{type:"button",onClick:()=>d(k=>!k),className:$.cn("text-muted-foreground hover:text-foreground hover:bg-accent flex h-8 cursor-pointer items-center rounded-md px-2 text-xs transition-colors"),"aria-pressed":l,"aria-label":l?"Collapse assistant":"Expand assistant",children:l?c.jsx(Pl,{strokeWidth:2,className:"size-3.5 rotate-90"}):c.jsx(jl,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,c.jsx("button",{onClick:()=>{n(!1),d(!1)},className:"text-muted-foreground hover:text-foreground hover:bg-accent -mr-1 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors","aria-label":`Close ${u}`,children:c.jsx(rn,{className:"size-4.5"})})]})]}),c.jsx(oe.div,{className:"aui-modal-thread w-full flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:fe},children:c.jsx(Un,{})})]},"chat"):c.jsx(oe.button,{layout:!0,layoutId:"chat-container",onClick:()=>n(!0),className:$.cn("aui-modal-button bg-primary text-primary-foreground flex size-12 cursor-pointer items-center justify-center border shadow-lg transition-shadow hover:shadow-xl",o("full")),initial:!1,"aria-label":`Open ${u}`,style:{originX:1,originY:1},children:c.jsx(oe.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:fe},children:f?f("closed"):c.jsx(Nl,{className:"size-6"})})},"button")})})})})};function mg(t){switch(t){case"bottom-left":return"left-4 bottom-4";case"top-right":return"right-4 top-4";case"top-left":return"left-4 top-4";case"bottom-right":return"right-4 bottom-4";default:$.assertNever(t)}}const gg=()=>{const{config:t}=$.useElements(),r=En(),o=t.sidecar??{},{title:i,dimensions:e}=o,{isExpanded:n,setIsExpanded:a}=wo(),d=j.useAssistantState(({thread:u})=>u).messages.some(u=>u.status?.type==="running");return c.jsx(X.LazyMotion,{features:X.domMax,children:c.jsxs(oe.div,{initial:{width:e?.default?.width??"400px",height:e?.default?.height??"100vh"},animate:{width:n?e?.expanded?.width??"800px":e?.default?.width??"400px",height:n?e?.expanded?.height??"100%":e?.default?.height??"100vh"},transition:{duration:.3,ease:fe},className:$.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",r.className),children:[c.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[c.jsx("span",{className:$.cn("flex items-center gap-2 text-sm font-medium",d&&"shimmer"),children:i}),c.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:c.jsx(Q,{tooltip:n?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(u=>!u),children:n?c.jsx(El,{className:"size-4.5"}):c.jsx(Ul,{className:"size-4.5"})})})]}),c.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:c.jsx(Un,{})})]})})},pg=()=>{const{config:t}=$.useElements();switch(t.variant){case"standalone":return c.jsx(Un,{});case"sidecar":return c.jsx(gg,{});case"widget":return c.jsx(fg,{});default:$.assertNever(t.variant)}};exports.useGramElements=$.useElements;exports.Chat=pg;exports.GramElementsProvider=Ql;exports.defineFrontendTool=Kl;
|
|
56
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return m.useEffect(()=>{t&&(document.getElementById(t)||console.error(o))},[o,t]),null},Xf="DialogDescriptionWarning",Yf=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${no(Xf).contentName}}.`;return m.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");r&&e&&(document.getElementById(r)||console.warn(i))},[i,t,r]),null},Qf=Vi,em=Bi,tm=Ji,nm=Ki,rm=Hi,im=Xi,om=eo;function am({...t}){return c.jsx(Qf,{"data-slot":"dialog",...t})}function sm({...t}){return c.jsx(em,{"data-slot":"dialog-trigger",...t})}function lm({...t}){return c.jsx(tm,{"data-slot":"dialog-portal",...t})}function cm({className:t,...r}){return c.jsx(nm,{"data-slot":"dialog-overlay",className:$.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...r})}function um({className:t,children:r,showCloseButton:o=!0,...i}){return c.jsxs(lm,{"data-slot":"dialog-portal",children:[c.jsx(cm,{}),c.jsxs(rm,{"data-slot":"dialog-content",className:$.cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...i,children:[r,o&&c.jsxs(om,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[c.jsx(rn,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function dm({className:t,...r}){return c.jsx(im,{"data-slot":"dialog-title",className:$.cn("text-lg leading-none font-semibold",t),...r})}function fm(t,r=[]){let o=[];function i(n,a){const l=m.createContext(a);l.displayName=n+"Context";const d=o.length;o=[...o,a];const u=g=>{const{scope:h,children:v,...y}=g,p=h?.[t]?.[d]||l,b=m.useMemo(()=>y,Object.values(y));return c.jsx(p.Provider,{value:b,children:v})};u.displayName=n+"Provider";function f(g,h){const v=h?.[t]?.[d]||l,y=m.useContext(v);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${g}\` must be used within \`${n}\``)}return[u,f]}const e=()=>{const n=o.map(a=>m.createContext(a));return function(l){const d=l?.[t]||n;return m.useMemo(()=>({[`__scope${t}`]:{...l,[t]:d}}),[l,d])}};return e.scopeName=t,[i,mm(e,...r)]}function mm(...t){const r=t[0];if(t.length===1)return r;const o=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(n){const a=i.reduce((l,{useScope:d,scopeName:u})=>{const g=d(n)[`__scope${u}`];return{...l,...g}},{});return m.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return o.scopeName=r.scopeName,o}var gm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Pn=gm.reduce((t,r)=>{const o=Dr(`Primitive.${r}`),i=m.forwardRef((e,n)=>{const{asChild:a,...l}=e,d=a?o:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...l,ref:n})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});function pm(){return Qs.useSyncExternalStore(vm,()=>!0,()=>!1)}function vm(){return()=>{}}var Cn="Avatar",[hm]=fm(Cn),[ym,ro]=hm(Cn),io=m.forwardRef((t,r)=>{const{__scopeAvatar:o,...i}=t,[e,n]=m.useState("idle");return c.jsx(ym,{scope:o,imageLoadingStatus:e,onImageLoadingStatusChange:n,children:c.jsx(Pn.span,{...i,ref:r})})});io.displayName=Cn;var oo="AvatarImage",ao=m.forwardRef((t,r)=>{const{__scopeAvatar:o,src:i,onLoadingStatusChange:e=()=>{},...n}=t,a=ro(oo,o),l=bm(i,n),d=xe(u=>{e(u),a.onImageLoadingStatusChange(u)});return Y(()=>{l!=="idle"&&d(l)},[l,d]),l==="loaded"?c.jsx(Pn.img,{...n,ref:r,src:i}):null});ao.displayName=oo;var so="AvatarFallback",lo=m.forwardRef((t,r)=>{const{__scopeAvatar:o,delayMs:i,...e}=t,n=ro(so,o),[a,l]=m.useState(i===void 0);return m.useEffect(()=>{if(i!==void 0){const d=window.setTimeout(()=>l(!0),i);return()=>window.clearTimeout(d)}},[i]),a&&n.imageLoadingStatus!=="loaded"?c.jsx(Pn.span,{...e,ref:r}):null});lo.displayName=so;function xr(t,r){return t?r?(t.src!==r&&(t.src=r),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function bm(t,{referrerPolicy:r,crossOrigin:o}){const i=pm(),e=m.useRef(null),n=i?(e.current||(e.current=new window.Image),e.current):null,[a,l]=m.useState(()=>xr(n,t));return Y(()=>{l(xr(n,t))},[n,t]),Y(()=>{const d=g=>()=>{l(g)};if(!n)return;const u=d("loaded"),f=d("error");return n.addEventListener("load",u),n.addEventListener("error",f),r&&(n.referrerPolicy=r),typeof o=="string"&&(n.crossOrigin=o),()=>{n.removeEventListener("load",u),n.removeEventListener("error",f)}},[n,o,r]),a}var $m=io,xm=ao,_m=lo;function wm({className:t,...r}){return c.jsx($m,{"data-slot":"avatar",className:$.cn("relative flex size-8 shrink-0 overflow-hidden rounded-full",t),...r})}function Sm({className:t,...r}){return c.jsx(xm,{"data-slot":"avatar-image",className:$.cn("aspect-square size-full",t),...r})}function km({className:t,...r}){return c.jsx(_m,{"data-slot":"avatar-fallback",className:$.cn("bg-muted flex size-full items-center justify-center rounded-full",t),...r})}const jm=t=>{const[r,o]=N.useState(void 0);return N.useEffect(()=>{if(!t){o(void 0);return}const i=URL.createObjectURL(t);return o(i),()=>{URL.revokeObjectURL(i)}},[t]),r},co=()=>{const{file:t,src:r}=j.useAssistantState(Ao.useShallow(({attachment:o})=>{if(o.type!=="image")return{};if(o.file)return{file:o.file};const i=o.content?.filter(e=>e.type==="image")[0]?.image;return i?{src:i}:{}}));return jm(t)??r},Im=({src:t})=>{const[r,o]=N.useState(!1);return c.jsx("img",{src:t,alt:"Image Preview",className:r?"aui-attachment-preview-image-loaded block h-auto max-h-[80vh] w-auto max-w-full object-contain":"aui-attachment-preview-image-loading hidden",onLoad:()=>o(!0)})},Nm=({children:t})=>{const r=co();return r?c.jsxs(am,{children:[c.jsx(sm,{className:"aui-attachment-preview-trigger hover:bg-accent/50 cursor-pointer transition-colors",asChild:!0,children:t}),c.jsxs(um,{className:"aui-attachment-preview-dialog-content [&_svg]:text-background [&>button]:bg-foreground/60 [&>button]:hover:[&_svg]:text-destructive p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:!ring-0",children:[c.jsx(dm,{className:"aui-sr-only sr-only",children:"Image Attachment Preview"}),c.jsx("div",{className:"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:c.jsx(Im,{src:r})})]})]}):t},Om=()=>{const t=j.useAssistantState(({attachment:o})=>o.type==="image"),r=co();return c.jsxs(wm,{className:"aui-attachment-tile-avatar h-full w-full rounded-none",children:[c.jsx(Sm,{src:r,alt:"Attachment preview",className:"aui-attachment-tile-image object-cover"}),c.jsx(km,{delayMs:t?200:0,children:c.jsx(wl,{className:"aui-attachment-tile-fallback-icon text-muted-foreground size-8"})})]})},uo=()=>{const r=j.useAssistantApi().attachment.source==="composer",o=j.useAssistantState(({attachment:e})=>e.type==="image"),i=j.useAssistantState(({attachment:e})=>{const n=e.type;switch(n){case"image":return"Image";case"document":return"Document";case"file":return"File";default:{const a=n;throw new Error(`Unknown attachment type: ${a}`)}}});return c.jsxs(bn,{children:[c.jsxs(j.AttachmentPrimitive.Root,{className:$.cn("aui-attachment-root relative",o&&"aui-attachment-root-composer only:[&>#attachment-tile]:size-24"),children:[c.jsx(Nm,{children:c.jsx($n,{asChild:!0,children:c.jsx("div",{className:$.cn("aui-attachment-tile bg-muted size-14 cursor-pointer overflow-hidden rounded-[14px] border transition-opacity hover:opacity-75",r&&"aui-attachment-tile-composer border-foreground/20"),role:"button",id:"attachment-tile","aria-label":`${i} attachment`,children:c.jsx(Om,{})})})}),r&&c.jsx(Pm,{})]}),c.jsx(xn,{side:"top",children:c.jsx(j.AttachmentPrimitive.Name,{})})]})},Pm=()=>c.jsx(j.AttachmentPrimitive.Remove,{asChild:!0,children:c.jsx(Q,{tooltip:"Remove file",className:"aui-attachment-tile-remove text-muted-foreground hover:[&_svg]:text-destructive absolute top-1.5 right-1.5 size-3.5 rounded-full bg-white opacity-100 shadow-sm hover:!bg-white [&_svg]:text-black",side:"top",children:c.jsx(rn,{className:"aui-attachment-remove-icon size-3 dark:stroke-[2.5px]"})})}),Cm=()=>c.jsx("div",{className:"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2",children:c.jsx(j.MessagePrimitive.Attachments,{components:{Attachment:uo}})}),Em=()=>c.jsx("div",{className:"aui-composer-attachments mb-2 flex w-full flex-row items-center gap-2 overflow-x-auto px-1.5 pt-0.5 pb-1 empty:hidden",children:c.jsx(j.ComposerPrimitive.Attachments,{components:{Attachment:uo}})}),Dm=()=>c.jsx(j.ComposerPrimitive.AddAttachment,{asChild:!0,children:c.jsx(Q,{tooltip:"Add Attachment",side:"top",variant:"ghost",size:"icon",align:"start",className:"aui-composer-add-attachment hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-[34px] rounded-full p-1 text-xs font-semibold","aria-label":"Add Attachment",children:c.jsx(zl,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})}),En=()=>{const{config:t}=$.useElements(),r=t.theme??{};return N.useMemo(()=>{const{colorScheme:o="light"}=r;return{className:o==="dark"||o==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[r])};var Ot="Popover",[fo]=Je(Ot,[xt]),qe=xt(),[Um,$e]=fo(Ot),mo=t=>{const{__scopePopover:r,children:o,open:i,defaultOpen:e,onOpenChange:n,modal:a=!1}=t,l=qe(r),d=m.useRef(null),[u,f]=m.useState(!1),[g,h]=wt({prop:i,defaultProp:e??!1,onChange:n,caller:Ot});return c.jsx(oi,{...l,children:c.jsx(Um,{scope:r,contentId:Oe(),triggerRef:d,open:g,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(v=>!v),[h]),hasCustomAnchor:u,onCustomAnchorAdd:m.useCallback(()=>f(!0),[]),onCustomAnchorRemove:m.useCallback(()=>f(!1),[]),modal:a,children:o})})};mo.displayName=Ot;var go="PopoverAnchor",Tm=m.forwardRef((t,r)=>{const{__scopePopover:o,...i}=t,e=$e(go,o),n=qe(o),{onCustomAnchorAdd:a,onCustomAnchorRemove:l}=e;return m.useEffect(()=>(a(),()=>l()),[a,l]),c.jsx(vn,{...n,...i,ref:r})});Tm.displayName=go;var po="PopoverTrigger",vo=m.forwardRef((t,r)=>{const{__scopePopover:o,...i}=t,e=$e(po,o),n=qe(o),a=G(r,e.triggerRef),l=c.jsx(Z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":e.open,"aria-controls":e.contentId,"data-state":xo(e.open),...i,ref:a,onClick:R(t.onClick,e.onOpenToggle)});return e.hasCustomAnchor?l:c.jsx(vn,{asChild:!0,...n,children:l})});vo.displayName=po;var Dn="PopoverPortal",[Am,Rm]=fo(Dn,{forceMount:void 0}),ho=t=>{const{__scopePopover:r,forceMount:o,children:i,container:e}=t,n=$e(Dn,r);return c.jsx(Am,{scope:r,forceMount:o,children:c.jsx(pe,{present:o||n.open,children:c.jsx(_t,{asChild:!0,container:e,children:i})})})};ho.displayName=Dn;var Ue="PopoverContent",yo=m.forwardRef((t,r)=>{const o=Rm(Ue,t.__scopePopover),{forceMount:i=o.forceMount,...e}=t,n=$e(Ue,t.__scopePopover);return c.jsx(pe,{present:i||n.open,children:n.modal?c.jsx(Lm,{...e,ref:r}):c.jsx(Mm,{...e,ref:r})})});yo.displayName=Ue;var zm=an("PopoverContent.RemoveScroll"),Lm=m.forwardRef((t,r)=>{const o=$e(Ue,t.__scopePopover),i=m.useRef(null),e=G(r,i),n=m.useRef(!1);return m.useEffect(()=>{const a=i.current;if(a)return Zi(a)},[]),c.jsx(jn,{as:zm,allowPinchZoom:!0,children:c.jsx(bo,{...t,ref:e,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:R(t.onCloseAutoFocus,a=>{a.preventDefault(),n.current||o.triggerRef.current?.focus()}),onPointerDownOutside:R(t.onPointerDownOutside,a=>{const l=a.detail.originalEvent,d=l.button===0&&l.ctrlKey===!0,u=l.button===2||d;n.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:R(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),Mm=m.forwardRef((t,r)=>{const o=$e(Ue,t.__scopePopover),i=m.useRef(!1),e=m.useRef(!1);return c.jsx(bo,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{t.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||o.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,e.current=!1},onInteractOutside:n=>{t.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(e.current=!0));const a=n.target;o.triggerRef.current?.contains(a)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&e.current&&n.preventDefault()}})}),bo=m.forwardRef((t,r)=>{const{__scopePopover:o,trapFocus:i,onOpenAutoFocus:e,onCloseAutoFocus:n,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,...g}=t,h=$e(Ue,o),v=qe(o);return Ei(),c.jsx(kn,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:e,onUnmountAutoFocus:n,children:c.jsx(ht,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>h.onOpenChange(!1),children:c.jsx(ai,{"data-state":xo(h.open),role:"dialog",id:h.contentId,...v,...g,ref:r,style:{...g.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),$o="PopoverClose",Zm=m.forwardRef((t,r)=>{const{__scopePopover:o,...i}=t,e=$e($o,o);return c.jsx(Z.button,{type:"button",...i,ref:r,onClick:R(t.onClick,()=>e.onOpenChange(!1))})});Zm.displayName=$o;var Fm="PopoverArrow",Vm=m.forwardRef((t,r)=>{const{__scopePopover:o,...i}=t,e=qe(o);return c.jsx(si,{...e,...i,ref:r})});Vm.displayName=Fm;function xo(t){return t?"open":"closed"}var Wm=mo,Bm=vo,Gm=ho,Jm=yo;function Km({...t}){return c.jsx(Wm,{"data-slot":"popover",...t})}function Hm({...t}){return c.jsx(Bm,{"data-slot":"popover-trigger",...t})}function qm({className:t,align:r="center",sideOffset:o=4,...i}){return c.jsx(Gm,{children:c.jsx(Jm,{"data-slot":"popover-content",align:r,sideOffset:o,className:$.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...i})})}const fe=[.23,1,.32,1],Xm=({children:t})=>{const r=$.useRadius(),o=j.useAssistantState(({message:g})=>g).parts,i=o.filter(g=>g.type==="tool-call"),e=i.some(g=>g.status?.type==="running"),n=N.useMemo(()=>e?c.jsx(nn,{className:"text-muted-foreground size-4 animate-spin"}):c.jsx(Ge,{className:"size-4 text-green-500"}),[e]),{config:a}=$.useElements(),[l,d]=N.useState(a.tools?.expandToolGroupsByDefault??!1),u=$.useDensity(),f=N.useMemo(()=>{const g=o.filter(h=>h.type==="tool-call");return g.length===0?"No tools called":g.length===1?`Calling ${$i(g[0].toolName)}...`:e?`Calling ${g.length} tools...`:`Executed ${g.length} tools`},[o,e]);return a.tools?.components?.[i[0].toolName]?t:c.jsx(X.LazyMotion,{features:X.domAnimation,children:i.length>1?c.jsxs("button",{className:$.cn("group my-4 w-full max-w-xl cursor-pointer border",r("sm")),onClick:()=>d(!l),children:[c.jsxs("div",{className:$.cn("bg-muted/40 flex items-center rounded-b-none!",r("sm"),u("py-xs"),u("gap-md"),u("px-md"),l&&"border-b"),children:[c.jsx("span",{children:n}),c.jsx("span",{className:$.cn("font-semibold",e&&"shimmer"),children:f}),c.jsx("div",{className:"ml-auto",children:c.jsx(ce,{variant:"ghost",size:"icon",className:"cursor-pointer hover:bg-transparent",onClick:()=>d(!l),children:l?c.jsx(Pr,{className:"size-4"}):c.jsx(tn,{className:"size-4"})})})]}),c.jsx(X.AnimatePresence,{children:l&&c.jsx(oe.div,{initial:{height:0,opacity:0,y:-10},animate:{height:"auto",opacity:1,y:0},exit:{height:0,opacity:0,y:-10},transition:{duration:.3,ease:fe},style:{overflow:"hidden"},children:t})})]}):c.jsx("div",{className:$.cn("bg-muted/40 my-4 flex w-full max-w-xl cursor-pointer items-center rounded-b-none! border"),children:t})})},Un=()=>{const t=En(),r=$.useDensity(),{config:o}=$.useElements(),i=o.components??{};return c.jsx(X.LazyMotion,{features:X.domAnimation,children:c.jsx(X.MotionConfig,{reducedMotion:"user",children:c.jsx(j.ThreadPrimitive.Root,{className:$.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",t.className),children:c.jsxs(j.ThreadPrimitive.Viewport,{className:$.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",r("p-lg")),children:[c.jsx(j.ThreadPrimitive.If,{empty:!0,children:i.ThreadWelcome?c.jsx(i.ThreadWelcome,{}):c.jsx(Qm,{})}),c.jsx(j.ThreadPrimitive.Messages,{components:{UserMessage:i.UserMessage??lg,EditComposer:i.EditComposer??ug,AssistantMessage:i.AssistantMessage??og}}),c.jsx(j.ThreadPrimitive.If,{empty:!1,children:c.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),c.jsx(tg,{})]})})})})},Ym=()=>c.jsx(j.ThreadPrimitive.ScrollToBottom,{asChild:!0,children:c.jsx(Q,{tooltip:"Scroll to bottom",variant:"outline",className:"aui-thread-scroll-to-bottom dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible",children:c.jsx(cl,{})})}),Qm=()=>{const{config:t}=$.useElements(),r=$.useDensity(),{title:o,subtitle:i}=t.welcome??{},e=t.variant==="standalone";return c.jsxs("div",{className:$.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",e?"items-center justify-center":"",r("gap-lg")),children:[c.jsx("div",{className:$.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:c.jsxs("div",{className:$.cn("aui-thread-welcome-message flex flex-col",e?"items-center text-center":"size-full justify-start",r("gap-sm"),!e&&r("py-md")),children:[c.jsx(oe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:fe},className:$.cn("aui-thread-welcome-message-motion-1 font-semibold",r("text-title")),children:o}),c.jsx(oe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:fe},className:$.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",r("text-subtitle")),children:i})]})}),c.jsx(eg,{})]})},eg=()=>{const{config:t}=$.useElements(),r=$.useRadius(),o=$.useDensity(),i=t.welcome?.suggestions??[],e=t.variant==="standalone";return i.length===0?null:c.jsx("div",{className:$.cn("aui-thread-welcome-suggestions w-full",o("gap-md"),o("py-lg"),e?"flex flex-wrap items-center justify-center":i.length===1?"flex":"grid @md:grid-cols-2"),children:i.map((n,a)=>c.jsx(oe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:fe},className:$.cn("aui-thread-welcome-suggestion-display",!e&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:c.jsx(j.ThreadPrimitive.Suggestion,{prompt:n.action,send:!0,asChild:!0,children:c.jsxs(ce,{variant:"ghost",className:$.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",o("text-base"),e?`flex-row items-center ${o("gap-sm")} ${o("px-md")} ${o("py-sm")} ${r("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${o("gap-sm")} ${o("px-lg")} ${o("py-md")} ${r("xl")}`),"aria-label":n.action,children:[c.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-sm font-medium",children:n.title}),c.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:n.label})]})})},`suggested-action-${n.title}-${a}`))})},tg=()=>{const{config:t}=$.useElements(),r=$.useRadius(),o=$.useDensity(),i=t.composer??{placeholder:"Send a message...",attachments:!0},e=t.components??{};return e.Composer?c.jsx(e.Composer,{}):c.jsxs("div",{className:$.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",o("gap-md"),o("py-md"),r("xl")),children:[c.jsx(Ym,{}),c.jsxs(j.ComposerPrimitive.Root,{className:$.cn("aui-composer-root group/input-group border-input bg-background has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/5 dark:bg-background relative flex w-full flex-col border px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:ring-1",r("xl")),children:[i.attachments&&c.jsx(Em,{}),c.jsx(j.ComposerPrimitive.Input,{placeholder:i.placeholder,className:$.cn("aui-composer-input placeholder:text-muted-foreground mb-1 max-h-32 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 outline-none focus-visible:ring-0",o("h-input"),o("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),c.jsx(rg,{})]})]})},ng=()=>{const{model:t,setModel:r}=$.useElements(),[o,i]=N.useState(!1),[e,n]=N.useState(!1),a=N.useRef(null),l=N.useRef(0),d=N.useRef(!1);N.useEffect(()=>{o&&!d.current&&requestAnimationFrame(()=>{const f=a.current;f&&f.scrollHeight>0&&(f.scrollTop=l.current)}),d.current=o},[o]),N.useEffect(()=>{o&&n(!1)},[o]);const u=f=>{l.current=f.currentTarget.scrollTop};return c.jsx(yi,{children:c.jsxs(bn,{open:e&&!o,onOpenChange:n,children:[c.jsxs(Km,{open:o,onOpenChange:i,children:[c.jsx($n,{asChild:!0,children:c.jsx(Hm,{asChild:!0,children:c.jsx(ce,{variant:"ghost",size:"icon","data-state":o?"open":"closed",className:"aui-composer-model-picker data-[state=open]:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 flex w-fit items-center gap-2 rounded-full px-2.5 py-1 text-xs font-semibold","aria-label":"Model Settings",children:c.jsx(Fl,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),c.jsx(qm,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:c.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:u,children:s.MODELS.map(f=>c.jsxs(ce,{onClick:()=>{r(f)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[f===t?c.jsx("div",{children:c.jsx(Ge,{className:"size-4 text-emerald-500"})}):c.jsx("div",{className:"size-4",children:" "}),f]},f))})})]}),c.jsx(xn,{side:"bottom",align:"start",children:"Model Settings"})]})})},rg=()=>{const{config:t}=$.useElements(),r=$.useRadius(),o=t.composer??{attachments:!0};return c.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[c.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[o.attachments?c.jsx(Dm,{}):c.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),t.model?.showModelPicker&&c.jsx(ng,{})]}),c.jsx(j.ThreadPrimitive.If,{running:!1,children:c.jsx(j.ComposerPrimitive.Send,{asChild:!0,children:c.jsx(Q,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:$.cn("aui-composer-send size-[34px] p-1",r("full")),"aria-label":"Send message",children:c.jsx(dl,{className:"aui-composer-send-icon size-5"})})})}),c.jsx(j.ThreadPrimitive.If,{running:!0,children:c.jsx(j.ComposerPrimitive.Cancel,{asChild:!0,children:c.jsx(ce,{type:"button",variant:"default",size:"icon",className:$.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",r("full")),"aria-label":"Stop generating",children:c.jsx(Wl,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},ig=()=>c.jsx(j.MessagePrimitive.Error,{children:c.jsx(j.ErrorPrimitive.Root,{className:"aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200",children:c.jsx(j.ErrorPrimitive.Message,{className:"aui-message-error-message line-clamp-2"})})}),og=()=>{const{config:t}=$.useElements(),r=t.tools??{},o=t.components??{};return c.jsx(j.MessagePrimitive.Root,{asChild:!0,children:c.jsxs("div",{className:"aui-assistant-message-root animate-in fade-in slide-in-from-bottom-1 relative mx-auto w-full py-4 duration-150 ease-out last:mb-24","data-role":"assistant",children:[c.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[c.jsx(j.MessagePrimitive.Parts,{components:{Text:o.Text??bi,Image:o.Image??ag,tools:{by_name:r.components,Fallback:o.ToolFallback??Dd},Reasoning:o.Reasoning??Oi,ReasoningGroup:o.ReasoningGroup??Pi,ToolGroup:o.ToolGroup??Xm}}),c.jsx(ig,{})]}),c.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[c.jsx(_o,{}),c.jsx(sg,{})]})]})})},ag=t=>c.jsx("img",{src:t.image}),sg=()=>c.jsxs(j.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",autohideFloat:"single-branch",className:"aui-assistant-action-bar-root text-muted-foreground data-floating:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-floating:absolute data-floating:rounded-md data-floating:border data-floating:p-1 data-floating:shadow-sm",children:[c.jsx(j.ActionBarPrimitive.Copy,{asChild:!0,children:c.jsxs(Q,{tooltip:"Copy",children:[c.jsx(j.MessagePrimitive.If,{copied:!0,children:c.jsx(Ge,{})}),c.jsx(j.MessagePrimitive.If,{copied:!1,children:c.jsx(Cr,{})})]})}),c.jsx(j.ActionBarPrimitive.Reload,{asChild:!0,children:c.jsx(Q,{tooltip:"Refresh",children:c.jsx(Ml,{})})})]}),lg=()=>{const t=$.useRadius();return c.jsx(j.MessagePrimitive.Root,{asChild:!0,children:c.jsxs("div",{className:"aui-user-message-root animate-in fade-in slide-in-from-bottom-1 mx-auto grid w-full auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out first:mt-3 last:mb-5 [&:where(>*)]:col-start-2","data-role":"user",children:[c.jsx(Cm,{}),c.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[c.jsx("div",{className:$.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",t("xl")),children:c.jsx(j.MessagePrimitive.Parts,{})}),c.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:c.jsx(cg,{})})]}),c.jsx(_o,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},cg=()=>c.jsx(j.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:c.jsx(j.ActionBarPrimitive.Edit,{asChild:!0,children:c.jsx(Q,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:c.jsx(Al,{})})})}),ug=()=>c.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:c.jsxs(j.ComposerPrimitive.Root,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[c.jsx(j.ComposerPrimitive.Input,{className:"aui-edit-composer-input text-foreground flex min-h-[60px] w-full resize-none bg-transparent p-4 outline-none",autoFocus:!0}),c.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[c.jsx(j.ComposerPrimitive.Cancel,{asChild:!0,children:c.jsx(ce,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),c.jsx(j.ComposerPrimitive.Send,{asChild:!0,children:c.jsx(ce,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),_o=({className:t,...r})=>c.jsxs(j.BranchPickerPrimitive.Root,{hideWhenSingleBranch:!0,className:$.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",t),...r,children:[c.jsx(j.BranchPickerPrimitive.Previous,{asChild:!0,children:c.jsx(Q,{tooltip:"Previous",children:c.jsx(hl,{})})}),c.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[c.jsx(j.BranchPickerPrimitive.Number,{})," / ",c.jsx(j.BranchPickerPrimitive.Count,{})]}),c.jsx(j.BranchPickerPrimitive.Next,{asChild:!0,children:c.jsx(Q,{tooltip:"Next",children:c.jsx(bl,{})})})]}),wo=()=>{const{config:t,isExpanded:r,setIsExpanded:o}=$.useElements(),i=t.modal?.defaultExpanded??!1;return{expandable:t.modal?.expandable??!1,isExpanded:r,setIsExpanded:o,defaultExpanded:i}},dg={layout:{duration:.25,ease:fe}},fg=()=>{const{config:t}=$.useElements(),r=En(),o=$.useRadius(),i=$.useDensity(),[e,n]=N.useState(t.modal?.defaultOpen??!1),{expandable:a,isExpanded:l,setIsExpanded:d}=wo(),u=t.modal?.title,f=t.modal?.icon,g=t.modal?.position??"bottom-right",h=mg(g),v=N.useMemo(()=>t.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[t.modal?.dimensions?.default]),y=N.useMemo(()=>t.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[t.modal?.dimensions?.expanded]),b=j.useAssistantState(({thread:k})=>k).messages.some(k=>k.status?.type==="running"),x=l?y.width:v.width,_=l?y.height:v.height,w=v.maxHeight;return c.jsx(X.LazyMotion,{features:X.domMax,children:c.jsx(X.MotionConfig,{reducedMotion:"user",transition:dg,children:c.jsx("div",{className:$.cn("aui-root aui-modal-anchor fixed z-10",h,r.className,o("lg"),e&&"shadow-xl"),children:c.jsx(X.AnimatePresence,{mode:"wait",children:e?c.jsxs(oe.div,{layout:!0,layoutId:"chat-container",className:$.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",o("lg")),initial:!1,style:{originX:g.includes("left")?0:1,originY:g.includes("top")?0:1,width:x,height:_,maxHeight:w},children:[c.jsxs(oe.div,{className:$.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",i("h-header"),i("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:fe},children:[c.jsx("div",{className:$.cn("flex min-w-0 items-center"),children:c.jsxs("span",{className:$.cn("text-md flex items-center gap-2 truncate font-medium",b&&"shimmer"),children:[c.jsx("span",{className:"truncate",children:u}),b&&c.jsx(nn,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),c.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?c.jsx("button",{type:"button",onClick:()=>d(k=>!k),className:$.cn("text-muted-foreground hover:text-foreground hover:bg-accent flex h-8 cursor-pointer items-center rounded-md px-2 text-xs transition-colors"),"aria-pressed":l,"aria-label":l?"Collapse assistant":"Expand assistant",children:l?c.jsx(Pl,{strokeWidth:2,className:"size-3.5 rotate-90"}):c.jsx(jl,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,c.jsx("button",{onClick:()=>{n(!1),d(!1)},className:"text-muted-foreground hover:text-foreground hover:bg-accent -mr-1 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors","aria-label":`Close ${u}`,children:c.jsx(rn,{className:"size-4.5"})})]})]}),c.jsx(oe.div,{className:"aui-modal-thread w-full flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:fe},children:c.jsx(Un,{})})]},"chat"):c.jsx(oe.button,{layout:!0,layoutId:"chat-container",onClick:()=>n(!0),className:$.cn("aui-modal-button bg-primary text-primary-foreground flex size-12 cursor-pointer items-center justify-center border shadow-lg transition-shadow hover:shadow-xl",o("full")),initial:!1,"aria-label":`Open ${u}`,style:{originX:1,originY:1},children:c.jsx(oe.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:fe},className:"flex size-full items-center justify-center",children:f?f("closed"):c.jsx(Nl,{className:"size-6"})})},"button")})})})})};function mg(t){switch(t){case"bottom-left":return"left-4 bottom-4";case"top-right":return"right-4 top-4";case"top-left":return"left-4 top-4";case"bottom-right":return"right-4 bottom-4";default:$.assertNever(t)}}const gg=()=>{const{config:t}=$.useElements(),r=En(),o=t.sidecar??{},{title:i,dimensions:e}=o,{isExpanded:n,setIsExpanded:a}=wo(),d=j.useAssistantState(({thread:u})=>u).messages.some(u=>u.status?.type==="running");return c.jsx(X.LazyMotion,{features:X.domMax,children:c.jsxs(oe.div,{initial:{width:e?.default?.width??"400px",height:e?.default?.height??"100vh"},animate:{width:n?e?.expanded?.width??"800px":e?.default?.width??"400px",height:n?e?.expanded?.height??"100%":e?.default?.height??"100vh"},transition:{duration:.3,ease:fe},className:$.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",r.className),children:[c.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[c.jsx("span",{className:$.cn("flex items-center gap-2 text-sm font-medium",d&&"shimmer"),children:i}),c.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:c.jsx(Q,{tooltip:n?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(u=>!u),children:n?c.jsx(El,{className:"size-4.5"}):c.jsx(Ul,{className:"size-4.5"})})})]}),c.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:c.jsx(Un,{})})]})})},pg=()=>{const{config:t}=$.useElements();switch(t.variant){case"standalone":return c.jsx(Un,{});case"sidecar":return c.jsx(gg,{});case"widget":return c.jsx(fg,{});default:$.assertNever(t.variant)}};exports.useGramElements=$.useElements;exports.Chat=pg;exports.GramElementsProvider=Ql;exports.defineFrontendTool=Kl;
|