teodor-new-chat-ui 4.3.97 → 4.3.99
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/index.esm.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -16403,7 +16403,7 @@ const Xp = g.forwardRef(({ className: e, orientation: t = "vertical", ...n }, r)
|
|
|
16403
16403
|
}
|
|
16404
16404
|
));
|
|
16405
16405
|
Xp.displayName = zl.displayName;
|
|
16406
|
-
const Uu =
|
|
16406
|
+
const Uu = 25;
|
|
16407
16407
|
function Wu({
|
|
16408
16408
|
className: e = "",
|
|
16409
16409
|
showCreateButton: t = !0,
|
package/dist/index.umd.js
CHANGED
|
@@ -134,4 +134,4 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
|
|
|
134
134
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
135
135
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
136
136
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
137
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function o0(e,t=Ws){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function s0(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),o0(t),r0(t)}function Ka(e){const t=e+"CollectionProvider",[n,r]=An(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=y=>{const{scope:v,children:m}=y,w=b.useRef(null),S=b.useRef(new Map).current;return d.jsx(o,{scope:v,itemMap:S,collectionRef:w,children:m})};i.displayName=t;const a=e+"CollectionSlot",l=ur.createSlot(a),c=b.forwardRef((y,v)=>{const{scope:m,children:w}=y,S=s(a,m),k=We(v,S.collectionRef);return d.jsx(l,{ref:k,children:w})});c.displayName=a;const u=e+"CollectionItemSlot",f="data-radix-collection-item",h=ur.createSlot(u),p=b.forwardRef((y,v)=>{const{scope:m,children:w,...S}=y,k=b.useRef(null),T=We(v,k),C=s(u,m);return b.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),d.jsx(h,{[f]:"",ref:T,children:w})});p.displayName=u;function x(y){const v=s(e+"CollectionConsumer",y);return b.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},x,r]}var i0=g.createContext(void 0);function Vs(e){const t=g.useContext(i0);return e||t||"ltr"}const a0=["top","right","bottom","left"],tr=Math.min,rn=Math.max,Ks=Math.round,qs=Math.floor,Rn=e=>({x:e,y:e}),l0={left:"right",right:"left",bottom:"top",top:"bottom"},c0={start:"end",end:"start"};function qa(e,t,n){return rn(e,tr(t,n))}function Hn(e,t){return typeof e=="function"?e(t):e}function Un(e){return e.split("-")[0]}function $r(e){return e.split("-")[1]}function Ga(e){return e==="x"?"y":"x"}function Ya(e){return e==="y"?"height":"width"}const u0=new Set(["top","bottom"]);function Pn(e){return u0.has(Un(e))?"y":"x"}function Xa(e){return Ga(Pn(e))}function d0(e,t,n){n===void 0&&(n=!1);const r=$r(e),o=Xa(e),s=Ya(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Gs(i)),[i,Gs(i)]}function f0(e){const t=Gs(e);return[Ja(e),t,Ja(t)]}function Ja(e){return e.replace(/start|end/g,t=>c0[t])}const Sf=["left","right"],Cf=["right","left"],h0=["top","bottom"],p0=["bottom","top"];function m0(e,t,n){switch(e){case"top":case"bottom":return n?t?Cf:Sf:t?Sf:Cf;case"left":case"right":return t?h0:p0;default:return[]}}function g0(e,t,n,r){const o=$r(e);let s=m0(Un(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ja)))),s}function Gs(e){return e.replace(/left|right|bottom|top/g,t=>l0[t])}function y0(e){return{top:0,right:0,bottom:0,left:0,...e}}function Tf(e){return typeof e!="number"?y0(e):{top:e,right:e,bottom:e,left:e}}function Ys(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function kf(e,t,n){let{reference:r,floating:o}=e;const s=Pn(t),i=Xa(t),a=Ya(i),l=Un(t),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch($r(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const x0=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=kf(c,r,l),h=r,p={},x=0;for(let y=0;y<a.length;y++){const{name:v,fn:m}=a[y],{x:w,y:S,data:k,reset:T}=await m({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});u=w??u,f=S??f,p={...p,[v]:{...p[v],...k}},T&&x<=50&&(x++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:u,y:f}=kf(c,h,l)),y=-1)}return{x:u,y:f,placement:h,strategy:o,middlewareData:p}};async function So(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Hn(t,e),x=Tf(p),v=a[h?f==="floating"?"reference":"floating":f],m=Ys(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Ys(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(m.top-T.top+x.top)/k.y,bottom:(T.bottom-m.bottom+x.bottom)/k.y,left:(m.left-T.left+x.left)/k.x,right:(T.right-m.right+x.right)/k.x}}const v0=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Hn(e,t)||{};if(c==null)return{};const f=Tf(u),h={x:n,y:r},p=Xa(o),x=Ya(p),y=await i.getDimensions(c),v=p==="y",m=v?"top":"left",w=v?"bottom":"right",S=v?"clientHeight":"clientWidth",k=s.reference[x]+s.reference[p]-h[p]-s.floating[x],T=h[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[x]);const P=k/2-T/2,_=E/2-y[x]/2-1,j=tr(f[m],_),D=tr(f[w],_),B=j,F=E-y[x]-D,O=E/2-y[x]/2+P,$=qa(B,O,F),R=!l.arrow&&$r(o)!=null&&O!==$&&s.reference[x]/2-(O<B?j:D)-y[x]/2<0,W=R?O<B?O-B:O-F:0;return{[p]:h[p]+W,data:{[p]:$,centerOffset:O-$-W,...R&&{alignmentOffset:W}},reset:R}}}),w0=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:y=!0,...v}=Hn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const m=Un(o),w=Pn(a),S=Un(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=h||(S||!y?[Gs(a)]:f0(a)),C=x!=="none";!h&&C&&T.push(...g0(a,y,x,k));const E=[a,...T],P=await So(t,v),_=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&_.push(P[m]),f){const O=d0(o,i,k);_.push(P[O[0]],P[O[1]])}if(j=[...j,{placement:o,overflows:_}],!_.every(O=>O<=0)){var D,B;const O=(((D=s.flip)==null?void 0:D.index)||0)+1,$=E[O];if($&&(!(f==="alignment"?w!==Pn($):!1)||j.every(U=>Pn(U.placement)===w?U.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:$}};let R=(B=j.filter(W=>W.overflows[0]<=0).sort((W,U)=>W.overflows[1]-U.overflows[1])[0])==null?void 0:B.placement;if(!R)switch(p){case"bestFit":{var F;const W=(F=j.filter(U=>{if(C){const z=Pn(U.placement);return z===w||z==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(z=>z>0).reduce((z,ie)=>z+ie,0)]).sort((U,z)=>U[1]-z[1])[0])==null?void 0:F[0];W&&(R=W);break}case"initialPlacement":R=a;break}if(o!==R)return{reset:{placement:R}}}return{}}}};function Ef(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function If(e){return a0.some(t=>e[t]>=0)}const b0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Hn(e,t);switch(r){case"referenceHidden":{const s=await So(t,{...o,elementContext:"reference"}),i=Ef(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:If(i)}}}case"escaped":{const s=await So(t,{...o,altBoundary:!0}),i=Ef(s,n.floating);return{data:{escapedOffsets:i,escaped:If(i)}}}default:return{}}}}},Nf=new Set(["left","top"]);async function S0(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Un(n),a=$r(n),l=Pn(n)==="y",c=Nf.has(i)?-1:1,u=s&&l?-1:1,f=Hn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof x=="number"&&(p=a==="end"?x*-1:x),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const C0=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await S0(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},T0=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:v=>{let{x:m,y:w}=v;return{x:m,y:w}}},...l}=Hn(e,t),c={x:n,y:r},u=await So(t,l),f=Pn(Un(o)),h=Ga(f);let p=c[h],x=c[f];if(s){const v=h==="y"?"top":"left",m=h==="y"?"bottom":"right",w=p+u[v],S=p-u[m];p=qa(w,p,S)}if(i){const v=f==="y"?"top":"left",m=f==="y"?"bottom":"right",w=x+u[v],S=x-u[m];x=qa(w,x,S)}const y=a.fn({...t,[h]:p,[f]:x});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:s,[f]:i}}}}}},k0=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Hn(e,t),u={x:n,y:r},f=Pn(o),h=Ga(f);let p=u[h],x=u[f];const y=Hn(a,t),v=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const S=h==="y"?"height":"width",k=s.reference[h]-s.floating[S]+v.mainAxis,T=s.reference[h]+s.reference[S]-v.mainAxis;p<k?p=k:p>T&&(p=T)}if(c){var m,w;const S=h==="y"?"width":"height",k=Nf.has(Un(o)),T=s.reference[f]-s.floating[S]+(k&&((m=i.offset)==null?void 0:m[f])||0)+(k?0:v.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?v.crossAxis:0);x<T?x=T:x>C&&(x=C)}return{[h]:p,[f]:x}}}},E0=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=Hn(e,t),u=await So(t,c),f=Un(o),h=$r(o),p=Pn(o)==="y",{width:x,height:y}=s.floating;let v,m;f==="top"||f==="bottom"?(v=f,m=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(m=f,v=h==="end"?"top":"bottom");const w=y-u.top-u.bottom,S=x-u.left-u.right,k=tr(y-u[v],w),T=tr(x-u[m],S),C=!t.middlewareData.shift;let E=k,P=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!h){const j=rn(u.left,0),D=rn(u.right,0),B=rn(u.top,0),F=rn(u.bottom,0);p?P=x-2*(j!==0||D!==0?j+D:rn(u.left,u.right)):E=y-2*(B!==0||F!==0?B+F:rn(u.top,u.bottom))}await l({...t,availableWidth:P,availableHeight:E});const _=await i.getDimensions(a.floating);return x!==_.width||y!==_.height?{reset:{rects:!0}}:{}}}};function Xs(){return typeof window<"u"}function zr(e){return Af(e)?(e.nodeName||"").toLowerCase():"#document"}function on(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function On(e){var t;return(t=(Af(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Af(e){return Xs()?e instanceof Node||e instanceof on(e).Node:!1}function wn(e){return Xs()?e instanceof Element||e instanceof on(e).Element:!1}function Mn(e){return Xs()?e instanceof HTMLElement||e instanceof on(e).HTMLElement:!1}function _f(e){return!Xs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof on(e).ShadowRoot}const I0=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=bn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!I0.has(o)}const N0=new Set(["table","td","th"]);function A0(e){return N0.has(zr(e))}const _0=[":popover-open",":modal"];function Js(e){return _0.some(t=>{try{return e.matches(t)}catch{return!1}})}const j0=["transform","translate","scale","rotate","perspective"],R0=["transform","translate","scale","rotate","perspective","filter"],P0=["paint","layout","strict","content"];function Za(e){const t=Qa(),n=wn(e)?bn(e):e;return j0.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||R0.some(r=>(n.willChange||"").includes(r))||P0.some(r=>(n.contain||"").includes(r))}function O0(e){let t=nr(e);for(;Mn(t)&&!Br(t);){if(Za(t))return t;if(Js(t))return null;t=nr(t)}return null}function Qa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const M0=new Set(["html","body","#document"]);function Br(e){return M0.has(zr(e))}function bn(e){return on(e).getComputedStyle(e)}function Zs(e){return wn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nr(e){if(zr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_f(e)&&e.host||On(e);return _f(t)?t.host:t}function jf(e){const t=nr(e);return Br(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mn(t)&&Co(t)?t:jf(t)}function To(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=jf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=on(o);if(s){const a=el(i);return t.concat(i,i.visualViewport||[],Co(o)?o:[],a&&n?To(a):[])}return t.concat(o,To(o,[],n))}function el(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Rf(e){const t=bn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Mn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ks(n)!==s||Ks(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function tl(e){return wn(e)?e:e.contextElement}function Hr(e){const t=tl(e);if(!Mn(t))return Rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Rf(t);let i=(s?Ks(n.width):n.width)/r,a=(s?Ks(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const D0=Rn(0);function Pf(e){const t=on(e);return!Qa()||!t.visualViewport?D0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function L0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==on(e)?!1:t}function Cr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=tl(e);let i=Rn(1);t&&(r?wn(r)&&(i=Hr(r)):i=Hr(e));const a=L0(s,n,r)?Pf(s):Rn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const h=on(s),p=r&&wn(r)?on(r):r;let x=h,y=el(x);for(;y&&r&&p!==x;){const v=Hr(y),m=y.getBoundingClientRect(),w=bn(y),S=m.left+(y.clientLeft+parseFloat(w.paddingLeft))*v.x,k=m.top+(y.clientTop+parseFloat(w.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,f*=v.y,l+=S,c+=k,x=on(y),y=el(x)}}return Ys({width:u,height:f,x:l,y:c})}function Qs(e,t){const n=Zs(e).scrollLeft;return t?t.left+n:Cr(On(e)).left+n}function Of(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Qs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function F0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=On(r),a=t?Js(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Rn(1);const u=Rn(0),f=Mn(r);if((f||!f&&!s)&&((zr(r)!=="body"||Co(i))&&(l=Zs(r)),Mn(r))){const p=Cr(r);c=Hr(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=i&&!f&&!s?Of(i,l):Rn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function $0(e){return Array.from(e.getClientRects())}function z0(e){const t=On(e),n=Zs(e),r=e.ownerDocument.body,o=rn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=rn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Qs(e);const a=-n.scrollTop;return bn(r).direction==="rtl"&&(i+=rn(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Mf=25;function B0(e,t){const n=on(e),r=On(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Qa();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Qs(r);if(c<=0){const u=r.ownerDocument,f=u.body,h=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,x=Math.abs(r.clientWidth-f.clientWidth-p);x<=Mf&&(s-=x)}else c<=Mf&&(s+=c);return{width:s,height:i,x:a,y:l}}const H0=new Set(["absolute","fixed"]);function U0(e,t){const n=Cr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Mn(e)?Hr(e):Rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Df(e,t,n){let r;if(t==="viewport")r=B0(e,n);else if(t==="document")r=z0(On(e));else if(wn(t))r=U0(t,n);else{const o=Pf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ys(r)}function Lf(e,t){const n=nr(e);return n===t||!wn(n)||Br(n)?!1:bn(n).position==="fixed"||Lf(n,t)}function W0(e,t){const n=t.get(e);if(n)return n;let r=To(e,[],!1).filter(a=>wn(a)&&zr(a)!=="body"),o=null;const s=bn(e).position==="fixed";let i=s?nr(e):e;for(;wn(i)&&!Br(i);){const a=bn(i),l=Za(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&H0.has(o.position)||Co(i)&&!l&&Lf(e,i))?r=r.filter(u=>u!==i):o=a,i=nr(i)}return t.set(e,r),r}function V0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Js(t)?[]:W0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=Df(t,u,o);return c.top=rn(f.top,c.top),c.right=tr(f.right,c.right),c.bottom=tr(f.bottom,c.bottom),c.left=rn(f.left,c.left),c},Df(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function K0(e){const{width:t,height:n}=Rf(e);return{width:t,height:n}}function q0(e,t,n){const r=Mn(t),o=On(t),s=n==="fixed",i=Cr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Rn(0);function c(){l.x=Qs(o)}if(r||!r&&!s)if((zr(t)!=="body"||Co(o))&&(a=Zs(t)),r){const p=Cr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?Of(o,a):Rn(0),f=i.left+a.scrollLeft-l.x-u.x,h=i.top+a.scrollTop-l.y-u.y;return{x:f,y:h,width:i.width,height:i.height}}function nl(e){return bn(e).position==="static"}function Ff(e,t){if(!Mn(e)||bn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return On(e)===n&&(n=n.ownerDocument.body),n}function $f(e,t){const n=on(e);if(Js(e))return n;if(!Mn(e)){let o=nr(e);for(;o&&!Br(o);){if(wn(o)&&!nl(o))return o;o=nr(o)}return n}let r=Ff(e,t);for(;r&&A0(r)&&nl(r);)r=Ff(r,t);return r&&Br(r)&&nl(r)&&!Za(r)?n:r||O0(e)||n}const G0=async function(e){const t=this.getOffsetParent||$f,n=this.getDimensions,r=await n(e.floating);return{reference:q0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Y0(e){return bn(e).direction==="rtl"}const X0={convertOffsetParentRelativeRectToViewportRelativeRect:F0,getDocumentElement:On,getClippingRect:V0,getOffsetParent:$f,getElementRects:G0,getClientRects:$0,getDimensions:K0,getScale:Hr,isElement:wn,isRTL:Y0};function zf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function J0(e,t){let n=null,r;const o=On(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const x=qs(f),y=qs(o.clientWidth-(u+h)),v=qs(o.clientHeight-(f+p)),m=qs(u),S={rootMargin:-x+"px "+-y+"px "+-v+"px "+-m+"px",threshold:rn(0,tr(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!zf(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function Z0(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=tl(e),u=o||s?[...c?To(c):[],...To(t)]:[];u.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});const f=c&&a?J0(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(m=>{let[w]=m;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let x,y=l?Cr(e):null;l&&v();function v(){const m=Cr(e);y&&!zf(y,m)&&n(),y=m,x=requestAnimationFrame(v)}return n(),()=>{var m;u.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(m=p)==null||m.disconnect(),p=null,l&&cancelAnimationFrame(x)}}const Q0=C0,eS=T0,tS=w0,nS=E0,rS=b0,Bf=v0,oS=k0,sS=(e,t,n)=>{const r=new Map,o={platform:X0,...n},s={...o.platform,_c:r};return x0(e,t,{...o,platform:s})};var iS=typeof document<"u",aS=function(){},ei=iS?b.useLayoutEffect:aS;function ti(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 n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ti(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!ti(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Hf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Uf(e,t){const n=Hf(e);return Math.round(t*n)/n}function rl(e){const t=g.useRef(e);return ei(()=>{t.current=e}),t}function lS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,f]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=g.useState(r);ti(h,r)||p(r);const[x,y]=g.useState(null),[v,m]=g.useState(null),w=g.useCallback(U=>{U!==C.current&&(C.current=U,y(U))},[]),S=g.useCallback(U=>{U!==E.current&&(E.current=U,m(U))},[]),k=s||x,T=i||v,C=g.useRef(null),E=g.useRef(null),P=g.useRef(u),_=l!=null,j=rl(l),D=rl(o),B=rl(c),F=g.useCallback(()=>{if(!C.current||!E.current)return;const U={placement:t,strategy:n,middleware:h};D.current&&(U.platform=D.current),sS(C.current,E.current,U).then(z=>{const ie={...z,isPositioned:B.current!==!1};O.current&&!ti(P.current,ie)&&(P.current=ie,Lo.flushSync(()=>{f(ie)}))})},[h,t,n,D,B]);ei(()=>{c===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,f(U=>({...U,isPositioned:!1})))},[c]);const O=g.useRef(!1);ei(()=>(O.current=!0,()=>{O.current=!1}),[]),ei(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(j.current)return j.current(k,T,F);F()}},[k,T,F,j,_]);const $=g.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:S}),[w,S]),R=g.useMemo(()=>({reference:k,floating:T}),[k,T]),W=g.useMemo(()=>{const U={position:n,left:0,top:0};if(!R.floating)return U;const z=Uf(R.floating,u.x),ie=Uf(R.floating,u.y);return a?{...U,transform:"translate("+z+"px, "+ie+"px)",...Hf(R.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:ie}},[n,a,R.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:F,refs:$,elements:R,floatingStyles:W}),[u,F,$,R,W])}const cS=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Bf({element:r.current,padding:o}).fn(n):{}:r?Bf({element:r,padding:o}).fn(n):{}}}},uS=(e,t)=>({...Q0(e),options:[e,t]}),dS=(e,t)=>({...eS(e),options:[e,t]}),fS=(e,t)=>({...oS(e),options:[e,t]}),hS=(e,t)=>({...tS(e),options:[e,t]}),pS=(e,t)=>({...nS(e),options:[e,t]}),mS=(e,t)=>({...rS(e),options:[e,t]}),gS=(e,t)=>({...cS(e),options:[e,t]});var yS="Arrow",Wf=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(Ae.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Wf.displayName=yS;var xS=Wf;function Vf(e){const[t,n]=g.useState(void 0);return Pt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ol="Popper",[Kf,ni]=An(ol),[vS,qf]=Kf(ol),Gf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=g.useState(null);return d.jsx(vS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Gf.displayName=ol;var Yf="PopperAnchor",Xf=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=qf(Yf,n),i=g.useRef(null),a=We(t,i),l=g.useRef(null);return g.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:d.jsx(Ae.div,{...o,ref:a})});Xf.displayName=Yf;var sl="PopperContent",[wS,bS]=Kf(sl),Jf=g.forwardRef((e,t)=>{var ee,L,Q,ue,ye,de;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:x,...y}=e,v=qf(sl,n),[m,w]=g.useState(null),S=We(t,Re=>w(Re)),[k,T]=g.useState(null),C=Vf(k),E=(C==null?void 0:C.width)??0,P=(C==null?void 0:C.height)??0,_=r+(s!=="center"?"-"+s:""),j=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],B=D.length>0,F={padding:j,boundary:D.filter(CS),altBoundary:B},{refs:O,floatingStyles:$,placement:R,isPositioned:W,middlewareData:U}=lS({strategy:"fixed",placement:_,whileElementsMounted:(...Re)=>Z0(...Re,{animationFrame:p==="always"}),elements:{reference:v.anchor},middleware:[uS({mainAxis:o+P,alignmentAxis:i}),l&&dS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?fS():void 0,...F}),l&&hS({...F}),pS({...F,apply:({elements:Re,rects:ce,availableWidth:Ze,availableHeight:it})=>{const{width:ft,height:vt}=ce.reference,yt=Re.floating.style;yt.setProperty("--radix-popper-available-width",`${Ze}px`),yt.setProperty("--radix-popper-available-height",`${it}px`),yt.setProperty("--radix-popper-anchor-width",`${ft}px`),yt.setProperty("--radix-popper-anchor-height",`${vt}px`)}}),k&&gS({element:k,padding:a}),TS({arrowWidth:E,arrowHeight:P}),h&&mS({strategy:"referenceHidden",...F})]}),[z,ie]=eh(R),X=Mt(x);Pt(()=>{W&&(X==null||X())},[W,X]);const ae=(ee=U.arrow)==null?void 0:ee.x,we=(L=U.arrow)==null?void 0:L.y,V=((Q=U.arrow)==null?void 0:Q.centerOffset)!==0,[le,xe]=g.useState();return Pt(()=>{m&&xe(window.getComputedStyle(m).zIndex)},[m]),d.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:W?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[(ue=U.transformOrigin)==null?void 0:ue.x,(ye=U.transformOrigin)==null?void 0:ye.y].join(" "),...((de=U.hide)==null?void 0:de.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(wS,{scope:n,placedSide:z,onArrowChange:T,arrowX:ae,arrowY:we,shouldHideArrow:V,children:d.jsx(Ae.div,{"data-side":z,"data-align":ie,...y,ref:S,style:{...y.style,animation:W?void 0:"none"}})})})});Jf.displayName=sl;var Zf="PopperArrow",SS={top:"bottom",right:"left",bottom:"top",left:"right"},Qf=g.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=bS(Zf,r),i=SS[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(xS,{...o,ref:n,style:{...o.style,display:"block"}})})});Qf.displayName=Zf;function CS(e){return e!==null}var TS=e=>({name:"transformOrigin",options:e,fn(t){var v,m,w;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=eh(n),f={start:"0%",center:"50%",end:"100%"}[u],h=(((m=o.arrow)==null?void 0:m.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let x="",y="";return c==="bottom"?(x=i?f:`${h}px`,y=`${-l}px`):c==="top"?(x=i?f:`${h}px`,y=`${r.floating.height+l}px`):c==="right"?(x=`${-l}px`,y=i?f:`${p}px`):c==="left"&&(x=`${r.floating.width+l}px`,y=i?f:`${p}px`),{data:{x,y}}}});function eh(e){const[t,n="center"]=e.split("-");return[t,n]}var th=Gf,nh=Xf,rh=Jf,oh=Qf,il="rovingFocusGroup.onEntryFocus",kS={bubbles:!1,cancelable:!0},ko="RovingFocusGroup",[al,sh,ES]=Ka(ko),[IS,ih]=An(ko,[ES]),[NS,AS]=IS(ko),ah=g.forwardRef((e,t)=>d.jsx(al.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(al.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(_S,{...e,ref:t})})}));ah.displayName=ko;var _S=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...f}=e,h=g.useRef(null),p=We(t,h),x=Vs(s),[y,v]=vr({prop:i,defaultProp:a??null,onChange:l,caller:ko}),[m,w]=g.useState(!1),S=Mt(c),k=sh(n),T=g.useRef(!1),[C,E]=g.useState(0);return g.useEffect(()=>{const P=h.current;if(P)return P.addEventListener(il,S),()=>P.removeEventListener(il,S)},[S]),d.jsx(NS,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:y,onItemFocus:g.useCallback(P=>v(P),[v]),onItemShiftTab:g.useCallback(()=>w(!0),[]),onFocusableItemAdd:g.useCallback(()=>E(P=>P+1),[]),onFocusableItemRemove:g.useCallback(()=>E(P=>P-1),[]),children:d.jsx(Ae.div,{tabIndex:m||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ge(e.onMouseDown,()=>{T.current=!0}),onFocus:ge(e.onFocus,P=>{const _=!T.current;if(P.target===P.currentTarget&&_&&!m){const j=new CustomEvent(il,kS);if(P.currentTarget.dispatchEvent(j),!j.defaultPrevented){const D=k().filter(R=>R.focusable),B=D.find(R=>R.active),F=D.find(R=>R.id===y),$=[B,F,...D].filter(Boolean).map(R=>R.ref.current);uh($,u)}}T.current=!1}),onBlur:ge(e.onBlur,()=>w(!1))})})}),lh="RovingFocusGroupItem",ch=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_n(),c=s||l,u=AS(lh,n),f=u.currentTabStopId===c,h=sh(n),{onFocusableItemAdd:p,onFocusableItemRemove:x,currentTabStopId:y}=u;return g.useEffect(()=>{if(r)return p(),()=>x()},[r,p,x]),d.jsx(al.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:d.jsx(Ae.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:ge(e.onMouseDown,v=>{r?u.onItemFocus(c):v.preventDefault()}),onFocus:ge(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:ge(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const m=PS(v,u.orientation,u.dir);if(m!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(m==="last")S.reverse();else if(m==="prev"||m==="next"){m==="prev"&&S.reverse();const k=S.indexOf(v.currentTarget);S=u.loop?OS(S,k+1):S.slice(k+1)}setTimeout(()=>uh(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:y!=null}):i})})});ch.displayName=lh;var jS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function RS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function PS(e,t,n){const r=RS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jS[r]}function uh(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function OS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var MS=ah,DS=ch,ll=["Enter"," "],LS=["ArrowDown","PageUp","Home"],dh=["ArrowUp","PageDown","End"],FS=[...LS,...dh],$S={ltr:[...ll,"ArrowRight"],rtl:[...ll,"ArrowLeft"]},zS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Eo="Menu",[Io,BS,HS]=Ka(Eo),[Tr,fh]=An(Eo,[HS,ni,ih]),ri=ni(),hh=ih(),[US,kr]=Tr(Eo),[WS,No]=Tr(Eo),ph=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ri(t),[l,c]=g.useState(null),u=g.useRef(!1),f=Mt(s),h=Vs(o);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),d.jsx(th,{...a,children:d.jsx(US,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:d.jsx(WS,{scope:t,onClose:g.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:u,dir:h,modal:i,children:r})})})};ph.displayName=Eo;var VS="MenuAnchor",cl=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ri(n);return d.jsx(nh,{...o,...r,ref:t})});cl.displayName=VS;var ul="MenuPortal",[KS,mh]=Tr(ul,{forceMount:void 0}),gh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=kr(ul,t);return d.jsx(KS,{scope:t,forceMount:n,children:d.jsx(nn,{present:n||s.open,children:d.jsx(ks,{asChild:!0,container:o,children:r})})})};gh.displayName=ul;var un="MenuContent",[qS,dl]=Tr(un),yh=g.forwardRef((e,t)=>{const n=mh(un,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kr(un,e.__scopeMenu),i=No(un,e.__scopeMenu);return d.jsx(Io.Provider,{scope:e.__scopeMenu,children:d.jsx(nn,{present:r||s.open,children:d.jsx(Io.Slot,{scope:e.__scopeMenu,children:i.modal?d.jsx(GS,{...o,ref:t}):d.jsx(YS,{...o,ref:t})})})})}),GS=g.forwardRef((e,t)=>{const n=kr(un,e.__scopeMenu),r=g.useRef(null),o=We(t,r);return g.useEffect(()=>{const s=r.current;if(s)return Fa(s)},[]),d.jsx(fl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ge(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),YS=g.forwardRef((e,t)=>{const n=kr(un,e.__scopeMenu);return d.jsx(fl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),XS=ur.createSlot("MenuContent.ScrollLock"),fl=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:x,...y}=e,v=kr(un,n),m=No(un,n),w=ri(n),S=hh(n),k=BS(n),[T,C]=g.useState(null),E=g.useRef(null),P=We(t,E,v.onContentChange),_=g.useRef(0),j=g.useRef(""),D=g.useRef(0),B=g.useRef(null),F=g.useRef("right"),O=g.useRef(0),$=x?js:g.Fragment,R=x?{as:XS,allowPinchZoom:!0}:void 0,W=z=>{var ee,L;const ie=j.current+z,X=k().filter(Q=>!Q.disabled),ae=document.activeElement,we=(ee=X.find(Q=>Q.ref.current===ae))==null?void 0:ee.textValue,V=X.map(Q=>Q.textValue),le=lC(V,ie,we),xe=(L=X.find(Q=>Q.textValue===le))==null?void 0:L.ref.current;(function Q(ue){j.current=ue,window.clearTimeout(_.current),ue!==""&&(_.current=window.setTimeout(()=>Q(""),1e3))})(ie),xe&&setTimeout(()=>xe.focus())};g.useEffect(()=>()=>window.clearTimeout(_.current),[]),Ra();const U=g.useCallback(z=>{var X,ae;return F.current===((X=B.current)==null?void 0:X.side)&&uC(z,(ae=B.current)==null?void 0:ae.area)},[]);return d.jsx(qS,{scope:n,searchRef:j,onItemEnter:g.useCallback(z=>{U(z)&&z.preventDefault()},[U]),onItemLeave:g.useCallback(z=>{var ie;U(z)||((ie=E.current)==null||ie.focus(),C(null))},[U]),onTriggerLeave:g.useCallback(z=>{U(z)&&z.preventDefault()},[U]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(z=>{B.current=z},[]),children:d.jsx($,{...R,children:d.jsx(Ts,{asChild:!0,trapped:o,onMountAutoFocus:ge(s,z=>{var ie;z.preventDefault(),(ie=E.current)==null||ie.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:d.jsx(Cs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:d.jsx(MS,{asChild:!0,...S,dir:m.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:ge(l,z=>{m.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(rh,{role:"menu","aria-orientation":"vertical","data-state":Oh(v.open),"data-radix-menu-content":"",dir:m.dir,...w,...y,ref:P,style:{outline:"none",...y.style},onKeyDown:ge(y.onKeyDown,z=>{const X=z.target.closest("[data-radix-menu-content]")===z.currentTarget,ae=z.ctrlKey||z.altKey||z.metaKey,we=z.key.length===1;X&&(z.key==="Tab"&&z.preventDefault(),!ae&&we&&W(z.key));const V=E.current;if(z.target!==V||!FS.includes(z.key))return;z.preventDefault();const xe=k().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);dh.includes(z.key)&&xe.reverse(),iC(xe)}),onBlur:ge(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(_.current),j.current="")}),onPointerMove:ge(e.onPointerMove,_o(z=>{const ie=z.target,X=O.current!==z.clientX;if(z.currentTarget.contains(ie)&&X){const ae=z.clientX>O.current?"right":"left";F.current=ae,O.current=z.clientX}}))})})})})})})});yh.displayName=un;var JS="MenuGroup",hl=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Ae.div,{role:"group",...r,ref:t})});hl.displayName=JS;var ZS="MenuLabel",xh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Ae.div,{...r,ref:t})});xh.displayName=ZS;var oi="MenuItem",vh="menu.itemSelect",si=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=g.useRef(null),i=No(oi,e.__scopeMenu),a=dl(oi,e.__scopeMenu),l=We(t,s),c=g.useRef(!1),u=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(vh,{bubbles:!0,cancelable:!0});f.addEventListener(vh,p=>r==null?void 0:r(p),{once:!0}),od(f,h),h.defaultPrevented?c.current=!1:i.onClose()}};return d.jsx(wh,{...o,ref:l,disabled:n,onClick:ge(e.onClick,u),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),c.current=!0},onPointerUp:ge(e.onPointerUp,f=>{var h;c.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ge(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||ll.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});si.displayName=oi;var wh=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=dl(oi,n),a=hh(n),l=g.useRef(null),c=We(t,l),[u,f]=g.useState(!1),[h,p]=g.useState("");return g.useEffect(()=>{const x=l.current;x&&p((x.textContent??"").trim())},[s.children]),d.jsx(Io.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:d.jsx(DS,{asChild:!0,...a,focusable:!r,children:d.jsx(Ae.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ge(e.onPointerMove,_o(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ge(e.onPointerLeave,_o(x=>i.onItemLeave(x))),onFocus:ge(e.onFocus,()=>f(!0)),onBlur:ge(e.onBlur,()=>f(!1))})})})}),QS="MenuCheckboxItem",bh=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return d.jsx(Eh,{scope:e.__scopeMenu,checked:n,children:d.jsx(si,{role:"menuitemcheckbox","aria-checked":ii(n)?"mixed":n,...o,ref:t,"data-state":ml(n),onSelect:ge(o.onSelect,()=>r==null?void 0:r(ii(n)?!0:!n),{checkForDefaultPrevented:!1})})})});bh.displayName=QS;var Sh="MenuRadioGroup",[eC,tC]=Tr(Sh,{value:void 0,onValueChange:()=>{}}),Ch=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Mt(r);return d.jsx(eC,{scope:e.__scopeMenu,value:n,onValueChange:s,children:d.jsx(hl,{...o,ref:t})})});Ch.displayName=Sh;var Th="MenuRadioItem",kh=g.forwardRef((e,t)=>{const{value:n,...r}=e,o=tC(Th,e.__scopeMenu),s=n===o.value;return d.jsx(Eh,{scope:e.__scopeMenu,checked:s,children:d.jsx(si,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ml(s),onSelect:ge(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});kh.displayName=Th;var pl="MenuItemIndicator",[Eh,nC]=Tr(pl,{checked:!1}),Ih=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=nC(pl,n);return d.jsx(nn,{present:r||ii(s.checked)||s.checked===!0,children:d.jsx(Ae.span,{...o,ref:t,"data-state":ml(s.checked)})})});Ih.displayName=pl;var rC="MenuSeparator",Nh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Ae.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Nh.displayName=rC;var oC="MenuArrow",Ah=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ri(n);return d.jsx(oh,{...o,...r,ref:t})});Ah.displayName=oC;var sC="MenuSub",[Vk,_h]=Tr(sC),Ao="MenuSubTrigger",jh=g.forwardRef((e,t)=>{const n=kr(Ao,e.__scopeMenu),r=No(Ao,e.__scopeMenu),o=_h(Ao,e.__scopeMenu),s=dl(Ao,e.__scopeMenu),i=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),d.jsx(cl,{asChild:!0,...c,children:d.jsx(wh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Oh(n.open),...e,ref:wa(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ge(e.onPointerMove,_o(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ge(e.onPointerLeave,_o(f=>{var p,x;u();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const y=(x=n.content)==null?void 0:x.dataset.side,v=y==="right",m=v?-5:5,w=h[v?"left":"right"],S=h[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+m,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ge(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||$S[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});jh.displayName=Ao;var Rh="MenuSubContent",Ph=g.forwardRef((e,t)=>{const n=mh(un,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kr(un,e.__scopeMenu),i=No(un,e.__scopeMenu),a=_h(Rh,e.__scopeMenu),l=g.useRef(null),c=We(t,l);return d.jsx(Io.Provider,{scope:e.__scopeMenu,children:d.jsx(nn,{present:r||s.open,children:d.jsx(Io.Slot,{scope:e.__scopeMenu,children:d.jsx(fl,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ge(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ge(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ge(e.onKeyDown,u=>{var p;const f=u.currentTarget.contains(u.target),h=zS[i.dir].includes(u.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});Ph.displayName=Rh;function Oh(e){return e?"open":"closed"}function ii(e){return e==="indeterminate"}function ml(e){return ii(e)?"indeterminate":e?"checked":"unchecked"}function iC(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function aC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function lC(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=aC(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function cC(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,u=a.y,f=l.x,h=l.y;u>r!=h>r&&n<(f-c)*(r-u)/(h-u)+c&&(o=!o)}return o}function uC(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return cC(n,t)}function _o(e){return t=>t.pointerType==="mouse"?e(t):void 0}var dC=ph,fC=cl,hC=gh,pC=yh,mC=hl,gC=xh,yC=si,xC=bh,vC=Ch,wC=kh,bC=Ih,SC=Nh,CC=Ah,TC=jh,kC=Ph,ai="DropdownMenu",[EC,Kk]=An(ai,[fh]),Kt=fh(),[IC,Mh]=EC(ai),Dh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Kt(t),c=g.useRef(null),[u,f]=vr({prop:o,defaultProp:s??!1,onChange:i,caller:ai});return d.jsx(IC,{scope:t,triggerId:_n(),triggerRef:c,contentId:_n(),open:u,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(h=>!h),[f]),modal:a,children:d.jsx(dC,{...l,open:u,onOpenChange:f,dir:r,modal:a,children:n})})};Dh.displayName=ai;var Lh="DropdownMenuTrigger",Fh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Mh(Lh,n),i=Kt(n);return d.jsx(fC,{asChild:!0,...i,children:d.jsx(Ae.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:wa(t,s.triggerRef),onPointerDown:ge(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ge(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Fh.displayName=Lh;var NC="DropdownMenuPortal",$h=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Kt(t);return d.jsx(hC,{...r,...n})};$h.displayName=NC;var zh="DropdownMenuContent",Bh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mh(zh,n),s=Kt(n),i=g.useRef(!1);return d.jsx(pC,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ge(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ge(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Bh.displayName=zh;var AC="DropdownMenuGroup",_C=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(mC,{...o,...r,ref:t})});_C.displayName=AC;var jC="DropdownMenuLabel",Hh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(gC,{...o,...r,ref:t})});Hh.displayName=jC;var RC="DropdownMenuItem",Uh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(yC,{...o,...r,ref:t})});Uh.displayName=RC;var PC="DropdownMenuCheckboxItem",Wh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(xC,{...o,...r,ref:t})});Wh.displayName=PC;var OC="DropdownMenuRadioGroup",MC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(vC,{...o,...r,ref:t})});MC.displayName=OC;var DC="DropdownMenuRadioItem",Vh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(wC,{...o,...r,ref:t})});Vh.displayName=DC;var LC="DropdownMenuItemIndicator",Kh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(bC,{...o,...r,ref:t})});Kh.displayName=LC;var FC="DropdownMenuSeparator",qh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(SC,{...o,...r,ref:t})});qh.displayName=FC;var $C="DropdownMenuArrow",zC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(CC,{...o,...r,ref:t})});zC.displayName=$C;var BC="DropdownMenuSubTrigger",Gh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(TC,{...o,...r,ref:t})});Gh.displayName=BC;var HC="DropdownMenuSubContent",Yh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(kC,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Yh.displayName=HC;var UC=Dh,WC=Fh,VC=$h,Xh=Bh,Jh=Hh,Zh=Uh,Qh=Wh,ep=Vh,tp=Kh,np=qh,rp=Gh,op=Yh;const KC=UC,qC=WC,GC=g.forwardRef(({className:e,inset:t,children:n,...r},o)=>d.jsxs(rp,{ref:o,className:te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,d.jsx(he.ChevronRight,{className:"ml-auto h-4 w-4"})]}));GC.displayName=rp.displayName;const YC=g.forwardRef(({className:e,...t},n)=>d.jsx(op,{ref:n,className:te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));YC.displayName=op.displayName;const sp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>d.jsx(VC,{children:d.jsx(Xh,{ref:r,sideOffset:t,className:te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...n})}));sp.displayName=Xh.displayName;const gl=g.forwardRef(({className:e,inset:t,...n},r)=>d.jsx(Zh,{ref:r,className:te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));gl.displayName=Zh.displayName;const XC=g.forwardRef(({className:e,children:t,checked:n,...r},o)=>d.jsxs(Qh,{ref:o,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(tp,{children:d.jsx(he.Check,{className:"h-4 w-4"})})}),t]}));XC.displayName=Qh.displayName;const JC=g.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(ep,{ref:r,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(tp,{children:d.jsx(he.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));JC.displayName=ep.displayName;const ZC=g.forwardRef(({className:e,inset:t,...n},r)=>d.jsx(Jh,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ZC.displayName=Jh.displayName;const QC=g.forwardRef(({className:e,...t},n)=>d.jsx(np,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));QC.displayName=np.displayName;const ip={value:""};function li({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:u=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:x}){const{api:y}=Mi(),{currentThreadId:v}=ns(),{threadId:m,messages:w,hasMore:S,isHistoryLoading:k,isLoading:T,loadOlder:C,navigateToCheckpoint:E,returnToLatest:P,checkpoint:_,checkpoints:j,interrupt:D,metadata:B}=rs(),{isStreaming:F,error:O,connectionState:$,submit:R,stop:W}=eu(),U=m??v??null,z=(_==null?void 0:_.id)??null,ie=(_==null?void 0:_.namespace)??null,X=(B==null?void 0:B.assemblingMessageId)??null,ae=D,[we,V]=b.useState(!1);b.useEffect(()=>{ae||V(!1)},[ae]);const le=b.useCallback(()=>{V(!0)},[]),xe=b.useCallback(()=>{V(!1)},[]),ee=!!ae||we,[L,Q]=b.useState(null),[ue,ye]=b.useState(""),[de,Re]=b.useState(null),[ce,Ze]=b.useState([]),[it,ft]=b.useState(0),[vt,yt]=b.useState(0),[Qe,ke]=b.useState(!1),[at,lt]=b.useState(null),[ot,et]=b.useState(null),[se,Ee]=b.useState(!1),[Se,qe]=b.useState(null),[Xe,It]=b.useState(!1),Ct=b.useRef(!1),[wt,hn]=b.useState(()=>ip.value),Wn=b.useRef(wt),Ge=b.useRef(null),Ve=b.useCallback(Y=>{ip.value=Y,hn(Y)},[]),[qt,Dt]=b.useState(!1),Nt=b.useCallback((Y,ne)=>{if(!Y||typeof Y!="object")return null;const fe=Y[ne];return typeof fe=="number"?fe:null},[]),Zt=b.useCallback((Y,ne)=>{if(!Y||typeof Y!="object")return null;const fe=Y[ne];return typeof fe=="string"&&fe.trim()?fe:null},[]),At=b.useMemo(()=>{const Y=Array.isArray(j)?[...j]:[];return Y.some(fe=>Nt(fe.metadata,"step")!==null)&&Y.sort((fe,Ye)=>{const pt=Nt(fe.metadata,"step"),Rt=Nt(Ye.metadata,"step");if(pt!==null||Rt!==null)return(Rt??Number.NEGATIVE_INFINITY)-(pt??Number.NEGATIVE_INFINITY);const _t=Date.parse(fe.createdAt??""),Tn=Date.parse(Ye.createdAt??"");return Number.isNaN(_t)||Number.isNaN(Tn)?0:Tn-_t}),Y},[j,Nt]),Cn=b.useRef(null),Qt=b.useRef(null),ct=b.useCallback(()=>{Cn.current&&(Cn.current.value=""),Qt.current&&(Qt.current.value=""),ft(Y=>Y+1),yt(Y=>Y+1)},[]),$e=b.useCallback(Y=>{Ve(Y)},[Ve]),Lt=b.useRef(!1);b.useEffect(()=>{Lt.current&&!F&&(Ze([]),ct()),Lt.current=F},[F,ct]);const[Oe,ht]=b.useState("desktop");b.useEffect(()=>{const Y=()=>{const ne=window.innerWidth;ht(ne<640?"phone":ne<1024?"tablet":"desktop")};return Y(),window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},[]),b.useEffect(()=>{It(!1),Ct.current=!1},[U]),b.useEffect(()=>{Wn.current=wt},[wt]),b.useEffect(()=>{if(!L){Ge.current=null;return}Ge.current===null&&(Ge.current=Wn.current),Ve(ue??"")},[ue,L,Ve]);const ir=b.useCallback(async()=>{if(!(!S||k||!Xe))try{await C()}catch(Y){console.warn("loadOlder failed",Y)}},[S,Xe,k,C]);b.useEffect(()=>{(async()=>{if(!y.baseUrl){qe(null);return}try{const fe=(await y.getAgent("default")).uiDefaultMessage||"";qe(fe||null)}catch(ne){console.warn("Failed to fetch default message:",ne),qe(null)}})()},[y.baseUrl]),b.useEffect(()=>{O&&!se&&(x==null||x(O))},[O,se,x]);const Kr=Y=>{if(Y.length>Ws)return`Message too long (${Y.length}/${Ws} characters)`;try{return s0(Y),null}catch(ne){return(ne==null?void 0:ne.message)||"Invalid message"}},ar=async Y=>{const ne=Y.trim();if(!(!ne&&ce.length===0)){if(ne){const fe=Kr(ne);if(fe){Re(fe);return}}try{await R({text:ne||"",attachments:ce,payload:L?{edit:!0,originalMessageId:L}:void 0},{checkpointId:z??void 0,checkpointNs:ie??void 0}),h==null||h(ne),Ve(""),Re(null),Ze([]),ct(),Q(null),ye("")}catch(fe){const Ye=(fe==null?void 0:fe.message)||"Failed to send message";Re(Ye),x==null||x(Ye)}}},lr=b.useCallback((Y,ne)=>{c&&(Ge.current=wt,Q(Y),ye(ne),Ve(ne),Re(null))},[wt,c,Ve]),Vn=b.useCallback(()=>{Q(null),ye(""),Re(null),Ve(Ge.current??wt),Ge.current=null},[wt,Ve]),Kn=b.useCallback((Y,ne)=>{lr(Y,ne)},[lr]),qr=b.useCallback(Y=>{for(let ne=Y-1;ne>=0;ne--)if(w[ne].role==="user"){const fe=w[ne].content||[],pt=fe.filter(Rt=>Rt.type==="text").map(Rt=>Rt.text).join("")||(()=>{try{return JSON.stringify(fe,null,2)}catch{return String(fe)}})();pt&&R({text:pt},{checkpointId:z??void 0,checkpointNs:ie??void 0});break}},[w,R,z,ie]),I=Y=>{const ne=Array.from(Y.target.files||[]);Ze(fe=>[...fe,...ne]),Y.target.value=""},q=Y=>{Ze(ne=>{const fe=ne.filter((Ye,pt)=>Y!==pt);return fe.length===0&&ct(),fe})},oe=async Y=>{const ne=(Y.target.files||[])[0];if(ne){lt(null),et(null),ke(!0);try{await R({attachments:[ne]},{checkpointId:z??void 0,checkpointNs:ie??void 0});const fe=`Uploaded ${ne.name} - processing through chat stream`;et(fe)}catch(fe){const Ye=fe instanceof Error?fe.message:"Failed to upload Excel file";console.error("Excel upload failed",fe),lt(Ye),x==null||x(Ye)}finally{ke(!1),Y.target.value="",ct()}}},be=Y=>{if(!Y)return"Unknown";const ne=Date.parse(Y);return Number.isNaN(ne)?Y:new Date(ne).toLocaleString()},He=async Y=>{if(v){Dt(!0);try{if(!Y){await P();return}const ne=At.find(Ye=>Ye.checkpointId===Y),fe=(ne==null?void 0:ne.checkpointNs)??null;await E(Y,fe)}finally{Dt(!1)}}},tt=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,ze=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,De=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return d.jsxs("div",{className:tt,children:[!!O&&!se&&d.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[d.jsx("span",{children:O}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>Ee(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:d.jsx(he.X,{size:16})})]}),v&&j.length>0&&d.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[d.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),d.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:z??"",onChange:Y=>{const ne=Y.target.value||null;He(ne)},children:[d.jsx("option",{value:"",children:"Latest"}),At.map(Y=>{const ne=Nt(Y.metadata,"step"),fe=Zt(Y.metadata,"source"),Ye=[];ne!==null&&Ye.push(`Step ${ne}`),fe&&Ye.push(fe);const pt=Ye.length?` — ${Ye.join(" • ")}`:"";return d.jsxs("option",{value:Y.checkpointId,children:[be(Y.createdAt),pt]},Y.checkpointId)})]})]}),d.jsxs("div",{className:`relative ${ze}`,style:r?{maxHeight:r}:void 0,children:[d.jsx(Va,{className:"h-full",style:{height:"100%"},messages:w,isStreaming:F,streamingAssistantId:X,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Oe,enableMessageEditing:c,editingMessageId:L,onStartReached:()=>{Xe&&ir()},onScrollAway:Y=>{if(!Ct.current){Ct.current=!0;return}Y&&It(!0)},onEdit:Kn,onRegenerate:qr,onCancelEdit:Vn,emptyMessage:Se??void 0,isNavigatingCheckpoint:qt,activeInterrupt:ae,disableInterruptActions:we,onInterruptActionStart:le,onInterruptActionEnd:xe,showToolMessages:u}),($==="reconnecting"||$==="connecting")&&d.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(he.Loader2,{className:"h-3 w-3 animate-spin"}),$==="reconnecting"?"Reconnecting…":"Connecting…"]})}),$==="error"&&d.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&d.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[d.jsx(he.Loader2,{className:"h-6 w-6 animate-spin"}),d.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),d.jsxs("div",{className:De,children:[L&&d.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(he.Edit3,{size:16,className:"text-blue-600"}),d.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:Vn,className:"text-blue-600 hover:bg-blue-100",children:d.jsx(he.X,{size:16})})]})}),(a||l)&&d.jsxs("div",{className:"mb-3 space-y-3",children:[a&&d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:Cn,type:"file",multiple:!0,onChange:Y=>I(Y),className:"hidden"},it),ce.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:ce.map((Y,ne)=>d.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[d.jsx(he.Paperclip,{size:14}),d.jsx("span",{className:"truncate max-w-[150px]",children:Y.name}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>q(ne),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${Y.name}`,children:d.jsx(he.X,{size:12})})]},ne))})]}),l&&d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:Qt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:oe,className:"hidden"},vt),Qe&&d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsx(he.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ot&&!Qe&&d.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ot}),at&&!Qe&&d.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:at})]})]}),de&&d.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:de}),d.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&d.jsxs(KC,{children:[d.jsx(qC,{asChild:!0,children:d.jsx(nt,{type:"button",size:"icon",variant:"outline",disabled:F||ee,title:"More input actions",className:f.moreButton||"",children:d.jsx(he.Plus,{size:16})})}),d.jsxs(sp,{align:"start",sideOffset:6,className:"w-52",children:[a&&d.jsxs(gl,{onClick:()=>{var Y;return(Y=Cn.current)==null?void 0:Y.click()},className:"cursor-pointer",children:[d.jsx(he.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&d.jsxs(gl,{onClick:()=>{var Y;Qe||(Y=Qt.current)==null||Y.click()},className:`cursor-pointer ${Qe?"opacity-60 pointer-events-none":""}`,children:[d.jsx(he.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),d.jsx("div",{className:"flex-1",children:d.jsx(yx,{initialValue:ue,editingMessageId:L,value:wt,onValueChange:$e,placeholder:L?"Edit your message...":t,isStreaming:F,disabled:ee,maxLength:Ws,onSend:ar,onCancelEdit:Vn,onStop:W,allowEmptySend:ce.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${L?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${de?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const ci=g.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ci.displayName="Input";function yl(e,[t,n]){return Math.min(n,Math.max(t,e))}function eT(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var xl="ScrollArea",[ap,qk]=An(xl),[tT,dn]=ap(xl),lp=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=g.useState(null),[c,u]=g.useState(null),[f,h]=g.useState(null),[p,x]=g.useState(null),[y,v]=g.useState(null),[m,w]=g.useState(0),[S,k]=g.useState(0),[T,C]=g.useState(!1),[E,P]=g.useState(!1),_=We(t,D=>l(D)),j=Vs(o);return d.jsx(tT,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:x,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:y,onScrollbarYChange:v,scrollbarYEnabled:E,onScrollbarYEnabledChange:P,onCornerWidthChange:w,onCornerHeightChange:k,children:d.jsx(Ae.div,{dir:j,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":m+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});lp.displayName=xl;var cp="ScrollAreaViewport",up=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=dn(cp,n),a=g.useRef(null),l=We(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx(Ae.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});up.displayName=cp;var Dn="ScrollAreaScrollbar",vl=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=dn(Dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return g.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(nT,{...r,ref:t,forceMount:n}):o.type==="scroll"?d.jsx(rT,{...r,ref:t,forceMount:n}):o.type==="auto"?d.jsx(dp,{...r,ref:t,forceMount:n}):o.type==="always"?d.jsx(wl,{...r,ref:t}):null});vl.displayName=Dn;var nT=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=dn(Dn,e.__scopeScrollArea),[s,i]=g.useState(!1);return g.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},u=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(nn,{present:n||s,children:d.jsx(dp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),rT=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=dn(Dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=hi(()=>l("SCROLL_END"),100),[a,l]=eT("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return g.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),g.useEffect(()=>{const c=o.viewport,u=s?"scrollLeft":"scrollTop";if(c){let f=c[u];const h=()=>{const p=c[u];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),d.jsx(nn,{present:n||a!=="hidden",children:d.jsx(wl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ge(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ge(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),dp=g.forwardRef((e,t)=>{const n=dn(Dn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=g.useState(!1),a=e.orientation==="horizontal",l=hi(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:u)}},10);return Ur(n.viewport,l),Ur(n.content,l),d.jsx(nn,{present:r||s,children:d.jsx(wl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),wl=g.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=dn(Dn,e.__scopeScrollArea),s=g.useRef(null),i=g.useRef(0),[a,l]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=gp(a.viewport,a.content),u={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return cT(h,i.current,a,p)}return n==="horizontal"?d.jsx(oT,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=yp(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?d.jsx(sT,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=yp(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),oT=g.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=dn(Dn,e.__scopeScrollArea),[i,a]=g.useState(),l=g.useRef(null),c=We(t,l,s.onScrollbarXChange);return g.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(hp,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":fi(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),vp(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:di(i.paddingLeft),paddingEnd:di(i.paddingRight)}})}})}),sT=g.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=dn(Dn,e.__scopeScrollArea),[i,a]=g.useState(),l=g.useRef(null),c=We(t,l,s.onScrollbarYChange);return g.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(hp,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":fi(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),vp(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:di(i.paddingTop),paddingEnd:di(i.paddingBottom)}})}})}),[iT,fp]=ap(Dn),hp=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:f,...h}=e,p=dn(Dn,n),[x,y]=g.useState(null),v=We(t,_=>y(_)),m=g.useRef(null),w=g.useRef(""),S=p.viewport,k=r.content-r.viewport,T=Mt(u),C=Mt(l),E=hi(f,10);function P(_){if(m.current){const j=_.clientX-m.current.left,D=_.clientY-m.current.top;c({x:j,y:D})}}return g.useEffect(()=>{const _=j=>{const D=j.target;(x==null?void 0:x.contains(D))&&T(j,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,x,k,T]),g.useEffect(C,[r,C]),Ur(x,E),Ur(p.content,E),d.jsx(iT,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:Mt(s),onThumbPointerUp:Mt(i),onThumbPositionChange:C,onThumbPointerDown:Mt(a),children:d.jsx(Ae.div,{...h,ref:v,style:{position:"absolute",...h.style},onPointerDown:ge(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),m.current=x.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),P(_))}),onPointerMove:ge(e.onPointerMove,P),onPointerUp:ge(e.onPointerUp,_=>{const j=_.target;j.hasPointerCapture(_.pointerId)&&j.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),m.current=null})})})}),ui="ScrollAreaThumb",pp=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=fp(ui,e.__scopeScrollArea);return d.jsx(nn,{present:n||o.hasThumb,children:d.jsx(aT,{ref:t,...r})})}),aT=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=dn(ui,n),i=fp(ui,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),c=g.useRef(void 0),u=hi(()=>{c.current&&(c.current(),c.current=void 0)},100);return g.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(u(),!c.current){const p=uT(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,u,a]),d.jsx(Ae.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ge(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),x=f.clientX-p.left,y=f.clientY-p.top;i.onThumbPointerDown({x,y})}),onPointerUp:ge(e.onPointerUp,i.onThumbPointerUp)})});pp.displayName=ui;var bl="ScrollAreaCorner",mp=g.forwardRef((e,t)=>{const n=dn(bl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?d.jsx(lT,{...e,ref:t}):null});mp.displayName=bl;var lT=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=dn(bl,n),[s,i]=g.useState(0),[a,l]=g.useState(0),c=!!(s&&a);return Ur(o.scrollbarX,()=>{var f;const u=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),Ur(o.scrollbarY,()=>{var f;const u=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),c?d.jsx(Ae.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function di(e){return e?parseInt(e,10):0}function gp(e,t){const n=e/t;return isNaN(n)?0:n}function fi(e){const t=gp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function cT(e,t,n,r="ltr"){const o=fi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,f=r==="ltr"?[0,u]:[u*-1,0];return xp([l,c],f)(e)}function yp(e,t,n="ltr"){const r=fi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=yl(e,l);return xp([0,i],[0,a])(c)}function xp(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function vp(e,t){return e>0&&e<t}var uT=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function hi(e,t){const n=Mt(e),r=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),g.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ur(e,t){const n=Mt(t);Pt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var wp=lp,dT=up,fT=mp;const bp=g.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(wp,{ref:r,className:te("relative overflow-hidden",e),...n,children:[d.jsx(dT,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),d.jsx(Sp,{}),d.jsx(fT,{})]}));bp.displayName=wp.displayName;const Sp=g.forwardRef(({className:e,orientation:t="vertical",...n},r)=>d.jsx(vl,{ref:r,orientation:t,className:te("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:d.jsx(pp,{className:"relative flex-1 rounded-full bg-border"})}));Sp.displayName=vl.displayName;const Cp=40;function Sl({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:u}){const{threads:f,currentThreadId:h,isLoading:p,actions:x}=ns(),{loadThread:y}=rs(),{createThread:v,deleteThread:m,renameThread:w}=x,[S,k]=b.useState(Array.isArray(f)?f:[]),T=b.useRef(S.length>0),C=b.useRef(null),E=b.useRef(0),[P,_]=b.useState(null),[j,D]=b.useState(""),[B,F]=b.useState(!1);b.useEffect(()=>{const V=Array.isArray(f)?f:[];if(V.length>0){T.current=!0,k(V);return}p||(T.current=!1,k(V))},[f,p]),b.useEffect(()=>{if(!C.current)return;const V=C.current.querySelector("[data-radix-scroll-area-viewport]");if(!V)return;let le=null,xe=null;return le=requestAnimationFrame(()=>{xe=requestAnimationFrame(()=>{V.scrollTop=E.current})}),()=>{le!==null&&cancelAnimationFrame(le),xe!==null&&cancelAnimationFrame(xe)}},[S]);const O=async V=>{try{await y(V),a==null||a(V),l==null||l(V)}catch(le){console.error("Failed to select thread:",le)}},$=async()=>{try{F(!0);const V=await v();c==null||c(V),a==null||a(V)}catch(V){console.error("Failed to create thread:",V)}finally{F(!1)}},R=async(V,le)=>{if(le.stopPropagation(),!!confirm("Delete this thread?")){if(C.current){const xe=C.current.querySelector("[data-radix-scroll-area-viewport]");xe&&(E.current=xe.scrollTop)}try{await m(V),u==null||u(V)}catch(xe){console.error("Failed to delete thread:",xe)}}},W=(V,le)=>{le.stopPropagation(),_(V.threadId),D(V.title||`Thread ${V.threadId.slice(0,8)}`)},U=async V=>{if(j.trim())try{await w(V,j.trim()),_(null),D("")}catch(le){console.error("Failed to update title:",le)}},z=()=>{_(null),D("")},ie=(V,le)=>{V.key==="Enter"?U(le):V.key==="Escape"&&z()},X=V=>{if(!V)return"";try{const le=new Date(V),ee=new Date().getTime()-le.getTime(),L=Math.floor(ee/(1e3*60*60*24));return L===0?le.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):L===1?"Yesterday":L<7?`${L} days ago`:le.toLocaleDateString()}catch{return""}},ae=V=>V.title||`Thread ${V.threadId.slice(0,8)}`,we=V=>{const le=ae(V);return le.length<=Cp?le:`${le.slice(0,Cp)}...`};return d.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&d.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:d.jsx(nt,{onClick:$,disabled:B||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:B?"Creating...":"New Chat",children:d.jsx(he.MessageSquarePlus,{size:20})})}),d.jsx(bp,{ref:C,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:d.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[d.jsx(he.Loader2,{className:"h-5 w-5 animate-spin"}),d.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?d.jsxs("div",{className:"text-center py-8 text-slate-400",children:[d.jsx(he.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),d.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((V,le)=>new Date(le.updatedAt||le.createdAt||"").getTime()-new Date(V.updatedAt||V.createdAt||"").getTime()).map(V=>d.jsxs("div",{onClick:()=>O(V.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===V.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"flex-1 min-w-0",children:P===V.threadId?d.jsxs("div",{className:"flex items-center gap-2",onClick:le=>le.stopPropagation(),children:[d.jsx(ci,{value:j,onChange:le=>D(le.target.value),onKeyDown:le=>ie(le,V.threadId),className:"h-6 text-sm",autoFocus:!0}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>U(V.threadId),className:"h-6 w-6 p-0",children:d.jsx(he.Check,{size:12})}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:z,className:"h-6 w-6 p-0",children:d.jsx(he.X,{size:12})})]}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:we(V)}),d.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[d.jsx(he.Calendar,{size:10}),d.jsx("span",{children:X(V.updatedAt||V.createdAt)})]})]})}),d.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&P!==V.threadId&&d.jsx(nt,{variant:"ghost",size:"sm",onClick:le=>W(V,le),className:"h-6 w-6 p-0",title:"Edit title",children:d.jsx(he.Edit3,{size:12})}),n&&d.jsx(nt,{variant:"ghost",size:"sm",onClick:le=>R(V.threadId,le),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:d.jsx(he.Trash2,{size:12})})]})]}),i===V.threadId&&d.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},V.threadId))})})]})}function Wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function hT(e){if(typeof e!="string")return;const t=e.trim();if(t)return zn(t)}function Tp(){const e=[Wr("__API_BASE_URL__"),Wr("__CHAT_API_BASE_URL__"),Wr("__CHAT_API_URL__")];for(const t of e){const n=hT(t);if(n)return n}}function kp(){const e=[Wr("__API_AUTH_TOKEN__"),Wr("__CHAT_API_KEY__"),Wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Ep(...e){for(const t of e)if(typeof t=="string"&&t.trim())return zn(t);return zn()}function Ip(){const e={},t=Tp(),n=kp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Np(){const e=Ip(),t=qn.getAuthToken(),n=Tp();return{apiBaseUrl:Ep(e.baseUrl,qn.baseUrl,n),apiKey:t||e.apiKey||kp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Ap="chat-settings";function pT(){try{const e=localStorage.getItem(Ap);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function mT(e){try{const t={...e,apiBaseUrl:zn(e.apiBaseUrl)};localStorage.setItem(Ap,JSON.stringify(t)),t.apiKey&&qn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function gT(){const e=Np(),t=pT(),n=qn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ep(qn.baseUrl,r,e.apiBaseUrl)}}function yT(e){qn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),mT(e)}var xT="Label",_p=g.forwardRef((e,t)=>d.jsx(Ae.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));_p.displayName=xT;var jp=_p;const vT=Do.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fn=g.forwardRef(({className:e,...t},n)=>d.jsx(jp,{ref:n,className:te(vT(),e),...t}));fn.displayName=jp.displayName;function Rp(e){const t=g.useRef({value:e,previous:e});return g.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pi="Switch",[wT,Gk]=An(pi),[bT,ST]=wT(pi),Pp=g.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=g.useState(null),x=We(t,S=>p(S)),y=g.useRef(!1),v=h?u||!!h.closest("form"):!0,[m,w]=vr({prop:o,defaultProp:s??!1,onChange:c,caller:pi});return d.jsxs(bT,{scope:n,checked:m,disabled:a,children:[d.jsx(Ae.button,{type:"button",role:"switch","aria-checked":m,"aria-required":i,"data-state":Lp(m),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:x,onClick:ge(e.onClick,S=>{w(k=>!k),v&&(y.current=S.isPropagationStopped(),y.current||S.stopPropagation())})}),v&&d.jsx(Dp,{control:h,bubbles:!y.current,name:r,value:l,checked:m,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});Pp.displayName=pi;var Op="SwitchThumb",Mp=g.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=ST(Op,n);return d.jsx(Ae.span,{"data-state":Lp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Mp.displayName=Op;var CT="SwitchBubbleInput",Dp=g.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=g.useRef(null),a=We(i,s),l=Rp(n),c=Vf(t);return g.useEffect(()=>{const u=i.current;if(!u)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const x=new Event("click",{bubbles:r});p.call(u,n),u.dispatchEvent(x)}},[l,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Dp.displayName=CT;function Lp(e){return e?"checked":"unchecked"}var Fp=Pp,TT=Mp;const rr=g.forwardRef(({className:e,...t},n)=>d.jsx(Fp,{className:te("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:d.jsx(TT,{className:te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));rr.displayName=Fp.displayName;var $p=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"}),kT="VisuallyHidden",ET=g.forwardRef((e,t)=>d.jsx(Ae.span,{...e,ref:t,style:{...$p,...e.style}}));ET.displayName=kT;var IT=[" ","Enter","ArrowUp","ArrowDown"],NT=[" ","Enter"],Er="Select",[mi,gi,AT]=Ka(Er),[Vr,Yk]=An(Er,[AT,ni]),yi=ni(),[_T,or]=Vr(Er),[jT,RT]=Vr(Er),zp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:f,disabled:h,required:p,form:x}=e,y=yi(t),[v,m]=g.useState(null),[w,S]=g.useState(null),[k,T]=g.useState(!1),C=Vs(c),[E,P]=vr({prop:r,defaultProp:o??!1,onChange:s,caller:Er}),[_,j]=vr({prop:i,defaultProp:a,onChange:l,caller:Er}),D=g.useRef(null),B=v?x||!!v.closest("form"):!0,[F,O]=g.useState(new Set),$=Array.from(F).map(R=>R.props.value).join(";");return d.jsx(th,{...y,children:d.jsxs(_T,{required:p,scope:t,trigger:v,onTriggerChange:m,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:_n(),value:_,onValueChange:j,open:E,onOpenChange:P,dir:C,triggerPointerDownPosRef:D,disabled:h,children:[d.jsx(mi.Provider,{scope:t,children:d.jsx(jT,{scope:e.__scopeSelect,onNativeOptionAdd:g.useCallback(R=>{O(W=>new Set(W).add(R))},[]),onNativeOptionRemove:g.useCallback(R=>{O(W=>{const U=new Set(W);return U.delete(R),U})},[]),children:n})}),B?d.jsxs(um,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:f,value:_,onChange:R=>j(R.target.value),disabled:h,form:x,children:[_===void 0?d.jsx("option",{value:""}):null,Array.from(F)]},$):null]})})};zp.displayName=Er;var Bp="SelectTrigger",Hp=g.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=yi(n),i=or(Bp,n),a=i.disabled||r,l=We(t,i.onTriggerChange),c=gi(n),u=g.useRef("touch"),[f,h,p]=fm(y=>{const v=c().filter(S=>!S.disabled),m=v.find(S=>S.value===i.value),w=hm(v,y,m);w!==void 0&&i.onValueChange(w.value)}),x=y=>{a||(i.onOpenChange(!0),p()),y&&(i.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return d.jsx(nh,{asChild:!0,...s,children:d.jsx(Ae.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":dm(i.value)?"":void 0,...o,ref:l,onClick:ge(o.onClick,y=>{y.currentTarget.focus(),u.current!=="mouse"&&x(y)}),onPointerDown:ge(o.onPointerDown,y=>{u.current=y.pointerType;const v=y.target;v.hasPointerCapture(y.pointerId)&&v.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(x(y),y.preventDefault())}),onKeyDown:ge(o.onKeyDown,y=>{const v=f.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&h(y.key),!(v&&y.key===" ")&&IT.includes(y.key)&&(x(),y.preventDefault())})})})});Hp.displayName=Bp;var Up="SelectValue",Wp=g.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=or(Up,n),{onValueNodeHasChildrenChange:c}=l,u=s!==void 0,f=We(t,l.onValueNodeChange);return Pt(()=>{c(u)},[c,u]),d.jsx(Ae.span,{...a,ref:f,style:{pointerEvents:"none"},children:dm(l.value)?d.jsx(d.Fragment,{children:i}):s})});Wp.displayName=Up;var PT="SelectIcon",Vp=g.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return d.jsx(Ae.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Vp.displayName=PT;var OT="SelectPortal",Kp=e=>d.jsx(ks,{asChild:!0,...e});Kp.displayName=OT;var Ir="SelectContent",qp=g.forwardRef((e,t)=>{const n=or(Ir,e.__scopeSelect),[r,o]=g.useState();if(Pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Lo.createPortal(d.jsx(Gp,{scope:e.__scopeSelect,children:d.jsx(mi.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(Yp,{...e,ref:t})});qp.displayName=Ir;var Sn=10,[Gp,sr]=Vr(Ir),MT="SelectContentImpl",DT=ur.createSlot("SelectContent.RemoveScroll"),Yp=g.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:x,hideWhenDetached:y,avoidCollisions:v,...m}=e,w=or(Ir,n),[S,k]=g.useState(null),[T,C]=g.useState(null),E=We(t,ee=>k(ee)),[P,_]=g.useState(null),[j,D]=g.useState(null),B=gi(n),[F,O]=g.useState(!1),$=g.useRef(!1);g.useEffect(()=>{if(S)return Fa(S)},[S]),Ra();const R=g.useCallback(ee=>{const[L,...Q]=B().map(de=>de.ref.current),[ue]=Q.slice(-1),ye=document.activeElement;for(const de of ee)if(de===ye||(de==null||de.scrollIntoView({block:"nearest"}),de===L&&T&&(T.scrollTop=0),de===ue&&T&&(T.scrollTop=T.scrollHeight),de==null||de.focus(),document.activeElement!==ye))return},[B,T]),W=g.useCallback(()=>R([P,S]),[R,P,S]);g.useEffect(()=>{F&&W()},[F,W]);const{onOpenChange:U,triggerPointerDownPosRef:z}=w;g.useEffect(()=>{if(S){let ee={x:0,y:0};const L=ue=>{var ye,de;ee={x:Math.abs(Math.round(ue.pageX)-(((ye=z.current)==null?void 0:ye.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((de=z.current)==null?void 0:de.y)??0))}},Q=ue=>{ee.x<=10&&ee.y<=10?ue.preventDefault():S.contains(ue.target)||U(!1),document.removeEventListener("pointermove",L),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Q,{capture:!0})}}},[S,U,z]),g.useEffect(()=>{const ee=()=>U(!1);return window.addEventListener("blur",ee),window.addEventListener("resize",ee),()=>{window.removeEventListener("blur",ee),window.removeEventListener("resize",ee)}},[U]);const[ie,X]=fm(ee=>{const L=B().filter(ye=>!ye.disabled),Q=L.find(ye=>ye.ref.current===document.activeElement),ue=hm(L,ee,Q);ue&&setTimeout(()=>ue.ref.current.focus())}),ae=g.useCallback((ee,L,Q)=>{const ue=!$.current&&!Q;(w.value!==void 0&&w.value===L||ue)&&(_(ee),ue&&($.current=!0))},[w.value]),we=g.useCallback(()=>S==null?void 0:S.focus(),[S]),V=g.useCallback((ee,L,Q)=>{const ue=!$.current&&!Q;(w.value!==void 0&&w.value===L||ue)&&D(ee)},[w.value]),le=r==="popper"?Cl:Xp,xe=le===Cl?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:x,hideWhenDetached:y,avoidCollisions:v}:{};return d.jsx(Gp,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:ae,selectedItem:P,onItemLeave:we,itemTextRefCallback:V,focusSelectedItem:W,selectedItemText:j,position:r,isPositioned:F,searchRef:ie,children:d.jsx(js,{as:DT,allowPinchZoom:!0,children:d.jsx(Ts,{asChild:!0,trapped:w.open,onMountAutoFocus:ee=>{ee.preventDefault()},onUnmountAutoFocus:ge(o,ee=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),ee.preventDefault()}),children:d.jsx(Cs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:ee=>ee.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:d.jsx(le,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:ee=>ee.preventDefault(),...m,...xe,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...m.style},onKeyDown:ge(m.onKeyDown,ee=>{const L=ee.ctrlKey||ee.altKey||ee.metaKey;if(ee.key==="Tab"&&ee.preventDefault(),!L&&ee.key.length===1&&X(ee.key),["ArrowUp","ArrowDown","Home","End"].includes(ee.key)){let ue=B().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(ee.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(ee.key)){const ye=ee.target,de=ue.indexOf(ye);ue=ue.slice(de+1)}setTimeout(()=>R(ue)),ee.preventDefault()}})})})})})})});Yp.displayName=MT;var LT="SelectItemAlignedPosition",Xp=g.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=or(Ir,n),i=sr(Ir,n),[a,l]=g.useState(null),[c,u]=g.useState(null),f=We(t,E=>u(E)),h=gi(n),p=g.useRef(!1),x=g.useRef(!0),{viewport:y,selectedItem:v,selectedItemText:m,focusSelectedItem:w}=i,S=g.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&y&&v&&m){const E=s.trigger.getBoundingClientRect(),P=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),j=m.getBoundingClientRect();if(s.dir!=="rtl"){const ye=j.left-P.left,de=_.left-ye,Re=E.left-de,ce=E.width+Re,Ze=Math.max(ce,P.width),it=window.innerWidth-Sn,ft=yl(de,[Sn,Math.max(Sn,it-Ze)]);a.style.minWidth=ce+"px",a.style.left=ft+"px"}else{const ye=P.right-j.right,de=window.innerWidth-_.right-ye,Re=window.innerWidth-E.right-de,ce=E.width+Re,Ze=Math.max(ce,P.width),it=window.innerWidth-Sn,ft=yl(de,[Sn,Math.max(Sn,it-Ze)]);a.style.minWidth=ce+"px",a.style.right=ft+"px"}const D=h(),B=window.innerHeight-Sn*2,F=y.scrollHeight,O=window.getComputedStyle(c),$=parseInt(O.borderTopWidth,10),R=parseInt(O.paddingTop,10),W=parseInt(O.borderBottomWidth,10),U=parseInt(O.paddingBottom,10),z=$+R+F+U+W,ie=Math.min(v.offsetHeight*5,z),X=window.getComputedStyle(y),ae=parseInt(X.paddingTop,10),we=parseInt(X.paddingBottom,10),V=E.top+E.height/2-Sn,le=B-V,xe=v.offsetHeight/2,ee=v.offsetTop+xe,L=$+R+ee,Q=z-L;if(L<=V){const ye=D.length>0&&v===D[D.length-1].ref.current;a.style.bottom="0px";const de=c.clientHeight-y.offsetTop-y.offsetHeight,Re=Math.max(le,xe+(ye?we:0)+de+W),ce=L+Re;a.style.height=ce+"px"}else{const ye=D.length>0&&v===D[0].ref.current;a.style.top="0px";const Re=Math.max(V,$+y.offsetTop+(ye?ae:0)+xe)+Q;a.style.height=Re+"px",y.scrollTop=L-V+y.offsetTop}a.style.margin=`${Sn}px 0`,a.style.minHeight=ie+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,y,v,m,s.dir,r]);Pt(()=>S(),[S]);const[k,T]=g.useState();Pt(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=g.useCallback(E=>{E&&x.current===!0&&(S(),w==null||w(),x.current=!1)},[S,w]);return d.jsx($T,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:d.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:d.jsx(Ae.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Xp.displayName=LT;var FT="SelectPopperPosition",Cl=g.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Sn,...s}=e,i=yi(n);return d.jsx(rh,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Cl.displayName=FT;var[$T,Tl]=Vr(Ir,{}),kl="SelectViewport",Jp=g.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=sr(kl,n),i=Tl(kl,n),a=We(t,s.onViewportChange),l=g.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),d.jsx(mi.Slot,{scope:n,children:d.jsx(Ae.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ge(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-u.scrollTop);if(p>0){const x=window.innerHeight-Sn*2,y=parseFloat(f.style.minHeight),v=parseFloat(f.style.height),m=Math.max(y,v);if(m<x){const w=m+p,S=Math.min(x,w),k=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(u.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});Jp.displayName=kl;var Zp="SelectGroup",[zT,BT]=Vr(Zp),HT=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_n();return d.jsx(zT,{scope:n,id:o,children:d.jsx(Ae.div,{role:"group","aria-labelledby":o,...r,ref:t})})});HT.displayName=Zp;var Qp="SelectLabel",em=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=BT(Qp,n);return d.jsx(Ae.div,{id:o.id,...r,ref:t})});em.displayName=Qp;var xi="SelectItem",[UT,tm]=Vr(xi),nm=g.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=or(xi,n),l=sr(xi,n),c=a.value===r,[u,f]=g.useState(s??""),[h,p]=g.useState(!1),x=We(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),y=_n(),v=g.useRef("touch"),m=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(UT,{scope:n,value:r,disabled:o,textId:y,isSelected:c,onItemTextChange:g.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:d.jsx(mi.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:d.jsx(Ae.div,{role:"option","aria-labelledby":y,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:ge(i.onFocus,()=>p(!0)),onBlur:ge(i.onBlur,()=>p(!1)),onClick:ge(i.onClick,()=>{v.current!=="mouse"&&m()}),onPointerUp:ge(i.onPointerUp,()=>{v.current==="mouse"&&m()}),onPointerDown:ge(i.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:ge(i.onPointerMove,w=>{var S;v.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ge(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ge(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(NT.includes(w.key)&&m(),w.key===" "&&w.preventDefault())})})})})});nm.displayName=xi;var jo="SelectItemText",rm=g.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=or(jo,n),a=sr(jo,n),l=tm(jo,n),c=RT(jo,n),[u,f]=g.useState(null),h=We(t,m=>f(m),l.onItemTextChange,m=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,m,l.value,l.disabled)}),p=u==null?void 0:u.textContent,x=g.useMemo(()=>d.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:y,onNativeOptionRemove:v}=c;return Pt(()=>(y(x),()=>v(x)),[y,v,x]),d.jsxs(d.Fragment,{children:[d.jsx(Ae.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Lo.createPortal(s.children,i.valueNode):null]})});rm.displayName=jo;var om="SelectItemIndicator",sm=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return tm(om,n).isSelected?d.jsx(Ae.span,{"aria-hidden":!0,...r,ref:t}):null});sm.displayName=om;var El="SelectScrollUpButton",im=g.forwardRef((e,t)=>{const n=sr(El,e.__scopeSelect),r=Tl(El,e.__scopeSelect),[o,s]=g.useState(!1),i=We(t,r.onScrollButtonChange);return Pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});im.displayName=El;var Il="SelectScrollDownButton",am=g.forwardRef((e,t)=>{const n=sr(Il,e.__scopeSelect),r=Tl(Il,e.__scopeSelect),[o,s]=g.useState(!1),i=We(t,r.onScrollButtonChange);return Pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});am.displayName=Il;var lm=g.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=sr("SelectScrollButton",n),i=g.useRef(null),a=gi(n),l=g.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return g.useEffect(()=>()=>l(),[l]),Pt(()=>{var u;const c=a().find(f=>f.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),d.jsx(Ae.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ge(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ge(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ge(o.onPointerLeave,()=>{l()})})}),WT="SelectSeparator",cm=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return d.jsx(Ae.div,{"aria-hidden":!0,...r,ref:t})});cm.displayName=WT;var Nl="SelectArrow",VT=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yi(n),s=or(Nl,n),i=sr(Nl,n);return s.open&&i.position==="popper"?d.jsx(oh,{...o,...r,ref:t}):null});VT.displayName=Nl;var KT="SelectBubbleInput",um=g.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=g.useRef(null),s=We(r,o),i=Rp(t);return g.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&u){const f=new Event("change",{bubbles:!0});u.call(a,t),a.dispatchEvent(f)}},[i,t]),d.jsx(Ae.select,{...n,style:{...$p,...n.style},ref:s,defaultValue:t})});um.displayName=KT;function dm(e){return e===""||e===void 0}function fm(e){const t=Mt(e),n=g.useRef(""),r=g.useRef(0),o=g.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function hm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=qT(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function qT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var GT=zp,pm=Hp,YT=Wp,XT=Vp,JT=Kp,mm=qp,ZT=Jp,gm=em,ym=nm,QT=rm,ek=sm,xm=im,vm=am,wm=cm;const bm=GT,Sm=YT,Al=g.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(pm,{ref:r,className:te("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,d.jsx(XT,{asChild:!0,children:d.jsx(he.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Al.displayName=pm.displayName;const Cm=g.forwardRef(({className:e,...t},n)=>d.jsx(xm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(he.ChevronUp,{className:"h-4 w-4"})}));Cm.displayName=xm.displayName;const Tm=g.forwardRef(({className:e,...t},n)=>d.jsx(vm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(he.ChevronDown,{className:"h-4 w-4"})}));Tm.displayName=vm.displayName;const _l=g.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>d.jsx(JT,{children:d.jsxs(mm,{ref:o,className:te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[d.jsx(Cm,{}),d.jsx(ZT,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(Tm,{})]})}));_l.displayName=mm.displayName;const tk=g.forwardRef(({className:e,...t},n)=>d.jsx(gm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));tk.displayName=gm.displayName;const Nr=g.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(ym,{ref:r,className:te("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(ek,{children:d.jsx(he.Check,{className:"h-4 w-4"})})}),d.jsx(QT,{children:t})]}));Nr.displayName=ym.displayName;const nk=g.forwardRef(({className:e,...t},n)=>d.jsx(wm,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));nk.displayName=wm.displayName;var rk="Separator",km="horizontal",ok=["horizontal","vertical"],Em=g.forwardRef((e,t)=>{const{decorative:n,orientation:r=km,...o}=e,s=sk(r)?r:km,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(Ae.div,{"data-orientation":s,...a,...o,ref:t})});Em.displayName=rk;function sk(e){return ok.includes(e)}var Im=Em;const Nm=g.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>d.jsx(Im,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Nm.displayName=Im.displayName;const ik=Jd,ak=Eb,lk=Zd,Am=g.forwardRef(({className:e,...t},n)=>d.jsx(Ds,{className:te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Am.displayName=Ds.displayName;const ck=Do.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),_m=g.forwardRef(({side:e="right",className:t,children:n,...r},o)=>d.jsxs(lk,{children:[d.jsx(Am,{}),d.jsxs(Ls,{ref:o,className:te(ck({side:e}),t),...r,children:[n,d.jsxs(Qd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[d.jsx(he.X,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_m.displayName=Ls.displayName;const jm=({className:e,...t})=>d.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});jm.displayName="SheetHeader";const Rm=g.forwardRef(({className:e,...t},n)=>d.jsx(br,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));Rm.displayName=br.displayName;const Pm=g.forwardRef(({className:e,...t},n)=>d.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));Pm.displayName=Fs.displayName;const uk={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function dk({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,u]=b.useState(!1),{toast:f}=Ea();b.useEffect(()=>{const v=JSON.stringify(a)!==JSON.stringify(e);u(v)},[a,e]),b.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),u(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(uk),u(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},x=()=>{l(e),u(!1),o(!1)},y=async()=>{try{const m=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${m.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return d.jsxs(ik,{open:r,onOpenChange:o,children:[d.jsx(ak,{asChild:!0,children:d.jsxs(nt,{variant:"outline",size:"sm",className:n,children:[d.jsx(he.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&d.jsx(ed,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),d.jsxs(_m,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[d.jsxs(jm,{children:[d.jsx(Rm,{children:"Chat Settings"}),d.jsx(Pm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),d.jsxs("div",{className:"space-y-6 py-6",children:[d.jsxs(po,{children:[d.jsx(mo,{className:"pb-3",children:d.jsxs(go,{className:"text-lg flex items-center gap-2",children:[d.jsx(he.Server,{className:"h-5 w-5"}),"API Configuration"]})}),d.jsxs(yo,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(fn,{htmlFor:"api-url",children:"API Base URL"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(ci,{id:"api-url",value:a.api.baseUrl,onChange:v=>l(m=>({...m,api:{...m.api,baseUrl:v.target.value}})),placeholder:"http://localhost:8000/api"}),d.jsx(nt,{variant:"outline",onClick:y,children:"Test"})]})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(fn,{htmlFor:"enable-auth",children:"Enable Authentication"}),d.jsx(rr,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:v=>l(m=>({...m,api:{...m.api,enableAuth:v}}))})]}),a.api.enableAuth&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(fn,{htmlFor:"auth-token",children:"Authentication Token"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(ci,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:v=>l(m=>({...m,api:{...m.api,authToken:v.target.value}})),placeholder:"Enter your Bearer token"}),d.jsx(nt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?d.jsx(he.EyeOff,{className:"h-4 w-4"}):d.jsx(he.Eye,{className:"h-4 w-4"})})]})]})]})]}),d.jsxs(po,{children:[d.jsx(mo,{className:"pb-3",children:d.jsxs(go,{className:"text-lg flex items-center gap-2",children:[d.jsx(he.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),d.jsxs(yo,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(fn,{htmlFor:"layout",children:"Layout Style"}),d.jsxs(bm,{value:a.ui.layout,onValueChange:v=>l(m=>({...m,ui:{...m.ui,layout:v}})),children:[d.jsx(Al,{children:d.jsx(Sm,{})}),d.jsxs(_l,{children:[d.jsx(Nr,{value:"sidebar",children:"Sidebar Layout"}),d.jsx(Nr,{value:"fullscreen",children:"Fullscreen"}),d.jsx(Nr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(fn,{htmlFor:"theme",children:"Theme"}),d.jsxs(bm,{value:a.ui.theme,onValueChange:v=>l(m=>({...m,ui:{...m.ui,theme:v}})),children:[d.jsx(Al,{children:d.jsx(Sm,{})}),d.jsxs(_l,{children:[d.jsx(Nr,{value:"light",children:"Light"}),d.jsx(Nr,{value:"dark",children:"Dark"}),d.jsx(Nr,{value:"system",children:"System"})]})]})]}),d.jsx(Nm,{}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(fn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),d.jsx(rr,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:v=>l(m=>({...m,ui:{...m.ui,showTimestamps:v}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(fn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),d.jsx(rr,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:v=>l(m=>({...m,ui:{...m.ui,showAgentNames:v}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(fn,{htmlFor:"compact-messages",children:"Compact Messages"}),d.jsx(rr,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:v=>l(m=>({...m,ui:{...m.ui,compactMessages:v}}))})]})]})]})]}),d.jsxs(po,{children:[d.jsx(mo,{className:"pb-3",children:d.jsxs(go,{className:"text-lg flex items-center gap-2",children:[d.jsx(he.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),d.jsxs(yo,{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(fn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),d.jsx(rr,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:v=>l(m=>({...m,behavior:{...m.behavior,autoSave:v}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(fn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),d.jsx(rr,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:v=>l(m=>({...m,behavior:{...m.behavior,enableStreaming:v}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(fn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),d.jsx(rr,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:v=>l(m=>({...m,behavior:{...m.behavior,showTypingIndicator:v}}))})]})]})]})]}),d.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[d.jsxs(nt,{variant:"outline",onClick:p,children:[d.jsx(he.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(nt,{variant:"outline",onClick:x,children:"Cancel"}),d.jsxs(nt,{onClick:h,disabled:!c,children:[d.jsx(he.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function fk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const u="h-full";switch(c){case"phone":return`${u} max-w-none`;case"tablet":return`${u} max-w-4xl mx-auto`;case"half-screen":return`${u} max-w-2xl`;case"desktop":default:return`${u} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var u;(u=s.onThreadChange)==null||u.call(s,c)},[s]);return e==="fullscreen"?d.jsx(os,{...s,onThreadChange:l,children:d.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:d.jsx(li,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?d.jsx(os,{...s,onThreadChange:l,children:d.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:d.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&d.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:d.jsx(Sl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),d.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:d.jsx(li,{onError:s.onError,enableFileUpload:!0})})]})})}):d.jsx(os,{...s,onThreadChange:l,children:d.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&d.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:d.jsx(Sl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),d.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:d.jsx(li,{onError:s.onError,enableFileUpload:!0})})]})})}_e.ChatApi=Ac,_e.ChatInterface=li,_e.ChatProviders=os,_e.ChatSettings=dk,_e.MarkdownContent=bo,_e.MessageComponent=Wa,_e.MessageList=Va,_e.ThreadManager=Sl,_e.applySettings=yT,_e.chatApiClient=qn,_e.default=fk,_e.del=Nc,_e.get=mn,_e.getChatToken=kc,_e.getCurrentSettings=gT,_e.getDefaultApiConfig=Ip,_e.getDefaultChatSettings=Np,_e.onChatTokenChanged=Ec,_e.post=Oi,_e.put=Ic,_e.setChatToken=Pi,_e.useApi=Mi,_e.useChatStream=Wc,_e.useMessagesReducer=Dc,_e.useStream=eu,_e.useThreadState=rs,_e.useThreads=ns,Object.defineProperties(_e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
137
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function o0(e,t=Ws){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function s0(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),o0(t),r0(t)}function Ka(e){const t=e+"CollectionProvider",[n,r]=An(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=y=>{const{scope:v,children:m}=y,w=b.useRef(null),S=b.useRef(new Map).current;return d.jsx(o,{scope:v,itemMap:S,collectionRef:w,children:m})};i.displayName=t;const a=e+"CollectionSlot",l=ur.createSlot(a),c=b.forwardRef((y,v)=>{const{scope:m,children:w}=y,S=s(a,m),k=We(v,S.collectionRef);return d.jsx(l,{ref:k,children:w})});c.displayName=a;const u=e+"CollectionItemSlot",f="data-radix-collection-item",h=ur.createSlot(u),p=b.forwardRef((y,v)=>{const{scope:m,children:w,...S}=y,k=b.useRef(null),T=We(v,k),C=s(u,m);return b.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),d.jsx(h,{[f]:"",ref:T,children:w})});p.displayName=u;function x(y){const v=s(e+"CollectionConsumer",y);return b.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},x,r]}var i0=g.createContext(void 0);function Vs(e){const t=g.useContext(i0);return e||t||"ltr"}const a0=["top","right","bottom","left"],tr=Math.min,rn=Math.max,Ks=Math.round,qs=Math.floor,Rn=e=>({x:e,y:e}),l0={left:"right",right:"left",bottom:"top",top:"bottom"},c0={start:"end",end:"start"};function qa(e,t,n){return rn(e,tr(t,n))}function Hn(e,t){return typeof e=="function"?e(t):e}function Un(e){return e.split("-")[0]}function $r(e){return e.split("-")[1]}function Ga(e){return e==="x"?"y":"x"}function Ya(e){return e==="y"?"height":"width"}const u0=new Set(["top","bottom"]);function Pn(e){return u0.has(Un(e))?"y":"x"}function Xa(e){return Ga(Pn(e))}function d0(e,t,n){n===void 0&&(n=!1);const r=$r(e),o=Xa(e),s=Ya(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Gs(i)),[i,Gs(i)]}function f0(e){const t=Gs(e);return[Ja(e),t,Ja(t)]}function Ja(e){return e.replace(/start|end/g,t=>c0[t])}const Sf=["left","right"],Cf=["right","left"],h0=["top","bottom"],p0=["bottom","top"];function m0(e,t,n){switch(e){case"top":case"bottom":return n?t?Cf:Sf:t?Sf:Cf;case"left":case"right":return t?h0:p0;default:return[]}}function g0(e,t,n,r){const o=$r(e);let s=m0(Un(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ja)))),s}function Gs(e){return e.replace(/left|right|bottom|top/g,t=>l0[t])}function y0(e){return{top:0,right:0,bottom:0,left:0,...e}}function Tf(e){return typeof e!="number"?y0(e):{top:e,right:e,bottom:e,left:e}}function Ys(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function kf(e,t,n){let{reference:r,floating:o}=e;const s=Pn(t),i=Xa(t),a=Ya(i),l=Un(t),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch($r(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const x0=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=kf(c,r,l),h=r,p={},x=0;for(let y=0;y<a.length;y++){const{name:v,fn:m}=a[y],{x:w,y:S,data:k,reset:T}=await m({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});u=w??u,f=S??f,p={...p,[v]:{...p[v],...k}},T&&x<=50&&(x++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:u,y:f}=kf(c,h,l)),y=-1)}return{x:u,y:f,placement:h,strategy:o,middlewareData:p}};async function So(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Hn(t,e),x=Tf(p),v=a[h?f==="floating"?"reference":"floating":f],m=Ys(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Ys(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(m.top-T.top+x.top)/k.y,bottom:(T.bottom-m.bottom+x.bottom)/k.y,left:(m.left-T.left+x.left)/k.x,right:(T.right-m.right+x.right)/k.x}}const v0=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Hn(e,t)||{};if(c==null)return{};const f=Tf(u),h={x:n,y:r},p=Xa(o),x=Ya(p),y=await i.getDimensions(c),v=p==="y",m=v?"top":"left",w=v?"bottom":"right",S=v?"clientHeight":"clientWidth",k=s.reference[x]+s.reference[p]-h[p]-s.floating[x],T=h[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[x]);const P=k/2-T/2,_=E/2-y[x]/2-1,j=tr(f[m],_),D=tr(f[w],_),B=j,F=E-y[x]-D,O=E/2-y[x]/2+P,$=qa(B,O,F),R=!l.arrow&&$r(o)!=null&&O!==$&&s.reference[x]/2-(O<B?j:D)-y[x]/2<0,W=R?O<B?O-B:O-F:0;return{[p]:h[p]+W,data:{[p]:$,centerOffset:O-$-W,...R&&{alignmentOffset:W}},reset:R}}}),w0=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:y=!0,...v}=Hn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const m=Un(o),w=Pn(a),S=Un(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=h||(S||!y?[Gs(a)]:f0(a)),C=x!=="none";!h&&C&&T.push(...g0(a,y,x,k));const E=[a,...T],P=await So(t,v),_=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&_.push(P[m]),f){const O=d0(o,i,k);_.push(P[O[0]],P[O[1]])}if(j=[...j,{placement:o,overflows:_}],!_.every(O=>O<=0)){var D,B;const O=(((D=s.flip)==null?void 0:D.index)||0)+1,$=E[O];if($&&(!(f==="alignment"?w!==Pn($):!1)||j.every(U=>Pn(U.placement)===w?U.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:$}};let R=(B=j.filter(W=>W.overflows[0]<=0).sort((W,U)=>W.overflows[1]-U.overflows[1])[0])==null?void 0:B.placement;if(!R)switch(p){case"bestFit":{var F;const W=(F=j.filter(U=>{if(C){const z=Pn(U.placement);return z===w||z==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(z=>z>0).reduce((z,ie)=>z+ie,0)]).sort((U,z)=>U[1]-z[1])[0])==null?void 0:F[0];W&&(R=W);break}case"initialPlacement":R=a;break}if(o!==R)return{reset:{placement:R}}}return{}}}};function Ef(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function If(e){return a0.some(t=>e[t]>=0)}const b0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Hn(e,t);switch(r){case"referenceHidden":{const s=await So(t,{...o,elementContext:"reference"}),i=Ef(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:If(i)}}}case"escaped":{const s=await So(t,{...o,altBoundary:!0}),i=Ef(s,n.floating);return{data:{escapedOffsets:i,escaped:If(i)}}}default:return{}}}}},Nf=new Set(["left","top"]);async function S0(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Un(n),a=$r(n),l=Pn(n)==="y",c=Nf.has(i)?-1:1,u=s&&l?-1:1,f=Hn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof x=="number"&&(p=a==="end"?x*-1:x),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const C0=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await S0(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},T0=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:v=>{let{x:m,y:w}=v;return{x:m,y:w}}},...l}=Hn(e,t),c={x:n,y:r},u=await So(t,l),f=Pn(Un(o)),h=Ga(f);let p=c[h],x=c[f];if(s){const v=h==="y"?"top":"left",m=h==="y"?"bottom":"right",w=p+u[v],S=p-u[m];p=qa(w,p,S)}if(i){const v=f==="y"?"top":"left",m=f==="y"?"bottom":"right",w=x+u[v],S=x-u[m];x=qa(w,x,S)}const y=a.fn({...t,[h]:p,[f]:x});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:s,[f]:i}}}}}},k0=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Hn(e,t),u={x:n,y:r},f=Pn(o),h=Ga(f);let p=u[h],x=u[f];const y=Hn(a,t),v=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const S=h==="y"?"height":"width",k=s.reference[h]-s.floating[S]+v.mainAxis,T=s.reference[h]+s.reference[S]-v.mainAxis;p<k?p=k:p>T&&(p=T)}if(c){var m,w;const S=h==="y"?"width":"height",k=Nf.has(Un(o)),T=s.reference[f]-s.floating[S]+(k&&((m=i.offset)==null?void 0:m[f])||0)+(k?0:v.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?v.crossAxis:0);x<T?x=T:x>C&&(x=C)}return{[h]:p,[f]:x}}}},E0=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=Hn(e,t),u=await So(t,c),f=Un(o),h=$r(o),p=Pn(o)==="y",{width:x,height:y}=s.floating;let v,m;f==="top"||f==="bottom"?(v=f,m=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(m=f,v=h==="end"?"top":"bottom");const w=y-u.top-u.bottom,S=x-u.left-u.right,k=tr(y-u[v],w),T=tr(x-u[m],S),C=!t.middlewareData.shift;let E=k,P=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!h){const j=rn(u.left,0),D=rn(u.right,0),B=rn(u.top,0),F=rn(u.bottom,0);p?P=x-2*(j!==0||D!==0?j+D:rn(u.left,u.right)):E=y-2*(B!==0||F!==0?B+F:rn(u.top,u.bottom))}await l({...t,availableWidth:P,availableHeight:E});const _=await i.getDimensions(a.floating);return x!==_.width||y!==_.height?{reset:{rects:!0}}:{}}}};function Xs(){return typeof window<"u"}function zr(e){return Af(e)?(e.nodeName||"").toLowerCase():"#document"}function on(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function On(e){var t;return(t=(Af(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Af(e){return Xs()?e instanceof Node||e instanceof on(e).Node:!1}function wn(e){return Xs()?e instanceof Element||e instanceof on(e).Element:!1}function Mn(e){return Xs()?e instanceof HTMLElement||e instanceof on(e).HTMLElement:!1}function _f(e){return!Xs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof on(e).ShadowRoot}const I0=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=bn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!I0.has(o)}const N0=new Set(["table","td","th"]);function A0(e){return N0.has(zr(e))}const _0=[":popover-open",":modal"];function Js(e){return _0.some(t=>{try{return e.matches(t)}catch{return!1}})}const j0=["transform","translate","scale","rotate","perspective"],R0=["transform","translate","scale","rotate","perspective","filter"],P0=["paint","layout","strict","content"];function Za(e){const t=Qa(),n=wn(e)?bn(e):e;return j0.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||R0.some(r=>(n.willChange||"").includes(r))||P0.some(r=>(n.contain||"").includes(r))}function O0(e){let t=nr(e);for(;Mn(t)&&!Br(t);){if(Za(t))return t;if(Js(t))return null;t=nr(t)}return null}function Qa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const M0=new Set(["html","body","#document"]);function Br(e){return M0.has(zr(e))}function bn(e){return on(e).getComputedStyle(e)}function Zs(e){return wn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nr(e){if(zr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_f(e)&&e.host||On(e);return _f(t)?t.host:t}function jf(e){const t=nr(e);return Br(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mn(t)&&Co(t)?t:jf(t)}function To(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=jf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=on(o);if(s){const a=el(i);return t.concat(i,i.visualViewport||[],Co(o)?o:[],a&&n?To(a):[])}return t.concat(o,To(o,[],n))}function el(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Rf(e){const t=bn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Mn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ks(n)!==s||Ks(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function tl(e){return wn(e)?e:e.contextElement}function Hr(e){const t=tl(e);if(!Mn(t))return Rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Rf(t);let i=(s?Ks(n.width):n.width)/r,a=(s?Ks(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const D0=Rn(0);function Pf(e){const t=on(e);return!Qa()||!t.visualViewport?D0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function L0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==on(e)?!1:t}function Cr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=tl(e);let i=Rn(1);t&&(r?wn(r)&&(i=Hr(r)):i=Hr(e));const a=L0(s,n,r)?Pf(s):Rn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const h=on(s),p=r&&wn(r)?on(r):r;let x=h,y=el(x);for(;y&&r&&p!==x;){const v=Hr(y),m=y.getBoundingClientRect(),w=bn(y),S=m.left+(y.clientLeft+parseFloat(w.paddingLeft))*v.x,k=m.top+(y.clientTop+parseFloat(w.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,f*=v.y,l+=S,c+=k,x=on(y),y=el(x)}}return Ys({width:u,height:f,x:l,y:c})}function Qs(e,t){const n=Zs(e).scrollLeft;return t?t.left+n:Cr(On(e)).left+n}function Of(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Qs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function F0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=On(r),a=t?Js(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Rn(1);const u=Rn(0),f=Mn(r);if((f||!f&&!s)&&((zr(r)!=="body"||Co(i))&&(l=Zs(r)),Mn(r))){const p=Cr(r);c=Hr(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=i&&!f&&!s?Of(i,l):Rn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function $0(e){return Array.from(e.getClientRects())}function z0(e){const t=On(e),n=Zs(e),r=e.ownerDocument.body,o=rn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=rn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Qs(e);const a=-n.scrollTop;return bn(r).direction==="rtl"&&(i+=rn(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Mf=25;function B0(e,t){const n=on(e),r=On(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Qa();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Qs(r);if(c<=0){const u=r.ownerDocument,f=u.body,h=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,x=Math.abs(r.clientWidth-f.clientWidth-p);x<=Mf&&(s-=x)}else c<=Mf&&(s+=c);return{width:s,height:i,x:a,y:l}}const H0=new Set(["absolute","fixed"]);function U0(e,t){const n=Cr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Mn(e)?Hr(e):Rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Df(e,t,n){let r;if(t==="viewport")r=B0(e,n);else if(t==="document")r=z0(On(e));else if(wn(t))r=U0(t,n);else{const o=Pf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ys(r)}function Lf(e,t){const n=nr(e);return n===t||!wn(n)||Br(n)?!1:bn(n).position==="fixed"||Lf(n,t)}function W0(e,t){const n=t.get(e);if(n)return n;let r=To(e,[],!1).filter(a=>wn(a)&&zr(a)!=="body"),o=null;const s=bn(e).position==="fixed";let i=s?nr(e):e;for(;wn(i)&&!Br(i);){const a=bn(i),l=Za(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&H0.has(o.position)||Co(i)&&!l&&Lf(e,i))?r=r.filter(u=>u!==i):o=a,i=nr(i)}return t.set(e,r),r}function V0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Js(t)?[]:W0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=Df(t,u,o);return c.top=rn(f.top,c.top),c.right=tr(f.right,c.right),c.bottom=tr(f.bottom,c.bottom),c.left=rn(f.left,c.left),c},Df(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function K0(e){const{width:t,height:n}=Rf(e);return{width:t,height:n}}function q0(e,t,n){const r=Mn(t),o=On(t),s=n==="fixed",i=Cr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Rn(0);function c(){l.x=Qs(o)}if(r||!r&&!s)if((zr(t)!=="body"||Co(o))&&(a=Zs(t)),r){const p=Cr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?Of(o,a):Rn(0),f=i.left+a.scrollLeft-l.x-u.x,h=i.top+a.scrollTop-l.y-u.y;return{x:f,y:h,width:i.width,height:i.height}}function nl(e){return bn(e).position==="static"}function Ff(e,t){if(!Mn(e)||bn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return On(e)===n&&(n=n.ownerDocument.body),n}function $f(e,t){const n=on(e);if(Js(e))return n;if(!Mn(e)){let o=nr(e);for(;o&&!Br(o);){if(wn(o)&&!nl(o))return o;o=nr(o)}return n}let r=Ff(e,t);for(;r&&A0(r)&&nl(r);)r=Ff(r,t);return r&&Br(r)&&nl(r)&&!Za(r)?n:r||O0(e)||n}const G0=async function(e){const t=this.getOffsetParent||$f,n=this.getDimensions,r=await n(e.floating);return{reference:q0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Y0(e){return bn(e).direction==="rtl"}const X0={convertOffsetParentRelativeRectToViewportRelativeRect:F0,getDocumentElement:On,getClippingRect:V0,getOffsetParent:$f,getElementRects:G0,getClientRects:$0,getDimensions:K0,getScale:Hr,isElement:wn,isRTL:Y0};function zf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function J0(e,t){let n=null,r;const o=On(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const x=qs(f),y=qs(o.clientWidth-(u+h)),v=qs(o.clientHeight-(f+p)),m=qs(u),S={rootMargin:-x+"px "+-y+"px "+-v+"px "+-m+"px",threshold:rn(0,tr(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!zf(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function Z0(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=tl(e),u=o||s?[...c?To(c):[],...To(t)]:[];u.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});const f=c&&a?J0(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(m=>{let[w]=m;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let x,y=l?Cr(e):null;l&&v();function v(){const m=Cr(e);y&&!zf(y,m)&&n(),y=m,x=requestAnimationFrame(v)}return n(),()=>{var m;u.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(m=p)==null||m.disconnect(),p=null,l&&cancelAnimationFrame(x)}}const Q0=C0,eS=T0,tS=w0,nS=E0,rS=b0,Bf=v0,oS=k0,sS=(e,t,n)=>{const r=new Map,o={platform:X0,...n},s={...o.platform,_c:r};return x0(e,t,{...o,platform:s})};var iS=typeof document<"u",aS=function(){},ei=iS?b.useLayoutEffect:aS;function ti(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 n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ti(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!ti(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Hf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Uf(e,t){const n=Hf(e);return Math.round(t*n)/n}function rl(e){const t=g.useRef(e);return ei(()=>{t.current=e}),t}function lS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,f]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=g.useState(r);ti(h,r)||p(r);const[x,y]=g.useState(null),[v,m]=g.useState(null),w=g.useCallback(U=>{U!==C.current&&(C.current=U,y(U))},[]),S=g.useCallback(U=>{U!==E.current&&(E.current=U,m(U))},[]),k=s||x,T=i||v,C=g.useRef(null),E=g.useRef(null),P=g.useRef(u),_=l!=null,j=rl(l),D=rl(o),B=rl(c),F=g.useCallback(()=>{if(!C.current||!E.current)return;const U={placement:t,strategy:n,middleware:h};D.current&&(U.platform=D.current),sS(C.current,E.current,U).then(z=>{const ie={...z,isPositioned:B.current!==!1};O.current&&!ti(P.current,ie)&&(P.current=ie,Lo.flushSync(()=>{f(ie)}))})},[h,t,n,D,B]);ei(()=>{c===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,f(U=>({...U,isPositioned:!1})))},[c]);const O=g.useRef(!1);ei(()=>(O.current=!0,()=>{O.current=!1}),[]),ei(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(j.current)return j.current(k,T,F);F()}},[k,T,F,j,_]);const $=g.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:S}),[w,S]),R=g.useMemo(()=>({reference:k,floating:T}),[k,T]),W=g.useMemo(()=>{const U={position:n,left:0,top:0};if(!R.floating)return U;const z=Uf(R.floating,u.x),ie=Uf(R.floating,u.y);return a?{...U,transform:"translate("+z+"px, "+ie+"px)",...Hf(R.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:ie}},[n,a,R.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:F,refs:$,elements:R,floatingStyles:W}),[u,F,$,R,W])}const cS=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Bf({element:r.current,padding:o}).fn(n):{}:r?Bf({element:r,padding:o}).fn(n):{}}}},uS=(e,t)=>({...Q0(e),options:[e,t]}),dS=(e,t)=>({...eS(e),options:[e,t]}),fS=(e,t)=>({...oS(e),options:[e,t]}),hS=(e,t)=>({...tS(e),options:[e,t]}),pS=(e,t)=>({...nS(e),options:[e,t]}),mS=(e,t)=>({...rS(e),options:[e,t]}),gS=(e,t)=>({...cS(e),options:[e,t]});var yS="Arrow",Wf=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(Ae.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Wf.displayName=yS;var xS=Wf;function Vf(e){const[t,n]=g.useState(void 0);return Pt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ol="Popper",[Kf,ni]=An(ol),[vS,qf]=Kf(ol),Gf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=g.useState(null);return d.jsx(vS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Gf.displayName=ol;var Yf="PopperAnchor",Xf=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=qf(Yf,n),i=g.useRef(null),a=We(t,i),l=g.useRef(null);return g.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:d.jsx(Ae.div,{...o,ref:a})});Xf.displayName=Yf;var sl="PopperContent",[wS,bS]=Kf(sl),Jf=g.forwardRef((e,t)=>{var ee,L,Q,ue,ye,de;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:x,...y}=e,v=qf(sl,n),[m,w]=g.useState(null),S=We(t,Re=>w(Re)),[k,T]=g.useState(null),C=Vf(k),E=(C==null?void 0:C.width)??0,P=(C==null?void 0:C.height)??0,_=r+(s!=="center"?"-"+s:""),j=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],B=D.length>0,F={padding:j,boundary:D.filter(CS),altBoundary:B},{refs:O,floatingStyles:$,placement:R,isPositioned:W,middlewareData:U}=lS({strategy:"fixed",placement:_,whileElementsMounted:(...Re)=>Z0(...Re,{animationFrame:p==="always"}),elements:{reference:v.anchor},middleware:[uS({mainAxis:o+P,alignmentAxis:i}),l&&dS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?fS():void 0,...F}),l&&hS({...F}),pS({...F,apply:({elements:Re,rects:ce,availableWidth:Ze,availableHeight:it})=>{const{width:ft,height:vt}=ce.reference,yt=Re.floating.style;yt.setProperty("--radix-popper-available-width",`${Ze}px`),yt.setProperty("--radix-popper-available-height",`${it}px`),yt.setProperty("--radix-popper-anchor-width",`${ft}px`),yt.setProperty("--radix-popper-anchor-height",`${vt}px`)}}),k&&gS({element:k,padding:a}),TS({arrowWidth:E,arrowHeight:P}),h&&mS({strategy:"referenceHidden",...F})]}),[z,ie]=eh(R),X=Mt(x);Pt(()=>{W&&(X==null||X())},[W,X]);const ae=(ee=U.arrow)==null?void 0:ee.x,we=(L=U.arrow)==null?void 0:L.y,V=((Q=U.arrow)==null?void 0:Q.centerOffset)!==0,[le,xe]=g.useState();return Pt(()=>{m&&xe(window.getComputedStyle(m).zIndex)},[m]),d.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:W?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[(ue=U.transformOrigin)==null?void 0:ue.x,(ye=U.transformOrigin)==null?void 0:ye.y].join(" "),...((de=U.hide)==null?void 0:de.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(wS,{scope:n,placedSide:z,onArrowChange:T,arrowX:ae,arrowY:we,shouldHideArrow:V,children:d.jsx(Ae.div,{"data-side":z,"data-align":ie,...y,ref:S,style:{...y.style,animation:W?void 0:"none"}})})})});Jf.displayName=sl;var Zf="PopperArrow",SS={top:"bottom",right:"left",bottom:"top",left:"right"},Qf=g.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=bS(Zf,r),i=SS[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(xS,{...o,ref:n,style:{...o.style,display:"block"}})})});Qf.displayName=Zf;function CS(e){return e!==null}var TS=e=>({name:"transformOrigin",options:e,fn(t){var v,m,w;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=eh(n),f={start:"0%",center:"50%",end:"100%"}[u],h=(((m=o.arrow)==null?void 0:m.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let x="",y="";return c==="bottom"?(x=i?f:`${h}px`,y=`${-l}px`):c==="top"?(x=i?f:`${h}px`,y=`${r.floating.height+l}px`):c==="right"?(x=`${-l}px`,y=i?f:`${p}px`):c==="left"&&(x=`${r.floating.width+l}px`,y=i?f:`${p}px`),{data:{x,y}}}});function eh(e){const[t,n="center"]=e.split("-");return[t,n]}var th=Gf,nh=Xf,rh=Jf,oh=Qf,il="rovingFocusGroup.onEntryFocus",kS={bubbles:!1,cancelable:!0},ko="RovingFocusGroup",[al,sh,ES]=Ka(ko),[IS,ih]=An(ko,[ES]),[NS,AS]=IS(ko),ah=g.forwardRef((e,t)=>d.jsx(al.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(al.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(_S,{...e,ref:t})})}));ah.displayName=ko;var _S=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...f}=e,h=g.useRef(null),p=We(t,h),x=Vs(s),[y,v]=vr({prop:i,defaultProp:a??null,onChange:l,caller:ko}),[m,w]=g.useState(!1),S=Mt(c),k=sh(n),T=g.useRef(!1),[C,E]=g.useState(0);return g.useEffect(()=>{const P=h.current;if(P)return P.addEventListener(il,S),()=>P.removeEventListener(il,S)},[S]),d.jsx(NS,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:y,onItemFocus:g.useCallback(P=>v(P),[v]),onItemShiftTab:g.useCallback(()=>w(!0),[]),onFocusableItemAdd:g.useCallback(()=>E(P=>P+1),[]),onFocusableItemRemove:g.useCallback(()=>E(P=>P-1),[]),children:d.jsx(Ae.div,{tabIndex:m||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ge(e.onMouseDown,()=>{T.current=!0}),onFocus:ge(e.onFocus,P=>{const _=!T.current;if(P.target===P.currentTarget&&_&&!m){const j=new CustomEvent(il,kS);if(P.currentTarget.dispatchEvent(j),!j.defaultPrevented){const D=k().filter(R=>R.focusable),B=D.find(R=>R.active),F=D.find(R=>R.id===y),$=[B,F,...D].filter(Boolean).map(R=>R.ref.current);uh($,u)}}T.current=!1}),onBlur:ge(e.onBlur,()=>w(!1))})})}),lh="RovingFocusGroupItem",ch=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_n(),c=s||l,u=AS(lh,n),f=u.currentTabStopId===c,h=sh(n),{onFocusableItemAdd:p,onFocusableItemRemove:x,currentTabStopId:y}=u;return g.useEffect(()=>{if(r)return p(),()=>x()},[r,p,x]),d.jsx(al.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:d.jsx(Ae.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:ge(e.onMouseDown,v=>{r?u.onItemFocus(c):v.preventDefault()}),onFocus:ge(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:ge(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const m=PS(v,u.orientation,u.dir);if(m!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(m==="last")S.reverse();else if(m==="prev"||m==="next"){m==="prev"&&S.reverse();const k=S.indexOf(v.currentTarget);S=u.loop?OS(S,k+1):S.slice(k+1)}setTimeout(()=>uh(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:y!=null}):i})})});ch.displayName=lh;var jS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function RS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function PS(e,t,n){const r=RS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jS[r]}function uh(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function OS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var MS=ah,DS=ch,ll=["Enter"," "],LS=["ArrowDown","PageUp","Home"],dh=["ArrowUp","PageDown","End"],FS=[...LS,...dh],$S={ltr:[...ll,"ArrowRight"],rtl:[...ll,"ArrowLeft"]},zS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Eo="Menu",[Io,BS,HS]=Ka(Eo),[Tr,fh]=An(Eo,[HS,ni,ih]),ri=ni(),hh=ih(),[US,kr]=Tr(Eo),[WS,No]=Tr(Eo),ph=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ri(t),[l,c]=g.useState(null),u=g.useRef(!1),f=Mt(s),h=Vs(o);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),d.jsx(th,{...a,children:d.jsx(US,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:d.jsx(WS,{scope:t,onClose:g.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:u,dir:h,modal:i,children:r})})})};ph.displayName=Eo;var VS="MenuAnchor",cl=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ri(n);return d.jsx(nh,{...o,...r,ref:t})});cl.displayName=VS;var ul="MenuPortal",[KS,mh]=Tr(ul,{forceMount:void 0}),gh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=kr(ul,t);return d.jsx(KS,{scope:t,forceMount:n,children:d.jsx(nn,{present:n||s.open,children:d.jsx(ks,{asChild:!0,container:o,children:r})})})};gh.displayName=ul;var un="MenuContent",[qS,dl]=Tr(un),yh=g.forwardRef((e,t)=>{const n=mh(un,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kr(un,e.__scopeMenu),i=No(un,e.__scopeMenu);return d.jsx(Io.Provider,{scope:e.__scopeMenu,children:d.jsx(nn,{present:r||s.open,children:d.jsx(Io.Slot,{scope:e.__scopeMenu,children:i.modal?d.jsx(GS,{...o,ref:t}):d.jsx(YS,{...o,ref:t})})})})}),GS=g.forwardRef((e,t)=>{const n=kr(un,e.__scopeMenu),r=g.useRef(null),o=We(t,r);return g.useEffect(()=>{const s=r.current;if(s)return Fa(s)},[]),d.jsx(fl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ge(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),YS=g.forwardRef((e,t)=>{const n=kr(un,e.__scopeMenu);return d.jsx(fl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),XS=ur.createSlot("MenuContent.ScrollLock"),fl=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:x,...y}=e,v=kr(un,n),m=No(un,n),w=ri(n),S=hh(n),k=BS(n),[T,C]=g.useState(null),E=g.useRef(null),P=We(t,E,v.onContentChange),_=g.useRef(0),j=g.useRef(""),D=g.useRef(0),B=g.useRef(null),F=g.useRef("right"),O=g.useRef(0),$=x?js:g.Fragment,R=x?{as:XS,allowPinchZoom:!0}:void 0,W=z=>{var ee,L;const ie=j.current+z,X=k().filter(Q=>!Q.disabled),ae=document.activeElement,we=(ee=X.find(Q=>Q.ref.current===ae))==null?void 0:ee.textValue,V=X.map(Q=>Q.textValue),le=lC(V,ie,we),xe=(L=X.find(Q=>Q.textValue===le))==null?void 0:L.ref.current;(function Q(ue){j.current=ue,window.clearTimeout(_.current),ue!==""&&(_.current=window.setTimeout(()=>Q(""),1e3))})(ie),xe&&setTimeout(()=>xe.focus())};g.useEffect(()=>()=>window.clearTimeout(_.current),[]),Ra();const U=g.useCallback(z=>{var X,ae;return F.current===((X=B.current)==null?void 0:X.side)&&uC(z,(ae=B.current)==null?void 0:ae.area)},[]);return d.jsx(qS,{scope:n,searchRef:j,onItemEnter:g.useCallback(z=>{U(z)&&z.preventDefault()},[U]),onItemLeave:g.useCallback(z=>{var ie;U(z)||((ie=E.current)==null||ie.focus(),C(null))},[U]),onTriggerLeave:g.useCallback(z=>{U(z)&&z.preventDefault()},[U]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(z=>{B.current=z},[]),children:d.jsx($,{...R,children:d.jsx(Ts,{asChild:!0,trapped:o,onMountAutoFocus:ge(s,z=>{var ie;z.preventDefault(),(ie=E.current)==null||ie.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:d.jsx(Cs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:d.jsx(MS,{asChild:!0,...S,dir:m.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:ge(l,z=>{m.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(rh,{role:"menu","aria-orientation":"vertical","data-state":Oh(v.open),"data-radix-menu-content":"",dir:m.dir,...w,...y,ref:P,style:{outline:"none",...y.style},onKeyDown:ge(y.onKeyDown,z=>{const X=z.target.closest("[data-radix-menu-content]")===z.currentTarget,ae=z.ctrlKey||z.altKey||z.metaKey,we=z.key.length===1;X&&(z.key==="Tab"&&z.preventDefault(),!ae&&we&&W(z.key));const V=E.current;if(z.target!==V||!FS.includes(z.key))return;z.preventDefault();const xe=k().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);dh.includes(z.key)&&xe.reverse(),iC(xe)}),onBlur:ge(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(_.current),j.current="")}),onPointerMove:ge(e.onPointerMove,_o(z=>{const ie=z.target,X=O.current!==z.clientX;if(z.currentTarget.contains(ie)&&X){const ae=z.clientX>O.current?"right":"left";F.current=ae,O.current=z.clientX}}))})})})})})})});yh.displayName=un;var JS="MenuGroup",hl=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Ae.div,{role:"group",...r,ref:t})});hl.displayName=JS;var ZS="MenuLabel",xh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Ae.div,{...r,ref:t})});xh.displayName=ZS;var oi="MenuItem",vh="menu.itemSelect",si=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=g.useRef(null),i=No(oi,e.__scopeMenu),a=dl(oi,e.__scopeMenu),l=We(t,s),c=g.useRef(!1),u=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(vh,{bubbles:!0,cancelable:!0});f.addEventListener(vh,p=>r==null?void 0:r(p),{once:!0}),od(f,h),h.defaultPrevented?c.current=!1:i.onClose()}};return d.jsx(wh,{...o,ref:l,disabled:n,onClick:ge(e.onClick,u),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),c.current=!0},onPointerUp:ge(e.onPointerUp,f=>{var h;c.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ge(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||ll.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});si.displayName=oi;var wh=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=dl(oi,n),a=hh(n),l=g.useRef(null),c=We(t,l),[u,f]=g.useState(!1),[h,p]=g.useState("");return g.useEffect(()=>{const x=l.current;x&&p((x.textContent??"").trim())},[s.children]),d.jsx(Io.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:d.jsx(DS,{asChild:!0,...a,focusable:!r,children:d.jsx(Ae.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ge(e.onPointerMove,_o(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ge(e.onPointerLeave,_o(x=>i.onItemLeave(x))),onFocus:ge(e.onFocus,()=>f(!0)),onBlur:ge(e.onBlur,()=>f(!1))})})})}),QS="MenuCheckboxItem",bh=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return d.jsx(Eh,{scope:e.__scopeMenu,checked:n,children:d.jsx(si,{role:"menuitemcheckbox","aria-checked":ii(n)?"mixed":n,...o,ref:t,"data-state":ml(n),onSelect:ge(o.onSelect,()=>r==null?void 0:r(ii(n)?!0:!n),{checkForDefaultPrevented:!1})})})});bh.displayName=QS;var Sh="MenuRadioGroup",[eC,tC]=Tr(Sh,{value:void 0,onValueChange:()=>{}}),Ch=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Mt(r);return d.jsx(eC,{scope:e.__scopeMenu,value:n,onValueChange:s,children:d.jsx(hl,{...o,ref:t})})});Ch.displayName=Sh;var Th="MenuRadioItem",kh=g.forwardRef((e,t)=>{const{value:n,...r}=e,o=tC(Th,e.__scopeMenu),s=n===o.value;return d.jsx(Eh,{scope:e.__scopeMenu,checked:s,children:d.jsx(si,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ml(s),onSelect:ge(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});kh.displayName=Th;var pl="MenuItemIndicator",[Eh,nC]=Tr(pl,{checked:!1}),Ih=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=nC(pl,n);return d.jsx(nn,{present:r||ii(s.checked)||s.checked===!0,children:d.jsx(Ae.span,{...o,ref:t,"data-state":ml(s.checked)})})});Ih.displayName=pl;var rC="MenuSeparator",Nh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Ae.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Nh.displayName=rC;var oC="MenuArrow",Ah=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ri(n);return d.jsx(oh,{...o,...r,ref:t})});Ah.displayName=oC;var sC="MenuSub",[Vk,_h]=Tr(sC),Ao="MenuSubTrigger",jh=g.forwardRef((e,t)=>{const n=kr(Ao,e.__scopeMenu),r=No(Ao,e.__scopeMenu),o=_h(Ao,e.__scopeMenu),s=dl(Ao,e.__scopeMenu),i=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),d.jsx(cl,{asChild:!0,...c,children:d.jsx(wh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Oh(n.open),...e,ref:wa(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ge(e.onPointerMove,_o(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ge(e.onPointerLeave,_o(f=>{var p,x;u();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const y=(x=n.content)==null?void 0:x.dataset.side,v=y==="right",m=v?-5:5,w=h[v?"left":"right"],S=h[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+m,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ge(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||$S[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});jh.displayName=Ao;var Rh="MenuSubContent",Ph=g.forwardRef((e,t)=>{const n=mh(un,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kr(un,e.__scopeMenu),i=No(un,e.__scopeMenu),a=_h(Rh,e.__scopeMenu),l=g.useRef(null),c=We(t,l);return d.jsx(Io.Provider,{scope:e.__scopeMenu,children:d.jsx(nn,{present:r||s.open,children:d.jsx(Io.Slot,{scope:e.__scopeMenu,children:d.jsx(fl,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ge(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ge(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ge(e.onKeyDown,u=>{var p;const f=u.currentTarget.contains(u.target),h=zS[i.dir].includes(u.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});Ph.displayName=Rh;function Oh(e){return e?"open":"closed"}function ii(e){return e==="indeterminate"}function ml(e){return ii(e)?"indeterminate":e?"checked":"unchecked"}function iC(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function aC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function lC(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=aC(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function cC(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,u=a.y,f=l.x,h=l.y;u>r!=h>r&&n<(f-c)*(r-u)/(h-u)+c&&(o=!o)}return o}function uC(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return cC(n,t)}function _o(e){return t=>t.pointerType==="mouse"?e(t):void 0}var dC=ph,fC=cl,hC=gh,pC=yh,mC=hl,gC=xh,yC=si,xC=bh,vC=Ch,wC=kh,bC=Ih,SC=Nh,CC=Ah,TC=jh,kC=Ph,ai="DropdownMenu",[EC,Kk]=An(ai,[fh]),Kt=fh(),[IC,Mh]=EC(ai),Dh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Kt(t),c=g.useRef(null),[u,f]=vr({prop:o,defaultProp:s??!1,onChange:i,caller:ai});return d.jsx(IC,{scope:t,triggerId:_n(),triggerRef:c,contentId:_n(),open:u,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(h=>!h),[f]),modal:a,children:d.jsx(dC,{...l,open:u,onOpenChange:f,dir:r,modal:a,children:n})})};Dh.displayName=ai;var Lh="DropdownMenuTrigger",Fh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Mh(Lh,n),i=Kt(n);return d.jsx(fC,{asChild:!0,...i,children:d.jsx(Ae.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:wa(t,s.triggerRef),onPointerDown:ge(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ge(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Fh.displayName=Lh;var NC="DropdownMenuPortal",$h=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Kt(t);return d.jsx(hC,{...r,...n})};$h.displayName=NC;var zh="DropdownMenuContent",Bh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mh(zh,n),s=Kt(n),i=g.useRef(!1);return d.jsx(pC,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ge(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ge(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Bh.displayName=zh;var AC="DropdownMenuGroup",_C=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(mC,{...o,...r,ref:t})});_C.displayName=AC;var jC="DropdownMenuLabel",Hh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(gC,{...o,...r,ref:t})});Hh.displayName=jC;var RC="DropdownMenuItem",Uh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(yC,{...o,...r,ref:t})});Uh.displayName=RC;var PC="DropdownMenuCheckboxItem",Wh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(xC,{...o,...r,ref:t})});Wh.displayName=PC;var OC="DropdownMenuRadioGroup",MC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(vC,{...o,...r,ref:t})});MC.displayName=OC;var DC="DropdownMenuRadioItem",Vh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(wC,{...o,...r,ref:t})});Vh.displayName=DC;var LC="DropdownMenuItemIndicator",Kh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(bC,{...o,...r,ref:t})});Kh.displayName=LC;var FC="DropdownMenuSeparator",qh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(SC,{...o,...r,ref:t})});qh.displayName=FC;var $C="DropdownMenuArrow",zC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(CC,{...o,...r,ref:t})});zC.displayName=$C;var BC="DropdownMenuSubTrigger",Gh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(TC,{...o,...r,ref:t})});Gh.displayName=BC;var HC="DropdownMenuSubContent",Yh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kt(n);return d.jsx(kC,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Yh.displayName=HC;var UC=Dh,WC=Fh,VC=$h,Xh=Bh,Jh=Hh,Zh=Uh,Qh=Wh,ep=Vh,tp=Kh,np=qh,rp=Gh,op=Yh;const KC=UC,qC=WC,GC=g.forwardRef(({className:e,inset:t,children:n,...r},o)=>d.jsxs(rp,{ref:o,className:te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,d.jsx(he.ChevronRight,{className:"ml-auto h-4 w-4"})]}));GC.displayName=rp.displayName;const YC=g.forwardRef(({className:e,...t},n)=>d.jsx(op,{ref:n,className:te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));YC.displayName=op.displayName;const sp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>d.jsx(VC,{children:d.jsx(Xh,{ref:r,sideOffset:t,className:te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...n})}));sp.displayName=Xh.displayName;const gl=g.forwardRef(({className:e,inset:t,...n},r)=>d.jsx(Zh,{ref:r,className:te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));gl.displayName=Zh.displayName;const XC=g.forwardRef(({className:e,children:t,checked:n,...r},o)=>d.jsxs(Qh,{ref:o,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(tp,{children:d.jsx(he.Check,{className:"h-4 w-4"})})}),t]}));XC.displayName=Qh.displayName;const JC=g.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(ep,{ref:r,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(tp,{children:d.jsx(he.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));JC.displayName=ep.displayName;const ZC=g.forwardRef(({className:e,inset:t,...n},r)=>d.jsx(Jh,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ZC.displayName=Jh.displayName;const QC=g.forwardRef(({className:e,...t},n)=>d.jsx(np,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));QC.displayName=np.displayName;const ip={value:""};function li({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:u=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:x}){const{api:y}=Mi(),{currentThreadId:v}=ns(),{threadId:m,messages:w,hasMore:S,isHistoryLoading:k,isLoading:T,loadOlder:C,navigateToCheckpoint:E,returnToLatest:P,checkpoint:_,checkpoints:j,interrupt:D,metadata:B}=rs(),{isStreaming:F,error:O,connectionState:$,submit:R,stop:W}=eu(),U=m??v??null,z=(_==null?void 0:_.id)??null,ie=(_==null?void 0:_.namespace)??null,X=(B==null?void 0:B.assemblingMessageId)??null,ae=D,[we,V]=b.useState(!1);b.useEffect(()=>{ae||V(!1)},[ae]);const le=b.useCallback(()=>{V(!0)},[]),xe=b.useCallback(()=>{V(!1)},[]),ee=!!ae||we,[L,Q]=b.useState(null),[ue,ye]=b.useState(""),[de,Re]=b.useState(null),[ce,Ze]=b.useState([]),[it,ft]=b.useState(0),[vt,yt]=b.useState(0),[Qe,ke]=b.useState(!1),[at,lt]=b.useState(null),[ot,et]=b.useState(null),[se,Ee]=b.useState(!1),[Se,qe]=b.useState(null),[Xe,It]=b.useState(!1),Ct=b.useRef(!1),[wt,hn]=b.useState(()=>ip.value),Wn=b.useRef(wt),Ge=b.useRef(null),Ve=b.useCallback(Y=>{ip.value=Y,hn(Y)},[]),[qt,Dt]=b.useState(!1),Nt=b.useCallback((Y,ne)=>{if(!Y||typeof Y!="object")return null;const fe=Y[ne];return typeof fe=="number"?fe:null},[]),Zt=b.useCallback((Y,ne)=>{if(!Y||typeof Y!="object")return null;const fe=Y[ne];return typeof fe=="string"&&fe.trim()?fe:null},[]),At=b.useMemo(()=>{const Y=Array.isArray(j)?[...j]:[];return Y.some(fe=>Nt(fe.metadata,"step")!==null)&&Y.sort((fe,Ye)=>{const pt=Nt(fe.metadata,"step"),Rt=Nt(Ye.metadata,"step");if(pt!==null||Rt!==null)return(Rt??Number.NEGATIVE_INFINITY)-(pt??Number.NEGATIVE_INFINITY);const _t=Date.parse(fe.createdAt??""),Tn=Date.parse(Ye.createdAt??"");return Number.isNaN(_t)||Number.isNaN(Tn)?0:Tn-_t}),Y},[j,Nt]),Cn=b.useRef(null),Qt=b.useRef(null),ct=b.useCallback(()=>{Cn.current&&(Cn.current.value=""),Qt.current&&(Qt.current.value=""),ft(Y=>Y+1),yt(Y=>Y+1)},[]),$e=b.useCallback(Y=>{Ve(Y)},[Ve]),Lt=b.useRef(!1);b.useEffect(()=>{Lt.current&&!F&&(Ze([]),ct()),Lt.current=F},[F,ct]);const[Oe,ht]=b.useState("desktop");b.useEffect(()=>{const Y=()=>{const ne=window.innerWidth;ht(ne<640?"phone":ne<1024?"tablet":"desktop")};return Y(),window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},[]),b.useEffect(()=>{It(!1),Ct.current=!1},[U]),b.useEffect(()=>{Wn.current=wt},[wt]),b.useEffect(()=>{if(!L){Ge.current=null;return}Ge.current===null&&(Ge.current=Wn.current),Ve(ue??"")},[ue,L,Ve]);const ir=b.useCallback(async()=>{if(!(!S||k||!Xe))try{await C()}catch(Y){console.warn("loadOlder failed",Y)}},[S,Xe,k,C]);b.useEffect(()=>{(async()=>{if(!y.baseUrl){qe(null);return}try{const fe=(await y.getAgent("default")).uiDefaultMessage||"";qe(fe||null)}catch(ne){console.warn("Failed to fetch default message:",ne),qe(null)}})()},[y.baseUrl]),b.useEffect(()=>{O&&!se&&(x==null||x(O))},[O,se,x]);const Kr=Y=>{if(Y.length>Ws)return`Message too long (${Y.length}/${Ws} characters)`;try{return s0(Y),null}catch(ne){return(ne==null?void 0:ne.message)||"Invalid message"}},ar=async Y=>{const ne=Y.trim();if(!(!ne&&ce.length===0)){if(ne){const fe=Kr(ne);if(fe){Re(fe);return}}try{await R({text:ne||"",attachments:ce,payload:L?{edit:!0,originalMessageId:L}:void 0},{checkpointId:z??void 0,checkpointNs:ie??void 0}),h==null||h(ne),Ve(""),Re(null),Ze([]),ct(),Q(null),ye("")}catch(fe){const Ye=(fe==null?void 0:fe.message)||"Failed to send message";Re(Ye),x==null||x(Ye)}}},lr=b.useCallback((Y,ne)=>{c&&(Ge.current=wt,Q(Y),ye(ne),Ve(ne),Re(null))},[wt,c,Ve]),Vn=b.useCallback(()=>{Q(null),ye(""),Re(null),Ve(Ge.current??wt),Ge.current=null},[wt,Ve]),Kn=b.useCallback((Y,ne)=>{lr(Y,ne)},[lr]),qr=b.useCallback(Y=>{for(let ne=Y-1;ne>=0;ne--)if(w[ne].role==="user"){const fe=w[ne].content||[],pt=fe.filter(Rt=>Rt.type==="text").map(Rt=>Rt.text).join("")||(()=>{try{return JSON.stringify(fe,null,2)}catch{return String(fe)}})();pt&&R({text:pt},{checkpointId:z??void 0,checkpointNs:ie??void 0});break}},[w,R,z,ie]),I=Y=>{const ne=Array.from(Y.target.files||[]);Ze(fe=>[...fe,...ne]),Y.target.value=""},q=Y=>{Ze(ne=>{const fe=ne.filter((Ye,pt)=>Y!==pt);return fe.length===0&&ct(),fe})},oe=async Y=>{const ne=(Y.target.files||[])[0];if(ne){lt(null),et(null),ke(!0);try{await R({attachments:[ne]},{checkpointId:z??void 0,checkpointNs:ie??void 0});const fe=`Uploaded ${ne.name} - processing through chat stream`;et(fe)}catch(fe){const Ye=fe instanceof Error?fe.message:"Failed to upload Excel file";console.error("Excel upload failed",fe),lt(Ye),x==null||x(Ye)}finally{ke(!1),Y.target.value="",ct()}}},be=Y=>{if(!Y)return"Unknown";const ne=Date.parse(Y);return Number.isNaN(ne)?Y:new Date(ne).toLocaleString()},He=async Y=>{if(v){Dt(!0);try{if(!Y){await P();return}const ne=At.find(Ye=>Ye.checkpointId===Y),fe=(ne==null?void 0:ne.checkpointNs)??null;await E(Y,fe)}finally{Dt(!1)}}},tt=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,ze=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,De=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return d.jsxs("div",{className:tt,children:[!!O&&!se&&d.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[d.jsx("span",{children:O}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>Ee(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:d.jsx(he.X,{size:16})})]}),v&&j.length>0&&d.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[d.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),d.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:z??"",onChange:Y=>{const ne=Y.target.value||null;He(ne)},children:[d.jsx("option",{value:"",children:"Latest"}),At.map(Y=>{const ne=Nt(Y.metadata,"step"),fe=Zt(Y.metadata,"source"),Ye=[];ne!==null&&Ye.push(`Step ${ne}`),fe&&Ye.push(fe);const pt=Ye.length?` — ${Ye.join(" • ")}`:"";return d.jsxs("option",{value:Y.checkpointId,children:[be(Y.createdAt),pt]},Y.checkpointId)})]})]}),d.jsxs("div",{className:`relative ${ze}`,style:r?{maxHeight:r}:void 0,children:[d.jsx(Va,{className:"h-full",style:{height:"100%"},messages:w,isStreaming:F,streamingAssistantId:X,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Oe,enableMessageEditing:c,editingMessageId:L,onStartReached:()=>{Xe&&ir()},onScrollAway:Y=>{if(!Ct.current){Ct.current=!0;return}Y&&It(!0)},onEdit:Kn,onRegenerate:qr,onCancelEdit:Vn,emptyMessage:Se??void 0,isNavigatingCheckpoint:qt,activeInterrupt:ae,disableInterruptActions:we,onInterruptActionStart:le,onInterruptActionEnd:xe,showToolMessages:u}),($==="reconnecting"||$==="connecting")&&d.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(he.Loader2,{className:"h-3 w-3 animate-spin"}),$==="reconnecting"?"Reconnecting…":"Connecting…"]})}),$==="error"&&d.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&d.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[d.jsx(he.Loader2,{className:"h-6 w-6 animate-spin"}),d.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),d.jsxs("div",{className:De,children:[L&&d.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(he.Edit3,{size:16,className:"text-blue-600"}),d.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:Vn,className:"text-blue-600 hover:bg-blue-100",children:d.jsx(he.X,{size:16})})]})}),(a||l)&&d.jsxs("div",{className:"mb-3 space-y-3",children:[a&&d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:Cn,type:"file",multiple:!0,onChange:Y=>I(Y),className:"hidden"},it),ce.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:ce.map((Y,ne)=>d.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[d.jsx(he.Paperclip,{size:14}),d.jsx("span",{className:"truncate max-w-[150px]",children:Y.name}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>q(ne),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${Y.name}`,children:d.jsx(he.X,{size:12})})]},ne))})]}),l&&d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:Qt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:oe,className:"hidden"},vt),Qe&&d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsx(he.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ot&&!Qe&&d.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ot}),at&&!Qe&&d.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:at})]})]}),de&&d.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:de}),d.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&d.jsxs(KC,{children:[d.jsx(qC,{asChild:!0,children:d.jsx(nt,{type:"button",size:"icon",variant:"outline",disabled:F||ee,title:"More input actions",className:f.moreButton||"",children:d.jsx(he.Plus,{size:16})})}),d.jsxs(sp,{align:"start",sideOffset:6,className:"w-52",children:[a&&d.jsxs(gl,{onClick:()=>{var Y;return(Y=Cn.current)==null?void 0:Y.click()},className:"cursor-pointer",children:[d.jsx(he.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&d.jsxs(gl,{onClick:()=>{var Y;Qe||(Y=Qt.current)==null||Y.click()},className:`cursor-pointer ${Qe?"opacity-60 pointer-events-none":""}`,children:[d.jsx(he.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),d.jsx("div",{className:"flex-1",children:d.jsx(yx,{initialValue:ue,editingMessageId:L,value:wt,onValueChange:$e,placeholder:L?"Edit your message...":t,isStreaming:F,disabled:ee,maxLength:Ws,onSend:ar,onCancelEdit:Vn,onStop:W,allowEmptySend:ce.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${L?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${de?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const ci=g.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ci.displayName="Input";function yl(e,[t,n]){return Math.min(n,Math.max(t,e))}function eT(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var xl="ScrollArea",[ap,qk]=An(xl),[tT,dn]=ap(xl),lp=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=g.useState(null),[c,u]=g.useState(null),[f,h]=g.useState(null),[p,x]=g.useState(null),[y,v]=g.useState(null),[m,w]=g.useState(0),[S,k]=g.useState(0),[T,C]=g.useState(!1),[E,P]=g.useState(!1),_=We(t,D=>l(D)),j=Vs(o);return d.jsx(tT,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:x,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:y,onScrollbarYChange:v,scrollbarYEnabled:E,onScrollbarYEnabledChange:P,onCornerWidthChange:w,onCornerHeightChange:k,children:d.jsx(Ae.div,{dir:j,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":m+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});lp.displayName=xl;var cp="ScrollAreaViewport",up=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=dn(cp,n),a=g.useRef(null),l=We(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx(Ae.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});up.displayName=cp;var Dn="ScrollAreaScrollbar",vl=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=dn(Dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return g.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(nT,{...r,ref:t,forceMount:n}):o.type==="scroll"?d.jsx(rT,{...r,ref:t,forceMount:n}):o.type==="auto"?d.jsx(dp,{...r,ref:t,forceMount:n}):o.type==="always"?d.jsx(wl,{...r,ref:t}):null});vl.displayName=Dn;var nT=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=dn(Dn,e.__scopeScrollArea),[s,i]=g.useState(!1);return g.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},u=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(nn,{present:n||s,children:d.jsx(dp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),rT=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=dn(Dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=hi(()=>l("SCROLL_END"),100),[a,l]=eT("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return g.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),g.useEffect(()=>{const c=o.viewport,u=s?"scrollLeft":"scrollTop";if(c){let f=c[u];const h=()=>{const p=c[u];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),d.jsx(nn,{present:n||a!=="hidden",children:d.jsx(wl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ge(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ge(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),dp=g.forwardRef((e,t)=>{const n=dn(Dn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=g.useState(!1),a=e.orientation==="horizontal",l=hi(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:u)}},10);return Ur(n.viewport,l),Ur(n.content,l),d.jsx(nn,{present:r||s,children:d.jsx(wl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),wl=g.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=dn(Dn,e.__scopeScrollArea),s=g.useRef(null),i=g.useRef(0),[a,l]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=gp(a.viewport,a.content),u={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return cT(h,i.current,a,p)}return n==="horizontal"?d.jsx(oT,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=yp(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?d.jsx(sT,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=yp(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),oT=g.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=dn(Dn,e.__scopeScrollArea),[i,a]=g.useState(),l=g.useRef(null),c=We(t,l,s.onScrollbarXChange);return g.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(hp,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":fi(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),vp(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:di(i.paddingLeft),paddingEnd:di(i.paddingRight)}})}})}),sT=g.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=dn(Dn,e.__scopeScrollArea),[i,a]=g.useState(),l=g.useRef(null),c=We(t,l,s.onScrollbarYChange);return g.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(hp,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":fi(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),vp(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:di(i.paddingTop),paddingEnd:di(i.paddingBottom)}})}})}),[iT,fp]=ap(Dn),hp=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:f,...h}=e,p=dn(Dn,n),[x,y]=g.useState(null),v=We(t,_=>y(_)),m=g.useRef(null),w=g.useRef(""),S=p.viewport,k=r.content-r.viewport,T=Mt(u),C=Mt(l),E=hi(f,10);function P(_){if(m.current){const j=_.clientX-m.current.left,D=_.clientY-m.current.top;c({x:j,y:D})}}return g.useEffect(()=>{const _=j=>{const D=j.target;(x==null?void 0:x.contains(D))&&T(j,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,x,k,T]),g.useEffect(C,[r,C]),Ur(x,E),Ur(p.content,E),d.jsx(iT,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:Mt(s),onThumbPointerUp:Mt(i),onThumbPositionChange:C,onThumbPointerDown:Mt(a),children:d.jsx(Ae.div,{...h,ref:v,style:{position:"absolute",...h.style},onPointerDown:ge(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),m.current=x.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),P(_))}),onPointerMove:ge(e.onPointerMove,P),onPointerUp:ge(e.onPointerUp,_=>{const j=_.target;j.hasPointerCapture(_.pointerId)&&j.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),m.current=null})})})}),ui="ScrollAreaThumb",pp=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=fp(ui,e.__scopeScrollArea);return d.jsx(nn,{present:n||o.hasThumb,children:d.jsx(aT,{ref:t,...r})})}),aT=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=dn(ui,n),i=fp(ui,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),c=g.useRef(void 0),u=hi(()=>{c.current&&(c.current(),c.current=void 0)},100);return g.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(u(),!c.current){const p=uT(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,u,a]),d.jsx(Ae.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ge(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),x=f.clientX-p.left,y=f.clientY-p.top;i.onThumbPointerDown({x,y})}),onPointerUp:ge(e.onPointerUp,i.onThumbPointerUp)})});pp.displayName=ui;var bl="ScrollAreaCorner",mp=g.forwardRef((e,t)=>{const n=dn(bl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?d.jsx(lT,{...e,ref:t}):null});mp.displayName=bl;var lT=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=dn(bl,n),[s,i]=g.useState(0),[a,l]=g.useState(0),c=!!(s&&a);return Ur(o.scrollbarX,()=>{var f;const u=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),Ur(o.scrollbarY,()=>{var f;const u=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),c?d.jsx(Ae.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function di(e){return e?parseInt(e,10):0}function gp(e,t){const n=e/t;return isNaN(n)?0:n}function fi(e){const t=gp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function cT(e,t,n,r="ltr"){const o=fi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,f=r==="ltr"?[0,u]:[u*-1,0];return xp([l,c],f)(e)}function yp(e,t,n="ltr"){const r=fi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=yl(e,l);return xp([0,i],[0,a])(c)}function xp(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function vp(e,t){return e>0&&e<t}var uT=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function hi(e,t){const n=Mt(e),r=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),g.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ur(e,t){const n=Mt(t);Pt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var wp=lp,dT=up,fT=mp;const bp=g.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(wp,{ref:r,className:te("relative overflow-hidden",e),...n,children:[d.jsx(dT,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),d.jsx(Sp,{}),d.jsx(fT,{})]}));bp.displayName=wp.displayName;const Sp=g.forwardRef(({className:e,orientation:t="vertical",...n},r)=>d.jsx(vl,{ref:r,orientation:t,className:te("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:d.jsx(pp,{className:"relative flex-1 rounded-full bg-border"})}));Sp.displayName=vl.displayName;const Cp=25;function Sl({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:u}){const{threads:f,currentThreadId:h,isLoading:p,actions:x}=ns(),{loadThread:y}=rs(),{createThread:v,deleteThread:m,renameThread:w}=x,[S,k]=b.useState(Array.isArray(f)?f:[]),T=b.useRef(S.length>0),C=b.useRef(null),E=b.useRef(0),[P,_]=b.useState(null),[j,D]=b.useState(""),[B,F]=b.useState(!1);b.useEffect(()=>{const V=Array.isArray(f)?f:[];if(V.length>0){T.current=!0,k(V);return}p||(T.current=!1,k(V))},[f,p]),b.useEffect(()=>{if(!C.current)return;const V=C.current.querySelector("[data-radix-scroll-area-viewport]");if(!V)return;let le=null,xe=null;return le=requestAnimationFrame(()=>{xe=requestAnimationFrame(()=>{V.scrollTop=E.current})}),()=>{le!==null&&cancelAnimationFrame(le),xe!==null&&cancelAnimationFrame(xe)}},[S]);const O=async V=>{try{await y(V),a==null||a(V),l==null||l(V)}catch(le){console.error("Failed to select thread:",le)}},$=async()=>{try{F(!0);const V=await v();c==null||c(V),a==null||a(V)}catch(V){console.error("Failed to create thread:",V)}finally{F(!1)}},R=async(V,le)=>{if(le.stopPropagation(),!!confirm("Delete this thread?")){if(C.current){const xe=C.current.querySelector("[data-radix-scroll-area-viewport]");xe&&(E.current=xe.scrollTop)}try{await m(V),u==null||u(V)}catch(xe){console.error("Failed to delete thread:",xe)}}},W=(V,le)=>{le.stopPropagation(),_(V.threadId),D(V.title||`Thread ${V.threadId.slice(0,8)}`)},U=async V=>{if(j.trim())try{await w(V,j.trim()),_(null),D("")}catch(le){console.error("Failed to update title:",le)}},z=()=>{_(null),D("")},ie=(V,le)=>{V.key==="Enter"?U(le):V.key==="Escape"&&z()},X=V=>{if(!V)return"";try{const le=new Date(V),ee=new Date().getTime()-le.getTime(),L=Math.floor(ee/(1e3*60*60*24));return L===0?le.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):L===1?"Yesterday":L<7?`${L} days ago`:le.toLocaleDateString()}catch{return""}},ae=V=>V.title||`Thread ${V.threadId.slice(0,8)}`,we=V=>{const le=ae(V);return le.length<=Cp?le:`${le.slice(0,Cp)}...`};return d.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&d.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:d.jsx(nt,{onClick:$,disabled:B||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:B?"Creating...":"New Chat",children:d.jsx(he.MessageSquarePlus,{size:20})})}),d.jsx(bp,{ref:C,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:d.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[d.jsx(he.Loader2,{className:"h-5 w-5 animate-spin"}),d.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?d.jsxs("div",{className:"text-center py-8 text-slate-400",children:[d.jsx(he.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),d.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((V,le)=>new Date(le.updatedAt||le.createdAt||"").getTime()-new Date(V.updatedAt||V.createdAt||"").getTime()).map(V=>d.jsxs("div",{onClick:()=>O(V.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===V.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"flex-1 min-w-0",children:P===V.threadId?d.jsxs("div",{className:"flex items-center gap-2",onClick:le=>le.stopPropagation(),children:[d.jsx(ci,{value:j,onChange:le=>D(le.target.value),onKeyDown:le=>ie(le,V.threadId),className:"h-6 text-sm",autoFocus:!0}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>U(V.threadId),className:"h-6 w-6 p-0",children:d.jsx(he.Check,{size:12})}),d.jsx(nt,{variant:"ghost",size:"sm",onClick:z,className:"h-6 w-6 p-0",children:d.jsx(he.X,{size:12})})]}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:we(V)}),d.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[d.jsx(he.Calendar,{size:10}),d.jsx("span",{children:X(V.updatedAt||V.createdAt)})]})]})}),d.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&P!==V.threadId&&d.jsx(nt,{variant:"ghost",size:"sm",onClick:le=>W(V,le),className:"h-6 w-6 p-0",title:"Edit title",children:d.jsx(he.Edit3,{size:12})}),n&&d.jsx(nt,{variant:"ghost",size:"sm",onClick:le=>R(V.threadId,le),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:d.jsx(he.Trash2,{size:12})})]})]}),i===V.threadId&&d.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},V.threadId))})})]})}function Wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function hT(e){if(typeof e!="string")return;const t=e.trim();if(t)return zn(t)}function Tp(){const e=[Wr("__API_BASE_URL__"),Wr("__CHAT_API_BASE_URL__"),Wr("__CHAT_API_URL__")];for(const t of e){const n=hT(t);if(n)return n}}function kp(){const e=[Wr("__API_AUTH_TOKEN__"),Wr("__CHAT_API_KEY__"),Wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Ep(...e){for(const t of e)if(typeof t=="string"&&t.trim())return zn(t);return zn()}function Ip(){const e={},t=Tp(),n=kp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Np(){const e=Ip(),t=qn.getAuthToken(),n=Tp();return{apiBaseUrl:Ep(e.baseUrl,qn.baseUrl,n),apiKey:t||e.apiKey||kp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Ap="chat-settings";function pT(){try{const e=localStorage.getItem(Ap);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function mT(e){try{const t={...e,apiBaseUrl:zn(e.apiBaseUrl)};localStorage.setItem(Ap,JSON.stringify(t)),t.apiKey&&qn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function gT(){const e=Np(),t=pT(),n=qn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ep(qn.baseUrl,r,e.apiBaseUrl)}}function yT(e){qn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),mT(e)}var xT="Label",_p=g.forwardRef((e,t)=>d.jsx(Ae.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));_p.displayName=xT;var jp=_p;const vT=Do.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fn=g.forwardRef(({className:e,...t},n)=>d.jsx(jp,{ref:n,className:te(vT(),e),...t}));fn.displayName=jp.displayName;function Rp(e){const t=g.useRef({value:e,previous:e});return g.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pi="Switch",[wT,Gk]=An(pi),[bT,ST]=wT(pi),Pp=g.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=g.useState(null),x=We(t,S=>p(S)),y=g.useRef(!1),v=h?u||!!h.closest("form"):!0,[m,w]=vr({prop:o,defaultProp:s??!1,onChange:c,caller:pi});return d.jsxs(bT,{scope:n,checked:m,disabled:a,children:[d.jsx(Ae.button,{type:"button",role:"switch","aria-checked":m,"aria-required":i,"data-state":Lp(m),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:x,onClick:ge(e.onClick,S=>{w(k=>!k),v&&(y.current=S.isPropagationStopped(),y.current||S.stopPropagation())})}),v&&d.jsx(Dp,{control:h,bubbles:!y.current,name:r,value:l,checked:m,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});Pp.displayName=pi;var Op="SwitchThumb",Mp=g.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=ST(Op,n);return d.jsx(Ae.span,{"data-state":Lp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Mp.displayName=Op;var CT="SwitchBubbleInput",Dp=g.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=g.useRef(null),a=We(i,s),l=Rp(n),c=Vf(t);return g.useEffect(()=>{const u=i.current;if(!u)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const x=new Event("click",{bubbles:r});p.call(u,n),u.dispatchEvent(x)}},[l,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Dp.displayName=CT;function Lp(e){return e?"checked":"unchecked"}var Fp=Pp,TT=Mp;const rr=g.forwardRef(({className:e,...t},n)=>d.jsx(Fp,{className:te("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:d.jsx(TT,{className:te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));rr.displayName=Fp.displayName;var $p=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"}),kT="VisuallyHidden",ET=g.forwardRef((e,t)=>d.jsx(Ae.span,{...e,ref:t,style:{...$p,...e.style}}));ET.displayName=kT;var IT=[" ","Enter","ArrowUp","ArrowDown"],NT=[" ","Enter"],Er="Select",[mi,gi,AT]=Ka(Er),[Vr,Yk]=An(Er,[AT,ni]),yi=ni(),[_T,or]=Vr(Er),[jT,RT]=Vr(Er),zp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:f,disabled:h,required:p,form:x}=e,y=yi(t),[v,m]=g.useState(null),[w,S]=g.useState(null),[k,T]=g.useState(!1),C=Vs(c),[E,P]=vr({prop:r,defaultProp:o??!1,onChange:s,caller:Er}),[_,j]=vr({prop:i,defaultProp:a,onChange:l,caller:Er}),D=g.useRef(null),B=v?x||!!v.closest("form"):!0,[F,O]=g.useState(new Set),$=Array.from(F).map(R=>R.props.value).join(";");return d.jsx(th,{...y,children:d.jsxs(_T,{required:p,scope:t,trigger:v,onTriggerChange:m,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:_n(),value:_,onValueChange:j,open:E,onOpenChange:P,dir:C,triggerPointerDownPosRef:D,disabled:h,children:[d.jsx(mi.Provider,{scope:t,children:d.jsx(jT,{scope:e.__scopeSelect,onNativeOptionAdd:g.useCallback(R=>{O(W=>new Set(W).add(R))},[]),onNativeOptionRemove:g.useCallback(R=>{O(W=>{const U=new Set(W);return U.delete(R),U})},[]),children:n})}),B?d.jsxs(um,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:f,value:_,onChange:R=>j(R.target.value),disabled:h,form:x,children:[_===void 0?d.jsx("option",{value:""}):null,Array.from(F)]},$):null]})})};zp.displayName=Er;var Bp="SelectTrigger",Hp=g.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=yi(n),i=or(Bp,n),a=i.disabled||r,l=We(t,i.onTriggerChange),c=gi(n),u=g.useRef("touch"),[f,h,p]=fm(y=>{const v=c().filter(S=>!S.disabled),m=v.find(S=>S.value===i.value),w=hm(v,y,m);w!==void 0&&i.onValueChange(w.value)}),x=y=>{a||(i.onOpenChange(!0),p()),y&&(i.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return d.jsx(nh,{asChild:!0,...s,children:d.jsx(Ae.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":dm(i.value)?"":void 0,...o,ref:l,onClick:ge(o.onClick,y=>{y.currentTarget.focus(),u.current!=="mouse"&&x(y)}),onPointerDown:ge(o.onPointerDown,y=>{u.current=y.pointerType;const v=y.target;v.hasPointerCapture(y.pointerId)&&v.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(x(y),y.preventDefault())}),onKeyDown:ge(o.onKeyDown,y=>{const v=f.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&h(y.key),!(v&&y.key===" ")&&IT.includes(y.key)&&(x(),y.preventDefault())})})})});Hp.displayName=Bp;var Up="SelectValue",Wp=g.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=or(Up,n),{onValueNodeHasChildrenChange:c}=l,u=s!==void 0,f=We(t,l.onValueNodeChange);return Pt(()=>{c(u)},[c,u]),d.jsx(Ae.span,{...a,ref:f,style:{pointerEvents:"none"},children:dm(l.value)?d.jsx(d.Fragment,{children:i}):s})});Wp.displayName=Up;var PT="SelectIcon",Vp=g.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return d.jsx(Ae.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Vp.displayName=PT;var OT="SelectPortal",Kp=e=>d.jsx(ks,{asChild:!0,...e});Kp.displayName=OT;var Ir="SelectContent",qp=g.forwardRef((e,t)=>{const n=or(Ir,e.__scopeSelect),[r,o]=g.useState();if(Pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Lo.createPortal(d.jsx(Gp,{scope:e.__scopeSelect,children:d.jsx(mi.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(Yp,{...e,ref:t})});qp.displayName=Ir;var Sn=10,[Gp,sr]=Vr(Ir),MT="SelectContentImpl",DT=ur.createSlot("SelectContent.RemoveScroll"),Yp=g.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:x,hideWhenDetached:y,avoidCollisions:v,...m}=e,w=or(Ir,n),[S,k]=g.useState(null),[T,C]=g.useState(null),E=We(t,ee=>k(ee)),[P,_]=g.useState(null),[j,D]=g.useState(null),B=gi(n),[F,O]=g.useState(!1),$=g.useRef(!1);g.useEffect(()=>{if(S)return Fa(S)},[S]),Ra();const R=g.useCallback(ee=>{const[L,...Q]=B().map(de=>de.ref.current),[ue]=Q.slice(-1),ye=document.activeElement;for(const de of ee)if(de===ye||(de==null||de.scrollIntoView({block:"nearest"}),de===L&&T&&(T.scrollTop=0),de===ue&&T&&(T.scrollTop=T.scrollHeight),de==null||de.focus(),document.activeElement!==ye))return},[B,T]),W=g.useCallback(()=>R([P,S]),[R,P,S]);g.useEffect(()=>{F&&W()},[F,W]);const{onOpenChange:U,triggerPointerDownPosRef:z}=w;g.useEffect(()=>{if(S){let ee={x:0,y:0};const L=ue=>{var ye,de;ee={x:Math.abs(Math.round(ue.pageX)-(((ye=z.current)==null?void 0:ye.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((de=z.current)==null?void 0:de.y)??0))}},Q=ue=>{ee.x<=10&&ee.y<=10?ue.preventDefault():S.contains(ue.target)||U(!1),document.removeEventListener("pointermove",L),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Q,{capture:!0})}}},[S,U,z]),g.useEffect(()=>{const ee=()=>U(!1);return window.addEventListener("blur",ee),window.addEventListener("resize",ee),()=>{window.removeEventListener("blur",ee),window.removeEventListener("resize",ee)}},[U]);const[ie,X]=fm(ee=>{const L=B().filter(ye=>!ye.disabled),Q=L.find(ye=>ye.ref.current===document.activeElement),ue=hm(L,ee,Q);ue&&setTimeout(()=>ue.ref.current.focus())}),ae=g.useCallback((ee,L,Q)=>{const ue=!$.current&&!Q;(w.value!==void 0&&w.value===L||ue)&&(_(ee),ue&&($.current=!0))},[w.value]),we=g.useCallback(()=>S==null?void 0:S.focus(),[S]),V=g.useCallback((ee,L,Q)=>{const ue=!$.current&&!Q;(w.value!==void 0&&w.value===L||ue)&&D(ee)},[w.value]),le=r==="popper"?Cl:Xp,xe=le===Cl?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:x,hideWhenDetached:y,avoidCollisions:v}:{};return d.jsx(Gp,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:ae,selectedItem:P,onItemLeave:we,itemTextRefCallback:V,focusSelectedItem:W,selectedItemText:j,position:r,isPositioned:F,searchRef:ie,children:d.jsx(js,{as:DT,allowPinchZoom:!0,children:d.jsx(Ts,{asChild:!0,trapped:w.open,onMountAutoFocus:ee=>{ee.preventDefault()},onUnmountAutoFocus:ge(o,ee=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),ee.preventDefault()}),children:d.jsx(Cs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:ee=>ee.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:d.jsx(le,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:ee=>ee.preventDefault(),...m,...xe,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...m.style},onKeyDown:ge(m.onKeyDown,ee=>{const L=ee.ctrlKey||ee.altKey||ee.metaKey;if(ee.key==="Tab"&&ee.preventDefault(),!L&&ee.key.length===1&&X(ee.key),["ArrowUp","ArrowDown","Home","End"].includes(ee.key)){let ue=B().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(ee.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(ee.key)){const ye=ee.target,de=ue.indexOf(ye);ue=ue.slice(de+1)}setTimeout(()=>R(ue)),ee.preventDefault()}})})})})})})});Yp.displayName=MT;var LT="SelectItemAlignedPosition",Xp=g.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=or(Ir,n),i=sr(Ir,n),[a,l]=g.useState(null),[c,u]=g.useState(null),f=We(t,E=>u(E)),h=gi(n),p=g.useRef(!1),x=g.useRef(!0),{viewport:y,selectedItem:v,selectedItemText:m,focusSelectedItem:w}=i,S=g.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&y&&v&&m){const E=s.trigger.getBoundingClientRect(),P=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),j=m.getBoundingClientRect();if(s.dir!=="rtl"){const ye=j.left-P.left,de=_.left-ye,Re=E.left-de,ce=E.width+Re,Ze=Math.max(ce,P.width),it=window.innerWidth-Sn,ft=yl(de,[Sn,Math.max(Sn,it-Ze)]);a.style.minWidth=ce+"px",a.style.left=ft+"px"}else{const ye=P.right-j.right,de=window.innerWidth-_.right-ye,Re=window.innerWidth-E.right-de,ce=E.width+Re,Ze=Math.max(ce,P.width),it=window.innerWidth-Sn,ft=yl(de,[Sn,Math.max(Sn,it-Ze)]);a.style.minWidth=ce+"px",a.style.right=ft+"px"}const D=h(),B=window.innerHeight-Sn*2,F=y.scrollHeight,O=window.getComputedStyle(c),$=parseInt(O.borderTopWidth,10),R=parseInt(O.paddingTop,10),W=parseInt(O.borderBottomWidth,10),U=parseInt(O.paddingBottom,10),z=$+R+F+U+W,ie=Math.min(v.offsetHeight*5,z),X=window.getComputedStyle(y),ae=parseInt(X.paddingTop,10),we=parseInt(X.paddingBottom,10),V=E.top+E.height/2-Sn,le=B-V,xe=v.offsetHeight/2,ee=v.offsetTop+xe,L=$+R+ee,Q=z-L;if(L<=V){const ye=D.length>0&&v===D[D.length-1].ref.current;a.style.bottom="0px";const de=c.clientHeight-y.offsetTop-y.offsetHeight,Re=Math.max(le,xe+(ye?we:0)+de+W),ce=L+Re;a.style.height=ce+"px"}else{const ye=D.length>0&&v===D[0].ref.current;a.style.top="0px";const Re=Math.max(V,$+y.offsetTop+(ye?ae:0)+xe)+Q;a.style.height=Re+"px",y.scrollTop=L-V+y.offsetTop}a.style.margin=`${Sn}px 0`,a.style.minHeight=ie+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,y,v,m,s.dir,r]);Pt(()=>S(),[S]);const[k,T]=g.useState();Pt(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=g.useCallback(E=>{E&&x.current===!0&&(S(),w==null||w(),x.current=!1)},[S,w]);return d.jsx($T,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:d.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:d.jsx(Ae.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Xp.displayName=LT;var FT="SelectPopperPosition",Cl=g.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Sn,...s}=e,i=yi(n);return d.jsx(rh,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Cl.displayName=FT;var[$T,Tl]=Vr(Ir,{}),kl="SelectViewport",Jp=g.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=sr(kl,n),i=Tl(kl,n),a=We(t,s.onViewportChange),l=g.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),d.jsx(mi.Slot,{scope:n,children:d.jsx(Ae.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ge(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-u.scrollTop);if(p>0){const x=window.innerHeight-Sn*2,y=parseFloat(f.style.minHeight),v=parseFloat(f.style.height),m=Math.max(y,v);if(m<x){const w=m+p,S=Math.min(x,w),k=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(u.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});Jp.displayName=kl;var Zp="SelectGroup",[zT,BT]=Vr(Zp),HT=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_n();return d.jsx(zT,{scope:n,id:o,children:d.jsx(Ae.div,{role:"group","aria-labelledby":o,...r,ref:t})})});HT.displayName=Zp;var Qp="SelectLabel",em=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=BT(Qp,n);return d.jsx(Ae.div,{id:o.id,...r,ref:t})});em.displayName=Qp;var xi="SelectItem",[UT,tm]=Vr(xi),nm=g.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=or(xi,n),l=sr(xi,n),c=a.value===r,[u,f]=g.useState(s??""),[h,p]=g.useState(!1),x=We(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),y=_n(),v=g.useRef("touch"),m=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(UT,{scope:n,value:r,disabled:o,textId:y,isSelected:c,onItemTextChange:g.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:d.jsx(mi.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:d.jsx(Ae.div,{role:"option","aria-labelledby":y,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:ge(i.onFocus,()=>p(!0)),onBlur:ge(i.onBlur,()=>p(!1)),onClick:ge(i.onClick,()=>{v.current!=="mouse"&&m()}),onPointerUp:ge(i.onPointerUp,()=>{v.current==="mouse"&&m()}),onPointerDown:ge(i.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:ge(i.onPointerMove,w=>{var S;v.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ge(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ge(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(NT.includes(w.key)&&m(),w.key===" "&&w.preventDefault())})})})})});nm.displayName=xi;var jo="SelectItemText",rm=g.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=or(jo,n),a=sr(jo,n),l=tm(jo,n),c=RT(jo,n),[u,f]=g.useState(null),h=We(t,m=>f(m),l.onItemTextChange,m=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,m,l.value,l.disabled)}),p=u==null?void 0:u.textContent,x=g.useMemo(()=>d.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:y,onNativeOptionRemove:v}=c;return Pt(()=>(y(x),()=>v(x)),[y,v,x]),d.jsxs(d.Fragment,{children:[d.jsx(Ae.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Lo.createPortal(s.children,i.valueNode):null]})});rm.displayName=jo;var om="SelectItemIndicator",sm=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return tm(om,n).isSelected?d.jsx(Ae.span,{"aria-hidden":!0,...r,ref:t}):null});sm.displayName=om;var El="SelectScrollUpButton",im=g.forwardRef((e,t)=>{const n=sr(El,e.__scopeSelect),r=Tl(El,e.__scopeSelect),[o,s]=g.useState(!1),i=We(t,r.onScrollButtonChange);return Pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});im.displayName=El;var Il="SelectScrollDownButton",am=g.forwardRef((e,t)=>{const n=sr(Il,e.__scopeSelect),r=Tl(Il,e.__scopeSelect),[o,s]=g.useState(!1),i=We(t,r.onScrollButtonChange);return Pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});am.displayName=Il;var lm=g.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=sr("SelectScrollButton",n),i=g.useRef(null),a=gi(n),l=g.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return g.useEffect(()=>()=>l(),[l]),Pt(()=>{var u;const c=a().find(f=>f.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),d.jsx(Ae.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ge(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ge(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ge(o.onPointerLeave,()=>{l()})})}),WT="SelectSeparator",cm=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return d.jsx(Ae.div,{"aria-hidden":!0,...r,ref:t})});cm.displayName=WT;var Nl="SelectArrow",VT=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yi(n),s=or(Nl,n),i=sr(Nl,n);return s.open&&i.position==="popper"?d.jsx(oh,{...o,...r,ref:t}):null});VT.displayName=Nl;var KT="SelectBubbleInput",um=g.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=g.useRef(null),s=We(r,o),i=Rp(t);return g.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&u){const f=new Event("change",{bubbles:!0});u.call(a,t),a.dispatchEvent(f)}},[i,t]),d.jsx(Ae.select,{...n,style:{...$p,...n.style},ref:s,defaultValue:t})});um.displayName=KT;function dm(e){return e===""||e===void 0}function fm(e){const t=Mt(e),n=g.useRef(""),r=g.useRef(0),o=g.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function hm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=qT(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function qT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var GT=zp,pm=Hp,YT=Wp,XT=Vp,JT=Kp,mm=qp,ZT=Jp,gm=em,ym=nm,QT=rm,ek=sm,xm=im,vm=am,wm=cm;const bm=GT,Sm=YT,Al=g.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(pm,{ref:r,className:te("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,d.jsx(XT,{asChild:!0,children:d.jsx(he.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Al.displayName=pm.displayName;const Cm=g.forwardRef(({className:e,...t},n)=>d.jsx(xm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(he.ChevronUp,{className:"h-4 w-4"})}));Cm.displayName=xm.displayName;const Tm=g.forwardRef(({className:e,...t},n)=>d.jsx(vm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(he.ChevronDown,{className:"h-4 w-4"})}));Tm.displayName=vm.displayName;const _l=g.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>d.jsx(JT,{children:d.jsxs(mm,{ref:o,className:te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[d.jsx(Cm,{}),d.jsx(ZT,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(Tm,{})]})}));_l.displayName=mm.displayName;const tk=g.forwardRef(({className:e,...t},n)=>d.jsx(gm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));tk.displayName=gm.displayName;const Nr=g.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(ym,{ref:r,className:te("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(ek,{children:d.jsx(he.Check,{className:"h-4 w-4"})})}),d.jsx(QT,{children:t})]}));Nr.displayName=ym.displayName;const nk=g.forwardRef(({className:e,...t},n)=>d.jsx(wm,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));nk.displayName=wm.displayName;var rk="Separator",km="horizontal",ok=["horizontal","vertical"],Em=g.forwardRef((e,t)=>{const{decorative:n,orientation:r=km,...o}=e,s=sk(r)?r:km,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(Ae.div,{"data-orientation":s,...a,...o,ref:t})});Em.displayName=rk;function sk(e){return ok.includes(e)}var Im=Em;const Nm=g.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>d.jsx(Im,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Nm.displayName=Im.displayName;const ik=Jd,ak=Eb,lk=Zd,Am=g.forwardRef(({className:e,...t},n)=>d.jsx(Ds,{className:te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Am.displayName=Ds.displayName;const ck=Do.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),_m=g.forwardRef(({side:e="right",className:t,children:n,...r},o)=>d.jsxs(lk,{children:[d.jsx(Am,{}),d.jsxs(Ls,{ref:o,className:te(ck({side:e}),t),...r,children:[n,d.jsxs(Qd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[d.jsx(he.X,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_m.displayName=Ls.displayName;const jm=({className:e,...t})=>d.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});jm.displayName="SheetHeader";const Rm=g.forwardRef(({className:e,...t},n)=>d.jsx(br,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));Rm.displayName=br.displayName;const Pm=g.forwardRef(({className:e,...t},n)=>d.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));Pm.displayName=Fs.displayName;const uk={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function dk({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,u]=b.useState(!1),{toast:f}=Ea();b.useEffect(()=>{const v=JSON.stringify(a)!==JSON.stringify(e);u(v)},[a,e]),b.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),u(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(uk),u(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},x=()=>{l(e),u(!1),o(!1)},y=async()=>{try{const m=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${m.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return d.jsxs(ik,{open:r,onOpenChange:o,children:[d.jsx(ak,{asChild:!0,children:d.jsxs(nt,{variant:"outline",size:"sm",className:n,children:[d.jsx(he.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&d.jsx(ed,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),d.jsxs(_m,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[d.jsxs(jm,{children:[d.jsx(Rm,{children:"Chat Settings"}),d.jsx(Pm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),d.jsxs("div",{className:"space-y-6 py-6",children:[d.jsxs(po,{children:[d.jsx(mo,{className:"pb-3",children:d.jsxs(go,{className:"text-lg flex items-center gap-2",children:[d.jsx(he.Server,{className:"h-5 w-5"}),"API Configuration"]})}),d.jsxs(yo,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(fn,{htmlFor:"api-url",children:"API Base URL"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(ci,{id:"api-url",value:a.api.baseUrl,onChange:v=>l(m=>({...m,api:{...m.api,baseUrl:v.target.value}})),placeholder:"http://localhost:8000/api"}),d.jsx(nt,{variant:"outline",onClick:y,children:"Test"})]})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(fn,{htmlFor:"enable-auth",children:"Enable Authentication"}),d.jsx(rr,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:v=>l(m=>({...m,api:{...m.api,enableAuth:v}}))})]}),a.api.enableAuth&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(fn,{htmlFor:"auth-token",children:"Authentication Token"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(ci,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:v=>l(m=>({...m,api:{...m.api,authToken:v.target.value}})),placeholder:"Enter your Bearer token"}),d.jsx(nt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?d.jsx(he.EyeOff,{className:"h-4 w-4"}):d.jsx(he.Eye,{className:"h-4 w-4"})})]})]})]})]}),d.jsxs(po,{children:[d.jsx(mo,{className:"pb-3",children:d.jsxs(go,{className:"text-lg flex items-center gap-2",children:[d.jsx(he.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),d.jsxs(yo,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(fn,{htmlFor:"layout",children:"Layout Style"}),d.jsxs(bm,{value:a.ui.layout,onValueChange:v=>l(m=>({...m,ui:{...m.ui,layout:v}})),children:[d.jsx(Al,{children:d.jsx(Sm,{})}),d.jsxs(_l,{children:[d.jsx(Nr,{value:"sidebar",children:"Sidebar Layout"}),d.jsx(Nr,{value:"fullscreen",children:"Fullscreen"}),d.jsx(Nr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(fn,{htmlFor:"theme",children:"Theme"}),d.jsxs(bm,{value:a.ui.theme,onValueChange:v=>l(m=>({...m,ui:{...m.ui,theme:v}})),children:[d.jsx(Al,{children:d.jsx(Sm,{})}),d.jsxs(_l,{children:[d.jsx(Nr,{value:"light",children:"Light"}),d.jsx(Nr,{value:"dark",children:"Dark"}),d.jsx(Nr,{value:"system",children:"System"})]})]})]}),d.jsx(Nm,{}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(fn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),d.jsx(rr,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:v=>l(m=>({...m,ui:{...m.ui,showTimestamps:v}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(fn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),d.jsx(rr,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:v=>l(m=>({...m,ui:{...m.ui,showAgentNames:v}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(fn,{htmlFor:"compact-messages",children:"Compact Messages"}),d.jsx(rr,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:v=>l(m=>({...m,ui:{...m.ui,compactMessages:v}}))})]})]})]})]}),d.jsxs(po,{children:[d.jsx(mo,{className:"pb-3",children:d.jsxs(go,{className:"text-lg flex items-center gap-2",children:[d.jsx(he.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),d.jsxs(yo,{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(fn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),d.jsx(rr,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:v=>l(m=>({...m,behavior:{...m.behavior,autoSave:v}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(fn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),d.jsx(rr,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:v=>l(m=>({...m,behavior:{...m.behavior,enableStreaming:v}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(fn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),d.jsx(rr,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:v=>l(m=>({...m,behavior:{...m.behavior,showTypingIndicator:v}}))})]})]})]})]}),d.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[d.jsxs(nt,{variant:"outline",onClick:p,children:[d.jsx(he.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(nt,{variant:"outline",onClick:x,children:"Cancel"}),d.jsxs(nt,{onClick:h,disabled:!c,children:[d.jsx(he.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function fk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const u="h-full";switch(c){case"phone":return`${u} max-w-none`;case"tablet":return`${u} max-w-4xl mx-auto`;case"half-screen":return`${u} max-w-2xl`;case"desktop":default:return`${u} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var u;(u=s.onThreadChange)==null||u.call(s,c)},[s]);return e==="fullscreen"?d.jsx(os,{...s,onThreadChange:l,children:d.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:d.jsx(li,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?d.jsx(os,{...s,onThreadChange:l,children:d.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:d.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&d.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:d.jsx(Sl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),d.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:d.jsx(li,{onError:s.onError,enableFileUpload:!0})})]})})}):d.jsx(os,{...s,onThreadChange:l,children:d.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&d.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:d.jsx(Sl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),d.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:d.jsx(li,{onError:s.onError,enableFileUpload:!0})})]})})}_e.ChatApi=Ac,_e.ChatInterface=li,_e.ChatProviders=os,_e.ChatSettings=dk,_e.MarkdownContent=bo,_e.MessageComponent=Wa,_e.MessageList=Va,_e.ThreadManager=Sl,_e.applySettings=yT,_e.chatApiClient=qn,_e.default=fk,_e.del=Nc,_e.get=mn,_e.getChatToken=kc,_e.getCurrentSettings=gT,_e.getDefaultApiConfig=Ip,_e.getDefaultChatSettings=Np,_e.onChatTokenChanged=Ec,_e.post=Oi,_e.put=Ic,_e.setChatToken=Pi,_e.useApi=Mi,_e.useChatStream=Wc,_e.useMessagesReducer=Dc,_e.useStream=eu,_e.useThreadState=rs,_e.useThreads=ns,Object.defineProperties(_e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED