@ycodium-ai/plugin-conversation 0.2.3176 → 0.2.3188

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/assets/ui.js +6 -3
  2. package/package.json +1 -1
package/assets/ui.js CHANGED
@@ -2260,6 +2260,9 @@ var lB=Object.create;var tf=Object.defineProperty;var dB=Object.getOwnPropertyDe
2260
2260
  .\\[-ms-overflow-style\\:none\\]:where(:scope, *) {
2261
2261
  -ms-overflow-style: none;
2262
2262
  }
2263
+ .\\[background\\:linear-gradient\\(var\\(--accent\\)\\,var\\(--accent\\)\\)\\,var\\(--background\\)\\]:where(:scope, *) {
2264
+ background: linear-gradient(var(--accent),var(--accent)),var(--background);
2265
+ }
2263
2266
  .\\[clip-path\\:inset\\(0_round_calc\\(var\\(--widget-radius\\)-1px\\)\\)\\]:where(:scope, *) {
2264
2267
  clip-path: inset(0 round calc(var(--widget-radius) - 1px));
2265
2268
  }
@@ -4080,7 +4083,7 @@ ${S}
4080
4083
  .session-map-inspector { max-height: 58vh; border: 0; border-top: 1px solid var(--map-border); }
4081
4084
  .session-map-transcript { min-height: 9rem; max-height: 36vh; }
4082
4085
  }
4083
- `;function OT(e){let[t,n]=j(""),[o,r]=j("all"),[a]=j(()=>ip(e.memoryScope)),s=M(a.camera!==null&&a.focusThreadId===e.focusThreadId),[i,l]=j(s.current?a.selectedId:null),[d,u]=j(s.current&&a.camera!==null?a.camera:{x:24,y:24,scale:1}),[f,p]=j({}),[m,h]=j(a.draft);z(()=>{Lv(e.memoryScope,{focusThreadId:e.focusThreadId,camera:d,selectedId:i,draft:m})},[e.memoryScope,e.focusThreadId,d,i,m]),z(()=>()=>Rv(e.memoryScope),[e.memoryScope]);let[g,v]=j(null),C=M(null),y=$(()=>e.board===null?null:bT(e.board,e.fuller),[e.board,e.fuller]),x=$(()=>{let S=new Map;if(y===null)return S;for(let L of y.threads)S.set(L.threadId,L);return S},[y]),b=$(()=>{if(y===null)return{cards:[],childCounts:new Map,descendantCounts:new Map};let S=yv(vv(y.threads),y.anchors);return uT(S,e.collapsed)},[y,e.collapsed]),T=b.cards.filter(S=>{let L=x.get(S.threadId);return L===void 0||o!=="all"&&L.projectId!==o?!1:t.trim().length===0?!0:`${L.title} ${S.question} ${S.answer}`.toLowerCase().includes(t.trim().toLowerCase())}),I=b.cards.find(S=>S.id===i)??T.find(S=>S.threadId===e.focusThreadId)??null,P=o==="all"?e.t("map.projectAll"):y?.projects.find(S=>S.projectId===o)?.title??e.t("map.projectAll"),k=e.focusThreadId!==null&&x.has(e.focusThreadId);return z(()=>{if(!k||e.focusThreadId===null||y===null)return;let S=yv(vv(y.threads),y.anchors),L=T3(S,e.focusThreadId,e.collapsed);if(L.length===e.collapsed.size&&L.every(E=>e.collapsed.has(E))||e.onCollapsed(L),s.current){s.current=!1;return}let _=S.findLast(E=>E.threadId===e.focusThreadId);_!==void 0&&l(_.id)},[e.focusThreadId,e.locateToken,k]),w("section",{ref:C,className:"ycodium-session-map","data-pane":e.fill==="pane"?"":void 0,"data-page":e.fill==="page"?"":void 0,children:[c("style",{children:lp}),w("header",{className:"session-map-bar",children:[w("div",{className:"session-map-title",children:[c("strong",{children:y?.workspaceTitle||e.t("map.title")}),c("span",{children:e.pending&&y===null?e.t("map.loading"):e.t("map.sessions",{count:y?.threads.length??0})})]}),w("div",{className:"session-map-actions",children:[e.viewSwitch,w("div",{className:"session-map-zoom",children:[c(re,{type:"button",size:"icon-xs",variant:"outline","aria-label":e.t("map.zoomOut"),onClick:()=>u(DT(d,1/1.15)),children:c(Fs,{})}),c("span",{children:e.t("map.zoom",{percent:Math.round(d.scale*100)})}),c(re,{type:"button",size:"icon-xs",variant:"outline","aria-label":e.t("map.zoomIn"),onClick:()=>u(DT(d,1.15)),children:c(sc,{})}),c(re,{type:"button",size:"xs",variant:"outline",onClick:()=>{let L=C.current?.querySelector(".session-map-stage")?.getBoundingClientRect(),R=y===null?[]:T.map(_=>Nc(_,y.positions,f));u(mT(R,L?.width??800,L?.height??600)),p({})},children:e.t("map.fit")})]}),c(re,{type:"button",size:"xs",variant:"outline",onClick:e.onLocate,children:e.t("map.locate")}),c(re,{type:"button",size:"xs",variant:"ghost",onClick:()=>{p({}),e.onTidy()},children:e.t("map.tidy")}),e.viewSwitch!=null||e.onClose===null?null:c(re,{type:"button",size:"xs",variant:"ghost",onClick:e.onClose,children:e.t("map.close")})]})]}),g===null?null:w("div",{className:"session-map-undo",children:[c("span",{children:e.t("map.hiddenNotice",{title:g.title})}),c(re,{type:"button",size:"xs",variant:"outline",onClick:()=>{e.onRestore(g.threadId),v(null)},children:e.t("map.undo")})]}),y===null?null:w("div",{className:"session-map-body",children:[w("aside",{className:"session-map-side",children:[c(rw,{className:"session-map-search",value:t,size:"sm",variant:"ghost","aria-label":e.t("map.search"),placeholder:e.t("map.search"),onValueChange:n}),w("div",{className:"session-map-actions",style:{marginTop:8},children:[c(re,{type:"button",size:"xs",onClick:()=>h({kind:"new"}),children:e.t("map.new")}),w(oa,{value:o,onValueChange:S=>r(S??"all"),children:[c(Ws,{size:"xs","aria-label":e.t("map.projectAll"),children:c(aa,{children:P})}),w(ra,{children:[c(or,{value:"all",children:e.t("map.projectAll")}),y.projects.map(S=>c(or,{value:S.projectId,children:S.title||S.workspaceRoot},S.projectId))]})]})]}),y.threads.length===0?c(qs,{title:e.t("map.empty")}):null,c(w3,{t:e.t,board:y,focusThreadId:e.focusThreadId,onOpen:S=>{let L=b.cards.findLast(R=>R.threadId===S);L!==void 0&&l(L.id),e.onOpenThread(S)}})]}),c(PT,{t:e.t,board:y,cards:T,childCounts:b.childCounts,descendantCounts:b.descendantCounts,collapsed:e.collapsed,focusThreadId:e.focusThreadId,selectedId:I?.id??null,optimistic:f,camera:d,resumeCamera:a.camera!==null&&a.focusThreadId===e.focusThreadId,locateToken:e.locateToken,onCamera:u,onSelect:S=>l(S.id),onMove:e.onMove,onOptimistic:(S,L,R)=>p(_=>({..._,[S]:{x:L,y:R}})),onToggleCollapse:S=>{let L=new Set(e.collapsed);L.has(S)?L.delete(S):L.add(S),e.onCollapsed([...L])},onContinue:S=>{l(S.id),h({kind:"continue",threadId:S.threadId})},onBranch:S=>{l(S.id),h({kind:"branch",threadId:S.threadId,messageId:S.messageId})},onHide:S=>{let L=x.get(S)?.title??e.t("settings.hiddenUntitled");v({threadId:S,title:L}),e.onHide(S)},onOpen:e.onOpenThread}),c(_T,{t:e.t,board:y,cards:b.cards,selected:I,detail:e.detail,detailThreadId:e.detailThreadId,phrases:e.phrases,draft:m,savedText:S=>{let L=ip(e.memoryScope);return L.textTarget===S?L.text:""},onText:(S,L)=>Lv(e.memoryScope,{textTarget:S,text:L}),onDraft:h,onPhrases:e.onPhrases,onAnchor:e.onAnchor,onLoadDetail:e.onLoadDetail,onOpen:e.onOpenThread,formatTime:e.formatTime,onSend:e.onSend})]})]})}function w3(e){let t=M(null),n=$(()=>I3(e.board,e.t),[e.board,e.t]),o=n.findIndex(r=>r.kind==="thread"&&r.thread.threadId===e.focusThreadId);return z(()=>{o<0||t.current?.scrollIndexIntoView({index:o,animated:!1})},[e.focusThreadId,o]),c("div",{className:"session-map-sessions",children:c(ep,{ref:t,data:n,estimatedItemSize:36,keyExtractor:r=>r.key,extraData:e.focusThreadId,style:{height:"100%"},renderItem:({item:r})=>r.kind==="header"?c("div",{className:"session-map-project",children:r.title}):c(aw,{className:"session-map-session",label:r.thread.title||e.t("card.empty"),pressed:r.thread.threadId===e.focusThreadId,trailing:r.thread.running?c("span",{className:"session-map-running",children:e.t("map.running")}):void 0,onClick:()=>e.onOpen(r.thread.threadId)})})})}function I3(e,t){let n=new Map;for(let s of e.threads){let i=n.get(s.projectId)??[];i.push(s),n.set(s.projectId,i)}let o=new Set(e.projects.map(s=>s.projectId)),r=[];for(let s of e.projects){let i=n.get(s.projectId)??[];if(i.length!==0){r.push({kind:"header",key:`project:${s.projectId}`,title:s.title||s.workspaceRoot});for(let l of i)r.push({kind:"thread",key:l.threadId,thread:l})}}let a=e.threads.filter(s=>!o.has(s.projectId));if(a.length>0){r.push({kind:"header",key:"project:none",title:t("map.ungrouped")});for(let s of a)r.push({kind:"thread",key:s.threadId,thread:s})}return r}function DT(e,t){let n=Math.min(4,Math.max(.25,e.scale*t));return{...e,scale:n}}function T3(e,t,n){return[...fT(e,t,n)]}var Ev="ycodium-session-map:phrases",Av="ycodium-session-map:collapsed",BT="ycodium-session-map:phrases",zT="ycodium-session-map:collapsed";function HT(e,t,n){let o=r=>{r.key===e&&n()};return window.addEventListener("storage",o),window.addEventListener(t,n),()=>{window.removeEventListener("storage",o),window.removeEventListener(t,n)}}var ri=[];function UT(){return GT(Ev)}function $T(e){jT(Ev,JSON.stringify(e)),window.dispatchEvent(new Event(BT))}function KT(e){return HT(Ev,BT,e)}function VT(){return GT(Av)}function qT(e){jT(Av,JSON.stringify(e)),window.dispatchEvent(new Event(zT))}function WT(e){return HT(Av,zT,e)}var FT=new Map;function GT(e){let t=P3(e),n=FT.get(e);if(n!==void 0&&n.raw===t)return n.value;let o=k3(t);return FT.set(e,{raw:t,value:o}),o}function k3(e){if(e===null)return ri;try{let t=JSON.parse(e);if(!Array.isArray(t))return ri;let n=t.filter(o=>typeof o=="string");return n.length===0?ri:n}catch{return ri}}function P3(e){try{return localStorage.getItem(e)}catch{return null}}function jT(e,t){try{localStorage.setItem(e,t)}catch{}}X();function dp(e){let[t,n]=j(()=>({data:e,board:bv(null,e)}));return t.data!==e&&n({data:e,board:bv(t.board,e)}),t.board}function cp(e){let t=Fn(KT,UT,()=>ri),n=Fn(WT,VT,()=>ri),o=$(()=>new Set(n),[n]),[r,a]=j(null),s=M(0),[i,l]=j(0),d=e.environmentId,u=e.threadId,f=d===null?{}:{environmentId:d},p=e.bridge.commands.useSubscription("live",{},f),m=e.bridge.commands.useSubscription("ycodium.sessionProjection",{name:"card",threadId:u!==null&&u.length>0?u:"_"},f),h=e.bridge.i18n.usePluginTranslation(),g=e.bridge.useFormatTimestamp(),v=dp(p.data);z(()=>{u===null||u.length===0||e.bridge.commands.invoke("focus",{threadId:u},f)},[u,d,e.bridge]);let C=u===null?null:ST(m.data);return c(OT,{t:h,board:v,pending:p.isPending,focusThreadId:u,fuller:C,detail:r?.view??null,detailThreadId:r?.threadId??null,phrases:_c(t),collapsed:o,fill:e.fill,locateToken:e.locateToken+i,memoryScope:d??"",viewSwitch:e.viewSwitch??null,formatTime:g,onClose:e.onClose,onOpenThread:y=>{d!==null&&e.bridge.openThread({environmentId:d,threadId:y})},onLocate:()=>l(y=>y+1),onPhrases:$T,onCollapsed:qT,onMove:(y,x,b)=>{e.bridge.commands.invoke("move",{cardId:y,x,y:b},f)},onTidy:()=>{e.bridge.commands.invoke("tidy",{},f)},onHide:y=>{e.bridge.commands.invoke("hide",{threadId:y},f)},onRestore:y=>{e.bridge.commands.invoke("restore",{threadId:y},f)},onAnchor:(y,x)=>{e.bridge.commands.invoke("preferences",{patch:{anchor:{threadId:y,cardId:x}}},f)},onLoadDetail:y=>{let x=s.current+1;s.current=x,e.bridge.commands.invoke("detail",{threadId:y},f).then(b=>{s.current===x&&a({threadId:y,view:wT(b)})})},onSend:async(y,x,b)=>{let T=IT(await L3(e.bridge,y,x,b,f));return T.ok&&T.walkedBack?e.bridge.notify(h("card.walkedBack"),"info"):T.ok&&e.bridge.notify(h("draft.sent"),"success"),T}})}async function L3(e,t,n,o,r){switch(t.kind){case"continue":return e.commands.invoke("send",{threadId:t.threadId,text:n},r);case"branch":return e.commands.invoke("fork",{threadId:t.threadId,messageId:t.messageId,text:n},r);case"new":return e.commands.invoke("create",{projectId:o,text:n},r);default:return t}}X();function rn(){return{t:wn().i18n.usePluginTranslation()}}function QT(e){if(e.cacheDisjoint!==!0)return null;let t=e.cachedInputTokens,n=e.inputTokens;if(t===void 0||n===void 0)return null;let o=t+n;if(o<=0)return null;if(t>=o)return"100%";let r=t/o*100;for(let a=0;a<=3;a+=1){let s=r.toFixed(a);if(Number.parseFloat(s)<100)return`${s}%`}return"99.9%"}function XT(e){let t,n,o,r=!0,a=!1;for(let s of e)s!==void 0&&(a=!0,s.cacheDisjoint!==!0&&(r=!1),s.outputTokens!==void 0&&(t=(t??0)+s.outputTokens),s.inputTokens!==void 0&&(n=(n??0)+s.inputTokens),s.cachedInputTokens!==void 0&&(o=(o??0)+s.cachedInputTokens));if(!(t===void 0&&n===void 0&&o===void 0))return{...a&&r?{cacheDisjoint:!0}:{},...t!==void 0?{outputTokens:t}:{},...n!==void 0?{inputTokens:n}:{},...o!==void 0?{cachedInputTokens:o}:{}}}function Dc(e){return e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}var R3=fe(function({item:t,ordinal:n,usage:o,onSelect:r}){return w("button",{type:"button","data-turn-navigator-row":t.sectionKey,onClick:()=>r(t),className:"flex w-full cursor-pointer items-start gap-2.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-accent",children:[c("span",{className:"shrink-0 pt-px font-mono text-[10px] text-muted-foreground tabular-nums",children:n}),w("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[c("span",{className:"line-clamp-2 min-w-0 font-medium text-chat leading-snug",children:t.userText}),t.assistantText?w("span",{className:"flex items-baseline gap-2",children:[c("span",{className:"line-clamp-1 min-w-0 flex-1 text-[11px] text-muted-foreground leading-snug",children:t.assistantText}),o?.outputTokens!==void 0?c("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground tabular-nums",children:Dc(o.outputTokens)}):null]}):null]})]})});function E3({totals:e}){let{t}=rn();if(!e)return null;let n=QT(e),o=[e.outputTokens===void 0?null:{label:t("turnNavigator.usageOutput"),value:Dc(e.outputTokens)},e.inputTokens===void 0?null:{label:t("turnNavigator.usageInput"),value:Dc(e.inputTokens)},e.cachedInputTokens===void 0?null:{label:t("turnNavigator.usageCacheRead"),value:n===null?Dc(e.cachedInputTokens):`${Dc(e.cachedInputTokens)} (${n})`}].filter(r=>r!==null);return o.length===0?null:w("div",{className:"flex items-baseline gap-2 border-t px-2 py-1.5",children:[c("span",{className:"flex-1 font-mono text-[10px] text-muted-foreground uppercase tracking-[0.14em]",children:t("turnNavigator.usage")}),o.map(r=>w("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:[r.label," ",r.value]},r.label))]})}var A3=fe(function({getText:t,size:n="xs",variant:o="outline",className:r}){let{t:a}=rn(),s=wn().writeClipboard,[i,l]=j(!1),d=a("turnNavigator.copyMarkdown");return w(Ue,{children:[c(Ke,{render:c(re,{"aria-label":d,disabled:i,onClick:()=>{s(t()).then(()=>{l(!0),window.setTimeout(()=>l(!1),1e3)})},type:"button",size:n,variant:o,className:G("text-muted-foreground hover:text-foreground",r)}),children:i?c(Wn,{className:"size-3 text-primary"}):c(Ns,{className:"size-3"})}),c($e,{children:c("p",{children:d})})]})});function YT({items:e,totalTurnCount:t,bottomInset:n,usageByTurnId:o,onSelect:r,exportMarkdown:a,onDownload:s,placement:i="float"}){let{t:l}=rn(),[d,u]=j(!1),f=$(()=>e.map((g,v)=>({item:g,ordinal:v+1})).reverse(),[e]),p=$(()=>XT(f.map(({item:g})=>g.turnId===null?void 0:o.get(g.turnId))),[f,o]);if(e.length===0)return null;let m=t??e.length,h=l("turnNavigator.open",{count:m});return w(Mr,{onOpenChange:u,open:d,children:[w(_r,{render:c(re,{"aria-label":h,className:G("gap-1.5 rounded-full px-3",i==="float"&&"absolute right-3 z-40"),"data-testid":"turn-navigator-pill",size:"xs",style:i==="float"?{bottom:n+12}:void 0,title:h,variant:"glass"}),children:[c(Zd,{"aria-hidden":!0}),c("span",{className:"font-mono font-semibold text-[11px] tabular-nums",children:m})]}),c(Nr,{align:"end",className:"w-80 flex-col",side:"top",children:w("div",{className:"flex max-h-[min(60vh,26rem)] flex-col",children:[w("div",{className:"flex items-center gap-1.5 border-b px-2 py-1.5",children:[c("span",{className:"flex-1 font-mono text-[10px] text-muted-foreground uppercase tracking-[0.14em]",children:l("turnNavigator.title")}),c("span",{className:"font-mono text-[10px] text-muted-foreground tabular-nums",children:m})]}),c("div",{className:G("min-h-0 flex-1 overflow-y-auto overflow-x-hidden p-1"),children:f.map(({item:g,ordinal:v})=>c(R3,{item:g,onSelect:C=>{u(!1),r(C)},ordinal:v,usage:g.turnId===null?void 0:o.get(g.turnId)},g.sectionKey))}),c(E3,{totals:p}),w("div",{className:"flex items-center gap-1 border-t px-2 py-1.5",children:[c("span",{className:"flex-1 font-mono text-[10px] text-muted-foreground uppercase tracking-[0.14em]",children:l("turnNavigator.export")}),c(A3,{size:"icon-xs",getText:a,variant:"ghost"}),c(re,{"aria-label":l("turnNavigator.downloadMarkdown"),onClick:()=>s("md"),size:"xs",title:l("turnNavigator.downloadMarkdown"),variant:"ghost",children:c("span",{className:"font-mono text-[10px]",children:".md"})}),c(re,{"aria-label":l("turnNavigator.downloadJson"),onClick:()=>s("json"),size:"xs",title:l("turnNavigator.downloadJson"),variant:"ghost",children:c("span",{className:"font-mono text-[10px]",children:".json"})})]})]})})]})}X();function Oc(e){return e.replace(/\s+/g," ")}function M3(e,t){let n=e.slice(Math.max(0,e.length-t));return/^[\uDC00-\uDFFF]/.test(n)&&(n=n.slice(1)),n}function N3(e,t){let n=e.slice(0,t);return/[\uD800-\uDBFF]$/.test(n)&&(n=n.slice(0,-1)),n}function up(e){let n=(e instanceof Element?e:e?.parentElement??null)?.closest("[data-assistant-quote-body]")??null;return n?.closest('[data-message-role="assistant"]')?n:null}function JT(e){if(!e||e.isCollapsed||e.rangeCount===0)return null;let t=e.getRangeAt(0),n=up(t.startContainer);if(n===null||up(t.endContainer)!==n)return null;let o=n.closest("[data-message-id]")?.dataset.messageId;if(!o)return null;let r=e.toString().trim();if(r.length===0)return null;let a=document.createRange();a.selectNodeContents(n),a.setEnd(t.startContainer,t.startOffset);let s=document.createRange();s.selectNodeContents(n),s.setStart(t.endContainer,t.endOffset);let i=Oc(t.toString()),l=i.length>i.trimStart().length?" ":"",d=i.length>i.trimEnd().length?" ":"",u=Oc(a.toString()+l),f=Oc(d+s.toString()),p=u.length,m=p+i.trim().length,h=t.getClientRects(),g=h[0]??t.getBoundingClientRect(),v=h[h.length-1]??g;return{messageId:o,text:r,start:p,end:m,prefix:M3(u,32),suffix:N3(f,32),anchor:{x:v.right,top:g.top,bottom:v.bottom}}}var fp="assistant-quote-inserter",pp="assistant-quote-open-comment";X();var e0=100,_3=new Map,ZT=new Map,mp=e=>typeof e=="function"?e():e,t0=(e,t)=>typeof t=="function"?t(e):t;function D3(e,t,n){let o=e.get(t);return o===void 0&&(o={values:new Map,limit:Math.max(1,n)},e.set(t,o)),o}function O3(e,t){let n=ZT.get(e);return n===void 0&&(n={values:new Map,limit:Math.max(1,t)},ZT.set(e,n)),n}function F3(e,t){if(!(e.values.size<=e.limit)){for(let[n,o]of e.values){if(e.values.size<=e.limit)return;o===t||o.committed||o.leases>0||(e.values.delete(n),o.alive=!1,o.subscribers.clear())}for(let[n,o]of e.values){if(e.values.size<=e.limit)return;o===t||o.leases>0||(e.values.delete(n),o.alive=!1,o.subscribers.clear())}}}function Mv(e,t,n){e.values.get(t)===n&&(e.values.delete(t),e.values.set(t,n))}function n0(e,t,n){let o=e.values.get(t);return o===void 0&&(o={value:mp(n),subscribers:new Set,leases:0,alive:!0,committed:!1},e.values.set(t,o)),o}function Fc(e){queueMicrotask(()=>F3(e))}function Mt(e,t,n,o=e0){let r=Math.max(1,o),a=D3(_3,e,r),s=n0(a,t,n),i=A(f=>s.alive?(a.limit=r,s.committed=!0,Mv(a,t,s),s.leases+=1,s.subscribers.add(f),Fc(a),()=>{s.subscribers.delete(f),s.leases=Math.max(0,s.leases-1),Fc(a)}):()=>{},[r,s,a,t]),l=A(()=>s.value,[s]),d=Fn(i,l,l),u=A(f=>{if(!s.alive||a.values.get(t)!==s)return;let p=s.value,m=t0(p,f);if(!Object.is(m,p)){s.value=m,Mv(a,t,s);for(let h of s.subscribers)h();Fc(a)}},[s,a,t]);return[d,u]}function o0(e,t){let n=M(null);(n.current===null||n.current.key!==e)&&(n.current={key:e,value:mp(t)});let[,o]=Jr(a=>a+1,0),r=A(a=>{let s=n.current;if(s===null||s.key!==e)return;let i=t0(s.value,a);Object.is(i,s.value)||(s.value=i,o())},[e]);return[n.current.value,r]}function at(e,t,n,o=e0){let r=Math.max(1,o),a=O3(e,r),s=n0(a,t,()=>({current:mp(n)}));return z(()=>{if(!(!s.alive||a.values.get(t)!==s))return a.limit=r,s.committed=!0,Mv(a,t,s),s.leases+=1,Fc(a),()=>{s.leases=Math.max(0,s.leases-1),Fc(a)}},[r,s,a,t]),s.value}function Ro(e,t){let n=M(null);return(n.current===null||n.current.key!==e)&&(n.current={key:e,ref:{current:mp(t)}}),n.current.ref}var B3=300;function r0(e){let{data:t,target:n,threadKey:o,surfaceRef:r}=e,{t:a}=le(),s=at(fp,o,null),[,i]=Mt(pp,o,null),[l,d]=j(null),u=M(null);if(z(()=>{let g,v=()=>{let I=r.current,P=document.getSelection(),k=P&&P.rangeCount>0?P.getRangeAt(0):null;if(!I||!k||!I.contains(k.commonAncestorContainer)){d(null);return}let S=JT(P);if(S===null){d(null);return}let L=t.assistantQuotes.serialize({version:1,environmentId:n.environmentId,threadId:n.threadId,messageId:S.messageId,text:S.text,start:S.start,end:S.end,prefix:S.prefix,suffix:S.suffix});d({source:L,...S.anchor})},C=I=>{u.current?.contains(I.target)||(clearTimeout(g),g=setTimeout(v,B3))},y=I=>{u.current?.contains(I.target)||(clearTimeout(g),d(null))},x=()=>d(null),b=I=>{I.key==="Escape"&&d(null)},T=()=>{(document.getSelection()?.isCollapsed??!0)&&d(null)};return document.addEventListener("pointerup",C,!0),document.addEventListener("keyup",C,!0),document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",b,!0),document.addEventListener("selectionchange",T),window.addEventListener("scroll",x,!0),()=>{clearTimeout(g),document.removeEventListener("pointerup",C,!0),document.removeEventListener("keyup",C,!0),document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",b,!0),document.removeEventListener("selectionchange",T),window.removeEventListener("scroll",x,!0)}},[t,r,n.environmentId,n.threadId]),l===null)return null;let f=l.source,p=Math.max(8,Math.min(window.innerWidth-200,l.x-12)),m=l.bottom+6,h=m+40<=window.innerHeight?m:Math.max(8,l.top-40);return c("div",{ref:u,className:"fixed z-50",style:{left:p,top:h},"data-assistant-quote-toolbar":"",children:w(re,{size:"sm",variant:"outline",className:"shadow-md",disabled:f===null,title:f===null?a("timeline.quote.tooLong"):void 0,onMouseDown:g=>g.preventDefault(),onClick:()=>{f!==null&&s.current?.(f)===!0&&(i(f),document.getSelection()?.removeAllRanges(),d(null))},children:[c(na,{"aria-hidden":"true"}),a("timeline.quote.cite")]})})}X();X();function a0(e){let t=e.map(o=>({key:o.key,turnId:o.turnId,firstRowIndex:o.firstRowIndex,endRowIndex:o.firstRowIndex+o.rowIds.length})),n=new Map;for(let o of e)for(let[r,a]of o.rowIds.entries())n.set(a,{turnId:o.turnId,index:o.firstRowIndex+r});return{sections:t,bySectionKey:new Map(t.map(o=>[o.key,o])),byRowId:n}}function gp({index:e,visibleSectionKeys:t,protectedRowIds:n,selectionRows:o}){let r=t.flatMap(d=>{let u=e.bySectionKey.get(d)?.turnId;return u==null?[]:[u]}),a=n.flatMap(d=>{let u=e.byRowId.get(d)?.turnId;return u==null?[]:[u]}),s=o?e.byRowId.get(o.firstRowId)?.index:void 0,i=o?e.byRowId.get(o.lastRowId)?.index:void 0,l=s===void 0||i===void 0?[]:e.sections.flatMap(d=>d.turnId!==null&&d.endRowIndex>Math.min(s,i)&&d.firstRowIndex<=Math.max(s,i)?[d.turnId]:[]);return{firstTurnId:r[0]??null,lastTurnId:r.at(-1)??null,protectedTurnIds:[...new Set(a)],selectionTurnRange:l.length>0?{firstTurnId:l[0],lastTurnId:l.at(-1)}:null}}function s0(e,t,n,o){if(!o)return n;let r=e.findIndex(a=>t.has(a));return r<0?n:Math.max(n,e.length-r)}X();X();function Nv(e,t){for(let n of e.querySelectorAll("[data-timeline-row-id]"))if(n.dataset.timelineRowId===t)return n;return null}function ai(e,t){let n=0,o=e.length,r=-1;for(;n<o;){let a=Math.floor((n+o)/2),i=e[a].getBoundingClientRect();Math.max(i.bottom,i.top+1)>t?(r=a,o=a):n=a+1}return r}function z3(e){let t=e.getBoundingClientRect().top,n=e.querySelectorAll("[data-timeline-turn-section]"),o=a=>{let s=a.querySelectorAll("[data-timeline-row-id]"),i=ai(s,t),l=i<0?void 0:s[i],d=l?.dataset.timelineRowId;return!l||d===void 0?null:{rowId:d,offsetPx:Math.round(t-l.getBoundingClientRect().top)}};if(n.length===0)return o(e);let r=ai(n,t);if(r<0)return null;for(let a=r;a<n.length;a+=1){let s=o(n[a]);if(s)return s}return null}function i0(e,t){let n=0,o=e;for(;o&&o!==t;)n+=o.offsetTop,o=o.offsetParent;return n}var _v=class extends Xr{getSnapshotBeforeUpdate(t){return t.inputKey!==this.props.inputKey&&t.onBeforeInputChange(),null}componentDidUpdate(){}componentWillUnmount(){this.props.onBeforeInputChange()}render(){return this.props.children}};function l0({inputKey:e,onBeforeInputChange:t,handleRef:n,onAttach:o,className:r,children:a,onScroll:s,onInteractionRowsChange:i}){let l=M(null),d=M({inputKey:e,store:pc()});d.current.inputKey!==e&&(d.current={inputKey:e,store:pc()});let u=M(i);u.current=i;let f=A(m=>{let h=d.current;return h.store.acquire(m,()=>{d.current===h&&u.current?.(h.store.rows())})},[]);me(()=>{i?.(d.current.store.rows())},[e,i]),Bo(n,()=>({get node(){return l.current},measure:()=>{let m=l.current;return m?{scroll:m.scrollTop,scrollLength:m.clientHeight,contentLength:m.scrollHeight,topOf:h=>{let g=Nv(m,h);return g===null?null:i0(g,m)},heightOf:h=>{let g=Nv(m,h);return g===null?null:g.offsetHeight},rowAtScroll:()=>z3(m)}:null},scrollToEnd:m=>{let h=l.current;if(h){if(m?.animated){h.scrollTo({top:h.scrollHeight,behavior:"smooth"});return}h.scrollTop=h.scrollHeight-h.clientHeight}},scrollToRow:(m,h)=>{let g=l.current;if(!g)return!1;let v=Nv(g,m);return v?(g.scrollTop=Math.max(0,i0(v,g)-(h?.viewOffset??0)),!0):!1},scrollToOffset:m=>{let h=l.current;h&&(h.scrollTop=Math.max(0,m))}}),[]);let p=A(m=>{l.current=m,o(m)},[o]);return c(_v,{inputKey:e,onBeforeInputChange:t,children:c(fc,{value:f,children:c("div",{ref:p,className:r,style:{position:"relative"},onScroll:s,children:a})})})}function ml(e){if(!e)return!1;let t=e.tagName?.toLowerCase(),n=e.getAttribute?.("contenteditable");if(t==="textarea"||n==="true"||n===""||n==="plaintext-only"||"isContentEditable"in e&&e.isContentEditable===!0)return!0;if(t==="input"){let o=e.getAttribute?.("type")?.toLowerCase()??"text";if(!["button","submit","reset","image","checkbox","radio"].includes(o))return!0}return e.matches?.(":focus-visible")??!1}function pl(e,t){let o=(e?.nodeType===1?e:e?.parentElement)?.closest("[data-timeline-row-id]");return o&&t.contains(o)?o.dataset.timelineRowId??null:null}function hp(e){let t=e.ownerDocument.getSelection?.();if(!t||t.isCollapsed)return null;let n=null,o=null;for(let d=0;d<t.rangeCount;d+=1){let u=t.getRangeAt(d);u.intersectsNode(e)&&(n??=u,o=u)}if(!n||!o)return null;let r=pl(n.startContainer,e),a=pl(o.endContainer,e);if(r&&a)return{firstRowId:r,lastRowId:a};let s=e.querySelectorAll("[data-timeline-row-id]"),i=s[0]?.dataset.timelineRowId,l=s[s.length-1]?.dataset.timelineRowId;return i&&l?{firstRowId:r??i,lastRowId:a??l}:null}function Bc(e){let t=e.ownerDocument.getSelection?.();if(!t||t.isCollapsed)return!1;for(let n=0;n<t.rangeCount;n+=1)if(t.getRangeAt(n).intersectsNode(e))return!0;return!1}X();function Ya(e){let t=M(e);t.current=e;let n=M(!1),o=M(null),r=M(null),a=M(0),s=A(()=>{a.current+=1,r.current!==null&&cancelAnimationFrame(r.current),r.current=null},[]),i=A(()=>{if(!n.current||!t.current||r.current!==null||o.current===null)return;let u=++a.current;r.current=requestAnimationFrame(f=>{if(u!==a.current||(r.current=null,!n.current||!t.current))return;let p=o.current;o.current=null,p?.(f)})},[]),l=A(u=>{o.current=u,i()},[i]),d=A(()=>{o.current=null,s()},[s]);return me(()=>(n.current=!0,i(),()=>{n.current=!1,s()}),[e,s,i]),$(()=>({request:l,cancel:d}),[l,d])}function d0({root:e,inputKey:t,visible:n,index:o,topInset:r,bottomInset:a,interactionRows:s,onRangeChange:i,onSelectionChange:l}){let d=M({inputKey:t,visible:n,index:o,topInset:r,bottomInset:a,interactionRows:s,onRangeChange:i,onSelectionChange:l});d.current={inputKey:t,visible:n,index:o,topInset:r,bottomInset:a,interactionRows:s,onRangeChange:i,onSelectionChange:l};let u=Ya(n),f=M(null),p=A(()=>{let h=d.current;if(!e||!h.visible||e.clientHeight<=0)return;let g=e.getBoundingClientRect();if(g.height<=0)return;let v=g.top+h.topInset,C=g.bottom-h.bottomInset,y=e.querySelectorAll("[data-timeline-turn-section]"),x=ai(y,v),b=[];if(x>=0)for(let S=x;S<y.length;S+=1){let L=y[S];if(L.getBoundingClientRect().top>=C)break;L.dataset.timelineTurnSection!==void 0&&b.push(L.dataset.timelineTurnSection)}let T=[...h.interactionRows()],I=e.ownerDocument.activeElement;if(ml(I)){let S=pl(I,e);S&&T.push(S)}let P=gp({index:h.index,visibleSectionKeys:b,protectedRowIds:T,selectionRows:hp(e)}),k=`${h.inputKey}:${JSON.stringify(P)}`;k!==f.current&&(f.current=k,h.onRangeChange?.(P))},[e]),m=A(()=>u.request(p),[u,p]);return me(()=>{if(f.current=null,!n||!e)return;let h=t,g=!0,v=()=>{!g||d.current.inputKey!==h||!d.current.visible||(d.current.onSelectionChange(Bc(e)),m())};e.addEventListener("scroll",v,{passive:!0}),e.addEventListener("focusin",v),e.addEventListener("focusout",v),e.ownerDocument.addEventListener("selectionchange",v);let C=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return C?.observe(e),e.firstElementChild&&C?.observe(e.firstElementChild),v(),()=>{g=!1,u.cancel(),C?.disconnect(),e.removeEventListener("scroll",v),e.removeEventListener("focusin",v),e.removeEventListener("focusout",v),e.ownerDocument.removeEventListener("selectionchange",v),i?.(null)}},[u,t,i,m,e,n]),me(()=>{n&&m()},[o,m,n]),m}X();var c0=fe(function({sectionKey:t,rowKeyPrefix:n,rowIds:o,renderRow:r,sectionRef:a}){return c("div",{className:"session-turn","data-timeline-turn-section":t,ref:a,children:o.map(s=>c("div",{className:"transcript-col min-w-0 overflow-x-clip",children:r(s)},`${n}:${s}`))})});var H3=400;function u0({root:e,minimumCount:t,keepAbovePx:n=0,canCompact:o,onCompact:r}){let a=e.ownerDocument,s=new Set,i,l=!1,d=()=>e.scrollHeight-e.clientHeight-e.scrollTop<=2,u=()=>{if(i=void 0,a.hidden||s.size>0||!o()||e.clientHeight<=0||!d()||Bc(e))return;let b=e.querySelectorAll("[data-timeline-turn-section]"),T=e.getBoundingClientRect().top-32-n,I=0,P=Math.max(0,b.length-t);for(;I<P;){let S=Math.floor((I+P)/2),L=b[S].getBoundingClientRect().bottom;if(!Number.isFinite(L))return;L<=T?I=S+1:P=S}if(I===0)return;let k=a.activeElement;if(k&&ml(k)){for(let S=0;S<I;S+=1)if(b[S].contains(k))return}r(b.length-I)},f=!1,p=()=>{if(a.hidden||s.size>0||!o()||f){clearTimeout(i),i=void 0;return}i===void 0&&(i=setTimeout(u,H3))},m=()=>{clearTimeout(i),i=void 0,p()},h=()=>{let b=d();!b||!l?m():p(),l=b},g=b=>{s.add(b.pointerId),m()},v=b=>{s.delete(b.pointerId),m()},C=()=>{f=Bc(e),m()},y=()=>{s.clear(),m()},x=["wheel","keydown","focusin","focusout"];for(let b of x)e.addEventListener(b,m,{passive:!0});return e.addEventListener("scroll",h,{passive:!0}),e.addEventListener("pointerdown",g,!0),a.addEventListener("pointerup",v,!0),a.addEventListener("pointercancel",v,!0),a.addEventListener("selectionchange",C),a.addEventListener("visibilitychange",p),a.defaultView?.addEventListener("blur",y),p(),{schedule:p,disconnect:()=>{clearTimeout(i);for(let b of x)e.removeEventListener(b,m);e.removeEventListener("scroll",h),e.removeEventListener("pointerdown",g,!0),a.removeEventListener("pointerup",v,!0),a.removeEventListener("pointercancel",v,!0),a.removeEventListener("selectionchange",C),a.removeEventListener("visibilitychange",p),a.defaultView?.removeEventListener("blur",y)}}}X();function f0({root:e,topInsetPx:t,onActiveSectionChange:n,onActiveStartHiddenChange:o,active:r}){let a=M(r);a.current=r;let s=Ya(r),i=M(new Map),l=M(null),d=M(null),u=M(n);u.current=n;let f=M(o);f.current=o;let p=M(null),m=M(null),h=A(()=>{if(!a.current||!e)return;let x=e.scrollTop+t,b=null,T=Number.NEGATIVE_INFINITY,I=null,P=Number.POSITIVE_INFINITY;for(let[R,_]of i.current){if(!_.isConnected)continue;let E=_.offsetTop;E<P&&(P=E,I=R),E<=x&&E>=T&&(T=E,b=R)}let k=b??I;k!==d.current&&(d.current=k,u.current(k));let S=k===null?null:i.current.get(k)?.firstElementChild??null,L=S!==null&&S.getBoundingClientRect().bottom<=e.getBoundingClientRect().top+1;L!==p.current&&(p.current=L,f.current?.(L))},[e,t]),g=A(()=>{a.current&&s.request(h)},[s,h]);z(()=>{if(!r||!e||typeof IntersectionObserver>"u")return;let x=!0,b=new IntersectionObserver(()=>{!x||!a.current||g()},{root:e,rootMargin:`-${t}px 0px 0px 0px`,threshold:0});l.current=b;for(let I of i.current.values())b.observe(I);let T=new IntersectionObserver(()=>{!x||!a.current||g()},{root:e,threshold:0});m.current=T;for(let I of i.current.values())I.firstElementChild&&T.observe(I.firstElementChild);return g(),()=>{x=!1,b.disconnect(),l.current=null,T.disconnect(),m.current=null,s.cancel()}},[r,s,g,e,t]);let v=M(new Map),C=A(x=>{let b=v.current.get(x);if(b)return b;let T=I=>{let P=i.current.get(x);P&&P!==I&&(l.current?.unobserve(P),P.firstElementChild&&m.current?.unobserve(P.firstElementChild),i.current.delete(x)),I?(i.current.set(x,I),l.current?.observe(I),I.firstElementChild&&m.current?.observe(I.firstElementChild)):v.current.get(x)===T&&v.current.delete(x)};return v.current.set(x,T),T},[]),y=A(()=>{a.current&&(d.current=null,p.current=null,g())},[g]);return $(()=>({observeSection:C,refresh:y}),[C,y])}function vp(e,t){return e===t?!0:!e||!t?!1:e.identity===t.identity&&e.instanceId===t.instanceId&&e.driverKind===t.driverKind&&e.providerDisplayName===t.providerDisplayName&&e.accentColor===t.accentColor&&e.modelLabel===t.modelLabel&&e.effortLabel===t.effortLabel&&e.effortLevel===t.effortLevel}function p0(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function m0(e,t){return e.turnId===t.turnId&&e.createdAt===t.createdAt&&vp(e.badge,t.badge)}function g0(e,t){if(e===t)return!0;if(e.kind!==t.kind||e.id!==t.id)return!1;switch(e.kind){case"turn-identity":return m0(e,t);case"turn-summary":{let n=t;return e.createdAt===n.createdAt&&e.copyText===n.copyText&&e.cardAnchor===n.cardAnchor&&e.footer===n.footer&&(e.identity===void 0?n.identity===void 0:n.identity!==void 0&&m0(e.identity,n.identity))}case"tool-group":{let n=t;return e.createdAt===n.createdAt&&e.groupId===n.groupId&&p0(e.entries,n.entries)}case"working":{let n=t;return e.createdAt===n.createdAt&&e.turnId===n.turnId&&e.compacting===n.compacting&&vp(e.modelBadge,n.modelBadge)}case"model-switch":{let n=t;return e.createdAt===n.createdAt&&e.pending===n.pending&&vp(e.badge,n.badge)}case"proposed-plan":return e.proposedPlan===t.proposedPlan;case"turn-plan":{let n=t;return e.createdAt===n.createdAt&&e.turnPlan.plan===n.turnPlan.plan}case"work":{let n=t;return e.isExpandedToolGroupEntry===n.isExpandedToolGroupEntry&&e.isLastExpandedToolGroupEntry===n.isLastExpandedToolGroupEntry&&p0(e.groupedEntries,n.groupedEntries)}case"message":{let n=t;return e.message===n.message&&e.presentation===n.presentation&&e.textTone===n.textTone&&e.durationStart===n.durationStart&&e.showAssistantMeta===n.showAssistantMeta&&e.showAssistantCopyButton===n.showAssistantCopyButton&&e.copyInFooter===n.copyInFooter&&e.assistantCopyStreaming===n.assistantCopyStreaming&&vp(e.modelBadge,n.modelBadge)}}}function U3(e,t,n){for(let o=t;o<n;o+=1){let r=e[o];switch(r.kind){case"turn-identity":return r.turnId;case"working":return r.turnId??null;case"message":if(r.message.role==="assistant")return r.message.turnId;break;case"tool-group":if(r.entries[0]?.turnId!==void 0)return r.entries[0].turnId??null;break;case"work":if(r.groupedEntries[0]?.turnId!==void 0)return r.groupedEntries[0].turnId??null;break;case"turn-plan":return r.turnPlan.turnId;case"proposed-plan":return r.proposedPlan.turnId;case"turn-summary":return r.footer.turnId}}return null}function h0(e,t,n=[]){let o=new Map(n.map(a=>[a.key,a])),r=[];for(let a of t){if(a.end<=a.start)continue;let s=U3(e,a.start,a.end),i=o.get(a.key);if(i!==void 0&&i.turnId===s&&$3(i,e,a.start,a.end)){r.push(i);continue}r.push({key:a.key,turnId:s,firstRowIndex:a.start,rowIds:e.slice(a.start,a.end).map(l=>l.id)})}return r}function $3(e,t,n,o){if(e.firstRowIndex!==n||e.rowIds.length!==o-n)return!1;for(let r=0;r<e.rowIds.length;r+=1)if(e.rowIds[r]!==t[n+r].id)return!1;return!0}function v0(e,t){let n=Math.max(0,Math.min(t,e)),o=e-n;return{startIndex:o,hasHiddenOlder:o>0}}function si(e,t,n){let o=e.findIndex(r=>r.rowIds.includes(t));return o<0?n:Math.max(n,e.length-o)}function K3(e,t){let n=t.historyWindow,{status:o}=t,r={activities:t.activities,timelineEntries:t.timelineEntries,latestTurn:n?null:o.latestTurn,runningTurnId:n?null:o.runningTurnId,expandedTurnIds:t.expandedTurnIds,isWorking:!n&&o.isWorking,activeTurnStartedAt:n?null:o.activeTurnStartedAt,resolveModelBadge:t.resolveModelBadge,pendingModelSelection:n?null:o.pendingModelSelection},a=e.deriveGroups(r),s=o.latestTurn;if(n&&s&&s.completedAt!==null){let i=s.turnId;if(a.rows.some(d=>d.kind==="message"?d.message.role==="assistant"&&d.message.turnId===i:d.kind==="work"?d.groupedEntries.some(u=>u.turnId===i):d.kind==="tool-group"&&d.entries.some(u=>u.turnId===i)))return e.deriveGroups({...r,latestTurn:s})}return a}var V3=new Map,q3={markdown:()=>"",download(){}},W3=[],G3={latestTurn:null,latestAssistantMessageId:null,runningTurnId:null,isWorking:!1,workingStepLabel:null,stall:null,retry:null,activeTurnStartedAt:null,totalTurnCount:null,pendingModelSelection:null,scheduledWakes:W3},j3={inputs:null,structure:{rowIds:[],sections:[]},indexById:new Map,rows:[],meta:{status:G3,usageByTurnId:V3,exportApi:q3,finalAssistantMessageReceived:!1},version:0};function Q3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function X3(e,t,n,o){let r=K3(n,e),a=Y3(t.structure.rowIds,r.rows),s=a?t.indexById:new Map(r.rows.map((h,g)=>[h.id,g])),i=r.rows.map((h,g)=>{let v=a?t.rows[g]:t.rows[t.indexById.get(h.id)??-1],C=v!==void 0&&g0(v,h)?v:h;return C!==v&&o.add(h.id),C});if(!a)for(let h of t.indexById.keys())s.has(h)||o.add(h);let l=h0(i,r.turnGroups,t.structure.sections),d=a?t.structure.rowIds:i.map(h=>h.id),u=a&&Q3(t.structure.sections,l)?t.structure:{rowIds:d,sections:l},f=e.derive.hasSettledAssistantMessage(e.timelineEntries,e.status.latestAssistantMessageId),p=t.meta.status===e.status&&t.meta.usageByTurnId===e.usageByTurnId&&t.meta.exportApi===e.exportApi&&t.meta.finalAssistantMessageReceived===f?t.meta:{status:e.status,usageByTurnId:e.usageByTurnId,exportApi:e.exportApi,finalAssistantMessageReceived:f},m=o.size>0||u!==t.structure||p!==t.meta;return{inputs:e,structure:u,indexById:s,rows:i,meta:p,version:m?t.version+1:t.version}}function Y3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n].id)return!1;return!0}function gl(e){return e.getStructure().rowIds.some(t=>e.getRow(t)?.kind==="message")}function y0(){let e=null,t=null,n=j3,o=new Set,r=0,a=new Set,s=new Map,i=()=>{if(e===null||n.inputs===e)return n;t??=e.derive.createRowsCache();let l=new Set;n=X3(e,n,t,l);for(let d of l)o.add(d);return n};return{setInputs(l){e=l},hasInputs:()=>e!==null,flush(){if(a.size===0&&s.size===0||e===null)return;let{version:l}=i();if(l===r&&o.size===0)return;r=l;let d=[...o];o.clear();for(let u of d){let f=s.get(u);if(f!==void 0)for(let p of Array.from(f))p()}for(let u of Array.from(a))u()},subscribe(l){return a.add(l),()=>{a.delete(l)}},subscribeRow(l,d){let u=s.get(l);return u===void 0&&(u=new Set,s.set(l,u)),u.add(d),()=>{u.delete(d),u.size===0&&s.get(l)===u&&s.delete(l)}},getStructure:()=>i().structure,getRow(l){let{indexById:d,rows:u}=i(),f=d.get(l);return f===void 0?void 0:u[f]},getRows:()=>i().rows,getMeta:()=>i().meta,getVersion:()=>i().version}}X();function yp(e){return Fn(e.subscribe,e.getStructure,e.getStructure)}function C0(e,t){let n=A(r=>e.subscribeRow(t,r),[e,t]),o=A(()=>e.getRow(t),[e,t]);return Fn(n,o,o)}function In(e,t,n=Object.is){let o=M(null),r=A(()=>{let a=e.getVersion(),s=o.current;if(s!==null&&s.store===e&&s.select===t&&s.version===a)return s.value;let i=t(e),l=s!==null&&s.store===e&&n(s.value,i)?s.value:i;return o.current={store:e,select:t,version:a,value:l},l},[e,t,n]);return Fn(e.subscribe,r,r)}X();X();function J3(e,t){let n={hour:"numeric",minute:"2-digit",...t?{second:"2-digit"}:{}};return e==="locale"?n:{...n,hour12:e==="12-hour"}}function Z3(e){let t=e?.trim();if(t)try{return Intl.DateTimeFormat.supportedLocalesOf([t]),t}catch{return}}function eV(){return typeof window>"u"?null:window.desktopBridge?.getSystemLocale?.()??null}var Dv=Z3(eV()),x0=new Map;function b0(e,t){let n=`${e}:${t?"seconds":"minutes"}`,o=x0.get(n);if(o)return o;let r=new Intl.DateTimeFormat(Dv,J3(e,t));return x0.set(n,r),r}function Ov(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}var tV=new Intl.DateTimeFormat(void 0,{month:"long"});function nV(e){let t=e%100;if(t>=11&&t<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}function oV(e,t){let n=Ov(e);return n?b0(t,!1).format(n):""}function Or(e,t){let n=Ov(e);if(!n)return"";let o=oV(e,t),r=n.getDate(),a=tV.format(n),s=n.getFullYear();return`${o}, ${r}${nV(r)} ${a} ${s}`}var rV=new Intl.DateTimeFormat(Dv,{month:"numeric",day:"numeric"}),aV=new Intl.DateTimeFormat(Dv,{month:"numeric",day:"numeric",year:"numeric"});function pa(e,t,n,o=Date.now()){let r=Ov(e);if(!r)return"";let a=b0(t,!1).format(r),s=new Date(o),i=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),l=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),d=Math.round((i-l)/864e5);return d<=0?a:d===1?n("relativeTime.yesterdayAt",{time:a}):`${(r.getFullYear()===s.getFullYear()?rV:aV).format(r)} ${a}`}X();var St=dt(null),Cp=dt(null);X();var hl=new Map,S0=24,sV=4e3,iV=1024,w0=16384;function Fv(e){let t=hl.get(e);if(t)return t;let n={values:new Map,listeners:new Set,stringLength:0};if(hl.set(e,n),hl.size>S0){for(let[o,r]of hl)if(r.listeners.size===0&&o!==e&&(hl.delete(o),hl.size<=S0))break}return n}function Bv(e,t,n){return Fv(e).values.get(t)??n}function zc(e,t,n,o=!0){let r=Fv(e);if(typeof n=="string"&&(n=n.slice(0,iV)),r.values.get(t)===n)return;let a=r.values.get(t);if(typeof a=="string"&&(r.stringLength-=a.length),r.values.delete(t),r.values.set(t,n),typeof n=="string"&&(r.stringLength+=n.length),r.stringLength>w0){for(let[s,i]of r.values)if(!(typeof i!="string"||s===t)&&(r.values.delete(s),r.stringLength-=i.length,r.stringLength<=w0))break}if(r.values.size>sV){let s=r.values.keys().next().value;if(s!==void 0){let i=r.values.get(s);typeof i=="string"&&(r.stringLength-=i.length),r.values.delete(s)}}o&&r.listeners.forEach(s=>s())}function io(e,t,n){let o=A(i=>{let l=Fv(e);return l.listeners.add(i),()=>l.listeners.delete(i)},[e]),r=A(()=>Bv(e,t,n),[e,t,n]),a=Fn(o,r,r),s=A(i=>zc(e,t,i),[e,t]);return[a,s]}function je(){let e=wn().i18n.usePluginTranslation();return{t:(t,n)=>e(t,n)}}var I0=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api"];if(!I0)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{COMMUNICATION_RECORDS_READ_LIMIT:Wre,MAX_PLUGIN_SESSION_PROJECTION_BYTES:Gre,MAX_PLUGIN_SKILL_COMPANION_FILE_BYTES:jre,MAX_PLUGIN_SKILL_COMPANION_TOTAL_BYTES:Qre,MAX_PLUGIN_STREAM_BUFFER:Xre,MAX_PLUGIN_TOOL_PRESENTATION_BYTES:Yre,MAX_PLUGIN_WORKSPACE_WRITE_BYTES:Jre,MIN_PLUGIN_INTERVAL_MS:Zre,PLUGIN_API_MIN_VERSION:eae,PLUGIN_API_VERSION:tae,PLUGIN_PROXY_DIRECT:nae,PLUGIN_SESSION_PROJECTION_COMMAND:oae,REASONING_OPTION_LABEL:rae,REQUEST_RESOLVED_TRIGGER_KIND:aae,THREAD_ACTIVITIES_LIST_LIMIT:sae,THREAD_MESSAGES_LIST_LIMIT:iae,TOOL_LIFECYCLE_ACTIVITY_KINDS:lae,TURN_PROGRESS_TRIGGER_KIND:dae,USER_INPUT_PENDING_TRIGGER_KIND:cae,acceptPluginToolPresentation:uae,definePlugin:fae,effortText:T0,isThreadNotFound:pae,knownEffortLevel:mae,mergeLaunchEnv:gae,modelOptionLabelKind:k0,modelSelectionStringOption:hae,parseRetryAfterMs:vae,pluginJsonByteLength:yae,projectOrNull:Cae,readRequestResolved:xae,readThreadFailed:bae,readTurnProgress:Sae,readUserInputPending:wae,reasoningEffortLevel:Iae,reasoningEffortShortLabel:Tae,relabelModelOptionDescriptors:P0,threadMessagesNewestFirst:kae,threadOrNull:Pae}=I0;function xp(e,t,n){if(e!=="opencode"||t.length===0)return!1;let o=n?.trim();return o?!t.some(r=>r.slug===o):!1}function bp(e,t){if(e)return t?e:e.filter(n=>n.id!=="agent"||n.value!=="plan")}var L0={effort:"traits.savedOption.effort",reasoningEffort:"traits.savedOption.reasoningEffort",variant:"traits.savedOption.variant"},R0=e=>`traits.optionValue.${e}`;function lV(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function E0(e,t){if(t==="agent")return e("traits.savedOption.agent");let n=k0(t);return n===void 0?lV(t):e(L0[n])}function zv(e,t){return P0(t,{kind:n=>e(L0[n]),level:n=>e(R0(n))})}function Hv(e,t){return T0(t,n=>e(R0(n)))}function A0(e,t){return(e??[]).map(n=>typeof n.value=="boolean"?{id:n.id,label:t(n.id),type:"boolean",currentValue:n.value}:{id:n.id,label:t(n.id),type:"select",options:[{id:n.value,label:n.value}],currentValue:n.value})}function M0(e){return e==="failed"?"failed":e==="running"?"running":"idle"}function N0(e){return e.includes("failed")?"failed":e.includes("running")?"running":"idle"}var Sp="chat-process-row flex w-full min-w-0 select-none items-center gap-1.5 px-2 text-left";function Hc({children:e}){return c("span",{"aria-hidden":!0,className:"flex size-4 shrink-0 items-center justify-center",children:e})}function Uc({status:e}){return c("span",{"aria-hidden":!0,className:"flex size-2 shrink-0 items-center justify-center",children:e===null?null:c("span",{className:G("block size-2 rounded-full",e==="failed"?"bg-destructive":e==="success"?"bg-success":"border border-muted-foreground/60")})})}function wp({state:e,variant:t="inline",className:n,children:o}){return w("div",{"data-process-state":e,"data-process-kind":t,className:G("chat-process-shell relative min-w-0 overflow-hidden",t==="tool"?"rounded-lg bg-card":"rounded-md",n),children:[e==="running"?c("span",{"aria-hidden":!0,className:"chat-process-shell-pulse animate-status-pulse"}):null,o]})}X();X();var vl=class extends Error{reason;constructor(t,n,o){super(n,o),this.reason=t}};function dV(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.fontSize="16px";let n=document.activeElement;document.body.appendChild(t);try{return t.focus({preventScroll:!0}),t.select(),t.setSelectionRange(0,e.length),document.execCommand("copy")}catch{return!1}finally{t.remove();let o=n?.focus;typeof o=="function"&&o.call(n)}}async function cV(e,t){let n=()=>new vl("unavailable",`Clipboard API is unavailable while copying ${t}.`);if(typeof window>"u")throw n();if(!e)return!1;if(typeof navigator>"u"||!navigator.clipboard?.writeText){if(dV(e))return!0;throw n()}try{return await navigator.clipboard.writeText(e),!0}catch(o){throw new vl("write-failed",`Failed to copy ${t} to the clipboard.`,{cause:o})}}function Ip({timeout:e=2e3,target:t="text",onCopy:n,onError:o}={}){let[r,a]=j(!1),s=M(null),i=M(n),l=M(o),d=M(t),u=M(e);i.current=n,l.current=o,d.current=t,u.current=e;let f=A((p,m)=>{cV(p,d.current).then(h=>{h&&(s.current&&clearTimeout(s.current),a(!0),i.current?.(m),u.current!==0&&(s.current=setTimeout(()=>{a(!1),s.current=null},u.current)))},h=>{l.current?.(h instanceof Error?h:new Error(String(h)),m)})},[]);return z(()=>()=>{s.current&&clearTimeout(s.current)},[]),{copyToClipboard:f,isCopied:r}}var _0=1e3,uV={unavailable:"copyButton.clipboardUnavailable","write-failed":"copyButton.copyFailedDetail"};function fV({title:e,description:t}){return w("span",{role:"status",className:"dropdown-glass pointer-events-none fixed z-100 rounded-md px-2 py-1 text-pretty text-popover-foreground text-xs shadow-xl shadow-black/25",children:[e,t?c("span",{className:"block text-muted-foreground",children:t}):null]})}var Ja=fe(function({text:t,size:n="xs",variant:o="outline",className:r,toastAnchor:a="above",label:s}){let{t:i}=je(),l=s??i("copyButton.copyToClipboard"),d=M(null),[u,f]=j(null),p=M(null),m=(v,C)=>{let y=d.current?.getBoundingClientRect();y&&(p.current&&clearTimeout(p.current),f({top:a==="above"?Math.max(4,y.top-(C===void 0?26:40)):Math.min(window.innerHeight-26,y.bottom+4),left:Math.max(4,y.left+y.width/2),title:v,description:C}),p.current=setTimeout(()=>f(null),_0))};z(()=>()=>{p.current&&clearTimeout(p.current)},[]);let{copyToClipboard:h,isCopied:g}=Ip({onCopy:()=>m(i("copyButton.copied")),onError:v=>m(i("copyButton.failedToCopy"),v instanceof vl?i(uV[v.reason]):v.message),timeout:_0});return w(Ue,{children:[c(Ke,{render:c(re,{"aria-label":l,disabled:g,onClick:()=>h(t),ref:d,type:"button",size:n,variant:o,className:G("text-muted-foreground hover:text-foreground",r)}),children:g?c(Wn,{className:"size-3 text-primary"}):c(Ns,{className:"size-3"})}),c($e,{children:c("p",{children:l})}),u?c("span",{"aria-hidden":!0,className:"pointer-events-none fixed",style:{top:u.top,left:u.left},children:c("span",{className:"relative block -translate-x-1/2",children:c(fV,{title:u.title,description:u.description})})}):null]})});function Tp({text:e,label:t,children:n}){return w("span",{className:"group/hover-copy inline-flex min-w-0 items-center gap-0.5",children:[n,c("span",{className:"inline-flex opacity-0 transition-opacity duration-(--control-duration) pointer-events-none group-focus-within/hover-copy:pointer-events-auto group-focus-within/hover-copy:opacity-100 group-hover/hover-copy:pointer-events-auto group-hover/hover-copy:opacity-100 [@media(pointer:coarse)]:pointer-events-auto [@media(pointer:coarse)]:opacity-100",children:c(Ja,{text:e,label:t,variant:"ghost",size:"icon-xs",className:"shrink-0",toastAnchor:"below"})})]})}X();var pV=[".m4v",".mov",".mp4",".ogv",".webm"],mV=[".aac",".flac",".m4a",".mp3",".oga",".ogg",".opus",".wav",".weba"];function D0(e){let t=e.name.lastIndexOf(".");if(t<=0)return null;let n=e.name.slice(t).toLowerCase();return pV.includes(n)?"video":mV.includes(n)?"audio":null}var gV=["image/gif","image/jpeg","image/png","image/webp"],hV=new Set(gV);function Uv(e){return hV.has(e.toLowerCase())}function vV(e){return Uv(e)?"image":"file"}var yV=new Set(["application/json","application/xml","application/x-yaml","application/yaml"]),CV=[".doc",".docx",".odt",".ppt",".pptx",".odp",".xls",".xlsx",".ods"];function Fr(e){if(e.type==="image")return"image";let t=e.mimeType.toLowerCase();if(t==="image/svg+xml")return"svg";if(t==="application/pdf")return"pdf";let n=D0(e);if(n)return n;let o=e.name.lastIndexOf(".");return o>0&&CV.includes(e.name.slice(o).toLowerCase())?"office":t.startsWith("text/")||yV.has(t)?"text":"file"}function Za(e){let t=Fr(e);return t==="image"||t==="svg"}function es(e){return!Number.isFinite(e)||e<=0?"0 KB":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function $v(e){let t={id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes};return vV(e.mimeType)==="image"?{type:"image",...t}:{type:"file",...t,...e.source?{source:e.source}:{}}}function kp(e,t){let n=e.flatMap(r=>r.previewUrl?[{...r,src:r.previewUrl}]:[]);if(n.length===0)return null;let o=n.findIndex(r=>r.id===t);return o<0?null:{images:n.map(r=>({src:r.src,name:r.name,attachmentId:r.id,...r.source===void 0?{}:{source:r.source},...r.type!==void 0&&r.mimeType!==void 0&&Fr({type:r.type,mimeType:r.mimeType,name:r.name})==="svg"?{svg:!0}:{}})),index:o}}function Pp(e){switch(e){case"image":case"svg":return Xd;case"video":return Ha;case"audio":return tr;case"pdf":return $d;case"office":return Kd;case"text":return Ud;case"file":return Io}}function $c({images:e}){let t=et(St),{t:n}=je();return e.length===0?null:c("div",{className:"mb-2 grid max-w-[420px] grid-cols-2 gap-2",children:e.map(o=>c("div",{className:"overflow-hidden rounded-lg border border-border/80 bg-background/70",children:o.previewUrl?c("button",{type:"button",className:"h-full w-full cursor-zoom-in","data-attachment-action":"preview","data-attachment-name":o.name,"aria-label":n("attachments.preview",{name:o.name}),onClick:()=>{let r=kp(e,o.id);r&&t.onImageExpand(r)},children:c("img",{src:o.previewUrl,alt:o.name,loading:"lazy",decoding:"async",className:Fr(o)==="svg"?"block h-auto max-h-[220px] w-full bg-white object-contain":"block h-auto max-h-[220px] w-full object-cover object-top"})}):c("div",{className:"flex min-h-[72px] items-center justify-center px-2 py-3 text-center text-secondary-label text-chat-dense",children:o.name})},o.id))})}function Kc(e){let{t}=je(),n=et(St).onAttachmentDocumentOpen,o=Fr(e.attachment),r=Pp(o),a=t("attachments.open",{name:e.attachment.name}),s=w(he,{children:[c(r,{className:"size-4 shrink-0 text-secondary-label"}),w("span",{className:"min-w-0 flex-1",children:[c("span",{className:"block truncate font-medium text-foreground text-chat-row",children:e.attachment.name}),c("span",{className:"block text-secondary-label text-chat-meta",children:es(e.attachment.sizeBytes)})]})]});return e.attachment.previewUrl&&(o==="video"||o==="audio")?w("div",{className:"flex max-w-sm flex-col gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-2",children:[c("a",{href:e.attachment.previewUrl,target:"_blank",rel:"noreferrer","aria-label":a,className:"flex items-center gap-2 hover:underline",children:s}),c(bw,{kind:o,src:e.attachment.previewUrl,title:e.attachment.name})]}):(o==="pdf"||o==="office")&&n?c("button",{type:"button","data-attachment-action":"open","data-attachment-name":e.attachment.name,"aria-label":a,onClick:()=>n({attachmentId:e.attachment.id,name:e.attachment.name}),className:"flex w-full cursor-pointer items-center gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-2 text-start hover:bg-background/90",children:s}):e.attachment.previewUrl?c("a",{href:e.attachment.previewUrl,target:"_blank",rel:"noreferrer","aria-label":a,className:"flex items-center gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-2 hover:bg-background/90",children:s}):c("div",{className:"flex items-center gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-2",children:s})}X();X();var xV=Object.freeze([]),bV=()=>xV;function O0(e){return e.type==="file"&&e.source?._tag==="thread-reference"}function SV(e){return e.omitted===null?e.carried:w(he,{children:[c("span",{className:"inline-block max-w-full",children:`${e.carried} \xB7`})," ",c("span",{className:"inline-block max-w-full",children:e.omitted})]})}function F0(e){let t=et(St),{t:n}=je(),r=(t.threadReferences?.useDeliveries??bV)(t.activeThreadEnvironmentId,e).filter(a=>a.status!=="unreadable");return r.length===0?null:c("ul",{"aria-label":n("threadReference.listLabel"),className:"flex min-w-0 max-w-[min(70%,40rem)] flex-col gap-0.5 text-chat-dense text-muted-foreground",children:r.map(a=>w("li",{"data-thread-reference-delivery":a.status,className:"flex min-w-0 items-start gap-1",children:[c("span",{className:"flex h-lh shrink-0 items-center",children:c(ta,{"aria-hidden":"true",className:"size-3.5"})}),w("span",{className:"flex min-w-0 flex-1 flex-wrap gap-x-1",children:[c("span",{className:"max-w-max min-w-0 grow basis-24 truncate",children:n("threadReference.title",{title:a.reference.title})}),c("span",{className:"max-w-full",children:a.status==="carried"?c(SV,{carried:n("threadReference.carried",{count:a.carriedMessages}),omitted:a.omittedMessages>0?n("threadReference.omitted",{count:a.omittedMessages}):null}):a.status==="missing"?n("threadReference.missing"):n("threadReference.loading")})]})]},`${a.reference.environmentId}:${a.reference.threadId}`))})}X();function wV(e){let t=e.match(/:(\d+)$/);if(!t?.[1])return{path:e,line:void 0,column:void 0};let n=e.slice(0,-t[0].length),o=n.match(/:(\d+)$/);return o?.[1]?{path:n.slice(0,-o[0].length),line:o[1],column:t[1]}:{path:n,line:t[1],column:void 0}}function Kv(e){return e.replaceAll("\\","/")}function Vv(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function IV(e){return Vv(Kv(e.replace(/[\\/]+$/,"")))}function TV(e){return e.slice(e.lastIndexOf("/")+1)}function kV(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function PV(e){return e.startsWith("\\\\")||/^[A-Za-z]:([/\\]|$)/.test(Vv(Kv(e)))}function Lp(e,t){let{path:n,line:o,column:r}=wV(e),a=Vv(Kv(n)),s=a;if(t){let i=IV(t),l=TV(i),d=PV(t)?p=>p.toLowerCase():p=>p,u=d(a),f=d(i);if(u===f)s=l;else if(u.startsWith(`${f}/`))s=`${l}/${a.slice(i.length+1)}`;else if(!kV(a)){let p=a.replace(/^\.\/+/,"").replace(/^\/+/,"");s=u.startsWith(`${d(l)}/`)?a:`${l}/${p}`}}return o?`${s}:${o}${r?`:${r}`:""}`:s}var LV=/<review_comment\b([^>]*)>\s*([\s\S]*?)<\/review_comment>/g,RV=/([a-zA-Z][a-zA-Z0-9_-]*)="([^"]*)"/g,EV=/(`{3,})([^\s`]*)[^\n]*\n([\s\S]*?)\n\1/g;function AV(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function MV(e){let t={};for(let n of e.matchAll(RV))t[n[1]]=AV(n[2]??"");return t}function B0(e){return e===void 0||!/^\d+$/.test(e)?null:Number(e)}function NV(e){let n=Array.from(e.matchAll(EV)).at(-1),o=n?.index;return{text:e.slice(0,o??e.length).trim(),language:n?.[2]?.trim()||"diff",contents:n?.[3]??""}}function _V(e,t,n){let o=MV(e),r=B0(o.startIndex),a=B0(o.endIndex),s=o.filePath?.trim(),i=o.sectionId?.trim();if(!s||!i||r===null||a===null)return null;let l=NV(t);return{id:`review-comment:${n}:${i}:${s}:${r}:${a}`,sectionId:i,sectionTitle:o.sectionTitle?.trim()||null,filePath:s,startIndex:Math.min(r,a),endIndex:Math.max(r,a),rangeLabel:o.rangeLabel?.trim()||null,text:l.text,diff:l.contents,fenceLanguage:l.language}}function Rp(e){let t=[],n=0,o=0;for(let a of e.matchAll(LV)){let s=a.index??0,i=e.slice(n,s);i.length>0&&t.push({kind:"text",id:`review-comment-text:${n}`,text:i});let l=_V(a[1]??"",a[2]??"",o);l?(t.push({kind:"review-comment",comment:l}),o+=1):t.push({kind:"text",id:`review-comment-invalid:${s}`,text:a[0]}),n=s+a[0].length}let r=e.slice(n);return r.length>0&&t.push({kind:"text",id:`review-comment-text:${n}`,text:r}),t}function z0(e,t){let n=Math.max(0,...Array.from(t.matchAll(/`+/g),r=>r[0].length)),o="`".repeat(Math.max(3,n+1));return[`${o}${e}`,t.trimEnd(),o].join(`
4086
+ `;function OT(e){let[t,n]=j(""),[o,r]=j("all"),[a]=j(()=>ip(e.memoryScope)),s=M(a.camera!==null&&a.focusThreadId===e.focusThreadId),[i,l]=j(s.current?a.selectedId:null),[d,u]=j(s.current&&a.camera!==null?a.camera:{x:24,y:24,scale:1}),[f,p]=j({}),[m,h]=j(a.draft);z(()=>{Lv(e.memoryScope,{focusThreadId:e.focusThreadId,camera:d,selectedId:i,draft:m})},[e.memoryScope,e.focusThreadId,d,i,m]),z(()=>()=>Rv(e.memoryScope),[e.memoryScope]);let[g,v]=j(null),C=M(null),y=$(()=>e.board===null?null:bT(e.board,e.fuller),[e.board,e.fuller]),x=$(()=>{let S=new Map;if(y===null)return S;for(let L of y.threads)S.set(L.threadId,L);return S},[y]),b=$(()=>{if(y===null)return{cards:[],childCounts:new Map,descendantCounts:new Map};let S=yv(vv(y.threads),y.anchors);return uT(S,e.collapsed)},[y,e.collapsed]),T=b.cards.filter(S=>{let L=x.get(S.threadId);return L===void 0||o!=="all"&&L.projectId!==o?!1:t.trim().length===0?!0:`${L.title} ${S.question} ${S.answer}`.toLowerCase().includes(t.trim().toLowerCase())}),I=b.cards.find(S=>S.id===i)??T.find(S=>S.threadId===e.focusThreadId)??null,P=o==="all"?e.t("map.projectAll"):y?.projects.find(S=>S.projectId===o)?.title??e.t("map.projectAll"),k=e.focusThreadId!==null&&x.has(e.focusThreadId);return z(()=>{if(!k||e.focusThreadId===null||y===null)return;let S=yv(vv(y.threads),y.anchors),L=T3(S,e.focusThreadId,e.collapsed);if(L.length===e.collapsed.size&&L.every(E=>e.collapsed.has(E))||e.onCollapsed(L),s.current){s.current=!1;return}let _=S.findLast(E=>E.threadId===e.focusThreadId);_!==void 0&&l(_.id)},[e.focusThreadId,e.locateToken,k]),w("section",{ref:C,className:"ycodium-session-map","data-pane":e.fill==="pane"?"":void 0,"data-page":e.fill==="page"?"":void 0,children:[c("style",{children:lp}),w("header",{className:"session-map-bar",children:[w("div",{className:"session-map-title",children:[c("strong",{children:y?.workspaceTitle||e.t("map.title")}),c("span",{children:e.pending&&y===null?e.t("map.loading"):e.t("map.sessions",{count:y?.threads.length??0})})]}),w("div",{className:"session-map-actions",children:[e.viewSwitch,w("div",{className:"session-map-zoom",children:[c(re,{type:"button",size:"icon-xs",variant:"outline","aria-label":e.t("map.zoomOut"),onClick:()=>u(DT(d,1/1.15)),children:c(Fs,{})}),c("span",{children:e.t("map.zoom",{percent:Math.round(d.scale*100)})}),c(re,{type:"button",size:"icon-xs",variant:"outline","aria-label":e.t("map.zoomIn"),onClick:()=>u(DT(d,1.15)),children:c(sc,{})}),c(re,{type:"button",size:"xs",variant:"outline",onClick:()=>{let L=C.current?.querySelector(".session-map-stage")?.getBoundingClientRect(),R=y===null?[]:T.map(_=>Nc(_,y.positions,f));u(mT(R,L?.width??800,L?.height??600)),p({})},children:e.t("map.fit")})]}),c(re,{type:"button",size:"xs",variant:"outline",onClick:e.onLocate,children:e.t("map.locate")}),c(re,{type:"button",size:"xs",variant:"ghost",onClick:()=>{p({}),e.onTidy()},children:e.t("map.tidy")}),e.viewSwitch!=null||e.onClose===null?null:c(re,{type:"button",size:"xs",variant:"ghost",onClick:e.onClose,children:e.t("map.close")})]})]}),g===null?null:w("div",{className:"session-map-undo",children:[c("span",{children:e.t("map.hiddenNotice",{title:g.title})}),c(re,{type:"button",size:"xs",variant:"outline",onClick:()=>{e.onRestore(g.threadId),v(null)},children:e.t("map.undo")})]}),y===null?null:w("div",{className:"session-map-body",children:[w("aside",{className:"session-map-side",children:[c(rw,{className:"session-map-search",value:t,size:"sm",variant:"ghost","aria-label":e.t("map.search"),placeholder:e.t("map.search"),onValueChange:n}),w("div",{className:"session-map-actions",style:{marginTop:8},children:[c(re,{type:"button",size:"xs",onClick:()=>h({kind:"new"}),children:e.t("map.new")}),w(oa,{value:o,onValueChange:S=>r(S??"all"),children:[c(Ws,{size:"xs","aria-label":e.t("map.projectAll"),children:c(aa,{children:P})}),w(ra,{children:[c(or,{value:"all",children:e.t("map.projectAll")}),y.projects.map(S=>c(or,{value:S.projectId,children:S.title||S.workspaceRoot},S.projectId))]})]})]}),y.threads.length===0?c(qs,{title:e.t("map.empty")}):null,c(w3,{t:e.t,board:y,focusThreadId:e.focusThreadId,onOpen:S=>{let L=b.cards.findLast(R=>R.threadId===S);L!==void 0&&l(L.id),e.onOpenThread(S)}})]}),c(PT,{t:e.t,board:y,cards:T,childCounts:b.childCounts,descendantCounts:b.descendantCounts,collapsed:e.collapsed,focusThreadId:e.focusThreadId,selectedId:I?.id??null,optimistic:f,camera:d,resumeCamera:a.camera!==null&&a.focusThreadId===e.focusThreadId,locateToken:e.locateToken,onCamera:u,onSelect:S=>l(S.id),onMove:e.onMove,onOptimistic:(S,L,R)=>p(_=>({..._,[S]:{x:L,y:R}})),onToggleCollapse:S=>{let L=new Set(e.collapsed);L.has(S)?L.delete(S):L.add(S),e.onCollapsed([...L])},onContinue:S=>{l(S.id),h({kind:"continue",threadId:S.threadId})},onBranch:S=>{l(S.id),h({kind:"branch",threadId:S.threadId,messageId:S.messageId})},onHide:S=>{let L=x.get(S)?.title??e.t("settings.hiddenUntitled");v({threadId:S,title:L}),e.onHide(S)},onOpen:e.onOpenThread}),c(_T,{t:e.t,board:y,cards:b.cards,selected:I,detail:e.detail,detailThreadId:e.detailThreadId,phrases:e.phrases,draft:m,savedText:S=>{let L=ip(e.memoryScope);return L.textTarget===S?L.text:""},onText:(S,L)=>Lv(e.memoryScope,{textTarget:S,text:L}),onDraft:h,onPhrases:e.onPhrases,onAnchor:e.onAnchor,onLoadDetail:e.onLoadDetail,onOpen:e.onOpenThread,formatTime:e.formatTime,onSend:e.onSend})]})]})}function w3(e){let t=M(null),n=$(()=>I3(e.board,e.t),[e.board,e.t]),o=n.findIndex(r=>r.kind==="thread"&&r.thread.threadId===e.focusThreadId);return z(()=>{o<0||t.current?.scrollIndexIntoView({index:o,animated:!1})},[e.focusThreadId,o]),c("div",{className:"session-map-sessions",children:c(ep,{ref:t,data:n,estimatedItemSize:36,keyExtractor:r=>r.key,extraData:e.focusThreadId,style:{height:"100%"},renderItem:({item:r})=>r.kind==="header"?c("div",{className:"session-map-project",children:r.title}):c(aw,{className:"session-map-session",label:r.thread.title||e.t("card.empty"),pressed:r.thread.threadId===e.focusThreadId,trailing:r.thread.running?c("span",{className:"session-map-running",children:e.t("map.running")}):void 0,onClick:()=>e.onOpen(r.thread.threadId)})})})}function I3(e,t){let n=new Map;for(let s of e.threads){let i=n.get(s.projectId)??[];i.push(s),n.set(s.projectId,i)}let o=new Set(e.projects.map(s=>s.projectId)),r=[];for(let s of e.projects){let i=n.get(s.projectId)??[];if(i.length!==0){r.push({kind:"header",key:`project:${s.projectId}`,title:s.title||s.workspaceRoot});for(let l of i)r.push({kind:"thread",key:l.threadId,thread:l})}}let a=e.threads.filter(s=>!o.has(s.projectId));if(a.length>0){r.push({kind:"header",key:"project:none",title:t("map.ungrouped")});for(let s of a)r.push({kind:"thread",key:s.threadId,thread:s})}return r}function DT(e,t){let n=Math.min(4,Math.max(.25,e.scale*t));return{...e,scale:n}}function T3(e,t,n){return[...fT(e,t,n)]}var Ev="ycodium-session-map:phrases",Av="ycodium-session-map:collapsed",BT="ycodium-session-map:phrases",zT="ycodium-session-map:collapsed";function HT(e,t,n){let o=r=>{r.key===e&&n()};return window.addEventListener("storage",o),window.addEventListener(t,n),()=>{window.removeEventListener("storage",o),window.removeEventListener(t,n)}}var ri=[];function UT(){return GT(Ev)}function $T(e){jT(Ev,JSON.stringify(e)),window.dispatchEvent(new Event(BT))}function KT(e){return HT(Ev,BT,e)}function VT(){return GT(Av)}function qT(e){jT(Av,JSON.stringify(e)),window.dispatchEvent(new Event(zT))}function WT(e){return HT(Av,zT,e)}var FT=new Map;function GT(e){let t=P3(e),n=FT.get(e);if(n!==void 0&&n.raw===t)return n.value;let o=k3(t);return FT.set(e,{raw:t,value:o}),o}function k3(e){if(e===null)return ri;try{let t=JSON.parse(e);if(!Array.isArray(t))return ri;let n=t.filter(o=>typeof o=="string");return n.length===0?ri:n}catch{return ri}}function P3(e){try{return localStorage.getItem(e)}catch{return null}}function jT(e,t){try{localStorage.setItem(e,t)}catch{}}X();function dp(e){let[t,n]=j(()=>({data:e,board:bv(null,e)}));return t.data!==e&&n({data:e,board:bv(t.board,e)}),t.board}function cp(e){let t=Fn(KT,UT,()=>ri),n=Fn(WT,VT,()=>ri),o=$(()=>new Set(n),[n]),[r,a]=j(null),s=M(0),[i,l]=j(0),d=e.environmentId,u=e.threadId,f=d===null?{}:{environmentId:d},p=e.bridge.commands.useSubscription("live",{},f),m=e.bridge.commands.useSubscription("ycodium.sessionProjection",{name:"card",threadId:u!==null&&u.length>0?u:"_"},f),h=e.bridge.i18n.usePluginTranslation(),g=e.bridge.useFormatTimestamp(),v=dp(p.data);z(()=>{u===null||u.length===0||e.bridge.commands.invoke("focus",{threadId:u},f)},[u,d,e.bridge]);let C=u===null?null:ST(m.data);return c(OT,{t:h,board:v,pending:p.isPending,focusThreadId:u,fuller:C,detail:r?.view??null,detailThreadId:r?.threadId??null,phrases:_c(t),collapsed:o,fill:e.fill,locateToken:e.locateToken+i,memoryScope:d??"",viewSwitch:e.viewSwitch??null,formatTime:g,onClose:e.onClose,onOpenThread:y=>{d!==null&&e.bridge.openThread({environmentId:d,threadId:y})},onLocate:()=>l(y=>y+1),onPhrases:$T,onCollapsed:qT,onMove:(y,x,b)=>{e.bridge.commands.invoke("move",{cardId:y,x,y:b},f)},onTidy:()=>{e.bridge.commands.invoke("tidy",{},f)},onHide:y=>{e.bridge.commands.invoke("hide",{threadId:y},f)},onRestore:y=>{e.bridge.commands.invoke("restore",{threadId:y},f)},onAnchor:(y,x)=>{e.bridge.commands.invoke("preferences",{patch:{anchor:{threadId:y,cardId:x}}},f)},onLoadDetail:y=>{let x=s.current+1;s.current=x,e.bridge.commands.invoke("detail",{threadId:y},f).then(b=>{s.current===x&&a({threadId:y,view:wT(b)})})},onSend:async(y,x,b)=>{let T=IT(await L3(e.bridge,y,x,b,f));return T.ok&&T.walkedBack?e.bridge.notify(h("card.walkedBack"),"info"):T.ok&&e.bridge.notify(h("draft.sent"),"success"),T}})}async function L3(e,t,n,o,r){switch(t.kind){case"continue":return e.commands.invoke("send",{threadId:t.threadId,text:n},r);case"branch":return e.commands.invoke("fork",{threadId:t.threadId,messageId:t.messageId,text:n},r);case"new":return e.commands.invoke("create",{projectId:o,text:n},r);default:return t}}X();function rn(){return{t:wn().i18n.usePluginTranslation()}}function QT(e){if(e.cacheDisjoint!==!0)return null;let t=e.cachedInputTokens,n=e.inputTokens;if(t===void 0||n===void 0)return null;let o=t+n;if(o<=0)return null;if(t>=o)return"100%";let r=t/o*100;for(let a=0;a<=3;a+=1){let s=r.toFixed(a);if(Number.parseFloat(s)<100)return`${s}%`}return"99.9%"}function XT(e){let t,n,o,r=!0,a=!1;for(let s of e)s!==void 0&&(a=!0,s.cacheDisjoint!==!0&&(r=!1),s.outputTokens!==void 0&&(t=(t??0)+s.outputTokens),s.inputTokens!==void 0&&(n=(n??0)+s.inputTokens),s.cachedInputTokens!==void 0&&(o=(o??0)+s.cachedInputTokens));if(!(t===void 0&&n===void 0&&o===void 0))return{...a&&r?{cacheDisjoint:!0}:{},...t!==void 0?{outputTokens:t}:{},...n!==void 0?{inputTokens:n}:{},...o!==void 0?{cachedInputTokens:o}:{}}}function Dc(e){return e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}var R3=fe(function({item:t,ordinal:n,usage:o,onSelect:r}){return w("button",{type:"button","data-turn-navigator-row":t.sectionKey,onClick:()=>r(t),className:"flex w-full cursor-pointer items-start gap-2.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-accent",children:[c("span",{className:"shrink-0 pt-px font-mono text-[10px] text-muted-foreground tabular-nums",children:n}),w("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[c("span",{className:"line-clamp-2 min-w-0 font-medium text-chat leading-snug",children:t.userText}),t.assistantText?w("span",{className:"flex items-baseline gap-2",children:[c("span",{className:"line-clamp-1 min-w-0 flex-1 text-[11px] text-muted-foreground leading-snug",children:t.assistantText}),o?.outputTokens!==void 0?c("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground tabular-nums",children:Dc(o.outputTokens)}):null]}):null]})]})});function E3({totals:e}){let{t}=rn();if(!e)return null;let n=QT(e),o=[e.outputTokens===void 0?null:{label:t("turnNavigator.usageOutput"),value:Dc(e.outputTokens)},e.inputTokens===void 0?null:{label:t("turnNavigator.usageInput"),value:Dc(e.inputTokens)},e.cachedInputTokens===void 0?null:{label:t("turnNavigator.usageCacheRead"),value:n===null?Dc(e.cachedInputTokens):`${Dc(e.cachedInputTokens)} (${n})`}].filter(r=>r!==null);return o.length===0?null:w("div",{className:"flex items-baseline gap-2 border-t px-2 py-1.5",children:[c("span",{className:"flex-1 font-mono text-[10px] text-muted-foreground uppercase tracking-[0.14em]",children:t("turnNavigator.usage")}),o.map(r=>w("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:[r.label," ",r.value]},r.label))]})}var A3=fe(function({getText:t,size:n="xs",variant:o="outline",className:r}){let{t:a}=rn(),s=wn().writeClipboard,[i,l]=j(!1),d=a("turnNavigator.copyMarkdown");return w(Ue,{children:[c(Ke,{render:c(re,{"aria-label":d,disabled:i,onClick:()=>{s(t()).then(()=>{l(!0),window.setTimeout(()=>l(!1),1e3)})},type:"button",size:n,variant:o,className:G("text-muted-foreground hover:text-foreground",r)}),children:i?c(Wn,{className:"size-3 text-primary"}):c(Ns,{className:"size-3"})}),c($e,{children:c("p",{children:d})})]})});function YT({items:e,totalTurnCount:t,bottomInset:n,usageByTurnId:o,onSelect:r,exportMarkdown:a,onDownload:s,placement:i="float"}){let{t:l}=rn(),[d,u]=j(!1),f=$(()=>e.map((g,v)=>({item:g,ordinal:v+1})).reverse(),[e]),p=$(()=>XT(f.map(({item:g})=>g.turnId===null?void 0:o.get(g.turnId))),[f,o]);if(e.length===0)return null;let m=t??e.length,h=l("turnNavigator.open",{count:m});return w(Mr,{onOpenChange:u,open:d,children:[w(_r,{render:c(re,{"aria-label":h,className:G("gap-1.5 rounded-full px-3",i==="float"&&"absolute right-3 z-40"),"data-testid":"turn-navigator-pill",size:"xs",style:i==="float"?{bottom:n+12}:void 0,title:h,variant:"glass"}),children:[c(Zd,{"aria-hidden":!0}),c("span",{className:"font-mono font-semibold text-[11px] tabular-nums",children:m})]}),c(Nr,{align:"end",className:"w-80 flex-col",side:"top",children:w("div",{className:"flex max-h-[min(60vh,26rem)] flex-col",children:[w("div",{className:"flex items-center gap-1.5 border-b px-2 py-1.5",children:[c("span",{className:"flex-1 font-mono text-[10px] text-muted-foreground uppercase tracking-[0.14em]",children:l("turnNavigator.title")}),c("span",{className:"font-mono text-[10px] text-muted-foreground tabular-nums",children:m})]}),c("div",{className:G("min-h-0 flex-1 overflow-y-auto overflow-x-hidden p-1"),children:f.map(({item:g,ordinal:v})=>c(R3,{item:g,onSelect:C=>{u(!1),r(C)},ordinal:v,usage:g.turnId===null?void 0:o.get(g.turnId)},g.sectionKey))}),c(E3,{totals:p}),w("div",{className:"flex items-center gap-1 border-t px-2 py-1.5",children:[c("span",{className:"flex-1 font-mono text-[10px] text-muted-foreground uppercase tracking-[0.14em]",children:l("turnNavigator.export")}),c(A3,{size:"icon-xs",getText:a,variant:"ghost"}),c(re,{"aria-label":l("turnNavigator.downloadMarkdown"),onClick:()=>s("md"),size:"xs",title:l("turnNavigator.downloadMarkdown"),variant:"ghost",children:c("span",{className:"font-mono text-[10px]",children:".md"})}),c(re,{"aria-label":l("turnNavigator.downloadJson"),onClick:()=>s("json"),size:"xs",title:l("turnNavigator.downloadJson"),variant:"ghost",children:c("span",{className:"font-mono text-[10px]",children:".json"})})]})]})})]})}X();function Oc(e){return e.replace(/\s+/g," ")}function M3(e,t){let n=e.slice(Math.max(0,e.length-t));return/^[\uDC00-\uDFFF]/.test(n)&&(n=n.slice(1)),n}function N3(e,t){let n=e.slice(0,t);return/[\uD800-\uDBFF]$/.test(n)&&(n=n.slice(0,-1)),n}function up(e){let n=(e instanceof Element?e:e?.parentElement??null)?.closest("[data-assistant-quote-body]")??null;return n?.closest('[data-message-role="assistant"]')?n:null}function JT(e){if(!e||e.isCollapsed||e.rangeCount===0)return null;let t=e.getRangeAt(0),n=up(t.startContainer);if(n===null||up(t.endContainer)!==n)return null;let o=n.closest("[data-message-id]")?.dataset.messageId;if(!o)return null;let r=e.toString().trim();if(r.length===0)return null;let a=document.createRange();a.selectNodeContents(n),a.setEnd(t.startContainer,t.startOffset);let s=document.createRange();s.selectNodeContents(n),s.setStart(t.endContainer,t.endOffset);let i=Oc(t.toString()),l=i.length>i.trimStart().length?" ":"",d=i.length>i.trimEnd().length?" ":"",u=Oc(a.toString()+l),f=Oc(d+s.toString()),p=u.length,m=p+i.trim().length,h=t.getClientRects(),g=h[0]??t.getBoundingClientRect(),v=h[h.length-1]??g;return{messageId:o,text:r,start:p,end:m,prefix:M3(u,32),suffix:N3(f,32),anchor:{x:v.right,top:g.top,bottom:v.bottom}}}var fp="assistant-quote-inserter",pp="assistant-quote-open-comment";X();var e0=100,_3=new Map,ZT=new Map,mp=e=>typeof e=="function"?e():e,t0=(e,t)=>typeof t=="function"?t(e):t;function D3(e,t,n){let o=e.get(t);return o===void 0&&(o={values:new Map,limit:Math.max(1,n)},e.set(t,o)),o}function O3(e,t){let n=ZT.get(e);return n===void 0&&(n={values:new Map,limit:Math.max(1,t)},ZT.set(e,n)),n}function F3(e,t){if(!(e.values.size<=e.limit)){for(let[n,o]of e.values){if(e.values.size<=e.limit)return;o===t||o.committed||o.leases>0||(e.values.delete(n),o.alive=!1,o.subscribers.clear())}for(let[n,o]of e.values){if(e.values.size<=e.limit)return;o===t||o.leases>0||(e.values.delete(n),o.alive=!1,o.subscribers.clear())}}}function Mv(e,t,n){e.values.get(t)===n&&(e.values.delete(t),e.values.set(t,n))}function n0(e,t,n){let o=e.values.get(t);return o===void 0&&(o={value:mp(n),subscribers:new Set,leases:0,alive:!0,committed:!1},e.values.set(t,o)),o}function Fc(e){queueMicrotask(()=>F3(e))}function Mt(e,t,n,o=e0){let r=Math.max(1,o),a=D3(_3,e,r),s=n0(a,t,n),i=A(f=>s.alive?(a.limit=r,s.committed=!0,Mv(a,t,s),s.leases+=1,s.subscribers.add(f),Fc(a),()=>{s.subscribers.delete(f),s.leases=Math.max(0,s.leases-1),Fc(a)}):()=>{},[r,s,a,t]),l=A(()=>s.value,[s]),d=Fn(i,l,l),u=A(f=>{if(!s.alive||a.values.get(t)!==s)return;let p=s.value,m=t0(p,f);if(!Object.is(m,p)){s.value=m,Mv(a,t,s);for(let h of s.subscribers)h();Fc(a)}},[s,a,t]);return[d,u]}function o0(e,t){let n=M(null);(n.current===null||n.current.key!==e)&&(n.current={key:e,value:mp(t)});let[,o]=Jr(a=>a+1,0),r=A(a=>{let s=n.current;if(s===null||s.key!==e)return;let i=t0(s.value,a);Object.is(i,s.value)||(s.value=i,o())},[e]);return[n.current.value,r]}function at(e,t,n,o=e0){let r=Math.max(1,o),a=O3(e,r),s=n0(a,t,()=>({current:mp(n)}));return z(()=>{if(!(!s.alive||a.values.get(t)!==s))return a.limit=r,s.committed=!0,Mv(a,t,s),s.leases+=1,Fc(a),()=>{s.leases=Math.max(0,s.leases-1),Fc(a)}},[r,s,a,t]),s.value}function Ro(e,t){let n=M(null);return(n.current===null||n.current.key!==e)&&(n.current={key:e,ref:{current:mp(t)}}),n.current.ref}var B3=300;function r0(e){let{data:t,target:n,threadKey:o,surfaceRef:r}=e,{t:a}=le(),s=at(fp,o,null),[,i]=Mt(pp,o,null),[l,d]=j(null),u=M(null);if(z(()=>{let g,v=()=>{let I=r.current,P=document.getSelection(),k=P&&P.rangeCount>0?P.getRangeAt(0):null;if(!I||!k||!I.contains(k.commonAncestorContainer)){d(null);return}let S=JT(P);if(S===null){d(null);return}let L=t.assistantQuotes.serialize({version:1,environmentId:n.environmentId,threadId:n.threadId,messageId:S.messageId,text:S.text,start:S.start,end:S.end,prefix:S.prefix,suffix:S.suffix});d({source:L,...S.anchor})},C=I=>{u.current?.contains(I.target)||(clearTimeout(g),g=setTimeout(v,B3))},y=I=>{u.current?.contains(I.target)||(clearTimeout(g),d(null))},x=()=>d(null),b=I=>{I.key==="Escape"&&d(null)},T=()=>{(document.getSelection()?.isCollapsed??!0)&&d(null)};return document.addEventListener("pointerup",C,!0),document.addEventListener("keyup",C,!0),document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",b,!0),document.addEventListener("selectionchange",T),window.addEventListener("scroll",x,!0),()=>{clearTimeout(g),document.removeEventListener("pointerup",C,!0),document.removeEventListener("keyup",C,!0),document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",b,!0),document.removeEventListener("selectionchange",T),window.removeEventListener("scroll",x,!0)}},[t,r,n.environmentId,n.threadId]),l===null)return null;let f=l.source,p=Math.max(8,Math.min(window.innerWidth-200,l.x-12)),m=l.bottom+6,h=m+40<=window.innerHeight?m:Math.max(8,l.top-40);return c("div",{ref:u,className:"fixed z-50 rounded-control-3 bg-background",style:{left:p,top:h},"data-assistant-quote-toolbar":"",children:w(re,{size:"sm",variant:"outline",className:"shadow-md",disabled:f===null,title:f===null?a("timeline.quote.tooLong"):void 0,onMouseDown:g=>g.preventDefault(),onClick:()=>{f!==null&&s.current?.(f)===!0&&(i(f),document.getSelection()?.removeAllRanges(),d(null))},children:[c(na,{"aria-hidden":"true"}),a("timeline.quote.cite")]})})}X();X();function a0(e){let t=e.map(o=>({key:o.key,turnId:o.turnId,firstRowIndex:o.firstRowIndex,endRowIndex:o.firstRowIndex+o.rowIds.length})),n=new Map;for(let o of e)for(let[r,a]of o.rowIds.entries())n.set(a,{turnId:o.turnId,index:o.firstRowIndex+r});return{sections:t,bySectionKey:new Map(t.map(o=>[o.key,o])),byRowId:n}}function gp({index:e,visibleSectionKeys:t,protectedRowIds:n,selectionRows:o}){let r=t.flatMap(d=>{let u=e.bySectionKey.get(d)?.turnId;return u==null?[]:[u]}),a=n.flatMap(d=>{let u=e.byRowId.get(d)?.turnId;return u==null?[]:[u]}),s=o?e.byRowId.get(o.firstRowId)?.index:void 0,i=o?e.byRowId.get(o.lastRowId)?.index:void 0,l=s===void 0||i===void 0?[]:e.sections.flatMap(d=>d.turnId!==null&&d.endRowIndex>Math.min(s,i)&&d.firstRowIndex<=Math.max(s,i)?[d.turnId]:[]);return{firstTurnId:r[0]??null,lastTurnId:r.at(-1)??null,protectedTurnIds:[...new Set(a)],selectionTurnRange:l.length>0?{firstTurnId:l[0],lastTurnId:l.at(-1)}:null}}function s0(e,t,n,o){if(!o)return n;let r=e.findIndex(a=>t.has(a));return r<0?n:Math.max(n,e.length-r)}X();X();function Nv(e,t){for(let n of e.querySelectorAll("[data-timeline-row-id]"))if(n.dataset.timelineRowId===t)return n;return null}function ai(e,t){let n=0,o=e.length,r=-1;for(;n<o;){let a=Math.floor((n+o)/2),i=e[a].getBoundingClientRect();Math.max(i.bottom,i.top+1)>t?(r=a,o=a):n=a+1}return r}function z3(e){let t=e.getBoundingClientRect().top,n=e.querySelectorAll("[data-timeline-turn-section]"),o=a=>{let s=a.querySelectorAll("[data-timeline-row-id]"),i=ai(s,t),l=i<0?void 0:s[i],d=l?.dataset.timelineRowId;return!l||d===void 0?null:{rowId:d,offsetPx:Math.round(t-l.getBoundingClientRect().top)}};if(n.length===0)return o(e);let r=ai(n,t);if(r<0)return null;for(let a=r;a<n.length;a+=1){let s=o(n[a]);if(s)return s}return null}function i0(e,t){let n=0,o=e;for(;o&&o!==t;)n+=o.offsetTop,o=o.offsetParent;return n}var _v=class extends Xr{getSnapshotBeforeUpdate(t){return t.inputKey!==this.props.inputKey&&t.onBeforeInputChange(),null}componentDidUpdate(){}componentWillUnmount(){this.props.onBeforeInputChange()}render(){return this.props.children}};function l0({inputKey:e,onBeforeInputChange:t,handleRef:n,onAttach:o,className:r,children:a,onScroll:s,onInteractionRowsChange:i}){let l=M(null),d=M({inputKey:e,store:pc()});d.current.inputKey!==e&&(d.current={inputKey:e,store:pc()});let u=M(i);u.current=i;let f=A(m=>{let h=d.current;return h.store.acquire(m,()=>{d.current===h&&u.current?.(h.store.rows())})},[]);me(()=>{i?.(d.current.store.rows())},[e,i]),Bo(n,()=>({get node(){return l.current},measure:()=>{let m=l.current;return m?{scroll:m.scrollTop,scrollLength:m.clientHeight,contentLength:m.scrollHeight,topOf:h=>{let g=Nv(m,h);return g===null?null:i0(g,m)},heightOf:h=>{let g=Nv(m,h);return g===null?null:g.offsetHeight},rowAtScroll:()=>z3(m)}:null},scrollToEnd:m=>{let h=l.current;if(h){if(m?.animated){h.scrollTo({top:h.scrollHeight,behavior:"smooth"});return}h.scrollTop=h.scrollHeight-h.clientHeight}},scrollToRow:(m,h)=>{let g=l.current;if(!g)return!1;let v=Nv(g,m);return v?(g.scrollTop=Math.max(0,i0(v,g)-(h?.viewOffset??0)),!0):!1},scrollToOffset:m=>{let h=l.current;h&&(h.scrollTop=Math.max(0,m))}}),[]);let p=A(m=>{l.current=m,o(m)},[o]);return c(_v,{inputKey:e,onBeforeInputChange:t,children:c(fc,{value:f,children:c("div",{ref:p,className:r,style:{position:"relative"},onScroll:s,children:a})})})}function ml(e){if(!e)return!1;let t=e.tagName?.toLowerCase(),n=e.getAttribute?.("contenteditable");if(t==="textarea"||n==="true"||n===""||n==="plaintext-only"||"isContentEditable"in e&&e.isContentEditable===!0)return!0;if(t==="input"){let o=e.getAttribute?.("type")?.toLowerCase()??"text";if(!["button","submit","reset","image","checkbox","radio"].includes(o))return!0}return e.matches?.(":focus-visible")??!1}function pl(e,t){let o=(e?.nodeType===1?e:e?.parentElement)?.closest("[data-timeline-row-id]");return o&&t.contains(o)?o.dataset.timelineRowId??null:null}function hp(e){let t=e.ownerDocument.getSelection?.();if(!t||t.isCollapsed)return null;let n=null,o=null;for(let d=0;d<t.rangeCount;d+=1){let u=t.getRangeAt(d);u.intersectsNode(e)&&(n??=u,o=u)}if(!n||!o)return null;let r=pl(n.startContainer,e),a=pl(o.endContainer,e);if(r&&a)return{firstRowId:r,lastRowId:a};let s=e.querySelectorAll("[data-timeline-row-id]"),i=s[0]?.dataset.timelineRowId,l=s[s.length-1]?.dataset.timelineRowId;return i&&l?{firstRowId:r??i,lastRowId:a??l}:null}function Bc(e){let t=e.ownerDocument.getSelection?.();if(!t||t.isCollapsed)return!1;for(let n=0;n<t.rangeCount;n+=1)if(t.getRangeAt(n).intersectsNode(e))return!0;return!1}X();function Ya(e){let t=M(e);t.current=e;let n=M(!1),o=M(null),r=M(null),a=M(0),s=A(()=>{a.current+=1,r.current!==null&&cancelAnimationFrame(r.current),r.current=null},[]),i=A(()=>{if(!n.current||!t.current||r.current!==null||o.current===null)return;let u=++a.current;r.current=requestAnimationFrame(f=>{if(u!==a.current||(r.current=null,!n.current||!t.current))return;let p=o.current;o.current=null,p?.(f)})},[]),l=A(u=>{o.current=u,i()},[i]),d=A(()=>{o.current=null,s()},[s]);return me(()=>(n.current=!0,i(),()=>{n.current=!1,s()}),[e,s,i]),$(()=>({request:l,cancel:d}),[l,d])}function d0({root:e,inputKey:t,visible:n,index:o,topInset:r,bottomInset:a,interactionRows:s,onRangeChange:i,onSelectionChange:l}){let d=M({inputKey:t,visible:n,index:o,topInset:r,bottomInset:a,interactionRows:s,onRangeChange:i,onSelectionChange:l});d.current={inputKey:t,visible:n,index:o,topInset:r,bottomInset:a,interactionRows:s,onRangeChange:i,onSelectionChange:l};let u=Ya(n),f=M(null),p=A(()=>{let h=d.current;if(!e||!h.visible||e.clientHeight<=0)return;let g=e.getBoundingClientRect();if(g.height<=0)return;let v=g.top+h.topInset,C=g.bottom-h.bottomInset,y=e.querySelectorAll("[data-timeline-turn-section]"),x=ai(y,v),b=[];if(x>=0)for(let S=x;S<y.length;S+=1){let L=y[S];if(L.getBoundingClientRect().top>=C)break;L.dataset.timelineTurnSection!==void 0&&b.push(L.dataset.timelineTurnSection)}let T=[...h.interactionRows()],I=e.ownerDocument.activeElement;if(ml(I)){let S=pl(I,e);S&&T.push(S)}let P=gp({index:h.index,visibleSectionKeys:b,protectedRowIds:T,selectionRows:hp(e)}),k=`${h.inputKey}:${JSON.stringify(P)}`;k!==f.current&&(f.current=k,h.onRangeChange?.(P))},[e]),m=A(()=>u.request(p),[u,p]);return me(()=>{if(f.current=null,!n||!e)return;let h=t,g=!0,v=()=>{!g||d.current.inputKey!==h||!d.current.visible||(d.current.onSelectionChange(Bc(e)),m())};e.addEventListener("scroll",v,{passive:!0}),e.addEventListener("focusin",v),e.addEventListener("focusout",v),e.ownerDocument.addEventListener("selectionchange",v);let C=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return C?.observe(e),e.firstElementChild&&C?.observe(e.firstElementChild),v(),()=>{g=!1,u.cancel(),C?.disconnect(),e.removeEventListener("scroll",v),e.removeEventListener("focusin",v),e.removeEventListener("focusout",v),e.ownerDocument.removeEventListener("selectionchange",v),i?.(null)}},[u,t,i,m,e,n]),me(()=>{n&&m()},[o,m,n]),m}X();var c0=fe(function({sectionKey:t,rowKeyPrefix:n,rowIds:o,renderRow:r,sectionRef:a}){return c("div",{className:"session-turn","data-timeline-turn-section":t,ref:a,children:o.map(s=>c("div",{className:"transcript-col min-w-0 overflow-x-clip",children:r(s)},`${n}:${s}`))})});var H3=400;function u0({root:e,minimumCount:t,keepAbovePx:n=0,canCompact:o,onCompact:r}){let a=e.ownerDocument,s=new Set,i,l=!1,d=()=>e.scrollHeight-e.clientHeight-e.scrollTop<=2,u=()=>{if(i=void 0,a.hidden||s.size>0||!o()||e.clientHeight<=0||!d()||Bc(e))return;let b=e.querySelectorAll("[data-timeline-turn-section]"),T=e.getBoundingClientRect().top-32-n,I=0,P=Math.max(0,b.length-t);for(;I<P;){let S=Math.floor((I+P)/2),L=b[S].getBoundingClientRect().bottom;if(!Number.isFinite(L))return;L<=T?I=S+1:P=S}if(I===0)return;let k=a.activeElement;if(k&&ml(k)){for(let S=0;S<I;S+=1)if(b[S].contains(k))return}r(b.length-I)},f=!1,p=()=>{if(a.hidden||s.size>0||!o()||f){clearTimeout(i),i=void 0;return}i===void 0&&(i=setTimeout(u,H3))},m=()=>{clearTimeout(i),i=void 0,p()},h=()=>{let b=d();!b||!l?m():p(),l=b},g=b=>{s.add(b.pointerId),m()},v=b=>{s.delete(b.pointerId),m()},C=()=>{f=Bc(e),m()},y=()=>{s.clear(),m()},x=["wheel","keydown","focusin","focusout"];for(let b of x)e.addEventListener(b,m,{passive:!0});return e.addEventListener("scroll",h,{passive:!0}),e.addEventListener("pointerdown",g,!0),a.addEventListener("pointerup",v,!0),a.addEventListener("pointercancel",v,!0),a.addEventListener("selectionchange",C),a.addEventListener("visibilitychange",p),a.defaultView?.addEventListener("blur",y),p(),{schedule:p,disconnect:()=>{clearTimeout(i);for(let b of x)e.removeEventListener(b,m);e.removeEventListener("scroll",h),e.removeEventListener("pointerdown",g,!0),a.removeEventListener("pointerup",v,!0),a.removeEventListener("pointercancel",v,!0),a.removeEventListener("selectionchange",C),a.removeEventListener("visibilitychange",p),a.defaultView?.removeEventListener("blur",y)}}}X();function f0({root:e,topInsetPx:t,onActiveSectionChange:n,onActiveStartHiddenChange:o,active:r}){let a=M(r);a.current=r;let s=Ya(r),i=M(new Map),l=M(null),d=M(null),u=M(n);u.current=n;let f=M(o);f.current=o;let p=M(null),m=M(null),h=A(()=>{if(!a.current||!e)return;let x=e.scrollTop+t,b=null,T=Number.NEGATIVE_INFINITY,I=null,P=Number.POSITIVE_INFINITY;for(let[R,_]of i.current){if(!_.isConnected)continue;let E=_.offsetTop;E<P&&(P=E,I=R),E<=x&&E>=T&&(T=E,b=R)}let k=b??I;k!==d.current&&(d.current=k,u.current(k));let S=k===null?null:i.current.get(k)?.firstElementChild??null,L=S!==null&&S.getBoundingClientRect().bottom<=e.getBoundingClientRect().top+1;L!==p.current&&(p.current=L,f.current?.(L))},[e,t]),g=A(()=>{a.current&&s.request(h)},[s,h]);z(()=>{if(!r||!e||typeof IntersectionObserver>"u")return;let x=!0,b=new IntersectionObserver(()=>{!x||!a.current||g()},{root:e,rootMargin:`-${t}px 0px 0px 0px`,threshold:0});l.current=b;for(let I of i.current.values())b.observe(I);let T=new IntersectionObserver(()=>{!x||!a.current||g()},{root:e,threshold:0});m.current=T;for(let I of i.current.values())I.firstElementChild&&T.observe(I.firstElementChild);return g(),()=>{x=!1,b.disconnect(),l.current=null,T.disconnect(),m.current=null,s.cancel()}},[r,s,g,e,t]);let v=M(new Map),C=A(x=>{let b=v.current.get(x);if(b)return b;let T=I=>{let P=i.current.get(x);P&&P!==I&&(l.current?.unobserve(P),P.firstElementChild&&m.current?.unobserve(P.firstElementChild),i.current.delete(x)),I?(i.current.set(x,I),l.current?.observe(I),I.firstElementChild&&m.current?.observe(I.firstElementChild)):v.current.get(x)===T&&v.current.delete(x)};return v.current.set(x,T),T},[]),y=A(()=>{a.current&&(d.current=null,p.current=null,g())},[g]);return $(()=>({observeSection:C,refresh:y}),[C,y])}function vp(e,t){return e===t?!0:!e||!t?!1:e.identity===t.identity&&e.instanceId===t.instanceId&&e.driverKind===t.driverKind&&e.providerDisplayName===t.providerDisplayName&&e.accentColor===t.accentColor&&e.modelLabel===t.modelLabel&&e.effortLabel===t.effortLabel&&e.effortLevel===t.effortLevel}function p0(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function m0(e,t){return e.turnId===t.turnId&&e.createdAt===t.createdAt&&vp(e.badge,t.badge)}function g0(e,t){if(e===t)return!0;if(e.kind!==t.kind||e.id!==t.id)return!1;switch(e.kind){case"turn-identity":return m0(e,t);case"turn-summary":{let n=t;return e.createdAt===n.createdAt&&e.copyText===n.copyText&&e.cardAnchor===n.cardAnchor&&e.footer===n.footer&&(e.identity===void 0?n.identity===void 0:n.identity!==void 0&&m0(e.identity,n.identity))}case"tool-group":{let n=t;return e.createdAt===n.createdAt&&e.groupId===n.groupId&&p0(e.entries,n.entries)}case"working":{let n=t;return e.createdAt===n.createdAt&&e.turnId===n.turnId&&e.compacting===n.compacting&&vp(e.modelBadge,n.modelBadge)}case"model-switch":{let n=t;return e.createdAt===n.createdAt&&e.pending===n.pending&&vp(e.badge,n.badge)}case"proposed-plan":return e.proposedPlan===t.proposedPlan;case"turn-plan":{let n=t;return e.createdAt===n.createdAt&&e.turnPlan.plan===n.turnPlan.plan}case"work":{let n=t;return e.isExpandedToolGroupEntry===n.isExpandedToolGroupEntry&&e.isLastExpandedToolGroupEntry===n.isLastExpandedToolGroupEntry&&p0(e.groupedEntries,n.groupedEntries)}case"message":{let n=t;return e.message===n.message&&e.presentation===n.presentation&&e.textTone===n.textTone&&e.durationStart===n.durationStart&&e.showAssistantMeta===n.showAssistantMeta&&e.showAssistantCopyButton===n.showAssistantCopyButton&&e.copyInFooter===n.copyInFooter&&e.assistantCopyStreaming===n.assistantCopyStreaming&&vp(e.modelBadge,n.modelBadge)}}}function U3(e,t,n){for(let o=t;o<n;o+=1){let r=e[o];switch(r.kind){case"turn-identity":return r.turnId;case"working":return r.turnId??null;case"message":if(r.message.role==="assistant")return r.message.turnId;break;case"tool-group":if(r.entries[0]?.turnId!==void 0)return r.entries[0].turnId??null;break;case"work":if(r.groupedEntries[0]?.turnId!==void 0)return r.groupedEntries[0].turnId??null;break;case"turn-plan":return r.turnPlan.turnId;case"proposed-plan":return r.proposedPlan.turnId;case"turn-summary":return r.footer.turnId}}return null}function h0(e,t,n=[]){let o=new Map(n.map(a=>[a.key,a])),r=[];for(let a of t){if(a.end<=a.start)continue;let s=U3(e,a.start,a.end),i=o.get(a.key);if(i!==void 0&&i.turnId===s&&$3(i,e,a.start,a.end)){r.push(i);continue}r.push({key:a.key,turnId:s,firstRowIndex:a.start,rowIds:e.slice(a.start,a.end).map(l=>l.id)})}return r}function $3(e,t,n,o){if(e.firstRowIndex!==n||e.rowIds.length!==o-n)return!1;for(let r=0;r<e.rowIds.length;r+=1)if(e.rowIds[r]!==t[n+r].id)return!1;return!0}function v0(e,t){let n=Math.max(0,Math.min(t,e)),o=e-n;return{startIndex:o,hasHiddenOlder:o>0}}function si(e,t,n){let o=e.findIndex(r=>r.rowIds.includes(t));return o<0?n:Math.max(n,e.length-o)}function K3(e,t){let n=t.historyWindow,{status:o}=t,r={activities:t.activities,timelineEntries:t.timelineEntries,latestTurn:n?null:o.latestTurn,runningTurnId:n?null:o.runningTurnId,expandedTurnIds:t.expandedTurnIds,isWorking:!n&&o.isWorking,activeTurnStartedAt:n?null:o.activeTurnStartedAt,resolveModelBadge:t.resolveModelBadge,pendingModelSelection:n?null:o.pendingModelSelection},a=e.deriveGroups(r),s=o.latestTurn;if(n&&s&&s.completedAt!==null){let i=s.turnId;if(a.rows.some(d=>d.kind==="message"?d.message.role==="assistant"&&d.message.turnId===i:d.kind==="work"?d.groupedEntries.some(u=>u.turnId===i):d.kind==="tool-group"&&d.entries.some(u=>u.turnId===i)))return e.deriveGroups({...r,latestTurn:s})}return a}var V3=new Map,q3={markdown:()=>"",download(){}},W3=[],G3={latestTurn:null,latestAssistantMessageId:null,runningTurnId:null,isWorking:!1,workingStepLabel:null,stall:null,retry:null,activeTurnStartedAt:null,totalTurnCount:null,pendingModelSelection:null,scheduledWakes:W3},j3={inputs:null,structure:{rowIds:[],sections:[]},indexById:new Map,rows:[],meta:{status:G3,usageByTurnId:V3,exportApi:q3,finalAssistantMessageReceived:!1},version:0};function Q3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function X3(e,t,n,o){let r=K3(n,e),a=Y3(t.structure.rowIds,r.rows),s=a?t.indexById:new Map(r.rows.map((h,g)=>[h.id,g])),i=r.rows.map((h,g)=>{let v=a?t.rows[g]:t.rows[t.indexById.get(h.id)??-1],C=v!==void 0&&g0(v,h)?v:h;return C!==v&&o.add(h.id),C});if(!a)for(let h of t.indexById.keys())s.has(h)||o.add(h);let l=h0(i,r.turnGroups,t.structure.sections),d=a?t.structure.rowIds:i.map(h=>h.id),u=a&&Q3(t.structure.sections,l)?t.structure:{rowIds:d,sections:l},f=e.derive.hasSettledAssistantMessage(e.timelineEntries,e.status.latestAssistantMessageId),p=t.meta.status===e.status&&t.meta.usageByTurnId===e.usageByTurnId&&t.meta.exportApi===e.exportApi&&t.meta.finalAssistantMessageReceived===f?t.meta:{status:e.status,usageByTurnId:e.usageByTurnId,exportApi:e.exportApi,finalAssistantMessageReceived:f},m=o.size>0||u!==t.structure||p!==t.meta;return{inputs:e,structure:u,indexById:s,rows:i,meta:p,version:m?t.version+1:t.version}}function Y3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n].id)return!1;return!0}function gl(e){return e.getStructure().rowIds.some(t=>e.getRow(t)?.kind==="message")}function y0(){let e=null,t=null,n=j3,o=new Set,r=0,a=new Set,s=new Map,i=()=>{if(e===null||n.inputs===e)return n;t??=e.derive.createRowsCache();let l=new Set;n=X3(e,n,t,l);for(let d of l)o.add(d);return n};return{setInputs(l){e=l},hasInputs:()=>e!==null,flush(){if(a.size===0&&s.size===0||e===null)return;let{version:l}=i();if(l===r&&o.size===0)return;r=l;let d=[...o];o.clear();for(let u of d){let f=s.get(u);if(f!==void 0)for(let p of Array.from(f))p()}for(let u of Array.from(a))u()},subscribe(l){return a.add(l),()=>{a.delete(l)}},subscribeRow(l,d){let u=s.get(l);return u===void 0&&(u=new Set,s.set(l,u)),u.add(d),()=>{u.delete(d),u.size===0&&s.get(l)===u&&s.delete(l)}},getStructure:()=>i().structure,getRow(l){let{indexById:d,rows:u}=i(),f=d.get(l);return f===void 0?void 0:u[f]},getRows:()=>i().rows,getMeta:()=>i().meta,getVersion:()=>i().version}}X();function yp(e){return Fn(e.subscribe,e.getStructure,e.getStructure)}function C0(e,t){let n=A(r=>e.subscribeRow(t,r),[e,t]),o=A(()=>e.getRow(t),[e,t]);return Fn(n,o,o)}function In(e,t,n=Object.is){let o=M(null),r=A(()=>{let a=e.getVersion(),s=o.current;if(s!==null&&s.store===e&&s.select===t&&s.version===a)return s.value;let i=t(e),l=s!==null&&s.store===e&&n(s.value,i)?s.value:i;return o.current={store:e,select:t,version:a,value:l},l},[e,t,n]);return Fn(e.subscribe,r,r)}X();X();function J3(e,t){let n={hour:"numeric",minute:"2-digit",...t?{second:"2-digit"}:{}};return e==="locale"?n:{...n,hour12:e==="12-hour"}}function Z3(e){let t=e?.trim();if(t)try{return Intl.DateTimeFormat.supportedLocalesOf([t]),t}catch{return}}function eV(){return typeof window>"u"?null:window.desktopBridge?.getSystemLocale?.()??null}var Dv=Z3(eV()),x0=new Map;function b0(e,t){let n=`${e}:${t?"seconds":"minutes"}`,o=x0.get(n);if(o)return o;let r=new Intl.DateTimeFormat(Dv,J3(e,t));return x0.set(n,r),r}function Ov(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}var tV=new Intl.DateTimeFormat(void 0,{month:"long"});function nV(e){let t=e%100;if(t>=11&&t<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}function oV(e,t){let n=Ov(e);return n?b0(t,!1).format(n):""}function Or(e,t){let n=Ov(e);if(!n)return"";let o=oV(e,t),r=n.getDate(),a=tV.format(n),s=n.getFullYear();return`${o}, ${r}${nV(r)} ${a} ${s}`}var rV=new Intl.DateTimeFormat(Dv,{month:"numeric",day:"numeric"}),aV=new Intl.DateTimeFormat(Dv,{month:"numeric",day:"numeric",year:"numeric"});function pa(e,t,n,o=Date.now()){let r=Ov(e);if(!r)return"";let a=b0(t,!1).format(r),s=new Date(o),i=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),l=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),d=Math.round((i-l)/864e5);return d<=0?a:d===1?n("relativeTime.yesterdayAt",{time:a}):`${(r.getFullYear()===s.getFullYear()?rV:aV).format(r)} ${a}`}X();var St=dt(null),Cp=dt(null);X();var hl=new Map,S0=24,sV=4e3,iV=1024,w0=16384;function Fv(e){let t=hl.get(e);if(t)return t;let n={values:new Map,listeners:new Set,stringLength:0};if(hl.set(e,n),hl.size>S0){for(let[o,r]of hl)if(r.listeners.size===0&&o!==e&&(hl.delete(o),hl.size<=S0))break}return n}function Bv(e,t,n){return Fv(e).values.get(t)??n}function zc(e,t,n,o=!0){let r=Fv(e);if(typeof n=="string"&&(n=n.slice(0,iV)),r.values.get(t)===n)return;let a=r.values.get(t);if(typeof a=="string"&&(r.stringLength-=a.length),r.values.delete(t),r.values.set(t,n),typeof n=="string"&&(r.stringLength+=n.length),r.stringLength>w0){for(let[s,i]of r.values)if(!(typeof i!="string"||s===t)&&(r.values.delete(s),r.stringLength-=i.length,r.stringLength<=w0))break}if(r.values.size>sV){let s=r.values.keys().next().value;if(s!==void 0){let i=r.values.get(s);typeof i=="string"&&(r.stringLength-=i.length),r.values.delete(s)}}o&&r.listeners.forEach(s=>s())}function io(e,t,n){let o=A(i=>{let l=Fv(e);return l.listeners.add(i),()=>l.listeners.delete(i)},[e]),r=A(()=>Bv(e,t,n),[e,t,n]),a=Fn(o,r,r),s=A(i=>zc(e,t,i),[e,t]);return[a,s]}function je(){let e=wn().i18n.usePluginTranslation();return{t:(t,n)=>e(t,n)}}var I0=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api"];if(!I0)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{COMMUNICATION_RECORDS_READ_LIMIT:Wre,MAX_PLUGIN_SESSION_PROJECTION_BYTES:Gre,MAX_PLUGIN_SKILL_COMPANION_FILE_BYTES:jre,MAX_PLUGIN_SKILL_COMPANION_TOTAL_BYTES:Qre,MAX_PLUGIN_STREAM_BUFFER:Xre,MAX_PLUGIN_TOOL_PRESENTATION_BYTES:Yre,MAX_PLUGIN_WORKSPACE_WRITE_BYTES:Jre,MIN_PLUGIN_INTERVAL_MS:Zre,PLUGIN_API_MIN_VERSION:eae,PLUGIN_API_VERSION:tae,PLUGIN_PROXY_DIRECT:nae,PLUGIN_SESSION_PROJECTION_COMMAND:oae,REASONING_OPTION_LABEL:rae,REQUEST_RESOLVED_TRIGGER_KIND:aae,THREAD_ACTIVITIES_LIST_LIMIT:sae,THREAD_MESSAGES_LIST_LIMIT:iae,TOOL_LIFECYCLE_ACTIVITY_KINDS:lae,TURN_PROGRESS_TRIGGER_KIND:dae,USER_INPUT_PENDING_TRIGGER_KIND:cae,acceptPluginToolPresentation:uae,definePlugin:fae,effortText:T0,isThreadNotFound:pae,knownEffortLevel:mae,mergeLaunchEnv:gae,modelOptionLabelKind:k0,modelSelectionStringOption:hae,parseRetryAfterMs:vae,pluginJsonByteLength:yae,projectOrNull:Cae,readRequestResolved:xae,readThreadFailed:bae,readTurnProgress:Sae,readUserInputPending:wae,reasoningEffortLevel:Iae,reasoningEffortShortLabel:Tae,relabelModelOptionDescriptors:P0,threadMessagesNewestFirst:kae,threadOrNull:Pae}=I0;function xp(e,t,n){if(e!=="opencode"||t.length===0)return!1;let o=n?.trim();return o?!t.some(r=>r.slug===o):!1}function bp(e,t){if(e)return t?e:e.filter(n=>n.id!=="agent"||n.value!=="plan")}var L0={effort:"traits.savedOption.effort",reasoningEffort:"traits.savedOption.reasoningEffort",variant:"traits.savedOption.variant"},R0=e=>`traits.optionValue.${e}`;function lV(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function E0(e,t){if(t==="agent")return e("traits.savedOption.agent");let n=k0(t);return n===void 0?lV(t):e(L0[n])}function zv(e,t){return P0(t,{kind:n=>e(L0[n]),level:n=>e(R0(n))})}function Hv(e,t){return T0(t,n=>e(R0(n)))}function A0(e,t){return(e??[]).map(n=>typeof n.value=="boolean"?{id:n.id,label:t(n.id),type:"boolean",currentValue:n.value}:{id:n.id,label:t(n.id),type:"select",options:[{id:n.value,label:n.value}],currentValue:n.value})}function M0(e){return e==="failed"?"failed":e==="running"?"running":"idle"}function N0(e){return e.includes("failed")?"failed":e.includes("running")?"running":"idle"}var Sp="chat-process-row flex w-full min-w-0 select-none items-center gap-1.5 px-2 text-left";function Hc({children:e}){return c("span",{"aria-hidden":!0,className:"flex size-4 shrink-0 items-center justify-center",children:e})}function Uc({status:e}){return c("span",{"aria-hidden":!0,className:"flex size-2 shrink-0 items-center justify-center",children:e===null?null:c("span",{className:G("block size-2 rounded-full",e==="failed"?"bg-destructive":e==="success"?"bg-success":"border border-muted-foreground/60")})})}function wp({state:e,variant:t="inline",className:n,children:o}){return w("div",{"data-process-state":e,"data-process-kind":t,className:G("chat-process-shell relative min-w-0 overflow-hidden",t==="tool"?"rounded-lg bg-card":"rounded-md",n),children:[e==="running"?c("span",{"aria-hidden":!0,className:"chat-process-shell-pulse animate-status-pulse"}):null,o]})}X();X();var vl=class extends Error{reason;constructor(t,n,o){super(n,o),this.reason=t}};function dV(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.fontSize="16px";let n=document.activeElement;document.body.appendChild(t);try{return t.focus({preventScroll:!0}),t.select(),t.setSelectionRange(0,e.length),document.execCommand("copy")}catch{return!1}finally{t.remove();let o=n?.focus;typeof o=="function"&&o.call(n)}}async function cV(e,t){let n=()=>new vl("unavailable",`Clipboard API is unavailable while copying ${t}.`);if(typeof window>"u")throw n();if(!e)return!1;if(typeof navigator>"u"||!navigator.clipboard?.writeText){if(dV(e))return!0;throw n()}try{return await navigator.clipboard.writeText(e),!0}catch(o){throw new vl("write-failed",`Failed to copy ${t} to the clipboard.`,{cause:o})}}function Ip({timeout:e=2e3,target:t="text",onCopy:n,onError:o}={}){let[r,a]=j(!1),s=M(null),i=M(n),l=M(o),d=M(t),u=M(e);i.current=n,l.current=o,d.current=t,u.current=e;let f=A((p,m)=>{cV(p,d.current).then(h=>{h&&(s.current&&clearTimeout(s.current),a(!0),i.current?.(m),u.current!==0&&(s.current=setTimeout(()=>{a(!1),s.current=null},u.current)))},h=>{l.current?.(h instanceof Error?h:new Error(String(h)),m)})},[]);return z(()=>()=>{s.current&&clearTimeout(s.current)},[]),{copyToClipboard:f,isCopied:r}}var _0=1e3,uV={unavailable:"copyButton.clipboardUnavailable","write-failed":"copyButton.copyFailedDetail"};function fV({title:e,description:t}){return w("span",{role:"status",className:"dropdown-glass pointer-events-none fixed z-100 rounded-md px-2 py-1 text-pretty text-popover-foreground text-xs shadow-xl shadow-black/25",children:[e,t?c("span",{className:"block text-muted-foreground",children:t}):null]})}var Ja=fe(function({text:t,size:n="xs",variant:o="outline",className:r,toastAnchor:a="above",label:s}){let{t:i}=je(),l=s??i("copyButton.copyToClipboard"),d=M(null),[u,f]=j(null),p=M(null),m=(v,C)=>{let y=d.current?.getBoundingClientRect();y&&(p.current&&clearTimeout(p.current),f({top:a==="above"?Math.max(4,y.top-(C===void 0?26:40)):Math.min(window.innerHeight-26,y.bottom+4),left:Math.max(4,y.left+y.width/2),title:v,description:C}),p.current=setTimeout(()=>f(null),_0))};z(()=>()=>{p.current&&clearTimeout(p.current)},[]);let{copyToClipboard:h,isCopied:g}=Ip({onCopy:()=>m(i("copyButton.copied")),onError:v=>m(i("copyButton.failedToCopy"),v instanceof vl?i(uV[v.reason]):v.message),timeout:_0});return w(Ue,{children:[c(Ke,{render:c(re,{"aria-label":l,disabled:g,onClick:()=>h(t),ref:d,type:"button",size:n,variant:o,className:G("text-muted-foreground hover:text-foreground",r)}),children:g?c(Wn,{className:"size-3 text-primary"}):c(Ns,{className:"size-3"})}),c($e,{children:c("p",{children:l})}),u?c("span",{"aria-hidden":!0,className:"pointer-events-none fixed",style:{top:u.top,left:u.left},children:c("span",{className:"relative block -translate-x-1/2",children:c(fV,{title:u.title,description:u.description})})}):null]})});function Tp({text:e,label:t,children:n}){return w("span",{className:"group/hover-copy inline-flex min-w-0 items-center gap-0.5",children:[n,c("span",{className:"inline-flex opacity-0 transition-opacity duration-(--control-duration) pointer-events-none group-focus-within/hover-copy:pointer-events-auto group-focus-within/hover-copy:opacity-100 group-hover/hover-copy:pointer-events-auto group-hover/hover-copy:opacity-100 [@media(pointer:coarse)]:pointer-events-auto [@media(pointer:coarse)]:opacity-100",children:c(Ja,{text:e,label:t,variant:"ghost",size:"icon-xs",className:"shrink-0",toastAnchor:"below"})})]})}X();var pV=[".m4v",".mov",".mp4",".ogv",".webm"],mV=[".aac",".flac",".m4a",".mp3",".oga",".ogg",".opus",".wav",".weba"];function D0(e){let t=e.name.lastIndexOf(".");if(t<=0)return null;let n=e.name.slice(t).toLowerCase();return pV.includes(n)?"video":mV.includes(n)?"audio":null}var gV=["image/gif","image/jpeg","image/png","image/webp"],hV=new Set(gV);function Uv(e){return hV.has(e.toLowerCase())}function vV(e){return Uv(e)?"image":"file"}var yV=new Set(["application/json","application/xml","application/x-yaml","application/yaml"]),CV=[".doc",".docx",".odt",".ppt",".pptx",".odp",".xls",".xlsx",".ods"];function Fr(e){if(e.type==="image")return"image";let t=e.mimeType.toLowerCase();if(t==="image/svg+xml")return"svg";if(t==="application/pdf")return"pdf";let n=D0(e);if(n)return n;let o=e.name.lastIndexOf(".");return o>0&&CV.includes(e.name.slice(o).toLowerCase())?"office":t.startsWith("text/")||yV.has(t)?"text":"file"}function Za(e){let t=Fr(e);return t==="image"||t==="svg"}function es(e){return!Number.isFinite(e)||e<=0?"0 KB":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function $v(e){let t={id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes};return vV(e.mimeType)==="image"?{type:"image",...t}:{type:"file",...t,...e.source?{source:e.source}:{}}}function kp(e,t){let n=e.flatMap(r=>r.previewUrl?[{...r,src:r.previewUrl}]:[]);if(n.length===0)return null;let o=n.findIndex(r=>r.id===t);return o<0?null:{images:n.map(r=>({src:r.src,name:r.name,attachmentId:r.id,...r.source===void 0?{}:{source:r.source},...r.type!==void 0&&r.mimeType!==void 0&&Fr({type:r.type,mimeType:r.mimeType,name:r.name})==="svg"?{svg:!0}:{}})),index:o}}function Pp(e){switch(e){case"image":case"svg":return Xd;case"video":return Ha;case"audio":return tr;case"pdf":return $d;case"office":return Kd;case"text":return Ud;case"file":return Io}}function $c({images:e}){let t=et(St),{t:n}=je();return e.length===0?null:c("div",{className:"mb-2 grid max-w-[420px] grid-cols-2 gap-2",children:e.map(o=>c("div",{className:"overflow-hidden rounded-lg border border-border/80 bg-background/70",children:o.previewUrl?c("button",{type:"button",className:"h-full w-full cursor-zoom-in","data-attachment-action":"preview","data-attachment-name":o.name,"aria-label":n("attachments.preview",{name:o.name}),onClick:()=>{let r=kp(e,o.id);r&&t.onImageExpand(r)},children:c("img",{src:o.previewUrl,alt:o.name,loading:"lazy",decoding:"async",className:Fr(o)==="svg"?"block h-auto max-h-[220px] w-full bg-white object-contain":"block h-auto max-h-[220px] w-full object-cover object-top"})}):c("div",{className:"flex min-h-[72px] items-center justify-center px-2 py-3 text-center text-secondary-label text-chat-dense",children:o.name})},o.id))})}function Kc(e){let{t}=je(),n=et(St).onAttachmentDocumentOpen,o=Fr(e.attachment),r=Pp(o),a=t("attachments.open",{name:e.attachment.name}),s=w(he,{children:[c(r,{className:"size-4 shrink-0 text-secondary-label"}),w("span",{className:"min-w-0 flex-1",children:[c("span",{className:"block truncate font-medium text-foreground text-chat-row",children:e.attachment.name}),c("span",{className:"block text-secondary-label text-chat-meta",children:es(e.attachment.sizeBytes)})]})]});return e.attachment.previewUrl&&(o==="video"||o==="audio")?w("div",{className:"flex max-w-sm flex-col gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-2",children:[c("a",{href:e.attachment.previewUrl,target:"_blank",rel:"noreferrer","aria-label":a,className:"flex items-center gap-2 hover:underline",children:s}),c(bw,{kind:o,src:e.attachment.previewUrl,title:e.attachment.name})]}):(o==="pdf"||o==="office")&&n?c("button",{type:"button","data-attachment-action":"open","data-attachment-name":e.attachment.name,"aria-label":a,onClick:()=>n({attachmentId:e.attachment.id,name:e.attachment.name}),className:"flex w-full cursor-pointer items-center gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-2 text-start hover:bg-background/90",children:s}):e.attachment.previewUrl?c("a",{href:e.attachment.previewUrl,target:"_blank",rel:"noreferrer","aria-label":a,className:"flex items-center gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-2 hover:bg-background/90",children:s}):c("div",{className:"flex items-center gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-2",children:s})}X();X();var xV=Object.freeze([]),bV=()=>xV;function O0(e){return e.type==="file"&&e.source?._tag==="thread-reference"}function SV(e){return e.omitted===null?e.carried:w(he,{children:[c("span",{className:"inline-block max-w-full",children:`${e.carried} \xB7`})," ",c("span",{className:"inline-block max-w-full",children:e.omitted})]})}function F0(e){let t=et(St),{t:n}=je(),r=(t.threadReferences?.useDeliveries??bV)(t.activeThreadEnvironmentId,e).filter(a=>a.status!=="unreadable");return r.length===0?null:c("ul",{"aria-label":n("threadReference.listLabel"),className:"flex min-w-0 max-w-[min(70%,40rem)] flex-col gap-0.5 text-chat-dense text-muted-foreground",children:r.map(a=>w("li",{"data-thread-reference-delivery":a.status,className:"flex min-w-0 items-start gap-1",children:[c("span",{className:"flex h-lh shrink-0 items-center",children:c(ta,{"aria-hidden":"true",className:"size-3.5"})}),w("span",{className:"flex min-w-0 flex-1 flex-wrap gap-x-1",children:[c("span",{className:"max-w-max min-w-0 grow basis-24 truncate",children:n("threadReference.title",{title:a.reference.title})}),c("span",{className:"max-w-full",children:a.status==="carried"?c(SV,{carried:n("threadReference.carried",{count:a.carriedMessages}),omitted:a.omittedMessages>0?n("threadReference.omitted",{count:a.omittedMessages}):null}):a.status==="missing"?n("threadReference.missing"):n("threadReference.loading")})]})]},`${a.reference.environmentId}:${a.reference.threadId}`))})}X();function wV(e){let t=e.match(/:(\d+)$/);if(!t?.[1])return{path:e,line:void 0,column:void 0};let n=e.slice(0,-t[0].length),o=n.match(/:(\d+)$/);return o?.[1]?{path:n.slice(0,-o[0].length),line:o[1],column:t[1]}:{path:n,line:t[1],column:void 0}}function Kv(e){return e.replaceAll("\\","/")}function Vv(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function IV(e){return Vv(Kv(e.replace(/[\\/]+$/,"")))}function TV(e){return e.slice(e.lastIndexOf("/")+1)}function kV(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function PV(e){return e.startsWith("\\\\")||/^[A-Za-z]:([/\\]|$)/.test(Vv(Kv(e)))}function Lp(e,t){let{path:n,line:o,column:r}=wV(e),a=Vv(Kv(n)),s=a;if(t){let i=IV(t),l=TV(i),d=PV(t)?p=>p.toLowerCase():p=>p,u=d(a),f=d(i);if(u===f)s=l;else if(u.startsWith(`${f}/`))s=`${l}/${a.slice(i.length+1)}`;else if(!kV(a)){let p=a.replace(/^\.\/+/,"").replace(/^\/+/,"");s=u.startsWith(`${d(l)}/`)?a:`${l}/${p}`}}return o?`${s}:${o}${r?`:${r}`:""}`:s}var LV=/<review_comment\b([^>]*)>\s*([\s\S]*?)<\/review_comment>/g,RV=/([a-zA-Z][a-zA-Z0-9_-]*)="([^"]*)"/g,EV=/(`{3,})([^\s`]*)[^\n]*\n([\s\S]*?)\n\1/g;function AV(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function MV(e){let t={};for(let n of e.matchAll(RV))t[n[1]]=AV(n[2]??"");return t}function B0(e){return e===void 0||!/^\d+$/.test(e)?null:Number(e)}function NV(e){let n=Array.from(e.matchAll(EV)).at(-1),o=n?.index;return{text:e.slice(0,o??e.length).trim(),language:n?.[2]?.trim()||"diff",contents:n?.[3]??""}}function _V(e,t,n){let o=MV(e),r=B0(o.startIndex),a=B0(o.endIndex),s=o.filePath?.trim(),i=o.sectionId?.trim();if(!s||!i||r===null||a===null)return null;let l=NV(t);return{id:`review-comment:${n}:${i}:${s}:${r}:${a}`,sectionId:i,sectionTitle:o.sectionTitle?.trim()||null,filePath:s,startIndex:Math.min(r,a),endIndex:Math.max(r,a),rangeLabel:o.rangeLabel?.trim()||null,text:l.text,diff:l.contents,fenceLanguage:l.language}}function Rp(e){let t=[],n=0,o=0;for(let a of e.matchAll(LV)){let s=a.index??0,i=e.slice(n,s);i.length>0&&t.push({kind:"text",id:`review-comment-text:${n}`,text:i});let l=_V(a[1]??"",a[2]??"",o);l?(t.push({kind:"review-comment",comment:l}),o+=1):t.push({kind:"text",id:`review-comment-invalid:${s}`,text:a[0]}),n=s+a[0].length}let r=e.slice(n);return r.length>0&&t.push({kind:"text",id:`review-comment-text:${n}`,text:r}),t}function z0(e,t){let n=Math.max(0,...Array.from(t.matchAll(/`+/g),r=>r[0].length)),o="`".repeat(Math.max(3,n+1));return[`${o}${e}`,t.trimEnd(),o].join(`
4084
4087
  `)}function H0(e){if((e.fenceLanguage??"diff")!=="diff")return"";let t=e.diff.trim();if(t.length===0)return"";if(t.startsWith("diff --git "))return t;let n=e.filePath.replaceAll("\\","/");return[`diff --git a/${n} b/${n}`,`--- a/${n}`,`+++ b/${n}`,t].join(`
4085
4088
  `)}var Vc="[a-zA-Z][a-zA-Z0-9:_-]*";function yl(e){return e===" "||e===`
4086
4089
  `||e===" "||e==="\r"}function Cl(e){return e.enabled&&e.userInvocable!==!1}var $0="ycodium",U0=`${$0}:`,DV=new RegExp(String.raw`(^|\s)([$/])(${Vc})(?=\s|$)`,"g");function qv(e){return[...e.matchAll(DV)].map(t=>{let n=(t.index??0)+(t[1]?.length??0),o=t[3]??"";return{sigil:t[2],name:o,start:n,end:n+o.length+1}})}var mse=new RegExp(String.raw`([$/])(${Vc})(?=\s|$)`,"y");function K0(e,t){let n=t.get(e);if(n!==void 0)return n;if(!e.startsWith(U0))return;let o=t.get(e.slice(U0.length));return o?.scope===$0?o:void 0}function V0(e,t,n,o=yl){if(t.length!==e.length+1)return null;let r=0;for(;r<e.length&&e[r]===t[r];)r+=1;let a=t.charAt(r);if(!yl(a)||r<e.length&&o(e.charAt(r))||t.slice(r+1)!==e.slice(r))return null;let s=r;for(;s>0&&!o(t.charAt(s-1));)s-=1;let l=OV.exec(t.slice(s,r))?.[1];return l===void 0||K0(l,n)===void 0?null:{start:s,end:r+1,replacement:`$${l}${a}`}}var OV=new RegExp(String.raw`^/(${Vc})$`);function Ep(e){return new Map(e.map(t=>[t.name,t]))}function q0(e,t){return t.size===0?[]:qv(e).flatMap(n=>{let o=K0(n.name,t);return o===void 0?[]:[{...n,skill:o}]})}var FV="inline-flex h-[1.41em] max-w-full items-center gap-[0.33em] rounded-[0.5em] px-[0.5em] font-medium leading-none align-middle",BV=`${FV} border border-border/70 bg-accent/40 text-foreground`,Ap=`${BV} text-[12px]`,Mp="block size-[1.17em] shrink-0 self-center opacity-85 [&>svg]:block",Np="truncate leading-tight",W0='<svg width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>';var G0="inline-flex h-[1.41em] max-w-full items-center gap-[0.33em] rounded-[0.5em] px-[0.5em] font-medium leading-none align-middle",j0=`${G0} border border-border/70 bg-accent/40 text-foreground`,zV=`${j0} text-[12px]`,Vo=`${j0} text-[0.86em] select-none`,ir="relative inline-flex align-[-0.125em] leading-none data-[composer-chip-selected]:after:pointer-events-none data-[composer-chip-selected]:after:absolute data-[composer-chip-selected]:after:inset-0 data-[composer-chip-selected]:after:rounded-[6px] data-[composer-chip-selected]:after:bg-[Highlight] data-[composer-chip-selected]:after:opacity-30 data-[composer-chip-selected]:after:content-['']",lo="block size-[1.17em] shrink-0 self-center opacity-85 [&>svg]:block",Q0="truncate leading-tight",co="block self-center truncate leading-tight select-none",Wv="border-skill-chip-border bg-skill-chip text-skill-chip-foreground",X0=`${G0} select-none border ${Wv} text-[0.86em]`,Y0='<svg width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>',_p="ml-[0.17em] inline-flex size-[1.17em] shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground/72 transition-colors hover:bg-foreground/10 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring";function HV(e){return e.split(/[\s_-]+/).filter(t=>t.length>0).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function UV(e){let t=e.displayName?.trim();return t||HV(e.name)}function J0(e){let t=[],n=0;for(let o of q0(e.text,e.index))o.start>n&&t.push(e.text.slice(n,o.start)),t.push(c($V,{skill:o.skill,rawText:e.text.slice(o.start,o.end)},`${o.start}:${o.name}`)),n=o.end;return n===0?c(he,{children:e.text}):(n<e.text.length&&t.push(e.text.slice(n)),c(he,{children:t}))}function $V(e){return c("span",{className:"inline-flex align-middle leading-none","data-markdown-copy":e.rawText,children:w("span",{className:G(Ap,Wv),children:[c("span",{"aria-hidden":"true",className:Mp,dangerouslySetInnerHTML:{__html:W0}}),c("span",{className:Np,children:UV(e.skill)})]})})}function Z0(e){let{label:t,tooltipText:n,expired:o=!1}=e;return w(Ue,{children:[w(Ke,{render:c("span",{className:G(Ap,o&&"border-destructive/35 bg-destructive/8 text-destructive-foreground"),"data-terminal-context-expired":o?"true":void 0}),children:[c(To,{className:G(Mp,"size-icon-1",o&&"opacity-100")}),c("span",{className:Np,children:t})]}),c($e,{side:"top",className:"max-w-80 whitespace-pre-wrap leading-tight",children:n})]})}var KV=/\n*<element_context>\n([\s\S]*?)\n<\/element_context>\s*$/;function xl(e){let t=KV.exec(e);if(!t)return{promptText:e,contextCount:0,contexts:[]};let n=e.slice(0,t.index).replace(/\n+$/,""),o=VV(t[1]??"");return{promptText:n,contextCount:o.length,contexts:o}}function VV(e){let t=[],n=null,o=()=>{n&&(t.push({header:n.header,body:n.bodyLines.join(`
@@ -4100,7 +4103,7 @@ ${t.context.body}`:t.context.header;return w(Ue,{children:[w(Ke,{render:c("span"
4100
4103
  `)){let r=o.trim();if(!uq.test(r)){n.push(t?dq(o):o);continue}t=!r.startsWith("</")&&pq.test(r)}return n.join(`
4101
4104
  `).replace(cq,"")};var pk=`
4102
4105
  </preset-prefix>
4103
- ${dk}`,mq=new RegExp(`^${Bp}\\n<preset-prefix id="([^"]*)">\\n([\\s\\S]*?)\\n</preset-prefix>\\n${dk}(?:\\n\\n([\\s\\S]*))?$`),gq=e=>{if(e.split(pk).length!==2)return null;let t=mq.exec(e);if(t===null)return null;let[,n,o,r]=t;return n?{presetId:n,prefix:o??"",body:r??""}:null};var hq=new RegExp(`${ck}<plugin-instruction>\\n([\\s\\S]*?)\\n<\\/plugin-instruction>`);function mk(e){let t=e.match(hq)?.[1];if(t===void 0)return null;try{let n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return null;let o=n;return typeof o.pluginId!="string"||typeof o.title!="string"||typeof o.body!="string"?null:{pluginId:o.pluginId,title:o.title,body:o.body}}catch{return null}}function jv({row:e}){let t=et(St).derive;if(zp(e.message.text)){let n=t.parsePresetPrefixText(e.message.text);return n?w(he,{children:[c(vq,{parsed:n}),n.body.length>0||(e.message.attachments?.length??0)>0?c(jv,{row:{...e,message:{...e.message,text:n.body}}}):null]}):c(Cq,{row:e})}return c(lk,{row:e,text:e.message.text})}function Hp({children:e}){return c("div",{className:"flex justify-center py-1",children:c("div",{className:"max-w-[80%] rounded-lg border border-border/60 bg-muted/30 px-3 py-2 text-chat-row text-muted-foreground",children:e})})}function vq({parsed:e}){let{t}=je();return w(Hp,{children:[c("p",{className:"font-medium text-foreground/80",children:t("preset.systemBlockTitle",{name:e.presetId})}),e.prefix.trim().length>0?c("p",{className:"mt-1 whitespace-pre-wrap",children:e.prefix}):null]})}var yq={"child.settled":"childThread.notification.settled","child.failed":"childThread.notification.failed","child.approval":"childThread.notification.approval","child.question":"childThread.notification.question","child.stopped":"childThread.notification.stopped","plugin.notice":"childThread.notification.pluginNotice","selfdev.resolved":"childThread.notification.selfdevResolved"};function Cq({row:e}){let{t}=je(),n=wn(),{derive:o,activeThreadEnvironmentId:r}=et(St),a=e.message.attachments??[],s=a.filter(u=>Za(u)),i=a.filter(u=>!Za(u)),l=u=>{let f=mk(u);if(f)return w(Hp,{children:[c("p",{className:"font-medium text-foreground/80",children:f.title}),f.body.length>0?c("p",{className:"mt-1 whitespace-pre-wrap",children:f.body}):null]});let p=o.parseThreadHandoverText(u);if(p)return w(Hp,{children:[c("p",{className:"font-medium text-foreground/80",children:t("continuation.systemBlockTitle")}),c("p",{className:"mt-1",children:t("continuation.systemBlockTurns",{count:p.includedTurns})}),c("p",{className:"mt-1 whitespace-pre-wrap",children:p.body})]});let m=o.parseSystemNotificationText(u);if(!m)return null;let h=m.childThreadId&&m.kind!=="plugin.notice"&&m.kind!=="selfdev.resolved";return w(Hp,{children:[c("p",{className:"font-medium text-foreground/80",children:t(yq[m.kind],{title:m.title})}),m.summary.trim().length>0?c("p",{className:"mt-1 whitespace-pre-wrap",children:m.summary}):null,h?c(re,{type:"button",size:"xs",variant:"outline",className:"relative mt-2 pointer-coarse:after:absolute pointer-coarse:after:inset-0 pointer-coarse:after:min-h-11",onClick:()=>n.openThread({environmentId:r,threadId:m.childThreadId}),children:t("childThread.open")}):null]})},d=fk(e.message.text).map(l).filter(u=>u!==null);return d.length===0&&a.length===0?null:w(he,{children:[d.map((u,f)=>c(Yr,{children:u},f)),a.length>0?w("div",{className:"min-w-0 px-3 py-2",children:[c($c,{images:s}),i.map(u=>c(Kc,{attachment:u},u.id))]}):null]})}function gk(e,t){let n=t.parsePresetPrefixText(e??"")?.body??null;if(n===null&&zp(e??""))return null;let r=Dp(n??e??"").visibleText;for(;;){let i=Fp(r);if(!i.annotation)break;r=i.promptText}let a=xl(r).promptText,s=Rp(a).map(i=>i.kind==="text"?t.messageLinksToPreviewText(i.text):i.comment.text).join(" ").replace(/\s+/g," ").trim();return s.length>0?s:null}var hk=30,vk=8,Qv=hk+vk;function Xv(e){return`${e.ordinal}/${e.total}`}var yk=fe(function({ref:t,textRef:n,positionRef:o,initialHeader:r,onJump:a}){let{t:s}=je(),i=s("timeline.pinnedTurnHeaderJump");return c("div",{ref:t,className:"pointer-events-none absolute inset-x-0 top-0 z-10 px-3 data-[visible=false]:hidden sm:px-5","data-timeline-turn-header":"true","data-visible":"false",children:c("div",{className:"transcript-col-wide",style:{paddingTop:vk},children:w(re,{type:"button",variant:"outline",size:"sm",title:i,onClick:a,className:"pointer-events-auto w-full min-w-0 justify-start gap-2 bg-background px-2.5 text-xs font-normal text-muted-foreground shadow-xs hover:text-foreground",style:{height:hk},children:[c(_d,{"aria-hidden":!0,className:"size-icon-2 shrink-0"}),c("span",{className:"sr-only",children:i}),c("span",{ref:o,className:"shrink-0 tabular-nums",children:Xv(r)}),c("span",{ref:n,className:"min-w-0 flex-1 truncate text-left",children:r.text})]})})})});function Ck({row:e}){let t=et(St),{t:n}=je(),[o,r]=io(t.threadKey,`message:${e.message.id}`,!1);if(e.presentation==="compact"&&!o)return c(wp,{state:"idle",children:w("button",{type:"button",className:G(Sp,"chat-process-text cursor-pointer text-secondary-label hover:bg-accent/20"),"aria-expanded":!1,"aria-label":n("timeline.expandMessage"),onClick:()=>{t.onProcessDisclosureChange?.(e.id),r(!0)},children:[c(Uc,{status:null}),c(Hc,{children:c(na,{className:"size-icon-1","aria-hidden":!0})}),c("span",{className:"min-w-0 flex-1 truncate",children:t.derive.reasoningPreviewText(e.message.text)}),c(ln,{className:"size-icon-1 shrink-0 -rotate-90","aria-hidden":!0})]})});let s=e.message.attachments??[],i=s.filter(u=>Za(u)),l=s.filter(u=>!Za(u)),d=e.message.text||(e.message.streaming||s.length>0?"":n("timeline.emptyResponse"));return c(he,{children:w("div",{className:"relative min-w-0 px-1 py-0.5","data-assistant-text-tone":e.textTone==="process"&&e.presentation!=="compact"?"process":"primary",children:[e.presentation==="compact"?w("div",{className:"mb-1 flex items-center gap-2",children:[c("button",{type:"button",className:"chat-process-meta mb-1 rounded-sm text-secondary-label","aria-expanded":!0,onClick:()=>{t.onProcessDisclosureChange?.(e.id),r(!1)},children:n("timeline.collapseMessage")}),e.copyInFooter?null:c(Ja,{text:e.message.text,variant:"ghost"})]}):null,e.modelBadge?c(bq,{badge:e.modelBadge,createdAt:e.message.createdAt}):null,c("div",{"data-assistant-quote-body":"",children:c(Gn,{disclosureKey:`message:${e.message.id}:assistant`,text:d,className:e.textTone==="process"&&e.presentation!=="compact"?"chat-commentary":"chat-readable-body",cwd:t.markdownCwd,threadRef:t.threadRef??void 0,isStreaming:!!e.message.streaming,lineBreaks:t.derive.shouldPreserveAssistantLineBreaks(d),skills:t.skills,onImageExpand:t.onImageExpand,artifactTurnId:e.message.turnId})}),c($c,{images:i}),l.length>0&&c("div",{className:"mb-2 flex max-w-[420px] flex-col gap-1.5",children:l.map(u=>c(Kc,{attachment:u},u.id))}),e.showAssistantMeta||e.showAssistantCopyButton&&!e.assistantCopyStreaming&&e.message.text.trim().length>0?w("div",{className:"mt-1.5 flex select-none items-center gap-2 text-chat-row tabular-nums opacity-0 transition-opacity duration-(--control-duration) focus-within:opacity-100 group-hover/assistant:opacity-100 [@media(pointer:coarse)]:opacity-100",children:[c(xq,{row:e}),e.showAssistantMeta&&!e.message.streaming&&e.modelBadge===null&&w(Ue,{children:[c(Ke,{render:c("p",{className:"text-muted-foreground text-chat-row tabular-nums"}),children:pa(e.message.updatedAt,t.timestampFormat,n)}),c($e,{children:Or(e.message.updatedAt,t.timestampFormat)})]})]}):null]})})}function xq({row:e}){let n=et(St).derive.resolveAssistantMessageCopyState({text:e.message.text??null,showCopyButton:e.showAssistantCopyButton,streaming:e.assistantCopyStreaming});return n.visible?c(Ja,{text:n.text??"",variant:"ghost"}):null}function Yv({badge:e}){let{t}=je(),n=Hv(t,e);return w(he,{children:[e.driverKind?c("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg border border-border/60 bg-card","aria-label":e.providerDisplayName??void 0,children:c(nr,{driver:e.driverKind,displayName:e.providerDisplayName,accentColor:e.accentColor,className:"size-5",iconClassName:"size-4"})}):null,w("span",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[e.driverKind?c("span",{className:"font-medium text-foreground",children:e.providerDisplayName}):null,c(Tp,{text:e.modelLabel,label:t("copyButton.copyModelName"),children:c("span",{className:"min-w-0 truncate text-muted-foreground",children:e.modelLabel})}),n?w("span",{children:[" \xB7 ",n]}):null]})]})}function bq({badge:e,createdAt:t}){let n=et(St),{t:o}=je();return w("div",{className:"mb-3 flex min-w-0 select-none flex-wrap items-center gap-x-2.5 gap-y-1 text-chat-dense text-muted-foreground","data-testid":"assistant-model-header",children:[c(Yv,{badge:e}),c("span",{"aria-hidden":!0,children:"\xB7"}),w(Ue,{children:[c(Ke,{render:c("span",{className:"shrink-0 tabular-nums"}),children:pa(t,n.timestampFormat,o)}),c($e,{children:Or(t,n.timestampFormat)})]})]})}function xk({row:e}){let{t}=je(),n=Hv(t,e.badge),o=n?`${e.badge.modelLabel} \xB7 ${n}`:e.badge.modelLabel,r=[e.badge.providerDisplayName,o].filter(s=>typeof s=="string"&&s.length>0).join(" \xB7 "),a=e.pending?t("timeline.modelSwitchPending",{model:r}):t("timeline.modelSwitched",{model:r});return w("div",{role:"separator","aria-label":a,"data-pending":e.pending?"true":void 0,className:"flex items-center gap-2 px-1 py-1 text-chat-dense text-muted-foreground/70",children:[c("span",{"aria-hidden":!0,className:"h-px min-w-4 flex-1 bg-border/60"}),w("span",{className:"flex min-w-0 shrink items-center gap-1.5",children:[e.badge.driverKind?c(nr,{driver:e.badge.driverKind,displayName:e.badge.providerDisplayName,accentColor:e.badge.accentColor,className:"size-icon-1",iconClassName:"size-icon-1"}):null,c("span",{className:"truncate",children:a})]}),c("span",{"aria-hidden":!0,className:"h-px min-w-4 flex-1 bg-border/60"})]})}var Jv=240,Sq=/\s/u;function bk(e){if(!e)return null;let t=[],n=0,o=!1,r=()=>{for(;n>Jv-1;)n-=t.pop()?.length??0;for(;t.at(-1)===" ";)t.pop(),n-=1;return t.push("\u2026"),t.join("")};for(let a of e){if(Sq.test(a)){o=t.length>0;continue}if(o&&(t.push(" "),n+=1,o=!1,n>Jv)||(t.push(a),n+=a.length,n>Jv))return r()}return t.length>0?t.join(""):null}function wq(e,t,n){let o=t.find(s=>s.kind==="message"&&s.message.role==="user"),r=o?.kind==="message"?o.message:null,a=null;for(let s of t)s.kind==="message"&&s.message.role==="assistant"&&(a=s.message.text??null);return{id:e,sectionKey:e,anchorRowId:o?.id??t[0]?.id??e,userText:r===null?null:bk(n.parseSystemNotificationText(r.text)?.summary??n.parseThreadHandoverText(r.text)?.body??n.messageLinksToPreviewText(n.parsePresetPrefixText(r.text)?.body??r.text)),assistantText:bk(a),headerText:r===null?null:gk(r.text,n)}}function Iq(e){for(let t of e){let n=t.kind==="message"?t.message.turnId??null:t.kind==="turn-summary"?t.footer.turnId:null;if(n!==null)return n}return null}function Tq(e,t){return e.sectionKey===t.sectionKey&&e.anchorRowId===t.anchorRowId&&e.userText===t.userText&&e.assistantText===t.assistantText&&e.headerText===t.headerText&&e.turnId===t.turnId}function kq(e,t,n){for(let o=0;o<e.length;o+=1)if(e[o]!==n[t.firstRowIndex+o])return!1;return!0}function Pq(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function Lq(e){let t=new Map,n=null;return o=>{let r=o.getVersion();if(n!==null&&n.store===o&&n.version===r)return n.entries;let a=new Map,s=[],i=o.getRows();for(let d of o.getStructure().sections){let u=t.get(d.key);if(u!==void 0&&u.rowIds===d.rowIds&&kq(u.rows,d,i)){a.set(d.key,u),s.push(u.entry);continue}let f=i.slice(d.firstRowIndex,d.firstRowIndex+d.rowIds.length),p=wq(d.key,f,e),m={...p,turnId:Iq(f)},h=u!==void 0&&Tq(u.entry.item,m)?u.entry:{summary:p,item:m};a.set(d.key,{rowIds:d.rowIds,rows:f,entry:h}),s.push(h)}t=a;let l=n!==null&&Pq(n.entries,s)?n.entries:s;return n={store:o,version:r,entries:l},l}}var Sk=new WeakMap;function Tk(e,t){let n=Sk.get(e);return(n===void 0||n.derive!==t)&&(n={derive:t,read:Lq(t)},Sk.set(e,n)),n.read(e)}var wk=new WeakMap;function kk(e,t){let n=Tk(e,t),o=wk.get(n);if(o===void 0){let r=n.filter(({summary:s})=>s.userText!==null).length,a=0;o=n.flatMap(({summary:s})=>(s.userText!==null&&(a+=1),s.headerText===null?[]:[{sectionKey:s.sectionKey,text:s.headerText,anchorRowId:s.anchorRowId,ordinal:a,total:r}])),wk.set(n,o)}return o}function Pk(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>{let r=t[o];return n.sectionKey===r.sectionKey&&n.text===r.text&&n.anchorRowId===r.anchorRowId&&n.ordinal===r.ordinal&&n.total===r.total})}var Ik=new WeakMap;function Lk(e,t){let n=Tk(e,t),o=Ik.get(n);return o===void 0&&(o=n.filter(({summary:r})=>r.userText!==null).map(({item:r})=>r),Ik.set(n,o)),o}function Rk(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>n===t[o])}var Rq=[],Eq=e=>e.getMeta().usageByTurnId,Aq=e=>e.getMeta().exportApi,Mq=e=>e.getMeta().status.totalTurnCount??null,Ek=fe(function({rowsStore:t,derive:n,paneVisible:o,bottomInset:r,onSelect:a,onTurnNavigatorChange:s}){let i=A(m=>o?Lk(m,n):Rq,[n,o]),l=In(t,i,Rk),d=In(t,Eq),u=In(t,Aq),f=In(t,Mq),p=$(()=>o?{items:l,totalTurnCount:f,bottomInset:r,usageByTurnId:d,onSelect:a,exportMarkdown:u.markdown,onDownload:u.download}:null,[r,u,l,a,o,f,d]);return z(()=>{p!==null&&s(p)},[s,p]),z(()=>{if(o)return()=>s(null)},[s,o]),null});function Ak({timeline:e,previousOverlayHeight:t,overlayHeight:n,followingEnd:o}){e&&o&&n>t&&e.scrollToEnd({animated:!1})}function Mk(e,t){let n=e.topOf(t),o=e.heightOf(t);return typeof n!="number"||typeof o!="number"||!Number.isFinite(n)||!Number.isFinite(o)?null:n+Math.max(1,o)}function Nk({measurement:e,followingEnd:t}){return t?null:e.rowAtScroll()}function Up(e,t){let n=Array.from(e.querySelectorAll("[data-timeline-turn-section]")),o=n.findIndex(a=>a.querySelector(`[data-timeline-row-id="${CSS.escape(t)}"]`)),r=o<0?n:n.slice(0,o+1);for(let a of r)a.style.contentVisibility="visible";e.offsetHeight,requestAnimationFrame(()=>{for(let a of r)a.style.removeProperty("content-visibility")})}X();var Nq=e=>e.getMeta().status.workingStepLabel??null,_q=e=>e.getMeta().status.stall??null,Dq=e=>e.getMeta().status.retry??null,Oq=e=>e.getMeta().status.isWorking,_k=fe(function({rowsStore:t,historyWindow:n,children:o}){let r=In(t,Nq),a=In(t,_q),s=In(t,Dq),i=$(()=>n?{workingStepLabel:null,stall:null,retry:null}:{workingStepLabel:r,stall:a,retry:s},[n,s,a,r]);return c(Cp,{value:i,children:o})});function Dk({rowsStore:e,historyWindow:t}){let{t:n}=je();return In(e,Oq)&&!t?null:c("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:c("p",{className:"text-placeholder text-chat",children:n("timeline.empty")})})}X();function $p(e){return e==="loading"?"threadSync.loading":"threadSync.syncing"}var Fq=1e3,Kp=150;function Vp(e,t=Fq){let[n,o]=j(null);return z(()=>{if(e===null){o(null);return}let r=globalThis.setTimeout(()=>{o(e)},t);return()=>{globalThis.clearTimeout(r)}},[e,t]),n}var Bq=5;function Ok(e){let t=e.data.useThreadSyncPhase(e.target);return Vp(t,Kp)==="loading"?c(Zv,{}):e.hideEmptyPlaceholder?null:c(Dk,{rowsStore:e.rowsStore,historyWindow:e.historyWindow})}function Zv(){let{t:e}=le();return w("div",{className:"pointer-events-none absolute inset-0 overflow-hidden bg-background px-3 pt-4 sm:px-5","data-timeline-loading-skeleton":"",role:"status",children:[c("span",{className:"sr-only",children:e($p("loading"))}),c("div",{className:"transcript-col flex flex-col gap-6",children:Array.from({length:Bq},(t,n)=>w("div",{"aria-hidden":"true",className:"flex flex-col gap-3",children:[c("div",{className:"h-9 self-end rounded-[18px] bg-muted-foreground/15",style:{width:`${44-n%2*14}%`}}),[92,84,61].map((o,r)=>c("div",{className:"h-3 rounded-control-1 bg-muted-foreground/15",style:{width:`${o-n%3*6}%`}},r))]},n))})]})}var Fk=c("div",{className:"h-3 sm:h-4"}),Bk=c("div",{className:"h-10 sm:h-12"});function zk({loading:e,blocked:t,onLoadEarlier:n,fade:o}){let{t:r}=je();return c("div",{className:o?"pt-10 sm:pt-12":"pt-3 sm:pt-4",children:c("div",{className:"transcript-col pb-2",children:c("button",{type:"button","data-timeline-load-earlier":"",onClick:n,disabled:e||t,className:"relative w-full select-none py-1.5 text-chat-row text-muted-foreground/60 hover:text-foreground disabled:cursor-default pointer-coarse:after:absolute pointer-coarse:after:inset-0 pointer-coarse:after:min-h-11",children:r(e?"timeline.loadingEarlier":"timeline.loadEarlier")})})})}function Hk({loading:e,blocked:t,onLoadLater:n,onReturnToLatest:o}){let{t:r}=je();return w("div",{className:"transcript-col flex items-center justify-center gap-2 py-2",children:[c(re,{variant:"ghost",size:"sm",onClick:n,disabled:e||t,children:r(e?"timeline.loadingLater":"timeline.loadLater")}),o?c(re,{variant:"ghost",size:"sm",onClick:o,children:r("timeline.returnToLatest")}):null]})}function Uk({onReveal:e,fade:t}){let{t:n}=je();return c("div",{className:t?"pt-10 sm:pt-12":"pt-3 sm:pt-4",children:c("div",{className:"transcript-col pb-2",children:c("button",{type:"button","data-timeline-load-earlier":"",onClick:e,className:"relative w-full select-none py-1.5 text-chat-row text-muted-foreground/60 hover:text-foreground pointer-coarse:after:absolute pointer-coarse:after:inset-0 pointer-coarse:after:min-h-11",children:n("timeline.loadEarlier")})})})}var $k=c("div",{className:"h-3 sm:h-4"});X();var zq=Object.freeze([]),Kk=e=>e.getMeta().status.scheduledWakes??zq;function Vk(e,t){let n=M(e);return t&&(n.current=e),n.current}X();function qp(e){return JSON.stringify([e.turnId??null,e.toolCallId?"tool":"entry",e.toolCallId||e.id])}X();function lr(e){if(!Number.isFinite(e)||e<0)return"0ms";if(e<1e3)return`${Math.max(1,Math.round(e))}ms`;if(e<1e4){let s=Math.round(e/100)/10;return s>=10?"10s":`${s.toFixed(1)}s`}if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.round(e/1e3),n=Math.floor(t/3600),o=Math.floor(t%3600/60),r=t%60,a=[];return n>0&&a.push(`${n}h`),o>0&&a.push(`${o}m`),r>0&&a.push(`${r}s`),a.join(" ")}function qk({badge:e,startedAt:t,completedAt:n,timestampFormat:o}){let{t:r}=je();if(e===null&&t===void 0)return null;let a=r("timeline.turnInfo");return w(Mr,{children:[c(_r,{openOnHover:!0,delay:250,render:c(re,{type:"button",size:"icon-xs",variant:"ghost","data-turn-info":"","aria-label":a,className:"shrink-0 text-muted-foreground"}),children:c(Yd,{className:"size-3.5","aria-hidden":!0})}),c(Nr,{side:"top",align:"start",className:"max-w-80",children:w("div",{className:"flex flex-col gap-2 text-chat-dense",children:[e!==null?c("div",{className:"flex min-w-0 items-center gap-2",children:c(Yv,{badge:e})}):null,t!==void 0?c("div",{className:"text-muted-foreground tabular-nums",children:r("timeline.turnStarted",{time:Or(t,o)})}):null,n!==void 0?c("div",{className:"text-muted-foreground tabular-nums",children:r("timeline.turnFinished",{time:Or(n,o)})}):null]})})]})}function Hq(e){return e<1e3?Math.round(e).toLocaleString():e<1e6?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}function ey({label:e,children:t}){let[n,o]=j(!1);return w(Ue,{open:n,onOpenChange:o,children:[c(Ke,{render:c("button",{type:"button",className:"inline-flex items-center gap-1 rounded-sm"}),"aria-label":e,onClick:()=>o(r=>!r),children:t}),c($e,{children:e})]})}var Wk=fe(function({footer:t,timestampFormat:n,copyText:o,identity:r}){let{t:a}=je(),s=t.state,i=s==="error"?a("timeline.error"):s==="interrupted"?a("timeline.interrupted"):null;return w("div",{"data-turn-summary":t.turnId,className:"chat-process-meta flex min-w-0 select-none items-center gap-2 px-1 text-muted-foreground",children:[w("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[i!==null?w(ey,{label:i,children:[s==="error"?c(Kt,{className:"size-icon-1 text-destructive-foreground","aria-hidden":!0}):c(dc,{className:"size-3","aria-hidden":!0}),c("span",{className:"sr-only",children:i})]}):null,t.workingElapsedMs!==void 0?c(ey,{label:a("timeline.workingTime",{duration:lr(t.workingElapsedMs)}),children:lr(t.workingElapsedMs)}):null,t.workingElapsedMs!==void 0&&t.outputTokens!==void 0?c("span",{"aria-hidden":!0,children:"\xB7"}):null,t.outputTokens!==void 0?c(Tp,{text:String(t.outputTokens),label:a("copyButton.copyTokenCount"),children:c(ey,{label:`${a("timeline.outputTokens")}: ${t.outputTokens.toLocaleString()}`,children:a("timeline.outputTokenCount",{count:t.outputTokens,value:Hq(t.outputTokens)})})}):null]}),c(qk,{badge:r?.badge??null,startedAt:r?.createdAt,completedAt:t.completedAt,timestampFormat:n}),o?c(Ja,{text:o,variant:"ghost",size:"icon-xs",className:"shrink-0",toastAnchor:"below"}):null]})});X();function Uq(e){return e.toolLifecycleStatus==="interrupted"}function $q(e){let t=e?.stoppedByUser===!0;return e?.continuedAfterStop===!0?t?"toolGroup.interruptedByYouKeptRunning":"toolGroup.interruptedKeptRunning":e?.terminationConfirmed===!0?t?"toolGroup.interruptedByYou":"toolGroup.interrupted":t?"toolGroup.interruptedByYouMayStillRun":"toolGroup.interruptedMayStillRun"}function ty(e,t){if(!Uq(e))return null;let n=e.toolInterrupt,o=t($q(n)),r=[n?.durationMs===void 0?null:lr(n.durationMs),e.toolIo?.exitCode===void 0?null:t("toolGroup.exitCode",{code:e.toolIo.exitCode})].filter(a=>a!==null);return r.length===0?o:`${o} \xB7 ${r.join(" \xB7 ")}`}X();function Gk(e){if(e<1e3)return String(e);if(e<1e6){let n=e/1e3;return`${n<10?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}k`}if(e<1e9){let n=e/1e6;return`${n<10?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}m`}let t=e/1e9;return`${t<10?t.toFixed(1).replace(/\.0$/,""):Math.round(t)}b`}var jk=fe(function(t){let{additions:n,deletions:o,className:r,showParentheses:a=!1,layout:s="aligned"}=t,{t:i}=je(),l=new Intl.ListFormat(void 0,{type:"unit"}).format([i("changedFiles.additions",{count:n}),i("changedFiles.deletions",{count:o})]);return w(he,{children:[a&&c("span",{className:"text-muted-foreground/70",children:"("}),w("span",{role:"group","aria-label":l,className:G(s==="inline"?"inline-flex items-center gap-1 tabular-nums align-middle":"inline-grid grid-cols-[4ch_4ch] gap-2 text-right tabular-nums align-middle",r),children:[w("span",{"aria-hidden":"true",className:"font-mono text-diff-addition",children:["+",Gk(n)]}),w("span",{"aria-hidden":"true",className:"font-mono text-diff-deletion",children:["-",Gk(o)]})]}),a&&c("span",{className:"text-muted-foreground/70",children:")"})]})});function qc({name:e,className:t}){switch(e){case"bot":return c(As,{className:t,"aria-hidden":!0});case"check":return c(Wn,{className:t,"aria-hidden":!0});case"circle-alert":return c(Jt,{className:t,"aria-hidden":!0});case"eye":return c(Hd,{className:t,"aria-hidden":!0});case"globe":return c(Gd,{className:t,"aria-hidden":!0});case"hammer":return c(Qd,{className:t,"aria-hidden":!0});case"message-circle":return c(Ds,{className:t,"aria-hidden":!0});case"search":return c(Us,{className:t,"aria-hidden":!0});case"square-pen":return c(oo,{className:t,"aria-hidden":!0});case"terminal":return c(To,{className:t,"aria-hidden":!0});case"wrench":return c(uc,{className:t,"aria-hidden":!0});case"x":return c(Kt,{className:t,"aria-hidden":!0});case"zap":return c(Ks,{className:t,"aria-hidden":!0})}}function Kq(e){switch(e){case"read":return"eye";case"edit":return"square-pen";case"command":return"terminal";case"search":return"globe";case"code-search":return"search";case"other":return"wrench";case"dynamic-tool":return"hammer";case"agent-tool":return"bot";case"tone-tool":return"zap";case"mixed":case null:return"hammer"}}function ny(e,t){let n=new Map;for(let o of e){let r=t(o);n.set(r,(n.get(r)??0)+1)}return Array.from(n,([o,r])=>({action:o,icon:Kq(o),count:r}))}function oy(e,t){let n;for(let o of ny(e,t))(!n||o.count>n.count)&&(n=o);return n?.icon??"wrench"}function Qk(e){return typeof e.toolData=="object"&&e.toolData!==null&&!Array.isArray(e.toolData)?e.toolData:null}function Xk(e,t,n,o){if(t===void 0||n===void 0||n.length===0)return e;let r=e.trim();for(let a of[`mcp__ycodium__${t}`,`ycodium_${t}`,`ycodium ${t}`,t]){if(r===a)return n;if(!r.startsWith(`${a} `))continue;let s=r.slice(a.length).trim();return s.length===0?n:o!==void 0&&s.toLowerCase()==="started"?o(n):`${n} ${s}`}return e}var bl=20,Vq={failed:"toolGroup.showFailure",declined:"toolGroup.showDeclined",stopped:"toolGroup.showCancelled"};function Sl(e){return qp(e)}function Yk(e,t,n,o,r){let a=e.toolLabel,s=n.resolveToolCommand(e);if(s&&a?.descriptive&&!a.path&&a.detail?.trim())return a.detail.replace(/\s+/g," ").trim();for(let g of[e.rawCommand,e.command]){let v=n.parseToolCommandInput(g)?.description;if(v)return v.replace(/\s+/g," ").trim()}if(s)return s.replace(/\s+/g," ").trim();let i=Qk(e),l=typeof i?.toolName=="string"?i.toolName:typeof i?.name=="string"?i.name:void 0,d=e.builtinMcpTool||void 0,u=Xk(a?.name??l??e.toolTitle??e.label,d,d===void 0?void 0:o?.get(d),r),f=a?.path??e.changedFiles?.[0],p=f?Lp(f,t):void 0,m=[u.trim().toLowerCase()==="tool"?void 0:u,p,a?.detail??e.detail],h=[];for(let g of m){let v=g?.replace(/\s+/g," ").trim();v&&!h.some(C=>C.toLowerCase()===v.toLowerCase())&&h.push(v)}return h.join(" ")||null}function Jk({entry:e,presentation:t}){let n=e.toolLabel?.diffStat;return!n||t==="failed"||t==="declined"||t==="stopped"?null:c(jk,{...n,layout:"inline",className:"chat-process-meta ms-2 shrink-0"})}function Zk({toolIcon:e,glyphClassName:t}){let n=et(St),o=n.SiteIcon;return e.pageUrl!==void 0&&o!==void 0?c(o,{threadRef:n.threadRef,pageUrl:e.pageUrl,className:"size-3.5 shrink-0 rounded-sm object-contain"}):c(qc,{name:"globe",className:t})}function qq({entry:e,failed:t=!1,derive:n}){return t?c(Jt,{"aria-hidden":!0,className:"size-icon-1 shrink-0 text-destructive-foreground"}):e.toolIcon!==void 0?c(Zk,{toolIcon:e.toolIcon,glyphClassName:"size-icon-1 shrink-0 stroke-[1.8] text-muted-foreground opacity-70"}):c(qc,{name:oy([e],n.toolGroupAction),className:"size-icon-1 shrink-0 stroke-[1.8] text-muted-foreground opacity-70"})}function Wq({entries:e,failed:t,derive:n}){let{t:o}=je(),r=$(()=>ny(e,n.toolGroupAction),[e,n]),a=r.length===1;return a&&r[0].count<2?null:c("span",{className:"chat-process-meta flex shrink-0 items-center gap-2 tabular-nums","aria-label":o("toolGroup.calls",{count:e.length}),children:r.map(({action:s,icon:i,count:l})=>w("span",{"aria-hidden":!0,className:"flex items-center gap-1",children:[a?null:c(qc,{name:i,className:G("size-icon-1 shrink-0 stroke-[1.8] opacity-70",t?"text-destructive-foreground":"text-icon-muted")}),l]},s))})}function eP({entry:e}){let t=et(St),n=e.detail??e.command??e.rawCommand??e.toolLabel?.detail,o=JSON.stringify([e.id,e.sourceActivityKind,e.toolLifecycleStatus]),r=t.renderToolCallDetail?.({entry:e,threadRef:t.threadRef,threadKey:t.threadKey,workspaceRoot:t.workspaceRoot,revision:o,onOpenFileDiff:t.onOpenFileDiff});return c("div",{className:"min-w-0 space-y-2 p-3",children:r!==void 0?c(he,{children:r}):c("pre",{className:"chat-tool-body overflow-x-auto rounded-md bg-muted/40 p-2",children:n??""})})}var Gq=fe(function(t){let{entry:n,threadKey:o,workspaceRoot:r,onDisclosureChange:a}=t,s=et(St),i=s.derive,{t:l}=je(),[d,u]=io(o,`call:${Sl(n)}`,!1),f=i.toolPresentationStatus(n),p=f==="failed",m=f==="declined",h=f==="stopped",g=h?ty(n,l):null,v=i.resolveWorkEntryStatus(n),C=v==="failed"||v==="running"?v:null,y=Fo();return w("div",{"data-tool-call-id":n.toolCallId??n.id,"data-tool-identity":Sl(n),className:"border-b border-border/50 last:border-b-0",children:[w("button",{type:"button","aria-expanded":d,"aria-controls":y,onClick:()=>{a?.(),u(!d)},className:G("chat-tool-member-row chat-tool-summary flex w-full min-w-0 items-center gap-1.5 px-3 text-left hover:bg-accent/20",p?"text-destructive-foreground":"text-muted-foreground"),children:[c(Uc,{status:C}),c(Hc,{children:c(qq,{entry:n,failed:p,derive:i})}),w("span",{className:"flex min-w-0 flex-1 items-center",children:[c("span",{className:"truncate",children:Yk(n,r,i,s.declaredToolTitles,x=>l("toolGroup.declaredStarted",{title:x}))??l("toolGroup.calls",{count:1})}),c(Jk,{entry:n,presentation:f})]}),p||m||h?c("span",{className:"chat-process-meta shrink-0",children:p?l("toolGroup.failed",{count:1}):m?l("toolGroup.declined",{count:1}):g??l("toolGroup.cancelled",{count:1})}):null,c(ln,{"aria-hidden":!0,className:G("size-icon-1 shrink-0",!d&&"-rotate-90")})]}),d?c("div",{id:y,children:c(eP,{entry:n})}):null]})});function jq({threadKey:e,stateKey:t,maxHeight:n,children:o}){let r=M(null);return me(()=>{let a=r.current;if(!a)return;a.scrollTop=Bv(e,`${t}:scroll`,0);let s=()=>{zc(e,`${t}:scroll`,a.scrollTop,!1)};return a.addEventListener("scroll",s,{passive:!0}),()=>a.removeEventListener("scroll",s)},[e,t]),c("div",{ref:r,"data-slot":"scroll-area-viewport",className:"min-w-0 overflow-y-auto overscroll-y-contain",style:{maxHeight:n},children:o})}var tP=fe(function({entries:t,groupId:n,threadKey:o,workspaceRoot:r,onDisclosureChange:a}){let s=et(St),i=s.derive,{t:l}=je(),[d,u]=io(o,`group:${n}`,!1),[f,p]=io(o,`group-page:${n}`,0),m=Fo(),h=M(null),[g,v]=j(null),C=t.at(-1),{failedCount:y,declinedCount:x,stoppedCount:b,issue:T,runningCount:I}=$(()=>({...i.summarizeToolGroup(t),runningCount:t.filter(N=>i.toolPresentationStatus(N)==="running").length}),[t,i]),P=T?.entry??C,k=Math.max(0,Math.ceil(t.length/bl)-1),S=Math.min(f,k),L=S*bl,R=t.slice(L,L+bl),_=t.length>1;if(me(()=>{if(!g)return;let N=h.current,B=Array.from(N?.querySelectorAll("[data-tool-identity]")??[]).find(U=>U.dataset.toolIdentity===g.id);if(!B)return;let ue=B.closest('[data-slot="scroll-area-viewport"]');ue&&(ue.scrollTop+=B.getBoundingClientRect().top-ue.getBoundingClientRect().top),B.querySelector("button")?.focus({preventScroll:!0})},[g]),!C||!P)return null;let E=N=>{a?.(),p(N)},D={threadKey:o,workspaceRoot:r,onDisclosureChange:a},H=N0(t.map(N=>M0(i.resolveWorkEntryStatus(N)))),K=oy(t,i.toolGroupAction),O=_?null:ty(C,l),Z=H==="failed"?"failed":H==="running"?"running":x+b===t.length?null:"success";return c(wp,{state:H,variant:"tool",children:w("section",{ref:h,"data-tool-group-id":n,className:"min-w-0",children:[w("div",{className:"flex min-w-0 items-center",children:[w("button",{type:"button","aria-expanded":d,"aria-controls":m,onClick:()=>{a?.(),u(!d),!_&&!d&&zc(o,`call:${Sl(C)}`,!0)},className:G(Sp,"flex-1",y>0?"text-destructive-foreground":"text-muted-foreground"),children:[c(Uc,{status:Z}),c(Hc,{children:!_&&C.toolIcon!==void 0&&y===0?c(Zk,{toolIcon:C.toolIcon,glyphClassName:"size-icon-1 shrink-0 stroke-[1.8] opacity-70 text-icon-muted"}):c(qc,{name:K,className:G("size-icon-1 shrink-0 stroke-[1.8] opacity-70",y>0?"text-destructive-foreground":"text-icon-muted")})}),w("span",{className:G("flex min-w-0 flex-1 items-center",d&&_?"chat-process-text":"chat-tool-summary"),children:[c("span",{className:"truncate",children:d&&_?l("toolGroup.calls",{count:t.length}):Yk(P,r,i,s.declaredToolTitles,N=>l("toolGroup.declaredStarted",{title:N}))??l("toolGroup.calls",{count:1})}),d&&_?null:c(Jk,{entry:P,presentation:i.toolPresentationStatus(P)})]}),I>0?c("span",{className:"chat-process-meta shrink-0 tabular-nums",children:l("toolGroup.running",{count:I})}):null,y>0?c("span",{className:"chat-process-meta shrink-0 tabular-nums",children:l("toolGroup.failed",{count:y})}):null,x>0?c("span",{className:"chat-process-meta shrink-0 tabular-nums",children:l("toolGroup.declined",{count:x})}):null,b>0?c("span",{className:"chat-process-meta shrink-0 tabular-nums",children:l("toolGroup.cancelled",{count:b})}):null,d&&_?null:c(Wq,{entries:t,failed:y>0,derive:i}),c(ln,{"aria-hidden":!0,className:G("size-icon-1 shrink-0",!d&&"-rotate-90")})]}),T&&_?c("button",{type:"button",className:G("chat-process-meta me-2 min-h-8 shrink-0 rounded-control-4 px-1 underline [@media(pointer:coarse)]:min-h-11",T.kind==="failed"?"text-destructive-foreground":"text-muted-foreground"),onClick:()=>{a?.(),u(!0),p(Math.floor(t.indexOf(T.entry)/bl)),zc(o,`call:${Sl(T.entry)}`,!0),v({id:Sl(T.entry)})},children:l(Vq[T.kind])}):null]}),d?c("div",{id:m,className:"border-t border-border/50",children:_?w(he,{children:[t.length>bl?w("div",{className:"chat-process-meta flex items-center gap-1 border-b border-border/40 px-2 py-1 text-muted-foreground",children:[c("span",{className:"min-w-0 flex-1 tabular-nums",children:l("toolGroup.pageRange",{from:L+1,to:Math.min(L+bl,t.length),count:t.length})}),[{label:l("toolGroup.firstPage"),target:0,disabled:S===0,Icon:Bd},{label:l("toolGroup.previousPage"),target:S-1,disabled:S===0,Icon:Ms},{label:l("toolGroup.nextPage"),target:S+1,disabled:S===k,Icon:no},{label:l("toolGroup.lastPage"),target:k,disabled:S===k,Icon:zd}].map(({label:N,target:B,disabled:ue,Icon:U})=>c("button",{type:"button","aria-label":N,disabled:ue,onClick:()=>E(B),className:"flex size-7 items-center justify-center rounded-control-3 disabled:opacity-64 [@media(pointer:coarse)]:size-11",children:c(U,{"aria-hidden":!0,className:"size-icon-1"})},N))]}):null,c(jq,{threadKey:o,stateKey:`group-scroll:${n}:${S}`,maxHeight:"min(320px, 50dvh)",children:c("div",{className:"space-y-0.5 py-1",children:R.map(N=>c(Gq,{entry:N,...D},Sl(N)))})})]}):w(he,{children:[O?c("p",{className:"chat-process-meta px-3 pt-3 text-muted-foreground",children:c("span",{children:O})}):null,c(eP,{entry:C})]})}):null]})})});X();function nP(){let e=wn(),t=r=>r instanceof Error?r.message:void 0,n=(r,a)=>a!==void 0&&a.length>0?`${r}: ${a}`:r,o=(r,a,s)=>e.notify(r,a,s);return{error:(r,a,s)=>{let i=s?.description??t(a);o(n(r,i),"error",i)},warning:(r,a,s)=>{let i=s?.description??t(a);o(n(r,i),"warning",i)},success:(r,a,s)=>{let i=a??s?.description;o(n(r,i),"success",i)}}}function Wp(e){let t=e.match(/^\s{0,3}#{1,6}\s+(.+)$/m)?.[1]?.trim();return t&&t.length>0?t:null}function ry(e){let t=e.trimEnd().split(/\r?\n/),n=t[0]&&/^\s{0,3}#{1,6}\s+/.test(t[0])?t.slice(1):[...t];for(;n[0]?.trim().length===0;)n.shift();if(n[0]?.match(/^\s{0,3}#{1,6}\s+(.+)$/)?.[1]?.trim().toLowerCase()==="summary")for(n.shift();n[0]?.trim().length===0;)n.shift();return n.join(`
4106
+ ${dk}`,mq=new RegExp(`^${Bp}\\n<preset-prefix id="([^"]*)">\\n([\\s\\S]*?)\\n</preset-prefix>\\n${dk}(?:\\n\\n([\\s\\S]*))?$`),gq=e=>{if(e.split(pk).length!==2)return null;let t=mq.exec(e);if(t===null)return null;let[,n,o,r]=t;return n?{presetId:n,prefix:o??"",body:r??""}:null};var hq=new RegExp(`${ck}<plugin-instruction>\\n([\\s\\S]*?)\\n<\\/plugin-instruction>`);function mk(e){let t=e.match(hq)?.[1];if(t===void 0)return null;try{let n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return null;let o=n;return typeof o.pluginId!="string"||typeof o.title!="string"||typeof o.body!="string"?null:{pluginId:o.pluginId,title:o.title,body:o.body}}catch{return null}}function jv({row:e}){let t=et(St).derive;if(zp(e.message.text)){let n=t.parsePresetPrefixText(e.message.text);return n?w(he,{children:[c(vq,{parsed:n}),n.body.length>0||(e.message.attachments?.length??0)>0?c(jv,{row:{...e,message:{...e.message,text:n.body}}}):null]}):c(Cq,{row:e})}return c(lk,{row:e,text:e.message.text})}function Hp({children:e}){return c("div",{className:"flex justify-center py-1",children:c("div",{className:"max-w-[80%] rounded-lg border border-border/60 bg-muted/30 px-3 py-2 text-chat-row text-muted-foreground",children:e})})}function vq({parsed:e}){let{t}=je();return w(Hp,{children:[c("p",{className:"font-medium text-foreground/80",children:t("preset.systemBlockTitle",{name:e.presetId})}),e.prefix.trim().length>0?c("p",{className:"mt-1 whitespace-pre-wrap",children:e.prefix}):null]})}var yq={"child.settled":"childThread.notification.settled","child.failed":"childThread.notification.failed","child.approval":"childThread.notification.approval","child.question":"childThread.notification.question","child.stopped":"childThread.notification.stopped","plugin.notice":"childThread.notification.pluginNotice","selfdev.resolved":"childThread.notification.selfdevResolved"};function Cq({row:e}){let{t}=je(),n=wn(),{derive:o,activeThreadEnvironmentId:r}=et(St),a=e.message.attachments??[],s=a.filter(u=>Za(u)),i=a.filter(u=>!Za(u)),l=u=>{let f=mk(u);if(f)return w(Hp,{children:[c("p",{className:"font-medium text-foreground/80",children:f.title}),f.body.length>0?c("p",{className:"mt-1 whitespace-pre-wrap",children:f.body}):null]});let p=o.parseThreadHandoverText(u);if(p)return w(Hp,{children:[c("p",{className:"font-medium text-foreground/80",children:t("continuation.systemBlockTitle")}),c("p",{className:"mt-1",children:t("continuation.systemBlockTurns",{count:p.includedTurns})}),c("p",{className:"mt-1 whitespace-pre-wrap",children:p.body})]});let m=o.parseSystemNotificationText(u);if(!m)return null;let h=m.childThreadId&&m.kind!=="plugin.notice"&&m.kind!=="selfdev.resolved";return w(Hp,{children:[c("p",{className:"font-medium text-foreground/80",children:t(yq[m.kind],{title:m.title})}),m.summary.trim().length>0?c("p",{className:"mt-1 whitespace-pre-wrap",children:m.summary}):null,h?c(re,{type:"button",size:"xs",variant:"outline",className:"relative mt-2 pointer-coarse:after:absolute pointer-coarse:after:inset-0 pointer-coarse:after:min-h-11",onClick:()=>n.openThread({environmentId:r,threadId:m.childThreadId}),children:t("childThread.open")}):null]})},d=fk(e.message.text).map(l).filter(u=>u!==null);return d.length===0&&a.length===0?null:w(he,{children:[d.map((u,f)=>c(Yr,{children:u},f)),a.length>0?w("div",{className:"min-w-0 px-3 py-2",children:[c($c,{images:s}),i.map(u=>c(Kc,{attachment:u},u.id))]}):null]})}function gk(e,t){let n=t.parsePresetPrefixText(e??"")?.body??null;if(n===null&&zp(e??""))return null;let r=Dp(n??e??"").visibleText;for(;;){let i=Fp(r);if(!i.annotation)break;r=i.promptText}let a=xl(r).promptText,s=Rp(a).map(i=>i.kind==="text"?t.messageLinksToPreviewText(i.text):i.comment.text).join(" ").replace(/\s+/g," ").trim();return s.length>0?s:null}var hk=30,vk=8,Qv=hk+vk;function Xv(e){return`${e.ordinal}/${e.total}`}var yk=fe(function({ref:t,textRef:n,positionRef:o,initialHeader:r,onJump:a}){let{t:s}=je(),i=s("timeline.pinnedTurnHeaderJump");return c("div",{ref:t,className:"pointer-events-none absolute inset-x-0 top-0 z-10 px-3 data-[visible=false]:hidden sm:px-5","data-timeline-turn-header":"true","data-visible":"false",children:c("div",{className:"transcript-col-wide",style:{paddingTop:vk},children:c("div",{className:"rounded-control-3 bg-background",children:w(re,{type:"button",variant:"outline",size:"sm",title:i,onClick:a,className:"pointer-events-auto w-full min-w-0 justify-start gap-2 bg-background px-2.5 text-xs font-normal text-muted-foreground shadow-xs hover:text-foreground",style:{height:hk},children:[c(_d,{"aria-hidden":!0,className:"size-icon-2 shrink-0"}),c("span",{className:"sr-only",children:i}),c("span",{ref:o,className:"shrink-0 tabular-nums",children:Xv(r)}),c("span",{ref:n,className:"min-w-0 flex-1 truncate text-left",children:r.text})]})})})})});function Ck({row:e}){let t=et(St),{t:n}=je(),[o,r]=io(t.threadKey,`message:${e.message.id}`,!1);if(e.presentation==="compact"&&!o)return c(wp,{state:"idle",children:w("button",{type:"button",className:G(Sp,"chat-process-text cursor-pointer text-secondary-label hover:bg-accent/20"),"aria-expanded":!1,"aria-label":n("timeline.expandMessage"),onClick:()=>{t.onProcessDisclosureChange?.(e.id),r(!0)},children:[c(Uc,{status:null}),c(Hc,{children:c(na,{className:"size-icon-1","aria-hidden":!0})}),c("span",{className:"min-w-0 flex-1 truncate",children:t.derive.reasoningPreviewText(e.message.text)}),c(ln,{className:"size-icon-1 shrink-0 -rotate-90","aria-hidden":!0})]})});let s=e.message.attachments??[],i=s.filter(u=>Za(u)),l=s.filter(u=>!Za(u)),d=e.message.text||(e.message.streaming||s.length>0?"":n("timeline.emptyResponse"));return c(he,{children:w("div",{className:"relative min-w-0 px-1 py-0.5","data-assistant-text-tone":e.textTone==="process"&&e.presentation!=="compact"?"process":"primary",children:[e.presentation==="compact"?w("div",{className:"mb-1 flex items-center gap-2",children:[c("button",{type:"button",className:"chat-process-meta mb-1 rounded-sm text-secondary-label","aria-expanded":!0,onClick:()=>{t.onProcessDisclosureChange?.(e.id),r(!1)},children:n("timeline.collapseMessage")}),e.copyInFooter?null:c(Ja,{text:e.message.text,variant:"ghost"})]}):null,e.modelBadge?c(bq,{badge:e.modelBadge,createdAt:e.message.createdAt}):null,c("div",{"data-assistant-quote-body":"",children:c(Gn,{disclosureKey:`message:${e.message.id}:assistant`,text:d,className:e.textTone==="process"&&e.presentation!=="compact"?"chat-commentary":"chat-readable-body",cwd:t.markdownCwd,threadRef:t.threadRef??void 0,isStreaming:!!e.message.streaming,lineBreaks:t.derive.shouldPreserveAssistantLineBreaks(d),skills:t.skills,onImageExpand:t.onImageExpand,artifactTurnId:e.message.turnId})}),c($c,{images:i}),l.length>0&&c("div",{className:"mb-2 flex max-w-[420px] flex-col gap-1.5",children:l.map(u=>c(Kc,{attachment:u},u.id))}),e.showAssistantMeta||e.showAssistantCopyButton&&!e.assistantCopyStreaming&&e.message.text.trim().length>0?w("div",{className:"mt-1.5 flex select-none items-center gap-2 text-chat-row tabular-nums opacity-0 transition-opacity duration-(--control-duration) focus-within:opacity-100 group-hover/assistant:opacity-100 [@media(pointer:coarse)]:opacity-100",children:[c(xq,{row:e}),e.showAssistantMeta&&!e.message.streaming&&e.modelBadge===null&&w(Ue,{children:[c(Ke,{render:c("p",{className:"text-muted-foreground text-chat-row tabular-nums"}),children:pa(e.message.updatedAt,t.timestampFormat,n)}),c($e,{children:Or(e.message.updatedAt,t.timestampFormat)})]})]}):null]})})}function xq({row:e}){let n=et(St).derive.resolveAssistantMessageCopyState({text:e.message.text??null,showCopyButton:e.showAssistantCopyButton,streaming:e.assistantCopyStreaming});return n.visible?c(Ja,{text:n.text??"",variant:"ghost"}):null}function Yv({badge:e}){let{t}=je(),n=Hv(t,e);return w(he,{children:[e.driverKind?c("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg border border-border/60 bg-card","aria-label":e.providerDisplayName??void 0,children:c(nr,{driver:e.driverKind,displayName:e.providerDisplayName,accentColor:e.accentColor,className:"size-5",iconClassName:"size-4"})}):null,w("span",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[e.driverKind?c("span",{className:"font-medium text-foreground",children:e.providerDisplayName}):null,c(Tp,{text:e.modelLabel,label:t("copyButton.copyModelName"),children:c("span",{className:"min-w-0 truncate text-muted-foreground",children:e.modelLabel})}),n?w("span",{children:[" \xB7 ",n]}):null]})]})}function bq({badge:e,createdAt:t}){let n=et(St),{t:o}=je();return w("div",{className:"mb-3 flex min-w-0 select-none flex-wrap items-center gap-x-2.5 gap-y-1 text-chat-dense text-muted-foreground","data-testid":"assistant-model-header",children:[c(Yv,{badge:e}),c("span",{"aria-hidden":!0,children:"\xB7"}),w(Ue,{children:[c(Ke,{render:c("span",{className:"shrink-0 tabular-nums"}),children:pa(t,n.timestampFormat,o)}),c($e,{children:Or(t,n.timestampFormat)})]})]})}function xk({row:e}){let{t}=je(),n=Hv(t,e.badge),o=n?`${e.badge.modelLabel} \xB7 ${n}`:e.badge.modelLabel,r=[e.badge.providerDisplayName,o].filter(s=>typeof s=="string"&&s.length>0).join(" \xB7 "),a=e.pending?t("timeline.modelSwitchPending",{model:r}):t("timeline.modelSwitched",{model:r});return w("div",{role:"separator","aria-label":a,"data-pending":e.pending?"true":void 0,className:"flex items-center gap-2 px-1 py-1 text-chat-dense text-muted-foreground/70",children:[c("span",{"aria-hidden":!0,className:"h-px min-w-4 flex-1 bg-border/60"}),w("span",{className:"flex min-w-0 shrink items-center gap-1.5",children:[e.badge.driverKind?c(nr,{driver:e.badge.driverKind,displayName:e.badge.providerDisplayName,accentColor:e.badge.accentColor,className:"size-icon-1",iconClassName:"size-icon-1"}):null,c("span",{className:"truncate",children:a})]}),c("span",{"aria-hidden":!0,className:"h-px min-w-4 flex-1 bg-border/60"})]})}var Jv=240,Sq=/\s/u;function bk(e){if(!e)return null;let t=[],n=0,o=!1,r=()=>{for(;n>Jv-1;)n-=t.pop()?.length??0;for(;t.at(-1)===" ";)t.pop(),n-=1;return t.push("\u2026"),t.join("")};for(let a of e){if(Sq.test(a)){o=t.length>0;continue}if(o&&(t.push(" "),n+=1,o=!1,n>Jv)||(t.push(a),n+=a.length,n>Jv))return r()}return t.length>0?t.join(""):null}function wq(e,t,n){let o=t.find(s=>s.kind==="message"&&s.message.role==="user"),r=o?.kind==="message"?o.message:null,a=null;for(let s of t)s.kind==="message"&&s.message.role==="assistant"&&(a=s.message.text??null);return{id:e,sectionKey:e,anchorRowId:o?.id??t[0]?.id??e,userText:r===null?null:bk(n.parseSystemNotificationText(r.text)?.summary??n.parseThreadHandoverText(r.text)?.body??n.messageLinksToPreviewText(n.parsePresetPrefixText(r.text)?.body??r.text)),assistantText:bk(a),headerText:r===null?null:gk(r.text,n)}}function Iq(e){for(let t of e){let n=t.kind==="message"?t.message.turnId??null:t.kind==="turn-summary"?t.footer.turnId:null;if(n!==null)return n}return null}function Tq(e,t){return e.sectionKey===t.sectionKey&&e.anchorRowId===t.anchorRowId&&e.userText===t.userText&&e.assistantText===t.assistantText&&e.headerText===t.headerText&&e.turnId===t.turnId}function kq(e,t,n){for(let o=0;o<e.length;o+=1)if(e[o]!==n[t.firstRowIndex+o])return!1;return!0}function Pq(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function Lq(e){let t=new Map,n=null;return o=>{let r=o.getVersion();if(n!==null&&n.store===o&&n.version===r)return n.entries;let a=new Map,s=[],i=o.getRows();for(let d of o.getStructure().sections){let u=t.get(d.key);if(u!==void 0&&u.rowIds===d.rowIds&&kq(u.rows,d,i)){a.set(d.key,u),s.push(u.entry);continue}let f=i.slice(d.firstRowIndex,d.firstRowIndex+d.rowIds.length),p=wq(d.key,f,e),m={...p,turnId:Iq(f)},h=u!==void 0&&Tq(u.entry.item,m)?u.entry:{summary:p,item:m};a.set(d.key,{rowIds:d.rowIds,rows:f,entry:h}),s.push(h)}t=a;let l=n!==null&&Pq(n.entries,s)?n.entries:s;return n={store:o,version:r,entries:l},l}}var Sk=new WeakMap;function Tk(e,t){let n=Sk.get(e);return(n===void 0||n.derive!==t)&&(n={derive:t,read:Lq(t)},Sk.set(e,n)),n.read(e)}var wk=new WeakMap;function kk(e,t){let n=Tk(e,t),o=wk.get(n);if(o===void 0){let r=n.filter(({summary:s})=>s.userText!==null).length,a=0;o=n.flatMap(({summary:s})=>(s.userText!==null&&(a+=1),s.headerText===null?[]:[{sectionKey:s.sectionKey,text:s.headerText,anchorRowId:s.anchorRowId,ordinal:a,total:r}])),wk.set(n,o)}return o}function Pk(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>{let r=t[o];return n.sectionKey===r.sectionKey&&n.text===r.text&&n.anchorRowId===r.anchorRowId&&n.ordinal===r.ordinal&&n.total===r.total})}var Ik=new WeakMap;function Lk(e,t){let n=Tk(e,t),o=Ik.get(n);return o===void 0&&(o=n.filter(({summary:r})=>r.userText!==null).map(({item:r})=>r),Ik.set(n,o)),o}function Rk(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>n===t[o])}var Rq=[],Eq=e=>e.getMeta().usageByTurnId,Aq=e=>e.getMeta().exportApi,Mq=e=>e.getMeta().status.totalTurnCount??null,Ek=fe(function({rowsStore:t,derive:n,paneVisible:o,bottomInset:r,onSelect:a,onTurnNavigatorChange:s}){let i=A(m=>o?Lk(m,n):Rq,[n,o]),l=In(t,i,Rk),d=In(t,Eq),u=In(t,Aq),f=In(t,Mq),p=$(()=>o?{items:l,totalTurnCount:f,bottomInset:r,usageByTurnId:d,onSelect:a,exportMarkdown:u.markdown,onDownload:u.download}:null,[r,u,l,a,o,f,d]);return z(()=>{p!==null&&s(p)},[s,p]),z(()=>{if(o)return()=>s(null)},[s,o]),null});function Ak({timeline:e,previousOverlayHeight:t,overlayHeight:n,followingEnd:o}){e&&o&&n>t&&e.scrollToEnd({animated:!1})}function Mk(e,t){let n=e.topOf(t),o=e.heightOf(t);return typeof n!="number"||typeof o!="number"||!Number.isFinite(n)||!Number.isFinite(o)?null:n+Math.max(1,o)}function Nk({measurement:e,followingEnd:t}){return t?null:e.rowAtScroll()}function Up(e,t){let n=Array.from(e.querySelectorAll("[data-timeline-turn-section]")),o=n.findIndex(a=>a.querySelector(`[data-timeline-row-id="${CSS.escape(t)}"]`)),r=o<0?n:n.slice(0,o+1);for(let a of r)a.style.contentVisibility="visible";e.offsetHeight,requestAnimationFrame(()=>{for(let a of r)a.style.removeProperty("content-visibility")})}X();var Nq=e=>e.getMeta().status.workingStepLabel??null,_q=e=>e.getMeta().status.stall??null,Dq=e=>e.getMeta().status.retry??null,Oq=e=>e.getMeta().status.isWorking,_k=fe(function({rowsStore:t,historyWindow:n,children:o}){let r=In(t,Nq),a=In(t,_q),s=In(t,Dq),i=$(()=>n?{workingStepLabel:null,stall:null,retry:null}:{workingStepLabel:r,stall:a,retry:s},[n,s,a,r]);return c(Cp,{value:i,children:o})});function Dk({rowsStore:e,historyWindow:t}){let{t:n}=je();return In(e,Oq)&&!t?null:c("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:c("p",{className:"text-placeholder text-chat",children:n("timeline.empty")})})}X();function $p(e){return e==="loading"?"threadSync.loading":"threadSync.syncing"}var Fq=1e3,Kp=150;function Vp(e,t=Fq){let[n,o]=j(null);return z(()=>{if(e===null){o(null);return}let r=globalThis.setTimeout(()=>{o(e)},t);return()=>{globalThis.clearTimeout(r)}},[e,t]),n}var Bq=5;function Ok(e){let t=e.data.useThreadSyncPhase(e.target);return Vp(t,Kp)==="loading"?c(Zv,{}):e.hideEmptyPlaceholder?null:c(Dk,{rowsStore:e.rowsStore,historyWindow:e.historyWindow})}function Zv(){let{t:e}=le();return w("div",{className:"pointer-events-none absolute inset-0 overflow-hidden bg-background px-3 pt-4 sm:px-5","data-timeline-loading-skeleton":"",role:"status",children:[c("span",{className:"sr-only",children:e($p("loading"))}),c("div",{className:"transcript-col flex flex-col gap-6",children:Array.from({length:Bq},(t,n)=>w("div",{"aria-hidden":"true",className:"flex flex-col gap-3",children:[c("div",{className:"h-9 self-end rounded-[18px] bg-muted-foreground/15",style:{width:`${44-n%2*14}%`}}),[92,84,61].map((o,r)=>c("div",{className:"h-3 rounded-control-1 bg-muted-foreground/15",style:{width:`${o-n%3*6}%`}},r))]},n))})]})}var Fk=c("div",{className:"h-3 sm:h-4"}),Bk=c("div",{className:"h-10 sm:h-12"});function zk({loading:e,blocked:t,onLoadEarlier:n,fade:o}){let{t:r}=je();return c("div",{className:o?"pt-10 sm:pt-12":"pt-3 sm:pt-4",children:c("div",{className:"transcript-col pb-2",children:c("button",{type:"button","data-timeline-load-earlier":"",onClick:n,disabled:e||t,className:"relative w-full select-none py-1.5 text-chat-row text-muted-foreground/60 hover:text-foreground disabled:cursor-default pointer-coarse:after:absolute pointer-coarse:after:inset-0 pointer-coarse:after:min-h-11",children:r(e?"timeline.loadingEarlier":"timeline.loadEarlier")})})})}function Hk({loading:e,blocked:t,onLoadLater:n,onReturnToLatest:o}){let{t:r}=je();return w("div",{className:"transcript-col flex items-center justify-center gap-2 py-2",children:[c(re,{variant:"ghost",size:"sm",onClick:n,disabled:e||t,children:r(e?"timeline.loadingLater":"timeline.loadLater")}),o?c(re,{variant:"ghost",size:"sm",onClick:o,children:r("timeline.returnToLatest")}):null]})}function Uk({onReveal:e,fade:t}){let{t:n}=je();return c("div",{className:t?"pt-10 sm:pt-12":"pt-3 sm:pt-4",children:c("div",{className:"transcript-col pb-2",children:c("button",{type:"button","data-timeline-load-earlier":"",onClick:e,className:"relative w-full select-none py-1.5 text-chat-row text-muted-foreground/60 hover:text-foreground pointer-coarse:after:absolute pointer-coarse:after:inset-0 pointer-coarse:after:min-h-11",children:n("timeline.loadEarlier")})})})}var $k=c("div",{className:"h-3 sm:h-4"});X();var zq=Object.freeze([]),Kk=e=>e.getMeta().status.scheduledWakes??zq;function Vk(e,t){let n=M(e);return t&&(n.current=e),n.current}X();function qp(e){return JSON.stringify([e.turnId??null,e.toolCallId?"tool":"entry",e.toolCallId||e.id])}X();function lr(e){if(!Number.isFinite(e)||e<0)return"0ms";if(e<1e3)return`${Math.max(1,Math.round(e))}ms`;if(e<1e4){let s=Math.round(e/100)/10;return s>=10?"10s":`${s.toFixed(1)}s`}if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.round(e/1e3),n=Math.floor(t/3600),o=Math.floor(t%3600/60),r=t%60,a=[];return n>0&&a.push(`${n}h`),o>0&&a.push(`${o}m`),r>0&&a.push(`${r}s`),a.join(" ")}function qk({badge:e,startedAt:t,completedAt:n,timestampFormat:o}){let{t:r}=je();if(e===null&&t===void 0)return null;let a=r("timeline.turnInfo");return w(Mr,{children:[c(_r,{openOnHover:!0,delay:250,render:c(re,{type:"button",size:"icon-xs",variant:"ghost","data-turn-info":"","aria-label":a,className:"shrink-0 text-muted-foreground"}),children:c(Yd,{className:"size-3.5","aria-hidden":!0})}),c(Nr,{side:"top",align:"start",className:"max-w-80",children:w("div",{className:"flex flex-col gap-2 text-chat-dense",children:[e!==null?c("div",{className:"flex min-w-0 items-center gap-2",children:c(Yv,{badge:e})}):null,t!==void 0?c("div",{className:"text-muted-foreground tabular-nums",children:r("timeline.turnStarted",{time:Or(t,o)})}):null,n!==void 0?c("div",{className:"text-muted-foreground tabular-nums",children:r("timeline.turnFinished",{time:Or(n,o)})}):null]})})]})}function Hq(e){return e<1e3?Math.round(e).toLocaleString():e<1e6?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}function ey({label:e,children:t}){let[n,o]=j(!1);return w(Ue,{open:n,onOpenChange:o,children:[c(Ke,{render:c("button",{type:"button",className:"inline-flex items-center gap-1 rounded-sm"}),"aria-label":e,onClick:()=>o(r=>!r),children:t}),c($e,{children:e})]})}var Wk=fe(function({footer:t,timestampFormat:n,copyText:o,identity:r}){let{t:a}=je(),s=t.state,i=s==="error"?a("timeline.error"):s==="interrupted"?a("timeline.interrupted"):null;return w("div",{"data-turn-summary":t.turnId,className:"chat-process-meta flex min-w-0 select-none items-center gap-2 px-1 text-muted-foreground",children:[w("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[i!==null?w(ey,{label:i,children:[s==="error"?c(Kt,{className:"size-icon-1 text-destructive-foreground","aria-hidden":!0}):c(dc,{className:"size-3","aria-hidden":!0}),c("span",{className:"sr-only",children:i})]}):null,t.workingElapsedMs!==void 0?c(ey,{label:a("timeline.workingTime",{duration:lr(t.workingElapsedMs)}),children:lr(t.workingElapsedMs)}):null,t.workingElapsedMs!==void 0&&t.outputTokens!==void 0?c("span",{"aria-hidden":!0,children:"\xB7"}):null,t.outputTokens!==void 0?c(Tp,{text:String(t.outputTokens),label:a("copyButton.copyTokenCount"),children:c(ey,{label:`${a("timeline.outputTokens")}: ${t.outputTokens.toLocaleString()}`,children:a("timeline.outputTokenCount",{count:t.outputTokens,value:Hq(t.outputTokens)})})}):null]}),c(qk,{badge:r?.badge??null,startedAt:r?.createdAt,completedAt:t.completedAt,timestampFormat:n}),o?c(Ja,{text:o,variant:"ghost",size:"icon-xs",className:"shrink-0",toastAnchor:"below"}):null]})});X();function Uq(e){return e.toolLifecycleStatus==="interrupted"}function $q(e){let t=e?.stoppedByUser===!0;return e?.continuedAfterStop===!0?t?"toolGroup.interruptedByYouKeptRunning":"toolGroup.interruptedKeptRunning":e?.terminationConfirmed===!0?t?"toolGroup.interruptedByYou":"toolGroup.interrupted":t?"toolGroup.interruptedByYouMayStillRun":"toolGroup.interruptedMayStillRun"}function ty(e,t){if(!Uq(e))return null;let n=e.toolInterrupt,o=t($q(n)),r=[n?.durationMs===void 0?null:lr(n.durationMs),e.toolIo?.exitCode===void 0?null:t("toolGroup.exitCode",{code:e.toolIo.exitCode})].filter(a=>a!==null);return r.length===0?o:`${o} \xB7 ${r.join(" \xB7 ")}`}X();function Gk(e){if(e<1e3)return String(e);if(e<1e6){let n=e/1e3;return`${n<10?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}k`}if(e<1e9){let n=e/1e6;return`${n<10?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}m`}let t=e/1e9;return`${t<10?t.toFixed(1).replace(/\.0$/,""):Math.round(t)}b`}var jk=fe(function(t){let{additions:n,deletions:o,className:r,showParentheses:a=!1,layout:s="aligned"}=t,{t:i}=je(),l=new Intl.ListFormat(void 0,{type:"unit"}).format([i("changedFiles.additions",{count:n}),i("changedFiles.deletions",{count:o})]);return w(he,{children:[a&&c("span",{className:"text-muted-foreground/70",children:"("}),w("span",{role:"group","aria-label":l,className:G(s==="inline"?"inline-flex items-center gap-1 tabular-nums align-middle":"inline-grid grid-cols-[4ch_4ch] gap-2 text-right tabular-nums align-middle",r),children:[w("span",{"aria-hidden":"true",className:"font-mono text-diff-addition",children:["+",Gk(n)]}),w("span",{"aria-hidden":"true",className:"font-mono text-diff-deletion",children:["-",Gk(o)]})]}),a&&c("span",{className:"text-muted-foreground/70",children:")"})]})});function qc({name:e,className:t}){switch(e){case"bot":return c(As,{className:t,"aria-hidden":!0});case"check":return c(Wn,{className:t,"aria-hidden":!0});case"circle-alert":return c(Jt,{className:t,"aria-hidden":!0});case"eye":return c(Hd,{className:t,"aria-hidden":!0});case"globe":return c(Gd,{className:t,"aria-hidden":!0});case"hammer":return c(Qd,{className:t,"aria-hidden":!0});case"message-circle":return c(Ds,{className:t,"aria-hidden":!0});case"search":return c(Us,{className:t,"aria-hidden":!0});case"square-pen":return c(oo,{className:t,"aria-hidden":!0});case"terminal":return c(To,{className:t,"aria-hidden":!0});case"wrench":return c(uc,{className:t,"aria-hidden":!0});case"x":return c(Kt,{className:t,"aria-hidden":!0});case"zap":return c(Ks,{className:t,"aria-hidden":!0})}}function Kq(e){switch(e){case"read":return"eye";case"edit":return"square-pen";case"command":return"terminal";case"search":return"globe";case"code-search":return"search";case"other":return"wrench";case"dynamic-tool":return"hammer";case"agent-tool":return"bot";case"tone-tool":return"zap";case"mixed":case null:return"hammer"}}function ny(e,t){let n=new Map;for(let o of e){let r=t(o);n.set(r,(n.get(r)??0)+1)}return Array.from(n,([o,r])=>({action:o,icon:Kq(o),count:r}))}function oy(e,t){let n;for(let o of ny(e,t))(!n||o.count>n.count)&&(n=o);return n?.icon??"wrench"}function Qk(e){return typeof e.toolData=="object"&&e.toolData!==null&&!Array.isArray(e.toolData)?e.toolData:null}function Xk(e,t,n,o){if(t===void 0||n===void 0||n.length===0)return e;let r=e.trim();for(let a of[`mcp__ycodium__${t}`,`ycodium_${t}`,`ycodium ${t}`,t]){if(r===a)return n;if(!r.startsWith(`${a} `))continue;let s=r.slice(a.length).trim();return s.length===0?n:o!==void 0&&s.toLowerCase()==="started"?o(n):`${n} ${s}`}return e}var bl=20,Vq={failed:"toolGroup.showFailure",declined:"toolGroup.showDeclined",stopped:"toolGroup.showCancelled"};function Sl(e){return qp(e)}function Yk(e,t,n,o,r){let a=e.toolLabel,s=n.resolveToolCommand(e);if(s&&a?.descriptive&&!a.path&&a.detail?.trim())return a.detail.replace(/\s+/g," ").trim();for(let g of[e.rawCommand,e.command]){let v=n.parseToolCommandInput(g)?.description;if(v)return v.replace(/\s+/g," ").trim()}if(s)return s.replace(/\s+/g," ").trim();let i=Qk(e),l=typeof i?.toolName=="string"?i.toolName:typeof i?.name=="string"?i.name:void 0,d=e.builtinMcpTool||void 0,u=Xk(a?.name??l??e.toolTitle??e.label,d,d===void 0?void 0:o?.get(d),r),f=a?.path??e.changedFiles?.[0],p=f?Lp(f,t):void 0,m=[u.trim().toLowerCase()==="tool"?void 0:u,p,a?.detail??e.detail],h=[];for(let g of m){let v=g?.replace(/\s+/g," ").trim();v&&!h.some(C=>C.toLowerCase()===v.toLowerCase())&&h.push(v)}return h.join(" ")||null}function Jk({entry:e,presentation:t}){let n=e.toolLabel?.diffStat;return!n||t==="failed"||t==="declined"||t==="stopped"?null:c(jk,{...n,layout:"inline",className:"chat-process-meta ms-2 shrink-0"})}function Zk({toolIcon:e,glyphClassName:t}){let n=et(St),o=n.SiteIcon;return e.pageUrl!==void 0&&o!==void 0?c(o,{threadRef:n.threadRef,pageUrl:e.pageUrl,className:"size-3.5 shrink-0 rounded-sm object-contain"}):c(qc,{name:"globe",className:t})}function qq({entry:e,failed:t=!1,derive:n}){return t?c(Jt,{"aria-hidden":!0,className:"size-icon-1 shrink-0 text-destructive-foreground"}):e.toolIcon!==void 0?c(Zk,{toolIcon:e.toolIcon,glyphClassName:"size-icon-1 shrink-0 stroke-[1.8] text-muted-foreground opacity-70"}):c(qc,{name:oy([e],n.toolGroupAction),className:"size-icon-1 shrink-0 stroke-[1.8] text-muted-foreground opacity-70"})}function Wq({entries:e,failed:t,derive:n}){let{t:o}=je(),r=$(()=>ny(e,n.toolGroupAction),[e,n]),a=r.length===1;return a&&r[0].count<2?null:c("span",{className:"chat-process-meta flex shrink-0 items-center gap-2 tabular-nums","aria-label":o("toolGroup.calls",{count:e.length}),children:r.map(({action:s,icon:i,count:l})=>w("span",{"aria-hidden":!0,className:"flex items-center gap-1",children:[a?null:c(qc,{name:i,className:G("size-icon-1 shrink-0 stroke-[1.8] opacity-70",t?"text-destructive-foreground":"text-icon-muted")}),l]},s))})}function eP({entry:e}){let t=et(St),n=e.detail??e.command??e.rawCommand??e.toolLabel?.detail,o=JSON.stringify([e.id,e.sourceActivityKind,e.toolLifecycleStatus]),r=t.renderToolCallDetail?.({entry:e,threadRef:t.threadRef,threadKey:t.threadKey,workspaceRoot:t.workspaceRoot,revision:o,onOpenFileDiff:t.onOpenFileDiff});return c("div",{className:"min-w-0 space-y-2 p-3",children:r!==void 0?c(he,{children:r}):c("pre",{className:"chat-tool-body overflow-x-auto rounded-md bg-muted/40 p-2",children:n??""})})}var Gq=fe(function(t){let{entry:n,threadKey:o,workspaceRoot:r,onDisclosureChange:a}=t,s=et(St),i=s.derive,{t:l}=je(),[d,u]=io(o,`call:${Sl(n)}`,!1),f=i.toolPresentationStatus(n),p=f==="failed",m=f==="declined",h=f==="stopped",g=h?ty(n,l):null,v=i.resolveWorkEntryStatus(n),C=v==="failed"||v==="running"?v:null,y=Fo();return w("div",{"data-tool-call-id":n.toolCallId??n.id,"data-tool-identity":Sl(n),className:"border-b border-border/50 last:border-b-0",children:[w("button",{type:"button","aria-expanded":d,"aria-controls":y,onClick:()=>{a?.(),u(!d)},className:G("chat-tool-member-row chat-tool-summary flex w-full min-w-0 items-center gap-1.5 px-3 text-left hover:bg-accent/20",p?"text-destructive-foreground":"text-muted-foreground"),children:[c(Uc,{status:C}),c(Hc,{children:c(qq,{entry:n,failed:p,derive:i})}),w("span",{className:"flex min-w-0 flex-1 items-center",children:[c("span",{className:"truncate",children:Yk(n,r,i,s.declaredToolTitles,x=>l("toolGroup.declaredStarted",{title:x}))??l("toolGroup.calls",{count:1})}),c(Jk,{entry:n,presentation:f})]}),p||m||h?c("span",{className:"chat-process-meta shrink-0",children:p?l("toolGroup.failed",{count:1}):m?l("toolGroup.declined",{count:1}):g??l("toolGroup.cancelled",{count:1})}):null,c(ln,{"aria-hidden":!0,className:G("size-icon-1 shrink-0",!d&&"-rotate-90")})]}),d?c("div",{id:y,children:c(eP,{entry:n})}):null]})});function jq({threadKey:e,stateKey:t,maxHeight:n,children:o}){let r=M(null);return me(()=>{let a=r.current;if(!a)return;a.scrollTop=Bv(e,`${t}:scroll`,0);let s=()=>{zc(e,`${t}:scroll`,a.scrollTop,!1)};return a.addEventListener("scroll",s,{passive:!0}),()=>a.removeEventListener("scroll",s)},[e,t]),c("div",{ref:r,"data-slot":"scroll-area-viewport",className:"min-w-0 overflow-y-auto overscroll-y-contain",style:{maxHeight:n},children:o})}var tP=fe(function({entries:t,groupId:n,threadKey:o,workspaceRoot:r,onDisclosureChange:a}){let s=et(St),i=s.derive,{t:l}=je(),[d,u]=io(o,`group:${n}`,!1),[f,p]=io(o,`group-page:${n}`,0),m=Fo(),h=M(null),[g,v]=j(null),C=t.at(-1),{failedCount:y,declinedCount:x,stoppedCount:b,issue:T,runningCount:I}=$(()=>({...i.summarizeToolGroup(t),runningCount:t.filter(N=>i.toolPresentationStatus(N)==="running").length}),[t,i]),P=T?.entry??C,k=Math.max(0,Math.ceil(t.length/bl)-1),S=Math.min(f,k),L=S*bl,R=t.slice(L,L+bl),_=t.length>1;if(me(()=>{if(!g)return;let N=h.current,B=Array.from(N?.querySelectorAll("[data-tool-identity]")??[]).find(U=>U.dataset.toolIdentity===g.id);if(!B)return;let ue=B.closest('[data-slot="scroll-area-viewport"]');ue&&(ue.scrollTop+=B.getBoundingClientRect().top-ue.getBoundingClientRect().top),B.querySelector("button")?.focus({preventScroll:!0})},[g]),!C||!P)return null;let E=N=>{a?.(),p(N)},D={threadKey:o,workspaceRoot:r,onDisclosureChange:a},H=N0(t.map(N=>M0(i.resolveWorkEntryStatus(N)))),K=oy(t,i.toolGroupAction),O=_?null:ty(C,l),Z=H==="failed"?"failed":H==="running"?"running":x+b===t.length?null:"success";return c(wp,{state:H,variant:"tool",children:w("section",{ref:h,"data-tool-group-id":n,className:"min-w-0",children:[w("div",{className:"flex min-w-0 items-center",children:[w("button",{type:"button","aria-expanded":d,"aria-controls":m,onClick:()=>{a?.(),u(!d),!_&&!d&&zc(o,`call:${Sl(C)}`,!0)},className:G(Sp,"flex-1",y>0?"text-destructive-foreground":"text-muted-foreground"),children:[c(Uc,{status:Z}),c(Hc,{children:!_&&C.toolIcon!==void 0&&y===0?c(Zk,{toolIcon:C.toolIcon,glyphClassName:"size-icon-1 shrink-0 stroke-[1.8] opacity-70 text-icon-muted"}):c(qc,{name:K,className:G("size-icon-1 shrink-0 stroke-[1.8] opacity-70",y>0?"text-destructive-foreground":"text-icon-muted")})}),w("span",{className:G("flex min-w-0 flex-1 items-center",d&&_?"chat-process-text":"chat-tool-summary"),children:[c("span",{className:"truncate",children:d&&_?l("toolGroup.calls",{count:t.length}):Yk(P,r,i,s.declaredToolTitles,N=>l("toolGroup.declaredStarted",{title:N}))??l("toolGroup.calls",{count:1})}),d&&_?null:c(Jk,{entry:P,presentation:i.toolPresentationStatus(P)})]}),I>0?c("span",{className:"chat-process-meta shrink-0 tabular-nums",children:l("toolGroup.running",{count:I})}):null,y>0?c("span",{className:"chat-process-meta shrink-0 tabular-nums",children:l("toolGroup.failed",{count:y})}):null,x>0?c("span",{className:"chat-process-meta shrink-0 tabular-nums",children:l("toolGroup.declined",{count:x})}):null,b>0?c("span",{className:"chat-process-meta shrink-0 tabular-nums",children:l("toolGroup.cancelled",{count:b})}):null,d&&_?null:c(Wq,{entries:t,failed:y>0,derive:i}),c(ln,{"aria-hidden":!0,className:G("size-icon-1 shrink-0",!d&&"-rotate-90")})]}),T&&_?c("button",{type:"button",className:G("chat-process-meta me-2 min-h-8 shrink-0 rounded-control-4 px-1 underline [@media(pointer:coarse)]:min-h-11",T.kind==="failed"?"text-destructive-foreground":"text-muted-foreground"),onClick:()=>{a?.(),u(!0),p(Math.floor(t.indexOf(T.entry)/bl)),zc(o,`call:${Sl(T.entry)}`,!0),v({id:Sl(T.entry)})},children:l(Vq[T.kind])}):null]}),d?c("div",{id:m,className:"border-t border-border/50",children:_?w(he,{children:[t.length>bl?w("div",{className:"chat-process-meta flex items-center gap-1 border-b border-border/40 px-2 py-1 text-muted-foreground",children:[c("span",{className:"min-w-0 flex-1 tabular-nums",children:l("toolGroup.pageRange",{from:L+1,to:Math.min(L+bl,t.length),count:t.length})}),[{label:l("toolGroup.firstPage"),target:0,disabled:S===0,Icon:Bd},{label:l("toolGroup.previousPage"),target:S-1,disabled:S===0,Icon:Ms},{label:l("toolGroup.nextPage"),target:S+1,disabled:S===k,Icon:no},{label:l("toolGroup.lastPage"),target:k,disabled:S===k,Icon:zd}].map(({label:N,target:B,disabled:ue,Icon:U})=>c("button",{type:"button","aria-label":N,disabled:ue,onClick:()=>E(B),className:"flex size-7 items-center justify-center rounded-control-3 disabled:opacity-64 [@media(pointer:coarse)]:size-11",children:c(U,{"aria-hidden":!0,className:"size-icon-1"})},N))]}):null,c(jq,{threadKey:o,stateKey:`group-scroll:${n}:${S}`,maxHeight:"min(320px, 50dvh)",children:c("div",{className:"space-y-0.5 py-1",children:R.map(N=>c(Gq,{entry:N,...D},Sl(N)))})})]}):w(he,{children:[O?c("p",{className:"chat-process-meta px-3 pt-3 text-muted-foreground",children:c("span",{children:O})}):null,c(eP,{entry:C})]})}):null]})})});X();function nP(){let e=wn(),t=r=>r instanceof Error?r.message:void 0,n=(r,a)=>a!==void 0&&a.length>0?`${r}: ${a}`:r,o=(r,a,s)=>e.notify(r,a,s);return{error:(r,a,s)=>{let i=s?.description??t(a);o(n(r,i),"error",i)},warning:(r,a,s)=>{let i=s?.description??t(a);o(n(r,i),"warning",i)},success:(r,a,s)=>{let i=a??s?.description;o(n(r,i),"success",i)}}}function Wp(e){let t=e.match(/^\s{0,3}#{1,6}\s+(.+)$/m)?.[1]?.trim();return t&&t.length>0?t:null}function ry(e){let t=e.trimEnd().split(/\r?\n/),n=t[0]&&/^\s{0,3}#{1,6}\s+/.test(t[0])?t.slice(1):[...t];for(;n[0]?.trim().length===0;)n.shift();if(n[0]?.match(/^\s{0,3}#{1,6}\s+(.+)$/)?.[1]?.trim().toLowerCase()==="summary")for(n.shift();n[0]?.trim().length===0;)n.shift();return n.join(`
4104
4107
  `)}function oP(e,t,n){let o=n?.maxLines??8,r=ry(e).trimEnd().split(/\r?\n/).map(l=>l.trimEnd()),a=[],s=0,i=!1;for(let l of r){let d=l.trim().length>0;if(d&&s>=o){i=!0;break}a.push(l),d&&(s+=1)}for(;a.length>0&&a.at(-1)?.trim().length===0;)a.pop();return a.length===0?Wp(e)??t("proposedPlan.previewUnavailable"):(i&&a.push("","..."),a.join(`
4105
4108
  `))}function Qq(e){let t=e.toLowerCase().replace(/[`'".,!?()[\]{}]+/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t:"plan"}function rP(e){let t=Wp(e);return`${Qq(t??"plan")}.md`}function aP(e){return`${e.trimEnd()}
4106
4109
  `}function sP(e,t){let n=new Blob([t],{type:"text/markdown;charset=utf-8"}),o=URL.createObjectURL(n),r=document.createElement("a");r.href=o,r.download=e,r.click(),window.setTimeout(()=>{URL.revokeObjectURL(o)},0)}function Wc(e,t,n="duration"){let o=`<${n}></${n}>`,r=`<${n}/>`,a=i=>{let l=e.indexOf(i);return l<0?null:[e.slice(0,l),e.slice(l+i.length)]},s=a(o)??a(r);return s===null?w(he,{children:[e,t]}):w(he,{children:[s[0],t,s[1]]})}var Gp=1024,iP=fe(function({planMarkdown:t,threadKey:n,rowId:o,environmentId:r,threadRef:a,cwd:s,workspaceRoot:i,onSavePlanToWorkspace:l}){let{t:d}=je(),u=nP(),[f,p]=io(n,`proposed-plan:${o}:expanded`,!1),[m,h]=j(!1),[g,v]=io(n,`proposed-plan:${o}:save-path`,""),[C,y]=j(!1);vf(o,m||C);let x=M(!1),b=M(!1);me(()=>(x.current=!0,()=>{x.current=!1}),[]);let{copyToClipboard:T,isCopied:I}=Ip({target:"plan",onError:N=>{u.error(d("proposedPlan.couldNotCopy"),N,{description:d("proposedPlan.copyErrorDescription")})}}),P=Fo(),k=Wp(t)??d("proposedPlan.defaultTitle"),S=t.split(`
@@ -4132,7 +4135,7 @@ ${dk}`,mq=new RegExp(`^${Bp}\\n<preset-prefix id="([^"]*)">\\n([\\s\\S]*?)\\n</p
4132
4135
  `).replace(/^\n+|\n+$/g,"")}function MQ(e){return AQ(e.text).length>0}function j_(e){return!MQ(e)}function NQ(e,t){return e.lineStart===e.lineEnd?t("pendingContext.terminalLine",{line:e.lineStart}):t("pendingContext.terminalLines",{start:e.lineStart,end:e.lineEnd})}function Q_(e,t){return t("pendingContext.terminalLabel",{terminal:e.terminalLabel,range:NQ(e,t)})}function X_(e,t,n){return e<=n&&n<t}function Y_(e,t){if(!t)return;let n=e[e.length-1];if(n&&n.type==="text"){n.text+=t;return}e.push({type:"text",text:t})}function J_(e,t){let n=0;for(let o=0;o<e.length;o+=1)if(e[o]===Zr){if(o>n&&t({type:"text",text:e.slice(n,o),promptOffset:n})===!0||t({type:"terminal-context",promptOffset:o})===!0)return!0;n=o+1}return n<e.length&&t({type:"text",text:e.slice(n),promptOffset:n})===!0}function _Q(e,t){return J_(e,n=>n.type!=="text"?!1:t(n.text,n.promptOffset))}function DQ(e,t){return _Q(e,(n,o)=>{for(let r of Ku(n))if(r.type==="mention"&&t(r,o)===!0)return!0;return!1})}function OQ(e){let t=[];if(!e)return t;let n=Ku(e),o=0;for(let r of n)r.start<o||(r.start>o&&Y_(t,e.slice(o,r.start)),r.type==="mention"?t.push({type:"mention",path:r.value,source:r.source}):t.push({type:"skill",name:r.value}),o=r.end);return o<e.length&&Y_(t,e.slice(o)),t}function ub(e,t,n){return!e||t>=n?!1:DQ(e,(o,r)=>{let a=r+o.start,s=r+o.end,i=a-1,l=s;return!!(i>=0&&/\s/.test(e[i]??"")&&X_(t,n,i)||l<e.length&&/\s/.test(e[l]??"")&&X_(t,n,l))})}function Pa(e,t=[]){if(!e)return[];let n=[],o=0;return J_(e,r=>r.type==="text"?(n.push(...OQ(r.text)),!1):(n.push({type:"terminal-context",context:t[o]??null}),o+=1,!1)),n}function eD(e){return e.isMobileViewport?null:e.modifierKey&&e.shiftKey?e.isDraftThread?"background":null:e.shiftKey?null:e.modifierKey?"steer":"foreground"}var Z_=e=>e.type!=="text";function tD(e,t){return Number.isFinite(t)?Math.max(0,Math.min(e.length,Math.floor(t))):e.length}function fb(e){return yl(e)||e===Zr}function Mo(e,t){let n=tD(e,t),o=Pa(e);if(o.length===0)return n;let r=n,a=0;for(let s of o){if(s.type==="mention"){let l=s.source.length;if(r<=1)return a+(r===0?0:l);r-=1,a+=l;continue}if(s.type==="skill"){let l=s.name.length+1;if(r<=1)return a+(r===0?0:l);r-=1,a+=l;continue}if(s.type==="terminal-context"){if(r<=1)return a+r;r-=1,a+=1;continue}let i=s.text.length;if(r<=i)return a+r;r-=i,a+=i}return a}function nD(e){return e.type==="text"?e.text.length:1}function oD(e,t){let n=e.reduce((o,r)=>o+nD(r),0);return Number.isFinite(t)?Math.max(0,Math.min(n,Math.floor(t))):n}function Zo(e,t){return oD(Pa(e),t)}function Un(e,t){let n=tD(e,t),o=Pa(e);if(o.length===0)return n;let r=n,a=0;for(let s of o){if(s.type==="mention"){let l=s.source.length;if(r===0)return a;if(r<=l)return a+1;r-=l,a+=1;continue}if(s.type==="skill"){let l=s.name.length+1;if(r===0)return a;if(r<=l)return a+1;r-=l,a+=1;continue}if(s.type==="terminal-context"){if(r<=1)return a+r;r-=1,a+=1;continue}let i=s.text.length;if(r<=i)return a+r;r-=i,a+=i}return a}function sd(e,t,n){let o=Pa(e);if(!o.some(Z_))return!1;let r=oD(o,t),a=0;for(let s of o){if(Z_(s)&&(n==="left"&&r===a+1||n==="right"&&r===a))return!0;a+=nD(s)}return!1}function go(e,t){return G_(e,t,fb)}function rD(e,t,n,o){let r=Math.max(0,Math.min(e.length,t)),a=Math.max(r,Math.min(e.length,n));return{text:`${e.slice(0,r)}${o}${e.slice(a)}`,cursor:r+o.length}}function aD(e){return e.map(t=>[t.id,t.threadId,t.terminalId,t.terminalLabel,t.lineStart,t.lineEnd,t.createdAt,t.text].join("")).join("")}function sD(e){return e.map(t=>[t.name,t.displayName??"",t.shortDescription??"",t.description??"",t.path,t.scope??"",t.enabled?"1":"0"].join("")).join("")}function iD(e){let t=0;return e.getEditorState().read(()=>{let n=Ee();Te(n)&&!n.isCollapsed()&&(t=n.getTextContent().length)}),t}function lD(e){e.update(()=>{let t=Ee();Te(t)&&!t.isCollapsed()&&t.removeText()})}X();X();function FQ(e){return(e.comment??e.text).replace(/\s+/g," ").trim()}var id=class e extends po{__quote;__source;static getType(){return"composer-quote"}static clone(t){return new e(t.__quote,t.__source,t.__key)}static importJSON(t){return zg(t.quote,t.source).updateFromJSON(t)}constructor(t,n,o){super(o),this.__quote=t,this.__source=n}exportJSON(){return{...super.exportJSON(),quote:this.__quote,source:this.__source,type:"composer-quote",version:1}}createDOM(){let t=document.createElement("span");return t.className=ir,t}updateDOM(){return!1}getTextContent(){return this.__source}isInline(){return!0}decorate(){return c(BQ,{nodeKey:this.getKey(),quote:this.__quote,source:this.__source})}};function zg(e,t){return hs(new id(e,t))}function BQ(e){let{t}=le(),[n]=Vt(),o=Br(),r=o?.data.assistantQuotes??null,[a,s]=j(!1),[i,l]=j(e.quote.comment??""),[d,u]=Mt(pp,o?.threadKey??"",null);z(()=>{d===null||d!==e.source||(u(null),l(e.quote.comment??""),s(!0))},[d,e.quote.comment,e.source,u]);let f=FQ(e.quote),p=()=>{if(s(!1),r===null)return;let m=r.withComment(e.quote,i),h=r.serialize(m);h!==null&&n.update(()=>{let g=Yl(e.nodeKey);g instanceof id&&g.replace(zg(m,h))})};return w(Mr,{open:a,onOpenChange:m=>{m&&l(e.quote.comment??""),s(m)},children:[c(_r,{render:w("span",{className:Vo,contentEditable:!1,spellCheck:!1,role:"button",tabIndex:-1,"data-composer-quote-chip":"true","aria-label":t("composer.quote.chipLabel",{text:f}),children:[c(na,{"aria-hidden":"true",className:lo}),c("span",{className:co,children:f})]})}),c(Nr,{side:"top",align:"start",className:"w-96 max-w-[calc(100vw-2rem)]",children:w("div",{className:"flex flex-col gap-2",children:[c("div",{className:"line-clamp-6 whitespace-pre-wrap border-l-2 border-border ps-2 text-muted-foreground text-sm",children:e.quote.text}),c(yf,{value:i,autoFocus:!0,rows:3,placeholder:t("composer.quote.commentPlaceholder"),"aria-label":t("composer.quote.commentLabel"),onChange:m=>l(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),p())}}),w("div",{className:"flex justify-end gap-2",children:[c(re,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:t("composer.cancel")}),c(re,{size:"sm",onClick:p,disabled:r===null,children:t("composer.quote.saveComment")})]})]})})]})}var Vu=class e extends po{__reference;__source;static getType(){return"composer-thread-reference"}static clone(t){return new e(t.__reference,t.__source,t.__key)}static importJSON(t){return pb(t.reference,t.source).updateFromJSON(t)}constructor(t,n,o){super(o),this.__reference=t,this.__source=n}exportJSON(){return{...super.exportJSON(),reference:this.__reference,source:this.__source,type:"composer-thread-reference",version:1}}createDOM(){let t=document.createElement("span");return t.className=ir,t}updateDOM(){return!1}getTextContent(){return this.__source}isInline(){return!0}decorate(){return c(zQ,{title:this.__reference.title})}};function pb(e,t){return hs(new Vu(e,t))}function zQ(e){let{t}=le();return w("span",{className:Vo,contentEditable:!1,spellCheck:!1,"data-composer-thread-reference-chip":"true","aria-label":t("composer.threadReference.chipLabel",{title:e.title}),children:[c(ta,{"aria-hidden":"true",className:lo}),c("span",{className:co,children:e.title})]})}var mb=[id,Vu];function Hg(e){return mb.some(t=>e instanceof t)}function HQ(e){return{collect:t=>[...e.assistantQuotes.collect(t).map(n=>({start:n.start,end:n.end,createNode:()=>zg(n.quote,n.source)})),...(e.threadReferences?.collect(t)??[]).map(n=>({start:n.start,end:n.end,createNode:()=>pb(n.reference,n.source)}))].toSorted((n,o)=>n.start-o.start)}}function Oi(){let e=Br()?.data??null,t=$(()=>e===null?null:HQ(e),[e]),n=M(t);return n.current=t,n}var ld=new Map,UQ=32;function dD(e,t){for(ld.delete(e),ld.set(e,t);ld.size>UQ;){let n=ld.keys().next().value;if(n===void 0)break;ld.delete(n)}}function $Q(e){return{anchor:e.length,focus:e.length}}function La(e,t,n){let o=ld.get(e);if(o)return dD(e,o),o;let r={cursor:n?.cursor??t.length,expandedCursor:n?.expandedCursor??t.length,selection:n?{anchor:n.cursor,focus:n.cursor}:$Q(t),history:h_()};return dD(e,r),r}function dd(e,t,n){let o=La(e,t);o.cursor=n.cursor,o.expandedCursor=n.expandedCursor,o.selection=n.selection}function cD(e,t,n,o){let r=La(e,t);r.cursor=n,r.expandedCursor=o}function uD(e,t){let n=e.current,o=[...e.undoStack],r=[...e.redoStack];t(),e.current=n,e.undoStack.splice(0,e.undoStack.length,...o),e.redoStack.splice(0,e.redoStack.length,...r)}function KQ(e){let t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t>=0?e.slice(t+1):e}function VQ(e){return e.replaceAll("\\","\\\\").replaceAll("[","\\[").replaceAll("]","\\]")}function qQ(e){return encodeURI(e).replaceAll("(","%28").replaceAll(")","%29").replaceAll("#","%23").replaceAll("?","%3F").replaceAll("\\","%5C")}function Fi(e){return`[${VQ(KQ(e))}](${qQ(e)})`}X();function gb(e){let t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)}function fD(e){let t=gb(e);return t.startsWith(".")&&!t.slice(1).includes(".")?"directory":t.includes(".")?"file":"directory"}X();X();var pD=dt(null),Ug=pD.Provider;function Nt(){let e=At(pD);if(e===null)throw new Error("Composer API has not been provided.");return e}var $g=fe(function(t){let n=Nt().pierreIcons,o=n.useSpriteReady();Rd(n.ensureSprite,[n]);let r=$(()=>n.resolveForEntry(t.pathValue,t.kind),[n,t.kind,t.pathValue]);return o?c("svg",{"aria-hidden":"true","data-file-icon":r.symbolId,className:G("size-4 shrink-0",t.className),children:c("use",{href:`#${r.symbolId}`})}):t.kind==="directory"?c(Ua,{className:G("size-4 shrink-0 text-icon-muted",t.className)}):c(Vd,{className:G("size-4 shrink-0 text-icon-muted",t.className)})});var mD=Vo;function gD(e){return w(he,{children:[c($g,{pathValue:e.path,kind:fD(e.path),theme:e.theme,className:lo}),c("span",{className:e.selectable?Q0:co,children:e.label})]})}function Kg(e){return c("span",{className:mD,contentEditable:!1,spellCheck:!1,"data-composer-mention-chip":"true",children:c(gD,{path:e.path,label:gb(e.path),theme:e.theme})})}function Vg(e){return w("span",{className:X0,contentEditable:!1,spellCheck:!1,"data-composer-skill-chip":"true",children:[c("span",{"aria-hidden":"true",className:lo,dangerouslySetInnerHTML:{__html:Y0}}),c("span",{className:co,children:e.label})]})}function hD(e){let{label:t,tooltipText:n,expired:o=!1}=e;return w(Ue,{children:[c(Ke,{render:w("span",{className:G(Vo,o&&"border-destructive/35 bg-destructive/8 text-destructive-foreground"),"data-terminal-context-expired":o?"true":void 0,children:[c(To,{className:G(lo,"size-icon-1",o&&"opacity-100")}),c("span",{className:co,children:t})]})}),c($e,{side:"top",className:"max-w-80 whitespace-pre-wrap leading-tight",children:n})]})}function vD({context:e}){let{t}=le(),n=Q_(e,t),o=j_(e),r=o?t("pendingContext.terminalExpired",{label:n}):e.text;return c(hD,{label:n,tooltipText:r,expired:o})}function WQ(e){let t=[];for(let n of e.split(/[\s:_-]+/))n.length!==0&&t.push(n.charAt(0).toUpperCase()+n.slice(1));return t.join(" ")}function GQ(e){return e.replaceAll("\\","/")}function No(e){let t=e.displayName?.trim();return t||WQ(e.name)}function hb(e,t){return t?e.filter(Cl):[]}function yD(e,t){let n=new Set(t.map(o=>o.name.trim().toLowerCase()));return e.filter(o=>!n.has(o.name.trim().toLowerCase()))}function CD(e){let t=GQ(e.path);if(t.includes("/.codex/plugins/")||t.includes("/.agents/plugins/"))return"app";switch(e.scope?.trim().toLowerCase()){case"repo":case"repository":return"repo";case"project":case"workspace":case"local":return"project";case"user":case"personal":return"personal";case"system":return"system";case void 0:case"":return"other";default:return"other"}}var qg=dt({onRemoveTerminalContext:()=>{}});function jQ(e){let t=c(Kg,{path:e.path,theme:JQ()});return w(Ue,{children:[c(Ke,{render:t}),c($e,{side:"top",className:"max-w-120 whitespace-normal leading-tight wrap-anywhere",children:e.path})]})}var Bi=class e extends po{__path;__source;static getType(){return"composer-mention"}static clone(t){return new e(t.__path,t.__source,t.__key)}static importJSON(t){return qu(t.path,t.source).updateFromJSON(t)}constructor(t,n=Fi(t),o){super(o),this.__path=t,this.__source=n}exportJSON(){return{...super.exportJSON(),path:this.__path,source:this.__source,type:"composer-mention",version:1}}createDOM(){let t=document.createElement("span");return t.className=ir,t}updateDOM(){return!1}getTextContent(){return this.__source}isInline(){return!0}decorate(){return c(jQ,{path:this.__path})}};function qu(e,t){return hs(new Bi(e,t))}function QQ(e){let t=e.shortDescription?.trim();return t||e.description?.trim()||null}function zi(e){return new Map(e.map(t=>[t.name,{label:No(t),description:QQ(t)}]))}function XQ(e){let t=c(Vg,{label:e.skillLabel});return e.skillDescription?w(Ue,{children:[c(Ke,{render:t}),c($e,{side:"top",className:"max-w-120 whitespace-normal leading-tight",children:e.skillDescription})]}):t}var cd=class e extends po{__skillName;__skillLabel;__skillDescription;static getType(){return"composer-skill"}static clone(t){return new e(t.__skillName,t.__skillLabel,t.__skillDescription,t.__key)}static importJSON(t){return vb(t.skillName,t.skillLabel??t.skillName,t.skillDescription??null).updateFromJSON(t)}constructor(t,n,o,r){super(r);let a=t.startsWith("$")?t.slice(1):t;this.__skillName=a,this.__skillLabel=n,this.__skillDescription=o}exportJSON(){return{...super.exportJSON(),skillName:this.__skillName,skillLabel:this.__skillLabel,...this.__skillDescription?{skillDescription:this.__skillDescription}:{},type:"composer-skill",version:1}}createDOM(){let t=document.createElement("span");return t.className=ir,t}updateDOM(){return!1}getTextContent(){return`$${this.__skillName}`}isInline(){return!0}decorate(){return c(XQ,{skillLabel:this.__skillLabel,skillDescription:this.__skillDescription})}};function vb(e,t,n){return hs(new cd(e,t,n))}function YQ(e){return c(vD,{context:e.context})}var qr=class e extends po{__context;static getType(){return"composer-terminal-context"}static clone(t){return new e(t.__context,t.__key)}static importJSON(t){return yb(t.context)}constructor(t,n){super(n),this.__context=t}exportJSON(){return{...super.exportJSON(),context:this.__context,type:"composer-terminal-context",version:1}}createDOM(){let t=document.createElement("span");return t.className=ir,t}updateDOM(){return!1}getTextContent(){return Zr}isInline(){return!0}decorate(){return c(YQ,{context:this.__context})}};function yb(e){return hs(new qr(e))}function br(e){return e instanceof Bi||e instanceof cd||e instanceof qr||Hg(e)}function JQ(){return document.documentElement.classList.contains("dark")?"dark":"light"}function Gu(e,t){return Number.isFinite(t)?Math.max(0,Math.min(e.length,Math.floor(t))):e.length}function Wg(e){return Hg(e)?e.getTextContentSize():1}function bD(e){return e.getTextContentSize()}function ZQ(e,t,n){return t+(n>0?Wg(e):0)}function e7(e,t,n){return t+(n>0?bD(e):0)}function t7(e,t){let n=e.getParent();if(!n||!We(n))return null;let o=e.getIndexWithinParent();return t.value===0?{key:n.getKey(),offset:o,type:"element"}:t.value===Wg(e)?{key:n.getKey(),offset:o+1,type:"element"}:(t.value-=Wg(e),null)}function Gg(e){return br(e)?Wg(e):st(e)?e.getTextContentSize():Zl(e)?1:We(e)?e.getChildren().reduce((t,n)=>t+Gg(n),0):0}function Cb(e){return br(e)?bD(e):st(e)?e.getTextContentSize():Zl(e)?1:We(e)?e.getChildren().reduce((t,n)=>t+Cb(n),0):0}function ud(e,t){let n=0,o=e;for(;o;){let r=o.getParent();if(!r||!We(r))break;let a=r.getChildren(),s=o.getIndexWithinParent();for(let i=0;i<s;i+=1){let l=a[i];l&&(n+=Gg(l))}o=r}if(st(e))return n+Math.min(t,e.getTextContentSize());if(br(e))return ZQ(e,n,t);if(Zl(e))return n+Math.min(t,1);if(We(e)){let r=e.getChildren(),a=Math.max(0,Math.min(t,r.length));for(let s=0;s<a;s+=1){let i=r[s];i&&(n+=Gg(i))}return n}return n}function Wu(e,t){let n=0,o=e;for(;o;){let r=o.getParent();if(!r||!We(r))break;let a=r.getChildren(),s=o.getIndexWithinParent();for(let i=0;i<s;i+=1){let l=a[i];l&&(n+=Cb(l))}o=r}if(st(e))return n+Math.min(t,e.getTextContentSize());if(br(e))return e7(e,n,t);if(Zl(e))return n+Math.min(t,1);if(We(e)){let r=e.getChildren(),a=Math.max(0,Math.min(t,r.length));for(let s=0;s<a;s+=1){let i=r[s];i&&(n+=Cb(i))}return n}return n}function jg(e,t){if(br(e))return t7(e,t);if(st(e)){let n=e.getTextContentSize();return t.value<=n?{key:e.getKey(),offset:t.value,type:"text"}:(t.value-=n,null)}if(Zl(e)){let n=e.getParent();if(!n)return null;let o=e.getIndexWithinParent();return t.value===0?{key:n.getKey(),offset:o,type:"element"}:t.value===1?{key:n.getKey(),offset:o+1,type:"element"}:(t.value-=1,null)}if(We(e)){let n=e.getChildren();for(let o of n){let r=jg(o,t);if(r)return r}if(t.value===0)return{key:e.getKey(),offset:n.length,type:"element"}}return null}function ju(){return gt().getChildren().reduce((n,o)=>n+Gg(o),0)}function Ra(e){let t=gt(),n=ju(),r={value:Math.max(0,Math.min(e,n))},a=jg(t,r)??{key:t.getKey(),offset:t.getChildren().length,type:"element"},s=Ri();s.anchor.set(a.key,a.offset,a.type),s.focus.set(a.key,a.offset,a.type),Yo(s)}function fd(e,t){let n=gt(),o=ju(),r=Math.max(0,Math.min(e,o)),a=Math.max(0,Math.min(t,o)),s={value:r},i={value:a},l=jg(n,s)??{key:n.getKey(),offset:n.getChildren().length,type:"element"},d=jg(n,i)??{key:n.getKey(),offset:n.getChildren().length,type:"element"},u=Ri();u.anchor.set(l.key,l.offset,l.type),u.focus.set(d.key,d.offset,d.type),Yo(u)}function xb(e){if(!Te(e))return null;let t=e.anchor.getNode(),n=e.focus.getNode(),o=Wu(t,e.anchor.offset),r=Wu(n,e.focus.offset);return{start:Math.min(o,r),end:Math.max(o,r)}}function bb(e){return Te(e)?e.getNodes().some(t=>br(t)):!1}function Hi(e){let t=Ee();if(!Te(t)||!t.isCollapsed())return e;let n=t.anchor.getNode(),o=ud(n,t.anchor.offset),r=ju();return Math.max(0,Math.min(o,r))}function Sb(e){let t=Ee();if(!Te(t)||!t.isCollapsed())return e;let n=t.anchor.getNode(),o=Wu(n,t.anchor.offset),r=gt().getTextContent().length;return Math.max(0,Math.min(o,r))}function Qg(e){let t=Ee();return Te(t)?{anchor:ud(t.anchor.getNode(),t.anchor.offset),focus:ud(t.focus.getNode(),t.focus.offset)}:e}function xD(e,t){let n=t.split(`
4133
4136
  `);for(let o=0;o<n.length;o+=1){let r=n[o]??"";r.length>0&&e.append(yr(r)),o<n.length-1&&e.append(Li())}}function n7(e,t,n){let o=0;for(let r of n?.collect(t)??[])xD(e,t.slice(o,r.start)),e.append(r.createNode()),o=r.end;xD(e,t.slice(o))}function Qu(e,t,n,o){let r=gt();r.clear();let a=Xo();r.append(a);let s=Pa(e,t);for(let i of s){if(i.type==="mention"){a.append(qu(i.path,i.source));continue}if(i.type==="skill"){let l=n.get(i.name);a.append(vb(i.name,l?.label??No({name:i.name}),l?.description??null));continue}if(i.type==="terminal-context"){i.context&&a.append(yb(i.context));continue}n7(a,i.text,o)}}function Xg(e){return e instanceof qr?[e.__context.id]:We(e)?e.getChildren().flatMap(t=>Xg(t)):[]}X();function pd(e){return/mac|iphone|ipad|ipod/i.test(e)}function Ui(){let e=globalThis.crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function SD(e,t){return e.registerCommand(fg,n=>{if(!(n instanceof ClipboardEvent)||n.clipboardData===null||n.clipboardData.files.length>0)return!1;let o=n.clipboardData.getData("text/plain");if(o.length===0)return!1;let r=t.readLinkChips?.()?.collect(o)??[],a=Ku(`${o}
4134
4137
  `).filter(p=>p.type==="mention"&&p.end<=o.length&&!r.some(m=>p.start<m.end&&m.start<p.end));if(a.length===0&&r.length===0)return!1;let s=[...a.map(p=>({start:p.start,end:p.end,isMention:!0,create:()=>t.createMentionNode(p.value,p.source)})),...r.map(p=>({start:p.start,end:p.end,isMention:!1,create:()=>p.createNode()}))].sort((p,m)=>p.start-m.start),i=Ee();if(!Te(i))return!1;let l=[],d=p=>{let m=p.split(`
4135
- `);for(let h=0;h<m.length;h+=1){let g=m[h]??"";g.length>0&&l.push(yr(g)),h<m.length-1&&l.push(Li())}},u=s[0];if(u?.isMention&&u.start===0){let p=i.isBackward()?i.focus:i.anchor,m=t.getExpandedAbsoluteOffsetForPoint(p.getNode(),p.offset),h=gt().getTextContent().slice(m-1,m);h.length>0&&!/\s/.test(h)&&l.push(yr(" "))}let f=0;for(let p of s)p.start<f||(p.start>f&&d(o.slice(f,p.start)),l.push(p.create()),f=p.end);return f<o.length?d(o.slice(f)):s.at(-1)?.isMention&&l.push(yr(" ")),i.insertNodes(l),n.preventDefault(),!0},Jo)}function wD(){let[e]=Vt();return z(()=>{let t=r=>{if(r.inputType!=="insertText"||!r.data||r.isComposing)return;let a=r.data;e.getEditorState().read(()=>{let i=Ee();if(!Te(i)||!i.isCollapsed()||i.anchor.type!=="element")return!1;let l=i.anchor.getNode();return We(l)&&br(l.getChildAtIndex(i.anchor.offset))})&&(r.preventDefault(),r.stopImmediatePropagation(),e.update(()=>{let i=Ee();Te(i)&&i.insertText(a)},{discrete:!0}))},n=null,o=e.registerRootListener((r,a)=>{a?.removeEventListener("beforeinput",t,!0),r?.addEventListener("beforeinput",t,!0),n=r});return()=>{n?.removeEventListener("beforeinput",t,!0),o()}},[e]),null}function ID(e){let[t]=Vt();return z(()=>{let n=(l,d)=>{if(!e.onCommandKeyDown||!d)return!1;if(l==="Enter"&&(d.isComposing||d.keyCode===229))return d.stopPropagation(),!0;let u=e.onCommandKeyDown(l,d);return u&&(d.preventDefault(),d.stopPropagation()),u},o=t.registerCommand(SM,l=>n("ArrowDown",l),Jo),r=t.registerCommand(wM,l=>n("ArrowUp",l),Jo),a=t.registerCommand(cg,l=>n("Enter",l),Jo),s=t.registerCommand(ug,l=>n("Tab",l),Jo),i=t.registerCommand(kM,l=>n("Escape",l),Jo);return()=>{o(),r(),a(),s(),i()}},[t,e]),null}function TD(){let[e]=Vt();return z(()=>{let t=e.registerCommand(ig,o=>{let r=null;if(e.getEditorState().read(()=>{let s=Ee();if(!Te(s)||!s.isCollapsed())return;let i=Hi(0);if(i<=0)return;let l=gt().getTextContent();sd(l,i,"left")&&(r=i-1)}),r===null)return!1;let a=r;return o?.preventDefault(),o?.stopPropagation(),e.update(()=>{Ra(a)}),!0},Jo),n=e.registerCommand(lg,o=>{let r=null;if(e.getEditorState().read(()=>{let s=Ee();if(!Te(s)||!s.isCollapsed())return;let i=Hi(0),l=ju();if(i>=l)return;let d=gt().getTextContent();sd(d,i,"right")&&(r=i+1)}),r===null)return!1;let a=r;return o?.preventDefault(),o?.stopPropagation(),e.update(()=>{Ra(a)}),!0},Jo);return()=>{t(),n()}},[e]),null}function kD(){let[e]=Vt();return z(()=>e.registerCommand(TM,t=>{if(!pd(navigator.platform)||t.key!=="Home"&&t.key!=="End"||t.altKey||t.metaKey||t.ctrlKey||t.isComposing)return!1;let n=e.getRootElement(),o=window.getSelection(),r=o?.anchorNode;return!n||!o||!r||!n.contains(r)||o.rangeCount===0||typeof o.modify!="function"?!1:(t.preventDefault(),t.stopPropagation(),o.modify(t.shiftKey?"extend":"move",t.key==="Home"?"backward":"forward","lineboundary"),e.update(()=>{Yo(HA(o,e))}),!0)},Jo),[e]),null}function PD(){let[e]=Vt();return z(()=>e.registerUpdateListener(({editorState:t})=>{let n=null;t.read(()=>{let o=Ee();if(!Te(o)||!o.isCollapsed())return;let r=o.anchor.getNode();if(!br(r)||o.anchor.offset===0)return;n=ud(r,0)+1}),n!==null&&queueMicrotask(()=>{e.update(()=>{Ra(n)})})}),[e]),null}function LD(){let[e]=Vt(),{onRemoveTerminalContext:t}=et(qg);return z(()=>e.registerCommand(dg,n=>{let o=Ee();if(!Te(o)||!o.isCollapsed())return!1;let r=o.anchor.getNode(),a=Hi(0),s=i=>{if(!br(i))return!1;let l=ud(i,0);return i.remove(),i instanceof qr?(t(i.__context.id),Ra(a)):Ra(l),n?.preventDefault(),!0};if(s(r))return!0;if(st(r)){if(o.anchor.offset>0)return!1;if(s(r.getPreviousSibling()))return!0;let i=r.getParent();if(We(i)){let l=r.getIndexWithinParent();if(l>0&&s(i.getChildAtIndex(l-1)))return!0}return!1}if(We(r)){let i=o.anchor.offset-1;if(i>=0&&s(r.getChildAtIndex(i)))return!0}return!1},Jo),[e,t]),null}function RD(){let[e]=Vt();return z(()=>{let t=new Set,n=e.getRootElement()===document.activeElement,o=l=>{for(let d of t)l.has(d)||e.getElementByKey(d)?.removeAttribute("data-composer-chip-selected");for(let d of l)e.getElementByKey(d)?.setAttribute("data-composer-chip-selected","true");t=l},r=()=>{let l=new Set;return e.getEditorState().read(()=>{let d=Ee();if(Te(d)&&!d.isCollapsed())for(let u of d.getNodes())u instanceof po&&l.add(u.getKey())}),l},a=e.registerUpdateListener(()=>{o(n?r():new Set)}),s=e.registerCommand(vM,()=>(n=!0,o(r()),!1),ed),i=e.registerCommand(sM,()=>(n=!1,o(new Set),!1),ed);return()=>{a(),s(),i()}},[e]),null}function ED(){let[e]=Vt(),t=Oi();return z(()=>SD(e,{createMentionNode:qu,getExpandedAbsoluteOffsetForPoint:Wu,readLinkChips:()=>t.current}),[e]),null}X();var o7=[["(",")"],["[","]"],["{","}"],["'","'"],['"','"'],["\u201C","\u201D"],["`","`"],["<",">"],["\xAB","\xBB"],["*","*"],["_","_"]],MD=new Map(o7),AD=MD.get("`")??null;function ND(e){let[t]=Vt(),n=M(e.terminalContexts),o=M(zi(e.skills)),r=Oi(),a=M(null),s=M(null);z(()=>{n.current=e.terminalContexts},[e.terminalContexts]),z(()=>{o.current=zi(e.skills)},[e.skills]);let i=xh(l=>{let d=MD.get(l),u=a.current;if(!d)return a.current=null,!1;let f=!1;return t.update(()=>{let p=u??(()=>{let v=Ee();if(!Te(v)||v.isCollapsed()||bb(v))return null;let C=xb(v);if(!C||C.start===C.end)return null;let y=gt().getTextContent();return ub(y,C.start,C.end)?null:{value:y,expandedStart:C.start,expandedEnd:C.end}})();if(!p||!d)return;let m=p.value.slice(p.expandedStart,p.expandedEnd),h=`${p.value.slice(0,p.expandedStart)}${l}${m}${d}${p.value.slice(p.expandedEnd)}`;Qu(h,n.current,o.current,r.current);let g=Un(h,p.expandedStart);fd(g+l.length,g+l.length+m.length),f=!0,a.current=null}),f});return z(()=>{let l=g=>{if(s.current){if(g.key==="Dead"||g.key===" "||g.code==="Space")return;s.current=null}if(g.defaultPrevented||g.isComposing||g.metaKey||g.ctrlKey){a.current=null,s.current=null;return}t.getEditorState().read(()=>{let v=Ee();if(!Te(v)||v.isCollapsed()){a.current=null,s.current=null;return}if(bb(v)){a.current=null,s.current=null;return}let C=xb(v);if(!C||C.start===C.end){a.current=null,s.current=null;return}let y=gt().getTextContent();if(ub(y,C.start,C.end)){a.current=null,s.current=null;return}let x={value:y,expandedStart:C.start,expandedEnd:C.end};a.current=x,s.current=null})},d=g=>{if(g.inputType==="insertCompositionText"&&g.data==="`"&&AD!==null&&a.current){s.current=a.current;return}if(s.current||g.inputType==="insertCompositionText")return;if(typeof g.data!="string"){a.current=null;return}let v=g.inputType==="insertText"?g.data:null;if(!v||v.length!==1){a.current=null;return}i(v)&&(g.preventDefault(),g.stopPropagation(),g.stopImmediatePropagation())},u=g=>{queueMicrotask(()=>{t.update(()=>{let v=s.current;if(!v)return;let C=gt().getTextContent(),y=AD;if(y===null){s.current=null;return}let x=`${v.value.slice(0,v.expandedStart)}\`${v.value.slice(v.expandedEnd)}`;if(C!==x){g?.finalAttempt&&(a.current=null,s.current=null);return}let b=v.value.slice(v.expandedStart,v.expandedEnd),T=Un(C,v.expandedStart);fd(T,T+1);let I=Ee();if(!Te(I)){a.current=null,s.current=null;return}I.insertText(`\`${b}${y}`),fd(T+1,T+1+b.length),a.current=null,s.current=null},{tag:mo})})},f=g=>{let v=g;(v.inputType==="insertText"||v.inputType==="insertCompositionText")&&u()},p=()=>{u({finalAttempt:!0})},m=null,h=t.registerRootListener((g,v)=>{v?.removeEventListener("keydown",l),v?.removeEventListener("beforeinput",d,!0),v?.removeEventListener("input",f),v?.removeEventListener("compositionend",p),g?.addEventListener("keydown",l),g?.addEventListener("beforeinput",d,!0),g?.addEventListener("input",f),g?.addEventListener("compositionend",p),m=g});return()=>{m&&(m.removeEventListener("keydown",l),m.removeEventListener("beforeinput",d,!0),m.removeEventListener("input",f),m.removeEventListener("compositionend",p)),h()}},[t]),null}var r7=`composer-editor-${Math.random().toString(36).slice(2)}`,wb="relative [font-family:var(--font-composer,var(--font-sans))] [font-size:var(--font-size-prompt,0.875rem)] [@media(max-width:39.999rem)_and_(pointer:coarse)]:[font-size:max(var(--font-size-prompt,1rem),16px)]",Ib="block max-h-50 min-h-17.5 w-full overflow-y-auto whitespace-pre-wrap wrap-break-word bg-transparent leading-relaxed text-foreground focus:outline-none";function a7({documentKey:e,value:t,cursor:n,terminalContexts:o,skills:r,disabled:a,placeholder:s,className:i,ariaLabel:l,onRemoveTerminalContext:d,onChange:u,onCommandKeyDown:f,onPaste:p,editorRef:m}){let[h]=Vt(),g=M(u);g.current=u;let v=Zo(t,n),C=La(e,t,{cursor:v,expandedCursor:Mo(t,v)}),y=Zo(t,C.cursor),x=aD(o),b=M(x),T=sD(r),I=M(T),P=M(zi(r)),k=Oi(),S=M({value:t,cursor:y,expandedCursor:C.expandedCursor,selection:C.selection,terminalContextIds:o.map(O=>O.id)}),L=M(e),R=C.history,_=M(!1),E=$(()=>({onRemoveTerminalContext:d}),[d]);me(()=>{P.current=zi(r)},[r]),z(()=>{h.setEditable(!a)},[a,h]),me(()=>{let O=Zo(t,n),Z=S.current,N=L.current,B=N!==e,ue=b.current!==x,U=I.current!==T;if(!B&&Z.value===t&&Z.cursor===O&&!ue&&!U)return;if(B){let ae=Z.selection;h.getEditorState().read(()=>{ae=Qg(ae)}),dd(N,Z.value,{cursor:Z.cursor,expandedCursor:Z.expandedCursor,selection:ae})}let oe=La(e,t),Q=B?oe.selection:{anchor:O,focus:O};S.current={value:t,cursor:B?oe.cursor:O,expandedCursor:B?oe.expandedCursor:Mo(t,O),selection:Q,terminalContextIds:o.map(ae=>ae.id)},L.current=e,b.current=x,I.current=T;let V=h.getRootElement(),W=!!(V&&document.activeElement===V);if(!B&&Z.value===t&&!ue&&!U&&!W)return;let ee=B?La(N,Z.value).history:null;_.current=!0;let ie=t==="",J=()=>h.update(()=>{let ae=B||Z.value!==t||ue||U;ae&&Qu(t,o,P.current,k.current),B?fd(Q.anchor,Q.focus):(ae||W)&&Ra(O)},{discrete:!0,tag:ie?[mo,px,OM]:mo});ee?uD(ee,J):J(),ie&&W&&requestAnimationFrame(()=>setTimeout(()=>{document.activeElement===h.getRootElement()&&h.update(()=>{let ae=Ee();Te(ae)&&(ae.dirty=!0)},{tag:[mo,px]})},0)),dd(e,t,S.current),queueMicrotask(()=>{_.current=!1})},[n,e,h,T,o,x,t]);let D=A(O=>{let Z=h.getRootElement();if(!Z)return;let N=Zo(S.current.value,O);Z.focus({preventScroll:!0}),h.update(()=>{Ra(N)}),S.current={value:S.current.value,cursor:N,expandedCursor:Mo(S.current.value,N),selection:{anchor:N,focus:N},terminalContextIds:S.current.terminalContextIds},dd(L.current,S.current.value,{cursor:S.current.cursor,expandedCursor:S.current.expandedCursor,selection:S.current.selection}),g.current(S.current.value,N,S.current.expandedCursor,!1,S.current.terminalContextIds)},[h]),H=A(()=>{let O=S.current;return h.getEditorState().read(()=>{let Z=gt().getTextContent(),N=Zo(Z,S.current.cursor),B=Zo(Z,Hi(N)),ue=Gu(Z,S.current.expandedCursor),U=Gu(Z,Sb(ue)),oe=Xg(gt()),Q=Qg(S.current.selection);O={value:Z,cursor:B,expandedCursor:U,selection:Q,terminalContextIds:oe}}),S.current=O,dd(L.current,O.value,O),O},[h]);Bo(m,()=>({focus:()=>{D(S.current.cursor)},focusAt:D,focusAtEnd:()=>{D(Un(S.current.value,S.current.value.length))},readSnapshot:H,readSelectedTextLength:()=>iD(h),removeSelectedText:()=>lD(h)}),[h,D,H]);let K=A(O=>{O.read(()=>{let Z=gt().getTextContent(),N=Zo(Z,S.current.cursor),B=Zo(Z,Hi(N)),ue=Gu(Z,S.current.expandedCursor),U=Gu(Z,Sb(ue)),oe=Xg(gt()),Q=Qg(S.current.selection),V=S.current;if(V.value===Z&&V.cursor===B&&V.expandedCursor===U&&V.selection.anchor===Q.anchor&&V.selection.focus===Q.focus&&V.terminalContextIds.length===oe.length&&V.terminalContextIds.every((ee,ie)=>ee===oe[ie])||_.current)return;S.current={value:Z,cursor:B,expandedCursor:U,selection:Q,terminalContextIds:oe},dd(L.current,Z,{cursor:B,expandedCursor:U,selection:Q});let W=sd(Z,B,"left")||sd(Z,B,"right");g.current(Z,B,U,W,oe)})},[]);return c(qg,{value:E,children:w("div",{className:wb,children:[c(W_,{contentEditable:c(FN,{className:G(Ib,i),"data-testid":"composer-editor","data-composer-prompt":"true",spellCheck:!1,autoCorrect:"off",autoCapitalize:"off","aria-placeholder":s,...l?{"aria-label":l}:{},placeholder:c("span",{}),onPasteCapture:p}),placeholder:o.length>0?null:c("div",{className:"pointer-events-none absolute inset-0 select-none leading-relaxed text-placeholder",children:s}),ErrorBoundary:BN}),c(v_,{onChange:K}),c(ID,{...f?{onCommandKeyDown:f}:{}}),c(wD,{}),c(ND,{terminalContexts:o,skills:r}),c(kD,{}),c(TD,{}),c(PD,{}),c(LD,{}),c(ED,{}),c(RD,{}),c(g_,{externalHistoryState:R},e)]})})}function s7(e){let[t]=Vt(),n=M(e),o=M(e),[r,a]=j(e.documentKey);r===e.documentKey&&(n.current=e),o.current=e,me(()=>{r===e.documentKey||t.isComposing()||a(e.documentKey)},[r,t,e.documentKey]),z(()=>{let i=null,l=()=>{let u=o.current.documentKey;a(f=>f===u?f:u)},d=t.registerRootListener((u,f)=>{f?.removeEventListener("compositionend",l),u?.addEventListener("compositionend",l),i=u});return()=>{i?.removeEventListener("compositionend",l),d()}},[t]);let s=r===e.documentKey?e:n.current;return c(a7,{...s})}function md({documentKey:e,value:t,cursor:n,terminalContexts:o,skills:r,disabled:a,placeholder:s,className:i,ariaLabel:l,onRemoveTerminalContext:d,onChange:u,onCommandKeyDown:f,onPaste:p,editorRef:m}){let h=M(t),g=M(o),v=M(zi(r)),C=M(Oi().current),y=$(()=>({namespace:"ycodium-composer-editor",editable:!0,nodes:[Bi,cd,qr,...mb],editorState:()=>{Qu(h.current,g.current,v.current,C.current)},onError:x=>{throw x}}),[]);return c(YM,{initialConfig:y,children:c(s7,{documentKey:e,value:t,cursor:n,terminalContexts:o,skills:r,disabled:a,placeholder:s,onRemoveTerminalContext:d,onChange:u,onPaste:p,editorRef:m,...f?{onCommandKeyDown:f}:{},...i?{className:i}:{},...l?{ariaLabel:l}:{}})},r7)}function _D(e){return typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function"}function DD(e){return _D(e)?Promise.resolve(e).then(DD):e===!1?!1:e==null?!0:e.accepted}function Xu(e,t,n){let o=e.trim().length-t;return o<=0?null:n("composer.promptTooLong",{count:o,excess:o.toLocaleString("en-US"),max:t.toLocaleString("en-US")})}function Tb(e){return e.submissionTarget==="provider-turn"?Xu(e.providerInput??e.prompt,e.maxInputChars,e.t):null}function OD(e){return _D(e)}function FD(e){let t=Tb(e);if(t)return e.event?.preventDefault(),{validationMessage:t,didDispatch:!1};let n=DD(e.onSend(e.event));return typeof n!="boolean"?n.then(o=>(o||e.event?.preventDefault(),{validationMessage:null,didDispatch:o})):(n||e.event?.preventDefault(),{validationMessage:null,didDispatch:n})}var $n=new Map;function i7(e,t,n){return`${e}\0${t}\0${n??"none"}`}function kb(e,t){$n.delete(e),$n.set(e,t)}function gd(e,t){if($n.get(e)===t){if(t.operationLeases>0){t.disposeRequested=!0;return}t.releaseAuthorityWatch?.(),t.releaseAuthorityWatch=void 0,$n.delete(e);for(let n of t.state.added)t.releaseUpload(n.id),URL.revokeObjectURL(n.previewUrl);for(let n of t.listeners)n()}}function l7(e){if($n.size<=100)return;let t=Array.from($n);for(let[n,o]of t){if($n.size<=100)return;n===e||o.committed||o.listeners.size>0||o.operationLeases>0||gd(n,o)}for(let[n,o]of t){if($n.size<=100)return;n===e||o.listeners.size>0||o.operationLeases>0||gd(n,o)}}function Yg(){queueMicrotask(()=>l7())}function BD(e,t,n,o,r=void 0){let a=n.management?.revision??null,s=i7(e,n.intentId,a),i=$n.get(s);if(i)return i.releaseUpload=o.releaseUpload,i.watchAuthority=r,i.state;let l={key:s,inputKey:e,environmentId:t,intentId:n.intentId,revision:a,text:n.management?.text??n.text??"",retained:n.management?.attachments??[],added:[],saving:!1,error:null},d={state:l,listeners:new Set,releaseUpload:o.releaseUpload,operationLeases:0,committed:!1,disposeRequested:!1,watchAuthority:r,releaseAuthorityWatch:void 0};return $n.set(s,d),l}function zD(e,t){let n=$n.get(e);return n?(n.releaseAuthorityWatch===void 0&&n.watchAuthority!==void 0&&(n.releaseAuthorityWatch=n.watchAuthority({threadKey:n.state.inputKey,intentId:n.state.intentId,revision:n.state.revision,onInvalid:()=>gd(e,n)})),n.committed=!0,kb(e,n),n.listeners.add(t),Yg(),()=>{n.listeners.delete(t),Yg()}):()=>{}}function $i(e,t){let n=$n.get(e);if(!n)return;n.committed=!0;let o=t(n.state);if(o!==n.state){n.state=o,kb(e,n);for(let r of n.listeners)r()}}function Jg(e){return $n.get(e)?.state}function HD(e){let t=$n.get(e);if(!t)return null;t.committed=!0,t.operationLeases+=1,kb(e,t);let n=!1;return()=>{if(!n){if(n=!0,t.operationLeases=Math.max(0,t.operationLeases-1),t.operationLeases===0&&t.disposeRequested){gd(e,t);return}Yg()}}}function Zg(e){let t=$n.get(e);t&&gd(e,t)}function UD(e,t){let n=new Map(t.flatMap(o=>o.waiting&&o.management!==void 0?[[o.intentId,o.management.revision]]:[]));for(let[o,r]of $n)r.state.inputKey===e&&n.get(r.state.intentId)!==r.state.revision&&gd(o,r);Yg()}var d7=[],c7=[],u7=()=>{};function $D({entry:e,current:t,inputKey:n,environmentId:o,unavailable:r,attachments:a,watchEditorAuthority:s,onEdit:i,onClose:l}){let{t:d}=rn(),u=BD(n,o,e,a,s),f=Fn(O=>zD(u.key,O),()=>Jg(u.key)??u,()=>Jg(u.key)??u),{key:p,text:m,retained:h,added:g,saving:v,error:C}=f,y=M(null),[x,b]=j(()=>m.length),T=Br()?.data.assistantQuotes??null,I=O=>Xu(T?T.expandForProvider(O):O,a.limits.maxInputChars,d),P=I(m),k=M(null),S=a.useUploadStatuses(),L=$(()=>h.map(O=>O.id),[h]),R=a.useAssetUrls(o,L),_=!t?.management||t.management.revision!==e.management?.revision;z(()=>{t===void 0&&(Zg(p),l())},[t,p,l]);let E=()=>{v||(Zg(p),l())},D=O=>{if(v||r||_)return;let Z=null,N=[...g];for(let B of O){let ue=B.type||"application/octet-stream";if(B.size===0){Z=d("attachments.empty",{name:B.name});continue}let U=a.makeImageAttachment({id:a.randomUUID(),name:B.name,mimeType:ue,sizeBytes:B.size,file:B});N.push(U),a.startUpload({environmentId:o,image:U})}$i(p,B=>({...B,added:N,error:Z}))},H=async()=>{let O=Jg(p);if(!O||O.saving||r||_||!O.text.trim()&&O.retained.length+O.added.length===0||I(O.text)!==null)return;let Z=HD(p);if(Z!==null){$i(p,N=>({...N,saving:!0,error:null}));try{await a.awaitUploads(O.added.map(B=>B.id));let N=a.getUploadedAttachments({environmentId:o,images:O.added});if(!N)throw new Error(d("turnQueue.uploadFailed"));await i(e,{text:O.text,attachments:[...O.retained,...N]}),Zg(p),l()}catch(N){$i(p,B=>({...B,saving:!1,error:N instanceof Error?N.message:d("turnQueue.actionFailed")}))}finally{Z()}}},K=[...h.map((O,Z)=>({...O,previewUrl:R[Z],added:!1})).filter(O=>O.source?._tag!=="thread-reference"),...g.map(O=>({...O,added:!0}))];return c(Cf,{open:!0,onOpenChange:O=>{O||E()},children:w(wf,{className:"max-w-2xl","data-queued-message-editor":!0,initialFocus:()=>(y.current?.focusAtEnd(),!1),children:[w(Sf,{children:[c(If,{children:d("turnQueue.editTitle")}),c(xf,{children:d("turnQueue.editDescription")})]}),w("div",{className:"max-h-[60dvh] space-y-3 overflow-y-auto px-6 pb-4",onDragOver:O=>{O.dataTransfer.types.includes("Files")&&O.preventDefault()},onDrop:O=>{O.dataTransfer.files.length&&(O.preventDefault(),O.stopPropagation(),D(Array.from(O.dataTransfer.files)))},children:[c("div",{className:"rounded-lg border border-input bg-background px-3 py-2 focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/24",children:c(md,{editorRef:y,documentKey:`queue-editor\0${p}`,value:m,cursor:x,terminalContexts:d7,skills:c7,disabled:v,placeholder:d("turnQueue.editText"),ariaLabel:d("turnQueue.editText"),className:"max-h-[40dvh]",onRemoveTerminalContext:u7,onChange:(O,Z)=>{b(Z),$i(p,N=>({...N,text:O}))},onCommandKeyDown:(O,Z)=>O!=="Enter"||!(Z.metaKey||Z.ctrlKey)?!1:(H(),!0),onPaste:O=>{O.clipboardData.files.length&&(O.preventDefault(),D(Array.from(O.clipboardData.files)))}})}),P?c("p",{role:"alert",className:"text-sm text-destructive-foreground",children:P}):null,c("ul",{className:"flex flex-wrap gap-2",children:K.map(O=>w("li",{className:"flex max-w-full items-center gap-2 rounded-md border border-border px-2 py-1.5",children:[O.type==="image"&&O.previewUrl?c("img",{src:O.previewUrl,alt:O.name,className:"size-12 rounded object-cover"}):c(Io,{className:"size-4 shrink-0"}),w("div",{className:"min-w-0 text-xs",children:[c("p",{className:"max-w-48 break-words",children:O.name}),c("p",{className:"text-muted-foreground",children:a.formatAttachmentSize(O.sizeBytes)}),O.added&&S.get(O.id)!=="ready"?c("p",{children:d(S.get(O.id)==="failed"?"turnQueue.uploadFailed":"turnQueue.uploading")}):null,O.added&&S.get(O.id)==="failed"?c(re,{size:"xs",variant:"ghost",disabled:v||r||_,onClick:()=>{let Z=g.find(N=>N.id===O.id);Z&&a.retryUpload({environmentId:o,image:Z})},children:d("turnQueue.retryUpload")}):null]}),c(re,{size:"icon-xs",variant:"ghost","aria-label":d("turnQueue.removeAttachment",{name:O.name}),disabled:v||_,onClick:()=>{O.added?(a.releaseUpload(O.id),O.previewUrl&&URL.revokeObjectURL(O.previewUrl),$i(p,Z=>({...Z,added:Z.added.filter(N=>N.id!==O.id)}))):$i(p,Z=>({...Z,retained:Z.retained.filter(N=>N.id!==O.id)}))},children:c(Kt,{className:"size-3.5"})})]},O.id))}),c("input",{ref:k,type:"file",multiple:!0,className:"hidden","aria-label":d("turnQueue.addAttachments"),onChange:O=>{D(Array.from(O.target.files??[])),O.target.value=""}}),w(re,{size:"sm",variant:"outline",disabled:v||r||_,onClick:()=>k.current?.click(),children:[c(Io,{className:"size-4"}),d("turnQueue.addAttachments")]}),_?c("p",{role:"alert",className:"text-sm text-muted-foreground",children:d("turnQueue.editStale")}):null,C?c("p",{role:"alert",className:"text-sm text-destructive-foreground",children:C}):null]}),w(bf,{children:[c(re,{variant:"ghost",disabled:v,onClick:E,children:d("turnQueue.discardEdit")}),c(re,{disabled:v||r||_||P!==null||!m.trim()&&K.length===0,onClick:()=>{H()},children:d(v?"turnQueue.saving":"turnQueue.saveEdit")})]})]})})}X();var Sr=["approval-required","auto-accept-edits","auto","full-access"];var f7={"approval-required":ec,"auto-accept-edits":Rr,auto:Wa,"full-access":Va},p7={"approval-required":"approvalRequired","auto-accept-edits":"autoAcceptEdits",auto:"auto","full-access":"fullAccess"};function hd(){let{t:e}=le();return A(t=>{let n=p7[t];return{mode:t,label:e(`runtimeMode.${n}`),description:e(`runtimeMode.${n}Description`),icon:f7[t]}},[e])}function KD(e){let{t}=rn(),n=hd(),{interactionMode:o,runtimeMode:r,nativeModeName:a}=e.sentWith,s=[o===void 0?null:t(o==="plan"?"turnQueue.sentWithPlan":"turnQueue.sentWithNoPlan"),a??(r===void 0?null:n(r).label)].filter(i=>i!=null);return c("p",{className:"text-muted-foreground","data-queued-sent-with":!0,children:t("turnQueue.sentWith",{modes:s.join(" \xB7 ")})})}function VD(e,t){let n=e.find(a=>a.intentId===t.intentId);if(!n)return e;let o=e.filter(a=>a.intentId!==t.intentId),r=t.beforeIntentId===null?o.length:o.findIndex(a=>a.intentId===t.beforeIntentId);return r<0?e:(o.splice(r,0,n),o)}function qD(e,t,n){if(t===n)return null;let o={intentId:t,beforeIntentId:n,previousOrder:e.map(a=>a.intentId)};return VD(e,o).every((a,s)=>a.intentId===e[s]?.intentId)?null:o}function WD(e,t){if(!e.find(l=>l.intentId===t.intentId)?.management?.canReorder||t.beforeIntentId!==null&&!e.some(l=>l.intentId===t.beforeIntentId))return{entries:e,settled:!0};let o=new Set(e.map(l=>l.intentId)),r=new Set(t.previousOrder),a=t.previousOrder.filter(l=>o.has(l));return e.filter(l=>r.has(l.intentId)).some((l,d)=>l.intentId!==a[d])?{entries:e,settled:!0}:{entries:VD(e,t),settled:!1}}X();X();function m7({entry:e,unavailable:t,onCancel:n}){let{t:o}=rn(),r=M(!1),[a,s]=j(!1),[i,l]=j(!1),[d,u]=j(!1);z(()=>{u(!1),l(!1)},[e.status,e.deliveryCertainty]);let f=async()=>{if(!(r.current||t||e.action===null)){r.current=!0,s(!0),l(!1);try{await n(e),u(!1)}catch{l(!0)}finally{r.current=!1,s(!1)}}};return w("li",{className:"space-y-2 border-t border-border py-2","data-turn-queue-message":!0,children:[c("p",{className:"text-muted-foreground",children:o(e.deliveryCertainty==="unknown"?"turnQueue.itemUnknown":e.status==="queued"?"turnQueue.itemQueued":e.status==="blocked"||e.status==="reconciling"?"turnQueue.itemBlocked":"turnQueue.itemRunning")}),c("p",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e.text??o("turnQueue.messageUnavailable")}),e.attachmentNames.length>0?c("p",{className:"break-words text-muted-foreground",children:e.attachmentNames.join(", ")}):null,e.action!==null?d&&e.action==="abandon"?w("div",{className:"space-y-2",children:[c("p",{children:o("turnQueue.abandonDescription")}),w("div",{className:"flex flex-wrap gap-2",children:[c(re,{size:"xs",variant:"outline",disabled:a||t,onClick:()=>{f()},children:o("turnQueue.confirmAbandon")}),c(re,{size:"xs",variant:"ghost",disabled:a,onClick:()=>u(!1),children:o("turnQueue.keepWaiting")})]})]}):c(re,{size:"xs",variant:"outline",disabled:a||t,onClick:()=>e.action==="abandon"?u(!0):void f(),children:o(a?"turnQueue.cancelling":e.action==="abandon"?"turnQueue.stopWaiting":"turnQueue.cancelMessage")}):null,i?c("p",{role:"alert",className:"text-destructive-foreground",children:o("turnQueue.actionFailed")}):null]})}function GD({entries:e,unavailable:t,onCancel:n,autoExpand:o=!1}){let{t:r}=rn(),[a,s]=j(null),i=a??o,l=Fo();return e.length===0?null:w("div",{className:"min-w-0 basis-full space-y-2",children:[c(re,{size:"xs",variant:"ghost","aria-expanded":i,"aria-controls":l,onClick:()=>s(!i),children:r(i?"turnQueue.hideMessages":"turnQueue.showMessages")}),i?c("ol",{id:l,className:"max-h-64 overflow-y-auto overscroll-contain",children:e.map(d=>c(m7,{entry:d,unavailable:t,onCancel:n},d.intentId))}):null]})}function Pb({queue:e,unavailable:t=!1,onResume:n,entries:o,onCancel:r}){let{t:a}=rn(),s=M(!1),[i,l]=j(!1),[d,u]=j(!1);z(()=>{e.paused||u(!1)},[e.paused]);let f=e.deliveryUncertain||e.blocked||e.reconciling;if(!e.paused&&!f)return null;let p=o?.[0]?.action==="abandon"&&(e.reconciling||e.deliveryUncertain),m=e.paused?a("turnQueue.pausedTitle"):e.deliveryUncertain?a("turnQueue.uncertainTitle"):e.blocked?a("turnQueue.blockedTitle"):e.reconciling?a("turnQueue.reconcilingTitle"):a("turnQueue.queuedTitle"),h=e.deliveryUncertain?a("turnQueue.uncertainDescription"):e.blocked?a("turnQueue.blockedDescription"):e.reconciling?a("turnQueue.reconcilingDescription"):e.paused?a("turnQueue.pausedDescription"):a("turnQueue.queuedDescription"),g=async()=>{if(!(s.current||t||!e.paused)){s.current=!0,l(!0),u(!1);try{await n()}catch{u(!0)}finally{s.current=!1,l(!1)}}};return w("div",{className:"mx-auto mb-2 flex w-full max-w-3xl select-none flex-wrap items-start gap-2 rounded-md border border-warning/40 bg-background px-3 py-2 text-xs text-foreground","data-turn-queue-banner":!0,role:"status",children:[w("div",{className:"min-w-0 flex-1 basis-48 space-y-1",children:[c("p",{className:"font-medium",children:m}),c("p",{className:"text-muted-foreground",children:h}),e.paused&&f?c("p",{className:"text-muted-foreground",children:a("turnQueue.pausedUncertainDescription")}):null,t?c("p",{className:"text-muted-foreground",children:a("turnQueue.disconnected")}):null,d&&e.paused?c("p",{className:"text-destructive-foreground",role:"alert",children:a("turnQueue.resumeFailed")}):null]}),e.paused?c(re,{size:"xs",variant:"outline",disabled:i,softDisabled:t,onClick:()=>{g()},children:a(i?"turnQueue.resuming":"turnQueue.resume")}):null,r&&o?c(GD,{entries:o.filter(v=>v.status!=="queued"),unavailable:t,onCancel:r,autoExpand:p}):null]})}var g7=[aR,rR],h7=[];function v7({submission:e}){let{t}=rn();return w("li",{"data-queue-pending-message":e.messageId,className:"flex items-center gap-1.5 border-t border-border/50 px-2 py-1.5",children:[c("span",{"aria-hidden":"true",className:"grid size-6 shrink-0 place-items-center",children:c("span",{className:"size-1.5 rounded-full bg-muted-foreground/60"})}),w("div",{className:"min-w-0 flex-1",children:[c("p",{className:"line-clamp-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:Gv(e.text)||t("turnQueue.attachmentsOnly")}),e.attachmentNames.length?w("p",{className:"flex items-center gap-1 text-muted-foreground",children:[c(Io,{className:"size-3 shrink-0"}),c("span",{className:"truncate",children:e.attachmentNames.join(", ")})]}):null]}),c("span",{role:"status",className:"w-[5.25rem] shrink-0 text-end text-muted-foreground",children:t("primaryActions.sendingButtonLabel")})]})}function y7({entry:e,disabled:t,dropPosition:n,dragPosition:o,feedback:r,reducedMotion:a,children:s}){let{t:i}=rn(),{attributes:l,listeners:d,setNodeRef:u,setActivatorNodeRef:f,transform:p,transition:m,isDragging:h}=tR({id:e.intentId,disabled:t,transition:a?null:{duration:160,easing:"ease-out"}});return w("li",{ref:u,"data-queue-intent":e.intentId,"data-queue-dragging":h||void 0,"data-queue-feedback":r,style:{transform:ns.Transform.toString(p),transition:m},className:G("relative flex items-center gap-1.5 border-t border-border/50 px-2 py-1.5",h&&"z-10 bg-accent shadow-md ring-1 ring-primary/50 ring-inset",r==="saved"&&"bg-primary/10 ring-1 ring-primary/30 ring-inset",r==="failed"&&"bg-destructive/10"),children:[n?c("span",{"aria-hidden":"true","data-queue-drop-position":n,className:G("pointer-events-none absolute inset-x-1 z-20 h-0.5 rounded-full bg-primary before:absolute before:-top-0.5 before:start-0 before:size-1.5 before:rounded-full before:bg-primary",n==="before"?"top-0":"bottom-0")}):null,c(re,{ref:f,size:"icon-xs",variant:"ghost",className:G("shrink-0 touch-none cursor-grab text-muted-foreground active:cursor-grabbing",(h||r==="saved")&&"bg-primary/10 text-primary"),...l,...d,"aria-label":i("turnQueue.reorderMessage"),title:i("turnQueue.reorderMessage"),softDisabled:t,children:r==="saved"?c(Wn,{className:"size-3.5"}):c(jd,{className:"size-3.5"})}),s,h&&o?c("span",{"aria-hidden":"true","data-queue-drag-position":!0,className:"pointer-events-none absolute end-3 rounded bg-primary/10 px-2 py-1 font-medium text-primary tabular-nums",children:o}):null]})}function jD({inputKey:e,entries:t,pendingSubmissions:n=h7,environmentId:o,unavailable:r,attachments:a,actions:s,onCancel:i}){let{t:l}=rn(),d=dm("(prefers-reduced-motion: reduce)"),[u,f]=Mt("turn-queue:editing",e,null),[p,m]=Mt("turn-queue:pending",e,!1),h=at("turn-queue:pending-ref",e,!1),[g,v]=Mt("turn-queue:error",e,null),[C,y]=Mt("turn-queue:drag",e,null),[x,b]=Mt("turn-queue:move",e,null),T=at("turn-queue:reorder-ref",e,!1),[I,P]=Mt("turn-queue:feedback",e,null),k=PL(ky(Ll,{activationConstraint:{distance:5}}),ky(Pl,{coordinateGetter:nR,scrollBehavior:d?"auto":"smooth"})),S=$(()=>t.filter(N=>N.waiting),[t]),L=x?WD(S,x.preview):null,R=L?.entries??S,_=R.length+n.length,E=r||p||x!==null,D=R.findIndex(N=>N.intentId===C?.activeId),H=R.findIndex(N=>N.intentId===C?.overId);z(()=>{UD(e,t)},[t,e]),z(()=>{x!==null&&(r||x.acknowledged&&L?.settled)&&(T.current=!1,b(null),!r&&S.some(N=>N.intentId===x.preview.intentId)&&P({intentId:x.preview.intentId,kind:"saved"}))},[S,x,L?.settled,r]),z(()=>{if(I===null||I.kind==="failed")return;let N=window.setTimeout(()=>P(B=>B===I?null:B),1600);return()=>window.clearTimeout(N)},[I]);let K=async N=>{if(!(h.current||T.current||r)){h.current=!0,m(!0),v(null),P(null);try{await N()}catch(B){v(B instanceof Error?B.message:l("turnQueue.actionFailed"))}finally{h.current=!1,m(!1)}}},O=(N,B)=>K(async()=>{let ue=qD(S,N.intentId,B);if(!(ue===null||!N.management?.canReorder)){T.current=!0,b({preview:ue,acknowledged:!1});try{await s.onReorder(N,B),b(U=>U?.preview===ue?{...U,acknowledged:!0}:U)}catch(U){throw T.current=!1,b(null),P({intentId:N.intentId,kind:"failed"}),U}}}),Z=r?l("turnQueue.disconnected"):x!==null?l("turnQueue.saving"):C!==null?`${l("turnQueue.dragStarted")} ${H+1}/${R.length}`:I?.kind==="saved"?l("common.action.done"):I?.kind==="cancelled"?l("turnQueue.dragCancelled"):"";return w(he,{children:[_>0?w("section",{"aria-label":l("turnQueue.pendingMessages"),"data-turn-queue-dock":!0,className:"mx-auto mb-2 w-full max-w-3xl overflow-hidden rounded-xl border border-border/60 bg-background/95 text-xs shadow-xs",children:[w("div",{className:"flex h-7 items-center justify-between gap-3 px-3 py-1.5 text-muted-foreground",children:[c("span",{className:"shrink-0",children:l("turnQueue.queued",{count:_})}),c("span",{role:"status","aria-live":C===null?"polite":"off","data-queue-reorder-status":x?"saving":I?.kind,className:G("min-w-0 truncate",I?.kind==="saved"&&"text-primary"),children:Z})]}),c(VL,{sensors:k,collisionDetection:EL,modifiers:g7,accessibility:{screenReaderInstructions:{draggable:l("turnQueue.dragInstructions")},announcements:{onDragStart:()=>l("turnQueue.dragStarted"),onDragOver:({over:N})=>{let B=R.findIndex(ue=>ue.intentId===N?.id);return B<0?void 0:`${l("turnQueue.dragStarted")} ${B+1}/${R.length}`},onDragEnd:()=>l("turnQueue.dragFinished"),onDragCancel:()=>l("turnQueue.dragCancelled")}},onDragStart:({active:N})=>{let B=R.find(ue=>ue.intentId===N.id);!B?.management?.canReorder||E||(v(null),P(null),y({activeId:B.intentId,overId:B.intentId}))},onDragOver:({over:N})=>{let B=R.find(ue=>ue.intentId===N?.id);B&&y(ue=>ue&&{...ue,overId:B.intentId})},onDragCancel:()=>{C&&P({intentId:C.activeId,kind:"cancelled"}),y(null)},onDragEnd:({active:N,over:B})=>{if(y(null),!B||N.id===B.id)return;let ue=R.findIndex(V=>V.intentId===N.id),U=R.findIndex(V=>V.intentId===B.id),oe=R[ue];if(!oe?.management?.canReorder||U<0)return;let Q=R[U+(ue<U?1:0)]?.intentId??null;O(oe,Q)},children:c(ZL,{items:R.map(N=>N.intentId),strategy:XL,children:w("ol",{className:"max-h-52 overflow-x-hidden overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",children:[R.map((N,B)=>w(y7,{entry:N,disabled:!N.management?.canReorder||E,reducedMotion:d,feedback:I?.intentId===N.intentId?I.kind:void 0,dropPosition:N.intentId===C?.overId&&D!==H?D<H?"after":"before":void 0,dragPosition:N.intentId===C?.activeId?`${H+1}/${R.length}`:void 0,children:[w("div",{className:"min-w-0 flex-1",children:[c("p",{className:"line-clamp-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:Gv(N.text??"")||l("turnQueue.attachmentsOnly")}),N.attachmentNames.length?w("p",{className:"flex items-center gap-1 text-muted-foreground",children:[c(Io,{className:"size-3 shrink-0"}),c("span",{className:"truncate",children:N.attachmentNames.join(", ")})]}):null,N.pendingAction?c("p",{className:"text-muted-foreground",children:l(N.pendingAction==="steer"?"turnQueue.steering":"turnQueue.interrupting")}):null,N.sentWith?c(KD,{sentWith:N.sentWith}):null,N.failure?c("p",{role:"alert",className:"text-destructive-foreground",children:N.failure}):null]}),w("div",{className:G("flex shrink-0 items-center gap-0.5",N.intentId===C?.activeId&&"invisible"),children:[c(re,{size:"icon-xs",variant:"ghost",disabled:!N.management||E||C!==null,"aria-label":l("turnQueue.editMessage"),title:l("turnQueue.editMessage"),onClick:()=>f(N),children:c(ac,{className:"size-3.5"})}),N.management?.canSteer?c(re,{size:"icon-xs",variant:"ghost",disabled:E||C!==null,"data-turn-queue-steer":"","aria-label":l("turnQueue.steer"),title:l("turnQueue.steerDescription"),onClick:()=>{K(()=>s.onRun(N,"steer"))},children:c(ic,{className:"size-3.5"})}):null,w(ro,{children:[c(so,{render:c(re,{size:"icon-xs",variant:"ghost",disabled:E||!N.management||C!==null,"aria-label":l("turnQueue.messageActions")}),children:c(Ho,{className:"size-4"})}),w(ao,{align:"end",children:[w(Uo,{disabled:!N.management?.canReorder||B===0,onClick:()=>{O(N,R[B-1].intentId)},children:[c(Od,{className:"size-4"}),l("turnQueue.moveUp")]}),w(Uo,{disabled:!N.management?.canReorder||B===R.length-1,onClick:()=>{O(N,R[B+2]?.intentId??null)},children:[c(Nd,{className:"size-4"}),l("turnQueue.moveDown")]}),N.management?.canSteer?c(Uo,{onClick:()=>{K(()=>s.onRun(N,"steer"))},children:l("turnQueue.steer")}):null,c(Uo,{disabled:!N.management?.canRun,onClick:()=>{K(()=>s.onRun(N,"interrupt"))},children:l(N.management?.expectedTurnId?"turnQueue.interruptAndRun":"turnQueue.sendNext")}),c(sa,{}),c(Uo,{disabled:N.action!=="cancel",onClick:()=>{K(()=>i(N))},children:l("turnQueue.cancelMessage")})]})]})]})]},N.intentId)),n.map(N=>c(v7,{submission:N},N.messageId))]})})},e),g?c("p",{role:"alert",className:"px-3 py-2 text-destructive-foreground",children:g}):null]}):null,u?c($D,{entry:u,current:t.find(N=>N.intentId===u.intentId),inputKey:e,environmentId:o,unavailable:E,attachments:a,watchEditorAuthority:s.watchEditorAuthority,onEdit:s.onEdit,onClose:()=>f(null)},`${e}\0${u.intentId}\0${u.management?.revision??"none"}`):null]})}function QD({data:e,target:t,inputKey:n,attachments:o}){let r=e.useQueue({target:t,threadKey:n}),{environmentId:a,threadId:s}=t,i=e.queue,l=$(()=>{let u={environmentId:a,threadId:s};return{actions:{onEdit:(p,m)=>i.edit(u,p,m),onReorder:(p,m)=>i.reorder(u,p,m),onRun:(p,m)=>i.run(u,p,m),watchEditorAuthority:i.watchEditorAuthority},onCancel:p=>i.cancel(u,p),onResume:()=>i.resume(u)}},[i,a,s]),d=$(()=>({data:e,target:t,threadKey:`${n}\0queue-editor`}),[e,t,n]);return w(he,{children:[c(Qp,{value:d,children:c(jD,{inputKey:n,actions:l.actions,attachments:o,entries:r.entries,pendingSubmissions:r.pendingSubmissions,environmentId:a,onCancel:l.onCancel,unavailable:r.unavailable})}),c(Pb,{entries:r.entries,onCancel:l.onCancel,onResume:l.onResume,queue:r.state,unavailable:r.unavailable})]})}X();function vd(e){return e.id??e.label}function Lb(e,t){return Array.from(new Set((t??[]).flatMap(n=>{let o=e.options.find(r=>r.id!==void 0?r.id===n:r.label===n.trim());return o?[vd(o)]:[]})))}var XD=fe(function(t){let n=t.data.useQuestions(t.target);return n.pending.length===0?null:c("div",{"data-async-question-stack":!0,className:"mx-auto mb-2 flex max-h-[45vh] w-full max-w-3xl flex-col gap-2 overflow-y-auto overscroll-contain",children:n.pending.toReversed().map(o=>c(x7,{pending:o,actions:n},o.requestId))})});function C7(e,t,n){let o={};for(let r of e.questions){let a=n[r.id]?.trim()??"",s=t[r.id]??[];if(a.length>0)o[r.id]=a;else if(s.length>0)o[r.id]=r.multiSelect?s:s[0];else return null}return o}var x7=fe(function(t){let{pending:n,actions:o}=t,{t:r}=le(),[a,s]=j({}),[i,l]=j({}),[d,u]=j(!1),[f,p]=j(null),m=C7(n,a,i),h=C=>{u(!0),p(null),C().then(y=>{u(!1),p(y)})},g=()=>{m===null||d||h(()=>o.answer(n.requestId,m))},v=(C,y,x)=>s(b=>{let T=b[C]??[],I=T.includes(y)?T.filter(P=>P!==y):x?[...T,y]:[y];return{...b,[C]:I}});return w("section",{"data-async-question":n.requestId,"aria-label":r("asyncQuestion.title"),className:"overflow-hidden rounded-xl border border-border/60 bg-background/95 px-3 py-2 text-sm shadow-xs",children:[w("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c(qa,{"aria-hidden":!0,className:"size-icon-1 shrink-0"}),c("span",{className:"font-medium",children:r("asyncQuestion.title")})]}),n.questions.map(C=>{let y=a[C.id]??[],x=i[C.id]??"";return w("div",{className:"mt-2","data-async-question-item":C.id,children:[c("p",{className:"whitespace-pre-wrap break-words text-foreground/85",children:C.question}),C.multiSelect?c("p",{className:"mt-0.5 text-xs text-secondary-label",children:r("pendingUserInput.selectOneOrMore")}):null,C.options.length>0?c("div",{className:"mt-1.5 flex flex-wrap gap-1",children:C.options.map(b=>{let T=vd(b),I=x.trim().length===0&&y.includes(T);return w(re,{size:"xs",variant:I?"secondary":"outline","aria-pressed":I,"data-async-question-option":T,disabled:d,onClick:()=>v(C.id,T,C.multiSelect===!0),children:[I?c(Wn,{"aria-hidden":!0,className:"size-icon-1"}):null,b.label]},T)})}):null,c(Ar,{type:"text",value:x,disabled:d,placeholder:r("asyncQuestion.answerPlaceholder"),"aria-label":r("asyncQuestion.answerLabel",{question:C.question}),className:"mt-1.5 h-8",onChange:b=>l(T=>({...T,[C.id]:b.target.value})),onKeyDown:b=>{b.key!=="Enter"||b.nativeEvent.isComposing||(b.preventDefault(),g())}})]},C.id)}),f?c("p",{role:"alert",className:"mt-1.5 text-xs text-destructive-foreground",children:f}):null,w("div",{className:G("mt-2 flex items-center justify-end gap-1"),children:[c(re,{size:"xs",variant:"ghost",disabled:d,onClick:()=>h(()=>o.dismiss(n.requestId)),children:r("asyncQuestion.dismiss")}),c(re,{size:"xs","data-async-question-submit":"",disabled:d||m===null,onClick:g,children:r("asyncQuestion.answer")})]})]})});X();var Rb=220,b7={opacity:0,transform:"translate3d(0, 4rem, 0)"},S7={opacity:0,transform:"translate3d(0, 7rem, 0)"},YD={opacity:1,transform:"none"},JD={transition:`transform ${Rb}ms ease-in, opacity ${Rb}ms ease-in`},w7={default:"border-[var(--chat-composer-attached-outline)]",error:"border-destructive/24",info:"border-info/24",success:"border-success/24",warning:"border-warning/24"};function e1({className:e,items:t}){let{t:n}=le(),[o,r]=j(null),a=M(null),s=o!==null&&t.some(m=>m.id===o)?o:null;if(z(()=>()=>{a.current&&clearTimeout(a.current)},[]),t.length===0)return null;let i=t[0];if(!i)return null;let l=t.slice(1),d=l.length>0,u=d&&s!==i.id,f=l[0],p=m=>{!m.onDismiss||s||(r(m.id),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,m.onDismiss?.()},Rb))};return c("div",{className:G("group/banner-stack chat-composer-drawer-slot",e),"data-composer-banner-drawer":"true",children:w("div",{className:G("relative flex flex-col-reverse",d?"group-hover/banner-stack:z-50 group-focus-within/banner-stack:z-50":null),children:[u&&f?c("div",{className:G("pointer-events-none absolute inset-x-0 -top-3 z-0 mx-auto h-3 rounded-t-2xl","chat-composer-banner-stack-cap border border-b-0 shadow-[0_6px_18px_rgba(0,0,0,0.06)]",w7[f.variant],"transition-opacity duration-150 ease-out","group-hover/banner-stack:opacity-0 group-focus-within/banner-stack:opacity-0"),style:{width:"96%"},"aria-hidden":"true"}):null,c("div",{className:G("relative z-10",s===i.id?"pointer-events-none":null),style:{...JD,...s===i.id?b7:YD},children:c(ZD,{item:i,attached:!0,exiting:s===i.id,onDismissRequest:()=>p(i)})}),d?c("div",{"data-composer-banner-stack-expanded-items":"true",className:G("relative z-20 grid grid-rows-[0fr] transition-[grid-template-rows] duration-150 ease-out","group-hover/banner-stack:grid-rows-[1fr] group-focus-within/banner-stack:grid-rows-[1fr]"),children:c("div",{className:"min-h-0 overflow-hidden",children:c("div",{className:G("invisible pointer-events-none space-y-2 pb-2 opacity-0","translate-y-1 transform-gpu transition-[opacity,transform] duration-150 ease-out will-change-[opacity,transform]","group-hover/banner-stack:visible group-hover/banner-stack:pointer-events-auto group-hover/banner-stack:translate-y-0 group-hover/banner-stack:opacity-100","group-focus-within/banner-stack:visible group-focus-within/banner-stack:pointer-events-auto group-focus-within/banner-stack:translate-y-0 group-focus-within/banner-stack:opacity-100"),children:l.map(m=>c("div",{className:G(s===m.id?"pointer-events-none":null),style:{...JD,...s===m.id?S7:YD},children:c(ZD,{item:m,attached:!1,exiting:s===m.id,onDismissRequest:()=>p(m)})},m.id))})})}):null]})})}function ZD({item:e,attached:t,exiting:n,onDismissRequest:o}){let{t:r}=le(),a=e.onDismiss&&!e.actions;return e.presentation==="compact"?w(gc,{variant:e.variant,role:"status",className:G("min-h-0 px-3 text-xs sm:px-4",t?"chat-composer-drawer-surface chat-composer-drawer-attached pt-1.5 pb-[calc(var(--chat-composer-attachment-overlap)_+_0.25rem)]":"alert-glass rounded-[22px] py-1.5",e.className),"data-composer-banner-presentation":"compact","data-composer-banner-id":e.id,"data-variant":e.variant,children:[e.icon,w(Mh,{className:"flex min-w-0 items-baseline gap-1.5 font-normal leading-5",children:[c("span",{className:"shrink-0 font-medium text-foreground",children:e.title}),e.description?c("span",{className:"min-w-0 truncate text-muted-foreground",children:e.description}):null]}),e.actions||e.onDismiss?w(hc,{className:G("shrink-0",e.actionClassName),children:[e.actions,e.onDismiss?c(re,{size:"icon-xs",variant:"ghost","aria-label":e.dismissLabel??r("composer.dismissNotice"),disabled:n,onClick:o,children:c(Kt,{})}):null]}):null]}):w(gc,{variant:e.variant,className:G(t?"chat-composer-drawer-surface chat-composer-drawer-attached px-3 pt-2 pb-[calc(var(--chat-composer-attachment-overlap)_+_0.375rem)] text-xs sm:px-4":"alert-glass rounded-[22px]",e.className),"data-composer-banner-id":e.id,"data-variant":e.variant,children:[e.icon,c(Mh,{children:e.title}),e.description?c(kf,{children:e.description}):null,e.actions||e.onDismiss?w(hc,{className:G(e.actionClassName,a?"max-sm:col-start-3 max-sm:row-start-1 max-sm:mt-0 max-sm:self-start":void 0),children:[e.actions,e.onDismiss?c(re,{size:"icon-xs",variant:"ghost","aria-label":e.dismissLabel??r("composer.dismissWarning"),disabled:n,onClick:o,children:c(Kt,{})}):null]}):null]})}X();var t1=dt(!1),n1=t1.Provider;function o1(){return At(t1)}X();var r1=dt(null),a1=r1;function s1(){let[e,t]=j(0),n=A(o=>{t(r=>Math.max(0,r+(o?1:-1)))},[]);return[e>0,n]}function i1(){let e=et(r1);me(()=>(e?.(!0),()=>e?.(!1)),[e])}function I7({api:e,draftId:t,environmentId:n,slots:o,threadId:r}){let a=e.presets.useDraftPresetId(t),s=t!==null;return o?.renderSlot("conversation.hero.agentPreset",{environmentId:n,threadId:r,draftId:t,presetId:a,selectable:s,onSelectPreset:s&&t!==null?i=>e.presets.setDraftPresetId(t,i):void 0})}function l1({api:e,belowSlot:t,composer:n,data:o,draftHero:r,draftId:a,environmentId:s,onOverlayElementChange:i,queue:l,questions:d,slots:u,target:f,threadId:p,threadKey:m}){let h=o.useComposerBanners({target:f,threadKey:m}),g=c(e1,{className:"relative z-0",items:h.items}),[v,C]=s1();return w("div",{ref:i,"data-chat-composer-overlay":"true",className:r.active?"pointer-events-none absolute inset-0 z-20 flex items-center":"pointer-events-none absolute inset-x-0 bottom-0 z-20 pt-1.5 sm:pt-2",children:[w("div",{ref:r.transitionGroupRef,className:"w-full ps-[calc(env(safe-area-inset-left)+0.75rem)] pe-[calc(env(safe-area-inset-right)+0.75rem)] sm:ps-[calc(env(safe-area-inset-left)+1.25rem)] sm:pe-[calc(env(safe-area-inset-right)+1.25rem)]",children:[w("div",{className:"pointer-events-auto relative z-10",children:[l,d,r.active?w("div",{className:"absolute inset-x-0 bottom-full z-0",children:[e===void 0?u?.renderSlot("conversation.hero.agentPreset",{environmentId:s,threadId:p}):c(I7,{api:e,draftId:a??null,environmentId:s,slots:u,threadId:p}),c("div",{"aria-hidden":v||void 0,className:G("pb-8 transition-opacity duration-150 motion-reduce:transition-none",v&&"pointer-events-none select-none opacity-0"),style:{viewTransitionName:r.headlineTransitionName},children:r.headline}),g]},`${m}:${a??""}`):g,w("div",{"data-chat-composer-stack":"true",className:"chat-composer-glass-shell relative mx-auto w-full max-w-3xl",style:{viewTransitionName:r.composerTransitionName},children:[c("div",{className:"chat-composer-glass-host relative z-10 w-full rounded-[22px]",children:c("div",{ref:r.composerAnchorRef,className:"relative z-10",children:c(n1,{value:h.items.length>0,children:c(a1,{value:C,children:n})})})}),c("div",{className:"min-h-0",children:t})]}),c("div",{"data-chat-composer-dock":"true",className:"mx-auto mt-2 w-full max-w-3xl empty:hidden",children:u?.renderSlot("conversation.input.dock",{environmentId:s,threadId:p})})]}),c("div",{"aria-hidden":!0,className:"h-[calc(env(safe-area-inset-bottom)+1rem)] sm:h-[calc(env(safe-area-inset-bottom)+1.25rem)]"})]}),h.overlay]})}function d1(e,t){let n=e!==null&&e!=="plan-follow-up";return{showTopDrawer:e!==null&&(n||!t),showCollapsedPromptRow:t&&!n,hasBlocking:n}}function Eb(e){return typeof e=="string"?e:`${e.environmentId}\0${e.threadId}`}var c1=(e,t)=>`${e}\0${Eb(t)}`;X();var T7={"start-failed":"attachments.uploadFailure.startFailed","not-connected":"attachments.uploadFailure.notConnected",rejected:"attachments.uploadFailure.rejected","timed-out":"attachments.uploadFailure.timedOut",cancelled:"attachments.uploadFailure.cancelled",failed:"attachments.uploadFailure.failed"};function eh(e,t){let n=e.code===void 0?void 0:T7[e.code];return n===void 0?e.reason:t(n,{status:e.httpStatus??""})}function u1(e,t){let n=0,o=0;for(let r of e.imageIds){let a=e.uploadsByImageId[r];a?.status==="failed"&&a.environmentId===e.environmentId?o+=1:(a?.status!=="ready"||a.environmentId!==e.environmentId)&&(n+=1)}return o>0?t("attachments.retryOrRemoveFailed",{count:o}):n>0?t("attachments.stillUploading",{count:n}):null}function th(e){let t=Math.max(0,Math.min(1,Number.isFinite(e)?e:0));return`${Math.floor(t*100)}%`}X();function f1(e,t){let n=t?.hasWideActions?780:620;return e!==null&&e<n}function p1(e,t){return t?.hasWideActions?e!==null&&e<780:!1}function m1(e,t){let n=Nt().pane.useVisible(),[o,r]=j(null);me(()=>{if(!n)return;let s=e.current;if(!s)return;let i=!0;if(typeof ResizeObserver<"u"){let u=new ResizeObserver(f=>{if(!i)return;let p=f.find(v=>v.target===s);if(!p)return;let m=window.getComputedStyle(s),h=Number.parseFloat(m.paddingLeft)||0,g=Number.parseFloat(m.paddingRight)||0;r(Math.round(p.contentRect.width+h+g))});return u.observe(s),()=>{i=!1,u.disconnect()}}let l=null,d=()=>{l===null&&(l=window.requestAnimationFrame(()=>{l=null,i&&r(s.clientWidth)}))};return d(),window.addEventListener("resize",d),()=>{i=!1,window.removeEventListener("resize",d),l!==null&&window.cancelAnimationFrame(l)}},[e,n]);let a=f1(o,{hasWideActions:t});return{isComposerFooterCompact:a,isComposerPrimaryActionsCompact:a&&p1(o,{hasWideActions:t})}}X();function g1(e,t){let n=[],o=[];for(let r of e){let a=t(r);if(a.kind==="remote")return{paths:[],remote:!0,unavailableNames:[]};a.kind==="path"?n.push(a.path):o.push(r.name)}return{paths:n,remote:!1,unavailableNames:o}}function h1(e){let t=g1(e.folders,e.resolve);t.remote&&e.notifyError(e.t("attachments.folderRemote"));for(let n of t.unavailableNames)e.notifyError(e.t("attachments.folderPathUnavailable",{name:n}),e.t("attachments.folderPathUnavailableDetail"));for(let n of t.paths)e.insertText(`${Fi(n)} `)}var Ab="ycodium:paste-as-text",v1=new TextEncoder;function y1(e,t){return e.key.toLowerCase()==="v"&&e.shiftKey&&!e.altKey&&(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)}function k7(e){return e.bypassAutoAttachment||!e.canAttach||e.text.length===0?"inline":e.wouldExceedInputLimit||e.text.length>=32768||v1.encode(e.text).byteLength>=32768?"attachment":"inline"}function P7(e){let t=new Set(e.map(n=>n.toLowerCase()));if(!t.has("pasted-text.txt"))return"pasted-text.txt";for(let n=2;;n+=1){let o=`pasted-text-${n}.txt`;if(!t.has(o))return o}}function L7(e){let t=Math.max(0,Math.min(e.valueLength,e.selectedLength));return e.valueLength-t+e.textLength>e.maxLength}function C1(e){let t=L7({valueLength:e.valueLength,selectedLength:e.selectedLength,textLength:e.text.length,maxLength:e.maxInputChars});if(k7({text:e.text,bypassAutoAttachment:e.bypassAutoAttachment,wouldExceedInputLimit:t,canAttach:!0})!=="attachment")return{kind:"inline"};let n=v1.encode(e.text).byteLength;return e.maxFileBytes!==null&&n>e.maxFileBytes?t?{kind:"reject",reason:"file-too-large"}:{kind:"inline"}:{kind:"fold",fileName:P7(e.existingNames),sizeBytes:n}}function x1(e,t,n){if(e.blocked)return!1;let{editor:o,registry:r,t:a}=e;r.documentKey!==e.documentKey&&(r.documentKey=e.documentKey,r.names.clear());for(let i of e.existingImageNames)r.names.add(i);let s=C1({text:t,bypassAutoAttachment:n,valueLength:e.promptLength,selectedLength:o?.readSelectedTextLength()??0,maxInputChars:e.maxInputChars,maxFileBytes:e.maxFileBytes,existingNames:[...r.names]});return s.kind==="inline"?!1:s.kind==="reject"?(e.notify.error(a("attachments.pastedTooLargeToAttach"),a("attachments.pastedTooLargeToAttachDetail")),!0):(r.names.add(s.fileName),o?.removeSelectedText(),e.addFoldedFile(new File([t],s.fileName,{type:"text/plain;charset=utf-8"})),e.notify.info(a("attachments.pastedAttached",{name:s.fileName}),a("attachments.pastedAttachedDetail",{size:es(s.sizeBytes),shortcut:pd(navigator.platform)?"\u2318\u21E7V":"Ctrl+Shift+V"})),!0)}X();var b1="application/x-ycodium-composer-mention";function Mb(e){return e.includes(b1)}function S1(e){let t=n=>Mb(n.dataTransfer.types)?(n.preventDefault(),n.stopPropagation(),n.nativeEvent.stopPropagation(),!0):!1;return{onDragEnter(n){t(n)&&e.setDragActive(!0)},onDragOver(n){t(n)&&(n.dataTransfer.dropEffect="move",e.setDragActive(!0))},onDrop(n){if(!t(n))return;e.setDragActive(!1);let o=n.dataTransfer.getData(b1);o.length!==0&&(e.insertMentionAtEnd(`${o} `)||e.onInsertRejected())}}}function w1({documentKey:e,insertMentionAtEnd:t,onInsertRejected:n}){let[o,r]=j(!1),a=S1({insertMentionAtEnd:t,setDragActive:r,onInsertRejected:n}),s=i=>{if(!Mb(i.dataTransfer.types))return;i.stopPropagation();let l=i.relatedTarget;l instanceof Node&&i.currentTarget.contains(l)||r(!1)};return me(()=>{r(!1)},[e]),z(()=>{if(!o)return;let i=()=>{r(!1)};return window.addEventListener("dragend",i),()=>window.removeEventListener("dragend",i)},[o]),{isDragOverComposer:o,composerMentionDragHandlers:a,onComposerMentionDragLeaveCapture:s}}X();function I1(e){let t=M(0);return z(()=>{let n=()=>{t.current=Date.now()+1e3},o=s=>{s.target instanceof Node&&e.current?.contains(s.target)&&y1(s,pd(navigator.platform))&&n()},r=()=>{t.current=0},a=()=>{let s=document.activeElement;s instanceof Node&&e.current?.contains(s)&&n()};return window.addEventListener(Ab,a),window.addEventListener("keydown",o,!0),window.addEventListener("blur",r),()=>{window.removeEventListener(Ab,a),window.removeEventListener("keydown",o,!0),window.removeEventListener("blur",r)}},[e]),A(()=>{let n=Date.now()<=t.current;return t.current=0,n},[])}function T1(e){let{api:t,attachments:n,t:o,addComposerImages:r,promptRef:a,promptInputRef:s,composerEditorRef:i,composerFormRef:l,composerThreadKey:d,attachmentDocumentKey:u,attachmentImagesRef:f,limits:p,supportsAttachmentUploads:m,composerDocumentKey:h,isComposerApprovalState:g,pasteBlocked:v,hasPendingUserInputs:C,projectSelectionRequired:y,environmentId:x}=e,b=I1(l),T=M({documentKey:"",names:new Set}),I=(D,H)=>x1({blocked:v,editor:i.current,documentKey:u,registry:T.current,existingImageNames:f.current.map(K=>K.name),promptLength:a.current.length,maxInputChars:p.maxInputChars,maxFileBytes:m?null:p.inlineAttachmentMaxBytes,t:o,notify:t.notify,addFoldedFile:K=>{r([K],{source:{_tag:"pasted-text"}})}},D,H),P=D=>{let H=Array.from(D.clipboardData.files);if(H.length>0){D.preventDefault(),r(H);return}let K=D.clipboardData.getData("text/plain");I(K,b())&&(D.preventDefault(),D.stopPropagation())},k=(D,H)=>{if(D.length===0||g||C||y)return!1;let K=a.current,O=(H?.ensureLeadingBoundary??!1)&&K.length>0&&!/\s$/.test(K);return s.current?.applyPromptReplacement(K.length,K.length,O?` ${D}`:D)??!1},S=at(fp,d,null);S.current=D=>{if(g||C||y)return!1;let H=a.current,K=Math.max(0,Math.min(H.length,s.current?.readSnapshot().expandedCursor??H.length)),O=H.slice(0,K),Z=H.slice(K),N=`${O.length>0&&!/\s$/.test(O)?" ":""}${D}${/^\s/.test(Z)?"":" "}`;return s.current?.applyPromptReplacement(K,K,N)??!1};let{isDragOverComposer:L,composerMentionDragHandlers:R,onComposerMentionDragLeaveCapture:_}=w1({documentKey:h,insertMentionAtEnd:D=>k(D,{ensureLeadingBoundary:!0}),onInsertRejected:()=>{t.notify.error(o("composer.unableToAddToChat"),o("composer.composerBusy"))}});return{onComposerPaste:P,insertComposerTextAtEnd:k,addDroppedFolders:D=>{h1({folders:D,resolve:H=>n.resolveDroppedFolder({environmentId:x,folder:H}),t:o,notifyError:(H,K)=>t.notify.error(H,K),insertText:H=>k(H,{ensureLeadingBoundary:!0})})},isDragOverComposer:L,composerMentionDragHandlers:R,onComposerMentionDragLeaveCapture:_}}X();function k1(e){let{api:t,t:n,limits:o,promptRef:r,promptInputRef:a,composerEditorRef:s,composerImagesRef:i,composerDraftTarget:l,setComposerDraftPrompt:d,addComposerDraftImages:u,clearComposerDraftPromptAndImages:f,setIsStashMenuOpen:p,setStashPulse:m,isComposerCollapsedMobile:h,expandMobileComposer:g,keybindings:v,terminalOpen:C,isComposerModelPickerOpen:y,hasPendingUserInputs:x,isComposerApprovalState:b,projectSelectionRequired:T,answeringQuestion:I}=e,P=M(0),k=M(null),S=M(new Set),L=t.stash.useStore,R=L(U=>U.entries),_=L(U=>U.stashEntry),E=L(U=>U.takeEntry),D=L(U=>U.finalizeEntryImages);z(()=>()=>{k.current!==null&&window.clearTimeout(k.current)},[]);let H=A(()=>{P.current+=1,m({key:P.current,active:!0}),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{k.current=null,m(U=>({...U,active:!1}))},1200)},[]),K=A(U=>{let{entry:oe,durable:Q}=E(U.id);if(!oe)return;Q||t.notify.warning(n("composer.stashReappear"),n("composer.storageRejectedKeep")),p(!1);let V=r.current,W=U.prompt.length===0?V:V.trim().length?`${V.replace(/\s+$/,"")}
4138
+ `);for(let h=0;h<m.length;h+=1){let g=m[h]??"";g.length>0&&l.push(yr(g)),h<m.length-1&&l.push(Li())}},u=s[0];if(u?.isMention&&u.start===0){let p=i.isBackward()?i.focus:i.anchor,m=t.getExpandedAbsoluteOffsetForPoint(p.getNode(),p.offset),h=gt().getTextContent().slice(m-1,m);h.length>0&&!/\s/.test(h)&&l.push(yr(" "))}let f=0;for(let p of s)p.start<f||(p.start>f&&d(o.slice(f,p.start)),l.push(p.create()),f=p.end);return f<o.length?d(o.slice(f)):s.at(-1)?.isMention&&l.push(yr(" ")),i.insertNodes(l),n.preventDefault(),!0},Jo)}function wD(){let[e]=Vt();return z(()=>{let t=r=>{if(r.inputType!=="insertText"||!r.data||r.isComposing)return;let a=r.data;e.getEditorState().read(()=>{let i=Ee();if(!Te(i)||!i.isCollapsed()||i.anchor.type!=="element")return!1;let l=i.anchor.getNode();return We(l)&&br(l.getChildAtIndex(i.anchor.offset))})&&(r.preventDefault(),r.stopImmediatePropagation(),e.update(()=>{let i=Ee();Te(i)&&i.insertText(a)},{discrete:!0}))},n=null,o=e.registerRootListener((r,a)=>{a?.removeEventListener("beforeinput",t,!0),r?.addEventListener("beforeinput",t,!0),n=r});return()=>{n?.removeEventListener("beforeinput",t,!0),o()}},[e]),null}function ID(e){let[t]=Vt();return z(()=>{let n=(l,d)=>{if(!e.onCommandKeyDown||!d)return!1;if(l==="Enter"&&(d.isComposing||d.keyCode===229))return d.stopPropagation(),!0;let u=e.onCommandKeyDown(l,d);return u&&(d.preventDefault(),d.stopPropagation()),u},o=t.registerCommand(SM,l=>n("ArrowDown",l),Jo),r=t.registerCommand(wM,l=>n("ArrowUp",l),Jo),a=t.registerCommand(cg,l=>n("Enter",l),Jo),s=t.registerCommand(ug,l=>n("Tab",l),Jo),i=t.registerCommand(kM,l=>n("Escape",l),Jo);return()=>{o(),r(),a(),s(),i()}},[t,e]),null}function TD(){let[e]=Vt();return z(()=>{let t=e.registerCommand(ig,o=>{let r=null;if(e.getEditorState().read(()=>{let s=Ee();if(!Te(s)||!s.isCollapsed())return;let i=Hi(0);if(i<=0)return;let l=gt().getTextContent();sd(l,i,"left")&&(r=i-1)}),r===null)return!1;let a=r;return o?.preventDefault(),o?.stopPropagation(),e.update(()=>{Ra(a)}),!0},Jo),n=e.registerCommand(lg,o=>{let r=null;if(e.getEditorState().read(()=>{let s=Ee();if(!Te(s)||!s.isCollapsed())return;let i=Hi(0),l=ju();if(i>=l)return;let d=gt().getTextContent();sd(d,i,"right")&&(r=i+1)}),r===null)return!1;let a=r;return o?.preventDefault(),o?.stopPropagation(),e.update(()=>{Ra(a)}),!0},Jo);return()=>{t(),n()}},[e]),null}function kD(){let[e]=Vt();return z(()=>e.registerCommand(TM,t=>{if(!pd(navigator.platform)||t.key!=="Home"&&t.key!=="End"||t.altKey||t.metaKey||t.ctrlKey||t.isComposing)return!1;let n=e.getRootElement(),o=window.getSelection(),r=o?.anchorNode;return!n||!o||!r||!n.contains(r)||o.rangeCount===0||typeof o.modify!="function"?!1:(t.preventDefault(),t.stopPropagation(),o.modify(t.shiftKey?"extend":"move",t.key==="Home"?"backward":"forward","lineboundary"),e.update(()=>{Yo(HA(o,e))}),!0)},Jo),[e]),null}function PD(){let[e]=Vt();return z(()=>e.registerUpdateListener(({editorState:t})=>{let n=null;t.read(()=>{let o=Ee();if(!Te(o)||!o.isCollapsed())return;let r=o.anchor.getNode();if(!br(r)||o.anchor.offset===0)return;n=ud(r,0)+1}),n!==null&&queueMicrotask(()=>{e.update(()=>{Ra(n)})})}),[e]),null}function LD(){let[e]=Vt(),{onRemoveTerminalContext:t}=et(qg);return z(()=>e.registerCommand(dg,n=>{let o=Ee();if(!Te(o)||!o.isCollapsed())return!1;let r=o.anchor.getNode(),a=Hi(0),s=i=>{if(!br(i))return!1;let l=ud(i,0);return i.remove(),i instanceof qr?(t(i.__context.id),Ra(a)):Ra(l),n?.preventDefault(),!0};if(s(r))return!0;if(st(r)){if(o.anchor.offset>0)return!1;if(s(r.getPreviousSibling()))return!0;let i=r.getParent();if(We(i)){let l=r.getIndexWithinParent();if(l>0&&s(i.getChildAtIndex(l-1)))return!0}return!1}if(We(r)){let i=o.anchor.offset-1;if(i>=0&&s(r.getChildAtIndex(i)))return!0}return!1},Jo),[e,t]),null}function RD(){let[e]=Vt();return z(()=>{let t=new Set,n=e.getRootElement()===document.activeElement,o=l=>{for(let d of t)l.has(d)||e.getElementByKey(d)?.removeAttribute("data-composer-chip-selected");for(let d of l)e.getElementByKey(d)?.setAttribute("data-composer-chip-selected","true");t=l},r=()=>{let l=new Set;return e.getEditorState().read(()=>{let d=Ee();if(Te(d)&&!d.isCollapsed())for(let u of d.getNodes())u instanceof po&&l.add(u.getKey())}),l},a=e.registerUpdateListener(()=>{o(n?r():new Set)}),s=e.registerCommand(vM,()=>(n=!0,o(r()),!1),ed),i=e.registerCommand(sM,()=>(n=!1,o(new Set),!1),ed);return()=>{a(),s(),i()}},[e]),null}function ED(){let[e]=Vt(),t=Oi();return z(()=>SD(e,{createMentionNode:qu,getExpandedAbsoluteOffsetForPoint:Wu,readLinkChips:()=>t.current}),[e]),null}X();var o7=[["(",")"],["[","]"],["{","}"],["'","'"],['"','"'],["\u201C","\u201D"],["`","`"],["<",">"],["\xAB","\xBB"],["*","*"],["_","_"]],MD=new Map(o7),AD=MD.get("`")??null;function ND(e){let[t]=Vt(),n=M(e.terminalContexts),o=M(zi(e.skills)),r=Oi(),a=M(null),s=M(null);z(()=>{n.current=e.terminalContexts},[e.terminalContexts]),z(()=>{o.current=zi(e.skills)},[e.skills]);let i=xh(l=>{let d=MD.get(l),u=a.current;if(!d)return a.current=null,!1;let f=!1;return t.update(()=>{let p=u??(()=>{let v=Ee();if(!Te(v)||v.isCollapsed()||bb(v))return null;let C=xb(v);if(!C||C.start===C.end)return null;let y=gt().getTextContent();return ub(y,C.start,C.end)?null:{value:y,expandedStart:C.start,expandedEnd:C.end}})();if(!p||!d)return;let m=p.value.slice(p.expandedStart,p.expandedEnd),h=`${p.value.slice(0,p.expandedStart)}${l}${m}${d}${p.value.slice(p.expandedEnd)}`;Qu(h,n.current,o.current,r.current);let g=Un(h,p.expandedStart);fd(g+l.length,g+l.length+m.length),f=!0,a.current=null}),f});return z(()=>{let l=g=>{if(s.current){if(g.key==="Dead"||g.key===" "||g.code==="Space")return;s.current=null}if(g.defaultPrevented||g.isComposing||g.metaKey||g.ctrlKey){a.current=null,s.current=null;return}t.getEditorState().read(()=>{let v=Ee();if(!Te(v)||v.isCollapsed()){a.current=null,s.current=null;return}if(bb(v)){a.current=null,s.current=null;return}let C=xb(v);if(!C||C.start===C.end){a.current=null,s.current=null;return}let y=gt().getTextContent();if(ub(y,C.start,C.end)){a.current=null,s.current=null;return}let x={value:y,expandedStart:C.start,expandedEnd:C.end};a.current=x,s.current=null})},d=g=>{if(g.inputType==="insertCompositionText"&&g.data==="`"&&AD!==null&&a.current){s.current=a.current;return}if(s.current||g.inputType==="insertCompositionText")return;if(typeof g.data!="string"){a.current=null;return}let v=g.inputType==="insertText"?g.data:null;if(!v||v.length!==1){a.current=null;return}i(v)&&(g.preventDefault(),g.stopPropagation(),g.stopImmediatePropagation())},u=g=>{queueMicrotask(()=>{t.update(()=>{let v=s.current;if(!v)return;let C=gt().getTextContent(),y=AD;if(y===null){s.current=null;return}let x=`${v.value.slice(0,v.expandedStart)}\`${v.value.slice(v.expandedEnd)}`;if(C!==x){g?.finalAttempt&&(a.current=null,s.current=null);return}let b=v.value.slice(v.expandedStart,v.expandedEnd),T=Un(C,v.expandedStart);fd(T,T+1);let I=Ee();if(!Te(I)){a.current=null,s.current=null;return}I.insertText(`\`${b}${y}`),fd(T+1,T+1+b.length),a.current=null,s.current=null},{tag:mo})})},f=g=>{let v=g;(v.inputType==="insertText"||v.inputType==="insertCompositionText")&&u()},p=()=>{u({finalAttempt:!0})},m=null,h=t.registerRootListener((g,v)=>{v?.removeEventListener("keydown",l),v?.removeEventListener("beforeinput",d,!0),v?.removeEventListener("input",f),v?.removeEventListener("compositionend",p),g?.addEventListener("keydown",l),g?.addEventListener("beforeinput",d,!0),g?.addEventListener("input",f),g?.addEventListener("compositionend",p),m=g});return()=>{m&&(m.removeEventListener("keydown",l),m.removeEventListener("beforeinput",d,!0),m.removeEventListener("input",f),m.removeEventListener("compositionend",p)),h()}},[t]),null}var r7=`composer-editor-${Math.random().toString(36).slice(2)}`,wb="relative [font-family:var(--font-composer,var(--font-sans))] [font-size:var(--font-size-prompt,0.875rem)] [@media(max-width:39.999rem)_and_(pointer:coarse)]:[font-size:max(var(--font-size-prompt,1rem),16px)]",Ib="block max-h-50 min-h-17.5 w-full overflow-y-auto whitespace-pre-wrap wrap-break-word bg-transparent leading-relaxed text-foreground focus:outline-none";function a7({documentKey:e,value:t,cursor:n,terminalContexts:o,skills:r,disabled:a,placeholder:s,className:i,ariaLabel:l,onRemoveTerminalContext:d,onChange:u,onCommandKeyDown:f,onPaste:p,editorRef:m}){let[h]=Vt(),g=M(u);g.current=u;let v=Zo(t,n),C=La(e,t,{cursor:v,expandedCursor:Mo(t,v)}),y=Zo(t,C.cursor),x=aD(o),b=M(x),T=sD(r),I=M(T),P=M(zi(r)),k=Oi(),S=M({value:t,cursor:y,expandedCursor:C.expandedCursor,selection:C.selection,terminalContextIds:o.map(O=>O.id)}),L=M(e),R=C.history,_=M(!1),E=$(()=>({onRemoveTerminalContext:d}),[d]);me(()=>{P.current=zi(r)},[r]),z(()=>{h.setEditable(!a)},[a,h]),me(()=>{let O=Zo(t,n),Z=S.current,N=L.current,B=N!==e,ue=b.current!==x,U=I.current!==T;if(!B&&Z.value===t&&Z.cursor===O&&!ue&&!U)return;if(B){let ae=Z.selection;h.getEditorState().read(()=>{ae=Qg(ae)}),dd(N,Z.value,{cursor:Z.cursor,expandedCursor:Z.expandedCursor,selection:ae})}let oe=La(e,t),Q=B?oe.selection:{anchor:O,focus:O};S.current={value:t,cursor:B?oe.cursor:O,expandedCursor:B?oe.expandedCursor:Mo(t,O),selection:Q,terminalContextIds:o.map(ae=>ae.id)},L.current=e,b.current=x,I.current=T;let V=h.getRootElement(),W=!!(V&&document.activeElement===V);if(!B&&Z.value===t&&!ue&&!U&&!W)return;let ee=B?La(N,Z.value).history:null;_.current=!0;let ie=t==="",J=()=>h.update(()=>{let ae=B||Z.value!==t||ue||U;ae&&Qu(t,o,P.current,k.current),B?fd(Q.anchor,Q.focus):(ae||W)&&Ra(O)},{discrete:!0,tag:ie?[mo,px,OM]:mo});ee?uD(ee,J):J(),ie&&W&&requestAnimationFrame(()=>setTimeout(()=>{document.activeElement===h.getRootElement()&&h.update(()=>{let ae=Ee();Te(ae)&&(ae.dirty=!0)},{tag:[mo,px]})},0)),dd(e,t,S.current),queueMicrotask(()=>{_.current=!1})},[n,e,h,T,o,x,t]);let D=A(O=>{let Z=h.getRootElement();if(!Z)return;let N=Zo(S.current.value,O);Z.focus({preventScroll:!0}),h.update(()=>{Ra(N)}),S.current={value:S.current.value,cursor:N,expandedCursor:Mo(S.current.value,N),selection:{anchor:N,focus:N},terminalContextIds:S.current.terminalContextIds},dd(L.current,S.current.value,{cursor:S.current.cursor,expandedCursor:S.current.expandedCursor,selection:S.current.selection}),g.current(S.current.value,N,S.current.expandedCursor,!1,S.current.terminalContextIds)},[h]),H=A(()=>{let O=S.current;return h.getEditorState().read(()=>{let Z=gt().getTextContent(),N=Zo(Z,S.current.cursor),B=Zo(Z,Hi(N)),ue=Gu(Z,S.current.expandedCursor),U=Gu(Z,Sb(ue)),oe=Xg(gt()),Q=Qg(S.current.selection);O={value:Z,cursor:B,expandedCursor:U,selection:Q,terminalContextIds:oe}}),S.current=O,dd(L.current,O.value,O),O},[h]);Bo(m,()=>({focus:()=>{D(S.current.cursor)},focusAt:D,focusAtEnd:()=>{D(Un(S.current.value,S.current.value.length))},readSnapshot:H,readSelectedTextLength:()=>iD(h),removeSelectedText:()=>lD(h)}),[h,D,H]);let K=A(O=>{O.read(()=>{let Z=gt().getTextContent(),N=Zo(Z,S.current.cursor),B=Zo(Z,Hi(N)),ue=Gu(Z,S.current.expandedCursor),U=Gu(Z,Sb(ue)),oe=Xg(gt()),Q=Qg(S.current.selection),V=S.current;if(V.value===Z&&V.cursor===B&&V.expandedCursor===U&&V.selection.anchor===Q.anchor&&V.selection.focus===Q.focus&&V.terminalContextIds.length===oe.length&&V.terminalContextIds.every((ee,ie)=>ee===oe[ie])||_.current)return;S.current={value:Z,cursor:B,expandedCursor:U,selection:Q,terminalContextIds:oe},dd(L.current,Z,{cursor:B,expandedCursor:U,selection:Q});let W=sd(Z,B,"left")||sd(Z,B,"right");g.current(Z,B,U,W,oe)})},[]);return c(qg,{value:E,children:w("div",{className:wb,children:[c(W_,{contentEditable:c(FN,{className:G(Ib,i),"data-testid":"composer-editor","data-composer-prompt":"true",spellCheck:!1,autoCorrect:"off",autoCapitalize:"off","aria-placeholder":s,...l?{"aria-label":l}:{},placeholder:c("span",{}),onPasteCapture:p}),placeholder:o.length>0?null:c("div",{className:"pointer-events-none absolute inset-0 select-none leading-relaxed text-placeholder",children:s}),ErrorBoundary:BN}),c(v_,{onChange:K}),c(ID,{...f?{onCommandKeyDown:f}:{}}),c(wD,{}),c(ND,{terminalContexts:o,skills:r}),c(kD,{}),c(TD,{}),c(PD,{}),c(LD,{}),c(ED,{}),c(RD,{}),c(g_,{externalHistoryState:R},e)]})})}function s7(e){let[t]=Vt(),n=M(e),o=M(e),[r,a]=j(e.documentKey);r===e.documentKey&&(n.current=e),o.current=e,me(()=>{r===e.documentKey||t.isComposing()||a(e.documentKey)},[r,t,e.documentKey]),z(()=>{let i=null,l=()=>{let u=o.current.documentKey;a(f=>f===u?f:u)},d=t.registerRootListener((u,f)=>{f?.removeEventListener("compositionend",l),u?.addEventListener("compositionend",l),i=u});return()=>{i?.removeEventListener("compositionend",l),d()}},[t]);let s=r===e.documentKey?e:n.current;return c(a7,{...s})}function md({documentKey:e,value:t,cursor:n,terminalContexts:o,skills:r,disabled:a,placeholder:s,className:i,ariaLabel:l,onRemoveTerminalContext:d,onChange:u,onCommandKeyDown:f,onPaste:p,editorRef:m}){let h=M(t),g=M(o),v=M(zi(r)),C=M(Oi().current),y=$(()=>({namespace:"ycodium-composer-editor",editable:!0,nodes:[Bi,cd,qr,...mb],editorState:()=>{Qu(h.current,g.current,v.current,C.current)},onError:x=>{throw x}}),[]);return c(YM,{initialConfig:y,children:c(s7,{documentKey:e,value:t,cursor:n,terminalContexts:o,skills:r,disabled:a,placeholder:s,onRemoveTerminalContext:d,onChange:u,onPaste:p,editorRef:m,...f?{onCommandKeyDown:f}:{},...i?{className:i}:{},...l?{ariaLabel:l}:{}})},r7)}function _D(e){return typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function"}function DD(e){return _D(e)?Promise.resolve(e).then(DD):e===!1?!1:e==null?!0:e.accepted}function Xu(e,t,n){let o=e.trim().length-t;return o<=0?null:n("composer.promptTooLong",{count:o,excess:o.toLocaleString("en-US"),max:t.toLocaleString("en-US")})}function Tb(e){return e.submissionTarget==="provider-turn"?Xu(e.providerInput??e.prompt,e.maxInputChars,e.t):null}function OD(e){return _D(e)}function FD(e){let t=Tb(e);if(t)return e.event?.preventDefault(),{validationMessage:t,didDispatch:!1};let n=DD(e.onSend(e.event));return typeof n!="boolean"?n.then(o=>(o||e.event?.preventDefault(),{validationMessage:null,didDispatch:o})):(n||e.event?.preventDefault(),{validationMessage:null,didDispatch:n})}var $n=new Map;function i7(e,t,n){return`${e}\0${t}\0${n??"none"}`}function kb(e,t){$n.delete(e),$n.set(e,t)}function gd(e,t){if($n.get(e)===t){if(t.operationLeases>0){t.disposeRequested=!0;return}t.releaseAuthorityWatch?.(),t.releaseAuthorityWatch=void 0,$n.delete(e);for(let n of t.state.added)t.releaseUpload(n.id),URL.revokeObjectURL(n.previewUrl);for(let n of t.listeners)n()}}function l7(e){if($n.size<=100)return;let t=Array.from($n);for(let[n,o]of t){if($n.size<=100)return;n===e||o.committed||o.listeners.size>0||o.operationLeases>0||gd(n,o)}for(let[n,o]of t){if($n.size<=100)return;n===e||o.listeners.size>0||o.operationLeases>0||gd(n,o)}}function Yg(){queueMicrotask(()=>l7())}function BD(e,t,n,o,r=void 0){let a=n.management?.revision??null,s=i7(e,n.intentId,a),i=$n.get(s);if(i)return i.releaseUpload=o.releaseUpload,i.watchAuthority=r,i.state;let l={key:s,inputKey:e,environmentId:t,intentId:n.intentId,revision:a,text:n.management?.text??n.text??"",retained:n.management?.attachments??[],added:[],saving:!1,error:null},d={state:l,listeners:new Set,releaseUpload:o.releaseUpload,operationLeases:0,committed:!1,disposeRequested:!1,watchAuthority:r,releaseAuthorityWatch:void 0};return $n.set(s,d),l}function zD(e,t){let n=$n.get(e);return n?(n.releaseAuthorityWatch===void 0&&n.watchAuthority!==void 0&&(n.releaseAuthorityWatch=n.watchAuthority({threadKey:n.state.inputKey,intentId:n.state.intentId,revision:n.state.revision,onInvalid:()=>gd(e,n)})),n.committed=!0,kb(e,n),n.listeners.add(t),Yg(),()=>{n.listeners.delete(t),Yg()}):()=>{}}function $i(e,t){let n=$n.get(e);if(!n)return;n.committed=!0;let o=t(n.state);if(o!==n.state){n.state=o,kb(e,n);for(let r of n.listeners)r()}}function Jg(e){return $n.get(e)?.state}function HD(e){let t=$n.get(e);if(!t)return null;t.committed=!0,t.operationLeases+=1,kb(e,t);let n=!1;return()=>{if(!n){if(n=!0,t.operationLeases=Math.max(0,t.operationLeases-1),t.operationLeases===0&&t.disposeRequested){gd(e,t);return}Yg()}}}function Zg(e){let t=$n.get(e);t&&gd(e,t)}function UD(e,t){let n=new Map(t.flatMap(o=>o.waiting&&o.management!==void 0?[[o.intentId,o.management.revision]]:[]));for(let[o,r]of $n)r.state.inputKey===e&&n.get(r.state.intentId)!==r.state.revision&&gd(o,r);Yg()}var d7=[],c7=[],u7=()=>{};function $D({entry:e,current:t,inputKey:n,environmentId:o,unavailable:r,attachments:a,watchEditorAuthority:s,onEdit:i,onClose:l}){let{t:d}=rn(),u=BD(n,o,e,a,s),f=Fn(O=>zD(u.key,O),()=>Jg(u.key)??u,()=>Jg(u.key)??u),{key:p,text:m,retained:h,added:g,saving:v,error:C}=f,y=M(null),[x,b]=j(()=>m.length),T=Br()?.data.assistantQuotes??null,I=O=>Xu(T?T.expandForProvider(O):O,a.limits.maxInputChars,d),P=I(m),k=M(null),S=a.useUploadStatuses(),L=$(()=>h.map(O=>O.id),[h]),R=a.useAssetUrls(o,L),_=!t?.management||t.management.revision!==e.management?.revision;z(()=>{t===void 0&&(Zg(p),l())},[t,p,l]);let E=()=>{v||(Zg(p),l())},D=O=>{if(v||r||_)return;let Z=null,N=[...g];for(let B of O){let ue=B.type||"application/octet-stream";if(B.size===0){Z=d("attachments.empty",{name:B.name});continue}let U=a.makeImageAttachment({id:a.randomUUID(),name:B.name,mimeType:ue,sizeBytes:B.size,file:B});N.push(U),a.startUpload({environmentId:o,image:U})}$i(p,B=>({...B,added:N,error:Z}))},H=async()=>{let O=Jg(p);if(!O||O.saving||r||_||!O.text.trim()&&O.retained.length+O.added.length===0||I(O.text)!==null)return;let Z=HD(p);if(Z!==null){$i(p,N=>({...N,saving:!0,error:null}));try{await a.awaitUploads(O.added.map(B=>B.id));let N=a.getUploadedAttachments({environmentId:o,images:O.added});if(!N)throw new Error(d("turnQueue.uploadFailed"));await i(e,{text:O.text,attachments:[...O.retained,...N]}),Zg(p),l()}catch(N){$i(p,B=>({...B,saving:!1,error:N instanceof Error?N.message:d("turnQueue.actionFailed")}))}finally{Z()}}},K=[...h.map((O,Z)=>({...O,previewUrl:R[Z],added:!1})).filter(O=>O.source?._tag!=="thread-reference"),...g.map(O=>({...O,added:!0}))];return c(Cf,{open:!0,onOpenChange:O=>{O||E()},children:w(wf,{className:"max-w-2xl","data-queued-message-editor":!0,initialFocus:()=>(y.current?.focusAtEnd(),!1),children:[w(Sf,{children:[c(If,{children:d("turnQueue.editTitle")}),c(xf,{children:d("turnQueue.editDescription")})]}),w("div",{className:"max-h-[60dvh] space-y-3 overflow-y-auto px-6 pb-4",onDragOver:O=>{O.dataTransfer.types.includes("Files")&&O.preventDefault()},onDrop:O=>{O.dataTransfer.files.length&&(O.preventDefault(),O.stopPropagation(),D(Array.from(O.dataTransfer.files)))},children:[c("div",{className:"rounded-lg border border-input bg-background px-3 py-2 focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/24",children:c(md,{editorRef:y,documentKey:`queue-editor\0${p}`,value:m,cursor:x,terminalContexts:d7,skills:c7,disabled:v,placeholder:d("turnQueue.editText"),ariaLabel:d("turnQueue.editText"),className:"max-h-[40dvh]",onRemoveTerminalContext:u7,onChange:(O,Z)=>{b(Z),$i(p,N=>({...N,text:O}))},onCommandKeyDown:(O,Z)=>O!=="Enter"||!(Z.metaKey||Z.ctrlKey)?!1:(H(),!0),onPaste:O=>{O.clipboardData.files.length&&(O.preventDefault(),D(Array.from(O.clipboardData.files)))}})}),P?c("p",{role:"alert",className:"text-sm text-destructive-foreground",children:P}):null,c("ul",{className:"flex flex-wrap gap-2",children:K.map(O=>w("li",{className:"flex max-w-full items-center gap-2 rounded-md border border-border px-2 py-1.5",children:[O.type==="image"&&O.previewUrl?c("img",{src:O.previewUrl,alt:O.name,className:"size-12 rounded object-cover"}):c(Io,{className:"size-4 shrink-0"}),w("div",{className:"min-w-0 text-xs",children:[c("p",{className:"max-w-48 break-words",children:O.name}),c("p",{className:"text-muted-foreground",children:a.formatAttachmentSize(O.sizeBytes)}),O.added&&S.get(O.id)!=="ready"?c("p",{children:d(S.get(O.id)==="failed"?"turnQueue.uploadFailed":"turnQueue.uploading")}):null,O.added&&S.get(O.id)==="failed"?c(re,{size:"xs",variant:"ghost",disabled:v||r||_,onClick:()=>{let Z=g.find(N=>N.id===O.id);Z&&a.retryUpload({environmentId:o,image:Z})},children:d("turnQueue.retryUpload")}):null]}),c(re,{size:"icon-xs",variant:"ghost","aria-label":d("turnQueue.removeAttachment",{name:O.name}),disabled:v||_,onClick:()=>{O.added?(a.releaseUpload(O.id),O.previewUrl&&URL.revokeObjectURL(O.previewUrl),$i(p,Z=>({...Z,added:Z.added.filter(N=>N.id!==O.id)}))):$i(p,Z=>({...Z,retained:Z.retained.filter(N=>N.id!==O.id)}))},children:c(Kt,{className:"size-3.5"})})]},O.id))}),c("input",{ref:k,type:"file",multiple:!0,className:"hidden","aria-label":d("turnQueue.addAttachments"),onChange:O=>{D(Array.from(O.target.files??[])),O.target.value=""}}),w(re,{size:"sm",variant:"outline",disabled:v||r||_,onClick:()=>k.current?.click(),children:[c(Io,{className:"size-4"}),d("turnQueue.addAttachments")]}),_?c("p",{role:"alert",className:"text-sm text-muted-foreground",children:d("turnQueue.editStale")}):null,C?c("p",{role:"alert",className:"text-sm text-destructive-foreground",children:C}):null]}),w(bf,{children:[c(re,{variant:"ghost",disabled:v,onClick:E,children:d("turnQueue.discardEdit")}),c(re,{disabled:v||r||_||P!==null||!m.trim()&&K.length===0,onClick:()=>{H()},children:d(v?"turnQueue.saving":"turnQueue.saveEdit")})]})]})})}X();var Sr=["approval-required","auto-accept-edits","auto","full-access"];var f7={"approval-required":ec,"auto-accept-edits":Rr,auto:Wa,"full-access":Va},p7={"approval-required":"approvalRequired","auto-accept-edits":"autoAcceptEdits",auto:"auto","full-access":"fullAccess"};function hd(){let{t:e}=le();return A(t=>{let n=p7[t];return{mode:t,label:e(`runtimeMode.${n}`),description:e(`runtimeMode.${n}Description`),icon:f7[t]}},[e])}function KD(e){let{t}=rn(),n=hd(),{interactionMode:o,runtimeMode:r,nativeModeName:a}=e.sentWith,s=[o===void 0?null:t(o==="plan"?"turnQueue.sentWithPlan":"turnQueue.sentWithNoPlan"),a??(r===void 0?null:n(r).label)].filter(i=>i!=null);return c("p",{className:"text-muted-foreground","data-queued-sent-with":!0,children:t("turnQueue.sentWith",{modes:s.join(" \xB7 ")})})}function VD(e,t){let n=e.find(a=>a.intentId===t.intentId);if(!n)return e;let o=e.filter(a=>a.intentId!==t.intentId),r=t.beforeIntentId===null?o.length:o.findIndex(a=>a.intentId===t.beforeIntentId);return r<0?e:(o.splice(r,0,n),o)}function qD(e,t,n){if(t===n)return null;let o={intentId:t,beforeIntentId:n,previousOrder:e.map(a=>a.intentId)};return VD(e,o).every((a,s)=>a.intentId===e[s]?.intentId)?null:o}function WD(e,t){if(!e.find(l=>l.intentId===t.intentId)?.management?.canReorder||t.beforeIntentId!==null&&!e.some(l=>l.intentId===t.beforeIntentId))return{entries:e,settled:!0};let o=new Set(e.map(l=>l.intentId)),r=new Set(t.previousOrder),a=t.previousOrder.filter(l=>o.has(l));return e.filter(l=>r.has(l.intentId)).some((l,d)=>l.intentId!==a[d])?{entries:e,settled:!0}:{entries:VD(e,t),settled:!1}}X();X();function m7({entry:e,unavailable:t,onCancel:n}){let{t:o}=rn(),r=M(!1),[a,s]=j(!1),[i,l]=j(!1),[d,u]=j(!1);z(()=>{u(!1),l(!1)},[e.status,e.deliveryCertainty]);let f=async()=>{if(!(r.current||t||e.action===null)){r.current=!0,s(!0),l(!1);try{await n(e),u(!1)}catch{l(!0)}finally{r.current=!1,s(!1)}}};return w("li",{className:"space-y-2 border-t border-border py-2","data-turn-queue-message":!0,children:[c("p",{className:"text-muted-foreground",children:o(e.deliveryCertainty==="unknown"?"turnQueue.itemUnknown":e.status==="queued"?"turnQueue.itemQueued":e.status==="blocked"||e.status==="reconciling"?"turnQueue.itemBlocked":"turnQueue.itemRunning")}),c("p",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e.text??o("turnQueue.messageUnavailable")}),e.attachmentNames.length>0?c("p",{className:"break-words text-muted-foreground",children:e.attachmentNames.join(", ")}):null,e.action!==null?d&&e.action==="abandon"?w("div",{className:"space-y-2",children:[c("p",{children:o("turnQueue.abandonDescription")}),w("div",{className:"flex flex-wrap gap-2",children:[c(re,{size:"xs",variant:"outline",disabled:a||t,onClick:()=>{f()},children:o("turnQueue.confirmAbandon")}),c(re,{size:"xs",variant:"ghost",disabled:a,onClick:()=>u(!1),children:o("turnQueue.keepWaiting")})]})]}):c(re,{size:"xs",variant:"outline",disabled:a||t,onClick:()=>e.action==="abandon"?u(!0):void f(),children:o(a?"turnQueue.cancelling":e.action==="abandon"?"turnQueue.stopWaiting":"turnQueue.cancelMessage")}):null,i?c("p",{role:"alert",className:"text-destructive-foreground",children:o("turnQueue.actionFailed")}):null]})}function GD({entries:e,unavailable:t,onCancel:n,autoExpand:o=!1}){let{t:r}=rn(),[a,s]=j(null),i=a??o,l=Fo();return e.length===0?null:w("div",{className:"min-w-0 basis-full space-y-2",children:[c(re,{size:"xs",variant:"ghost","aria-expanded":i,"aria-controls":l,onClick:()=>s(!i),children:r(i?"turnQueue.hideMessages":"turnQueue.showMessages")}),i?c("ol",{id:l,className:"max-h-64 overflow-y-auto overscroll-contain",children:e.map(d=>c(m7,{entry:d,unavailable:t,onCancel:n},d.intentId))}):null]})}function Pb({queue:e,unavailable:t=!1,onResume:n,entries:o,onCancel:r}){let{t:a}=rn(),s=M(!1),[i,l]=j(!1),[d,u]=j(!1);z(()=>{e.paused||u(!1)},[e.paused]);let f=e.deliveryUncertain||e.blocked||e.reconciling;if(!e.paused&&!f)return null;let p=o?.[0]?.action==="abandon"&&(e.reconciling||e.deliveryUncertain),m=e.paused?a("turnQueue.pausedTitle"):e.deliveryUncertain?a("turnQueue.uncertainTitle"):e.blocked?a("turnQueue.blockedTitle"):e.reconciling?a("turnQueue.reconcilingTitle"):a("turnQueue.queuedTitle"),h=e.deliveryUncertain?a("turnQueue.uncertainDescription"):e.blocked?a("turnQueue.blockedDescription"):e.reconciling?a("turnQueue.reconcilingDescription"):e.paused?a("turnQueue.pausedDescription"):a("turnQueue.queuedDescription"),g=async()=>{if(!(s.current||t||!e.paused)){s.current=!0,l(!0),u(!1);try{await n()}catch{u(!0)}finally{s.current=!1,l(!1)}}};return w("div",{className:"mx-auto mb-2 flex w-full max-w-3xl select-none flex-wrap items-start gap-2 rounded-md border border-warning/40 bg-background px-3 py-2 text-xs text-foreground","data-turn-queue-banner":!0,role:"status",children:[w("div",{className:"min-w-0 flex-1 basis-48 space-y-1",children:[c("p",{className:"font-medium",children:m}),c("p",{className:"text-muted-foreground",children:h}),e.paused&&f?c("p",{className:"text-muted-foreground",children:a("turnQueue.pausedUncertainDescription")}):null,t?c("p",{className:"text-muted-foreground",children:a("turnQueue.disconnected")}):null,d&&e.paused?c("p",{className:"text-destructive-foreground",role:"alert",children:a("turnQueue.resumeFailed")}):null]}),e.paused?c(re,{size:"xs",variant:"outline",disabled:i,softDisabled:t,onClick:()=>{g()},children:a(i?"turnQueue.resuming":"turnQueue.resume")}):null,r&&o?c(GD,{entries:o.filter(v=>v.status!=="queued"),unavailable:t,onCancel:r,autoExpand:p}):null]})}var g7=[aR,rR],h7=[];function v7({submission:e}){let{t}=rn();return w("li",{"data-queue-pending-message":e.messageId,className:"flex items-center gap-1.5 border-t border-border/50 px-2 py-1.5",children:[c("span",{"aria-hidden":"true",className:"grid size-6 shrink-0 place-items-center",children:c("span",{className:"size-1.5 rounded-full bg-muted-foreground/60"})}),w("div",{className:"min-w-0 flex-1",children:[c("p",{className:"line-clamp-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:Gv(e.text)||t("turnQueue.attachmentsOnly")}),e.attachmentNames.length?w("p",{className:"flex items-center gap-1 text-muted-foreground",children:[c(Io,{className:"size-3 shrink-0"}),c("span",{className:"truncate",children:e.attachmentNames.join(", ")})]}):null]}),c("span",{role:"status",className:"w-[5.25rem] shrink-0 text-end text-muted-foreground",children:t("primaryActions.sendingButtonLabel")})]})}function y7({entry:e,disabled:t,dropPosition:n,dragPosition:o,feedback:r,reducedMotion:a,children:s}){let{t:i}=rn(),{attributes:l,listeners:d,setNodeRef:u,setActivatorNodeRef:f,transform:p,transition:m,isDragging:h}=tR({id:e.intentId,disabled:t,transition:a?null:{duration:160,easing:"ease-out"}});return w("li",{ref:u,"data-queue-intent":e.intentId,"data-queue-dragging":h||void 0,"data-queue-feedback":r,style:{transform:ns.Transform.toString(p),transition:m},className:G("relative flex items-center gap-1.5 border-t border-border/50 px-2 py-1.5",h&&"z-10 shadow-md ring-1 ring-primary/50 ring-inset [background:linear-gradient(var(--accent),var(--accent)),var(--background)]",r==="saved"&&"bg-primary/10 ring-1 ring-primary/30 ring-inset",r==="failed"&&"bg-destructive/10"),children:[n?c("span",{"aria-hidden":"true","data-queue-drop-position":n,className:G("pointer-events-none absolute inset-x-1 z-20 h-0.5 rounded-full bg-primary before:absolute before:-top-0.5 before:start-0 before:size-1.5 before:rounded-full before:bg-primary",n==="before"?"top-0":"bottom-0")}):null,c(re,{ref:f,size:"icon-xs",variant:"ghost",className:G("shrink-0 touch-none cursor-grab text-muted-foreground active:cursor-grabbing",(h||r==="saved")&&"bg-primary/10 text-primary"),...l,...d,"aria-label":i("turnQueue.reorderMessage"),title:i("turnQueue.reorderMessage"),softDisabled:t,children:r==="saved"?c(Wn,{className:"size-3.5"}):c(jd,{className:"size-3.5"})}),s,h&&o?c("span",{"aria-hidden":"true","data-queue-drag-position":!0,className:"pointer-events-none absolute end-3 rounded bg-primary/10 px-2 py-1 font-medium text-primary tabular-nums",children:o}):null]})}function jD({inputKey:e,entries:t,pendingSubmissions:n=h7,environmentId:o,unavailable:r,attachments:a,actions:s,onCancel:i}){let{t:l}=rn(),d=dm("(prefers-reduced-motion: reduce)"),[u,f]=Mt("turn-queue:editing",e,null),[p,m]=Mt("turn-queue:pending",e,!1),h=at("turn-queue:pending-ref",e,!1),[g,v]=Mt("turn-queue:error",e,null),[C,y]=Mt("turn-queue:drag",e,null),[x,b]=Mt("turn-queue:move",e,null),T=at("turn-queue:reorder-ref",e,!1),[I,P]=Mt("turn-queue:feedback",e,null),k=PL(ky(Ll,{activationConstraint:{distance:5}}),ky(Pl,{coordinateGetter:nR,scrollBehavior:d?"auto":"smooth"})),S=$(()=>t.filter(N=>N.waiting),[t]),L=x?WD(S,x.preview):null,R=L?.entries??S,_=R.length+n.length,E=r||p||x!==null,D=R.findIndex(N=>N.intentId===C?.activeId),H=R.findIndex(N=>N.intentId===C?.overId);z(()=>{UD(e,t)},[t,e]),z(()=>{x!==null&&(r||x.acknowledged&&L?.settled)&&(T.current=!1,b(null),!r&&S.some(N=>N.intentId===x.preview.intentId)&&P({intentId:x.preview.intentId,kind:"saved"}))},[S,x,L?.settled,r]),z(()=>{if(I===null||I.kind==="failed")return;let N=window.setTimeout(()=>P(B=>B===I?null:B),1600);return()=>window.clearTimeout(N)},[I]);let K=async N=>{if(!(h.current||T.current||r)){h.current=!0,m(!0),v(null),P(null);try{await N()}catch(B){v(B instanceof Error?B.message:l("turnQueue.actionFailed"))}finally{h.current=!1,m(!1)}}},O=(N,B)=>K(async()=>{let ue=qD(S,N.intentId,B);if(!(ue===null||!N.management?.canReorder)){T.current=!0,b({preview:ue,acknowledged:!1});try{await s.onReorder(N,B),b(U=>U?.preview===ue?{...U,acknowledged:!0}:U)}catch(U){throw T.current=!1,b(null),P({intentId:N.intentId,kind:"failed"}),U}}}),Z=r?l("turnQueue.disconnected"):x!==null?l("turnQueue.saving"):C!==null?`${l("turnQueue.dragStarted")} ${H+1}/${R.length}`:I?.kind==="saved"?l("common.action.done"):I?.kind==="cancelled"?l("turnQueue.dragCancelled"):"";return w(he,{children:[_>0?w("section",{"aria-label":l("turnQueue.pendingMessages"),"data-turn-queue-dock":!0,className:"mx-auto mb-2 w-full max-w-3xl overflow-hidden rounded-xl border border-border/60 bg-background/95 text-xs shadow-xs",children:[w("div",{className:"flex h-7 items-center justify-between gap-3 px-3 py-1.5 text-muted-foreground",children:[c("span",{className:"shrink-0",children:l("turnQueue.queued",{count:_})}),c("span",{role:"status","aria-live":C===null?"polite":"off","data-queue-reorder-status":x?"saving":I?.kind,className:G("min-w-0 truncate",I?.kind==="saved"&&"text-primary"),children:Z})]}),c(VL,{sensors:k,collisionDetection:EL,modifiers:g7,accessibility:{screenReaderInstructions:{draggable:l("turnQueue.dragInstructions")},announcements:{onDragStart:()=>l("turnQueue.dragStarted"),onDragOver:({over:N})=>{let B=R.findIndex(ue=>ue.intentId===N?.id);return B<0?void 0:`${l("turnQueue.dragStarted")} ${B+1}/${R.length}`},onDragEnd:()=>l("turnQueue.dragFinished"),onDragCancel:()=>l("turnQueue.dragCancelled")}},onDragStart:({active:N})=>{let B=R.find(ue=>ue.intentId===N.id);!B?.management?.canReorder||E||(v(null),P(null),y({activeId:B.intentId,overId:B.intentId}))},onDragOver:({over:N})=>{let B=R.find(ue=>ue.intentId===N?.id);B&&y(ue=>ue&&{...ue,overId:B.intentId})},onDragCancel:()=>{C&&P({intentId:C.activeId,kind:"cancelled"}),y(null)},onDragEnd:({active:N,over:B})=>{if(y(null),!B||N.id===B.id)return;let ue=R.findIndex(V=>V.intentId===N.id),U=R.findIndex(V=>V.intentId===B.id),oe=R[ue];if(!oe?.management?.canReorder||U<0)return;let Q=R[U+(ue<U?1:0)]?.intentId??null;O(oe,Q)},children:c(ZL,{items:R.map(N=>N.intentId),strategy:XL,children:w("ol",{className:"max-h-52 overflow-x-hidden overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",children:[R.map((N,B)=>w(y7,{entry:N,disabled:!N.management?.canReorder||E,reducedMotion:d,feedback:I?.intentId===N.intentId?I.kind:void 0,dropPosition:N.intentId===C?.overId&&D!==H?D<H?"after":"before":void 0,dragPosition:N.intentId===C?.activeId?`${H+1}/${R.length}`:void 0,children:[w("div",{className:"min-w-0 flex-1",children:[c("p",{className:"line-clamp-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:Gv(N.text??"")||l("turnQueue.attachmentsOnly")}),N.attachmentNames.length?w("p",{className:"flex items-center gap-1 text-muted-foreground",children:[c(Io,{className:"size-3 shrink-0"}),c("span",{className:"truncate",children:N.attachmentNames.join(", ")})]}):null,N.pendingAction?c("p",{className:"text-muted-foreground",children:l(N.pendingAction==="steer"?"turnQueue.steering":"turnQueue.interrupting")}):null,N.sentWith?c(KD,{sentWith:N.sentWith}):null,N.failure?c("p",{role:"alert",className:"text-destructive-foreground",children:N.failure}):null]}),w("div",{className:G("flex shrink-0 items-center gap-0.5",N.intentId===C?.activeId&&"invisible"),children:[c(re,{size:"icon-xs",variant:"ghost",disabled:!N.management||E||C!==null,"aria-label":l("turnQueue.editMessage"),title:l("turnQueue.editMessage"),onClick:()=>f(N),children:c(ac,{className:"size-3.5"})}),N.management?.canSteer?c(re,{size:"icon-xs",variant:"ghost",disabled:E||C!==null,"data-turn-queue-steer":"","aria-label":l("turnQueue.steer"),title:l("turnQueue.steerDescription"),onClick:()=>{K(()=>s.onRun(N,"steer"))},children:c(ic,{className:"size-3.5"})}):null,w(ro,{children:[c(so,{render:c(re,{size:"icon-xs",variant:"ghost",disabled:E||!N.management||C!==null,"aria-label":l("turnQueue.messageActions")}),children:c(Ho,{className:"size-4"})}),w(ao,{align:"end",children:[w(Uo,{disabled:!N.management?.canReorder||B===0,onClick:()=>{O(N,R[B-1].intentId)},children:[c(Od,{className:"size-4"}),l("turnQueue.moveUp")]}),w(Uo,{disabled:!N.management?.canReorder||B===R.length-1,onClick:()=>{O(N,R[B+2]?.intentId??null)},children:[c(Nd,{className:"size-4"}),l("turnQueue.moveDown")]}),N.management?.canSteer?c(Uo,{onClick:()=>{K(()=>s.onRun(N,"steer"))},children:l("turnQueue.steer")}):null,c(Uo,{disabled:!N.management?.canRun,onClick:()=>{K(()=>s.onRun(N,"interrupt"))},children:l(N.management?.expectedTurnId?"turnQueue.interruptAndRun":"turnQueue.sendNext")}),c(sa,{}),c(Uo,{disabled:N.action!=="cancel",onClick:()=>{K(()=>i(N))},children:l("turnQueue.cancelMessage")})]})]})]})]},N.intentId)),n.map(N=>c(v7,{submission:N},N.messageId))]})})},e),g?c("p",{role:"alert",className:"px-3 py-2 text-destructive-foreground",children:g}):null]}):null,u?c($D,{entry:u,current:t.find(N=>N.intentId===u.intentId),inputKey:e,environmentId:o,unavailable:E,attachments:a,watchEditorAuthority:s.watchEditorAuthority,onEdit:s.onEdit,onClose:()=>f(null)},`${e}\0${u.intentId}\0${u.management?.revision??"none"}`):null]})}function QD({data:e,target:t,inputKey:n,attachments:o}){let r=e.useQueue({target:t,threadKey:n}),{environmentId:a,threadId:s}=t,i=e.queue,l=$(()=>{let u={environmentId:a,threadId:s};return{actions:{onEdit:(p,m)=>i.edit(u,p,m),onReorder:(p,m)=>i.reorder(u,p,m),onRun:(p,m)=>i.run(u,p,m),watchEditorAuthority:i.watchEditorAuthority},onCancel:p=>i.cancel(u,p),onResume:()=>i.resume(u)}},[i,a,s]),d=$(()=>({data:e,target:t,threadKey:`${n}\0queue-editor`}),[e,t,n]);return w(he,{children:[c(Qp,{value:d,children:c(jD,{inputKey:n,actions:l.actions,attachments:o,entries:r.entries,pendingSubmissions:r.pendingSubmissions,environmentId:a,onCancel:l.onCancel,unavailable:r.unavailable})}),c(Pb,{entries:r.entries,onCancel:l.onCancel,onResume:l.onResume,queue:r.state,unavailable:r.unavailable})]})}X();function vd(e){return e.id??e.label}function Lb(e,t){return Array.from(new Set((t??[]).flatMap(n=>{let o=e.options.find(r=>r.id!==void 0?r.id===n:r.label===n.trim());return o?[vd(o)]:[]})))}var XD=fe(function(t){let n=t.data.useQuestions(t.target);return n.pending.length===0?null:c("div",{"data-async-question-stack":!0,className:"mx-auto mb-2 flex max-h-[45vh] w-full max-w-3xl flex-col gap-2 overflow-y-auto overscroll-contain",children:n.pending.toReversed().map(o=>c(x7,{pending:o,actions:n},o.requestId))})});function C7(e,t,n){let o={};for(let r of e.questions){let a=n[r.id]?.trim()??"",s=t[r.id]??[];if(a.length>0)o[r.id]=a;else if(s.length>0)o[r.id]=r.multiSelect?s:s[0];else return null}return o}var x7=fe(function(t){let{pending:n,actions:o}=t,{t:r}=le(),[a,s]=j({}),[i,l]=j({}),[d,u]=j(!1),[f,p]=j(null),m=C7(n,a,i),h=C=>{u(!0),p(null),C().then(y=>{u(!1),p(y)})},g=()=>{m===null||d||h(()=>o.answer(n.requestId,m))},v=(C,y,x)=>s(b=>{let T=b[C]??[],I=T.includes(y)?T.filter(P=>P!==y):x?[...T,y]:[y];return{...b,[C]:I}});return w("section",{"data-async-question":n.requestId,"aria-label":r("asyncQuestion.title"),className:"overflow-hidden rounded-xl border border-border/60 bg-background/95 px-3 py-2 text-sm shadow-xs",children:[w("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c(qa,{"aria-hidden":!0,className:"size-icon-1 shrink-0"}),c("span",{className:"font-medium",children:r("asyncQuestion.title")})]}),n.questions.map(C=>{let y=a[C.id]??[],x=i[C.id]??"";return w("div",{className:"mt-2","data-async-question-item":C.id,children:[c("p",{className:"whitespace-pre-wrap break-words text-foreground/85",children:C.question}),C.multiSelect?c("p",{className:"mt-0.5 text-xs text-secondary-label",children:r("pendingUserInput.selectOneOrMore")}):null,C.options.length>0?c("div",{className:"mt-1.5 flex flex-wrap gap-1",children:C.options.map(b=>{let T=vd(b),I=x.trim().length===0&&y.includes(T);return w(re,{size:"xs",variant:I?"secondary":"outline","aria-pressed":I,"data-async-question-option":T,disabled:d,onClick:()=>v(C.id,T,C.multiSelect===!0),children:[I?c(Wn,{"aria-hidden":!0,className:"size-icon-1"}):null,b.label]},T)})}):null,c(Ar,{type:"text",value:x,disabled:d,placeholder:r("asyncQuestion.answerPlaceholder"),"aria-label":r("asyncQuestion.answerLabel",{question:C.question}),className:"mt-1.5 h-8",onChange:b=>l(T=>({...T,[C.id]:b.target.value})),onKeyDown:b=>{b.key!=="Enter"||b.nativeEvent.isComposing||(b.preventDefault(),g())}})]},C.id)}),f?c("p",{role:"alert",className:"mt-1.5 text-xs text-destructive-foreground",children:f}):null,w("div",{className:G("mt-2 flex items-center justify-end gap-1"),children:[c(re,{size:"xs",variant:"ghost",disabled:d,onClick:()=>h(()=>o.dismiss(n.requestId)),children:r("asyncQuestion.dismiss")}),c(re,{size:"xs","data-async-question-submit":"",disabled:d||m===null,onClick:g,children:r("asyncQuestion.answer")})]})]})});X();var Rb=220,b7={opacity:0,transform:"translate3d(0, 4rem, 0)"},S7={opacity:0,transform:"translate3d(0, 7rem, 0)"},YD={opacity:1,transform:"none"},JD={transition:`transform ${Rb}ms ease-in, opacity ${Rb}ms ease-in`},w7={default:"border-[var(--chat-composer-attached-outline)]",error:"border-destructive/24",info:"border-info/24",success:"border-success/24",warning:"border-warning/24"};function e1({className:e,items:t}){let{t:n}=le(),[o,r]=j(null),a=M(null),s=o!==null&&t.some(m=>m.id===o)?o:null;if(z(()=>()=>{a.current&&clearTimeout(a.current)},[]),t.length===0)return null;let i=t[0];if(!i)return null;let l=t.slice(1),d=l.length>0,u=d&&s!==i.id,f=l[0],p=m=>{!m.onDismiss||s||(r(m.id),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,m.onDismiss?.()},Rb))};return c("div",{className:G("group/banner-stack chat-composer-drawer-slot",e),"data-composer-banner-drawer":"true",children:w("div",{className:G("relative flex flex-col-reverse",d?"group-hover/banner-stack:z-50 group-focus-within/banner-stack:z-50":null),children:[u&&f?c("div",{className:G("pointer-events-none absolute inset-x-0 -top-3 z-0 mx-auto h-3 rounded-t-2xl","chat-composer-banner-stack-cap border border-b-0 shadow-[0_6px_18px_rgba(0,0,0,0.06)]",w7[f.variant],"transition-opacity duration-150 ease-out","group-hover/banner-stack:opacity-0 group-focus-within/banner-stack:opacity-0"),style:{width:"96%"},"aria-hidden":"true"}):null,c("div",{className:G("relative z-10",s===i.id?"pointer-events-none":null),style:{...JD,...s===i.id?b7:YD},children:c(ZD,{item:i,attached:!0,exiting:s===i.id,onDismissRequest:()=>p(i)})}),d?c("div",{"data-composer-banner-stack-expanded-items":"true",className:G("relative z-20 grid grid-rows-[0fr] transition-[grid-template-rows] duration-150 ease-out","group-hover/banner-stack:grid-rows-[1fr] group-focus-within/banner-stack:grid-rows-[1fr]"),children:c("div",{className:"min-h-0 overflow-hidden",children:c("div",{className:G("invisible pointer-events-none space-y-2 pb-2 opacity-0","translate-y-1 transform-gpu transition-[opacity,transform] duration-150 ease-out will-change-[opacity,transform]","group-hover/banner-stack:visible group-hover/banner-stack:pointer-events-auto group-hover/banner-stack:translate-y-0 group-hover/banner-stack:opacity-100","group-focus-within/banner-stack:visible group-focus-within/banner-stack:pointer-events-auto group-focus-within/banner-stack:translate-y-0 group-focus-within/banner-stack:opacity-100"),children:l.map(m=>c("div",{className:G(s===m.id?"pointer-events-none":null),style:{...JD,...s===m.id?S7:YD},children:c(ZD,{item:m,attached:!1,exiting:s===m.id,onDismissRequest:()=>p(m)})},m.id))})})}):null]})})}function ZD({item:e,attached:t,exiting:n,onDismissRequest:o}){let{t:r}=le(),a=e.onDismiss&&!e.actions;return e.presentation==="compact"?w(gc,{variant:e.variant,role:"status",className:G("min-h-0 px-3 text-xs sm:px-4",t?"chat-composer-drawer-surface chat-composer-drawer-attached pt-1.5 pb-[calc(var(--chat-composer-attachment-overlap)_+_0.25rem)]":"alert-glass rounded-[22px] py-1.5",e.className),"data-composer-banner-presentation":"compact","data-composer-banner-id":e.id,"data-variant":e.variant,children:[e.icon,w(Mh,{className:"flex min-w-0 items-baseline gap-1.5 font-normal leading-5",children:[c("span",{className:"shrink-0 font-medium text-foreground",children:e.title}),e.description?c("span",{className:"min-w-0 truncate text-muted-foreground",children:e.description}):null]}),e.actions||e.onDismiss?w(hc,{className:G("shrink-0",e.actionClassName),children:[e.actions,e.onDismiss?c(re,{size:"icon-xs",variant:"ghost","aria-label":e.dismissLabel??r("composer.dismissNotice"),disabled:n,onClick:o,children:c(Kt,{})}):null]}):null]}):w(gc,{variant:e.variant,className:G(t?"chat-composer-drawer-surface chat-composer-drawer-attached px-3 pt-2 pb-[calc(var(--chat-composer-attachment-overlap)_+_0.375rem)] text-xs sm:px-4":"alert-glass rounded-[22px]",e.className),"data-composer-banner-id":e.id,"data-variant":e.variant,children:[e.icon,c(Mh,{children:e.title}),e.description?c(kf,{children:e.description}):null,e.actions||e.onDismiss?w(hc,{className:G(e.actionClassName,a?"max-sm:col-start-3 max-sm:row-start-1 max-sm:mt-0 max-sm:self-start":void 0),children:[e.actions,e.onDismiss?c(re,{size:"icon-xs",variant:"ghost","aria-label":e.dismissLabel??r("composer.dismissWarning"),disabled:n,onClick:o,children:c(Kt,{})}):null]}):null]})}X();var t1=dt(!1),n1=t1.Provider;function o1(){return At(t1)}X();var r1=dt(null),a1=r1;function s1(){let[e,t]=j(0),n=A(o=>{t(r=>Math.max(0,r+(o?1:-1)))},[]);return[e>0,n]}function i1(){let e=et(r1);me(()=>(e?.(!0),()=>e?.(!1)),[e])}function I7({api:e,draftId:t,environmentId:n,slots:o,threadId:r}){let a=e.presets.useDraftPresetId(t),s=t!==null;return o?.renderSlot("conversation.hero.agentPreset",{environmentId:n,threadId:r,draftId:t,presetId:a,selectable:s,onSelectPreset:s&&t!==null?i=>e.presets.setDraftPresetId(t,i):void 0})}function l1({api:e,belowSlot:t,composer:n,data:o,draftHero:r,draftId:a,environmentId:s,onOverlayElementChange:i,queue:l,questions:d,slots:u,target:f,threadId:p,threadKey:m}){let h=o.useComposerBanners({target:f,threadKey:m}),g=c(e1,{className:"relative z-0",items:h.items}),[v,C]=s1();return w("div",{ref:i,"data-chat-composer-overlay":"true",className:r.active?"pointer-events-none absolute inset-0 z-20 flex items-center":"pointer-events-none absolute inset-x-0 bottom-0 z-20 pt-1.5 sm:pt-2",children:[w("div",{ref:r.transitionGroupRef,className:"w-full ps-[calc(env(safe-area-inset-left)+0.75rem)] pe-[calc(env(safe-area-inset-right)+0.75rem)] sm:ps-[calc(env(safe-area-inset-left)+1.25rem)] sm:pe-[calc(env(safe-area-inset-right)+1.25rem)]",children:[w("div",{className:"pointer-events-auto relative z-10",children:[l,d,r.active?w("div",{className:"absolute inset-x-0 bottom-full z-0",children:[e===void 0?u?.renderSlot("conversation.hero.agentPreset",{environmentId:s,threadId:p}):c(I7,{api:e,draftId:a??null,environmentId:s,slots:u,threadId:p}),c("div",{"aria-hidden":v||void 0,className:G("pb-8 transition-opacity duration-150 motion-reduce:transition-none",v&&"pointer-events-none select-none opacity-0"),style:{viewTransitionName:r.headlineTransitionName},children:r.headline}),g]},`${m}:${a??""}`):g,w("div",{"data-chat-composer-stack":"true",className:"chat-composer-glass-shell relative mx-auto w-full max-w-3xl",style:{viewTransitionName:r.composerTransitionName},children:[c("div",{className:"chat-composer-glass-host relative z-10 w-full rounded-[22px]",children:c("div",{ref:r.composerAnchorRef,className:"relative z-10",children:c(n1,{value:h.items.length>0,children:c(a1,{value:C,children:n})})})}),c("div",{className:"min-h-0",children:t})]}),c("div",{"data-chat-composer-dock":"true",className:"mx-auto mt-2 w-full max-w-3xl empty:hidden",children:u?.renderSlot("conversation.input.dock",{environmentId:s,threadId:p})})]}),c("div",{"aria-hidden":!0,className:"h-[calc(env(safe-area-inset-bottom)+1rem)] sm:h-[calc(env(safe-area-inset-bottom)+1.25rem)]"})]}),h.overlay]})}function d1(e,t){let n=e!==null&&e!=="plan-follow-up";return{showTopDrawer:e!==null&&(n||!t),showCollapsedPromptRow:t&&!n,hasBlocking:n}}function Eb(e){return typeof e=="string"?e:`${e.environmentId}\0${e.threadId}`}var c1=(e,t)=>`${e}\0${Eb(t)}`;X();var T7={"start-failed":"attachments.uploadFailure.startFailed","not-connected":"attachments.uploadFailure.notConnected",rejected:"attachments.uploadFailure.rejected","timed-out":"attachments.uploadFailure.timedOut",cancelled:"attachments.uploadFailure.cancelled",failed:"attachments.uploadFailure.failed"};function eh(e,t){let n=e.code===void 0?void 0:T7[e.code];return n===void 0?e.reason:t(n,{status:e.httpStatus??""})}function u1(e,t){let n=0,o=0;for(let r of e.imageIds){let a=e.uploadsByImageId[r];a?.status==="failed"&&a.environmentId===e.environmentId?o+=1:(a?.status!=="ready"||a.environmentId!==e.environmentId)&&(n+=1)}return o>0?t("attachments.retryOrRemoveFailed",{count:o}):n>0?t("attachments.stillUploading",{count:n}):null}function th(e){let t=Math.max(0,Math.min(1,Number.isFinite(e)?e:0));return`${Math.floor(t*100)}%`}X();function f1(e,t){let n=t?.hasWideActions?780:620;return e!==null&&e<n}function p1(e,t){return t?.hasWideActions?e!==null&&e<780:!1}function m1(e,t){let n=Nt().pane.useVisible(),[o,r]=j(null);me(()=>{if(!n)return;let s=e.current;if(!s)return;let i=!0;if(typeof ResizeObserver<"u"){let u=new ResizeObserver(f=>{if(!i)return;let p=f.find(v=>v.target===s);if(!p)return;let m=window.getComputedStyle(s),h=Number.parseFloat(m.paddingLeft)||0,g=Number.parseFloat(m.paddingRight)||0;r(Math.round(p.contentRect.width+h+g))});return u.observe(s),()=>{i=!1,u.disconnect()}}let l=null,d=()=>{l===null&&(l=window.requestAnimationFrame(()=>{l=null,i&&r(s.clientWidth)}))};return d(),window.addEventListener("resize",d),()=>{i=!1,window.removeEventListener("resize",d),l!==null&&window.cancelAnimationFrame(l)}},[e,n]);let a=f1(o,{hasWideActions:t});return{isComposerFooterCompact:a,isComposerPrimaryActionsCompact:a&&p1(o,{hasWideActions:t})}}X();function g1(e,t){let n=[],o=[];for(let r of e){let a=t(r);if(a.kind==="remote")return{paths:[],remote:!0,unavailableNames:[]};a.kind==="path"?n.push(a.path):o.push(r.name)}return{paths:n,remote:!1,unavailableNames:o}}function h1(e){let t=g1(e.folders,e.resolve);t.remote&&e.notifyError(e.t("attachments.folderRemote"));for(let n of t.unavailableNames)e.notifyError(e.t("attachments.folderPathUnavailable",{name:n}),e.t("attachments.folderPathUnavailableDetail"));for(let n of t.paths)e.insertText(`${Fi(n)} `)}var Ab="ycodium:paste-as-text",v1=new TextEncoder;function y1(e,t){return e.key.toLowerCase()==="v"&&e.shiftKey&&!e.altKey&&(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)}function k7(e){return e.bypassAutoAttachment||!e.canAttach||e.text.length===0?"inline":e.wouldExceedInputLimit||e.text.length>=32768||v1.encode(e.text).byteLength>=32768?"attachment":"inline"}function P7(e){let t=new Set(e.map(n=>n.toLowerCase()));if(!t.has("pasted-text.txt"))return"pasted-text.txt";for(let n=2;;n+=1){let o=`pasted-text-${n}.txt`;if(!t.has(o))return o}}function L7(e){let t=Math.max(0,Math.min(e.valueLength,e.selectedLength));return e.valueLength-t+e.textLength>e.maxLength}function C1(e){let t=L7({valueLength:e.valueLength,selectedLength:e.selectedLength,textLength:e.text.length,maxLength:e.maxInputChars});if(k7({text:e.text,bypassAutoAttachment:e.bypassAutoAttachment,wouldExceedInputLimit:t,canAttach:!0})!=="attachment")return{kind:"inline"};let n=v1.encode(e.text).byteLength;return e.maxFileBytes!==null&&n>e.maxFileBytes?t?{kind:"reject",reason:"file-too-large"}:{kind:"inline"}:{kind:"fold",fileName:P7(e.existingNames),sizeBytes:n}}function x1(e,t,n){if(e.blocked)return!1;let{editor:o,registry:r,t:a}=e;r.documentKey!==e.documentKey&&(r.documentKey=e.documentKey,r.names.clear());for(let i of e.existingImageNames)r.names.add(i);let s=C1({text:t,bypassAutoAttachment:n,valueLength:e.promptLength,selectedLength:o?.readSelectedTextLength()??0,maxInputChars:e.maxInputChars,maxFileBytes:e.maxFileBytes,existingNames:[...r.names]});return s.kind==="inline"?!1:s.kind==="reject"?(e.notify.error(a("attachments.pastedTooLargeToAttach"),a("attachments.pastedTooLargeToAttachDetail")),!0):(r.names.add(s.fileName),o?.removeSelectedText(),e.addFoldedFile(new File([t],s.fileName,{type:"text/plain;charset=utf-8"})),e.notify.info(a("attachments.pastedAttached",{name:s.fileName}),a("attachments.pastedAttachedDetail",{size:es(s.sizeBytes),shortcut:pd(navigator.platform)?"\u2318\u21E7V":"Ctrl+Shift+V"})),!0)}X();var b1="application/x-ycodium-composer-mention";function Mb(e){return e.includes(b1)}function S1(e){let t=n=>Mb(n.dataTransfer.types)?(n.preventDefault(),n.stopPropagation(),n.nativeEvent.stopPropagation(),!0):!1;return{onDragEnter(n){t(n)&&e.setDragActive(!0)},onDragOver(n){t(n)&&(n.dataTransfer.dropEffect="move",e.setDragActive(!0))},onDrop(n){if(!t(n))return;e.setDragActive(!1);let o=n.dataTransfer.getData(b1);o.length!==0&&(e.insertMentionAtEnd(`${o} `)||e.onInsertRejected())}}}function w1({documentKey:e,insertMentionAtEnd:t,onInsertRejected:n}){let[o,r]=j(!1),a=S1({insertMentionAtEnd:t,setDragActive:r,onInsertRejected:n}),s=i=>{if(!Mb(i.dataTransfer.types))return;i.stopPropagation();let l=i.relatedTarget;l instanceof Node&&i.currentTarget.contains(l)||r(!1)};return me(()=>{r(!1)},[e]),z(()=>{if(!o)return;let i=()=>{r(!1)};return window.addEventListener("dragend",i),()=>window.removeEventListener("dragend",i)},[o]),{isDragOverComposer:o,composerMentionDragHandlers:a,onComposerMentionDragLeaveCapture:s}}X();function I1(e){let t=M(0);return z(()=>{let n=()=>{t.current=Date.now()+1e3},o=s=>{s.target instanceof Node&&e.current?.contains(s.target)&&y1(s,pd(navigator.platform))&&n()},r=()=>{t.current=0},a=()=>{let s=document.activeElement;s instanceof Node&&e.current?.contains(s)&&n()};return window.addEventListener(Ab,a),window.addEventListener("keydown",o,!0),window.addEventListener("blur",r),()=>{window.removeEventListener(Ab,a),window.removeEventListener("keydown",o,!0),window.removeEventListener("blur",r)}},[e]),A(()=>{let n=Date.now()<=t.current;return t.current=0,n},[])}function T1(e){let{api:t,attachments:n,t:o,addComposerImages:r,promptRef:a,promptInputRef:s,composerEditorRef:i,composerFormRef:l,composerThreadKey:d,attachmentDocumentKey:u,attachmentImagesRef:f,limits:p,supportsAttachmentUploads:m,composerDocumentKey:h,isComposerApprovalState:g,pasteBlocked:v,hasPendingUserInputs:C,projectSelectionRequired:y,environmentId:x}=e,b=I1(l),T=M({documentKey:"",names:new Set}),I=(D,H)=>x1({blocked:v,editor:i.current,documentKey:u,registry:T.current,existingImageNames:f.current.map(K=>K.name),promptLength:a.current.length,maxInputChars:p.maxInputChars,maxFileBytes:m?null:p.inlineAttachmentMaxBytes,t:o,notify:t.notify,addFoldedFile:K=>{r([K],{source:{_tag:"pasted-text"}})}},D,H),P=D=>{let H=Array.from(D.clipboardData.files);if(H.length>0){D.preventDefault(),r(H);return}let K=D.clipboardData.getData("text/plain");I(K,b())&&(D.preventDefault(),D.stopPropagation())},k=(D,H)=>{if(D.length===0||g||C||y)return!1;let K=a.current,O=(H?.ensureLeadingBoundary??!1)&&K.length>0&&!/\s$/.test(K);return s.current?.applyPromptReplacement(K.length,K.length,O?` ${D}`:D)??!1},S=at(fp,d,null);S.current=D=>{if(g||C||y)return!1;let H=a.current,K=Math.max(0,Math.min(H.length,s.current?.readSnapshot().expandedCursor??H.length)),O=H.slice(0,K),Z=H.slice(K),N=`${O.length>0&&!/\s$/.test(O)?" ":""}${D}${/^\s/.test(Z)?"":" "}`;return s.current?.applyPromptReplacement(K,K,N)??!1};let{isDragOverComposer:L,composerMentionDragHandlers:R,onComposerMentionDragLeaveCapture:_}=w1({documentKey:h,insertMentionAtEnd:D=>k(D,{ensureLeadingBoundary:!0}),onInsertRejected:()=>{t.notify.error(o("composer.unableToAddToChat"),o("composer.composerBusy"))}});return{onComposerPaste:P,insertComposerTextAtEnd:k,addDroppedFolders:D=>{h1({folders:D,resolve:H=>n.resolveDroppedFolder({environmentId:x,folder:H}),t:o,notifyError:(H,K)=>t.notify.error(H,K),insertText:H=>k(H,{ensureLeadingBoundary:!0})})},isDragOverComposer:L,composerMentionDragHandlers:R,onComposerMentionDragLeaveCapture:_}}X();function k1(e){let{api:t,t:n,limits:o,promptRef:r,promptInputRef:a,composerEditorRef:s,composerImagesRef:i,composerDraftTarget:l,setComposerDraftPrompt:d,addComposerDraftImages:u,clearComposerDraftPromptAndImages:f,setIsStashMenuOpen:p,setStashPulse:m,isComposerCollapsedMobile:h,expandMobileComposer:g,keybindings:v,terminalOpen:C,isComposerModelPickerOpen:y,hasPendingUserInputs:x,isComposerApprovalState:b,projectSelectionRequired:T,answeringQuestion:I}=e,P=M(0),k=M(null),S=M(new Set),L=t.stash.useStore,R=L(U=>U.entries),_=L(U=>U.stashEntry),E=L(U=>U.takeEntry),D=L(U=>U.finalizeEntryImages);z(()=>()=>{k.current!==null&&window.clearTimeout(k.current)},[]);let H=A(()=>{P.current+=1,m({key:P.current,active:!0}),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{k.current=null,m(U=>({...U,active:!1}))},1200)},[]),K=A(U=>{let{entry:oe,durable:Q}=E(U.id);if(!oe)return;Q||t.notify.warning(n("composer.stashReappear"),n("composer.storageRejectedKeep")),p(!1);let V=r.current,W=U.prompt.length===0?V:V.trim().length?`${V.replace(/\s+$/,"")}
4136
4139
 
4137
4140
  ${U.prompt}`:U.prompt,ee=W!==V;if(ee&&(r.current=W,d(l,W),a.current?.syncCursor(Un(W,W.length),null)),U.attachments.length>0){let J=new Set(i.current.map(Ce=>Ce.id)),ae=new Set(i.current.map(Ce=>`${Ce.mimeType}\0${Ce.sizeBytes}\0${Ce.name}`)),Se=U.attachments.filter(Ce=>!J.has(Ce.id)&&!ae.has(`${Ce.mimeType}\0${Ce.sizeBytes}\0${Ce.name}`)),we=t.draft.hydrateImagesFromPersisted(Se);we.length>0&&u(l,we)}let ie=[];U.droppedImageNames.length>0&&ie.push(n("composer.stashImagesTooLarge",{names:U.droppedImageNames.join(", ")})),U.unreadableImageNames&&U.unreadableImageNames.length>0&&ie.push(n("composer.stashImagesUnreadable",{names:U.unreadableImageNames.join(", ")})),ie.length>0&&t.notify.warning(n("composer.someImagesNotRestored"),ie.join(" ")),ee&&window.requestAnimationFrame(()=>{s.current?.focusAtEnd()})},[u,l,i,r,d,n,E]),O=A(U=>{let{durable:oe}=E(U.id);oe||t.notify.warning(n("composer.stashEntryMayReturn"),n("composer.storageRejectedDelete"))},[n,E]),Z=A(async()=>{let U=r.current.split(Zr).join("").trim(),oe=[...i.current];if(U.length===0&&oe.length===0){p(ee=>!ee);return}let Q=`${Eb(l)}\0${U}\0${oe.map(ee=>ee.id).join(",")}`;if(S.current.has(Q))return;S.current.add(Q);let V=l,W=Ui();try{let{evicted:ee,written:ie,durable:J}=_({id:W,createdAt:new Date().toISOString(),prompt:U,attachments:[],droppedImageNames:[],unreadableImageNames:[],pendingImageCount:oe.length});if(!ie){t.notify.error(n("composer.couldNotStash"),n("composer.storageRejectedWrite"));return}J||t.notify.warning(n("composer.stashNotSurvive"),n("composer.storageUnavailableMemory")),r.current="",f(V);for(let se of oe)t.uploads.release(se.id);a.current?.syncCursor(0,null),H(),ee&&t.notify.warning(n("composer.oldestStashDiscarded"),n("composer.oldestStashDiscardedDetail",{count:t.stash.maxEntries}));let ae=[],Se=[],we=[];for(let se of oe){let q=await t.imageCompression.compressForStash(se.file);if(!q.ok){(q.reason==="too-large"?Se:we).push(se.name);continue}ae.push({id:se.id,name:se.name,mimeType:q.image.mimeType,sizeBytes:q.image.sizeBytes,dataUrl:q.image.dataUrl})}let{kept:Ce,droppedNames:Re}=t.stash.partitionAttachments(ae),{attached:rt,durable:te}=D(W,{attachments:Ce,droppedImageNames:[...Se,...Re],unreadableImageNames:we});rt?!te&&J&&oe.length>0&&t.notify.warning(n("composer.stashImagesNotSaved"),n("composer.stashImagesMissingOnReload")):Ce.length>0&&t.notify.warning(n("composer.stashImagesDidNotAttach"),n("composer.stashImagesDidNotAttachDetail",{count:Ce.length}))}finally{S.current.delete(Q)}},[f,l,i,D,r,H,_,n]),N=A(()=>{p(U=>!U)},[]),B=A(()=>{if(h){g(),p(!0);return}N()},[g,h,N]),ue=A(()=>{p(!1)},[]);return t.pane.useKeydown(U=>{if(t.keybindings.resolveShortcutCommand(U,v,{context:{terminalFocus:t.terminalFocus.getOwner()!==null,terminalOpen:C,modelPickerOpen:y}})==="composer.stash"&&(U.preventDefault(),U.stopPropagation(),!t.commandPalette.isOpen())){if(x&&!b){p(Q=>!Q);return}b||T||I||Z()}},{capture:!0}),{stashQueue:R,restoreStashEntry:K,deleteStashEntry:O,toggleStashMenu:N,toggleInlineStashMenu:B,closeStashMenu:ue}}X();function P1(e,t,n){return{...$v({id:Ui(),name:t.name||e.t("attachments.defaultFileName"),mimeType:t.type||"application/octet-stream",sizeBytes:t.size,...n?{source:n}:{}}),previewUrl:URL.createObjectURL(t),file:t}}async function L1(e,t,n){let{t:o,supportsAttachmentUploads:r,inlineAttachmentMaxBytes:a}=e;if(!e.activeThreadId||t.length===0)return;if(e.answerQuestionsFirst){e.notifyError(o("attachments.answerQuestionsFirst"));return}let s=e.activeThreadId,i=e.attachmentDocumentKey,l=e.pendingCompressions,d=l.get(i)??0,u=[],f=null;for(let p of t){if(p.size<=0){f=o("attachments.empty",{name:p.name});continue}u.push(p)}if(e.setThreadError(s,f),u.length!==0){l.set(i,d+u.length);try{let p=[],m=null;for(let h of u){if(!(e.imageCompression.isHeicFile(h)||Uv(h.type))){if(!r&&h.size>a){m=o("attachments.tooLarge",{name:h.name,limit:es(a)});continue}p.push(P1(e,h,n?.source));continue}let v=await e.imageCompression.prepareForAttachment(h,r?Number.POSITIVE_INFINITY:a);if(!v.ok){if(r){p.push(P1(e,h));continue}m=v.reason==="unreadable"?o("attachments.unreadableImage",{name:h.name}):o("attachments.imageTooLarge",{name:h.name});continue}let C=v.file;p.push({...$v({id:Ui(),name:C.name||o("attachments.defaultImageName"),mimeType:C.type,sizeBytes:C.size}),previewUrl:URL.createObjectURL(C),file:C})}p.length===1&&p[0]?e.addImage(p[0]):p.length>1&&e.addImages(p),m!==null&&e.setThreadError(s,m)}finally{let p=(l.get(i)??0)-u.length;p>0?l.set(i,p):l.delete(i)}}}function R1(e){let{api:t,t:n,limits:o,setThreadError:r,activeThreadId:a,answerQuestionsFirst:s,attachmentTarget:i,attachmentDocumentKey:l,supportsAttachmentUploads:d,pendingImageCompressionsRef:u,addComposerDraftImage:f,addComposerDraftImages:p,removeComposerDraftImage:m}=e,h=A(b=>{f(i,b)},[i,f]),g=A(b=>{p(i,b)},[i,p]),v=A(b=>{t.uploads.release(b),m(i,b)},[t.uploads,i,m]),C=(b,T)=>L1({activeThreadId:a,answerQuestionsFirst:s,notifyError:I=>t.notify.error(I),t:n,setThreadError:r,attachmentDocumentKey:l,pendingCompressions:u.current,supportsAttachmentUploads:d,inlineAttachmentMaxBytes:o.inlineAttachmentMaxBytes,imageCompression:t.imageCompression,addImage:h,addImages:g},b,T);return{addComposerImages:C,removeComposerImage:b=>{v(b)},onComposerAttachmentInputChange:b=>{let T=Array.from(b.target.files??[]);b.target.value="",T.length!==0&&C(T)}}}X();var E1=e=>({images:e.images,nonPersistedImageIds:e.nonPersistedImageIds});function R7(e){let{supported:t,attachments:n,environmentId:o,threadId:r,requestId:a,question:s,responding:i}=e,l=s?.id,d=s?.allowFreeform;return $(()=>t&&a!==null&&l!==void 0&&d!==!1&&!i&&r?n.questionDraftTarget({environmentId:o,threadId:r,requestId:a,questionId:l}):null,[d,n,o,l,a,i,t,r])}function A1(e){let t=R7(e),n=t??e.composerDraftTarget,o=t?[e.environmentId,e.composerDraftTarget,"question",t].join("\0"):[e.environmentId,e.composerDraftTarget].join("\0");return{questionAttachmentTarget:t,attachmentTarget:n,attachmentDocumentKey:o}}X();function M1(e,t){let n=Sr.indexOf(e);if(n===-1)return Sr[0];let o=(n+t+Sr.length)%Sr.length;return Sr[o]??Sr[0]}function N1(e){let{composerRef:t,sendContextRef:n,api:o,t:r,limits:a,composerData:s,refs:i,composerDraftTarget:l,activeThread:d,addComposerImages:u,addDroppedFolders:f,focusComposer:p,insertComposerTextAtEnd:m,insertComposerDraftTerminalContext:h,composerPreviewAnnotations:g,composerReviewComments:v,isComposerApprovalState:C,pendingUserInputCount:y,projectSelectionRequired:x,noProviderAvailable:b,modelState:T,handleRuntimeModeChange:I,runtimeMode:P,setIsComposerModelPickerOpen:k,setProviderInputSubmissionError:S}=e,{composerEditorRef:L,promptInputRef:R,promptRef:_,composerImagesRef:E,composerTerminalContextsRef:D,composerElementContextsRef:H}=i,{selectedModel:K,selectedModelOptionsForDispatch:O,selectedModelSelection:Z,selectedModelStatus:N,selectedNativeModeId:B,selectedProvider:ue,selectedProviderEntry:U,selectedProviderModels:oe,selectedPluginAction:Q,pluginBlockMessage:V,composerNativeMode:W,canSwitchNativeMode:ee,handleComposerNativeModeChange:ie}=T,J=A(()=>R.current?.readSnapshot()??{value:_.current,cursor:Un(_.current,_.current.length),expandedCursor:_.current.length,terminalContextIds:D.current.map(Se=>Se.id)},[D,_]),ae=()=>({prompt:_.current,images:E.current,terminalContexts:D.current,elementContexts:H.current,previewAnnotations:g,reviewComments:v,selectedModelOptionsForDispatch:O,selectedModelSelection:Z,...B?{selectedNativeModeId:B}:{},providerAvailable:U!==void 0,selectedProvider:ue,selectedModel:K,selectedModelStatus:N,selectedProviderModels:oe,selectedPluginAction:Q});n.current=ae,Bo(t,()=>({focusAtEnd:()=>{L.current?.focusAtEnd()},focusAt:we=>{L.current?.focusAt(we)},addDroppedFiles:we=>{u(we),p()},addDroppedFolders:we=>{f(we),p()},insertTextAtEnd:m,toggleModelPicker:()=>{k(we=>!we)},cyclePermissionMode:we=>{if(W===null){I(M1(P,we));return}let{modes:Ce,current:Re}=W;if(!ee||Ce.length<2)return;let rt=Ce.findIndex(se=>se.id===Re.id),te=Ce[(rt+we+Ce.length)%Ce.length];te!==void 0&&ie(te.id)},readSnapshot:J,resetCursorState:we=>{R.current?.resetCursorState(we)},addTerminalContext:we=>{if(!d)return;let Ce=J(),Re=o.terminalContext.insertInlinePlaceholder(Ce.value,Ce.expandedCursor),rt=Un(Re.prompt,Re.cursor);h(l,Re.prompt,{id:Ui(),threadId:d.id,createdAt:new Date().toISOString(),...we},Re.contextIndex)&&(_.current=Re.prompt,R.current?.syncCursor(rt,go(Re.prompt,Re.cursor)),window.requestAnimationFrame(()=>{L.current?.focusAt(rt)}))},readSendIdentity:()=>({pluginActionId:Q?.id??null,prompt:_.current}),getSendContext:ae,validateProviderInput:we=>{let Ce=V??Tb({prompt:_.current,providerInput:s.assistantQuotes.expandForProvider(we),submissionTarget:"provider-turn",maxInputChars:a.maxInputChars,t:r});return S(Ce),Ce===null}}),[d,u,l,h,_,E,D,H,g,v,p,C,y,x,J,K,O,Z,B,b,ue,oe,Q,V,s,ae,n,a.maxInputChars,W,ee,ie,I,P,r])}X();function _1(e){let{composerImages:t,composerImagesRef:n,composerTerminalContexts:o,composerTerminalContextsRef:r,composerElementContexts:a,composerElementContextsRef:s}=e;me(()=>{n.current=t},[t,n]),me(()=>{r.current=o},[o,r]),me(()=>{s.current=a},[a,s])}X();var E7=['[data-composer-drawer-layer="true"]','[data-slot="popover-popup"]','[data-slot="menu-popup"]','[data-slot="select-popup"]','[data-slot="combobox-popup"]','[data-slot="autocomplete-popup"]'].join(",");function A7(e){return e.closest(E7)!==null}function D1(e){let{isMobileViewport:t,forceExpandedOnMobile:n,composerEditorRef:o,composerSurfaceRef:r,composerFormRef:a}=e,[s,i]=j(!1),l=t&&!n&&!s,d=M(null),u=M(null),f=M(null),p=M(!1),m=A(()=>{if(!t)return;d.current!==null&&(window.cancelAnimationFrame(d.current),d.current=null);let C=document.activeElement;C instanceof HTMLElement&&C.blur(),i(!1)},[t]),h=A(()=>{d.current!==null&&(window.cancelAnimationFrame(d.current),d.current=null),u.current!==null&&window.cancelAnimationFrame(u.current),f.current!==null&&window.cancelAnimationFrame(f.current),p.current=!0,i(!0),u.current=window.requestAnimationFrame(()=>{u.current=null,o.current?.focusAtEnd(),f.current=window.requestAnimationFrame(()=>{f.current=null,p.current=!1})})},[]),g=A(()=>{t&&(p.current||(d.current!==null&&window.cancelAnimationFrame(d.current),d.current=window.requestAnimationFrame(()=>{if(d.current=null,p.current)return;let C=r.current,y=a.current,x=document.activeElement;x instanceof Element&&A7(x)||x instanceof Node&&(C&&C.contains(x)||y&&y.contains(x))||i(!1)})))},[t]);return z(()=>()=>{d.current!==null&&window.cancelAnimationFrame(d.current),u.current!==null&&window.cancelAnimationFrame(u.current),f.current!==null&&window.cancelAnimationFrame(f.current)},[]),{isComposerCollapsedMobile:l,blurMobileComposerAfterSend:m,expandMobileComposer:h,scheduleComposerCollapseCheck:g,handleFormFocusCapture:C=>{let y=C.target;l&&y instanceof HTMLElement&&y.closest('[data-chat-composer-collapsed-controls="true"]')||(d.current!==null&&(window.cancelAnimationFrame(d.current),d.current=null),i(!0))}}}X();function O1(e){let{t,threadId:n,setThreadError:o,promptRef:r,promptInputRef:a,respondToApproval:s,respondToDecision:i,selectUserInputOption:l,advanceUserInput:d,activePendingProgress:u,activePendingIsResponding:f,activePendingResolvedAnswers:p}=e,m=$(()=>u?{questionIndex:u.questionIndex,isLastQuestion:u.isLastQuestion,canAdvance:u.canAdvance,isResponding:f,isComplete:!!p}:null,[f,u,p]),h=A((y,x)=>{l(y,x),r.current="",a.current?.resetCursorState({cursor:0})},[r,l]),g=A(async(y,x,b)=>{try{await s(y,x,b)}catch(T){o(n,T instanceof Error?T.message:t("approval.respondFailed"))}},[n,s,o,t]),v=A((y,x)=>{i(y,x).then(b=>{b!==null&&o(n,b)})},[n,i,o]),C=A(()=>{d().then(y=>{y!==null&&o(n,y)})},[d,n,o]);return{pendingPrimaryAction:m,onSelectActivePendingUserInputOption:h,onRespondToApproval:g,onRespondToComposerDecision:v,onAdvanceActivePendingUserInput:C}}X();function F1(e){return e.startsWith("!")}function B1(e){return e.slice(1).trim()}function z1(e){return e.length===0?"empty":/[\r\n]/.test(e)?"multiline":null}function M7(){return null}function H1(){let{data:e,target:t,threadKey:n}=qo();return(e.useShellCommand??M7)({target:t,threadKey:n})}X();function U1({promptRef:e,maxInputChars:t,noProviderAvailable:n,sendDisabledReason:o,isModelSendBlocked:r,onModelSendBlocked:a,onDispatched:s,activeThreadId:i,activePendingProgress:l,composerDocumentKey:d,pendingImageCompressionsRef:u,onSend:f,onStillCompressing:p,shouldBlurMobileComposerOnSubmit:m,blurMobileComposerAfterSend:h}){let{t:g}=le(),[v,C]=j(null),[y,x]=j(!1),b=M(0);z(()=>{b.current+=1,C(null),x(!1)},[d]),z(()=>{o===null&&x(!1)},[o]);let T=A(P=>{C(k=>k===null?k:Xu(P,t,g))},[t,g]),I=A((P,k="foreground")=>{if(n){P?.preventDefault();return}if(o!==null){P?.preventDefault(),x(!0);return}if(r){P?.preventDefault(),a();return}if(i&&(u.current.get(d)??0)>0){P?.preventDefault(),p();return}let S=b.current,L=FD({prompt:e.current,submissionTarget:l?"pending-user-input":"provider-turn",maxInputChars:t,t:g,event:P,onSend:_=>f(_,k)}),R=_=>{S===b.current&&(C(_.validationMessage),_.didDispatch&&(s(),m()&&h()))};if(OD(L))return L.then(R);R(L)},[l,i,h,d,r,t,n,a,s,f,p,u,e,o,m,g]);return{composerSubmissionError:v??(y?o:null),setComposerSubmissionError:C,revalidatePromptLength:T,submitComposer:I}}function $1(e){let{api:t,t:n,limits:o,composerDraftTarget:r,composerDraft:a,composerDocumentKey:s,promptRef:i,promptInputRef:l,pendingImageCompressionsRef:d,setComposerDraftPrompt:u,setModelSendBlockShown:f,onSend:p,onCompactContext:m,blurMobileComposerAfterSend:h,isMobileViewport:g,isComposerApprovalState:v,activePendingApproval:C,activePendingProgress:y,activePendingResolvedAnswers:x,pendingUserInputCount:b,activeThreadId:T,phase:I,isSendBusy:P,environmentUnavailable:k,compactDisabled:S,noProviderAvailable:L,isSendDisabled:R,sendDisabledReason:_,isModelSendBlocked:E,showPlanFollowUpPrompt:D}=e,H=H1(),K=t.draft.useThreadDraftSelector(r,ie=>F1(ie.prompt)),O=H!==null&&K&&!v&&y===null,Z=A(()=>!g||P||R||L||k!==null||I==="running"?!1:y?y.isLastQuestion&&!!x:D||a.hasSendableContent,[y,x,a.hasSendableContent,k,g,P,R,L,I,D]),{composerSubmissionError:N,setComposerSubmissionError:B,revalidatePromptLength:ue,submitComposer:U}=U1({promptRef:i,maxInputChars:o.maxInputChars,noProviderAvailable:L,sendDisabledReason:_,isModelSendBlocked:E,onModelSendBlocked:()=>{f(!0)},onDispatched:()=>{f(!1)},activeThreadId:T,activePendingProgress:y,composerDocumentKey:s,pendingImageCompressionsRef:d,onSend:p,onStillCompressing:()=>{t.notify.info(n("composer.stillCompressing"),n("composer.sendAgainThumbnail"))},shouldBlurMobileComposerOnSubmit:Z,blurMobileComposerAfterSend:h}),oe=M(!1),Q=A(ie=>{if(ie?.preventDefault(),H===null||oe.current)return;if(H.unavailableReason!==null){B(H.unavailableReason);return}let J=i.current,ae=B1(J),Se=z1(ae);if(Se==="empty")return;if(Se==="multiline"){B(n("composer.shellCommand.singleLine"));return}B(null),oe.current=!0;let we=r;H.run(ae).then(Ce=>{!Ce||i.current!==J||(i.current="",u(we,""),l.current?.syncCursor(0,null))}).finally(()=>{oe.current=!1})},[r,H,i,u,B,n]),V=A((ie,J)=>{if(O){Q(ie);return}U(ie,J)},[Q,O,U]),W=A(()=>{if(!O)return!1;let ie=i.current.slice(1);return i.current=ie,u(r,ie),l.current?.resetCursorState({prompt:ie,cursor:ie.length}),!0},[r,i,u,O]),ee=A(()=>{S||L||C!==null||b>0||I==="running"||P||!T||m()},[C,T,S,P,L,m,b,I]);return{composerSubmissionError:N,revalidatePromptLength:ue,submitComposerOrShellCommand:V,exitShellCommandMode:W,compactThreadContext:ee,hostShellCommand:H,shellCommandMode:O}}X();X();var nh=fe(function(t){let{t:n}=le();if(t.count===0)return null;let o=t.placement==="inline",r=c("span",{className:G("text-[10px] font-medium leading-none tabular-nums",t.pulsing?"animate-[prompt-stash-count-enter_180ms_ease-out_both] text-primary motion-reduce:animate-none":"text-muted-foreground"),children:t.count},t.pulseKey);return o?w(re,{size:"micro",variant:"ghost-muted","data-prompt-stash-badge":"true","aria-label":n("stash.ariaLabel",{count:t.count}),"aria-expanded":t.menuOpen,className:G("shrink-0 gap-1 px-1.5",(t.menuOpen||t.pulsing)&&"[--control-icon-color:currentColor] text-foreground"),onPointerDown:a=>a.preventDefault(),onClick:t.onToggleMenu,children:[c(Zi,{className:"size-3 shrink-0","aria-hidden":"true"}),r]}):w("button",{type:"button","data-prompt-stash-badge":"true","aria-label":n("stash.ariaLabel",{count:t.count}),"aria-expanded":t.menuOpen,className:G("chat-composer-shoulder-tab chat-composer-stash-tab absolute -top-7 right-4 z-0 inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-t-xl border border-b-0 px-3 pb-1 text-xs leading-none","transition-colors duration-(--control-duration)",t.menuOpen&&"pointer-events-none",t.menuOpen||t.pulsing?"text-foreground":"text-muted-foreground hover:text-foreground"),onPointerDown:a=>{a.preventDefault()},onClick:t.onToggleMenu,children:[c(Zi,{className:"size-3 shrink-0","aria-hidden":"true"}),n("stash.label"),r]})});X();function V1(e){let t=new Map;return e.map(n=>{let o=t.get(n.step)??0;return t.set(n.step,o+1),{key:`${n.step}:${o}`,step:n}})}function K1({className:e,steps:t}){return t.length<=1?null:c("span",{"aria-hidden":!0,className:G("flex w-10 shrink-0 items-center gap-0.5",e),children:V1(t).map(({key:n,step:o})=>c("span",{className:G("h-[3px] min-w-0 flex-1 rounded-full",o.status==="completed"?"bg-success":o.status==="inProgress"?"bg-primary":"bg-muted-foreground/25")},n))})}var oh=fe(function({expanded:t,hasTrailingShoulder:n=!1,onDismiss:o,onToggle:r,placement:a="tab",progress:s,steps:i}){let{t:l}=le();if(s.totalSteps<=0)return null;let d=s.completedSteps>=s.totalSteps,u=l("tasksBadge.ariaLabel",{completed:s.completedSteps,total:s.totalSteps,step:s.step});return a==="inline"?w("span",{className:"inline-flex shrink-0 items-center gap-0.5","data-composer-tasks-badge":"true",children:[w(re,{size:"micro",variant:"ghost-muted","aria-expanded":t,"aria-label":u,className:"shrink-0 gap-1 px-1.5",onClick:r,onPointerDown:f=>f.preventDefault(),children:[c(_s,{"aria-hidden":!0,className:"size-3 shrink-0"}),c("span",{children:l("tasksBadge.label")}),c(K1,{steps:i}),w("span",{className:G("font-medium tabular-nums",d?"text-success":"text-muted-foreground"),children:[s.completedSteps,"/",s.totalSteps]})]}),c(re,{size:"icon-micro",variant:"ghost-muted","aria-label":l("tasksBadge.dismissLabel"),className:"shrink-0",onClick:o,onPointerDown:f=>f.preventDefault(),children:c(Kt,{"aria-hidden":!0,className:"size-2.5"})})]}):w("div",{className:G("chat-composer-shoulder-tab chat-composer-tasks-tab absolute -top-7 left-4 z-0 flex h-8 items-center gap-1 rounded-t-xl border border-b-0 px-2 pb-1 text-xs leading-none text-muted-foreground",n?"right-28":"right-4",d&&"text-foreground"),"data-composer-tasks-badge":"true",children:[w("button",{type:"button","aria-expanded":t,"aria-label":u,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 self-stretch text-muted-foreground hover:text-foreground",onClick:r,onPointerDown:f=>f.preventDefault(),children:[c(_s,{"aria-hidden":!0,className:"size-icon-1 shrink-0"}),c("span",{className:"shrink-0",children:l("tasksBadge.label")}),c("span",{className:"min-w-0 flex-1 truncate text-left font-medium text-foreground/80","data-composer-task-current":"true",children:s.step}),w("span",{className:G("shrink-0 font-medium tabular-nums",d?"text-success":"text-muted-foreground"),children:[s.completedSteps,"/",s.totalSteps]}),c(K1,{className:"w-20",steps:i})]}),c(re,{size:"icon-micro",variant:"ghost-muted","aria-label":l("tasksBadge.dismissLabel"),className:"shrink-0",onClick:o,onPointerDown:f=>f.preventDefault(),children:c(Kt,{"aria-hidden":!0,className:"size-3"})})]})}),q1=fe(function({onDismiss:t,onCollapse:n,progress:o,steps:r}){let{t:a}=le();return w("div",{className:"chat-composer-top-drawer","data-chat-composer-tasks-drawer":"true",children:[w("div",{className:"flex items-center gap-1 px-3 py-1.5 sm:px-4",children:[w("button",{type:"button","aria-expanded":"true",className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 self-stretch text-left text-xs text-muted-foreground hover:text-foreground",onClick:n,onPointerDown:s=>s.preventDefault(),children:[c(_s,{"aria-hidden":!0,className:"size-icon-1 shrink-0"}),c("span",{className:"font-medium text-foreground",children:a("tasksBadge.label")}),w("span",{className:"tabular-nums",children:[o.completedSteps,"/",o.totalSteps]})]}),c(re,{size:"icon-micro",variant:"ghost-muted","aria-label":a("tasksBadge.dismissLabel"),className:"shrink-0",onClick:t,onPointerDown:s=>s.preventDefault(),children:c(Kt,{"aria-hidden":!0,className:"size-3"})})]}),c("div",{className:"space-y-px px-3 pb-4 sm:px-4",role:"list",children:V1(r).map(({key:s,step:i})=>w("div",{className:"flex items-baseline gap-2 text-xs leading-5",role:"listitem",children:[c("span",{"aria-hidden":!0,className:G("w-3 shrink-0 text-center font-mono text-[10px]",i.status==="completed"?"text-success":i.status==="inProgress"?"text-primary":"text-muted-foreground/40"),children:i.status==="completed"?"\u2713":i.status==="inProgress"?"\u25CF":"\u25CB"}),c("span",{className:G("min-w-0 flex-1",i.status==="completed"?"text-muted-foreground/55":i.status==="inProgress"?"text-foreground/90":"text-muted-foreground/70"),children:i.step}),c("span",{className:"ml-auto w-10 shrink-0 text-right text-[10px] text-muted-foreground/45 tabular-nums","data-composer-task-duration":"true",children:i.durationMs!==void 0?lr(i.durationMs):i.status==="inProgress"?a("tasksBadge.now"):null})]},s))})]})});function W1(e){let{activeThreadId:t,activeThread:n,activeTasksProgress:o,activeTaskSteps:r,isTasksDrawerOpen:a,setIsTasksDrawerOpen:s,dismissedTasksTurnId:i,setDismissedTasksTurnId:l,stashQueue:d,isStashMenuOpen:u,stashPulse:f,toggleInlineStashMenu:p,isComposerApprovalState:m,externalDrawerAttached:h,showComposerTopDrawer:g,isComposerCollapsedMobile:v,hasBlockingComposerTopDrawer:C}=e,y=A(()=>{s(D=>!D)},[]),x=n?.latestTurn?.turnId??null,b=x!==null&&i===x,T=b?null:o,I=b?null:r,P=A(()=>{x!==null&&l(x),s(!1)},[x]),S=d.length>0&&!m&&(h||g||a||v)?c(nh,{count:d.length,menuOpen:u,placement:"inline",pulseKey:f.key,pulsing:f.active,onToggleMenu:p}):null,R=T!==null&&I!==null&&!a&&!C&&(h||g||v)?c(oh,{expanded:!1,onDismiss:P,onToggle:y,placement:"inline",progress:T,steps:I}):null,_=!h&&!g&&!a&&!v,E=_&&(d.length>0||T!==null&&I!==null&&T.totalSteps>0);return z(()=>{(T===null||I===null)&&s(!1)},[I,T]),z(()=>{C&&s(!1)},[C]),z(()=>{s(!1)},[t]),{toggleTasksDrawer:y,dismissTasks:P,visibleTasksProgress:T,visibleTaskSteps:I,inlineStashBadge:S,inlineTasksBadge:R,showShoulderTabs:_,hasShoulderTab:E}}X();function G1(e){return e==="ready"}function j1(e){return e==="ready"||e==="unchecked"||e==="checking"}function Q1(e,t){switch(e){case"ready":return t("readiness.ready.title");case"unchecked":return t("readiness.unchecked.title");case"checking":return t("readiness.checking.title");case"disabled":return t("readiness.disabled.title");case"not-installed":return t("readiness.notInstalled.title");case"unauthenticated":return t("readiness.unauthenticated.title");case"error":return t("readiness.error.title");default:return e}}function rh(e){return e.enabled&&j1(e.readiness)}function Yu(e){return e.enabled}function X1(e){let t=new Map;for(let n of e){let o=t.get(n.driverKind);o?o.push(n):t.set(n.driverKind,[n])}return[...t.values()].flat()}var Y1=e=>e.enabled;function J1(e,t){let n=e.find(o=>o.instanceId===t);if(n)return n.driverKind}function N7(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _7(e,t){let n=t?.trim();if(!n)return e;let o=new RegExp(`^${N7(n)}(?:\\s*[.:/-]\\s*|\\s+)`,"iu");return e.replace(o,"").trim()||e}function Nb(e,t){let n=t?.preferShortName&&e.shortName?e.shortName:e.name;return _7(n,e.subProvider)}function yd(e){return Nb(e,{preferShortName:!0})}function Z1(e,t){if(!e)return null;let n=t.get(e.instanceId)?.find(o=>o.slug===e.model);return n?yd(n):e.model}function eO(e,t,n){return typeof n=="number"&&n>0?e("contextWindow.compactsAtThreshold",{threshold:n.toLocaleString()}):t?e("contextWindow.compactsForModel",{model:t}):e("contextWindow.compactsWhenNeeded")}X();var tO="h-7 min-h-7 gap-1.5 rounded-[var(--control-radius)] px-2.5 text-secondary-label transition-none hover:text-foreground [&_svg[data-composer-control-icon]]:mx-0 [&_svg[data-composer-control-chevron]]:-mx-0.5";function ho({className:e,size:t="sm",variant:n="ghost",...o}){return c(re,{className:G(tO,e),size:t,variant:n,...o})}function er({icon:e,className:t,opticalSize:n="default"}){return c(e,{"aria-hidden":"true",className:G("shrink-0",n==="large"?"size-4.5":"size-4",t),"data-composer-control-icon":!0})}function Wr(){return c(ln,{"aria-hidden":"true",className:"-mx-0.5 size-icon-2 shrink-0 text-icon-muted","data-composer-control-chevron":!0,strokeWidth:2.25})}function ah({className:e,size:t="sm",variant:n="ghost",...o}){return c(Ws,{className:G(tO,e),icon:c(Wr,{}),size:t,variant:n,...o})}function _b(e,t){if(!e)return t("composer.agentPickerLabel");let n=e.agentName?.trim(),o=e.displayName.trim();return n?!o||o===n?n:`${n} \xB7 ${o}`:o}function Db(e,t){let n=e.filter(Yu),o=t.lockedProvider;if(o==null||o.length===0)return n;let r=t.lockedContinuationGroupKey;return n.filter(a=>a.driverKind===o&&(!r||a.continuationGroupKey===r))}var Ob=fe(function(t){let{t:n}=le(),o=t.instanceEntries.filter(Yu),r=t.unavailableInstanceId??null,a=r===null?null:t.instanceEntries.find(g=>g.instanceId===r)??null,s=t.notChosen===!0&&r===null,i=r!==null||s?null:o.find(g=>g.instanceId===t.activeInstanceId)??null,l=t.lockedProvider!=null&&t.lockedProvider.length>0,d=Db(t.instanceEntries,t),u=d.some(g=>g.instanceId!==t.activeInstanceId),f=t.disabled||!l?null:r!==null?d.length===0?n("composer.agentUnavailableNoChoice"):null:u?null:n("composer.agentSwitchUnavailable"),p=Fo(),m=G("min-w-0 justify-between whitespace-nowrap",t.compact?"max-w-36 shrink-0":"max-w-44 shrink"),h=w(he,{children:[r!==null?c(Jt,{"aria-hidden":"true",className:"size-4 shrink-0 text-warning"}):s?null:i?c(nr,{driver:i.driverKind,displayName:i.displayName,accentColor:i.accentColor,className:"size-4",iconClassName:"size-4",indicatorBackground:"var(--contrast-input)"}):null,r!==null?w("span",{className:"min-w-0 truncate text-warning","data-composer-agent-unavailable":"true",children:[a===null?r:_b(a,n)," \xB7 ",n("composer.agentUnavailableBadge")]}):s?c("span",{className:"min-w-0 truncate","data-composer-agent-not-chosen":"true",children:n("composer.agentChoosePlaceholder")}):c("span",{className:"min-w-0 truncate",children:_b(i,n)})]});return f!==null?w(Ue,{children:[w(Ke,{render:c(ho,{"aria-label":n("composer.agentPickerLabel"),"aria-describedby":p,"data-composer-agent-picker":"true",softDisabled:!0,className:m}),children:[h,c("span",{id:p,className:"sr-only",children:f})]}),c($e,{side:"top",align:"start",className:"max-w-80 leading-snug",children:f})]}):w(ro,{children:[w(so,{render:c(ho,{"aria-label":n("composer.agentPickerLabel"),"data-composer-agent-picker":"true",disabled:t.disabled||d.length===0,className:m}),children:[h,c(Wr,{})]}),c(ao,{align:"start",children:c(rr,{value:r!==null||s?"":t.activeInstanceId,onValueChange:g=>{!g||r===null&&!s&&g===t.activeInstanceId||t.onInstanceChange(g)},children:d.map(g=>c(ko,{value:g.instanceId,children:_b(g,n)},g.instanceId))})})]})});function nO(e){return c(Ob,{...e})}function Fb(e){switch(e){case"probing":return{seatKey:"modelPicker.fetchingModels",blockKey:"composer.modelFetching",canChooseModel:!1};case"missing":return{seatKey:"modelPicker.chooseModel",blockKey:"composer.modelMissing",canChooseModel:!0};case"unavailable":return{seatKey:null,blockKey:"composer.modelUnavailable",canChooseModel:!0};default:return null}}function oO(e){return e.submissionTarget==="provider-turn"&&e.status!=="known"}function rO(e){if(!e.blockedOnSend||e.submissionTarget!=="provider-turn")return null;let t=Fb(e.status);return t===null?{blockKey:"composer.modelReady",canChooseModel:!1}:{blockKey:t.blockKey,canChooseModel:t.canChooseModel}}function D7(e){return typeof e!="string"?null:e.trim()||null}function O7(e){if(e.type!=="select"||!e.promptInjectedValues?.includes("ultrathink"))return e;let t=e.options.filter(r=>r.id!=="ultrathink"),n=e.currentValue==="ultrathink"?void 0:e.currentValue,o=t.length===0?e.promptInjectedValues:e.promptInjectedValues.filter(r=>r!=="ultrathink");return{id:e.id,label:e.label,...e.description?{description:e.description}:{},type:"select",options:t,...n?{currentValue:n}:{},...o.length>0?{promptInjectedValues:o}:{}}}function F7(e){let t=O7(e);return t.type==="select"?{...t,options:[...t.options],...t.promptInjectedValues?{promptInjectedValues:[...t.promptInjectedValues]}:{}}:{...t}}function B7(e,t){return e?.find(o=>o.id===t)?.value}function aO(e,t){let n=D7(t);return n?e.options.length===0?n==="ultrathink"&&e.promptInjectedValues?.includes(n)?void 0:n:e.promptInjectedValues?.includes(n)&&e.options.some(o=>o.id===n)?e.options.find(o=>o.isDefault)?.id:e.options.some(o=>o.id===n)?n:e.currentValue??e.options.find(o=>o.isDefault)?.id:e.currentValue??e.options.find(o=>o.isDefault)?.id}function z7(e,t){if(e.type==="boolean")return typeof t=="boolean"?{...e,currentValue:t}:e;let n=typeof t=="string"?aO(e,t):aO(e,e.currentValue);if(!n){let{currentValue:o,...r}=e;return r}return{...e,currentValue:n}}function Ju(e){let{caps:t,selections:n}=e;return(t.optionDescriptors??[]).map(F7).map(r=>z7(r,B7(n,r.id)??r.currentValue))}function Ki(e){if(e)return e.type==="boolean"||e.currentValue?e.currentValue:e.options.find(t=>t.isDefault)?.id}function Bb(e){if(!e)return;let t=Ki(e);if(typeof t=="string")return e.options.find(n=>n.id===t)?.label}function H7(e){if(!e||e.length===0)return;let t=[];for(let n of e){let o=Ki(n);(typeof o=="string"||typeof o=="boolean")&&t.push({id:n.id,value:o})}return t.length>0?t:void 0}function sh(e,t){if(!t||t.length===0)return;let n=new Set(t.map(r=>r.id)),o=H7(e)?.filter(r=>n.has(r.id));return o&&o.length>0?o:void 0}X();function U7(){let{t:e}=le();return c(Er,{variant:"outline",className:"inline-flex h-4 w-fit min-w-0 items-center justify-center gap-0 border-border/70 bg-muted/60 px-1.5 py-0 font-semibold text-[10px] text-muted-foreground leading-none sm:h-4",children:e("traits.default")})}function $7(e,t,n){return sh(e,[...t??[],{id:n}])}function sO(e,t,n){return e.map(o=>o.id!==t?o:o.type==="boolean"?{...o,...typeof n=="boolean"?{currentValue:n}:{}}:{...o,...typeof n=="string"?{currentValue:n}:{}})}function K7(e){if(!e)return null;let t=Ki(e);return typeof t=="string"?t:null}function iO(){let{t:e}=le();return t=>E0(e,t)}var V7=e=>e;function q7(e,t,n,o,r,a,s){let i=e.getModelCapabilities(n,o,a),l=xp(t,n,o),d=l?A0(bp(r,a),s):Ju({caps:i,selections:r}),u=d.filter(C=>C.type==="select"),f=d.filter(C=>C.type==="boolean"),p=u[0]??null,m=u.find(C=>C.id==="contextWindow")??null,h=u.find(C=>C.id==="agent")??null,g=f.find(C=>C.id==="fastMode")??null,v=f.find(C=>C.id==="thinking")??null;return{caps:i,descriptors:d,selectDescriptors:u,booleanDescriptors:f,primarySelectDescriptor:p,contextWindowDescriptor:m,agentDescriptor:h,fastModeDescriptor:g,thinkingDescriptor:v,modelIsUnavailable:l}}function zb(e){let t=q7(e.modelApi,e.provider,e.models,e.model,e.modelOptions,e.planModeEnabled,e.labelOf??V7),n=t.primarySelectDescriptor!==null,o=t.thinkingDescriptor!==null,r=t.fastModeDescriptor!==null,a=t.contextWindowDescriptor!==null,s=t.agentDescriptor!==null;return{...t,showEffort:n,showThinking:o,showFastMode:r,showContextWindow:a,showAgent:s,hasAnyControls:n||o||r||a||s||t.modelIsUnavailable&&t.descriptors.length>0}}function Hb(e){return zb(e).hasAnyControls}var Ub=fe(function({provider:t,instanceId:n,models:o,model:r,modelOptions:a,planModeEnabled:s,...i}){let{t:l}=le(),d=iO(),u=Nt(),f=u.draft.useStore(T=>T.setProviderModelOptions),p=A(T=>{if("onModelOptionsChange"in i){i.onModelOptionsChange(T);return}let I=i.threadRef??i.draftId;I&&f(I,t,T,{...n?{instanceId:n}:{},model:r,persistSticky:!0})},[n,r,i,t,f]),{descriptors:m,selectDescriptors:h,booleanDescriptors:g,hasAnyControls:v,modelIsUnavailable:C}=zb({modelApi:u.model,provider:t,models:o,model:r,modelOptions:a,planModeEnabled:s,labelOf:d}),y=zv(l,h),x=(T,I)=>{p($7(T,a,I))},b=(T,I)=>{I&&x(sO(m,T.id,I),T.id)};return v?C?c(he,{children:m.map((T,I)=>{let P=T.type==="boolean"?l(T.currentValue===!0?"traits.on":"traits.off"):Bb(T);return P?w("div",{children:[I>0?c(sa,{}):null,w(ol,{children:[c(lw,{children:T.label}),c("div",{className:"px-2 pb-1.5 text-ui-sm text-muted-foreground",children:P})]})]},T.id):null})}):w(he,{children:[y.map((T,I)=>{let P=K7(T)??"";return w("div",{children:[I>0?c(sa,{}):null,w(ol,{children:[c("div",{className:"px-2 pt-1.5 pb-1 font-medium text-muted-foreground text-xs",children:T.label}),c(rr,{value:P,onValueChange:k=>b(T,k),children:T.options.map(k=>c(ko,{value:k.id,hideIndicator:!0,closeOnClick:!0,children:w("span",{className:"flex w-full min-w-0 flex-col",children:[c("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:w("span",{className:"min-w-0 truncate",children:[k.label,k.isDefault?w(he,{children:[" ",c(U7,{})]}):null]})}),k.description?c("span",{className:"max-w-56 text-pretty text-muted-foreground/80 text-xs",children:k.description}):null]})},k.id))})]})]},T.id)}),g.map((T,I)=>{let P=T.currentValue===!0?"on":"off";return w("div",{children:[I>0||y.length>0?c(sa,{}):null,w(ol,{children:[c("div",{className:"px-2 py-1.5 font-medium text-muted-foreground text-xs",children:T.label}),c(rr,{value:P,onValueChange:k=>{x(sO(m,T.id,k==="on"),T.id)},children:["on","off"].map(k=>c(ko,{value:k,hideIndicator:!0,closeOnClick:!0,children:c("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:c("span",{children:l(k==="on"?"traits.on":"traits.off")})})},k))})]})]},T.id)})]}):null});function W7(e,t){let n=null,o=!1,r=[];for(let a of t.descriptors){if(a.id==="fastMode"&&a.type==="boolean"){o=a.currentValue===!0,n=e(o?"traits.fast":"traits.normal");continue}if(t.provider==="codex"&&a.id==="serviceTier"&&a.type==="select"){let i=Ki(a),l=a.options.find(({label:d})=>d==="Fast");if(l&&(i==="default"||i===l.id)){o=i===l.id,n=a.options.find(({id:d})=>d===i)?.label??e(o?"traits.fast":"traits.normal");continue}}let s=a.type==="boolean"?e("traits.labelWithState",{label:a.label,state:e(a.currentValue===!0?"traits.on":"traits.off")}):Bb(a);typeof s=="string"&&s.length>0&&r.push(s)}return r.length===0&&n!==null?{label:n,showFastModeIcon:!1}:{label:r.join(" \xB7 "),showFastModeIcon:o}}var lO=fe(function({provider:t,instanceId:n,models:o,model:r,modelOptions:a,planModeEnabled:s,triggerVariant:i,triggerClassName:l,...d}){let[u,f]=j(!1),{t:p}=le(),m=iO(),h=Nt().model,{descriptors:g}=zb({modelApi:h,provider:t,models:o,model:r,modelOptions:a,planModeEnabled:s,labelOf:m});if(!Hb({modelApi:h,provider:t,models:o,model:r,modelOptions:a,planModeEnabled:s}))return null;let{label:v,showFastModeIcon:C}=W7(p,{provider:t,descriptors:zv(p,g)}),y=C?w(he,{children:[c(er,{icon:Ks,className:G("fill-current opacity-80",t==="claudeAgent"?"text-[#d97757]":"text-foreground")}),c("span",{className:"sr-only",children:p("traits.fastModeOn")})]}):null,x=t==="codex";return w(ro,{open:u,onOpenChange:b=>{f(b)},children:[c(so,{render:c(ho,{variant:i??"ghost",className:G(x?"min-w-0 max-w-40 shrink justify-start overflow-hidden whitespace-nowrap sm:max-w-48":"shrink-0 whitespace-nowrap",l)}),children:x?w("span",{className:"flex min-w-0 w-full items-center gap-1.5 overflow-hidden",children:[y,c("span",{className:"min-w-0 truncate",children:v}),c(Wr,{})]}):w(he,{children:[y,c("span",{children:v}),c(Wr,{})]})}),c(ao,{align:"start",children:c(Ub,{provider:t,...n?{instanceId:n}:{},models:o,model:r,modelOptions:a,planModeEnabled:s,...d})})]})});function dO(e,t){let{provider:n,model:o,models:r,modelOptions:a,planModeEnabled:s}=e;if(xp(n,r,o)){let m=bp(a,s);return{provider:n,modelOptionsForDispatch:m&&m.length>0?[...m]:void 0}}let i=t.getModelCapabilities(r,o,s),l=Ju({caps:i,selections:a}),d=r.find(m=>m.slug===o)?.capabilities?.optionDescriptors?.find(m=>m.type==="select"&&m.id==="effort"),u=i.optionDescriptors?.find(m=>m.type==="select"&&m.id==="effort"),p=n==="claudeAgent"&&a?.some(m=>m.id==="effort"&&m.value==="ultrathink")&&(d?.type==="select"&&d.promptInjectedValues?.includes("ultrathink")?!0:u?.type==="select"&&(u.promptInjectedValues?.includes("ultrathink")||u.options.length>0&&!u.options.some(m=>m.id==="ultrathink")))?a?.filter(m=>m.id!=="effort"):a;return{provider:n,modelOptionsForDispatch:sh(l,[...p??[],...s?[]:G7(r,o,t)])}}function G7(e,t,n){let o=Ju({caps:n.getModelCapabilities(e,t,!0),selections:void 0}).find(r=>r.type==="select"&&r.id==="agent");return o&&Ki(o)==="plan"?[{id:o.id}]:[]}function cO(e,t){let{provider:n,instanceId:o,threadRef:r,draftId:a,model:s,models:i,modelOptions:l,planModeEnabled:d}=t;return!(r!==void 0||a!==void 0)||!Hb({modelApi:t.modelApi,provider:n,models:i,model:s,modelOptions:l,planModeEnabled:d})?null:c(e,{provider:n,...o?{instanceId:o}:{},models:i,...r?{threadRef:r}:{},...a?{draftId:a}:{},model:s,modelOptions:l,planModeEnabled:d})}function uO(e){return cO(Ub,e)}function fO(e){return cO(lO,e)}X();function pO(e){let{threadId:t,isLocalDraftThread:n,selection:o,selectionsEqual:r,onChosen:a}=e,s=M(null);z(()=>{let i=s.current;s.current={threadId:t,selection:o},!(i===null||i.threadId!==t||n)&&(r(i.selection,o)||a?.(o))},[t,n,o,r,a])}X();function mO(e){let{api:t,providerStatus:n,instanceId:o,environmentId:r,cwd:a,threadId:s}=e,i=t.providerInventory.useWorkspaceInventory({environmentId:r,instanceId:o,cwd:a,threadId:s});return $(()=>n===null||i===null?n:{...n,slashCommands:i.slashCommands,skills:i.skills},[n,i])}function gO(e){let{api:t,t:n,settings:o,composerDraft:r,composerDraftTarget:a,environmentId:s,gitCwd:i,routeKind:l,threadId:d,activeThread:u,isLocalDraftThread:f,unavailableAgentInstanceId:p,agentNotChosen:m,runtimeMode:h,lockedProvider:g,providerStatuses:v,projectId:C,activeProjectDefaultModelSelection:y,activeThreadModelSelection:x,compactDisabledReason:b,externalSendDisabledReason:T,attachmentBlockReason:I,answeringQuestion:P,setComposerDraftNativeMode:k,handleNativeModeChange:S,onProviderInstanceSelect:L,onModelSelectionChosen:R}=e,_=$(()=>X1(t.model.applyInstanceSettings(t.model.deriveInstanceEntries(v),o)),[t.model,v,o]),E=r.activeProvider??null,D=u?.session?.providerInstanceId??x?.instanceId??y?.instanceId??null,K=J1(_,E??D)??t.model.makeDriverKind("unconfigured"),O=g??K,Z=$(()=>{if(!g||!u)return null;let yt=u.session?.providerInstanceId??x?.instanceId;return yt?_.find(Ot=>Ot.instanceId===yt)?.continuationGroupKey??null:null},[u,x?.instanceId,g,_]),N=$(()=>{if(p!==null)return p;let yt=[r.activeProvider,u?.session?.providerInstanceId,x?.instanceId,y?.instanceId];for(let Ot of yt){if(!Ot)continue;let xt=_.find(Ct=>Ct.instanceId===Ot&&Y1(Ct));if(xt){if(g&&xt.driverKind!==g||Z&&xt.continuationGroupKey!==Z)continue;return xt.instanceId}}return t.model.noProviderSelection.instanceId},[y?.instanceId,u?.session?.providerInstanceId,x?.instanceId,r.activeProvider,Z,g,_,p]),B=p!==null,ue=$(()=>B||m?void 0:_.find(yt=>yt.instanceId===N),[m,B,_,N]),U=ue===void 0&&!B&&!m,oe=B&&Db(_,{lockedProvider:g,lockedContinuationGroupKey:Z}).length===0,Q=b??(U?n("composer.compactingUnavailable"):null),V=ue?.driverKind??O,{modelOptions:W,selectedModel:ee,selectedModelStatus:ie}=t.draft.useEffectiveModelState({threadRef:a,providers:v,selectedProvider:V,selectedInstanceId:N,threadModelSelection:x,projectModelSelection:y,settings:o}),J=$(()=>ue?.snapshot??null,[ue]),ae=mO({api:t,providerStatus:J,instanceId:ue?.instanceId??null,environmentId:s,cwd:i,threadId:l==="server"?d:null}),Se=$(()=>ue?.models??[],[ue]),we=$(()=>dO({provider:V,model:ee,models:Se,modelOptions:W?.[N],planModeEnabled:o.planModeEnabled},t.model),[W,N,ee,V,Se,o.planModeEnabled]),Ce=we.modelOptionsForDispatch,Re=o.planModeEnabled,rt=$(()=>({showInteractionModeToggle:Re&&t.model.getInteractionModeToggle(v,V),runtimeModeSwitch:ae?.runtimeModeSwitch??"next-turn"}),[Re,v,V,ae]),te=ae?.supportsNativeModeSwitch===!0,se=f&&te?r.nativeModeByProvider?.[N]??null:null,q=$(()=>t.model.resolveNativeMode(ae,{runtimeMode:h,nativeModeId:f?se:u?.nativeModeId??null}),[t.model,u?.nativeModeId,ae,h,f,se]),ce=se&&q?.current.id===se?se:void 0,Y=A(yt=>{f&&k(a,N,yt),S(yt)},[f,k,a,N,S]),ke=$(()=>t.model.createSelection(N,ee,Ce),[t.model,N,ee,Ce]);pO({threadId:u?.id??null,isLocalDraftThread:f,selection:ke,selectionsEqual:t.model.selectionsEqual,onChosen:B||m?void 0:R});let Fe=A(yt=>L(yt,ke),[L,ke]),Ge=ee,Ve=$(()=>{let yt=new Map;for(let Ot of _)yt.set(Ot.instanceId,t.model.getAppModelOptionsForInstance(o,Ot,Ot.instanceId===N?Ge:null));return yt},[t.model,_,N,Ge,o]),It=$(()=>(Ve.get(N)??[]).some(Ot=>Ot.slug===Ge)?Ge:t.model.normalizeSlug(Ge)??Ge,[t.model,Ve,N,Ge,V]),ft=f&&g===null,wt=t.pluginComposer.useOptions(ft?s:null,C),Ze=wt.options,it=ft?r.selectedPluginActionKey:null,Zt=$(()=>it===null?null:Ze.find(yt=>yt.id===it)??null,[it,Ze]),Ht=it!==null,de=Ht&&Zt===null?n(wt.isKnown?"composer.pluginUnavailable":"composer.pluginLoading"):null,Pe=T??de??(P?null:I),Ie=Pe!==null,[ze,nt]=j(!1);z(()=>{nt(!1)},[N]);let Pt=oO({status:ie,submissionTarget:P?"pending-user-input":"provider-turn"}),tn=rO({blockedOnSend:ze,status:ie,submissionTarget:P?"pending-user-input":"provider-turn"}),Dn=$(()=>Z1(x,Ve),[x,Ve]);return{providerInstanceEntries:_,lockedContinuationGroupKey:Z,selectedInstanceId:N,agentUnavailable:B,selectedProviderEntry:ue,noProviderAvailable:U,agentUnavailableNoChoice:oe,resolvedCompactDisabledReason:Q,selectedProvider:V,composerModelOptions:W,selectedModel:ee,selectedModelStatus:ie,selectedProviderStatus:ae,selectedProviderModels:Se,composerProviderState:we,selectedModelOptionsForDispatch:Ce,planModeUiEnabled:Re,composerProviderControls:rt,canSwitchNativeMode:te,composerNativeMode:q,selectedNativeModeId:ce,handleComposerNativeModeChange:Y,selectedModelSelection:ke,onAgentInstanceChange:Fe,modelOptionsByInstance:Ve,selectedModelForPickerWithCustomFallback:It,canSelectPluginAction:ft,pluginOptions:Ze,selectedPluginAction:Zt,isPluginComposer:Ht,pluginBlockMessage:de,sendDisabledReason:Pe,isSendDisabled:Ie,setModelSendBlockShown:nt,isModelSendBlocked:Pt,modelSendBlock:tn,activeThreadModelDisplayName:Dn}}function hO(e){let{api:t,settings:n,routeKind:o,routeThreadRef:r,draftId:a,selectedProvider:s,selectedInstanceId:i,selectedModel:l,selectedProviderModels:d,composerModelOptions:u}=e,f={modelApi:t.model,provider:s,instanceId:i,...o==="server"?{threadRef:r}:{},...o==="draft"&&a?{draftId:a}:{},model:l,models:d,modelOptions:u?.[i],planModeEnabled:n.planModeEnabled};return{providerTraitsMenuContent:uO(f),providerTraitsPicker:fO(f)}}X();X();var $b="ycodium:status-bar-usage-surface";var vO=fe(function(t){let{data:n,target:o}=qo(),r=XS(),a=n.useAccountUsageInstance(o),s=`${o.environmentId}:${o.threadId}`;return z(()=>{if(r)return window.dispatchEvent(new CustomEvent($b,{detail:{owner:s,environmentId:o.environmentId,instanceId:a?.instanceId??null,instanceLabel:a?.instanceLabel??null,decisionOccupiesComposer:t.decisionOccupiesComposer,clear:!1}})),()=>{window.dispatchEvent(new CustomEvent($b,{detail:{owner:s,clear:!0}}))}},[r,a?.instanceId,a?.instanceLabel,s,t.decisionOccupiesComposer,o.environmentId]),null});function j7(e,t,n){let o=[];o.push(t(e));let r=n(e);return r&&o.push(r),e.pageUrl&&o.push(e.pageUrl),e.selector&&o.push(e.selector),e.htmlPreview.trim().length>0&&(o.push(""),o.push(e.htmlPreview.trim().slice(0,600))),o.join(`
4138
4141
  `)}function Q7({context:e,onRemove:t}){let{t:n}=le(),o=Nt().elementContext,r=o.formatLabel(e),a=o.formatSourceLabel(e);return w(Ue,{children:[c(Ke,{render:w("span",{className:G(Vo,"pr-1"),children:[c(Lr,{className:G(lo,"size-icon-1")}),c("span",{className:co,children:r}),a?c("span",{className:"select-none text-[10px] font-normal leading-tight text-muted-foreground/85",children:a}):null,c("button",{type:"button","aria-label":n("pendingContext.removeElement",{label:r}),className:_p,onClick:s=>{s.preventDefault(),s.stopPropagation(),t(e.id)},children:c(Kt,{className:"size-3","aria-hidden":!0})})]})}),c($e,{side:"top",className:"max-w-96 whitespace-pre-wrap leading-tight",children:j7(e,o.formatLabel,o.formatSourceLabel)})]})}function yO({contexts:e,onRemove:t,className:n}){return e.length===0?null:c("div",{className:G("flex flex-wrap gap-1.5",n),children:e.map(o=>c(Q7,{context:o,onRemove:t},o.id))})}function CO({comments:e,onRemove:t,className:n}){let{t:o}=le();return e.length===0?null:c("div",{className:G("flex flex-wrap gap-1.5",n),children:e.map(r=>{let a=`${r.filePath} ${r.rangeLabel}`,s=w("span",{className:G(Vo,"pr-1"),children:[c(Ds,{className:G(lo,"size-icon-1")}),c("span",{className:co,children:a}),c("button",{type:"button","aria-label":o("pendingContext.removeReviewComment",{label:a}),className:_p,onClick:i=>{i.preventDefault(),i.stopPropagation(),t(r.id)},children:c(Kt,{className:"size-3","aria-hidden":!0})})]},r.id);return r.text.length===0?s:w(Ue,{children:[c(Ke,{render:s}),c($e,{side:"top",className:"max-w-96 whitespace-pre-wrap leading-tight",children:r.text})]},r.id)})})}function ih(e){let{t}=le(),n=t(e.tooltipKey,{count:e.count});return w(Ue,{children:[c(Ke,{render:w("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-muted-foreground",children:[e.icon,e.count]})}),c($e,{side:"top",children:n})]})}function xO({annotations:e,images:t,onRemove:n,onExpandImage:o,uploadsByImageId:r,onRetryUpload:a,className:s}){let{t:i}=le(),l=Nt().elementContext;if(e.length===0)return null;let d=new Map(t.map(u=>[u.id,u]));return c("div",{className:G("flex flex-wrap gap-1.5",s),children:e.map(u=>{let f=d.get(u.id),p=f?r?.[f.id]:void 0,m=u.elements.flatMap(h=>{let g=l.normalizeSelection(h.element);return g?[{id:h.id,label:l.formatLabel(g)}]:[]});return w("section",{className:"group/preview-annotation relative flex min-w-0 max-w-full items-center overflow-hidden rounded-lg border border-border/80 bg-background/72",children:[f?.previewUrl?c("button",{type:"button","aria-label":i("previewAnnotation.previewImage",{name:f.name}),className:"size-14 shrink-0 cursor-zoom-in overflow-hidden border-r border-border/70 bg-muted",onClick:()=>o(f.id),children:c("img",{src:f.previewUrl,alt:i("previewAnnotation.cropAlt"),className:"size-full object-cover transition-transform duration-(--control-duration) group-hover/preview-annotation:scale-[1.03]"})}):c("span",{className:"grid size-10 shrink-0 place-items-center border-r border-border/70 text-message-action",children:c(Lr,{className:"size-icon-2"})}),w("div",{className:"min-w-0 px-2.5 py-2 pr-8",children:[u.comment.trim()?c("p",{className:"max-w-80 truncate text-foreground text-xs font-medium",children:u.comment.trim()}):null,w("div",{className:G("flex min-w-0 items-center gap-2",u.comment.trim()&&"mt-1"),children:[m.length>0?w("div",{className:"flex min-w-0 items-center gap-1",children:[m.slice(0,2).map(({id:h,label:g})=>c("span",{className:"max-w-40 truncate font-mono text-secondary-label text-[10px]",children:g},h)),m.length>2?w("span",{className:"text-secondary-label text-[10px]",children:["+",m.length-2]}):null]}):null,w("div",{className:"flex shrink-0 items-center gap-2",children:[u.elements.length>0?c(ih,{icon:c(Lr,{className:"size-3"}),count:u.elements.length,tooltipKey:"previewAnnotation.elementCount"}):null,u.regions.length>0?c(ih,{icon:c(qd,{className:"size-3"}),count:u.regions.length,tooltipKey:"previewAnnotation.regionCount"}):null,u.strokes.length>0?c(ih,{icon:c(Rr,{className:"size-3"}),count:u.strokes.length,tooltipKey:"previewAnnotation.drawingCount"}):null,u.styleChanges.length>0?c(ih,{icon:c(Bs,{className:"size-3"}),count:u.styleChanges.length,tooltipKey:"previewAnnotation.styleChangeCount"}):null,p?.status==="uploading"?c("span",{className:"text-[10px] text-secondary-label",children:th(p.progress)}):null,p?.status==="failed"&&f&&a?w(Ue,{children:[c(Ke,{render:c(re,{size:"icon-micro",variant:"ghost-muted","aria-label":i("attachments.retryUpload",{name:f.name}),onClick:()=>a(f)}),children:c(Hs,{className:"size-3"})}),c($e,{side:"top",children:eh(p,i)})]}):null]})]})]}),c(re,{size:"icon-micro",variant:"ghost-muted","aria-label":i("previewAnnotation.remove"),className:"absolute right-1.5 top-1.5 [--control-icon-color:currentColor] rounded text-icon-muted hover:bg-muted",onClick:()=>n(u.id),children:c(Kt,{className:"size-3"})})]},u.id)})})}function Kb(e,t){let n=e.flatMap(r=>r.previewUrl?[{id:r.id,src:r.previewUrl,name:r.name,source:r.source}]:[]);if(n.length===0)return null;let o=n.findIndex(r=>r.id===t);return o<0?null:{images:n.map(r=>({src:r.src,name:r.name,...r.source===void 0?{}:{source:r.source}})),index:o}}function bO(e){let{t}=le(),{api:n,environmentId:o,composerDraftTarget:r,isComposerCollapsedMobile:a,isComposerApprovalState:s,hasPendingUserInputs:i,supportsAttachmentUploads:l,uploadsByImageId:d,composerImages:u,composerPreviewableImages:f,composerPreviewAnnotations:p,composerReviewComments:m,composerElementContexts:h,nonPersistedComposerImageIdSet:g,removeComposerDraftPreviewAnnotation:v,removeComposerDraftReviewComment:C,removeComposerDraftElementContext:y,removeComposerImage:x,onExpandImage:b}=e;return w(he,{children:[!a&&!s&&!i&&p.length>0&&c(xO,{annotations:p,images:u,...l?{uploadsByImageId:d,onRetryUpload:T=>n.uploads.retry({environmentId:o,image:T})}:{},onRemove:T=>{n.uploads.release(T),v(r,T)},onExpandImage:T=>{let I=Kb(f,T);I&&b(I)},className:"mb-3"}),!a&&!s&&!i&&m.length>0&&c(CO,{comments:m,onRemove:T=>C(r,T),className:"mb-3"}),!a&&!s&&!i&&h.length>0&&c(yO,{contexts:h,onRemove:T=>y(r,T),className:"mb-3"}),!a&&!s&&!i&&u.some(T=>!p.some(I=>I.id===T.id))&&c("div",{className:"mb-3 flex flex-wrap gap-2",children:u.filter(T=>!p.some(I=>I.id===T.id)).map(T=>{let I=l?d[T.id]:void 0,P=Fr(T),k=Pp(P),S=P==="image"&&!!T.previewUrl;return w("div",{"data-composer-attachment-id":T.id,className:G("relative h-16 overflow-hidden rounded-lg border border-border/80 bg-background",S?"w-16":"w-44 max-w-full"),children:[S?c("button",{type:"button",className:"h-full w-full cursor-zoom-in","aria-label":t("attachments.preview",{name:T.name}),onClick:()=>{let L=Kb(f,T.id);L&&b(L)},children:c("img",{src:T.previewUrl,alt:T.name,className:"h-full w-full object-cover"})}):w("a",{href:T.previewUrl,target:"_blank",rel:"noreferrer",className:"flex h-full w-full items-center gap-2 px-2 pe-7 text-start","aria-label":t("attachments.open",{name:T.name}),children:[c(k,{className:"size-4 shrink-0 text-secondary-label"}),w("span",{className:"min-w-0",children:[c("span",{className:"block truncate text-[11px] text-foreground",children:T.name}),c("span",{className:"block text-[10px] text-secondary-label",children:es(T.sizeBytes)})]})]}),g.has(T.id)&&w(Ue,{children:[c(Ke,{render:c("span",{role:"img","aria-label":t("attachments.draftMayNotPersist"),className:"absolute left-1 top-1 inline-flex items-center justify-center rounded bg-background/85 p-0.5 text-amber-600",children:c(Jt,{className:"size-3"})})}),c($e,{side:"top",className:"max-w-64 whitespace-normal leading-tight",children:t("attachments.draftMayNotPersistDetail")})]}),I?.status==="uploading"&&c("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-background/85 px-1 text-center text-[10px] text-foreground",children:th(I.progress)}),I?.status==="failed"&&w(Ue,{children:[c(Ke,{render:c(re,{variant:"ghost",size:"icon-xs",className:"absolute bottom-1 left-1 bg-background/85 hover:bg-background/90",onClick:()=>n.uploads.retry({environmentId:o,image:T}),"aria-label":t("attachments.retryUpload",{name:T.name})}),children:c(Hs,{})}),c($e,{side:"top",className:"max-w-64 whitespace-normal leading-tight",children:eh(I,t)})]}),c(re,{variant:"ghost",size:"icon-xs",className:"absolute right-1 top-1 bg-background/80 hover:bg-background/90",onClick:()=>x(T.id),"aria-label":t("attachments.remove",{name:T.name}),children:c(Kt,{})})]},T.id)})})]})}function SO(e){return e.machineUnavailable?"machineDisconnected":e.sessionStarted&&e.sessionDisconnected?"settled":"default"}function wO(e){switch(e){case"machineDisconnected":return"composer.disconnectedPlaceholder";case"settled":return"composer.idlePlaceholder";case"default":return null}}function IO(e){return e.isComposerApprovalState?e.approvalDetail??e.t("composer.resolveApprovalToContinue"):e.activePendingProgress?e.t("composer.typeOwnAnswer"):e.showPlanFollowUpPrompt?e.t("composer.addFeedbackRefinePlan"):e.projectSelectionRequired?e.t("composer.chooseProjectToStart"):e.noProviderAvailable?e.t("composer.enableProviderToSend"):e.t(e.tailPlaceholderKey??"composer.askAnythingFull")}X();X();var TO=fe(function(t){let{t:n}=le(),o=hd();return w(ro,{children:[c(so,{render:c(re,{size:"sm",variant:"ghost",className:"shrink-0 px-2 text-muted-foreground/70 hover:text-foreground/80","aria-label":n("composer.moreComposerControls")}),children:c(Ho,{"aria-hidden":"true",className:"size-4"})}),w(ao,{align:"start",children:[t.traitsMenuContent?w(he,{children:[t.traitsMenuContent,c(sa,{})]}):null,t.showInteractionModeToggle&&t.nativeMode===null?w(he,{children:[c("div",{className:"px-2 py-1.5 font-medium text-muted-foreground text-xs",children:n("composer.modeMenuTitle")}),w(rr,{value:t.interactionMode,onValueChange:r=>{!r||r===t.interactionMode||t.onToggleInteractionMode()},children:[c(ko,{value:"default",children:n("composer.interactionModeChat")}),c(ko,{value:"plan",children:n("composer.interactionModePlan")})]}),c(sa,{})]}):null,t.nativeMode===null?w(he,{children:[c("div",{className:"px-2 py-1.5 font-medium text-muted-foreground text-xs",children:n("composer.accessMenuTitle")}),c(rr,{value:t.runtimeMode,onValueChange:r=>{!r||r===t.runtimeMode||t.onRuntimeModeChange(r)},children:Sr.map(r=>c(ko,{value:r,children:o(r).label},r))}),t.runtimeModeSwitch==="next-turn"?c("div",{className:"px-2 pb-1.5 text-muted-foreground text-xs leading-4",children:n("runtimeMode.appliesNextTurnHint")}):null]}):w(he,{children:[c("div",{className:"px-2 py-1.5 font-medium text-muted-foreground text-xs",children:n("composer.accessMenuTitle")}),t.canSwitchNativeMode&&t.nativeMode.modes.length>1?w(he,{children:[c(rr,{value:t.nativeMode.current.id,onValueChange:r=>{t.onNativeModeChange(String(r))},children:t.nativeMode.modes.map(r=>c(ko,{value:r.id,children:r.name},r.id))}),t.runtimeModeSwitch==="next-turn"?c("div",{className:"px-2 pb-1.5 text-muted-foreground text-xs leading-4",children:n("runtimeMode.appliesNextTurnHint")}):null]}):c("div",{className:"px-2 pb-1.5 text-foreground text-sm","data-composer-native-mode":t.nativeMode.current.id,children:t.nativeMode.current.name})]})]})]})});X();X();X();var Vb="model:",qb="unavailable-models:",Wb="action:",xs="pluginActions:manage",bs="favorites:unavailable";function Vi(e,t){return`${Vb}${e.length}:${e}${t}`}function lh(e){if(!e.startsWith(Vb))return null;let t=e.slice(Vb.length),n=t.indexOf(":");if(n===-1)return null;let o=t.slice(0,n);if(!/^\d+$/.test(o))return null;let r=Number(o),a=t.slice(n+1);return!Number.isSafeInteger(r)||r>a.length?null:{instanceId:a.slice(0,r),slug:a.slice(r)}}function kO(e){return`${qb}${e}`}function PO(e){return e.startsWith(qb)?e.slice(qb.length):null}function Cd(e){return`${Wb}${e}`}function LO(e){if(!e.startsWith(Wb))return null;let t=e.slice(Wb.length);return t.length>0?t:null}function RO(e,t,n){return t!==null&&e.includes(t)&&n(t)?t:e.find(n)??null}var EO=fe(function(t){let{t:n}=le(),o=t.isFavorite?n("modelPicker.removeFromFavorites"):n("modelPicker.addToFavorites"),r=[t.providerDisplayName,t.model.subProvider,t.providerAccountEmail].filter(l=>typeof l=="string"&&l.length>0).join(" \xB7 "),a=w(js,{hideIndicator:!0,index:t.index,value:Vi(t.instanceId,t.model.slug),disabled:!!t.disabledReason,"data-resting-highlight":t.restingHighlight?"":void 0,contentClassName:"flex w-full items-center gap-3",className:G("group relative w-full !min-w-0 max-w-full cursor-pointer rounded-md px-2 py-2 transition-colors duration-(--control-duration)","hover:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))] data-highlighted:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))] data-resting-highlight:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))] data-selected:bg-foreground/[0.08] data-selected:text-foreground data-selected:ring-0 [&[data-highlighted][data-selected]]:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))] [&[data-resting-highlight][data-selected]]:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))]",t.disabledReason&&"data-disabled:pointer-events-auto data-disabled:cursor-not-allowed data-disabled:hover:bg-transparent"),children:[w("div",{className:"min-w-0 flex-1 text-left",children:[w("div",{className:"flex min-w-0 items-center gap-2",children:[w("div",{className:"min-w-0 truncate text-xs font-medium leading-snug",children:[t.useTriggerLabel?yd(t.model):Nb(t.model,t.preferShortName?{preferShortName:!0}:void 0),t.disambiguateInstance?w("span",{className:"font-normal text-muted-foreground",children:[" ","\xB7 ",t.providerDisplayName]}):null]}),t.model.isUnavailable?c(Er,{variant:"outline",size:"sm",children:n("modelPicker.unavailableBadge")}):null]}),t.showProvider&&w("div",{className:"mt-1 flex items-center gap-1.5",children:[c(nr,{driver:t.driver,displayName:t.providerDisplayName,accentColor:t.providerAccentColor,className:"size-icon-2",iconClassName:"size-3",indicatorBackground:"var(--popover)"}),c("span",{className:"truncate text-xs font-normal leading-snug text-muted-foreground/70",children:r})]})]}),w("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jumpLabel?c(rl,{className:"h-4 min-w-0 rounded-sm px-1.5 text-[10px]",children:t.jumpLabel}):null,w(Ue,{children:[c(Ke,{render:c(re,{size:"icon-xs",variant:"ghost",className:G("-mr-1 shrink-0 text-muted-foreground/70 opacity-64 transition-[color,opacity] hover:text-foreground hover:opacity-100 group-hover:opacity-100",t.isFavorite&&"text-foreground opacity-100"),onClick:l=>{l.stopPropagation(),t.onToggleFavorite()},onKeyDown:l=>{l.stopPropagation()},softDisabled:!!t.disabledReason,"aria-label":o,children:c($s,{className:G("size-icon-1",t.isFavorite&&"fill-current text-yellow-500")})})}),c($e,{side:"top",align:"center",children:o})]})]})]}),s=t.disabledReason??t.actionLabel,i=s?w(Ue,{children:[c(Ke,{render:a}),c($e,{side:"left",align:"center",className:"max-w-64 leading-snug",children:s})]}):a;return t.sectionLabel?w(he,{children:[c("div",{className:"px-2 pt-2 pb-1 text-ui-2xs font-medium uppercase leading-none tracking-wide text-muted-foreground/70",children:t.sectionLabel}),i]}):i});X();function X7(e,t){let n=e.displayName,o=e.enabled?e.readiness:"disabled";if(G1(o))return n;let r=Q1(o,t),a=e.snapshot.readiness.detail?.trim();return a?t("instance.statusWithDetail",{name:n,status:r,detail:a}):t("instance.status",{name:n,status:r})}var Y7="pointer-events-none absolute -right-1 top-1/2 z-10 h-5 w-0.75 -translate-y-1/2 rounded-l-full bg-primary",J7="pointer-events-none absolute -right-0.5 top-0.5 z-10 flex size-3.5 items-center justify-center rounded-full bg-transparent shadow-sm ",Z7=`${J7} text-update-foreground`,AO="left",MO=8,NO="max-w-64 font-normal leading-snug",_O=fe(function(t){let{t:n}=le(),{t:o}=le(),r=Nt().model.isProviderUpdateInFlight,a=p=>{t.onSelectInstance(p)},s=t.showFavorites??!0,[i,l]=j(null),d=M(null),[u,f]=j(null);return me(()=>{let p=d.current;if(!p)return;let m=Array.from(p.querySelectorAll("[data-model-picker-provider]")).find(h=>h.dataset.modelPickerProvider===t.selectedInstanceId);if(!m){f(null);return}f(m.offsetTop+m.offsetHeight/2-10)},[t.instanceEntries,t.selectedInstanceId,s]),c("div",{className:"w-11 shrink-0 overflow-hidden bg-muted/30","data-model-picker-sidebar":"true",children:c("div",{className:"h-full overflow-y-auto overscroll-contain [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:w("div",{ref:d,className:"relative flex min-h-full flex-col gap-1 p-1",children:[u!==null?c("div",{"data-model-picker-selected-indicator":"true",className:G(Y7,"right-0 translate-y-0 transition-[top] duration-200 ease-out"),style:{top:u}}):null,s?w(he,{children:[c("div",{className:"relative w-full","data-model-picker-provider":"favorites",children:w(Ue,{children:[c(Ke,{render:c("button",{className:G("relative isolate flex w-full cursor-pointer aspect-square items-center justify-center rounded-md transition-colors hover:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))] focus-visible:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))]"),onClick:()=>a("favorites"),type:"button","aria-label":n("modelPicker.favorites"),children:c($s,{className:"size-5 fill-current shrink-0","aria-hidden":!0})})}),c($e,{side:AO,sideOffset:MO,align:"center",className:NO,children:n("modelPicker.favorites")})]})}),c("div",{className:"border-b border-border/70","aria-hidden":"true"})]}):null,t.instanceEntries.map(p=>{let m=!rh(p),h=t.disabledInstanceIds?.has(p.instanceId)??!1,g=m||h,v=t.selectedInstanceId===p.instanceId,C=i===p.instanceId,y=r(p.snapshot),x=p.snapshot.versionAdvisory?.latestVersion!=null?o("updates.rail.updatingToVersion",{version:p.snapshot.versionAdvisory.latestVersion}):o("updates.rail.updating"),b=m?X7(p,o):h?t.getDisabledInstanceTooltip?.(p)??p.displayName:y?`${p.displayName} \u2014 ${x}`:p.displayName,T=w("button",{className:G("relative isolate flex w-full cursor-pointer aspect-square items-center justify-center rounded-md transition-colors hover:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))] focus-visible:bg-[color-mix(in_srgb,var(--popover)_90%,var(--contrast-foreground))]",g&&"opacity-50 cursor-not-allowed hover:bg-transparent"),"data-provider-accent-color":p.accentColor,onClick:()=>!g&&a(p.instanceId),onMouseEnter:()=>l(p.instanceId),onMouseLeave:()=>l(P=>P===p.instanceId?null:P),onFocus:()=>l(p.instanceId),onBlur:()=>l(P=>P===p.instanceId?null:P),disabled:g,type:"button","aria-label":g?b:p.displayName,children:[c(nr,{driver:p.driverKind,displayName:p.displayName,accentColor:p.accentColor,className:"size-6",iconClassName:"size-5",indicatorBackground:C&&!g?"var(--muted)":v?"var(--background)":"color-mix(in oklab, var(--muted) 30%, transparent)"}),y?c("span",{className:Z7,"aria-hidden":!0,children:c(nl,{className:"size-2.5"})}):null]}),I=g?c("span",{className:"relative block w-full",children:T}):T;return c("div",{className:"relative w-full","data-model-picker-provider":p.instanceId,children:w(Ue,{children:[c(Ke,{render:I}),w($e,{side:AO,sideOffset:MO,align:"center",className:NO,children:[b,p.accountEmail?c("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:p.accountEmail}):null]})]})},p.instanceId)})]})})})});X();function dh(e){return e?.trim()||null}function DO({label:e}){return c("div",{className:"px-2 pt-2 pb-1 text-ui-2xs font-medium uppercase leading-none tracking-wide text-muted-foreground/70",children:e})}var OO=fe(function({index:t,itemKey:n,action:o,showSectionHeader:r,restingHighlight:a}){let{t:s}=le(),i=dh(o.description);return w(he,{children:[r?c(DO,{label:s("modelPicker.plugins")}):null,w(js,{hideIndicator:!0,index:t,value:n,"data-resting-highlight":a?"":void 0,className:"group w-full cursor-pointer rounded-md px-2 py-2 data-resting-highlight:bg-accent data-resting-highlight:text-accent-foreground",contentClassName:"flex w-full items-center gap-2",children:[c(zs,{className:"size-4 shrink-0 text-muted-foreground/70"}),w("div",{className:"min-w-0 flex-1 text-left",children:[c("div",{className:"truncate text-xs font-medium leading-snug",children:o.title}),c("div",{className:"mt-1 truncate text-xs font-normal leading-snug text-muted-foreground/70",children:i})]})]})]})}),FO=fe(function(t){let{t:n}=le();return w(js,{hideIndicator:!0,index:t.index,value:t.itemKey,"aria-expanded":t.expanded,className:"group w-full cursor-pointer rounded-md px-2 py-2",contentClassName:"flex w-full items-center gap-3",children:[w("div",{className:"min-w-0 flex-1 text-left",children:[c("div",{className:"text-xs font-medium leading-snug",children:n("modelPicker.unavailableModels")}),c("div",{className:"mt-1 text-xs font-normal leading-snug text-muted-foreground/70",children:n("modelPicker.modelCount",{count:t.count})})]}),c(no,{className:`size-4 transition-transform${t.expanded?" rotate-90":""}`})]})}),BO=fe(function({index:t,showSectionHeader:n}){let{t:o}=le();return w(he,{children:[n?c(DO,{label:o("modelPicker.plugins")}):null,w(js,{hideIndicator:!0,index:t,value:xs,className:"group w-full cursor-pointer rounded-md px-2 py-2",contentClassName:"flex w-full items-center gap-2",children:[c(Dd,{className:"size-4 shrink-0 text-muted-foreground/70"}),c("span",{className:"min-w-0 flex-1 truncate text-left text-xs font-normal leading-snug text-muted-foreground",children:o("modelPicker.managePlugins")})]})]})}),zO=fe(function({index:t,instanceName:n}){let{t:o}=le();return w(js,{hideIndicator:!0,index:t,value:bs,className:"group w-full cursor-pointer rounded-md px-2 py-2",contentClassName:"flex w-full items-center gap-2",children:[c(cc,{className:"size-4 shrink-0 text-muted-foreground/70"}),w("div",{className:"min-w-0 flex-1 text-left",children:[c("div",{className:"text-xs font-normal leading-snug text-muted-foreground",children:o("modelPicker.favoritesUnavailable")}),c("div",{className:"mt-1 truncate text-xs font-medium leading-snug",children:o("modelPicker.showInstanceModels",{name:n})})]}),c(no,{className:"size-4 shrink-0 text-muted-foreground/70"})]})});function HO(e){let{t}=le();return c("div",{className:"px-2 pt-2",children:c("div",{className:"border-b border-border/70 pb-2.5 transition-colors focus-within:border-ring",children:c(gw,{ref:e.inputRef,className:"[&_input]:h-control-3 [&_input]:font-sans [&_input]:leading-control-3",inputClassName:"rounded-none bg-transparent text-sm",placeholder:t("modelPicker.searchPlaceholder"),showTrigger:!1,startAddon:c(Us,{className:"-translate-x-0.5 size-4 shrink-0 text-muted-foreground opacity-70"}),value:e.value,onChange:n=>e.onValueChange(n.target.value),onKeyDown:n=>{if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),e.onEscape?.();return}let o=n.key==="Enter"?e.enterKey():null;if(o){n.preventBaseUIHandler?.(),n.preventDefault(),n.stopPropagation(),e.onCommit(o);return}n.stopPropagation()},onMouseDown:n=>n.stopPropagation(),onTouchStart:n=>n.stopPropagation(),size:"sm",unstyled:!0})})})}function UO({top:e,bottom:t}){if(!(!e&&!t))return G("virtualized-scroll-fade [--fade-size:1.5rem]",e&&t&&"[--virtualized-scroll-fade-mask:linear-gradient(to_bottom,transparent,black_var(--fade-size),black_calc(100%-var(--fade-size)),transparent)]",e&&!t&&"[--virtualized-scroll-fade-mask:linear-gradient(to_bottom,transparent,black_var(--fade-size))]",!e&&t&&"[--virtualized-scroll-fade-mask:linear-gradient(to_bottom,black_calc(100%-var(--fade-size)),transparent)]")}X();function $O(e,t,n,o,r){let a=new Map,s=new Set;for(let u of e){let f=o(u);a.set(f,(a.get(f)??0)+1),s.add(n(u))}let i=s.size>1,l=new Map,d=null;for(let u of e){let f=n(u);l.set(t(u),{section:i&&f!==d?r(u):null,disambiguate:(a.get(o(u))??0)>1}),d=f}return l}function KO(e,t){let n=[],o=[];for(let r of e)t(r)?o.push(r):n.push(r);return{current:n,unavailable:o}}function VO(e){return e.instanceReady?!0:e.entry.enabled&&e.entry.driverKind==="opencode"&&e.instanceId===e.activeInstanceId&&e.option.slug===e.activeModel&&e.option.isUnavailable===!0}function Kn(e,t){let n=e.trim();return n?t?.trimLeadingPattern?n.replace(t.trimLeadingPattern,"").toLowerCase():n.toLowerCase():""}function e9(e,t){if(!t)return 0;let n=0,o=-1,r=-1,a=0;for(let s=0;s<e.length;s+=1)if(e[s]===t[n]&&(o===-1&&(o=s),r!==-1&&(a+=s-r-1),r=s,n+=1,n===t.length)){let i=s-o+1-t.length,l=Math.min(64,e.length-t.length);return o*2+a*3+i+l}return null}function Gb(e,t){return Math.min(64,Math.max(0,e.length-t.length))}function t9(e,t,n){let o=null;for(let r of n){let a=e.indexOf(`${r}${t}`);if(a===-1)continue;let s=a+r.length;(o===null||s<o)&&(o=s)}return o}function wr(e){let{value:t,query:n}=e;if(!t||!n)return null;if(t===n)return e.exactBase;if(e.prefixBase!==void 0&&t.startsWith(n))return e.prefixBase+Gb(t,n);if(e.boundaryBase!==void 0){let o=t9(t,n,e.boundaryMarkers??[" ","-","_","/"]);if(o!==null)return e.boundaryBase+o*2+Gb(t,n)}if(e.includesBase!==void 0){let o=t.indexOf(n);if(o!==-1)return e.includesBase+o*2+Gb(t,n)}if(e.fuzzyBase!==void 0){let o=e9(t,n);if(o!==null)return e.fuzzyBase+o}return null}function n9(e,t){let n=e.score-t.score;return n!==0?n:e.tieBreaker.localeCompare(t.tieBreaker)}function o9(e,t){let n=0,o=e.length;for(;n<o;){let r=n+Math.floor((o-n)/2),a=e[r];if(!a)break;n9(t,a)<0?o=r:n=r+1}return n}function ch(e,t,n){if(n<=0)return;let o=o9(e,t);if(e.length<n){e.splice(o,0,t);return}o>=n||(e.splice(o,0,t),e.pop())}var r9=24;function a9(e){return[Kn(e.name),...e.shortName?[Kn(e.shortName)]:[],...e.subProvider?[Kn(e.subProvider)]:[],Kn(e.driverKind),Kn(e.providerDisplayName),...e.providerAccountEmail?[Kn(e.providerAccountEmail)]:[],jb(e),...e.slug?[Kn(e.slug)]:[]]}function s9(e,t,n){return wr({value:e,query:t,exactBase:n,prefixBase:n+2,boundaryBase:n+4,includesBase:n+6,...t.length>=3?{fuzzyBase:n+100}:{}})}function jb(e){return Kn([e.name,e.shortName,e.subProvider,e.driverKind,e.providerDisplayName,e.providerAccountEmail,e.slug].filter(t=>typeof t=="string"&&t.length>0).join(" "))}function qO(e,t){let n=Kn(t).split(/\s+/u).filter(r=>r.length>0);if(n.length===0)return 0;let o=0;for(let r of n){let a=[];for(let s=0;s<e.length;s+=1){let i=s9(e[s],r,s*10);i!==null&&a.push(i)}if(a.length===0)return null;o+=Math.min(...a)}return o}function WO(e,t){let n=qO(a9(e),t);return n===null?null:e.isFavorite?n-r9:n}function GO(e,t){return qO([Kn(e.title),Kn(e.description??"")],t)}function jO(e,t){return`${e}:${t}`}var QO=[],i9=[],l9=[];function xd(e){return Vi(e.instanceId,e.slug)}function XO(e,t,n){return t.environmentId===n&&t.instanceId===e.instanceId&&t.model===e.slug}function YO(e){let{keybindings:t,modelOptionsByInstance:n,instanceEntries:o,hideInstanceRail:r=!1,getModelDisabledReason:a,getModelContinuationLabel:s,onContinueInModel:i,onInstanceModelChange:l,onManagePlugins:d,onSelectPluginAction:u}=e,f=e.pluginActions??QO,p=e.selectedPluginActionKey??null,{t:m}=le(),{t:h}=le(),g=Nt(),[v,C]=j(""),[y,x]=j(!1),[b,T]=j(!1),I=M(null),P=M(null),k=M(null),[S,L]=j(!1),R=g.environment.useActiveEnvironmentId(),_=g.settings.useClientSettings(de=>de.favorites??[]),E=$(()=>R===null?l9:_.filter(de=>de.environmentId===R),[R,_]),D=$(()=>new Set(E.map(de=>jO(de.instanceId,de.model))),[E]),H=A(de=>R===null?!1:E.some(Pe=>XO(de,Pe,R)),[R,E]),K=$(()=>new Map(o.map(de=>[de.instanceId,de])),[o]),O=A(de=>e.lockedProvider===null?!0:de.driverKind!==e.lockedProvider?!1:e.lockedContinuationGroupKey?de.continuationGroupKey===e.lockedContinuationGroupKey:!0,[e.lockedContinuationGroupKey,e.lockedProvider]),Z=$(()=>{let de=new Set;for(let Pe of o)rh(Pe)&&de.add(Pe.instanceId);return de},[o]),N=$(()=>{let de=[];for(let[Pe,Ie]of n){let ze=K.get(Pe);if(!ze)continue;let nt=Z.has(Pe);for(let Pt of Ie)VO({entry:ze,instanceReady:nt,instanceId:Pe,option:Pt,activeInstanceId:e.activeInstanceId,activeModel:e.model})&&de.push({slug:Pt.slug,name:Pt.name,...Pt.shortName?{shortName:Pt.shortName}:{},...Pt.subProvider?{subProvider:Pt.subProvider}:{},...Pt.isUnavailable?{isUnavailable:!0}:{},instanceId:Pe,driverKind:ze.driverKind,instanceDisplayName:ze.displayName,...ze.accentColor?{instanceAccentColor:ze.accentColor}:{},...ze.accountEmail?{instanceAccountEmail:ze.accountEmail}:{},...ze.continuationGroupKey?{continuationGroupKey:ze.continuationGroupKey}:{}})}return de},[n,K,Z,e.activeInstanceId,e.model]),B=(n.get(e.activeInstanceId)??[]).some(de=>de.slug===e.model&&de.isUnavailable===!0),[ue,U]=j(()=>e.lockedProvider!==null||B?e.activeInstanceId:N.some(H)?"favorites":e.activeInstanceId),[oe,Q]=j(()=>new Set),V=$(()=>t??[],[t]),W=g.settings.useUpdateClientSettings(),ee=A(()=>{I.current?.focus({preventScroll:!0})},[]),ie=A(de=>{U(de),window.requestAnimationFrame(()=>{ee()})},[ee]);me(()=>{ee();let de=window.requestAnimationFrame(()=>{ee()}),Pe=window.setTimeout(()=>{ee()},0);return()=>{window.cancelAnimationFrame(de),window.clearTimeout(Pe)}},[ee]);let J=e.lockedProvider!==null,ae=v.trim().length>0,Se=$(()=>{if(!J)return;let de=new Set;for(let Pe of o)O(Pe)||de.add(Pe.instanceId);return de},[o,J,O]),we=$(()=>{let de=o.filter(Yu);if(!J)return de;let Pe=[],Ie=[];for(let ze of de)O(ze)?Pe.push(ze):Ie.push(ze);return[...Pe,...Ie]},[o,J,O]),Ce=!r&&!ae&&we.length>0,Re=$(()=>o.map(de=>de.instanceId),[o]),rt=$(()=>{let de=N;if(v.trim()){let Pe=de.map(Ie=>({model:Ie,score:WO({name:Ie.name,...Ie.shortName?{shortName:Ie.shortName}:{},...Ie.subProvider?{subProvider:Ie.subProvider}:{},driverKind:Ie.driverKind,providerDisplayName:Ie.instanceDisplayName,...Ie.instanceAccountEmail?{providerAccountEmail:Ie.instanceAccountEmail}:{},isFavorite:H(Ie)},v),isFavorite:H(Ie),tieBreaker:jb({name:Ie.name,...Ie.shortName?{shortName:Ie.shortName}:{},...Ie.subProvider?{subProvider:Ie.subProvider}:{},driverKind:Ie.driverKind,providerDisplayName:Ie.instanceDisplayName,...Ie.instanceAccountEmail?{providerAccountEmail:Ie.instanceAccountEmail}:{}})})).filter(Ie=>Ie.score!==null);if(e.lockedProvider!==null){let Ie=[];for(let ze of Pe)O(ze.model)&&Ie.push(ze);return Ie.toSorted((ze,nt)=>{let Pt=ze.score-nt.score;return Pt!==0?Pt:ze.isFavorite!==nt.isFavorite?ze.isFavorite?-1:1:ze.tieBreaker.localeCompare(nt.tieBreaker)}).map(ze=>ze.model)}return Pe.toSorted((Ie,ze)=>{let nt=Ie.score-ze.score;return nt!==0?nt:Ie.isFavorite!==ze.isFavorite?Ie.isFavorite?-1:1:Ie.tieBreaker.localeCompare(ze.tieBreaker)}).map(Ie=>Ie.model)}return e.lockedProvider!==null?(de=de.filter(Pe=>O(Pe)),ue==="favorites"?de=de.filter(Pe=>H(Pe)):de=de.filter(Pe=>Pe.instanceId===ue)):ue==="favorites"?de=de.filter(Pe=>H(Pe)):de=de.filter(Pe=>Pe.instanceId===ue),g.model.sortProviderModelItems(de,{favoriteModelKeys:D,groupFavorites:ue!=="favorites",instanceOrder:ue==="favorites"?Re:[]})},[D,N,Re,O,e.lockedProvider,v,ue,H]),te=A((de,Pe)=>g.model.resolvePickerRowAction({disabledReason:a?.(de,Pe)??null,continuationLabel:i?s?.(de,Pe)??null:null}),[s,a,i]),se=A(de=>te(de.instanceId,de.slug),[te]),q=$(()=>KO(rt,de=>se(de).kind==="blocked"),[rt,se]),ce=$(()=>q.unavailable.length===0?null:{key:kO(ue),models:q.unavailable,isExpanded:oe.has(ue)},[oe,q,ue]),Y=$(()=>[...q.current,...ce?.isExpanded?ce.models:[]],[q,ce]),ke=$(()=>$O(Y,de=>Vi(de.instanceId,de.slug),de=>de.instanceId,de=>de.slug,de=>de.instanceDisplayName),[Y]),Fe=u!==void 0,Ge=$(()=>{if(!Fe)return QO;let de=v.trim();return de.length===0?f:f.map(Pe=>({action:Pe,score:GO(Pe,de)})).filter(Pe=>Pe.score!==null).toSorted((Pe,Ie)=>Pe.score-Ie.score||Pe.action.title.localeCompare(Ie.action.title)).map(Pe=>Pe.action)},[v,f,Fe]),Ve=Fe&&(!ae||Ge.length>0),It=$(()=>Ve?[...Ge.map(de=>Cd(de.id)),xs]:i9,[Ve,Ge]),ft=$(()=>new Map(Ge.map(de=>[Cd(de.id),de])),[Ge]),wt=It[0]??null,Ze=A(de=>{Q(Pe=>{let Ie=new Set(Pe);return Ie.has(de)?Ie.delete(de):Ie.add(de),Ie})},[]),it=A((de,Pe)=>{let Ie=te(Pe,de);if(Ie.kind==="blocked")return;if(Ie.kind==="continue"){i?.(Pe,de);return}let ze=n.get(Pe);if(!ze||!K.has(Pe))return;let nt=g.model.resolveSelectableModel(de,ze);nt&&l(Pe,nt)},[K,n,i,l,te]),Zt=A(de=>{let Pe=PO(de);if(Pe){Ze(Pe);return}if(de===xs){d?.();return}if(de===bs){ie(e.activeInstanceId);return}let Ie=LO(de);if(Ie!==null){u?.(Ie);return}let ze=Y.find(Pt=>xd(Pt)===de);if(!ze||se(ze).kind==="blocked")return;let nt=lh(de);nt&&it(nt.slug,nt.instanceId)},[it,ie,e.activeInstanceId,d,u,Ze,Y,se]),Ht=A(de=>{if(R===null)return;let Pe=_.findIndex(ze=>XO(de,ze,R)),Ie=[..._];Pe>=0?Ie.splice(Pe,1):Ie.push({environmentId:R,instanceId:de.instanceId,model:de.slug}),W({favorites:Ie})},[R,_,W]);return{t:m,tProviders:h,api:g,searchQuery:v,setSearchQuery:C,showTopScrollFade:y,showBottomScrollFade:b,setShowTopScrollFade:x,setShowBottomScrollFade:T,searchInputRef:I,modelListRef:P,highlightedModelKeyRef:k,hasHighlight:S,setHasHighlight:L,favoritesSet:D,itemIsFavorite:H,entryByInstanceId:K,selectedInstanceId:ue,handleSelectInstance:ie,keybindings:V,isLocked:J,isSearching:ae,lockedDisabledInstanceIds:Se,sidebarInstanceEntries:we,showSidebar:Ce,flatModels:N,modelGroups:q,unavailableSection:ce,visibleModels:Y,modelRowMarks:ke,pluginsEnabled:Fe,pluginActions:f,pluginItemKeys:It,pluginByItemKey:ft,firstPluginItemKey:wt,resolveRowAction:te,resolveModelRowAction:se,handleModelSelect:it,commitItemKey:Zt,toggleFavorite:Ht,selectedPluginActionKey:p}}var JO=new Map;function d9(){return c("div",{className:"h-0.5"})}var ZO=fe(function(t){let{t:n,tProviders:o,api:r,searchQuery:a,setSearchQuery:s,showTopScrollFade:i,showBottomScrollFade:l,setShowTopScrollFade:d,setShowBottomScrollFade:u,searchInputRef:f,modelListRef:p,highlightedModelKeyRef:m,hasHighlight:h,setHasHighlight:g,favoritesSet:v,itemIsFavorite:C,entryByInstanceId:y,selectedInstanceId:x,handleSelectInstance:b,keybindings:T,isLocked:I,isSearching:P,lockedDisabledInstanceIds:k,sidebarInstanceEntries:S,showSidebar:L,flatModels:R,modelGroups:_,unavailableSection:E,visibleModels:D,modelRowMarks:H,pluginsEnabled:K,pluginActions:O,pluginItemKeys:Z,pluginByItemKey:N,firstPluginItemKey:B,resolveRowAction:ue,resolveModelRowAction:U,handleModelSelect:oe,commitItemKey:Q,toggleFavorite:V,selectedPluginActionKey:W}=YO(t),ee=$(()=>{let Y=new Map,ke=0;for(let Fe of D){if(ue(Fe.instanceId,Fe.slug).kind==="blocked")continue;let Ge=r.keybindings.modelPickerJumpCommandForIndex(ke);if(!Ge)return Y;Y.set(xd(Fe),Ge),ke+=1}return Y},[ue,D]),ie=$(()=>[...ee.keys()],[ee]),J=x==="favorites"&&!P&&D.length===0&&E===null,ae=$(()=>[...R.map(Y=>xd(Y)),...E?[E.key]:[],...J?[bs]:[],...K?[...O.map(Y=>Cd(Y.id)),xs]:[]],[J,R,O,K,E]),Se=$(()=>{let Y=D.map(ke=>xd(ke));return E&&Y.splice(_.current.length,0,E.key),J&&Y.push(bs),Z.length>0?[...Y,...Z]:Y},[J,E,_,Z,D]),we=$(()=>new Map(D.map(Y=>[xd(Y),Y])),[D]),Ce=A(()=>{let Y=p.current?.getScrollableNode();if(!(Y instanceof HTMLElement))return;let ke=Math.max(0,Y.scrollHeight-Y.clientHeight);d(Y.scrollTop>1),u(ke-Y.scrollTop>1)},[]),Re=$(()=>({terminalFocus:!1,terminalOpen:t.terminalOpen,modelPickerOpen:!0}),[t.terminalOpen]),rt=$(()=>{if(ee.size===0)return JO;let Y={platform:navigator.platform,context:Re},ke=new Map;for(let[Fe,Ge]of ee){let Ve=r.keybindings.shortcutLabelForCommand(T,Ge,Y);Ve&&ke.set(Fe,Ve)}return ke.size>0?ke:JO},[T,ee,Re]),te=W===null?Vi(t.activeInstanceId,t.model):Cd(W),se=$(()=>RO(Se,te,ke=>{let Fe=we.get(ke);return N.has(ke)||!!Fe&&U(Fe).kind!=="blocked"}),[Se,we,N,U,te]),q=h?null:se;me(()=>{let Y=q===null?-1:Se.indexOf(q);Y>=0&&p.current?.scrollIndexIntoView?.({index:Y,animated:!1})},[Se,q]);let ce=$(()=>({favoritesSet:v,modelJumpLabelByKey:rt,selectedItemKey:te,restingRowKey:q}),[v,rt,te,q]);return r.pane.useKeydown(Y=>{if(Y.defaultPrevented||Y.repeat)return;let ke=r.keybindings.resolveShortcutCommand(Y,T,{platform:navigator.platform,context:Re}),Fe=r.keybindings.modelPickerJumpIndexFromCommand(ke??"");if(Fe===null)return;let Ge=ie[Fe];if(!Ge)return;let Ve=lh(Ge);Ve&&(Y.preventDefault(),Y.stopPropagation(),oe(Ve.slug,Ve.instanceId))},{capture:!0}),me(()=>{d(!1),u(Se.length>5);let Y=0,ke=window.requestAnimationFrame(()=>{Ce(),Y=window.requestAnimationFrame(Ce)});return()=>{window.cancelAnimationFrame(ke),window.cancelAnimationFrame(Y)}},[Se,Ce]),c(vw,{delay:0,children:w("div",{className:"relative flex h-screen max-h-86.5 w-screen max-w-90 flex-row overflow-hidden","data-model-picker-content":"true",children:[L&&c(_O,{selectedInstanceId:x,onSelectInstance:b,instanceEntries:S,showFavorites:!0,...k?{disabledInstanceIds:k,getDisabledInstanceTooltip:Y=>o("instance.lockedToThread",{name:Y.displayName})}:{}}),c(pw,{inline:!0,items:ae,filteredItems:Se,filter:null,autoHighlight:!0,open:!0,virtualized:!0,value:te,onItemHighlighted:(Y,ke)=>{m.current=typeof Y=="string"?Y:null,g(typeof Y=="string"),ke.reason==="keyboard"&&ke.index>=0&&p.current?.scrollIndexIntoView?.({index:ke.index,animated:!1})},onValueChange:Y=>{typeof Y=="string"&&Q(Y)},children:w("div",{className:G("flex min-h-0 flex-1 flex-col overflow-hidden bg-muted/40",L&&"border-l border-border/70"),children:[c(HO,{inputRef:f,value:a,onValueChange:s,onEscape:t.onRequestClose,enterKey:()=>m.current??se,onCommit:Q}),c("div",{className:"relative min-h-0 flex-1 overflow-hidden pr-px",children:c(hw,{className:"size-full min-w-0 p-0 not-empty:p-0",children:c(ep,{ref:p,data:Se,extraData:ce,keyExtractor:Y=>Y,renderItem:({item:Y,index:ke})=>{let Fe=E?.key===Y?{count:E.models.length,isExpanded:E.isExpanded}:null;if(Fe)return c(FO,{index:ke,itemKey:Y,count:Fe.count,expanded:Fe.isExpanded});let Ge=N.get(Y);if(Ge)return c(OO,{index:ke,itemKey:Y,action:Ge,showSectionHeader:Y===B,restingHighlight:Y===q});if(Y===bs)return c(zO,{index:ke,instanceName:y.get(t.activeInstanceId)?.displayName??t.activeInstanceId});if(Y===xs)return c(BO,{index:ke,showSectionHeader:Y===B});let Ve=we.get(Y);if(!Ve)return null;let It=U(Ve),ft=H.get(Y);return c(EO,{index:ke,model:Ve,instanceId:Ve.instanceId,driver:Ve.driverKind,providerDisplayName:Ve.instanceDisplayName,providerAccentColor:Ve.instanceAccentColor,providerAccountEmail:Ve.instanceAccountEmail,isFavorite:C(Ve),isSelected:Y===te,restingHighlight:Y===q,showProvider:!0,disambiguateInstance:ft?.disambiguate===!0,sectionLabel:ft?.section??null,preferShortName:!I,useTriggerLabel:!1,jumpLabel:rt.get(Y)??null,disabledReason:It.kind==="blocked"?It.reason:null,actionLabel:It.kind==="continue"?It.label:null,onToggleFavorite:()=>V(Ve)},Y)},estimatedItemSize:52,drawDistance:480,recycleItems:!0,contentContainerClassName:"pl-2 pr-px",ItemSeparatorComponent:d9,onLayout:Ce,onScroll:Ce,className:G("scrollbar-gutter-stable h-full overflow-x-hidden overscroll-y-contain py-1.5 [&::-webkit-scrollbar-track]:my-2",UO({top:i,bottom:l}))})})}),c(mw,{className:"not-empty:py-6 empty:h-0 text-xs font-normal leading-snug",children:n("modelPicker.noModelsFound")})]})})]})})});function c9(e){let t=e.unknownModelLabel?.trim();if(t)return t;let n=e.catalogOptions.find(o=>o.slug===e.model);return n?yd(n):e.model}var Qb=fe(function(t){let{t:n}=le(),[o,r]=j(!1),s=zo()&&(t.open??o),i=$(()=>t.instanceEntries.find(b=>b.instanceId===t.activeInstanceId)??null,[t.activeInstanceId,t.instanceEntries]),l=t.activeInstanceId,d=t.modelOptionsByInstance.get(l)??[],u=Fb(t.modelStatus),f=c9({model:t.model,catalogOptions:d,unknownModelLabel:u?.seatKey?n(u.seatKey):null}),p=t.modelStatus==="unavailable",m=b=>{t.onOpenChange?.(b),t.open===void 0&&r(b)};z(()=>{if(!s)return;let{documentElement:b,body:T}=document,I=b.style.overscrollBehavior,P=T.style.overflow,k=T.style.paddingRight,S=window.innerWidth-b.clientWidth;b.style.overscrollBehavior="contain",T.style.overflow="hidden",S>0&&(T.style.paddingRight=`${S}px`);let L=E=>E instanceof Element&&E.closest("[data-model-picker-content]"),R=E=>{L(E.target)||E.preventDefault()},_=E=>{L(E.target)||E.preventDefault()};return document.addEventListener("wheel",R,{capture:!0,passive:!1}),document.addEventListener("touchmove",_,{capture:!0,passive:!1}),()=>{document.removeEventListener("wheel",R,{capture:!0}),document.removeEventListener("touchmove",_,{capture:!0}),b.style.overscrollBehavior=I,T.style.overflow=P,T.style.paddingRight=k}},[s]);let h=(b,T)=>{t.disabled||(t.onInstanceModelChange(b,T),m(!1))},g=(b,T)=>{t.disabled||(t.onContinueInModel?.(b,T),m(!1))},v=b=>{t.disabled||(t.onSelectPluginAction?.(b),m(!1))},C=()=>{t.onManagePlugins?.(),m(!1)},y=t.selectedPluginActionKey==null?null:t.pluginActions?.find(b=>b.id===t.selectedPluginActionKey)??null,x=y?dh(y.description):null;return w(Mr,{open:s,onOpenChange:b=>{if(t.disabled){m(!1);return}m(b)},children:[w(_r,{render:c(ho,{"aria-label":t.triggerAriaLabel,variant:t.triggerVariant??"ghost","data-chat-provider-model-picker":"true",className:G("min-w-0 justify-between whitespace-nowrap",t.compact?"max-w-42 shrink-0":"max-w-48 shrink sm:max-w-56",t.triggerClassName),disabled:t.disabled}),children:[c("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:y?w(he,{children:[c(zs,{className:"size-4 shrink-0"}),w(Ue,{children:[w(Ke,{render:c("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 truncate"}),children:[c("span",{className:"shrink-0",children:y.title}),x?w("span",{className:"min-w-0 truncate text-muted-foreground/80",children:["\xB7 ",x]}):null]}),c($e,{side:"top",children:x?`${y.title} \xB7 ${x}`:y.title})]})]}):w(he,{children:[t.showInstanceOnTrigger!==!1&&i?c(nr,{driver:i.driverKind,displayName:i.displayName,accentColor:i.accentColor,className:G("size-4",t.activeProviderIconClassName),iconClassName:"size-4",indicatorBackground:"var(--contrast-input)"}):null,w(Ue,{children:[c(Ke,{render:c("span",{className:"min-w-0 flex-1 overflow-hidden truncate"}),children:f}),c($e,{side:"top",children:p?n("modelPicker.unavailableLabel",{name:i?`${i.displayName} \xB7 ${f}`:f}):i?`${i.displayName} \xB7 ${f}`:f})]}),p?c(Er,{variant:"outline",size:"sm",children:n("modelPicker.unavailableBadge")}):null]})}),c("span",{"aria-hidden":"true",className:"flex items-center",children:c(Wr,{})})]}),c(Nr,{align:"start",className:"before:hidden [--viewport-inline-padding:0]",viewportClassName:"!overflow-hidden rounded-[calc(var(--widget-radius)-1px)] p-0 [clip-path:inset(0_round_calc(var(--widget-radius)-1px))]",children:c(ZO,{activeInstanceId:l,model:t.model,lockedProvider:t.lockedProvider,lockedContinuationGroupKey:t.lockedContinuationGroupKey??null,instanceEntries:t.instanceEntries,...t.hideInstanceRail?{hideInstanceRail:!0}:{},...t.keybindings?{keybindings:t.keybindings}:{},modelOptionsByInstance:t.modelOptionsByInstance,terminalOpen:t.terminalOpen??!1,onRequestClose:()=>m(!1),...t.getModelDisabledReason?{getModelDisabledReason:t.getModelDisabledReason}:{},...t.getModelContinuationLabel?{getModelContinuationLabel:t.getModelContinuationLabel}:{},...t.onContinueInModel?{onContinueInModel:g}:{},onInstanceModelChange:h,...t.pluginActions?{pluginActions:t.pluginActions}:{},selectedPluginActionKey:t.selectedPluginActionKey??null,...t.onSelectPluginAction?{onSelectPluginAction:v}:{},...t.onManagePlugins?{onManagePlugins:C}:{}})})]})});function eF(e){let{slots:t,...n}=e,o=c(Qb,{...n,hideInstanceRail:!0,showInstanceOnTrigger:!1}),r=t?.renderSlot("conversation.input.model",n,o);return c("span",{"data-conversation-slot":"conversation.input.model",children:r??o})}function tF(e){return c(Qb,{...e,hideInstanceRail:!0,showInstanceOnTrigger:!1})}X();function nF(e){return e.description??e.name}var oF=fe(function(t){let{t:n}=le(),{current:o,modes:r}=t.nativeMode,a=nF(o);return!t.canSwitch||r.length<2?w(Ue,{children:[w(Ke,{render:c(ho,{className:"shrink-0 cursor-default whitespace-nowrap font-medium",type:"button",disabled:!0,"data-composer-native-mode":o.id,"aria-label":n("composer.agentModeLabel",{name:o.name})}),children:[c(er,{icon:el}),c("span",{children:o.name})]}),w($e,{side:"top",children:[c("span",{className:"block font-medium",children:a}),r.length>1?c("span",{className:"mt-1 block text-muted-foreground text-xs",children:n("composer.agentModesList",{modes:r.map(s=>s.name).join(", ")})}):null]})]}):w(he,{children:[w(Ue,{children:[w(oa,{value:o.id,onValueChange:s=>t.onNativeModeChange(s),children:[w(Ke,{render:c(ah,{className:"shrink-0 whitespace-nowrap font-medium","data-composer-native-mode":o.id,"aria-label":n("composer.agentModeLabel",{name:o.name})}),children:[c(er,{icon:el}),c(aa,{children:o.name})]}),w(ra,{alignItemWithTrigger:!1,children:[r.map(s=>c(or,{value:s.id,hideIndicator:!0,className:"min-w-56 py-2",children:w("div",{className:"grid min-w-0 gap-0.5",children:[c("span",{className:"font-medium text-foreground",children:s.name}),s.description?c("span",{className:"text-muted-foreground text-xs leading-4",children:s.description}):null]})},s.id)),t.appliesNextTurn?c("div",{className:"border-t px-2 py-1.5 text-muted-foreground text-xs leading-4","data-composer-next-turn-note":"popup",children:n("runtimeMode.appliesNextTurnHint")}):null]})]}),c($e,{side:"top",children:t.appliesNextTurn?`${a} ${n("runtimeMode.appliesNextTurnHint")}`:a})]}),t.appliesNextTurn?c("span",{className:"hidden whitespace-nowrap text-muted-foreground text-xs sm:inline","data-composer-next-turn-note":"inline",children:n("runtimeMode.appliesNextTurn")}):null]})});function Xb(e){let{t}=le(),n=hd();if(e.nativeMode)return c(oF,{nativeMode:e.nativeMode,canSwitch:e.canSwitchNativeMode,appliesNextTurn:e.runtimeModeSwitch==="next-turn",onNativeModeChange:e.onNativeModeChange});let o=n(e.runtimeMode),r=o.icon,a=e.runtimeModeSwitch==="next-turn";return w(he,{children:[w(Ue,{children:[w(oa,{value:e.runtimeMode,onValueChange:s=>e.onRuntimeModeChange(s),children:[w(Ke,{render:c(ah,{"data-composer-permission":"true","data-composer-runtime-mode-switch":e.runtimeModeSwitch,className:"font-medium","aria-label":t("composer.runtimeMode")}),children:[c(er,{icon:r}),c(aa,{children:o.label})]}),w(ra,{alignItemWithTrigger:!1,children:[Sr.map(s=>{let i=n(s),l=i.icon;return c(or,{value:s,hideIndicator:!0,className:"min-w-64 py-2","data-runtime-mode":s,children:w("span",{className:"flex items-center gap-2",children:[c(l,{className:"size-4"}),i.label]})},s)}),a?c("div",{className:"border-t px-2 py-1.5 text-muted-foreground text-xs leading-4","data-composer-next-turn-note":"popup",children:t("runtimeMode.appliesNextTurnHint")}):null]})]}),c($e,{side:"top",children:a?t("runtimeMode.appliesNextTurnHint"):o.label})]}),a?c("span",{className:"hidden whitespace-nowrap text-muted-foreground text-xs sm:inline","data-composer-next-turn-note":"inline",children:t("runtimeMode.appliesNextTurn")}):null]})}function rF(e){return c(Xb,{...e})}function Yb(e){let{t}=le();if(!e.showInteractionModeToggle)return null;let n=e.interactionMode==="plan",o=t(n?"composer.planModeTooltip":"composer.defaultModeTooltip");return w(Ue,{children:[w(Ke,{render:c(ho,{"data-composer-plan-toggle":"true",className:G("shrink-0 whitespace-nowrap",n?"bg-accent text-accent-foreground hover:bg-accent/90":"text-secondary-label hover:text-foreground"),type:"button",onClick:e.onToggleInteractionMode,"aria-label":o}),children:[n?c(er,{icon:rc,className:"text-current opacity-100"}):c(er,{icon:As,opticalSize:"large"}),c("span",{className:"sr-only sm:not-sr-only",children:t(n?"composer.interactionModePlan":"composer.interactionModeBuild")})]}),c($e,{side:"top",children:o})]})}function aF(e){return c(Yb,{...e})}X();var u9=(e,t)=>t.isResponding?e("primaryActions.submitting"):t.compact?t.isLastQuestion?e("primaryActions.submit"):e("primaryActions.next"):t.isLastQuestion?t.questionIndex>0?e("primaryActions.submitAnswers"):e("primaryActions.submitAnswer"):e("primaryActions.nextQuestion"),f9=e=>{e.preventDefault()},bd=fe(function({compact:t,pendingAction:n,isRunning:o,showPlanFollowUpPrompt:r,promptHasText:a,isSendBusy:s,sendDisabledReason:i,isEnvironmentUnavailable:l,isPreparingWorktree:d,hasSendableContent:u,preserveComposerFocusOnPointerDown:f=!1,showSendWhileRunning:p=!1,onPreviousPendingQuestion:m,onInterrupt:h,interruptArmed:g=!1,stopping:v=!1,onImplementPlanInNewThread:C,shellCommandMode:y=!1,shellCommandUnavailableReason:x=null}){let{t:b}=le(),T=Nt(),I=f?{onPointerDown:f9}:void 0,P=T.settings.useEnvironmentIdentificationMode(),k=i!==null,S=T.devBackdrop.useVisible(P==="artwork"),L=_=>c("button",{type:"button",className:G("flex cursor-pointer items-center justify-center rounded-full bg-destructive/90 text-white shadow-xs shadow-destructive/24 inset-shadow-[0_1px_--theme(--color-white/16%)] transition-[background-color,scale] duration-(--control-duration) hover:bg-destructive hover:scale-105 active:inset-shadow-[0_1px_--theme(--color-black/8%)] active:shadow-none",v?"h-8 cursor-default px-3 text-xs font-medium whitespace-nowrap opacity-70 hover:scale-100":g?"h-8 px-3 text-xs font-medium whitespace-nowrap ring-2 ring-destructive/60":_?"size-8 sm:size-7":p&&u?"size-9 sm:size-8":"size-8 sm:h-8 sm:w-8"),...I,onClick:h,disabled:v,"data-interrupt-armed":g&&!v?"":void 0,"aria-label":b(v?"primaryActions.stopping":g?"primaryActions.confirmStopEsc":"primaryActions.stopGeneration"),children:v?b("primaryActions.stopping"):g?b("primaryActions.confirmStopEsc"):c("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":"true",children:c("rect",{x:"2",y:"2",width:"8",height:"8",rx:"1.5"})})});if(n)return w("div",{className:G("flex items-center justify-end",t?"gap-1.5":"gap-2"),children:[o?L(!0):null,n.questionIndex>0?t?c(re,{size:"icon-sm",variant:"outline",className:"rounded-full",...I,onClick:m,disabled:n.isResponding,"aria-label":b("primaryActions.previousQuestion"),children:c(Ms,{})}):c(re,{size:"sm",variant:"outline",className:"rounded-full",...I,onClick:m,disabled:n.isResponding,children:b("primaryActions.previous")}):null,c(re,{type:"submit",size:"sm",className:G("rounded-full bg-message-action text-message-action-foreground hover:bg-message-action-hover",t?"px-3":"px-4"),...I,disabled:l||n.isResponding||(n.isLastQuestion?!n.isComplete:!n.canAdvance),children:u9(b,{compact:t,isLastQuestion:n.isLastQuestion,isResponding:n.isResponding,questionIndex:n.questionIndex})})]});if(y){let _=c("button",{type:"submit","data-shell-command-run":"true",className:"flex h-9 w-9 items-center justify-center rounded-full bg-message-action text-message-action-foreground shadow-xs shadow-message-action/24 transition-[background-color,opacity,scale] duration-(--control-duration) enabled:cursor-pointer enabled:inset-shadow-[0_1px_--theme(--color-white/16%)] hover:scale-105 hover:bg-message-action-hover active:inset-shadow-[0_1px_--theme(--color-black/8%)] active:shadow-none disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none disabled:hover:scale-100 sm:h-8 sm:w-8",...I,disabled:x!==null||!u,"aria-label":x??b("primaryActions.runInTerminal"),children:c(To,{"aria-hidden":"true",className:"size-4"})});return o?w(he,{children:[L(!1),_]}):_}if(r)return a?c(re,{type:"submit",size:"sm",className:G("rounded-full bg-message-action text-message-action-foreground hover:bg-message-action-hover",t?"h-9 px-3 sm:h-8":"h-9 px-4 sm:h-8"),...I,disabled:s||k||l,children:b(s?"primaryActions.sendingButtonLabel":"primaryActions.refine")}):w("div",{"data-chat-composer-implement-actions":"true",className:"flex items-center justify-end",children:[c(re,{type:"submit",size:"sm",className:"h-9 rounded-l-full rounded-r-none bg-message-action px-4 text-message-action-foreground hover:bg-message-action-hover sm:h-8",...I,disabled:s||k||l,children:b(s?"primaryActions.sendingButtonLabel":"primaryActions.implement")}),w(ro,{children:[c(so,{render:c(re,{size:"sm",variant:"default",className:"h-9 rounded-l-none rounded-r-full border-l-message-action-foreground/20 bg-message-action px-2 text-message-action-foreground hover:bg-message-action-hover sm:h-8","aria-label":b("primaryActions.implementationActions"),...I,disabled:s||k||l}),children:c(ln,{})}),c(ao,{align:"end",side:"top",children:c(Uo,{disabled:s||k||l,onClick:()=>{C()},children:b("primaryActions.implementInNewThread")})})]})]});let R=w("button",{type:"submit",className:G("relative isolate flex h-9 w-9 items-center justify-center overflow-hidden rounded-full shadow-xs transition-[background-color,filter,opacity,scale] duration-(--control-duration) enabled:cursor-pointer enabled:inset-shadow-[0_1px_--theme(--color-white/16%)] hover:scale-105 active:inset-shadow-[0_1px_--theme(--color-black/8%)] active:shadow-none disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none disabled:hover:scale-100 sm:h-8 sm:w-8",S?"bg-transparent text-white enabled:shadow-black/24 enabled:hover:brightness-110":"bg-message-action text-message-action-foreground enabled:shadow-message-action/24 hover:bg-message-action-hover"),...I,disabled:s||k||l||!u,"aria-label":l?b("primaryActions.environmentDisconnected"):i||b(d?"primaryActions.preparingWorktree":s?"primaryActions.sendingAriaLabel":"primaryActions.sendMessage"),children:[S?c("span",{className:"absolute inset-0 -z-10","aria-hidden":"true",children:c(Cw,{compact:!0})}):null,s?c(nl,{className:"size-3.5","aria-hidden":"true"}):c("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:c("path",{d:"M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})]});return o?w(he,{children:[L(!1),p&&u?R:null]}):R});function Zu(e){let t=e.slots?.renderSlot(e.name,e.owner??{},e.fallback);return c("span",{"data-conversation-slot":e.name,children:t??e.fallback})}function Ea(e){return e===null||!Number.isFinite(e)?"0":e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}function p9(e){return e===null||!Number.isFinite(e)?null:e<10?`${e.toFixed(1).replace(/\.0$/,"")}%`:`${Math.round(e)}%`}function sF(e){let{t}=le(),{usage:n,breakdown:o,modelDisplayName:r,onCompact:a,compactDisabled:s,compactDisabledReason:i}=e,l=p9(n.usedPercentage),d=n.usedPercentage??0,u=n.usedPercentage===null?null:100,f=n.totalProcessedTokens??null,p=f!==null&&f>0;return w(Mr,{children:[c(_r,{openOnHover:!0,delay:150,closeDelay:a?150:0,render:c(re,{size:"icon-sm",variant:"ghost-muted","data-context-window-meter":"true",className:"size-7 rounded-full hover:text-muted-foreground data-pressed:text-muted-foreground","aria-label":n.maxTokens!==null&&l?t("contextWindow.usedPercentAria",{percentage:l}):t("contextWindow.usedTokensAria",{tokens:Ea(n.usedTokens)}),children:c(Eh,{"aria-hidden":!0,"aria-label":t("contextWindow.usage"),limit:u,shape:"ring",used:d})})}),c(Nr,{tooltipStyle:!0,side:"top",align:"end",viewportClassName:"p-0",className:"w-64 max-w-none text-left whitespace-normal",children:w("div",{className:"flex flex-col gap-2 p-[var(--floating-content-inset)]",children:[w("div",{className:"flex items-center justify-between gap-3",children:[c("div",{className:"font-medium text-muted-foreground text-xs",children:t("contextWindow.title")}),n.maxTokens!==null&&l?w("div",{className:"text-secondary-label text-[11px] tabular-nums",children:[c("span",{children:l}),c("span",{className:"mx-1",children:"\xB7"}),w("span",{children:[Ea(n.usedTokens),"/",Ea(n.maxTokens??null)]})]}):c("div",{className:"text-secondary-label text-[11px] tabular-nums",children:Ea(n.usedTokens)})]}),n.maxTokens!==null?c(Eh,{"aria-label":t("contextWindow.usage"),limit:u,shape:"bar",used:d}):null,o?w("div",{className:"flex flex-col gap-1","data-context-breakdown":"true",children:[w("div",{className:"flex items-center justify-between gap-3 text-[11px] leading-4","data-context-breakdown-row":"system",children:[c("span",{className:"text-secondary-label",children:t("contextWindow.system")}),c("span",{className:"font-medium tabular-nums text-secondary-label",children:Ea(o.systemTokens)})]}),w("div",{className:"flex items-center justify-between gap-3 text-[11px] leading-4","data-context-breakdown-row":"tools",children:[c("span",{className:"text-secondary-label",children:t("contextWindow.tools")}),c("span",{className:"font-medium tabular-nums text-secondary-label",children:Ea(o.toolsTokens)})]}),w("div",{className:"flex items-center justify-between gap-3 text-[11px] leading-4","data-context-breakdown-row":"messages",children:[c("span",{className:"text-secondary-label",children:t("contextWindow.messages")}),c("span",{className:"font-medium tabular-nums text-secondary-label",children:Ea(o.messageTokens)})]})]}):null,p?w("div",{className:"flex items-center justify-between gap-3 text-[11px] leading-4",children:[c("span",{className:"text-secondary-label",children:t("contextWindow.totalProcessed")}),c("span",{className:"font-medium tabular-nums text-secondary-label",children:Ea(f)})]}):null,n.compactsAutomatically?c("div",{className:"mt-1 text-pretty text-secondary-label text-[11px] font-medium",children:eO(t,r,n.autoCompactThreshold)}):null,a?w(he,{children:[w(re,{size:"xs",variant:"outline",className:"mt-1 w-full justify-center",disabled:s,onClick:a,children:[c(nc,{"aria-hidden":"true"}),t("contextWindow.compactContext")]}),s&&i?c("div",{className:"text-pretty text-secondary-label text-[11px]",children:i}):null]}):null]})})]})}X();function iF(e){if(e.useDraftPresetId===void 0||e.setDraftPresetId===void 0)throw new Error("missing draft preset api: useDraftPresetId and setDraftPresetId");return{useDraftPresetId:e.useDraftPresetId,setDraftPresetId:e.setDraftPresetId}}function Jb(e,t){return t==null?void 0:e.find(n=>n.presetId===t)}var Zb="__none__",lF=fe(function({environmentId:t,draftId:n,threadPresetId:o,compact:r}){let{t:a}=le(),s=Nt().presets,i=iF(s),l=s.useThreadPresets(t),d=i.useDraftPresetId(n);if(n===null){let m=Jb(l,o)?.displayName??o;return m===null?null:c(m9,{compact:r,label:m,applied:a("preset.appliedLabel",{name:m}),disabled:!0})}if(l.length===0)return null;let f=Jb(l,d)?.displayName??a("preset.none");return w(ro,{children:[w(so,{render:c(ho,{variant:"ghost","aria-label":a("preset.triggerLabel"),className:"max-w-40 min-w-0 shrink"}),children:[c(dF,{compact:r,label:f,applied:a("preset.appliedLabel",{name:f})}),c(Wr,{})]}),c(ao,{align:"start",children:w(ol,{children:[c("div",{className:"px-2 pt-1.5 pb-1 font-medium text-muted-foreground text-xs",children:a("preset.menuTitle")}),w(rr,{value:d??Zb,onValueChange:p=>{i.setDraftPresetId(n,p===Zb?null:p)},children:[c(ko,{value:Zb,hideIndicator:!0,closeOnClick:!0,children:c("span",{className:"min-w-0 truncate",children:a("preset.none")})}),l.map(p=>c(ko,{value:p.presetId,hideIndicator:!0,closeOnClick:!0,children:w("span",{className:"flex w-full min-w-0 flex-col",children:[c("span",{className:"min-w-0 truncate",children:p.displayName}),p.description?c("span",{className:"max-w-56 text-pretty text-muted-foreground/80 text-xs",children:p.description}):null]})},p.presetId))]})]})})]})});function m9(e){return c(ho,{variant:"ghost",disabled:e.disabled,"aria-label":e.applied,className:"max-w-40 min-w-0 shrink",children:c(dF,{compact:e.compact,label:e.label,applied:e.applied})})}function dF(e){return w(Ue,{children:[w(Ke,{render:c("span",{className:"flex min-w-0 items-center gap-1.5"}),children:[c(er,{icon:$a}),e.compact?null:c("span",{className:"min-w-0 truncate",children:e.label})]}),c($e,{side:"top",children:e.applied})]})}var g9=fe(function(t){let{data:n,target:o}=qo(),r=n.useContextUsage(o);return r?.window==null?null:c(sF,{usage:r.window,breakdown:r.breakdown,modelDisplayName:t.modelDisplayName,onCompact:t.onCompact,compactDisabled:t.compactDisabled,compactDisabledReason:t.compactDisabledReason})}),h9=fe(function(t){let{t:n}=le();return w(he,{children:[c(g9,{modelDisplayName:t.activeThreadModelDisplayName,onCompact:t.onCompactContext,compactDisabled:t.compactDisabled,compactDisabledReason:t.compactDisabledReason}),t.isPreparingWorktree?c("span",{className:"text-secondary-label text-xs",children:n("composer.preparingWorktree")}):null,c(bd,{compact:t.compact,pendingAction:t.pendingAction,isRunning:t.isRunning,showPlanFollowUpPrompt:t.showPlanFollowUpPrompt,promptHasText:t.promptHasText,isSendBusy:t.isSendBusy,sendDisabledReason:t.sendDisabledReason,isEnvironmentUnavailable:t.isEnvironmentUnavailable,isPreparingWorktree:t.isPreparingWorktree,hasSendableContent:t.hasSendableContent,preserveComposerFocusOnPointerDown:t.preserveComposerFocusOnPointerDown??!1,showSendWhileRunning:t.showSendWhileRunning??!1,onPreviousPendingQuestion:t.onPreviousPendingQuestion,onInterrupt:t.onInterrupt,interruptArmed:t.interruptArmed,stopping:t.stopping,onImplementPlanInNewThread:t.onImplementPlanInNewThread,shellCommandMode:t.shellCommandMode,shellCommandUnavailableReason:t.shellCommandUnavailableReason})]})});function cF(e){let{t}=le(),{isComposerFooterCompact:n,isComposerPrimaryActionsCompact:o,isMobileViewport:r,showMobilePendingAnswerActions:a,hasPendingUserInputs:s,projectSelectionRequired:i,noProviderAvailable:l,composerAttachmentInputRef:d,onComposerAttachmentInputChange:u,slots:f,selectedInstanceId:p,unavailableAgentInstanceId:m,agentNotChosen:h,agentUnavailable:g,providerInstanceEntries:v,lockedProvider:C,lockedContinuationGroupKey:y,onAgentInstanceChange:x,selectedModelForPickerWithCustomFallback:b,selectedModelStatus:T,keybindings:I,modelOptionsByInstance:P,terminalOpen:k,isComposerModelPickerOpen:S,setIsComposerModelPickerOpen:L,getModelDisabledReason:R,getModelContinuationLabel:_,onContinueInModel:E,onProviderModelSelect:D,canSelectPluginAction:H,pluginOptions:K,selectedPluginAction:O,onSelectPluginAction:Z,onManagePlugins:N,isPluginComposer:B,environmentId:ue,routeKind:U,draftId:oe,activeThread:Q,interactionMode:V,runtimeMode:W,composerProviderControls:ee,composerNativeMode:ie,canSwitchNativeMode:J,providerTraitsMenuContent:ae,providerTraitsPicker:Se,toggleInteractionMode:we,handleRuntimeModeChange:Ce,handleComposerNativeModeChange:Re,inlineTasksBadge:rt,inlineStashBadge:te,activeThreadModelDisplayName:se,pendingPrimaryAction:q,phase:ce,showPlanFollowUpPrompt:Y,composerDraft:ke,isSendBusy:Fe,sendDisabledReason:Ge,environmentUnavailable:Ve,isPreparingWorktree:It,previousUserInputQuestion:ft,handleInterruptPrimaryAction:wt,interruptArmed:Ze,stopping:it,handleImplementPlanInNewThreadPrimaryAction:Zt,shellCommandMode:Ht,shellCommandUnavailableReason:de,compactDisabled:Pe,resolvedCompactDisabledReason:Ie,compactThreadContext:ze}=e;return w("div",{"data-chat-composer-footer":"true","data-chat-composer-footer-compact":n?"true":"false",className:G("flex min-w-0 select-none flex-nowrap items-center justify-between gap-2 overflow-visible px-3 pb-3 sm:px-4 sm:pb-4",s&&"pt-2",n?"gap-1.5":"gap-2 sm:gap-0",a&&"hidden sm:flex"),children:[w("div",{className:"-m-1 -ms-3.5 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto p-1 ps-3.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[c("input",{ref:d,type:"file",multiple:!0,className:"hidden",tabIndex:-1,"aria-hidden":"true",onChange:u}),w(Ue,{children:[c(Ke,{render:c(re,{type:"button",variant:"ghost",size:"icon-sm","data-chat-composer-attach":"true",className:"shrink-0",disabled:i||s,"aria-label":t("attachments.add"),onClick:()=>d.current?.click()}),children:c(Io,{})}),c($e,{side:"top",children:t("attachments.add")})]}),l?w(re,{type:"button",size:"sm",variant:"ghost",disabled:!0,"data-chat-provider-unavailable":"true",className:"shrink-0 gap-2 px-2 text-secondary-label sm:px-3",children:[c(Jt,{className:"size-4"}),t("composer.noProviderAvailable")]}):w(he,{children:[c(Zu,{name:"conversation.input.agent",...f===void 0?{}:{slots:f},owner:{activeInstanceId:p,unavailableInstanceId:m,notChosen:h,instanceEntries:v,lockedProvider:C,lockedContinuationGroupKey:y,compact:n,onInstanceChange:x},fallback:c(Ob,{activeInstanceId:p,unavailableInstanceId:m,notChosen:h,instanceEntries:v,lockedProvider:C,lockedContinuationGroupKey:y,compact:n,onInstanceChange:x})}),g||h?null:c(eF,{...f===void 0?{}:{slots:f},compact:n,hideInstanceRail:!0,showInstanceOnTrigger:!1,activeInstanceId:p,model:b,modelStatus:T,lockedProvider:C,lockedContinuationGroupKey:y,instanceEntries:v,keybindings:I,modelOptionsByInstance:P,terminalOpen:k,open:S,onOpenChange:nt=>{L(nt)},getModelDisabledReason:R,getModelContinuationLabel:_,onContinueInModel:E,onInstanceModelChange:D,...H?{pluginActions:K,selectedPluginActionKey:O?.id??null,onSelectPluginAction:Z,onManagePlugins:N}:{}})]}),B?null:w(he,{children:[c(lF,{environmentId:ue,draftId:U==="draft"?oe:null,threadPresetId:Q?.presetId??null,compact:n},U==="draft"?oe:Q?.id??"thread"),n?c(TO,{interactionMode:V,runtimeMode:W,runtimeModeSwitch:ee.runtimeModeSwitch,nativeMode:ie,canSwitchNativeMode:J,showInteractionModeToggle:ee.showInteractionModeToggle,traitsMenuContent:ae,onToggleInteractionMode:we,onRuntimeModeChange:Ce,onNativeModeChange:Re}):w(he,{children:[Se?c(Zu,{name:"conversation.input.effort",...f===void 0?{}:{slots:f},fallback:Se}):null,ie===null&&ee.showInteractionModeToggle?c(Zu,{name:"conversation.input.plan",...f===void 0?{}:{slots:f},owner:{interactionMode:V,showInteractionModeToggle:ee.showInteractionModeToggle,onToggleInteractionMode:we},fallback:c(Yb,{interactionMode:V,showInteractionModeToggle:ee.showInteractionModeToggle,onToggleInteractionMode:we})}):null,c(Zu,{name:"conversation.input.permission",...f===void 0?{}:{slots:f},owner:{runtimeMode:W,runtimeModeSwitch:ee.runtimeModeSwitch,nativeMode:ie,canSwitchNativeMode:J,onRuntimeModeChange:Ce,onNativeModeChange:Re},fallback:c(Xb,{runtimeMode:W,runtimeModeSwitch:ee.runtimeModeSwitch,nativeMode:ie,canSwitchNativeMode:J,onRuntimeModeChange:Ce,onNativeModeChange:Re})})]})]})]}),w("div",{"data-chat-composer-actions":"right","data-chat-composer-primary-actions-compact":o?"true":"false",className:"flex shrink-0 flex-nowrap items-center justify-end gap-2",children:[a?null:rt,a?null:te,c(h9,{compact:o,activeThreadModelDisplayName:se,pendingAction:q,isRunning:ce==="running",showPlanFollowUpPrompt:!s&&Y,promptHasText:ke.promptHasText,isSendBusy:Fe,sendDisabledReason:Ge,isEnvironmentUnavailable:Ve!==null||l||i,isPreparingWorktree:It,hasSendableContent:ke.hasSendableContent,preserveComposerFocusOnPointerDown:r,showSendWhileRunning:r,onPreviousPendingQuestion:ft,onInterrupt:wt,interruptArmed:Ze,stopping:it,onImplementPlanInNewThread:Zt,shellCommandMode:Ht,shellCommandUnavailableReason:de,compactDisabled:Pe||l||Fe,compactDisabledReason:Ie,onCompactContext:ze})]})]})}var v9=e=>e.prompt.trim();function y9(e){let{t}=le(),n=e.api.draft.useThreadDraftSelector(e.composerDraftTarget,v9),o=e.pendingCustomAnswer!==null;return c("button",{type:"button",className:G("min-w-0 flex-1 truncate bg-transparent p-0 text-left text-[14px]",(o?e.pendingCustomAnswer:n)?"text-foreground":"text-placeholder"),onPointerDown:r=>r.preventDefault(),onClick:e.onExpand,"aria-label":t("composer.expandComposer"),children:o?e.pendingCustomAnswer||t("composer.typeOwnAnswer"):n||(e.noProviderAvailable?t("composer.enableProviderSettings"):t("composer.askAnything"))})}function uF(e){let{api:t,composerDraftTarget:n,pendingCustomAnswer:o,noProviderAvailable:r,onExpand:a,inlineTasksBadge:s,inlineStashBadge:i,submitDisabled:l,submitLabel:d,onSubmit:u}=e;return w("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[c(y9,{api:t,composerDraftTarget:n,pendingCustomAnswer:o,noProviderAvailable:r,onExpand:a}),s,i,c("button",{type:"button",className:"flex size-8 shrink-0 items-center justify-center rounded-full bg-message-action text-message-action-foreground hover:bg-message-action-hover disabled:opacity-64",disabled:l,"aria-label":d,onPointerDown:f=>f.preventDefault(),onClick:f=>{f.stopPropagation(),u()},children:c("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:c("path",{d:"M8 3L8 13M8 3L4 7M8 3L12 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}X();X();var fF={recent:"slashMenu.sections.recent",builtIn:"slashMenu.sections.builtIn",provider:"slashMenu.sections.provider",skills:"slashMenu.sections.skills",files:"slashMenu.sections.files",threads:"slashMenu.sections.threads"},pF=fe(function(t){let{t:n}=le(),o=M(null),r=Br()?.data.threadReferences!==void 0;return me(()=>{if(!t.activeItemId||!o.current)return;o.current.querySelector(`[data-composer-item-id="${CSS.escape(t.activeItemId)}"]`)?.scrollIntoView({block:"nearest"})},[t.activeItemId]),c(Lf,{autoHighlight:!1,mode:"none",onItemHighlighted:a=>{t.onHighlightedItemChange(typeof a=="string"?a:null)},children:c("div",{ref:o,className:"chat-composer-drawer-surface chat-composer-drawer-attached relative w-full overflow-hidden **:data-[slot=scroll-area-scrollbar]:data-[orientation=vertical]:my-4","data-composer-command-drawer":"true",children:t.items.length>0?c(Af,{className:"max-h-72 scroll-pb-6",children:c(Rf,{children:t.items.map((a,s)=>c(C9,{sectionTitle:a.section!==void 0&&t.items[s-1]?.section!==a.section?a.section:null,item:a,triggerKind:t.triggerKind,resolvedTheme:t.resolvedTheme,isActive:t.activeItemId===a.id,onHighlight:t.onHighlightedItemChange,onSelect:t.onSelect},a.id))})}):c("div",{className:"px-5 pt-3.5 pb-7",children:c("p",{className:"text-secondary-label text-xs",children:t.isLoading?eS(t.triggerKind)?n("composer.searchingSkills"):n("composer.searchingFiles"):eS(t.triggerKind)?n("composer.noSkillsFound"):t.triggerKind==="path"?n(r?"composer.noMatchingFilesOrThreads":"composer.noMatchingFiles"):n("composer.noMatchingCommand")})})})})});function eS(e){return e==="skill"||e==="slash-skill"}var C9=fe(function(t){let{t:n}=le(),o=t.item.type==="skill"?CD(t.item.skill):null,r=t.triggerKind==="slash-command"&&t.item.type==="skill"?t.item.skill:null;return w(he,{children:[t.sectionTitle!==null?c("div",{role:"presentation","data-composer-menu-section":t.sectionTitle,className:"px-3 pt-2 pb-1 text-xs text-secondary-label",children:n(fF[t.sectionTitle]??fF.recent)}):null,w(Ef,{value:t.item.id,"data-composer-item-id":t.item.id,className:G("cursor-pointer select-none gap-3 rounded-lg px-3 py-2! hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit",t.isActive&&"bg-accent! text-accent-foreground!"),onMouseMove:()=>{t.isActive||t.onHighlight(t.item.id)},onMouseDown:a=>{a.preventDefault()},onClick:()=>{t.onSelect(t.item)},children:[t.item.type==="path"?c($g,{pathValue:t.item.path,kind:t.item.pathKind,theme:t.resolvedTheme}):null,t.item.type==="thread"?c(ta,{"aria-hidden":"true",className:"size-4 shrink-0 text-secondary-label"}):null,w("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[c("span",{className:"min-w-0 max-w-[45%] shrink-0 truncate font-sans text-xs font-medium",children:r?w(he,{children:[c("span",{className:"text-secondary-label",children:"/skill:"}),No(r)]}):t.item.label}),c("span",{className:"min-w-0 max-w-[48ch] flex-1 truncate text-left text-secondary-label text-xs",children:t.item.description}),o?c(S9,{kind:o,showSkillSuffix:eS(t.triggerKind)}):null]})]})]})}),x9={app:Fd,repo:Ua,project:Ua,personal:Ga,system:lc,other:oc},b9={app:"slashMenu.skillSource.app",repo:"slashMenu.skillSource.repo",project:"slashMenu.skillSource.project",personal:"slashMenu.skillSource.personal",system:"slashMenu.skillSource.system",other:"slashMenu.skillSource.other"};function S9(e){let{t}=le(),n=x9[e.kind],o=t(b9[e.kind]);return w(Er,{className:"ms-auto",variant:"secondary",children:[c(n,{"aria-hidden":"true",className:"text-current"}),e.showSkillSuffix?t("slashMenu.skillSourceWithSuffix",{source:o}):o]})}X();function w9(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function mF(e,t){let n=w9(e);if(!n)return"";let o=Date.now()-n.getTime();if(o<0)return t("relativeTime.justNow");let r=Math.floor(o/1e3);if(r<60)return t("relativeTime.justNow");let a=Math.floor(r/60);if(a<60)return t("relativeTime.minutesAgo",{count:a});let s=Math.floor(a/60);return s<24?t("relativeTime.hoursAgo",{count:s}):t("relativeTime.daysAgo",{count:Math.floor(s/24)})}var gF=90;function hF(e){return e.droppedImageNames.length+(e.unreadableImageNames?.length??0)}function I9(e,t){let n=e.prompt.trim().replace(/\s+/g," ");if(n.length>0)return n.length>gF?`${n.slice(0,gF)}\u2026`:n;let o=e.attachments.length+e.droppedImageNames.length;return o>0?t("stash.imageCountLabel",{count:o}):t("stash.emptyEntry")}var vF=fe(function(t){let{entries:n,onRestore:o,onDelete:r,onClose:a}=t,{t:s}=le(),i=Nt(),l=M(null),[d,u]=j(n[0]?.id??null),f=n.find(p=>p.id===d)??n[0];return z(()=>{let p=m=>{let h=l.current;h&&m.composedPath().includes(h)||m.target instanceof Element&&m.target.closest('[data-prompt-stash-badge="true"]')||a()};return document.addEventListener("pointerdown",p,!0),()=>document.removeEventListener("pointerdown",p,!0)},[a]),z(()=>{n.length!==0&&(n.some(p=>p.id===d)||u(n[0]?.id??null))},[n,d]),i.pane.useKeydown(p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),a();return}if(p.key==="ArrowDown"||p.key==="ArrowUp"){if(n.length===0)return;p.preventDefault(),p.stopPropagation();let m=n.findIndex(C=>C.id===d),h=p.key==="ArrowDown"?1:-1,v=((m>=0?m:h===1?-1:0)+h+n.length)%n.length;u(n[v]?.id??null);return}if(p.key==="Enter"){if(p.target instanceof HTMLElement&&p.target.closest("button[aria-label]")||!f)return;p.preventDefault(),p.stopPropagation(),o(f);return}if(p.key==="Backspace"&&(p.metaKey||p.ctrlKey)){if(!f)return;p.preventDefault(),p.stopPropagation(),r(f)}},{capture:!0}),c(Lf,{autoHighlight:!1,mode:"none",children:w("div",{ref:l,className:"chat-composer-drawer-surface chat-composer-drawer-attached relative w-full overflow-hidden","data-composer-stash-drawer":"true",children:[c("div",{className:"flex h-7 items-center justify-end px-2 pt-1",children:c(re,{variant:"ghost-muted",size:"icon-micro","aria-label":s("stash.closeLabel"),onPointerDown:p=>p.preventDefault(),onClick:a,children:c(Kt,{className:"size-3"})})}),c(Af,{className:"max-h-64 scroll-pb-6",children:c(Rf,{children:n.length===0?c("p",{className:"px-3 py-1.5 text-secondary-label text-xs",children:s("stash.empty")}):n.map(p=>w(Ef,{value:p.id,className:G("group/stash relative cursor-pointer select-none gap-3 rounded-lg px-3 py-1.5! hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit",d===p.id&&"bg-accent! text-accent-foreground!"),onMouseMove:()=>{d!==p.id&&u(p.id)},onMouseDown:m=>{m.preventDefault()},onClick:()=>{o(p)},children:[c("span",{className:"min-w-0 flex-1 truncate text-xs",children:I9(p,s)}),p.pendingImageCount?c("span",{className:"shrink-0 text-[10px] text-secondary-label",children:s("stash.savingImage",{count:p.pendingImageCount})}):hF(p)>0?c("span",{className:"shrink-0 text-[10px] text-warning-foreground",children:s("stash.imagesDropped",{count:hF(p)})}):null,p.attachments.length>0?c("span",{className:"flex shrink-0 items-center -space-x-1.5",children:p.attachments.slice(0,3).map(m=>c("img",{src:m.dataUrl,alt:"","aria-hidden":"true",className:"size-5 rounded border border-border/70 object-cover"},m.id))}):null,c("span",{className:"shrink-0 text-secondary-label text-xs max-sm:hidden",children:mF(p.createdAt,s)}),c(re,{variant:"ghost",size:"icon-xs",className:"pointer-events-none shrink-0 [--control-icon-color:currentColor] opacity-0 shadow-none! transition-opacity pointer-coarse:pointer-events-auto pointer-coarse:opacity-100 group-hover/stash:pointer-events-auto group-hover/stash:opacity-100 group-focus-within/stash:pointer-events-auto group-focus-within/stash:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100","aria-label":s("stash.deleteLabel"),onClick:m=>{m.stopPropagation(),r(p)},children:c(Kt,{className:"stroke-2"})})]},p.id))})})]})})});X();function T9(e,t){return e.bottom===t.bottom&&e.left===t.left&&e.maxHeight===t.maxHeight&&e.width===t.width&&e.overlap===t.overlap}function tS(e){let t=Nt(),n=af(),o=t.pane.useActive(),[r,a]=j(null);return me(()=>{if(!o)return;let s=e.anchor;if(!s){a(null);return}let i=!0,l=()=>{if(!i)return;let u=s.closest('[data-chat-composer-form="true"]'),p=(u?.querySelector('[data-chat-composer-main-surface="true"]')??u??s).getBoundingClientRect(),m=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)||16,g=(Number.parseFloat(window.getComputedStyle(u??s).getPropertyValue("--chat-composer-drawer-inset"))||1.375)*m,v=m+1,C={bottom:window.innerHeight-p.top-v,left:p.left+g,maxHeight:Math.max(96,p.top-24+v),width:Math.max(0,p.width-g*2),overlap:v};a(y=>y&&T9(y,C)?y:C)};l(),window.addEventListener("resize",l),window.addEventListener("scroll",l,!0);let d=typeof ResizeObserver>"u"?null:new ResizeObserver(l);if(d){d.observe(s);for(let u=s.parentElement;u;u=u.parentElement)d.observe(u)}return()=>{i=!1,d?.disconnect(),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0)}},[e.anchor,o]),!o||!r?null:t.createPortal(w("div",{className:n,"data-composer-drawer-layer":"true",style:{position:"fixed",zIndex:45,pointerEvents:"auto",clipPath:`inset(0 0 ${r.overlap}px 0)`,bottom:r.bottom,left:r.left,maxHeight:r.maxHeight,width:r.width},children:[c(k9,{}),e.children]}),document.body)}function k9(){return i1(),null}X();function nS(e,t){let n=e.name.toLowerCase(),o=No(e).toLowerCase(),r=e.shortDescription?.toLowerCase()??"",a=e.description?.toLowerCase()??"",s=e.scope?.toLowerCase()??"",i=[wr({value:n,query:t,exactBase:0,prefixBase:2,boundaryBase:4,includesBase:6,fuzzyBase:100,boundaryMarkers:["-","_","/"]}),wr({value:o,query:t,exactBase:1,prefixBase:3,boundaryBase:5,includesBase:7,fuzzyBase:110}),wr({value:r,query:t,exactBase:20,prefixBase:22,boundaryBase:24,includesBase:26}),wr({value:a,query:t,exactBase:30,prefixBase:32,boundaryBase:34,includesBase:36}),wr({value:s,query:t,exactBase:40,prefixBase:42,includesBase:44})].filter(l=>l!==null);return i.length===0?null:Math.min(...i)}function yF(e,t,n=Number.POSITIVE_INFINITY){let o=e.filter(Cl),r=Kn(t,{trimLeadingPattern:/^\$+/});if(!r)return o;let a=[];for(let s of o){let i=nS(s,r);i!==null&&ch(a,{item:s,score:i,tieBreaker:`${No(s).toLowerCase()}\0${s.name}`},n)}return a.map(s=>s.item)}function P9(e,t){if(e.type==="skill"){if(t==="skill")return 0;let a=t.startsWith("skill:")?t.slice(6):t,s=a?nS(e.skill,a):0;return s!==null?s:"skill".startsWith(t)?Number.MAX_SAFE_INTEGER:null}let n=e.type==="slash-command"?e.command.toLowerCase():e.command.name.toLowerCase(),o=e.description.toLowerCase(),r=[wr({value:n,query:t,exactBase:0,prefixBase:2,boundaryBase:4,includesBase:6,fuzzyBase:100,boundaryMarkers:["-","_","/"]}),wr({value:o,query:t,exactBase:20,prefixBase:22,boundaryBase:24,includesBase:26})].filter(a=>a!==null);return r.length===0?null:Math.min(...r)}function CF(e,t,n=[]){let o=Kn(t,{trimLeadingPattern:/^\/+/});if(!o)return[...e];let r=[];for(let a of e){let s=P9(a,o);if(s===null)continue;let i=n.includes(a.id)?s-1:s;ch(r,{item:a,score:i,tieBreaker:a.type==="slash-command"?`0\0${a.command}`:a.type==="provider-slash-command"?`1\0${a.command.name}\0${a.provider}`:`2\0${a.skill.name}\0${a.provider}`},Number.POSITIVE_INFINITY)}return r.map(a=>a.item)}function xF(e,t){let n=new Map(e.map(i=>[i.id,i])),o=t.map(i=>n.get(i)).filter(i=>i!==void 0).slice(0,3).map(i=>({...i,section:"recent"})),r=new Set(o.map(i=>i.id)),a=e.filter(i=>!r.has(i.id)),s=i=>i.type==="slash-command"?"builtIn":i.type==="provider-slash-command"?"provider":"skills";return[...o,...a.map(i=>({...i,section:s(i)}))]}function oS(e){return e.items.length===0?null:e.currentSearchKey===e.highlightedSearchKey&&e.highlightedItemId&&e.items.some(t=>t.id===e.highlightedItemId)?e.highlightedItemId:e.items[0]?.id??null}var bF=(e,t,n)=>n.endsWith(" ")&&e[t]===" "?t+1:t,L9=Object.freeze([]),R9=()=>L9,E9=Object.freeze({environmentId:"",threadId:""});function uh(e){return e===null?null:`${e.kind}:${e.rangeStart}:${e.rangeEnd}:${e.query}`}function SF({prompt:e,selectedProvider:t,selectedProviderStatus:n,planModeUiEnabled:o,showSkillsInSlashMenu:r,recentSlashCommandIds:a,environmentId:s,gitCwd:i,useComposerPathSearch:l,readComposerSnapshot:d,applyPromptReplacement:u,onInteractionModeChange:f,onOpenModelPicker:p,onSlashCommandUsed:m}){let{t:h}=le(),[g,v]=j(()=>go(e,e.length)),[C,y]=j(null),[x,b]=j(null),[T,I]=j(null),P=C!==null&&uh(g)===C?null:g,k=P?.kind==="path"?P.query:"",S=P?.kind==="path",L=l({environmentId:s,cwd:S?i:null,query:S?k:null}),R=Br(),_=R?.data.threadReferences,E=(_?.useCandidates??R9)({target:R?.target??E9,query:S?k:null}),D=$(()=>{if(!P)return[];if(P.kind==="path"){let Q=V=>E.length>0?{section:V}:{};return[...L.entries.map(V=>({id:`path:${V.kind}:${V.path}`,type:"path",path:V.path,pathKind:V.kind,label:A9(V.path),description:V.path.slice(0,Math.max(0,V.path.lastIndexOf("/"))),...Q("files")})),...E.map(V=>({id:`thread:${V.reference.environmentId}:${V.reference.threadId}`,type:"thread",reference:V.reference,label:V.reference.title,description:[V.projectLabel,V.machineLabel].filter(W=>W!==null).join(" \xB7 "),...Q("threads")}))]}if(P.kind==="slash-command"){let Q=[{id:"slash:model",type:"slash-command",command:"model",label:"/model",description:h("composer.switchModelDesc")},...o?[{id:"slash:plan",type:"slash-command",command:"plan",label:"/plan",description:h("composer.planDesc")},{id:"slash:default",type:"slash-command",command:"default",label:"/default",description:h("composer.defaultDesc")}]:[]],V=hb(n?.skills??[],r),W=yD(n?.slashCommands??[],n?.skills??[]).map(ae=>({id:`provider-slash-command:${t}:${ae.name}`,type:"provider-slash-command",provider:t,command:ae,label:`/${ae.name}`,description:ae.description??ae.input?.hint??h("composer.runProviderCommand")})),ee=P.query.trim().toLowerCase(),ie=V.map(ae=>({id:`skill:${t}:${ae.name}`,type:"skill",provider:t,skill:ae,label:`/skill:${ae.name}`,description:ae.shortDescription??ae.description??(ae.scope?h("composer.skillScopeDescription",{scope:ae.scope}):"")})),J=[...Q,...W,...ie];return ee===""?xF(J,a):CF(J,ee,a)}if(P.kind==="skill"||P.kind==="slash-skill"){let Q=P.kind==="skill"?n?.skills??[]:hb(n?.skills??[],r);return yF(Q,P.query).map(V=>({id:`skill:${t}:${V.name}`,type:"skill",provider:t,skill:V,label:No(V),description:V.shortDescription??V.description??(V.scope?h("composer.skillScopeDescription",{scope:V.scope}):h("composer.runProviderSkill"))}))}return[]},[P,o,a,t,n,r,h,E,L.entries]),H=P!==null&&!(P.kind==="slash-skill"&&D.length===0),K=P?`${P.kind}:${P.query.trim().toLowerCase()}`:null,O=$(()=>{let Q=oS({items:D,highlightedItemId:x,currentSearchKey:K,highlightedSearchKey:T});return D.find(V=>V.id===Q)??null},[D,x,K,T]),Z=A(()=>{let Q=d(),V=go(Q.value,Q.expandedCursor),W=C!==null&&uh(V)===C?null:V;return{snapshot:Q,trigger:W}},[d,C]),N=A(Q=>{let{snapshot:V,trigger:W}=Z();if(!W)return;if((Q.type==="slash-command"||Q.type==="provider-slash-command"||Q.type==="skill")&&m?.(Q.id),Q.type==="path"||Q.type==="thread"){let ae=Q.type==="path"?Fi(Q.path):_?.serialize(Q.reference)??null;if(ae===null)return;let Se=`${ae} `,we=bF(V.value,W.rangeEnd,Se);u(W.rangeStart,we,Se,{expectedText:V.value.slice(W.rangeStart,we)})&&b(null);return}if(Q.type==="slash-command"){if(Q.command==="model"){u(W.rangeStart,W.rangeEnd,"",{expectedText:V.value.slice(W.rangeStart,W.rangeEnd),focusEditorAfterReplace:!1})&&(b(null),p());return}f(Q.command==="plan"?"plan":"default"),u(W.rangeStart,W.rangeEnd,"",{expectedText:V.value.slice(W.rangeStart,W.rangeEnd)})&&b(null);return}let ee=Q.type==="provider-slash-command"?`/${Q.command.name} `:`$${Q.skill.name} `,ie=bF(V.value,W.rangeEnd,ee);u(W.rangeStart,ie,ee,{expectedText:V.value.slice(W.rangeStart,ie)})&&b(null)},[u,f,p,m,Z,_]);z(()=>{if(!H){b(null),I(null);return}let Q=oS({items:D,highlightedItemId:x,currentSearchKey:K,highlightedSearchKey:T});b(V=>V===Q?V:Q),I(V=>V===K?V:K)},[x,T,D,H,K]);let B=A(Q=>{b(Q),I(K)},[K]),ue=A(()=>{let{trigger:Q}=Z();return Q===null||Q.kind==="slash-skill"&&!H?!1:(y(uh(Q)),b(null),!0)},[H,Z]),U=A((Q,V)=>{let W=Mo(Q,V),ee=go(Q,W);v(ee);let ie=uh(ee);y(J=>J!==null&&J!==ie?null:J),b(null),I(null)},[]),oe=A(()=>{b(null)},[]);return{composerTrigger:g,menuTrigger:P,composerMenuItems:D,composerMenuOpen:H,composerMenuSearchKey:K,activeComposerMenuItem:O,resolveActiveComposerTrigger:Z,onSelectComposerItem:N,onComposerMenuItemHighlighted:B,onMenuEscape:ue,resetForDocumentChange:U,dismissTrigger:oe,workspaceEntries:L,highlightedItemId:x,setTrigger:v,setHighlightedItemId:b,setHighlightedSearchKey:I}}function A9(e){let t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t>=0?e.slice(t+1):e}X();function wF(e,t){let n=$(()=>Ep((e??[]).filter(Cl)),[e]);return A((o,r)=>{let a=V0(o,r,n,fb);a!==null&&t(a.start,a.end,a.replacement,{expectedText:r.slice(a.start,a.end)})},[t,n])}var IF=[],TF=[],kF=e=>e.prompt,PF=(e,t)=>{let n=new Map(e.map(o=>[o.id,o]));return t.flatMap(o=>{let r=n.get(o);return r?[r]:[]})},LF=(e,t)=>e.length===t.length&&e.every((n,o)=>n.id===t[o]);var RF=fe(function(t){let{handleRef:n,api:o,composerDraftTarget:r,composerDocumentKey:a,promptRef:s,editorRef:i,menuAnchor:l,resolvedTheme:d,selectedProvider:u,selectedProviderStatus:f,planModeUiEnabled:p,showSkillsInSlashMenu:m,recentSlashCommandIds:h,environmentId:g,gitCwd:v,onSlashCommandUsed:C,onOpenModelPicker:y,onInteractionModeChange:x,onToggleInteractionMode:b,activePendingProgress:T,activePendingRequestId:I,hasPendingUserInputs:P,changeUserInputCustomAnswer:k,terminalContexts:S,showTerminalContexts:L,showEditor:R,isApprovalState:_,editorClassName:E,placeholder:D,disabled:H,onPaste:K,onSubmit:O,isMobileViewport:Z,isDraftRoute:N,stashMenuOpen:B,stashEntries:ue,onRestoreStashEntry:U,onDeleteStashEntry:oe,onCloseStashMenu:Q,onPromptEdited:V,onUnclaimedEscape:W}=t,ee=o.draft.useThreadDraftSelector(r,kF),ie=o.draft.useStore,J=ie(be=>be.setPrompt),ae=ie(be=>be.setTerminalContexts),Se=ie(be=>be.removeTerminalContext),we=Un(ee,ee.length),Ce=La(a,ee,{cursor:we,expandedCursor:ee.length}),[Re,rt]=j(()=>({documentKey:a,cursor:Ce.cursor})),te=Re.documentKey===a?Re.cursor:Ce.cursor,se=A(be=>{rt(Be=>{let lt=Be.documentKey===a?Be.cursor:La(a,s.current).cursor,tt=typeof be=="function"?be(lt):be,ct=s.current,mt=Mo(ct,tt);return cD(a,ct,tt,mt),Be.documentKey===a&&Be.cursor===tt?Be:{documentKey:a,cursor:tt}})},[a,s]),q=M(!1),ce=M(!1),Y=M([]),ke=M(null),Fe=A(be=>{J(r,be)},[r,J]),Ge=A((be,Be,lt,tt,ct)=>{k(be,Be,lt,tt,ct),s.current=Be},[k,s]),Ve=A((be,Be,lt,tt)=>{let ct=s.current,mt=Math.max(0,Math.min(ct.length,be)),Rt=Math.max(mt,Math.min(ct.length,Be));if(tt?.expectedText!==void 0&&ct.slice(mt,Rt)!==tt.expectedText)return!1;let Ut=rD(s.current,be,Be,lt),pn=Un(Ut.text,Ut.cursor),Vn=Mo(Ut.text,pn);s.current=Ut.text;let mn=T?.activeQuestion;return mn&&P?Ge(mn.id,Ut.text,pn,Vn,!1):Fe(Ut.text),se(pn),nt(go(Ut.text,Vn)),tt?.focusEditorAfterReplace!==!1&&window.requestAnimationFrame(()=>{i.current?.focusAt(pn)}),!0},[T?.activeQuestion,i,P,Ge,s,se,Fe]),It=A(()=>{let be=i.current?.readSnapshot();return be||{value:s.current,cursor:te,expandedCursor:Mo(s.current,te),terminalContextIds:S.map(Be=>Be.id)}},[te,i,s,S]),ft=SF({prompt:ee,selectedProvider:u,selectedProviderStatus:f,planModeUiEnabled:p,showSkillsInSlashMenu:m,recentSlashCommandIds:h,environmentId:g,gitCwd:v,useComposerPathSearch:o.pathSearch.useComposerPathSearch,readComposerSnapshot:It,applyPromptReplacement:Ve,onInteractionModeChange:x,onOpenModelPicker:y,onSlashCommandUsed:C}),{composerTrigger:wt,composerMenuItems:Ze,composerMenuOpen:it,activeComposerMenuItem:Zt,resolveActiveComposerTrigger:Ht,onComposerMenuItemHighlighted:de,onMenuEscape:Pe,workspaceEntries:Ie,highlightedItemId:ze,setTrigger:nt,setHighlightedItemId:Pt}=ft,tn=wt?.kind??null,Dn=wt?.kind==="path"?wt.query:"",yt=T?T.customAnswer:ee,Ot=_?"":yt,xt=ft.resetForDocumentChange;z(()=>{xt(yt,te)},[a,xt,yt,te]),ce.current=it,Y.current=Ze,ke.current=Zt;let Ct=tn==="path"&&Dn.length>0&&Ie.isPending===!0,Lt=A(be=>{let Be=S.findIndex(ct=>ct.id===be);if(Be<0)return;let lt=o.terminalContext.removeInlinePlaceholder(s.current,Be);s.current=lt.prompt,Fe(lt.prompt),Se(r,be);let tt=Un(lt.prompt,lt.cursor);se(tt),nt(go(lt.prompt,lt.cursor))},[o.terminalContext,r,s,Se,se,Fe,S,nt]);me(()=>{s.current=ee,se(be=>Zo(ee,be))},[a,ee,s,se]),z(()=>{V(ee)},[V,ee]),z(()=>{it&&Q()},[it,Q]);let en=M(null);z(()=>{let be=T?.customAnswer;if(typeof be!="string"){if(en.current!==null){s.current=ee;let Rt=Un(ee,ee.length);se(Rt),nt(go(ee,Mo(ee,Rt)))}en.current=null;return}let Be=I,lt=T?.activeQuestion?.id??null,tt=en.current?.requestId!==Be||en.current?.questionId!==lt,ct=s.current!==be;if(en.current={requestId:Be,questionId:lt},!tt&&!ct)return;s.current=be;let mt=Un(be,be.length);se(mt),nt(go(be,Mo(be,mt))),Pt(null)},[T?.customAnswer,T?.activeQuestion?.id,I,ee,s]);let nn=wF(f?.skills,Ve),bt=A((be,Be,lt,tt,ct)=>{if(T?.activeQuestion&&P){if(T.activeQuestion.allowFreeform===!1)return;se(Be),nt(tt?null:go(be,lt)),Ge(T.activeQuestion.id,be,Be,lt,tt);return}let mt=s.current;s.current=be,Fe(be),LF(S,ct)||ae(r,PF(S,ct)),se(Be),nt(tt?null:go(be,lt)),nn(mt,be)},[T?.activeQuestion,nn,P,Ge,s,se,Fe,r,S,ae,nt]),Yt=ft.onSelectComposerItem,Gt=A(be=>{q.current||(q.current=!0,window.requestAnimationFrame(()=>{q.current=!1}),Yt(be))},[Yt]),Ye=A(be=>{if(Ze.length===0)return;let Be=Ze.findIndex(Rt=>Rt.id===ze),ct=((Be>=0?Be:be==="ArrowDown"?-1:0)+(be==="ArrowDown"?1:-1)+Ze.length)%Ze.length,mt=Ze[ct];Pt(mt?.id??null)},[ze,Ze,Pt]),jt=(be,Be)=>{if(be==="Escape")return Be.isComposing||Be.keyCode===229?!1:Pe()||(W?.()??!1);if(be==="Tab"&&Be.shiftKey)return p?(b(),!0):!1;let{trigger:lt}=Ht();if(ce.current||lt!==null){let mt=Y.current,Rt=ke.current??mt[0];if(be==="ArrowDown"&&mt.length>0)return Ye("ArrowDown"),!0;if(be==="ArrowUp"&&mt.length>0)return Ye("ArrowUp"),!0;if((be==="Enter"||be==="Tab")&&Rt)return Gt(Rt),!0}let ct=be==="Enter"?eD({isMobileViewport:Z,shiftKey:Be.shiftKey,modifierKey:Be.metaKey||Be.ctrlKey,isDraftThread:N}):null;return ct?(O(void 0,ct),!0):!1};return Bo(n,()=>({readSnapshot:It,readDraftPrompt:()=>ee,applyPromptReplacement:Ve,syncCursor:(be,Be)=>{se(be),nt(Be)},resetCursorState:be=>{let Be=be?.prompt??s.current,lt=Zo(Be,be?.cursor??0);Pt(null),se(lt),nt(be?.detectTrigger?go(Be,Mo(Be,lt)):null)}}),[Ve,ee,s,It,se,Pt,nt]),w(he,{children:[B&&!it&&!_&&c(tS,{anchor:l,children:c(vF,{entries:ue,onRestore:U,onDelete:oe,onClose:Q})}),it&&!_&&c(tS,{anchor:l,children:c(pF,{items:Ze,resolvedTheme:d,isLoading:Ct,triggerKind:tn,activeItemId:Zt?.id??null,onHighlightedItemChange:de,onSelect:Gt})}),R?c(md,{editorRef:i,documentKey:a,value:Ot,cursor:te,terminalContexts:L?S:IF,skills:f?.skills??TF,...E?{className:E}:{},onRemoveTerminalContext:Lt,onChange:bt,onCommandKeyDown:jt,onPaste:K,placeholder:D,disabled:H}):null]})});function EF({message:e}){return e?c("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive-foreground sm:px-4","data-chat-composer-validation":"prompt-length",children:e}):null}function AF(e){let{t}=le(),{message:n,pluginBlockMessage:o,agentNotChosen:r,agentUnavailable:a,agentUnavailableNoChoice:s,modelSendBlock:i,selectedModelStatus:l,onChooseModel:d}=e;return w(he,{children:[c(EF,{message:n}),o===null?null:c("p",{role:"status",className:"px-3 pb-2 text-xs text-muted-foreground sm:px-4","data-chat-composer-plugin-blocked":"true",children:o}),r?c("p",{role:"status",className:"px-3 pb-2 text-xs text-muted-foreground sm:px-4","data-chat-composer-agent-not-chosen":"true",children:t("composer.agentNotChosen")}):null,a?c("p",{role:"status",className:"px-3 pb-2 text-xs text-warning sm:px-4","data-chat-composer-agent-unavailable":"true",children:t(s?"composer.agentUnavailableNoChoice":"composer.agentUnavailable")}):null,i===null?null:w("p",{role:"status",className:"flex flex-wrap items-center gap-2 px-3 pb-2 text-xs text-muted-foreground sm:px-4","data-chat-composer-model-blocked":l,children:[t(i.blockKey),i.canChooseModel?c(re,{type:"button",size:"sm",variant:"ghost",className:"h-6 px-2 text-xs","data-chat-composer-choose-model":"true",onClick:()=>{d()},children:t("modelPicker.chooseModel")}):null]})]})}var M9={fetch:"worktreeSetup.step.fetch",checkout:"worktreeSetup.step.checkout",submodules:"worktreeSetup.step.submodules","setup-script":"worktreeSetup.step.setupScript",agent:"worktreeSetup.step.agent"};function N9(e){switch(e.state){case"done":return c(Wn,{"aria-hidden":!0,className:"size-3 shrink-0 text-success"});case"running":return c(nl,{"aria-hidden":!0,className:"size-3 shrink-0"});case"failed":return c(Jt,{"aria-hidden":!0,className:"size-3 shrink-0 text-destructive-foreground"});case"skipped":return c(Fs,{"aria-hidden":!0,className:"size-3 shrink-0 text-muted-foreground/60"});default:return c("span",{"aria-hidden":!0,className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/30"})}}function MF(e){let{t}=le(),{progress:n}=e;return w("div",{role:"status",className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-3 pb-2 text-xs text-muted-foreground sm:px-4","data-chat-composer-worktree-setup":"true",children:[c("ol",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:n.steps.map(o=>w("li",{className:G("flex items-center gap-1",o.state==="running"&&"text-foreground",o.state==="skipped"&&"text-muted-foreground/60",o.state==="failed"&&"text-destructive-foreground"),"data-step":o.id,"data-state":o.state,children:[c(N9,{state:o.state}),c("span",{children:t(M9[o.id])})]},o.id))}),n.cancellable?c(re,{type:"button",size:"xs",variant:"ghost",className:"ml-auto",onClick:n.cancel,"data-chat-composer-worktree-setup-cancel":"true",children:t("worktreeSetup.cancel")}):null]})}var _9=[];function NF(e){let{t}=le(),{props:n,model:o,status:r,submit:a,badges:s,traits:i,composerDraft:l}=e,d=e.pendingUserInputs.length>0,u=$(()=>e.composerImages.filter(y=>Fr(y)==="image"),[e.composerImages]),f=$(()=>new Set(e.nonPersistedComposerImageIds),[e.nonPersistedComposerImageIds]),p=e.isMobileViewport&&!e.isComposerCollapsedMobile&&e.pendingPrimaryAction!==null,m=r.phase==="running"||r.isSendBusy||o.isSendDisabled||o.noProviderAvailable||r.projectSelectionRequired||r.environmentUnavailable!==null||!l.hasSendableContent,h=!e.isComposerCollapsedMobile&&!e.isComposerApprovalState,g=SO({machineUnavailable:r.environmentUnavailable!==null,sessionStarted:r.activeThread?.session!=null,sessionDisconnected:r.phase==="disconnected"}),v=wO(g),C=IO({t,tailPlaceholderKey:v,isComposerApprovalState:e.isComposerApprovalState,approvalDetail:e.approvalDetail,activePendingProgress:e.activePendingProgress!==null,showPlanFollowUpPrompt:e.showPlanFollowUpPrompt,projectSelectionRequired:r.projectSelectionRequired,noProviderAvailable:o.noProviderAvailable});return c("div",{"data-chat-composer-main-surface":"true",className:"group relative z-10 rounded-[22px] p-px transition-colors duration-200",children:w("div",{ref:e.surfaceRef,"data-chat-composer-surface":"true","data-chat-composer-mobile-collapsed":e.isComposerCollapsedMobile?"true":"false",className:G("rounded-[20px] transition-[background-color] duration-200",e.isDragOverComposer?"bg-accent/45 ring-1 ring-primary/70":null,r.projectSelectionRequired?"opacity-75":null),children:[n.firstRow?c("div",{className:"@container/composer-first-row flex select-none items-center gap-2 px-3 pt-2 sm:px-4","data-conversation-card-first-row":!0,"data-chat-composer-collapsed-controls":"true",children:n.firstRow}):null,c(vO,{decisionOccupiesComposer:e.isComposerApprovalState}),e.showCollapsedMobilePromptRow?c(uF,{api:n.api,composerDraftTarget:n.composerDraftTarget,pendingCustomAnswer:e.activePendingProgress?e.activePendingProgress.customAnswer:null,noProviderAvailable:o.noProviderAvailable,onExpand:e.expandMobileComposer,inlineTasksBadge:s.inlineTasksBadge,inlineStashBadge:s.inlineStashBadge,submitDisabled:m,submitLabel:t("composer.sendMessage"),onSubmit:()=>a.submitComposerOrShellCommand()}):null,c(D9,{input:e,pendingUserInputs:d,showMobilePendingAnswerActions:p,composerPreviewableImages:u,nonPersistedComposerImageIdSet:f,composerPlaceholder:C}),c(AF,{message:e.providerInputSubmissionError??a.composerSubmissionError,pluginBlockMessage:o.pluginBlockMessage,agentNotChosen:r.agentNotChosen,agentUnavailable:o.agentUnavailable,agentUnavailableNoChoice:o.agentUnavailableNoChoice,modelSendBlock:o.modelSendBlock,selectedModelStatus:o.selectedModelStatus,onChooseModel:e.openModelPicker}),r.worktreeSetup==null?null:c(MF,{progress:r.worktreeSetup}),h?c(cF,{isComposerFooterCompact:e.isComposerFooterCompact,isComposerPrimaryActionsCompact:e.isComposerPrimaryActionsCompact,isMobileViewport:e.isMobileViewport,showMobilePendingAnswerActions:p,hasPendingUserInputs:d,projectSelectionRequired:r.projectSelectionRequired,noProviderAvailable:o.noProviderAvailable,composerAttachmentInputRef:e.composerAttachmentInputRef,onComposerAttachmentInputChange:e.onComposerAttachmentInputChange,slots:n.slots,selectedInstanceId:o.selectedInstanceId,unavailableAgentInstanceId:r.unavailableAgentInstanceId,agentNotChosen:r.agentNotChosen,agentUnavailable:o.agentUnavailable,providerInstanceEntries:o.providerInstanceEntries,lockedProvider:r.lockedProvider,lockedContinuationGroupKey:o.lockedContinuationGroupKey,onAgentInstanceChange:o.onAgentInstanceChange,selectedModelForPickerWithCustomFallback:o.selectedModelForPickerWithCustomFallback,selectedModelStatus:o.selectedModelStatus,keybindings:n.keybindings,modelOptionsByInstance:o.modelOptionsByInstance,terminalOpen:n.terminalOpen,isComposerModelPickerOpen:e.isComposerModelPickerOpen,setIsComposerModelPickerOpen:e.setIsComposerModelPickerOpen,getModelDisabledReason:n.getModelDisabledReason,getModelContinuationLabel:n.getModelContinuationLabel,onContinueInModel:n.onContinueInModel,onProviderModelSelect:n.onProviderModelSelect,canSelectPluginAction:o.canSelectPluginAction,pluginOptions:o.pluginOptions,selectedPluginAction:o.selectedPluginAction,onSelectPluginAction:n.onSelectPluginAction,onManagePlugins:n.onManagePlugins,isPluginComposer:o.isPluginComposer,environmentId:n.environmentId,routeKind:n.routeKind,draftId:n.draftId,activeThread:r.activeThread,interactionMode:r.interactionMode,runtimeMode:r.runtimeMode,composerProviderControls:o.composerProviderControls,composerNativeMode:o.composerNativeMode,canSwitchNativeMode:o.canSwitchNativeMode,providerTraitsMenuContent:i.providerTraitsMenuContent,providerTraitsPicker:i.providerTraitsPicker,toggleInteractionMode:n.toggleInteractionMode,handleRuntimeModeChange:n.handleRuntimeModeChange,handleComposerNativeModeChange:o.handleComposerNativeModeChange,inlineTasksBadge:s.inlineTasksBadge,inlineStashBadge:s.inlineStashBadge,activeThreadModelDisplayName:o.activeThreadModelDisplayName,pendingPrimaryAction:e.pendingPrimaryAction,phase:r.phase,showPlanFollowUpPrompt:e.showPlanFollowUpPrompt,composerDraft:l,isSendBusy:r.isSendBusy,sendDisabledReason:o.sendDisabledReason,environmentUnavailable:r.environmentUnavailable,isPreparingWorktree:r.isPreparingWorktree,previousUserInputQuestion:e.actions.previousUserInputQuestion,handleInterruptPrimaryAction:e.actions.handleInterruptPrimaryAction,interruptArmed:r.interruptArmed,stopping:r.stopping,handleImplementPlanInNewThreadPrimaryAction:e.actions.handleImplementPlanInNewThreadPrimaryAction,shellCommandMode:a.shellCommandMode,shellCommandUnavailableReason:a.hostShellCommand?.unavailableReason??null,compactDisabled:e.compactDisabled,resolvedCompactDisabledReason:o.resolvedCompactDisabledReason,compactThreadContext:e.compactThreadContext}):null]})})}function D9(e){let{t}=le(),{input:n,pendingUserInputs:o,showMobilePendingAnswerActions:r}=e,{props:a,model:s,status:i,submit:l,stash:d,composerDraft:u}=n,f=n.activePendingProgress?.activeQuestion?.allowFreeform===!1;return w("div",{ref:n.setComposerMenuAnchor,className:G("relative px-3 pb-2 sm:px-4","pt-3.5 sm:pt-4",n.isComposerApprovalState&&"pb-3 sm:pb-4",n.isComposerCollapsedMobile&&"hidden"),children:[c(bO,{api:a.api,environmentId:a.environmentId,composerDraftTarget:a.composerDraftTarget,isComposerCollapsedMobile:n.isComposerCollapsedMobile,isComposerApprovalState:n.isComposerApprovalState,hasPendingUserInputs:o,supportsAttachmentUploads:a.supportsAttachmentUploads,uploadsByImageId:n.uploadsByImageId,composerImages:n.composerImages,composerPreviewableImages:e.composerPreviewableImages,composerPreviewAnnotations:u.previewAnnotations,composerReviewComments:u.reviewComments,composerElementContexts:u.elementContexts,nonPersistedComposerImageIdSet:e.nonPersistedComposerImageIdSet,removeComposerDraftPreviewAnnotation:n.removeComposerDraftPreviewAnnotation,removeComposerDraftReviewComment:n.removeComposerDraftReviewComment,removeComposerDraftElementContext:n.removeComposerDraftElementContext,removeComposerImage:n.removeComposerImage,onExpandImage:a.onExpandImage}),c(O9,{mode:l.shellCommandMode,label:t("composer.shellCommand.mode"),hint:l.hostShellCommand?.unavailableReason??t("composer.shellCommand.hint")}),w("div",{className:"relative",children:[c(RF,{handleRef:n.promptInputRef,api:a.api,composerDraftTarget:a.composerDraftTarget,composerDocumentKey:n.composerDocumentKey,promptRef:a.promptRef,editorRef:n.composerEditorRef,menuAnchor:n.composerMenuAnchor,resolvedTheme:a.resolvedTheme,selectedProvider:s.selectedProvider,selectedProviderStatus:s.selectedProviderStatus,planModeUiEnabled:s.planModeUiEnabled,showSkillsInSlashMenu:a.settings.showSkillsInSlashMenu,recentSlashCommandIds:a.recentSlashCommandIds??_9,environmentId:a.environmentId,gitCwd:a.gitCwd,onSlashCommandUsed:a.onSlashCommandUsed,onOpenModelPicker:n.openModelPicker,onInteractionModeChange:n.switchInteractionMode,onToggleInteractionMode:a.toggleInteractionMode,activePendingProgress:n.activePendingProgress,activePendingRequestId:n.pendingUserInputs[0]?.requestId??null,hasPendingUserInputs:o,changeUserInputCustomAnswer:n.changeUserInputCustomAnswer,terminalContexts:u.terminalContexts,showTerminalContexts:!n.isComposerApprovalState&&!o,showEditor:!f,isApprovalState:n.isComposerApprovalState,editorClassName:r?"max-sm:pb-11":void 0,placeholder:e.composerPlaceholder,disabled:n.isComposerApprovalState||i.projectSelectionRequired,onPaste:n.handleComposerPaste,onSubmit:n.handleComposerSubmit,isMobileViewport:n.isMobileViewport,isDraftRoute:a.routeKind==="draft",stashMenuOpen:n.isStashMenuOpen,stashEntries:d.stashQueue,onRestoreStashEntry:d.restoreStashEntry,onDeleteStashEntry:d.deleteStashEntry,onCloseStashMenu:d.closeStashMenu,onPromptEdited:n.onPromptEdited,onUnclaimedEscape:n.handleUnclaimedEscape}),r?c(F9,{input:n}):null]})]})}function O9(e){return e.mode?w("div",{"data-composer-shell-command-mode":"true",className:"flex min-w-0 items-center gap-1.5 px-1 pb-1 text-xs",children:[c(To,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-primary"}),c("span",{className:"shrink-0 font-medium text-primary",children:e.label}),c("span",{className:"min-w-0 truncate text-muted-foreground",children:e.hint})]}):null}function F9(e){let{input:t}=e,{model:n,status:o,badges:r}=t;return w("div",{"data-chat-composer-mobile-pending-actions":"true",className:"absolute bottom-0 right-0 flex items-center justify-end gap-1",children:[r.inlineTasksBadge,r.inlineStashBadge,c(bd,{compact:!0,pendingAction:t.pendingPrimaryAction,isRunning:!1,showPlanFollowUpPrompt:!1,promptHasText:!1,isSendBusy:o.isSendBusy,sendDisabledReason:n.sendDisabledReason,isEnvironmentUnavailable:o.environmentUnavailable!==null||n.noProviderAvailable||o.projectSelectionRequired,isPreparingWorktree:!1,hasSendableContent:!1,preserveComposerFocusOnPointerDown:!0,onPreviousPendingQuestion:t.actions.previousUserInputQuestion,onInterrupt:t.actions.handleInterruptPrimaryAction,interruptArmed:o.interruptArmed,stopping:o.stopping,onImplementPlanInNewThread:t.actions.handleImplementPlanInNewThreadPrimaryAction})]})}function _F(e){let{formRef:t,onSubmit:n,onFocusCapture:o,onBlurCapture:r,dragHandlers:a,onDragLeaveCapture:s,badges:i,stashQueueLength:l,isStashMenuOpen:d,stashPulse:u,toggleStashMenu:f,drawers:p,children:m}=e;return w("form",{ref:t,onSubmit:n,onFocusCapture:o,onBlurCapture:r,onDragEnterCapture:a.onDragEnter,onDragOverCapture:a.onDragOver,onDragLeaveCapture:s,onDropCapture:a.onDrop,className:G("mx-auto w-full min-w-0 max-w-3xl",i.hasShoulderTab&&"pt-7"),"data-chat-composer-form":"true",children:[p,w("div",{className:"relative",children:[i.showShoulderTabs&&i.visibleTasksProgress&&i.visibleTaskSteps?c(oh,{expanded:!1,hasTrailingShoulder:l>0,onDismiss:i.dismissTasks,onToggle:i.toggleTasksDrawer,progress:i.visibleTasksProgress,steps:i.visibleTaskSteps}):null,i.showShoulderTabs?c(nh,{count:l,menuOpen:d,pulseKey:u.key,pulsing:u.active,onToggleMenu:f}):null,m]})]})}function DF(e){let{t}=le(),n=e.activePendingProgress?.activeQuestion?.multiSelect??!1;return c("div",{className:"px-3 pb-3 sm:px-4",children:w("div",{"data-chat-composer-mobile-pending-compact":"true",className:G("flex min-w-0 items-center gap-2 rounded-lg border border-border/55 bg-background/55 p-1.5 pl-3 transition-colors hover:bg-background/90",!n&&"p-0"),children:[e.isPendingUserInputChoiceOnly?null:c("button",{type:"button",className:G("min-w-0 flex-1 truncate bg-transparent py-1.5 text-left text-sm",e.activePendingProgress?.customAnswer?"text-foreground":"text-placeholder",!n&&"px-3 py-2"),onPointerDown:o=>o.preventDefault(),onClick:e.expandMobileComposer,"aria-label":t("composer.writeCustomAnswer"),children:e.activePendingProgress?.customAnswer||t("composer.writeCustomAnswer")}),e.inlineTasksBadge,e.inlineStashBadge,n?c(bd,{compact:!0,pendingAction:e.pendingPrimaryAction,isRunning:!1,showPlanFollowUpPrompt:!1,promptHasText:!1,isSendBusy:e.isSendBusy,sendDisabledReason:e.sendDisabledReason,isEnvironmentUnavailable:e.isEnvironmentUnavailable,isPreparingWorktree:!1,hasSendableContent:!1,preserveComposerFocusOnPointerDown:!0,onPreviousPendingQuestion:e.onPreviousActivePendingUserInputQuestion,onInterrupt:e.handleInterruptPrimaryAction,onImplementPlanInNewThread:e.handleImplementPlanInNewThreadPrimaryAction}):null]})})}function OF(e){let t=e.match(/^\s{0,3}#{1,6}\s+(.+)$/m)?.[1]?.trim();return t&&t.length>0?t:null}X();var B9=2e3,z9="min-h-8 max-w-full py-1.5 font-normal whitespace-normal text-start",H9=e=>[{decision:"cancel",label:e("composer.cancel")},{decision:"decline",label:e("composer.decline")},{decision:"acceptForSession",label:e("composer.alwaysAllowSession")},{decision:"accept",label:e("composer.approve")}];function U9(e,t){let n=[];return t<9&&n.push(String(t+1)),e==="accept"&&n.push("Enter"),e==="cancel"&&n.push("Escape"),n.length>0?n.join(" "):void 0}var FF=fe(function({requestId:t,isResponding:n,options:o,keybindings:r,declineReasonRelay:a,onRespondToApproval:s}){let{t:i}=le(),l=o??H9(i),d=Nt(),u=a==="native"||a==="queued",[f,p]=j(""),m=M([]);z(()=>{p("")},[t]);let h=A(v=>{let C=v==="decline"?f.trim():"";s(t,v,C.length>0?C:void 0)},[f,s,t]),g=A(v=>{let C=m.current.filter(b=>b!==null);if(C.length===0)return;let y=C.findIndex(b=>b===document.activeElement),x=y===-1?v===1?0:C.length-1:(y+v+C.length)%C.length;C[x]?.focus()},[]);return d.pane.useKeydown(v=>{if(n||d.terminalFocus.getOwner()!==null||v.isComposing||v.keyCode===229)return;let C=ts(v.target);if(r&&(!C||v.metaKey||v.ctrlKey||v.altKey)){let b=d.keybindings.approvalDecisionFromCommand(d.keybindings.resolveShortcutCommand(v,r));if(b!==null&&l.some(T=>T.decision===b)){v.preventDefault(),h(b);return}}if(C)return;let y=IP(v,l);if(y===null)return;if(v.preventDefault(),y.type==="move"){g(y.delta);return}let x=l[y.index];x&&h(x.decision)},{target:"document"}),c(he,{children:l.map((v,C)=>{let y=C<9?C+1:null,x=w(re,{ref:b=>{m.current[C]=b},size:"xs",variant:v.decision==="accept"?"default":"outline",style:{height:"auto"},"data-approval-decision":v.decision,"aria-keyshortcuts":U9(v.decision,C),className:`${z9}${v.decision==="decline"?" text-destructive-foreground [:hover,[data-pressed]]:text-destructive-foreground":""}`,disabled:n,onClick:()=>h(v.decision),children:[c("span",{className:"min-w-0 break-words",children:v.label}),y===null?null:c(rl,{className:"h-3.5 min-w-3.5 rounded-[3px] bg-transparent px-0 text-[10px] tabular-nums opacity-70",children:y})]},v.decision);return v.decision!=="decline"||!u?x:w(Yr,{children:[c(Ar,{type:"text",value:f,disabled:n,maxLength:B9,placeholder:i(a==="queued"?"approval.declineReasonQueuedPlaceholder":"approval.declineReasonPlaceholder"),"aria-label":i("approval.declineReasonLabel"),"data-approval-decline-reason":"true",className:"h-8 min-w-24 max-w-56 flex-1",onChange:b=>p(b.target.value),onKeyDown:b=>{if(b.key==="Enter"){b.preventDefault(),h("decline");return}b.key==="Escape"&&(b.preventDefault(),f.length>0?p(""):b.currentTarget.blur())}}),x]},v.decision)})})});X();var $9=["command","cmd"],K9=["file_path","filePath","path","notebook_path","notebookPath"],V9=["url"],q9=["query","q"],W9=["name","skill","skill_name","skillName"],BF=["toolName","tool_name"],zF=["description"],G9=[],j9=[];function Aa(e,t,n){for(let o of t){let a=e.find(s=>s.name===o)?.value.trim();if(!(a===void 0||a.length===0))return n.add(o),a}return null}function Q9(e){let t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),n=t>=0?e.slice(t+1):e;return n.length>0?n:e}function X9(e){let t=e[0];return t===void 0?null:e.every(n=>n.path===t.path)?t.path:null}function UF(e){let t=e.args??G9,n=e.fileChanges??j9,o=new Set,r=e.detail?.trim()??"",a=r.length>0?{shape:"text",text:r}:{shape:"none"},s=null,i=a,l=null;switch(e.requestKind){case"command":{let d=Aa(t,$9,o);d!==null&&(i={shape:"command",command:d});break}case"file-read":case"file-change":{let d=Aa(t,K9,o)??X9(n);d!==null&&(s=Q9(d),i=n.some(u=>u.path===d)?{shape:"none"}:{shape:"path",path:d});break}case"web-fetch":{let d=Aa(t,V9,o);d!==null&&(i={shape:"url",url:d});break}case"web-search":{let d=Aa(t,q9,o);d!==null&&(i={shape:"query",query:d});break}case"skill":{s=Aa(t,W9,o)??Aa(t,BF,o),l=Aa(t,zF,o),t.length>0&&(i={shape:"none"});break}case"mcp-tool":case"tool":{s=Aa(t,BF,o),l=Aa(t,zF,o),t.length>0&&(i={shape:"none"});break}case"mcp-elicitation":{s=e.appName?.trim()||null;break}}return{kind:e.requestKind,subject:s,body:i,description:l,args:t.filter(d=>!o.has(d.name)),fileChanges:n}}var Y9={"file-read":"approval.title.fileRead","file-change":"approval.title.fileChange",skill:"approval.title.skill","mcp-tool":"approval.title.tool",tool:"approval.title.tool","mcp-elicitation":"approval.title.appAccess"},J9={command:"approval.title.command","file-read":"approval.title.fileReadGeneric","file-change":"approval.title.fileChangeGeneric","web-fetch":"approval.title.webFetch","web-search":"approval.title.webSearch",skill:"approval.title.skillGeneric","mcp-tool":"approval.title.toolGeneric",tool:"approval.title.toolGeneric","mcp-elicitation":"approval.title.appAccessGeneric"},Z9={command:"approval.commandLabel","file-read":"approval.fileReadLabel","file-change":"approval.fileChangeLabel","web-fetch":"approval.webFetchLabel","web-search":"approval.webSearchLabel",skill:"approval.skillLabel","mcp-tool":"approval.mcpToolLabel",tool:"approval.toolLabel","mcp-elicitation":"approval.appAccessLabel"},eX={command:"approval.commandDetailLabel",path:"approval.body.pathLabel",url:"approval.body.urlLabel",query:"approval.body.queryLabel",text:"approval.body.detailLabel"};function $F(e,t){let n=e.subject!==null?Y9[e.kind]:void 0;return n!==void 0?t(n,{name:e.subject}):t(J9[e.kind])}function KF(e,t){return t(Z9[e])}function VF(e,t){return t(eX[e])}function qF(e){let t=e.content;if(t===void 0)return null;if(t.kind==="unified")return t.diff.length>0?t.diff:null;let n=HF(t.oldText??""),o=HF(t.newText);if(n.length===0&&o.length===0)return null;let r=`--- a/${e.path}