teodor-new-chat-ui 1.5.12 → 1.5.13

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 CHANGED
@@ -5040,7 +5040,6 @@ function tn({
5040
5040
  className: e = "",
5041
5041
  placeholder: t = "Type your message...",
5042
5042
  autoFocus: n = !0,
5043
- // make maxHeight optional by default (undefined) so the messages area can flex to fill available space
5044
5043
  maxHeight: r = void 0,
5045
5044
  streamingDebounceMs: o = 40,
5046
5045
  enableFileUpload: a = !0,
@@ -5176,7 +5175,7 @@ function tn({
5176
5175
  u && (await x(k), T(k));
5177
5176
  }, ue = async () => {
5178
5177
  await C(), T(null);
5179
- }, re = `flex flex-col h-full ${e} ${c.container || ""}`, fe = `flex-1 overflow-y-auto p-4 space-y-4 ${c.messagesArea || ""}`, Se = `flex-shrink-0 border-t p-4 ${c.inputArea || ""}`;
5178
+ }, re = `flex flex-col h-full ${e} ${c.container || ""}`, fe = `flex-1 min-h-0 overflow-y-auto p-4 space-y-4 ${c.messagesArea || ""}`, Se = `flex-shrink-0 border-t p-4 ${c.inputArea || ""}`;
5180
5179
  return /* @__PURE__ */ S("div", { className: re, children: [
5181
5180
  !!w && !H && /* @__PURE__ */ S("div", { className: "bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between", children: [
5182
5181
  /* @__PURE__ */ s("span", { children: w }),
package/dist/index.umd.js CHANGED
@@ -50,7 +50,7 @@
50
50
  `)},Ss=function(){var e=parseInt(document.body.getAttribute(lt)||"0",10);return isFinite(e)?e:0},Ku=function(){l.useEffect(function(){return document.body.setAttribute(lt,(Ss()+1).toString()),function(){var e=Ss()-1;e<=0?document.body.removeAttribute(lt):document.body.setAttribute(lt,e.toString())}},[])},ju=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Ku();var a=l.useMemo(function(){return Hu(o)},[o]);return l.createElement(Vu,{styles:Gu(a,!t,o,n?"":"!important")})},yr=!1;if(typeof window<"u")try{var sn=Object.defineProperty({},"passive",{get:function(){return yr=!0,!0}});window.addEventListener("test",sn,sn),window.removeEventListener("test",sn,sn)}catch{yr=!1}var dt=yr?{passive:!1}:!1,Yu=function(e){return e.tagName==="TEXTAREA"},Cs=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Yu(e)&&n[t]==="visible")},Xu=function(e){return Cs(e,"overflowY")},qu=function(e){return Cs(e,"overflowX")},Ns=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Es(e,r);if(o){var a=Ts(e,r),i=a[1],c=a[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ju=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Zu=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Es=function(e,t){return e==="v"?Xu(t):qu(t)},Ts=function(e,t){return e==="v"?Ju(t):Zu(t)},Qu=function(e,t){return e==="h"&&t==="rtl"?-1:1},Ru=function(e,t,n,r,o){var a=Qu(e,window.getComputedStyle(t).direction),i=a*r,c=n.target,d=t.contains(c),f=!1,u=i>0,p=0,h=0;do{if(!c)break;var m=Ts(e,c),w=m[0],g=m[1],v=m[2],b=g-v-a*w;(w||b)&&Es(e,c)&&(p+=b,h+=w);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(u&&Math.abs(p)<1||!u&&Math.abs(h)<1)&&(f=!0),f},an=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},_s=function(e){return[e.deltaX,e.deltaY]},Is=function(e){return e&&"current"in e?e.current:e},ef=function(e,t){return e[0]===t[0]&&e[1]===t[1]},tf=function(e){return`
51
51
  .block-interactivity-`.concat(e,` {pointer-events: none;}
52
52
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
53
- `)},nf=0,ut=[];function rf(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),o=l.useState(nf++)[0],a=l.useState(xs)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Nu([e.lockRef.current],(e.shards||[]).map(Is),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(g,v){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var b=an(g),y=n.current,x="deltaX"in g?g.deltaX:y[0]-b[0],S="deltaY"in g?g.deltaY:y[1]-b[1],C,k=g.target,E=Math.abs(x)>Math.abs(S)?"h":"v";if("touches"in g&&E==="h"&&k.type==="range")return!1;var M=Ns(E,k);if(!M)return!0;if(M?C=E:(C=E==="v"?"h":"v",M=Ns(E,k)),!M)return!1;if(!r.current&&"changedTouches"in g&&(x||S)&&(r.current=C),!C)return!0;var L=r.current||C;return Ru(L,v,g,L==="h"?x:S)},[]),d=l.useCallback(function(g){var v=g;if(!(!ut.length||ut[ut.length-1]!==a)){var b="deltaY"in v?_s(v):an(v),y=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&ef(C.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var x=(i.current.shards||[]).map(Is).filter(Boolean).filter(function(C){return C.contains(v.target)}),S=x.length>0?c(v,x[0]):!i.current.noIsolation;S&&v.cancelable&&v.preventDefault()}}},[]),f=l.useCallback(function(g,v,b,y){var x={name:g,delta:v,target:b,should:y,shadowParent:of(b)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(S){return S!==x})},1)},[]),u=l.useCallback(function(g){n.current=an(g),r.current=void 0},[]),p=l.useCallback(function(g){f(g.type,_s(g),g.target,c(g,e.lockRef.current))},[]),h=l.useCallback(function(g){f(g.type,an(g),g.target,c(g,e.lockRef.current))},[]);l.useEffect(function(){return ut.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:h}),document.addEventListener("wheel",d,dt),document.addEventListener("touchmove",d,dt),document.addEventListener("touchstart",u,dt),function(){ut=ut.filter(function(g){return g!==a}),document.removeEventListener("wheel",d,dt),document.removeEventListener("touchmove",d,dt),document.removeEventListener("touchstart",u,dt)}},[]);var m=e.removeScrollBar,w=e.inert;return l.createElement(l.Fragment,null,w?l.createElement(a,{styles:tf(o)}):null,m?l.createElement(ju,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function of(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const sf=Du(ys,rf);var cn=l.forwardRef(function(e,t){return l.createElement(on,Be({},e,{ref:t,sideCar:sf}))});cn.classNames=on.classNames;var xr=["Enter"," "],af=["ArrowDown","PageUp","Home"],As=["ArrowUp","PageDown","End"],cf=[...af,...As],lf={ltr:[...xr,"ArrowRight"],rtl:[...xr,"ArrowLeft"]},df={ltr:["ArrowLeft"],rtl:["ArrowRight"]},_t="Menu",[It,uf,ff]=Gn(_t),[Je,Ps]=Ie(_t,[ff,it,us]),ln=it(),Ms=us(),[pf,Ze]=Je(_t),[hf,At]=Je(_t),ks=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,c=ln(t),[d,f]=l.useState(null),u=l.useRef(!1),p=me(a),h=Wt(o);return l.useEffect(()=>{const m=()=>{u.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>u.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),s.jsx(lr,{...c,children:s.jsx(pf,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:s.jsx(hf,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:h,modal:i,children:r})})})};ks.displayName=_t;var gf="MenuAnchor",Sr=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ln(n);return s.jsx(dr,{...o,...r,ref:t})});Sr.displayName=gf;var Cr="MenuPortal",[mf,Ds]=Je(Cr,{forceMount:void 0}),Os=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=Ze(Cr,t);return s.jsx(mf,{scope:t,forceMount:n,children:s.jsx(we,{present:n||a.open,children:s.jsx(Rt,{asChild:!0,container:o,children:r})})})};Os.displayName=Cr;var Ee="MenuContent",[vf,Nr]=Je(Ee),Ls=l.forwardRef((e,t)=>{const n=Ds(Ee,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Ze(Ee,e.__scopeMenu),i=At(Ee,e.__scopeMenu);return s.jsx(It.Provider,{scope:e.__scopeMenu,children:s.jsx(we,{present:r||a.open,children:s.jsx(It.Slot,{scope:e.__scopeMenu,children:i.modal?s.jsx(bf,{...o,ref:t}):s.jsx(wf,{...o,ref:t})})})})}),bf=l.forwardRef((e,t)=>{const n=Ze(Ee,e.__scopeMenu),r=l.useRef(null),o=se(t,r);return l.useEffect(()=>{const a=r.current;if(a)return mr(a)},[]),s.jsx(Er,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:F(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),wf=l.forwardRef((e,t)=>{const n=Ze(Ee,e.__scopeMenu);return s.jsx(Er,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),yf=xe.createSlot("MenuContent.ScrollLock"),Er=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:h,onDismiss:m,disableOutsideScroll:w,...g}=e,v=Ze(Ee,n),b=At(Ee,n),y=ln(n),x=Ms(n),S=uf(n),[C,k]=l.useState(null),E=l.useRef(null),M=se(t,E,v.onContentChange),L=l.useRef(0),O=l.useRef(""),B=l.useRef(0),H=l.useRef(null),G=l.useRef("right"),K=l.useRef(0),Z=w?cn:l.Fragment,z=w?{as:yf,allowPinchZoom:!0}:void 0,Y=A=>{var $,Q;const U=O.current+A,R=S().filter(ee=>!ee.disabled),re=document.activeElement,I=($=R.find(ee=>ee.ref.current===re))==null?void 0:$.textValue,P=R.map(ee=>ee.textValue),le=kf(P,U,I),ce=(Q=R.find(ee=>ee.textValue===le))==null?void 0:Q.ref.current;(function ee(J){O.current=J,window.clearTimeout(L.current),J!==""&&(L.current=window.setTimeout(()=>ee(""),1e3))})(U),ce&&setTimeout(()=>ce.focus())};l.useEffect(()=>()=>window.clearTimeout(L.current),[]),Yn();const _=l.useCallback(A=>{var R,re;return G.current===((R=H.current)==null?void 0:R.side)&&Of(A,(re=H.current)==null?void 0:re.area)},[]);return s.jsx(vf,{scope:n,searchRef:O,onItemEnter:l.useCallback(A=>{_(A)&&A.preventDefault()},[_]),onItemLeave:l.useCallback(A=>{var U;_(A)||((U=E.current)==null||U.focus(),k(null))},[_]),onTriggerLeave:l.useCallback(A=>{_(A)&&A.preventDefault()},[_]),pointerGraceTimerRef:B,onPointerGraceIntentChange:l.useCallback(A=>{H.current=A},[]),children:s.jsx(Z,{...z,children:s.jsx(Ht,{asChild:!0,trapped:o,onMountAutoFocus:F(a,A=>{var U;A.preventDefault(),(U=E.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:s.jsx(St,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:h,onDismiss:m,children:s.jsx(wu,{asChild:!0,...x,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:F(d,A=>{b.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(ur,{role:"menu","aria-orientation":"vertical","data-state":Qs(v.open),"data-radix-menu-content":"",dir:b.dir,...y,...g,ref:M,style:{outline:"none",...g.style},onKeyDown:F(g.onKeyDown,A=>{const R=A.target.closest("[data-radix-menu-content]")===A.currentTarget,re=A.ctrlKey||A.altKey||A.metaKey,I=A.key.length===1;R&&(A.key==="Tab"&&A.preventDefault(),!re&&I&&Y(A.key));const P=E.current;if(A.target!==P||!cf.includes(A.key))return;A.preventDefault();const ce=S().filter($=>!$.disabled).map($=>$.ref.current);As.includes(A.key)&&ce.reverse(),Pf(ce)}),onBlur:F(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(L.current),O.current="")}),onPointerMove:F(e.onPointerMove,Mt(A=>{const U=A.target,R=K.current!==A.clientX;if(A.currentTarget.contains(U)&&R){const re=A.clientX>K.current?"right":"left";G.current=re,K.current=A.clientX}}))})})})})})})});Ls.displayName=Ee;var xf="MenuGroup",Tr=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(X.div,{role:"group",...r,ref:t})});Tr.displayName=xf;var Sf="MenuLabel",$s=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(X.div,{...r,ref:t})});$s.displayName=Sf;var dn="MenuItem",Fs="menu.itemSelect",un=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,a=l.useRef(null),i=At(dn,e.__scopeMenu),c=Nr(dn,e.__scopeMenu),d=se(t,a),f=l.useRef(!1),u=()=>{const p=a.current;if(!n&&p){const h=new CustomEvent(Fs,{bubbles:!0,cancelable:!0});p.addEventListener(Fs,m=>r==null?void 0:r(m),{once:!0}),fo(p,h),h.defaultPrevented?f.current=!1:i.onClose()}};return s.jsx(Bs,{...o,ref:d,disabled:n,onClick:F(e.onClick,u),onPointerDown:p=>{var h;(h=e.onPointerDown)==null||h.call(e,p),f.current=!0},onPointerUp:F(e.onPointerUp,p=>{var h;f.current||(h=p.currentTarget)==null||h.click()}),onKeyDown:F(e.onKeyDown,p=>{const h=c.searchRef.current!=="";n||h&&p.key===" "||xr.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});un.displayName=dn;var Bs=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,i=Nr(dn,n),c=Ms(n),d=l.useRef(null),f=se(t,d),[u,p]=l.useState(!1),[h,m]=l.useState("");return l.useEffect(()=>{const w=d.current;w&&m((w.textContent??"").trim())},[a.children]),s.jsx(It.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:s.jsx(yu,{asChild:!0,...c,focusable:!r,children:s.jsx(X.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:f,onPointerMove:F(e.onPointerMove,Mt(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,Mt(w=>i.onItemLeave(w))),onFocus:F(e.onFocus,()=>p(!0)),onBlur:F(e.onBlur,()=>p(!1))})})})}),Cf="MenuCheckboxItem",Us=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(Gs,{scope:e.__scopeMenu,checked:n,children:s.jsx(un,{role:"menuitemcheckbox","aria-checked":fn(n)?"mixed":n,...o,ref:t,"data-state":Ir(n),onSelect:F(o.onSelect,()=>r==null?void 0:r(fn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Us.displayName=Cf;var zs="MenuRadioGroup",[Nf,Ef]=Je(zs,{value:void 0,onValueChange:()=>{}}),Ws=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,a=me(r);return s.jsx(Nf,{scope:e.__scopeMenu,value:n,onValueChange:a,children:s.jsx(Tr,{...o,ref:t})})});Ws.displayName=zs;var Hs="MenuRadioItem",Vs=l.forwardRef((e,t)=>{const{value:n,...r}=e,o=Ef(Hs,e.__scopeMenu),a=n===o.value;return s.jsx(Gs,{scope:e.__scopeMenu,checked:a,children:s.jsx(un,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":Ir(a),onSelect:F(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Vs.displayName=Hs;var _r="MenuItemIndicator",[Gs,Tf]=Je(_r,{checked:!1}),Ks=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,a=Tf(_r,n);return s.jsx(we,{present:r||fn(a.checked)||a.checked===!0,children:s.jsx(X.span,{...o,ref:t,"data-state":Ir(a.checked)})})});Ks.displayName=_r;var _f="MenuSeparator",js=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(X.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});js.displayName=_f;var If="MenuArrow",Ys=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ln(n);return s.jsx(fr,{...o,...r,ref:t})});Ys.displayName=If;var Af="MenuSub",[jg,Xs]=Je(Af),Pt="MenuSubTrigger",qs=l.forwardRef((e,t)=>{const n=Ze(Pt,e.__scopeMenu),r=At(Pt,e.__scopeMenu),o=Xs(Pt,e.__scopeMenu),a=Nr(Pt,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,f={__scopeMenu:e.__scopeMenu},u=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>u,[u]),l.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),s.jsx(Sr,{asChild:!0,...f,children:s.jsx(Bs,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Qs(n.open),...e,ref:zn(t,o.onTriggerChange),onClick:p=>{var h;(h=e.onClick)==null||h.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:F(e.onPointerMove,Mt(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:F(e.onPointerLeave,Mt(p=>{var m,w;u();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const g=(w=n.content)==null?void 0:w.dataset.side,v=g==="right",b=v?-5:5,y=h[v?"left":"right"],x=h[v?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x:y,y:h.top},{x,y:h.top},{x,y:h.bottom},{x:y,y:h.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:F(e.onKeyDown,p=>{var m;const h=a.searchRef.current!=="";e.disabled||h&&p.key===" "||lf[r.dir].includes(p.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),p.preventDefault())})})})});qs.displayName=Pt;var Js="MenuSubContent",Zs=l.forwardRef((e,t)=>{const n=Ds(Ee,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Ze(Ee,e.__scopeMenu),i=At(Ee,e.__scopeMenu),c=Xs(Js,e.__scopeMenu),d=l.useRef(null),f=se(t,d);return s.jsx(It.Provider,{scope:e.__scopeMenu,children:s.jsx(we,{present:r||a.open,children:s.jsx(It.Slot,{scope:e.__scopeMenu,children:s.jsx(Er,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:f,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var p;i.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:F(e.onFocusOutside,u=>{u.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:F(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:F(e.onKeyDown,u=>{var m;const p=u.currentTarget.contains(u.target),h=df[i.dir].includes(u.key);p&&h&&(a.onOpenChange(!1),(m=c.trigger)==null||m.focus(),u.preventDefault())})})})})})});Zs.displayName=Js;function Qs(e){return e?"open":"closed"}function fn(e){return e==="indeterminate"}function Ir(e){return fn(e)?"indeterminate":e?"checked":"unchecked"}function Pf(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Mf(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function kf(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=Mf(e,Math.max(a,0));o.length===1&&(i=i.filter(f=>f!==n));const d=i.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function Df(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],f=c.x,u=c.y,p=d.x,h=d.y;u>r!=h>r&&n<(p-f)*(r-u)/(h-u)+f&&(o=!o)}return o}function Of(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Df(n,t)}function Mt(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Lf=ks,$f=Sr,Ff=Os,Bf=Ls,Uf=Tr,zf=$s,Wf=un,Hf=Us,Vf=Ws,Gf=Vs,Kf=Ks,jf=js,Yf=Ys,Xf=qs,qf=Zs,pn="DropdownMenu",[Jf,Yg]=Ie(pn,[Ps]),ve=Ps(),[Zf,Rs]=Jf(pn),ea=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,d=ve(t),f=l.useRef(null),[u,p]=He({prop:o,defaultProp:a??!1,onChange:i,caller:pn});return s.jsx(Zf,{scope:t,triggerId:Ae(),triggerRef:f,contentId:Ae(),open:u,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(h=>!h),[p]),modal:c,children:s.jsx(Lf,{...d,open:u,onOpenChange:p,dir:r,modal:c,children:n})})};ea.displayName=pn;var ta="DropdownMenuTrigger",na=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=Rs(ta,n),i=ve(n);return s.jsx($f,{asChild:!0,...i,children:s.jsx(X.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:zn(t,a.triggerRef),onPointerDown:F(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:F(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});na.displayName=ta;var Qf="DropdownMenuPortal",ra=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ve(t);return s.jsx(Ff,{...r,...n})};ra.displayName=Qf;var oa="DropdownMenuContent",sa=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rs(oa,n),a=ve(n),i=l.useRef(!1);return s.jsx(Bf,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:F(e.onCloseAutoFocus,c=>{var d;i.current||(d=o.triggerRef.current)==null||d.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:F(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,u=d.button===2||f;(!o.modal||u)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sa.displayName=oa;var Rf="DropdownMenuGroup",ep=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Uf,{...o,...r,ref:t})});ep.displayName=Rf;var tp="DropdownMenuLabel",aa=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(zf,{...o,...r,ref:t})});aa.displayName=tp;var np="DropdownMenuItem",ia=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Wf,{...o,...r,ref:t})});ia.displayName=np;var rp="DropdownMenuCheckboxItem",ca=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Hf,{...o,...r,ref:t})});ca.displayName=rp;var op="DropdownMenuRadioGroup",sp=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Vf,{...o,...r,ref:t})});sp.displayName=op;var ap="DropdownMenuRadioItem",la=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Gf,{...o,...r,ref:t})});la.displayName=ap;var ip="DropdownMenuItemIndicator",da=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Kf,{...o,...r,ref:t})});da.displayName=ip;var cp="DropdownMenuSeparator",ua=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(jf,{...o,...r,ref:t})});ua.displayName=cp;var lp="DropdownMenuArrow",dp=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Yf,{...o,...r,ref:t})});dp.displayName=lp;var up="DropdownMenuSubTrigger",fa=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Xf,{...o,...r,ref:t})});fa.displayName=up;var fp="DropdownMenuSubContent",pa=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(qf,{...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)"}})});pa.displayName=fp;var pp=ea,hp=na,gp=ra,ha=sa,ga=aa,ma=ia,va=ca,ba=la,wa=da,ya=ua,xa=fa,Sa=pa;const mp=pp,vp=hp,bp=l.forwardRef(({className:e,inset:t,children:n,...r},o)=>s.jsxs(xa,{ref:o,className:T("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,s.jsx(W.ChevronRight,{className:"ml-auto h-4 w-4"})]}));bp.displayName=xa.displayName;const wp=l.forwardRef(({className:e,...t},n)=>s.jsx(Sa,{ref:n,className:T("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}));wp.displayName=Sa.displayName;const Ca=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(gp,{children:s.jsx(ha,{ref:r,sideOffset:t,className:T("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})}));Ca.displayName=ha.displayName;const Na=l.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(ma,{ref:r,className:T("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}));Na.displayName=ma.displayName;const yp=l.forwardRef(({className:e,children:t,checked:n,...r},o)=>s.jsxs(va,{ref:o,className:T("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:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(wa,{children:s.jsx(W.Check,{className:"h-4 w-4"})})}),t]}));yp.displayName=va.displayName;const xp=l.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(ba,{ref:r,className:T("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:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(wa,{children:s.jsx(W.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));xp.displayName=ba.displayName;const Sp=l.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(ga,{ref:r,className:T("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Sp.displayName=ga.displayName;const Cp=l.forwardRef(({className:e,...t},n)=>s.jsx(ya,{ref:n,className:T("-mx-1 my-1 h-px bg-muted",e),...t}));Cp.displayName=ya.displayName;function kt({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=40,enableFileUpload:a=!0,enableMessageEditing:i=!0,customStyles:c={},onMessageSent:d,onError:f}){const{currentThreadId:u,messages:p,isStreaming:h,streamingAssistantId:m,error:w,send:g,stop:v,lastCheckpointId:b,listCheckpoints:y,navigateToCheckpoint:x,returnToLatest:S}=Un(),[C,k]=N.useState(""),[E,M]=N.useState(null),[L,O]=N.useState(null),[B,H]=N.useState([]),[G,K]=N.useState(!1),[Z,z]=N.useState([]),[Y,_]=N.useState(null),A=N.useRef(null),U=N.useRef(null),R=N.useRef(null),[re,I]=N.useState("desktop");N.useEffect(()=>{const D=()=>{const q=window.innerWidth;I(q<640?"phone":q<1024?"tablet":"desktop")};return D(),window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]),N.useEffect(()=>{var D;(D=A.current)==null||D.scrollIntoView({behavior:"smooth"})},[p]),N.useEffect(()=>{var D;n&&((D=U.current)==null||D.focus())},[n]),N.useEffect(()=>{w&&!G&&(f==null||f(w))},[w,G,f]),N.useEffect(()=>{let D=!0;if(!u){z([]),_(null);return}return y(u).then(q=>{var ye;if(!D)return;const ne=q.checkpoints||[];z(ne);const de=((ye=ne.slice().sort((gt,be)=>new Date(be.createdAt).getTime()-new Date(gt.createdAt).getTime())[0])==null?void 0:ye.checkpointId)||null;_(gt=>gt??de)}).catch(()=>{}),()=>{D=!1}},[u,y]),N.useEffect(()=>{b&&_(b)},[b]);const P=D=>{if(D.length>nt)return`Message too long (${D.length}/${nt} characters)`;try{return _l(D),null}catch(q){return(q==null?void 0:q.message)||"Invalid message"}},le=D=>{const q=D.content||[],ne=q.filter(de=>de.type==="text").map(de=>de.text).join("");if(ne)return ne;try{return JSON.stringify(q,null,2)}catch{return String(q)}},ce=D=>{var gt;if(!Z.length)return[];const ne=(((gt=p[D])==null?void 0:gt.role)??"user")==="user",de=ne?D+2:D+1;return Z.filter(be=>(be.messagesLen??-1)>=(ne?de:0)).filter(be=>ne?(be.messagesLen??0)>=de:(be.messagesLen??0)===de).map(be=>({checkpoint_id:be.checkpointId,checkpoint_ns:be.checkpointNs,message_count:be.messagesLen??0,last_message_preview:be.preview??void 0,ts:new Date(be.createdAt).getTime(),isCurrent:be.checkpointId===Y})).sort((be,Hg)=>(be.ts||0)-(Hg.ts||0))},$=D=>{if(D===void 0)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:0};const q=ce(D);if(q.length<=1)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:q.length};const ne=Math.max(0,q.findIndex(de=>de.isCurrent));return{canGoBack:ne>0,canGoForward:ne<q.length-1,currentIndex:ne,totalBranches:q.length}},Q=async()=>{const D=C.trim();if(!D&&B.length===0)return;const q=P(D);if(q){O(q);return}try{const ne=window.__editingCheckpointId||Y||void 0;await g(D,{checkpointId:ne,payloadExtras:E?{edit:!0,originalMessageId:E}:void 0,attachments:B}),d==null||d(D),k(""),O(null),H([]),delete window.__editingCheckpointId,M(null),U.current&&(U.current.style.height="auto")}catch(ne){const de=(ne==null?void 0:ne.message)||"Failed to send message";O(de),f==null||f(de)}},ee=(D,q)=>{i&&(M(D),k(q),O(null),setTimeout(()=>{U.current&&(U.current.focus(),U.current.style.height="auto",U.current.style.height=U.current.scrollHeight+"px")},0))},J=async(D,q)=>{const ne=p.find(ye=>ye.id===D);if(!ne){O("Message not found");return}const de=le(ne);M(D),k(de),window.__editingCheckpointId=q,setTimeout(()=>{var ye;return(ye=U.current)==null?void 0:ye.focus()},0)},te=()=>{M(null),k(""),O(null),delete window.__editingCheckpointId,U.current&&(U.current.style.height="auto")},ie=D=>{D.key==="Enter"&&!D.shiftKey?(D.preventDefault(),Q()):D.key==="Escape"&&E&&(D.preventDefault(),te())},he=D=>{const q=Array.from(D.target.files||[]);H(ne=>[...ne,...q])},j=D=>H(q=>q.filter((ne,de)=>D!==de)),V=async D=>{u&&(await x(D),_(D))},fe=async()=>{await S(),_(null)},oe=`flex flex-col h-full ${e} ${c.container||""}`,pe=`flex-1 overflow-y-auto p-4 space-y-4 ${c.messagesArea||""}`,Ne=`flex-shrink-0 border-t p-4 ${c.inputArea||""}`;return s.jsxs("div",{className:oe,children:[!!w&&!G&&s.jsxs("div",{className:"bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[s.jsx("span",{children:w}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>K(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:s.jsx(W.X,{size:16})})]}),u&&Z.length>0&&s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b bg-background/50 text-xs",children:[s.jsx(W.GitBranch,{className:"h-4 w-4 opacity-70"}),s.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),s.jsxs("select",{className:"border rounded px-2 py-1 text-xs",value:Y??"",onChange:D=>{const q=D.target.value||null;q?V(q):fe()},children:[s.jsx("option",{value:"",children:"Latest"}),Z.slice().sort((D,q)=>new Date(q.createdAt).getTime()-new Date(D.createdAt).getTime()).map(D=>s.jsxs("option",{value:D.checkpointId,children:[new Date(D.createdAt).toLocaleString(),D.preview?` — ${D.preview.slice(0,30)}`:""]},D.checkpointId))]})]}),s.jsxs("div",{className:pe,style:r?{maxHeight:r}:void 0,children:[p.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:"No messages yet. Start a conversation!"}):p.map((D,q)=>s.jsx(bo,{message:D,messageIndex:q,isStreamingMessage:h&&m===D.id,streamingDebounceMs:o,isEditing:E===D.id,showActions:i,showTimestamp:!1,showAgentName:!0,layoutSize:re,truncateToolMessages:!1,toolMessagePreviewLength:200,checkpointBranches:ce(q),currentCheckpointId:Y??void 0,temporalNavigation:$(q),onSwitchToCheckpoint:V,onReturnToMainThread:fe,onNavigateToPreviousBranch:()=>{const ne=ce(q),de=Math.max(0,ne.findIndex(ye=>ye.isCurrent));de>0&&V(ne[de-1].checkpoint_id)},onNavigateToNextBranch:()=>{const ne=ce(q),de=Math.max(0,ne.findIndex(ye=>ye.isCurrent));de>=0&&de<ne.length-1&&V(ne[de+1].checkpoint_id)},onEdit:(ne,de)=>ee(ne,de),onEditFromCheckpoint:J,onRegenerate:()=>{const ne=[...p].reverse().find(ye=>ye.role==="user"),de=ne?le(ne):"";de&&g(de,{checkpointId:Y??void 0})},onCancelEdit:te},D.id||q)),s.jsx("div",{ref:A})]}),s.jsxs("div",{className:Ne,children:[E&&s.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(W.Edit3,{size:16,className:"text-blue-600"}),s.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:te,className:"text-blue-600 hover:bg-blue-100",children:s.jsx(W.X,{size:16})})]})}),a&&s.jsxs("div",{className:"mb-3",children:[s.jsx("input",{ref:R,type:"file",multiple:!0,onChange:D=>he(D),className:"hidden"}),B.length>0&&s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:B.map((D,q)=>s.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2 text-sm",children:[s.jsx(W.Paperclip,{size:14}),s.jsx("span",{className:"truncate max-w-[150px]",children:D.name}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>j(q),className:"h-4 w-4 p-0 text-gray-500 hover:text-red-500","aria-label":`Remove ${D.name}`,children:s.jsx(W.X,{size:12})})]},q))})]}),L&&s.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:L}),s.jsxs("div",{className:"flex items-end gap-2",children:[a&&s.jsxs(mp,{children:[s.jsx(vp,{asChild:!0,children:s.jsx(ue,{type:"button",size:"icon",variant:"outline",disabled:h,title:"More input actions",children:s.jsx(W.Plus,{size:16})})}),s.jsx(Ca,{align:"start",sideOffset:6,className:"w-52",children:s.jsxs(Na,{onClick:()=>{var D;return(D=R.current)==null?void 0:D.click()},className:"cursor-pointer",children:[s.jsx(W.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]})})]}),s.jsx("div",{className:"flex-1",children:s.jsx(co,{ref:U,value:C,onChange:D=>{k(D.target.value),O(null),U.current&&(U.current.style.height="auto",U.current.style.height=`${U.current.scrollHeight}px`)},onKeyDown:ie,placeholder:E?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full ${E?"border-blue-400 bg-blue-50":""} ${L?"border-red-400":""}`,disabled:!1,maxLength:nt,rows:1})}),s.jsx("div",{children:h?s.jsx(ue,{type:"button",onClick:v,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:s.jsx(W.Square,{size:16})}):s.jsx(ue,{type:"button",onClick:Q,size:"icon",disabled:!C.trim()&&B.length===0,className:`shrink-0 ${c.sendButton||""}`,title:E?"Save changes":"Send message",children:s.jsx(W.Send,{size:16})})})]}),C.length>nt*.8&&s.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[C.length,"/",nt]})]})]})}const Dt=l.forwardRef(({className:e,type:t,...n},r)=>s.jsx("input",{type:t,className:T("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}));Dt.displayName="Input";function Ar(e,[t,n]){return Math.min(n,Math.max(t,e))}function Np(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Pr="ScrollArea",[Ea,Xg]=Ie(Pr),[Ep,Te]=Ea(Pr),Ta=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[f,u]=l.useState(null),[p,h]=l.useState(null),[m,w]=l.useState(null),[g,v]=l.useState(null),[b,y]=l.useState(0),[x,S]=l.useState(0),[C,k]=l.useState(!1),[E,M]=l.useState(!1),L=se(t,B=>d(B)),O=Wt(o);return s.jsx(Ep,{scope:n,type:r,dir:O,scrollHideDelay:a,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:h,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:E,onScrollbarYEnabledChange:M,onCornerWidthChange:y,onCornerHeightChange:S,children:s.jsx(X.div,{dir:O,...i,ref:L,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});Ta.displayName=Pr;var _a="ScrollAreaViewport",Ia=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...a}=e,i=Te(_a,n),c=l.useRef(null),d=se(t,c,i.onViewportChange);return s.jsxs(s.Fragment,{children:[s.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}),s.jsx(X.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Ia.displayName=_a;var Ue="ScrollAreaScrollbar",Mr=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Te(Ue,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),o.type==="hover"?s.jsx(Tp,{...r,ref:t,forceMount:n}):o.type==="scroll"?s.jsx(_p,{...r,ref:t,forceMount:n}):o.type==="auto"?s.jsx(Aa,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(kr,{...r,ref:t}):null});Mr.displayName=Ue;var Tp=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Te(Ue,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const f=()=>{window.clearTimeout(d),i(!0)},u=()=>{d=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),s.jsx(we,{present:n||a,children:s.jsx(Aa,{"data-state":a?"visible":"hidden",...r,ref:t})})}),_p=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Te(Ue,e.__scopeScrollArea),a=e.orientation==="horizontal",i=vn(()=>d("SCROLL_END"),100),[c,d]=Np("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 l.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const f=o.viewport,u=a?"scrollLeft":"scrollTop";if(f){let p=f[u];const h=()=>{const m=f[u];p!==m&&(d("SCROLL"),i()),p=m};return f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[o.viewport,a,d,i]),s.jsx(we,{present:n||c!=="hidden",children:s.jsx(kr,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:F(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:F(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Aa=l.forwardRef((e,t)=>{const n=Te(Ue,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=vn(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(c?f:u)}},10);return ft(n.viewport,d),ft(n.content,d),s.jsx(we,{present:r||a,children:s.jsx(kr,{"data-state":a?"visible":"hidden",...o,ref:t})})}),kr=l.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Te(Ue,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=Oa(c.viewport,c.content),u={...r,sizes:c,onSizesChange:d,hasThumb:f>0&&f<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function p(h,m){return Dp(h,i.current,c,m)}return n==="horizontal"?s.jsx(Ip,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,m=La(h,c,o.dir);a.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=p(h,o.dir))}}):n==="vertical"?s.jsx(Ap,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,m=La(h,c);a.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=p(h))}}):null}),Ip=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=Te(Ue,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),f=se(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),s.jsx(Ma,{"data-orientation":"horizontal",...o,ref:f,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":mn(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(a.viewport){const h=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),Fa(h,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:gn(i.paddingLeft),paddingEnd:gn(i.paddingRight)}})}})}),Ap=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=Te(Ue,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),f=se(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),s.jsx(Ma,{"data-orientation":"vertical",...o,ref:f,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":mn(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(a.viewport){const h=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),Fa(h,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:gn(i.paddingTop),paddingEnd:gn(i.paddingBottom)}})}})}),[Pp,Pa]=Ea(Ue),Ma=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:f,onWheelScroll:u,onResize:p,...h}=e,m=Te(Ue,n),[w,g]=l.useState(null),v=se(t,L=>g(L)),b=l.useRef(null),y=l.useRef(""),x=m.viewport,S=r.content-r.viewport,C=me(u),k=me(d),E=vn(p,10);function M(L){if(b.current){const O=L.clientX-b.current.left,B=L.clientY-b.current.top;f({x:O,y:B})}}return l.useEffect(()=>{const L=O=>{const B=O.target;(w==null?void 0:w.contains(B))&&C(O,S)};return document.addEventListener("wheel",L,{passive:!1}),()=>document.removeEventListener("wheel",L,{passive:!1})},[x,w,S,C]),l.useEffect(k,[r,k]),ft(w,E),ft(m.content,E),s.jsx(Pp,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:me(a),onThumbPointerUp:me(i),onThumbPositionChange:k,onThumbPointerDown:me(c),children:s.jsx(X.div,{...h,ref:v,style:{position:"absolute",...h.style},onPointerDown:F(e.onPointerDown,L=>{L.button===0&&(L.target.setPointerCapture(L.pointerId),b.current=w.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),M(L))}),onPointerMove:F(e.onPointerMove,M),onPointerUp:F(e.onPointerUp,L=>{const O=L.target;O.hasPointerCapture(L.pointerId)&&O.releasePointerCapture(L.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=""),b.current=null})})})}),hn="ScrollAreaThumb",ka=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Pa(hn,e.__scopeScrollArea);return s.jsx(we,{present:n||o.hasThumb,children:s.jsx(Mp,{ref:t,...r})})}),Mp=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,a=Te(hn,n),i=Pa(hn,n),{onThumbPositionChange:c}=i,d=se(t,p=>i.onThumbChange(p)),f=l.useRef(void 0),u=vn(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{const p=a.viewport;if(p){const h=()=>{if(u(),!f.current){const m=Op(p,c);f.current=m,c()}};return c(),p.addEventListener("scroll",h),()=>p.removeEventListener("scroll",h)}},[a.viewport,u,c]),s.jsx(X.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:F(e.onPointerDownCapture,p=>{const m=p.target.getBoundingClientRect(),w=p.clientX-m.left,g=p.clientY-m.top;i.onThumbPointerDown({x:w,y:g})}),onPointerUp:F(e.onPointerUp,i.onThumbPointerUp)})});ka.displayName=hn;var Dr="ScrollAreaCorner",Da=l.forwardRef((e,t)=>{const n=Te(Dr,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(kp,{...e,ref:t}):null});Da.displayName=Dr;var kp=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Te(Dr,n),[a,i]=l.useState(0),[c,d]=l.useState(0),f=!!(a&&c);return ft(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),d(u)}),ft(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),f?s.jsx(X.div,{...r,ref:t,style:{width:a,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function gn(e){return e?parseInt(e,10):0}function Oa(e,t){const n=e/t;return isNaN(n)?0:n}function mn(e){const t=Oa(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Dp(e,t,n,r="ltr"){const o=mn(n),a=o/2,i=t||a,c=o-i,d=n.scrollbar.paddingStart+i,f=n.scrollbar.size-n.scrollbar.paddingEnd-c,u=n.content-n.viewport,p=r==="ltr"?[0,u]:[u*-1,0];return $a([d,f],p)(e)}function La(e,t,n="ltr"){const r=mn(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,i=t.content-t.viewport,c=a-r,d=n==="ltr"?[0,i]:[i*-1,0],f=Ar(e,d);return $a([0,i],[0,c])(f)}function $a(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 Fa(e,t){return e>0&&e<t}var Op=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,c=n.top!==a.top;(i||c)&&t(),n=a,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function vn(e,t){const n=me(e),r=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),l.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ft(e,t){const n=me(t);ge(()=>{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 Ba=Ta,Lp=Ia,$p=Da;const Ua=l.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(Ba,{ref:r,className:T("relative overflow-hidden",e),...n,children:[s.jsx(Lp,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),s.jsx(za,{}),s.jsx($p,{})]}));Ua.displayName=Ba.displayName;const za=l.forwardRef(({className:e,orientation:t="vertical",...n},r)=>s.jsx(Mr,{ref:r,orientation:t,className:T("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:s.jsx(ka,{className:"relative flex-1 rounded-full bg-border"})}));za.displayName=Mr.displayName;function bn({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:a={},currentThreadId:i=null,navigateToThread:c,onThreadSelect:d,onThreadCreate:f,onThreadDelete:u}){const{loadThread:p,threads:h,refreshThreads:m,currentThreadId:w,createThread:g,deleteThread:v,renameThread:b}=Un(),[y,x]=N.useState(h??[]),[S,C]=N.useState(!1),[k,E]=N.useState(null),[M,L]=N.useState(null),[O,B]=N.useState(""),[H,G]=N.useState(!1);N.useEffect(()=>{x(h??[])},[h]);const K=async I=>{try{await p(I),c==null||c(I),d==null||d(I)}catch(P){console.error("Failed to select thread:",P)}},Z=async()=>{try{G(!0);const I=await g();f==null||f(I),c==null||c(I)}catch(I){console.error("Failed to create thread:",I)}finally{G(!1)}},z=async(I,P)=>{if(P.stopPropagation(),!!confirm("Delete this thread?"))try{await v(I),u==null||u(I)}catch(le){console.error("Failed to delete thread:",le)}},Y=(I,P)=>{P.stopPropagation(),L(I.threadId),B(I.title||`Thread ${I.threadId.slice(0,8)}`)},_=async I=>{if(O.trim())try{await b(I,O.trim()),L(null),B("")}catch(P){console.error("Failed to update title:",P)}},A=()=>{L(null),B("")},U=(I,P)=>{I.key==="Enter"?_(P):I.key==="Escape"&&A()},R=I=>{if(!I)return"";try{const P=new Date(I),ce=new Date().getTime()-P.getTime(),$=Math.floor(ce/(1e3*60*60*24));return $===0?P.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):$===1?"Yesterday":$<7?`${$} days ago`:P.toLocaleDateString()}catch{return""}},re=I=>I.title||`Thread ${I.threadId.slice(0,8)}`;return s.jsxs("div",{className:`flex flex-col h-full ${e} ${a.container||""}`,children:[t&&s.jsx("div",{className:a.header||"flex-shrink-0 p-4 border-b bg-slate-800 border-slate-700 text-slate-100",children:s.jsxs(ue,{onClick:Z,disabled:H||S,className:a.createButton||"w-full !bg-slate-700 hover:!bg-slate-600 !text-slate-100 !border-slate-600",size:"sm",children:[s.jsx(W.Plus,{size:16,className:"mr-2"}),H?"Creating...":"New Conversation"]})}),s.jsx(Ua,{className:`flex-1 ${a.threadList||""}`,style:{maxHeight:o},children:s.jsx("div",{className:"p-2 space-y-1 pb-4",children:S?s.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):y.length===0?s.jsxs("div",{className:"text-center py-8 text-slate-400",children:[s.jsx(W.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),s.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):y.slice().sort((I,P)=>new Date(P.updatedAt||P.createdAt||"").getTime()-new Date(I.updatedAt||I.createdAt||"").getTime()).map(I=>s.jsxs("div",{onClick:()=>K(I.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??w)===I.threadId?`${a.activeThread||"bg-slate-600 border-slate-500"} `:`${a.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600"}`} ${a.threadItem||""} text-slate-100`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"flex-1 min-w-0",children:M===I.threadId?s.jsxs("div",{className:"flex items-center gap-2",onClick:P=>P.stopPropagation(),children:[s.jsx(Dt,{value:O,onChange:P=>B(P.target.value),onKeyDown:P=>U(P,I.threadId),className:"h-6 text-sm",autoFocus:!0}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>_(I.threadId),className:"h-6 w-6 p-0",children:s.jsx(W.Check,{size:12})}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:A,className:"h-6 w-6 p-0",children:s.jsx(W.X,{size:12})})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"font-medium text-sm truncate text-slate-100",children:re(I)}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400 mt-1",children:[s.jsx(W.Calendar,{size:10}),s.jsx("span",{children:R(I.updatedAt||I.createdAt)})]})]})}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&M!==I.threadId&&s.jsx(ue,{variant:"ghost",size:"sm",onClick:P=>Y(I,P),className:"h-6 w-6 p-0",title:"Edit title",children:s.jsx(W.Edit3,{size:12})}),n&&s.jsx(ue,{variant:"ghost",size:"sm",onClick:P=>z(I.threadId,P),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:s.jsx(W.Trash2,{size:12})})]})]}),i===I.threadId&&s.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},I.threadId))})})]})}const Wa=N.createContext(null);function Fp({children:e,basePath:t="/chat"}){const n=N.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return s.jsx(Wa.Provider,{value:r,children:e})}function Bp(){const e=N.useContext(Wa);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const Or=768;function Up(){const[e,t]=l.useState(void 0);return l.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Or-1}px)`),r=()=>{t(window.innerWidth<Or)};return n.addEventListener("change",r),t(window.innerWidth<Or),()=>n.removeEventListener("change",r)},[]),!!e}var zp="Separator",Ha="horizontal",Wp=["horizontal","vertical"],Va=l.forwardRef((e,t)=>{const{decorative:n,orientation:r=Ha,...o}=e,a=Hp(r)?r:Ha,c=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return s.jsx(X.div,{"data-orientation":a,...c,...o,ref:t})});Va.displayName=zp;function Hp(e){return Wp.includes(e)}var Ga=Va;const Lr=l.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>s.jsx(Ga,{ref:o,decorative:n,orientation:t,className:T("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Lr.displayName=Ga.displayName;var wn="Dialog",[Ka,qg]=Ie(wn),[Vp,ke]=Ka(wn),ja=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[f,u]=He({prop:r,defaultProp:o??!1,onChange:a,caller:wn});return s.jsx(Vp,{scope:t,triggerRef:c,contentRef:d,contentId:Ae(),titleId:Ae(),descriptionId:Ae(),open:f,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:i,children:n})};ja.displayName=wn;var Ya="DialogTrigger",Xa=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(Ya,n),a=se(t,o.triggerRef);return s.jsx(X.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Br(o.open),...r,ref:a,onClick:F(e.onClick,o.onOpenToggle)})});Xa.displayName=Ya;var $r="DialogPortal",[Gp,qa]=Ka($r,{forceMount:void 0}),Ja=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=ke($r,t);return s.jsx(Gp,{scope:t,forceMount:n,children:l.Children.map(r,i=>s.jsx(we,{present:n||a.open,children:s.jsx(Rt,{asChild:!0,container:o,children:i})}))})};Ja.displayName=$r;var yn="DialogOverlay",Za=l.forwardRef((e,t)=>{const n=qa(yn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ke(yn,e.__scopeDialog);return a.modal?s.jsx(we,{present:r||a.open,children:s.jsx(jp,{...o,ref:t})}):null});Za.displayName=yn;var Kp=xe.createSlot("DialogOverlay.RemoveScroll"),jp=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(yn,n);return s.jsx(cn,{as:Kp,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(X.div,{"data-state":Br(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Qe="DialogContent",Qa=l.forwardRef((e,t)=>{const n=qa(Qe,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ke(Qe,e.__scopeDialog);return s.jsx(we,{present:r||a.open,children:a.modal?s.jsx(Yp,{...o,ref:t}):s.jsx(Xp,{...o,ref:t})})});Qa.displayName=Qe;var Yp=l.forwardRef((e,t)=>{const n=ke(Qe,e.__scopeDialog),r=l.useRef(null),o=se(t,n.contentRef,r);return l.useEffect(()=>{const a=r.current;if(a)return mr(a)},[]),s.jsx(Ra,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:F(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:F(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:F(e.onFocusOutside,a=>a.preventDefault())})}),Xp=l.forwardRef((e,t)=>{const n=ke(Qe,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return s.jsx(Ra,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,c;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((f=n.triggerRef.current)==null?void 0:f.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Ra=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=ke(Qe,n),d=l.useRef(null),f=se(t,d);return Yn(),s.jsxs(s.Fragment,{children:[s.jsx(Ht,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(St,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Br(c.open),...i,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(qp,{titleId:c.titleId}),s.jsx(Zp,{contentRef:d,descriptionId:c.descriptionId})]})]})}),Fr="DialogTitle",ei=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(Fr,n);return s.jsx(X.h2,{id:o.titleId,...r,ref:t})});ei.displayName=Fr;var ti="DialogDescription",ni=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(ti,n);return s.jsx(X.p,{id:o.descriptionId,...r,ref:t})});ni.displayName=ti;var ri="DialogClose",oi=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(ri,n);return s.jsx(X.button,{type:"button",...r,ref:t,onClick:F(e.onClick,()=>o.onOpenChange(!1))})});oi.displayName=ri;function Br(e){return e?"open":"closed"}var si="DialogTitleWarning",[Jg,ai]=Rc(si,{contentName:Qe,titleName:Fr,docsSlug:"dialog"}),qp=({titleId:e})=>{const t=ai(si),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
53
+ `)},nf=0,ut=[];function rf(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),o=l.useState(nf++)[0],a=l.useState(xs)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Nu([e.lockRef.current],(e.shards||[]).map(Is),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(g,v){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var b=an(g),y=n.current,x="deltaX"in g?g.deltaX:y[0]-b[0],S="deltaY"in g?g.deltaY:y[1]-b[1],C,k=g.target,E=Math.abs(x)>Math.abs(S)?"h":"v";if("touches"in g&&E==="h"&&k.type==="range")return!1;var M=Ns(E,k);if(!M)return!0;if(M?C=E:(C=E==="v"?"h":"v",M=Ns(E,k)),!M)return!1;if(!r.current&&"changedTouches"in g&&(x||S)&&(r.current=C),!C)return!0;var L=r.current||C;return Ru(L,v,g,L==="h"?x:S)},[]),d=l.useCallback(function(g){var v=g;if(!(!ut.length||ut[ut.length-1]!==a)){var b="deltaY"in v?_s(v):an(v),y=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&ef(C.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var x=(i.current.shards||[]).map(Is).filter(Boolean).filter(function(C){return C.contains(v.target)}),S=x.length>0?c(v,x[0]):!i.current.noIsolation;S&&v.cancelable&&v.preventDefault()}}},[]),f=l.useCallback(function(g,v,b,y){var x={name:g,delta:v,target:b,should:y,shadowParent:of(b)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(S){return S!==x})},1)},[]),u=l.useCallback(function(g){n.current=an(g),r.current=void 0},[]),p=l.useCallback(function(g){f(g.type,_s(g),g.target,c(g,e.lockRef.current))},[]),h=l.useCallback(function(g){f(g.type,an(g),g.target,c(g,e.lockRef.current))},[]);l.useEffect(function(){return ut.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:h}),document.addEventListener("wheel",d,dt),document.addEventListener("touchmove",d,dt),document.addEventListener("touchstart",u,dt),function(){ut=ut.filter(function(g){return g!==a}),document.removeEventListener("wheel",d,dt),document.removeEventListener("touchmove",d,dt),document.removeEventListener("touchstart",u,dt)}},[]);var m=e.removeScrollBar,w=e.inert;return l.createElement(l.Fragment,null,w?l.createElement(a,{styles:tf(o)}):null,m?l.createElement(ju,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function of(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const sf=Du(ys,rf);var cn=l.forwardRef(function(e,t){return l.createElement(on,Be({},e,{ref:t,sideCar:sf}))});cn.classNames=on.classNames;var xr=["Enter"," "],af=["ArrowDown","PageUp","Home"],As=["ArrowUp","PageDown","End"],cf=[...af,...As],lf={ltr:[...xr,"ArrowRight"],rtl:[...xr,"ArrowLeft"]},df={ltr:["ArrowLeft"],rtl:["ArrowRight"]},_t="Menu",[It,uf,ff]=Gn(_t),[Je,Ps]=Ie(_t,[ff,it,us]),ln=it(),Ms=us(),[pf,Ze]=Je(_t),[hf,At]=Je(_t),ks=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,c=ln(t),[d,f]=l.useState(null),u=l.useRef(!1),p=me(a),h=Wt(o);return l.useEffect(()=>{const m=()=>{u.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>u.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),s.jsx(lr,{...c,children:s.jsx(pf,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:s.jsx(hf,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:h,modal:i,children:r})})})};ks.displayName=_t;var gf="MenuAnchor",Sr=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ln(n);return s.jsx(dr,{...o,...r,ref:t})});Sr.displayName=gf;var Cr="MenuPortal",[mf,Ds]=Je(Cr,{forceMount:void 0}),Os=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=Ze(Cr,t);return s.jsx(mf,{scope:t,forceMount:n,children:s.jsx(we,{present:n||a.open,children:s.jsx(Rt,{asChild:!0,container:o,children:r})})})};Os.displayName=Cr;var Ee="MenuContent",[vf,Nr]=Je(Ee),Ls=l.forwardRef((e,t)=>{const n=Ds(Ee,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Ze(Ee,e.__scopeMenu),i=At(Ee,e.__scopeMenu);return s.jsx(It.Provider,{scope:e.__scopeMenu,children:s.jsx(we,{present:r||a.open,children:s.jsx(It.Slot,{scope:e.__scopeMenu,children:i.modal?s.jsx(bf,{...o,ref:t}):s.jsx(wf,{...o,ref:t})})})})}),bf=l.forwardRef((e,t)=>{const n=Ze(Ee,e.__scopeMenu),r=l.useRef(null),o=se(t,r);return l.useEffect(()=>{const a=r.current;if(a)return mr(a)},[]),s.jsx(Er,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:F(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),wf=l.forwardRef((e,t)=>{const n=Ze(Ee,e.__scopeMenu);return s.jsx(Er,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),yf=xe.createSlot("MenuContent.ScrollLock"),Er=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:h,onDismiss:m,disableOutsideScroll:w,...g}=e,v=Ze(Ee,n),b=At(Ee,n),y=ln(n),x=Ms(n),S=uf(n),[C,k]=l.useState(null),E=l.useRef(null),M=se(t,E,v.onContentChange),L=l.useRef(0),O=l.useRef(""),B=l.useRef(0),H=l.useRef(null),G=l.useRef("right"),K=l.useRef(0),Z=w?cn:l.Fragment,z=w?{as:yf,allowPinchZoom:!0}:void 0,Y=A=>{var $,Q;const U=O.current+A,R=S().filter(ee=>!ee.disabled),re=document.activeElement,I=($=R.find(ee=>ee.ref.current===re))==null?void 0:$.textValue,P=R.map(ee=>ee.textValue),le=kf(P,U,I),ce=(Q=R.find(ee=>ee.textValue===le))==null?void 0:Q.ref.current;(function ee(J){O.current=J,window.clearTimeout(L.current),J!==""&&(L.current=window.setTimeout(()=>ee(""),1e3))})(U),ce&&setTimeout(()=>ce.focus())};l.useEffect(()=>()=>window.clearTimeout(L.current),[]),Yn();const _=l.useCallback(A=>{var R,re;return G.current===((R=H.current)==null?void 0:R.side)&&Of(A,(re=H.current)==null?void 0:re.area)},[]);return s.jsx(vf,{scope:n,searchRef:O,onItemEnter:l.useCallback(A=>{_(A)&&A.preventDefault()},[_]),onItemLeave:l.useCallback(A=>{var U;_(A)||((U=E.current)==null||U.focus(),k(null))},[_]),onTriggerLeave:l.useCallback(A=>{_(A)&&A.preventDefault()},[_]),pointerGraceTimerRef:B,onPointerGraceIntentChange:l.useCallback(A=>{H.current=A},[]),children:s.jsx(Z,{...z,children:s.jsx(Ht,{asChild:!0,trapped:o,onMountAutoFocus:F(a,A=>{var U;A.preventDefault(),(U=E.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:s.jsx(St,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:h,onDismiss:m,children:s.jsx(wu,{asChild:!0,...x,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:F(d,A=>{b.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(ur,{role:"menu","aria-orientation":"vertical","data-state":Qs(v.open),"data-radix-menu-content":"",dir:b.dir,...y,...g,ref:M,style:{outline:"none",...g.style},onKeyDown:F(g.onKeyDown,A=>{const R=A.target.closest("[data-radix-menu-content]")===A.currentTarget,re=A.ctrlKey||A.altKey||A.metaKey,I=A.key.length===1;R&&(A.key==="Tab"&&A.preventDefault(),!re&&I&&Y(A.key));const P=E.current;if(A.target!==P||!cf.includes(A.key))return;A.preventDefault();const ce=S().filter($=>!$.disabled).map($=>$.ref.current);As.includes(A.key)&&ce.reverse(),Pf(ce)}),onBlur:F(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(L.current),O.current="")}),onPointerMove:F(e.onPointerMove,Mt(A=>{const U=A.target,R=K.current!==A.clientX;if(A.currentTarget.contains(U)&&R){const re=A.clientX>K.current?"right":"left";G.current=re,K.current=A.clientX}}))})})})})})})});Ls.displayName=Ee;var xf="MenuGroup",Tr=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(X.div,{role:"group",...r,ref:t})});Tr.displayName=xf;var Sf="MenuLabel",$s=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(X.div,{...r,ref:t})});$s.displayName=Sf;var dn="MenuItem",Fs="menu.itemSelect",un=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,a=l.useRef(null),i=At(dn,e.__scopeMenu),c=Nr(dn,e.__scopeMenu),d=se(t,a),f=l.useRef(!1),u=()=>{const p=a.current;if(!n&&p){const h=new CustomEvent(Fs,{bubbles:!0,cancelable:!0});p.addEventListener(Fs,m=>r==null?void 0:r(m),{once:!0}),fo(p,h),h.defaultPrevented?f.current=!1:i.onClose()}};return s.jsx(Bs,{...o,ref:d,disabled:n,onClick:F(e.onClick,u),onPointerDown:p=>{var h;(h=e.onPointerDown)==null||h.call(e,p),f.current=!0},onPointerUp:F(e.onPointerUp,p=>{var h;f.current||(h=p.currentTarget)==null||h.click()}),onKeyDown:F(e.onKeyDown,p=>{const h=c.searchRef.current!=="";n||h&&p.key===" "||xr.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});un.displayName=dn;var Bs=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,i=Nr(dn,n),c=Ms(n),d=l.useRef(null),f=se(t,d),[u,p]=l.useState(!1),[h,m]=l.useState("");return l.useEffect(()=>{const w=d.current;w&&m((w.textContent??"").trim())},[a.children]),s.jsx(It.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:s.jsx(yu,{asChild:!0,...c,focusable:!r,children:s.jsx(X.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:f,onPointerMove:F(e.onPointerMove,Mt(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,Mt(w=>i.onItemLeave(w))),onFocus:F(e.onFocus,()=>p(!0)),onBlur:F(e.onBlur,()=>p(!1))})})})}),Cf="MenuCheckboxItem",Us=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(Gs,{scope:e.__scopeMenu,checked:n,children:s.jsx(un,{role:"menuitemcheckbox","aria-checked":fn(n)?"mixed":n,...o,ref:t,"data-state":Ir(n),onSelect:F(o.onSelect,()=>r==null?void 0:r(fn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Us.displayName=Cf;var zs="MenuRadioGroup",[Nf,Ef]=Je(zs,{value:void 0,onValueChange:()=>{}}),Ws=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,a=me(r);return s.jsx(Nf,{scope:e.__scopeMenu,value:n,onValueChange:a,children:s.jsx(Tr,{...o,ref:t})})});Ws.displayName=zs;var Hs="MenuRadioItem",Vs=l.forwardRef((e,t)=>{const{value:n,...r}=e,o=Ef(Hs,e.__scopeMenu),a=n===o.value;return s.jsx(Gs,{scope:e.__scopeMenu,checked:a,children:s.jsx(un,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":Ir(a),onSelect:F(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Vs.displayName=Hs;var _r="MenuItemIndicator",[Gs,Tf]=Je(_r,{checked:!1}),Ks=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,a=Tf(_r,n);return s.jsx(we,{present:r||fn(a.checked)||a.checked===!0,children:s.jsx(X.span,{...o,ref:t,"data-state":Ir(a.checked)})})});Ks.displayName=_r;var _f="MenuSeparator",js=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(X.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});js.displayName=_f;var If="MenuArrow",Ys=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ln(n);return s.jsx(fr,{...o,...r,ref:t})});Ys.displayName=If;var Af="MenuSub",[jg,Xs]=Je(Af),Pt="MenuSubTrigger",qs=l.forwardRef((e,t)=>{const n=Ze(Pt,e.__scopeMenu),r=At(Pt,e.__scopeMenu),o=Xs(Pt,e.__scopeMenu),a=Nr(Pt,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,f={__scopeMenu:e.__scopeMenu},u=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>u,[u]),l.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),s.jsx(Sr,{asChild:!0,...f,children:s.jsx(Bs,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Qs(n.open),...e,ref:zn(t,o.onTriggerChange),onClick:p=>{var h;(h=e.onClick)==null||h.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:F(e.onPointerMove,Mt(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:F(e.onPointerLeave,Mt(p=>{var m,w;u();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const g=(w=n.content)==null?void 0:w.dataset.side,v=g==="right",b=v?-5:5,y=h[v?"left":"right"],x=h[v?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x:y,y:h.top},{x,y:h.top},{x,y:h.bottom},{x:y,y:h.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:F(e.onKeyDown,p=>{var m;const h=a.searchRef.current!=="";e.disabled||h&&p.key===" "||lf[r.dir].includes(p.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),p.preventDefault())})})})});qs.displayName=Pt;var Js="MenuSubContent",Zs=l.forwardRef((e,t)=>{const n=Ds(Ee,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Ze(Ee,e.__scopeMenu),i=At(Ee,e.__scopeMenu),c=Xs(Js,e.__scopeMenu),d=l.useRef(null),f=se(t,d);return s.jsx(It.Provider,{scope:e.__scopeMenu,children:s.jsx(we,{present:r||a.open,children:s.jsx(It.Slot,{scope:e.__scopeMenu,children:s.jsx(Er,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:f,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var p;i.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:F(e.onFocusOutside,u=>{u.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:F(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:F(e.onKeyDown,u=>{var m;const p=u.currentTarget.contains(u.target),h=df[i.dir].includes(u.key);p&&h&&(a.onOpenChange(!1),(m=c.trigger)==null||m.focus(),u.preventDefault())})})})})})});Zs.displayName=Js;function Qs(e){return e?"open":"closed"}function fn(e){return e==="indeterminate"}function Ir(e){return fn(e)?"indeterminate":e?"checked":"unchecked"}function Pf(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Mf(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function kf(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=Mf(e,Math.max(a,0));o.length===1&&(i=i.filter(f=>f!==n));const d=i.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function Df(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],f=c.x,u=c.y,p=d.x,h=d.y;u>r!=h>r&&n<(p-f)*(r-u)/(h-u)+f&&(o=!o)}return o}function Of(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Df(n,t)}function Mt(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Lf=ks,$f=Sr,Ff=Os,Bf=Ls,Uf=Tr,zf=$s,Wf=un,Hf=Us,Vf=Ws,Gf=Vs,Kf=Ks,jf=js,Yf=Ys,Xf=qs,qf=Zs,pn="DropdownMenu",[Jf,Yg]=Ie(pn,[Ps]),ve=Ps(),[Zf,Rs]=Jf(pn),ea=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,d=ve(t),f=l.useRef(null),[u,p]=He({prop:o,defaultProp:a??!1,onChange:i,caller:pn});return s.jsx(Zf,{scope:t,triggerId:Ae(),triggerRef:f,contentId:Ae(),open:u,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(h=>!h),[p]),modal:c,children:s.jsx(Lf,{...d,open:u,onOpenChange:p,dir:r,modal:c,children:n})})};ea.displayName=pn;var ta="DropdownMenuTrigger",na=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=Rs(ta,n),i=ve(n);return s.jsx($f,{asChild:!0,...i,children:s.jsx(X.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:zn(t,a.triggerRef),onPointerDown:F(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:F(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});na.displayName=ta;var Qf="DropdownMenuPortal",ra=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ve(t);return s.jsx(Ff,{...r,...n})};ra.displayName=Qf;var oa="DropdownMenuContent",sa=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rs(oa,n),a=ve(n),i=l.useRef(!1);return s.jsx(Bf,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:F(e.onCloseAutoFocus,c=>{var d;i.current||(d=o.triggerRef.current)==null||d.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:F(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,u=d.button===2||f;(!o.modal||u)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sa.displayName=oa;var Rf="DropdownMenuGroup",ep=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Uf,{...o,...r,ref:t})});ep.displayName=Rf;var tp="DropdownMenuLabel",aa=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(zf,{...o,...r,ref:t})});aa.displayName=tp;var np="DropdownMenuItem",ia=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Wf,{...o,...r,ref:t})});ia.displayName=np;var rp="DropdownMenuCheckboxItem",ca=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Hf,{...o,...r,ref:t})});ca.displayName=rp;var op="DropdownMenuRadioGroup",sp=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Vf,{...o,...r,ref:t})});sp.displayName=op;var ap="DropdownMenuRadioItem",la=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Gf,{...o,...r,ref:t})});la.displayName=ap;var ip="DropdownMenuItemIndicator",da=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Kf,{...o,...r,ref:t})});da.displayName=ip;var cp="DropdownMenuSeparator",ua=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(jf,{...o,...r,ref:t})});ua.displayName=cp;var lp="DropdownMenuArrow",dp=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Yf,{...o,...r,ref:t})});dp.displayName=lp;var up="DropdownMenuSubTrigger",fa=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(Xf,{...o,...r,ref:t})});fa.displayName=up;var fp="DropdownMenuSubContent",pa=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ve(n);return s.jsx(qf,{...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)"}})});pa.displayName=fp;var pp=ea,hp=na,gp=ra,ha=sa,ga=aa,ma=ia,va=ca,ba=la,wa=da,ya=ua,xa=fa,Sa=pa;const mp=pp,vp=hp,bp=l.forwardRef(({className:e,inset:t,children:n,...r},o)=>s.jsxs(xa,{ref:o,className:T("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,s.jsx(W.ChevronRight,{className:"ml-auto h-4 w-4"})]}));bp.displayName=xa.displayName;const wp=l.forwardRef(({className:e,...t},n)=>s.jsx(Sa,{ref:n,className:T("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}));wp.displayName=Sa.displayName;const Ca=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(gp,{children:s.jsx(ha,{ref:r,sideOffset:t,className:T("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})}));Ca.displayName=ha.displayName;const Na=l.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(ma,{ref:r,className:T("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}));Na.displayName=ma.displayName;const yp=l.forwardRef(({className:e,children:t,checked:n,...r},o)=>s.jsxs(va,{ref:o,className:T("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:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(wa,{children:s.jsx(W.Check,{className:"h-4 w-4"})})}),t]}));yp.displayName=va.displayName;const xp=l.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(ba,{ref:r,className:T("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:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(wa,{children:s.jsx(W.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));xp.displayName=ba.displayName;const Sp=l.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(ga,{ref:r,className:T("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Sp.displayName=ga.displayName;const Cp=l.forwardRef(({className:e,...t},n)=>s.jsx(ya,{ref:n,className:T("-mx-1 my-1 h-px bg-muted",e),...t}));Cp.displayName=ya.displayName;function kt({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=40,enableFileUpload:a=!0,enableMessageEditing:i=!0,customStyles:c={},onMessageSent:d,onError:f}){const{currentThreadId:u,messages:p,isStreaming:h,streamingAssistantId:m,error:w,send:g,stop:v,lastCheckpointId:b,listCheckpoints:y,navigateToCheckpoint:x,returnToLatest:S}=Un(),[C,k]=N.useState(""),[E,M]=N.useState(null),[L,O]=N.useState(null),[B,H]=N.useState([]),[G,K]=N.useState(!1),[Z,z]=N.useState([]),[Y,_]=N.useState(null),A=N.useRef(null),U=N.useRef(null),R=N.useRef(null),[re,I]=N.useState("desktop");N.useEffect(()=>{const D=()=>{const q=window.innerWidth;I(q<640?"phone":q<1024?"tablet":"desktop")};return D(),window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]),N.useEffect(()=>{var D;(D=A.current)==null||D.scrollIntoView({behavior:"smooth"})},[p]),N.useEffect(()=>{var D;n&&((D=U.current)==null||D.focus())},[n]),N.useEffect(()=>{w&&!G&&(f==null||f(w))},[w,G,f]),N.useEffect(()=>{let D=!0;if(!u){z([]),_(null);return}return y(u).then(q=>{var ye;if(!D)return;const ne=q.checkpoints||[];z(ne);const de=((ye=ne.slice().sort((gt,be)=>new Date(be.createdAt).getTime()-new Date(gt.createdAt).getTime())[0])==null?void 0:ye.checkpointId)||null;_(gt=>gt??de)}).catch(()=>{}),()=>{D=!1}},[u,y]),N.useEffect(()=>{b&&_(b)},[b]);const P=D=>{if(D.length>nt)return`Message too long (${D.length}/${nt} characters)`;try{return _l(D),null}catch(q){return(q==null?void 0:q.message)||"Invalid message"}},le=D=>{const q=D.content||[],ne=q.filter(de=>de.type==="text").map(de=>de.text).join("");if(ne)return ne;try{return JSON.stringify(q,null,2)}catch{return String(q)}},ce=D=>{var gt;if(!Z.length)return[];const ne=(((gt=p[D])==null?void 0:gt.role)??"user")==="user",de=ne?D+2:D+1;return Z.filter(be=>(be.messagesLen??-1)>=(ne?de:0)).filter(be=>ne?(be.messagesLen??0)>=de:(be.messagesLen??0)===de).map(be=>({checkpoint_id:be.checkpointId,checkpoint_ns:be.checkpointNs,message_count:be.messagesLen??0,last_message_preview:be.preview??void 0,ts:new Date(be.createdAt).getTime(),isCurrent:be.checkpointId===Y})).sort((be,Hg)=>(be.ts||0)-(Hg.ts||0))},$=D=>{if(D===void 0)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:0};const q=ce(D);if(q.length<=1)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:q.length};const ne=Math.max(0,q.findIndex(de=>de.isCurrent));return{canGoBack:ne>0,canGoForward:ne<q.length-1,currentIndex:ne,totalBranches:q.length}},Q=async()=>{const D=C.trim();if(!D&&B.length===0)return;const q=P(D);if(q){O(q);return}try{const ne=window.__editingCheckpointId||Y||void 0;await g(D,{checkpointId:ne,payloadExtras:E?{edit:!0,originalMessageId:E}:void 0,attachments:B}),d==null||d(D),k(""),O(null),H([]),delete window.__editingCheckpointId,M(null),U.current&&(U.current.style.height="auto")}catch(ne){const de=(ne==null?void 0:ne.message)||"Failed to send message";O(de),f==null||f(de)}},ee=(D,q)=>{i&&(M(D),k(q),O(null),setTimeout(()=>{U.current&&(U.current.focus(),U.current.style.height="auto",U.current.style.height=U.current.scrollHeight+"px")},0))},J=async(D,q)=>{const ne=p.find(ye=>ye.id===D);if(!ne){O("Message not found");return}const de=le(ne);M(D),k(de),window.__editingCheckpointId=q,setTimeout(()=>{var ye;return(ye=U.current)==null?void 0:ye.focus()},0)},te=()=>{M(null),k(""),O(null),delete window.__editingCheckpointId,U.current&&(U.current.style.height="auto")},ie=D=>{D.key==="Enter"&&!D.shiftKey?(D.preventDefault(),Q()):D.key==="Escape"&&E&&(D.preventDefault(),te())},he=D=>{const q=Array.from(D.target.files||[]);H(ne=>[...ne,...q])},j=D=>H(q=>q.filter((ne,de)=>D!==de)),V=async D=>{u&&(await x(D),_(D))},fe=async()=>{await S(),_(null)},oe=`flex flex-col h-full ${e} ${c.container||""}`,pe=`flex-1 min-h-0 overflow-y-auto p-4 space-y-4 ${c.messagesArea||""}`,Ne=`flex-shrink-0 border-t p-4 ${c.inputArea||""}`;return s.jsxs("div",{className:oe,children:[!!w&&!G&&s.jsxs("div",{className:"bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[s.jsx("span",{children:w}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>K(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:s.jsx(W.X,{size:16})})]}),u&&Z.length>0&&s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b bg-background/50 text-xs",children:[s.jsx(W.GitBranch,{className:"h-4 w-4 opacity-70"}),s.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),s.jsxs("select",{className:"border rounded px-2 py-1 text-xs",value:Y??"",onChange:D=>{const q=D.target.value||null;q?V(q):fe()},children:[s.jsx("option",{value:"",children:"Latest"}),Z.slice().sort((D,q)=>new Date(q.createdAt).getTime()-new Date(D.createdAt).getTime()).map(D=>s.jsxs("option",{value:D.checkpointId,children:[new Date(D.createdAt).toLocaleString(),D.preview?` — ${D.preview.slice(0,30)}`:""]},D.checkpointId))]})]}),s.jsxs("div",{className:pe,style:r?{maxHeight:r}:void 0,children:[p.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:"No messages yet. Start a conversation!"}):p.map((D,q)=>s.jsx(bo,{message:D,messageIndex:q,isStreamingMessage:h&&m===D.id,streamingDebounceMs:o,isEditing:E===D.id,showActions:i,showTimestamp:!1,showAgentName:!0,layoutSize:re,truncateToolMessages:!1,toolMessagePreviewLength:200,checkpointBranches:ce(q),currentCheckpointId:Y??void 0,temporalNavigation:$(q),onSwitchToCheckpoint:V,onReturnToMainThread:fe,onNavigateToPreviousBranch:()=>{const ne=ce(q),de=Math.max(0,ne.findIndex(ye=>ye.isCurrent));de>0&&V(ne[de-1].checkpoint_id)},onNavigateToNextBranch:()=>{const ne=ce(q),de=Math.max(0,ne.findIndex(ye=>ye.isCurrent));de>=0&&de<ne.length-1&&V(ne[de+1].checkpoint_id)},onEdit:(ne,de)=>ee(ne,de),onEditFromCheckpoint:J,onRegenerate:()=>{const ne=[...p].reverse().find(ye=>ye.role==="user"),de=ne?le(ne):"";de&&g(de,{checkpointId:Y??void 0})},onCancelEdit:te},D.id||q)),s.jsx("div",{ref:A})]}),s.jsxs("div",{className:Ne,children:[E&&s.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(W.Edit3,{size:16,className:"text-blue-600"}),s.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:te,className:"text-blue-600 hover:bg-blue-100",children:s.jsx(W.X,{size:16})})]})}),a&&s.jsxs("div",{className:"mb-3",children:[s.jsx("input",{ref:R,type:"file",multiple:!0,onChange:D=>he(D),className:"hidden"}),B.length>0&&s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:B.map((D,q)=>s.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2 text-sm",children:[s.jsx(W.Paperclip,{size:14}),s.jsx("span",{className:"truncate max-w-[150px]",children:D.name}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>j(q),className:"h-4 w-4 p-0 text-gray-500 hover:text-red-500","aria-label":`Remove ${D.name}`,children:s.jsx(W.X,{size:12})})]},q))})]}),L&&s.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:L}),s.jsxs("div",{className:"flex items-end gap-2",children:[a&&s.jsxs(mp,{children:[s.jsx(vp,{asChild:!0,children:s.jsx(ue,{type:"button",size:"icon",variant:"outline",disabled:h,title:"More input actions",children:s.jsx(W.Plus,{size:16})})}),s.jsx(Ca,{align:"start",sideOffset:6,className:"w-52",children:s.jsxs(Na,{onClick:()=>{var D;return(D=R.current)==null?void 0:D.click()},className:"cursor-pointer",children:[s.jsx(W.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]})})]}),s.jsx("div",{className:"flex-1",children:s.jsx(co,{ref:U,value:C,onChange:D=>{k(D.target.value),O(null),U.current&&(U.current.style.height="auto",U.current.style.height=`${U.current.scrollHeight}px`)},onKeyDown:ie,placeholder:E?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full ${E?"border-blue-400 bg-blue-50":""} ${L?"border-red-400":""}`,disabled:!1,maxLength:nt,rows:1})}),s.jsx("div",{children:h?s.jsx(ue,{type:"button",onClick:v,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:s.jsx(W.Square,{size:16})}):s.jsx(ue,{type:"button",onClick:Q,size:"icon",disabled:!C.trim()&&B.length===0,className:`shrink-0 ${c.sendButton||""}`,title:E?"Save changes":"Send message",children:s.jsx(W.Send,{size:16})})})]}),C.length>nt*.8&&s.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[C.length,"/",nt]})]})]})}const Dt=l.forwardRef(({className:e,type:t,...n},r)=>s.jsx("input",{type:t,className:T("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}));Dt.displayName="Input";function Ar(e,[t,n]){return Math.min(n,Math.max(t,e))}function Np(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Pr="ScrollArea",[Ea,Xg]=Ie(Pr),[Ep,Te]=Ea(Pr),Ta=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[f,u]=l.useState(null),[p,h]=l.useState(null),[m,w]=l.useState(null),[g,v]=l.useState(null),[b,y]=l.useState(0),[x,S]=l.useState(0),[C,k]=l.useState(!1),[E,M]=l.useState(!1),L=se(t,B=>d(B)),O=Wt(o);return s.jsx(Ep,{scope:n,type:r,dir:O,scrollHideDelay:a,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:h,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:E,onScrollbarYEnabledChange:M,onCornerWidthChange:y,onCornerHeightChange:S,children:s.jsx(X.div,{dir:O,...i,ref:L,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});Ta.displayName=Pr;var _a="ScrollAreaViewport",Ia=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...a}=e,i=Te(_a,n),c=l.useRef(null),d=se(t,c,i.onViewportChange);return s.jsxs(s.Fragment,{children:[s.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}),s.jsx(X.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Ia.displayName=_a;var Ue="ScrollAreaScrollbar",Mr=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Te(Ue,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),o.type==="hover"?s.jsx(Tp,{...r,ref:t,forceMount:n}):o.type==="scroll"?s.jsx(_p,{...r,ref:t,forceMount:n}):o.type==="auto"?s.jsx(Aa,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(kr,{...r,ref:t}):null});Mr.displayName=Ue;var Tp=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Te(Ue,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const f=()=>{window.clearTimeout(d),i(!0)},u=()=>{d=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),s.jsx(we,{present:n||a,children:s.jsx(Aa,{"data-state":a?"visible":"hidden",...r,ref:t})})}),_p=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Te(Ue,e.__scopeScrollArea),a=e.orientation==="horizontal",i=vn(()=>d("SCROLL_END"),100),[c,d]=Np("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 l.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const f=o.viewport,u=a?"scrollLeft":"scrollTop";if(f){let p=f[u];const h=()=>{const m=f[u];p!==m&&(d("SCROLL"),i()),p=m};return f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[o.viewport,a,d,i]),s.jsx(we,{present:n||c!=="hidden",children:s.jsx(kr,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:F(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:F(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Aa=l.forwardRef((e,t)=>{const n=Te(Ue,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=vn(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(c?f:u)}},10);return ft(n.viewport,d),ft(n.content,d),s.jsx(we,{present:r||a,children:s.jsx(kr,{"data-state":a?"visible":"hidden",...o,ref:t})})}),kr=l.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Te(Ue,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=Oa(c.viewport,c.content),u={...r,sizes:c,onSizesChange:d,hasThumb:f>0&&f<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function p(h,m){return Dp(h,i.current,c,m)}return n==="horizontal"?s.jsx(Ip,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,m=La(h,c,o.dir);a.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=p(h,o.dir))}}):n==="vertical"?s.jsx(Ap,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,m=La(h,c);a.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=p(h))}}):null}),Ip=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=Te(Ue,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),f=se(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),s.jsx(Ma,{"data-orientation":"horizontal",...o,ref:f,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":mn(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(a.viewport){const h=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),Fa(h,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:gn(i.paddingLeft),paddingEnd:gn(i.paddingRight)}})}})}),Ap=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=Te(Ue,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),f=se(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),s.jsx(Ma,{"data-orientation":"vertical",...o,ref:f,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":mn(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(a.viewport){const h=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),Fa(h,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:gn(i.paddingTop),paddingEnd:gn(i.paddingBottom)}})}})}),[Pp,Pa]=Ea(Ue),Ma=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:f,onWheelScroll:u,onResize:p,...h}=e,m=Te(Ue,n),[w,g]=l.useState(null),v=se(t,L=>g(L)),b=l.useRef(null),y=l.useRef(""),x=m.viewport,S=r.content-r.viewport,C=me(u),k=me(d),E=vn(p,10);function M(L){if(b.current){const O=L.clientX-b.current.left,B=L.clientY-b.current.top;f({x:O,y:B})}}return l.useEffect(()=>{const L=O=>{const B=O.target;(w==null?void 0:w.contains(B))&&C(O,S)};return document.addEventListener("wheel",L,{passive:!1}),()=>document.removeEventListener("wheel",L,{passive:!1})},[x,w,S,C]),l.useEffect(k,[r,k]),ft(w,E),ft(m.content,E),s.jsx(Pp,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:me(a),onThumbPointerUp:me(i),onThumbPositionChange:k,onThumbPointerDown:me(c),children:s.jsx(X.div,{...h,ref:v,style:{position:"absolute",...h.style},onPointerDown:F(e.onPointerDown,L=>{L.button===0&&(L.target.setPointerCapture(L.pointerId),b.current=w.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),M(L))}),onPointerMove:F(e.onPointerMove,M),onPointerUp:F(e.onPointerUp,L=>{const O=L.target;O.hasPointerCapture(L.pointerId)&&O.releasePointerCapture(L.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=""),b.current=null})})})}),hn="ScrollAreaThumb",ka=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Pa(hn,e.__scopeScrollArea);return s.jsx(we,{present:n||o.hasThumb,children:s.jsx(Mp,{ref:t,...r})})}),Mp=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,a=Te(hn,n),i=Pa(hn,n),{onThumbPositionChange:c}=i,d=se(t,p=>i.onThumbChange(p)),f=l.useRef(void 0),u=vn(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{const p=a.viewport;if(p){const h=()=>{if(u(),!f.current){const m=Op(p,c);f.current=m,c()}};return c(),p.addEventListener("scroll",h),()=>p.removeEventListener("scroll",h)}},[a.viewport,u,c]),s.jsx(X.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:F(e.onPointerDownCapture,p=>{const m=p.target.getBoundingClientRect(),w=p.clientX-m.left,g=p.clientY-m.top;i.onThumbPointerDown({x:w,y:g})}),onPointerUp:F(e.onPointerUp,i.onThumbPointerUp)})});ka.displayName=hn;var Dr="ScrollAreaCorner",Da=l.forwardRef((e,t)=>{const n=Te(Dr,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(kp,{...e,ref:t}):null});Da.displayName=Dr;var kp=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Te(Dr,n),[a,i]=l.useState(0),[c,d]=l.useState(0),f=!!(a&&c);return ft(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),d(u)}),ft(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),f?s.jsx(X.div,{...r,ref:t,style:{width:a,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function gn(e){return e?parseInt(e,10):0}function Oa(e,t){const n=e/t;return isNaN(n)?0:n}function mn(e){const t=Oa(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Dp(e,t,n,r="ltr"){const o=mn(n),a=o/2,i=t||a,c=o-i,d=n.scrollbar.paddingStart+i,f=n.scrollbar.size-n.scrollbar.paddingEnd-c,u=n.content-n.viewport,p=r==="ltr"?[0,u]:[u*-1,0];return $a([d,f],p)(e)}function La(e,t,n="ltr"){const r=mn(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,i=t.content-t.viewport,c=a-r,d=n==="ltr"?[0,i]:[i*-1,0],f=Ar(e,d);return $a([0,i],[0,c])(f)}function $a(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 Fa(e,t){return e>0&&e<t}var Op=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,c=n.top!==a.top;(i||c)&&t(),n=a,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function vn(e,t){const n=me(e),r=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),l.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ft(e,t){const n=me(t);ge(()=>{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 Ba=Ta,Lp=Ia,$p=Da;const Ua=l.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(Ba,{ref:r,className:T("relative overflow-hidden",e),...n,children:[s.jsx(Lp,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),s.jsx(za,{}),s.jsx($p,{})]}));Ua.displayName=Ba.displayName;const za=l.forwardRef(({className:e,orientation:t="vertical",...n},r)=>s.jsx(Mr,{ref:r,orientation:t,className:T("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:s.jsx(ka,{className:"relative flex-1 rounded-full bg-border"})}));za.displayName=Mr.displayName;function bn({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:a={},currentThreadId:i=null,navigateToThread:c,onThreadSelect:d,onThreadCreate:f,onThreadDelete:u}){const{loadThread:p,threads:h,refreshThreads:m,currentThreadId:w,createThread:g,deleteThread:v,renameThread:b}=Un(),[y,x]=N.useState(h??[]),[S,C]=N.useState(!1),[k,E]=N.useState(null),[M,L]=N.useState(null),[O,B]=N.useState(""),[H,G]=N.useState(!1);N.useEffect(()=>{x(h??[])},[h]);const K=async I=>{try{await p(I),c==null||c(I),d==null||d(I)}catch(P){console.error("Failed to select thread:",P)}},Z=async()=>{try{G(!0);const I=await g();f==null||f(I),c==null||c(I)}catch(I){console.error("Failed to create thread:",I)}finally{G(!1)}},z=async(I,P)=>{if(P.stopPropagation(),!!confirm("Delete this thread?"))try{await v(I),u==null||u(I)}catch(le){console.error("Failed to delete thread:",le)}},Y=(I,P)=>{P.stopPropagation(),L(I.threadId),B(I.title||`Thread ${I.threadId.slice(0,8)}`)},_=async I=>{if(O.trim())try{await b(I,O.trim()),L(null),B("")}catch(P){console.error("Failed to update title:",P)}},A=()=>{L(null),B("")},U=(I,P)=>{I.key==="Enter"?_(P):I.key==="Escape"&&A()},R=I=>{if(!I)return"";try{const P=new Date(I),ce=new Date().getTime()-P.getTime(),$=Math.floor(ce/(1e3*60*60*24));return $===0?P.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):$===1?"Yesterday":$<7?`${$} days ago`:P.toLocaleDateString()}catch{return""}},re=I=>I.title||`Thread ${I.threadId.slice(0,8)}`;return s.jsxs("div",{className:`flex flex-col h-full ${e} ${a.container||""}`,children:[t&&s.jsx("div",{className:a.header||"flex-shrink-0 p-4 border-b bg-slate-800 border-slate-700 text-slate-100",children:s.jsxs(ue,{onClick:Z,disabled:H||S,className:a.createButton||"w-full !bg-slate-700 hover:!bg-slate-600 !text-slate-100 !border-slate-600",size:"sm",children:[s.jsx(W.Plus,{size:16,className:"mr-2"}),H?"Creating...":"New Conversation"]})}),s.jsx(Ua,{className:`flex-1 ${a.threadList||""}`,style:{maxHeight:o},children:s.jsx("div",{className:"p-2 space-y-1 pb-4",children:S?s.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):y.length===0?s.jsxs("div",{className:"text-center py-8 text-slate-400",children:[s.jsx(W.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),s.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):y.slice().sort((I,P)=>new Date(P.updatedAt||P.createdAt||"").getTime()-new Date(I.updatedAt||I.createdAt||"").getTime()).map(I=>s.jsxs("div",{onClick:()=>K(I.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??w)===I.threadId?`${a.activeThread||"bg-slate-600 border-slate-500"} `:`${a.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600"}`} ${a.threadItem||""} text-slate-100`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"flex-1 min-w-0",children:M===I.threadId?s.jsxs("div",{className:"flex items-center gap-2",onClick:P=>P.stopPropagation(),children:[s.jsx(Dt,{value:O,onChange:P=>B(P.target.value),onKeyDown:P=>U(P,I.threadId),className:"h-6 text-sm",autoFocus:!0}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>_(I.threadId),className:"h-6 w-6 p-0",children:s.jsx(W.Check,{size:12})}),s.jsx(ue,{variant:"ghost",size:"sm",onClick:A,className:"h-6 w-6 p-0",children:s.jsx(W.X,{size:12})})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"font-medium text-sm truncate text-slate-100",children:re(I)}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400 mt-1",children:[s.jsx(W.Calendar,{size:10}),s.jsx("span",{children:R(I.updatedAt||I.createdAt)})]})]})}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&M!==I.threadId&&s.jsx(ue,{variant:"ghost",size:"sm",onClick:P=>Y(I,P),className:"h-6 w-6 p-0",title:"Edit title",children:s.jsx(W.Edit3,{size:12})}),n&&s.jsx(ue,{variant:"ghost",size:"sm",onClick:P=>z(I.threadId,P),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:s.jsx(W.Trash2,{size:12})})]})]}),i===I.threadId&&s.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},I.threadId))})})]})}const Wa=N.createContext(null);function Fp({children:e,basePath:t="/chat"}){const n=N.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return s.jsx(Wa.Provider,{value:r,children:e})}function Bp(){const e=N.useContext(Wa);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const Or=768;function Up(){const[e,t]=l.useState(void 0);return l.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Or-1}px)`),r=()=>{t(window.innerWidth<Or)};return n.addEventListener("change",r),t(window.innerWidth<Or),()=>n.removeEventListener("change",r)},[]),!!e}var zp="Separator",Ha="horizontal",Wp=["horizontal","vertical"],Va=l.forwardRef((e,t)=>{const{decorative:n,orientation:r=Ha,...o}=e,a=Hp(r)?r:Ha,c=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return s.jsx(X.div,{"data-orientation":a,...c,...o,ref:t})});Va.displayName=zp;function Hp(e){return Wp.includes(e)}var Ga=Va;const Lr=l.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>s.jsx(Ga,{ref:o,decorative:n,orientation:t,className:T("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Lr.displayName=Ga.displayName;var wn="Dialog",[Ka,qg]=Ie(wn),[Vp,ke]=Ka(wn),ja=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[f,u]=He({prop:r,defaultProp:o??!1,onChange:a,caller:wn});return s.jsx(Vp,{scope:t,triggerRef:c,contentRef:d,contentId:Ae(),titleId:Ae(),descriptionId:Ae(),open:f,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:i,children:n})};ja.displayName=wn;var Ya="DialogTrigger",Xa=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(Ya,n),a=se(t,o.triggerRef);return s.jsx(X.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Br(o.open),...r,ref:a,onClick:F(e.onClick,o.onOpenToggle)})});Xa.displayName=Ya;var $r="DialogPortal",[Gp,qa]=Ka($r,{forceMount:void 0}),Ja=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=ke($r,t);return s.jsx(Gp,{scope:t,forceMount:n,children:l.Children.map(r,i=>s.jsx(we,{present:n||a.open,children:s.jsx(Rt,{asChild:!0,container:o,children:i})}))})};Ja.displayName=$r;var yn="DialogOverlay",Za=l.forwardRef((e,t)=>{const n=qa(yn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ke(yn,e.__scopeDialog);return a.modal?s.jsx(we,{present:r||a.open,children:s.jsx(jp,{...o,ref:t})}):null});Za.displayName=yn;var Kp=xe.createSlot("DialogOverlay.RemoveScroll"),jp=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(yn,n);return s.jsx(cn,{as:Kp,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(X.div,{"data-state":Br(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Qe="DialogContent",Qa=l.forwardRef((e,t)=>{const n=qa(Qe,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ke(Qe,e.__scopeDialog);return s.jsx(we,{present:r||a.open,children:a.modal?s.jsx(Yp,{...o,ref:t}):s.jsx(Xp,{...o,ref:t})})});Qa.displayName=Qe;var Yp=l.forwardRef((e,t)=>{const n=ke(Qe,e.__scopeDialog),r=l.useRef(null),o=se(t,n.contentRef,r);return l.useEffect(()=>{const a=r.current;if(a)return mr(a)},[]),s.jsx(Ra,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:F(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:F(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:F(e.onFocusOutside,a=>a.preventDefault())})}),Xp=l.forwardRef((e,t)=>{const n=ke(Qe,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return s.jsx(Ra,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,c;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((f=n.triggerRef.current)==null?void 0:f.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Ra=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=ke(Qe,n),d=l.useRef(null),f=se(t,d);return Yn(),s.jsxs(s.Fragment,{children:[s.jsx(Ht,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(St,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Br(c.open),...i,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(qp,{titleId:c.titleId}),s.jsx(Zp,{contentRef:d,descriptionId:c.descriptionId})]})]})}),Fr="DialogTitle",ei=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(Fr,n);return s.jsx(X.h2,{id:o.titleId,...r,ref:t})});ei.displayName=Fr;var ti="DialogDescription",ni=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(ti,n);return s.jsx(X.p,{id:o.descriptionId,...r,ref:t})});ni.displayName=ti;var ri="DialogClose",oi=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ke(ri,n);return s.jsx(X.button,{type:"button",...r,ref:t,onClick:F(e.onClick,()=>o.onOpenChange(!1))})});oi.displayName=ri;function Br(e){return e?"open":"closed"}var si="DialogTitleWarning",[Jg,ai]=Rc(si,{contentName:Qe,titleName:Fr,docsSlug:"dialog"}),qp=({titleId:e})=>{const t=ai(si),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
54
54
 
55
55
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
56
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teodor-new-chat-ui",
3
- "version": "1.5.12",
3
+ "version": "1.5.13",
4
4
  "description": "React chat UI components with streaming support, tool calls, and modern design",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",