teodor-new-chat-ui 4.3.317 → 4.3.318
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -8241,7 +8241,7 @@ function h0(e) {
|
|
|
8241
8241
|
});
|
|
8242
8242
|
} else {
|
|
8243
8243
|
const s = [...o].sort(
|
|
8244
|
-
(i, a) => Date.parse(
|
|
8244
|
+
(i, a) => Date.parse(a.createdAt ?? "0") - Date.parse(i.createdAt ?? "0")
|
|
8245
8245
|
);
|
|
8246
8246
|
console.log(`[attemptDetection] Sorted ${s.length} versions for user message "${r}":`, {
|
|
8247
8247
|
versionOrder: s.map((i, a) => `v${a}: ${i.checkpointId} (${i.createdAt})`)
|
package/dist/index.umd.js
CHANGED
|
@@ -75,7 +75,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
75
75
|
`)},Cu=function(){var e=parseInt(document.body.getAttribute(Sr)||"0",10);return isFinite(e)?e:0},Lv=function(){y.useEffect(function(){return document.body.setAttribute(Sr,(Cu()+1).toString()),function(){var e=Cu()-1;e<=0?document.body.removeAttribute(Sr):document.body.setAttribute(Sr,e.toString())}},[])},$v=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Lv();var s=y.useMemo(function(){return Ov(o)},[o]);return y.createElement(Mv,{styles:Dv(s,!t,o,n?"":"!important")})},Wi=!1;if(typeof window<"u")try{var ns=Object.defineProperty({},"passive",{get:function(){return Wi=!0,!0}});window.addEventListener("test",ns,ns),window.removeEventListener("test",ns,ns)}catch{Wi=!1}var Cr=Wi?{passive:!1}:!1,Fv=function(e){return e.tagName==="TEXTAREA"},Tu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Fv(e)&&n[t]==="visible")},zv=function(e){return Tu(e,"overflowY")},Bv=function(e){return Tu(e,"overflowX")},ku=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Eu(e,r);if(o){var s=Iu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Uv=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Hv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Eu=function(e,t){return e==="v"?zv(t):Bv(t)},Iu=function(e,t){return e==="v"?Uv(t):Hv(t)},Wv=function(e,t){return e==="h"&&t==="rtl"?-1:1},Vv=function(e,t,n,r,o){var s=Wv(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,p=0;do{if(!a)break;var h=Iu(e,a),x=h[0],m=h[1],v=h[2],g=m-v-s*x;(x||g)&&Eu(e,a)&&(f+=g,p+=x);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(p)<1)&&(c=!0),c},rs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Nu=function(e){return[e.deltaX,e.deltaY]},Au=function(e){return e&&"current"in e?e.current:e},Kv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},qv=function(e){return`
|
|
76
76
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
77
77
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
78
|
-
`)},Gv=0,Tr=[];function Yv(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),o=y.useState(Gv++)[0],s=y.useState(Su)[0],i=y.useRef(e);y.useEffect(function(){i.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var m=gv([e.lockRef.current],(e.shards||[]).map(Au),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=y.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var g=rs(m),b=n.current,S="deltaX"in m?m.deltaX:b[0]-g[0],k="deltaY"in m?m.deltaY:b[1]-g[1],C,T=m.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in m&&E==="h"&&T.type==="range")return!1;var N=ku(E,T);if(!N)return!0;if(N?C=E:(C=E==="v"?"h":"v",N=ku(E,T)),!N)return!1;if(!r.current&&"changedTouches"in m&&(S||k)&&(r.current=C),!C)return!0;var _=r.current||C;return Vv(_,v,m,_==="h"?S:k)},[]),l=y.useCallback(function(m){var v=m;if(!(!Tr.length||Tr[Tr.length-1]!==s)){var g="deltaY"in v?Nu(v):rs(v),b=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&Kv(C.delta,g)})[0];if(b&&b.should){v.cancelable&&v.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Au).filter(Boolean).filter(function(C){return C.contains(v.target)}),k=S.length>0?a(v,S[0]):!i.current.noIsolation;k&&v.cancelable&&v.preventDefault()}}},[]),c=y.useCallback(function(m,v,g,b){var S={name:m,delta:v,target:g,should:b,shadowParent:Xv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=y.useCallback(function(m){n.current=rs(m),r.current=void 0},[]),f=y.useCallback(function(m){c(m.type,Nu(m),m.target,a(m,e.lockRef.current))},[]),p=y.useCallback(function(m){c(m.type,rs(m),m.target,a(m,e.lockRef.current))},[]);y.useEffect(function(){return Tr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",l,Cr),document.addEventListener("touchmove",l,Cr),document.addEventListener("touchstart",d,Cr),function(){Tr=Tr.filter(function(m){return m!==s}),document.removeEventListener("wheel",l,Cr),document.removeEventListener("touchmove",l,Cr),document.removeEventListener("touchstart",d,Cr)}},[]);var h=e.removeScrollBar,x=e.inert;return y.createElement(y.Fragment,null,x?y.createElement(s,{styles:qv(o)}):null,h?y.createElement($v,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Jv=kv(wu,Yv);var os=y.forwardRef(function(e,t){return y.createElement(ts,vn({},e,{ref:t,sideCar:Jv}))});os.classNames=ts.classNames;var Vi=["Enter"," "],Zv=["ArrowDown","PageUp","Home"],_u=["ArrowUp","PageDown","End"],Qv=[...Zv,..._u],eb={ltr:[...Vi,"ArrowRight"],rtl:[...Vi,"ArrowLeft"]},tb={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Wr="Menu",[Vr,nb,rb]=yi(Wr),[Zn,ju]=En(Wr,[rb,Go,fu]),ss=Go(),Ru=fu(),[ob,Qn]=Zn(Wr),[sb,Kr]=Zn(Wr),Pu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ss(t),[l,c]=y.useState(null),d=y.useRef(!1),f=jt(s),p=Mo(o);return y.useEffect(()=>{const h=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),u.jsx(au,{...a,children:u.jsx(ob,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(sb,{scope:t,onClose:y.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Pu.displayName=Wr;var ib="MenuAnchor",Ki=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ss(n);return u.jsx(lu,{...o,...r,ref:t})});Ki.displayName=ib;var qi="MenuPortal",[ab,Ou]=Zn(qi,{forceMount:void 0}),Mu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Qn(qi,t);return u.jsx(ab,{scope:t,forceMount:n,children:u.jsx(Qt,{present:n||s.open,children:u.jsx(Yo,{asChild:!0,container:o,children:r})})})};Mu.displayName=qi;var en="MenuContent",[lb,Gi]=Zn(en),Du=y.forwardRef((e,t)=>{const n=Ou(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Qn(en,e.__scopeMenu),i=Kr(en,e.__scopeMenu);return u.jsx(Vr.Provider,{scope:e.__scopeMenu,children:u.jsx(Qt,{present:r||s.open,children:u.jsx(Vr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(cb,{...o,ref:t}):u.jsx(ub,{...o,ref:t})})})})}),cb=y.forwardRef((e,t)=>{const n=Qn(en,e.__scopeMenu),r=y.useRef(null),o=Ye(t,r);return y.useEffect(()=>{const s=r.current;if(s)return zi(s)},[]),u.jsx(Yi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ub=y.forwardRef((e,t)=>{const n=Qn(en,e.__scopeMenu);return u.jsx(Yi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),db=qn.createSlot("MenuContent.ScrollLock"),Yi=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,disableOutsideScroll:x,...m}=e,v=Qn(en,n),g=Kr(en,n),b=ss(n),S=Ru(n),k=nb(n),[C,T]=y.useState(null),E=y.useRef(null),N=Ye(t,E,v.onContentChange),_=y.useRef(0),P=y.useRef(""),j=y.useRef(0),D=y.useRef(null),F=y.useRef("right"),A=y.useRef(0),z=x?os:y.Fragment,R=x?{as:db,allowPinchZoom:!0}:void 0,Z=O=>{var q,L;const W=P.current+O,J=k().filter(V=>!V.disabled),pe=document.activeElement,ae=(q=J.find(V=>V.ref.current===pe))==null?void 0:q.textValue,je=J.map(V=>V.textValue),G=Cb(je,W,ae),U=(L=J.find(V=>V.textValue===G))==null?void 0:L.ref.current;(function V(re){P.current=re,window.clearTimeout(_.current),re!==""&&(_.current=window.setTimeout(()=>V(""),1e3))})(W),U&&setTimeout(()=>U.focus())};y.useEffect(()=>()=>window.clearTimeout(_.current),[]),wi();const B=y.useCallback(O=>{var J,pe;return F.current===((J=D.current)==null?void 0:J.side)&&kb(O,(pe=D.current)==null?void 0:pe.area)},[]);return u.jsx(lb,{scope:n,searchRef:P,onItemEnter:y.useCallback(O=>{B(O)&&O.preventDefault()},[B]),onItemLeave:y.useCallback(O=>{var W;B(O)||((W=E.current)==null||W.focus(),T(null))},[B]),onTriggerLeave:y.useCallback(O=>{B(O)&&O.preventDefault()},[B]),pointerGraceTimerRef:j,onPointerGraceIntentChange:y.useCallback(O=>{D.current=O},[]),children:u.jsx(z,{...R,children:u.jsx(Lo,{asChild:!0,trapped:o,onMountAutoFocus:he(s,O=>{var W;O.preventDefault(),(W=E.current)==null||W.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Do,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,children:u.jsx(dv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:he(l,O=>{g.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(cu,{role:"menu","aria-orientation":"vertical","data-state":Qu(v.open),"data-radix-menu-content":"",dir:g.dir,...b,...m,ref:N,style:{outline:"none",...m.style},onKeyDown:he(m.onKeyDown,O=>{const J=O.target.closest("[data-radix-menu-content]")===O.currentTarget,pe=O.ctrlKey||O.altKey||O.metaKey,ae=O.key.length===1;J&&(O.key==="Tab"&&O.preventDefault(),!pe&&ae&&Z(O.key));const je=E.current;if(O.target!==je||!Qv.includes(O.key))return;O.preventDefault();const U=k().filter(q=>!q.disabled).map(q=>q.ref.current);_u.includes(O.key)&&U.reverse(),wb(U)}),onBlur:he(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(_.current),P.current="")}),onPointerMove:he(e.onPointerMove,Gr(O=>{const W=O.target,J=A.current!==O.clientX;if(O.currentTarget.contains(W)&&J){const pe=O.clientX>A.current?"right":"left";F.current=pe,A.current=O.clientX}}))})})})})})})});Du.displayName=en;var fb="MenuGroup",Xi=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{role:"group",...r,ref:t})});Xi.displayName=fb;var pb="MenuLabel",Lu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{...r,ref:t})});Lu.displayName=pb;var is="MenuItem",$u="menu.itemSelect",as=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=y.useRef(null),i=Kr(is,e.__scopeMenu),a=Gi(is,e.__scopeMenu),l=Ye(t,s),c=y.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent($u,{bubbles:!0,cancelable:!0});f.addEventListener($u,h=>r==null?void 0:r(h),{once:!0}),xc(f,p),p.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Fu,{...o,ref:l,disabled:n,onClick:he(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),c.current=!0},onPointerUp:he(e.onPointerUp,f=>{var p;c.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:he(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||Vi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});as.displayName=is;var Fu=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Gi(is,n),a=Ru(n),l=y.useRef(null),c=Ye(t,l),[d,f]=y.useState(!1),[p,h]=y.useState("");return y.useEffect(()=>{const x=l.current;x&&h((x.textContent??"").trim())},[s.children]),u.jsx(Vr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:u.jsx(fv,{asChild:!0,...a,focusable:!r,children:u.jsx(Pe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:he(e.onPointerMove,Gr(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:he(e.onPointerLeave,Gr(x=>i.onItemLeave(x))),onFocus:he(e.onFocus,()=>f(!0)),onBlur:he(e.onBlur,()=>f(!1))})})})}),hb="MenuCheckboxItem",zu=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Vu,{scope:e.__scopeMenu,checked:n,children:u.jsx(as,{role:"menuitemcheckbox","aria-checked":ls(n)?"mixed":n,...o,ref:t,"data-state":Zi(n),onSelect:he(o.onSelect,()=>r==null?void 0:r(ls(n)?!0:!n),{checkForDefaultPrevented:!1})})})});zu.displayName=hb;var Bu="MenuRadioGroup",[mb,gb]=Zn(Bu,{value:void 0,onValueChange:()=>{}}),Uu=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=jt(r);return u.jsx(mb,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Xi,{...o,ref:t})})});Uu.displayName=Bu;var Hu="MenuRadioItem",Wu=y.forwardRef((e,t)=>{const{value:n,...r}=e,o=gb(Hu,e.__scopeMenu),s=n===o.value;return u.jsx(Vu,{scope:e.__scopeMenu,checked:s,children:u.jsx(as,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Zi(s),onSelect:he(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Wu.displayName=Hu;var Ji="MenuItemIndicator",[Vu,xb]=Zn(Ji,{checked:!1}),Ku=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=xb(Ji,n);return u.jsx(Qt,{present:r||ls(s.checked)||s.checked===!0,children:u.jsx(Pe.span,{...o,ref:t,"data-state":Zi(s.checked)})})});Ku.displayName=Ji;var yb="MenuSeparator",qu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});qu.displayName=yb;var vb="MenuArrow",Gu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ss(n);return u.jsx(uu,{...o,...r,ref:t})});Gu.displayName=vb;var bb="MenuSub",[OT,Yu]=Zn(bb),qr="MenuSubTrigger",Xu=y.forwardRef((e,t)=>{const n=Qn(qr,e.__scopeMenu),r=Kr(qr,e.__scopeMenu),o=Yu(qr,e.__scopeMenu),s=Gi(qr,e.__scopeMenu),i=y.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=y.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return y.useEffect(()=>d,[d]),y.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(Ki,{asChild:!0,...c,children:u.jsx(Fu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Qu(n.open),...e,ref:xi(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:he(e.onPointerMove,Gr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:he(e.onPointerLeave,Gr(f=>{var h,x;d();const p=(h=n.content)==null?void 0:h.getBoundingClientRect();if(p){const m=(x=n.content)==null?void 0:x.dataset.side,v=m==="right",g=v?-5:5,b=p[v?"left":"right"],S=p[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:b,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:b,y:p.bottom}],side:m}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:he(e.onKeyDown,f=>{var h;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||eb[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});Xu.displayName=qr;var Ju="MenuSubContent",Zu=y.forwardRef((e,t)=>{const n=Ou(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Qn(en,e.__scopeMenu),i=Kr(en,e.__scopeMenu),a=Yu(Ju,e.__scopeMenu),l=y.useRef(null),c=Ye(t,l);return u.jsx(Vr.Provider,{scope:e.__scopeMenu,children:u.jsx(Qt,{present:r||s.open,children:u.jsx(Vr.Slot,{scope:e.__scopeMenu,children:u.jsx(Yi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:he(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:he(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:he(e.onKeyDown,d=>{var h;const f=d.currentTarget.contains(d.target),p=tb[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(h=a.trigger)==null||h.focus(),d.preventDefault())})})})})})});Zu.displayName=Ju;function Qu(e){return e?"open":"closed"}function ls(e){return e==="indeterminate"}function Zi(e){return ls(e)?"indeterminate":e?"checked":"unchecked"}function wb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Sb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Cb(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Sb(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Tb(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,p=l.y;d>r!=p>r&&n<(f-c)*(r-d)/(p-d)+c&&(o=!o)}return o}function kb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Tb(n,t)}function Gr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Eb=Pu,Ib=Ki,Nb=Mu,Ab=Du,_b=Xi,jb=Lu,Rb=as,Pb=zu,Ob=Uu,Mb=Wu,Db=Ku,Lb=qu,$b=Gu,Fb=Xu,zb=Zu,cs="DropdownMenu",[Bb,MT]=En(cs,[ju]),$t=ju(),[Ub,ed]=Bb(cs),td=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=y.useRef(null),[d,f]=gr({prop:o,defaultProp:s??!1,onChange:i,caller:cs});return u.jsx(Ub,{scope:t,triggerId:In(),triggerRef:c,contentId:In(),open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(p=>!p),[f]),modal:a,children:u.jsx(Eb,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};td.displayName=cs;var nd="DropdownMenuTrigger",rd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ed(nd,n),i=$t(n);return u.jsx(Ib,{asChild:!0,...i,children:u.jsx(Pe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:xi(t,s.triggerRef),onPointerDown:he(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:he(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});rd.displayName=nd;var Hb="DropdownMenuPortal",od=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(Nb,{...r,...n})};od.displayName=Hb;var sd="DropdownMenuContent",id=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ed(sd,n),s=$t(n),i=y.useRef(!1);return u.jsx(Ab,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:he(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:he(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});id.displayName=sd;var Wb="DropdownMenuGroup",Vb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(_b,{...o,...r,ref:t})});Vb.displayName=Wb;var Kb="DropdownMenuLabel",ad=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(jb,{...o,...r,ref:t})});ad.displayName=Kb;var qb="DropdownMenuItem",ld=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Rb,{...o,...r,ref:t})});ld.displayName=qb;var Gb="DropdownMenuCheckboxItem",cd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Pb,{...o,...r,ref:t})});cd.displayName=Gb;var Yb="DropdownMenuRadioGroup",Xb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Ob,{...o,...r,ref:t})});Xb.displayName=Yb;var Jb="DropdownMenuRadioItem",ud=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Mb,{...o,...r,ref:t})});ud.displayName=Jb;var Zb="DropdownMenuItemIndicator",dd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Db,{...o,...r,ref:t})});dd.displayName=Zb;var Qb="DropdownMenuSeparator",fd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Lb,{...o,...r,ref:t})});fd.displayName=Qb;var ew="DropdownMenuArrow",tw=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx($b,{...o,...r,ref:t})});tw.displayName=ew;var nw="DropdownMenuSubTrigger",pd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Fb,{...o,...r,ref:t})});pd.displayName=nw;var rw="DropdownMenuSubContent",hd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(zb,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});hd.displayName=rw;var ow=td,sw=rd,iw=od,md=id,gd=ad,xd=ld,yd=cd,vd=ud,bd=dd,wd=fd,Sd=pd,Cd=hd;const aw=ow,lw=sw,cw=y.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Sd,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ie.ChevronRight,{className:"ml-auto h-4 w-4"})]}));cw.displayName=Sd.displayName;const uw=y.forwardRef(({className:e,...t},n)=>u.jsx(Cd,{ref:n,className:ne("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}));uw.displayName=Cd.displayName;const Td=y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(iw,{children:u.jsx(md,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Td.displayName=md.displayName;const Qi=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(xd,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Qi.displayName=xd.displayName;const dw=y.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(yd,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(bd,{children:u.jsx(ie.Check,{className:"h-4 w-4"})})}),t]}));dw.displayName=yd.displayName;const fw=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(vd,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(bd,{children:u.jsx(ie.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));fw.displayName=vd.displayName;const pw=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(gd,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));pw.displayName=gd.displayName;const hw=y.forwardRef(({className:e,...t},n)=>u.jsx(wd,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));hw.displayName=wd.displayName;function mw(e){const t=new Map;console.log("[attemptDetection] groupCheckpointsByLastUserMessageId processing",e.length,"checkpoints");for(const n of e){const o=[...n.messages??[]].reverse().find(s=>s.role==="user");if(o!=null&&o.id){const s=t.get(o.id)??[];s.push(n),t.set(o.id,s),s.length===1?console.log(`[attemptDetection] New user message group: "${o.id}" checkpoint ${n.checkpointId}`):console.log(`[attemptDetection] Adding to existing group: "${o.id}" now has ${s.length} checkpoints`)}else console.log(`[attemptDetection] Checkpoint ${n.checkpointId} has no user messages`)}return console.log("[attemptDetection] Final grouping:",{totalGroups:t.size,groupSizes:Array.from(t.entries()).map(([n,r])=>({userMessageId:n,count:r.length}))}),t}function gw(e){console.log("[attemptDetection] buildAttemptMetadataMap called with",e.length,"checkpoints");const t=new Map,n=mw(e);console.log("[attemptDetection] Grouped into",n.size,"unique user message IDs");for(const[r,o]of n.entries())o.length>1&&console.log(`[attemptDetection] User message "${r}" found in ${o.length} checkpoints (EDITS DETECTED)`,{checkpointIds:o.map(s=>s.checkpointId),createdAts:o.map(s=>s.createdAt)});for(const[r,o]of n.entries())if(o.length===1){const s=o[0];s.checkpointId&&t.set(s.checkpointId,{attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:r})}else{const s=[...o].sort((i,a)=>Date.parse(i.createdAt??"0")-Date.parse(a.createdAt??"0"));console.log(`[attemptDetection] Sorted ${s.length} versions for user message "${r}":`,{versionOrder:s.map((i,a)=>`v${a}: ${i.checkpointId} (${i.createdAt})`)}),s.forEach((i,a)=>{i.checkpointId&&t.set(i.checkpointId,{attemptIndex:a,attemptCount:s.length,isLatestAttempt:a===s.length-1,baseUserMessageId:r})})}return console.log("[attemptDetection] Final versionMetadata:",{totalCheckpoints:t.size,editedMessages:Array.from(t.entries()).filter(([r,o])=>o.attemptCount>1).map(([r,o])=>({checkpointId:r,attemptIndex:o.attemptIndex,attemptCount:o.attemptCount,isLatestAttempt:o.isLatestAttempt}))}),t}function xw(e){const t=new Map;for(const[n,r]of e.entries())if(r.baseUserMessageId&&r.attemptCount>1){const o=t.get(r.baseUserMessageId)??[];o.push({checkpointId:n,attemptIndex:r.attemptIndex,attemptCount:r.attemptCount,isLatestAttempt:r.isLatestAttempt}),t.set(r.baseUserMessageId,o)}return t}const us=1e4;function yw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
78
|
+
`)},Gv=0,Tr=[];function Yv(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),o=y.useState(Gv++)[0],s=y.useState(Su)[0],i=y.useRef(e);y.useEffect(function(){i.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var m=gv([e.lockRef.current],(e.shards||[]).map(Au),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=y.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var g=rs(m),b=n.current,S="deltaX"in m?m.deltaX:b[0]-g[0],k="deltaY"in m?m.deltaY:b[1]-g[1],C,T=m.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in m&&E==="h"&&T.type==="range")return!1;var N=ku(E,T);if(!N)return!0;if(N?C=E:(C=E==="v"?"h":"v",N=ku(E,T)),!N)return!1;if(!r.current&&"changedTouches"in m&&(S||k)&&(r.current=C),!C)return!0;var _=r.current||C;return Vv(_,v,m,_==="h"?S:k)},[]),l=y.useCallback(function(m){var v=m;if(!(!Tr.length||Tr[Tr.length-1]!==s)){var g="deltaY"in v?Nu(v):rs(v),b=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&Kv(C.delta,g)})[0];if(b&&b.should){v.cancelable&&v.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Au).filter(Boolean).filter(function(C){return C.contains(v.target)}),k=S.length>0?a(v,S[0]):!i.current.noIsolation;k&&v.cancelable&&v.preventDefault()}}},[]),c=y.useCallback(function(m,v,g,b){var S={name:m,delta:v,target:g,should:b,shadowParent:Xv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=y.useCallback(function(m){n.current=rs(m),r.current=void 0},[]),f=y.useCallback(function(m){c(m.type,Nu(m),m.target,a(m,e.lockRef.current))},[]),p=y.useCallback(function(m){c(m.type,rs(m),m.target,a(m,e.lockRef.current))},[]);y.useEffect(function(){return Tr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",l,Cr),document.addEventListener("touchmove",l,Cr),document.addEventListener("touchstart",d,Cr),function(){Tr=Tr.filter(function(m){return m!==s}),document.removeEventListener("wheel",l,Cr),document.removeEventListener("touchmove",l,Cr),document.removeEventListener("touchstart",d,Cr)}},[]);var h=e.removeScrollBar,x=e.inert;return y.createElement(y.Fragment,null,x?y.createElement(s,{styles:qv(o)}):null,h?y.createElement($v,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Jv=kv(wu,Yv);var os=y.forwardRef(function(e,t){return y.createElement(ts,vn({},e,{ref:t,sideCar:Jv}))});os.classNames=ts.classNames;var Vi=["Enter"," "],Zv=["ArrowDown","PageUp","Home"],_u=["ArrowUp","PageDown","End"],Qv=[...Zv,..._u],eb={ltr:[...Vi,"ArrowRight"],rtl:[...Vi,"ArrowLeft"]},tb={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Wr="Menu",[Vr,nb,rb]=yi(Wr),[Zn,ju]=En(Wr,[rb,Go,fu]),ss=Go(),Ru=fu(),[ob,Qn]=Zn(Wr),[sb,Kr]=Zn(Wr),Pu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ss(t),[l,c]=y.useState(null),d=y.useRef(!1),f=jt(s),p=Mo(o);return y.useEffect(()=>{const h=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),u.jsx(au,{...a,children:u.jsx(ob,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(sb,{scope:t,onClose:y.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Pu.displayName=Wr;var ib="MenuAnchor",Ki=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ss(n);return u.jsx(lu,{...o,...r,ref:t})});Ki.displayName=ib;var qi="MenuPortal",[ab,Ou]=Zn(qi,{forceMount:void 0}),Mu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Qn(qi,t);return u.jsx(ab,{scope:t,forceMount:n,children:u.jsx(Qt,{present:n||s.open,children:u.jsx(Yo,{asChild:!0,container:o,children:r})})})};Mu.displayName=qi;var en="MenuContent",[lb,Gi]=Zn(en),Du=y.forwardRef((e,t)=>{const n=Ou(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Qn(en,e.__scopeMenu),i=Kr(en,e.__scopeMenu);return u.jsx(Vr.Provider,{scope:e.__scopeMenu,children:u.jsx(Qt,{present:r||s.open,children:u.jsx(Vr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(cb,{...o,ref:t}):u.jsx(ub,{...o,ref:t})})})})}),cb=y.forwardRef((e,t)=>{const n=Qn(en,e.__scopeMenu),r=y.useRef(null),o=Ye(t,r);return y.useEffect(()=>{const s=r.current;if(s)return zi(s)},[]),u.jsx(Yi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ub=y.forwardRef((e,t)=>{const n=Qn(en,e.__scopeMenu);return u.jsx(Yi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),db=qn.createSlot("MenuContent.ScrollLock"),Yi=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,disableOutsideScroll:x,...m}=e,v=Qn(en,n),g=Kr(en,n),b=ss(n),S=Ru(n),k=nb(n),[C,T]=y.useState(null),E=y.useRef(null),N=Ye(t,E,v.onContentChange),_=y.useRef(0),P=y.useRef(""),j=y.useRef(0),D=y.useRef(null),F=y.useRef("right"),A=y.useRef(0),z=x?os:y.Fragment,R=x?{as:db,allowPinchZoom:!0}:void 0,Z=O=>{var q,L;const W=P.current+O,J=k().filter(V=>!V.disabled),pe=document.activeElement,ae=(q=J.find(V=>V.ref.current===pe))==null?void 0:q.textValue,je=J.map(V=>V.textValue),G=Cb(je,W,ae),U=(L=J.find(V=>V.textValue===G))==null?void 0:L.ref.current;(function V(re){P.current=re,window.clearTimeout(_.current),re!==""&&(_.current=window.setTimeout(()=>V(""),1e3))})(W),U&&setTimeout(()=>U.focus())};y.useEffect(()=>()=>window.clearTimeout(_.current),[]),wi();const B=y.useCallback(O=>{var J,pe;return F.current===((J=D.current)==null?void 0:J.side)&&kb(O,(pe=D.current)==null?void 0:pe.area)},[]);return u.jsx(lb,{scope:n,searchRef:P,onItemEnter:y.useCallback(O=>{B(O)&&O.preventDefault()},[B]),onItemLeave:y.useCallback(O=>{var W;B(O)||((W=E.current)==null||W.focus(),T(null))},[B]),onTriggerLeave:y.useCallback(O=>{B(O)&&O.preventDefault()},[B]),pointerGraceTimerRef:j,onPointerGraceIntentChange:y.useCallback(O=>{D.current=O},[]),children:u.jsx(z,{...R,children:u.jsx(Lo,{asChild:!0,trapped:o,onMountAutoFocus:he(s,O=>{var W;O.preventDefault(),(W=E.current)==null||W.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Do,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,children:u.jsx(dv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:he(l,O=>{g.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(cu,{role:"menu","aria-orientation":"vertical","data-state":Qu(v.open),"data-radix-menu-content":"",dir:g.dir,...b,...m,ref:N,style:{outline:"none",...m.style},onKeyDown:he(m.onKeyDown,O=>{const J=O.target.closest("[data-radix-menu-content]")===O.currentTarget,pe=O.ctrlKey||O.altKey||O.metaKey,ae=O.key.length===1;J&&(O.key==="Tab"&&O.preventDefault(),!pe&&ae&&Z(O.key));const je=E.current;if(O.target!==je||!Qv.includes(O.key))return;O.preventDefault();const U=k().filter(q=>!q.disabled).map(q=>q.ref.current);_u.includes(O.key)&&U.reverse(),wb(U)}),onBlur:he(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(_.current),P.current="")}),onPointerMove:he(e.onPointerMove,Gr(O=>{const W=O.target,J=A.current!==O.clientX;if(O.currentTarget.contains(W)&&J){const pe=O.clientX>A.current?"right":"left";F.current=pe,A.current=O.clientX}}))})})})})})})});Du.displayName=en;var fb="MenuGroup",Xi=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{role:"group",...r,ref:t})});Xi.displayName=fb;var pb="MenuLabel",Lu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{...r,ref:t})});Lu.displayName=pb;var is="MenuItem",$u="menu.itemSelect",as=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=y.useRef(null),i=Kr(is,e.__scopeMenu),a=Gi(is,e.__scopeMenu),l=Ye(t,s),c=y.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent($u,{bubbles:!0,cancelable:!0});f.addEventListener($u,h=>r==null?void 0:r(h),{once:!0}),xc(f,p),p.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Fu,{...o,ref:l,disabled:n,onClick:he(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),c.current=!0},onPointerUp:he(e.onPointerUp,f=>{var p;c.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:he(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||Vi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});as.displayName=is;var Fu=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Gi(is,n),a=Ru(n),l=y.useRef(null),c=Ye(t,l),[d,f]=y.useState(!1),[p,h]=y.useState("");return y.useEffect(()=>{const x=l.current;x&&h((x.textContent??"").trim())},[s.children]),u.jsx(Vr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:u.jsx(fv,{asChild:!0,...a,focusable:!r,children:u.jsx(Pe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:he(e.onPointerMove,Gr(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:he(e.onPointerLeave,Gr(x=>i.onItemLeave(x))),onFocus:he(e.onFocus,()=>f(!0)),onBlur:he(e.onBlur,()=>f(!1))})})})}),hb="MenuCheckboxItem",zu=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Vu,{scope:e.__scopeMenu,checked:n,children:u.jsx(as,{role:"menuitemcheckbox","aria-checked":ls(n)?"mixed":n,...o,ref:t,"data-state":Zi(n),onSelect:he(o.onSelect,()=>r==null?void 0:r(ls(n)?!0:!n),{checkForDefaultPrevented:!1})})})});zu.displayName=hb;var Bu="MenuRadioGroup",[mb,gb]=Zn(Bu,{value:void 0,onValueChange:()=>{}}),Uu=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=jt(r);return u.jsx(mb,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Xi,{...o,ref:t})})});Uu.displayName=Bu;var Hu="MenuRadioItem",Wu=y.forwardRef((e,t)=>{const{value:n,...r}=e,o=gb(Hu,e.__scopeMenu),s=n===o.value;return u.jsx(Vu,{scope:e.__scopeMenu,checked:s,children:u.jsx(as,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Zi(s),onSelect:he(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Wu.displayName=Hu;var Ji="MenuItemIndicator",[Vu,xb]=Zn(Ji,{checked:!1}),Ku=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=xb(Ji,n);return u.jsx(Qt,{present:r||ls(s.checked)||s.checked===!0,children:u.jsx(Pe.span,{...o,ref:t,"data-state":Zi(s.checked)})})});Ku.displayName=Ji;var yb="MenuSeparator",qu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});qu.displayName=yb;var vb="MenuArrow",Gu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ss(n);return u.jsx(uu,{...o,...r,ref:t})});Gu.displayName=vb;var bb="MenuSub",[OT,Yu]=Zn(bb),qr="MenuSubTrigger",Xu=y.forwardRef((e,t)=>{const n=Qn(qr,e.__scopeMenu),r=Kr(qr,e.__scopeMenu),o=Yu(qr,e.__scopeMenu),s=Gi(qr,e.__scopeMenu),i=y.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=y.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return y.useEffect(()=>d,[d]),y.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(Ki,{asChild:!0,...c,children:u.jsx(Fu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Qu(n.open),...e,ref:xi(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:he(e.onPointerMove,Gr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:he(e.onPointerLeave,Gr(f=>{var h,x;d();const p=(h=n.content)==null?void 0:h.getBoundingClientRect();if(p){const m=(x=n.content)==null?void 0:x.dataset.side,v=m==="right",g=v?-5:5,b=p[v?"left":"right"],S=p[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:b,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:b,y:p.bottom}],side:m}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:he(e.onKeyDown,f=>{var h;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||eb[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});Xu.displayName=qr;var Ju="MenuSubContent",Zu=y.forwardRef((e,t)=>{const n=Ou(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Qn(en,e.__scopeMenu),i=Kr(en,e.__scopeMenu),a=Yu(Ju,e.__scopeMenu),l=y.useRef(null),c=Ye(t,l);return u.jsx(Vr.Provider,{scope:e.__scopeMenu,children:u.jsx(Qt,{present:r||s.open,children:u.jsx(Vr.Slot,{scope:e.__scopeMenu,children:u.jsx(Yi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:he(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:he(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:he(e.onKeyDown,d=>{var h;const f=d.currentTarget.contains(d.target),p=tb[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(h=a.trigger)==null||h.focus(),d.preventDefault())})})})})})});Zu.displayName=Ju;function Qu(e){return e?"open":"closed"}function ls(e){return e==="indeterminate"}function Zi(e){return ls(e)?"indeterminate":e?"checked":"unchecked"}function wb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Sb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Cb(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Sb(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Tb(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,p=l.y;d>r!=p>r&&n<(f-c)*(r-d)/(p-d)+c&&(o=!o)}return o}function kb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Tb(n,t)}function Gr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Eb=Pu,Ib=Ki,Nb=Mu,Ab=Du,_b=Xi,jb=Lu,Rb=as,Pb=zu,Ob=Uu,Mb=Wu,Db=Ku,Lb=qu,$b=Gu,Fb=Xu,zb=Zu,cs="DropdownMenu",[Bb,MT]=En(cs,[ju]),$t=ju(),[Ub,ed]=Bb(cs),td=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=y.useRef(null),[d,f]=gr({prop:o,defaultProp:s??!1,onChange:i,caller:cs});return u.jsx(Ub,{scope:t,triggerId:In(),triggerRef:c,contentId:In(),open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(p=>!p),[f]),modal:a,children:u.jsx(Eb,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};td.displayName=cs;var nd="DropdownMenuTrigger",rd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ed(nd,n),i=$t(n);return u.jsx(Ib,{asChild:!0,...i,children:u.jsx(Pe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:xi(t,s.triggerRef),onPointerDown:he(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:he(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});rd.displayName=nd;var Hb="DropdownMenuPortal",od=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(Nb,{...r,...n})};od.displayName=Hb;var sd="DropdownMenuContent",id=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ed(sd,n),s=$t(n),i=y.useRef(!1);return u.jsx(Ab,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:he(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:he(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});id.displayName=sd;var Wb="DropdownMenuGroup",Vb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(_b,{...o,...r,ref:t})});Vb.displayName=Wb;var Kb="DropdownMenuLabel",ad=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(jb,{...o,...r,ref:t})});ad.displayName=Kb;var qb="DropdownMenuItem",ld=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Rb,{...o,...r,ref:t})});ld.displayName=qb;var Gb="DropdownMenuCheckboxItem",cd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Pb,{...o,...r,ref:t})});cd.displayName=Gb;var Yb="DropdownMenuRadioGroup",Xb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Ob,{...o,...r,ref:t})});Xb.displayName=Yb;var Jb="DropdownMenuRadioItem",ud=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Mb,{...o,...r,ref:t})});ud.displayName=Jb;var Zb="DropdownMenuItemIndicator",dd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Db,{...o,...r,ref:t})});dd.displayName=Zb;var Qb="DropdownMenuSeparator",fd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Lb,{...o,...r,ref:t})});fd.displayName=Qb;var ew="DropdownMenuArrow",tw=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx($b,{...o,...r,ref:t})});tw.displayName=ew;var nw="DropdownMenuSubTrigger",pd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Fb,{...o,...r,ref:t})});pd.displayName=nw;var rw="DropdownMenuSubContent",hd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(zb,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});hd.displayName=rw;var ow=td,sw=rd,iw=od,md=id,gd=ad,xd=ld,yd=cd,vd=ud,bd=dd,wd=fd,Sd=pd,Cd=hd;const aw=ow,lw=sw,cw=y.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Sd,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ie.ChevronRight,{className:"ml-auto h-4 w-4"})]}));cw.displayName=Sd.displayName;const uw=y.forwardRef(({className:e,...t},n)=>u.jsx(Cd,{ref:n,className:ne("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}));uw.displayName=Cd.displayName;const Td=y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(iw,{children:u.jsx(md,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Td.displayName=md.displayName;const Qi=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(xd,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Qi.displayName=xd.displayName;const dw=y.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(yd,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(bd,{children:u.jsx(ie.Check,{className:"h-4 w-4"})})}),t]}));dw.displayName=yd.displayName;const fw=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(vd,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(bd,{children:u.jsx(ie.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));fw.displayName=vd.displayName;const pw=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(gd,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));pw.displayName=gd.displayName;const hw=y.forwardRef(({className:e,...t},n)=>u.jsx(wd,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));hw.displayName=wd.displayName;function mw(e){const t=new Map;console.log("[attemptDetection] groupCheckpointsByLastUserMessageId processing",e.length,"checkpoints");for(const n of e){const o=[...n.messages??[]].reverse().find(s=>s.role==="user");if(o!=null&&o.id){const s=t.get(o.id)??[];s.push(n),t.set(o.id,s),s.length===1?console.log(`[attemptDetection] New user message group: "${o.id}" checkpoint ${n.checkpointId}`):console.log(`[attemptDetection] Adding to existing group: "${o.id}" now has ${s.length} checkpoints`)}else console.log(`[attemptDetection] Checkpoint ${n.checkpointId} has no user messages`)}return console.log("[attemptDetection] Final grouping:",{totalGroups:t.size,groupSizes:Array.from(t.entries()).map(([n,r])=>({userMessageId:n,count:r.length}))}),t}function gw(e){console.log("[attemptDetection] buildAttemptMetadataMap called with",e.length,"checkpoints");const t=new Map,n=mw(e);console.log("[attemptDetection] Grouped into",n.size,"unique user message IDs");for(const[r,o]of n.entries())o.length>1&&console.log(`[attemptDetection] User message "${r}" found in ${o.length} checkpoints (EDITS DETECTED)`,{checkpointIds:o.map(s=>s.checkpointId),createdAts:o.map(s=>s.createdAt)});for(const[r,o]of n.entries())if(o.length===1){const s=o[0];s.checkpointId&&t.set(s.checkpointId,{attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:r})}else{const s=[...o].sort((i,a)=>Date.parse(a.createdAt??"0")-Date.parse(i.createdAt??"0"));console.log(`[attemptDetection] Sorted ${s.length} versions for user message "${r}":`,{versionOrder:s.map((i,a)=>`v${a}: ${i.checkpointId} (${i.createdAt})`)}),s.forEach((i,a)=>{i.checkpointId&&t.set(i.checkpointId,{attemptIndex:a,attemptCount:s.length,isLatestAttempt:a===s.length-1,baseUserMessageId:r})})}return console.log("[attemptDetection] Final versionMetadata:",{totalCheckpoints:t.size,editedMessages:Array.from(t.entries()).filter(([r,o])=>o.attemptCount>1).map(([r,o])=>({checkpointId:r,attemptIndex:o.attemptIndex,attemptCount:o.attemptCount,isLatestAttempt:o.isLatestAttempt}))}),t}function xw(e){const t=new Map;for(const[n,r]of e.entries())if(r.baseUserMessageId&&r.attemptCount>1){const o=t.get(r.baseUserMessageId)??[];o.push({checkpointId:n,attemptIndex:r.attemptIndex,attemptCount:r.attemptCount,isLatestAttempt:r.isLatestAttempt}),t.set(r.baseUserMessageId,o)}return t}const us=1e4;function yw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
79
79
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
80
80
|
|
|
81
81
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
|
package/package.json
CHANGED