@muyichengshayu/promptx 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/apps/runner/src/engines/index.js +13 -3
  3. package/apps/runner/src/engines/shellRunner.js +216 -0
  4. package/apps/runner/src/runManager.js +68 -9
  5. package/apps/server/src/agents/index.js +18 -3
  6. package/apps/server/src/codexRuns.js +24 -7
  7. package/apps/server/src/db.js +2 -0
  8. package/apps/server/src/gitDiff.js +279 -17
  9. package/apps/server/src/internalRoutes.js +8 -1
  10. package/apps/server/src/relayClient.js +5 -1
  11. package/apps/server/src/relayConfig.js +10 -0
  12. package/apps/server/src/runDispatchService.js +44 -13
  13. package/apps/server/src/runEventIngest.js +6 -4
  14. package/apps/server/src/taskRoutes.js +72 -0
  15. package/apps/web/dist/assets/{CodexSessionManagerDialog-BbaObUl_.js → CodexSessionManagerDialog-CELTkz9T.js} +1 -1
  16. package/apps/web/dist/assets/{TaskDiffReviewDialog-ClUn4Ni4.js → TaskDiffReviewDialog-VwZmo00b.js} +1 -1
  17. package/apps/web/dist/assets/WorkbenchSettingsDialog-CThWkZHd.js +1 -0
  18. package/apps/web/dist/assets/WorkbenchView-D6auwJnA.js +60 -0
  19. package/apps/web/dist/assets/index-8vfFmsVl.js +2 -0
  20. package/apps/web/dist/assets/{index-CTHBQ5Ng.css → index-BPfQQtEB.css} +1 -1
  21. package/apps/web/dist/index.html +2 -2
  22. package/package.json +1 -1
  23. package/packages/shared/src/index.js +6 -0
  24. package/packages/shared/src/shellCommands.js +81 -0
  25. package/packages/shared/src/shellCommands.test.js +45 -0
  26. package/apps/web/dist/assets/WorkbenchSettingsDialog-C74C5fs1.js +0 -1
  27. package/apps/web/dist/assets/WorkbenchView-BgfyrrvY.js +0 -57
  28. package/apps/web/dist/assets/index-BIa_ZvMq.js +0 -2
@@ -1,57 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-theme-github-dark-default-DBX58552.js","assets/vendor-shiki-core-1BqeTDsZ.js","assets/vendor-misc-u-M8sNMf.js","assets/vendor-misc-ClI1dyrl.css","assets/vendor-shiki-theme-github-light-RLAvZv0q.js","assets/vendor-shiki-lang-bash-zsQu0xn-.js","assets/vendor-shiki-lang-c-BDF8vgks.js","assets/vendor-shiki-lang-cpp-DyDAaXl6.js","assets/vendor-shiki-lang-csharp-BWfTXJXw.js","assets/vendor-shiki-lang-css-DbAm1fUO.js","assets/vendor-shiki-lang-diff-DmGC1G26.js","assets/vendor-shiki-lang-dockerfile-3x-8396r.js","assets/vendor-shiki-lang-dotenv--IVOlX2Q.js","assets/vendor-shiki-lang-fish-Bpv3hhJP.js","assets/vendor-shiki-lang-go-CIGC59jP.js","assets/vendor-shiki-lang-html-Bt_TLLZN.js","assets/vendor-shiki-lang-ini-BIllfys4.js","assets/vendor-shiki-lang-java-CXxu9crF.js","assets/vendor-shiki-lang-javascript-Cha7GNZm.js","assets/vendor-shiki-lang-json-CCZCjDUh.js","assets/vendor-shiki-lang-less-DAToytC5.js","assets/vendor-shiki-lang-markdown-C6lwMXFp.js","assets/vendor-shiki-lang-python-Bi9rmtY7.js","assets/vendor-shiki-lang-powershell-lrpuM0ez.js","assets/vendor-shiki-lang-rust-GTGDbY6A.js","assets/vendor-shiki-lang-sass-DFtHupN8.js","assets/vendor-shiki-lang-scss-BrfBNyyi.js","assets/vendor-shiki-lang-sql-H6--iFN-.js","assets/vendor-shiki-lang-toml-aTteTWYL.js","assets/vendor-shiki-lang-tsx-DoKZm6AV.js","assets/vendor-shiki-lang-typescript-B5awnqri.js","assets/vendor-shiki-lang-vue-CnrgQ7Z5.js","assets/vendor-shiki-lang-xml-Bv-TNPJt.js","assets/vendor-shiki-lang-yaml-DpxUxQ6M.js","assets/CodexSessionManagerDialog-BbaObUl_.js","assets/index-BIa_ZvMq.js","assets/vendor-router-Dn8q3tJM.js","assets/index-CTHBQ5Ng.css","assets/vendor-ui-BwEQCho1.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-ClUn4Ni4.js","assets/TaskDiffReviewDialog-CeGj0idf.css","assets/WorkbenchSettingsDialog-C74C5fs1.js"])))=>i.map(i=>d[i]);
2
- import{u as vt,t as We,f as Sa,_ as Ue,a as wa,b as xa,g as Ns,s as yr,c as Sr}from"./index-BIa_ZvMq.js";import{w as Te,ak as $t,aD as g,aI as ke,aG as ie,aJ as Ge,aE as b,aK as Xe,aL as ve,aF as i,aM as Jt,u as r,aN as fe,aO as ba,aP as os,c as G,aQ as w,aR as Ze,aS as it,aT as cn,o as dn,aU as Kt,aV as kn,b as K,n as st,aW as qt,aX as Xn,aY as Oo,r as as,aC as wr,aZ as rn,f as xr,a_ as co,a$ as As,G as br,al as kr,b0 as gn,b1 as hn}from"./vendor-misc-u-M8sNMf.js";import{X as ka,T as _r,L as Vt,C as bo,a as $s,B as jo,S as Tr,P as Zn,b as _a,c as Cr,A as Er,F as Dn,d as Sn,e as Ta,f as Ar,E as $r,g as Ir,h as Fo,i as ko,j as Is,k as Pr,l as Dr,m as Lr,U as Mr,W as Br,n as Ca,o as Rr,p as Ps,q as Os,I as Ea,r as Nr,s as Or,t as jr,u as Fr,G as Ur,v as Vr,w as zr,x as Hr,y as qr}from"./vendor-ui-BwEQCho1.js";import{M as Aa}from"./vendor-markdown-9aQhqbjm.js";import{n as _o,N as $a,a as To,i as Kr,V as Gs,b as Uo,u as Wr,c as Gr,E as Xr}from"./vendor-tiptap-rwYdQb1L.js";const Zt={NONE:"none",LATEST:"latest",ALL:"all"};function Yr(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===Zt.ALL?Zt.ALL:n===Zt.LATEST?Zt.LATEST:n===Zt.NONE?Zt.NONE:t.includeEvents?Zt.ALL:t.includeLatestEvents?Zt.LATEST:Zt.NONE}const Nt={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function Ia(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?Nt.AGENT_EVENT:t}const gt={THREAD_STARTED:"thread.started",TURN_STARTED:"turn.started",TURN_COMPLETED:"turn.completed",TURN_FAILED:"turn.failed",ERROR:"error",ITEM_STARTED:"item.started",ITEM_UPDATED:"item.updated",ITEM_COMPLETED:"item.completed"},nt={REASONING:"reasoning",WEB_SEARCH:"web_search",COLLAB_TOOL_CALL:"collab_tool_call",FILE_CHANGE:"file_change",COMMAND_EXECUTION:"command_execution",TODO_LIST:"todo_list",AGENT_MESSAGE:"agent_message"},Jr={none:{label:"不过期",hours:null}};Object.entries(Jr).map(([e,t])=>({value:e,label:t.label}));const Ss={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode"},Co=[{value:Ss.CODEX,label:"Codex",enabled:!0},{value:Ss.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:Ss.OPENCODE,label:"OpenCode",enabled:!0}],At={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},Qr=[{value:"local",label:"跟随本机时区"}],Zr={SKIP:"skip"},ei=[{value:Zr.SKIP,label:"已有运行时跳过本次"}],Xs={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},ti=[{value:Xs.DINGTALK,label:"钉钉 Webhook"},{value:Xs.FEISHU,label:"飞书 Webhook"},{value:Xs.WEBHOOK,label:"通用 Webhook"}],Ys={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},ni=[{value:Ys.COMPLETED,label:"本次运行结束后"},{value:Ys.SUCCESS,label:"本次运行成功后"},{value:Ys.ERROR,label:"本次运行失败后"}],si={SUMMARY:"summary"},oi=[{value:si.SUMMARY,label:"摘要消息"}],Vo={ZH_CN:"zh-CN",EN_US:"en-US"},ai=[{value:Vo.ZH_CN,label:"简体中文"},{value:Vo.EN_US,label:"English"}];function Eo(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Co.find(o=>o.value===t))==null?void 0:n.value)||Ss.CODEX}function lt(e){var t;return((t=Co.find(n=>n.value===Eo(e)))==null?void 0:t.label)||"Codex"}function ny(e=""){const t=String(e||"").trim();if(!t)return"";const n=/^[a-z]:[\\/]/i.test(t)||t.includes("\\");let o=t.replace(/\\/g,"/");return o.length>1&&!/^[a-z]:\/$/i.test(o)&&(o=o.replace(/\/+$/,"")),n?o.toLowerCase():o}function ri(e=[],t=10){const n=e.find(o=>{var s;return(o.type===At.TEXT||o.type===At.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const ii={class:"min-w-0 flex-1"},li={key:0,class:"flex items-center gap-2"},ui=["disabled"],js={__name:"DialogShell",props:{open:{type:Boolean,default:!1},backdropClass:{type:String,default:""},stackLevel:{type:Number,default:0},panelClass:{type:String,default:""},headerClass:{type:String,default:"px-4 py-4 sm:px-5"},bodyClass:{type:String,default:"min-h-0 flex-1"},showClose:{type:Boolean,default:!0},closeDisabled:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0},closeOnEscape:{type:Boolean,default:!0},lockBodyScroll:{type:Boolean,default:!0}},emits:["close"],setup(e,{emit:t}){const n=e,o=t,s=G(()=>n.backdropClass?n.backdropClass:`${n.stackLevel>=4?"z-[90]":n.stackLevel===3?"z-[75]":n.stackLevel===2?"z-[70]":n.stackLevel===1?"z-[60]":"z-50"} items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6`);function a(){n.closeDisabled||o("close")}function l(){!n.closeOnBackdrop||n.closeDisabled||o("close")}function d(h){!n.open||!n.closeOnEscape||n.closeDisabled||h.key==="Escape"&&o("close")}return Te(()=>n.open,h=>{if(n.lockBodyScroll&&document.body.classList.toggle("overflow-hidden",h),h&&n.closeOnEscape){window.addEventListener("keydown",d);return}window.removeEventListener("keydown",d)},{immediate:!0}),$t(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",d)}),(h,x)=>(g(),ke(os,{to:"body"},[ie(ba,{name:"dialog-shell"},{default:Ge(()=>[e.open?(g(),b("div",{key:0,class:ve(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:Xe(l,["self"])},[i("section",{class:ve(["panel dialog-shell-panel flex min-h-0 w-full flex-col overflow-hidden",e.panelClass])},[h.$slots.title||h.$slots.header||h.$slots["header-actions"]||e.showClose?(g(),b("div",{key:0,class:ve(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",ii,[Jt(h.$slots,"header",{},()=>[Jt(h.$slots,"title")])]),h.$slots["header-actions"]||e.showClose?(g(),b("div",li,[Jt(h.$slots,"header-actions"),e.showClose?(g(),b("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:a},[ie(r(ka),{class:"h-4 w-4"})],8,ui)):fe("",!0)])):fe("",!0)],2)):fe("",!0),i("div",{class:ve(e.bodyClass)},[Jt(h.$slots,"default")],2)],2)],2)):fe("",!0)]),_:3})]))}},ci={class:"flex items-start gap-3"},di={class:"theme-heading text-base font-semibold"},fi={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},pi={class:"flex justify-end gap-2 px-5 py-4"},mi=["disabled"],gi=["disabled"],ps={__name:"ConfirmDialog",props:{open:{type:Boolean,default:!1},title:{type:String,default:""},description:{type:String,default:""},confirmText:{type:String,default:""},cancelText:{type:String,default:""},loading:{type:Boolean,default:!1},danger:{type:Boolean,default:!1}},emits:["cancel","confirm"],setup(e,{emit:t}){const n=e,o=t,{t:s}=vt(),a=G(()=>n.title||s("common.confirm")),l=G(()=>n.confirmText||s("common.confirm")),d=G(()=>n.cancelText||s("common.cancel"));return(h,x)=>(g(),ke(js,{open:e.open,"stack-level":4,"panel-class":"max-w-md","header-class":"px-5 py-4","body-class":"flex flex-col","close-disabled":e.loading,"close-on-backdrop":!e.loading,"close-on-escape":!e.loading,onClose:x[2]||(x[2]=c=>o("cancel"))},{title:Ge(()=>[i("div",ci,[i("span",{class:ve(["inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border border-dashed",e.danger?"theme-status-danger":"theme-status-neutral"])},[ie(r(_r),{class:"h-4 w-4"})],2),i("div",null,[i("h2",di,w(a.value),1),e.description?(g(),b("p",fi,w(e.description),1)):fe("",!0)])])]),default:Ge(()=>[i("div",pi,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:x[0]||(x[0]=c=>o("cancel"))},w(d.value),9,mi),i("button",{type:"button",class:ve(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:x[1]||(x[1]=c=>o("confirm"))},w(e.loading?r(s)("common.processing"):l.value),11,gi)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},hi={class:"theme-divider settings-dialog-nav border-b px-3 py-3 sm:w-60 sm:shrink-0 sm:border-b-0 sm:border-r sm:px-4 sm:py-4"},vi={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},yi=["onClick"],Si={class:"min-w-0"},wi={class:"text-sm font-medium"},xi={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},bi={__name:"DialogSideNav",props:{modelValue:{type:String,default:""},sections:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;function o(s=""){n("update:modelValue",String(s||""))}return(s,a)=>(g(),b("aside",hi,[i("nav",vi,[(g(!0),b(Ze,null,it(e.sections,l=>(g(),b("button",{key:l.id,type:"button",class:ve(["settings-nav__item flex min-w-0 items-start gap-3 rounded-sm border px-3 py-3 text-left transition sm:w-full",e.modelValue===l.id?"theme-card-selected":"theme-card-idle-muted border-dashed hover:border-[var(--theme-borderStrong)] hover:bg-[var(--theme-appPanelStrong)]"]),onClick:d=>o(l.id)},[(g(),ke(cn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",Si,[i("div",wi,w(l.label),1),i("p",xi,w(l.description),1)])],10,yi))),128))])]))}},ki=["aria-label","disabled","onKeydown"],_i={class:"min-w-0 flex-1"},Ti={class:"theme-muted-text text-sm"},Ci={class:"flex min-h-0 w-full flex-col"},Ei={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},Ai=["onClick"],$i={class:"theme-empty-state px-3 py-4 text-sm"},en={__name:"WorkbenchSelect",props:{modelValue:{type:[String,Number],default:""},options:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:""},emptyText:{type:String,default:""},ariaLabel:{type:String,default:""},getOptionValue:{type:Function,default:e=>(e==null?void 0:e.id)??(e==null?void 0:e.value)??""},triggerClass:{type:String,default:""}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=e,o=t,{t:s}=vt(),a=K(null),l=K(null),d=K(!1),h=K(!1),x=K({}),c=G(()=>{const V=String(n.modelValue??"");return n.options.find(ne=>String(n.getOptionValue(ne)??"")===V)||null}),m=G(()=>n.placeholder||s("common.select")),f=G(()=>n.emptyText||s("common.noOptions"));function k(V){return V&&typeof V=="object"&&Object.prototype.hasOwnProperty.call(V,"label")?String(V.label||""):String(n.getOptionValue(V)??"")}function y(){n.disabled||(d.value||o("refresh-intent"),d.value=!0)}function L(){d.value=!1}function te(){if(d.value){L();return}y()}function S(V){o("update:modelValue",String(n.getOptionValue(V)??"").trim()),L()}function M(){if(!d.value||!a.value||typeof window>"u")return;const V=a.value.getBoundingClientRect(),ne=window.innerWidth,I=window.innerHeight,X=8,le=8,ce=160,D=360,Q=Math.max(0,I-V.bottom-le),re=Math.max(0,V.top-le);h.value=Q<260&&re>Q;const ae=h.value?re-X:Q-X,ge=Math.max(Math.min(D,Math.max(ae,0)),Math.min(ce,h.value?re:Q)),C=Math.min(V.width,ne-le*2),q=Math.min(Math.max(le,V.left),Math.max(le,ne-le-C));x.value={left:`${q}px`,top:h.value?`${V.top-X}px`:`${V.bottom+X}px`,width:`${C}px`,maxHeight:`${Math.max(ge,120)}px`,transform:h.value?"translateY(-100%)":"none"}}function N(V){var ne;!d.value||!a.value||a.value.contains(V.target)||(ne=l.value)!=null&&ne.contains(V.target)||L()}function H(V){V.key==="Escape"&&L()}return Te(()=>n.disabled,V=>{V&&L()}),Te(d,async V=>{V&&(await st(),M())}),dn(()=>{document.addEventListener("pointerdown",N),document.addEventListener("keydown",H),window.addEventListener("resize",M),window.addEventListener("scroll",M,!0)}),$t(()=>{document.removeEventListener("pointerdown",N),document.removeEventListener("keydown",H),window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}),(V,ne)=>(g(),b("div",{ref_key:"rootRef",ref:a,class:"relative min-w-0"},[i("button",{type:"button",class:ve(["workbench-select-trigger flex w-full items-center gap-3 rounded-sm border px-3 py-2 text-left transition focus:outline-none focus:ring-2",[n.triggerClass,e.disabled?"cursor-not-allowed border-[color-mix(in_srgb,var(--theme-borderDefault)_88%,var(--theme-textMuted))] bg-[color-mix(in_srgb,var(--theme-appPanelMuted)_82%,var(--theme-appBg))] text-[var(--theme-textMuted)]":"theme-input-shell text-[var(--theme-textPrimary)] hover:border-[var(--theme-borderStrong)] focus:border-[var(--theme-borderStrong)] focus:ring-[var(--theme-focusRing)]"]]),"aria-label":n.ariaLabel||void 0,disabled:e.disabled,onClick:te,onKeydown:[Kt(Xe(y,["prevent"]),["down"]),Kt(Xe(te,["prevent"]),["enter"]),Kt(Xe(te,["prevent"]),["space"])]},[i("div",_i,[Jt(V.$slots,"trigger",{selectedOption:c.value,open:d.value,loading:e.loading,disabled:e.disabled},()=>[i("div",Ti,w(c.value?k(c.value):m.value),1)])]),i("div",{class:ve(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(g(),ke(r(Vt),{key:0,class:"h-4 w-4 animate-spin"})):fe("",!0),ie(r(bo),{class:ve(["h-4 w-4 transition",d.value?"rotate-180":""])},null,8,["class"])],2)],42,ki),(g(),ke(os,{to:"body"},[d.value?(g(),b("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:kn(x.value)},[i("div",Ci,[Jt(V.$slots,"header",{loading:e.loading,options:e.options}),i("div",Ei,[e.options.length?(g(!0),b(Ze,{key:0},it(e.options,I=>Jt(V.$slots,"option",{key:String(e.getOptionValue(I)??""),option:I,selected:String(e.getOptionValue(I)??"")===String(e.modelValue??""),select:()=>S(I)},()=>[i("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:X=>S(I)},w(k(I)),9,Ai)])),128)):Jt(V.$slots,"empty",{key:1},()=>[i("div",$i,w(f.value),1)])])])],4)):fe("",!0)]))],512))}},zo={},Pa=typeof import.meta<"u"&&zo?zo:{};function Ii(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(Pa.VITE_API_PORT||"").trim();if(t)return e.port=t,e.toString().replace(/\/$/,"");const n=String(e.port||"");return new Set(["4173","5173","5174"]).has(n)?(e.port="3000",e.toString().replace(/\/$/,"")):e.toString().replace(/\/$/,"")}const Ao=(Pa.VITE_API_BASE_URL||Ii()).replace(/\/$/,"");function $o(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=We(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||We(t)}async function Ye(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Ao}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const a=await o.json().catch(()=>({}));throw new Error($o(a))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Io(){return Ao}function ws(e){return e?e.startsWith("http")?e:`${Ao}${e}`:""}function sy(){return Ye("/api/meta",{cache:"no-store"})}function Pi(){return Ye("/api/tasks")}function Di(e=30){const t=new URLSearchParams,n=Math.max(1,Number(e)||30);return t.set("limit",String(n)),Ye(`/api/tasks/workspace-diff-summaries?${t.toString()}`,{cache:"no-store"})}function Li(e){return Ye("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function Mi(e=[]){return Ye("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function Da(e){return Ye(`/api/tasks/${e}`)}function La(e,t){return Ye(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function Bi(e){return Ye(`/api/tasks/${e}`,{method:"DELETE"})}const Ma=Io();async function Ri(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Ma}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error($o(o,"errors.uploadFailed"))}return n.json()}async function Ni(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Ma}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error($o(o,"errors.pdfImportFailed"))}return n.json()}function Oi(){return Ye("/api/codex/sessions")}function ji(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return Ye(`/api/codex/workspaces${o?`?${o}`:""}`)}function oy(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim(),o=String(e.cwd||"").trim(),s=Number(e.limit||0);n&&t.set("engine",n),o&&t.set("cwd",o),Number.isFinite(s)&&s>0&&t.set("limit",String(s));const a=t.toString();return Ye(`/api/codex/session-candidates${a?`?${a}`:""}`,{cache:"no-store",signal:e.signal})}function ay(e={}){const t=new URLSearchParams,n=String(e.path||"").trim(),o=Number(e.limit||0);n&&t.set("path",n),Number.isFinite(o)&&o>0&&t.set("limit",String(o));const s=t.toString();return Ye(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function ry(e,t={}){const n=new URLSearchParams,o=String(e||"").trim(),s=String(t.path||"").trim(),a=Number(t.limit||0);o&&n.set("q",o),s&&n.set("path",s),Number.isFinite(a)&&a>0&&n.set("limit",String(a));const l=n.toString();return Ye(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function Fi(e){return Ye("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function Ui(e,t){return Ye(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function Vi(e){return Ye(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function zi(e){return Ye(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function Hi(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=String(t.refreshToken||"").trim();o&&n.set("path",o),s&&n.set("_",s);const a=n.toString();return Ye(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${a?`?${a}`:""}`,{cache:"no-store",signal:t.signal})}function qi(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),a=Number(n.limit||60),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(a)&&a>0&&o.set("limit",String(a)),l&&o.set("_",l);const d=o.toString();return Ye(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${d?`?${d}`:""}`,{cache:"no-store",signal:n.signal})}function Ki(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=Number(t.limit||0),a=String(t.refreshToken||"").trim();o&&n.set("path",o),Number.isFinite(s)&&s>0&&n.set("limit",String(s)),a&&n.set("_",a);const l=n.toString();return Ye(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function Wi(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),a=Number(n.limit||80),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(a)&&a>0&&o.set("limit",String(a)),l&&o.set("_",l);const d=o.toString();return Ye(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${d?`?${d}`:""}`,{cache:"no-store",signal:n.signal})}function Gi(e,t){return Ye(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function Xi(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=Yr(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const a=n.toString();return Ye(`/api/tasks/${encodeURIComponent(e)}/codex-runs${a?`?${a}`:""}`,{cache:"no-store"})}function Yi(e,t={}){const n=new URLSearchParams,o=Math.max(0,Number(t.afterSeq)||0),s=Math.max(1,Number(t.limit)||5e3);o>0&&n.set("afterSeq",String(o)),s>0&&n.set("limit",String(s));const a=n.toString();return Ye(`/api/codex/runs/${encodeURIComponent(e)}/events${a?`?${a}`:""}`,{cache:"no-store"})}function iy(e,t={}){const n=new URLSearchParams,o=String(t.scope||"workspace").trim(),s=String(t.runId||"").trim(),a=String(t.filePath||"").trim(),l=t.includeFiles!==!1,d=t.includeStats!==!1;o==="run"?n.set("scope","run"):o==="task"?n.set("scope","task"):n.set("scope","workspace"),s&&n.set("runId",s),a&&n.set("filePath",a),l||n.set("includeFiles","false"),d||n.set("includeStats","false");const h=n.toString();return Ye(`/api/tasks/${encodeURIComponent(e)}/git-diff${h?`?${h}`:""}`,{cache:"no-store"})}function Ji(e,t){return Ye(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function Qi(e){return Ye(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function Zi(e){return Ye(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const el={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},tl={class:"theme-muted-text mt-1 text-xs"},nl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},sl={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},ol={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},al={key:1,class:"space-y-4"},rl={key:0,class:"space-y-4"},il={class:"theme-heading text-base font-medium"},ll={class:"theme-muted-text mt-1 text-xs leading-5"},ul={class:"settings-section-card px-4 py-4"},cl={class:"block space-y-1.5"},dl={class:"theme-muted-text text-xs"},fl=["placeholder"],pl={key:1,class:"space-y-4"},ml={class:"flex items-start justify-between gap-3"},gl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},hl={class:"theme-muted-text mt-1 text-xs leading-5"},vl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},yl={class:"settings-section-card px-4 py-4"},Sl={class:"grid gap-4 sm:grid-cols-2"},wl={class:"space-y-1.5 sm:col-span-2"},xl={class:"theme-muted-text text-xs"},bl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},kl={class:"space-y-1.5"},_l={class:"theme-muted-text text-xs"},Tl=["disabled"],Cl={key:0,class:"space-y-1.5"},El={class:"theme-muted-text text-xs"},Al={class:"truncate text-sm text-[var(--theme-textPrimary)]"},$l={class:"space-y-1.5"},Il={class:"theme-muted-text text-xs"},Pl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Dl={class:"theme-muted-text text-xs"},Ll={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Ml={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Bl={key:2,class:"space-y-4"},Rl={class:"flex items-start justify-between gap-3"},Nl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ol={class:"theme-muted-text mt-1 text-xs leading-5"},jl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Fl={class:"settings-section-card px-4 py-4"},Ul={class:"grid gap-4 sm:grid-cols-2"},Vl={class:"space-y-1.5"},zl={class:"theme-muted-text text-xs"},Hl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},ql={class:"space-y-1.5"},Kl={class:"theme-muted-text text-xs"},Wl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Gl={class:"space-y-1.5 sm:col-span-2"},Xl={class:"theme-muted-text text-xs"},Yl=["placeholder","disabled"],Jl={class:"space-y-1.5"},Ql={class:"theme-muted-text text-xs"},Zl=["placeholder","disabled"],eu={class:"space-y-1.5"},tu={class:"theme-muted-text text-xs"},nu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},su={class:"space-y-1.5"},ou={class:"theme-muted-text text-xs"},au={class:"truncate text-sm text-[var(--theme-textPrimary)]"},ru={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},iu={key:0,class:"theme-danger-text"},lu={key:3,class:"theme-danger-text text-sm"},uu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},cu={class:"theme-muted-text theme-note-text"},du={class:"flex items-center justify-end gap-2"},fu=["disabled"],pu=["disabled"],mu="0 9 * * 1-5",Js="weekdays",Wn="09:00",An="1",gu={__name:"EditTaskDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""}},emits:["close","saved"],setup(e,{emit:t}){const n=e,o=t,{locale:s,t:a}=vt(),l=K(!1),d=K(!1),h=K(""),x=K("basic"),c=as({title:"",automationEnabled:!1,automationMode:Js,automationTime:Wn,automationWeekday:An,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),m=G(()=>String(n.taskTitle||"").trim()||a("workbench.untitledTask")),f=G(()=>[{id:"basic",label:a("taskDialog.sections.basic.label"),description:a("taskDialog.sections.basic.description"),icon:Zn},{id:"automation",label:a("taskDialog.sections.automation.label"),description:a("taskDialog.sections.automation.description"),icon:$s},{id:"notification",label:a("taskDialog.sections.notification.label"),description:a("taskDialog.sections.notification.description"),icon:jo}]),k=G(()=>[{value:"daily",label:a("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:a("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:a("taskDialog.sections.automation.modeWeekly")}]),y=G(()=>[{value:"1",label:a("taskDialog.sections.automation.weekday1")},{value:"2",label:a("taskDialog.sections.automation.weekday2")},{value:"3",label:a("taskDialog.sections.automation.weekday3")},{value:"4",label:a("taskDialog.sections.automation.weekday4")},{value:"5",label:a("taskDialog.sections.automation.weekday5")},{value:"6",label:a("taskDialog.sections.automation.weekday6")},{value:"0",label:a("taskDialog.sections.automation.weekday0")}]),L=G(()=>Qr.map(C=>({...C,label:C.value==="local"?a("taskDialog.sections.automation.timezoneLocal"):C.label}))),te=G(()=>ei.map(C=>({...C,label:C.value==="skip"?a("taskDialog.sections.automation.concurrencySkip"):C.label}))),S=G(()=>ti.map(C=>({...C,label:C.value==="dingtalk"?a("taskDialog.sections.notification.channelDingtalk"):C.value==="feishu"?a("taskDialog.sections.notification.channelFeishu"):C.value==="webhook"?a("taskDialog.sections.notification.channelWebhook"):C.label}))),M=G(()=>ni.map(C=>({...C,label:C.value==="completed"?a("taskDialog.sections.notification.triggerCompleted"):C.value==="success"?a("taskDialog.sections.notification.triggerSuccess"):C.value==="error"?a("taskDialog.sections.notification.triggerError"):C.label}))),N=G(()=>oi.map(C=>({...C,label:C.value==="summary"?a("taskDialog.sections.notification.messageSummary"):C.label}))),H=G(()=>ai.map(C=>({...C,label:C.value==="zh-CN"?a("taskDialog.sections.notification.localeZhCn"):C.value==="en-US"?a("taskDialog.sections.notification.localeEnUs"):C.label}))),V=G(()=>c.notificationEnabled?c.notificationLastStatus==="success"?a("taskDialog.sections.notification.statusSuccess"):c.notificationLastStatus==="error"?a("taskDialog.sections.notification.statusError"):a("taskDialog.sections.notification.statusPending"):a("taskDialog.sections.notification.statusDisabled"));function ne(){c.title="",c.automationEnabled=!1,c.automationMode=Js,c.automationTime=Wn,c.automationWeekday=An,c.automationTimezone="local",c.automationConcurrencyPolicy="skip",c.automationLastTriggeredAt="",c.automationNextTriggerAt="",c.notificationEnabled=!1,c.notificationChannelType="dingtalk",c.notificationWebhookUrl="",c.notificationSecret="",c.notificationTriggerOn="completed",c.notificationLocale=String(s.value||"zh-CN"),c.notificationMessageMode="summary",c.notificationLastStatus="",c.notificationLastError="",c.notificationLastSentAt=""}function I(C=0){return String(C).padStart(2,"0")}function X(C=""){const q=String(C||"").trim().replace(/\s+/g," ");let U=q.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return U?{mode:"weekdays",time:`${I(U[2])}:${I(U[1])}`,weekday:An}:(U=q.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),U?{mode:"daily",time:`${I(U[2])}:${I(U[1])}`,weekday:An}:(U=q.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),U?{mode:"weekly",time:`${I(U[2])}:${I(U[1])}`,weekday:String(U[3])}:{mode:Js,time:Wn,weekday:An}))}function le(C=""){const U=String(C||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!U)return Wn;const Ve=Number(U[1]),Ae=Number(U[2]);return!Number.isInteger(Ve)||!Number.isInteger(Ae)||Ve<0||Ve>23||Ae<0||Ae>59?Wn:`${I(Ve)}:${I(Ae)}`}function ce(){var Oe;const C=le(c.automationTime),[q,U]=C.split(":"),Ve=Number(q),Ae=Number(U);if(c.automationMode==="daily")return`${Ae} ${Ve} * * *`;if(c.automationMode==="weekly"){const Ne=((Oe=y.value.find(qe=>qe.value===String(c.automationWeekday||"")))==null?void 0:Oe.value)||An;return`${Ae} ${Ve} * * ${Ne}`}return`${Ae} ${Ve} * * 1-5`}function D(C={}){var U,Ve,Ae,Oe,Ne,qe,et,we,O,J,de,ye,pe,Ee,Ce,Pe;c.title=String(C.title||""),c.automationEnabled=!!((U=C.automation)!=null&&U.enabled);const q=X(((Ve=C.automation)==null?void 0:Ve.cron)||mu);c.automationMode=q.mode,c.automationTime=q.time,c.automationWeekday=q.weekday,c.automationTimezone=String(((Ae=C.automation)==null?void 0:Ae.timezone)||"local"),c.automationConcurrencyPolicy=String(((Oe=C.automation)==null?void 0:Oe.concurrencyPolicy)||"skip"),c.automationLastTriggeredAt=String(((Ne=C.automation)==null?void 0:Ne.lastTriggeredAt)||""),c.automationNextTriggerAt=String(((qe=C.automation)==null?void 0:qe.nextTriggerAt)||""),c.notificationEnabled=!!((et=C.notification)!=null&&et.enabled),c.notificationChannelType=String(((we=C.notification)==null?void 0:we.channelType)||"dingtalk"),c.notificationWebhookUrl=String(((O=C.notification)==null?void 0:O.webhookUrl)||""),c.notificationSecret=String(((J=C.notification)==null?void 0:J.secret)||""),c.notificationTriggerOn=String(((de=C.notification)==null?void 0:de.triggerOn)||"completed"),c.notificationLocale=String(((ye=C.notification)==null?void 0:ye.locale)||s.value||"zh-CN"),c.notificationMessageMode=String(((pe=C.notification)==null?void 0:pe.messageMode)||"summary"),c.notificationLastStatus=String(((Ee=C.notification)==null?void 0:Ee.lastStatus)||""),c.notificationLastError=String(((Ce=C.notification)==null?void 0:Ce.lastError)||""),c.notificationLastSentAt=String(((Pe=C.notification)==null?void 0:Pe.lastSentAt)||"")}async function Q(){const C=String(n.taskSlug||"").trim();if(!C){ne();return}l.value=!0,h.value="";try{const q=await Da(C);D(q)}catch(q){h.value=(q==null?void 0:q.message)||a("taskDialog.loadFailed")}finally{l.value=!1}}function re(){return{title:c.title,automation:{enabled:c.automationEnabled,cron:ce(),timezone:c.automationTimezone,concurrencyPolicy:c.automationConcurrencyPolicy},notification:{enabled:c.notificationEnabled,channelType:c.notificationChannelType,webhookUrl:c.notificationWebhookUrl,secret:c.notificationSecret,triggerOn:c.notificationTriggerOn,locale:c.notificationLocale,messageMode:c.notificationMessageMode}}}async function ae(){const C=String(n.taskSlug||"").trim();if(!(!C||l.value||d.value)){d.value=!0,h.value="";try{const q=await La(C,re());D(q),o("saved",q),o("close")}catch(q){h.value=(q==null?void 0:q.message)||a("taskDialog.saveFailed")}finally{d.value=!1}}}function ge(C=""){if(!C)return a("common.notAvailable");const q=new Date(C);return Number.isNaN(q.getTime())?a("common.notAvailable"):Sa(q.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Te(()=>n.open,C=>{if(C){x.value="basic",Q();return}},{immediate:!0}),Te(()=>n.taskSlug,()=>{n.open&&Q()}),(C,q)=>(g(),ke(js,{open:e.open,"stack-level":3,"panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-[42rem] sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:q[16]||(q[16]=U=>o("close"))},{title:Ge(()=>[i("div",null,[i("div",el,[ie(r(Zn),{class:"h-4 w-4"}),i("span",null,w(r(a)("taskDialog.title")),1)]),i("p",tl,w(r(a)("taskDialog.currentTask",{title:m.value})),1)])]),default:Ge(()=>[i("div",nl,[ie(bi,{modelValue:x.value,"onUpdate:modelValue":q[0]||(q[0]=U=>x.value=U),sections:f.value},null,8,["modelValue","sections"]),i("div",sl,[l.value?(g(),b("div",ol,[ie(r(Vt),{class:"h-4 w-4 animate-spin"}),i("span",null,w(r(a)("taskDialog.loading")),1)])):(g(),b("div",al,[x.value==="basic"?(g(),b("section",rl,[i("div",null,[i("div",il,w(r(a)("taskDialog.sections.basic.title")),1),i("p",ll,w(r(a)("taskDialog.sections.basic.intro")),1)]),i("section",ul,[i("label",cl,[i("span",dl,w(r(a)("taskDialog.sections.basic.taskTitle")),1),qt(i("input",{"onUpdate:modelValue":q[1]||(q[1]=U=>c.title=U),type:"text",maxlength:"140",class:"tool-input",placeholder:r(a)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,fl),[[Xn,c.title]])])])])):x.value==="automation"?(g(),b("section",pl,[i("div",ml,[i("div",null,[i("div",gl,[ie(r($s),{class:"h-4 w-4"}),i("span",null,w(r(a)("taskDialog.sections.automation.title")),1)]),i("p",hl,w(r(a)("taskDialog.sections.automation.intro")),1)]),i("label",vl,[qt(i("input",{"onUpdate:modelValue":q[2]||(q[2]=U=>c.automationEnabled=U),type:"checkbox",class:"h-4 w-4"},null,512),[[Oo,c.automationEnabled]]),i("span",null,w(r(a)("taskDialog.enabled")),1)])]),i("section",yl,[i("div",Sl,[i("label",wl,[i("span",xl,w(r(a)("taskDialog.sections.automation.mode")),1),ie(en,{modelValue:c.automationMode,"onUpdate:modelValue":q[3]||(q[3]=U=>c.automationMode=U),options:k.value,disabled:!c.automationEnabled,"get-option-value":U=>U.value},{trigger:Ge(({selectedOption:U})=>[i("div",bl,w((U==null?void 0:U.label)||r(a)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",kl,[i("span",_l,w(r(a)("taskDialog.sections.automation.time")),1),qt(i("input",{"onUpdate:modelValue":q[4]||(q[4]=U=>c.automationTime=U),type:"time",class:"tool-input",disabled:!c.automationEnabled},null,8,Tl),[[Xn,c.automationTime]])]),c.automationMode==="weekly"?(g(),b("label",Cl,[i("span",El,w(r(a)("taskDialog.sections.automation.weekday")),1),ie(en,{modelValue:c.automationWeekday,"onUpdate:modelValue":q[5]||(q[5]=U=>c.automationWeekday=U),options:y.value,disabled:!c.automationEnabled,"get-option-value":U=>U.value},{trigger:Ge(({selectedOption:U})=>[i("div",Al,w((U==null?void 0:U.label)||r(a)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):fe("",!0),i("label",$l,[i("span",Il,w(r(a)("taskDialog.sections.automation.timezone")),1),ie(en,{modelValue:c.automationTimezone,"onUpdate:modelValue":q[6]||(q[6]=U=>c.automationTimezone=U),options:L.value,disabled:!c.automationEnabled,"get-option-value":U=>U.value},{trigger:Ge(({selectedOption:U})=>[i("div",Pl,w((U==null?void 0:U.label)||r(a)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:ve(["space-y-1.5",c.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",Dl,w(r(a)("taskDialog.sections.automation.concurrencyPolicy")),1),ie(en,{modelValue:c.automationConcurrencyPolicy,"onUpdate:modelValue":q[7]||(q[7]=U=>c.automationConcurrencyPolicy=U),options:te.value,disabled:!c.automationEnabled,"get-option-value":U=>U.value},{trigger:Ge(({selectedOption:U})=>[i("div",Ll,w((U==null?void 0:U.label)||r(a)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",Ml,[i("p",null,w(r(a)("taskDialog.sections.automation.lastTriggered",{value:ge(c.automationLastTriggeredAt)})),1),i("p",null,w(r(a)("taskDialog.sections.automation.nextTriggered",{value:ge(c.automationNextTriggerAt)})),1)])])])):(g(),b("section",Bl,[i("div",Rl,[i("div",null,[i("div",Nl,[ie(r(jo),{class:"h-4 w-4"}),i("span",null,w(r(a)("taskDialog.sections.notification.title")),1)]),i("p",Ol,w(r(a)("taskDialog.sections.notification.intro")),1)]),i("label",jl,[qt(i("input",{"onUpdate:modelValue":q[8]||(q[8]=U=>c.notificationEnabled=U),type:"checkbox",class:"h-4 w-4"},null,512),[[Oo,c.notificationEnabled]]),i("span",null,w(r(a)("taskDialog.enabled")),1)])]),i("section",Fl,[i("div",Ul,[i("label",Vl,[i("span",zl,w(r(a)("taskDialog.sections.notification.channelType")),1),ie(en,{modelValue:c.notificationChannelType,"onUpdate:modelValue":q[9]||(q[9]=U=>c.notificationChannelType=U),options:S.value,disabled:!c.notificationEnabled,"get-option-value":U=>U.value},{trigger:Ge(({selectedOption:U})=>[i("div",Hl,w((U==null?void 0:U.label)||r(a)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",ql,[i("span",Kl,w(r(a)("taskDialog.sections.notification.triggerOn")),1),ie(en,{modelValue:c.notificationTriggerOn,"onUpdate:modelValue":q[10]||(q[10]=U=>c.notificationTriggerOn=U),options:M.value,disabled:!c.notificationEnabled,"get-option-value":U=>U.value},{trigger:Ge(({selectedOption:U})=>[i("div",Wl,w((U==null?void 0:U.label)||r(a)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Gl,[i("span",Xl,w(r(a)("taskDialog.sections.notification.webhookUrl")),1),qt(i("input",{"onUpdate:modelValue":q[11]||(q[11]=U=>c.notificationWebhookUrl=U),type:"text",class:"tool-input",placeholder:r(a)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!c.notificationEnabled},null,8,Yl),[[Xn,c.notificationWebhookUrl]])]),i("label",Jl,[i("span",Ql,w(r(a)("taskDialog.sections.notification.secret")),1),qt(i("input",{"onUpdate:modelValue":q[12]||(q[12]=U=>c.notificationSecret=U),type:"text",class:"tool-input",placeholder:r(a)("taskDialog.sections.notification.secretPlaceholder"),disabled:!c.notificationEnabled},null,8,Zl),[[Xn,c.notificationSecret]])]),i("label",eu,[i("span",tu,w(r(a)("taskDialog.sections.notification.locale")),1),ie(en,{modelValue:c.notificationLocale,"onUpdate:modelValue":q[13]||(q[13]=U=>c.notificationLocale=U),options:H.value,disabled:!c.notificationEnabled,"get-option-value":U=>U.value},{trigger:Ge(({selectedOption:U})=>[i("div",nu,w((U==null?void 0:U.label)||r(a)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",su,[i("span",ou,w(r(a)("taskDialog.sections.notification.messageMode")),1),ie(en,{modelValue:c.notificationMessageMode,"onUpdate:modelValue":q[14]||(q[14]=U=>c.notificationMessageMode=U),options:N.value,disabled:!c.notificationEnabled,"get-option-value":U=>U.value},{trigger:Ge(({selectedOption:U})=>[i("div",au,w((U==null?void 0:U.label)||r(a)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",ru,[i("p",null,w(r(a)("taskDialog.sections.notification.status",{value:V.value})),1),i("p",null,w(r(a)("taskDialog.sections.notification.lastSent",{value:ge(c.notificationLastSentAt)})),1),c.notificationLastError?(g(),b("p",iu,w(r(a)("taskDialog.sections.notification.lastError",{value:c.notificationLastError})),1)):fe("",!0)])])])),h.value?(g(),b("p",lu,w(h.value),1)):fe("",!0)]))])]),i("div",uu,[i("p",cu,w(r(a)("taskDialog.footerHint")),1),i("div",du,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:d.value,onClick:q[15]||(q[15]=U=>o("close"))},w(r(a)("common.cancel")),9,fu),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-sm",disabled:d.value||l.value,onClick:ae},[d.value?(g(),ke(r(Vt),{key:0,class:"h-4 w-4 animate-spin"})):(g(),ke(r(Tr),{key:1,class:"h-4 w-4"})),i("span",null,w(d.value?r(a)("common.saving"):r(a)("taskDialog.saveTaskConfig")),1)],8,pu)])])]),_:1},8,["open"]))}};function hu(e=[]){return(Array.isArray(e)&&e.length?e:Co).filter(n=>n&&typeof n=="object").map(n=>{const o=Eo(n.value);return{...n,value:o,label:String(n.label||lt(o)).trim()||lt(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function vu(e=[]){return hu(e).filter(t=>t.enabled&&t.available)}async function ly(){const e=await Ye("/api/meta",{cache:"no-store"});return vu(e==null?void 0:e.agentEngineOptions)}function Ba(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=lt(e==null?void 0:e.engine),a=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${a} · ${n}`:a}const yu={key:0,class:"flex items-center gap-2 text-sm"},Su={class:"min-w-0 flex-1 truncate"},wu={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},xu={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},bu={key:1,class:"theme-muted-text text-sm"},ku={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},_u=["onClick"],Tu={class:"flex items-center gap-3"},Cu={class:"min-w-0 flex-1"},Eu={class:"flex items-center gap-2 text-sm sm:hidden"},Au={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},$u={class:"hidden items-center gap-2 text-sm sm:flex"},Iu={class:"min-w-0 flex-1 truncate"},Pu={class:"font-medium text-[var(--theme-textPrimary)]"},Du={class:"theme-muted-text ml-2 font-mono text-[11px]"},Lu={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Mu={__name:"CodexSessionSelect",props:{modelValue:{type:String,default:""},sessions:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=t,{t:o}=vt();function s(c){return(c==null?void 0:c.title)||o("projectManager.untitledProject")}function a(c){return(c==null?void 0:c.cwd)||o("projectManager.notSet")}function l(c){return c!=null&&c.running?o("projectManager.running"):o("projectManager.idle")}function d(c){return c!=null&&c.running?"theme-status-warning":"theme-status-success"}function h(c){var f;const m=Math.max(0,Number((f=c==null?void 0:c.agentBindings)==null?void 0:f.length)||0);return m>1?o("projectManager.agentCount",{count:m}):lt(c==null?void 0:c.engine)}function x(c){return c?"theme-filter-active":"theme-filter-idle"}return(c,m)=>(g(),ke(en,{"model-value":e.modelValue,options:e.sessions,loading:e.loading,disabled:e.disabled,"trigger-class":"h-9",placeholder:r(o)("projectManager.selectProject"),"empty-text":r(o)("projectManager.noProjectsInSelect"),"get-option-value":f=>(f==null?void 0:f.id)||"","onUpdate:modelValue":m[0]||(m[0]=f=>n("update:modelValue",f)),onRefreshIntent:m[1]||(m[1]=f=>n("refresh-intent"))},{trigger:Ge(({selectedOption:f,disabled:k})=>[f?(g(),b("div",yu,[i("span",Su,[i("span",{class:ve(["font-medium",k?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},w(s(f)),3),i("span",wu,w(a(f)),1)]),i("span",xu,w(h(f)),1),i("span",{class:ve(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",d(f)])},w(l(f)),3)])):(g(),b("div",bu,w(e.loading?r(o)("projectManager.syncingProjects"):r(o)("projectManager.selectProject")),1))]),header:Ge(()=>[i("div",ku,[i("span",null,w(e.loading?r(o)("projectManager.syncingLatestProjects"):r(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(g(),ke(r(Vt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):fe("",!0)])]),option:Ge(({option:f,selected:k,select:y})=>[i("button",{type:"button",class:ve(["w-full rounded-sm border border-dashed p-3 text-left transition",x(k)]),onClick:y},[i("div",Tu,[i("div",Cu,[i("div",Eu,[i("span",Au,w(s(f)),1)]),i("div",$u,[i("span",Iu,[i("span",Pu,w(s(f)),1),i("span",Du,w(a(f)),1)]),i("span",Lu,w(h(f)),1),i("span",{class:ve(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d(f)])},w(l(f)),3)])]),k?(g(),ke(r(_a),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):fe("",!0)])],10,_u)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},Bu=["disabled"],Ru=["disabled"],Nu=["src","alt"],Ra={__name:"ImagePreviewOverlay",props:{modelValue:{type:String,default:""},images:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,o=t,{t:s}=vt(),a=K(1),l=G(()=>n.images.map(S=>String(S||"").trim()).filter(Boolean)),d=G(()=>l.value.findIndex(S=>S===n.modelValue)),h=G(()=>d.value>=0?l.value[d.value]:"");function x(){o("update:modelValue",""),a.value=1}function c(S){o("update:modelValue",String(S||"").trim()),a.value=1}function m(){d.value<=0||c(l.value[d.value-1])}function f(){d.value<0||d.value>=l.value.length-1||c(l.value[d.value+1])}function k(S){const M=Math.min(3,Math.max(.5,a.value+S));a.value=Math.round(M*100)/100}function y(){a.value=1}function L(S){h.value&&(S.preventDefault(),k(S.deltaY<0?.1:-.1))}function te(S){if(h.value){if(S.key==="Escape"){S.preventDefault(),x();return}if(S.key==="ArrowLeft"){S.preventDefault(),m();return}if(S.key==="ArrowRight"){S.preventDefault(),f();return}if(S.key==="+"||S.key==="="){S.preventDefault(),k(.1);return}if(S.key==="-"){S.preventDefault(),k(-.1);return}S.key==="0"&&(S.preventDefault(),y())}}return Te(()=>n.modelValue,S=>{S||(a.value=1)}),Te(l,S=>{if(n.modelValue){if(!S.length){x();return}if(!S.includes(n.modelValue)){const M=Math.min(d.value,S.length-1);c(S[M]||S[0])}}},{immediate:!0}),dn(()=>{window.addEventListener("keydown",te)}),$t(()=>{window.removeEventListener("keydown",te)}),(S,M)=>(g(),ke(os,{to:"body"},[h.value?(g(),b("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-50 flex items-center justify-center p-6",onClick:x,onWheel:L},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:M[2]||(M[2]=Xe(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:M[0]||(M[0]=N=>k(-.1))},w(r(s)("imagePreview.zoomOut")),1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:y},w(Math.round(a.value*100))+"% ",1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:M[1]||(M[1]=N=>k(.1))},w(r(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:M[3]||(M[3]=Xe(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:d.value<=0,onClick:m},w(r(s)("imagePreview.previous")),9,Bu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:d.value<0||d.value>=l.value.length-1,onClick:f},w(r(s)("imagePreview.next")),9,Ru),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:x},w(r(s)("imagePreview.close")),1)]),i("img",{src:h.value,alt:r(s)("imagePreview.alt"),class:"image-preview-overlay__image max-h-[90vh] max-w-[90vw] object-contain shadow-2xl transition-transform",style:kn({transform:`scale(${a.value})`}),onClick:M[4]||(M[4]=Xe(()=>{},["stop"]))},null,12,Nu)],32)):fe("",!0)]))}};let Qs=null;const uy={maxLines:2e3,maxChars:2e5},Zs={maxLines:2e3,maxChars:2e5},Ou={"github-dark-default":()=>Ue(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>Ue(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},ju={bash:()=>Ue(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>Ue(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>Ue(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>Ue(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>Ue(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>Ue(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>Ue(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>Ue(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>Ue(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>Ue(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>Ue(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>Ue(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>Ue(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>Ue(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>Ue(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>Ue(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>Ue(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>Ue(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>Ue(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>Ue(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>Ue(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>Ue(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>Ue(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>Ue(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>Ue(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>Ue(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>Ue(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>Ue(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>Ue(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function Na(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Po(e=[]){const t=Array.isArray(e)?e.map(o=>String(o??"")):[],n=t.reduce((o,s)=>o+s.length,0);return{lines:t,lineCount:t.length,charCount:n}}function Do(e={},t={}){const n=Number(t.maxHighlightLines||0),o=Number(t.maxHighlightChars||0);return n>0&&Number(e.lineCount||0)>n||o>0&&Number(e.charCount||0)>o}function Fu(e=[],t={}){const n=Po(e);return Do(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function Uu(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
3
- `);return Fu(n?n.split(`
4
- `):[],t)}async function Oa(){return Qs||(Qs=Promise.all([Ue(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.F),__vite__mapDeps([1,2,3])),Ue(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.G),__vite__mapDeps([1,2,3]))]).then(async([e,t])=>e.createHighlighterCore({engine:t.createJavaScriptRegexEngine(),langs:[],themes:[]}))),Qs}async function ja(e,t){if(!t||e.getLoadedThemes().includes(t))return;const n=Ou[t];n&&await e.loadTheme(await n())}async function Fa(e,t){if(!t||e.getLoadedLanguages().includes(t))return;const n=ju[t];n&&await e.loadLanguage(await n())}function Ln(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Vu={bash:"bash",c:"c",cpp:"cpp",cs:"csharp",csharp:"csharp",csh:"bash",css:"css",diff:"diff",dockerfile:"dockerfile",dotenv:"dotenv",env:"dotenv",fish:"fish",go:"go",html:"html",ini:"ini",java:"java",js:"javascript",javascript:"javascript",json:"json",jsx:"tsx",less:"less",md:"markdown",markdown:"markdown",powershell:"powershell",ps1:"powershell",pwsh:"powershell",python:"python",react:"tsx",rust:"rust",sass:"sass",scss:"scss",sh:"bash",shell:"bash",sql:"sql",svg:"html",text:"",toml:"toml",ts:"typescript",typescript:"typescript",tsx:"tsx",vue:"vue",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"bash"};function Fs(e=""){const t=String(e||"").trim().toLowerCase();return t?Vu[t]||t:""}function cy(e="",t=""){const n=Fs(t);if(n)return n;const o=String(e||"").trim().toLowerCase();if(!o)return"";const s=o.split("/").pop()||"",a=s.includes(".")?s.slice(s.lastIndexOf(".")):"",l={".c":"c",".cc":"cpp",".conf":"ini",".cpp":"cpp",".cs":"csharp",".csh":"bash",".css":"css",".diff":"diff",".env":"dotenv",".fish":"fish",".go":"go",".htm":"html",".html":"html",".ini":"ini",".java":"java",".js":"javascript",".json":"json",".jsx":"tsx",".less":"less",".md":"markdown",".ps1":"powershell",".py":"python",".rs":"rust",".sass":"sass",".scss":"scss",".sh":"bash",".sql":"sql",".svg":"html",".toml":"toml",".ts":"typescript",".tsx":"tsx",".vue":"vue",".xml":"xml",".yaml":"yaml",".yml":"yaml",".zsh":"bash"};return s===".env"?"dotenv":s==="dockerfile"?"dockerfile":s==="makefile"?"":l[a]||""}function Ua(e){const t=[];e!=null&&e.color&&t.push(`color:${e.color}`),(e==null?void 0:e.fontStyle)&1&&t.push("font-style:italic"),(e==null?void 0:e.fontStyle)&2&&t.push("font-weight:600"),(e==null?void 0:e.fontStyle)&4&&t.push("text-decoration:underline");const n=Ln((e==null?void 0:e.content)||"");return`<span${t.length?` style="${t.join(";")}"`:""}>${n}</span>`}function Va(e=[],t={}){const n=Math.max(1,Number(t.startLine)||1);return{html:e.map((o,s)=>`<tr class="source-code-view__line" data-line="${n+s}"><td class="source-code-view__gutter" data-line="${n+s}">${n+s}</td><td class="source-code-view__code"><span class="source-code-view__line-inner">${o}</span></td></tr>`).join(""),lineCount:e.length,bg:t.bg||"",fg:t.fg||"",gutterWidth:Na(e.length)}}function dy(e=[]){return(Array.isArray(e)?e.map(n=>String(n??"")):[]).map(n=>n?Ln(n):"&#8203;")}function eo(e=""){const t=String(e||"").replace(/\r\n/g,`
5
- `);return Va(t.split(`
6
- `).map(n=>n?Ln(n):"&#8203;"),{})}async function zu(e=[],t={}){const n=Po(e),o=n.lines,s=t.isDark?"github-dark-default":"github-light",a=Fs(t.language);if(!o.length)return[];if(Do(n,t))return o.map(l=>l?Ln(l):"&#8203;");if(!a)return o.map(l=>l?Ln(l):"&#8203;");try{const l=await Oa();return await ja(l,s),await Fa(l,a),(await l.codeToTokens(o.join(`
7
- `),{lang:a,theme:s})).tokens.map(h=>h.length?h.map(Ua).join(""):"&#8203;")}catch{return o.map(l=>l?Ln(l):"&#8203;")}}async function Hu(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
8
- `),o=t.isDark?"github-dark-default":"github-light",s=Fs(t.language),a=n?n.split(`
9
- `):[],l=Po(a);if(!n)return{html:"",lineCount:0,bg:"",fg:"",gutterWidth:Na(0)};if(Do(l,t)||!s)return eo(n);try{const d=await Oa();await ja(d,o),await Fa(d,s);const h=await d.codeToTokens(n,{lang:s,theme:o});return Va(h.tokens.map(x=>x.length?x.map(Ua).join(""):"&#8203;"),{bg:h.bg||"",fg:h.fg||""})}catch{return eo(n)}}const qu=new Aa,Ku="__PROMPTX_FENCE__";function za(e=""){return String(e||"").trim().toLowerCase()}function ms(e=""){return qu.utils.escapeHtml(String(e||""))}function Wu(e=""){const t=za(e);return t?["js","javascript"].includes(t)?"JavaScript":["jsx","react"].includes(t)?"React":["ts","typescript"].includes(t)?"TypeScript":t==="tsx"?"TSX":["sh","shell","zsh","bash","csh"].includes(t)?"Bash":t==="fish"?"Fish":["ps1","pwsh","powershell"].includes(t)?"PowerShell":t==="md"?"Markdown":t==="html"?"HTML":t==="vue"?"Vue":t==="svg"?"SVG":t==="json"?"JSON":t==="sql"?"SQL":t==="scss"?"SCSS":t==="sass"?"Sass":t==="less"?"Less":t==="toml"?"TOML":t==="ini"?"INI":["env","dotenv"].includes(t)?".env":["cs","csharp"].includes(t)?"C#":t.charAt(0).toUpperCase()+t.slice(1):""}function Ha(e={}){const t=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!1}),n=t.renderer.rules.link_open,o=t.renderer.rules.table_open,s=t.renderer.rules.table_close,a=t.renderer.rules.fence;return t.renderer.rules.link_open=(l,d,h,x,c)=>{const m=l[d];return m.attrSet("target","_blank"),m.attrSet("rel","noreferrer noopener"),typeof n=="function"?n(l,d,h,x,c):c.renderToken(l,d,h)},t.renderer.rules.table_open=(l,d,h,x,c)=>`<div class="codex-table-wrap">${typeof o=="function"?o(l,d,h,x,c):c.renderToken(l,d,h)}`,t.renderer.rules.table_close=(l,d,h,x,c)=>`${typeof s=="function"?s(l,d,h,x,c):c.renderToken(l,d,h)}</div>`,e.captureFences?t.renderer.rules.fence=(l,d,h,x={},c)=>{const m=l[d],f=Array.isArray(x.__promptxFences)?x.__promptxFences:[],k=f.length,y=`${Ku}${k}__`;return f.push({content:String((m==null?void 0:m.content)||""),language:String((m==null?void 0:m.info)||"").trim().split(/\s+/)[0]||"",placeholder:y}),x.__promptxFences=f,y}:typeof a=="function"&&(t.renderer.rules.fence=a),t}const Gu=Ha({captureFences:!0}),Xu=Ha();async function Yu(e="",t="",n={}){const o=String(e||"").replace(/\r\n/g,`
10
- `),s=za(t),a=Fs(s),d=(await zu(o.split(`
11
- `),{isDark:!!n.isDark,language:a||s})).join(`
12
- `),h=s?` class="language-${ms(s)}"`:"",x=Wu(t),c=ms(String(n.copyLabel||"Copy")),m=ms(String(n.copyAriaLabel||c)),k=`<div class="codex-code-block__header">${x?`<span class="codex-code-block__language">${ms(x)}</span>`:'<span class="codex-code-block__language-placeholder" aria-hidden="true"></span>'}<button type="button" class="codex-code-block__copy" data-copy-code="1" aria-label="${m}">${c}</button></div>`;return`<div class="${x?"codex-code-block codex-code-block--labeled":"codex-code-block"}">${k}<pre><code${h}>${d}</code></pre></div>`}async function Ju(e="",t=[],n={}){if(!Array.isArray(t)||!t.length)return e;const o=await Promise.all(t.map(s=>Yu(s.content,s.language,n)));return t.reduce((s,a,l)=>s.replace(a.placeholder,o[l]||a.placeholder),e)}async function Qu(e="",t={}){const n=String(e||"").trim();if(!n)return"";const o={},s=Gu.render(n,o);return Ju(s,o.__promptxFences||[],t)}function qa(e=""){const t=String(e||"").trim();return t?Xu.render(t):""}function Zu(e=""){let t=5381;for(const n of String(e||""))t=(t<<5)+t+n.charCodeAt(0),t|=0;return String(t>>>0)}function Ho(e={}){const t=String((e==null?void 0:e.id)||"").trim();return t?`id:${t}`:`${(e==null?void 0:e.type)||"block"}:${Zu(JSON.stringify(e||{}))}`}function ec(e=[]){const t=Array.isArray(e)?e:[],n=t.reduce((s,a)=>{const l=Ho(a);return s.set(l,(s.get(l)||0)+1),s},new Map),o=new Map;return t.map(s=>{const a=Ho(s),l=(o.get(a)||0)+1;return o.set(a,l),{key:`${a}:${l}`,signature:a,occurrence:l,duplicateCount:n.get(a)||1}})}const tc={key:0,class:"process-detail min-w-0 w-full max-w-full space-y-2"},nc={key:0,class:"process-detail-meta"},sc={key:0,class:"process-detail-meta__label"},oc={key:1,class:"process-detail-panel"},ac={class:"space-y-1.5"},rc={key:1,class:"process-detail-checklist__dot"},ic={key:0,class:"process-detail-footnote"},lc={key:0},uc={key:2,class:"process-detail-panel"},cc={class:"process-detail-directory__heading"},dc={key:0,class:"font-medium"},fc={key:1,class:"process-detail-directory__type"},pc={class:"process-detail-directory__list"},mc={key:0,class:"process-detail-footnote"},gc={key:0},hc={key:3,class:"process-detail-panel"},vc={class:"list-disc min-w-0 w-full max-w-full space-y-1.5 pl-5"},yc={key:0,class:"process-detail-footnote"},Sc={key:4,class:"process-detail-panel"},wc={class:"space-y-1.5"},xc={class:"process-detail-filechange__kind"},bc={class:"process-detail-filechange__path process-detail-mobile-code-scroll"},kc={key:5,class:"process-detail-panel"},_c={class:"space-y-2"},Tc={class:"flex min-w-0 items-center gap-2 text-xs leading-5"},Cc={class:"min-w-0 flex flex-1 items-center gap-2"},Ec={class:"shrink-0 font-medium text-[var(--theme-textPrimary)]"},Ac=["title"],$c=["onClick"],Ic={class:"process-detail-directory__type shrink-0"},Pc={key:0,class:"mt-2 border-l border-dashed border-[var(--theme-borderDefault)] pl-3"},Dc={key:1,class:"whitespace-pre-wrap break-words text-xs leading-5"},Lc=["innerHTML"],Mc={key:7,class:"process-detail-text"},Bc=Object.assign({name:"ProcessDetailRenderer"},{__name:"ProcessDetailRenderer",props:{blocks:{type:Array,default:()=>[]},kind:{type:String,default:""},detail:{type:String,default:""}},setup(e){const t=e,{t:n}=vt(),o=K(new Set),s=G(()=>{const D=Array.isArray(t.blocks)?t.blocks.filter(Boolean):[];return D.length?D:String(t.detail||"").trim()?[{type:"text",text:String(t.detail||"").trim()}]:[]}),a=G(()=>ec(s.value)),l=G(()=>a.value.map(D=>D.key));Te(s,(D=[])=>{const Q=new Set;D.forEach((re,ae)=>{(re==null?void 0:re.type)==="sub_agent_list"&&(Array.isArray(re.items)?re.items:[]).forEach((ge,C)=>{Q.add(ne(ae,ge,C))})}),o.value=new Set([...o.value].filter(re=>Q.has(re)))},{immediate:!0});function d(D=""){return qa(String(D||""))}function h(D=""){const Q=String(D||"").trim();return n(Q==="create"?"processDetail.changeCreate":Q==="delete"?"processDetail.changeDelete":Q==="update"?"processDetail.changeUpdate":"processDetail.changeGeneric")}function x(D={}){const Q=String((D==null?void 0:D.label)||"").trim().toLowerCase(),re=String((D==null?void 0:D.value)||"").trim();return re?re.length>56||["命令","command","目标","target","url","路径","path"].includes(Q)&&re.length>28?!0:re.includes(" ")&&re.length>36:!1}function c(D={},Q=[]){const re=String((D==null?void 0:D.label)||"").trim().toLowerCase();return["命令","command"].includes(re)?Array.isArray(Q)&&Q.length===1:!1}function m(D={}){const Q=String((D==null?void 0:D.label)||"").trim().toLowerCase();return["命令","command","路径","path","url","目标","target"].includes(Q)}function f(D={}){return D!=null&&D.completed?"completed":String((D==null?void 0:D.status)||"").trim().toLowerCase()==="in_progress"?"in_progress":"pending"}function k(D=0){return n("processDetail.hiddenItems",{count:D})}function y(D=0){return n("processDetail.directorySummary",{count:D})}function L(D=0){return n("processDetail.directoryHidden",{count:D})}function te(D=0){return l.value[D]||`block-${D}`}function S(D=""){const Q=String(D||"").trim().toLowerCase();return n(Q==="completed"?"processDetail.subAgentCompleted":Q==="failed"?"processDetail.subAgentFailed":Q==="running"?"processDetail.subAgentRunning":Q==="pending_init"?"processDetail.subAgentPending":"processDetail.subAgentUnknown")}function M(D={}){return String((D==null?void 0:D.title)||(D==null?void 0:D.target)||(D==null?void 0:D.id)||"").trim()}function N(D={}){const Q=M(D),re=[],ae=String((D==null?void 0:D.role)||"").trim(),ge=String((D==null?void 0:D.target)||"").trim(),C=String((D==null?void 0:D.model)||"").trim();return ae&&ae.toLowerCase()!=="default"&&re.push(ae),ge&&ge!==Q&&re.push(ge),C&&re.push(C),re.join(" · ")}function H(D={}){return!!String((D==null?void 0:D.message)||"").trim()}function V(D={}){const Q=String((D==null?void 0:D.message)||"").replace(/\s+/g," ").trim();return Q||N(D)}function ne(D=0,Q={},re=0){return`${te(D)}:sub-agent:${String((Q==null?void 0:Q.id)||(Q==null?void 0:Q.target)||(Q==null?void 0:Q.title)||re)}`}function I(D=0,Q={},re=0){return o.value.has(ne(D,Q,re))}function X(D=0,Q={},re=0){const ae=ne(D,Q,re),ge=new Set(o.value);ge.has(ae)?ge.delete(ae):ge.add(ae),o.value=ge}function le(D={}){return Array.isArray(D==null?void 0:D.messageBlocks)?D.messageBlocks.filter(Boolean):[]}function ce(D={}){return le(D).some(re=>!["text","markdown"].includes(String((re==null?void 0:re.type)||"").trim()))}return(D,Q)=>{const re=wr("ProcessDetailRenderer",!0);return s.value.length?(g(),b("div",tc,[(g(!0),b(Ze,null,it(s.value,(ae,ge)=>(g(),b(Ze,{key:l.value[ge]||`${ae.type}-${ge}`},[ae.type==="meta"?(g(),b("div",nc,[(g(!0),b(Ze,null,it(ae.items||[],(C,q)=>(g(),b("div",{key:`${ge}-meta-${q}`,class:ve(["process-detail-meta__item",{"process-detail-meta__item--long":x(C),"process-detail-meta__item--value-only":c(C,ae.items)}])},[c(C,ae.items)?fe("",!0):(g(),b("span",sc,w(C.label),1)),i("span",{class:ve(["process-detail-meta__value",{"process-detail-mobile-code-scroll":x(C),"process-detail-meta__value--mono":m(C)}])},w(C.value),3)],2))),128))])):ae.type==="checklist"?(g(),b("div",oc,[i("div",ac,[(g(!0),b(Ze,null,it(ae.items||[],(C,q)=>(g(),b("div",{key:`${ge}-check-${q}`,class:"process-detail-checklist__item"},[i("span",{class:ve(["process-detail-checklist__icon",`is-${f(C)}`])},[f(C)==="completed"?(g(),ke(r(_a),{key:0,class:"h-3 w-3"})):f(C)==="in_progress"?(g(),b("span",rc)):fe("",!0)],2),i("span",{class:ve(f(C)==="completed"?"line-through":"")},w(C.text),3)]))),128))]),ae.totalCount?(g(),b("div",ic,[rn(w(`已完成 ${(ae.items||[]).filter(C=>C.completed).length} / ${ae.totalCount}`)+" ",1),ae.hiddenCount?(g(),b("span",lc,w(`,还有 ${ae.hiddenCount} 项`),1)):fe("",!0)])):fe("",!0)])):ae.type==="directory_list"?(g(),b("div",uc,[i("div",cc,[ae.path?(g(),b("span",dc,w(ae.path),1)):fe("",!0),ae.entryType?(g(),b("span",fc,w(ae.entryType),1)):fe("",!0)]),i("div",pc,[(g(!0),b(Ze,null,it(ae.entries||[],(C,q)=>(g(),b("div",{key:`${ge}-entry-${q}`,class:"process-detail-directory__item"},w(C),1))),128))]),ae.totalCount?(g(),b("div",mc,[rn(w(y(ae.totalCount))+" ",1),ae.hiddenCount?(g(),b("span",gc,w(L(ae.hiddenCount)),1)):fe("",!0)])):fe("",!0)])):ae.type==="bullet_list"?(g(),b("div",hc,[i("ul",vc,[(g(!0),b(Ze,null,it(ae.items||[],(C,q)=>(g(),b("li",{key:`${ge}-bullet-${q}`,class:"min-w-0 w-full max-w-full break-words [overflow-wrap:anywhere]"},w(C),1))),128))]),ae.hiddenCount?(g(),b("div",yc,w(k(ae.hiddenCount)),1)):fe("",!0)])):ae.type==="file_changes"?(g(),b("div",Sc,[i("div",wc,[(g(!0),b(Ze,null,it(ae.items||[],(C,q)=>(g(),b("div",{key:`${ge}-change-${q}`,class:"process-detail-filechange__item"},[i("span",xc,w(h(C.kind)),1),i("span",bc,w(C.path),1)]))),128))])])):ae.type==="sub_agent_list"?(g(),b("div",kc,[i("div",_c,[(g(!0),b(Ze,null,it(ae.items||[],(C,q)=>(g(),b("div",{key:`${ge}-sub-agent-${q}`,class:"min-w-0"},[i("div",Tc,[i("div",Cc,[i("span",Ec,w(M(C)),1),V(C)?(g(),b("span",{key:0,class:"process-detail-subagent__preview min-w-0 flex-1",title:V(C)},w(V(C)),9,Ac)):fe("",!0)]),H(C)?(g(),b("button",{key:0,type:"button",class:"shrink-0 text-[11px] underline decoration-dashed underline-offset-2",onClick:U=>X(ge,C,q)},w(I(ge,C,q)?r(n)("common.collapse"):r(n)("common.expand")),9,$c)):fe("",!0),i("span",Ic,w(S(C.status)),1)]),H(C)&&I(ge,C,q)?(g(),b("div",Pc,[ce(C)?(g(),ke(re,{key:0,blocks:le(C),kind:"sub-agent-message"},null,8,["blocks"])):(g(),b("pre",Dc,w(C.message),1))])):fe("",!0)]))),128))])])):ae.type==="markdown"?(g(),b("div",{key:6,class:ve(["codex-markdown process-detail-markdown",{"process-detail-markdown--reasoning":t.kind==="reasoning"}]),innerHTML:d(ae.text)},null,10,Lc)):(g(),b("pre",Mc,w(ae.text),1))],64))),128))])):fe("",!0)}}}),Ka={__name:"SelectionInsertButton",props:{label:{type:String,default:""},top:{type:Number,default:0},left:{type:Number,default:0}},emits:["click"],setup(e,{emit:t}){function n(s){var a,l;typeof(s==null?void 0:s.button)=="number"&&s.button!==0||((a=s==null?void 0:s.preventDefault)==null||a.call(s),(l=s==null?void 0:s.stopPropagation)==null||l.call(s),o("click"))}const o=t;return(s,a)=>(g(),b("button",{type:"button",class:"tool-button tool-button-primary absolute z-20 inline-flex items-center gap-2 px-3 py-1.5 text-xs shadow-sm",style:kn({top:`${e.top}px`,left:`${e.left}px`}),onPointerdown:n,onKeydown:[a[0]||(a[0]=Kt(Xe(l=>o("click"),["prevent"]),["enter"])),a[1]||(a[1]=Kt(Xe(l=>o("click"),["prevent"]),["space"]))]},w(e.label),37))}},Wa=96,qo=34,an=8,Rc=72;function Nc(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement||null:null}function Ko(e,t,n){var a;const o=Nc(e);if(!o||!n)return null;const s=(a=o.closest)==null?void 0:a.call(o,t);return s&&n.contains(s)?s:null}function Oc(e){const t=(e==null?void 0:e.commonAncestorContainer)||null;return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentNode||null:null}function jc(e,t,{codeLeft:n=0,buttonWidth:o=Wa,scrollTop:s=0,scrollLeft:a=0,clientWidth:l=0,clientHeight:d=0}={}){const x=Math.max(e.left||0,Number(n)||0)-t.left+a,c=a+an,m=a+Math.max(an,l-o-an),f=Math.max(c,Math.min(m,x||a+an)),k=e.bottom-t.top+s+an,y=e.top-t.top+s-qo-an,L=s+an,te=s+d-an;return{top:k+qo<=te?k:Math.max(L,y),left:f}}function Ga(e={}){const t=K([]),n=K({visible:!1,top:0,left:0,content:""});let o=null,s=0;function a(){var H;return typeof e.getContainer=="function"?e.getContainer():((H=e.containerRef)==null?void 0:H.value)||null}function l(){return typeof e.getPositionContainer=="function"?e.getPositionContainer():a()}function d(){o&&(window.clearTimeout(o),o=null)}function h(){s&&(window.cancelAnimationFrame(s),s=0)}function x(H=[]){var V;t.value=H,(V=e.onSelectedRowsChange)==null||V.call(e,H)}function c({clearBrowserSelection:H=!1}={}){var V,ne,I,X;d(),h(),H&&((I=(ne=(V=window.getSelection)==null?void 0:V.call(window))==null?void 0:ne.removeAllRanges)==null||I.call(ne)),n.value={visible:!1,top:0,left:0,content:""},x([]),(X=e.onClear)==null||X.call(e)}function m(H){return H?typeof e.getOrderedRowElements=="function"?e.getOrderedRowElements(H).filter(Boolean):[...H.querySelectorAll(String(e.rowSelector||""))]:[]}function f(H){var V;return((V=e.mapRowElement)==null?void 0:V.call(e,H))??H}function k(H,V,ne){const I=String(e.rowSelector||"").trim(),X=m(ne);if(!I||!X.length)return[];const le=Ko(H.anchorNode,I,ne),ce=Ko(H.focusNode,I,ne);if(le&&ce){const D=X.indexOf(le),Q=X.indexOf(ce);if(D>=0&&Q>=0){const[re,ae]=D<=Q?[D,Q]:[Q,D];return X.slice(re,ae+1)}}return X.filter(D=>{try{return V.intersectsNode(D)}catch{return!1}})}function y(){var q,U,Ve;const H=(q=window.getSelection)==null?void 0:q.call(window),V=a(),ne=l();if(!(typeof e.isActive=="function"?e.isActive():!0)||!H||H.rangeCount<1||H.isCollapsed||!V||!ne){c();return}const X=H.getRangeAt(0),le=Oc(X);if(!le||!V.contains(le)){c();return}const ce=String(H.toString()||"").replace(/\u200b/g,"");if(!ce.trim()){c();return}const D=k(H,X,V);if(!D.length){c();return}const Q=D.map(Ae=>f(Ae)).filter(Ae=>Ae!==null&&typeof Ae<"u");if(!Q.length){c();return}const re=X.getBoundingClientRect(),ae=(U=ne.getBoundingClientRect)==null?void 0:U.call(ne);if(!ae){c();return}const ge=((Ve=e.getCodeLeft)==null?void 0:Ve.call(e,D[0]))||re.left,C=jc(re,ae,{codeLeft:ge,buttonWidth:Number(e.buttonWidth||Wa),scrollTop:Number(ne.scrollTop||0),scrollLeft:Number(ne.scrollLeft||0),clientWidth:Number(ne.clientWidth||0),clientHeight:Number(ne.clientHeight||0)});n.value={visible:!0,top:C.top,left:C.left,content:ce},x(Q)}function L(){d(),o=window.setTimeout(()=>{o=null,y()},Number(e.debounceMs||Rc))}function te(){L()}function S(){L()}function M(){!n.value.visible||s||(s=window.requestAnimationFrame(()=>{s=0,y()}))}function N(){M()}return dn(()=>{var H,V,ne,I;document.addEventListener("selectionchange",S),document.addEventListener("mouseup",S),document.addEventListener("scroll",N,!0),window.addEventListener("resize",N),(V=(H=window.visualViewport)==null?void 0:H.addEventListener)==null||V.call(H,"resize",N),(I=(ne=window.visualViewport)==null?void 0:ne.addEventListener)==null||I.call(ne,"scroll",N)}),$t(()=>{var H,V,ne,I;c({clearBrowserSelection:!0}),document.removeEventListener("selectionchange",S),document.removeEventListener("mouseup",S),document.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N),(V=(H=window.visualViewport)==null?void 0:H.removeEventListener)==null||V.call(H,"resize",N),(I=(ne=window.visualViewport)==null?void 0:ne.removeEventListener)==null||I.call(ne,"scroll",N)}),{selectedRows:t,selectionAction:n,clearSelectionState:c,clearScheduledSelectionUpdate:d,handleSelectionMouseUp:te,scheduleSelectionUpdate:L,updateSelectionActionFromDom:y}}const Fc=250,Uc=350,Vc=180,xs=2;function Xa(e){return(e==null?void 0:e.name)==="AbortError"}const to="promptx:codex-recent-paths",zc=12;function Ya(e){const{getMode:t,props:n,onSelect:o}=e,s=K([]),a=K(!1),l=K(""),d=K([]),h=K(!1),x=K(""),c=K([]),m=K([]),f=K("tree"),k=K(""),y=new Map;let L=null,te=0,S=0,M=null;const N=G(()=>String(n.query||"").trim()),H=G(()=>Math.max(1,Number(e.minimumQueryLength)||xs)),V=G(()=>N.value.length>=H.value),ne=G(()=>typeof t=="function"),I=G(()=>ne.value?String((t==null?void 0:t())||"").trim()==="search"?"search":"tree":f.value),X=G(()=>et(s.value)),le=G(()=>String(n.sessionId||"").trim()),ce=G(()=>le.value?`promptx:codex-tree-expanded:${le.value}`:""),D=G(()=>{if(!N.value)return c.value;const z=new Set(d.value.map(W=>W.path));return c.value.filter(W=>z.has(W.path))}),Q=G(()=>{const z=new Set(D.value.map(W=>W.path));return d.value.filter(W=>!z.has(W.path))}),re=G(()=>N.value?[...D.value,...Q.value]:c.value),ae=G(()=>I.value==="search"?re.value:X.value),ge=G(()=>I.value==="search"?h.value:a.value),C=G(()=>I.value==="search"?x.value:l.value),q=G(()=>I.value==="search"&&!!n.sessionId&&V.value&&!h.value&&!x.value&&!re.value.length),U=G(()=>I.value==="search"&&!!n.sessionId&&!!N.value&&!V.value&&!h.value&&!x.value),Ve=G(()=>I.value==="tree"&&!!n.sessionId&&!a.value&&!l.value&&!X.value.length);function Ae(z,W){if(!z||typeof window>"u")return W;try{const ue=window.localStorage.getItem(z);return ue?JSON.parse(ue):W}catch{return W}}function Oe(z,W){if(!(!z||typeof window>"u"))try{window.localStorage.setItem(z,JSON.stringify(W))}catch{}}function Ne(z=[]){return[...z].sort((W,ue)=>{const me=+(W.type!=="directory")-+(ue.type!=="directory");return me||String(W.path||W.name||"").localeCompare(String(ue.path||ue.name||""),"zh-CN")})}function qe(z){return{...z,children:[],expanded:!1,loaded:!1,loading:!1}}function et(z=[],W=0,ue=[]){return z.forEach(me=>{ue.push({...me,depth:W}),me.type==="directory"&&me.expanded&&me.children.length&&et(me.children,W+1,ue)}),ue}function we(z,W=s.value){for(const ue of W){if(ue.path===z)return ue;if(ue.children.length){const me=we(z,ue.children);if(me)return me}}return null}function O(){s.value=[...s.value]}function J(){L&&(window.clearTimeout(L),L=null),M&&(M.abort(),M=null)}function de(z=s.value,W=[]){return z.forEach(ue=>{ue.type==="directory"&&ue.expanded&&(W.push(ue.path),ue.children.length&&de(ue.children,W))}),W}function ye(){if(!ce.value)return;const z=[...new Set(de())];m.value=z,Oe(ce.value,z)}function pe(){m.value=ce.value?Ae(ce.value,[]).filter(Boolean):[]}function Ee(z=s.value,W=new Set){if(!W.size)return!1;const ue=z.filter(me=>me.type==="directory"&&me.hasChildren).map(me=>me.path);return!ue.length||ue.length!==W.size?!1:ue.every(me=>W.has(me))}function Ce(){const z=Ae(to,[]);if(!Array.isArray(z)||!le.value){c.value=[];return}c.value=z.filter(W=>W&&W.sessionId===le.value&&W.path).sort((W,ue)=>Number(ue.usedAt||0)-Number(W.usedAt||0)).slice(0,zc)}function Pe(z){return z.name||z.path||"."}function Re(z){return z.path||"."}function Ke(z){if(!le.value||!(z!=null&&z.path))return;const W={sessionId:le.value,path:z.path,name:z.name||Pe(z),type:z.type||"file",usedAt:Date.now()},ue=Ae(to,[]),me=[W];Array.isArray(ue)&&ue.forEach(je=>{!(je!=null&&je.path)||!(je!=null&&je.sessionId)||je.sessionId===W.sessionId&&je.path===W.path||me.push(je)}),Oe(to,me.slice(0,40)),Ce()}function ot(z=""){const W=String(z||"").trim();return!W||!W.includes("/")?"":W.slice(0,W.lastIndexOf("/"))}function De(){const z=ae.value;if(!z.length)return-1;const W=z.findIndex(ue=>ue.path===k.value);return W>=0?W:0}function Me(){const z=ae.value,W=De();return W<0||!z.length?null:z[W]||null}function _e(){const z=ae.value;if(!z.length){k.value="";return}z.some(W=>W.path===k.value)||(k.value=z[0].path)}function at(z,W){if(W){y.set(z,W);return}y.delete(z)}function mt(){var W;const z=y.get(k.value);(W=z==null?void 0:z.scrollIntoView)==null||W.call(z,{block:"nearest"})}function ct(z=""){return String(z||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function yt(z="",W=""){const ue=String(z||""),me=String(W||"").trim().toLowerCase();if(!ue||!me)return null;const je=ue.toLowerCase(),Et=je.indexOf(me);if(Et>=0)return{start:Et,end:Et+me.length};const zt=me.split(/[\\/\s_.-]+/).filter(Boolean).sort((_t,Bt)=>Bt.length-_t.length);for(const _t of zt){if(_t.length<2)continue;const Bt=je.indexOf(_t);if(Bt>=0)return{start:Bt,end:Bt+_t.length}}return null}function Tt(z="",W=""){const ue=String(z||""),me=yt(ue,W);return me?`${ct(ue.slice(0,me.start))}<mark class="theme-search-highlight">${ct(ue.slice(me.start,me.end))}</mark>${ct(ue.slice(me.end))}`:ct(ue)}function E(z){return Tt(Pe(z),N.value)}function F(z){return Tt(Re(z),N.value)}async function ee(z="",W={}){if(!n.sessionId){s.value=[],l.value="",a.value=!1;return}const ue=!z,me=ue?null:we(z);if(!(!ue&&!me)&&!(!W.force&&(ue&&s.value.length||!ue&&me.loaded))){ue?(a.value=!0,l.value=""):(me.loading=!0,l.value="",O());try{const je=await Hi(n.sessionId,{path:z,refreshToken:W.refreshToken||""}),Et=Ne(je.items||[]).map(qe);if(ue){s.value=Et;return}me.children=Et,me.loaded=!0}catch(je){l.value=je.message}finally{ue?a.value=!1:(me.loading=!1,O())}}}async function he(z=s.value,W=new Set,ue={}){for(const me of z)me.type!=="directory"||!W.has(me.path)||(me.expanded=!0,O(),await ee(me.path,ue),me.children.length&&await he(me.children,W,ue))}async function Be(z={}){await ee("",z);const W=new Set(m.value),ue=Ee(s.value,W),me=W.size>0&&!ue;ue&&(m.value=[],Oe(ce.value,[]),W.clear());for(const je of s.value)je.type!=="directory"||!je.hasChildren||(je.expanded=me?W.has(je.path):!1);if(O(),me){await he(s.value,W,z);return}}async function Ie(z){if(I.value!=="tree")return;const W=we(z);if(!(!W||W.type!=="directory")){if(!W.loaded&&!W.loading){W.expanded=!0,O(),await ee(W.path),ye();return}W.expanded=!W.expanded,O(),ye()}}function He(z){return z!=null&&z.path?(Ke(z),o==null||o(z),!0):!1}async function Je(z={}){const W=N.value;te+=1;const ue=te,me=z.refreshToken||"";if(J(),!n.open||!n.sessionId||!W||!V.value){h.value=!1,x.value="",d.value=[];return}M=new AbortController;try{const je=await qi(n.sessionId,W,{limit:80,refreshToken:me,signal:M.signal});if(ue!==te)return;d.value=je.items||[]}catch(je){if(Xa(je)||ue!==te)return;x.value=je.message,d.value=[]}finally{ue===te&&(M=null),ue===te&&(h.value=!1)}}function ut(z={}){if(J(),!n.open||!n.sessionId||!N.value||!V.value){h.value=!1,x.value="",d.value=[];return}h.value=!0,x.value="",L=window.setTimeout(()=>{L=null,Je(z)},Fc)}function ht(){if(!n.sessionId){s.value=[],l.value="",a.value=!1,d.value=[],x.value="",h.value=!1;return}S=Date.now(),s.value=[],l.value="",d.value=[],x.value="",Be({force:!0,refreshToken:S}),ut({refreshToken:S})}function tt(){if(ne.value)return!1;const z=N.value?"search":"tree";return f.value===z?!1:(f.value=z,!0)}function dt(){Ce(),pe(),tt(),ht()}function kt(){J(),d.value=[],x.value="",h.value=!1}function Dt(z){const W=ae.value;if(!W.length)return!1;const ue=De(),me=ue<0?0:(ue+z+W.length)%W.length;return k.value=W[me].path,st(mt),!0}async function oe(){if(I.value!=="tree")return!1;const z=Me();if(!z||z.type!=="directory")return!1;if(!z.expanded)return await Ie(z.path),k.value=z.path,!0;const W=ae.value,ue=De(),me=W[ue+1];return me&&ot(me.path)===z.path?(k.value=me.path,!0):!1}function $e(){if(I.value!=="tree")return!1;const z=Me();if(!z)return!1;if(z.type==="directory"&&z.expanded){const ue=we(z.path);return ue&&(ue.expanded=!1,O(),ye()),k.value=z.path,!0}const W=ot(z.path);return W?(k.value=W,!0):!1}function rt(){const z=ae.value;return z.length?He(z[De()]):!1}function St(){s.value=[],l.value="",a.value=!1,d.value=[],x.value="",h.value=!1,Ce(),pe(),n.sessionId&&n.open&&(Be({force:!0}),ut())}function Ct(){tt(),ut()}function ft(){_e(),st(mt)}return $t(()=>{J()}),{activeKey:k,collapseActiveDirectory:$e,confirmActive:rt,currentError:C,currentLoading:ge,emitSelect:He,expandActiveDirectory:oe,getDisplayName:Pe,getHighlightedName:E,getHighlightedPath:F,handleQueryChange:Ct,handleSessionChange:St,handleVisibleItemsChange:ft,initializeData:dt,moveActive:Dt,normalSearchItems:Q,normalizedQuery:N,recentSearchItems:D,resetData:kt,setItemRef:at,showSearchPromptState:U,showSearchEmptyState:q,showTreeEmptyState:Ve,toggleDirectory:Ie,treeItems:X,visibleItems:ae}}const Hc={class:"min-w-0"},qc={class:"theme-heading truncate text-sm font-medium"},Kc={class:"source-browser-layout grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},Wc={class:"theme-divider border-b px-4 py-3"},Gc={class:"block"},Xc={class:"sr-only"},Yc={class:"relative"},Jc=["placeholder","onKeydown"],Qc=["title","aria-label"],Zc={class:"min-h-0 flex-1 overflow-y-auto p-2"},ed={key:0,class:"theme-empty-state px-3 py-4 text-[12px]"},td={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},nd={key:2,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},sd={key:3,class:"theme-empty-state px-3 py-4 text-[12px]"},od={key:4,class:"theme-empty-state px-3 py-4 text-[12px]"},ad={key:5,class:"theme-empty-state px-3 py-4 text-[12px]"},rd={key:6,class:"theme-empty-state px-3 py-4 text-[12px]"},id={key:7,class:"theme-empty-state px-3 py-4 text-[12px]"},ld={key:8,class:"theme-empty-state px-3 py-4 text-[12px]"},ud={key:9,class:"theme-empty-state px-3 py-4 text-[12px]"},cd={key:10,class:"theme-empty-state px-3 py-4 text-[12px]"},dd={key:11,class:"space-y-1"},fd={key:0,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},pd=["onClick"],md={class:"min-w-0 flex-1"},gd=["innerHTML"],hd=["innerHTML"],vd={key:1,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},yd=["onClick"],Sd={class:"min-w-0 flex-1"},wd=["innerHTML"],xd=["innerHTML"],bd={key:12,class:"space-y-3"},kd={class:"theme-divider flex items-start gap-2.5 border-b px-3 py-2.5"},_d={class:"min-w-0 flex-1"},Td={class:"theme-list-item-title theme-list-item-title--strong break-all"},Cd={key:0,class:"theme-list-item-meta truncate"},Ed={class:"theme-list-item-meta shrink-0 pt-0.5"},Ad={class:"space-y-1 px-2 py-2"},$d=["onClick"],Id=["innerHTML"],Pd={key:0,class:"theme-muted-text px-1 text-[12px]"},Dd={key:13,class:"space-y-1"},Ld=["onClick"],Md={class:"flex items-start gap-1.5"},Bd=["onClick"],Rd={key:1,class:"block h-5 w-5 shrink-0"},Nd=["onClick"],Od={class:"flex min-h-0 flex-col overflow-hidden"},jd={class:"theme-divider border-b px-4 py-2"},Fd={class:"flex items-center justify-between gap-3"},Ud={class:"min-w-0"},Vd={key:0,class:"theme-muted-text truncate text-[12px]"},zd={key:1,class:"theme-muted-text mt-1 text-[11px]"},Hd={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},qd={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Kd={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-[12px]"},Wd={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Gd={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Xd={key:4,class:"source-browser-image-wrap flex h-full min-h-[12rem] items-center justify-center overflow-hidden rounded-sm border p-4"},Yd=["src","alt"],Jd={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-[12px]"},Qd={class:"source-code-view"},Zd={class:"source-code-view__table"},ef=["innerHTML"],tf=20,nf={__name:"CodexSessionSourceBrowserDialog",props:{open:{type:Boolean,default:!1},session:{type:Object,default:null}},emits:["close","insert-code-context"],setup(e,{emit:t}){const n=e,o=t,{t:s}=vt(),{isDark:a}=xa(),l=as({open:!1,sessionId:"",query:""}),d=K(""),h=K(""),x=K(!1),c=K(""),m=K(null),f=K(""),k=K("path"),y=K([]),L=K(!1),te=K(""),S=K(""),M=K(!1),N=K(""),H=new Map,V=K(null),ne=K(null),I=K(0),X=K([]),le=K("");let ce=0,D=0,Q=null,re=null;const ae=Uc,ge=Vc;let C=null;const q=new Map,U=G(()=>{var u;return String(((u=n.session)==null?void 0:u.id)||"").trim()}),Ve=G(()=>{var u;return String(((u=n.session)==null?void 0:u.cwd)||"").trim()}),Ae=G(()=>k.value!=="content"),Oe=G(()=>k.value==="content"),Ne=G(()=>String(f.value||"").trim()),qe=G(()=>Ne.value.length>=xs),et=G(()=>{var u;return((u=m.value)==null?void 0:u.name)||d.value||""}),we=G(()=>{var u;return((u=m.value)==null?void 0:u.path)||d.value||""}),O=G(()=>{var u;return Gt(((u=m.value)==null?void 0:u.size)||0)}),J=G(()=>{var A,B;const u=[];return(we.value||et.value)&&u.push(we.value||et.value),(A=m.value)!=null&&A.size&&u.push(O.value),(B=m.value)!=null&&B.truncated&&u.push(s("sourceBrowser.truncated")),u.join(" ")}),de=G(()=>{var u;return!!((u=m.value)!=null&&u.previewUrl)}),ye=G(()=>{var u,A;return!!((u=m.value)!=null&&u.binary&&!((A=m.value)!=null&&A.previewUrl))}),pe=G(()=>!!(m.value&&!m.value.binary&&!m.value.previewUrl)),Ee=K(""),Ce=K(""),Pe=K(""),Re=K("2.6rem"),{selectedRows:Ke,selectionAction:ot,clearSelectionState:De,handleSelectionMouseUp:Me,updateSelectionActionFromDom:_e}=Ga({getContainer:()=>ne.value,isActive:()=>n.open&&pe.value,rowSelector:".source-code-view__line",mapRowElement:u=>{var B;const A=Number(((B=u==null?void 0:u.getAttribute)==null?void 0:B.call(u,"data-line"))||0);return A>0?A:null},getCodeLeft:u=>{var be,ze,Fe;const A=(be=u==null?void 0:u.querySelector)==null?void 0:be.call(u,".source-code-view__code");if(!A)return 0;const B=(ze=A.getBoundingClientRect)==null?void 0:ze.call(A),R=(Fe=window.getComputedStyle)==null?void 0:Fe.call(window,A),se=Number.parseFloat((R==null?void 0:R.paddingLeft)||"0")||0;return((B==null?void 0:B.left)||0)+se},debounceMs:72}),at=G(()=>[...new Set(Ke.value)].map(u=>Number(u)||0).filter(u=>u>0).sort((u,A)=>u-A)),mt=G(()=>{var B;const u=String(((B=m.value)==null?void 0:B.content)||"").replace(/\r\n/g,`
13
- `),A=u?u.split(`
14
- `):[];return[...at.value].sort((R,se)=>R-se).map(R=>({lineNumber:R,content:String(A[R-1]||"")})).filter(R=>R.lineNumber>0)}),ct=G(()=>mt.value.length>0),yt=G(()=>Oe.value?s("sourceBrowser.contentSearchPlaceholder"):s("sourceBrowser.searchPlaceholder")),Tt=G(()=>Oe.value?s("sourceBrowser.searchModeContent"):s("sourceBrowser.searchModePath")),E=G(()=>!!Ne.value),F=G(()=>E.value?"search":"tree"),ee=G(()=>E.value&&Oe.value?L.value:$e.value),he=G(()=>Ae.value&&nn.value),Be=G(()=>Ae.value&&Bt.value),Ie=G(()=>E.value&&Oe.value&&!qe.value&&!L.value&&!te.value),He=G(()=>E.value&&Oe.value&&qe.value&&!!S.value&&!L.value&&!te.value&&!y.value.length),Je=G(()=>E.value&&Oe.value&&qe.value&&!L.value&&!te.value&&!S.value&&!y.value.length),ut=G(()=>{const u=[],A=new Map;return y.value.forEach(B=>{const R=String((B==null?void 0:B.path)||"").trim();if(!R)return;let se=A.get(R);se||(se={path:R,name:String((B==null?void 0:B.name)||R.split("/").pop()||R),items:[]},A.set(R,se),u.push(se)),se.items.push(B)}),u}),ht=G(()=>y.value.map(u=>v(u)).join("|")),tt=G(()=>p.value.map(u=>{const A=String((u==null?void 0:u.path)||"").trim(),B=u!=null&&u.expanded?1:0,R=u!=null&&u.loading?1:0;return`${A}:${B}:${R}`}).join("|")),{activeKey:dt,collapseActiveDirectory:kt,expandActiveDirectory:Dt,currentError:oe,currentLoading:$e,getDisplayName:rt,getHighlightedName:St,getHighlightedPath:Ct,handleQueryChange:ft,handleSessionChange:z,handleVisibleItemsChange:W,initializeData:ue,moveActive:me,normalSearchItems:je,recentSearchItems:Et,resetData:zt,setItemRef:_t,showSearchPromptState:Bt,showSearchEmptyState:nn,showTreeEmptyState:Qt,toggleDirectory:$,treeItems:T,visibleItems:p}=Ya({getMode:()=>F.value,props:l,onSelect:on});function _(u=""){return String(u||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function v(u){return`${(u==null?void 0:u.path)||""}:${(u==null?void 0:u.line)||0}:${(u==null?void 0:u.column)||0}`}function Y(u,A){if(A){H.set(u,A);return}H.delete(u)}function Qe(){var A;const u=H.get(N.value);(A=u==null?void 0:u.scrollIntoView)==null||A.call(u,{block:"nearest"})}function Le(u="",A=""){const B=String(u||""),R=String(A||"").trim();if(!B||!R)return _(B);const se=B.toLowerCase(),be=R.toLowerCase(),ze=se.indexOf(be);if(ze<0)return _(B);const Fe=ze+be.length;return`${_(B.slice(0,ze))}<mark class="theme-search-highlight">${_(B.slice(ze,Fe))}</mark>${_(B.slice(Fe))}`}function Ot(u="",A=""){const B=String(u||""),R=String(A||"").trim();if(!B||!R)return[];const se=B.toLowerCase(),be=R.toLowerCase(),ze=[];let Fe=0;for(;Fe<se.length;){const xt=se.indexOf(be,Fe);if(xt<0)break;ze.push({start:xt,end:xt+be.length}),Fe=xt+be.length}return ze}function jt(u,A,B){if(!u)return null;if(u.nodeType===Node.TEXT_NODE){const se=u.textContent||"",be=B.offset,ze=be+se.length;if(B.offset=ze,!se)return document.createTextNode("");const Fe=A.filter(Ht=>Ht.start<ze&&Ht.end>be);if(!Fe.length)return document.createTextNode(se);const xt=document.createDocumentFragment();let Lt=0;return Fe.forEach(Ht=>{const fs=Math.max(0,Ht.start-be),Ks=Math.min(se.length,Ht.end-be);if(fs>Lt&&xt.appendChild(document.createTextNode(se.slice(Lt,fs))),Ks>fs){const Ws=document.createElement("mark");Ws.className="source-code-view__search-hit",Ws.textContent=se.slice(fs,Ks),xt.appendChild(Ws)}Lt=Math.max(Lt,Ks)}),Lt<se.length&&xt.appendChild(document.createTextNode(se.slice(Lt))),xt}if(u.nodeType!==Node.ELEMENT_NODE)return u.cloneNode(!0);const R=u.cloneNode(!1);return Array.from(u.childNodes||[]).forEach(se=>{const be=jt(se,A,B);be&&R.appendChild(be)}),R}function Wt(u=ne.value){var A,B,R;u&&((R=(B=(A=u.querySelectorAll)==null?void 0:A.call(u,".source-code-view__line-inner[data-original-html]"))==null?void 0:B.forEach)==null||R.call(B,se=>{const be=se.dataset.originalHtml;typeof be=="string"&&(se.innerHTML=be)}))}function Rt(){var B,R,se;const u=ne.value,A=String(le.value||"").trim();u&&(Wt(u),A&&((se=(R=(B=u.querySelectorAll)==null?void 0:B.call(u,".source-code-view__line.is-match .source-code-view__line-inner"))==null?void 0:R.forEach)==null||se.call(R,be=>{be.dataset.originalHtml||(be.dataset.originalHtml=be.innerHTML);const ze=Ot(be.textContent||"",A);if(!ze.length)return;const Fe=document.createDocumentFragment(),xt={offset:0};Array.from(be.childNodes||[]).forEach(Lt=>{const Ht=jt(Lt,ze,xt);Ht&&Fe.appendChild(Ht)}),be.replaceChildren(Fe)})))}function Gt(u=0){const A=Math.max(0,Number(u)||0);return A<1024?`${A} B`:A<1024*1024?`${(A/1024).toFixed(A<10*1024?1:0)} KB`:`${(A/(1024*1024)).toFixed(1)} MB`}function Ft(){var A,B,R;const u=ne.value;u&&(Wt(u),(R=(B=(A=u.querySelectorAll)==null?void 0:A.call(u,".source-code-view__line.is-match, .source-code-view__line.is-focus-match"))==null?void 0:B.forEach)==null||R.call(B,se=>se.classList.remove("is-match","is-focus-match")))}function wt(){var A,B,R;const u=ne.value;u&&((R=(B=(A=u.querySelectorAll)==null?void 0:A.call(u,".source-code-view__line.is-selected"))==null?void 0:B.forEach)==null||R.call(B,se=>se.classList.remove("is-selected")))}function Xt(){wt();const u=ne.value;!u||!at.value.length||at.value.forEach(A=>{var se,be;const B=u.querySelector(`.source-code-view__gutter[data-line="${A}"]`),R=(se=B==null?void 0:B.closest)==null?void 0:se.call(B,"tr");(be=R==null?void 0:R.classList)==null||be.add("is-selected")})}function Us(){if(!at.value.length)return"";const u=[...at.value].sort((A,B)=>A-B);return u[0]===u[u.length-1]?`L${u[0]}`:`L${u[0]}-${u[u.length-1]}`}function Fn(){var A,B,R,se;if(!m.value||!ct.value)return;const u=mt.value.map(be=>be.lineNumber);o("insert-code-context",{source:"source",filePath:we.value,language:String(((A=m.value)==null?void 0:A.language)||""),rangeLabel:Us(),lineStart:Math.min(...u),lineEnd:Math.max(...u),content:String(ot.value.content||"").trim()||mt.value.map(be=>be.content).join(`
15
- `)}),(se=(R=(B=window.getSelection)==null?void 0:B.call(window))==null?void 0:R.removeAllRanges)==null||se.call(R),De(),o("close")}function Vs(u){var ze,Fe,xt,Lt;const A=(ze=window.getSelection)==null?void 0:ze.call(window),B=ne.value;if(!A||A.rangeCount<1||A.isCollapsed||!B)return;_e();const se=A.getRangeAt(0).commonAncestorContainer;if(!B.contains((se==null?void 0:se.nodeType)===1?se:se==null?void 0:se.parentNode))return;const be=String(A.toString()||"").replace(/\u200b/g,"");be&&((xt=(Fe=u==null?void 0:u.clipboardData)==null?void 0:Fe.setData)==null||xt.call(Fe,"text/plain",be),(Lt=u==null?void 0:u.preventDefault)==null||Lt.call(u))}function Ut(){C&&(window.clearTimeout(C),C=null)}function is(){q.clear()}function zs(u=""){const A=String(u||"").trim();if(!A||!q.has(A))return null;const B=q.get(A);return q.delete(A),q.set(A,B),B}function Un(u="",A=null){const B=String(u||"").trim();if(!(!B||!A))for(q.delete(B),q.set(B,A);q.size>tf;){const R=q.keys().next().value;if(!R)break;q.delete(R)}}function ls(u){Ut(),C=window.setTimeout(()=>{C=null,u==null||u()},ge)}function sn(){st(()=>{var u,A;(A=(u=V.value)==null?void 0:u.focus)==null||A.call(u)})}function Vn(u){var A,B,R;if((A=u==null?void 0:u.preventDefault)==null||A.call(u),Ne.value){(B=u==null?void 0:u.stopPropagation)==null||B.call(u),f.value="";return}(R=u==null?void 0:u.stopPropagation)==null||R.call(u),o("close")}function zn(){Ut(),ce+=1,is(),d.value="",h.value="",x.value=!1,c.value="",m.value=null,Ee.value="",Ce.value="",Pe.value="",Re.value="2.6rem",I.value=0,X.value=[],le.value="",De(),Ft()}function Yt(){D+=1,Q&&(window.clearTimeout(Q),Q=null),re&&(re.abort(),re=null),y.value=[],L.value=!1,te.value="",S.value="",M.value=!1,N.value="",X.value=[],le.value="",Ft()}function us(){if(Q&&(window.clearTimeout(Q),Q=null),!n.open||!U.value||!Oe.value)return;if(!Ne.value||!qe.value){Yt();return}L.value=!0,te.value="",Q=window.setTimeout(()=>{Q=null,Kn()},ae)}function Hn(u=1){const A=y.value;if(!A.length)return!1;const B=A.findIndex(se=>v(se)===N.value),R=B<0?0:(B+u+A.length)%A.length;return N.value=v(A[R]),st(Qe),!0}function Tn(){return p.value.length&&(p.value.find(u=>u.path===dt.value)||p.value[0])||null}function fn(u,A={}){return u?(dt.value=(u==null?void 0:u.path)||"",N.value="",d.value=String((u==null?void 0:u.path)||"").trim(),h.value=String((u==null?void 0:u.type)||"").trim(),c.value="",I.value=0,X.value=[],le.value="",(u==null?void 0:u.type)==="directory"?(Ut(),m.value=null,A.toggleDirectory&&!E.value&&$(u.path),!0):A.previewMode==="debounced"?(ls(()=>En(u==null?void 0:u.path)),!0):(Ut(),En(u==null?void 0:u.path),!0)):!1}function cs(){const u=y.value;if(!u.length)return!1;const A=u.find(B=>v(B)===N.value)||u[0];return mn(A),!0}function Hs(u){const A=String((u==null?void 0:u.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(A)&&!(E.value&&(A==="ArrowLeft"||A==="ArrowRight"))){if(Oe.value&&E.value){if(A==="ArrowDown"){if(u.preventDefault(),Hn(1)){const B=y.value,R=B.find(se=>v(se)===N.value)||B[0];mn(R,{previewMode:"debounced"})}return}if(A==="ArrowUp"){if(u.preventDefault(),Hn(-1)){const B=y.value,R=B.find(se=>v(se)===N.value)||B[0];mn(R,{previewMode:"debounced"})}return}if(A==="Enter"){u.preventDefault(),cs();return}A==="Escape"&&Vn(u);return}if(A==="ArrowDown"){u.preventDefault(),me(1)&&st(()=>{fn(Tn(),{previewMode:"debounced"})});return}if(A==="ArrowUp"){u.preventDefault(),me(-1)&&st(()=>{fn(Tn(),{previewMode:"debounced"})});return}if(A==="ArrowRight"){u.preventDefault(),Dt();return}if(A==="ArrowLeft"){u.preventDefault(),kt();return}if(A==="Enter"){u.preventDefault(),fn(Tn(),{toggleDirectory:!0});return}A==="Escape"&&Vn(u)}}async function Cn(){const u=Oe.value?"path":"content";if(k.value=u,!Ne.value){u==="content"?Yt():(Yt(),l.query="");return}if(u==="content"){l.query="",Kn();return}Yt(),l.query=f.value}function qs(u){var A;u.preventDefault(),(A=u.stopPropagation)==null||A.call(u),Cn().finally(()=>{sn()})}async function pn(){var be;if(await st(),Ft(),!ne.value)return;const u=[...new Set(X.value.map(ze=>Math.max(0,Number(ze)||0)).filter(ze=>ze>0))],A=Math.max(0,Number(I.value)||0);if(u.forEach(ze=>{var Lt,Ht;const Fe=ne.value.querySelector(`.source-code-view__gutter[data-line="${ze}"]`),xt=(Lt=Fe==null?void 0:Fe.closest)==null?void 0:Lt.call(Fe,"tr");(Ht=xt==null?void 0:xt.classList)==null||Ht.add("is-match")}),Rt(),!A){Xt();return}const B=A,R=ne.value.querySelector(`.source-code-view__gutter[data-line="${B}"]`),se=(be=R==null?void 0:R.closest)==null?void 0:be.call(R,"tr");if(!se){Xt();return}se.classList.add("is-match","is-focus-match"),Rt(),se.scrollIntoView({block:"center",inline:"nearest"}),Xt()}async function qn(){var be,ze,Fe;if(!pe.value){Ee.value="",Ce.value="",Pe.value="";return}const u=ce,A=String(((be=m.value)==null?void 0:be.content)||"").replace(/\r\n/g,`
16
- `),B=((ze=m.value)==null?void 0:ze.language)||"",R=Uu(A,Zs),se=await Hu(((Fe=m.value)==null?void 0:Fe.content)||"",{isDark:a.value,language:B,maxHighlightLines:Zs.maxLines,maxHighlightChars:Zs.maxChars});u===ce&&(Ee.value=se.html,Ce.value=R?"":se.bg||"",Pe.value=R?"":se.fg||"",Re.value=se.gutterWidth||"2.6rem",await st(),Xt())}async function En(u="",A={}){var ze;const B=String(u||"").trim();if(!U.value||!B)return;I.value=Math.max(0,Number(A.focusLine)||0),De();const R=String(((ze=m.value)==null?void 0:ze.path)||"").trim();if(!A.forceReload&&R===B&&!x.value&&!c.value){await pn();return}if(!A.forceReload&&x.value&&d.value===B)return;ce+=1;const se=ce;c.value="";const be=A.forceReload?null:zs(B);if(be){x.value=!1,m.value=be,await qn(),se===ce&&pe.value&&await pn();return}x.value=!0;try{const Fe=await Ki(U.value,{path:B,limit:204800,refreshToken:String(Date.now())});if(se!==ce)return;m.value=Fe,Un(B,Fe),await qn()}catch(Fe){if(se!==ce)return;m.value=null,c.value=(Fe==null?void 0:Fe.message)||s("sourceBrowser.previewFailed")}finally{se===ce&&(x.value=!1,pe.value&&await pn())}}function on(u){fn(u,{toggleDirectory:!0}),st(sn)}function ds(u,A){var B,R;(R=(B=u==null?void 0:u.currentTarget)==null?void 0:B.focus)==null||R.call(B),on(A)}async function Kn(){const u=Ne.value;if(!n.open||!U.value)return;D+=1;const A=D;if(!u||!qe.value){Yt();return}re&&(re.abort(),re=null),L.value=!0,te.value="",y.value=[],M.value=!1,N.value="",re=new AbortController;try{const B=await Wi(U.value,u,{limit:80,refreshToken:String(Date.now()),signal:re.signal});if(A!==D)return;S.value=u,y.value=Array.isArray(B.items)?B.items:[],M.value=!!B.truncated,N.value=y.value[0]?v(y.value[0]):"",y.value[0]&&mn(y.value[0],{previewMode:"debounced"})}catch(B){if(Xa(B)||A!==D)return;S.value=u,y.value=[],te.value=(B==null?void 0:B.message)||s("sourceBrowser.contentSearchFailed")}finally{A===D&&(re=null),A===D&&(L.value=!1)}}function mn(u,A={}){N.value=v(u),dt.value=(u==null?void 0:u.path)||"",d.value=String((u==null?void 0:u.path)||"").trim(),h.value="file",c.value="",le.value=S.value||Ne.value,X.value=y.value.filter(R=>(R==null?void 0:R.path)===(u==null?void 0:u.path)).map(R=>Number((R==null?void 0:R.line)||0)).filter(R=>R>0);const B=()=>En(u==null?void 0:u.path,{focusLine:u==null?void 0:u.line});if(A.previewMode==="debounced"){ls(B),st(sn);return}Ut(),B(),st(sn)}function P(u){const A=String((u==null?void 0:u.path)||"").trim();if(!A)return"";const B=A.split("/");return B[B.length-1]||A}function Z(u){const A=String((u==null?void 0:u.path)||"").trim();return!A||!A.includes("/")?"":A.slice(0,A.lastIndexOf("/"))}function Se(u){return`${Array.isArray(u==null?void 0:u.items)?u.items.length:0} 处`}function xe(u){const A=S.value||Ne.value;return Le((u==null?void 0:u.preview)||"",A)}return Te(()=>n.open,u=>{var A,B,R,se,be,ze;if(l.open=u,u){(R=(B=(A=window.getSelection)==null?void 0:A.call(window))==null?void 0:B.removeAllRanges)==null||R.call(B),l.sessionId=U.value,f.value="",k.value="path",l.query="",zn(),Yt(),ue(),sn();return}(ze=(be=(se=window.getSelection)==null?void 0:se.call(window))==null?void 0:be.removeAllRanges)==null||ze.call(be),f.value="",k.value="path",zn(),Yt(),zt()},{immediate:!0}),Te(U,u=>{l.sessionId=u,n.open&&(zn(),Yt(),z())}),Te(f,u=>{if(Ae.value){l.query=u;return}String(u||"").trim()!==String(S.value||"").trim()&&(le.value="",Rt()),us()}),Te(()=>l.query,()=>{Ae.value&&ft()}),Te(ht,()=>{st(Qe)}),Te(tt,()=>{W(),!(!E.value||!Ae.value)&&st(()=>{const u=Tn();u&&fn(u,{previewMode:"debounced"})})}),Te(a,async()=>{!n.open||!pe.value||(await qn(),await pn())}),Te(at,()=>{Xt()}),$t(()=>{var u,A,B;(B=(A=(u=window.getSelection)==null?void 0:u.call(window))==null?void 0:A.removeAllRanges)==null||B.call(A),De({clearBrowserSelection:!0}),Ut()}),(u,A)=>(g(),ke(js,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-full sm:h-[90vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-3.5","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:A[2]||(A[2]=B=>o("close"))},{title:Ge(()=>[i("div",Hc,[i("div",qc,w(Ve.value||r(s)("sourceBrowser.title")),1)])]),default:Ge(()=>{var B;return[i("div",Kc,[i("aside",{class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r",onKeydown:Hs},[i("div",Wc,[i("label",Gc,[i("span",Xc,w(r(s)("sourceBrowser.searchLabel")),1),i("div",Yc,[ie(r(Cr),{class:"theme-muted-text pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),qt(i("input",{ref_key:"searchInputRef",ref:V,"onUpdate:modelValue":A[0]||(A[0]=R=>f.value=R),type:"text",class:"tool-input w-full pl-9 pr-18 text-[12px]",placeholder:yt.value,onKeydown:[Kt(Vn,["esc"]),Kt(Xe(qs,["prevent"]),["tab"])]},null,40,Jc),[[Xn,f.value]]),ee.value?(g(),ke(r(Vt),{key:0,class:"theme-muted-text pointer-events-none absolute right-10 top-1/2 h-4 w-4 -translate-y-1/2 animate-spin"})):fe("",!0),i("button",{type:"button",class:"tool-button absolute right-1.5 top-1/2 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center px-0",title:Tt.value,"aria-label":Tt.value,onClick:Xe(Cn,["stop","prevent"])},[ie(r(Er),{class:"h-3.5 w-3.5"})],8,Qc)])])]),i("div",Zc,[U.value?E.value&&Oe.value&&te.value?(g(),b("div",td,w(te.value),1)):r(oe)?(g(),b("div",nd,w(r(oe)),1)):Be.value?(g(),b("div",sd,w(r(s)("sourceBrowser.searchMinKeywordHint",{count:r(xs)})),1)):he.value?(g(),b("div",od,w(r(s)("sourceBrowser.searchEmpty")),1)):Ie.value?(g(),b("div",ad,w(r(s)("sourceBrowser.searchMinKeywordHint",{count:r(xs)})),1)):Je.value?(g(),b("div",rd,w(r(s)("sourceBrowser.contentSearchPrompt")),1)):He.value?(g(),b("div",id,w(r(s)("sourceBrowser.contentSearchEmpty")),1)):r(Qt)?(g(),b("div",ld,w(r(s)("sourceBrowser.treeEmpty")),1)):E.value&&Oe.value&&L.value&&!y.value.length?(g(),b("div",ud,w(r(s)("sourceBrowser.contentSearching")),1)):r($e)&&!r(p).length?(g(),b("div",cd,w(r(s)("sourceBrowser.loadingFiles")),1)):E.value&&Ae.value?(g(),b("div",dd,[r(Et).length?(g(),b("div",fd,w(r(s)("sourceBrowser.recent")),1)):fe("",!0),(g(!0),b(Ze,null,it(r(Et),R=>(g(),b("button",{key:`recent-${R.path}`,ref_for:!0,ref:se=>r(_t)(R.path,se),type:"button",class:ve(["theme-list-row focus:outline-none",r(dt)===R.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:se=>on(R)},[(g(),ke(cn(R.type==="directory"?r(Dn):r(Sn)),{class:"theme-list-item-icon"})),i("div",md,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:r(St)(R)},null,8,gd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:r(Ct)(R)},null,8,hd)])],10,pd))),128)),l.query.trim()&&r(je).length?(g(),b("div",vd,w(r(s)("sourceBrowser.results")),1)):fe("",!0),(g(!0),b(Ze,null,it(r(je),R=>(g(),b("button",{key:`result-${R.path}`,ref_for:!0,ref:se=>r(_t)(R.path,se),type:"button",class:ve(["theme-list-row focus:outline-none",r(dt)===R.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:se=>on(R)},[(g(),ke(cn(R.type==="directory"?r(Dn):r(Sn)),{class:"theme-list-item-icon"})),i("div",Sd,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:r(St)(R)},null,8,wd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:r(Ct)(R)},null,8,xd)])],10,yd))),128))])):E.value?(g(),b("div",bd,[(g(!0),b(Ze,null,it(ut.value,R=>(g(),b("div",{key:R.path,class:"rounded-sm border border-[var(--theme-borderDefault)] bg-[var(--theme-panel)]"},[i("div",kd,[ie(r(Sn),{class:"theme-list-item-icon"}),i("div",_d,[i("div",Td,w(P(R)),1),Z(R)?(g(),b("div",Cd,w(Z(R)),1)):fe("",!0)]),i("div",Ed,w(Se(R)),1)]),i("div",Ad,[(g(!0),b(Ze,null,it(R.items,se=>(g(),b("button",{key:v(se),ref_for:!0,ref:be=>Y(v(se),be),type:"button",class:ve(["theme-list-row gap-0 focus:outline-none",N.value===v(se)?"theme-list-item-active":"theme-list-item-hover"]),onClick:be=>mn(se)},[i("div",{class:"theme-list-item-title min-w-0 flex-1 break-words leading-[1.45rem]",innerHTML:xe(se)},null,8,Id)],10,$d))),128))])]))),128)),M.value?(g(),b("div",Pd,w(r(s)("sourceBrowser.contentSearchTruncated")),1)):fe("",!0)])):(g(),b("div",Dd,[(g(!0),b(Ze,null,it(r(T),R=>(g(),b("div",{key:R.path,ref_for:!0,ref:se=>r(_t)(R.path,se),class:ve(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",r(dt)===R.path?"theme-list-item-active":R.type==="directory"&&R.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:kn({paddingLeft:`${R.depth*16+6}px`}),tabindex:"-1",onClick:se=>ds(se,R)},[i("div",Md,[R.type==="directory"?(g(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Xe(se=>r($)(R.path),["stop"])},[R.loading?(g(),ke(r(Vt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),ke(r(Ta),{key:1,class:ve(["h-3.5 w-3.5 transition",R.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,Bd)):(g(),b("span",Rd)),i("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 outline-none focus:outline-none",onClick:Xe(se=>on(R),["stop"])},[(g(),ke(cn(R.type==="directory"?r(Dn):r(Sn)),{class:ve(["h-4 w-4 shrink-0",R.type==="directory"&&R.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("span",{class:ve(["theme-list-item-title min-w-0 flex-1 truncate",R.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},w(r(rt)(R)),3)],8,Nd)])],14,Ld))),128))])):(g(),b("div",ed,w(r(s)("sourceBrowser.noProject")),1))])],32),i("section",Od,[i("div",jd,[i("div",Fd,[i("div",Ud,[J.value?(g(),b("p",Vd,w(J.value),1)):fe("",!0),pe.value?(g(),b("p",zd,w(r(s)("sourceBrowser.selectCodeLineHint")),1)):fe("",!0)])])]),i("div",Hd,[x.value?(g(),b("div",qd,[i("span",null,w(r(s)("sourceBrowser.previewLoading")),1)])):c.value?(g(),b("div",Kd,w(c.value),1)):h.value==="directory"?(g(),b("div",Wd,w(r(s)("sourceBrowser.selectFileHint")),1)):d.value?de.value?(g(),b("div",Xd,[i("img",{src:m.value.previewUrl,alt:et.value,class:"source-browser-image object-contain"},null,8,Yd)])):ye.value?(g(),b("div",Jd,[ie(r(Ar),{class:"h-8 w-8"}),i("span",null,w((B=m.value)!=null&&B.tooLarge?r(s)("sourceBrowser.binaryTooLarge"):r(s)("sourceBrowser.binaryUnsupported")),1)])):pe.value?(g(),b("div",{key:6,ref_key:"previewContainerRef",ref:ne,class:"source-browser-code relative rounded-sm border",style:kn({"--source-code-bg":Ce.value||"var(--theme-panel)","--source-code-fg":Pe.value||"var(--theme-textPrimary)","--source-code-gutter-width":Re.value}),onCopy:Vs,onMouseup:A[1]||(A[1]=(...R)=>r(Me)&&r(Me)(...R))},[i("div",Qd,[i("table",Zd,[i("tbody",{innerHTML:Ee.value},null,8,ef)])]),e.open&&r(ot).visible?(g(),ke(Ka,{key:0,top:r(ot).top,left:r(ot).left,label:r(s)("sourceBrowser.insertSelection"),onClick:Fn},null,8,["top","left","label"])):fe("",!0)],36)):fe("",!0):(g(),b("div",Gd,w(r(s)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},sf=wa(nf,[["__scopeId","data-v-8ccd6589"]]);function of(e={}){const{items:t,themeKey:n,getCacheKey:o=S=>String((S==null?void 0:S.id)||"").trim(),getSource:s=S=>String((S==null?void 0:S.content)||""),shouldRender:a=()=>!0,renderAsync:l=async S=>S,renderFallback:d=S=>S,onRendered:h=null}=e,x=new Map,c=new Map,m=K(0),f=G(()=>(Array.isArray(t==null?void 0:t.value)?t.value:[]).map(S=>{const M=!!a(S),N=String(o(S)||"").trim(),H=M?String(s(S)||""):"";return{item:S,active:M,cacheKey:N,source:H}}));function k(S){if(m.value,!a(S))return"";const M=String(s(S)||""),N=String(o(S)||"").trim(),H=String((n==null?void 0:n.value)||"");if(!N)return d(M,S);const V=x.get(N);return(V==null?void 0:V.source)===M&&(V==null?void 0:V.theme)===H?V.html:d(M,S)}async function y(S){if(!a(S))return;const M=String(s(S)||""),N=String(o(S)||"").trim();if(!N)return;const H=String((n==null?void 0:n.value)||""),V=x.get(N);if((V==null?void 0:V.source)===M&&(V==null?void 0:V.theme)===H)return;const ne=Symbol(N);c.set(N,ne);try{const I=await l(M,S,{themeKey:H});if(c.get(N)!==ne)return;x.set(N,{source:M,theme:H,html:I}),m.value+=1,h==null||h(S,{cacheKey:N,source:M,themeKey:H})}catch{}finally{c.get(N)===ne&&c.delete(N)}}function L(S=[]){S.forEach(M=>{M!=null&&M.item&&y(M.item)})}function te(S=[]){const M=new Set((Array.isArray(S)?S:[]).filter(H=>H==null?void 0:H.active).map(H=>String((H==null?void 0:H.cacheKey)||"").trim()).filter(Boolean));let N=!1;for(const H of x.keys())M.has(H)||(x.delete(H),N=!0);for(const H of c.keys())M.has(H)||c.delete(H);N&&(m.value+=1)}return Te(f,()=>{te(f.value||[]),L(f.value||[])},{immediate:!0}),Te(n,()=>{L(f.value||[])}),$t(()=>{c.clear()}),{getRenderedHtml:k}}const af=`${Io()}/api/events/stream`,Mn=new Set;let wn=null,bs=null;function fo(){bs&&(window.clearTimeout(bs),bs=null)}function Ja(){wn&&(wn.close(),wn=null)}function rf(e){Mn.forEach(t=>{try{t(e)}catch{}})}function Qa(){typeof window>"u"||typeof window.EventSource>"u"||wn||!Mn.size||(fo(),wn=new window.EventSource(af),wn.onmessage=e=>{try{const t=JSON.parse(String(e.data||"{}"));if(!(t!=null&&t.type))return;rf(t)}catch{}},wn.onerror=()=>{Ja(),Mn.size&&(fo(),bs=window.setTimeout(()=>{Qa()},1500))})}function lf(e){return typeof e!="function"?()=>{}:(Mn.add(e),Qa(),()=>{Mn.delete(e),!Mn.size&&(fo(),Ja())})}const Za=K(0),po=K(0),ks=K(""),Yn=K(""),_s=K(0),er=as({}),mo=as({}),go=as({}),Jn=new Map;let Wo=!1;const uf=new Set(["created","updated","deleted","reordered","session-linked","session-cleared"]),cf=new Set(["completed","error","stopped","interrupted","stop_timeout"]);function no(e,t=""){const n=String(t||"").trim();n&&(e[n]=Math.max(0,Number(e[n])||0)+1)}function df(e={}){const t=String(e.type||"").trim(),n=String(e.reason||"").trim();return{updatesTaskList:t==="runs.changed"||t==="tasks.changed"&&uf.has(n),updatesSessions:t==="ready"||t==="runs.changed"||t==="sessions.changed",updatesTaskRuns:t==="runs.changed",updatesTaskDiff:t==="runs.changed"||t==="tasks.changed"&&(n==="session-linked"||n==="session-cleared")}}function ff(e=null,t=null){const n=String((e==null?void 0:e.runId)||"").trim(),o=String((e==null?void 0:e.status)||"").trim(),s=String((t==null?void 0:t.runId)||"").trim(),a=String((t==null?void 0:t.status)||"").trim();return!n||!s||n!==s||!o||o!==a?!1:cf.has(a)}function pf(e="",t={}){const n=String(e||"").trim();if(!n)return;const o=Jn.get(n);o!=null&&o.size&&o.forEach(s=>{try{s(t)}catch{}})}function mf(e={}){const t=String(e.type||"").trim(),n=String(e.taskSlug||"").trim(),o=df(e);if(t){if(t==="ready"){Za.value+=1,ks.value="",Yn.value="",_s.value+=1;return}if(t==="tasks.changed"){ks.value=n,Yn.value=String(e.reason||"").trim(),o.updatesTaskList&&(po.value+=1),o.updatesTaskDiff&&no(mo,n);return}if(t==="runs.changed"){ks.value=n,Yn.value="";const s={runId:String(e.runId||"").trim(),status:String(e.status||"").trim(),sentAt:String(e.sentAt||"").trim()},a=n&&go[n]||null,l=ff(a,s);n&&(go[n]=s),o.updatesTaskList&&!l&&(po.value+=1),o.updatesSessions&&(_s.value+=1),o.updatesTaskRuns&&no(er,n),o.updatesTaskDiff&&!l&&no(mo,n);return}if(t==="sessions.changed"){Yn.value="",o.updatesSessions&&(_s.value+=1);return}t==="run.event"&&pf(n,{taskSlug:n,runId:String(e.runId||"").trim(),event:e.event||null})}}function tr(){Wo||typeof window>"u"||(lf(e=>{mf(e)}),Wo=!0)}function gf(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(er[t])||0):0}function hf(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(mo[t])||0):0}function vf(e=""){const t=String(e||"").trim();return t&&go[t]||null}function yf(e="",t){const n=String(e||"").trim();if(!n||typeof t!="function")return()=>{};tr();const o=Jn.get(n)||new Set;return o.add(t),Jn.set(n,o),()=>{const s=Jn.get(n);s&&(s.delete(t),s.size||Jn.delete(n))}}function nr(){return tr(),{readyVersion:Za,listSyncVersion:po,listSyncTaskSlug:ks,listSyncReason:Yn,sessionsSyncVersion:_s,getTaskRunSyncVersion:gf,getTaskRunChange:vf,getTaskDiffSyncVersion:hf}}const Sf=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/g,wf=/\u001B\[[0-?]*[ -/]*[@-~]/g,xf=/\u001B[@-_]/g,bf=/[\u0000-\u0008\u000B-\u001A\u001C-\u001F\u007F]/g;function kf(e=""){let t="";for(const n of String(e||"")){if(n==="\b"||n===""){t=t.slice(0,-1);continue}t+=n}return t}function On(e=""){return kf(String(e||"")).replace(Sf,"").replace(wf,"").replace(xf,"").replace(/\r\n/g,`
17
- `).replace(/\r/g,`
18
- `).replace(bf,"")}function rs(e=""){return On(e)}function _n(e=""){return String(e||"").replace(/^(?:[ \t]*\n)+/,"").replace(/(?:\n[ \t]*)+$/,"")}function Lo(e=[],t=12){const n=Array.isArray(e)?e:[];return n.length<=t?{items:n,hiddenCount:0}:{items:n.slice(0,t),hiddenCount:n.length-t}}function _f(e=""){const t=_n(rs(e));if(!t.trim())return null;const n=t.split(`
19
- `),o=String(n[0]||"").trim();if(!o)return null;const s=o.match(/^([A-Za-z][A-Za-z0-9 _/-]{1,24}):\s*(.+)$/);if(!s)return null;const a=s[1].trim().toLowerCase();if(!new Set(["read","grep","glob","find","ls","dir","tree","list","path","file","command"]).has(a))return null;const d=_n(n.slice(1).join(`
20
- `));return{meta:{type:"meta",items:[{label:s[1].trim(),value:s[2].trim()}]},rest:d}}function Tf(e="",t={}){const n=_n(rs(e));if(!n.trim()||!n.includes("<path>")||!n.includes("<entries>"))return null;const o=n.match(/<path>([\s\S]*?)<\/path>/i),s=n.match(/<type>([\s\S]*?)<\/type>/i),a=n.match(/<entries>([\s\S]*?)<\/entries>/i);if(!o&&!a)return null;const l=String((a==null?void 0:a[1])||"").split(`
21
- `).map(x=>x.trim()).filter(Boolean).filter(x=>!/^\(\d+\s+entries?\)$/i.test(x)),{items:d,hiddenCount:h}=Lo(l,t.maxItems??12);return{type:"directory_list",path:String((o==null?void 0:o[1])||"").trim(),entryType:String((s==null?void 0:s[1])||"").trim(),entries:d,totalCount:l.length,hiddenCount:h}}function Cf(e="",t={}){const n=_n(rs(e));if(!n.trim())return null;const o=n.split(`
22
- `).map(d=>d.trimEnd()),s=o.map(d=>{const h=d.match(/^\s*\[([ xX])\]\s+(.+)$/);return h?{completed:h[1].toLowerCase()==="x",text:h[2].trim()}:null}).filter(Boolean);if(!s.length||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:a,hiddenCount:l}=Lo(s,t.maxItems??12);return{type:"checklist",items:a,totalCount:s.length,hiddenCount:l}}function Ef(e="",t={}){const n=_n(rs(e));if(!n.trim())return null;const o=n.split(`
23
- `),s=o.map(d=>{const h=d.match(/^[-*]\s+(.+)$/);return h?h[1].trim():null}).filter(Boolean);if(s.length<2||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:a,hiddenCount:l}=Lo(s,t.maxItems??12);return{type:"bullet_list",items:a,totalCount:s.length,hiddenCount:l}}function Af(e="",t={}){return{type:t.preferMarkdown?"markdown":"text",text:e}}function $f(e=[]){return e.reduce((t,n)=>{const o=t[t.length-1];return o&&n&&o.type===n.type&&["text","markdown"].includes(n.type)?(o.text=`${o.text}
24
-
25
- ${n.text}`,t):(t.push(n),t)},[])}function If(e="",t={}){const n=String(e||"").split(/\n{2,}/).map(l=>_n(l)).filter(l=>l.trim());if(n.length<2)return null;const o=$f(n.flatMap(l=>Mo(l,{...t,_disableMixedSegmentation:!0}))),s=o.some(l=>!["text","markdown"].includes(l==null?void 0:l.type)),a=o.some(l=>["text","markdown"].includes(l==null?void 0:l.type));return s&&a?o:null}function Mo(e="",t={}){const n=_n(rs(e));if(!n.trim())return[];const o=_f(n);if(o!=null&&o.rest){const d=Mo(o.rest,t);return[o.meta,...d.length?d:[{type:"text",text:o.rest}]]}const s=Tf(n,t);if(s)return[s];const a=Cf(n,t);if(a)return[a];const l=Ef(n,t);if(l)return[l];if(!t._disableMixedSegmentation){const d=If(n,t);if(d!=null&&d.length)return d}return[Af(n,t)]}const Pf=new Set(["queued","starting","running","stopping"]);function ln(){return Ns()==="en-US"}function j(e,t){return ln()?t:e}function Go(e=""){const t=Date.parse(String(e||""));return Number.isFinite(t)?t:0}function Xo(e=[],t=""){return[...e].sort((n,o)=>{const s=+!!(o!=null&&o.running)-+!!(n!=null&&n.running);if(s)return s;const a=+((o==null?void 0:o.id)===t)-+((n==null?void 0:n.id)===t);if(a)return a;const l=Go(o.updatedAt)-Go(n.updatedAt);return l||String(n.title||n.cwd||n.id).localeCompare(String(o.title||o.cwd||o.id),Ns())})}function sr(e="",t=24,n=2400){const o=On(e).trim();if(!o)return"";const s=o.split(`
26
- `);let a=s.slice(0,t).join(`
27
- `);return a.length>n&&(a=`${a.slice(0,n).trimEnd()}...`),s.length>t?`${a}
28
- ...`:a}function yn(e=[]){const t=Array.isArray(e)?e:[];return t.length?t.map(n=>{const o=String((n==null?void 0:n.status)||"").trim().toLowerCase();return`${n.completed?"[x]":o==="in_progress"?"[-]":"[ ]"} ${n.text||j("未命名任务","Untitled Task")}`}).join(`
29
- `):""}function It(e=0){const t=Number(e||0);return Number.isFinite(t)?t.toLocaleString(Ns()):"0"}function Df(e=""){const t=String(e||"").trim().toLowerCase();return["completed","complete","succeeded","success","done"].includes(t)?"completed":["failed","error","errored","cancelled","canceled","stopped"].includes(t)?"failed":["running","in_progress","in-progress"].includes(t)?"running":["pending_init","pending"].includes(t)?"pending_init":t||"pending_init"}function or(e={}){const t=[],n=o=>{const s=String(o||"").trim();!s||t.includes(s)||t.push(s)};return(Array.isArray(e.receiver_thread_ids)?e.receiver_thread_ids:[]).forEach(n),e.agents_states&&typeof e.agents_states=="object"&&Object.keys(e.agents_states).forEach(n),t}function Ds(e={}){return or(e).length}function ar(e={}){const t=or(e),n=e.agents_states&&typeof e.agents_states=="object"?e.agents_states:{};return t.map(o=>{const s=n[o]&&typeof n[o]=="object"?n[o]:{},a=String(s.message||s.result||"").trim();return{id:o,status:Df(s.status),title:String(s.title||s.description||s.name||"").trim(),role:String(s.role||s.subagent_type||s.agent||"").trim(),target:String(s.target||s.path||"").trim(),model:String(s.model||"").trim(),message:a,messageBlocks:a?bn(a):[]}})}function Lf(e={},t=120){const n=ar(e).map(o=>o.message).filter(Boolean);return pt(n.join(ln()?" | ":"|"),t)}function rr(e=0){const t=Math.max(0,Math.floor(Number(e)||0));if(t<66)return`${t}s`;const n=Math.floor(t/3600),o=Math.floor(t%3600/60),s=t%60;return n>0?ln()?`${n}h ${o}m ${s}s`:`${n}小时${o}分${s}秒`:ln()?`${o}m ${s}s`:`${o}分${s}秒`}function pt(e="",t=140){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,t)}...`:""}function ir(e="",t=[]){const n=t.filter(Boolean);if(!n.length)return"";const o=n.map(s=>`- ${s}`).join(`
30
- `);return e?`${e}
31
- ${o}`:o}function es(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.label)||"").trim(),value:String((n==null?void 0:n.value)||"").trim()})).filter(n=>n.label&&n.value);return t.length?{type:"meta",items:t}:null}function Mf(e=""){const t=String(e||"").trim().toLowerCase();return["done","completed","complete","checked"].includes(t)?"completed":["in_progress","in-progress","active","doing","running"].includes(t)?"in_progress":"pending"}function Bf(e={}){return[e==null?void 0:e.text,e==null?void 0:e.content,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.activeForm].map(n=>String(n||"").trim()).find(Boolean)||j("未命名任务","Untitled Task")}function Ts(e=[]){return(Array.isArray(e)?e:[]).map(t=>{if(!t||typeof t!="object")return null;const n=Mf(t.status??(t.completed?"completed":"pending"));return{completed:n==="completed",status:n,text:Bf(t)}}).filter(Boolean)}function Yo(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return Ts(n);if(n&&typeof n=="object"){if(Array.isArray(n.todos))return Ts(n.todos);if(Array.isArray(n.items))return Ts(n.items)}}catch{return[]}return[]}function lr(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];return t.length?{type:"checklist",items:t,totalCount:t.length,hiddenCount:0}:null}function Bo(e=""){var x;const t=String(e||"").trim(),n=t.indexOf(":"),o=n>0&&n<=24,s=o?t.slice(0,n).trim():"",a=o?t.slice(n+1).trim():t,l=s.toLowerCase(),h=o?((x=Object.entries({shell:["bash","shell","sh","terminal","cmd","powershell"],read:["read","open","view","cat"],grep:["grep","rg","search","find"],list:["glob","ls","dir","tree","list"],web:["websearch","web_search","webfetch","fetch","browse","open_page"],todo:["todowrite","todo","tasklist","tasks"],edit:["edit","multiedit","write","patch","apply_patch","replace","create"]}).find(([,c])=>c.includes(l)))==null?void 0:x[0])||"generic":"shell";return{raw:t,toolName:s,normalizedTool:l,subject:a,category:h}}function ts(e={},t=null){const n=t||Bo(e.command);if(n.category!=="todo")return[];const o=Yo(e.aggregated_output);return o.length?o:Yo(n.subject)}function bn(e="",t={}){return Mo(On(e),t)}function Jo(e={}){const t=e.action||{},n=String(e.query||t.query||"").trim(),o=Array.isArray(t.queries)?t.queries.map(d=>String(d||"").trim()).filter(Boolean):[],s=String(t.url||"").trim(),a=[],l=es([n?{label:j("关键词","Query"),value:n}:null,s?{label:"URL",value:s}:null]);return l&&a.push(l),o.length>1&&a.push({type:"bullet_list",items:o,totalCount:o.length,hiddenCount:0}),a}function Qo(e={}){const t=String(e.tool||"").trim(),n=Ds(e),o=String(e.prompt||"").trim(),s=ar(e),a=[],l=[t?{label:j("工具","Tool"),value:t}:null,n?{label:j("子代理","Sub-agent"),value:String(n)}:null],d=es(l);return d&&a.push(d),s.length&&a.push({type:"sub_agent_list",items:s,totalCount:s.length,hiddenCount:0}),o&&a.push(...bn(o,{preferMarkdown:!0})),a}function Zo(e={}){const t=Array.isArray(e.changes)?e.changes:[];return t.length?[{type:"file_changes",items:t.map(n=>({kind:String((n==null?void 0:n.kind)||"").trim(),path:String((n==null?void 0:n.path)||"").trim()})),totalCount:t.length,hiddenCount:0}]:[]}function gs(e={},t=!1,n="codex"){const o=[],s=Bo(e.command),a=ts(e,s),l=lr(a),d=typeof e.exit_code=="number",h=d?e.exit_code===0:e.status==="completed",x=es([s.toolName?{label:j("工具","Tool"),value:s.toolName}:null,l||s.category!=="shell"?null:s.subject?{label:j("命令","Command"),value:s.subject}:e.command?{label:j("命令","Command"),value:e.command}:null,n&&n!=="codex"?{label:j("引擎","Engine"),value:lt(n)}:null,d&&!h?{label:j("退出码","Exit code"),value:String(e.exit_code)}:null]);if(x&&o.push(x),l&&o.push(l),t){if(l)return o;const c=sr(e.aggregated_output);c&&o.push(...bn(c,{preferMarkdown:s.category==="web"||s.category==="edit"}))}return o}function In(e={}){const t=Bo(e.command);return{groupType:["read","grep","list","web","todo"].includes(t.category)?t.category:"",groupTarget:t.subject||e.command||"",toolName:t.toolName||""}}function so(e={}){const t=Array.isArray(e.items)?Ts(e.items):[];return t.length?[lr(t)]:[]}function jn(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function ho(e=[],t=""){const n=String(t||"").trim();return n&&(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.runId)===n)||null}function Rf(e,t,n,o,s){const a=ho(e,t);return a?(a.events=[],a.lastEventSeq=0,a.summary=jn(),((n==null?void 0:n.items)||[]).forEach(l=>{No(a,l,o,s)}),a.eventCount=Math.max(Math.max(0,Number(a.eventCount)||0),Array.isArray(n==null?void 0:n.items)?n.items.length:0,Math.max(0,Number(a.lastEventSeq)||0)),a.eventsLoaded=!0,a.eventsLoading=!1,a):null}function Ls(e={}){return Eo(e==null?void 0:e.engine)}function Pt(e={}){return lt(Ls(e))}function ns(e=""){return Pf.has(String(e||"").trim())}function Ro(e=""){const t=String(e||"").trim();if(!t)return null;const n=t.match(/^Reconnecting\.\.\.\s*(\d+)\/(\d+)\s*\(([\s\S]+)\)$/i);return n?{attempt:Number(n[1]||0),total:Number(n[2]||0),reason:String(n[3]||"").trim(),rawMessage:t}:null}function ea(e={},t="completed"){const n=e.action||{},o=String(n.type||"").trim(),s=String(e.query||n.query||"").trim(),a=Array.isArray(n.queries)?n.queries.map(d=>String(d||"").trim()).filter(Boolean):[],l=String(n.url||s||"").trim();return o==="search"?{kind:"command",title:t==="started"?j("正在搜索网页","Searching the web"):j("已搜索网页","Web search completed"),detail:ir(s?j(`关键词:${s}`,`Query: ${s}`):"",a.length>1?a:[])}:o==="open_page"?{kind:"command",title:t==="started"?j("正在打开网页","Opening page"):j("已打开网页","Page opened"),detail:l}:{kind:"command",title:t==="started"?j("准备网页检索","Preparing web search"):j("网页检索已更新","Web search updated"),detail:s}}function ta(e={},t="completed"){const n=String(e.tool||"").trim(),o=Ds(e),s=pt(e.prompt);return n==="spawn_agent"?{kind:"todo",title:t==="started"?j("正在启动子代理","Starting sub-agent"):j(`已启动 ${o||1} 个子代理`,`Started ${o||1} sub-agent(s)`),detail:s?j(`任务:${s}`,`Task: ${s}`):""}:n==="wait"?{kind:"todo",title:t==="started"?o?j(`等待 ${o} 个子代理返回结果`,`Waiting for ${o} sub-agent result(s)`):j("等待子代理返回结果","Waiting for sub-agent results"):j("子代理结果已汇总","Sub-agent results aggregated"),detail:s?j(`等待内容:${s}`,`Waiting on: ${s}`):""}:{kind:"todo",title:t==="started"?j(`正在执行协作工具:${n||"未知工具"}`,`Running collaboration tool: ${n||"Unknown tool"}`):j(`协作工具完成:${n||"未知工具"}`,`Collaboration tool completed: ${n||"Unknown tool"}`),detail:s?j(`任务:${s}`,`Task: ${s}`):""}}function na(e={},t="completed"){const n=Array.isArray(e.changes)?e.changes:[],o={create:j("新增","Added"),update:j("更新","Updated"),delete:j("删除","Deleted")};return{kind:"command",title:t==="started"?j("正在整理文件变更","Collecting file changes"):j(`已记录 ${n.length||0} 个文件改动`,`Recorded ${n.length||0} file change(s)`),detail:ir("",n.map(s=>{const a=String((s==null?void 0:s.path)||"").trim();return`${o[String((s==null?void 0:s.kind)||"").trim()]||j("变更","Changed")} ${a||j("未命名文件","Unnamed file")}`}))}}function Nf(e,t={}){var l,d,h,x,c,m,f,k;e!=null&&e.summary||(e.summary=jn());const n=e.summary,o=Pt(e),s=String(t.type||"").trim(),a=t.item||{};if(s===gt.TURN_STARTED){n.currentActivity=j("正在分析任务","Analyzing task"),n.latestActivity=j(`${o} 开始执行`,`${o} started`),n.latestDetail="";return}if(s===gt.TURN_COMPLETED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=j(`${o} 执行完成`,`${o} completed`),n.latestDetail="";return}if(s===gt.TURN_FAILED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=j("本轮运行失败","This run failed"),n.latestDetail="";return}if(s===gt.ERROR){const y=Ro(ss(t));if(y){n.currentActivity=j(`网络异常,正在重试 (${y.attempt}/${y.total})`,`Network error, retrying (${y.attempt}/${y.total})`),n.latestActivity=n.currentActivity,n.latestDetail=pt(y.reason,120);return}n.currentActivity="",n.latestActivity=j(`${o} 返回错误`,`${o} returned an error`),n.latestDetail=pt(ss(t),120);return}if(s===gt.ITEM_STARTED){if(a.type===nt.REASONING){n.currentActivity=j("正在思考","Thinking"),n.latestActivity=j("正在思考","Thinking"),n.latestDetail=pt(a.text,120);return}if(a.type===nt.COMMAND_EXECUTION){if(In(a).groupType==="todo"){const L=yn(ts(a));n.currentActivity=j("正在更新待办列表","Updating todo list"),n.latestActivity=j("正在更新待办列表","Updating todo list"),n.latestDetail=pt(L,120);return}n.currentActivity=j("正在执行命令","Running command"),n.latestActivity=j("开始执行命令","Command started"),n.latestDetail=pt(a.command,120);return}if(a.type===nt.WEB_SEARCH){n.currentActivity=((l=a.action)==null?void 0:l.type)==="open_page"?j("正在打开网页","Opening page"):j("正在搜索网页","Searching the web"),n.latestActivity=n.currentActivity,n.latestDetail=pt(((d=a.action)==null?void 0:d.type)==="open_page"?((h=a.action)==null?void 0:h.url)||a.query:a.query||((x=a.action)==null?void 0:x.query),120);return}if(a.type===nt.COLLAB_TOOL_CALL){if(a.tool==="wait"){const y=Ds(a);n.waitingAgentCount=y,n.currentActivity=y?j(`等待 ${y} 个子代理返回结果`,`Waiting for ${y} sub-agent result(s)`):j("等待子代理返回结果","Waiting for sub-agent results"),n.latestActivity=n.currentActivity,n.latestDetail=pt(a.prompt,120);return}if(a.tool==="spawn_agent"){n.currentActivity=j("正在启动子代理","Starting sub-agent"),n.latestActivity=j("正在启动子代理","Starting sub-agent"),n.latestDetail=pt(a.prompt,120);return}}if(a.type===nt.FILE_CHANGE){n.currentActivity=j("正在整理文件变更","Collecting file changes"),n.latestActivity=j("正在整理文件变更","Collecting file changes"),n.latestDetail=pt((a.changes||[]).map(y=>y==null?void 0:y.path).filter(Boolean).join(ln()?", ":","),120);return}a.type===nt.TODO_LIST&&(n.currentActivity=j("正在规划执行步骤","Planning steps"),n.latestActivity=j("正在规划执行步骤","Planning steps"),n.latestDetail=pt((a.items||[]).map(y=>y==null?void 0:y.text).filter(Boolean).join(ln()?"; ":";"),120));return}if(s===gt.ITEM_COMPLETED){if(a.type===nt.COMMAND_EXECUTION){if(In(a).groupType==="todo"){n.currentActivity="",n.latestActivity=j("待办列表已更新","Todo list updated"),n.latestDetail=pt(yn(ts(a)),120);return}n.commandCount+=1,n.currentActivity="",n.latestActivity=j("命令执行完成","Command completed"),n.latestDetail=pt(a.command,120);return}if(a.type===nt.WEB_SEARCH){n.webSearchCount+=1,n.currentActivity="",n.latestActivity=((c=a.action)==null?void 0:c.type)==="open_page"?j("已打开网页","Page opened"):j("已搜索网页","Web search completed"),n.latestDetail=pt(((m=a.action)==null?void 0:m.type)==="open_page"?((f=a.action)==null?void 0:f.url)||a.query:a.query||((k=a.action)==null?void 0:k.query),120);return}if(a.type===nt.COLLAB_TOOL_CALL){if(a.tool==="spawn_agent"){const y=Ds(a);n.subAgentCount+=y,n.currentActivity="",n.latestActivity=y?j(`已启动 ${y} 个子代理`,`Started ${y} sub-agent(s)`):j("已启动子代理","Started sub-agent"),n.latestDetail=pt(a.prompt,120);return}if(a.tool==="wait"){n.waitingAgentCount=0,n.currentActivity="",n.latestActivity=j("子代理结果已汇总","Sub-agent results aggregated"),n.latestDetail=Lf(a,120)||pt(a.prompt,120);return}n.currentActivity="",n.latestActivity=j(`协作工具完成:${a.tool||"未知工具"}`,`Collaboration tool completed: ${a.tool||"Unknown tool"}`),n.latestDetail=pt(a.prompt,120);return}if(a.type===nt.FILE_CHANGE){const y=Array.isArray(a.changes)?a.changes:[];n.fileChangeCount+=y.length,n.currentActivity="",n.latestActivity=y.length?j(`已记录 ${y.length} 个文件改动`,`Recorded ${y.length} file change(s)`):j("已记录文件改动","Recorded file changes"),n.latestDetail=pt(y.map(L=>L==null?void 0:L.path).filter(Boolean).join(ln()?", ":","),120);return}if(a.type===nt.TODO_LIST){n.currentActivity="",n.latestActivity=j("待办列表已更新","Todo list updated"),n.latestDetail=pt((a.items||[]).map(y=>y==null?void 0:y.text).filter(Boolean).join(ln()?"; ":";"),120);return}a.type===nt.AGENT_MESSAGE&&(n.currentActivity="",n.latestActivity=j(`${o} 已返回结果`,`${o} returned a result`),n.latestDetail=pt(a.text,120))}}function Of(e={},t={}){const n=Date.parse(String(e.startedAt||""));if(!Number.isFinite(n))return 0;if(ns(e.status)){if(t.currentRunningRunId&&String(t.currentRunningRunId)===String(e.runId||"")&&Number.isFinite(Number(t.runningElapsedSeconds)))return Math.max(0,Math.floor(Number(t.runningElapsedSeconds)||0));const s=Number(t.nowMs)||Date.now();return Math.max(0,Math.floor((s-n)/1e3))}const o=Date.parse(String(e.finishedAt||""));return Number.isFinite(o)&&o>=n?Math.max(0,Math.floor((o-n)/1e3)):0}function ur(e={},t={}){const n=e.summary||jn(),o=[],s=Of(e,t);return s>0&&o.push({key:"elapsed",label:j("耗时","Elapsed"),value:rr(s)}),n.webSearchCount&&o.push({key:"web",label:j("网页","Web"),value:It(n.webSearchCount)}),n.commandCount&&o.push({key:"command",label:j("命令","Command"),value:It(n.commandCount)}),n.fileChangeCount&&o.push({key:"file",label:j("改动","Changes"),value:It(n.fileChangeCount)}),n.subAgentCount&&o.push({key:"agent",label:j("子代理","Sub-agent"),value:It(n.subAgentCount)}),o}function cr(e={}){const t=e.summary||jn();return t.waitingAgentCount>0?j(`当前:等待 ${It(t.waitingAgentCount)} 个子代理返回结果`,`Current: waiting for ${It(t.waitingAgentCount)} sub-agent result(s)`):t.currentActivity?j(`当前:${t.currentActivity}`,`Current: ${t.currentActivity}`):t.latestActivity?j(`最近:${t.latestActivity}`,`Latest: ${t.latestActivity}`):ns(e.status)?j(`当前:正在等待 ${Pt(e)} 返回更多事件`,`Current: waiting for more events from ${Pt(e)}`):""}function dr(e={}){const t=e.summary||jn();return String(t.latestDetail||"").trim()}function jf(e={}){return!!(ur(e).length||cr(e)||dr(e))}const Ff=[{type:"startup_config",title:e=>j(`${lt(e)} 启动配置冲突`,`${lt(e)} startup config conflict`),summary:e=>j(`${lt(e)} 当前启动参数可能与本机包装脚本、别名或外部环境配置冲突,请检查 CLI 启动方式。`,`${lt(e)} startup arguments may conflict with your local wrapper script, alias, or external environment configuration. Please check how the CLI is launched.`),patterns:[/not inside a trusted directory/i,/do you trust the contents of this directory/i,/trusted directory/i,/skip-git-repo-check/i,/prompt injection/i,/目录.*信任/,/可信目录/]},{type:"billing",title:j("额度或账单异常","Quota or billing issue"),summary:e=>j(`${lt(e)} 可能因为额度不足、欠费或账单限制而无法继续执行。`,`${lt(e)} may be unable to continue due to quota exhaustion, billing issues, or account limits.`),patterns:[/insufficient_quota/i,/exceeded your current quota/i,/\bquota\b/i,/\bbilling\b/i,/credit balance/i,/payment required/i,/余额不足/,/欠费/,/账单/,/充值/]},{type:"permission",title:j("权限不足","Insufficient permissions"),summary:e=>j(`${lt(e)} 当前权限不够,无法访问所需文件、命令或资源。`,`${lt(e)} does not currently have permission to access the required files, commands, or resources.`),patterns:[/permission denied/i,/insufficient permissions?/i,/forbidden/i,/unauthorized/i,/authentication_failed/i,/invalid token/i,/invalid api key/i,/\b401\b/,/access denied/i,/not allowed/i,/权限不足/,/没有权限/,/无权/,/拒绝访问/,/无效的令牌/]},{type:"rate_limit",title:j("请求过于频繁","Too many requests"),summary:e=>j(`${lt(e)} 可能触发了限流,请稍后再试。`,`${lt(e)} may have hit a rate limit. Please try again later.`),patterns:[/rate limit/i,/too many requests/i,/\b429\b/,/请求过于频繁/,/限流/]},{type:"context_limit",title:j("上下文过长","Context too long"),summary:j("这次发送的内容可能过长,超过了模型可处理的上下文限制。","The content sent in this run may be too long and exceed the model context limit."),patterns:[/context length/i,/maximum context length/i,/context_length_exceeded/i,/token limit/i,/prompt is too long/i,/上下文过长/,/超过.*token/i,/超出.*上下文/]},{type:"model_unavailable",title:j("模型或服务暂不可用","Model or service unavailable"),summary:e=>j(`${lt(e)} 背后的模型或服务当前不可用,请稍后重试。`,`The model or service behind ${lt(e)} is currently unavailable. Please try again later.`),patterns:[/model .*not found/i,/model .*unavailable/i,/service unavailable/i,/server error/i,/overloaded/i,/\b503\b/,/模型不可用/,/服务不可用/]},{type:"network",title:j("网络连接异常","Network connection issue"),summary:e=>j(`${lt(e)} 在请求过程中遇到了网络问题或连接超时。`,`${lt(e)} encountered a network problem or timeout while making the request.`),patterns:[/timed out/i,/\btimeout\b/i,/stream disconnected/i,/error sending request/i,/connection reset/i,/connection closed/i,/socket hang up/i,/network error/i,/fetch failed/i,/econnreset/i,/econnrefused/i,/enotfound/i,/network is unreachable/i,/temporary failure in name resolution/i,/网络异常/,/连接超时/]},{type:"cli_missing",title:e=>j(`${lt(e)} CLI 不可用`,`${lt(e)} CLI unavailable`),summary:e=>j(`当前环境没有正确安装或配置 ${lt(e)} CLI。`,`${lt(e)} CLI is not correctly installed or configured in the current environment.`),patterns:[/找不到 Codex CLI/,/找不到 Claude Code CLI/,/找不到 OpenCode CLI/,/codex --version/i,/claude --version/i,/opencode --version/i,/enoent/i,/not recognized as an internal or external command/i,/command not found/i]}];function Nn(e="",t="codex"){const n=On(e).trim();if(!n)return null;const o=Ff.find(s=>s.patterns.some(a=>a.test(n)));return o?{type:o.type,title:typeof o.title=="function"?o.title(t):o.title,summary:typeof o.summary=="function"?o.summary(t):o.summary,rawMessage:n}:null}function tn(e="",t="codex"){const n=On(e).trim();if(!n)return"";const o=Nn(n,t);return o?`${o.summary}
32
-
33
- ${j("原始错误","Raw error")}: ${o.rawMessage}`:n}function vo(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return On(e).trim();if(typeof e!="object")return"";const n=["message","detail","error","last_error","cause","reason","stderr","text","summary"];for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const s=vo(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=vo(o,t+1);if(s)return s}return""}function ss(e={}){return vo(e)}function Uf(e={},t="Codex",n="codex"){var a,l,d,h;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:j(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===gt.THREAD_STARTED){const x=e.thread_id?j(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:j(`${t} 会话已创建`,`${t} session created`),detail:x,detailBlocks:x?[es([{label:"ID",value:e.thread_id}])]:[]}}if(o===gt.TURN_STARTED)return{title:j(`${t} 开始执行`,`${t} started`),detail:""};if(o===gt.TURN_COMPLETED){const x=e.usage?[j(`输入 ${It(e.usage.input_tokens)}`,`Input ${It(e.usage.input_tokens)}`),e.usage.cached_input_tokens?j(`缓存 ${It(e.usage.cached_input_tokens)}`,`Cached ${It(e.usage.cached_input_tokens)}`):"",j(`输出 ${It(e.usage.output_tokens)}`,`Output ${It(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:j(`${t} 执行完成`,`${t} completed`),detail:x,detailBlocks:e.usage?[es([{label:j("输入","Input"),value:It(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:j("缓存","Cached"),value:It(e.usage.cached_input_tokens)}:null,{label:j("输出","Output"),value:It(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===gt.ERROR||o===gt.TURN_FAILED){const x=ss(e)||j(`${t} 执行失败`,`${t} failed`),c=o===gt.ERROR?Ro(x):null;if(c)return{kind:"info",title:j(`网络异常,正在重试 (${c.attempt}/${c.total})`,`Network error, retrying (${c.attempt}/${c.total})`),detail:tn(c.reason||c.rawMessage,n),detailBlocks:bn(tn(c.reason||c.rawMessage,n),{preferMarkdown:!0})};const m=Nn(x,n);return{kind:"error",title:(m==null?void 0:m.title)||(o===gt.TURN_FAILED?j("本轮运行失败","This run failed"):j(`${t} 返回错误`,`${t} returned an error`)),detail:tn(x,n),detailBlocks:bn(tn(x,n),{preferMarkdown:!0})}}if(o===gt.ITEM_STARTED)return s.type===nt.REASONING?{kind:"reasoning",title:j("思考过程","Thinking"),detail:s.text||"",detailBlocks:bn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===nt.WEB_SEARCH?{...ea(s,"started"),detailBlocks:Jo(s),groupType:"web",groupTarget:String(s.query||((a=s.action)==null?void 0:a.query)||((l=s.action)==null?void 0:l.url)||"").trim(),phase:"started"}:s.type===nt.COLLAB_TOOL_CALL?{...ta(s,"started"),detailBlocks:Qo(s)}:s.type===nt.FILE_CHANGE?{...na(s,"started"),detailBlocks:Zo(s)}:s.type===nt.COMMAND_EXECUTION?In(s).groupType==="todo"?{kind:"todo",title:j("更新待办列表","Update todo list"),detail:yn(ts(s)),detailBlocks:gs(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:j("开始执行命令","Command started"),detail:s.command||"",detailBlocks:gs(s,!1,n),...In(s),phase:"started"}:s.type===nt.TODO_LIST?{kind:"todo",title:j("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:so(s),groupType:"todo",phase:"started"}:{title:j(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===gt.ITEM_UPDATED&&s.type===nt.TODO_LIST)return{kind:"todo",title:j("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:so(s),groupType:"todo",phase:"updated"};if(o===gt.ITEM_COMPLETED){if(s.type===nt.AGENT_MESSAGE&&s.text)return{kind:"result",title:j(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===nt.WEB_SEARCH)return{...ea(s,"completed"),detailBlocks:Jo(s),groupType:"web",groupTarget:String(s.query||((d=s.action)==null?void 0:d.query)||((h=s.action)==null?void 0:h.url)||"").trim(),phase:"completed"};if(s.type===nt.COLLAB_TOOL_CALL)return{...ta(s,"completed"),detailBlocks:Qo(s)};if(s.type===nt.FILE_CHANGE)return{...na(s,"completed"),detailBlocks:Zo(s)};if(s.type===nt.COMMAND_EXECUTION){if(In(s).groupType==="todo"){const m=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:m?"todo":"error",title:m?j("更新待办列表","Update todo list"):j("更新待办列表失败","Todo list update failed"),detail:yn(ts(s)),detailBlocks:gs(s,!0,n),groupType:"todo",phase:"completed"}}const c=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:c?"command":"error",title:c?j("命令执行完成","Command completed"):j(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,sr(s.aggregated_output)].filter(Boolean).join(`
34
-
35
- `),detailBlocks:gs(s,!0,n),...In(s),phase:"completed"}}return s.type===nt.TODO_LIST?{kind:"todo",title:j("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:so(s),groupType:"todo",phase:"completed"}:{title:j(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:j(`事件: ${o}`,`Event: ${o}`),detail:""}}function Vf(e){return e.status==="queued"?j("排队中","Queued"):e.status==="starting"?j("启动中","Starting"):e.status==="stopping"?j("停止中","Stopping"):e.status==="running"?j("进行中","Running"):e.status==="error"?j("失败","Failed"):e.status==="interrupted"?j("已中断","Interrupted"):e.status==="stopped"?j("已停止","Stopped"):e.status==="stop_timeout"?j("停止超时","Stop timeout"):j("已完成","Completed")}function fr(e={},t){if(typeof e=="string"){const a=e.trim();return a?{id:t(),kind:"info",title:a,detail:""}:null}const n=String(e.title||"").trim(),o=String(e.detail||"").trim(),s=Array.isArray(e.detailBlocks)&&e.detailBlocks.length?e.detailBlocks.filter(Boolean):o?bn(o,{preferMarkdown:e.kind==="error"}):[];return!n&&!o?null:{id:t(),kind:e.kind||"info",title:n||o,detail:n?o:"",detailBlocks:s,groupType:String(e.groupType||"").trim(),groupTarget:String(e.groupTarget||"").trim(),toolName:String(e.toolName||"").trim(),phase:String(e.phase||"").trim()}}function zf(e={},t){const n=Array.isArray(e.promptBlocks)?e.promptBlocks.map(o=>({...o,meta:o!=null&&o.meta?{...o.meta}:{},content:(o==null?void 0:o.type)==="image"?ws(o.content):o.content})):[];return{id:t(),runId:String(e.id||"").trim(),engine:Ls(e),prompt:String(e.prompt||"").trim(),promptBlocks:n,status:"completed",startedAt:e.startedAt||e.createdAt||"",finishedAt:e.finishedAt||"",events:[],eventCount:Math.max(0,Number(e.eventCount)||(Array.isArray(e.events)?e.events.length:0)),eventsLoaded:!!e.eventsIncluded,eventsLoading:!1,responseMessage:"",errorMessage:"",lastEventSeq:0,summary:jn()}}function vn(e,t,n){const o=fr(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function Hf(e,t,n){var s;const o=fr(t,n);if(o){for(let a=e.events.length-1;a>=0;a-=1){const l=j("网络异常,正在重试","Network error, retrying");if(String(((s=e.events[a])==null?void 0:s.title)||"").startsWith(l)){e.events.splice(a,1,o);return}}e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120)}}function qf(e,t={},n,o=()=>{}){var a,l,d,h,x,c,m,f,k;const s=Ia(t.type);if(s===Nt.SESSION){o(t.session),e.engine=Ls(t.session||e);return}if(s===Nt.SESSION_UPDATED){o(t.session),e.engine=Ls(t.session||e);return}if(s===Nt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;vn(e,{title:t.message||j("状态已更新","Status updated"),detail:""},n);return}if(s===Nt.STDERR){const y=Nn(t.text,e.engine);vn(e,{kind:"error",title:(y==null?void 0:y.title)||"stderr",detail:tn(t.text,e.engine)},n);return}if(s===Nt.STDOUT){vn(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===Nt.AGENT_EVENT){if(Nf(e,t.event),((a=t.event)==null?void 0:a.type)===gt.THREAD_STARTED)return;const y=Uf(t.event,Pt(e),e.engine);String(y.title||"").startsWith(j("网络异常,正在重试","Network error, retrying"))?Hf(e,y,n):vn(e,y,n),((l=t.event)==null?void 0:l.type)===gt.ITEM_COMPLETED&&((h=(d=t.event)==null?void 0:d.item)==null?void 0:h.type)===nt.AGENT_MESSAGE&&((c=(x=t.event)==null?void 0:x.item)!=null&&c.text)&&(e.responseMessage=t.event.item.text);const L=ss(t.event)||j(`${Pt(e)} 执行失败`,`${Pt(e)} failed`);if(!(((m=t.event)==null?void 0:m.type)==="error"?Ro(L):null)&&(((f=t.event)==null?void 0:f.type)===gt.ERROR||((k=t.event)==null?void 0:k.type)===gt.TURN_FAILED)){const S=ss(t.event)||j(`${Pt(e)} 执行失败`,`${Pt(e)} failed`);e.errorMessage=tn(S,e.engine),e.status="error"}return}if(s===Nt.COMPLETED){vn(e,{kind:"result",title:j("本轮执行结束","Run finished"),detail:""},n),t.message&&(e.responseMessage=t.message);return}if(s===Nt.STOPPED){vn(e,{title:t.message||j("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===Nt.ERROR){const y=Nn(t.message,e.engine);vn(e,{kind:"error",title:(y==null?void 0:y.title)||j("执行失败","Execution failed"),detail:tn(t.message||j(`${Pt(e)} 执行失败`,`${Pt(e)} failed`),e.engine)},n)}}function Kf(e="",t="",n="codex"){const o=String(e||"").trim(),s=String(t||"").trim();if(!s)return!1;if(!o||/no last agent message|wrote empty content/i.test(o)||/执行失败[。.]?$/i.test(o))return!0;const a=Nn(o,n),l=Nn(s,n);return!a&&!!l}function Wf(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=tn(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=Kf(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=j(`本轮 ${Pt(e)} 执行已完成,没有返回额外文本。`,`${Pt(e)} completed in this run without returning additional text.`)),e}function No(e,t={},n,o=()=>{}){const s=Math.max(0,Number(t==null?void 0:t.seq)||0);if(s&&s<=Number(e.lastEventSeq||0))return!1;const a=(t==null?void 0:t.payload)||{};qf(e,a,n,o);const l=Ia(a.type);return l===Nt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===Nt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===Nt.ERROR&&(e.status="error",e.errorMessage=tn(String(a.message||e.errorMessage||j(`${Pt(e)} 执行失败`,`${Pt(e)} failed`)),e.engine),e.finishedAt=new Date().toISOString()),s&&(e.lastEventSeq=s),e.eventCount=Math.max(Math.max(0,Number(e.eventCount)||0),s,Array.isArray(e.events)?e.events.length:0),(s||Array.isArray(e.events)&&e.events.length)&&(e.eventsLoaded=!0),!0}function sa(e,t,n,o){const s=zf(e,t);return(e.events||[]).forEach(a=>{No(s,a,n,o)}),Wf(s,e)}const Gf=1800,oa=7200,Xf=15e3,oo={clearTaskCodexRuns:Qi,listCodexRunEvents:Yi,listTaskCodexRuns:Xi};function Qn(e={},t=!0){const n={id:String((e==null?void 0:e.runId)||(e==null?void 0:e.id)||"").trim(),prompt:String((e==null?void 0:e.prompt)||"").trim(),promptBlocks:Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks.map(o=>({type:String((o==null?void 0:o.type)||"").trim(),content:String((o==null?void 0:o.content)||"")})):[],responseMessage:String((e==null?void 0:e.responseMessage)||""),errorMessage:String((e==null?void 0:e.errorMessage)||"")};return t?{...n,status:String((e==null?void 0:e.status)||"").trim(),updatedAt:String((e==null?void 0:e.updatedAt)||""),eventCount:Math.max(0,Number(e==null?void 0:e.eventCount)||0),lastEventSeq:Math.max(0,Number(e==null?void 0:e.lastEventSeq)||0)}:n}function Yf(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>Qn(o,t)))}function Jf(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function Qf(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:a,currentRunningRunId:l,sessionError:d,supportsServerEvents:h,scheduleScrollToBottom:x,resetAutoStickToBottom:c,mergeSessionRecord:m,mergeSession:f,loadSessions:k,showProcessLogs:y}=e;let L=0,te=0,S=null,M="",N=null,H=null,V="",ne=!!(y!=null&&y.value),I=0;const X=new Map;function le(){return L+=1,L}function ce(){return te+=1,te}function D(){N&&(window.clearInterval(N),N=null)}function Q(){H&&(window.clearInterval(H),H=null)}function re(){I=Date.now()}function ae(){X.clear(),n.value=[],s.value=!1,a.value=0,l.value="",V="",M="",L=0,te=0,c()}function ge(){const O=[...n.value].reverse().find(J=>ns(J.status))||null;if(l.value=(O==null?void 0:O.runId)||"",s.value=!!O,O!=null&&O.startedAt){const J=Date.parse(String(O.startedAt||""));a.value=Number.isFinite(J)?J:Date.now();return}a.value=0}function C(O=null){return O?{...O}:Jf()}function q(O,J=null){if(!(J!=null&&J.runId)||O.eventsLoaded||!J.eventsLoaded)return X.has(O.runId)&&(O.eventsLoading=!0),O;const de=Math.max(Math.max(0,Number(J.lastEventSeq)||0),Math.max(0,Number(J.eventCount)||0),Array.isArray(J.events)?J.events.length:0),ye=Math.max(0,Number(O.eventCount)||0);return de<ye?(X.has(O.runId)&&(O.eventsLoading=!0),O):(O.events=Array.isArray(J.events)?[...J.events]:[],O.eventCount=Math.max(Math.max(0,Number(O.eventCount)||0),Math.max(0,Number(J.eventCount)||0),O.events.length),O.eventsLoaded=!0,O.eventsLoading=X.has(O.runId),O.lastEventSeq=Math.max(0,Number(J.lastEventSeq)||0),O.summary=C(J.summary),O)}function U(O,J){const de=ho(n.value,O);return de?(de.eventsLoading=!!J,n.value=[...n.value],de):null}async function Ve(O,J={}){const de=String((O==null?void 0:O.runId)||"").trim(),{force:ye=!1}=J;if(!de)return[];const pe=ho(n.value,de)||O;if(pe!=null&&pe.eventsLoaded&&!ye)return pe.events;if(X.has(de))return X.get(de);U(de,!0);const Ee=(async()=>{var Ce;try{const Pe=Qn(pe,!!(y!=null&&y.value)),Re=await oo.listCodexRunEvents(de,{limit:5e3}),Ke=Rf(n.value,de,Re,ce,De=>{f(De,{preserveRunning:!0})});if(!Ke)return Array.isArray(pe==null?void 0:pe.events)?pe.events:[];const ot=JSON.stringify(Pe)!==JSON.stringify(Qn(Ke,!!(y!=null&&y.value)));return n.value=[...n.value],ot&&t.active&&((Ce=n.value.at(-1))==null?void 0:Ce.runId)===de&&x(),Ke.events}catch(Pe){throw d.value=Pe.message,Pe}finally{U(de,!1),X.delete(de)}})();return X.set(de,Ee),Ee}function Ae(O,J){const de=String(O||"").trim();if(!de||!J)return!1;const ye=n.value.findIndex(Re=>Re.runId===de);if(ye<0)return!1;const pe=n.value[ye],Ee=Qn(pe,!!(y!=null&&y.value));if(!No(pe,J,ce,Re=>{f(Re,{preserveRunning:!0})}))return!0;const Pe=JSON.stringify(Ee)!==JSON.stringify(Qn(pe,!!(y!=null&&y.value)));return n.value=[...n.value],ge(),Pe&&x(),!0}function Oe(){if(D(),Q(),!(!t.active||!s.value||!t.taskSlug)){if(h){H=window.setInterval(()=>{qe({force:!0}).catch(()=>{});const O=Date.now();O-I<oa||(I=O,k({force:!0}).catch(()=>{}))},Xf);return}N=window.setInterval(()=>{qe({force:!0}).catch(()=>{});const O=Date.now();O-I<oa||(I=O,k({force:!0}).catch(()=>{}))},Gf)}}function Ne(O=[]){const J=[...o.value],de=new Map(n.value.filter(pe=>String((pe==null?void 0:pe.runId)||"").trim()).map(pe=>[String(pe.runId||"").trim(),pe])),ye=pe=>{if(!(pe!=null&&pe.id))return;const Ee=J.findIndex(Ce=>Ce.id===pe.id);Ee>=0?J[Ee]=m(J[Ee],pe,{preserveRunning:!0}):J.unshift(m(null,pe,{preserveRunning:!0}))};L=0,te=0,n.value=[...O||[]].reverse().map(pe=>{const Ee=sa(pe,le,ce,ye);return q(Ee,de.get(String((pe==null?void 0:pe.id)||"").trim())||null)}),o.value=J,ge()}async function qe(O={}){const{force:J=!1,scrollToLatest:de=!1}=O,ye=String(t.taskSlug||"").trim();if(!(!ye||!t.active&&!J))return S&&M===ye||S&&!J||(M=ye,S=(async()=>{try{const Ee=(await oo.listTaskCodexRuns(ye,{limit:30,events:"latest"})).items||[],Ce=!!(y!=null&&y.value),Pe=Yf(Ee,Ce),Re=de||V&&ne===Ce&&Pe!==V;Ne(Ee),V=Pe,ne=Ce,Oe();const Ke=n.value.at(-1)||null;if(Ke!=null&&Ke.runId&&!Ke.eventsLoaded){const ot=Ke.runId;Ve(Ke).catch(()=>{}).finally(()=>{var De;de&&t.active&&((De=n.value.at(-1))==null?void 0:De.runId)===ot&&x({force:!0})})}Re&&x({force:de})}catch(pe){d.value=pe.message}finally{S=null,M=""}})()),S}function et(O={}){const J=(O==null?void 0:O.run)||null,de=(O==null?void 0:O.session)||null;if(de&&f(de,{preserveRunning:!0}),!(J!=null&&J.id)){ge(),x({force:!0});return}const pe=sa(J,le,ce,Ce=>{f(Ce,{preserveRunning:!0})}),Ee=n.value.findIndex(Ce=>Ce.runId===pe.runId);if(Ee>=0){const Ce=[...n.value];Ce.splice(Ee,1,pe),n.value=Ce}else n.value=[...n.value,pe];ge(),x({force:!0})}async function we(){if(!(!t.taskSlug||s.value))try{await oo.clearTaskCodexRuns(t.taskSlug),ae(),x({force:!0})}catch(O){d.value=O.message}}return{applyCreatedRun:et,applyIncomingRunEvent:Ae,clearRealtimeReconcileTimer:Q,clearRunPollTimer:D,clearTurns:we,loadTurnEvents:Ve,markFallbackSessionPollNow:re,refreshRunHistory:qe,resetRunHistoryState:ae,syncRunningStateFromTurns:ge,updatePollingState:Oe}}const Zf=1500,ep=3e4;function tp(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:a,sending:l,stopping:d,sessionError:h,showManager:x,selectedSessionId:c,currentRunningRunId:m,supportsServerEvents:f,mergeSession:k,applyCreatedRun:y,refreshRunHistory:L,markFallbackSessionPollNow:te,showToast:S,getActiveAgentBinding:M=null}=e;let N=null,H=null,V=0,ne=0;const I=G(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),X=G(()=>n.value.length>0),le=G(()=>Xo(n.value,c.value)),ce=G(()=>X.value?"":We("projectManager.noProjects"));async function D(we={}){const{force:O=!1}=we;if(N)return N;const J=Date.now();return!O&&V&&J-V<Zf?{items:n.value,workspaces:o.value}:(N=(async()=>{s.value=!0,h.value="";try{const ye=(await Oi()).items||[];return n.value=ye,V=Date.now(),{items:ye,workspaces:o.value}}catch(de){throw h.value=de.message,de}finally{s.value=!1,N=null}})(),N)}async function Q(we={}){const{force:O=!1}=we;if(H)return H;const J=Date.now();return!O&&ne&&J-ne<ep?{items:o.value}:(H=(async()=>{try{const de=await ji();return o.value=de.items||[],ne=Date.now(),{items:o.value}}finally{H=null}})(),H)}async function re(we={}){const{forceSessions:O=!1,forceWorkspaces:J=!1}=we,[de,ye]=await Promise.all([D({force:O}),Q({force:J})]);return{items:(de==null?void 0:de.items)||n.value,workspaces:(ye==null?void 0:ye.items)||o.value}}function ae(we=""){const O=String(we||"").trim();!O||o.value.includes(O)||(o.value=[O,...o.value])}function ge(){x.value=!0,Q().catch(()=>{})}function C(){x.value=!1}function q(we){const O=String(we||"").trim();if(t.sessionSelectionLocked&&O&&O!==c.value){h.value=t.sessionSelectionLockReason||We("taskActions.sessionLocked");return}c.value=O}function U(){re({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function Ve(we){a.value=!0,h.value="";try{const O=await Fi(we);return k(O),ae(O.cwd),c.value=O.id,O}catch(O){throw h.value=O.message,O}finally{a.value=!1}}async function Ae(we,O){a.value=!0,h.value="";try{const J=await Ui(we,O);return k(J),ae(J.cwd),J}catch(J){throw h.value=J.message,J}finally{a.value=!1}}async function Oe(we){var J;const O=String(we||"").trim();if(!O)return{deletedSessionId:"",selectedSessionId:c.value};a.value=!0,h.value="";try{await Vi(O);const de=n.value.filter(pe=>pe.id!==O);n.value=de;let ye=c.value;return c.value===O&&(ye=((J=Xo(de,"")[0])==null?void 0:J.id)||"",c.value=ye),{deletedSessionId:O,selectedSessionId:ye}}catch(de){throw h.value=de.message,de}finally{a.value=!1}}async function Ne(we){const O=String(we||"").trim();if(!O)return null;a.value=!0,h.value="";try{const J=await zi(O);return J!=null&&J.session&&k(J.session),te(),await Promise.all([L({force:!0}),D({force:!0})]),S==null||S({message:We("projectManager.sessionReset"),type:"success"}),J}catch(J){throw h.value=J.message,J}finally{a.value=!1}}async function qe(){if(!t.taskSlug||!I.value||l.value||d.value)return!1;if(!c.value){const we=We("projectManager.selectProject");return h.value=we,S==null||S({message:we,type:"warning"}),!1}h.value="";try{await re({forceSessions:!0});const we=n.value.find(Re=>Re.id===c.value)||null;if(!we)return h.value=We("projectManager.projectMissing"),!1;if(we.running)return h.value=We("sessionTurns.currentProjectRunning"),!1;const O=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,J=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[];if(!String(O||"").trim())return h.value=We("sessionTurns.noPromptToSend"),!1;const de=np(we),ye=typeof M=="function"?M(we):null,pe=String((ye==null?void 0:ye.engine)||"").trim();if(pe&&!de.some(Re=>Re.engine===pe)){const Re=We("sessionPanel.agentNotEnabled");return h.value=Re,S==null||S({message:Re,type:"warning"}),!1}const Ee=ye,Ce=String((Ee==null?void 0:Ee.sessionRecordId)||c.value).trim(),Pe=await Ji(t.taskSlug,{projectSessionId:c.value,sessionId:Ce,prompt:O,promptBlocks:J});return y(Pe),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Re=>{console.error("[promptx] afterSend failed",Re)}),f||(te(),Promise.all([L({force:!0}),D({force:!0})]).catch(Re=>{h.value=Re.message})),!0}catch(we){return h.value=we.message,!1}}async function et(){if(!(!m.value||d.value))try{d.value=!0,await Zi(m.value),f||(te(),await Promise.all([L({force:!0}),D({force:!0})]))}catch(we){d.value=!1,h.value=we.message}}return{closeManager:C,handleCreateSession:Ve,handleDeleteSession:Oe,handleResetSession:Ne,handleSelectSession:q,handleSend:qe,handleUpdateSession:Ae,hasPrompt:I,helperText:ce,loadSessions:D,loadSessionResources:re,loadWorkspaces:Q,openManager:ge,refreshSessionsForSelection:U,sortedSessions:le,stopSending:et}}function np(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:sp(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function sp(e=""){const t=String(e||"").trim().toLowerCase();return t==="claude"||t==="claudecode"?"claude-code":t==="opencode"||t==="open-code"?"opencode":t==="claude-code"?"claude-code":"codex"}function op(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,a=[],l=!1,d=!1,h=0,x=!0;function c(){if(typeof window>"u"||!a.length){a=[];return}a.forEach(le=>{window.cancelAnimationFrame(le)}),a=[]}function m(){s+=1,c()}function f(le){d=!!le,(n==null?void 0:n.value)!==void 0&&(n.value=d)}function k(){l=!1,h+=1,x=!0,f(!1)}function y(le=t==null?void 0:t.value){return le?le.scrollHeight-le.scrollTop-le.clientHeight<=o:!0}function L(){return x&&!l}function te(){x&&!l&&f(!1)}function S(){if(x=y(),!x){m();return}te()}function M(){h+=1,l=!0,m()}function N(){const le=h+1;h=le,st(()=>{le===h&&requestAnimationFrame(()=>{le===h&&(l=!1,x=y(),te())})})}function H(){l=!0,m()}function V(){N()}function ne(le={}){const{force:ce=!1}=le;ce&&k(),m();const D=s;st(()=>{if(!(t==null?void 0:t.value)||D!==s)return;if(!ce&&!L()){f(!0);return}const re=()=>{const ge=t==null?void 0:t.value;!ge||D!==s||(ge.scrollTop=ge.scrollHeight,x=!0,f(!1))};re(),a=[requestAnimationFrame(()=>{re(),a=[requestAnimationFrame(re)]})]})}function I(){ne({force:!0})}function X(){h+=1,m()}return{cancelScheduledScrollToBottom:m,destroy:X,handleTranscriptScroll:S,handleTranscriptTouchEnd:V,handleTranscriptTouchMove:H,handleTranscriptTouchStart:M,isTranscriptNearBottom:y,resetAutoStickToBottom:k,scheduleScrollToBottom:ne,scrollToBottom:I}}const ap=150,pr="promptx:session-panel:show-process";function rp(e){return!(e==="0"||e==="false")}function ip(){if(typeof window>"u")return!0;try{return rp(window.localStorage.getItem(pr))}catch{return!0}}function lp(e,t,n={}){const{preserveRunning:o=!1}=n;if(!(t!=null&&t.id))return e||null;const s={...e||{},...t};return(!Array.isArray(t==null?void 0:t.agentBindings)||!t.agentBindings.length)&&Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length&&(s.agentBindings=e.agentBindings),o&&(s.running=!!(e!=null&&e.running)),s}function up(e,t){const n=nr(),o=K([]),s=K([]),a=K(!1),l=K(!1),d=K(!1),h=K(!1),x=K(""),c=K([]),m=K(null),f=K(0),k=K(0),y=K(!1),L=K(""),te=K(!1),S=K(ip()),M=typeof window<"u"&&typeof window.EventSource<"u";function N(oe=""){const $e=typeof oe=="object"&&oe!==null?String(oe.message||"").trim():String(oe||"").trim();$e&&t("toast",typeof oe=="object"&&oe!==null?{...oe,message:$e}:$e)}let H=null,V=null,ne=null,I={sessions:!1,runs:!1};const X=G({get(){return String(e.selectedSessionId||"").trim()},set(oe){t("selected-session-change",String(oe||"").trim())}}),le=G(()=>h.value?We("sessionPanel.stopping"):`${We("projectManager.running")} (${rr(k.value)})`),ce=G(()=>o.value.find(oe=>oe.id===X.value)||null),D=G(()=>{var $e;if(Array.isArray(($e=ce.value)==null?void 0:$e.agentBindings)&&ce.value.agentBindings.length)return ce.value.agentBindings;const oe=ce.value;return oe!=null&&oe.id?[{engine:oe.engine,sessionRecordId:oe.id,sessionId:oe.sessionId||"",started:!!oe.started,running:!!oe.running,isDefault:!0}]:[]}),Q=G({get(){var $e,rt;const oe=ao(e.selectedAgentEngine,D.value);return oe||(($e=D.value.find(St=>St.isDefault))==null?void 0:$e.engine)||((rt=D.value[0])==null?void 0:rt.engine)||""},set(oe){const $e=ao(oe,D.value);$e&&t("update:selectedAgentEngine",$e)}}),re=G(()=>D.value.find(oe=>oe.engine===Q.value)||D.value[0]||null),{destroy:ae,handleTranscriptScroll:ge,handleTranscriptTouchEnd:C,handleTranscriptTouchMove:q,handleTranscriptTouchStart:U,resetAutoStickToBottom:Ve,scheduleScrollToBottom:Ae,scrollToBottom:Oe}=op({transcriptRef:m,hasNewerMessages:te});function Ne(oe,$e,rt={}){return lp(oe,$e,rt)}function qe(oe,$e={}){if(!(oe!=null&&oe.id))return;const rt=[...o.value],St=rt.findIndex(Ct=>Ct.id===oe.id);St>=0?rt[St]=Ne(rt[St],oe,$e):rt.unshift(Ne(null,oe,$e)),o.value=rt}const{applyCreatedRun:et,applyIncomingRunEvent:we,clearRealtimeReconcileTimer:O,clearRunPollTimer:J,clearTurns:de,loadTurnEvents:ye,markFallbackSessionPollNow:pe,refreshRunHistory:Ee,resetRunHistoryState:Ce,updatePollingState:Pe}=Qf({props:e,turns:c,sessions:o,sending:d,sendingStartedAt:f,currentRunningRunId:L,sessionError:x,supportsServerEvents:M,scheduleScrollToBottom:Ae,resetAutoStickToBottom:Ve,showProcessLogs:S,mergeSessionRecord:Ne,mergeSession:qe,loadSessions:(...oe)=>ct(...oe)}),{closeManager:Re,handleCreateSession:Ke,handleDeleteSession:ot,handleResetSession:De,handleSelectSession:Me,handleSend:_e,handleUpdateSession:at,helperText:mt,loadSessions:ct,loadSessionResources:yt,loadWorkspaces:Tt,openManager:E,refreshSessionsForSelection:F,sortedSessions:ee,stopSending:he}=tp({props:e,sessions:o,workspaces:s,loading:a,managerBusy:l,sending:d,stopping:h,sessionError:x,showManager:y,selectedSessionId:X,currentRunningRunId:L,supportsServerEvents:M,mergeSession:qe,applyCreatedRun:et,refreshRunHistory:Ee,markFallbackSessionPollNow:pe,showToast:N,getActiveAgentBinding:()=>re.value});function Be(){H&&(window.clearInterval(H),H=null)}function Ie(){Be(),f.value||(f.value=Date.now()),k.value=Math.max(0,Math.floor((Date.now()-f.value)/1e3)),H=window.setInterval(()=>{k.value=Math.max(0,Math.floor((Date.now()-f.value)/1e3))},1e3)}function He(){ne&&(window.clearTimeout(ne),ne=null)}function Je(){He();const oe=I;I={sessions:!1,runs:!1},oe.sessions&&ct({force:!0}).catch(()=>{}),oe.runs&&Ee({force:!0}).catch(()=>{})}function ut(oe={}){typeof window>"u"||(I={sessions:I.sessions||!!oe.sessions,runs:I.runs||!!oe.runs},!(ne||!I.sessions&&!I.runs)&&(ne=window.setTimeout(()=>{Je()},ap)))}function ht(oe){return ur(oe,{currentRunningRunId:L.value,runningElapsedSeconds:k.value,nowMs:Date.now()})}function tt(oe=""){if(!oe)return"";const $e=new Date(oe);return Number.isNaN($e.getTime())?"":$e.toLocaleTimeString(Ns(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function dt(oe){return oe.status==="error"||oe.status==="stop_timeout"?"theme-process-error":oe.status==="interrupted"||oe.status==="stopped"?"theme-process-stopped":oe.status==="completed"?"theme-process-completed":"theme-process-running"}function kt(){S.value=!S.value}function Dt(oe){return!!(oe.responseMessage||oe.errorMessage||oe.status==="completed")}return Te(S,oe=>{if(!(typeof window>"u"))try{window.localStorage.setItem(pr,oe?"true":"false")}catch{}},{immediate:!0}),Te(d,oe=>{oe?(f.value||(f.value=Date.now()),Ie()):(Be(),f.value=0,k.value=0,h.value=!1),Pe(),t("sending-change",oe)},{immediate:!0}),Te(()=>!!e.taskRunning,oe=>{!e.active||oe||!d.value||ut({sessions:!0,runs:!0})}),Te(()=>e.active,oe=>{if(oe){yt({forceSessions:!0}).catch(()=>{});return}He(),O(),J()},{immediate:!0}),Te(()=>e.taskSlug,()=>{Ce(),y.value=!1,x.value="",e.active&&Ee({force:!0,scrollToLatest:!0}).catch(()=>{})},{immediate:!0}),Te(()=>{var oe;return[((oe=ce.value)==null?void 0:oe.id)||"",D.value.map($e=>$e.engine).join(","),e.selectedAgentEngine||""].join(`
36
- `)},()=>{var ft,z,W;const oe=String(((ft=ce.value)==null?void 0:ft.id)||"").trim(),$e=D.value,rt=Q.value;if(t("agent-bindings-change",{sessionId:oe,bindings:$e,selectedEngine:rt}),!oe||ao(e.selectedAgentEngine,$e))return;const Ct=((z=$e.find(ue=>ue.isDefault))==null?void 0:z.engine)||((W=$e[0])==null?void 0:W.engine)||"";Ct&&t("update:selectedAgentEngine",Ct)},{immediate:!0}),$t(()=>{Be(),O(),J(),He(),ae(),V==null||V()}),Te(()=>n.readyVersion.value,()=>{const oe=String(e.taskSlug||"").trim();!e.active&&!y.value||(y.value&&Tt().catch(()=>{}),ut({sessions:!0,runs:!!oe}))}),Te(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!y.value||ut({sessions:!0})}),Te(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||ut({sessions:!0,runs:!0})}),Te(()=>String(e.taskSlug||"").trim(),oe=>{V==null||V(),V=null,oe&&(V=yf(oe,({runId:$e,event:rt})=>{if(!e.active)return;we($e,rt)||ut({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:re,activeAgentEngine:Q,clearTurns:de,closeManager:Re,formatTurnTime:tt,getProcessCardClass:dt,getProcessStatus:Vf,getTurnAgentLabel:Pt,getTurnSummaryDetail:dr,getDisplayTurnSummaryItems:ht,getTurnSummaryStatus:cr,handleCreateSession:Ke,handleDeleteSession:ot,handleResetSession:De,handleSelectSession:Me,handleSend:_e,handleUpdateSession:at,loadTurnEvents:ye,hasTurnSummary:jf,helperText:mt,loading:a,managerBusy:l,openManager:E,refreshSessionsForSelection:F,selectedSessionId:X,sending:d,showProcessLogs:S,stopping:h,sessionError:x,shouldShowResponse:Dt,showManager:y,sortedSessions:ee,stopSending:he,toggleProcessLogs:kt,hasNewerMessages:te,transcriptRef:m,turns:c,workspaces:s,workingLabel:le,sessions:o,loadSessions:ct,currentProjectAgentBindings:D,handleTranscriptScroll:ge,handleTranscriptTouchEnd:C,handleTranscriptTouchMove:q,handleTranscriptTouchStart:U,scheduleScrollToBottom:Ae,scrollToBottom:Oe}}function ao(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const cp=8,dp=320,fp=10,pp=400;function aa(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function mp(e={}){const{turns:t,loadTurnEvents:n}=e,o=K({}),s=K({}),a=K({});function l(I){return String((I==null?void 0:I.runId)||(I==null?void 0:I.id)||"").trim()}function d(I){const X=l(I);return!!X&&X===l(t.value.at(-1))}function h(I){return Math.max(0,Number(I==null?void 0:I.eventCount)||0,Array.isArray(I==null?void 0:I.events)?I.events.length:0)}function x(I){return!ns(I==null?void 0:I.status)&&!d(I)&&h(I)>3}function c(I){return aa(I==null?void 0:I.prompt,cp,dp)}function m(I){return!ns(I==null?void 0:I.status)&&!d(I)&&c(I)}function f(I){return String((I==null?void 0:I.errorMessage)||(I==null?void 0:I.responseMessage)||"")}function k(I){return aa(f(I),fp,pp)}function y(I){return!(I!=null&&I.errorMessage)&&!d(I)&&k(I)}function L(I){return h(I)>0}function te(I=[]){const X=new Set((I||[]).map(D=>l(D)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([D])=>X.has(D))),s.value=Object.fromEntries(Object.entries(s.value).filter(([D])=>X.has(D))),a.value=Object.fromEntries(Object.entries(a.value).filter(([D])=>X.has(D)));const le=(I||[]).at(-1)||null,ce=l(le);ce&&(Object.prototype.hasOwnProperty.call(o.value,ce)||(o.value={...o.value,[ce]:!1}),Object.prototype.hasOwnProperty.call(s.value,ce)||(s.value={...s.value,[ce]:!1}),Object.prototype.hasOwnProperty.call(a.value,ce)||(a.value={...a.value,[ce]:!1}))}function S(I){const X=l(I);return X?Object.prototype.hasOwnProperty.call(o.value,X)?!!o.value[X]:x(I):!1}async function M(I){const X=l(I);if(!X)return;const le=!S(I);o.value={...o.value,[X]:le},!le&&L(I)&&!I.eventsLoaded&&!I.eventsLoading&&await n(I).catch(()=>{})}function N(I){const X=l(I);return X?Object.prototype.hasOwnProperty.call(s.value,X)?!!s.value[X]:m(I):!1}function H(I){const X=l(I);!X||!c(I)||(s.value={...s.value,[X]:!N(I)})}function V(I){const X=l(I);return X?Object.prototype.hasOwnProperty.call(a.value,X)?!!a.value[X]:y(I):!1}function ne(I){const X=l(I);!X||!k(I)||(a.value={...a.value,[X]:!V(I)})}return Te(t,I=>{te(I)},{immediate:!0,deep:!0}),{canCollapsePrompt:c,canCollapseResponse:k,getTurnEventCollapseKey:l,getTurnEventCount:h,hasTurnEventHistory:L,isLatestTurn:d,isPromptCollapsed:N,isResponseCollapsed:V,isTurnEventsCollapsed:S,togglePrompt:H,toggleResponse:ne,toggleTurnEvents:M}}function gp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function hp(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.label)||"").trim(),value:String((n==null?void 0:n.value)||"").trim()})).filter(n=>n.label&&n.value);return t.length?{type:"meta",items:t}:null}function vp(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function ro(e="",t=0){const n=Math.max(1,Number(t)||0);return e==="read"?`连续读取 ${n} 项`:e==="grep"?`连续检索 ${n} 次`:e==="list"?`连续列出 ${n} 处`:e==="web"?`连续网页检索 ${n} 次`:e==="todo"?"待办列表":e==="reasoning"?"思考过程":`连续处理 ${n} 项`}function io(e="",t=[],n=[]){var l;const o=gp(t.map(d=>d.groupTarget)),s=[];if(e==="todo"){const d=[...n].reverse().flatMap(h=>Array.isArray(h==null?void 0:h.detailBlocks)?h.detailBlocks:[]).find(h=>(h==null?void 0:h.type)==="checklist");return d?[d]:[]}if(e==="reasoning"){const d=[...t].reverse().find(h=>Array.isArray(h==null?void 0:h.detailBlocks)&&h.detailBlocks.length);return(l=d==null?void 0:d.detailBlocks)!=null&&l.length?d.detailBlocks:[]}const a=hp([{label:"类型",value:vp(e)},{label:"次数",value:String(t.length)}]);return a&&s.push(a),o.length&&s.push({type:"bullet_list",items:o.slice(0,8),totalCount:o.length,hiddenCount:Math.max(0,o.length-8)}),s}function mr(e=[]){if(!e.length)return[];const[t]=e,n=String(t.groupType||"").trim();if(!n)return e;if(n==="reasoning"){if(e.length===1)return e;const s=e[e.length-1];return[{...s,id:`${s.id}-group`,title:ro(n,e.length),detail:"",detailBlocks:io(n,e,e),isGrouped:!0,groupedCount:e.length}]}const o=e.filter(s=>s.phase==="completed"||s.phase==="updated"||s.kind==="error");if(!o.length)return[e[e.length-1]];if(n==="todo"){if(e.length===1)return e;const s=o[o.length-1];return[{...s,id:`${s.id}-group`,title:ro(n,e.length),detail:"",detailBlocks:io(n,e,o),isGrouped:!0,groupedCount:e.length}]}return o.length===1&&e.length<=2?[o[0]]:[{...o[o.length-1],id:`${o[o.length-1].id}-group`,title:ro(n,o.length),detail:"",detailBlocks:io(n,o,o),isGrouped:!0,groupedCount:o.length}]}function yp(e=[]){const t=Array.isArray(e)?e:[],n=t.filter(a=>String((a==null?void 0:a.groupType)||"").trim()==="todo");if(n.length<=1)return t;const[o]=mr(n);if(!o)return t;const s=t.reduce((a,l,d)=>String((l==null?void 0:l.groupType)||"").trim()==="todo"?d:a,-1);return s<0?t:t.flatMap((a,l)=>String((a==null?void 0:a.groupType)||"").trim()!=="todo"?[a]:l===s?[o]:[])}function Sp(e=[]){var o;const t=yp(Array.isArray(e)?e.filter(Boolean):[]),n=[];for(let s=0;s<t.length;s+=1){const a=t[s],l=String((a==null?void 0:a.groupType)||"").trim();if(!l){n.push(a);continue}const d=[a];for(;s+1<t.length&&String(((o=t[s+1])==null?void 0:o.groupType)||"").trim()===l;)d.push(t[s+1]),s+=1;n.push(...mr(d))}return n}const wp={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},xp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},bp={class:"flex flex-col gap-2"},kp={class:"flex items-center gap-2"},_p=["title"],Tp={class:"flex shrink-0 items-center gap-1.5"},Cp=["aria-pressed","aria-label","title"],Ep=["disabled"],Ap={class:"hidden sm:inline"},$p=["disabled"],Ip={class:"hidden sm:inline"},Pp=["aria-label"],Dp=["aria-pressed"],Lp=["aria-pressed","title","onClick"],Mp={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},Bp={class:"min-h-0 flex-1"},Rp={key:0,class:"theme-empty-state px-4 py-6 text-sm"},Np={key:1,class:"theme-empty-state px-4 py-6 text-sm"},Op=["data-turn-id","data-run-id"],jp={class:"flex justify-end"},Fp={class:"transcript-card transcript-card--prompt min-w-0 w-full rounded-sm bg-[var(--theme-promptBg)] px-4 py-3 font-mono text-sm text-[var(--theme-promptText)]"},Up={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Vp={class:"font-semibold"},zp={class:"flex items-center gap-2"},Hp=["onClick"],qp={class:"relative mt-2"},Kp={key:0,class:"space-y-3"},Wp={key:0,class:"whitespace-pre-wrap break-words leading-7"},Gp=["onClick"],Xp=["src","alt"],Yp={key:1,class:"whitespace-pre-wrap break-words leading-7"},Jp={key:0,class:"flex min-w-0 justify-start"},Qp={class:"flex items-center justify-between gap-3 text-xs"},Zp={class:"font-semibold"},em={class:"flex items-center gap-2"},tm=["disabled","onClick"],nm={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},sm={key:1,class:"mt-2 min-w-0 space-y-2"},om={class:"text-sm font-medium leading-6"},am={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},rm={key:3,class:"mt-2 text-xs text-current"},im={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},lm={key:0,class:"leading-5"},um={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},cm={key:2,class:"mt-2 flex flex-wrap gap-2"},dm={class:"font-medium"},fm={key:1,class:"flex justify-start"},pm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},mm={class:"font-semibold"},gm={class:"flex items-center gap-2"},hm=["onClick"],vm=["onClick"],ym={class:"relative mt-2"},Sm={key:0,class:"whitespace-pre-wrap break-words"},wm=["innerHTML"],xm={class:"pointer-events-none absolute bottom-1 right-1 z-10 flex flex-col items-end gap-1.5 sm:bottom-3 sm:right-3"},bm=["disabled"],km={key:2,class:"task-loading-dots","aria-hidden":"true"},_m={__name:"CodexSessionPanel",props:{prompt:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},beforeSend:{type:Function,default:null},afterSend:{type:Function,default:null},taskSlug:{type:String,default:""},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},active:{type:Boolean,default:!1},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1}},emits:["agent-bindings-change","insert-code-context","project-created","selected-session-change","sending-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=co(()=>Ue(()=>import("./CodexSessionManagerDialog-BbaObUl_.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,a=e,{closeManager:l,formatTurnTime:d,getProcessCardClass:h,getProcessStatus:x,getTurnAgentLabel:c,getDisplayTurnSummaryItems:m,getTurnSummaryDetail:f,getTurnSummaryStatus:k,handleCreateSession:y,handleDeleteSession:L,handleResetSession:te,handleSelectSession:S,handleSend:M,handleTranscriptScroll:N,handleTranscriptTouchEnd:H,handleTranscriptTouchMove:V,handleTranscriptTouchStart:ne,handleUpdateSession:I,helperText:X,loadTurnEvents:le,loading:ce,managerBusy:D,openManager:Q,refreshSessionsForSelection:re,selectedSessionId:ae,sending:ge,showProcessLogs:C,stopping:q,hasTurnSummary:U,hasNewerMessages:Ve,sessionError:Ae,shouldShowResponse:Oe,showManager:Ne,sortedSessions:qe,stopSending:et,toggleProcessLogs:we,transcriptRef:O,turns:J,workspaces:de,sessions:ye,loadSessions:pe,currentProjectAgentBindings:Ee,scheduleScrollToBottom:Ce,scrollToBottom:Pe}=up(a,s),Re=K(null),Ke=K(!1),ot=K(""),De=K(""),Me=K("all"),{t:_e}=vt(),{isDark:at}=xa(),mt=G(()=>at.value?"dark":"light"),ct=G(()=>{const p=new Set;return(Array.isArray(Ee.value)?Ee.value:[]).filter(_=>{const v=String((_==null?void 0:_.engine)||"").trim();return!v||p.has(v)?!1:(p.add(v),!0)})}),yt=G(()=>ct.value.length>1),Tt=G(()=>{const p=String(Me.value||"").trim();return!yt.value||p==="all"?J.value:J.value.filter(_=>String((_==null?void 0:_.engine)||"").trim()===p)}),{selectionAction:E,clearSelectionState:F,handleSelectionMouseUp:ee}=Ga({getContainer:()=>O.value,isActive:()=>!!(a.active&&J.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:p=>[...p.querySelectorAll("[data-response-selection-root]")],getCodeLeft:p=>{var _,v;return((v=(_=p==null?void 0:p.getBoundingClientRect)==null?void 0:_.call(p))==null?void 0:v.left)||0},debounceMs:72});Te([Me,()=>ct.value.map(p=>p.engine).join(`
37
- `)],()=>{Me.value!=="all"&&(ct.value.some(p=>p.engine===Me.value)||(Me.value="all"))},{immediate:!0}),Te(Me,()=>{F({clearBrowserSelection:!0}),Ce({force:!0})});function he(p={}){if((p==null?void 0:p.kind)==="reasoning")return!0;const _=String((p==null?void 0:p.title)||"").trim();return _?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/^Codex 会话已创建$/,/^Claude Code 会话已创建$/,/^OpenCode 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(v=>v.test(_)):!1}const{getTurnEventCount:Be,hasTurnEventHistory:Ie,isTurnEventsCollapsed:He,toggleTurnEvents:Je}=mp({turns:J,loadTurnEvents:le});function ut(p){return String((p==null?void 0:p.runId)||(p==null?void 0:p.id)||"").trim()}function ht(p){p!=null&&p.runId&&s("open-diff",{scope:"run",runId:p.runId})}function tt(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:dt}=of({items:J,themeKey:mt,getCacheKey:ut,getSource:p=>String((p==null?void 0:p.responseMessage)||""),shouldRender:p=>!!(p!=null&&p.responseMessage)&&!(p!=null&&p.errorMessage),renderAsync:p=>Qu(p,{isDark:at.value,copyLabel:_e("sessionPanel.copyCode"),copyAriaLabel:_e("sessionPanel.copyCodeAria")}),renderFallback:p=>qa(p),onRendered:p=>{const _=J.value.at(-1)||null;!a.active||!(_!=null&&_.runId)||_.runId!==(p==null?void 0:p.runId)||Ce()}});function kt(p){De.value=String(p||"").trim()}async function Dt(p){var v;if((v=navigator.clipboard)!=null&&v.writeText&&window.isSecureContext){await navigator.clipboard.writeText(p);return}const _=document.createElement("textarea");_.value=p,_.setAttribute("readonly","true"),_.style.position="fixed",_.style.opacity="0",_.style.pointerEvents="none",document.body.appendChild(_),_.select(),document.execCommand("copy"),document.body.removeChild(_)}function oe(p={}){const v=(Array.isArray(p==null?void 0:p.promptBlocks)?p.promptBlocks:[]).filter(Y=>(Y==null?void 0:Y.type)==="text"||(Y==null?void 0:Y.type)==="imported_text").map(Y=>String((Y==null?void 0:Y.content)||"").replace(/\u200b/g,"").trim()).filter(Boolean).join(`
38
-
39
- `);return v||String((p==null?void 0:p.prompt)||"").replace(/\u200b/g,"").trim()}function $e(p={}){const _=oe(p);_&&s("insert-code-context",{source:"response",content:_})}async function rt(p){var Le,Ot,jt,Wt,Rt;const _=(Ot=(Le=p==null?void 0:p.target)==null?void 0:Le.closest)==null?void 0:Ot.call(Le,'[data-copy-code="1"]');if(!_)return;const v=_.closest(".codex-code-block"),Y=(jt=v==null?void 0:v.querySelector)==null?void 0:jt.call(v,"pre code"),Qe=String((Y==null?void 0:Y.textContent)||"").replace(/\u200b/g,"");if(Qe){(Wt=p.preventDefault)==null||Wt.call(p),(Rt=p.stopPropagation)==null||Rt.call(p);try{await Dt(Qe),s("toast",{message:_e("sessionPanel.codeCopied"),type:"success"})}catch{s("toast",{message:_e("errors.requestFailed"),type:"warning"})}}}function St(){if(!E.value.visible)return;const p=String(E.value.content||"").replace(/\u200b/g,"").trim();if(!p){F({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:p}),F({clearBrowserSelection:!0})}function Ct(p={}){if(p!=null&&p.errorMessage)return;const _=String((p==null?void 0:p.responseMessage)||"").replace(/\u200b/g,"").trim();_&&s("insert-code-context",{source:"response",content:_})}const ft=G(()=>J.value.flatMap(p=>(Array.isArray(p==null?void 0:p.promptBlocks)?p.promptBlocks:[]).filter(_=>(_==null?void 0:_.type)==="image").map(_=>_.content)));function z(p){const v=(Array.isArray(p==null?void 0:p.events)?p.events:[]).filter(Y=>!he(Y));return Sp(v)}function W(p){return Be(p)}function ue(p){return p!=null&&p.eventsLoaded?W(p)>0:Ie(p)}function me(p){return!!(p!=null&&p.eventsLoading)}function je(p){return!!(p!=null&&p.eventsLoaded)&&z(p).length>0&&!He(p)}function Et(p){return!!(p!=null&&p.eventsLoaded)&&W(p)>0&&He(p)}function zt(p){return Ie(p)&&!(p!=null&&p.eventsLoaded)&&!(p!=null&&p.eventsLoading)}function _t(p={}){return Ba(p,{defaultLabel:_e("sessionPanel.defaultAgent")})}function Bt(p={}){return"bg-[var(--theme-appPanelStrong)]"}function nn(p=null){const _=String((p==null?void 0:p.id)||"").trim();if(_)return ye.value.find(Y=>Y.id===_)||null;const v=String(ae.value||"").trim();return v?ye.value.find(Y=>Y.id===v)||null:qe.value[0]||null}function Qt(p=null){const _=nn(p);return _!=null&&_.cwd?(ot.value=_.id,Ke.value=!0,!0):!1}function $(){return D.value?!1:(Q(),!0)}function T(){var p,_;return Ke.value?(Ke.value=!1,!0):(_=(p=Re.value)==null?void 0:p.closeTopDialog)!=null&&_.call(p)?!0:Ne.value?(l(),!0):!1}return t({closeTopDialog:T,openProjectManager:$,openSourceBrowser:Qt,send:M,scrollToBottom:Pe,stop:et}),(p,_)=>(g(),b("section",wp,[ie(sf,{open:Ke.value,session:r(ye).find(v=>v.id===ot.value)||null,onInsertCodeContext:_[0]||(_[0]=v=>s("insert-code-context",v)),onClose:_[1]||(_[1]=v=>Ke.value=!1)},null,8,["open","session"]),ie(r(o),{ref_key:"managerDialogRef",ref:Re,open:r(Ne),sessions:r(ye),workspaces:r(de),"selected-session-id":r(ae),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:r(ce),sending:r(ge),"on-refresh":r(pe),"on-create":r(y),"on-update":r(I),"on-delete":r(L),"on-reset":r(te),onClose:r(l),onOpenSourceBrowser:_[2]||(_[2]=v=>Qt(v)),onProjectCreated:_[3]||(_[3]=v=>s("project-created",v)),onSelectSession:r(S)},null,8,["open","sessions","workspaces","selected-session-id","selection-locked","selection-lock-reason","loading","sending","on-refresh","on-create","on-update","on-delete","on-reset","onClose","onSelectSession"]),i("div",xp,[i("div",bp,[i("div",kp,[i("div",{class:"min-w-0 flex-1",title:r(X)||""},[ie(Mu,{modelValue:r(ae),"onUpdate:modelValue":_[4]||(_[4]=v=>xr(ae)?ae.value=v:null),sessions:r(qe),loading:r(ce),disabled:r(ge)||r(D)||e.sessionSelectionLocked,onRefreshIntent:r(re)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,_p),i("div",Tp,[i("button",{type:"button",class:ve(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",r(C)?"tool-button-accent-subtle":""]),"aria-pressed":r(C)?"true":"false","aria-label":r(C)?r(_e)("sessionPanel.hideProcessToggle"):r(_e)("sessionPanel.showProcessToggle"),title:r(C)?r(_e)("sessionPanel.hideProcessToggle"):r(_e)("sessionPanel.showProcessToggle"),onClick:_[5]||(_[5]=(...v)=>r(we)&&r(we)(...v))},[r(C)?(g(),ke(r($r),{key:0,class:"h-4 w-4"})):(g(),ke(r(Ir),{key:1,class:"h-4 w-4"}))],10,Cp),e.diffSupported?(g(),b("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:!e.taskSlug,onClick:tt},[ie(r(Fo),{class:"h-4 w-4"}),_[17]||(_[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",Ap,w(r(_e)("sessionPanel.diff")),1)],8,Ep)):fe("",!0),i("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:r(D),onClick:_[6]||(_[6]=(...v)=>r(Q)&&r(Q)(...v))},[ie(r(Zn),{class:"h-4 w-4"}),_[18]||(_[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",Ip,w(r(_e)("sessionPanel.manageProjects")),1)],8,$p)])]),yt.value?(g(),b("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":r(_e)("sessionPanel.agentFilter")},[i("button",{type:"button",class:ve(["theme-agent-selector-button",Me.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Me.value==="all"?"true":"false",onClick:_[7]||(_[7]=v=>Me.value="all")},w(r(_e)("sessionPanel.allAgents")),11,Dp),(g(!0),b(Ze,null,it(ct.value,v=>(g(),b("button",{key:v.engine,type:"button",class:ve(["theme-agent-selector-button",Me.value===v.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Me.value===v.engine?"true":"false",title:_t(v),onClick:Y=>Me.value=v.engine},w(_t(v)),11,Lp))),128))],8,Pp)):fe("",!0),r(Ae)?(g(),b("p",Mp,[ie(r(ko),{class:"h-4 w-4"}),i("span",null,w(r(Ae)),1)])):fe("",!0)])]),i("div",Bp,[i("div",{ref_key:"transcriptRef",ref:O,"data-promptx-transcript":"1",class:"workbench-transcript relative flex h-full flex-col gap-3 overflow-x-hidden overflow-y-auto px-4 py-4",onScroll:_[9]||(_[9]=(...v)=>r(N)&&r(N)(...v)),onTouchstartPassive:_[10]||(_[10]=(...v)=>r(ne)&&r(ne)(...v)),onTouchmovePassive:_[11]||(_[11]=(...v)=>r(V)&&r(V)(...v)),onTouchendPassive:_[12]||(_[12]=(...v)=>r(H)&&r(H)(...v)),onTouchcancelPassive:_[13]||(_[13]=(...v)=>r(H)&&r(H)(...v))},[r(J).length?Tt.value.length?fe("",!0):(g(),b("div",Np,w(r(_e)("sessionPanel.emptyAgentFilter")),1)):(g(),b("div",Rp,w(r(_e)("sessionPanel.empty")),1)),(g(!0),b(Ze,null,it(Tt.value,v=>(g(),b("div",{key:v.id,"data-promptx-turn":"1","data-turn-id":v.id,"data-run-id":v.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",jp,[i("div",Fp,[i("div",Up,[i("span",Vp,w(r(_e)("sessionPanel.promptTitleWithAgent",{agent:r(c)(v)})),1),i("div",zp,[oe(v)?(g(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:Y=>$e(v)},[ie(r(Is),{class:"h-3 w-3"}),i("span",null,w(r(_e)("sessionPanel.insert")),1)],8,Hp)):fe("",!0),i("span",null,w(r(d)(v.startedAt)),1)])]),i("div",qp,[Array.isArray(v.promptBlocks)&&v.promptBlocks.length?(g(),b("div",Kp,[(g(!0),b(Ze,null,it(v.promptBlocks,(Y,Qe)=>(g(),b(Ze,{key:`${v.id}-prompt-${Qe}`},[Y.type==="text"||Y.type==="imported_text"?(g(),b("pre",Wp,w(Y.content),1)):(g(),b("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:Le=>kt(Y.content)},[i("img",{src:Y.content,alt:r(_e)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,Xp)],8,Gp))],64))),128))])):(g(),b("pre",Yp,w(v.prompt),1))])])]),r(C)?(g(),b("div",Jp,[i("div",{class:ve(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",r(h)(v)])},[i("div",Qp,[i("span",Zp,w(r(_e)("sessionPanel.processTitle")),1),i("div",em,[ue(v)?(g(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",disabled:v.eventsLoading,onClick:Y=>r(Je)(v)},[me(v)?(g(),ke(r(Vt),{key:0,class:"h-3 w-3 animate-spin"})):r(He)(v)?(g(),ke(r(bo),{key:1,class:"h-3 w-3"})):(g(),ke(r(Pr),{key:2,class:"h-3 w-3"})),i("span",null,w(v.eventsLoading?r(_e)("sessionPanel.loading"):r(He)(v)?`${r(_e)("sessionPanel.expand")} (${W(v)})`:r(_e)("sessionPanel.collapse")),1)],8,tm)):fe("",!0),i("span",null,w(r(x)(v)),1)])]),me(v)?(g(),b("div",nm,w(r(_e)("sessionPanel.loadingEvents")),1)):je(v)?(g(),b("div",sm,[(g(!0),b(Ze,null,it(z(v),Y=>(g(),b("div",{key:Y.id,class:ve(["transcript-event-card min-w-0 rounded-sm px-3 py-2",Bt(Y)])},[i("div",om,w(Y.title),1),Y.detail||Array.isArray(Y.detailBlocks)&&Y.detailBlocks.length?(g(),ke(Bc,{key:0,detail:Y.detail,blocks:Y.detailBlocks,kind:Y.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):fe("",!0)],2))),128))])):Et(v)||zt(v)?(g(),b("div",am,w(v.eventsLoaded?r(_e)("sessionPanel.hiddenEventsLoaded",{count:W(v)}):r(_e)("sessionPanel.hiddenEventsLoadLater",{count:W(v)})),1)):(g(),b("p",rm,w(["queued","starting","running","stopping"].includes(v.status)?r(_e)("sessionPanel.waitingEvents",{agent:r(c)(v)}):r(_e)("sessionPanel.noEvents")),1)),r(U)(v)?(g(),b("div",im,[r(k)(v)?(g(),b("div",lm,w(r(k)(v)),1)):fe("",!0),r(f)(v)?(g(),b("div",um,w(r(f)(v)),1)):fe("",!0),r(m)(v).length?(g(),b("div",cm,[(g(!0),b(Ze,null,it(r(m)(v),Y=>(g(),b("span",{key:Y.key,class:"transcript-card__pill inline-flex items-center gap-1 rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2 py-1"},[i("span",null,w(Y.label),1),i("span",dm,w(Y.value),1)]))),128))])):fe("",!0)])):fe("",!0)],2)])):fe("",!0),r(Oe)(v)?(g(),b("div",fm,[i("div",{class:ve(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",v.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",pm,[i("span",mm,w(v.errorMessage?r(_e)("sessionPanel.errorSuffix",{agent:r(c)(v)}):r(_e)("sessionPanel.responseSuffix",{agent:r(c)(v)})),1),i("div",gm,[e.diffSupported&&v.runId?(g(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:Y=>ht(v)},[ie(r(Fo),{class:"h-3 w-3"}),i("span",null,w(r(_e)("sessionPanel.view")),1)],8,hm)):fe("",!0),v.responseMessage&&!v.errorMessage?(g(),b("button",{key:1,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:Y=>Ct(v)},[ie(r(Is),{class:"h-3 w-3"}),i("span",null,w(r(_e)("sessionPanel.insert")),1)],8,vm)):fe("",!0),i("span",null,w(r(d)(v.finishedAt||v.startedAt)),1)])]),i("div",ym,[v.errorMessage?(g(),b("div",Sm,w(v.errorMessage),1)):(g(),b("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:_[8]||(_[8]=(...Y)=>r(ee)&&r(ee)(...Y)),onClick:rt,innerHTML:r(dt)(v)},null,40,wm))])],2)])):fe("",!0)],8,Op))),128)),r(E).visible?(g(),ke(Ka,{key:2,top:r(E).top,left:r(E).left,label:r(_e)("sourceBrowser.insertSelection"),onClick:St},null,8,["top","left","label"])):fe("",!0)],544),i("div",xm,[r(Ve)?(g(),b("button",{key:0,type:"button",class:ve([r(ge)?"mb-10 sm:mb-8":"","tool-button pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur"]),onClick:_[14]||(_[14]=(...v)=>r(Pe)&&r(Pe)(...v))},[ie(r(Dr),{class:"h-3.5 w-3.5"}),i("span",null,w(r(_e)("sessionPanel.jumpToLatest")),1)],2)):fe("",!0),r(ge)?(g(),b("button",{key:1,type:"button",class:"tool-button tool-button-warning-subtle pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur",disabled:r(q),onClick:_[15]||(_[15]=(...v)=>r(et)&&r(et)(...v))},[r(q)?(g(),ke(r(Vt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),ke(r(Lr),{key:1,class:"h-3.5 w-3.5"})),i("span",null,w(r(q)?r(_e)("sessionPanel.stopping"):r(_e)("sessionPanel.stop")),1),r(q)?fe("",!0):(g(),b("span",km,[..._[19]||(_[19]=[i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1)])]))],8,bm)):fe("",!0)])]),ie(Ra,{modelValue:De.value,"onUpdate:modelValue":_[16]||(_[16]=v=>De.value=v),images:ft.value},null,8,["modelValue","images"])]))}},Tm={key:0,class:"h-full min-h-0"},Cm={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},ra={__name:"WorkbenchActivityPanel",props:{taskSlug:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1},emptyMessage:{type:String,default:""}},emits:["agent-bindings-change","insert-code-context","sending-change","project-created","selected-session-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=n,s=K(null);function a(){var m,f;return(f=(m=s.value)==null?void 0:m.send)==null?void 0:f.call(m)}function l(){var m,f;(f=(m=s.value)==null?void 0:m.stop)==null||f.call(m)}function d(){var m,f;(f=(m=s.value)==null?void 0:m.scrollToBottom)==null||f.call(m)}function h(){var m,f;return((f=(m=s.value)==null?void 0:m.openProjectManager)==null?void 0:f.call(m))||!1}function x(){var m,f;return((f=(m=s.value)==null?void 0:m.openSourceBrowser)==null?void 0:f.call(m))||!1}function c(){var m,f;return((f=(m=s.value)==null?void 0:m.closeTopDialog)==null?void 0:f.call(m))||!1}return t({closeTopDialog:c,openProjectManager:h,openSourceBrowser:x,send:a,stop:l,scrollToBottom:d}),(m,f)=>e.taskSlug?(g(),b("div",Tm,[ie(_m,{ref_key:"panelRef",ref:s,active:!!e.taskSlug,"task-slug":e.taskSlug,"build-prompt":e.buildPrompt||(()=>""),"build-prompt-blocks":e.buildPromptBlocks||(()=>[]),"selected-session-id":e.selectedSessionId,"selected-agent-engine":e.selectedAgentEngine,"session-selection-locked":e.sessionSelectionLocked,"session-selection-lock-reason":e.sessionSelectionLockReason,"diff-supported":e.diffSupported,"task-running":e.taskRunning,onAgentBindingsChange:f[0]||(f[0]=k=>o("agent-bindings-change",k)),onInsertCodeContext:f[1]||(f[1]=k=>o("insert-code-context",k)),onProjectCreated:f[2]||(f[2]=k=>o("project-created",k)),onSendingChange:f[3]||(f[3]=k=>o("sending-change",k)),onSelectedSessionChange:f[4]||(f[4]=k=>o("selected-session-change",k)),"onUpdate:selectedAgentEngine":f[5]||(f[5]=k=>o("update:selectedAgentEngine",k)),onOpenDiff:f[6]||(f[6]=k=>o("open-diff",k)),onToast:f[7]||(f[7]=k=>o("toast",k))},null,8,["active","task-slug","build-prompt","build-prompt-blocks","selected-session-id","selected-agent-engine","session-selection-locked","session-selection-lock-reason","diff-supported","task-running"])])):e.emptyMessage?(g(),b("section",Cm,w(e.emptyMessage),1)):fe("",!0)}},Em=["title"],Am={class:"flex min-w-0 items-center gap-1.5"},$m=["aria-pressed","title","data-agent-engine","onClick"],ia={__name:"WorkbenchAgentSelector",props:{agentBindings:{type:Array,default:()=>[]},selectedAgentEngine:{type:String,default:""},align:{type:String,default:"start"}},emits:["update:selectedAgentEngine"],setup(e,{emit:t}){const n=e,o=t,{t:s}=vt(),a=G(()=>{const c=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(m=>{const f=String((m==null?void 0:m.engine)||"").trim();return!f||c.has(f)?!1:(c.add(f),!0)})}),l=G(()=>a.value.length>1),d=G(()=>{var m,f;const c=String(n.selectedAgentEngine||"").trim();return a.value.some(k=>k.engine===c)?c:((m=a.value.find(k=>k.isDefault))==null?void 0:m.engine)||((f=a.value[0])==null?void 0:f.engine)||""}),h=G(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function x(c={}){return Ba(c,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(c,m)=>l.value?(g(),b("div",{key:0,class:ve(["flex w-full overflow-x-auto pb-0.5",h.value]),title:r(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:m[1]||(m[1]=Xe(()=>{},["stop"]))},[i("div",Am,[(g(!0),b(Ze,null,it(a.value,f=>(g(),b("button",{key:f.engine,type:"button",class:ve(["theme-agent-selector-button",f.engine===d.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":f.engine===d.value,title:x(f),"data-agent-engine":f.engine,onMousedown:m[0]||(m[0]=Xe(()=>{},["prevent"])),onClick:k=>o("update:selectedAgentEngine",f.engine)},w(x(f)),43,$m))),128))])],42,Em)):fe("",!0)}},Im={class:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end sm:gap-2","data-promptx-editor-actions":""},Pm={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},Dm=["disabled","title","aria-label"],Lm={class:"sr-only sm:not-sr-only sm:inline"},Mm=["title","aria-label"],Bm={class:"sr-only sm:not-sr-only sm:inline"},Rm=["disabled","title","aria-label"],Nm={class:"sr-only sm:not-sr-only sm:inline"},Om=["title","aria-label"],jm={class:"sr-only sm:not-sr-only sm:inline"},Fm={key:0,class:"absolute right-1 top-1 min-w-[1rem] rounded-full bg-[var(--theme-primaryBg)] px-1 text-[10px] font-semibold leading-4 text-[var(--theme-primaryText)] sm:hidden"},Um=["disabled","title","aria-label"],Vm={class:"sr-only sm:not-sr-only sm:inline"},la={__name:"WorkbenchEditorActions",props:{canAddTodo:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},sendState:{type:String,default:"idle"},todoCount:{type:Number,default:0}},emits:["add-todo","open-file-picker","clear-request","copy-request","manage-todo","send-request"],setup(e,{emit:t}){const n=e,o=t,{t:s}=vt(),a=G(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(d,h)=>(g(),b("div",Im,[i("div",Pm,[i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.uploading,title:r(s)("editor.chooseFiles"),"aria-label":r(s)("editor.chooseFiles"),"data-promptx-editor-action":"files",onMousedown:h[0]||(h[0]=Xe(()=>{},["prevent"])),onClick:h[1]||(h[1]=x=>o("open-file-picker"))},[e.uploading?(g(),ke(r(Vt),{key:0,class:"h-4 w-4 animate-spin"})):(g(),ke(r(Mr),{key:1,class:"h-4 w-4"})),i("span",Lm,w(r(s)("editor.chooseFiles")),1)],40,Dm),i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",title:r(s)("editor.clear"),"aria-label":r(s)("editor.clear"),"data-promptx-editor-action":"clear",onMousedown:h[2]||(h[2]=Xe(()=>{},["prevent"])),onClick:h[3]||(h[3]=x=>o("clear-request"))},[ie(r(Br),{class:"h-4 w-4"}),i("span",Bm,w(r(s)("editor.clear")),1)],40,Mm),i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:!e.canAddTodo,title:r(s)("editor.todo"),"aria-label":r(s)("editor.todo"),"data-promptx-editor-action":"todo-add",onMousedown:h[4]||(h[4]=Xe(()=>{},["prevent"])),onClick:h[5]||(h[5]=x=>o("add-todo"))},[ie(r(Is),{class:"h-4 w-4"}),i("span",Nm,w(r(s)("editor.todo")),1)],40,Rm),i("button",{type:"button",class:"tool-button relative inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",title:l(),"aria-label":l(),"data-promptx-editor-action":"todo-manage",onMousedown:h[6]||(h[6]=Xe(()=>{},["prevent"])),onClick:h[7]||(h[7]=x=>o("manage-todo"))},[ie(r(Ca),{class:"h-4 w-4"}),i("span",jm,w(l()),1),e.todoCount>0?(g(),b("span",Fm,w(e.todoCount>9?"9+":e.todoCount),1)):fe("",!0)],40,Om),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.isCurrentTaskSending,title:r(s)("editor.send"),"aria-label":r(s)("editor.send"),"data-promptx-editor-action":"send",onMousedown:h[8]||(h[8]=Xe(()=>{},["prevent"])),onClick:h[9]||(h[9]=x=>o("send-request"))},[a.value?(g(),ke(r(Vt),{key:0,class:"h-4 w-4 animate-spin"})):(g(),ke(r(Rr),{key:1,class:"h-4 w-4"})),i("span",Vm,w(r(s)("editor.send")),1)],40,Um)])]))}};function zm(e){const{props:t,panelRef:n,onClose:o}=e,s=K({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),a=K(!1),l=K("bottom");function d(){o==null||o()}function h(k=!1){const y=window.innerWidth,L=window.innerHeight,te=12,S=8,M=320,N=560,H=420,V=180,ne=Math.min(N,Math.max(M,y-te*2)),I=Math.min(ne,y-te*2),X=t.anchorRect||{left:(y-I)/2,top:L/2,bottom:L/2};let le=X.left;le+I>y-te&&(le=y-te-I),le<te&&(le=te);const ce=Math.max(0,L-te-(X.bottom+S)),D=Math.max(0,X.top-S-te);k?l.value=ce>=D?"bottom":"top":l.value==="bottom"&&ce<V&&D>ce+24?l.value="top":l.value==="top"&&D<V&&ce>D+24&&(l.value="bottom");const Q=l.value,re=Q==="bottom"?ce:D,ae=Math.max(140,L-te*2),ge=Math.min(ae,Math.max(Math.min(H,re||H),V)),C={left:`${Math.round(le)}px`,width:`${Math.round(I)}px`,maxHeight:`${Math.round(ge)}px`,top:"auto",bottom:"auto"};return Q==="bottom"?C.top=`${Math.round(Math.max(te,X.bottom+S))}px`:C.bottom=`${Math.round(Math.max(te,L-X.top+S))}px`,C}function x(k=!1){const y=h(k);s.value={...s.value,left:y.left,top:y.top,bottom:y.bottom,width:y.width,maxHeight:y.maxHeight}}function c(){return!t.open||!t.anchorRect?!1:(l.value="bottom",x(!0),a.value=!0,!0)}function m(){a.value=!1}function f(k){!t.open||!n.value||n.value.contains(k.target)||d()}return dn(()=>{document.addEventListener("pointerdown",f)}),$t(()=>{document.removeEventListener("pointerdown",f)}),{closePicker:d,initializePanel:c,panelReady:a,panelStyle:s,resetPanel:m,updatePanelPosition:x}}function Hm(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:a,initializePanel:l,panelReady:d,panelStyle:h,resetPanel:x,updatePanelPosition:c}=zm({props:t,panelRef:n,onClose:o}),m=Ya({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return Te(()=>t.open,f=>{if(!f){m.resetData(),x();return}x(),t.anchorRect&&l()&&m.initializeData()},{flush:"sync"}),Te(()=>t.anchorRect,f=>{if(!(!t.open||!f)){if(!d.value){l()&&m.initializeData();return}c(!1)}},{flush:"sync"}),Te(()=>t.sessionId,()=>{m.handleSessionChange()},{flush:"sync",immediate:!0}),Te(()=>t.query,()=>{m.handleQueryChange()},{immediate:!0}),Te(m.visibleItems,()=>{m.handleVisibleItemsChange()},{immediate:!0}),{...m,closePicker:a,panelReady:d,panelStyle:h}}const qm={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},Km={class:"flex shrink-0 items-center gap-2"},Wm={class:"min-h-0 flex-1 overflow-y-auto p-2"},Gm={key:0,class:"theme-empty-state px-3 py-4 text-xs"},Xm={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ym={key:2,class:"theme-empty-state px-3 py-4 text-xs"},Jm={key:3,class:"theme-empty-state px-3 py-4 text-xs"},Qm={key:4,class:"theme-empty-state px-3 py-4 text-xs"},Zm={key:5,class:"space-y-1"},eg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},tg=["onClick"],ng={class:"min-w-0 flex-1"},sg=["innerHTML"],og=["innerHTML"],ag={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},rg=["onClick"],ig={class:"min-w-0 flex-1"},lg=["innerHTML"],ug=["innerHTML"],cg={key:6,class:"space-y-1"},dg={class:"flex items-start gap-1.5"},fg=["onClick"],pg={key:1,class:"block h-5 w-5 shrink-0"},mg=["onClick"],gg={class:"min-w-0 flex-1"},hg={class:"flex items-center gap-1.5"},vg={__name:"PathMentionPicker",props:{open:{type:Boolean,default:!1},sessionId:{type:String,default:""},query:{type:String,default:""},anchorRect:{type:Object,default:null}},emits:["close","select"],setup(e,{expose:t,emit:n}){const o=e,s=n,a=K(null),{t:l}=vt(),{activeKey:d,closePicker:h,collapseActiveDirectory:x,confirmActive:c,currentError:m,currentLoading:f,emitSelect:k,expandActiveDirectory:y,getDisplayName:L,getHighlightedName:te,getHighlightedPath:S,moveActive:M,normalSearchItems:N,normalizedQuery:H,panelReady:V,panelStyle:ne,recentSearchItems:I,setItemRef:X,showSearchEmptyState:le,showTreeEmptyState:ce,toggleDirectory:D,treeItems:Q,visibleItems:re}=Hm({props:o,panelRef:a,onClose:()=>s("close"),onSelect:ae=>s("select",ae)});return t({collapseActiveDirectory:x,moveActive:M,confirmActive:c,expandActiveDirectory:y}),(ae,ge)=>(g(),ke(os,{to:"body"},[e.open&&r(V)?(g(),b("div",{key:0,ref_key:"panelRef",ref:a,class:"theme-popover fixed z-40 flex flex-col overflow-hidden rounded-sm border shadow-lg",style:kn(r(ne))},[i("div",qm,[i("div",Km,[i("div",{class:ve(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",r(f)?"opacity-100":"opacity-0"])},[ie(r(Vt),{class:"h-3.5 w-3.5 animate-spin"})],2),i("button",{type:"button",class:"tool-button inline-flex h-7 w-7 items-center justify-center",onClick:ge[0]||(ge[0]=(...C)=>r(h)&&r(h)(...C))},[ie(r(ka),{class:"h-4 w-4"})])])]),i("div",Wm,[e.sessionId?r(m)?(g(),b("div",Xm,w(r(m)),1)):r(le)?(g(),b("div",Ym,w(r(l)("pathPicker.noResults")),1)):r(ce)?(g(),b("div",Jm,w(r(l)("pathPicker.emptyDirectory")),1)):r(f)&&!r(re).length?(g(),b("div",Qm,w(r(l)("pathPicker.loading")),1)):r(H)?(g(),b("div",Zm,[r(I).length?(g(),b("div",eg,w(r(l)("pathPicker.recent")),1)):fe("",!0),(g(!0),b(Ze,null,it(r(I),C=>(g(),b("button",{key:C.path,ref_for:!0,ref:q=>r(X)(C.path,q),type:"button",class:ve(["theme-list-row focus:outline-none",r(d)===C.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:q=>r(k)(C)},[(g(),ke(cn(C.type==="directory"?r(Dn):r(Sn)),{class:"theme-list-item-icon"})),i("div",ng,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:r(te)(C)},null,8,sg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:r(S)(C)},null,8,og)])],10,tg))),128)),r(H)&&r(N).length?(g(),b("div",ag,w(r(l)("pathPicker.results")),1)):fe("",!0),(g(!0),b(Ze,null,it(r(N),C=>(g(),b("button",{key:C.path,ref_for:!0,ref:q=>r(X)(C.path,q),type:"button",class:ve(["theme-list-row focus:outline-none",r(d)===C.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:q=>r(k)(C)},[(g(),ke(cn(C.type==="directory"?r(Dn):r(Sn)),{class:"theme-list-item-icon"})),i("div",ig,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:r(te)(C)},null,8,lg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:r(S)(C)},null,8,ug)])],10,rg))),128))])):(g(),b("div",cg,[(g(!0),b(Ze,null,it(r(Q),C=>(g(),b("div",{key:C.path,ref_for:!0,ref:q=>r(X)(C.path,q),class:ve(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",r(d)===C.path?"theme-list-item-active":C.type==="directory"&&C.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:kn({paddingLeft:`${C.depth*16+6}px`})},[i("div",dg,[C.type==="directory"?(g(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Xe(q=>r(D)(C.path),["stop"])},[C.loading?(g(),ke(r(Vt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),ke(r(Ta),{key:1,class:ve(["h-3.5 w-3.5 transition",C.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,fg)):(g(),b("span",pg)),i("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:q=>r(k)(C)},[(g(),ke(cn(C.type==="directory"?r(Dn):r(Sn)),{class:ve(["h-4 w-4 shrink-0",C.type==="directory"&&C.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",gg,[i("div",hg,[i("span",{class:ve(["theme-list-item-title truncate",C.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},w(r(L)(C)),3)])])],8,mg)])],6))),128))])):(g(),b("div",Gm,w(r(l)("pathPicker.selectProjectFirst")),1))])],4)):fe("",!0)]))}},yg={__name:"TiptapTextBlockView",props:_o,setup(e){return(t,n)=>(g(),ke(r(To),{"data-promptx-node":"text"},{default:Ge(()=>[ie(r($a),{"data-promptx-node-content":"text",class:"min-h-[40px] whitespace-pre-wrap break-words border-0 bg-transparent p-0 text-[15px] leading-8 text-[var(--theme-textPrimary)] outline-none",as:"div"})]),_:1}))}},gr={__name:"TiptapSpecialBlockFrame",props:{frameClass:{type:String,default:""},headerPaddingClass:{type:String,default:"px-4 py-3"},headerClass:{type:String,default:""},selected:{type:Boolean,default:!1}},setup(e){const t=e,n=G(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=G(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,a)=>(g(),b("div",{class:ve(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:ve(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[Jt(s.$slots,"header",{actionsStateClass:o.value})],2),Jt(s.$slots,"default")],2))}},bt={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function Sg(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))||`block-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Bn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||Sg()),meta:e!=null&&e.meta?{...e.meta}:{}}}function Pn(e=""){return Bn({type:At.TEXT,content:e,meta:{}})}function hs(e){return e&&e.type!==At.TEXT}function xn(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[Pn("")];const n=[];return t.forEach((o,s)=>{const a=Bn(o),l=n[n.length-1];!l&&hs(a)&&n.push(Pn("")),l&&hs(l)&&hs(a)&&n.push(Pn("")),n.push(a),s===t.length-1&&hs(a)&&n.push(Pn(""))}),n}function yo(e=""){const t=String(e||"").split(`
40
- `),n=[];return t.forEach((o,s)=>{o&&n.push({type:bt.TEXT,text:o}),s<t.length-1&&n.push({type:bt.HARD_BREAK})}),n}function wg(e=""){return yo(e)}function xg(e=[]){if(Array.isArray(e))return e;if(typeof(e==null?void 0:e.toArray)=="function")return e.toArray();if(typeof(e==null?void 0:e.forEach)=="function"){const t=[];return e.forEach(n=>{t.push(n)}),t}return[]}function Ms(e=[]){return xg(e).map(t=>{var o;const n=typeof(t==null?void 0:t.type)=="string"?t.type:(o=t==null?void 0:t.type)==null?void 0:o.name;return n===bt.TEXT?String(t.text||""):n===bt.HARD_BREAK?`
41
- `:Ms((t==null?void 0:t.content)||[])}).join("")}function bg(e=[]){return Ms(e)}function kg(e={}){var n,o;const t=Bn(e);return t.type===At.IMAGE?{type:bt.IMAGE_BLOCK,attrs:{clientId:t.clientId,src:String(t.content||"")}}:t.type===At.IMPORTED_TEXT?{type:bt.IMPORTED_TEXT_BLOCK,attrs:{clientId:t.clientId,fileName:String(((n=t.meta)==null?void 0:n.fileName)||""),collapsed:!!((o=t.meta)!=null&&o.collapsed)},content:yo(t.content)}:{type:bt.TEXT_BLOCK,attrs:{clientId:t.clientId},content:yo(t.content)}}function hr(e=[]){return xn(e).map(kg)}function vs(e=[]){return{type:bt.DOC,content:hr(e)}}function _g(e={}){var t,n,o,s,a,l;return(e==null?void 0:e.type)===bt.IMAGE_BLOCK?Bn({type:At.IMAGE,content:String(((t=e.attrs)==null?void 0:t.src)||""),clientId:String(((n=e.attrs)==null?void 0:n.clientId)||""),meta:{}}):(e==null?void 0:e.type)===bt.IMPORTED_TEXT_BLOCK?Bn({type:At.IMPORTED_TEXT,content:Ms(e.content||[]),clientId:String(((o=e.attrs)==null?void 0:o.clientId)||""),meta:{fileName:String(((s=e.attrs)==null?void 0:s.fileName)||""),collapsed:!!((a=e.attrs)!=null&&a.collapsed)}}):(e==null?void 0:e.type)===bt.TEXT_BLOCK?Bn({type:At.TEXT,content:Ms(e.content||[]),clientId:String(((l=e.attrs)==null?void 0:l.clientId)||""),meta:{}}):null}function Tg(e=null){const n=(Array.isArray(e==null?void 0:e.content)?e.content:[]).map(_g).filter(Boolean);return xn(n)}function Gn(e=[]){return JSON.stringify(xn(e).map(t=>{var n,o;return{type:(t==null?void 0:t.type)||"",content:String((t==null?void 0:t.content)||""),meta:{fileName:String(((n=t==null?void 0:t.meta)==null?void 0:n.fileName)||""),collapsed:!!((o=t==null?void 0:t.meta)!=null&&o.collapsed)}}}))}function Cg(e=""){const t=String(e);return{lines:t?t.split(`
42
- `).length:0,chars:t.length}}function Cs(e){var l;const t=(l=e==null?void 0:e.view)==null?void 0:l.dom;if(!(t instanceof HTMLElement))return;const n=t.closest('[data-promptx-editor-scroll="tiptap"]'),o=n instanceof HTMLElement?n.scrollTop:null,s=n instanceof HTMLElement?n.scrollLeft:null,a=()=>{t.focus({preventScroll:!0}),n instanceof HTMLElement&&o!==null&&(n.scrollTop=o,n.scrollLeft=s??0)};if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(a);return}queueMicrotask(a)}const Eg={class:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1.5","data-promptx-imported-meta":""},Ag=["aria-expanded"],$g={class:"theme-heading inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Ig=["aria-expanded"],Pg={class:"mt-0.5 break-all text-[12px] leading-4 text-[var(--theme-textSecondary)]"},Dg=["aria-label"],Lg={class:"max-h-[8.5rem] overflow-hidden whitespace-pre-wrap break-words leading-6"},Mg={key:0,class:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-[var(--theme-appPanelMuted)] to-transparent"},Bg={key:1,class:"theme-muted-text absolute bottom-2 right-4 bg-[var(--theme-appPanelMuted)] pl-2 text-xs"},lo="tool-button inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",Rg={__name:"TiptapImportedTextBlockView",props:_o,setup(e){const t=e,{t:n}=vt(),o=G(()=>{var k;return bg(((k=t.node)==null?void 0:k.content)||[])}),s=G(()=>{var k,y;return String(((y=(k=t.node)==null?void 0:k.attrs)==null?void 0:y.fileName)||n("blockEditor.unnamedFile"))}),a=G(()=>{const k=Cg(o.value);return n("blockEditor.stats",k)}),l=G(()=>n("blockEditor.fileSummary",{name:s.value,stats:a.value})),d=G(()=>{const k=String(o.value||"").replace(/\r\n/g,`
43
- `),y=k.split(`
44
- `),L=[];let te=0;for(const N of y){const H=N.trimEnd(),V=H.length?H:"";if(!(!V&&L[L.length-1]==="")&&(L.push(V),te+=V.length,L.length>=4||te>=220))break}const S=L.join(`
45
- `).trim(),M=k.trim();return{text:S,truncated:L.length<y.length||S.length<M.length}}),h=`${lo} tool-button-danger-subtle`;function x(k){k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),c())}function c(){var k,y,L;(L=t.updateAttributes)==null||L.call(t,{collapsed:!((y=(k=t.node)==null?void 0:k.attrs)!=null&&y.collapsed)}),Cs(t.editor)}function m(){var S;const{editor:k,getPos:y,node:L}=t;if(!k||typeof y!="function"||!L)return;const te=y();k.chain().focus().insertContentAt({from:te,to:te+L.nodeSize},{type:bt.TEXT_BLOCK,attrs:{clientId:String(((S=L.attrs)==null?void 0:S.clientId)||"")},content:wg(o.value)}).run(),Cs(t.editor)}function f(){var k;(k=t.deleteNode)==null||k.call(t),Cs(t.editor)}return(k,y)=>(g(),ke(r(To),{class:"group relative","data-promptx-node":"imported_text"},{default:Ge(()=>[ie(gr,{selected:k.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:Ge(({actionsStateClass:L})=>{var te,S,M,N;return[i("div",Eg,[i("div",{class:"min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((te=k.node.attrs)!=null&&te.collapsed)),onClick:c,onKeydown:x},[i("p",$g,[ie(r(Ps),{class:"h-3.5 w-3.5 shrink-0"}),rn(" "+w(r(n)("blockEditor.file")),1)])],40,Ag),i("div",{"data-promptx-imported-actions":"",class:ve(["col-start-2 row-start-1 flex shrink-0 flex-wrap items-center justify-end gap-1 self-start transition",L])},[i("button",{type:"button",class:ve(lo),contenteditable:"false",onClick:c},[ie(r(bo),{class:ve(["h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5",(S=k.node.attrs)!=null&&S.collapsed?"rotate-180":""])},null,8,["class"]),i("span",null,w((M=k.node.attrs)!=null&&M.collapsed?r(n)("blockEditor.expand"):r(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:ve(lo),contenteditable:"false",onClick:m},[ie(r(Ps),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(r(n)("blockEditor.convertToText")),1)]),i("button",{type:"button",class:ve(h),contenteditable:"false",onClick:f},[ie(r(Os),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(r(n)("blockEditor.delete")),1)])],2),i("div",{class:"col-span-2 min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((N=k.node.attrs)!=null&&N.collapsed)),onClick:c,onKeydown:x},[i("p",Pg,w(l.value),1)],40,Ig)])]}),default:Ge(()=>{var L,te;return[qt(i("div",{class:"theme-secondary-text relative cursor-pointer px-4 py-3 text-[12px] font-mono","data-promptx-imported-preview":"",role:"button",tabindex:"0","aria-label":r(n)("blockEditor.expand"),onClick:c,onKeydown:x},[i("div",Lg,w(d.value.text||r(n)("blockEditor.emptyContent")),1),d.value.truncated?(g(),b("div",Mg)):fe("",!0),d.value.truncated?(g(),b("span",Bg,"...")):fe("",!0)],40,Dg),[[As,(L=k.node.attrs)==null?void 0:L.collapsed]]),qt(ie(r($a),{as:"div","data-promptx-node-content":"imported_text",class:"min-h-[56px] whitespace-pre-wrap break-words px-4 py-4 font-mono text-[12px] leading-7 text-[var(--theme-textPrimary)] outline-none"},null,512),[[As,!((te=k.node.attrs)!=null&&te.collapsed)]])]}),_:1},8,["selected"])]),_:1}))}},Ng={class:"flex min-w-0 items-center justify-between gap-3"},Og={class:"theme-heading min-w-0 inline-flex items-center gap-1.5 text-xs font-medium leading-5"},jg={class:"mx-auto flex w-full max-w-[720px] justify-center px-4 py-4"},Fg=["src","alt"],Ug="tool-button tool-button-danger-subtle inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",Vg={__name:"TiptapImageBlockView",props:_o,setup(e){const t=e,{t:n}=vt();function o(){var a,l;typeof window>"u"||window.dispatchEvent(new CustomEvent("promptx:tiptap-image-preview",{detail:{src:String(((l=(a=t.node)==null?void 0:a.attrs)==null?void 0:l.src)||"")}}))}function s(){var a;(a=t.deleteNode)==null||a.call(t),Cs(t.editor)}return(a,l)=>(g(),ke(r(To),{class:"group","data-promptx-node":"image"},{default:Ge(()=>[ie(gr,{selected:a.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:Ge(({actionsStateClass:d})=>[i("div",Ng,[i("div",Og,[ie(r(Ea),{class:"h-3.5 w-3.5 shrink-0"}),rn(" "+w(r(n)("blockEditor.image")),1)]),i("div",{class:ve(["shrink-0 transition",d])},[i("button",{type:"button",class:ve(Ug),contenteditable:"false",onClick:s},[ie(r(Os),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(r(n)("blockEditor.delete")),1)])],2)])]),default:Ge(()=>{var d;return[i("div",jg,[i("button",{type:"button",class:"inline-flex cursor-zoom-in justify-center",contenteditable:"false",onClick:o},[i("img",{src:(d=a.node.attrs)==null?void 0:d.src,alt:r(n)("blockEditor.insertedImageAlt"),class:"max-h-[380px] w-auto max-w-full object-contain"},null,8,Fg)])])]}),_:1},8,["selected"])]),_:1}))}},zg=["accept"],ua=10*1024*1024,ca=2*1024*1024,da=8*1024*1024,Hg=1500,qg={__name:"TiptapBlockEditor",props:{modelValue:{type:Array,required:!0},codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","clear-request","file-feedback","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,{t:a}=vt(),l=new Set([".md",".markdown",".txt",".js",".mjs",".cjs",".ts",".mts",".cts",".jsx",".tsx",".vue",".json",".css",".scss",".sass",".less",".html",".htm",".xml",".svg",".yml",".yaml",".toml",".ini",".conf",".env",".py",".java",".go",".rs",".rb",".php",".sh",".bash",".zsh",".sql",".c",".cc",".cpp",".h",".hpp",".cs",".kt",".swift",".log",".csv"]),d=new Set(["application/json","application/ld+json","application/xml","application/javascript","application/x-javascript","application/typescript","application/x-typescript","application/yaml","application/x-yaml","application/toml","application/x-toml","application/x-sh","application/x-shellscript","application/sql"]),h=["image/*",".md,.markdown,.txt,.js,.mjs,.cjs,.ts,.mts,.cts,.jsx,.tsx,.vue,.json,.css,.scss,.sass,.less,.html,.htm,.xml,.svg,.yml,.yaml,.toml,.ini,.conf,.env,.py,.java,.go,.rs,.rb,.php,.sh,.bash,.zsh,.sql,.c,.cc,.cpp,.h,.hpp,.cs,.kt,.swift,.log,.csv",".pdf","text/plain","text/markdown","text/*","application/json","application/xml","application/javascript","application/typescript","application/yaml","application/x-yaml","application/toml","application/x-toml","application/x-sh","application/x-shellscript","application/sql","application/pdf"].join(","),x=K(null),c=K(null),m=K(""),f=K(Re()),k=K(null),y=K(null),L=K(!1),te=K(0),S=G(()=>xn(o.modelValue)),M=G(()=>S.value.filter(E=>(E==null?void 0:E.type)===At.IMAGE&&String(E.content||"").trim()).map(E=>String(E.content||"").trim()));let N=Gn(S.value);function H(E=X.value){if(!E)return!1;const F=Tg(E.getJSON()),ee=Gn(F);return ee===N?!1:(N=ee,s("update:modelValue",F),!0)}const V=Kr.extend({name:bt.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return Gs(yg)}}),ne=Uo.create({name:bt.IMPORTED_TEXT_BLOCK,group:"block",content:"inline*",defining:!0,selectable:!0,draggable:!1,addAttributes(){return{clientId:{default:""},fileName:{default:""},collapsed:{default:!1}}},parseHTML(){return[{tag:'div[data-type="promptx-imported-text-block"]'}]},renderHTML({HTMLAttributes:E}){return["div",{...E,"data-type":"promptx-imported-text-block"}]},addNodeView(){return Gs(Rg)}}),I=Uo.create({name:bt.IMAGE_BLOCK,group:"block",atom:!0,selectable:!0,draggable:!1,addAttributes(){return{clientId:{default:""},src:{default:""}}},parseHTML(){return[{tag:'div[data-type="promptx-image-block"]'}]},renderHTML({HTMLAttributes:E}){return["div",{...E,"data-type":"promptx-image-block"}]},addNodeView(){return Gs(Vg)}}),X=Wr({extensions:[Gr.configure({paragraph:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,codeBlock:!1,horizontalRule:!1,listItem:!1,bold:!1,italic:!1,strike:!1,code:!1,dropcursor:!0,gapcursor:!0}),V,ne,I],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown(E,F){return yr(F,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:pe()})?(F.preventDefault(),F.stopPropagation(),s("send-request"),!0):!F.shiftKey&&!F.altKey&&(F.metaKey||F.ctrlKey)&&String(F.key||"").toLowerCase()==="k"?ct():Tt(F)}},content:vs(S.value),onCreate({editor:E}){mt(E)},onFocus({editor:E}){L.value=!0,mt(E)},onBlur(){L.value=!1},onSelectionUpdate({editor:E}){mt(E)},onUpdate({editor:E}){te.value=Date.now(),H(E),mt(E)}});Te(X,E=>{if(!E)return;const F=xn(o.modelValue);N=Gn(F),E.commands.setContent(vs(F),!1)},{immediate:!0}),Te(()=>o.modelValue,E=>{const F=X.value;if(!F){N=Gn(xn(E));return}const ee=xn(E),he=Gn(ee);he!==N&&(N=he,F.commands.setContent(vs(ee),!1))},{deep:!0});function le(E){const F=String(E||"").trim();F&&s("file-feedback",F)}function ce(E){const F=String((E==null?void 0:E.name)||"").trim().toLowerCase();return F.includes(".")?`.${F.split(".").pop()}`:""}function D(E,F){return String((E==null?void 0:E.name)||"").trim()||a(F)}function Q(E){const F=Math.max(0,Number(E)||0);return F>=1024*1024?`${(F/(1024*1024)).toFixed(F>=10*1024*1024?0:1)} MB`:F>=1024?`${Math.round(F/1024)} KB`:`${F} B`}function re(E){if(!E)return!1;const F=String(E.type||"").toLowerCase(),ee=ce(E);return F.startsWith("text/")||l.has(ee)||d.has(F)}function ae(E){if(!E)return!1;const F=String(E.name||"").toLowerCase(),ee=String(E.type||"").toLowerCase();return F.endsWith(".pdf")||ee==="application/pdf"}function ge(E){const F=Array.from(E||[]).filter(Boolean),ee={imageFiles:[],textFiles:[],pdfFiles:[]},he=[],Be=[];return F.forEach(Ie=>{if(Ie.type.startsWith("image/")){if(Ie.size>ua){Be.push({name:D(Ie,"blockEditor.unnamedImage"),limit:Q(ua)});return}ee.imageFiles.push(Ie);return}if(ae(Ie)){if(Ie.size>da){Be.push({name:D(Ie,"blockEditor.unnamedPdf"),limit:Q(da)});return}ee.pdfFiles.push(Ie);return}if(re(Ie)){if(Ie.size>ca){Be.push({name:D(Ie,"blockEditor.unnamedFile"),limit:Q(ca)});return}ee.textFiles.push(Ie);return}he.push(D(Ie,"blockEditor.unnamedFile"))}),{...ee,unsupportedFiles:he,oversizedFiles:Be}}function C({unsupportedFiles:E=[],oversizedFiles:F=[]}={}){var ee;E.length&&le(a("blockEditor.unsupportedFiles",{names:E.slice(0,3).join("、"),extra:Math.max(0,E.length-3)})),F.length&&le(a("blockEditor.oversizedFiles",{names:F.slice(0,2).map(he=>he.name).join("、"),extra:Math.max(0,F.length-2),limit:((ee=F[0])==null?void 0:ee.limit)||""}))}function q(E){const{imageFiles:F,textFiles:ee,pdfFiles:he,unsupportedFiles:Be,oversizedFiles:Ie}=ge(E);return C({unsupportedFiles:Be,oversizedFiles:Ie}),ee.length&&s("import-text-files",ee),he.length&&s("import-pdf-files",he),F.length&&s("upload-files",F),F.length+ee.length+he.length>0}function U(E){const F=[...E.clipboardData.items].filter(ee=>ee.kind==="file").map(ee=>ee.getAsFile()).filter(Boolean);F.length&&(E.preventDefault(),q(F))}function Ve(E){E.preventDefault(),q(E.dataTransfer.files)}function Ae(E){const F=X.value;if(!F)return;const ee=E.target instanceof Element?E.target:null,he=E.currentTarget instanceof Element?E.currentTarget:null,Be=F.view.dom instanceof Element?F.view.dom:null;!ee||!he||!Be||ee.closest('button, input, textarea, select, a, [contenteditable="false"]')||!he.contains(ee)||ee.closest("[data-promptx-node]")||!(ee===he||ee===Be||he.contains(ee))||(E.preventDefault(),qe())}function Oe(E){q(E.target.files),E.target.value=""}function Ne(){var E;(E=x.value)==null||E.click()}function qe(){const E=X.value;E&&E.chain().focus("end").run()}function et(){var ee,he;const E=X.value;if(!E)return!1;(he=(ee=E.view.domObserver)==null?void 0:ee.flush)==null||he.call(ee);const F=H(E);return F&&(te.value=Date.now()),mt(E),F}function we(E=[]){const F=X.value;!F||!E.length||F.chain().focus().insertContent(E).run()}function O(E=[]){we(hr(E))}function J(E=[]){O(E)}function de(E=[]){O(E)}function ye(){const E=X.value;E&&E.commands.setContent(vs([Pn("")]),!0)}function pe(){var E,F;return!!((F=(E=X.value)==null?void 0:E.view)!=null&&F.composing)}function Ee(){var E;return pe()||L.value||(E=X.value)!=null&&E.isFocused?!0:Date.now()-te.value<Hg}function Ce(){var he;const E=X.value;if(!E)return!1;const F=E.state.selection,ee=F.$from.nodeAfter||F.$from.parent;return((he=ee==null?void 0:ee.type)==null?void 0:he.name)===bt.IMPORTED_TEXT_BLOCK}function Pe(E){var ee;const F=String(((ee=E==null?void 0:E.detail)==null?void 0:ee.src)||"").trim();F&&(m.value=F)}function Re(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function Ke(E=null,F=null){return!E||!F?!1:E.start===F.start&&E.end===F.end&&E.query===F.query&&E.clientId===F.clientId}function ot(){k.value=null}function De(E={}){const{suppressCurrent:F=!1}=E,ee=f.value;F&&ee.open&&(y.value={start:ee.start,end:ee.end,query:ee.query,clientId:ee.clientId}),f.value=Re(),ot()}function Me(){De({suppressCurrent:!0})}function _e(E=X.value){var He,Je,ut;if(!E)return null;const F=E.state.selection;if(!F.empty)return null;const{$from:ee,from:he}=F,Be=((Je=(He=ee.parent)==null?void 0:He.type)==null?void 0:Je.name)||"";if(![bt.TEXT_BLOCK,bt.IMPORTED_TEXT_BLOCK].includes(Be))return null;const Ie=ee.parent.textBetween(0,ee.parentOffset,`
46
- `,"\0");return{from:he,node:ee.parent,nodeTypeName:Be,nodeStart:ee.start(),parentOffset:ee.parentOffset,clientId:String(((ut=ee.parent.attrs)==null?void 0:ut.clientId)||""),textBefore:Ie}}function at(E=f.value.end){const F=X.value;if(typeof E=="object"&&E!==null&&(E=f.value.end),!F||!f.value.open||E<0){ot();return}try{const ee=F.view.coordsAtPos(E);k.value={left:ee.left,right:ee.left,top:ee.bottom,bottom:ee.bottom,width:0,height:0}}catch{ot()}}function mt(E=X.value){const F=_e(E),ee=f.value;if(ee.open&&ee.trigger==="shortcut"){if(!F||F.clientId!==ee.clientId||F.from<ee.start){De();return}const Je=E.state.doc.textBetween(ee.start,F.from,`
47
- `,"\0");if(/\s/.test(Je)){De();return}y.value=null,f.value={...ee,end:F.from,query:Je},at(F.from);return}if(!F){De();return}const he=F.textBefore.lastIndexOf("@");if(he<0){De();return}const Be=F.textBefore.slice(he+1);if(/\s/.test(Be)){De();return}const Ie=F.nodeStart+he,He=F.from;Ke(y.value,{start:Ie,end:He,query:Be,clientId:F.clientId})||(y.value=null,f.value={open:!0,start:Ie,end:He,query:Be,trigger:"mention",blockType:F.nodeTypeName,clientId:F.clientId},at(He))}function ct(){const E=X.value,F=_e(E);return!E||!F?!1:(y.value=null,f.value={open:!0,start:F.from,end:F.from,query:"",trigger:"shortcut",blockType:F.nodeTypeName,clientId:F.clientId},at(F.from),!0)}function yt(E){const F=X.value,ee=String((E==null?void 0:E.path)||"").trim(),he=f.value;if(!F||!ee||he.start<0||he.end<he.start)return De(),!1;const Be=he.trigger==="shortcut"?`${ee} `:`@${ee} `,Ie=he.start+Be.length;return F.chain().focus().command(({tr:He,dispatch:Je})=>(He.insertText(Be,he.start,he.end),He.setSelection(br.create(He.doc,Ie)),Je==null||Je(He),!0)).run(),te.value=Date.now(),y.value=null,De(),!0}function Tt(E){var F,ee,he,Be,Ie,He,Je,ut,ht,tt;if(!f.value.open)return!1;if(E.key==="Escape")return Me(),!0;if(E.key==="ArrowDown")return!!((ee=(F=c.value)==null?void 0:F.moveActive)!=null&&ee.call(F,1));if(E.key==="ArrowUp")return!!((Be=(he=c.value)==null?void 0:he.moveActive)!=null&&Be.call(he,-1));if(f.value.query&&(E.key==="ArrowLeft"||E.key==="ArrowRight"))return!1;if(E.key==="ArrowRight"){const dt=(He=(Ie=c.value)==null?void 0:Ie.expandActiveDirectory)==null?void 0:He.call(Ie);return dt&&typeof dt.then=="function"?(dt.catch(()=>{}),!0):!!dt}return E.key==="ArrowLeft"?!!((ut=(Je=c.value)==null?void 0:Je.collapseActiveDirectory)!=null&&ut.call(Je)):!E.shiftKey&&!E.altKey&&!E.metaKey&&!E.ctrlKey&&E.key==="Enter"?!!((tt=(ht=c.value)==null?void 0:ht.confirmActive)!=null&&tt.call(ht)):!1}return dn(()=>{window.addEventListener("promptx:tiptap-image-preview",Pe),window.addEventListener("resize",at),window.addEventListener("scroll",at)}),$t(()=>{window.removeEventListener("promptx:tiptap-image-preview",Pe),window.removeEventListener("resize",at),window.removeEventListener("scroll",at)}),Te(()=>o.codexSessionId,()=>{De()}),t({clearContent:ye,flushPendingInput:et,focusEditor:qe,insertBlocks:O,insertImportedBlocks:J,insertUploadedBlocks:de,isComposing:pe,isEditing:Ee,isImportedBlockActive:Ce,openFilePicker:Ne}),(E,F)=>(g(),b("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:Ve,onDragover:F[1]||(F[1]=Xe(()=>{},["prevent"])),onPaste:U},[i("input",{ref_key:"fileInputRef",ref:x,class:"hidden",type:"file",accept:r(h),multiple:"",onChange:Oe},null,40,zg),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:Ae},[r(X)?(g(),ke(r(Xr),{key:0,editor:r(X),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):fe("",!0)],32),ie(Ra,{modelValue:m.value,"onUpdate:modelValue":F[0]||(F[0]=ee=>m.value=ee),images:M.value},null,8,["modelValue","images"]),ie(vg,{ref_key:"mentionPickerRef",ref:c,open:f.value.open&&!!k.value,"session-id":e.codexSessionId,query:f.value.query,"anchor-rect":k.value,onClose:Me,onSelect:yt},null,8,["open","session-id","query","anchor-rect"])],32))}},Kg={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},fa={__name:"WorkbenchInputPanel",props:{codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"},modelValue:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","file-feedback","clear-request","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,a=K(null),{t:l}=vt(),d=G({get:()=>o.modelValue,set:S=>s("update:modelValue",S)});function h(){var S,M;(M=(S=a.value)==null?void 0:S.openFilePicker)==null||M.call(S)}function x(){var S,M;(M=(S=a.value)==null?void 0:S.focusEditor)==null||M.call(S)}function c(){var S,M;return((M=(S=a.value)==null?void 0:S.flushPendingInput)==null?void 0:M.call(S))||!1}function m(S){var M,N;(N=(M=a.value)==null?void 0:M.insertBlocks)==null||N.call(M,S)}function f(S){var M,N;(N=(M=a.value)==null?void 0:M.insertImportedBlocks)==null||N.call(M,S)}function k(S){var M,N;(N=(M=a.value)==null?void 0:M.insertUploadedBlocks)==null||N.call(M,S)}function y(){var S,M;return((M=(S=a.value)==null?void 0:S.isImportedBlockActive)==null?void 0:M.call(S))||!1}function L(){var S,M;return((M=(S=a.value)==null?void 0:S.isComposing)==null?void 0:M.call(S))||!1}function te(){var S,M;return((M=(S=a.value)==null?void 0:S.isEditing)==null?void 0:M.call(S))||!1}return t({focusEditor:x,flushPendingInput:c,insertBlocks:m,insertImportedBlocks:f,insertUploadedBlocks:k,isComposing:L,isEditing:te,isImportedBlockActive:y,openFilePicker:h}),(S,M)=>e.loading&&!e.modelValue.length?(g(),b("section",Kg,w(r(l)("workbench.loadingTaskContent")),1)):(g(),ke(qg,{key:1,ref_key:"blockEditorRef",ref:a,modelValue:d.value,"onUpdate:modelValue":M[0]||(M[0]=N=>d.value=N),"codex-session-id":e.codexSessionId,"send-behavior":e.sendBehavior,onUploadFiles:M[1]||(M[1]=N=>s("upload-files",N)),onImportTextFiles:M[2]||(M[2]=N=>s("import-text-files",N)),onImportPdfFiles:M[3]||(M[3]=N=>s("import-pdf-files",N)),onFileFeedback:M[4]||(M[4]=N=>s("file-feedback",N)),onClearRequest:M[5]||(M[5]=N=>s("clear-request")),onSendRequest:M[6]||(M[6]=N=>s("send-request"))},null,8,["modelValue","codex-session-id","send-behavior"]))}},Wg={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},Gg={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},Xg={class:"flex items-center gap-2"},Yg=["title","aria-label"],Jg={class:"min-w-0 flex-1"},Qg=["value","placeholder"],Zg=["disabled"],eh={class:"truncate"},th={__name:"WorkbenchMobileDetailHeader",props:{currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},title:{type:String,default:""},titleInputValue:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""}},emits:["back","begin-edit","title-blur","cancel-title-edit","update:titleInputValue"],setup(e,{emit:t}){const n=t,{t:o}=vt();return(s,a)=>(g(),b("section",Wg,[i("div",Gg,[i("div",Xg,[i("button",{type:"button",class:"tool-button inline-flex h-8 w-8 shrink-0 items-center justify-center px-0 py-0 text-[11px]",title:r(o)("workbench.tasks"),"aria-label":r(o)("workbench.tasks"),onClick:a[0]||(a[0]=l=>n("back"))},[ie(r(Nr),{class:"h-3.5 w-3.5"})],8,Yg),i("div",Jg,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(g(),b("input",{key:0,value:e.titleInputValue,type:"text",maxlength:"140","data-task-title-input":"current",class:"block w-full appearance-none border-0 bg-transparent p-0 text-left text-[13px] font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||r(o)("workbench.untitledTask"),onInput:a[1]||(a[1]=l=>n("update:titleInputValue",l.target.value)),onKeydown:[a[2]||(a[2]=Kt(Xe(l=>l.target.blur(),["prevent"]),["enter"])),a[3]||(a[3]=Kt(Xe(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:a[4]||(a[4]=l=>n("title-blur"))},null,40,Qg)):(g(),b("button",{key:1,type:"button",class:"inline-flex w-full items-center gap-1 truncate bg-transparent p-0 text-left text-[13px] font-semibold leading-5",disabled:!e.currentTaskSlug,onClick:a[5]||(a[5]=l=>n("begin-edit"))},[i("span",eh,w(e.title||r(o)("workbench.untitledTask")),1),ie(r(Zn),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,Zg))])])])]))}},nh={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},sh={class:"workbench-panel-header theme-divider border-b px-4 py-4"},oh={class:"flex items-center justify-between gap-3"},ah={class:"flex min-h-8 items-center"},rh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ih=["title"],lh=["disabled","title"],uh={class:"whitespace-nowrap"},ch={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},dh={key:0,class:"theme-empty-state px-3 py-4 text-sm"},fh=["onClick"],ph={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},mh={class:"flex items-start justify-between gap-3"},gh={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},hh=["title","aria-label"],vh={class:"min-w-0 h-5 flex-1 overflow-hidden"},yh=["value","placeholder"],Sh=["title","onClick"],wh={class:"min-w-0 truncate"},xh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},bh={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},kh={class:"mt-2 flex items-center justify-between gap-3"},_h={class:"min-w-0 text-[11px] opacity-70"},Th={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Ch={class:"theme-divider border-t px-3 py-3"},Eh={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},Ah={class:"min-w-0 break-words"},$h={class:"grid grid-cols-2 gap-2"},Ih=["disabled","title"],Ph={class:"whitespace-nowrap"},Dh=["disabled","title"],Lh={class:"whitespace-nowrap"},Mh={__name:"WorkbenchTaskListPanel",props:{loadingTasks:{type:Boolean,default:!1},tasks:{type:Array,default:()=>[]},currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},draftTitle:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""},creatingTask:{type:Boolean,default:!1},loadingTask:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},error:{type:String,default:""},removingTask:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},mobile:{type:Boolean,default:!1}},emits:["open-settings","create-task","reorder-task","select-task","title-click","title-blur","cancel-title-edit","update:draftTitle","edit-task","delete-task"],setup(e,{emit:t}){const n=e,o=t,{t:s}=vt(),a=K([]);Te(()=>n.tasks,f=>{a.value=Array.isArray(f)?[...f]:[]},{immediate:!0});function l(f){return f.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":f.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function d(){return"theme-status-warning"}function h(f){const k=new Date(f.updatedAt);return Number.isNaN(k.getTime())?"":Sa(k.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function x(f){var k,y;return!!((k=f==null?void 0:f.workspaceDiffSummary)!=null&&k.supported&&((y=f==null?void 0:f.workspaceDiffSummary)!=null&&y.fileCount))}function c(f){return f.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function m(f){if(n.mobile)return;const k=Number(f==null?void 0:f.oldIndex),y=Number(f==null?void 0:f.newIndex);!Number.isInteger(k)||!Number.isInteger(y)||k===y||o("reorder-task",a.value.map(L=>String((L==null?void 0:L.slug)||"").trim()).filter(Boolean))}return(f,k)=>(g(),b("aside",nh,[i("div",sh,[i("div",oh,[i("div",ah,[i("div",rh,[ie(r(Or),{class:"h-4 w-4"}),i("span",null,w(r(s)("workbench.title")),1)])]),i("button",{type:"button",class:"tool-button inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-xs",title:r(s)("workbench.settings"),onClick:k[0]||(k[0]=y=>o("open-settings"))},[ie(r(jr),{class:"h-4 w-4"}),i("span",{class:ve(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},w(r(s)("workbench.settings")),3)],8,ih)]),i("button",{type:"button",class:"tool-button tool-button-primary mt-4 inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:e.creatingTask||e.uploading,title:e.creatingTask?r(s)("workbench.creatingTask"):r(s)("workbench.createTask"),onClick:k[1]||(k[1]=y=>o("create-task"))},[ie(r(Is),{class:"h-4 w-4"}),i("span",uh,w(e.creatingTask?r(s)("workbench.creatingTask"):r(s)("workbench.createTask")),1)],8,lh)]),i("div",ch,[e.loadingTasks&&!e.tasks.length?(g(),b("div",dh,w(r(s)("workbench.loadingTasks")),1)):(g(),ke(r(Fr),{key:1,modelValue:a.value,"onUpdate:modelValue":k[8]||(k[8]=y=>a.value=y),class:"space-y-2",animation:180,disabled:e.mobile||e.tasks.length<=1,handle:".task-drag-handle","ghost-class":"workbench-task-card--ghost","chosen-class":"workbench-task-card--chosen","drag-class":"workbench-task-card--dragging","fallback-tolerance":"6",onEnd:m},{default:Ge(()=>[(g(!0),b(Ze,null,it(a.value,y=>{var L,te;return g(),b("article",{key:y.slug,class:ve(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(y)]),onClick:S=>o("select-task",y.slug)},[y.slug===e.currentTaskSlug?(g(),b("span",ph)):fe("",!0),i("div",mh,[i("div",gh,[e.mobile?fe("",!0):(g(),b("button",{key:0,type:"button",class:"task-drag-handle mt-0.5 inline-flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded-sm opacity-45 transition hover:opacity-80 active:cursor-grabbing",title:r(s)("workbench.dragToReorder"),"aria-label":r(s)("workbench.dragToReorder"),tabindex:"-1",onClick:k[2]||(k[2]=Xe(()=>{},["stop"]))},[ie(r(Ur),{class:"h-3.5 w-3.5"})],8,hh)),i("div",vh,[y.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===y.slug?(g(),b("input",{key:0,value:e.draftTitle,type:"text",maxlength:"140","data-task-title-input":"current",class:"block h-5 min-h-0 w-full appearance-none border-0 bg-transparent p-0 text-left text-sm font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||r(s)("workbench.untitledTask"),onClick:k[3]||(k[3]=Xe(()=>{},["stop"])),onInput:k[4]||(k[4]=S=>o("update:draftTitle",S.target.value)),onKeydown:[k[5]||(k[5]=Kt(Xe(S=>S.target.blur(),["prevent"]),["enter"])),k[6]||(k[6]=Kt(Xe(S=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:k[7]||(k[7]=S=>o("title-blur"))},null,40,yh)):(g(),b("button",{key:1,type:"button",class:ve(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",y.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:y.displayTitle,onClick:Xe(S=>o("title-click",y.slug),["stop"])},[(L=y.automation)!=null&&L.enabled?(g(),ke(r($s),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):fe("",!0),i("span",wh,w(y.displayTitle),1)],10,Sh))])]),i("div",xh,[y.sending?(g(),b("span",{key:0,class:ve(["inline-flex items-center gap-1.5 rounded-sm border border-dashed px-1.5 py-0.5",d()])},[k[11]||(k[11]=i("span",{class:"task-loading-dots","aria-hidden":"true"},[i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"})],-1)),i("span",null,w(r(s)("workbench.running")),1)],2)):fe("",!0)])]),i("div",bh,w(y.lastPromptPreview||r(s)("workbench.noMessagesYet")),1),i("div",kh,[i("div",_h,w(h(y)),1),i("div",Th,[x(y)?(g(),b("span",{key:0,class:ve(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",c(y)])},[i("span",null,w(r(s)("workbench.filesCount",{count:((te=y.workspaceDiffSummary)==null?void 0:te.fileCount)||0})),1)],2)):fe("",!0)])])],10,fh)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",Ch,[e.error?(g(),b("div",Eh,[ie(r(ko),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",Ah,w(e.error),1)])):fe("",!0),i("div",$h,[i("button",{type:"button",class:"tool-button inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask,title:r(s)("workbench.editTask"),onClick:k[9]||(k[9]=y=>o("edit-task"))},[ie(r(Zn),{class:"h-4 w-4"}),i("span",Ph,w(r(s)("workbench.editTask")),1)],8,Ih),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask||e.isCurrentTaskSending,title:e.removingTask?r(s)("workbench.deletingTask"):r(s)("workbench.deleteTask"),onClick:k[10]||(k[10]=y=>o("delete-task"))},[ie(r(Os),{class:"h-4 w-4"}),i("span",Lh,w(e.removingTask?r(s)("workbench.deletingTask"):r(s)("workbench.deleteTask")),1)],8,Dh)])])]))}},pa=wa(Mh,[["__scopeId","data-v-2eaa6605"]]),Bh={class:"min-w-0"},Rh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Nh={class:"theme-muted-text mt-1 text-xs leading-5"},Oh={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},jh={class:"theme-muted-text"},Fh={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},Uh={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},Vh={class:"space-y-3"},zh={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},Hh={class:"min-w-0 flex-1"},qh={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},Kh={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},Wh={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},Gh={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},Xh={class:"rounded-sm border border-dashed px-2 py-1"},Yh={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Jh={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Qh={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Zh={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},ev=["onClick"],tv=["onClick"],nv={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},sv={__name:"WorkbenchTodoDialog",props:{items:{type:Array,default:()=>[]},open:{type:Boolean,default:!1}},emits:["close","delete","use"],setup(e,{emit:t}){const n=e,o=t,{t:s}=vt(),a=G(()=>(n.items||[]).map(d=>{var y;const h=Array.isArray(d==null?void 0:d.blocks)?d.blocks:[],x=((y=h.find(L=>["text","imported_text"].includes(String((L==null?void 0:L.type)||""))&&String((L==null?void 0:L.content)||"").trim()))==null?void 0:y.content)||"",c=String(x||"").replace(/\s+/g," ").trim().slice(0,120),m=h.filter(L=>String((L==null?void 0:L.type)||"")==="image").length,f=h.filter(L=>String((L==null?void 0:L.type)||"")==="imported_text").length,k=h.filter(L=>String((L==null?void 0:L.type)||"")==="text"&&String((L==null?void 0:L.content)||"").trim()).length;return{...d,blockCount:h.length,imageCount:m,importedCount:f,preview:c||(m?s("todoDialog.imagePreview",{count:m}):s("todoDialog.noPreview")),textCount:k,timeLabel:l(d==null?void 0:d.createdAt)}}));function l(d=""){const h=Date.parse(String(d||""));if(!h)return s("todoDialog.justAdded");try{return new Intl.DateTimeFormat(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(h))}catch{return String(d||"")}}return(d,h)=>(g(),ke(js,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel max-w-3xl sm:h-[40rem] sm:max-h-[86vh]","header-class":"px-5 py-4","body-class":"min-h-0 flex flex-1 flex-col overflow-hidden",onClose:h[0]||(h[0]=x=>o("close"))},{title:Ge(()=>[i("div",Bh,[i("div",Rh,[ie(r(Ca),{class:"h-4 w-4"}),i("span",null,w(r(s)("todoDialog.title")),1)]),i("p",Nh,w(r(s)("todoDialog.intro")),1)])]),default:Ge(()=>[i("div",Oh,[i("span",jh,w(r(s)("todoDialog.summary",{count:a.value.length})),1),i("span",Fh,w(r(s)("todoDialog.summaryHint")),1)]),a.value.length?(g(),b("div",Uh,[i("div",Vh,[(g(!0),b(Ze,null,it(a.value,x=>(g(),b("article",{key:x.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",zh,[i("div",Hh,[i("div",qh,[i("span",null,w(r(s)("todoDialog.itemTitle")),1),i("span",Kh,[ie(r($s),{class:"h-3.5 w-3.5"}),rn(" "+w(x.timeLabel),1)])]),i("p",Wh,w(x.preview),1),i("div",Gh,[i("span",Xh,w(r(s)("todoDialog.blockCount",{count:x.blockCount})),1),x.textCount?(g(),b("span",Yh,[ie(r(Ps),{class:"h-3.5 w-3.5"}),rn(" "+w(r(s)("todoDialog.textCount",{count:x.textCount})),1)])):fe("",!0),x.importedCount?(g(),b("span",Jh,[ie(r(Ps),{class:"h-3.5 w-3.5"}),rn(" "+w(r(s)("todoDialog.importedCount",{count:x.importedCount})),1)])):fe("",!0),x.imageCount?(g(),b("span",Qh,[ie(r(Ea),{class:"h-3.5 w-3.5"}),rn(" "+w(r(s)("todoDialog.imageCount",{count:x.imageCount})),1)])):fe("",!0)])]),i("div",Zh,[i("button",{type:"button",class:"tool-button inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:c=>o("use",x.id)},[ie(r(Vr),{class:"h-4 w-4"}),i("span",null,w(r(s)("todoDialog.use")),1)],8,ev),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:c=>o("delete",x.id)},[ie(r(Os),{class:"h-4 w-4"}),i("span",null,w(r(s)("todoDialog.delete")),1)],8,tv)])])]))),128))])])):(g(),b("div",nv,w(r(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},ov={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},av={__name:"TopToast",props:{message:{type:String,default:""},type:{type:String,default:"success"}},setup(e){const t=e;function n(s="success"){return s==="warning"?"theme-status-warning":s==="error"?"theme-status-danger":s==="info"?"theme-status-info":"theme-status-success"}function o(s="success"){return s==="warning"?ko:s==="error"?zr:s==="info"?Hr:qr}return(s,a)=>(g(),ke(os,{to:"body"},[i("div",ov,[ie(ba,{"enter-active-class":"transform transition duration-200 ease-out","enter-from-class":"-translate-y-3 opacity-0","enter-to-class":"translate-y-0 opacity-100","leave-active-class":"transform transition duration-150 ease-in","leave-from-class":"translate-y-0 opacity-100","leave-to-class":"-translate-y-2 opacity-0"},{default:Ge(()=>[e.message?(g(),b("div",{key:0,class:ve(["app-top-toast flex max-w-md items-center gap-2 rounded-sm border px-4 py-2 text-sm shadow-[var(--theme-shadowPanel)] backdrop-blur",n(t.type)])},[(g(),ke(cn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,w(e.message),1)],2)):fe("",!0)]),_:1})])]))}};function rv(e,t=!1){const n=K(!!t);let o=null,s=()=>{};function a(l){n.value=!!l}return dn(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;o=window.matchMedia(e),a(o.matches);const l=d=>{a(d.matches)};if(typeof o.addEventListener=="function"){o.addEventListener("change",l),s=()=>o==null?void 0:o.removeEventListener("change",l);return}typeof o.addListener=="function"&&(o.addListener(l),s=()=>o==null?void 0:o.removeListener(l))}),$t(()=>{s()}),{matches:n}}const iv="(max-width: 1023px)",Es="promptxWorkbenchMobileView";function uo(e){return(e==null?void 0:e[Es])==="detail"}function lv({currentTaskSlug:e}){const{matches:t}=rv(iv),n=K("tasks"),o=K("activity");function s(m="tasks"){if(typeof window>"u")return;const f={...window.history.state||{}};m==="detail"?f[Es]="detail":delete f[Es],window.history.replaceState(f,"")}function a(){if(typeof window>"u")return;const m={...window.history.state||{},[Es]:"detail"};window.history.pushState(m,"")}function l(m=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=uo(m)?"detail":"tasks"}function d(m){t.value=!!m,l(typeof window>"u"?null:window.history.state)}function h(m={}){const{pushHistory:f=!0}=m;if(n.value="detail",!!t.value){if(f){a();return}s("detail")}}function x(m={}){const{useHistory:f=!0}=m;if(!t.value){n.value="tasks";return}if(f&&typeof window<"u"&&uo(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function c(m){t.value&&(n.value=uo(m.state)&&e.value?"detail":"tasks")}return dn(()=>{typeof window>"u"||window.addEventListener("popstate",c)}),$t(()=>{typeof window<"u"&&window.removeEventListener("popstate",c)}),Te(t,m=>{d(m)},{immediate:!0}),Te(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:h,isMobileLayout:t,leaveMobileDetail:x,mobileDetailTab:o,mobileView:n}}const So="PromptX";function uv(e=""){const t=String(r(e)||"").trim();return t?`${So} (${t})`:So}function cv(e=""){kr(()=>{typeof document>"u"||(document.title=uv(e))}),$t(()=>{typeof document>"u"||(document.title=So)})}const Rn="success";function dv(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||Rn).trim()||Rn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:Rn,duration:t}}function fv(e=2200){const t=K(""),n=K(Rn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=Rn}function a(l,d=e){const h=dv(l,d);if(!h.message){s();return}t.value=h.message,n.value=h.type,o&&window.clearTimeout(o),o=window.setTimeout(()=>{t.value="",n.value=Rn,o=null},h.duration)}return $t(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:a,clearToast:s}}function pv(e="",t=""){const n=String(e||"").trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;try{return new URL(n,t).toString()}catch{return n}}function mv(e=""){const t=String(e||"").replace(/\r\n/g,`
48
- `).split(`
49
- `);for(;t.length&&!String(t[0]||"").trim();)t.shift();for(;t.length&&!String(t[t.length-1]||"").trim();)t.pop();return t.join(`
50
- `)}function gv(e,t){const n=[];for(const[o,s]of((e==null?void 0:e.blocks)||[]).entries()){if(s.type===At.TEXT||s.type===At.IMPORTED_TEXT){const a=mv(s.content);a&&n.push(a,"");continue}if(s.type===At.IMAGE){const a=pv(s.content,t);a&&n.push(a,"")}}return n.join(`
51
- `).trim()}function hv(e,t){return gv(e,t)}const wo="promptx:active-task-slug",vv=150,yv=1500;function Bs(e=null){return!e||typeof e!="object"?null:{supported:!!e.supported,fileCount:Math.max(0,Number(e.fileCount)||0),additions:Math.max(0,Number(e.additions)||0),deletions:Math.max(0,Number(e.deletions)||0),statsComplete:!!e.statsComplete}}function un(e=[]){return(e||[]).map(t=>{var n,o;return{...t,clientId:String((t==null?void 0:t.clientId)||(t==null?void 0:t.id)||((o=(n=globalThis.crypto)==null?void 0:n.randomUUID)==null?void 0:o.call(n))||`block-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),meta:t!=null&&t.meta?{...t.meta}:{}}})}function Mt(e=[]){return(e||[]).map(t=>({id:String((t==null?void 0:t.id)||"").trim(),createdAt:String((t==null?void 0:t.createdAt)||""),blocks:un((t==null?void 0:t.blocks)||[])}))}function ma(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:un(e.blocks||[]),todoItems:Mt(e.todoItems||[])}}function vr(e=[]){return un(e).filter(t=>(t==null?void 0:t.type)===At.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function Sv(e=[]){return vr(e).length>0}function wv(){var t,n;const e=(n=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:n.call(t);return e?`todo-${e}`:`todo-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ga(){return un([{type:At.TEXT,content:"",meta:{}}])}function xo(e=[],t=16){return ri(e,t)||""}function xv(e=[],t=120){const n=e.find(o=>((o==null?void 0:o.type)==="text"||(o==null?void 0:o.type)==="imported_text")&&String(o.content||"").trim());return String((n==null?void 0:n.content)||"").replace(/\s+/g," ").trim().slice(0,t)}function ha(e={},t=[]){const n=String((e==null?void 0:e.title)||"").trim();if(n)return n;const o=String((e==null?void 0:e.autoTitle)||"").trim();if(o)return o;const s=xo(t);if(s)return s;const a=String((e==null?void 0:e.preview)||"").trim();return a?a.slice(0,16):We("workbench.untitledTask")}function Rs(e={}){return!!(e!=null&&e.running)}function bv(e={},t=!1){return t&&!Rs(e)?"sending":Rs(e)?"running":"idle"}function kv(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function va(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function _v(e=[],t=[]){const n=Array.isArray(e)?[...e]:[],o=Array.isArray(t)?t.map(d=>String(d||"").trim()).filter(Boolean):[];if(!o.length)return n;const s=new Map(n.map(d=>{const h=String((d==null?void 0:d.slug)||"").trim();return h?[h,d]:null}).filter(Boolean)),a=o.map(d=>s.get(d)||null).filter(Boolean),l=n.filter(d=>{const h=String((d==null?void 0:d.slug)||"").trim();return h&&!o.includes(h)});return[...a,...l]}function ya(e=[],t=[]){const n=new Map((e||[]).map(s=>{const a=String((s==null?void 0:s.slug)||"").trim();return a?[a,s]:null}).filter(Boolean));return(t||[]).map(s=>{const a=String((s==null?void 0:s.slug)||"").trim(),l=String((s==null?void 0:s.codexSessionId)||"").trim();if(!a)return s;if(Object.prototype.hasOwnProperty.call(s,"workspaceDiffSummary"))return{...s,workspaceDiffSummary:Bs(s.workspaceDiffSummary)};if(!l)return{...s,workspaceDiffSummary:null};const d=n.get(a),h=String((d==null?void 0:d.codexSessionId)||"").trim();return h&&h===l?{...s,workspaceDiffSummary:Bs(d.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function Tv(e=[],t=[]){const n=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[];if(!o.length)return!1;if(n.length!==o.length)return!0;const s=new Map(n.map(a=>{const l=String((a==null?void 0:a.slug)||"").trim();return l?[l,a]:null}).filter(Boolean));return o.some(a=>{const l=String((a==null?void 0:a.slug)||"").trim();if(!l)return!0;const d=s.get(l);if(!d)return!0;const h=String((a==null?void 0:a.codexSessionId)||"").trim(),x=String((d==null?void 0:d.codexSessionId)||"").trim();return!!(h!==x||!!(a!=null&&a.running)!=!!(d!=null&&d.running)||h&&!Object.prototype.hasOwnProperty.call(d||{},"workspaceDiffSummary")||h&&(d==null?void 0:d.workspaceDiffSummary)==null)})}function ys(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(wo,t);return}window.localStorage.removeItem(wo)}function Cv(){return typeof window>"u"?"":String(window.localStorage.getItem(wo)||"").trim()}function Ev(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function Av(){if(!(typeof window>"u"))try{const e=new URL(window.location.href);if(!e.searchParams.has("task"))return;e.searchParams.delete("task");const t=`${e.pathname}${e.search}${e.hash}`;window.history.replaceState({},"",t||"/")}catch{}}function $n(e){const t={slug:e.slug,sortOrder:Number(e.sortOrder)||0,title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),codexRunCount:Math.max(0,Number(e.codexRunCount)||0),todoCount:Math.max(0,Number(e.todoCount)||0),running:!!e.running,preview:String(e.lastPromptPreview||""),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdAt:e.createdAt||e.updatedAt||new Date().toISOString(),automation:e!=null&&e.automation?{enabled:!!e.automation.enabled,cron:String(e.automation.cron||""),nextTriggerAt:String(e.automation.nextTriggerAt||"")}:void 0,notification:e!=null&&e.notification?{enabled:!!e.notification.enabled,channelType:String(e.notification.channelType||""),triggerOn:String(e.notification.triggerOn||""),lastStatus:String(e.notification.lastStatus||""),lastSentAt:String(e.notification.lastSentAt||"")}:void 0};return Object.prototype.hasOwnProperty.call(e,"workspaceDiffSummary")&&(t.workspaceDiffSummary=Bs(e.workspaceDiffSummary)),t}function $v(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Io(),a=nr(),l=K(null),d=K([]),h=K({}),x=K({}),c=K({}),m=K(""),f=K({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),k=K(!0),y=K(!1),L=K(!1),te=K(!1),S=K(!1),M=K(!1),N=K(""),H=K(!1),V=K("");let ne=null,I=null,X=0,le=null,ce=0,D=null,Q=0,re={};const ae=G(()=>xo(f.value.blocks)),ge=G(()=>ha({title:f.value.title,autoTitle:f.value.autoTitle,preview:xv(f.value.blocks)},f.value.blocks));function C($,T={}){const p=String($||"").trim();if(!p)return"";const _=T.summary||Ce(p),v=T.cachedDraft===void 0?Pe(p):T.cachedDraft,Y=p===m.value;return Object.prototype.hasOwnProperty.call(x.value,p)?String(x.value[p]||"").trim():Y?String(f.value.codexSessionId||(_==null?void 0:_.codexSessionId)||"").trim():String((v==null?void 0:v.codexSessionId)||(_==null?void 0:_.codexSessionId)||"").trim()}const q=G(()=>C(m.value)),U=G(()=>bv(Ce(m.value),c.value[m.value])),Ve=G(()=>U.value!=="idle"),Ae=G(()=>d.value.some($=>Rs($))||Object.values(c.value).some(Boolean)),Oe=G(()=>Sv(f.value.blocks)),Ne=G(()=>Mt(f.value.todoItems)),qe=G(()=>ge.value||We("workbench.untitledTask")),et=G(()=>d.value.map($=>ot($)));function we($=""){return!$||!$.startsWith(s)?$:$.slice(s.length)}function O($=""){const T=String($||"").replace(/\r\n/g,`
52
- `).split(`
53
- `);for(;T.length&&!String(T[0]||"").trim();)T.shift();for(;T.length&&!String(T[T.length-1]||"").trim();)T.pop();return T.join(`
54
- `)}function J($=[]){return $.map(T=>({id:Number.isInteger(Number(T==null?void 0:T.id))?Number(T.id):null,type:T==null?void 0:T.type,content:(T==null?void 0:T.type)==="image"?we(T.content):O(T.content),meta:T!=null&&T.meta?{...T.meta}:{}}))}function de($=[]){return($||[]).map(T=>({id:String((T==null?void 0:T.id)||"").trim(),createdAt:String((T==null?void 0:T.createdAt)||""),blocks:J((T==null?void 0:T.blocks)||[])}))}function ye($=f.value.title,T=f.value.autoTitle,p=f.value.lastPromptPreview,_=f.value.todoItems,v=f.value.codexSessionId,Y=f.value.blocks){return JSON.stringify({title:String($||""),autoTitle:String(T||""),lastPromptPreview:String(p||""),todoItems:de(_),codexSessionId:String(v||""),blocks:J(Y)})}function pe(){return ye()!==V.value}function Ee(){var $,T;return!!((T=($=l.value)==null?void 0:$.isEditing)!=null&&T.call($))}function Ce($){return d.value.find(T=>T.slug===$)||null}function Pe($){return $&&h.value[$]||null}function Re($,T=""){const p=String($||"").trim();p&&(re={...re,[p]:String(T||"").trim()})}function Ke($=""){var v;const T=String($||"").trim();if(!T)return!1;const p=String(((v=Ce(T))==null?void 0:v.updatedAt)||"").trim(),_=String(re[T]||"").trim();return!!(p&&_&&p===_)}function ot($){const T=Pe($.slug),p=$.slug===m.value?f.value.blocks:(T==null?void 0:T.blocks)||[],_=$.slug===m.value?f.value.title:(T==null?void 0:T.title)??$.title,v=$.slug===m.value?f.value.autoTitle:(T==null?void 0:T.autoTitle)??$.autoTitle,Y=$.slug===m.value?Mt(f.value.todoItems).length:Mt((T==null?void 0:T.todoItems)||[]).length||Number($.todoCount||0),Qe=$.slug===m.value?f.value.lastPromptPreview||$.lastPromptPreview||"":(T==null?void 0:T.lastPromptPreview)||$.lastPromptPreview||"",Le=C($.slug,{summary:$,cachedDraft:T});return{...$,title:_,autoTitle:v,todoCount:Y,preview:Qe,codexSessionId:Le,sessionSelectionLocked:!!(Le&&Number($.codexRunCount||0)>0),sessionSelectionLockReason:Le&&Number($.codexRunCount||0)>0?We("taskActions.sessionLocked"):"",displayTitle:ha({title:_,autoTitle:v,preview:Qe},p),sending:Rs($)}}function De($,T={}){const{insertAtStart:p=!1}=T;if(!($!=null&&$.slug))return;const _=[...d.value],v=_.findIndex(Y=>Y.slug===$.slug);if(v>=0){_.splice(v,1,{..._[v],...$}),d.value=_;return}p?_.unshift($):_.push($),d.value=_}function Me($,T){$&&(h.value={...h.value,[$]:ma(T)})}function _e($){return $?`${s}/api/tasks/${$}/raw`:`${s}/api/tasks/`}function at($=""){const T=String($||"").trim();if(!T)return;const p=Ce(T),_=a.getTaskRunChange(T);if(!p||!(_!=null&&_.status))return;const v=kv(_.status);!!p.running!==v&&De({...p,running:v})}function mt($,T){c.value={...c.value,[$]:!!T}}function ct($=d.value){const T={};($||[]).forEach(p=>{p!=null&&p.slug&&(T[p.slug]=!!p.running)}),c.value=T}function yt($,T){$&&(x.value={...x.value,[$]:String(T||"").trim()})}async function Tt($,T){const p=String($||"").trim();if(!p)return;const _=String(T||"").trim(),v=Ce(p),Y=x.value[p]||(v==null?void 0:v.codexSessionId)||"";if(!!(Y&&Number((v==null?void 0:v.codexRunCount)||0)>0)&&_!==Y){N.value=We("taskActions.sessionLocked");return}yt(p,_);const Le=Pe(p);Le&&Me(p,{...Le,codexSessionId:_}),v&&De({...v,codexSessionId:_,workspaceDiffSummary:_&&_===Y?v.workspaceDiffSummary:null}),p===m.value&&(f.value={...f.value,codexSessionId:_});try{await Gi(p,_)}catch(Ot){yt(p,Y),Le&&Me(p,{...Le,codexSessionId:Y}),v&&De({...v,codexSessionId:Y}),p===m.value&&(f.value={...f.value,codexSessionId:Y}),N.value=Ot.message}}function E(){ne&&(window.clearTimeout(ne),ne=null)}function F(){le&&(window.clearTimeout(le),le=null)}function ee(){E(),!(y.value||!m.value)&&(ne=window.setTimeout(()=>{Dt({auto:!0,silent:!0})},1500))}function he(){if(!m.value)return;const $=Ce(m.value)||{slug:m.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};De({...$,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:Mt(f.value.todoItems).length,codexSessionId:q.value,preview:String(f.value.lastPromptPreview||"")})}function Be($={}){const T=String(($==null?void 0:$.slug)||"").trim();if(!T)return;const p=$n($);De(p),Re(T,p.updatedAt||$.updatedAt||""),T===m.value&&(Object.prototype.hasOwnProperty.call($,"title")&&(f.value.title=String($.title||"")),Object.prototype.hasOwnProperty.call($,"autoTitle")&&(f.value.autoTitle=String($.autoTitle||"")),Me(T,{...f.value}))}function Ie($=[]){const T=new Map(($||[]).map(p=>{const _=String((p==null?void 0:p.slug)||"").trim();return _?[_,Bs(p.workspaceDiffSummary)]:null}).filter(Boolean));T.size&&(d.value=d.value.map(p=>T.has(p.slug)?{...p,workspaceDiffSummary:T.get(p.slug)}:p))}async function He($=d.value){const T=Array.isArray($)?$:[],p=T.filter(v=>String((v==null?void 0:v.codexSessionId)||"").trim()),_=++ce;if(!p.length){d.value=T.map(v=>Object.prototype.hasOwnProperty.call(v,"workspaceDiffSummary")?v:{...v,workspaceDiffSummary:null});return}try{const v=await Di(T.length||30);if(_!==ce)return;Ie(v.items||[])}catch{}}async function Je($={}){const{silent:T=!1}=$;T||(k.value=!0,N.value="");try{const p=d.value,_=await Pi(),v=ya(p,(_.items||[]).map($n));d.value=v,ct(v),Tv(p,v)&&He(v)}catch(p){T||(N.value=p.message)}finally{T||(k.value=!1)}}async function ut($=[]){const T=_v(d.value,$),p=d.value.map(Y=>String((Y==null?void 0:Y.slug)||"").trim()).filter(Boolean),_=T.map(Y=>String((Y==null?void 0:Y.slug)||"").trim()).filter(Boolean);if(!_.length||_.join(",")===p.join(","))return!1;const v=d.value;d.value=T;try{const Y=await Mi(_);Q=Date.now()+yv;const Qe=ya(v,(Y.items||[]).map($n));return d.value=Qe,ct(Qe),!0}catch(Y){return d.value=v,N.value=Y.message,!1}}async function ht($=""){const T=String(m.value||"").trim(),p=String($||"").trim();if(!T)return;if(!d.value.some(v=>v.slug===T)){if(d.value.length){await kt(d.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},V.value=ye("","","",[],"",[]),H.value=!1;return}p&&p!==T||p&&(Ee()||pe()||H.value||S.value||M.value||y.value||await kt(T,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function tt($=""){const T=String($||"").trim();D===null?D=T:D!==T&&(D=""),!le&&(le=window.setTimeout(async()=>{const p=D;D=null,le=null,await Je({silent:!0}),await ht(p||"")},vv))}async function dt($){const T=await Da($),p=(T.blocks||[]).map(v=>({...v,content:v.type==="image"?ws(v.content):v.content}));return{state:{title:String(T.title||""),autoTitle:String(T.autoTitle||""),lastPromptPreview:String(T.lastPromptPreview||""),codexSessionId:String(T.codexSessionId||""),blocks:p,todoItems:Mt(T.todoItems||[])},summary:$n({...T,blocks:p}),updatedAt:String(T.updatedAt||"")}}async function kt($,T={}){const{focusEditor:p=!1,force:_=!1,skipIfDirtyOnApply:v=!1,skipIfEditingOnApply:Y=!1,scrollPanelToBottom:Qe=!1}=T,Le=String($||"").trim();if(!Le)return!1;const Ot=++X;y.value=!0,N.value="",t();try{const jt=String(m.value||"").trim(),Wt=Pe(Le),Rt=_&&Wt&&Ke(Le);let Gt=_&&!Rt?null:Wt,Ft=null;if(!Gt){const wt=await dt(Le);Gt=(wt==null?void 0:wt.state)||null,Ft=(wt==null?void 0:wt.summary)||null,Re(Le,(wt==null?void 0:wt.updatedAt)||(Ft==null?void 0:Ft.updatedAt)||"")}return Ot!==X||v&&Le===m.value&&(pe()||H.value)||Y&&Le===m.value&&Ee()?!1:(m.value=Le,ys(Le),f.value=ma(Gt),Me(Le,Gt),Ft&&De(Ft),yt(Le,Gt.codexSessionId),V.value=ye(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),H.value=!1,p&&st(()=>{var wt,Xt;return(Xt=(wt=l.value)==null?void 0:wt.focusEditor)==null?void 0:Xt.call(wt)}),(Qe||Le!==jt)&&o(),!0)}catch(jt){return Ot===X&&(N.value=jt.message),!1}finally{Ot===X&&(y.value=!1)}}async function Dt($={}){const{auto:T=!1,silent:p=!1}=$;return m.value?ye()===V.value?!0:I||(E(),S.value=!0,N.value="",I=(async()=>{try{const v=await La(m.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:Mt(f.value.todoItems),codexSessionId:q.value,expiry:"none",visibility:"private",blocks:J(f.value.blocks)}),Y={title:String(v.title||""),autoTitle:String(v.autoTitle||""),lastPromptPreview:String(v.lastPromptPreview||""),todoItems:Mt(v.todoItems||f.value.todoItems||[]),codexSessionId:q.value||String(v.codexSessionId||"").trim(),blocks:un(f.value.blocks)};return Me(m.value,Y),V.value=ye(Y.title,Y.autoTitle,Y.lastPromptPreview,Y.todoItems,Y.codexSessionId,Y.blocks),H.value=!1,De($n(v)),Re(m.value,v.updatedAt||""),!T&&!p&&n({message:We("taskActions.taskSaved"),type:"success"}),!0}catch(v){return N.value=v.message,!1}finally{S.value=!1,I=null,ye()!==V.value&&(H.value=!0,ee())}})(),I):!1}async function oe(){return M.value?(N.value=We("taskActions.fileProcessing"),!1):I||(H.value?Dt({auto:!1,silent:!0}):!0)}async function $e(){if(!await oe()&&m.value)return!1;L.value=!0,N.value="";try{const $=await Li({title:"",expiry:"none",visibility:"private"}),T={title:String($.title||""),autoTitle:String($.autoTitle||""),lastPromptPreview:String($.lastPromptPreview||""),codexSessionId:String($.codexSessionId||""),blocks:un($.blocks||[]),todoItems:Mt($.todoItems||[])};return Me($.slug,T),De($n($),{insertAtStart:!0}),await kt($.slug,{focusEditor:!0}),n({message:We("taskActions.taskCreated"),type:"success"}),!0}catch($){return N.value=$.message,!1}finally{L.value=!1}}async function rt($){const T=String($||"").trim();!T||T===m.value||!await oe()||await kt(T)}async function St(){if(m.value){te.value=!0,N.value="";try{const $=m.value;await Bi($),d.value=d.value.filter(v=>v.slug!==$);const T={...h.value};delete T[$],h.value=T;const p={...x.value};delete p[$],x.value=p;const _={...c.value};delete _[$],c.value=_,d.value.length?await kt(d.value[0].slug,{focusEditor:!0}):(m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},V.value=ye("","","",[],"",[]),H.value=!1,await $e())}catch($){N.value=$.message}finally{te.value=!1}}}function Ct($={}){const{silent:T=!1}=$;m.value&&(f.value={...f.value,blocks:ga()},Me(m.value,f.value),he(),H.value=!0,st(()=>{var p,_;(_=(p=l.value)==null?void 0:p.focusEditor)==null||_.call(p)}),T||n({message:We("taskActions.taskCleared"),type:"info"}))}function ft(){if(!m.value)return!1;const $=vr(f.value.blocks);return $.length?(f.value={...f.value,blocks:ga(),todoItems:[{id:wv(),createdAt:new Date().toISOString(),blocks:$},...Mt(f.value.todoItems)]},Me(m.value,f.value),he(),H.value=!0,st(()=>{var T,p;(p=(T=l.value)==null?void 0:T.focusEditor)==null||p.call(T)}),n({message:We("taskActions.todoAdded"),type:"success"}),!0):!1}function z($=""){const T=String($||"").trim();if(!m.value||!T)return!1;const p=Mt(f.value.todoItems).filter(_=>_.id!==T);return p.length===Mt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:p},Me(m.value,f.value),he(),H.value=!0,!0)}function W($=""){const T=String($||"").trim();if(!m.value||!T)return null;const p=Mt(f.value.todoItems).find(_=>_.id===T);return p?(f.value={...f.value,blocks:un(p.blocks),todoItems:Mt(f.value.todoItems).filter(_=>_.id!==T)},Me(m.value,f.value),he(),H.value=!0,st(()=>{var _,v;(v=(_=l.value)==null?void 0:_.focusEditor)==null||v.call(_)}),p):null}async function ue(){var v;if(await Je(),!d.value.length){await $e();return}const $=Ev();if($){const Y=await kt($,{focusEditor:!0,force:!0});if(Av(),Y)return}const T=((v=d.value.find(Y=>!!(Y!=null&&Y.running)))==null?void 0:v.slug)||"",p=Cv(),_=T||(d.value.some(Y=>Y.slug===p)?p:d.value[0].slug);await kt(_,{focusEditor:!0,force:!0})}async function me($){var T,p,_;M.value=!0,N.value="";try{const v=((p=(T=l.value)==null?void 0:T.isImportedBlockActive)==null?void 0:p.call(T))||!1,Y=[];for(const Qe of $){const Le=await Ri(Qe);Y.push({type:"image",content:ws(Le.url),meta:{}})}(_=l.value)==null||_.insertUploadedBlocks(Y),n({message:We("taskActions.imageInserted",{count:Y.length,appended:v}),type:"success"})}catch(v){N.value=v.message}finally{M.value=!1}}async function je($){var T,p,_;N.value="";try{const v=((p=(T=l.value)==null?void 0:T.isImportedBlockActive)==null?void 0:p.call(T))||!1,Y=[];for(const Qe of $){const Le=await Qe.text();Le.trim()&&Y.push({type:"imported_text",content:Le,meta:{fileName:Qe.name||We("workbench.untitledTask"),collapsed:!0}})}if(!Y.length){n({message:We("taskActions.noTextImported"),type:"warning"});return}(_=l.value)==null||_.insertImportedBlocks(Y),n({message:We("taskActions.importedBlocksInserted",{count:Y.length,appended:v}),type:"success"})}catch{N.value=We("taskActions.textImportFailed")}}async function Et($){var T;M.value=!0,N.value="";try{let p=0,_=0;for(const v of $){const Y=await Ni(v),Qe=(Y.blocks||[]).map(Le=>({...Le,content:Le.type==="image"?ws(Le.content):Le.content}));Qe.length&&((T=l.value)==null||T.insertBlocks(Qe),p+=Qe.length,_+=Number(Y.pageCount||0))}if(!p){n({message:We("taskActions.noPdfContent"),type:"warning"});return}n({message:We("taskActions.pdfBlocksInserted",{blockCount:p,pageCount:_}),type:"success"})}catch(p){N.value=p.message||We("taskActions.pdfImportFailed")}finally{M.value=!1}}function zt($){const T=$===m.value?f.value:Pe($);return T?hv({title:String(T.title||""),blocks:J(T.blocks||[])},_e($)):""}function _t($){const T=$===m.value?f.value:Pe($);return T?un(J(T.blocks||[])):[]}async function Bt($){return M.value?(N.value=We("taskActions.fileProcessingBeforeSend"),!1):$!==m.value?!0:S.value&&I?I:H.value?Dt({auto:!1,silent:!0}):!0}async function nn($){return await Bt($)?zt($):""}function Qt($,T){const p=va(T);!p||$!==m.value||(f.value.lastPromptPreview=p,Me(m.value,f.value),he())}return Te(f,()=>{if(y.value||!m.value)return;const $=xo(f.value.blocks);!String(f.value.title||"").trim()&&$&&$!==f.value.autoTitle&&(f.value.autoTitle=$),Me(m.value,f.value),H.value=ye()!==V.value,he(),H.value&&!S.value&&ee()},{deep:!0}),Te(m,$=>{$&&ys($)}),$t(()=>{E(),F()}),Te(()=>a.listSyncVersion.value,()=>{a.listSyncReason.value==="reordered"&&Date.now()<Q||(at(a.listSyncTaskSlug.value),tt(a.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:ft,applyTaskSettingsUpdate:Be,buildPromptForTask:zt,getPromptBlocksForTask:_t,buildPromptPreview:va,clearCurrentTaskContent:Ct,createTaskAndSelect:$e,currentProjectSessionId:q,currentTaskSendState:U,currentTaskAutoTitle:ae,currentTaskDisplayTitle:ge,currentTaskSlug:m,draft:f,editorRef:l,error:N,handleImportPdfFiles:Et,handleImportTextFiles:je,handleTaskSendingChange:mt,handleTaskSessionChange:Tt,handleUpload:me,hasCurrentDraftContent:Oe,hasAnyTaskSending:Ae,hasUnsavedChanges:H,initializeWorkbench:ue,isCurrentTaskSending:Ve,loadingTask:y,loadingTasks:k,pageTitle:qe,prepareCodexPromptForTask:nn,currentTodoItems:Ne,removeTodoItem:z,removeCurrentTask:St,reorderTaskList:ut,removingTask:te,renderedTasks:et,refreshTaskList:Je,saveTask:Dt,saving:S,selectTask:rt,selectedSessionMap:x,sendingTaskMap:c,taskDraftMap:h,tasks:d,useTodoItem:W,updateLastPromptPreview:Qt,uploading:M,creatingTask:L}}const Iv={class:"flex h-full min-h-0 flex-col overflow-hidden"},Pv={key:0,class:"workbench-desktop-layout grid min-h-0 flex-1 gap-4 lg:grid-cols-[260px_minmax(0,1fr)] lg:grid-rows-1"},Dv={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},Lv={class:"min-h-0 min-w-0 overflow-hidden"},Mv={class:"min-h-0 min-w-0 overflow-hidden"},Bv={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Rv={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},Nv={class:"flex flex-col gap-2"},Ov={class:"min-h-0 flex-1 overflow-hidden"},jv={key:1,class:"min-h-0 flex-1 overflow-hidden"},Fv={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},Uv={class:"workbench-mobile-tabs-panel shrink-0"},Vv={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},zv={class:"min-h-0 flex-1 overflow-hidden"},Hv={class:"h-full min-h-0"},qv={class:"h-full min-h-0"},Kv={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Wv={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},Gv={class:"flex flex-col gap-2"},Xv={class:"min-h-0 flex-1 overflow-hidden"},Yv={__name:"WorkbenchView",setup(e){const t=K(!1),n=K(!1),o=K(!1),s=K(!1),a=K(!1),l=K(!1),d=K(!1),h=K(!1),x=K(""),c=K(""),m=K(""),f=K(0),k=K("workspace"),y=K(""),{t:L}=vt(),{toastMessage:te,toastType:S,flashToast:M,clearToast:N}=fv(),{sendBehavior:H}=Sr(),V=co(()=>Ue(()=>import("./TaskDiffReviewDialog-ClUn4Ni4.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),ne=co(()=>Ue(()=>import("./WorkbenchSettingsDialog-C74C5fs1.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),I=K(null),X=K([]),le=K({});function ce(P="",Z=X.value){const Se=String(P||"").trim();return Se&&Z.some(xe=>(xe==null?void 0:xe.engine)===Se)?Se:""}function D(P=X.value){var Z,Se;return((Z=P.find(xe=>xe==null?void 0:xe.isDefault))==null?void 0:Z.engine)||((Se=P[0])==null?void 0:Se.engine)||""}const Q=G({get(){const P=String(Ne.value||"").trim();return P?ce(le.value[P])||D():""},set(P){const Z=String(Ne.value||"").trim(),Se=ce(P);!Z||!Se||(le.value={...le.value,[Z]:Se})}});function re(P){return P?I.value:null}function ae(){st(()=>{var P,Z;(Z=(P=re(O.value))==null?void 0:P.scrollToBottom)==null||Z.call(P)})}const{addCurrentDraftToTodo:ge,applyTaskSettingsUpdate:C,buildPromptForTask:q,getPromptBlocksForTask:U,clearCurrentTaskContent:Ve,createTaskAndSelect:Ae,creatingTask:Oe,currentProjectSessionId:Ne,currentTaskSendState:qe,currentTaskAutoTitle:et,currentTaskDisplayTitle:we,currentTaskSlug:O,draft:J,editorRef:de,error:ye,handleImportPdfFiles:pe,handleImportTextFiles:Ee,handleTaskSendingChange:Ce,handleTaskSessionChange:Pe,handleUpload:Re,hasCurrentDraftContent:Ke,hasUnsavedChanges:ot,initializeWorkbench:De,isCurrentTaskSending:Me,loadingTask:_e,loadingTasks:at,pageTitle:mt,prepareCodexPromptForTask:ct,currentTodoItems:yt,removeTodoItem:Tt,removeCurrentTask:E,reorderTaskList:F,removingTask:ee,renderedTasks:he,saveTask:Be,saving:Ie,selectTask:He,updateLastPromptPreview:Je,useTodoItem:ut,uploading:ht}=$v({clearToast:N,flashToast:M,scrollCurrentPanelToBottom:ae}),tt=G(()=>he.value.find(P=>P.slug===O.value)||null),dt=G(()=>{var P,Z;return!!((Z=(P=tt.value)==null?void 0:P.workspaceDiffSummary)!=null&&Z.supported)}),kt=G(()=>{const P=tt.value;return P?()=>ct(P.slug):null}),Dt=G(()=>{const P=tt.value;return P?()=>U(P.slug):null}),oe=G(()=>({creatingTask:Oe.value,currentTaskAutoTitle:J.value.autoTitle||et.value,currentTaskSlug:O.value,draftTitle:J.value.title,editingTaskTitleSlug:m.value,error:ye.value,isCurrentTaskSending:Me.value,loadingTask:_e.value,loadingTasks:at.value,removingTask:ee.value,tasks:he.value,uploading:ht.value})),$e=G(()=>{var P,Z,Se,xe;return{buildPromptBlocks:Dt.value,buildPrompt:kt.value,diffSupported:dt.value,selectedAgentEngine:Q.value,selectedSessionId:Ne.value,sessionSelectionLockReason:((P=tt.value)==null?void 0:P.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((Z=tt.value)!=null&&Z.sessionSelectionLocked),taskSlug:((Se=tt.value)==null?void 0:Se.slug)||"",taskRunning:!!((xe=tt.value)!=null&&xe.running)}}),rt=G(()=>({codexSessionId:Ne.value,sendBehavior:H.value,loading:_e.value})),St=G(()=>({currentTaskAutoTitle:J.value.autoTitle||et.value,currentTaskSlug:O.value,editingTaskTitleSlug:m.value,title:we.value,titleInputValue:J.value.title})),{enterMobileDetail:Ct,isMobileLayout:ft,leaveMobileDetail:z,mobileDetailTab:W,mobileView:ue}=lv({currentTaskSlug:O});function me(P){return P!=null&&P.sending||Number((P==null?void 0:P.codexRunCount)||0)>0?"activity":"input"}cv(mt);function je(P="workspace",Z=""){k.value=P==="run"?"run":P==="task"?"task":"workspace",y.value=k.value==="run"?String(Z||""):"",o.value=!0,f.value+=1}function Et(){o.value=!1}function zt(){s.value=!0}function _t(){s.value=!1}function Bt(){O.value&&(a.value=!0)}function nn(){a.value=!1}function Qt(){l.value=!0}function $(){l.value=!1,T(),p()}function T(){d.value=!1,x.value=""}function p(){h.value=!1,c.value=""}function _(P){C(P)}function v(P){J.value.title=P}async function Y(){m.value="",ot.value&&await Be({auto:!1,silent:!0})}function Qe(P){P===O.value&&(m.value=P,st(()=>{var Se,xe;const Z=document.querySelector('[data-task-title-input="current"]');(Se=Z==null?void 0:Z.focus)==null||Se.call(Z),(xe=Z==null?void 0:Z.select)==null||xe.call(Z)}))}async function Le(P){if(ft.value){await Un(P);return}if(P!==O.value){await Un(P);return}Qe(P)}function Ot(){n.value=!0}function jt(){ee.value||(n.value=!1)}async function Wt(){await E(),n.value=!1,ft.value&&z({useHistory:!1})}function Rt(){t.value=!0}function Gt(){t.value=!1}function Ft(){t.value=!1,Ve()}function wt(P){const Z=tt.value;Z&&Ce(Z.slug,P)}function Xt(P){const Z=tt.value;Z&&Pe(Z.slug,P)}function Us(P={}){const Z=String((P==null?void 0:P.sessionId)||"").trim(),Se=Ne.value;if(Z&&Z!==Se)return;const xe=Array.isArray(P==null?void 0:P.bindings)?P.bindings:[];X.value=xe;const u=ce(le.value[Se],xe)||ce(P==null?void 0:P.selectedEngine,xe)||D(xe);u&&(Q.value=u)}Te(Ne,(P,Z)=>{String(P||"").trim()!==String(Z||"").trim()&&(X.value=[])});function Fn(P){Q.value=P}function Vs(P){M(P),!(!ft.value||!O.value)&&(W.value="activity")}async function Ut(){var P,Z,Se,xe,u,A,B,R;typeof document<"u"&&((Z=(P=de.value)==null?void 0:P.isComposing)!=null&&Z.call(P))&&((xe=(Se=document.activeElement)==null?void 0:Se.blur)==null||xe.call(Se)),(A=(u=de.value)==null?void 0:u.flushPendingInput)==null||A.call(u),await st(),(R=(B=de.value)==null?void 0:B.flushPendingInput)==null||R.call(B),await st()}async function is(){await Ut(),await navigator.clipboard.writeText(q(O.value)),M({message:L("workbench.promptCopied"),type:"info"})}async function zs(){await Ae()&&ft.value&&(W.value="input",Ct())}async function Un(P){const Z=String(P||"").trim();Z&&(Z!==O.value&&await He(Z),ft.value&&O.value===Z&&(W.value=me(tt.value),Ct()))}async function ls(P=[]){await F(P)}async function sn(){await Ut(),ge()}function Vn(P={}){const Z=String((P==null?void 0:P.rangeLabel)||"").trim();if(Z)return Z;const Se=Math.max(0,Number(P==null?void 0:P.lineStart)||0),xe=Math.max(0,Number(P==null?void 0:P.lineEnd)||0);return Se&&xe&&Se!==xe?`L${Se}-L${xe}`:Se||xe?`L${Se||xe}`:""}function zn(P=""){return`code-context-${String(P||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function Yt(P={}){const Z=String((P==null?void 0:P.filePath)||"").trim(),Se=String((P==null?void 0:P.content)||"").replace(/\r\n/g,`
55
- `).trimEnd();if(!Z||!Se.trim())return null;const xe=String((P==null?void 0:P.language)||"").trim(),u=Vn(P),A=String((P==null?void 0:P.source)||"").trim()==="diff"?L("workbench.codeContextSourceDiff"):L("workbench.codeContextSourceFile"),B=xe?`\`\`\`${xe}`:"```",R=[L("workbench.codeContextTitle"),L("workbench.codeContextFile",{path:Z}),u?L("workbench.codeContextRange",{range:u}):"",L("workbench.codeContextSource",{source:A}),"",B,Se,"```"].filter(se=>se!=="");return{type:At.IMPORTED_TEXT,content:R.join(`
56
- `),meta:{fileName:zn(Z),collapsed:!1}}}async function us(P=[],Z="insertBlocks"){var xe,u,A,B;const Se=Array.isArray(P)?P.filter(Boolean):[];return Se.length?(await Ut(),(u=(xe=de.value)==null?void 0:xe[Z])==null||u.call(xe,Se),await st(),(B=(A=de.value)==null?void 0:A.focusEditor)==null||B.call(A),ft.value&&O.value&&(W.value="input"),M({message:L("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function Hn(P={}){const Z=String((P==null?void 0:P.source)||"").trim(),Se=String((P==null?void 0:P.content)||"").replace(/\r\n/g,`
57
- `).trim();if(Z==="response"){if(!Se)return;await us([Pn(Se)],"insertBlocks");return}const xe=Yt(P);xe&&await us([xe],"insertImportedBlocks")}function Tn(P){x.value=String(P||"").trim(),d.value=!!x.value}function fn(){x.value&&(Tt(x.value),T())}async function cs(P=c.value){const Z=String(P||"").trim();return!Z||!ut(Z)?!1:(p(),$(),!0)}async function Hs(P){await Ut();const Z=String(P||"").trim();if(Z){if(!Ke.value){await cs(Z);return}c.value=Z,h.value=!0}}async function Cn(){var xe,u,A,B;const P=O.value;if(!P)return;const Z=!!((u=(xe=tt.value)==null?void 0:xe.automation)!=null&&u.enabled);await Ut(),Je(P,q(P)),!(!await((B=(A=re(P))==null?void 0:A.send)==null?void 0:B.call(A))||P!==O.value)&&(ft.value&&(W.value="activity"),Z||Ve({silent:!0}),await Be({auto:!1,silent:!0}))}function qs(){!ft.value||ue.value!=="detail"||W.value!=="input"||!O.value||st(()=>{var P,Z;(Z=(P=de.value)==null?void 0:P.focusEditor)==null||Z.call(P)})}function pn(P){!ot.value&&!ht.value&&!Ie.value||(P.preventDefault(),P.returnValue="")}function qn(){var P,Z;return h.value?(p(),!0):d.value?(T(),!0):t.value?(Gt(),!0):n.value?(jt(),!0):a.value?(nn(),!0):l.value?($(),!0):o.value?(Et(),!0):s.value?(_t(),!0):!!((Z=(P=re(O.value))==null?void 0:P.closeTopDialog)!=null&&Z.call(P))}function En(P){var u,A,B,R,se;const Z=String(P.key||""),Se=Z.toLowerCase(),xe=P.metaKey||P.ctrlKey;if(Z==="Escape"){qn()&&(P.preventDefault(),(u=P.stopImmediatePropagation)==null||u.call(P));return}if(xe){if(Se==="s"){P.preventDefault(),Be({auto:!1});return}if(P.shiftKey&&Z==="Backspace"){P.preventDefault(),Rt();return}if(!P.isComposing){if(P.shiftKey&&P.code==="Comma"){P.preventDefault(),zt();return}if(P.shiftKey&&Se==="k"){P.preventDefault(),(B=(A=re(O.value))==null?void 0:A.openProjectManager)==null||B.call(A);return}if(P.shiftKey&&Se==="o"){P.preventDefault(),(se=(R=re(O.value))==null?void 0:R.openSourceBrowser)==null||se.call(R);return}P.shiftKey&&Se==="d"&&(P.preventDefault(),dt.value&&je("workspace"))}}}dn(()=>{De(),window.addEventListener("beforeunload",pn),window.addEventListener("keydown",En)}),$t(()=>{window.removeEventListener("beforeunload",pn),window.removeEventListener("keydown",En)}),Te([ft,ue,W,O],([P,Z,Se,xe])=>{!P||Z!=="detail"||Se!=="input"||!xe||qs()});const on={"update:draftTitle":v,"cancel-title-edit":()=>{m.value=""},"create-task":zs,"edit-task":Bt,"delete-task":Ot,"open-settings":zt,"reorder-task":ls,"select-task":Un,"title-blur":Y,"title-click":Le},ds={"agent-bindings-change":Us,"insert-code-context":Hn,"open-diff":({scope:P,runId:Z})=>je(P,Z),"project-created":()=>M({message:L("workbench.projectCreated"),type:"success"}),"selected-session-change":Xt,"update:selectedAgentEngine":Fn,"sending-change":wt,toast:Vs},Kn={"clear-request":Rt,"file-feedback":P=>M({message:P,type:"warning"}),"import-pdf-files":pe,"import-text-files":Ee,"send-request":Cn,"upload-files":Re},mn={"begin-edit":()=>Qe(O.value),back:z,"cancel-title-edit":()=>{m.value=""},"title-blur":Y,"update:titleInputValue":v};return(P,Z)=>(g(),b("div",Iv,[ie(av,{message:r(te),type:r(S)},null,8,["message","type"]),ie(ps,{open:t.value,title:r(L)("workbench.confirmClearTitle"),description:r(L)("workbench.confirmClearDescription"),"confirm-text":r(L)("workbench.confirmClearAction"),"cancel-text":r(L)("workbench.continueEditing"),onCancel:Gt,onConfirm:Ft},null,8,["open","title","description","confirm-text","cancel-text"]),ie(ps,{open:n.value,title:r(L)("workbench.confirmDeleteTitle"),description:r(L)("workbench.confirmDeleteDescription",{title:r(we)}),"confirm-text":r(L)("workbench.confirmDeleteAction"),"cancel-text":r(L)("workbench.keepForNow"),loading:r(ee),danger:"",onCancel:jt,onConfirm:Wt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),ie(ps,{open:d.value,title:r(L)("workbench.confirmDeleteTodoTitle"),description:r(L)("workbench.confirmDeleteTodoDescription"),"confirm-text":r(L)("workbench.confirmDeleteAction"),"cancel-text":r(L)("workbench.keepForNow"),danger:"",onCancel:T,onConfirm:fn},null,8,["open","title","description","confirm-text","cancel-text"]),ie(ps,{open:h.value,title:r(L)("workbench.replaceEditorTitle"),description:r(L)("workbench.replaceEditorDescription"),"confirm-text":r(L)("workbench.confirmReplaceAction"),"cancel-text":r(L)("workbench.dontReplaceYet"),onCancel:p,onConfirm:Z[0]||(Z[0]=Se=>cs())},null,8,["open","title","description","confirm-text","cancel-text"]),ie(sv,{open:l.value,items:r(yt),onClose:$,onDelete:Tn,onUse:Hs},null,8,["open","items"]),ie(r(V),{open:o.value,"task-slug":r(O),"task-title":r(we),"preferred-scope":k.value,"preferred-run-id":y.value,"focus-token":f.value,onInsertCodeContext:Hn,onClose:Et},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),ie(r(ne),{open:s.value,onClose:_t},null,8,["open"]),ie(gu,{open:a.value,"task-slug":r(O),"task-title":r(we),onClose:nn,onSaved:_},null,8,["open","task-slug","task-title"]),r(ft)?(g(),b("div",jv,[r(ue)==="tasks"?(g(),ke(pa,gn({key:0},oe.value,{mobile:""},hn(on)),null,16)):(g(),b("div",Fv,[ie(th,gn(St.value,hn(mn)),null,16),i("section",Uv,[i("div",Vv,[i("button",{type:"button",class:ve(["tool-button px-3 py-1.5 text-sm",r(W)==="activity"?"tool-button-accent-subtle":""]),onClick:Z[3]||(Z[3]=Se=>W.value="activity")},w(r(L)("workbench.activity")),3),i("button",{type:"button",class:ve(["tool-button px-3 py-1.5 text-sm",r(W)==="input"?"tool-button-accent-subtle":""]),onClick:Z[4]||(Z[4]=Se=>W.value="input")},w(r(L)("workbench.input")),3)])]),i("div",zv,[qt(i("div",Hv,[ie(ra,gn({ref_key:"codexPanelRef",ref:I},$e.value,{"empty-message":r(L)("workbench.selectTask")},hn(ds)),null,16,["empty-message"])],512),[[As,r(W)==="activity"]]),qt(i("div",qv,[i("div",Kv,[i("div",Wv,[i("div",Gv,[ie(la,{"can-add-todo":r(Ke),"is-current-task-sending":r(Me),"send-state":r(qe),"todo-count":r(yt).length,uploading:r(ht),onAddTodo:sn,onOpenFilePicker:Z[5]||(Z[5]=Se=>{var xe,u;return(u=(xe=r(de))==null?void 0:xe.openFilePicker)==null?void 0:u.call(xe)}),onClearRequest:Rt,onCopyRequest:is,onManageTodo:Qt,onSendRequest:Cn},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ie(ia,{"agent-bindings":X.value,"selected-agent-engine":Q.value,"onUpdate:selectedAgentEngine":Fn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Xv,[ie(fa,gn({ref_key:"editorRef",ref:de,modelValue:r(J).blocks,"onUpdate:modelValue":Z[6]||(Z[6]=Se=>r(J).blocks=Se)},rt.value,hn(Kn)),null,16,["modelValue"])])])],512),[[As,r(W)==="input"]])])]))])):(g(),b("div",Pv,[ie(pa,gn(oe.value,hn(on)),null,16),i("div",Dv,[i("div",Lv,[tt.value?(g(),ke(ra,gn({key:0,ref_key:"codexPanelRef",ref:I},$e.value,hn(ds)),null,16)):fe("",!0)]),i("div",Mv,[i("div",Bv,[i("div",Rv,[i("div",Nv,[ie(la,{"can-add-todo":r(Ke),"is-current-task-sending":r(Me),"send-state":r(qe),"todo-count":r(yt).length,uploading:r(ht),onAddTodo:sn,onOpenFilePicker:Z[1]||(Z[1]=Se=>{var xe,u;return(u=(xe=r(de))==null?void 0:xe.openFilePicker)==null?void 0:u.call(xe)}),onClearRequest:Rt,onCopyRequest:is,onManageTodo:Qt,onSendRequest:Cn},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ie(ia,{"agent-bindings":X.value,"selected-agent-engine":Q.value,align:"end","onUpdate:selectedAgentEngine":Fn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Ov,[ie(fa,gn({ref_key:"editorRef",ref:de,modelValue:r(J).blocks,"onUpdate:modelValue":Z[2]||(Z[2]=Se=>r(J).blocks=Se)},rt.value,hn(Kn)),null,16,["modelValue"])])])])])]))]))}},fy=Object.freeze(Object.defineProperty({__proto__:null,default:Yv},Symbol.toStringTag,{value:"Module"}));export{uy as D,xs as W,Ka as _,Ga as a,zu as b,rv as c,en as d,Fu as e,js as f,iy as g,Ye as h,cy as i,bi as j,sy as k,Xi as l,Fc as m,Xa as n,ay as o,lt as p,vu as q,dy as r,ry as s,ps as t,nr as u,ly as v,Eo as w,oy as x,ny as y,fy as z};