teodor-new-chat-ui 3.0.11 → 3.0.12

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
@@ -7117,17 +7117,17 @@ function Vn({
7117
7117
  const J = {
7118
7118
  threadId: h,
7119
7119
  checkpointId: y ?? null
7120
- }, le = st.current;
7121
- if (!(le && le.threadId === J.threadId && le.checkpointId === J.checkpointId))
7122
- return st.current = J, C(h).then((ue) => {
7123
- if (console.log("ChatInterface debug - listCheckpoints response:", ue), P) return;
7124
- const De = ((ue == null ? void 0 : ue.checkpoints) ?? []).slice().sort((at, Tn) => new Date(Tn.createdAt).getTime() - new Date(at.createdAt).getTime());
7120
+ }, ue = st.current;
7121
+ if (!(ue && ue.threadId === J.threadId && ue.checkpointId === J.checkpointId))
7122
+ return st.current = J, C(h).then((le) => {
7123
+ if (console.log("ChatInterface debug - listCheckpoints response:", le), P) return;
7124
+ const De = ((le == null ? void 0 : le.checkpoints) ?? []).slice().sort((at, Tn) => new Date(Tn.createdAt).getTime() - new Date(at.createdAt).getTime());
7125
7125
  console.log("ChatInterface debug - computed checkpoints:", De), V(De), te((at) => {
7126
7126
  var Tn;
7127
7127
  return at ?? ((Tn = De[0]) == null ? void 0 : Tn.checkpointId) ?? null;
7128
7128
  });
7129
- }).catch(() => {
7130
- P || (V([]), st.current = null);
7129
+ }).catch((le) => {
7130
+ console.error("ChatInterface debug - listCheckpoints error:", le), P || (V([]), st.current = null);
7131
7131
  }), () => {
7132
7132
  P = !0;
7133
7133
  };
@@ -7138,22 +7138,22 @@ function Vn({
7138
7138
  if (!N || k) return;
7139
7139
  const P = he.current;
7140
7140
  if (!P) return;
7141
- const J = P.scrollHeight, le = P.scrollTop;
7141
+ const J = P.scrollHeight, ue = P.scrollTop;
7142
7142
  Oe.current = !0;
7143
7143
  try {
7144
7144
  await L();
7145
- } catch (ue) {
7146
- console.warn("loadOlderMessages failed", ue);
7145
+ } catch (le) {
7146
+ console.warn("loadOlderMessages failed", le);
7147
7147
  } finally {
7148
7148
  requestAnimationFrame(() => {
7149
- const ue = he.current;
7150
- if (!ue) {
7149
+ const le = he.current;
7150
+ if (!le) {
7151
7151
  Oe.current = !1;
7152
7152
  return;
7153
7153
  }
7154
- const De = ue.scrollHeight;
7155
- ue.scrollTop = le + (De - J);
7156
- const at = De - ue.scrollTop - ue.clientHeight;
7154
+ const De = le.scrollHeight;
7155
+ le.scrollTop = ue + (De - J);
7156
+ const at = De - le.scrollTop - le.clientHeight;
7157
7157
  Ce.current = at <= 32, Oe.current = !1;
7158
7158
  });
7159
7159
  }
@@ -7196,8 +7196,8 @@ function Vn({
7196
7196
  return (J == null ? void 0 : J.message) || "Invalid message";
7197
7197
  }
7198
7198
  }, Sn = (P) => {
7199
- const J = P.content || [], le = J.filter((ue) => ue.type === "text").map((ue) => ue.text).join("");
7200
- if (le) return le;
7199
+ const J = P.content || [], ue = J.filter((le) => le.type === "text").map((le) => le.text).join("");
7200
+ if (ue) return ue;
7201
7201
  try {
7202
7202
  return JSON.stringify(J, null, 2);
7203
7203
  } catch {
@@ -7216,8 +7216,8 @@ function Vn({
7216
7216
  try {
7217
7217
  await w(P, { checkpointId: X || y || void 0, payloadExtras: B ? { edit: !0, originalMessageId: B } : void 0, attachments: G }), f == null || f(P), K(""), O(null), D([]), M(null), de.current && (de.current.style.height = "auto");
7218
7218
  } catch (J) {
7219
- const le = (J == null ? void 0 : J.message) || "Failed to send message";
7220
- O(le), p == null || p(le);
7219
+ const ue = (J == null ? void 0 : J.message) || "Failed to send message";
7220
+ O(ue), p == null || p(ue);
7221
7221
  }
7222
7222
  }
7223
7223
  }, Wr = (P, J) => {
@@ -7230,17 +7230,17 @@ function Vn({
7230
7230
  P.key === "Enter" && !P.shiftKey ? (P.preventDefault(), Cn()) : P.key === "Escape" && B && (P.preventDefault(), Yt());
7231
7231
  }, se = (P) => {
7232
7232
  const J = Array.from(P.target.files || []);
7233
- D((le) => [...le, ...J]);
7234
- }, xe = (P) => D((J) => J.filter((le, ue) => P !== ue)), Ne = async (P) => {
7233
+ D((ue) => [...ue, ...J]);
7234
+ }, xe = (P) => D((J) => J.filter((ue, le) => P !== le)), Ne = async (P) => {
7235
7235
  const J = (P.target.files || [])[0];
7236
7236
  if (J) {
7237
7237
  ae(null), j(null), Q(!0);
7238
7238
  try {
7239
- const le = await I.uploadExcel(J), ue = le.sheets.map((at) => `${at.sheetName} -> ${at.tableName}`).join(", "), De = ue ? `Uploaded ${J.name} (${le.sheets.length} sheet${le.sheets.length === 1 ? "" : "s"}: ${ue})` : `Uploaded ${J.name}`;
7240
- j(De), d == null || d({ file: J, response: le });
7241
- } catch (le) {
7242
- const ue = le instanceof Error ? le.message : "Failed to upload Excel file";
7243
- console.error("Excel upload failed", le), ae(ue), p == null || p(ue);
7239
+ const ue = await I.uploadExcel(J), le = ue.sheets.map((at) => `${at.sheetName} -> ${at.tableName}`).join(", "), De = le ? `Uploaded ${J.name} (${ue.sheets.length} sheet${ue.sheets.length === 1 ? "" : "s"}: ${le})` : `Uploaded ${J.name}`;
7240
+ j(De), d == null || d({ file: J, response: ue });
7241
+ } catch (ue) {
7242
+ const le = ue instanceof Error ? ue.message : "Failed to upload Excel file";
7243
+ console.error("Excel upload failed", ue), ae(le), p == null || p(le);
7244
7244
  } finally {
7245
7245
  Q(!1), P.target.value = "";
7246
7246
  }
@@ -7318,10 +7318,10 @@ function Vn({
7318
7318
  layoutSize: Tt,
7319
7319
  truncateToolMessages: !1,
7320
7320
  toolMessagePreviewLength: 200,
7321
- onEdit: (le, ue) => Wr(le, ue),
7321
+ onEdit: (ue, le) => Wr(ue, le),
7322
7322
  onRegenerate: () => {
7323
- const le = [...v].reverse().find((De) => De.role === "user"), ue = le ? Sn(le) : "";
7324
- ue && w(ue, { checkpointId: X || y || void 0 });
7323
+ const ue = [...v].reverse().find((De) => De.role === "user"), le = ue ? Sn(ue) : "";
7324
+ le && w(le, { checkpointId: X || y || void 0 });
7325
7325
  },
7326
7326
  onCancelEdit: Yt
7327
7327
  },
package/dist/index.umd.js CHANGED
@@ -55,7 +55,7 @@
55
55
  `)},_i=function(){var e=parseInt(document.body.getAttribute(Dt)||"0",10);return isFinite(e)?e:0},Ng=function(){d.useEffect(function(){return document.body.setAttribute(Dt,(_i()+1).toString()),function(){var e=_i()-1;e<=0?document.body.removeAttribute(Dt):document.body.setAttribute(Dt,e.toString())}},[])},Tg=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;Ng();var s=d.useMemo(function(){return Sg(o)},[o]);return d.createElement(Cg,{styles:Eg(s,!t,o,r?"":"!important")})},Lo=!1;if(typeof window<"u")try{var Zr=Object.defineProperty({},"passive",{get:function(){return Lo=!0,!0}});window.addEventListener("test",Zr,Zr),window.removeEventListener("test",Zr,Zr)}catch{Lo=!1}var Lt=Lo?{passive:!1}:!1,Ag=function(e){return e.tagName==="TEXTAREA"},ki=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!Ag(e)&&r[t]==="visible")},Pg=function(e){return ki(e,"overflowY")},Ig=function(e){return ki(e,"overflowX")},Oi=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=Mi(e,n);if(o){var s=Di(e,n),a=s[1],c=s[2];if(a>c)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},_g=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},kg=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},Mi=function(e,t){return e==="v"?Pg(t):Ig(t)},Di=function(e,t){return e==="v"?_g(t):kg(t)},Og=function(e,t){return e==="h"&&t==="rtl"?-1:1},Mg=function(e,t,r,n,o){var s=Og(e,window.getComputedStyle(t).direction),a=s*n,c=r.target,l=t.contains(c),f=!1,u=a>0,p=0,h=0;do{if(!c)break;var v=Di(e,c),m=v[0],g=v[1],b=v[2],w=g-b-s*m;(m||w)&&Mi(e,c)&&(p+=w,h+=m);var x=c.parentNode;c=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!l&&c!==document.body||l&&(t.contains(c)||t===c));return(u&&Math.abs(p)<1||!u&&Math.abs(h)<1)&&(f=!0),f},Qr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Li=function(e){return[e.deltaX,e.deltaY]},Fi=function(e){return e&&"current"in e?e.current:e},Dg=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Lg=function(e){return`
56
56
  .block-interactivity-`.concat(e,` {pointer-events: none;}
57
57
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
58
- `)},Fg=0,Ft=[];function $g(e){var t=d.useRef([]),r=d.useRef([0,0]),n=d.useRef(),o=d.useState(Fg++)[0],s=d.useState(Ii)[0],a=d.useRef(e);d.useEffect(function(){a.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=og([e.lockRef.current],(e.shards||[]).map(Fi),!0).filter(Boolean);return g.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=d.useCallback(function(g,b){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var w=Qr(g),x=r.current,y="deltaX"in g?g.deltaX:x[0]-w[0],C="deltaY"in g?g.deltaY:x[1]-w[1],N,k=g.target,E=Math.abs(y)>Math.abs(C)?"h":"v";if("touches"in g&&E==="h"&&k.type==="range")return!1;var M=Oi(E,k);if(!M)return!0;if(M?N=E:(N=E==="v"?"h":"v",M=Oi(E,k)),!M)return!1;if(!n.current&&"changedTouches"in g&&(y||C)&&(n.current=N),!N)return!0;var F=n.current||N;return Mg(F,b,g,F==="h"?y:C)},[]),l=d.useCallback(function(g){var b=g;if(!(!Ft.length||Ft[Ft.length-1]!==s)){var w="deltaY"in b?Li(b):Qr(b),x=t.current.filter(function(N){return N.name===b.type&&(N.target===b.target||b.target===N.shadowParent)&&Dg(N.delta,w)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var y=(a.current.shards||[]).map(Fi).filter(Boolean).filter(function(N){return N.contains(b.target)}),C=y.length>0?c(b,y[0]):!a.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),f=d.useCallback(function(g,b,w,x){var y={name:g,delta:b,target:w,should:x,shadowParent:Bg(w)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(C){return C!==y})},1)},[]),u=d.useCallback(function(g){r.current=Qr(g),n.current=void 0},[]),p=d.useCallback(function(g){f(g.type,Li(g),g.target,c(g,e.lockRef.current))},[]),h=d.useCallback(function(g){f(g.type,Qr(g),g.target,c(g,e.lockRef.current))},[]);d.useEffect(function(){return Ft.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Lt),document.addEventListener("touchmove",l,Lt),document.addEventListener("touchstart",u,Lt),function(){Ft=Ft.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Lt),document.removeEventListener("touchmove",l,Lt),document.removeEventListener("touchstart",u,Lt)}},[]);var v=e.removeScrollBar,m=e.inert;return d.createElement(d.Fragment,null,m?d.createElement(s,{styles:Lg(o)}):null,v?d.createElement(Tg,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Bg(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ug=pg(Pi,$g);var en=d.forwardRef(function(e,t){return d.createElement(Jr,Je({},e,{ref:t,sideCar:Ug}))});en.classNames=Jr.classNames;var Fo=["Enter"," "],Hg=["ArrowDown","PageUp","Home"],$i=["ArrowUp","PageDown","End"],zg=[...Hg,...$i],Wg={ltr:[...Fo,"ArrowRight"],rtl:[...Fo,"ArrowLeft"]},Vg={ltr:["ArrowLeft"],rtl:["ArrowRight"]},rr="Menu",[nr,jg,Kg]=oo(rr),[bt,Bi]=Be(rr,[Kg,Ot,wi]),tn=Ot(),Ui=wi(),[Rg,vt]=bt(rr),[Gg,or]=bt(rr),Hi=e=>{const{__scopeMenu:t,open:r=!1,children:n,dir:o,onOpenChange:s,modal:a=!0}=e,c=tn(t),[l,f]=d.useState(null),u=d.useRef(!1),p=we(s),h=Dr(o);return d.useEffect(()=>{const v=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),i.jsx(Eo,{...c,children:i.jsx(Rg,{scope:t,open:r,onOpenChange:p,content:l,onContentChange:f,children:i.jsx(Gg,{scope:t,onClose:d.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:h,modal:a,children:n})})})};Hi.displayName=rr;var qg="MenuAnchor",$o=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e,o=tn(r);return i.jsx(No,{...o,...n,ref:t})});$o.displayName=qg;var Bo="MenuPortal",[Xg,zi]=bt(Bo,{forceMount:void 0}),Wi=e=>{const{__scopeMenu:t,forceMount:r,children:n,container:o}=e,s=vt(Bo,t);return i.jsx(Xg,{scope:t,forceMount:r,children:i.jsx(Ae,{present:r||s.open,children:i.jsx(Rr,{asChild:!0,container:o,children:n})})})};Wi.displayName=Bo;var Me="MenuContent",[Yg,Uo]=bt(Me),Vi=d.forwardRef((e,t)=>{const r=zi(Me,e.__scopeMenu),{forceMount:n=r.forceMount,...o}=e,s=vt(Me,e.__scopeMenu),a=or(Me,e.__scopeMenu);return i.jsx(nr.Provider,{scope:e.__scopeMenu,children:i.jsx(Ae,{present:n||s.open,children:i.jsx(nr.Slot,{scope:e.__scopeMenu,children:a.modal?i.jsx(Jg,{...o,ref:t}):i.jsx(Zg,{...o,ref:t})})})})}),Jg=d.forwardRef((e,t)=>{const r=vt(Me,e.__scopeMenu),n=d.useRef(null),o=ie(t,n);return d.useEffect(()=>{const s=n.current;if(s)return ko(s)},[]),i.jsx(Ho,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:H(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Zg=d.forwardRef((e,t)=>{const r=vt(Me,e.__scopeMenu);return i.jsx(Ho,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Qg=Ie.createSlot("MenuContent.ScrollLock"),Ho=d.forwardRef((e,t)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:h,onDismiss:v,disableOutsideScroll:m,...g}=e,b=vt(Me,r),w=or(Me,r),x=tn(r),y=Ui(r),C=jg(r),[N,k]=d.useState(null),E=d.useRef(null),M=ie(t,E,b.onContentChange),F=d.useRef(0),_=d.useRef(""),B=d.useRef(0),R=d.useRef(null),U=d.useRef("right"),D=d.useRef(0),z=m?en:d.Fragment,O=m?{as:Qg,allowPinchZoom:!0}:void 0,G=A=>{var W,V;const ee=_.current+A,q=C().filter(se=>!se.disabled),ce=document.activeElement,$=(W=q.find(se=>se.ref.current===ce))==null?void 0:W.textValue,j=q.map(se=>se.textValue),le=um(j,ee,$),he=(V=q.find(se=>se.textValue===le))==null?void 0:V.ref.current;(function se(K){_.current=K,window.clearTimeout(F.current),K!==""&&(F.current=window.setTimeout(()=>se(""),1e3))})(ee),he&&setTimeout(()=>he.focus())};d.useEffect(()=>()=>window.clearTimeout(F.current),[]),io();const L=d.useCallback(A=>{var q,ce;return U.current===((q=R.current)==null?void 0:q.side)&&pm(A,(ce=R.current)==null?void 0:ce.area)},[]);return i.jsx(Yg,{scope:r,searchRef:_,onItemEnter:d.useCallback(A=>{L(A)&&A.preventDefault()},[L]),onItemLeave:d.useCallback(A=>{var ee;L(A)||((ee=E.current)==null||ee.focus(),k(null))},[L]),onTriggerLeave:d.useCallback(A=>{L(A)&&A.preventDefault()},[L]),pointerGraceTimerRef:B,onPointerGraceIntentChange:d.useCallback(A=>{R.current=A},[]),children:i.jsx(z,{...O,children:i.jsx(Lr,{asChild:!0,trapped:o,onMountAutoFocus:H(s,A=>{var ee;A.preventDefault(),(ee=E.current)==null||ee.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:i.jsx(Jt,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:h,onDismiss:v,children:i.jsx(Qh,{asChild:!0,...y,dir:w.dir,orientation:"vertical",loop:n,currentTabStopId:N,onCurrentTabStopIdChange:k,onEntryFocus:H(l,A=>{w.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(To,{role:"menu","aria-orientation":"vertical","data-state":ac(b.open),"data-radix-menu-content":"",dir:w.dir,...x,...g,ref:M,style:{outline:"none",...g.style},onKeyDown:H(g.onKeyDown,A=>{const q=A.target.closest("[data-radix-menu-content]")===A.currentTarget,ce=A.ctrlKey||A.altKey||A.metaKey,$=A.key.length===1;q&&(A.key==="Tab"&&A.preventDefault(),!ce&&$&&G(A.key));const j=E.current;if(A.target!==j||!zg.includes(A.key))return;A.preventDefault();const he=C().filter(W=>!W.disabled).map(W=>W.ref.current);$i.includes(A.key)&&he.reverse(),lm(he)}),onBlur:H(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(F.current),_.current="")}),onPointerMove:H(e.onPointerMove,ar(A=>{const ee=A.target,q=D.current!==A.clientX;if(A.currentTarget.contains(ee)&&q){const ce=A.clientX>D.current?"right":"left";U.current=ce,D.current=A.clientX}}))})})})})})})});Vi.displayName=Me;var em="MenuGroup",zo=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(te.div,{role:"group",...n,ref:t})});zo.displayName=em;var tm="MenuLabel",ji=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(te.div,{...n,ref:t})});ji.displayName=tm;var rn="MenuItem",Ki="menu.itemSelect",nn=d.forwardRef((e,t)=>{const{disabled:r=!1,onSelect:n,...o}=e,s=d.useRef(null),a=or(rn,e.__scopeMenu),c=Uo(rn,e.__scopeMenu),l=ie(t,s),f=d.useRef(!1),u=()=>{const p=s.current;if(!r&&p){const h=new CustomEvent(Ki,{bubbles:!0,cancelable:!0});p.addEventListener(Ki,v=>n==null?void 0:n(v),{once:!0}),wa(p,h),h.defaultPrevented?f.current=!1:a.onClose()}};return i.jsx(Ri,{...o,ref:l,disabled:r,onClick:H(e.onClick,u),onPointerDown:p=>{var h;(h=e.onPointerDown)==null||h.call(e,p),f.current=!0},onPointerUp:H(e.onPointerUp,p=>{var h;f.current||(h=p.currentTarget)==null||h.click()}),onKeyDown:H(e.onKeyDown,p=>{const h=c.searchRef.current!=="";r||h&&p.key===" "||Fo.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});nn.displayName=rn;var Ri=d.forwardRef((e,t)=>{const{__scopeMenu:r,disabled:n=!1,textValue:o,...s}=e,a=Uo(rn,r),c=Ui(r),l=d.useRef(null),f=ie(t,l),[u,p]=d.useState(!1),[h,v]=d.useState("");return d.useEffect(()=>{const m=l.current;m&&v((m.textContent??"").trim())},[s.children]),i.jsx(nr.ItemSlot,{scope:r,disabled:n,textValue:o??h,children:i.jsx(eg,{asChild:!0,...c,focusable:!n,children:i.jsx(te.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...s,ref:f,onPointerMove:H(e.onPointerMove,ar(m=>{n?a.onItemLeave(m):(a.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:H(e.onPointerLeave,ar(m=>a.onItemLeave(m))),onFocus:H(e.onFocus,()=>p(!0)),onBlur:H(e.onBlur,()=>p(!1))})})})}),rm="MenuCheckboxItem",Gi=d.forwardRef((e,t)=>{const{checked:r=!1,onCheckedChange:n,...o}=e;return i.jsx(Zi,{scope:e.__scopeMenu,checked:r,children:i.jsx(nn,{role:"menuitemcheckbox","aria-checked":on(r)?"mixed":r,...o,ref:t,"data-state":Vo(r),onSelect:H(o.onSelect,()=>n==null?void 0:n(on(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Gi.displayName=rm;var qi="MenuRadioGroup",[nm,om]=bt(qi,{value:void 0,onValueChange:()=>{}}),Xi=d.forwardRef((e,t)=>{const{value:r,onValueChange:n,...o}=e,s=we(n);return i.jsx(nm,{scope:e.__scopeMenu,value:r,onValueChange:s,children:i.jsx(zo,{...o,ref:t})})});Xi.displayName=qi;var Yi="MenuRadioItem",Ji=d.forwardRef((e,t)=>{const{value:r,...n}=e,o=om(Yi,e.__scopeMenu),s=r===o.value;return i.jsx(Zi,{scope:e.__scopeMenu,checked:s,children:i.jsx(nn,{role:"menuitemradio","aria-checked":s,...n,ref:t,"data-state":Vo(s),onSelect:H(n.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,r)},{checkForDefaultPrevented:!1})})})});Ji.displayName=Yi;var Wo="MenuItemIndicator",[Zi,sm]=bt(Wo,{checked:!1}),Qi=d.forwardRef((e,t)=>{const{__scopeMenu:r,forceMount:n,...o}=e,s=sm(Wo,r);return i.jsx(Ae,{present:n||on(s.checked)||s.checked===!0,children:i.jsx(te.span,{...o,ref:t,"data-state":Vo(s.checked)})})});Qi.displayName=Wo;var am="MenuSeparator",ec=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(te.div,{role:"separator","aria-orientation":"horizontal",...n,ref:t})});ec.displayName=am;var im="MenuArrow",tc=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e,o=tn(r);return i.jsx(Ao,{...o,...n,ref:t})});tc.displayName=im;var cm="MenuSub",[Yw,rc]=bt(cm),sr="MenuSubTrigger",nc=d.forwardRef((e,t)=>{const r=vt(sr,e.__scopeMenu),n=or(sr,e.__scopeMenu),o=rc(sr,e.__scopeMenu),s=Uo(sr,e.__scopeMenu),a=d.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:l}=s,f={__scopeMenu:e.__scopeMenu},u=d.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return d.useEffect(()=>u,[u]),d.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),l(null)}},[c,l]),i.jsx($o,{asChild:!0,...f,children:i.jsx(Ri,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":o.contentId,"data-state":ac(r.open),...e,ref:Qn(t,o.onTriggerChange),onClick:p=>{var h;(h=e.onClick)==null||h.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:H(e.onPointerMove,ar(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!r.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100))})),onPointerLeave:H(e.onPointerLeave,ar(p=>{var v,m;u();const h=(v=r.content)==null?void 0:v.getBoundingClientRect();if(h){const g=(m=r.content)==null?void 0:m.dataset.side,b=g==="right",w=b?-5:5,x=h[b?"left":"right"],y=h[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x,y:h.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:H(e.onKeyDown,p=>{var v;const h=s.searchRef.current!=="";e.disabled||h&&p.key===" "||Wg[n.dir].includes(p.key)&&(r.onOpenChange(!0),(v=r.content)==null||v.focus(),p.preventDefault())})})})});nc.displayName=sr;var oc="MenuSubContent",sc=d.forwardRef((e,t)=>{const r=zi(Me,e.__scopeMenu),{forceMount:n=r.forceMount,...o}=e,s=vt(Me,e.__scopeMenu),a=or(Me,e.__scopeMenu),c=rc(oc,e.__scopeMenu),l=d.useRef(null),f=ie(t,l);return i.jsx(nr.Provider,{scope:e.__scopeMenu,children:i.jsx(Ae,{present:n||s.open,children:i.jsx(nr.Slot,{scope:e.__scopeMenu,children:i.jsx(Ho,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:f,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var p;a.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:H(e.onFocusOutside,u=>{u.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:H(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:H(e.onKeyDown,u=>{var v;const p=u.currentTarget.contains(u.target),h=Vg[a.dir].includes(u.key);p&&h&&(s.onOpenChange(!1),(v=c.trigger)==null||v.focus(),u.preventDefault())})})})})})});sc.displayName=oc;function ac(e){return e?"open":"closed"}function on(e){return e==="indeterminate"}function Vo(e){return on(e)?"indeterminate":e?"checked":"unchecked"}function lm(e){const t=document.activeElement;for(const r of e)if(r===t||(r.focus(),document.activeElement!==t))return}function dm(e,t){return e.map((r,n)=>e[(t+n)%e.length])}function um(e,t,r){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let a=dm(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==r));const l=a.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return l!==r?l:void 0}function fm(e,t){const{x:r,y:n}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],l=t[a],f=c.x,u=c.y,p=l.x,h=l.y;u>n!=h>n&&r<(p-f)*(n-u)/(h-u)+f&&(o=!o)}return o}function pm(e,t){if(!t)return!1;const r={x:e.clientX,y:e.clientY};return fm(r,t)}function ar(e){return t=>t.pointerType==="mouse"?e(t):void 0}var hm=Hi,gm=$o,mm=Wi,bm=Vi,vm=zo,wm=ji,ym=nn,xm=Gi,Sm=Xi,Cm=Ji,Em=Qi,Nm=ec,Tm=tc,Am=nc,Pm=sc,sn="DropdownMenu",[Im,Jw]=Be(sn,[Bi]),Se=Bi(),[_m,ic]=Im(sn),cc=e=>{const{__scopeDropdownMenu:t,children:r,dir:n,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,l=Se(t),f=d.useRef(null),[u,p]=ot({prop:o,defaultProp:s??!1,onChange:a,caller:sn});return i.jsx(_m,{scope:t,triggerId:Ue(),triggerRef:f,contentId:Ue(),open:u,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(h=>!h),[p]),modal:c,children:i.jsx(hm,{...l,open:u,onOpenChange:p,dir:n,modal:c,children:r})})};cc.displayName=sn;var lc="DropdownMenuTrigger",dc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...o}=e,s=ic(lc,r),a=Se(r);return i.jsx(gm,{asChild:!0,...a,children:i.jsx(te.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...o,ref:Qn(t,s.triggerRef),onPointerDown:H(e.onPointerDown,c=>{!n&&c.button===0&&c.ctrlKey===!1&&(s.onOpenToggle(),s.open||c.preventDefault())}),onKeyDown:H(e.onKeyDown,c=>{n||(["Enter"," "].includes(c.key)&&s.onOpenToggle(),c.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});dc.displayName=lc;var km="DropdownMenuPortal",uc=e=>{const{__scopeDropdownMenu:t,...r}=e,n=Se(t);return i.jsx(mm,{...n,...r})};uc.displayName=km;var fc="DropdownMenuContent",pc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ic(fc,r),s=Se(r),a=d.useRef(!1);return i.jsx(bm,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...n,ref:t,onCloseAutoFocus:H(e.onCloseAutoFocus,c=>{var l;a.current||(l=o.triggerRef.current)==null||l.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:H(e.onInteractOutside,c=>{const l=c.detail.originalEvent,f=l.button===0&&l.ctrlKey===!0,u=l.button===2||f;(!o.modal||u)&&(a.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)"}})});pc.displayName=fc;var Om="DropdownMenuGroup",Mm=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(vm,{...o,...n,ref:t})});Mm.displayName=Om;var Dm="DropdownMenuLabel",hc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(wm,{...o,...n,ref:t})});hc.displayName=Dm;var Lm="DropdownMenuItem",gc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(ym,{...o,...n,ref:t})});gc.displayName=Lm;var Fm="DropdownMenuCheckboxItem",mc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(xm,{...o,...n,ref:t})});mc.displayName=Fm;var $m="DropdownMenuRadioGroup",Bm=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Sm,{...o,...n,ref:t})});Bm.displayName=$m;var Um="DropdownMenuRadioItem",bc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Cm,{...o,...n,ref:t})});bc.displayName=Um;var Hm="DropdownMenuItemIndicator",vc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Em,{...o,...n,ref:t})});vc.displayName=Hm;var zm="DropdownMenuSeparator",wc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Nm,{...o,...n,ref:t})});wc.displayName=zm;var Wm="DropdownMenuArrow",Vm=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Tm,{...o,...n,ref:t})});Vm.displayName=Wm;var jm="DropdownMenuSubTrigger",yc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Am,{...o,...n,ref:t})});yc.displayName=jm;var Km="DropdownMenuSubContent",xc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Pm,{...o,...n,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)"}})});xc.displayName=Km;var Rm=cc,Gm=dc,qm=uc,Sc=pc,Cc=hc,Ec=gc,Nc=mc,Tc=bc,Ac=vc,Pc=wc,Ic=yc,_c=xc;const Xm=Rm,Ym=Gm,Jm=d.forwardRef(({className:e,inset:t,children:r,...n},o)=>i.jsxs(Ic,{ref:o,className:P("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),...n,children:[r,i.jsx(X.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Jm.displayName=Ic.displayName;const Zm=d.forwardRef(({className:e,...t},r)=>i.jsx(_c,{ref:r,className:P("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}));Zm.displayName=_c.displayName;const kc=d.forwardRef(({className:e,sideOffset:t=4,...r},n)=>i.jsx(qm,{children:i.jsx(Sc,{ref:n,sideOffset:t,className:P("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),...r})}));kc.displayName=Sc.displayName;const jo=d.forwardRef(({className:e,inset:t,...r},n)=>i.jsx(Ec,{ref:n,className:P("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),...r}));jo.displayName=Ec.displayName;const Qm=d.forwardRef(({className:e,children:t,checked:r,...n},o)=>i.jsxs(Nc,{ref:o,className:P("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:r,...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Ac,{children:i.jsx(X.Check,{className:"h-4 w-4"})})}),t]}));Qm.displayName=Nc.displayName;const eb=d.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(Tc,{ref:n,className:P("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),...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Ac,{children:i.jsx(X.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));eb.displayName=Tc.displayName;const tb=d.forwardRef(({className:e,inset:t,...r},n)=>i.jsx(Cc,{ref:n,className:P("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...r}));tb.displayName=Cc.displayName;const rb=d.forwardRef(({className:e,...t},r)=>i.jsx(Pc,{ref:r,className:P("-mx-1 my-1 h-px bg-muted",e),...t}));rb.displayName=Pc.displayName;function ir({className:e="",placeholder:t="Type your message...",autoFocus:r=!0,maxHeight:n=void 0,streamingDebounceMs:o=40,enableFileUpload:s=!0,enableExcelUpload:a=!1,enableMessageEditing:c=!0,customStyles:l={},onMessageSent:f,onExcelUploadSuccess:u,onError:p}){const{currentThreadId:h,messages:v,isStreaming:m,streamingAssistantId:g,error:b,send:w,stop:x,lastCheckpointId:y,listCheckpoints:C,navigateToCheckpoint:N,returnToLatest:k,hasMoreHistory:E,isLoadingHistory:M,loadOlderMessages:F,api:_}=Zn();try{const I=typeof window<"u"?localStorage.getItem("currentThreadId"):null;console.log("ChatInterface debug - useChat()",{currentThreadId:h,lastCheckpointId:y,lsThread:I})}catch(I){console.log("ChatInterface debug - localStorage not available",I)}const[B,R]=T.useState(""),[U,D]=T.useState(null),[z,O]=T.useState(null),[G,L]=T.useState([]),[A,ee]=T.useState(!1),[q,ce]=T.useState(null),[$,j]=T.useState(null),[le,he]=T.useState(!1),[W,V]=T.useState(null),[se,K]=T.useState([]),[Y,ne]=T.useState(null),me=T.useRef(null),pe=T.useRef(null),Q=T.useRef(null),J=T.useRef(null),ge=T.useRef(null),Oe=T.useRef(!1),Ce=T.useRef(!0),pr=T.useRef(0),ut=T.useRef(null),[Ht,gs]=T.useState("desktop");T.useEffect(()=>{const I=()=>{const Z=window.innerWidth;gs(Z<640?"phone":Z<1024?"tablet":"desktop")};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),T.useEffect(()=>{let I=!1;if(!h){K([]),ne(null),ut.current=null;return}const Z={threadId:h,checkpointId:y??null},de=ut.current;if(!(de&&de.threadId===Z.threadId&&de.checkpointId===Z.checkpointId))return ut.current=Z,C(h).then(ue=>{if(console.log("ChatInterface debug - listCheckpoints response:",ue),I)return;const Fe=((ue==null?void 0:ue.checkpoints)??[]).slice().sort((ft,Dn)=>new Date(Dn.createdAt).getTime()-new Date(ft.createdAt).getTime());console.log("ChatInterface debug - computed checkpoints:",Fe),K(Fe),ne(ft=>{var Dn;return ft??((Dn=Fe[0])==null?void 0:Dn.checkpointId)??null})}).catch(()=>{I||(K([]),ut.current=null)}),()=>{I=!0}},[h,y,C]),T.useEffect(()=>{y&&ne(y)},[y]);const zt=T.useCallback(async()=>{if(!E||M)return;const I=ge.current;if(!I)return;const Z=I.scrollHeight,de=I.scrollTop;Oe.current=!0;try{await F()}catch(ue){console.warn("loadOlderMessages failed",ue)}finally{requestAnimationFrame(()=>{const ue=ge.current;if(!ue){Oe.current=!1;return}const Fe=ue.scrollHeight;ue.scrollTop=de+(Fe-Z);const ft=Fe-ue.scrollTop-ue.clientHeight;Ce.current=ft<=32,Oe.current=!1})}},[E,M,F]);T.useEffect(()=>{const I=ge.current;if(!I)return;const Z=()=>{I.scrollTop<=80&&zt();const Fe=I.scrollHeight-I.scrollTop-I.clientHeight;Ce.current=Fe<=80};return I.addEventListener("scroll",Z),()=>I.removeEventListener("scroll",Z)},[zt]),T.useEffect(()=>{v.length<pr.current&&(Ce.current=!0),pr.current=v.length},[v.length]),T.useEffect(()=>{const I=ge.current;I&&(Oe.current||Ce.current&&(I.scrollTop=I.scrollHeight,Ce.current=!0))},[v]),T.useEffect(()=>{var I;r&&((I=pe.current)==null||I.focus())},[r]),T.useEffect(()=>{(async()=>{try{const Z=await _.getAgent("default");V(Z.uiDefaultMessage||null)}catch(Z){console.warn("Failed to fetch default message:",Z),V(null)}})()},[_]),T.useEffect(()=>{b&&!le&&(p==null||p(b))},[b,le,p]);const ms=I=>{if(I.length>At)return`Message too long (${I.length}/${At} characters)`;try{return ip(I),null}catch(Z){return(Z==null?void 0:Z.message)||"Invalid message"}},In=I=>{const Z=I.content||[],de=Z.filter(ue=>ue.type==="text").map(ue=>ue.text).join("");if(de)return de;try{return JSON.stringify(Z,null,2)}catch{return String(Z)}},_n=async()=>{const I=B.trim();if(!(!I&&G.length===0)){if(I){const Z=ms(I);if(Z){O(Z);return}}try{await w(I,{checkpointId:Y||y||void 0,payloadExtras:U?{edit:!0,originalMessageId:U}:void 0,attachments:G}),f==null||f(I),R(""),O(null),L([]),D(null),pe.current&&(pe.current.style.height="auto")}catch(Z){const de=(Z==null?void 0:Z.message)||"Failed to send message";O(de),p==null||p(de)}}},bs=(I,Z)=>{c&&(D(I),R(Z),O(null),setTimeout(()=>{pe.current&&(pe.current.focus(),pe.current.style.height="auto",pe.current.style.height=pe.current.scrollHeight+"px")},0))},hr=()=>{D(null),R(""),O(null),pe.current&&(pe.current.style.height="auto")},kn=I=>{I.key==="Enter"&&!I.shiftKey?(I.preventDefault(),_n()):I.key==="Escape"&&U&&(I.preventDefault(),hr())},ae=I=>{const Z=Array.from(I.target.files||[]);L(de=>[...de,...Z])},xe=I=>L(Z=>Z.filter((de,ue)=>I!==ue)),Pe=async I=>{const Z=(I.target.files||[])[0];if(Z){ce(null),j(null),ee(!0);try{const de=await _.uploadExcel(Z),ue=de.sheets.map(ft=>`${ft.sheetName} -> ${ft.tableName}`).join(", "),Fe=ue?`Uploaded ${Z.name} (${de.sheets.length} sheet${de.sheets.length===1?"":"s"}: ${ue})`:`Uploaded ${Z.name}`;j(Fe),u==null||u({file:Z,response:de})}catch(de){const ue=de instanceof Error?de.message:"Failed to upload Excel file";console.error("Excel upload failed",de),ce(ue),p==null||p(ue)}finally{ee(!1),I.target.value=""}}},je=I=>{if(!I)return"Unknown";const Z=Date.parse(I);return Number.isNaN(Z)?I:new Date(Z).toLocaleString()},rt=async I=>{if(h){if(!I){await k(),ne(null);return}await N(I),ne(I)}},On=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${l.container||""}`,Mn=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-y-auto overflow-x-auto overscroll-contain break-words break-anywhere p-4 space-y-4 bg-transparent ${l.messagesArea||""}`,vs=`flex-shrink-0 w-full border-t p-4 bg-transparent ${l.inputArea||""}`;return i.jsxs("div",{className:On,children:[!!b&&!le&&i.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[i.jsx("span",{children:b}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>he(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:i.jsx(X.X,{size:16})})]}),(console.log("Checkpoint toolbar render",{currentThreadId:h,checkpoints:se,activeCheckpointId:Y}),null),h&&se.length>0&&i.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[i.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),i.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:Y??"",onChange:I=>{const Z=I.target.value||null;rt(Z)},children:[i.jsx("option",{value:"",children:"Latest"}),se.map(I=>i.jsxs("option",{value:I.checkpointId,children:[je(I.createdAt),I.preview?` — ${I.preview.slice(0,40)}`:""]},I.checkpointId))]})]}),i.jsxs("div",{ref:ge,className:Mn,style:n?{maxHeight:n}:void 0,children:[v.length===0?i.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:W||"No messages yet. Start a conversation!"}):i.jsxs(i.Fragment,{children:[(M||!E)&&i.jsx("div",{className:"flex justify-center py-2 text-xs text-muted-foreground",children:M?i.jsx(X.Loader2,{className:"h-4 w-4 animate-spin"}):"You've reached the beginning"}),v.map((I,Z)=>i.jsx(Na,{message:I,messageIndex:Z,isStreamingMessage:m&&g===I.id,streamingDebounceMs:o,isEditing:U===I.id,showActions:c,showTimestamp:!1,showAgentName:!0,layoutSize:Ht,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:(de,ue)=>bs(de,ue),onRegenerate:()=>{const de=[...v].reverse().find(Fe=>Fe.role==="user"),ue=de?In(de):"";ue&&w(ue,{checkpointId:Y||y||void 0})},onCancelEdit:hr},I.id||Z))]}),i.jsx("div",{ref:me})]}),i.jsxs("div",{className:vs,children:[U&&i.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(X.Edit3,{size:16,className:"text-blue-600"}),i.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:hr,className:"text-blue-600 hover:bg-blue-100",children:i.jsx(X.X,{size:16})})]})}),(s||a)&&i.jsxs("div",{className:"mb-3 space-y-3",children:[s&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:Q,type:"file",multiple:!0,onChange:I=>ae(I),className:"hidden"}),G.length>0&&i.jsx("div",{className:"flex flex-wrap gap-2",children:G.map((I,Z)=>i.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[i.jsx(X.Paperclip,{size:14}),i.jsx("span",{className:"truncate max-w-[150px]",children:I.name}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>xe(Z),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${I.name}`,children:i.jsx(X.X,{size:12})})]},Z))})]}),a&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:J,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Pe,className:"hidden"}),A&&i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(X.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),$&&!A&&i.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:$}),q&&!A&&i.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:q})]})]}),z&&i.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:z}),i.jsxs("div",{className:"flex items-end gap-2",children:[(s||a)&&i.jsxs(Xm,{children:[i.jsx(Ym,{asChild:!0,children:i.jsx(fe,{type:"button",size:"icon",variant:"outline",disabled:m,title:"More input actions",className:l.moreButton||"",children:i.jsx(X.Plus,{size:16})})}),i.jsxs(kc,{align:"start",sideOffset:6,className:"w-52",children:[s&&i.jsxs(jo,{onClick:()=>{var I;return(I=Q.current)==null?void 0:I.click()},className:"cursor-pointer",children:[i.jsx(X.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),a&&i.jsxs(jo,{onClick:()=>{var I;A||(I=J.current)==null||I.click()},className:`cursor-pointer ${A?"opacity-60 pointer-events-none":""}`,children:[i.jsx(X.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),i.jsx("div",{className:"flex-1",children:i.jsx(ma,{ref:pe,value:B,onChange:I=>{R(I.target.value),O(null),pe.current&&(pe.current.style.height="auto",pe.current.style.height=`${pe.current.scrollHeight}px`)},onKeyDown:kn,placeholder:U?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${U?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${z?"border-red-400":""} ${l.textarea||""}`,disabled:!1,maxLength:At,rows:1})}),i.jsx("div",{children:m?i.jsx(fe,{type:"button",onClick:x,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:i.jsx(X.Square,{size:16})}):i.jsx(fe,{type:"button",onClick:_n,size:"icon",disabled:!B.trim()&&G.length===0,className:`shrink-0 ${G.length>0?"bg-blue-500 hover:bg-blue-600 text-white":""} ${l.sendButton||""}`,title:U?"Save changes":"Send message",children:i.jsx(X.Send,{size:16})})})]}),B.length>At*.8&&i.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[B.length,"/",At]})]})]})}const cr=d.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:P("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:n,...r}));cr.displayName="Input";function Ko(e,[t,r]){return Math.min(r,Math.max(t,e))}function nb(e,t){return d.useReducer((r,n)=>t[r][n]??r,e)}var Ro="ScrollArea",[Oc,Zw]=Be(Ro),[ob,De]=Oc(Ro),Mc=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...a}=e,[c,l]=d.useState(null),[f,u]=d.useState(null),[p,h]=d.useState(null),[v,m]=d.useState(null),[g,b]=d.useState(null),[w,x]=d.useState(0),[y,C]=d.useState(0),[N,k]=d.useState(!1),[E,M]=d.useState(!1),F=ie(t,B=>l(B)),_=Dr(o);return i.jsx(ob,{scope:r,type:n,dir:_,scrollHideDelay:s,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:h,scrollbarX:v,onScrollbarXChange:m,scrollbarXEnabled:N,onScrollbarXEnabledChange:k,scrollbarY:g,onScrollbarYChange:b,scrollbarYEnabled:E,onScrollbarYEnabledChange:M,onCornerWidthChange:x,onCornerHeightChange:C,children:i.jsx(te.div,{dir:_,...a,ref:F,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Mc.displayName=Ro;var Dc="ScrollAreaViewport",Lc=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,a=De(Dc,r),c=d.useRef(null),l=ie(t,c,a.onViewportChange);return i.jsxs(i.Fragment,{children:[i.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}),i.jsx(te.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:i.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});Lc.displayName=Dc;var Ze="ScrollAreaScrollbar",Go=d.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=De(Ze,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=o,c=e.orientation==="horizontal";return d.useEffect(()=>(c?s(!0):a(!0),()=>{c?s(!1):a(!1)}),[c,s,a]),o.type==="hover"?i.jsx(sb,{...n,ref:t,forceMount:r}):o.type==="scroll"?i.jsx(ab,{...n,ref:t,forceMount:r}):o.type==="auto"?i.jsx(Fc,{...n,ref:t,forceMount:r}):o.type==="always"?i.jsx(qo,{...n,ref:t}):null});Go.displayName=Ze;var sb=d.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=De(Ze,e.__scopeScrollArea),[s,a]=d.useState(!1);return d.useEffect(()=>{const c=o.scrollArea;let l=0;if(c){const f=()=>{window.clearTimeout(l),a(!0)},u=()=>{l=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),i.jsx(Ae,{present:r||s,children:i.jsx(Fc,{"data-state":s?"visible":"hidden",...n,ref:t})})}),ab=d.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=De(Ze,e.__scopeScrollArea),s=e.orientation==="horizontal",a=dn(()=>l("SCROLL_END"),100),[c,l]=nb("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 d.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,o.scrollHideDelay,l]),d.useEffect(()=>{const f=o.viewport,u=s?"scrollLeft":"scrollTop";if(f){let p=f[u];const h=()=>{const v=f[u];p!==v&&(l("SCROLL"),a()),p=v};return f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[o.viewport,s,l,a]),i.jsx(Ae,{present:r||c!=="hidden",children:i.jsx(qo,{"data-state":c==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:H(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:H(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Fc=d.forwardRef((e,t)=>{const r=De(Ze,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,a]=d.useState(!1),c=e.orientation==="horizontal",l=dn(()=>{if(r.viewport){const f=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;a(c?f:u)}},10);return $t(r.viewport,l),$t(r.content,l),i.jsx(Ae,{present:n||s,children:i.jsx(qo,{"data-state":s?"visible":"hidden",...o,ref:t})})}),qo=d.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=De(Ze,e.__scopeScrollArea),s=d.useRef(null),a=d.useRef(0),[c,l]=d.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=zc(c.viewport,c.content),u={...n,sizes:c,onSizesChange:l,hasThumb:f>0&&f<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:h=>a.current=h};function p(h,v){return fb(h,a.current,c,v)}return r==="horizontal"?i.jsx(ib,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,v=Wc(h,c,o.dir);s.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=p(h,o.dir))}}):r==="vertical"?i.jsx(cb,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,v=Wc(h,c);s.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=p(h))}}):null}),ib=d.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=De(Ze,e.__scopeScrollArea),[a,c]=d.useState(),l=d.useRef(null),f=ie(t,l,s.onScrollbarXChange);return d.useEffect(()=>{l.current&&c(getComputedStyle(l.current))},[l]),i.jsx(Bc,{"data-orientation":"horizontal",...o,ref:f,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ln(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),jc(h,p)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&a&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:cn(a.paddingLeft),paddingEnd:cn(a.paddingRight)}})}})}),cb=d.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=De(Ze,e.__scopeScrollArea),[a,c]=d.useState(),l=d.useRef(null),f=ie(t,l,s.onScrollbarYChange);return d.useEffect(()=>{l.current&&c(getComputedStyle(l.current))},[l]),i.jsx(Bc,{"data-orientation":"vertical",...o,ref:f,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ln(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),jc(h,p)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&a&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:cn(a.paddingTop),paddingEnd:cn(a.paddingBottom)}})}})}),[lb,$c]=Oc(Ze),Bc=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:c,onThumbPositionChange:l,onDragScroll:f,onWheelScroll:u,onResize:p,...h}=e,v=De(Ze,r),[m,g]=d.useState(null),b=ie(t,F=>g(F)),w=d.useRef(null),x=d.useRef(""),y=v.viewport,C=n.content-n.viewport,N=we(u),k=we(l),E=dn(p,10);function M(F){if(w.current){const _=F.clientX-w.current.left,B=F.clientY-w.current.top;f({x:_,y:B})}}return d.useEffect(()=>{const F=_=>{const B=_.target;(m==null?void 0:m.contains(B))&&N(_,C)};return document.addEventListener("wheel",F,{passive:!1}),()=>document.removeEventListener("wheel",F,{passive:!1})},[y,m,C,N]),d.useEffect(k,[n,k]),$t(m,E),$t(v.content,E),i.jsx(lb,{scope:r,scrollbar:m,hasThumb:o,onThumbChange:we(s),onThumbPointerUp:we(a),onThumbPositionChange:k,onThumbPointerDown:we(c),children:i.jsx(te.div,{...h,ref:b,style:{position:"absolute",...h.style},onPointerDown:H(e.onPointerDown,F=>{F.button===0&&(F.target.setPointerCapture(F.pointerId),w.current=m.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),M(F))}),onPointerMove:H(e.onPointerMove,M),onPointerUp:H(e.onPointerUp,F=>{const _=F.target;_.hasPointerCapture(F.pointerId)&&_.releasePointerCapture(F.pointerId),document.body.style.webkitUserSelect=x.current,v.viewport&&(v.viewport.style.scrollBehavior=""),w.current=null})})})}),an="ScrollAreaThumb",Uc=d.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=$c(an,e.__scopeScrollArea);return i.jsx(Ae,{present:r||o.hasThumb,children:i.jsx(db,{ref:t,...n})})}),db=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=De(an,r),a=$c(an,r),{onThumbPositionChange:c}=a,l=ie(t,p=>a.onThumbChange(p)),f=d.useRef(void 0),u=dn(()=>{f.current&&(f.current(),f.current=void 0)},100);return d.useEffect(()=>{const p=s.viewport;if(p){const h=()=>{if(u(),!f.current){const v=pb(p,c);f.current=v,c()}};return c(),p.addEventListener("scroll",h),()=>p.removeEventListener("scroll",h)}},[s.viewport,u,c]),i.jsx(te.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:H(e.onPointerDownCapture,p=>{const v=p.target.getBoundingClientRect(),m=p.clientX-v.left,g=p.clientY-v.top;a.onThumbPointerDown({x:m,y:g})}),onPointerUp:H(e.onPointerUp,a.onThumbPointerUp)})});Uc.displayName=an;var Xo="ScrollAreaCorner",Hc=d.forwardRef((e,t)=>{const r=De(Xo,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?i.jsx(ub,{...e,ref:t}):null});Hc.displayName=Xo;var ub=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=De(Xo,r),[s,a]=d.useState(0),[c,l]=d.useState(0),f=!!(s&&c);return $t(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),$t(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),a(u)}),f?i.jsx(te.div,{...n,ref:t,style:{width:s,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function cn(e){return e?parseInt(e,10):0}function zc(e,t){const r=e/t;return isNaN(r)?0:r}function ln(e){const t=zc(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function fb(e,t,r,n="ltr"){const o=ln(r),s=o/2,a=t||s,c=o-a,l=r.scrollbar.paddingStart+a,f=r.scrollbar.size-r.scrollbar.paddingEnd-c,u=r.content-r.viewport,p=n==="ltr"?[0,u]:[u*-1,0];return Vc([l,f],p)(e)}function Wc(e,t,r="ltr"){const n=ln(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,a=t.content-t.viewport,c=s-n,l=r==="ltr"?[0,a]:[a*-1,0],f=Ko(e,l);return Vc([0,a],[0,c])(f)}function Vc(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function jc(e,t){return e>0&&e<t}var pb=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},a=r.left!==s.left,c=r.top!==s.top;(a||c)&&t(),r=s,n=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(n)};function dn(e,t){const r=we(e),n=d.useRef(0);return d.useEffect(()=>()=>window.clearTimeout(n.current),[]),d.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function $t(e,t){const r=we(t);ve(()=>{let n=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(n),o.unobserve(e)}}},[e,r])}var Kc=Mc,hb=Lc,gb=Hc;const Rc=d.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(Kc,{ref:n,className:P("relative overflow-hidden",e),...r,children:[i.jsx(hb,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),i.jsx(Gc,{}),i.jsx(gb,{})]}));Rc.displayName=Kc.displayName;const Gc=d.forwardRef(({className:e,orientation:t="vertical",...r},n)=>i.jsx(Go,{ref:n,orientation:t,className:P("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),...r,children:i.jsx(Uc,{className:"relative flex-1 rounded-full bg-border"})}));Gc.displayName=Go.displayName;function un({className:e="",showCreateButton:t=!0,showDeleteButton:r=!0,showEditTitle:n=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:a=null,navigateToThread:c,onThreadSelect:l,onThreadCreate:f,onThreadDelete:u}){const{loadThread:p,threads:h,refreshThreads:v,currentThreadId:m,createThread:g,deleteThread:b,renameThread:w}=Zn(),[x,y]=T.useState(h??[]),[C,N]=T.useState(!1),[k,E]=T.useState(null),[M,F]=T.useState(null),[_,B]=T.useState(""),[R,U]=T.useState(!1);T.useEffect(()=>{y(h??[])},[h]);const D=async $=>{try{await p($),c==null||c($),l==null||l($)}catch(j){console.error("Failed to select thread:",j)}},z=async()=>{try{U(!0);const $=await g();f==null||f($),c==null||c($)}catch($){console.error("Failed to create thread:",$)}finally{U(!1)}},O=async($,j)=>{if(j.stopPropagation(),!!confirm("Delete this thread?"))try{await b($),u==null||u($)}catch(le){console.error("Failed to delete thread:",le)}},G=($,j)=>{j.stopPropagation(),F($.threadId),B($.title||`Thread ${$.threadId.slice(0,8)}`)},L=async $=>{if(_.trim())try{await w($,_.trim()),F(null),B("")}catch(j){console.error("Failed to update title:",j)}},A=()=>{F(null),B("")},ee=($,j)=>{$.key==="Enter"?L(j):$.key==="Escape"&&A()},q=$=>{if(!$)return"";try{const j=new Date($),he=new Date().getTime()-j.getTime(),W=Math.floor(he/(1e3*60*60*24));return W===0?j.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):W===1?"Yesterday":W<7?`${W} days ago`:j.toLocaleDateString()}catch{return""}},ce=$=>$.title||`Thread ${$.threadId.slice(0,8)}`;return i.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&i.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:i.jsx(fe,{onClick:z,disabled:R||C,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:R?"Creating...":"New Chat",children:i.jsx(X.MessageSquarePlus,{size:20})})}),i.jsx(Rc,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:i.jsx("div",{className:"p-2 space-y-1 pb-4",children:C?i.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):x.length===0?i.jsxs("div",{className:"text-center py-8 text-slate-400",children:[i.jsx(X.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),i.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):x.slice().sort(($,j)=>new Date(j.updatedAt||j.createdAt||"").getTime()-new Date($.updatedAt||$.createdAt||"").getTime()).map($=>i.jsxs("div",{onClick:()=>D($.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(a??m)===$.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"flex-1 min-w-0",children:M===$.threadId?i.jsxs("div",{className:"flex items-center gap-2",onClick:j=>j.stopPropagation(),children:[i.jsx(cr,{value:_,onChange:j=>B(j.target.value),onKeyDown:j=>ee(j,$.threadId),className:"h-6 text-sm",autoFocus:!0}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>L($.threadId),className:"h-6 w-6 p-0",children:i.jsx(X.Check,{size:12})}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:A,className:"h-6 w-6 p-0",children:i.jsx(X.X,{size:12})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ce($)}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[i.jsx(X.Calendar,{size:10}),i.jsx("span",{children:q($.updatedAt||$.createdAt)})]})]})}),i.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[n&&M!==$.threadId&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:j=>G($,j),className:"h-6 w-6 p-0",title:"Edit title",children:i.jsx(X.Edit3,{size:12})}),r&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:j=>O($.threadId,j),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:i.jsx(X.Trash2,{size:12})})]})]}),a===$.threadId&&i.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},$.threadId))})})]})}const qc=T.createContext(null);function mb({children:e,basePath:t="/chat"}){const r=T.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),n={basePath:r,buildThreadPath:o=>`${r}/${o}`,buildBasePath:()=>r};return i.jsx(qc.Provider,{value:n,children:e})}function bb(){const e=T.useContext(qc);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const Xc={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1};function lr(e){var o;const t=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ln&&Ln.tagName.toUpperCase()==="SCRIPT"&&Ln.src||new URL("index.umd.js",document.baseURI).href}<"u"&&Xc?Xc[e]:void 0,r=(o=globalThis==null?void 0:globalThis.process)==null?void 0:o.env,n=r?r[e]:void 0;return(t??n)||void 0}function vb(){return lr("VITE_API_BASE_URL")||lr("NEXT_PUBLIC_API_BASE_URL")||void 0}function wb(){return lr("VITE_API_KEY")||lr("NEXT_PUBLIC_API_KEY")||lr("VITE_AUTH_TOKEN")||void 0}function Yc(){const e=vb(),t=wb(),r={};return e&&(r.baseUrl=e),t&&(r.apiKey=t),r}function Jc(){const e=Yc(),t=Qe.getAuthToken();return{apiBaseUrl:e.baseUrl||Qe.baseUrl||"http://localhost:8000",apiKey:t||e.apiKey||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const Zc="chat-settings";function yb(){try{const e=localStorage.getItem(Zc);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function xb(e){try{localStorage.setItem(Zc,JSON.stringify(e)),e.apiKey&&Qe.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Sb(){const e=Jc(),t=yb(),r=Qe.getAuthToken();return{...e,...t,apiKey:r||t.apiKey||e.apiKey,apiBaseUrl:Qe.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function Cb(e){e.apiKey&&Qe.setAuthToken(e.apiKey),xb(e)}const Yo=768;function Eb(){const[e,t]=d.useState(void 0);return d.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Yo-1}px)`),n=()=>{t(window.innerWidth<Yo)};return r.addEventListener("change",n),t(window.innerWidth<Yo),()=>r.removeEventListener("change",n)},[]),!!e}var Nb="Separator",Qc="horizontal",Tb=["horizontal","vertical"],el=d.forwardRef((e,t)=>{const{decorative:r,orientation:n=Qc,...o}=e,s=Ab(n)?n:Qc,c=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(te.div,{"data-orientation":s,...c,...o,ref:t})});el.displayName=Nb;function Ab(e){return Tb.includes(e)}var tl=el;const Jo=d.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...n},o)=>i.jsx(tl,{ref:o,decorative:r,orientation:t,className:P("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));Jo.displayName=tl.displayName;var fn="Dialog",[rl,Qw]=Be(fn),[Pb,We]=rl(fn),nl=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,c=d.useRef(null),l=d.useRef(null),[f,u]=ot({prop:n,defaultProp:o??!1,onChange:s,caller:fn});return i.jsx(Pb,{scope:t,triggerRef:c,contentRef:l,contentId:Ue(),titleId:Ue(),descriptionId:Ue(),open:f,onOpenChange:u,onOpenToggle:d.useCallback(()=>u(p=>!p),[u]),modal:a,children:r})};nl.displayName=fn;var ol="DialogTrigger",sl=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(ol,r),s=ie(t,o.triggerRef);return i.jsx(te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":es(o.open),...n,ref:s,onClick:H(e.onClick,o.onOpenToggle)})});sl.displayName=ol;var Zo="DialogPortal",[Ib,al]=rl(Zo,{forceMount:void 0}),il=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=We(Zo,t);return i.jsx(Ib,{scope:t,forceMount:r,children:d.Children.map(n,a=>i.jsx(Ae,{present:r||s.open,children:i.jsx(Rr,{asChild:!0,container:o,children:a})}))})};il.displayName=Zo;var pn="DialogOverlay",cl=d.forwardRef((e,t)=>{const r=al(pn,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=We(pn,e.__scopeDialog);return s.modal?i.jsx(Ae,{present:n||s.open,children:i.jsx(kb,{...o,ref:t})}):null});cl.displayName=pn;var _b=Ie.createSlot("DialogOverlay.RemoveScroll"),kb=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(pn,r);return i.jsx(en,{as:_b,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(te.div,{"data-state":es(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),wt="DialogContent",ll=d.forwardRef((e,t)=>{const r=al(wt,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=We(wt,e.__scopeDialog);return i.jsx(Ae,{present:n||s.open,children:s.modal?i.jsx(Ob,{...o,ref:t}):i.jsx(Mb,{...o,ref:t})})});ll.displayName=wt;var Ob=d.forwardRef((e,t)=>{const r=We(wt,e.__scopeDialog),n=d.useRef(null),o=ie(t,r.contentRef,n);return d.useEffect(()=>{const s=n.current;if(s)return ko(s)},[]),i.jsx(dl,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:H(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:H(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&s.preventDefault()}),onFocusOutside:H(e.onFocusOutside,s=>s.preventDefault())})}),Mb=d.forwardRef((e,t)=>{const r=We(wt,e.__scopeDialog),n=d.useRef(!1),o=d.useRef(!1);return i.jsx(dl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(n.current||(c=r.triggerRef.current)==null||c.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{var l,f;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=r.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),dl=d.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,c=We(wt,r),l=d.useRef(null),f=ie(t,l);return io(),i.jsxs(i.Fragment,{children:[i.jsx(Lr,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(Jt,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":es(c.open),...a,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(Db,{titleId:c.titleId}),i.jsx(Fb,{contentRef:l,descriptionId:c.descriptionId})]})]})}),Qo="DialogTitle",ul=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(Qo,r);return i.jsx(te.h2,{id:o.titleId,...n,ref:t})});ul.displayName=Qo;var fl="DialogDescription",pl=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(fl,r);return i.jsx(te.p,{id:o.descriptionId,...n,ref:t})});pl.displayName=fl;var hl="DialogClose",gl=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(hl,r);return i.jsx(te.button,{type:"button",...n,ref:t,onClick:H(e.onClick,()=>o.onOpenChange(!1))})});gl.displayName=hl;function es(e){return e?"open":"closed"}var ml="DialogTitleWarning",[ey,bl]=kf(ml,{contentName:wt,titleName:Qo,docsSlug:"dialog"}),Db=({titleId:e})=>{const t=bl(ml),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
58
+ `)},Fg=0,Ft=[];function $g(e){var t=d.useRef([]),r=d.useRef([0,0]),n=d.useRef(),o=d.useState(Fg++)[0],s=d.useState(Ii)[0],a=d.useRef(e);d.useEffect(function(){a.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=og([e.lockRef.current],(e.shards||[]).map(Fi),!0).filter(Boolean);return g.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=d.useCallback(function(g,b){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var w=Qr(g),x=r.current,y="deltaX"in g?g.deltaX:x[0]-w[0],C="deltaY"in g?g.deltaY:x[1]-w[1],N,k=g.target,E=Math.abs(y)>Math.abs(C)?"h":"v";if("touches"in g&&E==="h"&&k.type==="range")return!1;var M=Oi(E,k);if(!M)return!0;if(M?N=E:(N=E==="v"?"h":"v",M=Oi(E,k)),!M)return!1;if(!n.current&&"changedTouches"in g&&(y||C)&&(n.current=N),!N)return!0;var F=n.current||N;return Mg(F,b,g,F==="h"?y:C)},[]),l=d.useCallback(function(g){var b=g;if(!(!Ft.length||Ft[Ft.length-1]!==s)){var w="deltaY"in b?Li(b):Qr(b),x=t.current.filter(function(N){return N.name===b.type&&(N.target===b.target||b.target===N.shadowParent)&&Dg(N.delta,w)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var y=(a.current.shards||[]).map(Fi).filter(Boolean).filter(function(N){return N.contains(b.target)}),C=y.length>0?c(b,y[0]):!a.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),f=d.useCallback(function(g,b,w,x){var y={name:g,delta:b,target:w,should:x,shadowParent:Bg(w)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(C){return C!==y})},1)},[]),u=d.useCallback(function(g){r.current=Qr(g),n.current=void 0},[]),p=d.useCallback(function(g){f(g.type,Li(g),g.target,c(g,e.lockRef.current))},[]),h=d.useCallback(function(g){f(g.type,Qr(g),g.target,c(g,e.lockRef.current))},[]);d.useEffect(function(){return Ft.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Lt),document.addEventListener("touchmove",l,Lt),document.addEventListener("touchstart",u,Lt),function(){Ft=Ft.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Lt),document.removeEventListener("touchmove",l,Lt),document.removeEventListener("touchstart",u,Lt)}},[]);var v=e.removeScrollBar,m=e.inert;return d.createElement(d.Fragment,null,m?d.createElement(s,{styles:Lg(o)}):null,v?d.createElement(Tg,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Bg(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ug=pg(Pi,$g);var en=d.forwardRef(function(e,t){return d.createElement(Jr,Je({},e,{ref:t,sideCar:Ug}))});en.classNames=Jr.classNames;var Fo=["Enter"," "],Hg=["ArrowDown","PageUp","Home"],$i=["ArrowUp","PageDown","End"],zg=[...Hg,...$i],Wg={ltr:[...Fo,"ArrowRight"],rtl:[...Fo,"ArrowLeft"]},Vg={ltr:["ArrowLeft"],rtl:["ArrowRight"]},rr="Menu",[nr,jg,Kg]=oo(rr),[bt,Bi]=Be(rr,[Kg,Ot,wi]),tn=Ot(),Ui=wi(),[Rg,vt]=bt(rr),[Gg,or]=bt(rr),Hi=e=>{const{__scopeMenu:t,open:r=!1,children:n,dir:o,onOpenChange:s,modal:a=!0}=e,c=tn(t),[l,f]=d.useState(null),u=d.useRef(!1),p=we(s),h=Dr(o);return d.useEffect(()=>{const v=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),i.jsx(Eo,{...c,children:i.jsx(Rg,{scope:t,open:r,onOpenChange:p,content:l,onContentChange:f,children:i.jsx(Gg,{scope:t,onClose:d.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:h,modal:a,children:n})})})};Hi.displayName=rr;var qg="MenuAnchor",$o=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e,o=tn(r);return i.jsx(No,{...o,...n,ref:t})});$o.displayName=qg;var Bo="MenuPortal",[Xg,zi]=bt(Bo,{forceMount:void 0}),Wi=e=>{const{__scopeMenu:t,forceMount:r,children:n,container:o}=e,s=vt(Bo,t);return i.jsx(Xg,{scope:t,forceMount:r,children:i.jsx(Ae,{present:r||s.open,children:i.jsx(Rr,{asChild:!0,container:o,children:n})})})};Wi.displayName=Bo;var Me="MenuContent",[Yg,Uo]=bt(Me),Vi=d.forwardRef((e,t)=>{const r=zi(Me,e.__scopeMenu),{forceMount:n=r.forceMount,...o}=e,s=vt(Me,e.__scopeMenu),a=or(Me,e.__scopeMenu);return i.jsx(nr.Provider,{scope:e.__scopeMenu,children:i.jsx(Ae,{present:n||s.open,children:i.jsx(nr.Slot,{scope:e.__scopeMenu,children:a.modal?i.jsx(Jg,{...o,ref:t}):i.jsx(Zg,{...o,ref:t})})})})}),Jg=d.forwardRef((e,t)=>{const r=vt(Me,e.__scopeMenu),n=d.useRef(null),o=ie(t,n);return d.useEffect(()=>{const s=n.current;if(s)return ko(s)},[]),i.jsx(Ho,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:H(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Zg=d.forwardRef((e,t)=>{const r=vt(Me,e.__scopeMenu);return i.jsx(Ho,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Qg=Ie.createSlot("MenuContent.ScrollLock"),Ho=d.forwardRef((e,t)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:h,onDismiss:v,disableOutsideScroll:m,...g}=e,b=vt(Me,r),w=or(Me,r),x=tn(r),y=Ui(r),C=jg(r),[N,k]=d.useState(null),E=d.useRef(null),M=ie(t,E,b.onContentChange),F=d.useRef(0),_=d.useRef(""),B=d.useRef(0),R=d.useRef(null),U=d.useRef("right"),D=d.useRef(0),z=m?en:d.Fragment,O=m?{as:Qg,allowPinchZoom:!0}:void 0,G=A=>{var W,V;const ee=_.current+A,q=C().filter(se=>!se.disabled),ce=document.activeElement,$=(W=q.find(se=>se.ref.current===ce))==null?void 0:W.textValue,j=q.map(se=>se.textValue),le=um(j,ee,$),he=(V=q.find(se=>se.textValue===le))==null?void 0:V.ref.current;(function se(K){_.current=K,window.clearTimeout(F.current),K!==""&&(F.current=window.setTimeout(()=>se(""),1e3))})(ee),he&&setTimeout(()=>he.focus())};d.useEffect(()=>()=>window.clearTimeout(F.current),[]),io();const L=d.useCallback(A=>{var q,ce;return U.current===((q=R.current)==null?void 0:q.side)&&pm(A,(ce=R.current)==null?void 0:ce.area)},[]);return i.jsx(Yg,{scope:r,searchRef:_,onItemEnter:d.useCallback(A=>{L(A)&&A.preventDefault()},[L]),onItemLeave:d.useCallback(A=>{var ee;L(A)||((ee=E.current)==null||ee.focus(),k(null))},[L]),onTriggerLeave:d.useCallback(A=>{L(A)&&A.preventDefault()},[L]),pointerGraceTimerRef:B,onPointerGraceIntentChange:d.useCallback(A=>{R.current=A},[]),children:i.jsx(z,{...O,children:i.jsx(Lr,{asChild:!0,trapped:o,onMountAutoFocus:H(s,A=>{var ee;A.preventDefault(),(ee=E.current)==null||ee.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:i.jsx(Jt,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:h,onDismiss:v,children:i.jsx(Qh,{asChild:!0,...y,dir:w.dir,orientation:"vertical",loop:n,currentTabStopId:N,onCurrentTabStopIdChange:k,onEntryFocus:H(l,A=>{w.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(To,{role:"menu","aria-orientation":"vertical","data-state":ac(b.open),"data-radix-menu-content":"",dir:w.dir,...x,...g,ref:M,style:{outline:"none",...g.style},onKeyDown:H(g.onKeyDown,A=>{const q=A.target.closest("[data-radix-menu-content]")===A.currentTarget,ce=A.ctrlKey||A.altKey||A.metaKey,$=A.key.length===1;q&&(A.key==="Tab"&&A.preventDefault(),!ce&&$&&G(A.key));const j=E.current;if(A.target!==j||!zg.includes(A.key))return;A.preventDefault();const he=C().filter(W=>!W.disabled).map(W=>W.ref.current);$i.includes(A.key)&&he.reverse(),lm(he)}),onBlur:H(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(F.current),_.current="")}),onPointerMove:H(e.onPointerMove,ar(A=>{const ee=A.target,q=D.current!==A.clientX;if(A.currentTarget.contains(ee)&&q){const ce=A.clientX>D.current?"right":"left";U.current=ce,D.current=A.clientX}}))})})})})})})});Vi.displayName=Me;var em="MenuGroup",zo=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(te.div,{role:"group",...n,ref:t})});zo.displayName=em;var tm="MenuLabel",ji=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(te.div,{...n,ref:t})});ji.displayName=tm;var rn="MenuItem",Ki="menu.itemSelect",nn=d.forwardRef((e,t)=>{const{disabled:r=!1,onSelect:n,...o}=e,s=d.useRef(null),a=or(rn,e.__scopeMenu),c=Uo(rn,e.__scopeMenu),l=ie(t,s),f=d.useRef(!1),u=()=>{const p=s.current;if(!r&&p){const h=new CustomEvent(Ki,{bubbles:!0,cancelable:!0});p.addEventListener(Ki,v=>n==null?void 0:n(v),{once:!0}),wa(p,h),h.defaultPrevented?f.current=!1:a.onClose()}};return i.jsx(Ri,{...o,ref:l,disabled:r,onClick:H(e.onClick,u),onPointerDown:p=>{var h;(h=e.onPointerDown)==null||h.call(e,p),f.current=!0},onPointerUp:H(e.onPointerUp,p=>{var h;f.current||(h=p.currentTarget)==null||h.click()}),onKeyDown:H(e.onKeyDown,p=>{const h=c.searchRef.current!=="";r||h&&p.key===" "||Fo.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});nn.displayName=rn;var Ri=d.forwardRef((e,t)=>{const{__scopeMenu:r,disabled:n=!1,textValue:o,...s}=e,a=Uo(rn,r),c=Ui(r),l=d.useRef(null),f=ie(t,l),[u,p]=d.useState(!1),[h,v]=d.useState("");return d.useEffect(()=>{const m=l.current;m&&v((m.textContent??"").trim())},[s.children]),i.jsx(nr.ItemSlot,{scope:r,disabled:n,textValue:o??h,children:i.jsx(eg,{asChild:!0,...c,focusable:!n,children:i.jsx(te.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...s,ref:f,onPointerMove:H(e.onPointerMove,ar(m=>{n?a.onItemLeave(m):(a.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:H(e.onPointerLeave,ar(m=>a.onItemLeave(m))),onFocus:H(e.onFocus,()=>p(!0)),onBlur:H(e.onBlur,()=>p(!1))})})})}),rm="MenuCheckboxItem",Gi=d.forwardRef((e,t)=>{const{checked:r=!1,onCheckedChange:n,...o}=e;return i.jsx(Zi,{scope:e.__scopeMenu,checked:r,children:i.jsx(nn,{role:"menuitemcheckbox","aria-checked":on(r)?"mixed":r,...o,ref:t,"data-state":Vo(r),onSelect:H(o.onSelect,()=>n==null?void 0:n(on(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Gi.displayName=rm;var qi="MenuRadioGroup",[nm,om]=bt(qi,{value:void 0,onValueChange:()=>{}}),Xi=d.forwardRef((e,t)=>{const{value:r,onValueChange:n,...o}=e,s=we(n);return i.jsx(nm,{scope:e.__scopeMenu,value:r,onValueChange:s,children:i.jsx(zo,{...o,ref:t})})});Xi.displayName=qi;var Yi="MenuRadioItem",Ji=d.forwardRef((e,t)=>{const{value:r,...n}=e,o=om(Yi,e.__scopeMenu),s=r===o.value;return i.jsx(Zi,{scope:e.__scopeMenu,checked:s,children:i.jsx(nn,{role:"menuitemradio","aria-checked":s,...n,ref:t,"data-state":Vo(s),onSelect:H(n.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,r)},{checkForDefaultPrevented:!1})})})});Ji.displayName=Yi;var Wo="MenuItemIndicator",[Zi,sm]=bt(Wo,{checked:!1}),Qi=d.forwardRef((e,t)=>{const{__scopeMenu:r,forceMount:n,...o}=e,s=sm(Wo,r);return i.jsx(Ae,{present:n||on(s.checked)||s.checked===!0,children:i.jsx(te.span,{...o,ref:t,"data-state":Vo(s.checked)})})});Qi.displayName=Wo;var am="MenuSeparator",ec=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(te.div,{role:"separator","aria-orientation":"horizontal",...n,ref:t})});ec.displayName=am;var im="MenuArrow",tc=d.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e,o=tn(r);return i.jsx(Ao,{...o,...n,ref:t})});tc.displayName=im;var cm="MenuSub",[Yw,rc]=bt(cm),sr="MenuSubTrigger",nc=d.forwardRef((e,t)=>{const r=vt(sr,e.__scopeMenu),n=or(sr,e.__scopeMenu),o=rc(sr,e.__scopeMenu),s=Uo(sr,e.__scopeMenu),a=d.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:l}=s,f={__scopeMenu:e.__scopeMenu},u=d.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return d.useEffect(()=>u,[u]),d.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),l(null)}},[c,l]),i.jsx($o,{asChild:!0,...f,children:i.jsx(Ri,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":o.contentId,"data-state":ac(r.open),...e,ref:Qn(t,o.onTriggerChange),onClick:p=>{var h;(h=e.onClick)==null||h.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:H(e.onPointerMove,ar(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!r.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100))})),onPointerLeave:H(e.onPointerLeave,ar(p=>{var v,m;u();const h=(v=r.content)==null?void 0:v.getBoundingClientRect();if(h){const g=(m=r.content)==null?void 0:m.dataset.side,b=g==="right",w=b?-5:5,x=h[b?"left":"right"],y=h[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x,y:h.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:H(e.onKeyDown,p=>{var v;const h=s.searchRef.current!=="";e.disabled||h&&p.key===" "||Wg[n.dir].includes(p.key)&&(r.onOpenChange(!0),(v=r.content)==null||v.focus(),p.preventDefault())})})})});nc.displayName=sr;var oc="MenuSubContent",sc=d.forwardRef((e,t)=>{const r=zi(Me,e.__scopeMenu),{forceMount:n=r.forceMount,...o}=e,s=vt(Me,e.__scopeMenu),a=or(Me,e.__scopeMenu),c=rc(oc,e.__scopeMenu),l=d.useRef(null),f=ie(t,l);return i.jsx(nr.Provider,{scope:e.__scopeMenu,children:i.jsx(Ae,{present:n||s.open,children:i.jsx(nr.Slot,{scope:e.__scopeMenu,children:i.jsx(Ho,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:f,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var p;a.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:H(e.onFocusOutside,u=>{u.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:H(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:H(e.onKeyDown,u=>{var v;const p=u.currentTarget.contains(u.target),h=Vg[a.dir].includes(u.key);p&&h&&(s.onOpenChange(!1),(v=c.trigger)==null||v.focus(),u.preventDefault())})})})})})});sc.displayName=oc;function ac(e){return e?"open":"closed"}function on(e){return e==="indeterminate"}function Vo(e){return on(e)?"indeterminate":e?"checked":"unchecked"}function lm(e){const t=document.activeElement;for(const r of e)if(r===t||(r.focus(),document.activeElement!==t))return}function dm(e,t){return e.map((r,n)=>e[(t+n)%e.length])}function um(e,t,r){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let a=dm(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==r));const l=a.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return l!==r?l:void 0}function fm(e,t){const{x:r,y:n}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],l=t[a],f=c.x,u=c.y,p=l.x,h=l.y;u>n!=h>n&&r<(p-f)*(n-u)/(h-u)+f&&(o=!o)}return o}function pm(e,t){if(!t)return!1;const r={x:e.clientX,y:e.clientY};return fm(r,t)}function ar(e){return t=>t.pointerType==="mouse"?e(t):void 0}var hm=Hi,gm=$o,mm=Wi,bm=Vi,vm=zo,wm=ji,ym=nn,xm=Gi,Sm=Xi,Cm=Ji,Em=Qi,Nm=ec,Tm=tc,Am=nc,Pm=sc,sn="DropdownMenu",[Im,Jw]=Be(sn,[Bi]),Se=Bi(),[_m,ic]=Im(sn),cc=e=>{const{__scopeDropdownMenu:t,children:r,dir:n,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,l=Se(t),f=d.useRef(null),[u,p]=ot({prop:o,defaultProp:s??!1,onChange:a,caller:sn});return i.jsx(_m,{scope:t,triggerId:Ue(),triggerRef:f,contentId:Ue(),open:u,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(h=>!h),[p]),modal:c,children:i.jsx(hm,{...l,open:u,onOpenChange:p,dir:n,modal:c,children:r})})};cc.displayName=sn;var lc="DropdownMenuTrigger",dc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...o}=e,s=ic(lc,r),a=Se(r);return i.jsx(gm,{asChild:!0,...a,children:i.jsx(te.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...o,ref:Qn(t,s.triggerRef),onPointerDown:H(e.onPointerDown,c=>{!n&&c.button===0&&c.ctrlKey===!1&&(s.onOpenToggle(),s.open||c.preventDefault())}),onKeyDown:H(e.onKeyDown,c=>{n||(["Enter"," "].includes(c.key)&&s.onOpenToggle(),c.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});dc.displayName=lc;var km="DropdownMenuPortal",uc=e=>{const{__scopeDropdownMenu:t,...r}=e,n=Se(t);return i.jsx(mm,{...n,...r})};uc.displayName=km;var fc="DropdownMenuContent",pc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ic(fc,r),s=Se(r),a=d.useRef(!1);return i.jsx(bm,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...n,ref:t,onCloseAutoFocus:H(e.onCloseAutoFocus,c=>{var l;a.current||(l=o.triggerRef.current)==null||l.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:H(e.onInteractOutside,c=>{const l=c.detail.originalEvent,f=l.button===0&&l.ctrlKey===!0,u=l.button===2||f;(!o.modal||u)&&(a.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)"}})});pc.displayName=fc;var Om="DropdownMenuGroup",Mm=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(vm,{...o,...n,ref:t})});Mm.displayName=Om;var Dm="DropdownMenuLabel",hc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(wm,{...o,...n,ref:t})});hc.displayName=Dm;var Lm="DropdownMenuItem",gc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(ym,{...o,...n,ref:t})});gc.displayName=Lm;var Fm="DropdownMenuCheckboxItem",mc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(xm,{...o,...n,ref:t})});mc.displayName=Fm;var $m="DropdownMenuRadioGroup",Bm=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Sm,{...o,...n,ref:t})});Bm.displayName=$m;var Um="DropdownMenuRadioItem",bc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Cm,{...o,...n,ref:t})});bc.displayName=Um;var Hm="DropdownMenuItemIndicator",vc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Em,{...o,...n,ref:t})});vc.displayName=Hm;var zm="DropdownMenuSeparator",wc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Nm,{...o,...n,ref:t})});wc.displayName=zm;var Wm="DropdownMenuArrow",Vm=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Tm,{...o,...n,ref:t})});Vm.displayName=Wm;var jm="DropdownMenuSubTrigger",yc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Am,{...o,...n,ref:t})});yc.displayName=jm;var Km="DropdownMenuSubContent",xc=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Se(r);return i.jsx(Pm,{...o,...n,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)"}})});xc.displayName=Km;var Rm=cc,Gm=dc,qm=uc,Sc=pc,Cc=hc,Ec=gc,Nc=mc,Tc=bc,Ac=vc,Pc=wc,Ic=yc,_c=xc;const Xm=Rm,Ym=Gm,Jm=d.forwardRef(({className:e,inset:t,children:r,...n},o)=>i.jsxs(Ic,{ref:o,className:P("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),...n,children:[r,i.jsx(X.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Jm.displayName=Ic.displayName;const Zm=d.forwardRef(({className:e,...t},r)=>i.jsx(_c,{ref:r,className:P("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}));Zm.displayName=_c.displayName;const kc=d.forwardRef(({className:e,sideOffset:t=4,...r},n)=>i.jsx(qm,{children:i.jsx(Sc,{ref:n,sideOffset:t,className:P("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),...r})}));kc.displayName=Sc.displayName;const jo=d.forwardRef(({className:e,inset:t,...r},n)=>i.jsx(Ec,{ref:n,className:P("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),...r}));jo.displayName=Ec.displayName;const Qm=d.forwardRef(({className:e,children:t,checked:r,...n},o)=>i.jsxs(Nc,{ref:o,className:P("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:r,...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Ac,{children:i.jsx(X.Check,{className:"h-4 w-4"})})}),t]}));Qm.displayName=Nc.displayName;const eb=d.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(Tc,{ref:n,className:P("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),...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Ac,{children:i.jsx(X.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));eb.displayName=Tc.displayName;const tb=d.forwardRef(({className:e,inset:t,...r},n)=>i.jsx(Cc,{ref:n,className:P("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...r}));tb.displayName=Cc.displayName;const rb=d.forwardRef(({className:e,...t},r)=>i.jsx(Pc,{ref:r,className:P("-mx-1 my-1 h-px bg-muted",e),...t}));rb.displayName=Pc.displayName;function ir({className:e="",placeholder:t="Type your message...",autoFocus:r=!0,maxHeight:n=void 0,streamingDebounceMs:o=40,enableFileUpload:s=!0,enableExcelUpload:a=!1,enableMessageEditing:c=!0,customStyles:l={},onMessageSent:f,onExcelUploadSuccess:u,onError:p}){const{currentThreadId:h,messages:v,isStreaming:m,streamingAssistantId:g,error:b,send:w,stop:x,lastCheckpointId:y,listCheckpoints:C,navigateToCheckpoint:N,returnToLatest:k,hasMoreHistory:E,isLoadingHistory:M,loadOlderMessages:F,api:_}=Zn();try{const I=typeof window<"u"?localStorage.getItem("currentThreadId"):null;console.log("ChatInterface debug - useChat()",{currentThreadId:h,lastCheckpointId:y,lsThread:I})}catch(I){console.log("ChatInterface debug - localStorage not available",I)}const[B,R]=T.useState(""),[U,D]=T.useState(null),[z,O]=T.useState(null),[G,L]=T.useState([]),[A,ee]=T.useState(!1),[q,ce]=T.useState(null),[$,j]=T.useState(null),[le,he]=T.useState(!1),[W,V]=T.useState(null),[se,K]=T.useState([]),[Y,ne]=T.useState(null),me=T.useRef(null),pe=T.useRef(null),Q=T.useRef(null),J=T.useRef(null),ge=T.useRef(null),Oe=T.useRef(!1),Ce=T.useRef(!0),pr=T.useRef(0),ut=T.useRef(null),[Ht,gs]=T.useState("desktop");T.useEffect(()=>{const I=()=>{const Z=window.innerWidth;gs(Z<640?"phone":Z<1024?"tablet":"desktop")};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),T.useEffect(()=>{let I=!1;if(!h){K([]),ne(null),ut.current=null;return}const Z={threadId:h,checkpointId:y??null},ue=ut.current;if(!(ue&&ue.threadId===Z.threadId&&ue.checkpointId===Z.checkpointId))return ut.current=Z,C(h).then(de=>{if(console.log("ChatInterface debug - listCheckpoints response:",de),I)return;const Fe=((de==null?void 0:de.checkpoints)??[]).slice().sort((ft,Dn)=>new Date(Dn.createdAt).getTime()-new Date(ft.createdAt).getTime());console.log("ChatInterface debug - computed checkpoints:",Fe),K(Fe),ne(ft=>{var Dn;return ft??((Dn=Fe[0])==null?void 0:Dn.checkpointId)??null})}).catch(de=>{console.error("ChatInterface debug - listCheckpoints error:",de),I||(K([]),ut.current=null)}),()=>{I=!0}},[h,y,C]),T.useEffect(()=>{y&&ne(y)},[y]);const zt=T.useCallback(async()=>{if(!E||M)return;const I=ge.current;if(!I)return;const Z=I.scrollHeight,ue=I.scrollTop;Oe.current=!0;try{await F()}catch(de){console.warn("loadOlderMessages failed",de)}finally{requestAnimationFrame(()=>{const de=ge.current;if(!de){Oe.current=!1;return}const Fe=de.scrollHeight;de.scrollTop=ue+(Fe-Z);const ft=Fe-de.scrollTop-de.clientHeight;Ce.current=ft<=32,Oe.current=!1})}},[E,M,F]);T.useEffect(()=>{const I=ge.current;if(!I)return;const Z=()=>{I.scrollTop<=80&&zt();const Fe=I.scrollHeight-I.scrollTop-I.clientHeight;Ce.current=Fe<=80};return I.addEventListener("scroll",Z),()=>I.removeEventListener("scroll",Z)},[zt]),T.useEffect(()=>{v.length<pr.current&&(Ce.current=!0),pr.current=v.length},[v.length]),T.useEffect(()=>{const I=ge.current;I&&(Oe.current||Ce.current&&(I.scrollTop=I.scrollHeight,Ce.current=!0))},[v]),T.useEffect(()=>{var I;r&&((I=pe.current)==null||I.focus())},[r]),T.useEffect(()=>{(async()=>{try{const Z=await _.getAgent("default");V(Z.uiDefaultMessage||null)}catch(Z){console.warn("Failed to fetch default message:",Z),V(null)}})()},[_]),T.useEffect(()=>{b&&!le&&(p==null||p(b))},[b,le,p]);const ms=I=>{if(I.length>At)return`Message too long (${I.length}/${At} characters)`;try{return ip(I),null}catch(Z){return(Z==null?void 0:Z.message)||"Invalid message"}},In=I=>{const Z=I.content||[],ue=Z.filter(de=>de.type==="text").map(de=>de.text).join("");if(ue)return ue;try{return JSON.stringify(Z,null,2)}catch{return String(Z)}},_n=async()=>{const I=B.trim();if(!(!I&&G.length===0)){if(I){const Z=ms(I);if(Z){O(Z);return}}try{await w(I,{checkpointId:Y||y||void 0,payloadExtras:U?{edit:!0,originalMessageId:U}:void 0,attachments:G}),f==null||f(I),R(""),O(null),L([]),D(null),pe.current&&(pe.current.style.height="auto")}catch(Z){const ue=(Z==null?void 0:Z.message)||"Failed to send message";O(ue),p==null||p(ue)}}},bs=(I,Z)=>{c&&(D(I),R(Z),O(null),setTimeout(()=>{pe.current&&(pe.current.focus(),pe.current.style.height="auto",pe.current.style.height=pe.current.scrollHeight+"px")},0))},hr=()=>{D(null),R(""),O(null),pe.current&&(pe.current.style.height="auto")},kn=I=>{I.key==="Enter"&&!I.shiftKey?(I.preventDefault(),_n()):I.key==="Escape"&&U&&(I.preventDefault(),hr())},ae=I=>{const Z=Array.from(I.target.files||[]);L(ue=>[...ue,...Z])},xe=I=>L(Z=>Z.filter((ue,de)=>I!==de)),Pe=async I=>{const Z=(I.target.files||[])[0];if(Z){ce(null),j(null),ee(!0);try{const ue=await _.uploadExcel(Z),de=ue.sheets.map(ft=>`${ft.sheetName} -> ${ft.tableName}`).join(", "),Fe=de?`Uploaded ${Z.name} (${ue.sheets.length} sheet${ue.sheets.length===1?"":"s"}: ${de})`:`Uploaded ${Z.name}`;j(Fe),u==null||u({file:Z,response:ue})}catch(ue){const de=ue instanceof Error?ue.message:"Failed to upload Excel file";console.error("Excel upload failed",ue),ce(de),p==null||p(de)}finally{ee(!1),I.target.value=""}}},je=I=>{if(!I)return"Unknown";const Z=Date.parse(I);return Number.isNaN(Z)?I:new Date(Z).toLocaleString()},rt=async I=>{if(h){if(!I){await k(),ne(null);return}await N(I),ne(I)}},On=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${l.container||""}`,Mn=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-y-auto overflow-x-auto overscroll-contain break-words break-anywhere p-4 space-y-4 bg-transparent ${l.messagesArea||""}`,vs=`flex-shrink-0 w-full border-t p-4 bg-transparent ${l.inputArea||""}`;return i.jsxs("div",{className:On,children:[!!b&&!le&&i.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[i.jsx("span",{children:b}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>he(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:i.jsx(X.X,{size:16})})]}),(console.log("Checkpoint toolbar render",{currentThreadId:h,checkpoints:se,activeCheckpointId:Y}),null),h&&se.length>0&&i.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[i.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),i.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:Y??"",onChange:I=>{const Z=I.target.value||null;rt(Z)},children:[i.jsx("option",{value:"",children:"Latest"}),se.map(I=>i.jsxs("option",{value:I.checkpointId,children:[je(I.createdAt),I.preview?` — ${I.preview.slice(0,40)}`:""]},I.checkpointId))]})]}),i.jsxs("div",{ref:ge,className:Mn,style:n?{maxHeight:n}:void 0,children:[v.length===0?i.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:W||"No messages yet. Start a conversation!"}):i.jsxs(i.Fragment,{children:[(M||!E)&&i.jsx("div",{className:"flex justify-center py-2 text-xs text-muted-foreground",children:M?i.jsx(X.Loader2,{className:"h-4 w-4 animate-spin"}):"You've reached the beginning"}),v.map((I,Z)=>i.jsx(Na,{message:I,messageIndex:Z,isStreamingMessage:m&&g===I.id,streamingDebounceMs:o,isEditing:U===I.id,showActions:c,showTimestamp:!1,showAgentName:!0,layoutSize:Ht,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:(ue,de)=>bs(ue,de),onRegenerate:()=>{const ue=[...v].reverse().find(Fe=>Fe.role==="user"),de=ue?In(ue):"";de&&w(de,{checkpointId:Y||y||void 0})},onCancelEdit:hr},I.id||Z))]}),i.jsx("div",{ref:me})]}),i.jsxs("div",{className:vs,children:[U&&i.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(X.Edit3,{size:16,className:"text-blue-600"}),i.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:hr,className:"text-blue-600 hover:bg-blue-100",children:i.jsx(X.X,{size:16})})]})}),(s||a)&&i.jsxs("div",{className:"mb-3 space-y-3",children:[s&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:Q,type:"file",multiple:!0,onChange:I=>ae(I),className:"hidden"}),G.length>0&&i.jsx("div",{className:"flex flex-wrap gap-2",children:G.map((I,Z)=>i.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[i.jsx(X.Paperclip,{size:14}),i.jsx("span",{className:"truncate max-w-[150px]",children:I.name}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>xe(Z),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${I.name}`,children:i.jsx(X.X,{size:12})})]},Z))})]}),a&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:J,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Pe,className:"hidden"}),A&&i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(X.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),$&&!A&&i.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:$}),q&&!A&&i.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:q})]})]}),z&&i.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:z}),i.jsxs("div",{className:"flex items-end gap-2",children:[(s||a)&&i.jsxs(Xm,{children:[i.jsx(Ym,{asChild:!0,children:i.jsx(fe,{type:"button",size:"icon",variant:"outline",disabled:m,title:"More input actions",className:l.moreButton||"",children:i.jsx(X.Plus,{size:16})})}),i.jsxs(kc,{align:"start",sideOffset:6,className:"w-52",children:[s&&i.jsxs(jo,{onClick:()=>{var I;return(I=Q.current)==null?void 0:I.click()},className:"cursor-pointer",children:[i.jsx(X.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),a&&i.jsxs(jo,{onClick:()=>{var I;A||(I=J.current)==null||I.click()},className:`cursor-pointer ${A?"opacity-60 pointer-events-none":""}`,children:[i.jsx(X.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),i.jsx("div",{className:"flex-1",children:i.jsx(ma,{ref:pe,value:B,onChange:I=>{R(I.target.value),O(null),pe.current&&(pe.current.style.height="auto",pe.current.style.height=`${pe.current.scrollHeight}px`)},onKeyDown:kn,placeholder:U?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${U?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${z?"border-red-400":""} ${l.textarea||""}`,disabled:!1,maxLength:At,rows:1})}),i.jsx("div",{children:m?i.jsx(fe,{type:"button",onClick:x,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:i.jsx(X.Square,{size:16})}):i.jsx(fe,{type:"button",onClick:_n,size:"icon",disabled:!B.trim()&&G.length===0,className:`shrink-0 ${G.length>0?"bg-blue-500 hover:bg-blue-600 text-white":""} ${l.sendButton||""}`,title:U?"Save changes":"Send message",children:i.jsx(X.Send,{size:16})})})]}),B.length>At*.8&&i.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[B.length,"/",At]})]})]})}const cr=d.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:P("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:n,...r}));cr.displayName="Input";function Ko(e,[t,r]){return Math.min(r,Math.max(t,e))}function nb(e,t){return d.useReducer((r,n)=>t[r][n]??r,e)}var Ro="ScrollArea",[Oc,Zw]=Be(Ro),[ob,De]=Oc(Ro),Mc=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...a}=e,[c,l]=d.useState(null),[f,u]=d.useState(null),[p,h]=d.useState(null),[v,m]=d.useState(null),[g,b]=d.useState(null),[w,x]=d.useState(0),[y,C]=d.useState(0),[N,k]=d.useState(!1),[E,M]=d.useState(!1),F=ie(t,B=>l(B)),_=Dr(o);return i.jsx(ob,{scope:r,type:n,dir:_,scrollHideDelay:s,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:h,scrollbarX:v,onScrollbarXChange:m,scrollbarXEnabled:N,onScrollbarXEnabledChange:k,scrollbarY:g,onScrollbarYChange:b,scrollbarYEnabled:E,onScrollbarYEnabledChange:M,onCornerWidthChange:x,onCornerHeightChange:C,children:i.jsx(te.div,{dir:_,...a,ref:F,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Mc.displayName=Ro;var Dc="ScrollAreaViewport",Lc=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,a=De(Dc,r),c=d.useRef(null),l=ie(t,c,a.onViewportChange);return i.jsxs(i.Fragment,{children:[i.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}),i.jsx(te.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:i.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});Lc.displayName=Dc;var Ze="ScrollAreaScrollbar",Go=d.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=De(Ze,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=o,c=e.orientation==="horizontal";return d.useEffect(()=>(c?s(!0):a(!0),()=>{c?s(!1):a(!1)}),[c,s,a]),o.type==="hover"?i.jsx(sb,{...n,ref:t,forceMount:r}):o.type==="scroll"?i.jsx(ab,{...n,ref:t,forceMount:r}):o.type==="auto"?i.jsx(Fc,{...n,ref:t,forceMount:r}):o.type==="always"?i.jsx(qo,{...n,ref:t}):null});Go.displayName=Ze;var sb=d.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=De(Ze,e.__scopeScrollArea),[s,a]=d.useState(!1);return d.useEffect(()=>{const c=o.scrollArea;let l=0;if(c){const f=()=>{window.clearTimeout(l),a(!0)},u=()=>{l=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),i.jsx(Ae,{present:r||s,children:i.jsx(Fc,{"data-state":s?"visible":"hidden",...n,ref:t})})}),ab=d.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=De(Ze,e.__scopeScrollArea),s=e.orientation==="horizontal",a=dn(()=>l("SCROLL_END"),100),[c,l]=nb("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 d.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,o.scrollHideDelay,l]),d.useEffect(()=>{const f=o.viewport,u=s?"scrollLeft":"scrollTop";if(f){let p=f[u];const h=()=>{const v=f[u];p!==v&&(l("SCROLL"),a()),p=v};return f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[o.viewport,s,l,a]),i.jsx(Ae,{present:r||c!=="hidden",children:i.jsx(qo,{"data-state":c==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:H(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:H(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Fc=d.forwardRef((e,t)=>{const r=De(Ze,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,a]=d.useState(!1),c=e.orientation==="horizontal",l=dn(()=>{if(r.viewport){const f=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;a(c?f:u)}},10);return $t(r.viewport,l),$t(r.content,l),i.jsx(Ae,{present:n||s,children:i.jsx(qo,{"data-state":s?"visible":"hidden",...o,ref:t})})}),qo=d.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=De(Ze,e.__scopeScrollArea),s=d.useRef(null),a=d.useRef(0),[c,l]=d.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=zc(c.viewport,c.content),u={...n,sizes:c,onSizesChange:l,hasThumb:f>0&&f<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:h=>a.current=h};function p(h,v){return fb(h,a.current,c,v)}return r==="horizontal"?i.jsx(ib,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,v=Wc(h,c,o.dir);s.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=p(h,o.dir))}}):r==="vertical"?i.jsx(cb,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,v=Wc(h,c);s.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=p(h))}}):null}),ib=d.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=De(Ze,e.__scopeScrollArea),[a,c]=d.useState(),l=d.useRef(null),f=ie(t,l,s.onScrollbarXChange);return d.useEffect(()=>{l.current&&c(getComputedStyle(l.current))},[l]),i.jsx(Bc,{"data-orientation":"horizontal",...o,ref:f,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ln(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),jc(h,p)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&a&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:cn(a.paddingLeft),paddingEnd:cn(a.paddingRight)}})}})}),cb=d.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=De(Ze,e.__scopeScrollArea),[a,c]=d.useState(),l=d.useRef(null),f=ie(t,l,s.onScrollbarYChange);return d.useEffect(()=>{l.current&&c(getComputedStyle(l.current))},[l]),i.jsx(Bc,{"data-orientation":"vertical",...o,ref:f,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ln(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),jc(h,p)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&a&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:cn(a.paddingTop),paddingEnd:cn(a.paddingBottom)}})}})}),[lb,$c]=Oc(Ze),Bc=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:c,onThumbPositionChange:l,onDragScroll:f,onWheelScroll:u,onResize:p,...h}=e,v=De(Ze,r),[m,g]=d.useState(null),b=ie(t,F=>g(F)),w=d.useRef(null),x=d.useRef(""),y=v.viewport,C=n.content-n.viewport,N=we(u),k=we(l),E=dn(p,10);function M(F){if(w.current){const _=F.clientX-w.current.left,B=F.clientY-w.current.top;f({x:_,y:B})}}return d.useEffect(()=>{const F=_=>{const B=_.target;(m==null?void 0:m.contains(B))&&N(_,C)};return document.addEventListener("wheel",F,{passive:!1}),()=>document.removeEventListener("wheel",F,{passive:!1})},[y,m,C,N]),d.useEffect(k,[n,k]),$t(m,E),$t(v.content,E),i.jsx(lb,{scope:r,scrollbar:m,hasThumb:o,onThumbChange:we(s),onThumbPointerUp:we(a),onThumbPositionChange:k,onThumbPointerDown:we(c),children:i.jsx(te.div,{...h,ref:b,style:{position:"absolute",...h.style},onPointerDown:H(e.onPointerDown,F=>{F.button===0&&(F.target.setPointerCapture(F.pointerId),w.current=m.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),M(F))}),onPointerMove:H(e.onPointerMove,M),onPointerUp:H(e.onPointerUp,F=>{const _=F.target;_.hasPointerCapture(F.pointerId)&&_.releasePointerCapture(F.pointerId),document.body.style.webkitUserSelect=x.current,v.viewport&&(v.viewport.style.scrollBehavior=""),w.current=null})})})}),an="ScrollAreaThumb",Uc=d.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=$c(an,e.__scopeScrollArea);return i.jsx(Ae,{present:r||o.hasThumb,children:i.jsx(db,{ref:t,...n})})}),db=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=De(an,r),a=$c(an,r),{onThumbPositionChange:c}=a,l=ie(t,p=>a.onThumbChange(p)),f=d.useRef(void 0),u=dn(()=>{f.current&&(f.current(),f.current=void 0)},100);return d.useEffect(()=>{const p=s.viewport;if(p){const h=()=>{if(u(),!f.current){const v=pb(p,c);f.current=v,c()}};return c(),p.addEventListener("scroll",h),()=>p.removeEventListener("scroll",h)}},[s.viewport,u,c]),i.jsx(te.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:H(e.onPointerDownCapture,p=>{const v=p.target.getBoundingClientRect(),m=p.clientX-v.left,g=p.clientY-v.top;a.onThumbPointerDown({x:m,y:g})}),onPointerUp:H(e.onPointerUp,a.onThumbPointerUp)})});Uc.displayName=an;var Xo="ScrollAreaCorner",Hc=d.forwardRef((e,t)=>{const r=De(Xo,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?i.jsx(ub,{...e,ref:t}):null});Hc.displayName=Xo;var ub=d.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=De(Xo,r),[s,a]=d.useState(0),[c,l]=d.useState(0),f=!!(s&&c);return $t(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),$t(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),a(u)}),f?i.jsx(te.div,{...n,ref:t,style:{width:s,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function cn(e){return e?parseInt(e,10):0}function zc(e,t){const r=e/t;return isNaN(r)?0:r}function ln(e){const t=zc(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function fb(e,t,r,n="ltr"){const o=ln(r),s=o/2,a=t||s,c=o-a,l=r.scrollbar.paddingStart+a,f=r.scrollbar.size-r.scrollbar.paddingEnd-c,u=r.content-r.viewport,p=n==="ltr"?[0,u]:[u*-1,0];return Vc([l,f],p)(e)}function Wc(e,t,r="ltr"){const n=ln(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,a=t.content-t.viewport,c=s-n,l=r==="ltr"?[0,a]:[a*-1,0],f=Ko(e,l);return Vc([0,a],[0,c])(f)}function Vc(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function jc(e,t){return e>0&&e<t}var pb=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},a=r.left!==s.left,c=r.top!==s.top;(a||c)&&t(),r=s,n=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(n)};function dn(e,t){const r=we(e),n=d.useRef(0);return d.useEffect(()=>()=>window.clearTimeout(n.current),[]),d.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function $t(e,t){const r=we(t);ve(()=>{let n=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(n),o.unobserve(e)}}},[e,r])}var Kc=Mc,hb=Lc,gb=Hc;const Rc=d.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(Kc,{ref:n,className:P("relative overflow-hidden",e),...r,children:[i.jsx(hb,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),i.jsx(Gc,{}),i.jsx(gb,{})]}));Rc.displayName=Kc.displayName;const Gc=d.forwardRef(({className:e,orientation:t="vertical",...r},n)=>i.jsx(Go,{ref:n,orientation:t,className:P("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),...r,children:i.jsx(Uc,{className:"relative flex-1 rounded-full bg-border"})}));Gc.displayName=Go.displayName;function un({className:e="",showCreateButton:t=!0,showDeleteButton:r=!0,showEditTitle:n=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:a=null,navigateToThread:c,onThreadSelect:l,onThreadCreate:f,onThreadDelete:u}){const{loadThread:p,threads:h,refreshThreads:v,currentThreadId:m,createThread:g,deleteThread:b,renameThread:w}=Zn(),[x,y]=T.useState(h??[]),[C,N]=T.useState(!1),[k,E]=T.useState(null),[M,F]=T.useState(null),[_,B]=T.useState(""),[R,U]=T.useState(!1);T.useEffect(()=>{y(h??[])},[h]);const D=async $=>{try{await p($),c==null||c($),l==null||l($)}catch(j){console.error("Failed to select thread:",j)}},z=async()=>{try{U(!0);const $=await g();f==null||f($),c==null||c($)}catch($){console.error("Failed to create thread:",$)}finally{U(!1)}},O=async($,j)=>{if(j.stopPropagation(),!!confirm("Delete this thread?"))try{await b($),u==null||u($)}catch(le){console.error("Failed to delete thread:",le)}},G=($,j)=>{j.stopPropagation(),F($.threadId),B($.title||`Thread ${$.threadId.slice(0,8)}`)},L=async $=>{if(_.trim())try{await w($,_.trim()),F(null),B("")}catch(j){console.error("Failed to update title:",j)}},A=()=>{F(null),B("")},ee=($,j)=>{$.key==="Enter"?L(j):$.key==="Escape"&&A()},q=$=>{if(!$)return"";try{const j=new Date($),he=new Date().getTime()-j.getTime(),W=Math.floor(he/(1e3*60*60*24));return W===0?j.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):W===1?"Yesterday":W<7?`${W} days ago`:j.toLocaleDateString()}catch{return""}},ce=$=>$.title||`Thread ${$.threadId.slice(0,8)}`;return i.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&i.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:i.jsx(fe,{onClick:z,disabled:R||C,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:R?"Creating...":"New Chat",children:i.jsx(X.MessageSquarePlus,{size:20})})}),i.jsx(Rc,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:i.jsx("div",{className:"p-2 space-y-1 pb-4",children:C?i.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):x.length===0?i.jsxs("div",{className:"text-center py-8 text-slate-400",children:[i.jsx(X.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),i.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):x.slice().sort(($,j)=>new Date(j.updatedAt||j.createdAt||"").getTime()-new Date($.updatedAt||$.createdAt||"").getTime()).map($=>i.jsxs("div",{onClick:()=>D($.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(a??m)===$.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"flex-1 min-w-0",children:M===$.threadId?i.jsxs("div",{className:"flex items-center gap-2",onClick:j=>j.stopPropagation(),children:[i.jsx(cr,{value:_,onChange:j=>B(j.target.value),onKeyDown:j=>ee(j,$.threadId),className:"h-6 text-sm",autoFocus:!0}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>L($.threadId),className:"h-6 w-6 p-0",children:i.jsx(X.Check,{size:12})}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:A,className:"h-6 w-6 p-0",children:i.jsx(X.X,{size:12})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ce($)}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[i.jsx(X.Calendar,{size:10}),i.jsx("span",{children:q($.updatedAt||$.createdAt)})]})]})}),i.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[n&&M!==$.threadId&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:j=>G($,j),className:"h-6 w-6 p-0",title:"Edit title",children:i.jsx(X.Edit3,{size:12})}),r&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:j=>O($.threadId,j),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:i.jsx(X.Trash2,{size:12})})]})]}),a===$.threadId&&i.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},$.threadId))})})]})}const qc=T.createContext(null);function mb({children:e,basePath:t="/chat"}){const r=T.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),n={basePath:r,buildThreadPath:o=>`${r}/${o}`,buildBasePath:()=>r};return i.jsx(qc.Provider,{value:n,children:e})}function bb(){const e=T.useContext(qc);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const Xc={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1};function lr(e){var o;const t=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ln&&Ln.tagName.toUpperCase()==="SCRIPT"&&Ln.src||new URL("index.umd.js",document.baseURI).href}<"u"&&Xc?Xc[e]:void 0,r=(o=globalThis==null?void 0:globalThis.process)==null?void 0:o.env,n=r?r[e]:void 0;return(t??n)||void 0}function vb(){return lr("VITE_API_BASE_URL")||lr("NEXT_PUBLIC_API_BASE_URL")||void 0}function wb(){return lr("VITE_API_KEY")||lr("NEXT_PUBLIC_API_KEY")||lr("VITE_AUTH_TOKEN")||void 0}function Yc(){const e=vb(),t=wb(),r={};return e&&(r.baseUrl=e),t&&(r.apiKey=t),r}function Jc(){const e=Yc(),t=Qe.getAuthToken();return{apiBaseUrl:e.baseUrl||Qe.baseUrl||"http://localhost:8000",apiKey:t||e.apiKey||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const Zc="chat-settings";function yb(){try{const e=localStorage.getItem(Zc);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function xb(e){try{localStorage.setItem(Zc,JSON.stringify(e)),e.apiKey&&Qe.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Sb(){const e=Jc(),t=yb(),r=Qe.getAuthToken();return{...e,...t,apiKey:r||t.apiKey||e.apiKey,apiBaseUrl:Qe.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function Cb(e){e.apiKey&&Qe.setAuthToken(e.apiKey),xb(e)}const Yo=768;function Eb(){const[e,t]=d.useState(void 0);return d.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Yo-1}px)`),n=()=>{t(window.innerWidth<Yo)};return r.addEventListener("change",n),t(window.innerWidth<Yo),()=>r.removeEventListener("change",n)},[]),!!e}var Nb="Separator",Qc="horizontal",Tb=["horizontal","vertical"],el=d.forwardRef((e,t)=>{const{decorative:r,orientation:n=Qc,...o}=e,s=Ab(n)?n:Qc,c=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(te.div,{"data-orientation":s,...c,...o,ref:t})});el.displayName=Nb;function Ab(e){return Tb.includes(e)}var tl=el;const Jo=d.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...n},o)=>i.jsx(tl,{ref:o,decorative:r,orientation:t,className:P("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));Jo.displayName=tl.displayName;var fn="Dialog",[rl,Qw]=Be(fn),[Pb,We]=rl(fn),nl=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,c=d.useRef(null),l=d.useRef(null),[f,u]=ot({prop:n,defaultProp:o??!1,onChange:s,caller:fn});return i.jsx(Pb,{scope:t,triggerRef:c,contentRef:l,contentId:Ue(),titleId:Ue(),descriptionId:Ue(),open:f,onOpenChange:u,onOpenToggle:d.useCallback(()=>u(p=>!p),[u]),modal:a,children:r})};nl.displayName=fn;var ol="DialogTrigger",sl=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(ol,r),s=ie(t,o.triggerRef);return i.jsx(te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":es(o.open),...n,ref:s,onClick:H(e.onClick,o.onOpenToggle)})});sl.displayName=ol;var Zo="DialogPortal",[Ib,al]=rl(Zo,{forceMount:void 0}),il=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=We(Zo,t);return i.jsx(Ib,{scope:t,forceMount:r,children:d.Children.map(n,a=>i.jsx(Ae,{present:r||s.open,children:i.jsx(Rr,{asChild:!0,container:o,children:a})}))})};il.displayName=Zo;var pn="DialogOverlay",cl=d.forwardRef((e,t)=>{const r=al(pn,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=We(pn,e.__scopeDialog);return s.modal?i.jsx(Ae,{present:n||s.open,children:i.jsx(kb,{...o,ref:t})}):null});cl.displayName=pn;var _b=Ie.createSlot("DialogOverlay.RemoveScroll"),kb=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(pn,r);return i.jsx(en,{as:_b,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(te.div,{"data-state":es(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),wt="DialogContent",ll=d.forwardRef((e,t)=>{const r=al(wt,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=We(wt,e.__scopeDialog);return i.jsx(Ae,{present:n||s.open,children:s.modal?i.jsx(Ob,{...o,ref:t}):i.jsx(Mb,{...o,ref:t})})});ll.displayName=wt;var Ob=d.forwardRef((e,t)=>{const r=We(wt,e.__scopeDialog),n=d.useRef(null),o=ie(t,r.contentRef,n);return d.useEffect(()=>{const s=n.current;if(s)return ko(s)},[]),i.jsx(dl,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:H(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:H(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&s.preventDefault()}),onFocusOutside:H(e.onFocusOutside,s=>s.preventDefault())})}),Mb=d.forwardRef((e,t)=>{const r=We(wt,e.__scopeDialog),n=d.useRef(!1),o=d.useRef(!1);return i.jsx(dl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(n.current||(c=r.triggerRef.current)==null||c.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{var l,f;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=r.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),dl=d.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,c=We(wt,r),l=d.useRef(null),f=ie(t,l);return io(),i.jsxs(i.Fragment,{children:[i.jsx(Lr,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(Jt,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":es(c.open),...a,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(Db,{titleId:c.titleId}),i.jsx(Fb,{contentRef:l,descriptionId:c.descriptionId})]})]})}),Qo="DialogTitle",ul=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(Qo,r);return i.jsx(te.h2,{id:o.titleId,...n,ref:t})});ul.displayName=Qo;var fl="DialogDescription",pl=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(fl,r);return i.jsx(te.p,{id:o.descriptionId,...n,ref:t})});pl.displayName=fl;var hl="DialogClose",gl=d.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=We(hl,r);return i.jsx(te.button,{type:"button",...n,ref:t,onClick:H(e.onClick,()=>o.onOpenChange(!1))})});gl.displayName=hl;function es(e){return e?"open":"closed"}var ml="DialogTitleWarning",[ey,bl]=kf(ml,{contentName:wt,titleName:Qo,docsSlug:"dialog"}),Db=({titleId:e})=>{const t=bl(ml),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
59
59
 
60
60
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
61
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teodor-new-chat-ui",
3
- "version": "3.0.11",
3
+ "version": "3.0.12",
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",