codex-mobile-re 0.1.115 → 0.1.117

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.
@@ -0,0 +1,39 @@
1
+ import{c as P,r as U,g as ko,o as vt,a as Dt,b as Ln,d as Je,e as le,f as c,h as se,i as f,w as Ue,j as m,t as w,n as te,k as S,T as Vn,_ as oe,u as d,F as W,l as K,m as ye,p as Q,I as zn,q as yo,s as We,v as me,x as $e,y as Xe,z as Kn,A as wo,B as Pe,C as bo,D as Gn,E as Ht,G as Co,H as $o,J as ut,K as xo,L as To,M as _o,N as Io}from"./index-Q0GrjPAB.js";import{s as Pt}from"./sanitizeHtml-Bd3No2dT.js";function Lo(e){if(!e||/[\r\n]/u.test(e)||e.endsWith("/")||e.endsWith("\\")||/^[A-Za-z][A-Za-z0-9+.-]*:\/\//u.test(e))return!1;const t=e.startsWith("/"),n=/^[A-Za-z]:[\\/]/u.test(e),o=e.startsWith("./")||e.startsWith("../")||e.startsWith("~/");return t||n||o||/^[A-Za-z0-9._@() -]+\.[A-Za-z0-9]{1,12}$/u.test(e)?!0:/^[A-Za-z0-9._@() -]+(?:[\\/][A-Za-z0-9._@() -]+)+$/u.test(e)}function ht(e){return e.replace(/\\/gu,"/").split("/").filter(Boolean).pop()||e}function Ne(e){return e.replace(/\\/gu,"/")}function Zn(e){if(!e.startsWith("file://"))return e;let t=e.replace(/^file:\/\//u,"");try{t=decodeURIComponent(t)}catch{}return/^\/[A-Za-z]:\//u.test(t)&&(t=t.slice(1)),t}function Mo(e){const t=Ne(e),n=t.match(/^\/Users\/([^/]+)/u);if(n)return`/Users/${n[1]}`;const o=t.match(/^\/home\/([^/]+)/u);return o?`/home/${o[1]}`:""}function je(e){const t=Ne(e);if(!t)return t;let n="",o=t;const s=o.match(/^([A-Za-z]:)(\/.*)?$/u);s?(n=`${s[1]}/`,o=(s[2]??"").replace(/^\/+/u,"")):o.startsWith("/")&&(n="/",o=o.slice(1));const a=o.split("/").filter(Boolean),i=[];for(const l of a)if(l!=="."){if(l===".."){i.length>0&&i.pop();continue}i.push(l)}const r=i.join("/");return n?`${n}${r}`.replace(/\/+$/u,"")||n:r||t}function Jn(e,t){const n=Ne(Zn(e.trim()));if(!n)return"";if(n.startsWith("/")||/^[A-Za-z]:\//u.test(n))return je(n);if(n.startsWith("~/")){const a=Mo(t);if(a)return je(`${a}/${n.slice(2)}`)}const s=Ne(t.trim());return je(s?`${s.replace(/\/+$/u,"")}/${n}`:n)}function mt(e){let t=e,n="",o="";const s={"(":")","[":"]","{":"}","<":">",'"':'"',"'":"'","`":"`","“":"”","‘":"’"};for(;t.length>0;){const a=t[0],i=Object.prototype.hasOwnProperty.call(s,a)?s[a]:"";if(!i||!t.endsWith(i))break;n+=a,o+=i,t=t.slice(1,-1)}return{core:t,leading:n,trailing:o}}function Ye(e){if(!e)return null;let t=e.trim();t=mt(t).core.trim();let o=null;const s=t.match(/^(.*)#L(\d+)(?:C\d+)?$/u);if(s)t=s[1],o=Number(s[2]);else{const a=t.match(/^(.*):(\d+)(?::\d+)?$/u);a&&(t=a[1],o=Number(a[2]))}return t=Zn(t),Lo(t)?{path:t,line:o}:null}function Mn(e,t,n){let o=0,s=t-1;for(;s>=n&&e[s]==="*";)o+=1,s-=1;return o}function Ao(e,t){let n=0,o=t;for(;o<e.length&&e[o]==="*";)n+=1,o+=1;return n}function Xn(e,t,n,o,s){const a=Mn(e,t,o);return a<2?null:Ao(e,n)>=a?{segmentStart:t-a,segmentEnd:n+a,tokenEndTrim:0}:Mn(s,s.length,0)>=a?{segmentStart:t-a,segmentEnd:n,tokenEndTrim:a}:null}function Wt(e){const t=e.trim();if(!t.startsWith("[")||!t.endsWith(")"))return null;const n=t.indexOf("]");if(n<=1||t[n+1]!=="(")return null;const o=t.slice(1,n).trim(),s=t.slice(n+2,-1).trim();if(o.includes(`
2
+ `)||s.includes(`
3
+ `))return null;const a=mt(o).core.trim()||o,i=mt(s).core.trim();return i?{label:a,target:i}:null}function gt(e){const t=e.trim().match(/^codex:\/\/threads\/([A-Za-z0-9-]+)$/u);if(!t)return null;if(typeof window>"u")return`/#/thread/${t[1]}`;const n=window.location.pathname.replace(/\/?$/u,"/");return`${window.location.origin}${n}#/thread/${t[1]}`}function Yn(e){const t=Math.min(6,Math.max(1,Math.trunc(e)));return`h${String(t)}`}function Qn(e){switch(Math.min(6,Math.max(1,Math.trunc(e)))){case 1:return"message-heading-h1";case 2:return"message-heading-h2";case 3:return"message-heading-h3";case 4:return"message-heading-h4";case 5:return"message-heading-h5";default:return"message-heading-h6"}}const es={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",sh:"bash",shell:"bash",zsh:"bash",yml:"yaml",md:"markdown","c++":"cpp","c#":"csharp",ps1:"powershell"};function ce(e){return`${e.path}\0${e.movedToPath??""}`}function So(e,t){return e?!t||e===t?e:`${e}
4
+ ${t}`.trim():t}function Fo(e,t){const n=e.operation==="add"||t.operation==="add"?"add":e.operation==="delete"||t.operation==="delete"?"delete":"update";return{path:t.path||e.path,operation:n,movedToPath:t.movedToPath??e.movedToPath??null,diff:So(e.diff,t.diff),addedLineCount:e.addedLineCount+t.addedLineCount,removedLineCount:e.removedLineCount+t.removedLineCount}}function Po(e,t){const n=e.operation==="add"?0:e.operation==="update"?1:2,o=t.operation==="add"?0:t.operation==="update"?1:2;if(n!==o)return n-o;const s=`${e.path}\0${e.movedToPath??""}`,a=`${t.path}\0${t.movedToPath??""}`;return s.localeCompare(a)}function Et(e){const t=new Map;for(const n of e){const o=`${n.path}\0${n.movedToPath??""}`,s=t.get(o);t.set(o,s?Fo(s,n):{...n})}return Array.from(t.values()).sort(Po)}function Zt(e,t){return e.operation==="update"&&e.movedToPath?e.addedLineCount>0||e.removedLineCount>0?t("Moved + edited"):t("Moved"):e.operation==="add"?t("Added"):e.operation==="delete"?t("Deleted"):t("Edited")}function Eo(e){return e.operation==="update"&&e.movedToPath?"→":e.operation==="add"?"+":e.operation==="delete"?"−":"M"}function jt(e){return e.operation==="update"&&e.movedToPath?"move":e.operation}function Be(e){const t=[];return e.addedLineCount>0&&t.push(`+${e.addedLineCount}`),e.removedLineCount>0&&t.push(`-${e.removedLineCount}`),t.join(" ")}function ts(e,t,n=""){const o=[];return e>0&&o.push({tone:"add",label:`+${e}`}),t>0&&o.push({tone:"remove",label:`-${t}`}),o.length>0?o:n?[{tone:"neutral",label:n}]:[]}function Bo(e){return ts(e.addedLineCount,e.removedLineCount)}function ns(e,t){return e===1?`1 ${t("file changed")}`:`${e} ${t("files changed")}`}function Ro(e,t){if(!e||e.changes.length===0)return"";let n=0,o=0,s=0,a=0;for(const r of e.changes){if(r.operation==="add"){n+=1;continue}if(r.operation==="delete"){o+=1;continue}if(r.movedToPath){a+=1;continue}s+=1}const i=[];return s>0&&i.push(`${s} ${t("edited")}`),n>0&&i.push(`${n} ${t("added")}`),o>0&&i.push(`${o} ${t("deleted")}`),a>0&&i.push(`${a} ${t("moved")}`),i.join(", ")}function Oo(e,t){if(!e||e.changes.length===0)return t("Modified files");const n=ns(e.changes.length,t),o=Ro(e,t);return o?`${n} · ${o}`:n}function Do(e){if(!e||e.changes.length===0)return[];const t=e.changes.reduce((s,a)=>s+a.addedLineCount,0),n=e.changes.reduce((s,a)=>s+a.removedLineCount,0),o=e.changes.some(s=>s.movedToPath)?"Moved":"Ready";return ts(t,n,o)}function Ve(e,t){const n=Jn(e,t),o=je(Ne(t.trim())),s=je(Ne(n));return o&&s.startsWith(`${o}/`)?s.slice(o.length+1):e}function Ho(e,t,n){if(!e||e.changes.length===0)return"";const o=e.changes.map(s=>{const a=Ve(s.path,t),i=s.movedToPath?` -> ${Ve(s.movedToPath,t)}`:"",r=Be(s);return`- ${Zt(s,n)}: ${a}${i}${r?` (${r})`:""}`});return`${n("Modified files")}:
5
+ ${o.join(`
6
+ `)}`.trim()}function Wo(e){var o;const n=((o=(e.movedToPath||e.path).split(".").pop())==null?void 0:o.toLowerCase())??"";return es[n]??n??""}function jo(e){return e.operation==="update"&&/^diff --git |^@@ |^--- |^\+\+\+ |^[ +-]|^\*\*\* (Move to:|End of File)/mu.test(e.diff)}function qo(e){const t=e.diff.replace(/\r\n/g,`
7
+ `),n=t.length>0?t.split(`
8
+ `):[];return n.length>0&&n[n.length-1]===""&&n.pop(),n.map((o,s)=>({key:`${ce(e)}:synthetic:${s}`,kind:e.operation==="delete"?"remove":"add",oldLine:e.operation==="delete"?s+1:null,newLine:e.operation==="delete"?null:s+1,text:o}))}function Uo(e){const t=e.diff.replace(/\r\n/g,`
9
+ `),n=t.length>0?t.split(`
10
+ `):[];n.length>0&&n[n.length-1]===""&&n.pop();const o=[];let s=0,a=0;for(const[i,r]of n.entries()){const l=r.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/u);if(l){s=Number(l[1]),a=Number(l[2]),o.push({key:`${ce(e)}:hunk:${i}`,kind:"hunk",oldLine:null,newLine:null,text:r});continue}if(r.startsWith("+")&&!r.startsWith("+++")){o.push({key:`${ce(e)}:add:${i}`,kind:"add",oldLine:null,newLine:a,text:r.slice(1)}),a+=1;continue}if(r.startsWith("-")&&!r.startsWith("---")){o.push({key:`${ce(e)}:remove:${i}`,kind:"remove",oldLine:s,newLine:null,text:r.slice(1)}),s+=1;continue}if(r.startsWith(" ")){o.push({key:`${ce(e)}:context:${i}`,kind:"context",oldLine:s,newLine:a,text:r.slice(1)}),s+=1,a+=1;continue}o.push({key:`${ce(e)}:meta:${i}`,kind:"meta",oldLine:null,newLine:null,text:r})}return o}function No(e){return!e||!e.diff.trim()?[]:jo(e)?Uo(e):qo(e)}function Vo(e){return!!(e!=null&&e.diff.trim())}function zo(e){return e.kind==="add"?"+":e.kind==="remove"?"-":e.kind==="hunk"?"@@":""}function Ko(e,t){if(e.size===0)return e;const n=new Set;for(const o of e)t.has(o)&&n.add(o);return n.size===e.size?e:n}function Go(e){const{getMessages:t,getLiveTurnId:n,isFileChangeMessage:o,isCopyableAssistantMessage:s,isReasoningMessage:a,isPlanMessage:i,isFoldMember:r,getHiddenGroupedCommandIds:l,isMobile:h}=e,g=U(new Set),b=U(null),L=U(""),y=U(!1),I=P(()=>{var re,pe;const B=new Map,N=new Map,ue=new Map,ge=j=>!o(j)&&!a(j)&&!i(j)&&!l().has(j.id)&&!r(j);for(const j of t()){const ve=typeof j.turnIndex=="number"?`turn:${j.turnIndex}`:`message:${j.id}`;if(ge(j)&&B.set(ve,j.id),s(j)&&typeof j.turnIndex=="number"&&Array.isArray(j.fileChanges)&&j.fileChanges.length>0&&N.set(j.id,{changes:Et(j.fileChanges),sourceMessageIds:[],source:"assistant",turnId:j.turnId??""}),!o(j))continue;const _e=ue.get(ve);_e?_e.push(j):ue.set(ve,[j])}const ie={};for(const[j,ve]of ue.entries()){const _e=B.get(j);if(!_e)continue;const tt=((re=N.get(_e))==null?void 0:re.turnId)??"";ie[_e]={changes:Et(ve.flatMap(Ie=>Ie.fileChanges??[])),sourceMessageIds:ve.map(Ie=>Ie.id),source:"metadata",turnId:((pe=ve.find(Ie=>typeof Ie.turnId=="string"&&Ie.turnId.length>0))==null?void 0:pe.turnId)??tt}}for(const[j,ve]of N.entries())ie[j]||(ie[j]=ve);return ie}),k=P(()=>{var ge;const B=new Map,N=new Set;for(const ie of Object.values(I.value))for(const re of ie.sourceMessageIds)N.add(re);for(const ie of t()){if(!o(ie))continue;const re=typeof ie.turnIndex=="number"?`turn:${ie.turnIndex}`:`message:${ie.id}`,pe=B.get(re);pe?pe.push(ie):B.set(re,[ie])}const ue={};for(const[ie,re]of B.entries()){if(re.some(j=>N.has(j.id)))continue;const pe=re[re.length-1];pe&&(ue[pe.id]={changes:Et(re.flatMap(j=>j.fileChanges??[])),sourceMessageIds:re.map(j=>j.id),source:"metadata",turnId:pe.turnId??((ge=re.find(j=>typeof j.turnId=="string"&&j.turnId.length>0))==null?void 0:ge.turnId)??""})}return ue}),E=P(()=>{const B=new Set;for(const N of Object.values(I.value))for(const ue of N.sourceMessageIds)B.add(ue);for(const[N,ue]of Object.entries(k.value))for(const ge of ue.sourceMessageIds)ge!==N&&B.add(ge);return B}),x=P(()=>{var B;return((B=b.value)==null?void 0:B.changes)??[]}),C=P(()=>{const B=x.value;return B.length===0?null:B.find(N=>ce(N)===L.value)??B[0]}),A=P(()=>No(C.value));function _(B){const N=new Set(g.value);N.has(B.id)?N.delete(B.id):N.add(B.id),g.value=N}function R(B){return g.value.has(B.id)}function O(B,N){B&&(b.value=B,L.value=ce(N),y.value=!1)}function q(){b.value=null,L.value="",y.value=!1}function ee(){y.value=!y.value}function V(){y.value=!1}function fe(B){L.value=ce(B),h()&&(y.value=!1)}function Re(B){return I.value[B]??null}function ze(B){return g.value.has(B)}function $(B){const N=t().find(ue=>ue.id===B);N&&_(N)}function M(B){return Re(B.id)}function D(B){return k.value[B.id]??null}function G(B){if(!B)return!1;const N=n();return N?(B.turnId??"")!==N:!0}function ae(){const B=new Set([...Object.keys(I.value),...Object.keys(k.value)]);g.value=Ko(g.value,B)}return{anchoredFileChangeSummaryByAnchorId:I,standaloneFileChangeSummaryByMessageId:k,hiddenFileChangeMessageIds:E,isDiffViewerFileListOpen:y,diffViewerChanges:x,activeDiffViewerChange:C,activeDiffViewerLines:A,toggleFileChangeSummary:_,isFileChangeSummaryExpanded:R,openDiffViewer:O,closeDiffViewer:q,toggleDiffViewerFileList:ee,closeDiffViewerFileList:V,selectDiffViewerChange:fe,readAnchoredFileChangeSummaryById:Re,isFileChangeSummaryExpandedById:ze,toggleFileChangeSummaryById:$,readAnchoredFileChangeSummary:M,readStandaloneFileChangeSummary:D,isFileChangeSummaryVisible:G,pruneFileChangeSummaryIds:ae}}function Zo(e){const{getMessages:t,isCopyableAssistantMessage:n,isPlanMessage:o,planStepCopyMarker:s,buildFileChangeCopyText:a,getAnchoredFileChangeSummaries:i}=e,r=U("");let l=null;function h(A){var O;const _=Je(A);if(!_)return"";const R=[];return(O=_.explanation)!=null&&O.trim()&&R.push(_.explanation.trim()),_.steps.length>0&&R.push(_.steps.map(q=>`- ${s(q.status)} ${q.step}`.trim()).join(`
11
+ `)),R.join(`
12
+
13
+ `).trim()}function g(A){const _=[],R=A.text.trim()||h(A),O=o(A)&&R?`Plan
14
+ ${R}`:R;O&&_.push(O);const q=(A.fileAttachments??[]).map(V=>V.path.trim()).filter(V=>V.length>0);q.length>0&&_.push(`Files:
15
+ ${q.join(`
16
+ `)}`);const ee=(A.images??[]).map(V=>V.trim()).filter(V=>V.length>0);return ee.length>0&&_.push(`Images:
17
+ ${ee.join(`
18
+ `)}`),_.join(`
19
+
20
+ `).trim()}const b=P(()=>{var R;const A=new Map;for(const O of t()){if(!n(O))continue;const q=g(O);if(!q)continue;const ee=typeof O.turnIndex=="number"?`turn:${O.turnIndex}`:`message:${O.id}`,V=A.get(ee);if(V){V.anchorMessageId=O.id,V.parts.push(q);continue}A.set(ee,{anchorMessageId:O.id,parts:[q]})}const _={};for(const O of A.values()){const q=O.parts.join(`
21
+
22
+ `).trim();q&&(_[O.anchorMessageId]=q)}for(const[O,q]of Object.entries(i())){if(q.source!=="metadata")continue;const ee=a(q);if(!ee)continue;const V=(R=_[O])==null?void 0:R.trim();_[O]=V?`${V}
23
+
24
+ ${ee}`:ee}return _}),L=P(()=>{const A=new Map;for(const R of t()){if(!n(R)||typeof R.turnIndex!="number")continue;const O=`turn:${R.turnIndex}`,q=A.get(O);if(q){q.anchorMessageId=R.id,q.turnIndex=R.turnIndex;continue}A.set(O,{anchorMessageId:R.id,turnIndex:R.turnIndex})}const _={};for(const R of A.values())_[R.anchorMessageId]=R.turnIndex;return _});function y(A){return typeof b.value[A.id]=="string"}function I(A){return A.role==="user"&&g(A).length>0}function k(A){r.value=A,l&&clearTimeout(l),l=setTimeout(()=>{r.value===A&&(r.value=""),l=null},1800)}ko()&&vt(()=>{l&&(clearTimeout(l),l=null)});async function E(A){const _=t().find(q=>q.id===A);if(!_)return;const R=g(_);if(!R)return;let O=!1;try{await Dt(R),O=!0}catch{O=!1}O||(O=Ln(R)),O&&k(A)}function x(A){return typeof L.value[A.id]=="number"}async function C(A){const _=b.value[A]??"";if(!_)return;let R=!1;try{await Dt(_),R=!0}catch{R=!1}R||(R=Ln(_)),R&&k(A)}return{copiedResponseAnchorId:r,copyableResponseContentByAnchorId:b,forkableTurnIndexByAnchorId:L,showCopyResponseButton:y,isCopyableUserMessage:I,copyUserMessage:E,showForkResponseButton:x,copyResponse:C}}function Jo(e){const{getMessages:t,getLiveOverlay:n,isCommandMessage:o}=e,s=U(new Set),a=P(()=>{var A;const C=t();for(let _=C.length-1;_>=0;_-=1){const R=C[_];if(R.messageType==="commandExecution"&&((A=R.commandExecution)==null?void 0:A.status)==="inProgress")return R.id}return""}),i=P(()=>t().some(C=>C.role==="assistant"&&C.messageType==="agentMessage.live"&&C.text.trim().length>0)),r=P(()=>!!n()||a.value.length>0||i.value),l=P(()=>{const C=t(),A={};for(let _=0;_<C.length;){const R=C[_];if(!o(R)){_+=1;continue}const O=[];for(;_<C.length&&o(C[_]);)O.push(C[_]),_+=1;if(O.length<=1)continue;const q=O[O.length-1];A[q.id]=O.slice(0,-1)}return A}),h=P(()=>{const C=new Set;for(const A of Object.values(l.value))for(const _ of A)C.add(_.id);return C});function g(C){return o(C)&&s.value.has(C.id)}function b(C){return o(C)&&r.value}function L(C){var A;return o(C)&&(r.value||((A=C.commandExecution)==null?void 0:A.status)==="inProgress")}function y(C){if(!o(C))return;const A=new Set(s.value);A.has(C.id)?A.delete(C.id):A.add(C.id),s.value=A}function I(C){return l.value[C.id]??[]}function k(C){return o(C)?[...I(C),C]:[]}function E(C,A){if(C.size===0)return C;const _=new Set;for(const R of C)A.has(R)&&_.add(R);return _.size===C.size?C:_}function x(C){s.value=E(s.value,C)}return{expandedCommandIds:s,activeCommandMessageId:a,hasLiveAssistantText:i,isLiveTurnRuntime:r,groupedCommandsByLatestId:l,hiddenGroupedCommandIds:h,isCommandExpanded:g,isCommandCompact:b,isCommandOutputCondensed:L,toggleCommandExpand:y,getGroupedCommandsForLatest:I,getWorkBlockCommands:k,pruneCommandIdSets:x}}function Xo(e){const{getActiveThreadId:t,getCwd:n,onFileChangesChanged:o,updateThreadFileChanges:s,t:a}=e,i=U({}),r=U({}),l=U({});function h(x){const C=t();return x!=null&&x.turnId&&C?`thread:${C}:turn:${x.turnId}`:""}function g(x){return h(x).length>0}function b(x){const C=h(x);return C?i.value[C]??"idle":"idle"}function L(x){const C=h(x);return C?r.value[C]??"":""}function y(x){const C=b(x);return C==="undone"||C==="redoing"?"redo":"undo"}function I(x){const C=b(x);return C==="undoing"?a("Undoing"):C==="redoing"?a("Redoing"):y(x)==="redo"?a("Redo"):a("Undo")}async function k(x,C,A){const _=h(x),R=t(),O=n();if(!x||!_||!R||!O)return;const q=b(x),ee=C==="undo"?"undoing":"redoing";i.value={...i.value,[_]:ee},r.value={...r.value,[_]:""};let V;try{const fe=l.value[_]??[];V=await s(R,x.turnId,O,C,fe.length>0?fe:void 0,"single_turn",A)}catch(fe){i.value={...i.value,[_]:q},r.value={...r.value,[_]:fe instanceof Error?fe.message:a("Failed to update file changes.")};return}if(V.errors.length>0){C==="undo"?(l.value={...l.value,[_]:V.revertedPatchIds??[]},i.value={...i.value,[_]:"undone"}):((V.appliedPatchIds??[]).length>0&&(l.value={...l.value,[_]:V.appliedPatchIds??[]}),i.value={...i.value,[_]:"undone"}),r.value={...r.value,[_]:V.errors.join("; ")};return}if((V.changed??0)<=0){i.value={...i.value,[_]:q},r.value={...r.value,[_]:V.message||a(C==="undo"?"No file changes to undo.":"No file changes to redo.")};return}C==="undo"?(l.value={...l.value,[_]:V.revertedPatchIds??[]},i.value={...i.value,[_]:"undone"}):(l.value={...l.value,[_]:V.appliedPatchIds??[]},i.value={...i.value,[_]:"redone"}),o()}function E(){i.value={},r.value={},l.value={}}return{fileChangeActionState:i,fileChangeActionError:r,fileChangeRedoPatchIds:l,fileChangeActionKey:h,isFileChangeActionable:g,fileChangeActionStatus:b,fileChangeActionErrorText:L,fileChangeNextAction:y,fileChangeActionLabel:I,runFileChangeAction:k,resetFileChangeActions:E}}function Yo(e){const{toEditUrlFromBrowseHref:t}=e,n=U(!1),o=U(0),s=U(0),a=U(""),i=U("");function r(h){var y,I;const g=h.target,b=(y=g==null?void 0:g.closest)==null?void 0:y.call(g,"a.message-file-link");if(!b)return;const L=(((I=b.getAttribute)==null?void 0:I.call(b,"href"))??"").trim();!L||L==="#"||(h.preventDefault(),h.stopPropagation(),a.value=L,i.value=t(L),o.value=h.clientX,s.value=h.clientY,n.value=!0)}function l(){n.value&&(n.value=!1)}return{isFileLinkContextMenuVisible:n,fileLinkContextMenuX:o,fileLinkContextMenuY:s,fileLinkContextBrowseUrl:a,fileLinkContextEditUrl:i,handleConversationContextMenu:r,closeFileLinkContextMenu:l}}function Qo(e){const{isVideo:t}=e,n=U(""),o=U(!1),s=U(0),a=U(new Set);function i(b,L){return`${b}:${L}`}function r(b,L){return a.value.has(i(b,L))}function l(b,L){const y=new Set(a.value);y.add(i(b,L)),a.value=y,s.value+=1}function h(b){n.value=b,o.value=t(b)}function g(){n.value="",o.value=!1}return{modalImageUrl:n,modalIsVideo:o,markdownImageFailureVersion:s,isMarkdownImageFailed:r,onMarkdownImageError:l,openImageModal:h,closeImageModal:g}}const ea=["aria-label"],ta={class:"confirm-dialog-title"},na={class:"confirm-dialog-message"},sa={class:"confirm-dialog-actions"},oa=le({__name:"ConfirmDialog",props:{visible:{type:Boolean},title:{},message:{},confirmLabel:{default:""},cancelLabel:{default:""},danger:{type:Boolean,default:!1}},emits:["confirm","cancel"],setup(e){return(t,n)=>(c(),se(Vn,{to:"body"},[e.visible?(c(),f("div",{key:0,class:"confirm-dialog-overlay",onClick:n[2]||(n[2]=Ue(o=>t.$emit("cancel"),["self"]))},[m("div",{class:"confirm-dialog-panel",role:"alertdialog","aria-modal":"true","aria-label":e.title},[m("h3",ta,w(e.title),1),m("p",na,w(e.message),1),m("div",sa,[m("button",{class:"confirm-dialog-btn confirm-dialog-btn-cancel",type:"button",onClick:n[0]||(n[0]=o=>t.$emit("cancel"))},w(e.cancelLabel||"Cancel"),1),m("button",{class:te(["confirm-dialog-btn confirm-dialog-btn-confirm",{"is-danger":e.danger}]),type:"button",onClick:n[1]||(n[1]=o=>t.$emit("confirm"))},w(e.confirmLabel||"Confirm"),3)])],8,ea)])):S("",!0)]))}}),aa=oe(oa,[["__scopeId","data-v-de94025d"]]),ia={key:0,class:"diff-viewer-sidebar"},ra={class:"diff-viewer-sidebar-header"},la={class:"diff-viewer-sidebar-title"},ca={class:"diff-viewer-sidebar-count"},ua={class:"diff-viewer-sidebar-list"},da=["data-active","onClick"],fa=["data-operation"],ha={class:"diff-viewer-file-label"},ma={key:0,class:"diff-viewer-file-delta"},ga={class:"diff-viewer-main"},pa={class:"diff-viewer-toolbar"},va={class:"diff-viewer-title-wrap"},ka={class:"diff-viewer-title"},ya={class:"diff-viewer-subtitle"},wa={key:0},ba={class:"diff-viewer-toolbar-actions"},Ca=["aria-label"],$a={key:0,class:"diff-viewer-empty"},xa={class:"diff-viewer-empty-title"},Ta={class:"diff-viewer-empty-text"},_a={key:1,class:"diff-viewer-panel"},Ia={class:"diff-viewer-meta"},La={class:"diff-viewer-language"},Ma={class:"diff-viewer-lines"},Aa=["data-kind"],Sa={class:"diff-viewer-line-number"},Fa={class:"diff-viewer-line-number"},Pa={class:"diff-viewer-line-marker"},Ea=["innerHTML"],Ba={class:"diff-viewer-mobile-sheet-header"},Ra={class:"diff-viewer-sidebar-title"},Oa={class:"diff-viewer-sidebar-count"},Da={class:"diff-viewer-mobile-sheet-list"},Ha=["data-active","onClick"],Wa=["data-operation"],ja={class:"diff-viewer-file-label"},qa={key:0,class:"diff-viewer-file-delta"},Ua=le({__name:"DiffViewer",props:{change:{},changes:{},lines:{},isMobile:{type:Boolean},isFileListOpen:{type:Boolean},cwd:{}},emits:["close","select-change","toggle-file-list","close-file-list"],setup(e){const t=e,{t:n}=me();function o(r){return r.replace(/&/gu,"&amp;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;").replace(/"/gu,"&quot;").replace(/'/gu,"&#39;")}const s=P(()=>r=>Zt(r,n)),a=P(()=>r=>ns(r,n)),i=P(()=>r=>Ve(r,t.cwd));return(r,l)=>(c(),se(Vn,{to:"body"},[e.change?(c(),f("div",{key:0,class:"diff-viewer-backdrop",onClick:l[5]||(l[5]=h=>r.$emit("close"))},[m("div",{class:"diff-viewer-shell",onClick:l[4]||(l[4]=Ue(()=>{},["stop"]))},[e.isMobile?S("",!0):(c(),f("aside",ia,[m("div",ra,[m("p",la,w(d(n)("Changed files")),1),m("p",ca,w(a.value(e.changes.length)),1)]),m("div",ua,[(c(!0),f(W,null,K(e.changes,h=>(c(),f("button",{key:`diff-viewer:${d(ce)(h)}`,type:"button",class:"diff-viewer-file-button","data-active":d(ce)(h)===d(ce)(e.change),onClick:g=>r.$emit("select-change",h)},[m("span",{class:"file-change-badge","data-operation":d(jt)(h)},w(s.value(h)),9,fa),m("span",ha,[ye(w(i.value(h.path))+" ",1),h.movedToPath?(c(),f(W,{key:0},[ye(" → "+w(i.value(h.movedToPath)),1)],64)):S("",!0)]),d(Be)(h)?(c(),f("span",ma,w(d(Be)(h)),1)):S("",!0)],8,da))),128))])])),m("section",ga,[m("div",pa,[m("div",va,[m("p",ka,[ye(w(i.value(e.change.path))+" ",1),e.change.movedToPath?(c(),f(W,{key:0},[ye(" → "+w(i.value(e.change.movedToPath)),1)],64)):S("",!0)]),m("p",ya,[ye(w(s.value(e.change))+" ",1),d(Be)(e.change)?(c(),f("span",wa," · "+w(d(Be)(e.change)),1)):S("",!0)])]),m("div",ba,[e.isMobile?(c(),f("button",{key:0,type:"button",class:"diff-viewer-mobile-files-button",onClick:l[0]||(l[0]=h=>r.$emit("toggle-file-list"))},w(a.value(e.changes.length)),1)):S("",!0),m("button",{class:"image-modal-close diff-viewer-close",type:"button","aria-label":d(n)("Close diff viewer"),onClick:l[1]||(l[1]=h=>r.$emit("close"))},[Q(zn,{class:"icon-svg"})],8,Ca)])]),d(Vo)(e.change)?(c(),f("div",_a,[m("div",Ia,[m("span",La,w(d(Wo)(e.change)||"diff"),1)]),m("div",Ma,[(c(!0),f(W,null,K(e.lines,h=>(c(),f("div",{key:h.key,class:"diff-viewer-line","data-kind":h.kind},[m("span",Sa,w(h.oldLine??""),1),m("span",Fa,w(h.newLine??""),1),m("span",Pa,w(d(zo)(h)),1),m("code",{class:"diff-viewer-line-code",innerHTML:o(h.text)||" "},null,8,Ea)],8,Aa))),128))])])):(c(),f("div",$a,[m("p",xa,w(d(n)("No diff available")),1),m("p",Ta,w(d(n)("This summary was restored from the final answer text, but the thread history does not include patch diff content for this file.")),1)]))]),Q(yo,{name:"diff-viewer-sheet"},{default:We(()=>[e.isMobile&&e.isFileListOpen?(c(),f("div",{key:0,class:"diff-viewer-mobile-sheet-backdrop",onClick:l[3]||(l[3]=h=>r.$emit("close-file-list"))},[m("div",{class:"diff-viewer-mobile-sheet",onClick:l[2]||(l[2]=Ue(()=>{},["stop"]))},[l[6]||(l[6]=m("div",{class:"diff-viewer-mobile-sheet-handle","aria-hidden":"true"},null,-1)),m("div",Ba,[m("p",Ra,w(d(n)("Changed files")),1),m("p",Oa,w(a.value(e.changes.length)),1)]),m("div",Da,[(c(!0),f(W,null,K(e.changes,h=>(c(),f("button",{key:`diff-viewer-sheet:${d(ce)(h)}`,type:"button",class:"diff-viewer-file-button","data-active":d(ce)(h)===d(ce)(e.change),onClick:g=>r.$emit("select-change",h)},[m("span",{class:"file-change-badge","data-operation":d(jt)(h)},w(s.value(h)),9,Wa),m("span",ja,[ye(w(i.value(h.path))+" ",1),h.movedToPath?(c(),f(W,{key:0},[ye(" → "+w(i.value(h.movedToPath)),1)],64)):S("",!0)]),d(Be)(h)?(c(),f("span",qa,w(d(Be)(h)),1)):S("",!0)],8,Ha))),128))])])])):S("",!0)]),_:1})])])):S("",!0)]))}}),Na=oe(Ua,[["__scopeId","data-v-7ec6502b"]]),Va={},za={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function Ka(e,t){return c(),f("svg",za,[...t[0]||(t[0]=[m("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 14L4 9l5-5m-5 5h11a4 4 0 0 1 0 8H4"},null,-1)])])}const qt=oe(Va,[["render",Ka]]),Ga={class:"file-change-summary-label"},Za={class:"file-change-summary-status"},Ja=["data-tone"],Xa={class:"file-change-panel-inner"},Ya={class:"file-change-list"},Qa=["data-operation","title"],ei={class:"file-change-path-group"},ti=["title","onClick"],ni={key:0,class:"file-change-arrow"},si=["title","onClick"],oi={key:0,class:"file-change-delta"},ai=["data-tone"],ii=["title","aria-label","onClick"],ri={key:0,class:"file-change-actions"},li={key:0,class:"file-change-action-error"},ci=["disabled","title","aria-label"],ui=le({__name:"FileChangeSummaryBlock",props:{summary:{},expanded:{type:Boolean},inline:{type:Boolean},cwd:{},actionable:{type:Boolean},actionStatus:{},actionErrorText:{},nextAction:{},actionLabel:{}},emits:["toggle","open-diff","request-action","request-file-action"],setup(e){const t=e,{t:n}=me(),o=P(()=>r=>Zt(r,n)),s=P(()=>r=>Oo(r,n)),a=P(()=>r=>Ve(r,t.cwd)),i=P(()=>r=>`${n("Undo")} ${Ve(r.path,t.cwd)}`);return(r,l)=>e.summary?(c(),f("section",{key:0,class:te(["file-change-summary-block",{"file-change-summary-block-inline":e.inline}])},[m("button",{type:"button",class:te(["file-change-summary-row",{"file-change-summary-row-expanded":e.expanded}]),onClick:l[0]||(l[0]=h=>r.$emit("toggle"))},[m("span",{class:te(["file-change-chevron",{"file-change-chevron-open":e.expanded}])},"▶",2),m("span",Ga,w(s.value(e.summary)),1),m("span",Za,[(c(!0),f(W,null,K(d(Do)(e.summary),h=>(c(),f("span",{key:`summary-status:${e.summary.turnId}:${h.tone}:${h.label}`,class:"file-change-signed-count","data-tone":h.tone},w(h.label),9,Ja))),128))])],2),m("div",{class:te(["file-change-panel",{"file-change-panel-visible":e.expanded}])},[m("div",Xa,[m("ul",Ya,[(c(!0),f(W,null,K(e.summary.changes,h=>(c(),f("li",{key:`file-change:${e.summary.turnId}:${h.path}:${h.movedToPath||""}`,class:"file-change-item"},[m("span",{class:"file-change-badge","data-operation":d(jt)(h),title:o.value(h)},w(d(Eo)(h)),9,Qa),m("span",ei,[m("button",{type:"button",class:"file-change-path-button",title:h.path,onClick:g=>r.$emit("open-diff",h)},w(a.value(h.path)),9,ti),h.movedToPath?(c(),f("span",ni,"→")):S("",!0),h.movedToPath?(c(),f("button",{key:1,type:"button",class:"file-change-path-button",title:h.movedToPath,onClick:g=>r.$emit("open-diff",h)},w(a.value(h.movedToPath)),9,si)):S("",!0)]),h.addedLineCount>0||h.removedLineCount>0?(c(),f("span",oi,[(c(!0),f(W,null,K(d(Bo)(h),g=>(c(),f("span",{key:`change-delta:${e.summary.turnId}:${h.path}:${g.tone}:${g.label}`,class:"file-change-signed-count","data-tone":g.tone},w(g.label),9,ai))),128))])):S("",!0),e.actionable?(c(),f("button",{key:1,type:"button",class:"file-change-file-undo-button",title:i.value(h),"aria-label":i.value(h),onClick:g=>r.$emit("request-file-action",h)},[Q(qt,{class:"icon-svg file-change-action-icon"})],8,ii)):S("",!0)]))),128))]),e.actionable?(c(),f("div",ri,[e.actionErrorText?(c(),f("p",li,w(e.actionErrorText),1)):S("",!0),m("button",{type:"button",class:"file-change-action-button",disabled:e.actionStatus==="undoing"||e.actionStatus==="redoing",title:e.nextAction==="redo"?"Redo file changes from this turn":"Undo file changes from this turn","aria-label":e.nextAction==="redo"?"Redo file changes from this turn":"Undo file changes from this turn",onClick:l[1]||(l[1]=h=>r.$emit("request-action",e.nextAction))},[Q(qt,{class:te(["icon-svg file-change-action-icon",{"file-change-action-icon-redo":e.nextAction==="redo"}])},null,8,["class"]),ye(" "+w(e.actionLabel),1)],8,ci)])):S("",!0)])],2)],2)):S("",!0)}}),An=oe(ui,[["__scopeId","data-v-851281a0"]]),di=le({__name:"FileLinkContextMenu",props:{visible:{type:Boolean},x:{},y:{},browseUrl:{},editUrl:{}},emits:["close"],setup(e,{emit:t}){const n=e,o=t,s=U(null),a=P(()=>({left:`${String(n.x)}px`,top:`${String(n.y)}px`}));function i(){o("close")}function r(){const y=n.browseUrl;i(),!(!y||y==="#")&&window.open(y,"_blank","noopener,noreferrer")}function l(){const y=n.editUrl;i(),!(!y||y==="#")&&window.open(y,"_blank","noopener,noreferrer")}async function h(){const y=n.browseUrl;if(i(),!(!y||y==="#"))try{await Dt(y)}catch{}}function g(y){if(!n.visible)return;const I=s.value;if(!I){i();return}const k=y.target;k instanceof Node&&I.contains(k)||i()}function b(){i()}function L(y){y.key==="Escape"&&i()}return $e(()=>n.visible,y=>{y?(window.addEventListener("pointerdown",g,!0),window.addEventListener("blur",b),window.addEventListener("keydown",L,!0)):(window.removeEventListener("pointerdown",g,!0),window.removeEventListener("blur",b),window.removeEventListener("keydown",L,!0))}),vt(()=>{window.removeEventListener("pointerdown",g,!0),window.removeEventListener("blur",b),window.removeEventListener("keydown",L,!0)}),(y,I)=>e.visible?(c(),f("div",{key:0,ref_key:"menuRef",ref:s,class:"file-link-context-menu",style:Xe(a.value),onClick:I[0]||(I[0]=Ue(()=>{},["stop"]))},[m("button",{type:"button",class:"file-link-context-menu-item",onClick:r}," Open link "),m("button",{type:"button",class:"file-link-context-menu-item",onClick:h}," Copy link "),e.editUrl?(c(),f("button",{key:0,type:"button",class:"file-link-context-menu-item",onClick:l}," Edit file ")):S("",!0)],4)):S("",!0)}}),fi=oe(di,[["__scopeId","data-v-9cda1d9d"]]),hi=12e3,mi=240;function gi(e,{streaming:t,truncateStreaming:n=!0,maxChars:o=hi,maxLines:s=mi}){if(!n)return e;let a=e,i=!1;if(o>0&&a.length>o&&(a=a.slice(-o),i=!0),s>0){const r=a.split(/\r?\n/);r.length>s&&(a=r.slice(-s).join(`
25
+ `),i=!0)}return i?`...
26
+ ${a}`:a}const pi={class:"conversation-item conversation-item-overlay"},vi={class:"message-row"},ki={class:"message-stack"},yi={class:"live-overlay-inline","aria-live":"polite"},wi={class:"live-overlay-title-row"},bi={key:0,class:"live-overlay-spinner","aria-hidden":"true"},Ci=["aria-expanded"],$i={class:"live-overlay-label"},xi={class:"live-overlay-toggle","aria-hidden":"true"},Ti={key:2,class:"live-overlay-label"},_i={key:0,class:"live-overlay-reasoning"},Ii={key:1,class:"live-overlay-error"},Li=["href"],Mi=le({__name:"LiveOverlayItem",props:{overlay:{},feedbackMailto:{}},setup(e){const t=e,{buildFeedbackMailto:n,recordVisibleFailure:o}=Kn(),{t:s}=me(),a=U(!0);function i(){a.value=!a.value}const r=P(()=>{var h;return gi(((h=t.overlay)==null?void 0:h.reasoningText)??"",{streaming:!0})});function l(h,g){o(g);const b=h.currentTarget;b instanceof HTMLAnchorElement&&(b.href=n())}return(h,g)=>{var b,L,y,I,k,E;return c(),f("li",pi,[m("div",vi,[m("div",ki,[m("article",yi,[m("div",wi,[(b=e.overlay)!=null&&b.errorText?S("",!0):(c(),f("span",bi)),(L=e.overlay)!=null&&L.reasoningText?(c(),f("button",{key:1,type:"button",class:"live-overlay-heading","aria-expanded":a.value,onClick:i},[m("span",$i,w((y=e.overlay)==null?void 0:y.activityLabel),1),m("span",xi,w(a.value?"▾":"▸"),1)],8,Ci)):(c(),f("p",Ti,w((I=e.overlay)==null?void 0:I.activityLabel),1))]),(k=e.overlay)!=null&&k.reasoningText&&a.value?(c(),f("p",_i,w(r.value),1)):S("",!0),(E=e.overlay)!=null&&E.errorText?(c(),f("div",Ii,[m("span",null,w(e.overlay.errorText),1),m("a",{class:"live-overlay-feedback",href:e.feedbackMailto,onClick:g[0]||(g[0]=x=>l(x,e.overlay.errorText))},w(d(s)("Send feedback")),9,Li)])):S("",!0)])])])])}}}),Ai=oe(Mi,[["__scopeId","data-v-b69a0020"]]),Si={key:0},Fi={key:1,class:"message-bold-text"},Pi={key:2,class:"message-italic-text"},Ei={key:3,class:"message-strikethrough-text"},Bi=["href","title"],Ri=["href","title"],Oi={key:6,class:"message-inline-code"},Di=le({__name:"MessageInlineContent",props:{segments:{},toBrowseUrl:{type:Function}},setup(e){return(t,n)=>(c(!0),f(W,null,K(e.segments,(o,s)=>(c(),f(W,{key:s},[o.kind==="text"?(c(),f("span",Si,w(o.value),1)):o.kind==="bold"?(c(),f("strong",Fi,w(o.value),1)):o.kind==="italic"?(c(),f("em",Pi,w(o.value),1)):o.kind==="strikethrough"?(c(),f("s",Ei,w(o.value),1)):o.kind==="file"?(c(),f("a",{key:4,class:"message-file-link",href:e.toBrowseUrl(o.path),target:"_blank",rel:"noopener noreferrer",title:o.path},w(o.displayPath),9,Bi)):o.kind==="url"?(c(),f("a",{key:5,class:"message-file-link",href:o.href,target:"_blank",rel:"noopener noreferrer",title:o.href},w(o.value),9,Ri)):(c(),f("code",Oi,w(o.value),1))],64))),128))}}),He=oe(Di,[["__scopeId","data-v-e81c51c6"]]),Hi={},Wi={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function ji(e,t){return c(),f("svg",Wi,[...t[0]||(t[0]=[m("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2zm-4 4a2 2 0 0 1-2-2V8m4 8h10"},null,-1)])])}const qi=oe(Hi,[["render",ji]]),Ui=["data-role"],Ni=["aria-label","title"],Vi={key:0,class:"message-rollback-label"},zi=["aria-label","title"],Ki={class:"message-fork-label"},Gi=["data-copied","aria-label","title"],Zi={key:0,class:"message-copy-label"},Ji=le({__name:"MessageToolbar",props:{role:{},showEdit:{type:Boolean,default:!1},showFork:{type:Boolean,default:!1},showCopy:{type:Boolean,default:!1},copied:{type:Boolean,default:!1}},emits:["edit","fork","copy"],setup(e){const{t}=me();return(n,o)=>e.showEdit||e.showFork||e.showCopy?(c(),f("div",{key:0,class:"message-toolbar","data-role":e.role},[e.showEdit?(c(),f("button",{key:0,type:"button",class:"message-rollback-button","aria-label":d(t)("Rollback this message"),title:d(t)("Rollback this message"),onClick:o[0]||(o[0]=s=>n.$emit("edit"))},[Q(qt,{class:"icon-svg message-rollback-icon"}),e.role!=="user"?(c(),f("span",Vi,w(d(t)("Rollback")),1)):S("",!0)],8,Ni)):S("",!0),e.showFork?(c(),f("button",{key:1,type:"button",class:"message-fork-button","aria-label":d(t)("Fork thread from this response"),title:d(t)("Fork thread from this response"),onClick:o[1]||(o[1]=s=>n.$emit("fork"))},[Q(wo,{class:"icon-svg message-fork-icon"}),m("span",Ki,w(d(t)("Fork")),1)],8,zi)):S("",!0),e.showCopy?(c(),f("button",{key:2,type:"button",class:"message-copy-button","data-copied":e.copied,"aria-label":e.copied?d(t)("Response copied"):d(t)("Copy response"),title:e.copied?d(t)("Response copied"):d(t)("Copy response"),onClick:o[2]||(o[2]=s=>n.$emit("copy"))},[Q(qi,{class:"icon-svg message-copy-icon"}),e.role!=="user"?(c(),f("span",Zi,w(e.copied?"Copied":"Copy"),1)):S("",!0)],8,Gi)):S("",!0)],8,Ui)):S("",!0)}}),Xi=oe(Ji,[["__scopeId","data-v-59a7a725"]]),Yi="codex-web-local.process-fold.v1",Sn="codex:web-local:process-fold";function Bt(){return typeof localStorage>"u"?"auto":localStorage.getItem(Yi)==="expanded"?"expanded":"auto"}function Qi(e){const t=n=>e(n.detail);return window.addEventListener(Sn,t),()=>window.removeEventListener(Sn,t)}const er=["aria-expanded"],tr={class:"process-fold-label"},nr={class:"process-fold-toggle","aria-hidden":"true"},sr={key:0,class:"process-fold-body"},or=le({__name:"ProcessFold",props:{label:{},running:{type:Boolean},hasOutsideContent:{type:Boolean}},setup(e){const t=e,n=U(Bt()==="expanded"||!t.hasOutsideContent),o=U(!1);let s=!1;const a=Qi(()=>{o.value=!1,Bt()==="expanded"?n.value=!0:!t.running&&t.hasOutsideContent&&(n.value=!1)});$e(()=>t.running,r=>{const l=s;s=r,r?(l||(o.value=!1),o.value||(n.value=!0)):l&&!o.value&&t.hasOutsideContent&&Bt()!=="expanded"&&(n.value=!1)},{immediate:!0}),vt(()=>a());function i(){o.value=!0,n.value=!n.value}return(r,l)=>(c(),f("div",{class:te(["process-fold",{"process-fold--open":n.value,"process-fold--running":e.running}])},[m("button",{type:"button",class:"process-fold-header","aria-expanded":n.value,onClick:i},[m("span",tr,w(e.label),1),m("span",nr,w(n.value?"▾":"▸"),1)],8,er),n.value?(c(),f("div",sr,[Pe(r.$slots,"default",{},void 0)])):S("",!0)],2))}}),ar=oe(or,[["__scopeId","data-v-de9b3329"]]),ir=["aria-label"],rr=["data-turn","aria-label","onClick"],lr={class:"question-jump-preview-text"},cr=2,Rt="#3b82f6",ur=le({__name:"QuestionJumpBar",props:{anchors:{},activeTurn:{}},emits:["jump"],setup(e,{emit:t}){const n=e,o=t,{t:s}=me(),a=U(null),i=U(-1),r=U("0px"),l=P(()=>{const k=i.value;return k<0?null:n.anchors[k]??null});function h(k){var A;const E=n.activeTurn===((A=n.anchors[k])==null?void 0:A.turn),x={};if(i.value<0)return x.width=E?"18px":"12px",x.background=E?Rt:void 0,x;const C=Math.abs(k-i.value);return x.width=C===0?"32px":C===1?"20px":C===2?"14px":E?"18px":"12px",x.background=C===0?Rt:C===1?"rgba(59,130,246,0.6)":C===2?"rgba(59,130,246,0.35)":E?Rt:void 0,x.transitionDelay=`${C*20}ms`,x}function g(k){const E=a.value;if(!E)return-1;const x=Array.from(E.querySelectorAll(".question-jump-item"));let C=-1,A=Number.POSITIVE_INFINITY;for(let _=0;_<x.length;_+=1){const R=x[_].getBoundingClientRect(),O=R.top+R.height/2,q=Math.abs(k-O);q<A&&(A=q,C=_)}return C}function b(k){var O;const E=g(k.clientY);if(E<0)return;i.value=E;const x=a.value;if(!x)return;const A=(O=Array.from(x.querySelectorAll(".question-jump-item"))[E])==null?void 0:O.getBoundingClientRect(),_=x.getBoundingClientRect();if(!A)return;const R=A.top+A.height/2;r.value=`${R-_.top}px`}function L(){i.value=-1}function y(k){const E=g(k.clientY),x=E>=0?n.anchors[E]:null;x&&o("jump",x.turn)}function I(k){o("jump",k.turn)}return(k,E)=>e.anchors.length>=cr?(c(),f("nav",{key:0,class:"question-jump-bar","aria-label":d(s)("Question navigation")},[m("div",{ref_key:"trackRef",ref:a,class:"question-jump-track",onMousemove:b,onMouseleave:L,onMousedown:y},[(c(!0),f(W,null,K(e.anchors,(x,C)=>(c(),f("button",{key:x.turn,type:"button",class:"question-jump-item","data-turn":x.turn,"aria-label":d(s)("Jump to question {n}",{n:x.turn+1}),onMousedown:E[0]||(E[0]=Ue(()=>{},["prevent"])),onClick:A=>I(x)},[m("span",{class:"question-jump-dot",style:Xe(h(C))},null,4)],40,rr))),128))],544),l.value?(c(),f("div",{key:0,class:"question-jump-preview",role:"tooltip",style:Xe({top:r.value})},[m("span",lr,w(l.value.text),1)],4)):S("",!0)],8,ir)):S("",!0)}}),dr=oe(ur,[["__scopeId","data-v-96d087d4"]]),fr=["data-state"],hr=["aria-expanded"],mr={class:"reasoning-block-title"},gr={class:"reasoning-block-toggle","aria-hidden":"true"},pr={key:0,class:"reasoning-block-body"},vr={key:0,class:"reasoning-block-summary"},kr=["innerHTML"],yr=le({__name:"ReasoningBlock",props:{message:{},expanded:{type:Boolean},contentHtml:{}},emits:["toggle"],setup(e){const t=e,{t:n}=me(),o=P(()=>{var a;return(((a=t.message.reasoning)==null?void 0:a.summary)??[]).map(i=>i.trim()).filter(Boolean).join(`
27
+ `).trim()});return(s,a)=>(c(),f("div",{class:"reasoning-block","data-state":e.expanded?"expanded":"collapsed"},[m("button",{type:"button",class:"reasoning-block-header","aria-expanded":e.expanded,onClick:a[0]||(a[0]=i=>s.$emit("toggle"))},[m("span",mr,w(d(n)("Thinking process")),1),m("span",gr,w(e.expanded?"▾":"▸"),1)],8,hr),e.expanded?(c(),f("div",pr,[o.value?(c(),f("p",vr,w(o.value),1)):S("",!0),m("div",{class:"reasoning-block-content message-card",innerHTML:e.contentHtml},null,8,kr)])):S("",!0)],8,fr))}}),Fn=oe(yr,[["__scopeId","data-v-5fa90230"]]),wr=new Set(["read_file","ls","grep","glob","web_fetch","read_skill","code_index","connect_tool_source"]),br=new Set(["write_file","edit_file","multi_edit","move_file","delete_range","delete_symbol","notebook_edit"]),Cr=new Set(["task","run_skill","explore","research","review","security_review"]);function $r(e){var n;const t=((n=e.toolCall)==null?void 0:n.tool)??"";return wr.has(t)?"readonly":br.has(t)?"modify":Cr.has(t)?"delegate":null}const xr=2;function Tr(e){var a;const t=[];let n=[],o=null;const s=()=>{if(o!==null&&n.length>=xr)t.push({type:"batch",kind:o,messages:n});else for(const i of n)t.push({type:"tool",message:i});n=[],o=null};for(const i of e){if(i.messageType!=="toolCall"||((a=i.toolCall)==null?void 0:a.status)==="inProgress"){s(),t.push({type:"tool",message:i});continue}const r=$r(i);if(r===null){s(),t.push({type:"tool",message:i});continue}o!==null&&o!==r&&s(),o=r,n.push(i)}return s(),t}function _r(e,t,n){const{t:o}=n;if(e==="readonly"){const s=t.filter(l=>{var h,g;return((h=l.toolCall)==null?void 0:h.tool)==="read_file"||((g=l.toolCall)==null?void 0:g.tool)==="ls"}).length,a=t.filter(l=>{var g;const h=((g=l.toolCall)==null?void 0:g.tool)??"";return h==="grep"||h==="glob"||h==="web_fetch"||h==="code_index"}).length,i=t.length-s-a,r=[];return s>0&&r.push(o("Read {n} files",{n:s})),a>0&&r.push(o("Search {n} files",{n:a})),i>0&&r.push(o("{n} read calls",{n:i})),r.join(" · ")}return e==="modify"?o("Modified {n} files",{n:t.length}):e==="delegate"?o("Delegated {n} tasks",{n:t.length}):o("Explored {n} items",{n:t.length})}const Ir={class:"message-row","data-role":"system"},Lr={class:"message-stack","data-role":"system"},Mr=["title"],Ar={key:0,class:"tool-call-server"},Sr={class:"tool-call-name"},Fr={class:"tool-call-status"},Pr={key:0,class:"work-block-spinner","aria-hidden":"true"},Er={key:1,class:"tool-call-status-icon","aria-hidden":"true"},Br={key:2,class:"tool-call-status-icon","aria-hidden":"true"},Rr=le({__name:"ToolCallRow",props:{message:{}},setup(e){const t=e,{t:n}=me(),o=P(()=>{const i=t.message.toolCall;if(!i)return"";switch(i.status){case"inProgress":return n("Running");case"failed":return n("Failed");default:return n("Done")}}),s=P(()=>{var i;switch((i=t.message.toolCall)==null?void 0:i.status){case"inProgress":return"tool-call-running";case"failed":return"tool-call-error";default:return"tool-call-ok"}}),a=P(()=>{const i=t.message.toolCall;if(!i)return"";const r=[];return i.server&&r.push(i.server),r.push(i.tool),i.error&&r.push(i.error),typeof i.durationMs=="number"&&i.durationMs>=0&&r.push(`${i.durationMs}ms`),r.join(" · ")});return(i,r)=>{var l,h,g,b;return c(),f("div",Ir,[m("div",Lr,[m("div",{class:te(["tool-call-block",s.value]),title:a.value},[r[0]||(r[0]=m("span",{class:"tool-call-icon","aria-hidden":"true"},"🛠",-1)),(l=e.message.toolCall)!=null&&l.server?(c(),f("span",Ar,w(e.message.toolCall.server),1)):S("",!0),m("code",Sr,w(((h=e.message.toolCall)==null?void 0:h.tool)||e.message.text||"(tool)"),1),m("span",Fr,[((g=e.message.toolCall)==null?void 0:g.status)==="inProgress"?(c(),f("span",Pr)):((b=e.message.toolCall)==null?void 0:b.status)==="completed"?(c(),f("span",Er,"✓")):(c(),f("span",Br,"✗")),ye(" "+w(o.value),1)])],10,Mr)])])}}}),Ut=oe(Rr,[["__scopeId","data-v-e25278a7"]]),Or=["aria-expanded","title"],Dr={class:"tool-batch-toggle","aria-hidden":"true"},Hr={class:"tool-batch-label"},Wr={class:"tool-batch-count"},jr={key:0,class:"tool-batch-body"},qr=le({__name:"ToolBatchBlock",props:{kind:{},messages:{}},setup(e){const t=e,{t:n}=me(),o=U(!1),s=P(()=>_r(t.kind,t.messages,{t:n})),a=P(()=>t.messages.map(i=>{var r;return((r=i.toolCall)==null?void 0:r.tool)??""}).join(" · "));return(i,r)=>(c(),f("div",{class:te(["tool-batch-block",{"tool-batch-block--open":o.value}])},[m("button",{type:"button",class:"tool-batch-head","aria-expanded":o.value,title:a.value,onClick:r[0]||(r[0]=l=>o.value=!o.value)},[m("span",Dr,w(o.value?"▾":"▸"),1),r[1]||(r[1]=m("span",{class:"tool-batch-icon","aria-hidden":"true"},"🛠",-1)),m("span",Hr,w(s.value),1),m("span",Wr,w(e.messages.length),1)],8,Or),o.value?(c(),f("div",jr,[(c(!0),f(W,null,K(e.messages,l=>(c(),se(Ut,{key:l.id,message:l},null,8,["message"]))),128))])):S("",!0)],2))}}),Ur=oe(qr,[["__scopeId","data-v-908995a9"]]),Nr=["data-turn-key"],Vr={key:0,class:"conversation-turn-request","aria-label":"User request"},zr={class:"conversation-turn-items"},Kr={key:1,class:"conversation-turn-process","aria-label":"Turn process"},Gr=["aria-expanded","aria-label"],Zr={key:2,class:"conversation-turn-time"},Jr={class:"conversation-turn-process-count"},Xr={key:1,class:"conversation-turn-process-heading"},Yr={key:0,class:"conversation-turn-time"},Qr={key:2,class:"conversation-turn-items conversation-turn-process-items"},el={key:2,class:"conversation-turn-final","aria-label":"Assistant final response"},tl={class:"conversation-turn-items"},nl=le({__name:"ThreadTurn",props:{turnKey:{},request:{},processItems:{default:()=>[]},finalItem:{},fileChangeAnchorIds:{default:()=>[]},durationMs:{},warm:{},warmItems:{default:()=>[]}},setup(e){const t=e,{t:n}=me(),o=U(!0),s=P(()=>t.processItems.length+t.fileChangeAnchorIds.length),a=P(()=>!!t.finalItem);return $e(s,(i,r)=>{i>r&&(o.value=!0)}),(i,r)=>e.warm?(c(),f(W,{key:0},[Pe(i.$slots,"warm-card",{warm:e.warm},void 0),(c(!0),f(W,null,K(e.warmItems,l=>Pe(i.$slots,"default",{key:l.message.id,item:l,section:"warm"},void 0)),128))],64)):(c(),f("li",{key:1,class:"conversation-turn","data-turn-key":e.turnKey},[e.request?(c(),f("section",Vr,[m("ol",zr,[Pe(i.$slots,"default",{item:e.request,section:"request"},void 0)])])):S("",!0),s.value>0?(c(),f("section",Kr,[a.value?(c(),f("button",{key:0,class:"conversation-turn-process-heading conversation-turn-process-toggle",type:"button","aria-expanded":o.value,"aria-label":o.value?d(n)("Collapse turn process"):d(n)("Expand turn process"),onClick:r[0]||(r[0]=l=>o.value=!o.value)},[o.value?(c(),se(bo,{key:0,class:"conversation-turn-process-toggle-icon"})):(c(),se(Gn,{key:1,class:"conversation-turn-process-toggle-icon"})),m("span",null,w(d(n)("Turn process")),1),e.durationMs!=null&&e.durationMs>0?(c(),f("span",Zr,w(d(Ht)(e.durationMs)),1)):S("",!0),m("span",Jr,w(d(n)("{n} process items",{n:s.value})),1)],8,Gr)):(c(),f("div",Xr,[ye(w(d(n)("Turn process"))+" ",1),e.durationMs!=null&&e.durationMs>0?(c(),f("span",Yr,w(d(Ht)(e.durationMs)),1)):S("",!0)])),o.value?(c(),f("ol",Qr,[(c(!0),f(W,null,K(e.processItems,l=>Pe(i.$slots,"default",{key:l.message.id,item:l,section:"process"},void 0)),128)),(c(!0),f(W,null,K(e.fileChangeAnchorIds,l=>(c(),f("li",{key:`file-change-${l}`,class:"conversation-turn-row conversation-turn-file-change"},[Pe(i.$slots,"file-change",{anchorMessageId:l},void 0)]))),128))])):S("",!0)])):S("",!0),e.finalItem?(c(),f("section",el,[m("ol",tl,[Pe(i.$slots,"default",{item:e.finalItem,section:"final"},void 0)])])):S("",!0)],8,Nr))}}),sl=oe(nl,[["__scopeId","data-v-03c06fab"]]),ol=["aria-expanded"],al={class:"warm-turn__preview"},il={key:0,class:"warm-turn__meta"},rl={class:"warm-turn__content"},ll={key:1,class:"warm-turn__assistant"},cl=le({__name:"WarmTurnCard",props:{userText:{},assistantPreview:{},toolCount:{},expanded:{type:Boolean}},emits:["toggle"],setup(e,{emit:t}){const n=t,{t:o}=me();function s(){n("toggle")}return(a,i)=>(c(),f("div",{class:te(["warm-turn",{"warm-turn--expanded":e.expanded}])},[m("button",{type:"button",class:"warm-turn__head","aria-expanded":e.expanded,onClick:s},[Q(Gn,{class:te(["warm-turn__chevron",{"warm-turn__chevron--open":e.expanded}])},null,8,["class"]),m("span",al,w(e.userText),1),e.toolCount>0?(c(),f("span",il,w(d(o)("{n} tools",{n:e.toolCount})),1)):S("",!0)],8,ol),m("div",rl,[e.expanded?Pe(a.$slots,"default",{},void 0,!0,0):e.assistantPreview?(c(),f("div",ll,w(e.assistantPreview),1)):S("",!0)])],2))}}),ul=oe(cl,[["__scopeId","data-v-7e3ebbc7"]]),dl=["aria-expanded"],fl=["title"],hl={class:"work-block-command"},ml={class:"work-block-status"},gl={key:0,class:"work-block-spinner","aria-hidden":"true"},pl={key:1,class:"work-block-status-icon","aria-hidden":"true"},vl={key:2,class:"work-block-status-icon","aria-hidden":"true"},kl={class:"work-block-output-inner"},yl=["textContent"],wl=["textContent"],bl={key:0,class:"work-block-permission-hint",role:"note"},Cl=le({__name:"WorkBlockItem",props:{command:{},stepIndex:{},expanded:{type:Boolean},compact:{type:Boolean},outputCondensed:{type:Boolean}},emits:["toggle"],setup(e){const t=e,{t:n}=me(),o=P(()=>{var l,h;const r=(l=t.command.commandExecution)==null?void 0:l.status;return r==="inProgress"?"cmd-status-running":r==="completed"&&((h=t.command.commandExecution)==null?void 0:h.exitCode)===0?"cmd-status-ok":"cmd-status-error"}),s=P(()=>{const r=t.command.commandExecution;if(!r)return"";switch(r.status){case"inProgress":return n("Running");case"completed":return r.exitCode===0?n("Done"):`${n("Exit")} ${r.exitCode??"?"}`;case"failed":return n("Failed");case"declined":return n("Declined");case"interrupted":return n("Stopped");default:return""}}),a=[/access to the path .* is denied/iu,/access is denied/iu,/permission denied/iu,/not permitted/iu,/EACCES|EPERM/iu,/denied access|deny access/iu,/拒绝访问/iu,/没有权限/iu,/权限不足/iu,/要求提权|需要提权|require_escalated/iu],i=P(()=>{const r=t.command.commandExecution;if(!r||!(r.status==="failed"||r.status==="declined"||typeof r.exitCode=="number"&&r.exitCode!==0))return"";const h=r.aggregatedOutput??"";return!h||!a.some(g=>g.test(h))?"":n("Command blocked by a permission or sandbox restriction; no approval prompt was shown. Check the approval policy or trusted directories if you expected one.")});return(r,l)=>{var h,g,b,L,y,I;return c(),f("div",{class:te(["work-block",[o.value,{"work-block-expanded":e.expanded,"work-block-compact":e.compact}]])},[m("button",{type:"button",class:"work-block-header","aria-expanded":e.expanded,onClick:l[0]||(l[0]=k=>r.$emit("toggle"))},[m("span",{class:"work-step-dot",title:`${d(n)("Step")} ${String(e.stepIndex+1)}`},w(e.stepIndex+1),9,fl),m("code",hl,w(d(n)("Command")),1),m("span",ml,[((h=e.command.commandExecution)==null?void 0:h.status)==="inProgress"?(c(),f("span",gl)):((g=e.command.commandExecution)==null?void 0:g.status)==="completed"&&((b=e.command.commandExecution)==null?void 0:b.exitCode)===0?(c(),f("span",pl,"✓")):((L=e.command.commandExecution)==null?void 0:L.status)==="failed"?(c(),f("span",vl,"✗")):S("",!0),ye(" "+w(s.value),1)])],8,dl),m("div",{class:te(["work-block-output-wrap",{"work-block-output-visible":e.expanded}])},[m("div",kl,[m("pre",{class:"work-block-output-command",textContent:w(((y=e.command.commandExecution)==null?void 0:y.command)||"(command)")},null,8,yl),m("pre",{class:te(["work-block-output",{"cmd-output-condensed":e.outputCondensed}]),textContent:w(((I=e.command.commandExecution)==null?void 0:I.aggregatedOutput)||"(no output)")},null,10,wl)])],2),i.value?(c(),f("p",bl,w(i.value),1)):S("",!0)],2)}}}),Pn=oe(Cl,[["__scopeId","data-v-e9fdf684"]]),$l=2;function En(e){const t=e.messageType;return t==="commandExecution"||t==="toolCall"}function xl(e){var n,o;return(((n=e.commandExecution)==null?void 0:n.status)??"")==="inProgress"||(((o=e.toolCall)==null?void 0:o.status)??"")==="inProgress"?!0:(e.messageType??"").endsWith(".live")}function Tl(e,t){return e.messages.every(n=>t(n))}function _l(e){const t=[];let n=[],o="";const s=()=>{n.length>0&&(t.push(n),n=[])};for(const r of e){const l=r.turnId??"",h=En(r)&&l!=="";(!h||l!==o)&&(n.length>0&&s(),o=h?l:""),h&&n.push(r)}s();const a=new Map;for(const r of e)r.messageType==="worked"&&r.turnId&&typeof r.durationMs=="number"&&a.set(r.turnId,r.durationMs);const i=[];for(const r of t){if(r.length<$l)continue;const l=r[0].turnId??"";let h=0,g=0,b=0,L=!1;for(const I of r)I.messageType==="toolCall"?h+=1:I.messageType==="reasoning"?g+=1:I.messageType==="commandExecution"&&(b+=1),xl(I)&&(L=!0);const y=e.some(I=>I.turnId===l&&!En(I));i.push({turnId:l,messages:r,running:L,toolCount:h,thoughtCount:g,commandCount:b,durationMs:a.get(l)??0,hasOutsideContent:y})}return i}function Il(e,t){const{t:n,formatDuration:o}=t,s=[];return e.running?s.push(n("Working…")):e.durationMs>0?s.push(o(e.durationMs)):s.push(n("Processed")),e.toolCount>0&&s.push(n("{n} tools",{n:e.toolCount})),e.thoughtCount>0&&s.push(n("{n} thoughts",{n:e.thoughtCount})),e.commandCount>0&&s.push(n("{n} commands",{n:e.commandCount})),s.join(" · ")}function Ll(e){return e.text.length>0||Array.isArray(e.images)&&e.images.length>0||Array.isArray(e.fileAttachments)&&e.fileAttachments.length>0||Array.isArray(e.skills)&&e.skills.length>0}function Ml(e){return!Ll(e)}function Al(e){return e.role==="user"?"user":e.messageType==="reasoning"?"reasoning":e.messageType==="plan"||e.messageType==="plan.live"?"plan":e.messageType==="fileChange"?"file-change":e.messageType==="commandExecution"||e.messageType==="toolCall"||e.messageType==="worked"?"process":"assistant"}function Sl(e,t=!1){var n;return e.role==="assistant"&&e.messageType!=="reasoning"&&e.messageType!=="commandExecution"&&e.messageType!=="toolCall"&&e.messageType!=="worked"&&e.messageType!=="plan"&&e.messageType!=="plan.live"&&e.messageType!=="fileChange"&&(t||!((n=e.messageType)!=null&&n.endsWith(".live")))&&e.text.trim().length>0}function Fl(e,t){var a,i;const n=[];let o=null;for(const r of e)(r.role==="user"||!o)&&(o={key:`turn-${r.id}`,items:[]},n.push(o)),o.items.push({message:r,kind:Al(r)});const s=n.length-1;for(let r=0;r<n.length;r+=1){const l=n[r],h=(i=(a=l.items.find(y=>{var I;return(I=y.message.turnId)==null?void 0:I.trim()}))==null?void 0:a.message.turnId)==null?void 0:i.trim(),g=t!==void 0&&"liveTurnId"in t;if((t==null?void 0:t.liveOverlayActive)===!0&&(g?h===(t==null?void 0:t.liveTurnId):r===s))continue;const L=[...l.items].reverse().find(y=>Sl(y.message,(t==null?void 0:t.liveOverlayActive)===!1));L&&((t==null?void 0:t.liveOverlayActive)!==!1&&l.items.some(I=>typeof I.message.messageType=="string"&&I.message.messageType.endsWith(".live"))||(L.kind="final-assistant"))}return n}function ss(e){return e.replace(/\s+/g," ").trim()}function Pl(e){const t=ss(e);return t.length<=80?t:t.slice(0,80)}function os(e){const t=ss(e);return t.length<=80?t:t.slice(0,77)+"..."}function Nt(e){return{sessionKey:e,expandedWarmTurns:new Set,coldPage:0}}function kt(e,t){return e.sessionKey===t?e:Nt(t)}function El(e,t){const n=kt(e,t);return{...n,coldPage:n.coldPage+1}}function Bl(e,t,n){const o=kt(e,t),s=Math.max(0,Math.floor(n));return o.coldPage>=s?o:{...o,coldPage:s}}function Bn(e,t,n,o){const s=kt(e,t),a=new Set(s.expandedWarmTurns);return o?a.add(n):a.delete(n),{...s,expandedWarmTurns:a}}function Rl(e){return e.role==="user"}function Ol(e){var t;return((t=e.messageType)==null?void 0:t.endsWith(".live"))===!0}function Dl(e){var a;const t=[];let n=-1,o=0;const s=(i,r)=>{t.push({userItem:i,assistantPreview:"",toolCount:0,startIdx:r,endIdx:e.length})};for(let i=0;i<e.length;i+=1){const r=e[i];if(Rl(r)){if(n>=0)t[t.length-1].endIdx=i;else{t.push({userItem:r,assistantPreview:"",toolCount:0,startIdx:o,endIdx:e.length}),n=i,o=i;continue}n=i,s(r,i)}else if(n>=0&&t.length>0){const l=t[t.length-1],h=((a=r.text)==null?void 0:a.trim())||"";r.role==="assistant"&&!Ol(r)&&h&&(l.assistantPreview=os(h)),r.messageType==="toolCall"&&(l.toolCount+=1)}}return t}function Hl({turnCount:e,hotTurns:t,pageSize:n,coldPage:o}){const s=Math.max(0,e),a=Math.max(0,t),i=Math.max(0,s-Math.min(s,a));if(i===0)return{warmStartTurn:0,warmEndTurn:0,coldTurnCount:0};const r=Math.max(0,n),l=Math.max(0,Math.floor(o)),h=Math.min(i,r*(l+1));return{warmStartTurn:i-h,warmEndTurn:i,coldTurnCount:i-h}}function Wl({turn:e,turnCount:t,hotTurns:n,pageSize:o}){const s=Math.max(0,t),a=Math.max(0,n),i=Math.max(0,s-Math.min(s,a));if(i===0||e>=i)return 0;const r=Math.max(1,o),l=Math.max(0,Math.floor(e)),h=i-l;return Math.max(0,Math.ceil(h/r)-1)}function Rn(e,t,n){if(t.length===0)return e.slice(0);if(n>=t.length)return[];const o=t[n].startIdx;return e.slice(o)}function jl(e){const t={};for(const n of e)n.messageType==="worked"&&n.turnId&&typeof n.durationMs=="number"&&(t[n.turnId]=(t[n.turnId]??0)+n.durationMs);return t}function ql(e){const t=e.trim();if(!t)return"";if(t.startsWith("data:")||t.startsWith("blob:")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/codex-local-image?"))return t;if(t.startsWith("file://"))return`/codex-local-image?path=${encodeURIComponent(t)}`;const n=t.startsWith("/"),o=/^[A-Za-z]:[\\/]/u.test(t);return n||o?`/codex-local-image?path=${encodeURIComponent(t)}`:t}function qe(e,t={}){const n=[],o=/codex:\/\/threads\/[A-Za-z0-9-]+|https?:\/\/[^\s<>"'`,。;:!?、()[\]{}「」『』《》]+|file:\/\/[^\n<>"'`,。;:!?、[\]{}「」『』《》]+|["'](?:[A-Za-z]:[\\/]|~\/|\.{1,2}\/|\/)[^\n"']+["']|`(?:[A-Za-z]:[\\/]|~\/|\.{1,2}\/|\/)[^`\n]+`/gu;let s=0;for(const a of e.matchAll(o)){if(typeof a.index!="number")continue;const i=a.index,r=i+a[0].length;let l=a[0],h="";for(;/[.,;:!?,。;:!?、]$/u.test(l);)h=l.slice(-1)+h,l=l.slice(0,-1);const g=Xn(e,i,r,s,l),b=(g==null?void 0:g.segmentStart)??i,L=(g==null?void 0:g.segmentEnd)??r;b>s&&n.push({kind:"text",value:e.slice(s,b)}),g!=null&&g.tokenEndTrim&&(l=l.slice(0,-g.tokenEndTrim));const y=mt(l);l=y.core;const I=y.leading,k=y.trailing+h;I&&n.push({kind:"text",value:I});const E=gt(l);if(E)n.push({kind:"url",value:E,href:E}),k&&n.push({kind:"text",value:k});else if(l.startsWith("**")&&l.endsWith("**")&&l.length>4)n.push({kind:"bold",value:l.slice(2,-2)}),k&&n.push({kind:"text",value:k});else if(/^https?:\/\//u.test(l))n.push({kind:"url",value:l,href:l}),k&&n.push({kind:"text",value:k});else{const x=Ye(l);x?(n.push({kind:"file",value:l,path:x.path,displayPath:l,downloadName:ht(x.path)}),k&&n.push({kind:"text",value:k})):n.push({kind:"text",value:a[0]})}s=L}return s<e.length&&n.push({kind:"text",value:e.slice(s)}),t.applyMarkdownMarkers===!1?n:as(n)}function Ot(e,t){const n=[];let o=!1,s="";const a=i=>{i&&n.push({kind:"text",value:i})};for(const i of e){if(i.kind!=="text"){o&&(a(`${t.marker}${s}`),o=!1,s=""),n.push(i);continue}let r=i.value;for(;r.length>0;){const l=r.indexOf(t.marker);if(l<0){o?s+=r:a(r);break}const h=r.slice(0,l);if(o?s+=h:a(h),r=r.slice(l+t.marker.length),o){const g=s;g.length>0&&(!t.isValidContent||t.isValidContent(g))?n.push({kind:t.kind,value:g}):a(`${t.marker}${g}${t.marker}`),s="",o=!1}else o=!0}}return o&&a(`${t.marker}${s}`),n}function as(e){const t=o=>o.trim().length>0&&!/^\s/u.test(o)&&!/\s$/u.test(o);let n=Ot(e,{marker:"**",kind:"bold",isValidContent:t});return n=Ot(n,{marker:"~~",kind:"strikethrough",isValidContent:t}),n=Ot(n,{marker:"*",kind:"italic",isValidContent:t}),n}function Ul(e,t={}){const n=[];let o=0,s=0;const a=(i,r)=>{let l=i.indexOf("[",r);for(;l>=0;){const h=i.indexOf("]",l+1);if(h<0)return null;if(i[h+1]!=="("){l=i.indexOf("[",l+1);continue}let g=1,b=h+2,L=!1;for(;b<i.length;){const y=i[b];if(y===`
28
+ `){L=!0;break}if(y==="("&&(g+=1),y===")"&&(g-=1,g===0)){const I=i.slice(l,b+1);if(Wt(I))return{start:l,end:b+1,token:I};break}b+=1}if(L){l=i.indexOf("[",l+1);continue}l=i.indexOf("[",l+1)}return null};for(;s<e.length;){const i=a(e,s);if(!i)break;const{start:r,end:l,token:h}=i,g=Xn(e,r,l,o,h),b=(g==null?void 0:g.segmentStart)??r,L=(g==null?void 0:g.segmentEnd)??l;b>o&&n.push(...qe(e.slice(o,b),t));const y=Wt(h);if(!y){n.push(...qe(e.slice(b,L),t)),o=L,s=L;continue}const I=y.label,k=y.target,E=gt(k);if(E)n.push({kind:"url",value:I||E,href:E});else if(/^https?:\/\//u.test(k))n.push({kind:"url",value:I||k,href:k});else{const x=Ye(k);x?n.push({kind:"file",value:k,path:x.path,displayPath:I||k,downloadName:ht(x.path)}):n.push({kind:"text",value:h})}o=L,s=L}return o<e.length&&n.push(...qe(e.slice(o),t)),n}function Nl(e){const t=e.includes("`"),n=Ul(e,{applyMarkdownMarkers:!t});if(!t)return n;if(!n.some(s=>s.kind==="text"&&s.value.includes("`")))return as(n);const o=s=>{if(!s.includes("`"))return qe(s);const a=[];let i=0,r=0;for(;i<s.length;){if(s[i]!=="`"){i+=1;continue}let l=1;for(;i+l<s.length&&s[i+l]==="`";)l+=1;const h="`".repeat(l);let g=i+l,b=-1;for(;g<s.length;){const y=s.indexOf(h,g);if(y<0)break;const I=y>0&&s[y-1]==="`",k=y+l<s.length&&s[y+l]==="`",E=s.slice(i+l,y).includes(`
29
+ `);if(!I&&!k&&!E){b=y;break}g=y+1}if(b<0){i+=l;continue}i>r&&a.push(...qe(s.slice(r,i)));const L=s.slice(i+l,b);if(L.length>0){const y=Wt(L);if(y){const I=gt(y.target);if(I)a.push({kind:"url",value:y.label||I,href:I});else if(/^https?:\/\//u.test(y.target))a.push({kind:"url",value:y.label||y.target,href:y.target});else{const k=Ye(y.target);k?a.push({kind:"file",value:y.target,path:k.path,displayPath:y.label||y.target,downloadName:ht(k.path)}):a.push({kind:"code",value:L})}}else{const I=gt(L);if(I)a.push({kind:"url",value:I,href:I});else if(/^https?:\/\/[^\s]+$/u.test(L))a.push({kind:"url",value:L,href:L});else{const k=Ye(L);if(k){const E=k.line?`${k.path}:${String(k.line)}`:k.path;a.push({kind:"file",value:L,path:k.path,displayPath:E,downloadName:ht(k.path)})}else a.push({kind:"code",value:L})}}}else a.push({kind:"text",value:`${h}${h}`});i=b+l,r=i}return r<s.length&&a.push(...qe(s.slice(r))),a};return n.flatMap(s=>s.kind==="text"?o(s.value):[s])}function is(e){return e.replace(/\r\n/gu,`
30
+ `)}function xe(e){var n;return(((n=e.match(/^\s*/u))==null?void 0:n[0])??"").replace(/\t/gu," ").length}function rs(e,t){if(t<=0)return e.trimStart();let n=0,o=0;for(;n<e.length&&o<t;){const s=e[n];o+=s===" "?4:1,n+=1}return e.slice(n)}function Te(e){return e.trim().length===0}function Vt(e){const t=e.match(/^\s{0,3}(#{1,6})\s+(.+)$/u);return t?{level:t[1].length,value:t[2].trim()}:null}function dt(e){const t=e.match(/^\s{0,3}>\s?(.*)$/u);return t?t[1]??"":null}function Qe(e){var n;const t=e.match(/^\s*[-*+]\s+(.+)$/u);return((n=t==null?void 0:t[1])==null?void 0:n.trim())??null}function Vl(e){var n;const t=e.match(/^(\s*)[-*+]\s+(.+)$/u);return t?{indent:xe(t[1]??""),text:((n=t[2])==null?void 0:n.trim())??""}:null}function et(e){var n;const t=e.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.+)$/u);return t?{checked:(t[1]??" ").toLowerCase()==="x",text:((n=t[2])==null?void 0:n.trim())??""}:null}function On(e){var n;const t=e.match(/^(\s*)[-*+]\s+\[([ xX])\]\s+(.+)$/u);return t?{indent:xe(t[1]??""),item:{checked:(t[2]??" ").toLowerCase()==="x",text:((n=t[3])==null?void 0:n.trim())??""}}:null}function ls(e){var n;const t=e.match(/^(\s*)(\d+)[.)]\s+(.+)$/u);return t?{indent:xe(t[1]??""),start:Number.parseInt(t[2]??"1",10)||1,text:((n=t[3])==null?void 0:n.trim())??""}:null}function zt(e){var t;return((t=ls(e))==null?void 0:t.text)??null}function Dn(e){return ls(e)}function Kt(e){const t=e.trim();if(!t.includes("|"))return null;let n=t;n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1));const o=[];let s="",a=0;for(let i=0;i<n.length;i+=1){const r=n[i];if(r==="\\"&&n[i+1]==="|"){s+="|",i+=1;continue}if(r==="`"){let l=1;for(;n[i+l]==="`";)l+=1;s+=n.slice(i,i+l),a===0?a=l:a===l&&(a=0),i+=l-1;continue}if(r==="|"&&a===0){o.push(s.trim()),s="";continue}s+=r}return o.push(s.trim()),o.some(i=>i.length>0)?o:null}function zl(e){const t=Kt(e);if(!t||t.length===0)return null;const n=t.map(o=>{const s=o.replace(/\s+/gu,"");if(!/^:?-{3,}:?$/u.test(s))return null;const a=s.startsWith(":"),i=s.endsWith(":");return a&&i?"center":i?"right":a?"left":null});return n.every((o,s)=>o!==null||/^-+$/u.test(t[s].replace(/\s+/gu,"")))?n:null}function Hn(e,t){return e.length===t?e:e.length>t?e.slice(0,t):[...e,...Array.from({length:t-e.length},()=>"")]}function Wn(e,t){var g;if(t+1>=e.length)return null;const n=e[t],o=e[t+1],s=Kt(n),a=zl(o);if(!s||!a||s.length!==a.length)return null;const i=n.trim();if(!i.startsWith("|")&&(((g=i.match(/\|/gu))==null?void 0:g.length)??0)<2)return null;const r=s.length,l=[];let h=t+2;for(;h<e.length&&!Te(e[h]);){const b=Kt(e[h]);if(!b)break;l.push(Hn(b,r)),h+=1}return{kind:"table",headers:Hn(s,r),rows:l,alignments:a}}function Kl(e){return Te(e)||pt(e)!==null||Gt(e)||Vt(e)!==null||dt(e)!==null||et(e)!==null||Qe(e)!==null||zt(e)!==null}function Gl(e,t,n=-1){const o=[];let s=t;for(;s<e.length&&!(Kl(e[s])||n>=0&&xe(e[s])<=n);)o.push(n>=0?rs(e[s],n+1):e[s]),s+=1;const a=o.join(`
31
+ `).trim();return a?{value:a,nextIndex:s}:null}function cs(e,t){for(let n=t;n<e.length;n+=1)if(!Te(e[n]))return n;return-1}function Zl(e,t,n,o=null,s=!1){const a=[];let i=t;for(;i<e.length;){const r=e[i];if(Te(r)){const b=cs(e,i+1);if(b===-1){a.push(""),i=e.length;break}const L=o==null?void 0:o(e[b]);if(L&&L.indent===n||xe(e[b])<=n)break;a.push(""),i+=1;continue}const l=o==null?void 0:o(r);if(l&&l.indent===n)break;const h=xe(r),g=s&&(et(r)!==null||Qe(r)!==null);if(h<=n&&!g)break;a.push(h>n?rs(r,n+1):r.trimStart()),i+=1}for(;a.length>0&&Te(a[0]);)a.shift();for(;a.length>0&&Te(a[a.length-1]);)a.pop();return a.length===0?null:{blocks:ft(a.join(`
32
+ `)),nextIndex:i}}function jn(e,t,n,o=!1){const s=[];let a=t;const i=n(e[t]);if(!i)return null;const r=i.indent;for(;a<e.length;){const l=n(e[a]);if(l===null||l.indent!==r)break;const h=[l.text],g=[];for(a+=1;a<e.length;){if(Te(e[a])){const k=cs(e,a+1);if(k===-1){a=e.length;break}const E=n(e[k]);if(E&&E.indent===r){a=k;break}if(xe(e[k])<=r){a=k;break}a+=1;continue}const b=n(e[a]);if(b&&b.indent===r)break;const L=xe(e[a])>r,y=o&&(et(e[a])!==null||Qe(e[a])!==null);if(L||y){const k=Zl(e,a,r,n,o);if(k){g.push(...k.blocks),a=k.nextIndex;continue}}if(xe(e[a])<=r)break;const I=Gl(e,a,r);if(!I)break;h.push(I.value),a=I.nextIndex}s.push(g.length>0?{paragraphs:h,children:g}:{paragraphs:h})}return s.length>0?{items:s,nextIndex:a}:null}function Gt(e){return/^\s{0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/u.test(e.trim())}function pt(e){const t=e.match(/^\s{0,3}(```+|~~~+)\s*([^\s`~][^`]*)?\s*$/u);return t?{marker:t[1],language:(t[2]??"").trim()}:null}function ft(e){var a;const n=is(e).split(`
33
+ `),o=[];let s=0;for(;s<n.length;){if(Te(n[s])){s+=1;continue}const i=pt(n[s]);if(i){s+=1;const k=[];for(;s<n.length;){if(n[s].trim()===i.marker){s+=1;break}k.push(n[s]),s+=1}o.push({kind:"codeBlock",language:i.language,value:k.join(`
34
+ `)});continue}if(Gt(n[s])){o.push({kind:"thematicBreak"}),s+=1;continue}const r=Vt(n[s]);if(r){o.push({kind:"heading",level:r.level,value:r.value}),s+=1;continue}if(dt(n[s])!==null){const k=[];for(;s<n.length;){const E=dt(n[s]);if(E===null)break;k.push(E),s+=1}o.push({kind:"blockquote",value:k.join(`
35
+ `).trim()});continue}const h=Wn(n,s);if(h){o.push(h),s+=2+h.rows.length;continue}if(et(n[s])!==null){const k=[],E=((a=On(n[s]))==null?void 0:a.indent)??0;for(;s<n.length;){const x=On(n[s]);if(x===null||x.indent!==E)break;k.push(x.item),s+=1}if(k.length>0){o.push({kind:"taskList",items:k});continue}}const b=Qe(n[s]);if(b!==null){const k=jn(n,s,Vl);if(k){o.push({kind:"unorderedList",items:k.items}),s=k.nextIndex;continue}if(b.length>0){o.push({kind:"unorderedList",items:[{paragraphs:[b]}]}),s+=1;continue}}const L=zt(n[s]);if(L!==null){const k=Dn(n[s]),E=jn(n,s,Dn,!0);if(E){o.push({kind:"orderedList",items:E.items,start:(k==null?void 0:k.start)??1}),s=E.nextIndex;continue}if(L.length>0){o.push({kind:"orderedList",items:[{paragraphs:[L]}],start:(k==null?void 0:k.start)??1}),s+=1;continue}}const y=[];for(;s<n.length&&!(Te(n[s])||pt(n[s])||Gt(n[s])||Vt(n[s])||Wn(n,s)||dt(n[s])!==null||et(n[s])!==null||Qe(n[s])!==null||zt(n[s])!==null);)y.push(n[s]),s+=1;const I=y.join(`
36
+ `).trim();I&&o.push({kind:"paragraph",value:I})}return o}function Jl(e){if(!e.includes("![")||!e.includes("]("))return ft(e);const t=[],n=/!\[([^\]]*)\]\(([^)\n]+)\)/gu;let o=0;for(const s of e.matchAll(n)){const[a,i,r]=s;if(typeof s.index!="number")continue;const l=s.index,h=l+a.length,g=ql(r.trim());g&&(l>o&&t.push(...ft(e.slice(o,l))),t.push({kind:"image",url:g,alt:i.trim(),markdown:a}),o=h)}return o<e.length&&t.push(...ft(e.slice(o))),t}function qn(e){const n=is(e).split(`
37
+ `),o=[];let s=0,a=0;const i=r=>{if(r<=a)return;const l=n.slice(a,r).join(`
38
+ `);o.push(...Jl(l))};for(;s<n.length;){const r=pt(n[s]);if(!r){s+=1;continue}i(s),s+=1;const l=[];for(;s<n.length;){if(n[s].trim()===r.marker){s+=1;break}l.push(n[s]),s+=1}o.push({kind:"codeBlock",language:r.language,value:l.join(`
39
+ `)}),a=s}return i(n.length),o.length>0?o:[{kind:"paragraph",value:e}]}const Xl=300,Yl=1200,Ql=300,ec=250;function tc(e){const{getCwd:t,isVideoMediaUrl:n}=e,o=U(null),s=U(0);let a=null;const i=new Map,r=new Map,l=new Map,h=new Map;function g($,M,D,G){for($.has(M)&&$.delete(M),$.set(M,D);$.size>G;){const ae=$.keys().next().value;if(ae===void 0)break;$.delete(ae)}return D}function b(){return o.value?Promise.resolve():(a||(a=Co(()=>import("./common-BeuopZEI.js"),[]).then($=>{o.value=$.default,h.clear(),l.clear(),s.value+=1}).finally(()=>{a=null})),a)}function L(){return!!o.value}function y($){const M=r.get($);return M?(r.delete($),r.set($,M),M):g(r,$,Nl($),Yl)}function I($){const M=$.trim();if(!M)return"#";const D=N=>N.startsWith("/")||/^[A-Za-z]:[\\/]/u.test(N),G=Ye(M),ae=(G==null?void 0:G.path)??M,B=Jn(ae,t());if(D(B)){const N=B.startsWith("/")?B:`/${B}`;return`/codex-local-browse${encodeURI(N)}`}return"#"}function k($){const M=$.trim();if(!M)return"";try{const D=new URL(M,window.location.href);return D.pathname.startsWith("/codex-local-browse")?`${`/codex-local-edit${D.pathname.slice(19)}`}${D.search}${D.hash}`:""}catch{return""}}function E($){const M=i.get($.id);if(M&&M.text===$.text&&M.cwd===t())return i.delete($.id),i.set($.id,M),M.blocks;const D=qn($.text);return g(i,$.id,{text:$.text,cwd:t(),blocks:D},Xl).blocks}function x($){return $.replace(/&/gu,"&amp;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;").replace(/"/gu,"&quot;").replace(/'/gu,"&#39;")}function C($){var D;const M=((D=$.trim().split(/\s+/u)[0])==null?void 0:D.toLowerCase())??"";return M?es[M]??M:""}function A($,M){const D=C($);if(!D)return x(M);const G=o.value;if(!G)return x(M);try{if(G.getLanguage(D))return G.highlight(M,{language:D,ignoreIllegals:!0}).value}catch{}return x(M)}function _($,M){return Pt(R($,M))}function R($,M){const D=`${s.value}\0${C($)}\0${$}\0${M}`,G=h.get(D);return G!==void 0?(h.delete(D),h.set(D,G),G):g(h,D,A($,M),ec)}function O($){return y($).map(M=>M.kind==="text"?x(M.value):M.kind==="bold"?`<strong class="message-bold-text">${x(M.value)}</strong>`:M.kind==="italic"?`<em class="message-italic-text">${x(M.value)}</em>`:M.kind==="strikethrough"?`<s class="message-strikethrough-text">${x(M.value)}</s>`:M.kind==="file"?`<a class="message-file-link" href="${x(I(M.path))}" target="_blank" rel="noopener noreferrer" title="${x(M.path)}">${x(M.displayPath)}</a>`:M.kind==="url"?`<a class="message-file-link" href="${x(M.href)}" target="_blank" rel="noopener noreferrer" title="${x(M.href)}">${x(M.value)}</a>`:`<code class="message-inline-code">${x(M.value)}</code>`).join("")}function q($){return $.paragraphs.map(M=>`<div class="message-list-item-text message-list-item-paragraph">${O(M)}</div>`).join("")}function ee($){var G;const M=q($),D=((G=$.children)==null?void 0:G.map(ae=>fe(ae)).join(""))??"";return Pt(M+D)}function V($){return $?` style="text-align:${$}"`:""}function fe($){if($.kind==="paragraph")return`<p class="message-text">${O($.value)}</p>`;if($.kind==="heading"){const M=Math.min(6,Math.max(1,Math.trunc($.level))),D=Yn(M),G=`message-heading ${Qn(M)}`;return`<${D} class="${G}">${O($.value)}</${D}>`}if($.kind==="blockquote")return`<blockquote class="message-blockquote">${O($.value)}</blockquote>`;if($.kind==="unorderedList")return`<ul class="message-list message-list-unordered">${$.items.map(D=>`<li class="message-list-item"><div class="message-list-item-content">${ee(D)}</div></li>`).join("")}</ul>`;if($.kind==="taskList")return`<ul class="message-list message-task-list">${$.items.map(D=>`<li class="message-task-item"><span class="message-task-checkbox" data-checked="${D.checked?"true":"false"}">${D.checked?"☑":"☐"}</span><div class="message-list-item-text">${O(D.text)}</div></li>`).join("")}</ul>`;if($.kind==="orderedList"){const M=$.items.map(D=>`<li class="message-list-item"><div class="message-list-item-content">${ee(D)}</div></li>`).join("");return`<ol class="message-list message-list-ordered" start="${$.start}">${M}</ol>`}if($.kind==="table"){const M=$.headers.map((ae,B)=>`<th class="message-table-head-cell"${V($.alignments[B]??null)}>${O(ae)}</th>`).join(""),D=$.rows.map(ae=>'<tr class="message-table-body-row">'+ae.map((B,N)=>`<td class="message-table-cell"${V($.alignments[N]??null)}>${O(B)}</td>`).join("")+"</tr>").join(""),G=D?`<tbody>${D}</tbody>`:"";return`<div class="message-table-wrap"><table class="message-table"><thead><tr>${M}</tr></thead>${G}</table></div>`}return $.kind==="codeBlock"?`<div class="message-code-block">${$.language?`<div class="message-code-language">${x($.language)}</div>`:""}<pre class="message-code-pre"><code class="hljs">${_($.language,$.value)}</code></pre></div>`:$.kind==="thematicBreak"?'<hr class="message-divider">':n($.url)?`<video class="message-image-preview message-video-preview message-markdown-image" src="${x($.url)}" controls preload="metadata"></video>`:`<img class="message-image-preview message-markdown-image" src="${x($.url)}" alt="${x($.alt||"Embedded message image")}" loading="lazy">`}function Re($){const M=`${t()}\0${s.value}\0${$}`,D=l.get(M);if(D&&D.text===$&&D.cwd===t()&&D.highlightVersion===s.value)return l.delete(M),l.set(M,D),D.html;const G=qn($).map(B=>fe(B)).join(""),ae=Pt(G);return g(l,M,{text:$,cwd:t(),highlightVersion:s.value,html:ae},Ql).html}function ze(){i.clear(),r.clear(),l.clear(),h.clear()}return{highlightCacheVersion:s,hasHighlightLoaded:L,ensureHighlightJsLoaded:b,getInlineSegments:y,toBrowseUrl:I,toEditUrlFromBrowseHref:k,getMessageBlocks:E,renderListItemContentAsHtml:ee,renderCachedHighlightedCodeAsHtml:_,renderMarkdownBlocksAsHtml:Re,clearRenderCaches:ze}}const nc={key:0,class:"conversation-switching-bar",role:"status"},sc={key:1,class:"conversation-loading"},oc={key:2,class:"conversation-empty"},ac={key:0,class:"conversation-load-more"},ic=["disabled"],rc={key:1,class:"conversation-load-more conversation-warm-collapse"},lc=["disabled"],cc=["id"],uc={class:"message-row","data-role":"system"},dc={class:"message-stack","data-role":"system"},fc={class:"message-row","data-role":"system","data-message-type":"fileChange"},hc={class:"message-stack","data-role":"system"},mc={key:0,class:"conversation-item conversation-item-fold","data-role":"system","data-message-type":"processFold"},gc={class:"message-row","data-role":"system"},pc={class:"message-stack","data-role":"system"},vc={key:0,class:"work-block-list"},kc=["id","data-role","data-message-type"],yc={key:0,class:"message-row thread-compaction-row","data-role":"system"},wc={class:"thread-compaction-inline thread-compaction-inline--pending",role:"status"},bc={key:1,class:"message-row thread-compaction-row","data-role":"system"},Cc={class:"thread-compaction-inline thread-compaction-inline--done",role:"status"},$c={key:2,class:"message-row","data-role":"system"},xc={class:"message-stack","data-role":"system"},Tc={class:"work-block-list"},_c=["data-role","data-message-type"],Ic=["data-role"],Lc=["data-role"],Mc={key:5,class:"message-row","data-role":"system","data-message-type":"plan"},Ac={class:"message-stack","data-role":"system"},Sc={class:"thread-plan-record"},Fc={class:"thread-plan-record-header"},Pc={key:0,class:"thread-plan-record-explanation"},Ec={key:1,class:"thread-plan-record-steps"},Bc=["data-status"],Rc={class:"thread-plan-record-marker","aria-hidden":"true"},Oc=["data-role","data-message-type"],Dc=["data-role"],Hc=["data-role"],Wc=["data-role"],jc=["onClick"],qc=["src"],Uc=["src","alt"],Nc={key:1,class:"message-file-attachments"},Vc=["href","title"],zc={key:2,class:"message-skill-attachments"},Kc=["href","title"],Gc={class:"message-skill-chip-prefix"},Zc={class:"message-skill-chip-name"},Jc=["data-role"],Xc={key:0,class:"automation-message-label"},Yc={key:0},Qc={key:1,class:"work-summary-wrap","aria-live":"polite"},eu={class:"work-summary-text"},tu={key:0,class:"message-text"},nu={key:2,class:"message-blockquote"},su={key:3,class:"message-list message-list-unordered"},ou=["innerHTML"],au={key:4,class:"message-list message-task-list"},iu=["data-checked"],ru={class:"message-list-item-text"},lu=["start"],cu=["innerHTML"],uu={key:6,class:"message-table-wrap"},du={class:"message-table"},fu={key:0},hu={key:7,class:"message-code-block"},mu={key:0,class:"message-code-language"},gu={class:"message-code-pre"},pu=["innerHTML"],vu={key:8,class:"message-divider"},ku={key:9,class:"message-text"},yu=["onClick"],wu=["src"],bu=["src","alt","onError"],Cu=["href","onClick"],$u=["title","aria-label"],xu=["aria-label"],Tu=["src"],_u=["src","alt"],Iu=16,Un=30,Nn=20,Lu=200,Mu=le({__name:"ThreadConversation",props:{messages:{},pendingRequests:{},liveOverlay:{},liveTurnId:{},isLoading:{type:Boolean},activeThreadId:{},cwd:{},hasMorePersistedAbove:{type:Boolean},isLoadingPersistedAbove:{type:Boolean},loadEarlierMessages:{type:Function}},emits:["forkThread","rollback","respondServerRequest","fileChangesChanged"],setup(e,{expose:t,emit:n}){function o(u){return Ho(u,a.cwd,J)}function s(u){return Ve(u,a.cwd)}const a=e,i=tc({getCwd:()=>a.cwd,isVideoMediaUrl:ct}),{highlightCacheVersion:r,hasHighlightLoaded:l,ensureHighlightJsLoaded:h,getInlineSegments:g,toBrowseUrl:b,toEditUrlFromBrowseHref:L,getMessageBlocks:y,renderListItemContentAsHtml:I,renderCachedHighlightedCodeAsHtml:k,renderMarkdownBlocksAsHtml:E,clearRenderCaches:x}=i,C=Jo({getMessages:()=>a.messages,getLiveOverlay:()=>a.liveOverlay,isCommandMessage:Ke}),{hiddenGroupedCommandIds:A,isCommandExpanded:_,isCommandCompact:R,isCommandOutputCondensed:O,toggleCommandExpand:q,getWorkBlockCommands:ee,pruneCommandIdSets:V}=C,fe=Yo({toEditUrlFromBrowseHref:L}),{isFileLinkContextMenuVisible:Re,fileLinkContextMenuX:ze,fileLinkContextMenuY:$,fileLinkContextBrowseUrl:M,fileLinkContextEditUrl:D,handleConversationContextMenu:G,closeFileLinkContextMenu:ae}=fe,{isMobile:B}=$o(),N=Go({getMessages:()=>a.messages,getLiveTurnId:()=>a.liveTurnId??"",isFileChangeMessage:$t,isCopyableAssistantMessage:nn,isReasoningMessage:wt,isPlanMessage:yt,isFoldMember:kn,getHiddenGroupedCommandIds:()=>A.value,isMobile:()=>B.value}),{anchoredFileChangeSummaryByAnchorId:ue,hiddenFileChangeMessageIds:ge,isDiffViewerFileListOpen:ie,diffViewerChanges:re,activeDiffViewerChange:pe,activeDiffViewerLines:j,toggleFileChangeSummary:ve,isFileChangeSummaryExpanded:_e,openDiffViewer:tt,closeDiffViewer:Ie,toggleDiffViewerFileList:us,closeDiffViewerFileList:ds,selectDiffViewerChange:fs,readAnchoredFileChangeSummaryById:ke,isFileChangeSummaryExpandedById:hs,toggleFileChangeSummaryById:ms,readStandaloneFileChangeSummary:we,isFileChangeSummaryVisible:Jt,pruneFileChangeSummaryIds:gs}=N,ps=Zo({getMessages:()=>a.messages,isCopyableAssistantMessage:nn,isPlanMessage:yt,planStepCopyMarker:yn,buildFileChangeCopyText:o,getAnchoredFileChangeSummaries:()=>ue.value}),{copiedResponseAnchorId:vs,forkableTurnIndexByAnchorId:ks,showCopyResponseButton:ys,isCopyableUserMessage:ws,copyUserMessage:bs,showForkResponseButton:Cs,copyResponse:$s}=ps,{buildFeedbackMailto:xs,feedbackMailtoBase:Ts,recordVisibleFailure:_s}=Kn(),{t:J}=me(),Xt=Ts();function Is(u,p){_s(p);const F=u.currentTarget;F instanceof HTMLAnchorElement&&(F.href=xs())}function Ke(u){return u.messageType==="commandExecution"&&!!u.commandExecution}function Yt(u){return u.messageType==="compaction.pending"}function Qt(u){return u.messageType==="compaction.done"}function yt(u){return u.messageType==="plan"||u.messageType==="plan.live"}function wt(u){return u.messageType==="reasoning"&&!!u.reasoning}const bt=U(new Set);function en(u){return bt.value.has(u.id)}function tn(u){const p=new Set(bt.value);p.has(u.id)?p.delete(u.id):p.add(u.id),bt.value=p}function Ct(u){return u.messageType==="toolCall"&&!!u.toolCall}function Ls(u){return u.messageType==="turnError"}function $t(u){return u.messageType==="fileChange"&&u.fileChangeStatus==="completed"&&Array.isArray(u.fileChanges)&&u.fileChanges.length>0}function Ms(u){return Ke(u)||Ct(u)||$t(u)||Yt(u)||Qt(u)||u.messageType==="plan"?!1:Ml(u)}function nn(u){return u.role==="assistant"&&!Ke(u)&&u.messageType!=="worked"&&!(u.messageType??"").endsWith(".live")}const xt=n,Le=U(null),sn=U(null),As=Qo({isVideo:ct}),{modalImageUrl:nt,modalIsVideo:Ss,markdownImageFailureVersion:Fs,isMarkdownImageFailed:Ps,onMarkdownImageError:Es,openImageModal:on,closeImageModal:st}=As,Bs=Xo({getActiveThreadId:()=>a.activeThreadId,getCwd:()=>a.cwd,onFileChangesChanged:()=>xt("fileChangesChanged",a.activeThreadId),updateThreadFileChanges:Io,t:J}),{fileChangeActionKey:an,isFileChangeActionable:rn,fileChangeActionStatus:ln,fileChangeActionErrorText:cn,fileChangeNextAction:un,fileChangeActionLabel:dn,runFileChangeAction:Rs,resetFileChangeActions:Os}=Bs,Ce=U(null),Ds=P(()=>{const u=Ce.value;return u?u.kind==="edit-message"?J("Rollback this turn?"):u.action==="undo"?J("Undo file changes?"):J("Redo file changes?"):""}),Hs=P(()=>{const u=Ce.value;return u?u.kind==="edit-message"?J("This rolls the thread back to this turn so you can edit the message. Later replies will be removed."):u.filePathLabel?u.action==="undo"?J("Undo the changes to {file}? This modifies the working tree and Codex cannot revert it automatically.",{file:u.filePathLabel}):J("Redo the changes to {file}? This reapplies the edits to the working tree.",{file:u.filePathLabel}):u.action==="undo"?J("Undo the file changes from this turn? This modifies the working tree and Codex cannot revert it automatically."):J("Redo the file changes from this turn? This reapplies the edits to the working tree."):""}),Me=U(!0);let Ee=0,be=0,ot=0,Ge=null;const fn=new WeakSet,Ae=U(Nt(a.activeThreadId)),hn=P(()=>kt(Ae.value,a.activeThreadId)),Se=U(!1),Tt=P(()=>a.messages.filter(u=>!yt(u))),Oe=P(()=>Dl(Tt.value)),_t=P(()=>Hl({turnCount:Oe.value.length,hotTurns:Un,pageSize:Nn,coldPage:hn.value.coldPage})),It=P(()=>_t.value.warmStartTurn),De=P(()=>_t.value.warmEndTurn),mn=P(()=>_t.value.coldTurnCount),gn=P(()=>mn.value>0),Lt=P(()=>hn.value.expandedWarmTurns),Ws=P(()=>{const u=Tt.value,p=Oe.value,F=[],H=Lt.value;for(let ne=It.value;ne<De.value;ne+=1){const de=p[ne];if(!de)continue;const T={turn:ne,userText:os(de.userItem.text),assistantPreview:de.assistantPreview,toolCount:de.toolCount,expanded:H.has(ne)},z=H.has(ne)?u.slice(de.startIdx,de.endIdx).map(X=>({message:X})):[];F.push({key:`warm-${ne}`,warm:T,warmItems:z,processItems:[],fileChangeAnchorIds:[]})}const Y=Rn(u,p,De.value),v=Y[0];if(!v)return F;const he=a.messages.findIndex(ne=>ne.id===v.id),Fe=he>=0?a.messages.slice(he):Y;for(const ne of Fl(Fe,{liveOverlayActive:a.liveOverlay!==null,liveTurnId:a.liveTurnId})){const de=ne.items.find(Z=>Z.kind==="user"),T=ne.items.find(Z=>Z.kind==="final-assistant"),z=ne.items.filter(Z=>Z!==de&&Z!==T&&Z.message.messageType!=="worked").map(Z=>({message:Z.message,presentation:Z.kind==="plan"?"plan":"process"})),X=ne.items.map(Z=>Z.message.id).filter(Z=>!!ke(Z));F.push({key:ne.key,warmItems:[],request:de?{message:de.message}:void 0,processItems:z,fileChangeAnchorIds:X,finalItem:T?{message:T.message,presentation:"final-assistant"}:void 0})}return F}),js=P(()=>jl(a.messages));function qs(u){var F,H;const p=((F=u.request)==null?void 0:F.message.turnId)??((H=u.finalItem)==null?void 0:H.message.turnId);return p?js.value[p]:void 0}function pn(){Ae.value=El(Ae.value,a.activeThreadId)}function Us(u){Ae.value=Bn(Ae.value,a.activeThreadId,u,!Lt.value.has(u))}const vn=P(()=>Oe.value.map((u,p)=>({turn:p,text:Pl(u.userItem.text)}))),Ns=P(()=>Math.max(0,vn.value.length-1)),Vs=P(()=>{const u=new Map;return Oe.value.forEach((p,F)=>{u.set(p.userItem.id,F)}),u});function Mt(u){return`question-anchor-${u}`}function zs(u){const p=Vs.value.get(u.id);if(p!==void 0&&!(p<De.value))return Mt(p)}function Ks(u){if(u<De.value){let p=Ae.value;if(u<It.value){const F=Wl({turn:u,turnCount:Oe.value.length,hotTurns:Un,pageSize:Nn});p=Bl(p,a.activeThreadId,F)}p=Bn(p,a.activeThreadId,u,!0),Ae.value=p}Me.value=!1,ut().then(()=>{const p=Le.value,F=document.getElementById(Mt(u));if(!p||!F)return;const H=F.getBoundingClientRect(),Y=p.getBoundingClientRect(),v=p.scrollTop+H.top-Y.top-12;p.scrollTo({top:Math.max(0,v),behavior:"smooth"})})}const Gs=P(()=>{const u=Tt.value,p=Oe.value,F=[];for(let he=It.value;he<De.value;he+=1){if(!Lt.value.has(he))continue;const Fe=p[he];Fe&&F.push(...u.slice(Fe.startIdx,Fe.endIdx))}const H=Rn(u,p,De.value),Y=H[0];if(!Y)return F;const v=a.messages.findIndex(he=>he.id===Y.id);return F.push(...v>=0?a.messages.slice(v):H),F}),at=P(()=>_l(Gs.value)),Ze=P(()=>{var p;const u=new Map;for(const F of at.value){const H=((p=F.messages[0])==null?void 0:p.id)??"";H&&u.set(H,F)}return u}),Zs=P(()=>{const u=new Set;for(const p of at.value)for(const F of p.messages)u.add(F.id);return u}),Js=P(()=>{var F;const u=new Set,p=H=>A.value.has(H.id)||ge.value.has(H.id);for(const H of at.value)Tl(H,p)&&u.add(((F=H.messages[0])==null?void 0:F.id)??"");return u}),Xs=P(()=>{const u=new Set;for(const p of at.value)u.add(p.turnId);return u});function Ys(u){return Ze.value.has(u.id)}function kn(u){return Zs.value.has(u.id)}function Qs(u){var p;return((p=Ze.value.get(u.id))==null?void 0:p.messages)??[]}function eo(u){return Tr(Qs(u))}function to(u){var p;return u.type==="batch"?`tool-batch-${u.kind}-${((p=u.messages[0])==null?void 0:p.id)??""}`:u.message.id}function no(u){const p=Ze.value.get(u.id);return p?Il(p,{t:J,formatDuration:Ht}):""}function so(u){var p;return((p=Ze.value.get(u.id))==null?void 0:p.running)??!1}function oo(u){var p;return((p=Ze.value.get(u.id))==null?void 0:p.hasOutsideContent)??!0}function ao(u){return u.messageType==="worked"}const io=P(()=>a.hasMorePersistedAbove===!0),ro=P(()=>!Me.value&&(a.messages.length>0||a.pendingRequests.length>0||!!a.liveOverlay));function yn(u){switch(u){case"completed":return"[x]";case"inProgress":return"[~]";default:return"[ ]"}}function lo(u){const p=ks.value[u];typeof p=="number"&&a.activeThreadId&&xt("forkThread",{threadId:a.activeThreadId,turnIndex:p})}const At=P(()=>{const u={};for(const p of a.messages){if(p.role!=="user"||typeof p.turnIndex!="number")continue;const F=typeof p.turnId=="string"&&p.turnId.length>0?p.turnId:"";!F||p.text.trim().length===0||(u[p.id]=F)}return u});function co(u){return typeof At.value[u.id]=="string"}function uo(u){At.value[u]&&(Ce.value={kind:"edit-message",messageId:u})}function wn(u,p){an(u)&&(Ce.value={kind:"file-change",summary:u,action:p})}function bn(u,p){!u||!an(u)||!p.path||(Ce.value={kind:"file-change",summary:u,action:"undo",filePaths:[p.path],filePathLabel:s(p.path)})}function fo(){const u=Ce.value;if(Ce.value=null,!!u){if(u.kind==="edit-message"){const p=At.value[u.messageId];p&&xt("rollback",{turnId:p});return}Rs(u.summary,u.action,u.filePaths)}}function ho(){const u=Le.value,p=sn.value;!u||!p||(u.scrollTop=u.scrollHeight,p.scrollIntoView({block:"end"}))}function mo(u){return u.scrollHeight-(u.scrollTop+u.clientHeight)<=Iu}function go(){if(Le.value&&Me.value){it();return}}function it(){Le.value&&ho()}function St(){return Me.value}function Cn(){if(!St()){ot=0,be=0;return}if(it(),ot-=1,ot<=0){be=0;return}be=requestAnimationFrame(Cn)}function rt(u=6){St()&&(be&&(cancelAnimationFrame(be),be=0),ot=Math.max(u,1),be=requestAnimationFrame(Cn))}function $n(){rt(3)}function xn(){Me.value=!0,it(),rt(4)}async function Tn(){var Y;const u=Le.value;if(!u||!a.hasMorePersistedAbove||Se.value||a.isLoadingPersistedAbove===!0)return;Se.value=!0;const p=a.activeThreadId,F=u.scrollHeight,H=u.scrollTop;try{await((Y=a.loadEarlierMessages)==null?void 0:Y.call(a,p)),await ut(),a.activeThreadId===p&&(u.scrollTop=H+(u.scrollHeight-F))}finally{Se.value=!1}}t({jumpToLatest:xn});function po(){if(!St())return;const u=Le.value;if(!u)return;const p=u.querySelectorAll("img.message-image-preview");for(const F of p)F.complete||fn.has(F)||(fn.add(F),F.addEventListener("load",$n,{once:!0}),F.addEventListener("error",$n,{once:!0}))}async function lt(){return Ge||(Ge=ut().then(()=>new Promise(u=>{Ee&&cancelAnimationFrame(Ee),Ee=requestAnimationFrame(()=>{Ee=0,Ge=null,go(),po(),rt(),u()})})),Ge)}$e(()=>a.messages,async u=>{if(a.isLoading)return;const p=new Set(u.filter(F=>F.messageType==="commandExecution"&&F.commandExecution).map(F=>F.id));V(p),gs(),await lt()}),$e(()=>a.messages.some(u=>u.text.includes("```")),u=>{!u||l()||h()},{immediate:!0}),$e(()=>a.pendingRequests,async()=>{a.isLoading||await lt()},{deep:!0}),$e(()=>a.liveOverlay,async u=>{u&&Me.value&&(await ut(),it(),rt(8))},{deep:!0}),$e(()=>a.isLoading,async u=>{u||await lt()}),$e(()=>a.activeThreadId,async()=>{Me.value=!0,nt.value="",Se.value=!1,Os(),Ae.value=Nt(a.activeThreadId),await lt()},{flush:"post"});function vo(){const u=Le.value;!u||a.isLoading||(Me.value=mo(u),u.scrollTop<Lu&&!Se.value&&(gn.value?pn():a.hasMorePersistedAbove===!0&&Tn()))}const Ft=/\.(mp4|m4v|webm|mov|mkv|ogv|ogg|mpeg|avi)$/iu;function ct(u){const p=u.trim();if(!p)return!1;if(p.startsWith("data:video/"))return!0;try{const F=new URL(p,window.location.href);return Ft.test(F.pathname)?!0:F.pathname==="/codex-local-image"?Ft.test(F.searchParams.get("path")??""):!1}catch{return Ft.test(p)}}return vt(()=>{x(),Ee&&(cancelAnimationFrame(Ee),Ee=0),be&&(cancelAnimationFrame(be),be=0)}),(u,p)=>(c(),f(W,null,[m("section",{class:"conversation-root",onContextmenuCapture:p[4]||(p[4]=(...F)=>d(G)&&d(G)(...F))},[e.isLoading&&e.messages.length>0?(c(),f("div",nc,w(d(J)("Loading messages...")),1)):S("",!0),e.isLoading&&e.messages.length===0?(c(),f("p",sc,w(d(J)("Loading messages...")),1)):e.messages.length===0&&e.pendingRequests.length===0&&!e.liveOverlay?(c(),f("p",oc,w(d(J)("No messages in this thread yet.")),1)):(c(),f("ul",{key:3,ref_key:"conversationListRef",ref:Le,class:"conversation-list",onScroll:vo},[io.value?(c(),f("li",ac,[m("button",{type:"button",class:"load-more-button",disabled:Se.value||e.isLoadingPersistedAbove,onClick:Tn},w(Se.value||e.isLoadingPersistedAbove?d(J)("Loading…"):d(J)("Load earlier messages")),9,ic)])):S("",!0),gn.value?(c(),f("li",rc,[m("button",{type:"button",class:"load-more-button",disabled:Se.value,onClick:pn},w(d(J)("Load earlier ({n} turns)",{n:mn.value})),9,lc)])):S("",!0),(c(!0),f(W,null,K(Ws.value,F=>(c(),se(sl,{key:F.key,"turn-key":F.key,warm:F.warm,"warm-items":F.warmItems,request:F.request,"process-items":F.processItems,"final-item":F.finalItem,"file-change-anchor-ids":F.fileChangeAnchorIds,"duration-ms":qs(F)},{"warm-card":We(({warm:H})=>[m("li",{id:Mt(H.turn),class:"conversation-item conversation-item-warm-card","data-role":"system","data-message-type":"warmTurn"},[m("div",uc,[m("div",dc,[Q(ul,{"user-text":H.userText,"assistant-preview":H.assistantPreview,"tool-count":H.toolCount,expanded:H.expanded,onToggle:Y=>Us(H.turn)},null,8,["user-text","assistant-preview","tool-count","expanded","onToggle"])])])],8,cc)]),"file-change":We(({anchorMessageId:H})=>[m("div",fc,[m("div",hc,[d(Jt)(d(ke)(H))?(c(),se(An,{key:0,summary:d(ke)(H),expanded:d(hs)(H),cwd:a.cwd,actionable:d(rn)(d(ke)(H)),"action-status":d(ln)(d(ke)(H)),"action-error-text":d(cn)(d(ke)(H)),"next-action":d(un)(d(ke)(H)),"action-label":d(dn)(d(ke)(H)),onToggle:Y=>d(ms)(H),onOpenDiff:Y=>d(tt)(d(ke)(H),Y),onRequestAction:Y=>wn(d(ke)(H),Y),onRequestFileAction:Y=>bn(d(ke)(H),Y)},null,8,["summary","expanded","cwd","actionable","action-status","action-error-text","next-action","action-label","onToggle","onOpenDiff","onRequestAction","onRequestFileAction"])):S("",!0)])])]),default:We(({item:H,section:Y})=>[(c(!0),f(W,null,K([H.message],v=>{var he,Fe,ne,de;return c(),f(W,{key:v.id},[Ys(v)&&!Js.value.has(v.id)?(c(),f("li",mc,[m("div",gc,[m("div",pc,[Q(ar,{label:no(v),running:so(v),"has-outside-content":oo(v)},{default:We(()=>[(c(!0),f(W,null,K(eo(v),T=>(c(),f(W,{key:to(T)},[T.type==="batch"?(c(),se(Ur,{key:0,kind:T.kind,messages:T.messages},null,8,["kind","messages"])):(c(!0),f(W,{key:1},K([T.message],z=>(c(),f(W,{key:z.id},[!d(A).has(z.id)&&!d(ge).has(z.id)?(c(),f(W,{key:0},[Ke(z)?(c(),f("div",vc,[(c(!0),f(W,null,K(d(ee)(z),(X,Z)=>(c(),se(Pn,{key:`work-cmd-${X.id}`,command:X,"step-index":Z,expanded:d(_)(X),compact:d(R)(X),"output-condensed":d(O)(X),onToggle:_n=>d(q)(X)},null,8,["command","step-index","expanded","compact","output-condensed","onToggle"]))),128))])):Ct(z)?(c(),se(Ut,{key:1,message:z},null,8,["message"])):wt(z)?(c(),se(Fn,{key:2,message:z,expanded:en(z),"content-html":d(E)(z.text),onToggle:X=>tn(z)},null,8,["message","expanded","content-html","onToggle"])):S("",!0)],64)):S("",!0)],64))),128))],64))),128))]),_:2},1032,["label","running","has-outside-content"])])])])):!kn(v)&&!d(A).has(v.id)&&!d(ge).has(v.id)&&!(ao(v)&&Xs.value.has(v.turnId??""))&&!Ms(v)?(c(),f("li",{key:1,id:zs(v),class:te(["conversation-item",{"conversation-item-request":Y==="request","conversation-item-process":Y==="process"||H.presentation==="process","conversation-item-final":Y==="final"||H.presentation==="final-assistant","conversation-item-plan":H.presentation==="plan"}]),"data-role":v.role,"data-message-type":v.messageType||""},[Yt(v)?(c(),f("div",yc,[m("div",wc,[p[6]||(p[6]=m("span",{class:"thread-compaction-spinner","aria-hidden":"true"},null,-1)),m("span",null,w(d(J)("Compacting thread context…")),1)])])):Qt(v)?(c(),f("div",bc,[m("div",Cc,w(d(J)("Context compacted")),1)])):Ke(v)?(c(),f("div",$c,[m("div",xc,[m("div",Tc,[(c(!0),f(W,null,K(d(ee)(v),(T,z)=>(c(),se(Pn,{key:`work-cmd-${T.id}`,command:T,"step-index":z,expanded:d(_)(T),compact:d(R)(T),"output-condensed":d(O)(T),onToggle:X=>d(q)(T)},null,8,["command","step-index","expanded","compact","output-condensed","onToggle"]))),128))])])])):Ct(v)?(c(),se(Ut,{key:3,message:v},null,8,["message"])):$t(v)?(c(),f("div",{key:4,class:"message-row","data-role":v.role,"data-message-type":v.messageType||""},[m("div",{class:"message-stack","data-role":v.role},[m("article",{class:"message-body","data-role":v.role},[d(Jt)(d(we)(v))?(c(),se(An,{key:0,summary:d(we)(v),expanded:d(_e)(v),cwd:a.cwd,actionable:d(rn)(d(we)(v)),"action-status":d(ln)(d(we)(v)),"action-error-text":d(cn)(d(we)(v)),"next-action":d(un)(d(we)(v)),"action-label":d(dn)(d(we)(v)),onToggle:T=>d(ve)(v),onOpenDiff:T=>d(tt)(d(we)(v),T),onRequestAction:T=>wn(d(we)(v),T),onRequestFileAction:T=>bn(d(we)(v),T)},null,8,["summary","expanded","cwd","actionable","action-status","action-error-text","next-action","action-label","onToggle","onOpenDiff","onRequestAction","onRequestFileAction"])):S("",!0)],8,Lc)],8,Ic)],8,_c)):H.presentation==="plan"?(c(),f("div",Mc,[m("div",Ac,[m("article",Sc,[m("div",Fc,w(d(J)("Plan")),1),(he=d(Je)(v))!=null&&he.explanation?(c(),f("p",Pc,w((Fe=d(Je)(v))==null?void 0:Fe.explanation),1)):S("",!0),(ne=d(Je)(v))!=null&&ne.steps.length?(c(),f("ol",Ec,[(c(!0),f(W,null,K((de=d(Je)(v))==null?void 0:de.steps,(T,z)=>(c(),f("li",{key:`${v.id}-plan-${z}`,"data-status":T.status},[m("span",Rc,w(yn(T.status)),1),m("span",null,w(T.step),1)],8,Bc))),128))])):S("",!0)])])])):(c(),f("div",{key:6,class:te(["message-row",{"message-row-final":H.presentation==="final-assistant"}]),"data-role":v.role,"data-message-type":v.messageType||""},[m("div",{class:"message-stack","data-role":v.role},[m("article",{class:"message-body","data-role":v.role},[v.images&&v.images.length>0?(c(),f("ul",{key:0,class:te(["message-image-list",{"message-generated-image-list":v.messageType==="imageView"}]),"data-role":v.role},[(c(!0),f(W,null,K(v.images,T=>(c(),f("li",{key:T,class:"message-image-item"},[m("button",{class:"message-image-button",type:"button",onClick:z=>d(on)(T)},[ct(T)?(c(),f("video",{key:0,class:te(["message-image-preview message-video-preview",{"message-generated-image-preview":v.messageType==="imageView"}]),src:T,controls:"",preload:"metadata"},null,10,qc)):(c(),f("img",{key:1,class:te(["message-image-preview",{"message-generated-image-preview":v.messageType==="imageView"}]),src:T,alt:v.messageType==="imageView"?"Generated image":"Message image preview",loading:"lazy"},null,10,Uc))],8,jc)]))),128))],10,Wc)):S("",!0),v.fileAttachments&&v.fileAttachments.length>0?(c(),f("div",Nc,[(c(!0),f(W,null,K(v.fileAttachments,T=>(c(),f("span",{key:`${v.id}:${T.path}`,class:"message-file-chip"},[p[7]||(p[7]=m("span",{class:"message-file-chip-icon"},"📄",-1)),m("a",{class:"message-file-link message-file-chip-name",href:d(b)(T.path),target:"_blank",rel:"noopener noreferrer",title:T.path},w(T.label),9,Vc)]))),128))])):S("",!0),v.skills&&v.skills.length>0?(c(),f("div",zc,[(c(!0),f(W,null,K(v.skills,T=>(c(),f("a",{key:`${v.id}:${T.path}`,class:"message-skill-chip",href:d(b)(T.path),title:T.path},[m("span",Gc,w(d(J)("Skill")),1),m("span",Zc,w(T.name),1)],8,Kc))),128))])):S("",!0),v.text.length>0?(c(),f("article",{key:3,class:"message-card","data-role":v.role},[v.isAutomationRun?(c(),f("div",Xc,[p[8]||(p[8]=m("span",null,"Sent via automation",-1)),v.automationDisplayName?(c(),f("code",Yc,w(v.automationDisplayName),1)):S("",!0)])):S("",!0),v.messageType==="worked"?(c(),f("div",Qc,[m("p",eu,w(v.text),1)])):wt(v)?(c(),se(Fn,{key:2,message:v,expanded:en(v),"content-html":d(E)(v.text),onToggle:T=>tn(v)},null,8,["message","expanded","content-html","onToggle"])):xo([v.id,v.text,a.cwd,d(r),d(Fs)],()=>(c(),f("div",{key:3,class:"message-text-flow"},[(c(!0),f(W,null,K(d(y)(v),(T,z)=>(c(),f(W,{key:`block-${z}`},[T.kind==="paragraph"?(c(),f("p",tu,[Q(He,{segments:d(g)(T.value),"to-browse-url":d(b)},null,8,["segments","to-browse-url"])])):T.kind==="heading"?(c(),se(To(d(Yn)(T.level)),{key:1,class:te(["message-heading",d(Qn)(T.level)])},{default:We(()=>[Q(He,{segments:d(g)(T.value),"to-browse-url":d(b)},null,8,["segments","to-browse-url"])]),_:2},1032,["class"])):T.kind==="blockquote"?(c(),f("blockquote",nu,[Q(He,{segments:d(g)(T.value),"to-browse-url":d(b)},null,8,["segments","to-browse-url"])])):T.kind==="unorderedList"?(c(),f("ul",su,[(c(!0),f(W,null,K(T.items,(X,Z)=>(c(),f("li",{key:`ul-${z}-${Z}`,class:"message-list-item"},[m("div",{class:"message-list-item-content",innerHTML:d(I)(X)},null,8,ou)]))),128))])):T.kind==="taskList"?(c(),f("ul",au,[(c(!0),f(W,null,K(T.items,(X,Z)=>(c(),f("li",{key:`task-${z}-${Z}`,class:"message-task-item"},[m("span",{class:"message-task-checkbox","data-checked":X.checked},w(X.checked?"☑":"☐"),9,iu),m("div",ru,[Q(He,{segments:d(g)(X.text),"to-browse-url":d(b)},null,8,["segments","to-browse-url"])])]))),128))])):T.kind==="orderedList"?(c(),f("ol",{key:5,class:"message-list message-list-ordered",start:T.start},[(c(!0),f(W,null,K(T.items,(X,Z)=>(c(),f("li",{key:`ol-${z}-${Z}`,class:"message-list-item"},[m("div",{class:"message-list-item-content",innerHTML:d(I)(X)},null,8,cu)]))),128))],8,lu)):T.kind==="table"?(c(),f("div",uu,[m("table",du,[m("thead",null,[m("tr",null,[(c(!0),f(W,null,K(T.headers,(X,Z)=>(c(),f("th",{key:`th-${z}-${Z}`,class:"message-table-head-cell",style:Xe({textAlign:T.alignments[Z]??"left"})},[Q(He,{segments:d(g)(X),"to-browse-url":d(b)},null,8,["segments","to-browse-url"])],4))),128))])]),T.rows.length>0?(c(),f("tbody",fu,[(c(!0),f(W,null,K(T.rows,(X,Z)=>(c(),f("tr",{key:`tr-${z}-${Z}`,class:"message-table-body-row"},[(c(!0),f(W,null,K(X,(_n,In)=>(c(),f("td",{key:`td-${z}-${Z}-${In}`,class:"message-table-cell",style:Xe({textAlign:T.alignments[In]??"left"})},[Q(He,{segments:d(g)(_n),"to-browse-url":d(b)},null,8,["segments","to-browse-url"])],4))),128))]))),128))])):S("",!0)])])):T.kind==="codeBlock"?(c(),f("div",hu,[T.language?(c(),f("div",mu,w(T.language),1)):S("",!0),m("pre",gu,[m("code",{class:"hljs",innerHTML:d(k)(T.language,T.value)},null,8,pu)])])):T.kind==="thematicBreak"?(c(),f("hr",vu)):d(Ps)(v.id,z)?(c(),f("p",ku,w(T.markdown),1)):(c(),f("button",{key:10,class:"message-image-button",type:"button",onClick:X=>d(on)(T.url)},[ct(T.url)?(c(),f("video",{key:0,class:"message-image-preview message-video-preview message-markdown-image",src:T.url,controls:"",preload:"metadata"},null,8,wu)):(c(),f("img",{key:1,class:"message-image-preview message-markdown-image",src:T.url,alt:T.alt||"Embedded message image",loading:"lazy",onError:X=>d(Es)(v.id,z)},null,40,bu))],8,yu))],64))),128))])),p,0),Ls(v)?(c(),f("a",{key:4,class:"turn-error-feedback",href:d(Xt),onClick:T=>Is(T,v.text)},w(d(J)("Send feedback")),9,Cu)):S("",!0)],8,Jc)):S("",!0),Y!=="process"?(c(),se(Xi,{key:4,role:v.role,"show-edit":co(v),"show-fork":d(Cs)(v),"show-copy":d(ys)(v)||d(ws)(v),copied:d(vs)===v.id,onEdit:T=>uo(v.id),onFork:T=>lo(v.id),onCopy:T=>v.role==="user"?d(bs)(v.id):d($s)(v.id)},null,8,["role","show-edit","show-fork","show-copy","copied","onEdit","onFork","onCopy"])):S("",!0)],8,Hc)],8,Dc)],10,Oc))],10,kc)):S("",!0)],64)}),128))]),_:2},1032,["turn-key","warm","warm-items","request","process-items","final-item","file-change-anchor-ids","duration-ms"]))),128)),e.liveOverlay?(c(),se(Ai,{key:2,overlay:e.liveOverlay,"feedback-mailto":d(Xt)},null,8,["overlay","feedback-mailto"])):S("",!0),m("li",{ref_key:"bottomAnchorRef",ref:sn,class:"conversation-bottom-anchor"},null,512)],544)),Q(dr,{anchors:vn.value,"active-turn":Ns.value,onJump:Ks},null,8,["anchors","active-turn"]),ro.value?(c(),f("button",{key:4,type:"button",class:"jump-to-latest-button",title:d(J)("Jump to latest"),"aria-label":d(J)("Jump to latest output"),onClick:xn},[Q(_o,{class:"icon-svg jump-to-latest-icon"})],8,$u)):S("",!0),d(nt).length>0?(c(),f("div",{key:5,class:"image-modal-backdrop",onClick:p[3]||(p[3]=(...F)=>d(st)&&d(st)(...F))},[m("div",{class:"image-modal-content",onClick:p[2]||(p[2]=Ue(()=>{},["stop"]))},[m("button",{class:"image-modal-close",type:"button","aria-label":d(J)("Close image preview"),onClick:p[1]||(p[1]=(...F)=>d(st)&&d(st)(...F))},[Q(zn,{class:"icon-svg"})],8,xu),d(Ss)?(c(),f("video",{key:0,class:"image-modal-image",src:d(nt),controls:"",autoplay:""},null,8,Tu)):(c(),f("img",{key:1,class:"image-modal-image",src:d(nt),alt:d(J)("Expanded message image")},null,8,_u))])])):S("",!0),Q(fi,{visible:d(Re),x:d(ze),y:d($),"browse-url":d(M),"edit-url":d(D),onClose:d(ae)},null,8,["visible","x","y","browse-url","edit-url","onClose"]),Q(Na,{change:d(pe),changes:d(re),lines:d(j),"is-mobile":d(B),"is-file-list-open":d(ie),cwd:a.cwd,onClose:d(Ie),onSelectChange:d(fs),onToggleFileList:d(us),onCloseFileList:d(ds)},null,8,["change","changes","lines","is-mobile","is-file-list-open","cwd","onClose","onSelectChange","onToggleFileList","onCloseFileList"])],32),Q(aa,{visible:Ce.value!==null,title:Ds.value,message:Hs.value,"confirm-label":"Confirm",danger:"",onConfirm:fo,onCancel:p[5]||(p[5]=F=>Ce.value=null)},null,8,["visible","title","message"])],64))}}),Fu=oe(Mu,[["__scopeId","data-v-e186c1a1"]]);export{Fu as default};
@@ -1 +1 @@
1
- import{e as De,x as re,f as c,h as Pe,i as p,j as u,F as E,t as d,k as y,u as f,l as I,n as L,a0 as Ne,w as je,m as Qe,p as B,W,y as He,T as Le,c as ie,r as x,v as Be,_ as We}from"./index-BJ-YiA9y.js";const ze={class:"thread-pending-request-title"},Ke=["title"],Ye={class:"thread-pending-request-approval"},Je=["aria-label"],Ze=["aria-pressed","onClick"],Ge={class:"thread-pending-request-option-index"},Xe={class:"thread-pending-request-option-label"},_e={class:"thread-pending-request-footer thread-pending-request-footer--approval"},et=["value","placeholder"],tt={key:0,class:"thread-pending-request-validation-error",role:"alert"},nt={class:"thread-pending-request-header"},rt={class:"thread-pending-request-heading"},it={class:"thread-pending-request-eyebrow"},st={class:"thread-pending-request-title"},ot={key:0,class:"thread-pending-request-counter"},at={key:0,class:"thread-pending-request-preview"},lt={class:"thread-pending-request-preview-code"},ut={key:1,class:"thread-pending-request-validation-error",role:"alert"},dt={key:2,class:"thread-pending-request-user-input"},ct={key:0,class:"thread-pending-request-question-description"},pt=["href"],ft={class:"thread-pending-request-question-title"},ht={key:0},mt={key:0,class:"thread-pending-request-question-text"},gt={key:1,class:"thread-pending-request-input-wrap"},yt={class:"thread-pending-request-select-label"},vt=["type","value","onInput"],qt={key:2,class:"thread-pending-request-select-wrap"},bt={class:"thread-pending-request-select-label"},kt={key:3,class:"thread-pending-request-select-wrap"},At={class:"thread-pending-request-select-label"},wt={key:4,class:"thread-pending-request-question-options"},Ct=["checked","onChange"],Et={class:"thread-pending-request-checkbox-label"},xt={key:2,class:"thread-pending-request-validation-error"},Rt={class:"thread-pending-request-footer"},St={key:3,class:"thread-pending-request-user-input"},$t={class:"thread-pending-request-question-title"},Tt={key:0,class:"thread-pending-request-question-text"},Vt={key:1,class:"thread-pending-request-question-options"},Mt={class:"thread-pending-request-select-wrap"},Ot={class:"thread-pending-request-select-label"},It={key:0,class:"thread-pending-request-question-description"},Ut={key:2,class:"thread-pending-request-input-wrap"},Ft={class:"thread-pending-request-select-label"},Dt=["value","placeholder","onInput"],Pt={class:"thread-pending-request-footer"},Nt={key:4,class:"thread-pending-request-actions"},jt={key:5,class:"thread-pending-request-actions"},Qt=De({__name:"ThreadPendingRequestPanel",props:{request:{},requestCount:{},hasQueueAbove:{type:Boolean},panelWidth:{},visualViewportHeight:{},panelError:{}},emits:["respondServerRequest"],setup(s,{emit:se}){const k=s,b=se,oe=ie(()=>{const e=typeof k.panelWidth=="number"&&k.panelWidth>0?k.panelWidth:0,t=typeof k.visualViewportHeight=="number"&&k.visualViewportHeight>0?`${k.visualViewportHeight}px`:"100dvh";return{...e>0?{width:`${e}px`}:{},"--visual-viewport-height":t}}),q=x("accept"),R=x(""),T=x({}),V=x({}),A=x({}),w=x(""),{t:o}=Be();function m(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function h(e){return typeof e=="string"?e.trim():""}function ae(e){return typeof e=="string"?e:null}function le(e){return/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:JSON.stringify(e)}function ue(e){const n=(Array.isArray(e.commandActions)?e.commandActions:[]).map(r=>m(r)).map(r=>h(r==null?void 0:r.command)).find(r=>r.length>0);if(n)return n.replace(/\s+/g," ").trim();if(Array.isArray(e.command)){const r=e.command.filter(i=>typeof i=="string").map(i=>i.trim()).filter(i=>i.length>0);if(r.length>0)return r.map(i=>le(i)).join(" ")}return pe(h(e.command))}function U(e){return e.method==="item/commandExecution/requestApproval"||e.method==="execCommandApproval"}function F(e){return e.method==="item/fileChange/requestApproval"||e.method==="applyPatchApproval"}function S(e){return e.method==="item/permissions/requestApproval"}function D(e){return U(e)||F(e)||S(e)}function P(e){return e.method==="mcpServer/elicitation/request"}function de(e){const t=m(e.params);return h(t==null?void 0:t.reason)||h(t==null?void 0:t.prompt)||h(t==null?void 0:t.message)}function ce(e){return D(e)?o("Awaiting approval"):P(e)?o("MCP server input required"):e.method==="item/tool/requestUserInput"?o("Awaiting response"):e.method==="item/tool/call"?o("Tool call waiting for response"):e.method}function z(e){const t=de(e);return t||(U(e)?o("Do you want to run this command?"):F(e)?o("Do you want to make these changes?"):S(e)?o("Do you want to grant these permissions?"):P(e)?o("An MCP server needs your input before Codex can continue."):e.method==="item/tool/requestUserInput"?o("Codex needs your answer before it can continue."):o("Codex is waiting for a response before it can continue."))}function pe(e){var a;const t=e.trim();if(!t)return"";const n=t.match(/-Command\s+(.+)$/i),r=((a=n==null?void 0:n[1])==null?void 0:a.trim())??t;return(r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):r).replace(/\\"/g,'"').replace(/`"/g,'"').replace(/""/g,'"').replace(/\s+/g," ").trim()}function $(e){const t=m(e.params);if(!t)return"";if(U(e))return ue(t);if(F(e)){const n=h(t.grantRoot)||h(t.grant_root);if(n)return n.replace(/\s+/g," ").trim();const r=m(t.fileChanges)??m(t.changes);if(!r)return"";const i=Object.keys(r).map(a=>a.trim()).filter(a=>a.length>0);return i.length===0?"":i.slice(0,3).join(", ")}return S(e)?fe(t.permissions):P(e)?h(t.serverName)||h(t.url):""}function fe(e){const t=m(e);if(!t)return"";const n=[],r=m(t.fileSystem),i=m(t.network),a=Array.isArray(r==null?void 0:r.read)?r.read.filter(v=>typeof v=="string"):[],l=Array.isArray(r==null?void 0:r.write)?r.write.filter(v=>typeof v=="string"):[];return a.length>0&&n.push(`${o("Read")}: ${a.join(", ")}`),l.length>0&&n.push(`${o("Write")}: ${l.join(", ")}`),(i==null?void 0:i.enabled)===!0&&n.push(o("Network access")),n.join(" • ")}function he(e){return!e||!D(e)?[]:[{id:"accept",label:o("Yes")},{id:"acceptForSession",label:o("Yes for Session")}]}const N=ie(()=>he(k.request));re(()=>{var e;return((e=k.request)==null?void 0:e.id)??0},()=>{var e;R.value="",T.value={},V.value={},A.value={},w.value="",q.value=((e=N.value[0])==null?void 0:e.id)??"accept"},{immediate:!0}),re(N,e=>{var t;q.value!=="decline"&&(e.some(n=>n.id===q.value)||(q.value=((t=e[0])==null?void 0:t.id)??"accept"))},{immediate:!0});function M(e,t){return`${String(e)}:${t}`}function K(e){const t=m(e.params),n=Array.isArray(t==null?void 0:t.questions)?t.questions:[],r=[];for(const i of n){const a=m(i);if(!a)continue;const l=h(a.id);if(!l)continue;const v=Array.isArray(a.options)?a.options.map(g=>m(g)).map(g=>({label:h(g==null?void 0:g.label),description:h(g==null?void 0:g.description)})).filter(g=>g.label.length>0):[];r.push({id:l,header:h(a.header),question:h(a.question),isOther:a.isOther===!0,options:v})}return r}function j(e,t,n){const r=M(e,t),i=T.value[r];return typeof i=="string"&&i.length>0?i:n}function Y(e,t){return V.value[M(e,t)]??""}function me(e,t,n){const r=M(e,t);T.value={...T.value,[r]:n}}function ge(e){return e.options.map(t=>({value:t.label,label:t.label}))}function ye(e,t,n){const r=n.target;if(!(r instanceof HTMLInputElement))return;const i=M(e,t);V.value={...V.value,[i]:r.value}}function J(e,t,n){var i,a;const r=j(e,t,((i=n[0])==null?void 0:i.label)||"");return((a=n.find(l=>l.label===r))==null?void 0:a.description)??""}function O(e,t){return`${String(e)}:${t}`}function Z(e){var t;return h((t=m(e.params))==null?void 0:t.serverName)}function G(e){var n;const t=h((n=m(e.params))==null?void 0:n.url);if(!t)return"";try{const r=new URL(t),i=r.protocol.toLowerCase();return i==="https:"||i==="http:"?r.toString():""}catch{return""}}function Q(e){const t=m(e.params),n=m(t==null?void 0:t.requestedSchema),r=m(n==null?void 0:n.properties);if(!r)return[];const i=new Set(Array.isArray(n==null?void 0:n.required)?n.required.filter(a=>typeof a=="string"):[]);return Object.entries(r).map(([a,l])=>ve(a,m(l),i.has(a))).filter(a=>a!==null)}function ve(e,t,n){if(!t)return null;const r=h(t.title)||e,i=h(t.description),a=h(t.type);if(a==="boolean")return{key:e,label:r,description:i,required:n,kind:"boolean",inputType:"checkbox",options:[],defaultValue:typeof t.default=="boolean"?t.default:null,hasExplicitDefault:typeof t.default=="boolean"};if(a==="number"||a==="integer")return{key:e,label:r,description:i,required:n,kind:"number",inputType:"number",options:[],defaultValue:typeof t.default=="number"?t.default:null,hasExplicitDefault:typeof t.default=="number"};const l=X(t);if(a==="array")return{key:e,label:r,description:i,required:n,kind:"multiEnum",inputType:"checkbox",options:l,defaultValue:Array.isArray(t.default)?t.default.filter(g=>typeof g=="string"):[],hasExplicitDefault:Array.isArray(t.default)};const v=ae(t.default);return l.length>0?{key:e,label:r,description:i,required:n,kind:"singleEnum",inputType:"select",options:l,defaultValue:v,hasExplicitDefault:v!==null}:{key:e,label:r,description:i,required:n,kind:"string",inputType:qe(t),options:[],defaultValue:v,hasExplicitDefault:v!==null}}function X(e){const n=(Array.isArray(e.oneOf)?e.oneOf:Array.isArray(e.anyOf)?e.anyOf:[]).map(l=>m(l)).map(l=>({value:h(l==null?void 0:l.const),label:h(l==null?void 0:l.title)||h(l==null?void 0:l.const)})).filter(l=>l.value.length>0);if(n.length>0)return n;const r=m(e.items);if(r){const l=X(r);if(l.length>0)return l}const i=Array.isArray(e.enum)?e.enum.filter(l=>typeof l=="string"):[],a=Array.isArray(e.enumNames)?e.enumNames.filter(l=>typeof l=="string"):[];return i.map((l,v)=>({value:l,label:a[v]||l}))}function qe(e){const t=h(e.format);return t==="email"?"email":t==="uri"?"url":t==="date"?"date":t==="date-time"?"datetime-local":"text"}function C(e,t){const n=A.value[O(e,t.key)];return n!==void 0?n:t.defaultValue}function _(e,t){const n=C(e,t);return Array.isArray(n)?n.filter(r=>typeof r=="string"):[]}function be(e,t,n){const r=n.target;r instanceof HTMLInputElement&&ee(e,t,r.value)}function ee(e,t,n){const r=(t.kind==="number",n);A.value={...A.value,[O(e,t.key)]:n.length>0?r:null},w.value=""}function ke(e,t,n){let r=null;n==="true"?r=!0:n==="false"&&(r=!1),A.value={...A.value,[O(e,t.key)]:r},w.value=""}function Ae(e,t,n,r){const i=r.target;if(!(i instanceof HTMLInputElement))return;const a=new Set(_(e,t));i.checked?a.add(n):a.delete(n),A.value={...A.value,[O(e,t.key)]:Array.from(a)},w.value=""}function we(e){return e===!0?"true":e===!1?"false":""}function Ce(e){const t=[{value:"true",label:o("True")},{value:"false",label:o("False")}];return e.hasExplicitDefault||t.unshift({value:"",label:o("Select true or false")}),t}function Ee(e){const t=e.options.map(n=>({value:n.value,label:n.label}));return e.hasExplicitDefault||t.unshift({value:"",label:o("Select an option")}),t}function xe(e,t){const n=C(e,t);return t.kind==="multiEnum"?Array.isArray(n)&&n.length>0:t.kind==="boolean"?typeof n=="boolean":t.kind==="number"&&typeof n=="number"?!0:typeof n=="string"&&n.trim().length>0}function Re(e){const t=Q(e).filter(n=>n.required&&!xe(e.id,n)).map(n=>n.label);return t.length===0?"":t.length===1?`${o("Answer the required field")}: ${t[0]}.`:`${o("Answer the required field")}: ${t.join(", ")}.`}function Se(e){const t={};for(const n of Q(e)){const r=C(e.id,n);if(n.kind==="multiEnum"){const a=Array.isArray(r)?r:[];(a.length>0||n.required)&&(t[n.key]=a);continue}if(n.kind==="boolean"){typeof r=="boolean"&&(t[n.key]=r);continue}if(n.kind==="number"){const a=typeof r=="number"?r:Number(String(r).trim());Number.isNaN(a)||(t[n.key]=a);continue}const i=String(r??"").trim();(i.length>0||n.required)&&(t[n.key]=i)}return t}function $e(e){q.value=e}function Te(){q.value="decline"}function Ve(e){const t=e.target;t instanceof HTMLInputElement&&(R.value=t.value,q.value="decline")}function te(e,t){var n;if(S(e)){if(t==="decline"||t==="cancel"){b("respondServerRequest",{id:e.id,error:{code:-32e3,message:t==="cancel"?"Cancelled from CodexUI.":"Declined from CodexUI."}});return}const r=m((n=m(e.params))==null?void 0:n.permissions)??{};b("respondServerRequest",{id:e.id,result:{permissions:r,scope:t==="acceptForSession"?"session":"turn"}});return}b("respondServerRequest",{id:e.id,result:{decision:t}})}function ne(e){const t=R.value.trim(),n=t.length>0?"decline":q.value;if(S(e)){te(e,n);return}b("respondServerRequest",{id:e.id,result:{decision:n},followUpMessageText:t||void 0})}function H(e,t){const n=m(e.params),r={action:t};if(t==="accept"&&h(n==null?void 0:n.mode)==="form"){const i=Re(e);if(i){w.value=i;return}r.content=Se(e)}b("respondServerRequest",{id:e.id,result:r})}function Me(e){var r;const t=K(e),n={};for(const i of t){const a=j(e.id,i.id,((r=i.options[0])==null?void 0:r.label)||""),l=Y(e.id,i.id).trim(),v=[a,l].map(g=>g.trim()).filter(g=>g.length>0);n[i.id]={answers:v}}b("respondServerRequest",{id:e.id,result:{answers:n}})}function Oe(e){b("respondServerRequest",{id:e.id,result:{success:!1,contentItems:[{type:"inputText",text:"Tool call rejected from CodexUI."}]}})}function Ie(e){b("respondServerRequest",{id:e.id,result:{success:!0,contentItems:[]}})}function Ue(e){b("respondServerRequest",{id:e.id,result:{}})}function Fe(e){b("respondServerRequest",{id:e.id,error:{code:-32e3,message:"Rejected from CodexUI."}})}return(e,t)=>(c(),Pe(Le,{to:"body"},[s.request?(c(),p("section",{key:0,class:"thread-pending-request",style:He(oe.value)},[u("article",{class:L(["thread-pending-request-shell",{"thread-pending-request-shell--no-top-radius":s.hasQueueAbove}])},[D(s.request)?(c(),p(E,{key:0},[u("p",ze,d(z(s.request)),1),$(s.request)?(c(),p("p",{key:0,class:"thread-pending-request-command-line",title:$(s.request)},d($(s.request)),9,Ke)):y("",!0),u("section",Ye,[u("div",{class:"thread-pending-request-options",role:"radiogroup","aria-label":f(o)("Approval choices")},[(c(!0),p(E,null,I(N.value,(n,r)=>(c(),p("button",{key:n.id,type:"button",class:L(["thread-pending-request-option",{"is-selected":q.value===n.id}]),"aria-pressed":q.value===n.id,onClick:i=>$e(n.id)},[u("span",Ge,d(r+1)+".",1),u("span",Xe,d(n.label),1)],10,Ze))),128))],8,Je),u("footer",_e,[u("label",{class:L(["thread-pending-request-inline-input",{"is-active":q.value==="decline"||R.value.length>0}])},[t[11]||(t[11]=u("span",{class:"thread-pending-request-option-index"},"3.",-1)),u("input",{class:"thread-pending-request-inline-control",type:"text",value:R.value,placeholder:f(o)("No, and tell Codex what to do differently"),onFocus:Te,onInput:Ve,onKeydown:t[0]||(t[0]=Ne(je(n=>ne(s.request),["prevent"]),["enter"]))},null,40,et)],2),u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[1]||(t[1]=n=>te(s.request,"cancel"))},d(f(o)("Skip")),1),u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[2]||(t[2]=n=>ne(s.request))},d(f(o)("Send")),1)]),s.panelError?(c(),p("p",tt,d(s.panelError),1)):y("",!0)])],64)):(c(),p(E,{key:1},[u("header",nt,[u("div",rt,[u("p",it,d(ce(s.request)),1),u("p",st,d(z(s.request)),1)]),(s.requestCount??0)>1?(c(),p("span",ot,d(s.requestCount??0)+" "+d(f(o)("pending")),1)):y("",!0)]),$(s.request)?(c(),p("div",at,[u("code",lt,d($(s.request)),1)])):y("",!0),s.panelError?(c(),p("p",ut,d(s.panelError),1)):y("",!0),s.request.method==="mcpServer/elicitation/request"?(c(),p("section",dt,[Z(s.request)?(c(),p("p",ct,d(f(o)("Server"))+": "+d(Z(s.request)),1)):y("",!0),G(s.request)?(c(),p("a",{key:1,class:"thread-pending-request-link",href:G(s.request),target:"_blank",rel:"noopener noreferrer"},d(f(o)("Open authorization link")),9,pt)):y("",!0),(c(!0),p(E,null,I(Q(s.request),n=>(c(),p("div",{key:`${s.request.id}:${n.key}`,class:"thread-pending-request-question"},[u("p",ft,[Qe(d(n.label),1),n.required?(c(),p("span",ht," *")):y("",!0)]),n.description?(c(),p("p",mt,d(n.description),1)):y("",!0),n.kind==="string"||n.kind==="number"?(c(),p("label",gt,[u("span",yt,d(f(o)("Value")),1),u("input",{class:"thread-pending-request-input",type:n.inputType,value:String(C(s.request.id,n)??""),onInput:r=>be(s.request.id,n,r)},null,40,vt)])):n.kind==="boolean"?(c(),p("div",qt,[u("span",bt,d(f(o)("Choice")),1),B(W,{class:"thread-pending-request-dropdown","model-value":we(C(s.request.id,n)),options:Ce(n),placeholder:f(o)("Select true or false"),"onUpdate:modelValue":r=>ke(s.request.id,n,r)},null,8,["model-value","options","placeholder","onUpdate:modelValue"])])):n.kind==="singleEnum"?(c(),p("div",kt,[u("span",At,d(f(o)("Choice")),1),B(W,{class:"thread-pending-request-dropdown","model-value":String(C(s.request.id,n)??""),options:Ee(n),placeholder:f(o)("Select an option"),"enable-search":"","search-placeholder":f(o)("Search options..."),"onUpdate:modelValue":r=>ee(s.request.id,n,r)},null,8,["model-value","options","placeholder","search-placeholder","onUpdate:modelValue"])])):(c(),p("div",wt,[(c(!0),p(E,null,I(n.options,r=>(c(),p("label",{key:`${s.request.id}:${n.key}:${r.value}`,class:"thread-pending-request-checkbox-row"},[u("input",{class:"thread-pending-request-checkbox",type:"checkbox",checked:_(s.request.id,n).includes(r.value),onChange:i=>Ae(s.request.id,n,r.value,i)},null,40,Ct),u("span",Et,d(r.label),1)]))),128))]))]))),128)),w.value?(c(),p("p",xt,d(w.value),1)):y("",!0),u("footer",Rt,[u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[3]||(t[3]=n=>H(s.request,"cancel"))},d(f(o)("Cancel")),1),u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[4]||(t[4]=n=>H(s.request,"decline"))},d(f(o)("Decline")),1),u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[5]||(t[5]=n=>H(s.request,"accept"))},d(f(o)("Continue")),1)])])):s.request.method==="item/tool/requestUserInput"?(c(),p("section",St,[(c(!0),p(E,null,I(K(s.request),n=>{var r;return c(),p("div",{key:`${s.request.id}:${n.id}`,class:"thread-pending-request-question"},[u("p",$t,d(n.header||n.question),1),n.question?(c(),p("p",Tt,d(n.question),1)):y("",!0),n.options.length>0?(c(),p("div",Vt,[u("div",Mt,[u("span",Ot,d(f(o)("Choice")),1),B(W,{class:"thread-pending-request-dropdown","model-value":j(s.request.id,n.id,((r=n.options[0])==null?void 0:r.label)||""),options:ge(n),placeholder:f(o)("Choice"),"onUpdate:modelValue":i=>me(s.request.id,n.id,i)},null,8,["model-value","options","placeholder","onUpdate:modelValue"])]),J(s.request.id,n.id,n.options)?(c(),p("p",It,d(J(s.request.id,n.id,n.options)),1)):y("",!0)])):y("",!0),n.isOther?(c(),p("label",Ut,[u("span",Ft,d(f(o)("Other answer")),1),u("input",{class:"thread-pending-request-input",type:"text",value:Y(s.request.id,n.id),placeholder:f(o)("Other answer"),onInput:i=>ye(s.request.id,n.id,i)},null,40,Dt)])):y("",!0)])}),128)),u("footer",Pt,[u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[6]||(t[6]=n=>Me(s.request))},d(f(o)("Send")),1)])])):s.request.method==="item/tool/call"?(c(),p("section",Nt,[u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[7]||(t[7]=n=>Oe(s.request))},d(f(o)("Fail Tool Call")),1),u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[8]||(t[8]=n=>Ie(s.request))},d(f(o)("Success (Empty)")),1)])):(c(),p("section",jt,[u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[9]||(t[9]=n=>Ue(s.request))},d(f(o)("Return Empty Result")),1),u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[10]||(t[10]=n=>Fe(s.request))},d(f(o)("Reject Request")),1)]))],64))],2)],4)):y("",!0)]))}}),Lt=We(Qt,[["__scopeId","data-v-1f49cff5"]]);export{Lt as default};
1
+ import{e as De,x as re,f as c,h as Pe,i as p,j as u,F as E,t as d,k as y,u as f,l as I,n as L,a0 as Ne,w as je,m as Qe,p as B,W,y as He,T as Le,c as ie,r as x,v as Be,_ as We}from"./index-Q0GrjPAB.js";const ze={class:"thread-pending-request-title"},Ke=["title"],Ye={class:"thread-pending-request-approval"},Je=["aria-label"],Ze=["aria-pressed","onClick"],Ge={class:"thread-pending-request-option-index"},Xe={class:"thread-pending-request-option-label"},_e={class:"thread-pending-request-footer thread-pending-request-footer--approval"},et=["value","placeholder"],tt={key:0,class:"thread-pending-request-validation-error",role:"alert"},nt={class:"thread-pending-request-header"},rt={class:"thread-pending-request-heading"},it={class:"thread-pending-request-eyebrow"},st={class:"thread-pending-request-title"},ot={key:0,class:"thread-pending-request-counter"},at={key:0,class:"thread-pending-request-preview"},lt={class:"thread-pending-request-preview-code"},ut={key:1,class:"thread-pending-request-validation-error",role:"alert"},dt={key:2,class:"thread-pending-request-user-input"},ct={key:0,class:"thread-pending-request-question-description"},pt=["href"],ft={class:"thread-pending-request-question-title"},ht={key:0},mt={key:0,class:"thread-pending-request-question-text"},gt={key:1,class:"thread-pending-request-input-wrap"},yt={class:"thread-pending-request-select-label"},vt=["type","value","onInput"],qt={key:2,class:"thread-pending-request-select-wrap"},bt={class:"thread-pending-request-select-label"},kt={key:3,class:"thread-pending-request-select-wrap"},At={class:"thread-pending-request-select-label"},wt={key:4,class:"thread-pending-request-question-options"},Ct=["checked","onChange"],Et={class:"thread-pending-request-checkbox-label"},xt={key:2,class:"thread-pending-request-validation-error"},Rt={class:"thread-pending-request-footer"},St={key:3,class:"thread-pending-request-user-input"},$t={class:"thread-pending-request-question-title"},Tt={key:0,class:"thread-pending-request-question-text"},Vt={key:1,class:"thread-pending-request-question-options"},Mt={class:"thread-pending-request-select-wrap"},Ot={class:"thread-pending-request-select-label"},It={key:0,class:"thread-pending-request-question-description"},Ut={key:2,class:"thread-pending-request-input-wrap"},Ft={class:"thread-pending-request-select-label"},Dt=["value","placeholder","onInput"],Pt={class:"thread-pending-request-footer"},Nt={key:4,class:"thread-pending-request-actions"},jt={key:5,class:"thread-pending-request-actions"},Qt=De({__name:"ThreadPendingRequestPanel",props:{request:{},requestCount:{},hasQueueAbove:{type:Boolean},panelWidth:{},visualViewportHeight:{},panelError:{}},emits:["respondServerRequest"],setup(s,{emit:se}){const k=s,b=se,oe=ie(()=>{const e=typeof k.panelWidth=="number"&&k.panelWidth>0?k.panelWidth:0,t=typeof k.visualViewportHeight=="number"&&k.visualViewportHeight>0?`${k.visualViewportHeight}px`:"100dvh";return{...e>0?{width:`${e}px`}:{},"--visual-viewport-height":t}}),q=x("accept"),R=x(""),T=x({}),V=x({}),A=x({}),w=x(""),{t:o}=Be();function m(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function h(e){return typeof e=="string"?e.trim():""}function ae(e){return typeof e=="string"?e:null}function le(e){return/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:JSON.stringify(e)}function ue(e){const n=(Array.isArray(e.commandActions)?e.commandActions:[]).map(r=>m(r)).map(r=>h(r==null?void 0:r.command)).find(r=>r.length>0);if(n)return n.replace(/\s+/g," ").trim();if(Array.isArray(e.command)){const r=e.command.filter(i=>typeof i=="string").map(i=>i.trim()).filter(i=>i.length>0);if(r.length>0)return r.map(i=>le(i)).join(" ")}return pe(h(e.command))}function U(e){return e.method==="item/commandExecution/requestApproval"||e.method==="execCommandApproval"}function F(e){return e.method==="item/fileChange/requestApproval"||e.method==="applyPatchApproval"}function S(e){return e.method==="item/permissions/requestApproval"}function D(e){return U(e)||F(e)||S(e)}function P(e){return e.method==="mcpServer/elicitation/request"}function de(e){const t=m(e.params);return h(t==null?void 0:t.reason)||h(t==null?void 0:t.prompt)||h(t==null?void 0:t.message)}function ce(e){return D(e)?o("Awaiting approval"):P(e)?o("MCP server input required"):e.method==="item/tool/requestUserInput"?o("Awaiting response"):e.method==="item/tool/call"?o("Tool call waiting for response"):e.method}function z(e){const t=de(e);return t||(U(e)?o("Do you want to run this command?"):F(e)?o("Do you want to make these changes?"):S(e)?o("Do you want to grant these permissions?"):P(e)?o("An MCP server needs your input before Codex can continue."):e.method==="item/tool/requestUserInput"?o("Codex needs your answer before it can continue."):o("Codex is waiting for a response before it can continue."))}function pe(e){var a;const t=e.trim();if(!t)return"";const n=t.match(/-Command\s+(.+)$/i),r=((a=n==null?void 0:n[1])==null?void 0:a.trim())??t;return(r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):r).replace(/\\"/g,'"').replace(/`"/g,'"').replace(/""/g,'"').replace(/\s+/g," ").trim()}function $(e){const t=m(e.params);if(!t)return"";if(U(e))return ue(t);if(F(e)){const n=h(t.grantRoot)||h(t.grant_root);if(n)return n.replace(/\s+/g," ").trim();const r=m(t.fileChanges)??m(t.changes);if(!r)return"";const i=Object.keys(r).map(a=>a.trim()).filter(a=>a.length>0);return i.length===0?"":i.slice(0,3).join(", ")}return S(e)?fe(t.permissions):P(e)?h(t.serverName)||h(t.url):""}function fe(e){const t=m(e);if(!t)return"";const n=[],r=m(t.fileSystem),i=m(t.network),a=Array.isArray(r==null?void 0:r.read)?r.read.filter(v=>typeof v=="string"):[],l=Array.isArray(r==null?void 0:r.write)?r.write.filter(v=>typeof v=="string"):[];return a.length>0&&n.push(`${o("Read")}: ${a.join(", ")}`),l.length>0&&n.push(`${o("Write")}: ${l.join(", ")}`),(i==null?void 0:i.enabled)===!0&&n.push(o("Network access")),n.join(" • ")}function he(e){return!e||!D(e)?[]:[{id:"accept",label:o("Yes")},{id:"acceptForSession",label:o("Yes for Session")}]}const N=ie(()=>he(k.request));re(()=>{var e;return((e=k.request)==null?void 0:e.id)??0},()=>{var e;R.value="",T.value={},V.value={},A.value={},w.value="",q.value=((e=N.value[0])==null?void 0:e.id)??"accept"},{immediate:!0}),re(N,e=>{var t;q.value!=="decline"&&(e.some(n=>n.id===q.value)||(q.value=((t=e[0])==null?void 0:t.id)??"accept"))},{immediate:!0});function M(e,t){return`${String(e)}:${t}`}function K(e){const t=m(e.params),n=Array.isArray(t==null?void 0:t.questions)?t.questions:[],r=[];for(const i of n){const a=m(i);if(!a)continue;const l=h(a.id);if(!l)continue;const v=Array.isArray(a.options)?a.options.map(g=>m(g)).map(g=>({label:h(g==null?void 0:g.label),description:h(g==null?void 0:g.description)})).filter(g=>g.label.length>0):[];r.push({id:l,header:h(a.header),question:h(a.question),isOther:a.isOther===!0,options:v})}return r}function j(e,t,n){const r=M(e,t),i=T.value[r];return typeof i=="string"&&i.length>0?i:n}function Y(e,t){return V.value[M(e,t)]??""}function me(e,t,n){const r=M(e,t);T.value={...T.value,[r]:n}}function ge(e){return e.options.map(t=>({value:t.label,label:t.label}))}function ye(e,t,n){const r=n.target;if(!(r instanceof HTMLInputElement))return;const i=M(e,t);V.value={...V.value,[i]:r.value}}function J(e,t,n){var i,a;const r=j(e,t,((i=n[0])==null?void 0:i.label)||"");return((a=n.find(l=>l.label===r))==null?void 0:a.description)??""}function O(e,t){return`${String(e)}:${t}`}function Z(e){var t;return h((t=m(e.params))==null?void 0:t.serverName)}function G(e){var n;const t=h((n=m(e.params))==null?void 0:n.url);if(!t)return"";try{const r=new URL(t),i=r.protocol.toLowerCase();return i==="https:"||i==="http:"?r.toString():""}catch{return""}}function Q(e){const t=m(e.params),n=m(t==null?void 0:t.requestedSchema),r=m(n==null?void 0:n.properties);if(!r)return[];const i=new Set(Array.isArray(n==null?void 0:n.required)?n.required.filter(a=>typeof a=="string"):[]);return Object.entries(r).map(([a,l])=>ve(a,m(l),i.has(a))).filter(a=>a!==null)}function ve(e,t,n){if(!t)return null;const r=h(t.title)||e,i=h(t.description),a=h(t.type);if(a==="boolean")return{key:e,label:r,description:i,required:n,kind:"boolean",inputType:"checkbox",options:[],defaultValue:typeof t.default=="boolean"?t.default:null,hasExplicitDefault:typeof t.default=="boolean"};if(a==="number"||a==="integer")return{key:e,label:r,description:i,required:n,kind:"number",inputType:"number",options:[],defaultValue:typeof t.default=="number"?t.default:null,hasExplicitDefault:typeof t.default=="number"};const l=X(t);if(a==="array")return{key:e,label:r,description:i,required:n,kind:"multiEnum",inputType:"checkbox",options:l,defaultValue:Array.isArray(t.default)?t.default.filter(g=>typeof g=="string"):[],hasExplicitDefault:Array.isArray(t.default)};const v=ae(t.default);return l.length>0?{key:e,label:r,description:i,required:n,kind:"singleEnum",inputType:"select",options:l,defaultValue:v,hasExplicitDefault:v!==null}:{key:e,label:r,description:i,required:n,kind:"string",inputType:qe(t),options:[],defaultValue:v,hasExplicitDefault:v!==null}}function X(e){const n=(Array.isArray(e.oneOf)?e.oneOf:Array.isArray(e.anyOf)?e.anyOf:[]).map(l=>m(l)).map(l=>({value:h(l==null?void 0:l.const),label:h(l==null?void 0:l.title)||h(l==null?void 0:l.const)})).filter(l=>l.value.length>0);if(n.length>0)return n;const r=m(e.items);if(r){const l=X(r);if(l.length>0)return l}const i=Array.isArray(e.enum)?e.enum.filter(l=>typeof l=="string"):[],a=Array.isArray(e.enumNames)?e.enumNames.filter(l=>typeof l=="string"):[];return i.map((l,v)=>({value:l,label:a[v]||l}))}function qe(e){const t=h(e.format);return t==="email"?"email":t==="uri"?"url":t==="date"?"date":t==="date-time"?"datetime-local":"text"}function C(e,t){const n=A.value[O(e,t.key)];return n!==void 0?n:t.defaultValue}function _(e,t){const n=C(e,t);return Array.isArray(n)?n.filter(r=>typeof r=="string"):[]}function be(e,t,n){const r=n.target;r instanceof HTMLInputElement&&ee(e,t,r.value)}function ee(e,t,n){const r=(t.kind==="number",n);A.value={...A.value,[O(e,t.key)]:n.length>0?r:null},w.value=""}function ke(e,t,n){let r=null;n==="true"?r=!0:n==="false"&&(r=!1),A.value={...A.value,[O(e,t.key)]:r},w.value=""}function Ae(e,t,n,r){const i=r.target;if(!(i instanceof HTMLInputElement))return;const a=new Set(_(e,t));i.checked?a.add(n):a.delete(n),A.value={...A.value,[O(e,t.key)]:Array.from(a)},w.value=""}function we(e){return e===!0?"true":e===!1?"false":""}function Ce(e){const t=[{value:"true",label:o("True")},{value:"false",label:o("False")}];return e.hasExplicitDefault||t.unshift({value:"",label:o("Select true or false")}),t}function Ee(e){const t=e.options.map(n=>({value:n.value,label:n.label}));return e.hasExplicitDefault||t.unshift({value:"",label:o("Select an option")}),t}function xe(e,t){const n=C(e,t);return t.kind==="multiEnum"?Array.isArray(n)&&n.length>0:t.kind==="boolean"?typeof n=="boolean":t.kind==="number"&&typeof n=="number"?!0:typeof n=="string"&&n.trim().length>0}function Re(e){const t=Q(e).filter(n=>n.required&&!xe(e.id,n)).map(n=>n.label);return t.length===0?"":t.length===1?`${o("Answer the required field")}: ${t[0]}.`:`${o("Answer the required field")}: ${t.join(", ")}.`}function Se(e){const t={};for(const n of Q(e)){const r=C(e.id,n);if(n.kind==="multiEnum"){const a=Array.isArray(r)?r:[];(a.length>0||n.required)&&(t[n.key]=a);continue}if(n.kind==="boolean"){typeof r=="boolean"&&(t[n.key]=r);continue}if(n.kind==="number"){const a=typeof r=="number"?r:Number(String(r).trim());Number.isNaN(a)||(t[n.key]=a);continue}const i=String(r??"").trim();(i.length>0||n.required)&&(t[n.key]=i)}return t}function $e(e){q.value=e}function Te(){q.value="decline"}function Ve(e){const t=e.target;t instanceof HTMLInputElement&&(R.value=t.value,q.value="decline")}function te(e,t){var n;if(S(e)){if(t==="decline"||t==="cancel"){b("respondServerRequest",{id:e.id,error:{code:-32e3,message:t==="cancel"?"Cancelled from CodexUI.":"Declined from CodexUI."}});return}const r=m((n=m(e.params))==null?void 0:n.permissions)??{};b("respondServerRequest",{id:e.id,result:{permissions:r,scope:t==="acceptForSession"?"session":"turn"}});return}b("respondServerRequest",{id:e.id,result:{decision:t}})}function ne(e){const t=R.value.trim(),n=t.length>0?"decline":q.value;if(S(e)){te(e,n);return}b("respondServerRequest",{id:e.id,result:{decision:n},followUpMessageText:t||void 0})}function H(e,t){const n=m(e.params),r={action:t};if(t==="accept"&&h(n==null?void 0:n.mode)==="form"){const i=Re(e);if(i){w.value=i;return}r.content=Se(e)}b("respondServerRequest",{id:e.id,result:r})}function Me(e){var r;const t=K(e),n={};for(const i of t){const a=j(e.id,i.id,((r=i.options[0])==null?void 0:r.label)||""),l=Y(e.id,i.id).trim(),v=[a,l].map(g=>g.trim()).filter(g=>g.length>0);n[i.id]={answers:v}}b("respondServerRequest",{id:e.id,result:{answers:n}})}function Oe(e){b("respondServerRequest",{id:e.id,result:{success:!1,contentItems:[{type:"inputText",text:"Tool call rejected from CodexUI."}]}})}function Ie(e){b("respondServerRequest",{id:e.id,result:{success:!0,contentItems:[]}})}function Ue(e){b("respondServerRequest",{id:e.id,result:{}})}function Fe(e){b("respondServerRequest",{id:e.id,error:{code:-32e3,message:"Rejected from CodexUI."}})}return(e,t)=>(c(),Pe(Le,{to:"body"},[s.request?(c(),p("section",{key:0,class:"thread-pending-request",style:He(oe.value)},[u("article",{class:L(["thread-pending-request-shell",{"thread-pending-request-shell--no-top-radius":s.hasQueueAbove}])},[D(s.request)?(c(),p(E,{key:0},[u("p",ze,d(z(s.request)),1),$(s.request)?(c(),p("p",{key:0,class:"thread-pending-request-command-line",title:$(s.request)},d($(s.request)),9,Ke)):y("",!0),u("section",Ye,[u("div",{class:"thread-pending-request-options",role:"radiogroup","aria-label":f(o)("Approval choices")},[(c(!0),p(E,null,I(N.value,(n,r)=>(c(),p("button",{key:n.id,type:"button",class:L(["thread-pending-request-option",{"is-selected":q.value===n.id}]),"aria-pressed":q.value===n.id,onClick:i=>$e(n.id)},[u("span",Ge,d(r+1)+".",1),u("span",Xe,d(n.label),1)],10,Ze))),128))],8,Je),u("footer",_e,[u("label",{class:L(["thread-pending-request-inline-input",{"is-active":q.value==="decline"||R.value.length>0}])},[t[11]||(t[11]=u("span",{class:"thread-pending-request-option-index"},"3.",-1)),u("input",{class:"thread-pending-request-inline-control",type:"text",value:R.value,placeholder:f(o)("No, and tell Codex what to do differently"),onFocus:Te,onInput:Ve,onKeydown:t[0]||(t[0]=Ne(je(n=>ne(s.request),["prevent"]),["enter"]))},null,40,et)],2),u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[1]||(t[1]=n=>te(s.request,"cancel"))},d(f(o)("Skip")),1),u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[2]||(t[2]=n=>ne(s.request))},d(f(o)("Send")),1)]),s.panelError?(c(),p("p",tt,d(s.panelError),1)):y("",!0)])],64)):(c(),p(E,{key:1},[u("header",nt,[u("div",rt,[u("p",it,d(ce(s.request)),1),u("p",st,d(z(s.request)),1)]),(s.requestCount??0)>1?(c(),p("span",ot,d(s.requestCount??0)+" "+d(f(o)("pending")),1)):y("",!0)]),$(s.request)?(c(),p("div",at,[u("code",lt,d($(s.request)),1)])):y("",!0),s.panelError?(c(),p("p",ut,d(s.panelError),1)):y("",!0),s.request.method==="mcpServer/elicitation/request"?(c(),p("section",dt,[Z(s.request)?(c(),p("p",ct,d(f(o)("Server"))+": "+d(Z(s.request)),1)):y("",!0),G(s.request)?(c(),p("a",{key:1,class:"thread-pending-request-link",href:G(s.request),target:"_blank",rel:"noopener noreferrer"},d(f(o)("Open authorization link")),9,pt)):y("",!0),(c(!0),p(E,null,I(Q(s.request),n=>(c(),p("div",{key:`${s.request.id}:${n.key}`,class:"thread-pending-request-question"},[u("p",ft,[Qe(d(n.label),1),n.required?(c(),p("span",ht," *")):y("",!0)]),n.description?(c(),p("p",mt,d(n.description),1)):y("",!0),n.kind==="string"||n.kind==="number"?(c(),p("label",gt,[u("span",yt,d(f(o)("Value")),1),u("input",{class:"thread-pending-request-input",type:n.inputType,value:String(C(s.request.id,n)??""),onInput:r=>be(s.request.id,n,r)},null,40,vt)])):n.kind==="boolean"?(c(),p("div",qt,[u("span",bt,d(f(o)("Choice")),1),B(W,{class:"thread-pending-request-dropdown","model-value":we(C(s.request.id,n)),options:Ce(n),placeholder:f(o)("Select true or false"),"onUpdate:modelValue":r=>ke(s.request.id,n,r)},null,8,["model-value","options","placeholder","onUpdate:modelValue"])])):n.kind==="singleEnum"?(c(),p("div",kt,[u("span",At,d(f(o)("Choice")),1),B(W,{class:"thread-pending-request-dropdown","model-value":String(C(s.request.id,n)??""),options:Ee(n),placeholder:f(o)("Select an option"),"enable-search":"","search-placeholder":f(o)("Search options..."),"onUpdate:modelValue":r=>ee(s.request.id,n,r)},null,8,["model-value","options","placeholder","search-placeholder","onUpdate:modelValue"])])):(c(),p("div",wt,[(c(!0),p(E,null,I(n.options,r=>(c(),p("label",{key:`${s.request.id}:${n.key}:${r.value}`,class:"thread-pending-request-checkbox-row"},[u("input",{class:"thread-pending-request-checkbox",type:"checkbox",checked:_(s.request.id,n).includes(r.value),onChange:i=>Ae(s.request.id,n,r.value,i)},null,40,Ct),u("span",Et,d(r.label),1)]))),128))]))]))),128)),w.value?(c(),p("p",xt,d(w.value),1)):y("",!0),u("footer",Rt,[u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[3]||(t[3]=n=>H(s.request,"cancel"))},d(f(o)("Cancel")),1),u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[4]||(t[4]=n=>H(s.request,"decline"))},d(f(o)("Decline")),1),u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[5]||(t[5]=n=>H(s.request,"accept"))},d(f(o)("Continue")),1)])])):s.request.method==="item/tool/requestUserInput"?(c(),p("section",St,[(c(!0),p(E,null,I(K(s.request),n=>{var r;return c(),p("div",{key:`${s.request.id}:${n.id}`,class:"thread-pending-request-question"},[u("p",$t,d(n.header||n.question),1),n.question?(c(),p("p",Tt,d(n.question),1)):y("",!0),n.options.length>0?(c(),p("div",Vt,[u("div",Mt,[u("span",Ot,d(f(o)("Choice")),1),B(W,{class:"thread-pending-request-dropdown","model-value":j(s.request.id,n.id,((r=n.options[0])==null?void 0:r.label)||""),options:ge(n),placeholder:f(o)("Choice"),"onUpdate:modelValue":i=>me(s.request.id,n.id,i)},null,8,["model-value","options","placeholder","onUpdate:modelValue"])]),J(s.request.id,n.id,n.options)?(c(),p("p",It,d(J(s.request.id,n.id,n.options)),1)):y("",!0)])):y("",!0),n.isOther?(c(),p("label",Ut,[u("span",Ft,d(f(o)("Other answer")),1),u("input",{class:"thread-pending-request-input",type:"text",value:Y(s.request.id,n.id),placeholder:f(o)("Other answer"),onInput:i=>ye(s.request.id,n.id,i)},null,40,Dt)])):y("",!0)])}),128)),u("footer",Pt,[u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[6]||(t[6]=n=>Me(s.request))},d(f(o)("Send")),1)])])):s.request.method==="item/tool/call"?(c(),p("section",Nt,[u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[7]||(t[7]=n=>Oe(s.request))},d(f(o)("Fail Tool Call")),1),u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[8]||(t[8]=n=>Ie(s.request))},d(f(o)("Success (Empty)")),1)])):(c(),p("section",jt,[u("button",{type:"button",class:"thread-pending-request-primary",onClick:t[9]||(t[9]=n=>Ue(s.request))},d(f(o)("Return Empty Result")),1),u("button",{type:"button",class:"thread-pending-request-secondary",onClick:t[10]||(t[10]=n=>Fe(s.request))},d(f(o)("Reject Request")),1)]))],64))],2)],4)):y("",!0)]))}}),Lt=We(Qt,[["__scopeId","data-v-1f49cff5"]]);export{Lt as default};
@@ -1,4 +1,4 @@
1
- import{e as dn,r as ct,O as un,P as _n,o as fn,x as pn,Q as vs,J as gn,R as vn,S as mn,U as Sn,f as Ht,i as Wt,j as Ke,F as wn,l as bn,n as ms,t as zt,u as Ft,k as yn,v as Cn,V as kn,_ as xn}from"./index-BJ-YiA9y.js";/**
1
+ import{e as dn,r as ct,O as un,P as _n,o as fn,x as pn,Q as vs,J as gn,R as vn,S as mn,U as Sn,f as Ht,i as Wt,j as Ke,F as wn,l as bn,n as ms,t as zt,u as Ft,k as yn,v as Cn,V as kn,_ as xn}from"./index-Q0GrjPAB.js";/**
2
2
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
3
  * @license MIT
4
4
  *