@gram-ai/elements 1.18.2 → 1.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements.cjs +2 -2
- package/dist/elements.css +1 -1
- package/dist/elements.js +1497 -1512
- package/package.json +1 -1
package/dist/elements.cjs
CHANGED
|
@@ -93,7 +93,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
93
93
|
|
|
94
94
|
Utilities:
|
|
95
95
|
${t.map(r=>`- ${r.language}: ${r.prompt}`).join(`
|
|
96
|
-
`)}`}function bM(e){return"https://localhost:8080".replace(/\/+$/,"")}const _M=({children:e,config:t})=>{const r=bM(),o=hM({auth:t.api,projectSlug:t.projectSlug}),n=B_(),[i,a]=D.useState(t.model?.defaultModel??Oc[0]),[s,l]=D.useState(t.modal?.defaultExpanded??!1),[u,c]=D.useState(t.modal?.defaultOpen),d=t.plugins??T.recommended,f=yM(t.systemPrompt,d),{data:p,isLoading:g}=aN({auth:o,mcp:t.mcp,environment:t.environment??{}}),h=D.useRef({requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool});h.current={requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool};const b=D.useCallback(()=>({requestApproval:(...$)=>h.current.requestApproval(...$),isToolApproved:(...$)=>h.current.isToolApproved(...$),whitelistTool:(...$)=>h.current.whitelistTool(...$)}),[]);D.useEffect(()=>(t.tools?.toolsRequiringApproval?.length&&cN(b(),t.tools.toolsRequiringApproval),()=>{dN()}),[t.tools?.toolsRequiringApproval,b]);const y=D.useMemo(()=>({sendMessages:async({messages:$,abortSignal:v})=>{const k=!!t.languageModel;if(o.isLoading)throw new Error("Session is laoding");const N=x.thread.getModelContext(),I=uN(lN(N?.tools??{})),O=k?null:ix({baseURL:r,apiKey:"unused, but must be set",headers:o.headers});t.languageModel&&console.log("Using custom language model",t.languageModel);const z={...p,...Oj(I)},F=fN(z,t.tools?.toolsRequiringApproval,b()),te=t.languageModel?t.languageModel:O.chat(i);try{return oM({system:f,model:te,messages:sM($),tools:F,stopWhen:m$(10),experimental_transform:pM({delayInMs:15}),abortSignal:v,onError:({error:J})=>{console.error("Stream error in onError callback:",J)}}).toUIMessageStream()}catch(ie){throw console.error("Error creating stream:",ie),ie}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,i,f,p,g,b,r,o.headers]),x=Tj({transport:y});return m.jsx(L.AssistantRuntimeProvider,{runtime:x,children:m.jsxs(T.ElementsContext.Provider,{value:{config:t,setModel:a,model:i,isExpanded:s,setIsExpanded:l,isOpen:u??!1,setIsOpen:c,plugins:d},children:[e,m.jsx(x0,{tools:t.tools?.frontendTools??{}})]})})},wM=e=>{const t=new WO;return m.jsx(HO,{client:t,children:m.jsx(gM,{children:m.jsx(_M,{...e})})})};function Oe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function Cf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hc(...e){return t=>{let r=!1;const o=e.map(n=>{const i=Cf(n,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let n=0;n<o.length;n++){const i=o[n];typeof i=="function"?i():Cf(e[n],null)}}}}function Ge(...e){return _.useCallback(Hc(...e),e)}function xM(e,t){const r=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return m.jsx(r.Provider,{value:l,children:a})};o.displayName=e+"Provider";function n(i){const a=_.useContext(r);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,n]}function Po(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a),l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,$M(n,...t)]}function $M(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}function Gc(e){const t=SM(e),r=_.forwardRef((o,n)=>{const{children:i,...a}=o,s=_.Children.toArray(i),l=s.find(kM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}function SM(e){const t=_.forwardRef((r,o)=>{const{children:n,...i}=r;if(_.isValidElement(n)){const a=TM(n),s=EM(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Hc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _$=Symbol("radix.slottable");function IM(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=_$,t}function kM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_$}function EM(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function TM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var OM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=OM.reduce((e,t)=>{const r=Gc(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function NM(e,t){e&&sm.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...r)=>t.current?.(...r),[])}function PM(e,t=globalThis?.document){const r=Sr(e);_.useEffect(()=>{const o=n=>{n.key==="Escape"&&r(n)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[r,t])}var CM="DismissableLayer",Ou="dismissableLayer.update",jM="dismissableLayer.pointerDownOutside",AM="dismissableLayer.focusOutside",jf,w$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ha=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:n,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(w$),[c,d]=_.useState(null),f=c?.ownerDocument??globalThis?.document,[,p]=_.useState({}),g=Ge(t,I=>d(I)),h=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=h.indexOf(b),x=c?h.indexOf(c):-1,$=u.layersWithOutsidePointerEventsDisabled.size>0,v=x>=y,k=MM(I=>{const O=I.target,z=[...u.branches].some(F=>F.contains(O));!v||z||(n?.(I),a?.(I),I.defaultPrevented||s?.())},f),N=DM(I=>{const O=I.target;[...u.branches].some(F=>F.contains(O))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},f);return PM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},f),_.useEffect(()=>{if(c)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jf=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Af(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=jf)}},[c,f,r,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Af())},[c,u]),_.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ou,I),()=>document.removeEventListener(Ou,I)},[]),m.jsx(Ce.div,{...l,ref:g,style:{pointerEvents:$?v?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,k.onPointerDownCapture)})});Ha.displayName=CM;var RM="DismissableLayerBranch",zM=_.forwardRef((e,t)=>{const r=_.useContext(w$),o=_.useRef(null),n=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),m.jsx(Ce.div,{...e,ref:n})});zM.displayName=RM;function MM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1),n=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){x$(jM,r,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=l,t.addEventListener("click",n.current,{once:!0})):l()}else t.removeEventListener("click",n.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",n.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function DM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1);return _.useEffect(()=>{const n=i=>{i.target&&!o.current&&x$(AM,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Af(){const e=new CustomEvent(Ou);document.dispatchEvent(e)}function x$(e,t,r,{discrete:o}){const n=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?NM(n,i):n.dispatchEvent(i)}var lt=globalThis?.document?_.useLayoutEffect:()=>{},UM=_[" useId ".trim().toString()]||(()=>{}),LM=0;function qr(e){const[t,r]=_.useState(UM());return lt(()=>{r(o=>o??String(LM++))},[e]),t?`radix-${t}`:""}const ZM=["top","right","bottom","left"],ur=Math.min,Ye=Math.max,Di=Math.round,Go=Math.floor,At=e=>({x:e,y:e}),FM={left:"right",right:"left",bottom:"top",top:"bottom"},qM={start:"end",end:"start"};function Nu(e,t,r){return Ye(e,ur(t,r))}function Bt(e,t){return typeof e=="function"?e(t):e}function Jt(e){return e.split("-")[0]}function dn(e){return e.split("-")[1]}function Kc(e){return e==="x"?"y":"x"}function Yc(e){return e==="y"?"height":"width"}const VM=new Set(["top","bottom"]);function jt(e){return VM.has(Jt(e))?"y":"x"}function Qc(e){return Kc(jt(e))}function BM(e,t,r){r===void 0&&(r=!1);const o=dn(e),n=Qc(e),i=Yc(n);let a=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Ui(a)),[a,Ui(a)]}function JM(e){const t=Ui(e);return[Pu(e),t,Pu(t)]}function Pu(e){return e.replace(/start|end/g,t=>qM[t])}const Rf=["left","right"],zf=["right","left"],WM=["top","bottom"],HM=["bottom","top"];function GM(e,t,r){switch(e){case"top":case"bottom":return r?t?zf:Rf:t?Rf:zf;case"left":case"right":return t?WM:HM;default:return[]}}function KM(e,t,r,o){const n=dn(e);let i=GM(Jt(e),r==="start",o);return n&&(i=i.map(a=>a+"-"+n),t&&(i=i.concat(i.map(Pu)))),i}function Ui(e){return e.replace(/left|right|bottom|top/g,t=>FM[t])}function YM(e){return{top:0,right:0,bottom:0,left:0,...e}}function $$(e){return typeof e!="number"?YM(e):{top:e,right:e,bottom:e,left:e}}function Li(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function Mf(e,t,r){let{reference:o,floating:n}=e;const i=jt(t),a=Qc(t),s=Yc(a),l=Jt(t),u=i==="y",c=o.x+o.width/2-n.width/2,d=o.y+o.height/2-n.height/2,f=o[s]/2-n[s]/2;let p;switch(l){case"top":p={x:c,y:o.y-n.height};break;case"bottom":p={x:c,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-n.width,y:d};break;default:p={x:o.x,y:o.y}}switch(dn(t)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const QM=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:a}=r,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=Mf(u,o,l),f=o,p={},g=0;for(let h=0;h<s.length;h++){const{name:b,fn:y}=s[h],{x,y:$,data:v,reset:k}=await y({x:c,y:d,initialPlacement:o,placement:f,strategy:n,middlewareData:p,rects:u,platform:a,elements:{reference:e,floating:t}});c=x??c,d=$??d,p={...p,[b]:{...p[b],...v}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:n}):k.rects),{x:c,y:d}=Mf(u,f,l)),h=-1)}return{x:c,y:d,placement:f,strategy:n,middlewareData:p}};async function Kn(e,t){var r;t===void 0&&(t={});const{x:o,y:n,platform:i,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Bt(t,e),g=$$(p),b=s[f?d==="floating"?"reference":"floating":d],y=Li(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(b)))==null||r?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),x=d==="floating"?{x:o,y:n,width:a.floating.width,height:a.floating.height}:a.reference,$=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),v=await(i.isElement==null?void 0:i.isElement($))?await(i.getScale==null?void 0:i.getScale($))||{x:1,y:1}:{x:1,y:1},k=Li(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:$,strategy:l}):x);return{top:(y.top-k.top+g.top)/v.y,bottom:(k.bottom-y.bottom+g.bottom)/v.y,left:(y.left-k.left+g.left)/v.x,right:(k.right-y.right+g.right)/v.x}}const XM=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Bt(e,t)||{};if(u==null)return{};const d=$$(c),f={x:r,y:o},p=Qc(n),g=Yc(p),h=await a.getDimensions(u),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",$=b?"clientHeight":"clientWidth",v=i.reference[g]+i.reference[p]-f[p]-i.floating[g],k=f[p]-i.reference[p],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[$]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=s.floating[$]||i.floating[g]);const O=v/2-k/2,z=I/2-h[g]/2-1,F=ur(d[y],z),te=ur(d[x],z),ie=F,J=I-h[g]-te,V=I/2-h[g]/2+O,we=Nu(ie,V,J),oe=!l.arrow&&dn(n)!=null&&V!==we&&i.reference[g]/2-(V<ie?F:te)-h[g]/2<0,de=oe?V<ie?V-ie:V-J:0;return{[p]:f[p]+de,data:{[p]:we,centerOffset:V-we-de,...oe&&{alignmentOffset:de}},reset:oe}}}),e4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,middlewareData:i,rects:a,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=Bt(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=Jt(n),x=jt(s),$=Jt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=f||($||!h?[Ui(s)]:JM(s)),N=g!=="none";!f&&N&&k.push(...KM(s,h,g,v));const I=[s,...k],O=await Kn(t,b),z=[];let F=((o=i.flip)==null?void 0:o.overflows)||[];if(c&&z.push(O[y]),d){const V=BM(n,a,v);z.push(O[V[0]],O[V[1]])}if(F=[...F,{placement:n,overflows:z}],!z.every(V=>V<=0)){var te,ie;const V=(((te=i.flip)==null?void 0:te.index)||0)+1,we=I[V];if(we&&(!(d==="alignment"?x!==jt(we):!1)||F.every(K=>jt(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:V,overflows:F},reset:{placement:we}};let oe=(ie=F.filter(de=>de.overflows[0]<=0).sort((de,K)=>de.overflows[1]-K.overflows[1])[0])==null?void 0:ie.placement;if(!oe)switch(p){case"bestFit":{var J;const de=(J=F.filter(K=>{if(N){const fe=jt(K.placement);return fe===x||fe==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(fe=>fe>0).reduce((fe,B)=>fe+B,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:J[0];de&&(oe=de);break}case"initialPlacement":oe=s;break}if(n!==oe)return{reset:{placement:oe}}}return{}}}};function Df(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Uf(e){return ZM.some(t=>e[t]>=0)}const t4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:o="referenceHidden",...n}=Bt(e,t);switch(o){case"referenceHidden":{const i=await Kn(t,{...n,elementContext:"reference"}),a=Df(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Uf(a)}}}case"escaped":{const i=await Kn(t,{...n,altBoundary:!0}),a=Df(i,r.floating);return{data:{escapedOffsets:a,escaped:Uf(a)}}}default:return{}}}}},S$=new Set(["left","top"]);async function r4(e,t){const{placement:r,platform:o,elements:n}=e,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),a=Jt(r),s=dn(r),l=jt(r)==="y",u=S$.has(a)?-1:1,c=i&&l?-1:1,d=Bt(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof g=="number"&&(p=s==="end"?g*-1:g),l?{x:p*c,y:f*u}:{x:f*u,y:p*c}}const n4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:i,placement:a,middlewareData:s}=t,l=await r4(t,e);return a===((r=s.offset)==null?void 0:r.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:n+l.x,y:i+l.y,data:{...l,placement:a}}}}},o4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:s={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Bt(e,t),u={x:r,y:o},c=await Kn(t,l),d=jt(Jt(n)),f=Kc(d);let p=u[f],g=u[d];if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=p+c[b],$=p-c[y];p=Nu(x,p,$)}if(a){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=g+c[b],$=g-c[y];g=Nu(x,g,$)}const h=s.fn({...t,[f]:p,[d]:g});return{...h,data:{x:h.x-r,y:h.y-o,enabled:{[f]:i,[d]:a}}}}}},i4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:o,placement:n,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Bt(e,t),c={x:r,y:o},d=jt(n),f=Kc(d);let p=c[f],g=c[d];const h=Bt(s,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(l){const $=f==="y"?"height":"width",v=i.reference[f]-i.floating[$]+b.mainAxis,k=i.reference[f]+i.reference[$]-b.mainAxis;p<v?p=v:p>k&&(p=k)}if(u){var y,x;const $=f==="y"?"width":"height",v=S$.has(Jt(n)),k=i.reference[d]-i.floating[$]+(v&&((y=a.offset)==null?void 0:y[d])||0)+(v?0:b.crossAxis),N=i.reference[d]+i.reference[$]+(v?0:((x=a.offset)==null?void 0:x[d])||0)-(v?b.crossAxis:0);g<k?g=k:g>N&&(g=N)}return{[f]:p,[d]:g}}}},a4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,o;const{placement:n,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Bt(e,t),c=await Kn(t,u),d=Jt(n),f=dn(n),p=jt(n)==="y",{width:g,height:h}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=f===(await(a.isRTL==null?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,b=f==="end"?"top":"bottom");const x=h-c.top-c.bottom,$=g-c.left-c.right,v=ur(h-c[b],x),k=ur(g-c[y],$),N=!t.middlewareData.shift;let I=v,O=k;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(O=$),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(I=x),N&&!f){const F=Ye(c.left,0),te=Ye(c.right,0),ie=Ye(c.top,0),J=Ye(c.bottom,0);p?O=g-2*(F!==0||te!==0?F+te:Ye(c.left,c.right)):I=h-2*(ie!==0||J!==0?ie+J:Ye(c.top,c.bottom))}await l({...t,availableWidth:O,availableHeight:I});const z=await a.getDimensions(s.floating);return g!==z.width||h!==z.height?{reset:{rects:!0}}:{}}}};function Ga(){return typeof window<"u"}function pn(e){return I$(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dt(e){var t;return(t=(I$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function I$(e){return Ga()?e instanceof Node||e instanceof Qe(e).Node:!1}function St(e){return Ga()?e instanceof Element||e instanceof Qe(e).Element:!1}function zt(e){return Ga()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function Lf(e){return!Ga()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const s4=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&!s4.has(n)}const u4=new Set(["table","td","th"]);function l4(e){return u4.has(pn(e))}const c4=[":popover-open",":modal"];function Ka(e){return c4.some(t=>{try{return e.matches(t)}catch{return!1}})}const d4=["transform","translate","scale","rotate","perspective"],p4=["transform","translate","scale","rotate","perspective","filter"],f4=["paint","layout","strict","content"];function Xc(e){const t=ed(),r=St(e)?It(e):e;return d4.some(o=>r[o]?r[o]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||p4.some(o=>(r.willChange||"").includes(o))||f4.some(o=>(r.contain||"").includes(o))}function m4(e){let t=lr(e);for(;zt(t)&&!nn(t);){if(Xc(t))return t;if(Ka(t))return null;t=lr(t)}return null}function ed(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const h4=new Set(["html","body","#document"]);function nn(e){return h4.has(pn(e))}function It(e){return Qe(e).getComputedStyle(e)}function Ya(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lr(e){if(pn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Lf(e)&&e.host||Dt(e);return Lf(t)?t.host:t}function k$(e){const t=lr(e);return nn(t)?e.ownerDocument?e.ownerDocument.body:e.body:zt(t)&&Co(t)?t:k$(t)}function Yn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=k$(e),i=n===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(n);if(i){const s=Cu(a);return t.concat(a,a.visualViewport||[],Co(n)?n:[],s&&r?Yn(s):[])}return t.concat(n,Yn(n,[],r))}function Cu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function E$(e){const t=It(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=zt(e),i=n?e.offsetWidth:r,a=n?e.offsetHeight:o,s=Di(r)!==i||Di(o)!==a;return s&&(r=i,o=a),{width:r,height:o,$:s}}function td(e){return St(e)?e:e.contextElement}function Vr(e){const t=td(e);if(!zt(t))return At(1);const r=t.getBoundingClientRect(),{width:o,height:n,$:i}=E$(t);let a=(i?Di(r.width):r.width)/o,s=(i?Di(r.height):r.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const g4=At(0);function T$(e){const t=Qe(e);return!ed()||!t.visualViewport?g4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function v4(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Qe(e)?!1:t}function Ir(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),i=td(e);let a=At(1);t&&(o?St(o)&&(a=Vr(o)):a=Vr(e));const s=v4(i,r,o)?T$(i):At(0);let l=(n.left+s.x)/a.x,u=(n.top+s.y)/a.y,c=n.width/a.x,d=n.height/a.y;if(i){const f=Qe(i),p=o&&St(o)?Qe(o):o;let g=f,h=Cu(g);for(;h&&o&&p!==g;){const b=Vr(h),y=h.getBoundingClientRect(),x=It(h),$=y.left+(h.clientLeft+parseFloat(x.paddingLeft))*b.x,v=y.top+(h.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,u*=b.y,c*=b.x,d*=b.y,l+=$,u+=v,g=Qe(h),h=Cu(g)}}return Li({width:c,height:d,x:l,y:u})}function rd(e,t){const r=Ya(e).scrollLeft;return t?t.left+r:Ir(Dt(e)).left+r}function O$(e,t,r){r===void 0&&(r=!1);const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-(r?0:rd(e,o)),i=o.top+t.scrollTop;return{x:n,y:i}}function y4(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const i=n==="fixed",a=Dt(o),s=t?Ka(t.floating):!1;if(o===a||s&&i)return r;let l={scrollLeft:0,scrollTop:0},u=At(1);const c=At(0),d=zt(o);if((d||!d&&!i)&&((pn(o)!=="body"||Co(a))&&(l=Ya(o)),zt(o))){const p=Ir(o);u=Vr(o),c.x=p.x+o.clientLeft,c.y=p.y+o.clientTop}const f=a&&!d&&!i?O$(a,l,!0):At(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:r.y*u.y-l.scrollTop*u.y+c.y+f.y}}function b4(e){return Array.from(e.getClientRects())}function _4(e){const t=Dt(e),r=Ya(e),o=e.ownerDocument.body,n=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-r.scrollLeft+rd(e);const s=-r.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-n),{width:n,height:i,x:a,y:s}}function w4(e,t){const r=Qe(e),o=Dt(e),n=r.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(n){i=n.width,a=n.height;const u=ed();(!u||u&&t==="fixed")&&(s=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:s,y:l}}const x4=new Set(["absolute","fixed"]);function $4(e,t){const r=Ir(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,i=zt(e)?Vr(e):At(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=n*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function Zf(e,t,r){let o;if(t==="viewport")o=w4(e,r);else if(t==="document")o=_4(Dt(e));else if(St(t))o=$4(t,r);else{const n=T$(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Li(o)}function N$(e,t){const r=lr(e);return r===t||!St(r)||nn(r)?!1:It(r).position==="fixed"||N$(r,t)}function S4(e,t){const r=t.get(e);if(r)return r;let o=Yn(e,[],!1).filter(s=>St(s)&&pn(s)!=="body"),n=null;const i=It(e).position==="fixed";let a=i?lr(e):e;for(;St(a)&&!nn(a);){const s=It(a),l=Xc(a);!l&&s.position==="fixed"&&(n=null),(i?!l&&!n:!l&&s.position==="static"&&!!n&&x4.has(n.position)||Co(a)&&!l&&N$(e,a))?o=o.filter(c=>c!==a):n=s,a=lr(a)}return t.set(e,o),o}function I4(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const a=[...r==="clippingAncestors"?Ka(t)?[]:S4(t,this._c):[].concat(r),o],s=a[0],l=a.reduce((u,c)=>{const d=Zf(t,c,n);return u.top=Ye(d.top,u.top),u.right=ur(d.right,u.right),u.bottom=ur(d.bottom,u.bottom),u.left=Ye(d.left,u.left),u},Zf(t,s,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function k4(e){const{width:t,height:r}=E$(e);return{width:t,height:r}}function E4(e,t,r){const o=zt(t),n=Dt(t),i=r==="fixed",a=Ir(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=At(0);function u(){l.x=rd(n)}if(o||!o&&!i)if((pn(t)!=="body"||Co(n))&&(s=Ya(t)),o){const p=Ir(t,!0,i,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else n&&u();i&&!o&&n&&u();const c=n&&!o&&!i?O$(n,s):At(0),d=a.left+s.scrollLeft-l.x-c.x,f=a.top+s.scrollTop-l.y-c.y;return{x:d,y:f,width:a.width,height:a.height}}function Ds(e){return It(e).position==="static"}function Ff(e,t){if(!zt(e)||It(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Dt(e)===r&&(r=r.ownerDocument.body),r}function P$(e,t){const r=Qe(e);if(Ka(e))return r;if(!zt(e)){let n=lr(e);for(;n&&!nn(n);){if(St(n)&&!Ds(n))return n;n=lr(n)}return r}let o=Ff(e,t);for(;o&&l4(o)&&Ds(o);)o=Ff(o,t);return o&&nn(o)&&Ds(o)&&!Xc(o)?r:o||m4(e)||r}const T4=async function(e){const t=this.getOffsetParent||P$,r=this.getDimensions,o=await r(e.floating);return{reference:E4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function O4(e){return It(e).direction==="rtl"}const N4={convertOffsetParentRelativeRectToViewportRelativeRect:y4,getDocumentElement:Dt,getClippingRect:I4,getOffsetParent:P$,getElementRects:T4,getClientRects:b4,getDimensions:k4,getScale:Vr,isElement:St,isRTL:O4};function C$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function P4(e,t){let r=null,o;const n=Dt(e);function i(){var s;clearTimeout(o),(s=r)==null||s.disconnect(),r=null}function a(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:p}=u;if(s||t(),!f||!p)return;const g=Go(d),h=Go(n.clientWidth-(c+f)),b=Go(n.clientHeight-(d+p)),y=Go(c),$={rootMargin:-g+"px "+-h+"px "+-b+"px "+-y+"px",threshold:Ye(0,ur(1,l))||1};let v=!0;function k(N){const I=N[0].intersectionRatio;if(I!==l){if(!v)return a();I?a(!1,I):o=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!C$(u,e.getBoundingClientRect())&&a(),v=!1}try{r=new IntersectionObserver(k,{...$,root:n.ownerDocument})}catch{r=new IntersectionObserver(k,$)}r.observe(e)}return a(!0),i}function C4(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=td(e),c=n||i?[...u?Yn(u):[],...Yn(t)]:[];c.forEach(y=>{n&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const d=u&&s?P4(u,r):null;let f=-1,p=null;a&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var $;($=p)==null||$.observe(t)})),r()}),u&&!l&&p.observe(u),p.observe(t));let g,h=l?Ir(e):null;l&&b();function b(){const y=Ir(e);h&&!C$(h,y)&&r(),h=y,g=requestAnimationFrame(b)}return r(),()=>{var y;c.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const j4=n4,A4=o4,R4=e4,z4=a4,M4=t4,qf=XM,D4=i4,U4=(e,t,r)=>{const o=new Map,n={platform:N4,...r},i={...n.platform,_c:o};return QM(e,t,{...n,platform:i})};var L4=typeof document<"u",Z4=function(){},ai=L4?D.useLayoutEffect:Z4;function Zi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!Zi(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const i=n[o];if(!(i==="_owner"&&e.$$typeof)&&!Zi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function j$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vf(e,t){const r=j$(e);return Math.round(t*r)/r}function Us(e){const t=_.useRef(e);return ai(()=>{t.current=e}),t}function F4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(o);Zi(f,o)||p(o);const[g,h]=_.useState(null),[b,y]=_.useState(null),x=_.useCallback(K=>{K!==N.current&&(N.current=K,h(K))},[]),$=_.useCallback(K=>{K!==I.current&&(I.current=K,y(K))},[]),v=i||g,k=a||b,N=_.useRef(null),I=_.useRef(null),O=_.useRef(c),z=l!=null,F=Us(l),te=Us(n),ie=Us(u),J=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:r,middleware:f};te.current&&(K.platform=te.current),U4(N.current,I.current,K).then(fe=>{const B={...fe,isPositioned:ie.current!==!1};V.current&&!Zi(O.current,B)&&(O.current=B,sm.flushSync(()=>{d(B)}))})},[f,t,r,te,ie]);ai(()=>{u===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const V=_.useRef(!1);ai(()=>(V.current=!0,()=>{V.current=!1}),[]),ai(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(F.current)return F.current(v,k,J);J()}},[v,k,J,F,z]);const we=_.useMemo(()=>({reference:N,floating:I,setReference:x,setFloating:$}),[x,$]),oe=_.useMemo(()=>({reference:v,floating:k}),[v,k]),de=_.useMemo(()=>{const K={position:r,left:0,top:0};if(!oe.floating)return K;const fe=Vf(oe.floating,c.x),B=Vf(oe.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+B+"px)",...j$(oe.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:B}},[r,s,oe.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:J,refs:we,elements:oe,floatingStyles:de}),[c,J,we,oe,de])}const q4=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?qf({element:o.current,padding:n}).fn(r):{}:o?qf({element:o,padding:n}).fn(r):{}}}},V4=(e,t)=>({...j4(e),options:[e,t]}),B4=(e,t)=>({...A4(e),options:[e,t]}),J4=(e,t)=>({...D4(e),options:[e,t]}),W4=(e,t)=>({...R4(e),options:[e,t]}),H4=(e,t)=>({...z4(e),options:[e,t]}),G4=(e,t)=>({...M4(e),options:[e,t]}),K4=(e,t)=>({...q4(e),options:[e,t]});var Y4="Arrow",A$=_.forwardRef((e,t)=>{const{children:r,width:o=10,height:n=5,...i}=e;return m.jsx(Ce.svg,{...i,ref:t,width:o,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});A$.displayName=Y4;var Q4=A$;function X4(e){const[t,r]=_.useState(void 0);return lt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const i=n[0];let a,s;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;a=u.inlineSize,s=u.blockSize}else a=e.offsetWidth,s=e.offsetHeight;r({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}var nd="Popper",[R$,Qa]=Po(nd),[eD,z$]=R$(nd),M$=e=>{const{__scopePopper:t,children:r}=e,[o,n]=_.useState(null);return m.jsx(eD,{scope:t,anchor:o,onAnchorChange:n,children:r})};M$.displayName=nd;var D$="PopperAnchor",U$=_.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:o,...n}=e,i=z$(D$,r),a=_.useRef(null),s=Ge(t,a),l=_.useRef(null);return _.useEffect(()=>{const u=l.current;l.current=o?.current||a.current,u!==l.current&&i.onAnchorChange(l.current)}),o?null:m.jsx(Ce.div,{...n,ref:s})});U$.displayName=D$;var od="PopperContent",[tD,rD]=R$(od),L$=_.forwardRef((e,t)=>{const{__scopePopper:r,side:o="bottom",sideOffset:n=0,align:i="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...h}=e,b=z$(od,r),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=X4(v),I=N?.width??0,O=N?.height??0,z=o+(i!=="center"?"-"+i:""),F=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},te=Array.isArray(u)?u:[u],ie=te.length>0,J={padding:F,boundary:te.filter(oD),altBoundary:ie},{refs:V,floatingStyles:we,placement:oe,isPositioned:de,middlewareData:K}=F4({strategy:"fixed",placement:z,whileElementsMounted:(...xe)=>C4(...xe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[V4({mainAxis:n+O,alignmentAxis:a}),l&&B4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?J4():void 0,...J}),l&&W4({...J}),H4({...J,apply:({elements:xe,rects:Ro,availableWidth:ss,availableHeight:fn})=>{const{width:pt,height:zo}=Ro.reference,je=xe.floating.style;je.setProperty("--radix-popper-available-width",`${ss}px`),je.setProperty("--radix-popper-available-height",`${fn}px`),je.setProperty("--radix-popper-anchor-width",`${pt}px`),je.setProperty("--radix-popper-anchor-height",`${zo}px`)}}),v&&K4({element:v,padding:s}),iD({arrowWidth:I,arrowHeight:O}),f&&G4({strategy:"referenceHidden",...J})]}),[fe,B]=q$(oe),Ue=Sr(g);lt(()=>{de&&Ue?.()},[de,Ue]);const ye=K.arrow?.x,Le=K.arrow?.y,U=K.arrow?.centerOffset!==0,[Q,me]=_.useState();return lt(()=>{y&&me(window.getComputedStyle(y).zIndex)},[y]),m.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...we,transform:de?we.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(tD,{scope:r,placedSide:fe,onArrowChange:k,arrowX:ye,arrowY:Le,shouldHideArrow:U,children:m.jsx(Ce.div,{"data-side":fe,"data-align":B,...h,ref:$,style:{...h.style,animation:de?void 0:"none"}})})})});L$.displayName=od;var Z$="PopperArrow",nD={top:"bottom",right:"left",bottom:"top",left:"right"},F$=_.forwardRef(function(t,r){const{__scopePopper:o,...n}=t,i=rD(Z$,o),a=nD[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:m.jsx(Q4,{...n,ref:r,style:{...n.style,display:"block"}})})});F$.displayName=Z$;function oD(e){return e!==null}var iD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:o,middlewareData:n}=t,a=n.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=q$(r),d={start:"0%",center:"50%",end:"100%"}[c],f=(n.arrow?.x??0)+s/2,p=(n.arrow?.y??0)+l/2;let g="",h="";return u==="bottom"?(g=a?d:`${f}px`,h=`${-l}px`):u==="top"?(g=a?d:`${f}px`,h=`${o.floating.height+l}px`):u==="right"?(g=`${-l}px`,h=a?d:`${p}px`):u==="left"&&(g=`${o.floating.width+l}px`,h=a?d:`${p}px`),{data:{x:g,y:h}}}});function q$(e){const[t,r="center"]=e.split("-");return[t,r]}var V$=M$,id=U$,B$=L$,J$=F$,aD="Portal",Xa=_.forwardRef((e,t)=>{const{container:r,...o}=e,[n,i]=_.useState(!1);lt(()=>i(!0),[]);const a=r||n&&globalThis?.document?.body;return a?am.createPortal(m.jsx(Ce.div,{...o,ref:t}),a):null});Xa.displayName=aD;function sD(e,t){return _.useReducer((r,o)=>t[r][o]??r,e)}var Gt=e=>{const{present:t,children:r}=e,o=uD(t),n=typeof r=="function"?r({present:o.isPresent}):_.Children.only(r),i=Ge(o.ref,lD(n));return typeof r=="function"||o.isPresent?_.cloneElement(n,{ref:i}):null};Gt.displayName="Presence";function uD(e){const[t,r]=_.useState(),o=_.useRef(null),n=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=sD(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const u=Ko(o.current);i.current=s==="mounted"?u:"none"},[s]),lt(()=>{const u=o.current,c=n.current;if(c!==e){const f=i.current,p=Ko(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&f!==p?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,l]),lt(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=p=>{const h=Ko(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&h&&(l("ANIMATION_END"),!n.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(i.current=Ko(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:_.useCallback(u=>{o.current=u?getComputedStyle(u):null,r(u)},[])}}function Ko(e){return e?.animationName||"none"}function lD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var cD=_[" useInsertionEffect ".trim().toString()]||lt;function es({prop:e,defaultProp:t,onChange:r=()=>{},caller:o}){const[n,i,a]=dD({defaultProp:t,onChange:r}),s=e!==void 0,l=s?e:n;{const c=_.useRef(e!==void 0);_.useEffect(()=>{const d=c.current;d!==s&&console.warn(`${o} is changing from ${d?"controlled":"uncontrolled"} to ${s?"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.`),c.current=s},[s,o])}const u=_.useCallback(c=>{if(s){const d=pD(c)?c(e):c;d!==e&&a.current?.(d)}else i(c)},[s,e,i,a]);return[l,u]}function dD({defaultProp:e,onChange:t}){const[r,o]=_.useState(e),n=_.useRef(r),i=_.useRef(t);return cD(()=>{i.current=t},[t]),_.useEffect(()=>{n.current!==r&&(i.current?.(r),n.current=r)},[r,n]),[r,o,i]}function pD(e){return typeof e=="function"}var fD=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"}),mD="VisuallyHidden",W$=_.forwardRef((e,t)=>m.jsx(Ce.span,{...e,ref:t,style:{...fD,...e.style}}));W$.displayName=mD;var hD=W$,[ts]=Po("Tooltip",[Qa]),rs=Qa(),H$="TooltipProvider",gD=700,ju="tooltip.open",[vD,ad]=ts(H$),G$=e=>{const{__scopeTooltip:t,delayDuration:r=gD,skipDelayDuration:o=300,disableHoverableContent:n=!1,children:i}=e,a=_.useRef(!0),s=_.useRef(!1),l=_.useRef(0);return _.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),m.jsx(vD,{scope:t,isOpenDelayedRef:a,delayDuration:r,onOpen:_.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(u=>{s.current=u},[]),disableHoverableContent:n,children:i})};G$.displayName=H$;var Qn="Tooltip",[yD,jo]=ts(Qn),K$=e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=ad(Qn,e.__scopeTooltip),u=rs(t),[c,d]=_.useState(null),f=qr(),p=_.useRef(0),g=a??l.disableHoverableContent,h=s??l.delayDuration,b=_.useRef(!1),[y,x]=es({prop:o,defaultProp:n??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(ju))):l.onClose(),i?.(I)},caller:Qn}),$=_.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),v=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),N=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},h)},[h,x]);return _.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),m.jsx(V$,{...u,children:m.jsx(yD,{scope:t,contentId:f,open:y,stateAttribute:$,trigger:c,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{l.isOpenDelayedRef.current?N():v()},[l.isOpenDelayedRef,N,v]),onTriggerLeave:_.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:v,onClose:k,disableHoverableContent:g,children:r})})};K$.displayName=Qn;var Au="TooltipTrigger",Y$=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=jo(Au,r),i=ad(Au,r),a=rs(r),s=_.useRef(null),l=Ge(t,s,n.onTriggerChange),u=_.useRef(!1),c=_.useRef(!1),d=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(id,{asChild:!0,...a,children:m.jsx(Ce.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...o,ref:l,onPointerMove:Oe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(n.onTriggerEnter(),c.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{n.onTriggerLeave(),c.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{n.open&&n.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Oe(e.onFocus,()=>{u.current||n.onOpen()}),onBlur:Oe(e.onBlur,n.onClose),onClick:Oe(e.onClick,n.onClose)})})});Y$.displayName=Au;var sd="TooltipPortal",[bD,_D]=ts(sd,{forceMount:void 0}),Q$=e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,i=jo(sd,t);return m.jsx(bD,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(Xa,{asChild:!0,container:n,children:o})})})};Q$.displayName=sd;var on="TooltipContent",X$=_.forwardRef((e,t)=>{const r=_D(on,e.__scopeTooltip),{forceMount:o=r.forceMount,side:n="top",...i}=e,a=jo(on,e.__scopeTooltip);return m.jsx(Gt,{present:o||a.open,children:a.disableHoverableContent?m.jsx(eS,{side:n,...i,ref:t}):m.jsx(wD,{side:n,...i,ref:t})})}),wD=_.forwardRef((e,t)=>{const r=jo(on,e.__scopeTooltip),o=ad(on,e.__scopeTooltip),n=_.useRef(null),i=Ge(t,n),[a,s]=_.useState(null),{trigger:l,onClose:u}=r,c=n.current,{onPointerInTransitChange:d}=o,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((g,h)=>{const b=g.currentTarget,y={x:g.clientX,y:g.clientY},x=ID(y,b.getBoundingClientRect()),$=kD(y,x),v=ED(h.getBoundingClientRect()),k=OD([...$,...v]);s(k),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(l&&c){const g=b=>p(b,c),h=b=>p(b,l);return l.addEventListener("pointerleave",g),c.addEventListener("pointerleave",h),()=>{l.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",h)}}},[l,c,p,f]),_.useEffect(()=>{if(a){const g=h=>{const b=h.target,y={x:h.clientX,y:h.clientY},x=l?.contains(b)||c?.contains(b),$=!TD(y,a);x?f():$&&(f(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,f]),m.jsx(eS,{...e,ref:i})}),[xD,$D]=ts(Qn,{isInside:!1}),SD=IM("TooltipContent"),eS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,children:o,"aria-label":n,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=jo(on,r),u=rs(r),{onClose:c}=l;return _.useEffect(()=>(document.addEventListener(ju,c),()=>document.removeEventListener(ju,c)),[c]),_.useEffect(()=>{if(l.trigger){const d=f=>{f.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),m.jsx(Ha,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:m.jsxs(B$,{"data-state":l.stateAttribute,...u,...s,ref:t,style:{...s.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:[m.jsx(SD,{children:o}),m.jsx(xD,{scope:r,isInside:!0,children:m.jsx(hD,{id:l.contentId,role:"tooltip",children:n||o})})]})})});X$.displayName=on;var tS="TooltipArrow",rS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=rs(r);return $D(tS,r).isInside?null:m.jsx(J$,{...n,...o,ref:t})});rS.displayName=tS;function ID(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,o,n,i)){case i:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function kD(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}function ED(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}function TD(e,t){const{x:r,y:o}=e;let n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],u=s.x,c=s.y,d=l.x,f=l.y;c>o!=f>o&&r<(d-u)*(o-c)/(f-c)+u&&(n=!n)}return n}function OD(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),ND(t)}function ND(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var PD=G$,CD=K$,jD=Y$,AD=Q$,RD=X$,zD=rS;function nS({delayDuration:e=0,...t}){return m.jsx(PD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ud({...e}){return m.jsx(nS,{children:m.jsx(CD,{"data-slot":"tooltip",...e})})}function ld({...e}){return m.jsx(jD,{"data-slot":"tooltip-trigger",...e})}function cd({className:e,sideOffset:t=0,children:r,...o}){return m.jsx(AD,{children:m.jsxs(RD,{"data-slot":"tooltip-content",sideOffset:t,className:T.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",e),...o,children:[r,m.jsx(zD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}var Ls="focusScope.autoFocusOnMount",Zs="focusScope.autoFocusOnUnmount",Bf={bubbles:!1,cancelable:!0},MD="FocusScope",dd=_.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:n,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=Sr(n),c=Sr(i),d=_.useRef(null),f=Ge(t,h=>l(h)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(o){let h=function($){if(p.paused||!s)return;const v=$.target;s.contains(v)?d.current=v:Qt(d.current,{select:!0})},b=function($){if(p.paused||!s)return;const v=$.relatedTarget;v!==null&&(s.contains(v)||Qt(d.current,{select:!0}))},y=function($){if(document.activeElement===document.body)for(const k of $)k.removedNodes.length>0&&Qt(s)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const x=new MutationObserver(y);return s&&x.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),x.disconnect()}}},[o,s,p.paused]),_.useEffect(()=>{if(s){Wf.add(p);const h=document.activeElement;if(!s.contains(h)){const y=new CustomEvent(Ls,Bf);s.addEventListener(Ls,u),s.dispatchEvent(y),y.defaultPrevented||(DD(qD(oS(s)),{select:!0}),document.activeElement===h&&Qt(s))}return()=>{s.removeEventListener(Ls,u),setTimeout(()=>{const y=new CustomEvent(Zs,Bf);s.addEventListener(Zs,c),s.dispatchEvent(y),y.defaultPrevented||Qt(h??document.body,{select:!0}),s.removeEventListener(Zs,c),Wf.remove(p)},0)}}},[s,u,c,p]);const g=_.useCallback(h=>{if(!r&&!o||p.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,y=document.activeElement;if(b&&y){const x=h.currentTarget,[$,v]=UD(x);$&&v?!h.shiftKey&&y===v?(h.preventDefault(),r&&Qt($,{select:!0})):h.shiftKey&&y===$&&(h.preventDefault(),r&&Qt(v,{select:!0})):y===x&&h.preventDefault()}},[r,o,p.paused]);return m.jsx(Ce.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})});dd.displayName=MD;function DD(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Qt(o,{select:t}),document.activeElement!==r)return}function UD(e){const t=oS(e),r=Jf(t,e),o=Jf(t.reverse(),e);return[r,o]}function oS(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Jf(e,t){for(const r of e)if(!LD(r,{upTo:t}))return r}function LD(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function ZD(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&ZD(e)&&t&&e.select()}}var Wf=FD();function FD(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Hf(e,t),e.unshift(t)},remove(t){e=Hf(e,t),e[0]?.resume()}}}function Hf(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function qD(e){return e.filter(t=>t.tagName!=="A")}var Fs=0;function iS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Gf()),document.body.insertAdjacentElement("beforeend",e[1]??Gf()),Fs++,()=>{Fs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Fs--}},[])}function Gf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Pt=function(){return Pt=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function aS(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function VD(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var si="right-scroll-bar-position",ui="width-before-scroll-bar",BD="with-scroll-bars-hidden",JD="--removed-body-scroll-bar-size";function qs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function WD(e,t){var r=D.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var HD=typeof window<"u"?_.useLayoutEffect:_.useEffect,Kf=new WeakMap;function GD(e,t){var r=WD(null,function(o){return e.forEach(function(n){return qs(n,o)})});return HD(function(){var o=Kf.get(r);if(o){var n=new Set(o),i=new Set(e),a=r.current;n.forEach(function(s){i.has(s)||qs(s,null)}),i.forEach(function(s){n.has(s)||qs(s,a)})}Kf.set(r,e)},[e]),r}function KD(e){return e}function YD(e,t){t===void 0&&(t=KD);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var a=t(i,o);return r.push(a),function(){r=r.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(s){return i(s)},filter:function(){return r}}},assignMedium:function(i){o=!0;var a=[];if(r.length){var s=r;r=[],s.forEach(i),a=r}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),r}}}};return n}function QD(e){e===void 0&&(e={});var t=YD(null);return t.options=Pt({async:!0,ssr:!1},e),t}var sS=function(e){var t=e.sideCar,r=aS(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return _.createElement(o,Pt({},r))};sS.isSideCarExport=!0;function XD(e,t){return e.useMedium(t),sS}var uS=QD(),Vs=function(){},ns=_.forwardRef(function(e,t){var r=_.useRef(null),o=_.useState({onScrollCapture:Vs,onWheelCapture:Vs,onTouchMoveCapture:Vs}),n=o[0],i=o[1],a=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,y=e.as,x=y===void 0?"div":y,$=e.gapMode,v=aS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,N=GD([r,t]),I=Pt(Pt({},v),n);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:uS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!b,lockRef:r,gapMode:$}),a?_.cloneElement(_.Children.only(s),Pt(Pt({},I),{ref:N})):_.createElement(x,Pt({},I,{className:l,ref:N}),s))});ns.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ns.classNames={fullWidth:ui,zeroRight:si};var eU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=eU();return t&&e.setAttribute("nonce",t),e}function rU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function nU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var oU=function(){var e=0,t=null;return{add:function(r){e==0&&(t=tU())&&(rU(t,r),nU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},iU=function(){var e=oU();return function(t,r){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},lS=function(){var e=iU(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},aU={left:0,top:0,right:0,gap:0},Bs=function(e){return parseInt(e||"",10)||0},sU=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[Bs(r),Bs(o),Bs(n)]},uU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return aU;var t=sU(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},lU=lS(),Br="data-scroll-locked",cU=function(e,t,r,o){var n=e.left,i=e.top,a=e.right,s=e.gap;return r===void 0&&(r="margin"),`
|
|
96
|
+
`)}`}function bM(e){return(e.api?.url||"https://app.getgram.ai").replace(/\/+$/,"")}const _M=({children:e,config:t})=>{const r=bM(t),o=hM({auth:t.api,projectSlug:t.projectSlug}),n=B_(),[i,a]=D.useState(t.model?.defaultModel??Oc[0]),[s,l]=D.useState(t.modal?.defaultExpanded??!1),[u,c]=D.useState(t.modal?.defaultOpen),d=t.plugins??T.recommended,f=yM(t.systemPrompt,d),{data:p,isLoading:g}=aN({auth:o,mcp:t.mcp,environment:t.environment??{}}),h=D.useRef({requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool});h.current={requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool};const b=D.useCallback(()=>({requestApproval:(...$)=>h.current.requestApproval(...$),isToolApproved:(...$)=>h.current.isToolApproved(...$),whitelistTool:(...$)=>h.current.whitelistTool(...$)}),[]);D.useEffect(()=>(t.tools?.toolsRequiringApproval?.length&&cN(b(),t.tools.toolsRequiringApproval),()=>{dN()}),[t.tools?.toolsRequiringApproval,b]);const y=D.useMemo(()=>({sendMessages:async({messages:$,abortSignal:v})=>{const k=!!t.languageModel;if(o.isLoading)throw new Error("Session is laoding");const N=x.thread.getModelContext(),I=uN(lN(N?.tools??{})),O=k?null:ix({baseURL:r,apiKey:"unused, but must be set",headers:o.headers});t.languageModel&&console.log("Using custom language model",t.languageModel);const z={...p,...Oj(I)},F=fN(z,t.tools?.toolsRequiringApproval,b()),te=t.languageModel?t.languageModel:O.chat(i);try{return oM({system:f,model:te,messages:sM($),tools:F,stopWhen:m$(10),experimental_transform:pM({delayInMs:15}),abortSignal:v,onError:({error:J})=>{console.error("Stream error in onError callback:",J)}}).toUIMessageStream()}catch(ie){throw console.error("Error creating stream:",ie),ie}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,i,f,p,g,b,r,o.headers]),x=Tj({transport:y});return m.jsx(L.AssistantRuntimeProvider,{runtime:x,children:m.jsxs(T.ElementsContext.Provider,{value:{config:t,setModel:a,model:i,isExpanded:s,setIsExpanded:l,isOpen:u??!1,setIsOpen:c,plugins:d},children:[e,m.jsx(x0,{tools:t.tools?.frontendTools??{}})]})})},wM=e=>{const t=new WO;return m.jsx(HO,{client:t,children:m.jsx(gM,{children:m.jsx(_M,{...e})})})};function Oe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function Cf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hc(...e){return t=>{let r=!1;const o=e.map(n=>{const i=Cf(n,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let n=0;n<o.length;n++){const i=o[n];typeof i=="function"?i():Cf(e[n],null)}}}}function Ge(...e){return _.useCallback(Hc(...e),e)}function xM(e,t){const r=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return m.jsx(r.Provider,{value:l,children:a})};o.displayName=e+"Provider";function n(i){const a=_.useContext(r);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,n]}function Po(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a),l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,$M(n,...t)]}function $M(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}function Gc(e){const t=SM(e),r=_.forwardRef((o,n)=>{const{children:i,...a}=o,s=_.Children.toArray(i),l=s.find(kM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}function SM(e){const t=_.forwardRef((r,o)=>{const{children:n,...i}=r;if(_.isValidElement(n)){const a=TM(n),s=EM(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Hc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _$=Symbol("radix.slottable");function IM(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=_$,t}function kM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_$}function EM(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function TM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var OM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=OM.reduce((e,t)=>{const r=Gc(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function NM(e,t){e&&sm.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...r)=>t.current?.(...r),[])}function PM(e,t=globalThis?.document){const r=Sr(e);_.useEffect(()=>{const o=n=>{n.key==="Escape"&&r(n)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[r,t])}var CM="DismissableLayer",Ou="dismissableLayer.update",jM="dismissableLayer.pointerDownOutside",AM="dismissableLayer.focusOutside",jf,w$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ha=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:n,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(w$),[c,d]=_.useState(null),f=c?.ownerDocument??globalThis?.document,[,p]=_.useState({}),g=Ge(t,I=>d(I)),h=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=h.indexOf(b),x=c?h.indexOf(c):-1,$=u.layersWithOutsidePointerEventsDisabled.size>0,v=x>=y,k=MM(I=>{const O=I.target,z=[...u.branches].some(F=>F.contains(O));!v||z||(n?.(I),a?.(I),I.defaultPrevented||s?.())},f),N=DM(I=>{const O=I.target;[...u.branches].some(F=>F.contains(O))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},f);return PM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},f),_.useEffect(()=>{if(c)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jf=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Af(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=jf)}},[c,f,r,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Af())},[c,u]),_.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ou,I),()=>document.removeEventListener(Ou,I)},[]),m.jsx(Ce.div,{...l,ref:g,style:{pointerEvents:$?v?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,k.onPointerDownCapture)})});Ha.displayName=CM;var RM="DismissableLayerBranch",zM=_.forwardRef((e,t)=>{const r=_.useContext(w$),o=_.useRef(null),n=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),m.jsx(Ce.div,{...e,ref:n})});zM.displayName=RM;function MM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1),n=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){x$(jM,r,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=l,t.addEventListener("click",n.current,{once:!0})):l()}else t.removeEventListener("click",n.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",n.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function DM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1);return _.useEffect(()=>{const n=i=>{i.target&&!o.current&&x$(AM,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Af(){const e=new CustomEvent(Ou);document.dispatchEvent(e)}function x$(e,t,r,{discrete:o}){const n=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?NM(n,i):n.dispatchEvent(i)}var lt=globalThis?.document?_.useLayoutEffect:()=>{},UM=_[" useId ".trim().toString()]||(()=>{}),LM=0;function qr(e){const[t,r]=_.useState(UM());return lt(()=>{r(o=>o??String(LM++))},[e]),t?`radix-${t}`:""}const ZM=["top","right","bottom","left"],ur=Math.min,Ye=Math.max,Di=Math.round,Go=Math.floor,At=e=>({x:e,y:e}),FM={left:"right",right:"left",bottom:"top",top:"bottom"},qM={start:"end",end:"start"};function Nu(e,t,r){return Ye(e,ur(t,r))}function Bt(e,t){return typeof e=="function"?e(t):e}function Jt(e){return e.split("-")[0]}function dn(e){return e.split("-")[1]}function Kc(e){return e==="x"?"y":"x"}function Yc(e){return e==="y"?"height":"width"}const VM=new Set(["top","bottom"]);function jt(e){return VM.has(Jt(e))?"y":"x"}function Qc(e){return Kc(jt(e))}function BM(e,t,r){r===void 0&&(r=!1);const o=dn(e),n=Qc(e),i=Yc(n);let a=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Ui(a)),[a,Ui(a)]}function JM(e){const t=Ui(e);return[Pu(e),t,Pu(t)]}function Pu(e){return e.replace(/start|end/g,t=>qM[t])}const Rf=["left","right"],zf=["right","left"],WM=["top","bottom"],HM=["bottom","top"];function GM(e,t,r){switch(e){case"top":case"bottom":return r?t?zf:Rf:t?Rf:zf;case"left":case"right":return t?WM:HM;default:return[]}}function KM(e,t,r,o){const n=dn(e);let i=GM(Jt(e),r==="start",o);return n&&(i=i.map(a=>a+"-"+n),t&&(i=i.concat(i.map(Pu)))),i}function Ui(e){return e.replace(/left|right|bottom|top/g,t=>FM[t])}function YM(e){return{top:0,right:0,bottom:0,left:0,...e}}function $$(e){return typeof e!="number"?YM(e):{top:e,right:e,bottom:e,left:e}}function Li(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function Mf(e,t,r){let{reference:o,floating:n}=e;const i=jt(t),a=Qc(t),s=Yc(a),l=Jt(t),u=i==="y",c=o.x+o.width/2-n.width/2,d=o.y+o.height/2-n.height/2,f=o[s]/2-n[s]/2;let p;switch(l){case"top":p={x:c,y:o.y-n.height};break;case"bottom":p={x:c,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-n.width,y:d};break;default:p={x:o.x,y:o.y}}switch(dn(t)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const QM=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:a}=r,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=Mf(u,o,l),f=o,p={},g=0;for(let h=0;h<s.length;h++){const{name:b,fn:y}=s[h],{x,y:$,data:v,reset:k}=await y({x:c,y:d,initialPlacement:o,placement:f,strategy:n,middlewareData:p,rects:u,platform:a,elements:{reference:e,floating:t}});c=x??c,d=$??d,p={...p,[b]:{...p[b],...v}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:n}):k.rects),{x:c,y:d}=Mf(u,f,l)),h=-1)}return{x:c,y:d,placement:f,strategy:n,middlewareData:p}};async function Kn(e,t){var r;t===void 0&&(t={});const{x:o,y:n,platform:i,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Bt(t,e),g=$$(p),b=s[f?d==="floating"?"reference":"floating":d],y=Li(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(b)))==null||r?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),x=d==="floating"?{x:o,y:n,width:a.floating.width,height:a.floating.height}:a.reference,$=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),v=await(i.isElement==null?void 0:i.isElement($))?await(i.getScale==null?void 0:i.getScale($))||{x:1,y:1}:{x:1,y:1},k=Li(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:$,strategy:l}):x);return{top:(y.top-k.top+g.top)/v.y,bottom:(k.bottom-y.bottom+g.bottom)/v.y,left:(y.left-k.left+g.left)/v.x,right:(k.right-y.right+g.right)/v.x}}const XM=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Bt(e,t)||{};if(u==null)return{};const d=$$(c),f={x:r,y:o},p=Qc(n),g=Yc(p),h=await a.getDimensions(u),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",$=b?"clientHeight":"clientWidth",v=i.reference[g]+i.reference[p]-f[p]-i.floating[g],k=f[p]-i.reference[p],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[$]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=s.floating[$]||i.floating[g]);const O=v/2-k/2,z=I/2-h[g]/2-1,F=ur(d[y],z),te=ur(d[x],z),ie=F,J=I-h[g]-te,V=I/2-h[g]/2+O,we=Nu(ie,V,J),oe=!l.arrow&&dn(n)!=null&&V!==we&&i.reference[g]/2-(V<ie?F:te)-h[g]/2<0,de=oe?V<ie?V-ie:V-J:0;return{[p]:f[p]+de,data:{[p]:we,centerOffset:V-we-de,...oe&&{alignmentOffset:de}},reset:oe}}}),e4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,middlewareData:i,rects:a,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=Bt(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=Jt(n),x=jt(s),$=Jt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=f||($||!h?[Ui(s)]:JM(s)),N=g!=="none";!f&&N&&k.push(...KM(s,h,g,v));const I=[s,...k],O=await Kn(t,b),z=[];let F=((o=i.flip)==null?void 0:o.overflows)||[];if(c&&z.push(O[y]),d){const V=BM(n,a,v);z.push(O[V[0]],O[V[1]])}if(F=[...F,{placement:n,overflows:z}],!z.every(V=>V<=0)){var te,ie;const V=(((te=i.flip)==null?void 0:te.index)||0)+1,we=I[V];if(we&&(!(d==="alignment"?x!==jt(we):!1)||F.every(K=>jt(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:V,overflows:F},reset:{placement:we}};let oe=(ie=F.filter(de=>de.overflows[0]<=0).sort((de,K)=>de.overflows[1]-K.overflows[1])[0])==null?void 0:ie.placement;if(!oe)switch(p){case"bestFit":{var J;const de=(J=F.filter(K=>{if(N){const fe=jt(K.placement);return fe===x||fe==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(fe=>fe>0).reduce((fe,B)=>fe+B,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:J[0];de&&(oe=de);break}case"initialPlacement":oe=s;break}if(n!==oe)return{reset:{placement:oe}}}return{}}}};function Df(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Uf(e){return ZM.some(t=>e[t]>=0)}const t4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:o="referenceHidden",...n}=Bt(e,t);switch(o){case"referenceHidden":{const i=await Kn(t,{...n,elementContext:"reference"}),a=Df(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Uf(a)}}}case"escaped":{const i=await Kn(t,{...n,altBoundary:!0}),a=Df(i,r.floating);return{data:{escapedOffsets:a,escaped:Uf(a)}}}default:return{}}}}},S$=new Set(["left","top"]);async function r4(e,t){const{placement:r,platform:o,elements:n}=e,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),a=Jt(r),s=dn(r),l=jt(r)==="y",u=S$.has(a)?-1:1,c=i&&l?-1:1,d=Bt(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof g=="number"&&(p=s==="end"?g*-1:g),l?{x:p*c,y:f*u}:{x:f*u,y:p*c}}const n4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:i,placement:a,middlewareData:s}=t,l=await r4(t,e);return a===((r=s.offset)==null?void 0:r.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:n+l.x,y:i+l.y,data:{...l,placement:a}}}}},o4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:s={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Bt(e,t),u={x:r,y:o},c=await Kn(t,l),d=jt(Jt(n)),f=Kc(d);let p=u[f],g=u[d];if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=p+c[b],$=p-c[y];p=Nu(x,p,$)}if(a){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=g+c[b],$=g-c[y];g=Nu(x,g,$)}const h=s.fn({...t,[f]:p,[d]:g});return{...h,data:{x:h.x-r,y:h.y-o,enabled:{[f]:i,[d]:a}}}}}},i4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:o,placement:n,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Bt(e,t),c={x:r,y:o},d=jt(n),f=Kc(d);let p=c[f],g=c[d];const h=Bt(s,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(l){const $=f==="y"?"height":"width",v=i.reference[f]-i.floating[$]+b.mainAxis,k=i.reference[f]+i.reference[$]-b.mainAxis;p<v?p=v:p>k&&(p=k)}if(u){var y,x;const $=f==="y"?"width":"height",v=S$.has(Jt(n)),k=i.reference[d]-i.floating[$]+(v&&((y=a.offset)==null?void 0:y[d])||0)+(v?0:b.crossAxis),N=i.reference[d]+i.reference[$]+(v?0:((x=a.offset)==null?void 0:x[d])||0)-(v?b.crossAxis:0);g<k?g=k:g>N&&(g=N)}return{[f]:p,[d]:g}}}},a4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,o;const{placement:n,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Bt(e,t),c=await Kn(t,u),d=Jt(n),f=dn(n),p=jt(n)==="y",{width:g,height:h}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=f===(await(a.isRTL==null?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,b=f==="end"?"top":"bottom");const x=h-c.top-c.bottom,$=g-c.left-c.right,v=ur(h-c[b],x),k=ur(g-c[y],$),N=!t.middlewareData.shift;let I=v,O=k;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(O=$),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(I=x),N&&!f){const F=Ye(c.left,0),te=Ye(c.right,0),ie=Ye(c.top,0),J=Ye(c.bottom,0);p?O=g-2*(F!==0||te!==0?F+te:Ye(c.left,c.right)):I=h-2*(ie!==0||J!==0?ie+J:Ye(c.top,c.bottom))}await l({...t,availableWidth:O,availableHeight:I});const z=await a.getDimensions(s.floating);return g!==z.width||h!==z.height?{reset:{rects:!0}}:{}}}};function Ga(){return typeof window<"u"}function pn(e){return I$(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dt(e){var t;return(t=(I$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function I$(e){return Ga()?e instanceof Node||e instanceof Qe(e).Node:!1}function St(e){return Ga()?e instanceof Element||e instanceof Qe(e).Element:!1}function zt(e){return Ga()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function Lf(e){return!Ga()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const s4=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&!s4.has(n)}const u4=new Set(["table","td","th"]);function l4(e){return u4.has(pn(e))}const c4=[":popover-open",":modal"];function Ka(e){return c4.some(t=>{try{return e.matches(t)}catch{return!1}})}const d4=["transform","translate","scale","rotate","perspective"],p4=["transform","translate","scale","rotate","perspective","filter"],f4=["paint","layout","strict","content"];function Xc(e){const t=ed(),r=St(e)?It(e):e;return d4.some(o=>r[o]?r[o]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||p4.some(o=>(r.willChange||"").includes(o))||f4.some(o=>(r.contain||"").includes(o))}function m4(e){let t=lr(e);for(;zt(t)&&!nn(t);){if(Xc(t))return t;if(Ka(t))return null;t=lr(t)}return null}function ed(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const h4=new Set(["html","body","#document"]);function nn(e){return h4.has(pn(e))}function It(e){return Qe(e).getComputedStyle(e)}function Ya(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lr(e){if(pn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Lf(e)&&e.host||Dt(e);return Lf(t)?t.host:t}function k$(e){const t=lr(e);return nn(t)?e.ownerDocument?e.ownerDocument.body:e.body:zt(t)&&Co(t)?t:k$(t)}function Yn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=k$(e),i=n===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(n);if(i){const s=Cu(a);return t.concat(a,a.visualViewport||[],Co(n)?n:[],s&&r?Yn(s):[])}return t.concat(n,Yn(n,[],r))}function Cu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function E$(e){const t=It(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=zt(e),i=n?e.offsetWidth:r,a=n?e.offsetHeight:o,s=Di(r)!==i||Di(o)!==a;return s&&(r=i,o=a),{width:r,height:o,$:s}}function td(e){return St(e)?e:e.contextElement}function Vr(e){const t=td(e);if(!zt(t))return At(1);const r=t.getBoundingClientRect(),{width:o,height:n,$:i}=E$(t);let a=(i?Di(r.width):r.width)/o,s=(i?Di(r.height):r.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const g4=At(0);function T$(e){const t=Qe(e);return!ed()||!t.visualViewport?g4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function v4(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Qe(e)?!1:t}function Ir(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),i=td(e);let a=At(1);t&&(o?St(o)&&(a=Vr(o)):a=Vr(e));const s=v4(i,r,o)?T$(i):At(0);let l=(n.left+s.x)/a.x,u=(n.top+s.y)/a.y,c=n.width/a.x,d=n.height/a.y;if(i){const f=Qe(i),p=o&&St(o)?Qe(o):o;let g=f,h=Cu(g);for(;h&&o&&p!==g;){const b=Vr(h),y=h.getBoundingClientRect(),x=It(h),$=y.left+(h.clientLeft+parseFloat(x.paddingLeft))*b.x,v=y.top+(h.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,u*=b.y,c*=b.x,d*=b.y,l+=$,u+=v,g=Qe(h),h=Cu(g)}}return Li({width:c,height:d,x:l,y:u})}function rd(e,t){const r=Ya(e).scrollLeft;return t?t.left+r:Ir(Dt(e)).left+r}function O$(e,t,r){r===void 0&&(r=!1);const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-(r?0:rd(e,o)),i=o.top+t.scrollTop;return{x:n,y:i}}function y4(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const i=n==="fixed",a=Dt(o),s=t?Ka(t.floating):!1;if(o===a||s&&i)return r;let l={scrollLeft:0,scrollTop:0},u=At(1);const c=At(0),d=zt(o);if((d||!d&&!i)&&((pn(o)!=="body"||Co(a))&&(l=Ya(o)),zt(o))){const p=Ir(o);u=Vr(o),c.x=p.x+o.clientLeft,c.y=p.y+o.clientTop}const f=a&&!d&&!i?O$(a,l,!0):At(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:r.y*u.y-l.scrollTop*u.y+c.y+f.y}}function b4(e){return Array.from(e.getClientRects())}function _4(e){const t=Dt(e),r=Ya(e),o=e.ownerDocument.body,n=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-r.scrollLeft+rd(e);const s=-r.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-n),{width:n,height:i,x:a,y:s}}function w4(e,t){const r=Qe(e),o=Dt(e),n=r.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(n){i=n.width,a=n.height;const u=ed();(!u||u&&t==="fixed")&&(s=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:s,y:l}}const x4=new Set(["absolute","fixed"]);function $4(e,t){const r=Ir(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,i=zt(e)?Vr(e):At(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=n*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function Zf(e,t,r){let o;if(t==="viewport")o=w4(e,r);else if(t==="document")o=_4(Dt(e));else if(St(t))o=$4(t,r);else{const n=T$(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Li(o)}function N$(e,t){const r=lr(e);return r===t||!St(r)||nn(r)?!1:It(r).position==="fixed"||N$(r,t)}function S4(e,t){const r=t.get(e);if(r)return r;let o=Yn(e,[],!1).filter(s=>St(s)&&pn(s)!=="body"),n=null;const i=It(e).position==="fixed";let a=i?lr(e):e;for(;St(a)&&!nn(a);){const s=It(a),l=Xc(a);!l&&s.position==="fixed"&&(n=null),(i?!l&&!n:!l&&s.position==="static"&&!!n&&x4.has(n.position)||Co(a)&&!l&&N$(e,a))?o=o.filter(c=>c!==a):n=s,a=lr(a)}return t.set(e,o),o}function I4(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const a=[...r==="clippingAncestors"?Ka(t)?[]:S4(t,this._c):[].concat(r),o],s=a[0],l=a.reduce((u,c)=>{const d=Zf(t,c,n);return u.top=Ye(d.top,u.top),u.right=ur(d.right,u.right),u.bottom=ur(d.bottom,u.bottom),u.left=Ye(d.left,u.left),u},Zf(t,s,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function k4(e){const{width:t,height:r}=E$(e);return{width:t,height:r}}function E4(e,t,r){const o=zt(t),n=Dt(t),i=r==="fixed",a=Ir(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=At(0);function u(){l.x=rd(n)}if(o||!o&&!i)if((pn(t)!=="body"||Co(n))&&(s=Ya(t)),o){const p=Ir(t,!0,i,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else n&&u();i&&!o&&n&&u();const c=n&&!o&&!i?O$(n,s):At(0),d=a.left+s.scrollLeft-l.x-c.x,f=a.top+s.scrollTop-l.y-c.y;return{x:d,y:f,width:a.width,height:a.height}}function Ds(e){return It(e).position==="static"}function Ff(e,t){if(!zt(e)||It(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Dt(e)===r&&(r=r.ownerDocument.body),r}function P$(e,t){const r=Qe(e);if(Ka(e))return r;if(!zt(e)){let n=lr(e);for(;n&&!nn(n);){if(St(n)&&!Ds(n))return n;n=lr(n)}return r}let o=Ff(e,t);for(;o&&l4(o)&&Ds(o);)o=Ff(o,t);return o&&nn(o)&&Ds(o)&&!Xc(o)?r:o||m4(e)||r}const T4=async function(e){const t=this.getOffsetParent||P$,r=this.getDimensions,o=await r(e.floating);return{reference:E4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function O4(e){return It(e).direction==="rtl"}const N4={convertOffsetParentRelativeRectToViewportRelativeRect:y4,getDocumentElement:Dt,getClippingRect:I4,getOffsetParent:P$,getElementRects:T4,getClientRects:b4,getDimensions:k4,getScale:Vr,isElement:St,isRTL:O4};function C$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function P4(e,t){let r=null,o;const n=Dt(e);function i(){var s;clearTimeout(o),(s=r)==null||s.disconnect(),r=null}function a(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:p}=u;if(s||t(),!f||!p)return;const g=Go(d),h=Go(n.clientWidth-(c+f)),b=Go(n.clientHeight-(d+p)),y=Go(c),$={rootMargin:-g+"px "+-h+"px "+-b+"px "+-y+"px",threshold:Ye(0,ur(1,l))||1};let v=!0;function k(N){const I=N[0].intersectionRatio;if(I!==l){if(!v)return a();I?a(!1,I):o=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!C$(u,e.getBoundingClientRect())&&a(),v=!1}try{r=new IntersectionObserver(k,{...$,root:n.ownerDocument})}catch{r=new IntersectionObserver(k,$)}r.observe(e)}return a(!0),i}function C4(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=td(e),c=n||i?[...u?Yn(u):[],...Yn(t)]:[];c.forEach(y=>{n&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const d=u&&s?P4(u,r):null;let f=-1,p=null;a&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var $;($=p)==null||$.observe(t)})),r()}),u&&!l&&p.observe(u),p.observe(t));let g,h=l?Ir(e):null;l&&b();function b(){const y=Ir(e);h&&!C$(h,y)&&r(),h=y,g=requestAnimationFrame(b)}return r(),()=>{var y;c.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const j4=n4,A4=o4,R4=e4,z4=a4,M4=t4,qf=XM,D4=i4,U4=(e,t,r)=>{const o=new Map,n={platform:N4,...r},i={...n.platform,_c:o};return QM(e,t,{...n,platform:i})};var L4=typeof document<"u",Z4=function(){},ai=L4?D.useLayoutEffect:Z4;function Zi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!Zi(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const i=n[o];if(!(i==="_owner"&&e.$$typeof)&&!Zi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function j$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vf(e,t){const r=j$(e);return Math.round(t*r)/r}function Us(e){const t=_.useRef(e);return ai(()=>{t.current=e}),t}function F4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(o);Zi(f,o)||p(o);const[g,h]=_.useState(null),[b,y]=_.useState(null),x=_.useCallback(K=>{K!==N.current&&(N.current=K,h(K))},[]),$=_.useCallback(K=>{K!==I.current&&(I.current=K,y(K))},[]),v=i||g,k=a||b,N=_.useRef(null),I=_.useRef(null),O=_.useRef(c),z=l!=null,F=Us(l),te=Us(n),ie=Us(u),J=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:r,middleware:f};te.current&&(K.platform=te.current),U4(N.current,I.current,K).then(fe=>{const B={...fe,isPositioned:ie.current!==!1};V.current&&!Zi(O.current,B)&&(O.current=B,sm.flushSync(()=>{d(B)}))})},[f,t,r,te,ie]);ai(()=>{u===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const V=_.useRef(!1);ai(()=>(V.current=!0,()=>{V.current=!1}),[]),ai(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(F.current)return F.current(v,k,J);J()}},[v,k,J,F,z]);const we=_.useMemo(()=>({reference:N,floating:I,setReference:x,setFloating:$}),[x,$]),oe=_.useMemo(()=>({reference:v,floating:k}),[v,k]),de=_.useMemo(()=>{const K={position:r,left:0,top:0};if(!oe.floating)return K;const fe=Vf(oe.floating,c.x),B=Vf(oe.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+B+"px)",...j$(oe.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:B}},[r,s,oe.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:J,refs:we,elements:oe,floatingStyles:de}),[c,J,we,oe,de])}const q4=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?qf({element:o.current,padding:n}).fn(r):{}:o?qf({element:o,padding:n}).fn(r):{}}}},V4=(e,t)=>({...j4(e),options:[e,t]}),B4=(e,t)=>({...A4(e),options:[e,t]}),J4=(e,t)=>({...D4(e),options:[e,t]}),W4=(e,t)=>({...R4(e),options:[e,t]}),H4=(e,t)=>({...z4(e),options:[e,t]}),G4=(e,t)=>({...M4(e),options:[e,t]}),K4=(e,t)=>({...q4(e),options:[e,t]});var Y4="Arrow",A$=_.forwardRef((e,t)=>{const{children:r,width:o=10,height:n=5,...i}=e;return m.jsx(Ce.svg,{...i,ref:t,width:o,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});A$.displayName=Y4;var Q4=A$;function X4(e){const[t,r]=_.useState(void 0);return lt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const i=n[0];let a,s;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;a=u.inlineSize,s=u.blockSize}else a=e.offsetWidth,s=e.offsetHeight;r({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}var nd="Popper",[R$,Qa]=Po(nd),[eD,z$]=R$(nd),M$=e=>{const{__scopePopper:t,children:r}=e,[o,n]=_.useState(null);return m.jsx(eD,{scope:t,anchor:o,onAnchorChange:n,children:r})};M$.displayName=nd;var D$="PopperAnchor",U$=_.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:o,...n}=e,i=z$(D$,r),a=_.useRef(null),s=Ge(t,a),l=_.useRef(null);return _.useEffect(()=>{const u=l.current;l.current=o?.current||a.current,u!==l.current&&i.onAnchorChange(l.current)}),o?null:m.jsx(Ce.div,{...n,ref:s})});U$.displayName=D$;var od="PopperContent",[tD,rD]=R$(od),L$=_.forwardRef((e,t)=>{const{__scopePopper:r,side:o="bottom",sideOffset:n=0,align:i="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...h}=e,b=z$(od,r),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=X4(v),I=N?.width??0,O=N?.height??0,z=o+(i!=="center"?"-"+i:""),F=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},te=Array.isArray(u)?u:[u],ie=te.length>0,J={padding:F,boundary:te.filter(oD),altBoundary:ie},{refs:V,floatingStyles:we,placement:oe,isPositioned:de,middlewareData:K}=F4({strategy:"fixed",placement:z,whileElementsMounted:(...xe)=>C4(...xe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[V4({mainAxis:n+O,alignmentAxis:a}),l&&B4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?J4():void 0,...J}),l&&W4({...J}),H4({...J,apply:({elements:xe,rects:Ro,availableWidth:ss,availableHeight:fn})=>{const{width:pt,height:zo}=Ro.reference,je=xe.floating.style;je.setProperty("--radix-popper-available-width",`${ss}px`),je.setProperty("--radix-popper-available-height",`${fn}px`),je.setProperty("--radix-popper-anchor-width",`${pt}px`),je.setProperty("--radix-popper-anchor-height",`${zo}px`)}}),v&&K4({element:v,padding:s}),iD({arrowWidth:I,arrowHeight:O}),f&&G4({strategy:"referenceHidden",...J})]}),[fe,B]=q$(oe),Ue=Sr(g);lt(()=>{de&&Ue?.()},[de,Ue]);const ye=K.arrow?.x,Le=K.arrow?.y,U=K.arrow?.centerOffset!==0,[Q,me]=_.useState();return lt(()=>{y&&me(window.getComputedStyle(y).zIndex)},[y]),m.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...we,transform:de?we.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(tD,{scope:r,placedSide:fe,onArrowChange:k,arrowX:ye,arrowY:Le,shouldHideArrow:U,children:m.jsx(Ce.div,{"data-side":fe,"data-align":B,...h,ref:$,style:{...h.style,animation:de?void 0:"none"}})})})});L$.displayName=od;var Z$="PopperArrow",nD={top:"bottom",right:"left",bottom:"top",left:"right"},F$=_.forwardRef(function(t,r){const{__scopePopper:o,...n}=t,i=rD(Z$,o),a=nD[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:m.jsx(Q4,{...n,ref:r,style:{...n.style,display:"block"}})})});F$.displayName=Z$;function oD(e){return e!==null}var iD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:o,middlewareData:n}=t,a=n.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=q$(r),d={start:"0%",center:"50%",end:"100%"}[c],f=(n.arrow?.x??0)+s/2,p=(n.arrow?.y??0)+l/2;let g="",h="";return u==="bottom"?(g=a?d:`${f}px`,h=`${-l}px`):u==="top"?(g=a?d:`${f}px`,h=`${o.floating.height+l}px`):u==="right"?(g=`${-l}px`,h=a?d:`${p}px`):u==="left"&&(g=`${o.floating.width+l}px`,h=a?d:`${p}px`),{data:{x:g,y:h}}}});function q$(e){const[t,r="center"]=e.split("-");return[t,r]}var V$=M$,id=U$,B$=L$,J$=F$,aD="Portal",Xa=_.forwardRef((e,t)=>{const{container:r,...o}=e,[n,i]=_.useState(!1);lt(()=>i(!0),[]);const a=r||n&&globalThis?.document?.body;return a?am.createPortal(m.jsx(Ce.div,{...o,ref:t}),a):null});Xa.displayName=aD;function sD(e,t){return _.useReducer((r,o)=>t[r][o]??r,e)}var Gt=e=>{const{present:t,children:r}=e,o=uD(t),n=typeof r=="function"?r({present:o.isPresent}):_.Children.only(r),i=Ge(o.ref,lD(n));return typeof r=="function"||o.isPresent?_.cloneElement(n,{ref:i}):null};Gt.displayName="Presence";function uD(e){const[t,r]=_.useState(),o=_.useRef(null),n=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=sD(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const u=Ko(o.current);i.current=s==="mounted"?u:"none"},[s]),lt(()=>{const u=o.current,c=n.current;if(c!==e){const f=i.current,p=Ko(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&f!==p?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,l]),lt(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=p=>{const h=Ko(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&h&&(l("ANIMATION_END"),!n.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(i.current=Ko(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:_.useCallback(u=>{o.current=u?getComputedStyle(u):null,r(u)},[])}}function Ko(e){return e?.animationName||"none"}function lD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var cD=_[" useInsertionEffect ".trim().toString()]||lt;function es({prop:e,defaultProp:t,onChange:r=()=>{},caller:o}){const[n,i,a]=dD({defaultProp:t,onChange:r}),s=e!==void 0,l=s?e:n;{const c=_.useRef(e!==void 0);_.useEffect(()=>{const d=c.current;d!==s&&console.warn(`${o} is changing from ${d?"controlled":"uncontrolled"} to ${s?"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.`),c.current=s},[s,o])}const u=_.useCallback(c=>{if(s){const d=pD(c)?c(e):c;d!==e&&a.current?.(d)}else i(c)},[s,e,i,a]);return[l,u]}function dD({defaultProp:e,onChange:t}){const[r,o]=_.useState(e),n=_.useRef(r),i=_.useRef(t);return cD(()=>{i.current=t},[t]),_.useEffect(()=>{n.current!==r&&(i.current?.(r),n.current=r)},[r,n]),[r,o,i]}function pD(e){return typeof e=="function"}var fD=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"}),mD="VisuallyHidden",W$=_.forwardRef((e,t)=>m.jsx(Ce.span,{...e,ref:t,style:{...fD,...e.style}}));W$.displayName=mD;var hD=W$,[ts]=Po("Tooltip",[Qa]),rs=Qa(),H$="TooltipProvider",gD=700,ju="tooltip.open",[vD,ad]=ts(H$),G$=e=>{const{__scopeTooltip:t,delayDuration:r=gD,skipDelayDuration:o=300,disableHoverableContent:n=!1,children:i}=e,a=_.useRef(!0),s=_.useRef(!1),l=_.useRef(0);return _.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),m.jsx(vD,{scope:t,isOpenDelayedRef:a,delayDuration:r,onOpen:_.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(u=>{s.current=u},[]),disableHoverableContent:n,children:i})};G$.displayName=H$;var Qn="Tooltip",[yD,jo]=ts(Qn),K$=e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=ad(Qn,e.__scopeTooltip),u=rs(t),[c,d]=_.useState(null),f=qr(),p=_.useRef(0),g=a??l.disableHoverableContent,h=s??l.delayDuration,b=_.useRef(!1),[y,x]=es({prop:o,defaultProp:n??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(ju))):l.onClose(),i?.(I)},caller:Qn}),$=_.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),v=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),N=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},h)},[h,x]);return _.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),m.jsx(V$,{...u,children:m.jsx(yD,{scope:t,contentId:f,open:y,stateAttribute:$,trigger:c,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{l.isOpenDelayedRef.current?N():v()},[l.isOpenDelayedRef,N,v]),onTriggerLeave:_.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:v,onClose:k,disableHoverableContent:g,children:r})})};K$.displayName=Qn;var Au="TooltipTrigger",Y$=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=jo(Au,r),i=ad(Au,r),a=rs(r),s=_.useRef(null),l=Ge(t,s,n.onTriggerChange),u=_.useRef(!1),c=_.useRef(!1),d=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(id,{asChild:!0,...a,children:m.jsx(Ce.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...o,ref:l,onPointerMove:Oe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(n.onTriggerEnter(),c.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{n.onTriggerLeave(),c.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{n.open&&n.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Oe(e.onFocus,()=>{u.current||n.onOpen()}),onBlur:Oe(e.onBlur,n.onClose),onClick:Oe(e.onClick,n.onClose)})})});Y$.displayName=Au;var sd="TooltipPortal",[bD,_D]=ts(sd,{forceMount:void 0}),Q$=e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,i=jo(sd,t);return m.jsx(bD,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(Xa,{asChild:!0,container:n,children:o})})})};Q$.displayName=sd;var on="TooltipContent",X$=_.forwardRef((e,t)=>{const r=_D(on,e.__scopeTooltip),{forceMount:o=r.forceMount,side:n="top",...i}=e,a=jo(on,e.__scopeTooltip);return m.jsx(Gt,{present:o||a.open,children:a.disableHoverableContent?m.jsx(eS,{side:n,...i,ref:t}):m.jsx(wD,{side:n,...i,ref:t})})}),wD=_.forwardRef((e,t)=>{const r=jo(on,e.__scopeTooltip),o=ad(on,e.__scopeTooltip),n=_.useRef(null),i=Ge(t,n),[a,s]=_.useState(null),{trigger:l,onClose:u}=r,c=n.current,{onPointerInTransitChange:d}=o,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((g,h)=>{const b=g.currentTarget,y={x:g.clientX,y:g.clientY},x=ID(y,b.getBoundingClientRect()),$=kD(y,x),v=ED(h.getBoundingClientRect()),k=OD([...$,...v]);s(k),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(l&&c){const g=b=>p(b,c),h=b=>p(b,l);return l.addEventListener("pointerleave",g),c.addEventListener("pointerleave",h),()=>{l.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",h)}}},[l,c,p,f]),_.useEffect(()=>{if(a){const g=h=>{const b=h.target,y={x:h.clientX,y:h.clientY},x=l?.contains(b)||c?.contains(b),$=!TD(y,a);x?f():$&&(f(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,f]),m.jsx(eS,{...e,ref:i})}),[xD,$D]=ts(Qn,{isInside:!1}),SD=IM("TooltipContent"),eS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,children:o,"aria-label":n,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=jo(on,r),u=rs(r),{onClose:c}=l;return _.useEffect(()=>(document.addEventListener(ju,c),()=>document.removeEventListener(ju,c)),[c]),_.useEffect(()=>{if(l.trigger){const d=f=>{f.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),m.jsx(Ha,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:m.jsxs(B$,{"data-state":l.stateAttribute,...u,...s,ref:t,style:{...s.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:[m.jsx(SD,{children:o}),m.jsx(xD,{scope:r,isInside:!0,children:m.jsx(hD,{id:l.contentId,role:"tooltip",children:n||o})})]})})});X$.displayName=on;var tS="TooltipArrow",rS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=rs(r);return $D(tS,r).isInside?null:m.jsx(J$,{...n,...o,ref:t})});rS.displayName=tS;function ID(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,o,n,i)){case i:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function kD(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}function ED(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}function TD(e,t){const{x:r,y:o}=e;let n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],u=s.x,c=s.y,d=l.x,f=l.y;c>o!=f>o&&r<(d-u)*(o-c)/(f-c)+u&&(n=!n)}return n}function OD(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),ND(t)}function ND(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var PD=G$,CD=K$,jD=Y$,AD=Q$,RD=X$,zD=rS;function nS({delayDuration:e=0,...t}){return m.jsx(PD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ud({...e}){return m.jsx(nS,{children:m.jsx(CD,{"data-slot":"tooltip",...e})})}function ld({...e}){return m.jsx(jD,{"data-slot":"tooltip-trigger",...e})}function cd({className:e,sideOffset:t=0,children:r,...o}){return m.jsx(AD,{children:m.jsxs(RD,{"data-slot":"tooltip-content",sideOffset:t,className:T.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",e),...o,children:[r,m.jsx(zD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}var Ls="focusScope.autoFocusOnMount",Zs="focusScope.autoFocusOnUnmount",Bf={bubbles:!1,cancelable:!0},MD="FocusScope",dd=_.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:n,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=Sr(n),c=Sr(i),d=_.useRef(null),f=Ge(t,h=>l(h)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(o){let h=function($){if(p.paused||!s)return;const v=$.target;s.contains(v)?d.current=v:Qt(d.current,{select:!0})},b=function($){if(p.paused||!s)return;const v=$.relatedTarget;v!==null&&(s.contains(v)||Qt(d.current,{select:!0}))},y=function($){if(document.activeElement===document.body)for(const k of $)k.removedNodes.length>0&&Qt(s)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const x=new MutationObserver(y);return s&&x.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),x.disconnect()}}},[o,s,p.paused]),_.useEffect(()=>{if(s){Wf.add(p);const h=document.activeElement;if(!s.contains(h)){const y=new CustomEvent(Ls,Bf);s.addEventListener(Ls,u),s.dispatchEvent(y),y.defaultPrevented||(DD(qD(oS(s)),{select:!0}),document.activeElement===h&&Qt(s))}return()=>{s.removeEventListener(Ls,u),setTimeout(()=>{const y=new CustomEvent(Zs,Bf);s.addEventListener(Zs,c),s.dispatchEvent(y),y.defaultPrevented||Qt(h??document.body,{select:!0}),s.removeEventListener(Zs,c),Wf.remove(p)},0)}}},[s,u,c,p]);const g=_.useCallback(h=>{if(!r&&!o||p.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,y=document.activeElement;if(b&&y){const x=h.currentTarget,[$,v]=UD(x);$&&v?!h.shiftKey&&y===v?(h.preventDefault(),r&&Qt($,{select:!0})):h.shiftKey&&y===$&&(h.preventDefault(),r&&Qt(v,{select:!0})):y===x&&h.preventDefault()}},[r,o,p.paused]);return m.jsx(Ce.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})});dd.displayName=MD;function DD(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Qt(o,{select:t}),document.activeElement!==r)return}function UD(e){const t=oS(e),r=Jf(t,e),o=Jf(t.reverse(),e);return[r,o]}function oS(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Jf(e,t){for(const r of e)if(!LD(r,{upTo:t}))return r}function LD(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function ZD(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&ZD(e)&&t&&e.select()}}var Wf=FD();function FD(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Hf(e,t),e.unshift(t)},remove(t){e=Hf(e,t),e[0]?.resume()}}}function Hf(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function qD(e){return e.filter(t=>t.tagName!=="A")}var Fs=0;function iS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Gf()),document.body.insertAdjacentElement("beforeend",e[1]??Gf()),Fs++,()=>{Fs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Fs--}},[])}function Gf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Pt=function(){return Pt=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function aS(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function VD(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var si="right-scroll-bar-position",ui="width-before-scroll-bar",BD="with-scroll-bars-hidden",JD="--removed-body-scroll-bar-size";function qs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function WD(e,t){var r=D.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var HD=typeof window<"u"?_.useLayoutEffect:_.useEffect,Kf=new WeakMap;function GD(e,t){var r=WD(null,function(o){return e.forEach(function(n){return qs(n,o)})});return HD(function(){var o=Kf.get(r);if(o){var n=new Set(o),i=new Set(e),a=r.current;n.forEach(function(s){i.has(s)||qs(s,null)}),i.forEach(function(s){n.has(s)||qs(s,a)})}Kf.set(r,e)},[e]),r}function KD(e){return e}function YD(e,t){t===void 0&&(t=KD);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var a=t(i,o);return r.push(a),function(){r=r.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(s){return i(s)},filter:function(){return r}}},assignMedium:function(i){o=!0;var a=[];if(r.length){var s=r;r=[],s.forEach(i),a=r}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),r}}}};return n}function QD(e){e===void 0&&(e={});var t=YD(null);return t.options=Pt({async:!0,ssr:!1},e),t}var sS=function(e){var t=e.sideCar,r=aS(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return _.createElement(o,Pt({},r))};sS.isSideCarExport=!0;function XD(e,t){return e.useMedium(t),sS}var uS=QD(),Vs=function(){},ns=_.forwardRef(function(e,t){var r=_.useRef(null),o=_.useState({onScrollCapture:Vs,onWheelCapture:Vs,onTouchMoveCapture:Vs}),n=o[0],i=o[1],a=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,y=e.as,x=y===void 0?"div":y,$=e.gapMode,v=aS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,N=GD([r,t]),I=Pt(Pt({},v),n);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:uS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!b,lockRef:r,gapMode:$}),a?_.cloneElement(_.Children.only(s),Pt(Pt({},I),{ref:N})):_.createElement(x,Pt({},I,{className:l,ref:N}),s))});ns.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ns.classNames={fullWidth:ui,zeroRight:si};var eU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=eU();return t&&e.setAttribute("nonce",t),e}function rU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function nU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var oU=function(){var e=0,t=null;return{add:function(r){e==0&&(t=tU())&&(rU(t,r),nU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},iU=function(){var e=oU();return function(t,r){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},lS=function(){var e=iU(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},aU={left:0,top:0,right:0,gap:0},Bs=function(e){return parseInt(e||"",10)||0},sU=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[Bs(r),Bs(o),Bs(n)]},uU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return aU;var t=sU(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},lU=lS(),Br="data-scroll-locked",cU=function(e,t,r,o){var n=e.left,i=e.top,a=e.right,s=e.gap;return r===void 0&&(r="margin"),`
|
|
97
97
|
.`.concat(BD,` {
|
|
98
98
|
overflow: hidden `).concat(o,`;
|
|
99
99
|
padding-right: `).concat(s,"px ").concat(o,`;
|
|
@@ -140,4 +140,4 @@ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHid
|
|
|
140
140
|
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},MU="DialogDescriptionWarning",DU=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${OS(MU).contentName}}.`;return _.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},UU=gS,LU=yS,ZU=_S,FU=wS,qU=xS,VU=SS,BU=ES;function JU({...e}){return m.jsx(UU,{"data-slot":"dialog",...e})}function WU({...e}){return m.jsx(LU,{"data-slot":"dialog-trigger",...e})}function HU({...e}){return m.jsx(ZU,{"data-slot":"dialog-portal",...e})}function GU({className:e,...t}){return m.jsx(FU,{"data-slot":"dialog-overlay",className:T.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",e),...t})}function KU({className:e,children:t,showCloseButton:r=!0,...o}){return m.jsxs(HU,{"data-slot":"dialog-portal",children:[m.jsx(GU,{}),m.jsxs(qU,{"data-slot":"dialog-content",className:T.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",e),...o,children:[t,r&&m.jsxs(BU,{"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:[m.jsx(Eo,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function YU({className:e,...t}){return m.jsx(VU,{"data-slot":"dialog-title",className:T.cn("text-lg leading-none font-semibold",e),...t})}function QU(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a);s.displayName=i+"Context";const l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,XU(n,...t)]}function XU(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}var e6=Symbol.for("react.lazy"),qi=_[" use ".trim().toString()];function t6(e){return typeof e=="object"&&e!==null&&"then"in e}function NS(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===e6&&"_payload"in e&&t6(e._payload)}function PS(e){const t=n6(e),r=_.forwardRef((o,n)=>{let{children:i,...a}=o;NS(i)&&typeof qi=="function"&&(i=qi(i._payload));const s=_.Children.toArray(i),l=s.find(a6);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}var r6=PS("Slot");function n6(e){const t=_.forwardRef((r,o)=>{let{children:n,...i}=r;if(NS(n)&&typeof qi=="function"&&(n=qi(n._payload)),_.isValidElement(n)){const a=u6(n),s=s6(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Hc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var CS=Symbol("radix.slottable");function o6(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=CS,t}var i6=o6("Slottable");function a6(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===CS}function s6(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function u6(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var l6=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gd=l6.reduce((e,t)=>{const r=PS(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function c6(){return _j.useSyncExternalStore(d6,()=>!0,()=>!1)}function d6(){return()=>{}}var vd="Avatar",[p6]=QU(vd),[f6,jS]=p6(vd),AS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,...o}=e,[n,i]=_.useState("idle");return m.jsx(f6,{scope:r,imageLoadingStatus:n,onImageLoadingStatusChange:i,children:m.jsx(gd.span,{...o,ref:t})})});AS.displayName=vd;var RS="AvatarImage",zS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,src:o,onLoadingStatusChange:n=()=>{},...i}=e,a=jS(RS,r),s=m6(o,i),l=Sr(u=>{n(u),a.onImageLoadingStatusChange(u)});return lt(()=>{s!=="idle"&&l(s)},[s,l]),s==="loaded"?m.jsx(gd.img,{...i,ref:t,src:o}):null});zS.displayName=RS;var MS="AvatarFallback",DS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:o,...n}=e,i=jS(MS,r),[a,s]=_.useState(o===void 0);return _.useEffect(()=>{if(o!==void 0){const l=window.setTimeout(()=>s(!0),o);return()=>window.clearTimeout(l)}},[o]),a&&i.imageLoadingStatus!=="loaded"?m.jsx(gd.span,{...n,ref:t}):null});DS.displayName=MS;function tm(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function m6(e,{referrerPolicy:t,crossOrigin:r}){const o=c6(),n=_.useRef(null),i=o?(n.current||(n.current=new window.Image),n.current):null,[a,s]=_.useState(()=>tm(i,e));return lt(()=>{s(tm(i,e))},[i,e]),lt(()=>{const l=d=>()=>{s(d)};if(!i)return;const u=l("loaded"),c=l("error");return i.addEventListener("load",u),i.addEventListener("error",c),t&&(i.referrerPolicy=t),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",u),i.removeEventListener("error",c)}},[i,r,t]),a}var h6=AS,g6=zS,v6=DS;function y6({className:e,...t}){return m.jsx(h6,{"data-slot":"avatar",className:T.cn("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function b6({className:e,...t}){return m.jsx(g6,{"data-slot":"avatar-image",className:T.cn("aspect-square size-full",e),...t})}function _6({className:e,...t}){return m.jsx(v6,{"data-slot":"avatar-fallback",className:T.cn("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}const rm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,nm=T.clsx,US=(e,t)=>r=>{var o;if(t?.variants==null)return nm(e,r?.class,r?.className);const{variants:n,defaultVariants:i}=t,a=Object.keys(n).map(u=>{const c=r?.[u],d=i?.[u];if(c===null)return null;const f=rm(c)||rm(d);return n[u][f]}),s=r&&Object.entries(r).reduce((u,c)=>{let[d,f]=c;return f===void 0||(u[d]=f),u},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((u,c)=>{let{class:d,className:f,...p}=c;return Object.entries(p).every(g=>{let[h,b]=g;return Array.isArray(b)?b.includes({...i,...s}[h]):{...i,...s}[h]===b})?[...u,d,f]:u},[]);return nm(e,a,l,r?.class,r?.className)},w6=US("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"}}),$t=_.forwardRef(({className:e,variant:t,size:r,asChild:o=!1,...n},i)=>{const a=o?r6:"button";return m.jsx(a,{"data-slot":"button",className:T.cn(w6({variant:t,size:r,className:e})),ref:i,...n})});$t.displayName="Button";const ct=D.forwardRef(({children:e,tooltip:t,side:r="bottom",align:o="center",className:n,...i},a)=>m.jsxs(ud,{children:[m.jsx(ld,{asChild:!0,children:m.jsxs($t,{variant:"ghost",size:"icon",...i,className:T.cn("aui-button-icon size-6 p-1",n),ref:a,children:[m.jsx(i6,{children:e}),m.jsx("span",{className:"aui-sr-only sr-only",children:t})]})}),m.jsx(cd,{side:r,align:o,children:t})]}));ct.displayName="TooltipIconButton";const x6=e=>{const[t,r]=D.useState(void 0);return D.useEffect(()=>{if(!e){r(void 0);return}const o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o)}},[e]),t},LS=()=>{const{file:e,src:t}=L.useAssistantState(b0.useShallow(({attachment:r})=>{if(r.type!=="image")return{};if(r.file)return{file:r.file};const o=r.content?.filter(n=>n.type==="image")[0]?.image;return o?{src:o}:{}}));return x6(e)??t},$6=({src:e})=>{const[t,r]=D.useState(!1);return m.jsx("img",{src:e,alt:"Image Preview",className:t?"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:()=>r(!0)})},S6=({children:e})=>{const t=LS();return t?m.jsxs(JU,{children:[m.jsx(WU,{className:"aui-attachment-preview-trigger hover:bg-accent/50 cursor-pointer transition-colors",asChild:!0,children:e}),m.jsxs(KU,{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:[m.jsx(YU,{className:"aui-sr-only sr-only",children:"Image Attachment Preview"}),m.jsx("div",{className:"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:m.jsx($6,{src:t})})]})]}):e},I6=()=>{const e=L.useAssistantState(({attachment:r})=>r.type==="image"),t=LS();return m.jsxs(y6,{className:"aui-attachment-tile-avatar h-full w-full rounded-none",children:[m.jsx(b6,{src:t,alt:"Attachment preview",className:"aui-attachment-tile-image object-cover"}),m.jsx(_6,{delayMs:e?200:0,children:m.jsx(EN,{className:"aui-attachment-tile-fallback-icon text-muted-foreground size-8"})})]})},ZS=()=>{const t=L.useAssistantApi().attachment.source==="composer",r=L.useAssistantState(({attachment:n})=>n.type==="image"),o=L.useAssistantState(({attachment:n})=>{const i=n.type;switch(i){case"image":return"Image";case"document":return"Document";case"file":return"File";default:{const a=i;throw new Error(`Unknown attachment type: ${a}`)}}});return m.jsxs(ud,{children:[m.jsxs(L.AttachmentPrimitive.Root,{className:T.cn("aui-attachment-root relative",r&&"aui-attachment-root-composer only:[&>#attachment-tile]:size-24"),children:[m.jsx(S6,{children:m.jsx(ld,{asChild:!0,children:m.jsx("div",{className:T.cn("aui-attachment-tile bg-muted size-14 cursor-pointer overflow-hidden rounded-[14px] border transition-opacity hover:opacity-75",t&&"aui-attachment-tile-composer border-foreground/20"),role:"button",id:"attachment-tile","aria-label":`${o} attachment`,children:m.jsx(I6,{})})})}),t&&m.jsx(k6,{})]}),m.jsx(cd,{side:"top",children:m.jsx(L.AttachmentPrimitive.Name,{})})]})},k6=()=>m.jsx(L.AttachmentPrimitive.Remove,{asChild:!0,children:m.jsx(ct,{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:m.jsx(Eo,{className:"aui-attachment-remove-icon size-3 dark:stroke-[2.5px]"})})}),E6=()=>m.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:m.jsx(L.MessagePrimitive.Attachments,{components:{Attachment:ZS}})}),T6=()=>m.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:m.jsx(L.ComposerPrimitive.Attachments,{components:{Attachment:ZS}})}),O6=()=>m.jsx(L.ComposerPrimitive.AddAttachment,{asChild:!0,children:m.jsx(ct,{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:m.jsx(FN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})});function N6(e){return D.useMemo(()=>e.reduce((t,r)=>(t?.[r.language]&&!r.overrideExisting||(t={...t,[r.language]:{CodeHeader:r.Header??(()=>null),SyntaxHighlighter:r.Component??void 0}}),t),{}),[e])}const P6=()=>{const{plugins:e}=T.useElements(),t=N6(e);return m.jsx(Ws.MarkdownTextPrimitive,{remarkPlugins:[_0],className:"aui-md",components:A6,componentsByLanguage:t})},FS=D.memo(P6),C6=({language:e,code:t})=>{const o=L.useAssistantState(({message:s})=>s).status?.type==="complete",{isCopied:n,copyToClipboard:i}=j6(),a=()=>{!t||n||i(t)};return o?m.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:[m.jsx("span",{className:"aui-code-header-language lowercase [&>span]:text-xs",children:e}),m.jsxs(ct,{tooltip:"Copy",onClick:a,children:[!n&&m.jsx(Nc,{}),n&&m.jsx(nr,{})]})]}):null},j6=({copiedDuration:e=3e3}={})=>{const[t,r]=D.useState(!1);return{isCopied:t,copyToClipboard:n=>{n&&navigator.clipboard.writeText(n).then(()=>{r(!0),setTimeout(()=>r(!1),e)})}}},A6=Ws.unstable_memoizeMarkdownComponents({h1:({className:e,...t})=>m.jsx("h1",{className:T.cn("aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",e),...t}),h2:({className:e,...t})=>m.jsx("h2",{className:T.cn("aui-md-h2 mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h3:({className:e,...t})=>m.jsx("h3",{className:T.cn("aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h4:({className:e,...t})=>m.jsx("h4",{className:T.cn("aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h5:({className:e,...t})=>m.jsx("h5",{className:T.cn("aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0",e),...t}),h6:({className:e,...t})=>m.jsx("h6",{className:T.cn("aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",e),...t}),p:({className:e,...t})=>m.jsx("p",{className:T.cn("aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",e),...t}),a:({className:e,...t})=>m.jsx("a",{className:T.cn("aui-md-a text-primary font-medium underline underline-offset-4",e),...t}),blockquote:({className:e,...t})=>m.jsx("blockquote",{className:T.cn("aui-md-blockquote border-l-2 pl-6 italic",e),...t}),ul:({className:e,...t})=>m.jsx("ul",{className:T.cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2",e),...t}),ol:({className:e,...t})=>m.jsx("ol",{className:T.cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2",e),...t}),hr:({className:e,...t})=>m.jsx("hr",{className:T.cn("aui-md-hr my-5 border-b",e),...t}),table:({className:e,...t})=>m.jsx("table",{className:T.cn("aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",e),...t}),th:({className:e,...t})=>m.jsx("th",{className:T.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",e),...t}),td:({className:e,...t})=>m.jsx("td",{className:T.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",e),...t}),tr:({className:e,...t})=>m.jsx("tr",{className:T.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",e),...t}),sup:({className:e,...t})=>m.jsx("sup",{className:T.cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline",e),...t}),pre:({className:e,...t})=>m.jsx("pre",{className:T.cn("aui-md-pre text-foreground bg-muted overflow-x-auto rounded-t-none! rounded-b-lg border border-t-0 p-4",e),...t}),code:function({className:t,...r}){const o=Ws.useIsMarkdownCodeBlock();return m.jsx("code",{className:T.cn(!o&&"aui-md-inline-code bg-muted rounded border font-semibold",t),...r})},CodeHeader:C6});var is="Collapsible",[R6]=Po(is),[z6,yd]=R6(is),qS=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:o,defaultOpen:n,disabled:i,onOpenChange:a,...s}=e,[l,u]=es({prop:o,defaultProp:n??!1,onChange:a,caller:is});return m.jsx(z6,{scope:r,disabled:i,contentId:qr(),open:l,onOpenToggle:_.useCallback(()=>u(c=>!c),[u]),children:m.jsx(Ce.div,{"data-state":_d(l),"data-disabled":i?"":void 0,...s,ref:t})})});qS.displayName=is;var VS="CollapsibleTrigger",BS=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,...o}=e,n=yd(VS,r);return m.jsx(Ce.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":_d(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...o,ref:t,onClick:Oe(e.onClick,n.onOpenToggle)})});BS.displayName=VS;var bd="CollapsibleContent",JS=_.forwardRef((e,t)=>{const{forceMount:r,...o}=e,n=yd(bd,e.__scopeCollapsible);return m.jsx(Gt,{present:r||n.open,children:({present:i})=>m.jsx(M6,{...o,ref:t,present:i})})});JS.displayName=bd;var M6=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:o,children:n,...i}=e,a=yd(bd,r),[s,l]=_.useState(o),u=_.useRef(null),c=Ge(t,u),d=_.useRef(0),f=d.current,p=_.useRef(0),g=p.current,h=a.open||s,b=_.useRef(h),y=_.useRef(void 0);return _.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),lt(()=>{const x=u.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const $=x.getBoundingClientRect();d.current=$.height,p.current=$.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(o)}},[a.open,o]),m.jsx(Ce.div,{"data-state":_d(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!h,...i,ref:c,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:h&&n})});function _d(e){return e?"open":"closed"}var D6=qS;function U6({...e}){return m.jsx(D6,{"data-slot":"collapsible",...e})}function L6({...e}){return m.jsx(BS,{"data-slot":"collapsible-trigger",...e})}function Z6({...e}){return m.jsx(JS,{"data-slot":"collapsible-content",...e})}const om=200,WS=({className:e,children:t})=>{const r=D.useRef(null),[o,n]=D.useState(!1),i=L.useScrollLock(r,om),a=D.useCallback(s=>{s||i(),n(s)},[i]);return m.jsx(U6,{ref:r,open:o,onOpenChange:a,className:T.cn("aui-reasoning-root mb-4 w-full",e),style:{"--animation-duration":`${om}ms`},children:t})};WS.displayName="ReasoningRoot";const F6=({className:e})=>m.jsx("div",{className:T.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)",e)}),q6=({active:e,className:t})=>m.jsxs(L6,{className:T.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",t,e&&"shimmer"),children:[m.jsx(bN,{className:"aui-reasoning-trigger-icon size-4 shrink-0"}),m.jsxs("span",{className:"aui-reasoning-trigger-label-wrapper relative inline-block leading-none",children:[m.jsx("span",{children:"Reasoning"}),e?m.jsx("span",{"aria-hidden":!0,className:"aui-reasoning-trigger-shimmer shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",children:"Reasoning"}):null]}),m.jsx(Ei,{className:T.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")})]}),HS=({className:e,children:t,"aria-busy":r})=>m.jsxs(Z6,{className:T.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)",e),"aria-busy":r,children:[t,m.jsx(F6,{})]});HS.displayName="ReasoningContent";const GS=({className:e,children:t})=>m.jsx("div",{className:T.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",e),children:t});GS.displayName="ReasoningText";const V6=()=>m.jsx(FS,{}),B6=({children:e,startIndex:t,endIndex:r})=>{const o=L.useAssistantState(({message:n})=>{if(n.status?.type!=="running")return!1;const i=n.parts.length-1;return i<0||n.parts[i]?.type!=="reasoning"?!1:i>=t&&i<=r});return m.jsxs(WS,{children:[m.jsx(q6,{active:o}),m.jsx(HS,{"aria-busy":o,children:m.jsx(GS,{children:e})})]})},KS=D.memo(V6);KS.displayName="Reasoning";const YS=D.memo(B6);YS.displayName="ReasoningGroup";var as="Popover",[QS]=Po(as,[Qa]),Ao=Qa(),[J6,pr]=QS(as),XS=e=>{const{__scopePopover:t,children:r,open:o,defaultOpen:n,onOpenChange:i,modal:a=!1}=e,s=Ao(t),l=_.useRef(null),[u,c]=_.useState(!1),[d,f]=es({prop:o,defaultProp:n??!1,onChange:i,caller:as});return m.jsx(V$,{...s,children:m.jsx(J6,{scope:t,contentId:qr(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:_.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>c(!0),[]),onCustomAnchorRemove:_.useCallback(()=>c(!1),[]),modal:a,children:r})})};XS.displayName=as;var e0="PopoverAnchor",W6=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(e0,r),i=Ao(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=n;return _.useEffect(()=>(a(),()=>s()),[a,s]),m.jsx(id,{...i,...o,ref:t})});W6.displayName=e0;var t0="PopoverTrigger",r0=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(t0,r),i=Ao(r),a=Ge(t,n.triggerRef),s=m.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":s0(n.open),...o,ref:a,onClick:Oe(e.onClick,n.onOpenToggle)});return n.hasCustomAnchor?s:m.jsx(id,{asChild:!0,...i,children:s})});r0.displayName=t0;var wd="PopoverPortal",[H6,G6]=QS(wd,{forceMount:void 0}),n0=e=>{const{__scopePopover:t,forceMount:r,children:o,container:n}=e,i=pr(wd,t);return m.jsx(H6,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(Xa,{asChild:!0,container:n,children:o})})})};n0.displayName=wd;var an="PopoverContent",o0=_.forwardRef((e,t)=>{const r=G6(an,e.__scopePopover),{forceMount:o=r.forceMount,...n}=e,i=pr(an,e.__scopePopover);return m.jsx(Gt,{present:o||i.open,children:i.modal?m.jsx(Y6,{...n,ref:t}):m.jsx(Q6,{...n,ref:t})})});o0.displayName=an;var K6=Gc("PopoverContent.RemoveScroll"),Y6=_.forwardRef((e,t)=>{const r=pr(an,e.__scopePopover),o=_.useRef(null),n=Ge(t,o),i=_.useRef(!1);return _.useEffect(()=>{const a=o.current;if(a)return mS(a)},[]),m.jsx(pd,{as:K6,allowPinchZoom:!0,children:m.jsx(i0,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,a=>{a.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0,u=s.button===2||l;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Oe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),Q6=_.forwardRef((e,t)=>{const r=pr(an,e.__scopePopover),o=_.useRef(!1),n=_.useRef(!1);return m.jsx(i0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||r.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const a=i.target;r.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&n.current&&i.preventDefault()}})}),i0=_.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:c,...d}=e,f=pr(an,r),p=Ao(r);return iS(),m.jsx(dd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,onUnmountAutoFocus:i,children:m.jsx(Ha,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:c,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:m.jsx(B$,{"data-state":s0(f.open),role:"dialog",id:f.contentId,...p,...d,ref:t,style:{...d.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)"}})})})}),a0="PopoverClose",X6=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(a0,r);return m.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Oe(e.onClick,()=>n.onOpenChange(!1))})});X6.displayName=a0;var e2="PopoverArrow",t2=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=Ao(r);return m.jsx(J$,{...n,...o,ref:t})});t2.displayName=e2;function s0(e){return e?"open":"closed"}var r2=XS,n2=r0,o2=n0,i2=o0;function u0({...e}){return m.jsx(r2,{"data-slot":"popover",...e})}function l0({...e}){return m.jsx(n2,{"data-slot":"popover-trigger",...e})}function c0({className:e,align:t="center",sideOffset:r=4,...o}){return m.jsx(o2,{children:m.jsx(i2,{"data-slot":"popover-content",align:t,sideOffset:r,className:T.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",e),...o})})}const a2=US("flex size-5 items-center justify-center rounded-full",{variants:{status:{pending:"border border-dashed border-muted-foreground/50",running:"text-primary",complete:"text-green-600 dark:text-green-500",error:"text-destructive",approval:"text-amber-500"}},defaultVariants:{status:"pending"}});function s2(e){switch(e){case"text/markdown":return"markdown";case"text/html":return"html";case"text/css":return"css";case"application/json":return"json";case"text/javascript":return"javascript";case"text/typescript":return"typescript";case"text/python":return"python";default:return}}function u2(e,t){if(t==="json")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return e}function l2(e){return typeof e=="object"&&e!==null&&"content"in e&&Array.isArray(e.content)}function d0({status:e}){return m.jsxs("div",{className:T.cn(a2({status:e})),children:[e==="pending"&&null,e==="running"&&m.jsx(lu,{className:"size-4 animate-spin"}),e==="complete"&&m.jsx(nr,{className:"size-4"}),e==="error"&&m.jsx(Eo,{className:"size-4"}),e==="approval"&&m.jsx(lu,{className:"text-muted-foreground size-4 animate-spin"})]})}function c2({content:e}){const[t,r]=D.useState(!1),o=async n=>{n.stopPropagation(),await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)};return m.jsx("button",{onClick:o,className:"text-muted-foreground hover:bg-accent hover:text-foreground rounded p-1 transition-colors","aria-label":"Copy to clipboard",children:t?m.jsx(nr,{className:"size-4"}):m.jsx(Nc,{className:"size-4"})})}function p0({text:e,language:t,className:r}){const[o,n]=D.useState(null);return D.useEffect(()=>{t&&w0.codeToHtml(e,{lang:t,theme:"github-dark-default",rootStyle:"background-color: transparent;",transformers:[{pre(i){i.properties.class="w-full py-3 px-4 max-h-[300px] overflow-y-auto whitespace-pre-wrap text-left text-sm"}}]}).then(n)},[e,t]),o?m.jsx("div",{className:T.cn("w-full bg-slate-800/90",r),dangerouslySetInnerHTML:{__html:o}}):m.jsx("pre",{className:T.cn("w-full bg-slate-800/90 px-4 py-3 text-sm whitespace-pre-wrap text-slate-100",r),children:e})}function d2({data:e}){const t=`data:image/png;base64,${e}`;return m.jsx("div",{className:"flex items-center justify-center rounded-lg p-5",style:{backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
141
141
|
linear-gradient(135deg, #ccc 25%, transparent 25%),
|
|
142
142
|
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
|
143
|
-
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:m.jsx("img",{src:t,className:"max-h-[300px] max-w-full object-contain"})})}function p2({content:e}){return m.jsx("div",{className:"w-full",children:e.content.map((t,r)=>{switch(t.type){case"text":{const o=s2(t._meta?.["getgram.ai/mime-type"]??"text/plain"),n=u2(t.text,o);return m.jsx(p0,{text:n,language:o},r)}case"image":return m.jsx(d2,{data:t.data},r);default:return m.jsx("pre",{className:"px-4 py-3 text-sm whitespace-pre-wrap",children:JSON.stringify(t,null,2)},r)}})})}function im({title:e,content:t,defaultExpanded:r=!1,highlightSyntax:o=!0,language:n="json"}){const[i,a]=D.useState(r),s=l2(t),l=s?JSON.stringify(t,null,2):typeof t=="string"?t:JSON.stringify(t,null,2);return m.jsxs("div",{"data-slot":"tool-ui-section",className:"border-border border-t",children:[m.jsxs("button",{onClick:()=>a(!i),className:"hover:bg-accent/50 flex w-full cursor-pointer items-center justify-between px-4 py-2.5 text-left transition-colors",children:[m.jsx("span",{className:"text-muted-foreground text-sm",children:e}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(c2,{content:l}),m.jsx(J_,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",i&&"rotate-90")})]})]}),i&&m.jsx("div",{className:"border-border border-t",children:s?m.jsx(p2,{content:t}):o?m.jsx(p0,{text:l,language:n}):m.jsx("pre",{className:"text-foreground overflow-x-auto px-4 py-3 text-sm whitespace-pre-wrap",children:l})})]})}function f2({name:e,icon:t,provider:r,status:o="complete",request:n,result:i,defaultExpanded:a=!1,className:s,onApproveOnce:l,onApproveForSession:u,onDeny:c}){const d=o==="approval"&&l!==void 0&&c!==void 0,[f,p]=D.useState(a),g=n!==void 0||i!==void 0,[h,b]=D.useState("one-time"),[y,x]=D.useState(!1);D.useEffect(()=>{!d&&f&&!a&&p(!1)},[d]);const $=()=>{h==="for-session"&&u?u():l&&l()};return m.jsxs("div",{"data-slot":"tool-ui",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",s),children:[r&&m.jsxs("div",{"data-slot":"tool-ui-provider",className:T.cn("border-border flex items-center gap-2 border-b px-4 py-2.5"),children:[t?m.jsx("span",{className:"flex size-5 items-center justify-center",children:t}):m.jsx("span",{className:"bg-muted flex size-5 items-center justify-center rounded text-xs font-medium",children:r.charAt(0).toUpperCase()}),m.jsx("span",{className:"text-sm font-medium",children:r})]}),m.jsxs("button",{onClick:()=>g&&p(!f),disabled:!g,className:T.cn("flex w-full items-center gap-2 px-4 py-3 text-left",g&&"hover:bg-accent/50 cursor-pointer transition-colors"),children:[m.jsx(d0,{status:o}),m.jsx("span",{className:T.cn("flex-1 text-sm",!r&&d&&"shimmer"),children:e}),g&&m.jsx(Ei,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",f&&"rotate-180")})]}),f&&g&&m.jsxs("div",{"data-slot":"tool-ui-content",children:[n!==void 0&&m.jsx(im,{title:"Arguments",content:n,highlightSyntax:!0,language:"json"}),i!==void 0&&m.jsx(im,{title:"Output",content:i,highlightSyntax:!0,language:"json"})]}),d&&m.jsxs("div",{"data-slot":"tool-ui-approval-actions",className:"border-border flex items-center justify-end gap-2 border-t px-4 py-3",children:[m.jsx("div",{children:m.jsx("span",{className:"text-muted-foreground text-sm",children:"This tool requires approval"})}),m.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[m.jsxs($t,{variant:"outline",size:"sm",onClick:c,className:"text-destructive hover:bg-destructive/10",children:[m.jsx(Eo,{className:"mr-1 size-3"}),"Deny"]}),m.jsxs("div",{className:"flex items-center",children:[m.jsxs($t,{variant:"default",size:"sm",onClick:$,className:"flex cursor-pointer justify-between gap-1 rounded-r-none bg-emerald-600 hover:bg-emerald-700",children:[m.jsx(nr,{className:"mr-1 size-3"}),m.jsx("span",{className:"min-w-[110px]",children:h==="one-time"?"Approve this time":"Approve always"})]}),m.jsxs(u0,{open:y,onOpenChange:x,children:[m.jsx(l0,{asChild:!0,children:m.jsx($t,{variant:"default",size:"sm",className:"cursor-pointer rounded-l-none border-l border-emerald-700 bg-emerald-600 px-2 hover:bg-emerald-700",children:m.jsx(Ei,{className:"size-3"})})}),m.jsxs(c0,{align:"end",className:"w-64 p-1",sideOffset:4,children:[m.jsxs("button",{onClick:()=>{b("one-time"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(nr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="one-time"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve only once"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"You'll be asked again next time"})]})]}),u&&m.jsxs("button",{onClick:()=>{b("for-session"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(nr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="for-session"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve always"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"Trust this tool for the session"})]})]})]})]})]})]})]})]})}function m2({title:e,icon:t,status:r="complete",defaultExpanded:o=!1,children:n,className:i}){const[a,s]=D.useState(o);return m.jsxs("div",{"data-slot":"tool-ui-group",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",i),children:[m.jsxs("button",{onClick:()=>s(!a),className:"hover:bg-accent/50 flex w-full items-center gap-2 px-4 py-3 text-left transition-colors",children:[t||m.jsx(d0,{status:r==="running"?"running":"complete"}),m.jsx("span",{className:T.cn("flex-1 text-sm font-medium",r==="running"&&"shimmer"),children:e}),m.jsx(Ei,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",a&&"rotate-180")})]}),a&&m.jsx("div",{"data-slot":"tool-ui-group-content",className:"border-border border-t",children:n})]})}const h2=({toolName:e,toolCallId:t,status:r,result:o,args:n})=>{const{pendingApprovals:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l}=B_(),u=i.get(t),d=L.useAssistantState(({message:x})=>x).parts.filter(x=>x.type==="tool-call"),f=d.findIndex(x=>x.toolName===e),p=()=>{s(t)},g=()=>{a(e),s(t)},h=()=>{l(t)},b=()=>u?"approval":r.type==="incomplete"?"error":r.type==="complete"?o&&typeof o=="object"&&"isError"in o&&o.isError?"error":"complete":"running",y=()=>{if(o!==void 0)return typeof o=="object"&&o!==null&&"content"in o&&Array.isArray(o.content)||typeof o=="string",o};return m.jsx("div",{className:T.cn("aui-tool-fallback-root flex w-full flex-col",f!==-1&&f!==d.length-1&&"border-b"),children:m.jsx(f2,{name:e,status:b(),request:n,result:y(),onApproveOnce:u?p:void 0,onApproveForSession:u?g:void 0,onDeny:u?h:void 0,className:"rounded-none border-0"})})},xd=()=>{const{config:e}=T.useElements(),t=e.theme??{};return D.useMemo(()=>{const{colorScheme:r="light"}=t;return{className:r==="dark"||r==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])},or=[.23,1,.32,1];function g2(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const v2=({children:e})=>{const t=L.useAssistantState(({message:s})=>s).parts,r=t.filter(s=>s.type==="tool-call"),o=r.some(s=>s.status?.type==="running"),{config:n}=T.useElements(),i=n.tools?.expandToolGroupsByDefault??!1,a=D.useMemo(()=>{const s=t.filter(l=>l.type==="tool-call");return s.length===0?"No tools called":s.length===1?`Calling ${g2(s[0].toolName)}...`:o?`Calling ${s.length} tools...`:`Executed ${s.length} tools`},[t,o]);return n.tools?.components?.[r[0]?.toolName]?e:r.length===1?m.jsx("div",{className:T.cn("my-4 w-full max-w-xl"),children:m.jsx("div",{className:"border-border bg-card overflow-hidden rounded-lg border",children:e})}):m.jsx("div",{className:"my-4 w-full max-w-xl",children:m.jsx(m2,{title:a,status:o?"running":"complete",defaultExpanded:i,children:e})})},y2=()=>m.jsxs("div",{style:{backgroundColor:"#fef3c7",border:"1px solid #f59e0b",borderRadius:"6px",padding:"12px 16px",margin:"8px",fontSize:"14px",color:"#92400e"},children:[m.jsx("strong",{children:"Warning:"})," You are using an API key directly in the client. Please"," ",m.jsx("a",{href:"https://github.com/speakeasy-api/gram/tree/main/elements#setting-up-your-backend",target:"_blank",rel:"noopener noreferrer",style:{color:"#b45309",textDecoration:"underline"},children:"set up a session endpoint"})," ","before deploying to production."]}),$d=()=>{const e=xd(),t=T.useDensity(),{config:r}=T.useElements(),o=r.components??{},n=r.api&&"UNSAFE_apiKey"in r.api;return m.jsx(Zt.LazyMotion,{features:Zt.domAnimation,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",children:m.jsx(L.ThreadPrimitive.Root,{className:T.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",e.className),children:m.jsxs(L.ThreadPrimitive.Viewport,{className:T.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",t("p-lg")),children:[m.jsx(L.ThreadPrimitive.If,{empty:!0,children:o.ThreadWelcome?m.jsx(o.ThreadWelcome,{}):m.jsx(_2,{})}),n&&m.jsx(y2,{}),m.jsx(L.ThreadPrimitive.Messages,{components:{UserMessage:o.UserMessage??O2,EditComposer:o.EditComposer??P2,AssistantMessage:o.AssistantMessage??k2}}),m.jsx(L.ThreadPrimitive.If,{empty:!1,children:m.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),m.jsx(x2,{})]})})})})},b2=()=>m.jsx(L.ThreadPrimitive.ScrollToBottom,{asChild:!0,children:m.jsx(ct,{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:m.jsx(hN,{})})}),_2=()=>{const{config:e}=T.useElements(),t=T.useDensity(),{title:r,subtitle:o}=e.welcome??{},n=e.variant==="standalone";return m.jsxs("div",{className:T.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",n?"items-center justify-center":"",t("gap-lg")),children:[m.jsx("div",{className:T.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:m.jsxs("div",{className:T.cn("aui-thread-welcome-message flex flex-col",n?"items-center text-center":"size-full justify-start",t("gap-sm"),!n&&t("py-md")),children:[m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:or},className:T.cn("aui-thread-welcome-message-motion-1 text-foreground font-semibold",t("text-title")),children:r}),m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:or},className:T.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",t("text-subtitle")),children:o})]})}),m.jsx(w2,{})]})},w2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.welcome?.suggestions??[],n=e.variant==="standalone";return o.length===0?null:m.jsx("div",{className:T.cn("aui-thread-welcome-suggestions w-full",r("gap-md"),r("py-lg"),n?"flex flex-wrap items-center justify-center":o.length===1?"flex":"grid max-w-fit @md:grid-cols-2"),children:o.map((i,a)=>m.jsx(Lt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:or},className:T.cn("aui-thread-welcome-suggestion-display",!n&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:m.jsx(L.ThreadPrimitive.Suggestion,{prompt:i.action,send:!0,asChild:!0,children:m.jsxs($t,{variant:"ghost",className:T.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",r("text-base"),n?`flex-row items-center ${r("gap-sm")} ${r("px-md")} ${r("py-sm")} ${t("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${r("gap-sm")} ${r("px-lg")} ${r("py-md")} ${t("xl")}`),"aria-label":i.action,children:[m.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-foreground text-sm font-medium",children:i.title}),m.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:i.label})]})})},`suggested-action-${i.title}-${a}`))})},x2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.composer??{placeholder:"Send a message...",attachments:!0},n=e.components??{};return n.Composer?m.jsx(n.Composer,{}):m.jsxs("div",{className:T.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",r("gap-md"),r("py-md"),t("xl")),children:[m.jsx(b2,{}),m.jsxs(L.ComposerPrimitive.Root,{className:T.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",t("xl")),children:[o.attachments&&m.jsx(T6,{}),m.jsx(L.ComposerPrimitive.Input,{placeholder:o.placeholder,className:T.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",r("h-input"),r("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),m.jsx(S2,{})]})]})},$2=()=>{const{model:e,setModel:t}=T.useElements(),[r,o]=D.useState(!1),[n,i]=D.useState(!1),a=D.useRef(null),s=D.useRef(0),l=D.useRef(!1);D.useEffect(()=>{r&&!l.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),l.current=r},[r]),D.useEffect(()=>{r&&i(!1)},[r]);const u=c=>{s.current=c.currentTarget.scrollTop};return m.jsx(nS,{children:m.jsxs(ud,{open:n&&!r,onOpenChange:i,children:[m.jsxs(u0,{open:r,onOpenChange:o,children:[m.jsx(ld,{asChild:!0,children:m.jsx(l0,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"icon","data-state":r?"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:m.jsx(JN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),m.jsx(c0,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:m.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:u,children:Oc.map(c=>m.jsxs($t,{onClick:()=>{t(c)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[c===e?m.jsx("div",{children:m.jsx(nr,{className:"size-4 text-emerald-500"})}):m.jsx("div",{className:"size-4",children:" "}),c]},c))})})]}),m.jsx(cd,{side:"bottom",align:"start",children:"Model Settings"})]})})},S2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=e.composer??{attachments:!0};return m.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[m.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[r.attachments?m.jsx(O6,{}):m.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),e.model?.showModelPicker&&!e.languageModel&&m.jsx($2,{})]}),m.jsx(L.ThreadPrimitive.If,{running:!1,children:m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx(ct,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:T.cn("aui-composer-send size-[34px] p-1",t("full")),"aria-label":"Send message",children:m.jsx(vN,{className:"aui-composer-send-icon size-5"})})})}),m.jsx(L.ThreadPrimitive.If,{running:!0,children:m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{type:"button",variant:"default",size:"icon",className:T.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",t("full")),"aria-label":"Stop generating",children:m.jsx(HN,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},I2=()=>m.jsx(L.MessagePrimitive.Error,{children:m.jsx(L.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:m.jsx(L.ErrorPrimitive.Message,{className:"aui-message-error-message line-clamp-2"})})}),k2=()=>{const{config:e}=T.useElements(),t=e.tools??{},r=e.components??{};return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.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:[m.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[m.jsx(L.MessagePrimitive.Parts,{components:{Text:r.Text??FS,Image:r.Image??E2,tools:{by_name:t.components,Fallback:r.ToolFallback??h2},Reasoning:r.Reasoning??KS,ReasoningGroup:r.ReasoningGroup??YS,ToolGroup:r.ToolGroup??v2}}),m.jsx(I2,{})]}),m.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[m.jsx(f0,{}),m.jsx(T2,{})]})]})})},E2=e=>m.jsx("img",{src:e.image}),T2=()=>m.jsxs(L.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:[m.jsx(L.ActionBarPrimitive.Copy,{asChild:!0,children:m.jsxs(ct,{tooltip:"Copy",children:[m.jsx(L.MessagePrimitive.If,{copied:!0,children:m.jsx(nr,{})}),m.jsx(L.MessagePrimitive.If,{copied:!1,children:m.jsx(Nc,{})})]})}),m.jsx(L.ActionBarPrimitive.Reload,{asChild:!0,children:m.jsx(ct,{tooltip:"Refresh",children:m.jsx(VN,{})})})]}),O2=()=>{const e=T.useRadius();return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.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:[m.jsx(E6,{}),m.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[m.jsx("div",{className:T.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",e("xl")),children:m.jsx(L.MessagePrimitive.Parts,{})}),m.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:m.jsx(N2,{})})]}),m.jsx(f0,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},N2=()=>m.jsx(L.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:m.jsx(L.ActionBarPrimitive.Edit,{asChild:!0,children:m.jsx(ct,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:m.jsx(LN,{})})})}),P2=()=>m.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:m.jsxs(L.ComposerPrimitive.Root,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[m.jsx(L.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}),m.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx($t,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),f0=({className:e,...t})=>m.jsxs(L.BranchPickerPrimitive.Root,{hideWhenSingleBranch:!0,className:T.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",e),...t,children:[m.jsx(L.BranchPickerPrimitive.Previous,{asChild:!0,children:m.jsx(ct,{tooltip:"Previous",children:m.jsx($N,{})})}),m.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[m.jsx(L.BranchPickerPrimitive.Number,{})," / ",m.jsx(L.BranchPickerPrimitive.Count,{})]}),m.jsx(L.BranchPickerPrimitive.Next,{asChild:!0,children:m.jsx(ct,{tooltip:"Next",children:m.jsx(J_,{})})})]}),m0=()=>{const{config:e,isExpanded:t,setIsExpanded:r}=T.useElements(),o=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:r,defaultExpanded:o}},C2={layout:{duration:.25,ease:or}},j2=()=>{const{config:e}=T.useElements(),t=xd(),r=T.useRadius(),o=T.useDensity(),[n,i]=D.useState(e.modal?.defaultOpen??!1),{expandable:a,isExpanded:s,setIsExpanded:l}=m0(),u=e.modal?.title,c=e.modal?.icon,d=e.modal?.position??"bottom-right",f=A2(d),p=D.useMemo(()=>e.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[e.modal?.dimensions?.default]),g=D.useMemo(()=>e.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[e.modal?.dimensions?.expanded]),b=L.useAssistantState(({thread:v})=>v).messages.some(v=>v.status?.type==="running"),y=s?g.width:p.width,x=s?g.height:p.height,$=p.maxHeight;return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",transition:C2,children:m.jsx("div",{className:T.cn("aui-root aui-modal-anchor fixed z-10",f,t.className,r("lg"),n&&"shadow-xl"),children:m.jsx(Zt.AnimatePresence,{mode:"wait",children:n?m.jsxs(Lt.div,{layout:!0,layoutId:"chat-container",className:T.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",r("lg")),initial:!1,style:{originX:d.includes("left")?0:1,originY:d.includes("top")?0:1,width:y,height:x,maxHeight:$},children:[m.jsxs(Lt.div,{className:T.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",o("h-header"),o("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:or},children:[m.jsx("div",{className:T.cn("flex min-w-0 items-center"),children:m.jsxs("span",{className:T.cn("text-md flex items-center gap-2 truncate font-medium",b&&"shimmer"),children:[m.jsx("span",{className:"truncate",children:u}),b&&m.jsx(lu,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),m.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?m.jsx("button",{type:"button",onClick:()=>l(v=>!v),className:T.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":s,"aria-label":s?"Collapse assistant":"Expand assistant",children:s?m.jsx(AN,{strokeWidth:2,className:"size-3.5 rotate-90"}):m.jsx(NN,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,m.jsx("button",{onClick:()=>{i(!1),l(!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:m.jsx(Eo,{className:"size-4.5"})})]})]}),m.jsx(Lt.div,{className:"aui-modal-thread w-full flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:or},children:m.jsx($d,{})})]},"chat"):m.jsx(Lt.button,{layout:!0,layoutId:"chat-container",onClick:()=>i(!0),className:T.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",r("full")),initial:!1,"aria-label":`Open ${u}`,style:{originX:1,originY:1},children:m.jsx(Lt.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:or},className:"flex size-full items-center justify-center",children:c?c("closed"):m.jsx(CN,{className:"size-6"})})},"button")})})})})};function A2(e){switch(e){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:T.assertNever(e)}}const R2=()=>{const{config:e}=T.useElements(),t=xd(),r=e.sidecar??{},{title:o,dimensions:n}=r,{isExpanded:i,setIsExpanded:a}=m0(),l=L.useAssistantState(({thread:u})=>u).messages.some(u=>u.status?.type==="running");return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsxs(Lt.div,{initial:{width:n?.default?.width??"400px",height:n?.default?.height??"100vh"},animate:{width:i?n?.expanded?.width??"800px":n?.default?.width??"400px",height:i?n?.expanded?.height??"100%":n?.default?.height??"100vh"},transition:{duration:.3,ease:or},className:T.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",t.className),children:[m.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[m.jsx("span",{className:T.cn("flex items-center gap-2 text-sm font-medium",l&&"shimmer"),children:o}),m.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:m.jsx(ct,{tooltip:i?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(u=>!u),children:i?m.jsx(zN,{className:"size-4.5"}):m.jsx(DN,{className:"size-4.5"})})})]}),m.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:m.jsx($d,{})})]})})},z2=()=>{const{config:e}=T.useElements();switch(e.variant){case"standalone":return m.jsx($d,{});case"sidecar":return m.jsx(R2,{});case"widget":return m.jsx(j2,{});default:T.assertNever(e.variant)}};exports.useGramElements=T.useElements;exports.Chat=z2;exports.GramElementsProvider=wM;exports.MODELS=Oc;exports.defineFrontendTool=pN;
|
|
143
|
+
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:m.jsx("img",{src:t,className:"max-h-[300px] max-w-full object-contain"})})}function p2({content:e}){return m.jsx("div",{className:"w-full",children:e.content.map((t,r)=>{switch(t.type){case"text":{const o=s2(t._meta?.["getgram.ai/mime-type"]??"text/plain"),n=u2(t.text,o);return m.jsx(p0,{text:n,language:o},r)}case"image":return m.jsx(d2,{data:t.data},r);default:return m.jsx("pre",{className:"px-4 py-3 text-sm whitespace-pre-wrap",children:JSON.stringify(t,null,2)},r)}})})}function im({title:e,content:t,defaultExpanded:r=!1,highlightSyntax:o=!0,language:n="json"}){const[i,a]=D.useState(r),s=l2(t),l=s?JSON.stringify(t,null,2):typeof t=="string"?t:JSON.stringify(t,null,2);return m.jsxs("div",{"data-slot":"tool-ui-section",className:"border-border border-t",children:[m.jsxs("button",{onClick:()=>a(!i),className:"hover:bg-accent/50 flex w-full cursor-pointer items-center justify-between px-4 py-2.5 text-left transition-colors",children:[m.jsx("span",{className:"text-muted-foreground text-sm",children:e}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(c2,{content:l}),m.jsx(J_,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",i&&"rotate-90")})]})]}),i&&m.jsx("div",{className:"border-border border-t",children:s?m.jsx(p2,{content:t}):o?m.jsx(p0,{text:l,language:n}):m.jsx("pre",{className:"text-foreground overflow-x-auto px-4 py-3 text-sm whitespace-pre-wrap",children:l})})]})}function f2({name:e,icon:t,provider:r,status:o="complete",request:n,result:i,defaultExpanded:a=!1,className:s,onApproveOnce:l,onApproveForSession:u,onDeny:c}){const d=o==="approval"&&l!==void 0&&c!==void 0,[f,p]=D.useState(a),g=n!==void 0||i!==void 0,[h,b]=D.useState("one-time"),[y,x]=D.useState(!1);D.useEffect(()=>{!d&&f&&!a&&p(!1)},[d]);const $=()=>{h==="for-session"&&u?u():l&&l()};return m.jsxs("div",{"data-slot":"tool-ui",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",s),children:[r&&m.jsxs("div",{"data-slot":"tool-ui-provider",className:T.cn("border-border flex items-center gap-2 border-b px-4 py-2.5"),children:[t?m.jsx("span",{className:"flex size-5 items-center justify-center",children:t}):m.jsx("span",{className:"bg-muted flex size-5 items-center justify-center rounded text-xs font-medium",children:r.charAt(0).toUpperCase()}),m.jsx("span",{className:"text-sm font-medium",children:r})]}),m.jsxs("button",{onClick:()=>g&&p(!f),disabled:!g,className:T.cn("flex w-full items-center gap-2 px-4 py-3 text-left",g&&"hover:bg-accent/50 cursor-pointer transition-colors"),children:[m.jsx(d0,{status:o}),m.jsx("span",{className:T.cn("flex-1 text-sm",!r&&d&&"shimmer"),children:e}),g&&m.jsx(Ei,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",f&&"rotate-180")})]}),f&&g&&m.jsxs("div",{"data-slot":"tool-ui-content",children:[n!==void 0&&m.jsx(im,{title:"Arguments",content:n,highlightSyntax:!0,language:"json"}),i!==void 0&&m.jsx(im,{title:"Output",content:i,highlightSyntax:!0,language:"json"})]}),d&&m.jsxs("div",{"data-slot":"tool-ui-approval-actions",className:"border-border flex items-center justify-end gap-2 border-t px-4 py-3",children:[m.jsx("div",{children:m.jsx("span",{className:"text-muted-foreground text-sm",children:"This tool requires approval"})}),m.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[m.jsxs($t,{variant:"outline",size:"sm",onClick:c,className:"text-destructive hover:bg-destructive/10",children:[m.jsx(Eo,{className:"mr-1 size-3"}),"Deny"]}),m.jsxs("div",{className:"flex items-center",children:[m.jsxs($t,{variant:"default",size:"sm",onClick:$,className:"flex cursor-pointer justify-between gap-1 rounded-r-none bg-emerald-600 hover:bg-emerald-700",children:[m.jsx(nr,{className:"mr-1 size-3"}),m.jsx("span",{className:"min-w-[110px]",children:h==="one-time"?"Approve this time":"Approve always"})]}),m.jsxs(u0,{open:y,onOpenChange:x,children:[m.jsx(l0,{asChild:!0,children:m.jsx($t,{variant:"default",size:"sm",className:"cursor-pointer rounded-l-none border-l border-emerald-700 bg-emerald-600 px-2 hover:bg-emerald-700",children:m.jsx(Ei,{className:"size-3"})})}),m.jsxs(c0,{align:"end",className:"w-64 p-1",sideOffset:4,children:[m.jsxs("button",{onClick:()=>{b("one-time"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(nr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="one-time"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve only once"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"You'll be asked again next time"})]})]}),u&&m.jsxs("button",{onClick:()=>{b("for-session"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(nr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="for-session"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve always"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"Trust this tool for the session"})]})]})]})]})]})]})]})]})}function m2({title:e,icon:t,status:r="complete",defaultExpanded:o=!1,children:n,className:i}){const[a,s]=D.useState(o);return m.jsxs("div",{"data-slot":"tool-ui-group",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",i),children:[m.jsxs("button",{onClick:()=>s(!a),className:"hover:bg-accent/50 flex w-full items-center gap-2 px-4 py-3 text-left transition-colors",children:[t||m.jsx(d0,{status:r==="running"?"running":"complete"}),m.jsx("span",{className:T.cn("flex-1 text-sm font-medium",r==="running"&&"shimmer"),children:e}),m.jsx(Ei,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",a&&"rotate-180")})]}),a&&m.jsx("div",{"data-slot":"tool-ui-group-content",className:"border-border border-t",children:n})]})}const h2=({toolName:e,toolCallId:t,status:r,result:o,args:n})=>{const{pendingApprovals:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l}=B_(),u=i.get(t),d=L.useAssistantState(({message:x})=>x).parts.filter(x=>x.type==="tool-call"),f=d.findIndex(x=>x.toolName===e),p=()=>{s(t)},g=()=>{a(e),s(t)},h=()=>{l(t)},b=()=>u?"approval":r.type==="incomplete"?"error":r.type==="complete"?o&&typeof o=="object"&&"isError"in o&&o.isError?"error":"complete":"running",y=()=>{if(o!==void 0)return typeof o=="object"&&o!==null&&"content"in o&&Array.isArray(o.content)||typeof o=="string",o};return m.jsx("div",{className:T.cn("aui-tool-fallback-root flex w-full flex-col",f!==-1&&f!==d.length-1&&"border-b"),children:m.jsx(f2,{name:e,status:b(),request:n,result:y(),onApproveOnce:u?p:void 0,onApproveForSession:u?g:void 0,onDeny:u?h:void 0,className:"rounded-none border-0"})})},xd=()=>{const{config:e}=T.useElements(),t=e.theme??{};return D.useMemo(()=>{const{colorScheme:r="light"}=t;return{className:r==="dark"||r==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])},or=[.23,1,.32,1];function g2(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const v2=({children:e})=>{const t=L.useAssistantState(({message:s})=>s).parts,r=t.filter(s=>s.type==="tool-call"),o=r.some(s=>s.status?.type==="running"),{config:n}=T.useElements(),i=n.tools?.expandToolGroupsByDefault??!1,a=D.useMemo(()=>{const s=t.filter(l=>l.type==="tool-call");return s.length===0?"No tools called":s.length===1?`Calling ${g2(s[0].toolName)}...`:o?`Calling ${s.length} tools...`:`Executed ${s.length} tools`},[t,o]);return n.tools?.components?.[r[0]?.toolName]?e:r.length===1?m.jsx("div",{className:T.cn("my-4 w-full max-w-xl"),children:m.jsx("div",{className:"border-border bg-card overflow-hidden rounded-lg border",children:e})}):m.jsx("div",{className:"my-4 w-full max-w-xl",children:m.jsx(m2,{title:a,status:o?"running":"complete",defaultExpanded:i,children:e})})},y2=()=>m.jsxs("div",{className:"m-2 rounded-md border border-amber-500 bg-amber-100 px-4 py-3 text-sm text-amber-800 dark:border-amber-600 dark:bg-amber-900/30 dark:text-amber-200",children:[m.jsx("strong",{children:"Warning:"})," You are using an API key directly in the client. Please"," ",m.jsx("a",{href:"https://github.com/speakeasy-api/gram/tree/main/elements#setting-up-your-backend",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-800 dark:text-amber-300 dark:hover:text-amber-200",children:"set up a session endpoint"})," ","before deploying to production."]}),$d=()=>{const e=xd(),t=T.useDensity(),{config:r}=T.useElements(),o=r.components??{},n=r.api&&"UNSAFE_apiKey"in r.api;return m.jsx(Zt.LazyMotion,{features:Zt.domAnimation,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",children:m.jsx(L.ThreadPrimitive.Root,{className:T.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",e.className),children:m.jsxs(L.ThreadPrimitive.Viewport,{className:T.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",t("p-lg")),children:[m.jsx(L.ThreadPrimitive.If,{empty:!0,children:o.ThreadWelcome?m.jsx(o.ThreadWelcome,{}):m.jsx(_2,{})}),n&&m.jsx(y2,{}),m.jsx(L.ThreadPrimitive.Messages,{components:{UserMessage:o.UserMessage??O2,EditComposer:o.EditComposer??P2,AssistantMessage:o.AssistantMessage??k2}}),m.jsx(L.ThreadPrimitive.If,{empty:!1,children:m.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),m.jsx(x2,{})]})})})})},b2=()=>m.jsx(L.ThreadPrimitive.ScrollToBottom,{asChild:!0,children:m.jsx(ct,{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:m.jsx(hN,{})})}),_2=()=>{const{config:e}=T.useElements(),t=T.useDensity(),{title:r,subtitle:o}=e.welcome??{},n=e.variant==="standalone";return m.jsxs("div",{className:T.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",n?"items-center justify-center":"",t("gap-lg")),children:[m.jsx("div",{className:T.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:m.jsxs("div",{className:T.cn("aui-thread-welcome-message flex flex-col",n?"items-center text-center":"size-full justify-start",t("gap-sm"),!n&&t("py-md")),children:[m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:or},className:T.cn("aui-thread-welcome-message-motion-1 text-foreground font-semibold",t("text-title")),children:r}),m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:or},className:T.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",t("text-subtitle")),children:o})]})}),m.jsx(w2,{})]})},w2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.welcome?.suggestions??[],n=e.variant==="standalone";return o.length===0?null:m.jsx("div",{className:T.cn("aui-thread-welcome-suggestions w-full",r("gap-md"),r("py-lg"),n?"flex flex-wrap items-center justify-center":o.length===1?"flex":"grid max-w-fit @md:grid-cols-2"),children:o.map((i,a)=>m.jsx(Lt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:or},className:T.cn("aui-thread-welcome-suggestion-display",!n&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:m.jsx(L.ThreadPrimitive.Suggestion,{prompt:i.action,send:!0,asChild:!0,children:m.jsxs($t,{variant:"ghost",className:T.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",r("text-base"),n?`flex-row items-center ${r("gap-sm")} ${r("px-md")} ${r("py-sm")} ${t("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${r("gap-sm")} ${r("px-lg")} ${r("py-md")} ${t("xl")}`),"aria-label":i.action,children:[m.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-foreground text-sm font-medium",children:i.title}),m.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:i.label})]})})},`suggested-action-${i.title}-${a}`))})},x2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.composer??{placeholder:"Send a message...",attachments:!0},n=e.components??{};return n.Composer?m.jsx(n.Composer,{}):m.jsxs("div",{className:T.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",r("gap-md"),r("py-md"),t("xl")),children:[m.jsx(b2,{}),m.jsxs(L.ComposerPrimitive.Root,{className:T.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",t("xl")),children:[o.attachments&&m.jsx(T6,{}),m.jsx(L.ComposerPrimitive.Input,{placeholder:o.placeholder,className:T.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",r("h-input"),r("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),m.jsx(S2,{})]})]})},$2=()=>{const{model:e,setModel:t}=T.useElements(),[r,o]=D.useState(!1),[n,i]=D.useState(!1),a=D.useRef(null),s=D.useRef(0),l=D.useRef(!1);D.useEffect(()=>{r&&!l.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),l.current=r},[r]),D.useEffect(()=>{r&&i(!1)},[r]);const u=c=>{s.current=c.currentTarget.scrollTop};return m.jsx(nS,{children:m.jsxs(ud,{open:n&&!r,onOpenChange:i,children:[m.jsxs(u0,{open:r,onOpenChange:o,children:[m.jsx(ld,{asChild:!0,children:m.jsx(l0,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"icon","data-state":r?"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:m.jsx(JN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),m.jsx(c0,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:m.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:u,children:Oc.map(c=>m.jsxs($t,{onClick:()=>{t(c)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[c===e?m.jsx("div",{children:m.jsx(nr,{className:"size-4 text-emerald-500"})}):m.jsx("div",{className:"size-4",children:" "}),c]},c))})})]}),m.jsx(cd,{side:"bottom",align:"start",children:"Model Settings"})]})})},S2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=e.composer??{attachments:!0};return m.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[m.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[r.attachments?m.jsx(O6,{}):m.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),e.model?.showModelPicker&&!e.languageModel&&m.jsx($2,{})]}),m.jsx(L.ThreadPrimitive.If,{running:!1,children:m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx(ct,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:T.cn("aui-composer-send size-[34px] p-1",t("full")),"aria-label":"Send message",children:m.jsx(vN,{className:"aui-composer-send-icon size-5"})})})}),m.jsx(L.ThreadPrimitive.If,{running:!0,children:m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{type:"button",variant:"default",size:"icon",className:T.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",t("full")),"aria-label":"Stop generating",children:m.jsx(HN,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},I2=()=>m.jsx(L.MessagePrimitive.Error,{children:m.jsx(L.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:m.jsx(L.ErrorPrimitive.Message,{className:"aui-message-error-message line-clamp-2"})})}),k2=()=>{const{config:e}=T.useElements(),t=e.tools??{},r=e.components??{};return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.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:[m.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[m.jsx(L.MessagePrimitive.Parts,{components:{Text:r.Text??FS,Image:r.Image??E2,tools:{by_name:t.components,Fallback:r.ToolFallback??h2},Reasoning:r.Reasoning??KS,ReasoningGroup:r.ReasoningGroup??YS,ToolGroup:r.ToolGroup??v2}}),m.jsx(I2,{})]}),m.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[m.jsx(f0,{}),m.jsx(T2,{})]})]})})},E2=e=>m.jsx("img",{src:e.image}),T2=()=>m.jsxs(L.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:[m.jsx(L.ActionBarPrimitive.Copy,{asChild:!0,children:m.jsxs(ct,{tooltip:"Copy",children:[m.jsx(L.MessagePrimitive.If,{copied:!0,children:m.jsx(nr,{})}),m.jsx(L.MessagePrimitive.If,{copied:!1,children:m.jsx(Nc,{})})]})}),m.jsx(L.ActionBarPrimitive.Reload,{asChild:!0,children:m.jsx(ct,{tooltip:"Refresh",children:m.jsx(VN,{})})})]}),O2=()=>{const e=T.useRadius();return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.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:[m.jsx(E6,{}),m.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[m.jsx("div",{className:T.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",e("xl")),children:m.jsx(L.MessagePrimitive.Parts,{})}),m.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:m.jsx(N2,{})})]}),m.jsx(f0,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},N2=()=>m.jsx(L.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:m.jsx(L.ActionBarPrimitive.Edit,{asChild:!0,children:m.jsx(ct,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:m.jsx(LN,{})})})}),P2=()=>m.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:m.jsxs(L.ComposerPrimitive.Root,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[m.jsx(L.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}),m.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx($t,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),f0=({className:e,...t})=>m.jsxs(L.BranchPickerPrimitive.Root,{hideWhenSingleBranch:!0,className:T.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",e),...t,children:[m.jsx(L.BranchPickerPrimitive.Previous,{asChild:!0,children:m.jsx(ct,{tooltip:"Previous",children:m.jsx($N,{})})}),m.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[m.jsx(L.BranchPickerPrimitive.Number,{})," / ",m.jsx(L.BranchPickerPrimitive.Count,{})]}),m.jsx(L.BranchPickerPrimitive.Next,{asChild:!0,children:m.jsx(ct,{tooltip:"Next",children:m.jsx(J_,{})})})]}),m0=()=>{const{config:e,isExpanded:t,setIsExpanded:r}=T.useElements(),o=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:r,defaultExpanded:o}},C2={layout:{duration:.25,ease:or}},j2=()=>{const{config:e}=T.useElements(),t=xd(),r=T.useRadius(),o=T.useDensity(),[n,i]=D.useState(e.modal?.defaultOpen??!1),{expandable:a,isExpanded:s,setIsExpanded:l}=m0(),u=e.modal?.title,c=e.modal?.icon,d=e.modal?.position??"bottom-right",f=A2(d),p=D.useMemo(()=>e.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[e.modal?.dimensions?.default]),g=D.useMemo(()=>e.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[e.modal?.dimensions?.expanded]),b=L.useAssistantState(({thread:v})=>v).messages.some(v=>v.status?.type==="running"),y=s?g.width:p.width,x=s?g.height:p.height,$=p.maxHeight;return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",transition:C2,children:m.jsx("div",{className:T.cn("aui-root aui-modal-anchor fixed z-10",f,t.className,r("lg"),n&&"shadow-xl"),children:m.jsx(Zt.AnimatePresence,{mode:"wait",children:n?m.jsxs(Lt.div,{layout:!0,layoutId:"chat-container",className:T.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",r("lg")),initial:!1,style:{originX:d.includes("left")?0:1,originY:d.includes("top")?0:1,width:y,height:x,maxHeight:$},children:[m.jsxs(Lt.div,{className:T.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",o("h-header"),o("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:or},children:[m.jsx("div",{className:T.cn("flex min-w-0 items-center"),children:m.jsxs("span",{className:T.cn("text-md flex items-center gap-2 truncate font-medium",b&&"shimmer"),children:[m.jsx("span",{className:"truncate",children:u}),b&&m.jsx(lu,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),m.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?m.jsx("button",{type:"button",onClick:()=>l(v=>!v),className:T.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":s,"aria-label":s?"Collapse assistant":"Expand assistant",children:s?m.jsx(AN,{strokeWidth:2,className:"size-3.5 rotate-90"}):m.jsx(NN,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,m.jsx("button",{onClick:()=>{i(!1),l(!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:m.jsx(Eo,{className:"size-4.5"})})]})]}),m.jsx(Lt.div,{className:"aui-modal-thread w-full flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:or},children:m.jsx($d,{})})]},"chat"):m.jsx(Lt.button,{layout:!0,layoutId:"chat-container",onClick:()=>i(!0),className:T.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",r("full")),initial:!1,"aria-label":`Open ${u}`,style:{originX:1,originY:1},children:m.jsx(Lt.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:or},className:"flex size-full items-center justify-center",children:c?c("closed"):m.jsx(CN,{className:"size-6"})})},"button")})})})})};function A2(e){switch(e){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:T.assertNever(e)}}const R2=()=>{const{config:e}=T.useElements(),t=xd(),r=e.sidecar??{},{title:o,dimensions:n}=r,{isExpanded:i,setIsExpanded:a}=m0(),l=L.useAssistantState(({thread:u})=>u).messages.some(u=>u.status?.type==="running");return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsxs(Lt.div,{initial:{width:n?.default?.width??"400px",height:n?.default?.height??"100vh"},animate:{width:i?n?.expanded?.width??"800px":n?.default?.width??"400px",height:i?n?.expanded?.height??"100%":n?.default?.height??"100vh"},transition:{duration:.3,ease:or},className:T.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",t.className),children:[m.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[m.jsx("span",{className:T.cn("flex items-center gap-2 text-sm font-medium",l&&"shimmer"),children:o}),m.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:m.jsx(ct,{tooltip:i?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(u=>!u),children:i?m.jsx(zN,{className:"size-4.5"}):m.jsx(DN,{className:"size-4.5"})})})]}),m.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:m.jsx($d,{})})]})})},z2=()=>{const{config:e}=T.useElements();switch(e.variant){case"standalone":return m.jsx($d,{});case"sidecar":return m.jsx(R2,{});default:return m.jsx(j2,{})}};exports.useGramElements=T.useElements;exports.Chat=z2;exports.GramElementsProvider=wM;exports.MODELS=Oc;exports.defineFrontendTool=pN;
|