@muyichengshayu/promptx 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.5
4
+
5
+ - 工作台新增任务级未读提醒:当非当前聚焦任务的一次 agent turn 进入终态后,任务卡片会显示未读红点,浏览器页签标题也会切换为“你有新消息”,帮助在多任务并行时更快发现新进展。
6
+ - 新增通知音能力与通用设置开关:通用设置里可单独控制是否播放任务未读提示音,默认关闭;同时补齐音频兼容、首次交互解锁与缓存刷新逻辑,减少浏览器不响或误触发的情况。
7
+ - 收敛未读状态细节与稳定性:当前任务前台聚焦时不会误记未读;切换任务后中栏 Agent 过滤会自动回到“全部”;未读去重缓存改为可回收并设置上限,避免工作台长时间打开后内存状态持续膨胀。
8
+ - 补齐未读通知相关回归测试,并修正页签标题国际化与主题色细节,确保中英文环境和不同主题下的体验更一致。
9
+
3
10
  ## 0.2.4
4
11
 
5
12
  - 重构远程命令安全模型:把远程 `shell` 命令放行从旧的 Relay 高权限开关收口到统一的 `remoteCommandSecurity` 配置,明确区分 `disabled / relay / trusted-proxy` 三种模式;本机 loopback 访问继续默认允许,远程入口则必须显式匹配对应安全模式。
@@ -1,3 +1,3 @@
1
- import{W as dt,f as ht,m as Mt,s as jt,n as It,o as ut,d as Et,p as tt,c as Pt,q as ct,t as ft,v as At,w as qe,x as Dt,y as et}from"./WorkbenchView-EAjf4pvb.js";import{u as Ve,f as Rt,e as Tt}from"./index-DpCCivzJ.js";import{w as oe,n as me,ak as at,aD as c,aI as re,aJ as De,aF as n,aQ as d,u as i,aG as I,aW as Lt,aU as Bt,aX as Ft,aE as g,aR as he,aS as Se,aL as O,aN as M,aV as Nt,aK as nt,b as $,c as C,o as Ot,aZ as yt,r as Ut}from"./vendor-misc-u-M8sNMf.js";import{c as Ht,L as Ge,F as Xe,e as zt,b as st,X as pt,C as Kt,M as qt,j as Vt,x as Wt,P as Qt,i as gt,E as Gt,N as Xt,q as Jt,r as Yt,O as Zt}from"./vendor-ui-BwEQCho1.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";const en={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},nn={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},sn={class:"flex items-start gap-2 text-xs leading-5"},an={class:"theme-muted-text shrink-0"},ln={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},on={class:"theme-muted-text mt-4 block text-xs"},rn={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},dn=["placeholder"],un={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},cn={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},fn={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},pn={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},gn={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},vn={key:4,class:"theme-empty-state px-3 py-8 text-sm"},mn={key:5,class:"theme-empty-state px-3 py-8 text-sm"},hn={key:6,class:"theme-empty-state px-3 py-8 text-sm"},yn={key:7,class:"space-y-1"},xn=["onClick"],bn={class:"min-w-0 flex-1"},wn=["innerHTML"],Sn=["innerHTML"],kn={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},Cn={key:8,class:"space-y-1"},_n={class:"flex items-start gap-1.5"},$n=["onClick"],Mn=["onClick"],jn={class:"min-w-0 flex-1"},In={key:0,class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all"},En={class:"theme-divider flex flex-col-reverse gap-2 border-t border-dashed px-4 py-4 sm:flex-row sm:items-center sm:justify-end sm:px-5"},Pn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},An=["disabled"],Dn=["disabled"],Rn={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve(),B=$(""),D=$(null),p=$(!1),S=$(""),E=$(!1),o=$(""),b=$([]),P=$(!1),u=$(""),_=$(""),de=$(null);let V=null,U=0,F=null;const H=new Map,z=C(()=>$e(D.value?[D.value]:[])),G=C(()=>String(u.value||"").trim()),X=C(()=>G.value.length>=dt),R=C(()=>!!G.value),Q=C(()=>R.value?b.value:z.value),Z=C(()=>Q.value.map(e=>{const l=m((e==null?void 0:e.path)||""),s=e!=null&&e.expanded?1:0,f=e!=null&&e.loading?1:0;return`${l}:${s}:${f}`}).join("|")),ge=C(()=>R.value&&!X.value&&!E.value&&!o.value),ae=C(()=>R.value&&X.value&&!E.value&&!o.value&&!b.value.length),J=C(()=>!R.value&&!p.value&&!S.value&&!z.value.length);function h(e=""){const l=String(e||"").trim();return/^[a-z]:[\\/]/i.test(l)||l.includes("\\")}function m(e=""){const l=String(e||"").trim();if(!l)return"";const s=h(l);let f=l.replace(/\\/g,"/");return f.length>1&&!/^[a-z]:\/?$/i.test(f)&&f!=="/"&&(f=f.replace(/\/+$/,"")),s?f.toLowerCase():f}function v(e="",l=""){const s=m(e),f=m(l);return!s||!f?!1:s===f||s.startsWith(`${f}/`)}function K(e="",l=""){const s=String(e||"").trim(),f=String(l||"").trim();return s?f?h(s)?/^[a-z]:\\?$/i.test(s)?`${s.replace(/[\\/]+$/,"")}\\${f}`:`${s.replace(/[\\/]+$/,"")}\\${f}`:s==="/"?`/${f}`:`${s.replace(/\/+$/,"")}/${f}`:s:f}function ee(e="",l=""){const s=m(e),f=m(l);if(!s||!f||!v(f,s))return[];const W=f===s?"":f.slice(s.length).replace(/^\//,"");return W?W.split("/").filter(Boolean):[]}function w(e=""){const l=String(e||"").trim();if(!l||m(l)===m(B.value))return"";const s=h(l),f=l.replace(/\\/g,"/");if(s){const ie=f.replace(/\/+$/,""),le=ie.lastIndexOf("/");if(le<=2)return"";const ze=ie.slice(0,le).replace(/\//g,"\\");return v(ze,B.value)?ze:""}const W=f.replace(/\/+$/,""),se=W.lastIndexOf("/");if(se<=0)return"";const we=W.slice(0,se)||"/";return v(we,B.value)?we:""}function ke(e){return(e==null?void 0:e.name)||(e==null?void 0:e.path)||y("directoryPicker.unnamedDirectory")}function Je(e=""){const l=String(e||"").trim();return l?l.split(/[\\/]/).filter(Boolean).at(-1)||l:"Home"}function ue(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ce(e="",l=""){const s=String(e||""),f=String(l||"").trim().toLowerCase();if(!s||!f)return null;const W=s.toLowerCase(),se=W.indexOf(f);if(se>=0)return{start:se,end:se+f.length};const we=f.split(/[\\/\s_.-]+/).filter(Boolean).sort((ie,le)=>le.length-ie.length);for(const ie of we){if(ie.length<2)continue;const le=W.indexOf(ie);if(le>=0)return{start:le,end:le+ie.length}}return null}function _e(e="",l=""){const s=String(e||""),f=Ce(s,l);return f?`${ue(s.slice(0,f.start))}<mark class="theme-search-highlight">${ue(s.slice(f.start,f.end))}</mark>${ue(s.slice(f.end))}`:ue(s)}function ce(e){return _e(ke(e),u.value)}function T(e){return _e((e==null?void 0:e.path)||"",u.value)}function Re(e,l=0){return{...e,depth:l,expanded:!1,loaded:!1,loading:!1,children:[]}}function $e(e=[],l=[]){return e.forEach(s=>{l.push(s),s.expanded&&s.children.length&&$e(s.children,l)}),l}function fe(){D.value&&(D.value={...D.value})}function ye(){V&&(window.clearTimeout(V),V=null),F&&(F.abort(),F=null)}function xe(e,l=D.value?[D.value]:[]){const s=m(e);if(!s)return null;for(const f of l){if(m(f.path)===s)return f;if(f.children.length){const W=xe(e,f.children);if(W)return W}}return null}function Y(e){_.value=String((e==null?void 0:e.path)||"").trim()}function pe(e=""){return m(e)}function Te(e,l){const s=pe(e);if(s){if(l){H.set(s,l);return}H.delete(s)}}function be(){var l;const e=H.get(pe(_.value));(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})}function We(){me(()=>{var e,l;(l=(e=de.value)==null?void 0:e.focus)==null||l.call(e)})}function Ye(){const e=Q.value;if(!e.length){_.value="";return}const l=pe(_.value);l&&e.some(s=>pe((s==null?void 0:s.path)||"")===l)||Y(e[0])}function Me(){const e=Q.value;if(!e.length)return-1;const l=pe(_.value),s=e.findIndex(f=>pe((f==null?void 0:f.path)||"")===l);return s>=0?s:0}function te(){const e=Q.value,l=Me();return l<0||!e.length?null:e[l]||null}function ve(e=1){const l=Q.value;if(!l.length)return!1;const s=Me(),f=s<0?0:(s+e+l.length)%l.length;return Y(l[f]),me(be),!0}async function Qe(){if(R.value)return!1;const e=te();if(!e||!e.hasChildren)return!1;if(!e.expanded)return await ne(e),!0;const l=Q.value,s=Me(),f=l[s+1];return f&&w(f.path)===e.path?(Y(f),me(be),!0):!1}function Le(){if(R.value)return!1;const e=te();if(!e)return!1;if(e.expanded&&e.hasChildren)return e.expanded=!1,fe(),Y(e),!0;const l=w(e.path);if(!l)return!1;const s=xe(l);return s?(Y(s),me(be),!0):!1}function je(e){var l,s,f;if((l=e==null?void 0:e.preventDefault)==null||l.call(e),G.value){(s=e==null?void 0:e.stopPropagation)==null||s.call(e),u.value="";return}(f=e==null?void 0:e.stopPropagation)==null||f.call(e),A("close")}function Be(e){const l=String((e==null?void 0:e.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(l)&&!(R.value&&(l==="ArrowLeft"||l==="ArrowRight"))){if(l==="ArrowDown"){e.preventDefault(),ve(1);return}if(l==="ArrowUp"){e.preventDefault(),ve(-1);return}if(l==="Escape"){je(e);return}if(R.value){if(l==="Enter"){e.preventDefault();const s=te();s&&Ue(s)}return}if(l==="ArrowRight"){e.preventDefault(),Qe();return}if(l==="ArrowLeft"){e.preventDefault(),Le();return}l==="Enter"&&(e.preventDefault(),He())}}async function Ie(e,l={}){if(!(!e||e.loading)&&!(e.loaded&&!l.force)){e.loading=!0,S.value="",fe();try{const s=await ut({path:e.path,limit:240});e.children=(s.items||[]).map(f=>Re(f,e.depth+1)),e.loaded=!0}catch(s){S.value=s.message||y("directoryPicker.loadFailed")}finally{e.loading=!1,fe()}}}async function Ee(){p.value=!0,S.value="";try{const e=await ut({limit:240});B.value=String(e.path||""),D.value=Re({name:Je(e.path||""),path:String(e.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),D.value.children=(e.items||[]).map(l=>Re(l,1)),D.value.loaded=!0,D.value.expanded=!0,Y(D.value)}catch(e){S.value=e.message||y("directoryPicker.treeLoadFailed"),D.value=null,B.value=""}finally{p.value=!1}}async function Fe(e=""){const l=String(e||"").trim();if(!l||!B.value||!v(l,B.value))return;let s=D.value;if(!s)return;Y(s);const f=ee(B.value,l);for(const W of f){await Ie(s),s.expanded=!0,fe();const se=xe(K(s.path,W),s.children);if(!se)break;s=se,Y(s)}}async function Pe(){u.value="",b.value=[],o.value="",P.value=!1,_.value="",await Ee();const e=String(j.initialPath||"").trim();e&&v(e,B.value)&&await Fe(e)}async function ne(e){if(e!=null&&e.path&&(Y(e),!!e.hasChildren)){if(!e.loaded){e.expanded=!0,fe(),await Ie(e);return}e.expanded=!e.expanded,fe()}}function Ae(e){e!=null&&e.path&&Y(e)}async function Ne(){const e=String(u.value||"").trim();U+=1;const l=U;if(ye(),!j.open||!e||!B.value||!X.value){E.value=!1,o.value="",b.value=[],P.value=!1;return}E.value=!0,o.value="",F=new AbortController;try{const s=await jt(e,{path:B.value,limit:80,signal:F.signal});if(l!==U)return;b.value=Array.isArray(s.items)?s.items:[],P.value=!!s.truncated}catch(s){if(It(s)||l!==U)return;o.value=s.message||y("directoryPicker.searchFailed"),b.value=[],P.value=!1}finally{l===U&&(F=null),l===U&&(E.value=!1)}}function Oe(){if(ye(),!String(u.value||"").trim()||!X.value){E.value=!1,o.value="",b.value=[],P.value=!1;return}E.value=!0,o.value="",V=window.setTimeout(()=>{V=null,Ne()},Mt)}async function Ue(e){e!=null&&e.path&&(await Fe(e.path),u.value="")}function He(){_.value&&(A("select",_.value),A("close"))}return oe(u,()=>{Oe()}),oe(Z,()=>{Ye(),me(be)},{immediate:!0}),oe(()=>j.open,e=>{if(e){Pe().catch(()=>{}),We();return}ye()}),at(()=>{ye()}),(e,l)=>(c(),re(ht,{open:r.open,"stack-level":1,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-4xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":p.value||E.value,"close-on-backdrop":!(p.value||E.value),"close-on-escape":!(p.value||E.value),onClose:l[2]||(l[2]=s=>A("close"))},{title:De(()=>[n("div",null,[n("div",en,[I(i(Xe),{class:"h-4 w-4"}),n("span",null,d(i(y)("directoryPicker.title")),1)]),n("p",tn,d(i(y)("directoryPicker.intro")),1)])]),default:De(()=>[n("div",{class:"flex min-h-0 flex-1 flex-col overflow-hidden",onKeydown:Be},[n("div",nn,[n("div",sn,[n("span",an,d(i(y)("directoryPicker.currentSelection")),1),n("span",ln,d(_.value||i(y)("directoryPicker.selectionPlaceholder")),1)])]),n("label",on,[n("span",null,d(i(y)("directoryPicker.searchLabel")),1),n("div",rn,[I(i(Ht),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Lt(n("input",{ref_key:"searchInputRef",ref:de,"onUpdate:modelValue":l[0]||(l[0]=s=>u.value=s),type:"text",placeholder:i(y)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]",onKeydown:Bt(je,["esc"])},null,40,dn),[[Ft,u.value]])])]),n("div",un,[R.value&&o.value?(c(),g("div",cn,d(o.value),1)):!R.value&&S.value?(c(),g("div",fn,d(S.value),1)):R.value&&E.value?(c(),g("div",pn,[I(i(Ge),{class:"h-4 w-4 animate-spin"}),n("span",null,d(i(y)("directoryPicker.searching")),1)])):!R.value&&p.value?(c(),g("div",gn,[I(i(Ge),{class:"h-4 w-4 animate-spin"}),n("span",null,d(i(y)("directoryPicker.treeLoading")),1)])):ge.value?(c(),g("div",vn,d(i(y)("directoryPicker.searchMinKeywordHint",{count:i(dt)})),1)):ae.value?(c(),g("div",mn,d(i(y)("directoryPicker.noSearchResults")),1)):J.value?(c(),g("div",hn,d(i(y)("directoryPicker.emptyTree")),1)):R.value?(c(),g("div",yn,[(c(!0),g(he,null,Se(b.value,s=>(c(),g("button",{key:s.path,ref_for:!0,ref:f=>Te(s.path,f),type:"button",class:O(["theme-list-row focus:outline-none",m(_.value)===m(s.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:f=>Ue(s)},[I(i(Xe),{class:"theme-list-item-icon"}),n("div",bn,[n("div",null,[n("span",{class:"theme-list-item-title block break-all",innerHTML:ce(s)},null,8,wn)]),n("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:T(s)},null,8,Sn)])],10,xn))),128)),P.value?(c(),g("p",kn,d(i(y)("directoryPicker.truncatedHint")),1)):M("",!0)])):(c(),g("div",Cn,[(c(!0),g(he,null,Se(z.value,s=>(c(),g("div",{key:s.path,ref_for:!0,ref:f=>Te(s.path,f),class:O(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",m(_.value)===m(s.path)?"theme-list-item-active":s.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nt({paddingLeft:`${s.depth*16+6}px`})},[n("div",_n,[n("button",{type:"button",class:O(["theme-icon-button h-5 w-5 shrink-0",s.hasChildren?"":"invisible pointer-events-none"]),onClick:nt(f=>ne(s),["stop"])},[s.loading?(c(),re(i(Ge),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(c(),re(i(zt),{key:1,class:O(["h-3.5 w-3.5 transition",s.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,$n),n("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:f=>Ae(s)},[I(i(Xe),{class:O(["h-4 w-4 shrink-0",m(_.value)===m(s.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),n("div",jn,[n("div",{class:O(["theme-list-item-title truncate",s.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},d(ke(s)),3),s.isHomeRoot?(c(),g("div",In,d(s.path),1)):M("",!0)])],8,Mn)])],6))),128))]))])],32),n("div",En,[n("div",Pn,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:p.value||E.value,onClick:l[1]||(l[1]=s=>A("close"))},d(i(y)("directoryPicker.cancel")),9,An),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:p.value||E.value||!_.value,onClick:He},[I(i(st),{class:"h-4 w-4"}),n("span",null,d(i(y)("directoryPicker.useCurrentDirectory")),1)],8,Dn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Tn={class:"grid gap-4"},Ln={class:"theme-muted-text block text-xs"},Bn=["value","disabled"],Fn={class:"theme-muted-text block text-xs"},Nn={class:"mt-1 flex gap-2"},On={class:"relative min-w-0 flex-1"},Un=["value","disabled"],Hn=["disabled"],zn=["disabled"],Kn={id:"codex-manager-workspace-suggestions"},qn=["value"],Vn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Wn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Qn={class:"theme-muted-text block text-xs"},Gn={class:"mt-1"},Xn={class:"flex items-center gap-2 text-sm"},Jn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Yn=["disabled","onClick"],Zn={class:"flex items-center justify-between gap-3"},es={class:"min-w-0 flex-1 truncate"},ts={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},ns={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},ss={class:"theme-muted-text block text-xs"},as={class:"mt-2 grid gap-2"},is=["disabled","onClick"],ls={class:"min-w-0"},os={class:"text-sm text-[var(--theme-textPrimary)]"},rs={class:"theme-muted-text mt-0.5 text-[11px] leading-5"},ds={class:"theme-muted-text mt-2 text-[11px] leading-5"},us={class:"theme-muted-text block text-xs"},cs={class:"mt-1 flex gap-2"},fs=["value","disabled"],ps=["disabled"],gs={key:1,class:"theme-popover theme-divider absolute left-0 right-0 top-[calc(100%+0.375rem)] z-20 overflow-hidden rounded-sm border border-solid shadow-sm"},vs={class:"flex items-center justify-between gap-2 border-b border-solid px-3 py-2 text-[11px] leading-5"},ms={class:"font-medium text-[var(--theme-textPrimary)]"},hs={key:0,class:"theme-muted-text"},ys={key:0,class:"max-h-72 overflow-y-auto p-2"},xs=["disabled","onClick"],bs={class:"flex min-w-0 items-center justify-between gap-3"},ws={class:"min-w-0 flex-1 truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ss={class:"shrink-0 text-[11px] leading-4 text-[var(--theme-textMuted)]"},ks={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Cs=["disabled"],_s={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},$s={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},vt={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},agentEngines:{type:Array,default:()=>[]},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},sessionCandidates:{type:Array,default:()=>[]},sessionCandidatesLoading:{type:Boolean,default:!1},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","select-session-candidate","update:agentEngines","update:cwd","update:engine","update:sessionId","update:title"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve(),B=$(null),D=$(null),p=$(!1),S=$(-1),E=C(()=>{const h=String(j.engine||"").trim();return j.engineOptions.find(m=>String((m==null?void 0:m.value)||"").trim()===h)||null}),o=C(()=>{const h=Array.isArray(j.agentEngines)?j.agentEngines:[];return[...new Set(h.map(m=>String(m||"").trim()).filter(Boolean))]}),b=C(()=>j.engineOptions.filter(h=>String((h==null?void 0:h.value)||"").trim()!==String(j.engine||"").trim())),P=C(()=>!!String(j.cwd||"").trim()),u=C(()=>String(j.sessionId||"").trim()),_=C(()=>u.value.toLowerCase()),de=C(()=>j.sessionCandidates.filter(h=>h==null?void 0:h.matchedCwd)),V=C(()=>{const h=_.value,m=de.value;return h?m.filter(v=>[v==null?void 0:v.label,v==null?void 0:v.id,v==null?void 0:v.cwd].map(ee=>String(ee||"").toLowerCase()).some(ee=>ee.includes(h))).slice(0,10):m.slice(0,10)});function U(){j.busy||!j.canEditSessionId||!P.value||(p.value=!0)}function F(){p.value=!1,S.value=-1}function H(){const h=V.value;if(!h.length){S.value=-1;return}const m=h.findIndex(v=>v.id===u.value);S.value=m>=0?m:0}function z(){me(()=>{var h,m;(m=(h=D.value)==null?void 0:h.focus)==null||m.call(h)})}function G(){if(p.value){F();return}U(),z()}function X(){A("update:cwd","")}function R(h){if(!j.canEditEngine||j.busy)return;const m=String(h||"").trim(),v=o.value.includes(m)?o.value.filter(K=>K!==m):[...o.value,m];A("update:agentEngines",v)}function Q(){A("update:sessionId",""),F(),z()}function Z(h){var m;A("update:sessionId",((m=h==null?void 0:h.target)==null?void 0:m.value)||""),P.value&&U()}function ge(h){A("select-session-candidate",h),F(),z()}function ae(h){if(j.busy||!j.canEditSessionId||!P.value)return;const m=V.value;if(h.key==="ArrowDown"){if(h.preventDefault(),!p.value){U(),H();return}if(!m.length)return;S.value=S.value<0?0:Math.min(m.length-1,S.value+1);return}if(h.key==="ArrowUp"){if(h.preventDefault(),!p.value){U(),H();return}if(!m.length)return;S.value=S.value<0?m.length-1:Math.max(0,S.value-1);return}if(h.key==="Enter"&&p.value&&m.length&&S.value>=0){h.preventDefault(),ge(m[S.value]);return}h.key==="Escape"&&p.value&&(h.preventDefault(),F())}function J(h){!p.value||!B.value||B.value.contains(h.target)||F()}return oe(V,()=>{H()}),oe(()=>j.canEditSessionId,h=>{(!h||!P.value)&&F()}),oe(P,h=>{h||F()}),Ot(()=>{document.addEventListener("pointerdown",J)}),at(()=>{document.removeEventListener("pointerdown",J)}),(h,m)=>(c(),g("div",Tn,[n("label",Ln,[n("span",null,d(i(y)("projectManager.projectTitleOptional")),1),n("input",{value:r.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:r.busy,onInput:m[0]||(m[0]=v=>A("update:title",v.target.value))},null,40,Bn)]),n("label",Fn,[n("span",null,d(i(y)("projectManager.workingDirectoryField")),1),n("div",Nn,[n("div",On,[n("input",{value:r.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:O(["tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",r.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:r.busy||!r.canEditCwd,onInput:m[1]||(m[1]=v=>A("update:cwd",v.target.value))},null,42,Un),r.cwd&&r.canEditCwd?(c(),g("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:r.busy,onClick:X},[I(i(pt),{class:"h-3.5 w-3.5"})],8,Hn)):M("",!0)]),n("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:r.busy||!r.canEditCwd,onClick:m[2]||(m[2]=v=>A("open-directory-picker"))},[I(i(Xe),{class:"h-4 w-4"}),n("span",null,d(r.mobile?i(y)("projectManager.choose"):i(y)("projectManager.chooseDirectory")),1)],8,zn)]),n("datalist",Kn,[(c(!0),g(he,null,Se(r.workspaceSuggestions,v=>(c(),g("option",{key:v,value:v},null,8,qn))),128))]),r.duplicateCwdMessage?(c(),g("p",Vn,d(r.duplicateCwdMessage),1)):r.cwdReadonlyMessage?(c(),g("p",Wn,d(r.cwdReadonlyMessage),1)):M("",!0)]),n("label",Qn,[n("span",null,d(i(y)("projectManager.engineField")),1),n("div",Gn,[I(Et,{"model-value":r.engine,options:r.engineOptions,disabled:r.busy||!r.canEditEngine,placeholder:i(y)("projectManager.selectEngine"),"empty-text":i(y)("projectManager.noEngines"),"get-option-value":v=>(v==null?void 0:v.value)||"","onUpdate:modelValue":m[3]||(m[3]=v=>A("update:engine",v))},{trigger:De(({disabled:v})=>{var K;return[n("div",Xn,[n("span",{class:O(["min-w-0 flex-1 truncate",v?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},d(((K=E.value)==null?void 0:K.label)||i(y)("projectManager.selectEngine")),3),E.value&&E.value.enabled===!1?(c(),g("span",Jn,d(i(y)("projectManager.comingSoon")),1)):M("",!0)])]}),option:De(({option:v,selected:K,select:ee})=>[n("button",{type:"button",class:O(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",K?"theme-filter-active":"theme-filter-idle"]),disabled:(v==null?void 0:v.enabled)===!1,onClick:ee},[n("div",Zn,[n("span",es,d(v.label),1),(v==null?void 0:v.enabled)===!1?(c(),g("span",ts,d(i(y)("projectManager.comingSoon")),1)):M("",!0)])],10,Yn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),r.engineReadonlyMessage?(c(),g("p",ns,d(r.engineReadonlyMessage),1)):M("",!0)]),n("div",ss,[n("span",null,d(i(y)("projectManager.collaborationAgents")),1),n("div",as,[(c(!0),g(he,null,Se(b.value,v=>(c(),g("button",{key:v.value,type:"button",class:O(["theme-list-row flex items-center justify-between gap-3 rounded-sm border border-solid px-3 py-2 text-left transition",o.value.includes(v.value)?"theme-list-item-active":"theme-list-item-hover"]),disabled:r.busy||!r.canEditEngine,onClick:K=>R(v.value)},[n("div",ls,[n("div",os,d(v.label),1),n("div",rs,d(o.value.includes(v.value)?i(y)("projectManager.agentEnabled"):i(y)("projectManager.agentDisabled")),1)]),o.value.includes(v.value)?(c(),re(i(st),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textPrimary)]"})):M("",!0)],10,is))),128))]),n("p",ds,d(i(y)("projectManager.collaborationAgentsHint")),1)]),n("label",us,[n("span",null,d(i(y)("projectManager.sessionId")),1),n("div",cs,[n("div",{ref_key:"sessionComboboxRef",ref:B,class:"relative min-w-0 flex-1"},[n("input",{ref_key:"sessionInputRef",ref:D,value:r.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",disabled:r.busy||!r.canEditSessionId,onFocus:U,onInput:Z,onKeydown:ae},null,40,fs),r.canEditSessionId?(c(),g("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:r.busy||!P.value,onClick:G},[r.sessionCandidatesLoading?(c(),re(i(Ge),{key:0,class:"h-3.5 w-3.5 animate-spin"})):u.value?(c(),re(i(pt),{key:1,class:"h-3.5 w-3.5",onClick:nt(Q,["stop"])})):(c(),re(i(Kt),{key:2,class:O(["h-3.5 w-3.5 transition",p.value?"rotate-180":""])},null,8,["class"]))],8,ps)):M("",!0),r.canEditSessionId&&p.value?(c(),g("div",gs,[n("div",vs,[n("span",ms,d(i(y)("projectManager.sessionCandidates")),1),r.sessionCandidatesLoading?(c(),g("span",hs,d(i(y)("projectManager.sessionCandidatesLoading")),1)):M("",!0)]),V.value.length?(c(),g("div",ys,[(c(!0),g(he,null,Se(V.value,(v,K)=>(c(),g("button",{key:`${v.engine}:${v.id}`,type:"button",class:O(["theme-list-row mb-1 w-full px-2 py-1.5 text-left last:mb-0",K===S.value?"theme-list-item-active":"theme-list-item-hover"]),disabled:r.busy,onMousedown:m[4]||(m[4]=nt(()=>{},["prevent"])),onClick:ee=>ge(v)},[n("div",bs,[n("span",ws,d(v.label||v.id),1),n("span",Ss,d(v.updatedAtLabel||i(y)("projectManager.unknown")),1)])],42,xs))),128))])):(c(),g("div",ks,d(P.value?i(y)("projectManager.noSessionCandidates"):i(y)("projectManager.sessionCandidatesNeedDirectory")),1))])):M("",!0)],512),u.value?(c(),g("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:r.busy,onClick:m[5]||(m[5]=v=>A("copy-session-id"))},[r.sessionIdCopied?(c(),re(i(st),{key:0,class:"h-4 w-4"})):(c(),re(i(qt),{key:1,class:"h-4 w-4"})),n("span",null,d(r.sessionIdCopied?i(y)("projectManager.sessionIdCopied"):i(y)("projectManager.copySessionId")),1)],8,Cs)):M("",!0)]),r.sessionIdReadonlyMessage?(c(),g("p",_s,d(r.sessionIdReadonlyMessage),1)):(c(),g("p",$s,d(P.value?i(y)("projectManager.sessionIdHint"):i(y)("projectManager.sessionCandidatesNeedDirectory")),1))])]))}},Ms={class:"flex items-center justify-between gap-3"},js={class:"theme-heading text-sm font-medium"},Is={key:0,class:"theme-muted-text mt-1 text-xs"},Es=["disabled"],Ps=["onClick"],As={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Ds={class:"flex w-full flex-col gap-2 text-left"},Rs={class:"theme-heading min-w-0 text-sm font-medium"},Ts=["title"],Ls=["title"],Bs={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Fs={key:0,"aria-hidden":"true"},Ns={key:1},Os={class:"flex flex-wrap items-center gap-2 pt-1"},Us={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},mt={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:r=>r},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve();function B(S){return j.mode==="edit"&&j.editingSessionId===S.id?"theme-card-selected":j.isSessionRunning(S.id)?"theme-card-warning":"theme-card-idle-strong"}function D(S){return j.isCurrentSession(S.id)?y("projectManager.current"):y("projectManager.regular")}function p(S){return j.isCurrentSession(S.id)?"theme-status-info":"theme-status-neutral"}return(S,E)=>(c(),g("div",{class:O(r.mobile?"flex h-full min-h-0 flex-col":"")},[n("div",Ms,[n("div",null,[n("div",js,d(i(y)("projectManager.projectList")),1),r.hasSessions?M("",!0):(c(),g("p",Is,d(i(y)("projectManager.noProjects")),1))]),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:r.busy,onClick:E[0]||(E[0]=o=>A("create"))},[I(i(Vt),{class:"h-4 w-4"}),n("span",null,d(i(y)("projectManager.create")),1)],8,Es)]),n("div",{class:O(["mt-4 space-y-2",r.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(c(!0),g(he,null,Se(r.sessions,o=>{var b;return c(),g("article",{key:o.id,class:O(["relative cursor-pointer rounded-sm border p-3 transition",B(o)]),onClick:P=>A("select",o.id)},[r.mode==="edit"&&r.editingSessionId===o.id?(c(),g("span",As)):M("",!0),n("div",Ds,[n("div",Rs,[n("span",{class:"block truncate",title:o.title||i(y)("projectManager.untitledProject")},d(o.title||i(y)("projectManager.untitledProject")),9,Ts)]),n("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:o.cwd},d(o.cwd),9,Ls),n("div",Bs,[n("span",null,d(((b=o==null?void 0:o.agentBindings)==null?void 0:b.length)>1?i(y)("projectManager.agentCount",{count:o.agentBindings.length}):i(tt)(o.engine)),1),r.mobile?M("",!0):(c(),g("span",Fs,"·")),r.mobile?M("",!0):(c(),g("span",Ns,d(r.formatUpdatedAt(o.updatedAt)),1))]),n("div",Os,[n("span",{class:O(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",p(o)])},d(D(o)),3),n("span",{class:O(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",r.getRuntimeStatusClass(o.id)])},[r.isSessionRunning(o.id)?(c(),g("span",Us)):M("",!0),yt(" "+d(r.getRuntimeStatusLabel(o.id)),1)],2),n("span",{class:O(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",r.getThreadStatusClass(o)])},d(r.getThreadStatusLabel(o)),3)])])],10,Ps)}),128))],2)],2))}},Hs={class:"space-y-3"},zs={class:"dashed-panel px-3 py-3"},Ks={class:"theme-muted-text text-[11px]"},qs={class:"mt-2 flex flex-wrap gap-2"},Vs={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Ws={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},Qs={class:"dashed-panel px-3 py-3"},Gs={class:"theme-muted-text text-[11px]"},Xs={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},Js={key:0,class:"mt-2 flex flex-wrap gap-1.5"},Ys={class:"dashed-panel px-3 py-3"},Zs={class:"theme-muted-text text-[11px]"},ea={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ta={class:"dashed-panel px-3 py-3"},na={class:"theme-muted-text text-[11px]"},sa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},aa={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},la={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},oa={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:r=>r},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(r){const{t:q}=Ve();return(j,A)=>{var y,B,D,p,S,E,o,b,P;return c(),g("div",Hs,[n("div",zs,[n("div",Ks,d(i(q)("projectManager.runtimeStatus")),1),n("div",qs,[n("span",{class:O(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",r.getRuntimeStatusClass((y=r.activeSession)==null?void 0:y.id)])},[r.isSessionRunning((B=r.activeSession)==null?void 0:B.id)?(c(),g("span",Vs)):M("",!0),yt(" "+d(r.getRuntimeStatusLabel((D=r.activeSession)==null?void 0:D.id)),1)],2),n("span",{class:O(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",r.getThreadStatusClass(r.activeSession)])},d(r.getThreadStatusLabel(r.activeSession)),3),(p=r.activeSession)!=null&&p.id&&r.isCurrentSession(r.activeSession.id)?(c(),g("span",Ws,d(i(q)("projectManager.currentProject")),1)):M("",!0)])]),n("div",Qs,[n("div",Gs,d(i(q)("projectManager.engine")),1),n("div",Xs,d(i(tt)((S=r.activeSession)==null?void 0:S.engine)),1),((o=(E=r.activeSession)==null?void 0:E.agentBindings)==null?void 0:o.length)>1?(c(),g("div",Js,[(c(!0),g(he,null,Se(r.activeSession.agentBindings,u=>(c(),g("span",{key:u.engine,class:"theme-status-neutral inline-flex items-center rounded-sm border border-solid px-1.5 py-0.5 text-[10px]"},d(i(tt)(u.engine)),1))),128))])):M("",!0)]),n("div",Ys,[n("div",Zs,d(i(q)("projectManager.workingDirectory")),1),n("div",ea,d(((b=r.activeSession)==null?void 0:b.cwd)||i(q)("projectManager.notSet")),1)]),n("div",ta,[n("div",na,d(i(q)("projectManager.updatedAt")),1),n("div",sa,d(r.formatUpdatedAt((P=r.activeSession)==null?void 0:P.updatedAt)),1)]),n("div",aa,[n("div",ia,[I(i(Wt),{class:"h-3.5 w-3.5"}),n("span",null,d(i(q)("projectManager.note")),1)]),n("p",la,d(i(q)("projectManager.noteDescription")),1)])])}}},ra={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},da={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ua={class:"theme-divider theme-muted-panel border-b px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},ca={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},fa={class:"flex flex-wrap items-start justify-between gap-3"},pa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ga={class:"mt-5"},va={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},ma={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4 sm:flex-row sm:items-center sm:justify-between"},ha={class:"flex flex-wrap items-center gap-2"},ya=["disabled"],xa=["disabled"],ba=["disabled"],wa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Sa=["disabled"],ka=["disabled"],Ca=["disabled"],_a={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},$a={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ma={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},ja={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ia={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Ea=["disabled"],Pa={class:"min-w-0 flex-1"},Aa={class:"theme-heading truncate text-sm font-medium"},Da={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ra={class:"theme-divider border-b px-4 py-3"},Ta={class:"grid grid-cols-2 gap-2"},La=["disabled"],Ba={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Fa={key:0},Na={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Oa={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Ua=["disabled"],Ha=["disabled"],za=["disabled"],Ka=["disabled"],qa=3e3,Za={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session","open-source-browser"],setup(r,{expose:q,emit:j}){const A=new Map;function y(t="",a=""){const x=qe(t),k=et(a);return!x||!k?"":`${x}
1
+ import{W as dt,f as ht,m as Mt,s as jt,n as It,o as ut,d as Et,p as tt,c as Pt,q as ct,t as ft,v as At,w as qe,x as Dt,y as et}from"./WorkbenchView-3rJGJ6O2.js";import{u as Ve,f as Rt,e as Tt}from"./index-DCBAbk14.js";import{w as oe,n as me,ak as at,aD as c,aI as re,aJ as De,aF as n,aQ as d,u as i,aG as I,aW as Lt,aU as Bt,aX as Ft,aE as g,aR as he,aS as Se,aL as O,aN as M,aV as Nt,aK as nt,b as $,c as C,o as Ot,aZ as yt,r as Ut}from"./vendor-misc-u-M8sNMf.js";import{c as Ht,L as Ge,F as Xe,e as zt,b as st,X as pt,C as Kt,M as qt,j as Vt,x as Wt,P as Qt,i as gt,E as Gt,N as Xt,q as Jt,r as Yt,O as Zt}from"./vendor-ui-BwEQCho1.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";const en={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},nn={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},sn={class:"flex items-start gap-2 text-xs leading-5"},an={class:"theme-muted-text shrink-0"},ln={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},on={class:"theme-muted-text mt-4 block text-xs"},rn={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},dn=["placeholder"],un={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},cn={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},fn={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},pn={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},gn={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},vn={key:4,class:"theme-empty-state px-3 py-8 text-sm"},mn={key:5,class:"theme-empty-state px-3 py-8 text-sm"},hn={key:6,class:"theme-empty-state px-3 py-8 text-sm"},yn={key:7,class:"space-y-1"},xn=["onClick"],bn={class:"min-w-0 flex-1"},wn=["innerHTML"],Sn=["innerHTML"],kn={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},Cn={key:8,class:"space-y-1"},_n={class:"flex items-start gap-1.5"},$n=["onClick"],Mn=["onClick"],jn={class:"min-w-0 flex-1"},In={key:0,class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all"},En={class:"theme-divider flex flex-col-reverse gap-2 border-t border-dashed px-4 py-4 sm:flex-row sm:items-center sm:justify-end sm:px-5"},Pn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},An=["disabled"],Dn=["disabled"],Rn={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve(),B=$(""),D=$(null),p=$(!1),S=$(""),E=$(!1),o=$(""),b=$([]),P=$(!1),u=$(""),_=$(""),de=$(null);let V=null,U=0,F=null;const H=new Map,z=C(()=>$e(D.value?[D.value]:[])),G=C(()=>String(u.value||"").trim()),X=C(()=>G.value.length>=dt),R=C(()=>!!G.value),Q=C(()=>R.value?b.value:z.value),Z=C(()=>Q.value.map(e=>{const l=m((e==null?void 0:e.path)||""),s=e!=null&&e.expanded?1:0,f=e!=null&&e.loading?1:0;return`${l}:${s}:${f}`}).join("|")),ge=C(()=>R.value&&!X.value&&!E.value&&!o.value),ae=C(()=>R.value&&X.value&&!E.value&&!o.value&&!b.value.length),J=C(()=>!R.value&&!p.value&&!S.value&&!z.value.length);function h(e=""){const l=String(e||"").trim();return/^[a-z]:[\\/]/i.test(l)||l.includes("\\")}function m(e=""){const l=String(e||"").trim();if(!l)return"";const s=h(l);let f=l.replace(/\\/g,"/");return f.length>1&&!/^[a-z]:\/?$/i.test(f)&&f!=="/"&&(f=f.replace(/\/+$/,"")),s?f.toLowerCase():f}function v(e="",l=""){const s=m(e),f=m(l);return!s||!f?!1:s===f||s.startsWith(`${f}/`)}function K(e="",l=""){const s=String(e||"").trim(),f=String(l||"").trim();return s?f?h(s)?/^[a-z]:\\?$/i.test(s)?`${s.replace(/[\\/]+$/,"")}\\${f}`:`${s.replace(/[\\/]+$/,"")}\\${f}`:s==="/"?`/${f}`:`${s.replace(/\/+$/,"")}/${f}`:s:f}function ee(e="",l=""){const s=m(e),f=m(l);if(!s||!f||!v(f,s))return[];const W=f===s?"":f.slice(s.length).replace(/^\//,"");return W?W.split("/").filter(Boolean):[]}function w(e=""){const l=String(e||"").trim();if(!l||m(l)===m(B.value))return"";const s=h(l),f=l.replace(/\\/g,"/");if(s){const ie=f.replace(/\/+$/,""),le=ie.lastIndexOf("/");if(le<=2)return"";const ze=ie.slice(0,le).replace(/\//g,"\\");return v(ze,B.value)?ze:""}const W=f.replace(/\/+$/,""),se=W.lastIndexOf("/");if(se<=0)return"";const we=W.slice(0,se)||"/";return v(we,B.value)?we:""}function ke(e){return(e==null?void 0:e.name)||(e==null?void 0:e.path)||y("directoryPicker.unnamedDirectory")}function Je(e=""){const l=String(e||"").trim();return l?l.split(/[\\/]/).filter(Boolean).at(-1)||l:"Home"}function ue(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ce(e="",l=""){const s=String(e||""),f=String(l||"").trim().toLowerCase();if(!s||!f)return null;const W=s.toLowerCase(),se=W.indexOf(f);if(se>=0)return{start:se,end:se+f.length};const we=f.split(/[\\/\s_.-]+/).filter(Boolean).sort((ie,le)=>le.length-ie.length);for(const ie of we){if(ie.length<2)continue;const le=W.indexOf(ie);if(le>=0)return{start:le,end:le+ie.length}}return null}function _e(e="",l=""){const s=String(e||""),f=Ce(s,l);return f?`${ue(s.slice(0,f.start))}<mark class="theme-search-highlight">${ue(s.slice(f.start,f.end))}</mark>${ue(s.slice(f.end))}`:ue(s)}function ce(e){return _e(ke(e),u.value)}function T(e){return _e((e==null?void 0:e.path)||"",u.value)}function Re(e,l=0){return{...e,depth:l,expanded:!1,loaded:!1,loading:!1,children:[]}}function $e(e=[],l=[]){return e.forEach(s=>{l.push(s),s.expanded&&s.children.length&&$e(s.children,l)}),l}function fe(){D.value&&(D.value={...D.value})}function ye(){V&&(window.clearTimeout(V),V=null),F&&(F.abort(),F=null)}function xe(e,l=D.value?[D.value]:[]){const s=m(e);if(!s)return null;for(const f of l){if(m(f.path)===s)return f;if(f.children.length){const W=xe(e,f.children);if(W)return W}}return null}function Y(e){_.value=String((e==null?void 0:e.path)||"").trim()}function pe(e=""){return m(e)}function Te(e,l){const s=pe(e);if(s){if(l){H.set(s,l);return}H.delete(s)}}function be(){var l;const e=H.get(pe(_.value));(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})}function We(){me(()=>{var e,l;(l=(e=de.value)==null?void 0:e.focus)==null||l.call(e)})}function Ye(){const e=Q.value;if(!e.length){_.value="";return}const l=pe(_.value);l&&e.some(s=>pe((s==null?void 0:s.path)||"")===l)||Y(e[0])}function Me(){const e=Q.value;if(!e.length)return-1;const l=pe(_.value),s=e.findIndex(f=>pe((f==null?void 0:f.path)||"")===l);return s>=0?s:0}function te(){const e=Q.value,l=Me();return l<0||!e.length?null:e[l]||null}function ve(e=1){const l=Q.value;if(!l.length)return!1;const s=Me(),f=s<0?0:(s+e+l.length)%l.length;return Y(l[f]),me(be),!0}async function Qe(){if(R.value)return!1;const e=te();if(!e||!e.hasChildren)return!1;if(!e.expanded)return await ne(e),!0;const l=Q.value,s=Me(),f=l[s+1];return f&&w(f.path)===e.path?(Y(f),me(be),!0):!1}function Le(){if(R.value)return!1;const e=te();if(!e)return!1;if(e.expanded&&e.hasChildren)return e.expanded=!1,fe(),Y(e),!0;const l=w(e.path);if(!l)return!1;const s=xe(l);return s?(Y(s),me(be),!0):!1}function je(e){var l,s,f;if((l=e==null?void 0:e.preventDefault)==null||l.call(e),G.value){(s=e==null?void 0:e.stopPropagation)==null||s.call(e),u.value="";return}(f=e==null?void 0:e.stopPropagation)==null||f.call(e),A("close")}function Be(e){const l=String((e==null?void 0:e.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(l)&&!(R.value&&(l==="ArrowLeft"||l==="ArrowRight"))){if(l==="ArrowDown"){e.preventDefault(),ve(1);return}if(l==="ArrowUp"){e.preventDefault(),ve(-1);return}if(l==="Escape"){je(e);return}if(R.value){if(l==="Enter"){e.preventDefault();const s=te();s&&Ue(s)}return}if(l==="ArrowRight"){e.preventDefault(),Qe();return}if(l==="ArrowLeft"){e.preventDefault(),Le();return}l==="Enter"&&(e.preventDefault(),He())}}async function Ie(e,l={}){if(!(!e||e.loading)&&!(e.loaded&&!l.force)){e.loading=!0,S.value="",fe();try{const s=await ut({path:e.path,limit:240});e.children=(s.items||[]).map(f=>Re(f,e.depth+1)),e.loaded=!0}catch(s){S.value=s.message||y("directoryPicker.loadFailed")}finally{e.loading=!1,fe()}}}async function Ee(){p.value=!0,S.value="";try{const e=await ut({limit:240});B.value=String(e.path||""),D.value=Re({name:Je(e.path||""),path:String(e.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),D.value.children=(e.items||[]).map(l=>Re(l,1)),D.value.loaded=!0,D.value.expanded=!0,Y(D.value)}catch(e){S.value=e.message||y("directoryPicker.treeLoadFailed"),D.value=null,B.value=""}finally{p.value=!1}}async function Fe(e=""){const l=String(e||"").trim();if(!l||!B.value||!v(l,B.value))return;let s=D.value;if(!s)return;Y(s);const f=ee(B.value,l);for(const W of f){await Ie(s),s.expanded=!0,fe();const se=xe(K(s.path,W),s.children);if(!se)break;s=se,Y(s)}}async function Pe(){u.value="",b.value=[],o.value="",P.value=!1,_.value="",await Ee();const e=String(j.initialPath||"").trim();e&&v(e,B.value)&&await Fe(e)}async function ne(e){if(e!=null&&e.path&&(Y(e),!!e.hasChildren)){if(!e.loaded){e.expanded=!0,fe(),await Ie(e);return}e.expanded=!e.expanded,fe()}}function Ae(e){e!=null&&e.path&&Y(e)}async function Ne(){const e=String(u.value||"").trim();U+=1;const l=U;if(ye(),!j.open||!e||!B.value||!X.value){E.value=!1,o.value="",b.value=[],P.value=!1;return}E.value=!0,o.value="",F=new AbortController;try{const s=await jt(e,{path:B.value,limit:80,signal:F.signal});if(l!==U)return;b.value=Array.isArray(s.items)?s.items:[],P.value=!!s.truncated}catch(s){if(It(s)||l!==U)return;o.value=s.message||y("directoryPicker.searchFailed"),b.value=[],P.value=!1}finally{l===U&&(F=null),l===U&&(E.value=!1)}}function Oe(){if(ye(),!String(u.value||"").trim()||!X.value){E.value=!1,o.value="",b.value=[],P.value=!1;return}E.value=!0,o.value="",V=window.setTimeout(()=>{V=null,Ne()},Mt)}async function Ue(e){e!=null&&e.path&&(await Fe(e.path),u.value="")}function He(){_.value&&(A("select",_.value),A("close"))}return oe(u,()=>{Oe()}),oe(Z,()=>{Ye(),me(be)},{immediate:!0}),oe(()=>j.open,e=>{if(e){Pe().catch(()=>{}),We();return}ye()}),at(()=>{ye()}),(e,l)=>(c(),re(ht,{open:r.open,"stack-level":1,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-4xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":p.value||E.value,"close-on-backdrop":!(p.value||E.value),"close-on-escape":!(p.value||E.value),onClose:l[2]||(l[2]=s=>A("close"))},{title:De(()=>[n("div",null,[n("div",en,[I(i(Xe),{class:"h-4 w-4"}),n("span",null,d(i(y)("directoryPicker.title")),1)]),n("p",tn,d(i(y)("directoryPicker.intro")),1)])]),default:De(()=>[n("div",{class:"flex min-h-0 flex-1 flex-col overflow-hidden",onKeydown:Be},[n("div",nn,[n("div",sn,[n("span",an,d(i(y)("directoryPicker.currentSelection")),1),n("span",ln,d(_.value||i(y)("directoryPicker.selectionPlaceholder")),1)])]),n("label",on,[n("span",null,d(i(y)("directoryPicker.searchLabel")),1),n("div",rn,[I(i(Ht),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Lt(n("input",{ref_key:"searchInputRef",ref:de,"onUpdate:modelValue":l[0]||(l[0]=s=>u.value=s),type:"text",placeholder:i(y)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]",onKeydown:Bt(je,["esc"])},null,40,dn),[[Ft,u.value]])])]),n("div",un,[R.value&&o.value?(c(),g("div",cn,d(o.value),1)):!R.value&&S.value?(c(),g("div",fn,d(S.value),1)):R.value&&E.value?(c(),g("div",pn,[I(i(Ge),{class:"h-4 w-4 animate-spin"}),n("span",null,d(i(y)("directoryPicker.searching")),1)])):!R.value&&p.value?(c(),g("div",gn,[I(i(Ge),{class:"h-4 w-4 animate-spin"}),n("span",null,d(i(y)("directoryPicker.treeLoading")),1)])):ge.value?(c(),g("div",vn,d(i(y)("directoryPicker.searchMinKeywordHint",{count:i(dt)})),1)):ae.value?(c(),g("div",mn,d(i(y)("directoryPicker.noSearchResults")),1)):J.value?(c(),g("div",hn,d(i(y)("directoryPicker.emptyTree")),1)):R.value?(c(),g("div",yn,[(c(!0),g(he,null,Se(b.value,s=>(c(),g("button",{key:s.path,ref_for:!0,ref:f=>Te(s.path,f),type:"button",class:O(["theme-list-row focus:outline-none",m(_.value)===m(s.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:f=>Ue(s)},[I(i(Xe),{class:"theme-list-item-icon"}),n("div",bn,[n("div",null,[n("span",{class:"theme-list-item-title block break-all",innerHTML:ce(s)},null,8,wn)]),n("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:T(s)},null,8,Sn)])],10,xn))),128)),P.value?(c(),g("p",kn,d(i(y)("directoryPicker.truncatedHint")),1)):M("",!0)])):(c(),g("div",Cn,[(c(!0),g(he,null,Se(z.value,s=>(c(),g("div",{key:s.path,ref_for:!0,ref:f=>Te(s.path,f),class:O(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",m(_.value)===m(s.path)?"theme-list-item-active":s.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nt({paddingLeft:`${s.depth*16+6}px`})},[n("div",_n,[n("button",{type:"button",class:O(["theme-icon-button h-5 w-5 shrink-0",s.hasChildren?"":"invisible pointer-events-none"]),onClick:nt(f=>ne(s),["stop"])},[s.loading?(c(),re(i(Ge),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(c(),re(i(zt),{key:1,class:O(["h-3.5 w-3.5 transition",s.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,$n),n("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:f=>Ae(s)},[I(i(Xe),{class:O(["h-4 w-4 shrink-0",m(_.value)===m(s.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),n("div",jn,[n("div",{class:O(["theme-list-item-title truncate",s.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},d(ke(s)),3),s.isHomeRoot?(c(),g("div",In,d(s.path),1)):M("",!0)])],8,Mn)])],6))),128))]))])],32),n("div",En,[n("div",Pn,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:p.value||E.value,onClick:l[1]||(l[1]=s=>A("close"))},d(i(y)("directoryPicker.cancel")),9,An),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:p.value||E.value||!_.value,onClick:He},[I(i(st),{class:"h-4 w-4"}),n("span",null,d(i(y)("directoryPicker.useCurrentDirectory")),1)],8,Dn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Tn={class:"grid gap-4"},Ln={class:"theme-muted-text block text-xs"},Bn=["value","disabled"],Fn={class:"theme-muted-text block text-xs"},Nn={class:"mt-1 flex gap-2"},On={class:"relative min-w-0 flex-1"},Un=["value","disabled"],Hn=["disabled"],zn=["disabled"],Kn={id:"codex-manager-workspace-suggestions"},qn=["value"],Vn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Wn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Qn={class:"theme-muted-text block text-xs"},Gn={class:"mt-1"},Xn={class:"flex items-center gap-2 text-sm"},Jn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Yn=["disabled","onClick"],Zn={class:"flex items-center justify-between gap-3"},es={class:"min-w-0 flex-1 truncate"},ts={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},ns={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},ss={class:"theme-muted-text block text-xs"},as={class:"mt-2 grid gap-2"},is=["disabled","onClick"],ls={class:"min-w-0"},os={class:"text-sm text-[var(--theme-textPrimary)]"},rs={class:"theme-muted-text mt-0.5 text-[11px] leading-5"},ds={class:"theme-muted-text mt-2 text-[11px] leading-5"},us={class:"theme-muted-text block text-xs"},cs={class:"mt-1 flex gap-2"},fs=["value","disabled"],ps=["disabled"],gs={key:1,class:"theme-popover theme-divider absolute left-0 right-0 top-[calc(100%+0.375rem)] z-20 overflow-hidden rounded-sm border border-solid shadow-sm"},vs={class:"flex items-center justify-between gap-2 border-b border-solid px-3 py-2 text-[11px] leading-5"},ms={class:"font-medium text-[var(--theme-textPrimary)]"},hs={key:0,class:"theme-muted-text"},ys={key:0,class:"max-h-72 overflow-y-auto p-2"},xs=["disabled","onClick"],bs={class:"flex min-w-0 items-center justify-between gap-3"},ws={class:"min-w-0 flex-1 truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ss={class:"shrink-0 text-[11px] leading-4 text-[var(--theme-textMuted)]"},ks={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Cs=["disabled"],_s={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},$s={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},vt={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},agentEngines:{type:Array,default:()=>[]},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},sessionCandidates:{type:Array,default:()=>[]},sessionCandidatesLoading:{type:Boolean,default:!1},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","select-session-candidate","update:agentEngines","update:cwd","update:engine","update:sessionId","update:title"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve(),B=$(null),D=$(null),p=$(!1),S=$(-1),E=C(()=>{const h=String(j.engine||"").trim();return j.engineOptions.find(m=>String((m==null?void 0:m.value)||"").trim()===h)||null}),o=C(()=>{const h=Array.isArray(j.agentEngines)?j.agentEngines:[];return[...new Set(h.map(m=>String(m||"").trim()).filter(Boolean))]}),b=C(()=>j.engineOptions.filter(h=>String((h==null?void 0:h.value)||"").trim()!==String(j.engine||"").trim())),P=C(()=>!!String(j.cwd||"").trim()),u=C(()=>String(j.sessionId||"").trim()),_=C(()=>u.value.toLowerCase()),de=C(()=>j.sessionCandidates.filter(h=>h==null?void 0:h.matchedCwd)),V=C(()=>{const h=_.value,m=de.value;return h?m.filter(v=>[v==null?void 0:v.label,v==null?void 0:v.id,v==null?void 0:v.cwd].map(ee=>String(ee||"").toLowerCase()).some(ee=>ee.includes(h))).slice(0,10):m.slice(0,10)});function U(){j.busy||!j.canEditSessionId||!P.value||(p.value=!0)}function F(){p.value=!1,S.value=-1}function H(){const h=V.value;if(!h.length){S.value=-1;return}const m=h.findIndex(v=>v.id===u.value);S.value=m>=0?m:0}function z(){me(()=>{var h,m;(m=(h=D.value)==null?void 0:h.focus)==null||m.call(h)})}function G(){if(p.value){F();return}U(),z()}function X(){A("update:cwd","")}function R(h){if(!j.canEditEngine||j.busy)return;const m=String(h||"").trim(),v=o.value.includes(m)?o.value.filter(K=>K!==m):[...o.value,m];A("update:agentEngines",v)}function Q(){A("update:sessionId",""),F(),z()}function Z(h){var m;A("update:sessionId",((m=h==null?void 0:h.target)==null?void 0:m.value)||""),P.value&&U()}function ge(h){A("select-session-candidate",h),F(),z()}function ae(h){if(j.busy||!j.canEditSessionId||!P.value)return;const m=V.value;if(h.key==="ArrowDown"){if(h.preventDefault(),!p.value){U(),H();return}if(!m.length)return;S.value=S.value<0?0:Math.min(m.length-1,S.value+1);return}if(h.key==="ArrowUp"){if(h.preventDefault(),!p.value){U(),H();return}if(!m.length)return;S.value=S.value<0?m.length-1:Math.max(0,S.value-1);return}if(h.key==="Enter"&&p.value&&m.length&&S.value>=0){h.preventDefault(),ge(m[S.value]);return}h.key==="Escape"&&p.value&&(h.preventDefault(),F())}function J(h){!p.value||!B.value||B.value.contains(h.target)||F()}return oe(V,()=>{H()}),oe(()=>j.canEditSessionId,h=>{(!h||!P.value)&&F()}),oe(P,h=>{h||F()}),Ot(()=>{document.addEventListener("pointerdown",J)}),at(()=>{document.removeEventListener("pointerdown",J)}),(h,m)=>(c(),g("div",Tn,[n("label",Ln,[n("span",null,d(i(y)("projectManager.projectTitleOptional")),1),n("input",{value:r.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:r.busy,onInput:m[0]||(m[0]=v=>A("update:title",v.target.value))},null,40,Bn)]),n("label",Fn,[n("span",null,d(i(y)("projectManager.workingDirectoryField")),1),n("div",Nn,[n("div",On,[n("input",{value:r.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:O(["tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",r.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:r.busy||!r.canEditCwd,onInput:m[1]||(m[1]=v=>A("update:cwd",v.target.value))},null,42,Un),r.cwd&&r.canEditCwd?(c(),g("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:r.busy,onClick:X},[I(i(pt),{class:"h-3.5 w-3.5"})],8,Hn)):M("",!0)]),n("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:r.busy||!r.canEditCwd,onClick:m[2]||(m[2]=v=>A("open-directory-picker"))},[I(i(Xe),{class:"h-4 w-4"}),n("span",null,d(r.mobile?i(y)("projectManager.choose"):i(y)("projectManager.chooseDirectory")),1)],8,zn)]),n("datalist",Kn,[(c(!0),g(he,null,Se(r.workspaceSuggestions,v=>(c(),g("option",{key:v,value:v},null,8,qn))),128))]),r.duplicateCwdMessage?(c(),g("p",Vn,d(r.duplicateCwdMessage),1)):r.cwdReadonlyMessage?(c(),g("p",Wn,d(r.cwdReadonlyMessage),1)):M("",!0)]),n("label",Qn,[n("span",null,d(i(y)("projectManager.engineField")),1),n("div",Gn,[I(Et,{"model-value":r.engine,options:r.engineOptions,disabled:r.busy||!r.canEditEngine,placeholder:i(y)("projectManager.selectEngine"),"empty-text":i(y)("projectManager.noEngines"),"get-option-value":v=>(v==null?void 0:v.value)||"","onUpdate:modelValue":m[3]||(m[3]=v=>A("update:engine",v))},{trigger:De(({disabled:v})=>{var K;return[n("div",Xn,[n("span",{class:O(["min-w-0 flex-1 truncate",v?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},d(((K=E.value)==null?void 0:K.label)||i(y)("projectManager.selectEngine")),3),E.value&&E.value.enabled===!1?(c(),g("span",Jn,d(i(y)("projectManager.comingSoon")),1)):M("",!0)])]}),option:De(({option:v,selected:K,select:ee})=>[n("button",{type:"button",class:O(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",K?"theme-filter-active":"theme-filter-idle"]),disabled:(v==null?void 0:v.enabled)===!1,onClick:ee},[n("div",Zn,[n("span",es,d(v.label),1),(v==null?void 0:v.enabled)===!1?(c(),g("span",ts,d(i(y)("projectManager.comingSoon")),1)):M("",!0)])],10,Yn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),r.engineReadonlyMessage?(c(),g("p",ns,d(r.engineReadonlyMessage),1)):M("",!0)]),n("div",ss,[n("span",null,d(i(y)("projectManager.collaborationAgents")),1),n("div",as,[(c(!0),g(he,null,Se(b.value,v=>(c(),g("button",{key:v.value,type:"button",class:O(["theme-list-row flex items-center justify-between gap-3 rounded-sm border border-solid px-3 py-2 text-left transition",o.value.includes(v.value)?"theme-list-item-active":"theme-list-item-hover"]),disabled:r.busy||!r.canEditEngine,onClick:K=>R(v.value)},[n("div",ls,[n("div",os,d(v.label),1),n("div",rs,d(o.value.includes(v.value)?i(y)("projectManager.agentEnabled"):i(y)("projectManager.agentDisabled")),1)]),o.value.includes(v.value)?(c(),re(i(st),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textPrimary)]"})):M("",!0)],10,is))),128))]),n("p",ds,d(i(y)("projectManager.collaborationAgentsHint")),1)]),n("label",us,[n("span",null,d(i(y)("projectManager.sessionId")),1),n("div",cs,[n("div",{ref_key:"sessionComboboxRef",ref:B,class:"relative min-w-0 flex-1"},[n("input",{ref_key:"sessionInputRef",ref:D,value:r.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",disabled:r.busy||!r.canEditSessionId,onFocus:U,onInput:Z,onKeydown:ae},null,40,fs),r.canEditSessionId?(c(),g("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:r.busy||!P.value,onClick:G},[r.sessionCandidatesLoading?(c(),re(i(Ge),{key:0,class:"h-3.5 w-3.5 animate-spin"})):u.value?(c(),re(i(pt),{key:1,class:"h-3.5 w-3.5",onClick:nt(Q,["stop"])})):(c(),re(i(Kt),{key:2,class:O(["h-3.5 w-3.5 transition",p.value?"rotate-180":""])},null,8,["class"]))],8,ps)):M("",!0),r.canEditSessionId&&p.value?(c(),g("div",gs,[n("div",vs,[n("span",ms,d(i(y)("projectManager.sessionCandidates")),1),r.sessionCandidatesLoading?(c(),g("span",hs,d(i(y)("projectManager.sessionCandidatesLoading")),1)):M("",!0)]),V.value.length?(c(),g("div",ys,[(c(!0),g(he,null,Se(V.value,(v,K)=>(c(),g("button",{key:`${v.engine}:${v.id}`,type:"button",class:O(["theme-list-row mb-1 w-full px-2 py-1.5 text-left last:mb-0",K===S.value?"theme-list-item-active":"theme-list-item-hover"]),disabled:r.busy,onMousedown:m[4]||(m[4]=nt(()=>{},["prevent"])),onClick:ee=>ge(v)},[n("div",bs,[n("span",ws,d(v.label||v.id),1),n("span",Ss,d(v.updatedAtLabel||i(y)("projectManager.unknown")),1)])],42,xs))),128))])):(c(),g("div",ks,d(P.value?i(y)("projectManager.noSessionCandidates"):i(y)("projectManager.sessionCandidatesNeedDirectory")),1))])):M("",!0)],512),u.value?(c(),g("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:r.busy,onClick:m[5]||(m[5]=v=>A("copy-session-id"))},[r.sessionIdCopied?(c(),re(i(st),{key:0,class:"h-4 w-4"})):(c(),re(i(qt),{key:1,class:"h-4 w-4"})),n("span",null,d(r.sessionIdCopied?i(y)("projectManager.sessionIdCopied"):i(y)("projectManager.copySessionId")),1)],8,Cs)):M("",!0)]),r.sessionIdReadonlyMessage?(c(),g("p",_s,d(r.sessionIdReadonlyMessage),1)):(c(),g("p",$s,d(P.value?i(y)("projectManager.sessionIdHint"):i(y)("projectManager.sessionCandidatesNeedDirectory")),1))])]))}},Ms={class:"flex items-center justify-between gap-3"},js={class:"theme-heading text-sm font-medium"},Is={key:0,class:"theme-muted-text mt-1 text-xs"},Es=["disabled"],Ps=["onClick"],As={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Ds={class:"flex w-full flex-col gap-2 text-left"},Rs={class:"theme-heading min-w-0 text-sm font-medium"},Ts=["title"],Ls=["title"],Bs={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Fs={key:0,"aria-hidden":"true"},Ns={key:1},Os={class:"flex flex-wrap items-center gap-2 pt-1"},Us={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},mt={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:r=>r},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve();function B(S){return j.mode==="edit"&&j.editingSessionId===S.id?"theme-card-selected":j.isSessionRunning(S.id)?"theme-card-warning":"theme-card-idle-strong"}function D(S){return j.isCurrentSession(S.id)?y("projectManager.current"):y("projectManager.regular")}function p(S){return j.isCurrentSession(S.id)?"theme-status-info":"theme-status-neutral"}return(S,E)=>(c(),g("div",{class:O(r.mobile?"flex h-full min-h-0 flex-col":"")},[n("div",Ms,[n("div",null,[n("div",js,d(i(y)("projectManager.projectList")),1),r.hasSessions?M("",!0):(c(),g("p",Is,d(i(y)("projectManager.noProjects")),1))]),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:r.busy,onClick:E[0]||(E[0]=o=>A("create"))},[I(i(Vt),{class:"h-4 w-4"}),n("span",null,d(i(y)("projectManager.create")),1)],8,Es)]),n("div",{class:O(["mt-4 space-y-2",r.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(c(!0),g(he,null,Se(r.sessions,o=>{var b;return c(),g("article",{key:o.id,class:O(["relative cursor-pointer rounded-sm border p-3 transition",B(o)]),onClick:P=>A("select",o.id)},[r.mode==="edit"&&r.editingSessionId===o.id?(c(),g("span",As)):M("",!0),n("div",Ds,[n("div",Rs,[n("span",{class:"block truncate",title:o.title||i(y)("projectManager.untitledProject")},d(o.title||i(y)("projectManager.untitledProject")),9,Ts)]),n("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:o.cwd},d(o.cwd),9,Ls),n("div",Bs,[n("span",null,d(((b=o==null?void 0:o.agentBindings)==null?void 0:b.length)>1?i(y)("projectManager.agentCount",{count:o.agentBindings.length}):i(tt)(o.engine)),1),r.mobile?M("",!0):(c(),g("span",Fs,"·")),r.mobile?M("",!0):(c(),g("span",Ns,d(r.formatUpdatedAt(o.updatedAt)),1))]),n("div",Os,[n("span",{class:O(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",p(o)])},d(D(o)),3),n("span",{class:O(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",r.getRuntimeStatusClass(o.id)])},[r.isSessionRunning(o.id)?(c(),g("span",Us)):M("",!0),yt(" "+d(r.getRuntimeStatusLabel(o.id)),1)],2),n("span",{class:O(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",r.getThreadStatusClass(o)])},d(r.getThreadStatusLabel(o)),3)])])],10,Ps)}),128))],2)],2))}},Hs={class:"space-y-3"},zs={class:"dashed-panel px-3 py-3"},Ks={class:"theme-muted-text text-[11px]"},qs={class:"mt-2 flex flex-wrap gap-2"},Vs={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Ws={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},Qs={class:"dashed-panel px-3 py-3"},Gs={class:"theme-muted-text text-[11px]"},Xs={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},Js={key:0,class:"mt-2 flex flex-wrap gap-1.5"},Ys={class:"dashed-panel px-3 py-3"},Zs={class:"theme-muted-text text-[11px]"},ea={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ta={class:"dashed-panel px-3 py-3"},na={class:"theme-muted-text text-[11px]"},sa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},aa={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},la={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},oa={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:r=>r},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(r){const{t:q}=Ve();return(j,A)=>{var y,B,D,p,S,E,o,b,P;return c(),g("div",Hs,[n("div",zs,[n("div",Ks,d(i(q)("projectManager.runtimeStatus")),1),n("div",qs,[n("span",{class:O(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",r.getRuntimeStatusClass((y=r.activeSession)==null?void 0:y.id)])},[r.isSessionRunning((B=r.activeSession)==null?void 0:B.id)?(c(),g("span",Vs)):M("",!0),yt(" "+d(r.getRuntimeStatusLabel((D=r.activeSession)==null?void 0:D.id)),1)],2),n("span",{class:O(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",r.getThreadStatusClass(r.activeSession)])},d(r.getThreadStatusLabel(r.activeSession)),3),(p=r.activeSession)!=null&&p.id&&r.isCurrentSession(r.activeSession.id)?(c(),g("span",Ws,d(i(q)("projectManager.currentProject")),1)):M("",!0)])]),n("div",Qs,[n("div",Gs,d(i(q)("projectManager.engine")),1),n("div",Xs,d(i(tt)((S=r.activeSession)==null?void 0:S.engine)),1),((o=(E=r.activeSession)==null?void 0:E.agentBindings)==null?void 0:o.length)>1?(c(),g("div",Js,[(c(!0),g(he,null,Se(r.activeSession.agentBindings,u=>(c(),g("span",{key:u.engine,class:"theme-status-neutral inline-flex items-center rounded-sm border border-solid px-1.5 py-0.5 text-[10px]"},d(i(tt)(u.engine)),1))),128))])):M("",!0)]),n("div",Ys,[n("div",Zs,d(i(q)("projectManager.workingDirectory")),1),n("div",ea,d(((b=r.activeSession)==null?void 0:b.cwd)||i(q)("projectManager.notSet")),1)]),n("div",ta,[n("div",na,d(i(q)("projectManager.updatedAt")),1),n("div",sa,d(r.formatUpdatedAt((P=r.activeSession)==null?void 0:P.updatedAt)),1)]),n("div",aa,[n("div",ia,[I(i(Wt),{class:"h-3.5 w-3.5"}),n("span",null,d(i(q)("projectManager.note")),1)]),n("p",la,d(i(q)("projectManager.noteDescription")),1)])])}}},ra={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},da={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ua={class:"theme-divider theme-muted-panel border-b px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},ca={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},fa={class:"flex flex-wrap items-start justify-between gap-3"},pa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ga={class:"mt-5"},va={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},ma={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4 sm:flex-row sm:items-center sm:justify-between"},ha={class:"flex flex-wrap items-center gap-2"},ya=["disabled"],xa=["disabled"],ba=["disabled"],wa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Sa=["disabled"],ka=["disabled"],Ca=["disabled"],_a={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},$a={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ma={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},ja={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ia={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Ea=["disabled"],Pa={class:"min-w-0 flex-1"},Aa={class:"theme-heading truncate text-sm font-medium"},Da={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ra={class:"theme-divider border-b px-4 py-3"},Ta={class:"grid grid-cols-2 gap-2"},La=["disabled"],Ba={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Fa={key:0},Na={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Oa={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Ua=["disabled"],Ha=["disabled"],za=["disabled"],Ka=["disabled"],qa=3e3,Za={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session","open-source-browser"],setup(r,{expose:q,emit:j}){const A=new Map;function y(t="",a=""){const x=qe(t),k=et(a);return!x||!k?"":`${x}
2
2
  ${k}`}function B(t=""){if(!t)return null;const a=A.get(t);return a?a.expiresAt<=Date.now()?(A.delete(t),null):Array.isArray(a.items)?a.items:[]:null}function D(t="",a=[]){t&&A.set(t,{expiresAt:Date.now()+qa,items:Array.isArray(a)?a:[]})}const p=r,S=j,{locale:E,t:o}=Ve(),b=$("edit"),P=$(""),u=Ut({title:"",engine:"codex",agentEngines:[],cwd:"",sessionId:""}),_=$(""),de=$(!1),V=$(!1),U=$(!1),F=$(!1),H=$(!1),z=$(!1),G=$(!1),X=$(!1),{matches:R}=Pt("(max-width: 767px)"),Q=$("list"),Z=$("basic"),ge=$(ct()),ae=$([]),J=$(!1);let h=null,m=null,v=null,K=0;const ee=C(()=>Qe(p.sessions)),w=C(()=>p.sessions.find(t=>t.id===P.value)||null),ke=C(()=>p.sessions.length>0),Je=C(()=>p.sessions.find(t=>t.id===p.selectedSessionId)||null),ue=C(()=>!!(w.value&&te(w.value.id))),Ce=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),_e=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),ce=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),T=C(()=>p.loading||de.value||V.value||U.value||F.value),Re=C(()=>String(u.sessionId||"").trim()),$e=C(()=>{var x,k;const t=new Set,a=[];return[u.cwd,(x=w.value)==null?void 0:x.cwd,(k=Je.value)==null?void 0:k.cwd,...p.workspaces,...p.sessions.map(N=>N.cwd)].forEach(N=>{const L=String(N||"").trim();!L||t.has(L)||(t.add(L),a.push(L))}),a.slice(0,12)}),fe=C(()=>ge.value),ye=C(()=>ae.value.map(t=>({...t,updatedAtLabel:t.updatedAt?Ee(t.updatedAt):""}))),xe=C(()=>{const t=et(u.cwd);return t?p.sessions.filter(a=>{var x;return a.id===((x=w.value)==null?void 0:x.id)?!1:et(a.cwd)===t}):[]}),Y=C(()=>{if(!xe.value.length)return"";const t=xe.value.slice(0,3).map(a=>{const x=a.title||o("projectManager.untitledProject");return E.value==="en-US"?`"${x}"`:`「${x}」`}).join(E.value==="en-US"?", ":"、");return o("projectManager.duplicateDirectory",{labels:t,count:xe.value.length})}),pe=C(()=>b.value!=="edit"||Ce.value?"":o("projectManager.cwdReadonly")),Te=C(()=>b.value!=="edit"||!w.value||_e.value?"":o("projectManager.engineReadonly")),be=C(()=>b.value!=="edit"||!w.value||ce.value?"":o("projectManager.sessionIdReadonly")),We=C(()=>b.value==="create"?de.value?o("projectManager.creatingProject"):o("projectManager.createProject"):V.value?o("projectManager.savingChanges"):o("projectManager.saveChanges")),Ye=C(()=>{var t;return b.value==="create"?o("projectManager.newProject"):((t=w.value)==null?void 0:t.title)||o("projectManager.untitledProject")});function Me(t=""){const a=Date.parse(String(t||""));return Number.isFinite(a)?a:0}function te(t){var a;return!!((a=p.sessions.find(x=>x.id===t))!=null&&a.running)}function ve(t){return!!t&&t===p.selectedSessionId}function Qe(t=[]){return[...t].sort((a,x)=>{const k=Number(te(x.id))-Number(te(a.id));if(k)return k;const N=Number(ve(x.id))-Number(ve(a.id));if(N)return N;const L=Me(x.updatedAt)-Me(a.updatedAt);return L||Tt(String(a.title||a.cwd||a.id),String(x.title||x.cwd||x.id))})}function Le(t){return te(t)?o("projectManager.running"):o("projectManager.idle")}function je(t){return te(t)?"theme-status-warning":"theme-status-success"}function Be(t){return t!=null&&t.started?o("projectManager.threadBound"):o("projectManager.notStarted")}function Ie(t){return t!=null&&t.started?"theme-status-success":"theme-status-neutral"}function Ee(t=""){if(!t)return o("projectManager.unknown");const a=new Date(t);return Number.isNaN(a.getTime())?t:Rt(a.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Fe(t){u.title=String((t==null?void 0:t.title)||""),u.engine=qe(t==null?void 0:t.engine),u.agentEngines=(Array.isArray(t==null?void 0:t.agentBindings)?t.agentBindings:[]).map(a=>qe(a==null?void 0:a.engine)).filter(a=>a&&a!==u.engine),u.cwd=String((t==null?void 0:t.cwd)||""),u.sessionId=String((t==null?void 0:t.sessionId)||(t==null?void 0:t.engineSessionId)||(t==null?void 0:t.engineThreadId)||(t==null?void 0:t.codexThreadId)||"").trim()}function Pe(){b.value="create",P.value="",_.value="",u.title="",u.engine="codex",u.agentEngines=[],u.cwd="",u.sessionId=""}function ne(t){const a=p.sessions.find(x=>x.id===t);a&&(b.value="edit",P.value=a.id,_.value="",Fe(a))}function Ae(){var t;return p.selectedSessionId&&p.sessions.some(a=>a.id===p.selectedSessionId)?p.selectedSessionId:((t=ee.value[0])==null?void 0:t.id)||""}function Ne(t="basic"){Q.value="detail",Z.value=t}function Oe(){Q.value="list",Z.value="basic"}function Ue(){Pe(),R.value&&Ne("basic")}function He(t){T.value||(ne(t),R.value&&Ne("basic"))}function e(t){u.cwd=String(t||"").trim()}async function l(){var a,x;const t=((a=w.value)==null?void 0:a.id)||Ae();return!t||((!w.value||w.value.id!==t)&&(ne(t),await me()),!((x=w.value)!=null&&x.cwd))?!1:(R.value&&Ne("basic"),S("open-source-browser",w.value),S("close"),!0)}function s(){return H.value?(H.value=!1,!0):z.value?(z.value=!1,!0):G.value?(G.value=!1,!0):p.open?(S("close"),!0):!1}function f(t){u.title=String(t||"")}function W(t){u.engine=qe(t),u.agentEngines=u.agentEngines.filter(a=>a!==u.engine)}function se(t){u.agentEngines=[...new Set((Array.isArray(t)?t:[]).map(a=>qe(a)).filter(a=>a&&a!==u.engine))]}function we(t){u.cwd=String(t||"")}function ie(t){u.sessionId=String(t||"")}function le(t){u.sessionId=String((t==null?void 0:t.id)||"").trim()}function ze(){_.value="",H.value=!1,z.value=!1,X.value=!1,Z.value="basic",Q.value=R.value?"list":"detail";const t=Ae();if(t){ne(t);return}Pe()}async function xt(){if(!(T.value||typeof p.onRefresh!="function")){_.value="";try{await Promise.all([p.onRefresh(),it()])}catch(t){_.value=t.message}}}async function it(){try{ge.value=await At()}catch{ge.value=ct()}}function Ze(){m&&(clearTimeout(m),m=null)}function Ke(){v&&(v.abort(),v=null)}async function bt(){const t=String(u.cwd||"").trim();if(!p.open||!ce.value||!t){ae.value=[],J.value=!1,Ke();return}const a=++K;Ke();const x=y(u.engine,t),k=B(x);if(k){ae.value=k,J.value=!1;return}v=new AbortController,J.value=!0;try{const N=await Dt({engine:u.engine,cwd:t,limit:50,signal:v.signal});if(a!==K)return;const L=Array.isArray(N==null?void 0:N.items)?N.items:[];ae.value=L,D(x,L)}catch(N){if((N==null?void 0:N.name)==="AbortError")return;a===K&&(ae.value=[])}finally{a===K&&(J.value=!1,v=null)}}function lt(t=250){if(Ze(),!p.open||!ce.value||!String(u.cwd||"").trim()){ae.value=[],J.value=!1,Ke();return}m=setTimeout(()=>{m=null,bt().catch(()=>{})},t)}async function wt(t){var x;if((x=navigator.clipboard)!=null&&x.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const a=document.createElement("textarea");a.value=t,a.setAttribute("readonly","true"),a.style.position="fixed",a.style.opacity="0",a.style.pointerEvents="none",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}async function ot(){const t=Re.value;if(t)try{await wt(t),X.value=!0,h&&clearTimeout(h),h=setTimeout(()=>{X.value=!1,h=null},1800)}catch(a){_.value=(a==null?void 0:a.message)||o("projectManager.copySessionIdFailed")}}async function rt(){if(!T.value){_.value="";try{const t=St();if(!t)return;await kt(t)}catch(t){_.value=t.message}}}function St(){if(b.value==="create"){const a=String(u.cwd||"").trim();return a?{type:"create",cwd:a,payload:{title:u.title,engine:u.engine,agentEngines:[u.engine,...u.agentEngines],cwd:a,sessionId:String(u.sessionId||"").trim()}}:(_.value=o("projectManager.directoryRequired"),null)}if(!w.value)return _.value=o("projectManager.projectMissing"),null;const t={title:u.title,engine:u.engine,agentEngines:[u.engine,...u.agentEngines]};return Ce.value&&(t.cwd=u.cwd),ce.value&&(t.sessionId=String(u.sessionId||"").trim()),{type:"update",sessionId:w.value.id,payload:t}}async function kt(t){var a,x;if(t.type==="create"){de.value=!0;try{const k=await((a=p.onCreate)==null?void 0:a.call(p,t.payload));k!=null&&k.id&&(ne(k.id),S("select-session",k.id),await me(),S("project-created",k),S("close"));return}finally{de.value=!1}}V.value=!0;try{const k=await((x=p.onUpdate)==null?void 0:x.call(p,t.sessionId,t.payload));k!=null&&k.id&&ne(k.id)}finally{V.value=!1}}async function Ct(){var a,x;if(!w.value||U.value)return;const t=w.value.id;_.value="",U.value=!0;try{const k=await((a=p.onDelete)==null?void 0:a.call(p,t));H.value=!1;const N=p.sessions.filter($t=>$t.id!==t),L=(k==null?void 0:k.selectedSessionId)||((x=Qe(N)[0])==null?void 0:x.id)||"";S("select-session",L),L?(ne(L),R.value&&Oe()):(Pe(),R.value&&Oe())}catch(k){_.value=k.message}finally{U.value=!1}}async function _t(){var a;if(!w.value||F.value)return;const t=w.value.id;_.value="",F.value=!0;try{const x=await((a=p.onReset)==null?void 0:a.call(p,t));z.value=!1;const k=(x==null?void 0:x.session)||p.sessions.find(N=>N.id===t)||null;k!=null&&k.id&&ne(k.id)}catch(x){_.value=x.message}finally{F.value=!1}}return oe(()=>p.open,t=>{if(t){ze(),typeof p.onRefresh=="function"?xt().catch(()=>{}):it().catch(()=>{});return}G.value=!1,H.value=!1,z.value=!1,X.value=!1,_.value="",Ze(),Ke(),ae.value=[],J.value=!1},{immediate:!0}),oe(R,t=>{t||(Q.value="detail")},{immediate:!0}),oe(()=>p.sessions,()=>{if(!p.open)return;if(b.value==="create"){if(!!(String(u.title||"").trim()||String(u.cwd||"").trim())||!!String(u.sessionId||"").trim())return;const x=Ae();x&&ne(x);return}if(w.value){Fe(w.value);return}const t=Ae();if(t){ne(t);return}Pe()}),oe(()=>[p.open,b.value,u.engine,u.cwd,ce.value].join(`
3
3
  `),()=>{lt(250)},{immediate:!0}),oe(()=>{var t;return((t=w.value)==null?void 0:t.id)||""},()=>{lt(0)}),at(()=>{h&&(clearTimeout(h),h=null),Ze(),Ke()}),q({closeTopDialog:s}),(t,a)=>(c(),g(he,null,[I(ft,{open:z.value,title:i(o)("projectManager.confirmResetTitle"),description:w.value?i(o)("projectManager.confirmResetDescription",{title:w.value.title||i(o)("projectManager.untitledProject")}):"","confirm-text":i(o)("projectManager.confirmReset"),"cancel-text":i(o)("projectManager.keep"),loading:F.value,onCancel:a[0]||(a[0]=x=>z.value=!1),onConfirm:_t},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(ft,{open:H.value,title:i(o)("projectManager.confirmDeleteTitle"),description:w.value?i(o)("projectManager.confirmDeleteDescription",{title:w.value.title||i(o)("projectManager.untitledProject")}):"","confirm-text":i(o)("projectManager.confirmDelete"),"cancel-text":i(o)("projectManager.keep"),loading:U.value,danger:"",onCancel:a[1]||(a[1]=x=>H.value=!1),onConfirm:Ct},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(Rn,{open:G.value,"initial-path":u.cwd,suggestions:$e.value,onClose:a[2]||(a[2]=x=>G.value=!1),onSelect:e},null,8,["open","initial-path","suggestions"]),I(ht,{open:r.open,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":T.value,"close-on-backdrop":!T.value,"close-on-escape":!T.value,onClose:a[12]||(a[12]=x=>S("close"))},{title:De(()=>[n("div",ra,[I(i(Zt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.managingTitle")),1)])]),default:De(()=>{var x,k,N;return[i(R)?(c(),g("div",_a,[Q.value==="list"?(c(),g("div",$a,[n("div",Ma,[I(mt,{mobile:"",busy:T.value,"editing-session-id":P.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"has-sessions":ke.value,"is-current-session":ve,"is-session-running":te,mode:b.value,sessions:ee.value,onCreate:Ue,onSelect:He},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(c(),g("div",ja,[n("div",Ia,[n("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:T.value,onClick:Oe},[I(i(Yt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.projectList")),1)],8,Ea),n("div",Pa,[n("div",Aa,d(Ye.value),1),b.value==="edit"&&((k=w.value)!=null&&k.cwd)?(c(),g("p",Da,d(w.value.cwd),1)):M("",!0)])]),n("div",Ra,[n("div",Ta,[n("button",{type:"button",class:O(["tool-button px-3 py-2 text-sm",Z.value==="basic"?"tool-button-accent-subtle":""]),onClick:a[7]||(a[7]=L=>Z.value="basic")},d(i(o)("projectManager.basicInfo")),3),n("button",{type:"button",class:O(["tool-button px-3 py-2 text-sm",Z.value==="status"?"tool-button-accent-subtle":""]),disabled:b.value==="create",onClick:a[8]||(a[8]=L=>Z.value="status")},d(i(o)("projectManager.status")),11,La)])]),n("div",Ba,[Z.value==="basic"?(c(),g("div",Fa,[I(vt,{mobile:"",busy:T.value,"can-edit-engine":b.value!=="edit"||_e.value,"can-edit-cwd":b.value!=="edit"||Ce.value,"can-edit-session-id":b.value!=="edit"||ce.value,cwd:u.cwd,"cwd-readonly-message":pe.value,"duplicate-cwd-message":Y.value,engine:u.engine,"agent-engines":u.agentEngines,"engine-options":fe.value,"engine-readonly-message":Te.value,"session-candidates":ye.value,"session-candidates-loading":J.value,"session-id":u.sessionId,"session-id-copied":X.value,"session-id-readonly-message":be.value,title:u.title,"workspace-suggestions":$e.value,onCopySessionId:ot,onOpenDirectoryPicker:a[9]||(a[9]=L=>G.value=!0),onSelectSessionCandidate:le,"onUpdate:cwd":we,"onUpdate:engine":W,"onUpdate:agentEngines":se,"onUpdate:sessionId":ie,"onUpdate:title":f},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),_.value?(c(),g("p",Na,[I(i(gt),{class:"h-4 w-4"}),n("span",null,d(_.value),1)])):M("",!0),n("div",Oa,[n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:T.value,onClick:rt},d(We.value),9,Ua),b.value==="edit"&&w.value?(c(),g("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||!((N=w.value)!=null&&N.cwd),onClick:l},d(i(o)("projectManager.viewSource")),9,Ha)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:1,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||ue.value,onClick:a[10]||(a[10]=L=>z.value=!0)},d(F.value?i(o)("projectManager.resettingSession"):i(o)("projectManager.newSession")),9,za)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:T.value||ue.value,onClick:a[11]||(a[11]=L=>H.value=!0)},d(U.value?i(o)("projectManager.deletingProject"):i(o)("projectManager.deleteProject")),9,Ka)):M("",!0)])])):(c(),re(oa,{key:1,"active-session":w.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"is-current-session":ve,"is-session-running":te},null,8,["active-session"]))])]))])):(c(),g("div",da,[n("aside",ua,[I(mt,{busy:T.value,"editing-session-id":P.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"has-sessions":ke.value,"is-current-session":ve,"is-session-running":te,mode:b.value,sessions:ee.value,onCreate:Ue,onSelect:He},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),n("div",ca,[n("div",fa,[n("div",null,[n("div",pa,[I(i(Qt),{class:"h-4 w-4"}),n("span",null,d(b.value==="create"?i(o)("projectManager.createTitle"):i(o)("projectManager.editTitle")),1)])])]),n("div",ga,[I(vt,{busy:T.value,"can-edit-engine":b.value!=="edit"||_e.value,"can-edit-cwd":b.value!=="edit"||Ce.value,"can-edit-session-id":b.value!=="edit"||ce.value,cwd:u.cwd,"cwd-readonly-message":pe.value,"duplicate-cwd-message":Y.value,engine:u.engine,"agent-engines":u.agentEngines,"engine-options":fe.value,"engine-readonly-message":Te.value,"session-candidates":ye.value,"session-candidates-loading":J.value,"session-id":u.sessionId,"session-id-copied":X.value,"session-id-readonly-message":be.value,title:u.title,"workspace-suggestions":$e.value,onCopySessionId:ot,onOpenDirectoryPicker:a[3]||(a[3]=L=>G.value=!0),onSelectSessionCandidate:le,"onUpdate:cwd":we,"onUpdate:engine":W,"onUpdate:agentEngines":se,"onUpdate:sessionId":ie,"onUpdate:title":f},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),_.value?(c(),g("p",va,[I(i(gt),{class:"h-4 w-4"}),n("span",null,d(_.value),1)])):M("",!0),n("div",ma,[n("div",ha,[b.value==="edit"&&w.value?(c(),g("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||!((x=w.value)!=null&&x.cwd),onClick:l},[I(i(Gt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.viewSource")),1)],8,ya)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:1,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||ue.value,onClick:a[4]||(a[4]=L=>z.value=!0)},[I(i(Xt),{class:"h-4 w-4"}),n("span",null,d(F.value?i(o)("projectManager.resettingSession"):i(o)("projectManager.newSession")),1)],8,xa)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||ue.value,onClick:a[5]||(a[5]=L=>H.value=!0)},[I(i(Jt),{class:"h-4 w-4"}),n("span",null,d(U.value?i(o)("projectManager.deletingProject"):i(o)("projectManager.deleteProject")),1)],8,ba)):M("",!0)]),n("div",wa,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:a[6]||(a[6]=L=>S("close"))},d(i(o)("projectManager.close")),9,Sa),b.value==="create"&&ke.value?(c(),g("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:ze},d(i(o)("projectManager.backToList")),9,ka)):M("",!0),n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:rt},d(We.value),9,Ca)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{Za as default};
@@ -1,4 +1,4 @@
1
- import{g as lt,t as A,f as Ze,u as Te,a as rt,b as ot}from"./index-DpCCivzJ.js";import{u as ut,g as Ae,l as ct,a as dt,_ as ft,r as ht,e as mt,D as Me,b as vt,i as gt,c as pt,d as xt,f as kt}from"./WorkbenchView-EAjf4pvb.js";import{w as K,c as E,b as B,n as et,aD as b,aE as R,aF as n,aR as he,aS as Le,aL as O,aQ as h,aG as j,u as s,aW as Be,aX as yt,aN as Y,ak as bt,aI as Pe,aJ as xe,f as wt,a$ as We}from"./vendor-misc-u-M8sNMf.js";import{c as St,k as Ge,C as Ee,R as Ke,b as Rt,i as Ft,h as tt,F as Je,z as Qe}from"./vendor-ui-BwEQCho1.js";import"./vendor-router-Dn8q3tJM.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";function re(e,l,r=""){const p=l==="run"?"run":l==="task"?"task":"workspace";return[String(e||"").trim(),p,String(r||"").trim()].join("::")}function je(e="",l=""){return`${String(e||"").trim()}::${String(l||"").trim()}`}function Ct(e=""){return`${String(e||"").trim()}::`}function st(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ge(e,l){const r=e.get(l);return r?(e.delete(l),e.set(l,r),st(r)):null}function pe(e,l,r,p=0){for(e.delete(l),e.set(l,st(r));p>0&&e.size>p;){const x=e.keys().next().value;if(typeof x>"u")break;e.delete(x)}}function fe(e=""){const l=String(e||"").trim().toUpperCase();return l==="A"||l==="D"?l:"M"}function Lt(e=""){const l=String(e||"");if(!l)return[];const r=l.split(`
1
+ import{g as lt,t as A,f as Ze,u as Te,a as rt,b as ot}from"./index-DCBAbk14.js";import{u as ut,g as Ae,l as ct,a as dt,_ as ft,r as ht,e as mt,D as Me,b as vt,i as gt,c as pt,d as xt,f as kt}from"./WorkbenchView-3rJGJ6O2.js";import{w as K,c as E,b as B,n as et,aD as b,aE as R,aF as n,aR as he,aS as Le,aL as O,aQ as h,aG as j,u as s,aW as Be,aX as yt,aN as Y,ak as bt,aI as Pe,aJ as xe,f as wt,a$ as We}from"./vendor-misc-u-M8sNMf.js";import{c as St,k as Ge,C as Ee,R as Ke,b as Rt,i as Ft,h as tt,F as Je,z as Qe}from"./vendor-ui-BwEQCho1.js";import"./vendor-router-Dn8q3tJM.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";function re(e,l,r=""){const p=l==="run"?"run":l==="task"?"task":"workspace";return[String(e||"").trim(),p,String(r||"").trim()].join("::")}function je(e="",l=""){return`${String(e||"").trim()}::${String(l||"").trim()}`}function Ct(e=""){return`${String(e||"").trim()}::`}function st(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ge(e,l){const r=e.get(l);return r?(e.delete(l),e.set(l,r),st(r)):null}function pe(e,l,r,p=0){for(e.delete(l),e.set(l,st(r));p>0&&e.size>p;){const x=e.keys().next().value;if(typeof x>"u")break;e.delete(x)}}function fe(e=""){const l=String(e||"").trim().toUpperCase();return l==="A"||l==="D"?l:"M"}function Lt(e=""){const l=String(e||"");if(!l)return[];const r=l.split(`
2
2
  `),p=[];let x=0,H=0;return r.forEach((f,u)=>{const T=f.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(T){x=Number(T[1]),H=Number(T[2]),p.push({id:`hunk-${u}`,kind:"hunk",oldNumber:"",newNumber:"",content:f});return}if(f.startsWith("+")&&!f.startsWith("+++")){p.push({id:`line-${u}`,kind:"add",oldNumber:"",newNumber:H,content:f}),H+=1;return}if(f.startsWith("-")&&!f.startsWith("---")){p.push({id:`line-${u}`,kind:"delete",oldNumber:x,newNumber:"",content:f}),x+=1;return}if(f.startsWith(" ")){p.push({id:`line-${u}`,kind:"context",oldNumber:x,newNumber:H,content:f}),x+=1,H+=1;return}p.push({id:`line-${u}`,kind:"meta",oldNumber:"",newNumber:"",content:f})}),p}function Pt(e=""){const l=String(e||"").trim();if(!l)return"";const r=l.match(/^当前分支已从 (.+) 切换到 (.+)$/);return r?A("diffReview.warningBranchChanged",{from:r[1],to:r[2]}):l==="当前 HEAD 已不在基线 commit 的后续历史中,仓库可能经历了 reset、rebase 或切分支"?A("diffReview.warningHeadDetachedFromBaseline"):l}function $e(e=""){const l=String(e||"").trim();if(!l)return"";const p=new Map([["二进制文件暂不支持在线 diff 预览。","diffReview.binaryPreviewUnavailable"],["文件内容较大,暂不展示具体 diff。","diffReview.fileTooLarge"],["diff 内容较长,暂不在页面内完整展示。","diffReview.diffTooLong"],["diff 内容较长,当前仅展示摘要预览。","diffReview.diffPreviewOnly"],["当前工作目录不是 Git 仓库,暂不支持代码变更审查。","diffReview.notGitRepo"],["任务不存在。","diffReview.taskNotFound"],["请选择一轮执行后再查看本轮代码变更。","diffReview.runRequired"],["没有找到对应的执行记录。","diffReview.runNotFound"],["这轮执行还没有建立代码变更基线,暂时无法查看本轮 diff。","diffReview.runBaselineMissing"],["当前任务还没有建立代码变更基线,请先让 Codex 执行一轮。","diffReview.taskBaselineMissing"],["这轮执行缺少结束快照,暂时无法准确还原本轮代码变更。","diffReview.runSnapshotMissing"],["原工作目录已不是有效的 Git 仓库,暂时无法读取代码变更。","diffReview.originalRepoInvalid"],["基线对应的 commit 已不存在,仓库可能被 reset、rebase 或切换到无关历史,暂时无法准确读取该范围的代码变更。","diffReview.baselineCommitMissing"]]).get(l);return p?A(p):/^git diff 计算超时(>\d+ms)[。.]?$/.test(l)||l==="该文件 diff 计算超时,暂不在线展示详细内容。"?A("diffReview.fileDiffTimedOut"):l}function Ne(e=null){return!e||typeof e!="object"?e:{...e,reason:$e(e.reason),warnings:Array.isArray(e.warnings)?e.warnings.map(l=>Pt(l)).filter(Boolean):[],files:Array.isArray(e.files)?e.files.map(l=>({...l,message:$e(l==null?void 0:l.message)})):[]}}function $t(e=[],l="",r=0){const p=Math.max(0,Number(r)||0);if(!p)return[];const x=String(l||"").trim(),H=Array.isArray(e)?e:[],f=[],u=new Set;return x&&H.find($=>String(($==null?void 0:$.path)||"").trim()===x)&&(f.push(x),u.add(x)),H.forEach(T=>{const $=String((T==null?void 0:T.path)||"").trim();!$||u.has($)||f.length>=p||(f.push($),u.add($))}),f}function Tt(e){const l=B("workspace"),r=B(""),p=B(""),x=B("all"),H=B(""),f=B([]),u=B(null),T=B(!1),$=B(!1),te=B(""),se=B(!1),J=B(null),U=B(0),W=new Map,ae=ut();let w=0,S=0,g="",F="",G="",X=-1;const ne=new Map,q=new Map,N=new Map,ie=new Map,le=12e3,oe=3,a=E(()=>f.value.filter(t=>t.completed)),o=E(()=>{var i;const t={all:0,A:0,M:0,D:0};return(((i=u.value)==null?void 0:i.files)||[]).forEach(d=>{const v=fe(d==null?void 0:d.status);t.all+=1,t[v]+=1}),t}),m=E(()=>{var d;const t=((d=u.value)==null?void 0:d.files)||[],i=String(H.value||"").trim().toLowerCase();return t.filter(v=>x.value!=="all"&&fe(v==null?void 0:v.status)!==x.value?!1:i?String((v==null?void 0:v.path)||"").toLowerCase().includes(i):!0)}),_=E(()=>{const t=m.value;return t.find(i=>i.path===p.value)||t[0]||null}),C=E(()=>{var t;return Lt(((t=_.value)==null?void 0:t.patch)||"")}),V=E(()=>C.value.map((t,i)=>({...t,index:i})).filter(t=>t.kind==="hunk")),c=E(()=>$t(m.value,p.value,oe)),D=E(()=>{var t,i;return $.value&&!((i=(t=u.value)==null?void 0:t.summary)!=null&&i.statsComplete)}),L=E(()=>{var d;const t=((d=u.value)==null?void 0:d.baseline)||null;if(!(t!=null&&t.createdAt)&&!(t!=null&&t.headShort))return"";const i=[];return t.createdAt&&i.push(A("diffReview.baselineTime",{value:Ze(t.createdAt)})),t.branch&&i.push(A("diffReview.baselineBranch",{value:t.branch})),t.headShort&&i.push(A("diffReview.baselineCommit",{value:t.headShort})),t.currentHeadShort&&i.push(A("diffReview.currentHead",{value:t.currentHeadShort})),i.join(" · ")});function ue(t){return(t==null?void 0:t.status)==="completed"?A("diffReview.completed"):(t==null?void 0:t.status)==="error"?A("diffReview.failed"):(t==null?void 0:t.status)==="interrupted"?A("diffReview.interrupted"):A("diffReview.stopped")}function ce(t,i){if(t){if(i){W.set(t,i);return}W.delete(t)}}function Z(t,i={}){const d=V.value;if(!d.length)return;const v=Math.min(Math.max(0,Number(t)||0),d.length-1),M=d[v],I=W.get(M.id);I&&(U.value=v,I.scrollIntoView({block:i.block||"center",behavior:i.behavior||"smooth"}))}function k(t=1){V.value.length&&Z(U.value+t)}function ke(t){return`${new Date((t==null?void 0:t.startedAt)||(t==null?void 0:t.createdAt)).toLocaleString(lt())} · ${ue(t)}`}function ye(){const t=a.value;if(!t.length){r.value="";return}t.some(i=>i.id===r.value)||(r.value=t[0].id)}function de(){const t=m.value;if(!t.length){p.value="";return}t.some(i=>i.path===p.value)||(p.value=t[0].path)}function be(t=""){return fe(t)==="A"?A("diffReview.added"):fe(t)==="D"?A("diffReview.deleted"):A("diffReview.modified")}function we(t=""){return fe(t)==="A"?"theme-status-success":fe(t)==="D"?"theme-status-danger":"theme-status-warning"}function y(t="all"){return t==="A"?A("diffReview.added"):t==="D"?A("diffReview.deleted"):t==="M"?A("diffReview.modified"):A("diffReview.all")}function Se(t="all"){return x.value===t?"theme-filter-active":"theme-filter-idle"}function _e(t="context"){return t==="add"?"theme-patch-add":t==="delete"?"theme-patch-delete":t==="hunk"?"theme-patch-hunk":t==="meta"?"theme-patch-meta":"theme-patch-context"}function De(t,i=""){const d=String(i||"").trim();d&&Array.from(t.keys()).forEach(v=>{String(v||"").startsWith(d)&&t.delete(v)})}function at(){const t=Ct(e.taskSlug);De(ne,t),De(q,t),De(N,t)}function Ve(){const t=l.value==="run"?"run":l.value==="task"?"task":"workspace",i=t==="run"?r.value:"",d=re(e.taskSlug,t,i);return{scope:t,runId:i,signature:d}}function Oe(t=""){var d;const i=String(t||"").trim();return i&&(((d=u.value)==null?void 0:d.files)||[]).find(v=>v.path===i)||null}function Ue(t=null){return!!t&&!t.patchLoaded&&!t.binary&&!t.tooLarge&&!t.message}function me(t="",i="",d=null,v=null){var I;const M=re(e.taskSlug,l.value,l.value==="run"?r.value:"");return t!==M||!d||!((I=u.value)!=null&&I.files)?!1:(u.value={...u.value,baseline:(v==null?void 0:v.baseline)||u.value.baseline||null,warnings:(v==null?void 0:v.warnings)||u.value.warnings||[],files:u.value.files.map(P=>P.path===i?d:P)},!0)}async function qe(t="",i={}){const d=String(t||"").trim(),v=String(i.signature||"").trim();if(!d||!v)return null;const M=je(v,d),I=ge(N,M);if(I)return{detailedFile:I,normalizedPayload:null};const P=ie.get(M);if(P)return P;const Q=(async()=>{try{const z=await Ae(e.taskSlug,{scope:i.scope,runId:i.runId,filePath:d,timeoutMs:le}),ee=Ne(z),ve=(ee.files||[]).find(Ce=>Ce.path===d);if(!ve)throw new Error(A("diffReview.noFileDiffContent"));return pe(N,M,ve,120),{detailedFile:ve,normalizedPayload:ee}}catch(z){return{error:z}}finally{ie.delete(M)}})();return ie.set(M,Q),Q}async function Ie(){var i,d;if(!e.taskSlug||!e.active||!((i=u.value)!=null&&i.supported))return;const t=Ve();for(const v of c.value){const M=Oe(v);if(!Ue(M))continue;const I=re(e.taskSlug,l.value,l.value==="run"?r.value:"");if(t.signature!==I)return;const P=await qe(v,t);if(P){if(P.error){const Q=$e(((d=P.error)==null?void 0:d.message)||"")||A("diffReview.fileDiffTimedOut"),z={...M,patch:"",patchLoaded:!0,tooLarge:!0,message:Q};pe(N,je(t.signature,v),z,120),me(t.signature,v,z,null);continue}me(t.signature,v,P.detailedFile,P.normalizedPayload)}}}async function nt(){if(!e.taskSlug){f.value=[],r.value="",G="",X=-1;return}const t=ae.getTaskRunSyncVersion(e.taskSlug);if(G===e.taskSlug&&X===t)return;const i=await ct(e.taskSlug,{limit:20,events:"none"});f.value=i.items||[],G=e.taskSlug,X=t,ye()}async function He(){if(!e.taskSlug||!e.active)return;const t=++w;T.value=!0,$.value=!1,te.value="";try{const i=l.value==="run"?"run":l.value==="task"?"task":"workspace";i==="run"&&await nt();const d=re(e.taskSlug,i,i==="run"?r.value:"");if(i==="run"&&!r.value){u.value={supported:!1,reason:A("diffReview.noReviewRuns"),repoRoot:"",summary:{fileCount:0,additions:0,deletions:0,statsComplete:!0},files:[]},de();return}const v=ge(ne,d);if(v){u.value=v,g=d;const P=ge(q,d);P?(u.value={...v,baseline:P.baseline||v.baseline||null,warnings:P.warnings||v.warnings||[],summary:P.summary||v.summary},F=d):F="",de(),Re().catch(()=>{}),Ie().catch(()=>{}),P||ze().catch(()=>{});return}const M=await Ae(e.taskSlug,{scope:i,runId:i==="run"?r.value:"",includeStats:!1});if(t!==w)return;const I=Ne(M);u.value=I,pe(ne,d,I,36),g=d,F="",de(),Re().catch(()=>{}),Ie().catch(()=>{}),ze().catch(()=>{})}catch(i){if(t!==w)return;te.value=i.message,u.value=null}finally{t===w&&(T.value=!1)}}async function ze(){var M,I,P;if(!e.taskSlug||!e.active||!((M=u.value)!=null&&M.supported))return;const t=l.value==="run"?"run":l.value==="task"?"task":"workspace",i=t==="run"?r.value:"",d=re(e.taskSlug,t,i);if(F===d&&((P=(I=u.value)==null?void 0:I.summary)!=null&&P.statsComplete))return;const v=ge(q,d);if(v){u.value={...u.value,baseline:v.baseline||u.value.baseline||null,warnings:v.warnings||u.value.warnings||[],summary:v.summary||u.value.summary},F=d,$.value=!1;return}$.value=!0;try{const Q=await Ae(e.taskSlug,{scope:t,runId:i,includeFiles:!1,includeStats:!0}),z=re(e.taskSlug,l.value,l.value==="run"?r.value:"");if(d!==z||!u.value)return;const ee=Ne(Q);u.value={...u.value,baseline:ee.baseline||u.value.baseline||null,warnings:ee.warnings||u.value.warnings||[],summary:ee.summary||u.value.summary},pe(q,d,{baseline:ee.baseline||null,warnings:ee.warnings||[],summary:ee.summary||null},36),F=d}catch{}finally{const Q=re(e.taskSlug,l.value,l.value==="run"?r.value:"");d===Q&&($.value=!1)}}async function Re(){var P,Q;const t=String(p.value||"").trim();if(!e.taskSlug||!e.active||!t)return;const i=Ve(),d=Oe(t);if(!Ue(d))return;const v=je(i.signature,t),M=ge(N,v);if(M&&((P=u.value)!=null&&P.files)){me(i.signature,t,M,null);return}const I=++S;se.value=!0;try{const z=await qe(t,i);if(I!==S||!z)return;const ee=re(e.taskSlug,l.value,l.value==="run"?r.value:"");if(i.signature!==ee)return;if(z.error){const ve=$e(((Q=z.error)==null?void 0:Q.message)||"")||A("diffReview.fileDiffTimedOut"),Ce={...d,patch:"",patchLoaded:!0,tooLarge:!0,message:ve};pe(N,v,Ce,120),me(i.signature,t,Ce,null);return}me(i.signature,t,z.detailedFile,z.normalizedPayload)}finally{I===S&&(se.value=!1,String(p.value||"").trim()!==t&&Re().catch(()=>{}))}}function Fe({force:t=!1}={}){if(!e.taskSlug||!e.active)return;const i=re(e.taskSlug,l.value,l.value==="run"?r.value:"");!t&&i===g||He().catch(()=>{})}async function it(){!e.taskSlug||!e.active||T.value||(at(),g="",F="",G="",X=-1,await He())}return K(()=>[e.taskSlug,e.active,l.value,r.value],([t,i],d=[])=>{const v=d[0]||"";t!==v&&(p.value="",g="",f.value=[],r.value="",G="",X=-1,F=""),!(!t||!i)&&Fe()},{immediate:!0}),K(()=>{var t,i;return[x.value,((i=(t=u.value)==null?void 0:t.files)==null?void 0:i.length)||0]},()=>{de()}),K(()=>[p.value,V.value.length],()=>{U.value=0,W.clear(),et(()=>{var t,i;V.value.length?Z(0,{behavior:"auto",block:"start"}):(i=(t=J.value)==null?void 0:t.scrollTo)==null||i.call(t,{top:0,behavior:"auto"})})}),K(()=>p.value,()=>{Re().catch(()=>{})},{immediate:!0}),K(()=>{var t;return[e.active,(t=u.value)==null?void 0:t.supported,c.value.join(`
3
3
  `)]},([t,i])=>{!t||!i||Ie().catch(()=>{})}),K(()=>[e.preferredScope,e.preferredRunId,e.focusToken],([t,i,d],v=[])=>{const M=Number(v[2]||0),I=t==="run"?"run":t==="task"?"task":"workspace",P=I==="run"&&i?String(i||""):"",Q=l.value!==I,z=I==="run"&&P&&r.value!==P;l.value=I,P&&(r.value=P),I!=="run"&&(r.value=""),!Q&&!z&&e.active&&e.taskSlug&&d!==M&&(g="",Fe())},{immediate:!0}),K(()=>ae.readyVersion.value,()=>{!e.active||!e.taskSlug||(G="",X=-1,g="",F="",Fe({force:!0}))}),K(()=>ae.getTaskDiffSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||(G="",X=-1,F="",g="",Fe({force:!0}))}),{activeHunkIndex:U,baselineMetaText:L,diffPayload:u,diffScope:l,error:te,fileSearch:H,filteredFiles:m,getFilterButtonClass:Se,getFilterLabel:y,getPatchLineClass:_e,getRunStatusLabel:ue,getStatusClass:we,getStatusLabel:be,jumpToAdjacentHunk:k,loadDiff:He,loading:T,normalizeFileStatus:fe,patchLoading:se,patchViewportRef:J,runs:f,selectedFile:_,selectedFilePath:p,selectedPatchHunks:V,selectedPatchLines:C,selectedRunId:r,setPatchLineRef:ce,showSummarySkeleton:D,statsLoading:$,statusCounts:o,statusFilter:x,terminalRuns:a,formatRunOptionLabel:ke,refreshDiff:it}}const _t={class:"mb-3 grid grid-cols-2 gap-2"},Dt=["onClick"],It={class:"theme-input-shell mb-3 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs text-[var(--theme-textMuted)]"},Ht=["placeholder"],At={key:0,class:"theme-empty-state theme-empty-state-strong mb-3 px-3 py-2 text-[11px]"},Mt={key:1,class:"theme-empty-state px-3 py-4 text-xs"},jt={key:2,class:"theme-empty-state px-3 py-4 text-xs"},Nt={key:3,class:"space-y-1"},Bt=["onClick","onKeydown"],Vt={class:"min-w-0 flex-1"},Ot={class:"theme-list-item-title break-all"},Ut={class:"theme-list-item-meta mt-1"},Xe={__name:"TaskDiffFileList",props:{diffPayload:{type:Object,default:null},fileSearch:{type:String,default:""},autoFocusSelected:{type:Boolean,default:!1},filteredFiles:{type:Array,default:()=>[]},focusToken:{type:Number,default:0},getFilterButtonClass:{type:Function,default:()=>""},getFilterLabel:{type:Function,default:e=>e},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},selectedFilePath:{type:String,default:""},showSummarySkeleton:{type:Boolean,default:!1},statusCounts:{type:Object,default:()=>({})},statusFilter:{type:String,default:"all"}},emits:["select-file","update:fileSearch","update:statusFilter"],setup(e,{emit:l}){const r=e,p=l,{t:x}=Te(),H=new Map,f=B(0),u=B(0),T=E({get:()=>r.fileSearch,set:w=>p("update:fileSearch",w)}),$=E({get:()=>r.statusFilter,set:w=>p("update:statusFilter",w)}),te=E(()=>{var w;return Array.isArray((w=r.diffPayload)==null?void 0:w.files)&&r.diffPayload.files.length>0});function se(w,S){if(S){H.set(w,S);return}H.delete(w)}function J(w){et(()=>{var g,F;const S=H.get(w);(g=S==null?void 0:S.focus)==null||g.call(S),(F=S==null?void 0:S.scrollIntoView)==null||F.call(S,{block:"nearest",inline:"nearest"})})}function U(){!r.autoFocusSelected||!r.selectedFilePath||f.value===u.value||(u.value=f.value,J(r.selectedFilePath))}function W(w=1,S=""){const g=Array.isArray(r.filteredFiles)?r.filteredFiles:[];if(!g.length)return;const F=g.findIndex(N=>N.path===S),G=g.findIndex(N=>N.path===r.selectedFilePath),ne=(Math.max(0,F>=0?F:G)+w+g.length)%g.length,q=g[ne];q!=null&&q.path&&(p("select-file",q.path),J(q.path))}function ae(w,S){const g=String((w==null?void 0:w.key)||"");if(g==="ArrowDown"){w.preventDefault(),W(1,S);return}if(g==="ArrowUp"){w.preventDefault(),W(-1,S);return}(g==="Enter"||g===" ")&&S&&(w.preventDefault(),p("select-file",S))}return K(()=>r.focusToken,w=>{f.value=w,U()},{immediate:!0}),K(()=>r.selectedFilePath,()=>{U()}),(w,S)=>(b(),R(he,null,[n("div",_t,[(b(),R(he,null,Le(["all","A","M","D"],g=>n("button",{key:g,type:"button",class:O(["inline-flex w-full items-center justify-center gap-1 whitespace-nowrap rounded-sm border px-2 py-1 text-[11px] transition",e.getFilterButtonClass(g)]),onClick:F=>$.value=g},h(e.getFilterLabel(g))+" "+h(e.statusCounts[g]||0),11,Dt)),64))]),n("label",It,[j(s(St),{class:"h-3.5 w-3.5 shrink-0"}),Be(n("input",{"onUpdate:modelValue":S[0]||(S[0]=g=>T.value=g),type:"text",placeholder:s(x)("diffReview.searchFilePath"),class:"min-w-0 flex-1 bg-transparent text-xs text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,8,Ht),[[yt,T.value]])]),e.showSummarySkeleton?(b(),R("div",At,h(s(x)("diffReview.statsPending")),1)):Y("",!0),te.value?e.filteredFiles.length?(b(),R("div",Nt,[(b(!0),R(he,null,Le(e.filteredFiles,g=>(b(),R("button",{key:g.path,ref_for:!0,ref:F=>se(g.path,F),type:"button",class:O(["theme-list-row focus:outline-none",g.path===e.selectedFilePath?"theme-list-item-active":"theme-list-item-hover"]),onClick:F=>p("select-file",g.path),onKeydown:F=>ae(F,g.path)},[n("span",{class:O(["theme-list-item-badge",e.getStatusClass(g.status)])},h(e.getStatusLabel(g.status)),3),n("div",Vt,[n("div",Ot,h(g.path),1),n("div",Ut,h(g.statsLoaded?`+${g.additions} / -${g.deletions}`:s(x)("diffReview.statsOnDemand")),1)])],42,Bt))),128))])):(b(),R("div",jt,h(s(x)("diffReview.noMatches")),1)):(b(),R("div",Mt,h(s(x)("diffReview.noChanges")),1))],64))}},qt={key:0,class:"flex h-full min-h-0 flex-col overflow-hidden"},zt={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},Wt={class:"space-y-3 sm:hidden"},Gt={class:"flex items-start gap-2"},Et={class:"min-w-0 break-all font-medium text-[var(--theme-textPrimary)]"},Kt={class:"flex items-center justify-between gap-3"},Jt={class:"min-w-0"},Qt={class:"opacity-75"},Xt={class:"theme-muted-text mt-1 text-[11px]"},Yt=["disabled"],Zt={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},es=["disabled"],ts={class:"hidden items-center gap-3 sm:flex"},ss={class:"flex min-w-0 flex-1 flex-wrap items-center gap-2"},as={class:"break-all font-medium text-[var(--theme-textPrimary)]"},ns={class:"opacity-75"},is={class:"theme-muted-text text-[11px]"},ls=["disabled"],rs={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},os=["disabled"],us={key:0,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},cs={class:"theme-empty-state px-4 py-4"},ds={key:1,class:"theme-muted-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},fs={class:"task-diff-view min-w-max px-4 py-4 font-mono"},hs={key:0,class:"theme-inline-panel theme-secondary-text mb-3 rounded-sm border border-dashed px-3 py-2 text-[12px]"},ms=["data-line-id","data-line-kind"],vs={class:"task-diff-row__number select-none"},gs={class:"task-diff-row__number select-none"},ps=["innerHTML"],xs={key:3,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},ks={class:"theme-empty-state px-4 py-4"},ys={key:1,class:"theme-muted-text flex h-full items-center justify-center px-5 text-[12px]"},bs={__name:"TaskDiffPatchView",props:{activeHunkIndex:{type:Number,default:0},getPatchLineClass:{type:Function,default:()=>""},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},jumpToAdjacentHunk:{type:Function,default:()=>{}},patchLoading:{type:Boolean,default:!1},selectedFile:{type:Object,default:null},selectedPatchHunks:{type:Array,default:()=>[]},selectedPatchLines:{type:Array,default:()=>[]},setPatchLineRef:{type:Function,default:()=>{}},setPatchViewportRef:{type:Function,default:()=>{}}},emits:["insert-code-context"],setup(e,{emit:l}){const r=e,p=l,{t:x}=Te(),{isDark:H}=ot(),f=B([]),u=E(()=>{var a;return gt(((a=r.selectedFile)==null?void 0:a.path)||"")}),T=B(null),$=new Map;function te(a={}){return["add","delete","context"].includes(String((a==null?void 0:a.kind)||"").trim())}function se(a=""){const o=String(a||"").trim();return o&&f.value.find(m=>m.id===o)||null}const{selectedRows:J,selectionAction:U,clearSelectionState:W,handleSelectionMouseUp:ae,updateSelectionActionFromDom:w}=dt({getContainer:()=>T.value,isActive:()=>!!(r.selectedFile&&r.selectedPatchLines.length),rowSelector:".task-diff-row[data-line-id]",getOrderedRowElements:a=>[...a.querySelectorAll(".task-diff-row[data-line-id]")].filter(o=>te(se(o.getAttribute("data-line-id")))),mapRowElement:a=>{var o;return se(((o=a==null?void 0:a.getAttribute)==null?void 0:o.call(a,"data-line-id"))||"")},getCodeLeft:a=>{var V,c,D;const o=(V=a==null?void 0:a.querySelector)==null?void 0:V.call(a,".task-diff-line");if(!o)return 0;const m=(c=o.getBoundingClientRect)==null?void 0:c.call(o),_=(D=window.getComputedStyle)==null?void 0:D.call(window,o),C=Number.parseFloat((_==null?void 0:_.paddingLeft)||"0")||0;return((m==null?void 0:m.left)||0)+C},debounceMs:72});function S(a=[]){const o=a.flatMap(C=>[Number((C==null?void 0:C.oldNumber)||0),Number((C==null?void 0:C.newNumber)||0)]).filter(C=>C>0);if(!o.length)return{start:0,end:0,label:""};const m=Math.min(...o),_=Math.max(...o);return{start:m,end:_,label:m===_?`L${m}`:`L${m}-L${_}`}}function g(a=[]){return a.map(o=>String((o==null?void 0:o.content)||"")).join(`
4
4
  `).replace(/\u200b/g,"").trim()}function F(){var o,m,_;if(!r.selectedFile||!U.value.visible||!J.value.length)return;const a=S(J.value);p("insert-code-context",{source:"diff",filePath:String(r.selectedFile.path||""),language:"diff",rangeLabel:a.label,lineStart:a.start,lineEnd:a.end,content:g(J.value)||String(U.value.content||"").trim()}),(_=(m=(o=window.getSelection)==null?void 0:o.call(window))==null?void 0:m.removeAllRanges)==null||_.call(m),W()}function G(a,o){if(r.setPatchLineRef(a,o),!!a){if(o){$.set(a,o);return}$.delete(a)}}function X(a){T.value=a||null,r.setPatchViewportRef(a)}function ne(a){var D,L,ue,ce;const o=(D=window.getSelection)==null?void 0:D.call(window),m=T.value;if(!o||o.rangeCount<1||o.isCollapsed||!m)return;w();const C=o.getRangeAt(0).commonAncestorContainer;if(!m.contains((C==null?void 0:C.nodeType)===1?C:C==null?void 0:C.parentNode))return;const V=J.value;if(!V.length)return;const c=g(V);c&&((ue=(L=a==null?void 0:a.clipboardData)==null?void 0:L.setData)==null||ue.call(L,"text/plain",c),(ce=a==null?void 0:a.preventDefault)==null||ce.call(a))}function q(a){return(a==null?void 0:a.kind)==="add"?"+":(a==null?void 0:a.kind)==="delete"?"-":(a==null?void 0:a.kind)==="context"?" ":""}function N(a){const o=String((a==null?void 0:a.content)||"");return(a==null?void 0:a.kind)==="add"||(a==null?void 0:a.kind)==="delete"||(a==null?void 0:a.kind)==="context"?o.slice(1):o}function ie(a=""){return String(a||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function le(a,o=""){if((a==null?void 0:a.kind)==="add"||(a==null?void 0:a.kind)==="delete"||(a==null?void 0:a.kind)==="context"){const m=q(a),_=`task-diff-line__prefix--${a.kind}`;return{...a,renderedHtml:`<span class="task-diff-line__prefix ${_}">${ie(m||" ")}</span><span class="task-diff-line__body">${o||"&#8203;"}</span>`}}return{...a,renderedHtml:ie(String((a==null?void 0:a.content)||""))}}async function oe(){const a=Array.isArray(r.selectedPatchLines)?r.selectedPatchLines:[],o=[];a.forEach((c,D)=>{((c==null?void 0:c.kind)==="add"||(c==null?void 0:c.kind)==="delete"||(c==null?void 0:c.kind)==="context")&&o.push({lineIndex:D,body:N(c)})});const m=ht(o.map(c=>c.body));let _=0;if(f.value=a.map(c=>{if((c==null?void 0:c.kind)==="add"||(c==null?void 0:c.kind)==="delete"||(c==null?void 0:c.kind)==="context"){const D=m[_]||"&#8203;";return _+=1,le(c,D)}return le(c)}),!o.length||mt(o.map(c=>c.body),Me))return;const C=await vt(o.map(c=>c.body),{isDark:H.value,language:u.value,maxHighlightLines:Me.maxLines,maxHighlightChars:Me.maxChars});let V=0;f.value=a.map(c=>{if((c==null?void 0:c.kind)==="add"||(c==null?void 0:c.kind)==="delete"||(c==null?void 0:c.kind)==="context"){const D=C[V]||"&#8203;";return V+=1,le(c,D)}return le(c)})}return K(()=>{var a;return[r.selectedPatchLines,(a=r.selectedFile)==null?void 0:a.path,H.value]},()=>{W(),oe()},{immediate:!0,deep:!0}),bt(()=>{var a,o,m;(m=(o=(a=window.getSelection)==null?void 0:a.call(window))==null?void 0:o.removeAllRanges)==null||m.call(o),W({clearBrowserSelection:!0}),$.clear()}),(a,o)=>e.selectedFile?(b(),R("div",qt,[n("div",zt,[n("div",Wt,[n("div",Gt,[n("span",{class:O(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[12px]",e.getStatusClass(e.selectedFile.status)])},h(e.getStatusLabel(e.selectedFile.status)),3),n("span",Et,h(e.selectedFile.path),1)]),n("div",Kt,[n("div",Jt,[n("div",Qt,h(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:s(x)("diffReview.statsOnDemand")),1),n("div",Xt,h(s(x)("diffReview.selectCodeLineHint")),1)]),n("div",{class:O(["inline-flex h-8 shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[n("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:o[0]||(o[0]=m=>e.jumpToAdjacentHunk(-1))},[j(s(Ge),{class:"h-4 w-4"})],8,Yt),n("span",Zt,h(s(x)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),n("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:o[1]||(o[1]=m=>e.jumpToAdjacentHunk(1))},[j(s(Ee),{class:"h-4 w-4"})],8,es)],2)])]),n("div",ts,[n("div",ss,[n("span",{class:O(["inline-flex rounded-sm border px-1.5 py-0.5 text-[12px]",e.getStatusClass(e.selectedFile.status)])},h(e.getStatusLabel(e.selectedFile.status)),3),n("span",as,h(e.selectedFile.path),1),n("span",ns,h(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:s(x)("diffReview.statsOnDemand")),1),n("span",is,h(s(x)("diffReview.selectCodeLineHint")),1)]),n("div",{class:O(["inline-flex h-8 w-[132px] shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[n("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:o[2]||(o[2]=m=>e.jumpToAdjacentHunk(-1))},[j(s(Ge),{class:"h-4 w-4"})],8,ls),n("span",rs,h(s(x)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),n("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:o[3]||(o[3]=m=>e.jumpToAdjacentHunk(1))},[j(s(Ee),{class:"h-4 w-4"})],8,os)],2)])]),e.selectedFile.message&&!e.selectedPatchLines.length?(b(),R("div",us,[n("div",cs,h(e.selectedFile.message),1)])):e.patchLoading&&!e.selectedFile.patchLoaded?(b(),R("div",ds,h(s(x)("diffReview.loadingFileDiff")),1)):e.selectedPatchLines.length?(b(),R("div",{key:2,ref:X,class:"relative flex-1 overflow-auto",onCopy:ne,onMouseup:o[4]||(o[4]=(...m)=>s(ae)&&s(ae)(...m))},[n("div",fs,[e.selectedFile.message?(b(),R("div",hs,h(e.selectedFile.message),1)):Y("",!0),(b(!0),R(he,null,Le(f.value,m=>{var _;return b(),R("div",{key:m.id,ref_for:!0,ref:C=>G(m.id,C),class:O(["task-diff-row grid",[e.getPatchLineClass(m.kind),m.kind==="hunk"&&((_=e.selectedPatchHunks[e.activeHunkIndex])==null?void 0:_.id)===m.id?"ring-1 ring-inset ring-[var(--theme-warning)]":""]]),"data-line-id":m.id,"data-line-kind":m.kind},[n("span",vs,h(m.oldNumber),1),n("span",gs,h(m.newNumber),1),n("pre",{class:O(["task-diff-line overflow-visible whitespace-pre px-3 py-0.5",m.kind==="meta"||m.kind==="hunk"?"task-diff-line--plain":""]),innerHTML:m.renderedHtml},null,10,ps)],10,ms)}),128))]),s(U).visible?(b(),Pe(ft,{key:0,top:s(U).top,left:s(U).left,label:s(x)("diffReview.insertSelection"),onClick:F},null,8,["top","left","label"])):Y("",!0)],32)):(b(),R("div",xs,[n("div",ks,h(s(x)("diffReview.noFileDiffContent")),1)]))])):(b(),R("div",ys,h(s(x)("diffReview.selectFile")),1))}},Ye=rt(bs,[["__scopeId","data-v-f94acc18"]]),ws={class:"panel flex h-full min-h-0 flex-col overflow-hidden"},Ss={class:"theme-divider border-b px-4 py-3"},Rs={class:"flex flex-col gap-2"},Fs={class:"grid grid-cols-4 gap-2 sm:flex sm:flex-wrap sm:items-center"},Cs={class:"sm:hidden"},Ls={class:"hidden sm:inline"},Ps={class:"sm:hidden"},$s={class:"hidden sm:inline"},Ts=["disabled"],_s={class:"sm:hidden"},Ds={class:"hidden sm:inline"},Is={class:"truncate text-xs text-[var(--theme-textPrimary)]"},Hs={class:"theme-divider theme-muted-text border-b border-dashed px-3 py-2 text-[11px]"},As=["onClick"],Ms={class:"flex items-start gap-3"},js={class:"min-w-0 flex-1"},Ns={class:"truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Bs={class:"theme-muted-text mt-1 text-[11px]"},Vs={key:0,class:"theme-divider theme-danger-text border-b px-4 py-3 text-sm"},Os={class:"inline-flex items-start gap-2"},Us={class:"break-all"},qs={key:1,class:"theme-muted-text flex flex-1 items-center justify-center px-5 text-sm"},zs={key:2,class:"flex flex-1 items-center justify-center px-5"},Ws={class:"theme-empty-state w-full max-w-xl px-4 py-5 text-sm text-[var(--theme-textSecondary)]"},Gs={class:"theme-heading inline-flex items-center gap-2 font-medium"},Es={class:"mt-2 break-all leading-7"},Ks={key:0,class:"mt-3 flex flex-wrap gap-2 text-xs"},Js={class:"theme-status-neutral inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Qs={class:"break-all"},Xs={key:0,class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Ys={key:3,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Zs={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},ea={class:"flex flex-wrap items-center gap-2"},ta={key:0,class:"theme-status-info inline-flex min-w-0 items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},sa={class:"min-w-0 break-all"},aa={class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},na={class:"text-[var(--theme-textPrimary)]"},ia={class:"font-medium text-[var(--theme-success)]"},la={class:"font-medium text-[var(--theme-danger)]"},ra={key:2,class:"opacity-75"},oa={key:0,class:"mt-2 break-all text-[11px] opacity-75"},ua={key:1,class:"mt-2 flex flex-col gap-1"},ca={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},da={class:"theme-divider border-b px-3 py-3"},fa={class:"grid grid-cols-2 gap-2"},ha=["disabled"],ma={class:"theme-divider theme-muted-panel min-h-0 flex-1 overflow-y-auto p-3"},va={class:"min-h-0 flex-1 overflow-hidden bg-[var(--theme-appPanelStrong)]"},ga={key:1,class:"grid min-h-0 flex-1 grid-cols-[320px_minmax(0,1fr)] overflow-hidden"},pa={class:"theme-divider theme-muted-panel min-h-0 overflow-y-auto border-r p-3"},xa={class:"min-h-0 overflow-hidden bg-[var(--theme-appPanelStrong)]"},ka={__name:"TaskDiffReviewPanel",props:{taskSlug:{type:String,default:""},preferredScope:{type:String,default:"workspace"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0},active:{type:Boolean,default:!1}},emits:["insert-code-context"],setup(e,{emit:l}){const r=e,p=l,{activeHunkIndex:x,baselineMetaText:H,diffPayload:f,diffScope:u,error:T,fileSearch:$,filteredFiles:te,formatRunOptionLabel:se,getFilterButtonClass:J,getFilterLabel:U,getPatchLineClass:W,getRunStatusLabel:ae,getStatusClass:w,getStatusLabel:S,jumpToAdjacentHunk:g,loading:F,patchLoading:G,patchViewportRef:X,refreshDiff:ne,selectedFile:q,selectedFilePath:N,selectedPatchHunks:ie,selectedPatchLines:le,selectedRunId:oe,setPatchLineRef:a,showSummarySkeleton:o,statsLoading:m,statusCounts:_,statusFilter:C,terminalRuns:V}=Tt(r),{matches:c}=pt("(max-width: 767px)"),D=B("files"),{t:L}=Te();function ue(Z){N.value=Z,c.value&&(D.value="patch")}function ce(Z){X.value=Z||null}return K(c,Z=>{Z||(D.value="files")},{immediate:!0}),K(N,Z=>{!Z&&c.value&&(D.value="files")}),K(u,()=>{c.value&&(D.value="files")}),(Z,k)=>{var ke,ye,de,be,we;return b(),R("section",ws,[n("div",Ss,[n("div",Rs,[n("div",Fs,[n("button",{type:"button",class:O(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",s(u)==="workspace"?"theme-filter-active":""]),onClick:k[0]||(k[0]=y=>u.value="workspace")},[n("span",Cs,h(s(L)("diffReview.scopeCurrentShort")),1),n("span",Ls,h(s(L)("diffReview.scopeCurrent")),1)],2),n("button",{type:"button",class:O(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",s(u)==="task"?"theme-filter-active":""]),onClick:k[1]||(k[1]=y=>u.value="task")},[n("span",Ps,h(s(L)("diffReview.scopeTaskShort")),1),n("span",$s,h(s(L)("diffReview.scopeTask")),1)],2),n("button",{type:"button",class:O(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",s(u)==="run"?"theme-filter-active":""]),onClick:k[2]||(k[2]=y=>u.value="run")},[n("span",null,h(s(L)("diffReview.scopeRun")),1)],2),n("button",{type:"button",class:"tool-button tool-button-info-subtle inline-flex shrink-0 items-center justify-center gap-2 px-3 py-2 text-xs",disabled:s(F),onClick:k[3]||(k[3]=(...y)=>s(ne)&&s(ne)(...y))},[j(s(Ke),{class:O(["h-3.5 w-3.5 sm:hidden",s(F)?"animate-spin":""])},null,8,["class"]),n("span",_s,h(s(L)("diffReview.refresh")),1),j(s(Ke),{class:O(["hidden h-3.5 w-3.5 sm:inline-block",s(F)?"animate-spin":""])},null,8,["class"]),n("span",Ds,h(s(F)?s(L)("diffReview.refreshing"):s(m)?s(L)("diffReview.computing"):s(L)("diffReview.refresh")),1)],8,Ts)]),s(u)==="run"?(b(),Pe(xt,{key:0,modelValue:s(oe),"onUpdate:modelValue":k[4]||(k[4]=y=>wt(oe)?oe.value=y:null),class:"min-w-0 sm:max-w-[360px]",options:s(V),loading:s(F),"get-option-value":y=>(y==null?void 0:y.id)||"",placeholder:s(L)("diffReview.selectRun"),"empty-text":s(L)("diffReview.noRuns")},{trigger:xe(({selectedOption:y})=>[n("div",Is,h(y?s(se)(y):s(L)("diffReview.selectRun")),1)]),header:xe(()=>[n("div",Hs,h(s(L)("diffReview.runCount",{count:s(V).length})),1)]),option:xe(({option:y,selected:Se,select:_e})=>[n("button",{type:"button",class:O(["w-full rounded-sm border border-dashed px-3 py-2 text-left transition",Se?"theme-filter-active":"theme-filter-idle"]),onClick:_e},[n("div",Ms,[n("div",js,[n("div",Ns,h(s(Ze)(y.startedAt||y.createdAt)),1),n("div",Bs,h(s(ae)(y)),1)]),Se?(b(),Pe(s(Rt),{key:0,class:"mt-0.5 h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):Y("",!0)])],10,As)]),_:1},8,["modelValue","options","loading","get-option-value","placeholder","empty-text"])):Y("",!0)])]),s(T)?(b(),R("div",Vs,[n("div",Os,[j(s(Ft),{class:"mt-0.5 h-4 w-4 shrink-0"}),n("span",Us,h(s(T)),1)])])):Y("",!0),s(F)&&!s(f)?(b(),R("div",qs,h(s(L)("diffReview.loading")),1)):s(f)&&!s(f).supported?(b(),R("div",zs,[n("div",Ws,[n("div",Gs,[j(s(tt),{class:"h-4 w-4"}),n("span",null,h(s(L)("diffReview.unavailableTitle")),1)]),n("p",Es,h(s(f).reason||s(L)("diffReview.unavailableReason")),1),s(f).repoRoot?(b(),R("div",Ks,[n("div",Js,[j(s(Je),{class:"h-3.5 w-3.5 shrink-0"}),n("span",Qs,h(s(f).repoRoot),1)]),s(f).branch?(b(),R("div",Xs,[j(s(Qe),{class:"h-3.5 w-3.5 shrink-0"}),n("span",null,h(s(f).branch),1)])):Y("",!0)])):Y("",!0)])])):s(f)?(b(),R("div",Ys,[n("div",Zs,[n("div",ea,[s(f).repoRoot?(b(),R("div",ta,[j(s(Je),{class:"h-3.5 w-3.5 shrink-0"}),n("span",sa,h(s(f).repoRoot),1)])):Y("",!0),n("div",aa,[j(s(Qe),{class:"h-3.5 w-3.5 shrink-0"}),n("span",null,h(s(f).branch||s(L)("diffReview.unknownBranch")),1),k[18]||(k[18]=n("span",{class:"opacity-50"},"•",-1)),n("span",na,h(s(L)("diffReview.fileCount",{count:((ke=s(f).summary)==null?void 0:ke.fileCount)||0})),1),(ye=s(f).summary)!=null&&ye.statsComplete?(b(),R(he,{key:0},[k[14]||(k[14]=n("span",{class:"opacity-50"},"•",-1)),n("span",ia,"+"+h(((de=s(f).summary)==null?void 0:de.additions)||0),1),n("span",la,"-"+h(((be=s(f).summary)==null?void 0:be.deletions)||0),1)],64)):s(o)?(b(),R(he,{key:1},[k[15]||(k[15]=n("span",{class:"opacity-50"},"•",-1)),k[16]||(k[16]=n("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-successSoft)]"},null,-1)),k[17]||(k[17]=n("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-dangerSoft)]"},null,-1))],64)):(b(),R("span",ra,h(s(L)("diffReview.waitingStats")),1))])]),s(H)?(b(),R("p",oa,h(s(H)),1)):Y("",!0),(we=s(f).warnings)!=null&&we.length?(b(),R("div",ua,[(b(!0),R(he,null,Le(s(f).warnings,y=>(b(),R("p",{key:y,class:"text-[11px] text-[var(--theme-warningText)]"},h(y),1))),128))])):Y("",!0)]),s(c)?(b(),R("div",ca,[n("div",da,[n("div",fa,[n("button",{type:"button",class:O(["tool-button px-3 py-2 text-sm",D.value==="files"?"tool-button-accent-subtle":""]),onClick:k[5]||(k[5]=y=>D.value="files")},h(s(L)("diffReview.filesTab")),3),n("button",{type:"button",class:O(["tool-button px-3 py-2 text-sm",D.value==="patch"?"tool-button-accent-subtle":""]),disabled:!s(q),onClick:k[6]||(k[6]=y=>D.value="patch")},h(s(L)("diffReview.diffTab")),11,ha)])]),Be(n("div",ma,[j(Xe,{"auto-focus-selected":e.active&&D.value==="files","diff-payload":s(f),"file-search":s($),"focus-token":e.focusToken,"filtered-files":s(te),"get-filter-button-class":s(J),"get-filter-label":s(U),"get-status-class":s(w),"get-status-label":s(S),"selected-file-path":s(N),"show-summary-skeleton":s(o),"status-counts":s(_),"status-filter":s(C),"onUpdate:fileSearch":k[7]||(k[7]=y=>$.value=y),"onUpdate:statusFilter":k[8]||(k[8]=y=>C.value=y),onSelectFile:ue},null,8,["auto-focus-selected","diff-payload","file-search","focus-token","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])],512),[[We,D.value==="files"]]),Be(n("div",va,[j(Ye,{"active-hunk-index":s(x),"get-patch-line-class":s(W),"get-status-class":s(w),"get-status-label":s(S),"jump-to-adjacent-hunk":s(g),"patch-loading":s(G),"selected-file":s(q),"selected-patch-hunks":s(ie),"selected-patch-lines":s(le),"set-patch-line-ref":s(a),"set-patch-viewport-ref":ce,onInsertCodeContext:k[9]||(k[9]=y=>p("insert-code-context",y))},null,8,["active-hunk-index","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])],512),[[We,D.value==="patch"]])])):(b(),R("div",ga,[n("div",pa,[j(Xe,{"auto-focus-selected":e.active,"diff-payload":s(f),"file-search":s($),"focus-token":e.focusToken,"filtered-files":s(te),"get-filter-button-class":s(J),"get-filter-label":s(U),"get-status-class":s(w),"get-status-label":s(S),"selected-file-path":s(N),"show-summary-skeleton":s(o),"status-counts":s(_),"status-filter":s(C),"onUpdate:fileSearch":k[10]||(k[10]=y=>$.value=y),"onUpdate:statusFilter":k[11]||(k[11]=y=>C.value=y),onSelectFile:k[12]||(k[12]=y=>N.value=y)},null,8,["auto-focus-selected","diff-payload","file-search","focus-token","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])]),n("div",xa,[j(Ye,{"active-hunk-index":s(x),"get-patch-line-class":s(W),"get-status-class":s(w),"get-status-label":s(S),"jump-to-adjacent-hunk":s(g),"patch-loading":s(G),"selected-file":s(q),"selected-patch-hunks":s(ie),"selected-patch-lines":s(le),"set-patch-line-ref":s(a),"set-patch-viewport-ref":ce,onInsertCodeContext:k[13]||(k[13]=y=>p("insert-code-context",y))},null,8,["active-hunk-index","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])])]))])):Y("",!0)])}}},ya={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Pa={__name:"TaskDiffReviewDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""},preferredScope:{type:String,default:"task"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0}},emits:["close","insert-code-context"],setup(e,{emit:l}){const r=e,p=l,{t:x}=Te(),H=E(()=>{const u=String(r.taskTitle||"").trim();return u?x("diffReview.dialogTitleWithTask",{title:u}):x("diffReview.dialogTitle")});function f(u){p("insert-code-context",u),p("close")}return(u,T)=>(b(),Pe(kt,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] sm:h-[96vh] sm:max-h-[96vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex-1 overflow-hidden p-3 sm:p-4",onClose:T[0]||(T[0]=$=>p("close"))},{title:xe(()=>[n("div",ya,[j(s(tt),{class:"h-4 w-4"}),n("span",null,h(H.value),1)])]),default:xe(()=>[j(ka,{"task-slug":e.taskSlug,active:e.open,"preferred-scope":e.preferredScope,"preferred-run-id":e.preferredRunId,"focus-token":e.focusToken,onInsertCodeContext:f},null,8,["task-slug","active","preferred-scope","preferred-run-id","focus-token"])]),_:1},8,["open"]))}};export{Pa as default};
@@ -0,0 +1 @@
1
+ import{aD as l,aE as c,aF as e,aQ as i,u as a,aR as H,aS as q,aL as Y,aV as qt,aI as T,aN as v,c as x,w as at,ak as Kt,aJ as be,aG as U,aW as I,b2 as Wt,aY as ot,aX as De,b3 as zt,b as m,r as Ce}from"./vendor-misc-u-M8sNMf.js";import{h as Q,j as Jt,d as Gt,f as Yt,k as Qt}from"./WorkbenchView-3rJGJ6O2.js";import{u as mt,b as Xt,W as ke,c as Zt,f as es,d as lt}from"./index-DCBAbk14.js";import{b as gt,K as we,L as ue,D as rt,E as ts,g as ss,H as ct,t as ns,J as is,x as as}from"./vendor-ui-BwEQCho1.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";function os(){return Q("/api/relay/config",{cache:"no-store"})}function dt(F){return Q("/api/relay/config",{method:"PUT",body:JSON.stringify(F)})}function ls(){return Q("/api/relay/reconnect",{method:"POST"})}function rs(){return Q("/api/system/config",{cache:"no-store"})}function ut(F){return Q("/api/system/config",{method:"PUT",body:JSON.stringify(F)})}function cs(){return Q("/api/diagnostics/runtime",{cache:"no-store"})}const ds={class:"space-y-4"},us={class:"flex items-center justify-between gap-3"},ms={class:"theme-heading text-sm font-medium"},gs={class:"theme-toggle-current theme-badge-muted theme-muted-text rounded-sm border border-dashed px-2 py-1 text-[11px]"},hs={class:"theme-muted-text theme-note-text mt-1"},vs={class:"space-y-4"},xs={class:"theme-muted-text px-1 text-[10px] font-medium uppercase tracking-[0.16em]"},ys=["onClick"],ps={class:"flex items-start gap-3"},_s={class:"mt-0.5 flex items-center gap-1.5"},fs={class:"min-w-0 flex-1"},bs={class:"flex items-center justify-between gap-2"},Ds={class:"truncate text-sm font-medium"},Cs={class:"theme-muted-text theme-note-text mt-1"},ks={__name:"ThemeToggle",setup(F){const{currentTheme:X,setTheme:Z,themes:me}=Xt(),{t:R}=mt(),Se=x(()=>{const C=me.value.filter(y=>y.mode==="light"),ee=me.value.filter(y=>y.mode==="dark");return[{id:"light",label:R("theme.groupLight"),items:C},{id:"dark",label:R("theme.groupDark"),items:ee}].filter(y=>y.items.length)});function Te(C){Z(C)}function s(C){return R(`theme.description.${C.id}`,{},C.description)}return(C,ee)=>(l(),c("div",ds,[e("div",null,[e("div",us,[e("div",ms,i(a(R)("theme.heading")),1),e("div",gs,i(a(R)("theme.currentTheme",{name:a(X).shortName})),1)]),e("div",hs,i(a(R)("theme.helper")),1)]),e("div",vs,[(l(!0),c(H,null,q(Se.value,y=>(l(),c("section",{key:y.id,class:"space-y-1.5"},[e("div",xs,i(y.label),1),(l(!0),c(H,null,q(y.items,b=>(l(),c("button",{key:b.id,type:"button",class:Y(["theme-option theme-toggle-card w-full rounded-sm border px-3 py-2 text-left transition",b.id===a(X).id?"theme-option-active":"theme-option-idle"]),onClick:j=>Te(b.id)},[e("div",ps,[e("div",_s,[(l(!0),c(H,null,q(b.swatches,(j,P)=>(l(),c("span",{key:`${b.id}-${P}`,class:"h-3 w-3 rounded-full border border-black/10",style:qt({backgroundColor:j})},null,4))),128))]),e("div",fs,[e("div",bs,[e("span",Ds,i(b.shortName),1),b.id===a(X).id?(l(),T(a(gt),{key:0,class:"h-4 w-4 shrink-0"})):v("",!0)]),e("div",Cs,i(s(b)),1)])])],10,ys))),128))]))),128))])]))}},ws={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Ss={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},Ts={key:0,class:"space-y-4"},Rs={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ps={class:"settings-section-card space-y-4 px-4 py-4"},Es={class:"theme-heading text-sm font-medium"},Ms={class:"theme-muted-text mt-1 text-xs leading-5"},Bs={class:"grid gap-3"},Ns=["value","onChange"],$s={class:"min-w-0"},Us={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Is={class:"theme-muted-text mt-1 text-xs leading-5"},Fs={class:"settings-section-card space-y-4 px-4 py-4"},js={class:"theme-heading text-sm font-medium"},Ls={class:"theme-muted-text mt-1 text-xs leading-5"},Os={class:"settings-form-card flex items-center justify-between gap-3 px-3 py-3"},Vs={class:"min-w-0"},As={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Hs={class:"theme-muted-text mt-1 text-xs leading-5"},qs={class:"settings-section-card space-y-4 px-4 py-4"},Ks={class:"theme-heading text-sm font-medium"},Ws={class:"theme-muted-text mt-1 text-xs leading-5"},zs={class:"block space-y-1.5"},Js={class:"theme-muted-text text-xs"},Gs={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Ys=["onClick"],Qs={class:"flex items-center justify-between gap-3"},Xs={class:"min-w-0"},Zs={class:"truncate text-[var(--theme-textPrimary)]"},en={class:"theme-muted-text mt-1 truncate text-xs"},tn={key:0,class:"theme-status-success rounded-sm border border-dashed px-2 py-0.5 text-[10px]"},sn={class:"theme-muted-text theme-note-text"},nn={class:"settings-section-card space-y-4 px-4 py-4"},an={class:"theme-heading text-sm font-medium"},on={class:"theme-muted-text mt-1 text-xs leading-5"},ln={class:"space-y-1.5"},rn={class:"theme-muted-text text-xs"},cn={class:"space-y-2"},dn={class:"min-w-0"},un={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},mn={class:"theme-muted-text mt-1 text-xs leading-5"},gn=["checked"],hn={class:"min-w-0"},vn={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},xn={class:"theme-muted-text mt-1 text-xs leading-5"},yn=["checked"],pn={class:"min-w-0"},_n={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},fn={class:"theme-muted-text mt-1 text-xs leading-5"},bn=["checked"],Dn={key:0,class:"space-y-1.5"},Cn={class:"theme-muted-text text-xs"},kn=["placeholder"],wn={key:0,class:"theme-muted-text text-xs leading-5"},Sn={class:"theme-muted-text text-xs leading-5"},Tn={class:"settings-form-card px-3 py-3"},Rn={class:"text-xs leading-5 text-[var(--theme-warningText)]"},Pn={class:"settings-form-footer flex flex-wrap items-center justify-end gap-3"},En={class:"flex flex-wrap items-center gap-2"},Mn=["disabled"],Bn={key:1,class:"space-y-4"},Nn={class:"theme-heading text-base font-medium"},$n={class:"theme-muted-text mt-1 text-xs leading-5"},Un={class:"settings-section-card px-4 py-4"},In={key:2,class:"space-y-4"},Fn={class:"flex items-start justify-between gap-3"},jn={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ln={class:"settings-section-card space-y-4 px-4 py-4"},On={class:"settings-form-card flex items-center justify-between gap-3 px-3 py-2"},Vn={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},An={class:"theme-muted-text mt-1 text-xs"},Hn=["disabled"],qn={class:"grid gap-4 sm:grid-cols-2"},Kn={class:"space-y-1.5 sm:col-span-2"},Wn={class:"theme-muted-text text-xs"},zn=["disabled"],Jn={class:"space-y-1.5"},Gn={class:"theme-muted-text text-xs"},Yn=["disabled"],Qn={class:"space-y-1.5"},Xn={class:"theme-muted-text text-xs"},Zn={class:"relative"},ei=["type","placeholder","disabled"],ti=["disabled"],si={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},ni={class:"min-w-0 space-y-1"},ii={key:0,class:"theme-danger-text theme-note-text"},ai={key:1,class:"theme-status-warning theme-note-text"},oi={key:2,class:"theme-danger-text theme-note-text"},li={key:3,class:"theme-status-success theme-note-text"},ri={key:4,class:"theme-danger-text theme-note-text"},ci={key:5,class:"theme-muted-text theme-note-text"},di={key:6,class:"theme-muted-text theme-note-text"},ui={key:7,class:"theme-muted-text theme-note-text"},mi={key:8,class:"theme-status-success theme-note-text"},gi={key:9,class:"theme-muted-text theme-note-text"},hi={class:"flex flex-wrap items-center gap-2"},vi=["disabled"],xi=["disabled"],yi=["disabled"],pi={key:3,class:"space-y-4"},_i={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},fi={class:"theme-muted-text mt-1 text-xs leading-5"},bi={class:"settings-section-card space-y-4 px-4 py-4"},Di={class:"space-y-1.5"},Ci={class:"theme-muted-text text-xs"},ki=["disabled"],wi={class:"theme-muted-text text-xs leading-5"},Si={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},Ti={class:"min-w-0 space-y-1"},Ri={key:0,class:"theme-status-warning theme-note-text"},Pi={key:1,class:"theme-danger-text theme-note-text"},Ei={key:2,class:"theme-status-success theme-note-text"},Mi={key:3,class:"theme-muted-text theme-note-text"},Bi={class:"flex flex-wrap items-center gap-2"},Ni=["disabled"],$i={class:"settings-section-card space-y-4 px-4 py-4"},Ui={class:"flex flex-wrap items-start justify-between gap-3"},Ii={class:"theme-heading text-sm font-medium"},Fi={class:"theme-muted-text mt-1 text-xs leading-5"},ji={class:"flex flex-wrap items-center gap-2"},Li=["disabled"],Oi={class:"min-w-0 space-y-1"},Vi={key:0,class:"theme-danger-text theme-note-text"},Ai={key:1,class:"theme-status-success theme-note-text"},Hi={key:2,class:"theme-muted-text theme-note-text"},qi={key:0,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},Ki={class:"settings-form-card space-y-1 px-3 py-3"},Wi={class:"theme-heading text-lg font-medium"},zi={class:"theme-muted-text text-xs"},Ji={class:"settings-form-card space-y-1 px-3 py-3"},Gi={class:"theme-heading text-lg font-medium"},Yi={class:"theme-muted-text text-xs"},Qi={class:"settings-form-card space-y-1 px-3 py-3"},Xi={class:"theme-heading text-lg font-medium"},Zi={class:"theme-muted-text text-xs"},ea={class:"settings-form-card space-y-1 px-3 py-3"},ta={class:"theme-heading text-lg font-medium"},sa={class:"theme-muted-text text-xs"},na={key:1,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},ia={class:"settings-form-card space-y-1 px-3 py-3"},aa={class:"theme-heading text-lg font-medium"},oa={class:"theme-muted-text text-xs"},la={class:"settings-form-card space-y-1 px-3 py-3"},ra={class:"theme-heading text-lg font-medium"},ca={class:"theme-muted-text text-xs"},da={class:"settings-form-card space-y-1 px-3 py-3"},ua={class:"theme-heading text-lg font-medium"},ma={class:"theme-muted-text text-xs"},ga={class:"settings-form-card space-y-1 px-3 py-3"},ha={class:"theme-heading text-lg font-medium"},va={class:"theme-muted-text text-xs"},xa={key:2,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3"},ya={class:"settings-form-card space-y-1 px-3 py-3"},pa={class:"theme-heading text-lg font-medium"},_a={class:"theme-muted-text text-xs"},fa={class:"settings-form-card space-y-1 px-3 py-3"},ba={class:"theme-heading text-lg font-medium"},Da={class:"theme-muted-text text-xs"},Ca={class:"settings-form-card space-y-1 px-3 py-3"},ka={class:"theme-heading text-sm font-medium"},wa={class:"theme-muted-text text-xs"},Sa={class:"grid gap-4 lg:grid-cols-2"},Ta={class:"settings-form-card space-y-3 px-3 py-3"},Ra={class:"theme-heading text-sm font-medium"},Pa={class:"space-y-2 text-xs"},Ea={class:"flex items-center justify-between gap-3"},Ma={class:"truncate text-right text-[var(--theme-textPrimary)]"},Ba={class:"flex items-center justify-between gap-3"},Na={class:"text-right text-[var(--theme-textPrimary)]"},$a={class:"flex items-center justify-between gap-3"},Ua={class:"text-right text-[var(--theme-textPrimary)]"},Ia={class:"flex items-center justify-between gap-3"},Fa={class:"text-right text-[var(--theme-textPrimary)]"},ja={class:"flex items-center justify-between gap-3"},La={class:"text-right text-[var(--theme-textPrimary)]"},Oa={class:"settings-form-card space-y-3 px-3 py-3"},Va={class:"theme-heading text-sm font-medium"},Aa={class:"space-y-2 text-xs"},Ha={class:"theme-muted-text"},qa={class:"text-[var(--theme-textPrimary)]"},Ka={key:3,class:"settings-form-card space-y-3 px-3 py-3"},Wa={class:"theme-heading text-sm font-medium"},za={class:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3 text-xs"},Ja={class:"theme-muted-text"},Ga={class:"text-[var(--theme-textPrimary)]"},Ya={key:4,class:"settings-form-card space-y-2 px-3 py-3"},Qa={class:"theme-heading text-sm font-medium"},Xa={class:"theme-muted-text text-xs leading-5"},Za={class:"theme-muted-text text-xs leading-5"},eo={key:4,class:"space-y-4"},to={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},so={class:"theme-muted-text mt-1 text-xs leading-5"},no={class:"settings-section-card space-y-3 px-4 py-4"},io={class:"min-w-0"},ao={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},oo={class:"theme-muted-text mt-1 text-xs leading-5"},lo={class:"flex flex-wrap items-center gap-2"},ro={class:"rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2.5 py-1 text-xs font-medium text-[var(--theme-textPrimary)]"},co={class:"rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2.5 py-1 text-xs font-medium text-[var(--theme-textPrimary)]"},uo={class:"theme-muted-text theme-note-text"},mo={key:5,class:"space-y-4"},go={class:"theme-heading text-base font-medium"},ho={class:"theme-muted-text mt-1 text-xs leading-5"},vo={class:"settings-section-card px-4 py-4"},xo={class:"flex items-center justify-between gap-3"},yo={class:"theme-heading text-sm font-medium"},po={class:"theme-muted-text mt-1 text-xs leading-5"},_o={class:"theme-badge-strong rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium"},Ro={__name:"WorkbenchSettingsDialog",props:{open:{type:Boolean,default:!1}},emits:["close"],setup(F,{emit:X}){const Z=F,me=X,{locale:R,localeOptions:Se,setLocale:Te,t:s}=mt(),{getPreference:C,setPreference:ee}=Zt(),y=m(""),b=m(!1),j=m(""),P=m(!1),L=m(!1),E=m(!1),_=m(""),k=m(""),ge=m(!1),K=m(!1),M=m(""),te=m(""),se=m(!1),W=m(!1),he=m(!1),z=m(!1),ne=m(""),w=m(null),u=m(null),f=m(!1),J=Ce({runnerMaxConcurrentRuns:!1}),ie=m(!1),ve=m(!1),xe=m(!1),ye=m(!1),d=Ce({enabled:!1,relayUrl:"",deviceId:"",deviceToken:""}),G=Ce({runnerMaxConcurrentRuns:3}),h=Ce({sendBehavior:"",notificationSoundEnabled:!1,remoteCommandSecurityMode:"disabled",trustedProxyToken:""}),S=m("general");let O=null,V=null,pe=null,ae=null;const ht=x(()=>[{id:"general",label:s("settingsDialog.general.sectionLabel"),description:s("settingsDialog.general.sectionDescription"),icon:we},{id:"theme",label:s("theme.title"),description:s("theme.sectionDescription"),icon:is},{id:"relay",label:s("settingsDialog.relay.sectionLabel"),description:s("settingsDialog.relay.sectionDescription"),icon:rt},{id:"system",label:s("settingsDialog.system.sectionLabel"),description:s("settingsDialog.system.sectionDescription"),icon:ct},{id:"shortcuts",label:s("settingsDialog.shortcuts.sectionLabel"),description:s("settingsDialog.shortcuts.sectionDescription"),icon:we},{id:"about",label:s("settingsDialog.about.sectionLabel"),description:s("settingsDialog.about.sectionDescription"),icon:as}]),vt=x(()=>lt.map(t=>({value:t.value,label:s(t.labelKey),description:s(t.descriptionKey)})));function xt(t=null,n=""){const o=String((t==null?void 0:t.messageKey)||"").trim();if(o){const g=s(o);if(g&&g!==o)return g}return String((t==null?void 0:t.message)||"").trim()||(n?s(n):"")}function _e(t="",n=""){const o=String(t||"").trim();if(o){const g=`settingsDialog.relay.reason.${o}`,D=s(g);if(D!==g)return D}return String(n||"").trim()||s("common.notAvailable")}function yt(t=null){const n=String((t==null?void 0:t.type)||"").trim()||"unknown",o=`settingsDialog.relay.event.${n}`,g=s(o);return g!==o?g:n}function pt(t=null){const n=String((t==null?void 0:t.lastErrorKey)||"").trim(),o=t!=null&&t.lastErrorParams&&typeof t.lastErrorParams=="object"?t.lastErrorParams:{};return n==="connect_failed"?s("settingsDialog.relay.error.connect_failed"):n==="disconnected"?s("settingsDialog.relay.error.disconnected",{reason:_e(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="rejected"?s("settingsDialog.relay.error.rejected",{reason:_e(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="closed_with_code"?s("settingsDialog.relay.error.closedWithCode",{code:o.code||(t==null?void 0:t.lastCloseCode)||0}):String((t==null?void 0:t.lastError)||"").trim()}const _t=x(()=>{var t,n,o,g;return E.value?s("settingsDialog.relay.status.reconnecting"):L.value||ie.value?s("settingsDialog.relay.status.saving"):P.value?s("settingsDialog.relay.status.loading"):(t=u.value)!=null&&t.reconnectPaused?s("settingsDialog.relay.status.paused"):(n=u.value)!=null&&n.connected?s("settingsDialog.relay.status.connected"):(((o=u.value)==null?void 0:o.enabled)??d.enabled)&&Number(((g=u.value)==null?void 0:g.nextReconnectDelayMs)||0)>0?s("settingsDialog.relay.status.waitingReconnect"):d.enabled?s("settingsDialog.relay.status.disconnected"):s("settingsDialog.relay.status.disabled")}),ft=x(()=>{var t,n;return(t=u.value)!=null&&t.reconnectPaused?"theme-status-danger":(n=u.value)!=null&&n.connected?"theme-status-success":d.enabled?"theme-status-warning":"theme-status-neutral"}),bt=x(()=>[{id:"open-settings",label:s("settingsDialog.shortcuts.openSettingsTitle"),description:s("settingsDialog.shortcuts.openSettingsDescription"),mac:"⌘ ⇧ ,",windows:"Ctrl + Shift + ,"},{id:"open-project-manager",label:s("settingsDialog.shortcuts.openProjectManagerTitle"),description:s("settingsDialog.shortcuts.openProjectManagerDescription"),mac:"⌘ ⇧ K",windows:"Ctrl + Shift + K"},{id:"open-source-browser",label:s("settingsDialog.shortcuts.openSourceBrowserTitle"),description:s("settingsDialog.shortcuts.openSourceBrowserDescription"),mac:"⌘ ⇧ O",windows:"Ctrl + Shift + O"},{id:"open-diff-review",label:s("settingsDialog.shortcuts.openDiffReviewTitle"),description:s("settingsDialog.shortcuts.openDiffReviewDescription"),mac:"⌘ ⇧ D",windows:"Ctrl + Shift + D"},{id:"close-top-dialog",label:s("settingsDialog.shortcuts.closeTopDialogTitle"),description:s("settingsDialog.shortcuts.closeTopDialogDescription"),mac:"Esc",windows:"Esc"}]),Dt=x(()=>{var t,n,o;return!f.value&&!_.value&&!k.value&&!((t=u.value)!=null&&t.lastError)&&!((n=u.value)!=null&&n.lastCloseReason)&&!((o=u.value)!=null&&o.lastConnectedAt)}),Ct=x(()=>{const t=d.deviceToken?`${"*".repeat(Math.max(0,d.deviceToken.length-4))}${d.deviceToken.slice(-4)}`:"";return JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceTokenMasked:t,managedByEnv:f.value},status:u.value||null},null,2)}),A=x(()=>{var t,n;return((n=(t=w.value)==null?void 0:t.runner)==null?void 0:n.runner)||null}),oe=x(()=>{var t,n;return!!((n=(t=w.value)==null?void 0:t.runner)!=null&&n.ok&&A.value)}),p=x(()=>{var t;return((t=A.value)==null?void 0:t.metrics)||null}),Be=x(()=>{var t;return((t=w.value)==null?void 0:t.recovery)||null}),Ne=x(()=>{var t;return((t=w.value)==null?void 0:t.maintenance)||null}),kt=x(()=>{var t;return((t=w.value)==null?void 0:t.gitDiffWorker)||null}),wt=x(()=>JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{runner:{maxConcurrentRuns:G.runnerMaxConcurrentRuns,managedByEnv:J.runnerMaxConcurrentRuns}},diagnostics:w.value||null},null,2));function le(t){const n=String(t||"").trim();if(!n)return s("common.notAvailable");const o=new Date(n);return Number.isNaN(o.getTime())?n:es(o.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}const St=x(()=>{var t,n,o,g,D,B,N,$;return[{key:"queued_cancelled",label:s("settingsDialog.system.stopReasons.queued_cancelled"),value:Math.max(0,Number((n=(t=p.value)==null?void 0:t.stopReasons)==null?void 0:n.queued_cancelled)||0)},{key:"user_requested",label:s("settingsDialog.system.stopReasons.user_requested"),value:Math.max(0,Number((g=(o=p.value)==null?void 0:o.stopReasons)==null?void 0:g.user_requested)||0)},{key:"user_requested_after_error",label:s("settingsDialog.system.stopReasons.user_requested_after_error"),value:Math.max(0,Number((B=(D=p.value)==null?void 0:D.stopReasons)==null?void 0:B.user_requested_after_error)||0)},{key:"stop_timeout",label:s("settingsDialog.system.stopReasons.stop_timeout"),value:Math.max(0,Number(($=(N=p.value)==null?void 0:N.stopReasons)==null?void 0:$.stop_timeout)||0)}]}),Tt=x(()=>{var t,n,o,g,D,B,N,$,ce,de;return[{key:"runner_timeout_without_stop_request",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_without_stop_request"),value:Math.max(0,Number((n=(t=p.value)==null?void 0:t.stopTimeoutPhases)==null?void 0:n.runner_timeout_without_stop_request)||0)},{key:"runner_timeout_before_cancel",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_before_cancel"),value:Math.max(0,Number((g=(o=p.value)==null?void 0:o.stopTimeoutPhases)==null?void 0:g.runner_timeout_before_cancel)||0)},{key:"cli_not_exiting",label:s("settingsDialog.system.stopTimeoutPhases.cli_not_exiting"),value:Math.max(0,Number((B=(D=p.value)==null?void 0:D.stopTimeoutPhases)==null?void 0:B.cli_not_exiting)||0)},{key:"os_kill_slow",label:s("settingsDialog.system.stopTimeoutPhases.os_kill_slow"),value:Math.max(0,Number(($=(N=p.value)==null?void 0:N.stopTimeoutPhases)==null?void 0:$.os_kill_slow)||0)},{key:"runner_finalize_after_exit",label:s("settingsDialog.system.stopTimeoutPhases.runner_finalize_after_exit"),value:Math.max(0,Number((de=(ce=p.value)==null?void 0:ce.stopTimeoutPhases)==null?void 0:de.runner_finalize_after_exit)||0)}]}),Rt=x(()=>Se.value.map(t=>({value:t.value,label:t.value==="zh-CN"?s("locale.zhHans"):s("locale.enUs"),englishLabel:t.englishLabel})));async function Pt(){b.value=!0,j.value="";try{const t=await Qt(),n=String((t==null?void 0:t.version)||"").trim();y.value=n,n||(j.value=s("settingsDialog.about.versionPending"))}catch(t){y.value="",j.value=(t==null?void 0:t.message)||s("settingsDialog.about.versionLoadFailed")}finally{b.value=!1}}function Re(t={}){d.enabled=!!(t!=null&&t.enabled),d.relayUrl=String((t==null?void 0:t.relayUrl)||""),d.deviceId=String((t==null?void 0:t.deviceId)||""),d.deviceToken=String((t==null?void 0:t.deviceToken)||"")}function Pe(t={}){var n,o,g;G.runnerMaxConcurrentRuns=Math.max(1,Number((n=t==null?void 0:t.runner)==null?void 0:n.maxConcurrentRuns)||3),h.remoteCommandSecurityMode=String(((o=t==null?void 0:t.remoteCommandSecurity)==null?void 0:o.mode)||"disabled").trim()||"disabled",h.trustedProxyToken="",he.value=!!((g=t==null?void 0:t.remoteCommandSecurity)!=null&&g.trustedProxyTokenConfigured)}function Et(){var t;h.sendBehavior=String(C(ke.SEND_BEHAVIOR)||((t=lt[1])==null?void 0:t.value)||""),h.notificationSoundEnabled=!!C(ke.NOTIFICATION_SOUND_ENABLED)}async function $e(){P.value=!0,_.value="",k.value="";try{const t=await os();Re((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigLoadFailed"),u.value=null}finally{P.value=!1}}async function Mt(){var t,n;ge.value=!0,M.value="",te.value="";try{const o=await rs();Pe((o==null?void 0:o.config)||{}),J.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),re()}catch(o){M.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigLoadFailed")}finally{ge.value=!1}}async function re(){z.value=!0,ne.value="";try{w.value=await cs()}catch(t){ne.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsLoadFailed")}finally{z.value=!1}}async function Bt(){L.value=!0,_.value="",k.value="";try{const t=await dt({enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceToken:d.deviceToken});Re((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null,k.value=d.enabled?s("settingsDialog.relay.relayConfigSavedEnabled"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigSaveFailed")}finally{L.value=!1}}async function Nt(){E.value=!0,_.value="",k.value="";try{const t=await ls();u.value=(t==null?void 0:t.relay)||null,k.value=s("settingsDialog.relay.relayReconnectTriggered"),setTimeout(()=>{$e()},1200)}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayReconnectFailed")}finally{E.value=!1}}async function $t(){var t,n;K.value=!0,M.value="",te.value="";try{const o=await ut({runner:{maxConcurrentRuns:G.runnerMaxConcurrentRuns}});Pe((o==null?void 0:o.config)||{}),J.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),te.value=s("settingsDialog.system.systemConfigSaved"),re()}catch(o){M.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigSaveFailed")}finally{K.value=!1}}function Ue(){ae&&(clearTimeout(ae),ae=null),W.value=!1}async function Ut(){se.value=!0,M.value="";try{const t=await ut({remoteCommandSecurity:It()});Pe((t==null?void 0:t.config)||{}),Ue(),W.value=!0,ae=setTimeout(()=>{W.value=!1,ae=null},1200)}catch(t){M.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemConfigSaveFailed")}finally{se.value=!1}}function It(){const t={mode:h.remoteCommandSecurityMode},n=String(h.trustedProxyToken||"").trim();return h.remoteCommandSecurityMode==="trusted-proxy"&&n&&(t.trustedProxyToken=n),t}function Ee(t){h.remoteCommandSecurityMode=t}function Ft(){return!!(String(d.relayUrl||"").trim()&&String(d.deviceId||"").trim()&&String(d.deviceToken||"").trim())}async function jt(){var t;if(!f.value){if(_.value="",k.value="",d.enabled&&!Ft()){d.enabled=!1,_.value=s("settingsDialog.relay.relayFieldsRequired");return}ie.value=!0;try{const n=await dt({enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceToken:d.deviceToken});Re((n==null?void 0:n.config)||{}),f.value=!!(n!=null&&n.managedByEnv),u.value=(n==null?void 0:n.relay)||null,k.value=d.enabled?s("settingsDialog.relay.relayEnabledSaved"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(n){d.enabled=!!((t=u.value)!=null&&t.enabled),_.value=(n==null?void 0:n.message)||s("settingsDialog.relay.relayToggleFailed")}finally{ie.value=!1}}}async function Ie(t){var o;if((o=navigator.clipboard)!=null&&o.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}async function Lt(){try{await Ie(Ct.value),xe.value=!0,O&&clearTimeout(O),O=setTimeout(()=>{xe.value=!1,O=null},2e3)}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayDiagnosticsCopyFailed")}}async function Ot(){try{await Ie(wt.value),ye.value=!0,V&&clearTimeout(V),V=setTimeout(()=>{ye.value=!1,V=null},2e3)}catch(t){ne.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsCopyFailed")}}function Vt(t){Te(t)}function Me(){pe&&(clearInterval(pe),pe=null)}function At(){Me(),!(!Z.open||S.value!=="system")&&(re(),pe=setInterval(()=>{re()},5e3))}return at(()=>Z.open,t=>{if(t){S.value="general",Et(),Pt(),$e(),Mt();return}},{immediate:!0}),at([()=>Z.open,S],([t,n])=>{if(t&&n==="system"){At();return}Me()},{immediate:!0}),Kt(()=>{O&&(clearTimeout(O),O=null),V&&(clearTimeout(V),V=null),Ue(),Me()}),(t,n)=>(l(),T(Yt,{open:F.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col sm:flex-row",onClose:n[14]||(n[14]=o=>me("close"))},{title:be(()=>[e("div",ws,[U(a(ns),{class:"h-4 w-4"}),e("span",null,i(a(s)("common.settings")),1)])]),default:be(()=>{var o,g,D,B,N,$,ce,de,Fe,je,Le,Oe,Ve,Ae,He,qe,Ke,We,ze,Je,Ge,Ye,Qe,Xe,Ze,et,tt,st,nt,it;return[U(Jt,{modelValue:S.value,"onUpdate:modelValue":n[0]||(n[0]=r=>S.value=r),sections:ht.value},null,8,["modelValue","sections"]),e("div",Ss,[S.value==="general"?(l(),c("section",Ts,[e("div",null,[e("div",Rs,[U(a(we),{class:"h-4 w-4"}),e("span",null,i(a(s)("settingsDialog.general.title")),1)])]),e("section",Ps,[e("div",null,[e("div",Es,i(a(s)("settingsDialog.general.sendBehavior.title")),1),e("p",Ms,i(a(s)("settingsDialog.general.sendBehavior.description")),1)]),e("div",Bs,[(l(!0),c(H,null,q(vt.value,r=>(l(),c("label",{key:r.value,class:"settings-form-card flex items-start gap-3 px-3 py-3"},[I(e("input",{"onUpdate:modelValue":n[1]||(n[1]=fe=>h.sendBehavior=fe),value:r.value,type:"radio",name:"workbench-send-behavior",class:"mt-0.5 h-4 w-4",onChange:fe=>a(ee)(a(ke).SEND_BEHAVIOR,r.value)},null,40,Ns),[[Wt,h.sendBehavior]]),e("div",$s,[e("div",Us,i(r.label),1),e("p",Is,i(r.description),1)])]))),128))])]),e("section",Fs,[e("div",null,[e("div",js,i(a(s)("settingsDialog.general.notificationSound.title")),1),e("p",Ls,i(a(s)("settingsDialog.general.notificationSound.description")),1)]),e("label",Os,[e("div",Vs,[e("div",As,i(a(s)("settingsDialog.general.notificationSound.switchLabel")),1),e("p",Hs,i(a(s)("settingsDialog.general.notificationSound.switchHint")),1)]),I(e("input",{"onUpdate:modelValue":n[2]||(n[2]=r=>h.notificationSoundEnabled=r),type:"checkbox",class:"h-4 w-4 shrink-0",onChange:n[3]||(n[3]=r=>a(ee)(a(ke).NOTIFICATION_SOUND_ENABLED,h.notificationSoundEnabled))},null,544),[[ot,h.notificationSoundEnabled]])])]),e("section",qs,[e("div",null,[e("div",Ks,i(a(s)("locale.title")),1),e("p",Ws,i(a(s)("locale.description")),1)]),e("label",zs,[e("span",Js,i(a(s)("locale.field")),1),U(Gt,{"model-value":a(R),options:Rt.value,"get-option-value":r=>r.value,"onUpdate:modelValue":Vt},{trigger:be(({selectedOption:r})=>[e("div",Gs,i((r==null?void 0:r.label)||a(s)("common.select")),1)]),option:be(({option:r,selected:fe,select:Ht})=>[e("button",{type:"button",class:"workbench-select-option theme-filter-idle w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm",onClick:fo=>Ht()},[e("div",Qs,[e("div",Xs,[e("div",Zs,i(r.label),1),e("div",en,i(r.englishLabel),1)]),fe?(l(),c("span",tn,i(a(s)("common.enabled")),1)):v("",!0)])],8,Ys)]),_:1},8,["model-value","options","get-option-value"])]),e("p",sn,i(a(s)("locale.immediateHint")),1)]),e("section",nn,[e("div",null,[e("div",an,i(a(s)("settingsDialog.general.remoteCommandSecurityTitle")),1),e("p",on,i(a(s)("settingsDialog.general.remoteCommandSecurityDescription")),1)]),e("div",ln,[e("span",rn,i(a(s)("settingsDialog.general.remoteCommandSecurityModeField")),1),e("div",cn,[e("label",{class:Y(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="disabled"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",dn,[e("div",un,i(a(s)("settingsDialog.general.remoteCommandSecurityModeDisabled")),1),e("p",mn,i(a(s)("settingsDialog.general.remoteCommandSecurityModeDisabledDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="disabled",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[4]||(n[4]=r=>Ee("disabled"))},null,40,gn)],2),e("label",{class:Y(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="relay"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",hn,[e("div",vn,i(a(s)("settingsDialog.general.remoteCommandSecurityModeRelay")),1),e("p",xn,i(a(s)("settingsDialog.general.remoteCommandSecurityModeRelayDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="relay",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[5]||(n[5]=r=>Ee("relay"))},null,40,yn)],2),e("label",{class:Y(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="trusted-proxy"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",pn,[e("div",_n,i(a(s)("settingsDialog.general.remoteCommandSecurityModeTrustedProxy")),1),e("p",fn,i(a(s)("settingsDialog.general.remoteCommandSecurityModeTrustedProxyDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="trusted-proxy",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[6]||(n[6]=r=>Ee("trusted-proxy"))},null,40,bn)],2)])]),h.remoteCommandSecurityMode==="trusted-proxy"?(l(),c("label",Dn,[e("span",Cn,i(a(s)("settingsDialog.general.trustedProxyTokenField")),1),I(e("input",{"onUpdate:modelValue":n[7]||(n[7]=r=>h.trustedProxyToken=r),type:"password",class:"tool-input",placeholder:he.value?a(s)("settingsDialog.general.trustedProxyTokenReplacePlaceholder"):a(s)("settingsDialog.general.trustedProxyTokenPlaceholder")},null,8,kn),[[De,h.trustedProxyToken]]),he.value?(l(),c("p",wn,i(a(s)("settingsDialog.general.trustedProxyTokenConfiguredHint")),1)):v("",!0),e("p",Sn,i(he.value?a(s)("settingsDialog.general.trustedProxyTokenReplaceHint"):a(s)("settingsDialog.general.trustedProxyTokenHint")),1)])):v("",!0),e("div",Tn,[e("p",Rn,i(a(s)("settingsDialog.general.remoteCommandSecurityWarning")),1)]),e("div",Pn,[e("div",En,[e("button",{type:"button",class:Y(["tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",W.value?"tool-button-accent-subtle":"tool-button-primary"]),disabled:se.value,onClick:Ut},[se.value?(l(),T(a(ue),{key:0,class:"h-4 w-4 animate-spin"})):W.value?(l(),T(a(gt),{key:1,class:"h-4 w-4"})):v("",!0),e("span",null,i(se.value?a(s)("common.saving"):W.value?a(s)("settingsDialog.general.remoteCommandSecuritySaved"):a(s)("settingsDialog.general.remoteCommandSecuritySave")),1)],10,Mn)])])])])):S.value==="theme"?(l(),c("section",Bn,[e("div",null,[e("div",Nn,i(a(s)("theme.title")),1),e("p",$n,i(a(s)("theme.sectionDescription")),1)]),e("section",Un,[U(ks)])])):S.value==="relay"?(l(),c("section",In,[e("div",Fn,[e("div",null,[e("div",jn,[U(a(rt),{class:"h-4 w-4"}),e("span",null,i(a(s)("settingsDialog.relay.title")),1)])]),e("span",{class:Y(["rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium",ft.value])},i(_t.value),3)]),e("section",Ln,[e("label",On,[e("div",null,[e("div",Vn,i(a(s)("settingsDialog.relay.enableTitle")),1),e("p",An,i(a(s)("settingsDialog.relay.enableDescription")),1)]),I(e("input",{"onUpdate:modelValue":n[8]||(n[8]=r=>d.enabled=r),type:"checkbox",class:"h-4 w-4",disabled:f.value,onChange:jt},null,40,Hn),[[ot,d.enabled]])]),e("div",qn,[e("label",Kn,[e("span",Wn,i(a(s)("settingsDialog.relay.relayUrl")),1),I(e("input",{"onUpdate:modelValue":n[9]||(n[9]=r=>d.relayUrl=r),type:"text",placeholder:"https://user1.promptx.example.com",class:"tool-input",disabled:f.value},null,8,zn),[[De,d.relayUrl]])]),e("label",Jn,[e("span",Gn,i(a(s)("settingsDialog.relay.deviceId")),1),I(e("input",{"onUpdate:modelValue":n[10]||(n[10]=r=>d.deviceId=r),type:"text",placeholder:"my-macbook",class:"tool-input",disabled:f.value},null,8,Yn),[[De,d.deviceId]])]),e("label",Qn,[e("span",Xn,i(a(s)("settingsDialog.relay.deviceToken")),1),e("div",Zn,[I(e("input",{"onUpdate:modelValue":n[11]||(n[11]=r=>d.deviceToken=r),type:ve.value?"text":"password",placeholder:a(s)("settingsDialog.relay.deviceTokenPlaceholder"),class:"tool-input pr-10",disabled:f.value},null,8,ei),[[zt,d.deviceToken]]),e("button",{type:"button",class:"theme-icon-button absolute inset-y-1 right-1 flex h-auto w-8 items-center justify-center",disabled:f.value,onClick:n[12]||(n[12]=r=>ve.value=!ve.value)},[ve.value?(l(),T(a(ss),{key:1,class:"h-4 w-4"})):(l(),T(a(ts),{key:0,class:"h-4 w-4"}))],8,ti)])])]),e("div",si,[e("div",ni,[(o=u.value)!=null&&o.reconnectPausedReason?(l(),c("p",ii,i(a(s)("settingsDialog.relay.pausedReconnect",{reason:_e(u.value.reconnectPausedReasonCode,u.value.reconnectPausedReason)})),1)):v("",!0),f.value?(l(),c("p",ai,i(a(s)("settingsDialog.relay.managedByEnv")),1)):v("",!0),_.value?(l(),c("p",oi,i(_.value),1)):k.value?(l(),c("p",li,i(k.value),1)):(g=u.value)!=null&&g.lastError?(l(),c("p",ri,i(a(s)("settingsDialog.relay.lastError",{value:pt(u.value)})),1)):(D=u.value)!=null&&D.lastCloseReason?(l(),c("p",ci,i(a(s)("settingsDialog.relay.lastClosed",{reason:_e(u.value.lastCloseReasonCode,u.value.lastCloseReason),code:u.value.lastCloseCode})),1)):(B=u.value)!=null&&B.lastConnectedAt?(l(),c("p",di,i(a(s)("settingsDialog.relay.lastConnected",{value:le(u.value.lastConnectedAt)})),1)):v("",!0),($=(N=u.value)==null?void 0:N.recentEvents)!=null&&$.length?(l(),c("p",ui,i(a(s)("settingsDialog.relay.recentEvent",{value:yt(u.value.recentEvents[0])})),1)):v("",!0),xe.value?(l(),c("p",mi,i(a(s)("settingsDialog.relay.copied")),1)):v("",!0),Dt.value?(l(),c("p",gi,i(a(s)("settingsDialog.relay.defaultHint")),1)):v("",!0)]),e("div",hi,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||L.value||ie.value||E.value||!(((ce=u.value)==null?void 0:ce.enabled)??d.enabled),onClick:Nt},[E.value?(l(),T(a(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,i(E.value?a(s)("settingsDialog.relay.reconnecting"):a(s)("settingsDialog.relay.reconnectNow")),1)],8,vi),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||E.value,onClick:Lt},[e("span",null,i(xe.value?a(s)("settingsDialog.relay.diagnosticsCopied"):a(s)("settingsDialog.relay.copyDiagnostics")),1)],8,xi),e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||L.value||ie.value||E.value||f.value,onClick:Bt},[L.value?(l(),T(a(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,i(L.value?a(s)("common.saving"):a(s)("settingsDialog.relay.saveConfig")),1)],8,yi)])])])])):S.value==="system"?(l(),c("section",pi,[e("div",null,[e("div",_i,[U(a(ct),{class:"h-4 w-4"}),e("span",null,i(a(s)("settingsDialog.system.title")),1)]),e("p",fi,i(a(s)("settingsDialog.system.intro")),1)]),e("section",bi,[e("label",Di,[e("span",Ci,i(a(s)("settingsDialog.system.maxConcurrentRuns")),1),I(e("input",{"onUpdate:modelValue":n[13]||(n[13]=r=>G.runnerMaxConcurrentRuns=r),type:"number",min:"1",max:"16",step:"1",class:"tool-input",disabled:J.runnerMaxConcurrentRuns||ge.value||K.value},null,8,ki),[[De,G.runnerMaxConcurrentRuns,void 0,{number:!0}]]),e("p",wi,i(a(s)("settingsDialog.system.maxConcurrentRunsHint")),1)]),e("div",Si,[e("div",Ti,[J.runnerMaxConcurrentRuns?(l(),c("p",Ri,i(a(s)("settingsDialog.system.managedByEnv")),1)):M.value?(l(),c("p",Pi,i(M.value),1)):te.value?(l(),c("p",Ei,i(te.value),1)):(l(),c("p",Mi,i(a(s)("settingsDialog.system.diagnosticsHint")),1))]),e("div",Bi,[e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:J.runnerMaxConcurrentRuns||ge.value||K.value,onClick:$t},[K.value?(l(),T(a(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,i(K.value?a(s)("common.saving"):a(s)("settingsDialog.system.saveConfig")),1)],8,Ni)])])]),e("section",$i,[e("div",Ui,[e("div",null,[e("div",Ii,i(a(s)("settingsDialog.system.runtimeDiagnostics")),1),e("p",Fi,i(a(s)("settingsDialog.system.runtimeDiagnosticsHint")),1)]),e("div",ji,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:z.value,onClick:re},[z.value?(l(),T(a(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,i(z.value?a(s)("settingsDialog.system.refreshingDiagnostics"):a(s)("settingsDialog.system.refreshDiagnostics")),1)],8,Li),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",onClick:Ot},[e("span",null,i(ye.value?a(s)("settingsDialog.system.diagnosticsCopied"):a(s)("settingsDialog.system.copyDiagnostics")),1)])])]),e("div",Oi,[ne.value?(l(),c("p",Vi,i(ne.value),1)):ye.value?(l(),c("p",Ai,i(a(s)("settingsDialog.system.diagnosticsCopiedHint")),1)):(l(),c("p",Hi,i(a(s)("settingsDialog.system.diagnosticsHint")),1))]),oe.value?(l(),c("div",qi,[e("div",Ki,[n[15]||(n[15]=e("div",{class:"theme-muted-text text-xs"},"active",-1)),e("div",Wi,i(((de=A.value)==null?void 0:de.activeRunCount)||0),1),e("p",zi,i(a(s)("settingsDialog.system.active")),1)]),e("div",Ji,[n[16]||(n[16]=e("div",{class:"theme-muted-text text-xs"},"tracked",-1)),e("div",Gi,i(((Fe=A.value)==null?void 0:Fe.trackedRunCount)||0),1),e("p",Yi,i(a(s)("settingsDialog.system.tracked")),1)]),e("div",Qi,[n[17]||(n[17]=e("div",{class:"theme-muted-text text-xs"},"queued",-1)),e("div",Xi,i(((je=A.value)==null?void 0:je.queuedRunCount)||0),1),e("p",Zi,i(a(s)("settingsDialog.system.queued")),1)]),e("div",ea,[n[18]||(n[18]=e("div",{class:"theme-muted-text text-xs"},"maxConcurrent",-1)),e("div",ta,i(((Oe=(Le=A.value)==null?void 0:Le.config)==null?void 0:Oe.maxConcurrentRuns)||G.runnerMaxConcurrentRuns),1),e("p",sa,i(a(s)("settingsDialog.system.maxConcurrent")),1)])])):v("",!0),oe.value?(l(),c("div",na,[e("div",ia,[n[19]||(n[19]=e("div",{class:"theme-muted-text text-xs"},"completed",-1)),e("div",aa,i(((Ve=p.value)==null?void 0:Ve.totalCompleted)||0),1),e("p",oa,i(a(s)("settingsDialog.system.completed")),1)]),e("div",la,[n[20]||(n[20]=e("div",{class:"theme-muted-text text-xs"},"stopped",-1)),e("div",ra,i(((Ae=p.value)==null?void 0:Ae.totalStopped)||0),1),e("p",ca,i(a(s)("settingsDialog.system.stopped")),1)]),e("div",da,[n[21]||(n[21]=e("div",{class:"theme-muted-text text-xs"},"error",-1)),e("div",ua,i(((He=p.value)==null?void 0:He.totalErrored)||0),1),e("p",ma,i(a(s)("settingsDialog.system.error")),1)]),e("div",ga,[n[22]||(n[22]=e("div",{class:"theme-muted-text text-xs"},"stop_timeout",-1)),e("div",ha,i(((qe=p.value)==null?void 0:qe.totalStopTimeout)||0),1),e("p",va,i(a(s)("settingsDialog.system.stopTimeout")),1)])])):v("",!0),oe.value?(l(),c("div",xa,[e("div",ya,[n[23]||(n[23]=e("div",{class:"theme-muted-text text-xs"},"event flush failures",-1)),e("div",pa,i(((Ke=p.value)==null?void 0:Ke.eventFlushFailureCount)||0),1),e("p",_a,i(a(s)("settingsDialog.system.eventWriteFailures")),1)]),e("div",fa,[n[24]||(n[24]=e("div",{class:"theme-muted-text text-xs"},"recovered runs",-1)),e("div",ba,i(((ze=(We=Be.value)==null?void 0:We.metrics)==null?void 0:ze.totalRecovered)||0),1),e("p",Da,i(a(s)("settingsDialog.system.recoveredRuns")),1)]),e("div",Ca,[n[25]||(n[25]=e("div",{class:"theme-muted-text text-xs"},"last cleanup",-1)),e("div",ka,i(le((Ge=(Je=Ne.value)==null?void 0:Je.lastCleanup)==null?void 0:Ge.finishedAt)),1),e("p",wa,i(a(s)("settingsDialog.system.lastMaintenanceAt")),1)])])):v("",!0),e("div",Sa,[e("div",Ta,[e("div",Ra,i(a(s)("settingsDialog.system.baseStatus")),1),e("div",Pa,[e("div",Ea,[n[26]||(n[26]=e("span",{class:"theme-muted-text"},"runner baseUrl",-1)),e("span",Ma,i(((Qe=(Ye=w.value)==null?void 0:Ye.runner)==null?void 0:Qe.baseUrl)||"-"),1)]),e("div",Ba,[n[27]||(n[27]=e("span",{class:"theme-muted-text"},"runner startedAt",-1)),e("span",Na,i(le((Xe=A.value)==null?void 0:Xe.startedAt)),1)]),e("div",$a,[n[28]||(n[28]=e("span",{class:"theme-muted-text"},"last sweep",-1)),e("span",Ua,i(le((et=(Ze=Be.value)==null?void 0:Ze.metrics)==null?void 0:et.lastSweepFinishedAt)),1)]),e("div",Ia,[n[29]||(n[29]=e("span",{class:"theme-muted-text"},"git diff worker",-1)),e("span",Fa,i(kt.value?a(s)("settingsDialog.system.available"):a(s)("settingsDialog.system.unknown")),1)]),e("div",ja,[n[30]||(n[30]=e("span",{class:"theme-muted-text"},"db vacuum",-1)),e("span",La,i(le((tt=Ne.value)==null?void 0:tt.lastVacuumAt)),1)])])]),e("div",Oa,[e("div",Va,i(a(s)("settingsDialog.system.stopReasonTitle")),1),e("div",Aa,[(l(!0),c(H,null,q(St.value,r=>(l(),c("div",{key:r.key,class:"flex items-center justify-between gap-3"},[e("span",Ha,i(r.label),1),e("span",qa,i(r.value),1)]))),128))])])]),oe.value?(l(),c("div",Ka,[e("div",Wa,i(a(s)("settingsDialog.system.stopTimeoutPhaseTitle")),1),e("div",za,[(l(!0),c(H,null,q(Tt.value,r=>(l(),c("div",{key:r.key,class:"flex items-center justify-between gap-3 rounded-sm border border-dashed border-[var(--theme-borderMuted)] px-2.5 py-2"},[e("span",Ja,i(r.label),1),e("span",Ga,i(r.value),1)]))),128))])])):v("",!0),!oe.value&&!z.value?(l(),c("div",Ya,[e("div",Qa,i(a(s)("settingsDialog.system.runnerUnavailable")),1),e("p",Xa,i(xt((st=w.value)==null?void 0:st.runner,"settingsDialog.system.runnerUnavailableDescription")),1),e("p",Za," baseUrl: "+i(((it=(nt=w.value)==null?void 0:nt.runner)==null?void 0:it.baseUrl)||"-"),1)])):v("",!0)])])):S.value==="shortcuts"?(l(),c("section",eo,[e("div",null,[e("div",to,[U(a(we),{class:"h-4 w-4"}),e("span",null,i(a(s)("settingsDialog.shortcuts.title")),1)]),e("p",so,i(a(s)("settingsDialog.shortcuts.intro")),1)]),e("section",no,[(l(!0),c(H,null,q(bt.value,r=>(l(),c("div",{key:r.id,class:"settings-form-card flex flex-col justify-between gap-3 px-3 py-3 sm:flex-row sm:items-center"},[e("div",io,[e("div",ao,i(r.label),1),e("p",oo,i(r.description),1)]),e("div",lo,[e("span",ro,i(r.mac),1),e("span",co,i(r.windows),1)])]))),128)),e("p",uo,i(a(s)("settingsDialog.shortcuts.note")),1)])])):(l(),c("section",mo,[e("div",null,[e("div",go,i(a(s)("settingsDialog.about.title")),1),e("p",ho,i(a(s)("settingsDialog.about.intro")),1)]),e("section",vo,[e("div",xo,[e("div",null,[e("div",yo,i(a(s)("settingsDialog.about.versionTitle")),1),e("p",po,i(j.value||a(s)("settingsDialog.about.versionDescription")),1)]),e("span",_o,i(b.value?a(s)("common.loading"):y.value?`v${y.value}`:a(s)("common.unavailable")),1)])])]))])]}),_:1},8,["open"]))}};export{Ro as default};