@muyichengshayu/promptx 0.2.18 → 0.2.19

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 (80) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/apps/web/dist/assets/{CodexSessionManagerDialog-D_72LIMv.js → CodexSessionManagerDialog-C5Cht229.js} +3 -3
  3. package/apps/web/dist/assets/{TaskDiffReviewDialog-CoQgN73y.js → TaskDiffReviewDialog-D2l8KtRI.js} +5 -5
  4. package/apps/web/dist/assets/{WorkbenchSettingsDialog-Bw-fcsXi.js → WorkbenchSettingsDialog-DGj-_tuL.js} +1 -1
  5. package/apps/web/dist/assets/WorkbenchView-ih1G4f79.js +58 -0
  6. package/apps/web/dist/assets/index-4LeM_JQe.js +2 -0
  7. package/apps/web/dist/assets/index-D9Ojj7Lp.css +1 -0
  8. package/apps/web/dist/assets/{vendor-markdown-9aQhqbjm.js → vendor-markdown-C2aIjAg9.js} +1 -1
  9. package/apps/web/dist/assets/{vendor-misc-u-M8sNMf.js → vendor-misc-DqxAnmp9.js} +30 -29
  10. package/apps/web/dist/assets/{vendor-router-Dn8q3tJM.js → vendor-router-4TN1NQvz.js} +1 -1
  11. package/apps/web/dist/assets/{vendor-shiki-core-1BqeTDsZ.js → vendor-shiki-core-UNANE_3B.js} +1 -1
  12. package/apps/web/dist/assets/vendor-shiki-lang-bash-OmlQ8O-f.js +1 -0
  13. package/apps/web/dist/assets/vendor-shiki-lang-c-Bf17QIO6.js +1 -0
  14. package/apps/web/dist/assets/vendor-shiki-lang-cpp-Dz7DCXQD.js +1 -0
  15. package/apps/web/dist/assets/vendor-shiki-lang-csharp-weekbih6.js +1 -0
  16. package/apps/web/dist/assets/vendor-shiki-lang-css-Cc89nYhT.js +1 -0
  17. package/apps/web/dist/assets/vendor-shiki-lang-diff-BKW5_WJa.js +1 -0
  18. package/apps/web/dist/assets/vendor-shiki-lang-dockerfile-DKFA3n9j.js +1 -0
  19. package/apps/web/dist/assets/vendor-shiki-lang-dotenv-BftIlyZY.js +1 -0
  20. package/apps/web/dist/assets/vendor-shiki-lang-fish-DTee4iUj.js +1 -0
  21. package/apps/web/dist/assets/vendor-shiki-lang-go-iEA7Y2np.js +1 -0
  22. package/apps/web/dist/assets/vendor-shiki-lang-html-fEXQcPZb.js +1 -0
  23. package/apps/web/dist/assets/vendor-shiki-lang-ini-BJNPDfrG.js +1 -0
  24. package/apps/web/dist/assets/vendor-shiki-lang-java-CZdBcwkx.js +1 -0
  25. package/apps/web/dist/assets/vendor-shiki-lang-javascript-5n6OdqL_.js +1 -0
  26. package/apps/web/dist/assets/vendor-shiki-lang-json-DkR7bRnH.js +1 -0
  27. package/apps/web/dist/assets/vendor-shiki-lang-less-DN-gfwMv.js +1 -0
  28. package/apps/web/dist/assets/vendor-shiki-lang-markdown-CgfEScgY.js +1 -0
  29. package/apps/web/dist/assets/vendor-shiki-lang-powershell-N9rELqmw.js +1 -0
  30. package/apps/web/dist/assets/vendor-shiki-lang-python-6ZggAICS.js +1 -0
  31. package/apps/web/dist/assets/vendor-shiki-lang-rust-BvkG5Wz9.js +1 -0
  32. package/apps/web/dist/assets/vendor-shiki-lang-sass-DFAXHETo.js +1 -0
  33. package/apps/web/dist/assets/vendor-shiki-lang-scss-ClLYCF3s.js +1 -0
  34. package/apps/web/dist/assets/vendor-shiki-lang-sql-CBrOCv6B.js +1 -0
  35. package/apps/web/dist/assets/vendor-shiki-lang-toml-C0vpllp6.js +1 -0
  36. package/apps/web/dist/assets/vendor-shiki-lang-tsx-DVg_XTuK.js +1 -0
  37. package/apps/web/dist/assets/vendor-shiki-lang-typescript-DV5oo9cD.js +1 -0
  38. package/apps/web/dist/assets/vendor-shiki-lang-vue-QYrDJbPe.js +1 -0
  39. package/apps/web/dist/assets/vendor-shiki-lang-xml-D4OZNqPk.js +1 -0
  40. package/apps/web/dist/assets/vendor-shiki-lang-yaml-BZu-v6Um.js +1 -0
  41. package/apps/web/dist/assets/vendor-shiki-theme-github-dark-default-DVxJvksW.js +1 -0
  42. package/apps/web/dist/assets/vendor-shiki-theme-github-light-BRz4x11q.js +1 -0
  43. package/apps/web/dist/assets/{vendor-tiptap-rwYdQb1L.js → vendor-tiptap-DLVi2vZE.js} +1 -1
  44. package/apps/web/dist/assets/{vendor-ui-BglsaDbv.js → vendor-ui-CnLXY_Zv.js} +31 -26
  45. package/apps/web/dist/index.html +4 -4
  46. package/package.json +1 -1
  47. package/apps/web/dist/assets/WorkbenchView-CsZnW4Q7.js +0 -58
  48. package/apps/web/dist/assets/index-Bt9T2IKp.js +0 -2
  49. package/apps/web/dist/assets/index-DaJU954y.css +0 -1
  50. package/apps/web/dist/assets/vendor-shiki-lang-bash-zsQu0xn-.js +0 -1
  51. package/apps/web/dist/assets/vendor-shiki-lang-c-BDF8vgks.js +0 -1
  52. package/apps/web/dist/assets/vendor-shiki-lang-cpp-DyDAaXl6.js +0 -1
  53. package/apps/web/dist/assets/vendor-shiki-lang-csharp-BWfTXJXw.js +0 -1
  54. package/apps/web/dist/assets/vendor-shiki-lang-css-DbAm1fUO.js +0 -1
  55. package/apps/web/dist/assets/vendor-shiki-lang-diff-DmGC1G26.js +0 -1
  56. package/apps/web/dist/assets/vendor-shiki-lang-dockerfile-3x-8396r.js +0 -1
  57. package/apps/web/dist/assets/vendor-shiki-lang-dotenv--IVOlX2Q.js +0 -1
  58. package/apps/web/dist/assets/vendor-shiki-lang-fish-Bpv3hhJP.js +0 -1
  59. package/apps/web/dist/assets/vendor-shiki-lang-go-CIGC59jP.js +0 -1
  60. package/apps/web/dist/assets/vendor-shiki-lang-html-Bt_TLLZN.js +0 -1
  61. package/apps/web/dist/assets/vendor-shiki-lang-ini-BIllfys4.js +0 -1
  62. package/apps/web/dist/assets/vendor-shiki-lang-java-CXxu9crF.js +0 -1
  63. package/apps/web/dist/assets/vendor-shiki-lang-javascript-Cha7GNZm.js +0 -1
  64. package/apps/web/dist/assets/vendor-shiki-lang-json-CCZCjDUh.js +0 -1
  65. package/apps/web/dist/assets/vendor-shiki-lang-less-DAToytC5.js +0 -1
  66. package/apps/web/dist/assets/vendor-shiki-lang-markdown-C6lwMXFp.js +0 -1
  67. package/apps/web/dist/assets/vendor-shiki-lang-powershell-lrpuM0ez.js +0 -1
  68. package/apps/web/dist/assets/vendor-shiki-lang-python-Bi9rmtY7.js +0 -1
  69. package/apps/web/dist/assets/vendor-shiki-lang-rust-GTGDbY6A.js +0 -1
  70. package/apps/web/dist/assets/vendor-shiki-lang-sass-DFtHupN8.js +0 -1
  71. package/apps/web/dist/assets/vendor-shiki-lang-scss-BrfBNyyi.js +0 -1
  72. package/apps/web/dist/assets/vendor-shiki-lang-sql-H6--iFN-.js +0 -1
  73. package/apps/web/dist/assets/vendor-shiki-lang-toml-aTteTWYL.js +0 -1
  74. package/apps/web/dist/assets/vendor-shiki-lang-tsx-DoKZm6AV.js +0 -1
  75. package/apps/web/dist/assets/vendor-shiki-lang-typescript-B5awnqri.js +0 -1
  76. package/apps/web/dist/assets/vendor-shiki-lang-vue-CnrgQ7Z5.js +0 -1
  77. package/apps/web/dist/assets/vendor-shiki-lang-xml-Bv-TNPJt.js +0 -1
  78. package/apps/web/dist/assets/vendor-shiki-lang-yaml-DpxUxQ6M.js +0 -1
  79. package/apps/web/dist/assets/vendor-shiki-theme-github-dark-default-DBX58552.js +0 -1
  80. package/apps/web/dist/assets/vendor-shiki-theme-github-light-RLAvZv0q.js +0 -1
@@ -0,0 +1,58 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-theme-github-dark-default-DVxJvksW.js","assets/vendor-shiki-core-UNANE_3B.js","assets/vendor-misc-DqxAnmp9.js","assets/vendor-misc-ClI1dyrl.css","assets/vendor-shiki-theme-github-light-BRz4x11q.js","assets/vendor-shiki-lang-bash-OmlQ8O-f.js","assets/vendor-shiki-lang-c-Bf17QIO6.js","assets/vendor-shiki-lang-cpp-Dz7DCXQD.js","assets/vendor-shiki-lang-csharp-weekbih6.js","assets/vendor-shiki-lang-css-Cc89nYhT.js","assets/vendor-shiki-lang-diff-BKW5_WJa.js","assets/vendor-shiki-lang-dockerfile-DKFA3n9j.js","assets/vendor-shiki-lang-dotenv-BftIlyZY.js","assets/vendor-shiki-lang-fish-DTee4iUj.js","assets/vendor-shiki-lang-go-iEA7Y2np.js","assets/vendor-shiki-lang-html-fEXQcPZb.js","assets/vendor-shiki-lang-ini-BJNPDfrG.js","assets/vendor-shiki-lang-java-CZdBcwkx.js","assets/vendor-shiki-lang-javascript-5n6OdqL_.js","assets/vendor-shiki-lang-json-DkR7bRnH.js","assets/vendor-shiki-lang-less-DN-gfwMv.js","assets/vendor-shiki-lang-markdown-CgfEScgY.js","assets/vendor-shiki-lang-python-6ZggAICS.js","assets/vendor-shiki-lang-powershell-N9rELqmw.js","assets/vendor-shiki-lang-rust-BvkG5Wz9.js","assets/vendor-shiki-lang-sass-DFAXHETo.js","assets/vendor-shiki-lang-scss-ClLYCF3s.js","assets/vendor-shiki-lang-sql-CBrOCv6B.js","assets/vendor-shiki-lang-toml-C0vpllp6.js","assets/vendor-shiki-lang-tsx-DVg_XTuK.js","assets/vendor-shiki-lang-typescript-DV5oo9cD.js","assets/vendor-shiki-lang-vue-QYrDJbPe.js","assets/vendor-shiki-lang-xml-D4OZNqPk.js","assets/vendor-shiki-lang-yaml-BZu-v6Um.js","assets/CodexSessionManagerDialog-C5Cht229.js","assets/index-4LeM_JQe.js","assets/vendor-router-4TN1NQvz.js","assets/index-D9Ojj7Lp.css","assets/vendor-ui-CnLXY_Zv.js","assets/vendor-markdown-C2aIjAg9.js","assets/vendor-tiptap-DLVi2vZE.js","assets/TaskDiffReviewDialog-D2l8KtRI.js","assets/TaskDiffReviewDialog-NsLGEda4.css","assets/WorkbenchSettingsDialog-DGj-_tuL.js"])))=>i.map(i=>d[i]);
2
+ import{u as Lt,t as Xe,f as Gr,_ as He,a as Xr,b as Yr,g as fo,s as Qa,c as Za}from"./index-4LeM_JQe.js";import{w as $e,ak as Nt,aD as p,aI as Ee,aG as ue,aJ as rt,aE as b,aK as at,aL as Te,aF as i,aM as mn,u as a,aN as de,aO as Jr,aP as Ls,c as q,aQ as w,aR as ft,aS as vt,aT as Rn,n as dt,o as kn,aU as un,aV as Nn,b as j,aW as ln,aX as bs,aY as ur,r as Ms,aC as ei,aZ as Ln,f as ti,a_ as Ro,a$ as ni,b0 as eo,G as si,al as oi,b1 as Un,b2 as jn}from"./vendor-misc-DqxAnmp9.js";import{X as Qr,T as ri,L as Gt,C as Go,a as to,B as cr,S as ai,P as As,b as Zr,c as ii,A as li,F as rs,d as Hn,e as ea,f as ui,E as ci,g as di,h as dr,i as Xo,j as no,k as fi,I as pi,l as mi,m as gi,U as hi,W as vi,n as ta,o as yi,p as so,q as po,r as na,s as Si,t as wi,u as xi,v as bi,G as ki,w as Ti,x as _i,y as Ci,z as Ei}from"./vendor-ui-CnLXY_Zv.js";import{M as sa}from"./vendor-markdown-C2aIjAg9.js";import{n as Yo,N as oa,a as Jo,i as Ai,V as wo,b as fr,u as Ii,c as $i,E as Pi}from"./vendor-tiptap-DLVi2vZE.js";const Di="shell",Li=new Set(["!","!"]),pr="text";function qs(e=""){return String(e||"").replace(/\r\n/g,`
3
+ `).trim()}function Mi(e=""){const t=String(e||"");return Li.has(t.charAt(0))}function Bi(e=""){const t=qs(e);return t?t.charAt(0)==="!"?`!${t.slice(1)}`:t:""}function Ri(e={}){const n=(Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks:[]).filter(u=>!!qs(u==null?void 0:u.content)),o=n.length>0,s=o?n.filter(u=>String((u==null?void 0:u.type)||"").trim()===pr).map(u=>qs(u==null?void 0:u.content)).filter(Boolean).join(`
4
+
5
+ `).trim():qs(e==null?void 0:e.prompt);if(!Mi(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(m=>String((m==null?void 0:m.type)||"").trim()!==pr))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=Bi(s).slice(1).trim();return l?{mode:Di,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const wn={NONE:"none",LATEST:"latest",ALL:"all"};function Ni(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===wn.ALL?wn.ALL:n===wn.LATEST?wn.LATEST:n===wn.NONE?wn.NONE:t.includeEvents?wn.ALL:t.includeLatestEvents?wn.LATEST:wn.NONE}const nn={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function ra(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?nn.AGENT_EVENT:t}const $t={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"},mt={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"},Oi={none:{label:"不过期",hours:null}};Object.entries(Oi).map(([e,t])=>({value:e,label:t.label}));const ks={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode",KIMI_CODE:"kimi-code"},Qo=[{value:ks.CODEX,label:"Codex",enabled:!0},{value:ks.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:ks.OPENCODE,label:"OpenCode",enabled:!0},{value:ks.KIMI_CODE,label:"Kimi Code",enabled:!0}],Pt={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},Fi=[{value:"local",label:"跟随本机时区"}],Ui={SKIP:"skip"},ji=[{value:Ui.SKIP,label:"已有运行时跳过本次"}],xo={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},Vi=[{value:xo.DINGTALK,label:"钉钉 Webhook"},{value:xo.FEISHU,label:"飞书 Webhook"},{value:xo.WEBHOOK,label:"通用 Webhook"}],bo={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},zi=[{value:bo.COMPLETED,label:"本次运行结束后"},{value:bo.SUCCESS,label:"本次运行成功后"},{value:bo.ERROR,label:"本次运行失败后"}],Hi={SUMMARY:"summary"},qi=[{value:Hi.SUMMARY,label:"摘要消息"}],mr={ZH_CN:"zh-CN",EN_US:"en-US"},Ki=[{value:mr.ZH_CN,label:"简体中文"},{value:mr.EN_US,label:"English"}];function oo(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Qo.find(o=>o.value===t))==null?void 0:n.value)||ks.CODEX}function St(e){var t;return((t=Qo.find(n=>n.value===oo(e)))==null?void 0:t.label)||"Codex"}function wS(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 Wi(e=[],t=10){const n=e.find(o=>{var s;return(o.type===Pt.TEXT||o.type===Pt.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const Gi={class:"min-w-0 flex-1"},Xi={key:0,class:"flex items-center gap-2"},Yi=["disabled"],mo={__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=q(()=>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 r(){n.closeDisabled||o("close")}function l(){!n.closeOnBackdrop||n.closeDisabled||o("close")}function u(m){!n.open||!n.closeOnEscape||n.closeDisabled||m.key==="Escape"&&o("close")}return $e(()=>n.open,m=>{if(n.lockBodyScroll&&document.body.classList.toggle("overflow-hidden",m),m&&n.closeOnEscape){window.addEventListener("keydown",u);return}window.removeEventListener("keydown",u)},{immediate:!0}),Nt(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",u)}),(m,k)=>(p(),Ee(Ls,{to:"body"},[ue(Jr,{name:"dialog-shell"},{default:rt(()=>[e.open?(p(),b("div",{key:0,class:Te(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:at(l,["self"])},[i("section",{class:Te(["panel dialog-shell-panel flex min-h-0 w-full flex-col overflow-hidden",e.panelClass])},[m.$slots.title||m.$slots.header||m.$slots["header-actions"]||e.showClose?(p(),b("div",{key:0,class:Te(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",Gi,[mn(m.$slots,"header",{},()=>[mn(m.$slots,"title")])]),m.$slots["header-actions"]||e.showClose?(p(),b("div",Xi,[mn(m.$slots,"header-actions"),e.showClose?(p(),b("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[ue(a(Qr),{class:"h-4 w-4"})],8,Yi)):de("",!0)])):de("",!0)],2)):de("",!0),i("div",{class:Te(e.bodyClass)},[mn(m.$slots,"default")],2)],2)],2)):de("",!0)]),_:3})]))}},Ji={class:"flex items-start gap-3"},Qi={class:"theme-heading text-base font-semibold"},Zi={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},el={class:"flex justify-end gap-2 px-5 py-4"},tl=["disabled"],nl=["disabled"],Fs={__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}=Lt(),r=q(()=>n.title||s("common.confirm")),l=q(()=>n.confirmText||s("common.confirm")),u=q(()=>n.cancelText||s("common.cancel"));return(m,k)=>(p(),Ee(mo,{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:k[2]||(k[2]=d=>o("cancel"))},{title:rt(()=>[i("div",Ji,[i("span",{class:Te(["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"])},[ue(a(ri),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Qi,w(r.value),1),e.description?(p(),b("p",Zi,w(e.description),1)):de("",!0)])])]),default:rt(()=>[i("div",el,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:k[0]||(k[0]=d=>o("cancel"))},w(u.value),9,tl),i("button",{type:"button",class:Te(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:k[1]||(k[1]=d=>o("confirm"))},w(e.loading?a(s)("common.processing"):l.value),11,nl)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},sl={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"},ol={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},rl=["onClick"],al={class:"min-w-0"},il={class:"text-sm font-medium"},ll={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},ul={__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,r)=>(p(),b("aside",sl,[i("nav",ol,[(p(!0),b(ft,null,vt(e.sections,l=>(p(),b("button",{key:l.id,type:"button",class:Te(["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:u=>o(l.id)},[(p(),Ee(Rn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",al,[i("div",il,w(l.label),1),i("p",ll,w(l.description),1)])],10,rl))),128))])]))}},cl=["aria-label","disabled","onKeydown"],dl={class:"min-w-0 flex-1"},fl={class:"theme-muted-text text-sm"},pl={class:"flex min-h-0 w-full flex-col"},ml={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},gl=["onClick"],hl={class:"theme-empty-state px-3 py-4 text-sm"},xn={__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}=Lt(),r=j(null),l=j(null),u=j(!1),m=j(!1),k=j({}),d=q(()=>{const O=String(n.modelValue??"");return n.options.find(se=>String(n.getOptionValue(se)??"")===O)||null}),T=q(()=>n.placeholder||s("common.select")),h=q(()=>n.emptyText||s("common.noOptions"));function g(O){return O&&typeof O=="object"&&Object.prototype.hasOwnProperty.call(O,"label")?String(O.label||""):String(n.getOptionValue(O)??"")}function f(){n.disabled||(u.value||o("refresh-intent"),u.value=!0)}function P(){u.value=!1}function ee(){if(u.value){P();return}f()}function v(O){o("update:modelValue",String(n.getOptionValue(O)??"").trim()),P()}function B(){if(!u.value||!r.value||typeof window>"u")return;const O=r.value.getBoundingClientRect(),se=window.innerWidth,A=window.innerHeight,X=8,ge=8,Se=160,L=360,ne=Math.max(0,A-O.bottom-ge),le=Math.max(0,O.top-ge);m.value=ne<260&&le>ne;const te=m.value?le-X:ne-X,ye=Math.max(Math.min(L,Math.max(te,0)),Math.min(Se,m.value?le:ne)),C=Math.min(O.width,se-ge*2),W=Math.min(Math.max(ge,O.left),Math.max(ge,se-ge-C));k.value={left:`${W}px`,top:m.value?`${O.top-X}px`:`${O.bottom+X}px`,width:`${C}px`,maxHeight:`${Math.max(ye,120)}px`,transform:m.value?"translateY(-100%)":"none"}}function K(O){var se;!u.value||!r.value||r.value.contains(O.target)||(se=l.value)!=null&&se.contains(O.target)||P()}function V(O){O.key==="Escape"&&P()}return $e(()=>n.disabled,O=>{O&&P()}),$e(u,async O=>{O&&(await dt(),B())}),kn(()=>{document.addEventListener("pointerdown",K),document.addEventListener("keydown",V),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0)}),Nt(()=>{document.removeEventListener("pointerdown",K),document.removeEventListener("keydown",V),window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}),(O,se)=>(p(),b("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:Te(["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:ee,onKeydown:[un(at(f,["prevent"]),["down"]),un(at(ee,["prevent"]),["enter"]),un(at(ee,["prevent"]),["space"])]},[i("div",dl,[mn(O.$slots,"trigger",{selectedOption:d.value,open:u.value,loading:e.loading,disabled:e.disabled},()=>[i("div",fl,w(d.value?g(d.value):T.value),1)])]),i("div",{class:Te(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(p(),Ee(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):de("",!0),ue(a(Go),{class:Te(["h-4 w-4 transition",u.value?"rotate-180":""])},null,8,["class"])],2)],42,cl),(p(),Ee(Ls,{to:"body"},[u.value?(p(),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:Nn(k.value)},[i("div",pl,[mn(O.$slots,"header",{loading:e.loading,options:e.options}),i("div",ml,[e.options.length?(p(!0),b(ft,{key:0},vt(e.options,A=>mn(O.$slots,"option",{key:String(e.getOptionValue(A)??""),option:A,selected:String(e.getOptionValue(A)??"")===String(e.modelValue??""),select:()=>v(A)},()=>[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=>v(A)},w(g(A)),9,gl)])),128)):mn(O.$slots,"empty",{key:1},()=>[i("div",hl,w(h.value),1)])])])],4)):de("",!0)]))],512))}},gr={},aa=typeof import.meta<"u"&&gr?gr:{};function vl(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(aa.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(/\/$/,"")}function Zo(){return(aa.VITE_API_BASE_URL||vl()).replace(/\/$/,"")}function er(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=Xe(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||Xe(t)}async function st(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Zo()}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error(er(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function cs(){return Zo()}function Ks(e){if(!e)return"";if(e.startsWith("http")){try{const t=new URL(e);if(typeof window<"u"&&(t.hostname==="localhost"||t.hostname==="127.0.0.1")){const n=new URL(window.location.origin);return t.hostname=n.hostname,t.port=n.port,t.protocol=n.protocol,t.toString()}}catch{}return e}return`${Zo()}${e}`}function xS(){return st("/api/meta",{cache:"no-store"})}function yl(){return st("/api/tasks")}function Sl(e=30){const t=typeof e=="object"&&e!==null?e:{limit:e},n=new URLSearchParams,o=Math.max(1,Number(t.limit)||30);return n.set("limit",String(o)),(t.slugs||[]).forEach(s=>{const r=String(s||"").trim();r&&n.append("slug",r)}),st(`/api/tasks/workspace-diff-summaries?${n.toString()}`,{cache:"no-store"})}function wl(e){return st("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function xl(e=[]){return st("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function ia(e){return st(`/api/tasks/${e}`)}function la(e,t){return st(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function bl(e){return st(`/api/tasks/${e}`,{method:"DELETE"})}async function kl(e){const t=new FormData;t.append("file",e);const n=await fetch(`${cs()}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(er(o,"errors.uploadFailed"))}return n.json()}async function Tl(e){const t=new FormData;t.append("file",e);const n=await fetch(`${cs()}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(er(o,"errors.pdfImportFailed"))}return n.json()}const _l=cs();function Cl(){return st("/api/codex/sessions")}function El(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return st(`/api/codex/workspaces${o?`?${o}`:""}`)}function bS(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 r=t.toString();return st(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function kS(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 st(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function TS(e,t={}){const n=new URLSearchParams,o=String(e||"").trim(),s=String(t.path||"").trim(),r=Number(t.limit||0);o&&n.set("q",o),s&&n.set("path",s),Number.isFinite(r)&&r>0&&n.set("limit",String(r));const l=n.toString();return st(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function Al(e){return st("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function Il(e,t){return st(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function $l(e){return st(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Pl(e){return st(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function Dl(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 r=n.toString();return st(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function Ll(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||60),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(r)&&r>0&&o.set("limit",String(r)),l&&o.set("_",l);const u=o.toString();return st(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function Ml(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=Number(t.limit||0),r=String(t.refreshToken||"").trim();o&&n.set("path",o),Number.isFinite(s)&&s>0&&n.set("limit",String(s)),r&&n.set("_",r);const l=n.toString();return st(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function Bl(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 r=n.toString();return st(`/api/codex/sessions/${encodeURIComponent(e)}/files/blame${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function Rl(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||80),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(r)&&r>0&&o.set("limit",String(r)),l&&o.set("_",l);const u=o.toString();return st(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function Nl(e,t){return st(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function Ol(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=Ni(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return st(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function Fl(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 r=n.toString();return st(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function _S(e,t={}){const n=new URLSearchParams,o=String(t.scope||"workspace").trim(),s=String(t.runId||"").trim(),r=String(t.filePath||"").trim(),l=t.includeFiles!==!1,u=t.includeStats!==!1,m=Math.max(0,Number(t.timeoutMs)||0);o==="run"?n.set("scope","run"):o==="task"?n.set("scope","task"):n.set("scope","workspace"),s&&n.set("runId",s),r&&n.set("filePath",r),l||n.set("includeFiles","false"),u||n.set("includeStats","false"),m>0&&n.set("timeoutMs",String(m));const k=n.toString();return st(`/api/tasks/${encodeURIComponent(e)}/git-diff${k?`?${k}`:""}`,{cache:"no-store"})}function CS(e,t={}){const n=new URLSearchParams,o=t.scope==="run"?"run":t.scope==="task"?"task":"workspace",s=String(t.runId||"").trim(),r=String(t.filePath||"").trim(),l=String(t.side||"").trim()==="before"?"before":"after";n.set("scope",o),n.set("side",l),s&&n.set("runId",s),r&&n.set("filePath",r);const u=n.toString();return`${_l}/api/tasks/${encodeURIComponent(e)}/git-diff/blob${u?`?${u}`:""}`}function Ul(e,t){return st(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function jl(e){return st(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function Vl(e){return st(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const zl={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Hl={class:"theme-muted-text mt-1 text-xs"},ql={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},Kl={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},Wl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},Gl={key:1,class:"space-y-4"},Xl={key:0,class:"space-y-4"},Yl={class:"theme-heading text-base font-medium"},Jl={class:"theme-muted-text mt-1 text-xs leading-5"},Ql={class:"settings-section-card px-4 py-4"},Zl={class:"block space-y-1.5"},eu={class:"theme-muted-text text-xs"},tu=["placeholder"],nu={key:1,class:"space-y-4"},su={class:"flex items-start justify-between gap-3"},ou={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},ru={class:"theme-muted-text mt-1 text-xs leading-5"},au={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},iu={class:"settings-section-card px-4 py-4"},lu={class:"grid gap-4 sm:grid-cols-2"},uu={class:"space-y-1.5 sm:col-span-2"},cu={class:"theme-muted-text text-xs"},du={class:"truncate text-sm text-[var(--theme-textPrimary)]"},fu={class:"space-y-1.5"},pu={class:"theme-muted-text text-xs"},mu=["disabled"],gu={key:0,class:"space-y-1.5"},hu={class:"theme-muted-text text-xs"},vu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},yu={class:"space-y-1.5"},Su={class:"theme-muted-text text-xs"},wu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},xu={class:"theme-muted-text text-xs"},bu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},ku={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Tu={key:2,class:"space-y-4"},_u={class:"flex items-start justify-between gap-3"},Cu={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Eu={class:"theme-muted-text mt-1 text-xs leading-5"},Au={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Iu={class:"settings-section-card px-4 py-4"},$u={class:"grid gap-4 sm:grid-cols-2"},Pu={class:"space-y-1.5"},Du={class:"theme-muted-text text-xs"},Lu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Mu={class:"space-y-1.5"},Bu={class:"theme-muted-text text-xs"},Ru={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Nu={class:"space-y-1.5 sm:col-span-2"},Ou={class:"theme-muted-text text-xs"},Fu=["placeholder","disabled"],Uu={class:"space-y-1.5"},ju={class:"theme-muted-text text-xs"},Vu=["placeholder","disabled"],zu={class:"space-y-1.5"},Hu={class:"theme-muted-text text-xs"},qu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Ku={class:"space-y-1.5"},Wu={class:"theme-muted-text text-xs"},Gu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Xu={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Yu={key:0,class:"theme-danger-text"},Ju={key:3,class:"theme-danger-text text-sm"},Qu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},Zu={class:"theme-muted-text theme-note-text"},ec={class:"flex items-center justify-end gap-2"},tc=["disabled"],nc=["disabled"],sc="0 9 * * 1-5",ko="weekdays",ws="09:00",es="1",oc={__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:r}=Lt(),l=j(!1),u=j(!1),m=j(""),k=j("basic"),d=Ms({title:"",automationEnabled:!1,automationMode:ko,automationTime:ws,automationWeekday:es,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),T=q(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),h=q(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:As},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:to},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:cr}]),g=q(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),f=q(()=>[{value:"1",label:r("taskDialog.sections.automation.weekday1")},{value:"2",label:r("taskDialog.sections.automation.weekday2")},{value:"3",label:r("taskDialog.sections.automation.weekday3")},{value:"4",label:r("taskDialog.sections.automation.weekday4")},{value:"5",label:r("taskDialog.sections.automation.weekday5")},{value:"6",label:r("taskDialog.sections.automation.weekday6")},{value:"0",label:r("taskDialog.sections.automation.weekday0")}]),P=q(()=>Fi.map(C=>({...C,label:C.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):C.label}))),ee=q(()=>ji.map(C=>({...C,label:C.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):C.label}))),v=q(()=>Vi.map(C=>({...C,label:C.value==="dingtalk"?r("taskDialog.sections.notification.channelDingtalk"):C.value==="feishu"?r("taskDialog.sections.notification.channelFeishu"):C.value==="webhook"?r("taskDialog.sections.notification.channelWebhook"):C.label}))),B=q(()=>zi.map(C=>({...C,label:C.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):C.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):C.value==="error"?r("taskDialog.sections.notification.triggerError"):C.label}))),K=q(()=>qi.map(C=>({...C,label:C.value==="summary"?r("taskDialog.sections.notification.messageSummary"):C.label}))),V=q(()=>Ki.map(C=>({...C,label:C.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):C.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):C.label}))),O=q(()=>d.notificationEnabled?d.notificationLastStatus==="success"?r("taskDialog.sections.notification.statusSuccess"):d.notificationLastStatus==="error"?r("taskDialog.sections.notification.statusError"):r("taskDialog.sections.notification.statusPending"):r("taskDialog.sections.notification.statusDisabled"));function se(){d.title="",d.automationEnabled=!1,d.automationMode=ko,d.automationTime=ws,d.automationWeekday=es,d.automationTimezone="local",d.automationConcurrencyPolicy="skip",d.automationLastTriggeredAt="",d.automationNextTriggerAt="",d.notificationEnabled=!1,d.notificationChannelType="dingtalk",d.notificationWebhookUrl="",d.notificationSecret="",d.notificationTriggerOn="completed",d.notificationLocale=String(s.value||"zh-CN"),d.notificationMessageMode="summary",d.notificationLastStatus="",d.notificationLastError="",d.notificationLastSentAt=""}function A(C=0){return String(C).padStart(2,"0")}function X(C=""){const W=String(C||"").trim().replace(/\s+/g," ");let D=W.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return D?{mode:"weekdays",time:`${A(D[2])}:${A(D[1])}`,weekday:es}:(D=W.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),D?{mode:"daily",time:`${A(D[2])}:${A(D[1])}`,weekday:es}:(D=W.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),D?{mode:"weekly",time:`${A(D[2])}:${A(D[1])}`,weekday:String(D[3])}:{mode:ko,time:ws,weekday:es}))}function ge(C=""){const D=String(C||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!D)return ws;const Ae=Number(D[1]),Pe=Number(D[2]);return!Number.isInteger(Ae)||!Number.isInteger(Pe)||Ae<0||Ae>23||Pe<0||Pe>59?ws:`${A(Ae)}:${A(Pe)}`}function Se(){var Ne;const C=ge(d.automationTime),[W,D]=C.split(":"),Ae=Number(W),Pe=Number(D);if(d.automationMode==="daily")return`${Pe} ${Ae} * * *`;if(d.automationMode==="weekly"){const Je=((Ne=f.value.find(Qe=>Qe.value===String(d.automationWeekday||"")))==null?void 0:Ne.value)||es;return`${Pe} ${Ae} * * ${Je}`}return`${Pe} ${Ae} * * 1-5`}function L(C={}){var D,Ae,Pe,Ne,Je,Qe,We,be,H,Z,me,Ce,fe,Me,he,Be;d.title=String(C.title||""),d.automationEnabled=!!((D=C.automation)!=null&&D.enabled);const W=X(((Ae=C.automation)==null?void 0:Ae.cron)||sc);d.automationMode=W.mode,d.automationTime=W.time,d.automationWeekday=W.weekday,d.automationTimezone=String(((Pe=C.automation)==null?void 0:Pe.timezone)||"local"),d.automationConcurrencyPolicy=String(((Ne=C.automation)==null?void 0:Ne.concurrencyPolicy)||"skip"),d.automationLastTriggeredAt=String(((Je=C.automation)==null?void 0:Je.lastTriggeredAt)||""),d.automationNextTriggerAt=String(((Qe=C.automation)==null?void 0:Qe.nextTriggerAt)||""),d.notificationEnabled=!!((We=C.notification)!=null&&We.enabled),d.notificationChannelType=String(((be=C.notification)==null?void 0:be.channelType)||"dingtalk"),d.notificationWebhookUrl=String(((H=C.notification)==null?void 0:H.webhookUrl)||""),d.notificationSecret=String(((Z=C.notification)==null?void 0:Z.secret)||""),d.notificationTriggerOn=String(((me=C.notification)==null?void 0:me.triggerOn)||"completed"),d.notificationLocale=String(((Ce=C.notification)==null?void 0:Ce.locale)||s.value||"zh-CN"),d.notificationMessageMode=String(((fe=C.notification)==null?void 0:fe.messageMode)||"summary"),d.notificationLastStatus=String(((Me=C.notification)==null?void 0:Me.lastStatus)||""),d.notificationLastError=String(((he=C.notification)==null?void 0:he.lastError)||""),d.notificationLastSentAt=String(((Be=C.notification)==null?void 0:Be.lastSentAt)||"")}async function ne(){const C=String(n.taskSlug||"").trim();if(!C){se();return}l.value=!0,m.value="";try{const W=await ia(C);L(W)}catch(W){m.value=(W==null?void 0:W.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function le(){return{title:d.title,automation:{enabled:d.automationEnabled,cron:Se(),timezone:d.automationTimezone,concurrencyPolicy:d.automationConcurrencyPolicy},notification:{enabled:d.notificationEnabled,channelType:d.notificationChannelType,webhookUrl:d.notificationWebhookUrl,secret:d.notificationSecret,triggerOn:d.notificationTriggerOn,locale:d.notificationLocale,messageMode:d.notificationMessageMode}}}async function te(){const C=String(n.taskSlug||"").trim();if(!(!C||l.value||u.value)){u.value=!0,m.value="";try{const W=await la(C,le());L(W),o("saved",W),o("close")}catch(W){m.value=(W==null?void 0:W.message)||r("taskDialog.saveFailed")}finally{u.value=!1}}}function ye(C=""){if(!C)return r("common.notAvailable");const W=new Date(C);return Number.isNaN(W.getTime())?r("common.notAvailable"):Gr(W.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return $e(()=>n.open,C=>{if(C){k.value="basic",ne();return}},{immediate:!0}),$e(()=>n.taskSlug,()=>{n.open&&ne()}),(C,W)=>(p(),Ee(mo,{open:e.open,"stack-level":3,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:W[16]||(W[16]=D=>o("close"))},{title:rt(()=>[i("div",null,[i("div",zl,[ue(a(As),{class:"h-4 w-4"}),i("span",null,w(a(r)("taskDialog.title")),1)]),i("p",Hl,w(a(r)("taskDialog.currentTask",{title:T.value})),1)])]),default:rt(()=>[i("div",ql,[ue(ul,{modelValue:k.value,"onUpdate:modelValue":W[0]||(W[0]=D=>k.value=D),sections:h.value},null,8,["modelValue","sections"]),i("div",Kl,[l.value?(p(),b("div",Wl,[ue(a(Gt),{class:"h-4 w-4 animate-spin"}),i("span",null,w(a(r)("taskDialog.loading")),1)])):(p(),b("div",Gl,[k.value==="basic"?(p(),b("section",Xl,[i("div",null,[i("div",Yl,w(a(r)("taskDialog.sections.basic.title")),1),i("p",Jl,w(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",Ql,[i("label",Zl,[i("span",eu,w(a(r)("taskDialog.sections.basic.taskTitle")),1),ln(i("input",{"onUpdate:modelValue":W[1]||(W[1]=D=>d.title=D),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,tu),[[bs,d.title]])])])])):k.value==="automation"?(p(),b("section",nu,[i("div",su,[i("div",null,[i("div",ou,[ue(a(to),{class:"h-4 w-4"}),i("span",null,w(a(r)("taskDialog.sections.automation.title")),1)]),i("p",ru,w(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",au,[ln(i("input",{"onUpdate:modelValue":W[2]||(W[2]=D=>d.automationEnabled=D),type:"checkbox",class:"h-4 w-4"},null,512),[[ur,d.automationEnabled]]),i("span",null,w(a(r)("taskDialog.enabled")),1)])]),i("section",iu,[i("div",lu,[i("label",uu,[i("span",cu,w(a(r)("taskDialog.sections.automation.mode")),1),ue(xn,{modelValue:d.automationMode,"onUpdate:modelValue":W[3]||(W[3]=D=>d.automationMode=D),options:g.value,disabled:!d.automationEnabled,"get-option-value":D=>D.value},{trigger:rt(({selectedOption:D})=>[i("div",du,w((D==null?void 0:D.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",fu,[i("span",pu,w(a(r)("taskDialog.sections.automation.time")),1),ln(i("input",{"onUpdate:modelValue":W[4]||(W[4]=D=>d.automationTime=D),type:"time",class:"tool-input",disabled:!d.automationEnabled},null,8,mu),[[bs,d.automationTime]])]),d.automationMode==="weekly"?(p(),b("label",gu,[i("span",hu,w(a(r)("taskDialog.sections.automation.weekday")),1),ue(xn,{modelValue:d.automationWeekday,"onUpdate:modelValue":W[5]||(W[5]=D=>d.automationWeekday=D),options:f.value,disabled:!d.automationEnabled,"get-option-value":D=>D.value},{trigger:rt(({selectedOption:D})=>[i("div",vu,w((D==null?void 0:D.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):de("",!0),i("label",yu,[i("span",Su,w(a(r)("taskDialog.sections.automation.timezone")),1),ue(xn,{modelValue:d.automationTimezone,"onUpdate:modelValue":W[6]||(W[6]=D=>d.automationTimezone=D),options:P.value,disabled:!d.automationEnabled,"get-option-value":D=>D.value},{trigger:rt(({selectedOption:D})=>[i("div",wu,w((D==null?void 0:D.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:Te(["space-y-1.5",d.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",xu,w(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),ue(xn,{modelValue:d.automationConcurrencyPolicy,"onUpdate:modelValue":W[7]||(W[7]=D=>d.automationConcurrencyPolicy=D),options:ee.value,disabled:!d.automationEnabled,"get-option-value":D=>D.value},{trigger:rt(({selectedOption:D})=>[i("div",bu,w((D==null?void 0:D.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",ku,[i("p",null,w(a(r)("taskDialog.sections.automation.lastTriggered",{value:ye(d.automationLastTriggeredAt)})),1),i("p",null,w(a(r)("taskDialog.sections.automation.nextTriggered",{value:ye(d.automationNextTriggerAt)})),1)])])])):(p(),b("section",Tu,[i("div",_u,[i("div",null,[i("div",Cu,[ue(a(cr),{class:"h-4 w-4"}),i("span",null,w(a(r)("taskDialog.sections.notification.title")),1)]),i("p",Eu,w(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",Au,[ln(i("input",{"onUpdate:modelValue":W[8]||(W[8]=D=>d.notificationEnabled=D),type:"checkbox",class:"h-4 w-4"},null,512),[[ur,d.notificationEnabled]]),i("span",null,w(a(r)("taskDialog.enabled")),1)])]),i("section",Iu,[i("div",$u,[i("label",Pu,[i("span",Du,w(a(r)("taskDialog.sections.notification.channelType")),1),ue(xn,{modelValue:d.notificationChannelType,"onUpdate:modelValue":W[9]||(W[9]=D=>d.notificationChannelType=D),options:v.value,disabled:!d.notificationEnabled,"get-option-value":D=>D.value},{trigger:rt(({selectedOption:D})=>[i("div",Lu,w((D==null?void 0:D.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Mu,[i("span",Bu,w(a(r)("taskDialog.sections.notification.triggerOn")),1),ue(xn,{modelValue:d.notificationTriggerOn,"onUpdate:modelValue":W[10]||(W[10]=D=>d.notificationTriggerOn=D),options:B.value,disabled:!d.notificationEnabled,"get-option-value":D=>D.value},{trigger:rt(({selectedOption:D})=>[i("div",Ru,w((D==null?void 0:D.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Nu,[i("span",Ou,w(a(r)("taskDialog.sections.notification.webhookUrl")),1),ln(i("input",{"onUpdate:modelValue":W[11]||(W[11]=D=>d.notificationWebhookUrl=D),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!d.notificationEnabled},null,8,Fu),[[bs,d.notificationWebhookUrl]])]),i("label",Uu,[i("span",ju,w(a(r)("taskDialog.sections.notification.secret")),1),ln(i("input",{"onUpdate:modelValue":W[12]||(W[12]=D=>d.notificationSecret=D),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!d.notificationEnabled},null,8,Vu),[[bs,d.notificationSecret]])]),i("label",zu,[i("span",Hu,w(a(r)("taskDialog.sections.notification.locale")),1),ue(xn,{modelValue:d.notificationLocale,"onUpdate:modelValue":W[13]||(W[13]=D=>d.notificationLocale=D),options:V.value,disabled:!d.notificationEnabled,"get-option-value":D=>D.value},{trigger:rt(({selectedOption:D})=>[i("div",qu,w((D==null?void 0:D.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Ku,[i("span",Wu,w(a(r)("taskDialog.sections.notification.messageMode")),1),ue(xn,{modelValue:d.notificationMessageMode,"onUpdate:modelValue":W[14]||(W[14]=D=>d.notificationMessageMode=D),options:K.value,disabled:!d.notificationEnabled,"get-option-value":D=>D.value},{trigger:rt(({selectedOption:D})=>[i("div",Gu,w((D==null?void 0:D.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",Xu,[i("p",null,w(a(r)("taskDialog.sections.notification.status",{value:O.value})),1),i("p",null,w(a(r)("taskDialog.sections.notification.lastSent",{value:ye(d.notificationLastSentAt)})),1),d.notificationLastError?(p(),b("p",Yu,w(a(r)("taskDialog.sections.notification.lastError",{value:d.notificationLastError})),1)):de("",!0)])])])),m.value?(p(),b("p",Ju,w(m.value),1)):de("",!0)]))])]),i("div",Qu,[i("p",Zu,w(a(r)("taskDialog.footerHint")),1),i("div",ec,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:u.value,onClick:W[15]||(W[15]=D=>o("close"))},w(a(r)("common.cancel")),9,tc),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-sm",disabled:u.value||l.value,onClick:te},[u.value?(p(),Ee(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(p(),Ee(a(ai),{key:1,class:"h-4 w-4"})),i("span",null,w(u.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,nc)])])]),_:1},8,["open"]))}};function rc(e=[]){return(Array.isArray(e)&&e.length?e:Qo).filter(n=>n&&typeof n=="object").map(n=>{const o=oo(n.value);return{...n,value:o,label:String(n.label||St(o)).trim()||St(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function ac(e=[]){return rc(e).filter(t=>t.enabled&&t.available)}async function ES(){const e=await st("/api/meta",{cache:"no-store"});return ac(e==null?void 0:e.agentEngineOptions)}function ua(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=St(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const ic={key:0,class:"flex items-center gap-2 text-sm"},lc={class:"min-w-0 flex-1 truncate"},uc={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},cc={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},dc={key:1,class:"theme-muted-text text-sm"},fc={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},pc=["onClick"],mc={class:"flex items-center gap-3"},gc={class:"min-w-0 flex-1"},hc={class:"flex items-center gap-2 text-sm sm:hidden"},vc={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},yc={class:"hidden items-center gap-2 text-sm sm:flex"},Sc={class:"min-w-0 flex-1 truncate"},wc={class:"font-medium text-[var(--theme-textPrimary)]"},xc={class:"theme-muted-text ml-2 font-mono text-[11px]"},bc={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},kc={__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}=Lt();function s(d){return(d==null?void 0:d.title)||o("projectManager.untitledProject")}function r(d){return(d==null?void 0:d.cwd)||o("projectManager.notSet")}function l(d){return d!=null&&d.running?o("projectManager.running"):o("projectManager.idle")}function u(d){return d!=null&&d.running?"theme-status-warning":"theme-status-success"}function m(d){var h;const T=Math.max(0,Number((h=d==null?void 0:d.agentBindings)==null?void 0:h.length)||0);return T>1?o("projectManager.agentCount",{count:T}):St(d==null?void 0:d.engine)}function k(d){return d?"theme-filter-active":"theme-filter-idle"}return(d,T)=>(p(),Ee(xn,{"model-value":e.modelValue,options:e.sessions,loading:e.loading,disabled:e.disabled,"trigger-class":"h-9",placeholder:a(o)("projectManager.selectProject"),"empty-text":a(o)("projectManager.noProjectsInSelect"),"get-option-value":h=>(h==null?void 0:h.id)||"","onUpdate:modelValue":T[0]||(T[0]=h=>n("update:modelValue",h)),onRefreshIntent:T[1]||(T[1]=h=>n("refresh-intent"))},{trigger:rt(({selectedOption:h,disabled:g})=>[h?(p(),b("div",ic,[i("span",lc,[i("span",{class:Te(["font-medium",g?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},w(s(h)),3),i("span",uc,w(r(h)),1)]),i("span",cc,w(m(h)),1),i("span",{class:Te(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",u(h)])},w(l(h)),3)])):(p(),b("div",dc,w(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:rt(()=>[i("div",fc,[i("span",null,w(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(p(),Ee(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):de("",!0)])]),option:rt(({option:h,selected:g,select:f})=>[i("button",{type:"button",class:Te(["w-full rounded-sm border border-dashed p-3 text-left transition",k(g)]),onClick:f},[i("div",mc,[i("div",gc,[i("div",hc,[i("span",vc,w(s(h)),1)]),i("div",yc,[i("span",Sc,[i("span",wc,w(s(h)),1),i("span",xc,w(r(h)),1)]),i("span",bc,w(m(h)),1),i("span",{class:Te(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",u(h)])},w(l(h)),3)])]),g?(p(),Ee(a(Zr),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):de("",!0)])],10,pc)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},Tc=["disabled"],_c=["disabled"],Cc=["src","alt"],No={__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}=Lt(),r=j(1),l=q(()=>n.images.map(v=>String(v||"").trim()).filter(Boolean)),u=q(()=>l.value.findIndex(v=>v===n.modelValue)),m=q(()=>u.value>=0?l.value[u.value]:"");function k(){o("update:modelValue",""),r.value=1}function d(v){o("update:modelValue",String(v||"").trim()),r.value=1}function T(){u.value<=0||d(l.value[u.value-1])}function h(){u.value<0||u.value>=l.value.length-1||d(l.value[u.value+1])}function g(v){const B=Math.min(3,Math.max(.5,r.value+v));r.value=Math.round(B*100)/100}function f(){r.value=1}function P(v){m.value&&(v.preventDefault(),g(v.deltaY<0?.1:-.1))}function ee(v){var B,K;if(m.value){if((B=v.stopPropagation)==null||B.call(v),(K=v.stopImmediatePropagation)==null||K.call(v),v.key==="Escape"){v.preventDefault(),k();return}if(v.key==="ArrowLeft"){v.preventDefault(),T();return}if(v.key==="ArrowRight"){v.preventDefault(),h();return}if(v.key==="+"||v.key==="="){v.preventDefault(),g(.1);return}if(v.key==="-"){v.preventDefault(),g(-.1);return}v.key==="0"&&(v.preventDefault(),f())}}return $e(()=>n.modelValue,v=>{v||(r.value=1)}),$e(l,v=>{if(n.modelValue){if(!v.length){k();return}if(!v.includes(n.modelValue)){const B=Math.min(u.value,v.length-1);d(v[B]||v[0])}}},{immediate:!0}),kn(()=>{window.addEventListener("keydown",ee,{capture:!0})}),Nt(()=>{window.removeEventListener("keydown",ee,{capture:!0})}),(v,B)=>(p(),Ee(Ls,{to:"body"},[m.value?(p(),b("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-[120] flex items-center justify-center p-6",onClick:k,onWheel:P},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:B[2]||(B[2]=at(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:B[0]||(B[0]=K=>g(-.1))},w(a(s)("imagePreview.zoomOut")),1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:f},w(Math.round(r.value*100))+"% ",1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:B[1]||(B[1]=K=>g(.1))},w(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:B[3]||(B[3]=at(()=>{},["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:u.value<=0,onClick:T},w(a(s)("imagePreview.previous")),9,Tc),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:u.value<0||u.value>=l.value.length-1,onClick:h},w(a(s)("imagePreview.next")),9,_c),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:k},w(a(s)("imagePreview.close")),1)]),i("img",{src:m.value,alt:a(s)("imagePreview.alt"),class:"image-preview-overlay__image max-h-[90vh] max-w-[90vw] object-contain shadow-2xl transition-transform",style:Nn({transform:`scale(${r.value})`}),onClick:B[4]||(B[4]=at(()=>{},["stop"]))},null,12,Cc)],32)):de("",!0)]))}};let To=null;const AS={maxLines:2e3,maxChars:2e5},_o={maxLines:2e3,maxChars:2e5},Ec={"github-dark-default":()=>He(()=>import("./vendor-shiki-theme-github-dark-default-DVxJvksW.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>He(()=>import("./vendor-shiki-theme-github-light-BRz4x11q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},Ac={bash:()=>He(()=>import("./vendor-shiki-lang-bash-OmlQ8O-f.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>He(()=>import("./vendor-shiki-lang-c-Bf17QIO6.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>He(()=>import("./vendor-shiki-lang-cpp-Dz7DCXQD.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>He(()=>import("./vendor-shiki-lang-csharp-weekbih6.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>He(()=>import("./vendor-shiki-lang-css-Cc89nYhT.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>He(()=>import("./vendor-shiki-lang-diff-BKW5_WJa.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>He(()=>import("./vendor-shiki-lang-dockerfile-DKFA3n9j.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>He(()=>import("./vendor-shiki-lang-dotenv-BftIlyZY.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>He(()=>import("./vendor-shiki-lang-fish-DTee4iUj.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>He(()=>import("./vendor-shiki-lang-go-iEA7Y2np.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>He(()=>import("./vendor-shiki-lang-html-fEXQcPZb.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>He(()=>import("./vendor-shiki-lang-ini-BJNPDfrG.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>He(()=>import("./vendor-shiki-lang-java-CZdBcwkx.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>He(()=>import("./vendor-shiki-lang-javascript-5n6OdqL_.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>He(()=>import("./vendor-shiki-lang-json-DkR7bRnH.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>He(()=>import("./vendor-shiki-lang-less-DN-gfwMv.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>He(()=>import("./vendor-shiki-lang-markdown-CgfEScgY.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>He(()=>import("./vendor-shiki-lang-python-6ZggAICS.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>He(()=>import("./vendor-shiki-lang-powershell-N9rELqmw.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>He(()=>import("./vendor-shiki-lang-rust-BvkG5Wz9.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>He(()=>import("./vendor-shiki-lang-sass-DFAXHETo.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>He(()=>import("./vendor-shiki-lang-scss-ClLYCF3s.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>He(()=>import("./vendor-shiki-lang-sql-CBrOCv6B.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>He(()=>import("./vendor-shiki-lang-toml-C0vpllp6.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>He(()=>import("./vendor-shiki-lang-tsx-DVg_XTuK.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>He(()=>import("./vendor-shiki-lang-typescript-DV5oo9cD.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>He(()=>import("./vendor-shiki-lang-vue-QYrDJbPe.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>He(()=>import("./vendor-shiki-lang-xml-D4OZNqPk.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>He(()=>import("./vendor-shiki-lang-yaml-BZu-v6Um.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function ca(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function tr(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 nr(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 Ic(e=[],t={}){const n=tr(e);return nr(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function $c(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
6
+ `);return Ic(n?n.split(`
7
+ `):[],t)}async function da(){return To||(To=Promise.all([He(()=>import("./vendor-shiki-core-UNANE_3B.js").then(e=>e.F),__vite__mapDeps([1,2,3])),He(()=>import("./vendor-shiki-core-UNANE_3B.js").then(e=>e.G),__vite__mapDeps([1,2,3]))]).then(async([e,t])=>e.createHighlighterCore({engine:t.createJavaScriptRegexEngine(),langs:[],themes:[]}))),To}async function fa(e,t){if(!t||e.getLoadedThemes().includes(t))return;const n=Ec[t];n&&await e.loadTheme(await n())}async function pa(e,t){if(!t||e.getLoadedLanguages().includes(t))return;const n=Ac[t];n&&await e.loadLanguage(await n())}function as(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Pc={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 go(e=""){const t=String(e||"").trim().toLowerCase();return t?Pc[t]||t:""}function IS(e="",t=""){const n=go(t);if(n)return n;const o=String(e||"").trim().toLowerCase();if(!o)return"";const s=o.split("/").pop()||"",r=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[r]||""}function ma(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=as((e==null?void 0:e.content)||"");return`<span${t.length?` style="${t.join(";")}"`:""}>${n}</span>`}function ga(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:ca(e.length)}}function $S(e=[]){return(Array.isArray(e)?e.map(n=>String(n??"")):[]).map(n=>n?as(n):"&#8203;")}function Co(e=""){const t=String(e||"").replace(/\r\n/g,`
8
+ `);return ga(t.split(`
9
+ `).map(n=>n?as(n):"&#8203;"),{})}async function Dc(e=[],t={}){const n=tr(e),o=n.lines,s=t.isDark?"github-dark-default":"github-light",r=go(t.language);if(!o.length)return[];if(nr(n,t))return o.map(l=>l?as(l):"&#8203;");if(!r)return o.map(l=>l?as(l):"&#8203;");try{const l=await da();return await fa(l,s),await pa(l,r),(await l.codeToTokens(o.join(`
10
+ `),{lang:r,theme:s})).tokens.map(m=>m.length?m.map(ma).join(""):"&#8203;")}catch{return o.map(l=>l?as(l):"&#8203;")}}async function Lc(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
11
+ `),o=t.isDark?"github-dark-default":"github-light",s=go(t.language),r=n?n.split(`
12
+ `):[],l=tr(r);if(!n)return{html:"",lineCount:0,bg:"",fg:"",gutterWidth:ca(0)};if(nr(l,t)||!s)return Co(n);try{const u=await da();await fa(u,o),await pa(u,s);const m=await u.codeToTokens(n,{lang:s,theme:o});return ga(m.tokens.map(k=>k.length?k.map(ma).join(""):"&#8203;"),{bg:m.bg||"",fg:m.fg||""})}catch{return Co(n)}}const Mc=new sa,Bc="__PROMPTX_FENCE__";function ha(e=""){return String(e||"").trim().toLowerCase()}function Us(e=""){return Mc.utils.escapeHtml(String(e||""))}function Rc(e=""){const t=ha(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 va(e={}){const t=new sa({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,r=t.renderer.rules.fence;return t.renderer.rules.link_open=(l,u,m,k,d)=>{const T=l[u];return T.attrSet("target","_blank"),T.attrSet("rel","noreferrer noopener"),typeof n=="function"?n(l,u,m,k,d):d.renderToken(l,u,m)},t.renderer.rules.table_open=(l,u,m,k,d)=>`<div class="codex-table-wrap">${typeof o=="function"?o(l,u,m,k,d):d.renderToken(l,u,m)}`,t.renderer.rules.table_close=(l,u,m,k,d)=>`${typeof s=="function"?s(l,u,m,k,d):d.renderToken(l,u,m)}</div>`,e.captureFences?t.renderer.rules.fence=(l,u,m,k={},d)=>{const T=l[u],h=Array.isArray(k.__promptxFences)?k.__promptxFences:[],g=h.length,f=`${Bc}${g}__`;return h.push({content:String((T==null?void 0:T.content)||""),language:String((T==null?void 0:T.info)||"").trim().split(/\s+/)[0]||"",placeholder:f}),k.__promptxFences=h,f}:typeof r=="function"&&(t.renderer.rules.fence=r),t}const Nc=va({captureFences:!0}),Oc=va();async function Fc(e="",t="",n={}){const o=String(e||"").replace(/\r\n/g,`
13
+ `),s=ha(t),r=go(s),u=(await Dc(o.split(`
14
+ `),{isDark:!!n.isDark,language:r||s})).join(`
15
+ `),m=s?` class="language-${Us(s)}"`:"",k=Rc(t),d=Us(String(n.copyLabel||"Copy")),T=Us(String(n.copyAriaLabel||d)),g=`<div class="codex-code-block__header">${k?`<span class="codex-code-block__language">${Us(k)}</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="${T}">${d}</button></div>`;return`<div class="${k?"codex-code-block codex-code-block--labeled":"codex-code-block"}">${g}<pre><code${m}>${u}</code></pre></div>`}async function Uc(e="",t=[],n={}){if(!Array.isArray(t)||!t.length)return e;const o=await Promise.all(t.map(s=>Fc(s.content,s.language,n)));return t.reduce((s,r,l)=>s.replace(r.placeholder,o[l]||r.placeholder),e)}async function jc(e="",t={}){const n=String(e||"").trim();if(!n)return"";const o={},s=Nc.render(n,o);return Uc(s,o.__promptxFences||[],t)}function ya(e=""){const t=String(e||"").trim();return t?Oc.render(t):""}function Vc(e=""){let t=5381;for(const n of String(e||""))t=(t<<5)+t+n.charCodeAt(0),t|=0;return String(t>>>0)}function hr(e={}){const t=String((e==null?void 0:e.id)||"").trim();return t?`id:${t}`:`${(e==null?void 0:e.type)||"block"}:${Vc(JSON.stringify(e||{}))}`}function zc(e=[]){const t=Array.isArray(e)?e:[],n=t.reduce((s,r)=>{const l=hr(r);return s.set(l,(s.get(l)||0)+1),s},new Map),o=new Map;return t.map(s=>{const r=hr(s),l=(o.get(r)||0)+1;return o.set(r,l),{key:`${r}:${l}`,signature:r,occurrence:l,duplicateCount:n.get(r)||1}})}const Hc={key:0,class:"process-detail min-w-0 w-full max-w-full space-y-2"},qc={key:0,class:"process-detail-meta"},Kc={key:0,class:"process-detail-meta__label"},Wc={key:1,class:"process-detail-panel"},Gc={class:"space-y-1.5"},Xc={key:1,class:"process-detail-checklist__dot"},Yc={key:0,class:"process-detail-footnote"},Jc={key:0},Qc={key:2,class:"process-detail-panel"},Zc={class:"process-detail-directory__heading"},ed={key:0,class:"font-medium"},td={key:1,class:"process-detail-directory__type"},nd={class:"process-detail-directory__list"},sd={key:0,class:"process-detail-footnote"},od={key:0},rd={key:3,class:"process-detail-panel"},ad={class:"list-disc min-w-0 w-full max-w-full space-y-1.5 pl-5"},id={key:0,class:"process-detail-footnote"},ld={key:4,class:"process-detail-panel"},ud={class:"space-y-1.5"},cd={class:"process-detail-filechange__kind"},dd={class:"process-detail-filechange__path process-detail-mobile-code-scroll"},fd={key:5,class:"process-detail-panel"},pd={class:"space-y-2"},md={class:"flex min-w-0 items-center gap-2 text-xs leading-5"},gd={class:"min-w-0 flex flex-1 items-center gap-2"},hd={class:"shrink-0 font-medium text-[var(--theme-textPrimary)]"},vd=["title"],yd=["onClick"],Sd={class:"process-detail-directory__type shrink-0"},wd={key:0,class:"mt-2 border-l border-dashed border-[var(--theme-borderDefault)] pl-3"},xd={key:1,class:"whitespace-pre-wrap break-words text-xs leading-5"},bd=["innerHTML"],kd={key:7,class:"process-detail-text"},Td=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}=Lt(),o=j(new Set),s=q(()=>{const L=Array.isArray(t.blocks)?t.blocks.filter(Boolean):[];return L.length?L:String(t.detail||"").trim()?[{type:"text",text:String(t.detail||"").trim()}]:[]}),r=q(()=>zc(s.value)),l=q(()=>r.value.map(L=>L.key));$e(s,(L=[])=>{const ne=new Set;L.forEach((le,te)=>{(le==null?void 0:le.type)==="sub_agent_list"&&(Array.isArray(le.items)?le.items:[]).forEach((ye,C)=>{ne.add(se(te,ye,C))})}),o.value=new Set([...o.value].filter(le=>ne.has(le)))},{immediate:!0});function u(L=""){return ya(String(L||""))}function m(L=""){const ne=String(L||"").trim();return n(ne==="create"?"processDetail.changeCreate":ne==="delete"?"processDetail.changeDelete":ne==="update"?"processDetail.changeUpdate":"processDetail.changeGeneric")}function k(L={}){const ne=String((L==null?void 0:L.label)||"").trim().toLowerCase(),le=String((L==null?void 0:L.value)||"").trim();return le?le.length>56||["命令","command","目标","target","url","路径","path"].includes(ne)&&le.length>28?!0:le.includes(" ")&&le.length>36:!1}function d(L={},ne=[]){const le=String((L==null?void 0:L.label)||"").trim().toLowerCase();return["命令","command"].includes(le)?Array.isArray(ne)&&ne.length===1:!1}function T(L={}){const ne=String((L==null?void 0:L.label)||"").trim().toLowerCase();return["命令","command","路径","path","url","目标","target"].includes(ne)}function h(L={}){return L!=null&&L.completed?"completed":String((L==null?void 0:L.status)||"").trim().toLowerCase()==="in_progress"?"in_progress":"pending"}function g(L=0){return n("processDetail.hiddenItems",{count:L})}function f(L=0){return n("processDetail.directorySummary",{count:L})}function P(L=0){return n("processDetail.directoryHidden",{count:L})}function ee(L=0){return l.value[L]||`block-${L}`}function v(L=""){const ne=String(L||"").trim().toLowerCase();return n(ne==="completed"?"processDetail.subAgentCompleted":ne==="failed"?"processDetail.subAgentFailed":ne==="running"?"processDetail.subAgentRunning":ne==="pending_init"?"processDetail.subAgentPending":"processDetail.subAgentUnknown")}function B(L={}){return String((L==null?void 0:L.title)||(L==null?void 0:L.target)||(L==null?void 0:L.id)||"").trim()}function K(L={}){const ne=B(L),le=[],te=String((L==null?void 0:L.role)||"").trim(),ye=String((L==null?void 0:L.target)||"").trim(),C=String((L==null?void 0:L.model)||"").trim();return te&&te.toLowerCase()!=="default"&&le.push(te),ye&&ye!==ne&&le.push(ye),C&&le.push(C),le.join(" · ")}function V(L={}){return!!String((L==null?void 0:L.message)||"").trim()}function O(L={}){const ne=String((L==null?void 0:L.message)||"").replace(/\s+/g," ").trim();return ne||K(L)}function se(L=0,ne={},le=0){return`${ee(L)}:sub-agent:${String((ne==null?void 0:ne.id)||(ne==null?void 0:ne.target)||(ne==null?void 0:ne.title)||le)}`}function A(L=0,ne={},le=0){return o.value.has(se(L,ne,le))}function X(L=0,ne={},le=0){const te=se(L,ne,le),ye=new Set(o.value);ye.has(te)?ye.delete(te):ye.add(te),o.value=ye}function ge(L={}){return Array.isArray(L==null?void 0:L.messageBlocks)?L.messageBlocks.filter(Boolean):[]}function Se(L={}){return ge(L).some(le=>!["text","markdown"].includes(String((le==null?void 0:le.type)||"").trim()))}return(L,ne)=>{const le=ei("ProcessDetailRenderer",!0);return s.value.length?(p(),b("div",Hc,[(p(!0),b(ft,null,vt(s.value,(te,ye)=>(p(),b(ft,{key:l.value[ye]||`${te.type}-${ye}`},[te.type==="meta"?(p(),b("div",qc,[(p(!0),b(ft,null,vt(te.items||[],(C,W)=>(p(),b("div",{key:`${ye}-meta-${W}`,class:Te(["process-detail-meta__item",{"process-detail-meta__item--long":k(C),"process-detail-meta__item--value-only":d(C,te.items)}])},[d(C,te.items)?de("",!0):(p(),b("span",Kc,w(C.label),1)),i("span",{class:Te(["process-detail-meta__value",{"process-detail-mobile-code-scroll":k(C),"process-detail-meta__value--mono":T(C)}])},w(C.value),3)],2))),128))])):te.type==="checklist"?(p(),b("div",Wc,[i("div",Gc,[(p(!0),b(ft,null,vt(te.items||[],(C,W)=>(p(),b("div",{key:`${ye}-check-${W}`,class:"process-detail-checklist__item"},[i("span",{class:Te(["process-detail-checklist__icon",`is-${h(C)}`])},[h(C)==="completed"?(p(),Ee(a(Zr),{key:0,class:"h-3 w-3"})):h(C)==="in_progress"?(p(),b("span",Xc)):de("",!0)],2),i("span",{class:Te(h(C)==="completed"?"line-through":"")},w(C.text),3)]))),128))]),te.totalCount?(p(),b("div",Yc,[Ln(w(`已完成 ${(te.items||[]).filter(C=>C.completed).length} / ${te.totalCount}`)+" ",1),te.hiddenCount?(p(),b("span",Jc,w(`,还有 ${te.hiddenCount} 项`),1)):de("",!0)])):de("",!0)])):te.type==="directory_list"?(p(),b("div",Qc,[i("div",Zc,[te.path?(p(),b("span",ed,w(te.path),1)):de("",!0),te.entryType?(p(),b("span",td,w(te.entryType),1)):de("",!0)]),i("div",nd,[(p(!0),b(ft,null,vt(te.entries||[],(C,W)=>(p(),b("div",{key:`${ye}-entry-${W}`,class:"process-detail-directory__item"},w(C),1))),128))]),te.totalCount?(p(),b("div",sd,[Ln(w(f(te.totalCount))+" ",1),te.hiddenCount?(p(),b("span",od,w(P(te.hiddenCount)),1)):de("",!0)])):de("",!0)])):te.type==="bullet_list"?(p(),b("div",rd,[i("ul",ad,[(p(!0),b(ft,null,vt(te.items||[],(C,W)=>(p(),b("li",{key:`${ye}-bullet-${W}`,class:"min-w-0 w-full max-w-full break-words [overflow-wrap:anywhere]"},w(C),1))),128))]),te.hiddenCount?(p(),b("div",id,w(g(te.hiddenCount)),1)):de("",!0)])):te.type==="file_changes"?(p(),b("div",ld,[i("div",ud,[(p(!0),b(ft,null,vt(te.items||[],(C,W)=>(p(),b("div",{key:`${ye}-change-${W}`,class:"process-detail-filechange__item"},[i("span",cd,w(m(C.kind)),1),i("span",dd,w(C.path),1)]))),128))])])):te.type==="sub_agent_list"?(p(),b("div",fd,[i("div",pd,[(p(!0),b(ft,null,vt(te.items||[],(C,W)=>(p(),b("div",{key:`${ye}-sub-agent-${W}`,class:"min-w-0"},[i("div",md,[i("div",gd,[i("span",hd,w(B(C)),1),O(C)?(p(),b("span",{key:0,class:"process-detail-subagent__preview min-w-0 flex-1",title:O(C)},w(O(C)),9,vd)):de("",!0)]),V(C)?(p(),b("button",{key:0,type:"button",class:"shrink-0 text-[11px] underline decoration-dashed underline-offset-2",onClick:D=>X(ye,C,W)},w(A(ye,C,W)?a(n)("common.collapse"):a(n)("common.expand")),9,yd)):de("",!0),i("span",Sd,w(v(C.status)),1)]),V(C)&&A(ye,C,W)?(p(),b("div",wd,[Se(C)?(p(),Ee(le,{key:0,blocks:ge(C),kind:"sub-agent-message"},null,8,["blocks"])):(p(),b("pre",xd,w(C.message),1))])):de("",!0)]))),128))])])):te.type==="markdown"?(p(),b("div",{key:6,class:Te(["codex-markdown process-detail-markdown",{"process-detail-markdown--reasoning":t.kind==="reasoning"}]),innerHTML:u(te.text)},null,10,bd)):(p(),b("pre",kd,w(te.text),1))],64))),128))])):de("",!0)}}}),Sa={__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 r,l;typeof(s==null?void 0:s.button)=="number"&&s.button!==0||((r=s==null?void 0:s.preventDefault)==null||r.call(s),(l=s==null?void 0:s.stopPropagation)==null||l.call(s),o("click"))}const o=t;return(s,r)=>(p(),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:Nn({top:`${e.top}px`,left:`${e.left}px`}),onPointerdown:n,onKeydown:[r[0]||(r[0]=un(at(l=>o("click"),["prevent"]),["enter"])),r[1]||(r[1]=un(at(l=>o("click"),["prevent"]),["space"]))]},w(e.label),37))}},wa=96,vr=34,Dn=8,_d=72;function Cd(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement||null:null}function yr(e,t,n){var r;const o=Cd(e);if(!o||!n)return null;const s=(r=o.closest)==null?void 0:r.call(o,t);return s&&n.contains(s)?s:null}function Ed(e){const t=(e==null?void 0:e.commonAncestorContainer)||null;return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentNode||null:null}function Ad(e,t,{codeLeft:n=0,buttonWidth:o=wa,scrollTop:s=0,scrollLeft:r=0,clientWidth:l=0,clientHeight:u=0}={}){const k=Math.max(e.left||0,Number(n)||0)-t.left+r,d=r+Dn,T=r+Math.max(Dn,l-o-Dn),h=Math.max(d,Math.min(T,k||r+Dn)),g=e.bottom-t.top+s+Dn,f=e.top-t.top+s-vr-Dn,P=s+Dn,ee=s+u-Dn;return{top:g+vr<=ee?g:Math.max(P,f),left:h}}function xa(e={}){const t=j([]),n=j({visible:!1,top:0,left:0,content:""});let o=null,s=0;function r(){var V;return typeof e.getContainer=="function"?e.getContainer():((V=e.containerRef)==null?void 0:V.value)||null}function l(){return typeof e.getPositionContainer=="function"?e.getPositionContainer():r()}function u(){o&&(window.clearTimeout(o),o=null)}function m(){s&&(window.cancelAnimationFrame(s),s=0)}function k(V=[]){var O;t.value=V,(O=e.onSelectedRowsChange)==null||O.call(e,V)}function d({clearBrowserSelection:V=!1}={}){var O,se,A,X;u(),m(),V&&((A=(se=(O=window.getSelection)==null?void 0:O.call(window))==null?void 0:se.removeAllRanges)==null||A.call(se)),n.value={visible:!1,top:0,left:0,content:""},k([]),(X=e.onClear)==null||X.call(e)}function T(V){return V?typeof e.getOrderedRowElements=="function"?e.getOrderedRowElements(V).filter(Boolean):[...V.querySelectorAll(String(e.rowSelector||""))]:[]}function h(V){var O;return((O=e.mapRowElement)==null?void 0:O.call(e,V))??V}function g(V,O,se){const A=String(e.rowSelector||"").trim(),X=T(se);if(!A||!X.length)return[];const ge=yr(V.anchorNode,A,se),Se=yr(V.focusNode,A,se);if(ge&&Se){const L=X.indexOf(ge),ne=X.indexOf(Se);if(L>=0&&ne>=0){const[le,te]=L<=ne?[L,ne]:[ne,L];return X.slice(le,te+1)}}return X.filter(L=>{try{return O.intersectsNode(L)}catch{return!1}})}function f(){var W,D,Ae;const V=(W=window.getSelection)==null?void 0:W.call(window),O=r(),se=l();if(!(typeof e.isActive=="function"?e.isActive():!0)||!V||V.rangeCount<1||V.isCollapsed||!O||!se){d();return}const X=V.getRangeAt(0),ge=Ed(X);if(!ge||!O.contains(ge)){d();return}const Se=String(V.toString()||"").replace(/\u200b/g,"");if(!Se.trim()){d();return}const L=g(V,X,O);if(!L.length){d();return}const ne=L.map(Pe=>h(Pe)).filter(Pe=>Pe!==null&&typeof Pe<"u");if(!ne.length){d();return}const le=X.getBoundingClientRect(),te=(D=se.getBoundingClientRect)==null?void 0:D.call(se);if(!te){d();return}const ye=((Ae=e.getCodeLeft)==null?void 0:Ae.call(e,L[0]))||le.left,C=Ad(le,te,{codeLeft:ye,buttonWidth:Number(e.buttonWidth||wa),scrollTop:Number(se.scrollTop||0),scrollLeft:Number(se.scrollLeft||0),clientWidth:Number(se.clientWidth||0),clientHeight:Number(se.clientHeight||0)});n.value={visible:!0,top:C.top,left:C.left,content:Se},k(ne)}function P(){u(),o=window.setTimeout(()=>{o=null,f()},Number(e.debounceMs||_d))}function ee(){P()}function v(){P()}function B(){!n.value.visible||s||(s=window.requestAnimationFrame(()=>{s=0,f()}))}function K(){B()}return kn(()=>{var V,O,se,A;document.addEventListener("selectionchange",v),document.addEventListener("mouseup",v),document.addEventListener("scroll",K,!0),window.addEventListener("resize",K),(O=(V=window.visualViewport)==null?void 0:V.addEventListener)==null||O.call(V,"resize",K),(A=(se=window.visualViewport)==null?void 0:se.addEventListener)==null||A.call(se,"scroll",K)}),Nt(()=>{var V,O,se,A;d({clearBrowserSelection:!0}),document.removeEventListener("selectionchange",v),document.removeEventListener("mouseup",v),document.removeEventListener("scroll",K,!0),window.removeEventListener("resize",K),(O=(V=window.visualViewport)==null?void 0:V.removeEventListener)==null||O.call(V,"resize",K),(A=(se=window.visualViewport)==null?void 0:se.removeEventListener)==null||A.call(se,"scroll",K)}),{selectedRows:t,selectionAction:n,clearSelectionState:d,clearScheduledSelectionUpdate:u,handleSelectionMouseUp:ee,scheduleSelectionUpdate:P,updateSelectionActionFromDom:f}}const Id=250,$d=350,Pd=180,Ws=2;function Oo(e){return(e==null?void 0:e.name)==="AbortError"}const Eo="promptx:codex-recent-paths",Dd=12;function ba(e){const{getMode:t,props:n,onSelect:o}=e,s=j([]),r=j(!1),l=j(""),u=j([]),m=j(!1),k=j(""),d=j([]),T=j([]),h=j("tree"),g=j(""),f=new Map;let P=null,ee=0,v=0,B=null;const K=q(()=>String(n.query||"").trim()),V=q(()=>Math.max(1,Number(e.minimumQueryLength)||Ws)),O=q(()=>K.value.length>=V.value),se=q(()=>typeof t=="function"),A=q(()=>se.value?String((t==null?void 0:t())||"").trim()==="search"?"search":"tree":h.value),X=q(()=>We(s.value)),ge=q(()=>String(n.sessionId||"").trim()),Se=q(()=>ge.value?`promptx:codex-tree-expanded:${ge.value}`:""),L=q(()=>{if(!K.value)return d.value;const z=new Set(u.value.map(Q=>Q.path));return d.value.filter(Q=>z.has(Q.path))}),ne=q(()=>{const z=new Set(L.value.map(Q=>Q.path));return u.value.filter(Q=>!z.has(Q.path))}),le=q(()=>K.value?[...L.value,...ne.value]:d.value),te=q(()=>A.value==="search"?le.value:X.value),ye=q(()=>A.value==="search"?m.value:r.value),C=q(()=>A.value==="search"?k.value:l.value),W=q(()=>A.value==="search"&&!!n.sessionId&&O.value&&!m.value&&!k.value&&!le.value.length),D=q(()=>A.value==="search"&&!!n.sessionId&&!!K.value&&!O.value&&!m.value&&!k.value),Ae=q(()=>A.value==="tree"&&!!n.sessionId&&!r.value&&!l.value&&!X.value.length);function Pe(z,Q){if(!z||typeof window>"u")return Q;try{const ce=window.localStorage.getItem(z);return ce?JSON.parse(ce):Q}catch{return Q}}function Ne(z,Q){if(!(!z||typeof window>"u"))try{window.localStorage.setItem(z,JSON.stringify(Q))}catch{}}function Je(z=[]){return[...z].sort((Q,ce)=>{const xe=+(Q.type!=="directory")-+(ce.type!=="directory");return xe||String(Q.path||Q.name||"").localeCompare(String(ce.path||ce.name||""),"zh-CN")})}function Qe(z){return{...z,children:[],expanded:!1,loaded:!1,loading:!1}}function We(z=[],Q=0,ce=[]){return z.forEach(xe=>{ce.push({...xe,depth:Q}),xe.type==="directory"&&xe.expanded&&xe.children.length&&We(xe.children,Q+1,ce)}),ce}function be(z,Q=s.value){for(const ce of Q){if(ce.path===z)return ce;if(ce.children.length){const xe=be(z,ce.children);if(xe)return xe}}return null}function H(){s.value=[...s.value]}function Z(){P&&(window.clearTimeout(P),P=null),B&&(B.abort(),B=null)}function me(z=s.value,Q=[]){return z.forEach(ce=>{ce.type==="directory"&&ce.expanded&&(Q.push(ce.path),ce.children.length&&me(ce.children,Q))}),Q}function Ce(){if(!Se.value)return;const z=[...new Set(me())];T.value=z,Ne(Se.value,z)}function fe(){T.value=Se.value?Pe(Se.value,[]).filter(Boolean):[]}function Me(z=s.value,Q=new Set){if(!Q.size)return!1;const ce=z.filter(xe=>xe.type==="directory"&&xe.hasChildren).map(xe=>xe.path);return!ce.length||ce.length!==Q.size?!1:ce.every(xe=>Q.has(xe))}function he(){const z=Pe(Eo,[]);if(!Array.isArray(z)||!ge.value){d.value=[];return}d.value=z.filter(Q=>Q&&Q.sessionId===ge.value&&Q.path).sort((Q,ce)=>Number(ce.usedAt||0)-Number(Q.usedAt||0)).slice(0,Dd)}function Be(z){return z.name||z.path||"."}function ze(z){return z.path||"."}function Le(z){if(!ge.value||!(z!=null&&z.path))return;const Q={sessionId:ge.value,path:z.path,name:z.name||Be(z),type:z.type||"file",usedAt:Date.now()},ce=Pe(Eo,[]),xe=[Q];Array.isArray(ce)&&ce.forEach(qe=>{!(qe!=null&&qe.path)||!(qe!=null&&qe.sessionId)||qe.sessionId===Q.sessionId&&qe.path===Q.path||xe.push(qe)}),Ne(Eo,xe.slice(0,40)),he()}function wt(z=""){const Q=String(z||"").trim();return!Q||!Q.includes("/")?"":Q.slice(0,Q.lastIndexOf("/"))}function Ye(){const z=te.value;if(!z.length)return-1;const Q=z.findIndex(ce=>ce.path===g.value);return Q>=0?Q:0}function bt(){const z=te.value,Q=Ye();return Q<0||!z.length?null:z[Q]||null}function Ge(){const z=te.value;if(!z.length){g.value="";return}z.some(Q=>Q.path===g.value)||(g.value=z[0].path)}function lt(z,Q){if(Q){f.set(z,Q);return}f.delete(z)}function it(){var Q;const z=f.get(g.value);(Q=z==null?void 0:z.scrollIntoView)==null||Q.call(z,{block:"nearest"})}function kt(z=""){return String(z||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function pt(z="",Q=""){const ce=String(z||""),xe=String(Q||"").trim().toLowerCase();if(!ce||!xe)return null;const qe=ce.toLowerCase(),Tt=qe.indexOf(xe);if(Tt>=0)return{start:Tt,end:Tt+xe.length};const Kt=xe.split(/[\\/\s_.-]+/).filter(Boolean).sort((Ut,Bt)=>Bt.length-Ut.length);for(const Ut of Kt){if(Ut.length<2)continue;const Bt=qe.indexOf(Ut);if(Bt>=0)return{start:Bt,end:Bt+Ut.length}}return null}function gt(z="",Q=""){const ce=String(z||""),xe=pt(ce,Q);return xe?`${kt(ce.slice(0,xe.start))}<mark class="theme-search-highlight">${kt(ce.slice(xe.start,xe.end))}</mark>${kt(ce.slice(xe.end))}`:kt(ce)}function $(z){return gt(Be(z),K.value)}function I(z){return gt(ze(z),K.value)}async function oe(z="",Q={}){if(!n.sessionId){s.value=[],l.value="",r.value=!1;return}const ce=!z,xe=ce?null:be(z);if(!(!ce&&!xe)&&!(!Q.force&&(ce&&s.value.length||!ce&&xe.loaded))){ce?(r.value=!0,l.value=""):(xe.loading=!0,l.value="",H());try{const qe=await Dl(n.sessionId,{path:z,refreshToken:Q.refreshToken||""}),Tt=Je(qe.items||[]).map(Qe);if(ce){s.value=Tt;return}xe.children=Tt,xe.loaded=!0}catch(qe){l.value=qe.message}finally{ce?r.value=!1:(xe.loading=!1,H())}}}async function Ie(z=s.value,Q=new Set,ce={}){for(const xe of z)xe.type!=="directory"||!Q.has(xe.path)||(xe.expanded=!0,H(),await oe(xe.path,ce),xe.children.length&&await Ie(xe.children,Q,ce))}async function Re(z={}){await oe("",z);const Q=new Set(T.value),ce=Me(s.value,Q),xe=Q.size>0&&!ce;ce&&(T.value=[],Ne(Se.value,[]),Q.clear());for(const qe of s.value)qe.type!=="directory"||!qe.hasChildren||(qe.expanded=xe?Q.has(qe.path):!1);if(H(),xe){await Ie(s.value,Q,z);return}}async function De(z){if(A.value!=="tree")return;const Q=be(z);if(!(!Q||Q.type!=="directory")){if(!Q.loaded&&!Q.loading){Q.expanded=!0,H(),await oe(Q.path),Ce();return}Q.expanded=!Q.expanded,H(),Ce()}}function Ze(z){return z!=null&&z.path?(Le(z),o==null||o(z),!0):!1}async function Ue(z={}){const Q=K.value;ee+=1;const ce=ee,xe=z.refreshToken||"";if(Z(),!n.open||!n.sessionId||!Q||!O.value){m.value=!1,k.value="",u.value=[];return}B=new AbortController;try{const qe=await Ll(n.sessionId,Q,{limit:80,refreshToken:xe,signal:B.signal});if(ce!==ee)return;u.value=qe.items||[]}catch(qe){if(Oo(qe)||ce!==ee)return;k.value=qe.message,u.value=[]}finally{ce===ee&&(B=null),ce===ee&&(m.value=!1)}}function _t(z={}){if(Z(),!n.open||!n.sessionId||!K.value||!O.value){m.value=!1,k.value="",u.value=[];return}m.value=!0,k.value="",P=window.setTimeout(()=>{P=null,Ue(z)},Id)}function yt(){if(!n.sessionId){s.value=[],l.value="",r.value=!1,u.value=[],k.value="",m.value=!1;return}v=Date.now(),s.value=[],l.value="",u.value=[],k.value="",Re({force:!0,refreshToken:v}),_t({refreshToken:v})}function Dt(){if(se.value)return!1;const z=K.value?"search":"tree";return h.value===z?!1:(h.value=z,!0)}function et(){he(),fe(),Dt(),yt()}function Xt(){Z(),u.value=[],k.value="",m.value=!1}function sn(z){const Q=te.value;if(!Q.length)return!1;const ce=Ye(),xe=ce<0?0:(ce+z+Q.length)%Q.length;return g.value=Q[xe].path,dt(it),!0}async function Yt(){if(A.value!=="tree")return!1;const z=bt();if(!z||z.type!=="directory")return!1;if(!z.expanded)return await De(z.path),g.value=z.path,!0;const Q=te.value,ce=Ye(),xe=Q[ce+1];return xe&&wt(xe.path)===z.path?(g.value=xe.path,!0):!1}function re(){if(A.value!=="tree")return!1;const z=bt();if(!z)return!1;if(z.type==="directory"&&z.expanded){const ce=be(z.path);return ce&&(ce.expanded=!1,H(),Ce()),g.value=z.path,!0}const Q=wt(z.path);return Q?(g.value=Q,!0):!1}function je(){const z=te.value;return z.length?Ze(z[Ye()]):!1}function tt(){s.value=[],l.value="",r.value=!1,u.value=[],k.value="",m.value=!1,he(),fe(),n.sessionId&&n.open&&(Re({force:!0}),_t())}function ot(){Dt(),_t()}function qt(){Ge(),dt(it)}return Nt(()=>{Z()}),{activeKey:g,collapseActiveDirectory:re,confirmActive:je,currentError:C,currentLoading:ye,emitSelect:Ze,expandActiveDirectory:Yt,getDisplayName:Be,getHighlightedName:$,getHighlightedPath:I,handleQueryChange:ot,handleSessionChange:tt,handleVisibleItemsChange:qt,initializeData:et,moveActive:sn,normalSearchItems:ne,normalizedQuery:K,recentSearchItems:L,resetData:Xt,setItemRef:lt,showSearchPromptState:D,showSearchEmptyState:W,showTreeEmptyState:Ae,toggleDirectory:De,treeItems:X,visibleItems:te}}const Ld={class:"min-w-0"},Md={class:"theme-heading truncate text-sm font-medium"},Bd={class:"source-browser-layout grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},Rd={class:"theme-divider border-b px-4 py-3"},Nd={class:"block"},Od={class:"sr-only"},Fd={class:"relative"},Ud=["placeholder","onKeydown"],jd=["title","aria-label"],Vd={class:"min-h-0 flex-1 overflow-y-auto p-2"},zd={key:0,class:"theme-empty-state px-3 py-4 text-[12px]"},Hd={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},qd={key:2,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},Kd={key:3,class:"theme-empty-state px-3 py-4 text-[12px]"},Wd={key:4,class:"theme-empty-state px-3 py-4 text-[12px]"},Gd={key:5,class:"theme-empty-state px-3 py-4 text-[12px]"},Xd={key:6,class:"theme-empty-state px-3 py-4 text-[12px]"},Yd={key:7,class:"theme-empty-state px-3 py-4 text-[12px]"},Jd={key:8,class:"theme-empty-state px-3 py-4 text-[12px]"},Qd={key:9,class:"theme-empty-state px-3 py-4 text-[12px]"},Zd={key:10,class:"theme-empty-state px-3 py-4 text-[12px]"},ef={key:11,class:"space-y-1"},tf={key:0,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},nf=["onClick"],sf={class:"min-w-0 flex-1"},of=["innerHTML"],rf=["innerHTML"],af={key:1,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},lf=["onClick"],uf={class:"min-w-0 flex-1"},cf=["innerHTML"],df=["innerHTML"],ff={key:12,class:"space-y-3"},pf={class:"theme-divider flex items-start gap-2.5 border-b px-3 py-2.5"},mf={class:"min-w-0 flex-1"},gf={class:"theme-list-item-title theme-list-item-title--strong break-all"},hf={key:0,class:"theme-list-item-meta truncate"},vf={class:"theme-list-item-meta shrink-0 pt-0.5"},yf={class:"space-y-1 px-2 py-2"},Sf=["onClick"],wf=["innerHTML"],xf={key:0,class:"theme-muted-text px-1 text-[12px]"},bf={key:13,class:"space-y-1"},kf=["onClick"],Tf={class:"flex items-start gap-1.5"},_f=["onClick"],Cf={key:1,class:"block h-5 w-5 shrink-0"},Ef=["onClick"],Af={class:"flex min-h-0 flex-col overflow-hidden"},If={class:"theme-divider border-b px-4 py-2"},$f={class:"flex items-center justify-between gap-3"},Pf={class:"min-w-0"},Df={key:0,class:"theme-muted-text truncate text-[12px]"},Lf={key:1,class:"theme-muted-text mt-1 text-[11px]"},Mf={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},Bf={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Rf={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-[12px]"},Nf={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Of={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Ff={key:4,class:"source-browser-image-wrap flex h-full min-h-[12rem] items-center justify-center overflow-hidden rounded-sm border p-4"},Uf=["src","alt"],jf={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-[12px]"},Vf={class:"source-code-view"},zf={class:"source-code-view__table"},Hf=["innerHTML"],qf={key:0,class:"inline-flex items-center gap-2"},Kf={key:1,class:"min-w-0"},Wf={class:"flex min-w-0 items-center gap-2"},Gf={class:"font-medium"},Xf={class:"theme-muted-text"},Yf={key:0,class:"theme-muted-text"},Jf={key:0,class:"mt-1 truncate"},Qf={key:1,class:"theme-muted-text mt-1"},Zf={key:2},Sr=20,ep={__name:"CodexSessionSourceBrowserDialog",props:{open:{type:Boolean,default:!1},session:{type:Object,default:null},initialSearchQuery:{type:String,default:""}},emits:["close","insert-code-context"],setup(e,{expose:t,emit:n}){const o=e,s=n,{t:r}=Lt(),{isDark:l}=Yr(),u=Ms({open:!1,sessionId:"",query:""}),m=j(""),k=j(""),d=j(!1),T=j(""),h=j(null),g=j(""),f=j("path"),P=j([]),ee=j(!1),v=j(""),B=j(""),K=j(!1),V=j(""),O=new Map,se=j(null),A=j(null),X=j(0),ge=j([]),Se=j(""),L=j(!1),ne=j(""),le=j(null),te=j(0),ye=j(8);let C=0,W=0,D=0,Ae=null,Pe=null,Ne=null;const Je=$d,Qe=Pd;let We=null;const be=new Map,H=new Map,Z=q(()=>{var c;return String(((c=o.session)==null?void 0:c.id)||"").trim()}),me=q(()=>{var c;return String(((c=o.session)==null?void 0:c.cwd)||"").trim()}),Ce=q(()=>f.value!=="content"),fe=q(()=>f.value==="content"),Me=q(()=>String(g.value||"").trim()),he=q(()=>Me.value.length>=Ws),Be=q(()=>{var c;return((c=h.value)==null?void 0:c.name)||m.value||""}),ze=q(()=>{var c;return((c=h.value)==null?void 0:c.path)||m.value||""}),Le=q(()=>{var c;return Sn(((c=h.value)==null?void 0:c.size)||0)}),wt=q(()=>{var E,R;const c=[];return(ze.value||Be.value)&&c.push(ze.value||Be.value),(E=h.value)!=null&&E.size&&c.push(Le.value),(R=h.value)!=null&&R.truncated&&c.push(r("sourceBrowser.truncated")),c.join(" ")}),Ye=q(()=>{var c;return!!((c=h.value)!=null&&c.previewUrl)}),bt=q(()=>{var c,E;return!!((c=h.value)!=null&&c.binary&&!((E=h.value)!=null&&E.previewUrl))}),Ge=q(()=>!!(h.value&&!h.value.binary&&!h.value.previewUrl)),lt=j(""),it=j(""),kt=j(""),pt=j("2.6rem"),{selectedRows:gt,selectionAction:$,clearSelectionState:I,handleSelectionMouseUp:oe,updateSelectionActionFromDom:Ie}=xa({getContainer:()=>A.value,isActive:()=>o.open&&Ge.value,rowSelector:".source-code-view__line",mapRowElement:c=>{var R;const E=Number(((R=c==null?void 0:c.getAttribute)==null?void 0:R.call(c,"data-line"))||0);return E>0?E:null},getCodeLeft:c=>{var pe,Fe,Ve;const E=(pe=c==null?void 0:c.querySelector)==null?void 0:pe.call(c,".source-code-view__code");if(!E)return 0;const R=(Fe=E.getBoundingClientRect)==null?void 0:Fe.call(E),J=(Ve=window.getComputedStyle)==null?void 0:Ve.call(window,E),G=Number.parseFloat((J==null?void 0:J.paddingLeft)||"0")||0;return((R==null?void 0:R.left)||0)+G},debounceMs:72}),Re=q(()=>[...new Set(gt.value)].map(c=>Number(c)||0).filter(c=>c>0).sort((c,E)=>c-E)),De=q(()=>{var R;const c=String(((R=h.value)==null?void 0:R.content)||"").replace(/\r\n/g,`
16
+ `),E=c?c.split(`
17
+ `):[];return[...Re.value].sort((J,G)=>J-G).map(J=>({lineNumber:J,content:String(E[J-1]||"")})).filter(J=>J.lineNumber>0)}),Ze=q(()=>De.value.length>0),Ue=q(()=>{var E;const c=Math.max(0,Number(te.value)||0);return!c||!Array.isArray((E=le.value)==null?void 0:E.items)?null:le.value.items.find(R=>Number(R==null?void 0:R.line)===c)||null}),_t=q(()=>{var c;return!!(Ge.value&&te.value&&(L.value||ne.value||Ue.value||(c=le.value)!=null&&c.message))}),yt=q(()=>fe.value?r("sourceBrowser.contentSearchPlaceholder"):r("sourceBrowser.searchPlaceholder")),Dt=q(()=>fe.value?r("sourceBrowser.searchModeContent"):r("sourceBrowser.searchModePath")),et=q(()=>!!Me.value),Xt=q(()=>et.value?"search":"tree"),sn=q(()=>et.value&&fe.value?ee.value:Kt.value),Yt=q(()=>Ce.value&&Cn.value),re=q(()=>Ce.value&&yn.value),je=q(()=>et.value&&fe.value&&!he.value&&!ee.value&&!v.value),tt=q(()=>et.value&&fe.value&&he.value&&!!B.value&&!ee.value&&!v.value&&!P.value.length),ot=q(()=>et.value&&fe.value&&he.value&&!ee.value&&!v.value&&!B.value&&!P.value.length),qt=q(()=>{const c=[],E=new Map;return P.value.forEach(R=>{const J=String((R==null?void 0:R.path)||"").trim();if(!J)return;let G=E.get(J);G||(G={path:J,name:String((R==null?void 0:R.name)||J.split("/").pop()||J),items:[]},E.set(J,G),c.push(G)),G.items.push(R)}),c}),z=q(()=>P.value.map(c=>F(c)).join("|")),Q=q(()=>_.value.map(c=>{const E=String((c==null?void 0:c.path)||"").trim(),R=c!=null&&c.expanded?1:0,J=c!=null&&c.loading?1:0;return`${E}:${R}:${J}`}).join("|")),{activeKey:ce,collapseActiveDirectory:xe,expandActiveDirectory:qe,currentError:Tt,currentLoading:Kt,getDisplayName:Ut,getHighlightedName:Bt,getHighlightedPath:Rt,handleQueryChange:Tn,handleSessionChange:Et,handleVisibleItemsChange:gn,initializeData:hn,moveActive:cn,normalSearchItems:_n,recentSearchItems:vn,resetData:On,setItemRef:dn,showSearchPromptState:yn,showSearchEmptyState:Cn,showTreeEmptyState:En,toggleDirectory:An,treeItems:fn,visibleItems:_}=ba({getMode:()=>Xt.value,props:u,onSelect:ke});function x(c=""){return String(c||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function F(c){return`${(c==null?void 0:c.path)||""}:${(c==null?void 0:c.line)||0}:${(c==null?void 0:c.column)||0}`}function ae(c,E){if(E){O.set(c,E);return}O.delete(c)}function ie(){var E;const c=O.get(V.value);(E=c==null?void 0:c.scrollIntoView)==null||E.call(c,{block:"nearest"})}function ve(c="",E=""){const R=String(c||""),J=String(E||"").trim();if(!R||!J)return x(R);const G=R.toLowerCase(),pe=J.toLowerCase(),Fe=G.indexOf(pe);if(Fe<0)return x(R);const Ve=Fe+pe.length;return`${x(R.slice(0,Fe))}<mark class="theme-search-highlight">${x(R.slice(Fe,Ve))}</mark>${x(R.slice(Ve))}`}function ut(c="",E=""){const R=String(c||""),J=String(E||"").trim();if(!R||!J)return[];const G=R.toLowerCase(),pe=J.toLowerCase(),Fe=[];let Ve=0;for(;Ve<G.length;){const It=G.indexOf(pe,Ve);if(It<0)break;Fe.push({start:It,end:It+pe.length}),Ve=It+pe.length}return Fe}function Oe(c,E,R){if(!c)return null;if(c.nodeType===Node.TEXT_NODE){const G=c.textContent||"",pe=R.offset,Fe=pe+G.length;if(R.offset=Fe,!G)return document.createTextNode("");const Ve=E.filter(tn=>tn.start<Fe&&tn.end>pe);if(!Ve.length)return document.createTextNode(G);const It=document.createDocumentFragment();let Ft=0;return Ve.forEach(tn=>{const Os=Math.max(0,tn.start-pe),yo=Math.min(G.length,tn.end-pe);if(Os>Ft&&It.appendChild(document.createTextNode(G.slice(Ft,Os))),yo>Os){const So=document.createElement("mark");So.className="source-code-view__search-hit",So.textContent=G.slice(Os,yo),It.appendChild(So)}Ft=Math.max(Ft,yo)}),Ft<G.length&&It.appendChild(document.createTextNode(G.slice(Ft))),It}if(c.nodeType!==Node.ELEMENT_NODE)return c.cloneNode(!0);const J=c.cloneNode(!1);return Array.from(c.childNodes||[]).forEach(G=>{const pe=Oe(G,E,R);pe&&J.appendChild(pe)}),J}function Jt(c=A.value){var E,R,J;c&&((J=(R=(E=c.querySelectorAll)==null?void 0:E.call(c,".source-code-view__line-inner[data-original-html]"))==null?void 0:R.forEach)==null||J.call(R,G=>{const pe=G.dataset.originalHtml;typeof pe=="string"&&(G.innerHTML=pe)}))}function on(){var R,J,G;const c=A.value,E=String(Se.value||"").trim();c&&(Jt(c),E&&((G=(J=(R=c.querySelectorAll)==null?void 0:R.call(c,".source-code-view__line.is-match .source-code-view__line-inner"))==null?void 0:J.forEach)==null||G.call(J,pe=>{pe.dataset.originalHtml||(pe.dataset.originalHtml=pe.innerHTML);const Fe=ut(pe.textContent||"",E);if(!Fe.length)return;const Ve=document.createDocumentFragment(),It={offset:0};Array.from(pe.childNodes||[]).forEach(Ft=>{const tn=Oe(Ft,Fe,It);tn&&Ve.appendChild(tn)}),pe.replaceChildren(Ve)})))}function Sn(c=0){const E=Math.max(0,Number(c)||0);return E<1024?`${E} B`:E<1024*1024?`${(E/1024).toFixed(E<10*1024?1:0)} KB`:`${(E/(1024*1024)).toFixed(1)} MB`}function In(c=""){const E=new Date(String(c||""));return Number.isNaN(E.getTime())?r("common.notAvailable"):new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(E)}function Ot(c=""){const R=new Date(String(c||"")).getTime();if(Number.isNaN(R))return"";const J=Date.now()-R,G=Math.abs(J),pe=[["year",365*24*60*60*1e3],["month",30*24*60*60*1e3],["day",24*60*60*1e3],["hour",60*60*1e3],["minute",60*1e3]],Fe=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}),[Ve,It]=pe.find(([,tn])=>G>=tn)||["minute",60*1e3],Ft=Math.round((R-Date.now())/It);return Fe.format(Ft,Ve)}function Qt(){return{top:`${Math.max(8,Number(ye.value)||0)}px`,right:"12px"}}function At(c=""){const E=String(c||"").trim();return E&&H.get(E)||null}function y(c="",E=null){const R=String(c||"").trim();if(!(!R||!E))for(H.set(R,E);H.size>Sr;){const J=H.keys().next().value;if(!J)break;H.delete(J)}}function N(c={}){W+=1,Ne&&(Ne.abort(),Ne=null),L.value=!1,ne.value="",le.value=null,te.value=0,c.clearCache&&H.clear()}async function M(){const c=ze.value;if(!Z.value||!c||!Ge.value)return;const E=At(c);if(E){le.value=E,L.value=!1,ne.value="";return}W+=1;const R=W;Ne&&Ne.abort(),Ne=new AbortController,L.value=!0,ne.value="";try{const J=await Bl(Z.value,{path:c,refreshToken:String(Date.now()),signal:Ne.signal});if(R!==W)return;le.value=J,y(c,J),ne.value=(J==null?void 0:J.supported)===!1?String(J.message||""):""}catch(J){if(Oo(J)||R!==W)return;le.value=null,ne.value=(J==null?void 0:J.message)||r("sourceBrowser.blameLoadFailed")}finally{R===W&&(L.value=!1,Ne=null)}}function we(c){var pe,Fe,Ve;if(!Ge.value)return;const E=(Fe=(pe=c==null?void 0:c.target)==null?void 0:pe.closest)==null?void 0:Fe.call(pe,".source-code-view__line");if(!E||!((Ve=A.value)!=null&&Ve.contains(E))){te.value=0;return}const R=Number(E.getAttribute("data-line")||0)||0,J=A.value.getBoundingClientRect(),G=E.getBoundingClientRect();te.value=R,ye.value=G.bottom-J.top+A.value.scrollTop+4,!le.value&&!L.value&&M()}function Ke(){te.value=0}function xt(){var E,R,J;const c=A.value;c&&(Jt(c),(J=(R=(E=c.querySelectorAll)==null?void 0:E.call(c,".source-code-view__line.is-match, .source-code-view__line.is-focus-match"))==null?void 0:R.forEach)==null||J.call(R,G=>G.classList.remove("is-match","is-focus-match")))}function Zt(){var E,R,J;const c=A.value;c&&((J=(R=(E=c.querySelectorAll)==null?void 0:E.call(c,".source-code-view__line.is-selected"))==null?void 0:R.forEach)==null||J.call(R,G=>G.classList.remove("is-selected")))}function jt(){Zt();const c=A.value;!c||!Re.value.length||Re.value.forEach(E=>{var G,pe;const R=c.querySelector(`.source-code-view__gutter[data-line="${E}"]`),J=(G=R==null?void 0:R.closest)==null?void 0:G.call(R,"tr");(pe=J==null?void 0:J.classList)==null||pe.add("is-selected")})}function rn(){if(!Re.value.length)return"";const c=[...Re.value].sort((E,R)=>E-R);return c[0]===c[c.length-1]?`L${c[0]}`:`L${c[0]}-${c[c.length-1]}`}function an(){var E,R,J,G;if(!h.value||!Ze.value)return;const c=De.value.map(pe=>pe.lineNumber);s("insert-code-context",{source:"source",filePath:ze.value,language:String(((E=h.value)==null?void 0:E.language)||""),rangeLabel:rn(),lineStart:Math.min(...c),lineEnd:Math.max(...c),content:String($.value.content||"").trim()||De.value.map(pe=>pe.content).join(`
18
+ `)}),(G=(J=(R=window.getSelection)==null?void 0:R.call(window))==null?void 0:J.removeAllRanges)==null||G.call(J),I(),s("close")}function Xn(c){var Fe,Ve,It,Ft;const E=(Fe=window.getSelection)==null?void 0:Fe.call(window),R=A.value;if(!E||E.rangeCount<1||E.isCollapsed||!R)return;Ie();const G=E.getRangeAt(0).commonAncestorContainer;if(!R.contains((G==null?void 0:G.nodeType)===1?G:G==null?void 0:G.parentNode))return;const pe=String(E.toString()||"").replace(/\u200b/g,"");pe&&((It=(Ve=c==null?void 0:c.clipboardData)==null?void 0:Ve.setData)==null||It.call(Ve,"text/plain",pe),(Ft=c==null?void 0:c.preventDefault)==null||Ft.call(c))}function pn(){We&&(window.clearTimeout(We),We=null)}function Yn(){be.clear(),H.clear()}function Jn(c=""){const E=String(c||"").trim();if(!E||!be.has(E))return null;const R=be.get(E);return be.delete(E),be.set(E,R),R}function ms(c="",E=null){const R=String(c||"").trim();if(!(!R||!E))for(be.delete(R),be.set(R,E);be.size>Sr;){const J=be.keys().next().value;if(!J)break;be.delete(J)}}function gs(c){pn(),We=window.setTimeout(()=>{We=null,c==null||c()},Qe)}function $n(){dt(()=>{var c,E;(E=(c=se.value)==null?void 0:c.focus)==null||E.call(c)})}function hs(c=""){const E=String(c||"").trim();return E?(f.value="path",en(),g.value=E,u.query=E,$n(),!0):!1}function Qn(c){var E,R,J;if((E=c==null?void 0:c.preventDefault)==null||E.call(c),Me.value){(R=c==null?void 0:c.stopPropagation)==null||R.call(c),g.value="";return}(J=c==null?void 0:c.stopPropagation)==null||J.call(c),s("close")}function vs(){pn(),C+=1,Yn(),m.value="",k.value="",d.value=!1,T.value="",h.value=null,lt.value="",it.value="",kt.value="",pt.value="2.6rem",X.value=0,ge.value=[],Se.value="",N({clearCache:!0}),I(),xt()}function en(){D+=1,Ae&&(window.clearTimeout(Ae),Ae=null),Pe&&(Pe.abort(),Pe=null),P.value=[],ee.value=!1,v.value="",B.value="",K.value=!1,V.value="",ge.value=[],Se.value="",xt()}function ho(){if(Ae&&(window.clearTimeout(Ae),Ae=null),!o.open||!Z.value||!fe.value)return;if(!Me.value||!he.value){en();return}ee.value=!0,v.value="",Ae=window.setTimeout(()=>{Ae=null,ct()},Je)}function ys(c=1){const E=P.value;if(!E.length)return!1;const R=E.findIndex(G=>F(G)===V.value),J=R<0?0:(R+c+E.length)%E.length;return V.value=F(E[J]),dt(ie),!0}function Zn(){return _.value.length&&(_.value.find(c=>c.path===ce.value)||_.value[0])||null}function Pn(c,E={}){return c?(ce.value=(c==null?void 0:c.path)||"",V.value="",m.value=String((c==null?void 0:c.path)||"").trim(),k.value=String((c==null?void 0:c.type)||"").trim(),T.value="",X.value=0,ge.value=[],Se.value="",N(),(c==null?void 0:c.type)==="directory"?(pn(),h.value=null,E.toggleDirectory&&!et.value&&An(c.path),!0):E.previewMode==="debounced"?(gs(()=>_e(c==null?void 0:c.path)),!0):(pn(),_e(c==null?void 0:c.path),!0)):!1}function Rs(){const c=P.value;if(!c.length)return!1;const E=c.find(R=>F(R)===V.value)||c[0];return ht(E),!0}function Ns(c){const E=String((c==null?void 0:c.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(E)&&!(et.value&&(E==="ArrowLeft"||E==="ArrowRight"))){if(fe.value&&et.value){if(E==="ArrowDown"){if(c.preventDefault(),ys(1)){const R=P.value,J=R.find(G=>F(G)===V.value)||R[0];ht(J,{previewMode:"debounced"})}return}if(E==="ArrowUp"){if(c.preventDefault(),ys(-1)){const R=P.value,J=R.find(G=>F(G)===V.value)||R[0];ht(J,{previewMode:"debounced"})}return}if(E==="Enter"){c.preventDefault(),Rs();return}E==="Escape"&&Qn(c);return}if(E==="ArrowDown"){c.preventDefault(),cn(1)&&dt(()=>{Pn(Zn(),{previewMode:"debounced"})});return}if(E==="ArrowUp"){c.preventDefault(),cn(-1)&&dt(()=>{Pn(Zn(),{previewMode:"debounced"})});return}if(E==="ArrowRight"){c.preventDefault(),qe();return}if(E==="ArrowLeft"){c.preventDefault(),xe();return}if(E==="Enter"){c.preventDefault(),Pn(Zn(),{toggleDirectory:!0});return}E==="Escape"&&Qn(c)}}async function Ss(){const c=fe.value?"path":"content";if(f.value=c,!Me.value){c==="content"?en():(en(),u.query="");return}if(c==="content"){u.query="",ct();return}en(),u.query=g.value}function vo(c){var E;c.preventDefault(),(E=c.stopPropagation)==null||E.call(c),Ss().finally(()=>{$n()})}async function S(){var pe;if(await dt(),xt(),!A.value)return;const c=[...new Set(ge.value.map(Fe=>Math.max(0,Number(Fe)||0)).filter(Fe=>Fe>0))],E=Math.max(0,Number(X.value)||0);if(c.forEach(Fe=>{var Ft,tn;const Ve=A.value.querySelector(`.source-code-view__gutter[data-line="${Fe}"]`),It=(Ft=Ve==null?void 0:Ve.closest)==null?void 0:Ft.call(Ve,"tr");(tn=It==null?void 0:It.classList)==null||tn.add("is-match")}),on(),!E){jt();return}const R=E,J=A.value.querySelector(`.source-code-view__gutter[data-line="${R}"]`),G=(pe=J==null?void 0:J.closest)==null?void 0:pe.call(J,"tr");if(!G){jt();return}G.classList.add("is-match","is-focus-match"),on(),G.scrollIntoView({block:"center",inline:"nearest"}),jt()}async function Y(){var pe,Fe,Ve;if(!Ge.value){lt.value="",it.value="",kt.value="";return}const c=C,E=String(((pe=h.value)==null?void 0:pe.content)||"").replace(/\r\n/g,`
19
+ `),R=((Fe=h.value)==null?void 0:Fe.language)||"",J=$c(E,_o),G=await Lc(((Ve=h.value)==null?void 0:Ve.content)||"",{isDark:l.value,language:R,maxHighlightLines:_o.maxLines,maxHighlightChars:_o.maxChars});c===C&&(lt.value=G.html,it.value=J?"":G.bg||"",kt.value=J?"":G.fg||"",pt.value=G.gutterWidth||"2.6rem",await dt(),jt())}async function _e(c="",E={}){var Fe;const R=String(c||"").trim();if(!Z.value||!R)return;X.value=Math.max(0,Number(E.focusLine)||0),I();const J=String(((Fe=h.value)==null?void 0:Fe.path)||"").trim();if(!E.forceReload&&J===R&&!d.value&&!T.value){await S();return}if(!E.forceReload&&d.value&&m.value===R)return;C+=1;const G=C;T.value="";const pe=E.forceReload?null:Jn(R);if(pe){d.value=!1,h.value=pe,await Y(),G===C&&Ge.value&&await S();return}d.value=!0;try{const Ve=await Ml(Z.value,{path:R,limit:204800,refreshToken:String(Date.now())});if(G!==C)return;h.value=Ve,ms(R,Ve),await Y()}catch(Ve){if(G!==C)return;h.value=null,T.value=(Ve==null?void 0:Ve.message)||r("sourceBrowser.previewFailed")}finally{G===C&&(d.value=!1,Ge.value&&await S())}}function ke(c){Pn(c,{toggleDirectory:!0}),dt($n)}function nt(c,E){var R,J;(J=(R=c==null?void 0:c.currentTarget)==null?void 0:R.focus)==null||J.call(R),ke(E)}async function ct(){const c=Me.value;if(!o.open||!Z.value)return;D+=1;const E=D;if(!c||!he.value){en();return}Pe&&(Pe.abort(),Pe=null),ee.value=!0,v.value="",P.value=[],K.value=!1,V.value="",Pe=new AbortController;try{const R=await Rl(Z.value,c,{limit:80,refreshToken:String(Date.now()),signal:Pe.signal});if(E!==D)return;B.value=c,P.value=Array.isArray(R.items)?R.items:[],K.value=!!R.truncated,V.value=P.value[0]?F(P.value[0]):"",P.value[0]&&ht(P.value[0],{previewMode:"debounced"})}catch(R){if(Oo(R)||E!==D)return;B.value=c,P.value=[],v.value=(R==null?void 0:R.message)||r("sourceBrowser.contentSearchFailed")}finally{E===D&&(Pe=null),E===D&&(ee.value=!1)}}function ht(c,E={}){V.value=F(c),ce.value=(c==null?void 0:c.path)||"",m.value=String((c==null?void 0:c.path)||"").trim(),k.value="file",T.value="",N(),Se.value=B.value||Me.value,ge.value=P.value.filter(J=>(J==null?void 0:J.path)===(c==null?void 0:c.path)).map(J=>Number((J==null?void 0:J.line)||0)).filter(J=>J>0);const R=()=>_e(c==null?void 0:c.path,{focusLine:c==null?void 0:c.line});if(E.previewMode==="debounced"){gs(R),dt($n);return}pn(),R(),dt($n)}function Vt(c){const E=String((c==null?void 0:c.path)||"").trim();if(!E)return"";const R=E.split("/");return R[R.length-1]||E}function Fn(c){const E=String((c==null?void 0:c.path)||"").trim();return!E||!E.includes("/")?"":E.slice(0,E.lastIndexOf("/"))}function Ya(c){return`${Array.isArray(c==null?void 0:c.items)?c.items.length:0} 处`}function Ja(c){const E=B.value||Me.value;return ve((c==null?void 0:c.preview)||"",E)}return $e(()=>o.open,c=>{var E,R,J,G,pe,Fe;if(u.open=c,c){(J=(R=(E=window.getSelection)==null?void 0:E.call(window))==null?void 0:R.removeAllRanges)==null||J.call(R),u.sessionId=Z.value,g.value="",f.value="path",u.query="",vs(),en(),hn(),hs(o.initialSearchQuery)||$n();return}(Fe=(pe=(G=window.getSelection)==null?void 0:G.call(window))==null?void 0:pe.removeAllRanges)==null||Fe.call(pe),g.value="",f.value="path",vs(),en(),On()},{immediate:!0}),$e(Z,c=>{u.sessionId=c,o.open&&(vs(),en(),Et())}),$e(()=>o.initialSearchQuery,c=>{o.open&&hs(c)}),$e(g,c=>{if(Ce.value){u.query=c;return}String(c||"").trim()!==String(B.value||"").trim()&&(Se.value="",on()),ho()}),$e(()=>u.query,()=>{Ce.value&&Tn()}),$e(z,()=>{dt(ie)}),$e(Q,()=>{gn(),!(!et.value||!Ce.value)&&dt(()=>{const c=Zn();c&&Pn(c,{previewMode:"debounced"})})}),$e(l,async()=>{!o.open||!Ge.value||(await Y(),await S())}),$e(Re,()=>{jt()}),Nt(()=>{var c,E,R;(R=(E=(c=window.getSelection)==null?void 0:c.call(window))==null?void 0:E.removeAllRanges)==null||R.call(E),I({clearBrowserSelection:!0}),pn()}),t({applyPathSearch:hs}),(c,E)=>(p(),Ee(mo,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] sm:h-[96vh] sm:max-h-[96vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-3.5","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:E[2]||(E[2]=R=>s("close"))},{title:rt(()=>[i("div",Ld,[i("div",Md,w(me.value||a(r)("sourceBrowser.title")),1)])]),default:rt(()=>{var R,J;return[i("div",Bd,[i("aside",{class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r",onKeydown:Ns},[i("div",Rd,[i("label",Nd,[i("span",Od,w(a(r)("sourceBrowser.searchLabel")),1),i("div",Fd,[ue(a(ii),{class:"theme-muted-text pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),ln(i("input",{ref_key:"searchInputRef",ref:se,"onUpdate:modelValue":E[0]||(E[0]=G=>g.value=G),type:"text",class:"tool-input w-full pl-9 pr-18 text-[12px]",placeholder:yt.value,onKeydown:[un(Qn,["esc"]),un(at(vo,["prevent"]),["tab"])]},null,40,Ud),[[bs,g.value]]),sn.value?(p(),Ee(a(Gt),{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"})):de("",!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:Dt.value,"aria-label":Dt.value,onClick:at(Ss,["stop","prevent"])},[ue(a(li),{class:"h-3.5 w-3.5"})],8,jd)])])]),i("div",Vd,[Z.value?et.value&&fe.value&&v.value?(p(),b("div",Hd,w(v.value),1)):a(Tt)?(p(),b("div",qd,w(a(Tt)),1)):re.value?(p(),b("div",Kd,w(a(r)("sourceBrowser.searchMinKeywordHint",{count:a(Ws)})),1)):Yt.value?(p(),b("div",Wd,w(a(r)("sourceBrowser.searchEmpty")),1)):je.value?(p(),b("div",Gd,w(a(r)("sourceBrowser.searchMinKeywordHint",{count:a(Ws)})),1)):ot.value?(p(),b("div",Xd,w(a(r)("sourceBrowser.contentSearchPrompt")),1)):tt.value?(p(),b("div",Yd,w(a(r)("sourceBrowser.contentSearchEmpty")),1)):a(En)?(p(),b("div",Jd,w(a(r)("sourceBrowser.treeEmpty")),1)):et.value&&fe.value&&ee.value&&!P.value.length?(p(),b("div",Qd,w(a(r)("sourceBrowser.contentSearching")),1)):a(Kt)&&!a(_).length?(p(),b("div",Zd,w(a(r)("sourceBrowser.loadingFiles")),1)):et.value&&Ce.value?(p(),b("div",ef,[a(vn).length?(p(),b("div",tf,w(a(r)("sourceBrowser.recent")),1)):de("",!0),(p(!0),b(ft,null,vt(a(vn),G=>(p(),b("button",{key:`recent-${G.path}`,ref_for:!0,ref:pe=>a(dn)(G.path,pe),type:"button",class:Te(["theme-list-row focus:outline-none",a(ce)===G.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:pe=>ke(G)},[(p(),Ee(Rn(G.type==="directory"?a(rs):a(Hn)),{class:"theme-list-item-icon"})),i("div",sf,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Bt)(G)},null,8,of)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Rt)(G)},null,8,rf)])],10,nf))),128)),u.query.trim()&&a(_n).length?(p(),b("div",af,w(a(r)("sourceBrowser.results")),1)):de("",!0),(p(!0),b(ft,null,vt(a(_n),G=>(p(),b("button",{key:`result-${G.path}`,ref_for:!0,ref:pe=>a(dn)(G.path,pe),type:"button",class:Te(["theme-list-row focus:outline-none",a(ce)===G.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:pe=>ke(G)},[(p(),Ee(Rn(G.type==="directory"?a(rs):a(Hn)),{class:"theme-list-item-icon"})),i("div",uf,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Bt)(G)},null,8,cf)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Rt)(G)},null,8,df)])],10,lf))),128))])):et.value?(p(),b("div",ff,[(p(!0),b(ft,null,vt(qt.value,G=>(p(),b("div",{key:G.path,class:"rounded-sm border border-[var(--theme-borderDefault)] bg-[var(--theme-panel)]"},[i("div",pf,[ue(a(Hn),{class:"theme-list-item-icon"}),i("div",mf,[i("div",gf,w(Vt(G)),1),Fn(G)?(p(),b("div",hf,w(Fn(G)),1)):de("",!0)]),i("div",vf,w(Ya(G)),1)]),i("div",yf,[(p(!0),b(ft,null,vt(G.items,pe=>(p(),b("button",{key:F(pe),ref_for:!0,ref:Fe=>ae(F(pe),Fe),type:"button",class:Te(["theme-list-row gap-0 focus:outline-none",V.value===F(pe)?"theme-list-item-active":"theme-list-item-hover"]),onClick:Fe=>ht(pe)},[i("div",{class:"theme-list-item-title min-w-0 flex-1 break-words leading-[1.45rem]",innerHTML:Ja(pe)},null,8,wf)],10,Sf))),128))])]))),128)),K.value?(p(),b("div",xf,w(a(r)("sourceBrowser.contentSearchTruncated")),1)):de("",!0)])):(p(),b("div",bf,[(p(!0),b(ft,null,vt(a(fn),G=>(p(),b("div",{key:G.path,ref_for:!0,ref:pe=>a(dn)(G.path,pe),class:Te(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(ce)===G.path?"theme-list-item-active":G.type==="directory"&&G.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nn({paddingLeft:`${G.depth*16+6}px`}),tabindex:"-1",onClick:pe=>nt(pe,G)},[i("div",Tf,[G.type==="directory"?(p(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:at(pe=>a(An)(G.path),["stop"])},[G.loading?(p(),Ee(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),Ee(a(ea),{key:1,class:Te(["h-3.5 w-3.5 transition",G.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,_f)):(p(),b("span",Cf)),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:at(pe=>ke(G),["stop"])},[(p(),Ee(Rn(G.type==="directory"?a(rs):a(Hn)),{class:Te(["h-4 w-4 shrink-0",G.type==="directory"&&G.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("span",{class:Te(["theme-list-item-title min-w-0 flex-1 truncate",G.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},w(a(Ut)(G)),3)],8,Ef)])],14,kf))),128))])):(p(),b("div",zd,w(a(r)("sourceBrowser.noProject")),1))])],32),i("section",Af,[i("div",If,[i("div",$f,[i("div",Pf,[wt.value?(p(),b("p",Df,w(wt.value),1)):de("",!0),Ge.value?(p(),b("p",Lf,w(a(r)("sourceBrowser.selectCodeLineHint")),1)):de("",!0)])])]),i("div",Mf,[d.value?(p(),b("div",Bf,[i("span",null,w(a(r)("sourceBrowser.previewLoading")),1)])):T.value?(p(),b("div",Rf,w(T.value),1)):k.value==="directory"?(p(),b("div",Nf,w(a(r)("sourceBrowser.selectFileHint")),1)):m.value?Ye.value?(p(),b("div",Ff,[i("img",{src:h.value.previewUrl,alt:Be.value,class:"source-browser-image object-contain"},null,8,Uf)])):bt.value?(p(),b("div",jf,[ue(a(ui),{class:"h-8 w-8"}),i("span",null,w((R=h.value)!=null&&R.tooLarge?a(r)("sourceBrowser.binaryTooLarge"):a(r)("sourceBrowser.binaryUnsupported")),1)])):Ge.value?(p(),b("div",{key:6,ref_key:"previewContainerRef",ref:A,class:"source-browser-code relative rounded-sm border",style:Nn({"--source-code-bg":it.value||"var(--theme-panel)","--source-code-fg":kt.value||"var(--theme-textPrimary)","--source-code-gutter-width":pt.value}),onCopy:Xn,onMouseup:E[1]||(E[1]=(...G)=>a(oe)&&a(oe)(...G)),onMousemove:we,onMouseleave:Ke},[i("div",Vf,[i("table",zf,[i("tbody",{innerHTML:lt.value},null,8,Hf)])]),_t.value?(p(),b("div",{key:0,class:"source-blame-popover pointer-events-none absolute z-20 w-[min(24rem,calc(100%-1.5rem))] rounded-sm border px-3 py-2 text-[11px] shadow-lg",style:Nn(Qt())},[L.value?(p(),b("div",qf,[ue(a(Gt),{class:"h-3.5 w-3.5 animate-spin"}),i("span",null,w(a(r)("sourceBrowser.blameLoading")),1)])):Ue.value?(p(),b("div",Kf,[i("div",Wf,[i("span",Gf,w(Ue.value.author||a(r)("common.notAvailable")),1),i("span",Xf,w(Ue.value.shortCommit),1),Ue.value.authorTime?(p(),b("span",Yf,w(Ot(Ue.value.authorTime)),1)):de("",!0)]),Ue.value.summary?(p(),b("div",Jf,w(Ue.value.summary),1)):de("",!0),Ue.value.authorTime?(p(),b("div",Qf,w(In(Ue.value.authorTime)),1)):de("",!0)])):(p(),b("div",Zf,w(ne.value||((J=le.value)==null?void 0:J.message)||a(r)("sourceBrowser.blameUnavailable")),1))],4)):de("",!0),e.open&&a($).visible?(p(),Ee(Sa,{key:1,top:a($).top,left:a($).left,label:a(r)("sourceBrowser.insertSelection"),onClick:an},null,8,["top","left","label"])):de("",!0)],36)):de("",!0):(p(),b("div",Of,w(a(r)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},tp=Xr(ep,[["__scopeId","data-v-5ae1fae5"]]);function np(e={}){const{items:t,themeKey:n,getCacheKey:o=v=>String((v==null?void 0:v.id)||"").trim(),getSource:s=v=>String((v==null?void 0:v.content)||""),shouldRender:r=()=>!0,renderAsync:l=async v=>v,renderFallback:u=v=>v,onRendered:m=null}=e,k=new Map,d=new Map,T=j(0),h=q(()=>(Array.isArray(t==null?void 0:t.value)?t.value:[]).map(v=>{const B=!!r(v),K=String(o(v)||"").trim(),V=B?String(s(v)||""):"";return{item:v,active:B,cacheKey:K,source:V}}));function g(v){if(T.value,!r(v))return"";const B=String(s(v)||""),K=String(o(v)||"").trim(),V=String((n==null?void 0:n.value)||"");if(!K)return u(B,v);const O=k.get(K);return(O==null?void 0:O.source)===B&&(O==null?void 0:O.theme)===V?O.html:u(B,v)}async function f(v){if(!r(v))return;const B=String(s(v)||""),K=String(o(v)||"").trim();if(!K)return;const V=String((n==null?void 0:n.value)||""),O=k.get(K);if((O==null?void 0:O.source)===B&&(O==null?void 0:O.theme)===V)return;const se=Symbol(K);d.set(K,se);try{const A=await l(B,v,{themeKey:V});if(d.get(K)!==se)return;k.set(K,{source:B,theme:V,html:A}),T.value+=1,m==null||m(v,{cacheKey:K,source:B,themeKey:V})}catch{}finally{d.get(K)===se&&d.delete(K)}}function P(v=[]){v.forEach(B=>{B!=null&&B.item&&f(B.item)})}function ee(v=[]){const B=new Set((Array.isArray(v)?v:[]).filter(V=>V==null?void 0:V.active).map(V=>String((V==null?void 0:V.cacheKey)||"").trim()).filter(Boolean));let K=!1;for(const V of k.keys())B.has(V)||(k.delete(V),K=!0);for(const V of d.keys())B.has(V)||d.delete(V);K&&(T.value+=1)}return $e(h,()=>{ee(h.value||[]),P(h.value||[])},{immediate:!0}),$e(n,()=>{P(h.value||[])}),Nt(()=>{d.clear()}),{getRenderedHtml:g}}const sp=`${cs()}/api/events/stream`,is=new Set;let qn=null,Gs=null;function Fo(){Gs&&(window.clearTimeout(Gs),Gs=null)}function ka(){qn&&(qn.close(),qn=null)}function op(e){is.forEach(t=>{try{t(e)}catch{}})}function Ta(){typeof window>"u"||typeof window.EventSource>"u"||qn||!is.size||(Fo(),qn=new window.EventSource(sp),qn.onmessage=e=>{try{const t=JSON.parse(String(e.data||"{}"));if(!(t!=null&&t.type))return;op(t)}catch{}},qn.onerror=()=>{ka(),is.size&&(Fo(),Gs=window.setTimeout(()=>{Ta()},1500))})}function rp(e){return typeof e!="function"?()=>{}:(is.add(e),Ta(),()=>{is.delete(e),!is.size&&(Fo(),ka())})}const _a=j(0),Uo=j(0),Xs=j(""),Ts=j(""),Ys=j(0),Ca=Ms({}),jo=Ms({}),Vo=Ms({}),_s=new Map;let wr=!1;const ap=new Set(["created","updated","deleted","reordered","session-linked","session-cleared"]),ip=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function Ao(e,t=""){const n=String(t||"").trim();n&&(e[n]=Math.max(0,Number(e[n])||0)+1)}function lp(e={}){const t=String(e.type||"").trim(),n=String(e.reason||"").trim();return{updatesTaskList:t==="runs.changed"||t==="tasks.changed"&&ap.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 up(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(),r=String((t==null?void 0:t.status)||"").trim();return!n||!s||n!==s||!o||o!==r?!1:ip.has(r)}function cp(e="",t={}){const n=String(e||"").trim();if(!n)return;const o=_s.get(n);o!=null&&o.size&&o.forEach(s=>{try{s(t)}catch{}})}function dp(e={}){const t=String(e.type||"").trim(),n=String(e.taskSlug||"").trim(),o=lp(e);if(t){if(t==="ready"){_a.value+=1,Xs.value="",Ts.value="",Ys.value+=1;return}if(t==="tasks.changed"){Xs.value=n,Ts.value=String(e.reason||"").trim(),o.updatesTaskList&&(Uo.value+=1),o.updatesTaskDiff&&Ao(jo,n);return}if(t==="runs.changed"){Xs.value=n,Ts.value="";const s={runId:String(e.runId||"").trim(),status:String(e.status||"").trim(),sentAt:String(e.sentAt||"").trim()},r=n&&Vo[n]||null,l=up(r,s);n&&(Vo[n]=s),o.updatesTaskList&&!l&&(Uo.value+=1),o.updatesSessions&&(Ys.value+=1),o.updatesTaskRuns&&Ao(Ca,n),o.updatesTaskDiff&&!l&&Ao(jo,n);return}if(t==="sessions.changed"){Ts.value="",o.updatesSessions&&(Ys.value+=1);return}t==="run.event"&&cp(n,{taskSlug:n,runId:String(e.runId||"").trim(),event:e.event||null})}}function Ea(){wr||typeof window>"u"||(rp(e=>{dp(e)}),wr=!0)}function fp(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(Ca[t])||0):0}function pp(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(jo[t])||0):0}function mp(e=""){const t=String(e||"").trim();return t&&Vo[t]||null}function gp(e="",t){const n=String(e||"").trim();if(!n||typeof t!="function")return()=>{};Ea();const o=_s.get(n)||new Set;return o.add(t),_s.set(n,o),()=>{const s=_s.get(n);s&&(s.delete(t),s.size||_s.delete(n))}}function Aa(){return Ea(),{readyVersion:_a,listSyncVersion:Uo,listSyncTaskSlug:Xs,listSyncReason:Ts,sessionsSyncVersion:Ys,getTaskRunSyncVersion:fp,getTaskRunChange:mp,getTaskDiffSyncVersion:pp}}const hp=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/g,vp=/\u001B\[[0-?]*[ -/]*[@-~]/g,yp=/\u001B[@-_]/g,Sp=/[\u0000-\u0008\u000B-\u001A\u001C-\u001F\u007F]/g;function wp(e=""){let t="";for(const n of String(e||"")){if(n==="\b"||n===""){t=t.slice(0,-1);continue}t+=n}return t}function fs(e=""){return wp(String(e||"")).replace(hp,"").replace(vp,"").replace(yp,"").replace(/\r\n/g,`
20
+ `).replace(/\r/g,`
21
+ `).replace(Sp,"")}function Bs(e=""){return fs(e)}function Gn(e=""){return String(e||"").replace(/^(?:[ \t]*\n)+/,"").replace(/(?:\n[ \t]*)+$/,"")}function sr(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 xp(e=""){const t=Gn(Bs(e));if(!t.trim())return null;const n=t.split(`
22
+ `),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 r=s[1].trim().toLowerCase();if(!new Set(["read","grep","glob","find","ls","dir","tree","list","path","file","command"]).has(r))return null;const u=Gn(n.slice(1).join(`
23
+ `));return{meta:{type:"meta",items:[{label:s[1].trim(),value:s[2].trim()}]},rest:u}}function bp(e="",t={}){const n=Gn(Bs(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),r=n.match(/<entries>([\s\S]*?)<\/entries>/i);if(!o&&!r)return null;const l=String((r==null?void 0:r[1])||"").split(`
24
+ `).map(k=>k.trim()).filter(Boolean).filter(k=>!/^\(\d+\s+entries?\)$/i.test(k)),{items:u,hiddenCount:m}=sr(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:u,totalCount:l.length,hiddenCount:m}}function kp(e="",t={}){const n=Gn(Bs(e));if(!n.trim())return null;const o=n.split(`
25
+ `).map(u=>u.trimEnd()),s=o.map(u=>{const m=u.match(/^\s*\[([ xX])\]\s+(.+)$/);return m?{completed:m[1].toLowerCase()==="x",text:m[2].trim()}:null}).filter(Boolean);if(!s.length||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:r,hiddenCount:l}=sr(s,t.maxItems??12);return{type:"checklist",items:r,totalCount:s.length,hiddenCount:l}}function Tp(e="",t={}){const n=Gn(Bs(e));if(!n.trim())return null;const o=n.split(`
26
+ `),s=o.map(u=>{const m=u.match(/^[-*]\s+(.+)$/);return m?m[1].trim():null}).filter(Boolean);if(s.length<2||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:r,hiddenCount:l}=sr(s,t.maxItems??12);return{type:"bullet_list",items:r,totalCount:s.length,hiddenCount:l}}function _p(e="",t={}){return{type:t.preferMarkdown?"markdown":"text",text:e}}function Cp(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}
27
+
28
+ ${n.text}`,t):(t.push(n),t)},[])}function Ep(e="",t={}){const n=String(e||"").split(/\n{2,}/).map(l=>Gn(l)).filter(l=>l.trim());if(n.length<2)return null;const o=Cp(n.flatMap(l=>or(l,{...t,_disableMixedSegmentation:!0}))),s=o.some(l=>!["text","markdown"].includes(l==null?void 0:l.type)),r=o.some(l=>["text","markdown"].includes(l==null?void 0:l.type));return s&&r?o:null}function or(e="",t={}){const n=Gn(Bs(e));if(!n.trim())return[];const o=xp(n);if(o!=null&&o.rest){const u=or(o.rest,t);return[o.meta,...u.length?u:[{type:"text",text:o.rest}]]}const s=bp(n,t);if(s)return[s];const r=kp(n,t);if(r)return[r];const l=Tp(n,t);if(l)return[l];if(!t._disableMixedSegmentation){const u=Ep(n,t);if(u!=null&&u.length)return u}return[_p(n,t)]}const Ap=new Set(["queued","starting","running","stopping"]);function Mn(){return fo()==="en-US"}function U(e,t){return Mn()?t:e}function Cs(e={}){const t=String((e==null?void 0:e.messageKey)||"").trim();if(t){const n=e!=null&&e.messageParams&&typeof e.messageParams=="object"?e.messageParams:{},o=Xe(t,n);if(o&&o!==t)return o}return String((e==null?void 0:e.message)||"").trim()}function xr(e=""){const t=Date.parse(String(e||""));return Number.isFinite(t)?t:0}function br(e=[],t=""){return[...e].sort((n,o)=>{const s=+!!(o!=null&&o.running)-+!!(n!=null&&n.running);if(s)return s;const r=+((o==null?void 0:o.id)===t)-+((n==null?void 0:n.id)===t);if(r)return r;const l=xr(o.updatedAt)-xr(n.updatedAt);return l||String(n.title||n.cwd||n.id).localeCompare(String(o.title||o.cwd||o.id),fo())})}function Ia(e="",t=24,n=2400){const o=fs(e).trim();if(!o)return"";const s=o.split(`
29
+ `);let r=s.slice(0,t).join(`
30
+ `);return r.length>n&&(r=`${r.slice(0,n).trimEnd()}...`),s.length>t?`${r}
31
+ ...`:r}function zn(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||U("未命名任务","Untitled Task")}`}).join(`
32
+ `):""}function zt(e=0){const t=Number(e||0);return Number.isFinite(t)?t.toLocaleString(fo()):"0"}function rr(e=""){return String(e||"").trim().toLowerCase()==="shell"}function Ip(e=""){return rr(e)?U("Shell","Shell"):St(e)}function $p(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 $a(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 ro(e={}){return $a(e).length}function Pa(e={}){const t=$a(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]:{},r=String(s.message||s.result||"").trim();return{id:o,status:$p(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:r,messageBlocks:r?Wn(r):[]}})}function Pp(e={},t=120){const n=Pa(e).map(o=>o.message).filter(Boolean);return Ct(n.join(Mn()?" | ":"|"),t)}function Da(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?Mn()?`${n}h ${o}m ${s}s`:`${n}小时${o}分${s}秒`:Mn()?`${o}m ${s}s`:`${o}分${s}秒`}function Ct(e="",t=140){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,t)}...`:""}function La(e="",t=[]){const n=t.filter(Boolean);if(!n.length)return"";const o=n.map(s=>`- ${s}`).join(`
33
+ `);return e?`${e}
34
+ ${o}`:o}function Is(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 Dp(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 Lp(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)||U("未命名任务","Untitled Task")}function Js(e=[]){return(Array.isArray(e)?e:[]).map(t=>{if(!t||typeof t!="object")return null;const n=Dp(t.status??(t.completed?"completed":"pending"));return{completed:n==="completed",status:n,text:Lp(t)}}).filter(Boolean)}function kr(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return Js(n);if(n&&typeof n=="object"){if(Array.isArray(n.todos))return Js(n.todos);if(Array.isArray(n.items))return Js(n.items)}}catch{return[]}return[]}function Ma(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];return t.length?{type:"checklist",items:t,totalCount:t.length,hiddenCount:0}:null}function ar(e=""){var k;const t=String(e||"").trim(),n=t.indexOf(":"),o=n>0&&n<=24,s=o?t.slice(0,n).trim():"",r=o?t.slice(n+1).trim():t,l=s.toLowerCase(),m=o?((k=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(([,d])=>d.includes(l)))==null?void 0:k[0])||"generic":"shell";return{raw:t,toolName:s,normalizedTool:l,subject:r,category:m}}function $s(e={},t=null){const n=t||ar(e.command);if(n.category!=="todo")return[];const o=kr(e.aggregated_output);return o.length?o:kr(n.subject)}function Wn(e="",t={}){return or(fs(e),t)}function Tr(e={}){const t=e.action||{},n=String(e.query||t.query||"").trim(),o=Array.isArray(t.queries)?t.queries.map(u=>String(u||"").trim()).filter(Boolean):[],s=String(t.url||"").trim(),r=[],l=Is([n?{label:U("关键词","Query"),value:n}:null,s?{label:"URL",value:s}:null]);return l&&r.push(l),o.length>1&&r.push({type:"bullet_list",items:o,totalCount:o.length,hiddenCount:0}),r}function _r(e={}){const t=String(e.tool||"").trim(),n=ro(e),o=String(e.prompt||"").trim(),s=Pa(e),r=[],l=[t?{label:U("工具","Tool"),value:t}:null,n?{label:U("子代理","Sub-agent"),value:String(n)}:null],u=Is(l);return u&&r.push(u),s.length&&r.push({type:"sub_agent_list",items:s,totalCount:s.length,hiddenCount:0}),o&&r.push(...Wn(o,{preferMarkdown:!0})),r}function Cr(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 js(e={},t=!1,n="codex"){const o=[],s=ar(e.command),r=$s(e,s),l=Ma(r),u=typeof e.exit_code=="number",m=u?e.exit_code===0:e.status==="completed",k=Is([s.toolName?{label:U("工具","Tool"),value:s.toolName}:null,l||s.category!=="shell"?null:s.subject?{label:U("命令","Command"),value:s.subject}:e.command?{label:U("命令","Command"),value:e.command}:null,n&&n!=="codex"?{label:U("引擎","Engine"),value:Ip(n)}:null,u&&!m?{label:U("退出码","Exit code"),value:String(e.exit_code)}:null]);if(k&&o.push(k),l&&o.push(l),t){if(l)return o;const d=Ia(e.aggregated_output);d&&o.push(...Wn(d,{preferMarkdown:s.category==="web"||s.category==="edit"}))}return o}function ss(e={}){const t=ar(e.command);return{groupType:["read","grep","list","web","todo"].includes(t.category)?t.category:"",groupTarget:t.subject||e.command||"",toolName:t.toolName||""}}function Io(e={}){const t=Array.isArray(e.items)?Js(e.items):[];return t.length?[Ma(t)]:[]}function ps(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function zo(e=[],t=""){const n=String(t||"").trim();return n&&(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.runId)===n)||null}function Mp(e,t,n,o,s){const r=zo(e,t);return r?(r.events=[],r.lastEventSeq=0,r.summary=ps(),((n==null?void 0:n.items)||[]).forEach(l=>{lr(r,l,o,s)}),r.eventCount=Math.max(Math.max(0,Number(r.eventCount)||0),Array.isArray(n==null?void 0:n.items)?n.items.length:0,Math.max(0,Number(r.lastEventSeq)||0)),r.eventsLoaded=!0,r.eventsLoading=!1,r):null}function Ba(e={}){const t=String((e==null?void 0:e.displayEngine)||"").trim();return t?oo(t):rr(e==null?void 0:e.engine)?"codex":oo(e==null?void 0:e.engine)}function Ht(e={}){return St(Ba(e))}function Bp(e={}){return rr(e==null?void 0:e.engine)}function Ps(e=""){return Ap.has(String(e||"").trim())}function ir(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 Er(e={},t="completed"){const n=e.action||{},o=String(n.type||"").trim(),s=String(e.query||n.query||"").trim(),r=Array.isArray(n.queries)?n.queries.map(u=>String(u||"").trim()).filter(Boolean):[],l=String(n.url||s||"").trim();return o==="search"?{kind:"command",title:t==="started"?U("正在搜索网页","Searching the web"):U("已搜索网页","Web search completed"),detail:La(s?U(`关键词:${s}`,`Query: ${s}`):"",r.length>1?r:[])}:o==="open_page"?{kind:"command",title:t==="started"?U("正在打开网页","Opening page"):U("已打开网页","Page opened"),detail:l}:{kind:"command",title:t==="started"?U("准备网页检索","Preparing web search"):U("网页检索已更新","Web search updated"),detail:s}}function Ar(e={},t="completed"){const n=String(e.tool||"").trim(),o=ro(e),s=Ct(e.prompt);return n==="spawn_agent"?{kind:"todo",title:t==="started"?U("正在启动子代理","Starting sub-agent"):U(`已启动 ${o||1} 个子代理`,`Started ${o||1} sub-agent(s)`),detail:s?U(`任务:${s}`,`Task: ${s}`):""}:n==="wait"?{kind:"todo",title:t==="started"?o?U(`等待 ${o} 个子代理返回结果`,`Waiting for ${o} sub-agent result(s)`):U("等待子代理返回结果","Waiting for sub-agent results"):U("子代理结果已汇总","Sub-agent results aggregated"),detail:s?U(`等待内容:${s}`,`Waiting on: ${s}`):""}:{kind:"todo",title:t==="started"?U(`正在执行协作工具:${n||"未知工具"}`,`Running collaboration tool: ${n||"Unknown tool"}`):U(`协作工具完成:${n||"未知工具"}`,`Collaboration tool completed: ${n||"Unknown tool"}`),detail:s?U(`任务:${s}`,`Task: ${s}`):""}}function Ir(e={},t="completed"){const n=Array.isArray(e.changes)?e.changes:[],o={create:U("新增","Added"),update:U("更新","Updated"),delete:U("删除","Deleted")};return{kind:"command",title:t==="started"?U("正在整理文件变更","Collecting file changes"):U(`已记录 ${n.length||0} 个文件改动`,`Recorded ${n.length||0} file change(s)`),detail:La("",n.map(s=>{const r=String((s==null?void 0:s.path)||"").trim();return`${o[String((s==null?void 0:s.kind)||"").trim()]||U("变更","Changed")} ${r||U("未命名文件","Unnamed file")}`}))}}function Rp(e,t={}){var l,u,m,k,d,T,h,g;e!=null&&e.summary||(e.summary=ps());const n=e.summary,o=Ht(e),s=String(t.type||"").trim(),r=t.item||{};if(s===$t.TURN_STARTED){n.currentActivity=U("正在分析任务","Analyzing task"),n.latestActivity=U(`${o} 开始执行`,`${o} started`),n.latestDetail="";return}if(s===$t.TURN_COMPLETED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=U(`${o} 执行完成`,`${o} completed`),n.latestDetail="";return}if(s===$t.TURN_FAILED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=U("本轮运行失败","This run failed"),n.latestDetail="";return}if(s===$t.ERROR){const f=ir(Ds(t));if(f){n.currentActivity=U(`网络异常,正在重试 (${f.attempt}/${f.total})`,`Network error, retrying (${f.attempt}/${f.total})`),n.latestActivity=n.currentActivity,n.latestDetail=Ct(f.reason,120);return}n.currentActivity="",n.latestActivity=U(`${o} 返回错误`,`${o} returned an error`),n.latestDetail=Ct(Ds(t),120);return}if(s===$t.ITEM_STARTED){if(r.type===mt.REASONING){n.currentActivity=U("正在思考","Thinking"),n.latestActivity=U("正在思考","Thinking"),n.latestDetail=Ct(r.text,120);return}if(r.type===mt.COMMAND_EXECUTION){if(ss(r).groupType==="todo"){const P=zn($s(r));n.currentActivity=U("正在更新待办列表","Updating todo list"),n.latestActivity=U("正在更新待办列表","Updating todo list"),n.latestDetail=Ct(P,120);return}n.currentActivity=U("正在执行命令","Running command"),n.latestActivity=U("开始执行命令","Command started"),n.latestDetail=Ct(r.command,120);return}if(r.type===mt.WEB_SEARCH){n.currentActivity=((l=r.action)==null?void 0:l.type)==="open_page"?U("正在打开网页","Opening page"):U("正在搜索网页","Searching the web"),n.latestActivity=n.currentActivity,n.latestDetail=Ct(((u=r.action)==null?void 0:u.type)==="open_page"?((m=r.action)==null?void 0:m.url)||r.query:r.query||((k=r.action)==null?void 0:k.query),120);return}if(r.type===mt.COLLAB_TOOL_CALL){if(r.tool==="wait"){const f=ro(r);n.waitingAgentCount=f,n.currentActivity=f?U(`等待 ${f} 个子代理返回结果`,`Waiting for ${f} sub-agent result(s)`):U("等待子代理返回结果","Waiting for sub-agent results"),n.latestActivity=n.currentActivity,n.latestDetail=Ct(r.prompt,120);return}if(r.tool==="spawn_agent"){n.currentActivity=U("正在启动子代理","Starting sub-agent"),n.latestActivity=U("正在启动子代理","Starting sub-agent"),n.latestDetail=Ct(r.prompt,120);return}}if(r.type===mt.FILE_CHANGE){n.currentActivity=U("正在整理文件变更","Collecting file changes"),n.latestActivity=U("正在整理文件变更","Collecting file changes"),n.latestDetail=Ct((r.changes||[]).map(f=>f==null?void 0:f.path).filter(Boolean).join(Mn()?", ":","),120);return}r.type===mt.TODO_LIST&&(n.currentActivity=U("正在规划执行步骤","Planning steps"),n.latestActivity=U("正在规划执行步骤","Planning steps"),n.latestDetail=Ct((r.items||[]).map(f=>f==null?void 0:f.text).filter(Boolean).join(Mn()?"; ":";"),120));return}if(s===$t.ITEM_COMPLETED){if(r.type===mt.COMMAND_EXECUTION){if(ss(r).groupType==="todo"){n.currentActivity="",n.latestActivity=U("待办列表已更新","Todo list updated"),n.latestDetail=Ct(zn($s(r)),120);return}n.commandCount+=1,n.currentActivity="",n.latestActivity=U("命令执行完成","Command completed"),n.latestDetail=Ct(r.command,120);return}if(r.type===mt.WEB_SEARCH){n.webSearchCount+=1,n.currentActivity="",n.latestActivity=((d=r.action)==null?void 0:d.type)==="open_page"?U("已打开网页","Page opened"):U("已搜索网页","Web search completed"),n.latestDetail=Ct(((T=r.action)==null?void 0:T.type)==="open_page"?((h=r.action)==null?void 0:h.url)||r.query:r.query||((g=r.action)==null?void 0:g.query),120);return}if(r.type===mt.COLLAB_TOOL_CALL){if(r.tool==="spawn_agent"){const f=ro(r);n.subAgentCount+=f,n.currentActivity="",n.latestActivity=f?U(`已启动 ${f} 个子代理`,`Started ${f} sub-agent(s)`):U("已启动子代理","Started sub-agent"),n.latestDetail=Ct(r.prompt,120);return}if(r.tool==="wait"){n.waitingAgentCount=0,n.currentActivity="",n.latestActivity=U("子代理结果已汇总","Sub-agent results aggregated"),n.latestDetail=Pp(r,120)||Ct(r.prompt,120);return}n.currentActivity="",n.latestActivity=U(`协作工具完成:${r.tool||"未知工具"}`,`Collaboration tool completed: ${r.tool||"Unknown tool"}`),n.latestDetail=Ct(r.prompt,120);return}if(r.type===mt.FILE_CHANGE){const f=Array.isArray(r.changes)?r.changes:[];n.fileChangeCount+=f.length,n.currentActivity="",n.latestActivity=f.length?U(`已记录 ${f.length} 个文件改动`,`Recorded ${f.length} file change(s)`):U("已记录文件改动","Recorded file changes"),n.latestDetail=Ct(f.map(P=>P==null?void 0:P.path).filter(Boolean).join(Mn()?", ":","),120);return}if(r.type===mt.TODO_LIST){n.currentActivity="",n.latestActivity=U("待办列表已更新","Todo list updated"),n.latestDetail=Ct((r.items||[]).map(f=>f==null?void 0:f.text).filter(Boolean).join(Mn()?"; ":";"),120);return}r.type===mt.AGENT_MESSAGE&&(n.currentActivity="",n.latestActivity=U(`${o} 已返回结果`,`${o} returned a result`),n.latestDetail=Ct(r.text,120))}}function Np(e={},t={}){const n=Date.parse(String(e.startedAt||""));if(!Number.isFinite(n))return 0;if(Ps(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 Ra(e={},t={}){const n=e.summary||ps(),o=[],s=Np(e,t);return s>0&&o.push({key:"elapsed",label:U("耗时","Elapsed"),value:Da(s)}),n.webSearchCount&&o.push({key:"web",label:U("网页","Web"),value:zt(n.webSearchCount)}),n.commandCount&&o.push({key:"command",label:U("命令","Command"),value:zt(n.commandCount)}),n.fileChangeCount&&o.push({key:"file",label:U("改动","Changes"),value:zt(n.fileChangeCount)}),n.subAgentCount&&o.push({key:"agent",label:U("子代理","Sub-agent"),value:zt(n.subAgentCount)}),o}function Na(e={}){const t=e.summary||ps();return t.waitingAgentCount>0?U(`当前:等待 ${zt(t.waitingAgentCount)} 个子代理返回结果`,`Current: waiting for ${zt(t.waitingAgentCount)} sub-agent result(s)`):t.currentActivity?U(`当前:${t.currentActivity}`,`Current: ${t.currentActivity}`):t.latestActivity?U(`最近:${t.latestActivity}`,`Latest: ${t.latestActivity}`):Ps(e.status)?U(`当前:正在等待 ${Ht(e)} 返回更多事件`,`Current: waiting for more events from ${Ht(e)}`):""}function Oa(e={}){const t=e.summary||ps();return String(t.latestDetail||"").trim()}function Op(e={}){return!!(Ra(e).length||Na(e)||Oa(e))}const Fp=[{type:"startup_config",title:e=>U(`${St(e)} 启动配置冲突`,`${St(e)} startup config conflict`),summary:e=>U(`${St(e)} 当前启动参数可能与本机包装脚本、别名或外部环境配置冲突,请检查 CLI 启动方式。`,`${St(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:U("额度或账单异常","Quota or billing issue"),summary:e=>U(`${St(e)} 可能因为额度不足、欠费或账单限制而无法继续执行。`,`${St(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:U("权限不足","Insufficient permissions"),summary:e=>U(`${St(e)} 当前权限不够,无法访问所需文件、命令或资源。`,`${St(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:U("请求过于频繁","Too many requests"),summary:e=>U(`${St(e)} 可能触发了限流,请稍后再试。`,`${St(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:U("上下文过长","Context too long"),summary:U("这次发送的内容可能过长,超过了模型可处理的上下文限制。","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:U("模型或服务暂不可用","Model or service unavailable"),summary:e=>U(`${St(e)} 背后的模型或服务当前不可用,请稍后重试。`,`The model or service behind ${St(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:U("网络连接异常","Network connection issue"),summary:e=>U(`${St(e)} 在请求过程中遇到了网络问题或连接超时。`,`${St(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=>U(`${St(e)} CLI 不可用`,`${St(e)} CLI unavailable`),summary:e=>U(`当前环境没有正确安装或配置 ${St(e)} CLI。`,`${St(e)} CLI is not correctly installed or configured in the current environment.`),patterns:[/找不到 Codex CLI/,/找不到 Claude Code CLI/,/找不到 OpenCode CLI/,/找不到 Kimi Code CLI/,/codex --version/i,/claude --version/i,/opencode --version/i,/kimi --version/i,/enoent/i,/not recognized as an internal or external command/i,/command not found/i]}];function ds(e="",t="codex"){const n=fs(e).trim();if(!n)return null;const o=Fp.find(s=>s.patterns.some(r=>r.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 bn(e="",t="codex"){const n=fs(e).trim();if(!n)return"";const o=ds(n,t);return o?`${o.summary}
35
+
36
+ ${U("原始错误","Raw error")}: ${o.rawMessage}`:n}function Ho(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return fs(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=Ho(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=Ho(o,t+1);if(s)return s}return""}function Ds(e={}){return Ho(e)}function Up(e={},t="Codex",n="codex"){var r,l,u,m;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:U(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===$t.THREAD_STARTED){const k=e.thread_id?U(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:U(`${t} 会话已创建`,`${t} session created`),detail:k,detailBlocks:k?[Is([{label:"ID",value:e.thread_id}])]:[]}}if(o===$t.TURN_STARTED)return{title:U(`${t} 开始执行`,`${t} started`),detail:""};if(o===$t.TURN_COMPLETED){const k=e.usage?[U(`输入 ${zt(e.usage.input_tokens)}`,`Input ${zt(e.usage.input_tokens)}`),e.usage.cached_input_tokens?U(`缓存 ${zt(e.usage.cached_input_tokens)}`,`Cached ${zt(e.usage.cached_input_tokens)}`):"",U(`输出 ${zt(e.usage.output_tokens)}`,`Output ${zt(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:U(`${t} 执行完成`,`${t} completed`),detail:k,detailBlocks:e.usage?[Is([{label:U("输入","Input"),value:zt(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:U("缓存","Cached"),value:zt(e.usage.cached_input_tokens)}:null,{label:U("输出","Output"),value:zt(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===$t.ERROR||o===$t.TURN_FAILED){const k=Ds(e)||U(`${t} 执行失败`,`${t} failed`),d=o===$t.ERROR?ir(k):null;if(d)return{kind:"info",title:U(`网络异常,正在重试 (${d.attempt}/${d.total})`,`Network error, retrying (${d.attempt}/${d.total})`),detail:bn(d.reason||d.rawMessage,n),detailBlocks:Wn(bn(d.reason||d.rawMessage,n),{preferMarkdown:!0})};const T=ds(k,n);return{kind:"error",title:(T==null?void 0:T.title)||(o===$t.TURN_FAILED?U("本轮运行失败","This run failed"):U(`${t} 返回错误`,`${t} returned an error`)),detail:bn(k,n),detailBlocks:Wn(bn(k,n),{preferMarkdown:!0})}}if(o===$t.ITEM_STARTED)return s.type===mt.REASONING?{kind:"reasoning",title:U("思考过程","Thinking"),detail:s.text||"",detailBlocks:Wn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===mt.WEB_SEARCH?{...Er(s,"started"),detailBlocks:Tr(s),groupType:"web",groupTarget:String(s.query||((r=s.action)==null?void 0:r.query)||((l=s.action)==null?void 0:l.url)||"").trim(),phase:"started"}:s.type===mt.COLLAB_TOOL_CALL?{...Ar(s,"started"),detailBlocks:_r(s)}:s.type===mt.FILE_CHANGE?{...Ir(s,"started"),detailBlocks:Cr(s)}:s.type===mt.COMMAND_EXECUTION?ss(s).groupType==="todo"?{kind:"todo",title:U("更新待办列表","Update todo list"),detail:zn($s(s)),detailBlocks:js(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:U("开始执行命令","Command started"),detail:s.command||"",detailBlocks:js(s,!1,n),...ss(s),phase:"started"}:s.type===mt.TODO_LIST?{kind:"todo",title:U("更新待办列表","Update todo list"),detail:zn(s.items),detailBlocks:Io(s),groupType:"todo",phase:"started"}:{title:U(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===$t.ITEM_UPDATED&&s.type===mt.TODO_LIST)return{kind:"todo",title:U("更新待办列表","Update todo list"),detail:zn(s.items),detailBlocks:Io(s),groupType:"todo",phase:"updated"};if(o===$t.ITEM_COMPLETED){if(s.type===mt.AGENT_MESSAGE&&s.text)return{kind:"result",title:U(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===mt.WEB_SEARCH)return{...Er(s,"completed"),detailBlocks:Tr(s),groupType:"web",groupTarget:String(s.query||((u=s.action)==null?void 0:u.query)||((m=s.action)==null?void 0:m.url)||"").trim(),phase:"completed"};if(s.type===mt.COLLAB_TOOL_CALL)return{...Ar(s,"completed"),detailBlocks:_r(s)};if(s.type===mt.FILE_CHANGE)return{...Ir(s,"completed"),detailBlocks:Cr(s)};if(s.type===mt.COMMAND_EXECUTION){if(ss(s).groupType==="todo"){const T=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:T?"todo":"error",title:T?U("更新待办列表","Update todo list"):U("更新待办列表失败","Todo list update failed"),detail:zn($s(s)),detailBlocks:js(s,!0,n),groupType:"todo",phase:"completed"}}const d=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:d?"command":"error",title:d?U("命令执行完成","Command completed"):U(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,Ia(s.aggregated_output)].filter(Boolean).join(`
37
+
38
+ `),detailBlocks:js(s,!0,n),...ss(s),phase:"completed"}}return s.type===mt.TODO_LIST?{kind:"todo",title:U("更新待办列表","Update todo list"),detail:zn(s.items),detailBlocks:Io(s),groupType:"todo",phase:"completed"}:{title:U(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:U(`事件: ${o}`,`Event: ${o}`),detail:""}}function jp(e){return e.status==="queued"?U("排队中","Queued"):e.status==="starting"?U("启动中","Starting"):e.status==="stopping"?U("停止中","Stopping"):e.status==="running"?U("进行中","Running"):e.status==="error"?U("失败","Failed"):e.status==="interrupted"?U("已中断","Interrupted"):e.status==="stopped"?U("已停止","Stopped"):e.status==="stop_timeout"?U("停止超时","Stop timeout"):U("已完成","Completed")}function Fa(e={},t){if(typeof e=="string"){const r=e.trim();return r?{id:t(),kind:"info",title:r,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?Wn(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 Vp(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"?Ks(o.content):o.content})):[];return{id:t(),runId:String(e.id||"").trim(),engine:String(e.engine||"").trim(),displayEngine:String(e.displayEngine||"").trim(),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:ps()}}function Vn(e,t,n){const o=Fa(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function zp(e,t,n){var s;const o=Fa(t,n);if(o){for(let r=e.events.length-1;r>=0;r-=1){const l=U("网络异常,正在重试","Network error, retrying");if(String(((s=e.events[r])==null?void 0:s.title)||"").startsWith(l)){e.events.splice(r,1,o);return}}e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120)}}function Hp(e,t={},n,o=()=>{}){var r,l,u,m,k,d,T,h,g;const s=ra(t.type);if(s===nn.SESSION){o(t.session);return}if(s===nn.SESSION_UPDATED){o(t.session);return}if(s===nn.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;Vn(e,{title:Cs(t)||U("状态已更新","Status updated"),detail:""},n);return}if(s===nn.STDERR){const f=ds(t.text,e.engine);Vn(e,{kind:"error",title:(f==null?void 0:f.title)||"stderr",detail:bn(t.text,e.engine)},n);return}if(s===nn.STDOUT){Vn(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===nn.AGENT_EVENT){if(Rp(e,t.event),((r=t.event)==null?void 0:r.type)===$t.THREAD_STARTED)return;const f=Up(t.event,Ht(e),e.engine);String(f.title||"").startsWith(U("网络异常,正在重试","Network error, retrying"))?zp(e,f,n):Vn(e,f,n),((l=t.event)==null?void 0:l.type)===$t.ITEM_COMPLETED&&((m=(u=t.event)==null?void 0:u.item)==null?void 0:m.type)===mt.AGENT_MESSAGE&&((d=(k=t.event)==null?void 0:k.item)!=null&&d.text)&&(e.responseMessage=t.event.item.text);const P=Ds(t.event)||U(`${Ht(e)} 执行失败`,`${Ht(e)} failed`);if(!(((T=t.event)==null?void 0:T.type)==="error"?ir(P):null)&&(((h=t.event)==null?void 0:h.type)===$t.ERROR||((g=t.event)==null?void 0:g.type)===$t.TURN_FAILED)){const v=Ds(t.event)||U(`${Ht(e)} 执行失败`,`${Ht(e)} failed`);e.errorMessage=bn(v,e.engine),e.status="error"}return}if(s===nn.COMPLETED){Vn(e,{kind:"result",title:U("本轮执行结束","Run finished"),detail:""},n);const f=Cs(t);f&&(e.responseMessage=f);return}if(s===nn.STOPPED){Vn(e,{title:Cs(t)||U("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===nn.ERROR){const f=Cs(t),P=ds(f,e.engine);Vn(e,{kind:"error",title:(P==null?void 0:P.title)||U("执行失败","Execution failed"),detail:bn(f||U(`${Ht(e)} 执行失败`,`${Ht(e)} failed`),e.engine)},n)}}function qp(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 r=ds(o,n),l=ds(s,n);return!r&&!!l}function Kp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=bn(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=qp(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=U(`本轮 ${Ht(e)} 执行已完成,没有返回额外文本。`,`${Ht(e)} completed in this run without returning additional text.`)),e}function lr(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 r=(t==null?void 0:t.payload)||{};Hp(e,r,n,o);const l=ra(r.type);return l===nn.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===nn.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===nn.ERROR&&(e.status="error",e.errorMessage=bn(String(Cs(r)||e.errorMessage||U(`${Ht(e)} 执行失败`,`${Ht(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 $r(e,t,n,o){const s=Vp(e,t);return(e.events||[]).forEach(r=>{lr(s,r,n,o)}),Kp(s,e)}const Wp=1800,Pr=7200,Gp=15e3,$o={clearTaskCodexRuns:jl,listCodexRunEvents:Fl,listTaskCodexRuns:Ol};function Es(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 Xp(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>Es(o,t)))}function Yp(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function Jp(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:r,currentRunningRunId:l,sessionError:u,supportsServerEvents:m,scheduleScrollToBottom:k,resetAutoStickToBottom:d,mergeSessionRecord:T,mergeSession:h,loadSessions:g,showProcessLogs:f}=e;let P=0,ee=0,v=null,B="",K=null,V=null,O="",se=!!(f!=null&&f.value),A=0;const X=new Map;function ge(){return P+=1,P}function Se(){return ee+=1,ee}function L(){K&&(window.clearInterval(K),K=null)}function ne(){V&&(window.clearInterval(V),V=null)}function le(){A=Date.now()}function te(){X.clear(),n.value=[],s.value=!1,r.value=0,l.value="",O="",B="",P=0,ee=0,d()}function ye(){const H=[...n.value].reverse().find(Z=>Ps(Z.status))||null;if(l.value=(H==null?void 0:H.runId)||"",s.value=!!H,H!=null&&H.startedAt){const Z=Date.parse(String(H.startedAt||""));r.value=Number.isFinite(Z)?Z:Date.now();return}r.value=0}function C(H=null){return H?{...H}:Yp()}function W(H,Z=null){if(!(Z!=null&&Z.runId)||H.eventsLoaded||!Z.eventsLoaded)return X.has(H.runId)&&(H.eventsLoading=!0),H;const me=Math.max(Math.max(0,Number(Z.lastEventSeq)||0),Math.max(0,Number(Z.eventCount)||0),Array.isArray(Z.events)?Z.events.length:0),Ce=Math.max(0,Number(H.eventCount)||0);return me<Ce?(X.has(H.runId)&&(H.eventsLoading=!0),H):(H.events=Array.isArray(Z.events)?[...Z.events]:[],H.eventCount=Math.max(Math.max(0,Number(H.eventCount)||0),Math.max(0,Number(Z.eventCount)||0),H.events.length),H.eventsLoaded=!0,H.eventsLoading=X.has(H.runId),H.lastEventSeq=Math.max(0,Number(Z.lastEventSeq)||0),H.summary=C(Z.summary),H)}function D(H,Z){const me=zo(n.value,H);return me?(me.eventsLoading=!!Z,n.value=[...n.value],me):null}async function Ae(H,Z={}){const me=String((H==null?void 0:H.runId)||"").trim(),{force:Ce=!1}=Z;if(!me)return[];const fe=zo(n.value,me)||H;if(fe!=null&&fe.eventsLoaded&&!Ce)return fe.events;if(X.has(me))return X.get(me);D(me,!0);const Me=(async()=>{var he;try{const Be=Es(fe,!!(f!=null&&f.value)),ze=await $o.listCodexRunEvents(me,{limit:5e3}),Le=Mp(n.value,me,ze,Se,Ye=>{h(Ye,{preserveRunning:!0})});if(!Le)return Array.isArray(fe==null?void 0:fe.events)?fe.events:[];const wt=JSON.stringify(Be)!==JSON.stringify(Es(Le,!!(f!=null&&f.value)));return n.value=[...n.value],wt&&t.active&&((he=n.value.at(-1))==null?void 0:he.runId)===me&&k(),Le.events}catch(Be){throw u.value=Be.message,Be}finally{D(me,!1),X.delete(me)}})();return X.set(me,Me),Me}function Pe(H,Z){const me=String(H||"").trim();if(!me||!Z)return!1;const Ce=n.value.findIndex(ze=>ze.runId===me);if(Ce<0)return!1;const fe=n.value[Ce],Me=Es(fe,!!(f!=null&&f.value));if(!lr(fe,Z,Se,ze=>{h(ze,{preserveRunning:!0})}))return!0;const Be=JSON.stringify(Me)!==JSON.stringify(Es(fe,!!(f!=null&&f.value)));return n.value=[...n.value],ye(),Be&&k(),!0}function Ne(){if(L(),ne(),!(!t.active||!s.value||!t.taskSlug)){if(m){V=window.setInterval(()=>{Qe({force:!0}).catch(()=>{});const H=Date.now();H-A<Pr||(A=H,g({force:!0}).catch(()=>{}))},Gp);return}K=window.setInterval(()=>{Qe({force:!0}).catch(()=>{});const H=Date.now();H-A<Pr||(A=H,g({force:!0}).catch(()=>{}))},Wp)}}function Je(H=[]){const Z=[...o.value],me=new Map(n.value.filter(fe=>String((fe==null?void 0:fe.runId)||"").trim()).map(fe=>[String(fe.runId||"").trim(),fe])),Ce=fe=>{if(!(fe!=null&&fe.id))return;const Me=Z.findIndex(he=>he.id===fe.id);Me>=0?Z[Me]=T(Z[Me],fe,{preserveRunning:!0}):Z.unshift(T(null,fe,{preserveRunning:!0}))};P=0,ee=0,n.value=[...H||[]].reverse().map(fe=>{const Me=$r(fe,ge,Se,Ce);return W(Me,me.get(String((fe==null?void 0:fe.id)||"").trim())||null)}),o.value=Z,ye()}async function Qe(H={}){const{force:Z=!1,scrollToLatest:me=!1}=H,Ce=String(t.taskSlug||"").trim();if(!(!Ce||!t.active&&!Z))return v&&B===Ce||v&&!Z||(B=Ce,v=(async()=>{try{const Me=(await $o.listTaskCodexRuns(Ce,{limit:30,events:"latest"})).items||[],he=!!(f!=null&&f.value),Be=Xp(Me,he),ze=me||O&&se===he&&Be!==O;Je(Me),O=Be,se=he,Ne();const Le=n.value.at(-1)||null;if(Le!=null&&Le.runId&&!Le.eventsLoaded){const wt=Le.runId;Ae(Le).catch(()=>{}).finally(()=>{var Ye;me&&t.active&&((Ye=n.value.at(-1))==null?void 0:Ye.runId)===wt&&k({force:!0})})}ze&&k({force:me})}catch(fe){u.value=fe.message}finally{v=null,B=""}})()),v}function We(H={}){const Z=(H==null?void 0:H.run)||null,me=(H==null?void 0:H.session)||null;if(me&&h(me,{preserveRunning:!0}),!(Z!=null&&Z.id)){ye(),k({force:!0});return}const fe=$r(Z,ge,Se,he=>{h(he,{preserveRunning:!0})}),Me=n.value.findIndex(he=>he.runId===fe.runId);if(Me>=0){const he=[...n.value];he.splice(Me,1,fe),n.value=he}else n.value=[...n.value,fe];ye(),k({force:!0})}async function be(){if(!(!t.taskSlug||s.value))try{await $o.clearTaskCodexRuns(t.taskSlug),te(),k({force:!0})}catch(H){u.value=H.message}}return{applyCreatedRun:We,applyIncomingRunEvent:Pe,clearRealtimeReconcileTimer:ne,clearRunPollTimer:L,clearTurns:be,loadTurnEvents:Ae,markFallbackSessionPollNow:le,refreshRunHistory:Qe,resetRunHistoryState:te,syncRunningStateFromTurns:ye,updatePollingState:Ne}}const Qp=1500,Zp=3e4;function em(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:r,sending:l,stopping:u,sessionError:m,showManager:k,selectedSessionId:d,currentRunningRunId:T,supportsServerEvents:h,mergeSession:g,applyCreatedRun:f,refreshRunHistory:P,markFallbackSessionPollNow:ee,showToast:v,getActiveAgentBinding:B=null}=e;let K=null,V=null,O=0,se=0;const A=q(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),X=q(()=>n.value.length>0),ge=q(()=>br(n.value,d.value)),Se=q(()=>X.value?"":Xe("projectManager.noProjects"));async function L(be={}){const{force:H=!1}=be;if(K)return K;const Z=Date.now();return!H&&O&&Z-O<Qp?{items:n.value,workspaces:o.value}:(K=(async()=>{s.value=!0,m.value="";try{const Ce=(await Cl()).items||[];return n.value=Ce,O=Date.now(),{items:Ce,workspaces:o.value}}catch(me){throw m.value=me.message,me}finally{s.value=!1,K=null}})(),K)}async function ne(be={}){const{force:H=!1}=be;if(V)return V;const Z=Date.now();return!H&&se&&Z-se<Zp?{items:o.value}:(V=(async()=>{try{const me=await El();return o.value=me.items||[],se=Date.now(),{items:o.value}}finally{V=null}})(),V)}async function le(be={}){const{forceSessions:H=!1,forceWorkspaces:Z=!1}=be,[me,Ce]=await Promise.all([L({force:H}),ne({force:Z})]);return{items:(me==null?void 0:me.items)||n.value,workspaces:(Ce==null?void 0:Ce.items)||o.value}}function te(be=""){const H=String(be||"").trim();!H||o.value.includes(H)||(o.value=[H,...o.value])}function ye(){k.value=!0,ne().catch(()=>{})}function C(){k.value=!1}function W(be){const H=String(be||"").trim();if(t.sessionSelectionLocked&&H&&H!==d.value){m.value=t.sessionSelectionLockReason||Xe("taskActions.sessionLocked");return}d.value=H}function D(){le({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function Ae(be){r.value=!0,m.value="";try{const H=await Al(be);return g(H),te(H.cwd),d.value=H.id,H}catch(H){throw m.value=H.message,H}finally{r.value=!1}}async function Pe(be,H){r.value=!0,m.value="";try{const Z=await Il(be,H);return g(Z),te(Z.cwd),Z}catch(Z){throw m.value=Z.message,Z}finally{r.value=!1}}async function Ne(be){var Z;const H=String(be||"").trim();if(!H)return{deletedSessionId:"",selectedSessionId:d.value};r.value=!0,m.value="";try{await $l(H);const me=n.value.filter(fe=>fe.id!==H);n.value=me;let Ce=d.value;return d.value===H&&(Ce=((Z=br(me,"")[0])==null?void 0:Z.id)||"",d.value=Ce),{deletedSessionId:H,selectedSessionId:Ce}}catch(me){throw m.value=me.message,me}finally{r.value=!1}}async function Je(be){const H=String(be||"").trim();if(!H)return null;r.value=!0,m.value="";try{const Z=await Pl(H);return Z!=null&&Z.session&&g(Z.session),ee(),await Promise.all([P({force:!0}),L({force:!0})]),v==null||v({message:Xe("projectManager.sessionReset"),type:"success"}),Z}catch(Z){throw m.value=Z.message,Z}finally{r.value=!1}}async function Qe(){if(!t.taskSlug||!A.value||l.value||u.value)return!1;if(!d.value){const be=Xe("projectManager.selectProject");return m.value=be,v==null||v({message:be,type:"warning"}),!1}m.value="";try{await le({forceSessions:!0});const be=n.value.find(Le=>Le.id===d.value)||null;if(!be)return m.value=Xe("projectManager.projectMissing"),!1;if(be.running)return m.value=Xe("sessionTurns.currentProjectRunning"),!1;const H=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,Z=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],me=Ri({prompt:H,promptBlocks:Z});if(me.reason){const Le=me.reason==="unsupported_blocks"?Xe("sessionPanel.shellUnsupportedBlocks"):Xe("sessionPanel.shellEmptyCommand");return m.value=Le,v==null||v({message:Le,type:"warning"}),!1}if(!String(H||"").trim())return m.value=Xe("sessionTurns.noPromptToSend"),!1;const Ce=tm(be),fe=typeof B=="function"?B(be):null,Me=String((fe==null?void 0:fe.engine)||"").trim();if(Me&&!Ce.some(Le=>Le.engine===Me)){const Le=Xe("sessionPanel.agentNotEnabled");return m.value=Le,v==null||v({message:Le,type:"warning"}),!1}const he=fe,Be=String(me.mode==="shell"?d.value:(he==null?void 0:he.sessionRecordId)||d.value).trim(),ze=await Ul(t.taskSlug,{projectSessionId:d.value,sessionId:Be,displayEngine:Me,prompt:me.mode==="shell"?me.prompt:H,promptBlocks:Z,commandMode:me.mode,command:me.command});return f(ze),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Le=>{console.error("[promptx] afterSend failed",Le)}),h||(ee(),Promise.all([P({force:!0}),L({force:!0})]).catch(Le=>{m.value=Le.message})),!0}catch(be){return m.value=be.message,!1}}async function We(){if(!(!T.value||u.value))try{u.value=!0,await Vl(T.value),h||(ee(),await Promise.all([P({force:!0}),L({force:!0})]))}catch(be){u.value=!1,m.value=be.message}}return{closeManager:C,handleCreateSession:Ae,handleDeleteSession:Ne,handleResetSession:Je,handleSelectSession:W,handleSend:Qe,handleUpdateSession:Pe,hasPrompt:A,helperText:Se,loadSessions:L,loadSessionResources:le,loadWorkspaces:ne,openManager:ye,refreshSessionsForSelection:D,sortedSessions:ge,stopSending:We}}function tm(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:nm(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function nm(e=""){const t=String(e||"").trim().toLowerCase();return t==="claude"||t==="claudecode"?"claude-code":t==="opencode"||t==="open-code"?"opencode":t==="kimi"||t==="kimicode"||t==="kimi-code"?"kimi-code":t==="claude-code"?"claude-code":"codex"}const sm=1200,om=[0,80,220,500,900];function rm(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,r=[],l=!1,u=!1,m=0,k=!0,d=0,T=[],h=0,g=null;function f(){const D=typeof window<"u"?window:globalThis;return typeof(D==null?void 0:D.setTimeout)!="function"||typeof(D==null?void 0:D.clearTimeout)!="function"?null:{setTimeout:D.setTimeout.bind(D),clearTimeout:D.clearTimeout.bind(D)}}function P(){if(typeof window>"u"||!r.length){r=[];return}r.forEach(D=>{window.cancelAnimationFrame(D)}),r=[]}function ee(){s+=1,P()}function v(){const D=f();if(!D){T=[],h=0;return}T.forEach(Ae=>{D.clearTimeout(Ae)}),T=[],h&&(D.clearTimeout(h),h=0)}function B(){var D;(D=g==null?void 0:g.disconnect)==null||D.call(g),g=null}function K(){return d>Date.now()}function V(D){u=!!D,(n==null?void 0:n.value)!==void 0&&(n.value=u)}function O(){l=!1,m+=1,k=!0,V(!1)}function se(D=t==null?void 0:t.value){return D?D.scrollHeight-D.scrollTop-D.clientHeight<=o:!0}function A(){return K()||k&&!l}function X(){k&&!l&&V(!1)}function ge(){if(k=se(),!k){ee();return}X()}function Se(){m+=1,l=!0,d=0,v(),B(),ee()}function L(){const D=m+1;m=D,dt(()=>{D===m&&requestAnimationFrame(()=>{D===m&&(l=!1,k=se(),X())})})}function ne(){l=!0,d=0,v(),B(),ee()}function le(){L()}function te(D={}){const{force:Ae=!1}=D;Ae&&O(),ee();const Pe=s;dt(()=>{if(!(t==null?void 0:t.value)||Pe!==s)return;if(!Ae&&!A()){V(!0);return}const Je=()=>{const We=t==null?void 0:t.value;!We||Pe!==s||(We.scrollTop=We.scrollHeight,k=!0,V(!1))};Je(),r=[requestAnimationFrame(()=>{Je(),r=[requestAnimationFrame(Je)]})]})}function ye(){te({force:!0})}function C(D={}){const Ae=Number(D.durationMs),Pe=Math.max(0,Number.isFinite(Ae)?Ae:sm),Ne=f();O(),d=Date.now()+Pe,v(),B(),Ne&&(T=om.map(Je=>Ne.setTimeout(()=>{K()&&te({force:!0})},Je)),h=Ne.setTimeout(()=>{d=0,h=0,v(),B()},Pe+40)),typeof window<"u"&&typeof window.ResizeObserver=="function"&&(g=new window.ResizeObserver(()=>{K()&&te({force:!0})}),t!=null&&t.value&&g.observe(t.value)),te({force:!0})}function W(){m+=1,d=0,v(),B(),ee()}return{cancelScheduledScrollToBottom:ee,destroy:W,handleTranscriptScroll:ge,handleTranscriptTouchEnd:le,handleTranscriptTouchMove:ne,handleTranscriptTouchStart:Se,beginForceFollowWindow:C,isTranscriptNearBottom:se,resetAutoStickToBottom:O,scheduleScrollToBottom:te,scrollToBottom:ye}}const am=150,Ua="promptx:session-panel:show-process";function im(e){return!(e==="0"||e==="false")}function lm(){if(typeof window>"u")return!0;try{return im(window.localStorage.getItem(Ua))}catch{return!0}}function um(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 cm(e,t){const n=Aa(),o=j([]),s=j([]),r=j(!1),l=j(!1),u=j(!1),m=j(!1),k=j(""),d=j([]),T=j(null),h=j(0),g=j(0),f=j(!1),P=j(""),ee=j(!1),v=j(lm()),B=typeof window<"u"&&typeof window.EventSource<"u";function K(re=""){const je=typeof re=="object"&&re!==null?String(re.message||"").trim():String(re||"").trim();je&&t("toast",typeof re=="object"&&re!==null?{...re,message:je}:je)}let V=null,O=null,se=null,A={sessions:!1,runs:!1};const X=q({get(){return String(e.selectedSessionId||"").trim()},set(re){t("selected-session-change",String(re||"").trim())}}),ge=q(()=>m.value?Xe("sessionPanel.stopping"):`${Xe("projectManager.running")} (${Da(g.value)})`),Se=q(()=>o.value.find(re=>re.id===X.value)||null),L=q(()=>{var je;if(Array.isArray((je=Se.value)==null?void 0:je.agentBindings)&&Se.value.agentBindings.length)return Se.value.agentBindings;const re=Se.value;return re!=null&&re.id?[{engine:re.engine,sessionRecordId:re.id,sessionId:re.sessionId||"",started:!!re.started,running:!!re.running,isDefault:!0}]:[]}),ne=q({get(){var je,tt;const re=Po(e.selectedAgentEngine,L.value);return re||((je=L.value.find(ot=>ot.isDefault))==null?void 0:je.engine)||((tt=L.value[0])==null?void 0:tt.engine)||""},set(re){const je=Po(re,L.value);je&&t("update:selectedAgentEngine",je)}}),le=q(()=>L.value.find(re=>re.engine===ne.value)||L.value[0]||null),{beginForceFollowWindow:te,destroy:ye,handleTranscriptScroll:C,handleTranscriptTouchEnd:W,handleTranscriptTouchMove:D,handleTranscriptTouchStart:Ae,resetAutoStickToBottom:Pe,scheduleScrollToBottom:Ne,scrollToBottom:Je}=rm({transcriptRef:T,hasNewerMessages:ee});function Qe(re,je,tt={}){return um(re,je,tt)}function We(re,je={}){if(!(re!=null&&re.id))return;const tt=[...o.value],ot=tt.findIndex(qt=>qt.id===re.id);ot>=0?tt[ot]=Qe(tt[ot],re,je):tt.unshift(Qe(null,re,je)),o.value=tt}const{applyCreatedRun:be,applyIncomingRunEvent:H,clearRealtimeReconcileTimer:Z,clearRunPollTimer:me,clearTurns:Ce,loadTurnEvents:fe,markFallbackSessionPollNow:Me,refreshRunHistory:he,resetRunHistoryState:Be,updatePollingState:ze}=Jp({props:e,turns:d,sessions:o,sending:u,sendingStartedAt:h,currentRunningRunId:P,sessionError:k,supportsServerEvents:B,scheduleScrollToBottom:Ne,resetAutoStickToBottom:Pe,showProcessLogs:v,mergeSessionRecord:Qe,mergeSession:We,loadSessions:(...re)=>pt(...re)}),{closeManager:Le,handleCreateSession:wt,handleDeleteSession:Ye,handleResetSession:bt,handleSelectSession:Ge,handleSend:lt,handleUpdateSession:it,helperText:kt,loadSessions:pt,loadSessionResources:gt,loadWorkspaces:$,openManager:I,refreshSessionsForSelection:oe,sortedSessions:Ie,stopSending:Re}=em({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:u,stopping:m,sessionError:k,showManager:f,selectedSessionId:X,currentRunningRunId:P,supportsServerEvents:B,mergeSession:We,applyCreatedRun:be,refreshRunHistory:he,markFallbackSessionPollNow:Me,showToast:K,getActiveAgentBinding:()=>le.value});function De(){V&&(window.clearInterval(V),V=null)}function Ze(){De(),h.value||(h.value=Date.now()),g.value=Math.max(0,Math.floor((Date.now()-h.value)/1e3)),V=window.setInterval(()=>{g.value=Math.max(0,Math.floor((Date.now()-h.value)/1e3))},1e3)}function Ue(){se&&(window.clearTimeout(se),se=null)}function _t(){Ue();const re=A;A={sessions:!1,runs:!1},re.sessions&&pt({force:!0}).catch(()=>{}),re.runs&&he({force:!0}).catch(()=>{})}function yt(re={}){typeof window>"u"||(A={sessions:A.sessions||!!re.sessions,runs:A.runs||!!re.runs},!(se||!A.sessions&&!A.runs)&&(se=window.setTimeout(()=>{_t()},am)))}function Dt(re){return Ra(re,{currentRunningRunId:P.value,runningElapsedSeconds:g.value,nowMs:Date.now()})}function et(re=""){if(!re)return"";const je=new Date(re);return Number.isNaN(je.getTime())?"":je.toLocaleTimeString(fo(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Xt(re){return re.status==="error"||re.status==="stop_timeout"?"theme-process-error":re.status==="interrupted"||re.status==="stopped"?"theme-process-stopped":re.status==="completed"?"theme-process-completed":"theme-process-running"}function sn(){v.value=!v.value}function Yt(re){return!!(re.responseMessage||re.errorMessage||re.status==="completed")}return $e(v,re=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ua,re?"true":"false")}catch{}},{immediate:!0}),$e(u,re=>{re?(h.value||(h.value=Date.now()),Ze()):(De(),h.value=0,g.value=0,m.value=!1),ze(),t("sending-change",re)},{immediate:!0}),$e(g,(re,je)=>{e.active&&je===0&&re>0&&Ne()}),$e(()=>!!e.taskRunning,re=>{!e.active||re||!u.value||yt({sessions:!0,runs:!0})}),$e(()=>e.active,re=>{if(re){gt({forceSessions:!0}).catch(()=>{});return}Ue(),Z(),me()},{immediate:!0}),$e(()=>e.taskSlug,()=>{Be(),f.value=!1,k.value="",e.active&&(te(),he({force:!0,scrollToLatest:!0}).catch(()=>{}))},{immediate:!0}),$e(()=>{var re;return[((re=Se.value)==null?void 0:re.id)||"",L.value.map(je=>je.engine).join(","),e.selectedAgentEngine||""].join(`
39
+ `)},()=>{var z,Q,ce;const re=String(((z=Se.value)==null?void 0:z.id)||"").trim(),je=L.value,tt=ne.value;if(t("agent-bindings-change",{sessionId:re,bindings:je,selectedEngine:tt}),!re||Po(e.selectedAgentEngine,je))return;const qt=((Q=je.find(xe=>xe.isDefault))==null?void 0:Q.engine)||((ce=je[0])==null?void 0:ce.engine)||"";qt&&t("update:selectedAgentEngine",qt)},{immediate:!0}),Nt(()=>{De(),Z(),me(),Ue(),ye(),O==null||O()}),$e(()=>n.readyVersion.value,()=>{const re=String(e.taskSlug||"").trim();!e.active&&!f.value||(f.value&&$().catch(()=>{}),yt({sessions:!0,runs:!!re}))}),$e(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!f.value||yt({sessions:!0})}),$e(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||yt({sessions:!0,runs:!0})}),$e(()=>String(e.taskSlug||"").trim(),re=>{O==null||O(),O=null,re&&(O=gp(re,({runId:je,event:tt})=>{if(!e.active)return;H(je,tt)||yt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:ne,clearTurns:Ce,closeManager:Le,formatTurnTime:et,getProcessCardClass:Xt,getProcessStatus:jp,getTurnAgentLabel:Ht,getTurnSummaryDetail:Oa,getDisplayTurnSummaryItems:Dt,getTurnSummaryStatus:Na,handleCreateSession:wt,handleDeleteSession:Ye,handleResetSession:bt,handleSelectSession:Ge,handleSend:lt,handleUpdateSession:it,loadTurnEvents:fe,hasTurnSummary:Op,helperText:kt,loading:r,managerBusy:l,openManager:I,refreshSessionsForSelection:oe,selectedSessionId:X,sending:u,showProcessLogs:v,stopping:m,sessionError:k,shouldShowResponse:Yt,showManager:f,sortedSessions:Ie,stopSending:Re,toggleProcessLogs:sn,hasNewerMessages:ee,transcriptRef:T,turns:d,workspaces:s,workingLabel:ge,sessions:o,loadSessions:pt,currentProjectAgentBindings:L,handleTranscriptScroll:C,handleTranscriptTouchEnd:W,handleTranscriptTouchMove:D,handleTranscriptTouchStart:Ae,scheduleScrollToBottom:Ne,scrollToBottom:Je}}function Po(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const dm=8,fm=320,pm=10,mm=400;function Dr(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function gm(e={}){const{turns:t,loadTurnEvents:n}=e,o=j({}),s=j({}),r=j({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function u(A){const X=l(A);return!!X&&X===l(t.value.at(-1))}function m(A){return Math.max(0,Number(A==null?void 0:A.eventCount)||0,Array.isArray(A==null?void 0:A.events)?A.events.length:0)}function k(A){return!Ps(A==null?void 0:A.status)&&!u(A)&&m(A)>3}function d(A){return Dr(A==null?void 0:A.prompt,dm,fm)}function T(A){return!Ps(A==null?void 0:A.status)&&!u(A)&&d(A)}function h(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function g(A){return Dr(h(A),pm,mm)}function f(A){return!(A!=null&&A.errorMessage)&&!u(A)&&g(A)}function P(A){return m(A)>0}function ee(A=[]){const X=new Set((A||[]).map(L=>l(L)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([L])=>X.has(L))),s.value=Object.fromEntries(Object.entries(s.value).filter(([L])=>X.has(L))),r.value=Object.fromEntries(Object.entries(r.value).filter(([L])=>X.has(L)));const ge=(A||[]).at(-1)||null,Se=l(ge);Se&&(Object.prototype.hasOwnProperty.call(o.value,Se)||(o.value={...o.value,[Se]:!1}),Object.prototype.hasOwnProperty.call(s.value,Se)||(s.value={...s.value,[Se]:!1}),Object.prototype.hasOwnProperty.call(r.value,Se)||(r.value={...r.value,[Se]:!1}))}function v(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(o.value,X)?!!o.value[X]:k(A):!1}async function B(A){const X=l(A);if(!X)return;const ge=!v(A);o.value={...o.value,[X]:ge},!ge&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function K(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(s.value,X)?!!s.value[X]:T(A):!1}function V(A){const X=l(A);!X||!d(A)||(s.value={...s.value,[X]:!K(A)})}function O(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(r.value,X)?!!r.value[X]:f(A):!1}function se(A){const X=l(A);!X||!g(A)||(r.value={...r.value,[X]:!O(A)})}return $e(t,A=>{ee(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:d,canCollapseResponse:g,getTurnEventCollapseKey:l,getTurnEventCount:m,hasTurnEventHistory:P,isLatestTurn:u,isPromptCollapsed:K,isResponseCollapsed:O,isTurnEventsCollapsed:v,togglePrompt:V,toggleResponse:se,toggleTurnEvents:B}}function hm(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function vm(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 ym(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function Do(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 Lo(e="",t=[],n=[]){var l;const o=hm(t.map(u=>u.groupTarget)),s=[];if(e==="todo"){const u=[...n].reverse().flatMap(m=>Array.isArray(m==null?void 0:m.detailBlocks)?m.detailBlocks:[]).find(m=>(m==null?void 0:m.type)==="checklist");return u?[u]:[]}if(e==="reasoning"){const u=[...t].reverse().find(m=>Array.isArray(m==null?void 0:m.detailBlocks)&&m.detailBlocks.length);return(l=u==null?void 0:u.detailBlocks)!=null&&l.length?u.detailBlocks:[]}const r=vm([{label:"类型",value:ym(e)},{label:"次数",value:String(t.length)}]);return r&&s.push(r),o.length&&s.push({type:"bullet_list",items:o.slice(0,8),totalCount:o.length,hiddenCount:Math.max(0,o.length-8)}),s}function ja(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:Do(n,e.length),detail:"",detailBlocks:Lo(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:Do(n,e.length),detail:"",detailBlocks:Lo(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:Do(n,o.length),detail:"",detailBlocks:Lo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Sm(e=[]){const t=Array.isArray(e)?e:[],n=t.filter(r=>String((r==null?void 0:r.groupType)||"").trim()==="todo");if(n.length<=1)return t;const[o]=ja(n);if(!o)return t;const s=t.reduce((r,l,u)=>String((l==null?void 0:l.groupType)||"").trim()==="todo"?u:r,-1);return s<0?t:t.flatMap((r,l)=>String((r==null?void 0:r.groupType)||"").trim()!=="todo"?[r]:l===s?[o]:[])}function wm(e=[]){var o;const t=Sm(Array.isArray(e)?e.filter(Boolean):[]),n=[];for(let s=0;s<t.length;s+=1){const r=t[s],l=String((r==null?void 0:r.groupType)||"").trim();if(!l){n.push(r);continue}const u=[r];for(;s+1<t.length&&String(((o=t[s+1])==null?void 0:o.groupType)||"").trim()===l;)u.push(t[s+1]),s+=1;n.push(...ja(u))}return n}const xm={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},bm={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},km={class:"flex flex-col gap-2"},Tm={class:"flex items-center gap-2"},_m=["title"],Cm={class:"flex shrink-0 items-center gap-1.5"},Em=["aria-pressed","aria-label","title"],Am=["disabled"],Im={class:"hidden sm:inline"},$m=["disabled"],Pm={class:"hidden sm:inline"},Dm=["aria-label"],Lm=["aria-pressed"],Mm=["aria-pressed","title","onClick"],Bm={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},Rm={class:"min-h-0 flex-1"},Nm={key:0,class:"theme-empty-state px-4 py-6 text-sm"},Om={key:1,class:"theme-empty-state px-4 py-6 text-sm"},Fm=["data-turn-id","data-run-id"],Um={class:"flex justify-end"},jm={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)]"},Vm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},zm={class:"font-semibold"},Hm={class:"flex items-center gap-2"},qm=["aria-label","title","onClick"],Km={class:"hidden sm:inline"},Wm={class:"relative mt-2"},Gm={key:0,class:"space-y-3"},Xm={key:0,class:"whitespace-pre-wrap break-words leading-7"},Ym=["onClick"],Jm=["src","alt"],Qm={key:1,class:"whitespace-pre-wrap break-words leading-7"},Zm={key:0,class:"flex min-w-0 justify-start"},eg={class:"flex items-center justify-between gap-3 text-xs"},tg={class:"font-semibold"},ng={class:"flex items-center gap-2"},sg=["disabled","onClick"],og={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},rg={key:1,class:"mt-2 min-w-0 space-y-2"},ag={class:"text-sm font-medium leading-6"},ig={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},lg={key:3,class:"mt-2 text-xs text-current"},ug={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},cg={key:0,class:"leading-5"},dg={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},fg={key:2,class:"mt-2 flex flex-wrap gap-2"},pg={class:"font-medium"},mg={key:1,class:"flex justify-start"},gg={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},hg={class:"font-semibold"},vg={class:"flex items-center gap-2","data-response-export-ignore":"1"},yg=["aria-label","title","onClick"],Sg={class:"hidden sm:inline"},wg=["aria-label","title","onClick"],xg={class:"hidden sm:inline"},bg=["aria-label","title","disabled","onClick"],kg={class:"hidden sm:inline"},Tg={class:"relative mt-2"},_g={key:0,class:"whitespace-pre-wrap break-words"},Cg=["innerHTML"],Eg={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"},Ag=["disabled"],Ig={key:2,class:"task-loading-dots","aria-hidden":"true"},ts=640,$g=2,Lr="promptx:selected-agent-filter-map",Pg={__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=Ro(()=>He(()=>import("./CodexSessionManagerDialog-C5Cht229.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:u,getProcessCardClass:m,getProcessStatus:k,getTurnAgentLabel:d,getDisplayTurnSummaryItems:T,getTurnSummaryDetail:h,getTurnSummaryStatus:g,handleCreateSession:f,handleDeleteSession:P,handleResetSession:ee,handleSelectSession:v,handleSend:B,handleTranscriptScroll:K,handleTranscriptTouchEnd:V,handleTranscriptTouchMove:O,handleTranscriptTouchStart:se,handleUpdateSession:A,helperText:X,loadTurnEvents:ge,loading:Se,managerBusy:L,openManager:ne,refreshSessionsForSelection:le,selectedSessionId:te,sending:ye,showProcessLogs:C,stopping:W,hasTurnSummary:D,hasNewerMessages:Ae,sessionError:Pe,shouldShowResponse:Ne,showManager:Je,sortedSessions:Qe,stopSending:We,toggleProcessLogs:be,transcriptRef:H,turns:Z,workspaces:me,sessions:Ce,loadSessions:fe,currentProjectAgentBindings:Me,scheduleScrollToBottom:he,scrollToBottom:Be}=cm(r,s),ze=j(null),Le=j(!1),wt=j(""),Ye=j(""),bt=j(""),Ge=j(""),lt=j(""),it=j(""),kt=new Map;function pt(){try{const y=JSON.parse(window.localStorage.getItem(Lr)||"{}");if(y&&typeof y=="object"&&!Array.isArray(y))return y}catch{}return{}}function gt(y){window.localStorage.setItem(Lr,JSON.stringify(y))}const $=j("all");$e($,y=>{const N=String(r.taskSlug||"").trim();if(!N)return;const M=pt();M[N]=y,gt(M)});const{t:I}=Lt(),{isDark:oe}=Yr(),Ie=q(()=>oe.value?"dark":"light"),Re=q(()=>{const y=new Set;return(Array.isArray(Me.value)?Me.value:[]).filter(N=>{const M=String((N==null?void 0:N.engine)||"").trim();return!M||y.has(M)?!1:(y.add(M),!0)})}),De=q(()=>Re.value.length>1),Ze=q(()=>{const y=String($.value||"").trim();return!De.value||y==="all"?Z.value:Z.value.filter(N=>Ba(N)===y)}),{selectionAction:Ue,clearSelectionState:_t,handleSelectionMouseUp:yt}=xa({getContainer:()=>H.value,isActive:()=>!!(r.active&&Z.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:y=>[...y.querySelectorAll("[data-response-selection-root]")],getCodeLeft:y=>{var N,M;return((M=(N=y==null?void 0:y.getBoundingClientRect)==null?void 0:N.call(y))==null?void 0:M.left)||0},debounceMs:72});$e([$,()=>Re.value.map(y=>y.engine).join(`
40
+ `)],()=>{$.value!=="all"&&Re.value.length&&(Re.value.some(y=>y.engine===$.value)||($.value="all"))},{immediate:!0}),$e($,()=>{_t({clearBrowserSelection:!0}),he({force:!0})}),$e(()=>r.taskSlug,(y,N)=>{if(!String(y||"").trim()||y===N)return;const we=pt()[y];$.value=we||"all"},{immediate:!0});function Dt(y={}){const N=String((y==null?void 0:y.title)||"").trim();return N?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/ 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(M=>M.test(N)):!1}function et(y={}){return I("sessionPanel.promptTitleWithAgent",{agent:d(y)})}function Xt(y={}){return y.errorMessage?I("sessionPanel.errorSuffix",{agent:d(y)}):I("sessionPanel.responseSuffix",{agent:d(y)})}const{getTurnEventCount:sn,hasTurnEventHistory:Yt,isTurnEventsCollapsed:re,toggleTurnEvents:je}=gm({turns:Z,loadTurnEvents:ge});function tt(y){return String((y==null?void 0:y.runId)||(y==null?void 0:y.id)||"").trim()}function ot(y={},N=null){const M=tt(y);if(M){if(N instanceof HTMLElement){kt.set(M,N);return}kt.delete(M)}}function qt(y){y!=null&&y.runId&&s("open-diff",{scope:"run",runId:y.runId})}function z(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:Q}=np({items:Z,themeKey:Ie,getCacheKey:tt,getSource:y=>String((y==null?void 0:y.responseMessage)||""),shouldRender:y=>!!(y!=null&&y.responseMessage)&&!(y!=null&&y.errorMessage),renderAsync:y=>jc(y,{isDark:oe.value,copyLabel:I("sessionPanel.copyCode"),copyAriaLabel:I("sessionPanel.copyCodeAria")}),renderFallback:y=>ya(y),onRendered:y=>{const N=Z.value.at(-1)||null;!r.active||!(N!=null&&N.runId)||N.runId!==(y==null?void 0:y.runId)||he()}});function ce(y){bt.value=String(y||"").trim()}async function xe(y){var M;if((M=navigator.clipboard)!=null&&M.writeText&&window.isSecureContext){await navigator.clipboard.writeText(y);return}const N=document.createElement("textarea");N.value=y,N.setAttribute("readonly","true"),N.style.position="fixed",N.style.opacity="0",N.style.pointerEvents="none",document.body.appendChild(N),N.select(),document.execCommand("copy"),document.body.removeChild(N)}async function qe(){var y;if(await dt(),(y=document.fonts)!=null&&y.ready)try{await document.fonts.ready}catch{}await new Promise(N=>window.requestAnimationFrame(N))}function Tt(y){const N=document.createElement("div");N.setAttribute("aria-hidden","true"),N.style.position="fixed",N.style.left=`-${ts+200}px`,N.style.top="0",N.style.width=`${ts}px`,N.style.pointerEvents="none",N.style.zIndex="-1";const M=y.cloneNode(!0);return M.classList.add("response-image-export-card"),M.style.position="static",M.style.width=`${ts}px`,M.style.minWidth=`${ts}px`,M.style.maxWidth=`${ts}px`,M.style.boxSizing="border-box",M.style.pointerEvents="none",N.appendChild(M),document.body.appendChild(N),{card:M,host:N}}async function Kt(y={}){var Ke,xt,Zt,jt,rn;const N=tt(y),M=N?kt.get(N):null;if(!M||it.value)return;it.value=N,(Zt=(xt=(Ke=window.getSelection)==null?void 0:Ke.call(window))==null?void 0:xt.removeAllRanges)==null||Zt.call(xt);let we=null;try{we=Tt(M);const an=we.card;await qe();const Xn=window.getComputedStyle(an),pn=Math.max(1,Math.ceil(an.scrollHeight||an.getBoundingClientRect().height)),Yn=await ni(an,{backgroundColor:Xn.backgroundColor||void 0,cacheBust:!0,filter:Jn=>!(Jn instanceof Element&&Jn.dataset.responseExportIgnore==="1"),height:pn,pixelRatio:$g,width:ts});if(!Yn)throw new Error("Response image export returned an empty blob.");_(Yn)}catch{s("toast",{message:I("sessionPanel.responseImageFailed"),type:"warning"})}finally{(rn=(jt=we==null?void 0:we.host)==null?void 0:jt.remove)==null||rn.call(jt),it.value===N&&(it.value="")}}function Ut(y={}){const M=(Array.isArray(y==null?void 0:y.promptBlocks)?y.promptBlocks:[]).filter(Ke=>(Ke==null?void 0:Ke.type)===Pt.TEXT||(Ke==null?void 0:Ke.type)===Pt.IMPORTED_TEXT||(Ke==null?void 0:Ke.type)===Pt.IMAGE).map(Ke=>({type:Ke.type,content:String((Ke==null?void 0:Ke.content)||"").replace(/\u200b/g,"").trim(),meta:Ke!=null&&Ke.meta?{...Ke.meta}:{}})).filter(Ke=>Ke.content);if(M.length)return M;const we=String((y==null?void 0:y.prompt)||"").replace(/\u200b/g,"").trim();return we?[{type:Pt.TEXT,content:we,meta:{}}]:[]}function Bt(y={}){return Ut(y).length>0}function Rt(y={}){const N=Ut(y);N.length&&s("insert-code-context",{source:"response",blocks:N})}async function Tn(y){var xt,Zt,jt,rn,an;const N=(Zt=(xt=y==null?void 0:y.target)==null?void 0:xt.closest)==null?void 0:Zt.call(xt,'[data-copy-code="1"]');if(!N)return!1;const M=N.closest(".codex-code-block"),we=(jt=M==null?void 0:M.querySelector)==null?void 0:jt.call(M,"pre code"),Ke=String((we==null?void 0:we.textContent)||"").replace(/\u200b/g,"");if(!Ke)return!1;(rn=y.preventDefault)==null||rn.call(y),(an=y.stopPropagation)==null||an.call(y);try{return await xe(Ke),s("toast",{message:I("sessionPanel.codeCopied"),type:"success"}),!0}catch{return s("toast",{message:I("errors.requestFailed"),type:"warning"}),!0}}function Et(y=""){return String(y||"").trim().split(/[?#]/)[0].replace(/:(\d+)(?::\d+)?$/,"")}function gn(y=""){const N=String(y||"").trim();try{return decodeURI(N)}catch{return N}}function hn(y=""){return gn(y).replace(/\\/g,"/").replace(/\/+/g,"/").trim()}function cn(y=""){const N=hn(y).replace(/^\.\//,"").split("/").filter(Boolean);return!N.length||N.some(M=>M==="."||M==="..")?"":N.join("/")}function _n(y=""){const N=String(y||"").trim();if(!N||N.startsWith("#")||N.startsWith("//"))return"";if(/^(?:https?:|mailto:|tel:|data:|blob:|javascript:)/i.test(N))try{const M=new URL(N);return M.origin!==window.location.origin?"":Et(M.pathname)}catch{return""}return Et(N)}function vn(y=""){const N=In(),M=hn((N==null?void 0:N.cwd)||"").replace(/\/$/,""),we=hn(_n(y));return!M||!we?"":we.startsWith("/")?we===M||!we.startsWith(`${M}/`)?"":cn(we.slice(M.length+1)):cn(we)}function On(y){var we,Ke,xt,Zt;const N=(Ke=(we=y==null?void 0:y.target)==null?void 0:we.closest)==null?void 0:Ke.call(we,".codex-markdown a[href]");if(!N)return!1;const M=vn(N.getAttribute("href")||"");return M?((xt=y.preventDefault)==null||xt.call(y),(Zt=y.stopPropagation)==null||Zt.call(y),Ot(null,{searchQuery:M})||s("toast",{message:I("sourceBrowser.noProject"),type:"warning"}),!0):!1}function dn(y){On(y)||Tn(y)}function yn(){if(!Ue.value.visible)return;const y=String(Ue.value.content||"").replace(/\u200b/g,"").trim();if(!y){_t({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:y}),_t({clearBrowserSelection:!0})}function Cn(y={}){if(y!=null&&y.errorMessage)return;const N=String((y==null?void 0:y.responseMessage)||"").replace(/\u200b/g,"").trim();N&&s("insert-code-context",{source:"response",content:N})}const En=q(()=>Z.value.flatMap(y=>(Array.isArray(y==null?void 0:y.promptBlocks)?y.promptBlocks:[]).filter(N=>(N==null?void 0:N.type)==="image").map(N=>N.content))),An=q(()=>Ge.value?[Ge.value]:[]);function fn(){lt.value&&(URL.revokeObjectURL(lt.value),lt.value="")}function _(y){fn();const N=URL.createObjectURL(y);lt.value=N,Ge.value=N}$e(Ge,y=>{y||fn()}),Nt(()=>{fn()});function x(y){const M=(Array.isArray(y==null?void 0:y.events)?y.events:[]).filter(we=>!Dt(we));return wm(M)}function F(y){return sn(y)}function ae(y){return y!=null&&y.eventsLoaded?F(y)>0:Yt(y)}function ie(y){return!!(y!=null&&y.eventsLoading)}function ve(y){return!!(y!=null&&y.eventsLoaded)&&x(y).length>0&&!re(y)}function ut(y){return!!(y!=null&&y.eventsLoaded)&&F(y)>0&&re(y)}function Oe(y){return Yt(y)&&!(y!=null&&y.eventsLoaded)&&!(y!=null&&y.eventsLoading)}function Jt(y={}){return ua(y,{defaultLabel:I("sessionPanel.defaultAgent")})}function on(y={}){return!Bp(y)}function Sn(y={}){return"bg-[var(--theme-appPanelStrong)]"}function In(y=null){const N=String((y==null?void 0:y.id)||"").trim();if(N)return Ce.value.find(we=>we.id===N)||null;const M=String(te.value||"").trim();return M?Ce.value.find(we=>we.id===M)||null:Qe.value[0]||null}function Ot(y=null,N={}){const M=In(y);return M!=null&&M.cwd?(wt.value=M.id,Ye.value=String(N.searchQuery||"").trim(),Le.value=!0,!0):!1}function Qt(){return L.value?!1:(ne(),!0)}function At(){var y,N;return Le.value?(Le.value=!1,!0):(N=(y=ze.value)==null?void 0:y.closeTopDialog)!=null&&N.call(y)?!0:Je.value?(l(),!0):!1}return t({closeTopDialog:At,openProjectManager:Qt,openSourceBrowser:Ot,send:B,scrollToBottom:Be,stop:We}),(y,N)=>(p(),b("section",xm,[ue(tp,{open:Le.value,session:a(Ce).find(M=>M.id===wt.value)||null,"initial-search-query":Ye.value,onInsertCodeContext:N[0]||(N[0]=M=>s("insert-code-context",M)),onClose:N[1]||(N[1]=M=>Le.value=!1)},null,8,["open","session","initial-search-query"]),ue(a(o),{ref_key:"managerDialogRef",ref:ze,open:a(Je),sessions:a(Ce),workspaces:a(me),"selected-session-id":a(te),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(Se),sending:a(ye),"on-refresh":a(fe),"on-create":a(f),"on-update":a(A),"on-delete":a(P),"on-reset":a(ee),onClose:a(l),onOpenSourceBrowser:N[2]||(N[2]=M=>Ot(M)),onProjectCreated:N[3]||(N[3]=M=>s("project-created",M)),onSelectSession:a(v)},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",bm,[i("div",km,[i("div",Tm,[i("div",{class:"min-w-0 flex-1",title:a(X)||""},[ue(kc,{modelValue:a(te),"onUpdate:modelValue":N[4]||(N[4]=M=>ti(te)?te.value=M:null),sessions:a(Qe),loading:a(Se),disabled:a(ye)||a(L)||e.sessionSelectionLocked,onRefreshIntent:a(le)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,_m),i("div",Cm,[i("button",{type:"button",class:Te(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",a(C)?"tool-button-accent-subtle":""]),"aria-pressed":a(C)?"true":"false","aria-label":a(C)?a(I)("sessionPanel.hideProcessToggle"):a(I)("sessionPanel.showProcessToggle"),title:a(C)?a(I)("sessionPanel.hideProcessToggle"):a(I)("sessionPanel.showProcessToggle"),onClick:N[5]||(N[5]=(...M)=>a(be)&&a(be)(...M))},[a(C)?(p(),Ee(a(ci),{key:0,class:"h-4 w-4"})):(p(),Ee(a(di),{key:1,class:"h-4 w-4"}))],10,Em),e.diffSupported?(p(),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:z},[ue(a(dr),{class:"h-4 w-4"}),N[18]||(N[18]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",Im,w(a(I)("sessionPanel.diff")),1)],8,Am)):de("",!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:a(L),onClick:N[6]||(N[6]=(...M)=>a(ne)&&a(ne)(...M))},[ue(a(As),{class:"h-4 w-4"}),N[19]||(N[19]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",Pm,w(a(I)("sessionPanel.manageProjects")),1)],8,$m)])]),De.value?(p(),b("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(I)("sessionPanel.agentFilter")},[i("button",{type:"button",class:Te(["theme-agent-selector-button",$.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":$.value==="all"?"true":"false",onClick:N[7]||(N[7]=M=>$.value="all")},w(a(I)("sessionPanel.allAgents")),11,Lm),(p(!0),b(ft,null,vt(Re.value,M=>(p(),b("button",{key:M.engine,type:"button",class:Te(["theme-agent-selector-button",$.value===M.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":$.value===M.engine?"true":"false",title:Jt(M),onClick:we=>$.value=M.engine},w(Jt(M)),11,Mm))),128))],8,Dm)):de("",!0),a(Pe)?(p(),b("p",Bm,[ue(a(Xo),{class:"h-4 w-4"}),i("span",null,w(a(Pe)),1)])):de("",!0)])]),i("div",Rm,[i("div",{ref_key:"transcriptRef",ref:H,"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:N[9]||(N[9]=(...M)=>a(K)&&a(K)(...M)),onTouchstartPassive:N[10]||(N[10]=(...M)=>a(se)&&a(se)(...M)),onTouchmovePassive:N[11]||(N[11]=(...M)=>a(O)&&a(O)(...M)),onTouchendPassive:N[12]||(N[12]=(...M)=>a(V)&&a(V)(...M)),onTouchcancelPassive:N[13]||(N[13]=(...M)=>a(V)&&a(V)(...M))},[a(Z).length?Ze.value.length?de("",!0):(p(),b("div",Om,w(a(I)("sessionPanel.emptyAgentFilter")),1)):(p(),b("div",Nm,w(a(I)("sessionPanel.empty")),1)),(p(!0),b(ft,null,vt(Ze.value,M=>(p(),b("div",{key:M.id,"data-promptx-turn":"1","data-turn-id":M.id,"data-run-id":M.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",Um,[i("div",jm,[i("div",Vm,[i("span",zm,w(et(M)),1),i("div",Hm,[Bt(M)?(p(),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)]","aria-label":a(I)("sessionPanel.insert"),title:a(I)("sessionPanel.insert"),onClick:we=>Rt(M)},[ue(a(no),{class:"h-3 w-3"}),i("span",Km,w(a(I)("sessionPanel.insert")),1)],8,qm)):de("",!0),i("span",null,w(a(u)(M.startedAt)),1)])]),i("div",Wm,[Array.isArray(M.promptBlocks)&&M.promptBlocks.length?(p(),b("div",Gm,[(p(!0),b(ft,null,vt(M.promptBlocks,(we,Ke)=>(p(),b(ft,{key:`${M.id}-prompt-${Ke}`},[we.type==="text"||we.type==="imported_text"?(p(),b("pre",Xm,w(we.content),1)):(p(),b("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:xt=>ce(we.content)},[i("img",{src:we.content,alt:a(I)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,Jm)],8,Ym))],64))),128))])):(p(),b("pre",Qm,w(M.prompt),1))])])]),a(C)&&on(M)?(p(),b("div",Zm,[i("div",{class:Te(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(m)(M)])},[i("div",eg,[i("span",tg,w(a(I)("sessionPanel.processTitle")),1),i("div",ng,[ae(M)?(p(),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:M.eventsLoading,onClick:we=>a(je)(M)},[ie(M)?(p(),Ee(a(Gt),{key:0,class:"h-3 w-3 animate-spin"})):a(re)(M)?(p(),Ee(a(Go),{key:1,class:"h-3 w-3"})):(p(),Ee(a(fi),{key:2,class:"h-3 w-3"})),i("span",null,w(M.eventsLoading?a(I)("sessionPanel.loading"):a(re)(M)?`${a(I)("sessionPanel.expand")} (${F(M)})`:a(I)("sessionPanel.collapse")),1)],8,sg)):de("",!0),i("span",null,w(a(k)(M)),1)])]),ie(M)?(p(),b("div",og,w(a(I)("sessionPanel.loadingEvents")),1)):ve(M)?(p(),b("div",rg,[(p(!0),b(ft,null,vt(x(M),we=>(p(),b("div",{key:we.id,class:Te(["transcript-event-card min-w-0 rounded-sm px-3 py-2",Sn(we)])},[i("div",ag,w(we.title),1),we.detail||Array.isArray(we.detailBlocks)&&we.detailBlocks.length?(p(),Ee(Td,{key:0,detail:we.detail,blocks:we.detailBlocks,kind:we.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):de("",!0)],2))),128))])):ut(M)||Oe(M)?(p(),b("div",ig,w(M.eventsLoaded?a(I)("sessionPanel.hiddenEventsLoaded",{count:F(M)}):a(I)("sessionPanel.hiddenEventsLoadLater",{count:F(M)})),1)):(p(),b("p",lg,w(["queued","starting","running","stopping"].includes(M.status)?a(I)("sessionPanel.waitingEvents",{agent:a(d)(M)}):a(I)("sessionPanel.noEvents")),1)),a(D)(M)?(p(),b("div",ug,[a(g)(M)?(p(),b("div",cg,w(a(g)(M)),1)):de("",!0),a(h)(M)?(p(),b("div",dg,w(a(h)(M)),1)):de("",!0),a(T)(M).length?(p(),b("div",fg,[(p(!0),b(ft,null,vt(a(T)(M),we=>(p(),b("span",{key:we.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(we.label),1),i("span",pg,w(we.value),1)]))),128))])):de("",!0)])):de("",!0)],2)])):de("",!0),a(Ne)(M)?(p(),b("div",mg,[i("div",{class:Te(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",M.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"]),ref_for:!0,ref:we=>ot(M,we)},[i("div",gg,[i("span",hg,w(Xt(M)),1),i("div",vg,[e.diffSupported&&M.runId?(p(),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)]","aria-label":a(I)("sessionPanel.view"),title:a(I)("sessionPanel.view"),onClick:we=>qt(M)},[ue(a(dr),{class:"h-3 w-3"}),i("span",Sg,w(a(I)("sessionPanel.view")),1)],8,yg)):de("",!0),M.responseMessage&&!M.errorMessage?(p(),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)]","aria-label":a(I)("sessionPanel.insert"),title:a(I)("sessionPanel.insert"),onClick:we=>Cn(M)},[ue(a(no),{class:"h-3 w-3"}),i("span",xg,w(a(I)("sessionPanel.insert")),1)],8,wg)):de("",!0),M.responseMessage&&!M.errorMessage?(p(),b("button",{key:2,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:cursor-wait disabled:opacity-60","aria-label":a(I)("sessionPanel.previewResponseImageAria"),title:a(I)("sessionPanel.previewResponseImageAria"),disabled:!!it.value,onClick:we=>Kt(M)},[it.value===tt(M)?(p(),Ee(a(Gt),{key:0,class:"h-3 w-3 animate-spin"})):(p(),Ee(a(pi),{key:1,class:"h-3 w-3"})),i("span",kg,w(a(I)("sessionPanel.previewResponseImage")),1)],8,bg)):de("",!0),i("span",null,w(a(u)(M.finishedAt||M.startedAt)),1)])]),i("div",Tg,[M.errorMessage?(p(),b("div",_g,w(M.errorMessage),1)):(p(),b("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:N[8]||(N[8]=(...we)=>a(yt)&&a(yt)(...we)),onClick:dn,innerHTML:a(Q)(M)},null,40,Cg))])],2)])):de("",!0)],8,Fm))),128)),a(Ue).visible?(p(),Ee(Sa,{key:2,top:a(Ue).top,left:a(Ue).left,label:a(I)("sourceBrowser.insertSelection"),onClick:yn},null,8,["top","left","label"])):de("",!0)],544),i("div",Eg,[a(Ae)?(p(),b("button",{key:0,type:"button",class:Te([a(ye)?"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:N[14]||(N[14]=(...M)=>a(Be)&&a(Be)(...M))},[ue(a(mi),{class:"h-3.5 w-3.5"}),i("span",null,w(a(I)("sessionPanel.jumpToLatest")),1)],2)):de("",!0),a(ye)?(p(),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:a(W),onClick:N[15]||(N[15]=(...M)=>a(We)&&a(We)(...M))},[a(W)?(p(),Ee(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),Ee(a(gi),{key:1,class:"h-3.5 w-3.5"})),i("span",null,w(a(W)?a(I)("sessionPanel.stopping"):a(I)("sessionPanel.stop")),1),a(W)?de("",!0):(p(),b("span",Ig,[...N[20]||(N[20]=[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,Ag)):de("",!0)])]),ue(No,{modelValue:bt.value,"onUpdate:modelValue":N[16]||(N[16]=M=>bt.value=M),images:En.value},null,8,["modelValue","images"]),ue(No,{modelValue:Ge.value,"onUpdate:modelValue":N[17]||(N[17]=M=>Ge.value=M),images:An.value},null,8,["modelValue","images"])]))}},Dg={key:0,class:"h-full min-h-0"},Lg={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},Mr={__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=j(null);function r(){var T,h;return(h=(T=s.value)==null?void 0:T.send)==null?void 0:h.call(T)}function l(){var T,h;(h=(T=s.value)==null?void 0:T.stop)==null||h.call(T)}function u(){var T,h;(h=(T=s.value)==null?void 0:T.scrollToBottom)==null||h.call(T)}function m(){var T,h;return((h=(T=s.value)==null?void 0:T.openProjectManager)==null?void 0:h.call(T))||!1}function k(){var T,h;return((h=(T=s.value)==null?void 0:T.openSourceBrowser)==null?void 0:h.call(T))||!1}function d(){var T,h;return((h=(T=s.value)==null?void 0:T.closeTopDialog)==null?void 0:h.call(T))||!1}return t({closeTopDialog:d,openProjectManager:m,openSourceBrowser:k,send:r,stop:l,scrollToBottom:u}),(T,h)=>e.taskSlug?(p(),b("div",Dg,[ue(Pg,{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:h[0]||(h[0]=g=>o("agent-bindings-change",g)),onInsertCodeContext:h[1]||(h[1]=g=>o("insert-code-context",g)),onProjectCreated:h[2]||(h[2]=g=>o("project-created",g)),onSendingChange:h[3]||(h[3]=g=>o("sending-change",g)),onSelectedSessionChange:h[4]||(h[4]=g=>o("selected-session-change",g)),"onUpdate:selectedAgentEngine":h[5]||(h[5]=g=>o("update:selectedAgentEngine",g)),onOpenDiff:h[6]||(h[6]=g=>o("open-diff",g)),onToast:h[7]||(h[7]=g=>o("toast",g))},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?(p(),b("section",Lg,w(e.emptyMessage),1)):de("",!0)}},Mg=["title"],Bg={class:"flex min-w-0 items-center gap-1.5"},Rg=["aria-pressed","title","data-agent-engine","onClick"],Br={__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}=Lt(),r=q(()=>{const d=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(T=>{const h=String((T==null?void 0:T.engine)||"").trim();return!h||d.has(h)?!1:(d.add(h),!0)})}),l=q(()=>r.value.length>1),u=q(()=>{var T,h;const d=String(n.selectedAgentEngine||"").trim();return r.value.some(g=>g.engine===d)?d:((T=r.value.find(g=>g.isDefault))==null?void 0:T.engine)||((h=r.value[0])==null?void 0:h.engine)||""}),m=q(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function k(d={}){return ua(d,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(d,T)=>l.value?(p(),b("div",{key:0,class:Te(["flex w-full overflow-x-auto pb-0.5",m.value]),title:a(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:T[1]||(T[1]=at(()=>{},["stop"]))},[i("div",Bg,[(p(!0),b(ft,null,vt(r.value,h=>(p(),b("button",{key:h.engine,type:"button",class:Te(["theme-agent-selector-button",h.engine===u.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":h.engine===u.value,title:k(h),"data-agent-engine":h.engine,onMousedown:T[0]||(T[0]=at(()=>{},["prevent"])),onClick:g=>o("update:selectedAgentEngine",h.engine)},w(k(h)),43,Rg))),128))])],42,Mg)):de("",!0)}},Ng={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":""},Og={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},Fg=["disabled","title","aria-label"],Ug={class:"sr-only sm:not-sr-only sm:inline"},jg=["title","aria-label"],Vg={class:"sr-only sm:not-sr-only sm:inline"},zg=["disabled","title","aria-label"],Hg={class:"sr-only sm:not-sr-only sm:inline"},qg=["title","aria-label"],Kg={class:"sr-only sm:not-sr-only sm:inline"},Wg={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"},Gg=["disabled","title","aria-label"],Xg={class:"sr-only sm:not-sr-only sm:inline"},Rr={__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}=Lt(),r=q(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(u,m)=>(p(),b("div",Ng,[i("div",Og,[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:a(s)("editor.chooseFiles"),"aria-label":a(s)("editor.chooseFiles"),"data-promptx-editor-action":"files",onMousedown:m[0]||(m[0]=at(()=>{},["prevent"])),onClick:m[1]||(m[1]=k=>o("open-file-picker"))},[e.uploading?(p(),Ee(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(p(),Ee(a(hi),{key:1,class:"h-4 w-4"})),i("span",Ug,w(a(s)("editor.chooseFiles")),1)],40,Fg),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:a(s)("editor.clear"),"aria-label":a(s)("editor.clear"),"data-promptx-editor-action":"clear",onMousedown:m[2]||(m[2]=at(()=>{},["prevent"])),onClick:m[3]||(m[3]=k=>o("clear-request"))},[ue(a(vi),{class:"h-4 w-4"}),i("span",Vg,w(a(s)("editor.clear")),1)],40,jg),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:a(s)("editor.todo"),"aria-label":a(s)("editor.todo"),"data-promptx-editor-action":"todo-add",onMousedown:m[4]||(m[4]=at(()=>{},["prevent"])),onClick:m[5]||(m[5]=k=>o("add-todo"))},[ue(a(no),{class:"h-4 w-4"}),i("span",Hg,w(a(s)("editor.todo")),1)],40,zg),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:m[6]||(m[6]=at(()=>{},["prevent"])),onClick:m[7]||(m[7]=k=>o("manage-todo"))},[ue(a(ta),{class:"h-4 w-4"}),i("span",Kg,w(l()),1),e.todoCount>0?(p(),b("span",Wg,w(e.todoCount>9?"9+":e.todoCount),1)):de("",!0)],40,qg),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:a(s)("editor.send"),"aria-label":a(s)("editor.send"),"data-promptx-editor-action":"send",onMousedown:m[8]||(m[8]=at(()=>{},["prevent"])),onClick:m[9]||(m[9]=k=>o("send-request"))},[r.value?(p(),Ee(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(p(),Ee(a(yi),{key:1,class:"h-4 w-4"})),i("span",Xg,w(a(s)("editor.send")),1)],40,Gg)])]))}};function Yg(e){const{props:t,panelRef:n,onClose:o}=e,s=j({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=j(!1),l=j("bottom");function u(){o==null||o()}function m(g=!1){const f=window.innerWidth,P=window.innerHeight,ee=12,v=8,B=320,K=560,V=420,O=180,se=Math.min(K,Math.max(B,f-ee*2)),A=Math.min(se,f-ee*2),X=t.anchorRect||{left:(f-A)/2,top:P/2,bottom:P/2};let ge=X.left;ge+A>f-ee&&(ge=f-ee-A),ge<ee&&(ge=ee);const Se=Math.max(0,P-ee-(X.bottom+v)),L=Math.max(0,X.top-v-ee);g?l.value=Se>=L?"bottom":"top":l.value==="bottom"&&Se<O&&L>Se+24?l.value="top":l.value==="top"&&L<O&&Se>L+24&&(l.value="bottom");const ne=l.value,le=ne==="bottom"?Se:L,te=Math.max(140,P-ee*2),ye=Math.min(te,Math.max(Math.min(V,le||V),O)),C={left:`${Math.round(ge)}px`,width:`${Math.round(A)}px`,maxHeight:`${Math.round(ye)}px`,top:"auto",bottom:"auto"};return ne==="bottom"?C.top=`${Math.round(Math.max(ee,X.bottom+v))}px`:C.bottom=`${Math.round(Math.max(ee,P-X.top+v))}px`,C}function k(g=!1){const f=m(g);s.value={...s.value,left:f.left,top:f.top,bottom:f.bottom,width:f.width,maxHeight:f.maxHeight}}function d(){return!t.open||!t.anchorRect?!1:(l.value="bottom",k(!0),r.value=!0,!0)}function T(){r.value=!1}function h(g){!t.open||!n.value||n.value.contains(g.target)||u()}return kn(()=>{document.addEventListener("pointerdown",h)}),Nt(()=>{document.removeEventListener("pointerdown",h)}),{closePicker:u,initializePanel:d,panelReady:r,panelStyle:s,resetPanel:T,updatePanelPosition:k}}function Jg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:u,panelStyle:m,resetPanel:k,updatePanelPosition:d}=Yg({props:t,panelRef:n,onClose:o}),T=ba({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return $e(()=>t.open,h=>{if(!h){T.resetData(),k();return}k(),t.anchorRect&&l()&&T.initializeData()},{flush:"sync"}),$e(()=>t.anchorRect,h=>{if(!(!t.open||!h)){if(!u.value){l()&&T.initializeData();return}d(!1)}},{flush:"sync"}),$e(()=>t.sessionId,()=>{T.handleSessionChange()},{flush:"sync",immediate:!0}),$e(()=>t.query,()=>{T.handleQueryChange()},{immediate:!0}),$e(T.visibleItems,()=>{T.handleVisibleItemsChange()},{immediate:!0}),{...T,closePicker:r,panelReady:u,panelStyle:m}}const Qg={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},Zg={class:"flex shrink-0 items-center gap-2"},eh={class:"min-h-0 flex-1 overflow-y-auto p-2"},th={key:0,class:"theme-empty-state px-3 py-4 text-xs"},nh={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},sh={key:2,class:"theme-empty-state px-3 py-4 text-xs"},oh={key:3,class:"theme-empty-state px-3 py-4 text-xs"},rh={key:4,class:"theme-empty-state px-3 py-4 text-xs"},ah={key:5,class:"space-y-1"},ih={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},lh=["onClick"],uh={class:"min-w-0 flex-1"},ch=["innerHTML"],dh=["innerHTML"],fh={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},ph=["onClick"],mh={class:"min-w-0 flex-1"},gh=["innerHTML"],hh=["innerHTML"],vh={key:6,class:"space-y-1"},yh={class:"flex items-start gap-1.5"},Sh=["onClick"],wh={key:1,class:"block h-5 w-5 shrink-0"},xh=["onClick"],bh={class:"min-w-0 flex-1"},kh={class:"flex items-center gap-1.5"},Th={__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,r=j(null),{t:l}=Lt(),{activeKey:u,closePicker:m,collapseActiveDirectory:k,confirmActive:d,currentError:T,currentLoading:h,emitSelect:g,expandActiveDirectory:f,getDisplayName:P,getHighlightedName:ee,getHighlightedPath:v,moveActive:B,normalSearchItems:K,normalizedQuery:V,panelReady:O,panelStyle:se,recentSearchItems:A,setItemRef:X,showSearchEmptyState:ge,showTreeEmptyState:Se,toggleDirectory:L,treeItems:ne,visibleItems:le}=Jg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:te=>s("select",te)});return t({collapseActiveDirectory:k,moveActive:B,confirmActive:d,expandActiveDirectory:f}),(te,ye)=>(p(),Ee(Ls,{to:"body"},[e.open&&a(O)?(p(),b("div",{key:0,ref_key:"panelRef",ref:r,class:"theme-popover fixed z-40 flex flex-col overflow-hidden rounded-sm border shadow-lg",style:Nn(a(se))},[i("div",Qg,[i("div",Zg,[i("div",{class:Te(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(h)?"opacity-100":"opacity-0"])},[ue(a(Gt),{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:ye[0]||(ye[0]=(...C)=>a(m)&&a(m)(...C))},[ue(a(Qr),{class:"h-4 w-4"})])])]),i("div",eh,[e.sessionId?a(T)?(p(),b("div",nh,w(a(T)),1)):a(ge)?(p(),b("div",sh,w(a(l)("pathPicker.noResults")),1)):a(Se)?(p(),b("div",oh,w(a(l)("pathPicker.emptyDirectory")),1)):a(h)&&!a(le).length?(p(),b("div",rh,w(a(l)("pathPicker.loading")),1)):a(V)?(p(),b("div",ah,[a(A).length?(p(),b("div",ih,w(a(l)("pathPicker.recent")),1)):de("",!0),(p(!0),b(ft,null,vt(a(A),C=>(p(),b("button",{key:C.path,ref_for:!0,ref:W=>a(X)(C.path,W),type:"button",class:Te(["theme-list-row focus:outline-none",a(u)===C.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:W=>a(g)(C)},[(p(),Ee(Rn(C.type==="directory"?a(rs):a(Hn)),{class:"theme-list-item-icon"})),i("div",uh,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ee)(C)},null,8,ch)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(v)(C)},null,8,dh)])],10,lh))),128)),a(V)&&a(K).length?(p(),b("div",fh,w(a(l)("pathPicker.results")),1)):de("",!0),(p(!0),b(ft,null,vt(a(K),C=>(p(),b("button",{key:C.path,ref_for:!0,ref:W=>a(X)(C.path,W),type:"button",class:Te(["theme-list-row focus:outline-none",a(u)===C.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:W=>a(g)(C)},[(p(),Ee(Rn(C.type==="directory"?a(rs):a(Hn)),{class:"theme-list-item-icon"})),i("div",mh,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ee)(C)},null,8,gh)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(v)(C)},null,8,hh)])],10,ph))),128))])):(p(),b("div",vh,[(p(!0),b(ft,null,vt(a(ne),C=>(p(),b("div",{key:C.path,ref_for:!0,ref:W=>a(X)(C.path,W),class:Te(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(u)===C.path?"theme-list-item-active":C.type==="directory"&&C.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nn({paddingLeft:`${C.depth*16+6}px`})},[i("div",yh,[C.type==="directory"?(p(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:at(W=>a(L)(C.path),["stop"])},[C.loading?(p(),Ee(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),Ee(a(ea),{key:1,class:Te(["h-3.5 w-3.5 transition",C.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,Sh)):(p(),b("span",wh)),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:W=>a(g)(C)},[(p(),Ee(Rn(C.type==="directory"?a(rs):a(Hn)),{class:Te(["h-4 w-4 shrink-0",C.type==="directory"&&C.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",bh,[i("div",kh,[i("span",{class:Te(["theme-list-item-title truncate",C.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},w(a(P)(C)),3)])])],8,xh)])],6))),128))])):(p(),b("div",th,w(a(l)("pathPicker.selectProjectFirst")),1))])],4)):de("",!0)]))}},_h={__name:"TiptapTextBlockView",props:Yo,setup(e){return(t,n)=>(p(),Ee(a(Jo),{"data-promptx-node":"text"},{default:rt(()=>[ue(a(oa),{"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}))}},Va={__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=q(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=q(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(p(),b("div",{class:Te(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:Te(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[mn(s.$slots,"header",{actionsStateClass:o.value})],2),mn(s.$slots,"default")],2))}},Mt={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function Ch(){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 ls(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||Ch()),meta:e!=null&&e.meta?{...e.meta}:{}}}function os(e=""){return ls({type:Pt.TEXT,content:e,meta:{}})}function Vs(e){return e&&e.type!==Pt.TEXT}function Kn(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[os("")];const n=[];return t.forEach((o,s)=>{const r=ls(o),l=n[n.length-1];!l&&Vs(r)&&n.push(os("")),l&&Vs(l)&&Vs(r)&&n.push(os("")),n.push(r),s===t.length-1&&Vs(r)&&n.push(os(""))}),n}function qo(e=""){const t=String(e||"").split(`
41
+ `),n=[];return t.forEach((o,s)=>{o&&n.push({type:Mt.TEXT,text:o}),s<t.length-1&&n.push({type:Mt.HARD_BREAK})}),n}function Eh(e=""){return qo(e)}function Ah(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 ao(e=[]){return Ah(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===Mt.TEXT?String(t.text||""):n===Mt.HARD_BREAK?`
42
+ `:ao((t==null?void 0:t.content)||[])}).join("")}function Ih(e=[]){return ao(e)}function $h(e={}){var n,o;const t=ls(e);return t.type===Pt.IMAGE?{type:Mt.IMAGE_BLOCK,attrs:{clientId:t.clientId,src:String(t.content||"")}}:t.type===Pt.IMPORTED_TEXT?{type:Mt.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:qo(t.content)}:{type:Mt.TEXT_BLOCK,attrs:{clientId:t.clientId},content:qo(t.content)}}function za(e=[]){return Kn(e).map($h)}function zs(e=[]){return{type:Mt.DOC,content:za(e)}}function Ph(e={}){var t,n,o,s,r,l;return(e==null?void 0:e.type)===Mt.IMAGE_BLOCK?ls({type:Pt.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)===Mt.IMPORTED_TEXT_BLOCK?ls({type:Pt.IMPORTED_TEXT,content:ao(e.content||[]),clientId:String(((o=e.attrs)==null?void 0:o.clientId)||""),meta:{fileName:String(((s=e.attrs)==null?void 0:s.fileName)||""),collapsed:!!((r=e.attrs)!=null&&r.collapsed)}}):(e==null?void 0:e.type)===Mt.TEXT_BLOCK?ls({type:Pt.TEXT,content:ao(e.content||[]),clientId:String(((l=e.attrs)==null?void 0:l.clientId)||""),meta:{}}):null}function Dh(e=null){const n=(Array.isArray(e==null?void 0:e.content)?e.content:[]).map(Ph).filter(Boolean);return Kn(n)}function xs(e=[]){return JSON.stringify(Kn(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 Lh(e=""){const t=String(e);return{lines:t?t.split(`
43
+ `).length:0,chars:t.length}}function Qs(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,r=()=>{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(r);return}queueMicrotask(r)}const Mh={class:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1.5","data-promptx-imported-meta":""},Bh=["aria-expanded"],Rh={class:"theme-heading inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Nh=["aria-expanded"],Oh={class:"mt-0.5 break-all text-[12px] leading-4 text-[var(--theme-textSecondary)]"},Fh=["aria-label"],Uh={class:"max-h-[8.5rem] overflow-hidden whitespace-pre-wrap break-words leading-6"},jh={key:0,class:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-[var(--theme-appPanelMuted)] to-transparent"},Vh={key:1,class:"theme-muted-text absolute bottom-2 right-4 bg-[var(--theme-appPanelMuted)] pl-2 text-xs"},Mo="tool-button inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",zh={__name:"TiptapImportedTextBlockView",props:Yo,setup(e){const t=e,{t:n}=Lt(),o=q(()=>{var g;return Ih(((g=t.node)==null?void 0:g.content)||[])}),s=q(()=>{var g,f;return String(((f=(g=t.node)==null?void 0:g.attrs)==null?void 0:f.fileName)||n("blockEditor.unnamedFile"))}),r=q(()=>{const g=Lh(o.value);return n("blockEditor.stats",g)}),l=q(()=>n("blockEditor.fileSummary",{name:s.value,stats:r.value})),u=q(()=>{const g=String(o.value||"").replace(/\r\n/g,`
44
+ `),f=g.split(`
45
+ `),P=[];let ee=0;for(const K of f){const V=K.trimEnd(),O=V.length?V:"";if(!(!O&&P[P.length-1]==="")&&(P.push(O),ee+=O.length,P.length>=4||ee>=220))break}const v=P.join(`
46
+ `).trim(),B=g.trim();return{text:v,truncated:P.length<f.length||v.length<B.length}}),m=`${Mo} tool-button-danger-subtle`;function k(g){g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),d())}function d(){var g,f,P;(P=t.updateAttributes)==null||P.call(t,{collapsed:!((f=(g=t.node)==null?void 0:g.attrs)!=null&&f.collapsed)}),Qs(t.editor)}function T(){var v;const{editor:g,getPos:f,node:P}=t;if(!g||typeof f!="function"||!P)return;const ee=f();g.chain().focus().insertContentAt({from:ee,to:ee+P.nodeSize},{type:Mt.TEXT_BLOCK,attrs:{clientId:String(((v=P.attrs)==null?void 0:v.clientId)||"")},content:Eh(o.value)}).run(),Qs(t.editor)}function h(){var g;(g=t.deleteNode)==null||g.call(t),Qs(t.editor)}return(g,f)=>(p(),Ee(a(Jo),{class:"group relative","data-promptx-node":"imported_text"},{default:rt(()=>[ue(Va,{selected:g.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:rt(({actionsStateClass:P})=>{var ee,v,B,K;return[i("div",Mh,[i("div",{class:"min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((ee=g.node.attrs)!=null&&ee.collapsed)),onClick:d,onKeydown:k},[i("p",Rh,[ue(a(so),{class:"h-3.5 w-3.5 shrink-0"}),Ln(" "+w(a(n)("blockEditor.file")),1)])],40,Bh),i("div",{"data-promptx-imported-actions":"",class:Te(["col-start-2 row-start-1 flex shrink-0 flex-wrap items-center justify-end gap-1 self-start transition",P])},[i("button",{type:"button",class:Te(Mo),contenteditable:"false",onClick:d},[ue(a(Go),{class:Te(["h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5",(v=g.node.attrs)!=null&&v.collapsed?"rotate-180":""])},null,8,["class"]),i("span",null,w((B=g.node.attrs)!=null&&B.collapsed?a(n)("blockEditor.expand"):a(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:Te(Mo),contenteditable:"false",onClick:T},[ue(a(so),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(a(n)("blockEditor.convertToText")),1)]),i("button",{type:"button",class:Te(m),contenteditable:"false",onClick:h},[ue(a(po),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(a(n)("blockEditor.delete")),1)])],2),i("div",{class:"col-span-2 min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((K=g.node.attrs)!=null&&K.collapsed)),onClick:d,onKeydown:k},[i("p",Oh,w(l.value),1)],40,Nh)])]}),default:rt(()=>{var P,ee;return[ln(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":a(n)("blockEditor.expand"),onClick:d,onKeydown:k},[i("div",Uh,w(u.value.text||a(n)("blockEditor.emptyContent")),1),u.value.truncated?(p(),b("div",jh)):de("",!0),u.value.truncated?(p(),b("span",Vh,"...")):de("",!0)],40,Fh),[[eo,(P=g.node.attrs)==null?void 0:P.collapsed]]),ln(ue(a(oa),{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),[[eo,!((ee=g.node.attrs)!=null&&ee.collapsed)]])]}),_:1},8,["selected"])]),_:1}))}},Hh={class:"flex min-w-0 items-center justify-between gap-3"},qh={class:"theme-heading min-w-0 inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Kh={class:"mx-auto flex w-full max-w-[720px] justify-center px-4 py-4"},Wh=["src","alt"],Gh="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]",Xh={__name:"TiptapImageBlockView",props:Yo,setup(e){const t=e,{t:n}=Lt();function o(){var r,l;typeof window>"u"||window.dispatchEvent(new CustomEvent("promptx:tiptap-image-preview",{detail:{src:String(((l=(r=t.node)==null?void 0:r.attrs)==null?void 0:l.src)||"")}}))}function s(){var r;(r=t.deleteNode)==null||r.call(t),Qs(t.editor)}return(r,l)=>(p(),Ee(a(Jo),{class:"group","data-promptx-node":"image"},{default:rt(()=>[ue(Va,{selected:r.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:rt(({actionsStateClass:u})=>[i("div",Hh,[i("div",qh,[ue(a(na),{class:"h-3.5 w-3.5 shrink-0"}),Ln(" "+w(a(n)("blockEditor.image")),1)]),i("div",{class:Te(["shrink-0 transition",u])},[i("button",{type:"button",class:Te(Gh),contenteditable:"false",onClick:s},[ue(a(po),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(a(n)("blockEditor.delete")),1)])],2)])]),default:rt(()=>{var u;return[i("div",Kh,[i("button",{type:"button",class:"inline-flex cursor-zoom-in justify-center",contenteditable:"false",onClick:o},[i("img",{src:(u=r.node.attrs)==null?void 0:u.src,alt:a(n)("blockEditor.insertedImageAlt"),class:"max-h-[380px] w-auto max-w-full object-contain"},null,8,Wh)])])]}),_:1},8,["selected"])]),_:1}))}},Yh=["accept"],Nr=10*1024*1024,Or=2*1024*1024,Fr=8*1024*1024,Jh=1500,Qh={__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:r}=Lt(),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"]),u=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"]),m=["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(","),k=j(null),d=j(null),T=j(""),h=j(ze()),g=j(null),f=j(null),P=j(!1),ee=j(0),v=q(()=>Kn(o.modelValue)),B=q(()=>v.value.filter($=>($==null?void 0:$.type)===Pt.IMAGE&&String($.content||"").trim()).map($=>String($.content||"").trim()));let K=xs(v.value);function V($=X.value){if(!$)return!1;const I=Dh($.getJSON()),oe=xs(I);return oe===K?!1:(K=oe,s("update:modelValue",I),!0)}const O=Ai.extend({name:Mt.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return wo(_h)}}),se=fr.create({name:Mt.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:$}){return["div",{...$,"data-type":"promptx-imported-text-block"}]},addNodeView(){return wo(zh)}}),A=fr.create({name:Mt.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:$}){return["div",{...$,"data-type":"promptx-image-block"}]},addNodeView(){return wo(Xh)}}),X=Ii({extensions:[$i.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}),O,se,A],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown($,I){return Qa(I,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:fe()})?(I.preventDefault(),I.stopPropagation(),s("send-request"),!0):!I.shiftKey&&!I.altKey&&(I.metaKey||I.ctrlKey)&&String(I.key||"").toLowerCase()==="k"?kt():gt(I)}},content:zs(v.value),onCreate({editor:$}){it($)},onFocus({editor:$}){P.value=!0,it($)},onBlur(){P.value=!1},onSelectionUpdate({editor:$}){it($)},onUpdate({editor:$}){ee.value=Date.now(),V($),it($)}});$e(X,$=>{if(!$)return;const I=Kn(o.modelValue);K=xs(I),$.commands.setContent(zs(I),!1)},{immediate:!0}),$e(()=>o.modelValue,$=>{const I=X.value;if(!I){K=xs(Kn($));return}const oe=Kn($),Ie=xs(oe);Ie!==K&&(K=Ie,I.commands.setContent(zs(oe),!1))},{deep:!0});function ge($){const I=String($||"").trim();I&&s("file-feedback",I)}function Se($){const I=String(($==null?void 0:$.name)||"").trim().toLowerCase();return I.includes(".")?`.${I.split(".").pop()}`:""}function L($,I){return String(($==null?void 0:$.name)||"").trim()||r(I)}function ne($){const I=Math.max(0,Number($)||0);return I>=1024*1024?`${(I/(1024*1024)).toFixed(I>=10*1024*1024?0:1)} MB`:I>=1024?`${Math.round(I/1024)} KB`:`${I} B`}function le($){if(!$)return!1;const I=String($.type||"").toLowerCase(),oe=Se($);return I.startsWith("text/")||l.has(oe)||u.has(I)}function te($){if(!$)return!1;const I=String($.name||"").toLowerCase(),oe=String($.type||"").toLowerCase();return I.endsWith(".pdf")||oe==="application/pdf"}function ye($){const I=Array.from($||[]).filter(Boolean),oe={imageFiles:[],textFiles:[],pdfFiles:[]},Ie=[],Re=[];return I.forEach(De=>{if(De.type.startsWith("image/")){if(De.size>Nr){Re.push({name:L(De,"blockEditor.unnamedImage"),limit:ne(Nr)});return}oe.imageFiles.push(De);return}if(te(De)){if(De.size>Fr){Re.push({name:L(De,"blockEditor.unnamedPdf"),limit:ne(Fr)});return}oe.pdfFiles.push(De);return}if(le(De)){if(De.size>Or){Re.push({name:L(De,"blockEditor.unnamedFile"),limit:ne(Or)});return}oe.textFiles.push(De);return}Ie.push(L(De,"blockEditor.unnamedFile"))}),{...oe,unsupportedFiles:Ie,oversizedFiles:Re}}function C({unsupportedFiles:$=[],oversizedFiles:I=[]}={}){var oe;$.length&&ge(r("blockEditor.unsupportedFiles",{names:$.slice(0,3).join("、"),extra:Math.max(0,$.length-3)})),I.length&&ge(r("blockEditor.oversizedFiles",{names:I.slice(0,2).map(Ie=>Ie.name).join("、"),extra:Math.max(0,I.length-2),limit:((oe=I[0])==null?void 0:oe.limit)||""}))}function W($){const{imageFiles:I,textFiles:oe,pdfFiles:Ie,unsupportedFiles:Re,oversizedFiles:De}=ye($);return C({unsupportedFiles:Re,oversizedFiles:De}),oe.length&&s("import-text-files",oe),Ie.length&&s("import-pdf-files",Ie),I.length&&s("upload-files",I),I.length+oe.length+Ie.length>0}function D($){const I=[...$.clipboardData.items].filter(oe=>oe.kind==="file").map(oe=>oe.getAsFile()).filter(Boolean);I.length&&($.preventDefault(),W(I))}function Ae($){$.preventDefault(),W($.dataTransfer.files)}function Pe($){const I=X.value;if(!I)return;const oe=$.target instanceof Element?$.target:null,Ie=$.currentTarget instanceof Element?$.currentTarget:null,Re=I.view.dom instanceof Element?I.view.dom:null;!oe||!Ie||!Re||oe.closest('button, input, textarea, select, a, [contenteditable="false"]')||!Ie.contains(oe)||oe.closest("[data-promptx-node]")||!(oe===Ie||oe===Re||Ie.contains(oe))||($.preventDefault(),Qe())}function Ne($){W($.target.files),$.target.value=""}function Je(){var $;($=k.value)==null||$.click()}function Qe(){const $=X.value;$&&$.chain().focus("end").run()}function We(){var oe,Ie;const $=X.value;if(!$)return!1;(Ie=(oe=$.view.domObserver)==null?void 0:oe.flush)==null||Ie.call(oe);const I=V($);return I&&(ee.value=Date.now()),it($),I}function be($=[]){const I=X.value;!I||!$.length||I.chain().focus().insertContent($).run()}function H($=[]){be(za($))}function Z($=[]){H($)}function me($=[]){H($)}function Ce(){const $=X.value;$&&$.commands.setContent(zs([os("")]),!0)}function fe(){var $,I;return!!((I=($=X.value)==null?void 0:$.view)!=null&&I.composing)}function Me(){var $;return fe()||P.value||($=X.value)!=null&&$.isFocused?!0:Date.now()-ee.value<Jh}function he(){var Ie;const $=X.value;if(!$)return!1;const I=$.state.selection,oe=I.$from.nodeAfter||I.$from.parent;return((Ie=oe==null?void 0:oe.type)==null?void 0:Ie.name)===Mt.IMPORTED_TEXT_BLOCK}function Be($){var oe;const I=String(((oe=$==null?void 0:$.detail)==null?void 0:oe.src)||"").trim();I&&(T.value=I)}function ze(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function Le($=null,I=null){return!$||!I?!1:$.start===I.start&&$.end===I.end&&$.query===I.query&&$.clientId===I.clientId}function wt(){g.value=null}function Ye($={}){const{suppressCurrent:I=!1}=$,oe=h.value;I&&oe.open&&(f.value={start:oe.start,end:oe.end,query:oe.query,clientId:oe.clientId}),h.value=ze(),wt()}function bt(){Ye({suppressCurrent:!0})}function Ge($=X.value){var Ze,Ue,_t;if(!$)return null;const I=$.state.selection;if(!I.empty)return null;const{$from:oe,from:Ie}=I,Re=((Ue=(Ze=oe.parent)==null?void 0:Ze.type)==null?void 0:Ue.name)||"";if(![Mt.TEXT_BLOCK,Mt.IMPORTED_TEXT_BLOCK].includes(Re))return null;const De=oe.parent.textBetween(0,oe.parentOffset,`
47
+ `,"\0");return{from:Ie,node:oe.parent,nodeTypeName:Re,nodeStart:oe.start(),parentOffset:oe.parentOffset,clientId:String(((_t=oe.parent.attrs)==null?void 0:_t.clientId)||""),textBefore:De}}function lt($=h.value.end){const I=X.value;if(typeof $=="object"&&$!==null&&($=h.value.end),!I||!h.value.open||$<0){wt();return}try{const oe=I.view.coordsAtPos($);g.value={left:oe.left,right:oe.left,top:oe.bottom,bottom:oe.bottom,width:0,height:0}}catch{wt()}}function it($=X.value){const I=Ge($),oe=h.value;if(oe.open&&oe.trigger==="shortcut"){if(!I||I.clientId!==oe.clientId||I.from<oe.start){Ye();return}const Ue=$.state.doc.textBetween(oe.start,I.from,`
48
+ `,"\0");if(/\s/.test(Ue)){Ye();return}f.value=null,h.value={...oe,end:I.from,query:Ue},lt(I.from);return}if(!I){Ye();return}const Ie=I.textBefore.lastIndexOf("@");if(Ie<0){Ye();return}const Re=I.textBefore.slice(Ie+1);if(/\s/.test(Re)){Ye();return}const De=I.nodeStart+Ie,Ze=I.from;Le(f.value,{start:De,end:Ze,query:Re,clientId:I.clientId})||(f.value=null,h.value={open:!0,start:De,end:Ze,query:Re,trigger:"mention",blockType:I.nodeTypeName,clientId:I.clientId},lt(Ze))}function kt(){const $=X.value,I=Ge($);return!$||!I?!1:(f.value=null,h.value={open:!0,start:I.from,end:I.from,query:"",trigger:"shortcut",blockType:I.nodeTypeName,clientId:I.clientId},lt(I.from),!0)}function pt($){const I=X.value,oe=String(($==null?void 0:$.path)||"").trim(),Ie=h.value;if(!I||!oe||Ie.start<0||Ie.end<Ie.start)return Ye(),!1;const Re=Ie.trigger==="shortcut"?`${oe} `:`@${oe} `,De=Ie.start+Re.length;return I.chain().focus().command(({tr:Ze,dispatch:Ue})=>(Ze.insertText(Re,Ie.start,Ie.end),Ze.setSelection(si.create(Ze.doc,De)),Ue==null||Ue(Ze),!0)).run(),ee.value=Date.now(),f.value=null,Ye(),!0}function gt($){var I,oe,Ie,Re,De,Ze,Ue,_t,yt,Dt;if(!h.value.open)return!1;if($.key==="Escape")return bt(),!0;if($.key==="ArrowDown")return!!((oe=(I=d.value)==null?void 0:I.moveActive)!=null&&oe.call(I,1));if($.key==="ArrowUp")return!!((Re=(Ie=d.value)==null?void 0:Ie.moveActive)!=null&&Re.call(Ie,-1));if(h.value.query&&($.key==="ArrowLeft"||$.key==="ArrowRight"))return!1;if($.key==="ArrowRight"){const et=(Ze=(De=d.value)==null?void 0:De.expandActiveDirectory)==null?void 0:Ze.call(De);return et&&typeof et.then=="function"?(et.catch(()=>{}),!0):!!et}return $.key==="ArrowLeft"?!!((_t=(Ue=d.value)==null?void 0:Ue.collapseActiveDirectory)!=null&&_t.call(Ue)):!$.shiftKey&&!$.altKey&&!$.metaKey&&!$.ctrlKey&&$.key==="Enter"?!!((Dt=(yt=d.value)==null?void 0:yt.confirmActive)!=null&&Dt.call(yt)):!1}return kn(()=>{window.addEventListener("promptx:tiptap-image-preview",Be),window.addEventListener("resize",lt),window.addEventListener("scroll",lt)}),Nt(()=>{window.removeEventListener("promptx:tiptap-image-preview",Be),window.removeEventListener("resize",lt),window.removeEventListener("scroll",lt)}),$e(()=>o.codexSessionId,()=>{Ye()}),t({clearContent:Ce,flushPendingInput:We,focusEditor:Qe,insertBlocks:H,insertImportedBlocks:Z,insertUploadedBlocks:me,isComposing:fe,isEditing:Me,isImportedBlockActive:he,openFilePicker:Je}),($,I)=>(p(),b("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:Ae,onDragover:I[1]||(I[1]=at(()=>{},["prevent"])),onPaste:D},[i("input",{ref_key:"fileInputRef",ref:k,class:"hidden",type:"file",accept:a(m),multiple:"",onChange:Ne},null,40,Yh),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:Pe},[a(X)?(p(),Ee(a(Pi),{key:0,editor:a(X),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):de("",!0)],32),ue(No,{modelValue:T.value,"onUpdate:modelValue":I[0]||(I[0]=oe=>T.value=oe),images:B.value},null,8,["modelValue","images"]),ue(Th,{ref_key:"mentionPickerRef",ref:d,open:h.value.open&&!!g.value,"session-id":e.codexSessionId,query:h.value.query,"anchor-rect":g.value,onClose:bt,onSelect:pt},null,8,["open","session-id","query","anchor-rect"])],32))}},Zh={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},Ur={__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,r=j(null),{t:l}=Lt(),u=q({get:()=>o.modelValue,set:v=>s("update:modelValue",v)});function m(){var v,B;(B=(v=r.value)==null?void 0:v.openFilePicker)==null||B.call(v)}function k(){var v,B;(B=(v=r.value)==null?void 0:v.focusEditor)==null||B.call(v)}function d(){var v,B;return((B=(v=r.value)==null?void 0:v.flushPendingInput)==null?void 0:B.call(v))||!1}function T(v){var B,K;(K=(B=r.value)==null?void 0:B.insertBlocks)==null||K.call(B,v)}function h(v){var B,K;(K=(B=r.value)==null?void 0:B.insertImportedBlocks)==null||K.call(B,v)}function g(v){var B,K;(K=(B=r.value)==null?void 0:B.insertUploadedBlocks)==null||K.call(B,v)}function f(){var v,B;return((B=(v=r.value)==null?void 0:v.isImportedBlockActive)==null?void 0:B.call(v))||!1}function P(){var v,B;return((B=(v=r.value)==null?void 0:v.isComposing)==null?void 0:B.call(v))||!1}function ee(){var v,B;return((B=(v=r.value)==null?void 0:v.isEditing)==null?void 0:B.call(v))||!1}return t({focusEditor:k,flushPendingInput:d,insertBlocks:T,insertImportedBlocks:h,insertUploadedBlocks:g,isComposing:P,isEditing:ee,isImportedBlockActive:f,openFilePicker:m}),(v,B)=>e.loading&&!e.modelValue.length?(p(),b("section",Zh,w(a(l)("workbench.loadingTaskContent")),1)):(p(),Ee(Qh,{key:1,ref_key:"blockEditorRef",ref:r,modelValue:u.value,"onUpdate:modelValue":B[0]||(B[0]=K=>u.value=K),"codex-session-id":e.codexSessionId,"send-behavior":e.sendBehavior,onUploadFiles:B[1]||(B[1]=K=>s("upload-files",K)),onImportTextFiles:B[2]||(B[2]=K=>s("import-text-files",K)),onImportPdfFiles:B[3]||(B[3]=K=>s("import-pdf-files",K)),onFileFeedback:B[4]||(B[4]=K=>s("file-feedback",K)),onClearRequest:B[5]||(B[5]=K=>s("clear-request")),onSendRequest:B[6]||(B[6]=K=>s("send-request"))},null,8,["modelValue","codex-session-id","send-behavior"]))}},ev={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},tv={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},nv={class:"flex items-center gap-2"},sv=["title","aria-label"],ov={class:"min-w-0 flex-1"},rv=["value","placeholder"],av=["disabled"],iv={class:"truncate"},lv={__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}=Lt();return(s,r)=>(p(),b("section",ev,[i("div",tv,[i("div",nv,[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:a(o)("workbench.tasks"),"aria-label":a(o)("workbench.tasks"),onClick:r[0]||(r[0]=l=>n("back"))},[ue(a(Si),{class:"h-3.5 w-3.5"})],8,sv),i("div",ov,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(p(),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||a(o)("workbench.untitledTask"),onInput:r[1]||(r[1]=l=>n("update:titleInputValue",l.target.value)),onKeydown:[r[2]||(r[2]=un(at(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=un(at(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,rv)):(p(),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:r[5]||(r[5]=l=>n("begin-edit"))},[i("span",iv,w(e.title||a(o)("workbench.untitledTask")),1),ue(a(As),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,av))])])])]))}},uv={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},cv={class:"workbench-panel-header theme-divider border-b px-4 py-4"},dv={class:"flex items-center justify-between gap-3"},fv={class:"flex min-h-8 items-center"},pv={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},mv=["title"],gv=["disabled","title"],hv={class:"whitespace-nowrap"},vv={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},yv={key:0,class:"theme-empty-state px-3 py-4 text-sm"},Sv=["onClick"],wv={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},xv={key:1,class:"absolute right-2 top-2 h-2.5 w-2.5 rounded-full bg-[var(--theme-danger)] shadow-[0_0_0_2px_var(--theme-appPanel)]","aria-hidden":"true"},bv={class:"flex items-start justify-between gap-3"},kv={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},Tv=["title","aria-label"],_v={class:"flex h-5 min-w-0 flex-1 items-center"},Cv=["value","placeholder"],Ev=["title","onClick"],Av={class:"min-w-0 truncate"},Iv={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},$v={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},Pv={class:"mt-2 flex items-center justify-between gap-3"},Dv={class:"min-w-0 text-[11px] opacity-70"},Lv={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Mv={class:"theme-divider border-t px-3 py-3"},Bv={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},Rv={class:"min-w-0 break-words"},Nv={class:"grid grid-cols-2 gap-2"},Ov=["disabled","title"],Fv={class:"whitespace-nowrap"},Uv=["disabled","title"],jv={class:"whitespace-nowrap"},Vv={__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}=Lt(),r=j([]);$e(()=>n.tasks,h=>{r.value=Array.isArray(h)?[...h]:[]},{immediate:!0});function l(h){return h.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":h.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function u(){return"theme-status-warning"}function m(h){const g=new Date(h.updatedAt);return Number.isNaN(g.getTime())?"":Gr(g.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function k(h){var g,f;return!!((g=h==null?void 0:h.workspaceDiffSummary)!=null&&g.supported&&((f=h==null?void 0:h.workspaceDiffSummary)!=null&&f.fileCount))}function d(h){return h.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function T(h){if(n.mobile)return;const g=Number(h==null?void 0:h.oldIndex),f=Number(h==null?void 0:h.newIndex);!Number.isInteger(g)||!Number.isInteger(f)||g===f||o("reorder-task",r.value.map(P=>String((P==null?void 0:P.slug)||"").trim()).filter(Boolean))}return(h,g)=>(p(),b("aside",uv,[i("div",cv,[i("div",dv,[i("div",fv,[i("div",pv,[ue(a(wi),{class:"h-4 w-4"}),i("span",null,w(a(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:a(s)("workbench.settings"),onClick:g[0]||(g[0]=f=>o("open-settings"))},[ue(a(xi),{class:"h-4 w-4"}),i("span",{class:Te(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},w(a(s)("workbench.settings")),3)],8,mv)]),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?a(s)("workbench.creatingTask"):a(s)("workbench.createTask"),onClick:g[1]||(g[1]=f=>o("create-task"))},[ue(a(no),{class:"h-4 w-4"}),i("span",hv,w(e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask")),1)],8,gv)]),i("div",vv,[e.loadingTasks&&!e.tasks.length?(p(),b("div",yv,w(a(s)("workbench.loadingTasks")),1)):(p(),Ee(a(bi),{key:1,modelValue:r.value,"onUpdate:modelValue":g[8]||(g[8]=f=>r.value=f),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:T},{default:rt(()=>[(p(!0),b(ft,null,vt(r.value,f=>{var P,ee;return p(),b("article",{key:f.slug,class:Te(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(f)]),onClick:v=>o("select-task",f.slug)},[f.slug===e.currentTaskSlug?(p(),b("span",wv)):de("",!0),f.hasUnreadUpdate?(p(),b("span",xv)):de("",!0),i("div",bv,[i("div",kv,[e.mobile?de("",!0):(p(),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:a(s)("workbench.dragToReorder"),"aria-label":a(s)("workbench.dragToReorder"),tabindex:"-1",onClick:g[2]||(g[2]=at(()=>{},["stop"]))},[ue(a(ki),{class:"h-3.5 w-3.5"})],8,Tv)),i("div",_v,[f.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===f.slug?(p(),b("input",{key:0,value:e.draftTitle,type:"text",maxlength:"140","data-task-title-input":"current",class:"flex h-5 w-full items-center 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||a(s)("workbench.untitledTask"),onClick:g[3]||(g[3]=at(()=>{},["stop"])),onInput:g[4]||(g[4]=v=>o("update:draftTitle",v.target.value)),onKeydown:[g[5]||(g[5]=un(at(v=>v.target.blur(),["prevent"]),["enter"])),g[6]||(g[6]=un(at(v=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:g[7]||(g[7]=v=>o("title-blur"))},null,40,Cv)):(p(),b("button",{key:1,type:"button",class:Te(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",f.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:f.displayTitle,onClick:at(v=>o("title-click",f.slug),["stop"])},[(P=f.automation)!=null&&P.enabled?(p(),Ee(a(to),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):de("",!0),i("span",Av,w(f.displayTitle),1)],10,Ev))])]),i("div",Iv,[f.sending?(p(),b("span",{key:0,class:Te(["inline-flex items-center gap-1.5 rounded-sm border border-dashed px-1.5 py-0.5",u()])},[g[11]||(g[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(a(s)("workbench.running")),1)],2)):de("",!0)])]),i("div",$v,w(f.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",Pv,[i("div",Dv,w(m(f)),1),i("div",Lv,[k(f)?(p(),b("span",{key:0,class:Te(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",d(f)])},[i("span",null,w(a(s)("workbench.filesCount",{count:((ee=f.workspaceDiffSummary)==null?void 0:ee.fileCount)||0})),1)],2)):de("",!0)])])],10,Sv)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",Mv,[e.error?(p(),b("div",Bv,[ue(a(Xo),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",Rv,w(e.error),1)])):de("",!0),i("div",Nv,[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:a(s)("workbench.editTask"),onClick:g[9]||(g[9]=f=>o("edit-task"))},[ue(a(As),{class:"h-4 w-4"}),i("span",Fv,w(a(s)("workbench.editTask")),1)],8,Ov),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?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask"),onClick:g[10]||(g[10]=f=>o("delete-task"))},[ue(a(po),{class:"h-4 w-4"}),i("span",jv,w(e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask")),1)],8,Uv)])])]))}},jr=Xr(Vv,[["__scopeId","data-v-200c2c76"]]),zv={class:"min-w-0"},Hv={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},qv={class:"theme-muted-text mt-1 text-xs leading-5"},Kv={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},Wv={class:"theme-muted-text"},Gv={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},Xv={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},Yv={class:"space-y-3"},Jv={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},Qv={class:"min-w-0 flex-1"},Zv={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},ey={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},ty={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},ny={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},sy={class:"rounded-sm border border-dashed px-2 py-1"},oy={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},ry={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},ay={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},iy={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},ly=["onClick"],uy=["onClick"],cy={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},dy={__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}=Lt(),r=q(()=>(n.items||[]).map(u=>{var f;const m=Array.isArray(u==null?void 0:u.blocks)?u.blocks:[],k=((f=m.find(P=>["text","imported_text"].includes(String((P==null?void 0:P.type)||""))&&String((P==null?void 0:P.content)||"").trim()))==null?void 0:f.content)||"",d=String(k||"").replace(/\s+/g," ").trim().slice(0,120),T=m.filter(P=>String((P==null?void 0:P.type)||"")==="image").length,h=m.filter(P=>String((P==null?void 0:P.type)||"")==="imported_text").length,g=m.filter(P=>String((P==null?void 0:P.type)||"")==="text"&&String((P==null?void 0:P.content)||"").trim()).length;return{...u,blockCount:m.length,imageCount:T,importedCount:h,preview:d||(T?s("todoDialog.imagePreview",{count:T}):s("todoDialog.noPreview")),textCount:g,timeLabel:l(u==null?void 0:u.createdAt)}}));function l(u=""){const m=Date.parse(String(u||""));if(!m)return s("todoDialog.justAdded");try{return new Intl.DateTimeFormat(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(m))}catch{return String(u||"")}}return(u,m)=>(p(),Ee(mo,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-3xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"px-5 py-4","body-class":"min-h-0 flex flex-1 flex-col overflow-hidden",onClose:m[0]||(m[0]=k=>o("close"))},{title:rt(()=>[i("div",zv,[i("div",Hv,[ue(a(ta),{class:"h-4 w-4"}),i("span",null,w(a(s)("todoDialog.title")),1)]),i("p",qv,w(a(s)("todoDialog.intro")),1)])]),default:rt(()=>[i("div",Kv,[i("span",Wv,w(a(s)("todoDialog.summary",{count:r.value.length})),1),i("span",Gv,w(a(s)("todoDialog.summaryHint")),1)]),r.value.length?(p(),b("div",Xv,[i("div",Yv,[(p(!0),b(ft,null,vt(r.value,k=>(p(),b("article",{key:k.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",Jv,[i("div",Qv,[i("div",Zv,[i("span",null,w(a(s)("todoDialog.itemTitle")),1),i("span",ey,[ue(a(to),{class:"h-3.5 w-3.5"}),Ln(" "+w(k.timeLabel),1)])]),i("p",ty,w(k.preview),1),i("div",ny,[i("span",sy,w(a(s)("todoDialog.blockCount",{count:k.blockCount})),1),k.textCount?(p(),b("span",oy,[ue(a(so),{class:"h-3.5 w-3.5"}),Ln(" "+w(a(s)("todoDialog.textCount",{count:k.textCount})),1)])):de("",!0),k.importedCount?(p(),b("span",ry,[ue(a(so),{class:"h-3.5 w-3.5"}),Ln(" "+w(a(s)("todoDialog.importedCount",{count:k.importedCount})),1)])):de("",!0),k.imageCount?(p(),b("span",ay,[ue(a(na),{class:"h-3.5 w-3.5"}),Ln(" "+w(a(s)("todoDialog.imageCount",{count:k.imageCount})),1)])):de("",!0)])]),i("div",iy,[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:d=>o("use",k.id)},[ue(a(Ti),{class:"h-4 w-4"}),i("span",null,w(a(s)("todoDialog.use")),1)],8,ly),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:d=>o("delete",k.id)},[ue(a(po),{class:"h-4 w-4"}),i("span",null,w(a(s)("todoDialog.delete")),1)],8,uy)])])]))),128))])])):(p(),b("div",cy,w(a(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},fy={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},py={__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"?Xo:s==="error"?_i:s==="info"?Ci:Ei}return(s,r)=>(p(),Ee(Ls,{to:"body"},[i("div",fy,[ue(Jr,{"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:rt(()=>[e.message?(p(),b("div",{key:0,class:Te(["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)])},[(p(),Ee(Rn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,w(e.message),1)],2)):de("",!0)]),_:1})])]))}};function my(e,t=!1){const n=j(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return kn(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;o=window.matchMedia(e),r(o.matches);const l=u=>{r(u.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))}),Nt(()=>{s()}),{matches:n}}const gy="(max-width: 1023px)",Zs="promptxWorkbenchMobileView";function Bo(e){return(e==null?void 0:e[Zs])==="detail"}function hy({currentTaskSlug:e}){const{matches:t}=my(gy),n=j("tasks"),o=j("activity");function s(T="tasks"){if(typeof window>"u")return;const h={...window.history.state||{}};T==="detail"?h[Zs]="detail":delete h[Zs],window.history.replaceState(h,"")}function r(){if(typeof window>"u")return;const T={...window.history.state||{},[Zs]:"detail"};window.history.pushState(T,"")}function l(T=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=Bo(T)?"detail":"tasks"}function u(T){t.value=!!T,l(typeof window>"u"?null:window.history.state)}function m(T={}){const{pushHistory:h=!0}=T;if(n.value="detail",!!t.value){if(h){r();return}s("detail")}}function k(T={}){const{useHistory:h=!0}=T;if(!t.value){n.value="tasks";return}if(h&&typeof window<"u"&&Bo(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function d(T){t.value&&(n.value=Bo(T.state)&&e.value?"detail":"tasks")}return kn(()=>{typeof window>"u"||window.addEventListener("popstate",d)}),Nt(()=>{typeof window<"u"&&window.removeEventListener("popstate",d)}),$e(t,T=>{u(T)},{immediate:!0}),$e(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:m,isMobileLayout:t,leaveMobileDetail:k,mobileDetailTab:o,mobileView:n}}const io="PromptX";function vy(e=""){const t=String(a(e)||"").trim();return t?`${io} (${t})`:io}function yy(e="",t={}){oi(()=>{if(typeof document>"u")return;const o=String(a(e)||"").trim();document.title=a(t.raw)?o||io:vy(o)}),Nt(()=>{typeof document>"u"||(document.title=io)})}const us="success";function Sy(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||us).trim()||us,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:us,duration:t}}function wy(e=2200){const t=j(""),n=j(us);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=us}function r(l,u=e){const m=Sy(l,u);if(!m.message){s();return}t.value=m.message,n.value=m.type,o&&window.clearTimeout(o),o=window.setTimeout(()=>{t.value="",n.value=us,o=null},m.duration)}return Nt(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:r,clearToast:s}}function xy(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 by(e=""){const t=String(e||"").replace(/\r\n/g,`
49
+ `).split(`
50
+ `);for(;t.length&&!String(t[0]||"").trim();)t.shift();for(;t.length&&!String(t[t.length-1]||"").trim();)t.pop();return t.join(`
51
+ `)}function ky(e,t){const n=[];for(const[o,s]of((e==null?void 0:e.blocks)||[]).entries()){if(s.type===Pt.TEXT||s.type===Pt.IMPORTED_TEXT){const r=by(s.content);r&&n.push(r,"");continue}if(s.type===Pt.IMAGE){const r=xy(s.content,t);r&&n.push(r,"")}}return n.join(`
52
+ `).trim()}function Ty(e,t){return ky(e,t)}const Ko="promptx:active-task-slug",_y=150,Cy=1500,Ey=800,lo=500,Ay=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function uo(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 Bn(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 Wt(e=[]){return(e||[]).map(t=>({id:String((t==null?void 0:t.id)||"").trim(),createdAt:String((t==null?void 0:t.createdAt)||""),blocks:Bn((t==null?void 0:t.blocks)||[])}))}function Vr(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:Bn(e.blocks||[]),todoItems:Wt(e.todoItems||[])}}function Ha(e=[]){return Bn(e).filter(t=>(t==null?void 0:t.type)===Pt.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function Iy(e=[]){return Ha(e).length>0}function $y(){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 zr(){return Bn([{type:Pt.TEXT,content:"",meta:{}}])}function Wo(e=[],t=16){return Wi(e,t)||""}function Py(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 Hr(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=Wo(t);if(s)return s;const r=String((e==null?void 0:e.preview)||"").trim();return r?r.slice(0,16):Xe("workbench.untitledTask")}function co(e={}){return!!(e!=null&&e.running)}function Dy(e={},t=!1){return t&&!co(e)?"sending":co(e)?"running":"idle"}function Ly(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function qa(e=""){return Ay.has(String(e||"").trim())}function My(e={},t={}){return!!(String((e==null?void 0:e.codexSessionId)||"").trim()&&qa(t==null?void 0:t.status))}function Ka(e="",t="",n=!1){const o=String(e||"").trim();return!!(o&&o===String(t||"").trim()&&n)}function By(e={},t="",n={}){const o=String(t||"").trim();return!o||Ka(o,n.currentTaskSlug,n.pageFocused)?{unreadMap:e,didMark:!1}:e!=null&&e[o]?{unreadMap:e,didMark:!1}:{unreadMap:{...e||{},[o]:!0},didMark:!0}}function Wa(e={},t=""){const n=String(t||"").trim();if(!n||!(e!=null&&e[n]))return e;const o={...e||{}};return delete o[n],o}function Ry(e={},t={}){return t.pageFocused?Wa(e,t.currentTaskSlug):e}function Ny(e={},t=[]){const n=new Set((t||[]).map(s=>String((s==null?void 0:s.slug)||"").trim()).filter(Boolean)),o={};return Object.entries(e||{}).forEach(([s,r])=>{n.has(s)&&r&&(o[s]=!0)}),o}function Ga(e=null){return typeof e=="string"?{status:e,taskSlug:""}:{status:String((e==null?void 0:e.status)||"").trim(),taskSlug:String((e==null?void 0:e.taskSlug)||"").trim()}}function Xa(e={},t=lo){const n=Math.max(1,Number(t)||lo),o=Object.entries(e||{});return o.length<=n?e:Object.fromEntries(o.slice(-n))}function Oy(e={},t=[],n=lo){const o=new Set((t||[]).map(r=>String((r==null?void 0:r.slug)||"").trim()).filter(Boolean)),s={};return Object.entries(e||{}).forEach(([r,l])=>{const u=Ga(l);u.taskSlug&&o.has(u.taskSlug)&&(s[r]=u)}),Xa(s,n)}function Fy(e={}){const t=String(e.taskSlug||"").trim(),n=e.change||null,o=String((n==null?void 0:n.runId)||"").trim(),s=String((n==null?void 0:n.status)||"").trim(),r=e.unreadMap||{},l=e.notifiedMap||{};if(!t||!o||!qa(s))return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!1};if(Ga(l[o]).status===s)return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!0};const m=Xa({...l,[o]:{taskSlug:t,status:s}},e.maxNotifiedRuns),k=By(r,t,{currentTaskSlug:e.currentTaskSlug,pageFocused:e.pageFocused});return{unreadMap:k.unreadMap,notifiedMap:m,didMark:k.didMark,didDedupe:!1}}function qr(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function Uy(e=[],t=[]){const n=Array.isArray(e)?[...e]:[],o=Array.isArray(t)?t.map(u=>String(u||"").trim()).filter(Boolean):[];if(!o.length)return n;const s=new Map(n.map(u=>{const m=String((u==null?void 0:u.slug)||"").trim();return m?[m,u]:null}).filter(Boolean)),r=o.map(u=>s.get(u)||null).filter(Boolean),l=n.filter(u=>{const m=String((u==null?void 0:u.slug)||"").trim();return m&&!o.includes(m)});return[...r,...l]}function Kr(e=[],t=[]){const n=new Map((e||[]).map(s=>{const r=String((s==null?void 0:s.slug)||"").trim();return r?[r,s]:null}).filter(Boolean));return(t||[]).map(s=>{const r=String((s==null?void 0:s.slug)||"").trim(),l=String((s==null?void 0:s.codexSessionId)||"").trim();if(!r)return s;if(Object.prototype.hasOwnProperty.call(s,"workspaceDiffSummary"))return{...s,workspaceDiffSummary:uo(s.workspaceDiffSummary)};if(!l)return{...s,workspaceDiffSummary:null};const u=n.get(r),m=String((u==null?void 0:u.codexSessionId)||"").trim();return m&&m===l?{...s,workspaceDiffSummary:uo(u.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function jy(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(r=>{const l=String((r==null?void 0:r.slug)||"").trim();return l?[l,r]:null}).filter(Boolean));return o.some(r=>{const l=String((r==null?void 0:r.slug)||"").trim();if(!l)return!0;const u=s.get(l);if(!u)return!0;const m=String((r==null?void 0:r.codexSessionId)||"").trim(),k=String((u==null?void 0:u.codexSessionId)||"").trim();return!!(m!==k||!!(r!=null&&r.running)!=!!(u!=null&&u.running)||m&&!Object.prototype.hasOwnProperty.call(u||{},"workspaceDiffSummary")||m&&(u==null?void 0:u.workspaceDiffSummary)==null)})}function Hs(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(Ko,t);return}window.localStorage.removeItem(Ko)}function Vy(){return typeof window>"u"?"":String(window.localStorage.getItem(Ko)||"").trim()}function zy(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function Hy(){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 ns(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=uo(e.workspaceDiffSummary)),t}function qy(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=cs(),r=Aa(),l=j(null),u=j([]),m=j({}),k=j({}),d=j({}),T=j({}),h=j({}),g=j(""),f=j({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),P=j(!0),ee=j(!1),v=j(!1),B=j(!1),K=j(!1),V=j(!1),O=j(""),se=j(!1),A=j("");let X=null,ge=null,Se=0,L=null,ne=0,le=null;const te=new Set;let ye=null,C=0,W={};const D=q(()=>Wo(f.value.blocks)),Ae=q(()=>Hr({title:f.value.title,autoTitle:f.value.autoTitle,preview:Py(f.value.blocks)},f.value.blocks));function Pe(_,x={}){const F=String(_||"").trim();if(!F)return"";const ae=x.summary||bt(F),ie=x.cachedDraft===void 0?Ge(F):x.cachedDraft,ve=F===g.value;return Object.prototype.hasOwnProperty.call(k.value,F)?String(k.value[F]||"").trim():ve?String(f.value.codexSessionId||(ae==null?void 0:ae.codexSessionId)||"").trim():String((ie==null?void 0:ie.codexSessionId)||(ae==null?void 0:ae.codexSessionId)||"").trim()}const Ne=q(()=>Pe(g.value)),Je=q(()=>Dy(bt(g.value),d.value[g.value])),Qe=q(()=>Je.value!=="idle"),We=q(()=>u.value.some(_=>co(_))||Object.values(d.value).some(Boolean)),be=q(()=>Object.values(T.value).some(Boolean)),H=j(0),Z=q(()=>Iy(f.value.blocks)),me=q(()=>Wt(f.value.todoItems)),Ce=q(()=>Ae.value||Xe("workbench.untitledTask")),fe=q(()=>u.value.map(_=>kt(_)));function Me(_=""){const x=String(_||"").trim();if(!x||x.startsWith("/uploads/"))return x;const F=cs();if(F&&x.startsWith(F))return x.slice(F.length);if(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?\/uploads\//.test(x)){const ae=x.match(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/uploads\/.*)$/);if(ae)return ae[3]}return x}function he(_=""){const x=String(_||"").replace(/\r\n/g,`
53
+ `).split(`
54
+ `);for(;x.length&&!String(x[0]||"").trim();)x.shift();for(;x.length&&!String(x[x.length-1]||"").trim();)x.pop();return x.join(`
55
+ `)}function Be(_=[]){return _.map(x=>({id:Number.isInteger(Number(x==null?void 0:x.id))?Number(x.id):null,type:x==null?void 0:x.type,content:(x==null?void 0:x.type)==="image"?Me(x.content):he(x.content),meta:x!=null&&x.meta?{...x.meta}:{}}))}function ze(_=[]){return(_||[]).map(x=>({id:String((x==null?void 0:x.id)||"").trim(),createdAt:String((x==null?void 0:x.createdAt)||""),blocks:Be((x==null?void 0:x.blocks)||[])}))}function Le(_=f.value.title,x=f.value.autoTitle,F=f.value.lastPromptPreview,ae=f.value.todoItems,ie=f.value.codexSessionId,ve=f.value.blocks){return JSON.stringify({title:String(_||""),autoTitle:String(x||""),lastPromptPreview:String(F||""),todoItems:ze(ae),codexSessionId:String(ie||""),blocks:Be(ve)})}function wt(){return Le()!==A.value}function Ye(){var _,x;return!!((x=(_=l.value)==null?void 0:_.isEditing)!=null&&x.call(_))}function bt(_){return u.value.find(x=>x.slug===_)||null}function Ge(_){return _&&m.value[_]||null}function lt(_,x=""){const F=String(_||"").trim();F&&(W={...W,[F]:String(x||"").trim()})}function it(_=""){var ie;const x=String(_||"").trim();if(!x)return!1;const F=String(((ie=bt(x))==null?void 0:ie.updatedAt)||"").trim(),ae=String(W[x]||"").trim();return!!(F&&ae&&F===ae)}function kt(_){const x=Ge(_.slug),F=_.slug===g.value?f.value.blocks:(x==null?void 0:x.blocks)||[],ae=_.slug===g.value?f.value.title:(x==null?void 0:x.title)??_.title,ie=_.slug===g.value?f.value.autoTitle:(x==null?void 0:x.autoTitle)??_.autoTitle,ve=_.slug===g.value?Wt(f.value.todoItems).length:Wt((x==null?void 0:x.todoItems)||[]).length||Number(_.todoCount||0),ut=_.slug===g.value?f.value.lastPromptPreview||_.lastPromptPreview||"":(x==null?void 0:x.lastPromptPreview)||_.lastPromptPreview||"",Oe=Pe(_.slug,{summary:_,cachedDraft:x});return{..._,title:ae,autoTitle:ie,todoCount:ve,preview:ut,codexSessionId:Oe,sessionSelectionLocked:!!(Oe&&Number(_.codexRunCount||0)>0),sessionSelectionLockReason:Oe&&Number(_.codexRunCount||0)>0?Xe("taskActions.sessionLocked"):"",displayTitle:Hr({title:ae,autoTitle:ie,preview:ut},F),sending:co(_),hasUnreadUpdate:!!T.value[_.slug]}}function pt(_,x={}){const{insertAtStart:F=!1}=x;if(!(_!=null&&_.slug))return;const ae=[...u.value],ie=ae.findIndex(ve=>ve.slug===_.slug);if(ie>=0){ae.splice(ie,1,{...ae[ie],..._}),u.value=ae;return}F?ae.unshift(_):ae.push(_),u.value=ae}function gt(_,x){_&&(m.value={...m.value,[_]:Vr(x)})}function $(_){return _?`${s}/api/tasks/${_}/raw`:`${s}/api/tasks/`}function I(_=""){const x=String(_||"").trim();if(!x)return;const F=bt(x),ae=r.getTaskRunChange(x);if(!F||!(ae!=null&&ae.status))return;const ie=Ly(ae.status);!!F.running!==ie&&pt({...F,running:ie})}function oe(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function Ie(_=""){return Ka(_,g.value,oe())}function Re(_=""){T.value=Wa(T.value,_)}function De(){T.value=Ry(T.value,{currentTaskSlug:g.value,pageFocused:oe()})}function Ze(_=[]){T.value=Ny(T.value,_),h.value=Oy(h.value,_)}function Ue(_=""){const x=String(_||"").trim();if(!x)return;const F=Fy({unreadMap:T.value,notifiedMap:h.value,taskSlug:x,change:r.getTaskRunChange(x),currentTaskSlug:g.value,pageFocused:oe(),maxNotifiedRuns:lo});T.value=F.unreadMap,h.value=F.notifiedMap,F.didMark&&(H.value+=1)}function _t(_,x){d.value={...d.value,[_]:!!x}}function yt(_=u.value){const x={};(_||[]).forEach(F=>{F!=null&&F.slug&&(x[F.slug]=!!F.running)}),d.value=x}function Dt(_,x){_&&(k.value={...k.value,[_]:String(x||"").trim()})}async function et(_,x){const F=String(_||"").trim();if(!F)return;const ae=String(x||"").trim(),ie=bt(F),ve=k.value[F]||(ie==null?void 0:ie.codexSessionId)||"";if(!!(ve&&Number((ie==null?void 0:ie.codexRunCount)||0)>0)&&ae!==ve){O.value=Xe("taskActions.sessionLocked");return}Dt(F,ae);const Oe=Ge(F);Oe&&gt(F,{...Oe,codexSessionId:ae}),ie&&pt({...ie,codexSessionId:ae,workspaceDiffSummary:ae&&ae===ve?ie.workspaceDiffSummary:null}),F===g.value&&(f.value={...f.value,codexSessionId:ae});try{await Nl(F,ae)}catch(Jt){Dt(F,ve),Oe&&gt(F,{...Oe,codexSessionId:ve}),ie&&pt({...ie,codexSessionId:ve}),F===g.value&&(f.value={...f.value,codexSessionId:ve}),O.value=Jt.message}}function Xt(){X&&(window.clearTimeout(X),X=null)}function sn(){L&&(window.clearTimeout(L),L=null)}function Yt(){Xt(),!(ee.value||!g.value)&&(X=window.setTimeout(()=>{Kt({auto:!0,silent:!0})},1500))}function re(){if(!g.value)return;const _=bt(g.value)||{slug:g.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};pt({..._,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:Wt(f.value.todoItems).length,codexSessionId:Ne.value,preview:String(f.value.lastPromptPreview||"")})}function je(_={}){const x=String((_==null?void 0:_.slug)||"").trim();if(!x)return;const F=ns(_);pt(F),lt(x,F.updatedAt||_.updatedAt||""),x===g.value&&(Object.prototype.hasOwnProperty.call(_,"title")&&(f.value.title=String(_.title||"")),Object.prototype.hasOwnProperty.call(_,"autoTitle")&&(f.value.autoTitle=String(_.autoTitle||"")),gt(x,{...f.value}))}function tt(_=[]){const x=new Map((_||[]).map(F=>{const ae=String((F==null?void 0:F.slug)||"").trim();return ae?[ae,uo(F.workspaceDiffSummary)]:null}).filter(Boolean));x.size&&(u.value=u.value.map(F=>x.has(F.slug)?{...F,workspaceDiffSummary:x.get(F.slug)}:F))}async function ot(_=u.value){const x=Array.isArray(_)?_:[],F=x.filter(ie=>String((ie==null?void 0:ie.codexSessionId)||"").trim()),ae=++ne;if(!F.length){u.value=x.map(ie=>Object.prototype.hasOwnProperty.call(ie,"workspaceDiffSummary")?ie:{...ie,workspaceDiffSummary:null});return}try{const ie=await Sl({limit:x.length||30,slugs:F.map(ve=>ve.slug)});if(ae!==ne)return;tt(ie.items||[])}catch{}}function qt(_=""){const x=String(_||"").trim();if(!x)return;const F=r.getTaskRunChange(x),ie=u.value.find(ve=>ve.slug===x);My(ie,F)&&(te.add(x),le&&window.clearTimeout(le),le=window.setTimeout(()=>{le=null;const ve=new Set(te);te.clear();const ut=u.value.filter(Oe=>ve.has(Oe.slug));ot(ut)},Ey))}async function z(_={}){const{silent:x=!1}=_;x||(P.value=!0,O.value="");try{const F=u.value,ae=await yl(),ie=Kr(F,(ae.items||[]).map(ns));u.value=ie,Ze(ie),yt(ie),jy(F,ie)&&ot(ie)}catch(F){x||(O.value=F.message)}finally{x||(P.value=!1)}}async function Q(_=[]){const x=Uy(u.value,_),F=u.value.map(ve=>String((ve==null?void 0:ve.slug)||"").trim()).filter(Boolean),ae=x.map(ve=>String((ve==null?void 0:ve.slug)||"").trim()).filter(Boolean);if(!ae.length||ae.join(",")===F.join(","))return!1;const ie=u.value;u.value=x;try{const ve=await xl(ae);C=Date.now()+Cy;const ut=Kr(ie,(ve.items||[]).map(ns));return u.value=ut,Ze(ut),yt(ut),!0}catch(ve){return u.value=ie,O.value=ve.message,!1}}async function ce(_=""){const x=String(g.value||"").trim(),F=String(_||"").trim();if(!x)return;if(!u.value.some(ie=>ie.slug===x)){if(u.value.length){await Tt(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}g.value="",Hs(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Le("","","",[],"",[]),se.value=!1;return}F&&F!==x||F&&(Ye()||wt()||se.value||K.value||V.value||ee.value||await Tt(x,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function xe(_=""){const x=String(_||"").trim();ye===null?ye=x:ye!==x&&(ye=""),!L&&(L=window.setTimeout(async()=>{const F=ye;ye=null,L=null,await z({silent:!0}),await ce(F||"")},_y))}async function qe(_){const x=await ia(_),F=(x.blocks||[]).map(ie=>({...ie,content:ie.type==="image"?Ks(ie.content):ie.content}));return{state:{title:String(x.title||""),autoTitle:String(x.autoTitle||""),lastPromptPreview:String(x.lastPromptPreview||""),codexSessionId:String(x.codexSessionId||""),blocks:F,todoItems:Wt(x.todoItems||[])},summary:ns({...x,blocks:F}),updatedAt:String(x.updatedAt||"")}}async function Tt(_,x={}){const{focusEditor:F=!1,force:ae=!1,skipIfDirtyOnApply:ie=!1,skipIfEditingOnApply:ve=!1,scrollPanelToBottom:ut=!1}=x,Oe=String(_||"").trim();if(!Oe)return!1;const Jt=++Se;ee.value=!0,O.value="",t();try{const on=String(g.value||"").trim(),Sn=Ge(Oe),In=ae&&Sn&&it(Oe);let Ot=ae&&!In?null:Sn,Qt=null;if(!Ot){const At=await qe(Oe);Ot=(At==null?void 0:At.state)||null,Qt=(At==null?void 0:At.summary)||null,lt(Oe,(At==null?void 0:At.updatedAt)||(Qt==null?void 0:Qt.updatedAt)||"")}return Jt!==Se||ie&&Oe===g.value&&(wt()||se.value)||ve&&Oe===g.value&&Ye()?!1:(g.value=Oe,Hs(Oe),Ie(Oe)&&Re(Oe),f.value=Vr(Ot),gt(Oe,Ot),Qt&&pt(Qt),Dt(Oe,Ot.codexSessionId),A.value=Le(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),se.value=!1,F&&dt(()=>{var At,y;return(y=(At=l.value)==null?void 0:At.focusEditor)==null?void 0:y.call(At)}),(ut||Oe!==on)&&o(),!0)}catch(on){return Jt===Se&&(O.value=on.message),!1}finally{Jt===Se&&(ee.value=!1)}}async function Kt(_={}){const{auto:x=!1,silent:F=!1}=_;return g.value?Le()===A.value?!0:ge||(Xt(),K.value=!0,O.value="",ge=(async()=>{try{const ie=await la(g.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:Wt(f.value.todoItems),codexSessionId:Ne.value,expiry:"none",visibility:"private",blocks:Be(f.value.blocks)}),ve={title:String(ie.title||""),autoTitle:String(ie.autoTitle||""),lastPromptPreview:String(ie.lastPromptPreview||""),todoItems:Wt(ie.todoItems||f.value.todoItems||[]),codexSessionId:Ne.value||String(ie.codexSessionId||"").trim(),blocks:Bn(f.value.blocks)};return gt(g.value,ve),A.value=Le(ve.title,ve.autoTitle,ve.lastPromptPreview,ve.todoItems,ve.codexSessionId,ve.blocks),se.value=!1,pt(ns(ie)),lt(g.value,ie.updatedAt||""),!x&&!F&&n({message:Xe("taskActions.taskSaved"),type:"success"}),!0}catch(ie){return O.value=ie.message,!1}finally{K.value=!1,ge=null,Le()!==A.value&&(se.value=!0,Yt())}})(),ge):!1}async function Ut(){return V.value?(O.value=Xe("taskActions.fileProcessing"),!1):ge||(se.value?Kt({auto:!1,silent:!0}):!0)}async function Bt(){if(!await Ut()&&g.value)return!1;v.value=!0,O.value="";try{const _=await wl({title:"",expiry:"none",visibility:"private"}),x={title:String(_.title||""),autoTitle:String(_.autoTitle||""),lastPromptPreview:String(_.lastPromptPreview||""),codexSessionId:String(_.codexSessionId||""),blocks:Bn(_.blocks||[]),todoItems:Wt(_.todoItems||[])};return gt(_.slug,x),pt(ns(_),{insertAtStart:!0}),await Tt(_.slug,{focusEditor:!0}),n({message:Xe("taskActions.taskCreated"),type:"success"}),!0}catch(_){return O.value=_.message,!1}finally{v.value=!1}}async function Rt(_){const x=String(_||"").trim();!x||x===g.value||!await Ut()||await Tt(x)}async function Tn(){if(g.value){B.value=!0,O.value="";try{const _=g.value;await bl(_),u.value=u.value.filter(ie=>ie.slug!==_);const x={...m.value};delete x[_],m.value=x;const F={...k.value};delete F[_],k.value=F;const ae={...d.value};delete ae[_],d.value=ae,Re(_),u.value.length?await Tt(u.value[0].slug,{focusEditor:!0}):(g.value="",Hs(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Le("","","",[],"",[]),se.value=!1,await Bt())}catch(_){O.value=_.message}finally{B.value=!1}}}function Et(_={}){const{silent:x=!1}=_;g.value&&(f.value={...f.value,blocks:zr()},gt(g.value,f.value),re(),se.value=!0,dt(()=>{var F,ae;(ae=(F=l.value)==null?void 0:F.focusEditor)==null||ae.call(F)}),x||n({message:Xe("taskActions.taskCleared"),type:"info"}))}function gn(){if(!g.value)return!1;const _=Ha(f.value.blocks);return _.length?(f.value={...f.value,blocks:zr(),todoItems:[{id:$y(),createdAt:new Date().toISOString(),blocks:_},...Wt(f.value.todoItems)]},gt(g.value,f.value),re(),se.value=!0,dt(()=>{var x,F;(F=(x=l.value)==null?void 0:x.focusEditor)==null||F.call(x)}),n({message:Xe("taskActions.todoAdded"),type:"success"}),!0):!1}function hn(_=""){const x=String(_||"").trim();if(!g.value||!x)return!1;const F=Wt(f.value.todoItems).filter(ae=>ae.id!==x);return F.length===Wt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:F},gt(g.value,f.value),re(),se.value=!0,!0)}function cn(_=""){const x=String(_||"").trim();if(!g.value||!x)return null;const F=Wt(f.value.todoItems).find(ae=>ae.id===x);return F?(f.value={...f.value,blocks:Bn(F.blocks),todoItems:Wt(f.value.todoItems).filter(ae=>ae.id!==x)},gt(g.value,f.value),re(),se.value=!0,dt(()=>{var ae,ie;(ie=(ae=l.value)==null?void 0:ae.focusEditor)==null||ie.call(ae)}),F):null}async function _n(){var ie;if(await z(),!u.value.length){await Bt();return}const _=zy();if(_){const ve=await Tt(_,{focusEditor:!0,force:!0});if(Hy(),ve)return}const x=((ie=u.value.find(ve=>!!(ve!=null&&ve.running)))==null?void 0:ie.slug)||"",F=Vy(),ae=x||(u.value.some(ve=>ve.slug===F)?F:u.value[0].slug);await Tt(ae,{focusEditor:!0,force:!0})}async function vn(_){var x,F,ae;V.value=!0,O.value="";try{const ie=((F=(x=l.value)==null?void 0:x.isImportedBlockActive)==null?void 0:F.call(x))||!1,ve=[];for(const ut of _){const Oe=await kl(ut);ve.push({type:"image",content:Ks(Oe.url),meta:{}})}(ae=l.value)==null||ae.insertUploadedBlocks(ve),n({message:Xe("taskActions.imageInserted",{count:ve.length,appended:ie}),type:"success"})}catch(ie){O.value=ie.message}finally{V.value=!1}}async function On(_){var x,F,ae;O.value="";try{const ie=((F=(x=l.value)==null?void 0:x.isImportedBlockActive)==null?void 0:F.call(x))||!1,ve=[];for(const ut of _){const Oe=await ut.text();Oe.trim()&&ve.push({type:"imported_text",content:Oe,meta:{fileName:ut.name||Xe("workbench.untitledTask"),collapsed:!0}})}if(!ve.length){n({message:Xe("taskActions.noTextImported"),type:"warning"});return}(ae=l.value)==null||ae.insertImportedBlocks(ve),n({message:Xe("taskActions.importedBlocksInserted",{count:ve.length,appended:ie}),type:"success"})}catch{O.value=Xe("taskActions.textImportFailed")}}async function dn(_){var x;V.value=!0,O.value="";try{let F=0,ae=0;for(const ie of _){const ve=await Tl(ie),ut=(ve.blocks||[]).map(Oe=>({...Oe,content:Oe.type==="image"?Ks(Oe.content):Oe.content}));ut.length&&((x=l.value)==null||x.insertBlocks(ut),F+=ut.length,ae+=Number(ve.pageCount||0))}if(!F){n({message:Xe("taskActions.noPdfContent"),type:"warning"});return}n({message:Xe("taskActions.pdfBlocksInserted",{blockCount:F,pageCount:ae}),type:"success"})}catch(F){O.value=F.message||Xe("taskActions.pdfImportFailed")}finally{V.value=!1}}function yn(_){const x=_===g.value?f.value:Ge(_);return x?Ty({title:String(x.title||""),blocks:Be(x.blocks||[])},$(_)):""}function Cn(_){const x=_===g.value?f.value:Ge(_);return x?Bn(Be(x.blocks||[])):[]}async function En(_){return V.value?(O.value=Xe("taskActions.fileProcessingBeforeSend"),!1):_!==g.value?!0:K.value&&ge?ge:se.value?Kt({auto:!1,silent:!0}):!0}async function An(_){return await En(_)?yn(_):""}function fn(_,x){const F=qr(x);!F||_!==g.value||(f.value.lastPromptPreview=F,gt(g.value,f.value),re())}return $e(f,()=>{if(ee.value||!g.value)return;const _=Wo(f.value.blocks);!String(f.value.title||"").trim()&&_&&_!==f.value.autoTitle&&(f.value.autoTitle=_),gt(g.value,f.value),se.value=Le()!==A.value,re(),se.value&&!K.value&&Yt()},{deep:!0}),$e(g,_=>{_&&(Hs(_),De())}),kn(()=>{typeof window>"u"||(window.addEventListener("focus",De),document.addEventListener("visibilitychange",De))}),Nt(()=>{Xt(),sn(),le&&(window.clearTimeout(le),le=null),te.clear(),typeof window<"u"&&(window.removeEventListener("focus",De),document.removeEventListener("visibilitychange",De))}),$e(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<C||(Ue(r.listSyncTaskSlug.value),I(r.listSyncTaskSlug.value),qt(r.listSyncTaskSlug.value),xe(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:gn,applyTaskSettingsUpdate:je,buildPromptForTask:yn,getPromptBlocksForTask:Cn,buildPromptPreview:qr,clearCurrentTaskContent:Et,createTaskAndSelect:Bt,currentProjectSessionId:Ne,currentTaskSendState:Je,currentTaskAutoTitle:D,currentTaskDisplayTitle:Ae,currentTaskSlug:g,draft:f,editorRef:l,error:O,handleImportPdfFiles:dn,handleImportTextFiles:On,handleTaskSendingChange:_t,handleTaskSessionChange:et,handleUpload:vn,hasCurrentDraftContent:Z,hasAnyTaskSending:We,hasUnsavedChanges:se,hasUnreadTaskUpdates:be,initializeWorkbench:_n,isCurrentTaskSending:Qe,loadingTask:ee,loadingTasks:P,pageTitle:Ce,prepareCodexPromptForTask:An,currentTodoItems:me,removeTodoItem:hn,removeCurrentTask:Tn,reorderTaskList:Q,removingTask:B,renderedTasks:fe,refreshTaskList:z,saveTask:Kt,saving:K,selectTask:Rt,selectedSessionMap:k,sendingTaskMap:d,taskDraftMap:m,tasks:u,unreadNotificationVersion:H,useTodoItem:cn,updateLastPromptPreview:fn,uploading:V,creatingTask:v}}const Ky={class:"flex h-full min-h-0 flex-col overflow-hidden"},Wy={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"},Gy={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},Xy={class:"min-h-0 min-w-0 overflow-hidden"},Yy={class:"min-h-0 min-w-0 overflow-hidden"},Jy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Qy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},Zy={class:"flex flex-col gap-2"},eS={class:"min-h-0 flex-1 overflow-hidden"},tS={key:1,class:"min-h-0 flex-1 overflow-hidden"},nS={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},sS={class:"workbench-mobile-tabs-panel shrink-0"},oS={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},rS={class:"min-h-0 flex-1 overflow-hidden"},aS={class:"h-full min-h-0"},iS={class:"h-full min-h-0"},lS={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},uS={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},cS={class:"flex flex-col gap-2"},dS={class:"min-h-0 flex-1 overflow-hidden"},fS="/sounds/notify-didi.wav?v=20260420-1",pS=3e3,Wr="promptx:selected-agent-engine-map",mS={__name:"WorkbenchView",setup(e){const t=j(!1),n=j(!1),o=j(!1),s=j(!1),r=j(!1),l=j(!1),u=j(!1),m=j(!1),k=j(""),d=j(""),T=j(""),h=j(0),g=j("workspace"),f=j(""),{t:P}=Lt(),{toastMessage:ee,toastType:v,flashToast:B,clearToast:K}=wy(),{notificationSoundEnabled:V,sendBehavior:O}=Za(),se=Ro(()=>He(()=>import("./TaskDiffReviewDialog-D2l8KtRI.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),A=Ro(()=>He(()=>import("./WorkbenchSettingsDialog-DGj-_tuL.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),X=j(null),ge=j([]);function Se(){try{const S=JSON.parse(window.localStorage.getItem(Wr)||"{}");if(S&&typeof S=="object"&&!Array.isArray(S))return S}catch{}return{}}function L(S){window.localStorage.setItem(Wr,JSON.stringify(S))}const ne=j(Se());let le=null,te=!1,ye=0;function C(S="",Y=ge.value){const _e=String(S||"").trim();return _e&&Y.some(ke=>(ke==null?void 0:ke.engine)===_e)?_e:""}function W(S=ge.value){var Y,_e;return((Y=S.find(ke=>ke==null?void 0:ke.isDefault))==null?void 0:Y.engine)||((_e=S[0])==null?void 0:_e.engine)||""}const D=q({get(){const S=String(he.value||"").trim();if(!S)return"";const Y=String(ne.value[S]||"").trim();return Y||W()},set(S){const Y=String(he.value||"").trim(),_e=String(S||"").trim();!Y||!_e||(ne.value={...ne.value,[Y]:_e},L(ne.value))}});function Ae(S){return S?X.value:null}function Pe(){dt(()=>{var S,Y;(Y=(S=Ae(he.value))==null?void 0:S.scrollToBottom)==null||Y.call(S)})}const{addCurrentDraftToTodo:Ne,applyTaskSettingsUpdate:Je,buildPromptForTask:Qe,getPromptBlocksForTask:We,clearCurrentTaskContent:be,createTaskAndSelect:H,creatingTask:Z,currentProjectSessionId:me,currentTaskSendState:Ce,currentTaskAutoTitle:fe,currentTaskDisplayTitle:Me,currentTaskSlug:he,draft:Be,editorRef:ze,error:Le,handleImportPdfFiles:wt,handleImportTextFiles:Ye,handleTaskSendingChange:bt,handleTaskSessionChange:Ge,handleUpload:lt,hasCurrentDraftContent:it,hasUnsavedChanges:kt,hasUnreadTaskUpdates:pt,initializeWorkbench:gt,isCurrentTaskSending:$,loadingTask:I,loadingTasks:oe,pageTitle:Ie,prepareCodexPromptForTask:Re,currentTodoItems:De,removeTodoItem:Ze,removeCurrentTask:Ue,reorderTaskList:_t,removingTask:yt,renderedTasks:Dt,saveTask:et,saving:Xt,selectTask:sn,unreadNotificationVersion:Yt,updateLastPromptPreview:re,useTodoItem:je,uploading:tt}=qy({clearToast:K,flashToast:B,scrollCurrentPanelToBottom:Pe}),ot=q(()=>Dt.value.find(S=>S.slug===he.value)||null),qt=q(()=>pt.value?P("workbench.newMessageTitle"):Ie.value),z=q(()=>pt.value),Q=q(()=>{var S,Y;return!!((Y=(S=ot.value)==null?void 0:S.workspaceDiffSummary)!=null&&Y.supported)}),ce=q(()=>{const S=ot.value;return S?()=>Re(S.slug):null}),xe=q(()=>{const S=ot.value;return S?()=>We(S.slug):null}),qe=q(()=>({creatingTask:Z.value,currentTaskAutoTitle:Be.value.autoTitle||fe.value,currentTaskSlug:he.value,draftTitle:Be.value.title,editingTaskTitleSlug:T.value,error:Le.value,isCurrentTaskSending:$.value,loadingTask:I.value,loadingTasks:oe.value,removingTask:yt.value,tasks:Dt.value,uploading:tt.value})),Tt=q(()=>{var S,Y,_e,ke;return{buildPromptBlocks:xe.value,buildPrompt:ce.value,diffSupported:Q.value,selectedAgentEngine:D.value,selectedSessionId:me.value,sessionSelectionLockReason:((S=ot.value)==null?void 0:S.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((Y=ot.value)!=null&&Y.sessionSelectionLocked),taskSlug:((_e=ot.value)==null?void 0:_e.slug)||"",taskRunning:!!((ke=ot.value)!=null&&ke.running)}}),Kt=q(()=>({codexSessionId:me.value,sendBehavior:O.value,loading:I.value})),Ut=q(()=>({currentTaskAutoTitle:Be.value.autoTitle||fe.value,currentTaskSlug:he.value,editingTaskTitleSlug:T.value,title:Me.value,titleInputValue:Be.value.title})),{enterMobileDetail:Bt,isMobileLayout:Rt,leaveMobileDetail:Tn,mobileDetailTab:Et,mobileView:gn}=hy({currentTaskSlug:he});function hn(S){return S!=null&&S.sending||Number((S==null?void 0:S.codexRunCount)||0)>0?"activity":"input"}yy(qt,{raw:z});function cn(){return typeof window>"u"?null:(le||(le=new Audio(fS),le.preload="auto",le.volume=.7),le)}function _n(){if(!V.value)return;const S=cn();if(!(!S||te))try{S.muted=!0;const Y=S.play();if(Y&&typeof Y.then=="function"){Y.then(()=>{S.pause(),S.currentTime=0,S.muted=!1,te=!0}).catch(()=>{S.muted=!1});return}S.pause(),S.currentTime=0,S.muted=!1,te=!0}catch{S.muted=!1}}function vn(){_n()}function On(){const S=cn();if(!S||!V.value)return;const Y=Date.now();if(!(Y-ye<pS)){ye=Y;try{S.muted=!1,S.currentTime=0,S.play().catch(()=>{})}catch{}}}function dn(S="workspace",Y=""){g.value=S==="run"?"run":S==="task"?"task":"workspace",f.value=g.value==="run"?String(Y||""):"",o.value=!0,h.value+=1}function yn(){o.value=!1}function Cn(){s.value=!0}function En(){s.value=!1}function An(){he.value&&(r.value=!0)}function fn(){r.value=!1}function _(){l.value=!0}function x(){l.value=!1,F(),ae()}function F(){u.value=!1,k.value=""}function ae(){m.value=!1,d.value=""}function ie(S){Je(S)}function ve(S){Be.value.title=S}async function ut(){T.value="",kt.value&&await et({auto:!1,silent:!0})}function Oe(S){S===he.value&&(T.value=S,dt(()=>{var _e,ke;const Y=document.querySelector('[data-task-title-input="current"]');(_e=Y==null?void 0:Y.focus)==null||_e.call(Y),(ke=Y==null?void 0:Y.select)==null||ke.call(Y)}))}async function Jt(S){if(Rt.value){await rn(S);return}if(S!==he.value){await rn(S);return}Oe(S)}function on(){n.value=!0}function Sn(){yt.value||(n.value=!1)}async function In(){await Ue(),n.value=!1,Rt.value&&Tn({useHistory:!1})}function Ot(){t.value=!0}function Qt(){t.value=!1}function At(){t.value=!1,be()}function y(S){const Y=ot.value;Y&&bt(Y.slug,S)}function N(S){const Y=ot.value;Y&&Ge(Y.slug,S)}function M(S={}){const Y=String((S==null?void 0:S.sessionId)||"").trim(),_e=me.value;if(Y&&Y!==_e)return;const ke=Array.isArray(S==null?void 0:S.bindings)?S.bindings:[];ge.value=ke;const nt=String(he.value||"").trim();if(!nt)return;const ct=String(ne.value[nt]||"").trim();if(ct&&ke.some(Vt=>(Vt==null?void 0:Vt.engine)===ct)){D.value!==ct&&(D.value=ct);return}const ht=C(S==null?void 0:S.selectedEngine,ke)||W(ke);ht&&D.value!==ht&&(D.value=ht)}$e(me,(S,Y)=>{String(S||"").trim()!==String(Y||"").trim()&&(ge.value=[])});function we(S){D.value=S}function Ke(S){B(S),!(!Rt.value||!he.value)&&(Et.value="activity")}async function xt(){var S,Y,_e,ke,nt,ct,ht,Vt;typeof document<"u"&&((Y=(S=ze.value)==null?void 0:S.isComposing)!=null&&Y.call(S))&&((ke=(_e=document.activeElement)==null?void 0:_e.blur)==null||ke.call(_e)),(ct=(nt=ze.value)==null?void 0:nt.flushPendingInput)==null||ct.call(nt),await dt(),(Vt=(ht=ze.value)==null?void 0:ht.flushPendingInput)==null||Vt.call(ht),await dt()}async function Zt(){await xt(),await navigator.clipboard.writeText(Qe(he.value)),B({message:P("workbench.promptCopied"),type:"info"})}async function jt(){await H()&&Rt.value&&(Et.value="input",Bt())}async function rn(S){const Y=String(S||"").trim();Y&&(Y!==he.value&&await sn(Y),Rt.value&&he.value===Y&&(Et.value=hn(ot.value),Bt()))}async function an(S=[]){await _t(S)}async function Xn(){await xt(),Ne()}function pn(S={}){const Y=String((S==null?void 0:S.rangeLabel)||"").trim();if(Y)return Y;const _e=Math.max(0,Number(S==null?void 0:S.lineStart)||0),ke=Math.max(0,Number(S==null?void 0:S.lineEnd)||0);return _e&&ke&&_e!==ke?`L${_e}-L${ke}`:_e||ke?`L${_e||ke}`:""}function Yn(S=""){return`code-context-${String(S||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function Jn(S={}){const Y=String((S==null?void 0:S.filePath)||"").trim(),_e=String((S==null?void 0:S.content)||"").replace(/\r\n/g,`
56
+ `).trimEnd();if(!Y||!_e.trim())return null;const ke=String((S==null?void 0:S.language)||"").trim(),nt=pn(S),ct=String((S==null?void 0:S.source)||"").trim()==="diff"?P("workbench.codeContextSourceDiff"):P("workbench.codeContextSourceFile"),ht=ke?`\`\`\`${ke}`:"```",Vt=[P("workbench.codeContextTitle"),P("workbench.codeContextFile",{path:Y}),nt?P("workbench.codeContextRange",{range:nt}):"",P("workbench.codeContextSource",{source:ct}),"",ht,_e,"```"].filter(Fn=>Fn!=="");return{type:Pt.IMPORTED_TEXT,content:Vt.join(`
57
+ `),meta:{fileName:Yn(Y),collapsed:!1}}}async function ms(S=[],Y="insertBlocks"){var ke,nt,ct,ht;const _e=Array.isArray(S)?S.filter(Boolean):[];return _e.length?(await xt(),(nt=(ke=ze.value)==null?void 0:ke[Y])==null||nt.call(ke,_e),await dt(),(ht=(ct=ze.value)==null?void 0:ct.focusEditor)==null||ht.call(ct),Rt.value&&he.value&&(Et.value="input"),B({message:P("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function gs(S={}){const Y=String((S==null?void 0:S.source)||"").trim(),_e=Array.isArray(S==null?void 0:S.blocks)?S.blocks.filter(Boolean):[],ke=String((S==null?void 0:S.content)||"").replace(/\r\n/g,`
58
+ `).trim();if(Y==="response"){if(_e.length){await ms(_e,"insertBlocks");return}if(!ke)return;await ms([os(ke)],"insertBlocks");return}const nt=Jn(S);nt&&await ms([nt],"insertImportedBlocks")}function $n(S){k.value=String(S||"").trim(),u.value=!!k.value}function hs(){k.value&&(Ze(k.value),F())}async function Qn(S=d.value){const Y=String(S||"").trim();return!Y||!je(Y)?!1:(ae(),x(),!0)}async function vs(S){await xt();const Y=String(S||"").trim();if(Y){if(!it.value){await Qn(Y);return}d.value=Y,m.value=!0}}async function en(){var ke,nt,ct,ht;const S=he.value;if(!S)return;const Y=!!((nt=(ke=ot.value)==null?void 0:ke.automation)!=null&&nt.enabled);await xt(),re(S,Qe(S)),!(!await((ht=(ct=Ae(S))==null?void 0:ct.send)==null?void 0:ht.call(ct))||S!==he.value)&&(Rt.value&&(Et.value="activity"),Y||be({silent:!0}),await et({auto:!1,silent:!0}))}function ho(){!Rt.value||gn.value!=="detail"||Et.value!=="input"||!he.value||dt(()=>{var S,Y;(Y=(S=ze.value)==null?void 0:S.focusEditor)==null||Y.call(S)})}function ys(S){!kt.value&&!tt.value&&!Xt.value||(S.preventDefault(),S.returnValue="")}function Zn(){var S,Y;return m.value?(ae(),!0):u.value?(F(),!0):t.value?(Qt(),!0):n.value?(Sn(),!0):r.value?(fn(),!0):l.value?(x(),!0):o.value?(yn(),!0):s.value?(En(),!0):!!((Y=(S=Ae(he.value))==null?void 0:S.closeTopDialog)!=null&&Y.call(S))}function Pn(S){var nt,ct,ht,Vt,Fn;const Y=String(S.key||""),_e=Y.toLowerCase(),ke=S.metaKey||S.ctrlKey;if(Y==="Escape"){Zn()&&(S.preventDefault(),(nt=S.stopImmediatePropagation)==null||nt.call(S));return}if(ke){if(_e==="s"){S.preventDefault(),et({auto:!1});return}if(S.shiftKey&&Y==="Backspace"){S.preventDefault(),Ot();return}if(!S.isComposing){if(S.shiftKey&&S.code==="Comma"){S.preventDefault(),Cn();return}if(S.shiftKey&&_e==="k"){S.preventDefault(),(ht=(ct=Ae(he.value))==null?void 0:ct.openProjectManager)==null||ht.call(ct);return}if(S.shiftKey&&_e==="o"){S.preventDefault(),(Fn=(Vt=Ae(he.value))==null?void 0:Vt.openSourceBrowser)==null||Fn.call(Vt);return}S.shiftKey&&_e==="d"&&(S.preventDefault(),Q.value&&dn("workspace"))}}}kn(()=>{gt(),window.addEventListener("beforeunload",ys),window.addEventListener("keydown",Pn),window.addEventListener("pointerdown",vn,{passive:!0})}),Nt(()=>{window.removeEventListener("beforeunload",ys),window.removeEventListener("keydown",Pn),window.removeEventListener("pointerdown",vn)}),$e([Rt,gn,Et,he],([S,Y,_e,ke])=>{!S||Y!=="detail"||_e!=="input"||!ke||ho()}),$e(Yt,(S,Y)=>{Number(S)<=Number(Y||0)||On()});const Rs={"update:draftTitle":ve,"cancel-title-edit":()=>{T.value=""},"create-task":jt,"edit-task":An,"delete-task":on,"open-settings":Cn,"reorder-task":an,"select-task":rn,"title-blur":ut,"title-click":Jt},Ns={"agent-bindings-change":M,"insert-code-context":gs,"open-diff":({scope:S,runId:Y})=>dn(S,Y),"project-created":()=>B({message:P("workbench.projectCreated"),type:"success"}),"selected-session-change":N,"update:selectedAgentEngine":we,"sending-change":y,toast:Ke},Ss={"clear-request":Ot,"file-feedback":S=>B({message:S,type:"warning"}),"import-pdf-files":wt,"import-text-files":Ye,"send-request":en,"upload-files":lt},vo={"begin-edit":()=>Oe(he.value),back:Tn,"cancel-title-edit":()=>{T.value=""},"title-blur":ut,"update:titleInputValue":ve};return(S,Y)=>(p(),b("div",Ky,[ue(py,{message:a(ee),type:a(v)},null,8,["message","type"]),ue(Fs,{open:t.value,title:a(P)("workbench.confirmClearTitle"),description:a(P)("workbench.confirmClearDescription"),"confirm-text":a(P)("workbench.confirmClearAction"),"cancel-text":a(P)("workbench.continueEditing"),onCancel:Qt,onConfirm:At},null,8,["open","title","description","confirm-text","cancel-text"]),ue(Fs,{open:n.value,title:a(P)("workbench.confirmDeleteTitle"),description:a(P)("workbench.confirmDeleteDescription",{title:a(Me)}),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),loading:a(yt),danger:"",onCancel:Sn,onConfirm:In},null,8,["open","title","description","confirm-text","cancel-text","loading"]),ue(Fs,{open:u.value,title:a(P)("workbench.confirmDeleteTodoTitle"),description:a(P)("workbench.confirmDeleteTodoDescription"),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),danger:"",onCancel:F,onConfirm:hs},null,8,["open","title","description","confirm-text","cancel-text"]),ue(Fs,{open:m.value,title:a(P)("workbench.replaceEditorTitle"),description:a(P)("workbench.replaceEditorDescription"),"confirm-text":a(P)("workbench.confirmReplaceAction"),"cancel-text":a(P)("workbench.dontReplaceYet"),onCancel:ae,onConfirm:Y[0]||(Y[0]=_e=>Qn())},null,8,["open","title","description","confirm-text","cancel-text"]),ue(dy,{open:l.value,items:a(De),onClose:x,onDelete:$n,onUse:vs},null,8,["open","items"]),ue(a(se),{open:o.value,"task-slug":a(he),"task-title":a(Me),"preferred-scope":g.value,"preferred-run-id":f.value,"focus-token":h.value,onInsertCodeContext:gs,onClose:yn},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),ue(a(A),{open:s.value,onClose:En},null,8,["open"]),ue(oc,{open:r.value,"task-slug":a(he),"task-title":a(Me),onClose:fn,onSaved:ie},null,8,["open","task-slug","task-title"]),a(Rt)?(p(),b("div",tS,[a(gn)==="tasks"?(p(),Ee(jr,Un({key:0},qe.value,{mobile:""},jn(Rs)),null,16)):(p(),b("div",nS,[ue(lv,Un(Ut.value,jn(vo)),null,16),i("section",sS,[i("div",oS,[i("button",{type:"button",class:Te(["tool-button px-3 py-1.5 text-sm",a(Et)==="activity"?"tool-button-accent-subtle":""]),onClick:Y[3]||(Y[3]=_e=>Et.value="activity")},w(a(P)("workbench.activity")),3),i("button",{type:"button",class:Te(["tool-button px-3 py-1.5 text-sm",a(Et)==="input"?"tool-button-accent-subtle":""]),onClick:Y[4]||(Y[4]=_e=>Et.value="input")},w(a(P)("workbench.input")),3)])]),i("div",rS,[ln(i("div",aS,[ue(Mr,Un({ref_key:"codexPanelRef",ref:X},Tt.value,{"empty-message":a(P)("workbench.selectTask")},jn(Ns)),null,16,["empty-message"])],512),[[eo,a(Et)==="activity"]]),ln(i("div",iS,[i("div",lS,[i("div",uS,[i("div",cS,[ue(Rr,{"can-add-todo":a(it),"is-current-task-sending":a($),"send-state":a(Ce),"todo-count":a(De).length,uploading:a(tt),onAddTodo:Xn,onOpenFilePicker:Y[5]||(Y[5]=_e=>{var ke,nt;return(nt=(ke=a(ze))==null?void 0:ke.openFilePicker)==null?void 0:nt.call(ke)}),onClearRequest:Ot,onCopyRequest:Zt,onManageTodo:_,onSendRequest:en},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(Br,{"agent-bindings":ge.value,"selected-agent-engine":D.value,"onUpdate:selectedAgentEngine":we},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",dS,[ue(Ur,Un({ref_key:"editorRef",ref:ze,modelValue:a(Be).blocks,"onUpdate:modelValue":Y[6]||(Y[6]=_e=>a(Be).blocks=_e)},Kt.value,jn(Ss)),null,16,["modelValue"])])])],512),[[eo,a(Et)==="input"]])])]))])):(p(),b("div",Wy,[ue(jr,Un(qe.value,jn(Rs)),null,16),i("div",Gy,[i("div",Xy,[ot.value?(p(),Ee(Mr,Un({key:0,ref_key:"codexPanelRef",ref:X},Tt.value,jn(Ns)),null,16)):de("",!0)]),i("div",Yy,[i("div",Jy,[i("div",Qy,[i("div",Zy,[ue(Rr,{"can-add-todo":a(it),"is-current-task-sending":a($),"send-state":a(Ce),"todo-count":a(De).length,uploading:a(tt),onAddTodo:Xn,onOpenFilePicker:Y[1]||(Y[1]=_e=>{var ke,nt;return(nt=(ke=a(ze))==null?void 0:ke.openFilePicker)==null?void 0:nt.call(ke)}),onClearRequest:Ot,onCopyRequest:Zt,onManageTodo:_,onSendRequest:en},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(Br,{"agent-bindings":ge.value,"selected-agent-engine":D.value,align:"end","onUpdate:selectedAgentEngine":we},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",eS,[ue(Ur,Un({ref_key:"editorRef",ref:ze,modelValue:a(Be).blocks,"onUpdate:modelValue":Y[2]||(Y[2]=_e=>a(Be).blocks=_e)},Kt.value,jn(Ss)),null,16,["modelValue"])])])])])]))]))}},PS=Object.freeze(Object.defineProperty({__proto__:null,default:mS},Symbol.toStringTag,{value:"Module"}));export{wS as A,PS as B,AS as D,Ws as W,No as _,xa as a,CS as b,Sa as c,Dc as d,Ic as e,my as f,_S as g,xn as h,IS as i,mo as j,st as k,Ol as l,ul as m,xS as n,Id as o,Oo as p,kS as q,$S as r,TS as s,St as t,Aa as u,ac as v,Fs as w,ES as x,oo as y,bS as z};