Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
TypeScript aiai-agentsai-memoryanthropicartificial-intelligencechromadbclaudeclaude-agent-sdkclaude-agentsclaude-codeclaude-code-pluginclaude-skillsembeddingslong-term-memorymem0memory-engineopenmemoryragsqlitesupermemory
import{C as e,D as t,E as n,N as r,O as i,S as a,_ as o,a as s,b as c,c as l,d as u,f as d,j as f,k as p,o as m,p as h,u as g,w as _,y as v}from"./served-from-8DzM0VAM.js";import{C as y,D as b,E as x,S,T as C,_ as w,a as T,b as ee,c as E,d as te,f as ne,g as D,h as O,i as re,m as k,n as A,o as ie,p as ae,r as oe,rt as j,s as se,u as ce,v as le,w as ue,y as de}from"./local-source-emarjVnA.js";import{a as fe,c as pe,o as me,s as he,t as ge}from"./brand-DA3Kl5y4.js";import{S as _e,a as M,c as ve,g as ye,h as be,l as xe,o as N,s as P,u as Se}from"./focus-overview-CQWF43T3.js";import{t as Ce}from"./file-text-xgr1MEDu.js";import{$ as F,B as we,C as Te,G as Ee,J as De,O as Oe,U as ke,_ as Ae,c as je,d as Me,f as Ne,m as Pe,s as Fe,u as Ie,w as Le}from"./parse-sse-frame-DXl4zDFf.js";import{B as Re,E as ze,G as Be,H as Ve,K as He,R as Ue,T as We,U as Ge,V as Ke,W as qe,a as Je,c as I,l as L,q as Ye,t as R,u as Xe,z as Ze}from"./req-DRjqKS_G.js";import{$ as Qe,An as $e,Cn as et,Dn as tt,H as nt,Ht as z,In as rt,Jn as it,Jt as at,L as ot,On as st,Q as ct,R as lt,Tn as ut,V as dt,Xn as ft,Xt as pt,Yt as mt,Zt as ht,_n as B,an as gt,ar as _t,bn as vt,cn as yt,d as bt,dn as xt,dr as St,fn as Ct,fr as wt,h as Tt,hn as Et,j as Dt,jn as Ot,k as kt,kn as At,ln as jt,lr as Mt,mr as Nt,n as Pt,nn as Ft,or as It,pr as Lt,qt as Rt,sr as zt,t as Bt,u as Vt,un as Ht,wn as Ut,xn as Wt,z as Gt}from"./index-Dknlc6p6.js";import{a as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./command-90ksKm7u.js";import{r as $t,s as en}from"./review-stack-client-DzMErSoo.js";var tn={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};tn.node;var nn=i(tn),rn={name:`circle-slash`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]};rn.node;var an=i(rn),on={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};on.node;var sn=i(on),cn={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};cn.node;var ln=i(cn),un={name:`folder-input`,size:24,node:[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]};un.node;var dn=i(un),fn={name:`folder-x`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]};fn.node;var pn=i(fn),mn={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};mn.node;var hn=i(mn),gn={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};gn.node;var _n=i(gn),vn={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};vn.node;var yn=i(vn),bn={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};bn.node;var xn=i(bn),Sn={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Sn.node;var Cn=i(Sn),wn={name:`megaphone`,size:24,node:[[`path`,{d:`M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z`,key:`q8bfy3`}],[`path`,{d:`M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14`,key:`1853fq`}],[`path`,{d:`M8 6v8`,key:`15ugcq`}]]};wn.node;var Tn=i(wn),En={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};En.node;var Dn=i(En),On={name:`presentation`,size:24,node:[[`path`,{d:`M2 3h20`,key:`91anmk`}],[`path`,{d:`M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3`,key:`2k9sn8`}],[`path`,{d:`m7 21 5-5 5 5`,key:`bip4we`}]]};On.node;var kn=i(On),An={name:`quote`,size:24,node:[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]};An.node;var jn=i(An),Mn={name:`split`,size:24,node:[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]};Mn.node;var Nn=i(Mn),Pn={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Pn.node;var Fn=i(Pn),In={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};In.node;var Ln=i(In),Rn={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Rn.node;var zn=i(Rn),V=r(f(),1),H=p(),Bn=Object.defineProperty,U=(e,t)=>Bn(e,`name`,{value:t,configurable:!0}),Vn=`Progress`,Hn=100,[Un,Wn]=d(Vn),[Gn,Kn]=Un(Vn),qn=V.forwardRef(U(function(e,t){let{__scopeProgress:n,value:r=null,max:i,getValueLabel:a=Xn,...o}=e;(i||i===0)&&!$n(i)&&console.error(tr(`${i}`,`Progress`));let s=$n(i)?i:Hn;r!==null&&!er(r,s)&&console.error(nr(`${r}`,`Progress`));let c=er(r,s)?r:null,l=Qn(c)?a(c,s):void 0;return(0,H.jsx)(Gn,{scope:n,value:c,max:s,children:(0,H.jsx)(h.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":Qn(c)?c:void 0,"aria-valuetext":l,role:`progressbar`,"data-state":Zn(c,s),"data-value":c??void 0,"data-max":s,...o,ref:t})})},`Progress`)),Jn=`ProgressIndicator`,Yn=V.forwardRef(U(function(e,t){let{__scopeProgress:n,...r}=e,i=Kn(Jn,n);return(0,H.jsx)(h.div,{"data-state":Zn(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...r,ref:t})},`ProgressIndicator`));function Xn(e,t){return`${Math.round(e/t*100)}%`}U(Xn,`defaultGetValueLabel`);function Zn(e,t){return e==null?`indeterminate`:e===t?`complete`:`loading`}U(Zn,`getProgressState`);function Qn(e){return typeof e==`number`}U(Qn,`isNumber`);function $n(e){return Qn(e)&&!isNaN(e)&&e>0}U($n,`isValidMaxNumber`);function er(e,t){return Qn(e)&&!isNaN(e)&&e<=t&&e>=0}U(er,`isValidValueNumber`);function tr(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Hn}\`.`}U(tr,`getInvalidMaxError`);function nr(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
- a positive number
- less than the value passed to \`max\` (or ${Hn} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`}U(nr,`getInvalidValueError`);var rr=Object.defineProperty,W=(e,t)=>rr(e,`name`,{value:t,configurable:!0});function ir(e,t){return V.useReducer((e,n)=>t[e][n]??e,e)}W(ir,`useStateMachine`);var G={Auto:`auto`,Always:`always`,Scroll:`scroll`,Hover:`hover`},K={Vertical:`vertical`,Horizontal:`horizontal`},q={LTR:`ltr`,RTL:`rtl`},ar=`ScrollArea`,[or,sr]=d(ar),[cr,J]=or(ar),lr=V.forwardRef(W(function(e,t){let{__scopeScrollArea:n,type:r=G.Hover,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=V.useState(null),[l,u]=V.useState(null),[d,f]=V.useState(null),[p,m]=V.useState(null),[g,_]=V.useState(null),[y,b]=V.useState(0),[x,S]=V.useState(0),[C,w]=V.useState(!1),[T,ee]=V.useState(!1),E=v(t,c),te=rt(i);return(0,H.jsx)(cr,{scope:n,type:r,dir:te,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:C,onScrollbarXEnabledChange:w,scrollbarY:g,onScrollbarYChange:_,scrollbarYEnabled:T,onScrollbarYEnabledChange:ee,onCornerWidthChange:b,onCornerHeightChange:S,children:(0,H.jsx)(h.div,{dir:te,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":y+`px`,"--radix-scroll-area-corner-height":x+`px`,...e.style}})})},`ScrollArea`)),ur=`ScrollAreaViewport`,dr=o(ur),fr=V.forwardRef(W(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,disableImplicitContentElement:a,...o}=e,s=J(ur,n),c=V.useRef(null),l=v(t,c,s.onViewportChange),u=V.isValidElement(r);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(pr,{nonce:i}),(0,H.jsx)(h.div,{"data-radix-scroll-area-viewport":``,...o,ref:l,style:{overflowX:s.scrollbarXEnabled?`scroll`:`hidden`,overflowY:s.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:a?r:u?(0,H.jsx)(dr,{child:r,children:e=>(0,H.jsx)(hr,{__scopeScrollArea:n,children:e})}):(0,H.jsx)(dr,{children:(0,H.jsx)(hr,{__scopeScrollArea:n,children:r})})})]})},`ScrollAreaViewport`)),pr=V.memo(W(function({nonce:e}){return(0,H.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:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),mr=`ScrollAreaContent`,hr=V.forwardRef(W(function(e,t){let{__scopeScrollArea:n,children:r,...i}=e,a=J(mr,n),o=v(t,a.onContentChange);return(0,H.jsx)(h.div,{...i,ref:o,style:{minWidth:`100%`,display:`table`,...e.style},children:r})},`ScrollAreaContent`)),Y=`ScrollAreaScrollbar`,gr=V.forwardRef(W(function(e,t){let{forceMount:n,...r}=e,i=J(Y,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===K.Horizontal;return V.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===G.Hover?(0,H.jsx)(_r,{...r,ref:t,forceMount:n}):i.type===G.Scroll?(0,H.jsx)(vr,{...r,ref:t,forceMount:n}):i.type===G.Auto?(0,H.jsx)(yr,{...r,ref:t,forceMount:n}):i.type===G.Always?(0,H.jsx)(br,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),_r=V.forwardRef(W(function(e,t){let{forceMount:n,...r}=e,i=J(Y,e.__scopeScrollArea),[a,o]=V.useState(!1);return V.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=W(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=W(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,H.jsx)(l,{present:n||a,children:(0,H.jsx)(yr,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),vr=V.forwardRef(W(function(e,t){let{forceMount:n,...r}=e,i=J(Y,e.__scopeScrollArea),a=e.orientation===K.Horizontal,o=Br(()=>c(`SCROLL_END`),100),[s,c]=ir(`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 V.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),V.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=W(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,H.jsx)(l,{present:n||s!==`hidden`,children:(0,H.jsx)(br,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:g(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:g(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),yr=V.forwardRef(W(function(e,t){let n=J(Y,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=V.useState(!1),s=e.orientation===K.Horizontal,c=Br(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return X(n.viewport,c),X(n.content,c),(0,H.jsx)(l,{present:r||a,children:(0,H.jsx)(br,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),br=V.forwardRef(W(function(e,t){let{orientation:n=K.Vertical,...r}=e,i=J(Y,e.__scopeScrollArea),a=V.useRef(null),o=V.useRef(0),[s,c]=V.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=Nr(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:W(e=>a.current=e,`onThumbChange`),onThumbPointerUp:W(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:W(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return Fr(e,o.current,s,t)}return W(d,`getScrollPosition`),n===K.Horizontal?(0,H.jsx)(xr,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=Ir(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===K.Vertical?(0,H.jsx)(Sr,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=Ir(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),xr=V.forwardRef(W(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=J(Y,e.__scopeScrollArea),[o,s]=V.useState(),c=V.useRef(null),l=v(t,c,a.onScrollbarXChange);return V.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(Tr,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===q.RTL?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===q.LTR?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":Pr(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Rr(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Mr(o.paddingLeft),paddingEnd:Mr(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),Sr=V.forwardRef(W(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=J(Y,e.__scopeScrollArea),[o,s]=V.useState(),c=V.useRef(null),l=v(t,c,a.onScrollbarYChange);return V.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(Tr,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===q.LTR?0:void 0,left:a.dir===q.RTL?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":Pr(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Rr(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Mr(o.paddingTop),paddingEnd:Mr(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[Cr,wr]=or(Y),Tr=V.forwardRef(W(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=J(Y,n),[m,_]=V.useState(null),y=v(t,_),b=V.useRef(null),x=V.useRef(``),S=p.viewport,C=r.content-r.viewport,w=j(u),T=j(c),ee=Br(d,10);function E(e){if(b.current){let t=e.clientX-b.current.left,n=e.clientY-b.current.top;l({x:t,y:n})}}return W(E,`handleDragScroll`),V.useEffect(()=>{let e=W(e=>{let t=e.target;m?.contains(t)&&w(e,C)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[S,m,C,w]),V.useEffect(T,[r,T]),X(m,ee),X(p.content,ee),(0,H.jsx)(Cr,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:j(a),onThumbPointerUp:j(o),onThumbPositionChange:T,onThumbPointerDown:j(s),children:(0,H.jsx)(h.div,{...f,ref:y,style:{position:`absolute`,...f.style},onPointerDown:g(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),b.current=m.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),E(e))}),onPointerMove:g(e.onPointerMove,E),onPointerUp:g(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=x.current,p.viewport&&(p.viewport.style.scrollBehavior=``),b.current=null})})})},`ScrollAreaScrollbarImpl`)),Er=`ScrollAreaThumb`,Dr=V.forwardRef(W(function(e,t){let{forceMount:n,...r}=e,i=wr(Er,e.__scopeScrollArea);return(0,H.jsx)(l,{present:n||i.hasThumb,children:(0,H.jsx)(Or,{ref:t,...r})})},`ScrollAreaThumb`)),Or=V.forwardRef(W(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=J(Er,n),o=wr(Er,n),{onThumbPositionChange:s}=o,c=v(t,o.onThumbChange),l=V.useRef(void 0),u=Br(()=>{l.current&&=(l.current(),void 0)},100);return V.useEffect(()=>{let e=a.viewport;if(e){let t=W(()=>{if(u(),!l.current){let t=zr(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,H.jsx)(h.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:g(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:g(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),kr=`ScrollAreaCorner`,Ar=V.forwardRef(W(function(e,t){let n=J(kr,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==G.Scroll&&r?(0,H.jsx)(jr,{...e,ref:t}):null},`ScrollAreaCorner`)),jr=V.forwardRef(W(function(e,t){let{__scopeScrollArea:n,...r}=e,i=J(kr,n),[a,o]=V.useState(0),[s,c]=V.useState(0),l=!!(a&&s),{onCornerWidthChange:u,onCornerHeightChange:d}=i;return X(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),X(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),V.useEffect(()=>()=>{u(0),d(0)},[u,d]),l?(0,H.jsx)(h.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===q.LTR?0:void 0,left:i.dir===q.RTL?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function Mr(e){return e?parseInt(e,10):0}W(Mr,`toInt`);function Nr(e,t){let n=e/t;return isNaN(n)?0:n}W(Nr,`getThumbRatio`);function Pr(e){let t=Nr(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}W(Pr,`getThumbSize`);function Fr(e,t,n,r=q.LTR){let i=Pr(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===q.LTR?[0,u]:[u*-1,0];return Lr([c,l],d)(e)}W(Fr,`getScrollPositionFromPointer`);function Ir(e,t,n=q.LTR){let r=Pr(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=n===q.LTR?[0,o]:[o*-1,0],l=Ot(e,c);return Lr([0,o],[0,s])(l)}W(Ir,`getThumbOffsetFromScroll`);function Lr(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}W(Lr,`linearScale`);function Rr(e,t){return e>0&&e<t}W(Rr,`isScrollingWithinScrollbarBounds`);var zr=W((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}return W(i,`loop`),i(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function Br(e,t){let n=j(e),r=V.useRef(0);return V.useEffect(()=>()=>window.clearTimeout(r.current),[]),V.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}W(Br,`useDebounceCallback`);function X(e,t){let n=j(t);u(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}W(X,`useResizeObserver`);var Vr=(0,V.memo)(({className:e,defaultOpen:t=!1,children:n,...r})=>(0,H.jsx)(M,{defaultOpen:t,className:c(`not-prose w-full space-y-4`,e),...r,children:n})),Hr=(0,V.memo)(({className:e,children:t,count:n,...r})=>{let{t:i}=a();return(0,H.jsx)(ve,{className:c(xe,e),...r,children:(0,H.jsx)(Se,{count:n,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(ft,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),t??i(`Build story`)]})})})}),Ur={active:`text-foreground`,complete:`text-foreground/90`,pending:`text-muted-foreground`},Wr={complete:()=>(0,H.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-muted-foreground text-card`,children:(0,H.jsx)(t,{className:`size-3 stroke-3`})}),active:()=>(0,H.jsx)(`span`,{className:`block size-4 rounded-full border-2 border-working-foreground`}),pending:()=>(0,H.jsx)(`span`,{className:`block size-4 rounded-full border-[1.5px] border-dashed border-control-edge`})},Gr=(0,V.memo)(({className:e,icon:t,label:n,description:r,time:i,status:a=`complete`,children:o,...s})=>(0,H.jsxs)(`div`,{"data-step-status":a,className:c(`flex gap-2.5 text-sm`,Ur[a],e),...s,children:[(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`relative mt-0.5 shrink-0`,children:[t?(0,H.jsx)(t,{className:`size-4`}):Wr[a](),(0,H.jsx)(`div`,{className:`absolute top-6 -bottom-2 left-1/2 -mx-px w-px bg-control-edge/55`})]}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[i&&(0,H.jsx)(`div`,{"data-slot":`chain-of-thought-step-time`,className:`mono-number text-xs text-muted-foreground`,children:i}),(0,H.jsx)(`div`,{className:`font-medium [overflow-wrap:anywhere]`,children:n}),r&&(0,H.jsx)(`div`,{"data-slot":`chain-of-thought-step-description`,className:`text-muted-foreground text-xs`,children:r}),o]})]})),Kr=5,qr=({steps:e})=>{let{t}=a(),n=e.slice(0,Math.max(0,e.length-Kr)),r=e.slice(n.length),i=e=>e.at===void 0?void 0:e.at===null?t(`Date not recorded`):ye(e.atIso,e.at,`time-or-day`),o=(e,t)=>(0,H.jsx)(Gr,{label:e.label,time:i(e),description:e.description,status:e.status},`${t}:${e.label}`);return(0,H.jsxs)(`div`,{"data-slot":`chain-of-thought-steps`,className:`space-y-3`,children:[n.length>0&&(0,H.jsxs)(M,{children:[(0,H.jsx)(P,{children:F(n.length===1?t(`{count} earlier step`):t(`{count} earlier steps`),{count:n.length})}),(0,H.jsx)(N,{className:`space-y-3 pt-3`,children:n.map(o)})]}),r.map((e,t)=>o(e,n.length+t))]})},Jr=({children:e})=>{let{t}=a(),[n,r]=(0,V.useState)(!1),[i,o]=(0,V.useState)(!1),s=(0,V.useRef)(null);return(0,V.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=()=>o(e.scrollHeight>e.clientHeight+1);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e,n]),(0,H.jsxs)(M,{open:n,onOpenChange:r,className:`space-y-2`,children:[!n&&(0,H.jsx)(`p`,{ref:s,"data-slot":`chain-of-thought-summary`,className:`line-clamp-3 text-sm text-muted-foreground`,children:e}),(0,H.jsx)(N,{children:(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e})}),(i||n)&&(0,H.jsx)(P,{children:t(n?`Show less`:`Read all`)})]})},Yr=(0,V.memo)(({className:e,...t})=>(0,H.jsx)(`div`,{className:c(`flex flex-wrap items-center gap-2`,e),...t})),Xr=(0,V.memo)(({className:e,children:t,...n})=>(0,H.jsx)(st,{className:c(`gap-1 px-2 py-0.5 font-normal text-xs`,e),variant:`secondary`,...n,children:t})),Zr=(0,V.memo)(({className:e,children:t,...n})=>(0,H.jsx)(N,{className:c(`mt-2 space-y-3 text-popover-foreground outline-none`,`motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:slide-out-to-top-2 motion-safe:data-[state=open]:slide-in-from-top-2 motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=open]:animate-in`,e),...n,children:t})),Qr=(0,V.memo)(({className:e,children:t,caption:n,...r})=>(0,H.jsxs)(`div`,{className:c(`mt-2 space-y-2`,e),...r,children:[(0,H.jsx)(`div`,{className:`relative flex max-h-[22rem] items-center justify-center overflow-hidden rounded-lg bg-muted p-3`,children:t}),n&&(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n})]}));Vr.displayName=`ChainOfThought`,Hr.displayName=`ChainOfThoughtHeader`,Gr.displayName=`ChainOfThoughtStep`,Yr.displayName=`ChainOfThoughtSearchResults`,Xr.displayName=`ChainOfThoughtSearchResult`,Zr.displayName=`ChainOfThoughtContent`,Qr.displayName=`ChainOfThoughtImage`;function $r(e){let[t,n]=V.useState(!1);return V.useLayoutEffect(()=>{let t=e.current;if(!t)return;let r=()=>n(t.scrollHeight>t.clientHeight+1||t.scrollWidth>t.clientWidth+1);r();let i=new ResizeObserver(r);return i.observe(t),t.firstElementChild&&i.observe(t.firstElementChild),()=>i.disconnect()},[e]),t}function ei({className:e,children:t,type:n=`auto`,scrollRegionLabel:r,overflowCaption:i,...a}){let o=V.useRef(null),s=$r(o);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(lr,{"data-slot":`scroll-area`,"data-overflowing":s||void 0,type:n,className:c(`relative data-overflowing:rounded-lg data-overflowing:border data-overflowing:border-control-edge`,e),...a,children:[(0,H.jsx)(fr,{ref:o,"data-slot":`scroll-area-viewport`,tabIndex:s?0:void 0,role:s&&r?`region`:void 0,"aria-label":s?r:void 0,className:`size-full max-h-[inherit] rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-ring`,children:t}),(0,H.jsx)(ti,{}),(0,H.jsx)(Ar,{})]}),s&&i!=null&&(0,H.jsx)(`p`,{"data-slot":`scroll-area-caption`,className:`mt-1.5 text-xs text-muted-foreground tabular`,children:i})]})}function ti({className:e,orientation:t=`vertical`,...n}){return(0,H.jsx)(gr,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:c(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,H.jsx)(Dr,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-control-edge`})})}var ni=({className:e,...t})=>(0,H.jsx)(`li`,{className:c(`group flex flex-col gap-1 rounded-md px-3 py-1 text-sm transition-colors hover:bg-muted`,e),...t}),ri=({completed:e=!1,className:t,...n})=>(0,H.jsx)(`span`,{className:c(`mt-0.5 inline-block size-2.5 shrink-0 rounded-full border`,e?`border-muted-foreground/20 bg-muted-foreground/10`:`border-muted-foreground/50`,t),...n}),ii=({completed:e=!1,className:t,...n})=>(0,H.jsx)(`span`,{className:c(`min-w-0 grow break-words`,e?`text-muted-foreground/50 line-through`:`text-muted-foreground`,t),...n}),ai=({children:e,className:t,...n})=>(0,H.jsx)(ei,{className:c(`mt-2 -mb-1 max-h-40`,t),...n,children:(0,H.jsx)(`div`,{className:`pr-4`,children:(0,H.jsx)(`ul`,{children:e})})}),oi={known:`{percent}% complete`,unknown:`Not measured yet`};function si({className:e,value:t,max:n=100,"aria-label":r,...i}){let{t:o}=a(),s=typeof t==`number`?`known`:`unknown`,l=typeof t==`number`?Math.round(t/n*100):null;return(0,H.jsx)(qn,{"data-slot":`progress`,"data-value-state":s,value:t??null,max:n,"aria-label":r??F(o(oi[s]),{percent:l??``}),className:c(`relative flex h-1.5 w-full items-center overflow-hidden rounded-full bg-muted inset-ring inset-ring-control-edge data-[value-state=unknown]:border data-[value-state=unknown]:border-dashed data-[value-state=unknown]:border-control-edge data-[value-state=unknown]:bg-transparent data-[value-state=unknown]:inset-ring-0`,e),...i,children:l!==null&&(0,H.jsx)(Yn,{"data-slot":`progress-indicator`,className:`size-full flex-1 rounded-full bg-primary transition-transform motion-reduce:transition-none`,style:{transform:`translateX(-${100-l}%)`}})})}var ci=({children:e,className:n,done:r,...i})=>{let{t:o}=a();return r===void 0?(0,H.jsx)(`div`,{className:c(`text-muted-foreground text-sm`,n),...i,children:e}):(0,H.jsxs)(`div`,{"data-task-done":r,className:c(`flex items-start gap-2.5 text-sm`,r?`text-muted-foreground`:`text-foreground`,n),...i,children:[r?(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-[4px] bg-shipped-foreground text-card`,children:(0,H.jsx)(t,{className:`size-3 stroke-3`})}):(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 rounded-[4px] border-[1.5px] border-control-edge`}),(0,H.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[r&&(0,H.jsxs)(`span`,{className:`sr-only`,children:[o(`Done:`),` `]}),e]})]})},li=({defaultOpen:e=!0,className:t,...n})=>(0,H.jsx)(M,{className:c(t),defaultOpen:e,...n}),ui=({children:e,className:t,title:n,done:r,total:i,...o})=>{let{t:s}=a(),l=r!==void 0&&i!==void 0&&i>0;return(0,H.jsx)(ve,{asChild:!0,className:c(`group`,t),...o,children:e??(0,H.jsx)(`button`,{type:`button`,className:c(`group/fold-trigger flex min-h-11 w-full cursor-pointer items-center gap-2 rounded-lg border border-control-edge bg-transparent px-3 py-2 text-left text-sm font-medium text-foreground outline-none touch-target-size hover-enabled:bg-surface focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50`,`border-transparent px-1`),children:(0,H.jsx)(Se,{count:l?(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(si,{"aria-hidden":`true`,value:r,max:i,className:c(`h-1.5 w-12`,r===i?`[&_[data-slot=progress-indicator]]:bg-shipped-foreground`:`[&_[data-slot=progress-indicator]]:bg-working-foreground`)}),(0,H.jsx)(`span`,{className:`mono-number`,children:F(s(`{done} of {total} done`),{done:r,total:i})})]}):void 0,children:(0,H.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:n})})})})},di=({children:e,className:t,...n})=>(0,H.jsx)(N,{className:c(`text-popover-foreground outline-none motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:slide-out-to-top-2 motion-safe:data-[state=open]:slide-in-from-top-2 motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=open]:animate-in`,t),...n,children:(0,H.jsx)(`div`,{className:`mt-2 space-y-2 border-control-edge/55 border-l-2 pl-4`,children:e})}),fi=new Map,pi=e=>{let t=fi.get(e);return t||(t=Lt.create(e),fi.set(e,t)),t},Z=`var(--color-muted-foreground, var(--muted-foreground))`,mi=`var(--color-background, var(--foreground))`,hi=({children:e,as:t=`p`,className:n,duration:r=2,spread:i=2})=>{let a=Nt(),o=(0,V.useMemo)(()=>(e?.length??0)*i,[e,i]);return(0,H.jsxs)(t,{"data-slot":`shimmer`,className:c(`inline-flex max-w-full items-center gap-1.5`,n),children:[a?(0,H.jsxs)(`span`,{"data-slot":`shimmer-mark`,"aria-hidden":`true`,className:`inline-flex shrink-0 items-center gap-0.5`,style:{color:Z},children:[(0,H.jsx)(`span`,{className:`size-1 rounded-full bg-current`}),(0,H.jsx)(`span`,{className:`size-1 rounded-full bg-current`}),(0,H.jsx)(`span`,{className:`size-1 rounded-full bg-current`})]}):(0,H.jsx)(`span`,{"data-slot":`shimmer-mark`,"aria-hidden":`true`,className:`size-[0.9em] shrink-0 motion-safe:animate-spin rounded-full border-[1.5px] border-current border-t-transparent`,style:{color:Z}}),a?(0,H.jsx)(`span`,{"data-slot":`shimmer-text`,style:{color:Z},children:e}):(0,H.jsx)(_i,{duration:r,spread:o,children:e})]})},gi=pi(`span`);function _i({children:e,duration:t,spread:n}){return(0,H.jsx)(gi,{"data-slot":`shimmer-text`,animate:{backgroundPosition:`0% center`},className:c(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text`,`[background-repeat:no-repeat,padding-box]`),initial:{backgroundPosition:`100% center`},style:{color:Z,WebkitTextFillColor:`transparent`,backgroundImage:`linear-gradient(90deg, #0000 calc(50% - ${n}px), ${mi}, #0000 calc(50% + ${n}px)), linear-gradient(${Z}, ${Z})`},transition:{duration:t,ease:`linear`,repeat:1/0},children:e})}var vi=(0,V.memo)(hi),yi=e=>e instanceof Error?e.message:String(e),Q=e=>F(_(e.english),e.values),bi=e=>e.recordedTitle??F(_(`{tool} conversation`),{tool:Fe(e.tool,_)}),xi=e=>`${bi(e)} ${e.idChip}`;function Si({labels:e}){return(0,H.jsx)(`span`,{className:`inline-grid place-items-center`,children:e.map((e,t)=>(0,H.jsx)(`span`,{className:e.isShown?`col-start-1 row-start-1`:`invisible col-start-1 row-start-1`,children:e.text},t))})}var Ci=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘↵`:`Ctrl ↵`,wi=`text-muted-foreground`;function Ti({children:e,reason:t=null}){let n=(0,H.jsxs)(`p`,{className:`flex items-start gap-1.5 break-words text-sm text-muted-foreground`,children:[(0,H.jsx)(an,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0`,children:e})]});return t?(0,H.jsxs)(`div`,{children:[n,(0,H.jsx)(B,{cause:t})]}):n}function Ei({call:e,cause:t}){return a(),(0,H.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,H.jsx)(`p`,{className:`font-medium break-words`,children:_(se[e])}),(0,H.jsx)(B,{cause:t})]})}var Di=`[data-folder-line]`;function Oi(e,t,n,r){let i=(0,V.useRef)(null),[a,o]=(0,V.useState)(null);(0,V.useLayoutEffect)(()=>{let a=i.current,s=n?a?.closest(Di)??a:a;if(!t||!a||!s)return;let c=de(e),l=document.createElement(`canvas`).getContext(`2d`);if(!l)return;let u=()=>{let t=getComputedStyle(a);l.font=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`;let n=s.clientWidth,i=c.find(e=>l.measureText(e+r).width<=n),u={folder:e,path:i??c[c.length-1],fitsOnOneLine:i!==void 0};o(e=>e&&e.folder===u.folder&&e.path===u.path&&e.fitsOnOneLine===u.fitsOnOneLine?e:u)};u();let d=new ResizeObserver(u);return d.observe(s),()=>d.disconnect()},[e,t,n,r]);let s=a?.folder===e?a:null;return{line:i,pathThatFits:s?.path??e,fitsOnOneLine:s?.fitsOnOneLine??!0}}function ki({folder:e,fitsTheWholeLine:t=!1,wordsAgainstItsEnd:n=``}){let[r,i]=(0,V.useState)(!1),{line:a,pathThatFits:o,fitsOnOneLine:l}=Oi(e,!r,t,n),u=(0,H.jsx)(s,{variant:`bare`,type:`button`,title:e,"aria-label":e,"aria-expanded":r,onClick:()=>i(e=>!e),className:c(`min-w-0 rounded-sm py-1 font-mono text-xs hover-enabled:text-foreground`,!t&&`flex-1`),children:(0,H.jsx)(`span`,{ref:a,className:c(`min-w-0 flex-1`,r||!l?`break-all`:`truncate`),children:r?e:o})});return t?(0,H.jsxs)(`span`,{className:`inline-flex max-w-full items-baseline-last align-middle`,children:[u,(0,H.jsx)(`span`,{className:`shrink-0 whitespace-pre`,children:n})]}):u}function Ai({id:e,words:t,folderIsGone:n=!1}){let r=ue(_(t.english),t);if(n){let n=r?.wordsAfter.match(/^\S*/)?.[0]??``;return(0,H.jsx)(Qe,{id:e,"data-folder-gone":!0,className:`min-w-0 font-mono [&>span]:min-w-0 [&>span]:flex-1`,children:(0,H.jsxs)(`span`,{"data-folder-line":!0,className:`block`,children:[(0,H.jsx)(pn,{"aria-hidden":`true`,className:`mr-1.5 inline size-3.5 align-[-0.15em]`}),r?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`whitespace-pre-wrap`,children:r.wordsBefore}),(0,H.jsx)(ki,{folder:r.folder,fitsTheWholeLine:!0,wordsAgainstItsEnd:n}),(0,H.jsx)(`span`,{className:`whitespace-pre-wrap`,children:r.wordsAfter.slice(n.length)})]}):Q(t)]})})}return(0,H.jsxs)(Qe,{id:e,className:`min-w-0 items-center font-mono [&>span]:flex [&>span]:min-w-0 [&>span]:flex-1 [&>span]:items-center`,children:[(0,H.jsx)(_t,{"aria-hidden":`true`,className:`mr-1.5 size-3.5 shrink-0`}),r?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`shrink-0 whitespace-pre`,children:r.wordsBefore}),(0,H.jsx)(ki,{folder:r.folder}),(0,H.jsx)(`span`,{className:`shrink-0 whitespace-pre`,children:r.wordsAfter})]}):Q(t)]})}function ji({view:e,onTryAgain:t}){a();let n=(0,V.useId)();return(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,H.jsxs)(`div`,{role:`alert`,className:`min-w-0 flex-1 basis-48 space-y-1 text-sm`,children:[(0,H.jsx)(`p`,{id:n,className:`font-medium break-words`,children:_(e.sentence)}),(0,H.jsx)(B,{cause:e.failureText})]}),(0,H.jsx)(s,{variant:`outline`,size:`sm`,"aria-describedby":n,onClick:e=>t(e.currentTarget),children:(0,H.jsx)(Si,{labels:E(_(e.tryAgainLabel),_(e.tryingAgainLabel),e.isTryingAgain)})})]})}function Mi(e,t){let n=t?.platform??null,r=t?.conversationSessionId??null,[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),u=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(n===null||r===null)return;let t=!0,i=0,o=()=>{let o=++i;e.loadConversationContinuation(n,r).then(e=>{t&&o===i&&(a(e),s(null),l(!1))},e=>{t&&o===i&&(s(yi(e)),l(!1))})};u.current=o,o();let c=e.subscribeToConversationContinuations(e=>{ce(e,{platform:n,conversationSessionId:r})&&o()});return()=>{t=!1,u.current=null,c()}},[e,n,r]),{read:i,readFailed:o!==null,readFailureView:w(o,c),readAgain:()=>u.current?.(),tryAgain:()=>{l(!0),u.current?.()}}}var Ni=new Map,Pi=new Set,Fi=e=>(Pi.add(e),()=>{Pi.delete(e)});function Ii(e,t){let n=t===null?null:O(t),r=(0,V.useSyncExternalStore)(Fi,()=>n===null?null:Ni.get(n)??null),i=e=>{if(n!==null){e?Ni.set(n,e):Ni.delete(n);for(let e of Pi)e()}};return{stopSentFor:r,stop:async n=>{if(t===null)return null;i({exchangeId:n.exchangeId,startedAtEpochMs:n.startedAtEpochMs});try{return await e.stopConversationContinuation(t.platform,t.conversationSessionId),null}catch(e){return i(null),yi(e)}}}}function Li({exchanges:e,platform:t,toolName:n,stopIsShown:r,stopButtonName:i,onStop:a}){return(0,H.jsx)(`div`,{className:`space-y-3 py-1`,"aria-live":`polite`,children:e.map(e=>(0,H.jsxs)(`div`,{"data-exchange-state":e.state,className:`space-y-2 text-sm`,children:[(0,H.jsx)(`p`,{className:`ml-auto w-fit max-w-[85%] rounded-2xl rounded-br-md bg-secondary px-3.5 py-2 whitespace-pre-wrap break-words text-secondary-foreground`,children:e.ownerMessage}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(ge,{tool:t,className:`size-3.5`}),(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:Fe(n,_)}),e.state===`running`?(0,H.jsx)(vi,{as:`span`,children:_(e.stateWords)}):(0,H.jsx)(`span`,{className:e.state===`failed`?`text-destructive`:void 0,children:_(e.stateWords)}),e.state===`running`&&r&&(0,H.jsxs)(s,{variant:`outline`,size:`sm`,className:`ml-auto`,"aria-label":i,disabled:e.stopWasSent,onClick:t=>a(e,t.currentTarget),children:[(0,H.jsx)(Fn,{"aria-hidden":`true`,className:`fill-current`}),_(`Stop`)]})]}),e.replyText!==null&&(0,H.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:e.replyText}),e.failureText!==null&&(0,H.jsx)(B,{cause:e.failureText}),e.notices.map(e=>(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q(e)},e.english))]})]},e.exchangeId))})}function Ri({source:e,platform:n,conversationSessionId:r,appActions:i,leading:o,trailing:c}){a();let[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(!1),[v,b]=(0,V.useState)(null),x=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(!h)return;let e=e=>{e.target instanceof Node&&x.current?.contains(e.target)||g(!1)};return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[h]);let S=async t=>{let i=e.openConversationInApp;if(i&&!l){u(!0),f(null),m(null);try{let e=await i(n,r);m({app:t,printedText:e.printedText})}catch(e){f(yi(e))}finally{u(!1)}}},C=async e=>{try{await navigator.clipboard.writeText(e),b(null),g(!0)}catch(e){g(!1),b(yi(e))}},w=v===null?null:y(v),T=i.openInApp;return(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1 gap-y-2`,children:[o,T&&(0,H.jsxs)(s,{variant:`ghost`,size:`xs`,className:wi,"aria-label":Q(T.buttonName),"aria-disabled":l,onClick:()=>void S(T.app),children:[(0,H.jsx)(It,{"aria-hidden":`true`}),(0,H.jsx)(Si,{labels:E(Q(T.label),_(`Opening…`),l)})]}),(0,H.jsxs)(s,{ref:x,variant:`ghost`,size:`xs`,className:wi,"aria-label":Q(h?i.copyResumeCommand.copiedButtonName:i.copyResumeCommand.buttonName),onClick:()=>void C(i.copyResumeCommand.command),children:[h?(0,H.jsx)(t,{"aria-hidden":`true`}):(0,H.jsx)(zn,{"aria-hidden":`true`}),_(h?`Copied`:`Copy resume command`)]}),c&&(0,H.jsx)(`div`,{className:`ml-auto`,children:c})]}),p&&(0,H.jsxs)(`div`,{role:`status`,className:`space-y-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(`p`,{className:`break-words`,children:F(_(`Opened in {app}.`),{app:p.app})}),(0,H.jsx)(B,{cause:p.printedText})]}),d&&(0,H.jsx)(Ei,{call:`open-in-app`,cause:d}),w&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsxs)(`div`,{role:`alert`,className:`space-y-1 break-words text-xs text-muted-foreground`,children:[(0,H.jsx)(`p`,{children:_(`Could not copy the command.`)}),(0,H.jsx)(B,{cause:w.details}),(0,H.jsx)(`p`,{children:Q(w.copyItFromHere)})]}),(0,H.jsx)(`p`,{className:`select-all break-words font-mono text-xs`,children:i.copyResumeCommand.command})]})]})}function zi(){return a(),(0,H.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-1.5`,children:[(0,H.jsx)(`p`,{"aria-hidden":`true`,className:`text-sm leading-none font-medium text-muted-foreground`,children:_(`Your reply`)}),(0,H.jsx)(gt,{className:`h-20 w-full rounded-lg`}),(0,H.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:_(ie.reading)})]})}function Bi({source:e,conversation:t,naming:n}){a();let r=ee(t)?t:null,i=xi(n),o=ae(i),{read:l,readFailed:u,readFailureView:d,readAgain:f,tryAgain:p}=Mi(e,r),{stopSentFor:m,stop:h}=Ii(e,r),[g,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(``),[x,C]=(0,V.useState)(null),w=(0,V.useRef)(null),T=(0,V.useRef)(null),D=(0,V.useId)(),O=(0,V.useId)(),re=(0,V.useId)(),k=S({conversationIsContinuable:r!==null,read:l,readFailed:u,sending:g});if(k===`reading`)return(0,H.jsx)(`div`,{"data-reply-state":k,children:(0,H.jsx)(zi,{})});if(k===`read-failure`)return d&&(0,H.jsx)(`div`,{"data-reply-state":k,children:(0,H.jsx)(ji,{view:d,onTryAgain:()=>p()})});if(l===null||r===null)return(0,H.jsx)(`div`,{"data-reply-state":k,children:(0,H.jsx)(Ti,{children:_(ie[`cannot-continue`])})});let A=te(l.target,l.exchanges,y,m),oe=ne({platform:r.platform,conversationSessionId:r.conversationSessionId,conversationName:i},l.target,e.openConversationInApp!==void 0),j=k===`turn-running`,se=!A.sendIsEnabled||g,ce=A.sendIsEnabled||g,ue=k===`idle`?y.trim()===``?ie.idle:null:k===`sending`||k===`turn-running`?ie[k]:null,de=A.folderGoneNotice??oe?.runsInFolderNotice??null,fe=e=>{let t=le(document.activeElement===e,A);t===`message-box`&&w.current?.focus(),t===`conversation-box`&&T.current?.focus()},pe=e=>{fe(e),p()},me=async t=>{if(A.sendIsEnabled&&!g){t&&fe(t),v(!0),C(null);try{await e.continueConversation(r.platform,r.conversationSessionId,y),b(``),f()}catch(e){C({call:`send`,cause:yi(e)})}finally{v(!1)}}},he=async(e,t)=>{fe(t),C(null);let n=await h(e);n&&C({call:`stop`,cause:n})},ge=(0,H.jsxs)(s,{variant:ce?`default`:`outline`,size:`sm`,"aria-label":Q(o.sendButton),"aria-keyshortcuts":`Meta+Enter Control+Enter`,"aria-disabled":se||void 0,onClick:e=>void me(e.currentTarget),children:[(0,H.jsx)(Si,{labels:E(_(`Send`),_(`Sending…`),g)}),(0,H.jsx)(`kbd`,{"aria-hidden":`true`,className:`hidden font-sans text-[0.7rem] opacity-75 md:inline`,children:Ci})]});return(0,H.jsxs)(`div`,{ref:T,tabIndex:A.composerIsShown?void 0:-1,"data-reply-state":k,className:`space-y-3 rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,children:[A.exchanges.length>0&&(0,H.jsx)(Li,{exchanges:A.exchanges,platform:r.platform,toolName:t.tool,stopIsShown:A.stopIsShown,stopButtonName:Q(o.stopButton),onStop:(e,t)=>void he(e,t)}),A.refusalText!==null&&(0,H.jsx)(Ti,{reason:A.refusalText,children:_(ie[`cannot-continue`])}),A.composerIsShown&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(ct,{htmlFor:D,className:c(j&&`text-muted-foreground`),children:_(`Your reply`)}),(0,H.jsx)(kt,{id:D,ref:w,"aria-label":Q(o.messageBox),"aria-describedby":[de?O:null,ue?re:null].filter(Boolean).join(` `)||void 0,placeholder:F(_(`Continue this {tool} conversation`),{tool:Fe(t.tool,_)}),value:y,rows:3,className:c(`resize-none`,j&&`opacity-60`),readOnly:g||j,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),me())}}),de&&(0,H.jsx)(Ai,{id:O,words:de,folderIsGone:A.folderGoneNotice!==null})]}),oe?(0,H.jsx)(Ri,{source:e,platform:r.platform,conversationSessionId:r.conversationSessionId,appActions:oe,trailing:ge}):(0,H.jsx)(`div`,{className:`flex justify-end`,children:ge}),ue&&(0,H.jsx)(`p`,{id:re,role:`status`,className:`text-sm text-muted-foreground`,children:_(ue)})]}),x&&(0,H.jsx)(Ei,{call:x.call,cause:x.cause}),d&&(0,H.jsx)(ji,{view:d,onTryAgain:pe})]})}function Vi({platform:e,conversationSessionId:t,toolName:n,conversationTitle:r,anotherConversationHasTheSameTitle:i=!1}){a();let o=I(e=>e.conversationContinuationSource());if(!o)return null;let s={...D({tool:n,title:r,conversationSessionId:t},[]),idChip:k(t,i)};return(0,H.jsx)(R,{ids:[`R2.8`],children:(0,H.jsx)(Bi,{source:o,conversation:{platform:e,conversationSessionId:t,tool:n},naming:s})})}var Hi={PR:xn,Commit:_n,Branch:hn,Page:Ce,Deck:kn,Doc:nn,File:sn,Link:Cn},Ui={all:e=>e(`All`),"docs-and-pages":e=>e(`Docs and pages`),code:e=>e(`Code`)};function Wi({products:e}){let{t}=a(),[n,r]=(0,V.useState)(`all`);if(e.length===0)return(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`Nothing attached yet.`)});let i=t=>e.filter(e=>Be[e.kind]===t),o={all:e.length,"docs-and-pages":i(`docs-and-pages`).length,code:i(`code`).length},s=o[`docs-and-pages`]>0&&o.code>0,c=s?n:`all`,l=Ye(c===`all`?e:i(c)),u=l.filter(e=>e.kind!==`Commit`),d=l.filter(e=>e.kind===`Commit`);return(0,H.jsxs)(`div`,{"data-slot":`deliverable-list`,className:`space-y-2`,children:[s&&(0,H.jsx)(At,{type:`single`,variant:`outline`,size:`sm`,spacing:1,value:c,onValueChange:e=>{e&&r(e)},"aria-label":t(`Which deliverables to show`),className:`flex-wrap`,children:Object.keys(Ui).map(e=>(0,H.jsxs)($e,{value:e,className:`gap-1.5 px-3`,children:[Ui[e](t),(0,H.jsx)(`span`,{className:`mono-number text-muted-foreground group-data-[state=on]/toggle:text-foreground`,children:o[e]})]},e))}),(0,H.jsxs)(`ul`,{className:`-mx-3 divide-y divide-border/70`,children:[u.map((e,t)=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Ki,{product:e})},`${t}-${e.kind}-${e.label}`)),d.length>0&&(0,H.jsx)(`li`,{children:(0,H.jsxs)(M,{children:[(0,H.jsx)(P,{className:`border-transparent`,children:F(d.length===1?t(`{count} commit`):t(`{count} commits`),{count:d.length})}),(0,H.jsx)(N,{children:(0,H.jsx)(`ul`,{className:`divide-y divide-border/70`,children:d.map((e,t)=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Ki,{product:e})},`${t}-${e.label}`))})})]})})]})]})}var Gi=`flex min-h-11 items-center gap-3 rounded-lg px-3 py-1.5 text-sm`;function Ki({product:e}){let{t}=a(),n=Hi[e.kind],r=He(e),i=e.href!==void 0&&!we(e.href),o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`min-w-16 shrink-0 text-muted-foreground`,children:t(e.kind)}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:c(`block [overflow-wrap:anywhere]`,e.kind===`Branch`&&`font-mono text-[0.8125rem]`),children:r}),e.availability===`origin-only`&&(0,H.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t(`Local file — check the original computer`)})]})]});return e.href===void 0?(0,H.jsxs)(`div`,{className:c(Gi,`flex-wrap`),children:[o,(0,H.jsx)(Ji,{name:r})]}):(0,H.jsxs)(vt,{href:e.href,className:c(Gi,i&&`hover:bg-surface`),children:[o,i&&(0,H.jsx)(It,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]})}var qi={ready:{Mark:zt,spoken:null,refusal:null},copied:{Mark:t,spoken:e=>e(`Copied`),refusal:null},refused:{Mark:zt,spoken:null,refusal:e=>e(`Could not copy. Select the name to copy it.`)}};function Ji({name:e}){let{t}=a(),[n,r]=(0,V.useState)({state:`ready`,cause:null}),i=async()=>{try{await navigator.clipboard.writeText(e),r({state:`copied`,cause:null})}catch(e){r({state:`refused`,cause:e instanceof Error?e.message:String(e)})}},{Mark:o,spoken:c,refusal:l}=qi[n.state];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(s,{variant:`ghost`,size:`icon-sm`,className:`shrink-0`,onClick:i,"aria-label":F(t(`Copy “{name}”`),{name:e}),children:(0,H.jsx)(o,{"aria-hidden":`true`})}),(0,H.jsx)(`span`,{role:`status`,className:`sr-only`,children:c?.(t)??``}),l&&(0,H.jsxs)(`div`,{className:`basis-full pb-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(`p`,{role:`alert`,children:l(t)}),(0,H.jsx)(B,{cause:n.cause})]})]})}function Yi({request:e}){let{focusAreas:t,sourceKind:n}=L(),r=new Map;for(let t of Ue(e)){let e=$t(t.href);e&&t.availability!==`origin-only`&&new URL(e).hostname.includes(`.`)&&r.set(e,t)}if(n===`sample`||!r.size)return null;let i=t.find(t=>t.id===e.focusAreaId)?.name??``;return(0,H.jsx)(Xi,{products:r,focusName:i})}function Xi({products:e,focusName:t}){let{t:n}=a(),r=e.keys().next().value,[i,o]=(0,V.useState)(r),c=e.has(i)?i:r,[l,u]=(0,V.useState)(()=>He(e.get(r))),[d,f]=(0,V.useState)(t),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(``),x=(0,V.useRef)(!1),S=(0,V.useRef)(null),C=`block w-full rounded-lg border bg-background px-3 py-1.5 touch-target-size md:not-pointer-coarse:min-h-10`;return(0,H.jsxs)(`details`,{className:`mt-3 rounded-lg border p-3`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer font-medium touch-target-size`,children:n(`Add a deliverable to Review Stack`)}),(0,H.jsxs)(`form`,{className:`mt-3 grid gap-3 text-sm`,onSubmit:async e=>{if(e.preventDefault(),x.current)return;x.current=!0,v(!0),b(``);let t={key:c,source:c,focus:d,title:l,what:p,context:h},r=JSON.stringify(t);S.current?.identity!==r&&(S.current={identity:r,id:crypto.randomUUID()});try{let e=await en([t],S.current.id);S.current=null,b(e.added?n(`Added to your Review Stack.`):n(`This original is already in your Review Stack.`))}catch(e){b(e instanceof Error?e.message:n(`Could not add this card. Try again.`))}finally{x.current=!1,v(!1)}},children:[(0,H.jsxs)(`fieldset`,{className:`grid gap-2`,disabled:_,children:[(0,H.jsxs)(`label`,{children:[n(`Original deliverable`),(0,H.jsx)(`select`,{value:c,className:C,onChange:t=>{let n=t.target.value;o(n),u(He(e.get(n))),m(``),g(``),b(``)},children:Array.from(e,([e,t])=>(0,H.jsx)(`option`,{value:e,children:He(t)},e))})]}),(0,H.jsxs)(`label`,{children:[n(`Focus area`),(0,H.jsx)(`input`,{required:!0,value:d,onChange:e=>f(e.target.value),className:C})]}),(0,H.jsxs)(`label`,{children:[n(`Title · 3–5 words`),(0,H.jsx)(`input`,{required:!0,maxLength:120,value:l,onChange:e=>u(e.target.value),className:C})]}),(0,H.jsxs)(`label`,{children:[n(`What it shows · 10–15 words`),(0,H.jsx)(`textarea`,{required:!0,maxLength:360,value:p,onChange:e=>m(e.target.value),className:C})]}),(0,H.jsxs)(`label`,{children:[n(`Why it belongs here · 10–15 words`),(0,H.jsx)(`textarea`,{required:!0,maxLength:360,value:h,onChange:e=>g(e.target.value),className:C})]})]}),y&&(0,H.jsx)(`p`,{role:`status`,children:y}),(0,H.jsx)(s,{type:`submit`,variant:`outline`,disabled:_,children:n(`Add to Review Stack`)})]})]})}var Zi={Docs:{words:e=>e(`Docs`),Icon:nn},Promo:{words:e=>e(`Promo`),Icon:Tn},Other:{words:e=>e(`Other`),Icon:Ln}};function Qi({tag:e}){let{t}=a(),{words:n,Icon:r}=Zi[e];return(0,H.jsxs)(`span`,{className:`inline-flex min-h-7 shrink-0 items-center gap-1.5 rounded-md border border-control-edge px-2 text-xs text-muted-foreground`,children:[(0,H.jsx)(r,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),n(t)]})}function $i({request:e}){let{t:n}=a(),{sourceKind:r}=L(),i=r===`sample`,[o,s]=(0,V.useState)([]),l=o.filter(t=>t.savedIn===e);l.length!==o.length&&s(l);let u=(0,V.useRef)(new Map),d=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=d.current===null?void 0:u.current.get(d.current);e&&(d.current=null,e.focus())});let f=e=>t=>{t?u.current.set(e,t):u.current.delete(e)},p=e=>l.some(t=>t.text===e.text),h=e.followUps.filter(e=>!e.done||p(e)),g=h.filter(e=>!e.done).length;if(e.state!==`shipped`||h.length===0)return null;let _=(t,r)=>{I.getState().updateSampleRequest(e.id,e=>{let r=t(e.followUps),i=r.find(e=>!e.done);return{...e,followUps:r,next:i?{who:`human`,text:i.text}:{who:`bot`,text:n(`Nothing left after ship`)}}});let i=Je(e.id);if(!i)throw Error(`Request ${e.id} left the model while its follow-up was saved`);s(e=>r(e).map(e=>({text:e.text,savedIn:i})))},v=e=>{d.current=e,_(t=>t.map(t=>t.text===e?{...t,done:!0}:t),t=>[...t,{text:e}])},y=e=>{d.current=e,_(t=>t.map(t=>t.text===e?{...t,done:!1}:t),t=>t.filter(t=>t.text!==e))};return(0,H.jsx)(R,{ids:[`R5.7`],children:(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`section-label`,children:F(n(`Open after ship · {count}`),{count:g})}),(0,H.jsx)(`ul`,{className:`divide-y divide-border/70`,children:h.map(e=>(0,H.jsxs)(`li`,{"data-follow-up":e.done?`saved`:`open`,className:`grid min-h-11 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 py-1.5 text-sm`,children:[(0,H.jsx)(Qi,{tag:e.tag}),(0,H.jsx)(`span`,{className:c(`[overflow-wrap:anywhere]`,e.done&&`text-muted-foreground line-through`),children:e.text}),(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{role:`status`,className:c(`inline-flex items-center gap-1.5 text-xs text-shipped-foreground`,!e.done&&`sr-only`),children:e.done&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),n(`Saved`)]})}),e.done?(0,H.jsx)(z,{ref:f(e.text),className:c(m({variant:`ghost`,size:`sm`}),`shrink-0`),icon:(0,H.jsx)(it,{}),onClick:()=>y(e.text),children:n(`Undo`)},`undo`):i&&(0,H.jsx)(z,{ref:f(e.text),className:c(m({variant:`outline`,size:`sm`}),`shrink-0`),icon:(0,H.jsx)(t,{}),onClick:()=>v(e.text),children:n(`Done`)},`done`)]})]},e.text))}),!i&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`These can’t be marked done from My Work yet.`)})]})})}function ea(e){let t=new Set,n=e.granular.flatMap(e=>e.media?.attachments??[]).filter(e=>!t.has(e.id)&&!!t.add(e.id));return n.length>0?{version:1,attachments:n}:void 0}var ta=(e,t,n=[])=>+!!n.some(e=>e.toLocaleLowerCase().includes(t.trim().toLocaleLowerCase()));function na({id:e,trigger:t,triggerTitle:n,groups:r,chosenValue:i,onChoose:a,searchPlaceholder:o,nothingFound:l,countLine:u,cannotChoose:d=!1,className:f}){let[p,m]=(0,V.useState)(!1),h=r.filter(e=>e.choices.length>0);return(0,H.jsxs)(ot,{modal:!0,open:p,onOpenChange:m,children:[(0,H.jsx)(Gt,{asChild:!0,children:(0,H.jsxs)(s,{id:e,type:`button`,variant:`outline`,size:`sm`,title:n,"aria-disabled":d||void 0,className:c(`min-w-0 justify-between gap-2 font-normal`,f),children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,H.jsx)(Mt,{"aria-hidden":`true`,className:`text-muted-foreground`})]})}),(0,H.jsx)(lt,{align:`end`,className:`w-80 gap-0 p-0`,children:(0,H.jsxs)(Qt,{filter:ta,children:[(0,H.jsx)(qt,{placeholder:o,"aria-label":o}),(0,H.jsxs)(Yt,{children:[(0,H.jsx)(Jt,{children:l}),h.map((e,t)=>(0,H.jsxs)(V.Fragment,{children:[t>0&&(0,H.jsx)(Zt,{}),(0,H.jsx)(Xt,{heading:e.heading,children:e.choices.map(e=>(0,H.jsx)(Kt,{value:e.value,keywords:e.searchWords,"data-checked":e.value===i,onSelect:()=>{m(!1),a(e.value)},children:(0,H.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.label})},e.value))})]},e.heading??t))]}),u&&(0,H.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-xs text-muted-foreground tabular`,children:u})]})})]})}function ra(e){return[...e.filter(e=>!e.done),...e.filter(e=>e.done)]}function ia(e,t=!0){let n=I(e=>e.loadRequestDetail),[r,i]=(0,V.useState)(0),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null);a?.request&&a!==s&&c(a);let l=e?oe(e):``,u=t&&e?.detailLoaded===!1,d=(0,V.useRef)(e);(0,V.useEffect)(()=>{d.current=e}),(0,V.useEffect)(()=>{let e=d.current;if(!e||!u)return;let t=new AbortController,r=!0,i=Date.now();return o({key:l}),n(e,{signal:t.signal}).then(e=>{r&&o({key:l,request:e})},e=>{r&&!t.signal.aborted&&o({key:l,error:e instanceof Error?e.message:`Request detail could not be loaded.`,waitedMs:Date.now()-i})}),()=>{r=!1,t.abort()}},[l,u,n,r]);let f=()=>i(e=>e+1);if(!e)return{loaded:null,failure:null,newerVersionReadFailure:null,tryAgain:f};if(!u)return{loaded:e,failure:null,newerVersionReadFailure:null,tryAgain:f};let p=a?.key===l?a:null;if(p?.request)return{loaded:A(e,p.request),failure:null,newerVersionReadFailure:null,tryAgain:f};let m=re(e.id,p,s);return m?{loaded:T(e,m.request),failure:null,newerVersionReadFailure:m.newerVersionReadFailure??null,tryAgain:f}:{loaded:null,failure:p?.error===void 0?null:{message:p.error,waitedMs:p.waitedMs??null},newerVersionReadFailure:null,tryAgain:f}}var $=`sm`,aa=(...e)=>e.filter(e=>typeof e==`string`&&e!==``).join(` `),oa=e=>e instanceof Error?e.message:String(e);function sa(e,t,n,r){switch(e.outcome){case`saved`:{let i=e.model.requests.find(e=>e.id===n),a=i?.review,o=(e.save?.scope??a?.mode)===`shared`,s=e.save?e.save.state===`queued`:a?.pending;return o&&a?.conflict?{tone:`problem`,words:()=>aa(_(`Your review decision was saved here, but your viewers still have conflicting decisions. Read this version and choose again.`),s&&_(`The saved decision is waiting to sync.`))}:r&&i?.contentFingerprint!==r?{tone:`problem`,words:()=>aa(_(`Your review decision was saved for the version you read. The current work changed; review it again.`),o&&s&&_(`The saved decision is waiting to sync.`))}:o?{tone:`saved`,words:()=>aa(_(t?`Checked for this shared version.`:`Check undone for this shared version.`),s&&_(`Saved here; waiting to sync to your other viewers.`))}:e.model.sourceKind===`cloud`?{tone:`saved`,words:()=>_(t?`Checked in your cloud viewer only. My Work sharing is off.`:`Check undone in your cloud viewer only. My Work sharing is off.`)}:{tone:`saved`,words:()=>_(t?x:b)}}case`changed-while-reading`:return{tone:`problem`,words:()=>_(C),cause:e.serverMessage};case`refused`:return{tone:`problem`,words:()=>_(`Your review decision was not saved. The worker refused this version as it is.`),cause:e.serverMessage};case`unavailable`:return{tone:`problem`,words:()=>_(`Your review decision was not saved. Local work is unavailable right now.`),cause:e.serverMessage}}}function ca({notice:e,focusRef:t}){return(0,H.jsxs)(`div`,{ref:t,tabIndex:t?-1:void 0,role:e.tone===`problem`?`alert`:`status`,className:c(`w-full space-y-1 rounded-sm text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,e.tone===`problem`?`font-medium text-foreground`:`text-muted-foreground`),children:[(0,H.jsx)(`p`,{children:e.words()}),e.cause&&(0,H.jsx)(B,{cause:e.cause})]})}function la(){let e=(0,V.useRef)(null),[t,n]=(0,V.useState)(0);return(0,V.useEffect)(()=>{if(t===0)return;let n=document.activeElement;(!n||n===document.body)&&e.current?.focus()},[t]),{outcomeLine:e,saveSettled:()=>n(e=>e+1)}}function ua({request:e}){a();let{mode:n}=Xe(),{sourceKind:r,devices:i}=L(),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),{outcomeLine:u,saveSettled:d}=la(),f=(0,V.useId)(),p=async t=>{s(!0);let n,r=!1;try{let i=await I.getState().setRequestChecked(e.id,t,e.contentFingerprint,e.review?.hash);r=i.outcome===`saved`,n=sa(i,t,e.id,e.contentFingerprint)}catch(e){n={tone:`problem`,words:()=>_(`Your review decision was not saved.`),cause:oa(e)}}finally{s(!1)}return l(n),d(),r},h=o||void 0,g=c&&(0,H.jsx)(ca,{notice:c,focusRef:u});if(e.review?.available===!1)return null;if(e.review?.conflict)return(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl border border-control-edge p-4 text-sm`,children:[(0,H.jsxs)(`div`,{role:`status`,className:`basis-full space-y-1`,children:[(0,H.jsx)(`p`,{children:_(`Your viewers recorded different review decisions. Read this version, then choose the decision to keep.`)}),(0,H.jsx)(B,{cause:e.review.message})]}),e.state===`needs-check`&&(0,H.jsxs)(z,{className:m({size:$}),onClick:()=>p(!0),"aria-disabled":h,children:[(0,H.jsx)(t,{}),_(`Mark checked`)]}),(0,H.jsxs)(z,{className:m({variant:`ghost`,size:$}),onClick:()=>p(!1),"aria-disabled":h,children:[(0,H.jsx)(it,{}),_(`Keep unchecked`)]}),g]});if(e.state===`needs-check`)return(0,H.jsx)(R,{ids:[`R6.2`,`R13.7`],children:(0,H.jsxs)(`section`,{"aria-labelledby":f,"data-lead-box":`check`,className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-3 rounded-xl border border-review-border bg-review px-4.5 py-4 text-sm md:px-5.5 md:py-4.75`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-60 space-y-1`,children:[(0,H.jsxs)(`h2`,{id:f,className:`flex items-center gap-2 font-medium text-review-foreground`,children:[(0,H.jsx)(Ut,{state:`needs-check`}),_(et[`needs-check`])]}),(0,H.jsx)(`p`,{className:`text-foreground`,children:_(`Check the work, then mark this version checked. Checking never ships it.`)})]}),(0,H.jsxs)(z,{className:m({size:$}),onClick:()=>p(!0),"aria-disabled":h,children:[(0,H.jsx)(t,{}),_(`Mark checked`)]}),g]})});if(!e.checkedAt)return g;let v=e.review?.mode===`shared`?e.review.pending?_(`Saved here; waiting to sync to your other viewers.`):_(`Saved as a shared review decision.`):r===`cloud`?_(`Saved in your cloud viewer only. My Work sharing is off.`):r===`sample`?n===`web`?F(_(`Saved from the web · syncing to {count} machines (demonstration).`),{count:i.length}):_(`Saved on this machine (demonstration).`):_(`Saved on this machine only.`);return(0,H.jsx)(R,{ids:[`R6.2`,`R13.7`],children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-3 rounded-xl border border-control-edge bg-surface p-4 text-sm`,children:[(0,H.jsxs)(`div`,{ref:u,tabIndex:-1,role:`status`,className:`min-w-0 flex-1 basis-60 space-y-1 rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,children:[(0,H.jsxs)(`p`,{className:`flex items-start gap-2 font-medium text-shipped-foreground`,children:[(0,H.jsx)(t,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{className:`tabular`,children:F(_(`Checked {checkedAt}.`),{checkedAt:ye(e.checkedAtIso,e.checkedAt)})})]}),(0,H.jsx)(`p`,{className:`text-muted-foreground`,children:aa(v,_(`Shipping is still your call.`))})]}),(0,H.jsxs)(z,{className:m({variant:`outline`,size:$}),onClick:()=>p(!1),"aria-disabled":h,children:[(0,H.jsx)(it,{}),_(`Undo`)]}),c?.tone===`problem`&&(0,H.jsx)(ca,{notice:c})]})})}var da={PR:e=>_(e===1?`{count} PR`:`{count} PRs`),Commit:e=>_(e===1?`{count} commit`:`{count} commits`),Branch:e=>_(e===1?`{count} branch`:`{count} branches`),Page:e=>_(e===1?`{count} page`:`{count} pages`),Deck:e=>_(e===1?`{count} deck`:`{count} decks`),Doc:e=>_(e===1?`{count} doc`:`{count} docs`),File:e=>_(e===1?`{count} file`:`{count} files`),Link:e=>_(e===1?`{count} link`:`{count} links`)};function fa(e){let t=new Map;for(let n of e)t.set(n.kind,(t.get(n.kind)??0)+1);return[...t].sort((e,t)=>t[1]-e[1]).map(([e,t])=>F(da[e](t),{count:t})).join(`, `)}function pa(e){let t=xt();return n=>{let r=n===`conversation`&&e.conversations.length===1?O(e.conversations[0]):null;return{href:t(n,r),open:()=>I.getState().showRequestPart(n,r)}}}var ma=`space-y-2 rounded-xl border border-goal-border bg-goal px-4.5 py-4 text-goal-heading md:px-5.5 md:py-4.75`;function ha({icon:e,children:t}){return(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-medium text-goal-foreground`,children:[(0,H.jsx)(e,{"aria-hidden":`true`,className:`size-4.5 shrink-0`}),t]})}function ga({href:e,onPress:t,children:n}){return(0,H.jsxs)(Tt,{href:e,onPress:t,className:`text-base text-goal-foreground`,children:[n,(0,H.jsx)(wt,{"aria-hidden":`true`})]})}function _a({request:e}){a();let n=pa(e),r=Ie(e.next),i=r.kind===`step`?tt(r,_):null;if(e.state===`needs-check`&&e.review?.available!==!1)return null;if(e.state===`shipped`){let r=Ue(e),i=n(`deliverables`);return(0,H.jsx)(R,{ids:[`R5.12`],children:(0,H.jsxs)(`section`,{"data-lead-box":`shipped`,className:ma,children:[(0,H.jsx)(ha,{icon:t,children:e.progress.completedAt?F(_(`Shipped {date}`),{date:ye(e.progress.completedAtIso,e.progress.completedAt)}):_(`Shipped`)}),r.length>0&&(0,H.jsx)(`p`,{children:F(_(`{kinds} ready to open.`),{kinds:fa(r)})}),r.length>0&&(0,H.jsx)(ga,{href:i.href,onPress:i.open,children:F(_(r.length===1?`Open {count} deliverable`:`Open {count} deliverables`),{count:r.length})})]})})}let o=e.state===`your-move`||e.state===`needs-check`,s=n(`conversation`);return(0,H.jsx)(R,{ids:[`R5.8`,`R6.3`],children:(0,H.jsxs)(`section`,{"data-lead-box":o?`your-move`:`agent`,className:ma,children:[(0,H.jsx)(ha,{icon:o?_e:wt,children:o||r.kind===`step`&&r.who===`human`?_(`Your move`):_(`Agent’s move`)}),(0,H.jsx)(`p`,{"data-lead-sentence":``,children:i??_(`A next step hasn’t been recorded.`)}),o&&e.conversations.length>0&&(0,H.jsx)(ga,{href:s.href,onPress:s.open,children:_(`Open conversation`)})]})})}function va({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border/70 py-2.5 text-sm last:border-b-0`,children:[(0,H.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,H.jsx)(`dd`,{className:`min-w-0 text-right font-medium tabular`,children:t})]})}function ya(e){let t=ke(e);return t?t.startsWith(`at this pace, about `)?F(_(`at this pace, about {date}`),{date:be(t.slice(De.length))}):_(t):null}var ba=t=>t.progress.readings>0&&t.progress.percent!==null?new Intl.NumberFormat(e(),{style:`percent`,maximumFractionDigits:0}).format(t.progress.percent/100):null;function xa({request:e}){a();let{team:t}=Xe(),n=Me(e.startedAt),r=ba(e),i=ya(e);return(0,H.jsx)(R,{ids:[`R3.2`,`R3.6`,`R5.11`,`R5.6`,`R5.3`,`R5.2`],children:(0,H.jsxs)(`dl`,{"data-request-facts":``,children:[(0,H.jsxs)(va,{label:_(`Progress`),children:[r??_(`Not reviewed yet`),i&&(0,H.jsx)(`span`,{"data-request-estimate":``,className:`block text-xs font-normal text-muted-foreground`,children:i})]}),e.progress.readings>0&&(0,H.jsx)(va,{label:_(`Reviewed`),children:(0,H.jsx)(Wt,{iso:e.progress.reviewedAtIso,words:e.progress.reviewedAt,form:`time-or-day`})}),(0,H.jsx)(va,{label:_(`Agent`),children:(0,H.jsx)(`span`,{className:`inline-flex justify-end`,children:(0,H.jsx)(Et,{agentId:e.agentId})})}),t&&(0,H.jsx)(va,{label:_(`Asked by`),children:e.askedBy}),(0,H.jsx)(va,{label:_(`Started`),children:n||e.startedAtIso?ye(e.startedAtIso,n??``):_(`Start not recorded`)}),e.progress.completedAt&&(0,H.jsx)(va,{label:_(`Shipped`),children:ye(e.progress.completedAtIso,e.progress.completedAt)})]})})}function Sa(e){let t=e.granular.length;return Re(e)?F(_(`Latest {count} records`),{count:t}):F(_(t===1?`{count} record`:`{count} records`),{count:t})}var Ca={conversation:{icon:Dn,name:()=>_(`Conversation`),count:e=>F(e.conversations.length===1?_(`{count} session`):_(`{count} sessions`),{count:e.conversations.length})},records:{icon:Ce,name:()=>_(`Records`),count:e=>Sa(e)},deliverables:{icon:ln,name:()=>_(`Deliverables`),count:e=>{let t=Ue(e).length;return F(_(t===1?`{count} work product`:`{count} work products`),{count:t})}}},wa={2:`md:grid-cols-2`};function Ta({request:e}){a();let t=pa(e),n=(0,V.useId)(),r=Ve(e);return(0,H.jsxs)(`section`,{"aria-labelledby":n,className:`space-y-3 md:space-y-3.75`,children:[(0,H.jsx)(`h2`,{id:n,className:`text-section-title-phone md:text-section-title`,children:_(`Under this request`)}),(0,H.jsx)(`ul`,{className:c(`grid gap-2.25 md:gap-3`,wa[r.length]??`md:grid-cols-3`),children:r.map(n=>{let{icon:r,name:i,count:a}=Ca[n],{href:o,open:s}=t(n);return(0,H.jsx)(`li`,{className:`min-w-0`,children:(0,H.jsxs)(`a`,{href:o,"data-request-door":n,onClick:yt(s),className:`grid h-full min-h-11 grid-cols-door-row items-center gap-x-3 rounded-xl border border-border bg-card px-3.75 py-3 shadow-panel outline-none hover:border-control-edge focus-visible:ring-3 focus-visible:ring-ring/50 md:flex md:flex-col md:items-stretch md:gap-1 md:rounded-2xl md:px-4.5 md:py-4.25`,children:[(0,H.jsxs)(`span`,{className:`flex items-center justify-between text-muted-foreground`,children:[(0,H.jsx)(r,{"aria-hidden":`true`,className:`size-4.5`}),(0,H.jsx)(St,{"aria-hidden":`true`,className:`hidden size-4 md:block`})]}),(0,H.jsx)(`h3`,{className:`text-index-title-phone md:mt-2 md:text-index-title`,children:i()}),(0,H.jsx)(`span`,{className:`text-sm text-muted-foreground tabular`,children:a(e)})]})},n)})}),!r.includes(`deliverables`)&&(0,H.jsx)(`p`,{"data-no-deliverables":``,className:`text-sm text-muted-foreground`,children:_(`No deliverables yet.`)})]})}var Ea=e=>JSON.stringify([`overall-request`,e]),Da=t=>new Intl.NumberFormat(e(),{style:`percent`,maximumFractionDigits:0}).format(t);function Oa({request:e}){a();let{sourceKind:t,requests:n}=L(),[r,i]=(0,V.useState)(!1),[o,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),{outcomeLine:d,saveSettled:f}=la(),p=(0,V.useId)(),h=(0,V.useId)(),g=e.suggestion,v=l&&(0,H.jsx)(ca,{notice:l,focusRef:d});if(!g)return v;let y=n.find(e=>e.id===Ea(g.requestId)),b=async e=>{e===`not-this`&&c(!1),i(!0);try{let n=await I.getState().answerRequestSuggestion(g,e),r=n.save?.scope===`shared`,i=n.save?.state===`queued`,a=n.save?.localMaterialization===`pending`,o=n.model.requests.some(e=>e.suggestion?.conversationKey===g.conversationKey&&e.suggestion.sharedConflict);return c(!1),o?(u({tone:`problem`,words:()=>aa(_(`Your decision was saved here, but grouping decisions still conflict. Read this suggestion and choose again.`),r&&i&&_(`The saved decision is waiting to sync.`),a&&_(`This viewer's local work copy is still updating.`))}),!0):(u({tone:`saved`,words:()=>aa(_(e===`join`?`Joined the request.`:`Kept these requests separate.`),_(r?i?`Saved here; waiting to sync to your other viewers.`:`Saved as a shared decision.`:t===`cloud`?`Saved in your cloud viewer only.`:`Saved on this machine only.`),a&&_(`This viewer's local work copy is still updating.`))}),!0)}catch(e){return u({tone:`problem`,words:()=>_(`Your grouping decision was not saved.`),cause:oa(e)}),!1}finally{i(!1),f()}},x=r||void 0;return(0,H.jsxs)(`section`,{"aria-labelledby":p,"data-request-suggestion":``,className:`space-y-3 rounded-xl border border-control-edge p-4 text-sm`,children:[(0,H.jsxs)(`h2`,{id:p,className:`flex items-center gap-2 text-xs font-medium tracking-[0.08em] text-muted-foreground uppercase`,children:[(0,H.jsx)(yn,{"aria-hidden":`true`,className:`size-4 shrink-0`}),_(`May be part of another request`)]}),g.sharedConflict&&(0,H.jsx)(`p`,{children:_(`Your viewers recorded different grouping decisions. Read this suggestion, then choose again to resolve them.`)}),(0,H.jsxs)(`p`,{className:`flex items-start gap-2 text-base font-medium`,children:[(0,H.jsx)(wt,{"aria-hidden":`true`,className:`mt-1 size-4 shrink-0`}),y?(0,H.jsx)(s,{variant:`link`,className:`h-auto min-w-0 shrink justify-start px-0 text-left text-base break-words whitespace-normal`,onClick:()=>I.getState().openRequestPage(y),children:g.requestTitle}):(0,H.jsx)(`span`,{className:`min-w-0 break-words`,children:g.requestTitle})]}),g.confidence!==void 0&&(0,H.jsx)(`p`,{className:`text-muted-foreground tabular`,children:F(_(`Looks like a continuation of that request ({percent} confidence).`),{percent:Da(g.confidence)})}),g.evidence&&(0,H.jsxs)(M,{children:[(0,H.jsx)(P,{className:`w-auto`,children:_(`How this was decided`)}),(0,H.jsx)(N,{children:(0,H.jsx)(`p`,{className:`mt-2 rounded-md bg-surface px-3 py-2 font-mono text-xs break-words text-foreground/80`,children:g.evidence})})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(s,{variant:`outline`,size:$,"aria-expanded":o,"aria-controls":h,"aria-disabled":x,onClick:()=>c(e=>!e),children:_(`Join that request`)}),(0,H.jsx)(z,{className:m({variant:`ghost`,size:$}),icon:(0,H.jsx)(Nn,{}),onClick:()=>b(`not-this`),"aria-disabled":x,children:_(`Keep separate`)})]}),(0,H.jsxs)(`div`,{id:h,hidden:!o,className:`space-y-2 rounded-lg border border-control-edge p-3`,children:[(0,H.jsx)(`p`,{children:F(_(`Join this work into “{title}”? It can’t be undone from here.`),{title:g.requestTitle})}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(z,{className:m({variant:`outline`,size:$}),icon:(0,H.jsx)(yn,{}),onClick:()=>b(`join`),"aria-disabled":x,children:_(`Join`)}),(0,H.jsx)(s,{variant:`ghost`,"aria-disabled":x,onClick:()=>c(!1),children:_(`Cancel`)})]}),o&&v]}),!o&&v]})}function ka({request:e}){return a(),e.review?.available===!1?(0,H.jsx)(R,{ids:[`R13.7`],children:(0,H.jsxs)(`div`,{role:`status`,"data-shared-check-unavailable":``,className:`space-y-1 rounded-r-lg border-l-3 border-attention-foreground bg-attention px-3.75 py-2.5 text-sm text-attention-foreground`,children:[(0,H.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(_e,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0`}),_(`Checking this shared version is unavailable until its evidence has synced.`)]}),(0,H.jsx)(B,{cause:e.review.message})]})}):null}function Aa({request:e,changes:t}){a();let{focusAreas:n}=L(),r=Le(e.focusAreaId,n),i=n.filter(e=>Te(e)&&e.id!==r);if(i.length===0&&r===`other`||e.canMoveFocus===!1)return null;let o=(e,t)=>({value:e,label:t,searchWords:[t]}),s=[{heading:_(`Your focus areas`),choices:i.filter(e=>e.status===`kept`).map(e=>o(e.id,e.name))},{heading:_(`Suggested`),choices:i.filter(e=>e.status===`suggested`).map(e=>o(e.id,e.name))},{choices:r===`other`?[]:[o(Oe,_(`Other`))]}],c=s.reduce((e,t)=>e+t.choices.length,0);return(0,H.jsx)(R,{ids:[`R16.6`],children:(0,H.jsx)(na,{trigger:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(dn,{"aria-hidden":`true`,className:`size-4`}),t.saving?_(`Moving…`):_(`Move to a focus area`)]}),groups:s,onChoose:n=>{t.apply({action:`move-request`,requestId:e.id,focusAreaId:n})},searchPlaceholder:_(`Find a focus area`),nothingFound:_(`No focus area matches.`),cannotChoose:t.saving,countLine:F(_(c===1?`{count} area`:`{count} areas · type to narrow`),{count:c})})})}function ja({request:e}){a();let t=nt(`request:${e.id}`),n=e.story.length>0||!!e.storyNarrative;return(0,H.jsx)(`footer`,{"data-request-foot":``,className:`border-t border-border pt-3.5`,children:(0,H.jsxs)(M,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2`,children:[(0,H.jsx)(Aa,{request:e,changes:t}),n&&(0,H.jsx)(ve,{asChild:!0,children:(0,H.jsxs)(s,{variant:`link`,size:`sm`,"data-request-history":``,className:`h-auto gap-1.5 px-1 text-base md:not-pointer-coarse:min-h-9`,children:[(0,H.jsx)(ft,{"aria-hidden":`true`}),_(`Request history`)]})})]}),(0,H.jsx)(dt,{changes:t}),n&&(0,H.jsx)(R,{ids:[`R7.2`,`R3.2`],children:(0,H.jsxs)(N,{className:`space-y-3`,children:[e.storyNarrative&&(0,H.jsx)(Jr,{children:e.storyNarrative}),e.story.length>0&&(0,H.jsx)(qr,{steps:e.story})]})})]})})}function Ma({steps:e}){return(0,H.jsx)(Rt,{"data-request-crumb":``,children:(0,H.jsx)(pt,{children:e.flatMap((e,t)=>[...t>0?[(0,H.jsx)(ht,{},`separator-${t}`)]:[],(0,H.jsx)(at,{children:(0,H.jsx)(mt,{href:e.href,onClick:yt(e.onPress),className:`[overflow-wrap:anywhere]`,children:e.label})},t)])})})}function Na(e){let{t}=a(),{focusAreas:n,requests:r}=L(),i=Ge(e,n,r),o=i.kind===`area`?i.area.id:Oe,s=i.kind===`area`?i.subFocus?.id??null:null,c=Ht(`focus`),l=Ht(`requests`),u={area:ze,status:null,closed:e.closed===!0},d=Ct(u),f=jt(o),p=jt(o,s),{goToPage:m,goToFocus:h,showRequests:g}=I.getState();if(i.kind===`not-sorted`)return[{label:t(We(`requests`).label),href:l,onPress:()=>m(`requests`)},{label:t(Ae),href:d,onPress:()=>g(u)}];let _=[{label:t(We(`focus`).label),href:c,onPress:()=>m(`focus`)}];return _.push({label:i.kind===`area`?i.area.name:t(`Other`),href:f,onPress:()=>h(o)}),s!==null&&i.kind===`area`&&i.subFocus&&_.push({label:i.subFocus.name,href:p,onPress:()=>h(o,{sub:s})}),_}function Pa(e){let{t}=a(),n=xt();return{label:Ee(e,t),href:n(null),onPress:()=>I.getState().showRequestPart(null)}}var Fa=(0,V.createContext)({arrivedByAMove:!1,returnedFrom:null});function Ia(e){let t=`door`in e?`[data-request-door="${CSS.escape(e.door)}"]`:`[data-session-row="${CSS.escape(e.session)}"]`;return document.querySelector(t)}function La({children:e,muted:t=!1}){let n=(0,V.useRef)(null),{arrivedByAMove:r,returnedFrom:i}=(0,V.useContext)(Fa);return(0,V.useEffect)(()=>{let e=document.activeElement;!r||e!==null&&e!==document.body||((i?Ia(i):null)??n.current)?.focus({preventScroll:!0})},[r,i]),(0,H.jsx)(`h1`,{ref:n,tabIndex:-1,"data-view-heading":``,className:c(`rounded-sm text-page-title-phone [overflow-wrap:anywhere] md:text-page-title`,t&&`text-muted-foreground`,Ft),children:e})}function Ra({request:e}){let{t}=a(),n=Na(e),r=e.summary??e.resolvesTo?.summary;return(0,H.jsx)(R,{ids:[`R3.6`,`R2.6`,`R16.5`],children:(0,H.jsxs)(`header`,{"data-request-head":``,className:`space-y-3 md:space-y-3.5`,children:[(0,H.jsx)(Ma,{steps:n}),(0,H.jsx)(La,{muted:!(e.title??e.resolvesTo?.title),children:Ee(e,t)}),r&&(0,H.jsx)(bt,{"data-request-summary":``,className:`max-w-reading`,children:r})]})})}function za({steps:e,title:t,lead:n}){return(0,H.jsxs)(`header`,{"data-request-head":``,className:`space-y-3 md:space-y-3.5`,children:[(0,H.jsx)(Ma,{steps:e}),(0,H.jsx)(La,{children:t}),n&&(0,H.jsx)(bt,{children:n})]})}function Ba(e){let t=Na(e);return[t[t.length-1],Pa(e)]}function Va({request:e}){a();let t=(0,V.useId)(),r=ba(e),i=e.state!==`shipped`;return(0,H.jsxs)(`div`,{"data-request-part":`request`,className:`space-y-6 md:space-y-8`,children:[(0,H.jsx)(Ra,{request:e}),(0,H.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-request md:gap-8`,children:[(0,H.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,H.jsx)(R,{ids:[`R5.5`,`R6.2`],children:(0,H.jsxs)(`p`,{"data-request-state":e.state,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1 text-sm`,children:[(0,H.jsx)(ut,{state:e.state}),i&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:_(e.stage)})]})]})}),(0,H.jsx)(_a,{request:e}),(0,H.jsx)(ua,{request:e},e.id)]}),(0,H.jsxs)(`aside`,{"aria-labelledby":t,className:`hidden border-l border-border pl-6 md:block`,children:[(0,H.jsx)(`h2`,{id:t,className:`mb-1 text-aside-title`,children:_(`Request details`)}),(0,H.jsx)(xa,{request:e})]})]}),(0,H.jsx)(Ta,{request:e}),(0,H.jsxs)(M,{className:`md:hidden`,children:[(0,H.jsx)(ve,{asChild:!0,children:(0,H.jsxs)(s,{variant:`link`,size:`sm`,"data-request-facts-fold":``,className:`h-auto gap-1.5 px-1 text-base`,children:[r?F(_(`Request details · {percent}`),{percent:r}):_(`Request details`),(0,H.jsx)(n,{"aria-hidden":`true`})]})}),(0,H.jsx)(N,{className:`pt-2`,children:(0,H.jsx)(xa,{request:e})})]}),(0,H.jsx)(Oa,{request:e},`suggestion:${e.id}`),(0,H.jsx)($i,{request:e}),(0,H.jsx)(ka,{request:e}),(0,H.jsx)(ja,{request:e})]})}function Ha({request:e}){let{t}=a(),n=Ba(e),r=Ue(e),i=ea(e);return(0,H.jsxs)(`div`,{"data-request-part":`deliverables`,className:`space-y-5 md:space-y-6`,children:[(0,H.jsx)(za,{steps:n,title:t(`Deliverables`),lead:F(t(r.length===1?`{count} work product from this request.`:`{count} work products from this request.`),{count:r.length})}),(0,H.jsx)(R,{ids:[`R5.10`,`R5.12`],children:(0,H.jsxs)(`div`,{className:`space-y-4`,children:[i&&(0,H.jsx)(Pt,{media:i,title:Ee(e,t)}),r.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`No deliverables yet.`)}):(0,H.jsx)(Wi,{products:r}),(0,H.jsx)(Yi,{request:e})]})})]})}var Ua=5,Wa=`max-h-96`;function Ga({records:e,boxed:n=!1}){return(0,H.jsx)(ai,{className:n?Wa:`max-h-none`,scrollRegionLabel:_(`Latest records`),overflowCaption:F(_(`{count} records · scroll to read them all`),{count:e.length}),children:e.map((e,n)=>(0,H.jsxs)(ni,{"data-record-kind":e.kind,className:`grid grid-cols-[1rem_auto_minmax(0,1fr)] items-start gap-x-3 gap-y-1 rounded-none border-b border-border/70 px-0 py-2.5 last:border-b-0 hover:bg-transparent in-data-overflowing:px-2.5 sm:grid-cols-[1rem_auto_minmax(0,1fr)_auto]`,children:[(0,H.jsx)(ri,{completed:e.kind===`memory`,className:c(`justify-self-center border-0`,e.kind===`memory`?`mt-0.5 flex size-3.5 items-center justify-center bg-muted-foreground text-card`:`mt-1.5 size-2 bg-muted-foreground`),children:e.kind===`memory`&&(0,H.jsx)(t,{"aria-hidden":`true`,className:`size-2.5 stroke-3`})}),(0,H.jsx)(Wt,{iso:e.atIso,words:e.at,form:`time-or-day`,className:`mono-number w-[8.5ch] text-[0.8125rem] leading-5 text-muted-foreground`}),(0,H.jsxs)(ii,{className:`text-sm leading-5 text-foreground/90`,children:[e.text,e.media&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(Bt,{media:e.media})]})]}),(0,H.jsx)(st,{variant:`outline`,className:`col-start-3 justify-self-start font-normal sm:col-start-auto sm:justify-self-auto`,children:e.kind===`memory`?_(`memory`):_(`work`)})]},`${n}-${e.text}`))})}function Ka({title:e,count:t,children:n}){return(0,H.jsxs)(M,{children:[(0,H.jsx)(`h2`,{children:(0,H.jsx)(P,{count:t,children:e})}),(0,H.jsx)(N,{className:`pt-3 pb-1`,children:n})]})}var qa={prompt:()=>_(`Your prompt`),"work-state":()=>_(`Work state`),observation:()=>_(`Observation`),summary:()=>_(`Session summary`),session:()=>_(`Session`),record:()=>_(`Record`)};function Ja(e){let t=je(e);return t.kind===null?t.title:F(_(`{kind}: {title}`),{kind:qa[t.kind](),title:t.title})}function Ya(e){let t=e.flatMap(e=>e.tasks);return t.length>0?F(_(`{done} of {total} done`),{done:t.filter(e=>e.done).length,total:t.length}):F(e.length===1?_(`{count} workstream`):_(`{count} workstreams`),{count:e.length})}function Xa({request:e}){let{t}=a(),n=Ba(e),r=(0,V.useId)(),i=e.granular.slice(0,Ua),o=e.granular.slice(Ua),s=Ke(e);return(0,H.jsxs)(`div`,{"data-request-part":`records`,className:`space-y-5 md:space-y-6`,children:[(0,H.jsx)(za,{steps:n,title:t(`Records`),lead:Ee(e,t)}),(0,H.jsx)(R,{ids:[`R3.5`],children:(0,H.jsxs)(`section`,{"aria-labelledby":r,className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border pb-2`,children:[(0,H.jsx)(`h2`,{id:r,className:`text-section-title-phone md:text-section-title`,children:t(`Latest records`)}),(0,H.jsx)(`span`,{className:`text-sm text-muted-foreground tabular`,children:Sa(e)})]}),Re(e)&&(0,H.jsx)(`p`,{"data-records-at-limit":``,className:`text-sm text-muted-foreground`,children:t(`A request keeps only its newest records, so older ones aren’t listed here.`)}),i.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`No records yet.`)}):(0,H.jsx)(Ga,{records:i}),o.length>0&&(0,H.jsxs)(M,{children:[(0,H.jsx)(P,{className:`mt-2`,children:F(o.length===1?t(`{count} earlier record`):t(`{count} earlier records`),{count:o.length})}),(0,H.jsx)(N,{className:`pt-2`,children:(0,H.jsx)(Ga,{records:o,boxed:!0})})]})]})}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[e.evidence.length>0&&(0,H.jsx)(R,{ids:[`R2.2`,`R5.11`],children:(0,H.jsx)(Ka,{title:t(`Sources`),count:F(e.evidence.length===1?t(`{count} source`):t(`{count} sources`),{count:e.evidence.length}),children:(0,H.jsx)(`ul`,{className:`space-y-1`,children:e.evidence.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(vt,{href:e.href,className:`flex touch-target-size items-center gap-2 text-sm text-muted-foreground md:not-pointer-coarse:min-h-9`,children:[(0,H.jsx)(Ce,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),Ja(e)]})},e.href===`#`?e.title:e.href))})})}),e.workstreams.length>0&&(0,H.jsx)(R,{ids:[`R3.4`],children:(0,H.jsx)(Ka,{title:t(`Workstreams`),count:Ya(e.workstreams),children:(0,H.jsx)(`div`,{className:`divide-y divide-border/70`,children:e.workstreams.map((e,n)=>(0,H.jsxs)(li,{defaultOpen:!1,className:`py-0.5`,children:[(0,H.jsx)(ui,{title:Pe(e.title)??t(`Supporting work`),done:e.tasks.filter(e=>e.done).length,total:e.tasks.length}),(0,H.jsx)(di,{className:`pb-3`,children:ra(e.tasks).map((e,n)=>(0,H.jsx)(ci,{done:e.done,children:Ne(e.name)??t(`Untitled task`)},`${n}-${e.name}`))})]},`${n}-${e.title}`))})})}),s.length>0&&(0,H.jsx)(Ka,{title:t(`Repository`),count:fa(s),children:(0,H.jsx)(Wi,{products:s})})]})]})}function Za({conversation:e,conversations:t}){let{t:n}=a(),r=D(e,t);return(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,H.jsx)(`span`,{children:Fe(e.tool,n)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,H.jsx)(`span`,{className:`font-mono`,children:r.idChip}),e.at!==`Time not recorded`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,H.jsx)(Wt,{iso:e.atIso,words:e.at})]})]})}function Qa({conversation:e,conversations:t}){let r=xt(),i=O(e);return(0,H.jsxs)(`a`,{href:r(`conversation`,i),"data-session-row":i,onClick:yt(()=>I.getState().showRequestPart(`conversation`,i)),className:`flex min-h-16 w-full items-center gap-3 rounded-sm px-1 py-3.5 outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 md:gap-4`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block text-row-title [overflow-wrap:anywhere]`,children:bi(D(e,t))}),(0,H.jsx)(`span`,{className:`mt-1 block text-sm text-muted-foreground`,children:(0,H.jsx)(Za,{conversation:e,conversations:t})})]}),(0,H.jsx)(n,{"aria-hidden":`true`,className:`size-4.5 shrink-0 text-muted-foreground`})]})}function $a({sessions:e,conversations:t}){return(0,H.jsx)(`ul`,{className:`divide-y divide-border border-t border-border`,children:e.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Qa,{conversation:e,conversations:t})},O(e)))})}function eo(e,t,n){let r=D(e,t),i=n.trim().toLocaleLowerCase();return[bi(r),r.idChip,e.conversationSessionId].some(e=>e.toLocaleLowerCase().includes(i))}function to({request:e}){let{t}=a(),n=Ba(e),[r,i]=(0,V.useState)(``),o=xt(),{conversations:s}=e,c=Ze(e),l=s.filter(e=>e!==c),u=l.filter(e=>D(e,s).recordedTitle!==null),d=l.filter(e=>D(e,s).recordedTitle===null),f=r.trim()!==``,p=f?s.filter(e=>eo(e,s,r)):[],m=s.length===0?t(`No session is linked to this request yet.`):s.length===1?t(`Choose the linked session to open or reply.`):F(t(`Choose one of the {count} linked sessions to open or reply.`),{count:s.length});return(0,H.jsxs)(`div`,{"data-request-part":`conversation`,className:`space-y-5 md:space-y-6`,children:[(0,H.jsx)(za,{steps:n,title:t(`Conversation`),lead:m}),(0,H.jsx)(R,{ids:[`R2.5`,`R2.2`],children:(0,H.jsxs)(`div`,{className:`space-y-4`,children:[s.length>0&&(0,H.jsx)(Vt,{label:t(`Find a session by name or ID`),words:r,onWords:i}),f?p.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:F(t(`No session matches “{words}”.`),{words:r.trim()})}):(0,H.jsx)($a,{sessions:p,conversations:s}):(0,H.jsxs)(H.Fragment,{children:[c&&(0,H.jsxs)(`section`,{"data-latest-session":O(c),className:`space-y-1.5 rounded-xl border border-border bg-card px-4.5 py-4 shadow-panel md:px-7 md:py-5.5`,children:[(0,H.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,H.jsx)(Ce,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t(`Session linked to the latest work update`)]}),(0,H.jsx)(`h2`,{className:`text-panel-title-phone [overflow-wrap:anywhere] md:text-panel-title`,children:bi(D(c,s))}),(0,H.jsx)(`p`,{className:`text-muted-foreground`,children:(0,H.jsx)(Za,{conversation:c,conversations:s})}),(0,H.jsxs)(Tt,{href:o(`conversation`,O(c)),onPress:()=>I.getState().showRequestPart(`conversation`,O(c)),className:`text-base`,children:[t(`Open this conversation`),(0,H.jsx)(wt,{"aria-hidden":`true`})]})]}),u.length>0&&(0,H.jsx)($a,{sessions:u,conversations:s}),d.length>0&&(0,H.jsxs)(M,{children:[(0,H.jsx)(P,{"data-untitled-sessions":``,children:F(c||u.length>0?d.length===1?t(`{count} other session without a saved title`):t(`{count} other sessions without a saved title`):d.length===1?t(`{count} session without a saved title`):t(`{count} sessions without a saved title`),{count:d.length})}),(0,H.jsx)(N,{className:`pt-2`,children:(0,H.jsx)($a,{sessions:d,conversations:s})})]})]})]})})]})}function no({request:e,conversation:t}){let{t:n}=a(),r=I(e=>e.conversationContinuationSource()!==null),i=xt()(`conversation`),o=Pa(e),s=(0,V.useId)(),c=(0,V.useId)(),l=D(t,e.conversations),u=bi(l),d=Fe(t.tool,n),f=[o,{label:n(`Conversation`),href:i,onPress:()=>I.getState().showRequestPart(`conversation`)}];return(0,H.jsxs)(`div`,{"data-request-part":`session`,"data-session":O(t),className:`space-y-5 md:space-y-7`,children:[(0,H.jsx)(za,{steps:f,title:u,lead:(0,H.jsx)(Za,{conversation:t,conversations:e.conversations})}),e.prompts.length>0&&(0,H.jsx)(R,{ids:[`R2.2`],children:(0,H.jsxs)(`section`,{"aria-labelledby":s,"data-session-words":``,className:`space-y-3 rounded-xl border border-border bg-card px-4.5 py-4 shadow-panel md:px-7 md:py-5.5`,children:[(0,H.jsxs)(`h2`,{id:s,className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,H.jsx)(jn,{"aria-hidden":`true`,className:`size-4 shrink-0`}),n(`Your words in this request`)]}),(0,H.jsx)(`ul`,{className:`space-y-3`,children:e.prompts.map((e,t)=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`blockquote`,{className:`border-l-2 border-goal-border pl-3.5 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.quote}),e.at!==`Time not recorded`&&(0,H.jsx)(`p`,{className:`mt-1 pl-4 text-xs text-muted-foreground mono-number`,children:be(Dt(e.at))})]},`${t}-${e.at}`))})]})}),r&&(0,H.jsxs)(`section`,{"aria-labelledby":c,"data-session-reply":``,className:`space-y-3`,children:[(0,H.jsx)(`h2`,{id:c,className:`text-section-title-phone [overflow-wrap:anywhere] md:text-section-title`,children:l.recordedTitle===null?F(n(`Reply to session {id} in {tool}`),{id:l.idChip,tool:d}):F(n(`Reply to {name} in {tool}`),{name:u,tool:d})}),(0,H.jsx)(Vi,{platform:t.platform,conversationSessionId:t.conversationSessionId,toolName:t.tool,conversationTitle:t.title,anotherConversationHasTheSameTitle:l.idChip!==k(t.conversationSessionId,!1)})]})]})}function ro(e){let t=Math.round(e/1e3);return t<1?_(`The worker answered in under a second.`):F(_(t===1?`Waited {seconds} second for the worker.`:`Waited {seconds} seconds for the worker.`),{seconds:t})}function io({request:e}){let{t}=a();return(0,H.jsxs)(`div`,{"data-request-loading":``,className:`space-y-6 md:space-y-8`,children:[(0,H.jsx)(Ra,{request:e}),(0,H.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-4`,children:[(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:t(`Loading request detail…`)}),(0,H.jsx)(gt,{className:`h-28 w-full rounded-xl motion-safe:animate-none md:w-2/3`}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`grid gap-2.25 md:grid-cols-3 md:gap-3`,children:[0,1,2].map(e=>(0,H.jsx)(gt,{className:`h-14 rounded-xl motion-safe:animate-none md:h-28 md:rounded-2xl`},e))})]})]})}function ao({request:e,cause:t,waitedMs:n,onTryAgain:r}){let{t:i}=a();return(0,H.jsxs)(`div`,{className:`space-y-6 md:space-y-8`,children:[(0,H.jsx)(Ra,{request:e}),(0,H.jsxs)(fe,{variant:`destructive`,role:`alert`,children:[(0,H.jsx)(pe,{children:i(`Could not load this request’s details.`)}),(0,H.jsxs)(he,{children:[n!==void 0&&(0,H.jsx)(`p`,{className:`tabular`,children:ro(n)}),(0,H.jsx)(B,{cause:t})]}),(0,H.jsx)(me,{children:(0,H.jsx)(s,{variant:`outline`,onClick:r,children:i(`Try again`)})})]})]})}function oo({request:e,arrivedByAMove:t=!1,returnedFrom:n=null}){let{t:r}=a(),i=(0,V.useMemo)(()=>({arrivedByAMove:t,returnedFrom:n}),[t,n]),o=ia(e),c=I(e=>e.view.requestPart),l=I(e=>e.view.requestSession),u=o.loaded,d=u&&c===`conversation`?qe(u,l):null,f=u!==null&&c===`conversation`&&l!==null&&d===null;if((0,V.useEffect)(()=>{f&&I.getState().showRequestPart(`conversation`,null,{replace:!0})},[f]),!u)return(0,H.jsx)(Fa.Provider,{value:i,children:o.failure?(0,H.jsx)(ao,{request:e,cause:o.failure.message,waitedMs:o.failure.waitedMs??void 0,onTryAgain:o.tryAgain}):(0,H.jsx)(io,{request:e})});let p=o.newerVersionReadFailure!==null&&(0,H.jsxs)(fe,{variant:`destructive`,role:`alert`,children:[(0,H.jsx)(pe,{children:r(`Could not load the newest version of this request. This is the version read before it.`)}),(0,H.jsx)(he,{children:(0,H.jsx)(B,{cause:o.newerVersionReadFailure})}),(0,H.jsx)(me,{children:(0,H.jsx)(s,{variant:`outline`,onClick:o.tryAgain,children:r(`Try again`)})})]}),m=c===`deliverables`?(0,H.jsx)(Ha,{request:u}):c===`records`?(0,H.jsx)(Xa,{request:u}):c===`conversation`?d?(0,H.jsx)(no,{request:u,conversation:d}):(0,H.jsx)(to,{request:u}):(0,H.jsx)(Va,{request:u});return(0,H.jsx)(Fa.Provider,{value:i,children:(0,H.jsxs)(`div`,{"data-request-page":u.id,className:`space-y-5`,children:[p,m]})})}export{oo as RequestPage};