teodor-new-chat-ui 3.0.189 → 3.0.190
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
|
@@ -13571,7 +13571,7 @@ function ti({
|
|
|
13571
13571
|
}
|
|
13572
13572
|
}, [v, y, De, ke, S, C]), Ne = (te) => {
|
|
13573
13573
|
const pe = Array.from(te.target.files || []);
|
|
13574
|
-
J((je) => [...je, ...pe]);
|
|
13574
|
+
J((je) => [...je, ...pe]), te.target.value = "";
|
|
13575
13575
|
}, at = (te) => J((pe) => pe.filter((je, Fe) => te !== Fe)), Lt = async (te) => {
|
|
13576
13576
|
const pe = (te.target.files || [])[0];
|
|
13577
13577
|
if (pe) {
|
package/dist/index.umd.js
CHANGED
|
@@ -136,4 +136,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
136
136
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
137
137
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
138
138
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
139
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Mw(e,t=Go){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 Dw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Mw(t),Ow(t)}function Fi(e){const t=e+"CollectionProvider",[n,r]=rn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,w=C.useRef(null),y=C.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:y,collectionRef:w,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=An.createSlot(a),u=C.forwardRef((v,g)=>{const{scope:x,children:w}=v,y=s(a,x),E=Me(g,y.collectionRef);return l.jsx(c,{ref:E,children:w})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=An.createSlot(d),m=C.forwardRef((v,g)=>{const{scope:x,children:w,...y}=v,E=C.useRef(null),S=Me(g,E),T=s(d,x);return C.useEffect(()=>(T.itemMap.set(E,{ref:E,...y}),()=>void T.itemMap.delete(E))),l.jsx(h,{[f]:"",ref:S,children:w})});m.displayName=d;function b(v){const g=s(e+"CollectionConsumer",v);return C.useCallback(()=>{const w=g.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},b,r]}var Lw=p.createContext(void 0);function Yo(e){const t=p.useContext(Lw);return e||t||"ltr"}const $w=["top","right","bottom","left"],Tn=Math.min,jt=Math.max,Xo=Math.round,Jo=Math.floor,an=e=>({x:e,y:e}),Fw={left:"right",right:"left",bottom:"top",top:"bottom"},zw={start:"end",end:"start"};function zi(e,t,n){return jt(e,Tn(t,n))}function hn(e,t){return typeof e=="function"?e(t):e}function pn(e){return e.split("-")[0]}function ir(e){return e.split("-")[1]}function Bi(e){return e==="x"?"y":"x"}function Hi(e){return e==="y"?"height":"width"}const Bw=new Set(["top","bottom"]);function ln(e){return Bw.has(pn(e))?"y":"x"}function Ui(e){return Bi(ln(e))}function Hw(e,t,n){n===void 0&&(n=!1);const r=ir(e),o=Ui(e),s=Hi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Zo(i)),[i,Zo(i)]}function Uw(e){const t=Zo(e);return[Wi(e),t,Wi(t)]}function Wi(e){return e.replace(/start|end/g,t=>zw[t])}const Yu=["left","right"],Xu=["right","left"],Ww=["top","bottom"],Vw=["bottom","top"];function qw(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Ww:Vw;default:return[]}}function Kw(e,t,n,r){const o=ir(e);let s=qw(pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Wi)))),s}function Zo(e){return e.replace(/left|right|bottom|top/g,t=>Fw[t])}function Gw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?Gw(e):{top:e,right:e,bottom:e,left:e}}function Qo(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 Zu(e,t,n){let{reference:r,floating:o}=e;const s=ln(t),i=Ui(t),a=Hi(i),c=pn(t),u=s==="y",d=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 m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(ir(t)){case"start":m[i]-=h*(n&&u?-1:1);break;case"end":m[i]+=h*(n&&u?-1:1);break}return m}const Yw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=Zu(u,r,c),h=r,m={},b=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:w,y,data:E,reset:S}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=w??d,f=y??f,m={...m,[g]:{...m[g],...E}},S&&b<=50&&(b++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=Zu(u,h,c)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}};async function Pr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=hn(t,e),b=Ju(m),g=a[h?f==="floating"?"reference":"floating":f],x=Qo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=Qo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:y,strategy:c}):w);return{top:(x.top-S.top+b.top)/E.y,bottom:(S.bottom-x.bottom+b.bottom)/E.y,left:(x.left-S.left+b.left)/E.x,right:(S.right-x.right+b.right)/E.x}}const Xw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=hn(e,t)||{};if(u==null)return{};const f=Ju(d),h={x:n,y:r},m=Ui(o),b=Hi(m),v=await i.getDimensions(u),g=m==="y",x=g?"top":"left",w=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[b]+s.reference[m]-h[m]-s.floating[b],S=h[m]-s.reference[m],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[b]);const N=E/2-S/2,A=I/2-v[b]/2-1,j=Tn(f[x],A),_=Tn(f[w],A),z=j,V=I-v[b]-_,O=I/2-v[b]/2+N,G=zi(z,O,V),W=!c.arrow&&ir(o)!=null&&O!==G&&s.reference[b]/2-(O<z?j:_)-v[b]/2<0,q=W?O<z?O-z:O-V:0;return{[m]:h[m]+q,data:{[m]:G,centerOffset:O-G-q,...W&&{alignmentOffset:q}},reset:W}}}),Jw=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:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:v=!0,...g}=hn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=pn(o),w=ln(a),y=pn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=h||(y||!v?[Zo(a)]:Uw(a)),T=b!=="none";!h&&T&&S.push(...Kw(a,v,b,E));const I=[a,...S],N=await Pr(t,g),A=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&A.push(N[x]),f){const O=Hw(o,i,E);A.push(N[O[0]],N[O[1]])}if(j=[...j,{placement:o,overflows:A}],!A.every(O=>O<=0)){var _,z;const O=(((_=s.flip)==null?void 0:_.index)||0)+1,G=I[O];if(G&&(!(f==="alignment"?w!==ln(G):!1)||j.every(L=>ln(L.placement)===w?L.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:G}};let W=(z=j.filter(q=>q.overflows[0]<=0).sort((q,L)=>q.overflows[1]-L.overflows[1])[0])==null?void 0:z.placement;if(!W)switch(m){case"bestFit":{var V;const q=(V=j.filter(L=>{if(T){const M=ln(L.placement);return M===w||M==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(M=>M>0).reduce((M,le)=>M+le,0)]).sort((L,M)=>L[1]-M[1])[0])==null?void 0:V[0];q&&(W=q);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return $w.some(t=>e[t]>=0)}const Zw=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 Pr(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await Pr(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function Qw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=pn(n),a=ir(n),c=ln(n)==="y",u=td.has(i)?-1:1,d=s&&c?-1:1,f=hn(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof b=="number"&&(m=a==="end"?b*-1:b),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const eb=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,c=await Qw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},tb=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:g=>{let{x,y:w}=g;return{x,y:w}}},...c}=hn(e,t),u={x:n,y:r},d=await Pr(t,c),f=ln(pn(o)),h=Bi(f);let m=u[h],b=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",w=m+d[g],y=m-d[x];m=zi(w,m,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",w=b+d[g],y=b-d[x];b=zi(w,b,y)}const v=a.fn({...t,[h]:m,[f]:b});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},nb=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:c=!0,crossAxis:u=!0}=hn(e,t),d={x:n,y:r},f=ln(o),h=Bi(f);let m=d[h],b=d[f];const v=hn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const y=h==="y"?"height":"width",E=s.reference[h]-s.floating[y]+g.mainAxis,S=s.reference[h]+s.reference[y]-g.mainAxis;m<E?m=E:m>S&&(m=S)}if(u){var x,w;const y=h==="y"?"width":"height",E=td.has(pn(o)),S=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(E?0:((w=i.offset)==null?void 0:w[f])||0)-(E?g.crossAxis:0);b<S?b=S:b>T&&(b=T)}return{[h]:m,[f]:b}}}},rb=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:c=()=>{},...u}=hn(e,t),d=await Pr(t,u),f=pn(o),h=ir(o),m=ln(o)==="y",{width:b,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const w=v-d.top-d.bottom,y=b-d.left-d.right,E=Tn(v-d[g],w),S=Tn(b-d[x],y),T=!t.middlewareData.shift;let I=E,N=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=w),T&&!h){const j=jt(d.left,0),_=jt(d.right,0),z=jt(d.top,0),V=jt(d.bottom,0);m?N=b-2*(j!==0||_!==0?j+_:jt(d.left,d.right)):I=v-2*(z!==0||V!==0?z+V:jt(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const A=await i.getDimensions(a.floating);return b!==A.width||v!==A.height?{reset:{rects:!0}}:{}}}};function es(){return typeof window<"u"}function ar(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function cn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return es()?e instanceof Node||e instanceof Pt(e).Node:!1}function Xt(e){return es()?e instanceof Element||e instanceof Pt(e).Element:!1}function un(e){return es()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function rd(e){return!es()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const ob=new Set(["inline","contents"]);function Or(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Jt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!ob.has(o)}const sb=new Set(["table","td","th"]);function ib(e){return sb.has(ar(e))}const ab=[":popover-open",":modal"];function ts(e){return ab.some(t=>{try{return e.matches(t)}catch{return!1}})}const lb=["transform","translate","scale","rotate","perspective"],cb=["transform","translate","scale","rotate","perspective","filter"],ub=["paint","layout","strict","content"];function Vi(e){const t=qi(),n=Xt(e)?Jt(e):e;return lb.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)||cb.some(r=>(n.willChange||"").includes(r))||ub.some(r=>(n.contain||"").includes(r))}function db(e){let t=kn(e);for(;un(t)&&!lr(t);){if(Vi(t))return t;if(ts(t))return null;t=kn(t)}return null}function qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const fb=new Set(["html","body","#document"]);function lr(e){return fb.has(ar(e))}function Jt(e){return Pt(e).getComputedStyle(e)}function ns(e){return Xt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kn(e){if(ar(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||cn(e);return rd(t)?t.host:t}function od(e){const t=kn(e);return lr(t)?e.ownerDocument?e.ownerDocument.body:e.body:un(t)&&Or(t)?t:od(t)}function Mr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const a=Ki(i);return t.concat(i,i.visualViewport||[],Or(o)?o:[],a&&n?Mr(a):[])}return t.concat(o,Mr(o,[],n))}function Ki(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=Jt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=un(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Xo(n)!==s||Xo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Gi(e){return Xt(e)?e:e.contextElement}function cr(e){const t=Gi(e);if(!un(t))return an(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Xo(n.width):n.width)/r,a=(s?Xo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const hb=an(0);function id(e){const t=Pt(e);return!qi()||!t.visualViewport?hb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function pb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function Hn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Gi(e);let i=an(1);t&&(r?Xt(r)&&(i=cr(r)):i=cr(e));const a=pb(s,n,r)?id(s):an(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Pt(s),m=r&&Xt(r)?Pt(r):r;let b=h,v=Ki(b);for(;v&&r&&m!==b;){const g=cr(v),x=v.getBoundingClientRect(),w=Jt(v),y=x.left+(v.clientLeft+parseFloat(w.paddingLeft))*g.x,E=x.top+(v.clientTop+parseFloat(w.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=y,u+=E,b=Pt(v),v=Ki(b)}}return Qo({width:d,height:f,x:c,y:u})}function Yi(e,t){const n=ns(e).scrollLeft;return t?t.left+n:Hn(cn(e)).left+n}function ad(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Yi(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function mb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=cn(r),a=t?ts(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=an(1);const d=an(0),f=un(r);if((f||!f&&!s)&&((ar(r)!=="body"||Or(i))&&(c=ns(r)),un(r))){const m=Hn(r);u=cr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=i&&!f&&!s?ad(i,c,!0):an(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function gb(e){return Array.from(e.getClientRects())}function xb(e){const t=cn(e),n=ns(e),r=e.ownerDocument.body,o=jt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=jt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Yi(e);const a=-n.scrollTop;return Jt(r).direction==="rtl"&&(i+=jt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function vb(e,t){const n=Pt(e),r=cn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=qi();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const wb=new Set(["absolute","fixed"]);function bb(e,t){const n=Hn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=un(e)?cr(e):an(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function ld(e,t,n){let r;if(t==="viewport")r=vb(e,n);else if(t==="document")r=xb(cn(e));else if(Xt(t))r=bb(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Qo(r)}function cd(e,t){const n=kn(e);return n===t||!Xt(n)||lr(n)?!1:Jt(n).position==="fixed"||cd(n,t)}function yb(e,t){const n=t.get(e);if(n)return n;let r=Mr(e,[],!1).filter(a=>Xt(a)&&ar(a)!=="body"),o=null;const s=Jt(e).position==="fixed";let i=s?kn(e):e;for(;Xt(i)&&!lr(i);){const a=Jt(i),c=Vi(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&wb.has(o.position)||Or(i)&&!c&&cd(e,i))?r=r.filter(d=>d!==i):o=a,i=kn(i)}return t.set(e,r),r}function Sb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ts(t)?[]:yb(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=ld(t,d,o);return u.top=jt(f.top,u.top),u.right=Tn(f.right,u.right),u.bottom=Tn(f.bottom,u.bottom),u.left=jt(f.left,u.left),u},ld(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Cb(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Tb(e,t,n){const r=un(t),o=cn(t),s=n==="fixed",i=Hn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=an(0);function u(){c.x=Yi(o)}if(r||!r&&!s)if((ar(t)!=="body"||Or(o))&&(a=ns(t)),r){const m=Hn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?ad(o,a):an(0),f=i.left+a.scrollLeft-c.x-d.x,h=i.top+a.scrollTop-c.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Xi(e){return Jt(e).position==="static"}function ud(e,t){if(!un(e)||Jt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return cn(e)===n&&(n=n.ownerDocument.body),n}function dd(e,t){const n=Pt(e);if(ts(e))return n;if(!un(e)){let o=kn(e);for(;o&&!lr(o);){if(Xt(o)&&!Xi(o))return o;o=kn(o)}return n}let r=ud(e,t);for(;r&&ib(r)&&Xi(r);)r=ud(r,t);return r&&lr(r)&&Xi(r)&&!Vi(r)?n:r||db(e)||n}const kb=async function(e){const t=this.getOffsetParent||dd,n=this.getDimensions,r=await n(e.floating);return{reference:Tb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eb(e){return Jt(e).direction==="rtl"}const Ib={convertOffsetParentRelativeRectToViewportRelativeRect:mb,getDocumentElement:cn,getClippingRect:Sb,getOffsetParent:dd,getElementRects:kb,getClientRects:gb,getDimensions:Cb,getScale:cr,isElement:Xt,isRTL:Eb};function fd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Nb(e,t){let n=null,r;const o=cn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(a||t(),!h||!m)return;const b=Jo(f),v=Jo(o.clientWidth-(d+h)),g=Jo(o.clientHeight-(f+m)),x=Jo(d),y={rootMargin:-b+"px "+-v+"px "+-g+"px "+-x+"px",threshold:jt(0,Tn(1,c))||1};let E=!0;function S(T){const I=T[0].intersectionRatio;if(I!==c){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!fd(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,y)}n.observe(e)}return i(!0),s}function Ab(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:c=!1}=r,u=Gi(e),d=o||s?[...u?Mr(u):[],...Mr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Nb(u,n):null;let h=-1,m=null;i&&(m=new ResizeObserver(x=>{let[w]=x;w&&w.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let b,v=c?Hn(e):null;c&&g();function g(){const x=Hn(e);v&&!fd(v,x)&&n(),v=x,b=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(b)}}const _b=eb,Rb=tb,jb=Jw,Pb=rb,Ob=Zw,hd=Xw,Mb=nb,Db=(e,t,n)=>{const r=new Map,o={platform:Ib,...n},s={...o.platform,_c:r};return Yw(e,t,{...o,platform:s})};var Lb=typeof document<"u",$b=function(){},rs=Lb?C.useLayoutEffect:$b;function os(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(!os(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)&&!os(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function pd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function md(e,t){const n=pd(e);return Math.round(t*n)/n}function Ji(e){const t=p.useRef(e);return rs(()=>{t.current=e}),t}function Fb(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:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);os(h,r)||m(r);const[b,v]=p.useState(null),[g,x]=p.useState(null),w=p.useCallback(L=>{L!==T.current&&(T.current=L,v(L))},[]),y=p.useCallback(L=>{L!==I.current&&(I.current=L,x(L))},[]),E=s||b,S=i||g,T=p.useRef(null),I=p.useRef(null),N=p.useRef(d),A=c!=null,j=Ji(c),_=Ji(o),z=Ji(u),V=p.useCallback(()=>{if(!T.current||!I.current)return;const L={placement:t,strategy:n,middleware:h};_.current&&(L.platform=_.current),Db(T.current,I.current,L).then(M=>{const le={...M,isPositioned:z.current!==!1};O.current&&!os(N.current,le)&&(N.current=le,Gr.flushSync(()=>{f(le)}))})},[h,t,n,_,z]);rs(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[u]);const O=p.useRef(!1);rs(()=>(O.current=!0,()=>{O.current=!1}),[]),rs(()=>{if(E&&(T.current=E),S&&(I.current=S),E&&S){if(j.current)return j.current(E,S,V);V()}},[E,S,V,j,A]);const G=p.useMemo(()=>({reference:T,floating:I,setReference:w,setFloating:y}),[w,y]),W=p.useMemo(()=>({reference:E,floating:S}),[E,S]),q=p.useMemo(()=>{const L={position:n,left:0,top:0};if(!W.floating)return L;const M=md(W.floating,d.x),le=md(W.floating,d.y);return a?{...L,transform:"translate("+M+"px, "+le+"px)",...pd(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:le}},[n,a,W.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:V,refs:G,elements:W,floatingStyles:q}),[d,V,G,W,q])}const zb=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?hd({element:r.current,padding:o}).fn(n):{}:r?hd({element:r,padding:o}).fn(n):{}}}},Bb=(e,t)=>({..._b(e),options:[e,t]}),Hb=(e,t)=>({...Rb(e),options:[e,t]}),Ub=(e,t)=>({...Mb(e),options:[e,t]}),Wb=(e,t)=>({...jb(e),options:[e,t]}),Vb=(e,t)=>({...Pb(e),options:[e,t]}),qb=(e,t)=>({...Ob(e),options:[e,t]}),Kb=(e,t)=>({...zb(e),options:[e,t]});var Gb="Arrow",gd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});gd.displayName=Gb;var Yb=gd;function xd(e){const[t,n]=p.useState(void 0);return ht(()=>{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 c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.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 Zi="Popper",[vd,ss]=rn(Zi),[Xb,wd]=vd(Zi),bd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return l.jsx(Xb,{scope:t,anchor:r,onAnchorChange:o,children:n})};bd.displayName=Zi;var yd="PopperAnchor",Sd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=wd(yd,n),i=p.useRef(null),a=Me(t,i),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(ye.div,{...o,ref:a})});Sd.displayName=yd;var Qi="PopperContent",[Jb,Zb]=vd(Qi),Cd=p.forwardRef((e,t)=>{var $,P,H,Q,ce,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:b,...v}=e,g=wd(Qi,n),[x,w]=p.useState(null),y=Me(t,Fe=>w(Fe)),[E,S]=p.useState(null),T=xd(E),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,A=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},_=Array.isArray(u)?u:[u],z=_.length>0,V={padding:j,boundary:_.filter(ey),altBoundary:z},{refs:O,floatingStyles:G,placement:W,isPositioned:q,middlewareData:L}=Fb({strategy:"fixed",placement:A,whileElementsMounted:(...Fe)=>Ab(...Fe,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[Bb({mainAxis:o+N,alignmentAxis:i}),c&&Hb({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Ub():void 0,...V}),c&&Wb({...V}),Vb({...V,apply:({elements:Fe,rects:$e,availableWidth:we,availableHeight:Ne})=>{const{width:Ue,height:et}=$e.reference,Xe=Fe.floating.style;Xe.setProperty("--radix-popper-available-width",`${we}px`),Xe.setProperty("--radix-popper-available-height",`${Ne}px`),Xe.setProperty("--radix-popper-anchor-width",`${Ue}px`),Xe.setProperty("--radix-popper-anchor-height",`${et}px`)}}),E&&Kb({element:E,padding:a}),ty({arrowWidth:I,arrowHeight:N}),h&&qb({strategy:"referenceHidden",...V})]}),[M,le]=Ed(W),J=pt(b);ht(()=>{q&&(J==null||J())},[q,J]);const ee=($=L.arrow)==null?void 0:$.x,D=(P=L.arrow)==null?void 0:P.y,Z=((H=L.arrow)==null?void 0:H.centerOffset)!==0,[ke,he]=p.useState();return ht(()=>{x&&he(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:q?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[(Q=L.transformOrigin)==null?void 0:Q.x,(ce=L.transformOrigin)==null?void 0:ce.y].join(" "),...((ie=L.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(Jb,{scope:n,placedSide:M,onArrowChange:S,arrowX:ee,arrowY:D,shouldHideArrow:Z,children:l.jsx(ye.div,{"data-side":M,"data-align":le,...v,ref:y,style:{...v.style,animation:q?void 0:"none"}})})})});Cd.displayName=Qi;var Td="PopperArrow",Qb={top:"bottom",right:"left",bottom:"top",left:"right"},kd=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Zb(Td,r),i=Qb[s.placedSide];return l.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:l.jsx(Yb,{...o,ref:n,style:{...o.style,display:"block"}})})});kd.displayName=Td;function ey(e){return e!==null}var ty=e=>({name:"transformOrigin",options:e,fn(t){var g,x,w;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Ed(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((w=o.arrow)==null?void 0:w.y)??0)+c/2;let b="",v="";return u==="bottom"?(b=i?f:`${h}px`,v=`${-c}px`):u==="top"?(b=i?f:`${h}px`,v=`${r.floating.height+c}px`):u==="right"?(b=`${-c}px`,v=i?f:`${m}px`):u==="left"&&(b=`${r.floating.width+c}px`,v=i?f:`${m}px`),{data:{x:b,y:v}}}});function Ed(e){const[t,n="center"]=e.split("-");return[t,n]}var Id=bd,Nd=Sd,Ad=Cd,_d=kd,ea="rovingFocusGroup.onEntryFocus",ny={bubbles:!1,cancelable:!0},Dr="RovingFocusGroup",[ta,Rd,ry]=Fi(Dr),[oy,jd]=rn(Dr,[ry]),[sy,iy]=oy(Dr),Pd=p.forwardRef((e,t)=>l.jsx(ta.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ta.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ay,{...e,ref:t})})}));Pd.displayName=Dr;var ay=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=p.useRef(null),m=Me(t,h),b=Yo(s),[v,g]=Ln({prop:i,defaultProp:a??null,onChange:c,caller:Dr}),[x,w]=p.useState(!1),y=pt(u),E=Rd(n),S=p.useRef(!1),[T,I]=p.useState(0);return p.useEffect(()=>{const N=h.current;if(N)return N.addEventListener(ea,y),()=>N.removeEventListener(ea,y)},[y]),l.jsx(sy,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:v,onItemFocus:p.useCallback(N=>g(N),[g]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>I(N=>N-1),[]),children:l.jsx(ye.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{S.current=!0}),onFocus:ae(e.onFocus,N=>{const A=!S.current;if(N.target===N.currentTarget&&A&&!x){const j=new CustomEvent(ea,ny);if(N.currentTarget.dispatchEvent(j),!j.defaultPrevented){const _=E().filter(W=>W.focusable),z=_.find(W=>W.active),V=_.find(W=>W.id===v),G=[z,V,..._].filter(Boolean).map(W=>W.ref.current);Dd(G,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>w(!1))})})}),Od="RovingFocusGroupItem",Md=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=on(),u=s||c,d=iy(Od,n),f=d.currentTabStopId===u,h=Rd(n),{onFocusableItemAdd:m,onFocusableItemRemove:b,currentTabStopId:v}=d;return p.useEffect(()=>{if(r)return m(),()=>b()},[r,m,b]),l.jsx(ta.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(ye.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:ae(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=uy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=d.loop?dy(y,E+1):y.slice(E+1)}setTimeout(()=>Dd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});Md.displayName=Od;var ly={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function uy(e,t,n){const r=cy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ly[r]}function Dd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function dy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fy=Pd,hy=Md,na=["Enter"," "],py=["ArrowDown","PageUp","Home"],Ld=["ArrowUp","PageDown","End"],my=[...py,...Ld],gy={ltr:[...na,"ArrowRight"],rtl:[...na,"ArrowLeft"]},xy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Lr="Menu",[$r,vy,wy]=Fi(Lr),[Un,$d]=rn(Lr,[wy,ss,jd]),is=ss(),Fd=jd(),[by,Wn]=Un(Lr),[yy,Fr]=Un(Lr),zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=is(t),[c,u]=p.useState(null),d=p.useRef(!1),f=pt(s),h=Yo(o);return p.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),l.jsx(Id,{...a,children:l.jsx(by,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(yy,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};zd.displayName=Lr;var Sy="MenuAnchor",ra=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=is(n);return l.jsx(Nd,{...o,...r,ref:t})});ra.displayName=Sy;var oa="MenuPortal",[Cy,Bd]=Un(oa,{forceMount:void 0}),Hd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Wn(oa,t);return l.jsx(Cy,{scope:t,forceMount:n,children:l.jsx(Rt,{present:n||s.open,children:l.jsx(Po,{asChild:!0,container:o,children:r})})})};Hd.displayName=oa;var zt="MenuContent",[Ty,sa]=Un(zt),Ud=p.forwardRef((e,t)=>{const n=Bd(zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Wn(zt,e.__scopeMenu),i=Fr(zt,e.__scopeMenu);return l.jsx($r.Provider,{scope:e.__scopeMenu,children:l.jsx(Rt,{present:r||s.open,children:l.jsx($r.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(ky,{...o,ref:t}):l.jsx(Ey,{...o,ref:t})})})})}),ky=p.forwardRef((e,t)=>{const n=Wn(zt,e.__scopeMenu),r=p.useRef(null),o=Me(t,r);return p.useEffect(()=>{const s=r.current;if(s)return ji(s)},[]),l.jsx(ia,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ey=p.forwardRef((e,t)=>{const n=Wn(zt,e.__scopeMenu);return l.jsx(ia,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Iy=An.createSlot("MenuContent.ScrollLock"),ia=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,disableOutsideScroll:b,...v}=e,g=Wn(zt,n),x=Fr(zt,n),w=is(n),y=Fd(n),E=vy(n),[S,T]=p.useState(null),I=p.useRef(null),N=Me(t,I,g.onContentChange),A=p.useRef(0),j=p.useRef(""),_=p.useRef(0),z=p.useRef(null),V=p.useRef("right"),O=p.useRef(0),G=b?Fo:p.Fragment,W=b?{as:Iy,allowPinchZoom:!0}:void 0,q=M=>{var $,P;const le=j.current+M,J=E().filter(H=>!H.disabled),ee=document.activeElement,D=($=J.find(H=>H.ref.current===ee))==null?void 0:$.textValue,Z=J.map(H=>H.textValue),ke=Fy(Z,le,D),he=(P=J.find(H=>H.textValue===ke))==null?void 0:P.ref.current;(function H(Q){j.current=Q,window.clearTimeout(A.current),Q!==""&&(A.current=window.setTimeout(()=>H(""),1e3))})(le),he&&setTimeout(()=>he.focus())};p.useEffect(()=>()=>window.clearTimeout(A.current),[]),Ei();const L=p.useCallback(M=>{var J,ee;return V.current===((J=z.current)==null?void 0:J.side)&&By(M,(ee=z.current)==null?void 0:ee.area)},[]);return l.jsx(Ty,{scope:n,searchRef:j,onItemEnter:p.useCallback(M=>{L(M)&&M.preventDefault()},[L]),onItemLeave:p.useCallback(M=>{var le;L(M)||((le=I.current)==null||le.focus(),T(null))},[L]),onTriggerLeave:p.useCallback(M=>{L(M)&&M.preventDefault()},[L]),pointerGraceTimerRef:_,onPointerGraceIntentChange:p.useCallback(M=>{z.current=M},[]),children:l.jsx(G,{...W,children:l.jsx(jo,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,M=>{var le;M.preventDefault(),(le=I.current)==null||le.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Ro,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,children:l.jsx(fy,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ae(c,M=>{x.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(Ad,{role:"menu","aria-orientation":"vertical","data-state":af(g.open),"data-radix-menu-content":"",dir:x.dir,...w,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:ae(v.onKeyDown,M=>{const J=M.target.closest("[data-radix-menu-content]")===M.currentTarget,ee=M.ctrlKey||M.altKey||M.metaKey,D=M.key.length===1;J&&(M.key==="Tab"&&M.preventDefault(),!ee&&D&&q(M.key));const Z=I.current;if(M.target!==Z||!my.includes(M.key))return;M.preventDefault();const he=E().filter($=>!$.disabled).map($=>$.ref.current);Ld.includes(M.key)&&he.reverse(),Ly(he)}),onBlur:ae(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(A.current),j.current="")}),onPointerMove:ae(e.onPointerMove,Br(M=>{const le=M.target,J=O.current!==M.clientX;if(M.currentTarget.contains(le)&&J){const ee=M.clientX>O.current?"right":"left";V.current=ee,O.current=M.clientX}}))})})})})})})});Ud.displayName=zt;var Ny="MenuGroup",aa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"group",...r,ref:t})});aa.displayName=Ny;var Ay="MenuLabel",Wd=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{...r,ref:t})});Wd.displayName=Ay;var as="MenuItem",Vd="menu.itemSelect",ls=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=Fr(as,e.__scopeMenu),a=sa(as,e.__scopeMenu),c=Me(t,s),u=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Vd,{bubbles:!0,cancelable:!0});f.addEventListener(Vd,m=>r==null?void 0:r(m),{once:!0}),Nc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(qd,{...o,ref:c,disabled:n,onClick:ae(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:ae(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ae(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||na.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ls.displayName=as;var qd=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=sa(as,n),a=Fd(n),c=p.useRef(null),u=Me(t,c),[d,f]=p.useState(!1),[h,m]=p.useState("");return p.useEffect(()=>{const b=c.current;b&&m((b.textContent??"").trim())},[s.children]),l.jsx($r.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:l.jsx(hy,{asChild:!0,...a,focusable:!r,children:l.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:ae(e.onPointerMove,Br(b=>{r?i.onItemLeave(b):(i.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,Br(b=>i.onItemLeave(b))),onFocus:ae(e.onFocus,()=>f(!0)),onBlur:ae(e.onBlur,()=>f(!1))})})})}),_y="MenuCheckboxItem",Kd=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(Zd,{scope:e.__scopeMenu,checked:n,children:l.jsx(ls,{role:"menuitemcheckbox","aria-checked":cs(n)?"mixed":n,...o,ref:t,"data-state":ca(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Kd.displayName=_y;var Gd="MenuRadioGroup",[Ry,jy]=Un(Gd,{value:void 0,onValueChange:()=>{}}),Yd=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return l.jsx(Ry,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(aa,{...o,ref:t})})});Yd.displayName=Gd;var Xd="MenuRadioItem",Jd=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=jy(Xd,e.__scopeMenu),s=n===o.value;return l.jsx(Zd,{scope:e.__scopeMenu,checked:s,children:l.jsx(ls,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ca(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Jd.displayName=Xd;var la="MenuItemIndicator",[Zd,Py]=Un(la,{checked:!1}),Qd=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Py(la,n);return l.jsx(Rt,{present:r||cs(s.checked)||s.checked===!0,children:l.jsx(ye.span,{...o,ref:t,"data-state":ca(s.checked)})})});Qd.displayName=la;var Oy="MenuSeparator",ef=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ef.displayName=Oy;var My="MenuArrow",tf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=is(n);return l.jsx(_d,{...o,...r,ref:t})});tf.displayName=My;var Dy="MenuSub",[EC,nf]=Un(Dy),zr="MenuSubTrigger",rf=p.forwardRef((e,t)=>{const n=Wn(zr,e.__scopeMenu),r=Fr(zr,e.__scopeMenu),o=nf(zr,e.__scopeMenu),s=sa(zr,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(ra,{asChild:!0,...u,children:l.jsx(qd,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":af(n.open),...e,ref:hi(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:ae(e.onPointerMove,Br(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,Br(f=>{var m,b;d();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const v=(b=n.content)==null?void 0:b.dataset.side,g=v==="right",x=g?-5:5,w=h[g?"left":"right"],y=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:w,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x:w,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,f=>{var m;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||gy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});rf.displayName=zr;var of="MenuSubContent",sf=p.forwardRef((e,t)=>{const n=Bd(zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Wn(zt,e.__scopeMenu),i=Fr(zt,e.__scopeMenu),a=nf(of,e.__scopeMenu),c=p.useRef(null),u=Me(t,c);return l.jsx($r.Provider,{scope:e.__scopeMenu,children:l.jsx(Rt,{present:r||s.open,children:l.jsx($r.Slot,{scope:e.__scopeMenu,children:l.jsx(ia,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),h=xy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});sf.displayName=of;function af(e){return e?"open":"closed"}function cs(e){return e==="indeterminate"}function ca(e){return cs(e)?"indeterminate":e?"checked":"unchecked"}function Ly(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function $y(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Fy(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=$y(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function zy(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],c=t[i],u=a.x,d=a.y,f=c.x,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function By(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return zy(n,t)}function Br(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Hy=zd,Uy=ra,Wy=Hd,Vy=Ud,qy=aa,Ky=Wd,Gy=ls,Yy=Kd,Xy=Yd,Jy=Jd,Zy=Qd,Qy=ef,e0=tf,t0=rf,n0=sf,us="DropdownMenu",[r0,IC]=rn(us,[$d]),yt=$d(),[o0,lf]=r0(us),cf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=yt(t),u=p.useRef(null),[d,f]=Ln({prop:o,defaultProp:s??!1,onChange:i,caller:us});return l.jsx(o0,{scope:t,triggerId:on(),triggerRef:u,contentId:on(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:a,children:l.jsx(Hy,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};cf.displayName=us;var uf="DropdownMenuTrigger",df=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=lf(uf,n),i=yt(n);return l.jsx(Uy,{asChild:!0,...i,children:l.jsx(ye.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:hi(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});df.displayName=uf;var s0="DropdownMenuPortal",ff=e=>{const{__scopeDropdownMenu:t,...n}=e,r=yt(t);return l.jsx(Wy,{...r,...n})};ff.displayName=s0;var hf="DropdownMenuContent",pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=lf(hf,n),s=yt(n),i=p.useRef(!1);return l.jsx(Vy,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!o.modal||d)&&(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)"}})});pf.displayName=hf;var i0="DropdownMenuGroup",a0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(qy,{...o,...r,ref:t})});a0.displayName=i0;var l0="DropdownMenuLabel",mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Ky,{...o,...r,ref:t})});mf.displayName=l0;var c0="DropdownMenuItem",gf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Gy,{...o,...r,ref:t})});gf.displayName=c0;var u0="DropdownMenuCheckboxItem",xf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Yy,{...o,...r,ref:t})});xf.displayName=u0;var d0="DropdownMenuRadioGroup",f0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Xy,{...o,...r,ref:t})});f0.displayName=d0;var h0="DropdownMenuRadioItem",vf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Jy,{...o,...r,ref:t})});vf.displayName=h0;var p0="DropdownMenuItemIndicator",wf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Zy,{...o,...r,ref:t})});wf.displayName=p0;var m0="DropdownMenuSeparator",bf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Qy,{...o,...r,ref:t})});bf.displayName=m0;var g0="DropdownMenuArrow",x0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(e0,{...o,...r,ref:t})});x0.displayName=g0;var v0="DropdownMenuSubTrigger",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(t0,{...o,...r,ref:t})});yf.displayName=v0;var w0="DropdownMenuSubContent",Sf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(n0,{...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)"}})});Sf.displayName=w0;var b0=cf,y0=df,S0=ff,Cf=pf,Tf=mf,kf=gf,Ef=xf,If=vf,Nf=wf,Af=bf,_f=yf,Rf=Sf;const C0=b0,T0=y0,k0=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(_f,{ref:o,className:X("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,l.jsx(oe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));k0.displayName=_f.displayName;const E0=p.forwardRef(({className:e,...t},n)=>l.jsx(Rf,{ref:n,className:X("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}));E0.displayName=Rf.displayName;const jf=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(S0,{children:l.jsx(Cf,{ref:r,sideOffset:t,className:X("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})}));jf.displayName=Cf.displayName;const ua=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(kf,{ref:r,className:X("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}));ua.displayName=kf.displayName;const I0=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(Ef,{ref:o,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Nf,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),t]}));I0.displayName=Ef.displayName;const N0=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(If,{ref:r,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Nf,{children:l.jsx(oe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));N0.displayName=If.displayName;const A0=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Tf,{ref:r,className:X("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));A0.displayName=Tf.displayName;const _0=p.forwardRef(({className:e,...t},n)=>l.jsx(Af,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));_0.displayName=Af.displayName;function ds({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:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:m}){const{currentThreadId:b,messages:v,isStreaming:g,streamingAssistantId:x,error:w,send:y,stop:E,lastCheckpointId:S,lastCheckpointNs:T,listCheckpoints:I,navigateToCheckpoint:N,returnToLatest:A,hasMoreHistory:j,isLoadingHistory:_,loadOlderMessages:z,api:V}=ao(),[O,G]=C.useState(null),[W,q]=C.useState(""),[L,M]=C.useState(null),[le,J]=C.useState([]),[ee,D]=C.useState(!1),[Z,ke]=C.useState(null),[he,$]=C.useState(null),[P,H]=C.useState(!1),[Q,ce]=C.useState(null),[ie,Fe]=C.useState([]),[$e,we]=C.useState(null),[Ne,Ue]=C.useState(null),[et,Xe]=C.useState(!1),ut=C.useRef(null),dt=C.useRef(null),ue=C.useRef(null),[fe,pe]=C.useState("desktop");C.useEffect(()=>{const te=()=>{const me=window.innerWidth;pe(me<640?"phone":me<1024?"tablet":"desktop")};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]),C.useEffect(()=>{let te=!1;if(!b){Fe([]),we(null),Ue(null),ue.current=null;return}const me={threadId:b,checkpointId:S??null,checkpointNs:T??null},Pe=ue.current;if(!(Pe&&Pe.threadId===me.threadId&&Pe.checkpointId===me.checkpointId&&Pe.checkpointNs===me.checkpointNs))return I(b).then(ze=>{var Vr;if(te)return;const Wt=((ze==null?void 0:ze.checkpoints)??[]).slice().sort((mn,qr)=>new Date(qr.createdAt).getTime()-new Date(mn.createdAt).getTime());Fe(Wt);const Mt=$e,Ur=Mt&&Wt.some(mn=>mn.checkpointId===Mt)?Mt:((Vr=Wt[0])==null?void 0:Vr.checkpointId)??null;let Wr=null;if(Ur){const mn=Wt.find(qr=>qr.checkpointId===Ur);Wr=(mn==null?void 0:mn.checkpointNs)??null}we(Ur),Ue(Wr),ue.current=me}).catch(ze=>{console.error("ChatInterface - listCheckpoints error:",ze),te||(Fe([]),ue.current=null)}),()=>{te=!0}},[b,S,T,$e,I]),C.useEffect(()=>{S&&(we(S),Ue(T??null))},[S,T]);const Se=C.useCallback(async()=>{if(!(!j||_))try{await z()}catch(te){console.warn("loadOlderMessages failed",te)}},[j,_,z]);C.useEffect(()=>{(async()=>{if(!V.baseUrl){ce(null);return}try{const me=await V.getAgent("default");ce(me.uiDefaultMessage||null)}catch(me){console.warn("Failed to fetch default message:",me),ce(null)}})()},[V]),C.useEffect(()=>{w&&!P&&(m==null||m(w))},[w,P,m]);const Oe=te=>{if(te.length>Go)return`Message too long (${te.length}/${Go} characters)`;try{return Dw(te),null}catch(me){return(me==null?void 0:me.message)||"Invalid message"}},Ve=async te=>{const me=te.trim();if(!(!me&&le.length===0)){if(me){const Pe=Oe(me);if(Pe){M(Pe);return}}try{await y(me||"",{checkpointId:$e??S??void 0,checkpointNs:Ne??T??void 0,payloadExtras:O?{edit:!0,originalMessageId:O}:void 0,attachments:le}),f==null||f(me),M(null),J([]),G(null),q("")}catch(Pe){const ze=(Pe==null?void 0:Pe.message)||"Failed to send message";M(ze),m==null||m(ze)}}},F=C.useCallback((te,me)=>{u&&(G(te),q(me),M(null))},[u]),Y=C.useCallback(()=>{G(null),q(""),M(null)},[]),je=C.useCallback((te,me)=>{F(te,me)},[F]),nt=C.useCallback(te=>{const me=Pe=>{const ze=Pe.content||[],Wt=ze.filter(Mt=>Mt.type==="text").map(Mt=>Mt.text).join("");if(Wt)return Wt;try{return JSON.stringify(ze,null,2)}catch{return String(ze)}};for(let Pe=te-1;Pe>=0;Pe--)if(v[Pe].role==="user"){const ze=me(v[Pe]);ze&&y(ze,{checkpointId:$e??S??void 0,checkpointNs:Ne??T??void 0});break}},[v,y,$e,Ne,S,T]),_e=te=>{const me=Array.from(te.target.files||[]);J(Pe=>[...Pe,...me])},at=te=>J(me=>me.filter((Pe,ze)=>te!==ze)),Ut=async te=>{const me=(te.target.files||[])[0];if(me){ke(null),$(null),D(!0);try{await y("",{checkpointId:$e??S??void 0,checkpointNs:Ne??T??void 0,attachments:[me]});const Pe=`Uploaded ${me.name} - processing through chat stream`;$(Pe)}catch(Pe){const ze=Pe instanceof Error?Pe.message:"Failed to upload Excel file";console.error("Excel upload failed",Pe),ke(ze),m==null||m(ze)}finally{D(!1),te.target.value=""}}},Gn=te=>{if(!te)return"Unknown";const me=Date.parse(te);return Number.isNaN(me)?te:new Date(me).toLocaleString()},wt=async te=>{if(b){Xe(!0);try{if(!te){await A(),we(null),Ue(null);return}const me=ie.find(ze=>ze.checkpointId===te),Pe=(me==null?void 0:me.checkpointNs)??null;await N(te,Pe),we(te),Ue(Pe)}finally{Xe(!1)}}},Ot=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,ft=`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 ${d.messagesArea||""}`,Et=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:Ot,children:[!!w&&!P&&l.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:[l.jsx("span",{children:w}),l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>H(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(oe.X,{size:16})})]}),b&&ie.length>0&&l.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:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.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:$e??"",onChange:te=>{const me=te.target.value||null;wt(me)},children:[l.jsx("option",{value:"",children:"Latest"}),ie.map(te=>l.jsxs("option",{value:te.checkpointId,children:[Gn(te.createdAt),te.preview?` — ${te.preview.slice(0,40)}`:""]},te.checkpointId))]})]}),l.jsx($i,{className:ft,style:r?{maxHeight:r}:void 0,messages:v,isStreaming:g,streamingAssistantId:x,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:fe,enableMessageEditing:u,editingMessageId:O,onStartReached:()=>{Se()},onEdit:je,onRegenerate:nt,onCancelEdit:Y,emptyMessage:Q??void 0,isNavigatingCheckpoint:et}),l.jsxs("div",{className:Et,children:[O&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(oe.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(We,{variant:"ghost",size:"sm",onClick:Y,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(oe.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ut,type:"file",multiple:!0,onChange:te=>_e(te),className:"hidden"}),le.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:le.map((te,me)=>l.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:[l.jsx(oe.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:te.name}),l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>at(me),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 ${te.name}`,children:l.jsx(oe.X,{size:12})})]},me))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:dt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Ut,className:"hidden"}),ee&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(oe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),he&&!ee&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:he}),Z&&!ee&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Z})]})]}),L&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:L}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(C0,{children:[l.jsx(T0,{asChild:!0,children:l.jsx(We,{type:"button",size:"icon",variant:"outline",disabled:g,title:"More input actions",className:d.moreButton||"",children:l.jsx(oe.Plus,{size:16})})}),l.jsxs(jf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(ua,{onClick:()=>{var te;return(te=ut.current)==null?void 0:te.click()},className:"cursor-pointer",children:[l.jsx(oe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(ua,{onClick:()=>{var te;ee||(te=dt.current)==null||te.click()},className:`cursor-pointer ${ee?"opacity-60 pointer-events-none":""}`,children:[l.jsx(oe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(Gm,{initialValue:W,editingMessageId:O,placeholder:O?"Edit your message...":t,isStreaming:g,disabled:!1,maxLength:Go,onSend:Ve,onCancelEdit:Y,onStop:E,allowEmptySend:le.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${O?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${L?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const fs=p.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:X("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}));fs.displayName="Input";function da(e,[t,n]){return Math.min(n,Math.max(t,e))}function R0(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var fa="ScrollArea",[Pf,NC]=rn(fa),[j0,Bt]=Pf(fa),Of=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,b]=p.useState(null),[v,g]=p.useState(null),[x,w]=p.useState(0),[y,E]=p.useState(0),[S,T]=p.useState(!1),[I,N]=p.useState(!1),A=Me(t,_=>c(_)),j=Yo(o);return l.jsx(j0,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:b,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:w,onCornerHeightChange:E,children:l.jsx(ye.div,{dir:j,...i,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Of.displayName=fa;var Mf="ScrollAreaViewport",Df=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Bt(Mf,n),a=p.useRef(null),c=Me(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(ye.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Df.displayName=Mf;var dn="ScrollAreaScrollbar",ha=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bt(dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?l.jsx(P0,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(O0,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Lf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(pa,{...r,ref:t}):null});ha.displayName=dn;var P0=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bt(dn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(Rt,{present:n||s,children:l.jsx(Lf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),O0=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bt(dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=gs(()=>c("SCROLL_END"),100),[a,c]=R0("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 p.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),p.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,c,i]),l.jsx(Rt,{present:n||a!=="hidden",children:l.jsx(pa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Lf=p.forwardRef((e,t)=>{const n=Bt(dn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",c=gs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return ur(n.viewport,c),ur(n.content,c),l.jsx(Rt,{present:r||s,children:l.jsx(pa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),pa=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Bt(dn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Hf(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,m){return z0(h,i.current,a,m)}return n==="horizontal"?l.jsx(M0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,m=Uf(h,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?l.jsx(D0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,m=Uf(h,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),M0=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Bt(dn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Me(t,c,s.onScrollbarXChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Ff,{"data-orientation":"horizontal",...o,ref:u,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":ms(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),Vf(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ps(i.paddingLeft),paddingEnd:ps(i.paddingRight)}})}})}),D0=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Bt(dn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Me(t,c,s.onScrollbarYChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Ff,{"data-orientation":"vertical",...o,ref:u,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":ms(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),Vf(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ps(i.paddingTop),paddingEnd:ps(i.paddingBottom)}})}})}),[L0,$f]=Pf(dn),Ff=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,m=Bt(dn,n),[b,v]=p.useState(null),g=Me(t,A=>v(A)),x=p.useRef(null),w=p.useRef(""),y=m.viewport,E=r.content-r.viewport,S=pt(d),T=pt(c),I=gs(f,10);function N(A){if(x.current){const j=A.clientX-x.current.left,_=A.clientY-x.current.top;u({x:j,y:_})}}return p.useEffect(()=>{const A=j=>{const _=j.target;(b==null?void 0:b.contains(_))&&S(j,E)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[y,b,E,S]),p.useEffect(T,[r,T]),ur(b,I),ur(m.content,I),l.jsx(L0,{scope:n,scrollbar:b,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:l.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:ae(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),x.current=b.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(A))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,A=>{const j=A.target;j.hasPointerCapture(A.pointerId)&&j.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=w.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),hs="ScrollAreaThumb",zf=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$f(hs,e.__scopeScrollArea);return l.jsx(Rt,{present:n||o.hasThumb,children:l.jsx($0,{ref:t,...r})})}),$0=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Bt(hs,n),i=$f(hs,n),{onThumbPositionChange:a}=i,c=Me(t,f=>i.onThumbChange(f)),u=p.useRef(void 0),d=gs(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const m=B0(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),l.jsx(ye.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),b=f.clientX-m.left,v=f.clientY-m.top;i.onThumbPointerDown({x:b,y:v})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});zf.displayName=hs;var ma="ScrollAreaCorner",Bf=p.forwardRef((e,t)=>{const n=Bt(ma,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(F0,{...e,ref:t}):null});Bf.displayName=ma;var F0=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Bt(ma,n),[s,i]=p.useState(0),[a,c]=p.useState(0),u=!!(s&&a);return ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(ye.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 ps(e){return e?parseInt(e,10):0}function Hf(e,t){const n=e/t;return isNaN(n)?0:n}function ms(e){const t=Hf(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function z0(e,t,n,r="ltr"){const o=ms(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Wf([c,u],f)(e)}function Uf(e,t,n="ltr"){const r=ms(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=da(e,c);return Wf([0,i],[0,a])(u)}function Wf(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 Vf(e,t){return e>0&&e<t}var B0=(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 gs(e,t){const n=pt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ur(e,t){const n=pt(t);ht(()=>{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 qf=Of,H0=Df,U0=Bf;const Kf=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(qf,{ref:r,className:X("relative overflow-hidden",e),...n,children:[l.jsx(H0,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(Gf,{}),l.jsx(U0,{})]}));Kf.displayName=qf.displayName;const Gf=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(ha,{ref:r,orientation:t,className:X("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:l.jsx(zf,{className:"relative flex-1 rounded-full bg-border"})}));Gf.displayName=ha.displayName;function ga({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,refreshThreads:m,currentThreadId:b,createThread:v,deleteThread:g,renameThread:x}=ao(),[w,y]=C.useState(h??[]),[E,S]=C.useState(!1),[T,I]=C.useState(null),[N,A]=C.useState(null),[j,_]=C.useState(""),[z,V]=C.useState(!1);C.useEffect(()=>{y(h??[])},[h]);const O=async D=>{try{await f(D),a==null||a(D),c==null||c(D)}catch(Z){console.error("Failed to select thread:",Z)}},G=async()=>{try{V(!0);const D=await v();u==null||u(D),a==null||a(D)}catch(D){console.error("Failed to create thread:",D)}finally{V(!1)}},W=async(D,Z)=>{if(Z.stopPropagation(),!!confirm("Delete this thread?"))try{await g(D),d==null||d(D)}catch(ke){console.error("Failed to delete thread:",ke)}},q=(D,Z)=>{Z.stopPropagation(),A(D.threadId),_(D.title||`Thread ${D.threadId.slice(0,8)}`)},L=async D=>{if(j.trim())try{await x(D,j.trim()),A(null),_("")}catch(Z){console.error("Failed to update title:",Z)}},M=()=>{A(null),_("")},le=(D,Z)=>{D.key==="Enter"?L(Z):D.key==="Escape"&&M()},J=D=>{if(!D)return"";try{const Z=new Date(D),he=new Date().getTime()-Z.getTime(),$=Math.floor(he/(1e3*60*60*24));return $===0?Z.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):$===1?"Yesterday":$<7?`${$} days ago`:Z.toLocaleDateString()}catch{return""}},ee=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.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:l.jsx(We,{onClick:G,disabled:z||E,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:z?"Creating...":"New Chat",children:l.jsx(oe.MessageSquarePlus,{size:20})})}),l.jsx(Kf,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:E?l.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):w.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(oe.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):w.slice().sort((D,Z)=>new Date(Z.updatedAt||Z.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>l.jsxs("div",{onClick:()=>O(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??b)===D.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:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:N===D.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:Z=>Z.stopPropagation(),children:[l.jsx(fs,{value:j,onChange:Z=>_(Z.target.value),onKeyDown:Z=>le(Z,D.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>L(D.threadId),className:"h-6 w-6 p-0",children:l.jsx(oe.Check,{size:12})}),l.jsx(We,{variant:"ghost",size:"sm",onClick:M,className:"h-6 w-6 p-0",children:l.jsx(oe.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ee(D)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(oe.Calendar,{size:10}),l.jsx("span",{children:J(D.updatedAt||D.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==D.threadId&&l.jsx(We,{variant:"ghost",size:"sm",onClick:Z=>q(D,Z),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(oe.Edit3,{size:12})}),n&&l.jsx(We,{variant:"ghost",size:"sm",onClick:Z=>W(D.threadId,Z),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(oe.Trash2,{size:12})})]})]}),i===D.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}function dr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function W0(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function Yf(){const e=[dr("__API_BASE_URL__"),dr("__CHAT_API_BASE_URL__"),dr("__CHAT_API_URL__")];for(const t of e){const n=W0(t);if(n)return n}}function Xf(){const e=[dr("__API_AUTH_TOKEN__"),dr("__CHAT_API_KEY__"),dr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Jf(){const e={},t=Yf(),n=Xf();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Zf(){const e=Jf(),t=gn.getAuthToken(),n=Yf();return{apiBaseUrl:e.baseUrl||gn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||Xf()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const Qf="chat-settings";function V0(){try{const e=localStorage.getItem(Qf);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function q0(e){try{localStorage.setItem(Qf,JSON.stringify(e)),e.apiKey&&gn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function K0(){const e=Zf(),t=V0(),n=gn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:gn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function G0(e){e.apiKey&&gn.setAuthToken(e.apiKey),q0(e)}var Y0="Label",eh=p.forwardRef((e,t)=>l.jsx(ye.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())}}));eh.displayName=Y0;var th=eh;const X0=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ht=p.forwardRef(({className:e,...t},n)=>l.jsx(th,{ref:n,className:X(X0(),e),...t}));Ht.displayName=th.displayName;function nh(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var xs="Switch",[J0,AC]=rn(xs),[Z0,Q0]=J0(xs),rh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[h,m]=p.useState(null),b=Me(t,y=>m(y)),v=p.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,w]=Ln({prop:o,defaultProp:s??!1,onChange:u,caller:xs});return l.jsxs(Z0,{scope:n,checked:x,disabled:a,children:[l.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":ah(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:b,onClick:ae(e.onClick,y=>{w(E=>!E),g&&(v.current=y.isPropagationStopped(),v.current||y.stopPropagation())})}),g&&l.jsx(ih,{control:h,bubbles:!v.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});rh.displayName=xs;var oh="SwitchThumb",sh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Q0(oh,n);return l.jsx(ye.span,{"data-state":ah(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});sh.displayName=oh;var eS="SwitchBubbleInput",ih=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Me(i,s),c=nh(n),u=xd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const b=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(b)}},[c,n,r]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ih.displayName=eS;function ah(e){return e?"checked":"unchecked"}var lh=rh,tS=sh;const En=p.forwardRef(({className:e,...t},n)=>l.jsx(lh,{className:X("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:l.jsx(tS,{className:X("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")})}));En.displayName=lh.displayName;var ch=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"}),nS="VisuallyHidden",rS=p.forwardRef((e,t)=>l.jsx(ye.span,{...e,ref:t,style:{...ch,...e.style}}));rS.displayName=nS;var oS=[" ","Enter","ArrowUp","ArrowDown"],sS=[" ","Enter"],Vn="Select",[vs,ws,iS]=Fi(Vn),[fr,_C]=rn(Vn,[iS,ss]),bs=ss(),[aS,In]=fr(Vn),[lS,cS]=fr(Vn),uh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:m,form:b}=e,v=bs(t),[g,x]=p.useState(null),[w,y]=p.useState(null),[E,S]=p.useState(!1),T=Yo(u),[I,N]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:Vn}),[A,j]=Ln({prop:i,defaultProp:a,onChange:c,caller:Vn}),_=p.useRef(null),z=g?b||!!g.closest("form"):!0,[V,O]=p.useState(new Set),G=Array.from(V).map(W=>W.props.value).join(";");return l.jsx(Id,{...v,children:l.jsxs(aS,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:w,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:on(),value:A,onValueChange:j,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:_,disabled:h,children:[l.jsx(vs.Provider,{scope:t,children:l.jsx(lS,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(W=>{O(q=>new Set(q).add(W))},[]),onNativeOptionRemove:p.useCallback(W=>{O(q=>{const L=new Set(q);return L.delete(W),L})},[]),children:n})}),z?l.jsxs(Oh,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:A,onChange:W=>j(W.target.value),disabled:h,form:b,children:[A===void 0?l.jsx("option",{value:""}):null,Array.from(V)]},G):null]})})};uh.displayName=Vn;var dh="SelectTrigger",fh=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=bs(n),i=In(dh,n),a=i.disabled||r,c=Me(t,i.onTriggerChange),u=ws(n),d=p.useRef("touch"),[f,h,m]=Dh(v=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),w=Lh(g,v,x);w!==void 0&&i.onValueChange(w.value)}),b=v=>{a||(i.onOpenChange(!0),m()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return l.jsx(Nd,{asChild:!0,...s,children:l.jsx(ye.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":Mh(i.value)?"":void 0,...o,ref:c,onClick:ae(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&b(v)}),onPointerDown:ae(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(b(v),v.preventDefault())}),onKeyDown:ae(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&oS.includes(v.key)&&(b(),v.preventDefault())})})})});fh.displayName=dh;var hh="SelectValue",ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=In(hh,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Me(t,c.onValueNodeChange);return ht(()=>{u(d)},[u,d]),l.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:Mh(c.value)?l.jsx(l.Fragment,{children:i}):s})});ph.displayName=hh;var uS="SelectIcon",mh=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});mh.displayName=uS;var dS="SelectPortal",gh=e=>l.jsx(Po,{asChild:!0,...e});gh.displayName=dS;var qn="SelectContent",xh=p.forwardRef((e,t)=>{const n=In(qn,e.__scopeSelect),[r,o]=p.useState();if(ht(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Gr.createPortal(l.jsx(vh,{scope:e.__scopeSelect,children:l.jsx(vs.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(wh,{...e,ref:t})});xh.displayName=qn;var Zt=10,[vh,Nn]=fr(qn),fS="SelectContentImpl",hS=An.createSlot("SelectContent.RemoveScroll"),wh=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:b,hideWhenDetached:v,avoidCollisions:g,...x}=e,w=In(qn,n),[y,E]=p.useState(null),[S,T]=p.useState(null),I=Me(t,$=>E($)),[N,A]=p.useState(null),[j,_]=p.useState(null),z=ws(n),[V,O]=p.useState(!1),G=p.useRef(!1);p.useEffect(()=>{if(y)return ji(y)},[y]),Ei();const W=p.useCallback($=>{const[P,...H]=z().map(ie=>ie.ref.current),[Q]=H.slice(-1),ce=document.activeElement;for(const ie of $)if(ie===ce||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===P&&S&&(S.scrollTop=0),ie===Q&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==ce))return},[z,S]),q=p.useCallback(()=>W([N,y]),[W,N,y]);p.useEffect(()=>{V&&q()},[V,q]);const{onOpenChange:L,triggerPointerDownPosRef:M}=w;p.useEffect(()=>{if(y){let $={x:0,y:0};const P=Q=>{var ce,ie;$={x:Math.abs(Math.round(Q.pageX)-(((ce=M.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ie=M.current)==null?void 0:ie.y)??0))}},H=Q=>{$.x<=10&&$.y<=10?Q.preventDefault():y.contains(Q.target)||L(!1),document.removeEventListener("pointermove",P),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",P),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",H,{capture:!0})}}},[y,L,M]),p.useEffect(()=>{const $=()=>L(!1);return window.addEventListener("blur",$),window.addEventListener("resize",$),()=>{window.removeEventListener("blur",$),window.removeEventListener("resize",$)}},[L]);const[le,J]=Dh($=>{const P=z().filter(ce=>!ce.disabled),H=P.find(ce=>ce.ref.current===document.activeElement),Q=Lh(P,$,H);Q&&setTimeout(()=>Q.ref.current.focus())}),ee=p.useCallback(($,P,H)=>{const Q=!G.current&&!H;(w.value!==void 0&&w.value===P||Q)&&(A($),Q&&(G.current=!0))},[w.value]),D=p.useCallback(()=>y==null?void 0:y.focus(),[y]),Z=p.useCallback(($,P,H)=>{const Q=!G.current&&!H;(w.value!==void 0&&w.value===P||Q)&&_($)},[w.value]),ke=r==="popper"?xa:bh,he=ke===xa?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:b,hideWhenDetached:v,avoidCollisions:g}:{};return l.jsx(vh,{scope:n,content:y,viewport:S,onViewportChange:T,itemRefCallback:ee,selectedItem:N,onItemLeave:D,itemTextRefCallback:Z,focusSelectedItem:q,selectedItemText:j,position:r,isPositioned:V,searchRef:le,children:l.jsx(Fo,{as:hS,allowPinchZoom:!0,children:l.jsx(jo,{asChild:!0,trapped:w.open,onMountAutoFocus:$=>{$.preventDefault()},onUnmountAutoFocus:ae(o,$=>{var P;(P=w.trigger)==null||P.focus({preventScroll:!0}),$.preventDefault()}),children:l.jsx(Ro,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:$=>$.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:l.jsx(ke,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:$=>$.preventDefault(),...x,...he,onPlaced:()=>O(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:ae(x.onKeyDown,$=>{const P=$.ctrlKey||$.altKey||$.metaKey;if($.key==="Tab"&&$.preventDefault(),!P&&$.key.length===1&&J($.key),["ArrowUp","ArrowDown","Home","End"].includes($.key)){let Q=z().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes($.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes($.key)){const ce=$.target,ie=Q.indexOf(ce);Q=Q.slice(ie+1)}setTimeout(()=>W(Q)),$.preventDefault()}})})})})})})});wh.displayName=fS;var pS="SelectItemAlignedPosition",bh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=In(qn,n),i=Nn(qn,n),[a,c]=p.useState(null),[u,d]=p.useState(null),f=Me(t,I=>d(I)),h=ws(n),m=p.useRef(!1),b=p.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:w}=i,y=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const ce=j.left-N.left,ie=A.left-ce,Fe=I.left-ie,$e=I.width+Fe,we=Math.max($e,N.width),Ne=window.innerWidth-Zt,Ue=da(ie,[Zt,Math.max(Zt,Ne-we)]);a.style.minWidth=$e+"px",a.style.left=Ue+"px"}else{const ce=N.right-j.right,ie=window.innerWidth-A.right-ce,Fe=window.innerWidth-I.right-ie,$e=I.width+Fe,we=Math.max($e,N.width),Ne=window.innerWidth-Zt,Ue=da(ie,[Zt,Math.max(Zt,Ne-we)]);a.style.minWidth=$e+"px",a.style.right=Ue+"px"}const _=h(),z=window.innerHeight-Zt*2,V=v.scrollHeight,O=window.getComputedStyle(u),G=parseInt(O.borderTopWidth,10),W=parseInt(O.paddingTop,10),q=parseInt(O.borderBottomWidth,10),L=parseInt(O.paddingBottom,10),M=G+W+V+L+q,le=Math.min(g.offsetHeight*5,M),J=window.getComputedStyle(v),ee=parseInt(J.paddingTop,10),D=parseInt(J.paddingBottom,10),Z=I.top+I.height/2-Zt,ke=z-Z,he=g.offsetHeight/2,$=g.offsetTop+he,P=G+W+$,H=M-P;if(P<=Z){const ce=_.length>0&&g===_[_.length-1].ref.current;a.style.bottom="0px";const ie=u.clientHeight-v.offsetTop-v.offsetHeight,Fe=Math.max(ke,he+(ce?D:0)+ie+q),$e=P+Fe;a.style.height=$e+"px"}else{const ce=_.length>0&&g===_[0].ref.current;a.style.top="0px";const Fe=Math.max(Z,G+v.offsetTop+(ce?ee:0)+he)+H;a.style.height=Fe+"px",v.scrollTop=P-Z+v.offsetTop}a.style.margin=`${Zt}px 0`,a.style.minHeight=le+"px",a.style.maxHeight=z+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);ht(()=>y(),[y]);const[E,S]=p.useState();ht(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const T=p.useCallback(I=>{I&&b.current===!0&&(y(),w==null||w(),b.current=!1)},[y,w]);return l.jsx(gS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:l.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});bh.displayName=pS;var mS="SelectPopperPosition",xa=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Zt,...s}=e,i=bs(n);return l.jsx(Ad,{...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)"}})});xa.displayName=mS;var[gS,va]=fr(qn,{}),wa="SelectViewport",yh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Nn(wa,n),i=va(wa,n),a=Me(t,s.onViewportChange),c=p.useRef(0);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(vs.Slot,{scope:n,children:l.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const b=window.innerHeight-Zt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<b){const w=x+m,y=Math.min(b,w),E=w-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});yh.displayName=wa;var Sh="SelectGroup",[xS,vS]=fr(Sh),wS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=on();return l.jsx(xS,{scope:n,id:o,children:l.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});wS.displayName=Sh;var Ch="SelectLabel",Th=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=vS(Ch,n);return l.jsx(ye.div,{id:o.id,...r,ref:t})});Th.displayName=Ch;var ys="SelectItem",[bS,kh]=fr(ys),Eh=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=In(ys,n),c=Nn(ys,n),u=a.value===r,[d,f]=p.useState(s??""),[h,m]=p.useState(!1),b=Me(t,w=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,w,r,o)}),v=on(),g=p.useRef("touch"),x=()=>{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 l.jsx(bS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:p.useCallback(w=>{f(y=>y||((w==null?void 0:w.textContent)??"").trim())},[]),children:l.jsx(vs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(ye.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:b,onFocus:ae(i.onFocus,()=>m(!0)),onBlur:ae(i.onBlur,()=>m(!1)),onClick:ae(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:ae(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:ae(i.onPointerDown,w=>{g.current=w.pointerType}),onPointerMove:ae(i.onPointerMove,w=>{var y;g.current=w.pointerType,o?(y=c.onItemLeave)==null||y.call(c):g.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,w=>{var y;w.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:ae(i.onKeyDown,w=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(sS.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})})})})});Eh.displayName=ys;var Hr="SelectItemText",Ih=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=In(Hr,n),a=Nn(Hr,n),c=kh(Hr,n),u=cS(Hr,n),[d,f]=p.useState(null),h=Me(t,x=>f(x),c.onItemTextChange,x=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,b=p.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return ht(()=>(v(b),()=>g(b)),[v,g,b]),l.jsxs(l.Fragment,{children:[l.jsx(ye.span,{id:c.textId,...s,ref:h}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Gr.createPortal(s.children,i.valueNode):null]})});Ih.displayName=Hr;var Nh="SelectItemIndicator",Ah=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return kh(Nh,n).isSelected?l.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});Ah.displayName=Nh;var ba="SelectScrollUpButton",_h=p.forwardRef((e,t)=>{const n=Nn(ba,e.__scopeSelect),r=va(ba,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return ht(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(jh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});_h.displayName=ba;var ya="SelectScrollDownButton",Rh=p.forwardRef((e,t)=>{const n=Nn(ya,e.__scopeSelect),r=va(ya,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return ht(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(jh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Rh.displayName=ya;var jh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Nn("SelectScrollButton",n),i=p.useRef(null),a=ws(n),c=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),ht(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),l.jsx(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{c()})})}),yS="SelectSeparator",Ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Ph.displayName=yS;var Sa="SelectArrow",SS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=bs(n),s=In(Sa,n),i=Nn(Sa,n);return s.open&&i.position==="popper"?l.jsx(_d,{...o,...r,ref:t}):null});SS.displayName=Sa;var CS="SelectBubbleInput",Oh=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Me(r,o),i=nh(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(ye.select,{...n,style:{...ch,...n.style},ref:s,defaultValue:t})});Oh.displayName=CS;function Mh(e){return e===""||e===void 0}function Dh(e){const t=pt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Lh(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=TS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function TS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kS=uh,$h=fh,ES=ph,IS=mh,NS=gh,Fh=xh,AS=yh,zh=Th,Bh=Eh,_S=Ih,RS=Ah,Hh=_h,Uh=Rh,Wh=Ph;const Vh=kS,qh=ES,Ca=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs($h,{ref:r,className:X("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,l.jsx(IS,{asChild:!0,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ca.displayName=$h.displayName;const Kh=p.forwardRef(({className:e,...t},n)=>l.jsx(Hh,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronUp,{className:"h-4 w-4"})}));Kh.displayName=Hh.displayName;const Gh=p.forwardRef(({className:e,...t},n)=>l.jsx(Uh,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4"})}));Gh.displayName=Uh.displayName;const Ta=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(NS,{children:l.jsxs(Fh,{ref:o,className:X("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:[l.jsx(Kh,{}),l.jsx(AS,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(Gh,{})]})}));Ta.displayName=Fh.displayName;const jS=p.forwardRef(({className:e,...t},n)=>l.jsx(zh,{ref:n,className:X("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jS.displayName=zh.displayName;const Kn=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Bh,{ref:r,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(RS,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),l.jsx(_S,{children:t})]}));Kn.displayName=Bh.displayName;const PS=p.forwardRef(({className:e,...t},n)=>l.jsx(Wh,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));PS.displayName=Wh.displayName;const Ss=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Ss.displayName="Card";const Cs=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("flex flex-col space-y-1.5 p-6",e),...t}));Cs.displayName="CardHeader";const Ts=p.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:X("text-2xl font-semibold leading-none tracking-tight",e),...t}));Ts.displayName="CardTitle";const OS=p.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:X("text-sm text-muted-foreground",e),...t}));OS.displayName="CardDescription";const ks=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("p-6 pt-0",e),...t}));ks.displayName="CardContent";const MS=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("flex items-center p-6 pt-0",e),...t}));MS.displayName="CardFooter";var DS="Separator",Yh="horizontal",LS=["horizontal","vertical"],Xh=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=Yh,...o}=e,s=$S(r)?r:Yh,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});Xh.displayName=DS;function $S(e){return LS.includes(e)}var Jh=Xh;const Zh=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(Jh,{ref:o,decorative:n,orientation:t,className:X("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Zh.displayName=Jh.displayName;const FS=Mu,zS=gw,BS=Du,Qh=p.forwardRef(({className:e,...t},n)=>l.jsx(Wo,{className:X("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}));Qh.displayName=Wo.displayName;const HS=Kr.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"}}),ep=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(BS,{children:[l.jsx(Qh,{}),l.jsxs(Vo,{ref:o,className:X(HS({side:e}),t),...r,children:[n,l.jsxs(Lu,{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:[l.jsx(oe.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ep.displayName=Vo.displayName;const tp=({className:e,...t})=>l.jsx("div",{className:X("flex flex-col space-y-2 text-center sm:text-left",e),...t});tp.displayName="SheetHeader";const np=p.forwardRef(({className:e,...t},n)=>l.jsx(zn,{ref:n,className:X("text-lg font-semibold text-foreground",e),...t}));np.displayName=zn.displayName;const rp=p.forwardRef(({className:e,...t},n)=>l.jsx(qo,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));rp.displayName=qo.displayName;const US={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 WS({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=C.useState(!1),[s,i]=C.useState(!1),[a,c]=C.useState(e),[u,d]=C.useState(!1),{toast:f}=yi();C.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),C.useEffect(()=>{c(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(US),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},b=()=>{c(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return l.jsxs(FS,{open:r,onOpenChange:o,children:[l.jsx(zS,{asChild:!0,children:l.jsxs(We,{variant:"outline",size:"sm",className:n,children:[l.jsx(oe.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(fi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(ep,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(tp,{children:[l.jsx(np,{children:"Chat Settings"}),l.jsx(rp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(Ss,{children:[l.jsx(Cs,{className:"pb-3",children:l.jsxs(Ts,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(ks,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Ht,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(fs,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(We,{variant:"outline",onClick:v,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Ht,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(En,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(Ht,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(fs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(We,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(oe.EyeOff,{className:"h-4 w-4"}):l.jsx(oe.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(Ss,{children:[l.jsx(Cs,{className:"pb-3",children:l.jsxs(Ts,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(ks,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Ht,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Vh,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(Ca,{children:l.jsx(qh,{})}),l.jsxs(Ta,{children:[l.jsx(Kn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Kn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Kn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(Ht,{htmlFor:"theme",children:"Theme"}),l.jsxs(Vh,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(Ca,{children:l.jsx(qh,{})}),l.jsxs(Ta,{children:[l.jsx(Kn,{value:"light",children:"Light"}),l.jsx(Kn,{value:"dark",children:"Dark"}),l.jsx(Kn,{value:"system",children:"System"})]})]})]}),l.jsx(Zh,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Ht,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(En,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Ht,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(En,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Ht,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(En,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(Ss,{children:[l.jsx(Cs,{className:"pb-3",children:l.jsxs(Ts,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(ks,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Ht,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(En,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Ht,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(En,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Ht,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(En,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(We,{variant:"outline",onClick:m,children:[l.jsx(oe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(We,{variant:"outline",onClick:b,children:"Cancel"}),l.jsxs(We,{onClick:h,disabled:!u,children:[l.jsx(oe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function VS({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),c=C.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(io,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(ds,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(io,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ga,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(ds,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(io,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ga,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(ds,{onError:s.onError,enableFileUpload:!0})})]})})}Ee.ChatApi=yl,Ee.ChatInterface=ds,Ee.ChatProvider=io,Ee.ChatSettings=WS,Ee.MarkdownContent=No,Ee.MessageComponent=qu,Ee.MessageList=$i,Ee.ThreadManager=ga,Ee.applySettings=G0,Ee.chatApiClient=gn,Ee.default=VS,Ee.del=bl,Ee.get=Nt,Ee.getChatToken=gl,Ee.getCurrentSettings=K0,Ee.getDefaultApiConfig=Jf,Ee.getDefaultChatSettings=Zf,Ee.onChatTokenChanged=xl,Ee.post=vl,Ee.put=wl,Ee.setChatToken=zs,Ee.useChat=ao,Ee.useChatStream=Sl,Ee.useMessagesReducer=Cl,Object.defineProperties(Ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
139
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Mw(e,t=Go){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 Dw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Mw(t),Ow(t)}function Fi(e){const t=e+"CollectionProvider",[n,r]=rn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,w=C.useRef(null),y=C.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:y,collectionRef:w,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=An.createSlot(a),u=C.forwardRef((v,g)=>{const{scope:x,children:w}=v,y=s(a,x),E=Me(g,y.collectionRef);return l.jsx(c,{ref:E,children:w})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=An.createSlot(d),m=C.forwardRef((v,g)=>{const{scope:x,children:w,...y}=v,E=C.useRef(null),S=Me(g,E),T=s(d,x);return C.useEffect(()=>(T.itemMap.set(E,{ref:E,...y}),()=>void T.itemMap.delete(E))),l.jsx(h,{[f]:"",ref:S,children:w})});m.displayName=d;function b(v){const g=s(e+"CollectionConsumer",v);return C.useCallback(()=>{const w=g.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},b,r]}var Lw=p.createContext(void 0);function Yo(e){const t=p.useContext(Lw);return e||t||"ltr"}const $w=["top","right","bottom","left"],Tn=Math.min,jt=Math.max,Xo=Math.round,Jo=Math.floor,an=e=>({x:e,y:e}),Fw={left:"right",right:"left",bottom:"top",top:"bottom"},zw={start:"end",end:"start"};function zi(e,t,n){return jt(e,Tn(t,n))}function hn(e,t){return typeof e=="function"?e(t):e}function pn(e){return e.split("-")[0]}function ir(e){return e.split("-")[1]}function Bi(e){return e==="x"?"y":"x"}function Hi(e){return e==="y"?"height":"width"}const Bw=new Set(["top","bottom"]);function ln(e){return Bw.has(pn(e))?"y":"x"}function Ui(e){return Bi(ln(e))}function Hw(e,t,n){n===void 0&&(n=!1);const r=ir(e),o=Ui(e),s=Hi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Zo(i)),[i,Zo(i)]}function Uw(e){const t=Zo(e);return[Wi(e),t,Wi(t)]}function Wi(e){return e.replace(/start|end/g,t=>zw[t])}const Yu=["left","right"],Xu=["right","left"],Ww=["top","bottom"],Vw=["bottom","top"];function qw(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Ww:Vw;default:return[]}}function Kw(e,t,n,r){const o=ir(e);let s=qw(pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Wi)))),s}function Zo(e){return e.replace(/left|right|bottom|top/g,t=>Fw[t])}function Gw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?Gw(e):{top:e,right:e,bottom:e,left:e}}function Qo(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 Zu(e,t,n){let{reference:r,floating:o}=e;const s=ln(t),i=Ui(t),a=Hi(i),c=pn(t),u=s==="y",d=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 m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(ir(t)){case"start":m[i]-=h*(n&&u?-1:1);break;case"end":m[i]+=h*(n&&u?-1:1);break}return m}const Yw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=Zu(u,r,c),h=r,m={},b=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:w,y,data:E,reset:S}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=w??d,f=y??f,m={...m,[g]:{...m[g],...E}},S&&b<=50&&(b++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=Zu(u,h,c)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}};async function Pr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=hn(t,e),b=Ju(m),g=a[h?f==="floating"?"reference":"floating":f],x=Qo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=Qo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:y,strategy:c}):w);return{top:(x.top-S.top+b.top)/E.y,bottom:(S.bottom-x.bottom+b.bottom)/E.y,left:(x.left-S.left+b.left)/E.x,right:(S.right-x.right+b.right)/E.x}}const Xw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=hn(e,t)||{};if(u==null)return{};const f=Ju(d),h={x:n,y:r},m=Ui(o),b=Hi(m),v=await i.getDimensions(u),g=m==="y",x=g?"top":"left",w=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[b]+s.reference[m]-h[m]-s.floating[b],S=h[m]-s.reference[m],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[b]);const N=E/2-S/2,A=I/2-v[b]/2-1,j=Tn(f[x],A),_=Tn(f[w],A),z=j,V=I-v[b]-_,O=I/2-v[b]/2+N,G=zi(z,O,V),W=!c.arrow&&ir(o)!=null&&O!==G&&s.reference[b]/2-(O<z?j:_)-v[b]/2<0,q=W?O<z?O-z:O-V:0;return{[m]:h[m]+q,data:{[m]:G,centerOffset:O-G-q,...W&&{alignmentOffset:q}},reset:W}}}),Jw=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:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:v=!0,...g}=hn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=pn(o),w=ln(a),y=pn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=h||(y||!v?[Zo(a)]:Uw(a)),T=b!=="none";!h&&T&&S.push(...Kw(a,v,b,E));const I=[a,...S],N=await Pr(t,g),A=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&A.push(N[x]),f){const O=Hw(o,i,E);A.push(N[O[0]],N[O[1]])}if(j=[...j,{placement:o,overflows:A}],!A.every(O=>O<=0)){var _,z;const O=(((_=s.flip)==null?void 0:_.index)||0)+1,G=I[O];if(G&&(!(f==="alignment"?w!==ln(G):!1)||j.every(L=>ln(L.placement)===w?L.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:G}};let W=(z=j.filter(q=>q.overflows[0]<=0).sort((q,L)=>q.overflows[1]-L.overflows[1])[0])==null?void 0:z.placement;if(!W)switch(m){case"bestFit":{var V;const q=(V=j.filter(L=>{if(T){const M=ln(L.placement);return M===w||M==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(M=>M>0).reduce((M,le)=>M+le,0)]).sort((L,M)=>L[1]-M[1])[0])==null?void 0:V[0];q&&(W=q);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return $w.some(t=>e[t]>=0)}const Zw=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 Pr(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await Pr(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function Qw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=pn(n),a=ir(n),c=ln(n)==="y",u=td.has(i)?-1:1,d=s&&c?-1:1,f=hn(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof b=="number"&&(m=a==="end"?b*-1:b),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const eb=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,c=await Qw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},tb=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:g=>{let{x,y:w}=g;return{x,y:w}}},...c}=hn(e,t),u={x:n,y:r},d=await Pr(t,c),f=ln(pn(o)),h=Bi(f);let m=u[h],b=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",w=m+d[g],y=m-d[x];m=zi(w,m,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",w=b+d[g],y=b-d[x];b=zi(w,b,y)}const v=a.fn({...t,[h]:m,[f]:b});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},nb=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:c=!0,crossAxis:u=!0}=hn(e,t),d={x:n,y:r},f=ln(o),h=Bi(f);let m=d[h],b=d[f];const v=hn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const y=h==="y"?"height":"width",E=s.reference[h]-s.floating[y]+g.mainAxis,S=s.reference[h]+s.reference[y]-g.mainAxis;m<E?m=E:m>S&&(m=S)}if(u){var x,w;const y=h==="y"?"width":"height",E=td.has(pn(o)),S=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(E?0:((w=i.offset)==null?void 0:w[f])||0)-(E?g.crossAxis:0);b<S?b=S:b>T&&(b=T)}return{[h]:m,[f]:b}}}},rb=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:c=()=>{},...u}=hn(e,t),d=await Pr(t,u),f=pn(o),h=ir(o),m=ln(o)==="y",{width:b,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const w=v-d.top-d.bottom,y=b-d.left-d.right,E=Tn(v-d[g],w),S=Tn(b-d[x],y),T=!t.middlewareData.shift;let I=E,N=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=w),T&&!h){const j=jt(d.left,0),_=jt(d.right,0),z=jt(d.top,0),V=jt(d.bottom,0);m?N=b-2*(j!==0||_!==0?j+_:jt(d.left,d.right)):I=v-2*(z!==0||V!==0?z+V:jt(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const A=await i.getDimensions(a.floating);return b!==A.width||v!==A.height?{reset:{rects:!0}}:{}}}};function es(){return typeof window<"u"}function ar(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function cn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return es()?e instanceof Node||e instanceof Pt(e).Node:!1}function Xt(e){return es()?e instanceof Element||e instanceof Pt(e).Element:!1}function un(e){return es()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function rd(e){return!es()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const ob=new Set(["inline","contents"]);function Or(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Jt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!ob.has(o)}const sb=new Set(["table","td","th"]);function ib(e){return sb.has(ar(e))}const ab=[":popover-open",":modal"];function ts(e){return ab.some(t=>{try{return e.matches(t)}catch{return!1}})}const lb=["transform","translate","scale","rotate","perspective"],cb=["transform","translate","scale","rotate","perspective","filter"],ub=["paint","layout","strict","content"];function Vi(e){const t=qi(),n=Xt(e)?Jt(e):e;return lb.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)||cb.some(r=>(n.willChange||"").includes(r))||ub.some(r=>(n.contain||"").includes(r))}function db(e){let t=kn(e);for(;un(t)&&!lr(t);){if(Vi(t))return t;if(ts(t))return null;t=kn(t)}return null}function qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const fb=new Set(["html","body","#document"]);function lr(e){return fb.has(ar(e))}function Jt(e){return Pt(e).getComputedStyle(e)}function ns(e){return Xt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kn(e){if(ar(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||cn(e);return rd(t)?t.host:t}function od(e){const t=kn(e);return lr(t)?e.ownerDocument?e.ownerDocument.body:e.body:un(t)&&Or(t)?t:od(t)}function Mr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const a=Ki(i);return t.concat(i,i.visualViewport||[],Or(o)?o:[],a&&n?Mr(a):[])}return t.concat(o,Mr(o,[],n))}function Ki(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=Jt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=un(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Xo(n)!==s||Xo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Gi(e){return Xt(e)?e:e.contextElement}function cr(e){const t=Gi(e);if(!un(t))return an(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Xo(n.width):n.width)/r,a=(s?Xo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const hb=an(0);function id(e){const t=Pt(e);return!qi()||!t.visualViewport?hb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function pb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function Hn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Gi(e);let i=an(1);t&&(r?Xt(r)&&(i=cr(r)):i=cr(e));const a=pb(s,n,r)?id(s):an(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Pt(s),m=r&&Xt(r)?Pt(r):r;let b=h,v=Ki(b);for(;v&&r&&m!==b;){const g=cr(v),x=v.getBoundingClientRect(),w=Jt(v),y=x.left+(v.clientLeft+parseFloat(w.paddingLeft))*g.x,E=x.top+(v.clientTop+parseFloat(w.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=y,u+=E,b=Pt(v),v=Ki(b)}}return Qo({width:d,height:f,x:c,y:u})}function Yi(e,t){const n=ns(e).scrollLeft;return t?t.left+n:Hn(cn(e)).left+n}function ad(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Yi(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function mb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=cn(r),a=t?ts(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=an(1);const d=an(0),f=un(r);if((f||!f&&!s)&&((ar(r)!=="body"||Or(i))&&(c=ns(r)),un(r))){const m=Hn(r);u=cr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=i&&!f&&!s?ad(i,c,!0):an(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function gb(e){return Array.from(e.getClientRects())}function xb(e){const t=cn(e),n=ns(e),r=e.ownerDocument.body,o=jt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=jt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Yi(e);const a=-n.scrollTop;return Jt(r).direction==="rtl"&&(i+=jt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function vb(e,t){const n=Pt(e),r=cn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=qi();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const wb=new Set(["absolute","fixed"]);function bb(e,t){const n=Hn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=un(e)?cr(e):an(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function ld(e,t,n){let r;if(t==="viewport")r=vb(e,n);else if(t==="document")r=xb(cn(e));else if(Xt(t))r=bb(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Qo(r)}function cd(e,t){const n=kn(e);return n===t||!Xt(n)||lr(n)?!1:Jt(n).position==="fixed"||cd(n,t)}function yb(e,t){const n=t.get(e);if(n)return n;let r=Mr(e,[],!1).filter(a=>Xt(a)&&ar(a)!=="body"),o=null;const s=Jt(e).position==="fixed";let i=s?kn(e):e;for(;Xt(i)&&!lr(i);){const a=Jt(i),c=Vi(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&wb.has(o.position)||Or(i)&&!c&&cd(e,i))?r=r.filter(d=>d!==i):o=a,i=kn(i)}return t.set(e,r),r}function Sb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ts(t)?[]:yb(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=ld(t,d,o);return u.top=jt(f.top,u.top),u.right=Tn(f.right,u.right),u.bottom=Tn(f.bottom,u.bottom),u.left=jt(f.left,u.left),u},ld(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Cb(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Tb(e,t,n){const r=un(t),o=cn(t),s=n==="fixed",i=Hn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=an(0);function u(){c.x=Yi(o)}if(r||!r&&!s)if((ar(t)!=="body"||Or(o))&&(a=ns(t)),r){const m=Hn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?ad(o,a):an(0),f=i.left+a.scrollLeft-c.x-d.x,h=i.top+a.scrollTop-c.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Xi(e){return Jt(e).position==="static"}function ud(e,t){if(!un(e)||Jt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return cn(e)===n&&(n=n.ownerDocument.body),n}function dd(e,t){const n=Pt(e);if(ts(e))return n;if(!un(e)){let o=kn(e);for(;o&&!lr(o);){if(Xt(o)&&!Xi(o))return o;o=kn(o)}return n}let r=ud(e,t);for(;r&&ib(r)&&Xi(r);)r=ud(r,t);return r&&lr(r)&&Xi(r)&&!Vi(r)?n:r||db(e)||n}const kb=async function(e){const t=this.getOffsetParent||dd,n=this.getDimensions,r=await n(e.floating);return{reference:Tb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eb(e){return Jt(e).direction==="rtl"}const Ib={convertOffsetParentRelativeRectToViewportRelativeRect:mb,getDocumentElement:cn,getClippingRect:Sb,getOffsetParent:dd,getElementRects:kb,getClientRects:gb,getDimensions:Cb,getScale:cr,isElement:Xt,isRTL:Eb};function fd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Nb(e,t){let n=null,r;const o=cn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(a||t(),!h||!m)return;const b=Jo(f),v=Jo(o.clientWidth-(d+h)),g=Jo(o.clientHeight-(f+m)),x=Jo(d),y={rootMargin:-b+"px "+-v+"px "+-g+"px "+-x+"px",threshold:jt(0,Tn(1,c))||1};let E=!0;function S(T){const I=T[0].intersectionRatio;if(I!==c){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!fd(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,y)}n.observe(e)}return i(!0),s}function Ab(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:c=!1}=r,u=Gi(e),d=o||s?[...u?Mr(u):[],...Mr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Nb(u,n):null;let h=-1,m=null;i&&(m=new ResizeObserver(x=>{let[w]=x;w&&w.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let b,v=c?Hn(e):null;c&&g();function g(){const x=Hn(e);v&&!fd(v,x)&&n(),v=x,b=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(b)}}const _b=eb,Rb=tb,jb=Jw,Pb=rb,Ob=Zw,hd=Xw,Mb=nb,Db=(e,t,n)=>{const r=new Map,o={platform:Ib,...n},s={...o.platform,_c:r};return Yw(e,t,{...o,platform:s})};var Lb=typeof document<"u",$b=function(){},rs=Lb?C.useLayoutEffect:$b;function os(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(!os(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)&&!os(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function pd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function md(e,t){const n=pd(e);return Math.round(t*n)/n}function Ji(e){const t=p.useRef(e);return rs(()=>{t.current=e}),t}function Fb(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:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);os(h,r)||m(r);const[b,v]=p.useState(null),[g,x]=p.useState(null),w=p.useCallback(L=>{L!==T.current&&(T.current=L,v(L))},[]),y=p.useCallback(L=>{L!==I.current&&(I.current=L,x(L))},[]),E=s||b,S=i||g,T=p.useRef(null),I=p.useRef(null),N=p.useRef(d),A=c!=null,j=Ji(c),_=Ji(o),z=Ji(u),V=p.useCallback(()=>{if(!T.current||!I.current)return;const L={placement:t,strategy:n,middleware:h};_.current&&(L.platform=_.current),Db(T.current,I.current,L).then(M=>{const le={...M,isPositioned:z.current!==!1};O.current&&!os(N.current,le)&&(N.current=le,Gr.flushSync(()=>{f(le)}))})},[h,t,n,_,z]);rs(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[u]);const O=p.useRef(!1);rs(()=>(O.current=!0,()=>{O.current=!1}),[]),rs(()=>{if(E&&(T.current=E),S&&(I.current=S),E&&S){if(j.current)return j.current(E,S,V);V()}},[E,S,V,j,A]);const G=p.useMemo(()=>({reference:T,floating:I,setReference:w,setFloating:y}),[w,y]),W=p.useMemo(()=>({reference:E,floating:S}),[E,S]),q=p.useMemo(()=>{const L={position:n,left:0,top:0};if(!W.floating)return L;const M=md(W.floating,d.x),le=md(W.floating,d.y);return a?{...L,transform:"translate("+M+"px, "+le+"px)",...pd(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:le}},[n,a,W.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:V,refs:G,elements:W,floatingStyles:q}),[d,V,G,W,q])}const zb=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?hd({element:r.current,padding:o}).fn(n):{}:r?hd({element:r,padding:o}).fn(n):{}}}},Bb=(e,t)=>({..._b(e),options:[e,t]}),Hb=(e,t)=>({...Rb(e),options:[e,t]}),Ub=(e,t)=>({...Mb(e),options:[e,t]}),Wb=(e,t)=>({...jb(e),options:[e,t]}),Vb=(e,t)=>({...Pb(e),options:[e,t]}),qb=(e,t)=>({...Ob(e),options:[e,t]}),Kb=(e,t)=>({...zb(e),options:[e,t]});var Gb="Arrow",gd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});gd.displayName=Gb;var Yb=gd;function xd(e){const[t,n]=p.useState(void 0);return ht(()=>{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 c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.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 Zi="Popper",[vd,ss]=rn(Zi),[Xb,wd]=vd(Zi),bd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return l.jsx(Xb,{scope:t,anchor:r,onAnchorChange:o,children:n})};bd.displayName=Zi;var yd="PopperAnchor",Sd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=wd(yd,n),i=p.useRef(null),a=Me(t,i),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(ye.div,{...o,ref:a})});Sd.displayName=yd;var Qi="PopperContent",[Jb,Zb]=vd(Qi),Cd=p.forwardRef((e,t)=>{var $,P,H,Q,ce,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:b,...v}=e,g=wd(Qi,n),[x,w]=p.useState(null),y=Me(t,Fe=>w(Fe)),[E,S]=p.useState(null),T=xd(E),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,A=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},_=Array.isArray(u)?u:[u],z=_.length>0,V={padding:j,boundary:_.filter(ey),altBoundary:z},{refs:O,floatingStyles:G,placement:W,isPositioned:q,middlewareData:L}=Fb({strategy:"fixed",placement:A,whileElementsMounted:(...Fe)=>Ab(...Fe,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[Bb({mainAxis:o+N,alignmentAxis:i}),c&&Hb({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Ub():void 0,...V}),c&&Wb({...V}),Vb({...V,apply:({elements:Fe,rects:$e,availableWidth:we,availableHeight:Ne})=>{const{width:Ue,height:et}=$e.reference,Xe=Fe.floating.style;Xe.setProperty("--radix-popper-available-width",`${we}px`),Xe.setProperty("--radix-popper-available-height",`${Ne}px`),Xe.setProperty("--radix-popper-anchor-width",`${Ue}px`),Xe.setProperty("--radix-popper-anchor-height",`${et}px`)}}),E&&Kb({element:E,padding:a}),ty({arrowWidth:I,arrowHeight:N}),h&&qb({strategy:"referenceHidden",...V})]}),[M,le]=Ed(W),J=pt(b);ht(()=>{q&&(J==null||J())},[q,J]);const ee=($=L.arrow)==null?void 0:$.x,D=(P=L.arrow)==null?void 0:P.y,Z=((H=L.arrow)==null?void 0:H.centerOffset)!==0,[ke,he]=p.useState();return ht(()=>{x&&he(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:q?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[(Q=L.transformOrigin)==null?void 0:Q.x,(ce=L.transformOrigin)==null?void 0:ce.y].join(" "),...((ie=L.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(Jb,{scope:n,placedSide:M,onArrowChange:S,arrowX:ee,arrowY:D,shouldHideArrow:Z,children:l.jsx(ye.div,{"data-side":M,"data-align":le,...v,ref:y,style:{...v.style,animation:q?void 0:"none"}})})})});Cd.displayName=Qi;var Td="PopperArrow",Qb={top:"bottom",right:"left",bottom:"top",left:"right"},kd=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Zb(Td,r),i=Qb[s.placedSide];return l.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:l.jsx(Yb,{...o,ref:n,style:{...o.style,display:"block"}})})});kd.displayName=Td;function ey(e){return e!==null}var ty=e=>({name:"transformOrigin",options:e,fn(t){var g,x,w;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Ed(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((w=o.arrow)==null?void 0:w.y)??0)+c/2;let b="",v="";return u==="bottom"?(b=i?f:`${h}px`,v=`${-c}px`):u==="top"?(b=i?f:`${h}px`,v=`${r.floating.height+c}px`):u==="right"?(b=`${-c}px`,v=i?f:`${m}px`):u==="left"&&(b=`${r.floating.width+c}px`,v=i?f:`${m}px`),{data:{x:b,y:v}}}});function Ed(e){const[t,n="center"]=e.split("-");return[t,n]}var Id=bd,Nd=Sd,Ad=Cd,_d=kd,ea="rovingFocusGroup.onEntryFocus",ny={bubbles:!1,cancelable:!0},Dr="RovingFocusGroup",[ta,Rd,ry]=Fi(Dr),[oy,jd]=rn(Dr,[ry]),[sy,iy]=oy(Dr),Pd=p.forwardRef((e,t)=>l.jsx(ta.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ta.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ay,{...e,ref:t})})}));Pd.displayName=Dr;var ay=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=p.useRef(null),m=Me(t,h),b=Yo(s),[v,g]=Ln({prop:i,defaultProp:a??null,onChange:c,caller:Dr}),[x,w]=p.useState(!1),y=pt(u),E=Rd(n),S=p.useRef(!1),[T,I]=p.useState(0);return p.useEffect(()=>{const N=h.current;if(N)return N.addEventListener(ea,y),()=>N.removeEventListener(ea,y)},[y]),l.jsx(sy,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:v,onItemFocus:p.useCallback(N=>g(N),[g]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>I(N=>N-1),[]),children:l.jsx(ye.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{S.current=!0}),onFocus:ae(e.onFocus,N=>{const A=!S.current;if(N.target===N.currentTarget&&A&&!x){const j=new CustomEvent(ea,ny);if(N.currentTarget.dispatchEvent(j),!j.defaultPrevented){const _=E().filter(W=>W.focusable),z=_.find(W=>W.active),V=_.find(W=>W.id===v),G=[z,V,..._].filter(Boolean).map(W=>W.ref.current);Dd(G,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>w(!1))})})}),Od="RovingFocusGroupItem",Md=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=on(),u=s||c,d=iy(Od,n),f=d.currentTabStopId===u,h=Rd(n),{onFocusableItemAdd:m,onFocusableItemRemove:b,currentTabStopId:v}=d;return p.useEffect(()=>{if(r)return m(),()=>b()},[r,m,b]),l.jsx(ta.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(ye.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:ae(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=uy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=d.loop?dy(y,E+1):y.slice(E+1)}setTimeout(()=>Dd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});Md.displayName=Od;var ly={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function uy(e,t,n){const r=cy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ly[r]}function Dd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function dy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fy=Pd,hy=Md,na=["Enter"," "],py=["ArrowDown","PageUp","Home"],Ld=["ArrowUp","PageDown","End"],my=[...py,...Ld],gy={ltr:[...na,"ArrowRight"],rtl:[...na,"ArrowLeft"]},xy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Lr="Menu",[$r,vy,wy]=Fi(Lr),[Un,$d]=rn(Lr,[wy,ss,jd]),is=ss(),Fd=jd(),[by,Wn]=Un(Lr),[yy,Fr]=Un(Lr),zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=is(t),[c,u]=p.useState(null),d=p.useRef(!1),f=pt(s),h=Yo(o);return p.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),l.jsx(Id,{...a,children:l.jsx(by,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(yy,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};zd.displayName=Lr;var Sy="MenuAnchor",ra=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=is(n);return l.jsx(Nd,{...o,...r,ref:t})});ra.displayName=Sy;var oa="MenuPortal",[Cy,Bd]=Un(oa,{forceMount:void 0}),Hd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Wn(oa,t);return l.jsx(Cy,{scope:t,forceMount:n,children:l.jsx(Rt,{present:n||s.open,children:l.jsx(Po,{asChild:!0,container:o,children:r})})})};Hd.displayName=oa;var zt="MenuContent",[Ty,sa]=Un(zt),Ud=p.forwardRef((e,t)=>{const n=Bd(zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Wn(zt,e.__scopeMenu),i=Fr(zt,e.__scopeMenu);return l.jsx($r.Provider,{scope:e.__scopeMenu,children:l.jsx(Rt,{present:r||s.open,children:l.jsx($r.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(ky,{...o,ref:t}):l.jsx(Ey,{...o,ref:t})})})})}),ky=p.forwardRef((e,t)=>{const n=Wn(zt,e.__scopeMenu),r=p.useRef(null),o=Me(t,r);return p.useEffect(()=>{const s=r.current;if(s)return ji(s)},[]),l.jsx(ia,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ey=p.forwardRef((e,t)=>{const n=Wn(zt,e.__scopeMenu);return l.jsx(ia,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Iy=An.createSlot("MenuContent.ScrollLock"),ia=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,disableOutsideScroll:b,...v}=e,g=Wn(zt,n),x=Fr(zt,n),w=is(n),y=Fd(n),E=vy(n),[S,T]=p.useState(null),I=p.useRef(null),N=Me(t,I,g.onContentChange),A=p.useRef(0),j=p.useRef(""),_=p.useRef(0),z=p.useRef(null),V=p.useRef("right"),O=p.useRef(0),G=b?Fo:p.Fragment,W=b?{as:Iy,allowPinchZoom:!0}:void 0,q=M=>{var $,P;const le=j.current+M,J=E().filter(H=>!H.disabled),ee=document.activeElement,D=($=J.find(H=>H.ref.current===ee))==null?void 0:$.textValue,Z=J.map(H=>H.textValue),ke=Fy(Z,le,D),he=(P=J.find(H=>H.textValue===ke))==null?void 0:P.ref.current;(function H(Q){j.current=Q,window.clearTimeout(A.current),Q!==""&&(A.current=window.setTimeout(()=>H(""),1e3))})(le),he&&setTimeout(()=>he.focus())};p.useEffect(()=>()=>window.clearTimeout(A.current),[]),Ei();const L=p.useCallback(M=>{var J,ee;return V.current===((J=z.current)==null?void 0:J.side)&&By(M,(ee=z.current)==null?void 0:ee.area)},[]);return l.jsx(Ty,{scope:n,searchRef:j,onItemEnter:p.useCallback(M=>{L(M)&&M.preventDefault()},[L]),onItemLeave:p.useCallback(M=>{var le;L(M)||((le=I.current)==null||le.focus(),T(null))},[L]),onTriggerLeave:p.useCallback(M=>{L(M)&&M.preventDefault()},[L]),pointerGraceTimerRef:_,onPointerGraceIntentChange:p.useCallback(M=>{z.current=M},[]),children:l.jsx(G,{...W,children:l.jsx(jo,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,M=>{var le;M.preventDefault(),(le=I.current)==null||le.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Ro,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,children:l.jsx(fy,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ae(c,M=>{x.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(Ad,{role:"menu","aria-orientation":"vertical","data-state":af(g.open),"data-radix-menu-content":"",dir:x.dir,...w,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:ae(v.onKeyDown,M=>{const J=M.target.closest("[data-radix-menu-content]")===M.currentTarget,ee=M.ctrlKey||M.altKey||M.metaKey,D=M.key.length===1;J&&(M.key==="Tab"&&M.preventDefault(),!ee&&D&&q(M.key));const Z=I.current;if(M.target!==Z||!my.includes(M.key))return;M.preventDefault();const he=E().filter($=>!$.disabled).map($=>$.ref.current);Ld.includes(M.key)&&he.reverse(),Ly(he)}),onBlur:ae(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(A.current),j.current="")}),onPointerMove:ae(e.onPointerMove,Br(M=>{const le=M.target,J=O.current!==M.clientX;if(M.currentTarget.contains(le)&&J){const ee=M.clientX>O.current?"right":"left";V.current=ee,O.current=M.clientX}}))})})})})})})});Ud.displayName=zt;var Ny="MenuGroup",aa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"group",...r,ref:t})});aa.displayName=Ny;var Ay="MenuLabel",Wd=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{...r,ref:t})});Wd.displayName=Ay;var as="MenuItem",Vd="menu.itemSelect",ls=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=Fr(as,e.__scopeMenu),a=sa(as,e.__scopeMenu),c=Me(t,s),u=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Vd,{bubbles:!0,cancelable:!0});f.addEventListener(Vd,m=>r==null?void 0:r(m),{once:!0}),Nc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(qd,{...o,ref:c,disabled:n,onClick:ae(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:ae(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ae(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||na.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ls.displayName=as;var qd=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=sa(as,n),a=Fd(n),c=p.useRef(null),u=Me(t,c),[d,f]=p.useState(!1),[h,m]=p.useState("");return p.useEffect(()=>{const b=c.current;b&&m((b.textContent??"").trim())},[s.children]),l.jsx($r.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:l.jsx(hy,{asChild:!0,...a,focusable:!r,children:l.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:ae(e.onPointerMove,Br(b=>{r?i.onItemLeave(b):(i.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,Br(b=>i.onItemLeave(b))),onFocus:ae(e.onFocus,()=>f(!0)),onBlur:ae(e.onBlur,()=>f(!1))})})})}),_y="MenuCheckboxItem",Kd=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(Zd,{scope:e.__scopeMenu,checked:n,children:l.jsx(ls,{role:"menuitemcheckbox","aria-checked":cs(n)?"mixed":n,...o,ref:t,"data-state":ca(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Kd.displayName=_y;var Gd="MenuRadioGroup",[Ry,jy]=Un(Gd,{value:void 0,onValueChange:()=>{}}),Yd=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return l.jsx(Ry,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(aa,{...o,ref:t})})});Yd.displayName=Gd;var Xd="MenuRadioItem",Jd=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=jy(Xd,e.__scopeMenu),s=n===o.value;return l.jsx(Zd,{scope:e.__scopeMenu,checked:s,children:l.jsx(ls,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ca(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Jd.displayName=Xd;var la="MenuItemIndicator",[Zd,Py]=Un(la,{checked:!1}),Qd=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Py(la,n);return l.jsx(Rt,{present:r||cs(s.checked)||s.checked===!0,children:l.jsx(ye.span,{...o,ref:t,"data-state":ca(s.checked)})})});Qd.displayName=la;var Oy="MenuSeparator",ef=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ef.displayName=Oy;var My="MenuArrow",tf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=is(n);return l.jsx(_d,{...o,...r,ref:t})});tf.displayName=My;var Dy="MenuSub",[EC,nf]=Un(Dy),zr="MenuSubTrigger",rf=p.forwardRef((e,t)=>{const n=Wn(zr,e.__scopeMenu),r=Fr(zr,e.__scopeMenu),o=nf(zr,e.__scopeMenu),s=sa(zr,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(ra,{asChild:!0,...u,children:l.jsx(qd,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":af(n.open),...e,ref:hi(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:ae(e.onPointerMove,Br(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,Br(f=>{var m,b;d();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const v=(b=n.content)==null?void 0:b.dataset.side,g=v==="right",x=g?-5:5,w=h[g?"left":"right"],y=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:w,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x:w,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,f=>{var m;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||gy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});rf.displayName=zr;var of="MenuSubContent",sf=p.forwardRef((e,t)=>{const n=Bd(zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Wn(zt,e.__scopeMenu),i=Fr(zt,e.__scopeMenu),a=nf(of,e.__scopeMenu),c=p.useRef(null),u=Me(t,c);return l.jsx($r.Provider,{scope:e.__scopeMenu,children:l.jsx(Rt,{present:r||s.open,children:l.jsx($r.Slot,{scope:e.__scopeMenu,children:l.jsx(ia,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),h=xy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});sf.displayName=of;function af(e){return e?"open":"closed"}function cs(e){return e==="indeterminate"}function ca(e){return cs(e)?"indeterminate":e?"checked":"unchecked"}function Ly(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function $y(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Fy(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=$y(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function zy(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],c=t[i],u=a.x,d=a.y,f=c.x,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function By(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return zy(n,t)}function Br(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Hy=zd,Uy=ra,Wy=Hd,Vy=Ud,qy=aa,Ky=Wd,Gy=ls,Yy=Kd,Xy=Yd,Jy=Jd,Zy=Qd,Qy=ef,e0=tf,t0=rf,n0=sf,us="DropdownMenu",[r0,IC]=rn(us,[$d]),yt=$d(),[o0,lf]=r0(us),cf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=yt(t),u=p.useRef(null),[d,f]=Ln({prop:o,defaultProp:s??!1,onChange:i,caller:us});return l.jsx(o0,{scope:t,triggerId:on(),triggerRef:u,contentId:on(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:a,children:l.jsx(Hy,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};cf.displayName=us;var uf="DropdownMenuTrigger",df=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=lf(uf,n),i=yt(n);return l.jsx(Uy,{asChild:!0,...i,children:l.jsx(ye.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:hi(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});df.displayName=uf;var s0="DropdownMenuPortal",ff=e=>{const{__scopeDropdownMenu:t,...n}=e,r=yt(t);return l.jsx(Wy,{...r,...n})};ff.displayName=s0;var hf="DropdownMenuContent",pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=lf(hf,n),s=yt(n),i=p.useRef(!1);return l.jsx(Vy,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!o.modal||d)&&(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)"}})});pf.displayName=hf;var i0="DropdownMenuGroup",a0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(qy,{...o,...r,ref:t})});a0.displayName=i0;var l0="DropdownMenuLabel",mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Ky,{...o,...r,ref:t})});mf.displayName=l0;var c0="DropdownMenuItem",gf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Gy,{...o,...r,ref:t})});gf.displayName=c0;var u0="DropdownMenuCheckboxItem",xf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Yy,{...o,...r,ref:t})});xf.displayName=u0;var d0="DropdownMenuRadioGroup",f0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Xy,{...o,...r,ref:t})});f0.displayName=d0;var h0="DropdownMenuRadioItem",vf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Jy,{...o,...r,ref:t})});vf.displayName=h0;var p0="DropdownMenuItemIndicator",wf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Zy,{...o,...r,ref:t})});wf.displayName=p0;var m0="DropdownMenuSeparator",bf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(Qy,{...o,...r,ref:t})});bf.displayName=m0;var g0="DropdownMenuArrow",x0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(e0,{...o,...r,ref:t})});x0.displayName=g0;var v0="DropdownMenuSubTrigger",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(t0,{...o,...r,ref:t})});yf.displayName=v0;var w0="DropdownMenuSubContent",Sf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return l.jsx(n0,{...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)"}})});Sf.displayName=w0;var b0=cf,y0=df,S0=ff,Cf=pf,Tf=mf,kf=gf,Ef=xf,If=vf,Nf=wf,Af=bf,_f=yf,Rf=Sf;const C0=b0,T0=y0,k0=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(_f,{ref:o,className:X("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,l.jsx(oe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));k0.displayName=_f.displayName;const E0=p.forwardRef(({className:e,...t},n)=>l.jsx(Rf,{ref:n,className:X("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}));E0.displayName=Rf.displayName;const jf=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(S0,{children:l.jsx(Cf,{ref:r,sideOffset:t,className:X("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})}));jf.displayName=Cf.displayName;const ua=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(kf,{ref:r,className:X("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}));ua.displayName=kf.displayName;const I0=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(Ef,{ref:o,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Nf,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),t]}));I0.displayName=Ef.displayName;const N0=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(If,{ref:r,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Nf,{children:l.jsx(oe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));N0.displayName=If.displayName;const A0=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Tf,{ref:r,className:X("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));A0.displayName=Tf.displayName;const _0=p.forwardRef(({className:e,...t},n)=>l.jsx(Af,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));_0.displayName=Af.displayName;function ds({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:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:m}){const{currentThreadId:b,messages:v,isStreaming:g,streamingAssistantId:x,error:w,send:y,stop:E,lastCheckpointId:S,lastCheckpointNs:T,listCheckpoints:I,navigateToCheckpoint:N,returnToLatest:A,hasMoreHistory:j,isLoadingHistory:_,loadOlderMessages:z,api:V}=ao(),[O,G]=C.useState(null),[W,q]=C.useState(""),[L,M]=C.useState(null),[le,J]=C.useState([]),[ee,D]=C.useState(!1),[Z,ke]=C.useState(null),[he,$]=C.useState(null),[P,H]=C.useState(!1),[Q,ce]=C.useState(null),[ie,Fe]=C.useState([]),[$e,we]=C.useState(null),[Ne,Ue]=C.useState(null),[et,Xe]=C.useState(!1),ut=C.useRef(null),dt=C.useRef(null),ue=C.useRef(null),[fe,pe]=C.useState("desktop");C.useEffect(()=>{const te=()=>{const me=window.innerWidth;pe(me<640?"phone":me<1024?"tablet":"desktop")};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]),C.useEffect(()=>{let te=!1;if(!b){Fe([]),we(null),Ue(null),ue.current=null;return}const me={threadId:b,checkpointId:S??null,checkpointNs:T??null},Pe=ue.current;if(!(Pe&&Pe.threadId===me.threadId&&Pe.checkpointId===me.checkpointId&&Pe.checkpointNs===me.checkpointNs))return I(b).then(ze=>{var Vr;if(te)return;const Wt=((ze==null?void 0:ze.checkpoints)??[]).slice().sort((mn,qr)=>new Date(qr.createdAt).getTime()-new Date(mn.createdAt).getTime());Fe(Wt);const Mt=$e,Ur=Mt&&Wt.some(mn=>mn.checkpointId===Mt)?Mt:((Vr=Wt[0])==null?void 0:Vr.checkpointId)??null;let Wr=null;if(Ur){const mn=Wt.find(qr=>qr.checkpointId===Ur);Wr=(mn==null?void 0:mn.checkpointNs)??null}we(Ur),Ue(Wr),ue.current=me}).catch(ze=>{console.error("ChatInterface - listCheckpoints error:",ze),te||(Fe([]),ue.current=null)}),()=>{te=!0}},[b,S,T,$e,I]),C.useEffect(()=>{S&&(we(S),Ue(T??null))},[S,T]);const Se=C.useCallback(async()=>{if(!(!j||_))try{await z()}catch(te){console.warn("loadOlderMessages failed",te)}},[j,_,z]);C.useEffect(()=>{(async()=>{if(!V.baseUrl){ce(null);return}try{const me=await V.getAgent("default");ce(me.uiDefaultMessage||null)}catch(me){console.warn("Failed to fetch default message:",me),ce(null)}})()},[V]),C.useEffect(()=>{w&&!P&&(m==null||m(w))},[w,P,m]);const Oe=te=>{if(te.length>Go)return`Message too long (${te.length}/${Go} characters)`;try{return Dw(te),null}catch(me){return(me==null?void 0:me.message)||"Invalid message"}},Ve=async te=>{const me=te.trim();if(!(!me&&le.length===0)){if(me){const Pe=Oe(me);if(Pe){M(Pe);return}}try{await y(me||"",{checkpointId:$e??S??void 0,checkpointNs:Ne??T??void 0,payloadExtras:O?{edit:!0,originalMessageId:O}:void 0,attachments:le}),f==null||f(me),M(null),J([]),G(null),q("")}catch(Pe){const ze=(Pe==null?void 0:Pe.message)||"Failed to send message";M(ze),m==null||m(ze)}}},F=C.useCallback((te,me)=>{u&&(G(te),q(me),M(null))},[u]),Y=C.useCallback(()=>{G(null),q(""),M(null)},[]),je=C.useCallback((te,me)=>{F(te,me)},[F]),nt=C.useCallback(te=>{const me=Pe=>{const ze=Pe.content||[],Wt=ze.filter(Mt=>Mt.type==="text").map(Mt=>Mt.text).join("");if(Wt)return Wt;try{return JSON.stringify(ze,null,2)}catch{return String(ze)}};for(let Pe=te-1;Pe>=0;Pe--)if(v[Pe].role==="user"){const ze=me(v[Pe]);ze&&y(ze,{checkpointId:$e??S??void 0,checkpointNs:Ne??T??void 0});break}},[v,y,$e,Ne,S,T]),_e=te=>{const me=Array.from(te.target.files||[]);J(Pe=>[...Pe,...me]),te.target.value=""},at=te=>J(me=>me.filter((Pe,ze)=>te!==ze)),Ut=async te=>{const me=(te.target.files||[])[0];if(me){ke(null),$(null),D(!0);try{await y("",{checkpointId:$e??S??void 0,checkpointNs:Ne??T??void 0,attachments:[me]});const Pe=`Uploaded ${me.name} - processing through chat stream`;$(Pe)}catch(Pe){const ze=Pe instanceof Error?Pe.message:"Failed to upload Excel file";console.error("Excel upload failed",Pe),ke(ze),m==null||m(ze)}finally{D(!1),te.target.value=""}}},Gn=te=>{if(!te)return"Unknown";const me=Date.parse(te);return Number.isNaN(me)?te:new Date(me).toLocaleString()},wt=async te=>{if(b){Xe(!0);try{if(!te){await A(),we(null),Ue(null);return}const me=ie.find(ze=>ze.checkpointId===te),Pe=(me==null?void 0:me.checkpointNs)??null;await N(te,Pe),we(te),Ue(Pe)}finally{Xe(!1)}}},Ot=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,ft=`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 ${d.messagesArea||""}`,Et=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:Ot,children:[!!w&&!P&&l.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:[l.jsx("span",{children:w}),l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>H(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(oe.X,{size:16})})]}),b&&ie.length>0&&l.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:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.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:$e??"",onChange:te=>{const me=te.target.value||null;wt(me)},children:[l.jsx("option",{value:"",children:"Latest"}),ie.map(te=>l.jsxs("option",{value:te.checkpointId,children:[Gn(te.createdAt),te.preview?` — ${te.preview.slice(0,40)}`:""]},te.checkpointId))]})]}),l.jsx($i,{className:ft,style:r?{maxHeight:r}:void 0,messages:v,isStreaming:g,streamingAssistantId:x,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:fe,enableMessageEditing:u,editingMessageId:O,onStartReached:()=>{Se()},onEdit:je,onRegenerate:nt,onCancelEdit:Y,emptyMessage:Q??void 0,isNavigatingCheckpoint:et}),l.jsxs("div",{className:Et,children:[O&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(oe.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(We,{variant:"ghost",size:"sm",onClick:Y,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(oe.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ut,type:"file",multiple:!0,onChange:te=>_e(te),className:"hidden"}),le.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:le.map((te,me)=>l.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:[l.jsx(oe.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:te.name}),l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>at(me),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 ${te.name}`,children:l.jsx(oe.X,{size:12})})]},me))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:dt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Ut,className:"hidden"}),ee&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(oe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),he&&!ee&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:he}),Z&&!ee&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Z})]})]}),L&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:L}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(C0,{children:[l.jsx(T0,{asChild:!0,children:l.jsx(We,{type:"button",size:"icon",variant:"outline",disabled:g,title:"More input actions",className:d.moreButton||"",children:l.jsx(oe.Plus,{size:16})})}),l.jsxs(jf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(ua,{onClick:()=>{var te;return(te=ut.current)==null?void 0:te.click()},className:"cursor-pointer",children:[l.jsx(oe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(ua,{onClick:()=>{var te;ee||(te=dt.current)==null||te.click()},className:`cursor-pointer ${ee?"opacity-60 pointer-events-none":""}`,children:[l.jsx(oe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(Gm,{initialValue:W,editingMessageId:O,placeholder:O?"Edit your message...":t,isStreaming:g,disabled:!1,maxLength:Go,onSend:Ve,onCancelEdit:Y,onStop:E,allowEmptySend:le.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${O?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${L?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const fs=p.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:X("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}));fs.displayName="Input";function da(e,[t,n]){return Math.min(n,Math.max(t,e))}function R0(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var fa="ScrollArea",[Pf,NC]=rn(fa),[j0,Bt]=Pf(fa),Of=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,b]=p.useState(null),[v,g]=p.useState(null),[x,w]=p.useState(0),[y,E]=p.useState(0),[S,T]=p.useState(!1),[I,N]=p.useState(!1),A=Me(t,_=>c(_)),j=Yo(o);return l.jsx(j0,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:b,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:w,onCornerHeightChange:E,children:l.jsx(ye.div,{dir:j,...i,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Of.displayName=fa;var Mf="ScrollAreaViewport",Df=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Bt(Mf,n),a=p.useRef(null),c=Me(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(ye.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Df.displayName=Mf;var dn="ScrollAreaScrollbar",ha=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bt(dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?l.jsx(P0,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(O0,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Lf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(pa,{...r,ref:t}):null});ha.displayName=dn;var P0=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bt(dn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(Rt,{present:n||s,children:l.jsx(Lf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),O0=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bt(dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=gs(()=>c("SCROLL_END"),100),[a,c]=R0("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 p.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),p.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,c,i]),l.jsx(Rt,{present:n||a!=="hidden",children:l.jsx(pa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Lf=p.forwardRef((e,t)=>{const n=Bt(dn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",c=gs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return ur(n.viewport,c),ur(n.content,c),l.jsx(Rt,{present:r||s,children:l.jsx(pa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),pa=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Bt(dn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Hf(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,m){return z0(h,i.current,a,m)}return n==="horizontal"?l.jsx(M0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,m=Uf(h,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?l.jsx(D0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,m=Uf(h,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),M0=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Bt(dn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Me(t,c,s.onScrollbarXChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Ff,{"data-orientation":"horizontal",...o,ref:u,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":ms(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),Vf(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ps(i.paddingLeft),paddingEnd:ps(i.paddingRight)}})}})}),D0=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Bt(dn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Me(t,c,s.onScrollbarYChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Ff,{"data-orientation":"vertical",...o,ref:u,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":ms(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),Vf(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ps(i.paddingTop),paddingEnd:ps(i.paddingBottom)}})}})}),[L0,$f]=Pf(dn),Ff=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,m=Bt(dn,n),[b,v]=p.useState(null),g=Me(t,A=>v(A)),x=p.useRef(null),w=p.useRef(""),y=m.viewport,E=r.content-r.viewport,S=pt(d),T=pt(c),I=gs(f,10);function N(A){if(x.current){const j=A.clientX-x.current.left,_=A.clientY-x.current.top;u({x:j,y:_})}}return p.useEffect(()=>{const A=j=>{const _=j.target;(b==null?void 0:b.contains(_))&&S(j,E)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[y,b,E,S]),p.useEffect(T,[r,T]),ur(b,I),ur(m.content,I),l.jsx(L0,{scope:n,scrollbar:b,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:l.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:ae(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),x.current=b.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(A))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,A=>{const j=A.target;j.hasPointerCapture(A.pointerId)&&j.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=w.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),hs="ScrollAreaThumb",zf=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$f(hs,e.__scopeScrollArea);return l.jsx(Rt,{present:n||o.hasThumb,children:l.jsx($0,{ref:t,...r})})}),$0=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Bt(hs,n),i=$f(hs,n),{onThumbPositionChange:a}=i,c=Me(t,f=>i.onThumbChange(f)),u=p.useRef(void 0),d=gs(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const m=B0(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),l.jsx(ye.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),b=f.clientX-m.left,v=f.clientY-m.top;i.onThumbPointerDown({x:b,y:v})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});zf.displayName=hs;var ma="ScrollAreaCorner",Bf=p.forwardRef((e,t)=>{const n=Bt(ma,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(F0,{...e,ref:t}):null});Bf.displayName=ma;var F0=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Bt(ma,n),[s,i]=p.useState(0),[a,c]=p.useState(0),u=!!(s&&a);return ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(ye.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 ps(e){return e?parseInt(e,10):0}function Hf(e,t){const n=e/t;return isNaN(n)?0:n}function ms(e){const t=Hf(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function z0(e,t,n,r="ltr"){const o=ms(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Wf([c,u],f)(e)}function Uf(e,t,n="ltr"){const r=ms(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=da(e,c);return Wf([0,i],[0,a])(u)}function Wf(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 Vf(e,t){return e>0&&e<t}var B0=(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 gs(e,t){const n=pt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ur(e,t){const n=pt(t);ht(()=>{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 qf=Of,H0=Df,U0=Bf;const Kf=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(qf,{ref:r,className:X("relative overflow-hidden",e),...n,children:[l.jsx(H0,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(Gf,{}),l.jsx(U0,{})]}));Kf.displayName=qf.displayName;const Gf=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(ha,{ref:r,orientation:t,className:X("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:l.jsx(zf,{className:"relative flex-1 rounded-full bg-border"})}));Gf.displayName=ha.displayName;function ga({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,refreshThreads:m,currentThreadId:b,createThread:v,deleteThread:g,renameThread:x}=ao(),[w,y]=C.useState(h??[]),[E,S]=C.useState(!1),[T,I]=C.useState(null),[N,A]=C.useState(null),[j,_]=C.useState(""),[z,V]=C.useState(!1);C.useEffect(()=>{y(h??[])},[h]);const O=async D=>{try{await f(D),a==null||a(D),c==null||c(D)}catch(Z){console.error("Failed to select thread:",Z)}},G=async()=>{try{V(!0);const D=await v();u==null||u(D),a==null||a(D)}catch(D){console.error("Failed to create thread:",D)}finally{V(!1)}},W=async(D,Z)=>{if(Z.stopPropagation(),!!confirm("Delete this thread?"))try{await g(D),d==null||d(D)}catch(ke){console.error("Failed to delete thread:",ke)}},q=(D,Z)=>{Z.stopPropagation(),A(D.threadId),_(D.title||`Thread ${D.threadId.slice(0,8)}`)},L=async D=>{if(j.trim())try{await x(D,j.trim()),A(null),_("")}catch(Z){console.error("Failed to update title:",Z)}},M=()=>{A(null),_("")},le=(D,Z)=>{D.key==="Enter"?L(Z):D.key==="Escape"&&M()},J=D=>{if(!D)return"";try{const Z=new Date(D),he=new Date().getTime()-Z.getTime(),$=Math.floor(he/(1e3*60*60*24));return $===0?Z.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):$===1?"Yesterday":$<7?`${$} days ago`:Z.toLocaleDateString()}catch{return""}},ee=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.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:l.jsx(We,{onClick:G,disabled:z||E,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:z?"Creating...":"New Chat",children:l.jsx(oe.MessageSquarePlus,{size:20})})}),l.jsx(Kf,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:E?l.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):w.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(oe.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):w.slice().sort((D,Z)=>new Date(Z.updatedAt||Z.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>l.jsxs("div",{onClick:()=>O(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??b)===D.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:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:N===D.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:Z=>Z.stopPropagation(),children:[l.jsx(fs,{value:j,onChange:Z=>_(Z.target.value),onKeyDown:Z=>le(Z,D.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>L(D.threadId),className:"h-6 w-6 p-0",children:l.jsx(oe.Check,{size:12})}),l.jsx(We,{variant:"ghost",size:"sm",onClick:M,className:"h-6 w-6 p-0",children:l.jsx(oe.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ee(D)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(oe.Calendar,{size:10}),l.jsx("span",{children:J(D.updatedAt||D.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==D.threadId&&l.jsx(We,{variant:"ghost",size:"sm",onClick:Z=>q(D,Z),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(oe.Edit3,{size:12})}),n&&l.jsx(We,{variant:"ghost",size:"sm",onClick:Z=>W(D.threadId,Z),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(oe.Trash2,{size:12})})]})]}),i===D.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}function dr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function W0(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function Yf(){const e=[dr("__API_BASE_URL__"),dr("__CHAT_API_BASE_URL__"),dr("__CHAT_API_URL__")];for(const t of e){const n=W0(t);if(n)return n}}function Xf(){const e=[dr("__API_AUTH_TOKEN__"),dr("__CHAT_API_KEY__"),dr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Jf(){const e={},t=Yf(),n=Xf();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Zf(){const e=Jf(),t=gn.getAuthToken(),n=Yf();return{apiBaseUrl:e.baseUrl||gn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||Xf()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const Qf="chat-settings";function V0(){try{const e=localStorage.getItem(Qf);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function q0(e){try{localStorage.setItem(Qf,JSON.stringify(e)),e.apiKey&&gn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function K0(){const e=Zf(),t=V0(),n=gn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:gn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function G0(e){e.apiKey&&gn.setAuthToken(e.apiKey),q0(e)}var Y0="Label",eh=p.forwardRef((e,t)=>l.jsx(ye.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())}}));eh.displayName=Y0;var th=eh;const X0=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ht=p.forwardRef(({className:e,...t},n)=>l.jsx(th,{ref:n,className:X(X0(),e),...t}));Ht.displayName=th.displayName;function nh(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var xs="Switch",[J0,AC]=rn(xs),[Z0,Q0]=J0(xs),rh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[h,m]=p.useState(null),b=Me(t,y=>m(y)),v=p.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,w]=Ln({prop:o,defaultProp:s??!1,onChange:u,caller:xs});return l.jsxs(Z0,{scope:n,checked:x,disabled:a,children:[l.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":ah(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:b,onClick:ae(e.onClick,y=>{w(E=>!E),g&&(v.current=y.isPropagationStopped(),v.current||y.stopPropagation())})}),g&&l.jsx(ih,{control:h,bubbles:!v.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});rh.displayName=xs;var oh="SwitchThumb",sh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Q0(oh,n);return l.jsx(ye.span,{"data-state":ah(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});sh.displayName=oh;var eS="SwitchBubbleInput",ih=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Me(i,s),c=nh(n),u=xd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const b=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(b)}},[c,n,r]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ih.displayName=eS;function ah(e){return e?"checked":"unchecked"}var lh=rh,tS=sh;const En=p.forwardRef(({className:e,...t},n)=>l.jsx(lh,{className:X("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:l.jsx(tS,{className:X("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")})}));En.displayName=lh.displayName;var ch=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"}),nS="VisuallyHidden",rS=p.forwardRef((e,t)=>l.jsx(ye.span,{...e,ref:t,style:{...ch,...e.style}}));rS.displayName=nS;var oS=[" ","Enter","ArrowUp","ArrowDown"],sS=[" ","Enter"],Vn="Select",[vs,ws,iS]=Fi(Vn),[fr,_C]=rn(Vn,[iS,ss]),bs=ss(),[aS,In]=fr(Vn),[lS,cS]=fr(Vn),uh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:m,form:b}=e,v=bs(t),[g,x]=p.useState(null),[w,y]=p.useState(null),[E,S]=p.useState(!1),T=Yo(u),[I,N]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:Vn}),[A,j]=Ln({prop:i,defaultProp:a,onChange:c,caller:Vn}),_=p.useRef(null),z=g?b||!!g.closest("form"):!0,[V,O]=p.useState(new Set),G=Array.from(V).map(W=>W.props.value).join(";");return l.jsx(Id,{...v,children:l.jsxs(aS,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:w,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:on(),value:A,onValueChange:j,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:_,disabled:h,children:[l.jsx(vs.Provider,{scope:t,children:l.jsx(lS,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(W=>{O(q=>new Set(q).add(W))},[]),onNativeOptionRemove:p.useCallback(W=>{O(q=>{const L=new Set(q);return L.delete(W),L})},[]),children:n})}),z?l.jsxs(Oh,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:A,onChange:W=>j(W.target.value),disabled:h,form:b,children:[A===void 0?l.jsx("option",{value:""}):null,Array.from(V)]},G):null]})})};uh.displayName=Vn;var dh="SelectTrigger",fh=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=bs(n),i=In(dh,n),a=i.disabled||r,c=Me(t,i.onTriggerChange),u=ws(n),d=p.useRef("touch"),[f,h,m]=Dh(v=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),w=Lh(g,v,x);w!==void 0&&i.onValueChange(w.value)}),b=v=>{a||(i.onOpenChange(!0),m()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return l.jsx(Nd,{asChild:!0,...s,children:l.jsx(ye.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":Mh(i.value)?"":void 0,...o,ref:c,onClick:ae(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&b(v)}),onPointerDown:ae(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(b(v),v.preventDefault())}),onKeyDown:ae(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&oS.includes(v.key)&&(b(),v.preventDefault())})})})});fh.displayName=dh;var hh="SelectValue",ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=In(hh,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Me(t,c.onValueNodeChange);return ht(()=>{u(d)},[u,d]),l.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:Mh(c.value)?l.jsx(l.Fragment,{children:i}):s})});ph.displayName=hh;var uS="SelectIcon",mh=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});mh.displayName=uS;var dS="SelectPortal",gh=e=>l.jsx(Po,{asChild:!0,...e});gh.displayName=dS;var qn="SelectContent",xh=p.forwardRef((e,t)=>{const n=In(qn,e.__scopeSelect),[r,o]=p.useState();if(ht(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Gr.createPortal(l.jsx(vh,{scope:e.__scopeSelect,children:l.jsx(vs.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(wh,{...e,ref:t})});xh.displayName=qn;var Zt=10,[vh,Nn]=fr(qn),fS="SelectContentImpl",hS=An.createSlot("SelectContent.RemoveScroll"),wh=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:b,hideWhenDetached:v,avoidCollisions:g,...x}=e,w=In(qn,n),[y,E]=p.useState(null),[S,T]=p.useState(null),I=Me(t,$=>E($)),[N,A]=p.useState(null),[j,_]=p.useState(null),z=ws(n),[V,O]=p.useState(!1),G=p.useRef(!1);p.useEffect(()=>{if(y)return ji(y)},[y]),Ei();const W=p.useCallback($=>{const[P,...H]=z().map(ie=>ie.ref.current),[Q]=H.slice(-1),ce=document.activeElement;for(const ie of $)if(ie===ce||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===P&&S&&(S.scrollTop=0),ie===Q&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==ce))return},[z,S]),q=p.useCallback(()=>W([N,y]),[W,N,y]);p.useEffect(()=>{V&&q()},[V,q]);const{onOpenChange:L,triggerPointerDownPosRef:M}=w;p.useEffect(()=>{if(y){let $={x:0,y:0};const P=Q=>{var ce,ie;$={x:Math.abs(Math.round(Q.pageX)-(((ce=M.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ie=M.current)==null?void 0:ie.y)??0))}},H=Q=>{$.x<=10&&$.y<=10?Q.preventDefault():y.contains(Q.target)||L(!1),document.removeEventListener("pointermove",P),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",P),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",H,{capture:!0})}}},[y,L,M]),p.useEffect(()=>{const $=()=>L(!1);return window.addEventListener("blur",$),window.addEventListener("resize",$),()=>{window.removeEventListener("blur",$),window.removeEventListener("resize",$)}},[L]);const[le,J]=Dh($=>{const P=z().filter(ce=>!ce.disabled),H=P.find(ce=>ce.ref.current===document.activeElement),Q=Lh(P,$,H);Q&&setTimeout(()=>Q.ref.current.focus())}),ee=p.useCallback(($,P,H)=>{const Q=!G.current&&!H;(w.value!==void 0&&w.value===P||Q)&&(A($),Q&&(G.current=!0))},[w.value]),D=p.useCallback(()=>y==null?void 0:y.focus(),[y]),Z=p.useCallback(($,P,H)=>{const Q=!G.current&&!H;(w.value!==void 0&&w.value===P||Q)&&_($)},[w.value]),ke=r==="popper"?xa:bh,he=ke===xa?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:b,hideWhenDetached:v,avoidCollisions:g}:{};return l.jsx(vh,{scope:n,content:y,viewport:S,onViewportChange:T,itemRefCallback:ee,selectedItem:N,onItemLeave:D,itemTextRefCallback:Z,focusSelectedItem:q,selectedItemText:j,position:r,isPositioned:V,searchRef:le,children:l.jsx(Fo,{as:hS,allowPinchZoom:!0,children:l.jsx(jo,{asChild:!0,trapped:w.open,onMountAutoFocus:$=>{$.preventDefault()},onUnmountAutoFocus:ae(o,$=>{var P;(P=w.trigger)==null||P.focus({preventScroll:!0}),$.preventDefault()}),children:l.jsx(Ro,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:$=>$.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:l.jsx(ke,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:$=>$.preventDefault(),...x,...he,onPlaced:()=>O(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:ae(x.onKeyDown,$=>{const P=$.ctrlKey||$.altKey||$.metaKey;if($.key==="Tab"&&$.preventDefault(),!P&&$.key.length===1&&J($.key),["ArrowUp","ArrowDown","Home","End"].includes($.key)){let Q=z().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes($.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes($.key)){const ce=$.target,ie=Q.indexOf(ce);Q=Q.slice(ie+1)}setTimeout(()=>W(Q)),$.preventDefault()}})})})})})})});wh.displayName=fS;var pS="SelectItemAlignedPosition",bh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=In(qn,n),i=Nn(qn,n),[a,c]=p.useState(null),[u,d]=p.useState(null),f=Me(t,I=>d(I)),h=ws(n),m=p.useRef(!1),b=p.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:w}=i,y=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const ce=j.left-N.left,ie=A.left-ce,Fe=I.left-ie,$e=I.width+Fe,we=Math.max($e,N.width),Ne=window.innerWidth-Zt,Ue=da(ie,[Zt,Math.max(Zt,Ne-we)]);a.style.minWidth=$e+"px",a.style.left=Ue+"px"}else{const ce=N.right-j.right,ie=window.innerWidth-A.right-ce,Fe=window.innerWidth-I.right-ie,$e=I.width+Fe,we=Math.max($e,N.width),Ne=window.innerWidth-Zt,Ue=da(ie,[Zt,Math.max(Zt,Ne-we)]);a.style.minWidth=$e+"px",a.style.right=Ue+"px"}const _=h(),z=window.innerHeight-Zt*2,V=v.scrollHeight,O=window.getComputedStyle(u),G=parseInt(O.borderTopWidth,10),W=parseInt(O.paddingTop,10),q=parseInt(O.borderBottomWidth,10),L=parseInt(O.paddingBottom,10),M=G+W+V+L+q,le=Math.min(g.offsetHeight*5,M),J=window.getComputedStyle(v),ee=parseInt(J.paddingTop,10),D=parseInt(J.paddingBottom,10),Z=I.top+I.height/2-Zt,ke=z-Z,he=g.offsetHeight/2,$=g.offsetTop+he,P=G+W+$,H=M-P;if(P<=Z){const ce=_.length>0&&g===_[_.length-1].ref.current;a.style.bottom="0px";const ie=u.clientHeight-v.offsetTop-v.offsetHeight,Fe=Math.max(ke,he+(ce?D:0)+ie+q),$e=P+Fe;a.style.height=$e+"px"}else{const ce=_.length>0&&g===_[0].ref.current;a.style.top="0px";const Fe=Math.max(Z,G+v.offsetTop+(ce?ee:0)+he)+H;a.style.height=Fe+"px",v.scrollTop=P-Z+v.offsetTop}a.style.margin=`${Zt}px 0`,a.style.minHeight=le+"px",a.style.maxHeight=z+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);ht(()=>y(),[y]);const[E,S]=p.useState();ht(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const T=p.useCallback(I=>{I&&b.current===!0&&(y(),w==null||w(),b.current=!1)},[y,w]);return l.jsx(gS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:l.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});bh.displayName=pS;var mS="SelectPopperPosition",xa=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Zt,...s}=e,i=bs(n);return l.jsx(Ad,{...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)"}})});xa.displayName=mS;var[gS,va]=fr(qn,{}),wa="SelectViewport",yh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Nn(wa,n),i=va(wa,n),a=Me(t,s.onViewportChange),c=p.useRef(0);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(vs.Slot,{scope:n,children:l.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const b=window.innerHeight-Zt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<b){const w=x+m,y=Math.min(b,w),E=w-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});yh.displayName=wa;var Sh="SelectGroup",[xS,vS]=fr(Sh),wS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=on();return l.jsx(xS,{scope:n,id:o,children:l.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});wS.displayName=Sh;var Ch="SelectLabel",Th=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=vS(Ch,n);return l.jsx(ye.div,{id:o.id,...r,ref:t})});Th.displayName=Ch;var ys="SelectItem",[bS,kh]=fr(ys),Eh=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=In(ys,n),c=Nn(ys,n),u=a.value===r,[d,f]=p.useState(s??""),[h,m]=p.useState(!1),b=Me(t,w=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,w,r,o)}),v=on(),g=p.useRef("touch"),x=()=>{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 l.jsx(bS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:p.useCallback(w=>{f(y=>y||((w==null?void 0:w.textContent)??"").trim())},[]),children:l.jsx(vs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(ye.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:b,onFocus:ae(i.onFocus,()=>m(!0)),onBlur:ae(i.onBlur,()=>m(!1)),onClick:ae(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:ae(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:ae(i.onPointerDown,w=>{g.current=w.pointerType}),onPointerMove:ae(i.onPointerMove,w=>{var y;g.current=w.pointerType,o?(y=c.onItemLeave)==null||y.call(c):g.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,w=>{var y;w.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:ae(i.onKeyDown,w=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(sS.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})})})})});Eh.displayName=ys;var Hr="SelectItemText",Ih=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=In(Hr,n),a=Nn(Hr,n),c=kh(Hr,n),u=cS(Hr,n),[d,f]=p.useState(null),h=Me(t,x=>f(x),c.onItemTextChange,x=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,b=p.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return ht(()=>(v(b),()=>g(b)),[v,g,b]),l.jsxs(l.Fragment,{children:[l.jsx(ye.span,{id:c.textId,...s,ref:h}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Gr.createPortal(s.children,i.valueNode):null]})});Ih.displayName=Hr;var Nh="SelectItemIndicator",Ah=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return kh(Nh,n).isSelected?l.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});Ah.displayName=Nh;var ba="SelectScrollUpButton",_h=p.forwardRef((e,t)=>{const n=Nn(ba,e.__scopeSelect),r=va(ba,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return ht(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(jh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});_h.displayName=ba;var ya="SelectScrollDownButton",Rh=p.forwardRef((e,t)=>{const n=Nn(ya,e.__scopeSelect),r=va(ya,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return ht(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(jh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Rh.displayName=ya;var jh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Nn("SelectScrollButton",n),i=p.useRef(null),a=ws(n),c=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),ht(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),l.jsx(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{c()})})}),yS="SelectSeparator",Ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Ph.displayName=yS;var Sa="SelectArrow",SS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=bs(n),s=In(Sa,n),i=Nn(Sa,n);return s.open&&i.position==="popper"?l.jsx(_d,{...o,...r,ref:t}):null});SS.displayName=Sa;var CS="SelectBubbleInput",Oh=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Me(r,o),i=nh(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(ye.select,{...n,style:{...ch,...n.style},ref:s,defaultValue:t})});Oh.displayName=CS;function Mh(e){return e===""||e===void 0}function Dh(e){const t=pt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Lh(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=TS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function TS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kS=uh,$h=fh,ES=ph,IS=mh,NS=gh,Fh=xh,AS=yh,zh=Th,Bh=Eh,_S=Ih,RS=Ah,Hh=_h,Uh=Rh,Wh=Ph;const Vh=kS,qh=ES,Ca=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs($h,{ref:r,className:X("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,l.jsx(IS,{asChild:!0,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ca.displayName=$h.displayName;const Kh=p.forwardRef(({className:e,...t},n)=>l.jsx(Hh,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronUp,{className:"h-4 w-4"})}));Kh.displayName=Hh.displayName;const Gh=p.forwardRef(({className:e,...t},n)=>l.jsx(Uh,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4"})}));Gh.displayName=Uh.displayName;const Ta=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(NS,{children:l.jsxs(Fh,{ref:o,className:X("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:[l.jsx(Kh,{}),l.jsx(AS,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(Gh,{})]})}));Ta.displayName=Fh.displayName;const jS=p.forwardRef(({className:e,...t},n)=>l.jsx(zh,{ref:n,className:X("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jS.displayName=zh.displayName;const Kn=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Bh,{ref:r,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(RS,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),l.jsx(_S,{children:t})]}));Kn.displayName=Bh.displayName;const PS=p.forwardRef(({className:e,...t},n)=>l.jsx(Wh,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));PS.displayName=Wh.displayName;const Ss=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Ss.displayName="Card";const Cs=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("flex flex-col space-y-1.5 p-6",e),...t}));Cs.displayName="CardHeader";const Ts=p.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:X("text-2xl font-semibold leading-none tracking-tight",e),...t}));Ts.displayName="CardTitle";const OS=p.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:X("text-sm text-muted-foreground",e),...t}));OS.displayName="CardDescription";const ks=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("p-6 pt-0",e),...t}));ks.displayName="CardContent";const MS=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("flex items-center p-6 pt-0",e),...t}));MS.displayName="CardFooter";var DS="Separator",Yh="horizontal",LS=["horizontal","vertical"],Xh=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=Yh,...o}=e,s=$S(r)?r:Yh,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});Xh.displayName=DS;function $S(e){return LS.includes(e)}var Jh=Xh;const Zh=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(Jh,{ref:o,decorative:n,orientation:t,className:X("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Zh.displayName=Jh.displayName;const FS=Mu,zS=gw,BS=Du,Qh=p.forwardRef(({className:e,...t},n)=>l.jsx(Wo,{className:X("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}));Qh.displayName=Wo.displayName;const HS=Kr.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"}}),ep=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(BS,{children:[l.jsx(Qh,{}),l.jsxs(Vo,{ref:o,className:X(HS({side:e}),t),...r,children:[n,l.jsxs(Lu,{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:[l.jsx(oe.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ep.displayName=Vo.displayName;const tp=({className:e,...t})=>l.jsx("div",{className:X("flex flex-col space-y-2 text-center sm:text-left",e),...t});tp.displayName="SheetHeader";const np=p.forwardRef(({className:e,...t},n)=>l.jsx(zn,{ref:n,className:X("text-lg font-semibold text-foreground",e),...t}));np.displayName=zn.displayName;const rp=p.forwardRef(({className:e,...t},n)=>l.jsx(qo,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));rp.displayName=qo.displayName;const US={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 WS({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=C.useState(!1),[s,i]=C.useState(!1),[a,c]=C.useState(e),[u,d]=C.useState(!1),{toast:f}=yi();C.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),C.useEffect(()=>{c(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(US),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},b=()=>{c(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return l.jsxs(FS,{open:r,onOpenChange:o,children:[l.jsx(zS,{asChild:!0,children:l.jsxs(We,{variant:"outline",size:"sm",className:n,children:[l.jsx(oe.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(fi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(ep,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(tp,{children:[l.jsx(np,{children:"Chat Settings"}),l.jsx(rp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(Ss,{children:[l.jsx(Cs,{className:"pb-3",children:l.jsxs(Ts,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(ks,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Ht,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(fs,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(We,{variant:"outline",onClick:v,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Ht,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(En,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(Ht,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(fs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(We,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(oe.EyeOff,{className:"h-4 w-4"}):l.jsx(oe.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(Ss,{children:[l.jsx(Cs,{className:"pb-3",children:l.jsxs(Ts,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(ks,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Ht,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Vh,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(Ca,{children:l.jsx(qh,{})}),l.jsxs(Ta,{children:[l.jsx(Kn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Kn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Kn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(Ht,{htmlFor:"theme",children:"Theme"}),l.jsxs(Vh,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(Ca,{children:l.jsx(qh,{})}),l.jsxs(Ta,{children:[l.jsx(Kn,{value:"light",children:"Light"}),l.jsx(Kn,{value:"dark",children:"Dark"}),l.jsx(Kn,{value:"system",children:"System"})]})]})]}),l.jsx(Zh,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Ht,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(En,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Ht,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(En,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Ht,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(En,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(Ss,{children:[l.jsx(Cs,{className:"pb-3",children:l.jsxs(Ts,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(ks,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Ht,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(En,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Ht,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(En,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Ht,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(En,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(We,{variant:"outline",onClick:m,children:[l.jsx(oe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(We,{variant:"outline",onClick:b,children:"Cancel"}),l.jsxs(We,{onClick:h,disabled:!u,children:[l.jsx(oe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function VS({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),c=C.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(io,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(ds,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(io,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ga,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(ds,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(io,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ga,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(ds,{onError:s.onError,enableFileUpload:!0})})]})})}Ee.ChatApi=yl,Ee.ChatInterface=ds,Ee.ChatProvider=io,Ee.ChatSettings=WS,Ee.MarkdownContent=No,Ee.MessageComponent=qu,Ee.MessageList=$i,Ee.ThreadManager=ga,Ee.applySettings=G0,Ee.chatApiClient=gn,Ee.default=VS,Ee.del=bl,Ee.get=Nt,Ee.getChatToken=gl,Ee.getCurrentSettings=K0,Ee.getDefaultApiConfig=Jf,Ee.getDefaultChatSettings=Zf,Ee.onChatTokenChanged=xl,Ee.post=vl,Ee.put=wl,Ee.setChatToken=zs,Ee.useChat=ao,Ee.useChatStream=Sl,Ee.useMessagesReducer=Cl,Object.defineProperties(Ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED